/** * Slack Thread Store Service * * Persists Slack thread conversations as markdown files so the orchestrator * can read conversation history. Also tracks which agents were delegated * from which Slack threads, enabling thread-aware proactive notifications. * * Storage layout: * ~/.crewly/slack-threads/ * {channelId}/ * {threadTs}.md — Thread conversation file * agent-index.json — Maps agent session → thread(s) * * @module services/slack/slack-thread-store */ import type { SlackImageInfo } from '../../types/slack.types.js'; /** * Represents an agent-to-thread mapping stored in the agent index */ export interface AgentThreadMapping { channelId: string; threadTs: string; agentName: string; delegatedAt: string; } /** * Thread info returned by lookup methods */ export interface ThreadInfo { channelId: string; threadTs: string; filePath: string; } /** * SlackThreadStoreService manages persistent storage of Slack thread * conversations and agent-thread associations. * * @example * ```typescript * const store = new SlackThreadStoreService(); * await store.appendUserMessage('C123', '1707432600.000001', 'Steve', 'Hello'); * await store.registerAgent('joe-session', 'Joe', 'C123', '1707432600.000001'); * const threads = store.findThreadsForAgent('joe-session'); * ``` */ export declare class SlackThreadStoreService { private baseDir; private agentIndex; private indexLoaded; /** * Create a new SlackThreadStoreService. * * @param crewlyHome - Base crewly home directory (defaults to ~/.crewly) */ constructor(crewlyHome?: string); /** * Compute the file path for a thread conversation file. * Pure function — does not perform I/O. * * @param channelId - Slack channel ID * @param threadTs - Slack thread timestamp * @returns Absolute path to the thread markdown file */ getThreadFilePath(channelId: string, threadTs: string): string; /** * Ensure the thread file exists, creating it with frontmatter if needed. * * @param channelId - Slack channel ID * @param threadTs - Slack thread timestamp * @param userName - Name of the user who started the thread * @returns Absolute path to the thread file */ ensureThreadFile(channelId: string, threadTs: string, userName: string): Promise; /** * Append a user message to the thread conversation file. * Optionally includes image metadata when the message has image attachments. * * @param channelId - Slack channel ID * @param threadTs - Slack thread timestamp * @param userName - Display name of the sender * @param message - Message content * @param images - Optional downloaded image info array */ appendUserMessage(channelId: string, threadTs: string, userName: string, message: string, images?: SlackImageInfo[]): Promise; /** * Append an orchestrator reply to the thread conversation file. * * @param channelId - Slack channel ID * @param threadTs - Slack thread timestamp * @param message - Orchestrator response content */ appendOrchestratorReply(channelId: string, threadTs: string, message: string): Promise; /** * Register an agent as being associated with a Slack thread. * Updates the in-memory index, persists to disk, and appends * the agent to the thread file's frontmatter. * * @param agentSession - Agent session name (e.g., 'innovation-team-joe-abc123') * @param agentName - Human-readable agent name (e.g., 'Joe') * @param channelId - Slack channel ID * @param threadTs - Slack thread timestamp */ registerAgent(agentSession: string, agentName: string, channelId: string, threadTs: string): Promise; /** * Find all threads associated with an agent session. * Synchronous lookup from in-memory index. * * @param sessionName - Agent session name to look up * @returns Array of ThreadInfo objects */ findThreadsForAgent(sessionName: string): ThreadInfo[]; /** * Load the agent index from disk into memory. * Only loads once unless forced. */ private loadIndex; /** * Persist the in-memory agent index to disk. */ private saveIndex; /** * Update the thread file's YAML frontmatter to include a newly registered agent. * * @param channelId - Slack channel ID * @param threadTs - Slack thread timestamp * @param agentSession - Agent session name * @param agentName - Human-readable agent name */ private updateThreadFrontmatter; } /** * Get the SlackThreadStoreService singleton. * * @returns The service instance or null if not initialized */ export declare function getSlackThreadStore(): SlackThreadStoreService | null; /** * Set the SlackThreadStoreService singleton. * * @param store - The service instance to set */ export declare function setSlackThreadStore(store: SlackThreadStoreService): void; /** * Reset the SlackThreadStoreService singleton (for testing). */ export declare function resetSlackThreadStore(): void; //# sourceMappingURL=slack-thread-store.service.d.ts.map