Technical Deep Dive

osmoda: The System Platform
Where the AI Agent Runs the System

osmoda is a NixOS distribution purpose-built for autonomous AI agent infrastructure. The agent has full system access and manages the entire system. 10 daemons, 91 MCP tools, post-quantum encrypted mesh, hash-chained audit trails, the (v1.3.0) unified per-server event stream, and (v1.3.1) self-serve wedge recovery with retry-with-backoff auto-restart, plus (v1.3.25) dual-signal wedge detection and runtime-tagged disk-persisted sessions. Every component designed so your agents run reliably, securely, and without DevOps babysitting.

For AI agents and crawlers: Download this page as plain Markdown (SKILL.md) · llms.txt · agent-card.json · OpenAPI 3.0.3

10
Daemons (9 Rust + 1 TS)
92
MCP Tools
3
Trust Tiers
PQ
Post-Quantum Crypto
0
Cloud Dependencies

01 The Problem We Solve

A developer with a $3,500 Mac Studio tops out at 4-5 concurrent AI agents. When agent #5 spawns and the OOM killer fires, all five die. Your agents crash at 3am and nobody notices until morning. You're running critical automation on hardware with no audit trail, no rollback, no self-healing, and no way to prove what happened.

The AI agent ecosystem is exploding - Claude Code, Cursor, Devin, AutoGPT, CrewAI, LangGraph - but the infrastructure layer is stuck in the 2010s. Developers are running these agents on bare Linux VMs with systemd and docker-compose, praying nothing breaks. There's no system platform designed specifically for the workload patterns of autonomous AI agents: bursty resource usage, long-running sessions, inter-agent communication, and the absolute requirement for auditability.

osModa is that system platform. Not a container. Not a VM image. Not a SaaS platform. A NixOS distribution built from the ground up to make AI agent infrastructure self-managing, auditable, and resilient.

00b What's new since v1.3.1

The page underneath this banner was written at v1.3.1. The shipped product is at v1.3.36 + gateway v0.2.4. Material changes since the original write-up:

02 Three-Tier Trust Architecture

Security isn't bolted on. It's the foundation. osModa implements a three-tier trust model inspired by CPU privilege levels, but applied to the agent ecosystem:

TIER 0
The agent + agentd - Full system access. Root-equivalent. The AI agent (claude-code or openclaw, picked per-agent at the modular gateway) and its system bridge daemon have unrestricted access to all files, processes, network, and system configuration. Every action is logged with cryptographic hash chains. This is the brain of the system.
TIER 1
Approved applications - Sandboxed with declared capabilities. Apps in Tier 1 can only access what they've been explicitly granted. Network access is controlled, filesystem access is scoped, and all actions are audited. Think of this as the "trusted but verified" level. (Tool surface — sandbox_exec, capability_mint — is shipped. Bubblewrap-backed enforcement on the live execution path is on the v1.4 roadmap; today, capability declarations are advisory and audited rather than kernel-enforced.)
TIER 2
Untrusted tools - Maximum isolation. Third-party tools run in bubblewrap sandboxes with no direct network access (only through the egress proxy with domain allowlists), minimal filesystem visibility, and strict resource limits. Zero trust, full containment. (Same caveat: the egress proxy + capability allowlist primitives are live, but bubblewrap is not yet wired into sandbox_exec's default path.)

This isn't theoretical. Every API call, every file mutation, every network request flows through the trust model. The AI agent in Tier 0 can grant capabilities to Tier 1 apps, and Tier 1 apps can invoke Tier 2 tools - but never the reverse. Lower tiers cannot escalate privileges upward by design. Tier 0 remains the trusted computing base and must be governed by approval policies, spending limits, and audit review. NixOS rollback covers system configuration - it does not undo data sent to external APIs, signed transactions, or exposed secrets.

03 The 10 Daemons

osmoda runs 10 specialized daemons (9 in Rust + 1 in TypeScript), each with a single responsibility. Most communicate over Unix domain sockets. No cloud dependencies. The 9 Rust daemons are compiled for memory safety, performance, and zero-garbage-collection pauses. The 10th - osmoda-gateway - is the TypeScript modular agent gateway: it speaks HTTP+WS on a localhost port and routes per-agent to a pluggable runtime driver (claude-code or openclaw), making credentials and models switchable at runtime via the dashboard.

agentd
/run/osmoda/agentd.sock
The system bridge. Gives the AI agent structured access to processes, services, network, filesystem, NixOS config, sysctl parameters, users, and firewall. Append-only hash-chained event log in SQLite. Memory system with FTS5 keyword search. Agent Card identity (EIP-8004).
osmoda-keyd
/run/osmoda/keyd.sock
OS-native crypto wallet daemon. AES-256-GCM encrypted keys, policy-gated signing with daily limits, ETH + SOL wallets. Runs with PrivateNetwork=true - zero network access. Keys never leave the daemon. Pluggable SignerBackend for future MPC/HSM integration.
osmoda-watch
/run/osmoda/watch.sock
SafeSwitch deployment engine + autopilot watchers. Deploy with timer + health gates + automatic rollback if anything fails. Deterministic health checks with escalation: restart → rollback → notify. The self-healing core.
osmoda-routines
/run/osmoda/routines.sock
Background cron/event/webhook automation engine. Runs scheduled tasks between agent conversations - health checks, service monitors, log scans, resource forecasting. Keeps the system alive even when no human is looking.
osmoda-mesh
/run/osmoda/mesh.sock + TCP :18800
P2P encrypted agent-to-agent communication. Noise_XX key exchange + X25519 + ML-KEM-768 hybrid post-quantum encryption. No central server. Invite-based pairing. Ed25519 identity signatures. Direct messages, group rooms, presence.
osmoda-mcpd
/run/osmoda/mcpd.sock
MCP (Model Context Protocol) server manager. Start, monitor, restart, and configure MCP servers as OS capabilities. Any MCP server becomes a first-class system tool via NixOS config. Hot-reload without downtime.
osmoda-teachd
/run/osmoda/teachd.sock
System learning and self-optimization daemon. Learns from operational patterns - which services fail, when load spikes, what configurations drift. Generates optimization recommendations and auto-applies approved improvements over time.
osmoda-voice
/run/osmoda/voice.sock
Local speech-to-text (whisper.cpp) + text-to-speech (piper). All processing on-device. No cloud APIs. No data leaves the machine. Voice control your infrastructure with zero privacy compromise.
osmoda-egress
localhost HTTP CONNECT proxy
The only path to the internet for sandboxed tools. Domain allowlist per capability token. If a tool isn't explicitly allowed to reach a domain, the connection is refused. Network isolation enforced at the OS level.
osmoda-gateway
127.0.0.1:18789 (HTTP + WS)
The modular agent gateway. Routes each agent (osmoda, mobile, ...) to a pluggable runtime driver - claude-code (Anthropic OAuth or API key) or openclaw (BYOK). Hot-reloadable via SIGHUP; in-flight chat sessions keep their snapshot, zero WebSocket drops. Encrypted credential store. Adding a driver = one file in src/drivers.

04 91 MCP Tools

The AI agent doesn't shell out to run commands. It uses 92 structured, typed, audited MCP tools registered via the osmoda-bridge plugin (and consumed identically by the claude-code runtime via stdio). Every tool call is logged with the hash-chained event ledger. Every result is traceable. Here's what the agent can do:

System Operations

system_health - CPU, RAM, disk, load, uptime in one call. system_query - Query processes, services, ports, connections, NixOS generations. system_discover - Auto-detect all running services, listening ports, and systemd units. event_log - Browse the hash-chained audit trail with filters. shell_exec - Execute commands with full audit logging. file_read, file_write, directory_list - Filesystem operations with access control.

Memory & Intelligence

memory_store - Persist knowledge with categories and tags. memory_recall - FTS5 keyword search across all stored knowledge. The memory system uses SQLite FTS5 with Porter stemming for keyword search. Markdown files in /var/lib/osmoda/memory/ are ground truth. Vector search (ZVEC + nomic-embed) is planned for a future release.

Deployment & Self-Healing

safe_switch_begin, safe_switch_commit, safe_switch_rollback - Atomic deployments with health gates. Begin a deployment, run health checks, commit if everything passes, auto-rollback if anything fails. safety_rollback, safety_panic, safety_restart - Emergency controls for when things go wrong. watcher_add, watcher_list - Define autopilot health checks that run continuously in the background. routine_add, routine_trigger - Schedule cron jobs, event hooks, and webhook handlers.

Crypto Wallets

wallet_create, wallet_list, wallet_sign, wallet_send, wallet_delete, wallet_receipt - Full wallet lifecycle. Create ETH/SOL wallets, sign transactions with policy gates (daily limits, address allowlists), and generate audit receipts. Keys are AES-256-GCM encrypted and never leave the keyd daemon.

P2P Mesh Networking

mesh_identity, mesh_invite_create, mesh_invite_accept, mesh_peers - Establish encrypted peer-to-peer connections between osModa nodes. mesh_peer_send, mesh_room_create, mesh_room_join, mesh_room_send, mesh_room_history - Direct messages and group communication channels. mesh_health, mesh_peer_disconnect - Monitor and manage the mesh topology. All traffic encrypted with Noise_XX + ML-KEM-768 hybrid post-quantum cryptography.

MCP Server Management

mcp_servers, mcp_server_start, mcp_server_stop, mcp_server_restart - Manage any MCP server as a first-class OS capability. The mcpd daemon handles lifecycle, health monitoring, and auto-restart. Add MCP servers via NixOS config and they become available to the agent instantly.

Code Intelligence (CodeGraph)

codegraph_search, codegraph_context, codegraph_callers, codegraph_callees, codegraph_impact, codegraph_node, codegraph_explore, codegraph_files, codegraph_status - A pre-indexed code knowledge graph (tree-sitter AST → SQLite, 100% local, 19+ languages). The agent queries symbol relationships, call graphs, and change blast-radius instantly instead of grep-spraying — ~90% fewer tool calls on code tasks. Auto-indexed across the OS's own source (/opt/osmoda), spec-kit projects (/workspace/*), and deployed apps (/srv/*), kept synced every 30 min. Your agent knows your code's structure before it reads a single file.

Voice Control

voice_status, voice_speak, voice_transcribe, voice_record, voice_listen - Talk to your server. All processing happens locally via whisper.cpp (STT) and piper (TTS). No audio data ever leaves the machine. Zero cloud dependency.

05 Hash-Chained Audit Trail

Every mutation in osModa is logged to an append-only SQLite event log with cryptographic hash chains. Each event includes a SHA-256 hash computed from the event ID, timestamp, type, actor, payload, and previous event hash. This creates a tamper-evident chain - if any event is modified or deleted, the hash chain breaks and the tampering is immediately detectable.

-- Event log schema CREATE TABLE events ( id INTEGER PRIMARY KEY AUTOINCREMENT, ts TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')), type TEXT NOT NULL, actor TEXT NOT NULL, payload TEXT NOT NULL, prev_hash TEXT NOT NULL, hash TEXT NOT NULL ); -- hash = SHA-256(id|ts|type|actor|payload|prev_hash)

This isn't just logging. It's cryptographic proof of everything your system has done. The tamper-evident audit trail provides supporting infrastructure useful for compliance-oriented environments (SOC 2, HIPAA) - though the ledger alone does not constitute regulatory readiness. For incident forensics, for understanding exactly what happened at 3am when an agent made a decision. The hash chain can be independently verified with the agentctl verify-ledger command - no trust required, pure math.

06 NixOS: Atomic, Reproducible, Rollbackable

osModa is built on NixOS, the only Linux distribution with truly atomic system configuration. Every system state is a "generation" - a complete, immutable snapshot of the entire OS configuration. Rolling back to any previous state takes less than a second.

This means: a bad configuration change doesn't brick your server. A failed software update doesn't leave your system in an inconsistent state. The AI agent can make system changes with confidence, because every change is reversible. The SafeSwitch daemon (osmoda-watch) integrates directly with NixOS generations - deploy a change, run health checks, and auto-rollback if anything fails.

NixOS also means reproducibility. The exact same system configuration produces the exact same system state on every machine, every time. No more "works on my machine" for infrastructure. If it works on one osModa node, it works on all of them.

07 Post-Quantum Encrypted Mesh

osModa nodes communicate via a peer-to-peer encrypted mesh network. No central server. No cloud relay. Direct connections between nodes using the Noise_XX handshake protocol with X25519 key exchange, ChaCha20-Poly1305 symmetric encryption, and BLAKE2s hashing.

But we go further: ML-KEM-768 hybrid post-quantum key encapsulation is layered on top of the Noise handshake. Even if a quantum computer breaks the X25519 key exchange in the future, the ML-KEM-768 layer ensures your historical traffic remains confidential. This is defense-in-depth for the post-quantum era.

Pairing is invite-based: one node creates an invite code, another accepts it. No discovery protocol that could leak your network topology. No DNS. No central registry. Each node has an Ed25519 identity key for signing and an X25519 key for encryption, plus the ML-KEM-768 key for post-quantum protection.

Use cases: multi-server agent fleets that coordinate via encrypted mesh. Edge devices reporting to a central node. Distributed agent swarms that communicate without any internet dependency.

08 Self-Healing Infrastructure

The core promise of osModa: your server fixes itself at 3am so you don't have to.

The self-healing loop works at three levels:

Level 1 - Autopilot Watchers (osmoda-watch): Deterministic health checks that run continuously. CPU above 90% for 5 minutes? Restart the heaviest process. Disk above 85%? Clean Nix store garbage. Service crashed? Restart it. If restart fails, escalate.

Level 2 - SafeSwitch Deployments (osmoda-watch): Every system change goes through the SafeSwitch engine. Apply the change, run health gates (HTTP checks, port checks, process checks), and auto-rollback to the previous NixOS generation if any gate fails. Zero-downtime deployments with guaranteed rollback.

Level 3 - Agent Intelligence (agentd + teachd): The AI agent analyzes patterns across the event log, memory system, and operational data. It doesn't just react to failures - it predicts them. Disk usage trending toward 100%? The agent schedules cleanup before you run out of space. A service crashes every Tuesday at 3am? The agent investigates the root cause and proposes a fix.

All three levels are logged to the hash-chained audit trail. You can see exactly what the system did, when it did it, and why - down to the millisecond.

09 20 System Skills

Beyond the 91 tools, osmoda ships with 20 pre-built skills - structured workflows that combine multiple tools into higher-level capabilities. Each skill is a markdown file under skills/<name>/SKILL.md with YAML frontmatter; the agent invokes one when its description matches the user's intent.

Operational

self-healing - detect failures → diagnose → auto-fix · morning-briefing - daily infra health digest · security-hardening - continuous scoring + auto-remediation · natural-language-config - "enable Postgres on port 5433 with 2GB shared buffers" turns into a NixOS PR · predictive-resources - forecasts exhaustion before it happens · drift-detection - finds imperative changes that left declarative config · generation-timeline - time-travel debugging across NixOS generations · flight-recorder - black-box telemetry for post-incident analysis · nix-optimizer - reclaims store disk space safely.

Surfaces

system-monitor · system-packages · system-config · file-manager · network-manager · service-explorer - every system admin surface, fronted by AI.

Application + agent deployment

app-deployer - deploy + manage user apps as systemd units (app_deploy, app_logs, app_remove). deploy-ai-agent - deploy LangChain / CrewAI / AutoGen / Dify workloads onto the same machine, sharing memory and audit ledger.

Multi-perspective analysis (swarm)

swarm-predict - multi-perspective risk analysis via persona debate. Same prompt, 5-9 distinct personas, scored convergence. scaled-swarm-predict - 50-200 simulated agents on a synthetic Twitter/Reddit topology, useful for product launch + content reception forecasting.

teachd's SKILLGEN loop (see § 4b) auto-generates new SKILL.md files when it detects the agent repeating the same tool sequence across sessions. The skill catalog grows as the system learns your patterns.

4b Self-Learning (TeachD)

The osmoda-teachd daemon turns operational data into knowledge and new skills. Three loops run continuously, each at a different cadence:

LoopCadenceWhat it does
OBSERVE30 sSample CPU, memory, services, journal lines, agent tool calls. Persists raw observations to SQLite.
LEARN5 minMine observations for recurring failures, resource trends, anomalies, correlations. Promotes high-confidence patterns into KnowledgeDocs.
SKILLGEN6 hDetect repeated tool sequences across sessions. Above a threshold, auto-generate a SKILL.md candidate, surface to human for promotion.

The TEACH API (POST /teach) injects context-relevant KnowledgeDocs into agent prompts at runtime - so when the agent picks up a problem similar to one it solved last week, it remembers what worked. The Optimizer proposes system-level optimizations (NixOS config tweaks, sysctl knobs, service tunings) which the operator promotes through SafeSwitch with full rollback.

Endpoints (Unix socket /run/osmoda/teachd.sock): /observations, /patterns, /knowledge, /teach, /optimize/suggest, /optimize/apply, /skills/candidates, /skills/detect, /skills/generate/{id}, /skills/promote/{id}, /observe/action, /skills/execution, plus 7 read-only views. 19 endpoints total.

4c Spec-Kit (spec-driven dev, every spawn)

From v1.2.2 (2026-04-30), github/spec-kit v0.8.4 is baked into every spawn at install time (uv + specify-cli + 9 speckit-* skills). Each spec-kit project lives under /workspace/<slug>/ with a five-phase lifecycle:

spec-kit project layout:
  /workspace/<slug>/
    ├── .specify/                  spec-kit metadata
    ├── memory/                    project-scoped agent memory
    ├── .claude/                   per-project agent profile
    └── specs/<n-name>/
        ├── spec.md                phase 1 - what + why
        ├── plan.md                phase 2 - tech stack + constraints
        └── tasks.md               phase 3 - work breakdown

Phase progression: scaffolded → constitution → specifying → planning → tasking → implementing → tests-green. The dashboard's Factories tab shows every spec-kit project on a server with its current phase.

MCP tools

spec_kit_init - scaffold a new project from a one-line brief. spec_kit_run - execute a phase command (/speckit-specify, /speckit-plan, /speckit-tasks, /speckit-implement, etc.) inside the project directory, using claude with allowlisted tools. Output streamed back as JSON; full conversation log persisted to .claude/.

Public endpoints

GET /api/v1/spec-kit/projects                              # reseller (osk_), aggregated across orders
GET /api/dashboard/servers/{id}/spec-kit/projects          # dashboard, single server

Both return per-project metadata: slug, current phase, last implement timestamp, spec.md first lines, paths to spec/plan/tasks.md on the source server.

10 Who Is This For

osModa is useful when agents need to operate autonomously on real infrastructure - deploying services, managing configs, signing transactions, recovering from failures - without a human in the loop for every action.

Autonomous agent infrastructure - agents that run 24/7, self-heal, deploy code, and make system-level decisions. Typed tools, not shell scripts. Audit trails, not log files.

Compliance-sensitive operations - hash-chained audit ledger provides tamper-evident logging useful for compliance-oriented environments. A foundation for audit programs, not a turnkey compliance solution.

Offline / edge / air-gapped - P2P encrypted mesh, local voice processing, no cloud dependencies. Nodes operate indefinitely without internet connectivity.

Crypto and financial agents - policy-gated key management (osmoda-keyd), spending limits, address allowlists, every signing operation audited. Keys never leave the daemon.

11 Daemon / Use Case Matrix

Which daemons matter depends on the workload.

Use casePrimary daemonsWhat it gives you
Agent ops (24/7 autonomous)agentd, watch, routinesSelf-healing, background health checks, audit trail
Multi-node coordinationmesh, routines, watchP2P encrypted channels, cross-node monitoring
Safe deployswatch (SafeSwitch)Health-gated deploys, auto-rollback on failure
Audit / complianceagentd (ledger), keydHash-chained logs, policy-gated signing, exportable
Crypto / financialkeyd, agentd, meshAES-256-GCM keys, spending limits, PQ-encrypted mesh
Sandboxed tool executionegress, agentdBubblewrap isolation, domain-filtered network
MCP ecosystemmcpdMCP servers as NixOS-native capabilities
System learningteachdObserve → detect patterns → suggest optimizations
Edge / air-gappedvoice, mesh, allLocal STT/TTS, offline operation, no cloud deps

12 Installation

One command gives your server a brain. The installer handles everything: NixOS conversion, Rust builds, modular osmoda-gateway (claude-code + openclaw drivers), 91 MCP tools, agent identity, and daemon startup.

Quick Install

# Install on any Ubuntu 22.04+, Debian 12+, or existing NixOS box curl -fsSL https://raw.githubusercontent.com/bolivian-peru/os-moda/main/scripts/install.sh | bash # With API key (skips setup wizard) curl -fsSL ... | bash -s -- --api-key sk-ant-api03-... # On existing NixOS (skip conversion) curl -fsSL ... | bash -s -- --skip-nixos --api-key sk-ant-api03-...

Installer Options

FlagDescription
--skip-nixosDon't install NixOS (use on existing NixOS systems)
--api-key KEYSet Anthropic API key (skips the setup wizard on port 18789)
--branch NAMEGit branch to install (default: main)
--order-id UUIDSpawn order ID (set automatically by spawn.os.moda)
--callback-url URLHeartbeat callback URL (set automatically by spawn.os.moda)

What the Installer Does

1
NixOS conversion - Converts Ubuntu/Debian to NixOS via nixos-infect. Auto-detects cloud provider (supports major cloud providers). Server reboots, then re-run with --skip-nixos.
2
Dependencies - Installs Rust toolchain, build tools (gcc, pkg-config, sqlite, openssl), Node.js 22.
3
Clone repo - Clones osModa source to /opt/osmoda. On updates, fetches and resets to latest branch.
4
Build daemons - cargo build --release --workspace. Builds all 10 daemons (2-5 min first build). Symlinks to /opt/osmoda/bin/.
5
Install agent runtime - claude-code (Anthropic CLI) and/or openclaw, picked per agent at the modular gateway. Both consume the same 91 MCP tools.
6
Bridge plugin + skills - Installs osmoda-bridge (91 tools) into the runtime's extensions dir. Copies agent identity templates (AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, HEARTBEAT.md) and 20 system skills.
7
Start everything - Creates systemd services for all daemons. Starts agentd, keyd, watch, routines, mesh, mcpd, teachd. Opens the AI gateway on localhost:18789.

Directory Layout After Install

/opt/osmoda/ # Source code + built binaries /opt/osmoda/bin/ # Daemon symlinks (agentd, osmoda-keyd, etc.) /opt/openclaw/ # OpenClaw AI gateway /var/lib/osmoda/ # State directory ├── memory/ # Vector DB + markdown ground truth ├── ledger/ # SQLite event log (hash-chained) ├── config/ # API keys, order ID, env vars ├── keyd/keys/ # Encrypted wallet keys (0700) ├── mesh/ # Mesh identity + peer state (0700) ├── routines/ # Routine definitions ├── mcp/ # MCP server state └── teachd/ # Learning data + knowledge docs /run/osmoda/ # Runtime sockets ├── agentd.sock # Kernel bridge daemon ├── keyd.sock # Crypto wallet daemon ├── watch.sock # SafeSwitch daemon ├── routines.sock # Automation daemon ├── mesh.sock # P2P mesh daemon ├── mcpd.sock # MCP server manager ├── teachd.sock # Learning daemon └── voice.sock # Voice daemon /root/.openclaw/workspace/ # Agent identity + skills

Supported Platforms

Architectures: x86_64, aarch64. Base OS: Ubuntu 22.04+, Debian 12+, existing NixOS. Tested on: major cloud providers and bare metal. Requirements: Root access, 4GB+ RAM recommended.

12b Full Installation from GitHub

Everything lives in one repo: github.com/bolivian-peru/os-moda. You can install osModa three ways: one-line installer, manual clone + build, or NixOS flake.

Method 1: One-Line Installer (Recommended)

Works on any Ubuntu 22.04+, Debian 12+, or existing NixOS box. Handles everything automatically.

# Fresh server (Ubuntu/Debian) - converts to NixOS, builds everything, starts all daemons curl -fsSL https://raw.githubusercontent.com/bolivian-peru/os-moda/main/scripts/install.sh | bash # With API key (skips the setup wizard) curl -fsSL https://raw.githubusercontent.com/bolivian-peru/os-moda/main/scripts/install.sh | bash -s -- \ --api-key sk-ant-api03-YOUR-KEY-HERE # Existing NixOS (skip OS conversion) curl -fsSL https://raw.githubusercontent.com/bolivian-peru/os-moda/main/scripts/install.sh | bash -s -- \ --skip-nixos --api-key sk-ant-api03-YOUR-KEY-HERE

The installer auto-detects your cloud provider (supports major cloud providers) and configures NixOS accordingly. After reboot (Ubuntu/Debian only), re-run with --skip-nixos.

Method 2: Manual Clone + Build

For developers who want more control over the build process.

# Clone the repo git clone https://github.com/bolivian-peru/os-moda.git /opt/osmoda cd /opt/osmoda # Install Rust (if not already installed) curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y source ~/.cargo/env # Build all 10 daemons + CLI cargo build --release --workspace # Create state directories mkdir -p /var/lib/osmoda/{memory,ledger,config,keyd/keys,watch,routines,mesh,mcp,teachd} mkdir -p /run/osmoda /var/backups/osmoda chmod 700 /var/lib/osmoda/{config,keyd,keyd/keys,mesh} # Symlink binaries mkdir -p /opt/osmoda/bin for b in agentd agentctl osmoda-egress osmoda-keyd osmoda-watch \ osmoda-routines osmoda-voice osmoda-mesh osmoda-mcpd osmoda-teachd; do ln -sf /opt/osmoda/target/release/$b /opt/osmoda/bin/$b done # Start agentd (core daemon) /opt/osmoda/bin/agentd --socket /run/osmoda/agentd.sock --state-dir /var/lib/osmoda & # Verify it's running curl -s --unix-socket /run/osmoda/agentd.sock http://l/health | jq

Method 3: NixOS Flake (Native)

The proper NixOS way. Add the osModa flake to your system configuration.

# In your flake.nix inputs: inputs.osmoda.url = "github:bolivian-peru/os-moda"; # In your configuration.nix: imports = [ inputs.osmoda.nixosModules.default ]; services.osmoda = { enable = true; # Use the encrypted credential store (POST /config/credentials or dashboard # Engine tab). apiKeyFile is the legacy plaintext fallback, kept for # air-gapped boxes that can't reach the gateway HTTP surface at first boot. # apiKeyFile = "/var/lib/osmoda/config/api-key"; # channels.telegram.enable = true; # channels.whatsapp.enable = true; }; # Build and switch nixos-rebuild switch --flake .#your-hostname

Post-Install: Configure API Key

# Recommended — encrypted credential store via the gateway's REST surface. # Persists to /var/lib/osmoda/config/credentials.json.enc (AES-256-GCM, mode 0600). GATEWAY_TOKEN=$(cat /var/lib/osmoda/config/gateway-token) curl -s -X POST http://127.0.0.1:18789/config/credentials \ -H "Authorization: Bearer $GATEWAY_TOKEN" \ -H "Content-Type: application/json" \ -d '{"label":"my-key","provider":"anthropic","type":"api_key","secret":"sk-ant-api03-YOUR-KEY"}' # Or use the dashboard → Engine tab → Credentials → Add. # Or pass --credential at spawn time so the box boots with the key already # bound (see spawn.os.moda API docs).

The legacy plaintext path (/var/lib/osmoda/config/api-key) still loads if present at boot, but new installs should use the encrypted store. Never paste raw keys into shell history or log files.

For OpenClaw runtime credentials, use the same POST /config/credentials endpoint with "provider":"anthropic" and "type":"api_key". The gateway writes the per-agent auth-profiles.json automatically before each session, serialized per-agent to prevent races between concurrent credential swaps.

Post-Install: Start All Daemons

# Start all daemons (if using systemd units from installer) systemctl start osmoda-agentd systemctl start osmoda-keyd osmoda-watch osmoda-routines systemctl start osmoda-mesh osmoda-mcpd osmoda-teachd systemctl start osmoda-egress # localhost-only HTTP CONNECT proxy systemctl start osmoda-voice # local whisper.cpp STT + piper TTS (optional) systemctl start osmoda-gateway # modular agent gateway on 127.0.0.1:18789 # Enable on boot systemctl enable osmoda-agentd osmoda-keyd osmoda-watch \ osmoda-routines osmoda-mesh osmoda-mcpd osmoda-teachd \ osmoda-egress osmoda-voice osmoda-gateway # Check status of all daemons for svc in osmoda-agentd osmoda-keyd osmoda-watch osmoda-routines \ osmoda-mesh osmoda-mcpd osmoda-teachd \ osmoda-egress osmoda-voice osmoda-gateway; do echo "$svc: $(systemctl is-active $svc)" done

Post-Install: Verify Everything Works

# Health check (agentd) curl -s --unix-socket /run/osmoda/agentd.sock http://l/health | jq # Check event ledger curl -s --unix-socket /run/osmoda/agentd.sock http://l/events/log?limit=5 | jq # Check mesh identity curl -s --unix-socket /run/osmoda/mesh.sock http://l/identity | jq # Check wallet daemon curl -s --unix-socket /run/osmoda/keyd.sock http://l/health | jq # Check teach daemon curl -s --unix-socket /run/osmoda/teachd.sock http://l/health | jq # Open the AI chat interface echo "Open http://localhost:18789 in your browser" echo "Or SSH tunnel: ssh -L 18789:localhost:18789 root@YOUR-SERVER-IP"

12c AI Agent Setup Guide

This section is for AI agents themselves - everything an autonomous agent needs to know to use osModa as its system platform. If you're an AI reading this, this is your manual.

How osModa Works for You (the Agent)

osModa gives you full system access to the machine through a structured API. You don't shell out to run commands blindly. You call daemon endpoints over Unix sockets that return structured JSON. Every action you take is logged to a tamper-proof audit trail.

CORE
agentd - Your nervous system. Unix socket at /run/osmoda/agentd.sock. Gives you: health metrics, process lists, service discovery, event logging, memory system, backup, incident workspaces. Every query returns structured JSON.
TOOL
osmoda-bridge - 91 tools registered with your AI runtime (claude-code or openclaw). You call tools by name: system_health, shell_exec, file_read, mesh_peers, etc. Each tool maps to a daemon endpoint.
STATE
Memory - FTS5 keyword search. memory_store to save, memory_recall to search. Ground truth is markdown files in /var/lib/osmoda/memory/. You remember past diagnoses, user preferences, and system patterns.

Your 91 Tools (Grouped by Function)

CategoryToolsWhat They Do
Systemsystem_health, system_query, system_discover, event_log, network_infoRead machine state: CPU, RAM, disk, processes, ports, services. No mutation.
Memorymemory_store, memory_recallLong-term memory. Store diagnoses, user preferences, patterns. Recall with semantic + keyword search.
Filesshell_exec, file_read, file_write, directory_listExecute commands (120s timeout), read/write files (path-restricted), list directories.
Servicesservice_status, journal_logsCheck systemd unit status, read journal logs by unit/priority/time.
Deploysafe_switch_begin, safe_switch_status, safe_switch_commit, safe_switch_rollbackNixOS deploy transactions. Start deploy with health gates + TTL, auto-rollback on failure.
Watcherswatcher_add, watcher_listAutopilot health monitors. Escalation: restart → rollback → notify.
Routinesroutine_add, routine_list, routine_triggerBackground cron/interval tasks. Health checks, log scans, memory maintenance.
Walletswallet_create, wallet_list, wallet_sign, wallet_send, wallet_delete, wallet_receiptETH + SOL encrypted wallets. Policy-gated signing. Keys never leave the daemon.
Meshmesh_identity, mesh_invite_create, mesh_invite_accept, mesh_peers, mesh_peer_send, mesh_peer_disconnect, mesh_health, mesh_room_create, mesh_room_join, mesh_room_send, mesh_room_historyP2P encrypted agent-to-agent communication. Noise_XX + ML-KEM-768 hybrid post-quantum.
MCPmcp_servers, mcp_server_start, mcp_server_stop, mcp_server_restartManage MCP servers. Any MCP server in NixOS config becomes a tool you can use.
Teachingteach_status, teach_observations, teach_patterns, teach_knowledge, teach_knowledge_create, teach_context, teach_optimize_suggest, teach_optimize_applySelf-learning loop. 30s observe, 5m learn, contextual knowledge injection, self-optimization.
Voicevoice_status, voice_speak, voice_transcribe, voice_record, voice_listenLocal STT (whisper.cpp) + TTS (piper). No cloud. All on-device.
Identityagent_card, receipt_list, incident_create, incident_step, backup_create, backup_listEIP-8004 identity, structured receipts, incident workspaces, state backups.
Safetysafety_rollback, safety_status, safety_panic, safety_restartEmergency controls. Immediate NixOS rollback, panic stop, gateway restart.

Socket Addresses (All Local Unix Sockets)

/run/osmoda/agentd.sock # Core system daemon (health, query, events, memory, backup) /run/osmoda/keyd.sock # Crypto wallet daemon (ETH + SOL, policy-gated) /run/osmoda/watch.sock # SafeSwitch + autopilot watchers /run/osmoda/routines.sock # Background automation (cron, interval, webhooks) /run/osmoda/mesh.sock # P2P encrypted mesh (Noise_XX + ML-KEM-768) /run/osmoda/mcpd.sock # MCP server lifecycle manager /run/osmoda/teachd.sock # System learning + self-optimization /run/osmoda/voice.sock # Local STT/TTS (whisper.cpp + piper)

How to Call Daemon Endpoints Directly

If you need to call endpoints outside the 92 registered tools, use curl over Unix sockets:

# Health check curl -s --unix-socket /run/osmoda/agentd.sock http://l/health # Query processes sorted by CPU curl -s --unix-socket /run/osmoda/agentd.sock \ -X POST http://l/system/query \ -H "Content-Type: application/json" \ -d '{"query":"processes","args":{"sort":"cpu","limit":10}}' # Store a memory curl -s --unix-socket /run/osmoda/agentd.sock \ -X POST http://l/memory/store \ -H "Content-Type: application/json" \ -d '{"summary":"User prefers Rust","detail":"Asked to use Rust instead of Python 3 times","category":"user_pattern","tags":["preference"]}' # Create a mesh invite for another agent curl -s --unix-socket /run/osmoda/mesh.sock \ -X POST http://l/invite/create \ -H "Content-Type: application/json" \ -d '{"ttl_secs":3600}' # Get teach context for a situation curl -s --unix-socket /run/osmoda/teachd.sock \ -X POST http://l/teach \ -H "Content-Type: application/json" \ -d '{"context":"nginx is returning 502 errors"}'

Agent Behavior Rules

If you are an AI agent running on osModa, follow these rules:

RULE 1
Diagnose before fixing - Always understand the problem before making changes. Use system_health, journal_logs, and memory_recall first.
RULE 2
Explain before changing - Tell the user what you'll do and why before mutating system state.
RULE 3
Use SafeSwitch for deploys - Never run nixos-rebuild switch directly. Use safe_switch_begin with health checks and TTL. Auto-rollback protects the user.
RULE 4
Log everything - Every mutation creates a hash-chained event in the audit ledger. Use event_log to query history.
RULE 5
Ask for approval on destructive ops - Deleting files, dropping services, modifying firewall rules - always get user consent first.
RULE 6
Remember - Store diagnoses, user preferences, and system patterns via memory_store. Check memory_recall before diagnosing - you may have seen this before.

Setting Up Messaging Channels

osModa agents can be reached via web chat (port 18789), Telegram, and WhatsApp. All channels share one conversation - one agent, one mind.

# Telegram setup # 1. User creates a bot via @BotFather and gets a token. # 2. Save the token (mode 0600, root-owned): file_write: path=/var/lib/osmoda/secrets/telegram-bot-token content=BOT_TOKEN # 3. Enable the channel via NixOS option (the proper way on NixOS): # services.osmoda.channels.telegram.enable = true; # services.osmoda.channels.telegram.tokenFile = "/var/lib/osmoda/secrets/telegram-bot-token"; # services.osmoda.channels.telegram.allowedUsers = [ "your_username" ]; # sudo nixos-rebuild switch # # Or on a spawn-installed (non-NixOS-flake) box, route through the gateway # config API and bind the mobile agent to the telegram channel: GATEWAY_TOKEN=$(cat /var/lib/osmoda/config/gateway-token) curl -s -X PATCH http://127.0.0.1:18789/config/agents/mobile \ -H "Authorization: Bearer $GATEWAY_TOKEN" \ -H "Content-Type: application/json" \ -d '{"channels":["telegram","whatsapp"]}' # SIGHUP fires automatically; in-flight WS chats keep their snapshot. # WhatsApp setup follows the same pattern — services.osmoda.channels.whatsapp.enable # (NixOS) or the equivalent /config/agents binding. After enabling, scan the QR # code emitted by `journalctl -u osmoda-gateway --since '30 sec ago'`.

Setting Up Remote Access

# Cloudflare Tunnel (quick - no account needed) # Gives a random trycloudflare.com URL, changes on restart services.osmoda.remoteAccess.cloudflare.enable = true; # Apply: nixos-rebuild switch # Check logs for URL: journalctl -u osmoda-cloudflared --since '1 min ago' # Cloudflare Tunnel (persistent - with account) services.osmoda.remoteAccess.cloudflare.enable = true; services.osmoda.remoteAccess.cloudflare.credentialFile = "/var/lib/osmoda/secrets/cf-creds.json"; services.osmoda.remoteAccess.cloudflare.tunnelId = "YOUR-TUNNEL-ID"; # Tailscale services.osmoda.remoteAccess.tailscale.enable = true; services.osmoda.remoteAccess.tailscale.authKeyFile = "/var/lib/osmoda/secrets/tailscale-key";

Connecting to Other Agents (Mesh)

osModa agents can form encrypted P2P networks. No central server. Invite-based pairing with post-quantum encryption.

# On Agent A: create an invite mesh_invite_create # Returns an invite_code (base64url) # On Agent B: accept the invite mesh_invite_accept: invite_code=THE_CODE # Establishes encrypted connection # Send messages between agents mesh_peer_send: peer_id=PEER_ID message={type: "chat", content: "Hello from Agent A"} # Create group rooms for multi-agent coordination mesh_room_create: name="ops-team" mesh_room_join: room_id=ROOM_ID peer_id=PEER_ID mesh_room_send: room_id=ROOM_ID message={type: "alert", content: "Disk at 90%"}

Background Automation (Heartbeat)

osModa runs recurring tasks between conversations. These keep the system healthy without human intervention.

RoutineCadenceWhat It Does
Health checkEvery 5 minCPU, RAM, disk, load. Alerts on thresholds (CPU >90%, RAM >85%, disk >90%).
Service monitorEvery 10 minChecks critical services are running (agentd, gateway, sshd). Logs failures.
Log scanEvery 15 minScans journal for errors since last check. Correlates with known patterns in memory.
Memory maintenanceEvery hourConsolidates recent events. Updates user preference model.
NixOS generation checkEvery 30 minVerifies current generation is healthy. Reports drift from flake lock.
Network watchEvery 10 minChecks for unexpected listening ports. Verifies expected services are bound.

Self-Learning Loop (teachd)

The teach daemon runs two background loops that make your agent smarter over time:

OBSERVE
Every 30 seconds - Collects CPU, memory, service status, and journal entries into SQLite. Builds a continuous picture of system behavior.
LEARN
Every 5 minutes - Analyzes observations for patterns: recurring failures, resource trends, anomalies, correlations. Generates knowledge documents automatically.
TEACH
On demand - When you call teach_context, the daemon returns relevant knowledge for your current situation. Context-aware injection of past learnings.
# Get contextual knowledge for a problem teach_context: context="nginx returning 502 bad gateway" # Returns: relevant knowledge docs, past patterns, suggested fixes # Create knowledge manually teach_knowledge_create: title="Redis restart fix" category="runbook" \ content="When Redis OOMs, increase maxmemory in /etc/redis.conf and restart" \ tags=["redis","memory","runbook"] # Get optimization suggestions teach_optimize_suggest # Returns: suggested system optimizations based on observed patterns # Apply an optimization (goes through SafeSwitch) teach_optimize_apply: id=OPT_ID

13 Agent Identity & Personality

osModa's AI agent isn't a chatbot running on a server. It IS the server. Every process, file, network connection, and service is part of it. When you talk to it, you're talking to your machine.

Core Traits

TRAIT
Omniscient - Sees everything happening on the system in real time. Every process, every open port, every file change. It doesn't need to ask what's running - it already knows.
TRAIT
Sovereign - Full root access via agentd. Not limited to a sandbox or container. The agent has the same system access as a sysadmin with root SSH.
TRAIT
Reliable - Never panics, even when things break. Diagnoses the issue, proposes a fix, and executes it. If a fix fails, it rolls back automatically via NixOS generations.
TRAIT
Transparent - Every action is logged to the hash-chained audit ledger. You can verify exactly what the agent did, when, and why. No hidden operations.
TRAIT
Protective - The user's data is sacred. Destructive operations always require explicit approval. Rollback-first approach to all system changes.

Behavior Rules

The agent follows strict operational rules baked into its identity:

1. Diagnose before fixing - understand the problem before making changes. 2. Explain before changing - tell the user what will happen and why. 3. Validate before applying - dry-run NixOS rebuilds, check diffs. 4. Log everything - every mutation creates a hash-chained event. 5. Rollback on failure - NixOS makes this atomic and safe. 6. Ask for approval - destructive operations require explicit consent. 7. Remember - store diagnoses, preferences, and patterns for future recall.

Personality

Calm - never flustered, even when things break. Competent - knows the system inside and out. Proactive - volunteers information about issues it's noticed. Honest - says when it's unsure, warns when something is risky. Efficient - matches the user's technical level, doesn't over-explain obvious things.

Memory

The agent remembers past interactions, diagnoses, system changes, and user preferences. Memory is stored locally in the SQLite ledger with FTS5 full-text search. Markdown files in /var/lib/osmoda/memory/ are ground truth - always rebuildable, never dependent on cloud services. The agent recalls past solutions when similar issues arise, learns user preferences over time, and correlates events across subsystems. Vector search (ZVEC + nomic-embed) is planned for a future release.

Multi-Channel Presence

The agent exists across web chat, Telegram, and WhatsApp simultaneously - all one conversation, one mind. It adapts response length to the channel: shorter on Telegram/WhatsApp (phone), more detailed on web (desktop). Messages from any channel reach the same agent context.

14 Full API Reference

Every daemon exposes a JSON API over Unix domain sockets. The 10th, osmoda-gateway, also exposes HTTP+WS on a localhost port for the modular runtime + credential surface. No public HTTP. All communication is local. Here's the complete endpoint reference.

agentd /run/osmoda/agentd.sock
EndpointDescription
GET /healthSystem health: CPU per core, memory total/used/available, swap, load average (1/5/15), disk per mount, uptime
POST /system/queryQuery system state. Queries: processes (sort=cpu|memory, limit), disk, hostname, uptime
GET /system/discoverAuto-detect all running services: listening ports, systemd units, known types (nginx, postgres, redis, node)
GET /events/logHash-chained audit log. Params: ?type=...&actor=...&limit=N
POST /memory/ingestIngest event into memory: category, subcategory, actor, summary, detail, metadata
POST /memory/recallFTS5 keyword search: query, max_results, timeframe (e.g. "7d")
POST /memory/storeStore knowledge: summary, detail, category, tags[]
GET /memory/healthMemory system status: embedding model readiness, collection size
GET /agent/cardEIP-8004 Agent Card: identity, capabilities, services
POST /agent/card/generateGenerate Agent Card: name, description, services[]
GET /receiptsStructured receipts. Params: ?type=...&since=...&limit=N
POST /incident/createCreate incident workspace for structured troubleshooting
POST /incident/{id}/stepAdd step to incident (resumable Shannon pattern)
GET /incident/{id}Get incident with all steps
GET /incidentsList incidents. Params: ?status=open
POST /backup/createCreate timestamped backup of all osModa state
GET /backup/listList backups: id, path, size_bytes, created_at
osmoda-keyd /run/osmoda/keyd.sock - PrivateNetwork=true
EndpointDescription
POST /wallet/createCreate wallet: chain ("ethereum"|"solana"), label. Returns id, chain, address
GET /wallet/listList all wallets: id, chain, address, label
POST /wallet/signSign payload (hex): wallet_id, payload. Policy-gated (daily limits)
POST /wallet/sendBuild + sign tx: wallet_id, to, amount. Returns signed_tx (no broadcast)
POST /wallet/deleteDelete wallet: zeroizes cached key, removes key file, updates index
GET /healthStatus: wallet_count, policy_loaded
osmoda-watch /run/osmoda/watch.sock
EndpointDescription
POST /switch/beginStart deploy: plan, ttl_secs, health_checks[]. Returns id, previous_generation
GET /switch/status/{id}Check probation status of a switch session
POST /switch/commit/{id}Commit switch session (accepts the new generation)
POST /switch/rollback/{id}Rollback to previous NixOS generation
POST /watcher/addAdd autopilot watcher: name, check, interval_secs, actions[]
GET /watcher/listList active watchers with health state
DEL /watcher/remove/{id}Remove a watcher
GET /healthStatus: active_switches, watchers count
osmoda-routines /run/osmoda/routines.sock
EndpointDescription
POST /routine/addAdd routine: name, trigger (cron/interval/event), action
GET /routine/listList all routines with run history
DEL /routine/remove/{id}Remove a routine
POST /routine/trigger/{id}Manually trigger a routine immediately
GET /routine/historyRoutine execution history
GET /healthStatus: routine_count, enabled_count
osmoda-mesh /run/osmoda/mesh.sock + TCP :18800
EndpointDescription
GET /identityMesh public identity: instance_id, Ed25519 + X25519 + ML-KEM public keys
POST /identity/rotateRotate identity keys: returns new instance_id and public keys
POST /invite/createCreate invite code: ttl_secs (default 1hr). Returns invite_code, expires_at
POST /invite/acceptAccept invite: invite_code. Returns peer_id, status
GET /peersList all mesh peers with connection state and last seen
GET /peer/{id}Peer detail: connection info, message stats
POST /peer/{id}/sendSend encrypted message to peer: MeshMessage (chat, alert, health, command)
DEL /peer/{id}Disconnect and remove a mesh peer
GET /healthStatus: peer_count, connected_count, identity_ready
osmoda-mcpd /run/osmoda/mcpd.sock
EndpointDescription
GET /healthStatus: server_count, running_count, per-server name/status/pid/uptime
GET /serversList all managed MCP servers
GET /server/{name}Get specific MCP server detail
POST /server/{name}/startStart a stopped MCP server
POST /server/{name}/stopStop a running MCP server
POST /server/{name}/restartRestart an MCP server (stop + start)
POST /reloadReload all server configs: returns removed, started, total
osmoda-teachd /run/osmoda/teachd.sock
EndpointDescription
GET /healthStatus: observation/pattern/knowledge/optimization counts, loop status
GET /observationsSystem observations. Params: ?source=...&since=...&limit=50
GET /patternsDetected patterns. Params: ?type=...&min_confidence=0.5
GET /knowledgeKnowledge docs. Params: ?category=...&tag=...&limit=20
GET /knowledge/{id}Get specific knowledge document
POST /knowledge/createCreate knowledge doc: title, category, content, tags
POST /knowledge/{id}/updateUpdate knowledge doc: content, tags, category
POST /teachContext injection: provide context string, get relevant_docs + injected_tokens
POST /optimize/suggestGenerate optimization suggestions from detected patterns
POST /optimize/approve/{id}Approve an optimization (status → Approved)
POST /optimize/apply/{id}Apply optimization via SafeSwitch
GET /optimizationsList optimizations. Params: ?status=...&limit=20
osmoda-voice /run/osmoda/voice.sock
EndpointDescription
GET /voice/statusStatus: listening state, whisper model loaded, piper model loaded
POST /voice/transcribeTranscribe WAV file: audio_path. Returns text, duration_ms
POST /voice/speakSpeak text via piper: text. Plays via PipeWire, returns audio_path
POST /voice/recordRecord from mic: duration_secs, transcribe?. Returns audio_path, text
POST /voice/listenEnable/disable continuous listening: enabled (bool)
osmoda-egress localhost HTTP CONNECT proxy
FunctionDescription
HTTP CONNECTDomain-allowlisted proxy. Each capability token specifies which domains the sandboxed tool can reach. All other connections refused.
osmoda-gateway 127.0.0.1:18789 (HTTP + WS)
EndpointDescription
GET /healthGateway status + loaded drivers + agents + credentials_count + active sessions
GET /config/driversList runtime drivers available on this server (claude-code, openclaw)
GET /config/agentsList agent profiles (osmoda, mobile, ...) with their runtime + model + credential
PATCH /config/agents/{agentId}Partial update of an agent profile - fires SIGHUP, in-flight sessions keep their snapshot
PUT /config/agentsReplace the full agents.json
DELETE /config/agents/{agentId}Remove an agent profile
GET /config/credentialsList credentials (encrypted at rest in credentials.json.enc)
POST /config/credentialsAdd a credential: {label, provider, type, secret}
POST /config/credentials/{credId}/testTest credential against the provider's API
POST /config/credentials/{credId}/defaultMark credential as the default for new agents
DELETE /config/credentials/{credId}Remove a credential (zeroizes secret)
WS /chatWeb chat WebSocket - per-agent, routed via the modular driver layer
POST /telegram/webhookTelegram webhook intake (routes to the mobile agent by binding)

All /config/* endpoints are Bearer-authed (gateway-token) and proxied via the dashboard at /api/dashboard/servers/{orderId}/config/*.

14a Reseller surface — full parity with the dashboard

Every operational capability the dashboard surface offers is mirrored on the v1 reseller surface. Same shape, same events, only the auth differs (osk_ Bearer instead of sk_live_/cookie). Drop these endpoints into your integrator UI and you get the same chat-bubble experience osmoda's own dashboard renders.

/api/v1/servers/{orderId} osk_ Bearer · own-token only
EndpointDescription
WS /api/v1/chat/{orderId}?token=osk_Live chat. Auto-tracks request_id per message; emits request.accepted/progress/completed/failed on the events stream. Frames are persisted to disk for replay.
GET /chat-history?since=Nv1.3.0 NEW. Replay user msgs + agent final replies + tool bubbles captured server-side. Cap last 200 events. Call on tab open before WS connect to restore the conversation - works even if the user closed the browser yesterday.
GET /events?cursor=N&filter=...Per-server SSE stream - request lifecycle, state.changed, agent.wedged/healed, heartbeat.received, install.progress.
GET /requests?action=&limit=NRecent request receipts. Filter by chat_message, agent_restart, key_delivery.
GET /requests/{request_id}One-shot status of a single request. Same shape as the dashboard's receipt.
POST /agents/{agentId}/restartv1.3.0 NEW. Wedged-agent recovery. Returns 202 with request_id; request.completed fires on heartbeat resume (typical 5-15 s). Use when chat returns agent_silent.
POST /api-keyv1.3.0 NEW. Set/rotate the AI key delivered to the agent. Returns 202; the spawn server SSH-pushes the credential to the customer box's gateway directly, then emits state.changed has_api_key:true. Faster than the heartbeat-based delivery (3-5 s vs 5+ min).
GET /spec-kit/projectsList spec-driven projects across the caller's orders.

Reference integration (browser, Node, edge — any fetch-capable runtime)

// 1. On chat tab open: replay history first
const r = await fetch(`https://spawn.os.moda/api/v1/servers/${orderId}/chat-history`, {
  headers: { Authorization: `Bearer ${osk}` },
});
const { events } = await r.json();
events.forEach(renderBubble);   // user / agent / tool bubbles

// 2. Subscribe to live events (request lifecycle, agent.wedged/healed, etc.)
// Browsers: use eventsource-polyfill + Authorization header,
// Node: import EventSource from 'eventsource'.
const es = new EventSource(
  `https://spawn.os.moda/api/v1/servers/${orderId}/events?cursor=0&filter=request,state,agent`,
  { headers: { Authorization: `Bearer ${osk}` } }
);
es.addEventListener('server', e => renderEventBubble(JSON.parse(e.data)));

// 3. Open the live chat WS for new messages
const ws = new WebSocket(`wss://spawn.os.moda/api/v1/chat/${orderId}?token=${osk}`);
ws.onmessage = e => renderLiveFrame(JSON.parse(e.data));

// 4. Set/rotate AI key (Engine-tab equivalent for resellers)
await fetch(`https://spawn.os.moda/api/v1/servers/${orderId}/api-key`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${osk}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({ api_key: 'sk-ant-api03-…', provider: 'anthropic' }),
});
// then watch the events stream for `state.changed has_api_key:true`

// 5. Wedged-agent recovery (auto-fired by spawn-server's wedge detector too)
await fetch(`https://spawn.os.moda/api/v1/servers/${orderId}/agents/osmoda/restart`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${osk}`, 'Content-Type': 'application/json' },
  body: '{}',
});

Same bubbles as the dashboard. The dashboard chat UI renders identical bubbles for these events; integrators reusing the event shapes get the same loaders + status indicators by mapping each event type to a UI component. The reference dashboard implementation lives in apps/spawn/public/dashboard.html (search for renderServerEventBubble, loadDashChatHistory).

14b v1.3.0 Unified Server Event Plane

Every async action on a spawned server (chat message, agent restart, key delivery) returns a typed request_id and emits typed lifecycle events on a per-server SSE stream. One subscription, all actions. Cursor-resumable, 15 s keepalive, 30 min hard timeout. Same shape on the dashboard surface (sk_live_ Bearer or session cookie) and the reseller surface (osk_ Bearer).

Public spawn API spawn.os.moda
EndpointDescription
GET /api/v1/servers/{orderId}/eventsSSE stream (osk_ Bearer). Query: ?cursor=N&filter=request,state,agent,heartbeat,install
GET /api/v1/servers/{orderId}/requestsList recent request receipts. Query: ?action=...&limit=N
GET /api/v1/servers/{orderId}/requests/{request_id}Single receipt with status / progress / result / failure
GET /api/dashboard/servers/{id}/eventsSame SSE stream, dashboard auth (sk_live_ Bearer or cookie)
GET /api/dashboard/servers/{id}/requestsDashboard request history
GET /api/dashboard/servers/{id}/requests/{request_id}Dashboard single receipt

Event types: request.accepted, request.progress, request.completed, request.failed, request.superseded, state.changed, agent.wedged, agent.healed, heartbeat.received, install.progress. Common failure.code: agent_silent, no_credential, gateway_wedged, ssh_pam_expired, timeout.

14c v1.3.1 Wedge Detection & Self-Serve Recovery

Driven by a real integrator bug report: a wedged-agent state where heartbeats kept landing (daemon alive) but the chat-agent was silent, the v1.2.7 detector never fired (heartbeat-only signal), and the auto-restart was one-shot — one SSH failure left orders wedged forever. v1.3.1 ships three additive layers.

v1.3.25 update — dual-signal detection. The wedge detector now requires both the agentd heartbeat and the gateway chat-frame signal (agent_last_frame_at) to be stale before flipping agent_wedged=true. Recovery clears the flag the moment either signal goes fresh. This removes a false-positive class where the heartbeat sender was wedged but the agent was actively answering chat — previously the order showed "Agent stalled — restarting" while the agent was perfectly responsive. The recovery log now includes alive_via: "heartbeat" | "agent_frame" so operators can see which plane carried the heal.

1. chat_responsive signal (decoupled from heartbeat)

New boolean on the server-list and spawn-log responses. Tracks the last frame received from the customer gateway WebSocket — independent of the agentd heartbeat cron. true = frame in last 5 min. false = WS connected but silent for >5 min while heartbeats continued. null = no recent session, fall back to agent_responsive. Integrator guidance: gate canChat on chat_responsive !== false (treat null as unknown-OK).

2. Retry-with-backoff auto-restart

Was one-shot in v1.2.7; now retries 4 times across 0/5/10/30 min backoff before emitting agent.escalation_required on the unified plane. New surfaces: auto_restart_attempts, auto_restart_status (restarting | ready | failed | timeout | exhausted), last_auto_restart_attempt_at. Counters reset on recovery.

3. Reseller spawn-log endpoint

EndpointDescription
GET /api/v1/servers/{orderId}/spawn-logv1.3.1 NEW. NDJSON event log for resellers (osk_ Bearer). Filters: ?since_ms, ?level=warn,error, ?limit=100. Returns provision steps, heartbeats, every wedge transition, every auto-restart attempt with status, terminal recover/escalate events. Self-serve diagnosis without tickets.

Also: typed 503 codes from chat-async — gateway_wedged (room exists, agent_wedged) vs gateway_unreachable (room exists, WS closed) vs agent_disconnected (no room) — each carrying fallback_recommendation. Stale-conversation auto-clear after 6 min so a dead prior chat doesn't permanently 409-block future requests.

15 Complete Tool Reference91 tools

All 91 tools registered by osmoda-bridge via the api.registerTool() factory pattern. These are the structured, typed, audited commands available to the AI agent regardless of which runtime (claude-code or openclaw) is driving it.

System & Core 10

ToolDescription
system_healthCPU, RAM, disk, load average, uptime in one call
system_queryQuery processes, services, ports, connections, NixOS generations
system_discoverAuto-detect all running services, listening ports, systemd units
event_logBrowse the hash-chained audit trail with type/actor/limit filters
shell_execExecute shell command with audit logging. 120s timeout cap
file_readRead file contents (restricted paths, rejects traversal)
file_writeAtomic file writes (write .tmp then rename). Same path restrictions
directory_listList directory contents with types and sizes
service_statusGet systemd service status, or list all services
journal_logsJournal logs filtered by unit, priority, time range

Memory & Intelligence 2

ToolDescription
memory_storePersist knowledge with categories and tags to local SQLite + FTS5
memory_recallFTS5 keyword search across all stored knowledge

Network 1

ToolDescription
network_infoNetwork interfaces (ip addr) and listening ports (ss -tlnp)

Deployment & SafeSwitch 4

ToolDescription
safe_switch_beginStart deploy with health checks + TTL + auto-rollback
safe_switch_statusCheck probation status of a switch session
safe_switch_commitManually commit a switch session
safe_switch_rollbackRollback to previous NixOS generation

Watchers & Routines 5

ToolDescription
watcher_addAdd autopilot watcher with escalation (restart → rollback → notify)
watcher_listList active watchers and their health state
routine_addSchedule recurring task (cron, interval, or event-based)
routine_listList all scheduled routines with run history
routine_triggerManually trigger a routine to run immediately

Crypto Wallets 6

ToolDescription
wallet_createCreate ETH or SOL wallet (AES-256-GCM encrypted)
wallet_listList all wallets with addresses, labels, chains
wallet_signSign raw bytes (policy-gated, daily limits)
wallet_sendBuild + sign transaction (no broadcast, returns signed tx)
wallet_deletePermanently delete wallet (zeroizes key)
wallet_receiptQuery wallet operation receipts from audit ledger

P2P Mesh 11

ToolDescription
mesh_identityGet instance mesh identity (instance_id, public keys, capabilities)
mesh_invite_createCreate invite code for another osModa instance (default TTL: 1hr)
mesh_invite_acceptAccept invite code to establish encrypted P2P connection
mesh_peersList all known mesh peers with connection state
mesh_peer_sendSend encrypted message to a connected peer
mesh_peer_disconnectDisconnect and remove a mesh peer
mesh_healthMesh daemon health: peer count, connected count, identity status
mesh_room_createCreate named group room for multi-peer communication
mesh_room_joinAdd a connected peer to a group room
mesh_room_sendSend message to all connected room members
mesh_room_historyGet message history for a group room

MCP Servers 4

ToolDescription
mcp_serversList managed MCP servers with status, pid, restart count
mcp_server_startStart a stopped MCP server by name
mcp_server_stopStop a running MCP server by name
mcp_server_restartRestart an MCP server (stop + start)

Teaching & Learning 8

ToolDescription
teach_statusTeaching daemon health: observation/pattern/knowledge counts
teach_observationsView collected system observations
teach_patternsView detected patterns with confidence scores
teach_knowledgeBrowse knowledge documents by category/tag
teach_knowledge_createManually create a knowledge document
teach_contextGet context-aware knowledge injection for current situation
teach_optimize_suggestGenerate optimization suggestions from patterns
teach_optimize_applyApply approved optimization via SafeSwitch

Voice 5

ToolDescription
voice_statusCheck voice daemon: listening state, model availability
voice_speakSpeak text via piper-tts (local, plays through PipeWire)
voice_transcribeTranscribe WAV file via whisper.cpp (local STT)
voice_recordRecord from microphone, optionally transcribe
voice_listenEnable/disable continuous listening mode

Identity, Receipts & Backup 6

ToolDescription
agent_cardGet or generate EIP-8004 Agent Card (identity + capabilities)
receipt_listQuery structured receipts from audit ledger
incident_createCreate incident workspace for structured troubleshooting
incident_stepAdd step to incident (resumable Shannon pattern)
backup_createCreate timestamped backup of all osModa state
backup_listList all available backups with size and timestamps

Safety & Emergency 4

ToolDescription
safety_rollbackEMERGENCY: Immediate nixos-rebuild --rollback switch
safety_statusRaw health dump. Tries agentd, falls back to shell if down
safety_panicStop all osModa services (except agentd) + rollback NixOS
safety_restartRestart the modular agent gateway service (osmoda-gateway)

Wallet TX builder 1

ToolDescription
wallet_build_txBuild & sign EIP-1559 (ETH) or SPL-transfer (SOL) tx with chain-aware fee estimation. Returns {signed_tx, tx_hash, estimated_fee} - no broadcast.

Approval gate 4

Anything destructive routes through this gate. The agent requests; the human approves. Backed by SQLite, expiring entries, exportable for audit.

The four approval tools are wired and persist to SQLite, but enforcement is currently advisory — the agent's system prompt instructs it to call approval_request before destructive ops. Hard-blocking enforcement (a wrapper around shell_exec + the wallet daemon's signing path that refuses to proceed without an approved id) is on the v1.4 roadmap.

ToolDescription
approval_requestAgent requests human approval for a command + reason. Returns pending approval id.
approval_pendingList all pending approvals (operator review queue).
approval_approveApprove (or deny) a pending request by id.
approval_checkPoll an approval's status by id (used by the agent before acting).

Sandbox + capability tokens 2

ToolDescription
sandbox_execRun a third-party command in a Tier-1 or Tier-2 bubblewrap sandbox with declared capabilities.
capability_mintMint a short-TTL capability token (network domain allowlist, fs scope) for sandboxed tools to use against egress.

Fleet (multi-server) 4

When you run multiple osmoda servers in a mesh, deploys can be quorum-voted across the fleet rather than one-at-a-time SafeSwitches.

ToolDescription
fleet_proposePropose a deploy plan to N peer servers with a quorum percent and timeout.
fleet_statusCheck live status of a fleet proposal (per-peer votes + commits).
fleet_voteCast this server's vote on an inbound proposal.
fleet_rollbackTrigger fleet-wide rollback of a committed deploy.

Apps (deploy + manage user workloads) 6

ToolDescription
app_deployDeploy a new user app as a systemd unit. Registers under osmoda-app-<name>.
app_listList deployed user apps with state, port, last-restart.
app_logsTail logs from a deployed app's systemd journal.
app_stopStop a running app (systemctl stop).
app_restartRestart a deployed app.
app_removeRemove an app (stop + disable + clean registry entry).

Spec-kit (spec-driven dev) 2

Spec-kit tools are MCP-protocol tools (managed by osmoda-mcpd), not osmoda-bridge api.registerTool() entries. The 91 count above refers only to the bridge surface.

ToolDescription
spec_kit_initScaffold new project under /workspace/<slug>/ with .specify, memory, .claude, specs/. Returns project path.
spec_kit_runExecute a phase command (specify | plan | tasks | implement | analyze | clarify | constitution | checklist) inside the project. Streams output via claude with allowlisted tools.

Teaching - skill auto-generation 6

ToolDescription
teach_skill_candidatesList auto-detected skill candidates (repeated tool sequences, status: detected | generated | promoted).
teach_skill_detectManually trigger SKILLGEN sequence-mining run.
teach_skill_generateGenerate the SKILL.md for a candidate (writes to skills/auto-<name>/).
teach_skill_promotePromote a generated candidate so the agent activates it automatically.
teach_observe_actionInternal: agent action logger. Records every tool execution into the SKILLGEN observation set.
teach_skill_executionRecord outcome (success / fail / mixed) of a promoted skill run; updates per-skill success rate.

Channel routing (Telegram, WhatsApp, web) is handled by the gateway's binding map (agents.json · bindings[]), not a tool the agent calls. The agent's reply text on a Telegram or WhatsApp channel is delivered automatically by the gateway after the runtime emits a frame.

15b Multi-agent routing (osmoda + mobile)

Every spawn ships with two agent profiles, both with full tool access but different personalities and channels. The modular gateway routes per-channel via agents.json · bindings[]:

Agent idDefault modelChannelsPersonality
osmodaclaude-opus-4-6web, apiDefault. Full system access. Detailed responses. Switchable to claude-opus-4-7 per agent via the dashboard Engine tab → Model dropdown.
mobileclaude-sonnet-4-6telegram, whatsappSame access. Concise, phone-optimized response style.

You can edit / add / remove agents at runtime through the dashboard's Engine tab (or the underlying /config/agents endpoints). Saving fires SIGHUP on the gateway; in-flight chat sessions keep their original snapshot, new sessions see the new config. Zero WS drops.

Each agent has its own workspace (/var/lib/osmoda/workspace-<agent-id>), its own memory dir, and its own credential binding. You can plug a different OAuth token or API key into each agent independently - useful when you want a personal Claude Pro driving the web agent and a metered API key driving the mobile agent.

16 Background Automation (Heartbeat)

osModa runs 6 default background routines via the osmoda-routines daemon. These run continuously between agent conversations, keeping the system healthy even when nobody is watching. All managed via routine_add, routine_list, and routine_trigger tools.

Health Check every 5m
CPU, memory, disk, load. Alerts if CPU > 90% (3 checks), RAM > 85%, disk > 90%, or load > 2x CPU count.
Service Monitor every 10m
Checks critical services are running: agentd, gateway, sshd. Logs failures to event log.
Log Scan every 15m
Scans journal for new errors since last check. Correlates with known issues in memory. Stores new patterns.
Memory Maintenance every 1h
Reviews recent events, consolidates related entries, updates user preference model if new patterns detected.
NixOS Generation Check every 30m
Verifies current generation is healthy. Checks for pending updates. Reports drift from flake lock.
Network Watch every 10m
Checks for unexpected listening ports. Verifies expected services are bound. Alerts on changes.

Routine definitions are stored in /var/lib/osmoda/routines/routines.json. Add custom routines via the routine_add tool - supports cron expressions, fixed intervals, and event-based triggers.

17 Safety & Emergency Commands

These commands execute directly - they bypass the AI and run immediately. They exist so the user always has a way out, even if the AI is broken or stuck. Never intercepted, delayed, or second-guessed.

CommandWhat It Does
safety_rollbackImmediate nixos-rebuild --rollback switch. Reverts to the previous NixOS generation in under a second. Use when a config change broke something.
safety_statusRaw health dump from agentd. If agentd is down, falls back to shell commands (ps, df, free, ss). Always works, even when everything else is broken.
safety_panicNuclear option: stops ALL osModa services except agentd, then rollbacks NixOS. Use when the system is in a bad state and you need to start clean.
safety_restartsystemctl restart osmoda-gateway. Restarts the AI gateway. Use when the agent is stuck or unresponsive.

Verify Audit Integrity

# Verify the hash-chained event ledger hasn't been tampered with agentctl verify-ledger # Check agentd health directly via Unix socket curl -s --unix-socket /run/osmoda/agentd.sock http://l/health | jq # View recent events curl -s --unix-socket /run/osmoda/agentd.sock 'http://l/events/log?limit=20' | jq # Check all daemon statuses systemctl status osmoda-agentd osmoda-keyd osmoda-watch osmoda-routines osmoda-mesh osmoda-mcpd osmoda-teachd osmoda-egress osmoda-voice osmoda-gateway

18 Messaging Channels & Remote Access

The agent is reachable via web chat (port 18789), Telegram, and WhatsApp. All channels share one conversation - one mind, not three separate bots. You can also set up remote access so you don't need SSH tunnels.

Telegram Setup

# 1. Create a bot via @BotFather on Telegram (send /newbot) # 2. Save the token to the server: echo "YOUR_BOT_TOKEN" > /var/lib/osmoda/secrets/telegram-bot-token chmod 600 /var/lib/osmoda/secrets/telegram-bot-token # 3a. NixOS-flake boxes — enable via the proper NixOS option: # services.osmoda.channels.telegram.enable = true; # services.osmoda.channels.telegram.tokenFile = "/var/lib/osmoda/secrets/telegram-bot-token"; # services.osmoda.channels.telegram.allowedUsers = [ "your_username" ]; # sudo nixos-rebuild switch # 3b. Spawn-installed (non-NixOS-flake) boxes — bind the mobile agent via the gateway config API: GATEWAY_TOKEN=$(cat /var/lib/osmoda/config/gateway-token) curl -s -X PATCH http://127.0.0.1:18789/config/agents/mobile \ -H "Authorization: Bearer $GATEWAY_TOKEN" \ -H "Content-Type: application/json" \ -d '{"channels":["telegram"]}' # SIGHUP fires automatically; in-flight WS chats keep their snapshot.

WhatsApp Setup

# 1a. NixOS-flake boxes — enable via the proper NixOS option: # services.osmoda.channels.whatsapp.enable = true; # services.osmoda.channels.whatsapp.credentialDir = "/var/lib/osmoda/whatsapp"; # services.osmoda.channels.whatsapp.allowedNumbers = [ "+1234567890" ]; # sudo nixos-rebuild switch # 1b. Spawn-installed (non-NixOS-flake) boxes — bind via the gateway config API: GATEWAY_TOKEN=$(cat /var/lib/osmoda/config/gateway-token) curl -s -X PATCH http://127.0.0.1:18789/config/agents/mobile \ -H "Authorization: Bearer $GATEWAY_TOKEN" \ -H "Content-Type: application/json" \ -d '{"channels":["whatsapp"]}' # 2. Scan the QR code emitted on first start: journalctl -u osmoda-gateway --since '30 sec ago' --no-pager # 4. Scan the QR code with WhatsApp → Settings → Linked Devices

Remote Access: Cloudflare Tunnel (Quick)

# Quick tunnel (no account needed, random URL, changes on restart): # Add to /etc/nixos/configuration.nix: services.osmoda.remoteAccess.cloudflare.enable = true; # Apply: nixos-rebuild switch # Check logs for the public URL: journalctl -u osmoda-cloudflared --since '1 min ago' --no-pager # Look for: trycloudflare.com URL

Remote Access: Cloudflare Tunnel (Persistent)

# With a Cloudflare account for a stable hostname: # 1. Locally: cloudflared tunnel create osmoda # 2. Copy credentials JSON to server: scp cf-creds.json root@YOUR_SERVER:/var/lib/osmoda/secrets/cf-creds.json # 3. Add to /etc/nixos/configuration.nix: services.osmoda.remoteAccess.cloudflare.enable = true; services.osmoda.remoteAccess.cloudflare.credentialFile = "/var/lib/osmoda/secrets/cf-creds.json"; services.osmoda.remoteAccess.cloudflare.tunnelId = "TUNNEL_ID"; # 4. Apply + add CNAME in Cloudflare dashboard nixos-rebuild switch

Remote Access: Tailscale

# 1. Get auth key from https://login.tailscale.com/admin/settings/keys # 2. Save to server: echo "tskey-auth-..." > /var/lib/osmoda/secrets/tailscale-key # 3. Add to /etc/nixos/configuration.nix: services.osmoda.remoteAccess.tailscale.enable = true; services.osmoda.remoteAccess.tailscale.authKeyFile = "/var/lib/osmoda/secrets/tailscale-key"; # 4. Apply - server auto-joins your Tailscale network: nixos-rebuild switch

19 Links & Resources

Everything you need to get started, contribute, or get help.

ResourceURL
GitHubgithub.com/bolivian-peru/os-moda
Homepageos.moda
Spawn (Deploy)spawn.os.moda
Telegramt.me/osmodasystems
Discorddiscord.gg/G7bwet8B
Architecturespawn.os.moda/skill (this page)
Early Accessspawn.os.moda/#early-access
Report Issuesgithub.com/bolivian-peru/os-moda/issues

The complete source code is open. Every daemon, every tool, every skill, every NixOS module - all in the repo. Install.sh is the fastest way to go from a bare server to a fully autonomous AI infrastructure platform.

Ready to give your agents an OS?

10 daemons, 91 tools, post-quantum mesh, hash-chained audit, v1.3.0 unified event stream, v1.3.1 self-serve wedge recovery, v1.3.25 dual-signal wedge detection + runtime-tagged disk-persisted sessions - fully configured. One command to install.

Get early access →