dsh-memu-memory 1.2.2 → 1.2.4

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 (58) hide show
  1. package/AGENTS.md +4 -1
  2. package/README.md +12 -16
  3. package/README.zh.md +13 -17
  4. package/docs/client-conventions.md +2 -0
  5. package/docs/contributing.md +7 -6
  6. package/docs/emotion-model-spec.md +2 -2
  7. package/docs/env-and-commands.md +63 -1
  8. package/docs/host-api.md +19 -0
  9. package/docs/memory-semantics.md +10 -1
  10. package/docs/troubleshooting.md +77 -3
  11. package/lib/activity-log.js +1 -1
  12. package/lib/binding-diagnostics.js +1 -1
  13. package/lib/client.js +223 -19
  14. package/lib/cycle.js +9 -1
  15. package/lib/embedding-catalog.js +416 -138
  16. package/lib/embedding-download.js +36 -11
  17. package/lib/freshness.js +97 -0
  18. package/lib/graph.js +244 -2
  19. package/lib/inject.js +218 -11
  20. package/lib/local-embedding-manager.js +3 -2
  21. package/lib/local-embedding-protocol.js +40 -3
  22. package/lib/local-embedding-worker.js +36 -6
  23. package/lib/local-vector-service.js +18 -4
  24. package/lib/memory.js +83 -17
  25. package/lib/memu.js +15 -7
  26. package/lib/private.js +25 -5
  27. package/lib/rpc.js +17 -3
  28. package/lib/salient-wake.js +402 -0
  29. package/lib/state.js +173 -1
  30. package/package.json +3 -2
  31. package/scripts/drive-session.mjs +864 -0
  32. package/scripts/mock-llm.mjs +903 -0
  33. package/scripts/simulate-injection.mjs +298 -0
  34. package/tests/client-render.test.mjs +69 -2
  35. package/tests/consolidation-fork.test.mjs +14 -1
  36. package/tests/drive-session.test.mjs +152 -0
  37. package/tests/embedding-catalog.test.mjs +116 -8
  38. package/tests/embedding-download.test.mjs +97 -2
  39. package/tests/embedding-runtime.test.mjs +21 -13
  40. package/tests/entity-merge.test.mjs +261 -0
  41. package/tests/fixtures/mock-llm/reply.txt +1 -0
  42. package/tests/freshness.test.mjs +140 -0
  43. package/tests/help-page.test.mjs +4 -4
  44. package/tests/injection-chain.test.mjs +176 -0
  45. package/tests/injection-rollback.test.mjs +230 -0
  46. package/tests/local-embedding-env.test.mjs +51 -0
  47. package/tests/local-embedding-manager.test.mjs +18 -0
  48. package/tests/local-embedding-protocol.test.mjs +28 -2
  49. package/tests/local-embedding-worker.test.mjs +94 -0
  50. package/tests/mock-llm.test.mjs +225 -0
  51. package/tests/open-loop-date.test.mjs +406 -0
  52. package/tests/salient-wake.test.mjs +362 -0
  53. package/tests/settings-plumbing.test.mjs +76 -0
  54. package/tests/sidebar.test.mjs +5 -1
  55. package/tests/simulate-injection.test.mjs +76 -0
  56. package/tests/stubs/dsh-schedule.js +105 -0
  57. package/tests/vector-profile.test.mjs +28 -4
  58. package/tests/webui-auth.test.mjs +4 -0
package/lib/memory.js CHANGED
@@ -2770,6 +2770,46 @@ export function noteGlobalInjected({ ids = [], at = stamp() }) {
2770
2770
  return touched
2771
2771
  }
2772
2772
 
2773
+ // Local calendar day (not UTC): "today" for a reminder is the user's today, the same
2774
+ // unit `salientDaysAhead` measures in.
2775
+ function localDateKey(date) {
2776
+ return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`
2777
+ }
2778
+
2779
+ // The overdue leg: dated promises that already slipped their day. Kept out of the
2780
+ // regular filter because it answers a different question (see dueOpenLoops).
2781
+ function overdueDatedOpenLoops(rows, { now, remindDays = 0, remindedAt = {}, excludeIds = new Set() }) {
2782
+ const nowMs = Number(now) || Date.now()
2783
+ const today = new Date(nowMs)
2784
+ const todayKey = localDateKey(today)
2785
+ const remindMs = Math.max(0, Number(remindDays) || 0) * 86_400_000
2786
+ const reminded = remindedAt && typeof remindedAt === 'object' ? remindedAt : {}
2787
+ return rows
2788
+ .filter(([id, entry]) => {
2789
+ if (!entry || excludeIds.has(id)) return false
2790
+ if (!entry.openLoop || entry.marginalized) return false
2791
+ // 'MM-DD' is an anniversary: it recurs on its own and is not a slipped promise.
2792
+ if (!isDatedSalientDate(entry.salientDate)) return false
2793
+ const ahead = salientDaysAhead(entry.salientDate, today)
2794
+ if (ahead === null || ahead >= 0) return false
2795
+ // One gate for archived / suppressed / expired / pending_review / superseded and
2796
+ // for secret bodies: same rule as every other automatic injection surface.
2797
+ if (!isMemoryEligible(entry, { automatic: true, now: nowMs })) return false
2798
+ const last = Date.parse(String(reminded[id] || ''))
2799
+ if (Number.isFinite(last)) {
2800
+ if (localDateKey(new Date(last)) === todayKey) return false
2801
+ if (remindMs > 0 && nowMs - last < remindMs) return false
2802
+ }
2803
+ return true
2804
+ })
2805
+ // Oldest date first: the promise that has been overdue longest is the one that
2806
+ // matters most. Ties fall back to age, then id, so the pick is deterministic.
2807
+ .sort((a, b) => String(a[1].salientDate).localeCompare(String(b[1].salientDate))
2808
+ || String(a[1].updatedAt || a[1].createdAt || '').localeCompare(String(b[1].updatedAt || b[1].createdAt || ''))
2809
+ || a[0].localeCompare(b[0]))
2810
+ .map(([id, entry]) => ({ id, entry, recurring: true }))
2811
+ }
2812
+
2773
2813
  /**
2774
2814
  * Unfinished threads old enough to be worth raising.
2775
2815
  *
@@ -2778,7 +2818,50 @@ export function noteGlobalInjected({ ids = [], at = stamp() }) {
2778
2818
  * retrieving it among four other lines is not the same as resurfacing it, so the
2779
2819
  * injector gets its own small query for this — sorted oldest-first, and never the ones
2780
2820
  * that were already pushed this session.
2821
+ *
2822
+ * Two legs share the result, in this order:
2823
+ *
2824
+ * 1. `includeOverdueDated` adds dated promises that already slipped their day
2825
+ * (`YYYY-MM-DD`, date < local today, `openLoop`). They are *not* subject to the
2826
+ * 3-day age threshold — being a day late is exactly when it matters — and they
2827
+ * are *not* silenced by `skipIds`/`injectedIds`: a promise that was mentioned
2828
+ * once and never closed has to come back. Their own clock is `remindedAt`
2829
+ * (memoryId -> ISO) plus `remindDays`: already repeated today → skip, last
2830
+ * repeat younger than the interval → skip.
2831
+ * 2. The regular leg, unchanged: `openLoop`, not marginalized, eligible, at least
2832
+ * `days` old, not in `skipIds`, not repeated this same turn (`excludeIds`).
2781
2833
  */
2834
+ export function dueOpenLoops({
2835
+ libraryId, days = 3, limit = 1, now = Date.now(), skipIds = [],
2836
+ remindDays = 0, remindedAt = {}, includeOverdueDated = false, excludeIds = [], sessionId = null,
2837
+ }) {
2838
+ if (!libraryId) return []
2839
+ const index = loadPrivateIndex(libraryId)
2840
+ const skip = new Set(skipIds || [])
2841
+ const excluded = new Set(excludeIds || [])
2842
+ // Filtered before the limit, not after: otherwise an entry this conversation may
2843
+ // not see would eat the single slot and leave the block empty.
2844
+ const visible = (entry) => (sessionId ? visibleToSession(entry, sessionId) : true)
2845
+ const rows = Object.entries(index.entries || {})
2846
+ const regular = rows
2847
+ .filter(([id, entry]) => {
2848
+ if (!entry || skip.has(id) || excluded.has(id)) return false
2849
+ if (!entry.openLoop || entry.marginalized) return false
2850
+ if (!isActive(entry)) return false
2851
+ if (!visible(entry)) return false
2852
+ const age = daysSince(entry.updatedAt || entry.createdAt, now)
2853
+ return age !== null && age >= days
2854
+ })
2855
+ .sort((a, b) => String(a[1].updatedAt || a[1].createdAt || '').localeCompare(String(b[1].updatedAt || b[1].createdAt || '')) || a[0].localeCompare(b[0]))
2856
+ .map(([id, entry]) => ({ id, entry, recurring: false }))
2857
+ const overdue = includeOverdueDated
2858
+ ? overdueDatedOpenLoops(rows, { now, remindDays, remindedAt, excludeIds: excluded }).filter(({ entry }) => visible(entry))
2859
+ : []
2860
+ // A dated promise that already slipped outranks a vague 3-day-old loop: the date
2861
+ // is a commitment, the other one is just unfinished.
2862
+ return [...overdue, ...regular].slice(0, Math.max(0, Number(limit) || 0))
2863
+ }
2864
+
2782
2865
  /**
2783
2866
  * Memories a sensory cue may be derived from.
2784
2867
  *
@@ -2822,20 +2905,3 @@ export function cueCandidates({ libraryId, sessionId = null, now = Date.now(), m
2822
2905
  .localeCompare(String(a.entry.updatedAt || a.entry.createdAt || '')))
2823
2906
  .slice(0, Math.max(0, Number(limit) || 0))
2824
2907
  }
2825
-
2826
- export function dueOpenLoops({ libraryId, days = 3, limit = 1, now = Date.now(), skipIds = [] }) {
2827
- if (!libraryId) return []
2828
- const index = loadPrivateIndex(libraryId)
2829
- const skip = new Set(skipIds || [])
2830
- return Object.entries(index.entries || {})
2831
- .filter(([id, entry]) => {
2832
- if (!entry || skip.has(id)) return false
2833
- if (!entry.openLoop || entry.marginalized) return false
2834
- if (!isActive(entry)) return false
2835
- const age = daysSince(entry.updatedAt || entry.createdAt, now)
2836
- return age !== null && age >= days
2837
- })
2838
- .sort((a, b) => String(a[1].updatedAt || a[1].createdAt || '').localeCompare(String(b[1].updatedAt || b[1].createdAt || '')))
2839
- .slice(0, Math.max(0, Number(limit) || 0))
2840
- .map(([id, entry]) => ({ id, entry }))
2841
- }
package/lib/memu.js CHANGED
@@ -6,6 +6,7 @@ import { ENGINE_VERSION, readCurrent, verifyEngine } from './engine.js'
6
6
  import { getSettings } from './state.js'
7
7
  import { activeProfile, captureVectorGeneration, assertVectorGeneration, assertProfileVerified, assertMigrationProfile } from './vector-profile.js'
8
8
  import { embeddingWorkerManager } from './local-embedding-manager.js'
9
+ import { modelIdForRole } from './local-embedding-protocol.js'
9
10
 
10
11
  // MemU's own storage mode. 'local' keeps every row in this plugin's sqlite files;
11
12
  // 'cloud' hands storage to MemU's backend and needs the vendor credentials in
@@ -95,12 +96,12 @@ async function runConfigured(args, options = {}) {
95
96
  return result
96
97
  }
97
98
 
98
- async function envFor({ db, provider, embedModel, baseUrl, apiKey, vectorProfile, route }) {
99
+ async function envFor({ db, provider, embedModel, baseUrl, apiKey, vectorProfile, route, role }) {
99
100
  const profile = route === 'managed-local' ? (vectorProfile || activeProfile()) : null
100
101
  if (profile) {
101
102
  assertProfileVerified(profile)
102
103
  const endpoint = await embeddingWorkerManager().acquire(profile)
103
- return localEmbeddingEnv({ ...endpoint, db })
104
+ return localEmbeddingEnv({ ...endpoint, db, role })
104
105
  }
105
106
  if (route === 'managed-local') throw new MemuError('managed local vector profile is not active', 'VECTOR_NOT_READY')
106
107
  const env = {}
@@ -117,7 +118,7 @@ async function envFor({ db, provider, embedModel, baseUrl, apiKey, vectorProfile
117
118
  // per-process random token (env only, never argv/log/config) and the pinned
118
119
  // embedding model id. Telemetry is switched off explicitly, because "local mode"
119
120
  // alone is not proof that nothing leaves the machine.
120
- export function localEmbeddingEnv({ baseUrl, token, model, db } = {}) {
121
+ export function localEmbeddingEnv({ baseUrl, token, model, rolesRequired, db, role } = {}) {
121
122
  const env = {
122
123
  MEMU_MEMORY_MODE: 'local',
123
124
  MEMU_EMBED_PROVIDER: 'openai',
@@ -127,7 +128,14 @@ export function localEmbeddingEnv({ baseUrl, token, model, db } = {}) {
127
128
  }
128
129
  if (typeof baseUrl === 'string' && baseUrl.trim()) env.MEMU_BASE_URL = baseUrl.trim()
129
130
  if (typeof token === 'string' && token.trim()) env.MEMU_API_KEY = token.trim()
130
- if (typeof model === 'string' && model.trim()) env.MEMU_EMBED_MODEL = model.trim()
131
+ // The embeddings envelope has no role field, so a profile that reads query and
132
+ // document differently carries its role on the model string. Only this side knows
133
+ // which MemU process it is starting, so only this side may say so — and it has to:
134
+ // the worker refuses a bare model id for such a profile rather than guess (§14.4).
135
+ const modelId = rolesRequired === true && typeof model === 'string' && model.trim()
136
+ ? modelIdForRole(model, role === 'query' ? 'query' : 'document')
137
+ : model
138
+ if (typeof modelId === 'string' && modelId.trim()) env.MEMU_EMBED_MODEL = modelId.trim()
131
139
  if (typeof db === 'string' && db.trim()) env.MEMU_DB = db.trim()
132
140
  return env
133
141
  }
@@ -148,7 +156,7 @@ export async function retrieve({ query, db, provider, embedModel, baseUrl, apiKe
148
156
  if (!query || !String(query).trim()) {
149
157
  throw new MemuError('retrieve requires a non-empty query', 'MEMU_BAD_ARGUMENT')
150
158
  }
151
- const res = await runConfigured(['retrieve', String(query), '--json'], { db, provider, embedModel, baseUrl, apiKey, vectorProfile, route, timeoutMs })
159
+ const res = await runConfigured(['retrieve', String(query), '--json'], { db, provider, embedModel, baseUrl, apiKey, vectorProfile, route, timeoutMs, role: 'query' })
152
160
  const data = parseJson(res.stdout)
153
161
  if (data === null) {
154
162
  return { raw: res.stdout.trim(), parseWarning: 'memu retrieve returned non-JSON' }
@@ -157,7 +165,7 @@ export async function retrieve({ query, db, provider, embedModel, baseUrl, apiKe
157
165
  }
158
166
 
159
167
  export async function listFiles({ db, provider, embedModel, baseUrl, apiKey, vectorProfile, route, timeoutMs = 60_000 } = {}) {
160
- const res = await runConfigured(['list-files', '--json'], { db, provider, embedModel, baseUrl, apiKey, vectorProfile, route, timeoutMs })
168
+ const res = await runConfigured(['list-files', '--json'], { db, provider, embedModel, baseUrl, apiKey, vectorProfile, route, timeoutMs, role: 'document' })
161
169
  const data = parseJson(res.stdout)
162
170
  if (data === null) {
163
171
  return { recall_files: [], raw: res.stdout.trim(), parseWarning: 'memu list-files returned non-JSON' }
@@ -170,7 +178,7 @@ export async function commit({ payload, db, provider, embedModel, baseUrl, apiKe
170
178
  const file = path.join(tmpDir, `commit-${process.pid}-${Date.now()}.json`)
171
179
  try {
172
180
  fs.writeFileSync(file, JSON.stringify(payload, null, 2), 'utf8')
173
- const res = await runConfigured(['commit', file, '--json'], { db, provider, embedModel, baseUrl, apiKey, vectorProfile, route, timeoutMs })
181
+ const res = await runConfigured(['commit', file, '--json'], { db, provider, embedModel, baseUrl, apiKey, vectorProfile, route, timeoutMs, role: 'document' })
174
182
  const data = parseJson(res.stdout)
175
183
  if (data === null) {
176
184
  return { raw: res.stdout.trim(), parseWarning: 'memu commit returned non-JSON' }
package/lib/private.js CHANGED
@@ -392,7 +392,25 @@ function snapshotMetaOf(snapshot) {
392
392
  // user's own chat — a queued draft until it runs, then a permanent resident of
393
393
  // that transcript — so the one visible difference between a live and a closed
394
394
  // session is that a closed one has to be read back from disk first.
395
- export async function requestHistoricalConsolidation(ctx, sessionId, { maxWaitMs = 180_000, force = false } = {}) {
395
+ // 一次整理要等多长时间,取决于它要读多少转录:fork 的种子是整段会话,worker 读完才
396
+ // 开始写。实测(2026-11-02,935 条事件的会话):第一次 180 s 到点时刚写完 3 条、
397
+ // 退避重试 131 s 完成——即约 0.14–0.2 s/事件。这里按 0.35 s/事件(≈2 倍余量)推预算,
398
+ // 并夹在 [180 s, 600 s]:小会话维持原来的 3 分钟,大会话不再必然撞墙,卡死的 fork
399
+ // 也仍会在 10 分钟内被收掉。显式传 maxWaitMs 的调用(含工具/测试)原样生效。
400
+ export const CONSOLIDATION_WAIT_POLICY = Object.freeze({
401
+ baseMs: 120_000,
402
+ perEventMs: 350,
403
+ minMs: 180_000,
404
+ maxMs: 600_000,
405
+ })
406
+
407
+ export function consolidationWaitBudget(eventCount, policy = CONSOLIDATION_WAIT_POLICY) {
408
+ const count = Number.isFinite(Number(eventCount)) ? Math.max(0, Math.floor(Number(eventCount))) : 0
409
+ const raw = policy.baseMs + count * policy.perEventMs
410
+ return Math.min(policy.maxMs, Math.max(policy.minMs, raw))
411
+ }
412
+
413
+ export async function requestHistoricalConsolidation(ctx, sessionId, { maxWaitMs = null, force = false } = {}) {
396
414
  const binding = getSessionBinding(sessionId)
397
415
  if (!binding) return { ok: false, error: 'session is not bound to a memory library; bind it first' }
398
416
  if (!binding.libraryId || !effectiveScope(binding).useLibrary) return { ok: false, error: 'private memory is disabled for this session or folder' }
@@ -492,6 +510,8 @@ export async function requestHistoricalConsolidation(ctx, sessionId, { maxWaitMs
492
510
  const snapshot = captured.snapshot
493
511
  const events = captured.events
494
512
  const snapshotMeta = snapshotMetaOf(snapshot)
513
+ // 范围大小决定等多久:显式给了就听调用方的,没给按这段转录的事件数推。
514
+ const budgetMs = Number.isInteger(maxWaitMs) && maxWaitMs > 0 ? maxWaitMs : consolidationWaitBudget(events.length)
495
515
  const generationAtStart = scopeGenerationOf(binding)
496
516
  // 待检查边界与已确认边界分开记:证据到达就记一次,失败不回退。
497
517
  safeLedger(() => noteEvidence({ sessionId, fromSeq: snapshot.fromSeq, throughSeq: snapshot.throughSeq }))
@@ -634,8 +654,8 @@ export async function requestHistoricalConsolidation(ctx, sessionId, { maxWaitMs
634
654
  sessionId,
635
655
  libraryId: binding.libraryId || null,
636
656
  ok: true,
637
- message: '整理已开始 · ' + (force ? '手动' : '空闲') + ' · fork ' + childId.slice(-8) + ' · ' + events.length + ' 条事件 · 快照 ' + snapshot.hash,
638
- detail: { childId, jobId, force, events: events.length, phase: 'started', snapshot: snapshotMeta,
657
+ message: '整理已开始 · ' + (force ? '手动' : '空闲') + ' · fork ' + childId.slice(-8) + ' · ' + events.length + ' 条事件 · 预算 ' + Math.round(budgetMs / 1000) + 's · 快照 ' + snapshot.hash,
658
+ detail: { childId, jobId, force, events: events.length, budgetMs, phase: 'started', snapshot: snapshotMeta,
639
659
  probe: { source: probe.source, hasWrite: probe.hasWrite, ptc: probe.ptcObserved === true },
640
660
  ...workerToolsMeta(workerTools) },
641
661
  })
@@ -726,7 +746,7 @@ export async function requestHistoricalConsolidation(ctx, sessionId, { maxWaitMs
726
746
  let timer = null
727
747
  let outcome
728
748
  try {
729
- const wait = new Promise((resolve) => { timer = setTimeout(() => resolve('timeout'), maxWaitMs) })
749
+ const wait = new Promise((resolve) => { timer = setTimeout(() => resolve('timeout'), budgetMs) })
730
750
  outcome = await Promise.race([idle.then(() => 'done'), wait])
731
751
  } finally { clearTimeout(timer) }
732
752
 
@@ -819,7 +839,7 @@ export async function requestHistoricalConsolidation(ctx, sessionId, { maxWaitMs
819
839
  settled: false,
820
840
  timedOut: true,
821
841
  reasonCode: 'timeout',
822
- error: 'consolidation timed out after ' + Math.round(maxWaitMs / 1000) + 's; the fork was stopped (memories written before the timeout are kept). Retry, or consolidate a shorter conversation.',
842
+ error: 'consolidation timed out after ' + Math.round(budgetMs / 1000) + 's over ' + events.length + ' events; the fork was stopped (memories written before the timeout are kept). Retry, or consolidate a shorter conversation.',
823
843
  })
824
844
  }
825
845
  return finish({
package/lib/rpc.js CHANGED
@@ -18,7 +18,7 @@ import { statsView } from './stats.js'
18
18
  import { getMemuConfig, saveMemuConfig, setEmbeddingSource, testMemuConfig, getSummaryConfig, getVisionConfig } from './memu-config.js'
19
19
  import { getLocalVectorState, downloadLocalVectorModel, installLocalVectorRuntime, selectLocalVectorModel, switchLocalVectorProfile, rollbackLocalVectorProfile, abortLocalVectorMigration, testLocalVector } from './local-vector-service.js'
20
20
  import { webUiHtml, WEBUI_PATH, standaloneHtml, standaloneAsset, SETTINGS_PATH } from './webui.js'
21
- import { getGraph, listEntities, createEntity, renameEntity, deleteEntity, linkEntries, unlinkEntry, getRelationship, updateRelationship, graphExport, restoreGraphData } from './graph.js'
21
+ import { getGraph, listEntities, createEntity, renameEntity, deleteEntity, mergeEntities, suggestEntityMerges, linkEntries, unlinkEntry, getRelationship, updateRelationship, graphExport, restoreGraphData } from './graph.js'
22
22
  import { getAttachment, attachmentThumbnail, attachmentPreview, exportMediaBundle, importMediaBundle, streamMediaExport, importMediaStream } from './media.js'
23
23
  import { listEvents, logStats, clearEvents } from './activity-log.js'
24
24
  import { warn } from './paths.js'
@@ -75,7 +75,8 @@ const LIBRARY_ROUTE_OPERATIONS = new Map([
75
75
  ['browseLibrary', 'read'], ['getMemory', 'read'], ['getStats', 'read'], ['addMemory', 'write'], ['updateMemory', 'write'],
76
76
  ['importMemories', 'import'], ['exportLibrary', 'export'], ['getAttachment', 'attachment.read'],
77
77
  ['browseWall', 'read'], ['getGraph', 'read'], ['listEntities', 'read'], ['createEntity', 'write'], ['renameEntity', 'write'],
78
- ['deleteEntity', 'write'], ['linkEntries', 'write'], ['unlinkEntry', 'write'], ['getRelationship', 'read'], ['updateRelationship', 'write'],
78
+ ['deleteEntity', 'write'], ['mergeEntities', 'write'], ['suggestEntityMerges', 'read'],
79
+ ['linkEntries', 'write'], ['unlinkEntry', 'write'], ['getRelationship', 'read'], ['updateRelationship', 'write'],
79
80
  ['listReviews', 'read'], ['resolveReview', 'write'], ['lexiconList', 'read'], ['lexiconSearch', 'read'], ['lexiconAdd', 'write'],
80
81
  ['lexiconUpdate', 'write'], ['lexiconDelete', 'write'], ['lexiconArchive', 'write'], ['lexiconRestore', 'write'],
81
82
  ['archiveMemory', 'archive'], ['deleteMemory', 'delete'],
@@ -890,6 +891,9 @@ async function dispatch(ctx, endpoint, payload = {}) {
890
891
  'inboundToolNames',
891
892
  // 全局提炼的审核模式(spec §6.1):恢复默认 = 回到 auto,不保留全审状态。
892
893
  'curatorReviewMode',
894
+ // 工单 C/D/E 的调参:没进这张表的 key 会被静默丢弃,设置页就成了死控件。
895
+ 'openLoopRemindDays', 'freshnessHint', 'freshnessDays',
896
+ 'salientWake', 'salientWakeHour', 'salientWakeTimeZone',
893
897
  ]) patch[key] = DEFAULT_SETTINGS[key]
894
898
  return updateSettings(patch)
895
899
  }
@@ -909,6 +913,9 @@ async function dispatch(ctx, endpoint, payload = {}) {
909
913
  'sidebarSettings', 'visionCaptionEnabled', 'inboundToolNames',
910
914
  // 全局提炼的审核模式(spec §6.1):不进 allowlist 的 patch 会被静默丢弃。
911
915
  'curatorReviewMode',
916
+ // 工单 C/D/E:未了之事复提节奏、时效提示、日期唤醒。缺一个就是设置页写了不生效。
917
+ 'openLoopRemindDays', 'freshnessHint', 'freshnessDays',
918
+ 'salientWake', 'salientWakeHour', 'salientWakeTimeZone',
912
919
  ])
913
920
  const clean = {}
914
921
  for (const [k, v] of Object.entries(patch)) if (allowed.has(k)) clean[k] = v
@@ -1242,6 +1249,10 @@ async function dispatch(ctx, endpoint, payload = {}) {
1242
1249
  return renameEntity(payload || {})
1243
1250
  case 'deleteEntity':
1244
1251
  return deleteEntity(payload || {})
1252
+ case 'mergeEntities':
1253
+ return mergeEntities(payload || {})
1254
+ case 'suggestEntityMerges':
1255
+ return suggestEntityMerges(payload || {})
1245
1256
  case 'linkEntries':
1246
1257
  return linkEntries(payload || {})
1247
1258
  case 'unlinkEntry':
@@ -1680,7 +1691,10 @@ async function dispatch(ctx, endpoint, payload = {}) {
1680
1691
  case 'getLocalVectorState':
1681
1692
  return getLocalVectorState()
1682
1693
  case 'downloadLocalVectorModel':
1683
- return await downloadLocalVectorModel(String(payload?.id || ''), { confirmed: payload?.confirmed === true })
1694
+ return await downloadLocalVectorModel(String(payload?.id || ''), {
1695
+ confirmed: payload?.confirmed === true,
1696
+ ...(payload?.provider ? { provider: String(payload.provider) } : {}),
1697
+ })
1684
1698
  case 'selectLocalVectorModel':
1685
1699
  return selectLocalVectorModel(String(payload?.id || ''))
1686
1700
  case 'installLocalVectorRuntime':