dominds 1.5.1 → 1.5.2

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 (101) hide show
  1. package/dist/dialog-fork.js +7 -6
  2. package/dist/docs/agent-priming.md +38 -0
  3. package/dist/docs/agent-priming.zh.md +34 -0
  4. package/dist/llm/kernel-driver/subdialog.js +17 -13
  5. package/dist/llm/kernel-driver/tellask-special.js +8 -7
  6. package/dist/persistence.js +48 -24
  7. package/dist/priming.js +151 -17
  8. package/dist/shared/types/storage.js +77 -0
  9. package/dist/static/assets/{_basePickBy-C-nynT9f.js → _basePickBy-B-A5XrWM.js} +3 -3
  10. package/dist/static/assets/{_basePickBy-C-nynT9f.js.map → _basePickBy-B-A5XrWM.js.map} +1 -1
  11. package/dist/static/assets/{_baseUniq-CiHd-eVT.js → _baseUniq-BANLb0cu.js} +2 -2
  12. package/dist/static/assets/{_baseUniq-CiHd-eVT.js.map → _baseUniq-BANLb0cu.js.map} +1 -1
  13. package/dist/static/assets/{arc-_OJzDWy1.js → arc-CYZYnojf.js} +2 -2
  14. package/dist/static/assets/{arc-_OJzDWy1.js.map → arc-CYZYnojf.js.map} +1 -1
  15. package/dist/static/assets/{architectureDiagram-VXUJARFQ-CDEG85ub.js → architectureDiagram-VXUJARFQ-Cxf4pmYG.js} +7 -7
  16. package/dist/static/assets/{architectureDiagram-VXUJARFQ-CDEG85ub.js.map → architectureDiagram-VXUJARFQ-Cxf4pmYG.js.map} +1 -1
  17. package/dist/static/assets/{blockDiagram-VD42YOAC-1LzKVc5t.js → blockDiagram-VD42YOAC-wvs0G30c.js} +7 -7
  18. package/dist/static/assets/{blockDiagram-VD42YOAC-1LzKVc5t.js.map → blockDiagram-VD42YOAC-wvs0G30c.js.map} +1 -1
  19. package/dist/static/assets/{c4Diagram-YG6GDRKO-BzYnVyvY.js → c4Diagram-YG6GDRKO-BKFNexn4.js} +3 -3
  20. package/dist/static/assets/{c4Diagram-YG6GDRKO-BzYnVyvY.js.map → c4Diagram-YG6GDRKO-BKFNexn4.js.map} +1 -1
  21. package/dist/static/assets/{channel-VAEDAk9T.js → channel-_1qpxJWy.js} +2 -2
  22. package/dist/static/assets/{channel-VAEDAk9T.js.map → channel-_1qpxJWy.js.map} +1 -1
  23. package/dist/static/assets/{chunk-4BX2VUAB-D0r2u3mX.js → chunk-4BX2VUAB-BIdC0phm.js} +2 -2
  24. package/dist/static/assets/{chunk-4BX2VUAB-D0r2u3mX.js.map → chunk-4BX2VUAB-BIdC0phm.js.map} +1 -1
  25. package/dist/static/assets/{chunk-55IACEB6-Dkl8Xw7i.js → chunk-55IACEB6-BNvGenQ9.js} +2 -2
  26. package/dist/static/assets/{chunk-55IACEB6-Dkl8Xw7i.js.map → chunk-55IACEB6-BNvGenQ9.js.map} +1 -1
  27. package/dist/static/assets/{chunk-B4BG7PRW-9sxsI8ns.js → chunk-B4BG7PRW-jmf-1Wv7.js} +5 -5
  28. package/dist/static/assets/{chunk-B4BG7PRW-9sxsI8ns.js.map → chunk-B4BG7PRW-jmf-1Wv7.js.map} +1 -1
  29. package/dist/static/assets/{chunk-DI55MBZ5-AHaqkaLl.js → chunk-DI55MBZ5-nmEmcikR.js} +4 -4
  30. package/dist/static/assets/{chunk-DI55MBZ5-AHaqkaLl.js.map → chunk-DI55MBZ5-nmEmcikR.js.map} +1 -1
  31. package/dist/static/assets/{chunk-FMBD7UC4-NWDLDixD.js → chunk-FMBD7UC4-kGysaq_j.js} +2 -2
  32. package/dist/static/assets/{chunk-FMBD7UC4-NWDLDixD.js.map → chunk-FMBD7UC4-kGysaq_j.js.map} +1 -1
  33. package/dist/static/assets/{chunk-QN33PNHL-C2KeUqle.js → chunk-QN33PNHL-8JwMLFIJ.js} +2 -2
  34. package/dist/static/assets/{chunk-QN33PNHL-C2KeUqle.js.map → chunk-QN33PNHL-8JwMLFIJ.js.map} +1 -1
  35. package/dist/static/assets/{chunk-QZHKN3VN-B6Eoxo5L.js → chunk-QZHKN3VN-DZleEj00.js} +2 -2
  36. package/dist/static/assets/{chunk-QZHKN3VN-B6Eoxo5L.js.map → chunk-QZHKN3VN-DZleEj00.js.map} +1 -1
  37. package/dist/static/assets/{chunk-TZMSLE5B-Bc-VyQon.js → chunk-TZMSLE5B-CXxl_uqH.js} +2 -2
  38. package/dist/static/assets/{chunk-TZMSLE5B-Bc-VyQon.js.map → chunk-TZMSLE5B-CXxl_uqH.js.map} +1 -1
  39. package/dist/static/assets/{classDiagram-2ON5EDUG-DmPfsN1H.js → classDiagram-2ON5EDUG-C-7R0QB6.js} +6 -6
  40. package/dist/static/assets/{classDiagram-2ON5EDUG-DmPfsN1H.js.map → classDiagram-2ON5EDUG-C-7R0QB6.js.map} +1 -1
  41. package/dist/static/assets/{classDiagram-v2-WZHVMYZB-DmPfsN1H.js → classDiagram-v2-WZHVMYZB-C-7R0QB6.js} +6 -6
  42. package/dist/static/assets/{classDiagram-v2-WZHVMYZB-DmPfsN1H.js.map → classDiagram-v2-WZHVMYZB-C-7R0QB6.js.map} +1 -1
  43. package/dist/static/assets/{clone-B1R4pLTW.js → clone-BwOKYSj8.js} +2 -2
  44. package/dist/static/assets/{clone-B1R4pLTW.js.map → clone-BwOKYSj8.js.map} +1 -1
  45. package/dist/static/assets/{cose-bilkent-S5V4N54A-CxY__sKv.js → cose-bilkent-S5V4N54A-BCBalM7p.js} +2 -2
  46. package/dist/static/assets/{cose-bilkent-S5V4N54A-CxY__sKv.js.map → cose-bilkent-S5V4N54A-BCBalM7p.js.map} +1 -1
  47. package/dist/static/assets/{dagre-6UL2VRFP-CPkB5tQ0.js → dagre-6UL2VRFP-uV2ekQoj.js} +7 -7
  48. package/dist/static/assets/{dagre-6UL2VRFP-CPkB5tQ0.js.map → dagre-6UL2VRFP-uV2ekQoj.js.map} +1 -1
  49. package/dist/static/assets/{diagram-PSM6KHXK-C6kCVpCz.js → diagram-PSM6KHXK-D-ZMog1-.js} +8 -8
  50. package/dist/static/assets/{diagram-PSM6KHXK-C6kCVpCz.js.map → diagram-PSM6KHXK-D-ZMog1-.js.map} +1 -1
  51. package/dist/static/assets/{diagram-QEK2KX5R-BWF6htf1.js → diagram-QEK2KX5R-BThSELUH.js} +7 -7
  52. package/dist/static/assets/{diagram-QEK2KX5R-BWF6htf1.js.map → diagram-QEK2KX5R-BThSELUH.js.map} +1 -1
  53. package/dist/static/assets/{diagram-S2PKOQOG-lKGJH6O9.js → diagram-S2PKOQOG-Di-YN5cd.js} +7 -7
  54. package/dist/static/assets/{diagram-S2PKOQOG-lKGJH6O9.js.map → diagram-S2PKOQOG-Di-YN5cd.js.map} +1 -1
  55. package/dist/static/assets/{erDiagram-Q2GNP2WA-DJ3YaFob.js → erDiagram-Q2GNP2WA-lBZ9DITn.js} +5 -5
  56. package/dist/static/assets/{erDiagram-Q2GNP2WA-DJ3YaFob.js.map → erDiagram-Q2GNP2WA-lBZ9DITn.js.map} +1 -1
  57. package/dist/static/assets/{flowDiagram-NV44I4VS-h3eQwA3O.js → flowDiagram-NV44I4VS-C_60PNQR.js} +6 -6
  58. package/dist/static/assets/{flowDiagram-NV44I4VS-h3eQwA3O.js.map → flowDiagram-NV44I4VS-C_60PNQR.js.map} +1 -1
  59. package/dist/static/assets/{ganttDiagram-JELNMOA3-BCbsDOF_.js → ganttDiagram-JELNMOA3-Dvqq-VHJ.js} +3 -3
  60. package/dist/static/assets/{ganttDiagram-JELNMOA3-BCbsDOF_.js.map → ganttDiagram-JELNMOA3-Dvqq-VHJ.js.map} +1 -1
  61. package/dist/static/assets/{gitGraphDiagram-V2S2FVAM-D0kX6h-T.js → gitGraphDiagram-V2S2FVAM-BTj8orRe.js} +8 -8
  62. package/dist/static/assets/{gitGraphDiagram-V2S2FVAM-D0kX6h-T.js.map → gitGraphDiagram-V2S2FVAM-BTj8orRe.js.map} +1 -1
  63. package/dist/static/assets/{graph-CZIEXp3A.js → graph-BqCzR2Nl.js} +3 -3
  64. package/dist/static/assets/{graph-CZIEXp3A.js.map → graph-BqCzR2Nl.js.map} +1 -1
  65. package/dist/static/assets/{index-vIzCTZQE.js → index-DrTqAfFy.js} +261 -197
  66. package/dist/static/assets/index-DrTqAfFy.js.map +1 -0
  67. package/dist/static/assets/{infoDiagram-HS3SLOUP-DUNbcXxv.js → infoDiagram-HS3SLOUP-DlC6wsrv.js} +6 -6
  68. package/dist/static/assets/{infoDiagram-HS3SLOUP-DUNbcXxv.js.map → infoDiagram-HS3SLOUP-DlC6wsrv.js.map} +1 -1
  69. package/dist/static/assets/{journeyDiagram-XKPGCS4Q-Cg_VhiqB.js → journeyDiagram-XKPGCS4Q-Dg_RgtQX.js} +5 -5
  70. package/dist/static/assets/{journeyDiagram-XKPGCS4Q-Cg_VhiqB.js.map → journeyDiagram-XKPGCS4Q-Dg_RgtQX.js.map} +1 -1
  71. package/dist/static/assets/{kanban-definition-3W4ZIXB7-DMVCZVFE.js → kanban-definition-3W4ZIXB7-DuGS3lId.js} +3 -3
  72. package/dist/static/assets/{kanban-definition-3W4ZIXB7-DMVCZVFE.js.map → kanban-definition-3W4ZIXB7-DuGS3lId.js.map} +1 -1
  73. package/dist/static/assets/{layout-DoKTmwlM.js → layout-FDz2bstZ.js} +5 -5
  74. package/dist/static/assets/{layout-DoKTmwlM.js.map → layout-FDz2bstZ.js.map} +1 -1
  75. package/dist/static/assets/{linear-DFVlPfX6.js → linear-CzsdvPGb.js} +2 -2
  76. package/dist/static/assets/{linear-DFVlPfX6.js.map → linear-CzsdvPGb.js.map} +1 -1
  77. package/dist/static/assets/{mindmap-definition-VGOIOE7T-l5K7agVV.js → mindmap-definition-VGOIOE7T-WsAF5UNp.js} +4 -4
  78. package/dist/static/assets/{mindmap-definition-VGOIOE7T-l5K7agVV.js.map → mindmap-definition-VGOIOE7T-WsAF5UNp.js.map} +1 -1
  79. package/dist/static/assets/{pieDiagram-ADFJNKIX-BfQzSE-A.js → pieDiagram-ADFJNKIX-DJpRJ5ei.js} +8 -8
  80. package/dist/static/assets/{pieDiagram-ADFJNKIX-BfQzSE-A.js.map → pieDiagram-ADFJNKIX-DJpRJ5ei.js.map} +1 -1
  81. package/dist/static/assets/{quadrantDiagram-AYHSOK5B-CJWvA5jc.js → quadrantDiagram-AYHSOK5B-CMyIzTkY.js} +3 -3
  82. package/dist/static/assets/{quadrantDiagram-AYHSOK5B-CJWvA5jc.js.map → quadrantDiagram-AYHSOK5B-CMyIzTkY.js.map} +1 -1
  83. package/dist/static/assets/{requirementDiagram-UZGBJVZJ-CeBbmqBK.js → requirementDiagram-UZGBJVZJ-D_yqVXGu.js} +4 -4
  84. package/dist/static/assets/{requirementDiagram-UZGBJVZJ-CeBbmqBK.js.map → requirementDiagram-UZGBJVZJ-D_yqVXGu.js.map} +1 -1
  85. package/dist/static/assets/{sankeyDiagram-TZEHDZUN-JeUBTDxx.js → sankeyDiagram-TZEHDZUN-D4-cF724.js} +2 -2
  86. package/dist/static/assets/{sankeyDiagram-TZEHDZUN-JeUBTDxx.js.map → sankeyDiagram-TZEHDZUN-D4-cF724.js.map} +1 -1
  87. package/dist/static/assets/{sequenceDiagram-WL72ISMW-Bd_7Pgc5.js → sequenceDiagram-WL72ISMW-B7J3gWYN.js} +4 -4
  88. package/dist/static/assets/{sequenceDiagram-WL72ISMW-Bd_7Pgc5.js.map → sequenceDiagram-WL72ISMW-B7J3gWYN.js.map} +1 -1
  89. package/dist/static/assets/{stateDiagram-FKZM4ZOC-D_WyM3K1.js → stateDiagram-FKZM4ZOC-DwEYYCcu.js} +9 -9
  90. package/dist/static/assets/{stateDiagram-FKZM4ZOC-D_WyM3K1.js.map → stateDiagram-FKZM4ZOC-DwEYYCcu.js.map} +1 -1
  91. package/dist/static/assets/{stateDiagram-v2-4FDKWEC3-Q_yh26yx.js → stateDiagram-v2-4FDKWEC3-D4LOOQV5.js} +5 -5
  92. package/dist/static/assets/{stateDiagram-v2-4FDKWEC3-Q_yh26yx.js.map → stateDiagram-v2-4FDKWEC3-D4LOOQV5.js.map} +1 -1
  93. package/dist/static/assets/{timeline-definition-IT6M3QCI-Ca8mCFDg.js → timeline-definition-IT6M3QCI-CyG-TJ_A.js} +3 -3
  94. package/dist/static/assets/{timeline-definition-IT6M3QCI-Ca8mCFDg.js.map → timeline-definition-IT6M3QCI-CyG-TJ_A.js.map} +1 -1
  95. package/dist/static/assets/{treemap-GDKQZRPO-CyBvKC8o.js → treemap-GDKQZRPO-yY4GiKmU.js} +5 -5
  96. package/dist/static/assets/{treemap-GDKQZRPO-CyBvKC8o.js.map → treemap-GDKQZRPO-yY4GiKmU.js.map} +1 -1
  97. package/dist/static/assets/{xychartDiagram-PRI3JC2R-DY0BLEdj.js → xychartDiagram-PRI3JC2R-5TYN_q15.js} +3 -3
  98. package/dist/static/assets/{xychartDiagram-PRI3JC2R-DY0BLEdj.js.map → xychartDiagram-PRI3JC2R-5TYN_q15.js.map} +1 -1
  99. package/dist/static/index.html +1 -1
  100. package/package.json +1 -1
  101. package/dist/static/assets/index-vIzCTZQE.js.map +0 -1
@@ -8,12 +8,13 @@ const promises_1 = __importDefault(require("node:fs/promises"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const dialog_1 = require("./dialog");
10
10
  const persistence_1 = require("./persistence");
11
+ const storage_1 = require("./shared/types/storage");
11
12
  const time_1 = require("./shared/utils/time");
12
13
  const id_1 = require("./utils/id");
13
- const FORK_BASELINE_ANCHOR = {
14
+ const FORK_BASELINE_ANCHOR = (0, storage_1.toRootGenerationAnchor)({
14
15
  rootCourse: 1,
15
16
  rootGenseq: 0,
16
- };
17
+ });
17
18
  function compareRootAnchor(left, right) {
18
19
  if (left.rootCourse < right.rootCourse)
19
20
  return -1;
@@ -126,10 +127,10 @@ function getRecordRootAnchor(record) {
126
127
  if (rootCourse === null || rootGenseq === null) {
127
128
  return null;
128
129
  }
129
- return {
130
+ return (0, storage_1.toRootGenerationAnchor)({
130
131
  rootCourse,
131
132
  rootGenseq,
132
- };
133
+ });
133
134
  }
134
135
  function normalizeDraftUserText(events, targetGenseq) {
135
136
  const texts = events
@@ -527,10 +528,10 @@ async function forkRootDialogTreeAtGeneration(args) {
527
528
  if (!targetStartEvent) {
528
529
  throw new Error(`Target genseq ${String(targetGenseq)} missing start event in dialog ${sourceRootId} course ${String(targetCourse)}`);
529
530
  }
530
- const cutoffAnchor = {
531
+ const cutoffAnchor = (0, storage_1.toRootGenerationAnchor)({
531
532
  rootCourse: targetCourse,
532
533
  rootGenseq: targetGenseq - 1,
533
- };
534
+ });
534
535
  const draftUserText = normalizeDraftUserText(rootEvents, targetGenseq);
535
536
  const latest = await persistence_1.DialogPersistence.loadDialogLatest(sourceRootDialogId, args.sourceStatus);
536
537
  const targetRootId = (0, id_1.generateDialogID)();
@@ -11,6 +11,23 @@ Priming is unified as an editable, versionable, replayable Markdown startup-scri
11
11
  - Explicit selection: users choose scripts at dialog creation time.
12
12
  - Visibility control: script-origin bubbles can be shown or hidden in UI.
13
13
 
14
+ ## Semantic Boundary
15
+
16
+ `priming` is currently not a full dialog checkpoint. It is a combination of dialog history plus a
17
+ reminder snapshot.
18
+
19
+ - Preserved:
20
+ - transcript / tool / tellask history records
21
+ - current reminder snapshot
22
+ - Explicitly dropped:
23
+ - pending subdialogs
24
+ - questions4human
25
+ - subdialog registry / subdialog responses
26
+ - other runtime-only waiting / blocking / orchestration state
27
+
28
+ This is an intentional semantic downgrade relative to a full runtime snapshot: a new dialog inherits
29
+ history and reminders, but it does not inherit in-flight workflow state.
30
+
14
31
  ## Storage Layout
15
32
 
16
33
  All scripts live under `.minds/priming/` in rtws:
@@ -39,9 +56,25 @@ version: 3
39
56
  title: Environment Probe Startup
40
57
  applicableMemberIds:
41
58
  - ux
59
+ reminders:
60
+ - content: Record the key result of each environment probe
61
+ meta:
62
+ source: priming
63
+ sticky: true
64
+ echoback: false
42
65
  ---
43
66
  ```
44
67
 
68
+ `reminders` is an optional top-level snapshot field and may be edited manually. Each reminder item
69
+ supports:
70
+
71
+ - `content`: required reminder text
72
+ - `ownerName`: optional registered ReminderOwner name; replay fails loudly if it is unknown
73
+ - `meta`: optional JSON-compatible data
74
+ - `echoback`: optional numbering/echo-back flag
75
+ - `createdAt`: optional timestamp string
76
+ - `priority`: optional `high | medium | low`
77
+
45
78
  ### Record blocks (required)
46
79
 
47
80
  Each section must be `### record <record-type>`.
@@ -121,9 +154,11 @@ Request contract:
121
154
  Runtime behavior:
122
155
 
123
156
  - On root dialog creation, selected scripts are replayed into `course-1`.
157
+ - If top-level frontmatter contains `reminders`, the current reminder snapshot is restored first.
124
158
  - Replayed events are tagged with `sourceTag: priming_script`.
125
159
  - Replay is injected into `dialog.msgs` for downstream model context.
126
160
  - `showInUi=false` only affects rendering; persistence/context remain unchanged.
161
+ - `pending/q4h/subdialog-*` runtime state is not restored.
127
162
 
128
163
  ## Save Startup Script (WebUI)
129
164
 
@@ -135,8 +170,11 @@ Runtime behavior:
135
170
  Export rules:
136
171
 
137
172
  - Export full course record history.
173
+ - Export the current reminder snapshot into top-level frontmatter.
138
174
  - Empty course export is rejected.
139
175
  - Frontmatter stores source dialog metadata (`rootId/selfId/course/status`).
176
+ - `pending/q4h/subdialog-*` runtime state is not exported; this is an explicit semantic downgrade in
177
+ the current priming design.
140
178
 
141
179
  ## Recent Usage Storage
142
180
 
@@ -11,6 +11,21 @@
11
11
  - 显式选择:创建对话时由用户明确选择,不做隐式注入。
12
12
  - 可见性可控:可选择是否在 UI 展示由脚本注入的历史气泡。
13
13
 
14
+ ## 语义边界(重要)
15
+
16
+ `priming` 目前不是“完整对话 checkpoint”,而是“对话历史 + reminder 快照”。
17
+
18
+ - 会保留:
19
+ - transcript / tool / tellask 等历史 record
20
+ - 当前 reminder 快照
21
+ - 会明确丢弃:
22
+ - pending subdialogs
23
+ - questions4human
24
+ - subdialog registry / subdialog responses
25
+ - 其它依赖运行中协程、阻塞关系、等待关系的 runtime state
26
+
27
+ 这意味着把某个对话“保存为启动脚本”时,语义上相对完整运行时状态是有降级的:新对话会继承历史和 reminder,但不会继承“仍在等待中的工作流状态”。
28
+
14
29
  ## 存储布局
15
30
 
16
31
  脚本统一放在 rtws 的 `.minds/priming/` 下:
@@ -39,9 +54,24 @@ version: 3
39
54
  title: 环境探针启动
40
55
  applicableMemberIds:
41
56
  - ux
57
+ reminders:
58
+ - content: 记录每次环境探针的关键结论
59
+ meta:
60
+ source: priming
61
+ sticky: true
62
+ echoback: false
42
63
  ---
43
64
  ```
44
65
 
66
+ 其中 `reminders` 是可选的顶层快照字段,支持手工编辑。每项字段为:
67
+
68
+ - `content`: 必填,提醒正文
69
+ - `ownerName`: 可选,ReminderOwner 注册名;若填写但运行时未注册,将报错
70
+ - `meta`: 可选,JSON 兼容数据
71
+ - `echoback`: 可选,是否参与编号/回显
72
+ - `createdAt`: 可选,时间戳字符串
73
+ - `priority`: 可选,`high | medium | low`
74
+
45
75
  ### record 块(必填)
46
76
 
47
77
  每段必须是:`### record <record-type>`。
@@ -119,9 +149,11 @@ Darwin ...
119
149
  运行时行为:
120
150
 
121
151
  - 创建 root dialog 后,按 `scriptRefs` 回放脚本。
152
+ - 若脚本顶层 frontmatter 含 `reminders`,会先恢复当前 reminder 快照。
122
153
  - 回放事件写入 `course-1`,并统一标记 `sourceTag: priming_script`。
123
154
  - 同步注入 `dialog.msgs`,确保后续 LLM 上下文可见。
124
155
  - `showInUi=false` 时仅隐藏展示,不影响持久化与上下文。
156
+ - `pending/q4h/subdialog-*` 等 runtime state 不会被恢复。
125
157
 
126
158
  ## 保存启动脚本(WebUI)
127
159
 
@@ -133,8 +165,10 @@ Darwin ...
133
165
  导出规则:
134
166
 
135
167
  - 从当前 course 导出完整 record 历史。
168
+ - 同时导出“当前 reminder 快照”到顶层 frontmatter。
136
169
  - 空历史禁止导出。
137
170
  - frontmatter 记录来源对话(rootId/selfId/course/status)。
171
+ - `pending/q4h/subdialog-*` 等 runtime state 不导出;这是当前设计下的显式语义降级。
138
172
 
139
173
  ## recent 使用记录
140
174
 
@@ -9,6 +9,7 @@ const dialog_instance_registry_1 = require("../../dialog-instance-registry");
9
9
  const log_1 = require("../../log");
10
10
  const persistence_1 = require("../../persistence");
11
11
  const runtime_language_1 = require("../../shared/runtime-language");
12
+ const storage_1 = require("../../shared/types/storage");
12
13
  const inter_dialog_format_1 = require("../../shared/utils/inter-dialog-format");
13
14
  const time_1 = require("../../shared/utils/time");
14
15
  const pending_tellask_reminder_1 = require("../../tools/pending-tellask-reminder");
@@ -235,14 +236,14 @@ async function supplyResponseToSupdialog(args) {
235
236
  (!Array.isArray(mentionList) || mentionList.length < 1)) {
236
237
  mentionList = [`@${responderId}`];
237
238
  }
238
- await persistence_1.DialogPersistence.savePendingSubdialogs(parentDialog.id, filteredPending, {
239
+ await persistence_1.DialogPersistence.savePendingSubdialogs(parentDialog.id, filteredPending, (0, storage_1.toRootGenerationAnchor)({
239
240
  rootCourse: parentDialog instanceof dialog_1.SubDialog
240
241
  ? parentDialog.rootDialog.currentCourse
241
242
  : parentDialog.currentCourse,
242
243
  rootGenseq: parentDialog instanceof dialog_1.SubDialog
243
244
  ? (parentDialog.rootDialog.activeGenSeqOrUndefined ?? 0)
244
245
  : (parentDialog.activeGenSeqOrUndefined ?? 0),
245
- }, parentDialog.status);
246
+ }), parentDialog.status);
246
247
  const hasQ4H = await parentDialog.hasPendingQ4H();
247
248
  const shouldRevive = !hasQ4H && filteredPending.length === 0;
248
249
  if (shouldRevive && parentDialog instanceof dialog_1.RootDialog) {
@@ -257,12 +258,7 @@ async function supplyResponseToSupdialog(args) {
257
258
  originMemberId,
258
259
  sessionSlug,
259
260
  callId: pendingRecord?.callId,
260
- callingCourse: pendingRecord &&
261
- typeof pendingRecord.callingCourse === 'number' &&
262
- Number.isFinite(pendingRecord.callingCourse) &&
263
- pendingRecord.callingCourse > 0
264
- ? Math.floor(pendingRecord.callingCourse)
265
- : undefined,
261
+ callingCourse: pendingRecord?.callingCourse,
266
262
  shouldRevive,
267
263
  };
268
264
  });
@@ -314,10 +310,14 @@ async function supplyResponseToSupdialog(args) {
314
310
  anchorRole: 'response',
315
311
  callId: resolvedCallId,
316
312
  genseq: calleeResponseRef.genseq,
317
- assignmentCourse: assignmentRef?.course,
318
- assignmentGenseq: assignmentRef?.genseq,
313
+ assignmentCourse: assignmentRef !== undefined ? (0, storage_1.toAssignmentCourseNumber)(assignmentRef.course) : undefined,
314
+ assignmentGenseq: assignmentRef !== undefined
315
+ ? (0, storage_1.toAssignmentGenerationSeqNumber)(assignmentRef.genseq)
316
+ : undefined,
319
317
  callerDialogId: parentDialog.id.selfId,
320
- callerCourse: result.callingCourse,
318
+ callerCourse: result.callingCourse !== undefined
319
+ ? (0, storage_1.toCallerCourseNumber)(result.callingCourse)
320
+ : undefined,
321
321
  };
322
322
  await persistence_1.DialogPersistence.appendEvent(subdialogId, calleeResponseRef.course, anchorRecord, parentDialog.status);
323
323
  }
@@ -328,8 +328,12 @@ async function supplyResponseToSupdialog(args) {
328
328
  callId: resolvedCallId,
329
329
  originMemberId: requesterId,
330
330
  sessionSlug: result.sessionSlug,
331
- calleeCourse: calleeResponseRef?.course,
332
- calleeGenseq: calleeResponseRef?.genseq,
331
+ calleeCourse: calleeResponseRef !== undefined
332
+ ? (0, storage_1.toCalleeCourseNumber)(calleeResponseRef.course)
333
+ : undefined,
334
+ calleeGenseq: calleeResponseRef !== undefined
335
+ ? (0, storage_1.toCalleeGenerationSeqNumber)(calleeResponseRef.genseq)
336
+ : undefined,
333
337
  });
334
338
  const immediateMirror = {
335
339
  type: 'tellask_result_msg',
@@ -10,6 +10,7 @@ const log_1 = require("../../log");
10
10
  const persistence_1 = require("../../persistence");
11
11
  const driver_messages_1 = require("../../shared/i18n/driver-messages");
12
12
  const runtime_language_1 = require("../../shared/runtime-language");
13
+ const storage_1 = require("../../shared/types/storage");
13
14
  const fbr_1 = require("../../shared/utils/fbr");
14
15
  const id_1 = require("../../shared/utils/id");
15
16
  const inter_dialog_format_1 = require("../../shared/utils/inter-dialog-format");
@@ -439,7 +440,7 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
439
440
  const subdialogCallName = callName === 'tellaskBack' ? 'freshBootsReasoning' : callName;
440
441
  const rawCallingCourse = dlg.activeGenCourseOrUndefined ?? dlg.currentCourse;
441
442
  const callingCourse = Number.isFinite(rawCallingCourse) && rawCallingCourse > 0
442
- ? Math.floor(rawCallingCourse)
443
+ ? (0, storage_1.toCallingCourseNumber)(rawCallingCourse)
443
444
  : undefined;
444
445
  const firstMentionForError = options.targetForError ?? parseResult.agentId;
445
446
  if (parseResult.type !== 'A' && member === null) {
@@ -562,12 +563,12 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
562
563
  callType: 'C',
563
564
  };
564
565
  await (0, subdialog_txn_1.withSubdialogTxnLock)(dlg.id, async () => {
565
- await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord, {
566
+ await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord, (0, storage_1.toRootGenerationAnchor)({
566
567
  rootCourse: dlg instanceof dialog_1.SubDialog ? dlg.rootDialog.currentCourse : dlg.currentCourse,
567
568
  rootGenseq: dlg instanceof dialog_1.SubDialog
568
569
  ? (dlg.rootDialog.activeGenSeqOrUndefined ?? 0)
569
570
  : (dlg.activeGenSeqOrUndefined ?? 0),
570
- });
571
+ }));
571
572
  });
572
573
  await syncPendingTellaskReminderBestEffort(dlg, 'kernel-driver:executeTellaskCall:FBR-TypeC:appendPending:lastRound');
573
574
  }
@@ -790,12 +791,12 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
790
791
  sessionSlug: parseResult.sessionSlug,
791
792
  };
792
793
  await (0, subdialog_txn_1.withSubdialogTxnLock)(dlg.id, async () => {
793
- await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord, {
794
+ await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord, (0, storage_1.toRootGenerationAnchor)({
794
795
  rootCourse: dlg instanceof dialog_1.SubDialog ? dlg.rootDialog.currentCourse : dlg.currentCourse,
795
796
  rootGenseq: dlg instanceof dialog_1.SubDialog
796
797
  ? (dlg.rootDialog.activeGenSeqOrUndefined ?? 0)
797
798
  : (dlg.activeGenSeqOrUndefined ?? 0),
798
- });
799
+ }));
799
800
  });
800
801
  await syncPendingTellaskReminderBestEffort(dlg, 'kernel-driver:executeTellaskCall:TypeB-fallback:appendPending');
801
802
  const initPrompt = {
@@ -972,12 +973,12 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
972
973
  callType: 'C',
973
974
  };
974
975
  await (0, subdialog_txn_1.withSubdialogTxnLock)(dlg.id, async () => {
975
- await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord, {
976
+ await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord, (0, storage_1.toRootGenerationAnchor)({
976
977
  rootCourse: dlg instanceof dialog_1.SubDialog ? dlg.rootDialog.currentCourse : dlg.currentCourse,
977
978
  rootGenseq: dlg instanceof dialog_1.SubDialog
978
979
  ? (dlg.rootDialog.activeGenSeqOrUndefined ?? 0)
979
980
  : (dlg.activeGenSeqOrUndefined ?? 0),
980
- });
981
+ }));
981
982
  });
982
983
  await syncPendingTellaskReminderBestEffort(dlg, 'kernel-driver:executeTellaskCall:TypeC:appendPending');
983
984
  const initPrompt = {
@@ -48,6 +48,7 @@ const dialog_1 = require("./dialog");
48
48
  const evt_registry_1 = require("./evt-registry");
49
49
  const log_1 = require("./log");
50
50
  const async_fifo_mutex_1 = require("./shared/async-fifo-mutex");
51
+ const storage_1 = require("./shared/types/storage");
51
52
  const time_1 = require("./shared/utils/time");
52
53
  const registry_1 = require("./tools/registry");
53
54
  function getErrorCode(error) {
@@ -88,11 +89,30 @@ function cloneRootGenerationAnchor(anchor) {
88
89
  }
89
90
  function resolveRootGenerationAnchor(dialog) {
90
91
  const rootDialog = dialog instanceof dialog_1.SubDialog ? dialog.rootDialog : dialog;
91
- return {
92
+ return (0, storage_1.toRootGenerationAnchor)({
92
93
  rootCourse: rootDialog.currentCourse,
93
94
  rootGenseq: rootDialog.activeGenSeqOrUndefined ?? 0,
95
+ });
96
+ }
97
+ function resolveReconciledRecordWriteTarget(dialog) {
98
+ return {
99
+ kind: 'dialog_course',
100
+ rootAnchor: resolveRootGenerationAnchor(dialog),
101
+ dialogCourse: (0, storage_1.toDialogCourseNumber)(dialog.activeGenCourseOrUndefined ?? dialog.currentCourse),
102
+ };
103
+ }
104
+ function rootAnchorWriteTarget(rootAnchor) {
105
+ return {
106
+ kind: 'root_anchor',
107
+ rootAnchor,
94
108
  };
95
109
  }
110
+ function resolveTargetCourseFromWriteTarget(writeTarget) {
111
+ if (writeTarget.kind === 'dialog_course') {
112
+ return writeTarget.dialogCourse;
113
+ }
114
+ return writeTarget.rootAnchor.rootCourse;
115
+ }
96
116
  function attachRootGenerationRef(dialog, record) {
97
117
  const anchor = resolveRootGenerationAnchor(dialog);
98
118
  return {
@@ -637,7 +657,9 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
637
657
  */
638
658
  async receiveTeammateCallResult(dialog, responderId, callName, mentionList, tellaskContent, result, status, callId) {
639
659
  const course = dialog.activeGenCourseOrUndefined ?? dialog.currentCourse;
640
- const calling_genseq = dialog.activeGenSeqOrUndefined;
660
+ const calling_genseq = dialog.activeGenSeqOrUndefined !== undefined
661
+ ? (0, storage_1.toCallingGenerationSeqNumber)(dialog.activeGenSeqOrUndefined)
662
+ : undefined;
641
663
  // Persist record WITH callId for replay correlation
642
664
  const ev = (() => {
643
665
  switch (callName) {
@@ -725,7 +747,9 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
725
747
  */
726
748
  async receiveTeammateResponse(dialog, responderId, callName, mentionList, tellaskContent, status, calleeDialogId, options) {
727
749
  const course = dialog.activeGenCourseOrUndefined ?? dialog.currentCourse;
728
- const calling_genseq = dialog.activeGenSeqOrUndefined;
750
+ const calling_genseq = dialog.activeGenSeqOrUndefined !== undefined
751
+ ? (0, storage_1.toCallingGenerationSeqNumber)(dialog.activeGenSeqOrUndefined)
752
+ : undefined;
729
753
  const calleeDialogSelfId = calleeDialogId ? calleeDialogId.selfId : undefined;
730
754
  const response = options.response;
731
755
  const agentId = options.agentId;
@@ -1206,7 +1230,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
1206
1230
  */
1207
1231
  async persistReminders(dialog, reminders) {
1208
1232
  await DialogPersistence._saveReminderState(this.dialogId, reminders);
1209
- await DialogPersistence.appendRemindersReconciledRecord(this.dialogId, reminders, resolveRootGenerationAnchor(dialog), dialog.status);
1233
+ await DialogPersistence.appendRemindersReconciledRecord(this.dialogId, reminders, resolveReconciledRecordWriteTarget(dialog), dialog.status);
1210
1234
  }
1211
1235
  /**
1212
1236
  * Persist a user message to storage
@@ -1300,7 +1324,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
1300
1324
  */
1301
1325
  async updateQuestions4Human(dialog, questions) {
1302
1326
  await DialogPersistence._saveQuestions4HumanState(this.dialogId, questions);
1303
- await DialogPersistence.appendQuestions4HumanReconciledRecord(this.dialogId, questions, resolveRootGenerationAnchor(dialog), dialog.status);
1327
+ await DialogPersistence.appendQuestions4HumanReconciledRecord(this.dialogId, questions, resolveReconciledRecordWriteTarget(dialog), dialog.status);
1304
1328
  }
1305
1329
  /**
1306
1330
  * Load Questions for Human state from storage
@@ -1332,7 +1356,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
1332
1356
  subdialogId: entry.subdialogId.selfId,
1333
1357
  agentId: entry.agentId,
1334
1358
  sessionSlug: entry.sessionSlug,
1335
- })), resolveRootGenerationAnchor(dialog), status);
1359
+ })), resolveReconciledRecordWriteTarget(dialog), status);
1336
1360
  }
1337
1361
  async loadSubdialogRegistry(rootDialog, status) {
1338
1362
  const entries = await DialogPersistence.loadSubdialogRegistry(rootDialog.id, status);
@@ -1477,7 +1501,7 @@ class DiskFileDialogStore extends dialog_1.DialogStore {
1477
1501
  const previousCount = previousQuestions.length;
1478
1502
  if (previousCount > 0) {
1479
1503
  await DialogPersistence.clearQuestions4HumanState(dialog.id);
1480
- await DialogPersistence.appendQuestions4HumanReconciledRecord(dialog.id, [], resolveRootGenerationAnchor(dialog), dialog.status);
1504
+ await DialogPersistence.appendQuestions4HumanReconciledRecord(dialog.id, [], resolveReconciledRecordWriteTarget(dialog), dialog.status);
1481
1505
  // Emit q4h_answered events for each removed question
1482
1506
  for (const q of previousQuestions) {
1483
1507
  const answeredEvent = {
@@ -2238,50 +2262,50 @@ class DialogPersistence {
2238
2262
  mentionList: response.mentionList ? [...response.mentionList] : undefined,
2239
2263
  }));
2240
2264
  }
2241
- static async appendRemindersReconciledRecord(dialogId, reminders, anchor, status) {
2265
+ static async appendRemindersReconciledRecord(dialogId, reminders, writeTarget, status) {
2242
2266
  const record = {
2243
2267
  ts: (0, time_1.formatUnifiedTimestamp)(new Date()),
2244
2268
  type: 'reminders_reconciled_record',
2245
- ...cloneRootGenerationAnchor(anchor),
2269
+ ...cloneRootGenerationAnchor(writeTarget.rootAnchor),
2246
2270
  reminders: reminders.map((reminder) => serializeReminderSnapshot(reminder)),
2247
2271
  };
2248
- await this.appendEvent(dialogId, anchor.rootCourse, record, status);
2272
+ await this.appendEvent(dialogId, resolveTargetCourseFromWriteTarget(writeTarget), record, status);
2249
2273
  }
2250
- static async appendQuestions4HumanReconciledRecord(dialogId, questions, anchor, status) {
2274
+ static async appendQuestions4HumanReconciledRecord(dialogId, questions, writeTarget, status) {
2251
2275
  const record = {
2252
2276
  ts: (0, time_1.formatUnifiedTimestamp)(new Date()),
2253
2277
  type: 'questions4human_reconciled_record',
2254
- ...cloneRootGenerationAnchor(anchor),
2278
+ ...cloneRootGenerationAnchor(writeTarget.rootAnchor),
2255
2279
  questions: this.cloneQuestions4Human(questions),
2256
2280
  };
2257
- await this.appendEvent(dialogId, anchor.rootCourse, record, status);
2281
+ await this.appendEvent(dialogId, resolveTargetCourseFromWriteTarget(writeTarget), record, status);
2258
2282
  }
2259
- static async appendPendingSubdialogsReconciledRecord(dialogId, pendingSubdialogs, anchor, status) {
2283
+ static async appendPendingSubdialogsReconciledRecord(dialogId, pendingSubdialogs, writeTarget, status) {
2260
2284
  const record = {
2261
2285
  ts: (0, time_1.formatUnifiedTimestamp)(new Date()),
2262
2286
  type: 'pending_subdialogs_reconciled_record',
2263
- ...cloneRootGenerationAnchor(anchor),
2287
+ ...cloneRootGenerationAnchor(writeTarget.rootAnchor),
2264
2288
  pendingSubdialogs: this.clonePendingSubdialogRecords(pendingSubdialogs),
2265
2289
  };
2266
- await this.appendEvent(dialogId, anchor.rootCourse, record, status);
2290
+ await this.appendEvent(dialogId, resolveTargetCourseFromWriteTarget(writeTarget), record, status);
2267
2291
  }
2268
- static async appendSubdialogRegistryReconciledRecord(dialogId, entries, anchor, status) {
2292
+ static async appendSubdialogRegistryReconciledRecord(dialogId, entries, writeTarget, status) {
2269
2293
  const record = {
2270
2294
  ts: (0, time_1.formatUnifiedTimestamp)(new Date()),
2271
2295
  type: 'subdialog_registry_reconciled_record',
2272
- ...cloneRootGenerationAnchor(anchor),
2296
+ ...cloneRootGenerationAnchor(writeTarget.rootAnchor),
2273
2297
  entries: this.cloneRegistryEntries(entries),
2274
2298
  };
2275
- await this.appendEvent(dialogId, anchor.rootCourse, record, status);
2299
+ await this.appendEvent(dialogId, resolveTargetCourseFromWriteTarget(writeTarget), record, status);
2276
2300
  }
2277
- static async appendSubdialogResponsesReconciledRecord(dialogId, responses, anchor, status) {
2301
+ static async appendSubdialogResponsesReconciledRecord(dialogId, responses, writeTarget, status) {
2278
2302
  const record = {
2279
2303
  ts: (0, time_1.formatUnifiedTimestamp)(new Date()),
2280
2304
  type: 'subdialog_responses_reconciled_record',
2281
- ...cloneRootGenerationAnchor(anchor),
2305
+ ...cloneRootGenerationAnchor(writeTarget.rootAnchor),
2282
2306
  responses: this.cloneSubdialogResponses(responses),
2283
2307
  };
2284
- await this.appendEvent(dialogId, anchor.rootCourse, record, status);
2308
+ await this.appendEvent(dialogId, resolveTargetCourseFromWriteTarget(writeTarget), record, status);
2285
2309
  }
2286
2310
  /**
2287
2311
  * Get the base dialogs directory path
@@ -3396,7 +3420,7 @@ class DialogPersistence {
3396
3420
  pending.dirty = true;
3397
3421
  }
3398
3422
  if (rootAnchor) {
3399
- await this.appendPendingSubdialogsReconciledRecord(rootDialogId, nextRecords, rootAnchor, status);
3423
+ await this.appendPendingSubdialogsReconciledRecord(rootDialogId, nextRecords, rootAnchorWriteTarget(rootAnchor), status);
3400
3424
  }
3401
3425
  return { previousRecords, records: nextRecords, removedRecords };
3402
3426
  }
@@ -3551,7 +3575,7 @@ class DialogPersistence {
3551
3575
  await fs.promises.writeFile(tempFile, jsonContent, 'utf-8');
3552
3576
  await this.renameWithRetry(tempFile, filePath, jsonContent);
3553
3577
  if (rootAnchor) {
3554
- await this.appendSubdialogResponsesReconciledRecord(rootDialogId, responses, rootAnchor, status);
3578
+ await this.appendSubdialogResponsesReconciledRecord(rootDialogId, responses, rootAnchorWriteTarget(rootAnchor), status);
3555
3579
  }
3556
3580
  }
3557
3581
  catch (error) {