@modusensus/dsh-mneme 0.7.30 → 0.7.32
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 +25 -7
- package/lib/api.js +79 -6
- package/lib/client.js +217 -30
- package/lib/commands.js +6 -2
- package/lib/config.js +80 -14
- package/lib/dream/decisions.js +147 -14
- package/lib/dream/sleep.js +84 -34
- package/lib/dream.js +250 -60
- package/lib/embedding.js +22 -2
- package/lib/index.js +68 -37
- package/lib/inject.js +16 -9
- package/lib/lang.js +156 -0
- package/lib/local-embedder.js +23 -9
- package/lib/mirror.js +17 -14
- package/lib/reranker.js +23 -8
- package/lib/runtime/adopt.js +176 -0
- package/lib/runtime/closure.js +172 -0
- package/lib/runtime/download.js +247 -0
- package/lib/runtime/layout.js +235 -0
- package/lib/runtime/loader.js +249 -0
- package/lib/runtime/provision.js +237 -0
- package/lib/runtime/tarball.js +130 -0
- package/lib/runtime/verify.js +191 -0
- package/lib/service.js +102 -8
- package/lib/settings.js +36 -2
- package/lib/store.js +26 -8
- package/lib/summarize.js +108 -35
- package/lib/tools.js +119 -0
- package/package.json +11 -6
- package/runtime-manifest.json +596 -0
- package/scripts/build-runtime-manifest.mjs +217 -0
- package/scripts/mneme-runtime.mjs +277 -0
- package/src/api.js +79 -6
- package/src/commands.js +6 -2
- package/src/config.js +80 -14
- package/src/dream/decisions.js +147 -14
- package/src/dream/sleep.js +84 -34
- package/src/dream.js +250 -60
- package/src/embedding.js +22 -2
- package/src/index.js +68 -37
- package/src/inject.js +16 -9
- package/src/lang.js +156 -0
- package/src/local-embedder.js +23 -9
- package/src/mirror.js +17 -14
- package/src/reranker.js +23 -8
- package/src/runtime/adopt.js +176 -0
- package/src/runtime/closure.js +172 -0
- package/src/runtime/download.js +247 -0
- package/src/runtime/layout.js +235 -0
- package/src/runtime/loader.js +249 -0
- package/src/runtime/provision.js +237 -0
- package/src/runtime/tarball.js +130 -0
- package/src/runtime/verify.js +191 -0
- package/src/service.js +102 -8
- package/src/settings.js +36 -2
- package/src/store.js +26 -8
- package/src/summarize.js +108 -35
- package/src/tools.js +119 -0
- package/test/api.test.js +89 -9
- package/test/client.test.js +94 -10
- package/test/config.test.js +17 -1
- package/test/dream-candidate-hybrid.test.js +281 -0
- package/test/dream.test.js +172 -0
- package/test/embedding-ready.test.js +196 -0
- package/test/helpers/runtime-source.js +60 -0
- package/test/helpers/tar-builder.js +80 -0
- package/test/inject.test.js +37 -1
- package/test/lang.test.js +87 -0
- package/test/quality-filter.test.js +68 -0
- package/test/reasoning-effort.test.js +106 -15
- package/test/reindex-backfill.test.js +62 -0
- package/test/runtime-adopt.test.js +206 -0
- package/test/runtime-cli.test.js +89 -0
- package/test/runtime-closure.test.js +193 -0
- package/test/runtime-download.test.js +302 -0
- package/test/runtime-layout.test.js +163 -0
- package/test/runtime-loader.test.js +237 -0
- package/test/runtime-manifest.test.js +158 -0
- package/test/runtime-provision.test.js +101 -0
- package/test/runtime-tarball.test.js +82 -0
- package/test/runtime-verify.test.js +214 -0
- package/test/sleep-action-set.test.js +422 -0
- package/test/store.test.js +14 -0
- package/test/summarize.test.js +224 -0
- package/test/tools.test.js +30 -5
- package/test/webServer-optional.test.js +34 -1
package/lib/tools.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
2
|
+
import { describeLocalRuntime, resolveRuntimeEntry } from "./runtime/loader.js";
|
|
3
|
+
import { defaultRuntimeDir } from "./runtime/layout.js";
|
|
4
|
+
import { hostModulesDir, loadRuntimeManifest, provisionRuntime } from "./runtime/provision.js";
|
|
5
|
+
import { matchesPlatform } from "./runtime/closure.js";
|
|
6
|
+
import { verifyPayload } from "./runtime/verify.js";
|
|
2
7
|
|
|
3
8
|
const TEXT_OUTPUT = (text) => [{ type: "text", text }];
|
|
4
9
|
// Per-registry tool-name registry: guards against duplicate registration on
|
|
@@ -331,6 +336,120 @@ export function createTools(ctx, service, config, embedder) {
|
|
|
331
336
|
const memory = service.setArchived(args.id, args.archived ?? true);
|
|
332
337
|
return { memory: { id: memory.id, archived: memory.archived } };
|
|
333
338
|
}
|
|
339
|
+
}),
|
|
340
|
+
|
|
341
|
+
// 运行时口子(issue #131 / PR-C)。
|
|
342
|
+
//
|
|
343
|
+
// 为什么要有这个工具:mneme 的取向是「本体保持完善但轻量;重的功能存在、默认不开、不被依赖」。
|
|
344
|
+
// 本地向量化就是那个重功能 —— 它需要额外一份运行时(解包后数百 MB)。面板上有按钮,但用户
|
|
345
|
+
// 可能根本不看面板;这时 agent 需要一个入口,能先查状态、把代价告诉用户,再按需取回。
|
|
346
|
+
//
|
|
347
|
+
// 关于「要不要直接 provision」:它会联网、可能传几十到上百 MB、耗时数分钟。所以工具描述里
|
|
348
|
+
// 明确要求先告知用户;只有在用户已经表示要本地向量化时才直接动手。
|
|
349
|
+
defineTool({
|
|
350
|
+
name: "memory_runtime",
|
|
351
|
+
description:
|
|
352
|
+
"Inspect or provision the LOCAL inference runtime that dsh-mneme's local (offline) embedding and rerank need: " +
|
|
353
|
+
"the transformers + onnxruntime dependency closure, hundreds of MB unpacked. It is deliberately NOT a default " +
|
|
354
|
+
"dependency — mneme's core stays lightweight and local vectorization is opt-in — so this tool is the hook that " +
|
|
355
|
+
"makes the heavy capability available on demand. Use action=status first: it is read-only and reports whether " +
|
|
356
|
+
"the runtime is ready plus what provisioning would cost. action=provision tries, in order: (1) adopting an " +
|
|
357
|
+
"existing copy from this profile's node_modules (no network; hardlinked when on the same volume, so no extra " +
|
|
358
|
+
"disk), (2) a configured local .tgz directory, (3) downloading from the npm registry against a pinned manifest, " +
|
|
359
|
+
"verifying every tarball's sha512. Provisioning can transfer tens to hundreds of MB and take minutes: unless " +
|
|
360
|
+
"the user has already asked for local vectorization, tell them that cost before calling it. action=verify loads " +
|
|
361
|
+
"the runtime and runs one real inference (strictly offline, so the model must already be cached).",
|
|
362
|
+
parameters: {
|
|
363
|
+
action: { type: "string", enum: ["status", "provision", "verify"], required: true, description: "status = read-only; provision = fetch/adopt the runtime; verify = run one real inference" },
|
|
364
|
+
overwrite: { type: "boolean", description: "provision only: replace an existing payload (use when repairing a broken one)" }
|
|
365
|
+
},
|
|
366
|
+
output: {
|
|
367
|
+
schema: {
|
|
368
|
+
type: "object",
|
|
369
|
+
additionalProperties: false,
|
|
370
|
+
properties: {
|
|
371
|
+
summary: { type: "string", required: true },
|
|
372
|
+
status: { type: "string", required: true },
|
|
373
|
+
cost: { type: "string", required: true },
|
|
374
|
+
strategy: { type: "string" },
|
|
375
|
+
payloadId: { type: "string" },
|
|
376
|
+
packages: { type: "integer" },
|
|
377
|
+
files: { type: "integer" },
|
|
378
|
+
bytes: { type: "integer" },
|
|
379
|
+
dimension: { type: "integer" },
|
|
380
|
+
reason: { type: "string" }
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
render: (_args, value) => TEXT_OUTPUT(value.summary)
|
|
384
|
+
},
|
|
385
|
+
async execute(args) {
|
|
386
|
+
const runtimeDir = config?.runtimeDir ?? "";
|
|
387
|
+
const manifest = loadRuntimeManifest();
|
|
388
|
+
const forPlatform = Array.isArray(manifest?.packages) ? manifest.packages.filter((pkg) => matchesPlatform(pkg, process.platform, process.arch)) : null;
|
|
389
|
+
const cost =
|
|
390
|
+
`Local vectorization needs an extra local inference runtime (transformers + onnxruntime closure, ` +
|
|
391
|
+
`hundreds of MB unpacked${forPlatform ? `, ${forPlatform.length} packages for this platform` : ""}). ` +
|
|
392
|
+
`It is not a default dependency: provisioning adopts an existing copy when possible, otherwise downloads it.`;
|
|
393
|
+
|
|
394
|
+
if (args.action === "provision") {
|
|
395
|
+
const result = await provisionRuntime({
|
|
396
|
+
hostModulesDir: hostModulesDir(import.meta.url),
|
|
397
|
+
runtimeDir,
|
|
398
|
+
localTarballDir: config?.runtimeTarballDir ?? "",
|
|
399
|
+
mirror: config?.runtimeMirror ?? "",
|
|
400
|
+
overwrite: args.overwrite === true,
|
|
401
|
+
manifest
|
|
402
|
+
});
|
|
403
|
+
return {
|
|
404
|
+
summary: result.ok
|
|
405
|
+
? `Runtime ${result.strategy === "download" ? "downloaded from npm" : "adopted from this machine"}: ` +
|
|
406
|
+
`${result.packages} packages / ${result.files} files. Local embedding can be used after a DSH reload.`
|
|
407
|
+
: `Could not provision the runtime: ${result.reason}`,
|
|
408
|
+
status: result.ok ? "available" : "failed",
|
|
409
|
+
cost,
|
|
410
|
+
strategy: result.strategy,
|
|
411
|
+
...(result.payloadId ? { payloadId: result.payloadId } : {}),
|
|
412
|
+
...(result.packages === undefined ? {} : { packages: result.packages }),
|
|
413
|
+
...(result.files === undefined ? {} : { files: result.files }),
|
|
414
|
+
...(result.bytes === undefined ? {} : { bytes: result.bytes }),
|
|
415
|
+
...(result.reason ? { reason: result.reason } : {})
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (args.action === "verify") {
|
|
420
|
+
const candidate = resolveRuntimeEntry({ runtimeDir: runtimeDir || undefined });
|
|
421
|
+
if (candidate === null) {
|
|
422
|
+
return { summary: "No usable runtime payload to verify.", status: "missing", cost };
|
|
423
|
+
}
|
|
424
|
+
const report = await verifyPayload(candidate.dir, { cacheDir: config?.embedModelCacheDir || undefined });
|
|
425
|
+
return {
|
|
426
|
+
summary: report.ok
|
|
427
|
+
? `Runtime verified: real inference succeeded (dim ${report.functional.dim}, ${report.functional.rows} rows, ` +
|
|
428
|
+
`${report.functional.elapsedMs}ms, offline). Integrity: ${report.integrity.status}.`
|
|
429
|
+
: `Runtime verification failed — structural: ${report.structural.ok}, functional: ${report.functional.ok} (${report.functional.reason}).`,
|
|
430
|
+
status: report.ok ? "verified" : "failed",
|
|
431
|
+
cost,
|
|
432
|
+
payloadId: candidate.payloadId,
|
|
433
|
+
...(report.functional.dim ? { dimension: report.functional.dim } : {}),
|
|
434
|
+
...(report.ok ? {} : { reason: report.functional.reason })
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// status:只读,且刻意不加载模型(那要几百毫秒且碰缓存)。报告要给到 agent 足够的信息去
|
|
439
|
+
// 决定「要不要打扰用户」。
|
|
440
|
+
const report = describeLocalRuntime({ runtimeDir: runtimeDir || defaultRuntimeDir() });
|
|
441
|
+
return {
|
|
442
|
+
summary:
|
|
443
|
+
`Local inference runtime: ${report.status}` +
|
|
444
|
+
(report.payloadId ? ` (${report.payloadId}, ${report.procedure ?? "?"}, ${report.materialize ?? "?"})` : "") +
|
|
445
|
+
`. ${report.status === "available" ? "Local embedding/rerank can be used." : "Local embedding is unavailable — " + (report.hint ?? "")}`,
|
|
446
|
+
status: report.status,
|
|
447
|
+
cost,
|
|
448
|
+
...(report.payloadId ? { payloadId: report.payloadId } : {}),
|
|
449
|
+
...(forPlatform ? { packages: forPlatform.length } : {}),
|
|
450
|
+
...(report.reason ? { reason: report.reason } : {})
|
|
451
|
+
};
|
|
452
|
+
}
|
|
334
453
|
})
|
|
335
454
|
];
|
|
336
455
|
|
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.
|
|
4
|
+
"version": "0.7.32",
|
|
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": {
|
|
@@ -47,16 +48,20 @@
|
|
|
47
48
|
},
|
|
48
49
|
"peerDependencies": {
|
|
49
50
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
50
|
-
"@deepseek-ai/dsh-host-webserver": "
|
|
51
|
-
"@deepseek-ai/dsh-llm": "
|
|
52
|
-
"@deepseek-ai/dsh-system-prompt": "
|
|
53
|
-
"@deepseek-ai/dsh-tools": "
|
|
51
|
+
"@deepseek-ai/dsh-host-webserver": ">=0.1.0-rc.6 <0.2.0 || >=0.1.5-rc.0 <0.3.0 || >=0.2.0-rc.0 <0.3.0",
|
|
52
|
+
"@deepseek-ai/dsh-llm": ">=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
|
+
"@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",
|
|
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": {
|