dsh-hypatia-auto-memory 0.4.0 → 0.5.0

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/README.md CHANGED
@@ -43,7 +43,8 @@ dsh plugin --profile web add dsh-hypatia-auto-memory
43
43
 
44
44
  Repeat for other profiles (desktop, dsh-tui). Restart the profile after install.
45
45
 
46
- The browser settings card is pre-built in `lib/client.js` and shipped with the
46
+ The browser half — the settings card and the conversation's Memory tab — is
47
+ pre-built in `lib/client.js` and shipped with the
47
48
  package. If you edit `src/client/*`, run `npm install && npm run build` in this
48
49
  directory to regenerate it; while `pnpm run dev:web` is active in the DSH
49
50
  checkout, client-plugin changes reload without a full page refresh.
@@ -253,6 +254,49 @@ agent/session-start ──▶ rules/taboos inject()
253
254
  in agent sessions — presets load disk skills in a nearer layer — so it is
254
255
  reported with its directory.
255
256
 
257
+ - **The conversation's Memory tab** is the read face of everything above. It sits
258
+ beside the **Chat** and **Trajectory** tabs (a `conversation.view` entry with
259
+ id `memory`, ordered after Trajectory) and shows, for the session it is bound
260
+ to, three things. **Status**: the logging and consolidation watermarks, the
261
+ pending token backlog, whether the `session-<id>` node exists, and any task
262
+ that exhausted its attempts together with the error that stopped it.
263
+ **Span summaries**: the `sum-<session>-<from>-<to>` entries consolidation
264
+ produced, with their archive tier. **Work units**: the `wu-*` entries derived
265
+ from those summaries, reached through the `derivedFrom` edges — their names are
266
+ content-addressed, so the edge is the only way to find them. Bodies render
267
+ through the shell's own `MarkdownText`, so a summary reads like assistant
268
+ Markdown elsewhere in the GUI.
269
+
270
+ Raw `msg-*` entries are deliberately **not** shown: they hold the conversation
271
+ verbatim, the reader just wrote them, and the agent is the right reader for
272
+ them.
273
+
274
+ The data arrives over a session-scoped, read-only HTTP route this plugin
275
+ registers on the DSH web server, `/api/dsh-hypatia-auto-memory/session`: status
276
+ from the in-memory state tables on every poll, the shelf content only when it
277
+ can have changed (on open, on a session switch, on a manual refresh, and when
278
+ consolidation advances the session's watermark), cached for 15 s in between.
279
+ Two channels were rejected on the way here. A **session projection** would be
280
+ the best shape, but the event that would drive it cannot be written from
281
+ outside this repository: `Session.append` offers no way to set the envelope's
282
+ `ignorable` marker, and the persistence read path refuses a session log
283
+ carrying an unknown event type without it — so a custom event would break
284
+ session reload. A **settings namespace** can be written safely but is
285
+ root-scoped: the Host cannot know which session the browser is showing, so it
286
+ would have to ship every session's data, and publishing means disposing and
287
+ re-creating the owning fiber, because `settings.register` refuses a duplicate
288
+ namespace and has no way to update a registered `base`.
289
+
290
+ The route is not one of the composed app's authenticated routes — a route a
291
+ plugin registers never is — so it authenticates itself the way
292
+ `dsh-hypatia-ui`'s does: the socket must be loopback, the `Host` must be a
293
+ loopback name (`localhost`, `127.x`, `[::1]`), and the request same-origin. A
294
+ browser tab on this page passes all three; a page on another origin fails the
295
+ last even from the same machine, and a DNS-rebound page fails the `Host` check.
296
+ `~/.dsh/storages/hypatia_auto_memory.json` and
297
+ `hypatia_auto_memory_diag.json` remain the durable record; the tab is a view of
298
+ the same facts, not a replacement for them.
299
+
256
300
  ## Configuration
257
301
 
258
302
  Settings namespace `hypatia-auto-memory` (edit `settings.yaml` or Web
@@ -350,9 +394,13 @@ changes. No card claims it, so it renders nowhere; nothing ever writes to it.
350
394
  ## Operations checklist
351
395
 
352
396
  1. After a turn ends, entries appear within seconds:
353
- `hypatia knowledge-get msg-<sessionId>-<n>` (`n` counts messages, from 0)
397
+ `hypatia knowledge-get msg-<sessionId>-<n>` (`n` counts messages, from 0).
398
+ The conversation's **Memory** tab answers the same question without a CLI,
399
+ and adds what the CLI cannot show: the watermarks themselves.
354
400
  2. Watermarks live in the state domain; failed tasks stay in the `tasks`
355
- table with their last error for inspection.
401
+ table with their last error for inspection. Both are what the Memory tab
402
+ reads; refresh it after changing the shelf, since the tab's snapshot is
403
+ keyed to the shelf this run is writing to.
356
404
  3. Restart mid-write is safe: messages already stored are skipped
357
405
  (get-before-create); uncovered ranges are re-enqueued from watermarks.
358
406
  4. To check the route warning: consolidation with no selected `models`
@@ -499,7 +547,7 @@ dsh-hypatia-auto-memory/
499
547
  │ ├── auto-approve.js # approves the agent's own plain bash hypatia calls
500
548
  │ ├── skills.js # bundled skill registration (never shadows another provider)
501
549
  │ ├── status.js # counters + structured logging
502
- │ └── client/ # browser settings card
550
+ │ └── client/ # settings card + Memory tab
503
551
  │ ├── index.tsx # client plugin entry + slot registration
504
552
  │ ├── SettingsCard.tsx
505
553
  │ ├── shelves.ts # shelf dropdown choices from the inventory namespace
package/README.zh-CN.md CHANGED
@@ -38,9 +38,10 @@ dsh plugin --profile web add dsh-hypatia-auto-memory
38
38
 
39
39
  对其它 profile(desktop、dsh-tui)重复以上步骤。安装后重启 profile。
40
40
 
41
- 浏览器设置卡片预构建在 `lib/client.js` 中,随包发布。如果你改了 `src/client/*`,
42
- 在本目录运行 `npm install && npm run build` 重新生成它;当 DSH checkout 里
43
- `pnpm run dev:web` 处于运行状态时,client-plugin 的改动无需整页刷新即可热更新。
41
+ 浏览器半——设置卡片与会话里的记忆标签页——预构建在 `lib/client.js` 中,随包发布。如果
42
+ 你改了 `src/client/*`,在本目录运行 `npm install && npm run build` 重新生成它;当 DSH
43
+ checkout 里 `pnpm run dev:web` 处于运行状态时,client-plugin 的改动无需整页刷新即可
44
+ 热更新。
44
45
 
45
46
  **替换 `dsh-hypatia`:** 把它从 profile 移除并重启。
46
47
 
@@ -199,6 +200,36 @@ agent/session-start ──▶ rules/taboos inject()
199
200
  登记上去但在 Agent 会话里仍胜出——预设会在更近的一层加载磁盘技能——所以会连同目录
200
201
  一起报告。
201
202
 
203
+ - **会话里的「记忆」标签页**是上述一切的读取面。它和 **对话**、**轨迹** 并排(一个
204
+ `conversation.view` 注册项,id 为 `memory`,排序在轨迹之后),对当前会话显示三块
205
+ 内容。**状态**:记录水位、整合水位、待整合 token、`session-<id>` 节点是否存在,以及
206
+ 用尽重试次数的任务和拦住它的那条错误。**跨度摘要**:整合产出的
207
+ `sum-<session>-<from>-<to>` 条目及其归档层级。**工作单元**:由这些摘要派生的 `wu-*`
208
+ 条目——它们通过 `derivedFrom` 边找到,因为名字是内容寻址的,不携带会话信息。正文用
209
+ 外壳自带的 `MarkdownText` 渲染,所以摘要读起来和 GUI 里其它地方的助手 Markdown
210
+ 一致。
211
+
212
+ 原始 `msg-*` 条目**故意不显示**:它是对话原文,读的人刚刚写过,而正确的读者是
213
+ Agent。
214
+
215
+ 数据经由本插件注册在 DSH web 服务器上的、会话作用域的只读 HTTP 路由
216
+ `/api/dsh-hypatia-auto-memory/session` 到达浏览器:状态每次轮询都从内存中的状态表
217
+ 现算,shelf 内容只在可能变化时才读(打开时、切换会话时、手动刷新时,以及整合推进了
218
+ 该会话水位时),其间缓存 15 秒。路上否掉了两条通道。**session projection** 形态最
219
+ 合适,但驱动它的事件在本仓库之外写不出来:`Session.append` 没有任何途径设置信封的
220
+ `ignorable` 标记,而持久化读取路径会拒绝一个带着未知事件类型、又没有该标记的会话
221
+ 日志——所以自定义事件会破坏会话重载。**设置命名空间**能安全写入,但它是根作用域的:
222
+ 宿主无法知道浏览器正在看哪个会话,只能把每个会话的数据都发出去;而且发布意味着销毁
223
+ 并重建持有它的 fiber,因为 `settings.register` 拒绝重名命名空间,也没有任何途径更新
224
+ 已注册的 `base`。
225
+
226
+ 这条路由不属于组合应用自己那批已鉴权的路由——插件注册的路由从来都不是——所以它像
227
+ `dsh-hypatia-ui` 那样自鉴权:socket 必须是回环,`Host` 必须是回环名(`localhost`、
228
+ `127.x`、`[::1]`),请求必须同源。本页面里的浏览器标签三条都满足;另一来源的页面
229
+ 即便同机也会在最后一条上失败,DNS 重绑定的页面会在 `Host` 检查上失败。
230
+ `~/.dsh/storages/hypatia_auto_memory.json` 和 `hypatia_auto_memory_diag.json` 仍是
231
+ 持久记录;标签页是同一批事实的视图,不是它们的替代品。
232
+
202
233
  ## 配置
203
234
 
204
235
  设置命名空间 `hypatia-auto-memory`(编辑 `settings.yaml` 或 Web 设置;所有字段可选,
@@ -287,8 +318,12 @@ rules/taboos 预载、启动清理。设置卡片把它做成 `hypatia list` 所
287
318
  ## 运维清单
288
319
 
289
320
  1. 一个 turn 结束后,条目在几秒内出现:
290
- `hypatia knowledge-get msg-<sessionId>-<n>`(`n` 从 0 开始数消息)
291
- 2. 水位在 state domain 里;失败的任务连同最后一次错误留在 `tasks` 表里供检查。
321
+ `hypatia knowledge-get msg-<sessionId>-<n>`(`n` 从 0 开始数消息)。
322
+ 会话里的**记忆**标签页不用敲 CLI 就能回答同一个问题,并且能给出 CLI 看不到的东西:
323
+ 水位本身。
324
+ 2. 水位在 state domain 里;失败的任务连同最后一次错误留在 `tasks` 表里供检查。这两者
325
+ 就是记忆标签页读的内容;换过 shelf 后要刷新它,因为它读的快照对应本次运行正在写入
326
+ 的那个 shelf。
292
327
  3. 写入中途重启是安全的:已存储的消息被跳过(get-before-create);未覆盖的范围从
293
328
  水位重新排队。
294
329
  4. 检查路由告警:没选 `models` 的巩固只记录一次告警,其余时间静默。
@@ -408,7 +443,7 @@ dsh-hypatia-auto-memory/
408
443
  │ ├── auto-approve.js # 批准 Agent 自己的纯 bash hypatia 调用
409
444
  │ ├── skills.js # 随包技能注册(从不遮蔽其它提供者)
410
445
  │ ├── status.js # 计数器 + 结构化日志
411
- │ └── client/ # 浏览器设置卡片
446
+ │ └── client/ # 设置卡片 + 记忆标签页
412
447
  │ ├── index.tsx # client 插件入口 + slot 注册
413
448
  │ ├── SettingsCard.tsx
414
449
  │ ├── shelves.ts # 来自清单命名空间的 shelf 下拉选项