$ show nanocoai/nanoclaw
NanoClaw is a self-hosted, multi-agent AI orchestration platform that runs containerized agent sessions, integrates with a wide range of chat channels (Slack, Discord, Telegram, WhatsApp, iMessage, etc.), and provides a CLI-based admin interface. It is architected as a host service (Node.js/TypeScript, SQLite) that manages per-session agent containers (Bun runtime) isolated via Docker. The system features a typed guard/approval system for privileged actions, a plugin-based skill system for extensibility, and a structured migration framework for database schema evolution. Key operational flows include inbound message routing from channel adapters, session lifecycle management with two-DB mailbox split (inbound/outbound SQLite), container orchestration with credential injection via OneCLI vault, and host sweep for periodic maintenance. The CLI (`ncl`) provides resource CRUD with hooks, command guard integration, and a socket-based transport protocol. The project emphasizes a small, auditable codebase, skill-based feature installation over configuration, and deterministic setup/upgrade workflows with Claude Code fallback for error recovery.
The LLM identified 3 files worth highlighting for reuse:
A simple but polished circuit breaker implementation with a configurable exponential backoff schedule (1s, 2s, 4s, 8s, 15s, 30s, 60s, 5min, 15min). Exports a single class `CircuitBreaker` with `recordFailure()`, `recordSuccess()`, and `isOpen()` methods. It is fully isolated (no internal imports) and can be extracted into any Node.js/TypeScript project needing startup backoff mitigation.
Provides `deriveAttachmentName` which generates safe file names from MIME types and Telegram attachment types, and `isSafeAttachmentName` which rejects path traversal attempts. Uses a curated MIME-to-extension mapping, falls back to generic extensions for unknown types, and handles Telegram-specific attachment types. Fully self-contained with no internal dependencies, making it reusable in any media-handling pipeline.
A brace-depth scanner that splits concatenated JSON objects (watch-style CLI output) without a full parser. Uses a simple state machine to track brace depth and string escapes, yielding complete JSON objects. This is a non-obvious, optimized approach for parsing streaming JSON output from CLIs. It is a single exported function with no internal dependencies, easily reusable in any project needing to parse concatenated JSON streams.