@tangle-network/agent-runtime 0.333.0 → 0.334.0

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 (53) hide show
  1. package/dist/{activation-Vw-UZJv6.js → activation-CVW7l4F3.js} +2 -2
  2. package/dist/{activation-Vw-UZJv6.js.map → activation-CVW7l4F3.js.map} +1 -1
  3. package/dist/{activation-BGZ0rVuv.d.ts → activation-D64x9f07.d.ts} +2 -2
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +2 -2
  6. package/dist/{coordination-driver-B6gob9rN.js → coordination-driver-D36spfRN.js} +22 -11
  7. package/dist/coordination-driver-D36spfRN.js.map +1 -0
  8. package/dist/{delegate-C8yWI1p2.js → delegate-DGPYLJLx.js} +2 -2
  9. package/dist/{delegate-C8yWI1p2.js.map → delegate-DGPYLJLx.js.map} +1 -1
  10. package/dist/durable.d.ts +1 -1
  11. package/dist/durable.js +3 -3
  12. package/dist/{graph-SJbUv3UT.js → graph-CnjWiqlB.js} +4 -4
  13. package/dist/{graph-SJbUv3UT.js.map → graph-CnjWiqlB.js.map} +1 -1
  14. package/dist/{improvement-cycle-6n7s5xCm.js → improvement-cycle-BC6GXcYl.js} +3 -3
  15. package/dist/{improvement-cycle-6n7s5xCm.js.map → improvement-cycle-BC6GXcYl.js.map} +1 -1
  16. package/dist/index.d.ts +4 -4
  17. package/dist/index.js +7 -7
  18. package/dist/intelligence.d.ts +2 -2
  19. package/dist/intelligence.js +3 -3
  20. package/dist/kernel.d.ts +1 -1
  21. package/dist/kernel.js +8 -8
  22. package/dist/{loop-runner-bin-3OdukLK8.js → loop-runner-bin-D3nU-Wp0.js} +3 -3
  23. package/dist/{loop-runner-bin-3OdukLK8.js.map → loop-runner-bin-D3nU-Wp0.js.map} +1 -1
  24. package/dist/{loop-runner-bin-CaH_49Ts.d.ts → loop-runner-bin-DpH55EFc.d.ts} +2 -2
  25. package/dist/loop-runner-bin.d.ts +1 -1
  26. package/dist/loop-runner-bin.js +1 -1
  27. package/dist/mcp/bin.js +3 -3
  28. package/dist/mcp/index.d.ts +2 -2
  29. package/dist/mcp/index.js +4 -4
  30. package/dist/{openai-tools-BhO6-5ff.d.ts → openai-tools-D8eHMvNr.d.ts} +2 -2
  31. package/dist/profiles.d.ts +1 -1
  32. package/dist/{provision-supervisor-DUtSy0yS.js → provision-supervisor-C1FQ2uIe.js} +3 -3
  33. package/dist/{provision-supervisor-DUtSy0yS.js.map → provision-supervisor-C1FQ2uIe.js.map} +1 -1
  34. package/dist/{runtime-PcxLUbUI.js → runtime-Cff0UnPw.js} +66 -16
  35. package/dist/runtime-Cff0UnPw.js.map +1 -0
  36. package/dist/{search-executor-THPHYkHm.js → search-executor-CFqHN4Dt.js} +2 -2
  37. package/dist/{search-executor-THPHYkHm.js.map → search-executor-CFqHN4Dt.js.map} +1 -1
  38. package/dist/{server-C-bJwSlH.js → server-CFIzBMYb.js} +3 -3
  39. package/dist/{server-C-bJwSlH.js.map → server-CFIzBMYb.js.map} +1 -1
  40. package/dist/{supervise-CrZSI8RM.js → supervise-Dl2rTArD.js} +53 -8
  41. package/dist/supervise-Dl2rTArD.js.map +1 -0
  42. package/dist/{supervisor-BfIZXA7e.js → supervisor-BObk9STz.js} +144 -18
  43. package/dist/supervisor-BObk9STz.js.map +1 -0
  44. package/dist/testing.d.ts +1 -1
  45. package/dist/testing.js +12 -12
  46. package/dist/tui/index.d.ts +1 -1
  47. package/dist/tui/index.js +1 -1
  48. package/dist/{types-CsDKtdE3.d.ts → types-Dkx4dbaX.d.ts} +15 -3
  49. package/package.json +3 -3
  50. package/dist/coordination-driver-B6gob9rN.js.map +0 -1
  51. package/dist/runtime-PcxLUbUI.js.map +0 -1
  52. package/dist/supervise-CrZSI8RM.js.map +0 -1
  53. package/dist/supervisor-BfIZXA7e.js.map +0 -1
@@ -3654,14 +3654,19 @@ function cappedDoublingMs(consecutive, first, ceiling) {
3654
3654
  const start = Math.max(0, first);
3655
3655
  return Math.min(Math.max(start, ceiling), start * 2 ** Math.max(0, consecutive - 1));
3656
3656
  }
3657
+ /** How often a refusal whose reset is beyond {@link MAX_RESET_HOLD_MS} is probed again. */
3658
+ const FAR_RESET_PROBE_MS = 60 * 6e4;
3657
3659
  /**
3658
3660
  * When a refusal says its quota resets, as epoch ms, or `undefined` when it names no usable time.
3659
3661
  * The Z.ai Coding Plan's opencode refusal names one in Beijing time with no zone:
3660
3662
  * `Usage limit reached for 5 hour. Your limit will reset at 2026-10-18 15:17:33`. On Discovery run
3661
3663
  * magnetar-rust-20261018b, 219 of 324 driver attempts ended on it between 06:04Z and 22:18Z, and
3662
3664
  * the last refusal came at 22:18Z against `reset at 2026-10-19 06:18:14`, which is 22:18:14Z at
3663
- * +08:00. A time with its own zone is read as written. A time in the past, or more than
3664
- * MAX_RESET_HOLD_MS ahead, is no reset time: the caller keeps its doubling pause.
3665
+ * +08:00. A time with its own zone is read as written. A time in the past is no reset time: the
3666
+ * caller keeps its doubling pause. A time more than MAX_RESET_HOLD_MS ahead is held for only
3667
+ * FAR_RESET_PROBE_MS at a time, so a misread zone cannot hold a seat for a day, yet the spent seat
3668
+ * is not asked again every 5 minutes: on magnetar-rust-20261019c a reset beyond 6 h drew about 12
3669
+ * attempts an hour against the refusing seat.
3665
3670
  */
3666
3671
  function unavailableResumeAt(text, nowMs) {
3667
3672
  const match = text.match(/\breset at (\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}:\d{2})(?:\.\d+)?(Z|[+-]\d{2}:?\d{2})?/u);
@@ -3669,8 +3674,8 @@ function unavailableResumeAt(text, nowMs) {
3669
3674
  const zone = match[3] ?? (/Usage limit reached for \d+ hour/u.test(text) ? "+08:00" : void 0);
3670
3675
  if (zone === void 0) return void 0;
3671
3676
  const at = Date.parse(`${match[1]}T${match[2]}${zone.length === 5 ? `${zone.slice(0, 3)}:${zone.slice(3)}` : zone}`);
3672
- if (!Number.isFinite(at) || at <= nowMs || at - nowMs > 216e5) return void 0;
3673
- return at;
3677
+ if (!Number.isFinite(at) || at <= nowMs) return void 0;
3678
+ return at - nowMs > 216e5 ? nowMs + FAR_RESET_PROBE_MS : at;
3674
3679
  }
3675
3680
  /**
3676
3681
  * Spread a wait over `[ms / 2, ms]`. Every driver a Platform restart cut off fails within the same
@@ -3743,6 +3748,26 @@ const causeMessages = {
3743
3748
  * Nothing ran for the request.
3744
3749
  */
3745
3750
  const DISPATCH_NOT_ADMITTED_CODE = "DISPATCH_NOT_ADMITTED";
3751
+ /**
3752
+ * The Sandbox SDK's codes for a box that cannot be provisioned for this profile, sent with HTTP
3753
+ * 422 when the failure is deterministic: a profile file mount outside the box's writable roots,
3754
+ * refused before any box exists, and a profile-file materialization that would fail the same way
3755
+ * again. On Discovery run queens21-h22-capture-root-1-20261019c every child profile mounted
3756
+ * `/work/queens21_count.c` on a read-only root filesystem, and 154 attempts across 4 workers were
3757
+ * retried as a lost transport. The same codes at another status may be transient and are not
3758
+ * read here.
3759
+ */
3760
+ const PROVISIONING_REFUSAL_CODES = /* @__PURE__ */ new Set(["PROFILE_FILE_MOUNT_OUTSIDE_ROOTS", "PROFILE_FILES_MATERIALIZE_FAILED"]);
3761
+ /** True for an error that is itself a deterministic provisioning refusal (see above). */
3762
+ function isProvisioningRefusal(value) {
3763
+ try {
3764
+ const code = readString(value, "code");
3765
+ const status = readNumber(value, "status") ?? readNumber(value, "statusCode");
3766
+ return code !== void 0 && status === 422 && PROVISIONING_REFUSAL_CODES.has(code);
3767
+ } catch {
3768
+ return false;
3769
+ }
3770
+ }
3746
3771
  /** The contract-error codes that wrap a failed READ rather than name a broken answer. */
3747
3772
  const readFailureCodes = /* @__PURE__ */ new Set(["RETAINED_RESULT_READ_FAILED", "RETAINED_CONTROL_REF_READ_FAILED"]);
3748
3773
  /** Socket-level failures, by the codes Node and undici assign, plus the Sandbox SDK's own. */
@@ -3810,6 +3835,7 @@ function classifyPendingCause(cause, phase, onCredentialRefusal) {
3810
3835
  }
3811
3836
  if (name === "ZodError" || Array.isArray(Reflect.get(value, "issues")) || code === "JSON_BOUND_VIOLATION") return at === "admission" ? "request-rejected" : "provider-contract";
3812
3837
  if (code === "DISPATCH_NOT_ADMITTED") return at === "admission" ? "request-rejected" : "provider-contract";
3838
+ if (isProvisioningRefusal(value)) return "request-rejected";
3813
3839
  if (isCredentialRefusal(value)) {
3814
3840
  if (at === "execution") return "unobservable";
3815
3841
  onCredentialRefusal?.();
@@ -10133,6 +10159,14 @@ function normalizeWorkerSlotBound(value) {
10133
10159
  if (!Number.isSafeInteger(value)) throw new ValidationError$1(`workerSlots must be a positive safe integer, or 0 or less for no bound, got ${String(value)}`);
10134
10160
  return value;
10135
10161
  }
10162
+ /** At most this many stage entries are kept from a port, each a finite, non-negative number. */
10163
+ const MAX_CAPTURE_STAGES = 16;
10164
+ function captureStages(value) {
10165
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return void 0;
10166
+ const stages = {};
10167
+ for (const [name, amount] of Object.entries(value).slice(0, MAX_CAPTURE_STAGES)) if (/^[A-Za-z][A-Za-z0-9]{0,63}$/u.test(name) && Number.isFinite(amount) && amount >= 0) stages[name] = amount;
10168
+ return Object.keys(stages).length === 0 ? void 0 : Object.freeze(stages);
10169
+ }
10136
10170
  const checkpointSlotKeys = /* @__PURE__ */ new WeakMap();
10137
10171
  function checkpointSlots(port) {
10138
10172
  let key = checkpointSlotKeys.get(port);
@@ -10323,9 +10357,9 @@ function trackCapture(port, work) {
10323
10357
  * bound, and judges coverage by the sessions alone. `onTiming` receives the queue wait and the
10324
10358
  * capture time of a workspace capture once it settles, whether it succeeded or failed.
10325
10359
  */
10326
- async function captureProviderWorkspaceSnapshot(port, context, scope = "environment", onTiming) {
10360
+ async function captureProviderWorkspaceSnapshot(port, context, scope = "environment", onTiming, parent) {
10327
10361
  assertProviderWorkspaceRetentionPort(port, "provider workspace retention");
10328
- if (scope === "native" || onTiming === void 0) return await captureWithinSlot(port, context, scope);
10362
+ if (scope === "native" || onTiming === void 0) return await captureWithinSlot(port, context, scope, void 0, parent);
10329
10363
  return await trackCapture(port, async (ahead) => {
10330
10364
  const requestedAt = Date.now();
10331
10365
  let grantedAt;
@@ -10346,7 +10380,8 @@ async function captureProviderWorkspaceSnapshot(port, context, scope = "environm
10346
10380
  });
10347
10381
  report({
10348
10382
  outcome: "captured",
10349
- archiveBytes: captured.snapshot.archive.byteLength
10383
+ archiveBytes: captured.snapshot.archive.byteLength,
10384
+ ...captured.stages === void 0 ? {} : { stages: captured.stages }
10350
10385
  });
10351
10386
  return captured;
10352
10387
  } catch (error) {
@@ -10358,7 +10393,7 @@ async function captureProviderWorkspaceSnapshot(port, context, scope = "environm
10358
10393
  }
10359
10394
  });
10360
10395
  }
10361
- async function captureWithinSlot(port, context, scope, onGranted) {
10396
+ async function captureWithinSlot(port, context, scope, onGranted, parent) {
10362
10397
  const native = scope === "native";
10363
10398
  if (native && port.captureNative === void 0) throw new ValidationError$1("provider workspace retention: the port has no captureNative");
10364
10399
  const timeoutMs = native ? port.nativeTimeoutMs ?? 12e4 : port.timeoutMs;
@@ -10366,6 +10401,9 @@ async function captureWithinSlot(port, context, scope, onGranted) {
10366
10401
  if (controlRef !== void 0 && (controlRef.environmentId !== context.environment.id || controlRef.provider !== context.environment.provider || context.providerSessionId != null && controlRef.sessionId !== context.providerSessionId)) throw new Error("provider workspace retention control reference names another environment or session");
10367
10402
  const controller = new AbortController();
10368
10403
  const clearDeadline = armDeadlineTimer(timeoutMs, () => controller.abort(/* @__PURE__ */ new Error(`provider workspace retention timed out after ${timeoutMs}ms`)), true);
10404
+ const stopFromParent = () => controller.abort(parent?.reason);
10405
+ if (parent?.aborted) stopFromParent();
10406
+ else parent?.addEventListener("abort", stopFromParent, { once: true });
10369
10407
  try {
10370
10408
  return await runAbortable(() => withCaptureSlot(native ? nativeSlots(port) : port, controller.signal, async () => {
10371
10409
  onGranted?.();
@@ -10425,15 +10463,18 @@ async function captureWithinSlot(port, context, scope, onGranted) {
10425
10463
  ...port.limits === void 0 ? {} : { limits: port.limits }
10426
10464
  });
10427
10465
  }
10466
+ const stages = "snapshot" in result ? captureStages(result.stages) : void 0;
10428
10467
  return {
10429
10468
  snapshot,
10430
10469
  provenance,
10431
10470
  coverageComplete,
10471
+ ...stages === void 0 ? {} : { stages },
10432
10472
  ...coverageComplete ? {} : { incompleteReason: `provider workspace retention coverage incomplete: ${coverageGaps.join("; ")}` }
10433
10473
  };
10434
10474
  }), controller.signal, `provider workspace retention timed out after ${timeoutMs}ms`);
10435
10475
  } finally {
10436
10476
  clearDeadline();
10477
+ parent?.removeEventListener("abort", stopFromParent);
10437
10478
  }
10438
10479
  }
10439
10480
  /** Reconcile Sidecar attempts to the exact captured session executions. */
@@ -12408,7 +12449,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12408
12449
  executionId: capturedExecutionId,
12409
12450
  environmentId: next.id
12410
12451
  }).catch(() => void 0) ?? Promise.resolve();
12411
- workspaceCapturePromise = Promise.all([nativeInFlight, liveInFlight]).then(() => captureProviderWorkspaceSnapshot(workspaceRetention, captureContext, "environment", reportTiming === void 0 ? void 0 : (measured) => {
12452
+ workspaceCapturePromise = Promise.all([nativeRunningInFlight, liveInFlight]).then(() => captureProviderWorkspaceSnapshot(workspaceRetention, captureContext, "environment", reportTiming === void 0 ? void 0 : (measured) => {
12412
12453
  timing = measured;
12413
12454
  })).finally(async () => {
12414
12455
  await started;
@@ -12462,6 +12503,8 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12462
12503
  };
12463
12504
  const nativePort = options.workspaceRetention?.captureNative === void 0 ? void 0 : options.workspaceRetention;
12464
12505
  let nativeInFlight;
12506
+ let nativeRunningInFlight;
12507
+ let nativeRunningStop;
12465
12508
  let nativeTimer;
12466
12509
  let nativeEvents = 0;
12467
12510
  let nativeEventsAtCopy;
@@ -12522,12 +12565,17 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12522
12565
  nativeTimer = void 0;
12523
12566
  closeNativeMirror?.();
12524
12567
  closeNativeMirror = void 0;
12568
+ nativeRunningStop?.abort(/* @__PURE__ */ new Error("native session copy stopped: its turn ended"));
12569
+ nativeRunningStop = void 0;
12525
12570
  await nativeInFlight;
12526
12571
  };
12527
12572
  const captureNative = (next, phase, admitted, afterStop = false) => {
12528
12573
  if (nativePort === void 0 || createProfile.harness === void 0) return Promise.resolve();
12529
12574
  const harness = createProfile.harness;
12575
+ const stop = phase === "running" ? new AbortController() : void 0;
12576
+ if (stop !== void 0) nativeRunningStop = stop;
12530
12577
  const tracked = (nativeInFlight ?? Promise.resolve()).then(async () => {
12578
+ stop?.signal.throwIfAborted();
12531
12579
  const controlRef = workspaceControlRef ?? admitted;
12532
12580
  const sessionId = providerSessionId ?? admitted?.sessionId ?? null;
12533
12581
  if (workspaceSnapshot !== void 0 && !nativeHoldsTranscript) return;
@@ -12544,7 +12592,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12544
12592
  nativeSessionId: null,
12545
12593
  profile: createProfile,
12546
12594
  phase
12547
- }, "native");
12595
+ }, "native", void 0, stop?.signal);
12548
12596
  let captured = await takeCopy();
12549
12597
  const settleBy = Date.now() + NATIVE_SETTLE_WINDOW_MS;
12550
12598
  while (afterStop && captured.coverageComplete !== true && (captured.provenance.attempts ?? []).some((attempt) => attempt.outcome === "unknown") && Date.now() < settleBy) {
@@ -12568,14 +12616,18 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12568
12616
  nativeHoldsTranscript = true;
12569
12617
  nativeEventsAtCopy = eventsAtStart;
12570
12618
  } catch (error) {
12619
+ if (stop?.signal.aborted) return;
12571
12620
  noteCaptureFailure(error);
12572
12621
  } finally {
12573
12622
  lastNativeCopyMs = Date.now() - copyStartedAt;
12574
12623
  }
12575
- }).finally(() => {
12624
+ }).catch(() => void 0).finally(() => {
12576
12625
  if (nativeInFlight === tracked) nativeInFlight = void 0;
12626
+ if (nativeRunningInFlight === tracked) nativeRunningInFlight = void 0;
12627
+ if (nativeRunningStop === stop) nativeRunningStop = void 0;
12577
12628
  });
12578
12629
  nativeInFlight = tracked;
12630
+ if (stop !== void 0) nativeRunningInFlight = tracked;
12579
12631
  return tracked;
12580
12632
  };
12581
12633
  const startNativeMirror = (next) => {
@@ -13142,10 +13194,17 @@ async function* streamProviderExecutor(args) {
13142
13194
  const ownerTakesCapture = () => args.options.workspaceRetention?.captureNative !== void 0 && args.createProfile.harness !== void 0 && source.retained && args.retention?.preserveEnvironment === true && args.retention.onEndOfTurnWork !== void 0;
13143
13195
  const handCaptureToOwner = (reported, captureOutcome, publish, beforeCapture) => {
13144
13196
  args.retention?.onEndOfTurnWork?.((async () => {
13197
+ const finalCopy = (async () => {
13198
+ try {
13199
+ await beforeCapture?.();
13200
+ } catch {}
13201
+ })();
13202
+ let snapshot;
13145
13203
  try {
13146
- await beforeCapture?.();
13147
- } catch {}
13148
- const snapshot = await args.captureWorkspace(environment, captureOutcome);
13204
+ snapshot = await args.captureWorkspace(environment, captureOutcome);
13205
+ } finally {
13206
+ await finalCopy;
13207
+ }
13149
13208
  if (publish) args.onPublishedSnapshot(snapshot);
13150
13209
  if (snapshot === void 0) return;
13151
13210
  await args.retention?.onEvidence?.({
@@ -19365,7 +19424,10 @@ function checkedSeatSelection(stage, selected) {
19365
19424
  * is being burned. Within that window it consumes neither `maxAttempts` nor the barren streak,
19366
19425
  * exactly like a pause, and only the deadline, the budget, and cancellation bound it. After the
19367
19426
  * window the failure bounds apply again, so a dead-on-arrival driver still stops, in minutes
19368
- * rather than hours. A failure that spent tokens without delivering keeps the bounds above,
19427
+ * rather than hours. The exception is a box that was created and then failed its setup (Sandbox's
19428
+ * `PartialFailureError`): it meets the same failure on every re-entry, so a second identical
19429
+ * attempt with no progress stops with `repeated-failure` (`SAME_PARTIAL_FAILURE_LIMIT`). A failure
19430
+ * that spent tokens without delivering keeps the bounds above,
19369
19431
  * because that is the burn the progress rule exists to stop. Measured 2026-10-04 on Discovery run research-nqs-20261003system2: a Platform
19370
19432
  * restart answered `HTTP 502 ... Platform key verification unavailable` from 03:04:34 to 03:09:41Z,
19371
19433
  * and the coordinator's twelve attempts ran out at 03:07:12Z with no token spent, while a sibling
@@ -19395,6 +19457,40 @@ const REPEATED_FAILURE_WINDOW_MS = 5 * 6e4;
19395
19457
  /** Consecutive identical reconciliation failures of one pending invocation that resolve it. */
19396
19458
  const SAME_PENDING_LIMIT = 2;
19397
19459
  /**
19460
+ * Consecutive attempts that end in the same Sandbox `PartialFailureError`, with nothing gained
19461
+ * between them, that stop the loop. That error is a box that was created and then failed its
19462
+ * setup (its profile files would not materialize, it did not become ready). The retained
19463
+ * execution is bound durably to the node, so each re-entry meets the same box and the same
19464
+ * failure. Discovery run queens21-h22-capture-root-1-20261019c re-entered four such boxes 154
19465
+ * times in 37 minutes on `mkdir: cannot create directory '/work': Read-only file system`, one
19466
+ * box per root, each inside the transient-outage window that retries a failure which spent
19467
+ * nothing. A second identical attempt proves what a third would repeat; a different failure, or
19468
+ * any progress, starts the count over.
19469
+ */
19470
+ const SAME_PARTIAL_FAILURE_LIMIT = 2;
19471
+ /** Longest cause chain read for a `PartialFailureError`; the failing box's error sits one or two wrappers down. */
19472
+ const PARTIAL_FAILURE_CAUSE_DEPTH = 6;
19473
+ /**
19474
+ * True when `error` or one of its causes is Sandbox's `PartialFailureError`. Read by name: the
19475
+ * class lives in `@tangle-network/sandbox`, which Runtime does not import, and a failure crosses
19476
+ * packages that may each hold their own copy of it, so `instanceof` would miss it.
19477
+ */
19478
+ function causedByPartialFailure(error) {
19479
+ const seen = /* @__PURE__ */ new Set();
19480
+ let current = error;
19481
+ for (let depth = 0; depth <= PARTIAL_FAILURE_CAUSE_DEPTH; depth += 1) {
19482
+ if (!(current instanceof Error) || seen.has(current)) return false;
19483
+ seen.add(current);
19484
+ try {
19485
+ if (errorProperty(current, "name") === "PartialFailureError") return true;
19486
+ current = current.cause;
19487
+ } catch {
19488
+ return false;
19489
+ }
19490
+ }
19491
+ return false;
19492
+ }
19493
+ /**
19398
19494
  * The pending invocation a failure left, when abandoning it is the resolution: the provider
19399
19495
  * answered and could not resolve the execution (`unobservable`), or a nested manager's recovery
19400
19496
  * could not be rebuilt (`nested-recovery`). A lost transport waits for the provider instead, in
@@ -19522,6 +19618,22 @@ function capacityCode(error) {
19522
19618
  function isUpstreamUnavailable(error) {
19523
19619
  return upstreamUnavailableSignal(error) !== void 0;
19524
19620
  }
19621
+ /** The error and its causes (`cause`, and `errors` members), bounded and cycle-safe. */
19622
+ function causeChain(error) {
19623
+ const chain = [];
19624
+ const queue = [error];
19625
+ while (queue.length > 0 && chain.length < 12) {
19626
+ const value = queue.shift();
19627
+ if (typeof value !== "object" || value === null || chain.includes(value)) continue;
19628
+ chain.push(value);
19629
+ try {
19630
+ const errors = Reflect.get(value, "errors");
19631
+ if (Array.isArray(errors)) queue.push(...errors);
19632
+ queue.push(Reflect.get(value, "cause"));
19633
+ } catch {}
19634
+ }
19635
+ return chain;
19636
+ }
19525
19637
  /**
19526
19638
  * Classify one driver failure. Runtime's own typed refusals are decisions and stay terminal; an
19527
19639
  * upstream capacity refusal is `unavailable`; anything else foreign is an accident and is
@@ -19539,6 +19651,7 @@ function classifyDriverFailure(error, signal) {
19539
19651
  if (error instanceof Error && errorProperty(error, "name") === "AbortError") return "terminal";
19540
19652
  if (error instanceof Error && isProviderSchemaRejection(error)) return "terminal";
19541
19653
  if (isCredentialRefusal(error)) return "terminal";
19654
+ if (causeChain(error).some(isProvisioningRefusal)) return "terminal";
19542
19655
  if (error instanceof HarnessTurnFailedError) {
19543
19656
  if (error.errorCode !== void 0 && DETERMINISTIC_BRIDGE_CODES.has(error.errorCode)) return "terminal";
19544
19657
  if (isUpstreamUnavailable(error)) return "unavailable";
@@ -19712,6 +19825,7 @@ async function runDriverWithRetry(run) {
19712
19825
  let consecutivePauses = 0;
19713
19826
  let samePending;
19714
19827
  let sameFailure;
19828
+ let samePartial;
19715
19829
  let abandonments = 0;
19716
19830
  let pauses = 0;
19717
19831
  let continuations = 0;
@@ -19846,12 +19960,17 @@ async function runDriverWithRetry(run) {
19846
19960
  since: failedAt
19847
19961
  };
19848
19962
  const repeated = sameFailure !== void 0 && sameFailure.count >= REPEATED_FAILURE_LIMIT && failedAt - sameFailure.since >= REPEATED_FAILURE_WINDOW_MS;
19963
+ samePartial = classification === "transient" && !progressed && pending === void 0 && causedByPartialFailure(error) ? {
19964
+ error: failure,
19965
+ count: samePartial?.error === failure ? samePartial.count + 1 : 1
19966
+ } : void 0;
19849
19967
  const stop = (() => {
19850
19968
  if (classification === "terminal") return "terminal-error";
19851
19969
  if (!retryEnabled) return "retry-disabled";
19852
19970
  if (run.signal.aborted) return "aborted";
19853
19971
  const byBudget = budgetStop(run.budget(), failedAt);
19854
19972
  if (byBudget) return byBudget;
19973
+ if (samePartial !== void 0 && samePartial.count >= SAME_PARTIAL_FAILURE_LIMIT) return "repeated-failure";
19855
19974
  if (inOutage) return void 0;
19856
19975
  if (chargedFailures >= maxAttempts) return "max-attempts";
19857
19976
  if (progressed) return repeated ? "repeated-failure" : void 0;
@@ -19909,6 +20028,7 @@ async function runDriverWithRetry(run) {
19909
20028
  outageSince = void 0;
19910
20029
  samePending = void 0;
19911
20030
  sameFailure = void 0;
20031
+ samePartial = void 0;
19912
20032
  abandonments = 0;
19913
20033
  const durationMs = now() - startedAt;
19914
20034
  const after = run.progress();
@@ -28794,7 +28914,7 @@ function createScope(args) {
28794
28914
  const childRun = runChild(live, executor, controller, recovery?.continuation?.task ?? task, opts, args.pool, reservation.ticket, args.blobs, now, args.journal, args.root, () => progressSeq++, materializationCommitted, {
28795
28915
  complete: async () => pendingEvidence?.complete(),
28796
28916
  fail: async () => pendingEvidence?.fail()
28797
- }, childDeadlineAtMs, recovery !== void 0, closeRetainedWrites, budgetGranted, permit.ready, recovery?.continuation?.priorSpent);
28917
+ }, childDeadlineAtMs, recovery !== void 0, closeRetainedWrites, budgetGranted, permit.ready, recovery?.continuation?.priorSpent, startedAt);
28798
28918
  args.pool.attribute(reservation.ticket, { stage: "executing" });
28799
28919
  const interactiveBindingCommitted = spawnCommitted.then(async () => {
28800
28920
  if (args.interactiveBindingDir === void 0) return;
@@ -29839,7 +29959,7 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
29839
29959
  * applied per child). The reservation is reconciled on EVERY path (success, abort, throw)
29840
29960
  * so the conserved pool can never leak a reservation.
29841
29961
  */
29842
- async function runChild(live, executor, childAbort, task, opts, pool, ticket, blobs, now, journal, journalRoot, nextProgressSeq, executionReady, executionEvidence, deadlineAtMs, recovering = false, closeRetainedWrites = async () => {}, budgetReady = void 0, slotReady = Promise.resolve(), priorSpent) {
29962
+ async function runChild(live, executor, childAbort, task, opts, pool, ticket, blobs, now, journal, journalRoot, nextProgressSeq, executionReady, executionEvidence, deadlineAtMs, recovering = false, closeRetainedWrites = async () => {}, budgetReady = void 0, slotReady = Promise.resolve(), priorSpent, startedAt) {
29843
29963
  if (priorSpent !== void 0) live.spent = detachedSnapshot(priorSpent, "prior committed usage");
29844
29964
  let reconciled = false;
29845
29965
  let reconciliationError;
@@ -29916,6 +30036,12 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
29916
30036
  throw error;
29917
30037
  }
29918
30038
  live.budgetViolation = pool.reconcile(ticket, spend);
30039
+ const settledAt = now();
30040
+ if (deadlineAtMs !== void 0 && startedAt !== void 0 && settledAt > deadlineAtMs) live.budgetViolation = { overspent: [...live.budgetViolation?.overspent ?? [], {
30041
+ channel: "deadline",
30042
+ reserved: deadlineAtMs - startedAt,
30043
+ spent: settledAt - startedAt
30044
+ }] };
29919
30045
  return;
29920
30046
  } catch (error) {
29921
30047
  if (error instanceof BudgetReconcileFault) live.budgetViolation = error.budgetViolation;
@@ -32024,4 +32150,4 @@ function isNonEmptySpend(s) {
32024
32150
  //#endregion
32025
32151
  export { readWorkerInteractiveBinding as $, FileSpawnJournal as $i, persistHarnessTranscript as $n, renderProfileMaterializationIssues as $r, admitContinuationPolicy as $t, bindScopeRetainedOwnerProvider as A, awaitAbortable$1 as Ai, providerAsExecutor as An, runWorktreeHarness as Ar, AUTHORITY_MARKERS as At, scopeRetainedOwnerRestorePoint as B, canonicalStreamEventFromSandboxEvent as Bi, startRetainedRun as Bn, CodexExecutionDiagnosticError as Br, DriverAttemptsExhaustedError as Bt, recordScopeOwnerPause as C, spendFromUsageTotals as Ca, unknownExecutionBindingReceipt as Ci, captureBeforeDestroy as Cn, toOtelAttributes as Cr, workerTraceHeaders as Ct, abandonScopeRetainedOwnerInvocation as D, promptFromAgentTurnInput as Da, projectSandboxOutcome as Di, runBrainLoop as Dn, sanitizeKnowledgeReadinessReport as Dr, createActivityLog as Dt, settledToIteration as E, resolveRedactor as Ea, executableAgentSpecSnapshot as Ei, routerBrain as En, sanitizeAgentRuntimeEvent as Er, DEFAULT_STALL_AFTER_MS as Et, reconcileScopeRetainedOwnerEnvironment as F, unavailablePauseMs as Fi, sandboxSessionTraceSource as Fn, LOCAL_HARNESSES as Fr, isPeerMailEnvelope as Ft, hostDirectoryReader as G, mapSandboxEvent as Gi, createWorkerSlots as Gn, controlProfileMaterialization as Gr, upstreamUnavailableSignal as Gt, scopeRetainedOwnerTurnEnded as H, createSandboxUsageLedger as Hi, retainedCreateMaterial as Hn, AGENT_PROFILE_MATERIALIZATION_AXES as Hr, classifyDriverFailure as Ht, scopeRetainedOwnerContext as I, unavailableSignalOfFailure as Ii, bridgeRuntimeAttachmentsKey as In, harnessInvocation as Ir, peerMailTools as It, coordinationProfileToolPrefix as J, sandboxEventServedBackend as Ji, abortError as Jn, profileMaterializationAxes$1 as Jr, authoredSeatStages as Jt, resolveSpawnResourcePaths as K, mapSandboxToolEvent as Ki, openSlotGroup as Kn, defineProfileMaterializationContract as Kr, SeatChain as Kt, scopeRetainedOwnerJournalRoot as L, TRACE_ROOT_SCHEMA as Li, bridgeStopSignalKey as Ln, harnessSupportsReasoningEffort as Lr, peerMailVerbNames as Lt, noteScopeRetainedOwnerCoordination as M, settlementFailureCause as Mi, resolveAgentEnvironmentProvider as Mn, createWorktree as Mr, PEER_MAIL_WIRE_KEY as Mt, prepareScopeRetainedOwnerSeatSwitch as N, registerRetainedExecutorPreparation as Ni, createPushTraceSource as Nn, removeWorktree as Nr, claimsAuthority as Nt, beginScopeRetainedOwnerDrive as O, promptOptionsFromAgentTurnInput as Oa, readSandboxOutcome as Oi, LEAF_CONTINUATION_TASK as On, sanitizeRuntimeStreamEvent as Or, readWorkerProgress as Ot, prepareScopeRetainedOwnerTask as P, retainedExecutorSeamKey as Pi, decodeToolPart as Pn, DEFAULT_LOCAL_HARNESS as Pr, createPeerMailbox as Pt, attachWorker as Q, FileResultBlobStore as Qi, harnessTranscriptArtifact as Qn, promptResourceProfileMaterialization as Qr, CheckUnavailableError as Qt, scopeRetainedOwnerPriorSpend as R, TRACE_SUMMARY_SCHEMA as Ri, reconnectRetainedRun as Rn, localHarnessExecutable as Rr, isLiveNodeStatus as Rt, recordScopeOwnerMaterialization as S, spendFromUsageEvents as Sa, runtimeOwnedScopeOwnerRuntime as Si, SandboxEvidenceRetentionError as Sn, padTraceId as Sr, workerTraceEnv as St, scopeOwnerExecutorNodeContext as T, defaultRedactorIdentityMaterial as Ta, executableAgentProfileSnapshot as Ti, readPromptOptions as Tn, createRuntimeStreamEventCollector as Tr, taskToPrompt as Tt, SPAWN_RESOURCE_PATH_MAX_BYTES as U, extractLlmCallEvent as Ui, destroyInteractiveEnvironment as Un, assertProfileMaterialization as Ur, runDriverWithRetry as Ut, scopeRetainedOwnerResult as V, createSandboxToolPartState as Vi, startRetainedRunInEnvironment as Vn, terminateProcessTreeAndConfirm as Vr, HarnessTurnFailedError as Vt, environmentReader as W, isSandboxTerminalEvent as Wi, environmentGone as Wn, assertProfileMaterializes as Wr, summarizeDriverAttempts as Wt, runtimeGraphMetadataKey as X, sumSandboxUsage as Xi, runAbortable as Xn, promptModelProfileMaterialization as Xr, CONTINUATIONS_DIR as Xt, providerVisibleProfile as Y, sandboxProgressEvents as Yi, linkAbort as Yn, promptControlProfileMaterialization as Yr, seatExecutionProfile as Yt, interactiveAdmissionSeamKey as Z, decodeHarnessUsage as Zi, captureHarnessTranscript as Zn, promptOnlyProfileMaterialization as Zr, CONTINUATION_FACTS as Zt, deriveNodeExecutionIdentity as _, ReservationWaitRefused as _a, runtimeOwnedDriveHarnessProviderEvidence as _i, defaultSelectWinner as _n, createOtelExporter as _r, createSteerableSandboxSession as _t, collectDelivered as a, replaySpawnTree as aa, worktreeCliProfileMaterialization as ai, expandQuestions as an, runCodeMode as ar, rollingDispatch as at, noteScopeOwnerPlannedExecution as b, meterUsageEvent as ba, runtimeOwnedExecutorProviderEvidence as bi, createSandboxLineage as bn, loopEventToOtelSpan as br, WORKER_TRACE_PROPAGATION as bt, runTree as c, isTraceAnalysisStore as ca, authoredAgentIdentity as ci, verdictFromJudgeScore as cn, ROUTER_PRICE_SOURCE as cr, bindReusableExecutorExecutionId as ct, isDriverSpec as d, contentAddress as da, inheritRuntimeOwnedExecutorAttestation as di, addHarnessUsage as dn, readTraceContextFromEnv as dr, cliWorktreeExecutor as dt, InMemoryResultBlobStore as ea, renderUnsupported as ei, admitFinding as en, readHarnessTranscript as er, reconnectRetainedInteractiveRun as et, withDriverExecutor as f, detachedFrozen as fa, knownExecutionBindingReceipt as fi, createCodexRolloutStoreReader as fn, traceContextToEnv as fr, createExecutor as ft, createScope as g, BudgetReconcileFault as ga, recordRuntimeOwnedDriveHarnessProviderEvidence as gi, createSandboxForSpec as gn, createOpenInferenceFileExporter as gr, DEFAULT_SANDBOX_STEERING_MAX_TURNS as gt, beginScopeOwnerAttempt as h, errMessage as ha, providerAttemptEvidence as hi, TERMINAL_DECISIONS as hn, buildRuntimeEventOtelSpans as hr, createWorktreeCliExecutor as ht, bestDelivered as i, materializeTreeView as ia, validateProfileMaterialization as ii, distillFindings as in, describeCodeModeTools as ir, queueOf as it, consumeScopeRetainedOwnerResult as j, runtimeFailureCause as ji, providerAsSandboxClient as jn, captureWorktreeDiff as jr, DEFAULT_PEER_MAIL_LIMITS as jt, bindScopeRetainedOwnerEnvironmentId as k, providerMessageText as ka, abortError$1 as ki, createAgentEnvironmentProviderRegistry as kn, runSettledCommand as kr, createInbox as kt, driverChild as l, parseWorkerToolTraceArtifact as la, authoredProfileDigest as li, bridgeAdmissionRefusal as ln, createPropagatingTraceEmitter as lr, captureReusableExecutorConfig as lt, assertRecursiveReservationPolicy as m, executorFailure as ma, newExecutionAttemptId as mi, readCodexRolloutSession as mn, buildLoopSpanNodes as mr, snapshotExecutorConfig as mt, createRootHandle as n, insideCursorNamespace as na, sandboxProfileMaterialization as ni, checkVerdictOf as nn, retainHarnessTranscript as nr, startRetainedInteractiveRun as nt, pickBestDelivered as o, WORKER_TOOL_TRACE_SCHEMA_VERSION as oa, attestRuntimeOwnedPendingExecutor as oi, failedItems as on, priceTokens as or, gateOnDeliverable as ot, SUBTREE_RESULT_LIMIT as p, detachedSnapshot as pa, knownMaterializationReceipt as pi, harnessUsageIsEmpty as pn, buildLoopOtelSpans as pr, createExecutorRegistry as pt, coordinationMcpAlias as q, notifySandboxEventObserver as qi, RunCancellationReason as qn, fullProfileMaterialization as qr, SeatChainExhaustedError as qt, createSupervisor as r, loadSpawnForest as ra, unsupportedProfileDimensions as ri, createContinuationKeeper as rn, createCodeModeTools as rr, freeSlots as rt, runFinalizer as s, captureWorkerTraceEvidence as sa, attestRuntimeOwnedScopeOwner as si, passedItems as sn, routerTokenPrice as sr, mapExecutorResult as st, DEFAULT_MAX_DEPTH as t, InMemorySpawnJournal as ta, sandboxActProfileMaterialization as ti, bestComposite as tn, resolveHarnessTranscriptCapture as tr, recoverRetainedInteractiveRun as tt, driverExecutorFactory as u, workerTraceAnalysisStore as ua, finalizeRuntimeOwnedPendingExecutor as ui, bridgeModelRouteRefusal as un, mergeTraceEnv as ur, cliInPlaceExecutor as ut, meterRuntimeOwnedAccounting as v, assertValidBudget as va, runtimeOwnedExecutorExecutionBinding as vi, isTerminalDecision as vn, flatOtelSpan as vr, createRouterTranscript as vt, restoreScopeOwnerAcceptedExecution as w, defaultRedactor as wa, unknownMaterializationReceipt as wi, assertBoxlessPromptOptions as wn, createRuntimeEventCollector as wr, workerTraceSeamKey as wt, recordScopeOwnerDriverAttempt as x, newUsageTotals as xa, runtimeOwnedPendingExecutorMaterialization as xi, acquireSandbox as xn, padSpanId as xr, readWorkerTraceContext as xt, meterRuntimeOwnedProviderAttempt as y, createBudgetPool as ya, runtimeOwnedExecutorMaterialization as yi, runAgentRounds as yn, generateSpanId as yr, createInPlaceCliExecutor as yt, scopeRetainedOwnerResourceReader as z, assertSandboxServedModel as zi, recoverRetainedRun as zn, parseCodexTokenUsage as zr, isTerminalNodeStatus as zt };
32026
32152
 
32027
- //# sourceMappingURL=supervisor-BfIZXA7e.js.map
32153
+ //# sourceMappingURL=supervisor-BObk9STz.js.map