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