Expand description
Cloud push subscription — replaces per-agent polling with a single sidecar-level WebSocket to muxbus-ws.agentmux.ai.
When MUXBUS_TOKEN is present, the subscriber:
- Opens wss://muxbus-ws.agentmux.ai with the bearer token.
- Listens for { type: “inject_available” } broadcast wake signals (zero metadata).
- On each signal, pulls pending injections for every locally-registered agent: one POST /reactive/pending-batch for all of them, or one GET /reactive/pending/:id per agent on a relay without the batch route.
- Claims all pending injections via REST POST /reactive/ack (atomic pending->delivered transition server-side) before delivering — only ids this call actually won the claim on get delivered via ReactiveHandler. A claimed injection that fails local delivery is released back to pending via REST POST /reactive/release so it’s retried, rather than silently dropped.
- Reconnects with exponential back-off on any disconnect.
The server broadcasts to ALL connected sidecars on every injection, so a subscriber cannot correlate the signal to any particular agent, account, or timing.
Agents register/unregister via add_agent()/remove_agent(). No MUXBUS_TOKEN → subscriber stays idle.
Modules§
- delivery
- Claim → verify → deliver for one agent’s pulled injections: the half of a
pull that comes after the relay answered, shared by the single pull
(
sync_agent_reactive) and the batch pull (sync_agents_batched). - live_
names - The names the relay subscription holds: every name a live pane answers to.
- session
- What bounds one WebSocket session of the cloud subscriber: how long it may take to open and how long it may go without a word from the relay. Without them a socket that went dead (or a handshake that never finished) held the session open for good while the status said connected.
- sign_in
- What the subscriber’s loop asks of the stored sign-in: whether it can be used or refreshed, whether a refresh came back for the same account, and a wait for a new sign-in.
- supervisor
- Keeps the cloud subscriber’s loop alive. The loop ends only by a panic, and
it can stall in a call that never returns (on 2026-11-11 two hosts stopped
receiving cloud messages for hours while their status said connected). The
loop stamps [
beat] every time round; a stamp that stops for [STALL_AFTER] means it is stuck, and either way a new loop is started.
Structs§
Enums§
- Relay
Release - Drop
agentfrom the relay subscription and release its WAN lease, awaiting the release (theRemoveAgentarm’s is fire-and-forget) — for a Take over, whose requester claims the lease right after.falseif it wasn’t subscribed.id_storeis where muxbus credentials live. What a Take over’s relay release did.
Constants§
- MUXBUS_
WS_ URL - Fallback when the cloud publishes no settings (
discovery::ws_url).
Functions§
- get_
global_ subscriber - load_
valid_ token - Load a valid (non-expired) access token via the broker, refreshing first
if the stored credential is missing/stale. Returns None if no credentials
are stored, the token is expired and refresh fails, or the refresh_token
is absent —
ensure_fresh’s own single-flight guard means this can run concurrently with the broker’s background sweep for the same credential without either one duplicating the other’s refresh attempt. - release_
agent_ now - take_
over_ lease_ now - Take over’s relay step on the requester ([
super::wan_lease::take_over]), with a fresh shared token.Unknown(fail open) when this instance has no MuxBus session or no token can be loaded.