Architecture
CLI-JAW is a Node.js server with 141 API endpoints across 15 route modules. Four interfaces (CLI, Web, Telegram, Discord) connect through a central server that dispatches to agents, orchestration, memory, and browser subsystems.
System Overview
All four interfaces pass through server.ts, which handles authentication, security, WebSocket, and bootstrap before delegating to route modules in src/routes/.
CLI (bin/commands/*) ──HTTP──→ server.ts (glue)
Web (public/) ──HTTP+WS→ │
Telegram Bot ──HTTP──→ │
Discord Bot ──HTTP──→ │
↓
Dashboard (port 24576) ─scan/proxy→ src/manager/
│
src/routes/* ──┤──→ src/core/
├──→ src/agent/
├──→ src/orchestrator/
├──→ src/prompt/
├──→ src/memory/
├──→ src/messaging/
├──→ src/telegram/
├──→ src/discord/
└──→ src/browser/
Four Interfaces
| Interface | Entry Point | Transport |
|---|---|---|
| CLI | bin/cli-jaw.ts + bin/commands/*.ts | HTTP to server |
| Web UI | public/index.html | HTTP + WebSocket |
| Telegram | src/telegram/bot.ts | Grammy bot polling |
| Discord | src/discord/bot.ts | discord.js gateway |
Route Modules
The server registers 15 route modules. Each is a self-contained registrar function that receives the Express app and auth middleware.
| Module | Routes | Responsibility |
|---|---|---|
server.ts (base) | 14 | Health, session, messages, auth, command, stop, clear |
settings.ts | 18 | Settings, prompt, heartbeat-md, MCP, CLI registry, quota |
browser.ts | 41 | Browser primitives, tab management, web-ai automation |
memory.ts | 13 | Memory runtime, KV store, memory files |
jaw-memory.ts | 11 | Jaw memory search, read, save, soul, flush, reflect |
orchestrate.ts | 11 | PABCD state, workers, dispatch, queue management |
goal.ts | 3 | Durable goal state, history |
goal-run.ts | 3 | Bounded goal-run lifecycle |
messaging.ts | 6 | Upload, file open, voice, channel send |
employees.ts | 5 | Employee CRUD and reset |
skills.ts | 5 | Skills list, enable, disable, reset |
avatar.ts | 4 | Agent/user avatar image management |
traces.ts | 3 | Public trace summary and event read |
heartbeat.ts | 2 | Heartbeat GET and validated PUT |
i18n.ts | 2 | Language list and locale bundles |
File Tree Overview
cli-jaw/
├── bin/ # CLI entry + 23 command files
│ ├── cli-jaw.ts # Root CLI router
│ └── commands/ # serve, init, doctor, chat, browser, ...
├── server.ts # Express/WS bootstrap (882L)
├── src/
│ ├── core/ # 21 files — config, DB, bus, i18n, employees
│ ├── agent/ # 37 files — spawn, events, lifecycle, ACP
│ ├── orchestrator/ # 10 files — PABCD pipeline, state machine
│ ├── prompt/ # builder + templates
│ ├── memory/ # 13 files — runtime, indexing, flush, identity
│ ├── cli/ # registry, commands, handlers, ACP client
│ ├── messaging/ # shared Telegram/Discord runtime
│ ├── telegram/ # Telegram bot transport
│ ├── discord/ # Discord bot transport
│ ├── browser/ # CDP control + web-ai automation
│ ├── routes/ # 15 route registrars
│ ├── manager/ # Dashboard server (77 TS/TSX files)
│ ├── security/ # Path guards, input validation
│ └── shared/ # Tool-log sanitization
├── public/ # Web UI (Vanilla TS + Vite 8)
│ ├── js/ # 80 TypeScript modules
│ ├── css/ # 11 CSS files
│ ├── manager/ # React 19 dashboard app (286 files)
│ └── dist/ # Build output
├── native/ # jaw-claude-i Rust helper
│ └── jaw-claude-i/ # 15 Rust source files
└── tests/ # 447 test files
Core Subsystems
| Subsystem | Location | Responsibility |
|---|---|---|
| Agent Runtime | src/agent/ | Spawn CLI processes, stream NDJSON events, manage sessions, queue, fallback, retry |
| Orchestrator | src/orchestrator/ | PABCD state machine, employee dispatch, worker monitoring |
| Memory | src/memory/ | 3-tier memory (structured/episodes/semantic), FTS5 indexing, flush, reflection |
| Prompt Builder | src/prompt/ | 9-step prompt pipeline: A1, A2, memory, orchestration, heartbeat, skills, delegation |
| Browser | src/browser/ | Chrome CDP control, vision click, tab lifecycle, web-ai automation |
| Messaging | src/messaging/ | Shared Telegram/Discord channel routing, target tracking |
Security Model
- Auth: All 71 mutation routes require
requireAuth. Loopback requests bypass tokens; LAN bypass is opt-in. - Rate limit: In-memory, IP-based, 120 requests/minute.
- Path guards:
assertMemoryRelPath(),assertSkillId(),safeResolveUnder()prevent traversal attacks. - Token bootstrap:
GET /api/auth/tokenchecksSec-Fetch-Siteto prevent cross-origin theft.
Data Storage
CLI-JAW uses SQLite via better-sqlite3 for sessions, messages, memory, employees, orchestration state, and queued messages. The database schema lives in src/core/db.ts.
session # active CLI, session ID, model, working directory
messages # conversation history with trace and tool log
memory # key-value memory store
employees # registered employee agents
employee_sessions # per-employee session tracking
orc_state # PABCD orchestration state
queued_messages # pending message queue
Try it:
- 이 프로젝트 구조 설명해줘
- 서버 API 몇 개야?