/** * Slack Manager Module * * Manages Slack connectors for agents that have `chat.slack` configured. * This module is responsible for: * - Creating one SlackConnector instance per Slack-enabled agent * - Managing connector lifecycle (start/stop) * - Providing access to connectors for status queries * * @module manager */ import type { ChatManagerConnectorState, FleetManagerContext, IChatManager } from "@herdctl/core"; import { SlackConnector } from "./slack-connector.js"; /** * SlackManager handles Slack connections for agents * * This class encapsulates the creation and lifecycle management of * SlackConnector instances for agents that have Slack chat configured. * * Implements IChatManager so FleetManager can interact with it through * the generic chat manager interface. */ export declare class SlackManager implements IChatManager { private ctx; private connectors; private initialized; constructor(ctx: FleetManagerContext); /** * Initialize Slack connectors for all configured agents * * This method: * 1. Iterates through agents to find those with Slack configured * 2. Creates a SlackConnector for each Slack-enabled agent * * Should be called during FleetManager initialization. */ initialize(): Promise; /** * Connect all Slack connectors * * Connects each connector to Slack via Socket Mode and subscribes to events. * Errors are logged but don't stop other connectors from connecting. */ start(): Promise; /** * Disconnect all Slack connectors gracefully * * Sessions are automatically persisted to disk on every update, * so they survive bot restarts. This method logs session state * before disconnecting for monitoring purposes. * * Errors are logged but don't prevent other connectors from disconnecting. */ stop(): Promise; /** * Get a connector for a specific agent * * @param qualifiedName - Qualified name of the agent (e.g., "herdctl.security-auditor") * @returns The SlackConnector instance, or undefined if not found */ getConnector(qualifiedName: string): SlackConnector | undefined; /** * Get all connector names * * @returns Array of agent qualified names that have Slack connectors */ getConnectorNames(): string[]; /** * Get the number of active connectors * * @returns Number of connectors that are currently connected */ getConnectedCount(): number; /** * Check if the manager has been initialized */ isInitialized(): boolean; /** * Check if a specific agent has a Slack connector * * @param qualifiedName - Qualified name of the agent (e.g., "herdctl.security-auditor") * @returns true if the agent has a Slack connector */ hasConnector(qualifiedName: string): boolean; /** * Check if a specific agent has a connector (alias for hasConnector) * * @param qualifiedName - Qualified name of the agent (e.g., "herdctl.security-auditor") * @returns true if the agent has a connector */ hasAgent(qualifiedName: string): boolean; /** * Get the state of a connector for a specific agent * * @param qualifiedName - Qualified name of the agent (e.g., "herdctl.security-auditor") * @returns The connector state, or undefined if not found */ getState(qualifiedName: string): ChatManagerConnectorState | undefined; /** * Handle an incoming Slack message * * This method: * 1. Gets or creates a session for the channel * 2. Builds job context from the message * 3. Executes the job via trigger * 4. Sends the response back to Slack * * @param qualifiedName - Qualified name of the agent handling the message * @param event - The Slack message event */ private handleMessage; /** * Handle errors from Slack connectors * * Logs errors without crashing the connector * * @param qualifiedName - Qualified name of the agent that encountered the error * @param error - The error that occurred */ private handleError; /** Slack's maximum message length */ private static readonly MAX_MESSAGE_LENGTH; /** * Format an error message for Slack display * * Creates a user-friendly error message with guidance on how to proceed. * * @param error - The error that occurred * @returns Formatted error message string */ formatErrorMessage(error: Error): string; /** * Split a response into chunks that fit Slack's 4000 character limit * * Uses the shared splitMessage utility from @herdctl/chat. * * @param text - The text to split * @returns Array of text chunks, each under 4000 characters */ splitResponse(text: string): string[]; /** * Send a response to Slack, splitting if necessary * * @param reply - The reply function from the message event * @param content - The content to send */ sendResponse(reply: (content: string) => Promise, content: string): Promise; /** * Resolve the agent's working directory to an absolute path string * * @param agent - The resolved agent configuration * @returns Absolute path to working directory, or undefined if not configured */ private resolveWorkingDirectory; } //# sourceMappingURL=manager.d.ts.map