dsh-layered-memory 0.7.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.en.md +165 -75
  2. package/README.md +174 -104
  3. package/assets/img/EmbeddingSource.png +0 -0
  4. package/assets/img/MemoryTools.png +0 -0
  5. package/assets/img/ToolTrajectory.png +0 -0
  6. package/assets/readme/bench-dialog.svg +87 -0
  7. package/assets/readme/bench-workflow.svg +79 -0
  8. package/assets/readme/flow.svg +74 -74
  9. package/assets/readme/storage.svg +56 -56
  10. package/dist/client.js +380 -2
  11. package/dist/config.d.ts +41 -1
  12. package/dist/config.js +10 -3
  13. package/dist/hooks/recall.d.ts +11 -8
  14. package/dist/hooks/recall.js +70 -51
  15. package/dist/index.d.ts +20 -0
  16. package/dist/index.js +15 -4
  17. package/dist/llm.d.ts +28 -0
  18. package/dist/llm.js +33 -0
  19. package/dist/pipeline/l1.js +5 -4
  20. package/dist/pipeline/l2.js +7 -2
  21. package/dist/pipeline/l3.js +7 -2
  22. package/dist/pipeline/rebuild.js +2 -2
  23. package/dist/pipeline/runner.d.ts +45 -8
  24. package/dist/pipeline/runner.js +185 -39
  25. package/dist/pipeline/trigger.d.ts +38 -0
  26. package/dist/pipeline/trigger.js +64 -0
  27. package/dist/settings.d.ts +14 -0
  28. package/dist/settings.js +41 -2
  29. package/dist/stats.js +113 -1
  30. package/dist/store/bm25.js +2 -1
  31. package/dist/store/download-queue.d.ts +35 -2
  32. package/dist/store/download-queue.js +102 -5
  33. package/dist/store/embedding.d.ts +12 -6
  34. package/dist/store/embedding.js +10 -7
  35. package/dist/store/l0.d.ts +2 -0
  36. package/dist/store/l0.js +4 -0
  37. package/dist/store/l1.d.ts +2 -0
  38. package/dist/store/l1.js +2 -2
  39. package/dist/store/model-catalog.js +1 -1
  40. package/dist/store/pending.d.ts +27 -6
  41. package/dist/store/pending.js +49 -9
  42. package/dist/store/search-utils.js +3 -2
  43. package/dist/store/session-modes.d.ts +4 -0
  44. package/dist/store/session-modes.js +16 -0
  45. package/dist/store/sqlite.d.ts +12 -0
  46. package/dist/store/sqlite.js +103 -5
  47. package/dist/util/recall-budget.d.ts +32 -0
  48. package/dist/util/recall-budget.js +85 -0
  49. package/dist/util/text.d.ts +8 -3
  50. package/dist/util/text.js +41 -15
  51. package/dist/util/tokenizer.d.ts +14 -0
  52. package/dist/util/tokenizer.js +53 -0
  53. package/package.json +6 -3
package/README.md CHANGED
@@ -1,57 +1,26 @@
1
- **简体中文** | [English](README.en.md)
1
+ <div align="center">
2
2
 
3
- <p align="center">
4
- <img src="./assets/img/Hero.png" width="100%"
5
- alt="DeepSeek Harness hero 横幅:对话自动分层蒸馏成记忆,模型每步前自动召回注入——右侧对话气泡逐层溶解为三层渐亮光带,流入带发光圆球与渐变轨道的玻璃胶囊(下有 日常·工作·智能·关闭 四档刻度),光丝回流示意召回注入">
6
- </p>
3
+ <img src="./assets/img/Hero.png" width="100%"
4
+ alt="DeepSeek Harness hero 横幅:对话自动分层蒸馏成记忆,模型每步前自动召回注入——右侧对话气泡逐层溶解为三层渐亮光带,流入带发光圆球与渐变轨道的玻璃胶囊(下有 日常·工作·智能·关闭 四档刻度),光丝回流示意召回注入">
7
5
 
8
6
  # dsh-layered-memory
9
7
 
10
- DeepSeek Harness 的**分层蒸馏记忆插件**(持久组合插件):对话在后台自动完成
11
- L0 捕获 → L1 原子记忆 → L2 场景整合 → L3 画像蒸馏,模型每一步前自动把相关记忆
12
- 注入上下文——用户与模型都不需要做任何操作。
13
-
14
- > 本插件的记忆核心能力(L0–L3 分层蒸馏管线、Prompt 与双写存储设计)参考自
15
- > [TencentDB-Agent-Memory](https://github.com/TencentCloud/TencentDB-Agent-Memory)
16
- > 中的 **MemoryCore**:Prompt 原样保留,仅把"LLM 操作文件"的 L2/L3 流程适配为
17
- > "LLM 输出、工程侧执行"。
18
-
19
- ## 运行时数据流
20
-
21
- <p align="center">
22
- <img src="./assets/readme/flow.svg" width="100%"
23
- alt="dsh-layered-memory 运行时数据流:左侧 User 与 Assistant 的会话事件流入插件(L0 捕获、L1–L3 蒸馏、检索召回、记忆工具),插件经 agent/pre-step 把相关记忆注入右侧 DSH 核心;蒸馏复用核心的 ctx.llm,数据双写 ~/.dsh/memory/">
24
- </p>
25
-
26
- 插件挂在 dsh 原生事件缝上(`session/event` 捕获、`agent/pre-step` 注入),
27
- 蒸馏调用复用宿主 `ctx.llm`,全程对用户与模型透明。另注册三个模型可主动调用的
28
- 记忆工具:`memory_search` / `conversation_search` / `memory_read_scene`。
8
+ **DeepSeek Harness 的分层蒸馏记忆插件:对话在后台自动完成 L0 捕获 → L1 原子记忆 → L2 场景整合 → L3 画像蒸馏,模型每一步前自动把相关记忆注入上下文。**
29
9
 
30
- ## 分层记忆(L0–L3)
10
+ [English](README.en.md) · [最新发行版](https://github.com/JunNanLYS/dsh-layered-memory/releases/latest) · [反馈问题](https://github.com/JunNanLYS/dsh-layered-memory/issues)
31
11
 
32
- <p align="center">
33
- <img src="./assets/img/Layers.png" width="100%"
34
- alt="分层记忆四层(自左上向右下逐层精炼):L0 原始对话(对话气泡)→ L1 原子记忆(发光事实粒子)→ L2 场景块(玻璃文档板)→ L3 核心画像(发光晶核);层间由 LLM 提取/整合/蒸馏光束相连,宽度递减表示数据逐层精炼">
35
- </p>
12
+ [![npm version](https://img.shields.io/npm/v/dsh-layered-memory?color=6f83ff&style=flat-square&label=npm)](https://www.npmjs.com/package/dsh-layered-memory)
13
+ [![DSH 0.1.0-rc.6](https://img.shields.io/badge/DSH-0.1.0--rc.6-8b5cf6?style=flat-square)](https://github.com/deepseek-ai/deepseek-harness)
14
+ [![MIT License](https://img.shields.io/badge/license-MIT-536990?style=flat-square)](LICENSE)
36
15
 
37
- ## 会话级记忆档位
38
-
39
- <p align="center">
40
- <img src="./assets/img/Modes.png" width="100%"
41
- alt="会话级记忆档位:一条玻璃胶囊滑轨四个停点(日常·工作·智能·关闭),发光圆球停在智能(默认)档;各档上方微场景——日常为个人聊天气泡、工作为代码文档窗格、智能为双流合流最亮、关闭为暗淡虚线幽灵泡">
42
- </p>
43
-
44
- - **控件**:输入栏内、模式选择器右侧的 pill(`记忆·自动`),点击在上方浮出 macOS
45
- 风格滑动选择器——拖拽松手吸附最近档位;深浅主题自适应;
46
- - 每会话的选择按 sessionId 持久化到 `session-modes.json`,重启/恢复会话不丢;
47
- 与全局开关叠加(全局是总闸);L2/L3 完全分族,跨族内容不渗透。
16
+ </div>
48
17
 
49
18
  ## 快速开始
50
19
 
51
20
  需要 Node ≥ 22.16。两种调用方式任选(`npx` 前缀可替换下面任何 `dsh` 命令):
52
21
 
53
22
  ```bash
54
- # 方式一:npx 直接跑官方 CLI(无需预装 dsh;可 pin 版本,如 dsh-layered-memory@0.6.1)
23
+ # 方式一:npx 直接跑官方 CLI(无需预装 dsh;可 pin 版本,如 dsh-layered-memory@0.8.0)
55
24
  npx -y @deepseek-ai/dsh plugin --profile web add dsh-layered-memory
56
25
 
57
26
  # 方式二:已装 dsh CLI(dsh 是 pnpm 转发器,未装 pnpm 时先 npm i -g pnpm)
@@ -62,14 +31,28 @@ dsh plugin --profile web add https://github.com/JunNanLYS/dsh-layered-memory
62
31
  dsh plugin --profile web add /path/to/dsh-layered-memory
63
32
  ```
64
33
 
34
+ ### 让 Agent 安装(推荐)
35
+
36
+ 如果当前 Agent 可以执行终端命令,把下面这段话完整发送给它:
37
+
38
+ ```text
39
+ 请为 DeepSeek Harness 的 web Profile 安装 dsh-layered-memory 插件。
40
+
41
+ 只执行下面两条命令,不要修改其他 Profile:
42
+ dsh plugin --profile web add dsh-layered-memory
43
+ dsh --profile web --dump-config
44
+
45
+ 确认输出中出现 dsh-layered-memory 后告诉我安装结果。
46
+ 不要替我关闭或重启正在运行的 DSH;安装完成后提醒我手动重启 DSH Web Host。
47
+ ```
48
+
49
+ Agent 应当返回安装结果,并明确告诉你配置中是否已经出现 `dsh-layered-memory`。
50
+
65
51
  本包声明了 `dsh.bundle` 组合包层(`cordis.patch.yml`),安装后会**自动挂载插件行**——
66
52
  不需要再手改 `$DSH_HOME/profiles/web/cordis.patch.yml`。然后重启 DeepSeek Harness,
67
53
  验证:`~/.dsh/memory/` 下出现 `conversations/ records/ scenes/` 目录和 `memory.db`
68
54
  即插件 apply 成功;设置页出现"记忆"页面、输入栏出现档位 pill 即 client 半边就绪。
69
55
 
70
- > ⚠️ **安全提示**:安装插件 = 以你的权限运行第三方代码。本插件会读取会话内容、
71
- > 在数据目录写文件、调用你配置的 LLM/embedding 服务;介意请先审查源码(`src/`)。
72
-
73
56
  **卸载**:`dsh plugin --profile web remove dsh-layered-memory` + 重启。数据保留在
74
57
  `~/.dsh/memory/`,不需要时手动删除整个目录即可。
75
58
 
@@ -84,6 +67,52 @@ npm run smoke # 冒烟测试(先重编:见下方命
84
67
  npx tsc src/smoke.ts --outDir dist-smoke --module nodenext --moduleResolution nodenext --target es2022 --strict --skipLibCheck --esModuleInterop
85
68
  ```
86
69
 
70
+ ## 运行时数据流
71
+
72
+ <p align="center">
73
+ <img src="./assets/readme/flow.svg" width="100%"
74
+ alt="dsh-layered-memory 运行时数据流:左侧 User 与 Assistant 的会话事件流入插件(L0 捕获、L1–L3 蒸馏、检索召回、记忆工具),插件经 agent/pre-step 把相关记忆注入右侧 DSH 核心;蒸馏复用核心的 ctx.llm,数据双写 ~/.dsh/memory/">
75
+ </p>
76
+
77
+ 插件挂在 dsh 原生事件上(`session/event` 捕获、`agent/pre-step` 注入),蒸馏调用复用宿主 `ctx.llm`。召回以**消息侧注入**呈现:相关记忆作为一条合成消息排在用户新消息之前,会话流里显示为**"上下文注入 · memory"**行(点开看命中内容)——用户能直接看到"记忆生效了";注入内容有长度预算与时间预算,超限截断/超时跳过,绝不拖慢对话。
78
+
79
+ **记忆工具(3):**
80
+ - memory_search
81
+ - conversation_search
82
+ - memory_read_scene
83
+
84
+ 真机实录:召回注入与工具调用在对话里的样子——"上下文注入 · memory"行先带出相关记忆,模型再按需调 `memory_read_scene` 读取场景块,凭记忆直接作答:
85
+
86
+ <p align="center">
87
+ <img src="./assets/img/MemoryTools.png" width="60%"
88
+ alt="对话界面实录(浅色主题):用户消息"我们最近要干什么?"上方可见"上下文注入 · memory"行;助手回答前列出 4 次 memory_read_scene 工具调用(参数为 scenes 场景块的 .md 文件名),随后凭记忆梳理近期目标与推进路线">
89
+ </p>
90
+
91
+ 在只开放代码执行入口的受限会话中,模型经由 `run_code` 间接调用记忆工具(轨迹视图中的 SUBTOOL 嵌套):
92
+
93
+ <p align="center">
94
+ <img src="./assets/img/ToolTrajectory.png" width="80%"
95
+ alt="工具调用轨迹视图:顶部彩色时间线与左侧步骤列表(SYSTEM/CONTEXT/USER/ASSISTANT/TOOL/SUBTOOL 彩色标签),run_code 工具步骤内嵌套 5 次 memory_read_scene 子工具调用(SUBTOOL 标记),右侧为所选步骤的详情面板">
96
+ </p>
97
+
98
+ ## 分层记忆(L0–L3)
99
+
100
+ <p align="center">
101
+ <img src="./assets/img/Layers.png" width="100%"
102
+ alt="分层记忆四层(自左上向右下逐层精炼):L0 原始对话(对话气泡)→ L1 原子记忆(发光事实粒子)→ L2 场景块(玻璃文档板)→ L3 核心画像(发光晶核);层间由 LLM 提取/整合/蒸馏光束相连,宽度递减表示数据逐层精炼">
103
+ </p>
104
+
105
+ ## 会话级记忆档位
106
+
107
+ <p align="center">
108
+ <img src="./assets/img/Modes.png" width="100%"
109
+ alt="会话级记忆档位:一条玻璃胶囊滑轨四个停点(日常·工作·智能·关闭),发光圆球停在智能(默认)档;各档上方微场景——日常为个人聊天气泡、工作为代码文档窗格、智能为双流合流最亮、关闭为暗淡虚线幽灵泡">
110
+ </p>
111
+
112
+ - **控件**:输入栏内、模式选择器右侧的 pill(`记忆·自动`),点击在上方浮出档位滑块深浅主题自适应;
113
+ - 每会话的选择按 sessionId 持久化到 `session-modes.json`,重启/恢复会话不丢;
114
+ 与全局开关叠加(全局是总闸);L2/L3 完全分类,分类内容不渗透。
115
+
87
116
  ## 界面预览
88
117
 
89
118
  <p align="center">
@@ -93,6 +122,81 @@ npx tsc src/smoke.ts --outDir dist-smoke --module nodenext --moduleResolution no
93
122
  alt="浅色主题下的同一设置页记忆浏览器概览:同款布局与信息,浅色卡片底与同套强调色,主题切换无需重载">
94
123
  </p>
95
124
 
125
+ ## 实测对比(DSH-MemBench:自动化基准)
126
+
127
+ 图文回答"长什么样",这一节用**自动化基准**的实测数字回答"**开了到底有什么用**"([`bench/`](./bench/),一条命令可复现)。方法:同场景库、逐字相同输入,**A 组(记忆开)** 与 **B 组(记忆关)** 各跑 3 次取合并值;环境 DeepSeek 官方 `deepseek-v4-flash`、插件 0.8.0、Windows;题型设计借鉴 [LongMemEval](https://github.com/xiaowu0162/longmemeval) / [LoCoMo](https://snap-research.github.io/locomo/) / [AMB](https://github.com/vectorize-io/agent-memory-benchmark)。
128
+
129
+ ### 对话赛道(15 场景 × 6 题型 × 3 次 = 270 题/组):答得准吗
130
+
131
+ <p align="center">
132
+ <img src="./assets/readme/bench-dialog.svg" width="100%"
133
+ alt="DSH-MemBench 对话赛道 A/B 对照条形图:A 组(记忆开)总准确率 92.6%(250/270),B 组(记忆关)17.8%(48/270);分题型各 45 题——抽取 A 45/45 对 B 3/45、多跳 A 45/45 对 B 0/45、时序 A 43/45 对 B 0/45、知识更新 A 31/45 对 B 0/45、场景回忆 A 41/45 对 B 0/45、拒答两组均 45/45 且 0 编造">
134
+ </p>
135
+
136
+ **召回双通道**(A 组):被动注入召回率 **75.1%**(该题要点出现在召回注入中,169/225),其余多数由模型**主动调用记忆工具**查回——84 题主动查询、**60 题靠工具兜底答对**;端到端 92.6% 是两通道 + 模型利用的合成结果。记忆库跨场景全程累积下,探针召回注入混入其他场景记忆 144 次(已如实计数),总准确率仍稳在 92.6%——抗干扰能力经受住了膨胀记忆库的考验。
137
+
138
+ ### 工作流赛道(4 场景 × 3 次,真实工具沙箱):做得对、做得省吗
139
+
140
+ <p align="center">
141
+ <img src="./assets/readme/bench-workflow.svg" width="100%"
142
+ alt="DSH-MemBench 工作流赛道 A/B 对照图:任务完成度 A 组 24/33(72.7%)对 B 组 11/33(33.3%);成本对比(B 组为满格基准)——步骤 125 对 186(B +49%)、工具调用 184 对 296(B +61%)、输入 token 1.30M 对 1.86M(B +43%);向用户求助 A 0 次对 B 3 次;登录场景输入 token A 241k 对 B 453k(+88%)">
143
+ </p>
144
+
145
+ **登录场景特写**(凭据只存在于记忆,站点为本地服务、令牌不可伪造):A 组三次全部**一轮直取**完成(6/6,241k 输入);B 组每次都要**反问用户要凭据**(3 次求助、双倍轮次)才完成 5/6,输入 453k——**+88%**。这正是记忆的核心价值之一:**省掉的不是任务难度,是无谓的往返与重复教学**。
146
+
147
+ ### 方法论与复现
148
+
149
+ ```bash
150
+ node bench/harness/run.mjs --arm A --repeats 3 --provider deepseek-official --model deepseek-v4-flash
151
+ node bench/harness/run.mjs --arm B --repeats 3 --provider deepseek-official --model deepseek-v4-flash # 对话赛道
152
+ node bench/harness/run.mjs --track workflow --arm A/B --repeats 3 ... # 工作流赛道
153
+ node bench/harness/report.mjs --latest [dialog|workflow] # 汇总报告
154
+ ```
155
+
156
+ - 判分:`contains-all` 程序判 + 判卷模型按要点判(答案原文与判分理由全部留痕 `result.json` 可人工复核);工作流完成度为产物文件 + 关键内容程序化校验;
157
+ - 指标全部来自供应商上报 usage(输入含缓存命中拆分)与会话事件折叠;**稳态缓存率**剔除每会话首请求(A 88.7% vs B 85.4%——记忆注入不伤缓存);
158
+ - 回归用途:改插件前后各跑一遍,`compare.mjs` 出对比表(环境头校验 + B 组对照组漂移告警);
159
+ - 局限(诚实声明):单机 ×3 次合并、判卷模型与被测模型同源、作者自建场景库(倾向记忆优势场景,欢迎自行复现);工具审计会标记越界访问(实测 Agent 偶发探测用户主目录,本基准场景答案不存于真实记忆库、数字不受影响)。
160
+
161
+ 完整报告与逐题数据:[`bench/baseline/`](./bench/baseline/)。
162
+
163
+ ## 存储布局
164
+
165
+ <p align="center">
166
+ <img src="./assets/readme/storage.svg" width="100%"
167
+ alt="存储布局:双写架构(JSONL 事实源只增不改 + memory.db 主检索库);文件形态含 conversations/records/scenes/persona/state/pending/session-modes/embedding-source/模型目录/推理运行时/日志与重建归档;检索三策略 keyword/embedding/hybrid(RRF k=60);降级链保证永不阻塞宿主">
168
+ </p>
169
+
170
+ 向量能力默认关闭(纯 FTS)。DSH 的 `ctx.llm` 无 embeddings 端点,语义检索由
171
+ **三态嵌入源**提供(关闭 / 远程 / 本地),设置页可运行时切换——见下节。
172
+
173
+ ## 语义检索(嵌入源)
174
+
175
+ 设置页(记忆 → 概览 → 语义检索)选择嵌入源,即时生效、无需改配置重启:
176
+
177
+ <p align="center">
178
+ <img src="./assets/img/EmbeddingSource.png" width="70%"
179
+ alt="设置页语义检索(嵌入源)面板(浅色主题):三态选择器(关闭/本地/远程,本地选中)显示当前嵌入源与首次启用自动安装运行时提示;下方本地模型目录列出 BGE small 中文(使用中/已就绪)、EmbeddingGemma 300M(下载 316MB)、BGE-M3(下载 560MB)三款模型的维度/上下文/体积/特点与下载入口">
180
+ </p>
181
+
182
+ 三种嵌入源:**关闭**(默认,纯 BM25 关键词检索)、**远程**(自备任意 OpenAI 兼容
183
+ `/embeddings` 服务,`embedding.*` 四件套配齐才可选)、**本地**(内置模型目录选一款,
184
+ ONNX 量化 **CPU 推理**——无需 API Key,数据不出本机)。本地模型目录是插件内置
185
+ 白名单(每款锁定 revision + 每文件 sha256,不可下载任意仓库)。
186
+
187
+ - **下载**:模型卡一键下载(默认镜像 `hf-mirror.com`,断点续传 + sha256 完整性
188
+ 校验;直连不可达时可走代理——默认自动探测 `HTTPS_PROXY`/`ALL_PROXY` 等环境
189
+ 变量,见 `embedding.proxy`)。单文件失败自动重试且换缓存键(`?dshmem-retry=N`,
190
+ 绕开镜像 CDN 偶发的坏缓存对象),校验失配从零重下、网络错误保留断点续传;
191
+ 落盘数据目录 `models/<id>/`,不用了随时在设置页删除;
192
+ - **按需运行时**:首次切换本地档才安装推理运行时(transformers.js,约 100~200MB,
193
+ 装进数据目录 `runtime/`——不进插件依赖树,不碰插件安装目录);
194
+ - **活切换**:一键换源——自动后台全量重嵌(进度可见、可取消,期间检索自动降级
195
+ 关键词,不影响对话;维度变化时向量表按新维度重建);切换失败保持旧源,重启仍按原源运行;
196
+ - **生效规则 = 部署上限 AND 运行时选择**:`embedding.allowLocalModels=false` 可整体
197
+ 禁用本地档、未配 `embedding.*` 四件套则远程档不可选(企业部署可收口),状态持久
198
+ 化在 `embedding-source.json`。
199
+
96
200
  ## 配置
97
201
 
98
202
  覆盖配置写在 profile 自己的 `cordis.patch.yml`,用**顶层裸 patch 条目**(直接 `id:`,
@@ -104,8 +208,8 @@ npx tsc src/smoke.ts --outDir dist-smoke --module nodenext --moduleResolution no
104
208
  name: dsh-layered-memory
105
209
  config: # 键按行整体替换(不深合并),按需写全要保留的键
106
210
  family: auto # 新会话默认档:auto | chat | work
107
- llm: # 蒸馏模型路由(不写则跟随当前默认模型)
108
- provider: ''
211
+ llm: # 蒸馏模型静态路由(双字段齐 = 部署 pin,优先于设置页选择;
212
+ provider: '' # 留空则跟随设置页"蒸馏模型"选择器或当前默认模型)
109
213
  model: ''
110
214
  ```
111
215
 
@@ -117,8 +221,9 @@ npx tsc src/smoke.ts --outDir dist-smoke --module nodenext --moduleResolution no
117
221
  | `capture.stripCodeBlocks` | `true` | 助手消息剥离代码块 |
118
222
  | `capture.maxMessageChars` | `4000` | 单条消息最大字符数 |
119
223
  | `extract.enabled` | `true` | L1 抽取 |
120
- | `extract.minMessages` | `1` | 攒够 N 条新消息跑一次 L1 抽取 |
121
- | `extract.backgroundMessages` | `10` | 抽取时附带的背景消息条数 |
224
+ | `extract.minMessages` | `6` | 稳态触发阈值:单会话攒够 N 条新消息跑一次 L1 抽取。起步阶段生效阈值从 1 翻倍爬坡到此值(首轮即出记忆,随后自动攒批省调用) |
225
+ | `extract.idleSeconds` | `300` | 闲置兜底:会话静默 N 秒后把未蒸馏切片落袋(接住"没攒够阈值用户就离开");`0` 关闭 |
226
+ | `extract.backgroundMessages` | `10` | 抽取时附带的背景消息条数(按会话从 L0 现查,会话间互不污染) |
122
227
  | `extract.candidatePool` | `5` | 去重候选池大小 |
123
228
  | `l2.enabled` | `true` | L2 场景整合 |
124
229
  | `l2.minNewMemories` | `5` | 距上次 L2 整合的新记忆阈值 |
@@ -127,9 +232,12 @@ npx tsc src/smoke.ts --outDir dist-smoke --module nodenext --moduleResolution no
127
232
  | `l3.enabled` | `true` | L3 画像蒸馏 |
128
233
  | `l3.interval` | `20` | L3 蒸馏间隔(新记忆条数) |
129
234
  | `recall.enabled` | `true` | 自动召回 |
130
- | `recall.maxResults` | `5` | 每步召回注入的 L1 条数 |
131
- | `recall.includePersona` | `true` | 召回时注入画像上下文(`<user-persona>`) |
132
- | `recall.includeSceneNav` | `true` | 召回时注入场景导航(`<scene-navigation>`) |
235
+ | `recall.maxResults` | `5` | 每条新用户消息前注入的 L1 条数上限 |
236
+ | `recall.maxCharsPerMemory` | `500` | 单条注入记忆的字符上限(超限截断并提示用记忆工具查全文);`0` 不限 |
237
+ | `recall.maxTotalRecallChars` | `2000` | 整轮注入总字符上限(超限按相关性丢尾部);`0` 不限 |
238
+ | `recall.timeoutMs` | `5000` | 召回总预算(ms):超时跳过本轮注入、不阻塞对话;`0` 不限时 |
239
+ | `recall.includePersona` | `true` | 系统提示注入画像上下文(`<user-persona>`,稳定区) |
240
+ | `recall.includeSceneNav` | `true` | 系统提示注入场景导航(`<scene-navigation>`,稳定区) |
133
241
  | `recall.strategy` | `hybrid` | 检索策略:`keyword` / `embedding` / `hybrid` |
134
242
  | `recall.scoreThreshold` | `0.3` | 召回分数阈值(低于不注入;仅 keyword/embedding 策略生效,hybrid 融合前不过滤;工具路径不过滤) |
135
243
  | `embedding.enabled` | `false` | 向量检索开关;关闭即纯 FTS 运行 |
@@ -141,69 +249,31 @@ npx tsc src/smoke.ts --outDir dist-smoke --module nodenext --moduleResolution no
141
249
  | `embedding.timeoutMs` | `10000` | 单次 embedding 调用超时(ms) |
142
250
  | `embedding.allowLocalModels` | `true` | 允许本地嵌入档(部署上限:关闭后设置页不能下载模型、不能切本地档) |
143
251
  | `embedding.mirror` | `https://hf-mirror.com` | 本地模型下载镜像根地址(可改回官方 `https://huggingface.co`) |
144
- | `llm.provider/model` | 空 | 蒸馏模型覆盖(默认用当前默认选择) |
145
- | `llm.maxTokens` | `256000` | 单次蒸馏输出 token 上限(全阶段统一;推理模型的 reasoning 与正文共享该预算,过低会被思考吃光导致正文 0 字符) |
252
+ | `embedding.proxy` | `''` | 模型下载代理三态:`''`(默认)= 自动探测代理环境变量(`HTTPS_PROXY`/`ALL_PROXY` 等,尊重 `NO_PROXY`);`none` = 禁用强制直连;其他值 = 代理 URL(如 `http://127.0.0.1:7890`)。镜像直连在国内网络间歇不可达(直连超时与污染字节交替出现过),开代理的机器建议保持默认自动探测 |
253
+ | `llm.provider/model` | 空 | 蒸馏模型静态路由(部署 pin):provider 与 model **双字段齐**时锁定蒸馏路由,优先于设置页的运行时选择与默认模型(部署可强制蒸馏走指定路由);留空则跟随"设置页选择 → 默认模型"。运行时可在设置页 → 记忆 → 概览的"蒸馏模型"选择器从**已配置的供应商**(含 dsh 设置 → 模型里添加的自定义供应商)中切换,即时生效无需重启 |
254
+ | `llm.maxTokens` | `65536` | 未分层调用的兜底输出总闸。各蒸馏层有独立预算(抽取 16k / 去重 8k / L2 32k / L3 16k;思考档 high/max 时自动 ×4,防 reasoning 吃光预算),分层预算可在设置页 → 记忆 → 概览 → 蒸馏参数运行时调整(留空/0 = 跟随内置默认) |
146
255
  | `llm.reasoningEffort` | `off` | 蒸馏思考档位(部署默认):`off` / `high` / `max`,空串不传(跟随模型默认)。蒸馏是结构化抽取任务,默认关思考——推理模型(如 v4-flash)默认 high 档的思考可把任意输出预算全部吃光导致正文 0 字符;非推理模型不认识 effort 时需设为空串。运行时可在设置页 → 记忆 → 概览临时切换(选"跟随配置"即回退本值) |
147
256
  | `llm.temperature` | `0.3` | 蒸馏温度 |
148
- | `llm.maxInputChars` | `700000` | 单次蒸馏输入字符预算(超限的 L1 输入自动分块抽取) |
257
+ | `llm.maxInputChars` | `700000` | 单次蒸馏输入字符预算(超限的 L1 输入自动分块抽取);运行时可在设置页 → 蒸馏参数 → 输入预算调整(留空/0 = 跟随本值) |
149
258
  | `llm.timeoutMs` | `120000` | 单次蒸馏调用超时(ms) |
150
259
  | `tools` | `true` | 是否注册模型可调用的记忆工具 |
151
260
 
152
- ## 存储布局
153
-
154
- <p align="center">
155
- <img src="./assets/readme/storage.svg" width="100%"
156
- alt="存储布局:双写架构(JSONL 事实源只增不改 + memory.db 主检索库);文件形态含 conversations/records/scenes/persona/state/pending/session-modes/embedding-source/模型目录/推理运行时/日志与重建归档;检索三策略 keyword/embedding/hybrid(RRF k=60);降级链保证永不阻塞宿主">
157
- </p>
158
-
159
- 向量能力默认关闭(纯 FTS)。DSH 的 `ctx.llm` 无 embeddings 端点,语义检索由
160
- **三态嵌入源**提供(关闭 / 远程 / 本地),设置页可运行时切换——见下节。
161
-
162
- ## 语义检索(嵌入源)
163
-
164
- 设置页(记忆 → 概览 → 语义检索)选择嵌入源,即时生效、无需改配置重启:
165
-
166
- | 嵌入源 | 说明 |
167
- | --- | --- |
168
- | **关闭**(默认) | 不做任何向量嵌入,纯 BM25 关键词检索 |
169
- | **远程** | 自备任意 OpenAI 兼容 `/embeddings` 服务(`embedding.*` 四件套配齐才可选) |
170
- | **本地** | 内置模型目录选一款,ONNX 量化 **CPU 推理**——无需 API Key,数据不出本机 |
171
-
172
- 本地模型目录是插件内置白名单(每款锁定 revision + 每文件 sha256,不可下载任意仓库):
173
-
174
- | 模型 | 维度 | 上下文 | 体积 | 特点 |
175
- | --- | --- | --- | --- | --- |
176
- | BGE small 中文 | 512 | 512 | ~25MB | CPU 嵌入最快,适合先体验语义检索 |
177
- | EmbeddingGemma 300M | 768 | 2048 | ~330MB | 100+ 语言含中文,质量与开销均衡(上游 MemoryCore 同款) |
178
- | BGE-M3 | 1024 | 8192 | ~590MB | 中文质量最强,单条嵌入可达秒级 |
179
-
180
- - **下载**:模型卡一键下载(默认镜像 `hf-mirror.com`,断点续传 + sha256 完整性
181
- 校验),落盘数据目录 `models/<id>/`,不用了随时在设置页删除;
182
- - **按需运行时**:首次切换本地档才安装推理运行时(transformers.js,约 100~200MB,
183
- 装进数据目录 `runtime/`——不进插件依赖树,不碰插件安装目录);
184
- - **活切换**:一键换源——自动后台全量重嵌(进度可见、可取消,期间检索自动降级
185
- 关键词,不影响对话;维度变化时向量表按新维度重建);切换失败保持旧源,重启仍
186
- 按原源运行;
187
- - **生效规则 = 部署上限 AND 运行时选择**:`embedding.allowLocalModels=false` 可整体
188
- 禁用本地档、未配 `embedding.*` 四件套则远程档不可选(企业部署可收口),状态持久
189
- 化在 `embedding-source.json`。
190
-
191
- ## 日志与排查
192
-
193
- dsh 宿主把插件日志打到控制台,插件将 info 及以上镜像到数据目录 `memory.log`。一轮
194
- 对话的典型日志路径:`L0 捕获` → `L0 落盘` → `蒸馏管线开始` → `LLM 调用(输入/输出
195
- 字符数、耗时)` → `L1 抽取完成` → `蒸馏管线结束`;下一轮有 `召回命中 N 条 L1`。
196
- LLM 空输出带完整诊断(finish 原因 / token 计数 / reasoning 摘录),JSON 解析失败
197
- 附模型原始输出前 400 字符,失败 warn 均带堆栈首帧。
198
-
199
261
  ## 与 MemoryCore 的差异
200
262
 
201
263
  - 内嵌完整管线(不依赖外部 Gateway),蒸馏复用 DSH 自己的 LLM;
202
264
  - L2/L3 由"LLM 操作文件工具"改为"LLM 输出操作 JSON / 完整文档,工程侧执行";
203
- - 召回注入点在 `agent/pre-step` + agent 作用域 `systemPrompt.context`(DSH 原生事件/服务);
265
+ - 召回注入点在 `agent/pre-step`(消息侧合成消息,官方 pre-step 替换语义)+ agent 作用域 `systemPrompt.context`(画像/导航稳定区,DSH 原生事件/服务);
204
266
  - 存储/检索即官方 sqlite 后端的单机裁剪版(裁掉多租户隔离列、TCVDB 云后端、审计表;
205
- 分词用自带 CJK 二元组替代 jieba,保持零原生依赖——仅 sqlite-vec 一个原生扩展,
206
- 加载失败自动降级)。
267
+ 分词与官方一致用 jieba——@node-rs/jieba 预编译二进制 + CJK 二元组并集,
268
+ 词元供 BM25 精确整词命中、二元组保子词召回;加载失败自动回退纯二元组,
269
+ FTS 索引按分词器版本戳自动重建)。
270
+
271
+ ## 路线图
272
+
273
+ 以下为规划中的功能,欢迎在 [Issues](https://github.com/JunNanLYS/dsh-layered-memory/issues) 反馈需求与优先级:
274
+
275
+ - [ ] **Git 分支感知**:记忆与当前 git 分支关联,召回可按分支过滤/加权(与现有记忆档位正交)
276
+ - [ ] **Claude Code / Codex 记忆导入**:一键迁移既有记忆资产(`CLAUDE.md`、Claude Code 记忆文件、Codex `AGENTS.md` 等),导入后进入分层蒸馏管线
207
277
 
208
278
  ## 致谢
209
279
 
Binary file
Binary file
Binary file
@@ -0,0 +1,87 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg"
2
+ width="1200" height="690" viewBox="0 0 1200 690"
3
+ role="img" aria-labelledby="benchDialogTitle benchDialogDesc">
4
+ <title id="benchDialogTitle">DSH-MemBench 对话赛道:A/B 两组准确率对照</title>
5
+ <desc id="benchDialogDesc">同题同输入对照:A 组(记忆开)总准确率 92.6%(250/270),B 组(记忆关)17.8%(48/270)。分题型(每题型 45 题):抽取 A 45/45 对 B 3/45;多跳 A 45/45 对 B 0/45;时序 A 43/45 对 B 0/45;知识更新 A 31/45 对 B 0/45;场景回忆 A 41/45 对 B 0/45;拒答两组均 45/45、0 编造。</desc>
6
+
7
+ <rect width="1200" height="690" rx="26" fill="#0D1526"/>
8
+
9
+ <g font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">
10
+
11
+ <!-- ── 标题与图例 ── -->
12
+ <text x="64" y="66" font-size="26" font-weight="700" fill="#EFF3FA">对话赛道:同题同输入 · A/B 对照准确率</text>
13
+ <text x="64" y="94" font-size="18" fill="#8296B3">15 场景 × 6 题型 × 3 次 = 270 题/组(每题型 45 题)· 条长 = 答对率,数值 = 答对题数</text>
14
+
15
+ <rect x="842" y="50" width="18" height="18" rx="5" fill="#FFD15D"/>
16
+ <text x="868" y="65" font-size="18" fill="#C2CDDE">A 组 · 记忆开</text>
17
+ <rect x="842" y="76" width="18" height="18" rx="5" fill="#4E6DA8"/>
18
+ <text x="868" y="91" font-size="18" fill="#C2CDDE">B 组 · 记忆关</text>
19
+
20
+ <!-- ── 网格线(0/25/50/75/100%)── -->
21
+ <g stroke="#1C2A47" stroke-width="1">
22
+ <line x1="260" y1="122" x2="260" y2="614"/>
23
+ <line x1="435" y1="122" x2="435" y2="614"/>
24
+ <line x1="610" y1="122" x2="610" y2="614"/>
25
+ <line x1="785" y1="122" x2="785" y2="614"/>
26
+ <line x1="960" y1="122" x2="960" y2="614"/>
27
+ </g>
28
+ <g font-size="17" fill="#8296B3" text-anchor="middle">
29
+ <text x="260" y="640">0%</text>
30
+ <text x="435" y="640">25%</text>
31
+ <text x="610" y="640">50%</text>
32
+ <text x="785" y="640">75%</text>
33
+ <text x="960" y="640">100%</text>
34
+ </g>
35
+
36
+ <!-- ── 总准确率(强调行)── -->
37
+ <text x="240" y="176" font-size="21" font-weight="700" fill="#EFF3FA" text-anchor="end">总准确率</text>
38
+ <rect x="260" y="148" width="648" height="26" rx="6" fill="#FFD15D"/>
39
+ <text x="922" y="169" font-size="22" font-weight="700" fill="#FFD15D">92.6%(250/270)</text>
40
+ <rect x="260" y="182" width="124" height="26" rx="6" fill="#4E6DA8"/>
41
+ <text x="396" y="203" font-size="22" font-weight="700" fill="#8FA6C6">17.8%(48/270)</text>
42
+
43
+ <line x1="64" y1="226" x2="1136" y2="226" stroke="#263A5C" stroke-width="1.5"/>
44
+
45
+ <!-- ── 分题型行 ── -->
46
+ <!-- 抽取 -->
47
+ <text x="240" y="286" font-size="19" fill="#C2CDDE" text-anchor="end">抽取</text>
48
+ <rect x="260" y="254" width="700" height="18" rx="5" fill="#FFD15D"/>
49
+ <text x="974" y="269" font-size="18" font-weight="700" fill="#FFD15D" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">45/45</text>
50
+ <rect x="260" y="278" width="47" height="18" rx="5" fill="#4E6DA8"/>
51
+ <text x="319" y="293" font-size="18" font-weight="700" fill="#8FA6C6" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">3/45</text>
52
+
53
+ <!-- 多跳 -->
54
+ <text x="240" y="348" font-size="19" fill="#C2CDDE" text-anchor="end">多跳</text>
55
+ <rect x="260" y="316" width="700" height="18" rx="5" fill="#FFD15D"/>
56
+ <text x="974" y="331" font-size="18" font-weight="700" fill="#FFD15D" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">45/45</text>
57
+ <text x="272" y="355" font-size="18" font-weight="700" fill="#8FA6C6" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">0/45</text>
58
+
59
+ <!-- 时序 -->
60
+ <text x="240" y="410" font-size="19" fill="#C2CDDE" text-anchor="end">时序</text>
61
+ <rect x="260" y="378" width="669" height="18" rx="5" fill="#FFD15D"/>
62
+ <text x="943" y="393" font-size="18" font-weight="700" fill="#FFD15D" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">43/45</text>
63
+ <text x="272" y="417" font-size="18" font-weight="700" fill="#8FA6C6" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">0/45</text>
64
+
65
+ <!-- 知识更新 -->
66
+ <text x="240" y="472" font-size="19" fill="#C2CDDE" text-anchor="end">知识更新 *</text>
67
+ <rect x="260" y="440" width="482" height="18" rx="5" fill="#FFD15D"/>
68
+ <text x="756" y="455" font-size="18" font-weight="700" fill="#FFD15D" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">31/45</text>
69
+ <text x="272" y="479" font-size="18" font-weight="700" fill="#8FA6C6" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">0/45</text>
70
+
71
+ <!-- 场景回忆 -->
72
+ <text x="240" y="534" font-size="19" fill="#C2CDDE" text-anchor="end">场景回忆</text>
73
+ <rect x="260" y="502" width="638" height="18" rx="5" fill="#FFD15D"/>
74
+ <text x="912" y="517" font-size="18" font-weight="700" fill="#FFD15D" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">41/45</text>
75
+ <text x="272" y="541" font-size="18" font-weight="700" fill="#8FA6C6" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">0/45</text>
76
+
77
+ <!-- 拒答 -->
78
+ <text x="240" y="596" font-size="19" fill="#C2CDDE" text-anchor="end">拒答 *</text>
79
+ <rect x="260" y="564" width="700" height="18" rx="5" fill="#FFD15D"/>
80
+ <text x="974" y="579" font-size="18" font-weight="700" fill="#FFD15D" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">45/45</text>
81
+ <rect x="260" y="588" width="700" height="18" rx="5" fill="#4E6DA8"/>
82
+ <text x="974" y="603" font-size="18" font-weight="700" fill="#8FA6C6" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">45/45</text>
83
+
84
+ <!-- ── 脚注 ── -->
85
+ <text x="64" y="672" font-size="16" fill="#8296B3">* 知识更新:改口后仍答旧值记 0 分(直接考核 L1 去重更新);拒答:没发生过的事编造即 0 分(两组均 0 编造)。</text>
86
+ </g>
87
+ </svg>
@@ -0,0 +1,79 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg"
2
+ width="1200" height="660" viewBox="0 0 1200 660"
3
+ role="img" aria-labelledby="benchWorkflowTitle benchWorkflowDesc">
4
+ <title id="benchWorkflowTitle">DSH-MemBench 工作流赛道:A/B 两组完成度与成本对照</title>
5
+ <desc id="benchWorkflowDesc">真实工具沙箱(4 场景 × 3 次)探针会话合计:任务完成度 A 组 24/33(72.7%)对 B 组 11/33(33.3%);成本对比以 B 组为满格基准,A 组相对更省——步骤 125 对 186(B +49%)、工具调用 184 对 296(B +61%)、输入 token 1.30M 对 1.86M(B +43%);向用户求助 A 0 次对 B 3 次;登录场景输入 token A 241k 对 B 453k(+88%)。</desc>
6
+
7
+ <rect width="1200" height="660" rx="26" fill="#0D1526"/>
8
+
9
+ <g font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">
10
+
11
+ <!-- ── 标题与图例 ── -->
12
+ <text x="64" y="66" font-size="26" font-weight="700" fill="#EFF3FA">工作流赛道:真实工具沙箱 · 做得对,也更省</text>
13
+ <text x="64" y="94" font-size="18" fill="#8296B3">4 场景 × 3 次 · 探针会话合计 · 成本行以 B 组为满格基准,蓝徽章 = B 组多付</text>
14
+
15
+ <rect x="842" y="50" width="18" height="18" rx="5" fill="#FFD15D"/>
16
+ <text x="868" y="65" font-size="18" fill="#C2CDDE">A 组 · 记忆开</text>
17
+ <rect x="842" y="76" width="18" height="18" rx="5" fill="#4E6DA8"/>
18
+ <text x="868" y="91" font-size="18" fill="#C2CDDE">B 组 · 记忆关</text>
19
+
20
+ <!-- ── 任务完成度 ── -->
21
+ <text x="64" y="152" font-size="20" font-weight="700" fill="#EFF3FA">任务完成度</text>
22
+ <text x="186" y="152" font-size="17" fill="#8296B3">(产物程序化校验)</text>
23
+
24
+ <rect x="260" y="170" width="509" height="26" rx="6" fill="#FFD15D"/>
25
+ <text x="783" y="191" font-size="22" font-weight="700" fill="#FFD15D">24/33 · 72.7%</text>
26
+ <rect x="260" y="206" width="233" height="26" rx="6" fill="#4E6DA8"/>
27
+ <text x="505" y="227" font-size="22" font-weight="700" fill="#8FA6C6">11/33 · 33.3%</text>
28
+
29
+ <line x1="64" y1="258" x2="1136" y2="258" stroke="#263A5C" stroke-width="1.5"/>
30
+
31
+ <!-- ── 成本对比(B = 满格基准)── -->
32
+ <text x="64" y="290" font-size="20" font-weight="700" fill="#EFF3FA">成本对比</text>
33
+ <text x="166" y="290" font-size="17" fill="#8296B3">(B 组 = 满格基准,条越短越省)</text>
34
+
35
+ <!-- 步骤 -->
36
+ <text x="240" y="348" font-size="19" fill="#C2CDDE" text-anchor="end">步骤</text>
37
+ <rect x="260" y="318" width="376" height="18" rx="5" fill="#FFD15D"/>
38
+ <text x="648" y="333" font-size="18" font-weight="700" fill="#FFD15D" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">125</text>
39
+ <rect x="260" y="342" width="560" height="18" rx="5" fill="#4E6DA8"/>
40
+ <text x="834" y="357" font-size="18" font-weight="700" fill="#8FA6C6" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">186</text>
41
+ <rect x="980" y="321" width="136" height="36" rx="10" fill="#315DA6"/>
42
+ <text x="1048" y="345" font-size="19" font-weight="700" fill="#FFD15D" text-anchor="middle">B +49%</text>
43
+
44
+ <!-- 工具调用 -->
45
+ <text x="240" y="430" font-size="19" fill="#C2CDDE" text-anchor="end">工具调用</text>
46
+ <rect x="260" y="400" width="348" height="18" rx="5" fill="#FFD15D"/>
47
+ <text x="620" y="415" font-size="18" font-weight="700" fill="#FFD15D" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">184</text>
48
+ <rect x="260" y="424" width="560" height="18" rx="5" fill="#4E6DA8"/>
49
+ <text x="834" y="439" font-size="18" font-weight="700" fill="#8FA6C6" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">296</text>
50
+ <rect x="980" y="403" width="136" height="36" rx="10" fill="#315DA6"/>
51
+ <text x="1048" y="427" font-size="19" font-weight="700" fill="#FFD15D" text-anchor="middle">B +61%</text>
52
+
53
+ <!-- 输入 token -->
54
+ <text x="240" y="512" font-size="19" fill="#C2CDDE" text-anchor="end">输入 token</text>
55
+ <rect x="260" y="482" width="391" height="18" rx="5" fill="#FFD15D"/>
56
+ <text x="663" y="497" font-size="18" font-weight="700" fill="#FFD15D" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">1.30M</text>
57
+ <rect x="260" y="506" width="560" height="18" rx="5" fill="#4E6DA8"/>
58
+ <text x="834" y="521" font-size="18" font-weight="700" fill="#8FA6C6" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">1.86M</text>
59
+ <rect x="980" y="485" width="136" height="36" rx="10" fill="#315DA6"/>
60
+ <text x="1048" y="509" font-size="19" font-weight="700" fill="#FFD15D" text-anchor="middle">B +43%</text>
61
+
62
+ <!-- ── 底部特写卡片 ── -->
63
+ <rect x="64" y="544" width="512" height="72" rx="14" fill="#15223A" stroke="#263A5C" stroke-width="1.5"/>
64
+ <text x="88" y="574" font-size="17" fill="#8296B3">向用户求助(探针会话)</text>
65
+ <text x="88" y="600" font-size="20" font-weight="700">
66
+ <tspan fill="#FFD15D">A 0 次</tspan>
67
+ <tspan fill="#8FA6C6"> · B 3 次(每轮要凭据)</tspan>
68
+ </text>
69
+
70
+ <rect x="624" y="544" width="512" height="72" rx="14" fill="#15223A" stroke="#263A5C" stroke-width="1.5"/>
71
+ <text x="648" y="574" font-size="17" fill="#8296B3">登录场景 · 输入 token(凭据只存在记忆里)</text>
72
+ <text x="648" y="600" font-size="20" font-weight="700">
73
+ <tspan fill="#FFD15D">A 241k</tspan>
74
+ <tspan fill="#8FA6C6"> · B 453k</tspan>
75
+ </text>
76
+ <rect x="1040" y="578" width="72" height="26" rx="8" fill="#315DA6"/>
77
+ <text x="1076" y="597" font-size="18" font-weight="700" fill="#FFD15D" text-anchor="middle">+88%</text>
78
+ </g>
79
+ </svg>