@tangle-network/agent-runtime 0.333.1 → 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-BiJHZQ7_.js → activation-CVW7l4F3.js} +2 -2
  2. package/dist/{activation-BiJHZQ7_.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-NpDEfkvT.js → coordination-driver-D36spfRN.js} +22 -11
  7. package/dist/coordination-driver-D36spfRN.js.map +1 -0
  8. package/dist/{delegate-D8fWCoxb.js → delegate-DGPYLJLx.js} +2 -2
  9. package/dist/{delegate-D8fWCoxb.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-BWg5yNC7.js → graph-CnjWiqlB.js} +4 -4
  13. package/dist/{graph-BWg5yNC7.js.map → graph-CnjWiqlB.js.map} +1 -1
  14. package/dist/{improvement-cycle-CL2GGCQq.js → improvement-cycle-BC6GXcYl.js} +3 -3
  15. package/dist/{improvement-cycle-CL2GGCQq.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-Cx6nXmMP.js → loop-runner-bin-D3nU-Wp0.js} +3 -3
  23. package/dist/{loop-runner-bin-Cx6nXmMP.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-Csm4ZzSd.js → provision-supervisor-C1FQ2uIe.js} +3 -3
  33. package/dist/{provision-supervisor-Csm4ZzSd.js.map → provision-supervisor-C1FQ2uIe.js.map} +1 -1
  34. package/dist/{runtime-BeuNt-n3.js → runtime-Cff0UnPw.js} +66 -16
  35. package/dist/runtime-Cff0UnPw.js.map +1 -0
  36. package/dist/{search-executor-wqvqoJZS.js → search-executor-CFqHN4Dt.js} +2 -2
  37. package/dist/{search-executor-wqvqoJZS.js.map → search-executor-CFqHN4Dt.js.map} +1 -1
  38. package/dist/{server-DheSbIyd.js → server-CFIzBMYb.js} +3 -3
  39. package/dist/{server-DheSbIyd.js.map → server-CFIzBMYb.js.map} +1 -1
  40. package/dist/{supervise-C8oeQwrk.js → supervise-Dl2rTArD.js} +53 -8
  41. package/dist/supervise-Dl2rTArD.js.map +1 -0
  42. package/dist/{supervisor-B4sM2Xu2.js → supervisor-BObk9STz.js} +135 -14
  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-NpDEfkvT.js.map +0 -1
  51. package/dist/runtime-BeuNt-n3.js.map +0 -1
  52. package/dist/supervise-C8oeQwrk.js.map +0 -1
  53. package/dist/supervisor-B4sM2Xu2.js.map +0 -1
@@ -3748,6 +3748,26 @@ const causeMessages = {
3748
3748
  * Nothing ran for the request.
3749
3749
  */
3750
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
+ }
3751
3771
  /** The contract-error codes that wrap a failed READ rather than name a broken answer. */
3752
3772
  const readFailureCodes = /* @__PURE__ */ new Set(["RETAINED_RESULT_READ_FAILED", "RETAINED_CONTROL_REF_READ_FAILED"]);
3753
3773
  /** Socket-level failures, by the codes Node and undici assign, plus the Sandbox SDK's own. */
@@ -3815,6 +3835,7 @@ function classifyPendingCause(cause, phase, onCredentialRefusal) {
3815
3835
  }
3816
3836
  if (name === "ZodError" || Array.isArray(Reflect.get(value, "issues")) || code === "JSON_BOUND_VIOLATION") return at === "admission" ? "request-rejected" : "provider-contract";
3817
3837
  if (code === "DISPATCH_NOT_ADMITTED") return at === "admission" ? "request-rejected" : "provider-contract";
3838
+ if (isProvisioningRefusal(value)) return "request-rejected";
3818
3839
  if (isCredentialRefusal(value)) {
3819
3840
  if (at === "execution") return "unobservable";
3820
3841
  onCredentialRefusal?.();
@@ -10138,6 +10159,14 @@ function normalizeWorkerSlotBound(value) {
10138
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)}`);
10139
10160
  return value;
10140
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
+ }
10141
10170
  const checkpointSlotKeys = /* @__PURE__ */ new WeakMap();
10142
10171
  function checkpointSlots(port) {
10143
10172
  let key = checkpointSlotKeys.get(port);
@@ -10328,9 +10357,9 @@ function trackCapture(port, work) {
10328
10357
  * bound, and judges coverage by the sessions alone. `onTiming` receives the queue wait and the
10329
10358
  * capture time of a workspace capture once it settles, whether it succeeded or failed.
10330
10359
  */
10331
- async function captureProviderWorkspaceSnapshot(port, context, scope = "environment", onTiming) {
10360
+ async function captureProviderWorkspaceSnapshot(port, context, scope = "environment", onTiming, parent) {
10332
10361
  assertProviderWorkspaceRetentionPort(port, "provider workspace retention");
10333
- 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);
10334
10363
  return await trackCapture(port, async (ahead) => {
10335
10364
  const requestedAt = Date.now();
10336
10365
  let grantedAt;
@@ -10351,7 +10380,8 @@ async function captureProviderWorkspaceSnapshot(port, context, scope = "environm
10351
10380
  });
10352
10381
  report({
10353
10382
  outcome: "captured",
10354
- archiveBytes: captured.snapshot.archive.byteLength
10383
+ archiveBytes: captured.snapshot.archive.byteLength,
10384
+ ...captured.stages === void 0 ? {} : { stages: captured.stages }
10355
10385
  });
10356
10386
  return captured;
10357
10387
  } catch (error) {
@@ -10363,7 +10393,7 @@ async function captureProviderWorkspaceSnapshot(port, context, scope = "environm
10363
10393
  }
10364
10394
  });
10365
10395
  }
10366
- async function captureWithinSlot(port, context, scope, onGranted) {
10396
+ async function captureWithinSlot(port, context, scope, onGranted, parent) {
10367
10397
  const native = scope === "native";
10368
10398
  if (native && port.captureNative === void 0) throw new ValidationError$1("provider workspace retention: the port has no captureNative");
10369
10399
  const timeoutMs = native ? port.nativeTimeoutMs ?? 12e4 : port.timeoutMs;
@@ -10371,6 +10401,9 @@ async function captureWithinSlot(port, context, scope, onGranted) {
10371
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");
10372
10402
  const controller = new AbortController();
10373
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 });
10374
10407
  try {
10375
10408
  return await runAbortable(() => withCaptureSlot(native ? nativeSlots(port) : port, controller.signal, async () => {
10376
10409
  onGranted?.();
@@ -10430,15 +10463,18 @@ async function captureWithinSlot(port, context, scope, onGranted) {
10430
10463
  ...port.limits === void 0 ? {} : { limits: port.limits }
10431
10464
  });
10432
10465
  }
10466
+ const stages = "snapshot" in result ? captureStages(result.stages) : void 0;
10433
10467
  return {
10434
10468
  snapshot,
10435
10469
  provenance,
10436
10470
  coverageComplete,
10471
+ ...stages === void 0 ? {} : { stages },
10437
10472
  ...coverageComplete ? {} : { incompleteReason: `provider workspace retention coverage incomplete: ${coverageGaps.join("; ")}` }
10438
10473
  };
10439
10474
  }), controller.signal, `provider workspace retention timed out after ${timeoutMs}ms`);
10440
10475
  } finally {
10441
10476
  clearDeadline();
10477
+ parent?.removeEventListener("abort", stopFromParent);
10442
10478
  }
10443
10479
  }
10444
10480
  /** Reconcile Sidecar attempts to the exact captured session executions. */
@@ -12413,7 +12449,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12413
12449
  executionId: capturedExecutionId,
12414
12450
  environmentId: next.id
12415
12451
  }).catch(() => void 0) ?? Promise.resolve();
12416
- 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) => {
12417
12453
  timing = measured;
12418
12454
  })).finally(async () => {
12419
12455
  await started;
@@ -12467,6 +12503,8 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12467
12503
  };
12468
12504
  const nativePort = options.workspaceRetention?.captureNative === void 0 ? void 0 : options.workspaceRetention;
12469
12505
  let nativeInFlight;
12506
+ let nativeRunningInFlight;
12507
+ let nativeRunningStop;
12470
12508
  let nativeTimer;
12471
12509
  let nativeEvents = 0;
12472
12510
  let nativeEventsAtCopy;
@@ -12527,12 +12565,17 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12527
12565
  nativeTimer = void 0;
12528
12566
  closeNativeMirror?.();
12529
12567
  closeNativeMirror = void 0;
12568
+ nativeRunningStop?.abort(/* @__PURE__ */ new Error("native session copy stopped: its turn ended"));
12569
+ nativeRunningStop = void 0;
12530
12570
  await nativeInFlight;
12531
12571
  };
12532
12572
  const captureNative = (next, phase, admitted, afterStop = false) => {
12533
12573
  if (nativePort === void 0 || createProfile.harness === void 0) return Promise.resolve();
12534
12574
  const harness = createProfile.harness;
12575
+ const stop = phase === "running" ? new AbortController() : void 0;
12576
+ if (stop !== void 0) nativeRunningStop = stop;
12535
12577
  const tracked = (nativeInFlight ?? Promise.resolve()).then(async () => {
12578
+ stop?.signal.throwIfAborted();
12536
12579
  const controlRef = workspaceControlRef ?? admitted;
12537
12580
  const sessionId = providerSessionId ?? admitted?.sessionId ?? null;
12538
12581
  if (workspaceSnapshot !== void 0 && !nativeHoldsTranscript) return;
@@ -12549,7 +12592,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12549
12592
  nativeSessionId: null,
12550
12593
  profile: createProfile,
12551
12594
  phase
12552
- }, "native");
12595
+ }, "native", void 0, stop?.signal);
12553
12596
  let captured = await takeCopy();
12554
12597
  const settleBy = Date.now() + NATIVE_SETTLE_WINDOW_MS;
12555
12598
  while (afterStop && captured.coverageComplete !== true && (captured.provenance.attempts ?? []).some((attempt) => attempt.outcome === "unknown") && Date.now() < settleBy) {
@@ -12573,14 +12616,18 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12573
12616
  nativeHoldsTranscript = true;
12574
12617
  nativeEventsAtCopy = eventsAtStart;
12575
12618
  } catch (error) {
12619
+ if (stop?.signal.aborted) return;
12576
12620
  noteCaptureFailure(error);
12577
12621
  } finally {
12578
12622
  lastNativeCopyMs = Date.now() - copyStartedAt;
12579
12623
  }
12580
- }).finally(() => {
12624
+ }).catch(() => void 0).finally(() => {
12581
12625
  if (nativeInFlight === tracked) nativeInFlight = void 0;
12626
+ if (nativeRunningInFlight === tracked) nativeRunningInFlight = void 0;
12627
+ if (nativeRunningStop === stop) nativeRunningStop = void 0;
12582
12628
  });
12583
12629
  nativeInFlight = tracked;
12630
+ if (stop !== void 0) nativeRunningInFlight = tracked;
12584
12631
  return tracked;
12585
12632
  };
12586
12633
  const startNativeMirror = (next) => {
@@ -13147,10 +13194,17 @@ async function* streamProviderExecutor(args) {
13147
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;
13148
13195
  const handCaptureToOwner = (reported, captureOutcome, publish, beforeCapture) => {
13149
13196
  args.retention?.onEndOfTurnWork?.((async () => {
13197
+ const finalCopy = (async () => {
13198
+ try {
13199
+ await beforeCapture?.();
13200
+ } catch {}
13201
+ })();
13202
+ let snapshot;
13150
13203
  try {
13151
- await beforeCapture?.();
13152
- } catch {}
13153
- const snapshot = await args.captureWorkspace(environment, captureOutcome);
13204
+ snapshot = await args.captureWorkspace(environment, captureOutcome);
13205
+ } finally {
13206
+ await finalCopy;
13207
+ }
13154
13208
  if (publish) args.onPublishedSnapshot(snapshot);
13155
13209
  if (snapshot === void 0) return;
13156
13210
  await args.retention?.onEvidence?.({
@@ -19370,7 +19424,10 @@ function checkedSeatSelection(stage, selected) {
19370
19424
  * is being burned. Within that window it consumes neither `maxAttempts` nor the barren streak,
19371
19425
  * exactly like a pause, and only the deadline, the budget, and cancellation bound it. After the
19372
19426
  * window the failure bounds apply again, so a dead-on-arrival driver still stops, in minutes
19373
- * 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,
19374
19431
  * because that is the burn the progress rule exists to stop. Measured 2026-10-04 on Discovery run research-nqs-20261003system2: a Platform
19375
19432
  * restart answered `HTTP 502 ... Platform key verification unavailable` from 03:04:34 to 03:09:41Z,
19376
19433
  * and the coordinator's twelve attempts ran out at 03:07:12Z with no token spent, while a sibling
@@ -19400,6 +19457,40 @@ const REPEATED_FAILURE_WINDOW_MS = 5 * 6e4;
19400
19457
  /** Consecutive identical reconciliation failures of one pending invocation that resolve it. */
19401
19458
  const SAME_PENDING_LIMIT = 2;
19402
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
+ /**
19403
19494
  * The pending invocation a failure left, when abandoning it is the resolution: the provider
19404
19495
  * answered and could not resolve the execution (`unobservable`), or a nested manager's recovery
19405
19496
  * could not be rebuilt (`nested-recovery`). A lost transport waits for the provider instead, in
@@ -19527,6 +19618,22 @@ function capacityCode(error) {
19527
19618
  function isUpstreamUnavailable(error) {
19528
19619
  return upstreamUnavailableSignal(error) !== void 0;
19529
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
+ }
19530
19637
  /**
19531
19638
  * Classify one driver failure. Runtime's own typed refusals are decisions and stay terminal; an
19532
19639
  * upstream capacity refusal is `unavailable`; anything else foreign is an accident and is
@@ -19544,6 +19651,7 @@ function classifyDriverFailure(error, signal) {
19544
19651
  if (error instanceof Error && errorProperty(error, "name") === "AbortError") return "terminal";
19545
19652
  if (error instanceof Error && isProviderSchemaRejection(error)) return "terminal";
19546
19653
  if (isCredentialRefusal(error)) return "terminal";
19654
+ if (causeChain(error).some(isProvisioningRefusal)) return "terminal";
19547
19655
  if (error instanceof HarnessTurnFailedError) {
19548
19656
  if (error.errorCode !== void 0 && DETERMINISTIC_BRIDGE_CODES.has(error.errorCode)) return "terminal";
19549
19657
  if (isUpstreamUnavailable(error)) return "unavailable";
@@ -19717,6 +19825,7 @@ async function runDriverWithRetry(run) {
19717
19825
  let consecutivePauses = 0;
19718
19826
  let samePending;
19719
19827
  let sameFailure;
19828
+ let samePartial;
19720
19829
  let abandonments = 0;
19721
19830
  let pauses = 0;
19722
19831
  let continuations = 0;
@@ -19851,12 +19960,17 @@ async function runDriverWithRetry(run) {
19851
19960
  since: failedAt
19852
19961
  };
19853
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;
19854
19967
  const stop = (() => {
19855
19968
  if (classification === "terminal") return "terminal-error";
19856
19969
  if (!retryEnabled) return "retry-disabled";
19857
19970
  if (run.signal.aborted) return "aborted";
19858
19971
  const byBudget = budgetStop(run.budget(), failedAt);
19859
19972
  if (byBudget) return byBudget;
19973
+ if (samePartial !== void 0 && samePartial.count >= SAME_PARTIAL_FAILURE_LIMIT) return "repeated-failure";
19860
19974
  if (inOutage) return void 0;
19861
19975
  if (chargedFailures >= maxAttempts) return "max-attempts";
19862
19976
  if (progressed) return repeated ? "repeated-failure" : void 0;
@@ -19914,6 +20028,7 @@ async function runDriverWithRetry(run) {
19914
20028
  outageSince = void 0;
19915
20029
  samePending = void 0;
19916
20030
  sameFailure = void 0;
20031
+ samePartial = void 0;
19917
20032
  abandonments = 0;
19918
20033
  const durationMs = now() - startedAt;
19919
20034
  const after = run.progress();
@@ -28799,7 +28914,7 @@ function createScope(args) {
28799
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, {
28800
28915
  complete: async () => pendingEvidence?.complete(),
28801
28916
  fail: async () => pendingEvidence?.fail()
28802
- }, childDeadlineAtMs, recovery !== void 0, closeRetainedWrites, budgetGranted, permit.ready, recovery?.continuation?.priorSpent);
28917
+ }, childDeadlineAtMs, recovery !== void 0, closeRetainedWrites, budgetGranted, permit.ready, recovery?.continuation?.priorSpent, startedAt);
28803
28918
  args.pool.attribute(reservation.ticket, { stage: "executing" });
28804
28919
  const interactiveBindingCommitted = spawnCommitted.then(async () => {
28805
28920
  if (args.interactiveBindingDir === void 0) return;
@@ -29844,7 +29959,7 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
29844
29959
  * applied per child). The reservation is reconciled on EVERY path (success, abort, throw)
29845
29960
  * so the conserved pool can never leak a reservation.
29846
29961
  */
29847
- 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) {
29848
29963
  if (priorSpent !== void 0) live.spent = detachedSnapshot(priorSpent, "prior committed usage");
29849
29964
  let reconciled = false;
29850
29965
  let reconciliationError;
@@ -29921,6 +30036,12 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
29921
30036
  throw error;
29922
30037
  }
29923
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
+ }] };
29924
30045
  return;
29925
30046
  } catch (error) {
29926
30047
  if (error instanceof BudgetReconcileFault) live.budgetViolation = error.budgetViolation;
@@ -32029,4 +32150,4 @@ function isNonEmptySpend(s) {
32029
32150
  //#endregion
32030
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 };
32031
32152
 
32032
- //# sourceMappingURL=supervisor-B4sM2Xu2.js.map
32153
+ //# sourceMappingURL=supervisor-BObk9STz.js.map