How zeroclaw-labs/zeroclaw works
1. Workspace shape
- This is a large Rust workspace centered on a single local-first agent runtime.
- The core product is the zeroclaw binary; around it are feature crates for runtime, channels, providers, tools, memory, hardware, plugins, and UI.
- There is also a top-level src/ tree that mirrors much of the same domain structure, suggesting the main executable and shared library surface are still built from the root package alongside the modular crates.
2. Primary control plane: the runtime
- crates/zeroclaw-runtime is the orchestration layer.
- It owns the agent loop, prompt/history management, tool execution, approval flow, security policy, cron/SOP execution, observability, onboarding, and trust/verifiable-intent logic.
- This is the core boundary where inbound events are turned into model calls and tool actions.
3. Inbound channels
- crates/zeroclaw-channels contains adapters for many message surfaces: Discord, Telegram, Matrix, Slack, email, webhooks, voice, CLI, social platforms, and ACP.
- These channels normalize external events into a common runtime-facing message flow.
- Some channels have helper subpipelines, such as transcription, TTS, link enrichment, history persistence, and WhatsApp-specific storage/web handling.
4. Gateway and client-facing API
- crates/zeroclaw-gateway exposes the local HTTP/WebSocket/SSE service used by the dashboard and other clients.
- It handles API endpoints, pairing/authentication, node/session management, static assets, TLS, and voice duplex.
- The gateway is the boundary between browser/UI clients and the runtime state, and it is also where the web dashboard connects.
5. Web dashboard and desktop shell
- web/ is the React/Vite dashboard for chat, config editing, memory browsing, cron management, tools, logs, and pairing.
- apps/tauri wraps the web UI in a Tauri desktop/mobile shell and exposes native commands, tray behavior, health checks, and gateway client integration.
- Architecturally, the web UI is a client of the gateway rather than the owner of business logic.
6. Model/provider layer
- crates/zeroclaw-providers abstracts LLM and multimodal backends: Anthropic, OpenAI, Gemini, Ollama, Bedrock, OpenRouter, Azure OpenAI, and others.
- It includes auth flows, routing/fallback behavior, compatible APIs, and model capability handling.
- Runtime requests flow from the agent loop into this provider layer, then return streamed or final model outputs.
7. Tooling and external action surface
- crates/zeroclaw-tools is the action layer the agent can invoke.
- It covers filesystem, shell, browser, HTTP, screenshots, search, cloud/workspace integrations, MCP clients, memory operations, and app-specific tools.
- Tools are a major trust boundary: the runtime mediates them through approvals, sandboxing, and receipts before effects are allowed.
8. Memory and retrieval
- crates/zeroclaw-memory implements persistent agent memory, retrieval, embeddings, chunking, consolidation, decay, policy, and response caching.
- Storage backends include SQLite, Postgres, Qdrant, and a no-op backend.
- This subsystem feeds context back into the agent loop and is also surfaced in the UI for browsing and management.
9. Security, trust, and autonomy
- crates/zeroclaw-runtime/src/security contains the main policy boundary: autonomy levels, sandboxing, prompt guards, workspace boundaries, leak detection, OTP/WebAuthn/pairing, and audit.
- trust and verifiable_intent support cryptographic confirmation of actions and receipts.
- This is where the repo enforces “supervised by default” behavior before expensive or risky actions execute.
10. Hardware and firmware
- crates/zeroclaw-hardware plus crates/robot-kit provide device discovery, serial/protocol handling, peripheral abstractions, flashing, and board-specific setup.
- The firmware/ directory contains target-specific code for Pico, ESP32, Nucleo, Arduino, and related protocol support.
- Hardware is treated as another tool/peripheral domain, with the runtime connecting to real devices through defined traits and transport layers.
11. Plugins and extensibility
- crates/zeroclaw-plugins is the host/runtime for WASM-based plugins and custom tools/channels.
- The plugins/ directory contains packaged example plugins, such as image generation integrations.
- This gives the architecture an extension boundary without requiring all integrations to be compiled into the core binary.
12. Event-driven automation
- The SOP/cron/heartbeat/routines areas in zeroclaw-runtime handle scheduled and event-triggered workflows.
- Triggers can come from cron, MQTT, webhooks, peripherals, or internal events, then run through approval and execution paths.
- This makes the system more than chat: it is an always-on automation engine with resumable workflows.
13. Configuration and persistence
- Configuration is centralized in TOML under ~/.zeroclaw/config.toml, with schema generation and migration support.
- Supporting crates handle workspace settings, provider aliases, secrets, policy, pairing, and platform-specific behavior.
- Session storage, debouncing, watchdogs, and migration code indicate the runtime preserves long-lived state across restarts.
14. Operational surfaces
- The repo includes docs/book content, CI/release automation, Docker and Kubernetes deployment assets, and a Tauri/web UI bundle.
- These are not core runtime subsystems, but they shape how the system is packaged, deployed, observed, and maintained.
- For an architecture diagram, the main external boundaries to show are: user/client UIs, channel ingress, provider egress, tool/action egress, memory storage, hardware/firmware, and the security gate around all side effects.
Main entry points: zeroclaw-runtime Runtime · main.rs zeroclaw · zeroclaw-gateway Gateway · zeroclaw-channels Channels
Components 21
Core runtime
Agent orchestration, policy, memory, and provider/tool execution.
- zeroclaw · Top-level workspace entry and shared root-package surface.
src/main.rs - Runtime · Main agent loop, approvals, policy, SOP/cron, observability, onboarding, and trust.
crates/zeroclaw-runtime - Agent loop · Prompting, history, dispatch, tool execution, and loop control.
crates/zeroclaw-runtime/src/agent - Security gate · Autonomy, sandboxing, prompt guards, leak detection, pairing, and audit.
crates/zeroclaw-runtime/src/security - SOP engine · Scheduled and event-triggered workflows with dispatch and approval paths.
crates/zeroclaw-runtime/src/sop - Cron · Recurring schedules, stores, and run management.
crates/zeroclaw-runtime/src/cron - Memory · Persistent memory, embeddings, retrieval, consolidation, and caching.
crates/zeroclaw-memory - Providers · LLM and multimodal provider routing, auth, fallback, and capability handling.
crates/zeroclaw-providers - Tools · Filesystem, shell, browser, search, memory, MCP, and app-specific tools.
crates/zeroclaw-tools - API types · Common request/response traits and schemas used across crates.
crates/zeroclaw-api
Ingress
External message surfaces and client entry points.
- Channels · Incoming message adapters for chat, email, voice, webhook, CLI, and social platforms.
crates/zeroclaw-channels - Gateway · HTTP/WebSocket/SSE boundary for dashboard clients, pairing, sessions, TLS, and voice duplex.
crates/zeroclaw-gateway - Web UI · React/Vite dashboard for chat, config, memory, cron, tools, logs, and pairing.
web - Tauri shell · Native wrapper around the web UI with tray, commands, and gateway integration.
apps/tauri
Extensions
Pluggable integrations and device/hardware domains.
- Plugins · Runtime host for WASM plugins, custom tools, and custom channels.
crates/zeroclaw-plugins - Hardware · Device discovery, serial/protocol handling, peripherals, and flashing support.
crates/zeroclaw-hardware - Robot kit · Higher-level robot behaviors and traits built on hardware abstractions.
crates/robot-kit - Firmware · Target firmware and protocol implementations for boards and microcontrollers.
firmware
Ops and surface
Configuration, infrastructure, and packaging surfaces around the core.
Connections 24
- zeroclaw → Runtime: starts · Main application delegates orchestration to the runtime.
- zeroclaw → Gateway: serves · Binary exposes the local gateway for clients.
- zeroclaw → Channels: ingests · Workspace includes ingress adapters for external events.
- zeroclaw → Config: loads · Runtime behavior is driven by central configuration.
- Runtime → Agent loop: runs · The runtime owns the agent loop and request lifecycle.
- Runtime → Security gate: guards · All sensitive actions pass through policy and autonomy checks.
- Runtime → SOP engine: orchestrates · Runtime schedules and executes SOP workflows.
- Runtime → Cron: schedules · Cron support feeds recurring work into the runtime.
- Runtime → Memory: retrieves · Memory is loaded into context and updated from outcomes.
- Runtime → Providers: calls · Model requests are routed into provider backends.
- Runtime → Tools: executes · Tool invocation is mediated by the runtime.
- Runtime → API types: shares contracts · Common types and traits define the runtime interface.
- Channels → Runtime: delivers events · Channel adapters normalize inbound messages for the runtime.
- Gateway → Runtime: proxies · Dashboard and API clients interact with runtime state through the gateway.
- Web UI → Gateway: connects · Browser UI uses the gateway as its backend.
- Tauri shell → Web UI: wraps · Desktop shell packages the web dashboard.
- Tauri shell → Gateway: uses · Native shell talks to the local gateway client.
- Plugins → Tools: extends · Plugins add custom tool capabilities.
- Plugins → Channels: extends · Plugins can also host custom channels.
- Hardware → Tools: exposes · Hardware operations are surfaced as callable tools.
- Robot kit → Hardware: builds on · Robot behaviors sit on top of hardware abstractions.
- Firmware → Hardware: targets · Embedded firmware is the endpoint for hardware support.
- Infra → Runtime: supports · Session and watchdog infrastructure supports long-lived execution.
- Docs → Runtime: documents · Architecture and operation docs describe the runtime-centric system.