dominds 1.24.2 → 1.24.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/apps/runtime.js +0 -3
  2. package/dist/dialog-display-state.js +4 -2
  3. package/dist/dialog-global-registry.d.ts +15 -1
  4. package/dist/dialog-global-registry.js +73 -5
  5. package/dist/dialog.d.ts +3 -3
  6. package/dist/dialog.js +4 -2
  7. package/dist/docs/tellask-background-continuation-refactor.zh.md +144 -15
  8. package/dist/llm/gen/mock.js +2 -0
  9. package/dist/llm/kernel-driver/drive.js +84 -16
  10. package/dist/llm/kernel-driver/flow.js +375 -100
  11. package/dist/llm/kernel-driver/loop.js +85 -46
  12. package/dist/llm/kernel-driver/reply-guidance.js +0 -3
  13. package/dist/llm/kernel-driver/tellask-special.d.ts +1 -0
  14. package/dist/llm/kernel-driver/tellask-special.js +3 -0
  15. package/dist/llm/kernel-driver/types.d.ts +10 -5
  16. package/dist/persistence.d.ts +30 -1
  17. package/dist/persistence.js +186 -4
  18. package/dist/runtime/driver-messages.d.ts +1 -0
  19. package/dist/runtime/driver-messages.js +7 -2
  20. package/dist/server/websocket-handler.d.ts +14 -0
  21. package/dist/server/websocket-handler.js +42 -3
  22. package/package.json +4 -4
  23. package/webapp/dist/assets/{_basePickBy-DBvh4H3k.js → _basePickBy-ZLV93S3E.js} +3 -3
  24. package/webapp/dist/assets/{_basePickBy-DBvh4H3k.js.map → _basePickBy-ZLV93S3E.js.map} +1 -1
  25. package/webapp/dist/assets/{_baseUniq-CQmc9B-o.js → _baseUniq-D0wSOJ06.js} +2 -2
  26. package/webapp/dist/assets/{_baseUniq-CQmc9B-o.js.map → _baseUniq-D0wSOJ06.js.map} +1 -1
  27. package/webapp/dist/assets/{arc-DfLiOX_4.js → arc-BHclbMTS.js} +2 -2
  28. package/webapp/dist/assets/{arc-DfLiOX_4.js.map → arc-BHclbMTS.js.map} +1 -1
  29. package/webapp/dist/assets/{architectureDiagram-2XIMDMQ5-CaTVJ5ev.js → architectureDiagram-2XIMDMQ5-CK99gE_D.js} +7 -7
  30. package/webapp/dist/assets/{architectureDiagram-2XIMDMQ5-CaTVJ5ev.js.map → architectureDiagram-2XIMDMQ5-CK99gE_D.js.map} +1 -1
  31. package/webapp/dist/assets/{blockDiagram-WCTKOSBZ-DlmAtUca.js → blockDiagram-WCTKOSBZ-fE5MBTEU.js} +7 -7
  32. package/webapp/dist/assets/{blockDiagram-WCTKOSBZ-DlmAtUca.js.map → blockDiagram-WCTKOSBZ-fE5MBTEU.js.map} +1 -1
  33. package/webapp/dist/assets/{c4Diagram-IC4MRINW-CNHKD5Sl.js → c4Diagram-IC4MRINW-BSLyPyoU.js} +3 -3
  34. package/webapp/dist/assets/{c4Diagram-IC4MRINW-CNHKD5Sl.js.map → c4Diagram-IC4MRINW-BSLyPyoU.js.map} +1 -1
  35. package/webapp/dist/assets/{channel-BTWhZYd5.js → channel-DSvMpp-a.js} +2 -2
  36. package/webapp/dist/assets/{channel-BTWhZYd5.js.map → channel-DSvMpp-a.js.map} +1 -1
  37. package/webapp/dist/assets/{chunk-4BX2VUAB-CV1n0Uhy.js → chunk-4BX2VUAB-OXEX170k.js} +2 -2
  38. package/webapp/dist/assets/{chunk-4BX2VUAB-CV1n0Uhy.js.map → chunk-4BX2VUAB-OXEX170k.js.map} +1 -1
  39. package/webapp/dist/assets/{chunk-55IACEB6-C5r77i_p.js → chunk-55IACEB6-BFQ_spQD.js} +2 -2
  40. package/webapp/dist/assets/{chunk-55IACEB6-C5r77i_p.js.map → chunk-55IACEB6-BFQ_spQD.js.map} +1 -1
  41. package/webapp/dist/assets/{chunk-FMBD7UC4-DJ1yHxrH.js → chunk-FMBD7UC4-CbQ2BBPs.js} +2 -2
  42. package/webapp/dist/assets/{chunk-FMBD7UC4-DJ1yHxrH.js.map → chunk-FMBD7UC4-CbQ2BBPs.js.map} +1 -1
  43. package/webapp/dist/assets/{chunk-JSJVCQXG-Ahg9hCCm.js → chunk-JSJVCQXG-C4P1mjCL.js} +2 -2
  44. package/webapp/dist/assets/{chunk-JSJVCQXG-Ahg9hCCm.js.map → chunk-JSJVCQXG-C4P1mjCL.js.map} +1 -1
  45. package/webapp/dist/assets/{chunk-KX2RTZJC-qBrewKt0.js → chunk-KX2RTZJC-BMd-daMY.js} +2 -2
  46. package/webapp/dist/assets/{chunk-KX2RTZJC-qBrewKt0.js.map → chunk-KX2RTZJC-BMd-daMY.js.map} +1 -1
  47. package/webapp/dist/assets/{chunk-NQ4KR5QH-1lEdM6Wi.js → chunk-NQ4KR5QH-B_ZhWMXR.js} +4 -4
  48. package/webapp/dist/assets/{chunk-NQ4KR5QH-1lEdM6Wi.js.map → chunk-NQ4KR5QH-B_ZhWMXR.js.map} +1 -1
  49. package/webapp/dist/assets/{chunk-QZHKN3VN-ChVR749G.js → chunk-QZHKN3VN-Cbf92xIw.js} +2 -2
  50. package/webapp/dist/assets/{chunk-QZHKN3VN-ChVR749G.js.map → chunk-QZHKN3VN-Cbf92xIw.js.map} +1 -1
  51. package/webapp/dist/assets/{chunk-WL4C6EOR-BAUXgk0K.js → chunk-WL4C6EOR-PtH-blkK.js} +6 -6
  52. package/webapp/dist/assets/{chunk-WL4C6EOR-BAUXgk0K.js.map → chunk-WL4C6EOR-PtH-blkK.js.map} +1 -1
  53. package/webapp/dist/assets/{classDiagram-VBA2DB6C-DlqyhKve.js → classDiagram-VBA2DB6C-Dc3ncaD0.js} +7 -7
  54. package/webapp/dist/assets/{classDiagram-VBA2DB6C-DlqyhKve.js.map → classDiagram-VBA2DB6C-Dc3ncaD0.js.map} +1 -1
  55. package/webapp/dist/assets/{classDiagram-v2-RAHNMMFH-DlqyhKve.js → classDiagram-v2-RAHNMMFH-Dc3ncaD0.js} +7 -7
  56. package/webapp/dist/assets/{classDiagram-v2-RAHNMMFH-DlqyhKve.js.map → classDiagram-v2-RAHNMMFH-Dc3ncaD0.js.map} +1 -1
  57. package/webapp/dist/assets/{clone-BFiIqUsc.js → clone-E9Ad85BC.js} +2 -2
  58. package/webapp/dist/assets/{clone-BFiIqUsc.js.map → clone-E9Ad85BC.js.map} +1 -1
  59. package/webapp/dist/assets/{cose-bilkent-S5V4N54A-JYvhtd6J.js → cose-bilkent-S5V4N54A-B-nj0o74.js} +2 -2
  60. package/webapp/dist/assets/{cose-bilkent-S5V4N54A-JYvhtd6J.js.map → cose-bilkent-S5V4N54A-B-nj0o74.js.map} +1 -1
  61. package/webapp/dist/assets/{dagre-KLK3FWXG-CCGcQh6w.js → dagre-KLK3FWXG-CyJYNIbm.js} +7 -7
  62. package/webapp/dist/assets/{dagre-KLK3FWXG-CCGcQh6w.js.map → dagre-KLK3FWXG-CyJYNIbm.js.map} +1 -1
  63. package/webapp/dist/assets/{diagram-E7M64L7V-BXC4AxAd.js → diagram-E7M64L7V-C8eweQ7b.js} +8 -8
  64. package/webapp/dist/assets/{diagram-E7M64L7V-BXC4AxAd.js.map → diagram-E7M64L7V-C8eweQ7b.js.map} +1 -1
  65. package/webapp/dist/assets/{diagram-IFDJBPK2-B--Sb3XT.js → diagram-IFDJBPK2-DMdygRl0.js} +7 -7
  66. package/webapp/dist/assets/{diagram-IFDJBPK2-B--Sb3XT.js.map → diagram-IFDJBPK2-DMdygRl0.js.map} +1 -1
  67. package/webapp/dist/assets/{diagram-P4PSJMXO-CVqgtrh3.js → diagram-P4PSJMXO-BQDZHb0a.js} +7 -7
  68. package/webapp/dist/assets/{diagram-P4PSJMXO-CVqgtrh3.js.map → diagram-P4PSJMXO-BQDZHb0a.js.map} +1 -1
  69. package/webapp/dist/assets/{erDiagram-INFDFZHY-BniHaRTt.js → erDiagram-INFDFZHY-C1HaXN6E.js} +5 -5
  70. package/webapp/dist/assets/{erDiagram-INFDFZHY-BniHaRTt.js.map → erDiagram-INFDFZHY-C1HaXN6E.js.map} +1 -1
  71. package/webapp/dist/assets/{flowDiagram-PKNHOUZH-wLKFBWTR.js → flowDiagram-PKNHOUZH-24nNqQyo.js} +7 -7
  72. package/webapp/dist/assets/{flowDiagram-PKNHOUZH-wLKFBWTR.js.map → flowDiagram-PKNHOUZH-24nNqQyo.js.map} +1 -1
  73. package/webapp/dist/assets/{ganttDiagram-A5KZAMGK-DrptcitZ.js → ganttDiagram-A5KZAMGK-BWPOFaLV.js} +3 -3
  74. package/webapp/dist/assets/{ganttDiagram-A5KZAMGK-DrptcitZ.js.map → ganttDiagram-A5KZAMGK-BWPOFaLV.js.map} +1 -1
  75. package/webapp/dist/assets/{gitGraphDiagram-K3NZZRJ6-C6l5aP44.js → gitGraphDiagram-K3NZZRJ6-D7_L-p_Y.js} +8 -8
  76. package/webapp/dist/assets/{gitGraphDiagram-K3NZZRJ6-C6l5aP44.js.map → gitGraphDiagram-K3NZZRJ6-D7_L-p_Y.js.map} +1 -1
  77. package/webapp/dist/assets/{graph-DXuQGYQN.js → graph-OHu4dL2n.js} +3 -3
  78. package/webapp/dist/assets/{graph-DXuQGYQN.js.map → graph-OHu4dL2n.js.map} +1 -1
  79. package/webapp/dist/assets/{index-DuQ1OCMG.js → index-CDCDAfqP.js} +165 -67
  80. package/webapp/dist/assets/{index-DuQ1OCMG.js.map → index-CDCDAfqP.js.map} +1 -1
  81. package/webapp/dist/assets/{infoDiagram-LFFYTUFH-BbleCSjW.js → infoDiagram-LFFYTUFH-CvaBM5j6.js} +6 -6
  82. package/webapp/dist/assets/{infoDiagram-LFFYTUFH-BbleCSjW.js.map → infoDiagram-LFFYTUFH-CvaBM5j6.js.map} +1 -1
  83. package/webapp/dist/assets/{ishikawaDiagram-PHBUUO56-DmV-LZuk.js → ishikawaDiagram-PHBUUO56-DB1l2Uue.js} +2 -2
  84. package/webapp/dist/assets/{ishikawaDiagram-PHBUUO56-DmV-LZuk.js.map → ishikawaDiagram-PHBUUO56-DB1l2Uue.js.map} +1 -1
  85. package/webapp/dist/assets/{journeyDiagram-4ABVD52K-D3sQFfac.js → journeyDiagram-4ABVD52K-TQR6_teO.js} +5 -5
  86. package/webapp/dist/assets/{journeyDiagram-4ABVD52K-D3sQFfac.js.map → journeyDiagram-4ABVD52K-TQR6_teO.js.map} +1 -1
  87. package/webapp/dist/assets/{kanban-definition-K7BYSVSG-BEeBlBtM.js → kanban-definition-K7BYSVSG-B-BOuC-U.js} +3 -3
  88. package/webapp/dist/assets/{kanban-definition-K7BYSVSG-BEeBlBtM.js.map → kanban-definition-K7BYSVSG-B-BOuC-U.js.map} +1 -1
  89. package/webapp/dist/assets/{layout-g7jjgV-W.js → layout-B8yqIqbx.js} +5 -5
  90. package/webapp/dist/assets/{layout-g7jjgV-W.js.map → layout-B8yqIqbx.js.map} +1 -1
  91. package/webapp/dist/assets/{linear-D_X91Yek.js → linear-CoLfiZKK.js} +2 -2
  92. package/webapp/dist/assets/{linear-D_X91Yek.js.map → linear-CoLfiZKK.js.map} +1 -1
  93. package/webapp/dist/assets/{mindmap-definition-YRQLILUH-NkMAIgRY.js → mindmap-definition-YRQLILUH-P70BMIHI.js} +4 -4
  94. package/webapp/dist/assets/{mindmap-definition-YRQLILUH-NkMAIgRY.js.map → mindmap-definition-YRQLILUH-P70BMIHI.js.map} +1 -1
  95. package/webapp/dist/assets/{pieDiagram-SKSYHLDU-Z6E4GEPC.js → pieDiagram-SKSYHLDU-DsS_4dTB.js} +8 -8
  96. package/webapp/dist/assets/{pieDiagram-SKSYHLDU-Z6E4GEPC.js.map → pieDiagram-SKSYHLDU-DsS_4dTB.js.map} +1 -1
  97. package/webapp/dist/assets/{quadrantDiagram-337W2JSQ-BH8hfOuU.js → quadrantDiagram-337W2JSQ-DoM9PEq-.js} +3 -3
  98. package/webapp/dist/assets/{quadrantDiagram-337W2JSQ-BH8hfOuU.js.map → quadrantDiagram-337W2JSQ-DoM9PEq-.js.map} +1 -1
  99. package/webapp/dist/assets/{requirementDiagram-Z7DCOOCP-DRJkvoQI.js → requirementDiagram-Z7DCOOCP-Bn3lYMMI.js} +4 -4
  100. package/webapp/dist/assets/{requirementDiagram-Z7DCOOCP-DRJkvoQI.js.map → requirementDiagram-Z7DCOOCP-Bn3lYMMI.js.map} +1 -1
  101. package/webapp/dist/assets/{sankeyDiagram-WA2Y5GQK-D2VwjtJo.js → sankeyDiagram-WA2Y5GQK-97kCegRT.js} +2 -2
  102. package/webapp/dist/assets/{sankeyDiagram-WA2Y5GQK-D2VwjtJo.js.map → sankeyDiagram-WA2Y5GQK-97kCegRT.js.map} +1 -1
  103. package/webapp/dist/assets/{sequenceDiagram-2WXFIKYE-Cq-gEPOw.js → sequenceDiagram-2WXFIKYE-DXqjQjf6.js} +4 -4
  104. package/webapp/dist/assets/{sequenceDiagram-2WXFIKYE-Cq-gEPOw.js.map → sequenceDiagram-2WXFIKYE-DXqjQjf6.js.map} +1 -1
  105. package/webapp/dist/assets/{stateDiagram-RAJIS63D-CFM8Jqke.js → stateDiagram-RAJIS63D-DQcTPKWP.js} +9 -9
  106. package/webapp/dist/assets/{stateDiagram-RAJIS63D-CFM8Jqke.js.map → stateDiagram-RAJIS63D-DQcTPKWP.js.map} +1 -1
  107. package/webapp/dist/assets/{stateDiagram-v2-FVOUBMTO-Dip5iGX_.js → stateDiagram-v2-FVOUBMTO-DHmxRVJn.js} +5 -5
  108. package/webapp/dist/assets/{stateDiagram-v2-FVOUBMTO-Dip5iGX_.js.map → stateDiagram-v2-FVOUBMTO-DHmxRVJn.js.map} +1 -1
  109. package/webapp/dist/assets/{timeline-definition-YZTLITO2-OI9JzMjX.js → timeline-definition-YZTLITO2-BlovQQ4B.js} +3 -3
  110. package/webapp/dist/assets/{timeline-definition-YZTLITO2-OI9JzMjX.js.map → timeline-definition-YZTLITO2-BlovQQ4B.js.map} +1 -1
  111. package/webapp/dist/assets/{treemap-KZPCXAKY-CtNF416A.js → treemap-KZPCXAKY-CGu93c9S.js} +5 -5
  112. package/webapp/dist/assets/{treemap-KZPCXAKY-CtNF416A.js.map → treemap-KZPCXAKY-CGu93c9S.js.map} +1 -1
  113. package/webapp/dist/assets/{vennDiagram-LZ73GAT5-CjaPj4FZ.js → vennDiagram-LZ73GAT5-Do1jprrz.js} +2 -2
  114. package/webapp/dist/assets/{vennDiagram-LZ73GAT5-CjaPj4FZ.js.map → vennDiagram-LZ73GAT5-Do1jprrz.js.map} +1 -1
  115. package/webapp/dist/assets/{xychartDiagram-JWTSCODW-21mBt9iu.js → xychartDiagram-JWTSCODW-BKa1DxVq.js} +3 -3
  116. package/webapp/dist/assets/{xychartDiagram-JWTSCODW-21mBt9iu.js.map → xychartDiagram-JWTSCODW-BKa1DxVq.js.map} +1 -1
  117. package/webapp/dist/index.html +1 -1
@@ -70,6 +70,125 @@ async function queueReplyReminderFollowUp(args) {
70
70
  function isReplyToolReminderPrompt(prompt) {
71
71
  return typeof prompt?.content === 'string' && (0, reply_prompt_copy_1.isReplyToolReminderPromptContent)(prompt.content);
72
72
  }
73
+ function hasSameReplyDirective(left, right) {
74
+ return (left.expectedReplyCallName === right.expectedReplyCallName &&
75
+ left.targetDialogId === right.targetDialogId &&
76
+ left.targetCallId === right.targetCallId &&
77
+ left.tellaskContent === right.tellaskContent);
78
+ }
79
+ function buildCurrentSideDialogAssignmentReplyDirective(dialog) {
80
+ switch (dialog.assignmentFromAsker.callName) {
81
+ case 'tellask':
82
+ return {
83
+ expectedReplyCallName: 'replyTellask',
84
+ targetDialogId: dialog.assignmentFromAsker.askerDialogId,
85
+ targetCallId: dialog.assignmentFromAsker.callId,
86
+ tellaskContent: dialog.assignmentFromAsker.tellaskContent,
87
+ };
88
+ case 'tellaskSessionless':
89
+ case 'freshBootsReasoning':
90
+ return {
91
+ expectedReplyCallName: 'replyTellaskSessionless',
92
+ targetDialogId: dialog.assignmentFromAsker.askerDialogId,
93
+ targetCallId: dialog.assignmentFromAsker.callId,
94
+ tellaskContent: dialog.assignmentFromAsker.tellaskContent,
95
+ };
96
+ default: {
97
+ const _exhaustive = dialog.assignmentFromAsker.callName;
98
+ throw new Error(`Unsupported sideDialog assignment callName: ${_exhaustive}`);
99
+ }
100
+ }
101
+ }
102
+ function isQueuedReplyObligationContinuation(prompt) {
103
+ return ((prompt.kind === 'new_course_runtime_reply' ||
104
+ prompt.kind === 'new_course_runtime_sideDialog') &&
105
+ (0, reply_prompt_copy_1.isReplyToolReminderPromptContent)(prompt.prompt));
106
+ }
107
+ function latestHasTellaskResultForCallId(latest, targetCallId) {
108
+ return (latest?.tellaskResults.results.some((entry) => entry.callId.trim() === targetCallId) === true);
109
+ }
110
+ async function claimQueuedReplyObligationContinuation(args) {
111
+ const directive = args.prompt.tellaskReplyDirective;
112
+ const targetCallId = directive.targetCallId.trim();
113
+ const targetDialogId = directive.targetDialogId.trim();
114
+ if (targetCallId === '' || targetDialogId === '') {
115
+ throw new Error(`reply obligation continuation invariant violation: empty target identity ` +
116
+ `(dialog=${args.dialog.id.valueOf()}, targetDialogId=${directive.targetDialogId}, targetCallId=${directive.targetCallId})`);
117
+ }
118
+ const latest = await persistence_1.DialogPersistence.loadDialogLatest(args.dialog.id, args.dialog.status);
119
+ if (latest?.sideDialogFinalResponse?.callId.trim() === targetCallId) {
120
+ return 'stale';
121
+ }
122
+ if (latestHasTellaskResultForCallId(latest, targetCallId)) {
123
+ return 'stale';
124
+ }
125
+ const targetLatest = targetDialogId === args.dialog.id.selfId
126
+ ? latest
127
+ : await persistence_1.DialogPersistence.loadDialogLatest(new dialog_1.DialogID(targetDialogId, args.dialog.id.rootId), args.dialog.status);
128
+ if (latestHasTellaskResultForCallId(targetLatest, targetCallId)) {
129
+ return 'stale';
130
+ }
131
+ if (args.dialog instanceof dialog_1.SideDialog) {
132
+ const assignmentDirective = buildCurrentSideDialogAssignmentReplyDirective(args.dialog);
133
+ if (hasSameReplyDirective(assignmentDirective, directive)) {
134
+ return 'claimed';
135
+ }
136
+ }
137
+ const activeDirective = await (0, tellask_special_1.loadActiveTellaskReplyDirective)(args.dialog);
138
+ if (!activeDirective) {
139
+ return 'stale';
140
+ }
141
+ if (activeDirective.targetCallId !== directive.targetCallId) {
142
+ return 'stale';
143
+ }
144
+ if (!hasSameReplyDirective(activeDirective, directive)) {
145
+ throw new Error(`reply obligation continuation invariant violation: active obligation changed for callId=${directive.targetCallId} ` +
146
+ `(dialog=${args.dialog.id.valueOf()}, expectedReplyCallName=${directive.expectedReplyCallName}, ` +
147
+ `activeReplyCallName=${activeDirective.expectedReplyCallName}, targetDialogId=${directive.targetDialogId}, ` +
148
+ `activeTargetDialogId=${activeDirective.targetDialogId})`);
149
+ }
150
+ return 'claimed';
151
+ }
152
+ async function resolveSideDialogReplyDirectiveForAssistantOutput(args) {
153
+ const replyTarget = args.replyTarget;
154
+ const targetCallId = replyTarget?.callId.trim();
155
+ if (!replyTarget || !targetCallId) {
156
+ return args.currentDirective;
157
+ }
158
+ if (args.currentDirective?.targetCallId === targetCallId) {
159
+ return args.currentDirective;
160
+ }
161
+ const latest = await persistence_1.DialogPersistence.loadDialogLatest(args.dialog.id, args.dialog.status);
162
+ if (!latest) {
163
+ return args.currentDirective;
164
+ }
165
+ if (latest.sideDialogFinalResponse?.callId.trim() === targetCallId) {
166
+ return args.currentDirective;
167
+ }
168
+ if (latestHasTellaskResultForCallId(latest, targetCallId)) {
169
+ return args.currentDirective;
170
+ }
171
+ const assignmentDirective = buildCurrentSideDialogAssignmentReplyDirective(args.dialog);
172
+ if (assignmentDirective.targetCallId !== targetCallId) {
173
+ return args.currentDirective;
174
+ }
175
+ if (assignmentDirective.targetDialogId !== replyTarget.callerDialogId ||
176
+ assignmentDirective.targetCallId !== replyTarget.callId) {
177
+ return args.currentDirective;
178
+ }
179
+ const latestAssignmentAnchor = latest.latestAssignmentAnchor;
180
+ if (latestAssignmentAnchor?.callId !== targetCallId ||
181
+ args.responseGenseq < latestAssignmentAnchor.assignmentGenseq) {
182
+ return args.currentDirective;
183
+ }
184
+ const activeDirective = await (0, tellask_special_1.loadActiveTellaskReplyDirective)(args.dialog);
185
+ if (activeDirective && !hasSameReplyDirective(activeDirective, assignmentDirective)) {
186
+ throw new Error(`sideDialog assistant output reply directive invariant violation: active obligation does not match latest assignment ` +
187
+ `(dialog=${args.dialog.id.valueOf()}, targetCallId=${targetCallId}, ` +
188
+ `activeTargetCallId=${activeDirective.targetCallId}, assignmentTargetCallId=${assignmentDirective.targetCallId})`);
189
+ }
190
+ return activeDirective ?? assignmentDirective;
191
+ }
73
192
  function hasQ4HAnswerCallId(callId) {
74
193
  return typeof callId === 'string' && callId.trim() !== '';
75
194
  }
@@ -294,16 +413,12 @@ async function clearStaleSideDialogRunControlForFinalResponse(args) {
294
413
  previousNextStepTriggerCount: latest.nextStep.triggers.length,
295
414
  };
296
415
  }
297
- function hasNoPromptSideDialogResumeEntitlement(dialog, driveOptions) {
298
- const entitlement = driveOptions?.noPromptSideDialogResumeEntitlement;
299
- if (!entitlement) {
300
- return false;
301
- }
302
- return entitlement.callerDialogId === dialog.id.selfId;
303
- }
304
416
  function hasResultArrivalTrigger(latest) {
305
417
  return latest?.nextStep.triggers.some((trigger) => trigger.kind === 'result_arrival') === true;
306
418
  }
419
+ function hasFollowupNextAction(latest) {
420
+ return latest?.nextStep.triggers.some((trigger) => trigger.kind === 'followup') === true;
421
+ }
307
422
  function hasCallerReviveEntitlement(dialog, driveOptions) {
308
423
  const entitlement = driveOptions?.noPromptSideDialogResumeEntitlement;
309
424
  if (!entitlement) {
@@ -415,13 +530,11 @@ async function inspectNoPromptSideDialogDrive(args) {
415
530
  (0, dialog_drive_work_1.hasRecoverableGenerationBeyondFinalResponse)(latest);
416
531
  const resolvedPendingSideDialogReplyEntitlement = hasResolvedPendingSideDialogReplyEntitlement(args.dialog, args.driveOptions);
417
532
  const resultArrivalTriggerPresent = hasResultArrivalTrigger(latest);
533
+ const followupNextActionPresent = hasFollowupNextAction(latest);
418
534
  const supplyResponseCallerReviveAllowed = hasCallerReviveEntitlement(args.dialog, args.driveOptions) &&
419
535
  (!resolvedPendingSideDialogReplyEntitlement || resultArrivalTriggerPresent);
420
- const backendLoopDurableWorkAllowed = source === 'kernel_driver_backend_loop' && resultArrivalTriggerPresent;
421
- const replyObligationFollowUpAllowed = source === 'kernel_driver_follow_up' &&
422
- args.driveOptions?.noPromptSideDialogResumeEntitlement?.reason ===
423
- 'reply_obligation_follow_up' &&
424
- hasNoPromptSideDialogResumeEntitlement(args.dialog, args.driveOptions);
536
+ const backendLoopDurableWorkAllowed = source === 'kernel_driver_backend_loop' &&
537
+ (resultArrivalTriggerPresent || followupNextActionPresent);
425
538
  const finalResponseResultArrivalReviveAllowed = sideDialogFinalResponseCallId !== undefined &&
426
539
  ((resolvedPendingSideDialogReplyEntitlement && resultArrivalTriggerPresent) ||
427
540
  backendLoopDurableWorkAllowed ||
@@ -436,11 +549,20 @@ async function inspectNoPromptSideDialogDrive(args) {
436
549
  sideDialogFinalResponseCallId,
437
550
  };
438
551
  }
552
+ if (resolvedPendingSideDialogReplyEntitlement && !resultArrivalTriggerPresent) {
553
+ return {
554
+ shouldReject: true,
555
+ source,
556
+ rejection: 'stale_consumed_result_arrival',
557
+ displayState,
558
+ currentCourse,
559
+ sideDialogFinalResponseCallId,
560
+ };
561
+ }
439
562
  if (!explicitInterruptedResumeAllowed &&
440
563
  !inProgressGenerationResumeAllowed &&
441
564
  !supplyResponseCallerReviveAllowed &&
442
- !backendLoopDurableWorkAllowed &&
443
- !replyObligationFollowUpAllowed) {
565
+ !backendLoopDurableWorkAllowed) {
444
566
  return {
445
567
  shouldReject: true,
446
568
  source,
@@ -544,71 +666,96 @@ async function surfaceRuntimeGuide(dialog, content) {
544
666
  }
545
667
  async function resolveEffectivePrompt(dialog, humanPrompt) {
546
668
  if (humanPrompt) {
547
- return { prompt: humanPrompt, fromUpNext: false };
669
+ return { prompt: humanPrompt, fromUpNext: false, droppedStaleQueuedContinuation: false };
548
670
  }
549
- const upNext = dialog.peekUpNext();
550
- if (!upNext) {
551
- return {
552
- prompt: await maybeResolveDeferredReplyReassertionPrompt(dialog),
553
- fromUpNext: false,
554
- };
555
- }
556
- return {
557
- fromUpNext: true,
558
- prompt: (() => {
559
- const normalizedUserLanguageCode = upNext.userLanguageCode === 'zh' || upNext.userLanguageCode === 'en'
560
- ? upNext.userLanguageCode
561
- : undefined;
562
- const common = {
563
- content: upNext.prompt,
564
- msgId: upNext.msgId,
565
- grammar: upNext.grammar ?? 'markdown',
566
- userLanguageCode: normalizedUserLanguageCode,
567
- runControl: upNext.runControl,
671
+ let droppedStaleQueuedContinuation = false;
672
+ for (;;) {
673
+ const upNext = dialog.peekUpNext();
674
+ if (!upNext) {
675
+ return {
676
+ prompt: await maybeResolveDeferredReplyReassertionPrompt(dialog),
677
+ fromUpNext: false,
678
+ droppedStaleQueuedContinuation,
568
679
  };
569
- switch (upNext.kind) {
570
- case 'user_generation_boundary':
571
- case 'deferred_q4h_answer': {
572
- const prompt = {
573
- ...common,
574
- origin: 'user',
575
- ...(upNext.q4hAnswerCallId === undefined
576
- ? {}
577
- : { q4hAnswerCallId: upNext.q4hAnswerCallId }),
578
- };
579
- return prompt;
680
+ }
681
+ if (isQueuedReplyObligationContinuation(upNext)) {
682
+ const claim = await claimQueuedReplyObligationContinuation({ dialog, prompt: upNext });
683
+ if (claim === 'stale') {
684
+ const discarded = dialog.takeUpNext();
685
+ if (!discarded || discarded.msgId !== upNext.msgId) {
686
+ throw new Error(`reply obligation continuation invariant violation: expected queued prompt ${upNext.msgId} before stale discard`);
580
687
  }
581
- case 'registered_assignment_update':
582
- case 'new_course_runtime_guide':
583
- case 'new_course_runtime_reply':
584
- case 'new_course_runtime_sideDialog': {
585
- const runtimeCommon = {
586
- ...common,
587
- origin: 'runtime',
588
- ...(upNext.skipTaskdoc === undefined ? {} : { skipTaskdoc: upNext.skipTaskdoc }),
589
- };
590
- if (upNext.kind === 'registered_assignment_update' ||
591
- upNext.kind === 'new_course_runtime_sideDialog') {
688
+ await persistence_1.DialogPersistence.clearPendingRuntimePrompt(dialog.id, upNext.msgId, dialog.status);
689
+ log_1.log.debug('kernel-driver dropped stale reply obligation continuation', undefined, {
690
+ dialogId: dialog.id.valueOf(),
691
+ rootId: dialog.id.rootId,
692
+ selfId: dialog.id.selfId,
693
+ msgId: upNext.msgId,
694
+ targetCallId: upNext.tellaskReplyDirective.targetCallId,
695
+ expectedReplyCallName: upNext.tellaskReplyDirective.expectedReplyCallName,
696
+ });
697
+ droppedStaleQueuedContinuation = true;
698
+ continue;
699
+ }
700
+ }
701
+ return {
702
+ fromUpNext: true,
703
+ droppedStaleQueuedContinuation,
704
+ prompt: (() => {
705
+ const normalizedUserLanguageCode = upNext.userLanguageCode === 'zh' || upNext.userLanguageCode === 'en'
706
+ ? upNext.userLanguageCode
707
+ : undefined;
708
+ const common = {
709
+ content: upNext.prompt,
710
+ msgId: upNext.msgId,
711
+ grammar: upNext.grammar ?? 'markdown',
712
+ userLanguageCode: normalizedUserLanguageCode,
713
+ runControl: upNext.runControl,
714
+ };
715
+ switch (upNext.kind) {
716
+ case 'user_generation_boundary':
717
+ case 'deferred_q4h_answer': {
592
718
  const prompt = {
593
- ...runtimeCommon,
594
- tellaskReplyDirective: upNext.tellaskReplyDirective,
595
- calleeDialogReplyTarget: upNext.calleeDialogReplyTarget,
719
+ ...common,
720
+ origin: 'user',
721
+ ...(upNext.q4hAnswerCallId === undefined
722
+ ? {}
723
+ : { q4hAnswerCallId: upNext.q4hAnswerCallId }),
596
724
  };
597
725
  return prompt;
598
726
  }
599
- if (upNext.kind === 'new_course_runtime_reply') {
600
- const prompt = {
601
- ...runtimeCommon,
602
- tellaskReplyDirective: upNext.tellaskReplyDirective,
727
+ case 'registered_assignment_update':
728
+ case 'new_course_runtime_guide':
729
+ case 'new_course_runtime_reply':
730
+ case 'new_course_runtime_sideDialog': {
731
+ const runtimeCommon = {
732
+ ...common,
733
+ origin: 'runtime',
734
+ ...(upNext.skipTaskdoc === undefined ? {} : { skipTaskdoc: upNext.skipTaskdoc }),
603
735
  };
736
+ if (upNext.kind === 'registered_assignment_update' ||
737
+ upNext.kind === 'new_course_runtime_sideDialog') {
738
+ const prompt = {
739
+ ...runtimeCommon,
740
+ tellaskReplyDirective: upNext.tellaskReplyDirective,
741
+ calleeDialogReplyTarget: upNext.calleeDialogReplyTarget,
742
+ };
743
+ return prompt;
744
+ }
745
+ if (upNext.kind === 'new_course_runtime_reply') {
746
+ const prompt = {
747
+ ...runtimeCommon,
748
+ tellaskReplyDirective: upNext.tellaskReplyDirective,
749
+ };
750
+ return prompt;
751
+ }
752
+ const prompt = runtimeCommon;
604
753
  return prompt;
605
754
  }
606
- const prompt = runtimeCommon;
607
- return prompt;
608
755
  }
609
- }
610
- })(),
611
- };
756
+ })(),
757
+ };
758
+ }
612
759
  }
613
760
  async function executeDriveRound(args) {
614
761
  const [dialog, humanPrompt, waitInQue, driveOptions] = args.driveArgs;
@@ -623,8 +770,38 @@ async function executeDriveRound(args) {
623
770
  let shouldRefreshDisplayStateAfterActiveRunCleared = false;
624
771
  let followUp;
625
772
  let driveResult;
626
- let calleeDialogReplyTarget;
627
- let activeTellaskReplyDirective;
773
+ let activeBusinessContinuation = driveOptions?.businessContinuation ?? { kind: 'none' };
774
+ const replyContinuationScope = {
775
+ refresh(continuation) {
776
+ activeBusinessContinuation = continuation;
777
+ },
778
+ directive() {
779
+ switch (activeBusinessContinuation.kind) {
780
+ case 'none':
781
+ return undefined;
782
+ case 'inter_dialog_reply':
783
+ return activeBusinessContinuation.tellaskReplyDirective;
784
+ default: {
785
+ const _exhaustive = activeBusinessContinuation;
786
+ throw new Error(`Unhandled business continuation kind: ${String(_exhaustive)}`);
787
+ }
788
+ }
789
+ },
790
+ target() {
791
+ switch (activeBusinessContinuation.kind) {
792
+ case 'none':
793
+ return undefined;
794
+ case 'inter_dialog_reply':
795
+ return activeBusinessContinuation.calleeDialogReplyTarget;
796
+ default: {
797
+ const _exhaustive = activeBusinessContinuation;
798
+ throw new Error(`Unhandled business continuation kind: ${String(_exhaustive)}`);
799
+ }
800
+ }
801
+ },
802
+ };
803
+ let calleeDialogReplyTarget = replyContinuationScope.target();
804
+ let activeTellaskReplyDirective = replyContinuationScope.directive();
628
805
  let activePromptWasReplyToolReminder = false;
629
806
  let shouldPauseAfterLocalUserInterjection = false;
630
807
  let resumeFromInterjectionPause = false;
@@ -656,7 +833,7 @@ async function executeDriveRound(args) {
656
833
  if (!cleanup.cleared) {
657
834
  await persistence_1.DialogPersistence.removeDriveWatchForDialog(dialog.id, dialog.status);
658
835
  }
659
- log_1.log.warn('Dropped stale no-prompt sideDialog drive after final response anchor', undefined, {
836
+ log_1.log.debug('Dropped stale no-prompt sideDialog drive after final response anchor', undefined, {
660
837
  dialogId: dialog.id.valueOf(),
661
838
  rootId: dialog.id.rootId,
662
839
  selfId: dialog.id.selfId,
@@ -713,6 +890,22 @@ async function executeDriveRound(args) {
713
890
  try {
714
891
  const inspection = await inspectNoPromptSideDialogDrive({ dialog, driveOptions });
715
892
  if (inspection.shouldReject) {
893
+ if (inspection.rejection === 'stale_consumed_result_arrival') {
894
+ log_1.log.debug('Dropped stale no-prompt sideDialog caller revive after result arrival', undefined, {
895
+ dialogId: dialog.id.valueOf(),
896
+ rootId: dialog.id.rootId,
897
+ selfId: dialog.id.selfId,
898
+ source: inspection.source,
899
+ reason: driveOptions?.reason ?? null,
900
+ rejection: inspection.rejection,
901
+ allowResumeFromInterrupted: driveOptions?.allowResumeFromInterrupted === true,
902
+ displayState: inspection.displayState ?? null,
903
+ currentCourse: inspection.currentCourse,
904
+ sideDialogFinalResponseCallId: inspection.sideDialogFinalResponseCallId ?? null,
905
+ waitInQue,
906
+ });
907
+ return;
908
+ }
716
909
  log_1.log.error('Rejected unexpected no-prompt sideDialog drive request', undefined, {
717
910
  dialogId: dialog.id.valueOf(),
718
911
  rootId: dialog.id.rootId,
@@ -839,18 +1032,23 @@ async function executeDriveRound(args) {
839
1032
  cautionRemediationCadenceGenerations = (0, context_health_1.resolveCautionRemediationCadenceGenerations)(providerCfg?.models[model]?.caution_remediation_cadence_generations);
840
1033
  }
841
1034
  const criticalCountdownRemaining = (0, context_health_1.resolveCriticalCountdownRemaining)(dialog.id.key(), snapshot);
1035
+ const userPromptContentForHealth = humanPrompt?.origin === 'user'
1036
+ ? humanPrompt.content
1037
+ : queuedUpNextBeforeHealth?.origin === 'user'
1038
+ ? queuedUpNextBeforeHealth.prompt
1039
+ : undefined;
842
1040
  const healthDecision = (0, context_health_1.decideKernelDriverContextHealth)({
843
1041
  dialogKey: dialog.id.key(),
844
1042
  snapshot,
845
1043
  hadUserPromptThisGen: isEffectiveUserPromptForContextHealth(humanPrompt) ||
846
1044
  (humanPrompt === undefined && isQueuedUserPromptForContextHealth(queuedUpNextBeforeHealth)),
847
- userPromptCriticalRemediationAlreadyApplied: false,
1045
+ userPromptCriticalRemediationAlreadyApplied: userPromptContentForHealth !== undefined &&
1046
+ (0, driver_messages_1.isAgentFacingCriticalUserInterjectionRemediationGuideContent)(userPromptContentForHealth),
848
1047
  canInjectPromptThisGen: !hasQueuedUpNext,
849
1048
  cautionRemediationCadenceGenerations,
850
1049
  criticalCountdownRemaining,
851
1050
  });
852
1051
  let healthPrompt;
853
- let criticalUserInterjectionRuntimeGuide;
854
1052
  if (healthDecision.kind === 'continue') {
855
1053
  if (healthDecision.reason === 'critical_force_new_course') {
856
1054
  const language = (0, work_language_1.getWorkLanguage)();
@@ -863,13 +1061,17 @@ async function executeDriveRound(args) {
863
1061
  (0, context_health_1.resetContextHealthRoundState)(dialog.id.key());
864
1062
  }
865
1063
  else if (healthDecision.reason === 'critical_user_prompt_remediation') {
866
- const language = (0, work_language_1.getWorkLanguage)();
867
- const dialogScope = dialog instanceof dialog_1.SideDialog ? 'sideDialog' : 'mainDialog';
868
- criticalUserInterjectionRuntimeGuide =
869
- (0, driver_messages_1.formatAgentFacingCriticalUserInterjectionRemediationGuide)(language, {
870
- dialogScope,
871
- promptsRemainingAfterThis: (0, context_health_1.consumeCriticalCountdown)(dialog.id.key()),
1064
+ if (userPromptContentForHealth === undefined ||
1065
+ !(0, driver_messages_1.isAgentFacingCriticalUserInterjectionRemediationGuideContent)(userPromptContentForHealth)) {
1066
+ log_1.log.warn('kernel-driver observed unwrapped critical user prompt; critical user interjection wrapping must happen at ingress', undefined, {
1067
+ dialogId: dialog.id.valueOf(),
1068
+ msgId: humanPrompt?.origin === 'user'
1069
+ ? humanPrompt.msgId
1070
+ : queuedUpNextBeforeHealth?.origin === 'user'
1071
+ ? queuedUpNextBeforeHealth.msgId
1072
+ : null,
872
1073
  });
1074
+ }
873
1075
  }
874
1076
  else if (!hasQueuedUpNext) {
875
1077
  const language = (0, work_language_1.getWorkLanguage)();
@@ -909,6 +1111,18 @@ async function executeDriveRound(args) {
909
1111
  dialog,
910
1112
  latest: latestBeforeCore,
911
1113
  }));
1114
+ if (resolvedPrompt.droppedStaleQueuedContinuation &&
1115
+ effectivePrompt === undefined &&
1116
+ !(0, dialog_drive_work_1.hasDurableDriveWork)(latestBeforeCore)) {
1117
+ log_1.log.debug('kernel-driver stopped after dropping stale queued continuation', undefined, {
1118
+ dialogId: dialog.id.valueOf(),
1119
+ rootId: dialog.id.rootId,
1120
+ selfId: dialog.id.selfId,
1121
+ source: driveSource,
1122
+ reason: driveOptions?.reason ?? null,
1123
+ });
1124
+ return;
1125
+ }
912
1126
  await applyRegisteredDialogRunControlsBeforeDrive({
913
1127
  dialog,
914
1128
  humanPrompt,
@@ -922,7 +1136,17 @@ async function executeDriveRound(args) {
922
1136
  throw new Error(`kernel-driver upNext invariant violation: expected queued prompt ${effectivePrompt?.msgId ?? 'unknown'} before drive`);
923
1137
  }
924
1138
  }
925
- calleeDialogReplyTarget = effectivePrompt?.calleeDialogReplyTarget;
1139
+ if (effectivePrompt?.tellaskReplyDirective !== undefined) {
1140
+ replyContinuationScope.refresh({
1141
+ kind: 'inter_dialog_reply',
1142
+ tellaskReplyDirective: effectivePrompt.tellaskReplyDirective,
1143
+ ...(effectivePrompt.calleeDialogReplyTarget === undefined
1144
+ ? {}
1145
+ : { calleeDialogReplyTarget: effectivePrompt.calleeDialogReplyTarget }),
1146
+ });
1147
+ }
1148
+ calleeDialogReplyTarget =
1149
+ effectivePrompt?.calleeDialogReplyTarget ?? replyContinuationScope.target();
926
1150
  const replyGuidance = await (0, reply_guidance_1.resolvePromptReplyGuidance)({
927
1151
  dlg: dialog,
928
1152
  prompt: effectivePrompt,
@@ -940,28 +1164,20 @@ async function executeDriveRound(args) {
940
1164
  !replyGuidance.isQ4HAnswerPrompt &&
941
1165
  replyGuidance.suppressInterDialogReplyGuidance &&
942
1166
  replyGuidance.deferredReplyReassertionDirective !== undefined;
943
- activeTellaskReplyDirective = replyGuidance.activeReplyDirective;
1167
+ activeTellaskReplyDirective =
1168
+ replyGuidance.activeReplyDirective ?? replyContinuationScope.directive();
944
1169
  activePromptWasReplyToolReminder = isReplyToolReminderPrompt(effectivePrompt);
945
- const activePromptCarriesReplyDirective = effectivePrompt?.tellaskReplyDirective !== undefined &&
1170
+ let activePromptCarriesReplyDirective = effectivePrompt?.tellaskReplyDirective !== undefined &&
946
1171
  activeTellaskReplyDirective !== undefined &&
947
1172
  effectivePrompt.tellaskReplyDirective.targetCallId ===
948
1173
  activeTellaskReplyDirective.targetCallId;
949
1174
  if (effectivePrompt && effectivePrompt.userLanguageCode) {
950
1175
  dialog.setLastUserLanguageCode(effectivePrompt.userLanguageCode);
951
1176
  }
952
- const coreDriveOptions = criticalUserInterjectionRuntimeGuide === undefined
953
- ? driveOptions
954
- : {
955
- ...(driveOptions ?? {
956
- source: driveSource,
957
- reason: 'critical_user_prompt_remediation',
958
- }),
959
- criticalUserInterjectionRuntimeGuide,
960
- };
961
1177
  driveResult = await (0, drive_1.driveDialogStreamCore)(dialog, {
962
1178
  scheduleDrive: args.scheduleDrive,
963
1179
  driveDialog: args.driveDialog,
964
- }, effectivePrompt, coreDriveOptions);
1180
+ }, effectivePrompt, driveOptions);
965
1181
  const latestAfterCore = await persistence_1.DialogPersistence.loadDialogLatest(dialog.id, dialog.status);
966
1182
  coreEndedInterrupted = latestAfterCore?.executionMarker?.kind === 'interrupted';
967
1183
  await restoreAcceptedRootDriveWakeAfterDriveFailure({
@@ -970,10 +1186,39 @@ async function executeDriveRound(args) {
970
1186
  reason: 'core_stopped',
971
1187
  hadRootDriveWakeBeforeCore,
972
1188
  });
973
- calleeDialogReplyTarget = driveResult.lastAssistantReplyTarget ?? calleeDialogReplyTarget;
1189
+ replyContinuationScope.refresh(driveResult.lastBusinessContinuation);
1190
+ calleeDialogReplyTarget =
1191
+ driveResult.lastAssistantReplyTarget ??
1192
+ replyContinuationScope.target() ??
1193
+ calleeDialogReplyTarget;
1194
+ activeTellaskReplyDirective = activeTellaskReplyDirective ?? replyContinuationScope.directive();
974
1195
  interruptedBySignal = (0, dialog_display_state_1.getActiveRunSignal)(dialog.id)?.aborted === true;
975
1196
  if (!interruptedBySignal) {
976
- followUp = dialog.takeUpNext();
1197
+ const queuedFollowUp = dialog.takeUpNext();
1198
+ if (queuedFollowUp && isQueuedReplyObligationContinuation(queuedFollowUp)) {
1199
+ const claim = await claimQueuedReplyObligationContinuation({
1200
+ dialog,
1201
+ prompt: queuedFollowUp,
1202
+ });
1203
+ if (claim === 'stale') {
1204
+ await persistence_1.DialogPersistence.clearPendingRuntimePrompt(dialog.id, queuedFollowUp.msgId, dialog.status);
1205
+ log_1.log.debug('kernel-driver dropped stale reply obligation follow-up after core', undefined, {
1206
+ dialogId: dialog.id.valueOf(),
1207
+ rootId: dialog.id.rootId,
1208
+ selfId: dialog.id.selfId,
1209
+ msgId: queuedFollowUp.msgId,
1210
+ targetCallId: queuedFollowUp.tellaskReplyDirective.targetCallId,
1211
+ expectedReplyCallName: queuedFollowUp.tellaskReplyDirective.expectedReplyCallName,
1212
+ });
1213
+ followUp = undefined;
1214
+ }
1215
+ else {
1216
+ followUp = queuedFollowUp;
1217
+ }
1218
+ }
1219
+ else {
1220
+ followUp = queuedFollowUp;
1221
+ }
977
1222
  }
978
1223
  let tailError;
979
1224
  try {
@@ -1021,6 +1266,33 @@ async function executeDriveRound(args) {
1021
1266
  });
1022
1267
  }
1023
1268
  else {
1269
+ const replyDirectiveForAssistantOutput = await resolveSideDialogReplyDirectiveForAssistantOutput({
1270
+ dialog,
1271
+ responseGenseq: directFallbackResponse.responseGenseq,
1272
+ replyTarget: driveResult.lastAssistantReplyTarget,
1273
+ currentDirective: activeTellaskReplyDirective,
1274
+ });
1275
+ if (replyDirectiveForAssistantOutput !== undefined &&
1276
+ replyDirectiveForAssistantOutput.targetCallId !==
1277
+ activeTellaskReplyDirective?.targetCallId) {
1278
+ // Business continuation identity should already come from the accepted next-step
1279
+ // trigger or the current runtime prompt. This branch only handles an explicit
1280
+ // assistant-output reply target surfaced by the core; do not broaden it into
1281
+ // transcript/assignment-anchor reconstruction.
1282
+ log_1.log.debug('kernel-driver rebound sideDialog reply directive to latest assistant output target', undefined, {
1283
+ dialogId: dialog.id.valueOf(),
1284
+ previousTargetCallId: activeTellaskReplyDirective?.targetCallId ?? null,
1285
+ nextTargetCallId: replyDirectiveForAssistantOutput.targetCallId,
1286
+ responseGenseq: directFallbackResponse.responseGenseq,
1287
+ replyTargetCallId: driveResult.lastAssistantReplyTarget?.callId ?? null,
1288
+ });
1289
+ }
1290
+ activeTellaskReplyDirective = replyDirectiveForAssistantOutput;
1291
+ activePromptCarriesReplyDirective =
1292
+ activePromptCarriesReplyDirective ||
1293
+ (activeTellaskReplyDirective !== undefined &&
1294
+ driveResult.lastAssistantReplyTarget?.callId ===
1295
+ activeTellaskReplyDirective.targetCallId);
1024
1296
  const hasFollowUp = followUp !== undefined;
1025
1297
  const suspension = await dialog.getSuspensionStatus();
1026
1298
  const backgroundCalleeBlocksImplicitReply = suspension.backgroundCalleeDialogs &&
@@ -1190,17 +1462,20 @@ async function executeDriveRound(args) {
1190
1462
  if (followUp.kind === 'runtime_reply_reminder' ||
1191
1463
  followUp.kind === 'runtime_sideDialog_reply_reminder') {
1192
1464
  await queueReplyReminderFollowUp({ dialog, followUp });
1465
+ const businessContinuation = {
1466
+ kind: 'inter_dialog_reply',
1467
+ tellaskReplyDirective: followUp.tellaskReplyDirective,
1468
+ ...(followUp.kind === 'runtime_sideDialog_reply_reminder' &&
1469
+ followUp.calleeDialogReplyTarget !== undefined
1470
+ ? { calleeDialogReplyTarget: followUp.calleeDialogReplyTarget }
1471
+ : {}),
1472
+ };
1193
1473
  args.scheduleDrive(dialog, {
1194
1474
  waitInQue: true,
1195
1475
  driveOptions: {
1196
1476
  source: 'kernel_driver_follow_up',
1197
1477
  reason: 'follow_up_prompt',
1198
- noPromptSideDialogResumeEntitlement: dialog instanceof dialog_1.SideDialog
1199
- ? {
1200
- callerDialogId: dialog.id.selfId,
1201
- reason: 'reply_obligation_follow_up',
1202
- }
1203
- : undefined,
1478
+ businessContinuation,
1204
1479
  },
1205
1480
  });
1206
1481
  return driveResult;