dominds 1.16.2 → 1.16.3

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.
@@ -34,7 +34,9 @@ export declare function broadcastRunControlCountsSnapshot(): Promise<void>;
34
34
  export declare function hasActiveRun(dialogId: DialogID): boolean;
35
35
  export declare function getActiveRunSignal(dialogId: DialogID): AbortSignal | undefined;
36
36
  export declare function createActiveRun(dialogId: DialogID): AbortSignal;
37
- export declare function clearActiveRun(dialogId: DialogID): void;
37
+ export declare function clearActiveRun(dialogId: DialogID, options?: Readonly<{
38
+ notifyBackendLoop?: boolean;
39
+ }>): void;
38
40
  export declare function clearRootDialogQuarantiningIfIdle(rootDialogId: DialogID): void;
39
41
  export declare function markRootDialogQuarantining(rootDialogId: DialogID): void;
40
42
  export declare function clearRootDialogQuarantining(rootDialogId: DialogID): void;
@@ -44,6 +44,7 @@ exports.requestInterruptDialog = requestInterruptDialog;
44
44
  exports.requestEmergencyStopAll = requestEmergencyStopAll;
45
45
  const time_1 = require("@longrun-ai/kernel/utils/time");
46
46
  const dialog_1 = require("./dialog");
47
+ const dialog_global_registry_1 = require("./dialog-global-registry");
47
48
  const dialog_interruption_1 = require("./dialog-interruption");
48
49
  const evt_registry_1 = require("./evt-registry");
49
50
  const log_1 = require("./log");
@@ -178,13 +179,19 @@ function createActiveRun(dialogId) {
178
179
  syncRunControlCountsAfterActiveRunChange('create_active_run', dialogId);
179
180
  return run.abortController.signal;
180
181
  }
181
- function clearActiveRun(dialogId) {
182
+ function clearActiveRun(dialogId, options) {
182
183
  const deleted = activeRunsByDialogKey.delete(dialogId.key());
183
184
  if (!deleted) {
184
185
  clearQuarantiningRootDialogIfIdle(dialogId.rootId);
185
186
  return;
186
187
  }
187
188
  clearQuarantiningRootDialogIfIdle(dialogId.rootId);
189
+ if (dialogId.selfId === dialogId.rootId && options?.notifyBackendLoop !== false) {
190
+ dialog_global_registry_1.globalDialogRegistry.notifyActiveRunCleared(dialogId.rootId, {
191
+ source: 'dialog_display_state_active_run_clear',
192
+ reason: 'root_active_run_cleared',
193
+ });
194
+ }
188
195
  syncRunControlCountsAfterActiveRunChange('clear_active_run', dialogId);
189
196
  }
190
197
  function clearQuarantiningRootDialogIfIdle(rootId) {
@@ -1,7 +1,7 @@
1
1
  import type { RootDialog } from './dialog';
2
2
  export type DriveTriggerEvent = Readonly<{
3
3
  type: 'drive_trigger_evt';
4
- action: 'mark_needs_drive' | 'mark_not_needing_drive';
4
+ action: 'mark_needs_drive' | 'mark_not_needing_drive' | 'active_run_cleared';
5
5
  rootId: string;
6
6
  entryFound: boolean;
7
7
  previousNeedsDrive: boolean | null;
@@ -28,6 +28,10 @@ declare class GlobalDialogRegistry {
28
28
  waitForDriveTrigger(): Promise<DriveTriggerEvent>;
29
29
  markNeedsDrive(rootId: string, meta?: DriveTriggerMeta): void;
30
30
  markNotNeedingDrive(rootId: string, meta?: DriveTriggerMeta): void;
31
+ notifyActiveRunCleared(rootId: string, meta?: DriveTriggerMeta): void;
32
+ noteActiveRunBlockedQueuedDrive(rootId: string): void;
33
+ hasPendingActiveRunClearedWake(rootId: string): boolean;
34
+ isMarkedNeedingDrive(rootId: string): boolean;
31
35
  getDialogsNeedingDrive(): RootDialog[];
32
36
  getLastDriveTrigger(rootId: string): DriveTriggerEvent | undefined;
33
37
  getAll(): RootDialog[];
@@ -29,7 +29,11 @@ class GlobalDialogRegistry {
29
29
  if (existing) {
30
30
  return;
31
31
  }
32
- this.entries.set(rootDialog.id.rootId, { rootDialog, needsDrive: false });
32
+ this.entries.set(rootDialog.id.rootId, {
33
+ rootDialog,
34
+ needsDrive: false,
35
+ activeRunClearedWakePending: false,
36
+ });
33
37
  void (async () => {
34
38
  try {
35
39
  const needsDrive = await persistence_1.DialogPersistence.getNeedsDrive(rootDialog.id);
@@ -82,6 +86,8 @@ class GlobalDialogRegistry {
82
86
  const previousNeedsDrive = entry ? entry.needsDrive : null;
83
87
  if (entry) {
84
88
  entry.needsDrive = true;
89
+ // A fresh queueing trigger supersedes any earlier "wake me once active run clears" debt.
90
+ entry.activeRunClearedWakePending = false;
85
91
  }
86
92
  this.publishDriveTrigger({
87
93
  action: 'mark_needs_drive',
@@ -101,6 +107,7 @@ class GlobalDialogRegistry {
101
107
  const previousNeedsDrive = entry ? entry.needsDrive : null;
102
108
  if (entry) {
103
109
  entry.needsDrive = false;
110
+ entry.activeRunClearedWakePending = false;
104
111
  }
105
112
  this.publishDriveTrigger({
106
113
  action: 'mark_not_needing_drive',
@@ -111,6 +118,43 @@ class GlobalDialogRegistry {
111
118
  meta: triggerMeta,
112
119
  });
113
120
  }
121
+ notifyActiveRunCleared(rootId, meta) {
122
+ const triggerMeta = meta ?? {
123
+ source: 'unknown',
124
+ reason: 'unspecified',
125
+ };
126
+ const entry = this.entries.get(rootId);
127
+ if (!entry) {
128
+ return;
129
+ }
130
+ if (!entry.activeRunClearedWakePending || !entry.needsDrive) {
131
+ entry.activeRunClearedWakePending = false;
132
+ return;
133
+ }
134
+ const currentNeedsDrive = entry ? entry.needsDrive : null;
135
+ entry.activeRunClearedWakePending = false;
136
+ this.publishDriveTrigger({
137
+ action: 'active_run_cleared',
138
+ rootId,
139
+ entryFound: true,
140
+ previousNeedsDrive: currentNeedsDrive,
141
+ nextNeedsDrive: entry.needsDrive,
142
+ meta: triggerMeta,
143
+ });
144
+ }
145
+ noteActiveRunBlockedQueuedDrive(rootId) {
146
+ const entry = this.entries.get(rootId);
147
+ if (!entry || !entry.needsDrive) {
148
+ return;
149
+ }
150
+ entry.activeRunClearedWakePending = true;
151
+ }
152
+ hasPendingActiveRunClearedWake(rootId) {
153
+ return this.entries.get(rootId)?.activeRunClearedWakePending === true;
154
+ }
155
+ isMarkedNeedingDrive(rootId) {
156
+ return this.entries.get(rootId)?.needsDrive === true;
157
+ }
114
158
  getDialogsNeedingDrive() {
115
159
  return Array.from(this.entries.values())
116
160
  .filter((entry) => entry.needsDrive)
@@ -74,6 +74,38 @@ async function loadPendingDiagnosticsSnapshot(args) {
74
74
  };
75
75
  }
76
76
  }
77
+ async function clearConsumedDeferredRootQueueIfIdle(dialog) {
78
+ if (dialog.id.selfId !== dialog.id.rootId) {
79
+ return;
80
+ }
81
+ if (!dialog_global_registry_1.globalDialogRegistry.get(dialog.id.rootId)) {
82
+ return;
83
+ }
84
+ const suspension = await dialog.getSuspensionStatus();
85
+ if (dialog.hasUpNext() || !suspension.canDrive) {
86
+ return;
87
+ }
88
+ const persistedNeedsDrive = await persistence_1.DialogPersistence.getNeedsDrive(dialog.id);
89
+ const registryNeedsDrive = dialog_global_registry_1.globalDialogRegistry.isMarkedNeedingDrive(dialog.id.rootId);
90
+ if (!registryNeedsDrive && !persistedNeedsDrive) {
91
+ return;
92
+ }
93
+ try {
94
+ await persistence_1.DialogPersistence.setNeedsDrive(dialog.id, false, dialog.status);
95
+ }
96
+ catch (error) {
97
+ log_1.log.error('kernel-driver failed to persist consumed deferred root queue cleanup', error, {
98
+ dialogId: dialog.id.valueOf(),
99
+ rootId: dialog.id.rootId,
100
+ selfId: dialog.id.selfId,
101
+ });
102
+ return;
103
+ }
104
+ dialog_global_registry_1.globalDialogRegistry.markNotNeedingDrive(dialog.id.rootId, {
105
+ source: 'kernel_driver_flow_tail',
106
+ reason: 'root_idle_after_consuming_deferred_queue',
107
+ });
108
+ }
77
109
  function hasNoPromptSubdialogResumeEntitlement(dialog, driveOptions) {
78
110
  const entitlement = driveOptions?.noPromptSubdialogResumeEntitlement;
79
111
  if (!entitlement) {
@@ -490,203 +522,224 @@ async function executeDriveRound(args) {
490
522
  if (!interruptedBySignal) {
491
523
  followUp = dialog.takeUpNext();
492
524
  }
493
- }
494
- finally {
495
- if (activeRunPrimed && ownsActiveRun) {
496
- (0, dialog_display_state_1.clearActiveRun)(dialog.id);
497
- }
498
- release();
499
- }
500
- if (dialog instanceof dialog_1.SubDialog &&
501
- driveResult &&
502
- !interruptedBySignal &&
503
- (driveResult.fbrConclusion !== undefined || driveResult.lastAssistantSayingContent !== null)) {
504
- if (driveResult.fbrConclusion) {
505
- await (0, subdialog_1.supplySubdialogResponseToAssignedCallerIfPendingV2)({
506
- subdialog: dialog,
507
- responseText: driveResult.fbrConclusion.responseText,
508
- responseGenseq: driveResult.fbrConclusion.responseGenseq,
509
- scheduleDrive: args.scheduleDrive,
510
- });
511
- }
512
- else if (driveResult.lastAssistantSayingContent !== null) {
513
- const hasInProgressFunctionCall = typeof driveResult.lastFunctionCallGenseq === 'number' &&
514
- Number.isFinite(driveResult.lastFunctionCallGenseq) &&
515
- driveResult.lastFunctionCallGenseq > 0 &&
516
- (typeof driveResult.lastAssistantSayingGenseq !== 'number' ||
517
- !Number.isFinite(driveResult.lastAssistantSayingGenseq) ||
518
- driveResult.lastAssistantSayingGenseq <= driveResult.lastFunctionCallGenseq);
519
- if (hasInProgressFunctionCall) {
520
- // Any function call means execution is still in-progress. Only supply when the callee
521
- // has produced a newer assistant saying after the latest function call.
522
- log_1.log.debug('kernel-driver skip subdialog response supply because latest saying is not after function calls', undefined, {
523
- rootId: dialog.id.rootId,
524
- selfId: dialog.id.selfId,
525
- lastAssistantSayingGenseq: driveResult.lastAssistantSayingGenseq,
526
- lastFunctionCallGenseq: driveResult.lastFunctionCallGenseq,
527
- });
528
- }
529
- else {
530
- const hasFollowUp = followUp !== undefined;
531
- const suspension = await dialog.getSuspensionStatus();
532
- if (!suspension.canDrive || hasFollowUp) {
533
- log_1.log.debug('kernel-driver skip subdialog response supply while callee is not finalized', undefined, {
534
- rootId: dialog.id.rootId,
535
- selfId: dialog.id.selfId,
536
- waitingQ4H: suspension.q4h,
537
- waitingSubdialogs: suspension.subdialogs,
538
- hasFollowUp,
525
+ let tailError;
526
+ try {
527
+ if (dialog instanceof dialog_1.SubDialog &&
528
+ driveResult &&
529
+ !interruptedBySignal &&
530
+ (driveResult.fbrConclusion !== undefined || driveResult.lastAssistantSayingContent !== null)) {
531
+ if (driveResult.fbrConclusion) {
532
+ await (0, subdialog_1.supplySubdialogResponseToAssignedCallerIfPendingV2)({
533
+ subdialog: dialog,
534
+ responseText: driveResult.fbrConclusion.responseText,
535
+ responseGenseq: driveResult.fbrConclusion.responseGenseq,
536
+ scheduleDrive: args.scheduleDrive,
539
537
  });
540
538
  }
541
- if (suspension.canDrive && !hasFollowUp) {
542
- if (!activeTellaskReplyDirective) {
543
- log_1.log.debug('kernel-driver skip implicit subdialog reply because no active tellask reply directive is bound to this drive', undefined, {
539
+ else if (driveResult.lastAssistantSayingContent !== null) {
540
+ const hasInProgressFunctionCall = typeof driveResult.lastFunctionCallGenseq === 'number' &&
541
+ Number.isFinite(driveResult.lastFunctionCallGenseq) &&
542
+ driveResult.lastFunctionCallGenseq > 0 &&
543
+ (typeof driveResult.lastAssistantSayingGenseq !== 'number' ||
544
+ !Number.isFinite(driveResult.lastAssistantSayingGenseq) ||
545
+ driveResult.lastAssistantSayingGenseq <= driveResult.lastFunctionCallGenseq);
546
+ if (hasInProgressFunctionCall) {
547
+ // Any function call means execution is still in-progress. Only supply when the callee
548
+ // has produced a newer assistant saying after the latest function call.
549
+ log_1.log.debug('kernel-driver skip subdialog response supply because latest saying is not after function calls', undefined, {
544
550
  rootId: dialog.id.rootId,
545
551
  selfId: dialog.id.selfId,
552
+ lastAssistantSayingGenseq: driveResult.lastAssistantSayingGenseq,
553
+ lastFunctionCallGenseq: driveResult.lastFunctionCallGenseq,
546
554
  });
547
555
  }
548
556
  else {
549
- if (typeof driveResult.lastAssistantSayingGenseq !== 'number' ||
550
- !Number.isFinite(driveResult.lastAssistantSayingGenseq) ||
551
- driveResult.lastAssistantSayingGenseq <= 0) {
552
- throw new Error(`Subdialog response supply invariant violation: missing lastAssistantSayingGenseq for dialog=${dialog.id.valueOf()}`);
553
- }
554
- const responseGenseq = Math.floor(driveResult.lastAssistantSayingGenseq);
555
- const directFallbackCallId = `direct-fallback-${(0, id_1.generateShortId)()}`;
556
- let supplied = false;
557
- if (subdialogReplyTarget) {
558
- supplied = await (0, subdialog_1.supplySubdialogResponseToSpecificCallerIfPendingV2)({
559
- subdialog: dialog,
560
- responseText: driveResult.lastAssistantSayingContent,
561
- responseGenseq,
562
- target: subdialogReplyTarget,
563
- deliveryMode: 'direct_fallback',
564
- replyResolution: {
565
- callId: directFallbackCallId,
566
- replyCallName: activeTellaskReplyDirective.expectedReplyCallName,
567
- },
568
- scheduleDrive: args.scheduleDrive,
557
+ const hasFollowUp = followUp !== undefined;
558
+ const suspension = await dialog.getSuspensionStatus();
559
+ if (!suspension.canDrive || hasFollowUp) {
560
+ log_1.log.debug('kernel-driver skip subdialog response supply while callee is not finalized', undefined, {
561
+ rootId: dialog.id.rootId,
562
+ selfId: dialog.id.selfId,
563
+ waitingQ4H: suspension.q4h,
564
+ waitingSubdialogs: suspension.subdialogs,
565
+ hasFollowUp,
569
566
  });
570
- if (!supplied) {
571
- supplied = await (0, subdialog_1.supplySubdialogResponseToAssignedCallerIfPendingV2)({
572
- subdialog: dialog,
573
- responseText: driveResult.lastAssistantSayingContent,
574
- responseGenseq,
575
- deliveryMode: 'direct_fallback',
576
- replyResolution: {
577
- callId: directFallbackCallId,
578
- replyCallName: activeTellaskReplyDirective.expectedReplyCallName,
579
- },
580
- scheduleDrive: args.scheduleDrive,
567
+ }
568
+ if (suspension.canDrive && !hasFollowUp) {
569
+ if (!activeTellaskReplyDirective) {
570
+ log_1.log.debug('kernel-driver skip implicit subdialog reply because no active tellask reply directive is bound to this drive', undefined, {
571
+ rootId: dialog.id.rootId,
572
+ selfId: dialog.id.selfId,
581
573
  });
582
574
  }
583
- }
584
- else {
585
- supplied = await (0, subdialog_1.supplySubdialogResponseToAssignedCallerIfPendingV2)({
586
- subdialog: dialog,
587
- responseText: driveResult.lastAssistantSayingContent,
588
- responseGenseq,
589
- deliveryMode: 'direct_fallback',
590
- replyResolution: {
591
- callId: directFallbackCallId,
592
- replyCallName: activeTellaskReplyDirective.expectedReplyCallName,
593
- },
594
- scheduleDrive: args.scheduleDrive,
595
- });
596
- }
597
- if (!supplied && subdialogReplyTarget) {
598
- const diagnostics = await loadPendingDiagnosticsSnapshot({
599
- rootId: dialog.id.rootId,
600
- ownerDialogId: subdialogReplyTarget.ownerDialogId,
601
- expectedSubdialogId: dialog.id.selfId,
602
- status: dialog.status,
603
- });
604
- log_1.log.debug('kernel-driver failed to supply subdialog response to specific caller', undefined, {
605
- calleeId: dialog.id.valueOf(),
606
- targetOwner: subdialogReplyTarget.ownerDialogId,
607
- targetOwnerDialogId: subdialogReplyTarget.ownerDialogId,
608
- targetCallType: subdialogReplyTarget.callType,
609
- targetCallId: subdialogReplyTarget.callId,
610
- diagnostics,
611
- });
575
+ else {
576
+ if (typeof driveResult.lastAssistantSayingGenseq !== 'number' ||
577
+ !Number.isFinite(driveResult.lastAssistantSayingGenseq) ||
578
+ driveResult.lastAssistantSayingGenseq <= 0) {
579
+ throw new Error(`Subdialog response supply invariant violation: missing lastAssistantSayingGenseq for dialog=${dialog.id.valueOf()}`);
580
+ }
581
+ const responseGenseq = Math.floor(driveResult.lastAssistantSayingGenseq);
582
+ const directFallbackCallId = `direct-fallback-${(0, id_1.generateShortId)()}`;
583
+ let supplied = false;
584
+ if (subdialogReplyTarget) {
585
+ supplied = await (0, subdialog_1.supplySubdialogResponseToSpecificCallerIfPendingV2)({
586
+ subdialog: dialog,
587
+ responseText: driveResult.lastAssistantSayingContent,
588
+ responseGenseq,
589
+ target: subdialogReplyTarget,
590
+ deliveryMode: 'direct_fallback',
591
+ replyResolution: {
592
+ callId: directFallbackCallId,
593
+ replyCallName: activeTellaskReplyDirective.expectedReplyCallName,
594
+ },
595
+ scheduleDrive: args.scheduleDrive,
596
+ });
597
+ if (!supplied) {
598
+ supplied = await (0, subdialog_1.supplySubdialogResponseToAssignedCallerIfPendingV2)({
599
+ subdialog: dialog,
600
+ responseText: driveResult.lastAssistantSayingContent,
601
+ responseGenseq,
602
+ deliveryMode: 'direct_fallback',
603
+ replyResolution: {
604
+ callId: directFallbackCallId,
605
+ replyCallName: activeTellaskReplyDirective.expectedReplyCallName,
606
+ },
607
+ scheduleDrive: args.scheduleDrive,
608
+ });
609
+ }
610
+ }
611
+ else {
612
+ supplied = await (0, subdialog_1.supplySubdialogResponseToAssignedCallerIfPendingV2)({
613
+ subdialog: dialog,
614
+ responseText: driveResult.lastAssistantSayingContent,
615
+ responseGenseq,
616
+ deliveryMode: 'direct_fallback',
617
+ replyResolution: {
618
+ callId: directFallbackCallId,
619
+ replyCallName: activeTellaskReplyDirective.expectedReplyCallName,
620
+ },
621
+ scheduleDrive: args.scheduleDrive,
622
+ });
623
+ }
624
+ if (!supplied && subdialogReplyTarget) {
625
+ const diagnostics = await loadPendingDiagnosticsSnapshot({
626
+ rootId: dialog.id.rootId,
627
+ ownerDialogId: subdialogReplyTarget.ownerDialogId,
628
+ expectedSubdialogId: dialog.id.selfId,
629
+ status: dialog.status,
630
+ });
631
+ log_1.log.debug('kernel-driver failed to supply subdialog response to specific caller', undefined, {
632
+ calleeId: dialog.id.valueOf(),
633
+ targetOwner: subdialogReplyTarget.ownerDialogId,
634
+ targetOwnerDialogId: subdialogReplyTarget.ownerDialogId,
635
+ targetCallType: subdialogReplyTarget.callType,
636
+ targetCallId: subdialogReplyTarget.callId,
637
+ diagnostics,
638
+ });
639
+ }
640
+ }
612
641
  }
613
642
  }
614
643
  }
615
644
  }
616
- }
617
- }
618
- if (!(dialog instanceof dialog_1.SubDialog) &&
619
- driveResult &&
620
- !interruptedBySignal &&
621
- driveResult.lastAssistantSayingContent !== null &&
622
- activeTellaskReplyDirective?.expectedReplyCallName === 'replyTellaskBack' &&
623
- followUp === undefined) {
624
- const hasInProgressFunctionCall = typeof driveResult.lastFunctionCallGenseq === 'number' &&
625
- Number.isFinite(driveResult.lastFunctionCallGenseq) &&
626
- driveResult.lastFunctionCallGenseq > 0 &&
627
- (typeof driveResult.lastAssistantSayingGenseq !== 'number' ||
628
- !Number.isFinite(driveResult.lastAssistantSayingGenseq) ||
629
- driveResult.lastAssistantSayingGenseq <= driveResult.lastFunctionCallGenseq);
630
- if (!hasInProgressFunctionCall) {
631
- if (!activePromptWasReplyToolReminder) {
632
- const language = (0, work_language_1.getWorkLanguage)();
633
- followUp = {
634
- prompt: await buildReplyToolReminderPrompt({
635
- dlg: dialog,
636
- directive: activeTellaskReplyDirective,
637
- language,
638
- }),
639
- msgId: (0, id_1.generateShortId)(),
640
- grammar: 'markdown',
641
- origin: 'runtime',
642
- userLanguageCode: language,
643
- tellaskReplyDirective: activeTellaskReplyDirective,
644
- };
645
- log_1.log.debug('kernel-driver queued replyTellaskBack reminder prompt after plain reply', undefined, {
646
- dialogId: dialog.id.valueOf(),
647
- targetCallId: activeTellaskReplyDirective.targetCallId,
648
- });
645
+ if (!(dialog instanceof dialog_1.SubDialog) &&
646
+ driveResult &&
647
+ !interruptedBySignal &&
648
+ driveResult.lastAssistantSayingContent !== null &&
649
+ activeTellaskReplyDirective?.expectedReplyCallName === 'replyTellaskBack' &&
650
+ followUp === undefined) {
651
+ const hasInProgressFunctionCall = typeof driveResult.lastFunctionCallGenseq === 'number' &&
652
+ Number.isFinite(driveResult.lastFunctionCallGenseq) &&
653
+ driveResult.lastFunctionCallGenseq > 0 &&
654
+ (typeof driveResult.lastAssistantSayingGenseq !== 'number' ||
655
+ !Number.isFinite(driveResult.lastAssistantSayingGenseq) ||
656
+ driveResult.lastAssistantSayingGenseq <= driveResult.lastFunctionCallGenseq);
657
+ if (!hasInProgressFunctionCall) {
658
+ if (!activePromptWasReplyToolReminder) {
659
+ const language = (0, work_language_1.getWorkLanguage)();
660
+ followUp = {
661
+ prompt: await buildReplyToolReminderPrompt({
662
+ dlg: dialog,
663
+ directive: activeTellaskReplyDirective,
664
+ language,
665
+ }),
666
+ msgId: (0, id_1.generateShortId)(),
667
+ grammar: 'markdown',
668
+ origin: 'runtime',
669
+ userLanguageCode: language,
670
+ tellaskReplyDirective: activeTellaskReplyDirective,
671
+ };
672
+ log_1.log.debug('kernel-driver queued replyTellaskBack reminder prompt after plain reply', undefined, {
673
+ dialogId: dialog.id.valueOf(),
674
+ targetCallId: activeTellaskReplyDirective.targetCallId,
675
+ });
676
+ }
677
+ else {
678
+ await (0, tellask_special_1.deliverTellaskBackReplyFromDirective)({
679
+ dlg: dialog,
680
+ directive: activeTellaskReplyDirective,
681
+ replyContent: driveResult.lastAssistantSayingContent,
682
+ callbacks: {
683
+ scheduleDrive: args.scheduleDrive,
684
+ driveDialog: args.driveDialog,
685
+ },
686
+ deliveryMode: 'direct_fallback',
687
+ });
688
+ await dialog.appendTellaskReplyResolution({
689
+ callId: `direct-fallback-${(0, id_1.generateShortId)()}`,
690
+ replyCallName: 'replyTellaskBack',
691
+ targetCallId: activeTellaskReplyDirective.targetCallId,
692
+ });
693
+ }
694
+ }
649
695
  }
650
- else {
651
- await (0, tellask_special_1.deliverTellaskBackReplyFromDirective)({
652
- dlg: dialog,
653
- directive: activeTellaskReplyDirective,
654
- replyContent: driveResult.lastAssistantSayingContent,
655
- callbacks: {
656
- scheduleDrive: args.scheduleDrive,
657
- driveDialog: args.driveDialog,
696
+ if (followUp) {
697
+ args.scheduleDrive(dialog, {
698
+ waitInQue: true,
699
+ driveOptions: {
700
+ source: 'kernel_driver_follow_up',
701
+ reason: 'follow_up_prompt',
702
+ },
703
+ humanPrompt: {
704
+ content: followUp.prompt,
705
+ msgId: followUp.msgId,
706
+ grammar: followUp.grammar ?? 'markdown',
707
+ origin: followUp.origin,
708
+ userLanguageCode: followUp.userLanguageCode === 'zh' || followUp.userLanguageCode === 'en'
709
+ ? followUp.userLanguageCode
710
+ : undefined,
711
+ q4hAnswerCallId: followUp.q4hAnswerCallId,
712
+ tellaskReplyDirective: followUp.tellaskReplyDirective,
713
+ skipTaskdoc: followUp.skipTaskdoc,
714
+ subdialogReplyTarget: followUp.subdialogReplyTarget,
715
+ runControl: followUp.runControl,
658
716
  },
659
- deliveryMode: 'direct_fallback',
660
717
  });
661
- await dialog.appendTellaskReplyResolution({
662
- callId: `direct-fallback-${(0, id_1.generateShortId)()}`,
663
- replyCallName: 'replyTellaskBack',
664
- targetCallId: activeTellaskReplyDirective.targetCallId,
718
+ }
719
+ }
720
+ catch (error) {
721
+ tailError = error;
722
+ }
723
+ if (tailError === undefined) {
724
+ try {
725
+ await clearConsumedDeferredRootQueueIfIdle(dialog);
726
+ }
727
+ catch (error) {
728
+ log_1.log.error('kernel-driver failed to reconcile consumed deferred root queue after tail', error, {
729
+ dialogId: dialog.id.valueOf(),
730
+ rootId: dialog.id.rootId,
731
+ selfId: dialog.id.selfId,
665
732
  });
666
733
  }
667
734
  }
735
+ if (tailError !== undefined) {
736
+ throw tailError;
737
+ }
668
738
  }
669
- if (followUp) {
670
- args.scheduleDrive(dialog, {
671
- waitInQue: true,
672
- driveOptions: {
673
- source: 'kernel_driver_follow_up',
674
- reason: 'follow_up_prompt',
675
- },
676
- humanPrompt: {
677
- content: followUp.prompt,
678
- msgId: followUp.msgId,
679
- grammar: followUp.grammar ?? 'markdown',
680
- origin: followUp.origin,
681
- userLanguageCode: followUp.userLanguageCode === 'zh' || followUp.userLanguageCode === 'en'
682
- ? followUp.userLanguageCode
683
- : undefined,
684
- q4hAnswerCallId: followUp.q4hAnswerCallId,
685
- tellaskReplyDirective: followUp.tellaskReplyDirective,
686
- skipTaskdoc: followUp.skipTaskdoc,
687
- subdialogReplyTarget: followUp.subdialogReplyTarget,
688
- runControl: followUp.runControl,
689
- },
690
- });
739
+ finally {
740
+ if (activeRunPrimed && ownsActiveRun) {
741
+ (0, dialog_display_state_1.clearActiveRun)(dialog.id);
742
+ }
743
+ release();
691
744
  }
692
745
  }
@@ -36,6 +36,11 @@ async function driveQueuedDialogsOnce() {
36
36
  continue;
37
37
  }
38
38
  if ((0, dialog_display_state_1.hasActiveRun)(rootDialog.id)) {
39
+ log_1.log.debug('Backend driver deferred queued root drive because dialog already has an active run', undefined, {
40
+ dialogId: rootDialog.id.valueOf(),
41
+ rootId: rootDialog.id.rootId,
42
+ });
43
+ dialog_global_registry_1.globalDialogRegistry.noteActiveRunBlockedQueuedDrive(rootDialog.id.rootId);
39
44
  continue;
40
45
  }
41
46
  if (!(await rootDialog.canDrive())) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dominds",
3
- "version": "1.16.2",
3
+ "version": "1.16.3",
4
4
  "description": "Dominds CLI and aggregation shell for the LongRun AI kernel/runtime packages.",
5
5
  "type": "commonjs",
6
6
  "publishConfig": {
@@ -52,9 +52,9 @@
52
52
  "ws": "^8.19.0",
53
53
  "yaml": "^2.8.2",
54
54
  "zod": "^4.3.6",
55
+ "@longrun-ai/codex-auth": "0.12.0",
55
56
  "@longrun-ai/kernel": "1.8.11",
56
- "@longrun-ai/shell": "1.8.11",
57
- "@longrun-ai/codex-auth": "0.12.0"
57
+ "@longrun-ai/shell": "1.8.11"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/node": "^25.3.5",