dsh-memu-memory 1.2.4 → 1.2.6

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 (57) hide show
  1. package/AGENTS.md +3 -1
  2. package/README.md +9 -9
  3. package/README.zh.md +6 -6
  4. package/docs/binding-lifecycle.md +1 -1
  5. package/docs/env-and-commands.md +4 -1
  6. package/docs/host-adaptation.md +318 -0
  7. package/docs/host-api.md +29 -5
  8. package/docs/memory-semantics.md +45 -9
  9. package/docs/troubleshooting.md +27 -8
  10. package/lib/binding-diagnostics.js +2 -2
  11. package/lib/client.js +246 -56
  12. package/lib/consolidation-ledger.js +46 -1
  13. package/lib/consolidation-worker.js +1 -0
  14. package/lib/cycle.js +51 -17
  15. package/lib/embedding-catalog.js +14 -0
  16. package/lib/embedding-runtime.js +202 -25
  17. package/lib/global-graph.js +99 -1
  18. package/lib/index.js +8 -0
  19. package/lib/inject.js +71 -33
  20. package/lib/lexicon-scope.js +143 -0
  21. package/lib/lexicon.js +31 -4
  22. package/lib/local-vector-service.js +82 -6
  23. package/lib/memory.js +186 -12
  24. package/lib/memu.js +318 -3
  25. package/lib/private.js +310 -67
  26. package/lib/rpc.js +183 -23
  27. package/lib/salient-wake.js +38 -2
  28. package/lib/state.js +7 -5
  29. package/lib/tools.js +40 -17
  30. package/lib/vector-migration.js +13 -1
  31. package/lib/webui/graph-view.bundle.js +1 -1
  32. package/lib/webui/graph-view.js +4 -1
  33. package/package.json +1 -1
  34. package/tests/absorb-review.test.mjs +2 -1
  35. package/tests/backend-compensation.test.mjs +1 -1
  36. package/tests/browser.test.mjs +58 -1
  37. package/tests/client-render.test.mjs +39 -0
  38. package/tests/consolidation-fork.test.mjs +81 -6
  39. package/tests/cross-library-recall.test.mjs +113 -0
  40. package/tests/curator-absorb.test.mjs +2 -1
  41. package/tests/curator-clusters.test.mjs +2 -1
  42. package/tests/curator-commit.test.mjs +2 -1
  43. package/tests/curator-link.test.mjs +2 -1
  44. package/tests/curator-review-mode.test.mjs +2 -1
  45. package/tests/cycle.test.mjs +2 -2
  46. package/tests/embedding-runtime.test.mjs +53 -1
  47. package/tests/global-graph.test.mjs +90 -0
  48. package/tests/lexicon-scope.test.mjs +256 -0
  49. package/tests/lexicon-ui.test.mjs +23 -0
  50. package/tests/managed-memory.test.mjs +1 -1
  51. package/tests/recall-dedup.test.mjs +1 -1
  52. package/tests/salient-wake.test.mjs +28 -1
  53. package/tests/settings-plumbing.test.mjs +1 -0
  54. package/tests/stubs/dsh-schedule.js +35 -0
  55. package/tests/ui-defaults.test.mjs +1 -1
  56. package/tests/vector-migration.test.mjs +20 -0
  57. package/tests/webui-auth.test.mjs +28 -0
package/AGENTS.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  ## 1. 硬规则(不放宽)
14
14
 
15
- 1. **不改 DSH 源码**,只用插件、公开 service、RPC、slot;只用公开扩展点。
15
+ 1. **不改 DSH 源码**,只用插件、公开 service、RPC、slot;只用公开扩展点。宿主差异用能力探测(方法/字段存在性),不写版本号比较;宁可降级并留一行日志,也不 fail closed(→ `docs/host-adaptation.md`)。
16
16
  2. **不让主 agent 写全局记忆**:全局只由 curator 写,主 agent 只读。
17
17
  3. **记忆规则与动态记忆都走 plugin 消息**:当前版本不再注册 system prompt 段;静态 guide 在回合首步以 `<memory-guide rules="…">` 投放(`rulesKey` 处理切域/改稿/压缩丢失),动态记忆走独立 plugin 消息,保护 KV cache 并让注入可折叠。
18
18
  4. **不每步注入**:普通回合首步注入;长工具回合只在出现尚未处理的真实人类消息批次时追加一次。工具日志、心跳不算人类消息。
@@ -31,6 +31,7 @@
31
31
  |---|---|
32
32
  | 现象不对、有报错 | `docs/troubleshooting.md`(先看症状速查表) |
33
33
  | 改现有行为 / 加新东西 / 提交前自检 | `docs/contributing.md` |
34
+ | **DSH 发新版本、要适配新宿主** | `docs/host-adaptation.md`(检查表 / 真机搭法 / 已知陷阱 / 版本记录) |
34
35
  | 忘了宿主 API 长什么样 | `docs/host-api.md`;三种 exec 形状在 `docs/troubleshooting.md` 附录 D |
35
36
  | 动 UI | `docs/client-conventions.md` |
36
37
  | 改记忆语义 / 提示词正文 | `docs/memory-semantics.md` |
@@ -75,6 +76,7 @@ npm run check # node --check + i18n + package.json + 文
75
76
  | `docs/troubleshooting.md` | §3 全部症状/落点/守卫 + 症状速查表 + 守卫索引表 + 附录(模块地图 §2.1、调用链 §2.2、数据铁律 §2.3、三种 exec 形状 §6.3、硬规则全文 §1) |
76
77
  | `docs/contributing.md` | §4 改动流程(四步 / 验证三件套 / 连带清单 / 文档同步)+ §5 六个扩展点 + §10 提交前清单 |
77
78
  | `docs/host-api.md` | §6.1 / 6.2 / 6.4–6.8:embedding、workspaceRegistry、历史会话与标题、fork/followup、定时器、RPC+slot+折叠、预设工具面真机证据边界 |
79
+ | `docs/host-adaptation.md` | 宿主版本适配手册:事实来源、memu 的宿主面清单、新版本检查流程、隔离真机搭法、0.2.2-rc.1 实测记录与陷阱 |
78
80
  | `docs/client-conventions.md` | §7:两个壳一份实现、颜色 token、控件纪律、数据与刷新、文案与结构 |
79
81
  | `docs/memory-semantics.md` | §8:三层、写入规则、全局记忆、注入(含预设会话首步 `<memory-guide>` 一次性投放)、提示词管理 |
80
82
  | `docs/env-and-commands.md` | §9:Windows 跑命令的 env、CRLF 补丁法、本地 link、引擎安装与回滚、本地向量受管运行时的安装/状态命令(§9.5)、MemU CLI 事实 |
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.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.
33
+ > **Status:** 1.2.6. 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
 
@@ -58,7 +58,7 @@ All screenshots are the real WebUI on isolated example data, not anyone's memori
58
58
 
59
59
  - **Three layers, one timeline.** `short_term` drafts expire after 72 hours by default; `long_term` is the body of ordinary memory; `must_remember` needs a reason and a source, decays over 365 days with a 0.35 strength floor, and can be *marginalized* but never auto-deleted to make room.
60
60
  - **Recall is a moment, not a dump.** The first turn after a session starts (or after compaction) gets an anchor block with budgets for pinned, core and global memory. After that, each user turn gets at most one recall. Deduplication and a token budget are enforced in code, not left to the prompt. Anchor and recall entries are **title cards**: title, id and semantic tags only. The body stays in the drawer and behind `memu_private_recall` / `memu_global_recall`, so the same budget exposes far more memories without pasting text the model never asked for.
61
- - **A private lexicon writes itself.** The consolidation worker extracts stable, evidenced slang, memes and project terms with one term per entry. Ordinary entries become active immediately (no human review queue), while sensitive triggers and sensitive edits stay user-only. The lexicon page is a card flow with active/archived tabs, edit, archive/restore and two-step permanent delete.
61
+ - **A private lexicon writes itself.** The consolidation worker extracts stable, evidenced slang, memes and project terms with one term per entry. Ordinary entries become active immediately (no human review queue), while sensitive triggers and sensitive edits stay user-only. The lexicon page is a card flow with active/archived tabs, edit, archive/restore and two-step permanent delete. A **global lexicon** sits beside the per-library ones: every conversation reads it, only you write it. With same-domain cross-library recall on, the anchor, this-turn match and `memu_lexicon_search` merge those libraries too — the page still browses one book at a time.
62
62
  - **Private links are algorithm-first.** After consolidation, a zero-token pass connects memories that share a rare name or alias in the same context/track and creates/reuses an entity hub (for example `yuike`). Uncertain pairs are handed to the consolidation worker for an evidence-based decision. Links are metadata (`source: 'auto'`), shown with an “Auto” badge in the graph and removable; they never rewrite a body, write a vector or delete anything.
63
63
  - **A date is either an anniversary or one day.** `MM-DD` recurs every year (a birthday); `YYYY-MM-DD` fires the day before and the day itself, then is spent. A memory that says "tomorrow" is stored as the dated form, so an appointment does not come back every year.
64
64
  - **Memory fades unevenly.** Recency, access count, peak and end effects, primacy, habituation and flashbulb accuracy feed one strength score. Mood is described by four components (joy / anger / sorrow / fear, summing to 1) plus arousal (intensity) and dominance (sense of control); a compound mood such as jealousy is a named mix of the four, not a new axis. Mood only reorders recall: it never enters the injected text and never rewrites a memory body. Gating is the OR of three independent conditions — the dominant share is >= 0.35, |arousal - 0.35| >= 0.1, or |dominance| >= 0.25; when none holds, both multipliers are exactly 1. Older entries carry no emotion and keep the old valence path; the four axes are never inferred back from valence. A vivid memory can be more confident than it is accurate, and the UI says so.
@@ -105,15 +105,15 @@ The sidebar has exactly **one** entry: **MemU WebUI**. The memory wall and all s
105
105
 
106
106
  **In-place work.** Clicking a memory card opens a right-side drawer with the full text and the fields that decide how it behaves — title, content, tags, disclosure, confidence, open loop — plus save, archive, restore and "open in the browser" for heavier work. Archived memories can be deleted in the same drawer; the first click only arms it and the second confirms. Global memories are read-only in the drawer and link to their own page. Filters and scroll position stay where they were. Cards that carry images use the first usable attachment as a cover, and the drawer opens the full gallery; `secret` and `never_say` entries never receive a pixel URL, so they show a label instead.
107
107
 
108
- **Graph and list together.** The **Relations** tab renders the graph canvas and the adjacency list side by side (stacked on narrow screens), with the focus selector above them and link/entity/relationship tools below. There is no mode switch to forget.
108
+ **Graph and list together.** The **Relations** tab renders the graph canvas and the adjacency list side by side (stacked on narrow screens), with the focus selector above them and link/entity/relationship tools below. There is no mode switch to forget. The scope selector also carries a **Global memory** entry: nodes are global entries and edges are `related/refines/supports`; the global view is read-only, and edges are removed from the global memory list.
109
109
 
110
110
  The locally bundled D3 force layout preserves positions and the camera across background data refreshes. Drag nodes, pan the background, zoom with the wheel or pinch, fit the graph, and highlight neighbors. Labels avoid collisions; graph settings adjust repulsion, link distance, labels and live layout. Layout only visualizes recorded links: it never infers or writes relationships. The graph page also lists **entity merge candidates** (same kind, contained or near-identical spellings) — suggestions only, confirmed by two clicks, and merging redirects links and folds aliases into the main node without deleting any memory.
111
111
 
112
112
  | Page | What it is for |
113
113
  |---|---|
114
114
  | Memories | Private/global grouped wall, source/status/library/preview, in-place drawer, multi-select bulk ops, node graph tab |
115
- | Engine & connection | Optional MemU engine install/switch, embedding endpoint, backups and restore |
116
- | Memory settings | Injection mode, token budgets, topK, relevance threshold, retention, open-loop cadence, freshness hint, date wake-up, automation |
115
+ | Engine & connection | Optional MemU engine install/switch, embedding endpoint, backups and restore; local runtime download shows MB/s, offers npmjs / npmmirror, and supports pause, stop and resume |
116
+ | Memory settings | Injection mode, token budgets, topK, same-domain cross-library recall, relevance threshold, retention, open-loop cadence, freshness hint, date wake-up, automation |
117
117
  | Folders | Folder-level private/global ceiling, expandable conversations and their own switches |
118
118
  | Libraries | Create, rename, archive, restore, explicitly delete libraries |
119
119
  | Memory browser | Full-text editing, attachments, review queue, graph and bounded canvas, JSON/ZIP import/export |
@@ -152,7 +152,7 @@ Updated defaults never overwrite custom text. The default-update notice remains
152
152
 
153
153
  | | |
154
154
  |---|---|
155
- | DSH | `>=0.2.0-rc.1` (web profile) |
155
+ | DSH | `>=0.2.0-rc.1` (web profile; verified on `0.2.2-rc.1`, 2026-11-05) |
156
156
  | Node.js | `>=20.9` |
157
157
  | OS | Windows, macOS or Linux, wherever DSH's web host runs |
158
158
  | Optional engine | Python 3.11+ **only** if you choose the vector backend. The default backend needs no Python, no embedding service and no API key. |
@@ -246,8 +246,8 @@ Folder policy is a **ceiling, not an initial value**: turning a folder switch of
246
246
  | `memu_private_unpin` | Marginalize a permanent memory with a first-person reason, quota and cooldown |
247
247
  | `memu_private_link` | Link memories/entities with evidence, or update a relationship snapshot; also adjudicates `memu_private_link_suggest` candidates; cannot delete edges |
248
248
  | `memu_private_link_suggest` | Run the local high-confidence linking/entity-hub pass for ids written this consolidation and return only uncertain candidate pairs |
249
- | `memu_lexicon_search` | Search active private-lexicon terms; archived and tombstoned terms stay hidden |
250
- | `memu_lexicon_propose` | Add or update a lexicon term; ordinary entries become active immediately, sensitive triggers remain user-only |
249
+ | `memu_lexicon_search` | Search active lexicon terms this conversation can see: bound library + global lexicon (+ same-domain libraries when cross-library recall is on); archived and tombstoned terms stay hidden |
250
+ | `memu_lexicon_propose` | Add or update a lexicon term in the bound library (never the global lexicon); ordinary entries become active immediately, sensitive triggers remain user-only |
251
251
  | `memu_global_recall` / `memu_global_list` | Read the global layer by domain |
252
252
  | `memu_status` | Storage health, sync heartbeat, recall state and image-turn status |
253
253
 
@@ -332,7 +332,7 @@ the idle window starts from real message activity or the agent's return to idle.
332
332
 
333
333
  ## Compatibility & limits
334
334
 
335
- - **Host:** DSH `>=0.2.0-rc.1`, using public extension points only (tools, injection, session query, subagents, slots, a prefixed HTTP route). No host source modifications.
335
+ - **Host:** DSH `>=0.2.0-rc.1`, using public extension points only (tools, injection, session query, subagents, slots, a prefixed HTTP route). No host source modifications. The core surfaces (13 `memu_*` tools, guide injection, settings page, right-sidebar tab, prefixed RPC) were verified on `0.2.2-rc.1` on 2026-11-05; the check table lives in [`docs/host-adaptation.md`](docs/host-adaptation.md). The optional dated-wake feature uses the host-wide `ctx.schedule` task API introduced in `0.2.2`; on `0.2.0`–`0.2.1` (session-scoped reminders) it detects the older shape and skips with one warning instead of retrying every sweep.
336
336
  - **Recall quality:** the default backend is lexical. Semantic recall depends on the optional engine and the embedding model you choose; the plugin cannot improve a model it does not own. LongMemEval, long-running group-chat A/B and "human-likeness" scores have **not** been run — test counts are not a quality score.
337
337
  - **No cloud sync, no accounts, no cross-device sync.** This is a local plugin with no server-side identity.
338
338
  - **Images without vision:** without an optional caption/vision endpoint, an image memory is a pointer plus what a person wrote about it. The plugin does not claim to see pixels.
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.4。首个公开发布版本为 1.0.0。细节文档已迁到 [`docs/`](docs/),[`AGENTS.md`](AGENTS.md) 只做索引。升级前请备份 `~/.dsh/dsh-memu-memory`;如果要存无法重建的数据,请先读[兼容性与边界](#兼容性与边界)。
33
+ > **状态:** 1.2.6。首个公开发布版本为 1.0.0。细节文档已迁到 [`docs/`](docs/),[`AGENTS.md`](AGENTS.md) 只做索引。升级前请备份 `~/.dsh/dsh-memu-memory`;如果要存无法重建的数据,请先读[兼容性与边界](#兼容性与边界)。
34
34
 
35
35
  ## 界面
36
36
 
@@ -103,15 +103,15 @@
103
103
 
104
104
  **原地操作。** 点记忆卡片会从右侧滑出详情抽屉:完整正文,以及决定它行为的字段——标题、正文、标签、说出口径、置信度、未了之事——外加保存、归档、恢复,以及需要重编辑时的「在记忆浏览中打开」。已归档的记忆可以直接在抽屉里删除:第一次点击只是准备,第二次才真正删除。全局记忆在抽屉里只读,并给出跳转。筛选条件与滚动位置保持不动。带图片的卡片会把第一张可用附件作为封面,抽屉里展开完整图片组;`secret` 与 `never_say` 条目不会拿到像素 URL,只显示标签占位。
105
105
 
106
- **关系图与邻接列表一起看。** 「节点图」页签把关系画布与邻接列表并排显示(窄屏上下堆叠),焦点选择在上方,建边/实体/关系状态工具在下方;没有需要记得切换的模式。
106
+ **关系图与邻接列表一起看。** 「节点图」页签把关系画布与邻接列表并排显示(窄屏上下堆叠),焦点选择在上方,建边/实体/关系状态工具在下方;没有需要记得切换的模式。范围选择器除了私有库,还带一项**全局记忆**:节点是全局条目、边是 `related/refines/supports`,全局视图只读,移除边仍在全局记忆列表里完成。
107
107
 
108
108
  图谱使用本地打包的 D3 力导向布局,后台数据刷新保留节点位置与视角。支持拖拽节点、空白处平移、滚轮/双指缩放、适应全图与关联高亮;标签自动避让,设置中可调整斥力、连线距离,以及关闭标签或动态布局。图谱布局只表达已记录的关联,不会推断或写入新的关系。实体可以直接在图谱里删除(仍被引用时会明确拒绝);永久删除一条记忆会连带清理指向它的边与孤立实体,孤立节点有启动扫描自动回收。节点图页还会列出**实体合并候选**(同 kind、名称包含或写法相近):只是建议,两次点击确认;合并把来源实体的记忆链接改指主节点、别名并入,不删除任何记忆。
109
109
 
110
110
  | 页面 | 用途 |
111
111
  |---|---|
112
112
  | MemU 记忆 | 私有/全局分组记忆墙、来源/状态/库名/预览、原地详情、多选批量操作、节点图统一视图 |
113
- | 引擎与连接 | 可选 MemU 引擎的安装与切换、embedding 配置、备份恢复 |
114
- | 记忆设置 | 注入模式、token 预算、topK、相关度下限、留存、未了之事复提节奏、时效提示、日期唤醒、自动化 |
113
+ | 引擎与连接 | 可选 MemU 引擎的安装与切换、embedding 配置、备份恢复;本地运行时下载显示 MB/s,可选 npmjs / npmmirror,支持暂停、停止与续传 |
114
+ | 记忆设置 | 注入模式、token 预算、topK、同领域跨库召回、相关度下限、留存、未了之事复提节奏、时效提示、日期唤醒、自动化 |
115
115
  | 文件夹 | 文件夹级私有/全局上限,展开对话修改各自选择 |
116
116
  | 记忆库 | 新建、改名、归档、恢复、显式删除 |
117
117
  | 记忆浏览 | 全文编辑、附件、复核池、有界图谱、JSON/ZIP 导入导出 |
@@ -150,7 +150,7 @@
150
150
 
151
151
  | | |
152
152
  |---|---|
153
- | DSH | `>=0.2.0-rc.1`(web profile) |
153
+ | DSH | `>=0.2.0-rc.1`(web profile;2026-11-05 在 `0.2.2-rc.1` 上实测) |
154
154
  | Node.js | `>=20.9` |
155
155
  | 操作系统 | Windows / macOS / Linux(跟随 DSH web 宿主) |
156
156
  | 可选引擎 | 仅在选择向量后端时需要 Python 3.11+。默认后端不需要 Python、embedding 服务或 API key。 |
@@ -319,7 +319,7 @@ return { content: originalContent, meta: { ...originalMeta, memoryInbound: batch
319
319
 
320
320
  ## 兼容性与边界
321
321
 
322
- - **宿主:** DSH `>=0.2.0-rc.1`,只使用公开扩展点(工具、注入、会话查询、子代理、slot、带前缀的 HTTP 路由),不修改宿主源码。
322
+ - **宿主:** DSH `>=0.2.0-rc.1`,只使用公开扩展点(工具、注入、会话查询、子代理、slot、带前缀的 HTTP 路由),不修改宿主源码。核心面(13 个 `memu_*` 工具、guide 注入、设置页、右侧栏、前缀 RPC)已在 2026-11-05 的 `0.2.2-rc.1` 上实测,核对表见 [`docs/host-adaptation.md`](docs/host-adaptation.md)。可选的日期唤醒使用 `0.2.2` 起的宿主级 `ctx.schedule` 任务表;在 `0.2.0`–`0.2.1`(会话级提醒 API)上会识别出旧形状、跳过并只警告一次,不会每轮重试。
323
323
  - **召回质量:** 默认后端是词法检索。语义召回取决于可选引擎和你选择的 embedding 模型;插件无法提升一个它不拥有的模型。没有跑过 LongMemEval、长期群聊/RP A/B 或「拟人度」评分——测试数量不是质量分数。
324
324
  - **没有云同步、账号或跨设备同步。** 这是本地插件,没有服务端身份。
325
325
  - **没有视觉时:** 图片记忆只是「指针 + 人写的描述」。插件不会声称看过像素。
@@ -12,7 +12,7 @@
12
12
  |---|---|---|---|
13
13
  | 1. 持久绑定 | `state.json` 的 `sessions[sessionId]`:`scopeKey`、`libraryId`、开关、`memoryContext`、`inbound.pending/seen/claimed/clock`、`sleepRetryAt`、注入标记等 | 跨重启、fork、插件重载保留;只有显式状态写入才改变 | 只读快照可读;报告的核心对象 |
14
14
  | 2. 运行时监听器 | `lib/preset-scope.js:19` 的 `attachments`,按 **agent context 对象** 键控 | 随 context 存在;context 被替换时旧监听器应释放,下一次 attach 重新挂载 | 跨进程不可读,声明为 `runtime-listener` |
15
- | 3. 临时映射/缓存 | `lib/inbound.js:12-14` 的 `mediaJobs`/`calls`/`sessions`、`lib/media.js:19` 的 `captures`、`lib/private.js:213` 的 `inFlight`、`lib/curator.js:11` 的 `jobs`、`lib/state.js:938` 的 `indexCache`、`lib/paths.js:52` 的 `readFailures` | 随 promise settle、turn/end、session/disposed、下一次成功读取或下一次加载清理 | 跨进程不可读,声明为 `temporary-map` 或 `cache` |
15
+ | 3. 临时映射/缓存 | `lib/inbound.js:12-14` 的 `mediaJobs`/`calls`/`sessions`、`lib/media.js:19` 的 `captures`、`lib/private.js:213` 的 `inFlight`、`lib/curator.js:11` 的 `jobs`、`lib/state.js:1146` 的 `indexCache`、`lib/paths.js:52` 的 `readFailures` | 随 promise settle、turn/end、session/disposed、下一次成功读取或下一次加载清理 | 跨进程不可读,声明为 `temporary-map` 或 `cache` |
16
16
 
17
17
  **三层不混算。** `summary.bindings`、`summary.inbound`、`summary.unfinished` 只统计持久绑定;`summary.runtime` 只在调用方提供了进程内快照时出现,分别是 `runtimeListeners` 和 `temporaryMaps` 的合计。runtime 计数不会加进 binding 数,也不会把“持久层零候选”解释成“运行时没有残留”。同一份 state 在提供/不提供 runtime 快照时,`bindings` 与 `candidates` 必须完全一致。
18
18
 
@@ -51,6 +51,7 @@ npm run replay
51
51
  - `memu-cli` 是 **PyPI 上的 Python 包,不是 npm 包**;锁定 `0.11.0b3`。
52
52
  - 发布版 `memu --help` 只有 `retrieve, search, list-files, commit`;源码里的 `memorize prepare/commit` **尚未发布**,**不要依赖 `memorize`**——当可选能力(启动探测 `memu memorize --help`,成功才注册入口,失败隐藏不报错)。
53
53
  - 必需命令 `retrieve` / `list-files` / `commit`;必需 flag `--json` / `--db` / `--provider` / `--embed-model` / `--api-key` / `--base-url`。**所有 CLI 字符串只在 `lib/memu.js`**。
54
+ - 本地向量模式下插件**常驻一个解释器**(`lib/memu.js` 的 resident engine):启动时 `import memu.cli` 一次,随后 `retrieve` / `list-files` / `commit` 通过 JSON 行协议调用同一个 `main(argv)`,省掉每条命令约 2 s 的导入链;每条命令结束显式 `database.close()`,空闲期不占 sqlite 句柄。远端 API 路由仍按命令新起进程;插件卸载或引擎安装/切换前关闭常驻进程,异常退出时下一条命令冷启动(见 `docs/troubleshooting.md` §3.26)。
54
55
 
55
56
  ```bash
56
57
  python -m memu retrieve "query" --json --db <db>
@@ -71,7 +72,9 @@ node scripts/local-runtime-install.mjs --download --cache <dir> # 用离线 ta
71
72
  node scripts/local-runtime-install.mjs --target <dir> --platform win32-x64 --id <modelId> --shallow
72
73
  ```
73
74
 
74
- 状态 `installed / absent / unsupported / downloading / verifying / installing / failed / cancelled`;`unsupported` = catalog 没 pin 该平台原生库(如 `darwin-x64`)。装失败只 `warn` + 回词法召回,不会自动改用云端 embedding。
75
+ 状态 `installed / absent / unsupported / downloading / paused / stopped / verifying / installing / failed / cancelled`;`unsupported` = catalog 没 pin 该平台原生库(如 `darwin-x64`)。装失败只 `warn` + 回词法召回,不会自动改用云端 embedding。
76
+
77
+ **下载源与续传(设置页)**:运行时三个 tarball 默认从 `npmjs` 取,也可选 `npmmirror(国内镜像)`;每个源都必须返回与 catalog pin 一致的 `bytes`/`sha256`,换源不会换运行时树。下载进度显示百分比、已下载/总量(MB)与实时速度(MB/s)。`暂停`/`停止`只中断传输、不发布 active;已下载字节保存在 `<runtimeRoot>/.cache/<artifact>-<sha256>.tgz.part`,继续/换源/重启后用 HTTP `Range` 从该偏移续传。旧版本留在 `.staging/install-*/.artifacts/*.tgz` 的部分下载会在下一次安装时被接管;校验失败才删除坏 part。
75
78
 
76
79
  #### 9.5.1 五条已核实模型(2026-11-02)
77
80
 
@@ -0,0 +1,318 @@
1
+ # 宿主版本适配手册 — dsh-memu-memory
2
+
3
+ 给下一次「DSH 又发新版本了」用。目标是把适配变成一份可重复的检查表:**先读宿主、再跑真机、最后只改证据支持的地方**。
4
+ 2026-11-05 用 `0.2.2-rc.1` 完整走了一遍,实测记录在 §5。
5
+
6
+ > 这份文档只讲**宿主版本之间的适配**。改记忆语义、RPC、UI 的常规流程在 `docs/contributing.md`;宿主 API 的当前事实速查在 `docs/host-api.md`。
7
+
8
+ ---
9
+
10
+ ## 1. 结论先行(2026-11-05,DSH 0.2.2-rc.1)
11
+
12
+ - **核心面无需改动**:13 个 `memu_*` 工具进入模型请求的 `request/header`;`<memory-guide>` 首轮注入 1 次;`turn/end` 为 `completed`;设置页「MemU 记忆」、右侧栏「MemU 记忆」、新会话弹窗、`/dsh-memu-memory` RPC 全部正常;浏览器控制台 0 error。
13
+ - **0.2.2-alpha.3 → 0.2.2-rc.1 在 memu 用到的宿主 `src` 上零改动**。rc.1 的 cordis 4.1 / timer 1.2 / include 1.1 升级没有影响本插件。
14
+ - **唯一发现的真实版本差异是 `ctx.schedule`**:`0.2.2+` 是宿主级任务表,`0.2.0`–`0.2.1` 是会话级提醒。日期唤醒只实现前者;现在用 `scheduleFlavor()` 结构探测,旧宿主返回 `{skipped:'schedule-api'}` 并只 warn 一次(1.2.6)。
15
+ - **不按版本号分支**:memu 没有 `versions/` 适配目录。宿主差异一律用能力探测(方法/字段存在性)或直接读公开形状;样式/逻辑代码里不出现 `semver` 比较。
16
+
17
+ ---
18
+
19
+ ## 2. memu 的宿主面清单(每次升级逐项过)
20
+
21
+ ### 2.1 Node 半侧
22
+
23
+ | 面 | memu 里的落点 | 0.2.2-rc.1 核对结果 |
24
+ |---|---|---|
25
+ | `ctx.tools.register` + `defineTool` | `lib/tools.js` `toolBase()` | 未变;13 个工具全部注册,`request/header` 可见 |
26
+ | `agent/pre-step` | `lib/inject.js` `registerInjection()` | 未变;payload 新增 `modelSelection`(本插件不读) |
27
+ | `agent/status` / `session/event` / `session/disposed` | `lib/inject.js`、`lib/inbound.js` | 未变 |
28
+ | `ctx.get('agents')`(`list()` / `get()` / `create()`) | `lib/preset-scope.js`、`lib/private.js`、`lib/curator.js` | 未变;`Agent.ctx` 仍在 |
29
+ | `ctx.get('sessionQuery')`(`listSessions` / `readSession` / `observeSession` / `readTitleSnapshots`) | `lib/rpc.js`、`lib/private.js`、`lib/curator.js` | 包源码未变 |
30
+ | `ctx.get('workspaceRegistry')` / `domain/changed` | `lib/rpc.js`、`lib/cycle.js` | 未变 |
31
+ | `ctx.get('subagents').startActivation` | `lib/curator.js` | 形状未变(`provider`/`label`/`delivery`/`request`/`signal`;结果 `stopReason`/`output`) |
32
+ | `ctx.get('attachments').readImage` | `lib/media.js` | 未变 |
33
+ | `ctx.get('schedule')` | `lib/salient-wake.js` | **变了**:见 §6.1 |
34
+ | `connection.requestRejection` / `authorizeLibrary` / `webServer.register` | `lib/rpc.js` | 未变;路由仍是 `kind:'prefix'` + `handler` |
35
+ | `ctx.interval` / `ctx.effect` / `ctx.on(..., {prepend})` | `lib/cycle.js`、`lib/index.js`、注入/监听 | cordis 4.1 未破坏这些用法 |
36
+ | `buildForkSeed`(动态 import `@deepseek-ai/dsh-session`) | `lib/private.js` | 仍从包根导出 |
37
+ | `createUserMessage({source:{kind:'plugin:dsh-memu-memory', form:'recall'}})` | `lib/inject.js` | 未变;`plugin:` 前缀仍被宿主接受 |
38
+
39
+ ### 2.2 Client 半侧
40
+
41
+ | 面 | memu 里的落点 | 0.2.2-rc.1 核对结果 |
42
+ |---|---|---|
43
+ | `window.__ModuleLoader__.load({id, factory})` | `lib/client.js` 包壳 | 未变;宿主启动图里有 `dsh-memu-memory` |
44
+ | `ctx.slots.inject('settings.section')` + `register` | `lib/client.js` `apply()` | 未变;设置页出现「MemU 记忆」 |
45
+ | `ctx.slots.inject('sidebar.right.pane.tab')` + `register` | 同上 | 未变;右侧栏出现「MemU 记忆」 |
46
+ | `ctx.inject(['sidebarRightTabs'])` + `sidebarRightTabs.register({id,kind,title,guide})` | 同上 | 未变 |
47
+ | `ctx.inject(['betterSidebar'])`(可选第三方) | 同上 | 仍按可选服务处理 |
48
+ | `ctx.locale.register(NS, {zh,en})` / `bind` | 同上 | 运行时仍只要求两条基线语言 |
49
+ | `ctx.connection.rpc.call(prefix, method, payload)` | 同上 | 未变 |
50
+ | `ctx.sessions.list`(`byId` / `ids` 快照) | 同上 | 契约未变 |
51
+ | `ctx.get('sidebarRight').mounted` / `uiSession.adapter.current` | 同上 | 未变(仍作为当前会话来源) |
52
+ | `dsh.client` 清单(`platform:'web'`、`inject`、`immediately`) | `package.json` | 字段仍被识别;`inject` 里没有启动图行的包会被忽略(不是错误) |
53
+
54
+ ### 2.3 装载与打包
55
+
56
+ | 面 | 检查点 |
57
+ |---|---|
58
+ | `engines.dsh` / `peerDependencies` | 宿主门禁在 `engines.dsh` 存在时只看它;**不要收窄、不要加下界到新版本**,否则旧宿主整包不加载 |
59
+ | `dsh.bundle.patch` | `cordis.patch.yml` 的 `insert` 行仍被 include 1.1 接受;显式 `id` 必须保留(匿名行在父配置重写后会重启) |
60
+ | `files` / `exports` | 新增运行时文件必须两处都进;`lib/` 是提交内容(本仓库无构建步骤,改 `lib/` 就是改发布物) |
61
+ | `dsh.client` | `platform:'web'` + `exports['./client']`;客户端包只在 `platform` 匹配时进入启动图 |
62
+
63
+ ---
64
+
65
+ ## 3. 新宿主发布时的标准流程
66
+
67
+ ### 3.1 固定目标构建
68
+
69
+ 先确认「新版本」到底是哪个构建:npm `dist-tags`(`latest` / `next` / `alpha`)与用户实际安装的 launcher `versions/<v>` 可能不是同一个。优先用**用户机器上真实存在的那个版本目录**做真机验证。
70
+
71
+ ```bash
72
+ npm view @deepseek-ai/dsh dist-tags
73
+ ls "<launcher>/versions/" # 真机事实
74
+ ```
75
+
76
+ 源码事实用 tag 固定,不要用浮动 master:
77
+
78
+ ```bash
79
+ cd D:/Code/deepseek-harness
80
+ git fetch origin tag dsh-v0.2.2-rc.1 --no-tags
81
+ git rev-parse dsh-v0.2.2-rc.1^{commit}
82
+ ```
83
+
84
+ ### 3.2 只 diff memu 用到的包
85
+
86
+ 先看规模,再读文件。测试目录的变更不算事实:
87
+
88
+ ```bash
89
+ git diff --stat dsh-v0.2.1-rc.5 dsh-v0.2.2-rc.1 -- \
90
+ 'packages/core/tools/src/**' 'packages/core/session/src/**' \
91
+ 'packages/core/agent/src/**' 'packages/core/agent-loop/src/**' \
92
+ 'packages/llm/llm/src/**' 'packages/session-query/session-query/src/**' \
93
+ 'packages/schedule/schedule/src/**' 'packages/subagent/subagent/src/**' \
94
+ 'packages/attachment/attachment/src/**' 'packages/host/webserver/src/**' \
95
+ 'packages/client/modules/src/**' 'packages/client/locale/src/**' \
96
+ 'packages/client/connection/src/**' 'packages/client/ui-settings/src/**' \
97
+ 'packages/client/ui-sidebar-right/src/**' 'packages/api/session-controller/src/client/**'
98
+ ```
99
+
100
+ 读的时候按「导出/契约/服务方法/事件 payload」四类看,不要逐行读实现。**跨 tag 往往只有 `package.json` 版本号变化**:`0.2.2-alpha.3 → 0.2.2-rc.1` 在 memu 用到的全部 `src` 上就是零改动(vendor 代码在 alpha.3 已定型)。
101
+
102
+ ### 3.3 四个装载门
103
+
104
+ 1. `engines.dsh` 与 peers 是否仍满足(不要改门禁)。
105
+ 2. `dsh.bundle.patch` 的 `insert` 行是否仍被解析(`--dump-config` 看得到 `dsh-memu-memory`)。
106
+ 3. `dsh.client` 是否仍进入启动图(页面里的 `window.__DSH_BOOT__` / `plugins/??…`)。
107
+ 4. 工具 DSL 是否仍接受 `lib/tools.js` 的 schema(真机 `request/header` 的工具名是最硬的证据)。
108
+
109
+ ### 3.4 服务 / 事件 / 字段
110
+
111
+ 按 §2 的表逐项问「这个名字还在吗、参数形状变了吗、返回值形状变了吗」。形状变化用**能力探测**处理:
112
+
113
+ - 首选「新方法存在与否」(如 `schedule.edit`);
114
+ - 其次「返回值是数组还是 `{items}`」;
115
+ - 最后才是「字段可选性」(`?.` + 默认值)。
116
+
117
+ 不要写 `if (version >= '0.2.2')`。版本号解析在 Node 半边也拿不到客户端宿主版本,客户端更拿不到。
118
+
119
+ ### 3.5 真机四件套
120
+
121
+ 1. `--dump-config`:确认插件行在组合里。
122
+ 2. 浏览器:页面能开、`style[data-dsh-memu-memory="ui"]` 在、设置页有「MemU 记忆」、右侧栏有「MemU 记忆」、新会话弹窗能关。
123
+ 3. 页面内 RPC:`fetch('/dsh-memu-memory/getSettingsState', …)` 返回 `{ok:true}`。
124
+ 4. Headless + mock LLM:跑一轮真实回合,断言 13 个工具 + guide 1 次 + `turn/end completed`。
125
+
126
+ 搭法见 §4。**四条都跑过才算「适配完成」**;只跑 `npm test` 不算(它用 fake 宿主)。
127
+
128
+ ### 3.6 记录
129
+
130
+ - `README.md` / `README.zh.md` 的兼容性表加「verified on …」。
131
+ - `docs/host-api.md` 更新对应小节;新发现的事实写进 §6.9。
132
+ - `CHANGELOG.md` 写清「验证了哪个构建、哪些面、哪些没测」。
133
+ - 本文件 §7 加一行。
134
+
135
+ ---
136
+
137
+ ## 4. 真机环境搭法(Windows)
138
+
139
+ ### 4.1 用 launcher 的安装,不要临时 npm 装
140
+
141
+ `<launcher>/versions/<v>/node_modules/@deepseek-ai/dsh/lib/bin.js` 是完整宿主。临时 `npm install @deepseek-ai/dsh` 会拖入可选 AWS SDK(几百个包、几分钟到几十分钟),还容易被文件锁打断(`ENOTEMPTY` 半装)。适配验证优先用 launcher 已装版本。
142
+
143
+ ### 4.2 隔离 home + 最小 profile
144
+
145
+ 不要碰 `~/.dsh` 的真实记忆库。用 launcher 的独立 home:
146
+
147
+ ```text
148
+ <launcher>/homes/0.2.2-rc.1/
149
+ profiles/memutest/ # 只放 dsh-memu-memory
150
+ profiles/memutest-headless/ # base + headless + memu,跑真实回合
151
+ ```
152
+
153
+ profile 的 `package.json` 只列 memu;`@deepseek-ai/dsh-base` / `dsh-web-app` 由宿主安装解析。把插件**复制**到 `profiles/<p>/node_modules/dsh-memu-memory`(不要 junction,Windows 权限与清理更麻烦;复制也避免测试时改到源码)。
154
+
155
+ ### 4.3 配一个本地假模型
156
+
157
+ `profiles/<p>/cordis.patch.yml`:
158
+
159
+ ```yaml
160
+ - id: llm-pi-ai
161
+ name: '@deepseek-ai/dsh-llm-pi-ai'
162
+ config:
163
+ providers:
164
+ memu-mock:
165
+ displayName: MemU Mock
166
+ api: openai-completions
167
+ baseURL: http://127.0.0.1:8090/v1
168
+ headers:
169
+ Authorization: Bearer local-mock
170
+ models:
171
+ - id: dsh-mock-llm
172
+ name: MemU Mock (eval only)
173
+ contextWindow: 128000
174
+ maxTokens: 4096
175
+ reasoningEfforts: false
176
+ - id: agent-default-model
177
+ config:
178
+ provider: memu-mock
179
+ model: dsh-mock-llm
180
+ ```
181
+
182
+ `- id/config` 是**整份替换**,不是合并;`provider`/`model` 必须写在 `config:` 下。非推理模型必须 `reasoningEfforts: false`,否则 `INVALID_CONFIG`(回合在发请求前中止,看起来像“没反应”)。
183
+
184
+ 启动假端点:
185
+
186
+ ```bash
187
+ node scripts/mock-llm.mjs --port 8090 --log ./mock.jsonl
188
+ ```
189
+
190
+ ### 4.4 Web 宿主与浏览器
191
+
192
+ ```bash
193
+ DSH_HOME="<launcher>/homes/0.2.2-rc.1" \
194
+ node "<launcher>/versions/0.2.2-rc.1/node_modules/@deepseek-ai/dsh/lib/bin.js" \
195
+ memutest --no-open --port 39430
196
+ ```
197
+
198
+ - stdout 只打印一行 `dsh web: http://…/?token=…`;用唯一日志文件接住,别让后续启动把它截断。
199
+ - `GET /?token=…` 返回 303 换会话 cookie;curl 要 `-L -c/-b`。
200
+ - 页面里的 `plugins/??<pkg>/client.js&rev=…` 是**组合 URL**;直接请求 `/plugins/<pkg>/client.js` 可能 404,属正常。
201
+ - Playwright 自带的浏览器版本可能与本机已装版本对不上(例如要 1248、只有 1194);用系统 Chrome:
202
+ `chromium.launch({ executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe' })`。
203
+ - 首次启动会叠三个弹窗:宿主「预览版说明」、宿主「开始使用 / 登录或 API Key」、本插件的新会话弹窗。断言前先按文本关掉;它们不是插件缺陷。
204
+ - 本插件的新会话弹窗是 `[data-dsh-memu-memory-gate]` 下的 `[role=dialog]`,出现是设计行为。
205
+
206
+ ### 4.5 读会话日志
207
+
208
+ 会话日志在 `<home>/sessions/<project>/<sessionId>/session.v4.jsonl.zstd`,是**多个 zstd frame 拼接**;Node 的 `zstdDecompressSync` 一次性调用只解第一帧。用 `scripts/drive-session.mjs` 里的 `scanZstdFrames` 逐帧解。
209
+
210
+ 断言的锚点:
211
+
212
+ - `request/header` → `data.header.tools` 的名字(数 `memu_*`);
213
+ - `user/message` → `source.kind === 'plugin:dsh-memu-memory'`、`source.form`、正文前缀 `<memory-guide` / `===== memory anchor =====`;
214
+ - `turn/end` → `data.reason.kind === 'completed'`。
215
+
216
+ ### 4.6 Headless 跑一轮
217
+
218
+ ```bash
219
+ DSH_HOME="<launcher>/homes/0.2.2-rc.1" \
220
+ node "<launcher>/versions/0.2.2-rc.1/node_modules/@deepseek-ai/dsh/lib/bin.js" \
221
+ memutest-headless --json "hello, please remember that my cat is named Mochi"
222
+ ```
223
+
224
+ headless 会禁用 `deepseek-account`;没有配假模型时会以 `MISSING_CREDENTIAL` 结束(不是插件问题)。
225
+
226
+ ---
227
+
228
+ ## 5. 0.2.2-rc.1 实测记录(2026-11-05)
229
+
230
+ 环境:launcher `versions/0.2.2-rc.1` + 独立 home;profile 只加 `dsh-memu-memory`;provider 为本地 `mock-llm`。
231
+
232
+ ### 5.1 页面 / RPC
233
+
234
+ - `GET /?token=…` 303 → 200,页面 40,428 bytes。
235
+ - 启动图:`{"id":"dsh-memu-memory", … "inject":[client-store, locale, connection, ui-settings, ui-sidebar-right], "immediately":true}`。
236
+ - 浏览器执行后:`style[data-dsh-memu-memory="ui"]` 存在;控制台 0 error、0 warning。
237
+ - 页面内 `fetch('/dsh-memu-memory/getSettingsState')` → 200 `{ok:true, value:{engine:…, memuConfig:…}}`。
238
+
239
+ ### 5.2 UI 入口
240
+
241
+ - 设置页:导航出现「MemU 记忆」。
242
+ - 右侧栏:出现「MemU 记忆 / 记忆库、注入与全局记忆」。
243
+ - 新会话弹窗:正常显示「这次对话要使用记忆吗?」并可关闭。
244
+
245
+ ### 5.3 一轮真实回合(headless + mock)
246
+
247
+ - 会话 `session-565ffa44-…`:21 个事件。
248
+ - `request/header`:`provider=memu-mock`、`model=dsh-mock-llm`、**36 个工具**,其中 13 个 `memu_*`:`memu_global_list`、`memu_global_recall`、`memu_lexicon_propose`、`memu_lexicon_search`、`memu_private_archive`、`memu_private_link`、`memu_private_link_suggest`、`memu_private_list`、`memu_private_recall`、`memu_private_remember`、`memu_private_unpin`、`memu_private_update`、`memu_status`。
249
+ - 插件消息:1 条 `source.kind='plugin:dsh-memu-memory'`、`form='recall'`,正文 `<memory-guide rules="…">`。
250
+ - `turn/end`:`completed`;无 error 事件。
251
+ - mock LLM 记录:首请求 `markers.guide=1`,其余块为 0(空库、默认设置)。
252
+
253
+ ### 5.4 没测的
254
+
255
+ - 桌面壳(Windows 标题栏、原生按钮区)——本插件不写 DOM app-region,但仍未在 0.2.2 桌面上跑过。
256
+ - 全局整理(`subagents.startActivation`)与历史会话 fork(`agents.create` + `followup`)只核对了类型/源码,没有在 0.2.2 真机上跑完一整次作业。
257
+ - 日期唤醒的**真实投递**没有等 5 分钟周期;只核对了 `ctx.schedule` 的 rc.1 类型与单测。
258
+ - 从 0.2.1 升级上来的旧库/旧 state.json:未在 0.2.2 上做迁移回归(数据格式未变,但不宣称已测)。
259
+
260
+ ---
261
+
262
+ ## 6. 已知陷阱与取舍
263
+
264
+ ### 6.1 `ctx.schedule` 两代 API
265
+
266
+ | 构建 | 方法形状 | 状态 |
267
+ |---|---|---|
268
+ | `0.2.2+` | `create(request)`、`list(request) -> {items}`、`edit({id, action:'delete'})` | memu 的日期唤醒使用这一代 |
269
+ | `0.2.0`–`0.2.1` | `create(sessionId, request)`、`list({sessionId}) -> 数组`、`delete({sessionId, id})` | 结构探测为 `session`,跳过并只 warn 一次 |
270
+
271
+ 识别用 `scheduleFlavor()`(`lib/salient-wake.js`):有 `edit` → `global`;否则有 `delete` → `session`。**不要**用版本号;宿主可能回移/改名服务。
272
+
273
+ 旧宿主上的行为是**有意降级**:返回 `{skipped:'schedule-api'}`,写一条 `stage:'schedule-api'` 的活动日志,被动注入仍然工作。不要为了“让旧宿主也能排程”去改 `create` 的参数形状——旧 API 的 `list` 必须逐会话调用,混用会把请求发给错误的目标。
274
+
275
+ ### 6.2 首启弹窗不是插件故障
276
+
277
+ 宿主会按本地状态弹「预览版说明」「开始使用」。它们都有全屏 mask,会拦截 Playwright 点击。先按文本点「继续」/关闭,再做断言。把这类环境弹窗误判成插件 bug 会浪费一整轮。
278
+
279
+ ### 6.3 zstd 只解第一帧
280
+
281
+ `zlib.zstdDecompressSync` 一次性调用只返回第一帧;会话日志是多帧拼接。用 `scanZstdFrames`(`scripts/drive-session.mjs`)逐帧解,否则会得到「21 个事件只看到 1 个」的假象。
282
+
283
+ ### 6.4 客户端启动图是组合 URL
284
+
285
+ 页面里的 `plugins/??pkg/client.js,@…&rev=…` 是组合请求;单个包的直链 404 不代表没加载。看 `window.__DSH_BOOT__` 或启动图 JSON。
286
+
287
+ ### 6.5 profile patch 的层级
288
+
289
+ `- id/config` 整份替换;`agent-default-model` 的 `provider`/`model` 在 `config` 下,不在条目顶层。写错层级不会报错,只会继续用默认 provider(然后 `MISSING_CREDENTIAL`)。
290
+
291
+ ### 6.6 临时 npm 安装的代价
292
+
293
+ `@deepseek-ai/dsh` 的可选依赖会拖入 AWS SDK;`--omit=optional` 也未必完全跳过。用 launcher 已装版本,省时且与用户一致。
294
+
295
+ ### 6.7 能力探测优先于版本判断
296
+
297
+ 本插件已有的例子:`scheduleFlavor()`、`sessionQuery.observeSession` 存在性、`betterSidebar` 存在性、`sidebarRight.mounted` / `uiSession.adapter.current` 的逐级回退。新差异优先补一条这样的探测,而不是引入 `semver`。
298
+
299
+ ---
300
+
301
+ ## 7. 版本记录
302
+
303
+ | 宿主构建 | 日期 | 结果 | 备注 |
304
+ |---|---|---|---|
305
+ | `0.2.1-rc.3` | 2026-10-27 | 文档基线 | 当时 `docs/host-api.md` §6.6 把 schedule 写成了宿主级;实际 `0.2.1` 是会话级,1.2.6 更正 |
306
+ | `0.2.2-alpha.3` | 2026-11-03 | 源码事实 | vendor / 工具 / schedule 新形状在这一版已定型 |
307
+ | `0.2.2-rc.1` | 2026-11-05 | **真机通过** | 13 工具、guide 1 次、设置页/侧栏/RPC/新会话弹窗;0 console error;schedule 新 API 形状核对 |
308
+
309
+ ---
310
+
311
+ ## 8. 维护本文件
312
+
313
+ 每适配一个新宿主:
314
+
315
+ 1. 在 §7 加一行,写清「真机通过 / 只读源码 / 没测」。
316
+ 2. 若新增了宿主能力探测,补一条单测(例如 `tests/salient-wake.test.mjs` 的 `scheduleFlavor`)。
317
+ 3. 若发现新的装载门或客户端契约,补进 §2 / §3。
318
+ 4. 若某个旧行为被证明是错的(如 §7 的 schedule 基线),直接改正文并在 CHANGELOG 里说明,不要留两套说法。
package/docs/host-api.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # 宿主事实与 API 速查 — dsh-memu-memory
2
2
 
3
- 2026-10-27 实测,DSH 0.2.1-rc.3。查的时候才翻。
3
+ 2026-10-27 实测,DSH 0.2.1-rc.3。2026-11-05 在 DSH 0.2.2-rc.1 上复核了核心面;版本适配流程见 `docs/host-adaptation.md`。
4
4
 
5
5
  > §6.3「取 sessionId 的三种形状」是排错高频项,放在 `docs/troubleshooting.md` 附录 D。
6
6
 
7
- ## 6. 宿主事实与 API 速查(2026-10-27 实测,DSH 0.2.1-rc.3)
7
+ ## 6. 宿主事实与 API 速查(2026-10-27 基线;2026-11-05 在 0.2.2-rc.1 复核)
8
8
 
9
9
 
10
10
  ### 6.1 DSH 没有 embedding 能力
@@ -39,9 +39,9 @@
39
39
 
40
40
  ### 6.6 定时器
41
41
 
42
- `ctx.schedule`(`@deepseek-ai/dsh-schedule`:create/list/catalog/history/delete/update,`every_seconds | daily | weekly | cron`,最小 60s)**绑定单个 sessionId、往该会话投递 prompt**、需要 sessionPersistence、且拒绝 subagent 会话——**不适合插件级全局清扫**。插件自己的清扫用 `ctx.interval`(cordis 随作用域回收),没有才退回 unref 的 `setInterval`。
42
+ `ctx.interval`(cordis 随作用域回收;没有才退回 unref 的 `setInterval`)是插件级周期清扫用的那一把。`ctx.schedule` 是**宿主任务表**,有两代 API,先探测再调用(`lib/salient-wake.js` 的 `scheduleFlavor()`)。
43
43
 
44
- **一次性到点任务(1.2.3 工单 E 用到的形状,2026-11-01 对照宿主源码核实):**
44
+ **0.2.2+ 宿主级任务表(日期唤醒使用这一代;2026-11-05 在 rc.1 核对)**
45
45
 
46
46
  ```js
47
47
  schedule.create({
@@ -55,11 +55,23 @@ schedule.edit({ id, action: 'delete' }) // 已结束的任务同样可以删
55
55
  ```
56
56
 
57
57
  - `ScheduleTiming` 另有 `after/at/every/daily/weekly/cron/rrule`;`at` 是 `AtInput = string | {date,time,time_zone}`,结构化形式三个字段都必填。
58
+ - 任务状态是 `active | paused | ended`;`paused` 是用户的显式暂停,不恢复。
58
59
  - 投递是 `agent.followup(...)`,**会新开一整回合**,冷会话由 `sessionController.resolveAgent` 自动 resume;`source.kind === 'schedule'`,所以本插件的注入管线(只认真实 `user` 消息)不会在那一回合跑召回——prompt 必须自带全部上下文。
59
- - `ctx.get('schedule')` 是**可选服务**:desktop 组合里有,别的宿主可能是 `undefined` 或抛错,必须 warn 后降级,不能让周期失败。
60
+ - `ctx.get('schedule')` 是**可选服务**:desktop / web 组合里有,别的宿主可能是 `undefined` 或抛错,必须 warn 后降级,不能让周期失败。
60
61
  - 投递是 at-least-once,receipt 只证明进了 inbox;任务持久化在宿主的 `storages/schedule.json`,用户在宿主 schedule UI 里看得见、也能手删。
61
62
  - subagent 会话被 `validateTarget` 拒绝(错误码 `subagent_session`),已归档会话是 `invalid_rule`。
62
63
 
64
+ **0.2.0–0.2.1 会话级提醒(日期唤醒不支持,探测后跳过)**
65
+
66
+ ```js
67
+ schedule.create(sessionId, { title, prompt, at: { ... } })
68
+ schedule.list({ sessionId }) // -> 数组
69
+ schedule.delete({ sessionId, id })
70
+ ```
71
+
72
+ - 任务绑定单个会话;没有 `edit`,状态只有 `active | inactive`。`scheduleFlavor()` 用「有没有 `edit`」区分两代:有 → `global`,否则有 `delete` → `session`。
73
+ - 旧宿主上 `runSalientWakePass()` 返回 `{ skipped: 'schedule-api' }`,写一条 `stage:'schedule-api'` 的活动日志并只 warn 一次;被动注入不受影响。**不要**把新 API 的 `{title,prompt,timing,target}` 直接喂给旧 API——旧 `list` 必须逐会话调用。
74
+
63
75
  事件:`ctx.on("agent/status", { agent, status })`,`AgentStatus = idle | running`;另有 `session/created`、`session/disposed`、`session/flush`;事件类型含 `turn/start`、`turn/end`(`step/*`、`user/message…`)与 `compaction/*`。**`turn/end` 不 await flush,不要在那里读存储;判 fork 成败只读事件对象本身。**
64
76
 
65
77
 
@@ -110,4 +122,16 @@ ctx.inject([sidebarRightTabs], ...) + ctx.slots.register({ name: sidebar.right.p
110
122
 
111
123
  复核方法:用 `zlib.zstdDecompressSync` 逐 frame 解压 `~/.dsh/sessions/<bucket>/<id>/session.v4.jsonl.zstd`;只统计 `request/header` 的工具名、`session.v4` 消息 id 和 `<memory-guide`/`===== memory anchor =====` 标签。不要打印会话正文,不要把同一消息在快照中的重复出现计成多次投放。
112
124
 
125
+ ### 6.9 宿主版本适配记录
126
+
127
+ 完整流程与真机命令见 `docs/host-adaptation.md`;这里只留结论。
128
+
129
+ | 宿主构建 | 日期 | 结论 |
130
+ |---|---|---|
131
+ | `0.2.1-rc.3` | 2026-10-27 | 本文档的基线事实;但 §6.6 当时的 schedule 形状实际属于 `0.2.2`,1.2.6 已更正 |
132
+ | `0.2.2-alpha.3` | 2026-11-03 | vendor(cordis 4.1 / timer 1.2 / include 1.1)与新 schedule API 在这一版定型 |
133
+ | `0.2.2-rc.1` | 2026-11-05 | 真机通过:13 个 `memu_*` 工具、guide 注入 1 次、设置页/侧栏/RPC/新会话弹窗、0 console error;alpha.3→rc.1 在 memu 用到的宿主 `src` 上零改动 |
134
+
135
+ 当前客户端启动图事实(0.2.2-rc.1 页面实测):`{"id":"dsh-memu-memory","inject":["@deepseek-ai/dsh-client-store","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-ui-sidebar-right"],"immediately":true}`;`inject` 里没有启动图行的包会被忽略,不是错误。
136
+
113
137
  ---