UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

41 lines • 1.52 kB
/** A catalog that answers the same view to everyone — for a fixed list of models. */ export function staticModelCatalog(view) { return { list: () => view }; } /** Accept a catalog or a fixed view (the `config/agent.ts` shorthand). */ export function toModelCatalog(value) { return typeof value.list === 'function' ? value : staticModelCatalog(value); } /** The entry `id` names in `view`, or `undefined`. */ export function findCatalogModel(view, id) { for (const group of view.providers) { const found = group.models.find((model) => model.id === id); if (found !== undefined) return found; } return undefined; } /** * A provider that runs every turn on `model` — what the loop wraps the bound provider in when a * turn has a selected model, so every call it makes (the answer, a structured-output pass, the * follow-up suggestions) goes to the same one. A provider that does not read `args.model` runs its * own default, unchanged. */ export function withSelectedModel(provider, model) { return { runTurn: (args) => provider.runTurn({ ...args, model }), }; } /** * A request named a model the catalog does not offer to this caller right now — or there is no * catalog to offer one. The routes answer `400` with its message. */ export class ModelNotAllowedError extends Error { constructor(message) { super(message); this.name = 'ModelNotAllowedError'; } } //# sourceMappingURL=model-catalog.js.map