Skip to content

Latest commit

 

History

History
679 lines (627 loc) · 88.7 KB

File metadata and controls

679 lines (627 loc) · 88.7 KB

ZimaOS-Blue Architecture

Current implementation architecture for this repository. This document is intentionally implementation-oriented: it describes what is wired in code today, not a future-state concept diagram.

Text Diagram

┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐
│ Vue Frontend + Tauri Desktop  (`web/` + `tauri-app/`)  ── same API, browser or native shell   │
│                                                                                               │
│ Vue 3 + Vite + TypeScript + Pinia + Vue Router + i18n                                         │
│ Build output embedded into Go binary; desktop adds tray/window/notification shell             │
│                                                                                               │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌───────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐   │
│ │ChatView  │ │Providers │ │Channels  │ │Security   │ │Metrics   │ │Plugins   │ │Settings  │   │
│ │          │ │PoolMgmt  │ │Mgmt      │ │Dashboard  │ │Dashboard │ │Store     │ │Panels    │   │
│ └──────────┘ └──────────┘ └──────────┘ └───────────┘ └──────────┘ └──────────┘ └──────────┘   │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌───────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐   │
│ │Home /    │ │Users /   │ │Voice /   │ │Workflow / │ │Billing   │ │Audit     │ │Desktop   │   │
│ │Profile   │ │Tenants   │ │Speech    │ │Cron       │ │Panels    │ │Logs      │ │Tray/App  │   │
│ └──────────┘ └──────────┘ └──────────┘ └───────────┘ └──────────┘ └──────────┘ └──────────┘   │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌───────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐   │
│ │Memory    │ │Workspace │ │Companion │ │Preview /  │ │Remote    │ │DeepRes   │ │Approval  │   │
│ │Browser   │ │Panels    │ │Monitor   │ │Auth/SSO   │ │Access    │ │Tasks     │ │Dialogs   │   │
│ └──────────┘ └──────────┘ └──────────┘ └───────────┘ └──────────┘ └──────────┘ └──────────┘   │
│                                                                                               │
│ API + stores/composables: chat, proxy, provider pool, auth, memory, companion, voice, tauri   │
└ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
         │ HTTP / WebSocket / SSE / IPC
         │ (Browser SPA, desktop shell, channels, voice, and external clients share one runtime)
         ▼
╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║  Go Backend  (`server/`)                                                                                  ║
╠═══════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║                                                                                                           ║
║  ┌───────────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                        Gateway & Routing  (`bootstrap/routes.go`)                                 │    ║
║  │                                                                                                   │    ║
║  │  Echo Router ──► Middleware: Auth → Permission → CORS → PromptGuard → Logging → Metrics           │    ║
║  │                                                                                                   │    ║
║  │  ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐  Chat & Proxy API        │    ║
║  │  │ Conversations │ │  Chat         │ │  Models /     │ │  Embeddings   │                          │    ║
║  │  │  Messages     │ │  Streaming    │ │  Providers    │ │  `/v1/*`      │                          │    ║
║  │  └───────────────┘ └───────────────┘ └───────────────┘ └───────────────┘                          │    ║
║  │  ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐  Management API          │    ║
║  │  │  Users /      │ │  Settings /   │ │  Metrics /    │ │  Channels /   │                          │    ║
║  │  │  Auth / Keys  │ │  Config       │ │  System       │ │  Heartbeat    │                          │    ║
║  │  └───────────────┘ └───────────────┘ └───────────────┘ └───────────────┘                          │    ║
║  │  ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐  Feature API             │    ║
║  │  │  Agent / MCP  │ │  Plugins      │ │  Skills /     │ │  Browser /    │                          │    ║
║  │  │  DeepResearch │ │  Tool Store   │ │  Workflow     │ │  Memory / PPT │                          │    ║
║  │  └───────────────┘ └───────────────┘ └───────────────┘ └───────────────┘                          │    ║
║  │  ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐  Realtime & Edge         │    ║
║  │  │  SSE Events   │ │  Companion    │ │  Voice /      │ │  Approval /   │                          │    ║
║  │  │  `/api/v1/`   │ │  WebSocket    │ │  VoiceWake    │ │  Debug / WS   │                          │    ║
║  │  └───────────────┘ └───────────────┘ └───────────────┘ └───────────────┘                          │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║         ▼                                                                                                 ║
║  ┌───────────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  API Proxy Runtime  (`proxy/` + `proxybridge/`)                                   │    ║
║  │                                                                                                   │    ║
║  │  Web chat / agent / voice / deep research / external OpenAI clients / Anthropic SDK / Codex CLI   │    ║
║  │       │                                                                                           │    ║
║  │       ▼                                                                                           │    ║
║  │  Inbound API Formats                                                                              │    ║
║  │  ┌──────────────┐ ┌──────────────┐ ┌───────────────┐ ┌──────────────┐                             │    ║
║  │  │OpenAI Compat │ │Anthropic API │ │ Responses /   │ │ Embeddings   │                             │    ║
║  │  │chat/responses│ │  messages    │ │ Models API    │ │              │                             │    ║
║  │  └──────────────┘ └──────────────┘ └───────────────┘ └──────────────┘                             │    ║
║  │       │                                                                                           │    ║
║  │       ▼                                                                                           │    ║
║  │  ┌──────────┐   ┌──────────┐   ┌──────────┐   ┌──────────┐   ┌──────────┐                         │    ║
║  │  │  Auth    │──▶│  Prompt  │──▶│  Context │──▶│  Route   │──▶│ Upstream │                         │    ║
║  │  │  Gate    │   │  Guard   │   │  Pruner  │   │  Select  │   │ Provider │                         │    ║
║  │  │(api key) │   │(security)│   │(pruner/) │   │(pool/)   │   │          │                         │    ║
║  │  └──────────┘   └──────────┘   └──────────┘   └──────────┘   └──────────┘                         │    ║
║  │                                     │              │              │                               │    ║
║  │                                     ▼              ▼              ▼                               │    ║
║  │                               ┌──────────┐  ┌────────────┐  ┌──────────┐                          │    ║
║  │                               │  Score   │  │ route:auto │  │ Failover │                          │    ║
║  │                               │  Cache   │  │ route:tier │  │ Race /   │                          │    ║
║  │                               │(ecache2) │  │ route:local│  │ Breaker  │                          │    ║
║  │                               └──────────┘  └────────────┘  └──────────┘                          │    ║
║  │                                                                                                   │    ║
║  │  ┌─────────────────────────────────────────────────────────────────────────────────────┐          │    ║
║  │  │  Two-Level Cache (runtime cache)                                                    │          │    ║
║  │  │  ┌──────────────────────┐          ┌───────────────────────────────┐                │          │    ║
║  │  │  │  L1: In-Memory LRU   │  miss──▶ │  L2: Disk SQLite Cache        │                │          │    ║
║  │  │  │  (ecache2 sharded)   │          │  (cache/) optional            │                │          │    ║
║  │  │  │  prompt stats + fast │          │  survives restart             │                │          │    ║
║  │  │  └──────────────────────┘          └───────────────────────────────┘                │          │    ║
║  │  └─────────────────────────────────────────────────────────────────────────────────────┘          │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐                                           │    ║
║  │  │  Conn    │  │  Toggle  │  │  Model   │  │  Metrics │                                           │    ║
║  │  │  Pool    │  │  Store   │  │  Compat  │  │  Writer  │                                           │    ║
║  │  │  HTTP/2  │  │  HotLoad │  │  Layer   │  │  (stats) │                                           │    ║
║  │  └──────────┘  └──────────┘  └──────────┘  └──────────┘                                           │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Provider Pool  (`providerpool/`)  ── Unified provider management                 │    ║
║  │                                                                                                   │    ║
║  │  Provider Types:                                                                                  │    ║
║  │  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌──────────┐             │    ║
║  │  │ OpenAI  │ │Anthropic│ │ Gemini  │ │DeepSeek │ │Moonshot │ │  Azure  │ │OpenRouter│             │    ║
║  │  └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └──────────┘             │    ║
║  │  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐              │    ║
║  │  │ MiniMax │ │ Ollama  │ │  Grok   │ │  Qwen   │ │ Bedrock │ │  GLM    │ │ Custom  │              │    ║
║  │  └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘              │    ║
║  │  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐                                      │    ║
║  │  │  Trial  │ │  IDE    │ │  Codex  │ │ Cloud   │ │Copilot  │                                      │    ║
║  │  │ (quota) │ │(detect) │ │ OAuth   │ │ Code    │ │ OAuth   │                                      │    ║
║  │  └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘                                      │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐                                 │    ║
║  │  │  Health  │ │ Priority │ │  Rate    │ │  OAuth   │ │  Model   │                                 │    ║
║  │  │  Check   │ │  Route   │ │  Limit   │ │  & Usage │ │ Discover │                                 │    ║
║  │  │(circuit) │ │  Engine  │ │(per-prov)│ │ tracker  │ │(auto)    │                                 │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘                                 │    ║
║  │                                                                                                   │    ║
║  │  API Formats: OpenAI Compat │ Anthropic │ Ollama │ OAuth                                          │    ║
║  │  Storage: SQLite-backed provider pool; legacy JSON auto-migrated                                  │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Tool & Harness Runtime                                                           │    ║
║  │                                                                                                   │    ║
║  │  `tools.Registry` + `tools.Executor` + runtime `ToolGateway`                                      │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐                                 │    ║
║  │  │  File    │ │  Exec    │ │ Browser  │ │ Convert  │ │ Agents   │                                 │    ║
║  │  │ read/    │ │ shell /  │ │ web_*    │ │ OCR/PDF/ │ │ subagent │                                 │    ║
║  │  │ write    │ │ sessions │ │ tools    │ │ PPT/img  │ │ bridge   │                                 │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘                                 │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐                                              │    ║
║  │  │ Approval │ │ Question │ │ Harness  │ │   SSE    │                                              │    ║
║  │  │ runtime  │ │ manager  │ │ runs +   │ │ broker   │                                              │    ║
║  │  │ resolve  │ │ ask-user │ │ artifacts│ │ events   │                                              │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘                                              │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Context Pruner  (`pruner/`)  ── Smart context pruning                            │    ║
║  │                                                                                                   │    ║
║  │  Request ──▶ DetectType ──▶ Segmentize ──▶ Score (BM25) ──▶ SelectTopK ──▶ Pruned Output          │    ║
║  │                  │              │              │                │                                 │    ║
║  │                  ▼              ▼              ▼                ▼                                 │    ║
║  │            ┌──────────┐  ┌──────────┐   ┌──────────┐    ┌──────────┐                              │    ║
║  │            │  Code    │  │ Function │   │ IDF Pre- │    │  Token   │                              │    ║
║  │            │  Log     │  │ Paragraph│   │ Compute  │    │  Budget  │                              │    ║
║  │            │  Doc     │  │ Data     │   │ ecache2  │    │  Greedy  │                              │    ║
║  │            │  Data    │  │ Import   │   │ LRU Cache│    │  Select  │                              │    ║
║  │            └──────────┘  └──────────┘   └──────────┘    └──────────┘                              │    ║
║  │                                                                                                   │    ║
║  │  Backends: local (line) │ bm25 (segment) │ legacy IR hooks still present                          │    ║
║  │  Middleware: plugs into proxy, processes user/tool/system messages                                │    ║
║  │  Config: enabled=false, threshold=0.5, min_lines=50, cache=256 slots                              │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Agent Runtime  ── chat / agent / MCP orchestration                               │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐         │    ║
║  │  │ ChatHandler  │  │ Tool Gateway │  │ ContextPack  │  │ Agent Runner │  │ Session /    │         │    ║
║  │  │ conv/store   │  │ approvals +  │  │ SOUL + skill │  │ MCP / deep   │  │ TODO state   │         │    ║
║  │  │ stream loops │  │ call shaping │  │ + planner mem│  │ task runner  │  │compact/budget│         │    ║
║  │  └──────────────┘  └──────────────┘  └──────────────┘  └──────────────┘  └──────────────┘         │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐                           │    ║
║  │  │ Proxy Bridge │  │ ClaudeCode   │  │ SmallModel   │  │ Workflow /   │                           │    ║
║  │  │ proxy or llm │  │ system prompt│  │ short QA /   │  │ Cron hooks   │                           │    ║
║  │  │ fallback     │  │ + bootstrap  │  │ tool routing │  │ automation   │                           │    ║
║  │  └──────────────┘  └──────────────┘  └──────────────┘  └──────────────┘                           │    ║
║  │                                                                                                   │    ║
║  │  Agent Runner: context-pack grounding + planner-memory trace + isolated subagent delegation       │    ║
║  │                + post-task self-reflect -> lessons / memory writes / review proposals             │    ║
║  │                                                                                                   │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Memory & Intelligence                                                            │    ║
║  │                                                                                                   │    ║
║  │  ┌─────────────────────────────┐  ┌─────────────────────────────┐  ┌─────────────────────────┐    │    ║
║  │  │  Conversation Memory        │  │  Long-term Memory           │  │  Search & Recall        │    │    ║
║  │  │  (`memory.Store`)           │  │  (`memory/`)                │  │  vector / hybrid opt.   │    │    ║
║  │  │  ┌────────┐ ┌────────┐      │  │  ┌────────┐ ┌────────┐      │  │  ┌────────┐ ┌─────────┐ │    │    ║
║  │  │  │Convs   │ │Messages│      │  │  │Daily   │ │Layered │      │  │  │FTS5    │ │sqlite-  │ │    │    ║
║  │  │  │titles  │ │history │      │  │  │logs    │ │memory  │      │  │  │keyword │ │vec      │ │    │    ║
║  │  │  └────────┘ └────────┘      │  │  └────────┘ └────────┘      │  │  │search  │ │hybrid   │ │    │    ║
║  │  │  ┌────────┐ ┌────────┐      │  │  ┌────────┐ ┌────────┐      │  │  └────────┘ └─────────┘ │    │    ║
║  │  │  │CmdState│ │Compact │      │  │  │Import /│ │Export /│      │  │  recall API + embeddings│    │    ║
║  │  │  │/ TODO  │ │summary │      │  │  │append  │ │prune   │      │  └─────────────────────────┘    │    ║
║  │  │  └────────┘ └────────┘      │  │  └────────┘ └────────┘      │                                 │    ║
║  │  └─────────────────────────────┘  └─────────────────────────────┘                                 │    ║
║  │                                                                                                   │    ║
║  │  Workspace: `workspace/` + `contextpack/` + embedded `SKILL.md` release                           │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Channel Adapters  (`channel/`)  ── Multi-channel messaging                       │    ║
║  │                                                                                                   │    ║
║  │  ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐          │    ║
║  │  │  Web   │ │Telegram│ │Discord │ │ Slack  │ │ WeChat │ │ Feishu │ │ Matrix │ │iMessage│          │    ║
║  │  │(built) │ │        │ │        │ │        │ │  Work  │ │ /Lark  │ │        │ │        │          │    ║
║  │  └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘          │    ║
║  │  ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐          │    ║
║  │  │WhatsApp│ │ Signal │ │ Teams  │ │Matter- │ │  Blue  │ │  Zalo  │ │DingTalk│ │ Google │          │    ║
║  │  │        │ │        │ │        │ │ most   │ │Bubbles │ │        │ │        │ │  Chat  │          │    ║
║  │  └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘          │    ║
║  │  ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐          │    ║
║  │  │  LINE  │ │Messengr│ │  Next  │ │ Nostr  │ │   QQ   │ │ Twitch │ │Twitter │ │ Viber  │          │    ║
║  │  │        │ │        │ │  cloud │ │        │ │        │ │        │ │        │ │        │          │    ║
║  │  └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘          │    ║
║  │  ┌────────┐                                                                                       │    ║
║  │  │Instagrm│                                                                                       │    ║
║  │  │        │                                                                                       │    ║
║  │  └────────┘                                                                                       │    ║
║  │                                                                                                   │    ║
║  │  Manager: central registry, auto-reconnect, message queue                                         │    ║
║  │  Humanizer (`humanizer/`): Markdown → natural text (IM mode / Voice mode)                         │    ║
║  │  AutoReply (`autoreply/`): rule-based auto-response                                               │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Security Layer  (`security/` + `auth/` + `permission/`)                          │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐       │    ║
║  │  │  JWT     │ │ API Keys │ │ Password │ │  MFA     │ │ WebAuthn │ │  OIDC    │ │  RBAC    │       │    ║
║  │  │  Auth    │ │ Scoped   │ │ Argon2id │ │  TOTP    │ │ Passkeys │ │ Provider │ │ Roles    │       │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘       │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐       │    ║
║  │  │ Permit   │ │ ExtAuth  │ │ Prompt   │ │ Sandbox  │ │ Approval │ │  Audit   │ │ TLS/ACME │       │    ║
║  │  │ page ACL │ │ headers  │ │ Guard    │ │ exec iso │ │ tool/exec│ │  trail   │ │ renew    │       │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘       │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐                                              │    ║
║  │  │ Threat   │ │ Firewall │ │  FS Safe │ │ Secrets  │                                              │    ║
║  │  │ detector │ │ origin   │ │ path chk │ │ encrypt  │                                              │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘                                              │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Voice & Speech Pipeline  (`voice/` + `tts/` + `stt/` + `speech/`)                │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐                    │    ║
║  │  │  Voice   │ │    WS    │ │   STT    │ │  Chat /  │ │   TTS    │ │VoiceWake │                    │    ║
║  │  │ sessions │ │  audio   │ │ routing  │ │  proxy   │ │ routing  │ │ triggers │                    │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘                    │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐                    │    ║
║  │  │ macOS    │ │ Windows  │ │ Whisper  │ │ Edge TTS │ │ Local /  │ │  Cache   │                    │    ║
║  │  │ native   │ │ native   │ │ models   │ │ stream   │ │ speaker  │ │  audio   │                    │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘                    │    ║
║  │                                                                                                   │    ║
║  │  Voice request ──▶ STT (native / Whisper) ──▶ Chat / Proxy Runtime ──▶ TTS (Edge / local)         │    ║
║  │  Session: per-user │ States: Idle→Listening→Processing→Speaking │ VoiceWake background target     │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Observability & Agents                                                           │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────────────────────┐  ┌──────────────────────────┐  ┌──────────────────────────┐         │    ║
║  │  │  Metrics  (`metrics/`)   │  │ Heartbeat (`heartbeat/`) │  │  Companion (`companion/`)│         │    ║
║  │  │  ┌────────┐ ┌────────┐   │  │  ┌────────┐ ┌────────┐   │  │  ┌────────┐ ┌────────┐   │         │    ║
║  │  │  │CPU/Mem │ │API Call│   │  │  │Periodic│ │HEART-  │   │  │  │Realtime│ │Session │   │         │    ║
║  │  │  │GC/Gortn│ │Token $ │   │  │  │Poll    │ │BEAT.md │   │  │  │Events  │ │Monitor │   │         │    ║
║  │  │  └────────┘ └────────┘   │  │  └────────┘ └────────┘   │  │  └────────┘ └────────┘   │         │    ║
║  │  │  SQLite writer + trend   │  │  Dedup + active hours    │  │  WebSocket + JSONL       │         │    ║
║  │  └──────────────────────────┘  └──────────────────────────┘  └──────────────────────────┘         │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Plugin & Skill System  (`plugin/` + `skill/` + `skillstore/`)                    │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────────────────────┐  ┌──────────────────────────┐  ┌──────────────────────────┐         │    ║
║  │  │  Plugin Runtime          │  │  Skill Registry          │  │  Skill Market            │         │    ║
║  │  │  ┌────────┐ ┌────────┐   │  │  ┌────────┐ ┌────────┐   │  │  ┌────────┐ ┌────────┐   │         │    ║
║  │  │  │Go      │ │  JS    │   │  │  │Embed   │ │ Local  │   │  │  │Browse  │ │Install │   │         │    ║
║  │  │  │Native  │ │disabled│   │  │  │skills  │ │ scan   │   │  │  │Update  │ │& Risk  │   │         │    ║
║  │  │  └────────┘ └────────┘   │  │  │SKILL.md│ │help cmd│   │  │  │Cache   │ │checks  │   │         │    ║
║  │  │  deps + restrictions     │  │  └────────┘ └────────┘   │  │  └────────┘ └────────┘   │         │    ║
║  │  └──────────────────────────┘  └──────────────────────────┘  └──────────────────────────┘         │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Integrations & Automation                                                        │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐       │    ║
║  │  │ Browser  │ │  Home    │ │  Cron    │ │ Workflow │ │ Convert  │ │  Tunnel  │ │  Backup  │       │    ║
║  │  │ (Rod)    │ │Assistant │ │ Schedule │ │  nodes   │ │ OCR/PDF/ │ │Ngrok /   │ │ Restore  │       │    ║
║  │  │ lazy init│ │  REST    │ │          │ │          │ │ PPT/x2t  │ │ Cloudfl. │ │ snapshots│       │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘       │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐                                              │    ║
║  │  │ WebPush  │ │ Webhook  │ │ MediaGen │ │ Preview  │                                              │    ║
║  │  │ VAPID    │ │ targets  │ │ image /  │ │ userdata │                                              │    ║
║  │  │ sender   │ │          │ │ cards    │ │ bridge   │                                              │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘                                              │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Worker & Scheduler  (`workerpool/` + `scheduler/`)                              │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐                                 │    ║
║  │  │   IO     │ │ Compute  │ │ Priority │ │ Schedule │ │ Task DB  │                                 │    ║
║  │  │  Pool    │ │  Pool    │ │ queues   │ │ engine   │ │ sqlite   │                                 │    ║
║  │  │ worker   │ │ worker   │ │ low→crit │ │ retry/DAG│ │ persist  │                                 │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘                                 │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐                                              │    ║
║  │  │ Pending  │ │ Running  │ │Complete/ │ │ Deferred │                                              │    ║
║  │  │ queue    │ │ stats    │ │Cancel    │ │ jobs /   │                                              │    ║
║  │  │ submit   │ │ metrics  │ │ states   │ │ resume   │                                              │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘                                              │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Core Runtime                                                                     │    ║
║  │                                                                                                   │    ║
║  │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐                    │    ║
║  │  │Lifecycle │ │  Worker  │ │  Config  │ │  Logger  │ │  Update  │ │  SysInfo │                    │    ║
║  │  │ Manager  │ │  Pool    │ │ YAML+KV  │ │ zerolog/ │ │  OTA     │ │  mem/cpu │                    │    ║
║  │  │ graceful │ │ priority │ │ hot-load │ │   zap    │ │ channels │ │  process │                    │    ║
║  │  └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘                    │    ║
║  │                                                                                                   │    ║
║  │  GC tuned at boot │ SQLite recovery + WAL │ lazy background services keep startup fast            │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║         │                                                                                                 ║
║  ┌──────┴────────────────────────────────────────────────────────────────────────────────────────────┐    ║
║  │                  Data Layer                                                                       │    ║
║  │                                                                                                   │    ║
║  │  ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐   │    ║
║  │  │  SQLite (WAL)  │ │ blue.db tables │ │ workspace/     │ │ plugin-cache/  │ │ models/ +      │   │    ║
║  │  │  blue.db       │ │ context anns   │ │ SOUL.md        │ │ backups/       │ │ vector store   │   │    ║
║  │  │ users/auth     │ │ shared runtime │ │ memory md      │ │ restore state  │ │ Whisper/OCR    │   │    ║
║  │  │ conv/provider  │ │                │ │ skills/media   │ │                │ │ sqlite-vec/FTS │   │    ║
║  │  │ config/harness │ │                │ │                │ │                │ │ hybrid search  │   │    ║
║  │  └────────────────┘ └────────────────┘ └────────────────┘ └────────────────┘ └────────────────┘   │    ║
║  └───────────────────────────────────────────────────────────────────────────────────────────────────┘    ║
║                                                                                                           ║
╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════╝
         │
         ▼
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│  External Services                                                                                        │
│                                                                                                           │
│  LLM Providers                                                                                            │
│  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐          │
│  │ OpenAI  │ │Anthropic│ │ Gemini  │ │DeepSeek │ │Moonshot │ │  Azure  │ │OpenRout.│ │ MiniMax │          │
│  └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘          │
│  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐          │
│  │  Ollama │ │  Grok   │ │  Qwen   │ │ Bedrock │ │  GLM    │ │  Codex  │ │CloudCode│ │ Custom  │          │
│  └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘          │
│                                                                                                           │
│  Channels (IM / Social)                                                                                   │
│  ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐                  │
│  │Telegram│ │Discord │ │ Slack  │ │ WeChat │ │ Feishu │ │ Matrix │ │iMessage│ │WhatsApp│                  │
│  └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘                  │
│  ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐                  │
│  │ Signal │ │ Teams  │ │Matter- │ │  Zalo  │ │DingTalk│ │ Google │ │  LINE  │ │Messengr│                  │
│  │        │ │        │ │ most   │ │        │ │        │ │  Chat  │ │        │ │        │                  │
│  └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘                  │
│  ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐                                        │
│  │  Next  │ │ Nostr  │ │   QQ   │ │ Twitch │ │Twitter │ │ Viber  │                                        │
│  │  cloud │ │        │ │        │ │        │ │        │ │        │                                        │
│  └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘                                        │
│                                                                                                           │
│  Remote Access (tunnel/)                                                                                  │
│  ┌──────────┐ ┌──────────┐                                                                                │
│  │  Ngrok   │ │Cloudflare│                                                                                │
│  │          │ │  Tunnel  │                                                                                │
│  └──────────┘ └──────────┘                                                                                │
│                                                                                                           │
│  Infrastructure                                                                                           │
│  ┌──────────┐ ┌──────────┐                                                                                │
│  │  Let's   │ │ Edge TTS │                                                                                │
│  │ Encrypt  │ │ (MS TTS) │                                                                                │
│  └──────────┘ └──────────┘                                                                                │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────┘

System Topology

Clients and surfaces
  - Browser SPA (`web/`)
  - Tauri desktop shell (`tauri-app/`)
  - CLI and socket IPC (`blue ...`, `sockipc`)
  - Channels, voice, webhooks, remote access
                                    |
                                    | HTTP / WebSocket / SSE / IPC
                                    v
+-----------------------------------------------------------------------------------+
| Go runtime (`server/`)                                                            |
|                                                                                   |
| Edge and assembly                                                                 |
|   `cmd/blue` + `internal/server` + `internal/bootstrap` + `internal/web`          |
|   - Echo router                                                                   |
|   - auth, API keys, page permissions                                              |
|   - static SPA serving                                                            |
|   - SSE and WebSocket endpoints                                                   |
|                                                                                   |
| Product services                                                                  |
|   chat, agent, deep research, workflow, cron, browser, media, companion, memory   |
|                                                                                   |
| Tool and execution plane                                                          |
|   `tools.Registry` + `tools.Executor` + approvals + `harness.Controller`          |
|                                                                                   |
| Inference plane                                                                   |
|   `server.ChatHandler` / `agent.Runner` / `voice.Service`                         |
|      -> `proxybridge.Bridge`                                                      |
|      -> `proxy.ProxyHandler`                                                      |
|      -> `providerpool.Router`                                                     |
|      -> upstream model providers                                                  |
|   fallback: direct `llm.ProviderRegistry` when proxy is disabled                  |
|                                                                                   |
| State plane                                                                       |
|   SQLite, kvstore-backed config, workspace files, markdown memory, vector store,  |
|   media artifacts, models, backups                                                |
+-----------------------------------------------------------------------------------+

Runtime Modes

  • Server mode. server/cmd/blue starts the full Go runtime and serves both API and the Vue SPA from the same process.
  • Desktop mode. tauri-app/ owns the native window, tray, notifications, and launches or embeds the Go runtime:
    • macOS and Windows use the CGO/FFI path.
    • Linux launches a blue-server sidecar and points the WebView at http://localhost:{port}.
  • CLI and IPC mode. Fast-path CLI dispatch handles lightweight commands before Cobra bootstraps the full server; longer-running skill and tool style commands are bridged through sockipc.

Boot Sequence

  1. bootstrap.TuneGC() applies Go runtime memory tuning.
  2. Config is loaded from YAML, then imported or overlaid into the SQLite-backed config.Store.
  3. Logger, lifecycle manager, worker pool, and blue.db are initialized.
  4. SQLite opens through database.OpenSQLiteWithRecovery, enabling WAL and recovery logic before services attach.
  5. Core services are created: users, auth, permissions, API keys, memory store, tool registry, skill registry, plugin registry, and server.ChatHandler.
  6. Background or lazy services are started: metrics, backup, OCR/PDF, browser, cron, workflow, push, speech, voice, companion, ngrok, and provider pool refresh.
  7. Workspace files and embedded assets are released under {dataDir}/workspace, including context packs and bundled SKILL.md files.
  8. bootstrap.RegisterAllRoutes mounts the API, proxy, SSE, WebSocket, IPC, and static frontend routes.
  9. HTTP starts first; provider model refresh, OAuth auto-refresh, and other deferred tasks hook into server.OnServerStart.

Major Layers

Layer Primary packages Responsibility
Runtime assembly cmd/blue, internal/bootstrap, internal/server Startup, dependency wiring, Echo server, TLS, route registration
Frontend and shell web, tauri-app, internal/web Vue SPA, desktop shell, localhost WebView binding, static asset serving
Identity and security auth, permission, rbac, mfa, password, oidc, security, sandbox, promptguard, api JWT/API key auth, page permissions, approvals, security checks, sandbox integration
Chat and agent runtime server, agent, deepresearch, claudecode, contextpack, session Conversation orchestration, system prompt building, context-pack grounding, agent execution, isolated subagent delegation, post-task reflection, session compaction
Tool and execution plane tools, browser, convert, mediagen, ppt, workflow, cron, push, harness, workspace Tool registry, browser and file tools, approvals, tracked runs, automation
Inference routing proxy, proxybridge, providerpool, llm, pruner, gateway OpenAI/Anthropic-style proxying, request normalization, provider routing, failover, context pruning
Memory and knowledge memory, embedding, skill, skillstore, plugin Conversation storage, markdown memory, vector search, skills, plugins, skill catalog
Integrations and I/O channel, autoreply, humanizer, voice, speech, stt, tts, voicewake, webhook, ngrok, tunnel, companion, heartbeat IM channels, speech pipeline, webhook and tunnel integrations, event streaming
Persistence and ops database, kvstore, backup, metrics, update, logger SQLite access, config persistence, recovery, metrics, OTA/update concerns, logging

Core Request Flows

Web and Desktop Chat

Vue route (`/chat`) or desktop WebView
  -> `/api/v1/conversations/*` and related chat APIs
  -> `server.ChatHandler`
  -> memory/session/tool orchestration + system prompt/context packs
  -> `proxybridge.Bridge` when proxy is enabled
     or direct `llm.ProviderRegistry` fallback
  -> upstream provider
  -> streaming response + conversation persistence + metrics + audit + SSE updates

Agent Runner

Chat task / agent task / harness-backed agent execution
  -> `agent.Runner`
  -> system prompt bootstrap + context-pack resolution + planner-memory recall
     - context packs and annotations are injected as grounded prompt context
     - planner-memory traces emit used/skipped/filtered task events
  -> tool execution through `tools.Registry` / `tools.Executor`
  -> optional `subagents` tool
     -> harness-backed child run
     -> isolated worker-style execution with shared workspace and bounded policy
  -> task completion or failure
  -> optional `self_reflect`
     -> summarize outcome from recorded plan + verification output
     -> extract grounded lessons
     -> optional memory writes and review-only proposals

OpenAI-Compatible Proxy

External client
  -> `/v1/chat/completions` | `/v1/messages` | `/v1/embeddings` | `/v1/models`
  -> API key validation + session tracking
  -> optional pruner, routing rules, model router, prompt cache, masking
  -> `providerpool.Router` selection + failover/provider race
  -> upstream format conversion and dispatch
  -> normalized response or SSE stream back to caller

Important detail: in the current implementation the proxy is an in-process handler mounted on Echo routes, not a mandatory separate microservice. Internal features reuse the same path through proxybridge.

Tool, Approval, and Harness Flow

Chat / agent / workflow issues a tool call
  -> `tools.Registry` + `tools.Executor`
  -> approval-aware exec/file/browser/image/pdf/tts tools
  -> approval or question event over SSE
  -> optional `harness.Controller` persists run tree, events, and artifacts
  -> result returns to chat, agent, workflow, or IPC caller

Voice Flow

`/api/v1/voice/*` HTTP or WebSocket audio
  -> `voice.Service`
  -> STT provider
     - native macOS / Windows ASR when available
     - Whisper-based fallback otherwise
  -> chat function routed through `proxybridge.Bridge`
  -> `speech` / `tts` provider
  -> synthesized audio or transcript response

Harness Architecture

Harness is the durable execution and evaluation control plane for tracked agent-style work in Blue. It is not just a diagnostics layer: the current implementation uses it to submit runs, persist execution trees, materialize reusable evaluations, score outcomes, compare candidates to baselines, and enforce release gates for tool-to-skill migration.

Harness Diagram

╔══════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ Harness Control Plane (`server/internal/harness/` + `server/internal/bootstrap/`)                        ║
╠══════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║                                                                                                          ║
║  Entry Surfaces                                                                                          ║
║  ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐                    ║
║  │ Harness API  │ │ Agent Compat │ │ Research /   │ │ `blue` CLI   │ │ Web Harness  │                    ║
║  │ `/api/v1/*`  │ │ `/tasks/*`   │ │ Workflow     │ │ `harness`    │ │ pages/report │                    ║
║  └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘                    ║
║                                   │                                                                      ║
║                                   ▼                                                                      ║
║  Runtime Bundle  (`HarnessRuntimeBundle`)                                                                ║
║  ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐                    ║
║  │SQLiteStore   │ │Controller    │ │Group         │ │Observer /    │ │Subagent +    │                    ║
║  │runs/groups/  │ │policy +      │ │Dispatcher    │ │RunTrace      │ │write/exec    │                    ║
║  │evals/reports │ │driver mux    │ │lease worker  │ │collectors    │ │guards        │                    ║
║  └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘                    ║
║                                   │                                                                      ║
║          ┌────────────────────────┴─────────────────────────┐                                            ║
║          ▼                                                  ▼                                            ║
║  Single Run Path                                   Eval Materialization                                  ║
║  `RunSpec` -> normalize -> policy ->              `Dataset` -> `DatasetVersion` -> `EvalSpec`            ║
║  approval -> execute by `RunKind` -> finalize     -> `RunGroup` + `RunGroupItem` -> `EvalRun`            ║
║  Kinds: agent_task / research / subagent /        Built-in datasets feed selector and execution lanes    ║
║  workflow                                          and batch migration programs.                         ║
║                                   │                                                                      ║
║                                   ▼                                                                      ║
║  Batch Execution + Scoring                                                                               ║
║  claim leased item -> build per-item `RunSpec` -> `Submit()` -> wait terminal run -> verify ->           ║
║  score (rule / ground-truth / judge) -> `Scorecard` + checkpoint artifact -> group/eval report           ║
║                                   │                                                                      ║
║                                   ▼                                                                      ║
║  Comparison + Release Gates                                                                              ║
║  compare target vs baseline/prior eval -> selector gate -> execution gate -> budget gate ->              ║
║  cutover readiness (candidate id + consecutive passing runs)                                             ║
║                                   │                                                                      ║
║                                   ▼                                                                      ║
║  SQLite Ledger                                                                                           ║
║  `harness_runs` / events / artifacts / `harness_run_groups` / items / `harness_scorecards`               ║
║  `harness_datasets` / versions / `harness_eval_specs` / `harness_eval_runs` / baselines / reports        ║
╚══════════════════════════════════════════════════════════════════════════════════════════════════════════╝

What Harness Owns

  • Single execution units. Run is the base execution primitive for agent tasks, research jobs, workflow runs, and subagent runs. Parent/child relationships are persisted so the run tree remains queryable after execution.
  • Guarded runtime submission. Before dispatch, the controller moves a run through normalized stages such as normalize, policy, approval, execute, and finalize, and records stage events for later inspection.
  • Batch and evaluation materialization. Reusable dataset manifests are frozen into DatasetVersion, bound into EvalSpec, and then expanded into concrete RunGroupItem attempts when an EvalRun is submitted.
  • Unified scoring and reporting. Terminal runs are verified, scored, and summarized into Scorecard, group reports, eval reports, artifacts, runtime evidence, and checkpoint payloads.
  • Release gating. The same stored eval reports feed selector, execution-equivalence, budget, and cutover-readiness checks, so migration decisions use persisted evidence instead of ad hoc spot checks.

End-to-End Process

  1. A caller enters through the harness API, an existing compatibility surface such as agent tasks or deep research, or the blue harness CLI.
  2. bootstrap assembles the runtime bundle, wiring the controller, store, dispatcher, observer, traces, and guard helpers into the protected server routes.
  3. For a single run, the controller validates the RunSpec, resolves policy defaults, picks the registered driver for the requested RunKind, creates the run row, and starts execution while appending lifecycle events and artifacts.
  4. For a reusable eval, the flow is Dataset -> DatasetVersion -> EvalSpec; submitting the eval materializes a concrete RunGroup and RunGroupItem set, then persists an EvalRun that points at that group. The group is the execution container, while the eval objects remain the reusable and auditable platform layer.
  5. The GroupDispatcher polls queued groups, claims runnable items with leases, builds a per-item RunSpec, submits it through the same controller path, waits for terminal status, then verifies and scores the result.
  6. Scoring can short-circuit on deterministic verification failure, otherwise it uses rule checks first, ground-truth checks where available, and judge scoring or heuristic fallback when deterministic evidence is insufficient.
  7. Persisted eval reports can then be compared against a baseline or a prior eval run. Blue uses that comparison data to run selector, execution-equivalence, and budget gates, and finally aggregates those lane results into a cutover-readiness decision that requires repeated passing candidate runs.

Built-In Harness Programs

  • Selector gate. Uses the built-in multilingual selector dataset to detect routing regressions, critical-case failures, route drift, and clarify-rate drift before selector changes are promoted.
  • Execution equivalence gate. Uses the batch-1 execution dataset to confirm that migrated skill flows still complete correctly relative to a baseline.
  • Budget gate. Measures native tool-surface shrinkage, schema-byte reduction, latency drift, and allowed final native tools during tool-to-skill cutover work.
  • Cutover readiness. Combines recent selector, execution, and budget assessments for a candidate and requires consecutive passing runs before a cutover is considered ready.

Frontend and Desktop Composition

  • web/ is a Vue 3 + Vite + TypeScript SPA with Pinia, Vue Router, and Vue I18n.
  • The router covers chat, home, settings, providers, channels, automation, voice, users, plugins, and preview-aware auth flows.
  • internal/web serves the built SPA with SPA fallback semantics and cache-control rules for hashed assets versus HTML.
  • tauri-app injects desktop markers into localhost pages, manages main and quick-panel windows, system tray actions, and native notifications.
  • In desktop mode the frontend still talks to the same localhost API surface; there is no separate desktop-only API.

State and Persistence

Location Purpose
{dataDir}/blue.db Primary SQLite database: users, API keys, permissions, conversations, config KV, provider pool tables, harness state, context-pack annotations, and other shared runtime data
Optional SQLite stores Metrics and session audit can use dedicated SQLite files when configured, but default to shared DB usage where possible
{dataDir}/workspace/ User-editable runtime workspace: persona/context files such as SOUL.md, released context packs, markdown memory content, and related artifacts
Legacy migrated SQLite files Older installs may contain archived contextpacks.db.migrated* artifacts after import into blue.db
Memory vector store path Resolved from memory config for hybrid memory search and embeddings
{dataDir}/media/ Generated images, browser captures, and other media task artifacts
{dataDir}/models/ Whisper, OCR, embedding, and other downloadable local model assets
{dataDir}/backups/ Backup snapshots and restore staging used by auto-recovery
{dataDir}/plugin-cache/ Downloaded and cached plugin artifacts

Package Map

Entry and edge

  • server/cmd/blue: main entrypoint, CLI dispatch, server startup
  • server/internal/bootstrap: service and route assembly
  • server/internal/server: Echo wrapper, chat handlers, API handlers
  • server/internal/web: static SPA discovery, extraction, and serving
  • tauri-app/src-tauri: desktop host runtime

Inference and routing

  • server/internal/proxy: /v1/* proxy handler, routing, failover, cache stats, masking, request normalization
  • server/internal/proxybridge: bridge that lets internal runtime code call the proxy as an llm backend
  • server/internal/providerpool: provider registry, model discovery, routing, health checks, OAuth, pricing, usage tracking
  • server/internal/llm: direct provider implementations for fallback and internal use
  • server/internal/pruner: local context-pruning middleware and management API

Tool and agent runtime

  • server/internal/tools: built-in tools, exec safety, approvals, browser adapters, tool gateway
  • server/internal/agent: agent runner, planner-memory grounding, isolated subagent delegation, agent-facing APIs, reflection hooks
  • server/internal/harness: tracked run controller, child-run policy, artifact and event persistence
  • server/internal/cron, workflow, push, browser, convert, mediagen, ppt: automation and execution integrations
  • server/internal/skill: Go skill registry and embedded skill assets

Memory and workspace

  • server/internal/memory: SQLite conversation store, markdown backend, layered memory, vector store, hybrid search
  • server/internal/session: session isolation, compaction, persistence hooks
  • server/internal/contextpack: workspace context packs, annotation-backed resolver, and prompt grounding inputs
  • server/internal/workspace: managed runtime workspace layout

Security and governance

  • server/internal/auth, permission, rbac, mfa, password, oidc, extauth: identity and access control
  • server/internal/security, sandbox, promptguard: runtime security features
  • server/internal/api: cross-runtime APIs such as approval resolution

Integrations

  • server/internal/channel, autoreply, humanizer: multi-channel delivery and rendering
  • server/internal/voice, speech, stt, tts, voicewake: speech stack
  • server/internal/ngrok, tunnel, webhook, companion, heartbeat: external integrations and background monitoring

Implementation Notes

  • The provider pool is SQLite-backed by default and auto-migrates legacy JSON data when a DB-backed pool is used.
  • The public pruner surface is effectively local-backend only; removed historical backends are still referenced in some legacy code paths and tests.
  • Bundled skills are sourced from assets/skills/, copied into server/internal/skill/embedded/, and released into the runtime workspace at startup.
  • The browser service, pruner middleware, vector memory backend, and some speech/model features are intentionally lazy so startup stays fast.