Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
# Client API ownership
The Go [`daemon` package](../cli/internal/daemon) adapts daemon protocol 3.
Application commands and TUI screens call named operations and receive typed
results. Generated code constructs routes and queries. The adapter checks
responses, bounds decoding, and chooses recovery policy. [OpenAPI](openapi.yaml)
defines the wire format. [HTTP API behavior](http-api-design.md) defines its
behavior.
## Request flow
Opening a context page follows this flow:
1. The screen calls `GetContextSnapshot` to obtain the latest prepared snapshot.
2. It calls `GetContextPage` with that snapshot ID, section, and page.
3. The adapter validates the response and returns a typed page or an error.
4. A typed UI message carries the result to the screen, which owns selection,
rendering, and rejection of outdated replies.
Reading context does not prepare a model request. If the snapshot changes, the
client obtains the new summary before requesting its pages.
## Code organization
Each domain keeps its operations and application-facing types together.
[`protocol/api.gen.go`](../cli/internal/daemon/protocol/api.gen.go) contains
wire types and HTTP request builders generated from OpenAPI with pinned
`oapi-codegen`. Conversion stays inside the adapter. The
[API contribution guide](contributing-api.md#implement-the-client-boundary)
gives the generation command and required checks.
The [generator](../cli/tools/apigen/main.go) runs in `cli/tools/apigen`, outside
the CLI dependency graph. It projects OpenAPI 3.2 to 3.1 in memory for the
generator, selects raw JSON for unions, and preserves nullable field tags for
adapter validation. The canonical spec remains authoritative. The adapter owns
bounded response reads, semantic validation, authentication recovery, and SSE
framing and replay. Session stream parsing is separate from chat operations.
Transport, decoding, and receipt recovery are private machinery.
Extension-specific result bodies remain explicit `json.RawMessage` values.
Local discovery and launching have s…