"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handlePlanCorrectness = handlePlanCorrectness;
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 handlePlanCorrectness({ assertion, test, output, prompt, }) {
    const vars = { ...(test?.vars ?? {}) };
    const { task, plan, definitions } = (0, util_1.getResolvedTrace)(output, vars, prompt);
    logger_1.default.debug(`plan-correctness: task length=${task.length}, definitions present=${Array.isArray(definitions) ? definitions.length : 'n/a'}, plan length=${plan.length}`);
    (0, invariant_1.default)(typeof task === 'string', 'plan-correctness requires a task (prompt) in test.vars or output.trusys');
    (0, invariant_1.default)(typeof plan === 'string' && plan.length > 0, 'plan-correctness requires a plan in test.vars or output.trusys.plan');
    (0, invariant_1.default)(definitions !== undefined && Array.isArray(definitions), 'plan-correctness requires tool_definitions or agent_definitions in test.vars or output.trusys');
    return {
        assertion,
        ...(await (0, matchers_1.matchesPlanCorrectness)(task, definitions, plan, test.options)),
    };
}
//# sourceMappingURL=planCorrectness.js.map