Skip to main content

Module rest

Module rest 

Source
Expand description

REST client and shared wire types for the agent HTTP API (Contract D, port 8080).

The native front (ados-control) serves the API on :8080; this is the client side used by the Rust TUI (and any other Rust REST consumer). Auth is the X-ADOS-Key header, or a dashboard PIN session in X-ADOS-Dashboard-Session; the pairing routes are reachable while unpaired. The client is blocking (ureq, HTTP-only) because its callers are simple pollers and worker threads off the flight-critical path.

The client returns raw serde_json::Value bodies. The types submodule adds typed serde structs for the read-projection shapes that the native route handlers project out of subsystem sockets and sidecars. Defining each shape once here keeps the data contract in the shared protocol crate, so a handler does not re-invent an ad-hoc struct per route. Every type carries an open extra map (via #[serde(flatten)]) and #[serde(default)] fields, so a new field on the producer side round-trips through a consumer that does not yet know about it.

Re-exports§

pub use types::*;

Modules§

types
Typed read-projection shapes for the agent HTTP API.

Structs§

Auth
The credentials a RestClient sends. Shared by every clone of a client, so setting a key or session on one applies to all of them.
RestClient
A blocking REST client for the agent HTTP API. Cheap to clone; clones share one Auth.

Enums§

RestError

Constants§

DEFAULT_BASE
Default base URL: the agent’s local HTTP API. Matches cli/main.py’s API_BASE.
DEFAULT_TIMEOUT
Default per-request timeout, matching the Python CLI’s httpx client.
STREAM_CONNECT_TIMEOUT
Connect timeout for a long-lived stream (server-sent events). The stream itself has no read timeout: an idle log stream is not a failure.

Functions§

status_detail
The human detail of an error body. Flat bodies carry detail, message or error as a string; nested ones carry an object under detail and/or error ({"detail": {"error": {"code", "message"}}}). The first string found among detail, message, error, each looked up directly and then as <k>.message and <k>.error.message, wins; empty when there is none.