@tangle-network/agent-runtime 3.0.43 → 5.0.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 (80) hide show
  1. package/CHANGELOG.md +5263 -0
  2. package/dist/{activation-CiUbW1QE.d.ts → activation-CtLdCiH3.d.ts} +2 -2
  3. package/dist/{activation-1YUy4GWu.js → activation-DGLWxFJu.js} +2 -2
  4. package/dist/{activation-1YUy4GWu.js.map → activation-DGLWxFJu.js.map} +1 -1
  5. package/dist/agent.d.ts +1 -1
  6. package/dist/agent.js +4 -4
  7. package/dist/candidate-execution/index.d.ts +1 -1
  8. package/dist/{coordination-manager-DXOwLu9T.js → coordination-manager-D74AZg7m.js} +7 -7
  9. package/dist/{coordination-manager-DXOwLu9T.js.map → coordination-manager-D74AZg7m.js.map} +1 -1
  10. package/dist/{coordination-map-routing-2_hUlTnz.js → coordination-map-routing-DVjW5Gx0.js} +2 -2
  11. package/dist/{coordination-map-routing-2_hUlTnz.js.map → coordination-map-routing-DVjW5Gx0.js.map} +1 -1
  12. package/dist/{delegate-CAvTMCk0.js → delegate-BVyFJ9AX.js} +2 -2
  13. package/dist/{delegate-CAvTMCk0.js.map → delegate-BVyFJ9AX.js.map} +1 -1
  14. package/dist/durable.d.ts +4 -2
  15. package/dist/durable.js +12 -184
  16. package/dist/durable.js.map +1 -1
  17. package/dist/{graph-C7Xthj-4.js → graph-r8zcRxbi.js} +6 -8
  18. package/dist/{graph-C7Xthj-4.js.map → graph-r8zcRxbi.js.map} +1 -1
  19. package/dist/{graph-registry-BoaUV5g8.js → graph-registry-B25FxBZN.js} +5 -5
  20. package/dist/graph-registry-B25FxBZN.js.map +1 -0
  21. package/dist/{graph-registry-EGeo_moB.js → graph-registry-C-hjRx2t.js} +1 -1
  22. package/dist/{improve-BZpoezFh.js → improve-D12GulmK.js} +7 -7
  23. package/dist/{improve-BZpoezFh.js.map → improve-D12GulmK.js.map} +1 -1
  24. package/dist/index.d.ts +3 -3
  25. package/dist/index.js +9 -9
  26. package/dist/intelligence.d.ts +3 -3
  27. package/dist/intelligence.js +5 -5
  28. package/dist/{jsonl-file-CbxMVnUj.js → jsonl-file-CeVYTIQJ.js} +45 -33
  29. package/dist/jsonl-file-CeVYTIQJ.js.map +1 -0
  30. package/dist/kernel.d.ts +2 -2
  31. package/dist/kernel.js +14 -13
  32. package/dist/{loop-runner-Dmjf2IY6.d.ts → loop-runner-BHBabRIw.d.ts} +2 -2
  33. package/dist/{loop-runner-BchibTTn.js → loop-runner-CYcN11I4.js} +2 -2
  34. package/dist/{loop-runner-BchibTTn.js.map → loop-runner-CYcN11I4.js.map} +1 -1
  35. package/dist/loop-runner-bin.d.ts +1 -1
  36. package/dist/loop-runner-bin.js +1 -1
  37. package/dist/mcp/bin.js +3 -3
  38. package/dist/mcp/index.d.ts +1 -1
  39. package/dist/mcp/index.js +5 -5
  40. package/dist/profiles.d.ts +1 -1
  41. package/dist/{provision-supervisor-BtDnk11d.js → provision-supervisor-BiqHJ-d4.js} +5 -5
  42. package/dist/{provision-supervisor-BtDnk11d.js.map → provision-supervisor-BiqHJ-d4.js.map} +1 -1
  43. package/dist/{run-cancellation-DEW04dun.js → run-cancellation-D5R-7UQt.js} +3 -3
  44. package/dist/{run-cancellation-DEW04dun.js.map → run-cancellation-D5R-7UQt.js.map} +1 -1
  45. package/dist/run-state-DRh8BOFi.js +350 -0
  46. package/dist/run-state-DRh8BOFi.js.map +1 -0
  47. package/dist/{runtime-CKoChP6L.js → runtime-BX_9-DJB.js} +18 -17
  48. package/dist/runtime-BX_9-DJB.js.map +1 -0
  49. package/dist/{scope-Bg1uCsPR.js → scope-JcCkUy_z.js} +268 -165
  50. package/dist/scope-JcCkUy_z.js.map +1 -0
  51. package/dist/{search-executor-CJ5y2-b8.js → search-executor-CdmaS5r4.js} +3 -3
  52. package/dist/{search-executor-CJ5y2-b8.js.map → search-executor-CdmaS5r4.js.map} +1 -1
  53. package/dist/{server-zdmmyP7r.js → server-BY6OluUf.js} +3 -3
  54. package/dist/{server-zdmmyP7r.js.map → server-BY6OluUf.js.map} +1 -1
  55. package/dist/settle-record-BSDDf9Z4.js +130 -0
  56. package/dist/settle-record-BSDDf9Z4.js.map +1 -0
  57. package/dist/{structural-rollout-CH9b7K9B.js → structural-rollout-BjMUUXLn.js} +3 -3
  58. package/dist/{structural-rollout-CH9b7K9B.js.map → structural-rollout-BjMUUXLn.js.map} +1 -1
  59. package/dist/{supervise-472pyfgQ.js → supervise-rYEsVVcn.js} +254 -414
  60. package/dist/supervise-rYEsVVcn.js.map +1 -0
  61. package/dist/{supervision-discovery-CD350Iar.js → supervision-discovery-D95Ack4J.js} +4 -129
  62. package/dist/supervision-discovery-D95Ack4J.js.map +1 -0
  63. package/dist/{supervisor-BDOWzyCC.js → supervisor-B-bX69uL.js} +185 -120
  64. package/dist/supervisor-B-bX69uL.js.map +1 -0
  65. package/dist/testing.d.ts +1 -1
  66. package/dist/testing.js +11 -11
  67. package/dist/{top-web-CNTJBqFy.js → top-web-D-wH9ipn.js} +13 -9
  68. package/dist/{top-web-CNTJBqFy.js.map → top-web-D-wH9ipn.js.map} +1 -1
  69. package/dist/tui/bin.js +3 -3
  70. package/dist/tui/index.d.ts +1 -1
  71. package/dist/tui/index.js +2 -2
  72. package/dist/{types-tG_tps7N.d.ts → types-DblV14Oe.d.ts} +204 -224
  73. package/package.json +7 -8
  74. package/dist/graph-registry-BoaUV5g8.js.map +0 -1
  75. package/dist/jsonl-file-CbxMVnUj.js.map +0 -1
  76. package/dist/runtime-CKoChP6L.js.map +0 -1
  77. package/dist/scope-Bg1uCsPR.js.map +0 -1
  78. package/dist/supervise-472pyfgQ.js.map +0 -1
  79. package/dist/supervision-discovery-CD350Iar.js.map +0 -1
  80. package/dist/supervisor-BDOWzyCC.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import { $i as assertEventBinding, $r as DISPATCH_NOT_ADMITTED_CODE, A as nestedScopeSeamKey, An as workerTraceEnv, Ar as recordRuntimeOwnedProviderDispatchNotStarted, Bi as createSandboxTurnEventCollector, Br as unknownMaterializationReceipt, Bt as retainedOwnerWorkspaceRetentionSeamKey, Ci as createBudgetPool, Cn as nativeCopyDelayMs, Cr as inheritRuntimeOwnedExecutorAttestation, Er as newExecutionAttemptId, Fr as runtimeOwnedExecutorMaterialization, Gi as sameModelId, Hr as executableAgentSpecSnapshot, Jt as nestedDriverTreeRoot, Ki as sandboxEventServedBackend, Kr as reportedFailureCause, Kt as attestNestedDriverTreeOwner, Li as extractTransportEventIdentity, Lt as scopeRetainedOwnerCheckpointing, Mi as sandboxLeafOutputFromEvents, Mr as recordRuntimeOwnedProviderModel, Ni as sandboxOutputMarker, Nn as mergeTraceEnv, On as resolveWorkerSlots, Pi as sandboxProgressEvents, Pr as runtimeOwnedExecutorExecutionBinding, Q as assertRecursiveReservationPolicy, Qi as RetainedRunProviderContractError, Qn as harnessTranscriptUnavailable, Qr as DISPATCH_EXECUTION_CHANGED_CODE, Qt as closesCursorSlot, R as appendSpawnEvents, Ri as assertSandboxServedModel, Rr as runtimeOwnedScopeOwnerRuntime, Si as isCredentialRefusal, Sn as captureProviderWorkspaceSnapshot, Sr as finalizeRuntimeOwnedPendingExecutor, T as sumSpendFromEvents, Tn as workspaceCaptureReceipt, Tr as knownMaterializationReceipt, Ui as isSandboxTerminalEvent, Ut as loadSpawnForest, V as finalizeScopeOwnerMaterialization, Vi as createSandboxUsageLedger, Vr as executableAgentProfileSnapshot, Wi as notifySandboxEventObserver, Wt as ownedTreeRootSpawn, X as reenteredWorkers, Xi as parseCodexUsageRecord, Xr as runtimeProviderCode, Xt as encodeResultBlob, Yn as captureHarnessTranscript, Yr as runtimeFailureRemediationSchema, Zi as recordValue, Zn as harnessTranscriptFromLines, Zt as SpawnEventIndex, _i as contentAddress, _r as attestRuntimeOwnedExecutor, _t as startScopeRecoveries, aa as RunCancellationReason, ai as retainedExecutorContext, an as reconnectRetainedRun, at as hasRetriableTeardowns, bi as hashJson, bn as assertProviderWorkspaceRetentionPort, ca as runAbortable, ci as UNAVAILABLE_STATUSES, da as promptOptionsFromAgentTurnInput, di as printedStatus, dt as registerNestedTeardownScope, ea as awaitAbortable, ei as RetainedExecutionPendingError, en as verifyWorkspaceMarker, fi as unavailablePauseMs, ft as releaseHeldEnvironments, gr as attestRuntimeOwnedDeferredExecutor, gt as settleManagerWork, hr as subscriptionUsageLimitSignal, ht as retryUnconfirmedTeardowns, ia as sameControlCoordinates, in as mintRetainedIdentity, ir as retainHarnessTranscript, it as closeScopeAdmission, jn as workerTraceHeaders, jr as recordRuntimeOwnedProviderIdentityConflict, jt as scopeRetainedOwnerSettled, ki as createSandboxToolPartState, kn as WORKER_TRACE_PROPAGATION, kr as recordRuntimeOwnedProviderAttemptStart, lr as isLiveNodeStatus, mi as unavailableSignalOfFailure, mt as releaseRetainedEnvironments, na as freezeControlRef, ni as isProvisioningRefusal, nn as stopRetainedNativeExecution, oa as abortReason, oi as retainedExecutorSeamKey, on as recoverRetainedRun, or as createActivityLog, pt as releaseManagerEnvironment, qi as sandboxTerminalUsageField, qn as HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS, qr as runtimeFailureCause, qt as driverRuntime, ra as isTerminalSessionStatus, ri as isSchemaRejection, rn as assertRetainedRunReplayMaterial, rt as closeRetainedSlots, sa as linkAbort, si as UNAVAILABLE_CODES, sn as startRetainedRun, sr as describeToolArgs, t as createScope, ta as exactSession, ti as TRANSPORT_ERROR_CODES, tn as describeRetainedNativeStops, vi as contentRef, vn as environmentGone, vr as attestRuntimeOwnedPendingExecutor, vt as unconfirmedTeardowns, w as prepareScopeResume, wn as openNativeMirror, wr as knownExecutionBindingReceipt, xi as credentialCommandExit, xn as captureProviderLiveWorkspace, yt as waitForScopeChildren, zi as canonicalSandboxUsageMode, zr as unknownExecutionBindingReceipt } from "./scope-Bg1uCsPR.js";
1
+ import { $i as sandboxEventServedBackend, $n as harnessTranscriptUnavailable, $r as runtimeProviderCode, $t as closesCursorSlot, A as nestedScopeSeamKey, Ai as createBudgetPool, An as WORKER_TRACE_PROPAGATION, Bi as sandboxOutputMarker, Br as runtimeOwnedScopeOwnerControl, Bt as bindScopeRetainedOwnerWorkspaceRetention, Cn as captureProviderWorkspaceSnapshot, Di as hashJson, Dr as knownMaterializationReceipt, Ei as turnFailurePolicy, En as workspaceCaptureReceipt, Er as knownExecutionBindingReceipt, Gi as assertSandboxServedModel, Gr as executableAgentSpecSnapshot, Gt as ownedTreeRootSpawn, Hr as unknownExecutionBindingReceipt, Ii as createSandboxToolPartState, Ir as runtimeOwnedExecutorExecutionBinding, Ji as createSandboxUsageLedger, Jn as HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS, Jt as driverRuntime, Ki as canonicalSandboxUsageMode, Lr as runtimeOwnedExecutorMaterialization, Lt as scopeRetainedOwnerCheckpointing, Mn as workerTraceHeaders, Mr as recordRuntimeOwnedProviderDispatchNotStarted, Nr as recordRuntimeOwnedProviderIdentityConflict, Oi as credentialCommandExit, Or as newExecutionAttemptId, Pn as mergeTraceEnv, Pr as recordRuntimeOwnedProviderModel, Q as assertRecursiveReservationPolicy, Qi as sameModelId, Qn as harnessTranscriptFromLines, Qr as runtimeFailureRemediationSchema, Qt as SpawnEventIndex, R as appendSpawnEvents, Si as contentRef, Sn as captureProviderLiveWorkspace, T as sumSpendFromEvents, Ti as turnFailureOf, Tn as openNativeMirror, Tr as inheritRuntimeOwnedExecutorAttestation, Ur as unknownMaterializationReceipt, V as finalizeScopeOwnerMaterialization, Vi as sandboxProgressEvents, Vr as runtimeOwnedScopeOwnerRuntime, Vt as retainedOwnerWorkspaceRetentionSeamKey, Wi as extractTransportEventIdentity, Wr as executableAgentProfileSnapshot, Wt as loadSpawnForest, X as reenteredWorkers, Xi as isSandboxTerminalEvent, Xn as captureHarnessTranscript, Xr as runtimeFailureCause, Yr as reportedFailureCause, Yt as nestedDriverTreeRoot, Zi as notifySandboxEventObserver, Zt as encodeResultBlob, _i as unavailableResumeAt, _r as subscriptionUsageLimitSignal, _t as startScopeRecoveries, aa as RetainedRunProviderContractError, ai as isProvisioningRefusal, an as mintRetainedIdentity, ar as retainHarnessTranscript, at as hasRetriableTeardowns, br as attestRuntimeOwnedPendingExecutor, ca as exactSession, ci as retainedExecutorContext, cn as startRetainedRun, cr as describeToolArgs, da as sameControlCoordinates, di as UNAVAILABLE_STATUSES, dt as registerNestedTeardownScope, ea as sandboxTerminalUsageField, fa as RunCancellationReason, ft as releaseHeldEnvironments, gi as unavailablePauseMs, gt as settleManagerWork, ha as runAbortable, hi as reportedResetAt, ht as retryUnconfirmedTeardowns, ia as recordValue, ii as TRANSPORT_ERROR_CODES, in as assertRetainedRunReplayMaterial, it as closeScopeAdmission, jn as workerTraceEnv, jr as recordRuntimeOwnedProviderAttemptStart, jt as scopeRetainedOwnerSettled, ki as isCredentialRefusal, kn as resolveWorkerSlots, la as freezeControlRef, li as retainedExecutorSeamKey, ma as linkAbort, mi as printedStatus, mt as releaseRetainedEnvironments, ni as DISPATCH_NOT_ADMITTED_CODE, nn as describeRetainedNativeStops, oa as assertEventBinding, oi as isSchemaRejection, on as reconnectRetainedRun, pa as abortReason, pt as releaseManagerEnvironment, qi as createSandboxTurnEventCollector, qt as attestNestedDriverTreeOwner, ra as parseCodexUsageRecord, ri as RetainedExecutionPendingError, rn as stopRetainedNativeExecution, rt as closeRetainedSlots, sa as awaitAbortable, sn as recoverRetainedRun, sr as createActivityLog, t as createScope, ti as DISPATCH_EXECUTION_CHANGED_CODE, tn as verifyWorkspaceMarker, ua as isTerminalSessionStatus, ui as UNAVAILABLE_CODES, ur as isLiveNodeStatus, va as promptOptionsFromAgentTurnInput, vi as unavailableSignalOfFailure, vr as attestRuntimeOwnedDeferredExecutor, vt as unconfirmedTeardowns, w as prepareScopeResume, wi as executorFailureInfra, wn as nativeCopyDelayMs, wr as finalizeRuntimeOwnedPendingExecutor, xi as contentAddress, xn as assertProviderWorkspaceRetentionPort, yn as environmentGone, yr as attestRuntimeOwnedExecutor, yt as waitForScopeChildren, zi as sandboxLeafOutputFromEvents, zt as bindScopeRetainedOwnerProvider } from "./scope-JcCkUy_z.js";
2
2
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError$1, r as BackendTransportError, t as AgentEvalError } from "./errors-AzSuGI23.js";
3
3
  import { $ as isAsyncIterable, J as deleteBoxSafe, Ot as teardownSurfaces, Q as isAbortError, St as armDeadlineTimer, Tt as isDeadlineAbortReason, U as addSpend, V as hasControlCharacter, W as addTokenUsage, Y as errorMessage, _t as ACCEPTED_RESULT_GRACE_MS, at as sleep, ct as throwIfAborted, dt as zeroSpend, et as mapWithConcurrency, ft as zeroTokenUsage, gt as withBudgetResources, it as roundBoxMinutes, lt as unmeteredSpend, nt as randomSuffix, ot as stringifySafe, pt as addResourceSpend, q as cloneTokenUsage, rt as randomUuid, st as throwAbort, tt as promptCacheTokenClasses, ut as withTimeout, xt as ROOT_DEADLINE_REASON } from "./workspace-streams-8ALHaZzx.js";
4
4
  import { t as runTaskQueue } from "./task-queue-DbpZAp6C.js";
5
- import { _ as errorText, d as detachedSnapshot, g as errorProperty, h as errorHttpStatus, l as sha256, m as errMessage, p as causeChain, v as defaultRedactor } from "./jsonl-file-CbxMVnUj.js";
5
+ import { _ as errorText, d as detachedSnapshot, g as errorProperty, h as errorHttpStatus, l as sha256, m as errMessage, p as causeChain, v as defaultRedactor } from "./jsonl-file-CeVYTIQJ.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-JOcg3NRs.js";
7
7
  import { r as nativeSystemPrompt, t as assertSandboxProfileCompatibility } from "./sandbox-profile-compat-oFGWESLn.js";
8
8
  import { a as writeAtomicDurableFile, s as fenceRunWrite } from "./durable-file-DstVeHcj.js";
@@ -5591,13 +5591,7 @@ const causedByPartialFailure = (error) => causeChain(error).some((cause) => caus
5591
5591
  function abandonablePending(error) {
5592
5592
  return error instanceof RetainedExecutionPendingError && (error.pendingCause === "unobservable" || error.pendingCause === "nested-recovery") ? error : void 0;
5593
5593
  }
5594
- /**
5595
- * Bridge error classes the bridge itself never retries: a request that fails identically on
5596
- * every attempt, mapped below 5xx on its HTTP path (`parse_error` 400, the other two 501). On the
5597
- * stream path the same failure arrives with no status at all — a profile that cannot materialize
5598
- * is a `parse_error` — and the status split alone read it as a bad moment and re-drove it to the
5599
- * attempt ceiling.
5600
- */
5594
+ /** Deterministic bridge refusals remain terminal even when transport omits HTTP status. */
5601
5595
  const DETERMINISTIC_BRIDGE_CODES = /* @__PURE__ */ new Set([
5602
5596
  "parse_error",
5603
5597
  "not_configured",
@@ -5612,25 +5606,22 @@ const DETERMINISTIC_BRIDGE_CODES = /* @__PURE__ */ new Set([
5612
5606
  */
5613
5607
  const CONTENT_FILTER_REASON = "refused by the model provider's content filter";
5614
5608
  const isContentFilterRefusal = (error) => causeChain(error).some((cause) => cause instanceof Error && /\bcontent was flagged for possible\b/iu.test(errorProperty(cause, "message") ?? ""));
5615
- /**
5616
- * A driver's harness turn ran to its terminal result, and that result reported failure.
5617
- *
5618
- * A provider executor returns a failed turn as an outcome; without this error it reads as a
5619
- * completed drive and never reaches the retry decision (a turn ended `status code 524`).
5620
- *
5621
- * `errorCode` is the provider's machine code when it reported one. The classifier reads the code;
5622
- * text decides only a printed capacity code and a content-filter refusal, which have none.
5623
- */
5609
+ /** A completed failed turn enters retry with its producer classification and legacy metadata intact. */
5624
5610
  var HarnessTurnFailedError = class extends Error {
5625
5611
  runtime;
5612
+ /** The failure as the harness reported it, before this error's framing. */
5613
+ reported;
5626
5614
  errorCode;
5627
5615
  statusCode;
5628
5616
  /** The shared HTTP error reader also uses this status for persisted diagnostics. */
5629
5617
  status;
5618
+ failure;
5630
5619
  constructor(runtime, failure) {
5631
5620
  super(`${runtime} harness turn ended with a failed outcome` + (failure.errorCode === void 0 ? "" : ` (${failure.errorCode})`) + `: ${failure.error}`);
5632
5621
  this.name = "HarnessTurnFailedError";
5633
5622
  this.runtime = runtime;
5623
+ this.reported = failure.error;
5624
+ if (failure.failure !== void 0) this.failure = failure.failure;
5634
5625
  if (failure.errorCode !== void 0) this.errorCode = failure.errorCode;
5635
5626
  if (failure.statusCode !== void 0) {
5636
5627
  this.statusCode = failure.statusCode;
@@ -5662,23 +5653,21 @@ function isDispatchExecutionChanged(value) {
5662
5653
  return false;
5663
5654
  }
5664
5655
  }
5665
- /**
5666
- * The code or status that marks `error` as an upstream capacity refusal, or `undefined`.
5667
- *
5668
- * A structured field is read first: a turn outcome's `errorCode`, a transport error's
5669
- * `upstreamCode` and `status`, a provider SDK error's `code` and `status`. The failure text is read
5670
- * only as {@link unavailableSignalOfFailure} says, because a harness CLI reports the router's
5671
- * refusal as text and Sandbox's held-room refusal shares its code with a shape that never fits.
5672
- */
5656
+ /** Read Runtime admission evidence before producer hints and legacy transport metadata. */
5673
5657
  function upstreamUnavailableSignal(error) {
5674
5658
  if (undispatchedCredentialExit(error) !== void 0) return "credential-unavailable";
5659
+ if (error instanceof CheckUnavailableError) return "check-unavailable";
5660
+ if (error instanceof CoordinationUnreachableError) return "coordination-unreachable";
5661
+ const typed = turnFailureOf(error);
5662
+ if (typed) return turnFailurePolicy(typed).classification === "unavailable" ? subscriptionUsageLimitSignal({
5663
+ error: "",
5664
+ errorCode: typed.code
5665
+ }) ?? typed.code : void 0;
5675
5666
  const refusal = retainedAdmissionCause(error) ?? reconciliationCapacityRefusal(error);
5676
5667
  if (refusal !== void 0) return upstreamUnavailableSignal(refusal);
5677
5668
  if (!(error instanceof Error)) return void 0;
5678
5669
  if (isCredentialRefusal(error)) return void 0;
5679
5670
  if (isProviderSchemaRejection(error)) return void 0;
5680
- if (error instanceof CheckUnavailableError) return "check-unavailable";
5681
- if (error instanceof CoordinationUnreachableError) return "coordination-unreachable";
5682
5671
  const transport = error instanceof BackendTransportError;
5683
5672
  if (error instanceof AgentEvalError && !transport) return void 0;
5684
5673
  const harness = error instanceof HarnessTurnFailedError;
@@ -5689,13 +5678,7 @@ function upstreamUnavailableSignal(error) {
5689
5678
  };
5690
5679
  return (harness ? subscriptionUsageLimitSignal(failure) : void 0) ?? unavailableSignalOfFailure(failure);
5691
5680
  }
5692
- /**
5693
- * The capacity refusal an admitted execution's reconciliation met: a cause with an upstream
5694
- * capacity code or HTTP 429. The execution is unresolved, not failed, so the driver pauses and
5695
- * reconciles it again, never abandoning it; a contract violation stays terminal (#1204).
5696
- * magnetar-rust-sandbox-20261102a's managers met `TangleCredentialCapacityError: HTTP 429` on
5697
- * 1,407 reconciliations, each classed transient.
5698
- */
5681
+ /** Capacity encountered while reconciling an admitted execution pauses that same execution. */
5699
5682
  function reconciliationCapacityRefusal(error) {
5700
5683
  if (!(error instanceof RetainedExecutionPendingError) || error.phase !== "execution") return void 0;
5701
5684
  if (error.pendingCause !== "unobservable" && error.pendingCause !== "transport") return void 0;
@@ -5711,21 +5694,10 @@ function ownCode(error) {
5711
5694
  return;
5712
5695
  }
5713
5696
  }
5714
- /**
5715
- * Classify one driver failure. Runtime's own typed refusals are decisions and stay terminal; an
5716
- * upstream capacity refusal is `unavailable`; anything else foreign is an accident and is
5717
- * retryable. A `BackendTransportError` is split by status because the taxonomy already promises
5718
- * consumers may branch on it: a 5xx/408 is the upstream having a bad moment, a 429/503/529 is the
5719
- * upstream out of capacity, and a 401/404/422 is a request that will fail identically forever. The
5720
- * bridge's own never-retry classes are terminal whether or not a status rides with them.
5721
- *
5722
- * An `AbortError` is the run's own only when `signal` (the run) or `stopSignal` (the manager's own
5723
- * stop: an accepted result, `stop`, a stop rule) has fired. Any other is a lost stream and is
5724
- * retried: on magnetar-rust-20261019b a 4.0 h root turn ended "bridgeExecutor: turn aborted" and,
5725
- * classed terminal, settled the run after one attempt.
5726
- */
5697
+ /** Runtime cancellation/contracts dominate producer policy; untyped foreign failures retain legacy rules. */
5727
5698
  function classifyDriverFailure(error, signal, stopSignal) {
5728
5699
  if (signal?.aborted) return "terminal";
5700
+ if (error instanceof CheckUnavailableError || error instanceof CoordinationUnreachableError) return "unavailable";
5729
5701
  if (error instanceof RetainedExecutionPendingError && error.pendingCause === "provider-contract") return "terminal";
5730
5702
  if (undispatchedCredentialExit(error) !== void 0) return "unavailable";
5731
5703
  const admission = retainedAdmissionCause(error);
@@ -5736,6 +5708,9 @@ function classifyDriverFailure(error, signal, stopSignal) {
5736
5708
  if (error instanceof Error && isProviderSchemaRejection(error)) return "terminal";
5737
5709
  if (isCredentialRefusal(error)) return "terminal";
5738
5710
  if (causeChain(error).some(isProvisioningRefusal)) return "terminal";
5711
+ if (error instanceof AgentEvalError && !(error instanceof BackendTransportError)) return "terminal";
5712
+ const typed = turnFailureOf(error);
5713
+ if (typed) return turnFailurePolicy(typed).classification;
5739
5714
  if (error instanceof HarnessTurnFailedError) {
5740
5715
  if (error.errorCode !== void 0 && DETERMINISTIC_BRIDGE_CODES.has(error.errorCode)) return "terminal";
5741
5716
  if (upstreamUnavailableSignal(error) !== void 0) return "unavailable";
@@ -5747,7 +5722,6 @@ function classifyDriverFailure(error, signal, stopSignal) {
5747
5722
  const status = error.status;
5748
5723
  return status === void 0 || status === 408 || status >= 500 ? "transient" : "terminal";
5749
5724
  }
5750
- if (error instanceof AgentEvalError) return "terminal";
5751
5725
  if (upstreamUnavailableSignal(error) !== void 0) return "unavailable";
5752
5726
  return foreignHttpStatusVerdict(error) ?? "transient";
5753
5727
  }
@@ -5818,17 +5792,17 @@ const TRANSPORT_NAMES = /* @__PURE__ */ new Set([
5818
5792
  "AbortError",
5819
5793
  "RetainedStreamError"
5820
5794
  ]);
5821
- /**
5822
- * A transient failure's kind, read from typed fields on any cause, never its text. `infra` is a
5823
- * transport that dropped, timed out or answered 408 or 5xx, and earns the outage bound; anything
5824
- * else foreign is `deterministic`, an answer that repeats, and earns no window. Of 4,449 failed
5825
- * attempts over the week to 2026-11-04, 2,019 were deterministic answers retried as transient
5826
- * (a failed box's 409, a play repository's exit 128, an expired key's 401, a harness refusal).
5827
- */
5795
+ /** Producer infra earns the outage window; producer work earns only the bounded deterministic streak. */
5828
5796
  function transientFailureKind(error) {
5797
+ const typed = turnFailureOf(error);
5798
+ if (typed) return turnFailurePolicy(typed).failureKind;
5829
5799
  if (causedByPartialFailure(error)) return "deterministic";
5830
5800
  return causeChain(error).some((cause) => {
5831
5801
  if (!(cause instanceof Error)) return false;
5802
+ if (cause instanceof HarnessTurnFailedError && executorFailureInfra({
5803
+ error: cause.reported,
5804
+ ...cause.errorCode === void 0 ? {} : { errorCode: cause.errorCode }
5805
+ })) return true;
5832
5806
  const status = cause instanceof HarnessTurnFailedError ? cause.statusCode ?? printedStatus(cause.message) : errorHttpStatus(cause);
5833
5807
  const code = ownCode(cause) ?? "";
5834
5808
  return status !== void 0 && (status === 408 || status >= 500) || TRANSPORT_CODES.has(code) || code.startsWith("UND_ERR_") || cause instanceof BackendTransportError || TRANSPORT_NAMES.has(errorProperty(cause, "name") ?? "");
@@ -8569,13 +8543,15 @@ function providerFailureEvent(event, sandboxEvent) {
8569
8543
  const detail = failureDetail(sandboxEvent.data) ?? failureDetail(outcome) ?? failureDetail(result) ?? (normalized?.type === "status" ? normalized.detail : void 0);
8570
8544
  const errorCode = failureCode(sandboxEvent.data) ?? failureCode(outcome) ?? failureCode(result);
8571
8545
  const statusCode = failureStatusCode(sandboxEvent.data) ?? failureStatusCode(outcome) ?? failureStatusCode(result);
8546
+ const failure = turnFailureOf(sandboxEvent.data) ?? turnFailureOf(outcome) ?? turnFailureOf(result);
8572
8547
  return {
8573
8548
  type: "result",
8574
8549
  data: {
8575
8550
  status: "failed",
8576
8551
  ...detail ? { error: detail } : {},
8577
8552
  ...errorCode ? { errorCode } : {},
8578
- ...statusCode === void 0 ? {} : { statusCode }
8553
+ ...statusCode === void 0 ? {} : { statusCode },
8554
+ ...failure === void 0 ? {} : { failure }
8579
8555
  }
8580
8556
  };
8581
8557
  }
@@ -8610,26 +8586,7 @@ function providerTerminalSuccess(event, sandboxEvent) {
8610
8586
  result?.status
8611
8587
  ].some((status) => typeof status === "string" && TERMINAL_SUCCESS_STATUSES.has(status));
8612
8588
  }
8613
- /**
8614
- * Holds a stream's failure frames until it ends, so the terminal frame decides the outcome.
8615
- *
8616
- * The sandbox outcome tracker latches the first `error` frame as the run's error and settles
8617
- * `failed` on it whatever the terminal frame says; and until this ledger existed the runtime
8618
- * only ever showed the tracker its failure frames, so a terminal `success: true` was never in
8619
- * evidence at all. A transport error that the harness recovered from — a stream break the
8620
- * sidecar re-attached, a tool backend that failed once — therefore settled the whole child
8621
- * `down` with the transient error as its reason, and the artifact the child had banked was
8622
- * discarded. On the 2026-09-20 fleet corpus, 25 children that finished their work settled that
8623
- * way.
8624
- *
8625
- * The rule: `error` frames are forgiven when the stream reports success and carries no verdict;
8626
- * a failed status or a failed terminal frame is the provider's own verdict on the run, and once
8627
- * one exists every failure frame is evidence again, in order, so the tracker names the first
8628
- * `error` as it always did. The existing contracts hold unchanged: `status: failed` then
8629
- * `done: {}` is failed, and the retained Claude tail `completed → failed → error → done` is
8630
- * failed with the error frame's message. The forgiven frames stay in the event archive the trace
8631
- * reads; only the outcome stops claiming them.
8632
- */
8589
+ /** Terminal success forgives recovered error frames; explicit failed verdicts retain their evidence. */
8633
8590
  function createProviderFailureLedger() {
8634
8591
  const failures = [];
8635
8592
  let verdicts = 0;
@@ -8648,7 +8605,12 @@ function createProviderFailureLedger() {
8648
8605
  if (failures.length === 0 || verdicts === 0 && succeeded) return void 0;
8649
8606
  const tracker = createAgentRunOutcomeTracker();
8650
8607
  for (const frame of failures) tracker.observe(frame);
8651
- return tracker.finish();
8608
+ const outcome = tracker.finish();
8609
+ const failure = failures.slice().reverse().map((frame) => turnFailureOf(frame.data)).find((value) => value !== void 0);
8610
+ return outcome === void 0 ? void 0 : {
8611
+ ...outcome,
8612
+ ...failure === void 0 ? {} : { failure }
8613
+ };
8652
8614
  }
8653
8615
  };
8654
8616
  }
@@ -8846,13 +8808,19 @@ function exactQuotaRefusal(error) {
8846
8808
  try {
8847
8809
  const refusal = causeChain(error).find((cause) => Reflect.get(cause, "name") === "TangleCredentialCapacityError" && Reflect.get(cause, "code") === "provider_quota_exhausted");
8848
8810
  if (refusal === void 0) return void 0;
8811
+ const failure = turnFailureOf(refusal);
8849
8812
  const resetAt = Reflect.get(refusal, "resetAt");
8850
8813
  return {
8851
8814
  text: "",
8852
8815
  success: false,
8853
8816
  error: `Subscription account capacity is unavailable${typeof resetAt === "string" ? ` until ${resetAt}` : ""}`,
8854
8817
  errorCode: "provider_quota_exhausted",
8855
- statusCode: 429
8818
+ statusCode: 429,
8819
+ failure: failure ?? {
8820
+ kind: "capacity",
8821
+ code: "provider_quota_exhausted",
8822
+ ...typeof resetAt === "string" && Number.isFinite(Date.parse(resetAt)) ? { resetAt: new Date(resetAt).toISOString() } : {}
8823
+ }
8856
8824
  };
8857
8825
  } catch {
8858
8826
  return;
@@ -8948,6 +8916,7 @@ var RetainedObservation = class {
8948
8916
  finalText: result.text,
8949
8917
  success: result.success,
8950
8918
  ...result.error ? { error: result.error } : {},
8919
+ ...result.failure === void 0 ? {} : { failure: result.failure },
8951
8920
  ...result.errorCode ? {
8952
8921
  errorCode: result.errorCode,
8953
8922
  statusCode: result.statusCode
@@ -8999,7 +8968,10 @@ var RetainedObservation = class {
8999
8968
  wake = setImmediate(() => {
9000
8969
  const close = () => {
9001
8970
  const flowing = this.sawTerminal ? 0 : RETAINED_TAIL_FLOW_MS - (Date.now() - this.lastObservedAt);
9002
- if (flowing <= 0) return resolve({ kind: "exact-result" });
8971
+ if (flowing <= 0) {
8972
+ wake = setImmediate(() => resolve({ kind: "exact-result" }));
8973
+ return;
8974
+ }
9003
8975
  grace = setTimeout(() => {
9004
8976
  wake = setImmediate(() => resolve({ kind: "exact-result" }));
9005
8977
  }, flowing);
@@ -9112,7 +9084,10 @@ var RetainedObservation = class {
9112
9084
  }
9113
9085
  this.pendingRead = void 0;
9114
9086
  if (observed.value.done) break;
9115
- if (this.acceptFrame(observed.value.value)) yield observed.value.value;
9087
+ if (this.acceptFrame(observed.value.value)) {
9088
+ yield observed.value.value;
9089
+ this.lastObservedAt = Date.now();
9090
+ }
9116
9091
  }
9117
9092
  } finally {
9118
9093
  Promise.resolve().then(() => iterator?.return?.()).catch(() => void 0);
@@ -10014,6 +9989,7 @@ var ProviderTurnSettlement = class {
10014
9989
  const statusCode = failureStatusCode(outcome);
10015
9990
  const nativeFailure = outcome?.status === "failed" ? {
10016
9991
  success: false,
9992
+ ...outcome.failure === void 0 ? {} : { failure: outcome.failure },
10017
9993
  ...outcome.error ? { error: outcome.error } : {},
10018
9994
  ...outcome.errorCode ? { errorCode: outcome.errorCode } : {},
10019
9995
  ...statusCode === void 0 ? {} : { statusCode }
@@ -10034,7 +10010,8 @@ var ProviderTurnSettlement = class {
10034
10010
  });
10035
10011
  if (signal !== void 0) this.unavailable = {
10036
10012
  signal,
10037
- cause: errorText(nativeFailure.error ?? "")
10013
+ cause: errorText(nativeFailure.error ?? ""),
10014
+ ...nativeFailure.failure ? { failure: nativeFailure.failure } : {}
10038
10015
  };
10039
10016
  }
10040
10017
  if (this.retained) await args.retention?.onResult(settled);
@@ -10440,7 +10417,9 @@ async function pauseForContinuation(scope, invocation, ended, attempt, refusalsB
10440
10417
  const continueInvocation = invocation.retention?.continueInvocation;
10441
10418
  if (refusal === void 0 || continueInvocation === void 0 || state.workspacePreservationRequired || state.workspaceCaptureFailure !== void 0) return;
10442
10419
  const refusalsInARow = ended.madeProgress ? 1 : refusalsBefore + 1;
10443
- const pauseMs = unavailablePauseMs(refusalsInARow, options.unavailablePause || {});
10420
+ const now = Date.now();
10421
+ const reset = unavailableResumeAt(reportedResetAt(refusal, now), now);
10422
+ const pauseMs = reset === void 0 ? unavailablePauseMs(refusalsInARow, options.unavailablePause || {}) : Math.max(1e3, reset - now);
10444
10423
  await invocation.retention?.onPause?.({
10445
10424
  attempt,
10446
10425
  signal: refusal.signal,
@@ -15188,7 +15167,7 @@ function singleShotDriver(maxIterations) {
15188
15167
  * model, process, limits, or backend behavior is detached and deeply frozen.
15189
15168
  * Explicit service/function fields remain live by reference because they are executable ports,
15190
15169
  * not portable configuration. */
15191
- function snapshotExecutorConfig(config) {
15170
+ function snapshotExecutorConfig(config, mode = "execution") {
15192
15171
  switch (config.backend) {
15193
15172
  case "router-tools": {
15194
15173
  const { complete, executeToolCall, onMessages, onToolStep, onProviderResponse, ...decisionData } = config;
@@ -15246,7 +15225,7 @@ function snapshotExecutorConfig(config) {
15246
15225
  const { provider, registry, profileForCreate, taskToTurn, validator, workspaceRetention, shared, ...decisionData } = config;
15247
15226
  if (shared !== void 0 && (decisionData.steering !== void 0 || decisionData.placements !== void 0 || workspaceRetention !== void 0)) throw new ValidationError$1("createExecutor(provider): shared placement cannot combine with steering, placements, or workspaceRetention");
15248
15227
  const snapshot = detachedSnapshot(decisionData, "createExecutor provider config");
15249
- const resolvedProvider = resolveAgentEnvironmentProvider(provider, registry);
15228
+ const resolvedProvider = mode === "control" && typeof provider === "string" ? registry?.get(provider) ?? provider : resolveAgentEnvironmentProvider(provider, registry);
15250
15229
  return Object.freeze({
15251
15230
  ...snapshot,
15252
15231
  provider: resolvedProvider,
@@ -16837,8 +16816,8 @@ function allSpawnedChildrenDown(tree) {
16837
16816
  }
16838
16817
  function poolExhausted(pool, opts) {
16839
16818
  const r = pool.readout();
16840
- if (r.iterationsLeft <= 0) return true;
16841
- if (r.tokensLeft <= 0) return true;
16819
+ if (r.iterationsCapped !== false && r.iterationsLeft <= 0) return true;
16820
+ if (r.tokensCapped !== false && r.tokensLeft <= 0) return true;
16842
16821
  return opts.budget.maxUsd !== void 0 && r.usdLeft <= 0;
16843
16822
  }
16844
16823
  function deadlinePassed(pool, opts) {
@@ -17122,7 +17101,7 @@ async function joinRunChildren(join, settleGraceMs) {
17122
17101
  if (!persistence.failed && join.retainedAtSettlement === "release") join.teardownUnconfirmed = await releaseRetainedEnvironments(scope);
17123
17102
  const releasing = !persistence.failed && join.retainedAtSettlement === "release";
17124
17103
  await confirmRetriableTeardowns(join, releasing);
17125
- join.teardownUnconfirmed = [...join.teardownUnconfirmed, ...unrecoveredRetainedChildren(scope, join.resumeFrom)];
17104
+ join.teardownUnconfirmed = await unrecoveredRetainedChildren(join);
17126
17105
  for (const node of join.teardownUnconfirmed) await join.opts.journal.appendEvent(join.opts.runId, {
17127
17106
  kind: "teardown-unconfirmed",
17128
17107
  ...unconfirmedRecord(node),
@@ -17131,6 +17110,112 @@ async function joinRunChildren(join, settleGraceMs) {
17131
17110
  });
17132
17111
  if (releasing) await closeRetainedSlots(scope);
17133
17112
  }
17113
+ /** Retained custody absent from the live scope, including a cold cancellation without ports. */
17114
+ async function unrecoveredRetainedChildren(join) {
17115
+ const { scope, resumeFrom } = join;
17116
+ const adopted = new Set(scope.view.nodes.map((node) => node.id));
17117
+ const unrecovered = [];
17118
+ for (const recovery of resumeFrom?.recoveries ?? []) {
17119
+ if (adopted.has(recovery.spawned.id)) continue;
17120
+ const environments = /* @__PURE__ */ new Map();
17121
+ for (const admission of recovery.admissions) {
17122
+ const environment = admission.phase === "environment" ? admission : admission.phase === "dispatched" ? admission.controlRef : void 0;
17123
+ if (environment === void 0) continue;
17124
+ const ref = {
17125
+ provider: environment.provider,
17126
+ environmentId: environment.environmentId,
17127
+ keptFor: "evidence"
17128
+ };
17129
+ environments.set(JSON.stringify([ref.provider, ref.environmentId]), ref);
17130
+ }
17131
+ unrecovered.push({
17132
+ id: recovery.spawned.id,
17133
+ label: recovery.spawned.label,
17134
+ runtime: recovery.spawned.runtime,
17135
+ status: resumeFrom?.view.nodes.find((node) => node.id === recovery.spawned.id)?.status ?? "pending",
17136
+ ...environments.size === 0 ? {} : { kept: [...environments.values()] },
17137
+ attempts: 0,
17138
+ detail: "Retained child was not recovered before settlement; source evidence and teardown remain unverified."
17139
+ });
17140
+ }
17141
+ const unconfirmed = new Map([...join.teardownUnconfirmed, ...unrecovered].map((node) => [node.id, node]));
17142
+ if (resumeFrom === void 0 || !(join.opts.signal?.reason instanceof RunCancellationReason)) return [...unconfirmed.values()];
17143
+ const forest = await loadSpawnForest(join.opts.journal, join.opts.runId);
17144
+ const destroyed = /* @__PURE__ */ new Map();
17145
+ const confirmed = /* @__PURE__ */ new Map();
17146
+ const refs = /* @__PURE__ */ new Map();
17147
+ const pending = /* @__PURE__ */ new Map();
17148
+ const keyOf = (provider, environmentId) => JSON.stringify([provider, environmentId]);
17149
+ const later = (proof, admission) => proof.tree === admission.tree ? proof.index > admission.index : Number.isFinite(proof.at) && Number.isFinite(admission.at) && proof.at > admission.at;
17150
+ for (const [index, { treeRoot, event }] of forest.events.entries()) {
17151
+ const position = {
17152
+ tree: treeRoot,
17153
+ index,
17154
+ at: Date.parse(event.at)
17155
+ };
17156
+ const invocation = JSON.stringify([treeRoot, event.id]);
17157
+ if (event.kind === "environment-teardown" && event.destroyed) {
17158
+ const key = keyOf(event.provider, event.environmentId);
17159
+ destroyed.set(key, [...destroyed.get(key) ?? [], position]);
17160
+ }
17161
+ if (event.kind === "teardown-confirmed") confirmed.set(event.id, [...confirmed.get(event.id) ?? [], position]);
17162
+ if (event.kind === "execution-input" || event.kind === "execution-result" || event.kind === "execution-abandoned") pending.delete(invocation);
17163
+ if (event.kind !== "execution-admitted") continue;
17164
+ const admission = event.admission;
17165
+ const environment = admission.phase === "environment" ? admission : admission.phase === "dispatched" ? admission.controlRef : void 0;
17166
+ if (environment === void 0) {
17167
+ pending.set(invocation, {
17168
+ id: event.id,
17169
+ position
17170
+ });
17171
+ continue;
17172
+ }
17173
+ pending.delete(invocation);
17174
+ const held = refs.get(event.id) ?? /* @__PURE__ */ new Map();
17175
+ const key = keyOf(environment.provider, environment.environmentId);
17176
+ const custody = held.get(key) ?? {
17177
+ ref: {
17178
+ provider: environment.provider,
17179
+ environmentId: environment.environmentId,
17180
+ keptFor: "evidence"
17181
+ },
17182
+ admissions: /* @__PURE__ */ new Map()
17183
+ };
17184
+ custody.admissions.set(treeRoot, position);
17185
+ held.set(key, custody);
17186
+ refs.set(event.id, held);
17187
+ }
17188
+ const discharged = (id, key, custody) => [...custody.admissions.values()].every((admission) => [...destroyed.get(key) ?? [], ...confirmed.get(id) ?? []].some((proof) => later(proof, admission)));
17189
+ const unknown = new Set([...pending.values()].filter(({ id, position }) => !(confirmed.get(id) ?? []).some((proof) => later(proof, position))).map(({ id }) => id));
17190
+ for (const [id, node] of unconfirmed) {
17191
+ if (node.attempts !== 0 || node.environments?.length || !node.kept?.length || unknown.has(id)) continue;
17192
+ if (node.kept.every((ref) => {
17193
+ const key = keyOf(ref.provider, ref.environmentId);
17194
+ const custody = refs.get(id)?.get(key);
17195
+ return custody !== void 0 && discharged(id, key, custody);
17196
+ })) unconfirmed.delete(id);
17197
+ }
17198
+ for (const node of forest.nodes) {
17199
+ const kept = [...refs.get(node.id) ?? []].filter(([key, custody]) => !discharged(node.id, key, custody)).map(([, custody]) => custody.ref);
17200
+ if (kept.length === 0 && !unknown.has(node.id)) continue;
17201
+ const prior = unconfirmed.get(node.id);
17202
+ const covered = new Set([...prior?.kept ?? [], ...prior?.environments ?? []].map((ref) => keyOf(ref.provider, ref.environmentId)));
17203
+ const missing = kept.filter((ref) => !covered.has(keyOf(ref.provider, ref.environmentId)));
17204
+ if (prior !== void 0 && missing.length === 0) continue;
17205
+ unconfirmed.set(node.id, {
17206
+ ...prior ?? {
17207
+ id: node.id,
17208
+ label: node.label,
17209
+ runtime: node.runtime,
17210
+ status: node.status,
17211
+ attempts: 0
17212
+ },
17213
+ ...(prior?.kept?.length ?? 0) + missing.length > 0 ? { kept: [...prior?.kept ?? [], ...missing] } : {},
17214
+ detail: prior?.detail ?? "Prior admitted execution has no confirmed teardown; source custody remains unverified."
17215
+ });
17216
+ }
17217
+ return [...unconfirmed.values()];
17218
+ }
17134
17219
  /**
17135
17220
  * A first teardown that failed or answered late is not the provider's last word, and a run that
17136
17221
  * settles over it leaves the sandbox running: cancelling 20 Discovery lanes
@@ -17159,35 +17244,6 @@ async function confirmRetriableTeardowns(join, releasing) {
17159
17244
  });
17160
17245
  }
17161
17246
  }
17162
- /** Retained children a resume restored from the journal but never adopted into the live scope. */
17163
- function unrecoveredRetainedChildren(scope, resumeFrom) {
17164
- const adopted = new Set(scope.view.nodes.map((node) => node.id));
17165
- const unrecovered = [];
17166
- for (const recovery of resumeFrom?.recoveries ?? []) {
17167
- if (adopted.has(recovery.spawned.id)) continue;
17168
- const environments = /* @__PURE__ */ new Map();
17169
- for (const admission of recovery.admissions) {
17170
- const environment = admission.phase === "environment" ? admission : admission.phase === "dispatched" ? admission.controlRef : void 0;
17171
- if (environment === void 0) continue;
17172
- const ref = {
17173
- provider: environment.provider,
17174
- environmentId: environment.environmentId,
17175
- keptFor: "evidence"
17176
- };
17177
- environments.set(JSON.stringify([ref.provider, ref.environmentId]), ref);
17178
- }
17179
- unrecovered.push({
17180
- id: recovery.spawned.id,
17181
- label: recovery.spawned.label,
17182
- runtime: recovery.spawned.runtime,
17183
- status: resumeFrom?.view.nodes.find((node) => node.id === recovery.spawned.id)?.status ?? "pending",
17184
- ...environments.size === 0 ? {} : { kept: [...environments.values()] },
17185
- attempts: 0,
17186
- detail: "Retained child was not recovered before settlement; source evidence and teardown remain unverified."
17187
- });
17188
- }
17189
- return unrecovered;
17190
- }
17191
17247
  // src/runtime/supervise/supervisor-run-tree.ts
17192
17248
  async function openRunTree(opts, now) {
17193
17249
  const rootAttemptId = newExecutionAttemptId(opts.runId);
@@ -17287,6 +17343,11 @@ function createSupervisor() {
17287
17343
  const journal = wrapJournalForBreaker(opts.journal, breaker);
17288
17344
  const scope = createRootScope(intake, opened, journal, now);
17289
17345
  const openScope = scope;
17346
+ const ownerControl = runtimeOwnedScopeOwnerControl(root);
17347
+ if (ownerControl !== void 0) {
17348
+ bindScopeRetainedOwnerProvider(openScope, ownerControl.provider, ownerControl.checkpointCapture);
17349
+ bindScopeRetainedOwnerWorkspaceRetention(openScope, ownerControl.checkpointCapture !== void 0);
17350
+ }
17290
17351
  if (rootLease) rootLease.bind({
17291
17352
  scope: openScope,
17292
17353
  cascadeAbort: (reason) => cascade.abort(new RunCancellationReason("root-handle", reason ?? "root handle aborted")),
@@ -17442,11 +17503,15 @@ async function executeRoot(root) {
17442
17503
  let executionAborted = controller.signal.aborted;
17443
17504
  let allChildrenDownAtSettle = false;
17444
17505
  let parked = false;
17506
+ let rootStarted = false;
17445
17507
  try {
17446
17508
  await startScopeRecoveries(scope);
17447
17509
  actOutcome = {
17448
17510
  ok: true,
17449
- out: await runAbortable(root.run, controller.signal, "supervisor aborted")
17511
+ out: await runAbortable(() => {
17512
+ rootStarted = true;
17513
+ return root.run();
17514
+ }, controller.signal, "supervisor aborted")
17450
17515
  };
17451
17516
  } catch (error) {
17452
17517
  if (error instanceof RunParkedError && error.runId === opts.runId) {
@@ -17473,7 +17538,7 @@ async function executeRoot(root) {
17473
17538
  error
17474
17539
  };
17475
17540
  }
17476
- if (!persistence.failed) try {
17541
+ if (rootStarted && !persistence.failed) try {
17477
17542
  await finalizeScopeOwnerMaterialization(scope);
17478
17543
  } catch (error) {
17479
17544
  if (actOutcome?.ok !== false) actOutcome = {
@@ -17578,4 +17643,4 @@ async function noWinner(settled, rejection) {
17578
17643
  }
17579
17644
  export { DEFAULT_PEER_MAIL_LIMITS as $, promptModelProfileMaterialization as $t, createSandboxForSpec as A, bridgeModelRouteRefusal as At, createRouterTranscript as B, defaultRunCommand as Bt, createExecutor as C, admitContinuationPolicy as Ct, runAgentRounds as D, failedItems as Dt, createSteerableSandboxSession as E, createContinuationKeeper as Et, codeModeArguments as F, harnessUsageIsEmpty as Ft, LEAF_CONTINUATION_TASK as G, terminateProcessTreeAndConfirm as Gt, createAgentEnvironmentProviderRegistry as H, runWorktreeHarness as Ht, codeModeModelOutput as I, readCodexRolloutSession as It, createInPlaceCliExecutor as J, controlProfileMaterialization as Jt, providerAsSandboxClient as K, assertProfileMaterialization as Kt, createCodeModeTools as L, createPushTraceSource as Lt, acquireSandbox as M, ROUTER_PRICE_SOURCE as Mt, TERMINAL_DECISIONS as N, addHarnessUsage as Nt, assertBoxlessPromptOptions as O, isFiniteNumber as Ot, defaultSelectWinner as P, createCodexRolloutStoreReader as Pt, AUTHORITY_MARKERS as Q, promptControlProfileMaterialization as Qt, runCodeMode as R, bridgeRuntimeAttachmentsKey as Rt, captureReusableExecutorConfig as S, CONTINUATIONS_DIR as St, DEFAULT_SANDBOX_STEERING_MAX_TURNS as T, checkVerdictOf as Tt, resolveAgentEnvironmentProvider as U, LOCAL_HARNESSES as Ut, routerBrain as V, runSettledCommand as Vt, providerAsExecutor as W, harnessInvocation as Wt, createInbox as X, fullProfileMaterialization as Xt, INBOX_RECEIPT_KEY as Y, defineProfileMaterializationContract as Yt, failPendingAfter as Z, profileMaterializationAxes$1 as Zt, withDriverExecutor as _, CheckUnavailableError as _t, assertRunParking as a, projectSandboxOutcome as an, peerMailVerbNames as at, createExecutorRegistry as b, mapExecutorResult as bt, sleepScopeWait as c, HarnessTurnFailedError as ct, runFinalizer as d, isContentFilterRefusal as dt, renderUnsupported as en, PEER_MAIL_WIRE_KEY as et, runTree as f, summarizeDriverAttempts as ft, isDriverSpec as g, preflightPublicCoordination as gt, driverExecutorFactory as h, upstreamUnavailableSignal as ht, RunParkedError as i, worktreeCliProfileMaterialization as in, peerMailTools as it, createSandboxLineage as j, priceTokens as jt, readPromptOptions as k, bridgeAdmissionRefusal as kt, withRunParking as l, abandonablePending as lt, driverChild as m, undispatchedCredentialExit as mt, createSupervisor as n, sandboxProfileMaterialization as nn, createPeerMailbox as nt, bindScopeParkingDrain as o, readSandboxOutcome as on, taskToPrompt$1 as ot, createRootHandle as p, transientFailureKind as pt, createWorktreeCliExecutor as q, assertProfileMaterializes as qt, assertResumeLimits as r, unsupportedProfileDimensions as rn, isPeerMailEnvelope as rt, readRunParking as s, DriverAttemptsExhaustedError as st, DEFAULT_MAX_DEPTH as t, sandboxActProfileMaterialization as tn, claimsAuthority as tt, bestDelivered as u, classifyDriverFailure as ut, InMemoryResultBlobStore as v, gateFactoryOnDeliverable as vt, snapshotExecutorConfig as w, bestComposite as wt, bindReusableExecutorExecutionId as x, verdictFromJudgeScore as xt, InMemorySpawnJournal as y, gateOnDeliverable as yt, toolResultText as z, bridgeStopSignalKey as zt };
17580
17645
 
17581
- //# sourceMappingURL=supervisor-BDOWzyCC.js.map
17646
+ //# sourceMappingURL=supervisor-B-bX69uL.js.map