/** 用户会话记录 */ export interface UserSession { chat_id: string; session_id: string; project_path: string; created_at: string; updated_at: string; } /** 白名单用户记录 */ export interface WhitelistUser { user_id: string; added_by: string; added_at: string; } /** 项目路径映射 */ export interface ProjectMapping { chat_id: string; project_path: string; updated_at: string; } /** 事件去重记录 */ export interface EventDedup { event_id: string; processed_at: string; } /** 消息映射记录 */ export interface MessageMapping { user_message_id: string; bot_message_id: string | null; chat_id: string; created_at: string; } /** 会话群记录 */ export interface SessionChat { chat_id: string; session_id: string; owner_id: string; project_path: string; title: string | null; title_set: boolean; created_at: string; updated_at: string; } /** 机器人数据库操作类 */ export declare class BotDatabase { private db; private dedupWindowMs; constructor(dbPath: string, dedupWindowMs?: number); /** 初始化数据库表结构 */ private initialize; /** 获取用户会话 */ getSession(chatId: string): UserSession | null; /** 创建或更新用户会话 */ upsertSession(chatId: string, sessionId: string, projectPath: string): void; /** 删除用户会话 */ deleteSession(chatId: string): boolean; /** 检查用户是否在白名单中 */ isUserWhitelisted(userId: string): boolean; /** 添加用户到白名单 */ addToWhitelist(userId: string, addedBy: string): boolean; /** 从白名单移除用户 */ removeFromWhitelist(userId: string): boolean; /** 获取所有白名单用户 */ getWhitelistedUsers(): WhitelistUser[]; /** 获取聊天的项目路径 */ getProjectPath(chatId: string): string | null; /** 设置聊天的项目路径 */ setProjectPath(chatId: string, projectPath: string): void; /** 检查事件是否已处理(用于去重) */ isEventProcessed(eventId: string): boolean; /** 标记事件为已处理 */ markEventProcessed(eventId: string): boolean; /** 清理过期的事件记录 */ cleanupOldEvents(): number; saveMessageMapping(userMessageId: string, chatId: string): void; updateBotMessageId(userMessageId: string, botMessageId: string): void; getMessageMapping(userMessageId: string): MessageMapping | null; deleteMessageMapping(userMessageId: string): boolean; getMessageMappingsAfter(userMessageId: string, chatId: string): MessageMapping[]; deleteMessageMappings(userMessageIds: string[]): number; deleteMessageMappingsByChatId(chatId: string): number; cleanupOldMessageMappings(maxAgeMs?: number): number; createSessionChat(chatId: string, sessionId: string, ownerId: string, projectPath: string): void; getSessionChat(chatId: string): SessionChat | null; getSessionChatsByOwner(ownerId: string): SessionChat[]; updateSessionChatTitle(chatId: string, title: string): void; deleteSessionChat(chatId: string): boolean; isSessionChat(chatId: string): boolean; /** 关闭数据库连接 */ close(): void; } /** 初始化数据库 */ export declare function initializeDatabase(dbPath: string): BotDatabase; /** 获取默认数据库实例 */ export declare function getDatabase(): BotDatabase; //# sourceMappingURL=index.d.ts.map