import { type SdkClient, SdkClientError } from "../client"; import type { AbortScope } from "../host/control/operations"; import { type SessionAttachment, type SessionRouter } from "../router"; import { ACP_SESSION_RECONNECT } from "../session-reconnect"; import type { SessionLifecycleMcpServer } from "./mcp"; type JsonObject = Record; /** The small agent-side ACP surface used for reverse requests. */ export interface AcpReverseConnection { request?(method: string, params: JsonObject, options?: { cancellationSignal?: AbortSignal; }): Promise; [key: string]: unknown; } export interface AcpProviderRegistration { capability: string; definitions: unknown; } export interface AcpSdkAdapterOptions { /** Broker lifecycle transport only. Live session work requires `router` plus an opaque attachment. */ client?: SdkClient; router?: SessionRouter; attachment?: SessionAttachment; sessionId?: string; connection?: AcpReverseConnection; providers?: AcpProviderRegistration[]; /** Lease IDs persisted by the ACP host across a WebSocket reconnect. */ expectedLeaseIds?: Record; heartbeatMs?: number; reverseCancelTtlMs?: number; } export declare class AcpSdkAdapterError extends Error { readonly code: string; constructor(code: string, message?: string); } /** * The error an ACP session launch must throw once a lifecycle request that carried MCP * servers has failed. */ export declare function acpMcpLaunchFailure(error: unknown, mcpServers: SessionLifecycleMcpServer[]): unknown; export type AcpReconnectFailedHandler = (error: SdkClientError) => void; export type AcpFrameHandler = (frame: Record) => void; export { ACP_SESSION_RECONNECT }; export declare class AcpSdkAdapter { #private; constructor(options: AcpSdkAdapterOptions); static connect(options: AcpSdkAdapterOptions): Promise; acceptAttachment(attachment: SessionAttachment): void; revokeAttachment(attachment: SessionAttachment): void; attachmentReady(attachment: SessionAttachment): Promise; /** * Re-register reverse providers on a live attachment without aborting in-flight * reverse RPCs. ACP session reuse and expired-lease recovery take this path * because `#providersActivated` otherwise leaves a dead permission lease in * place for the life of the session (#4909). */ ensureProviders(): Promise; acceptFrame(frame: Record): void; get leaseIds(): ReadonlyMap; get connectionId(): string | undefined; onReconnectFailed(handler: AcpReconnectFailedHandler): () => void; onFrame(handler: AcpFrameHandler): () => void; start(): Promise; close(): Promise; prompt(params: JsonObject | string): Promise; /** * Ends the active turn with a C04 terminal abort. The default `scope:"turn"` * only stops the current turn, matching the SDK `turn.abort` default and * other ACP clients' cancel behavior; `scope:"owned"` additionally stops * exact causal owned work (background Bash/task jobs, detached subagents) so * an external client can terminate everything a turn spawned. Paseo keeps * owned cancels through its provider config env * (`GJC_ACP_ABORT_SCOPE=owned`) without source changes. A fresh bounded * idempotency key per call keeps terminal-abort replay deterministic across * retries. */ cancel(scope?: AbortScope): Promise; setModel(params: JsonObject | string): Promise; control(operation: string, input?: JsonObject): Promise; query(query: string, input?: JsonObject, cursor?: string): Promise; global(operation: string, input?: JsonObject, idempotencyKey?: string): Promise; /** Uses lifecycle endpoint credentials only inside the ACP session owner. */ lifecycle(operation: string, input?: JsonObject, idempotencyKey?: string): Promise; sdkControl(params: { operation: string; input?: JsonObject; }): Promise; sdkQuery(params: { query: string; input?: JsonObject; cursor?: string; }): Promise; sdkGlobal(params: { operation: string; input?: JsonObject; idempotencyKey?: string; }): Promise; /** Dispatches the ACP extension method names without exposing endpoint credentials. */ handle(method: string, params?: JsonObject): Promise; registerProvider(provider: AcpProviderRegistration): Promise; }