/** * Multi-Agent Slack Integration * * Extends the Slack gateway with multi-agent support. * Mirrors MultiAgentDiscordHandler but uses Slack-specific APIs. * * Reused platform-agnostic components: * - MultiAgentOrchestrator: agent selection, chain tracking * - AgentProcessManager: getProcess('slack', channelId, agentId) * - SharedContextManager: channelId-based context */ import type { WebClient } from '@slack/web-api'; import type { MultiAgentConfig, MultiAgentRuntimeOptions } from './types.js'; import { SlackMultiBotManager, type SlackMentionEvent } from './slack-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 Slack Handler * * Integrates with the Slack gateway to provide multi-agent support. */ export declare class MultiAgentSlackHandler extends MultiAgentHandlerBase { private multiBotManager; protected logger: { debug: (message: string, ...args: unknown[]) => void; log: (message: string, ...args: unknown[]) => void; info: (message: string, ...args: unknown[]) => void; warn: (message: string, ...args: unknown[]) => void; error: (message: string, ...args: unknown[]) => void; }; /** Main Slack WebClient for posting system messages (heartbeat) */ private mainWebClient; /** Per-channel WebClient mapping (for multi-workspace support) */ private channelWebClients; /** Active channel for heartbeat reporting */ private heartbeatChannelId; /** Heartbeat polling interval handle */ private heartbeatInterval?; /** Interval handle for periodic cleanup */ /** Tracks the process used for history seeding per agent:channel */ private historySeedProcess; private promptEnhancer; constructor(config: MultiAgentConfig, processOptions?: Partial, runtimeOptions?: MultiAgentRuntimeOptions); protected getPlatformName(): 'discord' | 'slack'; formatBold(text: string): string; /** * Get the correct WebClient for a channel (multi-workspace aware). * Returns channel-specific client if registered, otherwise mainWebClient. */ private getWebClientForChannel; /** * Register a WebClient for a specific channel (call when receiving messages from agent bots) */ registerChannelWebClient(channelId: string, client: WebClient): void; protected sendChannelNotification(channelId: string, message: string): Promise; /** * Extract agent IDs from <@U...> mentions in message content */ extractMentionedAgentIds(content: string): string[]; protected platformCleanup(): Promise; /** * Initialize multi-bot support (call after Slack connects) */ initializeMultiBots(): Promise; /** * Set main Slack WebClient (for heartbeat status messages) */ setMainWebClient(client: WebClient): void; /** * Set main bot's user ID (call when Slack connects via auth.test) */ setBotUserId(userId: string): void; /** * Set main bot's bot ID */ setMainBotId(botId: string): void; /** * Set main bot token (to avoid duplicate connections) */ setMainBotToken(token: string): void; /** * Update configuration (for hot reload) */ updateConfig(config: MultiAgentConfig): void; /** * Handle a Slack message with multi-agent logic * * @returns Object with selected agents and their responses, or null if no agents respond */ handleMessage(event: SlackMentionEvent, cleanContent: string): Promise; /** * Process a single agent's response */ private processAgentResponse; /** * Build message context from Slack event */ private buildMessageContext; /** * Send formatted responses to Slack (handles message splitting) * Uses agent's dedicated bot if available, otherwise main WebClient */ sendAgentResponses(channelId: string, threadTs: string | undefined, responses: AgentResponse[], mainWebClient?: WebClient): Promise; /** * Send queued response to Slack (F7: message queue drain callback) */ protected sendQueuedResponse(agentId: string, message: QueuedMessage, response: string): Promise; /** * Handle bot->agent mention delegation (called by gateway for main bot messages). * Bridges the gap where Slack's app_mention event doesn't fire for bot-posted messages. */ handleBotToAgentMention(targetAgentId: string, event: SlackMentionEvent, mainWebClient: WebClient): Promise; /** * After sending agent responses, check for mentions to other agents and route them. * Necessary because Slack Socket Mode doesn't deliver a bot's own messages back to itself, * so the gateway's message listener never fires for responses sent by any bot. */ routeResponseMentions(channelId: string, threadTs: string, responses: AgentResponse[], mainWebClient: WebClient): Promise; /** * Get multi-bot manager */ getMultiBotManager(): SlackMultiBotManager; /** * Start heartbeat polling for a channel. * Only reports when at least 1 agent is busy. Silent when all idle. */ startHeartbeat(channelId: string): void; /** * Stop heartbeat polling */ stopHeartbeat(): void; /** * Poll agent states and report to Slack if any are busy */ private pollAndReport; /** * Get status of all agent bots */ getBotStatus(): Record; } //# sourceMappingURL=multi-agent-slack.d.ts.map