Skip to main content

HTTP and WebSocket

Mixed implementation/reference page. The daemon retains the metadata state/commands/WebSocket API and now adds the offline /library, /sessions, /sessions/{id}/control, /sessions/{id}/replay, and artifact routes. See current status and the software wire contract for exact implemented DTOs. The richer lifecycle and hardware routes below remain proposed. All HTTP routes use /api/v1; WebSocket transport remains the metadata playground.

Method / pathPurpose
GET /api/v1/stateSnapshot, state revision, sequence cursor, capabilities
GET /api/v1/devicesDevice identities, modes, freshness, capabilities
GET /api/v1/tracksRegistered track metadata
GET /api/v1/sessionsSession manifests and completion status
GET /api/v1/configEffective non-secret configuration
POST /api/v1/commandsSubmit the same command envelope used over WS
POST /api/v1/simulator/startInstantiate a scenario
POST /api/v1/simulator/stopStop simulation explicitly
POST /api/v1/sessionsBegin recording with a manifest
POST /api/v1/sessions/{id}/stopFinalize recording

Recording lifecycle and simulation lifecycle are distinct: stopping a recording does not stop playback.

Illustrative first-slice exchange

{
"schema_version": 1,
"session_id": "demo",
"command_id": "cmd-001",
"ownership_generation": 1,
"payload": { "type": "Play", "deck_id": 1 }
}

The server derives actor identity from the authenticated connection. It first returns a receipt tied to command_id; an applied event later supplies the sequence, output frame, and resulting state revision. Rejected commands carry stable reason codes such as unsupported, not_owner, stale_revision, or invalid_value.

Use JSON initially. A stream starts with a versioned snapshot and cursor; subscription setup must avoid a race between snapshot capture and subsequent events. Bound outbound queues, coalesce meters, and force resynchronization rather than silently dropping authoritative events. Reject incompatible schema versions explicitly.

Bind to loopback by default. For LAN operation, define authentication, allowed browser origins, viewer/controller roles, and transport protection. Require authentication on control-plane HTTP routes as well as WebSocket upgrades. Avoid logging credentials or raw track filesystem paths.