@agent-native/core 0.65.0 → 0.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acp-adapter.js","sourceRoot":"","sources":["../../../src/agent/harness/acp-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAuC,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAcjD,4EAA4E;AAC5E,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,2DAA2D;AAC3D,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,uCAAuC,CAAC;AAyBnE,MAAM,oBAAoB,GAA6B;IACrD,8EAA8E;IAC9E,kCAAkC;IAClC,OAAO,EAAE,KAAK;IACd,qEAAqE;IACrE,8DAA8D;IAC9D,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,4EAA4E;IAC5E,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,IAAI;CACjB,CAAC;AAEF;;;GAGG;AACH,MAAM,aAAa,GAAG,IAAI,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CAEzD,CAAC;AAElB,MAAM,UAAU,uBAAuB,CACrC,OAAiC;IAEjC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,KAAK,CAAC;IACnC,OAAO;QACL,IAAI;QACJ,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,WAAW;QACnC,WAAW,EACT,OAAO,CAAC,WAAW;YACnB,uDAAuD;QACzD,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,WAAW;QACrD,YAAY,EAAE,oBAAoB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MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC3B,OAAO,OAAO,CAAC,OAAO,CAAC;wBACrB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAO;wBAC/B,IAAI,EAAE,KAAK;qBACZ,CAAC,CAAC;gBACL,CAAC;gBACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;oBAChB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,SAAkB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;gBACpE,CAAC;gBACD,OAAO,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,EAAE;oBAChD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAC/B,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * ACP (Agent Client Protocol) harness adapter.\n *\n * Lets Agent-Native act as an ACP *client* and drive a local coding agent —\n * Gemini CLI, Claude Code, or any other ACP-compliant agent — through the\n * existing {@link AgentHarnessAdapter} substrate. The agent runs as a local\n * subprocess that owns its own loop, tools, and workspace filesystem access,\n * which is exactly the shape ACP was designed for. See:\n * https://agentclientprotocol.com\n *\n * Scope: this adapter targets *local* coding. The agent is spawned as a child\n * process and speaks newline-delimited JSON-RPC over stdio. It reuses whatever\n * local CLI login the agent already has (e.g. `gemini`/`claude` auth in the\n * user's home dir) by inheriting the parent environment. It is not a hosted or\n * sandboxed transport, and it is not a chat/A2A transport.\n *\n * The protocol transport and framing are handled by the official\n * `@zed-industries/agent-client-protocol` package, loaded lazily as an optional\n * dependency so apps that never use ACP do not pay for it. Everything in this\n * file beyond the thin spawn/connection glue is pure mapping logic between ACP\n * `session/update` notifications and {@link AgentHarnessEvent}s.\n */\n\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { spawn, type ChildProcessWithoutNullStreams } from \"node:child_process\";\nimport { Readable, Writable } from \"node:stream\";\n\nimport type {\n AgentHarnessAdapter,\n AgentHarnessApproval,\n AgentHarnessCapabilities,\n AgentHarnessCreateSessionOptions,\n AgentHarnessEvent,\n AgentHarnessMessage,\n AgentHarnessPermissionMode,\n AgentHarnessSession,\n AgentHarnessTurnInput,\n} from \"./types.js\";\n\n/** Grace period between SIGTERM and SIGKILL when tearing a session down. */\nconst SIGKILL_GRACE_MS = 2_000;\n/** Keep a bounded tail of child stderr for diagnostics. */\nconst STDERR_TAIL_LIMIT = 8_000;\n\n/**\n * The optional package that carries the ACP protocol transport. Loaded lazily;\n * `resolveAgentHarness` surfaces a clear install error when it is missing.\n */\nexport const ACP_PACKAGE = \"@zed-industries/agent-client-protocol\";\n\nexport interface AcpHarnessAdapterOptions {\n /** Adapter id, e.g. \"acp:gemini\". Defaults to \"acp\". */\n name?: string;\n /** Human-readable label for pickers. */\n label?: string;\n /** Short description for pickers and diagnostics. */\n description?: string;\n /** Executable to spawn (the ACP agent binary), e.g. \"gemini\" or \"npx\". */\n command?: string;\n /** Arguments passed to the agent binary, e.g. [\"--experimental-acp\"]. */\n args?: string[];\n /**\n * Extra environment variables for the agent process. Merged over the parent\n * environment, which the agent inherits so it can reuse the user's local CLI\n * login.\n */\n env?: Record<string, string>;\n /** Default working directory when a turn does not specify one. */\n cwd?: string;\n /** Hint shown when the optional ACP package is missing. */\n installPackage?: string;\n}\n\nconst DEFAULT_CAPABILITIES: AgentHarnessCapabilities = {\n // The agent runs locally with its own workspace access; Agent-Native does not\n // provide it an isolated sandbox.\n sandbox: false,\n // Best-effort: resumable when the agent advertises the `loadSession`\n // capability. Degrades to a fresh session per turn otherwise.\n resumable: true,\n approvals: true,\n // ACP host tools would flow through MCP servers; not wired in this adapter.\n hostTools: false,\n fileEvents: true,\n};\n\n/**\n * Indirect dynamic import so bundlers/TS do not try to resolve the optional ACP\n * package at build time (mirrors the AI SDK harness adapter).\n */\nconst dynamicImport = new Function(\"specifier\", \"return import(specifier)\") as (\n specifier: string,\n) => Promise<any>;\n\nexport function createAcpHarnessAdapter(\n options: AcpHarnessAdapterOptions,\n): AgentHarnessAdapter {\n const name = options.name ?? \"acp\";\n return {\n name,\n label: options.label ?? \"ACP Agent\",\n description:\n options.description ??\n \"Drives a local ACP-compliant coding agent over stdio.\",\n installPackage: options.installPackage ?? ACP_PACKAGE,\n capabilities: DEFAULT_CAPABILITIES,\n async createSession(sessionOptions) {\n const command = options.command?.trim();\n if (!command) {\n throw new Error(\n `[acp-harness] Harness \"${name}\" requires a command. Pass { command, args } when resolving the harness (e.g. resolveAgentHarness(\"acp\", { command: \"gemini\", args: [\"--experimental-acp\"] })).`,\n );\n }\n const acp = await dynamicImport(ACP_PACKAGE);\n const cwd = path.resolve(\n sessionOptions.cwd ?? options.cwd ?? process.cwd(),\n );\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n ...(options.env ?? {}),\n };\n const child = spawn(command, options.args ?? [], {\n cwd,\n env,\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n const session = new AcpHarnessSession({\n acp,\n child,\n command,\n cwd,\n permissionMode: sessionOptions.permissionMode ?? \"allow-reads\",\n });\n try {\n await session.initialize(sessionOptions);\n } catch (error) {\n await session.destroy();\n throw error;\n }\n return session;\n },\n };\n}\n\ninterface AcpHarnessSessionDeps {\n acp: any;\n child: ChildProcessWithoutNullStreams;\n command: string;\n cwd: string;\n permissionMode: AgentHarnessPermissionMode;\n}\n\ninterface PendingPermission {\n resolve: (response: AcpPermissionResponse) => void;\n options: AcpPermissionOption[];\n}\n\nclass AcpHarnessSession implements AgentHarnessSession {\n readonly id: string;\n\n private readonly acp: any;\n private readonly child: ChildProcessWithoutNullStreams;\n private readonly command: string;\n private readonly cwd: string;\n private readonly permissionMode: AgentHarnessPermissionMode;\n private connection: any;\n private acpSessionId = \"\";\n private supportsLoad = false;\n\n private queue: AsyncEventQueue<AgentHarnessEvent> | null = null;\n private readonly pendingPermissions = new Map<string, PendingPermission>();\n private readonly toolTitles = new Map<string, string>();\n private approvalCounter = 0;\n private stderrTail = \"\";\n private childExited = false;\n private shuttingDown = false;\n\n constructor(deps: AcpHarnessSessionDeps) {\n this.acp = deps.acp;\n this.child = deps.child;\n this.command = deps.command;\n this.cwd = deps.cwd;\n this.permissionMode = deps.permissionMode;\n // Placeholder until newSession/loadSession assigns the real id.\n this.id = `acp-${Math.random().toString(36).slice(2)}`;\n\n this.child.stderr?.on(\"data\", (chunk: Buffer) => {\n this.stderrTail = (this.stderrTail + chunk.toString()).slice(\n -STDERR_TAIL_LIMIT,\n );\n });\n this.child.on(\"exit\", () => {\n this.childExited = true;\n if (!this.shuttingDown && this.queue) {\n this.queue.push({\n type: \"error\",\n error: this.childExitMessage(),\n });\n this.queue.close();\n }\n this.rejectAllPending();\n });\n this.child.on(\"error\", (error: Error) => {\n this.childExited = true;\n if (this.queue) {\n this.queue.push({\n type: \"error\",\n error: `[acp-harness] ${this.command}: ${error.message}`,\n });\n this.queue.close();\n }\n this.rejectAllPending();\n });\n }\n\n async initialize(opts: AgentHarnessCreateSessionOptions): Promise<void> {\n const stream = this.acp.ndJsonStream(\n Writable.toWeb(this.child.stdin) as WritableStream<Uint8Array>,\n Readable.toWeb(this.child.stdout) as ReadableStream<Uint8Array>,\n );\n this.connection = new this.acp.ClientSideConnection(\n () => this.createClient(),\n stream,\n );\n\n const initResponse = await this.connection.initialize({\n protocolVersion: this.acp.PROTOCOL_VERSION ?? 1,\n clientCapabilities: {\n fs: { readTextFile: true, writeTextFile: true },\n terminal: false,\n },\n });\n this.supportsLoad = Boolean(initResponse?.agentCapabilities?.loadSession);\n\n const resume = opts.resumeState as\n | { sessionId?: string }\n | undefined\n | null;\n if (resume?.sessionId && this.supportsLoad) {\n try {\n await this.connection.loadSession({\n sessionId: resume.sessionId,\n cwd: this.cwd,\n mcpServers: [],\n });\n this.acpSessionId = resume.sessionId;\n return;\n } catch {\n // Fall through to a fresh session if the agent could not load it.\n }\n }\n\n const created = await this.connection.newSession({\n cwd: this.cwd,\n mcpServers: [],\n });\n this.acpSessionId =\n typeof created?.sessionId === \"string\" ? created.sessionId : this.id;\n }\n\n async *streamTurn(\n input: AgentHarnessTurnInput,\n ): AsyncIterable<AgentHarnessEvent> {\n if (this.childExited) {\n yield { type: \"error\", error: this.childExitMessage() };\n return;\n }\n const queue = new AsyncEventQueue<AgentHarnessEvent>();\n this.queue = queue;\n\n const abort = input.abortSignal;\n const onAbort = () => {\n this.connection?.cancel({ sessionId: this.acpSessionId }).catch(() => {});\n };\n if (abort) {\n if (abort.aborted) onAbort();\n else abort.addEventListener(\"abort\", onAbort, { once: true });\n }\n\n this.connection\n .prompt({\n sessionId: this.acpSessionId,\n prompt: buildAcpPromptBlocks(input),\n })\n .then((response: AcpPromptResponse) => {\n queue.push({ type: \"done\", reason: response?.stopReason });\n })\n .catch((error: unknown) => {\n queue.push({ type: \"error\", error: acpErrorMessage(error) });\n })\n .finally(() => {\n if (abort) abort.removeEventListener(\"abort\", onAbort);\n this.rejectAllPending();\n queue.close();\n this.queue = null;\n });\n\n yield* queue;\n }\n\n async approve(approval: AgentHarnessApproval): Promise<void> {\n const pending = this.pendingPermissions.get(approval.id);\n if (!pending) return;\n this.pendingPermissions.delete(approval.id);\n pending.resolve(\n buildAcpPermissionResponse(pending.options, approval.approved),\n );\n }\n\n async detach(): Promise<unknown> {\n const state = { sessionId: this.acpSessionId, cwd: this.cwd };\n await this.destroy();\n return state;\n }\n\n async stop(): Promise<unknown> {\n return this.detach();\n }\n\n async destroy(): Promise<void> {\n if (this.shuttingDown) return;\n this.shuttingDown = true;\n this.rejectAllPending();\n try {\n this.child.stdin?.end();\n } catch {}\n if (!this.childExited && this.child.exitCode === null) {\n try {\n this.child.kill(\"SIGTERM\");\n } catch {}\n const killTimer = setTimeout(() => {\n try {\n if (this.child.exitCode === null) this.child.kill(\"SIGKILL\");\n } catch {}\n }, SIGKILL_GRACE_MS);\n killTimer.unref?.();\n }\n }\n\n // --- ACP Client implementation (agent -> client) ---\n\n private createClient() {\n return {\n sessionUpdate: async (params: AcpSessionNotification) => {\n this.handleSessionUpdate(params.update);\n },\n requestPermission: async (params: AcpRequestPermissionRequest) =>\n this.handlePermission(params),\n readTextFile: async (params: AcpReadTextFileRequest) =>\n this.handleReadTextFile(params),\n writeTextFile: async (params: AcpWriteTextFileRequest) =>\n this.handleWriteTextFile(params),\n };\n }\n\n private handleSessionUpdate(update: AcpSessionUpdate): void {\n if (update?.sessionUpdate === \"tool_call\" && update.title) {\n this.toolTitles.set(update.toolCallId, update.title);\n }\n // Updates that arrive without an active turn are history replay from\n // loadSession; the transcript already contains them, so drop them.\n if (!this.queue) return;\n for (const event of acpUpdateToHarnessEvents(update, (id) =>\n this.toolTitles.get(id),\n )) {\n this.queue.push(event);\n }\n }\n\n private async handlePermission(\n params: AcpRequestPermissionRequest,\n ): Promise<AcpPermissionResponse> {\n const toolCall = params.toolCall ?? {};\n const decision = acpAutoPermissionDecision(\n toolCall.kind ?? undefined,\n this.permissionMode,\n );\n if (decision === \"allow\") {\n const optionId = selectAcpPermissionOption(params.options ?? [], true);\n if (optionId) return { outcome: { outcome: \"selected\", optionId } };\n }\n if (!this.queue) {\n // No surface to prompt on: decline rather than hang the agent's turn.\n return buildAcpPermissionResponse(params.options ?? [], false);\n }\n const id = `acp-approval-${++this.approvalCounter}`;\n const response = new Promise<AcpPermissionResponse>((resolve) => {\n this.pendingPermissions.set(id, {\n resolve,\n options: params.options ?? [],\n });\n });\n this.queue.push({\n type: \"approval-request\",\n id,\n tool: toolCall.toolCallId ?? toolCall.title,\n message: toolCall.title\n ? `Approve: ${toolCall.title}`\n : \"Agent is requesting permission\",\n input: toolCall.rawInput,\n });\n return response;\n }\n\n private async handleReadTextFile(\n params: AcpReadTextFileRequest,\n ): Promise<{ content: string }> {\n const abs = resolveAcpWorkspacePath(this.cwd, params.path);\n const raw = await fs.readFile(abs, \"utf8\");\n return { content: sliceTextFile(raw, params.line, params.limit) };\n }\n\n private async handleWriteTextFile(\n params: AcpWriteTextFileRequest,\n ): Promise<Record<string, never>> {\n const abs = resolveAcpWorkspacePath(this.cwd, params.path);\n const existed = await fileExists(abs);\n await fs.mkdir(path.dirname(abs), { recursive: true });\n await fs.writeFile(abs, params.content, \"utf8\");\n this.queue?.push({\n type: \"file-change\",\n path: params.path,\n operation: existed ? \"update\" : \"create\",\n });\n return {};\n }\n\n private rejectAllPending(): void {\n if (this.pendingPermissions.size === 0) return;\n for (const [, pending] of this.pendingPermissions) {\n pending.resolve({ outcome: { outcome: \"cancelled\" } });\n }\n this.pendingPermissions.clear();\n }\n\n private childExitMessage(): string {\n const tail = this.stderrTail.trim();\n const base = `[acp-harness] ${this.command} exited before the turn completed.`;\n return tail ? `${base}\\n${tail.slice(-1_000)}` : base;\n }\n}\n\n// --- Pure helpers (exported for testing) ---\n\n/** Build the ACP prompt content blocks for a turn. */\nexport function buildAcpPromptBlocks(input: {\n prompt?: string;\n messages?: AgentHarnessMessage[];\n}): Array<{ type: \"text\"; text: string }> {\n if (input.prompt && input.prompt.trim()) {\n return [{ type: \"text\", text: input.prompt }];\n }\n const messages = input.messages ?? [];\n for (let i = messages.length - 1; i >= 0; i--) {\n if (messages[i].role === \"user\") {\n const text = messageToText(messages[i].content);\n if (text.trim()) return [{ type: \"text\", text }];\n }\n }\n const joined = messages\n .map((message) => messageToText(message.content))\n .filter(Boolean)\n .join(\"\\n\\n\");\n return [{ type: \"text\", text: joined }];\n}\n\nfunction messageToText(content: string | unknown[]): string {\n if (typeof content === \"string\") return content;\n if (!Array.isArray(content)) return \"\";\n return content\n .map((part) => {\n if (typeof part === \"string\") return part;\n if (part && typeof part === \"object\" && \"text\" in part) {\n const text = (part as { text?: unknown }).text;\n return typeof text === \"string\" ? text : \"\";\n }\n return \"\";\n })\n .filter(Boolean)\n .join(\"\");\n}\n\n/**\n * Translate a single ACP `session/update` payload into harness events. Pure and\n * stateless; the caller supplies a resolver for tool titles seen on earlier\n * `tool_call` updates so completion events can be labelled.\n */\nexport function acpUpdateToHarnessEvents(\n update: AcpSessionUpdate,\n titleFor?: (toolCallId: string) => string | undefined,\n): AgentHarnessEvent[] {\n switch (update.sessionUpdate) {\n case \"agent_message_chunk\": {\n const text = acpContentBlockToText(update.content);\n return text ? [{ type: \"text-delta\", text }] : [];\n }\n case \"agent_thought_chunk\": {\n const text = acpContentBlockToText(update.content);\n return text ? [{ type: \"thinking-delta\", text }] : [];\n }\n case \"user_message_chunk\":\n // The user's own message; already in the transcript.\n return [];\n case \"tool_call\": {\n const events: AgentHarnessEvent[] = [\n {\n type: \"tool-start\",\n id: update.toolCallId,\n name: update.title || update.kind || \"tool\",\n input: update.rawInput ?? {},\n },\n ];\n events.push(...acpFileChangeEventsFromToolContent(update.content));\n if (isTerminalToolStatus(update.status)) {\n events.push({\n type: \"tool-done\",\n id: update.toolCallId,\n name: update.title || titleFor?.(update.toolCallId) || \"tool\",\n result: update.rawOutput ?? acpToolContentText(update.content),\n });\n }\n return events;\n }\n case \"tool_call_update\": {\n const content = update.content ?? undefined;\n const events: AgentHarnessEvent[] =\n acpFileChangeEventsFromToolContent(content);\n if (isTerminalToolStatus(update.status)) {\n events.push({\n type: \"tool-done\",\n id: update.toolCallId,\n name: update.title || titleFor?.(update.toolCallId) || \"tool\",\n result: update.rawOutput ?? acpToolContentText(content),\n });\n }\n return events;\n }\n case \"plan\":\n return [\n {\n type: \"activity\",\n label: acpPlanLabel(update.entries),\n tool: \"acp:plan\",\n },\n ];\n case \"available_commands_update\":\n case \"current_mode_update\":\n return [];\n default:\n return [];\n }\n}\n\nfunction isTerminalToolStatus(status: unknown): boolean {\n return status === \"completed\" || status === \"failed\";\n}\n\n/** Extract displayable text from an ACP content block. */\nexport function acpContentBlockToText(\n block: AcpContentBlock | undefined,\n): string {\n if (!block || typeof block !== \"object\") return \"\";\n if (block.type === \"text\")\n return typeof block.text === \"string\" ? block.text : \"\";\n if (block.type === \"resource_link\") {\n const label = block.name || block.uri || \"\";\n return block.uri ? `[${label}](${block.uri})` : label;\n }\n return \"\";\n}\n\nfunction acpToolContentText(\n content: AcpToolCallContent[] | undefined | null,\n): string {\n if (!Array.isArray(content)) return \"\";\n return content\n .map((entry) => {\n if (entry?.type === \"content\")\n return acpContentBlockToText(entry.content);\n if (entry?.type === \"diff\" && entry.path) return `diff: ${entry.path}`;\n return \"\";\n })\n .filter(Boolean)\n .join(\"\\n\");\n}\n\n/** Derive file-change events from a tool call's `diff` content blocks. */\nexport function acpFileChangeEventsFromToolContent(\n content: AcpToolCallContent[] | undefined | null,\n): AgentHarnessEvent[] {\n if (!Array.isArray(content)) return [];\n const events: AgentHarnessEvent[] = [];\n for (const entry of content) {\n if (entry?.type === \"diff\" && typeof entry.path === \"string\") {\n events.push({\n type: \"file-change\",\n path: entry.path,\n operation:\n entry.oldText === null || entry.oldText === undefined\n ? \"create\"\n : \"update\",\n });\n }\n }\n return events;\n}\n\nfunction acpPlanLabel(entries: AcpPlanEntry[] | undefined): string {\n const list = Array.isArray(entries) ? entries : [];\n const total = list.length;\n const done = list.filter((entry) => entry?.status === \"completed\").length;\n const active = list.find((entry) => entry?.status === \"in_progress\");\n const suffix = active?.content ? ` — ${active.content}` : \"\";\n return `Updated plan (${done}/${total})${suffix}`;\n}\n\n/**\n * Map an Agent-Native permission mode onto a decision for an ACP permission\n * request, using the tool-call kind the agent reports. Reads always run; edits\n * run under `allow-edits`; everything risky prompts unless `allow-all`.\n */\nexport function acpAutoPermissionDecision(\n kind: string | undefined,\n mode: AgentHarnessPermissionMode,\n): \"allow\" | \"prompt\" {\n if (mode === \"allow-all\") return \"allow\";\n const resolved = kind ?? \"other\";\n const readish =\n resolved === \"read\" ||\n resolved === \"search\" ||\n resolved === \"fetch\" ||\n resolved === \"think\";\n if (readish) return \"allow\";\n if (mode === \"allow-edits\") {\n return resolved === \"edit\" || resolved === \"move\" ? \"allow\" : \"prompt\";\n }\n return \"prompt\";\n}\n\n/**\n * Pick the option id to return for an ACP permission request. Prefers the\n * \"once\" variant so approvals do not silently become \"always\".\n */\nexport function selectAcpPermissionOption(\n options: AcpPermissionOption[],\n approved: boolean,\n): string | undefined {\n const order = approved\n ? ([\"allow_once\", \"allow_always\"] as const)\n : ([\"reject_once\", \"reject_always\"] as const);\n for (const kind of order) {\n const match = options.find((option) => option?.kind === kind);\n if (match) return match.optionId;\n }\n return undefined;\n}\n\nfunction buildAcpPermissionResponse(\n options: AcpPermissionOption[],\n approved: boolean,\n): AcpPermissionResponse {\n const optionId = selectAcpPermissionOption(options, approved);\n if (optionId) return { outcome: { outcome: \"selected\", optionId } };\n return { outcome: { outcome: \"cancelled\" } };\n}\n\n/**\n * Resolve a path requested by the agent against the session workspace, refusing\n * anything that escapes it. The agent already has its own filesystem tools;\n * this `fs/*` surface is a scoped convenience, not an arbitrary read/write hole.\n */\nexport function resolveAcpWorkspacePath(\n cwd: string,\n requestedPath: string,\n): string {\n if (typeof requestedPath !== \"string\" || requestedPath.length === 0) {\n throw new Error(\"[acp-harness] File path must be a non-empty string.\");\n }\n const normalizedCwd = path.resolve(cwd);\n const abs = path.isAbsolute(requestedPath)\n ? path.resolve(requestedPath)\n : path.resolve(normalizedCwd, requestedPath);\n const rel = path.relative(normalizedCwd, abs);\n if (rel === \"\") return abs;\n if (rel === \"..\" || rel.startsWith(`..${path.sep}`) || path.isAbsolute(rel)) {\n throw new Error(\n `[acp-harness] Refusing file access outside the session workspace: ${requestedPath}`,\n );\n }\n return abs;\n}\n\nfunction sliceTextFile(\n content: string,\n line?: number | null,\n limit?: number | null,\n): string {\n if (line == null && limit == null) return content;\n const lines = content.split(\"\\n\");\n const start = line && line > 0 ? line - 1 : 0;\n const end = limit && limit > 0 ? start + limit : lines.length;\n return lines.slice(start, end).join(\"\\n\");\n}\n\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await fs.access(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction acpErrorMessage(error: unknown): string {\n if (error && typeof error === \"object\") {\n const record = error as { message?: unknown; code?: unknown };\n if (typeof record.message === \"string\" && record.message) {\n return record.message;\n }\n if (record.code !== undefined) {\n return `ACP request failed (code ${String(record.code)})`;\n }\n }\n return typeof error === \"string\" ? error : \"ACP request failed\";\n}\n\n// --- Minimal structural mirrors of the ACP schema (avoids a build-time dep) ---\n\ninterface AcpContentBlock {\n type: string;\n text?: string;\n uri?: string;\n name?: string;\n [key: string]: unknown;\n}\n\ninterface AcpToolCallContent {\n type: string;\n content?: AcpContentBlock;\n path?: string;\n oldText?: string | null;\n newText?: string;\n terminalId?: string;\n}\n\ninterface AcpPlanEntry {\n content?: string;\n status?: string;\n priority?: string;\n}\n\nexport type AcpSessionUpdate =\n | {\n sessionUpdate:\n | \"agent_message_chunk\"\n | \"user_message_chunk\"\n | \"agent_thought_chunk\";\n content: AcpContentBlock;\n }\n | {\n sessionUpdate: \"tool_call\";\n toolCallId: string;\n title: string;\n kind?: string;\n status?: string;\n content?: AcpToolCallContent[];\n rawInput?: Record<string, unknown>;\n rawOutput?: Record<string, unknown>;\n locations?: unknown[];\n }\n | {\n sessionUpdate: \"tool_call_update\";\n toolCallId: string;\n title?: string | null;\n kind?: string | null;\n status?: string | null;\n content?: AcpToolCallContent[] | null;\n rawInput?: Record<string, unknown>;\n rawOutput?: Record<string, unknown>;\n }\n | { sessionUpdate: \"plan\"; entries: AcpPlanEntry[] }\n | { sessionUpdate: \"available_commands_update\"; availableCommands: unknown[] }\n | { sessionUpdate: \"current_mode_update\"; currentModeId: string };\n\ninterface AcpSessionNotification {\n sessionId: string;\n update: AcpSessionUpdate;\n}\n\ninterface AcpPermissionOption {\n optionId: string;\n name: string;\n kind: \"allow_once\" | \"allow_always\" | \"reject_once\" | \"reject_always\";\n}\n\ninterface AcpRequestPermissionRequest {\n sessionId: string;\n options: AcpPermissionOption[];\n toolCall: {\n toolCallId?: string;\n title?: string;\n kind?: string | null;\n rawInput?: Record<string, unknown>;\n };\n}\n\ntype AcpPermissionResponse = {\n outcome: { outcome: \"selected\"; optionId: string } | { outcome: \"cancelled\" };\n};\n\ninterface AcpReadTextFileRequest {\n sessionId: string;\n path: string;\n line?: number | null;\n limit?: number | null;\n}\n\ninterface AcpWriteTextFileRequest {\n sessionId: string;\n path: string;\n content: string;\n}\n\ninterface AcpPromptResponse {\n stopReason?: string;\n}\n\n/** Minimal async queue bridging ACP's callback updates to an async iterable. */\nclass AsyncEventQueue<T> implements AsyncIterable<T> {\n private readonly values: T[] = [];\n private readonly resolvers: Array<(result: IteratorResult<T>) => void> = [];\n private closed = false;\n\n push(value: T): void {\n if (this.closed) return;\n const resolver = this.resolvers.shift();\n if (resolver) resolver({ value, done: false });\n else this.values.push(value);\n }\n\n close(): void {\n if (this.closed) return;\n this.closed = true;\n let resolver: ((result: IteratorResult<T>) => void) | undefined;\n while ((resolver = this.resolvers.shift())) {\n resolver({ value: undefined as never, done: true });\n }\n }\n\n [Symbol.asyncIterator](): AsyncIterator<T> {\n return {\n next: (): Promise<IteratorResult<T>> => {\n if (this.values.length > 0) {\n return Promise.resolve({\n value: this.values.shift() as T,\n done: false,\n });\n }\n if (this.closed) {\n return Promise.resolve({ value: undefined as never, done: true });\n }\n return new Promise<IteratorResult<T>>((resolve) => {\n this.resolvers.push(resolve);\n });\n },\n };\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Built-in ACP harness presets.
3
+ *
4
+ * These register convenient defaults for known ACP-compliant local coding
5
+ * agents. Each preset's command/args are overridable through the resolve
6
+ * config, e.g.
7
+ *
8
+ * resolveAgentHarness("acp:gemini", { command: "gemini" });
9
+ *
10
+ * The default commands launch the agents through `npx` so they work without a
11
+ * prior global install. They are documented and overridable because agent CLIs
12
+ * still evolve their ACP entry flags.
13
+ */
14
+ interface AcpPreset {
15
+ name: string;
16
+ label: string;
17
+ description: string;
18
+ command: string;
19
+ args: string[];
20
+ }
21
+ export declare const BUILTIN_ACP_PRESETS: AcpPreset[];
22
+ /** Register the built-in ACP presets. */
23
+ export declare function registerBuiltinAcpHarnesses(): void;
24
+ export {};
25
+ //# sourceMappingURL=acp-builtin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acp-builtin.d.ts","sourceRoot":"","sources":["../../../src/agent/harness/acp-builtin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,eAAO,MAAM,mBAAmB,EAAE,SAAS,EAe1C,CAAC;AAEF,yCAAyC;AACzC,wBAAgB,2BAA2B,IAAI,IAAI,CAuBlD"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Built-in ACP harness presets.
3
+ *
4
+ * These register convenient defaults for known ACP-compliant local coding
5
+ * agents. Each preset's command/args are overridable through the resolve
6
+ * config, e.g.
7
+ *
8
+ * resolveAgentHarness("acp:gemini", { command: "gemini" });
9
+ *
10
+ * The default commands launch the agents through `npx` so they work without a
11
+ * prior global install. They are documented and overridable because agent CLIs
12
+ * still evolve their ACP entry flags.
13
+ */
14
+ import { createAcpHarnessAdapter, } from "./acp-adapter.js";
15
+ import { registerAgentHarness } from "./registry.js";
16
+ export const BUILTIN_ACP_PRESETS = [
17
+ {
18
+ name: "acp:gemini",
19
+ label: "Gemini CLI (ACP)",
20
+ description: "Drives the Gemini CLI as a local ACP coding agent.",
21
+ command: "npx",
22
+ args: ["-y", "@google/gemini-cli", "--experimental-acp"],
23
+ },
24
+ {
25
+ name: "acp:claude-code",
26
+ label: "Claude Code (ACP)",
27
+ description: "Drives Claude Code as a local ACP coding agent.",
28
+ command: "npx",
29
+ args: ["-y", "@zed-industries/claude-code-acp"],
30
+ },
31
+ ];
32
+ /** Register the built-in ACP presets. */
33
+ export function registerBuiltinAcpHarnesses() {
34
+ for (const preset of BUILTIN_ACP_PRESETS) {
35
+ registerAgentHarness({
36
+ name: preset.name,
37
+ label: preset.label,
38
+ description: preset.description,
39
+ installPackage: createAcpHarnessAdapter({ command: preset.command })
40
+ .installPackage,
41
+ capabilities: createAcpHarnessAdapter({ command: preset.command })
42
+ .capabilities,
43
+ create: (config) => {
44
+ const overrides = (config ?? {});
45
+ return createAcpHarnessAdapter({
46
+ name: preset.name,
47
+ label: preset.label,
48
+ description: preset.description,
49
+ command: preset.command,
50
+ args: preset.args,
51
+ ...overrides,
52
+ });
53
+ },
54
+ });
55
+ }
56
+ }
57
+ //# sourceMappingURL=acp-builtin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acp-builtin.js","sourceRoot":"","sources":["../../../src/agent/harness/acp-builtin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,uBAAuB,GAExB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAUrD,MAAM,CAAC,MAAM,mBAAmB,GAAgB;IAC9C;QACE,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,oDAAoD;QACjE,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,CAAC,IAAI,EAAE,oBAAoB,EAAE,oBAAoB,CAAC;KACzD;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EAAE,iDAAiD;QAC9D,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,CAAC,IAAI,EAAE,iCAAiC,CAAC;KAChD;CACF,CAAC;AAEF,yCAAyC;AACzC,MAAM,UAAU,2BAA2B;IACzC,KAAK,MAAM,MAAM,IAAI,mBAAmB,EAAE,CAAC;QACzC,oBAAoB,CAAC;YACnB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,cAAc,EAAE,uBAAuB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;iBACjE,cAAc;YACjB,YAAY,EAAE,uBAAuB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;iBAC/D,YAAY;YACf,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;gBACjB,MAAM,SAAS,GAAG,CAAC,MAAM,IAAI,EAAE,CAAsC,CAAC;gBACtE,OAAO,uBAAuB,CAAC;oBAC7B,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,WAAW,EAAE,MAAM,CAAC,WAAW;oBAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,GAAG,SAAS;iBACb,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["/**\n * Built-in ACP harness presets.\n *\n * These register convenient defaults for known ACP-compliant local coding\n * agents. Each preset's command/args are overridable through the resolve\n * config, e.g.\n *\n * resolveAgentHarness(\"acp:gemini\", { command: \"gemini\" });\n *\n * The default commands launch the agents through `npx` so they work without a\n * prior global install. They are documented and overridable because agent CLIs\n * still evolve their ACP entry flags.\n */\n\nimport {\n createAcpHarnessAdapter,\n type AcpHarnessAdapterOptions,\n} from \"./acp-adapter.js\";\nimport { registerAgentHarness } from \"./registry.js\";\n\ninterface AcpPreset {\n name: string;\n label: string;\n description: string;\n command: string;\n args: string[];\n}\n\nexport const BUILTIN_ACP_PRESETS: AcpPreset[] = [\n {\n name: \"acp:gemini\",\n label: \"Gemini CLI (ACP)\",\n description: \"Drives the Gemini CLI as a local ACP coding agent.\",\n command: \"npx\",\n args: [\"-y\", \"@google/gemini-cli\", \"--experimental-acp\"],\n },\n {\n name: \"acp:claude-code\",\n label: \"Claude Code (ACP)\",\n description: \"Drives Claude Code as a local ACP coding agent.\",\n command: \"npx\",\n args: [\"-y\", \"@zed-industries/claude-code-acp\"],\n },\n];\n\n/** Register the built-in ACP presets. */\nexport function registerBuiltinAcpHarnesses(): void {\n for (const preset of BUILTIN_ACP_PRESETS) {\n registerAgentHarness({\n name: preset.name,\n label: preset.label,\n description: preset.description,\n installPackage: createAcpHarnessAdapter({ command: preset.command })\n .installPackage,\n capabilities: createAcpHarnessAdapter({ command: preset.command })\n .capabilities,\n create: (config) => {\n const overrides = (config ?? {}) as Partial<AcpHarnessAdapterOptions>;\n return createAcpHarnessAdapter({\n name: preset.name,\n label: preset.label,\n description: preset.description,\n command: preset.command,\n args: preset.args,\n ...overrides,\n });\n },\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"builtin.d.ts","sourceRoot":"","sources":["../../../src/agent/harness/builtin.ts"],"names":[],"mappings":"AAYA,wBAAgB,6BAA6B,IAAI,IAAI,CAgBpD"}
1
+ {"version":3,"file":"builtin.d.ts","sourceRoot":"","sources":["../../../src/agent/harness/builtin.ts"],"names":[],"mappings":"AAiBA,wBAAgB,6BAA6B,IAAI,IAAI,CAgCpD"}
@@ -1,3 +1,5 @@
1
+ import { createAcpHarnessAdapter, } from "./acp-adapter.js";
2
+ import { registerBuiltinAcpHarnesses } from "./acp-builtin.js";
1
3
  import { createAiSdkHarnessAdapter, } from "./ai-sdk-adapter.js";
2
4
  import { registerAgentHarness } from "./registry.js";
3
5
  const AI_SDK_HARNESS_RUNTIMES = [
@@ -20,5 +22,18 @@ export function registerBuiltinAgentHarnesses() {
20
22
  }),
21
23
  });
22
24
  }
25
+ // Generic ACP entry: resolve with { command, args } for any ACP agent.
26
+ const acpAdapter = createAcpHarnessAdapter({ command: "acp" });
27
+ registerAgentHarness({
28
+ name: "acp",
29
+ label: "ACP Agent",
30
+ description: "Drives a local ACP-compliant coding agent over stdio.",
31
+ installPackage: acpAdapter.installPackage,
32
+ capabilities: acpAdapter.capabilities,
33
+ create: (config) => createAcpHarnessAdapter({
34
+ ...(config ?? {}),
35
+ }),
36
+ });
37
+ registerBuiltinAcpHarnesses();
23
38
  }
24
39
  //# sourceMappingURL=builtin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"builtin.js","sourceRoot":"","sources":["../../../src/agent/harness/builtin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAE1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,uBAAuB,GAA0B;IACrD,aAAa;IACb,OAAO;IACP,IAAI;CACL,CAAC;AAEF,MAAM,UAAU,6BAA6B;IAC3C,KAAK,MAAM,OAAO,IAAI,uBAAuB,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,yBAAyB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QACvD,oBAAoB,CAAC;YACnB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CACjB,yBAAyB,CAAC;gBACxB,OAAO;gBACP,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC;aACiC,CAAC;SACxD,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import {\n createAiSdkHarnessAdapter,\n type AiSdkHarnessRuntime,\n} from \"./ai-sdk-adapter.js\";\nimport { registerAgentHarness } from \"./registry.js\";\n\nconst AI_SDK_HARNESS_RUNTIMES: AiSdkHarnessRuntime[] = [\n \"claude-code\",\n \"codex\",\n \"pi\",\n];\n\nexport function registerBuiltinAgentHarnesses(): void {\n for (const runtime of AI_SDK_HARNESS_RUNTIMES) {\n const adapter = createAiSdkHarnessAdapter({ runtime });\n registerAgentHarness({\n name: adapter.name,\n label: adapter.label,\n description: adapter.description,\n installPackage: adapter.installPackage,\n capabilities: adapter.capabilities,\n create: (config) =>\n createAiSdkHarnessAdapter({\n runtime,\n ...(config ?? {}),\n } as Parameters<typeof createAiSdkHarnessAdapter>[0]),\n });\n }\n}\n"]}
1
+ {"version":3,"file":"builtin.js","sourceRoot":"","sources":["../../../src/agent/harness/builtin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GAExB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EACL,yBAAyB,GAE1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,uBAAuB,GAA0B;IACrD,aAAa;IACb,OAAO;IACP,IAAI;CACL,CAAC;AAEF,MAAM,UAAU,6BAA6B;IAC3C,KAAK,MAAM,OAAO,IAAI,uBAAuB,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,yBAAyB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QACvD,oBAAoB,CAAC;YACnB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CACjB,yBAAyB,CAAC;gBACxB,OAAO;gBACP,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC;aACiC,CAAC;SACxD,CAAC,CAAC;IACL,CAAC;IAED,uEAAuE;IACvE,MAAM,UAAU,GAAG,uBAAuB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/D,oBAAoB,CAAC;QACnB,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,uDAAuD;QACpE,cAAc,EAAE,UAAU,CAAC,cAAc;QACzC,YAAY,EAAE,UAAU,CAAC,YAAY;QACrC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CACjB,uBAAuB,CAAC;YACtB,GAAI,CAAC,MAAM,IAAI,EAAE,CAAuC;SACzD,CAAC;KACL,CAAC,CAAC;IAEH,2BAA2B,EAAE,CAAC;AAChC,CAAC","sourcesContent":["import {\n createAcpHarnessAdapter,\n type AcpHarnessAdapterOptions,\n} from \"./acp-adapter.js\";\nimport { registerBuiltinAcpHarnesses } from \"./acp-builtin.js\";\nimport {\n createAiSdkHarnessAdapter,\n type AiSdkHarnessRuntime,\n} from \"./ai-sdk-adapter.js\";\nimport { registerAgentHarness } from \"./registry.js\";\n\nconst AI_SDK_HARNESS_RUNTIMES: AiSdkHarnessRuntime[] = [\n \"claude-code\",\n \"codex\",\n \"pi\",\n];\n\nexport function registerBuiltinAgentHarnesses(): void {\n for (const runtime of AI_SDK_HARNESS_RUNTIMES) {\n const adapter = createAiSdkHarnessAdapter({ runtime });\n registerAgentHarness({\n name: adapter.name,\n label: adapter.label,\n description: adapter.description,\n installPackage: adapter.installPackage,\n capabilities: adapter.capabilities,\n create: (config) =>\n createAiSdkHarnessAdapter({\n runtime,\n ...(config ?? {}),\n } as Parameters<typeof createAiSdkHarnessAdapter>[0]),\n });\n }\n\n // Generic ACP entry: resolve with { command, args } for any ACP agent.\n const acpAdapter = createAcpHarnessAdapter({ command: \"acp\" });\n registerAgentHarness({\n name: \"acp\",\n label: \"ACP Agent\",\n description: \"Drives a local ACP-compliant coding agent over stdio.\",\n installPackage: acpAdapter.installPackage,\n capabilities: acpAdapter.capabilities,\n create: (config) =>\n createAcpHarnessAdapter({\n ...((config ?? {}) as Partial<AcpHarnessAdapterOptions>),\n }),\n });\n\n registerBuiltinAcpHarnesses();\n}\n"]}
@@ -4,6 +4,8 @@ export { getAgentHarnessEntry, isAgentHarnessPackageInstalled, listAgentHarnesse
4
4
  export { ensureAgentHarnessSessionTables, getAgentHarnessSession, getAgentHarnessSessionByRunId, getLatestAgentHarnessSessionForThread, listAgentHarnessSessions, markAgentHarnessSessionStopped, saveAgentHarnessSession, updateAgentHarnessSession, type AgentHarnessSessionStatus, type SaveAgentHarnessSessionInput, type StoredAgentHarnessSession, } from "./store.js";
5
5
  export { sendAgentHarnessEvent, startAgentHarnessRun, type StartAgentHarnessRunOptions, } from "./runner.js";
6
6
  export { aiSdkHarnessPartToEvents, createAiSdkHarnessAdapter, type AiSdkHarnessAdapterOptions, type AiSdkHarnessRuntime, type CodexCliAuthConfig, } from "./ai-sdk-adapter.js";
7
+ export { ACP_PACKAGE, acpAutoPermissionDecision, acpContentBlockToText, acpFileChangeEventsFromToolContent, acpUpdateToHarnessEvents, buildAcpPromptBlocks, createAcpHarnessAdapter, resolveAcpWorkspacePath, selectAcpPermissionOption, type AcpHarnessAdapterOptions, type AcpSessionUpdate, } from "./acp-adapter.js";
8
+ export { BUILTIN_ACP_PRESETS, registerBuiltinAcpHarnesses, } from "./acp-builtin.js";
7
9
  export { registerBuiltinAgentHarnesses } from "./builtin.js";
8
10
  export { agentHarnessBackgroundAgentController, createAgentHarnessBackgroundAgentController, getAgentHarnessBackgroundRun, listAgentHarnessBackgroundRuns, listAgentHarnessBackgroundTranscriptEvents, stopAgentHarnessBackgroundRun, } from "./background.js";
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/harness/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,kCAAkC,EAClC,eAAe,IAAI,2BAA2B,GAC/C,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EACtB,6BAA6B,EAC7B,qCAAqC,EACrC,wBAAwB,EACxB,8BAA8B,EAC9B,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,GAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EACL,qCAAqC,EACrC,2CAA2C,EAC3C,4BAA4B,EAC5B,8BAA8B,EAC9B,0CAA0C,EAC1C,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/harness/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,kCAAkC,EAClC,eAAe,IAAI,2BAA2B,GAC/C,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EACtB,6BAA6B,EAC7B,qCAAqC,EACrC,wBAAwB,EACxB,8BAA8B,EAC9B,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,GAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,yBAAyB,EACzB,qBAAqB,EACrB,kCAAkC,EAClC,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EACL,qCAAqC,EACrC,2CAA2C,EAC3C,4BAA4B,EAC5B,8BAA8B,EAC9B,0CAA0C,EAC1C,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC"}
@@ -3,6 +3,8 @@ export { getAgentHarnessEntry, isAgentHarnessPackageInstalled, listAgentHarnesse
3
3
  export { ensureAgentHarnessSessionTables, getAgentHarnessSession, getAgentHarnessSessionByRunId, getLatestAgentHarnessSessionForThread, listAgentHarnessSessions, markAgentHarnessSessionStopped, saveAgentHarnessSession, updateAgentHarnessSession, } from "./store.js";
4
4
  export { sendAgentHarnessEvent, startAgentHarnessRun, } from "./runner.js";
5
5
  export { aiSdkHarnessPartToEvents, createAiSdkHarnessAdapter, } from "./ai-sdk-adapter.js";
6
+ export { ACP_PACKAGE, acpAutoPermissionDecision, acpContentBlockToText, acpFileChangeEventsFromToolContent, acpUpdateToHarnessEvents, buildAcpPromptBlocks, createAcpHarnessAdapter, resolveAcpWorkspacePath, selectAcpPermissionOption, } from "./acp-adapter.js";
7
+ export { BUILTIN_ACP_PRESETS, registerBuiltinAcpHarnesses, } from "./acp-builtin.js";
6
8
  export { registerBuiltinAgentHarnesses } from "./builtin.js";
7
9
  export { agentHarnessBackgroundAgentController, createAgentHarnessBackgroundAgentController, getAgentHarnessBackgroundRun, listAgentHarnessBackgroundRuns, listAgentHarnessBackgroundTranscriptEvents, stopAgentHarnessBackgroundRun, } from "./background.js";
8
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agent/harness/index.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,kCAAkC,EAClC,eAAe,IAAI,2BAA2B,GAC/C,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,GAEpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EACtB,6BAA6B,EAC7B,qCAAqC,EACrC,wBAAwB,EACxB,8BAA8B,EAC9B,uBAAuB,EACvB,yBAAyB,GAI1B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAErB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAI1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EACL,qCAAqC,EACrC,2CAA2C,EAC3C,4BAA4B,EAC5B,8BAA8B,EAC9B,0CAA0C,EAC1C,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC","sourcesContent":["export type {\n AgentHarnessAdapter,\n AgentHarnessApproval,\n AgentHarnessCapabilities,\n AgentHarnessContinueInput,\n AgentHarnessCreateSessionOptions,\n AgentHarnessEvent,\n AgentHarnessMessage,\n AgentHarnessPermissionMode,\n AgentHarnessSession,\n AgentHarnessTurnInput,\n} from \"./types.js\";\nexport {\n agentHarnessEventToAgentChatEvents,\n stringifyResult as stringifyAgentHarnessResult,\n} from \"./translate.js\";\nexport {\n getAgentHarnessEntry,\n isAgentHarnessPackageInstalled,\n listAgentHarnesses,\n registerAgentHarness,\n resolveAgentHarness,\n type AgentHarnessEntry,\n} from \"./registry.js\";\nexport {\n ensureAgentHarnessSessionTables,\n getAgentHarnessSession,\n getAgentHarnessSessionByRunId,\n getLatestAgentHarnessSessionForThread,\n listAgentHarnessSessions,\n markAgentHarnessSessionStopped,\n saveAgentHarnessSession,\n updateAgentHarnessSession,\n type AgentHarnessSessionStatus,\n type SaveAgentHarnessSessionInput,\n type StoredAgentHarnessSession,\n} from \"./store.js\";\nexport {\n sendAgentHarnessEvent,\n startAgentHarnessRun,\n type StartAgentHarnessRunOptions,\n} from \"./runner.js\";\nexport {\n aiSdkHarnessPartToEvents,\n createAiSdkHarnessAdapter,\n type AiSdkHarnessAdapterOptions,\n type AiSdkHarnessRuntime,\n type CodexCliAuthConfig,\n} from \"./ai-sdk-adapter.js\";\nexport { registerBuiltinAgentHarnesses } from \"./builtin.js\";\nexport {\n agentHarnessBackgroundAgentController,\n createAgentHarnessBackgroundAgentController,\n getAgentHarnessBackgroundRun,\n listAgentHarnessBackgroundRuns,\n listAgentHarnessBackgroundTranscriptEvents,\n stopAgentHarnessBackgroundRun,\n} from \"./background.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agent/harness/index.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,kCAAkC,EAClC,eAAe,IAAI,2BAA2B,GAC/C,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,GAEpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EACtB,6BAA6B,EAC7B,qCAAqC,EACrC,wBAAwB,EACxB,8BAA8B,EAC9B,uBAAuB,EACvB,yBAAyB,GAI1B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAErB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAI1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,yBAAyB,EACzB,qBAAqB,EACrB,kCAAkC,EAClC,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,GAG1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EACL,qCAAqC,EACrC,2CAA2C,EAC3C,4BAA4B,EAC5B,8BAA8B,EAC9B,0CAA0C,EAC1C,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC","sourcesContent":["export type {\n AgentHarnessAdapter,\n AgentHarnessApproval,\n AgentHarnessCapabilities,\n AgentHarnessContinueInput,\n AgentHarnessCreateSessionOptions,\n AgentHarnessEvent,\n AgentHarnessMessage,\n AgentHarnessPermissionMode,\n AgentHarnessSession,\n AgentHarnessTurnInput,\n} from \"./types.js\";\nexport {\n agentHarnessEventToAgentChatEvents,\n stringifyResult as stringifyAgentHarnessResult,\n} from \"./translate.js\";\nexport {\n getAgentHarnessEntry,\n isAgentHarnessPackageInstalled,\n listAgentHarnesses,\n registerAgentHarness,\n resolveAgentHarness,\n type AgentHarnessEntry,\n} from \"./registry.js\";\nexport {\n ensureAgentHarnessSessionTables,\n getAgentHarnessSession,\n getAgentHarnessSessionByRunId,\n getLatestAgentHarnessSessionForThread,\n listAgentHarnessSessions,\n markAgentHarnessSessionStopped,\n saveAgentHarnessSession,\n updateAgentHarnessSession,\n type AgentHarnessSessionStatus,\n type SaveAgentHarnessSessionInput,\n type StoredAgentHarnessSession,\n} from \"./store.js\";\nexport {\n sendAgentHarnessEvent,\n startAgentHarnessRun,\n type StartAgentHarnessRunOptions,\n} from \"./runner.js\";\nexport {\n aiSdkHarnessPartToEvents,\n createAiSdkHarnessAdapter,\n type AiSdkHarnessAdapterOptions,\n type AiSdkHarnessRuntime,\n type CodexCliAuthConfig,\n} from \"./ai-sdk-adapter.js\";\nexport {\n ACP_PACKAGE,\n acpAutoPermissionDecision,\n acpContentBlockToText,\n acpFileChangeEventsFromToolContent,\n acpUpdateToHarnessEvents,\n buildAcpPromptBlocks,\n createAcpHarnessAdapter,\n resolveAcpWorkspacePath,\n selectAcpPermissionOption,\n type AcpHarnessAdapterOptions,\n type AcpSessionUpdate,\n} from \"./acp-adapter.js\";\nexport {\n BUILTIN_ACP_PRESETS,\n registerBuiltinAcpHarnesses,\n} from \"./acp-builtin.js\";\nexport { registerBuiltinAgentHarnesses } from \"./builtin.js\";\nexport {\n agentHarnessBackgroundAgentController,\n createAgentHarnessBackgroundAgentController,\n getAgentHarnessBackgroundRun,\n listAgentHarnessBackgroundRuns,\n listAgentHarnessBackgroundTranscriptEvents,\n stopAgentHarnessBackgroundRun,\n} from \"./background.js\";\n"]}
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: harness-agents
3
3
  description: >-
4
- Add or use full agent harness runtimes like Claude Code, Codex, Pi, Cursor, or Mastra inside Agent Native.
4
+ Add or use full agent harness runtimes like Claude Code, Codex, Pi, Cursor, Mastra, or ACP agents inside Agent Native.
5
5
  scope: dev
6
6
  ---
7
7
 
@@ -68,6 +68,52 @@ Harness runs are projected into the shared `BackgroundAgentRun` shape with
68
68
  `createAgentHarnessBackgroundAgentController()` and are available through the
69
69
  existing run routes as `goalId=agent-harness`.
70
70
 
71
+ ## ACP Agents
72
+
73
+ Agent Native can act as an [ACP](https://agentclientprotocol.com) (Agent Client
74
+ Protocol) client and drive a local coding agent — Gemini CLI, Claude Code, or
75
+ any ACP-compliant agent — through this same substrate. This is scoped to **local
76
+ coding**: the agent is spawned as a child process speaking newline-delimited
77
+ JSON-RPC over stdio, and inherits the parent environment so it reuses the user's
78
+ local CLI login. It is not a hosted/sandboxed transport, and it is not a
79
+ chat/A2A transport.
80
+
81
+ ```ts
82
+ import {
83
+ registerBuiltinAgentHarnesses,
84
+ resolveAgentHarness,
85
+ } from "@agent-native/core/agent/harness";
86
+
87
+ registerBuiltinAgentHarnesses();
88
+
89
+ // Built-in presets (commands overridable via the resolve config):
90
+ const gemini = resolveAgentHarness("acp:gemini");
91
+ const claude = resolveAgentHarness("acp:claude-code");
92
+
93
+ // Or any ACP agent by command:
94
+ const custom = resolveAgentHarness("acp", {
95
+ command: "gemini",
96
+ args: ["--experimental-acp"],
97
+ });
98
+ ```
99
+
100
+ - The protocol transport (`@zed-industries/agent-client-protocol`) is an optional
101
+ dependency loaded lazily; `installPackage` surfaces a clear install hint.
102
+ - The agent binary (e.g. `@google/gemini-cli`, `@zed-industries/claude-code-acp`)
103
+ is a separate external CLI the user installs; presets launch it through `npx`
104
+ by default and the command/args are overridable because agent ACP entry flags
105
+ still evolve.
106
+ - `permissionMode` maps onto ACP `session/request_permission` using the reported
107
+ tool-call kind: reads always run, edits run under `allow-edits`, everything
108
+ risky prompts unless `allow-all`. Approvals surface as `approval-request`
109
+ events; answer them through the harness session's `approve()`.
110
+ - `resumeState` carries the ACP `sessionId`; resume works when the agent
111
+ advertises the `loadSession` capability and degrades to a fresh session
112
+ otherwise.
113
+ - `fs/read_text_file` and `fs/write_text_file` are served against the session
114
+ workspace and refuse paths that escape it; terminal methods are not advertised
115
+ (the agent uses its own shell).
116
+
71
117
  ## Adapter Guidance
72
118
 
73
119
  - Keep harness packages optional. Use dynamic imports in adapters and expose an
@@ -295,8 +295,10 @@ export function SupportAgentChat() {
295
295
  Ready-made runtime helpers exist for OpenAI Agents, OpenAI Responses, the Claude
296
296
  Agent SDK, the Vercel AI SDK, and AG-UI, plus the normalized HTTP runtime above
297
297
  for any other agent (Mastra, Flue, Eve, LangGraph, or a custom service). ACP is
298
- not the default end-user app chat protocol, and Agent-Native does not currently
299
- claim A2UI support.
298
+ not the end-user app chat or A2A transport, and Agent-Native does not currently
299
+ claim A2UI support. ACP is supported in one specific place — driving a local
300
+ coding agent (Gemini CLI, Claude Code, …) through the
301
+ [harness layer](/docs/harness-agents#acp), not as the chat runtime here.
300
302
 
301
303
  [Native Chat UI — BYO agent runtimes](/docs/native-chat-ui#byo-agent-runtimes)
302
304
  is the canonical home for the event shapes, the runtime helpers, and `chatUI`
@@ -62,6 +62,65 @@ app that never uses a harness does not pay for it. Each adapter carries an
62
62
  error if the packages are missing, and `isAgentHarnessPackageInstalled(entry)`
63
63
  lets you check first.
64
64
 
65
+ `registerBuiltinAgentHarnesses()` also registers the [ACP](#acp) harnesses
66
+ (`acp`, `acp:gemini`, `acp:claude-code`).
67
+
68
+ ## ACP agents {#acp}
69
+
70
+ Agent-Native can act as an [ACP](https://agentclientprotocol.com) (Agent Client
71
+ Protocol) **client** and drive a local coding agent — Gemini CLI, Claude Code,
72
+ or any ACP-compliant agent — through this same substrate. The agent runs as a
73
+ local subprocess that speaks newline-delimited JSON-RPC over stdio; ACP's editor
74
+ ↔ agent model is exactly this shape.
75
+
76
+ This adapter is scoped to **local coding**. The child process inherits the
77
+ parent environment, so the agent reuses whatever local CLI login it already has
78
+ (for example `gemini` or `claude` auth in the user's home dir). It is not a
79
+ hosted or sandboxed transport, and it is not a chat/A2A transport — for those,
80
+ see [Agent Surfaces](/docs/agent-surfaces).
81
+
82
+ | Name | Default command | Resumable\* |
83
+ | ----------------- | ---------------------------------------------- | ----------- |
84
+ | `acp` | _(supply `command`/`args` via config)_ | yes |
85
+ | `acp:gemini` | `npx -y @google/gemini-cli --experimental-acp` | yes |
86
+ | `acp:claude-code` | `npx -y @zed-industries/claude-code-acp` | yes |
87
+
88
+ \*Resume works when the agent advertises the `loadSession` capability and
89
+ degrades to a fresh session otherwise.
90
+
91
+ ```ts
92
+ import {
93
+ registerBuiltinAgentHarnesses,
94
+ resolveAgentHarness,
95
+ } from "@agent-native/core/agent/harness";
96
+
97
+ registerBuiltinAgentHarnesses();
98
+
99
+ // A built-in preset (command/args are overridable through the resolve config):
100
+ const adapter = resolveAgentHarness("acp:gemini");
101
+
102
+ // Or any ACP agent by command:
103
+ const custom = resolveAgentHarness("acp", {
104
+ command: "gemini",
105
+ args: ["--experimental-acp"],
106
+ });
107
+ ```
108
+
109
+ The protocol transport (`@zed-industries/agent-client-protocol`) is an optional
110
+ dependency loaded lazily through the `installPackage` hint, just like the AI SDK
111
+ harnesses. The agent binary itself (`@google/gemini-cli`,
112
+ `@zed-industries/claude-code-acp`, …) is a separate external CLI; the presets
113
+ launch it through `npx` and the command/args stay overridable because agent ACP
114
+ entry flags still evolve.
115
+
116
+ `permissionMode` maps onto ACP `session/request_permission` using the tool-call
117
+ kind the agent reports: reads always run, edits run under `allow-edits`, and
118
+ everything risky prompts unless `allow-all`. Approvals surface as the normal
119
+ `approval-request` events. The adapter serves `fs/read_text_file` and
120
+ `fs/write_text_file` against the session workspace (refusing paths that escape
121
+ it) and writes emit `file-change` events; terminal methods are not advertised,
122
+ so the agent uses its own shell.
123
+
65
124
  ## Codex auth: Code UI vs harness sandboxes {#codex-auth}
66
125
 
67
126
  There are two Codex surfaces, and they authenticate differently:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.65.0",
3
+ "version": "0.66.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: harness-agents
3
3
  description: >-
4
- Add or use full agent harness runtimes like Claude Code, Codex, Pi, Cursor, or Mastra inside Agent Native.
4
+ Add or use full agent harness runtimes like Claude Code, Codex, Pi, Cursor, Mastra, or ACP agents inside Agent Native.
5
5
  scope: dev
6
6
  ---
7
7
 
@@ -68,6 +68,52 @@ Harness runs are projected into the shared `BackgroundAgentRun` shape with
68
68
  `createAgentHarnessBackgroundAgentController()` and are available through the
69
69
  existing run routes as `goalId=agent-harness`.
70
70
 
71
+ ## ACP Agents
72
+
73
+ Agent Native can act as an [ACP](https://agentclientprotocol.com) (Agent Client
74
+ Protocol) client and drive a local coding agent — Gemini CLI, Claude Code, or
75
+ any ACP-compliant agent — through this same substrate. This is scoped to **local
76
+ coding**: the agent is spawned as a child process speaking newline-delimited
77
+ JSON-RPC over stdio, and inherits the parent environment so it reuses the user's
78
+ local CLI login. It is not a hosted/sandboxed transport, and it is not a
79
+ chat/A2A transport.
80
+
81
+ ```ts
82
+ import {
83
+ registerBuiltinAgentHarnesses,
84
+ resolveAgentHarness,
85
+ } from "@agent-native/core/agent/harness";
86
+
87
+ registerBuiltinAgentHarnesses();
88
+
89
+ // Built-in presets (commands overridable via the resolve config):
90
+ const gemini = resolveAgentHarness("acp:gemini");
91
+ const claude = resolveAgentHarness("acp:claude-code");
92
+
93
+ // Or any ACP agent by command:
94
+ const custom = resolveAgentHarness("acp", {
95
+ command: "gemini",
96
+ args: ["--experimental-acp"],
97
+ });
98
+ ```
99
+
100
+ - The protocol transport (`@zed-industries/agent-client-protocol`) is an optional
101
+ dependency loaded lazily; `installPackage` surfaces a clear install hint.
102
+ - The agent binary (e.g. `@google/gemini-cli`, `@zed-industries/claude-code-acp`)
103
+ is a separate external CLI the user installs; presets launch it through `npx`
104
+ by default and the command/args are overridable because agent ACP entry flags
105
+ still evolve.
106
+ - `permissionMode` maps onto ACP `session/request_permission` using the reported
107
+ tool-call kind: reads always run, edits run under `allow-edits`, everything
108
+ risky prompts unless `allow-all`. Approvals surface as `approval-request`
109
+ events; answer them through the harness session's `approve()`.
110
+ - `resumeState` carries the ACP `sessionId`; resume works when the agent
111
+ advertises the `loadSession` capability and degrades to a fresh session
112
+ otherwise.
113
+ - `fs/read_text_file` and `fs/write_text_file` are served against the session
114
+ workspace and refuse paths that escape it; terminal methods are not advertised
115
+ (the agent uses its own shell).
116
+
71
117
  ## Adapter Guidance
72
118
 
73
119
  - Keep harness packages optional. Use dynamic imports in adapters and expose an