docs/book/src/architecture/crates.md
The workspace is split into layers. Edge crates talk to the outside world; core crates orchestrate; support crates provide utilities. Each crate has its own rustdoc — see API (rustdoc).
zeroclaw-runtimeThe agent loop, security-policy enforcement, SOP engine, cron scheduler, onboarding wizard, and TUI. Depends on every other core and edge crate.
Notable submodules:
agent/ — the main request/response loop, streaming, tool-call orchestrationsecurity/ — policy types, sandbox detection, OTP, emergency stopsop/ — Standard Operating Procedure engine (see SOP → Overview)onboard/ — the first-run wizard (wizard.rs)memory/ — wraps zeroclaw-memory with runtime-level caching and consolidation schedulesservice/ — systemd / launchctl / Windows Service integrationzeroclaw-configTOML schema and its validation. Handles:
ReadOnly / Supervised / Full)All user-facing config keys are documented in Reference → Config, which is generated from this crate.
zeroclaw-apiThe kernel ABI. Defines three public traits:
Provider — LLM client interface with streaming capability flagsChannel — inbound/outbound messaging surfaceTool — agent-callable capabilitiesThe runtime depends only on these traits, not on concrete implementations. This is what makes provider/channel/tool additions a matter of implementing a trait rather than patching the core.
zeroclaw-providersAll LLM client implementations plus the routing and fallback wrappers. See Model Providers → Overview for the list.
Structure:
traits.rs — re-exports from zeroclaw-api plus provider-internal helpersanthropic.rs, openai.rs, ollama.rs, … — one file per native providercompatible.rs — a single OpenAI-compatible implementation reused by 20+ providers (Groq, Mistral, xAI, Venice, etc.)router.rs — multi-provider router that routes by task hintreliable.rs — fallback-chain wrapperstreaming.rs — SSE parsing, token estimation, tool-call deltaszeroclaw-channels30+ messaging integrations. See Channels → Overview for the catalogue.
All channels implement the Channel trait from zeroclaw-api. Each is feature-gated — a minimal build includes only the channels you compile in.
The orchestrator/ submodule handles message streaming, draft updates, multi-message splits, and the ACP server.
zeroclaw-gatewayHTTP/WebSocket gateway. Exposes the runtime over:
Pairing is required by default; [gateway.allow_public_bind = true] enables binding to 0.0.0.0.
zeroclaw-toolsCallable tools the agent invokes. Not to be confused with CLI zeroclaw subcommands.
Includes: browser, http, pdf_extract, web_search, shell, file_read, file_write, hardware_probe, and more. See Tools → Overview.
Each tool is registered via factory and described to the model via Fluent-localised strings.
zeroclaw-memoryConversation memory and retrieval. SQLite is the default backend; PostgreSQL is available behind --features memory-postgres for multi-instance deployments that need a shared, concurrent-write store. Optional:
zeroclaw-tool-call-parserModel-side tool-call syntax parsing. Handles variations between providers:
tool_calls JSON<tool_use> blockszeroclaw-pluginsDynamic plugin loader for out-of-process tool implementations. See Developing → Plugin protocol.
zeroclaw-hardwareHardware abstraction — GPIO, I2C, SPI, USB. Platform-gated. See Hardware → Overview.
zeroclaw-infraTracing, metrics, structured logging. All crates emit events via this layer.
zeroclaw-macrosDerive macros for config schema, tool registration, and channel registration. Saves boilerplate across the workspace.
zeroclaw-tuiTerminal UI. Optional — compile with --features tui.
aardvark-sys, robot-kitSpecialised hardware support used by the hardware submodule. Out-of-scope unless you're bringing up specific peripherals.
The microkernel roadmap (RFC #5574) defines a feature-flag taxonomy. The practical upshot for a user:
default — a sensible core buildci-all — everything on, for CIchannel-<name> — opt-in per channel (e.g. channel-matrix, channel-discord)provider-<name> — opt-in per providerhardware — enable hardware subsystemtui — terminal UIRun cargo metadata --format-version 1 | jq '.workspace_members' or read the top-level Cargo.toml for the full list.