dsh-memu-memory 1.2.1 → 1.2.3
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/AGENTS.md +3 -1
- package/README.md +23 -8
- package/README.zh.md +16 -6
- package/docs/client-conventions.md +1 -0
- package/docs/contributing.md +18 -4
- package/docs/emotion-model-spec.md +2 -2
- package/docs/env-and-commands.md +20 -0
- package/docs/host-api.md +22 -1
- package/docs/memory-semantics.md +30 -2
- package/docs/troubleshooting.md +76 -5
- package/lib/activity-log.js +1 -1
- package/lib/backup.js +24 -2
- package/lib/binding-diagnostics.js +2 -2
- package/lib/client.js +1511 -153
- package/lib/consolidation-worker.js +30 -8
- package/lib/curator-evidence.js +131 -0
- package/lib/curator-policy.js +81 -0
- package/lib/curator.js +1252 -91
- package/lib/cycle.js +12 -1
- package/lib/embedding-download.js +39 -4
- package/lib/engine.js +6 -3
- package/lib/freshness.js +97 -0
- package/lib/global-graph.js +282 -0
- package/lib/graph.js +295 -11
- package/lib/inbound.js +19 -0
- package/lib/inject.js +396 -25
- package/lib/lexicon.js +1115 -0
- package/lib/local-vector-service.js +8 -6
- package/lib/managed-runtime.js +33 -2
- package/lib/memory.js +365 -34
- package/lib/memu.js +2 -2
- package/lib/migrate.js +83 -2
- package/lib/private-links.js +587 -0
- package/lib/private.js +32 -3
- package/lib/prompts/global-curator.md +76 -19
- package/lib/prompts/private-consolidation.coding.md +4 -1
- package/lib/prompts/private-consolidation.md +3 -1
- package/lib/prompts/private-consolidation.mixed.md +3 -1
- package/lib/prompts/private-consolidation.rp.md +3 -1
- package/lib/prompts.js +1 -1
- package/lib/rpc.js +589 -10
- package/lib/salient-wake.js +402 -0
- package/lib/state.js +95 -1
- package/lib/text-retrieval.js +661 -0
- package/lib/text-similarity.js +36 -18
- package/lib/tools.js +168 -10
- package/lib/webui/standalone.css +17 -0
- package/lib/webui/standalone.js +2 -0
- package/package.json +1 -1
- package/scripts/acceptance-local.mjs +8 -5
- package/scripts/curator-pair-calibrate.mjs +259 -0
- package/scripts/drive-session.mjs +853 -0
- package/scripts/lexicon-calibrate.mjs +230 -0
- package/scripts/lexicon-dedupe.mjs +318 -0
- package/scripts/mock-llm.mjs +903 -0
- package/tests/absorb-review.test.mjs +353 -0
- package/tests/appendix-b2.test.mjs +2 -2
- package/tests/client-export.test.mjs +520 -0
- package/tests/client-render.test.mjs +32 -4
- package/tests/consolidation-fork.test.mjs +14 -12
- package/tests/consolidation-snapshot.test.mjs +39 -0
- package/tests/curator-absorb.test.mjs +443 -0
- package/tests/curator-calibrate.test.mjs +173 -0
- package/tests/curator-clusters.test.mjs +281 -0
- package/tests/curator-commit.test.mjs +52 -5
- package/tests/curator-evidence.test.mjs +102 -0
- package/tests/curator-link.test.mjs +316 -0
- package/tests/curator-pairing.test.mjs +252 -0
- package/tests/curator-probe.test.mjs +15 -6
- package/tests/curator-review-mode.test.mjs +314 -0
- package/tests/disclosure.test.mjs +2 -1
- package/tests/entity-merge.test.mjs +261 -0
- package/tests/fixtures/curator-pairs/labeled.v1.jsonl +90 -0
- package/tests/fixtures/lexicon-stub-hooks.mjs +15 -0
- package/tests/fixtures/lexicon-stub.mjs +284 -0
- package/tests/fixtures/mock-llm/reply.txt +1 -0
- package/tests/freshness.test.mjs +140 -0
- package/tests/graph-cascade.test.mjs +35 -2
- package/tests/graph.test.mjs +96 -0
- package/tests/help-page.test.mjs +415 -0
- package/tests/inbound.test.mjs +6 -3
- package/tests/inject-guide.test.mjs +28 -0
- package/tests/inject.test.mjs +157 -5
- package/tests/injection-chain.test.mjs +176 -0
- package/tests/lexicon-calibrate.test.mjs +48 -0
- package/tests/lexicon-dedupe.test.mjs +171 -0
- package/tests/lexicon-frequency.test.mjs +179 -0
- package/tests/lexicon-inject.test.mjs +410 -0
- package/tests/lexicon-perf.test.mjs +436 -0
- package/tests/lexicon-ui.test.mjs +547 -0
- package/tests/lexicon.test.mjs +922 -0
- package/tests/managed-runtime.test.mjs +32 -0
- package/tests/mock-llm.test.mjs +225 -0
- package/tests/open-loop-date.test.mjs +406 -0
- package/tests/private-links.test.mjs +445 -0
- package/tests/prompts.test.mjs +35 -0
- package/tests/recall-dedup.test.mjs +33 -4
- package/tests/salient-wake.test.mjs +362 -0
- package/tests/settings-plumbing.test.mjs +76 -0
- package/tests/sidebar.test.mjs +5 -1
- package/tests/stubs/dsh-schedule.js +105 -0
- package/tests/tool-schema.test.mjs +1 -1
- package/tests/tools.test.mjs +112 -3
- package/tests/webui-auth.test.mjs +352 -2
- package/tests/webui.test.mjs +188 -0
package/lib/backup.js
CHANGED
|
@@ -59,6 +59,7 @@ const leaseFile = () => path.join(backupsDir(), '.leases.json')
|
|
|
59
59
|
const lockAnchor = () => path.join(backupsDir(), '.backup')
|
|
60
60
|
const stateFile = () => path.join(dataDir(), 'state.json')
|
|
61
61
|
const globalDbFile = () => path.join(dataDir(), 'global.sqlite3')
|
|
62
|
+
const lexiconRoot = () => path.join(dataDir(), 'lexicon')
|
|
62
63
|
const vectorActiveFile = () => path.join(indexDir(), 'vector-active.json')
|
|
63
64
|
const engineCurrentFile = () => path.join(dataDir(), 'engine', 'current.json')
|
|
64
65
|
|
|
@@ -505,8 +506,9 @@ function engineSummary() {
|
|
|
505
506
|
|
|
506
507
|
/**
|
|
507
508
|
* Copies every store a restore needs: plugin state, the global index and the
|
|
508
|
-
* per-library index files, the
|
|
509
|
-
* and their manifest, attachment references,
|
|
509
|
+
* per-library index files, the per-library lexicon files, the active vector
|
|
510
|
+
* profile journal, prompt overrides and their manifest, attachment references,
|
|
511
|
+
* and every MemU SQLite database.
|
|
510
512
|
* Deliberately absent: engine/, downloads/, logs/, tmp/ (large and
|
|
511
513
|
* re-downloadable) and any key material - the manifest carries identity, never
|
|
512
514
|
* a credential.
|
|
@@ -519,9 +521,21 @@ function writeStores(staging, exec) {
|
|
|
519
521
|
ensureDir(path.join(staging, 'index'))
|
|
520
522
|
ensureDir(path.join(staging, 'prompts'))
|
|
521
523
|
copyRegular(stateFile(), path.join(staging, 'state.json'))
|
|
524
|
+
// Consolidation ledger: per-session ranges/operations. It now participates in
|
|
525
|
+
// backup/restore so a restored install does not re-fork work it already did.
|
|
526
|
+
copyRegular(path.join(dataDir(), 'consolidation.json'), path.join(staging, 'consolidation.json'))
|
|
522
527
|
for (const name of readdirSafe(indexDir())) {
|
|
523
528
|
if (name.endsWith('.json')) copyRegular(path.join(indexDir(), name), path.join(staging, 'index', name))
|
|
524
529
|
}
|
|
530
|
+
// 词典:data/lexicon/<libraryId>.json 与索引同权进备份清单。只收安全 id
|
|
531
|
+
// 命名的 JSON(restore 侧 allowlist 用同一规则拒绝越界);目录还不存在(这个
|
|
532
|
+
// 数据根从未写过词典)就是空集。
|
|
533
|
+
ensureDir(path.join(staging, 'lexicon'))
|
|
534
|
+
for (const name of readdirSafe(lexiconRoot())) {
|
|
535
|
+
if (!name.endsWith('.json')) continue
|
|
536
|
+
if (!isSafeId(name.slice(0, -'.json'.length))) continue
|
|
537
|
+
copyRegular(path.join(lexiconRoot(), name), path.join(staging, 'lexicon', name))
|
|
538
|
+
}
|
|
525
539
|
copyRegular(path.join(dataDir(), 'prompts', 'manifest.json'), path.join(staging, 'prompts', 'manifest.json'))
|
|
526
540
|
copyTree(path.join(dataDir(), 'prompts'), path.join(staging, 'prompts'))
|
|
527
541
|
copyTree(path.join(dataDir(), 'attachments'), path.join(staging, 'attachments'))
|
|
@@ -903,6 +917,7 @@ function liveTargetFor(rel) {
|
|
|
903
917
|
const head = parts[0]
|
|
904
918
|
if (parts.length === 1) {
|
|
905
919
|
if (head === 'state.json') return stateFile()
|
|
920
|
+
if (head === 'consolidation.json') return path.join(dataDir(), 'consolidation.json')
|
|
906
921
|
if (head === 'global.sqlite3') return globalDbFile()
|
|
907
922
|
if (head === 'global.sqlite3-wal') return globalDbFile() + '-wal'
|
|
908
923
|
if (head === 'global.sqlite3-shm') return globalDbFile() + '-shm'
|
|
@@ -910,6 +925,13 @@ function liveTargetFor(rel) {
|
|
|
910
925
|
if ((head === 'index' || head === 'libraries') && parts.length === 2) {
|
|
911
926
|
return path.join(head === 'index' ? indexDir() : librariesDir(), parts[1])
|
|
912
927
|
}
|
|
928
|
+
if (head === 'lexicon' && parts.length === 2) {
|
|
929
|
+
// 词典只接受 <libraryId>.json:isSafeId 挡掉 ..、路径分隔符和任意文件名,
|
|
930
|
+
// 与 writeStores 收录时的同一规则对称。
|
|
931
|
+
const id = parts[1].endsWith('.json') ? parts[1].slice(0, -'.json'.length) : ''
|
|
932
|
+
if (!id || !isSafeId(id)) throw new Error('backup contains an entry this version cannot restore: ' + rel)
|
|
933
|
+
return path.join(lexiconRoot(), parts[1])
|
|
934
|
+
}
|
|
913
935
|
if ((head === 'prompts' || head === 'attachments') && parts.length >= 2) {
|
|
914
936
|
return path.join(dataDir(), parts.join(path.sep))
|
|
915
937
|
}
|
|
@@ -55,8 +55,8 @@ export const RUNTIME_STATE = Object.freeze([
|
|
|
55
55
|
{ layer: 'temporary-map', file: 'lib/inbound.js:14', name: 'sessions', keyedBy: 'sessionId', clearedBy: 'session/disposed (releaseInboundSession)' },
|
|
56
56
|
{ layer: 'temporary-map', file: 'lib/media.js:19', name: 'captures', keyedBy: 'sessionId', clearedBy: 'capture settle' },
|
|
57
57
|
{ layer: 'temporary-map', file: 'lib/private.js:347', name: 'inFlight', keyedBy: 'sessionId', clearedBy: 'consolidation settle' },
|
|
58
|
-
{ layer: 'temporary-map', file: 'lib/curator.js:
|
|
59
|
-
{ layer: 'cache', file: 'lib/state.js:
|
|
58
|
+
{ layer: 'temporary-map', file: 'lib/curator.js:50', name: 'jobs', keyedBy: 'job id', clearedBy: 'curation settle' },
|
|
59
|
+
{ layer: 'cache', file: 'lib/state.js:1061', name: 'indexCache', keyedBy: 'libraryId', clearedBy: 'next load / external write' },
|
|
60
60
|
{ layer: 'cache', file: 'lib/paths.js:52', name: 'readFailures', keyedBy: 'absolute file', clearedBy: 'a later successful read' },
|
|
61
61
|
])
|
|
62
62
|
|