import type { MemoryEntry, MemoryLayer } from './types.js'; /** 召回结果 */ export interface RecallResult { /** 召回的记忆条目(按相关度排序) */ entries: ScoredMemoryEntry[]; /** 是否超时 */ timedOut: boolean; /** 召回策略描述 */ strategy: string; } /** 带分数的记忆条目 */ export interface ScoredMemoryEntry extends MemoryEntry { /** 相关度分数 0-1 */ relevanceScore: number; } /** 召回配置 */ export interface RecallOptions { /** 最大返回条数,默认 5 */ maxResults?: number; /** 召回超时(毫秒),默认 3000 */ timeoutMs?: number; /** 仅召回指定层级 */ layers?: MemoryLayer[]; } /** * 智能记忆召回引擎 * * 召回策略(优先级排序): * 1. 关键词匹配:userText 分词后与 key/content 做模糊匹配 * 2. 重要性加权:importance 高的记忆权重更大 * 3. 时效性衰减:近期更新的记忆优先(updatedAt 越新分数越高) * * 超时保护:超过 timeoutMs 立即返回空结果,不阻塞对话 */ export declare class MemoryRecallEngine { /** * 召回相关记忆(带超时保护) */ recall(userText: string, allMemories: MemoryEntry[], options?: RecallOptions): Promise; private recallInner; /** * 提取查询词项(简单分词) * 支持中英文混合:英文按空格,中文按字 */ private extractTerms; /** * 计算关键词匹配分数(TF-IDF 加权) * 稀有词(出现在少量记忆中)获得更高权重,常见词权重降低 */ private computeKeywordScore; /** * 构建 IDF 映射表:term → IDF 分数 * IDF = log(N / df),N=总文档数,df=包含该 term 的文档数 */ private buildIDFMap; /** * 计算时效性分数(0-1) * 24 小时内的记忆得 1.0,30 天前的记忆得 ~0.1 */ private computeRecencyScore; } /** * 将召回结果格式化为可注入 system prompt 的文本 */ export declare function formatRecallForPrompt(result: RecallResult): string; //# sourceMappingURL=recall.d.ts.map