Skip to main content

Module websocket

Module websocket 

Source

Structs§

WSIncoming 🔒
Incoming WebSocket message envelope. Supports both ping/pong messages and wscommand-based RPC.
WsConn 🔒
The egress lanes’ receivers and per-connection state that the select! loop in handle_ws_connection mutates, so each branch is a method instead of an inline block. A method returns true when the connection should end.

Constants§

NON_PANE_EVENT_KEY 🔒
Sentinel key for every priority-lane event that is NOT a blockfile (terminal/PTY output) event. Not a valid block:<id> scope string, so it can never collide with a real pane key.

Functions§

background_event_key 🔒
Extract a coalescing key from a background-lane event. Background events are RPC-wrapped MPS events: { “eventtype”: “rpc”, “data”: { “command”: “eventrecv”, “data”: { “event”: “sysinfo”, “scopes”: [“local”] } } } Key = “:”, e.g. “sysinfo:local” or “blockstats:block:abc123”. Falls back to “:” for events that don’t match the expected shape (safe: they coalesce to one slot, which is acceptable because non-sysinfo/blockstats never reach this lane).
bus_broadcast 🔒
bus:broadcast: no acknowledgement.
bus_inject 🔒
bus:inject: types into the target’s terminal when it can be reached, else pushes through the message bus.
bus_register 🔒
bus:register: the connection becomes the agent it proved itself to be and starts receiving its bus messages.
bus_send 🔒
bus:send: queues a message for to and acknowledges it; a frame missing a field is ignored.
coalesce_background 🔒
Drain all immediately-available events from rx (including first) and coalesce them to the latest reading per (event-name:scope) key. Iteration order in the returned Vec is first-seen (stable across coalescing rounds).
dispatch_blockinput 🔒
Route a decoded blockinput payload — the actual human-keystroke path (termViewModel.ts’s blockinput WS command, used by both the standalone Terminal widget and an agent pane’s composer-drawer shell) — to its block’s controller.
dispatch_termsize 🔒
setblocktermsize: a resize for a block’s controller. The window’s alone: an agent connection is refused.
enqueue_priority_event 🔒
fair_drain_priority 🔒
Drain all immediately-available events from rx (including first) and interleave them round-robin by pane (priority_pane_key), instead of forwarding in raw arrival order. Without this, a pane producing output faster than the socket can flush it fills this same lane with its own frames, and a different pane’s keystroke-echo frame — queued in the same FIFO — waits behind the entire backlog. Round-robining bounds that wait to one slot per OTHER distinct pane with events currently queued, regardless of how deep any single pane’s backlog is.
forward_event 🔒
Forward a queued event-bus value to the WebSocket. Returns true if the send failed (the caller should break the loop).
handle_incoming_text 🔒
Handle an incoming text message. Returns Err(true) if the socket send failed. Returns Ok(Some((rx, agent_id))) if a bus:register was processed.
handle_ws 🔒
handle_ws_connection 🔒
input_command 🔒
blockinput and setblocktermsize: a payload for a block’s controller from this connection. A refusal is sent back as a bus:error frame (the one agent clients already read); a closed socket is the only Err.
next_bus_message 🔒
The next message of the agent bus, or never when this connection is not registered as an agent.
parse_block_input 🔒
Parse a CommandBlockInputData into a BlockInputUnion.
priority_pane_key 🔒
Extract a fairness key so a flood of PTY output from one pane can’t queue an unbounded number of frames ahead of a different pane’s own keystroke echo sitting in the same lane.
refuse_agent_input 🔒
The window’s input commands (blockinput keystrokes, setblocktermsize, and controllerinput’s Stop and resize) are the person’s hands: typed into a block they read as the person’s own words. A connection registered as an agent (the agent’s own token, proven at bus:register) writes into no block through them. An agent writes into its own terminal with the Terminal tool (the PtyShell API checks that the shell is its own) and reaches another agent with Message send. Everything else is as before.
send_frame 🔒
Sends one JSON frame. Err(true) means the socket send failed.
send_greeting 🔒
What a connecting client is sent first: the config event, then srvinfo.
srv_info_event 🔒
The srvinfo event sent once on every WebSocket connect, right after config: srv’s version, which the UI compares with its own, and the machine srv runs on (crate::srv_info).
with_question_controller 🔒
Run f on block_id’s persistent controller for agent.answer / agent.cancel. The error strings are matched by the frontend’s SAFE_TO_RETRY_VIA_FOLLOWUP allowlist (useAgentQuestions.ts).
wscommand_frame 🔒
The wscommand frames: rpc goes to the engine, the two input commands to input_command.

Type Aliases§

Registered 🔒