"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleArgumentCorrectness = void 0;
const path_1 = __importDefault(require("path"));
const pythonUtils_1 = require("../../python/pythonUtils");
const util_1 = require("./util");
const handleArgumentCorrectness = async ({ assertion, outputString, test, context, workspaceId, }) => {
    context.vars = { ...(context.test?.vars ?? {}), ...(context.vars ?? {}) };
    const { vars: mergedVars, outputString: resolvedOutputString } = (0, util_1.applyTraceFromOutputString)(outputString, context.vars);
    context.vars = mergedVars;
    context.trusys = {
        tool_calls: Array.isArray(mergedVars.tool_calls) ? mergedVars.tool_calls : [],
        agent_calls: Array.isArray(mergedVars.agent_calls) ? mergedVars.agent_calls : [],
        tool_definitions: Array.isArray(mergedVars.tool_definitions) ? mergedVars.tool_definitions : [],
        agent_definitions: Array.isArray(mergedVars.agent_definitions) ? mergedVars.agent_definitions : [],
        plan: mergedVars.plan ?? '',
        prompt: mergedVars.prompt ?? context.prompt ?? '',
    };
    const pythonScriptPath = path_1.default.join(__dirname, '..', 'python', 'argument_correctness.py');
    const pythonScriptOutput = await (0, pythonUtils_1.runPython)(pythonScriptPath, 'get_assert', [
        resolvedOutputString,
        context,
    ]);
    return {
        assertion,
        ...pythonScriptOutput,
    };
};
exports.handleArgumentCorrectness = handleArgumentCorrectness;
//# sourceMappingURL=argumentCorrectness.js.map