Skip to main content

Module api

Module api 

Source
Expand description

The documented HTTP API an orchestrating agent drives sessions with.

The web viewer’s own /api/... routes exist for the browser: they are undocumented, cookie-only, and shaped around what a phone renders. These /api/v1/... routes are the stable surface instead. They authenticate with a bearer token from a file the same user can read, answer with a version header so a client can tell which contract it reached, and — the point of the whole module — let a caller block until one specific prompt finishes and read a structured outcome for it.

Everything that needs the daemon’s live session actors or its SQLite store reaches them through SubagentBackend, because this crate cannot depend on the daemon runtime that owns them.

Structs§

ApiBackgroundWork
Observed provider-owned background work; absent when no live snapshot is available.
ApiFailure
An API failure with a message written for the caller.
ApiSession
One session as the API presents it. This is a narrower, more stable shape than the viewer’s own session projection, which changes whenever the browser needs something new.
BundleExport
A git bundle of the session’s work.
ExportRequest
FileQuery
Which file of the session’s workspace to read.
PromptRequest
PromptResponse
PushedBranch
A branch the daemon pushed on the caller’s behalf.
RelayHealth
SessionListQuery
SessionListResponse
SetConfigRequest
SpawnSubagentRequest
StartFollowup
Configuration and a first prompt to apply once a newly created session’s harness is ready. Served in M2.
StartSessionRequest
Create a session and, optionally, send its first prompt. Served in M2.
StartSessionResponse
SubagentListResponse
SubagentSourceRange
SubagentView
TranscriptItemView
TranscriptPage
A page of transcript items, read from the durable projection. One page of a session’s transcript, ordered by the sequence a reader pages by rather than by creation order.
TranscriptQuery
TranscriptResponse
TurnState
Where a session stands turn by turn, read from the durable projection when no live actor holds the session.
TurnSummary
What one turn produced, without loading the transcript around it.
UsageQuery
Page through a session’s transcript.
WaitCapacityRetry
WaitDecision
What one pass of the wait loop concluded, before the turn summary is read.
WaitObservation
Everything one pass of the wait loop knows about a session.
WaitRequest
WaitResponse
WriteFileQuery
One file from the session’s workspace, as bytes.
WriteFileResponse

Enums§

ExportError
Why an export could not be produced. Served in M4.
ExportKind
What form the caller wants the session’s work in.
RelayState
How the daemon’s live view of a session’s relay is doing.
StartStatus
How far a created session’s follow-up has got. Served in M2.
WaitOutcome
How a wait ended.

Constants§

API_VERSION
API_VERSION_HEADER
Response header naming the contract version this server speaks. A client that understands only version 1 can refuse anything else without parsing a body it may not recognize.
DEFAULT_TRANSCRIPT_LIMIT
How many transcript items a page carries when the caller names no limit, and the most it may ask for. A caller that asks for more gets the ceiling rather than an error: paging is the point, and refusing a large limit would only make the caller retry with a smaller one.
DEFAULT_WAIT_SECS
How long a wait blocks when the caller names no timeout, and the ceiling it may ask for. Both are generous: a turn routinely runs for minutes, and the caller is a program that reconnects rather than a person holding a page.
MAX_TRANSCRIPT_LIMIT
MAX_WAIT_SECS
Longest time a sub-agent completion wait may remain pending.

Traits§

SubagentBackend
Everything the API needs from the daemon: live session actors, the durable projection, and the target-side git operations.

Functions§

api_token_path
Where the bearer token lives. It is a file rather than an environment variable so it survives daemon restarts and so deleting it is the explicit revoke gesture.
load_or_create_api_token
Read the API bearer token, minting one on first use.
map_stop_reason
Classify a harness stop reason.
resolve_wait
Decide whether this observation ends the wait.