dsh-memu-memory 1.2.3 → 1.2.4
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.
- package/AGENTS.md +2 -1
- package/README.md +3 -15
- package/README.zh.md +3 -15
- package/docs/client-conventions.md +1 -0
- package/docs/contributing.md +1 -1
- package/docs/env-and-commands.md +48 -6
- package/docs/troubleshooting.md +41 -0
- package/lib/binding-diagnostics.js +1 -1
- package/lib/client.js +71 -10
- package/lib/embedding-catalog.js +416 -138
- package/lib/embedding-download.js +36 -11
- package/lib/inject.js +99 -3
- package/lib/local-embedding-manager.js +3 -2
- package/lib/local-embedding-protocol.js +40 -3
- package/lib/local-embedding-worker.js +36 -6
- package/lib/local-vector-service.js +18 -4
- package/lib/memu.js +15 -7
- package/lib/private.js +25 -5
- package/lib/rpc.js +4 -1
- package/lib/state.js +81 -0
- package/package.json +3 -2
- package/scripts/drive-session.mjs +19 -8
- package/scripts/simulate-injection.mjs +298 -0
- package/tests/client-render.test.mjs +56 -1
- package/tests/consolidation-fork.test.mjs +14 -1
- package/tests/drive-session.test.mjs +152 -0
- package/tests/embedding-catalog.test.mjs +116 -8
- package/tests/embedding-download.test.mjs +97 -2
- package/tests/embedding-runtime.test.mjs +21 -13
- package/tests/injection-rollback.test.mjs +230 -0
- package/tests/local-embedding-env.test.mjs +51 -0
- package/tests/local-embedding-manager.test.mjs +18 -0
- package/tests/local-embedding-protocol.test.mjs +28 -2
- package/tests/local-embedding-worker.test.mjs +94 -0
- package/tests/simulate-injection.test.mjs +76 -0
- package/tests/vector-profile.test.mjs +28 -4
package/AGENTS.md
CHANGED
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
人格预设会话里完全没有记忆 → T3.19 鉴权 401/403 说不清 → T3.20
|
|
51
51
|
日期到点没唤醒 → T3.21 时效提示没出现 → T3.22
|
|
52
52
|
实体合并 / 怕丢记忆 → T3.23
|
|
53
|
+
失败一轮后锚点/日期没了 → T3.24
|
|
53
54
|
```
|
|
54
55
|
|
|
55
56
|
---
|
|
@@ -63,7 +64,7 @@ node scripts/acceptance-local.mjs # 50/50
|
|
|
63
64
|
npm run check # node --check + i18n + package.json + 文档预算
|
|
64
65
|
```
|
|
65
66
|
|
|
66
|
-
**结果口径**:以 `node --test` 输出的 `ℹ tests / pass / fail / skipped` 为准。用例数变了先问「是不是我加的」,失败先问「是不是并发写了同一个库」——这仓库真会多个会话同时改它。测试数字只作**带日期快照**引用(2026-11-01 实测
|
|
67
|
+
**结果口径**:以 `node --test` 输出的 `ℹ tests / pass / fail / skipped` 为准。用例数变了先问「是不是我加的」,失败先问「是不是并发写了同一个库」——这仓库真会多个会话同时改它。测试数字只作**带日期快照**引用(2026-11-01 实测 1293 tests / 1291 pass / 0 fail / 2 skipped;两条真实引擎用例按设计跳过,历史 1291/1287/1280/1277/1273/1210/505/493/463/409/392 等不再代表当前),不当成当前保证。提交前逐条对 `docs/contributing.md` §10。
|
|
67
68
|
|
|
68
69
|
---
|
|
69
70
|
|
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ It is **local-first by default**. The default `agent` backend stores full text i
|
|
|
30
30
|
> [!WARNING]
|
|
31
31
|
> **Early-stage software.** This plugin is still early and may contain unforeseen errors, bugs or breaking changes. Back up your data, and please [report an issue](https://github.com/Tkingxiao/dsh-memu-memory/issues) or send a pull request — feedback helps the project improve.
|
|
32
32
|
|
|
33
|
-
> **Status:** 1.2.
|
|
33
|
+
> **Status:** 1.2.4. The first public release was 1.0.0. The manual now lives in [`docs/`](docs/), with [`AGENTS.md`](AGENTS.md) as a short index. Back up `~/.dsh/dsh-memu-memory` before upgrades, and read [Compatibility & limits](#compatibility--limits) before storing data you cannot re-create.
|
|
34
34
|
|
|
35
35
|
## Screenshots
|
|
36
36
|
|
|
@@ -360,22 +360,10 @@ With the preview running, use `npm run test:graph-browser -- http://127.0.0.1:77
|
|
|
360
360
|
|
|
361
361
|
The suite includes two optional real-engine integration cases: curator writing requires `DSH_MEMU_TEST_ENGINE_PYTHON`, and the backup venv/WAL case requires `DSH_MEMU_BACKUP_REAL_ENGINE=1`; both are skipped by default. The 50 automated acceptance checks pass. The optional engine was installed and smoke-tested in an isolated directory with the pinned wheel; embedding tests use a local deterministic server, which proves the protocol, not semantic quality.
|
|
362
362
|
|
|
363
|
-
## Changelog
|
|
364
|
-
|
|
365
|
-
**1.2.3 (2026-11-01)**: the six todolist work orders. Emotion now shows on the card (arousal / dominance / source, read-only); dated open loops re-raise every `openLoopRemindDays` instead of going quiet after one mention, and never repeat in a turn that already named them; recalled memory that looks time-sensitive gets one conditional `<memory-freshness>` line nudging the model to verify with a search tool *if* the conversation has one; optional `salientWake` (off by default, experimental) asks the host scheduler to wake the bound conversation on the day; entity merge candidates with two-click confirmation in the graph page (RPC methods 93 → 95). Also a loopback-only injection measurement harness (`scripts/mock-llm.mjs` + `scripts/drive-session.mjs`) so later tuning can be counted instead of argued about. No new dependencies, no build step, no data migration.
|
|
366
|
-
|
|
367
|
-
**1.2.2 (2026-11-01)**: title-card anchor/recall (id + title + semantic tags, body behind recall), automatic lexicon lifecycle and card management, private auto-links/entity hubs, help page v2, and WebUI layout/selector polish; together with the previously unreleased curator three-stage pipeline, global links, absorb/undo, review modes and lexicon store baseline. Prompt contracts are unified (remote curation stays tool-free, title 8–40 characters), the PTC worker mounts 5 write + 3 read tools, and no new dependencies or build steps were added.
|
|
368
|
-
|
|
369
|
-
**1.2.1 (2026-10-31)**: fact-level dedup (write-side gate + recall-side cluster folding); consolidation now works in PTC (run_code) sessions; sidebar consolidation-failure alerts (cross-session, clearable, jump-to-library); the "currently in vector store" count follows real additions and deletions; private/global groups and multi-select bulk ops on the memory wall; one-click view from the global page; graph delete cascades with orphan-entity cleanup; remote consolidation counts only what actually landed.
|
|
370
|
-
|
|
371
|
-
**1.1.3 (2026-10-30)**: managed local vectors are usable end to end (runtime/model download, switch-and-rebuild, progress with per-item failures); activity log with a Logs page; consolidation results move under the sidebar button; archive/restore and list refresh drop from seconds to milliseconds; a date written in the text is picked up when the field is empty; default topK 5/5; fixes the blank settings/WebUI panel (React #310).
|
|
372
|
-
|
|
373
|
-
**1.1.2 (2026-10-29)**: anchor and recall delivery in agent-preset conversations; startup catch-up consolidation; panel TDZ crash fix.
|
|
374
|
-
|
|
375
|
-
Full notes: [`CHANGELOG.md`](CHANGELOG.md).
|
|
376
|
-
|
|
377
363
|
## Documentation
|
|
378
364
|
|
|
365
|
+
- Release notes: [`CHANGELOG.md`](CHANGELOG.md)
|
|
366
|
+
|
|
379
367
|
[`AGENTS.md`](AGENTS.md) is the index for anyone changing this repo — which file answers
|
|
380
368
|
which question. The detail lives in [`docs/`](docs/): failure modes, the change process,
|
|
381
369
|
the host facts, and the UI, memory and environment rules.
|
package/README.zh.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
> [!WARNING]
|
|
31
31
|
> **早期版本提示。** 本插件仍处于早期阶段,可能存在无法预见的错误、bug 或不兼容变更。请先备份数据;欢迎[提交 Issue](https://github.com/Tkingxiao/dsh-memu-memory/issues) 或 PR 帮助改进。
|
|
32
32
|
|
|
33
|
-
> **状态:** 1.2.
|
|
33
|
+
> **状态:** 1.2.4。首个公开发布版本为 1.0.0。细节文档已迁到 [`docs/`](docs/),[`AGENTS.md`](AGENTS.md) 只做索引。升级前请备份 `~/.dsh/dsh-memu-memory`;如果要存无法重建的数据,请先读[兼容性与边界](#兼容性与边界)。
|
|
34
34
|
|
|
35
35
|
## 界面
|
|
36
36
|
|
|
@@ -346,22 +346,10 @@ node --import ./tests/loader-register.mjs scripts/preview.mjs --port 7789
|
|
|
346
346
|
|
|
347
347
|
测试包含两条可选真实引擎集成用例:curator 写入需设置 `DSH_MEMU_TEST_ENGINE_PYTHON`,备份 venv/WAL 需设置 `DSH_MEMU_BACKUP_REAL_ENGINE=1`,默认按设计跳过;50 条自动验收全部通过。可选引擎已在隔离目录安装并跑通锁定 wheel 的 smoke;embedding 测试使用本机确定性服务,只证明协议可用,不证明语义质量。
|
|
348
348
|
|
|
349
|
-
## 更新日志
|
|
350
|
-
|
|
351
|
-
**1.2.3(2026-11-01)**:`todolist` 六条设想的施工版本。情绪四轴上卡片(激活/掌控/来源,只读);带日期的未了之事过期后按 `openLoopRemindDays` 复提,且同回合不会和纪念日重复念;召回里带时间敏感信号的条目会在块尾收到一条条件式时效提示(引导模型在有搜索工具时先核实);可选的 `salientWake` 用宿主定时任务在日子当天唤醒会话(默认关闭、实验特性);节点图新增实体合并候选与两次点击确认(RPC 方法 93 → 95)。另有一套只监听本机的注入实测台(`scripts/mock-llm.mjs` + `scripts/drive-session.mjs`),让后续调参能被计数而不是靠争论。无新增依赖、无构建步骤、无数据迁移。
|
|
352
|
-
|
|
353
|
-
**1.2.2(2026-11-01)**:锚点/召回改为标题卡(正文留在 recall 工具与抽屉);词典自动入库与卡片管理;私有自动关联/实体枢纽;帮助页 v2;WebUI 布局与选择器优化;并合并此前未单独发布的 curator 三段式、全局关联、absorb 撤销、审核模式与词典库基线。远程整理提示词保持无工具、标题统一 8–40 字;PTC worker 挂载 5 写 + 3 读工具;无新增依赖或构建步骤。
|
|
354
|
-
|
|
355
|
-
**1.2.1(2026-10-31)**:事实级去重(写入近似门 + 召回按簇折叠);PTC(run_code)会话整理可用;侧边栏整理失败提醒(跨会话、可清除、可跳转);「当前已入向量库」计数跟随真实增减;记忆墙私有/全局分组与多选批量操作;全局记忆一键查看;关系图删除级联与孤儿回收;整理写入计数说真话。
|
|
356
|
-
|
|
357
|
-
**1.1.3(2026-10-30)**:受管本地向量可用(运行时/模型下载、切换重建、进度与失败明细);活动日志与「日志」页;整理结果落到侧边栏按钮下方;归档/还原与列表刷新提速到毫秒级;日期漏填时从正文兜底;默认 topK 5/5;修复设置/WebUI 白屏。
|
|
358
|
-
|
|
359
|
-
**1.1.2(2026-10-29)**:人格预设会话的锚点与召回送达;启动补扫空闲整理;面板 TDZ 崩溃修复。
|
|
360
|
-
|
|
361
|
-
完整记录见 [`CHANGELOG.md`](CHANGELOG.md)。
|
|
362
|
-
|
|
363
349
|
## 文档
|
|
364
350
|
|
|
351
|
+
- 版本记录:[`CHANGELOG.md`](CHANGELOG.md)
|
|
352
|
+
|
|
365
353
|
[`AGENTS.md`](AGENTS.md) 是给改这个仓库的人的索引:哪个问题去哪份文件。
|
|
366
354
|
细节在 [`docs/`](docs/):排错、改动流程、宿主事实,以及 UI、记忆语义与环境规则。
|
|
367
355
|
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
- `<button>` 里**不许**再嵌 `role="button"`(键盘够不到)。
|
|
25
25
|
- 破坏性操作 = **二次点击**(文案变「确认…?」,2.5s 复原),不用 `globalThis.confirm`、不用 modal。
|
|
26
26
|
- **算法给的候选(实体合并、关联建议)只显示、永不自动执行**:列表来自只读 RPC,逐条二次点击确认才写;操作后用一行回执说清影响面(`S.muted` + `V.accent`,自清),数字取 RPC 返回值,**不估算**。参考节点图页的合并候选(`docs/memory-semantics.md` §8.14)。
|
|
27
|
+
- **失败只在 WebUI「全部日志」标红**:活动日志三档 = 失败(`ok===false` 或 `level==='error'`)/ 降级(`level==='warn'` 且没失败)/ 常规,判据集中在 `logRowState`;总日志页用作用域 CSS `.dshm-logrow.is-failed` / `.is-degraded`,并且**同时给文字 Tag**(`logStateFailed`/`logDegraded` + hover 说明)——颜色不能是唯一通道。**侧栏「整理记录」不放失败行**(它只显示正常流水;失败由上方跨会话的「整理提醒」负责,别在两处重复标红),所以侧栏既不过 `logRowClass` 也不上色。判据别写成只看 `level==='error'`:整理超时记的是 `warn + ok=false`,那样失败会长得和正常行一样(真出过)。
|
|
27
28
|
- 设置项 = 即时保存 + 250ms trailing debounce,一次重试 + `console.warn`,`pagehide` 时 flush。反馈用 toast(2.6s),不用常驻 error/notice 字符串。
|
|
28
29
|
|
|
29
30
|
### 7.4 数据与刷新
|
package/docs/contributing.md
CHANGED
|
@@ -20,7 +20,7 @@ node scripts/acceptance-local.mjs # 50/50;视觉证据只证明本次已审
|
|
|
20
20
|
npm run check # node --check + i18n 键对齐 + package.json 可解析
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
**结果口径**:以 `node --test` 输出的 `ℹ tests / pass / fail / skipped` 为准。用例数变了先问「是不是我加的」,失败先问「是不是并发写了同一个库」——这仓库真会多个会话同时改它。文档里出现的测试数字一律当作**带日期的快照**:2026-11-01 实测
|
|
23
|
+
**结果口径**:以 `node --test` 输出的 `ℹ tests / pass / fail / skipped` 为准。用例数变了先问「是不是我加的」,失败先问「是不是并发写了同一个库」——这仓库真会多个会话同时改它。文档里出现的测试数字一律当作**带日期的快照**:2026-11-01 实测 1293 tests / 1291 pass / 0 fail / 2 skipped(curator 真实引擎与备份 venv/WAL 两条为 opt-in,按设计跳过);更早的 1287 / 1280 / 1277 / 1273 / 1210 / 505 / 392 / 321 / 327 / 333 等是历史快照或转述,不能当作当前保证。**计时与日期敏感的断言要按「整包并行 + 一天中的任何时刻」写**:`tests/sidebar.test.mjs` 的大库首屏用 1500ms(空载 378–448ms,整包并行曾到 1808ms,500ms 测的是机器的空闲程度),`tests/client-render.test.mjs` 的短条目过期时刻用相对时间(曾 pin 在当天 09:30Z,下午必红)。
|
|
24
24
|
|
|
25
25
|
### 4.3 每类改动的连带清单
|
|
26
26
|
|
package/docs/env-and-commands.md
CHANGED
|
@@ -60,7 +60,7 @@ python -m memu commit payload.json --json --db <db>
|
|
|
60
60
|
|
|
61
61
|
`commit` payload:`{ recall_files: [{ name, track: memory, description, content }], resource: [], user: {} }`。
|
|
62
62
|
|
|
63
|
-
### 9.5
|
|
63
|
+
### 9.5 本地向量模型与运行时(受管,2026-10-30 / 2026-11-02)
|
|
64
64
|
|
|
65
65
|
**不再需要手工环境变量**:运行时(`onnxruntime-node` 1.31.1 + `onnxruntime-common` + `@huggingface/tokenizers`)由插件按 catalog pin 装进 `<dataDir>/downloads/embeddings/runtime/`,规格见 §14.13。`DSH_MEMU_EMBED_RUNTIME_DIR` 只剩「显式覆盖」用途:指向的目录里没有那三个包时会被忽略(`warn`)并回落到受管目录;也不需要 Ollama。
|
|
66
66
|
|
|
@@ -73,11 +73,49 @@ node scripts/local-runtime-install.mjs --target <dir> --platform win32-x64 --id
|
|
|
73
73
|
|
|
74
74
|
状态 `installed / absent / unsupported / downloading / verifying / installing / failed / cancelled`;`unsupported` = catalog 没 pin 该平台原生库(如 `darwin-x64`)。装失败只 `warn` + 回词法召回,不会自动改用云端 embedding。
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
#### 9.5.1 五条已核实模型(2026-11-02)
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
每条都 pin 在来源仓库的 HEAD commit,逐文件 `bytes/sha256` 与文件清单双向核对一致,再用受管 ORT 树真跑推理(单位范数、重复编码余弦 1.0)。BGE / MiniLM / e5 走 ModelScope 直连(2026-10-30 的核实口径);两张 Qwen3 卡片的导出仓库在 ModelScope 上不存在(只读核对 `record not found`),所以走 hf-mirror,`huggingface.co` 源站作为可选项。
|
|
79
|
+
|
|
80
|
+
| catalog id | 制品 | 维度 / 窗口 | pooling | 前缀 | 加载 | 一次编码 29 / 380 / 1520 字 | 实测(42 条 recall-bench 草稿,33 条可答) |
|
|
81
|
+
|---|---:|---|---|---|---:|---|---|
|
|
82
|
+
| `bge-small-zh-v1.5-int8` | 24.6 MB | 512 / 512 | cls + L2 | 无 | 254 ms | 5 / 17 / 22 ms | R@1 0.6667 · R@3 0.9697 · MRR 0.8106 |
|
|
83
|
+
| `all-minilm-l6-v2-int8` | 23.9 MB | 384 / 512 | mean + L2 | 无 | 122 ms | 5 / 17 / 30 ms | R@1 0.5455 · R@3 1.0000 · MRR 0.7525 |
|
|
84
|
+
| `multilingual-e5-small` | 135.4 MB | 384 / 512 | mean + L2 | `query: ` / `passage: ` | 787 ms | 6 / 19 / 47 ms | R@1 0.6667 · R@3 1.0000 · MRR 0.8182 |
|
|
85
|
+
| `qwen3-embedding-0.6b-int8` | 600.2 MB | 1024 / 4096 | last + L2 | 官方 `Instruct: …\nQuery:` / 无 | 2.06 s | 91 / 437 / 4286 ms | 带前缀 R@1 0.6970 · R@3 0.9697 · MRR 0.8359;裸文本 0.6667 · 0.9394 · 0.8081 |
|
|
86
|
+
| `qwen3-embedding-0.6b-q4f16` | 541.8 MB | 1024 / 4096 | last + L2 | 同上 | 11.4 s | 110 / 870 / 5863 ms | 带前缀 R@1 0.7273 · R@3 0.9697 · MRR 0.8510;裸文本 0.6667 · 0.9394 · 0.8081 |
|
|
87
|
+
|
|
88
|
+
延迟那一列是**同一批文本、同一个受管 ORT 树**上重测的(29 / 380 / 1520 字三段中文),所以五行之间可以直接比:Qwen3 int8 一次编码是另外三款的 18–195 倍,q4f16 还要再慢一截、加载慢 5.5 倍。
|
|
89
|
+
|
|
90
|
+
**这些数字是同一份合成草稿上的横向对照,不是质量结论**(草稿带刻意保留的词面线索,`docs/recall-benchmark.md` 自己声明它不是金标;33 条可答样本上 0.03 的差就是 1 条)。表里读得出的只有相对关系:e5 与 BGE 同级、MiniLM 在中文上明显弱;Qwen3 两个变体在草稿上略高,但一次编码慢 18–195 倍。英文 paraphrase 余弦 MiniLM 0.62/0.70、BGE 0.65/0.64、e5 0.91/0.93。q4f16 在这份草稿上没有比 int8 差(0.7273 对 0.6970)——差一个样本,不足以给两个变体排质量,能当依据的只有实测到的「加载慢 5.5 倍 + 依赖 com.microsoft 贡献算子」。
|
|
91
|
+
|
|
92
|
+
**角色通道**(e5 与两张 Qwen3 卡片都需要;为什么必须存在、为什么不是猜):MemU 的 embeddings 信封只有 `{model, input, encoding_format}`,没有 role 字段。非对称前缀意味着同一句话有两种读法,所以角色由**启动子进程的一方**写在 model 字符串上——`retrieve` 用 `<id>@<rev>+<proto>:query`,`commit` / `list-files` 用 `:passage`;worker 解析后缀并按 profile 的 `prefixes` 施加前缀,**裸 model id 对这种 profile 直接 400 `LOCAL_VECTOR_ROLE_REQUIRED`**,绝不"默认成文档"。两边同前缀的模型(BGE/MiniLM)保持原样,裸 id 照旧可用。派生规则是 `prefixesRequireRole(entry)` = `prefixes.query !== prefixes.document`,前缀本身在指纹里,所以「要不要角色通道」和「这个向量空间长什么样」永远来自同一份事实(§14.8)。前缀不是装饰:实测同一句话加/不加前缀的余弦,e5 是 0.9811,Qwen3 int8 只有 **0.8284**(q4f16 0.8203)——Qwen3 的 Instruct 前缀真的把向量挪开了,草稿上的读数也对应得上(带前缀比裸前缀 R@1 高 0.03、MRR 高 0.028)。真机验证:五路互切 `MiniLM(g1) → Qwen3-int8(g2) → Qwen3-q4f16(g3) → e5(g4) → BGE(g5)` 各 6/6 条重建、0 失败,每次切换后中英查询都能召回,回滚回到上一空间。
|
|
93
|
+
|
|
94
|
+
**下载来源(provider)**:不传就取目录顺序里第一个已固定的来源,所以 Qwen3 卡片的默认是 **hf-mirror**;`huggingface.co` 源站是同 commit 的同一批文件,可选。选源只走那一个、失败也不回退到别的源(`download(id, { provider })` → RPC `downloadLocalVectorModel` 的 `provider` → 设置页在「有多于一个已固定来源」的卡片上给一行 `is-row` 选择,只有一个来源就不出现「选」这件事)。换源不改向量空间:provider 不进指纹,每个文件落盘前都要过目录里 pin 的同一个 `sha256`。两个真实踩到的坑记在这里:① hf-mirror 对小文件用 chunked 传输、**不发 `content-length`**,头缺失必须当「未知」而不是 0,否则每个小文件都被误判成大小不符(第一次真装 Qwen3 就是被这条挡住的);② 见证制品(基座仓库的 `1_Pooling/config.json`)默认绑死它被核实的那个 provider,多镜像来源要用 `origin.providers` 显式声明,否则换源会把整条封掉。
|
|
95
|
+
|
|
96
|
+
**两张 Qwen3 卡片是两个向量空间**:int8 是 `quantize_dynamic`(QInt8),图侧核实 196/196 个 `MatMulInteger` 的 scale/zero_point 都是 rank-0 标量、per-channel scale 向量为 0 → **per-tensor**,和另外三款 per-channel 不是同一个空间;q4f16 是 `com.microsoft.MatMulNBits`(int4、block_size=128)+ float16 激活,图输出 dtype 也是 float16。`quantization` 进指纹,所以分条目、分 DB,不能混用。两者都是 opset 21 的因果 LM:只有 `input_ids` + `attention_mask`(没有 `token_type_ids`),池化取**最后一个非 pad token**(`pooling=last`,官方 `1_Pooling` 声明 `pooling_mode_lasttoken=true`),且图**导出时固定 batch=1**——一次只能喂一行,worker 的 adapter 本来就逐行编码。分窗取 4096 而不是制品支持的 32768:1520 字实测已 4.29 s,按 32k 跑一条长记忆会直接顶到 worker 的 120 s 请求超时;窗口是指纹字段,所以这是写明的策略而不是疏漏。
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
node scripts/local-vector-verify.mjs # 只读:五条目录条目的 manifest/来源/已装 deep 校验
|
|
100
|
+
node scripts/local-vector-verify.mjs --download --id all-minilm-l6-v2-int8 # 显式联网装该模型(默认落 .tmp-* 临时根)
|
|
101
|
+
node scripts/local-vector-verify.mjs --download --id qwen3-embedding-0.6b-int8 --target <dataDir>/downloads/embeddings
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`--target` 指到插件数据目录就等于设置页的「下载并校验」;该脚本从不写 active profile,切换仍然只能走设置页的「切换并重建」。
|
|
105
|
+
|
|
106
|
+
### 9.6 注入实测台(工单 B,仅评测用)
|
|
107
|
+
|
|
108
|
+
**目的**:注入「发了什么」不等于「模型收到了什么」。这三件脚本只量最后一环——真正发给模型的请求里出现了哪些记忆块、出现几次。它们**不是运行时依赖**,`lib/` 永不 import,日志只记长度/哈希与标记计数(不记正文)。
|
|
109
|
+
|
|
110
|
+
| 工具 | 量的是 | 覆盖不到 |
|
|
111
|
+
|---|---|---|
|
|
112
|
+
| `scripts/simulate-injection.mjs` | 插件自己决定了什么:真实 `lib/inject.js` + 真实 `registerInjection('agent/pre-step')`,打在临时库与临时 `DSH_MEMU_HOME` 上 | 宿主的消息组装、真实模型的 tool 轮 |
|
|
113
|
+
| `scripts/mock-llm.mjs` | 收到请求时数标记 + `--report` 出「每轮 × 块矩阵」 | 它只是端点,不产生轮次 |
|
|
114
|
+
| `scripts/drive-session.mjs` | 真机上把轮次灌进绑定会话 | 需要宿主用假模型(见下) |
|
|
79
115
|
|
|
80
116
|
```bash
|
|
117
|
+
npm run simulate:injection # 50 轮离线基线,临时目录,cue 概率置 0 便于复现
|
|
118
|
+
node scripts/simulate-injection.mjs --turns 20 --out ./sim-run --json
|
|
81
119
|
node scripts/mock-llm.mjs --port 8123 --log ./mock-llm-<日期>.jsonl # 伪 OpenAI 端点,只监听 127.0.0.1,无鉴权
|
|
82
120
|
node scripts/mock-llm.mjs --reply-file ./tests/fixtures/mock-llm/reply.txt --port 8123 --log ./mock.jsonl
|
|
83
121
|
node scripts/mock-llm.mjs --report ./mock-llm-<日期>.jsonl > mock-llm-report-<日期>.md
|
|
@@ -86,11 +124,15 @@ node scripts/drive-session.mjs --session <id> --turns 50 \
|
|
|
86
124
|
--base http://127.0.0.1:<gateway 端口> --allow-api-route --requests-out ./requests.jsonl
|
|
87
125
|
```
|
|
88
126
|
|
|
89
|
-
-
|
|
90
|
-
-
|
|
127
|
+
- **离线模拟器**(1.2.4)在临时 `DSH_MEMU_HOME` 里播种一份"每种块各有一条"的库(明天/今天/已过期的带日期未了之事、年度纪念日、时效词、四个月前的旧条目、近似重复主题对),跑 N 轮,把每次组装好的请求打给本地伪端点,产出 `report.md` / `mock-llm.jsonl` / `settings-snapshot.json` 与一行 JSON 摘要。退出码 `0` / `2` 用法错 / `3` **注入链路自己报了 warn**(模拟器把 warn 当失败,不当噪声)。它**不是真机证据**:宿主侧的折叠、真实模型的 tool 轮都不在里面;两边对不上时以真机为准。
|
|
128
|
+
- 真机用法:DSH 的 provider profile 把 `baseURL` 指到 `http://127.0.0.1:8123/v1`(provider 配置在 `~/.dsh/profiles/<profile>/cordis.patch.yml` 的 `llm-pi-ai`,`- id/config` 是**整份替换不是合并**,改完要重启该 profile 的宿主),测试会话绑定一个手写播种库,再用 `drive-session.mjs` 灌轮数。
|
|
129
|
+
- 标记表 pin 在 `scripts/mock-llm.mjs` 的 `MARKERS`(`MARKER_SET_VERSION` 记插件版本)。**改 `lib/inject.js` 的块标记必须同处更新并 bump 版本**,否则报告把新块记成 0。回归见 `tests/simulate-injection.test.mjs`:它钉的是量具属性(guide 只在首轮一次、标题卡 `body lines` 必须为 0、日志里不许出现正文),不是某次的注入计数。
|
|
91
130
|
- `drive-session.mjs` 走宿主公开的 `sessionController.prompt`(`POST <base>/api/session/prompt` 的 Connection carrier 形状),并且**默认拒绝发送**:没有 `--allow-api-route` 就打印等价的手工请求并退出码 3。轮结束只认持久 session log 里本轮 `turn/end` 的 `reason.kind === 'completed'`。
|
|
92
131
|
- 退出码:`0` 全部完成 / `1` 某轮或传输失败 / `2` 用法错 / `3` 未授权传输(手工降级)/ `4` 观察不到 session log。
|
|
132
|
+
- **真机 50 轮已跑过(2026-11-01,隔离实例)**:`DSH_HOME` 指到 launcher 的独立 home(`…/in.dsh-plug.dsh-launcher/homes/<version>`),profile 只加一个 `dsh-memu-memory` junction,provider 用 `mock-llm` 起在 8090,`dsh --profile <p> --no-open --port 0` 打印带 token 的 URL → `GET /` 303 换 cookie → `drive-session --cookie-file` 灌 50 轮。读数(51 个请求、2 个会话指纹):`guide / anchor / due / anniversary / openLoop / texture` 各 **1** 次(都只在首轮),`ctx` Δ **27** 跨 **26/50** 轮(注入率 52%),`freshness` Δ **18** 跨 17 轮,`media / lexicon / cue / replay` 为 0(无附件、词典空、cue 概率 0、无压缩);标题卡 `bodyLines` 全 0;12 条播种条目全部浮现过(`uniqueIds` max 12)。
|
|
133
|
+
- **离线对照**(同一份 `registerInjection` 代码,`scripts/simulate-injection.mjs`,50 轮):注入 18/50 轮、`ctx` Δ18、`freshness` Δ11、其余块各 1、`bodyLines` 全 0。两边方向一致(首轮一次、逐回合召回、时效提示按需),绝对值不同——真机的转录更长、每轮都会重投新的召回,所以离线数只能读作"插件的决策",不能当装机读数。
|
|
134
|
+
- 这条链上有两个坑,踩过一次写在这里:① `- id/config` 是**整份替换**,profile 里声明 provider 就得把 `providers` 写全;非推理模型的 `reasoningEfforts` 必须是 `false`,写成 `{off: null}` 会被判 `INVALID_CONFIG`(**回合在发出请求前就中止,所以零花费、零外发**,但看着像"没反应")。② 宿主源码树 `packages/boot/app-boot/lib/` 是过期构建(`src` 支持 patch 路径列表,`lib` 不支持)→ 从源码起会崩;用已安装版本目录里的 `@deepseek-ai/dsh/lib/bin.js`。
|
|
135
|
+
- 这条链还顺手抓出一个行为缺口并修了(1.2.4):**从未到达模型的失败回合会消耗掉首轮的一次性内容**(guide / 锚点 / 当日纪念日 / 复提时钟)。插件现在把该轮消费的东西记在 `injectionRollback` 上,并按"本轮注入消息有没有进转录"决定撤不撤:配置无效(`INVALID_CONFIG`)时撤回、下一轮重新投,上游 500 时消息还在转录里就保住记账不重投。机制与边界 → `docs/troubleshooting.md` §3.24。
|
|
93
136
|
- 数据是**要丢弃的**:报告文件名带日期,别把捕获的对话提交进仓库,也别把伪端点当日常后端。
|
|
94
|
-
- **1.2.3 只交付了这套量具,还没跑过基线**:仓库里没有 `mock-llm-report-*.md`,所以任何「注入次数变化」的说法都还没有数据支撑。C/D 合入后的对照数据是待做项,跑法就是上面四条命令;报告里每个 0 注入的轮都要能解释(去重 / 预算 / 太短 / 无库),解释不了的轮次视为数据不可用。
|
|
95
137
|
|
|
96
138
|
---
|
package/docs/troubleshooting.md
CHANGED
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
聊很久一条记忆都没写 → §3.18
|
|
34
34
|
人格预设会话里完全没有记忆 → §3.19
|
|
35
35
|
鉴权 / 401/403 行为说不清 → §3.20
|
|
36
|
+
本地向量模型装不上 / 切不过去 / 召回 400 → §3.25
|
|
37
|
+
整理超时(fork 预算不够)→ §3.26
|
|
36
38
|
```
|
|
37
39
|
|
|
38
40
|
## 3. 出过的问题:症状 → 落点 → 守卫
|
|
@@ -275,8 +277,44 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
|
|
|
275
277
|
|
|
276
278
|
**守卫**:`tests/entity-merge.test.mjs`(链接全改指、别名并集与 cap、快照重键与冲突取舍、kind 不同/自指/未知 id 拒绝且不写、prune、suggest 真值表与纯读、RPC payload 形状);授权矩阵见 `tests/webui-auth.test.mjs`。
|
|
277
279
|
|
|
280
|
+
### 3.24 某一轮失败之后,整个会话再也不出现锚点/日期/未了之事(S4 注入 → 宿主回合失败)
|
|
281
|
+
|
|
282
|
+
**症状**:逐回合召回 `<memory-context>` 一直正常,但 `===== memory anchor =====`、`<memory-due>`、`<memory-anniversary>`、`[open loop]`、`<memory-guide>` 从某一轮起**整会话消失**,且库里的日期条目明明还在。真机实测台能直接重现:2026-11-01 那次 provider 配置报错,51 个请求里这五类块全为 0,而 `ctx`/`freshness` 照常。
|
|
283
|
+
|
|
284
|
+
**落点**:这些块是**一次性投放**的。`ensureUnifiedGuide` 写 `guideRulesKey`,锚点靠 `ANCHOR_SENTINEL` 进 `injectedIds`,日期/纪念日/未了之事拼在同一条首轮消息里,而记账发生在消息交回决策之后、模型调用之前。宿主随后报 `turn/end`(`reason.kind` 为 `error` 或 `aborted`)——**当时插件不看这个事件**,于是那一次失败吃掉了整个会话的首轮内容。压缩路径(`guideLost` / `reinjectPending`)只管 guide 与锚点的重投,救不了 due/anniversary/open loop。
|
|
285
|
+
|
|
286
|
+
**现在的做法**(1.2.4 起):注入投放时把"这一轮消费掉了一次性内容"记在 binding 上(`injectionRollback`:hostTurn + 那批 ids + guide 的 rulesKey + 纪念日/复提名单),同时在内存里留下**本轮那几条注入消息的 id**。判据来自宿主 `agent-loop` 的 `step()`:它在第一次尝试里就把 `decision.messages` 逐条 `append('user/message')` 进转录,**之后**才去连模型——所以插件只要看见自己那条 id 的 `user/message` 事件,就说明这一轮真的发出去了。`turn/end` 到达时:没见过实证且 `kind` 是 `error`/`aborted` → `rollbackInjectionForTurn` 只撤回**那一轮**的记账,下一轮重新投;见过实证或回合正常收尾 → `consumeInjectionRollback` 删掉记录、记账保住,之后一条迟到的旧事件也撤不动它。监听段排在最前且自带 try,不会被别的监听步骤抛错带走;回滚会写一条 `kind:'system'` 的活动日志与一条 warn,不静默。
|
|
287
|
+
|
|
288
|
+
**边界(重要,别当成万能药)**:这条链只对"请求根本没发出去"那类失败有意义。实测与源码都对得上:provider 配置无效(`INVALID_CONFIG`)在 `prepareRequest` 里抛,那时转录连用户消息都不留——正是需要撤回的情形;而**请求已发出、上游 500 或流式中断**时注入的消息已经在转录里(后续请求会原样重发),撤回只会让下一轮凭空多出第二条规则消息和第二个锚点,所以不撤。实证只在内存里:进程恰好在回合中间重启就查不到证据,此时**宁可漏撤一次也不误投**。逐回合召回本来就不依赖一次性记账,不受影响。
|
|
289
|
+
|
|
290
|
+
**守卫**:`tests/injection-rollback.test.mjs`(6 条)——失败回合后 guide/锚点/召回 id 全部撤回且下一轮重新投出、`completed` 回合不重复投、`completed` 会消费记录所以迟到的旧失败事件撤不动、注入消息已进转录时 500 类失败保住记账、投放前取消同样撤回、当日纪念日与复提时钟一起撤回。真机侧的复现路径见 `docs/env-and-commands.md` §9.6:让 provider 报 `INVALID_CONFIG` 跑一轮,再看转录与 binding 是否一致。
|
|
291
|
+
|
|
292
|
+
### 3.25 本地向量模型装不上 / 切不过去 / 召回 400(S4 受管向量 → 模型目录与角色通道)
|
|
293
|
+
|
|
294
|
+
**症状**:设置页里某个模型点不动;或切到 `multilingual-e5-small` 后召回整段没有,日志里出现 `LOCAL_VECTOR_ROLE_REQUIRED` / `LOCAL_VECTOR_MODEL_MISMATCH`;或换了模型后检索明显变差。
|
|
295
|
+
|
|
296
|
+
**落点**:三条 ModelScope 模型(BGE / MiniLM / e5)与两张 Qwen3 卡片(int8 / q4f16)都只从**固定 commit** 取制品,逐文件 `bytes/sha256` 是硬门槛,所以「下载按钮灰着」先跑 `node scripts/local-vector-verify.mjs` 看报的是 `manifest` 还是 `source`。Qwen3 的导出仓库在 ModelScope 上没有对应条目,默认来源是 hf-mirror、可切 huggingface 源站(同一 commit、同一份 sha256,换源不换向量空间);注意 hf-mirror 对小文件用 chunked 传输、不发 `content-length`,这条已被当作「未知」而不是 0 处理。e5 与 Qwen3 都是**非对称前缀**模型(`query: `/`passage: `、官方 `Instruct: …\nQuery:`),角色由插件写在发给 worker 的 model 字符串后缀上(`retrieve` → `:query`,`commit` / `list-files` → `:passage`);这种 profile 对**裸 model id 直接 400** `LOCAL_VECTOR_ROLE_REQUIRED`,绝不"默认成文档"——默认错一边等于换一个向量空间而 HTTP 还是 200。绕过插件 env 直接手起一个 MemU 进程(自己 export `MEMU_EMBED_MODEL`)就会撞上这条 400,这是设计而不是 bug。
|
|
297
|
+
|
|
298
|
+
**Qwen3 专属**:它是因果 LM,`pooling=last`(取最后一个非 pad token,opset 21),图导出时**固定 batch=1**,所以一次只能喂一行——worker 的 adapter 本来就逐行编码。int8 与 q4f16 是**两个向量空间**(量化方式进指纹),两张卡各自下载、各自重建,切过去不会复用对方的库。q4f16 依赖 `com.microsoft` 贡献算子域且实测**更慢**(加载 11.4 s vs 2.06 s)。延迟口径:短句一次编码 int8 91 ms / q4f16 110 ms,1520 字 4.29 s / 5.86 s,比另外三个模型慢一到两个数量级——「切换后感觉变卡」先看是不是切到了 Qwen3 卡片,分窗也因此只取 4096(制品支持 32k)。
|
|
299
|
+
|
|
300
|
+
**换了模型不等于换得对**:MiniLM 是英文模型,中文锚点召回实测弱于 BGE/e5(同一份合成草稿 R@1 0.5455 对 0.6667),"检索变差"先看设置页当前生效的 `catalogId` 而不是先怀疑注入。口径与实测数字在 `docs/env-and-commands.md` §9.5.1。
|
|
301
|
+
|
|
302
|
+
**守卫**:`tests/embedding-catalog.test.mjs`(三条目指纹钉死、只有非对称前缀需要角色通道)、`tests/local-embedding-protocol.test.mjs` 与 `tests/local-embedding-worker.test.mjs`(角色解析、前缀确实进推理、裸 id 被拒且没进推理)、`tests/local-embedding-env.test.mjs`(对称模型的 `MEMU_EMBED_MODEL` 逐字节不变)。
|
|
303
|
+
|
|
278
304
|
---
|
|
279
305
|
|
|
306
|
+
### 3.26 整理超时(S4 私有整理 → fork 预算)
|
|
307
|
+
|
|
308
|
+
**症状**:整理提醒里出现「整理超时 · fork f-xxxxxx · timeout:consolidation timed out after Ns」,而对话本身一切正常、库里也可能已经多了几条记忆。
|
|
309
|
+
|
|
310
|
+
**落点**:整理是一次**整段会话的 fork**——种子是截止快照的全部事件,worker 先读完整段转录才开始写,所以耗时随会话长度涨。2026-11-02 的真实读数(935 条事件的会话):开始后 **125 s 才写出第一条**,180 s 到点时只写完 3 条 → 超时;退避重试 131 s 完成。也就是说 180 s 的固定预算对大会话必然偏紧,**不是卡死、不是死锁,也不会丢已写入的记忆**。
|
|
311
|
+
|
|
312
|
+
**现在的做法**:预算按范围大小推(`consolidationWaitBudget(eventCount)`,政策 `120 s + 0.35 s/事件`,夹在 `[180 s, 600 s]`;斜率取自上面实测的 0.14–0.2 s/事件并留约 2 倍余量)。显式传 `maxWaitMs` 的调用方(测试、工具)仍然完全由调用方决定。「整理已开始」那条日志现在会写「预算 Ns」,失败行也会写「over N events」,所以下次看到超时能直接判断是不是范围太大。**超时仍然不会推进 `lastSleepSeq`**(没有回执就不算整理过),重试会重读同一段——这是 `§14.8`「先证明覆盖范围再推进」的代价,不能为了省时间改成部分推进。
|
|
313
|
+
|
|
314
|
+
**还能再快的两条路(未做,需拍板)**:① 把 fork 的种子换成脱敏压缩后的转录(远端路径 `condenseEvents` 已有先例,但 fork 的种子来自 `dsh-session.buildForkSeed`,要动得先确认能替换);② 常驻 MemU 进程,替掉「每次工具调用新起 python(导入链 2.05 s)」——这条同时能提速每轮召回与迁移重建。
|
|
315
|
+
|
|
316
|
+
**守卫**:`tests/consolidation-fork.test.mjs` 的 `the consolidation wait budget scales with the transcript`(0/100/200/935/5000/非法值)与既有的 `a fork still running at the deadline reports a timeout instead of silence`(显式 30 ms 仍生效、超时不得推进游标)。
|
|
317
|
+
|
|
280
318
|
|
|
281
319
|
## 守卫索引表
|
|
282
320
|
|
|
@@ -308,6 +346,9 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
|
|
|
308
346
|
| §3.21 | 日期到点没唤醒 | `tests/salient-wake.test.mjs`;活动日志 `kind:'wake'` 的 `detail.stage`(service/timezone/index/list/cleanup/create/pass)就是排查线,`state.json` 里先确认 `salientWake` 真的存下了。 |
|
|
309
347
|
| §3.22 | 时效提示没出现 | `tests/freshness.test.mjs` + `tests/injection-chain.test.mjs`;前置条件(真有召回、开关、预算装得下)少一个就不出,不是 bug。 |
|
|
310
348
|
| §3.23 | 实体合并 / 担心丢记忆 | `tests/entity-merge.test.mjs`(链接改指、别名 cap、快照冲突取舍、拒绝形状);合并只改指向,正文与条数不变。 |
|
|
349
|
+
| §3.24 | 失败一轮后锚点/日期再不出现 | `tests/injection-rollback.test.mjs`(6 条:撤回+重投、completed 不重复、迟到事件撤不动、已进转录的 500 类失败不误撤、投放前取消撤回、纪念日复提时钟一起撤)。 |
|
|
350
|
+
| §3.25 | 本地向量模型装不上 / 切不过去 / 召回 400 | `tests/embedding-catalog.test.mjs`(三条目指纹钉死、只有非对称前缀需要角色通道)、`tests/local-embedding-protocol.test.mjs`、`tests/local-embedding-worker.test.mjs`(前缀进推理、裸 id 拒且不入推理)、`tests/local-embedding-env.test.mjs`(对称模型 model 串逐字节不变)。 |
|
|
351
|
+
| §3.26 | 整理超时(fork 预算) | `tests/consolidation-fork.test.mjs`:预算随事件数缩放(0/100/200/935/5000/非法值),显式 `maxWaitMs` 仍生效,超时不推进 `lastSleepSeq`。 |
|
|
311
352
|
|
|
312
353
|
## 附录 A · 模块地图(原 §2.1)
|
|
313
354
|
|
|
@@ -56,7 +56,7 @@ export const RUNTIME_STATE = Object.freeze([
|
|
|
56
56
|
{ layer: 'temporary-map', file: 'lib/media.js:19', name: 'captures', keyedBy: 'sessionId', clearedBy: 'capture settle' },
|
|
57
57
|
{ layer: 'temporary-map', file: 'lib/private.js:347', name: 'inFlight', keyedBy: 'sessionId', clearedBy: 'consolidation settle' },
|
|
58
58
|
{ layer: 'temporary-map', file: 'lib/curator.js:50', name: 'jobs', keyedBy: 'job id', clearedBy: 'curation settle' },
|
|
59
|
-
{ layer: 'cache', file: 'lib/state.js:
|
|
59
|
+
{ layer: 'cache', file: 'lib/state.js:1142', name: 'indexCache', keyedBy: 'libraryId', clearedBy: 'next load / external write' },
|
|
60
60
|
{ layer: 'cache', file: 'lib/paths.js:52', name: 'readFailures', keyedBy: 'absolute file', clearedBy: 'a later successful read' },
|
|
61
61
|
])
|
|
62
62
|
|
package/lib/client.js
CHANGED
|
@@ -137,6 +137,10 @@ window.__ModuleLoader__.load({
|
|
|
137
137
|
runLogTitle: '整理记录',
|
|
138
138
|
runLogEmpty: '还没有整理记录。',
|
|
139
139
|
runLogOpen: '全部日志',
|
|
140
|
+
logStateFailed: '失败',
|
|
141
|
+
logStateFailedHint: '这一条是失败或超时:原因见正文。整理超时会自动退避重试,超时前已写入的记忆会保留。',
|
|
142
|
+
logDegraded: '降级',
|
|
143
|
+
logDegradedHint: '没有失败,但走了退路(例如向量未激活、自动关联跳过)。',
|
|
140
144
|
dedupedNotice: '未写入:库里已有几乎相同的记忆 [{id}]。要补充内容请在原条目上编辑合并;确属两次独立观测时才需要 allow_duplicate 重写。',
|
|
141
145
|
consolidateFeedTitle: '整理提醒',
|
|
142
146
|
consolidateFailedCol: '失败',
|
|
@@ -418,6 +422,8 @@ window.__ModuleLoader__.load({
|
|
|
418
422
|
managedVectorRuntimeInstall: '下载运行时',
|
|
419
423
|
managedVectorRuntimeTitle: '运行环境',
|
|
420
424
|
managedVectorModelsTitle: '模型',
|
|
425
|
+
managedVectorSource: '下载来源',
|
|
426
|
+
managedVectorSourceHint: '同一个固定 commit 的同一批文件;换来源不改向量空间——每个文件都要过目录里 pin 住的 sha256。',
|
|
421
427
|
managedVectorReady: '已就绪',
|
|
422
428
|
vectorRebuildTitle: '重建进度',
|
|
423
429
|
vectorStagePreparing: '准备中',
|
|
@@ -885,6 +891,10 @@ window.__ModuleLoader__.load({
|
|
|
885
891
|
runLogTitle: 'Runs',
|
|
886
892
|
runLogEmpty: 'No runs recorded yet.',
|
|
887
893
|
runLogOpen: 'All logs',
|
|
894
|
+
logStateFailed: 'Failed',
|
|
895
|
+
logStateFailedHint: 'This row failed or timed out; the reason is in the message. Timed-out consolidation retries itself with backoff, and memories written before the timeout are kept.',
|
|
896
|
+
logDegraded: 'Degraded',
|
|
897
|
+
logDegradedHint: 'Not a failure — a fallback path was taken (e.g. no active vector generation, auto-link skipped).',
|
|
888
898
|
dedupedNotice: 'Not written: the library already holds a near-identical memory [{id}]. Edit and merge into that entry instead; pass allow_duplicate only for two genuinely independent observations.',
|
|
889
899
|
consolidateFeedTitle: 'Consolidation alerts',
|
|
890
900
|
consolidateFailedCol: 'Failed',
|
|
@@ -1165,6 +1175,8 @@ window.__ModuleLoader__.load({
|
|
|
1165
1175
|
managedVectorRuntimeUnsupported: 'No verified runtime artifacts for this platform',
|
|
1166
1176
|
managedVectorRuntimeInstall: 'Download runtime',
|
|
1167
1177
|
managedVectorRuntimeTitle: 'Runtime',
|
|
1178
|
+
managedVectorSource: 'Download source',
|
|
1179
|
+
managedVectorSourceHint: 'The same files from one pinned commit. Switching source does not change the vector space: every file is verified against the sha256 pinned in the catalog.',
|
|
1168
1180
|
managedVectorModelsTitle: 'Models',
|
|
1169
1181
|
managedVectorReady: 'Ready',
|
|
1170
1182
|
vectorRebuildTitle: 'Rebuild progress',
|
|
@@ -1810,6 +1822,9 @@ window.__ModuleLoader__.load({
|
|
|
1810
1822
|
.dshm-card:hover{transform:translateY(-2px);box-shadow:0 10px 28px -12px rgba(0,0,0,.28)}
|
|
1811
1823
|
.dshm-rise{animation:dshm-rise-in .34s cubic-bezier(.22,1,.36,1) both;animation-delay:calc(var(--d,0) * 38ms)}
|
|
1812
1824
|
.dshm-card-head{display:flex;align-items:flex-start;gap:11px}
|
|
1825
|
+
.dshm-logrow.is-failed{border-left:2px solid var(--dsw-alias-label-error,#c0392b);background:color-mix(in srgb,var(--dsw-alias-label-error,#c0392b) 7%,transparent)}
|
|
1826
|
+
.dshm-logrow.is-failed .dshm-logmsg{color:var(--dsw-alias-label-error,#c0392b)}
|
|
1827
|
+
.dshm-logrow.is-degraded{border-left:2px solid var(--dsw-alias-label-warning,#b7791f)}
|
|
1813
1828
|
.dshm-card-ico{width:32px;height:32px;flex:none;border-radius:10px;display:grid;place-items:center;color:var(--dsw-alias-brand-primary,#2563eb);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#2563eb) 12%,transparent)}
|
|
1814
1829
|
.dshm-card-title{font-size:13.5px;font-weight:600;line-height:1.3}
|
|
1815
1830
|
.dshm-card-sub{margin-top:3px;font-size:11.5px;line-height:1.5;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8));max-width:60ch}
|
|
@@ -2298,6 +2313,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2298
2313
|
// otherwise the badge is just more grey text to skim past.
|
|
2299
2314
|
const TAG_TONES = {
|
|
2300
2315
|
warn: { color: V.warn, background: 'color-mix(in srgb, currentColor 12%, transparent)' },
|
|
2316
|
+
danger: { color: V.danger, background: 'color-mix(in srgb, currentColor 12%, transparent)' },
|
|
2301
2317
|
info: { color: V.accent, background: V.accentSoft },
|
|
2302
2318
|
}
|
|
2303
2319
|
|
|
@@ -2306,6 +2322,23 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2306
2322
|
return h('span', { style, title }, children)
|
|
2307
2323
|
}
|
|
2308
2324
|
|
|
2325
|
+
// 活动日志行的三档状态。失败 = ok=false 或 level=error;level=warn 而 ok 不为 false
|
|
2326
|
+
// 是「降级」(向量未激活、自动关联跳过),不能跟失败同色——真失败会被降级噪声淹没。
|
|
2327
|
+
// 只看 level==='error' 会漏:整理超时记的是 warn + ok=false(lib/private.js 的超时路径)。
|
|
2328
|
+
function logRowState(row) {
|
|
2329
|
+
if (!row || typeof row !== 'object') return null
|
|
2330
|
+
if (row.ok === false || row.level === 'error') return 'failed'
|
|
2331
|
+
if (row.level === 'warn') return 'degraded'
|
|
2332
|
+
return null
|
|
2333
|
+
}
|
|
2334
|
+
function logRowClass(row) {
|
|
2335
|
+
const state = logRowState(row)
|
|
2336
|
+
return state ? `dshm-logrow is-${state}` : 'dshm-logrow'
|
|
2337
|
+
}
|
|
2338
|
+
function logMessageClass(row) {
|
|
2339
|
+
return logRowState(row) === 'failed' ? 'dshm-logmsg' : undefined
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2309
2342
|
// The host lists untitled sessions (renamed title events are async), so fall
|
|
2310
2343
|
// back to a short id rather than the full `session-…` string in the picker.
|
|
2311
2344
|
function sessionLabel(s) {
|
|
@@ -3752,6 +3785,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3752
3785
|
const [busy, setBusy] = React.useState(false)
|
|
3753
3786
|
const [vectorOperation, setVectorOperation] = React.useState('')
|
|
3754
3787
|
const [vectorError, setVectorError] = React.useState('')
|
|
3788
|
+
// 每张卡片各自记下载来源;没选过就用目录的默认顺序(第一个已固定的 provider)。
|
|
3789
|
+
const [vectorProvider, setVectorProvider] = React.useState({})
|
|
3755
3790
|
// 全局记忆页"查看此记忆"的接力棒:带着 id 切到 MemU 记忆页,墙直接开对应抽屉。
|
|
3756
3791
|
const [wallFocus, setWallFocus] = React.useState(null)
|
|
3757
3792
|
// Success messages need their own slot: reusing `error` would paint a good
|
|
@@ -4656,9 +4691,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4656
4691
|
setVectorOperation('')
|
|
4657
4692
|
}
|
|
4658
4693
|
}
|
|
4659
|
-
const managedVectorDownload = async (id) => {
|
|
4694
|
+
const managedVectorDownload = async (id, provider) => {
|
|
4660
4695
|
if (!confirmAction(`download:${id}`)) return
|
|
4661
|
-
await managedVectorAction('downloadLocalVectorModel', { id, confirmed: true })
|
|
4696
|
+
await managedVectorAction('downloadLocalVectorModel', { id, confirmed: true, ...(provider ? { provider } : {}) })
|
|
4662
4697
|
}
|
|
4663
4698
|
const managedVectorSelect = async (id) => managedVectorAction('selectLocalVectorModel', { id })
|
|
4664
4699
|
const managedVectorSwitch = async () => {
|
|
@@ -5046,20 +5081,40 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5046
5081
|
const isRequested = localVector.vector?.requested?.catalogId === entry.id
|
|
5047
5082
|
const canSelect = install.installed === true && install.fingerprintMatches !== false
|
|
5048
5083
|
const pendingArtifact = entry.availability === 'pending' || (entry.pendingReasons || []).length > 0
|
|
5049
|
-
const
|
|
5084
|
+
const providers = entry.providers || []
|
|
5085
|
+
const chosenSource = vectorProvider[entry.id] || providers[0]?.id || ''
|
|
5086
|
+
const bytes = Number(entry.totalBytes)
|
|
5087
|
+
const sizeText = bytes > 0
|
|
5088
|
+
? (bytes >= 1048576 ? `${(bytes / 1048576).toFixed(bytes >= 10485760 ? 0 : 1)} MB` : `${Math.max(1, Math.round(bytes / 1024))} KB`)
|
|
5089
|
+
: t('managedVectorSizePending')
|
|
5050
5090
|
const statusText = install.installed ? t('managedVectorInstalled') : pendingArtifact ? t('managedVectorPending') : (install.status || entry.availability || t('managedVectorUnavailable'))
|
|
5051
5091
|
return h('div', { key: entry.id, className: 'dshm-model' },
|
|
5052
5092
|
h('div', null,
|
|
5053
5093
|
h('div', { className: 'dshm-step-title' }, entry.displayName || entry.id),
|
|
5054
5094
|
h('div', { className: 'dshm-model-meta' },
|
|
5055
5095
|
h(Tag, null, `${entry.dimension || '?'}d`),
|
|
5096
|
+
(entry.languages || []).length ? h(Tag, null, (entry.languages || []).join(' · ')) : null,
|
|
5056
5097
|
h(Tag, null, sizeText),
|
|
5057
5098
|
h(Tag, install.installed ? { tone: 'info' } : pendingArtifact ? { tone: 'warn' } : null, statusText),
|
|
5058
5099
|
isActive ? h(Tag, { tone: 'info' }, t('managedVectorActive')) : null,
|
|
5059
5100
|
isRequested ? h(Tag, { tone: 'warn' }, t('managedVectorRequested')) : null)),
|
|
5101
|
+
// 多个已固定来源才能选(只有一个就没有「选」这件事)。默认是目录顺序的
|
|
5102
|
+
// 第一个,也就是 Qwen3 卡片上的 hf-mirror;换源不改向量空间——每个文件
|
|
5103
|
+
// 都要过同一个 pin 住的 sha256。
|
|
5104
|
+
providers.length > 1 ? h('div', { className: 'dshm-nav-list is-row', role: 'tablist', 'aria-label': t('managedVectorSource') },
|
|
5105
|
+
providers.map(item => h('button', {
|
|
5106
|
+
key: item.id,
|
|
5107
|
+
type: 'button',
|
|
5108
|
+
role: 'tab',
|
|
5109
|
+
title: t('managedVectorSourceHint'),
|
|
5110
|
+
'aria-selected': chosenSource === item.id,
|
|
5111
|
+
disabled: busy || install.installed,
|
|
5112
|
+
className: `dshm-nav-item${chosenSource === item.id ? ' on' : ''}`,
|
|
5113
|
+
onClick: () => setVectorProvider(current => ({ ...current, [entry.id]: item.id })),
|
|
5114
|
+
}, item.label))) : null,
|
|
5060
5115
|
h('div', { className: 'dshm-step-actions' },
|
|
5061
5116
|
!install.installed && entry.availability === 'available'
|
|
5062
|
-
? h(Button, { onClick: () => managedVectorDownload(entry.id), disabled: busy, primary: true, title: t('managedVectorDownload') }, actionLabel(`download:${entry.id}`, t('managedVectorDownload')))
|
|
5117
|
+
? h(Button, { onClick: () => managedVectorDownload(entry.id, providers.length > 1 ? chosenSource : ''), disabled: busy, primary: true, title: t('managedVectorDownload') }, actionLabel(`download:${entry.id}`, t('managedVectorDownload')))
|
|
5063
5118
|
: null,
|
|
5064
5119
|
canSelect && !isActive
|
|
5065
5120
|
? h(Button, { onClick: () => managedVectorSelect(entry.id), disabled: busy, title: t('managedVectorSelect'), style: S.ghost }, t('managedVectorSelect'))
|
|
@@ -6025,10 +6080,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6025
6080
|
logNotice ? h('div', { style: { ...S.muted, marginTop: 6, color: V.accent } }, logNotice) : null,
|
|
6026
6081
|
logRows.length === 0
|
|
6027
6082
|
? h(Empty, null, t('logEmpty'))
|
|
6028
|
-
: h('div', { style: S.list }, logRows.map(row => h('div', { key: row.id, style: S.item },
|
|
6083
|
+
: h('div', { style: S.list }, logRows.map(row => h('div', { key: row.id, style: S.item, className: logRowClass(row) },
|
|
6029
6084
|
h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 8, alignItems: 'center' } },
|
|
6030
6085
|
h('div', { style: { display: 'flex', gap: 6, alignItems: 'center', minWidth: 0, flexWrap: 'wrap' } },
|
|
6031
|
-
h(Tag,
|
|
6086
|
+
h(Tag, null, LOG_KIND_LABELS[row.kind] || row.kind),
|
|
6087
|
+
logRowState(row) === 'failed' ? h(Tag, { tone: 'danger', title: t('logStateFailedHint') }, t('logStateFailed')) : null,
|
|
6088
|
+
logRowState(row) === 'degraded' ? h(Tag, { tone: 'warn', title: t('logDegradedHint') }, t('logDegraded')) : null,
|
|
6032
6089
|
h('span', { style: S.muted }, new Date(row.at).toLocaleString()),
|
|
6033
6090
|
// 整理/提炼日志挂上会话标题与文件夹名,裸 id 只做回退:日志页要回答
|
|
6034
6091
|
// "这是哪个对话、哪个库",光靠 sessionId 后 10 位查不动。
|
|
@@ -6051,7 +6108,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6051
6108
|
setLogNotice(ok ? t('copied') : t('copyFailed'))
|
|
6052
6109
|
},
|
|
6053
6110
|
}, t('logCopyOne')))),
|
|
6054
|
-
h('div', { style: { marginTop: 4, whiteSpace: 'pre-wrap' } }, row.message),
|
|
6111
|
+
h('div', { className: logMessageClass(row), style: { marginTop: 4, whiteSpace: 'pre-wrap' } }, row.message),
|
|
6055
6112
|
Array.isArray(row.refs) && row.refs.length
|
|
6056
6113
|
? h('div', { style: { ...S.muted, marginTop: 4 } }, row.refs.join(' · '))
|
|
6057
6114
|
: null,
|
|
@@ -6409,9 +6466,13 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6409
6466
|
curate: t('logKindCurate'), vector: t('logKindVector'), error: t('logKindError'), system: t('logKindSystem'),
|
|
6410
6467
|
check: t('logKindCheck'), wake: t('logKindWake'),
|
|
6411
6468
|
}
|
|
6469
|
+
// 侧栏的「整理记录」只放正常流水:失败已经由上方「整理提醒」负责(跨会话、可清除、
|
|
6470
|
+
// 可跳转),在这里再重复一遍只会让 5 行里挤满红字。红色与「失败/降级」标签只在
|
|
6471
|
+
// WebUI › 全部日志 里出现——那里才是按时间翻全部事件的地方。
|
|
6472
|
+
const sidebarRuns = runLog.filter((row) => logRowState(row) !== 'failed')
|
|
6412
6473
|
const renderRunRow = (row) => h('div', { key: row.id, style: S.item },
|
|
6413
6474
|
h('div', { style: { display: 'flex', gap: 6, alignItems: 'center', flexWrap: 'wrap' } },
|
|
6414
|
-
h(Tag,
|
|
6475
|
+
h(Tag, null, RUN_KIND_LABELS[row.kind] || row.kind),
|
|
6415
6476
|
h('span', { style: S.muted }, new Date(row.at).toLocaleTimeString())),
|
|
6416
6477
|
h('div', { style: { marginTop: 2, whiteSpace: 'pre-wrap', fontSize: 12 } }, row.message))
|
|
6417
6478
|
|
|
@@ -6470,9 +6531,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6470
6531
|
},
|
|
6471
6532
|
h('span', { style: { ...S.muted, fontWeight: 600 } }, t('runLogTitle')),
|
|
6472
6533
|
h('span', { style: { marginLeft: 'auto', fontSize: 11, fontWeight: 600, color: V.accent } }, t('runLogOpen') + ' ↗')),
|
|
6473
|
-
|
|
6534
|
+
sidebarRuns.length === 0
|
|
6474
6535
|
? h('div', { style: S.muted }, t('runLogEmpty'))
|
|
6475
|
-
: h('div', { style: S.list },
|
|
6536
|
+
: h('div', { style: S.list }, sidebarRuns.slice(0, 5).map(renderRunRow)))),
|
|
6476
6537
|
// 作用域放在控制卡之后:它是一组低频字段,先让用户看到记忆开关和整理入口。
|
|
6477
6538
|
h(ContextScope, { binding, sessionId, call, t })
|
|
6478
6539
|
)
|