@modusensus/dsh-mneme 0.7.31 → 0.8.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.
Files changed (93) hide show
  1. package/README.md +65 -27
  2. package/lib/api.js +139 -6
  3. package/lib/client.js +369 -32
  4. package/lib/commands.js +36 -5
  5. package/lib/config.js +101 -14
  6. package/lib/dream/decisions.js +147 -14
  7. package/lib/dream/sleep.js +84 -34
  8. package/lib/dream.js +250 -60
  9. package/lib/embedding.js +22 -2
  10. package/lib/index.js +68 -37
  11. package/lib/inject.js +54 -13
  12. package/lib/lang.js +168 -0
  13. package/lib/local-embedder.js +23 -9
  14. package/lib/mirror.js +17 -14
  15. package/lib/reranker.js +23 -8
  16. package/lib/runtime/adopt.js +176 -0
  17. package/lib/runtime/closure.js +172 -0
  18. package/lib/runtime/download.js +247 -0
  19. package/lib/runtime/layout.js +235 -0
  20. package/lib/runtime/loader.js +249 -0
  21. package/lib/runtime/provision.js +237 -0
  22. package/lib/runtime/tarball.js +130 -0
  23. package/lib/runtime/verify.js +191 -0
  24. package/lib/scope.js +83 -0
  25. package/lib/service.js +374 -55
  26. package/lib/settings.js +43 -2
  27. package/lib/store.js +126 -13
  28. package/lib/summarize.js +108 -35
  29. package/lib/tools.js +205 -12
  30. package/package.json +7 -2
  31. package/runtime-manifest.json +596 -0
  32. package/scripts/build-runtime-manifest.mjs +217 -0
  33. package/scripts/mneme-runtime.mjs +277 -0
  34. package/src/api.js +139 -6
  35. package/src/commands.js +36 -5
  36. package/src/config.js +101 -14
  37. package/src/dream/decisions.js +147 -14
  38. package/src/dream/sleep.js +84 -34
  39. package/src/dream.js +250 -60
  40. package/src/embedding.js +22 -2
  41. package/src/index.js +68 -37
  42. package/src/inject.js +54 -13
  43. package/src/lang.js +168 -0
  44. package/src/local-embedder.js +23 -9
  45. package/src/mirror.js +17 -14
  46. package/src/reranker.js +23 -8
  47. package/src/runtime/adopt.js +176 -0
  48. package/src/runtime/closure.js +172 -0
  49. package/src/runtime/download.js +247 -0
  50. package/src/runtime/layout.js +235 -0
  51. package/src/runtime/loader.js +249 -0
  52. package/src/runtime/provision.js +237 -0
  53. package/src/runtime/tarball.js +130 -0
  54. package/src/runtime/verify.js +191 -0
  55. package/src/scope.js +83 -0
  56. package/src/service.js +374 -55
  57. package/src/settings.js +43 -2
  58. package/src/store.js +126 -13
  59. package/src/summarize.js +108 -35
  60. package/src/tools.js +205 -12
  61. package/test/api.test.js +175 -9
  62. package/test/client.test.js +152 -10
  63. package/test/commands.test.js +40 -3
  64. package/test/config.test.js +17 -1
  65. package/test/dream-candidate-hybrid.test.js +281 -0
  66. package/test/dream.test.js +172 -0
  67. package/test/embedding-ready.test.js +196 -0
  68. package/test/helpers/runtime-source.js +60 -0
  69. package/test/helpers/tar-builder.js +80 -0
  70. package/test/inject.test.js +130 -1
  71. package/test/lang.test.js +87 -0
  72. package/test/quality-filter.test.js +68 -0
  73. package/test/reasoning-effort.test.js +106 -15
  74. package/test/reindex-backfill.test.js +62 -0
  75. package/test/runtime-adopt.test.js +206 -0
  76. package/test/runtime-cli.test.js +89 -0
  77. package/test/runtime-closure.test.js +193 -0
  78. package/test/runtime-download.test.js +302 -0
  79. package/test/runtime-layout.test.js +163 -0
  80. package/test/runtime-loader.test.js +237 -0
  81. package/test/runtime-manifest.test.js +158 -0
  82. package/test/runtime-provision.test.js +101 -0
  83. package/test/runtime-tarball.test.js +82 -0
  84. package/test/runtime-verify.test.js +214 -0
  85. package/test/scope-retrieval.test.js +197 -0
  86. package/test/scope-storage.test.js +247 -0
  87. package/test/scope-strict.test.js +165 -0
  88. package/test/service.test.js +76 -0
  89. package/test/sleep-action-set.test.js +422 -0
  90. package/test/store.test.js +14 -0
  91. package/test/summarize.test.js +224 -0
  92. package/test/tools.test.js +30 -5
  93. package/test/webServer-optional.test.js +34 -1
package/lib/tools.js CHANGED
@@ -1,4 +1,10 @@
1
1
  import { defineTool } from "@deepseek-ai/dsh-tools";
2
+ import { createScopeResolver } from "./scope.js";
3
+ import { describeLocalRuntime, resolveRuntimeEntry } from "./runtime/loader.js";
4
+ import { defaultRuntimeDir } from "./runtime/layout.js";
5
+ import { hostModulesDir, loadRuntimeManifest, provisionRuntime } from "./runtime/provision.js";
6
+ import { matchesPlatform } from "./runtime/closure.js";
7
+ import { verifyPayload } from "./runtime/verify.js";
2
8
 
3
9
  const TEXT_OUTPUT = (text) => [{ type: "text", text }];
4
10
  // Per-registry tool-name registry: guards against duplicate registration on
@@ -20,11 +26,44 @@ const MEMORY_ITEM_SCHEMA = {
20
26
  tags: { type: "array", items: { type: "string" } },
21
27
  importance: { type: "integer", required: true },
22
28
  source: { type: "string" },
29
+ // v0.8.0 A2:scope 标注与事件发生时间随行透出(未标注时缺省,可选属性)。
30
+ agent_scope: { type: "string" },
31
+ workspace_scope: { type: "string" },
32
+ sensitivity: { type: "string" },
33
+ occurred_at: { type: "string" },
23
34
  created_at: { type: "string", required: true },
24
35
  updated_at: { type: "string", required: true }
25
36
  }
26
37
  };
27
38
 
39
+ // v0.8.0 A2:occurred 时间窗参数 → store 过滤选项(list/count 同口径);
40
+ // 未传参返回空对象,既有调用方不受影响。(A3 复核:此处入参仅含 occurred 边界。)
41
+ function occurredWindow(args) {
42
+ const from = args?.occurred_from ?? null;
43
+ const to = args?.occurred_to ?? null;
44
+ return from !== null || to !== null ? { occurredFrom: from, occurredTo: to } : {};
45
+ }
46
+
47
+ // v0.8.0 A3:strictScope 硬过滤的 visibility 选项(store.list/count 同口径)。
48
+ // flag 关或会话 scope 未解析出(flag 关时解析器返回 null)→ 空对象不过滤;
49
+ // scope 为 {null,null}(匿名会话)时照传——store 侧 fail-closed 只放行未标注行。
50
+ function strictVisibility(config, scope) {
51
+ if (config?.strictScope !== true || !scope) return {};
52
+ return { visibility: { agentScope: scope.agent_scope, workspaceScope: scope.workspace_scope } };
53
+ }
54
+
55
+ // v0.8.0 A2:检索结果的 provenance 附加段——只在有标注时出现,未标注行渲染
56
+ // 与 A2 前逐字节一致。
57
+ const MEMORY_PROVENANCE = (m) => {
58
+ const parts = [];
59
+ if (m.occurred_at) parts.push(`occurred: ${m.occurred_at}`);
60
+ if (m.agent_scope || m.workspace_scope) {
61
+ parts.push(`scope: ${m.agent_scope ?? "global"} / ${m.workspace_scope ?? "global"}`);
62
+ }
63
+ if (m.sensitivity) parts.push(`sensitivity: ${m.sensitivity}`);
64
+ return parts.length ? ` | ${parts.join(" | ")}` : "";
65
+ };
66
+
28
67
  export function createTools(ctx, service, config, embedder) {
29
68
  const toolsRegistry = ctx.tools;
30
69
  let registeredTools = REGISTERED_TOOLS.get(toolsRegistry);
@@ -32,6 +71,10 @@ export function createTools(ctx, service, config, embedder) {
32
71
  registeredTools = new Set();
33
72
  REGISTERED_TOOLS.set(toolsRegistry, registeredTools);
34
73
  }
74
+ // v0.8.0 A1/A2(issue #17):会话 scope 解析(agentPreset + workspace 反查)。
75
+ // flag 关闭时恒返回 null——写入不标注,检索不加权,行为与 A1 前完全一致。
76
+ // logger 透传:registry 反查失败时 warnOnce 才有出口(否则静默降级无观测)。
77
+ const resolveSessionScope = createScopeResolver({ ctx, config, logger: ctx.logger });
35
78
  const tools = [
36
79
  defineTool({
37
80
  name: "memory_save",
@@ -45,7 +88,9 @@ export function createTools(ctx, service, config, embedder) {
45
88
  content: { type: "string", required: true, description: "Memory body" },
46
89
  tags: { type: "array", items: { type: "string" }, description: "Optional tags" },
47
90
  importance: { type: "integer", description: "1-5; >= threshold auto-injects into future sessions" },
48
- source: { type: "string", description: "Optional provenance" }
91
+ source: { type: "string", description: "Optional provenance" },
92
+ sensitivity: { type: "string", description: "Optional sensitivity label (free-form, e.g. personal). Same-title entries with different sensitivity stay separate instead of merging." },
93
+ occurred_at: { type: "string", description: "Optional ISO-8601 instant the remembered event happened (differs from write time). Invalid values are ignored." }
49
94
  },
50
95
  output: {
51
96
  schema: {
@@ -58,14 +103,21 @@ export function createTools(ctx, service, config, embedder) {
58
103
  },
59
104
  render: (_args, value) => TEXT_OUTPUT(`memory ${value.action}: ${value.id}`)
60
105
  },
61
- async execute(args) {
106
+ async execute(args, exec) {
107
+ // scope 标注:agent_scope/workspace_scope 由会话身份解析(不作为模型
108
+ // 参数),sensitivity/occurred_at 来自显式参数。解析绝不抛错、取不到
109
+ // 落 NULL;flag 关闭时 scope 为 null,一个字段都不标注。
110
+ const scope = resolveSessionScope(exec);
62
111
  const { action, memory } = service.saveWithDedupe({
63
112
  type: args.type,
64
113
  title: args.title,
65
114
  content: args.content,
66
115
  tags: args.tags ?? [],
67
116
  importance: args.importance ?? 3,
68
- source: args.source ?? "tool"
117
+ source: args.source ?? "tool",
118
+ ...(scope ? { agent_scope: scope.agent_scope, workspace_scope: scope.workspace_scope } : {}),
119
+ ...(args.sensitivity !== undefined ? { sensitivity: args.sensitivity } : {}),
120
+ ...(args.occurred_at !== undefined ? { occurred_at: args.occurred_at } : {})
69
121
  });
70
122
  return { action, id: memory.id };
71
123
  }
@@ -74,12 +126,15 @@ export function createTools(ctx, service, config, embedder) {
74
126
  defineTool({
75
127
  name: "memory_search",
76
128
  description: "Search the cross-session memory store. Use when you need past context: how a problem was solved, user preferences, project decisions. Substring-matches title/content/tags, and augments results with semantic (vector) recall + optional rerank when an embeddings provider is configured. Returns matching entries with source and timestamps.",
129
+ // A2 检索接线:occurred 时间窗 + 会话 scope 加成(见 execute)。
77
130
  parameters: {
78
131
  query: { type: "string", required: true, description: "Search text; substring match over title/content/tags" },
79
132
  limit: { type: "integer", description: "Max results (default 20)" },
80
133
  mode: { type: "string", enum: ["auto", "keyword", "vector", "hybrid"], description: "auto (default) = keyword hits first + vector fill when enabled; keyword = text only; vector = semantic recall first (falls back to keyword); hybrid = vector leads, keyword fills remaining slots" },
81
134
  semantic: { type: "boolean", description: "Shorthand: enable semantic (vector) recall (same as mode=vector when true)" },
82
- rerank: { type: "boolean", description: "Run cross-encoder rerank over candidates when a local reranker is configured (default true)" }
135
+ rerank: { type: "boolean", description: "Run cross-encoder rerank over candidates when a local reranker is configured (default true)" },
136
+ occurred_from: { type: "string", description: "Optional ISO date/timestamp lower bound on when the remembered event happened (occurred_at, falling back to created_at). Date-only values are inclusive from that day's 00:00Z." },
137
+ occurred_to: { type: "string", description: "Optional ISO date/timestamp upper bound on occurred_at. Date-only values are inclusive through that day's 23:59:59.999Z." }
83
138
  },
84
139
  output: {
85
140
  schema: {
@@ -99,19 +154,26 @@ export function createTools(ctx, service, config, embedder) {
99
154
  .map((m, i) => {
100
155
  const preview = (m.content ?? "").replace(/\s+/g, " ").trim();
101
156
  const cut = preview.length > 200 ? `${preview.slice(0, 200)}…` : preview;
102
- return `[${i + 1}] ${m.title}\n ID: ${m.id} | type: ${m.type} | importance: ${m.importance} | updated: ${m.updated_at}\n ${cut}`;
157
+ return `[${i + 1}] ${m.title}\n ID: ${m.id} | type: ${m.type} | importance: ${m.importance} | updated: ${m.updated_at}${MEMORY_PROVENANCE(m)}\n ${cut}`;
103
158
  })
104
159
  .join("\n\n");
105
160
  return TEXT_OUTPUT(`Found ${items.length} memory entr${items.length === 1 ? "y" : "ies"}:\n\n${body}`);
106
161
  }
107
162
  },
108
- async execute(args) {
163
+ async execute(args, exec) {
109
164
  const limit = args.limit ?? 20;
110
165
  const mode = args.semantic === true && !args.mode ? "vector" : args.mode ?? "auto";
166
+ // v0.8.0 A2(issue #17):scope 检索加权 + occurred 时间窗的检索接线。
167
+ // flag 关闭或解析不出 scope 时为 null,检索行为与 A2 前一致。
168
+ const scope = resolveSessionScope(exec);
169
+ const occurredFrom = args.occurred_from ?? null;
170
+ const occurredTo = args.occurred_to ?? null;
111
171
  const rows = await service.searchMemories(args.query, {
112
172
  mode,
113
173
  topK: limit,
114
- useRerank: args.rerank !== false
174
+ useRerank: args.rerank !== false,
175
+ ...(scope ? { scope } : {}),
176
+ ...(occurredFrom !== null || occurredTo !== null ? { occurredFrom, occurredTo } : {})
115
177
  });
116
178
  return { items: service.toApiList(rows) };
117
179
  }
@@ -124,7 +186,9 @@ export function createTools(ctx, service, config, embedder) {
124
186
  type: { type: "string", enum: ["preference", "project", "decision", "history", "rejected_solution", "pitfall", "constraint"], description: "Filter by type; omit for all" },
125
187
  limit: { type: "integer", description: "Page size (default 50)" },
126
188
  offset: { type: "integer", description: "Page offset (default 0)" },
127
- include_archived: { type: "boolean", description: "Include archived (hidden) entries so they can be found and restored (default false)" }
189
+ include_archived: { type: "boolean", description: "Include archived (hidden) entries so they can be found and restored (default false)" },
190
+ occurred_from: { type: "string", description: "Optional ISO date/timestamp lower bound on when the remembered event happened (occurred_at, falling back to created_at). Date-only values are inclusive from that day's 00:00Z." },
191
+ occurred_to: { type: "string", description: "Optional ISO date/timestamp upper bound on occurred_at. Date-only values are inclusive through that day's 23:59:59.999Z." }
128
192
  },
129
193
  output: {
130
194
  schema: {
@@ -142,7 +206,7 @@ export function createTools(ctx, service, config, embedder) {
142
206
  const items = value.items ?? [];
143
207
  if (items.length === 0) return TEXT_OUTPUT(`0 memory entries (of ${value.total}).`);
144
208
  const body = items
145
- .map((m, i) => `[${i + 1}] ${m.title} (type=${m.type}, importance=${m.importance})\n ID: ${m.id} | updated: ${m.updated_at}`)
209
+ .map((m, i) => `[${i + 1}] ${m.title} (type=${m.type}, importance=${m.importance})\n ID: ${m.id} | updated: ${m.updated_at}${MEMORY_PROVENANCE(m)}`)
146
210
  .join("\n\n");
147
211
  return TEXT_OUTPUT(`${items.length} memory entries (of ${value.total}):\n\n${body}`);
148
212
  }
@@ -153,9 +217,13 @@ export function createTools(ctx, service, config, embedder) {
153
217
  type: args.type,
154
218
  limit: args.limit ?? 50,
155
219
  offset: args.offset ?? 0,
156
- includeArchived
220
+ includeArchived,
221
+ ...occurredWindow(args),
222
+ // A3:strict 开启时按会话 scope 硬过滤(宿主按 (args, runContext) 调用,
223
+ // 从 arguments 取第二参)。
224
+ ...strictVisibility(config, resolveSessionScope(arguments[1]))
157
225
  }));
158
- return { items: rows, total: service.count(args.type, { includeArchived }) };
226
+ return { items: rows, total: service.count(args.type, { includeArchived, ...occurredWindow(args), ...strictVisibility(config, resolveSessionScope(arguments[1])) }) };
159
227
  }
160
228
  }),
161
229
 
@@ -181,6 +249,10 @@ export function createTools(ctx, service, config, embedder) {
181
249
  tags: { type: "array", items: { type: "string" } },
182
250
  content: { type: "string", required: true },
183
251
  source: { type: "string" },
252
+ agent_scope: { type: "string" },
253
+ workspace_scope: { type: "string" },
254
+ sensitivity: { type: "string" },
255
+ occurred_at: { type: "string" },
184
256
  created_at: { type: "string" },
185
257
  updated_at: { type: "string" }
186
258
  }
@@ -189,12 +261,19 @@ export function createTools(ctx, service, config, embedder) {
189
261
  },
190
262
  render: (_args, value) => {
191
263
  const m = value.memory;
192
- return TEXT_OUTPUT(`${m.title}\nID: ${m.id} | type: ${m.type} | importance: ${m.importance}\n\n${m.content}`);
264
+ return TEXT_OUTPUT(`${m.title}\nID: ${m.id} | type: ${m.type} | importance: ${m.importance}${MEMORY_PROVENANCE(m)}\n\n${m.content}`);
193
265
  }
194
266
  },
195
267
  async execute(args) {
196
268
  const memory = service.getById(args.id);
197
269
  if (memory === undefined) throw new Error("memory not found");
270
+ // v0.8.0 A3:strictScope 下他 scope 的行按不存在处理(无存在性泄漏)。
271
+ // 宿主注册表按 (args, runContext) 两参调用处理器,从 arguments 取第二参。
272
+ const runContext = arguments[1];
273
+ const scope = resolveSessionScope(runContext);
274
+ if (config.strictScope === true && scope && !service.isVisibleInScope(memory, scope)) {
275
+ throw new Error("memory not found");
276
+ }
198
277
  return { memory: service.toApiList([memory])[0] };
199
278
  }
200
279
  }),
@@ -331,6 +410,120 @@ export function createTools(ctx, service, config, embedder) {
331
410
  const memory = service.setArchived(args.id, args.archived ?? true);
332
411
  return { memory: { id: memory.id, archived: memory.archived } };
333
412
  }
413
+ }),
414
+
415
+ // 运行时口子(issue #131 / PR-C)。
416
+ //
417
+ // 为什么要有这个工具:mneme 的取向是「本体保持完善但轻量;重的功能存在、默认不开、不被依赖」。
418
+ // 本地向量化就是那个重功能 —— 它需要额外一份运行时(解包后数百 MB)。面板上有按钮,但用户
419
+ // 可能根本不看面板;这时 agent 需要一个入口,能先查状态、把代价告诉用户,再按需取回。
420
+ //
421
+ // 关于「要不要直接 provision」:它会联网、可能传几十到上百 MB、耗时数分钟。所以工具描述里
422
+ // 明确要求先告知用户;只有在用户已经表示要本地向量化时才直接动手。
423
+ defineTool({
424
+ name: "memory_runtime",
425
+ description:
426
+ "Inspect or provision the LOCAL inference runtime that dsh-mneme's local (offline) embedding and rerank need: " +
427
+ "the transformers + onnxruntime dependency closure, hundreds of MB unpacked. It is deliberately NOT a default " +
428
+ "dependency — mneme's core stays lightweight and local vectorization is opt-in — so this tool is the hook that " +
429
+ "makes the heavy capability available on demand. Use action=status first: it is read-only and reports whether " +
430
+ "the runtime is ready plus what provisioning would cost. action=provision tries, in order: (1) adopting an " +
431
+ "existing copy from this profile's node_modules (no network; hardlinked when on the same volume, so no extra " +
432
+ "disk), (2) a configured local .tgz directory, (3) downloading from the npm registry against a pinned manifest, " +
433
+ "verifying every tarball's sha512. Provisioning can transfer tens to hundreds of MB and take minutes: unless " +
434
+ "the user has already asked for local vectorization, tell them that cost before calling it. action=verify loads " +
435
+ "the runtime and runs one real inference (strictly offline, so the model must already be cached).",
436
+ parameters: {
437
+ action: { type: "string", enum: ["status", "provision", "verify"], required: true, description: "status = read-only; provision = fetch/adopt the runtime; verify = run one real inference" },
438
+ overwrite: { type: "boolean", description: "provision only: replace an existing payload (use when repairing a broken one)" }
439
+ },
440
+ output: {
441
+ schema: {
442
+ type: "object",
443
+ additionalProperties: false,
444
+ properties: {
445
+ summary: { type: "string", required: true },
446
+ status: { type: "string", required: true },
447
+ cost: { type: "string", required: true },
448
+ strategy: { type: "string" },
449
+ payloadId: { type: "string" },
450
+ packages: { type: "integer" },
451
+ files: { type: "integer" },
452
+ bytes: { type: "integer" },
453
+ dimension: { type: "integer" },
454
+ reason: { type: "string" }
455
+ }
456
+ },
457
+ render: (_args, value) => TEXT_OUTPUT(value.summary)
458
+ },
459
+ async execute(args) {
460
+ const runtimeDir = config?.runtimeDir ?? "";
461
+ const manifest = loadRuntimeManifest();
462
+ const forPlatform = Array.isArray(manifest?.packages) ? manifest.packages.filter((pkg) => matchesPlatform(pkg, process.platform, process.arch)) : null;
463
+ const cost =
464
+ `Local vectorization needs an extra local inference runtime (transformers + onnxruntime closure, ` +
465
+ `hundreds of MB unpacked${forPlatform ? `, ${forPlatform.length} packages for this platform` : ""}). ` +
466
+ `It is not a default dependency: provisioning adopts an existing copy when possible, otherwise downloads it.`;
467
+
468
+ if (args.action === "provision") {
469
+ const result = await provisionRuntime({
470
+ hostModulesDir: hostModulesDir(import.meta.url),
471
+ runtimeDir,
472
+ localTarballDir: config?.runtimeTarballDir ?? "",
473
+ mirror: config?.runtimeMirror ?? "",
474
+ overwrite: args.overwrite === true,
475
+ manifest
476
+ });
477
+ return {
478
+ summary: result.ok
479
+ ? `Runtime ${result.strategy === "download" ? "downloaded from npm" : "adopted from this machine"}: ` +
480
+ `${result.packages} packages / ${result.files} files. Local embedding can be used after a DSH reload.`
481
+ : `Could not provision the runtime: ${result.reason}`,
482
+ status: result.ok ? "available" : "failed",
483
+ cost,
484
+ strategy: result.strategy,
485
+ ...(result.payloadId ? { payloadId: result.payloadId } : {}),
486
+ ...(result.packages === undefined ? {} : { packages: result.packages }),
487
+ ...(result.files === undefined ? {} : { files: result.files }),
488
+ ...(result.bytes === undefined ? {} : { bytes: result.bytes }),
489
+ ...(result.reason ? { reason: result.reason } : {})
490
+ };
491
+ }
492
+
493
+ if (args.action === "verify") {
494
+ const candidate = resolveRuntimeEntry({ runtimeDir: runtimeDir || undefined });
495
+ if (candidate === null) {
496
+ return { summary: "No usable runtime payload to verify.", status: "missing", cost };
497
+ }
498
+ const report = await verifyPayload(candidate.dir, { cacheDir: config?.embedModelCacheDir || undefined });
499
+ return {
500
+ summary: report.ok
501
+ ? `Runtime verified: real inference succeeded (dim ${report.functional.dim}, ${report.functional.rows} rows, ` +
502
+ `${report.functional.elapsedMs}ms, offline). Integrity: ${report.integrity.status}.`
503
+ : `Runtime verification failed — structural: ${report.structural.ok}, functional: ${report.functional.ok} (${report.functional.reason}).`,
504
+ status: report.ok ? "verified" : "failed",
505
+ cost,
506
+ payloadId: candidate.payloadId,
507
+ ...(report.functional.dim ? { dimension: report.functional.dim } : {}),
508
+ ...(report.ok ? {} : { reason: report.functional.reason })
509
+ };
510
+ }
511
+
512
+ // status:只读,且刻意不加载模型(那要几百毫秒且碰缓存)。报告要给到 agent 足够的信息去
513
+ // 决定「要不要打扰用户」。
514
+ const report = describeLocalRuntime({ runtimeDir: runtimeDir || defaultRuntimeDir() });
515
+ return {
516
+ summary:
517
+ `Local inference runtime: ${report.status}` +
518
+ (report.payloadId ? ` (${report.payloadId}, ${report.procedure ?? "?"}, ${report.materialize ?? "?"})` : "") +
519
+ `. ${report.status === "available" ? "Local embedding/rerank can be used." : "Local embedding is unavailable — " + (report.hint ?? "")}`,
520
+ status: report.status,
521
+ cost,
522
+ ...(report.payloadId ? { payloadId: report.payloadId } : {}),
523
+ ...(forPlatform ? { packages: forPlatform.length } : {}),
524
+ ...(report.reason ? { reason: report.reason } : {})
525
+ };
526
+ }
334
527
  })
335
528
  ];
336
529
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@modusensus/dsh-mneme",
3
3
  "description": "Cross-session memory plugin for DeepSeek Harness with autoDream consolidation: SQLite store, Markdown mirrors, 7 model tools, automatic injection, session summarization, user profile/rules, custom slash commands, vector (semantic) search, and a Web GUI panel",
4
- "version": "0.7.31",
4
+ "version": "0.8.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -31,6 +31,7 @@
31
31
  "src",
32
32
  "scripts",
33
33
  "test",
34
+ "runtime-manifest.json",
34
35
  "cordis.patch.yml"
35
36
  ],
36
37
  "dsh": {
@@ -52,11 +53,15 @@
52
53
  "@deepseek-ai/dsh-system-prompt": ">=0.1.0-rc.6 <0.2.0 || >=0.1.5-rc.0 <0.3.0 || >=0.2.0-rc.0 <0.3.0",
53
54
  "@deepseek-ai/dsh-tools": ">=0.1.0-rc.6 <0.2.0 || >=0.1.5-rc.0 <0.3.0 || >=0.2.0-rc.0 <0.3.0",
54
55
  "@deepseek-ai/schemastery": "^3.18.1",
56
+ "@huggingface/transformers": ">=4.2.0 <5",
55
57
  "dsh-better-sidebar": "^0.18.0"
56
58
  },
57
59
  "peerDependenciesMeta": {
58
60
  "dsh-better-sidebar": {
59
61
  "optional": true
62
+ },
63
+ "@huggingface/transformers": {
64
+ "optional": true
60
65
  }
61
66
  },
62
67
  "devDependencies": {
@@ -66,6 +71,7 @@
66
71
  "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.6",
67
72
  "@deepseek-ai/dsh-tools": "^0.1.0-rc.6",
68
73
  "@deepseek-ai/schemastery": "^3.18.1",
74
+ "@huggingface/transformers": "^4.2.0",
69
75
  "c8": "^12.0.0",
70
76
  "lucide": "^1.42.0"
71
77
  },
@@ -89,7 +95,6 @@
89
95
  ]
90
96
  },
91
97
  "dependencies": {
92
- "@huggingface/transformers": "^4.2.0",
93
98
  "morphicons": "^1.7.1"
94
99
  },
95
100
  "overrides": {