@evident-ai/cli 3.4.1-dev.c6e7cf0 → 3.4.1-dev.d8ffc5f

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.
package/dist/index.js CHANGED
@@ -2451,7 +2451,7 @@ function isPreamblePinnedRunning(messages, userMessageId) {
2451
2451
  return completedOf(reply) != null && finishOf(reply) === "tool-calls";
2452
2452
  }
2453
2453
  function isB2AbandonmentConfirmed(params) {
2454
- return params.pinnedForMs >= params.minPinnedMs && params.descendantOngoing === false;
2454
+ return params.pinnedForMs >= params.minPinnedMs && params.descendantOngoing === false && params.rootOngoing === false;
2455
2455
  }
2456
2456
  function isAmbiguousTerminalFinish(m) {
2457
2457
  if (completedOf(m) == null) return false;
@@ -2464,7 +2464,7 @@ function isAmbiguousFinishPinnedRunning(messages, userMessageId) {
2464
2464
  return isAmbiguousTerminalFinish(reply);
2465
2465
  }
2466
2466
  function isAmbiguousFinishResolved(params) {
2467
- return params.sessionOngoing === false || params.pinnedForMs >= params.maxPinnedMs;
2467
+ return params.sessionOngoing === false || params.sessionOngoing !== true && params.pinnedForMs >= params.maxPinnedMs;
2468
2468
  }
2469
2469
  function messageError(messages, userMessageId) {
2470
2470
  const reply = findLastAssistantReplyFor(messages, userMessageId);
@@ -5740,6 +5740,7 @@ var ChannelDriver = class _ChannelDriver {
5740
5740
  deliveryDeadlineAnchored: false,
5741
5741
  b2PinnedSinceMs: 0,
5742
5742
  b2LastDescendantCheckMs: 0,
5743
+ b2RootOngoingHeldLogged: false,
5743
5744
  b2AbandonedSignalled: false,
5744
5745
  ambiguousPinnedSinceMs: 0,
5745
5746
  ambiguousResolved: false
@@ -5834,6 +5835,7 @@ var ChannelDriver = class _ChannelDriver {
5834
5835
  deliveryDeadlineAnchored: false,
5835
5836
  b2PinnedSinceMs: 0,
5836
5837
  b2LastDescendantCheckMs: 0,
5838
+ b2RootOngoingHeldLogged: false,
5837
5839
  b2AbandonedSignalled: false,
5838
5840
  ambiguousPinnedSinceMs: 0,
5839
5841
  ambiguousResolved: false
@@ -6187,6 +6189,7 @@ var ChannelDriver = class _ChannelDriver {
6187
6189
  if (snapshotReadable) {
6188
6190
  inFlight.b2PinnedSinceMs = 0;
6189
6191
  inFlight.b2LastDescendantCheckMs = 0;
6192
+ inFlight.b2RootOngoingHeldLogged = false;
6190
6193
  inFlight.b2AbandonedSignalled = false;
6191
6194
  }
6192
6195
  } else {
@@ -6198,11 +6201,15 @@ var ChannelDriver = class _ChannelDriver {
6198
6201
  const pinnedForMs = this.now() - inFlight.b2PinnedSinceMs;
6199
6202
  if (pinnedForMs >= B2_ABANDONMENT_MIN_PINNED_MS && this.now() - inFlight.b2LastDescendantCheckMs >= B2_ABANDONMENT_RECHECK_MS) {
6200
6203
  inFlight.b2LastDescendantCheckMs = this.now();
6201
- const descendantOngoing = await this.isAnyDescendantSessionOngoing(sessionId);
6204
+ const [descendantOngoing, rootOngoing] = await Promise.all([
6205
+ this.isAnyDescendantSessionOngoing(sessionId),
6206
+ isSessionOngoing(this.port, sessionId)
6207
+ ]);
6202
6208
  if (isB2AbandonmentConfirmed({
6203
6209
  pinnedForMs,
6204
6210
  minPinnedMs: B2_ABANDONMENT_MIN_PINNED_MS,
6205
- descendantOngoing
6211
+ descendantOngoing,
6212
+ rootOngoing
6206
6213
  })) {
6207
6214
  inFlight.b2AbandonedSignalled = true;
6208
6215
  this.log({
@@ -6211,12 +6218,26 @@ var ChannelDriver = class _ChannelDriver {
6211
6218
  conversation_id: conv.id,
6212
6219
  message_id: id
6213
6220
  });
6221
+ const reply = findLastAssistantReplyFor(messages, inFlight.opencodeMessageId);
6214
6222
  void this.postSignal(conv.id, id, "b2_abandoned_resolved", {
6215
- watched_for_ms: pinnedForMs
6223
+ watched_for_ms: pinnedForMs,
6224
+ finish: reply?.info?.finish ?? reply?.finish,
6225
+ ...rootOngoing != null ? { root_ongoing: rootOngoing } : {},
6226
+ ...descendantOngoing != null ? { descendant_ongoing: descendantOngoing } : {},
6227
+ opencode_message_id: inFlight.opencodeMessageId
6216
6228
  });
6217
6229
  await this.settleMessageDone(sessionId, watcher, inFlight, messages);
6218
6230
  return;
6219
6231
  }
6232
+ if (rootOngoing === true && !inFlight.b2RootOngoingHeldLogged) {
6233
+ inFlight.b2RootOngoingHeldLogged = true;
6234
+ this.log({
6235
+ level: "warn",
6236
+ message: `Message ${id.slice(0, 8)} b2-pinned for ${Math.round(pinnedForMs / 1e3)}s with root_ongoing=${rootOngoing} and descendant_ongoing=${descendantOngoing} \u2014 holding until OpenCode confirms the root is idle`,
6237
+ conversation_id: conv.id,
6238
+ message_id: id
6239
+ });
6240
+ }
6220
6241
  }
6221
6242
  }
6222
6243
  const ambiguousPinnedNow = activelyRunning && isAmbiguousFinishPinnedRunning(messages, inFlight.opencodeMessageId);