rustyclaw-core 0.2.0

Core library for RustyClaw β€” config, gateway protocol, secrets, tools, and shared types
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
<p align="center">
  <img src="logo.svg" alt="RustyClaw" width="200"/>
</p>

<h1 align="center">RustyClaw πŸ¦€πŸ¦ž</h1>

<p align="center">
  <strong>The secure, open-source operating system for AI agents</strong>
</p>

<p align="center">
  <a href="https://crates.io/crates/rustyclaw"><img src="https://img.shields.io/crates/v/rustyclaw.svg" alt="crates.io"></a>
  <a href="https://github.com/rexlunae/RustyClaw/actions"><img src="https://github.com/rexlunae/RustyClaw/workflows/CI/badge.svg" alt="CI"></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT"></a>
  <a href="https://discord.com/invite/clawd"><img src="https://img.shields.io/badge/Discord-Community-5865F2?logo=discord&logoColor=white" alt="Discord"></a>
</p>

<p align="center">
  <a href="#quick-start">Quick Start</a> β€’
  <a href="#building-from-source">Building</a> β€’
  <a href="#why-rustyclaw">Why RustyClaw</a> β€’
  <a href="#features">Features</a> β€’
  <a href="#security">Security</a> β€’
  <a href="#architecture">Architecture</a>
</p>

 pu---

## What is RustyClaw?

RustyClaw is an **agentic AI operating system** β€” a complete runtime for deploying, orchestrating, and securing AI agents. It provides everything agents need: tools, memory, isolation, scheduling, multi-agent coordination, and secure credential management.

Think of it as **Linux for AI agents**: a stable, secure foundation that handles the hard infrastructure problems so you can focus on what your agents actually do.

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         YOUR AI AGENTS                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Tools     β”‚  Memory    β”‚  Channels  β”‚  Sessions  β”‚  Scheduling    β”‚
β”‚  (30+)     β”‚  (files,   β”‚  (Signal,  β”‚  (spawn,   β”‚  (cron,        β”‚
β”‚            β”‚   search)  β”‚   Matrix)  β”‚   steer)   β”‚   heartbeat)   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                    SECURITY & ISOLATION LAYER                       β”‚
β”‚   PromptGuard Β· LeakDetector Β· Sandbox Β· Encrypted Vault Β· SSRF    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                     RUSTYCLAW RUNTIME (Rust)                        β”‚
β”‚            ~15MB RAM Β· <50ms startup Β· Single binary                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## Why RustyClaw?

### πŸ”’ Security-First Design

AI agents are powerful but risky. They can be tricked into leaking secrets, executing malicious commands, or exfiltrating data. RustyClaw is built with the assumption that **agents can't always be trusted**.

| Defense Layer | What It Does |
|---------------|--------------|
| **PromptGuard** | Detects prompt injection attacks (system override, role confusion, jailbreaks) |
| **LeakDetector** | Blocks credential exfiltration via API keys, tokens, SSH keys in outputs |
| **Sandbox Isolation** | Bubblewrap (Linux), Landlock (5.13+), sandbox-exec (macOS) |
| **SSRF Protection** | Blocks requests to private IPs, metadata endpoints |
| **Encrypted Vault** | AES-256 secrets with optional TOTP 2FA |
| **HTTP Request Scanning** | Validates URLs, headers, and bodies before outbound requests |

No other agent framework in the ecosystem has this level of built-in security. Most have **zero prompt injection defense**.

### ⚑ Lightweight & Fast

| Metric | RustyClaw | OpenClaw (Node.js) | Python Agents |
|--------|-----------|-------------------|---------------|
| **Memory** | ~15 MB | ~150 MB | ~100+ MB |
| **Startup** | <50 ms | ~500 ms | ~1s+ |
| **Binary** | ~8 MB | ~200 MB (w/ node) | N/A |
| **Dependencies** | 0 (single binary) | node_modules | venv |

Run on a $10 Raspberry Pi or a $500/month cloud instance. Same binary.

### πŸ”Œ Provider Agnostic

Connect to any LLM provider without code changes:

- **Anthropic** (Claude Opus, Sonnet, Haiku)
- **OpenAI** (GPT-4o, o1, o3)
- **Google** (Gemini Pro, Ultra)
- **GitHub Copilot** (with subscription)
- **xAI** (Grok)
- **Ollama** (local models)
- **OpenRouter** (200+ models)
- **Any OpenAI-compatible endpoint**

### πŸ€– Multi-Agent Orchestration

Spawn sub-agents, steer them mid-task, coordinate across sessions:

```rust
// Spawn a research agent
let research = spawn_agent("Summarize the latest papers on RLHF", AgentConfig {
    model: "claude-sonnet",
    timeout: Duration::minutes(10),
    ..default()
});

// Spawn a coding agent in parallel
let coder = spawn_agent("Implement the algorithm from the research", AgentConfig {
    model: "gpt-4o",
    ..default()
});

// Steer mid-execution
research.steer("Focus specifically on Constitutional AI approaches");
```

## Quick Start

### One-Line Setup (Everything)

Install RustyClaw plus all supporting tools (uv, Ollama, Node.js, Exo):

```bash
# From a clone
git clone https://github.com/rexlunae/RustyClaw.git && cd RustyClaw
./scripts/setup.sh

# Or pick components
./scripts/setup.sh --skip exo          # skip exo
./scripts/setup.sh --only rust rustyclaw  # just Rust + RustyClaw
```

### Install RustyClaw Only

```bash
cargo install rustyclaw
```

Or download a pre-built binary from [Releases](https://github.com/rexlunae/RustyClaw/releases).

### Configure

```bash
rustyclaw onboard
```

This interactive wizard sets up:
- API key for your preferred provider
- Encrypted secrets vault
- Workspace directory
- Channel connections (optional)

### Run

```bash
# Interactive terminal UI
rustyclaw tui

# Or run as a daemon for integrations
rustyclaw gateway start
```

## Building from Source

RustyClaw is organized as a **Cargo workspace** with three crates:

| Crate | Path | Description |
|-------|------|-------------|
| **rustyclaw-core** | `crates/rustyclaw-core/` | Core library β€” config, gateway, tools, secrets, providers |
| **rustyclaw-cli** | `crates/rustyclaw-cli/` | CLI binaries (`rustyclaw` and `rustyclaw-gateway`) |
| **rustyclaw-tui** | `crates/rustyclaw-tui/` | Terminal UI client (ratatui) |

### Prerequisites

- **Rust 1.85+** (Edition 2024)
- **OpenSSL** development headers (vendored by default)

```bash
# macOS β€” no extra deps needed (uses vendored OpenSSL)

# Ubuntu / Debian
sudo apt install build-essential pkg-config

# Fedora / RHEL
sudo dnf install gcc openssl-devel
```

### Build the Workspace

```bash
git clone https://github.com/rexlunae/RustyClaw.git
cd RustyClaw

# Debug build (fast compile, all crates)
cargo build --workspace

# Release build (optimized, ~11 MB binary with LTO)
cargo build --release
```

Binaries are produced at:
- `target/release/rustyclaw` β€” main CLI + TUI
- `target/release/rustyclaw-gateway` β€” standalone gateway daemon

### Feature Flags

Features are split across the workspace crates:

**rustyclaw-cli** (binary crate):

| Feature | Description | Default |
|---------|-------------|---------|
| `tui` | Terminal UI (ratatui + crossterm) | βœ… |

**rustyclaw-core** (library crate):

| Feature | Description | Default |
|---------|-------------|---------|
| `web-tools` | HTML parsing via scraper + html2md | βœ… |
| `matrix` | Matrix messenger support | |
| `browser` | CDP browser automation (chromiumoxide) | |
| `full` | web-tools + matrix + browser | |
| `signal` | Signal messenger (source-only, see below) | |

```bash
# Default (TUI + web tools)
cargo build --release

# Headless gateway only (no TUI)
cargo build --release -p rustyclaw-cli --no-default-features

# With Matrix support
cargo build --release --features rustyclaw-core/matrix

# Everything enabled
cargo build --release --features rustyclaw-core/full

# Build only the core library
cargo check -p rustyclaw-core

# Build only the TUI client
cargo check -p rustyclaw-tui
```

### Running Tests

```bash
# All workspace tests
cargo test --workspace

# Core library tests only
cargo test -p rustyclaw-core

# TUI client tests only
cargo test -p rustyclaw-tui
```

### Cross-Compilation (Raspberry Pi)

Build a headless gateway for ARM using [cross](https://github.com/cross-rs/cross):

```bash
cargo install cross --git https://github.com/cross-rs/cross

# 64-bit (Pi 3/4/5)
cross build --release --target aarch64-unknown-linux-gnu \
  -p rustyclaw-cli --no-default-features

# 32-bit (Pi 2/3)
cross build --release --target armv7-unknown-linux-gnueabihf \
  -p rustyclaw-cli --no-default-features
```

### Signal Messenger (Source Only)

Signal requires git-only dependencies not on crates.io. See [BUILDING.md](BUILDING.md) for detailed instructions on enabling Signal support.

## Features

### πŸ› οΈ 30+ Agentic Tools

Everything an agent needs to be useful:

| Category | Tools |
|----------|-------|
| **Files** | `read_file`, `write_file`, `edit_file`, `list_directory`, `search_files` |
| **Execution** | `execute_command`, `process`, `apply_patch` |
| **Web** | `web_fetch`, `web_search`, `browser` |
| **Memory** | `memory_search`, `memory_get` |
| **Scheduling** | `cron`, heartbeat system |
| **Multi-Agent** | `sessions_spawn`, `sessions_send`, `sessions_steer` |
| **Secrets** | `secrets_list`, `secrets_get`, `secrets_store` |
| **Devices** | `canvas`, `nodes`, `tts` |

### πŸ“š Skills System

Extend capabilities with skills β€” markdown files that teach agents new abilities:

```yaml
---
name: github
description: GitHub operations via gh CLI
requires:
  bins: [gh]
  env: [GITHUB_TOKEN]
---

# GitHub Skill

You can use the `gh` CLI to manage issues, PRs, and repos...
```

Skills support **dependency gating**: if requirements aren't met, the agent sees what's missing and can try to install it.

Browse community skills at [ClawHub](https://clawhub.com).

### πŸ’¬ Multi-Channel Support

Connect agents to the platforms where work happens:

- **Signal** (secure messaging)
- **Matrix** (federated chat)
- **Telegram** (bot API)
- **Discord** (bot API)
- **Slack** (with app tokens)
- **WhatsApp** (QR code pairing)
- **HTTP webhooks** (custom integrations)

### 🧠 Memory & Context

Two-layer memory system for long-running agents:

- **MEMORY.md** β€” Long-term facts (LLM-curated)
- **HISTORY.md** β€” Grep-searchable event log

Memory consolidation runs automatically, keeping context windows manageable while preserving important information.

### ⏰ Scheduling & Automation

Built-in cron system for recurring tasks:

```json
{
  "schedule": { "kind": "cron", "expr": "0 9 * * MON" },
  "payload": {
    "kind": "agentTurn",
    "message": "Check email and summarize anything urgent"
  }
}
```

Heartbeat system for proactive monitoring without explicit schedules.

## Security

RustyClaw's security model is documented in detail:

- **[SECURITY.md]docs/SECURITY.md** β€” Full security architecture
- **[THREAT_MODEL.md]docs/THREAT_MODEL.md** β€” Known threats and mitigations
- **[AUDIT.md]docs/AUDIT.md** β€” Audit log and findings

t### Quick Overview

```
User Input
    β”‚
    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ InputValidatorβ”‚ ─── Length, encoding, padding attacks
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PromptGuard  β”‚ ─── 6 injection categories, configurable sensitivity
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Agent      β”‚ ─── Sandboxed execution
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ LeakDetector  β”‚ ─── Blocks secrets in outputs/requests
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ SSRF Validatorβ”‚ ─── Blocks private IPs, metadata endpoints
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

### Encrypted Secrets Vault

API keys, tokens, and credentials are stored encrypted:

- AES-256-GCM encryption
- Optional TOTP 2FA for vault access
- Per-credential access policies (Always, WithApproval, WithAuth, SkillOnly)
- Agent tools cannot read the vault directory

## Architecture

RustyClaw follows a **trait-driven architecture** β€” core systems are pluggable:

```rust
// Swap providers without changing agent code
trait LlmProvider {
    async fn chat(&self, messages: &[Message]) -> Response;
}

// Swap channels without changing agent code
trait Channel {
    async fn receive(&self) -> InboundMessage;
    async fn send(&self, msg: OutboundMessage);
}

// Swap runtimes for different isolation levels
trait RuntimeAdapter {
    async fn execute(&self, command: Command) -> Output;
}
```

### Workspace Layout

```
RustyClaw/
β”œβ”€β”€ Cargo.toml              # Workspace root
β”œβ”€β”€ crates/
β”‚   β”œβ”€β”€ rustyclaw-core/     # Core library (config, gateway, tools, secrets, providers)
β”‚   β”œβ”€β”€ rustyclaw-cli/      # CLI binaries (rustyclaw + rustyclaw-gateway)
β”‚   └── rustyclaw-tui/      # Terminal UI client (ratatui)
β”œβ”€β”€ docs/                   # Architecture, security, and client spec docs
β”œβ”€β”€ tests/                  # Integration and E2E tests
└── website/                # Project website and install scripts
```

### Core Components

| Component | Crate | Responsibility |
|-----------|-------|----------------|
| **Gateway** | core | Daemon process, WebSocket protocol, session management |
| **Agent Loop** | core | LLM calls, tool execution, context management |
| **Tool Registry** | core | 30+ tools with dynamic registration and validation |
| **Session Manager** | core | Multi-agent coordination, history, spawn/steer |
| **Security Layer** | core | PromptGuard, LeakDetector, SSRF, sandbox |
| **Secrets Vault** | core | AES-256 encrypted credential storage, access policies |
| **Terminal UI** | tui | Interactive chat, tool approval, config management |
| **CLI** | cli | Command-line entry point, onboarding wizard |

## Comparison

| Feature | RustyClaw | OpenClaw | ZeroClaw | nanobot |
|---------|-----------|----------|----------|---------|
| **Language** | Rust | TypeScript | Rust | Python |
| **Memory** | ~15 MB | ~150 MB | <5 MB | ~100 MB |
| **Startup** | <50 ms | ~500 ms | <10 ms | ~1s |
| **PromptGuard** | βœ… | ❌ | ❌ | ❌ |
| **LeakDetector** | βœ… | ❌ | ❌ | ❌ |
| **Encrypted Vault** | βœ… | External | βœ… | ❌ |
| **Multi-Agent** | βœ… | βœ… | βœ… | βœ… |
| **Skills** | βœ… | βœ… | βœ… | βœ… |

## Contributing

We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

Key areas we're focused on:

- **Security hardening** β€” More detection patterns, sandbox improvements
- **New channels** β€” iMessage, Teams, Zulip
- **Performance** β€” Even lower memory, faster startup
- **Skills ecosystem** β€” More community skills

## License

MIT License. See [LICENSE](LICENSE).

## Acknowledgments

RustyClaw builds on ideas from:

- [OpenClaw]https://github.com/openclaw/openclaw β€” The original agentic AI assistant
- [IronClaw]https://github.com/nearai/ironclaw β€” Security patterns and HTTP scanning
- [nanobot]https://github.com/HKUDS/nanobot β€” Memory consolidation and progressive skill loading
- [ZeroClaw]https://github.com/zeroclaw-labs/zeroclaw β€” RuntimeAdapter and observability patterns

---

<p align="center">
  <strong>Built with πŸ¦€ by the RustyClaw community</strong>
</p>