feat: add agent-device acp, a deterministic stdio ACP agent#1132
feat: add agent-device acp, a deterministic stdio ACP agent#1132XeonBloomfield wants to merge 5 commits into
Conversation
|
Review finding: |
| ``` | ||
| open com.example.app --platform ios | ||
| snapshot -i | ||
| /snapshot -i |
There was a problem hiding this comment.
I think this line within the guide can be reverted as the previous behavior still works!
|
Ready for human review. I rechecked #1132 at head Checks: 15 successful; only expected skipped |
Add an Agent Client Protocol (ACP) v1 agent mode so ACP clients such as Zed can drive devices from the agent panel. agent-device has no LLM, so the agent is deterministic: each prompt line is one agent-device command in CLI syntax, executed through the same AgentDeviceClient path as MCP tools. - Hand-rolled protocol layer in src/acp/ mirroring src/mcp/ (zero new runtime dependencies), reusing the MCP newline-delimited JSON-RPC stdio transport, payload queue, and error formatting. - Prompt lines are tokenized with the replay-script tokenizer and parsed with the real CLI parser; target flags (--platform, --device, --udid, --session, --state-dir) are sticky within an ACP session. - Command executions stream as tool_call/tool_call_update notifications with daemon progress forwarding; screenshots attach as inline images; errors keep the code/hint/supportedOn contract. - session/cancel is intercepted ahead of the serialized queue so it takes effect between command lines of a running prompt; the command already in flight runs to completion (documented v1 limitation). - Natural-language prompts are refused with guidance instead of guessed at; available commands are advertised per session after session/new. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
Adds
agent-device acp: an Agent Client Protocol v1 agent over stdio, so ACP clients such as Zed can drive devices from their agent panel. Before: ACP editors could only reach agent-device indirectly, through whatever LLM agent they run and its MCP config. After:agent-device acpis a first-class agent surface — each prompt line is one agent-device command in CLI syntax, executed through the sameAgentDeviceClientpath as MCP tools, streamed back as ACP tool calls with daemon progress updates and inline screenshot images.Design choices:
src/acp/, reusing the MCP server's newline-delimited JSON-RPC transport, payload queue, and error formatting (the shared pieces are now exported fromsrc/mcp/instead of duplicated).--platform,--device,--udid,--session,--state-dir) are sticky within an ACP session.session/cancelis intercepted ahead of the serialized inbound queue so it takes effect between command lines of a running prompt. The command already in flight runs to completion — there is no abort seam in the daemon client; documented as a v1 limitation.session/newadvertises all MCP-exposed commands viaavailable_commands_update(response-before-notification ordering is pinned by test).Docs: new ACP section in
agent-setup.mdwith the Zedagent_serversconfig, README pointer, CHANGELOG entry, CONTEXT.md command-surface vocabulary update.23 files touched (13 new:
src/acp/+ tests). Scope stayed within the planned command-surface addition; the only changes outside it areexports of previously-private MCP transport/formatting helpers and the replay tokenizer.Validation
Full unit bundle green (3296 tests / 366 files, including 27 new ACP tests covering the router contract, prompt parsing, sticky flags, cancellation, refusal, screenshot image attachment, and out-of-band cancel interception).
check:quick,check:layering, fallow audit (0 dead code / 0 duplication after deduplicating againstsrc/mcp/), andtest:smokeall pass — including a newsmoke-acp.test.tsthat spawns the real stdio process and drives initialize → session/new → prompt refusal → clean shutdown. Live device evidence: through the packaged build (dist/src/internal/bin.js acp), an ACP session randevicesagainst a real daemon with an isolated state dir and streamed back actual inventory (iPhone 17 Pro simulator + host macOS target) as a completedtool_call_update; the daemon and state dir were cleaned up afterwards. Zed itself was not exercised — the wire contract was verified against the official ACP v1 JSON schema; a follow-up interactive Zed session is the remaining real-client check.🤖 Generated with Claude Code