small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
albedo robot-docs sessions.md
31 kB · 452 lines
Markdown

# session attachment Session creation and user turn admission use durable [operation receipts](operations.md). An accepted submission survives a daemon restart while it waits for transcript consumption. A retry with the same operation ID returns the original admission. The CLI app package owns session ID resolution. Full lowercase UUIDv7 IDs address roots and children directly. Shortened IDs match only root sessions, with an exact match taking precedence over prefixes. A missing full ID returns the same no-match error as a missing prefix; resume never creates a replacement. Opening reads the root list and settings once, then captures the selected session once and adds a child to its initial list if needed. opening a session attaches the cli to its event stream and independently reads `GET /sessions/{session_id}?tail=0`. replayed history does not establish the session's live phase; status and live events do. an idle status is enough to enable the composer, including a persisted `interrupted` session after a daemon restart. a missing or unrecognized phase is display metadata, not a failed connection. before live status is known, enter preserves the draft; superseded status replies cannot unblock it. starting a new turn does not require `/compact` to change the old phase. ## ACP sessions ACP creation commits the `sessions.acp` marker and `acp_overlay_identities` together. The marker survives a restart. While it is set, the session accepts input only as `acp_prompt` from the current attachment. `turn.next_batch` runs each ACP input as its own turn. `daemon/acp_attachments.gleam` owns the in-memory attachments and overlays. `daemon/http_acp.gleam` owns the routes and their authorization. The [ACP reference](acp.md) covers leases, resume, history loading, and restart behavior. ## Live status without a poll `GET /sessions/{session_id}?view=status` answers the live facts alone: `id`, `cursor`, `status`, `kernel`, `usage`, and `glances`. Its source is the session actor's own memory plus its kernel's port owner, n…