feat: v0.8.1 记忆深化 · 观测闭环 · 体验收口 — 窗口/输出上限全局单一配置 · 2478 用例全量回归 + E2E 冒烟
硬性契约:删除代码中一切写死的上下文窗口与最大输出上限(含六家模型元信息
钳制与全部兜底值)——唯一合法来源是设置面板「上下文长度」(llm.contextWindow)
与「最大输出上限」(llm.maxTokens),跨 Provider/模型原样透传。
P0 正确性收口:
- 迁移 11/12(SCHEMA_VERSION 5):记忆表 embedding 列 + 分 Provider 窗口键清理
- 记忆生命周期接线:会话终态清理 working memory / episodic 90 天 TTL / access_count 回写
- 回放缓冲模块化 + 会话终态清理(杜绝 4MB/会话内存滞留)
- i18n 收口:主进程 main-locale(zh/en,ui.locale 热切换)+ 渲染层 17 处出层
P1 能力演进:
- 本地向量混合检索:0.6×向量余弦 + 0.4×TF-IDF,Ollama embeddings 首次投产,
存量记忆惰性回填,嵌入不可用自动回退 TF-IDF
- MEMORY.md 维护闭环:固化去重消除截断盲区;两阶段维护(AI 建议 → 用户确认 →
原子改写 + 语义记忆双轨同步 + 审计);>50KB 告警
- 可观测闭环:cacheTokens 引擎→前端透传(Token 面板命中率/成本行)+ 输入框
上下文占用指示条
- MCP Prompts/Resources 对话可用:/mcp:{server}:{prompt} 与 @mcp:{server}:{uri}
P2 体验补全:
- 工具自定义策略(正则白/黑名单 + 频率 + 强制确认,热生效)
- 连续 ≥3 同类工具确认聚合为单弹框
- 会话消息游标分页(首屏 200 条向上翻页)
- 开机自启;Playwright + Electron E2E 冒烟(本地 mock LLM 零外联)
Review 回归修复:MCP 大小写失配 / 分页状态复位 / 清空=未配置语义(Number(null)=0
隐患)/ MEMORY.md 告警位置 / working_memories FK(迁移 13)/ 全局配置层废键清理;
附带根治权限加固启动时序、代理回环放行、safeStorage 降级、悬空 symlink 逃逸。
验证:typecheck/lint 0 问题;test:electron 2478/2478(0 跳过);E2E 2/2;
docs/v0.8.1-迭代实施清单.md 全项留档。
This commit is contained in:
@@ -16,14 +16,24 @@ import type { MemoryManager } from '../../memory/manager';
|
||||
export class MemoryStoreTool implements IMetonaTool {
|
||||
readonly definition: MetonaToolDef = {
|
||||
name: 'memory_store',
|
||||
description: 'Store a piece of information in persistent memory. Useful for remembering important facts, decisions, or user preferences across sessions.',
|
||||
description:
|
||||
'Store a piece of information in persistent memory. Useful for remembering important facts, decisions, or user preferences across sessions.',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
content: { type: 'string', description: 'The memory content to store' },
|
||||
type: { type: 'string', description: 'Memory type: "episodic" (events), "semantic" (knowledge), or "working" (task state)', enum: ['episodic', 'semantic', 'working'] },
|
||||
type: {
|
||||
type: 'string',
|
||||
description:
|
||||
'Memory type: "episodic" (events), "semantic" (knowledge), or "working" (task state)',
|
||||
enum: ['episodic', 'semantic', 'working'],
|
||||
},
|
||||
importance: { type: 'number', description: 'Importance score 0-1 (default 0.5)' },
|
||||
source: { type: 'string', description: 'Source of the memory', enum: ['user_input', 'tool_result', 'agent_thought', 'imported'] },
|
||||
source: {
|
||||
type: 'string',
|
||||
description: 'Source of the memory',
|
||||
enum: ['user_input', 'tool_result', 'agent_thought', 'imported'],
|
||||
},
|
||||
},
|
||||
required: ['content', 'type'],
|
||||
},
|
||||
@@ -39,7 +49,9 @@ export class MemoryStoreTool implements IMetonaTool {
|
||||
const content = args.content as string;
|
||||
const type = args.type as 'episodic' | 'semantic' | 'working';
|
||||
const importance = (args.importance as number) ?? 0.5;
|
||||
const source = (args.source as 'user_input' | 'tool_result' | 'agent_thought' | 'imported') ?? 'agent_thought';
|
||||
const source =
|
||||
(args.source as 'user_input' | 'tool_result' | 'agent_thought' | 'imported') ??
|
||||
'agent_thought';
|
||||
|
||||
// v0.3.0 修复: store() 是同步方法,移除多余的 await 避免误导维护者
|
||||
const id = this.memoryManager.store({
|
||||
@@ -59,14 +71,23 @@ export class MemoryStoreTool implements IMetonaTool {
|
||||
export class MemorySearchTool implements IMetonaTool {
|
||||
readonly definition: MetonaToolDef = {
|
||||
name: 'memory_search',
|
||||
description: 'Search persistent memory for relevant information. Returns memories sorted by relevance.',
|
||||
description:
|
||||
'Search persistent memory for relevant information. Returns memories sorted by relevance.',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
query: { type: 'string', description: 'Search query or keywords' },
|
||||
type: { type: 'string', description: 'Filter by memory type', enum: ['episodic', 'semantic', 'working'] },
|
||||
type: {
|
||||
type: 'string',
|
||||
description: 'Filter by memory type',
|
||||
enum: ['episodic', 'semantic', 'working'],
|
||||
},
|
||||
topK: { type: 'number', description: 'Number of results (default 5)' },
|
||||
threshold: { type: 'number', description: 'Minimum importance score 0-1 (default 0.7). Filters memories by importance, not search relevance.' },
|
||||
threshold: {
|
||||
type: 'number',
|
||||
description:
|
||||
'Minimum importance score 0-1 (default 0.7). Filters memories by importance, not search relevance.',
|
||||
},
|
||||
},
|
||||
required: ['query'],
|
||||
},
|
||||
@@ -84,8 +105,8 @@ export class MemorySearchTool implements IMetonaTool {
|
||||
const topK = (args.topK as number) ?? 5;
|
||||
const threshold = (args.threshold as number) ?? 0.7;
|
||||
|
||||
// v0.3.0 修复: search() 是同步方法,移除多余的 await 避免误导维护者
|
||||
const results = this.memoryManager.search(query, {
|
||||
// v0.8.1: search() 升级为 async(向量混合检索),查询向量异步生成
|
||||
const results = await this.memoryManager.search(query, {
|
||||
topK,
|
||||
type,
|
||||
minImportance: threshold,
|
||||
|
||||
Reference in New Issue
Block a user