docs/setup-wiring.md
Last updated: 2026-04-09
inbound.db (host-owned) and outbound.db (container-owned)/workspace/.heartbeat) instead of DB UPDATEdelivery.ts:handleSystemAction()processing_ack table + heartbeat file mtime for stale detectionprocessing_ack entries on startup (crash recovery)src/db/schema.ts (INBOUND_SCHEMA + OUTBOUND_SCHEMA), src/session-manager.ts, src/delivery.ts, src/host-sweep.ts, container/agent-runner/src/db/connection.ts, messages-in.ts, messages-out.ts, poll-loop.ts, mcp-tools/scheduling.ts, mcp-tools/interactive.tscontainer/agent-runner/tsconfig.json)ensureAgent() call added before applyContainerConfig() in src/container-runner.tsensureAgent, OneCLI rejects unknown agent identifiers and returns false, leaving container with no credentialssrc/index.ts imports ./channels/index.js (the barrel)/add-<channel> skills drop adapter files in and register them via the barrel slotsetup/register.ts creates entities (agent_groups, messaging_groups, messaging_group_agents) in data/v2.db--platform-id flaggetMessagingGroupAgentByPair() prevents duplicate wiringsetup/verify.ts checks the central DB (counts agent groups with wiring)src/router.ts logs MESSAGE DROPPED at WARN level when no agents wired, with actionable guidanceChannel skills now point to /manage-channels in their "Next Steps" section. Registration is handled by the /manage-channels skill, which reads each channel's ## Channel Info section for platform-specific guidance. Channel skills stay lean (credentials only).
Added step 5a "Wire Channels to Agent Groups" between channel installation (step 5) and mount allowlist (step 6). This step invokes /manage-channels which handles agent group creation, isolation level decisions, and wiring.
Each channel skill has a ## Channel Info structured section with: type, terminology, how-to-find-id, supports-threads, typical-use, default-isolation. The /manage-channels skill reads this for contextual recommendations.
setup/verify.ts checks all channel tokens: DISCORD_BOT_TOKEN, TELEGRAM_BOT_TOKEN, SLACK_BOT_TOKEN+SLACK_APP_TOKEN, GITHUB_TOKEN, LINEAR_API_KEY, GCHAT_CREDENTIALS, TEAMS_APP_ID+TEAMS_APP_PASSWORD, WEBEX_BOT_TOKEN, MATRIX_ACCESS_TOKEN, RESEND_API_KEY, WHATSAPP_ACCESS_TOKEN, IMESSAGE_ENABLED, plus WhatsApp Baileys auth dir.
Added session_mode: 'agent-shared' for cross-channel shared sessions (e.g. GitHub + Slack in one conversation). Session resolution looks up by agent_group_id instead of messaging_group_id when this mode is set.
agent_groups (id, name, folder, agent_provider, container_config)
↕ many-to-many
messaging_groups (id, channel_type, platform_id, name, is_group, unknown_sender_policy)
via
messaging_group_agents (messaging_group_id, agent_group_id, trigger_rules, session_mode, priority)
users (id, kind, display_name) -- namespaced as "<channel>:<handle>"
user_roles (user_id, role, agent_group_id) -- owner / admin (global or scoped)
agent_group_members (user_id, agent_group_id) -- unprivileged access gate
user_dms (user_id, channel_type, messaging_group_id) -- cold-DM cache
Privilege is a user-level concept — there is no "main" agent group or "admin" messaging group. user_roles carries owner (global only, first pairing sets it) and admin (global or scoped to an agent_group_id). Unknown-sender gating is per-messaging-group via messaging_groups.unknown_sender_policy (strict | request_approval | public).
Channel adapter → routeInbound() → resolve messaging_group → resolve agent via messaging_group_agents
→ resolve/create session → write to inbound.db → wake container → agent-runner polls inbound.db
→ agent responds → writes to outbound.db → host delivery poll reads outbound.db → deliver via adapter
| File | Purpose |
|---|---|
src/index.ts | Entry point, imports channel barrel |
src/channels/index.ts | Channel barrel — registry/Chat SDK bridge only in trunk; skills drop adapters in |
src/router.ts | Inbound routing, auto-creates messaging groups |
src/session-manager.ts | Creates inbound.db + outbound.db per session |
src/delivery.ts | Polls outbound.db, delivers, handles system actions |
src/host-sweep.ts | Syncs processing_ack, stale detection, recurrence |
src/container-runner.ts | Spawns containers, OneCLI ensureAgent + applyContainerConfig |
setup/register.ts | Creates entities (agent_group, messaging_group, wiring) |
setup/verify.ts | Checks central DB for registered groups |
container/agent-runner/src/db/connection.ts | Two-DB connection layer (inbound read-only, outbound read-write) |