dominds 1.4.1 → 1.4.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.
@@ -10,16 +10,22 @@ const events_1 = require("./events");
10
10
  const flow_1 = require("./flow");
11
11
  const subdialog_1 = require("./subdialog");
12
12
  const types_1 = require("./types");
13
+ function dispatchDrive(dialog, options) {
14
+ if (options.humanPrompt) {
15
+ return driveDialogStream(dialog, options.humanPrompt, options.waitInQue, options.driveOptions);
16
+ }
17
+ return driveDialogStream(dialog, undefined, options.waitInQue, options.driveOptions);
18
+ }
13
19
  async function driveDialogStream(...driveArgs) {
14
20
  const runtime = (0, types_1.createKernelDriverRuntimeState)();
15
21
  return await (0, flow_1.executeDriveRound)({
16
22
  runtime,
17
23
  driveArgs,
18
24
  scheduleDrive: (dialog, options) => {
19
- void driveDialogStream(dialog, options.humanPrompt, options.waitInQue, options.driveOptions);
25
+ void dispatchDrive(dialog, options);
20
26
  },
21
27
  driveDialog: async (dialog, options) => {
22
- await driveDialogStream(dialog, options.humanPrompt, options.waitInQue, options.driveOptions);
28
+ await dispatchDrive(dialog, options);
23
29
  },
24
30
  });
25
31
  }
@@ -38,7 +44,7 @@ async function supplyResponseToSupdialog(...args) {
38
44
  status,
39
45
  calleeResponseRef,
40
46
  scheduleDrive: (dialog, options) => {
41
- void driveDialogStream(dialog, options.humanPrompt, options.waitInQue, options.driveOptions);
47
+ void dispatchDrive(dialog, options);
42
48
  },
43
49
  });
44
50
  }
@@ -55,7 +61,7 @@ async function supplyResponseToSubdialogBridge(parentDialog, subdialogId, respon
55
61
  status,
56
62
  calleeResponseRef,
57
63
  scheduleDrive: (dialog, options) => {
58
- void driveDialogStream(dialog, options.humanPrompt, options.waitInQue, options.driveOptions);
64
+ void dispatchDrive(dialog, options);
59
65
  },
60
66
  });
61
67
  }
@@ -49,6 +49,60 @@ async function loadPendingDiagnosticsSnapshot(args) {
49
49
  };
50
50
  }
51
51
  }
52
+ function resolveDriveRequestSource(humanPrompt, driveOptions) {
53
+ if (driveOptions?.source) {
54
+ return driveOptions.source;
55
+ }
56
+ if (humanPrompt?.origin === 'user') {
57
+ return 'ws_user_message';
58
+ }
59
+ return 'unspecified';
60
+ }
61
+ async function inspectNoPromptSubdialogDrive(args) {
62
+ const source = resolveDriveRequestSource(undefined, args.driveOptions);
63
+ const latest = await persistence_1.DialogPersistence.loadDialogLatest(args.dialog.id, args.dialog.status);
64
+ const runState = latest?.runState;
65
+ const rawCourse = latest?.currentCourse ?? args.dialog.currentCourse;
66
+ const currentCourse = Number.isFinite(rawCourse) && rawCourse > 0 ? Math.floor(rawCourse) : 1;
67
+ const courseEvents = await persistence_1.DialogPersistence.loadCourseEvents(args.dialog.id, currentCourse, args.dialog.status);
68
+ const rawLastEvent = courseEvents[courseEvents.length - 1];
69
+ const lastEvent = rawLastEvent?.type === 'teammate_call_anchor_record'
70
+ ? { type: rawLastEvent.type, anchorRole: rawLastEvent.anchorRole }
71
+ : rawLastEvent
72
+ ? { type: rawLastEvent.type }
73
+ : undefined;
74
+ const explicitInterruptedResumeAllowed = args.driveOptions?.allowResumeFromInterrupted === true && runState?.kind === 'interrupted';
75
+ const supplyResponseParentReviveAllowed = source === 'kernel_driver_supply_response_parent_revive' &&
76
+ runState?.kind === 'blocked' &&
77
+ runState.reason.kind === 'waiting_for_subdialogs';
78
+ if (lastEvent?.type === 'teammate_call_anchor_record' && lastEvent.anchorRole === 'response') {
79
+ return {
80
+ shouldReject: true,
81
+ source,
82
+ rejection: 'finalized_after_response_anchor',
83
+ runState,
84
+ currentCourse,
85
+ lastEvent,
86
+ };
87
+ }
88
+ if (!explicitInterruptedResumeAllowed && !supplyResponseParentReviveAllowed) {
89
+ return {
90
+ shouldReject: true,
91
+ source,
92
+ rejection: 'missing_explicit_interrupted_resume_entitlement',
93
+ runState,
94
+ currentCourse,
95
+ lastEvent,
96
+ };
97
+ }
98
+ return {
99
+ shouldReject: false,
100
+ source,
101
+ runState,
102
+ currentCourse,
103
+ lastEvent,
104
+ };
105
+ }
52
106
  function resolveEffectivePrompt(dialog, humanPrompt) {
53
107
  if (humanPrompt) {
54
108
  return humanPrompt;
@@ -82,6 +136,7 @@ async function executeDriveRound(args) {
82
136
  let driveResult;
83
137
  let subdialogReplyTarget;
84
138
  const allowResumeFromInterrupted = driveOptions?.allowResumeFromInterrupted === true || humanPrompt?.origin === 'user';
139
+ const driveSource = resolveDriveRequestSource(humanPrompt, driveOptions);
85
140
  try {
86
141
  // Prime active-run registration right after acquiring dialog lock so user stop can
87
142
  // reliably interrupt queued auto-revive drives during preflight.
@@ -125,6 +180,38 @@ async function executeDriveRound(args) {
125
180
  // suspended by pending Q4H or subdialogs. This prevents duplicate generations when
126
181
  // multiple wake-ups race around the same subdialog completion boundary.
127
182
  if (!humanPrompt) {
183
+ if (dialog instanceof dialog_1.SubDialog && !dialog.hasUpNext()) {
184
+ try {
185
+ const inspection = await inspectNoPromptSubdialogDrive({ dialog, driveOptions });
186
+ if (inspection.shouldReject) {
187
+ log_1.log.error('Rejected unexpected no-prompt subdialog drive request', undefined, {
188
+ dialogId: dialog.id.valueOf(),
189
+ rootId: dialog.id.rootId,
190
+ selfId: dialog.id.selfId,
191
+ source: inspection.source,
192
+ reason: driveOptions?.reason ?? null,
193
+ rejection: inspection.rejection,
194
+ allowResumeFromInterrupted: driveOptions?.allowResumeFromInterrupted === true,
195
+ runState: inspection.runState ?? null,
196
+ currentCourse: inspection.currentCourse,
197
+ lastEvent: inspection.lastEvent ?? null,
198
+ waitInQue,
199
+ });
200
+ return;
201
+ }
202
+ }
203
+ catch (err) {
204
+ log_1.log.error('Failed to inspect unexpected no-prompt subdialog drive request', err, {
205
+ dialogId: dialog.id.valueOf(),
206
+ rootId: dialog.id.rootId,
207
+ selfId: dialog.id.selfId,
208
+ source: driveSource,
209
+ reason: driveOptions?.reason ?? null,
210
+ allowResumeFromInterrupted: driveOptions?.allowResumeFromInterrupted === true,
211
+ });
212
+ return;
213
+ }
214
+ }
128
215
  const suspension = await dialog.getSuspensionStatus();
129
216
  if (!suspension.canDrive) {
130
217
  const lastTrigger = dialog_global_registry_1.globalDialogRegistry.getLastDriveTrigger(dialog.id.rootId);
@@ -149,6 +236,8 @@ async function executeDriveRound(args) {
149
236
  nextNeedsDrive: lastTrigger.nextNeedsDrive,
150
237
  }
151
238
  : null,
239
+ source: driveSource,
240
+ reason: driveOptions?.reason ?? null,
152
241
  });
153
242
  return;
154
243
  }
@@ -333,6 +422,10 @@ async function executeDriveRound(args) {
333
422
  if (followUp) {
334
423
  args.scheduleDrive(dialog, {
335
424
  waitInQue: true,
425
+ driveOptions: {
426
+ source: 'kernel_driver_follow_up',
427
+ reason: 'follow_up_prompt',
428
+ },
336
429
  humanPrompt: {
337
430
  content: followUp.prompt,
338
431
  msgId: followUp.msgId,
@@ -34,7 +34,10 @@ async function driveQueuedDialogsOnce() {
34
34
  if (!(await rootDialog.canDrive())) {
35
35
  continue;
36
36
  }
37
- await (0, engine_1.driveDialogStream)(rootDialog, undefined, true);
37
+ await (0, engine_1.driveDialogStream)(rootDialog, undefined, true, {
38
+ source: 'kernel_driver_backend_loop',
39
+ reason: 'global_dialog_registry_needs_drive',
40
+ });
38
41
  const status = await rootDialog.getSuspensionStatus();
39
42
  const shouldStayQueued = rootDialog.hasUpNext() || !status.canDrive;
40
43
  if (shouldStayQueued) {
@@ -356,7 +356,11 @@ async function supplyResponseToSupdialog(args) {
356
356
  if (!isRoot || !hasRegistryEntry) {
357
357
  scheduleDrive(parentDialog, {
358
358
  waitInQue: true,
359
- driveOptions: { suppressDiligencePush: parentDialog.disableDiligencePush },
359
+ driveOptions: {
360
+ suppressDiligencePush: parentDialog.disableDiligencePush,
361
+ source: 'kernel_driver_supply_response_parent_revive',
362
+ reason: `all_pending_subdialogs_resolved:type_${callType}`,
363
+ },
360
364
  });
361
365
  }
362
366
  }
@@ -594,7 +594,14 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
594
594
  : {}),
595
595
  };
596
596
  try {
597
- await callbacks.driveDialog(sub, { humanPrompt: initPrompt, waitInQue: true });
597
+ await callbacks.driveDialog(sub, {
598
+ humanPrompt: initPrompt,
599
+ waitInQue: true,
600
+ driveOptions: {
601
+ source: 'kernel_driver_fbr_subdialog_round',
602
+ reason: `fbr_round_${i}_of_${fbrEffort}`,
603
+ },
604
+ });
598
605
  }
599
606
  catch (error) {
600
607
  const detail = error instanceof Error ? error.message : String(error);
@@ -668,7 +675,14 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
668
675
  grammar: 'markdown',
669
676
  origin: 'runtime',
670
677
  };
671
- await callbacks.driveDialog(supdialog, { humanPrompt: supPrompt, waitInQue: true });
678
+ await callbacks.driveDialog(supdialog, {
679
+ humanPrompt: supPrompt,
680
+ waitInQue: true,
681
+ driveOptions: {
682
+ source: 'kernel_driver_type_a_supdialog_call',
683
+ reason: 'type_a_supdialog_roundtrip',
684
+ },
685
+ });
672
686
  const responseText = await extractSupdialogResponseForTypeA(supdialog);
673
687
  const responseContent = (0, inter_dialog_format_1.formatTeammateResponseContent)({
674
688
  callName,
@@ -793,7 +807,14 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
793
807
  callId,
794
808
  },
795
809
  };
796
- callbacks.scheduleDrive(sub, { humanPrompt: initPrompt, waitInQue: true });
810
+ callbacks.scheduleDrive(sub, {
811
+ humanPrompt: initPrompt,
812
+ waitInQue: true,
813
+ driveOptions: {
814
+ source: 'kernel_driver_subdialog_init',
815
+ reason: 'type_b_fallback_subdialog_init',
816
+ },
817
+ });
797
818
  subdialogsCreated.push(sub.id);
798
819
  suspend = true;
799
820
  }
@@ -877,7 +898,14 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
877
898
  callId,
878
899
  },
879
900
  };
880
- callbacks.scheduleDrive(result.subdialog, { humanPrompt: resumePrompt, waitInQue: true });
901
+ callbacks.scheduleDrive(result.subdialog, {
902
+ humanPrompt: resumePrompt,
903
+ waitInQue: true,
904
+ driveOptions: {
905
+ source: 'kernel_driver_subdialog_resume',
906
+ reason: 'type_b_registered_subdialog_resume',
907
+ },
908
+ });
881
909
  }
882
910
  else {
883
911
  const initPrompt = {
@@ -900,7 +928,14 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
900
928
  callId,
901
929
  },
902
930
  };
903
- callbacks.scheduleDrive(result.subdialog, { humanPrompt: initPrompt, waitInQue: true });
931
+ callbacks.scheduleDrive(result.subdialog, {
932
+ humanPrompt: initPrompt,
933
+ waitInQue: true,
934
+ driveOptions: {
935
+ source: 'kernel_driver_subdialog_init',
936
+ reason: 'type_b_registered_subdialog_init',
937
+ },
938
+ });
904
939
  }
905
940
  subdialogsCreated.push(result.subdialog.id);
906
941
  suspend = true;
@@ -949,7 +984,14 @@ async function executeTellaskCall(dlg, agent, mentionList, body, callId, callbac
949
984
  callId,
950
985
  },
951
986
  };
952
- callbacks.scheduleDrive(sub, { humanPrompt: initPrompt, waitInQue: true });
987
+ callbacks.scheduleDrive(sub, {
988
+ humanPrompt: initPrompt,
989
+ waitInQue: true,
990
+ driveOptions: {
991
+ source: 'kernel_driver_subdialog_init',
992
+ reason: 'type_c_subdialog_init',
993
+ },
994
+ });
953
995
  subdialogsCreated.push(sub.id);
954
996
  suspend = true;
955
997
  }
@@ -451,7 +451,10 @@ async function maybeTriggerImmediateDiligencePrompt(rootDialog) {
451
451
  });
452
452
  }
453
453
  if (prepared.kind === 'prompt') {
454
- await (0, kernel_driver_1.driveDialogStream)(rootDialog, prepared.prompt, true);
454
+ await (0, kernel_driver_1.driveDialogStream)(rootDialog, prepared.prompt, true, {
455
+ source: 'ws_diligence_push',
456
+ reason: 'enable_keep_going_immediate_prompt',
457
+ });
455
458
  }
456
459
  }
457
460
  catch (error) {
@@ -1008,7 +1011,10 @@ async function handleUserMsg2Dlg(ws, packet) {
1008
1011
  grammar: effectivePrompt.grammar,
1009
1012
  userLanguageCode: effectivePrompt.userLanguageCode,
1010
1013
  origin: 'user',
1011
- }, true, undefined);
1014
+ }, true, {
1015
+ source: 'ws_user_message',
1016
+ reason: 'drive_dlg_by_user_msg',
1017
+ });
1012
1018
  return;
1013
1019
  }
1014
1020
  // Dialog not found in wsLiveDlg - drive using the canonical root/subdialog instances.
@@ -1038,7 +1044,10 @@ async function handleUserMsg2Dlg(ws, packet) {
1038
1044
  grammar: effectivePrompt.grammar,
1039
1045
  userLanguageCode: effectivePrompt.userLanguageCode,
1040
1046
  origin: 'user',
1041
- }, true, undefined);
1047
+ }, true, {
1048
+ source: 'ws_user_message',
1049
+ reason: 'drive_dlg_by_user_msg',
1050
+ });
1042
1051
  return;
1043
1052
  }
1044
1053
  catch (restoreError) {
@@ -1116,7 +1125,11 @@ async function handleResumeDialog(ws, packet) {
1116
1125
  return;
1117
1126
  }
1118
1127
  const restored = await restoreDialogForDrive(dialogIdObj, 'running');
1119
- await (0, kernel_driver_1.driveDialogStream)(restored, undefined, true, { allowResumeFromInterrupted: true });
1128
+ await (0, kernel_driver_1.driveDialogStream)(restored, undefined, true, {
1129
+ allowResumeFromInterrupted: true,
1130
+ source: 'ws_resume_dialog',
1131
+ reason: 'resume_dialog',
1132
+ });
1120
1133
  }
1121
1134
  async function handleResumeAll(ws, packet) {
1122
1135
  if (packet.type !== 'resume_all') {
@@ -1131,7 +1144,11 @@ async function handleResumeAll(ws, packet) {
1131
1144
  void (async () => {
1132
1145
  try {
1133
1146
  const dlg = await restoreDialogForDrive(id, 'running');
1134
- await (0, kernel_driver_1.driveDialogStream)(dlg, undefined, true, { allowResumeFromInterrupted: true });
1147
+ await (0, kernel_driver_1.driveDialogStream)(dlg, undefined, true, {
1148
+ allowResumeFromInterrupted: true,
1149
+ source: 'ws_resume_all',
1150
+ reason: 'resume_all',
1151
+ });
1135
1152
  }
1136
1153
  catch (err) {
1137
1154
  log.warn('resume_all: failed to resume dialog', err, { dialogId: id.valueOf() });
@@ -1250,7 +1267,10 @@ async function handleUserAnswer2Q4H(ws, packet) {
1250
1267
  userLanguageCode: effectivePrompt.userLanguageCode,
1251
1268
  q4hAnswerCallIds: askHumanCallIds,
1252
1269
  origin: 'user',
1253
- }, true, undefined);
1270
+ }, true, {
1271
+ source: 'ws_user_answer',
1272
+ reason: 'drive_dialog_by_user_answer',
1273
+ });
1254
1274
  }
1255
1275
  catch (error) {
1256
1276
  log.error('Error processing Q4H user answer:', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dominds",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "DevOps Mindsets — Sustainable Agentic Product Lifecycle",
5
5
  "type": "commonjs",
6
6
  "private": false,