import { type ChildProcessWithoutNullStreams, type SpawnOptionsWithoutStdio } from "node:child_process"; import { type JsonRpcNotificationHandler, type JsonRpcRequestHandler, type JsonRpcRequestOptions } from "./jsonrpc-message-layer.js"; import type { AuthenticateRequest, AuthenticateResponse, CancelNotification, CreateTerminalRequest, CreateTerminalResponse, InitializeRequest, InitializeResponse, KillTerminalCommandRequest, KillTerminalCommandResponse, LoadSessionRequest, LoadSessionResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, ReleaseTerminalRequest, ReleaseTerminalResponse, RequestId, RequestPermissionRequest, RequestPermissionResponse, SessionNotification, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, SetSessionModeRequest, SetSessionModeResponse, TerminalOutputRequest, TerminalOutputResponse, WaitForTerminalExitRequest, WaitForTerminalExitResponse, WriteTextFileRequest, WriteTextFileResponse } from "./types.js"; interface AcpRequestShape { params: TParams; result: TResult; } export interface AcpAgentRequestMap { initialize: AcpRequestShape; authenticate: AcpRequestShape; "session/new": AcpRequestShape; "session/load": AcpRequestShape; "session/prompt": AcpRequestShape; "session/set_mode": AcpRequestShape; "session/set_config_option": AcpRequestShape; } export interface AcpAgentNotificationMap { "session/cancel": CancelNotification; } export interface AcpClientRequestMap { "session/request_permission": AcpRequestShape; "fs/read_text_file": AcpRequestShape; "fs/write_text_file": AcpRequestShape; "terminal/create": AcpRequestShape; "terminal/output": AcpRequestShape; "terminal/wait_for_exit": AcpRequestShape; "terminal/kill": AcpRequestShape; "terminal/release": AcpRequestShape; } export interface AcpClientNotificationMap { "session/update": SessionNotification; } type ExtensionMethod = `_${string}`; type SpawnFunction = (command: string, args?: ReadonlyArray, options?: SpawnOptionsWithoutStdio) => ChildProcessWithoutNullStreams; export interface AcpTransportOptions { command: string; args?: readonly string[]; cwd?: string; env?: NodeJS.ProcessEnv; firstRequestId?: number; spawn?: SpawnFunction; } export interface AcpTransportClosedEvent { code: number | null; signal: NodeJS.Signals | null; reason: Error; stderr: string; } export declare class AcpTransport { readonly closed: Promise; private readonly command; private readonly child; private readonly layer; private stderrOutput; private static readonly STDERR_MAX_LENGTH; private resolveClosed; private closeEvent; private closeReason; private disposeStarted; private disposeEscalationTimer; private disposeForcedCloseTimer; constructor(options: AcpTransportOptions); sendRequest(method: TMethod, params: AcpAgentRequestMap[TMethod]["params"], options?: JsonRpcRequestOptions): Promise; sendRequest(method: string, params?: unknown, options?: JsonRpcRequestOptions): Promise; sendExtRequest(method: ExtensionMethod, params?: unknown, options?: JsonRpcRequestOptions): Promise; sendNotification(method: TMethod, params: AcpAgentNotificationMap[TMethod]): void; sendNotification(method: string, params?: unknown): void; sendExtNotification(method: ExtensionMethod, params?: unknown): void; sendExtNotification(method: string, params?: unknown): void; onRequest(method: TMethod, handler: (params: AcpClientRequestMap[TMethod]["params"], context: { id: RequestId; method: TMethod; }) => AcpClientRequestMap[TMethod]["result"] | Promise): void; onRequest(method: string, handler: JsonRpcRequestHandler): void; onExtRequest(method: TMethod, handler: (params: unknown, context: { id: RequestId; method: TMethod; }) => unknown | Promise): void; onExtRequest(method: string, handler: JsonRpcRequestHandler): void; onNotification(method: TMethod, handler: (params: AcpClientNotificationMap[TMethod], context: { method: TMethod; }) => void | Promise): void; onNotification(method: string, handler: JsonRpcNotificationHandler): void; onExtNotification(method: TMethod, handler: (params: unknown, context: { method: TMethod; }) => void | Promise): void; onExtNotification(method: string, handler: JsonRpcNotificationHandler): void; getStderrOutput(): string; pendingRequestCount(): number; dispose(reason?: Error): void; private close; } export {};