# ACP adapter The CLI ACP adapter translates line-delimited JSON-RPC requests to daemon operations. [`server.go`](../cli/internal/acp/server.go) owns the connection and dispatch. The daemon owns accepted work. See [sessions](sessions.md) for the underlying actor and stream. ## Connection and requests `Run` creates a random connection token, reads JSON-RPC lines, and serializes responses through a writer. It handles `initialize`, `session/list`, `session/new`, `session/resume`, `session/load`, `session/set_config_option`, and `session/prompt`. `session/cancel` is handled as a notification. Unknown request methods return `method_not_found`. `authenticate` returns an error because the adapter offers no authentication methods. See [`server.go`](../cli/internal/acp/server.go). EOF disconnects the adapter but accepted work remains daemon-owned. The adapter releases its attachments on exit. [`session.go`](../cli/internal/acp/session.go) observes daemon events and renews each session lease. ## Ownership and recovery [`acp_attachments.gleam`](../src/albedo/daemon/acp_attachments.gleam) owns writer attachments and overlays in a daemon-lifetime actor. The normal lease is 20 seconds and heartbeat interval is 5 seconds, before test time scaling. Attachments and overlays are not durable across a daemon or attachment actor restart. The session actor checks the attachment token when authorizing ACP cancellation. A missing or lost attachment returns `attachment_lost`. An enabled overlay that must be restored returns `overlay_reattach_required`. A failed reload can return `overlay_installed_reload_failed`. See [`acp_session.gleam`](../src/albedo/daemon/acp_session.gleam). ## Models and history The adapter backend exposes model listing and selection, session listing, and paged history. [`models.go`](../cli/internal/acp/models.go) and [`load.go`](../cli/internal/acp/load.go) translate those operations. [`session.go`](../cli/internal/acp/session.go) reconciles observed output with durable events and bounds its reconciliation metadata. A failed stream can make observation uncertain. ## MCP overlays The editor can supply MCP servers as a session overlay. [`acp.validate`](../src/albedo/daemon/acp.gleam) requires absolute command paths, unique server names, and unique environment variable names per server. Overlay names cannot shadow globally configured server names. [`http_acp.validate_and_probe_overlay`](../src/albedo/daemon/http_acp.gleam) reads those names from the installed `McpServersPlugin` and starts candidates with the installed `EditorMcpPlugin`. Both answer while their extensions are disabled. Without an `McpServersPlugin`, no names are reserved. Without an `EditorMcpPlugin`, a non-empty overlay fails with `409 mcp_overlay_failed`. See [plugins](plugins.md#mcp-settings-and-editor-probes). The daemon stores keyed fingerprints of server configuration, while the live overlay is held by the attachment actor. [`acp_session.publish`](../src/albedo/daemon/acp_session.gleam) publishes at an idle session boundary and restores the previous durable requirement if publication fails. A session that requires an absent overlay must reattach before using it. Overlay contents and credentials are runtime configuration and must be handled accordingly. Session preparation reaches the overlay through [`acp_overlay.resolve`](../src/albedo/daemon/acp_overlay.gleam), which the composition binds to `extension.Preparation.editor_overlay`. It reads the ACP marker first and returns `None` for a session without one, so ordinary turns do not load `acp_session`. Its catalogue lookup and save callbacks keep the revision it captured. See [MCP](mcp.md#editor-servers-over-acp). ## Related pages - [All topics](README.md) - [Change guidance](contributing.md) - [Session attachment](sessions.md) - [MCP extension](mcp.md)