dominds 1.18.2 → 1.19.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 (277) hide show
  1. package/dist/access-control.js +6 -6
  2. package/dist/apps/runtime.d.ts +2 -2
  3. package/dist/apps/runtime.js +28 -28
  4. package/dist/apps-host/client.d.ts +1 -1
  5. package/dist/apps-host/host.js +7 -7
  6. package/dist/apps-host/ipc-types.d.ts +2 -2
  7. package/dist/apps-host/ipc-types.js +10 -10
  8. package/dist/cli/read.d.ts +0 -1
  9. package/dist/cli/read.js +1 -6
  10. package/dist/dialog-display-state.d.ts +6 -6
  11. package/dist/dialog-display-state.js +46 -46
  12. package/dist/dialog-factory.d.ts +12 -12
  13. package/dist/dialog-factory.js +33 -30
  14. package/dist/dialog-fork.d.ts +2 -2
  15. package/dist/dialog-fork.js +140 -115
  16. package/dist/dialog-global-registry.d.ts +5 -5
  17. package/dist/dialog-global-registry.js +11 -11
  18. package/dist/dialog-instance-registry.d.ts +3 -3
  19. package/dist/dialog-instance-registry.js +52 -41
  20. package/dist/dialog.d.ts +100 -113
  21. package/dist/dialog.js +274 -229
  22. package/dist/docs/agent-priming.md +5 -5
  23. package/dist/docs/agent-priming.zh.md +5 -5
  24. package/dist/docs/app-constitution.md +1 -1
  25. package/dist/docs/app-constitution.zh.md +1 -1
  26. package/dist/docs/cli-usage.md +1 -1
  27. package/dist/docs/cli-usage.zh.md +1 -1
  28. package/dist/docs/design.md +14 -14
  29. package/dist/docs/design.zh.md +14 -14
  30. package/dist/docs/dialog-persistence.md +58 -58
  31. package/dist/docs/dialog-persistence.zh.md +61 -61
  32. package/dist/docs/dialog-system.md +363 -367
  33. package/dist/docs/dialog-system.zh.md +355 -357
  34. package/dist/docs/diligence-push.md +18 -18
  35. package/dist/docs/diligence-push.zh.md +17 -17
  36. package/dist/docs/dominds-agent-collaboration.zh.md +3 -3
  37. package/dist/docs/dominds-terminology.md +46 -47
  38. package/dist/docs/encapsulated-taskdoc.md +4 -4
  39. package/dist/docs/encapsulated-taskdoc.zh.md +3 -3
  40. package/dist/docs/fbr.md +30 -30
  41. package/dist/docs/fbr.zh.md +15 -15
  42. package/dist/docs/i18n.md +2 -2
  43. package/dist/docs/i18n.zh.md +2 -2
  44. package/dist/docs/mcp-support.md +5 -4
  45. package/dist/docs/mcp-support.zh.md +3 -2
  46. package/dist/docs/memory-system.md +4 -4
  47. package/dist/docs/memory-system.zh.md +1 -1
  48. package/dist/docs/mottos.md +1 -1
  49. package/dist/docs/mottos.zh.md +1 -1
  50. package/dist/docs/q4h.md +3 -3
  51. package/dist/docs/q4h.zh.md +1 -1
  52. package/dist/docs/roadmap.md +2 -2
  53. package/dist/docs/team_mgmt-toolset.md +11 -3
  54. package/dist/docs/team_mgmt-toolset.zh.md +9 -2
  55. package/dist/docs/tellask-collab.md +18 -18
  56. package/dist/docs/tellask-collab.zh.md +8 -8
  57. package/dist/docs/tellask-revive-context-refactor.zh.md +591 -0
  58. package/dist/evt-registry.d.ts +1 -2
  59. package/dist/evt-registry.js +2 -7
  60. package/dist/llm/gen/mock.js +9 -0
  61. package/dist/llm/kernel-driver/context.d.ts +1 -2
  62. package/dist/llm/kernel-driver/context.js +12 -26
  63. package/dist/llm/kernel-driver/drive.js +99 -75
  64. package/dist/llm/kernel-driver/engine.d.ts +2 -2
  65. package/dist/llm/kernel-driver/engine.js +10 -10
  66. package/dist/llm/kernel-driver/fbr.js +6 -6
  67. package/dist/llm/kernel-driver/flow.d.ts +1 -1
  68. package/dist/llm/kernel-driver/flow.js +129 -93
  69. package/dist/llm/kernel-driver/guardrails.js +4 -4
  70. package/dist/llm/kernel-driver/index.d.ts +1 -1
  71. package/dist/llm/kernel-driver/index.js +2 -2
  72. package/dist/llm/kernel-driver/loop.js +30 -30
  73. package/dist/llm/kernel-driver/reply-guidance.js +47 -52
  74. package/dist/llm/kernel-driver/restore.d.ts +3 -3
  75. package/dist/llm/kernel-driver/restore.js +23 -28
  76. package/dist/llm/kernel-driver/runtime.d.ts +1 -1
  77. package/dist/llm/kernel-driver/runtime.js +1 -1
  78. package/dist/llm/kernel-driver/sideDialog-txn.d.ts +8 -0
  79. package/dist/llm/kernel-driver/{subdialog-txn.js → sideDialog-txn.js} +13 -13
  80. package/dist/llm/kernel-driver/{subdialog.d.ts → sideDialog.d.ts} +13 -13
  81. package/dist/llm/kernel-driver/{subdialog.js → sideDialog.js} +203 -170
  82. package/dist/llm/kernel-driver/tellask-special.d.ts +7 -3
  83. package/dist/llm/kernel-driver/tellask-special.js +474 -497
  84. package/dist/llm/kernel-driver/types.d.ts +25 -9
  85. package/dist/mcp/config.d.ts +1 -0
  86. package/dist/mcp/config.js +7 -2
  87. package/dist/mcp/supervisor.d.ts +2 -0
  88. package/dist/mcp/supervisor.js +2 -1
  89. package/dist/minds/builtin/pangu/persona.en.md +4 -4
  90. package/dist/minds/load.js +6 -6
  91. package/dist/minds/system-prompt-parts.d.ts +1 -1
  92. package/dist/minds/system-prompt-parts.js +12 -12
  93. package/dist/minds/system-prompt.d.ts +1 -1
  94. package/dist/minds/system-prompt.js +56 -56
  95. package/dist/persistence-errors.d.ts +1 -1
  96. package/dist/persistence.d.ts +126 -121
  97. package/dist/persistence.js +1190 -786
  98. package/dist/priming.d.ts +3 -3
  99. package/dist/priming.js +62 -61
  100. package/dist/recovery/reply-special.js +5 -5
  101. package/dist/runtime/driver-messages.d.ts +3 -2
  102. package/dist/runtime/driver-messages.js +68 -57
  103. package/dist/runtime/inter-dialog-format.d.ts +12 -10
  104. package/dist/runtime/inter-dialog-format.js +80 -35
  105. package/dist/runtime/interjection-pause-stop.js +1 -1
  106. package/dist/runtime/reply-prompt-copy.d.ts +7 -3
  107. package/dist/runtime/reply-prompt-copy.js +39 -14
  108. package/dist/server/api-routes.js +87 -83
  109. package/dist/server/static-server.js +1 -1
  110. package/dist/server/websocket-handler.js +163 -153
  111. package/dist/tool-availability.js +1 -1
  112. package/dist/tools/app-reminders.js +17 -4
  113. package/dist/tools/ctrl.js +5 -5
  114. package/dist/tools/os.js +16 -16
  115. package/dist/tools/pending-tellask-reminder.js +20 -14
  116. package/dist/tools/prompts/control/en/index.md +1 -1
  117. package/dist/tools/prompts/control/en/principles.md +8 -8
  118. package/dist/tools/prompts/control/en/scenarios.md +7 -7
  119. package/dist/tools/prompts/control/en/tools.md +7 -7
  120. package/dist/tools/prompts/control/zh/principles.md +4 -4
  121. package/dist/tools/prompts/control/zh/scenarios.md +5 -5
  122. package/dist/tools/prompts/control/zh/tools.md +3 -3
  123. package/dist/tools/prompts/team_memory/en/scenarios.md +1 -1
  124. package/dist/tools/prompts/team_memory/zh/scenarios.md +1 -1
  125. package/dist/tools/team_mgmt-manual.js +2 -2
  126. package/dist/tools/team_mgmt-mcp-manual.js +10 -0
  127. package/dist/tools/team_mgmt.js +4 -4
  128. package/dist/utils/taskdoc.js +12 -12
  129. package/package.json +3 -3
  130. package/webapp/dist/assets/{_basePickBy-BPJaiZdW.js → _basePickBy-B7M9Q0Fa.js} +3 -3
  131. package/webapp/dist/assets/_basePickBy-B7M9Q0Fa.js.map +1 -0
  132. package/webapp/dist/assets/{_baseUniq-BEetT15i.js → _baseUniq-DAeYoL6j.js} +2 -2
  133. package/webapp/dist/assets/_baseUniq-DAeYoL6j.js.map +1 -0
  134. package/webapp/dist/assets/{arc-Dm7Zf36f.js → arc-Bh4nDbNR.js} +2 -2
  135. package/webapp/dist/assets/arc-Bh4nDbNR.js.map +1 -0
  136. package/webapp/dist/assets/{architectureDiagram-VXUJARFQ-BpTPtkuo.js → architectureDiagram-2XIMDMQ5-CxqmdsIm.js} +26 -8
  137. package/webapp/dist/assets/architectureDiagram-2XIMDMQ5-CxqmdsIm.js.map +1 -0
  138. package/webapp/dist/assets/{blockDiagram-VD42YOAC-C8fLN0iu.js → blockDiagram-WCTKOSBZ-CxIWLtpt.js} +187 -170
  139. package/webapp/dist/assets/blockDiagram-WCTKOSBZ-CxIWLtpt.js.map +1 -0
  140. package/webapp/dist/assets/{c4Diagram-YG6GDRKO-BpPr62CH.js → c4Diagram-IC4MRINW-1qErOIgG.js} +4 -4
  141. package/webapp/dist/assets/c4Diagram-IC4MRINW-1qErOIgG.js.map +1 -0
  142. package/webapp/dist/assets/{channel-EMYoPjW3.js → channel-DkgZHNUe.js} +2 -2
  143. package/webapp/dist/assets/channel-DkgZHNUe.js.map +1 -0
  144. package/webapp/dist/assets/{chunk-4BX2VUAB-CefNtjWG.js → chunk-4BX2VUAB-BmdMbU9v.js} +2 -2
  145. package/webapp/dist/assets/chunk-4BX2VUAB-BmdMbU9v.js.map +1 -0
  146. package/webapp/dist/assets/{chunk-55IACEB6-C_X7T43V.js → chunk-55IACEB6-D6LDTDBy.js} +2 -2
  147. package/webapp/dist/assets/chunk-55IACEB6-D6LDTDBy.js.map +1 -0
  148. package/webapp/dist/assets/{chunk-FMBD7UC4-ORmtkrtS.js → chunk-FMBD7UC4-C-BdCe4C.js} +2 -2
  149. package/webapp/dist/assets/chunk-FMBD7UC4-C-BdCe4C.js.map +1 -0
  150. package/webapp/dist/assets/{chunk-TZMSLE5B-Gao4qrq7.js → chunk-JSJVCQXG-WA_BLIm9.js} +14 -6
  151. package/webapp/dist/assets/chunk-JSJVCQXG-WA_BLIm9.js.map +1 -0
  152. package/webapp/dist/assets/{chunk-QN33PNHL-LTAOVhWu.js → chunk-KX2RTZJC-CA7sDJO5.js} +2 -2
  153. package/webapp/dist/assets/chunk-KX2RTZJC-CA7sDJO5.js.map +1 -0
  154. package/webapp/dist/assets/{chunk-DI55MBZ5-CbvrsI_w.js → chunk-NQ4KR5QH-wlvxalE3.js} +9 -7
  155. package/webapp/dist/assets/chunk-NQ4KR5QH-wlvxalE3.js.map +1 -0
  156. package/webapp/dist/assets/{chunk-QZHKN3VN-ZoUM_4u5.js → chunk-QZHKN3VN-Bo1VMcph.js} +2 -2
  157. package/webapp/dist/assets/chunk-QZHKN3VN-Bo1VMcph.js.map +1 -0
  158. package/webapp/dist/assets/{chunk-B4BG7PRW-BRe3_2oA.js → chunk-WL4C6EOR-B-Pk44be.js} +171 -121
  159. package/webapp/dist/assets/chunk-WL4C6EOR-B-Pk44be.js.map +1 -0
  160. package/webapp/dist/assets/{classDiagram-2ON5EDUG-uha1vIGN.js → classDiagram-VBA2DB6C-BqKuyb49.js} +7 -6
  161. package/webapp/dist/assets/classDiagram-VBA2DB6C-BqKuyb49.js.map +1 -0
  162. package/webapp/dist/assets/{classDiagram-v2-WZHVMYZB-uha1vIGN.js → classDiagram-v2-RAHNMMFH-BqKuyb49.js} +7 -6
  163. package/webapp/dist/assets/classDiagram-v2-RAHNMMFH-BqKuyb49.js.map +1 -0
  164. package/webapp/dist/assets/{clone-_9Ayb1Gp.js → clone-BX5z8WVZ.js} +2 -2
  165. package/webapp/dist/assets/clone-BX5z8WVZ.js.map +1 -0
  166. package/webapp/dist/assets/{cose-bilkent-S5V4N54A-C8wDw3NY.js → cose-bilkent-S5V4N54A-B-s11SgN.js} +2 -2
  167. package/webapp/dist/assets/cose-bilkent-S5V4N54A-B-s11SgN.js.map +1 -0
  168. package/webapp/dist/assets/cytoscape.esm-Bm8DJGmZ.js.map +1 -1
  169. package/webapp/dist/assets/{dagre-6UL2VRFP-BUSeNot0.js → dagre-KLK3FWXG-DmQFV2qK.js} +7 -7
  170. package/webapp/dist/assets/dagre-KLK3FWXG-DmQFV2qK.js.map +1 -0
  171. package/webapp/dist/assets/defaultLocale-B2RvLBDe.js.map +1 -1
  172. package/webapp/dist/assets/{diagram-PSM6KHXK-CMZAksVC.js → diagram-E7M64L7V-QRaBfST8.js} +10 -10
  173. package/webapp/dist/assets/diagram-E7M64L7V-QRaBfST8.js.map +1 -0
  174. package/webapp/dist/assets/{diagram-QEK2KX5R-BQKoRtwy.js → diagram-IFDJBPK2-lrWn1Obo.js} +9 -8
  175. package/webapp/dist/assets/diagram-IFDJBPK2-lrWn1Obo.js.map +1 -0
  176. package/webapp/dist/assets/{diagram-S2PKOQOG-DjMG97kd.js → diagram-P4PSJMXO-sTU7Hh-Y.js} +8 -8
  177. package/webapp/dist/assets/diagram-P4PSJMXO-sTU7Hh-Y.js.map +1 -0
  178. package/webapp/dist/assets/{erDiagram-Q2GNP2WA-BujwA137.js → erDiagram-INFDFZHY-Cx6jc9Wq.js} +96 -75
  179. package/webapp/dist/assets/erDiagram-INFDFZHY-Cx6jc9Wq.js.map +1 -0
  180. package/webapp/dist/assets/{flowDiagram-NV44I4VS-DgwPjg4y.js → flowDiagram-PKNHOUZH-DfGI49Dz.js} +98 -81
  181. package/webapp/dist/assets/flowDiagram-PKNHOUZH-DfGI49Dz.js.map +1 -0
  182. package/webapp/dist/assets/{ganttDiagram-JELNMOA3-Db2ykf3E.js → ganttDiagram-A5KZAMGK-nrcHWWaM.js} +28 -3
  183. package/webapp/dist/assets/ganttDiagram-A5KZAMGK-nrcHWWaM.js.map +1 -0
  184. package/webapp/dist/assets/{gitGraphDiagram-V2S2FVAM-D_gSifkv.js → gitGraphDiagram-K3NZZRJ6-D8ivAqd6.js} +38 -46
  185. package/webapp/dist/assets/gitGraphDiagram-K3NZZRJ6-D8ivAqd6.js.map +1 -0
  186. package/webapp/dist/assets/graph-R5G-y8tB.js +782 -0
  187. package/webapp/dist/assets/graph-R5G-y8tB.js.map +1 -0
  188. package/webapp/dist/assets/{index-DLajsIDJ.js → index--fy89xGh.js} +2214 -2023
  189. package/webapp/dist/assets/index--fy89xGh.js.map +1 -0
  190. package/webapp/dist/assets/{index-xvYYeHuy.css → index-DZFkLLVz.css} +18 -10
  191. package/webapp/dist/assets/{infoDiagram-HS3SLOUP-BDba5pKs.js → infoDiagram-LFFYTUFH-PIoZHr7s.js} +7 -7
  192. package/webapp/dist/assets/infoDiagram-LFFYTUFH-PIoZHr7s.js.map +1 -0
  193. package/webapp/dist/assets/init-ZxktEp_H.js.map +1 -1
  194. package/webapp/dist/assets/ishikawaDiagram-PHBUUO56-oCM-LYk1.js +966 -0
  195. package/webapp/dist/assets/ishikawaDiagram-PHBUUO56-oCM-LYk1.js.map +1 -0
  196. package/webapp/dist/assets/{journeyDiagram-XKPGCS4Q-CmJAbmlm.js → journeyDiagram-4ABVD52K-C2qidjQ5.js} +5 -5
  197. package/webapp/dist/assets/journeyDiagram-4ABVD52K-C2qidjQ5.js.map +1 -0
  198. package/webapp/dist/assets/{kanban-definition-3W4ZIXB7-DxQeBTDk.js → kanban-definition-K7BYSVSG-Du0TC8WS.js} +5 -3
  199. package/webapp/dist/assets/kanban-definition-K7BYSVSG-Du0TC8WS.js.map +1 -0
  200. package/webapp/dist/assets/{layout-DteV_yE8.js → layout-VmEo1OEB.js} +5 -5
  201. package/webapp/dist/assets/layout-VmEo1OEB.js.map +1 -0
  202. package/webapp/dist/assets/{linear-zItbPrND.js → linear-B662YHAc.js} +2 -2
  203. package/webapp/dist/assets/linear-B662YHAc.js.map +1 -0
  204. package/webapp/dist/assets/{mindmap-definition-VGOIOE7T-BJXI7UqO.js → mindmap-definition-YRQLILUH-D7arZj95.js} +7 -5
  205. package/webapp/dist/assets/mindmap-definition-YRQLILUH-D7arZj95.js.map +1 -0
  206. package/webapp/dist/assets/ordinal-CxptdPJm.js.map +1 -1
  207. package/webapp/dist/assets/{pieDiagram-ADFJNKIX-BpM-aH2p.js → pieDiagram-SKSYHLDU-DvjPP4PA.js} +8 -8
  208. package/webapp/dist/assets/pieDiagram-SKSYHLDU-DvjPP4PA.js.map +1 -0
  209. package/webapp/dist/assets/{quadrantDiagram-AYHSOK5B-NXdIpA15.js → quadrantDiagram-337W2JSQ-B_JUGMj_.js} +3 -3
  210. package/webapp/dist/assets/quadrantDiagram-337W2JSQ-B_JUGMj_.js.map +1 -0
  211. package/webapp/dist/assets/{requirementDiagram-UZGBJVZJ-D1AICAA0.js → requirementDiagram-Z7DCOOCP-DF0mpvE3.js} +16 -6
  212. package/webapp/dist/assets/requirementDiagram-Z7DCOOCP-DF0mpvE3.js.map +1 -0
  213. package/webapp/dist/assets/{sankeyDiagram-TZEHDZUN-WiReDPfo.js → sankeyDiagram-WA2Y5GQK-CoXlxv00.js} +2 -2
  214. package/webapp/dist/assets/sankeyDiagram-WA2Y5GQK-CoXlxv00.js.map +1 -0
  215. package/webapp/dist/assets/{sequenceDiagram-WL72ISMW-Cw76oP8t.js → sequenceDiagram-2WXFIKYE-DYqT5Pg7.js} +601 -201
  216. package/webapp/dist/assets/sequenceDiagram-2WXFIKYE-DYqT5Pg7.js.map +1 -0
  217. package/webapp/dist/assets/{stateDiagram-FKZM4ZOC-QjCeRczs.js → stateDiagram-RAJIS63D-D9b1mN8-.js} +9 -9
  218. package/webapp/dist/assets/stateDiagram-RAJIS63D-D9b1mN8-.js.map +1 -0
  219. package/webapp/dist/assets/{stateDiagram-v2-4FDKWEC3-IClqxQ4s.js → stateDiagram-v2-FVOUBMTO-DNzgudL_.js} +5 -5
  220. package/webapp/dist/assets/stateDiagram-v2-FVOUBMTO-DNzgudL_.js.map +1 -0
  221. package/webapp/dist/assets/{timeline-definition-IT6M3QCI-BfyfTY7m.js → timeline-definition-YZTLITO2-CkyKUY7A.js} +3 -3
  222. package/webapp/dist/assets/timeline-definition-YZTLITO2-CkyKUY7A.js.map +1 -0
  223. package/webapp/dist/assets/{treemap-GDKQZRPO-C5MiL6--.js → treemap-KZPCXAKY-CZd09kF-.js} +37 -24
  224. package/webapp/dist/assets/treemap-KZPCXAKY-CZd09kF-.js.map +1 -0
  225. package/webapp/dist/assets/vennDiagram-LZ73GAT5-BxVF5Olo.js +2487 -0
  226. package/webapp/dist/assets/vennDiagram-LZ73GAT5-BxVF5Olo.js.map +1 -0
  227. package/webapp/dist/assets/{xychartDiagram-PRI3JC2R-ybaJrSry.js → xychartDiagram-JWTSCODW-BRwRloPc.js} +4 -4
  228. package/webapp/dist/assets/xychartDiagram-JWTSCODW-BRwRloPc.js.map +1 -0
  229. package/webapp/dist/index.html +2 -2
  230. package/dist/docs/issues/global-dialog-event-broadcaster-missing.md +0 -128
  231. package/dist/llm/kernel-driver/subdialog-txn.d.ts +0 -8
  232. package/webapp/dist/assets/_basePickBy-BPJaiZdW.js.map +0 -1
  233. package/webapp/dist/assets/_baseUniq-BEetT15i.js.map +0 -1
  234. package/webapp/dist/assets/arc-Dm7Zf36f.js.map +0 -1
  235. package/webapp/dist/assets/architectureDiagram-VXUJARFQ-BpTPtkuo.js.map +0 -1
  236. package/webapp/dist/assets/blockDiagram-VD42YOAC-C8fLN0iu.js.map +0 -1
  237. package/webapp/dist/assets/c4Diagram-YG6GDRKO-BpPr62CH.js.map +0 -1
  238. package/webapp/dist/assets/channel-EMYoPjW3.js.map +0 -1
  239. package/webapp/dist/assets/chunk-4BX2VUAB-CefNtjWG.js.map +0 -1
  240. package/webapp/dist/assets/chunk-55IACEB6-C_X7T43V.js.map +0 -1
  241. package/webapp/dist/assets/chunk-B4BG7PRW-BRe3_2oA.js.map +0 -1
  242. package/webapp/dist/assets/chunk-DI55MBZ5-CbvrsI_w.js.map +0 -1
  243. package/webapp/dist/assets/chunk-FMBD7UC4-ORmtkrtS.js.map +0 -1
  244. package/webapp/dist/assets/chunk-QN33PNHL-LTAOVhWu.js.map +0 -1
  245. package/webapp/dist/assets/chunk-QZHKN3VN-ZoUM_4u5.js.map +0 -1
  246. package/webapp/dist/assets/chunk-TZMSLE5B-Gao4qrq7.js.map +0 -1
  247. package/webapp/dist/assets/classDiagram-2ON5EDUG-uha1vIGN.js.map +0 -1
  248. package/webapp/dist/assets/classDiagram-v2-WZHVMYZB-uha1vIGN.js.map +0 -1
  249. package/webapp/dist/assets/clone-_9Ayb1Gp.js.map +0 -1
  250. package/webapp/dist/assets/cose-bilkent-S5V4N54A-C8wDw3NY.js.map +0 -1
  251. package/webapp/dist/assets/dagre-6UL2VRFP-BUSeNot0.js.map +0 -1
  252. package/webapp/dist/assets/diagram-PSM6KHXK-CMZAksVC.js.map +0 -1
  253. package/webapp/dist/assets/diagram-QEK2KX5R-BQKoRtwy.js.map +0 -1
  254. package/webapp/dist/assets/diagram-S2PKOQOG-DjMG97kd.js.map +0 -1
  255. package/webapp/dist/assets/erDiagram-Q2GNP2WA-BujwA137.js.map +0 -1
  256. package/webapp/dist/assets/flowDiagram-NV44I4VS-DgwPjg4y.js.map +0 -1
  257. package/webapp/dist/assets/ganttDiagram-JELNMOA3-Db2ykf3E.js.map +0 -1
  258. package/webapp/dist/assets/gitGraphDiagram-V2S2FVAM-D_gSifkv.js.map +0 -1
  259. package/webapp/dist/assets/graph-BHjCU5xP.js +0 -425
  260. package/webapp/dist/assets/graph-BHjCU5xP.js.map +0 -1
  261. package/webapp/dist/assets/index-DLajsIDJ.js.map +0 -1
  262. package/webapp/dist/assets/infoDiagram-HS3SLOUP-BDba5pKs.js.map +0 -1
  263. package/webapp/dist/assets/journeyDiagram-XKPGCS4Q-CmJAbmlm.js.map +0 -1
  264. package/webapp/dist/assets/kanban-definition-3W4ZIXB7-DxQeBTDk.js.map +0 -1
  265. package/webapp/dist/assets/layout-DteV_yE8.js.map +0 -1
  266. package/webapp/dist/assets/linear-zItbPrND.js.map +0 -1
  267. package/webapp/dist/assets/mindmap-definition-VGOIOE7T-BJXI7UqO.js.map +0 -1
  268. package/webapp/dist/assets/pieDiagram-ADFJNKIX-BpM-aH2p.js.map +0 -1
  269. package/webapp/dist/assets/quadrantDiagram-AYHSOK5B-NXdIpA15.js.map +0 -1
  270. package/webapp/dist/assets/requirementDiagram-UZGBJVZJ-D1AICAA0.js.map +0 -1
  271. package/webapp/dist/assets/sankeyDiagram-TZEHDZUN-WiReDPfo.js.map +0 -1
  272. package/webapp/dist/assets/sequenceDiagram-WL72ISMW-Cw76oP8t.js.map +0 -1
  273. package/webapp/dist/assets/stateDiagram-FKZM4ZOC-QjCeRczs.js.map +0 -1
  274. package/webapp/dist/assets/stateDiagram-v2-4FDKWEC3-IClqxQ4s.js.map +0 -1
  275. package/webapp/dist/assets/timeline-definition-IT6M3QCI-BfyfTY7m.js.map +0 -1
  276. package/webapp/dist/assets/treemap-GDKQZRPO-C5MiL6--.js.map +0 -1
  277. package/webapp/dist/assets/xychartDiagram-PRI3JC2R-ybaJrSry.js.map +0 -1
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isTellaskCallFunctionName = isTellaskCallFunctionName;
4
- exports.loadLatestActiveTellaskReplyDirective = loadLatestActiveTellaskReplyDirective;
4
+ exports.loadActiveTellaskReplyDirective = loadActiveTellaskReplyDirective;
5
5
  exports.deliverTellaskBackReplyFromDirective = deliverTellaskBackReplyFromDirective;
6
6
  exports.recoverPendingReplyTellaskCalls = recoverPendingReplyTellaskCalls;
7
7
  exports.resolveTellaskFunctionCalls = resolveTellaskFunctionCalls;
8
8
  exports.formatTellaskInvalidCallResult = formatTellaskInvalidCallResult;
9
9
  exports.formatPendingTellaskFuncResultContent = formatPendingTellaskFuncResultContent;
10
+ exports.formatResolvedTellaskFuncResultContent = formatResolvedTellaskFuncResultContent;
10
11
  exports.formatResolvedAskHumanResultContent = formatResolvedAskHumanResultContent;
11
12
  exports.executeTellaskCalls = executeTellaskCalls;
12
13
  exports.processTellaskFunctionRound = processTellaskFunctionRound;
@@ -25,8 +26,8 @@ const work_language_1 = require("../../runtime/work-language");
25
26
  const team_1 = require("../../team");
26
27
  const pending_tellask_reminder_1 = require("../../tools/pending-tellask-reminder");
27
28
  const fbr_1 = require("./fbr");
28
- const subdialog_1 = require("./subdialog");
29
- const subdialog_txn_1 = require("./subdialog-txn");
29
+ const sideDialog_1 = require("./sideDialog");
30
+ const sideDialog_txn_1 = require("./sideDialog-txn");
30
31
  const TELLASK_SPECIAL_FUNCTION_NAMES = [
31
32
  'tellaskBack',
32
33
  'tellask',
@@ -47,37 +48,10 @@ function isReplyTellaskCallName(name) {
47
48
  function isRecord(value) {
48
49
  return typeof value === 'object' && value !== null && !Array.isArray(value);
49
50
  }
50
- async function loadLatestActiveTellaskReplyDirective(dialog) {
51
- const latest = await persistence_1.DialogPersistence.loadDialogLatest(dialog.id, dialog.status);
52
- if (!latest) {
53
- return undefined;
54
- }
55
- const maxCourse = Math.floor(latest.currentCourse);
56
- const resolvedTargetCallIds = new Set();
57
- for (let course = maxCourse; course >= 1; course -= 1) {
58
- const events = await persistence_1.DialogPersistence.loadCourseEvents(dialog.id, course, dialog.status);
59
- for (let index = events.length - 1; index >= 0; index -= 1) {
60
- const event = events[index];
61
- if (event.type === 'tellask_reply_resolution_record') {
62
- const targetCallId = event.targetCallId.trim();
63
- if (targetCallId !== '') {
64
- resolvedTargetCallIds.add(targetCallId);
65
- }
66
- continue;
67
- }
68
- if (event.type !== 'human_text_record') {
69
- continue;
70
- }
71
- const directive = event.tellaskReplyDirective;
72
- if (!directive) {
73
- continue;
74
- }
75
- const targetCallId = directive.targetCallId.trim();
76
- if (targetCallId === '' || resolvedTargetCallIds.has(targetCallId)) {
77
- continue;
78
- }
79
- return directive;
80
- }
51
+ async function loadActiveTellaskReplyDirective(dialog) {
52
+ const durableObligation = await persistence_1.DialogPersistence.loadActiveTellaskReplyObligation(dialog.id, dialog.status);
53
+ if (durableObligation) {
54
+ return durableObligation;
81
55
  }
82
56
  return undefined;
83
57
  }
@@ -123,6 +97,7 @@ function formatReplyFuncErrorResult(args) {
123
97
  function buildAssignmentReplyDirective(args) {
124
98
  return {
125
99
  expectedReplyCallName: args.callName === 'tellask' ? 'replyTellask' : 'replyTellaskSessionless',
100
+ targetDialogId: args.targetDialogId,
126
101
  targetCallId: args.targetCallId,
127
102
  tellaskContent: args.tellaskContent,
128
103
  };
@@ -136,64 +111,65 @@ function buildTellaskBackReplyDirective(args) {
136
111
  };
137
112
  }
138
113
  async function deliverTellaskBackReplyFromDirective(args) {
139
- // Type-A ask-back is the one place where the local "caller/callee" intuition flips:
140
- // the dialog running `replyTellaskBack` is the ask-back responder, while
141
- // directive.targetDialogId points to the ask-back requester that must receive the canonical
114
+ // Type-A ask-back is the one place where the local tellasker/tellaskee intuition flips:
115
+ // the dialog running `replyTellaskBack` is the ask-back tellaskee, while
116
+ // directive.targetDialogId points to the ask-back asker that must receive the canonical
142
117
  // tellaskBack result. Keep those roles explicit, otherwise it is very easy to accidentally
143
- // write the same business result twice by confusing the responder's local plaintext with the
144
- // canonical upstream delivery that must come only from an explicit reply tool call.
145
- const rootDialog = args.replyingDialog instanceof dialog_1.RootDialog
118
+ // write the same business result twice by confusing the tellaskee's local plaintext with the
119
+ // canonical ask-back asker delivery that must come only from an explicit reply tool call.
120
+ const mainDialog = args.replyingDialog instanceof dialog_1.MainDialog
146
121
  ? args.replyingDialog
147
- : args.replyingDialog instanceof dialog_1.SubDialog
148
- ? args.replyingDialog.rootDialog
122
+ : args.replyingDialog instanceof dialog_1.SideDialog
123
+ ? args.replyingDialog.mainDialog
149
124
  : undefined;
150
- if (!rootDialog) {
151
- throw new Error('replyTellaskBack invariant violation: missing root dialog');
125
+ if (!mainDialog) {
126
+ throw new Error('replyTellaskBack invariant violation: missing main dialog');
152
127
  }
153
- const askBackRequesterDialogId = new dialog_1.DialogID(args.directive.targetDialogId, rootDialog.id.rootId);
154
- const askBackRequesterDialog = rootDialog.lookupDialog(askBackRequesterDialogId.selfId) ??
155
- (await (0, dialog_instance_registry_1.ensureDialogLoaded)(rootDialog, askBackRequesterDialogId, rootDialog.status));
156
- if (!askBackRequesterDialog) {
157
- throw new Error(`replyTellaskBack invariant violation: target dialog ${askBackRequesterDialogId.selfId} not found`);
128
+ const askBackAskerDialogId = new dialog_1.DialogID(args.directive.targetDialogId, mainDialog.id.rootId);
129
+ const askBackAskerDialog = mainDialog.lookupDialog(askBackAskerDialogId.selfId) ??
130
+ (await (0, dialog_instance_registry_1.ensureDialogLoaded)(mainDialog, askBackAskerDialogId, mainDialog.status));
131
+ if (!askBackAskerDialog) {
132
+ throw new Error(`replyTellaskBack invariant violation: target dialog ${askBackAskerDialogId.selfId} not found`);
158
133
  }
159
134
  const response = (0, inter_dialog_format_1.formatTellaskResponseContent)({
160
135
  callName: 'tellaskBack',
136
+ callId: args.directive.targetCallId,
161
137
  responderId: args.replyingDialog.agentId,
162
- requesterId: askBackRequesterDialog.agentId,
138
+ tellaskerId: askBackAskerDialog.agentId,
163
139
  tellaskContent: args.directive.tellaskContent,
164
140
  responseBody: args.replyContent,
165
141
  status: 'completed',
166
142
  deliveryMode: args.deliveryMode,
167
143
  language: (0, work_language_1.getWorkLanguage)(),
168
144
  });
169
- const targetCallOriginCourse = (0, storage_1.toCallingCourseNumber)(askBackRequesterDialog.currentCourse);
170
- const targetCallOriginGenseq = (() => {
171
- for (let i = askBackRequesterDialog.msgs.length - 1; i >= 0; i -= 1) {
172
- const msg = askBackRequesterDialog.msgs[i];
145
+ const targetCallSiteCourse = (0, storage_1.toCallSiteCourseNo)(askBackAskerDialog.currentCourse);
146
+ const targetCallSiteGenseq = (() => {
147
+ for (let i = askBackAskerDialog.msgs.length - 1; i >= 0; i -= 1) {
148
+ const msg = askBackAskerDialog.msgs[i];
173
149
  if (!msg || msg.type !== 'func_call_msg') {
174
150
  continue;
175
151
  }
176
152
  if (msg.id !== args.directive.targetCallId) {
177
153
  continue;
178
154
  }
179
- return (0, storage_1.toCallingGenerationSeqNumber)(msg.genseq);
155
+ return (0, storage_1.toCallSiteGenseqNo)(msg.genseq);
180
156
  }
181
157
  return undefined;
182
158
  })();
183
- const replyMirror = await askBackRequesterDialog.receiveTellaskResponse(args.replyingDialog.agentId, 'tellaskBack', undefined, args.directive.tellaskContent, 'completed', args.replyingDialog.id, {
159
+ const replyMirror = await askBackAskerDialog.receiveTellaskResponse(args.replyingDialog.agentId, 'tellaskBack', undefined, args.directive.tellaskContent, 'completed', args.replyingDialog.id, {
184
160
  response,
185
161
  agentId: args.replyingDialog.agentId,
186
162
  callId: args.directive.targetCallId,
187
- originMemberId: askBackRequesterDialog.agentId,
188
- originCourse: targetCallOriginCourse,
189
- calling_genseq: targetCallOriginGenseq,
163
+ originMemberId: askBackAskerDialog.agentId,
164
+ callSiteCourse: targetCallSiteCourse,
165
+ callSiteGenseq: targetCallSiteGenseq,
190
166
  });
191
- await askBackRequesterDialog.addChatMessages(replyMirror);
192
- // Do not mark the requester resumed until the canonical tellaskBack result has actually been
167
+ await askBackAskerDialog.addChatMessages(replyMirror);
168
+ // Do not mark the ask-back asker resumed until the canonical tellaskBack result has actually been
193
169
  // persisted and mirrored locally. Otherwise a write failure here would leave suspension state
194
170
  // claiming "resumed" while the business fact never landed.
195
- askBackRequesterDialog.setSuspensionState('resumed');
196
- await reviveDialogIfUnblocked(askBackRequesterDialog, args.callbacks, 'reply_tellask_back_delivered');
171
+ askBackAskerDialog.setSuspensionState('resumed');
172
+ await reviveDialogIfUnblocked(askBackAskerDialog, args.callbacks, 'reply_tellask_back_delivered');
197
173
  }
198
174
  function isReplyTellaskCallRecord(record) {
199
175
  return isReplyTellaskCallName(record.name);
@@ -565,7 +541,6 @@ function resolveTellaskFunctionCalls(funcCalls, options) {
565
541
  originalCall: call,
566
542
  error: parsed.error,
567
543
  rawArgumentsText,
568
- contextArguments: rawArgumentsText,
569
544
  });
570
545
  continue;
571
546
  }
@@ -588,7 +563,7 @@ function formatTellaskInvalidCallResult(args) {
588
563
  genseq: args.call.genseq,
589
564
  };
590
565
  }
591
- function formatPendingTellaskFuncResultContent(name, startedAtMs) {
566
+ function formatPendingTellaskFuncResultContent(name, startedAtMs, callId) {
592
567
  const language = (0, work_language_1.getWorkLanguage)();
593
568
  const elapsed = (() => {
594
569
  if (startedAtMs === null) {
@@ -600,12 +575,99 @@ function formatPendingTellaskFuncResultContent(name, startedAtMs) {
600
575
  })();
601
576
  if (name === 'askHuman') {
602
577
  return language === 'zh'
603
- ? `Q4H 仍在等待人类回复,已持续 ${elapsed}。`
604
- : `Q4H is still waiting for human reply (elapsed ${elapsed}).`;
578
+ ? [
579
+ '[Dominds 诉请状态]',
580
+ '',
581
+ '`askHuman` 诉请已发出,当前仍在等待人类回复。',
582
+ '',
583
+ ...(callId ? [`- callId: ${callId}`] : []),
584
+ `- 已等待: ${elapsed}`,
585
+ '',
586
+ '这不是回贴内容。若后续收到回复,运行时会在后续上下文中用同一 callId 补入对应回复事实。',
587
+ ].join('\n')
588
+ : [
589
+ '[Dominds tellask status]',
590
+ '',
591
+ '`askHuman` has been issued and is still waiting for human reply.',
592
+ '',
593
+ ...(callId ? [`- callId: ${callId}`] : []),
594
+ `- Elapsed: ${elapsed}`,
595
+ '',
596
+ 'This is not reply content. If a reply arrives later, runtime will append the corresponding reply fact in later context with the same callId.',
597
+ ].join('\n');
605
598
  }
606
599
  return language === 'zh'
607
- ? `支线对话仍在进行中,已持续 ${elapsed}。`
608
- : `Sideline dialog is still running (elapsed ${elapsed}).`;
600
+ ? [
601
+ '[Dominds 诉请状态]',
602
+ '',
603
+ `\`${name}\` 诉请已发出,当前仍在等待回贴。`,
604
+ '',
605
+ ...(callId ? [`- callId: ${callId}`] : []),
606
+ `- 已等待: ${elapsed}`,
607
+ '',
608
+ '这不是回贴内容。若后续收到回贴,运行时会在后续上下文中用同一 callId 补入对应回贴事实。',
609
+ ].join('\n')
610
+ : [
611
+ '[Dominds tellask status]',
612
+ '',
613
+ `\`${name}\` has been issued and is still waiting for a reply.`,
614
+ '',
615
+ ...(callId ? [`- callId: ${callId}`] : []),
616
+ `- Elapsed: ${elapsed}`,
617
+ '',
618
+ 'This is not reply content. If a reply arrives later, runtime will append the corresponding reply fact in later context with the same callId.',
619
+ ].join('\n');
620
+ }
621
+ function formatResolvedTellaskFuncResultContent(args) {
622
+ const language = (0, work_language_1.getWorkLanguage)();
623
+ const callId = args.callId.trim();
624
+ if (callId === '') {
625
+ throw new Error(`tellask status formatter invariant violation: empty callId for ${args.name}`);
626
+ }
627
+ if (language === 'zh') {
628
+ if (args.status === 'pending') {
629
+ return [
630
+ '[Dominds 诉请状态]',
631
+ '',
632
+ `\`${args.name}\` 诉请仍在等待回贴,当前没有回贴正文。`,
633
+ '',
634
+ `- callId: ${callId}`,
635
+ '',
636
+ '不要把本工具结果当作回贴正文;若后续收到回贴,运行时会用同一 callId 补入对应回贴事实。',
637
+ ].join('\n');
638
+ }
639
+ const statusLabel = args.status === 'completed' ? '已收到回贴' : '已失败收口';
640
+ return [
641
+ '[Dominds 诉请状态]',
642
+ '',
643
+ `\`${args.name}\` 诉请${statusLabel},对应回贴事实已作为独立上下文事实补入。`,
644
+ '',
645
+ `- callId: ${callId}`,
646
+ '',
647
+ '请以同一 callId 的独立回贴事实为准;不要把本工具结果当作回贴正文。',
648
+ ].join('\n');
649
+ }
650
+ if (args.status === 'pending') {
651
+ return [
652
+ '[Dominds tellask status]',
653
+ '',
654
+ `\`${args.name}\` is still waiting for a reply; there is no reply body yet.`,
655
+ '',
656
+ `- callId: ${callId}`,
657
+ '',
658
+ 'Do not treat this tool result as reply content. If a reply arrives later, runtime will append the corresponding reply fact with the same callId.',
659
+ ].join('\n');
660
+ }
661
+ const statusLabel = args.status === 'completed' ? 'has received a reply' : 'has failed/closed';
662
+ return [
663
+ '[Dominds tellask status]',
664
+ '',
665
+ `\`${args.name}\` ${statusLabel}; the corresponding reply fact is present separately in context.`,
666
+ '',
667
+ `- callId: ${callId}`,
668
+ '',
669
+ 'Use the separate reply fact with the same callId as authoritative; do not treat this tool result as reply content.',
670
+ ].join('\n');
609
671
  }
610
672
  function formatResolvedAskHumanResultContent() {
611
673
  return (0, work_language_1.getWorkLanguage)() === 'zh'
@@ -619,7 +681,7 @@ function buildPendingTellaskFuncResult(args) {
619
681
  genseq: args.genseq,
620
682
  id: args.callId,
621
683
  name: args.callName,
622
- content: formatPendingTellaskFuncResultContent(args.callName, null),
684
+ content: formatPendingTellaskFuncResultContent(args.callName, null, args.callId),
623
685
  };
624
686
  }
625
687
  async function persistTellaskFuncResult(dlg, result) {
@@ -636,8 +698,8 @@ function buildTellaskResultToolOutput(args) {
636
698
  callName: args.callName,
637
699
  status: args.status,
638
700
  content: args.content,
639
- ...(typeof args.originCourse === 'number' ? { originCourse: args.originCourse } : {}),
640
- ...(typeof args.calling_genseq === 'number' ? { calling_genseq: args.calling_genseq } : {}),
701
+ ...(typeof args.callSiteCourse === 'number' ? { callSiteCourse: args.callSiteCourse } : {}),
702
+ ...(typeof args.callSiteGenseq === 'number' ? { callSiteGenseq: args.callSiteGenseq } : {}),
641
703
  call: args.callName === 'tellask'
642
704
  ? {
643
705
  tellaskContent: args.tellaskContent,
@@ -676,7 +738,7 @@ function buildTellaskCarryoverToolOutput(args) {
676
738
  role: 'user',
677
739
  genseq: args.genseq,
678
740
  content: args.content,
679
- originCourse: args.originCourse,
741
+ callSiteCourse: args.callSiteCourse,
680
742
  carryoverCourse: args.carryoverCourse,
681
743
  responderId: args.responderId,
682
744
  callName: args.callName,
@@ -750,134 +812,66 @@ function resolveFbrEffort(member) {
750
812
  return 0;
751
813
  return raw;
752
814
  }
753
- async function createSubDialog(callerDialog, targetAgentId, mentionList, tellaskContent, options) {
754
- return await callerDialog.createSubDialog(targetAgentId, mentionList, tellaskContent, options);
815
+ async function createSideDialog(askerDialog, targetAgentId, mentionList, tellaskContent, options) {
816
+ return await askerDialog.createSideDialog(targetAgentId, mentionList, tellaskContent, options);
755
817
  }
756
- async function updateSubdialogAssignment(subdialog, assignment) {
757
- subdialog.assignmentFromSup = assignment;
758
- await persistence_1.DialogPersistence.updateSubdialogAssignment(subdialog.id, assignment);
818
+ async function updateSideDialogAssignment(sideDialog, assignment, options) {
819
+ await persistence_1.DialogPersistence.updateSideDialogAssignment(sideDialog.id, assignment, sideDialog.status, options);
820
+ const nextAskerStackState = await persistence_1.DialogPersistence.loadSideDialogAskerStackState(sideDialog.id, sideDialog.status);
821
+ if (!nextAskerStackState) {
822
+ throw new Error(`Missing asker stack after assignment update: ${sideDialog.id.valueOf()}`);
823
+ }
824
+ sideDialog.askerStack = nextAskerStackState;
759
825
  }
760
- async function lookupLiveRegisteredSubdialog(rootDialog, agentId, sessionSlug) {
761
- const existing = rootDialog.lookupSubdialog(agentId, sessionSlug);
826
+ async function lookupLiveRegisteredSideDialog(mainDialog, agentId, sessionSlug) {
827
+ const existing = mainDialog.lookupSideDialog(agentId, sessionSlug);
762
828
  if (!existing) {
763
829
  return undefined;
764
830
  }
765
831
  const existingSession = existing.sessionSlug;
766
832
  if (!existingSession) {
767
- throw new Error(`Type B registry invariant violation: lookupSubdialog returned entry without sessionSlug (root=${rootDialog.id.valueOf()} sub=${existing.id.valueOf()})`);
833
+ throw new Error(`Type B registry invariant violation: lookupSideDialog returned entry without sessionSlug (root=${mainDialog.id.valueOf()} sub=${existing.id.valueOf()})`);
768
834
  }
769
- const latest = await persistence_1.DialogPersistence.loadDialogLatest(existing.id, rootDialog.status);
835
+ const latest = await persistence_1.DialogPersistence.loadDialogLatest(existing.id, mainDialog.status);
770
836
  const executionMarker = latest?.executionMarker;
771
837
  if (!executionMarker || executionMarker.kind !== 'dead') {
772
838
  return existing;
773
839
  }
774
- const removed = rootDialog.unregisterSubdialog(existing.agentId, existingSession);
840
+ const removed = mainDialog.unregisterSideDialog(existing.agentId, existingSession);
775
841
  if (!removed) {
776
- throw new Error(`Failed to unregister dead registered subdialog: root=${rootDialog.id.valueOf()} sub=${existing.id.valueOf()} session=${existingSession}`);
842
+ throw new Error(`Failed to unregister dead registered sideDialog: root=${mainDialog.id.valueOf()} sub=${existing.id.valueOf()} session=${existingSession}`);
777
843
  }
778
- await rootDialog.saveSubdialogRegistry();
779
- log_1.log.debug('Pruned dead registered subdialog from Type B registry', undefined, {
780
- rootId: rootDialog.id.rootId,
781
- subdialogId: existing.id.selfId,
844
+ await mainDialog.saveSideDialogRegistry();
845
+ log_1.log.debug('Pruned dead registered sideDialog from Type B registry', undefined, {
846
+ rootId: mainDialog.id.rootId,
847
+ sideDialogId: existing.id.selfId,
782
848
  agentId: existing.agentId,
783
849
  sessionSlug: existingSession,
784
850
  });
785
851
  return undefined;
786
852
  }
787
- async function resolveDialogWithinRoot(rootDialog, callerDialogId) {
788
- if (callerDialogId === rootDialog.id.selfId) {
789
- return rootDialog;
853
+ async function resolveDialogWithinRoot(mainDialog, askerDialogId) {
854
+ if (askerDialogId === mainDialog.id.selfId) {
855
+ return mainDialog;
790
856
  }
791
- const live = rootDialog.lookupDialog(callerDialogId);
857
+ const live = mainDialog.lookupDialog(askerDialogId);
792
858
  if (live) {
793
859
  return live;
794
860
  }
795
- const restored = await (0, dialog_instance_registry_1.ensureDialogLoaded)(rootDialog, new dialog_1.DialogID(callerDialogId, rootDialog.id.rootId), rootDialog.status);
861
+ const restored = await (0, dialog_instance_registry_1.ensureDialogLoaded)(mainDialog, new dialog_1.DialogID(askerDialogId, mainDialog.id.rootId), mainDialog.status);
796
862
  if (!restored) {
797
- throw new Error(`Type B caller restore invariant violation: root=${rootDialog.id.valueOf()} caller=${callerDialogId}`);
863
+ throw new Error(`Type B asker restore invariant violation: root=${mainDialog.id.valueOf()} asker=${askerDialogId}`);
798
864
  }
799
865
  return restored;
800
866
  }
801
- async function finishRegisteredTellaskReplacement(args) {
802
- const { ownerDialog, subdialog, pendingRecord, responseBody } = args;
803
- const language = (0, work_language_1.getWorkLanguage)();
804
- const requesterId = ownerDialog.agentId;
805
- const response = (0, inter_dialog_format_1.formatTellaskReplacementNoticeContent)({
806
- responderId: subdialog.agentId,
807
- requesterId,
808
- mentionList: pendingRecord.mentionList,
809
- sessionSlug: pendingRecord.sessionSlug,
810
- tellaskContent: pendingRecord.tellaskContent,
811
- responseBody,
812
- language,
813
- });
814
- const carryoverOriginCourse = pendingRecord.callingCourse;
815
- const carryoverContent = carryoverOriginCourse !== undefined && carryoverOriginCourse !== ownerDialog.currentCourse
816
- ? (0, inter_dialog_format_1.formatTellaskCarryoverResultContent)({
817
- originCourse: carryoverOriginCourse,
818
- callName: pendingRecord.callName,
819
- responderId: subdialog.agentId,
820
- mentionList: pendingRecord.mentionList,
821
- sessionSlug: pendingRecord.sessionSlug,
822
- tellaskContent: pendingRecord.tellaskContent,
823
- responseBody,
824
- status: 'failed',
825
- language,
826
- })
827
- : undefined;
828
- await ownerDialog.receiveTellaskResponse(subdialog.agentId, pendingRecord.callName, pendingRecord.mentionList, pendingRecord.tellaskContent, 'failed', subdialog.id, {
829
- response,
830
- agentId: subdialog.agentId,
831
- callId: pendingRecord.callId,
832
- originMemberId: requesterId,
833
- originCourse: carryoverOriginCourse,
834
- calling_genseq: pendingRecord.callingGenseq,
835
- carryoverContent,
836
- sessionSlug: pendingRecord.sessionSlug,
837
- });
838
- const immediateMirror = carryoverContent !== undefined
839
- ? buildTellaskCarryoverToolOutput({
840
- genseq: ownerDialog.activeGenSeqOrUndefined ?? 1,
841
- content: carryoverContent,
842
- originCourse: carryoverOriginCourse,
843
- carryoverCourse: ownerDialog.currentCourse,
844
- responderId: subdialog.agentId,
845
- callName: pendingRecord.callName,
846
- tellaskContent: pendingRecord.tellaskContent,
847
- status: 'failed',
848
- response,
849
- agentId: subdialog.agentId,
850
- callId: pendingRecord.callId,
851
- originMemberId: requesterId,
852
- mentionList: pendingRecord.mentionList,
853
- sessionSlug: pendingRecord.sessionSlug,
854
- calleeDialogId: subdialog.id.selfId,
855
- })
856
- : buildTellaskResultToolOutput({
857
- callId: pendingRecord.callId,
858
- callName: pendingRecord.callName,
859
- content: response,
860
- status: 'failed',
861
- originCourse: carryoverOriginCourse,
862
- calling_genseq: pendingRecord.callingGenseq,
863
- responderId: subdialog.agentId,
864
- tellaskContent: pendingRecord.tellaskContent,
865
- mentionList: pendingRecord.mentionList,
866
- sessionSlug: pendingRecord.sessionSlug,
867
- agentId: subdialog.agentId,
868
- originMemberId: requesterId,
869
- calleeDialogId: subdialog.id.selfId,
870
- });
871
- await ownerDialog.addChatMessages(immediateMirror);
872
- }
873
867
  async function reviveDialogIfUnblocked(dialog, callbacks, reason) {
874
868
  const suspension = await dialog.getSuspensionStatus({
875
- allowPendingSubdialogs: reason === 'reply_tellask_back_delivered',
869
+ allowPendingSideDialogs: true,
876
870
  });
877
871
  if (!suspension.canDrive) {
878
872
  return;
879
873
  }
880
- if (dialog instanceof dialog_1.RootDialog) {
874
+ if (dialog instanceof dialog_1.MainDialog) {
881
875
  await persistence_1.DialogPersistence.setNeedsDrive(dialog.id, true, dialog.status);
882
876
  }
883
877
  callbacks.scheduleDrive(dialog, {
@@ -886,12 +880,10 @@ async function reviveDialogIfUnblocked(dialog, callbacks, reason) {
886
880
  source: 'kernel_driver_supply_response_parent_revive',
887
881
  reason,
888
882
  suppressDiligencePush: dialog.disableDiligencePush,
889
- noPromptSubdialogResumeEntitlement: dialog instanceof dialog_1.SubDialog
883
+ noPromptSideDialogResumeEntitlement: dialog instanceof dialog_1.SideDialog
890
884
  ? {
891
885
  ownerDialogId: dialog.id.selfId,
892
- reason: reason === 'reply_tellask_back_delivered'
893
- ? 'reply_tellask_back_delivered'
894
- : 'resolved_pending_subdialog_reply',
886
+ reason: 'reply_tellask_back_delivered',
895
887
  }
896
888
  : undefined,
897
889
  },
@@ -914,13 +906,13 @@ function extractLastAssistantResponse(messages, defaultMessage) {
914
906
  }
915
907
  return responseText;
916
908
  }
917
- function findDeliveredTellaskBackReplyOnAskBackRequester(args) {
909
+ function findDeliveredTellaskBackReplyOnAskBackAsker(args) {
918
910
  // `replyTellaskBack` persists the canonical tellaskBack business result onto the ask-back
919
- // requester dialog immediately. Type-A orchestration must check that canonical delivery first
920
- // before it even considers any fallback extraction from responder plaintext, or we risk a
911
+ // asker immediately. Type-A orchestration must check that canonical delivery first
912
+ // before it even considers any fallback extraction from tellaskee plaintext, or we risk a
921
913
  // second final result with the same target callId.
922
- for (let i = args.requesterDialog.msgs.length - 1; i >= 0; i -= 1) {
923
- const msg = args.requesterDialog.msgs[i];
914
+ for (let i = args.askerDialog.msgs.length - 1; i >= 0; i -= 1) {
915
+ const msg = args.askerDialog.msgs[i];
924
916
  if (msg.type !== 'tellask_result_msg' || msg.callName !== 'tellaskBack') {
925
917
  continue;
926
918
  }
@@ -931,25 +923,31 @@ function findDeliveredTellaskBackReplyOnAskBackRequester(args) {
931
923
  }
932
924
  return undefined;
933
925
  }
934
- async function extractAskBackResponderPlaintextFallback(args) {
926
+ async function extractAskBackTellaskeePlaintextFallback(args) {
935
927
  try {
936
- return extractLastAssistantResponse(args.responderDialog.msgs, 'Supdialog completed without producing output.');
928
+ return extractLastAssistantResponse(args.tellaskeeDialog.msgs, 'AskerDialog completed without producing output.');
937
929
  }
938
930
  catch (err) {
939
- log_1.log.warn('Failed to extract supdialog response for Type A', err);
940
- return 'Supdialog completed with errors.';
931
+ log_1.log.warn('Failed to extract askerDialog response for Type A', err);
932
+ return 'AskerDialog completed with errors.';
941
933
  }
942
934
  }
943
935
  async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, options) {
944
936
  const toolOutputs = [];
945
937
  const callName = options.callName;
946
- const rawCallingCourse = dlg.activeGenCourseOrUndefined ?? dlg.currentCourse;
947
- const callingCourse = Number.isFinite(rawCallingCourse) && rawCallingCourse > 0
948
- ? (0, storage_1.toCallingCourseNumber)(rawCallingCourse)
949
- : undefined;
950
- const callingGenseq = typeof dlg.activeGenSeqOrUndefined === 'number'
951
- ? (0, storage_1.toCallingGenerationSeqNumber)(dlg.activeGenSeqOrUndefined)
952
- : undefined;
938
+ const rawCallSiteCourse = dlg.activeGenCourseOrUndefined ?? dlg.currentCourse;
939
+ if (!Number.isFinite(rawCallSiteCourse) || rawCallSiteCourse <= 0) {
940
+ throw new Error(`tellask pending invariant violation: missing valid call-site course ` +
941
+ `(rootId=${dlg.id.rootId}, selfId=${dlg.id.selfId}, callId=${callId}, callName=${callName})`);
942
+ }
943
+ const callSiteCourse = (0, storage_1.toCallSiteCourseNo)(rawCallSiteCourse);
944
+ if (typeof dlg.activeGenSeqOrUndefined !== 'number' ||
945
+ !Number.isInteger(dlg.activeGenSeqOrUndefined) ||
946
+ dlg.activeGenSeqOrUndefined <= 0) {
947
+ throw new Error(`tellask pending invariant violation: missing active genseq ` +
948
+ `(rootId=${dlg.id.rootId}, selfId=${dlg.id.selfId}, callId=${callId}, callName=${callName})`);
949
+ }
950
+ const callSiteGenseq = (0, storage_1.toCallSiteGenseqNo)(dlg.activeGenSeqOrUndefined);
953
951
  const parseResult = options.parseResult;
954
952
  const normalizedMentionList = mentionList ?? [];
955
953
  const isFreshBootsCall = callName === 'freshBootsReasoning';
@@ -971,7 +969,7 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
971
969
  callSiteRef: {
972
970
  course: dlg.currentCourse,
973
971
  messageIndex: dlg.msgs.length,
974
- ...(callingGenseq !== undefined ? { callingGenseq } : {}),
972
+ ...(callSiteGenseq !== undefined ? { callSiteGenseq } : {}),
975
973
  },
976
974
  };
977
975
  await persistence_1.DialogPersistence.appendQuestion4HumanState(dlg.id, question);
@@ -1014,8 +1012,8 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1014
1012
  callName,
1015
1013
  content: msg,
1016
1014
  status: 'failed',
1017
- originCourse: callingCourse,
1018
- calling_genseq: callingGenseq,
1015
+ callSiteCourse,
1016
+ callSiteGenseq,
1019
1017
  responderId: 'dominds',
1020
1018
  tellaskContent: body,
1021
1019
  mentionList: normalizedMentionList,
@@ -1023,8 +1021,8 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1023
1021
  originMemberId: dlg.agentId,
1024
1022
  }));
1025
1023
  await dlg.receiveTellaskCallResult('dominds', callName, mentionList, body, msg, 'failed', callId, {
1026
- originCourse: callingCourse,
1027
- calling_genseq: callingGenseq,
1024
+ callSiteCourse,
1025
+ callSiteGenseq,
1028
1026
  });
1029
1027
  dlg.clearCurrentCallId();
1030
1028
  return toolOutputs;
@@ -1034,7 +1032,7 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1034
1032
  if (callName === 'tellaskBack' && parseResult.type !== 'A') {
1035
1033
  throw new Error(`tellaskBack invariant violation: expected Type A parseResult (callId=${callId}, got=${parseResult.type})`);
1036
1034
  }
1037
- const subdialogCallName = callName === 'tellaskBack' ? 'freshBootsReasoning' : callName;
1035
+ const sideDialogCallName = callName === 'tellaskBack' ? 'freshBootsReasoning' : callName;
1038
1036
  const firstMentionForError = options.targetForError ?? parseResult.agentId;
1039
1037
  if (parseResult.type !== 'A' && member === null) {
1040
1038
  const msg = (0, driver_messages_1.formatDomindsNoteTellaskForTeammatesOnly)((0, work_language_1.getWorkLanguage)(), {
@@ -1046,8 +1044,8 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1046
1044
  callName,
1047
1045
  content: msg,
1048
1046
  status: 'failed',
1049
- originCourse: callingCourse,
1050
- calling_genseq: callingGenseq,
1047
+ callSiteCourse,
1048
+ callSiteGenseq,
1051
1049
  responderId: 'dominds',
1052
1050
  tellaskContent: body,
1053
1051
  mentionList: normalizedMentionList,
@@ -1055,8 +1053,8 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1055
1053
  originMemberId: dlg.agentId,
1056
1054
  }));
1057
1055
  await dlg.receiveTellaskCallResult('dominds', callName, mentionList, body, msg, 'failed', callId, {
1058
- originCourse: callingCourse,
1059
- calling_genseq: callingGenseq,
1056
+ callSiteCourse,
1057
+ callSiteGenseq,
1060
1058
  });
1061
1059
  dlg.clearCurrentCallId();
1062
1060
  return toolOutputs;
@@ -1071,8 +1069,8 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1071
1069
  callName,
1072
1070
  content: msg,
1073
1071
  status: 'failed',
1074
- originCourse: callingCourse,
1075
- calling_genseq: callingGenseq,
1072
+ callSiteCourse,
1073
+ callSiteGenseq,
1076
1074
  responderId: 'dominds',
1077
1075
  tellaskContent: body,
1078
1076
  mentionList: normalizedMentionList,
@@ -1080,8 +1078,8 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1080
1078
  originMemberId: dlg.agentId,
1081
1079
  }));
1082
1080
  await dlg.receiveTellaskCallResult('dominds', callName, mentionList, body, msg, 'failed', callId, {
1083
- originCourse: callingCourse,
1084
- calling_genseq: callingGenseq,
1081
+ callSiteCourse,
1082
+ callSiteGenseq,
1085
1083
  });
1086
1084
  dlg.clearCurrentCallId();
1087
1085
  return toolOutputs;
@@ -1103,8 +1101,8 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1103
1101
  callName,
1104
1102
  content: msg,
1105
1103
  status: 'failed',
1106
- originCourse: callingCourse,
1107
- calling_genseq: callingGenseq,
1104
+ callSiteCourse,
1105
+ callSiteGenseq,
1108
1106
  responderId: 'dominds',
1109
1107
  tellaskContent: body,
1110
1108
  mentionList: normalizedMentionList,
@@ -1112,13 +1110,13 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1112
1110
  originMemberId: dlg.agentId,
1113
1111
  }));
1114
1112
  await dlg.receiveTellaskCallResult('dominds', callName, mentionList, body, msg, 'failed', callId, {
1115
- originCourse: callingCourse,
1116
- calling_genseq: callingGenseq,
1113
+ callSiteCourse,
1114
+ callSiteGenseq,
1117
1115
  });
1118
1116
  dlg.clearCurrentCallId();
1119
1117
  return toolOutputs;
1120
1118
  }
1121
- const callerDialog = dlg;
1119
+ const askerDialog = dlg;
1122
1120
  const originMemberId = dlg.agentId;
1123
1121
  const collectiveTargets = options?.collectiveTargets ?? [parseResult.agentId];
1124
1122
  if (parseResult.type !== 'C') {
@@ -1131,8 +1129,8 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1131
1129
  callName,
1132
1130
  content: msg,
1133
1131
  status: 'failed',
1134
- originCourse: callingCourse,
1135
- calling_genseq: callingGenseq,
1132
+ callSiteCourse,
1133
+ callSiteGenseq,
1136
1134
  responderId: 'dominds',
1137
1135
  tellaskContent: body,
1138
1136
  mentionList: normalizedMentionList,
@@ -1140,38 +1138,38 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1140
1138
  originMemberId: dlg.agentId,
1141
1139
  }));
1142
1140
  await dlg.receiveTellaskCallResult('dominds', callName, mentionList, body, msg, 'failed', callId, {
1143
- originCourse: callingCourse,
1144
- calling_genseq: callingGenseq,
1141
+ callSiteCourse,
1142
+ callSiteGenseq,
1145
1143
  });
1146
1144
  dlg.clearCurrentCallId();
1147
1145
  return toolOutputs;
1148
1146
  }
1149
- const sub = await createSubDialog(dlg, parseResult.agentId, mentionList, body, {
1150
- callName: subdialogCallName,
1147
+ const sub = await createSideDialog(dlg, parseResult.agentId, mentionList, body, {
1148
+ callName: sideDialogCallName,
1151
1149
  originMemberId,
1152
- callerDialogId: callerDialog.id.selfId,
1150
+ askerDialogId: askerDialog.id.selfId,
1153
1151
  callId,
1154
1152
  collectiveTargets,
1155
1153
  effectiveFbrEffort: fbrEffort,
1156
1154
  });
1157
1155
  sub.setFbrConclusionToolsEnabled(false);
1158
1156
  const pendingRecord = {
1159
- subdialogId: sub.id.selfId,
1157
+ sideDialogId: sub.id.selfId,
1160
1158
  createdAt: (0, time_1.formatUnifiedTimestamp)(new Date()),
1161
- callName: subdialogCallName,
1159
+ callName: sideDialogCallName,
1162
1160
  mentionList,
1163
1161
  tellaskContent: body,
1164
1162
  targetAgentId: parseResult.agentId,
1165
1163
  callId,
1166
- callingCourse,
1167
- callingGenseq,
1164
+ callSiteCourse,
1165
+ callSiteGenseq,
1168
1166
  callType: 'C',
1169
1167
  };
1170
- await (0, subdialog_txn_1.withSubdialogTxnLock)(dlg.id, async () => {
1171
- await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord, (0, storage_1.toRootGenerationAnchor)({
1172
- rootCourse: dlg instanceof dialog_1.SubDialog ? dlg.rootDialog.currentCourse : dlg.currentCourse,
1173
- rootGenseq: dlg instanceof dialog_1.SubDialog
1174
- ? (dlg.rootDialog.activeGenSeqOrUndefined ?? 0)
1168
+ await (0, sideDialog_txn_1.withSideDialogTxnLock)(dlg.id, async () => {
1169
+ await persistence_1.DialogPersistence.appendPendingSideDialog(dlg.id, pendingRecord, (0, storage_1.toRootGenerationAnchor)({
1170
+ rootCourse: dlg instanceof dialog_1.SideDialog ? dlg.mainDialog.currentCourse : dlg.currentCourse,
1171
+ rootGenseq: dlg instanceof dialog_1.SideDialog
1172
+ ? (dlg.mainDialog.activeGenSeqOrUndefined ?? 0)
1175
1173
  : (dlg.activeGenSeqOrUndefined ?? 0),
1176
1174
  }));
1177
1175
  });
@@ -1203,8 +1201,8 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1203
1201
  humanPrompt: initPrompt,
1204
1202
  waitInQue: true,
1205
1203
  driveOptions: {
1206
- source: 'kernel_driver_subdialog_init',
1207
- reason: 'fresh_boots_reasoning_subdialog_init',
1204
+ source: 'kernel_driver_sideDialog_init',
1205
+ reason: 'fresh_boots_reasoning_sideDialog_init',
1208
1206
  },
1209
1207
  });
1210
1208
  return toolOutputs;
@@ -1218,8 +1216,8 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1218
1216
  callName,
1219
1217
  content: msg,
1220
1218
  status: 'failed',
1221
- originCourse: callingCourse,
1222
- calling_genseq: callingGenseq,
1219
+ callSiteCourse,
1220
+ callSiteGenseq,
1223
1221
  responderId: 'dominds',
1224
1222
  tellaskContent: body,
1225
1223
  mentionList: normalizedMentionList,
@@ -1227,34 +1225,47 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1227
1225
  originMemberId: dlg.agentId,
1228
1226
  }));
1229
1227
  await dlg.receiveTellaskCallResult('dominds', callName, mentionList, body, msg, 'failed', callId, {
1230
- originCourse: callingCourse,
1231
- calling_genseq: callingGenseq,
1228
+ callSiteCourse,
1229
+ callSiteGenseq,
1232
1230
  });
1233
1231
  dlg.clearCurrentCallId();
1234
1232
  return toolOutputs;
1235
1233
  }
1236
1234
  if (parseResult.type === 'A') {
1237
- if (dlg instanceof dialog_1.SubDialog) {
1235
+ if (dlg instanceof dialog_1.SideDialog) {
1238
1236
  // Identity map for Type-A ask-back:
1239
- // - `askBackRequesterDialog` is the sideline dialog that asked upstream for clarification.
1240
- // - `askBackResponderDialog` is the upstream dialog that must answer that ask-back.
1237
+ // - `askBackAskerDialog` is the Side Dialog that asked the tellasker for clarification.
1238
+ // - `askBackTellaskeeDialog` is the tellasker that must answer that ask-back.
1241
1239
  // The original tellask relationship is the opposite of the current ask-back relationship,
1242
- // so variable names like "supdialog" or "target" are too lossy here and invite bugs.
1243
- const askBackRequesterDialog = dlg;
1244
- const askBackResponderDialog = dlg.supdialog;
1245
- askBackRequesterDialog.setSuspensionState('suspended');
1240
+ // so variable names like "askerDialog" or "target" are too lossy here and invite bugs.
1241
+ const askBackAskerDialog = dlg;
1242
+ const askBackTellaskeeDialog = dlg.askerDialog;
1243
+ askBackAskerDialog.setSuspensionState('suspended');
1246
1244
  try {
1247
- const assignment = askBackRequesterDialog.assignmentFromSup;
1248
- const supPrompt = {
1249
- content: (0, inter_dialog_format_1.formatSupdialogCallPrompt)({
1250
- fromAgentId: askBackRequesterDialog.agentId,
1251
- toAgentId: askBackResponderDialog.agentId,
1252
- subdialogRequest: {
1245
+ const assignment = askBackAskerDialog.assignmentFromAsker;
1246
+ const tellaskBackReplyDirective = buildTellaskBackReplyDirective({
1247
+ targetDialogId: askBackAskerDialog.id.selfId,
1248
+ targetCallId: callId,
1249
+ tellaskContent: body,
1250
+ });
1251
+ await persistence_1.DialogPersistence.pushTellaskReplyObligation(askBackTellaskeeDialog.id, tellaskBackReplyDirective, askBackTellaskeeDialog.status);
1252
+ if (askBackTellaskeeDialog instanceof dialog_1.SideDialog) {
1253
+ const nextAskerStackState = await persistence_1.DialogPersistence.loadSideDialogAskerStackState(askBackTellaskeeDialog.id, askBackTellaskeeDialog.status);
1254
+ if (!nextAskerStackState) {
1255
+ throw new Error(`Missing asker stack after tellaskBack push: ${askBackTellaskeeDialog.id.valueOf()}`);
1256
+ }
1257
+ askBackTellaskeeDialog.askerStack = nextAskerStackState;
1258
+ }
1259
+ const askerPrompt = {
1260
+ content: (0, inter_dialog_format_1.formatAskerDialogCallPrompt)({
1261
+ fromAgentId: askBackAskerDialog.agentId,
1262
+ toAgentId: askBackTellaskeeDialog.agentId,
1263
+ sideDialogRequest: {
1253
1264
  callName,
1254
1265
  mentionList,
1255
1266
  tellaskContent: body,
1256
1267
  },
1257
- supdialogAssignment: {
1268
+ askerDialogAssignment: {
1258
1269
  callName: assignment.callName,
1259
1270
  mentionList: assignment.mentionList,
1260
1271
  tellaskContent: assignment.tellaskContent,
@@ -1264,39 +1275,36 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1264
1275
  msgId: (0, id_1.generateShortId)(),
1265
1276
  grammar: 'markdown',
1266
1277
  origin: 'runtime',
1267
- tellaskReplyDirective: buildTellaskBackReplyDirective({
1268
- targetDialogId: askBackRequesterDialog.id.selfId,
1269
- targetCallId: callId,
1270
- tellaskContent: body,
1271
- }),
1278
+ tellaskReplyDirective: tellaskBackReplyDirective,
1272
1279
  };
1273
- await callbacks.driveDialog(askBackResponderDialog, {
1274
- humanPrompt: supPrompt,
1280
+ await callbacks.driveDialog(askBackTellaskeeDialog, {
1281
+ humanPrompt: askerPrompt,
1275
1282
  waitInQue: true,
1276
1283
  driveOptions: {
1277
- source: 'kernel_driver_type_a_supdialog_call',
1278
- reason: 'type_a_supdialog_roundtrip',
1284
+ source: 'kernel_driver_type_a_askerDialog_call',
1285
+ reason: 'type_a_askerDialog_roundtrip',
1279
1286
  },
1280
1287
  });
1281
- const explicitReplyDelivery = findDeliveredTellaskBackReplyOnAskBackRequester({
1282
- requesterDialog: askBackRequesterDialog,
1288
+ const explicitReplyDelivery = findDeliveredTellaskBackReplyOnAskBackAsker({
1289
+ askerDialog: askBackAskerDialog,
1283
1290
  targetCallId: callId,
1284
1291
  });
1285
1292
  if (explicitReplyDelivery) {
1286
- // Important invariant: once the responder used `replyTellaskBack`, that write is the
1293
+ // Important invariant: once the tellaskee used `replyTellaskBack`, that write is the
1287
1294
  // single source of truth. Do not also synthesize another tellask result from the
1288
- // responder's generic assistant words, even if those words look "compatible".
1289
- askBackRequesterDialog.setSuspensionState('resumed');
1295
+ // tellaskee's generic assistant words, even if those words look "compatible".
1296
+ askBackAskerDialog.setSuspensionState('resumed');
1290
1297
  toolOutputs.push(explicitReplyDelivery);
1291
1298
  return toolOutputs;
1292
1299
  }
1293
- const responseText = await extractAskBackResponderPlaintextFallback({
1294
- responderDialog: askBackResponderDialog,
1300
+ const responseText = await extractAskBackTellaskeePlaintextFallback({
1301
+ tellaskeeDialog: askBackTellaskeeDialog,
1295
1302
  });
1296
1303
  const responseContent = (0, inter_dialog_format_1.formatTellaskResponseContent)({
1297
1304
  callName,
1305
+ callId,
1298
1306
  responderId: parseResult.agentId,
1299
- requesterId: askBackRequesterDialog.agentId,
1307
+ tellaskerId: askBackAskerDialog.agentId,
1300
1308
  mentionList,
1301
1309
  tellaskContent: body,
1302
1310
  responseBody: responseText,
@@ -1304,38 +1312,39 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1304
1312
  deliveryMode: 'direct_fallback',
1305
1313
  language: (0, work_language_1.getWorkLanguage)(),
1306
1314
  });
1307
- askBackRequesterDialog.setSuspensionState('resumed');
1315
+ askBackAskerDialog.setSuspensionState('resumed');
1308
1316
  toolOutputs.push(buildTellaskResultToolOutput({
1309
1317
  callId,
1310
1318
  callName,
1311
1319
  content: responseContent,
1312
1320
  status: 'completed',
1313
- originCourse: callingCourse,
1314
- calling_genseq: callingGenseq,
1321
+ callSiteCourse,
1322
+ callSiteGenseq,
1315
1323
  responderId: parseResult.agentId,
1316
1324
  tellaskContent: body,
1317
1325
  mentionList,
1318
1326
  agentId: parseResult.agentId,
1319
- originMemberId: askBackRequesterDialog.agentId,
1320
- calleeDialogId: askBackResponderDialog.id.selfId,
1327
+ originMemberId: askBackAskerDialog.agentId,
1328
+ calleeDialogId: askBackTellaskeeDialog.id.selfId,
1321
1329
  }));
1322
- await askBackRequesterDialog.receiveTellaskResponse(parseResult.agentId, callName, mentionList, body, 'completed', askBackResponderDialog.id, {
1330
+ await askBackAskerDialog.receiveTellaskResponse(parseResult.agentId, callName, mentionList, body, 'completed', askBackTellaskeeDialog.id, {
1323
1331
  response: responseContent,
1324
1332
  agentId: parseResult.agentId,
1325
1333
  callId,
1326
- originMemberId: askBackRequesterDialog.agentId,
1327
- originCourse: callingCourse,
1328
- calling_genseq: callingGenseq,
1334
+ originMemberId: askBackAskerDialog.agentId,
1335
+ callSiteCourse,
1336
+ callSiteGenseq,
1329
1337
  });
1330
1338
  }
1331
1339
  catch (err) {
1332
- log_1.log.warn('Type A supdialog processing error:', err);
1333
- askBackRequesterDialog.setSuspensionState('resumed');
1340
+ log_1.log.warn('Type A askerDialog processing error:', err);
1341
+ askBackAskerDialog.setSuspensionState('resumed');
1334
1342
  const errorText = `❌ **Error processing request to @${parseResult.agentId}:**\n\n${showErrorToAi(err)}`;
1335
1343
  const errorContent = (0, inter_dialog_format_1.formatTellaskResponseContent)({
1336
1344
  callName,
1345
+ callId,
1337
1346
  responderId: parseResult.agentId,
1338
- requesterId: askBackRequesterDialog.agentId,
1347
+ tellaskerId: askBackAskerDialog.agentId,
1339
1348
  mentionList,
1340
1349
  tellaskContent: body,
1341
1350
  responseBody: errorText,
@@ -1347,261 +1356,206 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1347
1356
  callName,
1348
1357
  content: errorContent,
1349
1358
  status: 'failed',
1350
- originCourse: callingCourse,
1351
- calling_genseq: callingGenseq,
1359
+ callSiteCourse,
1360
+ callSiteGenseq,
1352
1361
  responderId: parseResult.agentId,
1353
1362
  tellaskContent: body,
1354
1363
  mentionList,
1355
1364
  agentId: parseResult.agentId,
1356
- originMemberId: askBackRequesterDialog.agentId,
1357
- calleeDialogId: askBackResponderDialog.id.selfId,
1365
+ originMemberId: askBackAskerDialog.agentId,
1366
+ calleeDialogId: askBackTellaskeeDialog.id.selfId,
1358
1367
  }));
1359
- await askBackRequesterDialog.receiveTellaskResponse(parseResult.agentId, callName, mentionList, body, 'failed', askBackResponderDialog.id, {
1368
+ await askBackAskerDialog.receiveTellaskResponse(parseResult.agentId, callName, mentionList, body, 'failed', askBackTellaskeeDialog.id, {
1360
1369
  response: errorContent,
1361
1370
  agentId: parseResult.agentId,
1362
1371
  callId,
1363
- originMemberId: askBackRequesterDialog.agentId,
1364
- originCourse: callingCourse,
1365
- calling_genseq: callingGenseq,
1372
+ originMemberId: askBackAskerDialog.agentId,
1373
+ callSiteCourse,
1374
+ callSiteGenseq,
1366
1375
  });
1367
1376
  }
1368
1377
  }
1369
1378
  else {
1370
- log_1.log.warn('Type A call on dialog without supdialog, falling back to Type C', undefined, {
1371
- dialogId: dlg.id.selfId,
1379
+ const err = new Error(`Type A tellaskBack invariant violation: dialog is not a sideDialog ` +
1380
+ `(rootId=${dlg.id.rootId}, selfId=${dlg.id.selfId}, callId=${callId})`);
1381
+ log_1.log.error('Type A tellaskBack invariant violation: dialog is not a sideDialog', err, {
1382
+ rootId: dlg.id.rootId,
1383
+ selfId: dlg.id.selfId,
1384
+ course: callSiteCourse,
1385
+ genseq: callSiteGenseq,
1386
+ callId,
1372
1387
  });
1388
+ throw err;
1373
1389
  }
1374
1390
  }
1375
1391
  else if (parseResult.type === 'B') {
1376
- const callerDialog = dlg;
1377
- let rootDialog;
1378
- if (dlg instanceof dialog_1.RootDialog) {
1379
- rootDialog = dlg;
1392
+ const askerDialog = dlg;
1393
+ let mainDialog;
1394
+ if (dlg instanceof dialog_1.MainDialog) {
1395
+ mainDialog = dlg;
1380
1396
  }
1381
- else if (dlg instanceof dialog_1.SubDialog) {
1382
- rootDialog = dlg.rootDialog;
1397
+ else if (dlg instanceof dialog_1.SideDialog) {
1398
+ mainDialog = dlg.mainDialog;
1383
1399
  }
1384
- if (!rootDialog) {
1385
- log_1.log.warn('Type B call without root dialog, falling back to Type C', undefined, {
1386
- dialogId: dlg.id.selfId,
1400
+ if (!mainDialog) {
1401
+ const err = new Error(`Type B tellask invariant violation: missing mainDialog ` +
1402
+ `(rootId=${dlg.id.rootId}, selfId=${dlg.id.selfId}, callId=${callId})`);
1403
+ log_1.log.error('Type B tellask invariant violation: missing mainDialog', err, {
1404
+ rootId: dlg.id.rootId,
1405
+ selfId: dlg.id.selfId,
1406
+ course: callSiteCourse,
1407
+ genseq: callSiteGenseq,
1408
+ callId,
1409
+ sessionSlug: parseResult.sessionSlug,
1387
1410
  });
1388
- try {
1389
- const sub = await createSubDialog(dlg, parseResult.agentId, mentionList, body, {
1390
- callName: subdialogCallName,
1391
- originMemberId: dlg.agentId,
1392
- callerDialogId: callerDialog.id.selfId,
1393
- callId,
1394
- sessionSlug: parseResult.sessionSlug,
1395
- collectiveTargets: options?.collectiveTargets ?? [parseResult.agentId],
1396
- });
1397
- const pendingRecord = {
1398
- subdialogId: sub.id.selfId,
1399
- createdAt: (0, time_1.formatUnifiedTimestamp)(new Date()),
1400
- callName: subdialogCallName,
1401
- mentionList,
1402
- tellaskContent: body,
1403
- targetAgentId: parseResult.agentId,
1404
- callId,
1405
- callingCourse,
1406
- callingGenseq,
1407
- callType: 'C',
1408
- sessionSlug: parseResult.sessionSlug,
1409
- };
1410
- await (0, subdialog_txn_1.withSubdialogTxnLock)(dlg.id, async () => {
1411
- await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord, (0, storage_1.toRootGenerationAnchor)({
1412
- rootCourse: dlg instanceof dialog_1.SubDialog ? dlg.rootDialog.currentCourse : dlg.currentCourse,
1413
- rootGenseq: dlg instanceof dialog_1.SubDialog
1414
- ? (dlg.rootDialog.activeGenSeqOrUndefined ?? 0)
1415
- : (dlg.activeGenSeqOrUndefined ?? 0),
1416
- }));
1417
- });
1418
- await syncPendingTellaskReminderBestEffort(dlg, 'kernel-driver:executeTellaskCall:TypeB-fallback:appendPending');
1419
- const initPrompt = {
1420
- content: (0, inter_dialog_format_1.formatAssignmentFromSupdialog)({
1421
- callName: subdialogCallName,
1422
- fromAgentId: dlg.agentId,
1423
- toAgentId: sub.agentId,
1424
- mentionList,
1425
- tellaskContent: body,
1426
- language: (0, work_language_1.getWorkLanguage)(),
1427
- collectiveTargets: options?.collectiveTargets ?? [sub.agentId],
1428
- }),
1429
- msgId: (0, id_1.generateShortId)(),
1430
- grammar: 'markdown',
1431
- origin: 'runtime',
1432
- tellaskReplyDirective: buildAssignmentReplyDirective({
1433
- callName: 'tellaskSessionless',
1434
- targetCallId: callId,
1435
- tellaskContent: body,
1436
- }),
1437
- subdialogReplyTarget: {
1438
- ownerDialogId: callerDialog.id.selfId,
1439
- callType: 'C',
1440
- callId,
1441
- },
1442
- };
1443
- callbacks.scheduleDrive(sub, {
1444
- humanPrompt: initPrompt,
1445
- waitInQue: true,
1446
- driveOptions: {
1447
- source: 'kernel_driver_subdialog_init',
1448
- reason: 'type_b_fallback_subdialog_init',
1449
- },
1450
- });
1451
- }
1452
- catch (err) {
1453
- log_1.log.warn('Type B fallback subdialog creation error:', err);
1454
- }
1411
+ throw err;
1455
1412
  }
1456
1413
  else {
1457
1414
  const originMemberId = dlg.agentId;
1458
1415
  const assignment = {
1459
- callName: subdialogCallName,
1416
+ callName: sideDialogCallName,
1460
1417
  mentionList,
1461
1418
  tellaskContent: body,
1462
1419
  originMemberId,
1463
- callerDialogId: callerDialog.id.selfId,
1420
+ askerDialogId: askerDialog.id.selfId,
1464
1421
  callId,
1465
1422
  collectiveTargets: options?.collectiveTargets ?? [parseResult.agentId],
1466
1423
  };
1467
- const pendingOwner = callerDialog;
1468
- const replacementNotice = (0, driver_messages_1.formatRegisteredTellaskCallerUpdateNotice)((0, work_language_1.getWorkLanguage)());
1424
+ const pendingOwner = askerDialog;
1425
+ const isSameRegisteredSessionPending = (record) => record.callType === 'B' &&
1426
+ record.callName === 'tellask' &&
1427
+ record.targetAgentId === parseResult.agentId &&
1428
+ record.sessionSlug === parseResult.sessionSlug;
1469
1429
  const result = await (async () => {
1470
1430
  for (let attempt = 0; attempt < 4; attempt += 1) {
1471
- const seededExisting = rootDialog.lookupSubdialog(parseResult.agentId, parseResult.sessionSlug);
1472
- const seededPreviousCallerId = seededExisting?.assignmentFromSup.callerDialogId;
1473
- const lockIds = [rootDialog.id, pendingOwner.id];
1474
- if (seededPreviousCallerId !== undefined &&
1475
- seededPreviousCallerId !== rootDialog.id.selfId &&
1476
- seededPreviousCallerId !== pendingOwner.id.selfId) {
1477
- lockIds.push(new dialog_1.DialogID(seededPreviousCallerId, rootDialog.id.rootId));
1431
+ const seededExisting = mainDialog.lookupSideDialog(parseResult.agentId, parseResult.sessionSlug);
1432
+ const seededPreviousAskerId = seededExisting?.assignmentFromAsker.askerDialogId;
1433
+ const lockIds = [mainDialog.id, pendingOwner.id];
1434
+ if (seededPreviousAskerId !== undefined &&
1435
+ seededPreviousAskerId !== mainDialog.id.selfId &&
1436
+ seededPreviousAskerId !== pendingOwner.id.selfId) {
1437
+ lockIds.push(new dialog_1.DialogID(seededPreviousAskerId, mainDialog.id.rootId));
1478
1438
  }
1479
- const attemptResult = await (0, subdialog_txn_1.withSubdialogTxnLocks)(lockIds, async () => {
1480
- const existing = await lookupLiveRegisteredSubdialog(rootDialog, parseResult.agentId, parseResult.sessionSlug);
1439
+ const attemptResult = await (0, sideDialog_txn_1.withSideDialogTxnLocks)(lockIds, async () => {
1440
+ const existing = await lookupLiveRegisteredSideDialog(mainDialog, parseResult.agentId, parseResult.sessionSlug);
1481
1441
  if (existing) {
1482
- if (existing.assignmentFromSup.callerDialogId !== seededPreviousCallerId) {
1442
+ if (existing.assignmentFromAsker.askerDialogId !== seededPreviousAskerId) {
1483
1443
  return { kind: 'retry' };
1484
1444
  }
1485
- const previousCaller = await resolveDialogWithinRoot(rootDialog, existing.assignmentFromSup.callerDialogId);
1445
+ const previousAssignment = existing.assignmentFromAsker;
1486
1446
  const pendingRecord = {
1487
- subdialogId: existing.id.selfId,
1447
+ sideDialogId: existing.id.selfId,
1488
1448
  createdAt: (0, time_1.formatUnifiedTimestamp)(new Date()),
1489
- callName: subdialogCallName,
1449
+ callName: sideDialogCallName,
1490
1450
  mentionList,
1491
1451
  tellaskContent: body,
1492
1452
  targetAgentId: parseResult.agentId,
1493
1453
  callId,
1494
- callingCourse,
1495
- callingGenseq,
1454
+ callSiteCourse,
1455
+ callSiteGenseq,
1496
1456
  callType: 'B',
1497
1457
  sessionSlug: parseResult.sessionSlug,
1498
1458
  };
1499
1459
  try {
1500
- const previousPending = await persistence_1.DialogPersistence.loadPendingSubdialogs(previousCaller.id, previousCaller.status);
1501
- const replacedPending = previousPending.filter((record) => record.subdialogId === existing.id.selfId);
1502
- if (replacedPending.length > 1) {
1503
- throw new Error(`Type B pending invariant violation: caller=${previousCaller.id.valueOf()} sub=${existing.id.valueOf()} count=${replacedPending.length}`);
1504
- }
1505
- if (previousCaller.id.selfId === pendingOwner.id.selfId) {
1506
- const nextPending = previousPending.filter((record) => record.subdialogId !== existing.id.selfId);
1507
- nextPending.push(pendingRecord);
1508
- await persistence_1.DialogPersistence.savePendingSubdialogs(pendingOwner.id, nextPending, undefined, pendingOwner.status);
1509
- }
1510
- else {
1511
- await persistence_1.DialogPersistence.savePendingSubdialogs(previousCaller.id, previousPending.filter((record) => record.subdialogId !== existing.id.selfId), undefined, previousCaller.status);
1512
- const nextPending = (await persistence_1.DialogPersistence.loadPendingSubdialogs(pendingOwner.id, pendingOwner.status)).filter((record) => record.subdialogId !== existing.id.selfId);
1513
- nextPending.push(pendingRecord);
1514
- await persistence_1.DialogPersistence.savePendingSubdialogs(pendingOwner.id, nextPending, undefined, pendingOwner.status);
1460
+ if (previousAssignment.askerDialogId !== pendingOwner.id.selfId) {
1461
+ await persistence_1.DialogPersistence.mutatePendingSideDialogs(new dialog_1.DialogID(previousAssignment.askerDialogId, mainDialog.id.rootId), (previousPending) => ({
1462
+ kind: 'replace',
1463
+ records: previousPending.filter((record) => !isSameRegisteredSessionPending(record)),
1464
+ }), undefined, pendingOwner.status);
1515
1465
  }
1516
- await updateSubdialogAssignment(existing, assignment);
1466
+ await persistence_1.DialogPersistence.mutatePendingSideDialogs(pendingOwner.id, (previousPending) => ({
1467
+ kind: 'replace',
1468
+ records: [
1469
+ ...previousPending.filter((record) => !isSameRegisteredSessionPending(record)),
1470
+ pendingRecord,
1471
+ ],
1472
+ }), undefined, pendingOwner.status);
1473
+ await updateSideDialogAssignment(existing, assignment, {
1474
+ replacePendingCallId: previousAssignment.callId,
1475
+ replacePendingAskerDialogId: previousAssignment.askerDialogId,
1476
+ });
1517
1477
  return {
1518
1478
  kind: 'existing',
1519
- subdialog: existing,
1520
- previousCaller,
1521
- replacedPending: replacedPending[0],
1479
+ sideDialog: existing,
1480
+ previousPendingOwnerId: previousAssignment.askerDialogId,
1522
1481
  };
1523
1482
  }
1524
1483
  catch (err) {
1525
- log_1.log.warn('Failed to update registered subdialog assignment', err);
1526
- return {
1527
- kind: 'existing',
1528
- subdialog: existing,
1529
- previousCaller,
1530
- replacedPending: undefined,
1531
- };
1484
+ log_1.log.error('Failed to update registered sideDialog assignment', err, {
1485
+ rootId: mainDialog.id.rootId,
1486
+ sideDialogId: existing.id.selfId,
1487
+ ownerDialogId: pendingOwner.id.selfId,
1488
+ callId,
1489
+ sessionSlug: parseResult.sessionSlug,
1490
+ });
1491
+ throw err;
1532
1492
  }
1533
1493
  }
1534
- if (seededPreviousCallerId !== undefined) {
1494
+ if (seededPreviousAskerId !== undefined) {
1535
1495
  return { kind: 'retry' };
1536
1496
  }
1537
- const created = await createSubDialog(rootDialog, parseResult.agentId, mentionList, body, {
1538
- callName: subdialogCallName,
1497
+ const created = await createSideDialog(askerDialog, parseResult.agentId, mentionList, body, {
1498
+ callName: sideDialogCallName,
1539
1499
  originMemberId,
1540
- callerDialogId: callerDialog.id.selfId,
1500
+ askerDialogId: askerDialog.id.selfId,
1541
1501
  callId,
1542
1502
  sessionSlug: parseResult.sessionSlug,
1543
1503
  collectiveTargets: options?.collectiveTargets ?? [parseResult.agentId],
1544
1504
  });
1545
- rootDialog.registerSubdialog(created);
1546
- await rootDialog.saveSubdialogRegistry();
1505
+ mainDialog.registerSideDialog(created);
1506
+ await mainDialog.saveSideDialogRegistry();
1547
1507
  const pendingRecord = {
1548
- subdialogId: created.id.selfId,
1508
+ sideDialogId: created.id.selfId,
1549
1509
  createdAt: (0, time_1.formatUnifiedTimestamp)(new Date()),
1550
- callName: subdialogCallName,
1510
+ callName: sideDialogCallName,
1551
1511
  mentionList,
1552
1512
  tellaskContent: body,
1553
1513
  targetAgentId: parseResult.agentId,
1554
1514
  callId,
1555
- callingCourse,
1556
- callingGenseq,
1515
+ callSiteCourse,
1516
+ callSiteGenseq,
1557
1517
  callType: 'B',
1558
1518
  sessionSlug: parseResult.sessionSlug,
1559
1519
  };
1560
- const nextPending = (await persistence_1.DialogPersistence.loadPendingSubdialogs(pendingOwner.id, pendingOwner.status)).filter((record) => record.subdialogId !== created.id.selfId);
1561
- nextPending.push(pendingRecord);
1562
- await persistence_1.DialogPersistence.savePendingSubdialogs(pendingOwner.id, nextPending, undefined, pendingOwner.status);
1563
- return { kind: 'created', subdialog: created };
1520
+ await persistence_1.DialogPersistence.appendPendingSideDialog(pendingOwner.id, pendingRecord, undefined, pendingOwner.status);
1521
+ return { kind: 'created', sideDialog: created };
1564
1522
  });
1565
1523
  if (attemptResult.kind !== 'retry') {
1566
1524
  return attemptResult;
1567
1525
  }
1568
1526
  }
1569
- throw new Error(`Type B registered subdialog mutation failed to stabilize: root=${rootDialog.id.valueOf()} agent=${parseResult.agentId} session=${parseResult.sessionSlug}`);
1527
+ throw new Error(`Type B registered sideDialog mutation failed to stabilize: root=${mainDialog.id.valueOf()} agent=${parseResult.agentId} session=${parseResult.sessionSlug}`);
1570
1528
  })();
1571
- await syncPendingTellaskReminderBestEffort(pendingOwner, 'kernel-driver:executeTellaskCall:TypeB:replacePending');
1572
- if (result.kind === 'existing' && result.replacedPending) {
1573
- await finishRegisteredTellaskReplacement({
1574
- ownerDialog: result.previousCaller,
1575
- subdialog: result.subdialog,
1576
- pendingRecord: result.replacedPending,
1577
- responseBody: replacementNotice,
1578
- });
1579
- if (result.previousCaller.id.selfId !== pendingOwner.id.selfId) {
1580
- await syncPendingTellaskReminderBestEffort(result.previousCaller, 'kernel-driver:executeTellaskCall:TypeB:clearPreviousPending');
1581
- await reviveDialogIfUnblocked(result.previousCaller, callbacks, 'type_b_registered_subdialog_replaced_pending_round');
1529
+ await syncPendingTellaskReminderBestEffort(pendingOwner, 'kernel-driver:executeTellaskCall:TypeB:pushPendingAssignment');
1530
+ if (result.kind === 'existing' &&
1531
+ result.previousPendingOwnerId !== pendingOwner.id.selfId) {
1532
+ const previousPendingOwner = mainDialog.lookupDialog(result.previousPendingOwnerId);
1533
+ if (previousPendingOwner) {
1534
+ await syncPendingTellaskReminderBestEffort(previousPendingOwner, 'kernel-driver:executeTellaskCall:TypeB:replacePreviousPendingAssignment');
1582
1535
  }
1583
1536
  }
1584
1537
  if (result.kind === 'existing') {
1585
1538
  const resumePrompt = {
1586
- content: (0, inter_dialog_format_1.formatUpdatedAssignmentFromSupdialog)({
1587
- callName: subdialogCallName,
1539
+ content: (0, inter_dialog_format_1.formatUpdatedAssignmentFromAskerDialog)({
1540
+ callName: sideDialogCallName,
1588
1541
  fromAgentId: dlg.agentId,
1589
- toAgentId: result.subdialog.agentId,
1542
+ toAgentId: result.sideDialog.agentId,
1590
1543
  mentionList,
1591
1544
  sessionSlug: parseResult.sessionSlug,
1592
1545
  tellaskContent: body,
1593
1546
  language: (0, work_language_1.getWorkLanguage)(),
1594
- collectiveTargets: options?.collectiveTargets ?? [result.subdialog.agentId],
1547
+ collectiveTargets: options?.collectiveTargets ?? [result.sideDialog.agentId],
1595
1548
  }),
1596
1549
  msgId: (0, id_1.generateShortId)(),
1597
1550
  grammar: 'markdown',
1598
1551
  origin: 'runtime',
1599
1552
  tellaskReplyDirective: buildAssignmentReplyDirective({
1600
1553
  callName: 'tellask',
1554
+ targetDialogId: pendingOwner.id.selfId,
1601
1555
  targetCallId: callId,
1602
1556
  tellaskContent: body,
1603
1557
  }),
1604
- subdialogReplyTarget: {
1558
+ sideDialogReplyTarget: {
1605
1559
  ownerDialogId: pendingOwner.id.selfId,
1606
1560
  callType: 'B',
1607
1561
  callId,
@@ -1610,77 +1564,78 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1610
1564
  let queuedIntoActiveLoop = false;
1611
1565
  let queuedRuntimePrompt = false;
1612
1566
  try {
1613
- result.subdialog.queueRegisteredAssignmentUpdatePrompt({
1567
+ result.sideDialog.queueRegisteredAssignmentUpdatePrompt({
1614
1568
  prompt: resumePrompt.content,
1615
1569
  msgId: resumePrompt.msgId,
1616
1570
  grammar: resumePrompt.grammar,
1617
1571
  userLanguageCode: resumePrompt.userLanguageCode,
1618
1572
  tellaskReplyDirective: resumePrompt.tellaskReplyDirective,
1619
1573
  skipTaskdoc: resumePrompt.skipTaskdoc,
1620
- subdialogReplyTarget: resumePrompt.subdialogReplyTarget,
1574
+ sideDialogReplyTarget: resumePrompt.sideDialogReplyTarget,
1621
1575
  });
1622
1576
  queuedRuntimePrompt = true;
1623
- queuedIntoActiveLoop = result.subdialog.isLocked();
1577
+ queuedIntoActiveLoop = result.sideDialog.isLocked();
1624
1578
  }
1625
1579
  catch (err) {
1626
- log_1.log.warn('Failed to queue registered subdialog update into active loop', err, {
1627
- subdialogId: result.subdialog.id.valueOf(),
1580
+ log_1.log.warn('Failed to queue registered sideDialog update into active loop', err, {
1581
+ sideDialogId: result.sideDialog.id.valueOf(),
1628
1582
  sessionSlug: parseResult.sessionSlug,
1629
1583
  callId,
1630
1584
  });
1631
1585
  }
1632
1586
  if (queuedRuntimePrompt && !queuedIntoActiveLoop) {
1633
- callbacks.scheduleDrive(result.subdialog, {
1587
+ callbacks.scheduleDrive(result.sideDialog, {
1634
1588
  waitInQue: true,
1635
1589
  driveOptions: {
1636
- source: 'kernel_driver_subdialog_resume',
1637
- reason: 'type_b_registered_subdialog_resume',
1590
+ source: 'kernel_driver_sideDialog_resume',
1591
+ reason: 'type_b_registered_sideDialog_resume',
1638
1592
  },
1639
1593
  });
1640
1594
  }
1641
1595
  else if (!queuedRuntimePrompt) {
1642
- callbacks.scheduleDrive(result.subdialog, {
1596
+ callbacks.scheduleDrive(result.sideDialog, {
1643
1597
  humanPrompt: resumePrompt,
1644
1598
  waitInQue: true,
1645
1599
  driveOptions: {
1646
- source: 'kernel_driver_subdialog_resume',
1647
- reason: 'type_b_registered_subdialog_resume',
1600
+ source: 'kernel_driver_sideDialog_resume',
1601
+ reason: 'type_b_registered_sideDialog_resume',
1648
1602
  },
1649
1603
  });
1650
1604
  }
1651
1605
  }
1652
1606
  else {
1653
1607
  const initPrompt = {
1654
- content: (0, inter_dialog_format_1.formatAssignmentFromSupdialog)({
1655
- callName: subdialogCallName,
1656
- fromAgentId: rootDialog.agentId,
1657
- toAgentId: result.subdialog.agentId,
1608
+ content: (0, inter_dialog_format_1.formatAssignmentFromAskerDialog)({
1609
+ callName: sideDialogCallName,
1610
+ fromAgentId: mainDialog.agentId,
1611
+ toAgentId: result.sideDialog.agentId,
1658
1612
  mentionList,
1659
1613
  sessionSlug: parseResult.sessionSlug,
1660
1614
  tellaskContent: body,
1661
1615
  language: (0, work_language_1.getWorkLanguage)(),
1662
- collectiveTargets: options?.collectiveTargets ?? [result.subdialog.agentId],
1616
+ collectiveTargets: options?.collectiveTargets ?? [result.sideDialog.agentId],
1663
1617
  }),
1664
1618
  msgId: (0, id_1.generateShortId)(),
1665
1619
  grammar: 'markdown',
1666
1620
  origin: 'runtime',
1667
1621
  tellaskReplyDirective: buildAssignmentReplyDirective({
1668
1622
  callName: 'tellask',
1623
+ targetDialogId: pendingOwner.id.selfId,
1669
1624
  targetCallId: callId,
1670
1625
  tellaskContent: body,
1671
1626
  }),
1672
- subdialogReplyTarget: {
1627
+ sideDialogReplyTarget: {
1673
1628
  ownerDialogId: pendingOwner.id.selfId,
1674
1629
  callType: 'B',
1675
1630
  callId,
1676
1631
  },
1677
1632
  };
1678
- callbacks.scheduleDrive(result.subdialog, {
1633
+ callbacks.scheduleDrive(result.sideDialog, {
1679
1634
  humanPrompt: initPrompt,
1680
1635
  waitInQue: true,
1681
1636
  driveOptions: {
1682
- source: 'kernel_driver_subdialog_init',
1683
- reason: 'type_b_registered_subdialog_init',
1637
+ source: 'kernel_driver_sideDialog_init',
1638
+ reason: 'type_b_registered_sideDialog_init',
1684
1639
  },
1685
1640
  });
1686
1641
  }
@@ -1688,36 +1643,36 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1688
1643
  }
1689
1644
  if (parseResult.type === 'C') {
1690
1645
  try {
1691
- const sub = await createSubDialog(dlg, parseResult.agentId, mentionList, body, {
1692
- callName: subdialogCallName,
1646
+ const sub = await createSideDialog(dlg, parseResult.agentId, mentionList, body, {
1647
+ callName: sideDialogCallName,
1693
1648
  originMemberId: dlg.agentId,
1694
- callerDialogId: dlg.id.selfId,
1649
+ askerDialogId: dlg.id.selfId,
1695
1650
  callId,
1696
1651
  collectiveTargets: options?.collectiveTargets ?? [parseResult.agentId],
1697
1652
  });
1698
1653
  const pendingRecord = {
1699
- subdialogId: sub.id.selfId,
1654
+ sideDialogId: sub.id.selfId,
1700
1655
  createdAt: (0, time_1.formatUnifiedTimestamp)(new Date()),
1701
- callName: subdialogCallName,
1656
+ callName: sideDialogCallName,
1702
1657
  mentionList,
1703
1658
  tellaskContent: body,
1704
1659
  targetAgentId: parseResult.agentId,
1705
1660
  callId,
1706
- callingCourse,
1707
- callingGenseq,
1661
+ callSiteCourse,
1662
+ callSiteGenseq,
1708
1663
  callType: 'C',
1709
1664
  };
1710
- await (0, subdialog_txn_1.withSubdialogTxnLock)(dlg.id, async () => {
1711
- await persistence_1.DialogPersistence.appendPendingSubdialog(dlg.id, pendingRecord, (0, storage_1.toRootGenerationAnchor)({
1712
- rootCourse: dlg instanceof dialog_1.SubDialog ? dlg.rootDialog.currentCourse : dlg.currentCourse,
1713
- rootGenseq: dlg instanceof dialog_1.SubDialog
1714
- ? (dlg.rootDialog.activeGenSeqOrUndefined ?? 0)
1665
+ await (0, sideDialog_txn_1.withSideDialogTxnLock)(dlg.id, async () => {
1666
+ await persistence_1.DialogPersistence.appendPendingSideDialog(dlg.id, pendingRecord, (0, storage_1.toRootGenerationAnchor)({
1667
+ rootCourse: dlg instanceof dialog_1.SideDialog ? dlg.mainDialog.currentCourse : dlg.currentCourse,
1668
+ rootGenseq: dlg instanceof dialog_1.SideDialog
1669
+ ? (dlg.mainDialog.activeGenSeqOrUndefined ?? 0)
1715
1670
  : (dlg.activeGenSeqOrUndefined ?? 0),
1716
1671
  }));
1717
1672
  });
1718
1673
  await syncPendingTellaskReminderBestEffort(dlg, 'kernel-driver:executeTellaskCall:TypeC:appendPending');
1719
1674
  const initPrompt = {
1720
- content: (0, inter_dialog_format_1.formatAssignmentFromSupdialog)({
1675
+ content: (0, inter_dialog_format_1.formatAssignmentFromAskerDialog)({
1721
1676
  callName,
1722
1677
  fromAgentId: dlg.agentId,
1723
1678
  toAgentId: sub.agentId,
@@ -1731,10 +1686,11 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1731
1686
  origin: 'runtime',
1732
1687
  tellaskReplyDirective: buildAssignmentReplyDirective({
1733
1688
  callName: 'tellaskSessionless',
1689
+ targetDialogId: dlg.id.selfId,
1734
1690
  targetCallId: callId,
1735
1691
  tellaskContent: body,
1736
1692
  }),
1737
- subdialogReplyTarget: {
1693
+ sideDialogReplyTarget: {
1738
1694
  ownerDialogId: dlg.id.selfId,
1739
1695
  callType: 'C',
1740
1696
  callId,
@@ -1744,13 +1700,20 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1744
1700
  humanPrompt: initPrompt,
1745
1701
  waitInQue: true,
1746
1702
  driveOptions: {
1747
- source: 'kernel_driver_subdialog_init',
1748
- reason: 'type_c_subdialog_init',
1703
+ source: 'kernel_driver_sideDialog_init',
1704
+ reason: 'type_c_sideDialog_init',
1749
1705
  },
1750
1706
  });
1751
1707
  }
1752
1708
  catch (err) {
1753
- log_1.log.warn('Subdialog creation error:', err);
1709
+ log_1.log.error('SideDialog creation error', err, {
1710
+ rootId: dlg.id.rootId,
1711
+ selfId: dlg.id.selfId,
1712
+ callId,
1713
+ callName,
1714
+ targetAgentId: parseResult.agentId,
1715
+ });
1716
+ throw err;
1754
1717
  }
1755
1718
  }
1756
1719
  }
@@ -1764,8 +1727,8 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1764
1727
  callName,
1765
1728
  content: msg,
1766
1729
  status: 'failed',
1767
- originCourse: callingCourse,
1768
- calling_genseq: callingGenseq,
1730
+ callSiteCourse,
1731
+ callSiteGenseq,
1769
1732
  responderId: 'dominds',
1770
1733
  tellaskContent: body,
1771
1734
  mentionList: normalizedMentionList,
@@ -1773,8 +1736,8 @@ async function executeTellaskCall(dlg, mentionList, body, callId, callbacks, opt
1773
1736
  originMemberId: dlg.agentId,
1774
1737
  }));
1775
1738
  await dlg.receiveTellaskCallResult('dominds', callName, mentionList, body, msg, 'failed', callId, {
1776
- originCourse: callingCourse,
1777
- calling_genseq: callingGenseq,
1739
+ callSiteCourse,
1740
+ callSiteGenseq,
1778
1741
  });
1779
1742
  dlg.clearCurrentCallId();
1780
1743
  }
@@ -1791,7 +1754,7 @@ async function emitTellaskCallEvents(args) {
1791
1754
  }
1792
1755
  async function executeReplyTellaskCall(args) {
1793
1756
  const genseq = args.dlg.activeGenSeqOrUndefined ?? 1;
1794
- const activeDirective = args.activePromptReplyDirective ?? (await loadLatestActiveTellaskReplyDirective(args.dlg));
1757
+ const activeDirective = args.activePromptReplyDirective ?? (await loadActiveTellaskReplyDirective(args.dlg));
1795
1758
  const expectedCallName = activeDirective?.expectedReplyCallName;
1796
1759
  if (!expectedCallName) {
1797
1760
  return {
@@ -1833,15 +1796,19 @@ async function executeReplyTellaskCall(args) {
1833
1796
  switch (args.call.callName) {
1834
1797
  case 'replyTellask':
1835
1798
  case 'replyTellaskSessionless': {
1836
- if (!(args.dlg instanceof dialog_1.SubDialog)) {
1837
- throw new Error(`${args.call.callName} invariant violation: only subdialogs may reply upstream`);
1799
+ if (!(args.dlg instanceof dialog_1.SideDialog)) {
1800
+ throw new Error(`${args.call.callName} invariant violation: only sideDialogs may reply to the tellasker`);
1838
1801
  }
1839
- const expectedCallName = args.call.callName === 'replyTellask' ? 'tellask' : 'tellaskSessionless';
1840
- if (args.dlg.assignmentFromSup.callName !== expectedCallName) {
1841
- throw new Error(`${args.call.callName} invariant violation: assignment callName=${args.dlg.assignmentFromSup.callName}`);
1802
+ const assignmentCallName = args.dlg.assignmentFromAsker.callName;
1803
+ const assignmentMatchesReplyCall = args.call.callName === 'replyTellask'
1804
+ ? assignmentCallName === 'tellask'
1805
+ : assignmentCallName === 'tellaskSessionless' ||
1806
+ assignmentCallName === 'freshBootsReasoning';
1807
+ if (!assignmentMatchesReplyCall) {
1808
+ throw new Error(`${args.call.callName} invariant violation: assignment callName=${assignmentCallName}`);
1842
1809
  }
1843
- const supplied = await (0, subdialog_1.supplySubdialogResponseToAssignedCallerIfPendingV2)({
1844
- subdialog: args.dlg,
1810
+ const supplied = await (0, sideDialog_1.supplySideDialogResponseToAssignedAskerIfPendingV2)({
1811
+ sideDialog: args.dlg,
1845
1812
  responseText: args.call.replyContent,
1846
1813
  responseGenseq: genseq,
1847
1814
  replyResolution: {
@@ -1868,6 +1835,11 @@ async function executeReplyTellaskCall(args) {
1868
1835
  ],
1869
1836
  };
1870
1837
  }
1838
+ const nextAskerStackState = await persistence_1.DialogPersistence.loadSideDialogAskerStackState(args.dlg.id, args.dlg.status);
1839
+ if (!nextAskerStackState) {
1840
+ throw new Error(`Missing asker stack after reply delivery: ${args.dlg.id.valueOf()}`);
1841
+ }
1842
+ args.dlg.askerStack = nextAskerStackState;
1871
1843
  return {
1872
1844
  delivered: true,
1873
1845
  messages: [
@@ -1971,6 +1943,13 @@ function toExecutableValidTellaskCall(call) {
1971
1943
  async function executeValidTellaskCalls(args) {
1972
1944
  const results = [];
1973
1945
  const successfulReplyCallIds = [];
1946
+ const deferredScheduleCalls = [];
1947
+ const registrationPhaseCallbacks = {
1948
+ driveDialog: args.callbacks.driveDialog,
1949
+ scheduleDrive: (dialog, options) => {
1950
+ deferredScheduleCalls.push({ dialog, options });
1951
+ },
1952
+ };
1974
1953
  for (const call of args.calls) {
1975
1954
  const runtimeMentionList = (() => {
1976
1955
  switch (call.callName) {
@@ -2002,9 +1981,11 @@ async function executeValidTellaskCalls(args) {
2002
1981
  let parseResult;
2003
1982
  switch (call.callName) {
2004
1983
  case 'tellaskBack': {
2005
- targetForError = args.dlg instanceof dialog_1.SubDialog ? args.dlg.supdialog.agentId : undefined;
1984
+ targetForError = args.dlg instanceof dialog_1.SideDialog ? args.dlg.askerDialog.agentId : undefined;
2006
1985
  parseResult =
2007
- args.dlg instanceof dialog_1.SubDialog ? { type: 'A', agentId: args.dlg.supdialog.agentId } : null;
1986
+ args.dlg instanceof dialog_1.SideDialog
1987
+ ? { type: 'A', agentId: args.dlg.askerDialog.agentId }
1988
+ : null;
2008
1989
  break;
2009
1990
  }
2010
1991
  case 'replyTellask':
@@ -2057,7 +2038,7 @@ async function executeValidTellaskCalls(args) {
2057
2038
  if (isReplyTellaskCallName(call.callName)) {
2058
2039
  throw new Error(`replyTellask* control-flow invariant violation: unexpected call ${call.callName}`);
2059
2040
  }
2060
- const toolOutputs = await executeTellaskCall(args.dlg, runtimeMentionList, call.tellaskContent, call.callId, args.callbacks, {
2041
+ const toolOutputs = await executeTellaskCall(args.dlg, runtimeMentionList, call.tellaskContent, call.callId, registrationPhaseCallbacks, {
2061
2042
  callName: call.callName,
2062
2043
  parseResult,
2063
2044
  targetForError,
@@ -2065,6 +2046,9 @@ async function executeValidTellaskCalls(args) {
2065
2046
  });
2066
2047
  results.push(toolOutputs);
2067
2048
  }
2049
+ for (const scheduled of deferredScheduleCalls) {
2050
+ args.callbacks.scheduleDrive(scheduled.dialog, scheduled.options);
2051
+ }
2068
2052
  return {
2069
2053
  toolOutputs: results.flatMap((result) => result),
2070
2054
  successfulReplyCallIds,
@@ -2100,11 +2084,11 @@ async function processTellaskFunctionRound(args) {
2100
2084
  if (multiAskHumanCalls.length > 1 && originalCall.name === 'askHuman') {
2101
2085
  orderedSpecialDispositions.push({
2102
2086
  kind: 'invalid',
2087
+ callName: originalCall.name,
2103
2088
  issue: {
2104
2089
  originalCall,
2105
2090
  error: MULTIPLE_ASKHUMAN_CALLS_ERROR,
2106
2091
  rawArgumentsText: getRawArgumentsText(originalCall),
2107
- contextArguments: getRawArgumentsText(originalCall),
2108
2092
  },
2109
2093
  });
2110
2094
  continue;
@@ -2116,7 +2100,7 @@ async function processTellaskFunctionRound(args) {
2116
2100
  }
2117
2101
  const issue = invalidByCallId.get(originalCall.id);
2118
2102
  if (issue) {
2119
- orderedSpecialDispositions.push({ kind: 'invalid', issue });
2103
+ orderedSpecialDispositions.push({ kind: 'invalid', callName: originalCall.name, issue });
2120
2104
  continue;
2121
2105
  }
2122
2106
  throw new Error(`kernel-driver tellask special call invariant violation: unresolved tellask disposition for '${originalCall.id}' (${originalCall.name})`);
@@ -2146,19 +2130,12 @@ async function processTellaskFunctionRound(args) {
2146
2130
  continue;
2147
2131
  }
2148
2132
  const issue = disposition.issue;
2149
- await args.dlg.funcCallRequested(issue.originalCall.id, issue.originalCall.name, issue.contextArguments);
2133
+ await args.dlg.persistTellaskCall(issue.originalCall.id, disposition.callName, issue.rawArgumentsText, issue.originalCall.genseq, { deliveryMode: 'func_call_requested' });
2150
2134
  const result = formatTellaskInvalidCallResult({
2151
2135
  call: issue.originalCall,
2152
2136
  error: issue.error,
2153
2137
  });
2154
- await args.dlg.persistTellaskCallResultPair({
2155
- id: issue.originalCall.id,
2156
- name: issue.originalCall.name,
2157
- rawArgumentsText: issue.rawArgumentsText,
2158
- genseq: issue.originalCall.genseq,
2159
- result,
2160
- deliveryMode: 'func_call_requested',
2161
- });
2138
+ await persistTellaskFuncResult(args.dlg, result);
2162
2139
  tellaskCallMessages.push({
2163
2140
  type: 'func_call_msg',
2164
2141
  role: 'assistant',