Skip to content

Architecture

Michael Elliott edited this page Mar 14, 2026 · 2 revisions

Architecture

System Overview

┌──────────────────────────────────────────────────────────────────┐
│                      CLI (commander.js)                          │
│   gateway, agent, send, onboard, doctor, model, create-skill,   │
│   mcp-server, teams, skills, config, update, mesh, graphiti     │
├──────────────────────────────────────────────────────────────────┤
│                   Gateway (Express + WS)                         │
│     HTTP API  |  WebSocket  |  SSE Streaming  |  MC v2 SPA      │
├──────────┬──────────┬────────────┬───────────────────────────────┤
│ Channels │  Agent   │  Skills    │       Memory                  │
│ 15       │ Router   │ ~149 tools │  Graph (entities)             │
│ adapters │ Multi-   │ Shell      │  Learning (patterns)          │
│ Discord  │ Agent    │ Browser    │  Briefings (daily)            │
│ Telegram │ Planner  │ GitHub     │  Relationships                │
│ Slack    │ Autonomy │ Email      │  RAG / Vector Search          │
│ WhatsApp │ Goals    │ Training   │  Embeddings (FTS5)            │
│ Matrix   │ Self-    │ Self-Impr  │                               │
│ Signal   │ Initiative│ CAPTCHA   │                               │
│ Teams    │ Autopilot│ X/Twitter  │                               │
│ G. Chat  │ Sessions │ Voice      │                               │
│ IRC      │ Cost Opt │ MCP        │                               │
│ Mmost    │ Context  │ ...        │                               │
│ Lark     │ Fallback │            │                               │
│ Email    │ Chains   │            │                               │
│ LINE     │          │            │                               │
│ Zulip    │          │            │                               │
├──────────┴──────────┼────────────┼───────────────────────────────┤
│      Providers      │  Security  │     Mesh Network              │
│  34 LLM providers   │  Shield    │  mDNS + WebSocket             │
│  4 native + 30 compat│ Sandbox   │  HMAC auth                    │
│  Fallback chains    │  Vault     │  Cross-node routing            │
│  Self-heal          │  Audit Log │  Peer approval                 │
└─────────────────────┴────────────┴───────────────────────────────┘

Directory Structure

src/
├── agent/           # Core agent: processing, multi-agent, autonomy, planning, goals, self-initiative
├── channels/        # 15 messaging adapters (Discord, Telegram, Slack, WhatsApp, Matrix, Signal, Teams, Google Chat, IRC, Mattermost, Lark/Feishu, Email IMAP, LINE, Zulip, WebChat)
├── providers/       # 34 LLM providers (4 native: Anthropic, OpenAI, Google, Ollama + 30 OpenAI-compatible)
├── skills/          # ~149 tool/skill implementations across 91 skills
│   ├── builtin/     # Core built-in skills
│   └── dev/         # Dev-only skills (env-gated: TITAN_DEV_SKILLS=1)
├── memory/          # Graph memory, learning, briefings, relationships, RAG, embeddings
├── security/        # Prompt shield, sandbox, encrypted vault (AES-256-GCM), audit logging, pairing
├── gateway/         # HTTP/WS/SSE server, Mission Control v2 SPA, slash commands
├── voice/           # LiveKit WebRTC voice, Orpheus TTS, livekitAgent.ts
├── mcp/             # MCP Server mode (JSON-RPC 2.0, stdio + HTTP) and MCP client
├── browsing/        # Shared browser pool (Playwright), CapSolver CAPTCHA solving
├── training/        # Local model fine-tuning (LoRA via unsloth → GGUF → Ollama), dual pipelines
├── self-improvement/# LLM-as-judge eval, autoresearch, self-improvement system
├── mesh/            # Peer-to-peer networking (mDNS, WebSocket, HMAC auth)
├── recipes/         # Multi-step workflow recipes
├── config/          # Zod schema, config loading
├── cli/             # CLI commands (gateway, agent, create-skill, mcp-server, teams, doctor, etc.)
├── context/         # ContextEngine plugin system
├── metrics/         # Prometheus metrics
└── utils/           # Constants, helpers, logger, updater

Data Flow

  1. Inbound Message arrives via any of the 15 channel adapters or the HTTP API
  2. Slash Command Check — native commands or recipe commands
  3. Multi-Agent Router selects the appropriate agent (with fallback chains)
  4. Agent Processing — builds context (ContextEngine plugins), calls LLM, executes tools
  5. Tool Execution — autonomy check, sandbox enforcement, execute, return result
  6. Streaming — response streamed via SSE or WebSocket to the client
  7. Response — sent back through the originating channel
  8. Memory — conversation stored, graph updated, patterns learned, RAG indexed
  9. Self-Improvement — periodic LLM-as-judge evaluation, autoresearch for knowledge gaps

Key Design Decisions

  • Zero native dependencies — All optional deps in optionalDependencies
  • Pure ESM — Full ES module architecture with TypeScript strict mode
  • Dynamic imports — Optional features use await import() to avoid crash-on-missing
  • JSON file storage — No database server required (SQLite FTS5 for RAG)
  • Event-driven channels — All channels extend ChannelAdapter and emit events
  • Provider normalization — Unified interface with automatic routing and fallback chains
  • ContextEngine plugins — Modular context injection before each LLM call
  • MCP interop — Both server (expose tools) and client (consume external tools) via JSON-RPC 2.0

Clone this wiki locally