/** * ACP-to-Tisyn protocol adapter. * * Translates between Tisyn protocol messages (HostMessage/AgentMessage) * and ACP JSON-RPC messages sent to/from the Claude Code stdio process. * * The adapter connects to a pre-existing ACP process via stdio NDJSON * or spawns one as a subprocess. It does NOT terminate the process on * scope exit — only the logical connection is closed. */ import type { Operation, Stream } from "effection"; import type { HostMessage, AgentMessage } from "@tisyn/transport"; import type { AcpRequest, AcpMessage } from "./types.js"; export interface AcpAdapterConfig { /** Command to spawn the ACP process. If omitted, connects to existing process via stdio. */ command?: string; /** Arguments for the command. */ arguments?: string[]; /** Environment variables for the subprocess. */ env?: Record; /** Working directory for the subprocess. */ cwd?: string; } export interface AcpAdapter { /** * Send a Tisyn protocol message to the ACP process (translated to ACP format). */ sendTisynMessage(message: HostMessage): Operation; /** * Stream of Tisyn protocol messages received from the ACP process * (translated from ACP format). */ tisynMessages: Stream; /** * Block until the subprocess exits, then return a diagnostic Error * containing exit code/signal, command, and captured stderr. */ waitForProcessExit(): Operation; } /** * Translate a Tisyn ExecuteRequest into an ACP request. * Maps the Tisyn operation name to the corresponding ACP wire method * and forwards the effect payload directly as ACP params. * * The operation may be fully qualified (e.g. "claude-code.newSession") * or bare (e.g. "newSession"). The agent prefix is stripped before lookup. */ export declare function tisynExecuteToAcp(id: string, operation: string, args: unknown): AcpRequest; /** * Translate an ACP success response into a Tisyn ExecuteResponse. */ export declare function acpSuccessToTisyn(id: string, result: unknown): AgentMessage; /** * Translate an ACP error response into a Tisyn ExecuteResponse. */ export declare function acpErrorToTisyn(id: string, error: { code: number; message: string; data?: unknown; }): AgentMessage; /** * Translate an ACP notification into a Tisyn ProgressNotification. */ export declare function acpNotificationToTisyn(token: string, params: Record): AgentMessage; /** * Parse a raw JSON value from the ACP process into a validated AcpMessage. * Validates structure and returns a discriminated union member. */ export declare function parseAcpMessage(json: unknown): AcpMessage; /** * Create an ACP adapter resource that connects to an ACP stdio process. * * The adapter translates Tisyn protocol messages to/from ACP format * and exposes them as `sendTisynMessage` / `tisynMessages`. */ export declare function createAcpAdapter(config?: AcpAdapterConfig): Operation; //# sourceMappingURL=acp-adapter.d.ts.map