@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
45 lines • 2.58 kB
TypeScript
import type { ProtocolAdapter } from '../spi/protocol-adapter.js';
import { type A2uiStreamOptions } from './core.js';
export interface A2uiAdapterOptions extends A2uiStreamOptions {
/** Where the route mounts, under the agent's path. Default `'a2ui'` → `POST <path>/a2ui`. */
path?: string;
/** As `agUiAdapter`'s: how long a run waiting on a person may stay silent before the stream ends. */
quietMs?: number;
/** Largest action accepted, as JSON, in bytes. Default 8192. */
maxActionBytes?: number;
/** Largest `a2uiClientDataModel` accepted, as JSON, in bytes. Default 32768. */
maxDataModelBytes?: number;
}
/**
* Serve the agent as an A2UI (https://a2ui.org, v0.9) agent: `POST <path>/a2ui` answers with the
* run as a JSON Lines stream of A2UI server-to-client messages — `createSurface`,
* `updateComponents`, `updateDataModel`, `deleteSurface` — that any A2UI renderer draws.
*
* ```ts
* import { a2uiAdapter } from '@adonis-agora/agent/a2ui'
*
* export default defineConfig({ adapters: [a2uiAdapter()] })
* ```
*
* The body is `{ threadId?, message?, action?, uiCapabilities?, a2uiClientCapabilities?,
* a2uiClientDataModel?, agent? }` (the two A2UI fields also read from `metadata`, A2A-style):
* - `message` — the user's text;
* - `action` — an A2UI client message (`{ version: 'v0.9', action: { name, surfaceId,
* sourceComponentId, timestamp, context } }`, or v0.8's `{ userAction }`): it becomes the turn
* (`uiActionText`). `agora.approve` / `agora.reject` with `context.interruptId` decide the
* approval a previous stream ended on, and stream the rest of that run;
* - `threadId` — continue that thread (its owner is checked), or start one under that id;
* - `a2uiClientCapabilities` — the catalogs the client draws (`{ 'v0.9': { supportedCatalogIds } }`,
* what `MessageProcessor.getRendererCapabilities()` builds): the basic catalog is sent under the
* id the client lists for it;
* - `a2uiClientDataModel` — the data models of surfaces created with `sendDataModel`, handed to the
* prompt builder as `pageContext.a2uiDataModel`.
*
* `GET <path>/a2ui/threads/:threadId` answers a stored thread as `{ threadId, entries }`
* ({@link a2uiThreadReplay}): what a client draws again after a reload.
*
* Response headers name the library's ids: `X-Agent-Thread-Id`, `X-Agent-Run-Id`. Authenticated and
* owner-scoped exactly as `chat` is.
*/
export declare function a2uiAdapter(options?: A2uiAdapterOptions): ProtocolAdapter;
//# sourceMappingURL=adapter.d.ts.map