/** * intent-cache — 意图缓存与自学习引擎 * * 将宿主AI的判定结果缓存到本地,实现: * 1. 精确匹配:相同输入直接命中 * 2. 模糊匹配:编辑距离 ≤ 2 的输入也命中 * 3. 命中统计:高频意图逐步固化 * 4. 零LLM成本:纯本地文件读写 */ import type { AskResult } from './ask-engine'; export interface CachedIntent { /** 缓存的输入文本 */ input: string; /** 归一化后的输入(用于语义级缓存命中) */ normalizedInput: string; /** 匹配的 AskResult */ result: AskResult; /** 来源:local / host-ai / llm */ source: string; /** 命中次数 */ hitCount: number; /** 首次缓存时间 */ createdAt: string; /** 最后命中时间 */ lastUsed: string; } export interface IntentCache { version: string; entries: Record; /** 固化规则:命中次数超过阈值自动生成的本地规则建议 */ solidified: string[]; } /** * 查询缓存:精确 → 归一化语义 → 编辑距离模糊 */ export declare function getCachedIntent(input: string): Promise; /** * 写入缓存 */ export declare function cacheIntent(input: string, result: AskResult, source?: string): Promise; /** * 获取可固化的意图列表(命中次数超过阈值) */ export declare function getSolidifiableIntents(minHits: number): Promise; /** * 标记意图为已固化 */ export declare function markSolidified(input: string): Promise; /** * 获取缓存统计信息 */ export declare function getCacheStats(): Promise<{ total: number; solidified: number; avgHits: number; }>; //# sourceMappingURL=intent-cache.d.ts.map