A Production-Ready AI Agent Operating System Built from Scratch in Rust
"Building the next-generation intelligent assistant infrastructure,
making AI as ubiquitous as water โ fluid, adaptive, and ceaseless."
Why Crablet โข Architecture โข Memory โข GraphRAG โข Canvas โข Swarm โข Quick Start โข Docs
Crablet is not another chatbot wrapper. It is a complete AI Agent Operating System written entirely in Rust โ a system that provides production-ready cognitive infrastructure for Large Language Models with genuine thinking, planning, memory, tool use, and multi-agent collaboration.
| Traditional LLM Wrappers | Crablet |
|---|---|
| Stateless request/response | Persistent layered memory (working โ episodic โ semantic) |
| Single-step tool calls | ReAct reasoning loops with middleware pipeline |
| Flat retrieval (keyword search) | GraphRAG combining vector search + knowledge graph traversal |
| No output structuring | Canvas โ live structured artifact rendering |
| Sequential processing | Swarm โ 100+ concurrent collaborative agents |
| Python GC pauses | Zero-GC Rust with Tokio async runtime |
| Language | Share | Role |
|---|---|---|
| ๐ฆ Rust | 65.2% | Core engine, cognitive layers, memory, tools |
| ๐ฆ TypeScript | 28.8% | Frontend, Web UI, Dashboard |
| ๐ HTML | 4.7% | Templates, Canvas rendering |
| ๐ Python | 0.8% | MCP servers, skill scripts |
| ๐ณ Dockerfile | 0.2% | Container definitions |
Crablet's most distinctive feature is its biologically-inspired three-tier cognitive routing system. Inspired by Dual Process Theory, every input is automatically classified and routed by the Cognitive Router to the optimal processing layer:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ INPUT CHANNELS โ
โ CLI โ Web UI โ Telegram โ DingTalk โ Feishu โ HTTP Webhook โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GATEWAY LAYER (Axum + WebSocket) โ
โ JSON-RPC โ REST API โ SSE Streaming โ Auth โ Rate Limiting โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ EVENT BUS โ
โ Tokio Broadcast Channel (lock-free) โ
โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโโโโผโโโโโโโโ โโโโโโโโผโโโโโโโ โโโโโโโโโโโโผโโโโโโโ
โ SYSTEM 1 โ โ SYSTEM 2 โ โ SYSTEM 3 โ
โ Intuitive โ โ Analytical โ โ Collaborative โ
โ โ โ โ โ โ
โ Trie + Levensh.โ โ ReAct Engineโ โ Swarm Agents โ
โ < 10 ms โ โ 2 โ 10 s โ โ 10 s + โ
โโโโโโโโโโฌโโโโโโโโ โโโโโโโโฌโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโ
โ โ โ
โโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโ
โ FOUNDATION LAYER โ
โ Memory โ GraphRAG โ Tools โ Safety Oracle โ Canvas โ Skills โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The fastest path, designed for high-frequency, low-complexity interactions:
IntentTrieโ O(L) prefix-tree intent lookup- Levenshtein fuzzy matching โ tolerates typos and spelling variations
- Semantic cache โ memoized responses for repeated queries
- Ideal for: greetings, FAQs, system commands, cached results
The workhorse for complex reasoning tasks, built on a full ReAct pipeline with a pluggable middleware chain:
[Safety Oracle]
โ [CostGuard]
โ [SemanticCache]
โ [Planning]
โ [RAG Middleware]
โ [SkillContext]
โ [ReAct Core: Thought โ Action โ Observation loop]
โ [Canvas Post-processor]
โ [Streaming Pipeline]
Additional System 2 capabilities:
- Tree of Thoughts (ToT) โ parallel branch exploration for open-ended problems
- MCTS (Monte Carlo Tree Search) โ UCB1-guided thought exploration with LLM simulation
- Multimodal โ image and audio understanding integrated into reasoning
For tasks that require decomposition, parallelism, and coordination across multiple specialised agents:
SwarmOrchestratordecomposes goals into aTaskGraph- Individual agents run in isolated Tokio tasks (100+ concurrent)
- Agents communicate via typed message channels (
Task,Result,StatusUpdate,Broadcast,Error) SharedBlackboardfor cross-agent state sharing- Built-in
DebateModeratorfor structured multi-agent argumentation VotingAgentfor democratic consensus on proposalsTaskGraphtemplates โ reusable multi-step workflow definitions
Crablet implements a three-tier hierarchical memory architecture that mirrors how humans organize knowledge:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MEMORY HIERARCHY โ
โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ Working โ โ Episodic โ โ Semantic โ โ
โ โ Memory โ โ Memory โ โ Memory โ โ
โ โ โ โ โ โ โ โ
โ โ VecDeque โ โ SQLite โ โ Neo4j / SQLite โ โ
โ โ + Tiktoken โ โ WAL Mode โ โ Knowledge โ โ
โ โ Token Budget โ โ Sessions โ โ Graph โ โ
โ โ O(1) โ โ + Messages โ โ + D3 Export โ โ
โ โโโโโโโโฌโโโโโโโโ โโโโโโโโโฌโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโ โ
โ โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโ โ
โ MEMORY CONSOLIDATOR โ
โ LLM-powered background summarization loop โ
โ Triggers: every 20 messages OR 1 hour TTL โ
โ Output: long-term vector embeddings โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Token-budgeted context window โ tracks exact token count using
tiktoken-rs(cl100k_base tokenizer) - Smart compression โ preserves system message + last N exchanges; drops oldest messages when budget exceeded
- Expiry TTL โ auto-evicts idle sessions (
is_expired(Duration)) - Consolidator hook โ plugs into
MemoryConsolidatorfor seamless promotion to long-term memory
- SQLite-backed persistence โ WAL journal mode, 64MB cache, optimized pragmas for high-throughput writes
- Transactional writes โ
save_message_transactionalensures consistency across concurrent sessions - Session management โ UUID-based session IDs with per-channel tracking
- Chronological recall โ
get_history(session_id, limit)returns messages in conversation order
- Dual backend โ
SqliteKnowledgeGraph(zero-dependency) orNeo4jKnowledgeGraph(enterprise scale) - Entity + relation modeling โ
add_entity,add_relation,find_relatedwith directional traversal - D3.js export โ
export_d3_json()produces graph visualization data for the Web UI dashboard - Batch entity lookups โ
find_entities_batchfor efficient bulk graph queries
The background MemoryConsolidator runs as a persistent Tokio task and:
- Triggers every 20 messages or every 1 hour per session
- Fetches the last 50 messages and generates an LLM summary
- Stores the summary as a timestamped embedding in the Vector Store (
type: "conversation_summary") - Tags memories with
importanceandaccess_countfor future decay/retrieval scoring
Crablet's RAG system goes far beyond simple vector similarity โ it combines dense retrieval with structured knowledge graph reasoning:
Query Input
โ
โผ
Vector Search (fastembed / Qdrant)
โ โ cosine similarity
โผ
Entity Extraction (Rule + Phrase + Hybrid modes)
โ
โผ
Knowledge Graph Traversal (Neo4j / SQLite)
โ โ finds related entities and relations
โผ
Graph-Augmented Reranking
โ score = vector_score ร 0.7 + graph_boost ร 0.3
โ graph_boost = coverage ร 0.4 + relation_weight ร 0.25
โ + centrality ร 0.15 + graph_signal ร 0.2
โผ
Retrieved Context (documents + KG relations injected)
| Feature | Implementation |
|---|---|
| Embedding backends | fastembed (AllMiniLM-L6-v2, 384-dim, local) or Qdrant cloud |
| Vector store | SQLite (default), Qdrant (via qdrant-support feature), In-Memory (tests) |
| Chunking strategies | RecursiveCharacterChunker (500 chars, 50 overlap) + MarkdownChunker (heading-aware) |
| Entity extraction | Rule (tokenization), Phrase (bigram windows), Hybrid (both) |
| Graph backends | SqliteKnowledgeGraph or Neo4jKnowledgeGraph (feature-gated) |
| Centrality scoring | Normalized in-/out-degree centrality for entity relevance ranking |
| Document types | Text, Markdown (structure-aware), PDF (pdf-extract), Multimodal |
| Embedder pool | 2 concurrent fastembed workers (Tokio blocking tasks) |
| Reranking | Graph-signal-weighted cosine reranking before final top-k selection |
crablet knowledge extract --file document.pdf # PDF ingestion
crablet knowledge extract --file notes.md # Markdown-aware chunking
crablet knowledge extract --file code.rs # Source code indexing
crablet knowledge query "Rust async patterns" # Semantic searchCanvas is Crablet's real-time structured output rendering system. Rather than returning plain text, System 2 automatically detects and publishes rich artifacts to an interactive canvas that users can view, edit, and export.
enum CanvasComponent {
Markdown { content: String },
Code { language: String, content: String, filename: Option<String> },
Mermaid { chart: String }, // Auto-rendered flow/sequence diagrams
DataTable { headers, rows, title }, // Structured tabular data
Html { content: String }, // Live HTML preview (UI mockups)
}- Auto-detection โ
detect_and_publish_canvas()scans every LLM response for structured blocks - Artifact routing โ detected artifacts are published to the
EventBusasAgentEvent::CanvasUpdate - Session-scoped state โ
CanvasManagermaintains per-sessionCanvasStatewith ordered sections - Real-time streaming โ artifacts are streamed to the frontend via SSE (Server-Sent Events)
- CRUD operations โ
add_component,update_component,remove_componentfor interactive editing
| Trigger | Artifact Type | Example |
|---|---|---|
```mermaid |
Flow diagram | Architecture diagrams, sequence charts |
```html + <div/html/body> |
HTML Preview | UI mockups, dashboards |
```rust/python/ts (>5 lines) |
Code snippet | Generated code, scripts |
DataTable JSON |
Data table | Query results, comparisons |
| Markdown sections | Rich text | Reports, documentation |
The Swarm system enables true multi-agent collaboration using Rust's ownership model to guarantee race-free concurrent execution:
| Agent | File | Specialization |
|---|---|---|
Researcher |
agent/researcher.rs |
Web search, information gathering |
Coder |
agent/coder.rs |
Code generation and review |
Analyst |
agent/analyst.rs |
Data analysis, pattern recognition |
Reviewer |
agent/reviewer.rs |
Quality assurance, critique |
Planner |
agent/planning.rs |
Task decomposition, goal trees |
SecurityAgent |
agent/security.rs |
Vulnerability scanning, audit |
VotingAgent |
agent/voting.rs |
Democratic consensus on proposals |
DebateModerator |
agent/debate.rs |
Structured multi-round argumentation |
HITL |
agent/hitl.rs |
Human-in-the-loop approval gates |
// Typed message protocol โ compile-time safe
enum SwarmMessage {
Task { task_id, description, context, payload },
Result { task_id, content, payload },
StatusUpdate { task_id, status },
Broadcast { topic, content }, // pub/sub via topic registry
Error { task_id, error },
}- Pub/Sub topics โ agents subscribe to named topics;
Swarm::publish(topic, msg)fans out - Timeout protection โ every agent processing step has a 30-second hard timeout
- Blackboard pattern โ
SharedBlackboard(DashMap) for shared state without message passing - Persistence โ
SwarmPersistersaves task graphs and results to SQLite for crash recovery
crablet/
โโโ src/
โ โโโ main.rs # Entry point + CLI command dispatch
โ โโโ cognitive/ # โ
Cognitive core
โ โ โโโ router.rs # Meta-router: classifies & dispatches to S1/S2/S3
โ โ โโโ system1.rs # Intuitive layer (Trie + Levenshtein)
โ โ โโโ system2/
โ โ โ โโโ mod.rs # Deep reasoning orchestration
โ โ โ โโโ canvas.rs # Canvas artifact auto-detection
โ โ โ โโโ multimodal.rs # Vision + audio integration
โ โ โ โโโ post_process.rs # Response post-processing
โ โ โโโ system3.rs # Swarm routing
โ โ โโโ react.rs # ReAct ThoughtโActionโObservation loop
โ โ โโโ tot.rs # Tree of Thoughts
โ โ โโโ mcts_tot.rs # MCTS + UCB1 thought exploration
โ โ โโโ streaming_pipeline.rs # SSE streaming output
โ โ โโโ llm/
โ โ โ โโโ mod.rs # LlmClient trait + OpenAI/Ollama/DashScope/Kimi/ZhiPu
โ โ โ โโโ cache.rs # Semantic response cache (Moka LRU)
โ โ โโโ middleware/
โ โ โ โโโ safety.rs # Safety oracle injection
โ โ โ โโโ cost_guard.rs # Token budget enforcement
โ โ โ โโโ semantic_cache.rs # Query deduplication
โ โ โ โโโ planning.rs # Goal decomposition
โ โ โ โโโ rag.rs # RAG context injection
โ โ โ โโโ skill_context.rs # Skill metadata injection
โ โ โโโ multimodal/ # Image + audio processing
โ โโโ memory/ # โ
Memory system
โ โ โโโ working.rs # Token-budgeted in-memory context
โ โ โโโ episodic.rs # SQLite session & message persistence
โ โ โโโ semantic.rs # Knowledge graph (SQLite + Neo4j)
โ โ โโโ consolidator.rs # Background LLM summarization loop
โ โ โโโ manager.rs # Unified memory access interface
โ โ โโโ shared.rs # SharedBlackboard for swarm agents
โ โโโ knowledge/ # โ
RAG engine
โ โ โโโ vector_store.rs # fastembed + SQLite/Qdrant vector store
โ โ โโโ graph_rag.rs # GraphRAG: vector + KG hybrid retrieval
โ โ โโโ graph.rs # Knowledge graph CRUD
โ โ โโโ chunking.rs # Recursive + Markdown chunkers
โ โ โโโ reranking.rs # Graph-signal reranker
โ โ โโโ extractor.rs # Document text extraction
โ โ โโโ pdf.rs # PDF parsing
โ โ โโโ ingestion.rs # Batch document ingestion pipeline
โ โ โโโ multimodal.rs # Image/audio knowledge extraction
โ โโโ gateway/ # โ
API Gateway (Axum)
โ โ โโโ server.rs # HTTP + WebSocket server setup
โ โ โโโ websocket.rs # Real-time WebSocket handler
โ โ โโโ canvas.rs # Canvas component types
โ โ โโโ canvas_manager.rs # Per-session canvas state management
โ โ โโโ rpc.rs # JSON-RPC 2.0 dispatcher
โ โ โโโ session.rs # Session lifecycle management
โ โ โโโ ratelimit.rs # Token bucket rate limiting (governor)
โ โ โโโ events.rs # SSE event streaming
โ โโโ agent/ # โ
Agent roles
โ โ โโโ swarm.rs # Swarm orchestrator + channel mesh
โ โ โโโ coordinator.rs # Multi-agent task coordinator
โ โ โโโ factory.rs # Agent instantiation registry
โ โ โโโ voting.rs # Consensus voting mechanism
โ โ โโโ debate.rs # Multi-round debate moderator
โ โ โโโ hitl.rs # Human-in-the-loop approval
โ โ โโโ researcher.rs # Research specialist
โ โ โโโ coder.rs # Code generation specialist
โ โ โโโ analyst.rs # Data analysis specialist
โ โ โโโ reviewer.rs # Review & critique specialist
โ โ โโโ planning.rs # Planning & decomposition
โ โโโ tools/ # Tool implementations
โ โ โโโ bash.rs # Shell execution (SafetyOracle filtered)
โ โ โโโ file.rs # File read/write/list
โ โ โโโ search.rs # Web search (Serper / DuckDuckGo)
โ โ โโโ http.rs # HTTP client tool
โ โ โโโ vision.rs # Image analysis
โ โ โโโ browser.rs # Chromium browser automation
โ โ โโโ mcp.rs # MCP protocol tool bridge
โ โโโ skills/ # Plugin/skill management
โ โ โโโ registry.rs # Skill discovery and registration
โ โ โโโ executor.rs # YAML/Python/Node.js skill runner
โ โ โโโ installer.rs # Git-based skill installation
โ โ โโโ openclaw.rs # SKILL.md prompt-based skills
โ โ โโโ watcher.rs # Hot-reload skill file watcher
โ โโโ channels/ # Input channel adapters
โ โ โโโ cli/ # Interactive CLI + subcommands
โ โ โโโ domestic/
โ โ โ โโโ dingtalk.rs # DingTalk integration
โ โ โ โโโ feishu.rs # Feishu/Lark integration
โ โ โโโ international/
โ โ โ โโโ telegram.rs # Telegram Bot
โ โ โโโ discord.rs # Discord Gateway
โ โ โโโ universal/
โ โ โโโ http_webhook.rs # Generic HTTP webhook
โ โโโ auth/ # Authentication & authorization
โ โ โโโ oidc.rs # OpenID Connect / OAuth2 flow
โ โ โโโ handlers.rs # Login/callback HTTP handlers
โ โ โโโ middleware.rs # JWT validation middleware
โ โโโ safety/ # Safety layer
โ โ โโโ oracle.rs # Command allowlist/blocklist
โ โ โโโ mod.rs # Safety level config (Strict/Permissive/Disabled)
โ โโโ sandbox/ # Execution sandboxing
โ โ โโโ docker.rs # Docker container isolation
โ โ โโโ local.rs # Process-level sandboxing
โ โโโ scripting/ # Lua 5.4 scripting engine
โ โ โโโ engine.rs # mlua runtime integration
โ โ โโโ bindings.rs # Rust โ Lua API bindings
โ โโโ audit/ # Security audit agent
โ โโโ protocols/
โ โ โโโ a2a.rs # Agent-to-Agent protocol
โ โโโ telemetry.rs # OpenTelemetry tracing + metrics
โโโ frontend/ # Web UI (TypeScript + React + TailwindCSS)
โโโ skills/ # Built-in skill definitions (SKILL.md)
โ โโโ create_skills/
โ โโโ find_skills/
โ โโโ proactive_agent/
โ โโโ safe_run/
โโโ mcp_servers/ # Example MCP server scripts
โ โโโ math_server.py
โ โโโ mcp_test_server.py
โโโ migrations/ # SQLite migration files
โโโ config/config.toml # Default configuration
โโโ templates/index.html # Web UI HTML template
โโโ tests/ # Integration & unit tests (25+ test files)
โโโ Cargo.toml
โโโ Dockerfile
โโโ docker-compose.yml
โโโ Justfile
Crablet supports a wide range of LLM backends through a unified LlmClient trait:
| Provider | Authentication | Streaming | Tool Calls | Notes |
|---|---|---|---|---|
| OpenAI | OPENAI_API_KEY |
โ SSE | โ Function Calling | gpt-5.2, gpt-5.3, etc. |
| DashScope (Qwen) | DASHSCOPE_API_KEY |
โ | โ | OpenAI-compatible endpoint |
| Ollama | Local | โ | โ | qwen2.5:14b default |
| Kimi (Moonshot) | MOONSHOT_API_KEY |
โ | โ | Long-context specialist |
| ZhiPu (GLM) | ZHIPU_API_KEY |
โ | โ | Chinese-optimized |
| Any OpenAI-compat | OPENAI_API_BASE |
โ | โ | Custom base URL |
- Rust 1.80+ โ install via rustup
- Docker (optional โ for Neo4j and sandbox execution)
- Git
# 1. Clone
git clone https://github.com/isLinXu/crablet.git
cd crablet
# 2. Configure model settings anytime
./settings.sh
# Optional: non-interactive or skip model connectivity check
./settings.sh --non-interactive
./settings.sh --skip-verify
# 3. Install and start in one command
./one-click.shCommon maintenance commands:
# Check service status
crablet status
# Deep clean build artifacts and cache (free up space)
./clean.sh
# Manual build and install CLI
./install.sh
# Show current configuration
crablet config
# Manage scheduled tasks
crablet task list
# Manage workflows
crablet workflow list
# Start services in debug mode (detailed logs)
./debug.sh
# Full uninstall
./uninstall.sh --full# 1. Clone
git clone https://github.com/isLinXu/crablet.git
cd crablet
# 2. Fast build โ CLI + Web only (~5 min)
cargo build --release --no-default-features --features web
# 3. Full build โ all features (~15-20 min)
cargo build --release
# 4. Initialize config & database
./target/release/crablet init
# 5. Set your LLM API key
export OPENAI_API_KEY=sk-xxx
# or for DashScope/Qwen:
export DASHSCOPE_API_KEY=sk-xxx
export OPENAI_API_BASE=https://dashscope.aliyuncs.com/compatible-mode/v1
# 6. Start chatting
./target/release/crablet chat๐ก Speed tip: Install sccache to cache Rust compilation artifacts across builds:
cargo install sccache export RUSTC_WRAPPER=sccache
# Set your API key
export OPENAI_API_KEY=sk-xxx
# Launch Crablet + Neo4j
docker-compose up -d
# Open Web UI
open http://localhost:3000docker run -d \
--name crablet \
-p 3000:3000 \
-p 18789:18789 \
-e OPENAI_API_KEY=sk-xxx \
-v ./data:/data \
-v ./skills:/skills \
crablet:latestDouble-click to launch โ no terminal, no Docker, no dev environment needed.
# 1. Clone & build sidecar
git clone https://github.com/isLinXu/crablet.git
cd crablet
just desktop-sidecar # or: cargo build --release -p crablet --no-default-features --features web
# 2. Copy sidecar binary
just desktop-sidecar-copy # copies to desktop/binaries/
# 3. Build desktop app
just desktop-dmg # macOS: generates .dmg in target/release/bundle/dmg/
just desktop-build # macOS: generates .app only
# Or use the shell script directly:
./desktop/build-desktop.shFirst launch: The app opens a splash screen where you can paste your OpenAI / DashScope API key. The key is saved to your system keychain โ no env vars needed.
How it works: The Tauri shell launches crablet serve-web --port 18799 as a sidecar process, waits for it to become ready, then navigates to the built-in Web UI. Closing the window gracefully terminates the sidecar.
๐ฆ Pre-built releases: Download DMG / EXE from GitHub Releases (tag-triggered CI builds).
# Interactive multi-turn chat
crablet chat
# Single task execution
crablet run "Analyze this Rust code for performance bottlenecks"
# Unified Web UI + API gateway
crablet serve-web --port 18790
# Explicit gateway launch (same unified control plane)
crablet gateway --port 18790
# Vision / multimodal
crablet vision --image ./screenshot.png --query "Describe this diagram"
# Audio transcription
crablet audio --file meeting.wav
# Skill management
crablet skill list
crablet skill install https://github.com/user/my-skill.git
crablet skill create my-new-skill
# Knowledge base
crablet knowledge extract --file document.pdf
crablet knowledge extract --file notes.md
crablet knowledge query "How does GraphRAG work?"
# Security audit
crablet audit .
crablet audit ./src --format json # CI/CD-friendly JSON output
# System status
crablet status
# Lua scripting
crablet script run examples/scripts/summarize_paper.lua
# Debug / introspection
crablet debug --show-memory
crablet debug --show-graphCrablet provides four complementary extension mechanisms:
name: weather
description: Get current weather for a city using OpenMeteo API
version: 1.0.0
parameters:
type: object
properties:
city:
type: string
description: The city to get weather for
required: [city]
entrypoint: python3 weather.py
timeout: 10
env:
API_KEY: ${OPENMETEO_API_KEY}---
name: python-expert
description: Expert Python coding assistant
version: 1.0.0
---
You are a Python expert. Always use type hints and docstrings.
When writing code, follow PEP 8 conventions.# config.toml
[mcp_servers]
math_server = { command = "python3", args = ["mcp_servers/math_server.py"] }
custom_tools = { command = "node", args = ["./my-mcp-server/index.js"] }| Tool | Description | Safety |
|---|---|---|
bash |
Shell command execution | SafetyOracle allowlist |
file |
Read / Write / List files | Path sandboxing |
web_search |
Web search (Serper / DuckDuckGo) | Safe |
http |
Arbitrary HTTP requests | Safe |
vision |
Image understanding (multimodal LLM) | Safe |
browser |
Chromium browser automation | Docker sandbox |
calculator |
Math expression evaluation | Safe |
weather |
Weather API | Safe |
Config file location: ~/.config/crablet/config.toml
# Database
database_url = "sqlite:crablet.db?mode=rwc"
# LLM settings
model_name = "gpt-4o-mini"
max_tokens = 4096
temperature = 0.7
# Logging
log_level = "info" # trace | debug | info | warn | error
# Safety
[safety]
level = "Strict" # Strict | Permissive | Disabled
allowed_commands = ["ls", "cat", "echo", "pwd"]
blocked_commands = ["rm", "mv", "sudo", "chmod"]
# MCP servers
[mcp_servers]
math_server = { command = "python3", args = ["mcp_servers/math_server.py"] }
# GraphRAG entity extraction mode
# GRAPH_RAG_ENTITY_MODE = "rule" | "phrase" | "hybrid" (default)
# Concurrency limits
[limits]
max_concurrent_requests = 100
request_timeout = 30
# OIDC / OAuth2 (optional)
oidc_issuer = "https://your-tenant.auth0.com/"
oidc_client_id = "your-client-id"
oidc_client_secret = "your-client-secret"
jwt_secret = "your-app-secret"
# Observability
[telemetry]
enabled = true
endpoint = "http://tempo:4317"| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key |
DASHSCOPE_API_KEY |
Alibaba DashScope (Qwen) API key |
OPENAI_API_BASE |
Custom OpenAI-compatible base URL |
OLLAMA_MODEL |
Local Ollama model name (default: qwen2.5:14b) |
OLLAMA_API_BASE |
Ollama server URL (default: http://localhost:11434) |
MOONSHOT_API_KEY |
Kimi (Moonshot AI) API key |
ZHIPU_API_KEY |
ZhiPu GLM API key |
SERPER_API_KEY |
Serper web search API key |
DATABASE_URL |
SQLite or PostgreSQL connection string |
QDRANT_URL |
Qdrant vector database URL |
RUST_LOG |
Log level (info, debug, trace) |
GRAPH_RAG_ENTITY_MODE |
Entity extraction mode: rule / phrase / hybrid |
cargo build --release --no-default-features --features <flags>| Feature Flag | Description | Default |
|---|---|---|
web |
Axum HTTP server + Web UI + REST API | โ |
qdrant-support |
Qdrant vector database backend | โ |
knowledge |
Full RAG: fastembed + PDF + Neo4j + Qdrant | โ
(with knowledge) |
audio |
Whisper speech-to-text | โ |
scripting |
Lua 5.4 scripting engine (mlua) | โ |
telemetry |
OpenTelemetry distributed tracing | โ |
sandbox |
Docker container isolation (bollard) | โ |
telegram |
Telegram Bot integration | โ |
discord |
Discord Gateway integration | โ |
browser |
Chromium browser automation | โ |
inference |
ONNX Runtime (local model inference) | โ |
full |
All features enabled | โ |
Endpoint: ws://localhost:18789/ws
Send a message:
{
"type": "UserInput",
"content": "Write a Rust async function that reads a file"
}Receive streaming events:
| Event Type | Description |
|---|---|
ThoughtGenerated |
ReAct reasoning step (System 2 thinking) |
ToolExecutionStarted |
Tool invocation initiated |
ToolExecutionFinished |
Tool result received |
ResponseGenerated |
Final agent response |
CanvasUpdate |
New canvas artifact (type: mermaid / code / html / markdown) |
SwarmActivity |
Inter-agent message in the swarm |
MemoryConsolidated |
Background memory consolidation completed |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/chat |
Single-turn chat completion |
GET |
/api/status |
System health & stats |
GET |
/api/dashboard |
Monitoring dashboard data |
GET |
/api/knowledge |
List knowledge base documents |
DELETE |
/api/knowledge?source=... |
Delete knowledge document |
GET |
/api/canvas/:session_id |
Get canvas state for session |
GET |
/auth/login |
Initiate OIDC login flow |
GET |
/auth/callback |
OIDC callback handler |
GET |
/api/me |
Current authenticated user |
version: '3.8'
services:
crablet:
image: crablet:latest
ports:
- "3000:3000" # Web UI
- "18789:18789" # WebSocket Gateway
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY}
- DATABASE_URL=sqlite:///data/crablet.db
- RUST_LOG=info
volumes:
- ./data:/data
- ./skills:/skills
depends_on:
- neo4j
neo4j:
image: neo4j:5
ports:
- "7474:7474" # Neo4j Web UI
- "7687:7687" # Bolt protocol
environment:
- NEO4J_AUTH=neo4j/password
volumes:
- neo4j_data:/data
volumes:
neo4j_data:# config.toml (production)
database_url = "postgresql://user:pass@localhost/crablet"
log_level = "warn"
[safety]
level = "Strict"
[telemetry]
enabled = true
endpoint = "http://otel-collector:4317"
[limits]
max_concurrent_requests = 100
request_timeout = 30Crablet exports OpenTelemetry telemetry compatible with the full CNCF observability stack:
| Component | Integration |
|---|---|
| Distributed Tracing | Jaeger / Tempo |
| Metrics | Prometheus (crablet.request.duration, crablet.llm.tokens) |
| Dashboards | Grafana |
| Log aggregation | Loki / any OTLP-compatible backend |
The project includes 25+ test files covering:
# Unit & integration tests
cargo test
# Specific test suites
cargo test memory_test
cargo test vector_store_integration_test
cargo test react_chain_test
cargo test system1_verify
cargo test safety_test
cargo test graph_rag_returns_augmented_context
# End-to-end tests
cargo test e2e_full
cargo test e2e_auth_audit
# Demo tests (run specific agent scenarios)
cargo test demo_debate
cargo test demo_voting
cargo test demo_rag| Document | Description |
|---|---|
| Getting Started | Installation, first run, and basic usage |
| Architecture | Deep dive into the cognitive architecture |
| API Reference | CLI, REST API, WebSocket, and JSON-RPC |
| Configuration | All config options and environment variables |
| Deployment | Docker, production setup, and observability |
| Skill Development | Writing custom skills and MCP servers |
| Contributing | How to contribute to the project |
| Roadmap | Upcoming features and milestones |
- Three-tier cognitive architecture (System 1 / 2 / 3)
- Layered memory: Working โ Episodic โ Semantic + LLM Consolidation
- GraphRAG: vector store + knowledge graph hybrid retrieval
- Canvas: live artifact rendering (Mermaid, Code, HTML, DataTable)
- Multi-agent Swarm with VotingAgent, DebateModerator, HITL
- MCTS-based Tree of Thoughts reasoning
- OIDC/OAuth2 authentication (Auth0, Google, Keycloak)
- REST + WebSocket + JSON-RPC gateway
- Plugin ecosystem (YAML skills, SKILL.md, MCP protocol)
- Security Audit Agent
- Multi-channel: CLI, Telegram, DingTalk, Feishu, Discord, HTTP Webhook
- OpenTelemetry tracing + Prometheus metrics
- Docker + Docker Compose deployment
- High-performance gateway rewrite โ Axum-native, 3-5x throughput improvement
- 20+ messaging channels โ WeChat Work, Slack, WhatsApp, Microsoft Teams, QQ
- Agent Coordinator V2 โ Dynamic role assignment, context isolation, sub-agent spawning
- Canvas Editor โ Interactive canvas with Monaco code editor + Mermaid live preview
- Approval workflow โ
crablet approve <code>human-in-the-loop API - One-line installer โ
curl -fsSL https://crablet.dev/install.sh | sh
- Multi-tenancy โ RBAC, org isolation, SSO (LDAP/OAuth2), GDPR compliance
- Function Calling V2 โ Parallel tool execution (
ParallelToolExecution) - Long context management โ 128K+ token compression + summarization
- Procedural Memory โ Skill learning from successful task execution
- Cron scheduler โ Time-based and event-triggered task automation
- Cost analytics dashboard โ Per-model, per-user token cost tracking
- Crablet Skill Store โ
crablet skill install/search/publishmarketplace - Crablet Cloud โ Multi-tenant SaaS hosting with autoscaling
Contributions of all kinds are welcome! Please read CONTRIBUTING.md first.
# Fork & clone
git clone https://github.com/your-username/crablet.git
cd crablet
# Create a feature branch
git checkout -b feature/amazing-feature
# Make changes, add tests
cargo test
# Commit with conventional commits
git commit -m "feat(memory): add memory decay scoring for old summaries"
# Push and open a PR
git push origin feature/amazing-feature- Rust style:
cargo fmt+cargo clippybefore committing - Tests required: All new features must include integration tests
- Feature flags: New optional dependencies must be feature-gated
- Safety first: New tools must go through
SafetyOracle - No blocking: All I/O must use
tokio::spawn_blockingor async APIs
This project is licensed under the MIT License โ see LICENSE for details.
If Crablet helps you build something awesome, please give it a โญ Star!
Built with ๐ฆ Rust and โค๏ธ by isLinXu and contributors
Crablet โ because good AI infrastructure should be as reliable as a crab's shell,
and as fast as it scuttles sideways.