dsh-memu-memory 1.3.7 → 1.3.8

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 (54) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +58 -0
  3. package/README.md +7 -7
  4. package/README.zh.md +7 -7
  5. package/docs/client-conventions.md +1 -0
  6. package/docs/contributing.md +2 -2
  7. package/docs/memory-semantics.md +7 -6
  8. package/docs/troubleshooting.md +74 -7
  9. package/lib/binding-diagnostics.js +2 -2
  10. package/lib/client.js +150 -81
  11. package/lib/consolidation-ledger.js +6 -2
  12. package/lib/inbound.js +24 -9
  13. package/lib/inject.js +379 -215
  14. package/lib/memory.js +704 -181
  15. package/lib/paths.js +24 -0
  16. package/lib/private.js +242 -132
  17. package/lib/rpc.js +53 -6
  18. package/lib/snippet.js +49 -28
  19. package/lib/state.js +185 -26
  20. package/lib/tools.js +137 -28
  21. package/lib/webui.js +25 -1
  22. package/lib/worker-pool.js +260 -26
  23. package/package.json +1 -1
  24. package/scripts/check-i18n.mjs +19 -0
  25. package/scripts/recall-bench.mjs +4 -4
  26. package/scripts/simulate-injection.mjs +3 -0
  27. package/tests/activity-wiring.test.mjs +52 -0
  28. package/tests/client-render.test.mjs +207 -0
  29. package/tests/consolidation-feed.test.mjs +26 -0
  30. package/tests/consolidation-fork.test.mjs +587 -26
  31. package/tests/cross-library-recall.test.mjs +156 -0
  32. package/tests/cue.test.mjs +15 -2
  33. package/tests/hybrid-recall.test.mjs +488 -0
  34. package/tests/inbound.test.mjs +49 -4
  35. package/tests/inject-conflict.test.mjs +70 -9
  36. package/tests/inject-guide.test.mjs +13 -1
  37. package/tests/inject.test.mjs +10 -0
  38. package/tests/injection-budget.test.mjs +101 -0
  39. package/tests/injection-chain.test.mjs +37 -0
  40. package/tests/injection-rollback.test.mjs +172 -9
  41. package/tests/issue2-chain.test.mjs +169 -0
  42. package/tests/lexicon-inject.test.mjs +33 -5
  43. package/tests/managed-memory.test.mjs +625 -1
  44. package/tests/media.test.mjs +1 -1
  45. package/tests/new-session-gate.test.mjs +280 -25
  46. package/tests/open-loop-date.test.mjs +11 -1
  47. package/tests/recall-intent.test.mjs +52 -3
  48. package/tests/simulate-injection.test.mjs +4 -4
  49. package/tests/snippet.test.mjs +33 -1
  50. package/tests/state.test.mjs +8 -3
  51. package/tests/tool-schema.test.mjs +52 -0
  52. package/tests/tools.test.mjs +394 -0
  53. package/tests/webui.test.mjs +16 -2
  54. package/tests/worker-lifecycle.test.mjs +419 -36
package/lib/client.js CHANGED
@@ -372,7 +372,7 @@ window.__ModuleLoader__.load({
372
372
  settingsTuning: '保存与恢复',
373
373
  settingsHeaderNote: '改动即时保存(约 0.25 秒后写盘);「恢复默认」需两次点击确认。',
374
374
  settingsGroupRecall: '召回与注入',
375
- settingsGroupRecallDesc: '每轮注入什么、注入多少:注入模式、召回条数、token 预算与去重。',
375
+ settingsGroupRecallDesc: '每轮注入什么、注入多少:注入模式、记忆组数、token 预算与已接纳内容去重。',
376
376
  settingsGroupLifecycle: '记忆生命周期',
377
377
  settingsGroupLifecycleDesc: '永久上限、短期保留、未了之事复提与归档清理节奏。',
378
378
  settingsGroupCuration: '整理与唤醒',
@@ -384,8 +384,8 @@ window.__ModuleLoader__.load({
384
384
  settingsGroupIntegration: '集成',
385
385
  settingsGroupIntegrationDesc: '对外暴露的消息工具白名单与视觉描述服务。',
386
386
  autoInject: '注入模式',
387
- privateTopK: '私有 topK',
388
- globalTopK: '全局 topK',
387
+ privateTopK: '私有记忆组数上限',
388
+ globalTopK: '全局记忆组数上限',
389
389
  crossLibraryRecall: '跨库召回(仅同领域)',
390
390
  crossLibraryRecallHint: '开启后,这些读取会合并其它「同领域」私有库:自动召回、memu_private_recall、memu_private_list、侧栏私有列表,以及词典的锚点摘要、本回合匹配与 memu_lexicon_search。\n显式浏览某个库时,仍只显示该库。\n写入不受影响,仍只写当前库;全局词典只有你能写。\n跨库读取改变隔离边界,默认关闭。',
391
391
  crossLibraryRecallShort: '同领域私有库合并读取',
@@ -504,6 +504,8 @@ window.__ModuleLoader__.load({
504
504
  accuracyTag: '细节未必准',
505
505
  accept: '接受',
506
506
  reject: '丢弃',
507
+ reviewAccepted: '复核已通过,记忆转为活跃。',
508
+ reviewRejected: '复核未通过,记忆已归档(可在已归档里恢复)。',
507
509
  reviewReason: '原因',
508
510
  noMemoriesView: '这个记忆库还是空的。可以先在对话里让 agent 记点什么,或用上面的表单手写一条。',
509
511
  browseActiveTab: '活跃',
@@ -749,7 +751,7 @@ window.__ModuleLoader__.load({
749
751
  noArchived: '没有归档的记忆库。',
750
752
  archivedHint: '文件夹从 DSH 移除或在本机消失后,记忆库会自动归档;记忆不会被删除,需要你手动删除,或设置自动删除天数。',
751
753
  restore: '恢复',
752
- deleteForever: '彻底删除',
754
+ deleteLibrary: '彻底删除',
753
755
  deleteLibraryConfirm: '彻底删除记忆库 {name}?这会删掉它的 MemU 数据库和索引,无法恢复。',
754
756
  scopeMissing: '文件夹不存在',
755
757
  purgeArchivedAfterDays: '归档清理候选阈值(天,0=不提示)',
@@ -789,7 +791,7 @@ window.__ModuleLoader__.load({
789
791
  consolidateNow: '手动整理',
790
792
  consolidateHint: '为本库绑定的对话发起整理(与侧边栏同一通道,每次最多 5 个,正在整理的会跳过)。整理会产生模型调用成本。',
791
793
  consolidateNone: '该库没有可整理的绑定对话',
792
- consolidateDone: '已发起整理 {started} 个对话(正在整理 {running},失败 {failed}){rest}',
794
+ consolidateStarted: '已发起整理 {started} 个对话(正在整理 {running},失败 {failed}){rest}',
793
795
  consolidateRest: ',还有 {n} 个可再点一次',
794
796
  globalMemory: '全局记忆',
795
797
  prompts: '提示词',
@@ -975,7 +977,7 @@ window.__ModuleLoader__.load({
975
977
  helpScopesPitfall3: '条目带上下文(频道/角色/世界线/分支/knownBy)时,不匹配的会话看不到它;这是过滤,不是丢失。',
976
978
  helpTitleCards: '标题卡与召回',
977
979
  helpTitleCardsBody: '锚点与本回合召回只显示标题卡:标题、标签和 id,正文不注入;全文仍在记忆页抽屉与召回工具里。',
978
- helpTitleCardsRecall: '标题是目录:用标题关键词,或标题卡里方括号内的 id 调 memu_private_recall / memu_global_recall,工具返回仍是全文。',
980
+ helpTitleCardsRecall: '标题是目录:关键词搜索返回短片段,方括号内的精确 id 默认读取正文页。长正文用 next 提示里的 offset 与 revision 继续;跨库读取保留 libraryId。',
979
981
  helpTitleCardsRule: '标题写作:8–40 字,写具体的人/物/事件或结论(如「Yuike 名字来自小时候的白猫」),不要空标题或「关于XX的事」;细节放进 content。',
980
982
  helpArchiveDelete: '归档、删除与撤回',
981
983
  helpArchiveDeleteArchive: '归档 = 软删除:随时可恢复,关系与链接保留,不级联;条目移到「已归档」页签,不再注入。',
@@ -1032,7 +1034,7 @@ window.__ModuleLoader__.load({
1032
1034
  helpFaq3: '为什么有些记忆不会被注入?',
1033
1035
  helpFaq3A: '常见原因:pending_review(等内容复核)、archived/suppressed/expired/superseded、visibility=secret(自动注入会跳过)、上下文或 domain 不匹配。词典条目没有 pending 复核:写入即 active,归档的才不注入。',
1034
1036
  helpFaq4: '为什么锚点只有标题?怎么拿到正文?',
1035
- helpFaq4A: '锚点与本回合召回是目录:只给标题、标签和 id,避免挤占预算,也避免模型引用没拿到的原文。正文用 memu_private_recall / memu_global_recall 按标题关键词或 id 取,工具仍返回全文;也可在记忆页抽屉里直接读。',
1037
+ helpFaq4A: '锚点与本回合召回是目录:只给标题、标签和 id。用 memu_private_recall / memu_global_recall 按关键词取片段,按精确 id 读正文页;默认每页 2000 个码点,续页携带 offset 与 revision,正文更新会提示重新读取。也可在记忆页抽屉里直接读。',
1036
1038
  helpFaq5: '整理合并(absorb)之后,原来的条目去哪了?怎么撤销?',
1037
1039
  helpFaq5A: '合并不会删除任何东西:合并稿成为新的 active 条目,被吸收的来源归档、被取代的目标标记 superseded。在全局记忆页找到合并稿,点「撤销合并」即可整体恢复原状;全局链接也可以逐条移除。',
1038
1040
  helpFaq6: '词典为什么自动生效?怎么归档?为什么某条不注入?',
@@ -1319,7 +1321,7 @@ window.__ModuleLoader__.load({
1319
1321
  settingsTuning: 'Saving & reset',
1320
1322
  settingsHeaderNote: 'Edits save themselves about 0.25s after each change; Reset defaults asks for a second click.',
1321
1323
  settingsGroupRecall: 'Recall & injection',
1322
- settingsGroupRecallDesc: 'What each turn injects and how much: injection mode, topK, token budgets, dedupe.',
1324
+ settingsGroupRecallDesc: 'What each turn injects and how much: memory group limits, token budgets, and admitted-content dedupe.',
1323
1325
  settingsGroupLifecycle: 'Memory lifecycle',
1324
1326
  settingsGroupLifecycleDesc: 'Permanent cap, short-term retention, open-loop reminders and archive cleanup.',
1325
1327
  settingsGroupCuration: 'Curation & wake',
@@ -1331,8 +1333,8 @@ window.__ModuleLoader__.load({
1331
1333
  settingsGroupIntegration: 'Integration',
1332
1334
  settingsGroupIntegrationDesc: 'External message tool allowlist and the vision caption service.',
1333
1335
  autoInject: 'Injection mode',
1334
- privateTopK: 'Private topK',
1335
- globalTopK: 'Global topK',
1336
+ privateTopK: 'Private memory group limit',
1337
+ globalTopK: 'Global memory group limit',
1336
1338
  crossLibraryRecall: 'Cross-library recall (same domain)',
1337
1339
  crossLibraryRecallHint: 'When on, these reads merge other same-domain private libraries: automatic recall, memu_private_recall, memu_private_list, the sidebar private list, plus the lexicon anchor summaries, this-turn matching and memu_lexicon_search.\nExplicitly browsing a library still shows that library only.\nWrites are unaffected and still go to the current library; the global lexicon stays yours alone to write.\nReading across libraries changes the isolation boundary, so this is off by default.',
1338
1340
  crossLibraryRecallShort: 'Merge same-domain reads',
@@ -1451,6 +1453,8 @@ window.__ModuleLoader__.load({
1451
1453
  accuracyTag: 'details may be off',
1452
1454
  accept: 'Accept',
1453
1455
  reject: 'Discard',
1456
+ reviewAccepted: 'Review accepted; the memory is now active.',
1457
+ reviewRejected: 'Review rejected; the memory was archived (restore it from Archived).',
1454
1458
  reviewReason: 'Reason',
1455
1459
  noMemoriesView: 'This library is empty. Let the agent note something in a conversation, or write one above.',
1456
1460
  browseActiveTab: 'Active',
@@ -1695,7 +1699,7 @@ window.__ModuleLoader__.load({
1695
1699
  noArchived: 'No archived libraries.',
1696
1700
  archivedHint: 'A library is archived when its folder leaves DSH or disappears from this machine. Memory is never deleted automatically — delete it by hand, or set an auto-delete age.',
1697
1701
  restore: 'Restore',
1698
- deleteForever: 'Delete forever',
1702
+ deleteLibrary: 'Delete forever',
1699
1703
  deleteLibraryConfirm: 'Permanently delete {name}? This removes its MemU database and index and cannot be undone.',
1700
1704
  scopeMissing: 'Folder missing',
1701
1705
  purgeArchivedAfterDays: 'Archive cleanup review after days (0=off)',
@@ -1735,7 +1739,7 @@ window.__ModuleLoader__.load({
1735
1739
  consolidateNow: 'Consolidate now',
1736
1740
  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.',
1737
1741
  consolidateNone: 'No bound conversations to consolidate in this library',
1738
- consolidateDone: 'Started {started} conversations ({running} already running, {failed} failed){rest}',
1742
+ consolidateStarted: 'Started {started} conversations ({running} already running, {failed} failed){rest}',
1739
1743
  consolidateRest: ' — {n} more, click again',
1740
1744
  globalMemory: 'Global memory',
1741
1745
  prompts: 'Prompts',
@@ -1921,7 +1925,7 @@ window.__ModuleLoader__.load({
1921
1925
  helpScopesPitfall3: 'Entries carrying context (channel / character / world / branch / knownBy) stay hidden from conversations that do not match; that is filtering, not loss.',
1922
1926
  helpTitleCards: 'Title cards and recall',
1923
1927
  helpTitleCardsBody: 'The anchor and per-turn recall show title cards only: title, tags and id; bodies are not injected. The full text still lives in the memory drawer and the recall tools.',
1924
- helpTitleCardsRecall: 'The title is a directory: recall by title keyword, or by the id shown in brackets on the card, with memu_private_recall / memu_global_recall; the tools still return the full text.',
1928
+ helpTitleCardsRecall: 'Titles are an index: keyword searches return snippets; exact bracketed ids read body pages by default. Continue with the next offset and revision; preserve libraryId for cross-library reads.',
1925
1929
  helpTitleCardsRule: 'Title rule: 8–40 characters naming the concrete person/object/event or conclusion ("Yuike is named after a childhood white cat"); no empty titles or "about X" labels; details belong in content.',
1926
1930
  helpArchiveDelete: 'Archive, delete and undo',
1927
1931
  helpArchiveDeleteArchive: 'Archive = soft delete: restorable at any time, links and relationships kept, no cascade; the entry moves to the "Archived" tab and stops being injected.',
@@ -1978,7 +1982,7 @@ window.__ModuleLoader__.load({
1978
1982
  helpFaq3: 'Why are some memories not injected?',
1979
1983
  helpFaq3A: 'Common reasons: pending_review (waiting for approval), archived/suppressed/expired/superseded, visibility=secret (automatic injection skips it), or a context/domain mismatch. Lexicon terms have no pending review anymore: they are active on write and only archived terms stop being injected.',
1980
1984
  helpFaq4: 'Why does the anchor show only titles, and how do I get the body?',
1981
- helpFaq4A: 'The anchor and per-turn recall are a directory: title, tags and id only, to save budget and avoid quoting text the model was not given. Fetch the body with memu_private_recall / memu_global_recall by title keyword or id; the tools still return full text, and the memory-page drawer shows it too.',
1985
+ helpFaq4A: 'Anchor and per-turn recall are an index: title, tags and id only. Search keywords for snippets or read exact ids for body pages, 2000 Unicode code points per page by default. Continue with offset and revision; changed bodies require a restart. The memory-page drawer also shows the full text.',
1982
1986
  helpFaq5: 'Where did the original entries go after an absorb, and how do I undo it?',
1983
1987
  helpFaq5A: 'Absorbing deletes nothing: the merged entry becomes active, the target is marked superseded and the sources are archived. Find the merged entry on the global memory page and press "Undo merge" to restore everything; global links can be removed individually.',
1984
1988
  helpFaq6: 'The lexicon writes automatically — how do I archive, and why is a term not injected?',
@@ -2504,6 +2508,22 @@ html[data-standalone]:has(.dshm-root.is-graph-navless) .stage{padding-left:28px;
2504
2508
  .dshm-card-actions{margin-left:auto;display:flex;gap:8px;flex:none;align-items:center}
2505
2509
 
2506
2510
  .dshm-root input:not([type=checkbox]):not([type=radio]):focus,.dshm-root textarea:focus,.dshm-root select:focus{border-color:var(--dsw-alias-brand-primary,#2563eb);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary,#2563eb) 18%,transparent)}
2511
+ .dshm-consolidation{min-width:0;border:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.18));border-radius:16px;padding:10px 12px;margin-top:12px;background:var(--dsw-alias-bg-layer-1,rgba(127,127,127,.04))}
2512
+ .dshm-consolidation-head{display:flex;flex-wrap:wrap;gap:8px;align-items:center;width:100%;padding:0;border:0;background:transparent;cursor:pointer;text-align:left;color:inherit;font:inherit}
2513
+ .dshm-consolidation-title{min-width:0;font-size:12.5px;font-weight:600;overflow-wrap:anywhere}
2514
+ .dshm-consolidation-toggle{margin-left:auto;font-size:11px;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.72))}
2515
+ .dshm-consolidation-columns{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:14px;margin-top:7px}
2516
+ .dshm-consolidation-column,.dshm-consolidation-row{min-width:0}
2517
+ .dshm-consolidation-column-head{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-bottom:6px;font-size:12px;font-weight:600;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.72))}
2518
+ .dshm-consolidation-failed{color:var(--dsw-alias-state-error-primary,#c0392b)}
2519
+ .dshm-consolidation-rows{display:flex;flex-direction:column;gap:8px}
2520
+ .dshm-consolidation-identity{display:flex;gap:6px;align-items:center;min-width:0}
2521
+ .dshm-consolidation-identity>span:first-child{flex-shrink:0}
2522
+ .dshm-consolidation-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}
2523
+ .dshm-consolidation-meta{display:flex;flex-wrap:wrap;gap:6px;align-items:center;justify-content:space-between;margin-top:3px}
2524
+ .dshm-consolidation-time{min-width:0;font-size:11px;overflow-wrap:anywhere;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.72))}
2525
+ .dshm-consolidation-message{font-size:11px;margin-top:3px;overflow-wrap:anywhere;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.72))}
2526
+ .dshm-consolidation-latest{margin-top:7px}
2507
2527
  .dshm-btn:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 5px 14px -6px rgba(0,0,0,.32)}
2508
2528
  .dshm-btn:active:not(:disabled){transform:translateY(0) scale(.97);box-shadow:none}
2509
2529
  .dshm-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#2563eb);outline-offset:2px}
@@ -2950,9 +2970,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
2950
2970
  info: { color: V.accent, background: V.accentSoft },
2951
2971
  }
2952
2972
 
2953
- function Tag({ children, tone, title }) {
2954
- const style = tone && TAG_TONES[tone] ? { ...S.tag, ...TAG_TONES[tone] } : S.tag
2955
- return h('span', { style, title }, children)
2973
+ function Tag({ children, tone, title, style }) {
2974
+ const base = tone && TAG_TONES[tone] ? { ...S.tag, ...TAG_TONES[tone] } : S.tag
2975
+ // style 由调用方收紧(如提醒行里允许药丸截断),只在基础样式之上叠加。
2976
+ return h('span', { style: style ? { ...base, ...style } : base, title }, children)
2956
2977
  }
2957
2978
 
2958
2979
  // 活动日志行的三档状态。失败 = ok=false 或 level=error;level=warn 而 ok 不为 false
@@ -4598,6 +4619,25 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4598
4619
  setDetail(prev => prev ? { ...prev, busy: false, error: String(failure?.message || failure) } : prev)
4599
4620
  }
4600
4621
  }
4622
+ // 待复核记忆在抽屉里直接拍板(私有与全局都支持):与墙内其它写操作同一
4623
+ // 管理面授权模型,不带 sessionId;全局条目不带 libraryId 走全局复核路由。
4624
+ const resolveDetailReview = async (action) => {
4625
+ const current = detail
4626
+ if (!current?.item || current.item.status !== 'pending_review') return
4627
+ setDetail({ ...current, busy: true, error: '' })
4628
+ try {
4629
+ await call('resolveReview', {
4630
+ id: current.item.id, action,
4631
+ ...(current.item.libraryId ? { libraryId: current.item.libraryId } : {}),
4632
+ })
4633
+ setDetail(null)
4634
+ notifyMemoryWrite('review', current.item.libraryId || null)
4635
+ notice(action === 'accept' ? t('reviewAccepted') : t('reviewRejected'))
4636
+ reload()
4637
+ } catch (failure) {
4638
+ setDetail(prev => prev ? { ...prev, busy: false, error: String(failure?.message || failure) } : prev)
4639
+ }
4640
+ }
4601
4641
 
4602
4642
  // —— 多选批量操作(只对私有块生效;全局只读)——
4603
4643
  // 逐条走既有 RPC(updateMemory patch.status / deleteMemory),循环里失败的条目
@@ -4744,6 +4784,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4744
4784
  detailForm,
4745
4785
  detail.file && !detail.readonly ? h(MemoryAttachments, { items: detail.file.attachments, t, initialOpen: true }) : null,
4746
4786
  h('div', { className: 'dshm-drawer-actions' },
4787
+ shown.status === 'pending_review'
4788
+ ? h(Button, { primary: true, disabled: detail.busy, onClick: () => { void resolveDetailReview('accept') } }, t('accept'))
4789
+ : null,
4790
+ shown.status === 'pending_review'
4791
+ ? h(Button, { style: S.ghost, disabled: detail.busy, onClick: () => { void resolveDetailReview('reject') } }, t('reject'))
4792
+ : null,
4747
4793
  !detail.readonly
4748
4794
  ? h(Button, { primary: true, disabled: detail.busy, onClick: () => { void saveDetail() } }, t('save'))
4749
4795
  : null,
@@ -5839,8 +5885,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
5839
5885
  // another host process — land through the on-disk half of the marker.
5840
5886
  const vectorWorking = !!vectorOperation || ['downloading', 'verifying', 'installing'].includes(state?.localVector?.runtime?.status || '') || Object.values(state?.localVector?.installations || {}).some(item => ['downloading', 'verifying'].includes(item.status)) || ['preparing', 'prepared', 'syncing', 'switching'].includes(state?.localVector?.vector?.pending?.status)
5841
5887
  useMemoryBeat({ call, markerRef, onBeat: refresh, force: vectorWorking })
5842
- // Sizes need a directory walk; ask for them after the page has painted.
5888
+ // 引擎体积与可安装版本只在总览页的引擎卡消费:首屏(记忆墙)不为它们
5889
+ // 多发两个 RPC——宿主桥接可能串行处理请求,慢一个就拖住整页首帧。
5890
+ // 体积要遍历 venv 目录,打开总览页后再问;安装完成后版本号变化会重问。
5843
5891
  React.useEffect(() => {
5892
+ if (page !== PAGE.overview) return undefined
5844
5893
  let alive = true
5845
5894
  void (async () => {
5846
5895
  try {
@@ -5849,10 +5898,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
5849
5898
  } catch {}
5850
5899
  })()
5851
5900
  return () => { alive = false }
5852
- }, [call, state?.engine?.currentVersion])
5901
+ }, [call, page, state?.engine?.currentVersion])
5853
5902
  // Ask once on open, in the background: the page paints from cached state and
5854
5903
  // the version card fills in when PyPI answers.
5855
- React.useEffect(() => { void loadVersions(false) }, [loadVersions])
5904
+ React.useEffect(() => { if (page === PAGE.overview) void loadVersions(false) }, [page, loadVersions])
5856
5905
  React.useEffect(() => {
5857
5906
  if (state?.engine?.status !== 'installing') return undefined
5858
5907
  const id = setInterval(() => { void refreshEngine() }, 1200)
@@ -6184,7 +6233,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
6184
6233
  } catch { failed++ }
6185
6234
  }
6186
6235
  const rest = Math.max(0, targets.length - 5)
6187
- setNotice(t('consolidateDone')
6236
+ setNotice(t('consolidateStarted')
6188
6237
  .replace('{started}', String(started))
6189
6238
  .replace('{running}', String(running))
6190
6239
  .replace('{failed}', String(failed))
@@ -7238,7 +7287,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
7238
7287
  h('div', { style: S.muted }, `${t('scope')}: ${lib.scopeKey || '—'}`)),
7239
7288
  h('div', { style: { display: 'flex', gap: 6, flexShrink: 0 } },
7240
7289
  h(Button, { onClick: () => restoreLibraryNow(lib.id), disabled: busy, style: S.ghost }, t('restore')),
7241
- h(Button, { onClick: () => deleteLibraryNow(lib), disabled: busy, style: S.ghost }, actionLabel('library:' + lib.id, t('deleteForever'))))),
7290
+ h(Button, { onClick: () => deleteLibraryNow(lib), disabled: busy, style: S.ghost }, actionLabel('library:' + lib.id, t('deleteLibrary'))))),
7242
7291
  h('div', { style: S.row },
7243
7292
  lib.scopeMissing ? h(Tag, null, t('scopeMissing')) : null,
7244
7293
  h(Tag, null, `${t('privateCount')}: ${lib.privateCount ?? 0}`),
@@ -7539,6 +7588,14 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
7539
7588
  ? h(Tag, { tone: 'warn' }, `${t('accuracyTag')} ${f.accuracy}`) : null,
7540
7589
  h(Tag, null, enumText(t, STATUS_LABELS, f.status || 'active'))),
7541
7590
  h('div', { style: { display: 'flex', gap: 6, flexShrink: 0 } },
7591
+ // 待复核条目在这里就能拍板,不必绕去全局页的复核队列;
7592
+ // resolution 沿用复核草稿(缺省 replace),与全局队列同一 RPC。
7593
+ f.status === 'pending_review'
7594
+ ? h(Button, { onClick: () => resolveReview({ id: f.id, libraryId: browseLibId }, 'accept'), disabled: busy || browseBusy, primary: true }, t('accept'))
7595
+ : null,
7596
+ f.status === 'pending_review'
7597
+ ? h(Button, { onClick: () => resolveReview({ id: f.id, libraryId: browseLibId }, 'reject'), disabled: busy || browseBusy, style: S.ghost }, t('reject'))
7598
+ : null,
7542
7599
  h(Button, { onClick: () => saveMemory(f.id), disabled: busy || browseBusy }, t('save')),
7543
7600
  h(Button, { onClick: () => archiveMemory(f.id), disabled: busy || browseBusy, style: S.ghost }, t('archive')))),
7544
7601
  h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, margin: '8px 0 4px' } },
@@ -8279,30 +8336,31 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
8279
8336
  const when = (row) => {
8280
8337
  try { return new Date(row.at).toLocaleString([], { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }) } catch { return row.at }
8281
8338
  }
8282
- const rowEl = (row, tone) => h('div', { key: row.id, style: { minWidth: 0 } },
8283
- h('div', { style: { display: 'flex', gap: 6, alignItems: 'center', minWidth: 0 } },
8339
+ const rowEl = (row, tone) => h('div', { key: row.id, className: 'dshm-consolidation-row' },
8340
+ h('div', { className: 'dshm-consolidation-identity' },
8284
8341
  h(Tag, { tone: tone === 'fail' ? 'warn' : undefined }, tone === 'fail' ? t('consolidateFailed') : t('consolidateDone')),
8285
- h('span', { style: { fontSize: 12, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', minWidth: 0, flex: 1 }, title: row.message }, label(row)),
8286
- h('span', { style: { ...S.muted, flexShrink: 0, fontSize: 11 } }, when(row)),
8342
+ h('span', { className: 'dshm-consolidation-label', title: label(row) }, label(row))),
8343
+ h('div', { className: 'dshm-consolidation-meta' },
8344
+ h('span', { className: 'dshm-consolidation-time' }, when(row)),
8287
8345
  tone === 'fail' ? h(Button, {
8288
- style: { ...S.ghost, padding: '1px 7px', flexShrink: 0 },
8346
+ style: S.ghost,
8289
8347
  title: t('consolidateJumpHint'),
8290
8348
  onClick: () => onJump(row),
8291
8349
  }, '↗') : null),
8292
8350
  tone === 'fail' && row.message
8293
- ? h('div', { style: { ...S.muted, fontSize: 11, marginTop: 1, overflow: 'hidden', display: '-webkit-box', WebkitLineClamp: 2, WebkitBoxOrient: 'vertical' } }, row.message)
8351
+ ? h('div', { className: 'dshm-consolidation-message', title: row.message }, row.message)
8294
8352
  : null)
8295
- const column = (title, rows, tone) => h('div', { style: { minWidth: 0, flex: 1 } },
8296
- h('div', { style: { display: 'flex', gap: 6, alignItems: 'center', marginBottom: 4 } },
8297
- h('span', { style: { ...S.muted, fontWeight: 600, color: tone === 'fail' ? V.danger : undefined } }, title),
8353
+ const column = (title, rows, tone) => h('div', { className: 'dshm-consolidation-column' },
8354
+ h('div', { className: 'dshm-consolidation-column-head' },
8355
+ h('span', { className: tone === 'fail' ? 'dshm-consolidation-failed' : undefined }, title),
8298
8356
  tone === 'fail' && failures.length > 0 ? h(Button, {
8299
- style: { ...S.ghost, padding: '1px 6px', fontSize: 11, flexShrink: 0 },
8357
+ style: S.ghost,
8300
8358
  title: t('consolidateClearHint'),
8301
8359
  onClick: onClear,
8302
8360
  }, t('consolidateClear')) : null),
8303
8361
  rows.length === 0
8304
8362
  ? h('div', { style: S.muted }, '—')
8305
- : h('div', { style: { display: 'flex', flexDirection: 'column', gap: 5 } }, rows.map(row => rowEl(row, tone))))
8363
+ : h('div', { className: 'dshm-consolidation-rows' }, rows.map(row => rowEl(row, tone))))
8306
8364
  const latest = failures.length > 0 ? failures[0] : successes[0]
8307
8365
  const latestTone = failures.length > 0 ? 'fail' : 'ok'
8308
8366
  const head = h('button', {
@@ -8310,18 +8368,18 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
8310
8368
  'aria-expanded': open,
8311
8369
  title: open ? t('consolidateCollapse') : t('consolidateExpand'),
8312
8370
  onClick: () => setOpen(v => !v),
8313
- style: { display: 'flex', gap: 8, alignItems: 'center', width: '100%', padding: 0, border: 'none', background: 'transparent', cursor: 'pointer', textAlign: 'left', color: 'inherit', font: 'inherit' },
8371
+ className: 'dshm-consolidation-head',
8314
8372
  },
8315
- h('span', { style: { fontWeight: 600, fontSize: 12.5 } }, t('consolidateFeedTitle')),
8373
+ h('span', { className: 'dshm-consolidation-title' }, t('consolidateFeedTitle')),
8316
8374
  failures.length > 0 ? h(Tag, { tone: 'warn' }, t('consolidateFailedCount').replace('{n}', String(failures.length))) : null,
8317
- h('span', { style: { ...S.muted, marginLeft: 'auto', fontSize: 11 } }, open ? t('consolidateCollapse') : t('consolidateExpand')))
8318
- return h('div', { style: { ...S.section, padding: '10px 12px', marginTop: 12 }, role: 'status' },
8375
+ h('span', { className: 'dshm-consolidation-toggle' }, open ? t('consolidateCollapse') : t('consolidateExpand')))
8376
+ return h('div', { className: 'dshm-consolidation', role: 'status' },
8319
8377
  head,
8320
8378
  open
8321
- ? h('div', { style: { display: 'flex', gap: 14, marginTop: 7 } },
8379
+ ? h('div', { className: 'dshm-consolidation-columns' },
8322
8380
  column(t('consolidateFailedCol'), failures, 'fail'),
8323
8381
  column(t('consolidateOkCol'), successes, 'ok'))
8324
- : h('div', { style: { marginTop: 7 } }, rowEl(latest, latestTone)))
8382
+ : h('div', { className: 'dshm-consolidation-latest' }, rowEl(latest, latestTone)))
8325
8383
  }
8326
8384
 
8327
8385
  function MemoryTab({ ctx, t, sessionId }) {
@@ -8770,7 +8828,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
8770
8828
  const list = useSessionList(ctx)
8771
8829
  const call = useRpc(ctx)
8772
8830
  const decided = React.useRef(new Set())
8773
- const checking = React.useRef(false)
8831
+ // 已见过的空白会话即使抢先发了消息,也不能丢失尚未作答的询问。
8832
+ const pending = React.useRef(new Set())
8833
+ const visited = React.useRef(null)
8834
+ const deferred = React.useRef(null)
8835
+ const failures = React.useRef(new Map())
8774
8836
  const [prompt, setPrompt] = React.useState(null)
8775
8837
  const [choice, setChoice] = React.useState('auto')
8776
8838
  // The card picks the layers; this only picks *which* library carries them.
@@ -8792,56 +8854,56 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
8792
8854
  const summaryBlank = summary?.blank
8793
8855
  const summaryOrigin = summary?.origin
8794
8856
 
8857
+ const hasSummary = Boolean(summary)
8858
+ const promptSessionId = prompt?.sessionId
8859
+
8795
8860
  React.useEffect(() => {
8796
- if (!current || decided.current.has(current) || checking.current) return
8797
- if (!summary) return
8861
+ if (visited.current !== current) {
8862
+ visited.current = current
8863
+ deferred.current = null
8864
+ failures.current.delete(current)
8865
+ }
8866
+ if (!current || !hasSummary) return
8798
8867
  if (summaryOrigin === 'subagent') { decided.current.add(current); return }
8799
- if (summaryBlank === false) { decided.current.add(current); return }
8800
- // No workspace folder chosen yet: there is no scope to bind a library to,
8801
- // and initializing here would mint a placeholder library. Wait for the
8802
- // summary to carry a cwd — a folder picked later still prompts normally.
8803
- if (!summaryCwd) return
8804
- checking.current = true
8868
+ if (summaryBlank === true) pending.current.add(current)
8869
+ if (deferred.current === current || decided.current.has(current)) return
8870
+ if (summaryBlank === false && !pending.current.has(current)) {
8871
+ decided.current.add(current)
8872
+ return
8873
+ }
8874
+ if (!summaryCwd || promptSessionId === current) return
8805
8875
  let cancelled = false
8806
- ;(async () => {
8876
+ let retryTimer = null
8877
+ const check = async () => {
8878
+ if (cancelled) return
8807
8879
  try {
8808
8880
  const st = await call('getSessionPromptState', { sessionId: current, cwd: summaryCwd })
8809
8881
  if (cancelled) return
8810
- if (st.binding) {
8811
- // A binding left over from the pre-folder build still says
8812
- // Default/__default__. The conversation summary now carries the real
8813
- // cwd, so repair the name in place instead of leaving the wrong label.
8814
- if (st.binding.scopeKey === '__default__' && summaryCwd) {
8815
- await call('initSession', { sessionId: current, cwd: summaryCwd, createLibrary: false })
8816
- }
8817
- decided.current.add(current)
8818
- return
8819
- }
8820
- // The folder already said no to both layers, so there is nothing to
8821
- // ask: bind silently with nothing enabled and no library created
8822
- // (T5 — this is the bug where the prompt kept appearing for a folder
8823
- // whose memory was switched off).
8824
- if (st.shouldPrompt === false) {
8882
+ if (st.binding?.scopeKey === '__default__') {
8825
8883
  await call('initSession', { sessionId: current, cwd: summaryCwd, createLibrary: false })
8826
- await call('setSessionScope', { sessionId: current, useLibrary: false, useGlobal: false })
8884
+ if (cancelled) return
8885
+ }
8886
+ if (st.binding?.domainSource === 'chosen') {
8887
+ failures.current.delete(current)
8827
8888
  decided.current.add(current)
8828
8889
  return
8829
8890
  }
8830
- if (st.settings?.newSessionPromptDismissed) {
8831
- // "Don't ask again" must actually honor the remembered choice.
8832
- // Writing only one of the two layers (or, as this branch used to,
8833
- // only the library) let the folder policy fill the missing switch,
8834
- // so the remembered answer was not the answer the sidebar showed.
8891
+ if (st.shouldPrompt === false || st.settings?.newSessionPromptDismissed) {
8835
8892
  const card = CARD_OF[String(st.settings?.newSessionDefault || 'both')] || 'both'
8836
- const layers = LAYERS_OF[card]
8893
+ const layers = st.shouldPrompt === false ? LAYERS_OF.none : LAYERS_OF[card]
8837
8894
  await call('initSession', { sessionId: current, cwd: summaryCwd, createLibrary: layers.useLibrary })
8895
+ if (cancelled) return
8838
8896
  await call('setSessionScope', { sessionId: current, ...layers })
8897
+ if (cancelled) return
8898
+ failures.current.delete(current)
8839
8899
  decided.current.add(current)
8840
8900
  return
8841
8901
  }
8902
+ failures.current.delete(current)
8903
+ setError('')
8842
8904
  setPrompt({
8843
8905
  sessionId: current,
8844
- cwd: summaryCwd || '',
8906
+ cwd: summaryCwd,
8845
8907
  libraries: (st.libraries || []).filter((l) => l.scopeKey !== '__default__'),
8846
8908
  domains: Array.isArray(st.domains) && st.domains.length ? st.domains : ['rp', 'coding', 'general', 'mixed'],
8847
8909
  folder: st.folder || null,
@@ -8852,14 +8914,20 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
8852
8914
  setDomain('rp')
8853
8915
  setLibraryId((st.libraries || []).find((l) => l.scopeKey !== '__default__')?.id || '')
8854
8916
  } catch (e) {
8855
- if (!cancelled) setError(String(e?.message || e))
8856
- decided.current.add(current)
8857
- } finally {
8858
- if (!cancelled) checking.current = false
8917
+ if (cancelled) return
8918
+ const count = (failures.current.get(current)?.count || 0) + 1
8919
+ const delay = Math.min(30_000, 1_000 * 2 ** Math.min(count - 1, 5))
8920
+ failures.current.set(current, { count, retryAt: Date.now() + delay })
8921
+ setError(String(e?.message || e))
8922
+ retryTimer = setTimeout(check, delay)
8923
+ void call('logClientEvent', { sessionId: current, kind: 'error', message: '新会话记忆询问检查失败,将自动重试', detail: String(e?.message || e) }).catch(() => {})
8859
8924
  }
8860
- })()
8861
- return () => { cancelled = true; checking.current = false }
8862
- }, [current, summary, summaryCwd, summaryBlank, summaryOrigin, call])
8925
+ }
8926
+ const delay = Math.max(0, (failures.current.get(current)?.retryAt || 0) - Date.now())
8927
+ if (delay) retryTimer = setTimeout(check, delay)
8928
+ else void check()
8929
+ return () => { cancelled = true; clearTimeout(retryTimer) }
8930
+ }, [current, hasSummary, summaryCwd, summaryBlank, summaryOrigin, promptSessionId, call])
8863
8931
 
8864
8932
  const confirm = async () => {
8865
8933
  if (!prompt) return
@@ -8917,11 +8985,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
8917
8985
  } catch (e) {
8918
8986
  setError(String(e?.message || e))
8919
8987
  }
8920
- decided.current.add(prompt.sessionId)
8988
+ // 宿主复用空白会话;“稍后”只在本次停留期间抑制询问。
8989
+ deferred.current = prompt.sessionId
8921
8990
  setPrompt(null)
8922
8991
  }
8923
8992
 
8924
- if (!prompt) return null
8993
+ if (!prompt || prompt.sessionId !== current) return null
8925
8994
  const libraries = prompt.libraries || []
8926
8995
  const folder = prompt.folder || null
8927
8996
  const privateBlocked = folder ? folder.useLibrary === false : false
@@ -258,7 +258,7 @@ export function completeJob({
258
258
  }
259
259
 
260
260
  /** 失败:清掉 inflight、把范围退回 pending、按尝试次数退避。 */
261
- export function failJob({ sessionId, jobId, reasonCode = 'failed', retryable = true, error = null, now = Date.now() }) {
261
+ export function failJob({ sessionId, jobId, reasonCode = 'failed', retryable = true, error = null, executionKey = null, executionSettingsKey = null, executionDefaultsComparable = true, now = Date.now() }) {
262
262
  return mutateLedger((ledger) => {
263
263
  const entry = ensureEntry(ledger, sessionId)
264
264
  const job = entry.inflight && entry.inflight.jobId === jobId ? entry.inflight : null
@@ -282,12 +282,16 @@ export function failJob({ sessionId, jobId, reasonCode = 'failed', retryable = t
282
282
  if (job.snapshot?.hash) {
283
283
  const key = operationKey({ sessionId, libraryId: job.libraryId, snapshotHash: job.snapshot.hash, scopeGeneration: job.scopeGeneration })
284
284
  const prior = entry.operations[key]
285
+ const effectiveExecutionKey = executionKey && !executionDefaultsComparable && executionSettingsKey === prior?.executionSettingsKey
286
+ ? prior?.executionKey || executionKey : executionKey
285
287
  entry.operations[key] = {
286
288
  outcome: 'failed',
287
289
  ids: Array.isArray(prior?.ids) ? prior.ids : [],
288
290
  at: stamp(),
289
- failures: (Number(prior?.failures) || 0) + 1,
291
+ failures: (effectiveExecutionKey && prior?.executionKey && effectiveExecutionKey !== prior.executionKey ? 0 : Number(prior?.failures) || 0) + 1,
290
292
  firstFailedAt: prior?.firstFailedAt || stamp(),
293
+ ...(effectiveExecutionKey ? { executionKey: effectiveExecutionKey, executionSettingsKey } : {}),
294
+ reasonCode,
291
295
  }
292
296
  }
293
297
  pushHistory(entry, { jobId, status: 'failed', reasonCode, at: stamp() })
package/lib/inbound.js CHANGED
@@ -71,7 +71,7 @@ export function nativeInboundMessage(message) {
71
71
  let images = 0
72
72
  const content = (message?.content || []).filter(block => block?.type === 'text' || block?.type === 'image')
73
73
  .filter(block => block.type !== 'image' || ++images <= 8).slice(0, 16)
74
- .map(block => block.type === 'text' ? { type: 'text', text: String(block.text || '').slice(0, MAX_TEXT) } : block)
74
+ .map(block => block.type === 'text' ? { type: 'text', text: redactSecrets(String(block.text || '').slice(0, MAX_TEXT)) } : block)
75
75
  return content.some(block => block.type === 'image' || block.text.trim()) ? { id: message.id, role: 'user', content } : null
76
76
  }
77
77
 
@@ -136,18 +136,23 @@ export function ingestInboundBatch({ sessionId, batch, session, ctx, now = Date.
136
136
  return { accepted: accepted.length, duplicate: normalized.messages.length - accepted.length, pending: pending.length }
137
137
  }
138
138
 
139
- export function noteNativeUserMessages(sessionId, messages, { now = Date.now() } = {}) {
139
+ export function noteNativeUserMessages(sessionId, messages, { now = Date.now(), admitted = false } = {}) {
140
+ if (!admitted) return
140
141
  const binding = getSessionBinding(sessionId)
141
142
  if (!binding) return
142
143
  const before = journal(binding)
143
- const keys = messages.filter(message => message?.source?.kind === 'user' && message.role === 'user' && typeof message.id === 'string')
144
- .map(message => messageKey({ id: message.id, context: binding.memoryContext }))
144
+ const native = messages.filter(message => message?.source?.kind === 'user' && message.role === 'user' && typeof message.id === 'string')
145
+ const keys = native.map(message => messageKey({ id: message.id, context: binding.memoryContext }))
145
146
  const seen = [...new Set([...before.seen, ...keys])].slice(-MAX_SEEN)
146
147
  setSessionBinding(sessionId, {
147
- inbound: { ...before, seen, pending: before.pending.filter(item => !keys.includes(item.key)) },
148
+ inbound: { ...before, seen, pending: before.pending.map(item => native.some(message => item.producer === 'host.user'
149
+ && item.id === message.id && JSON.stringify(item.content) === JSON.stringify(nativeInboundMessage(message)?.content))
150
+ ? { ...item, nativeAdmitted: true } : item) },
148
151
  lastTurnAt: new Date(now).toISOString(),
149
152
  sessionGone: false, sessionGoneAt: null,
150
153
  })
154
+ const outcome = getSessionBinding(sessionId)?.lastInboundOutcome
155
+ if (outcome?.keys?.length) finishInbound(sessionId, outcome.keys, outcome.clock, outcome)
151
156
  }
152
157
 
153
158
  export function hasPendingInbound(sessionId) {
@@ -188,10 +193,19 @@ export function finishInbound(sessionId, keys, clock, outcome) {
188
193
  if (!binding) return
189
194
  const before = journal(binding)
190
195
  const done = new Set(keys)
191
- const claims = before.pending.filter(item => done.has(item.key)).map(item => deliveryClaim({ producer: item.producer, batchId: item.batchId }))
196
+ const matched = before.pending.filter(item => done.has(item.key))
197
+ if (!matched.length) return
198
+ const ready = matched.filter(item => item.producer === 'host.user' ? item.nativeAdmitted === true : outcome?.admitted === true)
199
+ if (ready.length !== matched.length) {
200
+ setSessionBinding(sessionId, { lastInboundOutcome: { ...structuredClone(outcome), status: 'proposed',
201
+ keys: [...keys], clock, at: new Date().toISOString(), count: matched.length } })
202
+ }
203
+ if (!ready.length) return
204
+ const readyKeys = new Set(ready.map(item => item.key))
205
+ const claims = ready.map(item => deliveryClaim({ producer: item.producer, batchId: item.batchId }))
192
206
  setSessionBinding(sessionId, {
193
- inbound: { ...before, seen: [...new Set([...before.seen, ...keys])].slice(-MAX_SEEN), claimed: [...new Set([...before.claimed, ...claims])].slice(-MAX_SEEN), pending: before.pending.filter(item => !done.has(item.key)), clock, retryAt: null },
194
- lastInboundOutcome: { ...outcome, at: new Date().toISOString(), count: keys.length },
207
+ inbound: { ...before, seen: [...new Set([...before.seen, ...readyKeys])].slice(-MAX_SEEN), claimed: [...new Set([...before.claimed, ...claims])].slice(-MAX_SEEN), pending: before.pending.filter(item => !readyKeys.has(item.key)), clock: Math.max(Number(before.clock || 0), Number(clock) || 0), retryAt: null },
208
+ lastInboundOutcome: { ...structuredClone(outcome), keys: [...keys], clock, at: new Date().toISOString(), count: ready.length },
195
209
  })
196
210
  flushState()
197
211
  }
@@ -249,11 +263,12 @@ export function observeInboundEvent(ctx, session, event) {
249
263
  const binding = getSessionBinding(id)
250
264
  if (!binding || !event.data.id) return
251
265
  const message = nativeInboundMessage(event.data)
252
- if (!message) { noteNativeUserMessages(id, [event.data]); return }
266
+ if (!message) { noteNativeUserMessages(id, [event.data], { admitted: true }); return }
253
267
  ingestInboundBatch({ sessionId: id, session, ctx, batch: {
254
268
  type: INBOUND_TYPE, version: 1, producer: 'host.user', batchId: `user:${event.data.id}`,
255
269
  messages: [message],
256
270
  }, mediaEventKey: event.seq !== undefined ? `seq:${event.seq}` : `id:${event.data.id}` })
271
+ noteNativeUserMessages(id, [event.data], { admitted: true })
257
272
  } else if (event?.type === 'turn/end') {
258
273
  calls.delete(id)
259
274
  }