Skip to content

feat: multi-channel architecture — IChannelAdapter + Vercel Chat SDK + Telegram security migration #146

Description

@ryaker

Summary

Signal channel landed (commit 160ab4dd) but isn't wired into the daemon yet. The existing Telegram gateway (src/steering/telegram-gateway.ts) bypasses the entire new security stack — no Casbin, no CapabilitySet, no quarantine processor, just a subprocess pipe. This issue formalizes the channel abstraction and closes both gaps while adding multi-channel support via Vercel Chat SDK.

Current State (Code-Verified, 2026-03-10)

  • ✅ Signal adapter implemented (src/channels/signal/) — not wired into daemon
  • ✅ Casbin policy gate, capability resolver, quarantine processor — all implemented
  • ChannelMessage / CapabilitySet types — channel-agnostic
  • IChannelAdapter interface — does not exist (abstraction is implicit)
  • ChannelManager — does not exist
  • ❌ Audit log — does not exist (Phase 3 gap from Signal spec)
  • ❌ Daemon wiring for any channel — not done
  • ❌ Telegram in security stack — still using subprocess bypass in src/steering/

The Telegram Security Gap

src/steering/telegram-gateway.ts currently:

  • Checks allowed_users[] string array only (no Casbin enforcement)
  • Spawns zora-agent ask as a subprocess — pipes raw CLI output back
  • Has no quarantine processor, no action budget, no intent drift, no dry-run
  • Predates the channel security layer

This is a security fix disguised as a feature addition.

What This Implements

1. IChannelAdapter interface (src/channels/channel-adapter.ts)

Formalizes the implicit abstraction — start(), stop(), onMessage(), send().

2. ChannelManager (src/channels/channel-manager.ts)

Single pipeline: policy gate → capability resolver → quarantine → orchestrator → audit → response.
Every channel uses this path. No bypass.

3. Append-only Audit Log (src/channels/channel-audit-log.ts)

JSONL at ~/.zora/audit/channel.log. Logs intake decisions, quarantine flags, tool calls, budget events. Never logs message content. Rotate at 10MB.

4. Signal wiring (Phase 3 completion)

Wire SignalIntakeAdapter into daemon.ts via ChannelManager. Add rate limiting (10 tasks/hr/sender). Add TOML config validation on startup.

5. Telegram migration (Phase 2)

Install @chat-adapter/telegram. Implement src/channels/telegram/telegram-adapter.tsIChannelAdapter. Deprecate src/steering/telegram-gateway.ts.

6. Multi-channel via Vercel Chat SDK (Phases 3-5)

pnpm add chat @chat-adapter/slack @chat-adapter/teams @chat-adapter/discord @chat-adapter/whatsapp @chat-adapter/google-chat

Single webhook server on channels.webhook_port. Each platform adapter translates Chat SDK events → ChannelMessageChannelManager.handleMessage().

Implementation Phases

Phase Deliverable Acceptance
1 Signal wired, audit log, rate limiting All 11 Signal integration tests pass
2 IChannelAdapter + Telegram migration Telegram through Casbin + quarantine; subprocess retired
3 WebhookServer + WhatsApp WhatsApp works with full policy enforcement
4 Slack + Teams Both channels operational
5 Discord + Google Chat All 7 channels, full integration test suite

New Security Invariants

INVARIANT-8: src/steering/telegram-gateway.ts MUST NOT be used after Phase 2
INVARIANT-9: All channels use ChannelManager.handleMessage() — no bypass path
INVARIANT-10: Webhook server validates platform signatures before processing

Files Changed

New: channel-adapter.ts, channel-manager.ts, channel-audit-log.ts, webhook-server.ts, src/channels/telegram/, src/channels/slack/, src/channels/teams/, src/channels/discord/, src/channels/whatsapp/, src/channels/google-chat/

Modified: daemon.ts, config/defaults.ts, config/loader.ts, signal adapter files

Deprecated: src/steering/telegram-gateway.ts

Full Spec

SPEC-multi-channel-architecture.md (Zora_Sims project)

Related

  • Closes Signal Phase 3 gaps (companion to commit 160ab4dd)
  • Supersedes src/steering/telegram-gateway.ts design
  • Vercel Chat SDK: https://github.com/vercel/chat (standalone, no Vercel hosting required)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions