mirror of
https://github.com/cline/cline.git
synced 2026-09-19 02:05:44 +08:00
Co-authored-by: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com>
33 lines
970 B
TypeScript
33 lines
970 B
TypeScript
import { Readable, Writable } from "node:stream";
|
|
import { registerClineClientIdentity } from "../utils/cline-client-identity";
|
|
import { writeDiagnostic } from "../utils/output";
|
|
|
|
export interface AcpModeOptions {
|
|
autoApproveTools?: boolean;
|
|
}
|
|
|
|
export async function runAcpMode(options?: AcpModeOptions): Promise<void> {
|
|
const { AgentSideConnection, ndJsonStream } = await import(
|
|
"@agentclientprotocol/sdk"
|
|
);
|
|
const { AcpAgent } = await import("./acpAgent");
|
|
|
|
registerClineClientIdentity("cline-acp");
|
|
|
|
writeDiagnostic("[acp] starting ACP mode over stdio…");
|
|
|
|
const stream = ndJsonStream(
|
|
Writable.toWeb(process.stdout) as WritableStream<Uint8Array>,
|
|
Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>,
|
|
);
|
|
|
|
const connection = new AgentSideConnection((conn) => {
|
|
return new AcpAgent(conn, {
|
|
autoApproveTools: options?.autoApproveTools,
|
|
});
|
|
}, stream);
|
|
|
|
// Keep the process alive until the connection closes
|
|
await connection.closed;
|
|
}
|