@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
27 lines • 1.5 kB
JavaScript
/**
* Refuse a wiring that cannot run a turn, at boot rather than on the first message: no `model` and
* no `engine` leaves the loop nothing to call, and `durable: true` names the loop's own durable
* runner, which a non-durable engine replaces (a durable engine brings its own durability).
*/
export function assertRunnable(options) {
const { engine } = options;
if (engine !== undefined && options.durable === true && engine.durable !== true) {
throw new Error(`[@adonis-agora/agent] \`durable: true\` runs turns on the library's loop, but the \`${engine.name}\` engine runs them instead. Drop \`durable\`, or use the engine's durable variant.`);
}
if (engine === undefined && options.model === undefined) {
throw new Error('[@adonis-agora/agent] set `model` in config/agent.ts (the loop runs the turns) or `engine` (something else does).');
}
}
/**
* The model the loop is handed when an engine runs the turns and no `model` is configured: nothing
* of the library's calls it on that path, and a caller that does (a background summarizer reading
* `deps.model`) is told why instead of crashing on `undefined`.
*/
export function engineOnlyModel(engine) {
return {
async runTurn() {
throw new Error(`[@adonis-agora/agent] the \`${engine.name}\` engine runs this deployment's turns and no \`model\` is configured; set \`model\` for anything that calls the loop's model directly.`);
},
};
}
//# sourceMappingURL=engine.js.map