import type { LLMProvider } from '../llm/types.js'; import type { Message } from '../types.js'; /** 从对话中提取的原子事实 */ export interface AtomFact { /** 记忆键(snake_case,用于 upsert) */ key: string; /** 事实内容 */ content: string; /** 分类 */ category: 'user_preference' | 'project_knowledge' | 'learned_fact' | 'custom'; /** 重要程度 1-5 */ importance: number; /** 来源会话 ID */ sourceSessionId: string; } /** 提取配置 */ export interface ExtractorOptions { /** LLM Provider 实例 */ llmProvider: LLMProvider; /** 降级 LLM Provider(可选,主 Provider 失败时切换) */ fallbackProvider?: LLMProvider; /** 单次提取最大原子事实数,默认 5 */ maxFactsPerSession?: number; /** 触发提取的最小迭代次数,默认 3 */ minIterations?: number; /** 提取超时(毫秒),默认 30000 */ timeoutMs?: number; } /** * LLM 驱动的原子事实提取器 * 从对话历史中提取持久性、可复用的结构化事实(L1 Atom) */ export declare class MemoryExtractor { private llmProvider; private fallbackProvider?; private maxFactsPerSession; private minIterations; private timeoutMs; constructor(opts: ExtractorOptions); /** * 从对话消息中提取原子事实 * @param messages 对话消息列表 * @param sessionId 当前会话 ID * @param existingKeys 已有的记忆键(用于去重) * @returns 提取到的原子事实数组 */ extract(messages: Message[], sessionId: string, existingKeys: string[]): Promise; /** * 调用 LLM 提取事实 */ private callLLM; /** * 单次流式 LLM 调用 */ private callLLMStream; /** * 解析 LLM 输出的 JSON 数组 */ private parseFacts; private normalizeCategory; /** * 构建对话摘要(将消息列表压缩为文本,限制总字符数) */ private buildMessagesSummary; } //# sourceMappingURL=extractor.d.ts.map