Runtime struct is the main entry point for the OneClaw Core Runtime. It owns all layer implementations (Security, Orchestrator, Memory, Event Bus, Tools) and manages the main event loop.
Struct Definition
Fields
The active configuration loaded from TOML or defaults
The security core implementation (Layer 0) - handles authorization, device pairing, and access control
The model router for LLM provider selection (Layer 1)
The context manager for prompt enrichment (Layer 1)
The chain executor for multi-step pipelines (Layer 1)
The memory backend implementation (Layer 2) - SQLite or NoopMemory
The event bus implementation (Layer 3) - for event-driven operations
Tool registry (Layer 4) - manages all registered tools available to the agent
Operational metrics with AtomicU64 counters for monitoring
Shutdown flag - set by signal handler or “exit” command to gracefully stop the event loop
v1.5 sync Provider for LLM calls (None = offline/no API key)
Embedding provider for vector search (None = disabled, FTS only)
Constructor Methods
with_defaults
Create runtime with all Noop implementations (for testing or bare boot).Configuration struct with runtime settings
A new Runtime instance with Noop trait implementations
with_security
Create runtime with DefaultSecurity (production mode). Other layers remain Noop until configured.Configuration struct with runtime settings
Workspace directory path for security constraints
A new Runtime instance with DefaultSecurity enabled
from_config
Create runtime from config using Registry to resolve all traits based on configuration.Configuration struct - determines which implementations to use
Workspace directory path
A new Runtime instance with all traits resolved from config, or an error if resolution fails
Key Methods
boot
Boot the runtime and initialize all 5 layers.Ok if all layers initialized successfully, otherwise an error
run
Run the main event loop with a single channel. Receives messages, processes through security + pipeline, and responds.The communication channel to receive/send messages (e.g., CLI, Telegram, MQTT)
Ok when loop exits gracefully, error if channel fails critically
run_multi
Run the main event loop with multiple channels via ChannelManager. Polls all channels round-robin.Channel manager containing multiple active channels
Ok when loop exits gracefully, error if manager fails critically
run_chain
Run a chain with the current runtime context (provider, memory, event bus, tools).The chain definition to execute
Input text to pass to the first chain step
Chain execution result with output and metadata, or error
with_async_event_bus
Replace the event bus with an AsyncEventBus for realtime events (opt-in for sub-10ms latency).Broadcast channel capacity (e.g., 256)
The broadcast sender - use
sender.subscribe() to create receiversBuilt-in Commands
The runtime processes these commands internally:help- Show all available commandsstatus- Show agent status, uptime, and layer informationmetrics- Show operational metrics (counters, latency)health- Health check all 5 layerspair- Generate device pairing codeverify CODE- Pair device with 6-digit codedevices- List all paired devicesunpair ID- Remove a paired devicetools- List registered toolstool X k=v- Execute tool X with parameterschannels- List active channelsevents- Show event bus status and recent eventsproviders- List LLM providers and statusremember X- Store X in memoryrecall X- Search memory for Xask Q- Ask AI a questionreload- Check config file for changes (report only)exit/quit/q- Shut down the agent
Security Model
Onlyexit, help, pair, and verify are always-open commands. All other commands require security authorization first. The runtime checks:
- Rate limiting - Default 60 requests/minute
- Device pairing - Device must be paired via
pair+verify - Per-command authorization - Each command checks ActionKind + resource