All skills now reference Docker CLI instead of Apple Container CLI. Setup skill defaults to Docker with optional /convert-to-apple-container. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2.2 KiB
2.2 KiB
Intent: src/index.ts modifications
What changed
Refactored from single WhatsApp channel to multi-channel architecture using the Channel interface.
Key sections
Imports (top of file)
- Added:
TelegramChannelfrom./channels/telegram.js - Added:
TELEGRAM_BOT_TOKEN,TELEGRAM_ONLYfrom./config.js - Added:
findChannelfrom./router.js - Added:
Channeltype from./types.js
Module-level state
- Added:
const channels: Channel[] = []— array of all active channels - Kept:
let whatsapp: WhatsAppChannel— still needed forsyncGroupMetadatareference
processGroupMessages()
- Added:
findChannel(channels, chatJid)lookup at the start - Changed:
whatsapp.setTyping()→channel.setTyping?.()(optional chaining) - Changed:
whatsapp.sendMessage()→channel.sendMessage()in output callback
getAvailableGroups()
- Unchanged: uses
c.is_groupfilter from base (Telegram channels passisGroup=trueviaonChatMetadata)
startMessageLoop()
- Added:
findChannel(channels, chatJid)lookup per group in message processing - Changed:
whatsapp.setTyping()→channel.setTyping?.()for typing indicators
main()
- Changed: shutdown disconnects all channels via
for (const ch of channels) - Added: shared
channelOptsobject for channel callbacks - Added: conditional WhatsApp creation (
if (!TELEGRAM_ONLY)) - Added: conditional Telegram creation (
if (TELEGRAM_BOT_TOKEN)) - Changed: scheduler
sendMessageusesfindChannel()→channel.sendMessage() - Changed: IPC
sendMessageusesfindChannel()→channel.sendMessage()
Invariants
- All existing message processing logic (triggers, cursors, idle timers) is preserved
- The
runAgentfunction is completely unchanged - State management (loadState/saveState) is unchanged
- Recovery logic is unchanged
- Container runtime check is unchanged (ensureContainerSystemRunning)
Must-keep
- The
escapeXmlandformatMessagesre-exports - The
_setRegisteredGroupstest helper - The
isDirectRunguard at bottom - All error handling and cursor rollback logic in processGroupMessages
- The outgoing queue flush and reconnection logic (in WhatsAppChannel, not here)