"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.callBuilderLLM = callBuilderLLM;
const llm_1 = require("../../../../services/llm");
const defaults_1 = require("../../../../modules/defaults");
const logger_1 = require("../../../../lib/logger");
/**
 * Call the LLM for workflow building.
 *
 * Uses a higher max_tokens than the shared caller because the builder
 * returns complete YAML + manifest JSON (typically 2000-4000 tokens).
 */
const BUILDER_MAX_TOKENS = 4096;
async function callBuilderLLM(messages, _toolIds) {
    const t0 = Date.now();
    const response = await (0, llm_1.callLLM)({
        model: defaults_1.LLM_MODEL_PRIMARY,
        messages,
        temperature: 0,
        max_tokens: BUILDER_MAX_TOKENS,
    });
    const usage = response.usage;
    logger_1.loggerRegistry.info(`[workflowBuilder:callLLM] ${Date.now() - t0}ms | in=${usage?.prompt_tokens} out=${usage?.completion_tokens} total=${usage?.total_tokens} | tool_calls=${response.tool_calls?.length || 0}`);
    return response;
}
