UNPKG

@adonis-agora/agent

Version:

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

34 lines • 2.11 kB
import type { SinkWriter, StreamFrame } from './spi/token-stream-sink.js'; import type { ToolInputPreview } from './spi/tool.js'; /** Default least time between two preview frames of one call ({@link ToolInputPreview.throttleMs}). */ export declare const DEFAULT_PREVIEW_THROTTLE_MS = 100; /** A preview a model turn showed: what the loop withdraws if the call's own push never replaces it. */ export interface ShownPreview { id: string; component: string; toolCallId: string; } /** The id a call's preview is shown under: the one its first `ctx.emitUi` push gets. */ export declare function previewUiId(toolCallId: string): string; /** The frame that withdraws a preview: partial, with nothing to draw. */ export declare function withdrawPreviewFrame(shown: ShownPreview): StreamFrame; export interface ToolInputPreviews { /** Hand THIS to the model provider: every frame passes through, previews are added after. */ writer: SinkWriter; /** The previews still standing (shown and not withdrawn), in the order they first appeared. */ shown(): ShownPreview[]; } /** * Wrap the writer a model turn streams into so a tool that previews its input * (`ToolHandler.previewInput`) gets `ui` frames drawn from the arguments while the model writes them. * * Per call: the streamed argument text (`tool-input-delta`) is accumulated, parsed as far as it goes * (`parsePartialJson`) and handed to the preview; what it renders is written as a `partial` component * frame — at most one every `throttleMs`, and only when it changed, so a long tree costs the stream * (and every sink buffering it) a bounded number of snapshots rather than one per delta. Whatever the * throttle held back is flushed when the arguments are complete (`tool-input-available`). * * Previews never fail the turn: a preview that throws is dropped for that call. */ export declare function previewToolInputs(inner: SinkWriter, resolve: (toolName: string, toolCallId: string) => Promise<ToolInputPreview | undefined>, now?: () => number): ToolInputPreviews; //# sourceMappingURL=tool-input-preview.d.ts.map