"use strict";
/**
 * "Improve this agent" — the ASI coverage entries must carry per-area
 * remediation (what's wrong + how to fix), so the portal can turn a scan into an
 * actionable improvement plan with concrete code/config to inject.
 *
 * Red → Green: before this, AsiCoverageEntry carried only counts/severity, so the
 * remediation strings the scanner already produces never reached the UI. Now each
 * entry exposes its findings' remediation text.
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = require("node:test");
const strict_1 = __importDefault(require("node:assert/strict"));
const owasp_agentic_scanner_js_1 = require("./owasp-agentic-scanner.js");
(0, node_test_1.describe)('ASI coverage carries remediation for the "Improve this agent" surface', () => {
    (0, node_test_1.it)('an agent with no governance hooks exposes hook-wiring remediation on an ASI entry', () => {
        const report = (0, owasp_agentic_scanner_js_1.scanAgent)({
            agentId: 'improve-test',
            name: 'no-hooks-bot',
            tools: ['shell_exec', 'network_request', 'file_write'],
            hooks: { preToolUse: false, postToolUse: false, postResponse: false },
            llmProvider: 'anthropic',
            killSwitchCapable: true,
        });
        const withRemediation = report.asiCoverage.filter((e) => e.remediations.length > 0);
        strict_1.default.ok(withRemediation.length > 0, 'at least one ASI area must carry remediation');
        // Every remediation entry must have the actionable fields.
        for (const e of withRemediation) {
            for (const r of e.remediations) {
                strict_1.default.equal(typeof r.title, 'string');
                strict_1.default.equal(typeof r.detail, 'string');
                strict_1.default.ok(r.remediation.length > 0, `remediation text present for ${e.asi}`);
            }
        }
        // The hook-wiring fix (the most common build-axis gap) must be discoverable.
        const all = withRemediation.flatMap((e) => e.remediations.map((r) => r.remediation.toLowerCase()));
        strict_1.default.ok(all.some((r) => r.includes('hook')), 'hook-wiring remediation must be present');
    });
    (0, node_test_1.it)('remediation count matches the per-area finding count', () => {
        const report = (0, owasp_agentic_scanner_js_1.scanAgent)({
            agentId: 'improve-test-2',
            name: 'bot',
            tools: ['Read'],
            hooks: { preToolUse: false, postToolUse: false, postResponse: false },
            llmProvider: 'anthropic',
            killSwitchCapable: true,
        });
        for (const e of report.asiCoverage) {
            strict_1.default.equal(e.remediations.length, e.findingCount, `ASI ${e.asi}: remediations should match findingCount`);
        }
    });
});
//# sourceMappingURL=asi-remediation-flow.test.js.map