Module cloud_subscriber

Module cloud_subscriber 

Source
Expand description

Cloud push subscription — replaces per-agent polling with a single sidecar-level WebSocket to muxbus.agentmux.ai.

When MUXBUS_TOKEN is present, the subscriber:

  1. Opens wss://muxbus.agentmux.ai/ws with the bearer token.
  2. Listens for { type: “inject_available” } broadcast wake signals (zero metadata).
  3. On each signal, polls REST GET /reactive/pending/:id for every locally-registered agent.
  4. Delivers via ReactiveHandler; ACKs successful deliveries via REST POST /reactive/ack.
  5. 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.

Structs§

CloudSubscriber

Enums§

ClientMsg 🔒
CtrlMsg 🔒
ServerMsg 🔒

Constants§

MAX_RECONNECT_DELAY_SECS 🔒
MUXBUS_REST_URL 🔒
MUXBUS_WS_URL 🔒
RECONNECT_DELAY_SECS 🔒

Statics§

GLOBAL_SUBSCRIBER 🔒

Functions§

connect_and_run 🔒
get_global_subscriber
handle_server_msg 🔒
Handle a message from the cloud server. The WS wake signal carries zero metadata — the sidecar polls all its registered agents via REST to find pending injections, so a compromised subscriber gains nothing.
load_valid_token 🔒
Load a valid (non-expired) access token, refreshing via refresh_token if needed. Saves refreshed credentials back to the store. Returns None if no credentials are stored, the token is expired and refresh fails, or the refresh_token is absent.
run_loop 🔒