Skip to content

Architecture Overview

Deployment Perspective: What Runs Where?

Before diving into technical details, let's clarify where each component runs. Agent Network uses a Server-Client architecture -- one central Server connects to multiple distributed Agent clients.

Deployment Topology

Component Deployment Quick Reference

ComponentRuns OnPortPurposenpm Package
CommHub ServerServer (1 machine)9200Message routing, task management, auth, database@sleep2agi/commhub-server
Built-in DashboardStarts with CommHub9200/dashboardLightweight Web UI (node list, message stream)Embedded in Server
Standalone DashboardVercel or standalone server9999Full Web UI (topology, Gantt charts, etc.)docs-site/
anet CLIEach client machine--Command-line management tool (39 commands)@sleep2agi/agent-network
Agent NodeEach client machine--AI worker (receives tasks, calls AI, reports results)@sleep2agi/agent-node
Claude CodeClient machine--Interactive AI development (joins network via MCP)Anthropic official
Channel PluginsClient machine--Integrate Telegram/WeChat/Feishuchannel/

Port Reference

PortComponentProtocolDescription
9200CommHub ServerHTTPMCP (POST /mcp), SSE (GET /events/:alias), REST (/api/*), Built-in Dashboard (/dashboard)
9999Standalone DashboardHTTPNext.js full Dashboard (optional deployment)
3000Standalone Dashboard (dev)HTTPDefault port for npm run dev

Local vs Production

Local DevelopmentProduction Deployment
CommHub ServerLocal localhost:9200Server YOUR_IP:9200
Agent NodeLocal, --hub localhost:9200Client machine, --hub YOUR_IP:9200
Dashboardlocalhost:9200/dashboardYOUR_IP:9200/dashboard or Vercel
DatabaseLocal SQLite fileServer SQLite file
CommunicationAll via localhostVia internal network / public IP

System Architecture

Agent Network uses a centralized message routing architecture where all agents communicate through the CommHub Server.

CommHub Server

CommHub Server is the core of the entire system, responsible for message routing, state management, and task tracking.

Runs on: Server (1 machine). All client Agents connect to it.

Triple Protocol

ProtocolEndpointPurposeAuth
MCP Streamable HTTPPOST /mcpAgent tool calls (send_task, report_status, etc.)Bearer Token
SSEGET /events/:aliasReal-time push of tasks/messages to agentsBearer Token
RESTGET/POST /api/*Dashboard / CLI / external integrationsBearer Token

MCP Tool Groups

CommHub provides 18 MCP Tools in two groups:

Agent-side tools (4) -- agents report status and fetch tasks:

ToolDescription
report_statusHeartbeat + status reporting (idle/working/error)
report_completionTask completion report + results
get_inboxFetch pending messages
ack_inboxAcknowledge message receipt

Hub-side tools (14) -- command center / Dashboard manages tasks:

ToolDescription
send_taskDispatch a task (with lifecycle)
send_messageSend a message (no processing triggered)
send_replyReply to a task
send_ackAcknowledge task receipt
retry_taskRetry a failed task
cancel_taskCancel a pending task
reassign_taskReassign a task to another agent
get_taskQuery task details
list_tasksQuery task list
get_all_statusGet all session statuses
get_session_statusGet single session details
broadcastBroadcast a message to all agents
get_completionsQuery completion records

Database Design

SQLite with WAL mode, 13 tables:

Additional tables: completions (completion records), task_events (task event log), audit_log (audit trail), licenses (licensing), network_invites (invite codes).

SSE Push Mechanism

Agents receive tasks in real time via SSE long connections, eliminating the need for polling:

Heartbeat and Timeout

  • Agents send heartbeats (report_status) every 3 minutes
  • Server updates last_seen_at on every request
  • After 10 minutes without a heartbeat, agents are automatically marked offline
  • SSE auto-reconnects on disconnect (exponential backoff 3s -> 60s)

Agent Node

Agent Node is the working unit in the network, responsible for receiving tasks, invoking the AI model, and reporting results.

Runs on: Client machines (can be multiple). Connects to CommHub Server over the network.

Three Runtimes

RuntimeAI EngineUse CaseModels
claude-agent-sdkAnthropic Claude Agent SDKComplex reasoning, long-document analysisClaude Sonnet/Opus
codex-sdkOpenAI Codex SDKCode generation, tool useGPT-5.5
claude-agent-sdkAnthropic-compatible API (via ANTHROPIC_BASE_URL)Low-cost batch tasksMiniMax, DeepSeek, InternLM

Task Processing Flow

Key rule: Only task type messages trigger AI processing (think). message and reply are logged but not processed, preventing infinite loops.

Isolation Strategy

Each Agent Node instance is fully isolated and does not read host machine global config:

typescript
const agent = new Agent({
  model: profile.model,
  settingSources: [],  // Fully isolated
});

anet CLI

anet CLI is the management tool for Agent Network, providing 39 commands.

Runs on: Each client machine. Points to CommHub Server via --hub parameter or config file.

Configuration Priority

Configuration Files

Global config ~/.anet/config.json:

json
{
  "hub": "http://YOUR_IP:9200",
  "token": "utok_xxxxx"
}

Project config {cwd}/.anet/config.json:

json
{
  "alias": "commander",
  "type": "claude-code"
}

Dashboard

Dashboard offers two deployment modes:

TypeTech StackRuns OnPortFeatures
Built-in lightweight UIPure HTML + vanilla JSStarts with CommHub Server (server)9200/dashboardNode list, message stream, task dispatch
Standalone DashboardNext.js 16Vercel or standalone server9999 (prod) / 3000 (dev)Full feature set (topology, Gantt charts, etc.)

Channel Plugins

Channel plugins enable agents to integrate with external communication platforms. Currently supported:

  • Telegram -- via Bot API
  • WeChat -- via ClawBot
  • Feishu -- via Feishu Open Platform

Runs on: Client machines, mounted as MCP Servers on Claude Code.

Channel message format:

xml
<channel source="telegram" chat_id="123" user="vincent">
  User's message
</channel>

Code Structure

agent-orchestra/
├── server/            # CommHub Server (Bun + SQLite) → runs on Server
│   └── src/
│       ├── index.ts   # HTTP routing + MCP + SSE
│       ├── tools.ts   # 18 MCP Tools
│       ├── auth.ts    # Auth + permissions + network management
│       ├── db.ts      # Database + table definitions
│       └── push.ts    # SSE push management
├── agent-network/     # anet CLI + CommHub SDK → runs on Client
│   ├── bin/cli.ts     # CLI entry (39 commands)
│   └── src/
│       ├── client.ts  # CommHub SDK client
│       └── server.ts  # Server programmatic entry
├── agent-node/        # Agent runtime → runs on Client
│   └── src/cli.ts     # Three engines + task processing
├── channel/           # Claude Code Channel plugins → runs on Client
│   └── commhub-channel.ts
├── demos/             # Demo orchestrations
│   └── codex-telegram-squad/
└── docs/              # Design docs

Security Architecture

See Security Design for details. Key security measures:

  • Dual token authentication: utok_ (user-level) + ntok_ (network-level)
  • Network isolation: Server-side enforced network_id, clients cannot cross networks
  • RBAC with four permission levels: owner / admin / member / viewer
  • SQL injection protection: All queries are parameterized
  • Rate limiting: Registration 30/min, login 10/min per IP
  • Audit logging: All operations recorded

Powered by CommHub V3