dsh-memu-memory 1.3.2 → 1.3.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.
- package/AGENTS.md +11 -3
- package/CHANGELOG.md +57 -3
- package/README.md +6 -11
- package/README.zh.md +6 -11
- package/assets/screenshots/drawer.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/stats.jpg +0 -0
- package/assets/screenshots/webui-dark.jpg +0 -0
- package/assets/screenshots/webui-memory.jpg +0 -0
- package/docs/client-conventions.md +21 -0
- package/docs/contributing.md +5 -2
- package/docs/memory-semantics.md +17 -0
- package/docs/troubleshooting.md +44 -0
- package/lib/binding-diagnostics.js +2 -2
- package/lib/client.js +125 -18
- package/lib/consolidation-snapshot.js +101 -5
- package/lib/consolidation-worker.js +1 -1
- package/lib/cycle.js +19 -1
- package/lib/index.js +83 -2
- package/lib/private.js +450 -165
- package/lib/rpc.js +14 -1
- package/lib/state.js +11 -1
- package/lib/turn-log.js +522 -0
- package/lib/webui/graph-view.bundle.js +1 -1
- package/lib/webui/graph-view.js +53 -25
- package/lib/webui/standalone.css +4 -29
- package/lib/worker-pool.js +741 -0
- package/package.json +1 -1
- package/scripts/acceptance-local.mjs +6 -5
- package/scripts/build-graph.mjs +32 -4
- package/scripts/check-all.mjs +2 -0
- package/scripts/check-idle-compositing.mjs +61 -0
- package/scripts/make-readme-shots.mjs +59 -0
- package/scripts/prune-turnlogs.mjs +30 -0
- package/tests/browser.test.mjs +27 -0
- package/tests/client-render.test.mjs +171 -0
- package/tests/consolidation-snapshot.test.mjs +89 -1
- package/tests/graph-view.test.mjs +60 -3
- package/tests/loader.mjs +2 -0
- package/tests/salience-domain.test.mjs +139 -0
- package/tests/settings-coverage.test.mjs +97 -0
- package/tests/stubs/dsh-session-query.js +26 -0
- package/tests/turn-log.test.mjs +474 -0
- package/tests/webui.test.mjs +19 -0
- package/tests/worker-lifecycle.test.mjs +1046 -0
- package/docs/recall-benchmark.md +0 -238
package/lib/client.js
CHANGED
|
@@ -270,6 +270,8 @@ window.__ModuleLoader__.load({
|
|
|
270
270
|
mergeReasonContainment: '名称包含',
|
|
271
271
|
mergeReasonDistance: '写法相近',
|
|
272
272
|
openMemu: '打开 MemU WebUI',
|
|
273
|
+
openGraphStudio: '打开关系图谱',
|
|
274
|
+
openGraphStudioHint: '在 WebUI 中打开完整关系图谱(浏览器拦下新标签页时在应用内打开)',
|
|
273
275
|
saved: '已保存',
|
|
274
276
|
copied: '已复制',
|
|
275
277
|
copyFailed: '复制失败,请手动选择文本',
|
|
@@ -419,6 +421,11 @@ window.__ModuleLoader__.load({
|
|
|
419
421
|
consolidationReasoningMedium: '中',
|
|
420
422
|
consolidationReasoningHigh: '高',
|
|
421
423
|
consolidationReasoningHint: '只影响后台整理 worker。抽测中 medium 的整理成本最低,通过数不低于 off/high;off 在该路由下仍会产生推理。',
|
|
424
|
+
consolidationRunner: '整理执行器',
|
|
425
|
+
consolidationRunnerFork: '每窗新 fork(默认)',
|
|
426
|
+
consolidationRunnerWorker: '持久 worker(省上下文)',
|
|
427
|
+
consolidationRunnerHint: 'fork 每窗新建一次整理会话,上下文最干净;worker 跨窗复用同一会话,按 200k 字符/16 窗换新,整理 token 约少一半,但会话内上下文会累积。切换从下一窗生效,无需重启。',
|
|
428
|
+
consolidationRunnerExperimental: '实验功能',
|
|
422
429
|
consolidationModeInherit: '继承当前会话',
|
|
423
430
|
consolidationModeHost: '指定宿主模型',
|
|
424
431
|
consolidationModeCustom: '自定义接入点',
|
|
@@ -677,6 +684,9 @@ window.__ModuleLoader__.load({
|
|
|
677
684
|
memoryContent: '记忆内容',
|
|
678
685
|
add: '写入',
|
|
679
686
|
browserIndexOnly: '显示本地索引,正文以此为准。',
|
|
687
|
+
browseSearch: '搜索本库',
|
|
688
|
+
browseSearchPlaceholder: '按标题、正文、ID 或标签过滤当前记忆库…',
|
|
689
|
+
browseSearchClear: '清空',
|
|
680
690
|
// Enum display labels. Stored values stay English; only these flip with locale.
|
|
681
691
|
layerLongTerm: '长期记忆',
|
|
682
692
|
layerAnchor: '锚点记忆',
|
|
@@ -776,6 +786,11 @@ window.__ModuleLoader__.load({
|
|
|
776
786
|
privateCount: '私有记忆',
|
|
777
787
|
pinned: '永久记忆',
|
|
778
788
|
bound: '绑定对话',
|
|
789
|
+
consolidateNow: '手动整理',
|
|
790
|
+
consolidateHint: '为本库绑定的对话发起整理(与侧边栏同一通道,每次最多 5 个,正在整理的会跳过)。整理会产生模型调用成本。',
|
|
791
|
+
consolidateNone: '该库没有可整理的绑定对话',
|
|
792
|
+
consolidateDone: '已发起整理 {started} 个对话(正在整理 {running},失败 {failed}){rest}',
|
|
793
|
+
consolidateRest: ',还有 {n} 个可再点一次',
|
|
779
794
|
globalMemory: '全局记忆',
|
|
780
795
|
prompts: '提示词',
|
|
781
796
|
promptCustom: '自定义',
|
|
@@ -1199,6 +1214,8 @@ window.__ModuleLoader__.load({
|
|
|
1199
1214
|
mergeReasonContainment: 'Name contained',
|
|
1200
1215
|
mergeReasonDistance: 'Similar spelling',
|
|
1201
1216
|
openMemu: 'Open MemU WebUI',
|
|
1217
|
+
openGraphStudio: 'Open relationship graph',
|
|
1218
|
+
openGraphStudioHint: 'Open the full relationship graph in the WebUI (opens in-app when the browser blocks a new tab)',
|
|
1202
1219
|
saved: 'Saved',
|
|
1203
1220
|
copied: 'Copied',
|
|
1204
1221
|
copyFailed: 'Copy failed; select the text manually',
|
|
@@ -1348,6 +1365,11 @@ window.__ModuleLoader__.load({
|
|
|
1348
1365
|
consolidationReasoningMedium: 'Medium',
|
|
1349
1366
|
consolidationReasoningHigh: 'High',
|
|
1350
1367
|
consolidationReasoningHint: 'Only affects the background consolidation worker. In the sampled run, medium had the lowest consolidation cost and no fewer passes than off/high; off still produced reasoning on this route.',
|
|
1368
|
+
consolidationRunner: 'Consolidation runner',
|
|
1369
|
+
consolidationRunnerFork: 'Fresh fork per window (default)',
|
|
1370
|
+
consolidationRunnerWorker: 'Persistent worker (less context)',
|
|
1371
|
+
consolidationRunnerHint: 'fork starts a new consolidation session every window (cleanest context); worker reuses one session across windows and rotates every 200k chars / 16 windows — roughly half the consolidation tokens, at the cost of accumulating context inside the session. Applies from the next window; no restart needed.',
|
|
1372
|
+
consolidationRunnerExperimental: 'Experimental',
|
|
1351
1373
|
consolidationModeInherit: 'Inherit the conversation',
|
|
1352
1374
|
consolidationModeHost: 'Pick a host model',
|
|
1353
1375
|
consolidationModeCustom: 'Custom endpoint',
|
|
@@ -1606,6 +1628,9 @@ window.__ModuleLoader__.load({
|
|
|
1606
1628
|
memoryContent: 'Memory content',
|
|
1607
1629
|
add: 'Write',
|
|
1608
1630
|
browserIndexOnly: 'Showing the local index, the authoritative copy.',
|
|
1631
|
+
browseSearch: 'Search this library',
|
|
1632
|
+
browseSearchPlaceholder: 'Filter the current library by title, body, id or tags…',
|
|
1633
|
+
browseSearchClear: 'Clear',
|
|
1609
1634
|
layerLongTerm: 'Long-term',
|
|
1610
1635
|
layerAnchor: 'Anchor',
|
|
1611
1636
|
layerMustRemember: 'Permanent',
|
|
@@ -1704,6 +1729,11 @@ window.__ModuleLoader__.load({
|
|
|
1704
1729
|
privateCount: 'Private',
|
|
1705
1730
|
pinned: 'Permanent',
|
|
1706
1731
|
bound: 'Sessions',
|
|
1732
|
+
consolidateNow: 'Consolidate now',
|
|
1733
|
+
consolidateHint: 'Start consolidation for conversations bound to this library (same channel as the sidebar; up to 5 per click, ones already running are skipped). Consolidation costs model calls.',
|
|
1734
|
+
consolidateNone: 'No bound conversations to consolidate in this library',
|
|
1735
|
+
consolidateDone: 'Started {started} conversations ({running} already running, {failed} failed){rest}',
|
|
1736
|
+
consolidateRest: ' — {n} more, click again',
|
|
1707
1737
|
globalMemory: 'Global memory',
|
|
1708
1738
|
prompts: 'Prompts',
|
|
1709
1739
|
promptCustom: 'Custom',
|
|
@@ -2052,8 +2082,8 @@ window.__ModuleLoader__.load({
|
|
|
2052
2082
|
browser: the list keeps its filters, scroll position and context. */
|
|
2053
2083
|
.dshm-wall-views{margin:2px 0 4px}
|
|
2054
2084
|
.dshm-wall-graph{margin-top:4px}
|
|
2055
|
-
.dshm-drawer-backdrop{position:fixed;inset:0;z-index:80;display:flex;justify-content:flex-end;background:rgba(10,14,22,.38)
|
|
2056
|
-
.dshm-drawer{width:min(480px,100%);height:100%;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:22px;background:var(--dsw-alias-bg-layer-1,#fff);color:var(--dsw-alias-label-primary,inherit);border-left:1px solid var(--dsw-alias-border-l1,#ddd);box-shadow:-24px 0 60px -34px rgba(0,0,0,.45);animation:dshm-drawer-in .3s cubic-bezier(.22,1,.36,1)
|
|
2085
|
+
.dshm-drawer-backdrop{position:fixed;inset:0;z-index:80;display:flex;justify-content:flex-end;background:rgba(10,14,22,.38);animation:dshm-fade-in .2s ease both}
|
|
2086
|
+
.dshm-drawer{width:min(480px,100%);height:100%;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:22px;background:var(--dsw-alias-bg-layer-1,#fff);color:var(--dsw-alias-label-primary,inherit);border-left:1px solid var(--dsw-alias-border-l1,#ddd);box-shadow:-24px 0 60px -34px rgba(0,0,0,.45);animation:dshm-drawer-in .3s cubic-bezier(.22,1,.36,1) backwards}
|
|
2057
2087
|
.dshm-drawer-head{display:flex;align-items:flex-start;gap:10px}
|
|
2058
2088
|
.dshm-drawer-title{margin:4px 0 6px;font-size:17px;font-weight:650;line-height:1.3;overflow-wrap:anywhere}
|
|
2059
2089
|
.dshm-drawer-meta{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
|
|
@@ -2404,7 +2434,10 @@ html[data-standalone]:has(.dshm-root.is-graph-navless) .stage{padding-left:28px;
|
|
|
2404
2434
|
.dshm-x:hover{opacity:1;background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.1));color:var(--dsw-alias-state-error-primary,#e5484d)}
|
|
2405
2435
|
.dshm-x:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#2563eb);outline-offset:1px}
|
|
2406
2436
|
|
|
2407
|
-
|
|
2437
|
+
/* 入场动画用 backwards 而非 both:both 会在动画结束后仍保留末帧的 transform
|
|
2438
|
+
(哪怕是单位矩阵),Chromium 据此给元素建立 containing block,把内部
|
|
2439
|
+
position:fixed 的抽屉遮罩困在页面列里——遮罩盖不住顶栏/侧栏、抽屉整体偏移。 */
|
|
2440
|
+
.dshm-page{min-width:0;display:flex;flex-direction:column;gap:13px;animation:dshm-page-in .26s cubic-bezier(.22,1,.36,1) backwards}
|
|
2408
2441
|
.dshm-head{margin:2px 0 5px}
|
|
2409
2442
|
.dshm-overline{font-size:10.5px;font-weight:700;letter-spacing:.18em;text-transform:uppercase;color:var(--dsw-alias-brand-primary,#2563eb);opacity:.9}
|
|
2410
2443
|
.dshm-h1{margin:4px 0 0;font-size:21px;font-weight:700;letter-spacing:-.01em}
|
|
@@ -2414,7 +2447,7 @@ html[data-standalone]:has(.dshm-root.is-graph-navless) .stage{padding-left:28px;
|
|
|
2414
2447
|
and hover that inline styles cannot express. */
|
|
2415
2448
|
.dshm-card{transition:transform .28s ease,box-shadow .28s ease,border-color .28s ease}
|
|
2416
2449
|
.dshm-card:hover{transform:translateY(-2px);box-shadow:0 10px 28px -12px rgba(0,0,0,.28)}
|
|
2417
|
-
.dshm-rise{animation:dshm-rise-in .34s cubic-bezier(.22,1,.36,1)
|
|
2450
|
+
.dshm-rise{animation:dshm-rise-in .34s cubic-bezier(.22,1,.36,1) backwards;animation-delay:calc(var(--d,0) * 38ms)}
|
|
2418
2451
|
.dshm-card-head{display:flex;align-items:flex-start;gap:11px}
|
|
2419
2452
|
.dshm-logrow.is-failed{border-left:2px solid var(--dsw-alias-state-error-primary,#c0392b);background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#c0392b) 7%,transparent)}
|
|
2420
2453
|
.dshm-logrow.is-failed .dshm-logmsg{color:var(--dsw-alias-state-error-primary,#c0392b)}
|
|
@@ -3096,7 +3129,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3096
3129
|
// chrome=false 时外壳(rail / 参数弹层 / 状态栏)由 Graph Studio 工作台自己画,
|
|
3097
3130
|
// 画布与引擎保持同一份实现:拖动、pin、弹簧链、簇作用域都不变。
|
|
3098
3131
|
function GraphCanvas({ graph, focus, onFocus, t, chrome = true, options: controlledOptions = null,
|
|
3099
|
-
apiRef = null, onZoom = null }) {
|
|
3132
|
+
apiRef = null, onZoom = null, onPaint = null }) {
|
|
3100
3133
|
const ref = React.useRef(null)
|
|
3101
3134
|
const tooltipRef = React.useRef(null)
|
|
3102
3135
|
const viewRef = React.useRef(null)
|
|
@@ -3122,6 +3155,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3122
3155
|
const view = module.createGraphView(canvas, {
|
|
3123
3156
|
onFocus: id => latest.current.onFocus(id),
|
|
3124
3157
|
onZoom: value => { setZoom(value); zoomNotify.current?.(value) },
|
|
3158
|
+
// 主画布每重绘一次通知一次:缩略图由它直接驱动,不自己轮询。
|
|
3159
|
+
onPaint: () => { onPaint?.() },
|
|
3125
3160
|
tooltip: tooltipRef.current,
|
|
3126
3161
|
reducedMotion: window.matchMedia?.('(prefers-reduced-motion: reduce)').matches,
|
|
3127
3162
|
emptyLabel: latest.current.t('graphEmpty'),
|
|
@@ -3247,7 +3282,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3247
3282
|
: node.kind !== 'memory' ? (node.status === 'provisional' ? 'provisional' : 'entity') : 'memory'
|
|
3248
3283
|
const gsColor = node => GS_NODE_COLORS[gsKind(node)]
|
|
3249
3284
|
|
|
3250
|
-
function GraphStudioMinimap({ active, t }) {
|
|
3285
|
+
function GraphStudioMinimap({ active, t, notifyRef = null }) {
|
|
3251
3286
|
const ref = React.useRef(null)
|
|
3252
3287
|
React.useEffect(() => {
|
|
3253
3288
|
if (!active || typeof document === 'undefined') return undefined
|
|
@@ -3260,9 +3295,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3260
3295
|
context.clearRect(0, 0, target.width, target.height)
|
|
3261
3296
|
try { context.drawImage(source, 0, 0, target.width, target.height) } catch {}
|
|
3262
3297
|
}
|
|
3298
|
+
// 只由主画布的 onPaint 驱动:空闲期主画布不重绘,缩略图就一帧不画。
|
|
3299
|
+
// 曾经这里是 setInterval(paint, 600),即使加了计数闸门也仍是一个常开定时器。
|
|
3300
|
+
if (notifyRef) notifyRef.current = paint
|
|
3263
3301
|
paint()
|
|
3264
|
-
|
|
3265
|
-
return () => clearInterval(timer)
|
|
3302
|
+
return () => { if (notifyRef) notifyRef.current = null }
|
|
3266
3303
|
}, [active])
|
|
3267
3304
|
return h('div', { className: 'dshm-gs-minimap' },
|
|
3268
3305
|
h('h4', null, t('gsMinimap')),
|
|
@@ -3332,6 +3369,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3332
3369
|
const addTargetLib = mergedScope ? (addLib || libraries[0]?.id || '') : (showGlobal ? '' : graphLibrary)
|
|
3333
3370
|
const apiRef = React.useRef(null)
|
|
3334
3371
|
const searchRef = React.useRef(null)
|
|
3372
|
+
// 缩略图的画笔登记处:主画布 onPaint 直接叫它,空闲期零定时器。
|
|
3373
|
+
const minimapPaint = React.useRef(null)
|
|
3335
3374
|
const beat = `${revision ?? ''}:${stamp ?? ''}`
|
|
3336
3375
|
const notify = message => setToast(message)
|
|
3337
3376
|
|
|
@@ -3675,9 +3714,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3675
3714
|
|
|
3676
3715
|
const stage = h('main', { className: 'dshm-gs-stage' },
|
|
3677
3716
|
h(GraphCanvas, { graph: canvasGraph, focus, onFocus: setFocus, t, chrome: false,
|
|
3678
|
-
options: canvasOptions, apiRef, onZoom: setZoom }),
|
|
3717
|
+
options: canvasOptions, apiRef, onZoom: setZoom, onPaint: () => minimapPaint.current?.() }),
|
|
3679
3718
|
canvasTools,
|
|
3680
|
-
minimap ? h(GraphStudioMinimap, { active: true, t }) : null,
|
|
3719
|
+
minimap ? h(GraphStudioMinimap, { active: true, t, notifyRef: minimapPaint }) : null,
|
|
3681
3720
|
h('div', { className: `dshm-gs-toast${toast ? ' show' : ''}`, role: 'status' }, toast),
|
|
3682
3721
|
error ? h('div', { className: 'dshm-gs-toast show', role: 'alert' }, error) : null,
|
|
3683
3722
|
!visibleEdges.length && nodes.length
|
|
@@ -5404,6 +5443,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5404
5443
|
// stayed in the same list with a different tag, so the mess you were trying to
|
|
5405
5444
|
// tidy up never actually left. Two lists, and only the archived one offers delete.
|
|
5406
5445
|
const [browseView, setBrowseView] = React.useState('active')
|
|
5446
|
+
// 当前库内的即时过滤:列表本来就已取回(browseLibrary),不再加一次 RPC。
|
|
5447
|
+
const [browseQuery, setBrowseQuery] = React.useState('')
|
|
5407
5448
|
// Permanent deletion is two clicks, and only for the row that was armed.
|
|
5408
5449
|
const [deleteArmed, setDeleteArmed] = React.useState('')
|
|
5409
5450
|
React.useEffect(() => {
|
|
@@ -6017,6 +6058,38 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6017
6058
|
setPage(PAGE.browser)
|
|
6018
6059
|
void openBrowser(libraryId)
|
|
6019
6060
|
}
|
|
6061
|
+
// 手动整理复用侧边栏同一条通道:generatePrivate(会话维度、force 语义一致),
|
|
6062
|
+
// 不新增端点。一次点击最多发起 5 个对话——整理是真金白银的模型调用,
|
|
6063
|
+
// 不能一键把整库几十个会话全点着;剩下的再按一次即可。
|
|
6064
|
+
// 计数全部取每个调用的返回值(ok / running / error),不估算。
|
|
6065
|
+
const consolidateLibrary = async (libraryId) => {
|
|
6066
|
+
if (!libraryId || !confirmAction('consolidate:' + libraryId)) return
|
|
6067
|
+
setBusy(true)
|
|
6068
|
+
try {
|
|
6069
|
+
const res = await call('listSessions', { limit: 200 })
|
|
6070
|
+
const targets = (res?.sessions || []).filter(row => row.libraryId === libraryId)
|
|
6071
|
+
if (!targets.length) { setError(t('consolidateNone')); return }
|
|
6072
|
+
let started = 0, running = 0, failed = 0
|
|
6073
|
+
for (const row of targets.slice(0, 5)) {
|
|
6074
|
+
try {
|
|
6075
|
+
const one = await call('generatePrivate', { sessionId: row.id })
|
|
6076
|
+
if (one?.ok === true) started++
|
|
6077
|
+
else if (one?.running) running++
|
|
6078
|
+
else failed++
|
|
6079
|
+
} catch { failed++ }
|
|
6080
|
+
}
|
|
6081
|
+
const rest = Math.max(0, targets.length - 5)
|
|
6082
|
+
setNotice(t('consolidateDone')
|
|
6083
|
+
.replace('{started}', String(started))
|
|
6084
|
+
.replace('{running}', String(running))
|
|
6085
|
+
.replace('{failed}', String(failed))
|
|
6086
|
+
.replace('{rest}', rest > 0 ? t('consolidateRest').replace('{n}', String(rest)) : ''))
|
|
6087
|
+
} catch (e) { setError(String(e?.message || e)) } finally { setBusy(false) }
|
|
6088
|
+
}
|
|
6089
|
+
const consolidateButton = (libraryId, style = S.ghost) => h(Button, {
|
|
6090
|
+
style, disabled: busy || !libraryId, title: t('consolidateHint'),
|
|
6091
|
+
onClick: () => { void consolidateLibrary(libraryId) },
|
|
6092
|
+
}, actionLabel('consolidate:' + libraryId, t('consolidateNow')))
|
|
6020
6093
|
const addMemory = async () => {
|
|
6021
6094
|
if (!browseLibId || !newMem.content.trim()) return
|
|
6022
6095
|
setBrowseBusy(true)
|
|
@@ -6994,6 +7067,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6994
7067
|
h('option', { value: 'deterministic' }, t('autoLinkDeterministic')),
|
|
6995
7068
|
h('option', { value: 'off' }, t('autoLinkOff')))),
|
|
6996
7069
|
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } }, t('autoLinkHint')),
|
|
7070
|
+
h(Field, { label: h('span', { style: { color: V.danger } }, t('consolidationRunner'), h('span', { style: { marginLeft: 6, fontWeight: 600 } }, t('consolidationRunnerExperimental'))) },
|
|
7071
|
+
h('select', { style: S.input, value: settings.consolidationRunner || 'fork', onChange: (e) => setSetting('consolidationRunner', e.target.value) },
|
|
7072
|
+
h('option', { value: 'fork' }, t('consolidationRunnerFork')),
|
|
7073
|
+
h('option', { value: 'worker' }, t('consolidationRunnerWorker')))),
|
|
7074
|
+
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } }, t('consolidationRunnerHint')),
|
|
6997
7075
|
h(Field, { label: t('consolidationModelMode') },
|
|
6998
7076
|
h('select', { style: S.input, value: consolidationMode, onChange: (e) => setSetting('consolidationModelMode', e.target.value) },
|
|
6999
7077
|
h('option', { value: 'inherit' }, t('consolidationModeInherit')),
|
|
@@ -7039,6 +7117,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7039
7117
|
h('strong', null, lib.name || lib.id),
|
|
7040
7118
|
h('div', { style: S.muted }, lib.id)),
|
|
7041
7119
|
h('div', { style: { display: 'flex', gap: 6, flexShrink: 0 } },
|
|
7120
|
+
consolidateButton(lib.id),
|
|
7042
7121
|
h(Button, { onClick: () => openBrowserFromLibrary(lib.id) }, t('browse')),
|
|
7043
7122
|
h(Button, { onClick: () => archiveLibrary(lib.id), disabled: busy }, t('archive')))),
|
|
7044
7123
|
h('div', { style: S.muted }, `${t('scope')}: ${lib.scopeKey || '—'}`),
|
|
@@ -7408,7 +7487,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7408
7487
|
|
|
7409
7488
|
const browsePool = file => file.status === 'pending_review' ? 'review' : file.status === 'archived' ? 'archived'
|
|
7410
7489
|
: ['suppressed', 'expired', 'superseded'].includes(file.status) || file.expiresAt && Date.parse(file.expiresAt) <= Date.now() ? 'inactive' : 'active'
|
|
7411
|
-
const
|
|
7490
|
+
const browseQueryText = browseQuery.trim().toLowerCase()
|
|
7491
|
+
const browseMatched = file => !browseQueryText
|
|
7492
|
+
|| [file.title, file.content, file.id, ...(Array.isArray(file.tags) ? file.tags : [])]
|
|
7493
|
+
.some(value => String(value || '').toLowerCase().includes(browseQueryText))
|
|
7494
|
+
const archShown = browseFiles.filter(file => browsePool(file) === browseView && browseMatched(file))
|
|
7412
7495
|
// An archived row is a body you are deciding about, not a draft you are editing:
|
|
7413
7496
|
// no title/content/tag fields, just enough to recognise it plus the two exits.
|
|
7414
7497
|
const renderArchivedMemory = (f) => h('div', { key: f.id, style: S.item },
|
|
@@ -7463,6 +7546,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7463
7546
|
title: t('browser'),
|
|
7464
7547
|
desc: t('descBrowser'),
|
|
7465
7548
|
right: h('div', { style: { display: 'flex', gap: 8, flexShrink: 0 } },
|
|
7549
|
+
consolidateButton(browseLibId),
|
|
7466
7550
|
h(Button, { onClick: () => importLibraryNow(), disabled: !browseLibId || browseBusy, style: S.ghost, title: t('importHint') }, t('importJson')),
|
|
7467
7551
|
h(Button, { onClick: () => exportLibraryNow(), disabled: !browseLibId, style: S.ghost }, t('export')),
|
|
7468
7552
|
h(Button, { onClick: () => exportLibraryNow({ includeAttachments: true }), disabled: !browseLibId, title: t('exportZip') }, t('exportZip')),
|
|
@@ -7473,15 +7557,29 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7473
7557
|
h('select', {
|
|
7474
7558
|
style: { ...S.input, flex: 1 }, value: browseLibId,
|
|
7475
7559
|
title: (state.libraries || []).find((lib) => lib.id === browseLibId)?.scopeKey || t('currentLibrary'),
|
|
7476
|
-
onChange: (e) => setBrowseLibId(e.target.value),
|
|
7560
|
+
onChange: (e) => { setBrowseLibId(e.target.value); setBrowseQuery('') },
|
|
7477
7561
|
}, (state.libraries || []).map((l) => h('option', { key: l.id, value: l.id }, libraryOptionLabel(l, state.libraries || []))))),
|
|
7562
|
+
browseView === 'relations' ? null : h('div', { style: S.row },
|
|
7563
|
+
h('span', { style: S.label }, t('browseSearch')),
|
|
7564
|
+
h('input', {
|
|
7565
|
+
style: { ...S.input, flex: 1 }, type: 'search', value: browseQuery,
|
|
7566
|
+
placeholder: t('browseSearchPlaceholder'), 'aria-label': t('browseSearch'),
|
|
7567
|
+
onChange: (e) => setBrowseQuery(e.target.value),
|
|
7568
|
+
}),
|
|
7569
|
+
browseQuery
|
|
7570
|
+
? h('span', { style: S.muted, role: 'status' },
|
|
7571
|
+
`${archShown.length} / ${browseFiles.filter(file => browsePool(file) === browseView).length}`)
|
|
7572
|
+
: null,
|
|
7573
|
+
browseQuery
|
|
7574
|
+
? h(Button, { style: S.ghost, onClick: () => setBrowseQuery(''), title: t('browseSearchClear') }, t('browseSearchClear'))
|
|
7575
|
+
: null),
|
|
7478
7576
|
browseSource === 'index'
|
|
7479
7577
|
? h('div', { style: { ...S.muted, marginTop: 6 } }, t('browserIndexOnly'))
|
|
7480
7578
|
: null,
|
|
7481
7579
|
h('div', { className: 'dshm-nav-list is-row', role: 'tablist', style: { marginTop: 10 } },
|
|
7482
7580
|
[['active', t('browseActiveTab')], ['archived', t('browseArchivedTab')], ['review', t('poolReview')], ['inactive', t('poolInactive')], ['relations', t('relations')]].map((pair) => {
|
|
7483
7581
|
const value = pair[0]
|
|
7484
|
-
const count = browseFiles.filter(file => browsePool(file) === value).length
|
|
7582
|
+
const count = browseFiles.filter(file => browsePool(file) === value && browseMatched(file)).length
|
|
7485
7583
|
return h('button', {
|
|
7486
7584
|
key: value,
|
|
7487
7585
|
type: 'button',
|
|
@@ -7758,10 +7856,17 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7758
7856
|
} }))
|
|
7759
7857
|
// 关系图谱独立成页:库/全局选择器由 GraphStudioPanel 自持,刷新随 SettingsPage
|
|
7760
7858
|
// 已有的心跳(revision/stamp)走 beat,页内不再开第二套轮询。
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7859
|
+
// §7.1「两个壳一份实现」:完整工作室只在独立 WebUI 里渲染。宿主设置页/侧栏
|
|
7860
|
+
// 里这一页只给一个按钮,点了直接打开 WebUI 的关系图谱页,不再嵌第二份画布。
|
|
7861
|
+
const graphBlock = standalone
|
|
7862
|
+
? h(GraphStudioPanel, {
|
|
7863
|
+
call, libraries: state.libraries || [], revision: state.revision, stamp: state.stamp, t,
|
|
7864
|
+
navHidden: graphNavHidden, onToggleNav: () => setGraphNavHidden(value => !value),
|
|
7865
|
+
})
|
|
7866
|
+
: h(Section, { title: t('pageGraph'), desc: t('descGraph'), icon: GlyphChart },
|
|
7867
|
+
h('div', { style: S.row },
|
|
7868
|
+
h(Button, { primary: true, title: t('openGraphStudioHint'),
|
|
7869
|
+
onClick: () => openWebUiPage('graph') }, t('openGraphStudio'))))
|
|
7765
7870
|
// 词典页:sourceMemoryId →「来源记忆 ↗」复用全局记忆页的 wallFocus 接力棒,
|
|
7766
7871
|
// 跳到 MemU 记忆页并直接打开对应条目的抽屉。
|
|
7767
7872
|
const lexiconBlock = h(LexiconPanel, {
|
|
@@ -7980,7 +8085,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7980
8085
|
// top segments). The indicator is one absolutely-positioned element moved by
|
|
7981
8086
|
// a transform, so the active item animates without per-item flicker.
|
|
7982
8087
|
const active = pageDefs[page] || pageDefs[0]
|
|
7983
|
-
|
|
8088
|
+
// 沉浸式只给独立 WebUI 的完整工作室用。宿主设置页里这一页现在只是一个按钮,
|
|
8089
|
+
// 不能再套 is-graph-wide:那会把本来横排的导航强制成 158px 竖排。
|
|
8090
|
+
const graphWide = standalone && page === PAGE.graph
|
|
7984
8091
|
return h('div', {
|
|
7985
8092
|
className: `dshm-root${graphWide ? ' is-graph-wide' : ''}${graphWide && graphNavHidden ? ' is-graph-navless' : ''}`,
|
|
7986
8093
|
'data-dshm-surface': embedded ? 'sidebar' : 'dialog',
|
|
@@ -162,6 +162,77 @@ export function snapshotHash(events, fromSeq, throughSeq) {
|
|
|
162
162
|
return hash.digest('hex')
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
// —— 外部追加恢复:活视图落后于持久日志 ————————————————————————————————
|
|
166
|
+
// sessionQuery 的 observeSession / readSession 都是 live-preferred:同一会话在宿主
|
|
167
|
+
// 里有活对象时,它们读活对象,不再看持久日志。宿主的活会话只随它自己的事件流增长;
|
|
168
|
+
// 如果另一个进程/导入路径直接改写了会话日志(bench 的 seed-session 就是直接重写
|
|
169
|
+
// session.v4.jsonl.zstd 来追加历史),活视图会冻结在旧前缀。这里只在活视图确实
|
|
170
|
+
// 落后于持久日志时改用冷读结果;正常活会话(含尚未落盘的尾部)永远保留活视图。
|
|
171
|
+
const COLD_PROBE_TTL_MS = 60_000
|
|
172
|
+
const COLD_PROBE_CACHE_LIMIT = 64
|
|
173
|
+
const coldProbeCache = new Map()
|
|
174
|
+
|
|
175
|
+
function lastSeqOf(events) {
|
|
176
|
+
const list = Array.isArray(events) ? events : []
|
|
177
|
+
for (let i = list.length - 1; i >= 0; i -= 1) {
|
|
178
|
+
const seq = Number(list[i]?.seq)
|
|
179
|
+
if (Number.isSafeInteger(seq)) return seq
|
|
180
|
+
}
|
|
181
|
+
return -1
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function rememberColdProbe(sessionId, liveLast, coldLast) {
|
|
185
|
+
coldProbeCache.set(sessionId, { liveLast, coldLastSeq: coldLast, at: Date.now() })
|
|
186
|
+
if (coldProbeCache.size <= COLD_PROBE_CACHE_LIMIT) return
|
|
187
|
+
const oldest = coldProbeCache.keys().next().value
|
|
188
|
+
if (oldest !== undefined) coldProbeCache.delete(oldest)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function defaultLoadColdLogModule() {
|
|
192
|
+
return import('@deepseek-ai/dsh-session-query')
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 持久日志比活视图更靠后时,返回冷读的完整日志;否则 null。
|
|
197
|
+
*
|
|
198
|
+
* 只在活视图路径调用。冷读模块(readColdSessionLog)来自宿主公开导出;拿不到持久
|
|
199
|
+
* 化服务或模块时静默降级,绝不影响现有快照路径。短 TTL 缓存避免正常长会话每窗
|
|
200
|
+
* 都做一次整份冷读:冷日志不领先时,60 秒内不重复探测。
|
|
201
|
+
*/
|
|
202
|
+
export async function reconcilePersistedAhead({
|
|
203
|
+
persistence = null, sessionId = null, liveEvents = [], liveHeader = null,
|
|
204
|
+
signal, loadModule = defaultLoadColdLogModule,
|
|
205
|
+
} = {}) {
|
|
206
|
+
if (!persistence || typeof persistence.open !== 'function' || !sessionId) return null
|
|
207
|
+
const key = String(sessionId)
|
|
208
|
+
const liveLast = lastSeqOf(liveEvents)
|
|
209
|
+
const cached = coldProbeCache.get(key)
|
|
210
|
+
if (cached && cached.coldLastSeq <= liveLast && Date.now() - cached.at < COLD_PROBE_TTL_MS) return null
|
|
211
|
+
let mod = null
|
|
212
|
+
try { mod = await loadModule() } catch { return null }
|
|
213
|
+
if (typeof mod?.readColdSessionLog !== 'function') return null
|
|
214
|
+
let log = null
|
|
215
|
+
try { log = await mod.readColdSessionLog(persistence, sessionId, signal) } catch { return null }
|
|
216
|
+
if (!Array.isArray(log?.events)) return null
|
|
217
|
+
const coldLast = lastSeqOf(log.events)
|
|
218
|
+
if (!Number.isSafeInteger(coldLast)) return null
|
|
219
|
+
rememberColdProbe(key, liveLast, coldLast)
|
|
220
|
+
if (coldLast <= liveLast) return null
|
|
221
|
+
// 同一逻辑会话的身份必须一致;不一致说明不是同一份日志,宁可保留活视图。
|
|
222
|
+
try {
|
|
223
|
+
if (liveHeader && typeof mod.assertSessionHeadersCompatible === 'function') {
|
|
224
|
+
mod.assertSessionHeadersCompatible(liveHeader, log.header)
|
|
225
|
+
}
|
|
226
|
+
} catch { return null }
|
|
227
|
+
return {
|
|
228
|
+
source: 'persisted-ahead',
|
|
229
|
+
events: log.events,
|
|
230
|
+
header: log.header || {},
|
|
231
|
+
inheritedEventCount: log.inheritedEventCount,
|
|
232
|
+
cursor: coldLast,
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
165
236
|
function unavailable(reasonCode, message) {
|
|
166
237
|
return { ok: false, code: 'unavailable', reasonCode, retryable: false, error: message }
|
|
167
238
|
}
|
|
@@ -199,11 +270,16 @@ function buildSnapshot({ sessionId, source, events, header, inheritedEventCount,
|
|
|
199
270
|
* code: 'deferred' —— 现在拿不到安全前缀(回合未闭合/半步),下次再试
|
|
200
271
|
* code: 'failed' —— 读失败,可重试
|
|
201
272
|
*/
|
|
202
|
-
export async function captureSessionSnapshot(ctx, sessionId, { signal } = {}) {
|
|
273
|
+
export async function captureSessionSnapshot(ctx, sessionId, { signal, loadColdLogModule } = {}) {
|
|
203
274
|
if (!sessionId) return unavailable('no-session-id', 'a snapshot needs a session id')
|
|
204
275
|
let sessionQuery = null
|
|
205
276
|
try { sessionQuery = ctx?.get?.('sessionQuery') || null } catch { sessionQuery = null }
|
|
206
277
|
if (!sessionQuery) return unavailable('no-session-query', 'the host exposes no sessionQuery service; a safe snapshot cannot be taken')
|
|
278
|
+
const persistence = (() => { try { return ctx?.get?.('sessionPersistence') || null } catch { return null } })()
|
|
279
|
+
const persistedAhead = (events, header) => reconcilePersistedAhead({
|
|
280
|
+
persistence, sessionId, liveEvents: events, liveHeader: header, signal,
|
|
281
|
+
...(loadColdLogModule ? { loadModule: loadColdLogModule } : {}),
|
|
282
|
+
})
|
|
207
283
|
|
|
208
284
|
if (typeof sessionQuery.observeSession === 'function') {
|
|
209
285
|
let lease = null
|
|
@@ -226,6 +302,18 @@ export async function captureSessionSnapshot(ctx, sessionId, { signal } = {}) {
|
|
|
226
302
|
// 租约必须还回去,否则 prepared 条目会一直被 refs 钉在缓存里。
|
|
227
303
|
try { lease?.[Symbol.dispose]?.(lease) } catch {}
|
|
228
304
|
}
|
|
305
|
+
// 活视图可能被宿主的缓存钉住,而持久日志已被外部追加(bench 种子写入)。
|
|
306
|
+
// 只在持久日志确实更靠后时切换,正常活会话不受影响。
|
|
307
|
+
if (source === 'lease-live') {
|
|
308
|
+
const ahead = await persistedAhead(events, header)
|
|
309
|
+
if (ahead) {
|
|
310
|
+
events = ahead.events
|
|
311
|
+
header = ahead.header
|
|
312
|
+
cursor = ahead.cursor
|
|
313
|
+
inheritedEventCount = ahead.inheritedEventCount
|
|
314
|
+
source = ahead.source
|
|
315
|
+
}
|
|
316
|
+
}
|
|
229
317
|
const safe = safePrefix(events, { requireClosedTurn: source === 'lease-live' })
|
|
230
318
|
if (!safe.ok) {
|
|
231
319
|
return deferred(safe.reasonCode, safe.reasonCode === 'no-closed-turn'
|
|
@@ -248,10 +336,18 @@ export async function captureSessionSnapshot(ctx, sessionId, { signal } = {}) {
|
|
|
248
336
|
} catch (error) {
|
|
249
337
|
return failed('read-failed', error)
|
|
250
338
|
}
|
|
251
|
-
|
|
339
|
+
let events = Array.isArray(snapshot?.events) ? [...snapshot.events] : []
|
|
340
|
+
let header = snapshot?.session || {}
|
|
341
|
+
let inheritedEventCount = snapshot?.inheritedEventCount
|
|
342
|
+
// readSession 也是 live-preferred;同一条外部追加恢复路径。
|
|
343
|
+
const ahead = await persistedAhead(events, header)
|
|
344
|
+
if (ahead) {
|
|
345
|
+
events = ahead.events
|
|
346
|
+
header = ahead.header
|
|
347
|
+
inheritedEventCount = ahead.inheritedEventCount
|
|
348
|
+
}
|
|
252
349
|
const safe = safePrefix(events, { requireClosedTurn: false })
|
|
253
350
|
if (!safe.ok) return deferred(safe.reasonCode, 'the stored transcript is not complete enough to snapshot (' + safe.reasonCode + ')', { observedEvents: events.length })
|
|
254
|
-
const header = snapshot?.session || {}
|
|
255
351
|
return {
|
|
256
352
|
ok: true,
|
|
257
353
|
events: safe.events,
|
|
@@ -261,7 +357,7 @@ export async function captureSessionSnapshot(ctx, sessionId, { signal } = {}) {
|
|
|
261
357
|
source: 'validated-log',
|
|
262
358
|
events: safe.events,
|
|
263
359
|
header,
|
|
264
|
-
inheritedEventCount
|
|
360
|
+
inheritedEventCount,
|
|
265
361
|
cursor: safe.throughSeq,
|
|
266
362
|
safe,
|
|
267
363
|
}),
|
|
@@ -271,4 +367,4 @@ export async function captureSessionSnapshot(ctx, sessionId, { signal } = {}) {
|
|
|
271
367
|
return unavailable('no-snapshot-api', 'sessionQuery exposes neither observeSession nor readSession; consolidation cannot read a safe snapshot')
|
|
272
368
|
}
|
|
273
369
|
|
|
274
|
-
export default { CONSOLIDATION_SNAPSHOT_VERSION, captureSessionSnapshot, safePrefix, snapshotHash, toolPairing, lastClosedTurnSeq, eventSeq }
|
|
370
|
+
export default { CONSOLIDATION_SNAPSHOT_VERSION, captureSessionSnapshot, reconcilePersistedAhead, safePrefix, snapshotHash, toolPairing, lastClosedTurnSeq, eventSeq }
|
|
@@ -185,7 +185,7 @@ export function buildWorkerBrief({ snapshot, probe = null, contract = '', reason
|
|
|
185
185
|
'本轮可用的工具:' + tools + '。',
|
|
186
186
|
singleOnly
|
|
187
187
|
? '直接写,不要再检索:目录和召回命中已经给出。目录里已有的同一事实用 memu_private_update(用目录里的 id)合并;真正新增用 memu_private_remember 逐条写。本轮不要使用 memu_private_remember_batch:上一轮批量参数 JSON 解析失败,逐条写才能保证每条都落库。'
|
|
188
|
-
: '
|
|
188
|
+
: '直接写,不要再检索:目录和召回命中已经给出。真正新增的条目合并成一次 memu_private_remember_batch({items:[...]}) 提交:每个窗口只发一次 batch,不要逐条 remember;只有本窗只写 1 条时才用 memu_private_remember。目录里已有的同一事实用 memu_private_update(用目录里的 id)合并,能合并的更新也放在同一轮里,不要一条一轮来回。',
|
|
189
189
|
'时间锚点:每条用户消息前的 [事件时间 YYYY-MM-DD HH:mm] 是那一轮的发生时间;observed_at 填这个时间,今天/明天/下周X/月底按它算绝对日期;不要用整理时的入库时间,也不要用真实时钟。',
|
|
190
190
|
'写库字段:speaker_id、source_kind、observed_at、absolute_date 必填;冲突用 conflicts_with,明确取代用 supersedes;助手说过的话用 source_kind=assistant_said;承诺写 commitment。',
|
|
191
191
|
'按价值排序:约定/承诺 = 新人物首次出现/换人接手/称呼变化 > 日期/改口/冲突 > 身份/边界/第三方人物 > 偏好/计划 > 其他明确事实。前两类必须写;每窗最多新增 8 条,普通事实最多 3 条,必写候选不受限,总数仍不超过 8 条。',
|
package/lib/cycle.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from './state.js'
|
|
6
6
|
import { expireShortTerm } from './memory.js'
|
|
7
7
|
import { requestPrivateConsolidation, CONSOLIDATION_BACKLOG_EVENTS, CONSOLIDATION_PROBE_MINUTES } from './private.js'
|
|
8
|
+
import { gcTurnLogs } from './turn-log.js'
|
|
8
9
|
import { startGlobalCuration } from './curator.js'
|
|
9
10
|
import { runVisibilityMigrationPass } from './migrate.js'
|
|
10
11
|
import { runSalientWakePass } from './salient-wake.js'
|
|
@@ -201,6 +202,21 @@ export async function runSleepPass(ctx, { now = Date.now(), log = () => {}, limi
|
|
|
201
202
|
return { ran, considered: candidates.length }
|
|
202
203
|
}
|
|
203
204
|
|
|
205
|
+
// 休眠 GC 的 turn-log 分配(设计文档 §3.4):对每个绑定做两条件检查——日志无未结算
|
|
206
|
+
// 增量(max seqEnd ≤ lastSleepSeq)且会话 ≥30 天无任何活动 → 删缓存文件。便宜检查:
|
|
207
|
+
// 只读绑定表 + 文件 stat/mtime,仅对已闲置满期的少数绑定才读日志内容找 max seqEnd;
|
|
208
|
+
// 没有日志文件的绑定直接跳过。异常只 warn,绝不绊倒 sweep 的其他 pass。
|
|
209
|
+
export function runTurnLogGcPass(_ctx, { now = Date.now(), log = () => {} } = {}) {
|
|
210
|
+
try {
|
|
211
|
+
const result = gcTurnLogs(listSessionBindings(), { now })
|
|
212
|
+
if (result.deleted.length > 0) log(`turn-log gc deleted ${result.deleted.length} idle turn log(s)`)
|
|
213
|
+
return result
|
|
214
|
+
} catch (error) {
|
|
215
|
+
log(`turn-log gc failed: ${error?.message || error}`)
|
|
216
|
+
return { deleted: [], kept: [], error: String(error?.message || error) }
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
204
220
|
// Background global curation: turn the conversations that happened since the last
|
|
205
221
|
// run into shared memory, using whichever session is live as the curator's parent.
|
|
206
222
|
export async function runCurationPass(ctx, { now = Date.now(), log = () => {} } = {}) {
|
|
@@ -288,6 +304,8 @@ export function runLibraryHousekeeping(ctx, { now = Date.now(), log = () => {} }
|
|
|
288
304
|
|
|
289
305
|
export async function runCyclePasses(ctx, options = {}) {
|
|
290
306
|
const shortTerm = runShortTermPass(ctx, options)
|
|
307
|
+
// turn-log GC 挂在 sweep 顺带跑(§3.4),只做 stat/绑定表级别的便宜检查。
|
|
308
|
+
const turnLogs = runTurnLogGcPass(ctx, options)
|
|
291
309
|
const sleep = await runSleepPass(ctx, options)
|
|
292
310
|
const curate = await runCurationPass(ctx, options)
|
|
293
311
|
const libraries = runLibraryHousekeeping(ctx, options)
|
|
@@ -302,7 +320,7 @@ export async function runCyclePasses(ctx, options = {}) {
|
|
|
302
320
|
try { options.log?.(`salient wake pass failed: ${error?.message || error}`) } catch {}
|
|
303
321
|
return { created: 0, cleaned: 0, skipped: 0, errors: 1 }
|
|
304
322
|
})
|
|
305
|
-
return { shortTerm, sleep, curate, libraries, migrated, salientWake }
|
|
323
|
+
return { shortTerm, turnLogs, sleep, curate, libraries, migrated, salientWake }
|
|
306
324
|
}
|
|
307
325
|
|
|
308
326
|
// DSH has no host scheduler a plugin can register a *global* job with
|