Architecture

How the pieces fit together

A Node/TypeScript core orchestrates Claude Agent SDK sessions through an MCP server. A React dashboard streams the live state. A separate daemon (Clawern) runs the same engine autonomously over a folder.

Top-level layout

src/
├── agents/             67 prompts + profiles + definitions
├── api/                Fastify server, WebSocket, 25 routes
├── assembly/           Markdown → HTML/DOCX
├── claw/               Clawern daemon (28 modules)
├── db/                 SQLite (auth, archive, matters)
├── documents/          PDF/DOCX/MD/TXT parser + sanitization
├── mcp/tools/          21 MCP tools
├── mcp/remote-bridge/  JSON-RPC bridge for Managed Agents
├── providers/          Anthropic / Mistral / local abstraction
├── workflows/          9 templates + executor
├── orchestrator.ts     Per-session SDK loop
├── dispatch.ts         Workflow + gate + budget selection
└── index.ts            Entry (CLI / --serve / claw)
viz/                    React 19 dashboard (Vite)
site/                   Static marketing site (Netlify)
menubar/                macOS SwiftUI menu bar app
tests/                  1,677 tests across 109 files

Request lifecycle

  1. BriefingPOST /api/sessions with document + context.
  2. Dispatch (src/dispatch.ts) picks a workflow template, assigns budget, wires a gate resolver.
  3. Orchestrator (src/orchestrator.ts) launches a Claude Agent SDK query() with the in-process MCP server.
  4. Specialists post findings to the debate board, challenge each other, and pass through the evaluator gate.
  5. Verification runs the 10-pass pipeline + the mechanical grounding verifier.
  6. Human gate pauses on critical calls; the dashboard surfaces the decision via WebSocket.
  7. Delivery assembles the deliverable + audit bundle (findings, debate resolutions, verification report, cost log).

Three layers of verification

LayerWhat it doesWhere
Evaluator gateDrops weak findings, up to 2 revision loopsmcp/tools/evaluator-gate.ts
Adversarial debateRed team / blue team challengeworkflows/templates/adversarial.ts
10-pass verificationcontext, ux, clarity, structure, accuracy, completeness, risk, formatting, legal_design, deliveryworkflows/templates/verification.ts
Grounding verifierString-matches every cited quote against the parsed documentmcp/tools/grounding-verifier.ts

Two runtimes, one engine

Interactive (API + dashboard)

Fastify + WebSockets. User briefs in plain language, watches agents debate, approves at gates, downloads audit bundle.

Clawern (autonomous)

Daemon watches a folder. Processes new documents on a 30-minute heartbeat. Precedent board persists findings across engagements. Pushes alerts to Telegram, email, macOS.