Skip to main content

Module acp

Module acp 

Source
Expand description

AcpController: manages agent CLIs that speak the Agent Client Protocol (ACP).

ACP is a JSON-RPC 2.0 protocol over stdin/stdout — the “LSP for AI agents.” Instead of custom per-provider output parsing, ACP provides a standardized protocol for session management, prompting, and streaming events.

Lifecycle:

  1. Spawn the ACP agent process (e.g., gemini --acp, openclaw acp)
  2. Send initialize request, receive capabilities
  3. Send initialized notification
  4. Create a session via session/create
  5. For each user turn: send session/prompt, stream session/update notifications
  6. On close: send shutdown + exit

I/O model (similar to PersistentSubprocessController):

  • stdin_writer: sends JSON-RPC requests/notifications to agent
  • stdout_reader: reads JSON-RPC responses/notifications, persists + broadcasts
  • process_waiter: monitors process lifecycle

See: https://github.com/agentclientprotocol/agent-client-protocol

Modules§

spawn_steps
The steps of AcpController::spawn_process, one function each, in the order they ran: launch the child, drain its stderr, mark it running, start the stdin writer, the stdout reader and the process waiter, then send initialize. Moved out of spawn_process without a change in behaviour.

Structs§

AcpController
AcpController manages an ACP-speaking agent process.

Constants§

ACP_OUTPUT_SUBJECT
MPS file subject name for ACP output.
BLOCK_CONTROLLER_ACP
TURN_RUNNING
What submit_input says to a slash command that arrives while a turn is running: a harness takes /compact only between turns, and queued behind other text it would no longer be a command. The caller waits for the turn’s end.