Forge Architecture

Local AI Agent Desktop App — Chat, IM Bridge, Scheduled Tasks. Powered by Claude Agent SDK.

loads URL spawns IPC fetch/SSE subprocess API calls stdio/SSE read/write agent query persist execute task notify log results Electron Shell v40 • IPC • File Watch Preload (contextBridge) Next.js 15 + React 19 Frontend Chat • Manage • IM • Schedule • Settings • Marketplace Tailwind CSS • i18n • SSE Streaming Next.js API Routes /api/chat SSE streaming /api/sessions CRUD /api/im-* channels + events /api/cron-* tasks + engine /api/mcp + models + agents /api/* settings upload market SDK Client System Prompt Builder (5-layer) Permission Bridge • Agent Loader Message Mapper • Thinking Mode createForgeQuery() IM Bridge Bridge Manager • Channel Router Permission Broker • Policy Engine Conversation Engine • Delivery SSE Event Bus Cron Engine 60s Tick Scheduler Cron Parser • Executor Heartbeat • Run Agent/Skill Task Execution History Claude Agent SDK @anthropic-ai/claude-agent-sdk CLI subprocess • Sessions AI Providers Anthropic • MiniMax • GLM Kimi • Qwen • Custom Anthropic Protocol + CLI OAuth IM Platforms Feishu/Lark SDK Telegram • Discord Adapters • Dedup • Audit Marketplace Template CRUD ~/.forge/marketplace/ SQLite (WAL) better-sqlite3 15+ tables • Auto-migration ~/.forge/forge.db MCP Servers stdio • SSE • HTTP Browser (Playwright) MCP workspace-fs.ts File System (~/.forge/ + .claude/) CLAUDE.md • SOUL.md • IDENTITY.md USER.md • MEMORY.md • HEARTBEAT.md skills/ • agents/ • rules/ • memory/ uploads/ • marketplace/ Legend Frontend Backend Service External API Database / Storage IM / Event Bus Security / IPC Data Flow Internal Call Tech Stack Next.js 15 (Turbopack) React 19 • TypeScript Tailwind CSS 3.4 Claude Agent SDK 0.2 Lark SDK • Playwright better-sqlite3 (WAL) Zod • shiki Electron 40 electron-builder L1: Desktop Shell L2: Frontend UI L3: API Routes L4: Core Services L5: External L6: Data Layer

Core Services

  • • SDK Client: 5-layer system prompt, permission bridge, agent/MCP loader
  • • IM Bridge: 3 adapters (Feishu/Telegram/Discord), policy engine, dedup
  • • Cron Engine: 60s scheduler, heartbeat, run-agent/skill/prompt actions
  • • Multi-provider AI: 6 providers via Anthropic-compatible protocol

Data & Storage

  • • SQLite (better-sqlite3, WAL mode) at ~/.forge/forge.db
  • • 15+ tables with auto-migration on startup
  • • File-based config: .claude/ dirs per workspace
  • • Marketplace templates, uploads, daily memory files

Desktop Integration

  • • Electron 40 shell with IPC bridge (contextBridge)
  • • Next.js standalone server spawned on random port
  • • SSE for real-time chat + IM event streaming
  • • File watch, clipboard, shell operations via preload