UNPKG

@adonis-agora/agent

Version:

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

36 lines • 2.43 kB
import type { ApplicationService } from '@adonisjs/core/types'; import { type FunctionalTool } from './ai-tool-ref.js'; import type { ToolRegistry } from './tool-registry.js'; /** A tool registered at boot, echoed back so the provider can log what it wired. */ export interface RegisteredTool { name: string; source: 'class' | 'functional'; } /** * Register one module export into the registry if it is an `@AiTool` class or a `defineTool(...)` * functional tool; ignore anything else. A name already present is skipped (first wins). Returns the * registered descriptor, or `null` when the export was not a tool / duplicated a registered name. */ export declare function registerToolExport(registry: ToolRegistry, exported: unknown, defaultRoles: string[], app?: ApplicationService): RegisteredTool | null; /** Register a `defineTool` functional tool, applying `defaultRoles` when it declares none. */ export declare function registerFunctionalTool(registry: ToolRegistry, tool: FunctionalTool, defaultRoles: string[]): RegisteredTool | null; /** * Scan `dir` RECURSIVELY for modules and register every exported `@AiTool` class / `defineTool` * tool into `registry` — the `app/agent_tools` convention. Only the environment-appropriate extension * is imported and each export is visited once (deduped), so a built `.js` and a dev `.ts` of the same * module never both register. Missing directory → no-op (the convention is opt-in). `defaultRoles` * fills a tool that declares no `roles` (`[]` by default: unrestricted). */ export declare function discoverTools(registry: ToolRegistry, dir: string, defaultRoles: string[], app?: ApplicationService): Promise<RegisteredTool[]>; /** * The build-time barrel shape the Assembler `init` hook generates for `app/agent_tools` * (key → lazy module import), mirroring durable's steps/workflows barrels. */ export type ToolsBarrel = Record<string, () => Promise<Record<string, unknown>>>; /** * Register every `@AiTool` / `defineTool` reachable from a generated {@link ToolsBarrel} — the * build-time equivalent of {@link discoverTools} with no runtime `readdir`. Each module is imported * once and each export registered once (deduped). */ export declare function registerToolsFromBarrel(registry: ToolRegistry, barrel: ToolsBarrel, defaultRoles: string[], app?: ApplicationService): Promise<RegisteredTool[]>; //# sourceMappingURL=tool-discovery.d.ts.map