import { JsonRpcRequest, JsonRpcResponse, JsonRpcNotification } from './protocol.js'; /** * A frame with its obvious credentials blanked. * * Exported for unit testing (see transport.test.ts). */ export declare function redactCredentials(frame: string): string; type MessageHandler = (msg: JsonRpcRequest | JsonRpcNotification) => void | Promise; export interface RequestOptions { /** * How long to wait for the client's answer. Defaults to 30s; 0 waits * indefinitely, for calls that wait on a person (permission dialogs) or * on a running process (terminal/wait_for_exit). */ timeoutMs?: number; /** Stop waiting when this fires (e.g. the prompt was cancelled). */ signal?: AbortSignal; } /** The client answered one of our requests with a JSON-RPC error. */ export declare class AcpRequestError extends Error { readonly method: string; readonly code: number; constructor(method: string, code: number, message: string); } /** The client did not answer one of our requests in time. */ export declare class AcpRequestTimeoutError extends Error { readonly method: string; readonly timeoutMs: number; constructor(method: string, timeoutMs: number); } export declare class StdioTransport { private buffer; protected handler: MessageHandler | null; private pendingRequests; private requestIdCounter; private unanswered; start(handler: MessageHandler): void; protected onData(chunk: string): void; private dispatch; protected write(line: string): void; send(msg: JsonRpcResponse | JsonRpcNotification): void; respond(id: number | string, result: unknown): void; error(id: number | string, code: number, message: string): void; notify(method: string, params: unknown): void; /** * Send a JSON-RPC request to the client and wait for the response. * Used for agent-initiated requests like session/request_permission. * * Rejects with AcpRequestError when the client answers with an error, * with AcpRequestTimeoutError when it does not answer in time, and with * an AbortError when `signal` fires. A result is never invented: callers * that treat a missing answer as "no" must say so with their own catch. */ request(method: string, params: unknown, options?: RequestOptions): Promise; } export {};