import { AcpTransport, type AcpTransportClosedEvent, type AcpTransportOptions } from "./acp-transport.js"; import type { JsonRpcRequestOptions } from "./jsonrpc-message-layer.js"; import { type AgentCapabilities, type AuthenticateResponse, type AuthMethod, type ClientCapabilities, type ContentBlock, type EnvVariable, type Implementation, type InitializeResponse, type LoadSessionResponse, type McpServer, type NewSessionResponse, type PermissionOption, type PromptResponse, type RequestId, type SessionConfigId, type SessionConfigOption, type SessionConfigValueId, type RequestPermissionOutcome, type ProtocolVersion, type SessionModeId, type SessionId, type SetSessionModeResponse, type SessionUpdateNotification, type ToolCallUpdate, type TerminalOutputResponse, type WaitForTerminalExitResponse } from "./types.js"; export type AcpClientState = "uninitialized" | "initialized" | "ready"; type ExtensionMethod = `_${string}`; export interface PromptTurn extends AsyncIterable { response: Promise; } export interface AcpClientFsHandler { readTextFile?: (args: { sessionId: SessionId; path: string; line?: number | null; limit?: number | null; }) => string | Promise; writeTextFile?: (args: { sessionId: SessionId; path: string; content: string; }) => void | Promise; } export interface AcpClientTerminalHandler { create: (args: { sessionId: SessionId; command: string; args?: string[]; cwd?: string | null; env?: EnvVariable[]; outputByteLimit?: number | null; }) => string | Promise; output: (args: { sessionId: SessionId; terminalId: string; }) => TerminalOutputResponse | Promise; waitForExit: (args: { sessionId: SessionId; terminalId: string; }) => WaitForTerminalExitResponse | Promise; kill: (args: { sessionId: SessionId; terminalId: string; }) => void | Promise; release: (args: { sessionId: SessionId; terminalId: string; }) => void | Promise; } type AcpClientPermissionHandler = (args: { toolCall: ToolCallUpdate; options: PermissionOption[]; }) => RequestPermissionOutcome | Promise; export interface AcpClientHandlers { permission?: AcpClientPermissionHandler; fs?: AcpClientFsHandler; terminal?: AcpClientTerminalHandler; } type AcpClientTransport = Pick & Partial>; interface AcpClientSharedOptions { protocolVersion?: ProtocolVersion; clientCapabilities?: ClientCapabilities; clientInfo?: Implementation | null; handlers?: AcpClientHandlers; permissionHandler?: AcpClientPermissionHandler; fsHandler?: AcpClientFsHandler; terminalHandler?: AcpClientTerminalHandler; skipAuth?: boolean; /** * Automatically approve all permission requests (selects the first * "allow_always" or "allow_once" option). Ignored when a custom * `permissionHandler` is provided. */ autoApprove?: boolean; } export interface AcpClientProcessOptions extends AcpClientSharedOptions { command: string; args?: readonly string[]; cwd?: string; env?: NodeJS.ProcessEnv; firstRequestId?: number; spawn?: AcpTransportOptions["spawn"]; } export interface AcpClientInjectedTransportOptions extends AcpClientSharedOptions { transport: AcpClientTransport; } export type AcpClientOptions = AcpClientProcessOptions | AcpClientInjectedTransportOptions; export declare class AcpClient { private readonly transport; private readonly clientProtocolVersion; private clientCapabilities?; private readonly clientInfo?; private readonly skipAuth; private readonly permissionHandler?; private readonly fsHandler?; private readonly terminalHandler?; private readonly activePromptUpdates; private readonly trackedTerminalIds; private hasRegisteredFsReadHandler; private hasRegisteredFsWriteHandler; private hasRegisteredTerminalHandlers; private disposed; private transportDisposed; private initializing; private authenticating; private lifecycleState; private negotiatedVersion; private availableAuthMethods; private negotiatedAgentCapabilities; private negotiatedAgentInfo; constructor(options: AcpClientOptions); get state(): AcpClientState; get negotiatedProtocolVersion(): ProtocolVersion | null; get authMethods(): AuthMethod[]; get agentCapabilities(): AgentCapabilities | undefined; get agentInfo(): Implementation | null | undefined; get closed(): Promise | undefined; initialize(clientCapabilities?: ClientCapabilities): Promise; authenticate(methodId: string): Promise; newSession(cwd: string, mcpServers: McpServer[]): Promise; loadSession(sessionId: SessionId, cwd: string, mcpServers: McpServer[]): Promise; cancelSession(sessionId: SessionId): Promise; setMode(sessionId: SessionId, modeId: SessionModeId): Promise; setConfigOption(sessionId: SessionId, configId: SessionConfigId, value: SessionConfigValueId): Promise; prompt(sessionId: SessionId, content: ContentBlock[]): PromptTurn; sendExtRequest(method: ExtensionMethod, params?: unknown, options?: JsonRpcRequestOptions): Promise; sendExtNotification(method: ExtensionMethod, params?: unknown): Promise; onExtRequest(method: TMethod, handler: (params: unknown, context: { id: RequestId; method: TMethod; }) => unknown | Promise): void; onExtNotification(method: TMethod, handler: (params: unknown, context: { method: TMethod; }) => void | Promise): void; dispose(): Promise; assertReady(operation: string): void; private assertNotDisposed; private registerCapabilityHandlers; private assertMcpServerCapabilitySupport; private handleSessionUpdateNotification; private trackTerminal; private assertKnownTerminal; private untrackTerminal; private assertPromptContentCapabilitySupport; } export {};