@tangle-network/agent-runtime 10.0.23 → 10.0.24

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 (81) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/{activation-D_J9qCzU.js → activation-DLbBM2S0.js} +2 -2
  3. package/dist/{activation-D_J9qCzU.js.map → activation-DLbBM2S0.js.map} +1 -1
  4. package/dist/{activation-DOzkzTrl.d.ts → activation-DUYtmQH_.d.ts} +2 -2
  5. package/dist/agent.d.ts +1 -1
  6. package/dist/agent.js +3 -3
  7. package/dist/{delegate-DCZPcYy8.js → delegate-Cz2GF_z7.js} +2 -2
  8. package/dist/{delegate-DCZPcYy8.js.map → delegate-Cz2GF_z7.js.map} +1 -1
  9. package/dist/{driver-control-acknowledgers-CgGt3NcX.js → driver-control-acknowledgers-pDEPMuML.js} +7 -7
  10. package/dist/{driver-control-acknowledgers-CgGt3NcX.js.map → driver-control-acknowledgers-pDEPMuML.js.map} +1 -1
  11. package/dist/durable-writer-thread.js +2 -2
  12. package/dist/durable.d.ts +1 -1
  13. package/dist/durable.js +14 -13
  14. package/dist/durable.js.map +1 -1
  15. package/dist/{graph-B3pBmvnf.js → graph-D-LVPqrm.js} +7 -6
  16. package/dist/{graph-B3pBmvnf.js.map → graph-D-LVPqrm.js.map} +1 -1
  17. package/dist/{improve-DhOOHHRz.js → improve-BJW9OcEn.js} +5 -5
  18. package/dist/{improve-DhOOHHRz.js.map → improve-BJW9OcEn.js.map} +1 -1
  19. package/dist/index.d.ts +41 -6
  20. package/dist/index.js +55 -21
  21. package/dist/index.js.map +1 -1
  22. package/dist/intelligence.d.ts +2 -2
  23. package/dist/intelligence.js +4 -4
  24. package/dist/kernel.d.ts +1 -1
  25. package/dist/kernel.js +15 -15
  26. package/dist/{loop-runner-L594gDYR.js → loop-runner-BZWObfqa.js} +2 -2
  27. package/dist/{loop-runner-L594gDYR.js.map → loop-runner-BZWObfqa.js.map} +1 -1
  28. package/dist/{loop-runner-CcXKPnMR.d.ts → loop-runner-ClANio8o.d.ts} +2 -2
  29. package/dist/loop-runner-bin.d.ts +1 -1
  30. package/dist/loop-runner-bin.js +1 -1
  31. package/dist/mcp/bin.js +3 -3
  32. package/dist/mcp/index.d.ts +1 -1
  33. package/dist/mcp/index.js +6 -6
  34. package/dist/mcp/memory-bin.js +1 -1
  35. package/dist/profiles.d.ts +1 -1
  36. package/dist/{provision-supervisor-Be-6HBsX.js → provision-supervisor-ChGKJz8s.js} +5 -5
  37. package/dist/{provision-supervisor-Be-6HBsX.js.map → provision-supervisor-ChGKJz8s.js.map} +1 -1
  38. package/dist/{result-blob-store-CJjp44Mz.js → result-blob-store-BZwRmrFF.js} +2 -2
  39. package/dist/{result-blob-store-CJjp44Mz.js.map → result-blob-store-BZwRmrFF.js.map} +1 -1
  40. package/dist/{run-cancellation-BNBmsY3a.js → run-cancellation-uCwV2Ra7.js} +2 -2
  41. package/dist/{run-cancellation-BNBmsY3a.js.map → run-cancellation-uCwV2Ra7.js.map} +1 -1
  42. package/dist/{run-reopen-Cr2SHmYa.js → run-reopen-YJwUAmv6.js} +6 -6
  43. package/dist/{run-reopen-Cr2SHmYa.js.map → run-reopen-YJwUAmv6.js.map} +1 -1
  44. package/dist/{run-state-Bko0BF0_.js → run-state-6jJzk6gB.js} +5 -5
  45. package/dist/{run-state-Bko0BF0_.js.map → run-state-6jJzk6gB.js.map} +1 -1
  46. package/dist/{runtime-Dfwc9cjt.js → runtime-Ddkn1wRr.js} +15 -15
  47. package/dist/{runtime-Dfwc9cjt.js.map → runtime-Ddkn1wRr.js.map} +1 -1
  48. package/dist/{search-executor-DnWnh4kj.js → search-executor-D9E9q-Pv.js} +4 -4
  49. package/dist/{search-executor-DnWnh4kj.js.map → search-executor-D9E9q-Pv.js.map} +1 -1
  50. package/dist/{server-RCsa_gyH.js → server-BhXz3JyW.js} +4 -4
  51. package/dist/{server-RCsa_gyH.js.map → server-BhXz3JyW.js.map} +1 -1
  52. package/dist/{settle-record-BlIw2MU1.js → settle-record-DWae7fwV.js} +2 -2
  53. package/dist/{settle-record-BlIw2MU1.js.map → settle-record-DWae7fwV.js.map} +1 -1
  54. package/dist/{structural-rollout-BLflx9cs.js → structural-rollout-BL8KLLw8.js} +4 -4
  55. package/dist/{structural-rollout-BLflx9cs.js.map → structural-rollout-BL8KLLw8.js.map} +1 -1
  56. package/dist/{supervise-037R-zl1.js → supervise-C7mDlK7S.js} +10 -7
  57. package/dist/supervise-C7mDlK7S.js.map +1 -0
  58. package/dist/{supervise-identity-CtxWEk1I.js → supervise-identity-DLPzZTp3.js} +2 -2
  59. package/dist/{supervise-identity-CtxWEk1I.js.map → supervise-identity-DLPzZTp3.js.map} +1 -1
  60. package/dist/{supervision-discovery-DKxqbnHf.js → supervision-discovery-8XnVtdOD.js} +3 -3
  61. package/dist/{supervision-discovery-DKxqbnHf.js.map → supervision-discovery-8XnVtdOD.js.map} +1 -1
  62. package/dist/{supervisor-DL4hO7UW.js → supervisor-BQwg_3T0.js} +494 -28
  63. package/dist/supervisor-BQwg_3T0.js.map +1 -0
  64. package/dist/{supervisor-accounting-DlDUl58C.js → supervisor-accounting-B0ofgTZX.js} +91 -14
  65. package/dist/supervisor-accounting-B0ofgTZX.js.map +1 -0
  66. package/dist/{supervisor-root-contract-BCbu1A4n.js → supervisor-root-contract-N7rW4Ynu.js} +3 -3
  67. package/dist/{supervisor-root-contract-BCbu1A4n.js.map → supervisor-root-contract-N7rW4Ynu.js.map} +1 -1
  68. package/dist/testing.d.ts +1 -1
  69. package/dist/testing.js +11 -11
  70. package/dist/{tool-server-n4XYpCok.js → tool-server-I63dnHZC.js} +39 -3
  71. package/dist/{tool-server-n4XYpCok.js.map → tool-server-I63dnHZC.js.map} +1 -1
  72. package/dist/{top-web-B-sHmI3g.js → top-web-BZM3es-m.js} +7 -7
  73. package/dist/{top-web-B-sHmI3g.js.map → top-web-BZM3es-m.js.map} +1 -1
  74. package/dist/tui/bin.js +3 -3
  75. package/dist/tui/index.d.ts +1 -1
  76. package/dist/tui/index.js +2 -2
  77. package/dist/{types-Pi5uCS88.d.ts → types-CByvdC7k.d.ts} +54 -39
  78. package/package.json +1 -1
  79. package/dist/supervise-037R-zl1.js.map +0 -1
  80. package/dist/supervisor-DL4hO7UW.js.map +0 -1
  81. package/dist/supervisor-accounting-DlDUl58C.js.map +0 -1
@@ -2,7 +2,7 @@ import { c as RetainedInteractiveAdmissionError, d as RetainedRunDispatchBinding
2
2
  import { C as linkAbort, S as deadlineSignal, T as signalAbortError, b as RunCancellationReason, c as withJsonlFileLock, d as journalFileStamp, h as checkVerdictOf, l as appendCommittedJsonLine, o as readCommittedJsonLines, r as prepareJsonlAppend, t as isNoEntError, w as runAbortable, y as sha256 } from "./jsonl-file-B2ESMrTh.js";
3
3
  import { c as checkInIdleMs, d as teardownExecutor, f as teardownSurfaces, n as CHILD_DEADLINE_REASON, o as armDeadlineTimer, s as boundedChildDeadlineAt, u as singleFlightTeardown } from "./deadline-CySmJ_0S.js";
4
4
  import { A as withBudgetResources, C as unreportedSpend, D as addResourceSpend, T as zeroSpend, a as cloneSpend, c as errorMessage, f as isAsyncIterable, i as chargedTokens, k as resourceTelemetry, n as addSpend, o as cloneTokenUsage, t as abortError, v as sleep } from "./util-qsH5cC9S.js";
5
- import { $ as budgetLeases, A as printedStatus, B as executorFailure, E as UNAVAILABLE_STATUSES, G as turnFailureOf, H as executorFailureReason, K as turnFailurePolicy, L as traceRootWriter, P as unavailableSignalOfFailure, Pt as recordValue, Q as budgetLeaseUpdates, R as contentAddress, S as retainedExecutorSeamKey, T as UNAVAILABLE_CODES, V as executorFailureInfra, X as isCredentialRefusal, Y as credentialCommandExit, Z as BudgetReconcileFault, _ as leafContinuationExecutionId, at as newUsageTotals, c as BUDGET_CONTINUATION_TASK, ct as assertValidBudget, d as RetainedExecutionPendingError, et as budgetRecoverySeeds, f as TRANSPORT_ERROR_CODES, g as isSpentCreateKeyRefusal, h as isSchemaRejection, i as runtimeFailureCause, it as meterUsageEvent, l as DISPATCH_EXECUTION_CHANGED_CODE, lt as assertValidSpend, m as isProvisioningRefusal, nt as createBudgetPool, p as executorEvidenceWriter, r as reportedFailureCause, rt as refreshBudgetLease, s as settlementFailureCause, st as spendFromUsageTotals, t as PROTOCOL_VERSION, tt as completedLeafBacking, u as DISPATCH_NOT_ADMITTED_CODE, v as prepareRetainedExecutor, vt as extractTransportEventIdentity, x as retainedExecutorContext, y as refusedBeforeItRan, yt as parseCanonicalTransportEvent } from "./tool-server-n4XYpCok.js";
5
+ import { $ as budgetLeases, A as printedStatus, B as executorFailure, E as UNAVAILABLE_STATUSES, G as turnFailureOf, H as executorFailureReason, K as turnFailurePolicy, L as traceRootWriter, P as unavailableSignalOfFailure, Pt as recordValue, Q as budgetLeaseUpdates, R as contentAddress, S as retainedExecutorSeamKey, T as UNAVAILABLE_CODES, V as executorFailureInfra, X as isCredentialRefusal, Y as credentialCommandExit, Z as BudgetReconcileFault, _ as leafContinuationExecutionId, at as newUsageTotals, c as BUDGET_CONTINUATION_TASK, ct as assertValidBudget, d as RetainedExecutionPendingError, et as budgetRecoverySeeds, f as TRANSPORT_ERROR_CODES, g as isSpentCreateKeyRefusal, h as isSchemaRejection, i as runtimeFailureCause, it as meterUsageEvent, l as DISPATCH_EXECUTION_CHANGED_CODE, lt as assertValidSpend, m as isProvisioningRefusal, nt as createBudgetPool, p as executorEvidenceWriter, r as reportedFailureCause, rt as refreshBudgetLease, s as settlementFailureCause, st as spendFromUsageTotals, t as PROTOCOL_VERSION, tt as completedLeafBacking, u as DISPATCH_NOT_ADMITTED_CODE, v as prepareRetainedExecutor, vt as extractTransportEventIdentity, x as retainedExecutorContext, y as refusedBeforeItRan, yt as parseCanonicalTransportEvent } from "./tool-server-I63dnHZC.js";
6
6
  import { a as errMessage, f as defaultRedactor, i as causeChain, l as errorText, m as resolveRedactor, n as detachedSnapshot, o as errorHttpStatus, r as shareParsedStrings, s as errorProperty } from "./snapshot-BKLziJ5K.js";
7
7
  import { p as canonicalObservedModelParts, t as assertExecutableAgentProfile } from "./model-policy-DFuhCC0-.js";
8
8
  import { b as verifiedArtifactChunks, g as workspaceLimits, h as safeArchivePath, i as readAgentCandidateWorkspaceArtifactFiles } from "./workspace-streams-C7PGLAUd.js";
@@ -6509,6 +6509,34 @@ function pendingCheckpoints(events, state) {
6509
6509
  return events.filter((event) => event.kind === "workspace-checkpoint" && event.id === state.args.nodeId && event.provider === state.provider?.name && !confirmed.has(JSON.stringify([event.environmentId, event.checkpoint.checkpointId])));
6510
6510
  }
6511
6511
  // src/runtime/supervise/retained-owner-checkpoint-capture.ts
6512
+ /** The two cleanups that never reached the provider, so the checkpoint is as it was. */
6513
+ const CLEANUP_CANCELLED = "cancelled before checkpoint cleanup";
6514
+ const CLEANUP_UNREACHABLE = "source-scoped checkpoint handle unavailable";
6515
+ /**
6516
+ * Checkpoints oldest first by when each was asked for. Journal order is not age: a request lookup
6517
+ * journals a checkpoint it recovers after any taken since, so the newest is the last of these.
6518
+ */
6519
+ function byTakenAt(events) {
6520
+ const taken = (at) => {
6521
+ const time = Date.parse(at);
6522
+ return Number.isFinite(time) ? time : Number.NEGATIVE_INFINITY;
6523
+ };
6524
+ return events.map((event, index) => ({
6525
+ event,
6526
+ index,
6527
+ at: taken(event.at)
6528
+ })).sort((a, b) => a.at === b.at ? a.index - b.index : a.at - b.at).map(({ event }) => event);
6529
+ }
6530
+ /**
6531
+ * The checkpoints whose delete reached the provider, confirmed or not. None is a restore source: a
6532
+ * provider can remove a checkpoint and still not confirm it (Sandbox answers a 200 it cannot
6533
+ * attest as `unknown`), and a create from a removed checkpoint is refused. On
6534
+ * real-work-benchmark-20261129b a reopen created from one and was refused with HTTP 404 "Snapshot
6535
+ * not found". Pass one node's events: checkpoint ids are the provider's, not the node's.
6536
+ */
6537
+ function deleteSentCheckpointIds(events) {
6538
+ return new Set(events.flatMap((event) => event.kind === "workspace-checkpoint-cleanup" && (event.confirmed || event.refused !== CLEANUP_CANCELLED && event.refused !== CLEANUP_UNREACHABLE) ? [event.checkpointId] : []));
6539
+ }
6512
6540
  /**
6513
6541
  * Delete restore-point checkpoints. A checkpoint is a restore point for a live owner, never
6514
6542
  * evidence: the turn's workspace capture and native session export are the evidence, and the
@@ -6531,8 +6559,8 @@ async function cleanCheckpoints(state, branching, checkpoints, parent) {
6531
6559
  let reason;
6532
6560
  const signal = deadlineSignal(parent, 3e4);
6533
6561
  try {
6534
- if (parent?.aborted) reason = "cancelled before checkpoint cleanup";
6535
- else if (branching === void 0) throw new Error("source-scoped checkpoint handle unavailable");
6562
+ if (parent?.aborted) reason = CLEANUP_CANCELLED;
6563
+ else if (branching === void 0) throw new Error(CLEANUP_UNREACHABLE);
6536
6564
  else {
6537
6565
  const acknowledgement = await runAbortable(() => branching.deleteCheckpoint(request, { signal }), signal, "retained owner checkpoint cleanup timed out");
6538
6566
  confirmed = workspaceCleanupAcknowledgementMatches(request, acknowledgement) && (acknowledgement.status === "deleted" || acknowledgement.status === "already_absent");
@@ -6753,8 +6781,8 @@ async function deleteOldestCheckpoint(state, branching, environmentId, signal) {
6753
6781
  // src/runtime/supervise/retained-owner-environment-recovery.ts
6754
6782
  function restoreBefore(owned, inputIndex) {
6755
6783
  const unusable = unusableEnvironmentIds(owned);
6756
- const deleted = new Set(owned.flatMap((event) => event.kind === "workspace-checkpoint-cleanup" && event.confirmed ? [event.checkpointId] : []));
6757
- return owned.slice(0, inputIndex < 0 ? owned.length : inputIndex).filter((event) => event.kind === "workspace-checkpoint" && unusable.has(event.environmentId) && !deleted.has(event.checkpoint.checkpointId)).at(-1);
6784
+ const deleted = deleteSentCheckpointIds(owned);
6785
+ return byTakenAt(owned.slice(0, inputIndex < 0 ? owned.length : inputIndex).filter((event) => event.kind === "workspace-checkpoint" && unusable.has(event.environmentId) && !deleted.has(event.checkpoint.checkpointId))).at(-1);
6758
6786
  }
6759
6787
  async function restoreCapable(provider) {
6760
6788
  if (provider === void 0) return false;
@@ -7775,6 +7803,18 @@ function consumeScopeRetainedOwnerResult(scope) {
7775
7803
  function retainedOwnerReleaseRetriable(scope) {
7776
7804
  return owners.get(scope)?.releaseRetriable ?? false;
7777
7805
  }
7806
+ /**
7807
+ * @internal Make every later release of this scope's owner keep its restore point: the newest
7808
+ * workspace checkpoint not yet deleted, and the environment it was taken from. A reopened run's
7809
+ * owner continues in that environment, or, once the environment is gone, in a new one created
7810
+ * from that checkpoint (`restoreBefore`). The environment stays because deleting a checkpoint
7811
+ * needs its source, and only a live source is sure to restore it. Superseded checkpoints and
7812
+ * every other environment are still released.
7813
+ */
7814
+ function keepScopeRetainedOwnerRestorePoint(scope) {
7815
+ const state = owners.get(scope);
7816
+ if (state !== void 0) state.keepRestorePoint = true;
7817
+ }
7778
7818
  /** One budget for every checkpoint lookup, delete and fork cleanup this release starts. Work cut short keeps its checkpoint and source. */
7779
7819
  const RELEASE_CHECKPOINT_CAPTURES_MS = 9e5;
7780
7820
  /** A release's wait for its destroys; a delete grows with the retained workspace it seals (Sandbox
@@ -7818,13 +7858,22 @@ async function releaseOwnerEnvironment(state, provider, capturesMs, destroyMs) {
7818
7858
  let lastDetail;
7819
7859
  let retriable = false;
7820
7860
  const checkpointFailures = [];
7861
+ let restorePoint;
7862
+ let reopenBoxes = /* @__PURE__ */ new Set();
7821
7863
  try {
7822
7864
  requestFailures = await reconcileCheckpointRequests(state, events, captures.signal);
7823
7865
  for (const { event } of requestFailures) pendingSources.add(event.environmentId);
7824
- const pending = pendingCheckpoints(events, state).filter((event) => !retentionFailures.has(event.environmentId));
7866
+ const owned = byTakenAt(pendingCheckpoints(events, state));
7867
+ if (state.keepRestorePoint === true) ({restorePoint, boxes: reopenBoxes} = reopenKeep(args.nodeId, events, owned, released));
7868
+ const pending = owned.filter((event) => event !== restorePoint && !retentionFailures.has(event.environmentId));
7825
7869
  for (const sourceEnvironmentId of new Set(pending.map((event) => event.environmentId))) {
7826
7870
  const branching = await checkpointHandle(state, sourceEnvironmentId, AbortSignal.any([captures.signal, AbortSignal.timeout(3e4)]));
7827
- checkpointFailures.push(...await cleanCheckpoints(state, branching, pending.filter((event) => event.environmentId === sourceEnvironmentId), captures.signal));
7871
+ const ofSource = pending.filter((event) => event.environmentId === sourceEnvironmentId);
7872
+ const newest = sourceEnvironmentId === restorePoint?.environmentId ? void 0 : ofSource.at(-1);
7873
+ const failed = await cleanCheckpoints(state, branching, newest === void 0 ? ofSource : ofSource.slice(0, -1), captures.signal);
7874
+ checkpointFailures.push(...failed);
7875
+ const standing = !released.has(sourceEnvironmentId) && (reopenBoxes.has(sourceEnvironmentId) || failed.length > 0 || pendingSources.has(sourceEnvironmentId) || state.held?.has(sourceEnvironmentId) === true);
7876
+ if (newest !== void 0 && !standing) checkpointFailures.push(...await cleanCheckpoints(state, branching, [newest], captures.signal));
7828
7877
  }
7829
7878
  } finally {
7830
7879
  clearTimeout(capturesTimer);
@@ -7832,7 +7881,7 @@ async function releaseOwnerEnvironment(state, provider, capturesMs, destroyMs) {
7832
7881
  const forksUnresolved = await settleCaptureForks(state, captures.signal);
7833
7882
  for (const { event } of checkpointFailures) pendingSources.add(event.environmentId);
7834
7883
  const held = state.held ??= /* @__PURE__ */ new Map();
7835
- const asking = [...environments].filter((id) => !released.has(id) && !retentionFailures.has(id) && !pendingSources.has(id) && !held.has(id));
7884
+ const asking = [...environments].filter((id) => !released.has(id) && !retentionFailures.has(id) && !pendingSources.has(id) && !held.has(id) && !reopenBoxes.has(id));
7836
7885
  const clock = state.releaseClock;
7837
7886
  if (clock !== void 0 && asking.length > 0) {
7838
7887
  clock.startedAt ??= Date.now();
@@ -7854,11 +7903,13 @@ async function releaseOwnerEnvironment(state, provider, capturesMs, destroyMs) {
7854
7903
  const heldBefore = asked === void 0 ? held.get(environmentId) : void 0;
7855
7904
  const retentionReason = retentionFailures.get(environmentId) ?? heldBefore;
7856
7905
  const nativeHold = retentionReason?.startsWith("native session copy incomplete:") === true;
7906
+ const keptForReopen = reopenBoxes.has(environmentId) ? restorePoint : void 0;
7857
7907
  if (retentionReason !== void 0 || pendingSources.has(environmentId)) {
7858
7908
  detail = !nativeHold && pendingSources.has(environmentId) ? "checkpoint cleanup unresolved: source preserved for exact lookup and cleanup" : retentionReason;
7859
7909
  preserved.push(environmentId);
7860
7910
  lastDetail = detail;
7861
- } else try {
7911
+ } else if (keptForReopen !== void 0) detail = `kept for reopen: restore point ${keptForReopen.checkpoint.checkpointId}`;
7912
+ else try {
7862
7913
  await asked;
7863
7914
  destroyed = true;
7864
7915
  } catch (error) {
@@ -7886,6 +7937,7 @@ async function releaseOwnerEnvironment(state, provider, capturesMs, destroyMs) {
7886
7937
  detail = `${detail}; ${describeRetainedNativeStops(stops)}`;
7887
7938
  lastDetail = detail;
7888
7939
  }
7940
+ if (keptForReopen !== void 0 && detail?.includes("it may still be running") === true) preserved.push(environmentId);
7889
7941
  }
7890
7942
  await args.journal.appendEvent(args.rootId, {
7891
7943
  kind: "environment-teardown",
@@ -7939,6 +7991,30 @@ async function releaseOwnerEnvironment(state, provider, capturesMs, destroyMs) {
7939
7991
  ...lastDetail === void 0 ? {} : { detail: lastDetail }
7940
7992
  }, ...checkpointTeardowns] : checkpointTeardowns;
7941
7993
  }
7994
+ /**
7995
+ * Under `keepRestorePoint`, what a reopened owner continues from: the checkpoint `restoreBefore`
7996
+ * would restore, the newest whose delete was never sent (counting any a request lookup just
7997
+ * recovered), and the boxes that stay with it: its own, and the owner's latest usable box, whose
7998
+ * work may be newer than any checkpoint. A reopen continues in that box and restores the
7999
+ * checkpoint only once it is gone.
8000
+ */
8001
+ function reopenKeep(nodeId, events, owned, released) {
8002
+ const own = events.filter((event) => event.id === nodeId);
8003
+ const sent = deleteSentCheckpointIds(own);
8004
+ const restorePoint = owned.filter((event) => !sent.has(event.checkpoint.checkpointId)).at(-1);
8005
+ const boxes = /* @__PURE__ */ new Set();
8006
+ if (restorePoint === void 0) return {
8007
+ restorePoint,
8008
+ boxes
8009
+ };
8010
+ if (!released.has(restorePoint.environmentId)) boxes.add(restorePoint.environmentId);
8011
+ const latest = own.flatMap((event) => event.kind === "execution-admitted" && event.admission.phase === "environment" ? [event.admission.environmentId] : []).at(-1);
8012
+ if (latest !== void 0 && !unusableEnvironmentIds(own).has(latest)) boxes.add(latest);
8013
+ return {
8014
+ restorePoint,
8015
+ boxes
8016
+ };
8017
+ }
7942
8018
  var PermanentReleaseRefusal = class extends Error {};
7943
8019
  const HELD_STOP = "stop not attempted: its provider holds the environment under a retention hold and a reconnect would wake it";
7944
8020
  /**
@@ -8577,9 +8653,10 @@ async function settleManagerWork(scope) {
8577
8653
  * admission that timed out before `create` named an environment. Measured on the Discovery fleet
8578
8654
  * of 2026-09-23/24 (Runtime 0.249.1 to 0.261.0): 338 of 1,620 agents never settled, so they had no
8579
8655
  * terminal record, no spend but the reservation ceiling, and no transcript receipt (#1301). A
8580
- * settlement under `retainedAtSettlement: 'release'` is final, so no process will recover these
8581
- * executions. Each slot closes with the settlement the driver already received, under the seq it
8582
- * saw, marked `retainedExecution: 'release-unconfirmed'`. The environment it may still hold stays
8656
+ * settlement under `retainedAtSettlement: 'release'` is final for them: a reopen
8657
+ * continues the root's owner alone, so no process will recover these executions. Each slot
8658
+ * closes with the settlement the driver already received, under the seq it saw, marked
8659
+ * `retainedExecution: 'release-unconfirmed'`. The environment it may still hold stays
8583
8660
  * named by its `teardown-unconfirmed` record for a sweeper. Never call this on a run a later
8584
8661
  * process may resume.
8585
8662
  */
@@ -14895,6 +14972,6 @@ function unknownChannels(spend) {
14895
14972
  function isNonEmptySpend(s) {
14896
14973
  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);
14897
14974
  }
14898
- export { appendTeardownConfirmation as $, generateSpanId as $n, knownExecutionBindingReceipt as $r, reconcileScopeRetainedOwnerEnvironment as $t, workerSteerRequestsDir as A, promptFromAgentTurnInput as Ai, startRetainedRunInEnvironment as An, transientFailureKind as Ar, RELEASE_DESTROY_MS as At, isTraceAnalysisStore as B, environmentGone as Bn, CheckUnavailableError as Br, recordScopeOwnerHarnessTranscript as Bt, readWorkerSteerRequests as C, RetainedRunProviderContractError as Ci, verifyWorkspaceMarker as Cn, isTerminalNodeStatus as Cr, unconfirmedTeardowns as Ct, workerCancelRequestsFile as D, freezeControlRef as Di, reconnectRetainedRun as Dn, classifyDriverFailure as Dr, scopeRetainedOwnerResourceReader as Dt, supervisorRunsRoot as E, exactSession as Ei, mintRetainedIdentity as En, abandonablePending as Er, releaseScopeRetainedOwnerForSeatPause as Et, createWorkerSlots as F, FileObserverJournal as Fn, SeatPauseError as Fr, scopeRetainedOwnerResult as Ft, attachWorker as G, mergeTraceEnv as Gn, attestRuntimeOwnedDeferredExecutor as Gr, coordinationMcpAlias as Gt, workerTraceAnalysisStore as H, workerTraceEnv as Hn, gateOnDeliverable as Hr, restoreScopeOwnerAcceptedExecution as Ht, openSlotGroup as I, createFileObserverHooks as In, authoredSeatStages as Ir, beginScopeOwnerAttempt as It, recoverRetainedInteractiveRun as J, buildLoopSpanNodes as Jn, attestRuntimeOwnedScopeOwner as Jr, runtimeGraphMetadataKey as Jt, readWorkerInteractiveBinding as K, readTraceContextFromEnv as Kn, attestRuntimeOwnedExecutor as Kr, coordinationProfileToolPrefix as Kt, resolveWorkerSlots as L, observerRecordDigest as Ln, seatExecutionProfile as Lr, finalizeScopeOwnerMaterialization as Lt, writeWorkerSteer as M, providerMessageText as Mi, acceptedInteractiveControl as Mn, upstreamUnavailableSignal as Mr, consumeScopeRetainedOwnerResult as Mt, writeWorkerSteerAcknowledgement as N, offerInteractiveControl as Nn, SEAT_RECHECK_MS as Nr, prepareScopeRetainedOwnerTask as Nt, workerCancellationsDir as O, retainedSessionReplaced as Oi, recoverRetainedRun as On, spentCreateKey as Or, environmentReader as Ot, writeWorkerSteerAsync as P, prepareInteractiveDelegation as Pn, SeatChain as Pr, scopeRetainedOwnerPriorSpend as Pt, spawnJournalRecordEvents as Q, flatOtelSpan as Qn, inheritRuntimeOwnedExecutorAttestation as Qr, assertRetainedOwnerCoordinationRekey as Qt, prepareScopeResume as R, verifyObserverRecords as Rn, subscriptionUsageLimitSignal as Rr, holdScopeOwnerTranscript as Rt, readWorkerSteerAcknowledgement as S, runtimeFlowBrain as Si, stopRetainedNativeExecution as Sn, isLiveNodeStatus as Sr, startScopeRecoveries as St, supervisorRunDir as T, awaitAbortable$1 as Ti, assertRetainedRunReplayMaterial as Tn, HarnessTurnFailedError as Tr, prepareScopeRetainedOwnerSeatSwitch as Tt, nestedScopeSeamKey as U, workerTraceHeaders as Un, mapExecutorResult as Ur, scopeOwnerExecutionObservation as Ut, parseWorkerToolTraceArtifact as V, WORKER_TRACE_PROPAGATION as Vn, gateFactoryOnDeliverable as Vr, recordScopeOwnerMaterialization as Vt, interactiveAdmissionSeamKey as W, createPropagatingTraceEmitter as Wn, verdictFromJudgeScore as Wr, scopeOwnerExecutorNodeContext as Wt, FileSpawnJournal as X, createOpenInferenceFileExporter as Xn, authoredProfileDigest as Xr, scopeRetainedOwnerSettled as Xt, startRetainedInteractiveRun as Y, buildRuntimeEventOtelSpans as Yn, authoredAgentIdentity as Yr, beginScopeRetainedOwnerDrive as Yt, appendSpawnEvents as Z, createOtelExporter as Zn, finalizeRuntimeOwnedPendingExecutor as Zr, scopeRetainedOwnerTurnEnded as Zt, fileEscalateQuestion as _, executableAgentProfileSnapshot as _i, executorObservation as _n, retainHarnessTranscript as _r, registerNestedTeardownScope as _t, closeStreamFile as a, recordRuntimeOwnedProviderDispatchNotStarted as ai, owners as an, HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS as ar, queueOf as at, readWorkerCancelRequests as b, runtimeCheckFactory as bi, NATIVE_STOP_UNCONFIRMED as bn, describeToolArgs as br, retryUnconfirmedTeardowns as bt, openStreamFileFenced as c, runtimeOwnedDriveHarnessProviderEvidence as ci, scopeRetainedOwnerJournalRoot as cn, harnessTranscriptArtifact as cr, closeRetainedSlots as ct, syncStreamFileFenced as d, runtimeOwnedExecutorProviderEvidence as di, materializeTreeView as dn, persistHarnessTranscript as dr, meterRuntimeOwnedAccounting as dt, knownMaterializationReceipt as ei, scopeRetainedOwnerRestorePoint as en, loopEventToOtelSpan as er, reenteredWorkers as et, writeStreamLinesFenced as f, runtimeOwnedPendingExecutorMaterialization as fi, attestNestedDriverTreeOwner as fn, readHarnessTranscript as fr, meterRuntimeOwnedProviderAttempt as ft, claimWorkerSteerDelivery as g, unknownMaterializationReceipt as gi, insideCursorNamespace as gn, resolveHarnessTranscriptCapture as gr, recordScopeOwnerPause as gt, cancelWorker as h, unknownExecutionBindingReceipt as hi, SpawnEventIndex as hn, readBoundHarnessSessions$1 as hr, recordScopeOwnerDriverAttempt as ht, ROOT_STREAM_FILE as i, recordRuntimeOwnedProviderAttemptStart as ii, bindScopeRetainedOwnerProvider as in, sanitizeRuntimeStreamEvent as ir, freeSlots as it, writeWorkerCancellation as j, promptOptionsFromAgentTurnInput as ji, retainedCreateMaterial as jn, undispatchedCredentialExit as jr, abandonScopeRetainedOwnerInvocation as jt, workerInboxFileFromEventDir as k, sameControlCoordinates as ki, startRetainedRun as kn, summarizeDriverAttempts as kr, resolveSpawnResourcePaths as kt, readRootStream as l, runtimeOwnedExecutorExecutionBinding as li, loadSpawnForest as ln, harnessTranscriptFromLines as lr, closeScopeAdmission as lt, appendWorkerControlEventAsync as m, runtimeOwnedScopeOwnerRuntime as mi, nestedDriverTreeRoot as mn, HARNESS_TRANSCRIPT_READ_LIMITS as mr, recordScopeOwnerBarrenPause as mt, terminalAccounting as n, providerAttemptEvidence as ni, scopeRetainedOwnerCheckpointing as nn, createRuntimeStreamEventCollector as nr, assertRecursiveReservationPolicy as nt, createRootStreamSink as o, recordRuntimeOwnedProviderIdentityConflict as oi, scopeOwnerLiabilities as on, captureBoundHarnessTranscript as or, rollingDispatch as ot, appendWorkerControlEvent as p, runtimeOwnedScopeOwnerControl as pi, driverRuntime as pn, settleHarnessTranscript as pr, pauseScopeSeatAdmission as pt, reconnectRetainedInteractiveRun as q, buildLoopOtelSpans as qn, attestRuntimeOwnedPendingExecutor as qr, providerVisibleProfile as qt, createScope as r, recordRuntimeOwnedDriveHarnessProviderEvidence as ri, bindScopeRetainedOwnerEnvironmentId as rn, sanitizeKnowledgeReadinessReport as rr, deriveNodeExecutionIdentity as rt, nodeStreamFile as s, recordRuntimeOwnedProviderModel as si, scopeRetainedOwnerContext as sn, captureHarnessTranscript as sr, boundRetainedReleases as st, isNonEmptySpend as t, newExecutionAttemptId as ti, noteScopeRetainedOwnerCoordination as tn, createRuntimeEventCollector as tr, settledToIteration as tt, readRootStreamReceipt as u, runtimeOwnedExecutorMaterialization as ui, ownedTreeRootSpawn as un, harnessTranscriptUnavailable as ur, hasRetriableTeardowns as ut, legacySupervisorRunDir as v, executableAgentSpecSnapshot as vi, executorObservationSeamKey as vn, DEFAULT_STALL_AFTER_MS as vr, releaseHeldEnvironments as vt, safeWorkerFile as w, assertEventBinding as wi, RetainedMaterializationTimeoutError as wn, DriverAttemptsExhaustedError as wr, waitForScopeChildren as wt, readWorkerCancellation as x, runtimeFlowAgent as xi, describeRetainedNativeStops as xn, readWorkerProgress as xr, settleManagerWork as xt, legacySupervisorRunsRoot as y, isRuntimeFlowBrain as yi, observeModelRequest as yn, createActivityLog as yr, releaseRetainedEnvironments as yt, replaySpawnTree as z, destroyInteractiveEnvironment as zn, preflightPublicCoordination as zr, noteScopeOwnerPlannedExecution as zt };
14975
+ export { appendTeardownConfirmation as $, flatOtelSpan as $n, inheritRuntimeOwnedExecutorAttestation as $r, assertRetainedOwnerCoordinationRekey as $t, workerSteerRequestsDir as A, sameControlCoordinates as Ai, startRetainedRun as An, summarizeDriverAttempts as Ar, RELEASE_DESTROY_MS as At, isTraceAnalysisStore as B, destroyInteractiveEnvironment as Bn, preflightPublicCoordination as Br, noteScopeOwnerPlannedExecution as Bt, readWorkerSteerRequests as C, runtimeFlowBrain as Ci, stopRetainedNativeExecution as Cn, isLiveNodeStatus as Cr, unconfirmedTeardowns as Ct, workerCancelRequestsFile as D, exactSession as Di, mintRetainedIdentity as Dn, abandonablePending as Dr, scopeRetainedOwnerResourceReader as Dt, supervisorRunsRoot as E, awaitAbortable$1 as Ei, assertRetainedRunReplayMaterial as En, HarnessTurnFailedError as Er, releaseScopeRetainedOwnerForSeatPause as Et, createWorkerSlots as F, prepareInteractiveDelegation as Fn, SeatChain as Fr, scopeRetainedOwnerPriorSpend as Ft, attachWorker as G, createPropagatingTraceEmitter as Gn, verdictFromJudgeScore as Gr, scopeOwnerExecutorNodeContext as Gt, workerTraceAnalysisStore as H, WORKER_TRACE_PROPAGATION as Hn, gateFactoryOnDeliverable as Hr, recordScopeOwnerMaterialization as Ht, openSlotGroup as I, FileObserverJournal as In, SeatPauseError as Ir, scopeRetainedOwnerResult as It, recoverRetainedInteractiveRun as J, buildLoopOtelSpans as Jn, attestRuntimeOwnedPendingExecutor as Jr, providerVisibleProfile as Jt, readWorkerInteractiveBinding as K, mergeTraceEnv as Kn, attestRuntimeOwnedDeferredExecutor as Kr, coordinationMcpAlias as Kt, resolveWorkerSlots as L, createFileObserverHooks as Ln, authoredSeatStages as Lr, beginScopeOwnerAttempt as Lt, writeWorkerSteer as M, promptOptionsFromAgentTurnInput as Mi, retainedCreateMaterial as Mn, undispatchedCredentialExit as Mr, abandonScopeRetainedOwnerInvocation as Mt, writeWorkerSteerAcknowledgement as N, providerMessageText as Ni, acceptedInteractiveControl as Nn, upstreamUnavailableSignal as Nr, consumeScopeRetainedOwnerResult as Nt, workerCancellationsDir as O, freezeControlRef as Oi, reconnectRetainedRun as On, classifyDriverFailure as Or, environmentReader as Ot, writeWorkerSteerAsync as P, offerInteractiveControl as Pn, SEAT_RECHECK_MS as Pr, prepareScopeRetainedOwnerTask as Pt, spawnJournalRecordEvents as Q, createOtelExporter as Qn, finalizeRuntimeOwnedPendingExecutor as Qr, scopeRetainedOwnerTurnEnded as Qt, prepareScopeResume as R, observerRecordDigest as Rn, seatExecutionProfile as Rr, finalizeScopeOwnerMaterialization as Rt, readWorkerSteerAcknowledgement as S, runtimeFlowAgent as Si, describeRetainedNativeStops as Sn, readWorkerProgress as Sr, startScopeRecoveries as St, supervisorRunDir as T, assertEventBinding as Ti, RetainedMaterializationTimeoutError as Tn, DriverAttemptsExhaustedError as Tr, prepareScopeRetainedOwnerSeatSwitch as Tt, nestedScopeSeamKey as U, workerTraceEnv as Un, gateOnDeliverable as Ur, restoreScopeOwnerAcceptedExecution as Ut, parseWorkerToolTraceArtifact as V, environmentGone as Vn, CheckUnavailableError as Vr, recordScopeOwnerHarnessTranscript as Vt, interactiveAdmissionSeamKey as W, workerTraceHeaders as Wn, mapExecutorResult as Wr, scopeOwnerExecutionObservation as Wt, FileSpawnJournal as X, buildRuntimeEventOtelSpans as Xn, authoredAgentIdentity as Xr, beginScopeRetainedOwnerDrive as Xt, startRetainedInteractiveRun as Y, buildLoopSpanNodes as Yn, attestRuntimeOwnedScopeOwner as Yr, runtimeGraphMetadataKey as Yt, appendSpawnEvents as Z, createOpenInferenceFileExporter as Zn, authoredProfileDigest as Zr, scopeRetainedOwnerSettled as Zt, fileEscalateQuestion as _, unknownMaterializationReceipt as _i, insideCursorNamespace as _n, resolveHarnessTranscriptCapture as _r, registerNestedTeardownScope as _t, closeStreamFile as a, recordRuntimeOwnedProviderAttemptStart as ai, bindScopeRetainedOwnerProvider as an, sanitizeRuntimeStreamEvent as ar, queueOf as at, readWorkerCancelRequests as b, isRuntimeFlowBrain as bi, observeModelRequest as bn, createActivityLog as br, retryUnconfirmedTeardowns as bt, openStreamFileFenced as c, recordRuntimeOwnedProviderModel as ci, scopeRetainedOwnerContext as cn, captureHarnessTranscript as cr, closeRetainedSlots as ct, syncStreamFileFenced as d, runtimeOwnedExecutorMaterialization as di, ownedTreeRootSpawn as dn, harnessTranscriptUnavailable as dr, meterRuntimeOwnedAccounting as dt, knownExecutionBindingReceipt as ei, reconcileScopeRetainedOwnerEnvironment as en, generateSpanId as er, reenteredWorkers as et, writeStreamLinesFenced as f, runtimeOwnedExecutorProviderEvidence as fi, materializeTreeView as fn, persistHarnessTranscript as fr, meterRuntimeOwnedProviderAttempt as ft, claimWorkerSteerDelivery as g, unknownExecutionBindingReceipt as gi, SpawnEventIndex as gn, readBoundHarnessSessions$1 as gr, recordScopeOwnerPause as gt, cancelWorker as h, runtimeOwnedScopeOwnerRuntime as hi, nestedDriverTreeRoot as hn, HARNESS_TRANSCRIPT_READ_LIMITS as hr, recordScopeOwnerDriverAttempt as ht, ROOT_STREAM_FILE as i, recordRuntimeOwnedDriveHarnessProviderEvidence as ii, bindScopeRetainedOwnerEnvironmentId as in, sanitizeKnowledgeReadinessReport as ir, freeSlots as it, writeWorkerCancellation as j, promptFromAgentTurnInput as ji, startRetainedRunInEnvironment as jn, transientFailureKind as jr, keepScopeRetainedOwnerRestorePoint as jt, workerInboxFileFromEventDir as k, retainedSessionReplaced as ki, recoverRetainedRun as kn, spentCreateKey as kr, resolveSpawnResourcePaths as kt, readRootStream as l, runtimeOwnedDriveHarnessProviderEvidence as li, scopeRetainedOwnerJournalRoot as ln, harnessTranscriptArtifact as lr, closeScopeAdmission as lt, appendWorkerControlEventAsync as m, runtimeOwnedScopeOwnerControl as mi, driverRuntime as mn, settleHarnessTranscript as mr, recordScopeOwnerBarrenPause as mt, terminalAccounting as n, newExecutionAttemptId as ni, noteScopeRetainedOwnerCoordination as nn, createRuntimeEventCollector as nr, assertRecursiveReservationPolicy as nt, createRootStreamSink as o, recordRuntimeOwnedProviderDispatchNotStarted as oi, owners as on, HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS as or, rollingDispatch as ot, appendWorkerControlEvent as p, runtimeOwnedPendingExecutorMaterialization as pi, attestNestedDriverTreeOwner as pn, readHarnessTranscript as pr, pauseScopeSeatAdmission as pt, reconnectRetainedInteractiveRun as q, readTraceContextFromEnv as qn, attestRuntimeOwnedExecutor as qr, coordinationProfileToolPrefix as qt, createScope as r, providerAttemptEvidence as ri, scopeRetainedOwnerCheckpointing as rn, createRuntimeStreamEventCollector as rr, deriveNodeExecutionIdentity as rt, nodeStreamFile as s, recordRuntimeOwnedProviderIdentityConflict as si, scopeOwnerLiabilities as sn, captureBoundHarnessTranscript as sr, boundRetainedReleases as st, isNonEmptySpend as t, knownMaterializationReceipt as ti, scopeRetainedOwnerRestorePoint as tn, loopEventToOtelSpan as tr, settledToIteration as tt, readRootStreamReceipt as u, runtimeOwnedExecutorExecutionBinding as ui, loadSpawnForest as un, harnessTranscriptFromLines as ur, hasRetriableTeardowns as ut, legacySupervisorRunDir as v, executableAgentProfileSnapshot as vi, executorObservation as vn, retainHarnessTranscript as vr, releaseHeldEnvironments as vt, safeWorkerFile as w, RetainedRunProviderContractError as wi, verifyWorkspaceMarker as wn, isTerminalNodeStatus as wr, waitForScopeChildren as wt, readWorkerCancellation as x, runtimeCheckFactory as xi, NATIVE_STOP_UNCONFIRMED as xn, describeToolArgs as xr, settleManagerWork as xt, legacySupervisorRunsRoot as y, executableAgentSpecSnapshot as yi, executorObservationSeamKey as yn, DEFAULT_STALL_AFTER_MS as yr, releaseRetainedEnvironments as yt, replaySpawnTree as z, verifyObserverRecords as zn, subscriptionUsageLimitSignal as zr, holdScopeOwnerTranscript as zt };
14899
14976
 
14900
- //# sourceMappingURL=supervisor-accounting-DlDUl58C.js.map
14977
+ //# sourceMappingURL=supervisor-accounting-B0ofgTZX.js.map