Skip to main content

Module handler

Module handler 

Source
Expand description

WebSocket connection handler — bidirectional JSON-RPC.

Tool callback flow:

  1. Client submits proposal via proposal.submit
  2. Runtime encounters a ToolCall action
  3. WsToolExecutor sends tools.execute request to client via shared write half
  4. WsToolExecutor awaits response on a oneshot channel
  5. Client executes tool locally, sends JSON-RPC response back
  6. Handler receives the response, resolves the oneshot
  7. Runtime continues execution with the tool result

Structs§

JsonRpcError
JsonRpcMessage
JsonRpcResponse

Functions§

broadcast_upgrade_nudge
Push a models.upgrade_available notification to all subscribed UI clients, returning how many it reached. Targets the same subscriber set the macOS host already uses for pushed events (a2ui_subscribers) — the UI-push channel — rather than standing up a parallel subscription. Mirrors [broadcast_a2ui_event].
handle_connection
Convenience wrapper for the standalone car-server binary: accepts the WebSocket handshake on a raw TcpStream then delegates to run_dispatch. Embedders that already have a handshake-completed WebSocketStream skip this and call run_dispatch directly.
handle_connection_unix
Convenience wrapper for the daemon-as-default Unix-socket listener. Same shape as handle_connection but accepts a UnixStream — used by the per-user UDS listener in car-server::main (default transport for FFI thin clients, since UDS is faster + permission-scoped vs localhost TCP).
recover_workflow_checkpoints
Re-arm workflow runs orphaned by a crash between an approval claim and its complete. Call once at daemon startup, before serving connections, so a restart mid-approval doesn’t bury paused runs. Best-effort: logs and returns on any error rather than failing boot.
run_dispatch
Transport-neutral entry point: drives the JSON-RPC dispatch loop against an already-handshake-completed split WebSocket. Generic over the read half (any Stream<Item = Result<Message, WsError>>) and the write half (a [WsSink] — type-erased so this function doesn’t templatize every downstream consumer of WsChannel).
run_upgrade_nudge_check
Run one proactive upgrade check and push a models.upgrade_available nudge to subscribers if warranted. Stamps last_nudge_secs after sending so the per-day throttle holds across ticks. The daemon calls this on a periodic timer; the nudge logic itself decides whether to actually surface anything (policy/throttle/dismissals).