Skip to content

Architecture Overview

High-Level Flow

IM Platform → IM Registry → Bot → AgentRuntime → AgentAdapter → Proxy :18899 → Upstream

Core Components

IM Registry Factory

Registers IM adapters by type. New IMs need only one registration line:

registerIM("feishu", feishuFactory);

AgentRuntime (modules/core/)

Message processing hub:

  • Session management
  • Agent adapter routing
  • Stats tracking
  • Error handling
  • Session persistence

AgentAdapter Interface

Unified abstraction for all agent backends:

  • Claude Code → spawn subprocess
  • Codex → app-server v2
  • OpenCode → HTTP API

Unified Proxy (:18899)

Single port for all agent requests. Anthropic-compatible format.

Bot Configuration

Multiple bots can run simultaneously with different IM + agent combinations.

Graceful Shutdown

SIGINT/SIGTERM → Stop IM → Stop Proxy → Persist sessions → Wait for active requests (10s timeout).