Skip to main content

Crate car_server_core

Crate car_server_core 

Source
Expand description

Transport-neutral library extracted from car-server.

Holds the JSON-RPC dispatcher, per-client session state, and the WebSocket channel plumbing. The standalone car-server binary is a thin wrapper that loads ~/.car/env, initializes telemetry, spawns the dream loop, binds a TCP listener, and on each connection calls run_dispatch.

Embedders (e.g. the future tokhn-daemon at U7) construct a ServerState via ServerState::embedded (or ServerStateConfig for advanced wiring), accept WebSocket connections in their own listener, and call run_dispatch directly — without re-implementing the dispatcher.

§Library boundary contract

Per the U1 plan, this library MUST NOT:

  • spawn the dream loop (caller decides),
  • initialize telemetry (caller decides),
  • load ~/.car/env (caller decides).

Those bootstraps stay in the embedder’s main. This contract prevents the dual-memgine bug U7 mitigates: if the library silently spawned its own dream loop, embedded users would end up with two memgine engines (the embedder’s plus the library’s).

§Lock primitive

ClientSession.memgine uses Arc<tokio::sync::Mutex<MemgineEngine>> per the “one-wrapper rule” — dispatcher handlers can hold the lock across .await points without risking poisoning, and tokio’s Mutex does not poison so a panicking handler does not poison the engine for sibling connections.

Re-exports§

pub use admission::InferenceAdmission;
pub use admission::ENV_MAX_CONCURRENT;
pub use handler::handle_connection;
pub use handler::run_dispatch;
pub use handler::JsonRpcError;
pub use handler::JsonRpcMessage;
pub use handler::JsonRpcResponse;
pub use handler::handle_connection_unix;
pub use session::ApprovalGate;
pub use session::ClientSession;
pub use session::ServerState;
pub use session::ServerStateConfig;
pub use session::WsChannel;
pub use session::WsMemgineIngestSink;
pub use session::WsSink;
pub use session::WsToolExecutor;
pub use session::WsVoiceEventSink;

Modules§

a2a
FFI wrappers for the car-a2a server lifecycle.
admission
Process-wide admission control for inference RPC handlers.
handler
WebSocket connection handler — bidirectional JSON-RPC.
host
Host-facing state for OS integrations.
mcp
MCP HTTP-streamable transport for the daemon.
meeting
JSON wrappers for the meeting capability surface.
parslee_auth
session
Server-side session state — shared across all connections.
ui_agent_loop
Runtime-side convergence machinery for the UI-improvement loop.
voice_turn
FFI wrapper around car_engine::dispatch_voice_turn.