# zeroclaw-labs/zeroclaw architecture

> Architecture diagram of the GitHub repository zeroclaw-labs/zeroclaw, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zeroclaw-labs/zeroclaw
- Repository: https://github.com/zeroclaw-labs/zeroclaw

## Overview

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: [`crates/zeroclaw-runtime`](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-runtime) (Runtime), [`src/main.rs`](https://github.com/zeroclaw-labs/zeroclaw/blob/master/src/main.rs) (zeroclaw), [`crates/zeroclaw-gateway`](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-gateway) (Gateway), [`crates/zeroclaw-channels`](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-channels) (Channels)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core runtime"]
  node_root(("zeroclaw<br/>app binary<br/>[main.rs]"))
  node_runtime["Runtime<br/>orchestration"]
  node_agent["Agent loop<br/>planning/execution"]
  node_security["Security gate<br/>policy boundary"]
  node_sop["SOP engine<br/>automation"]
  node_cron["Cron<br/>scheduler"]
  node_memory[("Memory<br/>retrieval store")]
  node_providers["Providers<br/>model backends"]
  node_tools["Tools<br/>action layer"]
  node_api["API types<br/>shared contracts"]
end

subgraph group_ingress["Ingress"]
  node_channels["Channels<br/>ingress adapters"]
  node_gateway["Gateway<br/>local server"]
  node_web["Web UI<br/>dashboard"]
  node_tauri["Tauri shell<br/>desktop app"]
end

subgraph group_ext["Extensions"]
  node_plugins["Plugins<br/>wasm host"]
  node_hardware["Hardware<br/>device layer"]
  node_robotkit["Robot kit<br/>device runtime"]
  node_firmware["Firmware<br/>embedded targets"]
end

subgraph group_ops["Ops and surface"]
  node_config["Config<br/>settings"]
  node_infra["Infra<br/>runtime support"]
  node_docs["Docs<br/>book"]
end

node_root -->|"starts"| node_runtime
node_root -->|"serves"| node_gateway
node_root -->|"ingests"| node_channels
node_root -->|"loads"| node_config
node_runtime -->|"runs"| node_agent
node_runtime -->|"guards"| node_security
node_runtime -->|"orchestrates"| node_sop
node_runtime -->|"schedules"| node_cron
node_runtime -->|"retrieves"| node_memory
node_runtime -->|"calls"| node_providers
node_runtime -->|"executes"| node_tools
node_runtime -->|"shares contracts"| node_api
node_channels -->|"delivers events"| node_runtime
node_gateway -->|"proxies"| node_runtime
node_web -->|"connects"| node_gateway
node_tauri -->|"wraps"| node_web
node_tauri -->|"uses"| node_gateway
node_plugins -->|"extends"| node_tools
node_plugins -->|"extends"| node_channels
node_hardware -->|"exposes"| node_tools
node_robotkit -->|"builds on"| node_hardware
node_firmware -->|"targets"| node_hardware
node_infra -->|"supports"| node_runtime
node_docs -.->|"documents"| node_runtime

click node_root "https://github.com/zeroclaw-labs/zeroclaw/blob/master/src/main.rs"
click node_runtime "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-runtime"
click node_agent "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-runtime/src/agent"
click node_security "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-runtime/src/security"
click node_sop "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-runtime/src/sop"
click node_cron "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-runtime/src/cron"
click node_memory "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-memory"
click node_providers "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-providers"
click node_tools "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-tools"
click node_api "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-api"
click node_channels "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-channels"
click node_gateway "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-gateway"
click node_web "https://github.com/zeroclaw-labs/zeroclaw/tree/master/web"
click node_tauri "https://github.com/zeroclaw-labs/zeroclaw/tree/master/apps/tauri"
click node_plugins "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-plugins"
click node_hardware "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-hardware"
click node_robotkit "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/robot-kit"
click node_firmware "https://github.com/zeroclaw-labs/zeroclaw/tree/master/firmware"
click node_config "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-config"
click node_infra "https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-infra"
click node_docs "https://github.com/zeroclaw-labs/zeroclaw/tree/master/docs/book"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_root,node_runtime,node_agent,node_security,node_sop,node_cron,node_memory,node_providers,node_tools,node_api toneBlue
class node_channels,node_gateway,node_web,node_tauri toneAmber
class node_plugins,node_hardware,node_robotkit,node_firmware toneMint
class node_config,node_infra,node_docs toneRose
```

## Components

### Core runtime

Agent orchestration, policy, memory, and provider/tool execution.

- [zeroclaw](https://github.com/zeroclaw-labs/zeroclaw/blob/master/src/main.rs): app binary · Top-level workspace entry and shared root-package surface. · `src/main.rs`
- [Runtime](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-runtime): orchestration · Main agent loop, approvals, policy, SOP/cron, observability, onboarding, and trust. · `crates/zeroclaw-runtime`
- [Agent loop](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-runtime/src/agent): planning/execution · Prompting, history, dispatch, tool execution, and loop control. · `crates/zeroclaw-runtime/src/agent`
- [Security gate](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-runtime/src/security): policy boundary · Autonomy, sandboxing, prompt guards, leak detection, pairing, and audit. · `crates/zeroclaw-runtime/src/security`
- [SOP engine](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-runtime/src/sop): automation · Scheduled and event-triggered workflows with dispatch and approval paths. · `crates/zeroclaw-runtime/src/sop`
- [Cron](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-runtime/src/cron): scheduler · Recurring schedules, stores, and run management. · `crates/zeroclaw-runtime/src/cron`
- [Memory](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-memory): retrieval store · Persistent memory, embeddings, retrieval, consolidation, and caching. · `crates/zeroclaw-memory`
- [Providers](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-providers): model backends · LLM and multimodal provider routing, auth, fallback, and capability handling. · `crates/zeroclaw-providers`
- [Tools](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-tools): action layer · Filesystem, shell, browser, search, memory, MCP, and app-specific tools. · `crates/zeroclaw-tools`
- [API types](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-api): shared contracts · Common request/response traits and schemas used across crates. · `crates/zeroclaw-api`

### Ingress

External message surfaces and client entry points.

- [Channels](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-channels): ingress adapters · Incoming message adapters for chat, email, voice, webhook, CLI, and social platforms. · `crates/zeroclaw-channels`
- [Gateway](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-gateway): local server · HTTP/WebSocket/SSE boundary for dashboard clients, pairing, sessions, TLS, and voice duplex. · `crates/zeroclaw-gateway`
- [Web UI](https://github.com/zeroclaw-labs/zeroclaw/tree/master/web): dashboard · React/Vite dashboard for chat, config, memory, cron, tools, logs, and pairing. · `web`
- [Tauri shell](https://github.com/zeroclaw-labs/zeroclaw/tree/master/apps/tauri): desktop app · Native wrapper around the web UI with tray, commands, and gateway integration. · `apps/tauri`

### Extensions

Pluggable integrations and device/hardware domains.

- [Plugins](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-plugins): wasm host · Runtime host for WASM plugins, custom tools, and custom channels. · `crates/zeroclaw-plugins`
- [Hardware](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-hardware): device layer · Device discovery, serial/protocol handling, peripherals, and flashing support. · `crates/zeroclaw-hardware`
- [Robot kit](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/robot-kit): device runtime · Higher-level robot behaviors and traits built on hardware abstractions. · `crates/robot-kit`
- [Firmware](https://github.com/zeroclaw-labs/zeroclaw/tree/master/firmware): embedded targets · Target firmware and protocol implementations for boards and microcontrollers. · `firmware`

### Ops and surface

Configuration, infrastructure, and packaging surfaces around the core.

- [Config](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-config): settings · Workspace config, schema, migration, secrets, pairing, and policy settings. · `crates/zeroclaw-config`
- [Infra](https://github.com/zeroclaw-labs/zeroclaw/tree/master/crates/zeroclaw-infra): runtime support · Session storage, debounce, and watchdog support used by the runtime. · `crates/zeroclaw-infra`
- [Docs](https://github.com/zeroclaw-labs/zeroclaw/tree/master/docs/book): book · Architecture, setup, security, provider, tool, and ops documentation. · `docs/book`

## Connections

- 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.
