import type { AuthMethod, CreateTerminalRequest, CreateTerminalResponse, KillTerminalRequest, KillTerminalResponse, ReadTextFileRequest, ReadTextFileResponse, ReleaseTerminalRequest, ReleaseTerminalResponse, RequestPermissionRequest, TerminalOutputRequest, TerminalOutputResponse, WaitForTerminalExitRequest, WaitForTerminalExitResponse, WriteTextFileRequest, WriteTextFileResponse } from '@agentclientprotocol/sdk'; export declare const PermissionDecision: { readonly AllowOnce: "allow_once"; readonly AllowAlways: "allow_always"; readonly Deny: "deny"; }; export type PermissionDecision = typeof PermissionDecision[keyof typeof PermissionDecision]; export interface RuntimeLogEvent { level: 'debug' | 'info' | 'warn' | 'error'; message: string; context?: Record; } export interface RuntimePermissionRequest { sessionId: string; toolCallId: string; toolName: string; /** * Human-readable title surfaced by the agent for the operation that needs * approval (e.g. `"Run npm install"`). Pulled from `toolCall.title` on the * raw payload; empty string when the agent didn't supply one. */ title: string; input: unknown; options: Array<{ optionId?: string; name?: string; kind?: string; }>; raw: RequestPermissionRequest; } export interface RuntimeAuthSelectionRequest { methods: AuthMethod[]; } /** Direction of an ACP wire frame relative to the host (`out` = host → agent). */ export type WireDirection = 'in' | 'out'; /** Context passed to each `WireMiddleware`. `frame` is mutable. */ export interface WireContext { direction: WireDirection; /** * The JSON-RPC frame as a plain JS object (already parsed). Mutate in place * or reassign to rewrite what reaches the next middleware / the wire. */ frame: unknown; } /** * Koa-style middleware run for every ACP frame in either direction. * Call `await next()` to forward; do not call it to drop the frame. * * Example (logger): `async (ctx, next) => { console.log(ctx.direction, ctx.frame); await next(); }` * Example (drop): `async (ctx, next) => { if (isPing(ctx.frame)) return; await next(); }` * Example (rewrite):`async (ctx, next) => { ctx.frame = redact(ctx.frame); await next(); }` */ export type WireMiddleware = (ctx: WireContext, next: () => Promise) => Promise | void; /** Reported by the node child-process transport when the agent process exits. */ export interface RuntimeAgentExitInfo { code: number | null; signal: NodeJS.Signals | null; /** Last <=32KB of stderr captured before exit, trimmed. */ stderr: string; } export interface RuntimeHost { chooseAuthMethod?(request: RuntimeAuthSelectionRequest): Promise; requestPermission?(request: RuntimePermissionRequest): Promise; readTextFile?(params: ReadTextFileRequest): Promise; writeTextFile?(params: WriteTextFileRequest): Promise; createTerminal?(params: CreateTerminalRequest): Promise; terminalOutput?(params: TerminalOutputRequest): Promise; waitForTerminalExit?(params: WaitForTerminalExitRequest): Promise; killTerminal?(params: KillTerminalRequest): Promise; releaseTerminal?(params: ReleaseTerminalRequest): Promise; /** * Prompt content the host can render. Forwarded to the agent during * `initialize` as `clientCapabilities.promptCapabilities`. Omitted fields * default to `false`. The agent uses this to decide whether to send images, * audio, or embedded resource references inside `session/prompt` updates. * * Mirrors the upstream ACP `PromptCapabilities` type. */ promptCapabilities?: { image?: boolean; audio?: boolean; embeddedContext?: boolean; }; log?(entry: RuntimeLogEvent): void; /** * Koa-style middleware chain run for every ACP wire frame in either direction. * Each middleware can observe, mutate (`ctx.frame = ...`), or drop (don't call `next`) * the frame before it reaches the next middleware or the underlying transport. * Provide a single function or an array (executed in order). */ wireMiddleware?: WireMiddleware | WireMiddleware[]; /** * Notification that the agent child process exited. Only invoked by the * default node transport; custom transports can call it as well. */ onAgentExit?(info: RuntimeAgentExitInfo): void; }