//#region extensions/crypto/src/services/forum-topics.d.ts /** * Forum Topics Service — Telegram threaded mode topic management. * * When Telegram "Topics" mode is enabled (via BotFather), each topic * in a group becomes an isolated conversation thread. This service: * * 1. Maps well-known topic names to purpose categories * 2. Routes notifications (heartbeat, cron, alerts) to the right topic * 3. Maintains topic ID ↔ purpose mapping per chat * 4. Provides session isolation — each topic gets its own LLM context * * Topic IDs are Telegram message_thread_id values. The "General" topic * has thread_id = undefined (or 1 in some API versions). * * State is persisted to disk on shutdown and restored on startup. * * Usage: * const topics = getForumTopics(); * topics.registerTopic(chatId, threadId, 'trading'); * const threadId = topics.getTopicForPurpose(chatId, 'alerts'); */ type TopicPurpose = 'general' | 'trading' | 'portfolio' | 'research' | 'alerts' | 'governance' | 'social' | 'admin'; interface TopicConfig { /** Telegram message_thread_id */ threadId: number; /** Human-readable topic name (as set in Telegram) */ name: string; /** Mapped purpose category */ purpose: TopicPurpose; /** Whether notifications should be routed here */ receivesNotifications: boolean; } interface ChatTopics { /** Telegram chat ID (group/supergroup) */ chatId: string; /** Whether forum mode is enabled for this chat */ forumEnabled: boolean; /** Registered topics */ topics: Map; /** Purpose → threadId quick lookup */ purposeMap: Map; } declare class ForumTopicsService { private chats; /** * Register a topic for a chat. Auto-maps name to purpose. */ registerTopic(chatId: string, threadId: number, name: string, purpose?: TopicPurpose): TopicConfig; /** * Remove a topic registration. */ unregisterTopic(chatId: string, threadId: number): boolean; /** * Get the thread ID for a given purpose in a chat. * Returns undefined if no topic is mapped for that purpose. */ getTopicForPurpose(chatId: string, purpose: TopicPurpose): number | undefined; /** * Get the thread ID for routing a notification. * Falls back: alerts topic → general topic → undefined. */ getNotificationTopic(chatId: string): number | undefined; /** * Get the purpose for a specific thread in a chat. */ getTopicPurpose(chatId: string, threadId: number): TopicPurpose | undefined; /** * Generate a session key suffix for a topic, enabling isolated LLM sessions. * Returns '-topic-{threadId}' or empty string if no forum mode. */ getSessionKeySuffix(chatId: string, threadId?: number): string; /** * Check if forum mode is enabled for a chat. */ isForumEnabled(chatId: string): boolean; /** * Enable/disable forum mode for a chat. */ setForumEnabled(chatId: string, enabled: boolean): void; /** * List all registered topics for a chat. */ listTopics(chatId: string): TopicConfig[]; /** * List all chats with forum mode enabled. */ listForumChats(): string[]; /** * Get suggested topic structure for a new forum-enabled chat. */ getSuggestedTopics(): Array<{ name: string; purpose: TopicPurpose; emoji: string; }>; private getOrCreateChat; private resolvePurpose; } declare function getForumTopics(): ForumTopicsService; declare function resetForumTopics(): void; /** Persist all forum topic state to disk. Called on graceful shutdown. */ declare function persistForumTopics(): void; /** Restore forum topic state from disk. Called on startup. */ declare function restoreForumTopics(): void; //#endregion export { ChatTopics, ForumTopicsService, TopicConfig, TopicPurpose, getForumTopics, persistForumTopics, resetForumTopics, restoreForumTopics }; //# sourceMappingURL=forum-topics.d.mts.map