feat: moderator bot for turn handoff messages

Add a dedicated moderator Discord bot that sends handoff messages when
the current speaker says NO_REPLY. This solves the wakeup problem.

Flow:
1. Agent A is current speaker, receives message
2. Agent A responds with NO_REPLY
3. Plugin detects NO_REPLY in message_sent hook, advances turn to Agent B
4. Plugin sends via moderator bot: '轮到(@AgentB)了,如果没有想说的请直接回复NO_REPLY'
5. This real Discord message triggers Agent B's session
6. Turn manager allows Agent B to respond

Implementation:
- moderatorBotToken config field for the moderator bot's Discord token
- userIdFromToken() extracts Discord user ID from bot token (base64)
- resolveDiscordUserId() maps accountId → Discord user ID via account tokens
- sendModeratorMessage() calls Discord REST API directly
- message_received ignores moderator bot messages (transparent to turn state)
- Moderator bot is NOT in the turn order
This commit is contained in:
zhi
2026-02-28 11:39:11 +00:00
parent 476308d0df
commit 54ff78cffe
2 changed files with 84 additions and 9 deletions

View File

@@ -10,6 +10,8 @@ export type WhisperGateConfig = {
endSymbols?: string[];
noReplyProvider: string;
noReplyModel: string;
/** Discord bot token for the moderator bot (used for turn handoff messages) */
moderatorBotToken?: string;
};
export type ChannelPolicy = {