Skip to main content

Module http_viewer

Module http_viewer 

Source
Expand description

The viewer routes a paired device calls, served only on the viewer listener (TLS, backend::lan::listeners), never on the loopback or LAN routers (agentmux-mobile’s SPEC_AGENT_STATUS_AND_LIVE_PANE_FEED_2026_10_07 §13.2, §13.3):

  • POST /agentmux/viewer/pair: a pairing code for a viewer token. The only route without a token.

  • GET /agentmux/viewer/hello, GET /agentmux/viewer/agents, GET /agentmux/viewer/agents/:name/feed, …/history (server::http_viewer_history), …/attachments/:id (server::http_viewer_attachments), GET /agentmux/viewer/panes, GET /agentmux/viewer/terminals/:block_id/feed (server::http_viewer_terminal), GET /agentmux/viewer/procs, and GET /agentmux/viewer/sysinfo and …/sysinfo/feed (server::http_viewer_sysinfo): Authorization: Bearer amxv_… only. Neither the lan_key nor the instance auth_key opens them, and the token opens nothing else: no other router knows it.

  • POST /agentmux/viewer/agents/:name/input (server::http_viewer_input): a message to an agent, as the user, from a device the owner allowed to send, signed by the device’s key.

Read-only otherwise. An agent hidden from paired devices is left out of the list and its feed and input are 404; agents of other channels on this machine are 404 too for now (they are not in this channel’s registry).

Structs§

AgentProbe 🔒
What a feed asks about its agent while it runs: the block it runs in now, whether it has been hidden from paired devices, its state, and the provider of a block it moves to, who it is for each snapshot, and what waits in it (its controller’s pending_for_devices).
FeedSource 🔒
Where a feed reads its agent’s transcript from.
FeedTiming 🔒
A feed’s clocks.
PairBody 🔒
ProcsQuery 🔒
Shown 🔒
status {state, since_ms, now_ms}; state and since_ms are null when a state the device was shown has gone (it drops its chip). What a feed last told its device about the agent.
Snapshot 🔒
A snapshot as read: where the feed stands after it, and its lines from from_line.
ViewerCaller 🔒
The paired device a request authenticated as.

Enums§

CatchUp 🔒
What FeedSource::catch_up found.

Constants§

FEED_HEARTBEAT 🔒
Heartbeat comment on a quiet feed.
FOLLOW_POLL 🔒
How often a feed checks that its agent hasn’t moved to another block, and reads lines of the agent’s shared transcript that no event of this block brought (another block, or another srv instance, running the same agent). The desktop pane polls the shared transcript as often (useAgentStream.ts, SHARED_ZONE_POLL_MS).
HEARTBEAT 🔒
READ_LIMIT 🔒
The most lines one bounded read returns (blockfile:read_range’s cap).
RETRY_PREAMBLE 🔒
SETTING_TOWER_SHARE 🔒
Settings key: let paired devices see this computer’s processes in their Tower (GET /agentmux/viewer/procs). Off unless set.
SNAPSHOT_TAIL_BYTES 🔒
SNAPSHOT_TAIL_TURNS 🔒
The snapshot: the last 50 turns or 256 KB, whichever is smaller.
STATUS_POLL 🔒
How often a feed looks at its agent’s state. One controller lookup and one block read, so a second is cheap and keeps the device’s chip current.

Functions§

agent_hidden 🔒
Whether the agent in block_id is hidden from paired devices: its definition (the block’s agentId) has hide_from_devices set. A store that can’t answer hides it: a device never sees, or sends to, an agent because a read failed.
append_event 🔒
audited_feed 🔒
lease, with the feed’s Audit rows: opened now, closed when the lease drops. what names what it shows (the agent, or a terminal). A computer’s feed open is signed (http_viewer_computers::refuse_unsigned_open); a phone’s carries its token.
bad_request 🔒
build_viewer_router
The viewer router: pairing, plus the token-gated read-only routes.
facts_events 🔒
The events that tell the device what changed about the agent in block_id: its state (status, feed::status_step) and what waits in it (pending, pending_step): the request waiting for the user’s answer by id and kind, and how many messages wait to be sent, never their text (§2).
feed_refused 🔒
The answer to a feed open that got no lease: 503 past the caps, 403 stopped_by_host when the host’s person stopped this device’s viewing.
feed_stream 🔒
One feed: retry, then a snapshot (or, for a reconnect whose Last-Event-ID still holds, the lines it missed as one append), then an append per published transcript append, reset + snapshot when the transcript is rewritten or the feed loses its place, and a heartbeat on a quiet stream. A status follows each snapshot and every change of the agent’s state, and a pending every change of what waits in it (facts_events). Ends with reset when the device falls more than 1 MB behind, or the agent is hidden or, for a computer, its host’s person stops allowing computers (hidden both: AgentProbe::for_device), and silently when the device is revoked (its lease’s token) or goes away. The lease is held until the stream is dropped.
handle_viewer_agents 🔒
GET /agentmux/viewer/agents: this channel’s agents, hidden ones left out, sorted case-insensitively.
handle_viewer_feed 🔒
GET /agentmux/viewer/agents/:name/feed: the agent’s transcript as Server-Sent Events (see feed_stream). 404 for an agent that isn’t this channel’s or is hidden; 503 past the feed caps.
handle_viewer_hello 🔒
GET /agentmux/viewer/hello: who this is, which device is asking, and whether it may send.
handle_viewer_pair 🔒
POST /agentmux/viewer/pair: {code, device_name, device_key?} for {token, device_id, hostname, channel, version, install_id?}; 401 for an unknown or expired code, 429 after too many wrong ones.
handle_viewer_panes 🔒
GET /agentmux/viewer/panes: every pane on this computer, window by window and tab by tab, with each agent’s shell drawer (backend::viewer::panes): names, types, the agent name a feed opens by, and whether a terminal runs. No content, command line or working directory; agents hidden from paired devices, and their shells, are left out.
handle_viewer_procs 🔒
GET /agentmux/viewer/procs?filter=: this computer’s Tower snapshot for a paired device (SPEC_TOWER_TASK_MANAGER_PANE_2026_10_08.md §8.3): its tasks and the busiest and largest of its processes, names only, never a command line. 403 unless the user turned sharing on; an agent hidden from paired devices, and its processes, are left out.
identity_of 🔒
Who the agent registered as name is, for the top of a device’s pane (docs/specs/SPEC_REMOTE_PANES_WATCH_AND_DRIVE_AN_AGENT_ON_ANOTHER_COMPUTER_2026_11_20.md §2): {name, color?, seat?}, its name as registered, the colour its own pane is drawn in (ui:color), and its seat as the LAN shares it with peers (agent_seat::summarize). Nothing else of its definition.
not_found 🔒
pending_on_resume 🔒
What waits in the agent, for a feed resumed from its Last-Event-ID (no snapshot): sent once even when nothing does, since the device may still show a request answered or a message sent while it was away; then pending_step sends it only when it changes.
pending_step 🔒
Whether to send what waits in the agent now: when it changed since it was last sent, and after a snapshot (which starts the device over) when anything waits. Nothing while nothing has waited yet.
provider_of 🔒
The agent’s provider id (claude, codex, …), ‘’ when unknown.
reset_event 🔒
send_state 🔒
Whether a device may send to agents: allowed (the owner’s grant and a key on file), off (no grant), or pair_again (a grant, but the device paired without a key, so it can’t sign). agentmux-mobile’s SPEC_SEND_FROM_THE_PHONE_2026_10_13 §4.
snapshot_event 🔒
The snapshot event; agent is who the agent is (identity_of), so the first event a device gets says it.
status_event 🔒
viewer_auth_middleware 🔒
Admit a request carrying a paired device’s viewer token: its SHA-256 is compared, in constant time, with every paired device’s. Stamps the device’s last_seen_ms at most once a minute.

Type Aliases§

StatusProbe 🔒
The state of the agent in a block, if it has one.