"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.agentCall = agentCall;
const config_1 = require("../../config");
const services_1 = require("../../services");
const types_1 = require("../../types");
async function agentCall(agentName, userInput) {
    return new Promise(async (resolve, reject) => {
        const config = await (0, config_1.getConfig)();
        const toolService = (this instanceof services_1.ToolsService ? this : (0, services_1.services)().Tools);
        const { Events, Plugins } = toolService.getContext();
        let fullPrompt = `${userInput}`;
        const enabledPlugins = (0, types_1.getEnabledPlugins)(config.plugins);
        if (enabledPlugins?.length) {
            const pluginText = await Plugins.callMany(enabledPlugins, userInput);
            fullPrompt += `\n ${pluginText}`;
        }
        Events.emit("agents:call", {
            name: agentName,
            query: fullPrompt,
            resolve,
            reject,
        });
    });
}
//# sourceMappingURL=agentCall.js.map