"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handlePlanAdherence = handlePlanAdherence;
const matchers_1 = require("../../matchers");
const invariant_1 = __importDefault(require("../../util/invariant"));
const logger_1 = __importDefault(require("../../logger"));
const util_1 = require("./util");
async function handlePlanAdherence({ assertion, test, output, prompt, }) {
    const vars = { ...(test?.vars ?? {}) };
    const { task, plan, trace } = (0, util_1.getResolvedTrace)(output, vars, prompt);
    logger_1.default.debug(`plan-adherence: task length=${task.length}, plan length=${plan.length}, trace count=${Array.isArray(trace) ? trace.length : 'n/a'}`);
    (0, invariant_1.default)(typeof task === 'string', 'plan-adherence requires a task (prompt) in test.vars or output.trusys');
    (0, invariant_1.default)(typeof plan === 'string' && plan.length > 0, 'plan-adherence requires a plan in test.vars or output.trusys.plan');
    (0, invariant_1.default)(trace !== undefined && Array.isArray(trace), 'plan-adherence requires tool_calls or agent_calls in test.vars or output.trusys');
    return {
        assertion,
        ...(await (0, matchers_1.matchesPlanAdherence)(task, plan, trace, test.options)),
    };
}
//# sourceMappingURL=planAdherence.js.map