@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
35 lines • 1.69 kB
JavaScript
export { DEV_TOOLS_BINDING, DEV_TOOLS_VERSION } from './contract.js';
export { DEV_TOOLS_FIELD_BYTES, DEV_TOOLS_MAX_BYTES, DEV_TOOLS_MAX_ROWS, truncateText, } from './limits.js';
export { validateDevToolInput } from './schema.js';
/**
* Register a lib's tools when the app serves dev tools: a no-op (`false`) when
* `@adonis-agora/agent/mcp_provider` is not registered, when `devTools: false`, or when the hub
* speaks another contract version. Call it from the provider's `boot()`, after the console config is
* resolved, and only when the console is enabled.
*
* Copy it into the lib (it is the whole integration):
*
* ```ts
* async function registerDevTools(app: DevToolsAppLike, lib: DevToolsLib): Promise<boolean> {
* if (!app.container.hasBinding('agora.devTools')) return false
* const hub = (await app.container.make('agora.devTools')) as Partial<DevToolsHub> | undefined
* if (hub?.version !== 1 || typeof hub.register !== 'function') return false
* // A lib with no console registers without `authorize`: only on a hub that gates it itself.
* if (lib.authorize === undefined && hub.supports?.('endpoint-authorize') !== true) return false
* hub.register(lib)
* return true
* }
* ```
*/
export async function registerDevTools(app, lib) {
if (!app.container.hasBinding('agora.devTools'))
return false;
const hub = (await app.container.make('agora.devTools'));
if (hub?.version !== 1 || typeof hub.register !== 'function')
return false;
if (lib.authorize === undefined && hub.supports?.('endpoint-authorize') !== true)
return false;
hub.register(lib);
return true;
}
//# sourceMappingURL=index.js.map