UNPKG

@adonis-agora/agent

Version:

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

63 lines • 3.62 kB
/** * Framework-independent GenUI owned by the Adonis agent: schemas, catalogs, presentations, * renderers and UI tools. The same local definitions can be imported by browser code. */ import { type GenuiFactory } from './factory.js'; import type { AdonisSandboxKitUrls } from './kit/adonis.js'; import { type Catalog, type GenuiCatalogScope, type GenuiToolsOptions } from './public.js'; import { type DefineSandboxOptions } from './sandbox.js'; export { AgentGenui, type GenuiFactory, type GenuiFactoryContext, type GenuiSetup, } from './factory.js'; export * from './public.js'; /** * Picks the catalog for ONE request — a tenant's own components, a plan's versions. Extend it and * pass the class as `resolver`: the provider builds it through the container, so it can `@inject()` * whatever it reads (a model, a service). */ export declare abstract class GenuiCatalogResolver { abstract resolve(scope: GenuiCatalogScope): Catalog | Promise<Catalog>; } type ResolverOption = GenuiCatalogResolver | (abstract new (...args: never[]) => GenuiCatalogResolver) | ((scope: GenuiCatalogScope) => Catalog | Promise<Catalog>); /** `genui({ … })` — everything `genuiTools` takes, plus the catalog and an optional resolver. */ export interface GenuiOptions extends Omit<GenuiToolsOptions, 'resolveCatalog'> { /** The boot-time catalog: names the per-component tools, and serves every request without a resolver. */ catalog?: Catalog; /** * The catalog for each request: a {@link GenuiCatalogResolver} (instance or class — a class is built * through the container) or a plain `(scope) => catalog`. With one, calls validate against the * resolved catalog and each turn's tool descriptions come from it (`ToolHandler.describe`). */ resolver?: ResolverOption; /** * Add the sandbox component (`Sandbox`): the model may write HTML, CSS and JS for a one-off * interactive answer when no catalog component fits. `true` for the defaults (no network), or * the {@link DefineSandboxOptions} (a policy listing origins, extra instructions). Off by default. * The browser's catalog should carry the same definition (`defineSandbox(...)` in the shared * catalog file) so the renderer enforces the same policy. */ sandbox?: boolean | DefineSandboxOptions; /** * Where the kit's assets are when this process cannot find them through Vite: a separate SPA * that builds them with `genuiSandboxKit()` and serves them itself, while the assembler hook * (`genuiKitHook`) writes the docs here. `{ kitUrl: '/spa/assets/genui-sandbox-kit.js', cssUrl, * tailwindUrl }` — urls the browser can fetch (same origin, or CORS-enabled). */ sandboxKit?: AdonisSandboxKitUrls; } /** * Generative UI for `config/agent.ts`: * * ```ts * import { genui } from '@adonis-agora/agent/genui' * import { catalog } from '#genui/catalog' // defineCatalog([...]) — shared with the browser * * export default defineConfig({ model, genui: genui({ catalog }) }) * ``` * * Registers one `ui__render` tool taking a component tree composed from the catalog (or, with * `mode: 'per-component'`, a `ui__show_<component>` tool per model-facing component; and/or the * generic `ui__show` with `showTool: true`). Each call validates * against the catalog and pushes through `ctx.emitUi`, so it streams as a `ui` frame and is persisted * on the message. Tools without `roles` get the config's `defaultRoles`, like every other tool. */ export declare function genui(options?: GenuiOptions): GenuiFactory; //# sourceMappingURL=index.d.ts.map