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

InterfaceEntry PointTransport
CLIbin/cli-jaw.ts + bin/commands/*.tsHTTP to server
Web UIpublic/index.htmlHTTP + WebSocket
Telegramsrc/telegram/bot.tsGrammy bot polling
Discordsrc/discord/bot.tsdiscord.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.

ModuleRoutesResponsibility
server.ts (base)14Health, session, messages, auth, command, stop, clear
settings.ts18Settings, prompt, heartbeat-md, MCP, CLI registry, quota
browser.ts41Browser primitives, tab management, web-ai automation
memory.ts13Memory runtime, KV store, memory files
jaw-memory.ts11Jaw memory search, read, save, soul, flush, reflect
orchestrate.ts11PABCD state, workers, dispatch, queue management
goal.ts3Durable goal state, history
goal-run.ts3Bounded goal-run lifecycle
messaging.ts6Upload, file open, voice, channel send
employees.ts5Employee CRUD and reset
skills.ts5Skills list, enable, disable, reset
avatar.ts4Agent/user avatar image management
traces.ts3Public trace summary and event read
heartbeat.ts2Heartbeat GET and validated PUT
i18n.ts2Language 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

SubsystemLocationResponsibility
Agent Runtimesrc/agent/Spawn CLI processes, stream NDJSON events, manage sessions, queue, fallback, retry
Orchestratorsrc/orchestrator/PABCD state machine, employee dispatch, worker monitoring
Memorysrc/memory/3-tier memory (structured/episodes/semantic), FTS5 indexing, flush, reflection
Prompt Buildersrc/prompt/9-step prompt pipeline: A1, A2, memory, orchestration, heartbeat, skills, delegation
Browsersrc/browser/Chrome CDP control, vision click, tab lifecycle, web-ai automation
Messagingsrc/messaging/Shared Telegram/Discord channel routing, target tracking

Security Model

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 몇 개야?