@tangle-network/agent-runtime 0.333.1 → 0.335.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 (67) hide show
  1. package/dist/{activation-BiJHZQ7_.js → activation-BT3VoIpg.js} +3 -3
  2. package/dist/{activation-BiJHZQ7_.js.map → activation-BT3VoIpg.js.map} +1 -1
  3. package/dist/{activation-BGZ0rVuv.d.ts → activation-DZbEj4oG.d.ts} +2 -2
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +2 -2
  6. package/dist/{bundle-DqvlwhKP.js → bundle-CMGJKcl6.js} +2 -2
  7. package/dist/{bundle-DqvlwhKP.js.map → bundle-CMGJKcl6.js.map} +1 -1
  8. package/dist/candidate-execution/index.js +5 -5
  9. package/dist/{coordination-driver-NpDEfkvT.js → coordination-driver-rNoFHYmZ.js} +36 -15
  10. package/dist/coordination-driver-rNoFHYmZ.js.map +1 -0
  11. package/dist/{delegate-D8fWCoxb.js → delegate-BdwThtY9.js} +2 -2
  12. package/dist/{delegate-D8fWCoxb.js.map → delegate-BdwThtY9.js.map} +1 -1
  13. package/dist/durable.d.ts +1 -1
  14. package/dist/durable.js +5 -5
  15. package/dist/{graph-BWg5yNC7.js → graph-Bph_DX-z.js} +5 -4
  16. package/dist/graph-Bph_DX-z.js.map +1 -0
  17. package/dist/{improvement-cycle-CL2GGCQq.js → improvement-cycle-Coj69usO.js} +6 -6
  18. package/dist/{improvement-cycle-CL2GGCQq.js.map → improvement-cycle-Coj69usO.js.map} +1 -1
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +9 -9
  21. package/dist/intelligence.d.ts +2 -2
  22. package/dist/intelligence.js +7 -7
  23. package/dist/kernel.d.ts +2 -2
  24. package/dist/kernel.js +10 -10
  25. package/dist/{loop-runner-bin-Cx6nXmMP.js → loop-runner-bin-9MtarSBu.js} +3 -3
  26. package/dist/{loop-runner-bin-Cx6nXmMP.js.map → loop-runner-bin-9MtarSBu.js.map} +1 -1
  27. package/dist/{loop-runner-bin-CaH_49Ts.d.ts → loop-runner-bin-BTC2czoj.d.ts} +2 -2
  28. package/dist/loop-runner-bin.d.ts +1 -1
  29. package/dist/loop-runner-bin.js +1 -1
  30. package/dist/mcp/bin.js +26 -7
  31. package/dist/mcp/bin.js.map +1 -1
  32. package/dist/mcp/index.d.ts +2 -2
  33. package/dist/mcp/index.js +5 -5
  34. package/dist/{openai-tools-BhO6-5ff.d.ts → openai-tools-DWuf9K9X.d.ts} +2 -2
  35. package/dist/{prepare-0kTqt9qn.js → prepare-Ci9Wrle5.js} +3 -3
  36. package/dist/{prepare-0kTqt9qn.js.map → prepare-Ci9Wrle5.js.map} +1 -1
  37. package/dist/{profile-DhZvQngF.js → profile-BAwFYsOE.js} +2 -2
  38. package/dist/{profile-DhZvQngF.js.map → profile-BAwFYsOE.js.map} +1 -1
  39. package/dist/profiles.d.ts +1 -1
  40. package/dist/{protected-model-port-CFQj32Lt.js → protected-model-port-DZUkB0cr.js} +4 -4
  41. package/dist/{protected-model-port-CFQj32Lt.js.map → protected-model-port-DZUkB0cr.js.map} +1 -1
  42. package/dist/{provision-supervisor-Csm4ZzSd.js → provision-supervisor-Ced9EeHy.js} +4 -4
  43. package/dist/{provision-supervisor-Csm4ZzSd.js.map → provision-supervisor-Ced9EeHy.js.map} +1 -1
  44. package/dist/{runtime-BeuNt-n3.js → runtime-DMVBv34m.js} +67 -17
  45. package/dist/runtime-DMVBv34m.js.map +1 -0
  46. package/dist/{sandbox-profile-compat-CVgQWb7T.js → sandbox-profile-compat-D_ZOL80S.js} +3 -2
  47. package/dist/sandbox-profile-compat-D_ZOL80S.js.map +1 -0
  48. package/dist/{search-executor-wqvqoJZS.js → search-executor-BNTeMygV.js} +3 -3
  49. package/dist/{search-executor-wqvqoJZS.js.map → search-executor-BNTeMygV.js.map} +1 -1
  50. package/dist/{server-DheSbIyd.js → server-z7xI_ItY.js} +4 -4
  51. package/dist/{server-DheSbIyd.js.map → server-z7xI_ItY.js.map} +1 -1
  52. package/dist/{supervise-C8oeQwrk.js → supervise-ISaRiWVe.js} +56 -9
  53. package/dist/supervise-ISaRiWVe.js.map +1 -0
  54. package/dist/{supervisor-B4sM2Xu2.js → supervisor-B-bkXttM.js} +325 -41
  55. package/dist/supervisor-B-bkXttM.js.map +1 -0
  56. package/dist/testing.d.ts +1 -1
  57. package/dist/testing.js +14 -14
  58. package/dist/tui/index.d.ts +1 -1
  59. package/dist/tui/index.js +1 -1
  60. package/dist/{types-CsDKtdE3.d.ts → types-BO8kh52C.d.ts} +89 -6
  61. package/package.json +3 -3
  62. package/dist/coordination-driver-NpDEfkvT.js.map +0 -1
  63. package/dist/graph-BWg5yNC7.js.map +0 -1
  64. package/dist/runtime-BeuNt-n3.js.map +0 -1
  65. package/dist/sandbox-profile-compat-CVgQWb7T.js.map +0 -1
  66. package/dist/supervise-C8oeQwrk.js.map +0 -1
  67. package/dist/supervisor-B4sM2Xu2.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { i as publishExclusiveDurableFile, n as assertNoSymlinkDescendant } from "./durable-file-B_eJr6Mb.js";
2
2
  import { c as RetainedInteractiveAdmissionError, d as RetainedRunDispatchBindingError, f as RuntimeRunStateError, i as ConfigError, l as RetainedInteractiveBindingError, m as ValidationError$1, r as BackendTransportError, t as AgentEvalError$1, u as RetainedRunAdmissionError } from "./errors-DodWX-cb.js";
3
- import { $ as isAsyncIterable$1, Ct as armDeadlineTimer, Dt as singleFlightTeardown, Et as isDeadlineAbortReason, G as chargedTokens, J as deleteBoxSafe, K as cloneSpend, L as deepFreezeCandidate, N as verifiedArtifactChunks, Ot as teardownExecutor, St as ROOT_DEADLINE_REASON, Tt as checkInIdleMs, U as addSpend, W as addTokenUsage, X as fnv1a32Hex, Y as errorMessage, Z as hasCompleteCacheBreakdown, _t as ACCEPTED_RESULT_GRACE_MS, at as sleep, c as verifyAgentCandidateWorkspaceTree, ct as throwIfAborted, dt as zeroSpend, et as mapWithConcurrency, f as verifyAgentCandidateWorkspaceArchive, ft as zeroTokenUsage, gt as withBudgetResources, ht as resourceTelemetry, it as roundBoxMinutes, j as verifyWorkspaceSnapshotArtifacts, kt as teardownSurfaces, lt as unmeteredSpend, mt as assertResources, nt as randomSuffix, o as readAgentCandidateWorkspaceArtifactFiles, ot as stringifySafe, pt as addResourceSpend, q as cloneTokenUsage, rt as randomUuid, s as verifyAgentCandidateWorkspaceArtifacts, st as throwAbort, t as assertSandboxProfileCompatibility, tt as promptCacheTokenClasses, ut as withTimeout, vt as CHILD_DEADLINE_REASON, wt as boundedChildDeadlineAt } from "./sandbox-profile-compat-CVgQWb7T.js";
3
+ import { $ as isAsyncIterable$1, Ct as armDeadlineTimer, Dt as singleFlightTeardown, Et as isDeadlineAbortReason, G as chargedTokens, J as deleteBoxSafe, K as cloneSpend, L as deepFreezeCandidate, N as verifiedArtifactChunks, Ot as teardownExecutor, St as ROOT_DEADLINE_REASON, Tt as checkInIdleMs, U as addSpend, W as addTokenUsage, X as fnv1a32Hex, Y as errorMessage, Z as hasCompleteCacheBreakdown, _t as ACCEPTED_RESULT_GRACE_MS, at as sleep, c as verifyAgentCandidateWorkspaceTree, ct as throwIfAborted, dt as zeroSpend, et as mapWithConcurrency, f as verifyAgentCandidateWorkspaceArchive, ft as zeroTokenUsage, gt as withBudgetResources, ht as resourceTelemetry, it as roundBoxMinutes, j as verifyWorkspaceSnapshotArtifacts, kt as teardownSurfaces, lt as unmeteredSpend, mt as assertResources, nt as randomSuffix, o as readAgentCandidateWorkspaceArtifactFiles, ot as stringifySafe, pt as addResourceSpend, q as cloneTokenUsage, rt as randomUuid, s as verifyAgentCandidateWorkspaceArtifacts, st as throwAbort, t as assertSandboxProfileCompatibility, tt as promptCacheTokenClasses, ut as withTimeout, vt as CHILD_DEADLINE_REASON, wt as boundedChildDeadlineAt } from "./sandbox-profile-compat-D_ZOL80S.js";
4
4
  import { runTaskQueue } from "./task-queue.js";
5
5
  import { a as readCommittedJsonLines, n as isNoEntError, t as appendCommittedJsonLine } from "./jsonl-file-DBv31uPi.js";
6
6
  import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, d as assertRouterAutoDeclaration, f as assertRouterAutoResponse, g as observedModelMatchesDeclared, h as observedModelHasSnapshot, l as profileProviderModel, m as mergeObservedModelIdentity, o as enforceTokenLimits, s as profileBridgeWireModel, t as assertExecutableAgentProfile, u as resolveRouterRetryPolicy } from "./model-policy-CyCUwHed.js";
@@ -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?.();
@@ -3869,6 +3890,9 @@ var RetainedExecutionPendingError = class extends Error {
3869
3890
  if (credentialRefused) credentialAdmissionRefusals.add(this);
3870
3891
  }
3871
3892
  };
3893
+ /** The instruction a keyed continuation runs in the held session: the node's task is unchanged,
3894
+ * and its conversation and workspace are where the budget stop left them. */
3895
+ const BUDGET_CONTINUATION_TASK = "Your previous turn reached its budget and stopped. Your manager gave you more budget to continue the same task in the same session: your conversation so far and the files in your workspace are where you left them. Continue from where you stopped. Do not start over.";
3872
3896
  /** The execution id of a leaf's later invocation, derived from its `execution-input` sequence so
3873
3897
  * a recovery derives the same one. A first invocation keeps the node id. */
3874
3898
  function leafContinuationExecutionId(nodeId, inputSeq) {
@@ -5288,7 +5312,8 @@ const HARNESS_INVOCATIONS = {
5288
5312
  "workspace-write",
5289
5313
  "-c",
5290
5314
  "approval_policy=\"never\""
5291
- ]
5315
+ ],
5316
+ fullAccessArgs: () => ["--dangerously-bypass-approvals-and-sandbox"]
5292
5317
  },
5293
5318
  opencode: {
5294
5319
  command: "opencode",
@@ -5378,7 +5403,10 @@ const CODEX_REPRODUCIBLE_ARGS = [
5378
5403
  function buildHarnessArgs(harness, taskPrompt, options = {}) {
5379
5404
  const invocation = HARNESS_INVOCATIONS[harness];
5380
5405
  const args = invocation.buildArgs(taskPrompt);
5381
- if (options.dangerouslySkipPermissions && !options.codexReproducible) args.push(...invocation.permissionBypassArgs?.() ?? []);
5406
+ if (options.dangerouslySkipPermissions && !options.codexReproducible) {
5407
+ const bypass = options.fullAccess ? invocation.fullAccessArgs ?? invocation.permissionBypassArgs : invocation.permissionBypassArgs;
5408
+ args.push(...bypass?.() ?? []);
5409
+ }
5382
5410
  if (options.codexReproducible) {
5383
5411
  if (harness !== "codex") throw new Error("harnessInvocation: codexReproducible requires the Codex harness");
5384
5412
  args.push(...CODEX_REPRODUCIBLE_ARGS);
@@ -6639,6 +6667,8 @@ async function runInPlaceHarness(opts) {
6639
6667
  applied,
6640
6668
  resourceInstructions,
6641
6669
  dangerouslySkipPermissions: true,
6670
+ fullAccess: true,
6671
+ ...opts.env ? { env: opts.env } : {},
6642
6672
  ...opts.harnessTimeoutMs !== void 0 ? { harnessTimeoutMs: opts.harnessTimeoutMs } : {},
6643
6673
  ...opts.signal ? { signal: opts.signal } : {},
6644
6674
  runHarness,
@@ -6669,6 +6699,13 @@ function applyProfilePlan(plan, workspacePath, context) {
6669
6699
  if (applied.unsupported.length > 0) throw new Error(`${context}: applied profile unexpectedly retained unsupported rows`);
6670
6700
  return applied;
6671
6701
  }
6702
+ /** `process.env` with the caller's per-run overrides applied; `undefined` removes a variable. */
6703
+ function callerEnv(overrides) {
6704
+ const env = { ...process.env };
6705
+ for (const [name, value] of Object.entries(overrides ?? {})) if (value === void 0) delete env[name];
6706
+ else env[name] = value;
6707
+ return env;
6708
+ }
6672
6709
  /**
6673
6710
  * The ONE profile-to-process step both placements share: §1.5 prompt/model delivery through
6674
6711
  * `harnessInvocation`, the materializer's flags and environment, and the `runLocalHarness` spawn
@@ -6679,6 +6716,7 @@ async function spawnProfiledHarness(args) {
6679
6716
  const invocationProfile = profileWithResourceInstructions(args.profile, args.resourceInstructions);
6680
6717
  const { command, args: invocationArgs } = harnessInvocation(args.harness, invocationProfile, args.taskPrompt, {
6681
6718
  dangerouslySkipPermissions: args.dangerouslySkipPermissions,
6719
+ ...args.fullAccess ? { fullAccess: true } : {},
6682
6720
  ...args.codexReproducible ? { codexReproducible: true } : {}
6683
6721
  });
6684
6722
  const harnessResult = await args.runHarness({
@@ -6690,7 +6728,7 @@ async function spawnProfiledHarness(args) {
6690
6728
  args: [...invocationArgs, ...args.applied.flags.map(publicPlanString)]
6691
6729
  },
6692
6730
  env: {
6693
- ...process.env,
6731
+ ...callerEnv(args.env),
6694
6732
  ...resolvePublicPlanEnv(args.applied.env)
6695
6733
  },
6696
6734
  ...args.codexReproducible ? { codexReproducible: true } : {},
@@ -10138,6 +10176,14 @@ function normalizeWorkerSlotBound(value) {
10138
10176
  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
10177
  return value;
10140
10178
  }
10179
+ /** At most this many stage entries are kept from a port, each a finite, non-negative number. */
10180
+ const MAX_CAPTURE_STAGES = 16;
10181
+ function captureStages(value) {
10182
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return void 0;
10183
+ const stages = {};
10184
+ 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;
10185
+ return Object.keys(stages).length === 0 ? void 0 : Object.freeze(stages);
10186
+ }
10141
10187
  const checkpointSlotKeys = /* @__PURE__ */ new WeakMap();
10142
10188
  function checkpointSlots(port) {
10143
10189
  let key = checkpointSlotKeys.get(port);
@@ -10328,9 +10374,9 @@ function trackCapture(port, work) {
10328
10374
  * bound, and judges coverage by the sessions alone. `onTiming` receives the queue wait and the
10329
10375
  * capture time of a workspace capture once it settles, whether it succeeded or failed.
10330
10376
  */
10331
- async function captureProviderWorkspaceSnapshot(port, context, scope = "environment", onTiming) {
10377
+ async function captureProviderWorkspaceSnapshot(port, context, scope = "environment", onTiming, parent) {
10332
10378
  assertProviderWorkspaceRetentionPort(port, "provider workspace retention");
10333
- if (scope === "native" || onTiming === void 0) return await captureWithinSlot(port, context, scope);
10379
+ if (scope === "native" || onTiming === void 0) return await captureWithinSlot(port, context, scope, void 0, parent);
10334
10380
  return await trackCapture(port, async (ahead) => {
10335
10381
  const requestedAt = Date.now();
10336
10382
  let grantedAt;
@@ -10351,7 +10397,8 @@ async function captureProviderWorkspaceSnapshot(port, context, scope = "environm
10351
10397
  });
10352
10398
  report({
10353
10399
  outcome: "captured",
10354
- archiveBytes: captured.snapshot.archive.byteLength
10400
+ archiveBytes: captured.snapshot.archive.byteLength,
10401
+ ...captured.stages === void 0 ? {} : { stages: captured.stages }
10355
10402
  });
10356
10403
  return captured;
10357
10404
  } catch (error) {
@@ -10363,7 +10410,7 @@ async function captureProviderWorkspaceSnapshot(port, context, scope = "environm
10363
10410
  }
10364
10411
  });
10365
10412
  }
10366
- async function captureWithinSlot(port, context, scope, onGranted) {
10413
+ async function captureWithinSlot(port, context, scope, onGranted, parent) {
10367
10414
  const native = scope === "native";
10368
10415
  if (native && port.captureNative === void 0) throw new ValidationError$1("provider workspace retention: the port has no captureNative");
10369
10416
  const timeoutMs = native ? port.nativeTimeoutMs ?? 12e4 : port.timeoutMs;
@@ -10371,6 +10418,9 @@ async function captureWithinSlot(port, context, scope, onGranted) {
10371
10418
  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
10419
  const controller = new AbortController();
10373
10420
  const clearDeadline = armDeadlineTimer(timeoutMs, () => controller.abort(/* @__PURE__ */ new Error(`provider workspace retention timed out after ${timeoutMs}ms`)), true);
10421
+ const stopFromParent = () => controller.abort(parent?.reason);
10422
+ if (parent?.aborted) stopFromParent();
10423
+ else parent?.addEventListener("abort", stopFromParent, { once: true });
10374
10424
  try {
10375
10425
  return await runAbortable(() => withCaptureSlot(native ? nativeSlots(port) : port, controller.signal, async () => {
10376
10426
  onGranted?.();
@@ -10430,15 +10480,18 @@ async function captureWithinSlot(port, context, scope, onGranted) {
10430
10480
  ...port.limits === void 0 ? {} : { limits: port.limits }
10431
10481
  });
10432
10482
  }
10483
+ const stages = "snapshot" in result ? captureStages(result.stages) : void 0;
10433
10484
  return {
10434
10485
  snapshot,
10435
10486
  provenance,
10436
10487
  coverageComplete,
10488
+ ...stages === void 0 ? {} : { stages },
10437
10489
  ...coverageComplete ? {} : { incompleteReason: `provider workspace retention coverage incomplete: ${coverageGaps.join("; ")}` }
10438
10490
  };
10439
10491
  }), controller.signal, `provider workspace retention timed out after ${timeoutMs}ms`);
10440
10492
  } finally {
10441
10493
  clearDeadline();
10494
+ parent?.removeEventListener("abort", stopFromParent);
10442
10495
  }
10443
10496
  }
10444
10497
  /** Reconcile Sidecar attempts to the exact captured session executions. */
@@ -12314,6 +12367,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12314
12367
  else managerStop.addEventListener("abort", cancel, { once: true });
12315
12368
  };
12316
12369
  let destroyed = false;
12370
+ let holdingForContinuation = false;
12317
12371
  let workspaceEnvironmentId;
12318
12372
  let workspaceSnapshot;
12319
12373
  let workspaceProvenance;
@@ -12413,7 +12467,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12413
12467
  executionId: capturedExecutionId,
12414
12468
  environmentId: next.id
12415
12469
  }).catch(() => void 0) ?? Promise.resolve();
12416
- workspaceCapturePromise = Promise.all([nativeInFlight, liveInFlight]).then(() => captureProviderWorkspaceSnapshot(workspaceRetention, captureContext, "environment", reportTiming === void 0 ? void 0 : (measured) => {
12470
+ workspaceCapturePromise = Promise.all([nativeRunningInFlight, liveInFlight]).then(() => captureProviderWorkspaceSnapshot(workspaceRetention, captureContext, "environment", reportTiming === void 0 ? void 0 : (measured) => {
12417
12471
  timing = measured;
12418
12472
  })).finally(async () => {
12419
12473
  await started;
@@ -12467,6 +12521,8 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12467
12521
  };
12468
12522
  const nativePort = options.workspaceRetention?.captureNative === void 0 ? void 0 : options.workspaceRetention;
12469
12523
  let nativeInFlight;
12524
+ let nativeRunningInFlight;
12525
+ let nativeRunningStop;
12470
12526
  let nativeTimer;
12471
12527
  let nativeEvents = 0;
12472
12528
  let nativeEventsAtCopy;
@@ -12527,12 +12583,17 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12527
12583
  nativeTimer = void 0;
12528
12584
  closeNativeMirror?.();
12529
12585
  closeNativeMirror = void 0;
12586
+ nativeRunningStop?.abort(/* @__PURE__ */ new Error("native session copy stopped: its turn ended"));
12587
+ nativeRunningStop = void 0;
12530
12588
  await nativeInFlight;
12531
12589
  };
12532
12590
  const captureNative = (next, phase, admitted, afterStop = false) => {
12533
12591
  if (nativePort === void 0 || createProfile.harness === void 0) return Promise.resolve();
12534
12592
  const harness = createProfile.harness;
12593
+ const stop = phase === "running" ? new AbortController() : void 0;
12594
+ if (stop !== void 0) nativeRunningStop = stop;
12535
12595
  const tracked = (nativeInFlight ?? Promise.resolve()).then(async () => {
12596
+ stop?.signal.throwIfAborted();
12536
12597
  const controlRef = workspaceControlRef ?? admitted;
12537
12598
  const sessionId = providerSessionId ?? admitted?.sessionId ?? null;
12538
12599
  if (workspaceSnapshot !== void 0 && !nativeHoldsTranscript) return;
@@ -12549,7 +12610,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12549
12610
  nativeSessionId: null,
12550
12611
  profile: createProfile,
12551
12612
  phase
12552
- }, "native");
12613
+ }, "native", void 0, stop?.signal);
12553
12614
  let captured = await takeCopy();
12554
12615
  const settleBy = Date.now() + NATIVE_SETTLE_WINDOW_MS;
12555
12616
  while (afterStop && captured.coverageComplete !== true && (captured.provenance.attempts ?? []).some((attempt) => attempt.outcome === "unknown") && Date.now() < settleBy) {
@@ -12573,14 +12634,18 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12573
12634
  nativeHoldsTranscript = true;
12574
12635
  nativeEventsAtCopy = eventsAtStart;
12575
12636
  } catch (error) {
12637
+ if (stop?.signal.aborted) return;
12576
12638
  noteCaptureFailure(error);
12577
12639
  } finally {
12578
12640
  lastNativeCopyMs = Date.now() - copyStartedAt;
12579
12641
  }
12580
- }).finally(() => {
12642
+ }).catch(() => void 0).finally(() => {
12581
12643
  if (nativeInFlight === tracked) nativeInFlight = void 0;
12644
+ if (nativeRunningInFlight === tracked) nativeRunningInFlight = void 0;
12645
+ if (nativeRunningStop === stop) nativeRunningStop = void 0;
12582
12646
  });
12583
12647
  nativeInFlight = tracked;
12648
+ if (stop !== void 0) nativeRunningInFlight = tracked;
12584
12649
  return tracked;
12585
12650
  };
12586
12651
  const startNativeMirror = (next) => {
@@ -12865,7 +12930,10 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12865
12930
  complete: workspaceCoverageComplete,
12866
12931
  incompleteReason: workspaceIncompleteReason
12867
12932
  }),
12868
- destroyEnvironment
12933
+ destroyEnvironment,
12934
+ onHeld: () => {
12935
+ holdingForContinuation = true;
12936
+ }
12869
12937
  });
12870
12938
  const refusal = ended.unavailable;
12871
12939
  const continueInvocation = invocation.retention?.continueInvocation;
@@ -12930,6 +12998,10 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12930
12998
  },
12931
12999
  async teardown(_grace) {
12932
13000
  controller.abort();
13001
+ if (holdingForContinuation) return {
13002
+ destroyed: false,
13003
+ detail: "environment held for a keyed continuation after a budget stop"
13004
+ };
12933
13005
  if (pending && cancelledExplicitly()) stopNativeExecution();
12934
13006
  if (options.workspaceRetention !== void 0 && workspaceRunActive) return {
12935
13007
  destroyed: false,
@@ -12950,9 +13022,27 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
12950
13022
  return [{
12951
13023
  provider: provider.name,
12952
13024
  environmentId,
12953
- ...preserved ? { keptFor: "evidence" } : {}
13025
+ ...preserved ? { keptFor: "evidence" } : holdingForContinuation ? { keptFor: "continuation" } : {}
12954
13026
  }];
12955
13027
  },
13028
+ heldForContinuation() {
13029
+ const held = environment;
13030
+ if (!holdingForContinuation || held === void 0 || destroyed) return void 0;
13031
+ return {
13032
+ provider: provider.name,
13033
+ environmentId: held.id,
13034
+ release: async (signal) => {
13035
+ if (!holdingForContinuation) return { destroyed: true };
13036
+ holdingForContinuation = false;
13037
+ return await destroyEnvironment(signal);
13038
+ },
13039
+ handOver: () => {
13040
+ holdingForContinuation = false;
13041
+ environment = void 0;
13042
+ destroyed = true;
13043
+ }
13044
+ };
13045
+ },
12956
13046
  releaseRetained: withoutRunningHarness(async (signal) => {
12957
13047
  controller.abort();
12958
13048
  if (!pending) return [];
@@ -13147,10 +13237,17 @@ async function* streamProviderExecutor(args) {
13147
13237
  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
13238
  const handCaptureToOwner = (reported, captureOutcome, publish, beforeCapture) => {
13149
13239
  args.retention?.onEndOfTurnWork?.((async () => {
13240
+ const finalCopy = (async () => {
13241
+ try {
13242
+ await beforeCapture?.();
13243
+ } catch {}
13244
+ })();
13245
+ let snapshot;
13150
13246
  try {
13151
- await beforeCapture?.();
13152
- } catch {}
13153
- const snapshot = await args.captureWorkspace(environment, captureOutcome);
13247
+ snapshot = await args.captureWorkspace(environment, captureOutcome);
13248
+ } finally {
13249
+ await finalCopy;
13250
+ }
13154
13251
  if (publish) args.onPublishedSnapshot(snapshot);
13155
13252
  if (snapshot === void 0) return;
13156
13253
  await args.retention?.onEvidence?.({
@@ -13330,7 +13427,9 @@ async function* streamProviderExecutor(args) {
13330
13427
  } finally {
13331
13428
  await stopEndedHarness();
13332
13429
  if (!finalCopyTaken) await args.finishNativeMirror(environment, failed ? "failed" : settled !== void 0 ? "settled" : "interrupted");
13333
- if ((!source.retained || settled !== void 0 && !failed) && !(source.retained && args.retention?.preserveEnvironment) && !(unavailable !== void 0 && !failed) && (args.options.destroyOnSettle ?? true)) {
13430
+ const held = source.retained && settled !== void 0 && !failed && unavailable === void 0 && args.retention?.preserveEnvironment !== true && args.retention?.holdOnSettle?.(settled.spent) === true;
13431
+ if (held) args.onHeld();
13432
+ if ((!source.retained || settled !== void 0 && !failed) && !(source.retained && args.retention?.preserveEnvironment) && !(unavailable !== void 0 && !failed) && !held && (args.options.destroyOnSettle ?? true)) {
13334
13433
  const cleanup = await args.destroyEnvironment();
13335
13434
  if (!cleanup.destroyed) {
13336
13435
  const error = new Error(cleanup.detail ?? "provider environment teardown was not confirmed");
@@ -19370,7 +19469,10 @@ function checkedSeatSelection(stage, selected) {
19370
19469
  * is being burned. Within that window it consumes neither `maxAttempts` nor the barren streak,
19371
19470
  * exactly like a pause, and only the deadline, the budget, and cancellation bound it. After the
19372
19471
  * 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,
19472
+ * rather than hours. The exception is a box that was created and then failed its setup (Sandbox's
19473
+ * `PartialFailureError`): it meets the same failure on every re-entry, so a second identical
19474
+ * attempt with no progress stops with `repeated-failure` (`SAME_PARTIAL_FAILURE_LIMIT`). A failure
19475
+ * that spent tokens without delivering keeps the bounds above,
19374
19476
  * because that is the burn the progress rule exists to stop. Measured 2026-10-04 on Discovery run research-nqs-20261003system2: a Platform
19375
19477
  * restart answered `HTTP 502 ... Platform key verification unavailable` from 03:04:34 to 03:09:41Z,
19376
19478
  * and the coordinator's twelve attempts ran out at 03:07:12Z with no token spent, while a sibling
@@ -19400,6 +19502,40 @@ const REPEATED_FAILURE_WINDOW_MS = 5 * 6e4;
19400
19502
  /** Consecutive identical reconciliation failures of one pending invocation that resolve it. */
19401
19503
  const SAME_PENDING_LIMIT = 2;
19402
19504
  /**
19505
+ * Consecutive attempts that end in the same Sandbox `PartialFailureError`, with nothing gained
19506
+ * between them, that stop the loop. That error is a box that was created and then failed its
19507
+ * setup (its profile files would not materialize, it did not become ready). The retained
19508
+ * execution is bound durably to the node, so each re-entry meets the same box and the same
19509
+ * failure. Discovery run queens21-h22-capture-root-1-20261019c re-entered four such boxes 154
19510
+ * times in 37 minutes on `mkdir: cannot create directory '/work': Read-only file system`, one
19511
+ * box per root, each inside the transient-outage window that retries a failure which spent
19512
+ * nothing. A second identical attempt proves what a third would repeat; a different failure, or
19513
+ * any progress, starts the count over.
19514
+ */
19515
+ const SAME_PARTIAL_FAILURE_LIMIT = 2;
19516
+ /** Longest cause chain read for a `PartialFailureError`; the failing box's error sits one or two wrappers down. */
19517
+ const PARTIAL_FAILURE_CAUSE_DEPTH = 6;
19518
+ /**
19519
+ * True when `error` or one of its causes is Sandbox's `PartialFailureError`. Read by name: the
19520
+ * class lives in `@tangle-network/sandbox`, which Runtime does not import, and a failure crosses
19521
+ * packages that may each hold their own copy of it, so `instanceof` would miss it.
19522
+ */
19523
+ function causedByPartialFailure(error) {
19524
+ const seen = /* @__PURE__ */ new Set();
19525
+ let current = error;
19526
+ for (let depth = 0; depth <= PARTIAL_FAILURE_CAUSE_DEPTH; depth += 1) {
19527
+ if (!(current instanceof Error) || seen.has(current)) return false;
19528
+ seen.add(current);
19529
+ try {
19530
+ if (errorProperty(current, "name") === "PartialFailureError") return true;
19531
+ current = current.cause;
19532
+ } catch {
19533
+ return false;
19534
+ }
19535
+ }
19536
+ return false;
19537
+ }
19538
+ /**
19403
19539
  * The pending invocation a failure left, when abandoning it is the resolution: the provider
19404
19540
  * answered and could not resolve the execution (`unobservable`), or a nested manager's recovery
19405
19541
  * could not be rebuilt (`nested-recovery`). A lost transport waits for the provider instead, in
@@ -19527,6 +19663,22 @@ function capacityCode(error) {
19527
19663
  function isUpstreamUnavailable(error) {
19528
19664
  return upstreamUnavailableSignal(error) !== void 0;
19529
19665
  }
19666
+ /** The error and its causes (`cause`, and `errors` members), bounded and cycle-safe. */
19667
+ function causeChain(error) {
19668
+ const chain = [];
19669
+ const queue = [error];
19670
+ while (queue.length > 0 && chain.length < 12) {
19671
+ const value = queue.shift();
19672
+ if (typeof value !== "object" || value === null || chain.includes(value)) continue;
19673
+ chain.push(value);
19674
+ try {
19675
+ const errors = Reflect.get(value, "errors");
19676
+ if (Array.isArray(errors)) queue.push(...errors);
19677
+ queue.push(Reflect.get(value, "cause"));
19678
+ } catch {}
19679
+ }
19680
+ return chain;
19681
+ }
19530
19682
  /**
19531
19683
  * Classify one driver failure. Runtime's own typed refusals are decisions and stay terminal; an
19532
19684
  * upstream capacity refusal is `unavailable`; anything else foreign is an accident and is
@@ -19544,6 +19696,7 @@ function classifyDriverFailure(error, signal) {
19544
19696
  if (error instanceof Error && errorProperty(error, "name") === "AbortError") return "terminal";
19545
19697
  if (error instanceof Error && isProviderSchemaRejection(error)) return "terminal";
19546
19698
  if (isCredentialRefusal(error)) return "terminal";
19699
+ if (causeChain(error).some(isProvisioningRefusal)) return "terminal";
19547
19700
  if (error instanceof HarnessTurnFailedError) {
19548
19701
  if (error.errorCode !== void 0 && DETERMINISTIC_BRIDGE_CODES.has(error.errorCode)) return "terminal";
19549
19702
  if (isUpstreamUnavailable(error)) return "unavailable";
@@ -19717,6 +19870,7 @@ async function runDriverWithRetry(run) {
19717
19870
  let consecutivePauses = 0;
19718
19871
  let samePending;
19719
19872
  let sameFailure;
19873
+ let samePartial;
19720
19874
  let abandonments = 0;
19721
19875
  let pauses = 0;
19722
19876
  let continuations = 0;
@@ -19851,12 +20005,17 @@ async function runDriverWithRetry(run) {
19851
20005
  since: failedAt
19852
20006
  };
19853
20007
  const repeated = sameFailure !== void 0 && sameFailure.count >= REPEATED_FAILURE_LIMIT && failedAt - sameFailure.since >= REPEATED_FAILURE_WINDOW_MS;
20008
+ samePartial = classification === "transient" && !progressed && pending === void 0 && causedByPartialFailure(error) ? {
20009
+ error: failure,
20010
+ count: samePartial?.error === failure ? samePartial.count + 1 : 1
20011
+ } : void 0;
19854
20012
  const stop = (() => {
19855
20013
  if (classification === "terminal") return "terminal-error";
19856
20014
  if (!retryEnabled) return "retry-disabled";
19857
20015
  if (run.signal.aborted) return "aborted";
19858
20016
  const byBudget = budgetStop(run.budget(), failedAt);
19859
20017
  if (byBudget) return byBudget;
20018
+ if (samePartial !== void 0 && samePartial.count >= SAME_PARTIAL_FAILURE_LIMIT) return "repeated-failure";
19860
20019
  if (inOutage) return void 0;
19861
20020
  if (chargedFailures >= maxAttempts) return "max-attempts";
19862
20021
  if (progressed) return repeated ? "repeated-failure" : void 0;
@@ -19914,6 +20073,7 @@ async function runDriverWithRetry(run) {
19914
20073
  outageSince = void 0;
19915
20074
  samePending = void 0;
19916
20075
  sameFailure = void 0;
20076
+ samePartial = void 0;
19917
20077
  abandonments = 0;
19918
20078
  const durationMs = now() - startedAt;
19919
20079
  const after = run.progress();
@@ -21724,6 +21884,7 @@ function createInPlaceCliExecutor(options) {
21724
21884
  taskPrompt,
21725
21885
  ...options.harnessTimeoutMs !== void 0 ? { harnessTimeoutMs: options.harnessTimeoutMs } : {},
21726
21886
  ...linked ? { signal: linked } : {},
21887
+ ...options.env ? { env: options.env } : {},
21727
21888
  ...options.runHarness ? { runHarness: options.runHarness } : {}
21728
21889
  });
21729
21890
  const spent = {
@@ -25707,7 +25868,7 @@ async function prepareInterruptedExecutors(opts, events, signal, now, parentId =
25707
25868
  if (!prepared) continue;
25708
25869
  }
25709
25870
  const priorMaterialization = [...owned].reverse().find((event) => event.kind === "materialized" || event.kind === "seat-materialized")?.receipt;
25710
- const continuation = latestInput !== void 0 && inputs.length > 1 && node.ownedTreeRoot === void 0 ? await leafContinuation(node, owned, latestInput, opts) : void 0;
25871
+ const continuation = latestInput !== void 0 && inputs.length > 1 && node.ownedTreeRoot === void 0 ? await leafContinuation(node, owned, latestInput, opts) : latestInput !== void 0 && node.continues !== void 0 && admissions.length === 0 && node.ownedTreeRoot === void 0 ? heldContinuation(node, events, latestInput) : void 0;
25711
25872
  recoveries.push({
25712
25873
  ...detachedSnapshot({
25713
25874
  spawned: node,
@@ -25773,6 +25934,23 @@ async function leafContinuation(node, owned, latestInput, opts) {
25773
25934
  priorSpent: priorResult.spent
25774
25935
  };
25775
25936
  }
25937
+ /**
25938
+ * A node that continues a budget-stopped node's held environment, recovered before its own first
25939
+ * admission: it runs in the environment and session of its predecessor's last environment
25940
+ * admission, so the recovery neither creates a second environment nor leaves the held one behind.
25941
+ */
25942
+ function heldContinuation(node, events, latestInput) {
25943
+ const continues = node.continues;
25944
+ const priorSession = [...events].reverse().flatMap((event) => event.id === continues.ofWorker && event.kind === "execution-admitted" && event.admission.phase === "environment" ? [event.admission] : [])[0];
25945
+ if (priorSession === void 0 || priorSession.environmentId !== continues.environmentId) throw new RuntimeRunStateError(`cannot recover '${node.id}': '${continues.ofWorker}' has no admission for the environment it continues`);
25946
+ return {
25947
+ task: BUDGET_CONTINUATION_TASK,
25948
+ inputSeq: latestInput.seq,
25949
+ executionId: node.id,
25950
+ priorSession,
25951
+ priorSpent: zeroSpend()
25952
+ };
25953
+ }
25776
25954
  async function assertRecordedResult(node, result, events, opts) {
25777
25955
  const before = events.slice(0, events.indexOf(result));
25778
25956
  const receipt = [...before].reverse().find((event) => event.kind === "materialized" || event.kind === "seat-materialized")?.receipt;
@@ -27890,6 +28068,7 @@ const pauseRecorders = /* @__PURE__ */ new WeakMap();
27890
28068
  const driverAttemptRecorders = /* @__PURE__ */ new WeakMap();
27891
28069
  const recoveryStarters = /* @__PURE__ */ new WeakMap();
27892
28070
  const retainedReleasers = /* @__PURE__ */ new WeakMap();
28071
+ const heldReleasers = /* @__PURE__ */ new WeakMap();
27893
28072
  const childDrains = /* @__PURE__ */ new WeakMap();
27894
28073
  const retainedSlotClosers = /* @__PURE__ */ new WeakMap();
27895
28074
  const teardownRetriers = /* @__PURE__ */ new WeakMap();
@@ -27956,6 +28135,17 @@ function unconfirmedTeardownOf(child, releasing) {
27956
28135
  ...child.teardownDetail === void 0 ? {} : { detail: child.teardownDetail }
27957
28136
  });
27958
28137
  }
28138
+ /** Ten minutes: a manager that is alive decides within a turn or two; one that crashed, or a host
28139
+ * that restarted, must not leave a paid environment running until a retire pass finds it. */
28140
+ const DEFAULT_BUDGET_STOP_HOLD_MS = 6e5;
28141
+ /**
28142
+ * @internal Release every environment this scope's settled children still hold after a budget
28143
+ * stop, at the join barrier: no later spawn of this scope can continue them. Each release journals
28144
+ * an `environment-teardown` with `heldRelease: 'scope-join'`. Never rejects.
28145
+ */
28146
+ async function releaseHeldEnvironments(scope) {
28147
+ await heldReleasers.get(scope)?.();
28148
+ }
27959
28149
  /** @internal Admit original children before the parent acts; do not wait for their results. */
27960
28150
  async function startScopeRecoveries(scope) {
27961
28151
  const start = recoveryStarters.get(scope);
@@ -28144,6 +28334,7 @@ function makeNestedScopeSeam(args, workerSlots, childSlot, childNodeId, childBud
28144
28334
  ownerBudget: nestedBudget
28145
28335
  } : {},
28146
28336
  ...args.deadlineCheckIn === void 0 ? {} : { deadlineCheckIn: args.deadlineCheckIn },
28337
+ ...args.budgetStopHoldMs === void 0 ? {} : { budgetStopHoldMs: args.budgetStopHoldMs },
28147
28338
  signal,
28148
28339
  ...restored ? { resumeFrom: restored.resumeFrom } : {},
28149
28340
  ...args.now ? { now: args.now } : {},
@@ -28262,6 +28453,7 @@ function createScope(args) {
28262
28453
  const task = detachedSnapshot(rawTask, "scope.spawn task");
28263
28454
  const opts = detachedSnapshot(rawOpts, "scope.spawn options");
28264
28455
  let prior;
28456
+ let continuing;
28265
28457
  let prepared;
28266
28458
  const prepare = () => {
28267
28459
  const agent = typeof agentOrFactory === "function" ? agentOrFactory() : agentOrFactory;
@@ -28295,14 +28487,28 @@ function createScope(args) {
28295
28487
  ok: false,
28296
28488
  reason: "duplicate-key"
28297
28489
  };
28298
- if (existing?.state === "done") return {
28299
- ok: true,
28300
- handle: existing.settled.handle,
28301
- prior: {
28302
- state: "completed",
28303
- settled: existing.settled
28304
- }
28305
- };
28490
+ if (existing?.state === "done") {
28491
+ const from = children.get(existing.id);
28492
+ const admission = opts.continueHeld === true && existing.settled.budgetViolation !== void 0 ? from?.held !== void 0 ? from.readEnvironmentAdmission?.() : void 0 : void 0;
28493
+ if (from?.held === void 0 || admission === void 0) return {
28494
+ ok: true,
28495
+ handle: existing.settled.handle,
28496
+ prior: {
28497
+ state: "completed",
28498
+ settled: existing.settled
28499
+ }
28500
+ };
28501
+ continuing = {
28502
+ from,
28503
+ admission,
28504
+ held: from.held
28505
+ };
28506
+ prior = {
28507
+ state: "continued",
28508
+ priorId: existing.id,
28509
+ environmentId: from.held.continuation.environmentId
28510
+ };
28511
+ }
28306
28512
  if (existing?.state === "down") prior = {
28307
28513
  state: "retried",
28308
28514
  priorId: existing.id,
@@ -28364,6 +28570,7 @@ function createScope(args) {
28364
28570
  try {
28365
28571
  const ordinal = recovery?.spawned.seq ?? spawnOrdinal++;
28366
28572
  const id = recovery?.spawned.id ?? `${args.parentId}:s${ordinal}`;
28573
+ const successorOf = opts.successorOf ?? continuing?.from.id;
28367
28574
  args.pool.attribute(reservation.ticket, {
28368
28575
  childId: id,
28369
28576
  stage: "admitted"
@@ -28475,6 +28682,8 @@ function createScope(args) {
28475
28682
  at: new Date(now()).toISOString()
28476
28683
  });
28477
28684
  });
28685
+ const holdMs = args.budgetStopHoldMs ?? 6e5;
28686
+ const holdOnSettle = opts.key !== void 0 && holdMs > 0 ? (spent) => overBudget(opts.budget, spent) || childDeadlineAtMs !== void 0 && now() > childDeadlineAtMs : void 0;
28478
28687
  const retainedContext = (continuing) => ({
28479
28688
  ...continuing === void 0 ? {} : {
28480
28689
  executionId: continuing.executionId,
@@ -28482,6 +28691,7 @@ function createScope(args) {
28482
28691
  ...continuing.priorSpent === void 0 ? {} : { priorSpent: continuing.priorSpent }
28483
28692
  },
28484
28693
  admissions,
28694
+ ...holdOnSettle === void 0 ? {} : { holdOnSettle },
28485
28695
  ...markRecoveryReady && continuing === void 0 ? { onReady: markRecoveryReady } : {},
28486
28696
  onAdmission,
28487
28697
  onResult,
@@ -28539,11 +28749,14 @@ function createScope(args) {
28539
28749
  },
28540
28750
  seams: {
28541
28751
  ...args.seams,
28542
- [retainedExecutorSeamKey]: retainedContext(recovery?.continuation === void 0 ? void 0 : {
28752
+ [retainedExecutorSeamKey]: retainedContext(recovery?.continuation !== void 0 ? {
28543
28753
  executionId: recovery.continuation.executionId,
28544
28754
  priorSession: recovery.continuation.priorSession,
28545
28755
  priorSpent: recovery.continuation.priorSpent
28546
- }),
28756
+ } : continuing !== void 0 ? {
28757
+ executionId: id,
28758
+ priorSession: continuing.admission
28759
+ } : void 0),
28547
28760
  [nestedScopeSeamKey]: makeNestedScopeSeam(args, workerSlots, permit, id, opts.budget, childDeadlineAtMs, deferredOwner),
28548
28761
  ...workerTrace ? { [workerTraceSeamKey]: workerTrace } : {},
28549
28762
  ...interactiveBindingDir ? { [interactiveAdmissionSeamKey]: (admission) => Promise.resolve(writeWorkerInteractiveAdmission(interactiveBindingDir, id, admission, now)).then(() => void 0) } : {}
@@ -28615,7 +28828,11 @@ function createScope(args) {
28615
28828
  ...nestedTeardownScopes.has(executor) ? { readNestedScope: nestedTeardownScopes.get(executor) } : {},
28616
28829
  ...executor.harnessTranscript ? { readTranscriptAtRelease: () => persistHarnessTranscript(readHarnessTranscript(executor), args.blobs) } : {},
28617
28830
  teardownAttempts: 0,
28618
- abortChild: (reason) => controller.abort(reason)
28831
+ abortChild: (reason) => controller.abort(reason),
28832
+ readEnvironmentAdmission: () => {
28833
+ const admission = admissions.find((record) => record.phase === "environment");
28834
+ return admission?.phase === "environment" ? admission : void 0;
28835
+ }
28619
28836
  };
28620
28837
  const recordCancellation = () => {
28621
28838
  if (!live.executorDone && live.acceptedResult === void 0 && executor.resultAccepted?.() !== true && controller.signal.reason instanceof RunCancellationReason) live.cancellationReason = controller.signal.reason;
@@ -28638,7 +28855,11 @@ function createScope(args) {
28638
28855
  label: opts.label,
28639
28856
  ...opts.key !== void 0 ? { key: opts.key } : {},
28640
28857
  ...opts.assignmentId === void 0 ? {} : { assignmentId: opts.assignmentId },
28641
- ...opts.successorOf === void 0 ? {} : { successorOf: opts.successorOf },
28858
+ ...successorOf === void 0 ? {} : { successorOf },
28859
+ ...continuing === void 0 ? {} : { continues: {
28860
+ ofWorker: continuing.from.id,
28861
+ environmentId: continuing.admission.environmentId
28862
+ } },
28642
28863
  budget: opts.budget,
28643
28864
  runtime: executor.runtime,
28644
28865
  ...ownedTreeRoot === void 0 ? {} : { ownedTreeRoot },
@@ -28786,7 +29007,7 @@ function createScope(args) {
28786
29007
  label: opts.label,
28787
29008
  ...opts.assignmentId === void 0 ? {} : { assignmentId: opts.assignmentId },
28788
29009
  ...opts.key === void 0 ? {} : { key: opts.key },
28789
- ...opts.successorOf === void 0 ? {} : { successorOf: opts.successorOf },
29010
+ ...successorOf === void 0 ? {} : { successorOf },
28790
29011
  runtime: executor.runtime,
28791
29012
  ...identity ? { identity } : {},
28792
29013
  agent: authoredAgentIdentity(spec.profile, identity?.profileDigest),
@@ -28796,10 +29017,16 @@ function createScope(args) {
28796
29017
  startedAt
28797
29018
  }
28798
29019
  }, { signal: args.signal });
28799
- const childRun = runChild(live, executor, controller, recovery?.continuation?.task ?? task, opts, args.pool, reservation.ticket, args.blobs, now, args.journal, args.root, () => progressSeq++, materializationCommitted, {
29020
+ if (continuing !== void 0) {
29021
+ continuing.held.clearCeiling?.();
29022
+ continuing.held.continuation.handOver();
29023
+ continuing.from.held = void 0;
29024
+ continuing.from.cleanupConfirmed = true;
29025
+ }
29026
+ const childRun = runChild(live, executor, controller, recovery?.continuation?.task ?? (continuing === void 0 ? task : "Your previous turn reached its budget and stopped. Your manager gave you more budget to continue the same task in the same session: your conversation so far and the files in your workspace are where you left them. Continue from where you stopped. Do not start over."), opts, args.pool, reservation.ticket, args.blobs, now, args.journal, args.root, () => progressSeq++, materializationCommitted, {
28800
29027
  complete: async () => pendingEvidence?.complete(),
28801
29028
  fail: async () => pendingEvidence?.fail()
28802
- }, childDeadlineAtMs, recovery !== void 0, closeRetainedWrites, budgetGranted, permit.ready, recovery?.continuation?.priorSpent);
29029
+ }, childDeadlineAtMs, recovery !== void 0, closeRetainedWrites, budgetGranted, permit.ready, recovery?.continuation?.priorSpent, startedAt);
28803
29030
  args.pool.attribute(reservation.ticket, { stage: "executing" });
28804
29031
  const interactiveBindingCommitted = spawnCommitted.then(async () => {
28805
29032
  if (args.interactiveBindingDir === void 0) return;
@@ -28827,6 +29054,11 @@ function createScope(args) {
28827
29054
  };
28828
29055
  }
28829
29056
  live.resolved = resolution;
29057
+ if (live.held !== void 0) if (resolution.kind === "done") {
29058
+ const timer = setTimeout(() => void releaseHeld(live, "hold-ceiling"), holdMs);
29059
+ timer.unref?.();
29060
+ live.held.clearCeiling = () => clearTimeout(timer);
29061
+ } else await releaseHeld(live, "scope-join");
28830
29062
  return resolution;
28831
29063
  }).finally(() => {
28832
29064
  permit.release();
@@ -28848,6 +29080,32 @@ function createScope(args) {
28848
29080
  throw err;
28849
29081
  }
28850
29082
  }
29083
+ const heldReleases = /* @__PURE__ */ new Set();
29084
+ /** Release the environment a settled child holds after a budget stop, once, and journal why. */
29085
+ function releaseHeld(child, reason) {
29086
+ const held = child.held;
29087
+ if (held === void 0) return Promise.resolve(false);
29088
+ child.held = void 0;
29089
+ held.clearCeiling?.();
29090
+ const release = (async () => {
29091
+ const answer = await held.continuation.release().catch((error) => ({
29092
+ destroyed: false,
29093
+ detail: errMessage(error)
29094
+ }));
29095
+ if (answer.destroyed) child.cleanupConfirmed = true;
29096
+ else if (answer.detail !== void 0) child.teardownDetail = answer.detail;
29097
+ await appendEnvironmentTeardown(args.journal, args.root, child.id, {
29098
+ provider: held.continuation.provider,
29099
+ environmentId: held.continuation.environmentId,
29100
+ destroyed: answer.destroyed,
29101
+ ...answer.detail === void 0 ? {} : { detail: answer.detail }
29102
+ }, new Date(now()).toISOString(), reason).catch(() => void 0);
29103
+ return true;
29104
+ })();
29105
+ heldReleases.add(release);
29106
+ release.finally(() => heldReleases.delete(release));
29107
+ return release;
29108
+ }
28851
29109
  async function commitSettlement(child, settlement, seq) {
28852
29110
  const pending = finalizeSettlement(child, settlement, seq, args, now).then((delivered) => {
28853
29111
  if (child.key !== void 0) recordKeyedSettlement(child.key, delivered);
@@ -29030,6 +29288,10 @@ function createScope(args) {
29030
29288
  next,
29031
29289
  nextResolved,
29032
29290
  send,
29291
+ releaseHeld: (nodeId, reason) => {
29292
+ const child = children.get(nodeId);
29293
+ return child === void 0 ? Promise.resolve(false) : releaseHeld(child, reason);
29294
+ },
29033
29295
  progress,
29034
29296
  observeTree: () => {
29035
29297
  const view = makeTreeView(args.parentId, children);
@@ -29094,6 +29356,10 @@ function createScope(args) {
29094
29356
  admissionSeals.set(scope, () => {
29095
29357
  admissionClosed = true;
29096
29358
  });
29359
+ heldReleasers.set(scope, async () => {
29360
+ await Promise.all([...children.values()].map((child) => releaseHeld(child, "scope-join")));
29361
+ await Promise.allSettled([...heldReleases]);
29362
+ });
29097
29363
  subtreeReaders.set(scope, () => summarizeTeam(children.values()));
29098
29364
  liveTeamReaders.set(scope, () => readLiveTeam(children.values(), ownerTurns, ownerLastTurnAt));
29099
29365
  runtimeOwnedProviderMeters.set(scope, async (spend, providerModel, detail, accountingOnly, alreadySpent) => meterInternal(spend, detail, providerModel, accountingOnly, true, alreadySpent));
@@ -29684,7 +29950,7 @@ async function appendReconciledFloor(journal, root, subject, settlement, settled
29684
29950
  }
29685
29951
  /** A release receipt has the same per-child sequence discipline: outside the cursor namespace and
29686
29952
  * monotonic per node, so a run released in two processes keeps its receipts ordered. */
29687
- async function appendEnvironmentTeardown(journal, root, id, receipt, at) {
29953
+ async function appendEnvironmentTeardown(journal, root, id, receipt, at, heldRelease) {
29688
29954
  const seq = await nextPerNodeSeq(journal, root, "environment-teardown", id);
29689
29955
  await journal.appendEvent(root, {
29690
29956
  kind: "environment-teardown",
@@ -29693,10 +29959,15 @@ async function appendEnvironmentTeardown(journal, root, id, receipt, at) {
29693
29959
  environmentId: receipt.environmentId,
29694
29960
  destroyed: receipt.destroyed,
29695
29961
  ...receipt.detail === void 0 ? {} : { detail: receipt.detail },
29962
+ ...heldRelease === void 0 ? {} : { heldRelease },
29696
29963
  seq,
29697
29964
  at
29698
29965
  });
29699
29966
  }
29967
+ /** Whether a settled spend exceeds the budget it was given, by the channels the pool reconciles. */
29968
+ function overBudget(budget, spent) {
29969
+ return chargedTokens(spent.tokens) > budget.maxTokens || spent.iterations > budget.maxIterations || budget.maxUsd !== void 0 && spent.usdKnown !== false && spent.usd > budget.maxUsd;
29970
+ }
29700
29971
  async function nextPerNodeSeq(journal, root, kind, id) {
29701
29972
  return (await journal.loadTree(root) ?? []).reduce((max, event) => event.kind === kind && event.id === id ? Math.max(max, event.seq) : max, -1) + 1;
29702
29973
  }
@@ -29844,7 +30115,7 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
29844
30115
  * applied per child). The reservation is reconciled on EVERY path (success, abort, throw)
29845
30116
  * so the conserved pool can never leak a reservation.
29846
30117
  */
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) {
30118
+ 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
30119
  if (priorSpent !== void 0) live.spent = detachedSnapshot(priorSpent, "prior committed usage");
29849
30120
  let reconciled = false;
29850
30121
  let reconciliationError;
@@ -29889,6 +30160,7 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
29889
30160
  if (teardownStarted) return;
29890
30161
  teardownStarted = true;
29891
30162
  try {
30163
+ await executor.heldForContinuation?.()?.release();
29892
30164
  await teardownExecutor(executor, grace, deadlineAtMs, now, live.askTeardown);
29893
30165
  live.cleanupConfirmed = true;
29894
30166
  } catch (error) {
@@ -29921,6 +30193,12 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
29921
30193
  throw error;
29922
30194
  }
29923
30195
  live.budgetViolation = pool.reconcile(ticket, spend);
30196
+ const settledAt = now();
30197
+ if (deadlineAtMs !== void 0 && startedAt !== void 0 && settledAt > deadlineAtMs) live.budgetViolation = { overspent: [...live.budgetViolation?.overspent ?? [], {
30198
+ channel: "deadline",
30199
+ reserved: deadlineAtMs - startedAt,
30200
+ spent: settledAt - startedAt
30201
+ }] };
29924
30202
  return;
29925
30203
  } catch (error) {
29926
30204
  if (error instanceof BudgetReconcileFault) live.budgetViolation = error.budgetViolation;
@@ -29989,7 +30267,9 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
29989
30267
  outRef
29990
30268
  };
29991
30269
  }
29992
- await teardownOnce(opts.shutdown ?? 5e3);
30270
+ const held = executor.heldForContinuation?.();
30271
+ if (held !== void 0 && live.budgetViolation !== void 0) live.held = { continuation: held };
30272
+ else await teardownOnce(opts.shutdown ?? 5e3);
29993
30273
  return {
29994
30274
  kind: "done",
29995
30275
  out: artifact.out,
@@ -30748,6 +31028,7 @@ function withDriverExecutor(base) {
30748
31028
  async function closeNestedScope(scope, controller, reason) {
30749
31029
  if (!controller.signal.aborted) controller.abort(reason);
30750
31030
  for (;;) if (await scope.next() === null) break;
31031
+ await releaseHeldEnvironments(scope);
30751
31032
  const view = scope.view;
30752
31033
  if (view.inFlight > 0) throw new ValidationError$1(`driverExecutor: nested cleanup left ${view.inFlight} running nodes`);
30753
31034
  }
@@ -31241,7 +31522,7 @@ function describeRejection(error) {
31241
31522
  function createSupervisor() {
31242
31523
  let attached;
31243
31524
  async function run(root, task, opts) {
31244
- const { budget, rootIdentity, rootSegment, rootMaterialization, runId, journal: journalStore, blobs: blobStore, executors: executorRegistry, recoverExecutor, maxDepth, workerSlots, reservationPolicy, deadlineCheckIn, maxRestarts, withinMs, childSettleGraceMs, teardownConfirmMs, resume, retainedAtSettlement: requestedRetainedAtSettlement, ownerWorkspaceRetention, now: suppliedNow, signal, hooks, workerTrace, workerTraceUnpropagated, interactiveBindingDir } = opts;
31525
+ const { budget, rootIdentity, rootSegment, rootMaterialization, runId, journal: journalStore, blobs: blobStore, executors: executorRegistry, recoverExecutor, maxDepth, workerSlots, reservationPolicy, deadlineCheckIn, budgetStopHoldMs, maxRestarts, withinMs, childSettleGraceMs, teardownConfirmMs, resume, retainedAtSettlement: requestedRetainedAtSettlement, ownerWorkspaceRetention, now: suppliedNow, signal, hooks, workerTrace, workerTraceUnpropagated, interactiveBindingDir } = opts;
31245
31526
  const input = detachedSnapshot({
31246
31527
  task,
31247
31528
  options: {
@@ -31389,6 +31670,7 @@ function createSupervisor() {
31389
31670
  ownerBudget: opts.budget
31390
31671
  } : {},
31391
31672
  ...deadlineCheckIn === void 0 ? {} : { deadlineCheckIn },
31673
+ ...budgetStopHoldMs === void 0 ? {} : { budgetStopHoldMs },
31392
31674
  signal: controller.signal,
31393
31675
  now,
31394
31676
  hooks: opts.hooks,
@@ -31455,7 +31737,9 @@ function createSupervisor() {
31455
31737
  clearAcceptedGrace?.();
31456
31738
  const settleGraceMs = !controller.signal.aborted ? boundedSettleGrace(opts.childSettleGraceMs, rootDeadlineAtMs, now) : 0;
31457
31739
  try {
31458
- teardownUnconfirmed = await drainLiveChildren(openScope, controller, settleGraceMs);
31740
+ await drainLiveChildren(openScope, controller, settleGraceMs);
31741
+ await releaseHeldEnvironments(openScope);
31742
+ teardownUnconfirmed = unconfirmedTeardowns(openScope);
31459
31743
  await settleManagerWork(openScope);
31460
31744
  if (!persistence.failed && retainedAtSettlement === "release") teardownUnconfirmed = await releaseRetainedEnvironments(openScope);
31461
31745
  const confirmWindowMs = opts.teardownConfirmMs ?? DEFAULT_TEARDOWN_CONFIRM_MS;
@@ -32027,6 +32311,6 @@ function isNonEmptySpend(s) {
32027
32311
  return s.iterations > 0 || s.tokens.input > 0 || s.tokens.output > 0 || s.usd > 0 || s.ms > 0 || s.tokensKnown === false || s.usdKnown === false || Object.values(s.resources ?? {}).some((resource) => resource.amount > 0 || !resource.known);
32028
32312
  }
32029
32313
  //#endregion
32030
- 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 };
32314
+ export { attachWorker as $, decodeHarnessUsage as $i, captureHarnessTranscript as $n, promptOnlyProfileMaterialization as $r, CONTINUATION_FACTS as $t, bindScopeRetainedOwnerEnvironmentId as A, promptOptionsFromAgentTurnInput as Aa, readSandboxOutcome as Ai, LEAF_CONTINUATION_TASK as An, sanitizeRuntimeStreamEvent as Ar, createInbox as At, scopeRetainedOwnerResourceReader as B, TRACE_SUMMARY_SCHEMA as Bi, reconnectRetainedRun as Bn, localHarnessExecutable as Br, isTerminalNodeStatus as Bt, recordScopeOwnerMaterialization as C, newUsageTotals as Ca, runtimeOwnedPendingExecutorMaterialization as Ci, acquireSandbox as Cn, padSpanId as Cr, workerTraceEnv as Ct, settledToIteration as D, defaultRedactorIdentityMaterial as Da, executableAgentProfileSnapshot as Di, readPromptOptions as Dn, createRuntimeStreamEventCollector as Dr, DEFAULT_STALL_AFTER_MS as Dt, scopeOwnerExecutorNodeContext as E, defaultRedactor as Ea, unknownMaterializationReceipt as Ei, assertBoxlessPromptOptions as En, createRuntimeEventCollector as Er, taskToPrompt as Et, prepareScopeRetainedOwnerTask as F, registerRetainedExecutorPreparation as Fi, createPushTraceSource as Fn, removeWorktree as Fr, createPeerMailbox as Ft, environmentReader as G, extractLlmCallEvent as Gi, destroyInteractiveEnvironment as Gn, assertProfileMaterialization as Gr, summarizeDriverAttempts as Gt, scopeRetainedOwnerResult as H, canonicalStreamEventFromSandboxEvent as Hi, startRetainedRun as Hn, CodexExecutionDiagnosticError as Hr, HarnessTurnFailedError as Ht, reconcileScopeRetainedOwnerEnvironment as I, retainedExecutorSeamKey as Ii, decodeToolPart as In, DEFAULT_LOCAL_HARNESS as Ir, isPeerMailEnvelope as It, coordinationMcpAlias as J, mapSandboxToolEvent as Ji, openSlotGroup as Jn, defineProfileMaterializationContract as Jr, SeatChainExhaustedError as Jt, hostDirectoryReader as K, isSandboxTerminalEvent as Ki, environmentGone as Kn, assertProfileMaterializes as Kr, upstreamUnavailableSignal as Kt, scopeRetainedOwnerContext as L, unavailablePauseMs as Li, sandboxSessionTraceSource as Ln, LOCAL_HARNESSES as Lr, peerMailTools as Lt, consumeScopeRetainedOwnerResult as M, awaitAbortable$1 as Mi, providerAsExecutor as Mn, runWorktreeHarness as Mr, DEFAULT_PEER_MAIL_LIMITS as Mt, noteScopeRetainedOwnerCoordination as N, runtimeFailureCause as Ni, providerAsSandboxClient as Nn, captureWorktreeDiff as Nr, PEER_MAIL_WIRE_KEY as Nt, abandonScopeRetainedOwnerInvocation as O, resolveRedactor as Oa, executableAgentSpecSnapshot as Oi, routerBrain as On, sanitizeAgentRuntimeEvent as Or, createActivityLog as Ot, prepareScopeRetainedOwnerSeatSwitch as P, settlementFailureCause as Pi, resolveAgentEnvironmentProvider as Pn, createWorktree as Pr, claimsAuthority as Pt, interactiveAdmissionSeamKey as Q, sumSandboxUsage as Qi, runAbortable as Qn, promptModelProfileMaterialization as Qr, CONTINUATIONS_DIR as Qt, scopeRetainedOwnerJournalRoot as R, unavailableSignalOfFailure as Ri, bridgeRuntimeAttachmentsKey as Rn, harnessInvocation as Rr, peerMailVerbNames as Rt, recordScopeOwnerDriverAttempt as S, meterUsageEvent as Sa, runtimeOwnedExecutorProviderEvidence as Si, createSandboxLineage as Sn, loopEventToOtelSpan as Sr, readWorkerTraceContext as St, restoreScopeOwnerAcceptedExecution as T, spendFromUsageTotals as Ta, unknownExecutionBindingReceipt as Ti, captureBeforeDestroy as Tn, toOtelAttributes as Tr, workerTraceSeamKey as Tt, scopeRetainedOwnerTurnEnded as U, createSandboxToolPartState as Ui, startRetainedRunInEnvironment as Un, terminateProcessTreeAndConfirm as Ur, classifyDriverFailure as Ut, scopeRetainedOwnerRestorePoint as V, assertSandboxServedModel as Vi, recoverRetainedRun as Vn, parseCodexTokenUsage as Vr, DriverAttemptsExhaustedError as Vt, SPAWN_RESOURCE_PATH_MAX_BYTES as W, createSandboxUsageLedger as Wi, retainedCreateMaterial as Wn, AGENT_PROFILE_MATERIALIZATION_AXES as Wr, runDriverWithRetry as Wt, providerVisibleProfile as X, sandboxEventServedBackend as Xi, abortError as Xn, profileMaterializationAxes$1 as Xr, seatExecutionProfile as Xt, coordinationProfileToolPrefix as Y, notifySandboxEventObserver as Yi, RunCancellationReason as Yn, fullProfileMaterialization as Yr, authoredSeatStages as Yt, runtimeGraphMetadataKey as Z, sandboxProgressEvents as Zi, linkAbort as Zn, promptControlProfileMaterialization as Zr, subscriptionUsageLimitSignal as Zt, createScope as _, errMessage as _a, providerAttemptEvidence as _i, TERMINAL_DECISIONS as _n, buildRuntimeEventOtelSpans as _r, DEFAULT_SANDBOX_STEERING_MAX_TURNS as _t, collectDelivered as a, loadSpawnForest as aa, unsupportedProfileDimensions as ai, createContinuationKeeper as an, createCodeModeTools as ar, queueOf as at, meterRuntimeOwnedProviderAttempt as b, assertValidBudget as ba, runtimeOwnedExecutorExecutionBinding as bi, isTerminalDecision as bn, flatOtelSpan as br, createInPlaceCliExecutor as bt, runTree as c, WORKER_TOOL_TRACE_SCHEMA_VERSION as ca, attestRuntimeOwnedPendingExecutor as ci, failedItems as cn, priceTokens as cr, mapExecutorResult as ct, isDriverSpec as d, parseWorkerToolTraceArtifact as da, authoredProfileDigest as di, bridgeAdmissionRefusal as dn, createPropagatingTraceEmitter as dr, cliInPlaceExecutor as dt, FileResultBlobStore as ea, promptResourceProfileMaterialization as ei, CheckUnavailableError as en, harnessTranscriptArtifact as er, readWorkerInteractiveBinding as et, withDriverExecutor as f, workerTraceAnalysisStore as fa, finalizeRuntimeOwnedPendingExecutor as fi, bridgeModelRouteRefusal as fn, mergeTraceEnv as fr, cliWorktreeExecutor as ft, beginScopeOwnerAttempt as g, executorFailure as ga, newExecutionAttemptId as gi, readCodexRolloutSession as gn, buildLoopSpanNodes as gr, createWorktreeCliExecutor as gt, assertRecursiveReservationPolicy as h, detachedSnapshot as ha, knownMaterializationReceipt as hi, harnessUsageIsEmpty as hn, buildLoopOtelSpans as hr, snapshotExecutorConfig as ht, bestDelivered as i, insideCursorNamespace as ia, sandboxProfileMaterialization as ii, checkVerdictOf as in, retainHarnessTranscript as ir, freeSlots as it, bindScopeRetainedOwnerProvider as j, providerMessageText as ja, abortError$1 as ji, createAgentEnvironmentProviderRegistry as jn, runSettledCommand as jr, AUTHORITY_MARKERS as jt, beginScopeRetainedOwnerDrive as k, promptFromAgentTurnInput as ka, projectSandboxOutcome as ki, runBrainLoop as kn, sanitizeKnowledgeReadinessReport as kr, readWorkerProgress as kt, driverChild as l, captureWorkerTraceEvidence as la, attestRuntimeOwnedScopeOwner as li, passedItems as ln, routerTokenPrice as lr, bindReusableExecutorExecutionId as lt, SUBTREE_RESULT_LIMIT as m, detachedFrozen as ma, knownExecutionBindingReceipt as mi, createCodexRolloutStoreReader as mn, traceContextToEnv as mr, createExecutorRegistry as mt, createRootHandle as n, InMemoryResultBlobStore as na, renderUnsupported as ni, admitFinding as nn, readHarnessTranscript as nr, recoverRetainedInteractiveRun as nt, pickBestDelivered as o, materializeTreeView as oa, validateProfileMaterialization as oi, distillFindings as on, describeCodeModeTools as or, rollingDispatch as ot, DEFAULT_BUDGET_STOP_HOLD_MS as p, contentAddress as pa, inheritRuntimeOwnedExecutorAttestation as pi, addHarnessUsage as pn, readTraceContextFromEnv as pr, createExecutor as pt, resolveSpawnResourcePaths as q, mapSandboxEvent as qi, createWorkerSlots as qn, controlProfileMaterialization as qr, SeatChain as qt, createSupervisor as r, InMemorySpawnJournal as ra, sandboxActProfileMaterialization as ri, bestComposite as rn, resolveHarnessTranscriptCapture as rr, startRetainedInteractiveRun as rt, runFinalizer as s, replaySpawnTree as sa, worktreeCliProfileMaterialization as si, expandQuestions as sn, runCodeMode as sr, gateOnDeliverable as st, DEFAULT_MAX_DEPTH as t, FileSpawnJournal as ta, renderProfileMaterializationIssues as ti, admitContinuationPolicy as tn, persistHarnessTranscript as tr, reconnectRetainedInteractiveRun as tt, driverExecutorFactory as u, isTraceAnalysisStore as ua, authoredAgentIdentity as ui, verdictFromJudgeScore as un, ROUTER_PRICE_SOURCE as ur, captureReusableExecutorConfig as ut, deriveNodeExecutionIdentity as v, BudgetReconcileFault as va, recordRuntimeOwnedDriveHarnessProviderEvidence as vi, createSandboxForSpec as vn, createOpenInferenceFileExporter as vr, createSteerableSandboxSession as vt, recordScopeOwnerPause as w, spendFromUsageEvents as wa, runtimeOwnedScopeOwnerRuntime as wi, SandboxEvidenceRetentionError as wn, padTraceId as wr, workerTraceHeaders as wt, noteScopeOwnerPlannedExecution as x, createBudgetPool as xa, runtimeOwnedExecutorMaterialization as xi, runAgentRounds as xn, generateSpanId as xr, WORKER_TRACE_PROPAGATION as xt, meterRuntimeOwnedAccounting as y, ReservationWaitRefused as ya, runtimeOwnedDriveHarnessProviderEvidence as yi, defaultSelectWinner as yn, createOtelExporter as yr, createRouterTranscript as yt, scopeRetainedOwnerPriorSpend as z, TRACE_ROOT_SCHEMA as zi, bridgeStopSignalKey as zn, harnessSupportsReasoningEffort as zr, isLiveNodeStatus as zt };
32031
32315
 
32032
- //# sourceMappingURL=supervisor-B4sM2Xu2.js.map
32316
+ //# sourceMappingURL=supervisor-B-bkXttM.js.map