/** * AcpConnection, Per-subagent ACP connection. * * Spawns a child process via Bun.spawn and connects to it via ClientSideConnection * using ndJsonStream over stdio. Implements the ACP Client interface so the * subagent can request permissions and send session updates. */ import type { SubagentInfo, SubagentResult, SubagentTask } from './protocol.js'; import type { PermissionRequestHandler } from '../permissions/prompt.js'; import type { RuntimeEventBus } from '../runtime/events/index.js'; import type { HookDispatcher } from '../hooks/index.js'; import type { AgentUsage } from '../../events/agents.js'; /** Shape of the (experimental/unstable) ACP `PromptResponse.usage` field. */ interface AcpPromptUsage { inputTokens: number; outputTokens: number; cachedReadTokens?: number | null; cachedWriteTokens?: number | null; } /** * Map the ACP prompt response's usage field (`cachedReadTokens`/`cachedWriteTokens`, * ACP protocol naming) onto the SDK's `AgentUsage` shape (`cacheReadTokens`/ * `cacheWriteTokens`). Exported for unit testing without spawning a real * ACP subprocess. */ export declare function mapAcpUsage(usage: AcpPromptUsage | null | undefined): AgentUsage | undefined; /** * AcpConnection manages the lifecycle of a single subagent child process. * * Lifecycle: * 1. Construct with spawn params * 2. Call run(), spawns child, performs ACP handshake, starts a session * 3. Resolves with SubagentResult when the subagent completes or is cancelled * 4. Call cancel() to abort */ export declare class AcpConnection { private task; readonly id: string; private info; private spawnCmd; private requestPermission; private runtimeBus; private conn; private sessionId; private childProcess; private toolCallsMade; private lastProgressText; private transportClosed; private readonly hookDispatcher; constructor(id: string, task: SubagentTask, spawnCmd: string[], requestPermission?: PermissionRequestHandler, runtimeBus?: RuntimeEventBus | null, hookDispatcher?: Pick | null); /** Current info snapshot. */ getInfo(): SubagentInfo; /** * Spawn the child process, perform the ACP handshake, and run the prompt. * Resolves with SubagentResult when the subagent completes or errors. */ run(): Promise; /** Cancel the running subagent. */ cancel(): Promise; private emitterContext; private transportId; private transportEndpoint; private emitTransportInitializing; private emitTransportAuthenticating; private emitTransportConnected; private emitTransportSyncing; private emitTransportDisconnected; private emitTransportTerminalFailure; private fireTransportHook; private cleanup; private buildClientImpl; private buildPromptText; } export {}; //# sourceMappingURL=connection.d.ts.map