/** Dev-tool: deterministic report of registry kinds and each contract's approval evaluation. */
export function buildToolContractReport(registry, samplesByKind = {}) {
    const entries = [];
    for (const kind of registry.kinds) {
        const contract = registry.get(kind);
        if (!contract) {
            continue;
        }
        const sample = samplesByKind[kind] ?? { params: {} };
        entries.push(buildEntry(contract, sample));
    }
    return {
        entries,
        kinds: registry.kinds
    };
}
function buildEntry(contract, sample) {
    const sampleParamsValid = contract.validateParams(sample.params);
    const sampleResultDetailsValid = contract.validateResultDetails(sample.resultDetails);
    const approvalSamples = [];
    if (sampleParamsValid) {
        for (const autoApprove of [false, true]) {
            const requirement = contract.evaluateApproval(sample.params, { autoApprove });
            approvalSamples.push({
                autoApprove,
                reason: requirement.reason,
                required: requirement.required
            });
        }
    }
    return {
        approvalSamples,
        kind: contract.kind,
        sampleParams: sample.params,
        sampleParamsValid,
        sampleResultDetailsValid
    };
}
export function formatToolContractReport(report) {
    const header = `HostTool registry: ${report.kinds.length} kind${report.kinds.length === 1 ? '' : 's'}`;
    const lines = [header, ''];
    for (const entry of report.entries) {
        lines.push(`- ${entry.kind}`);
        lines.push(`    sample params valid: ${entry.sampleParamsValid}`);
        lines.push(`    sample result details valid: ${entry.sampleResultDetailsValid}`);
        for (const sample of entry.approvalSamples) {
            const reasonSuffix = sample.reason ? ` (${sample.reason})` : '';
            lines.push(`    approval[autoApprove=${sample.autoApprove}]: ${sample.required}${reasonSuffix}`);
        }
    }
    return lines.join('\n');
}
//# sourceMappingURL=contract-report.js.map