donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
35 lines • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AgentsApi = void 0;
const DonobuAgentType_1 = require("../models/DonobuAgentType");
const InvalidParamValueException_1 = require("../exceptions/InvalidParamValueException");
/**
* This API manages the mapping of Donobu agents to GPT configurations.
*/
class AgentsApi {
constructor(agentsManager) {
this.agentsManager = agentsManager;
}
async set(req, res) {
const gptConfigNameBody = req.body;
const agentName = req.params.name;
if (!DonobuAgentType_1.DonobuAgent.includes(agentName)) {
throw new InvalidParamValueException_1.InvalidParamValueException('/api/agents/:name', agentName);
}
await this.agentsManager.set(agentName, gptConfigNameBody.gptConfigName ?? null);
res.json(gptConfigNameBody);
}
async get(req, res) {
const agentName = req.params.name;
const gptConfigName = await this.agentsManager.get(agentName);
res.json({
gptConfigName: gptConfigName,
});
}
async getAll(_req, res) {
const agentsMapping = await this.agentsManager.getAll();
res.json(Object.fromEntries(agentsMapping));
}
}
exports.AgentsApi = AgentsApi;
//# sourceMappingURL=AgentsApi.js.map