/** * Multi-Agent Discord Integration * * Extends the Discord gateway with multi-agent support. * Enables multiple AI personas to interact in Discord channels. */ import type { Message } from 'discord.js'; import type { MultiAgentConfig, MultiAgentRuntimeOptions } from './types.js'; import { MultiBotManager } from './multi-bot-manager.js'; import type { PersistentProcessOptions } from '../agent/persistent-cli-process.js'; import type { QueuedMessage } from './agent-message-queue.js'; import { MultiAgentHandlerBase, type AgentResponse, type MultiAgentResponse } from './multi-agent-base.js'; export type { AgentResponse, MultiAgentResponse } from './multi-agent-base.js'; /** * Multi-Agent Discord Handler * * Integrates with the Discord gateway to provide multi-agent support. * Should be instantiated and called from the Discord gateway when * multi-agent mode is enabled. */ export declare class MultiAgentDiscordHandler extends MultiAgentHandlerBase { private multiBotManager; private promptEnhancer; /** Discord client reference for main bot channel sends */ private discordClient; /** Tracks which agent:channel combos have received history injection (new session only) */ private historyInjected; constructor(config: MultiAgentConfig, processOptions?: Partial, runtimeOptions?: MultiAgentRuntimeOptions); protected getPlatformName(): 'discord' | 'slack'; formatBold(text: string): string; protected sendChannelNotification(channelId: string, message: string): Promise; /** * Extract agent IDs from <@USER_ID> mentions in message content. */ extractMentionedAgentIds(content: string): string[]; protected platformCleanup(): Promise; /** * Initialize multi-bot support (call after Discord connects) */ initializeMultiBots(): Promise; /** * Set bot's own user ID (call when Discord connects) * Also wires the PR Review Poller message sender via Discord client. */ setBotUserId(userId: string): void; /** * Set Discord client for PR Review Poller message delivery. * Call after Discord client is ready. * The sender posts the message to the channel AND injects it into the * multi-agent flow so LEAD processes the review comments. */ setDiscordClient(client: { channels: { fetch: (id: string) => Promise; }; }): void; /** * Set main bot token (to avoid duplicate logins in MultiBotManager) */ setMainBotToken(token: string): void; /** * Update configuration (for hot reload) */ updateConfig(config: MultiAgentConfig): void; /** * Handle a Discord message with multi-agent logic * * @returns Object with selected agents and their responses, or null if no agents respond */ handleMessage(message: Message, cleanContent: string): Promise; private handleStopCommand; /** * Process a single agent's response * @param discordMessage - Optional Discord message for emoji progression */ private processAgentResponse; /** * Build message context from Discord message */ private buildMessageContext; /** * Send queued response to Discord (F7: message queue drain callback) */ protected sendQueuedResponse(agentId: string, message: QueuedMessage, response: string): Promise; /** * Send formatted response to Discord (handles message splitting) * Uses agent's dedicated bot if available, otherwise main bot */ sendAgentResponses(originalMessage: Message, responses: AgentResponse[]): Promise; /** * Detect if the default agent (Conductor) performed direct code edits. * Checks for Claude CLI tool-use markers that indicate Edit/Write operations. */ private detectSelfImplementation; /** * Check git diff size after Conductor self-implementation. * If diff exceeds thresholds, auto-trigger Reviewer for quality gate. * * Thresholds (PAIR mode auto-escalation): * - >3 files changed -> auto-mention Reviewer * - >200 lines changed -> auto-mention Reviewer */ private triggerAutoReviewIfNeeded; /** * Get multi-bot manager */ getMultiBotManager(): MultiBotManager; /** * Get status of all agent bots */ getBotStatus(): Record; /** * After sending agent responses, check for mentions to other agents and route them. * Discord equivalent of Slack's routeResponseMentions -- necessary because Discord * bots don't receive their own messages as events. */ routeResponseMentions(originalMessage: Message, responses: AgentResponse[]): Promise; /** * Handle a delegated mention: process target agent response and recursively route. */ private handleDelegatedMention; /** * Execute text-based tool calls, routing discord_send through the agent's own bot. * Non-discord tools fall through to the base executeTextToolCalls. */ private executeAgentToolCalls; /** * Resolve @Name mentions in LLM response text to <@userId> Discord format. * LLMs generate plain text like "@LEAD", "@Conductor", "@DevBot" which won't * trigger Discord mentions or routeResponseMentions detection. */ private resolveResponseMentions; private getEffectiveMaxMentionDepth; /** * Find the reviewer agent entry from config */ private findReviewerAgent; } //# sourceMappingURL=multi-agent-discord.d.ts.map