Architecture
CLI-JAW is a Node.js 22 orchestration runtime with CLI, TUI, Web, Telegram, Discord, Dashboard, and Electron desktop surfaces. The canonical internal map lives in structure/; this page is a public overview.
System Overview
The core server is a small Express glue layer. server.ts is 593 lines and delegates to extracted route modules plus mounted sub-routers. The current surface is 201 handlers including the root page, with 200 API/media endpoints.
CLI / TUI / Web / Telegram / Discord / Electron
│
├─ HTTP commands and REST APIs
├─ SSE events: GET /api/events
└─ WebSocket fallback for legacy clients
↓
server.ts → src/routes/*
├─ src/core/ config, db, auth, event fan-out
├─ src/agent/ CLI process runtime and event adapters
├─ src/orchestrator/ IPABCD, worker registry, dispatch
├─ src/goal/ durable goals and continuation evidence
├─ src/memory/ structured memory, FTS5, task snapshot
├─ src/browser/ CDP, adaptive fetch, web-ai automation
├─ src/messaging/ channel send and transport registry
└─ src/jaw-ceo/ OpenAI Realtime CEO channel
jaw dashboard serve → src/manager/ → public/manager/
Runtime Surfaces
| Surface | Entry Point | Notes |
|---|---|---|
| Root CLI | bin/cli-jaw.ts | 26 root router cases, grouped user-facing surfaces such as chat search, browser web-ai, and dashboard federation. |
| Slash commands | src/cli/commands.ts | 40 commands; CLI/Web/Telegram/Discord visibility is policy-driven. |
| Web UI | public/index.html | Vanilla TypeScript modules, Vite 8, SSE-first event channel. |
| Manager dashboard | public/manager/ | React 19 dashboard for instances, notes, board, reminders, schedule, diff, memory, and CEO panels. |
| Electron desktop | electron/ | Packages a Node.js 22 sidecar and prefers bundled server/bin/jaw before global CLI discovery. |
| Telegram / Discord | src/telegram/, src/discord/ | Both use the shared messaging runtime and canonical /api/channel/send. |
Events
Current Web delivery is SSE-first. src/core/event-bus.ts stores a replay buffer, src/routes/events.ts exposes GET /api/events, and public/js/event-channel.ts handles Last-Event-ID replay, replay_gap, and fallback. public/js/ws.ts remains the shared dispatcher and legacy WebSocket path.
Current Counts
| Area | Current Count |
|---|---|
src/routes/ | 32 TypeScript files, 201 handlers including / |
src/core/ | 30 files, 3803 lines |
src/agent/ | 29 root TS files plus spawn/events submodules |
src/browser/web-ai/ | 68 TypeScript files |
src/browser/adaptive-fetch/ | 19 TypeScript files |
bin/commands/ | 30 top-level TypeScript files plus 9 TUI helper files |
public/js/ | 86 TypeScript modules |
public/manager/src/ | 300 source files |
electron/src/ | 27 TypeScript/TSX files |
Verification
Architecture docs are checked by the structure scripts:
bash structure/verify-counts.sh
bash structure/check-doc-drift.sh
verify-counts.sh validates every file-tree (NNNL) entry in structure/str_func.md, plus curated aggregate counts. check-doc-drift.sh validates command counts, route tables, and event inventory.
structure/INDEX.md, then read structure/str_func.md, structure/server_api.md, structure/commands.md, and structure/stream-events.md.