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

Constants§

HOST_MANAGEMENT_METHODS
JSON-RPC methods whose daemon handlers require host-management authority.

Functions§

broadcast_concierge_suggestion
Push a models.suggestion_available notification to subscribed UI clients, returning how many it reached. Targets the same a2ui_subscribers UI-push channel as broadcast_upgrade_nudge.
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).
reap_orphaned_sandboxes_at_boot
Reap CAR Docker sandbox containers orphaned by a prior daemon crash/SIGKILL (Parslee-ai/car#479). SandboxExecutor’s Drop handles normal teardown, but a hard kill leaves the sleep infinity container running forever. Sandboxes are created per session.bindSandbox (never at boot), so any container carrying the CAR ownership label is by definition orphaned. Best-effort: a host without Docker is a silent no-op.
reconcile_os_schedules_at_boot
Reap orphaned OS-level schedules at daemon boot — best-effort, mirrors recover_workflow_checkpoints. A schedule whose task was deleted while the daemon was down keeps firing a no-op command until this runs.
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_concierge_check
Run one proactive concierge check and push a models.suggestion_available notification per unserved lane to subscribers. Stamps last_concierge_secs after sending so the throttle holds across ticks. Mirrors run_upgrade_nudge_check but on the concierge’s independent cadence and throttle field, so the two never starve each other.
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_idle_backend_eviction
One pass of idle model-backend eviction. A long-running daemon under the default 24 GB cache budget pins loaded model weights resident forever — capacity eviction never fires below the cap — so RSS climbs to a model’s working set and never drops at idle (car-releases#67). This sweeps backends untouched for CAR_INFERENCE_MODEL_IDLE_SECS (default 300) out of the caches and releases isolated-worker residents at the same age; their RAM is reclaimed once outstanding handles drop or the worker’s confirmed process exit completes.
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).
seed_memgine_config
Acquire (or lazy-create + load from disk) the daemon-owned persistent memgine for agent_id. First call per id reads ~/.car/memory/agents/<id>.json if it exists; subsequent calls share the in-memory engine across sessions. Caller stores the returned Arc on ClientSession.bound_memgine so memory.* handlers route through it via ClientSession::effective_memgine. Resolve the car_memgine::MemgineConfig the daemon seeds its engines with: discover the .car/ project from the project anchor and apply its config.toml overrides (e.g. utility-aware retrieval). The anchor is $CAR_PROJECT_DIR when set, else the process cwd.
seed_trusted_skill_signers
Read the operator’s trusted skill-signer keyring from the .car/ project’s config.toml (trusted_skill_signers), discovered from the same anchor as seed_memgine_config: $CAR_PROJECT_DIR when set, else the process cwd. Absent key, absent file, or no project → an empty keyring.
session_principal_for_peers
The authenticated principal for this connection, stamped into approval audit records server-side so the “who decided” field can’t be forged by the caller (neo review #5c). Prefers the bound agent identity, else the connection id. Public wrapper over [session_principal] for the peer-messaging module.