small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo

ACP adapter #

The CLI ACP adapter translates line-delimited JSON-RPC requests to daemon operations. server.go owns the connection and dispatch. The daemon owns accepted work. See sessions 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.

EOF disconnects the adapter but accepted work remains daemon-owned. The adapter releases its attachments on exit. session.go observes daemon events and renews each session lease.

Ownership and recovery #

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.

Models and history #

The adapter backend exposes model listing and selection, session listing, and paged history. models.go and load.go translate those operations. 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 requires absolute command paths, unique server names, and unique environment variable names per server. Overlay names cannot shadow globally configured server names. The daemon stores keyed fingerprints of server configuration, while the live overlay is held by the attachment actor.

acp_session.publish 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.