1.3 KiB
1.3 KiB
summary, read_when
| summary | read_when | |
|---|---|---|
| Routing rules per surface (WhatsApp, Telegram, web) and shared context |
|
Surfaces & Routing
Updated: 2025-12-07
Goal: make replies deterministic per channel while keeping one shared context for direct chats.
- Surfaces (channel labels):
whatsapp,webchat,telegram,voice, etc. AddSurfaceto inboundMsgContextso templates/agents can log which channel a turn came from. Routing is fixed: replies go back to the origin surface; the model doesn’t choose. - Canonical direct session: All direct chats collapse into the single
mainsession by default (no config needed). Groups staygroup:<jid>, so they remain isolated. - Session store: Keys are resolved via
resolveSessionKey(scope, ctx, mainKey); the agent JSONL path lives under~/.clawdis/sessions/<SessionId>.jsonl. - WebChat: Always attaches to
main, loads the full session transcript so desktop reflects cross-surface history, and writes new turns back to the same session. - Implementation hints:
- Set
Surfacein each ingress (WhatsApp gateway, WebChat bridge, future Telegram). - Keep routing deterministic: originate → same surface. Use the gateway WebSocket for sends; avoid side channels.
- Do not let the agent emit “send to X” decisions; keep that policy in the host code.
- Set