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, SubAgent lifecycle, and RPC layer for zerocode. 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)subagent/: SubAgent spawning and lifecycle (see Delegation & SubAgents)cron/, daemon/, heartbeat/: scheduling and long-running process managementskillforge/, skills/: skill compilation and executionservice/: systemd / launchctl / Windows Service integrationrpc/: the RPC layer for zerocodezeroclaw-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 the core public traits, including:
ModelProvider: LLM client interface with streaming capability flagsChannel: inbound/outbound messaging surfaceTool: agent-callable capabilitiesMemory: conversation storage and retrievalObserver: typed metrics/observability sinkThe 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 retry 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: hint-based per-call model route selectionreliable.rs: same-provider retry / backoff / API-key rotation 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_request, pdf_read, web_search, shell, file_read, file_write, hardware probes (hardware_board_info, hardware_memory_read), 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-logThe single emission surface for every log event in the workspace. Owns
the on-disk JSONL schema (LogEvent), the alias-bound attribution
registry (ATTRIBUTION_FIELDS + COMPOSITE_PREFIXES), the
tracing-subscriber Layer that captures every tracing::* call, the
record! and scope! macros, the rolling-trim writer, the
paginated cursor reader behind /api/logs, and the bridge to the
typed Observer for Prometheus / OTel consumers. See
architecture/logging.md.
zeroclaw-spawnThe sanctioned wrapper around tokio::spawn. Provides the spawn!
macro, which instruments every background task with the caller's
current attribution span so a record! emitted inside the spawned
future inherits the parent's agent_alias / channel / session_key.
Call sites use spawn! instead of tokio::spawn directly.
zeroclaw-infraProcess-level support: debouncers, watchdogs, the SQLite session
backend. Not a tracing/metrics layer, that's zeroclaw-log.
zeroclaw-macrosDerive macros for config schema, tool registration, and channel registration. Saves boilerplate across the workspace.
zerocodeTerminal UI, built as a separate app under apps/zerocode/. It is its own workspace member with no zeroclaw-* crate dependency (see Docs & Translations → zerocode strings for its independent i18n catalogue).
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)hardware: enable hardware subsystemgateway, acp-bridge, whatsapp-web: opt-in capability groupsProviders are not feature-gated; they all compile in. Channel selection is the main per-build knob. Read the top-level Cargo.toml [features] table for the full list.