dsh-memu-memory 1.4.4 → 1.4.5
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/CHANGELOG.md +11 -0
- package/README.md +33 -14
- package/README.zh.md +34 -12
- package/assets/screenshots/drawer.jpg +0 -0
- package/assets/screenshots/libraries.jpg +0 -0
- package/assets/screenshots/mobile.jpg +0 -0
- package/assets/screenshots/relations.jpg +0 -0
- package/assets/screenshots/settings.jpg +0 -0
- package/assets/screenshots/webui-dark.jpg +0 -0
- package/assets/screenshots/webui-memory.jpg +0 -0
- package/docs/client-conventions.md +19 -3
- package/docs/contributing.md +4 -2
- package/docs/env-and-commands.md +9 -1
- package/docs/graph-scale.md +214 -0
- package/docs/lexicon-recall.md +100 -0
- package/docs/mcp-porting.md +8 -6
- package/docs/memory-semantics.md +35 -3
- package/docs/pending-work.md +3 -1
- package/docs/retention.md +83 -0
- package/docs/rt-index.md +452 -0
- package/docs/scale-performance.md +101 -0
- package/docs/token-budget.md +92 -0
- package/docs/troubleshooting.md +50 -11
- package/lib/auto-link/apply.js +7 -2
- package/lib/auto-link/candidates.js +32 -10
- package/lib/backup.js +67 -32
- package/lib/binding-diagnostics.js +1 -1
- package/lib/bounded-cache.js +80 -0
- package/lib/client.js +2096 -409
- package/lib/consolidation-ledger.js +21 -4
- package/lib/consolidation-worker.js +14 -1
- package/lib/cycle.js +16 -11
- package/lib/diagnostic-context.js +372 -0
- package/lib/diagnostics.js +147 -61
- package/lib/embedding-download.js +7 -8
- package/lib/engine-sources.js +286 -0
- package/lib/engine.js +23 -10
- package/lib/entity-repair.js +43 -13
- package/lib/entity-review.js +64 -0
- package/lib/environment-check.js +348 -36
- package/lib/feedback.js +25 -0
- package/lib/global-graph.js +46 -2
- package/lib/graph-adjacency-index.js +525 -0
- package/lib/graph-overview.js +293 -0
- package/lib/graph.js +658 -105
- package/lib/inbound.js +44 -15
- package/lib/index-pages.js +57 -0
- package/lib/index.js +44 -6
- package/lib/inject.js +119 -50
- package/lib/lexicon-rt-source.js +25 -0
- package/lib/lexicon-rt-worker.js +26 -0
- package/lib/lexicon-rt.js +224 -0
- package/lib/lexicon-scope.js +56 -5
- package/lib/lexicon.js +143 -54
- package/lib/local-vector-service.js +3 -0
- package/lib/maintenance-ledger.js +542 -12
- package/lib/managed-runtime.js +260 -80
- package/lib/media.js +1 -1
- package/lib/memory.js +564 -131
- package/lib/port-surface.js +96 -11
- package/lib/private.js +47 -21
- package/lib/recall-cache.js +20 -34
- package/lib/retention.js +173 -0
- package/lib/rpc.js +135 -52
- package/lib/rt-index/builder.js +209 -0
- package/lib/rt-index/format.js +231 -0
- package/lib/rt-index/manifest.js +105 -0
- package/lib/rt-index/reader.js +673 -0
- package/lib/rt-index-retention.js +151 -0
- package/lib/rt-index-service.js +283 -0
- package/lib/rt-index-worker.js +21 -0
- package/lib/salient-wake.js +55 -4
- package/lib/state.js +195 -24
- package/lib/temporal.js +39 -13
- package/lib/token-measurement.js +126 -0
- package/lib/tools.js +101 -6
- package/lib/turn-log.js +108 -3
- package/lib/webui/graph-layout-worker.js +68 -0
- package/lib/webui/graph-local-physics.js +390 -0
- package/lib/webui/graph-spatial-grid.js +64 -0
- package/lib/webui/graph-view.bundle.js +6 -1
- package/lib/webui/graph-view.js +478 -135
- package/lib/webui/graph-webgl-renderer.js +74 -0
- package/lib/webui/standalone.js +1 -1
- package/lib/worker-pool.js +30 -4
- package/package.json +3 -2
- package/scripts/acceptance-local.mjs +4 -10
- package/scripts/bench-all-libraries.mjs +47 -0
- package/scripts/check-classic-graph-browser.mjs +189 -0
- package/scripts/check-client-browser.mjs +929 -0
- package/scripts/check-graph-browser.mjs +6 -0
- package/scripts/check-graph-elastic-browser.mjs +139 -0
- package/scripts/check-memory-review-browser.mjs +124 -0
- package/scripts/entity-dedupe.mjs +19 -3
- package/scripts/graph-artifact-provenance.mjs +30 -0
- package/scripts/graph-freeze-manifest.mjs +129 -0
- package/scripts/graph-geometry-fixture.mjs +40 -0
- package/scripts/graph-physics-bench.mjs +218 -0
- package/scripts/graph-scale-bench.mjs +213 -0
- package/scripts/graph-scale-memory.mjs +48 -0
- package/scripts/graph-service-bench.mjs +72 -0
- package/scripts/make-readme-shots.mjs +17 -5
- package/scripts/preview.mjs +1 -0
- package/scripts/rebuild-rt.mjs +18 -0
- package/scripts/scale-bench.mjs +183 -0
- package/scripts/simulate-injection.mjs +47 -8
- package/scripts/verify-host-fixtures.mjs +108 -0
- package/scripts/verify-host-recovery.mjs +565 -0
- package/scripts/verify-vector-recovery.mjs +740 -0
- package/tests/auto-link-candidates.test.mjs +20 -0
- package/tests/browser.test.mjs +16 -2
- package/tests/client-export.test.mjs +16 -1
- package/tests/client-pagination.test.mjs +1495 -0
- package/tests/client-render.test.mjs +223 -28
- package/tests/consolidation-fork.test.mjs +93 -10
- package/tests/consolidation-ledger.test.mjs +17 -1
- package/tests/diagnostic-entity-candidates.test.mjs +54 -0
- package/tests/diagnostic-report.test.mjs +429 -0
- package/tests/diagnostic-wiring.test.mjs +88 -0
- package/tests/diagnostics.test.mjs +27 -0
- package/tests/embedding-download.test.mjs +44 -0
- package/tests/engine-source-settings.test.mjs +69 -0
- package/tests/engine-sources.test.mjs +145 -0
- package/tests/entity-dedupe.test.mjs +143 -0
- package/tests/entity-merge-review.test.mjs +363 -0
- package/tests/entity-merge.test.mjs +12 -4
- package/tests/entity-review.test.mjs +87 -0
- package/tests/environment-check.test.mjs +51 -1
- package/tests/feedback.test.mjs +95 -0
- package/tests/graph-adjacency-index.test.mjs +536 -0
- package/tests/graph-cascade.test.mjs +229 -0
- package/tests/graph-import-diagnostic.test.mjs +25 -0
- package/tests/graph-overview.test.mjs +709 -0
- package/tests/graph-session-authorization.test.mjs +419 -0
- package/tests/graph-view-geometry.test.mjs +426 -0
- package/tests/graph-view-scale.test.mjs +88 -0
- package/tests/graph-view.test.mjs +444 -5
- package/tests/graph.test.mjs +43 -0
- package/tests/help-page.test.mjs +128 -54
- package/tests/inbound.test.mjs +19 -0
- package/tests/index-pagination.test.mjs +113 -0
- package/tests/index-read-view.test.mjs +212 -0
- package/tests/inject-guide.test.mjs +9 -0
- package/tests/injection-dedupe.test.mjs +213 -0
- package/tests/lexicon-recall.test.mjs +641 -0
- package/tests/lexicon-rt-lifecycle.test.mjs +196 -0
- package/tests/lexicon-rt.test.mjs +468 -0
- package/tests/local-embedding-worker.test.mjs +38 -0
- package/tests/local-vector-service.test.mjs +32 -3
- package/tests/maintenance-compat.test.mjs +128 -0
- package/tests/maintenance-settlement.test.mjs +1003 -0
- package/tests/managed-memory.test.mjs +39 -11
- package/tests/managed-runtime.test.mjs +109 -0
- package/tests/memory-fields.test.mjs +24 -12
- package/tests/observed-evidence.test.mjs +52 -0
- package/tests/port-surface.test.mjs +93 -1
- package/tests/recall-cache.test.mjs +56 -3
- package/tests/recall-dedup.test.mjs +63 -2
- package/tests/retention.test.mjs +260 -0
- package/tests/rt-index-cross-library.test.mjs +230 -0
- package/tests/rt-index-integration.test.mjs +194 -0
- package/tests/rt-index-retention.test.mjs +552 -0
- package/tests/rt-index-scale.test.mjs +204 -0
- package/tests/rt-index.test.mjs +705 -0
- package/tests/salient-date-boundaries.test.mjs +121 -0
- package/tests/salient-wake.test.mjs +29 -0
- package/tests/scale-bench.test.mjs +53 -0
- package/tests/settings-plumbing.test.mjs +25 -0
- package/tests/simulate-injection.test.mjs +15 -1
- package/tests/standalone-navigation.test.mjs +44 -0
- package/tests/state.test.mjs +51 -0
- package/tests/temporal-precision.test.mjs +102 -0
- package/tests/temporal.test.mjs +10 -6
- package/tests/token-measurement.test.mjs +98 -0
- package/tests/tool-schema.test.mjs +41 -5
- package/tests/tools.test.mjs +6 -3
- package/tests/turn-token-budget.test.mjs +149 -0
- package/tests/webui-auth.test.mjs +57 -1
- package/tests/webui.test.mjs +40 -15
package/lib/rpc.js
CHANGED
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
DEFAULT_SETTINGS, getSettings, updateSettings, loadState, listLibraries, listArchivedLibraries, getLibrary, createLibrary,
|
|
4
4
|
renameLibrary, archiveLibrary, deleteLibrary, restoreLibrary, libraryScopeMissing, getSessionBinding, setSessionBinding, ensureSession,
|
|
5
5
|
ensureLibraryForCwd, getMemoryBackend,
|
|
6
|
-
deleteSessionBinding, releaseInjected, markReinjectPending, loadPrivateIndex, loadGlobalIndex, saveGlobalIndex, updatePrivateIndex, updateGlobalIndex,
|
|
6
|
+
deleteSessionBinding, releaseInjected, markReinjectPending, loadPrivateIndex, loadGlobalIndex, readPrivateIndex, readGlobalIndex, saveGlobalIndex, updatePrivateIndex, updateGlobalIndex,
|
|
7
7
|
backupDatabases, listBackups, restoreBackup, deleteBackup, globalDbPath, normalizeCwd, getWorkspacePolicy, listWorkspacePolicies, setWorkspacePolicy,
|
|
8
8
|
storageHealth, effectiveScope, summarizeIndex, getPromptDomains, addPromptDomain, removePromptDomain, memoryRevision, memoryStamp, noteMemoryBeat,
|
|
9
9
|
} from './state.js'
|
|
10
10
|
import { commit, closeMemuResident, prewarmMemuResident } from './memu.js'
|
|
11
|
-
import { privateList, privateUpdate, privateRemember, privateRecall, privateArchive, privateDelete, previewDelete, restoreDeleted, globalList, globalRecall, globalSetStatus, globalDelete, domainOf, decayStrength, appliesToDomain, importMemories, recordImportBatch, revertImportBatch, resolveMemoryReview, visibleToSession, isMemoryEligible } from './memory.js'
|
|
11
|
+
import { privateList, privateUpdate, privateRemember, privateRecall, privateArchive, privateDelete, previewDelete, restoreDeleted, globalList, globalRecall, globalSetStatus, globalDelete, domainOf, decayStrength, appliesToDomain, importMemories, recordImportBatch, revertImportBatch, resolveMemoryReview, visibleToSession, isMemoryEligible, resolveLibrary } from './memory.js'
|
|
12
12
|
import { normalizeMemoryContext } from './context.js'
|
|
13
13
|
import { requestPrivateConsolidation } from './private.js'
|
|
14
14
|
import { listHostModelOptions, discoverForkModels, redactConsolidationSettings, disposeConsolidationRoute } from './fork-model.js'
|
|
@@ -19,10 +19,14 @@ import { maybeMigrateLibraries } from './migrate.js'
|
|
|
19
19
|
import { getPromptStates, savePromptOverride, resetPrompt, resetAllPrompts } from './prompts.js'
|
|
20
20
|
import { statsView } from './stats.js'
|
|
21
21
|
import { recallCacheStats } from './recall-cache.js'
|
|
22
|
+
import { rtServiceDiagnostics } from './rt-index-service.js'
|
|
23
|
+
import { lexiconRtDiagnostics } from './lexicon-rt.js'
|
|
24
|
+
import { graphAdjacencyDiagnostics } from './graph-adjacency-index.js'
|
|
25
|
+
import { diagnosticGraphAdjacency } from './diagnostic-context.js'
|
|
22
26
|
import { getMemuConfig, saveMemuConfig, setEmbeddingSource, testMemuConfig, getSummaryConfig, getVisionConfig } from './memu-config.js'
|
|
23
27
|
import { getLocalVectorState, downloadLocalVectorModel, installLocalVectorRuntime, selectLocalVectorModel, switchLocalVectorProfile, rollbackLocalVectorProfile, abortLocalVectorMigration, testLocalVector } from './local-vector-service.js'
|
|
24
28
|
import { webUiHtml, WEBUI_PATH, standaloneHtml, standaloneAssetResponse, SETTINGS_PATH } from './webui.js'
|
|
25
|
-
import { getGraph, graphDomain, listEntities, createEntity, confirmEntities, renameEntity, deleteEntity, mergeEntities, suggestEntityMerges, linkEntries, unlinkEntry, purgeAutoLinks, getRelationship, updateRelationship, graphExport, restoreGraphData } from './graph.js'
|
|
29
|
+
import { getGraph, getGraphOverview, graphDomain, listEntities, createEntity, confirmEntities, renameEntity, deleteEntity, mergeEntities, suggestEntityMerges, suggestEntityMergeReviews, setEntityMergeRejection, linkEntries, unlinkEntry, purgeAutoLinks, getRelationship, updateRelationship, graphExport, restoreGraphData } from './graph.js'
|
|
26
30
|
import { generateAnchorCandidates, resetAnchorCandidatesCache } from './auto-link/candidates.js'
|
|
27
31
|
import { refreshPrivateAutoLinks } from './private-links.js'
|
|
28
32
|
import { refreshEntityMentions } from './auto-link/apply.js'
|
|
@@ -32,11 +36,12 @@ import { listEvents, logStats, clearEvents, record } from './activity-log.js'
|
|
|
32
36
|
import { redactSecrets, warn } from './paths.js'
|
|
33
37
|
import {
|
|
34
38
|
listDiagnostics, diagnosticStats, diagnosticAlerts, acknowledgeDiagnostics, clearDiagnostics,
|
|
35
|
-
diagnosticsDir as diagnosticsDirectory,
|
|
39
|
+
diagnosticsDir as diagnosticsDirectory, diagnosticRuntime, recordErrorDiagnostic,
|
|
36
40
|
} from './diagnostics.js'
|
|
37
|
-
import { runEnvironmentCheck, repairEnvironment, SAFE_REPAIRS, MANUAL_REPAIRS, REPAIR_LABELS } from './environment-check.js'
|
|
41
|
+
import { runEnvironmentCheck, repairEnvironment, collectDiagnosticReport, SAFE_REPAIRS, MANUAL_REPAIRS, REPAIR_LABELS } from './environment-check.js'
|
|
38
42
|
import { ALL_LEXICON_ID, GLOBAL_LEXICON_ID } from './lexicon.js'
|
|
39
43
|
import { lexiconSearch, lexiconSources } from './lexicon-scope.js'
|
|
44
|
+
import { pageIndexSources } from './index-pages.js'
|
|
40
45
|
|
|
41
46
|
let rejectionGuardWarned = false
|
|
42
47
|
|
|
@@ -98,6 +103,15 @@ function requireSessionId(payload) {
|
|
|
98
103
|
return id.trim()
|
|
99
104
|
}
|
|
100
105
|
|
|
106
|
+
// Browser graph actions carry a session id as JSON, while the graph layer uses
|
|
107
|
+
// the same execution context as memory reads/writes for scope and visibility.
|
|
108
|
+
// Keep direct in-process callers compatible, but never let an HTTP session
|
|
109
|
+
// silently degrade into session-less entity management.
|
|
110
|
+
function graphArgs(payload) {
|
|
111
|
+
if (payload?.sessionId === undefined) return payload || {}
|
|
112
|
+
return { ...payload, exec: execFor(requireSessionId(payload)) }
|
|
113
|
+
}
|
|
114
|
+
|
|
101
115
|
// Browser-facing library routes are authorized at the HTTP boundary. Direct
|
|
102
116
|
// dispatch callers intentionally keep the historical API and do not pass an
|
|
103
117
|
// authorization context. A session id is only trusted when its existing host
|
|
@@ -121,7 +135,8 @@ const LIBRARY_ROUTE_OPERATIONS = new Map([
|
|
|
121
135
|
['browseLibrary', 'read'], ['getMemory', 'read'], ['getStats', 'read'], ['addMemory', 'write'], ['updateMemory', 'write'],
|
|
122
136
|
['importMemories', 'import'], ['exportLibrary', 'export'], ['getAttachment', 'attachment.read'],
|
|
123
137
|
['browseWall', 'read'], ['getGraph', 'read'], ['listEntities', 'read'], ['createEntity', 'write'], ['renameEntity', 'write'],
|
|
124
|
-
['deleteEntity', 'write'], ['mergeEntities', 'write'], ['suggestEntityMerges', 'read'],
|
|
138
|
+
['deleteEntity', 'write'], ['mergeEntities', 'write'], ['suggestEntityMerges', 'read'], ['listEntityMergeReviews', 'read'],
|
|
139
|
+
['setEntityMergeRejection', 'write'],
|
|
125
140
|
// 自动关联的候选队列与实体确认同样按库鉴权:未登记的端点会被直接放行。
|
|
126
141
|
['getAnchorCandidates', 'read'], ['confirmEntities', 'write'], ['purgeAutoLinks', 'write'], ['clearLinkSuppression', 'write'],
|
|
127
142
|
['linkEntries', 'write'], ['unlinkEntry', 'write'], ['getRelationship', 'read'], ['updateRelationship', 'write'],
|
|
@@ -321,6 +336,7 @@ function lexiconTermView(e) {
|
|
|
321
336
|
id: e.id,
|
|
322
337
|
term: e.term,
|
|
323
338
|
kind: e.kind || 'term',
|
|
339
|
+
domain: graphDomain(e.domain || (e.libraryId === GLOBAL_LEXICON_ID ? 'unknown' : 'general')),
|
|
324
340
|
meaning: String(e.meaning || '').slice(0, 2000),
|
|
325
341
|
usage: String(e.usage || '').slice(0, 800),
|
|
326
342
|
aliases: Array.isArray(e.aliases) ? e.aliases.slice(0, 20) : [],
|
|
@@ -357,24 +373,29 @@ function lexiconFilterPage(rows, payload) {
|
|
|
357
373
|
const kind = String(payload?.kind || '')
|
|
358
374
|
const sensitivity = String(payload?.sensitivity || '')
|
|
359
375
|
const q = String(payload?.q || '').trim().toLowerCase()
|
|
376
|
+
const domain = graphDomain(payload?.domain)
|
|
377
|
+
const entryDomain = e => graphDomain(e.domain || (e.libraryId === GLOBAL_LEXICON_ID ? 'unknown' : 'general'))
|
|
378
|
+
const domains = [...new Set(rows.map(entryDomain))].sort()
|
|
379
|
+
const domainCounts = Object.fromEntries(domains.map(name => [name, 0]))
|
|
360
380
|
const statusCounts = { active: 0, archived: 0 }
|
|
361
381
|
for (const e of rows) statusCounts[e.status] += 1
|
|
362
382
|
const selected = rows
|
|
363
383
|
.filter((e) => !status || e.status === status)
|
|
364
384
|
.filter((e) => !sensitivity || e.sensitivity === sensitivity)
|
|
365
385
|
.filter((e) => !q || [e.term, e.meaning, e.usage, ...(Array.isArray(e.aliases) ? e.aliases : [])].join('\n').toLowerCase().includes(q))
|
|
386
|
+
for (const e of selected) if (!kind || e.kind === kind) domainCounts[entryDomain(e)]++
|
|
366
387
|
// 总览计数行只跟随 kind 以外的过滤:kind 标签上的数字才是"点了会变"的实时数。
|
|
367
388
|
const counts = { slang: 0, meme: 0, trigger: 0, term: 0 }
|
|
368
|
-
for (const e of selected) if (counts[e.kind] !== undefined) counts[e.kind] += 1
|
|
389
|
+
for (const e of selected) if ((!domain || entryDomain(e) === domain) && counts[e.kind] !== undefined) counts[e.kind] += 1
|
|
369
390
|
// updatedAt 倒序;同一时间戳按 id 兜底——分页与多端渲染的顺序必须可复现。
|
|
370
|
-
const filtered = selected.filter((e) => !kind || e.kind === kind)
|
|
391
|
+
const filtered = selected.filter((e) => (!kind || e.kind === kind) && (!domain || entryDomain(e) === domain))
|
|
371
392
|
.sort((a, b) => String(b.updatedAt || b.createdAt || '').localeCompare(String(a.updatedAt || a.createdAt || ''))
|
|
372
393
|
|| String(a.id).localeCompare(String(b.id)))
|
|
373
394
|
const pageSize = Math.max(1, Math.min(200, Number(payload?.pageSize) || 50))
|
|
374
395
|
const total = filtered.length
|
|
375
396
|
const pages = Math.max(1, Math.ceil(total / pageSize))
|
|
376
397
|
const page = Math.min(pages, Math.max(1, Number(payload?.page) || 1))
|
|
377
|
-
return { rows: filtered.slice((page - 1) * pageSize, page * pageSize), total, page, pages, pageSize, counts, statusCounts }
|
|
398
|
+
return { rows: filtered.slice((page - 1) * pageSize, page * pageSize), total, page, pages, pageSize, counts, statusCounts, domain, domains, domainCounts }
|
|
378
399
|
}
|
|
379
400
|
|
|
380
401
|
// 导入合并(§4.4)。冲突判定用核心层自己的 normalizeLexeme(与存储同源,零漂移):
|
|
@@ -490,7 +511,7 @@ async function mergeLexiconImport(libraryId, member) {
|
|
|
490
511
|
// List one library's memories. Retrieval needs the MemU engine, but the sidecar
|
|
491
512
|
// index holds the same rows, so an engine that is still installing (or broken)
|
|
492
513
|
// degrades to the index instead of failing the browser.
|
|
493
|
-
async function privateListView(scope, { limit = null, previewChars = 4000 } = {}) {
|
|
514
|
+
async function privateListView(scope, { limit = null, offset = 0, snapshotRevision = null, status = null, domain = null, query = '', previewChars = 4000 } = {}) {
|
|
494
515
|
const libraryId = scope.libraryId ?? getSessionBinding(scope.exec ? scope.exec?.agent?.session?.header?.id : null)?.libraryId
|
|
495
516
|
// 4000 的上限原本是"预览"口径,但浏览库的卡片是可编辑的 textarea:正文一旦
|
|
496
517
|
// 被截断,用户改一个字保存就会把尾部丢掉。列表默认仍是 4000(侧栏轻量预览),
|
|
@@ -550,13 +571,15 @@ async function privateListView(scope, { limit = null, previewChars = 4000 } = {}
|
|
|
550
571
|
.localeCompare(String(a.updatedAt || a.createdAt || ''))
|
|
551
572
|
|| String(a.id).localeCompare(String(b.id))
|
|
552
573
|
try {
|
|
553
|
-
const result = await privateList({ ...scope, preferIndex: true })
|
|
574
|
+
const result = await privateList({ ...scope, preferIndex: true, limit: itemLimit, offset, snapshotRevision, status, domain, query })
|
|
554
575
|
const files = (result.files || []).map((f) => shape(f.libraryId || libraryId, f.name, f.entry, f.content, f.libraryName)).sort(newestFirst)
|
|
555
576
|
return {
|
|
556
577
|
libraryId: result.libraryId,
|
|
557
578
|
...(result.libraries ? { libraries: result.libraries } : {}),
|
|
558
579
|
source: result.source || 'engine',
|
|
559
|
-
|
|
580
|
+
total: result.total ?? files.length, offset: result.offset || 0, snapshotRevision: result.snapshotRevision,
|
|
581
|
+
domains: result.domains, counts: result.counts,
|
|
582
|
+
files,
|
|
560
583
|
}
|
|
561
584
|
} catch (error) {
|
|
562
585
|
if (error?.code !== 'MEMU_ENGINE_NOT_READY') throw error
|
|
@@ -852,6 +875,9 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
852
875
|
globalCount: globalEntries.filter((e) => (e.status || 'active') === 'active').length,
|
|
853
876
|
jobs: listCurationJobs().slice(-10),
|
|
854
877
|
recallCache: recallCacheStats(),
|
|
878
|
+
rtIndex: rtServiceDiagnostics(),
|
|
879
|
+
lexiconRt: lexiconRtDiagnostics(),
|
|
880
|
+
graphAdjacency: diagnosticGraphAdjacency(graphAdjacencyDiagnostics()),
|
|
855
881
|
// docs/host-versions.md §13.6:宿主接口形状的诊断信息,不参与运行分支判断。
|
|
856
882
|
hostSurface: hostSurface(),
|
|
857
883
|
}
|
|
@@ -1148,12 +1174,16 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1148
1174
|
case 'resetSettings': {
|
|
1149
1175
|
const patch = {}
|
|
1150
1176
|
for (const key of [
|
|
1151
|
-
'autoInject', 'privateTopK', 'globalTopK', 'crossLibraryRecall', 'anchorTokens', 'turnTokens', 'injectionTotalTokens', 'dedupeTurns',
|
|
1177
|
+
'autoInject', 'privateTopK', 'globalTopK', 'crossLibraryRecall', 'anchorTokens', 'turnTokens', 'injectionTotalTokens', 'relevanceThreshold', 'dedupeTurns',
|
|
1152
1178
|
'globalEveryNTurns', 'minUserChars', 'mustRememberCap', 'randomCueChance',
|
|
1153
1179
|
'autoInstallEngine', 'newSessionPromptDismissed', 'newSessionDefault', 'habitsInjection',
|
|
1180
|
+
// 引擎下载源:恢复默认 = 自动(国内镜像优先)+ 不启用滚动版本 + 无自定义镜像。
|
|
1181
|
+
'engineSource', 'engineUvMirror', 'enginePythonMirror', 'engineAllowUnpinned',
|
|
1154
1182
|
'sleepConsolidation', 'sleepAfterIdleMinutes', 'autoCurateEveryHours',
|
|
1155
1183
|
'autoCurateSessionLimit', 'purgeArchivedAfterDays', 'memoryMode',
|
|
1156
1184
|
'shortTermTtlHours',
|
|
1185
|
+
'midTurnRecall', 'midTurnMinSteps', 'midTurnMinUnits', 'midTurnMinChars',
|
|
1186
|
+
'midTurnMaxPerTurn', 'midTurnCooldownMs', 'midTurnTokens', 'midTurnFullUnits', 'midTurnFullChars',
|
|
1157
1187
|
'sidebarSettings', 'visionCaptionEnabled',
|
|
1158
1188
|
'inboundToolNames',
|
|
1159
1189
|
// 全局提炼的审核模式(spec §6.1):恢复默认 = 回到 auto,不保留全审状态。
|
|
@@ -1168,6 +1198,11 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1168
1198
|
'autoLinkMode', 'allowWorkerAssertion',
|
|
1169
1199
|
// 增量回合日志(设计文档 §10.1):恢复默认 = on + 纯对话档。
|
|
1170
1200
|
'consolidationTurnLog', 'consolidationTurnLogTools',
|
|
1201
|
+
'retentionDryRun', 'retentionBoundTurnLogsEnabled', 'retentionBoundTurnLogDays',
|
|
1202
|
+
'retentionOrphanTurnLogsEnabled', 'retentionOrphanTurnLogDays',
|
|
1203
|
+
'retentionMaintenanceLedgerEnabled', 'retentionMaintenanceLedgerDays',
|
|
1204
|
+
'retentionSessionBindingsEnabled', 'retentionSessionBindingDays',
|
|
1205
|
+
'retentionVectorPruneEnabled', 'retentionVectorKeepGenerations', 'retentionVectorDays',
|
|
1171
1206
|
// 整理执行器(T1 §10.2):恢复默认 = 回到 'fork'(现状每窗新 fork)。
|
|
1172
1207
|
'consolidationRunner',
|
|
1173
1208
|
// 升级后的一次性实体碎片自愈:恢复默认 = 开(只合可证明的那一类)。
|
|
@@ -1185,6 +1220,9 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1185
1220
|
// the 'both' fallback that the dismissed branch then applied.
|
|
1186
1221
|
'mustRememberCap', 'randomCueChance', 'newSessionPromptDismissed', 'newSessionDefault', 'curatorModel',
|
|
1187
1222
|
'autoInstallEngine', 'pipIndexes',
|
|
1223
|
+
// 引擎下载源:不在名单里,设置页的「引擎下载源 / 自定义镜像 / 允许镜像最新」
|
|
1224
|
+
// 就是空头承诺——patch 会被静默丢弃(midTurnRecall 的旧教训)。
|
|
1225
|
+
'engineSource', 'engineUvMirror', 'enginePythonMirror', 'engineAllowUnpinned',
|
|
1188
1226
|
'sleepConsolidation', 'sleepAfterIdleMinutes', 'autoCurateEveryHours', 'autoCurateSessionLimit',
|
|
1189
1227
|
'memoryMode', 'memoryBackend', 'habitsInjection', 'purgeArchivedAfterDays',
|
|
1190
1228
|
'shortTermTtlHours',
|
|
@@ -1206,6 +1244,11 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1206
1244
|
'autoLinkMode', 'allowWorkerAssertion',
|
|
1207
1245
|
// 增量回合日志(设计文档 §10.1):on/off + 工具行三档(none/errors/summary)。
|
|
1208
1246
|
'consolidationTurnLog', 'consolidationTurnLogTools',
|
|
1247
|
+
'retentionDryRun', 'retentionBoundTurnLogsEnabled', 'retentionBoundTurnLogDays',
|
|
1248
|
+
'retentionOrphanTurnLogsEnabled', 'retentionOrphanTurnLogDays',
|
|
1249
|
+
'retentionMaintenanceLedgerEnabled', 'retentionMaintenanceLedgerDays',
|
|
1250
|
+
'retentionSessionBindingsEnabled', 'retentionSessionBindingDays',
|
|
1251
|
+
'retentionVectorPruneEnabled', 'retentionVectorKeepGenerations', 'retentionVectorDays',
|
|
1209
1252
|
// 整理执行器(T1 §10.2):'fork'(默认,现状)/ 'worker'(持久整理 worker)。
|
|
1210
1253
|
'consolidationRunner',
|
|
1211
1254
|
// 升级自愈的可写 kill switch:不在名单里,设置页那句「可关」就是空头承诺
|
|
@@ -1393,13 +1436,16 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1393
1436
|
if (!binding) return { files: [] }
|
|
1394
1437
|
return privateListView({ exec: execFor(sessionId) }, {
|
|
1395
1438
|
limit: payload?.limit,
|
|
1439
|
+
offset: payload?.offset,
|
|
1440
|
+
snapshotRevision: payload?.snapshotRevision,
|
|
1396
1441
|
previewChars: payload?.previewChars,
|
|
1397
1442
|
})
|
|
1398
1443
|
}
|
|
1399
1444
|
case 'browseLibrary': {
|
|
1400
1445
|
const id = String(payload?.libraryId || '')
|
|
1401
1446
|
if (!getLibrary(id)) throw new Error('library not found')
|
|
1402
|
-
return privateListView({ libraryId: id }
|
|
1447
|
+
return privateListView({ libraryId: id }, { limit: payload?.limit, offset: payload?.offset,
|
|
1448
|
+
snapshotRevision: payload?.snapshotRevision, status: payload?.status, domain: graphDomain(payload?.domain), query: payload?.query })
|
|
1403
1449
|
}
|
|
1404
1450
|
case 'getMemory': {
|
|
1405
1451
|
// One entry, for the memory wall's in-place drawer. Reading the whole library
|
|
@@ -1601,16 +1647,25 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1601
1647
|
if (libraries.some(library => !library)) throw new Error('library not found')
|
|
1602
1648
|
const domainFilter = graphDomain(payload?.domain)
|
|
1603
1649
|
const items = []
|
|
1604
|
-
const domains = new Set()
|
|
1605
1650
|
const errors = []
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1651
|
+
const sources = []
|
|
1652
|
+
for (const library of libraries) {
|
|
1653
|
+
try { sources.push({ scope: 'private', libraryId: library.id, library, index: readPrivateIndex(library.id) }) }
|
|
1654
|
+
catch { errors.push({ libraryId: library.id, error: 'memory index unavailable' }) }
|
|
1655
|
+
}
|
|
1656
|
+
try { sources.push({ scope: 'global', libraryId: null, library: null, index: readGlobalIndex() }) }
|
|
1657
|
+
catch { errors.push({ libraryId: null, error: 'global index unavailable' }) }
|
|
1658
|
+
const limit = Math.max(1, Math.min(5000, Number(payload?.limit) || 300))
|
|
1659
|
+
const offset = Math.max(0, Math.floor(Number(payload?.offset) || 0))
|
|
1660
|
+
const page = pageIndexSources({ sources, limit, offset, domain: domainFilter, snapshotRevision: payload?.snapshotRevision,
|
|
1661
|
+
viewKey: 'browseWall', status: payload?.status || null, query: payload?.query || '',
|
|
1662
|
+
})
|
|
1663
|
+
for (const { id, entry, source } of page.rows) {
|
|
1664
|
+
const lib = source.library
|
|
1608
1665
|
// An unstamped legacy entry reads as `general` in the private graph and
|
|
1609
1666
|
// `unknown` in the global one (graph.js / listGlobal). The wall shows both
|
|
1610
1667
|
// scopes side by side, so it keeps that split instead of inventing a third.
|
|
1611
1668
|
const domain = graphDomain(entry.domain) || (lib ? 'general' : 'unknown')
|
|
1612
|
-
domains.add(domain)
|
|
1613
|
-
if (domainFilter && domain !== domainFilter) continue
|
|
1614
1669
|
items.push({
|
|
1615
1670
|
id, title: entry.title || '', preview: String(entry.content || '').slice(0, 180),
|
|
1616
1671
|
libraryId: lib?.id || null, libraryName: lib?.name || 'global',
|
|
@@ -1635,10 +1690,6 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1635
1690
|
// (no url), so the wall never fetches their pixels.
|
|
1636
1691
|
attachments: lib && entry.attachments?.length ? attachmentPreview(lib.id, entry) : [],
|
|
1637
1692
|
})
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
for (const library of libraries) {
|
|
1641
|
-
try { collect(loadPrivateIndex(library.id), library) } catch { errors.push({ libraryId: library.id, error: 'memory index unavailable' }) }
|
|
1642
1693
|
}
|
|
1643
1694
|
// Global memory is shared across libraries and the wall always exposes a
|
|
1644
1695
|
// global scope. Include it even when a single private library was selected:
|
|
@@ -1646,64 +1697,78 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1646
1697
|
// global rows are not library-private data. Without this, the standalone
|
|
1647
1698
|
// single-library fallback (hosts that deny the all-libraries read) shows an
|
|
1648
1699
|
// empty global scope.
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
// 分页:记忆墙按 offset 逐批取,不再在 300 条处截断。5000 只是防一次请求
|
|
1652
|
-
// 把整库塞进一个 JSON 的上限(当前最大库 417 条,一条流就能读完)。
|
|
1653
|
-
const limit = Math.max(1, Math.min(5000, Number(payload?.limit) || 300))
|
|
1654
|
-
const offset = Math.max(0, Math.floor(Number(payload?.offset) || 0))
|
|
1655
|
-
return { items: items.slice(offset, offset + limit), total: items.length, offset, domains: [...domains].sort(), libraries, errors }
|
|
1700
|
+
return { items, total: page.total, offset, snapshotRevision: page.snapshotRevision,
|
|
1701
|
+
domains: page.domains, counts: page.counts, libraries, errors }
|
|
1656
1702
|
}
|
|
1657
|
-
case 'getGraph':
|
|
1703
|
+
case 'getGraph': {
|
|
1658
1704
|
// Reuse the private graph endpoint instead of adding a second read method:
|
|
1659
1705
|
// the authorization map and RPC method count stay unchanged. Global edges
|
|
1660
1706
|
// have no entity store, so the module is loaded lazily like unlink.
|
|
1661
|
-
|
|
1707
|
+
const args = payload?.sessionId === undefined ? (payload || {})
|
|
1708
|
+
: { ...payload, exec: execFor(requireSessionId(payload)) }
|
|
1709
|
+
if (args.scope === 'global') {
|
|
1710
|
+
if (payload?.sessionId !== undefined) {
|
|
1711
|
+
const binding = getSessionBinding(requireSessionId(payload))
|
|
1712
|
+
if (!binding || effectiveScope(binding).useGlobal !== true) throw new Error('global memory is disabled in this session')
|
|
1713
|
+
}
|
|
1662
1714
|
const globalGraph = await globalGraphApi()
|
|
1663
|
-
return globalGraph.
|
|
1715
|
+
if (args.overview === true) return globalGraph.getGlobalGraphOverview(args)
|
|
1716
|
+
return globalGraph.getGlobalGraph(args)
|
|
1664
1717
|
}
|
|
1665
|
-
|
|
1718
|
+
if (args.overview === true) return getGraphOverview(args)
|
|
1719
|
+
return getGraph(args)
|
|
1720
|
+
}
|
|
1666
1721
|
case 'listEntities':
|
|
1667
|
-
return listEntities(payload
|
|
1722
|
+
return listEntities(graphArgs(payload))
|
|
1668
1723
|
case 'createEntity': {
|
|
1669
1724
|
// 手工创建就是一次用户断言:直接 confirmed,并立刻挂上提及边。
|
|
1670
|
-
const
|
|
1725
|
+
const args = graphArgs(payload)
|
|
1726
|
+
const entity = createEntity({ ...args, status: 'confirmed', confirmedBy: 'user', origin: 'user' })
|
|
1671
1727
|
if (entity?.status === 'confirmed') {
|
|
1672
1728
|
let suppression = null
|
|
1673
1729
|
try { suppression = suppressionSet(payload?.libraryId) } catch {}
|
|
1674
1730
|
try {
|
|
1675
|
-
refreshEntityMentions({ libraryId: payload?.libraryId, entity, suppression,
|
|
1731
|
+
refreshEntityMentions({ libraryId: payload?.libraryId, entity, suppression,
|
|
1732
|
+
sessionId: payload?.sessionId === undefined ? null : requireSessionId(payload), operation: 'auto-link-create' })
|
|
1676
1733
|
} catch {}
|
|
1677
1734
|
resetAnchorCandidatesCache()
|
|
1678
1735
|
}
|
|
1679
1736
|
return entity
|
|
1680
1737
|
}
|
|
1681
1738
|
case 'renameEntity':
|
|
1682
|
-
return renameEntity(payload
|
|
1739
|
+
return renameEntity(graphArgs(payload))
|
|
1683
1740
|
case 'deleteEntity':
|
|
1684
|
-
return deleteEntity(payload
|
|
1741
|
+
return deleteEntity(graphArgs(payload))
|
|
1685
1742
|
case 'mergeEntities':
|
|
1686
|
-
return mergeEntities(payload
|
|
1743
|
+
return mergeEntities(graphArgs(payload))
|
|
1687
1744
|
case 'suggestEntityMerges':
|
|
1688
|
-
return suggestEntityMerges(payload
|
|
1745
|
+
return suggestEntityMerges(graphArgs(payload))
|
|
1746
|
+
case 'listEntityMergeReviews':
|
|
1747
|
+
return suggestEntityMergeReviews(graphArgs(payload))
|
|
1748
|
+
case 'setEntityMergeRejection':
|
|
1749
|
+
return setEntityMergeRejection(graphArgs(payload))
|
|
1689
1750
|
case 'getAnchorCandidates':
|
|
1690
1751
|
// 派生数据:只读记忆/实体/词典,生成本库的待确认队列快照。
|
|
1691
|
-
return generateAnchorCandidates({
|
|
1752
|
+
return generateAnchorCandidates({ ...graphArgs(payload), force: payload?.force === true })
|
|
1692
1753
|
case 'confirmEntities': {
|
|
1693
1754
|
// 人工确认是唯一入口:确认后同步补挂提及边(增量 R1),不等下次整理。
|
|
1694
|
-
const
|
|
1755
|
+
const args = graphArgs(payload)
|
|
1756
|
+
const result = confirmEntities({ exec: args.exec, libraryId: args.libraryId, entityIds: args.entityIds, by: 'user' })
|
|
1695
1757
|
resetAnchorCandidatesCache()
|
|
1696
1758
|
return result
|
|
1697
1759
|
}
|
|
1698
1760
|
case 'purgeAutoLinks': {
|
|
1699
1761
|
// 关系图的“删除全部自动边”:只删 source:'auto',并写抑制键防复活。
|
|
1700
|
-
const
|
|
1762
|
+
const args = graphArgs(payload)
|
|
1763
|
+
const result = purgeAutoLinks(args)
|
|
1701
1764
|
resetAnchorCandidatesCache()
|
|
1702
1765
|
return result
|
|
1703
1766
|
}
|
|
1704
1767
|
case 'clearLinkSuppression': {
|
|
1705
1768
|
// 反向操作:清除本库的删除标记;deterministic 模式下顺带全量重算一次。
|
|
1706
|
-
const
|
|
1769
|
+
const args = graphArgs(payload)
|
|
1770
|
+
if (args.exec) throw new Error('whole-library link maintenance requires explicit management access')
|
|
1771
|
+
const result = clearSuppression(args.libraryId)
|
|
1707
1772
|
let rebuilt = null
|
|
1708
1773
|
try {
|
|
1709
1774
|
rebuilt = await refreshPrivateAutoLinks({ libraryId: payload?.libraryId, full: true })
|
|
@@ -1714,21 +1779,23 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1714
1779
|
return { ...result, rebuilt: rebuilt?.applied ? (rebuilt.applied.added + rebuilt.applied.updated) : 0, skipped: rebuilt?.skipped || null }
|
|
1715
1780
|
}
|
|
1716
1781
|
case 'linkEntries':
|
|
1717
|
-
return linkEntries(payload
|
|
1782
|
+
return linkEntries(graphArgs(payload))
|
|
1718
1783
|
case 'unlinkEntry':
|
|
1719
|
-
return unlinkEntry(payload
|
|
1784
|
+
return unlinkEntry(graphArgs(payload))
|
|
1720
1785
|
case 'getRelationship':
|
|
1721
|
-
return getRelationship(payload
|
|
1786
|
+
return getRelationship(graphArgs(payload))
|
|
1722
1787
|
case 'updateRelationship':
|
|
1723
|
-
return updateRelationship(payload
|
|
1788
|
+
return updateRelationship(graphArgs(payload))
|
|
1724
1789
|
case 'listGlobal': {
|
|
1725
1790
|
const sessionId = payload?.sessionId || null
|
|
1726
1791
|
const exec = sessionId ? execFor(sessionId) : { agent: null }
|
|
1727
1792
|
try {
|
|
1728
|
-
const result = await globalList({ exec, domain: payload?.domain, preferIndex: true
|
|
1793
|
+
const result = await globalList({ exec, domain: payload?.domain, preferIndex: true,
|
|
1794
|
+
limit: payload?.limit, offset: payload?.offset, snapshotRevision: payload?.snapshotRevision })
|
|
1729
1795
|
return {
|
|
1730
1796
|
warning: result.warning || null,
|
|
1731
1797
|
source: result.source || null,
|
|
1798
|
+
total: result.total, offset: result.offset, snapshotRevision: result.snapshotRevision,
|
|
1732
1799
|
files: (result.files || []).map((f) => ({
|
|
1733
1800
|
id: f.name,
|
|
1734
1801
|
title: f.entry?.title || f.description || '',
|
|
@@ -1873,6 +1940,7 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1873
1940
|
pageSize: view.pageSize,
|
|
1874
1941
|
counts: view.counts,
|
|
1875
1942
|
statusCounts: view.statusCounts,
|
|
1943
|
+
domain: view.domain, domains: view.domains, domainCounts: view.domainCounts,
|
|
1876
1944
|
errors,
|
|
1877
1945
|
}
|
|
1878
1946
|
}
|
|
@@ -1880,7 +1948,7 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1880
1948
|
const data = lexicon.loadLexicon(libraryId)
|
|
1881
1949
|
// 公开两态(§2.1):pending/rejected 是内部状态与墓碑,列表永不返回。
|
|
1882
1950
|
const rows = Object.entries(data.terms || {})
|
|
1883
|
-
.map(([termId, e]) => ({ ...e, id: termId, status: e?.status || 'active' }))
|
|
1951
|
+
.map(([termId, e]) => ({ ...e, id: termId, libraryId, status: e?.status || 'active' }))
|
|
1884
1952
|
.filter((e) => LEXICON_PUBLIC_STATUSES.includes(e.status))
|
|
1885
1953
|
const view = lexiconFilterPage(rows, payload)
|
|
1886
1954
|
return {
|
|
@@ -1894,6 +1962,7 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1894
1962
|
pageSize: view.pageSize,
|
|
1895
1963
|
counts: view.counts,
|
|
1896
1964
|
statusCounts: view.statusCounts,
|
|
1965
|
+
domain: view.domain, domains: view.domains, domainCounts: view.domainCounts,
|
|
1897
1966
|
}
|
|
1898
1967
|
}
|
|
1899
1968
|
case 'lexiconSearch': {
|
|
@@ -2286,7 +2355,10 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
2286
2355
|
...listDiagnostics({ limit: payload?.limit, level: payload?.level, scope: payload?.scope, q: payload?.q, since: payload?.since }),
|
|
2287
2356
|
stats: diagnosticStats(),
|
|
2288
2357
|
dir: diagnosticsDirectory(),
|
|
2358
|
+
runtime: diagnosticRuntime(),
|
|
2289
2359
|
}
|
|
2360
|
+
case 'getDiagnosticReport':
|
|
2361
|
+
return collectDiagnosticReport({ limit: payload?.limit })
|
|
2290
2362
|
case 'getDiagnosticAlerts':
|
|
2291
2363
|
return diagnosticAlerts()
|
|
2292
2364
|
case 'acknowledgeDiagnostics':
|
|
@@ -2366,7 +2438,11 @@ export function registerRpc(ctx) {
|
|
|
2366
2438
|
try {
|
|
2367
2439
|
const payload = await dispatch(ctx, 'exportLibrary', { libraryId: exportMatch[1] })
|
|
2368
2440
|
await streamMediaExport(exportMatch[1], payload, res)
|
|
2369
|
-
} catch
|
|
2441
|
+
} catch (error) {
|
|
2442
|
+
recordErrorDiagnostic(error, { code: 'RPC_EXPORT_FAILED', scope: 'rpc', source: 'rpc', operation: 'export', alert: false,
|
|
2443
|
+
context: { sessionId, libraryId: exportMatch[1] } })
|
|
2444
|
+
if (!res.headersSent) { res.writeHead(400); res.end('attachment export unavailable') }
|
|
2445
|
+
}
|
|
2370
2446
|
return
|
|
2371
2447
|
}
|
|
2372
2448
|
const importMatch = /^\/dsh-memu-memory\/import\/([A-Za-z0-9._-]+)\.zip$/.exec(pathname)
|
|
@@ -2382,6 +2458,8 @@ export function registerRpc(ctx) {
|
|
|
2382
2458
|
res.writeHead(200, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' })
|
|
2383
2459
|
res.end(JSON.stringify({ ok: true, value: { ...value, missingAttachments: bundle.missing } }))
|
|
2384
2460
|
} catch (error) {
|
|
2461
|
+
recordErrorDiagnostic(error, { code: 'RPC_IMPORT_FAILED', scope: 'rpc', source: 'rpc', operation: 'import', alert: false,
|
|
2462
|
+
context: { sessionId, libraryId: importMatch[1] } })
|
|
2385
2463
|
res.writeHead(400, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' })
|
|
2386
2464
|
res.end(JSON.stringify({ ok: false, error: { message: rpcErrorMessage(error) } }))
|
|
2387
2465
|
}
|
|
@@ -2422,6 +2500,8 @@ export function registerRpc(ctx) {
|
|
|
2422
2500
|
res.writeHead(200, { 'Content-Type': thumbnail.mime, 'Cache-Control': 'private, no-store', 'X-Content-Type-Options': 'nosniff' })
|
|
2423
2501
|
res.end(thumbnail.data)
|
|
2424
2502
|
} catch (error) {
|
|
2503
|
+
recordErrorDiagnostic(error, { code: 'RPC_ATTACHMENT_FAILED', scope: 'rpc', source: 'rpc', operation: 'read', alert: false,
|
|
2504
|
+
context: { sessionId, libraryId: attachment[1] } })
|
|
2425
2505
|
res.writeHead(error.status || 503, { 'Cache-Control': 'no-store' })
|
|
2426
2506
|
res.end(error.status === 403 ? 'forbidden' : 'attachment unavailable')
|
|
2427
2507
|
}
|
|
@@ -2495,6 +2575,8 @@ export function registerRpc(ctx) {
|
|
|
2495
2575
|
try {
|
|
2496
2576
|
result = { ok: true, value: await dispatch(ctx, endpoint, payload) }
|
|
2497
2577
|
} catch (error) {
|
|
2578
|
+
recordErrorDiagnostic(error, { code: 'RPC_HANDLER_FAILED', scope: 'rpc', source: 'rpc', operation: 'dispatch',
|
|
2579
|
+
correlationId: envelope.rpcId, context: { sessionId: payload.sessionId, libraryId: payload.libraryId }, alert: false })
|
|
2498
2580
|
result = {
|
|
2499
2581
|
ok: false,
|
|
2500
2582
|
error: {
|
|
@@ -2525,6 +2607,7 @@ export function registerRpc(ctx) {
|
|
|
2525
2607
|
})
|
|
2526
2608
|
} catch (error) {
|
|
2527
2609
|
try { ctx.logger?.warn?.(`dsh-memu-memory: rpc unavailable: ${error?.message || error}`) } catch {}
|
|
2610
|
+
recordErrorDiagnostic(error, { code: 'RPC_REGISTRATION_FAILED', scope: 'rpc', source: 'rpc', operation: 'start', alert: false })
|
|
2528
2611
|
}
|
|
2529
2612
|
}
|
|
2530
2613
|
|