dsh-trivium 0.4.19 → 0.4.21

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
@@ -245,6 +245,10 @@ Off by default. After you turn **Chips (memory whitelist)** on in Settings, the
245
245
 
246
246
  ## Changelog
247
247
 
248
+ **0.4.21** — Host adaptation for `@deepseek-ai/dsh@0.2.x`. Session format v4 replaced the shared `kind: "plugin"` message source with producer-owned kinds: a third-party producer must write `kind: "plugin:dsh-trivium"` and drop the `plugin` field, or the whole turn fails with "format v4 message requires a producer-owned source kind". The plugin now picks the shape from the installed `dsh-llm` version, so 0.1.x keeps working. `agent/created` (0.1.6+) is handled next to `agent/session-start`, with a one-shot guard in case a host emits both. Peer range widened to `<0.3.0`. New `smoke-p14` pins both source shapes and the version switch. Four tools / short map / find paths unchanged.
249
+
250
+ **0.4.20** — Storage bump to `triviumdb@0.8.9`. The napi surface is unchanged (`triviumdb.d.ts` and `index.js` hash identically to 0.8.8), so this is a kernel-only update: SM-L2 is now the default QuIVer query path, FIND planning no longer materializes discarded candidates, and the server edition ships an attributed Web Console. All 14 offline smoke scripts pass unchanged. Four tools / short map / find paths unchanged.
251
+
248
252
  **0.4.19** — Fixed the plugin's own UI rendering Simplified Chinese on an English host ([issue #2](https://github.com/QWQcool/dsh-trivium/issues/2)). The `locale` service is now reached through `ctx.inject(["locale"], …)`, so **follow host** no longer depends on composition order, and the plugin fallback is `en` — the host's own `FALLBACK_LOCALE`, and the bucket every other resolved host language lands in. The Settings card and the Chips tab only ever choose between zh and en, so a browser naming no registered language no longer gets a Chinese card. Four tools / short map / find paths unchanged.
249
253
 
250
254
  **0.4.18** — `~/.dsh/trivium.json` is now written atomically (a truncated write used to reset every switch and chip pin silently) and is owner-only on POSIX. `npm test` runs every offline smoke script with isolated settings, and `smoke-p0` pins the hybrid text-index-after-reopen invariant. Four tools / short map / find paths unchanged.
@@ -308,7 +312,7 @@ Local source checkout: `npm install`, then `node scripts/link-dsh.mjs`, then res
308
312
  ## Release info
309
313
 
310
314
  - GitHub: https://github.com/QWQcool/dsh-trivium
311
- - npm: [`dsh-trivium@0.4.19`](https://www.npmjs.com/package/dsh-trivium)
315
+ - npm: [`dsh-trivium@0.4.21`](https://www.npmjs.com/package/dsh-trivium)
312
316
  - Tested host: `@deepseek-ai/dsh@0.1.5-rc.1` (also `0.1.1-rc.2` / `0.1.0-rc.8`)
313
317
  - License: MIT (depends on [TriviumDB](https://github.com/YoKONCy/TriviumDB), Apache-2.0)
314
318
 
package/README.zh-CN.md CHANGED
@@ -241,6 +241,10 @@ Trivium 是记忆内核,不是日记、日历或聊天伴侣。它按**节点
241
241
 
242
242
  ## 更新说明
243
243
 
244
+ **0.4.21** — 适配 `@deepseek-ai/dsh@0.2.x`。会话格式 v4 把共享的 `kind: "plugin"` 消息来源改成生产者自有的 kind:第三方生产者必须写 `kind: "plugin:dsh-trivium"` 且去掉 `plugin` 字段,否则整轮会以 "format v4 message requires a producer-owned source kind" 失败。插件按已安装的 `dsh-llm` 版本自动选择形状,0.1.x 仍走旧格式。新增对 `agent/created`(0.1.6+)的监听,与 `agent/session-start` 并存并做一次性去重。peer 范围放宽到 `<0.3.0`。新增 `smoke-p14` 钉住两种 source 形状与版本判定。四工具 / 短地图 / find 路径不变。
245
+
246
+ **0.4.20** — 存储升到 `triviumdb@0.8.9`。napi 接口零变更(`triviumdb.d.ts` 与 `index.js` 与 0.8.8 哈希完全一致),属纯内核升级:QuIVer 默认走 SM-L2 查询路径,FIND 规划不再物化被丢弃的候选,服务端版本带上带署名的 Web Console。14 个离线冒烟脚本原样通过。四工具 / 短地图 / find 路径不变。
247
+
244
248
  **0.4.19** — 修复插件自身界面在英文宿主上渲染成简体中文([issue #2](https://github.com/QWQcool/dsh-trivium/issues/2))。`locale` 服务改经 `ctx.inject(["locale"], …)` 获取,「跟随宿主」不再依赖插件组合顺序;兜底语言改为 `en`——与宿主自己的 `FALLBACK_LOCALE` 一致,也是其它已解析宿主语言的归宿。设置卡与芯片标签只在 zh / en 之间选择,浏览器未命名任何注册语言时不再给出中文卡。四工具 / 短地图 / find 路径不变。
245
249
 
246
250
  **0.4.18** — `~/.dsh/trivium.json` 改为原子写(此前写到一半被杀会让所有开关和芯片钉选静默回默认),POSIX 下权限收紧为仅属主可读。新增 `npm test` 聚合入口(每个脚本用独立临时设置文件),`smoke-p0` 新增「重开后 hybrid 文本索引仍可用」的断言。四工具 / 短地图 / find 路径行为不变。
@@ -304,7 +308,7 @@ Trivium 是记忆内核,不是日记、日历或聊天伴侣。它按**节点
304
308
  ## 发布信息
305
309
 
306
310
  - GitHub: https://github.com/QWQcool/dsh-trivium
307
- - npm: [`dsh-trivium@0.4.19`](https://www.npmjs.com/package/dsh-trivium)
311
+ - npm: [`dsh-trivium@0.4.21`](https://www.npmjs.com/package/dsh-trivium)
308
312
  - 测试宿主:`@deepseek-ai/dsh@0.1.5-rc.1`(兼 `0.1.1-rc.2` / `0.1.0-rc.8`)
309
313
  - License: MIT(依赖 [TriviumDB](https://github.com/YoKONCy/TriviumDB) 为 Apache-2.0)
310
314
 
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Host wire-format helpers, kept free of `@deepseek-ai/*` imports so the offline
3
+ * smoke suite can exercise them without a DSH install.
4
+ *
5
+ * Session format v4 (DSH 0.2.0+) replaced the shared `kind: "plugin"` message
6
+ * source with producer-owned kinds: a third-party producer is `plugin:<name>`
7
+ * and the `plugin` field is dropped. Writing the old shape into a v4 log fails
8
+ * the whole turn with "format v4 message requires a producer-owned source kind".
9
+ * 0.1.x only knows the old shape, so lib/index.js picks by host version.
10
+ */
11
+
12
+ /**
13
+ * Decide whether the host writes session format v4.
14
+ * @param version - `@deepseek-ai/dsh-llm` version, e.g. "0.1.5-rc.1" / "0.2.1-rc.2".
15
+ * @returns true for >= 0.2.0, and for an unreadable version (assume the current
16
+ * format rather than silently writing a shape the host rejects).
17
+ */
18
+ export function detectHostFormatV4(version) {
19
+ const v = String(version || "").trim();
20
+ if (!v) return true;
21
+ const [major, minor] = v.split(".").map((n) => parseInt(n, 10) || 0);
22
+ return major > 0 || minor >= 2;
23
+ }
24
+
25
+ /**
26
+ * Build the `source` for one plugin-authored message.
27
+ * @param hostFormatV4 - result of {@link detectHostFormatV4}.
28
+ * @param extra - additional source fields (form, sections, ...).
29
+ * @returns the source object the installed host accepts.
30
+ */
31
+ export function producerSourceFor(hostFormatV4, extra) {
32
+ return hostFormatV4
33
+ ? { kind: "plugin:dsh-trivium", ...extra }
34
+ : { kind: "plugin", plugin: "dsh-trivium", ...extra };
35
+ }
package/lib/index.js CHANGED
@@ -1,4 +1,6 @@
1
+ import { createRequire } from "node:module";
1
2
  import { BlockAssembler, createUserMessage } from "@deepseek-ai/dsh-llm";
3
+ import { detectHostFormatV4, producerSourceFor } from "./host-format.js";
2
4
  import { cwdOf, registerTools } from "./tools.js";
3
5
  import {
4
6
  buildShortMapReport,
@@ -29,6 +31,27 @@ import { syncSidecarOnOpen } from "./sidecar.js";
29
31
  export const name = "dsh-trivium";
30
32
  export const inject = ["tools"];
31
33
 
34
+ /*
35
+ * Session format v4 (DSH 0.2.0+) replaced the shared `kind: "plugin"` source
36
+ * with producer-owned kinds: a third-party producer is `plugin:<name>` and the
37
+ * `plugin` field is dropped. Writing the old shape into a v4 log fails the
38
+ * whole turn with "format v4 message requires a producer-owned source kind".
39
+ * 0.1.x only knows the old shape, so pick by host version.
40
+ */
41
+ function readHostLlmVersion() {
42
+ try {
43
+ return String(createRequire(import.meta.url)("@deepseek-ai/dsh-llm/package.json").version || "");
44
+ } catch {
45
+ return "";
46
+ }
47
+ }
48
+
49
+ export const HOST_FORMAT_V4 = detectHostFormatV4(readHostLlmVersion());
50
+
51
+ export function producerSource(extra) {
52
+ return producerSourceFor(HOST_FORMAT_V4, extra);
53
+ }
54
+
32
55
  const DEFAULTS = {
33
56
  autoRecall: false,
34
57
  anchorRecall: false,
@@ -127,7 +150,7 @@ function makeLlmCall(ctx, session, agent) {
127
150
  messages: [
128
151
  createUserMessage({
129
152
  content: [{ type: "text", text: prompt }],
130
- source: { kind: "plugin", plugin: "dsh-trivium" },
153
+ source: producerSource(),
131
154
  }),
132
155
  ],
133
156
  };
@@ -253,12 +276,10 @@ function injectShortMap(agent, db, budget) {
253
276
  agent.inject(
254
277
  createUserMessage({
255
278
  content: [{ type: "text", text: map.text }],
256
- source: {
257
- kind: "plugin",
258
- plugin: "dsh-trivium",
279
+ source: producerSource({
259
280
  form: "snapshot",
260
281
  sections: [{ name: "dsh-trivium", text: map.text }],
261
- },
282
+ }),
262
283
  }),
263
284
  );
264
285
  return map;
@@ -294,7 +315,19 @@ export function apply(ctx, config = {}) {
294
315
 
295
316
  registerTools(ctx, optionsOf);
296
317
 
297
- ctx.on("agent/session-start", async ({ agent }) => {
318
+ /*
319
+ * DSH 0.1.6 replaced the serial `agent/session-start` event with
320
+ * `agent/created` (payload `{ agent, source, signal? }`). 0.1.5 and older
321
+ * only emit session-start, and a host never emits both, but the started set
322
+ * keeps the four one-shot steps below from running twice if that changes.
323
+ */
324
+ const started = new Set();
325
+ const onAgentStart = async ({ agent }) => {
326
+ const startId = sessionKey(agent?.session);
327
+ if (startId) {
328
+ if (started.has(startId)) return;
329
+ started.add(startId);
330
+ }
298
331
  try {
299
332
  const ready = await ensureShortMap(agent, optionsOf());
300
333
  const cwd = ready?.cwd || cwdOf(agent);
@@ -340,7 +373,10 @@ export function apply(ctx, config = {}) {
340
373
  } catch (err) {
341
374
  log.warn?.(`[dsh-trivium] session-start skipped: ${err.message}`);
342
375
  }
343
- });
376
+ };
377
+
378
+ ctx.on("agent/created", onAgentStart);
379
+ ctx.on("agent/session-start", onAgentStart);
344
380
 
345
381
  ctx.on("session/event", (session, event) => {
346
382
  try {
@@ -457,10 +493,7 @@ export function apply(ctx, config = {}) {
457
493
  // No `form`: "pins" was never in DSH's ContextForm union, so the
458
494
  // client already rendered it as undeclared (opaque) context.
459
495
  // Omitting the field is the documented default for that.
460
- source: {
461
- kind: "plugin",
462
- plugin: "dsh-trivium",
463
- },
496
+ source: producerSource(),
464
497
  }),
465
498
  );
466
499
  }
@@ -498,11 +531,7 @@ export function apply(ctx, config = {}) {
498
531
  extra.push(
499
532
  createUserMessage({
500
533
  content: [{ type: "text", text }],
501
- source: {
502
- kind: "plugin",
503
- plugin: "dsh-trivium",
504
- form: "recall",
505
- },
534
+ source: producerSource({ form: "recall" }),
506
535
  }),
507
536
  );
508
537
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-trivium",
3
- "version": "0.4.19",
3
+ "version": "0.4.21",
4
4
  "description": "In-process graph memory for DeepSeek Harness, backed by TriviumDB.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -47,6 +47,7 @@
47
47
  "smoke-p11": "node scripts/smoke-p11.mjs",
48
48
  "smoke-p12": "node scripts/smoke-p12.mjs",
49
49
  "smoke-p13": "node scripts/smoke-p13.mjs",
50
+ "smoke-p14": "node scripts/smoke-p14.mjs",
50
51
  "preuninstall": "node ./lib/purge.js",
51
52
  "verify-live-p2": "node scripts/verify-live-p2.mjs"
52
53
  },
@@ -54,11 +55,11 @@
54
55
  "node": "^22.19.0 || >=24"
55
56
  },
56
57
  "peerDependencies": {
57
- "@deepseek-ai/dsh-llm": ">=0.1.0-rc.8 <0.1.1 || >=0.1.1-rc.2 <0.2.0",
58
- "@deepseek-ai/dsh-tools": ">=0.1.0-rc.8 <0.1.1 || >=0.1.1-rc.2 <0.2.0"
58
+ "@deepseek-ai/dsh-llm": ">=0.1.0-rc.8 <0.1.1 || >=0.1.1-rc.2 <0.3.0",
59
+ "@deepseek-ai/dsh-tools": ">=0.1.0-rc.8 <0.1.1 || >=0.1.1-rc.2 <0.3.0"
59
60
  },
60
61
  "dependencies": {
61
- "triviumdb": "^0.8.8"
62
+ "triviumdb": "^0.8.9"
62
63
  },
63
64
  "keywords": [
64
65
  "dsh-plugin",