ADR 0008: Channel Hub Architecture
Accepted
2 min read
This is a migrated reference document from the original Anvio source repo. Content is preserved as-is; canonical documentation lives in the sections above in the sidebar.
Original path: docs/adr/0008-channel-hub-architecture.md
Status
Accepted
Context
Users need remote agent interaction similar to modern agent orchestration systems (e.g. Claude-inspired workflows), but Anvio explicitly must not couple to Slack or any single communication platform.
Requirements include:
- Multiple channels (Telegram, WhatsApp, Discord, Slack, Web Chat, REST, CLI)
- Thread-based sessions with resume
- Background/detached execution
- Progress streaming and notifications
- Agent inbox for mid-run instructions
- Human approval workflow
- Multi-agent coordination
- CLI-first command center
Decision
Adopt a Channel Hub pattern:
ChannelAdapter— transport-only interface in@anvio/core. Optional methods for progress, notifications, and approvals.ChannelHub— registers adapters and routes outbound events from runtime/worker without channel-specific logic in the agent engine.- Event-driven glue — worker subscribes to
AGENT_RUN_*,APPROVAL_*,AGENT_INBOX_*events and dispatches through the hub. - Session as universal thread —
StoredSession.channelThreadmaps external thread IDs;detachedenables background runs. - Agent Inbox — in-process queue (
LocalAgentInbox) for injecting instructions into active sessions. - SupervisorOrchestrator — manager/subagent patterns (sequential, parallel, fan-out, fan-in) without channel awareness.
Sixteen adapters ship in packages/channels/src/: cli, discord, email (SMTP+IMAP), feishu, google-chat, matrix, mattermost, rest-api, signal, slack, sms (Twilio), teams, telegram, web-chat, whatsapp, plus a generic webhook base. Real SDK/HTTP wiring is configuration-driven per deployment; credentials come from env or the connection broker.
Consequences
Positive
- Runtime remains channel-agnostic; new channels are adapter-only work.
- Identical flow across all surfaces: create task → background execution → progress → approval → notification.
- CLI command center provides full platform access without Web UI.
- Aligns with local-first vision (ADR 0007): filesystem sessions, optional NATS for scale.
Negative
- Stub adapters require per-channel integration effort before production use.
- In-process inbox does not survive process restart (Level 3: persist to session store or Redis).
Update (implemented): FilesystemAgentInbox persists to workspace/inbox/<sessionId>.json.
- Approval UX varies by channel; adapters must render platform-native buttons where available.
Alternatives Rejected
- Slack-first architecture — violates non-goals in vision doc.
- Channel logic in AgentRuntime — couples domain to transport; rejected.
- Separate runtime per channel — duplicates orchestration; rejected.
Implementation Map
| Component | Location |
|---|---|
| Ports & types | packages/core/ |
| Channel Hub & adapters | packages/channels/ |
| Orchestrator | packages/agents/src/orchestrator.ts |
| Worker dispatch | apps/worker/src/main.ts |
| CLI Command Center | apps/cli/src/main.ts |
| Artifacts | packages/workspace/ (FilesystemArtifactStore) |
References
docs/10-channels.md- ADR 0007: Local-First Architecture
Last updated on