@tangle-network/agent-runtime 9.0.15 → 10.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 (93) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/dist/{activation-y6NAn3sW.d.ts → activation-CDlOqX5a.d.ts} +7 -8
  3. package/dist/{activation-DTVc4eVS.js → activation-CEGkyzEG.js} +2 -2
  4. package/dist/{activation-DTVc4eVS.js.map → activation-CEGkyzEG.js.map} +1 -1
  5. package/dist/agent.d.ts +1 -1
  6. package/dist/agent.js +3 -3
  7. package/dist/candidate-execution/index.d.ts +3 -0
  8. package/dist/candidate-execution/index.js +10 -3
  9. package/dist/candidate-execution/index.js.map +1 -1
  10. package/dist/{delegate-DigGceAE.js → delegate-V2Nz8GgO.js} +2 -2
  11. package/dist/{delegate-DigGceAE.js.map → delegate-V2Nz8GgO.js.map} +1 -1
  12. package/dist/{coordination-manager-mGr9UHYk.js → driver-control-acknowledgers-CJDYLJmW.js} +1042 -1042
  13. package/dist/driver-control-acknowledgers-CJDYLJmW.js.map +1 -0
  14. package/dist/durable.d.ts +5 -5
  15. package/dist/durable.js +13 -13
  16. package/dist/durable.js.map +1 -1
  17. package/dist/{failure-cause-WifbY42M.js → failure-cause-BI7cfDWx.js} +14 -2
  18. package/dist/failure-cause-BI7cfDWx.js.map +1 -0
  19. package/dist/{graph-registry-B_1C7qye.js → graph-registry-DxhlgHdA.js} +1 -1
  20. package/dist/{graph-registry-BbZN5deo.js → graph-registry-j9t9J0KT.js} +11 -12
  21. package/dist/{graph-registry-BbZN5deo.js.map → graph-registry-j9t9J0KT.js.map} +1 -1
  22. package/dist/{graph-D2DFmNIP.js → graph-wJOMQ1kC.js} +8 -8
  23. package/dist/{graph-D2DFmNIP.js.map → graph-wJOMQ1kC.js.map} +1 -1
  24. package/dist/{improve-DoANtwjC.js → improve-DOjywiPq.js} +42 -26
  25. package/dist/{improve-DoANtwjC.js.map → improve-DOjywiPq.js.map} +1 -1
  26. package/dist/index.d.ts +38 -6
  27. package/dist/index.js +59 -20
  28. package/dist/index.js.map +1 -1
  29. package/dist/intelligence.d.ts +93 -63
  30. package/dist/intelligence.js +166 -73
  31. package/dist/intelligence.js.map +1 -1
  32. package/dist/kernel.d.ts +3 -3
  33. package/dist/kernel.js +16 -15
  34. package/dist/{loop-runner-CVI07sjG.js → loop-runner-CPTOzSol.js} +2 -2
  35. package/dist/{loop-runner-CVI07sjG.js.map → loop-runner-CPTOzSol.js.map} +1 -1
  36. package/dist/{loop-runner-CfMOsISJ.d.ts → loop-runner-DwxZbYW5.d.ts} +2 -2
  37. package/dist/loop-runner-bin.d.ts +1 -1
  38. package/dist/loop-runner-bin.js +1 -1
  39. package/dist/mcp/bin.js +3 -3
  40. package/dist/mcp/index.d.ts +1 -1
  41. package/dist/mcp/index.js +7 -7
  42. package/dist/mcp/memory-bin.js +1 -1
  43. package/dist/{model-policy-CZwhXp8O.js → model-policy-CqDuBTq-.js} +12 -2
  44. package/dist/model-policy-CqDuBTq-.js.map +1 -0
  45. package/dist/{prepare-Cw4ZaN01.js → prepare-DT-ibRsm.js} +2 -2
  46. package/dist/{prepare-Cw4ZaN01.js.map → prepare-DT-ibRsm.js.map} +1 -1
  47. package/dist/profiles.d.ts +1 -1
  48. package/dist/profiles.js +1 -1
  49. package/dist/{provision-supervisor-BH6Fxf7H.js → provision-supervisor-B1_Kow9m.js} +6 -6
  50. package/dist/{provision-supervisor-BH6Fxf7H.js.map → provision-supervisor-B1_Kow9m.js.map} +1 -1
  51. package/dist/{run-cancellation-DHuvsgzo.js → run-cancellation-D5m6JHPH.js} +2 -2
  52. package/dist/{run-cancellation-DHuvsgzo.js.map → run-cancellation-D5m6JHPH.js.map} +1 -1
  53. package/dist/{run-state-CE2rffEV.js → run-state-DKOXe08H.js} +5 -5
  54. package/dist/{run-state-CE2rffEV.js.map → run-state-DKOXe08H.js.map} +1 -1
  55. package/dist/{runtime-PNBuLZxE.js → runtime-C5cWSMqU.js} +191 -24
  56. package/dist/runtime-C5cWSMqU.js.map +1 -0
  57. package/dist/{search-executor-CNxDTuV3.js → search-executor-CA6fTYWz.js} +5 -5
  58. package/dist/{search-executor-CNxDTuV3.js.map → search-executor-CA6fTYWz.js.map} +1 -1
  59. package/dist/{server-CfJ_WYXR.js → server-C8Z3vYdI.js} +4 -4
  60. package/dist/{server-CfJ_WYXR.js.map → server-C8Z3vYdI.js.map} +1 -1
  61. package/dist/{settle-record-einetd2l.js → settle-record-BDxPAO4m.js} +2 -2
  62. package/dist/{settle-record-einetd2l.js.map → settle-record-BDxPAO4m.js.map} +1 -1
  63. package/dist/{structural-rollout-BH_MWOy0.js → structural-rollout-B0HPcP9G.js} +5 -5
  64. package/dist/{structural-rollout-BH_MWOy0.js.map → structural-rollout-B0HPcP9G.js.map} +1 -1
  65. package/dist/{supervise-CM5cXyuf.js → supervise-Dvj-8S6D.js} +2341 -2283
  66. package/dist/supervise-Dvj-8S6D.js.map +1 -0
  67. package/dist/{supervision-discovery-BZRsXavN.js → supervision-discovery-CbrwcgJy.js} +3 -3
  68. package/dist/{supervision-discovery-BZRsXavN.js.map → supervision-discovery-CbrwcgJy.js.map} +1 -1
  69. package/dist/{supervisor-C3Fv97vT.js → supervisor-DwdeUC2l.js} +218 -47
  70. package/dist/supervisor-DwdeUC2l.js.map +1 -0
  71. package/dist/{supervisor-accounting-6O0Hr0Fg.js → supervisor-accounting-C48Yo9QC.js} +526 -348
  72. package/dist/supervisor-accounting-C48Yo9QC.js.map +1 -0
  73. package/dist/testing.d.ts +1 -1
  74. package/dist/testing.js +11 -11
  75. package/dist/{tool-server-CirrqFlr.js → tool-server-DsCeBr-C.js} +2 -2
  76. package/dist/{tool-server-CirrqFlr.js.map → tool-server-DsCeBr-C.js.map} +1 -1
  77. package/dist/{top-web-CRe6c8wu.js → top-web-CTOq4psb.js} +6 -6
  78. package/dist/{top-web-CRe6c8wu.js.map → top-web-CTOq4psb.js.map} +1 -1
  79. package/dist/tui/bin.js +3 -3
  80. package/dist/tui/index.d.ts +1 -1
  81. package/dist/tui/index.js +2 -2
  82. package/dist/{types-_j53efrk.d.ts → types-lnF0wIJW.d.ts} +8245 -8153
  83. package/dist/{workspace-streams-BakRr-Pl.js → workspace-streams-C7PGLAUd.js} +3 -3
  84. package/dist/workspace-streams-C7PGLAUd.js.map +1 -0
  85. package/package.json +6 -5
  86. package/dist/coordination-manager-mGr9UHYk.js.map +0 -1
  87. package/dist/failure-cause-WifbY42M.js.map +0 -1
  88. package/dist/model-policy-CZwhXp8O.js.map +0 -1
  89. package/dist/runtime-PNBuLZxE.js.map +0 -1
  90. package/dist/supervise-CM5cXyuf.js.map +0 -1
  91. package/dist/supervisor-C3Fv97vT.js.map +0 -1
  92. package/dist/supervisor-accounting-6O0Hr0Fg.js.map +0 -1
  93. package/dist/workspace-streams-BakRr-Pl.js.map +0 -1
@@ -1,19 +1,19 @@
1
- import { $n as captureHarnessTranscript, $r as RetainedRunProviderContractError, $t as loadSpawnForest, Ar as knownMaterializationReceipt, Br as runtimeOwnedExecutorMaterialization, Bt as scopeRetainedOwnerSettled, Cr as attestRuntimeOwnedPendingExecutor, Dr as finalizeRuntimeOwnedPendingExecutor, Fn as workerTraceHeaders, Fr as recordRuntimeOwnedProviderDispatchNotStarted, G as appendSpawnEvents, Gr as unknownExecutionBindingReceipt, Ir as recordRuntimeOwnedProviderIdentityConflict, J as reenteredWorkers, Jr as executableAgentSpecSnapshot, Jt as bindScopeRetainedOwnerProvider, Kr as unknownMaterializationReceipt, Kt as scopeRetainedOwnerCheckpointing, L as nestedScopeSeamKey, Ln as mergeTraceEnv, Lr as recordRuntimeOwnedProviderModel, M as prepareScopeResume, Mn as environmentGone, Nn as WORKER_TRACE_PROPAGATION, Or as inheritRuntimeOwnedExecutorAttestation, Pn as workerTraceEnv, Pr as recordRuntimeOwnedProviderAttemptStart, Sr as attestRuntimeOwnedExecutor, Ur as runtimeOwnedScopeOwnerControl, Wr as runtimeOwnedScopeOwnerRuntime, X as assertRecursiveReservationPolicy, Xt as scopeOwnerLiabilities, Yt as owners, Zn as HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS, _n as assertRetainedRunReplayMaterial, _t as waitForScopeChildren, ai as sameControlCoordinates, bn as recoverRetainedRun, br as subscriptionUsageLimitSignal, dn as observeModelRequest, dr as describeToolArgs, dt as releaseHeldEnvironments, ei as assertEventBinding, en as ownedTreeRootSpawn, ft as releaseRetainedEnvironments, gn as RetainedMaterializationTimeoutError, gt as unconfirmedTeardowns, hn as verifyWorkspaceMarker, ht as startScopeRecoveries, ii as retainedSessionReplaced, in as nestedDriverTreeRoot, j as resolveWorkerSlots, jr as newExecutionAttemptId, kr as knownExecutionBindingReceipt, kt as finalizeScopeOwnerMaterialization, ln as executorObservation, mn as stopRetainedNativeExecution, mt as settleManagerWork, n as terminalAccounting, ni as exactSession, nn as attestNestedDriverTreeOwner, nr as harnessTranscriptUnavailable, nt as closeScopeAdmission, on as encodeResultBlob, pn as describeRetainedNativeStops, pr as isLiveNodeStatus, pt as retryUnconfirmedTeardowns, q as appendTeardownConfirmation, qr as executableAgentProfileSnapshot, r as createScope, ri as freezeControlRef, rn as driverRuntime, rt as hasRetriableTeardowns, si as promptOptionsFromAgentTurnInput, sn as SpawnEventIndex, t as isNonEmptySpend, ti as awaitAbortable, tr as harnessTranscriptFromLines, tt as closeRetainedSlots, ur as createActivityLog, ut as registerNestedTeardownScope, vn as mintRetainedIdentity, xn as startRetainedRun, xr as attestRuntimeOwnedDeferredExecutor, yn as reconnectRetainedRun, zr as runtimeOwnedExecutorExecutionBinding } from "./supervisor-accounting-6O0Hr0Fg.js";
1
+ import { $r as executableAgentSpecSnapshot, $t as owners, Br as recordRuntimeOwnedProviderDispatchNotStarted, Cn as reconnectRetainedRun, Dr as attestRuntimeOwnedExecutor, Er as attestRuntimeOwnedDeferredExecutor, Fr as knownMaterializationReceipt, G as appendSpawnEvents, Gr as runtimeOwnedExecutorMaterialization, Hr as recordRuntimeOwnedProviderModel, In as environmentGone, Ir as newExecutionAttemptId, J as reenteredWorkers, Jr as runtimeOwnedScopeOwnerControl, L as nestedScopeSeamKey, Ln as WORKER_TRACE_PROPAGATION, M as prepareScopeResume, Mr as finalizeRuntimeOwnedPendingExecutor, Nr as inheritRuntimeOwnedExecutorAttestation, Or as attestRuntimeOwnedPendingExecutor, Pr as knownExecutionBindingReceipt, Qr as executableAgentProfileSnapshot, Qt as bindScopeRetainedOwnerProvider, Rn as workerTraceEnv, Sn as mintRetainedIdentity, Tn as startRetainedRun, Tr as subscriptionUsageLimitSignal, Vn as mergeTraceEnv, Vr as recordRuntimeOwnedProviderIdentityConflict, Wr as runtimeOwnedExecutorExecutionBinding, Wt as scopeRetainedOwnerSettled, X as assertRecursiveReservationPolicy, Xr as unknownExecutionBindingReceipt, Xt as scopeRetainedOwnerCheckpointing, Yr as runtimeOwnedScopeOwnerRuntime, Zr as unknownMaterializationReceipt, _n as describeRetainedNativeStops, _t as unconfirmedTeardowns, ai as assertEventBinding, ar as harnessTranscriptFromLines, bn as RetainedMaterializationTimeoutError, ci as freezeControlRef, cn as nestedDriverTreeRoot, dn as SpawnEventIndex, dt as registerNestedTeardownScope, en as scopeOwnerLiabilities, fi as promptOptionsFromAgentTurnInput, ft as releaseHeldEnvironments, gr as describeToolArgs, gt as startScopeRecoveries, hn as observeModelRequest, hr as createActivityLog, ht as settleManagerWork, ii as RetainedRunProviderContractError, in as ownedTreeRootSpawn, it as hasRetriableTeardowns, j as resolveWorkerSlots, jt as finalizeScopeOwnerMaterialization, li as retainedSessionReplaced, mt as retryUnconfirmedTeardowns, n as terminalAccounting, nt as closeRetainedSlots, oi as awaitAbortable, on as attestNestedDriverTreeOwner, or as harnessTranscriptUnavailable, pn as executorObservation, pt as releaseRetainedEnvironments, q as appendTeardownConfirmation, r as createScope, rn as loadSpawnForest, rr as captureHarnessTranscript, rt as closeScopeAdmission, si as exactSession, sn as driverRuntime, t as isNonEmptySpend, tr as HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS, tt as boundRetainedReleases, ui as sameControlCoordinates, un as encodeResultBlob, vn as stopRetainedNativeExecution, vr as isLiveNodeStatus, vt as waitForScopeChildren, wn as recoverRetainedRun, wt as RELEASE_DESTROY_MS, xn as assertRetainedRunReplayMaterial, yn as verifyWorkspaceMarker, zn as workerTraceHeaders, zr as recordRuntimeOwnedProviderAttemptStart } from "./supervisor-accounting-C48Yo9QC.js";
2
2
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError$1, r as BackendTransportError, t as AgentEvalError } from "./errors-DG8yufqX.js";
3
3
  import { d as abortReason, l as sha256, m as runAbortable, p as linkAbort, u as RunCancellationReason } from "./jsonl-file-BhuxeejY.js";
4
4
  import { a as ROOT_DEADLINE_REASON, f as teardownSurfaces, l as isDeadlineAbortReason, o as armDeadlineTimer, t as ACCEPTED_RESULT_GRACE_MS } from "./deadline-CySmJ_0S.js";
5
5
  import { C as unreportedSpend, D as addResourceSpend, E as zeroTokenUsage, S as unmeteredSpend, T as zeroSpend, _ as roundBoxMinutes, b as throwAbort, c as errorMessage, d as isAbortError, f as isAsyncIterable, g as randomUuid, h as randomSuffix, m as promptCacheTokenClasses, n as addSpend, o as cloneTokenUsage, p as mapWithConcurrency, r as addTokenUsage, s as deleteBoxSafe, v as sleep, w as withTimeout, x as throwIfAborted, y as stringifySafe } from "./util-qsH5cC9S.js";
6
6
  import { t as runTaskQueue } from "./task-queue-DbpZAp6C.js";
7
- import { B as turnFailurePolicy, C as cappedDoublingMs, D as unavailablePauseMs, E as reportedResetAt, Et as recordValue, H as credentialCommandExit, I as executorFailureInfra, N as contentAddress, O as unavailableResumeAt, P as contentRef, S as UNAVAILABLE_STATUSES, St as sandboxTerminalUsageField, T as printedStatus, Tt as parseCodexUsageRecord, U as isCredentialRefusal, V as hashJson, Y as createBudgetPool, a as runtimeProviderCode, bt as sameModelId, c as DISPATCH_EXECUTION_CHANGED_CODE, ct as sandboxProgressEvents, d as TRANSPORT_ERROR_CODES, dt as extractTransportEventIdentity, gt as createSandboxUsageLedger, ht as createSandboxTurnEventCollector, i as runtimeFailureRemediationSchema, k as unavailableSignalOfFailure, l as DISPATCH_NOT_ADMITTED_CODE, m as isSchemaRejection, mt as canonicalSandboxUsageMode, n as runtimeFailureCause, ot as sandboxLeafOutputFromEvents, p as isProvisioningRefusal, pt as assertSandboxServedModel, rt as createSandboxToolPartState, st as sandboxOutputMarker, t as reportedFailureCause, u as RetainedExecutionPendingError, v as retainedExecutorContext, vt as isSandboxTerminalEvent, x as UNAVAILABLE_CODES, xt as sandboxEventServedBackend, y as retainedExecutorSeamKey, yt as notifySandboxEventObserver, z as turnFailureOf } from "./failure-cause-WifbY42M.js";
7
+ import { B as turnFailurePolicy, C as cappedDoublingMs, Ct as sandboxTerminalUsageField, D as unavailablePauseMs, Dt as recordValue, E as reportedResetAt, Et as parseCodexUsageRecord, H as credentialCommandExit, I as executorFailureInfra, N as contentAddress, O as unavailableResumeAt, P as contentRef, S as UNAVAILABLE_STATUSES, St as sandboxEventServedBackend, T as printedStatus, U as isCredentialRefusal, V as hashJson, Y as createBudgetPool, a as runtimeProviderCode, bt as sameModelId, c as DISPATCH_EXECUTION_CHANGED_CODE, ct as sandboxProgressEvents, d as TRANSPORT_ERROR_CODES, dt as extractTransportEventIdentity, gt as createSandboxUsageLedger, ht as createSandboxTurnEventCollector, i as runtimeFailureRemediationSchema, k as unavailableSignalOfFailure, l as DISPATCH_NOT_ADMITTED_CODE, m as isSchemaRejection, mt as canonicalSandboxUsageMode, n as runtimeFailureCause, ot as sandboxLeafOutputFromEvents, p as isProvisioningRefusal, pt as assertSandboxServedModel, rt as createSandboxToolPartState, st as sandboxOutputMarker, t as reportedFailureCause, u as RetainedExecutionPendingError, v as retainedExecutorContext, vt as isSandboxTerminalEvent, x as UNAVAILABLE_CODES, xt as sandboxEventProviderModels, y as retainedExecutorSeamKey, yt as notifySandboxEventObserver, z as turnFailureOf } from "./failure-cause-BI7cfDWx.js";
8
8
  import { a as errMessage, i as causeChain, l as errorText, n as detachedSnapshot, o as errorHttpStatus, s as errorProperty, u as defaultRedactor } from "./snapshot-BKI_w3JD.js";
9
- 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-CZwhXp8O.js";
9
+ import { _ as reportedServedModel, a as concreteProfileModel, c as profileModelExecutionSettings, d as assertRouterAutoDeclaration, f as assertRouterAutoResponse, g as observedModelMatchesDeclared, l as profileProviderModel, m as mergeObservedModelIdentity, o as enforceTokenLimits, s as profileBridgeWireModel, t as assertExecutableAgentProfile, u as resolveRouterRetryPolicy, v as agentHarness } from "./model-policy-CqDuBTq-.js";
10
10
  import { r as nativeSystemPrompt, t as assertSandboxProfileCompatibility } from "./sandbox-profile-compat-l-SLQnGb.js";
11
- import { b as hasControlCharacter } from "./workspace-streams-BakRr-Pl.js";
11
+ import { x as hasControlCharacter } from "./workspace-streams-C7PGLAUd.js";
12
12
  import { i as checkVerdictOf, s as isFiniteNumber } from "./continuation-CZaeHEzQ.js";
13
13
  import { a as writeAtomicDurableFile, s as fenceRunWrite } from "./durable-file-DstVeHcj.js";
14
- import { t as PROTOCOL_VERSION } from "./tool-server-CirrqFlr.js";
14
+ import { t as PROTOCOL_VERSION } from "./tool-server-DsCeBr-C.js";
15
15
  import { i as notifyRuntimeHookEvent } from "./runtime-hooks-CsW2pfFk.js";
16
- import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentExactRunControlRefSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, REASONING_EFFORTS, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalWorkspaceCwd, harnessTypeSchema, mergeProxySecretBindings, nativeReasoningControl, profileMaterializationAxes, profileMaterializationAxes as profileMaterializationAxes$1, renderInputPartsAsText, sha256DigestSchema } from "@tangle-network/agent-interface";
16
+ import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentExactRunControlRefSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, REASONING_EFFORTS, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalWorkspaceCwd, harnessTypeSchema, mergeProxySecretBindings, nativeReasoningControl, profileMaterializationAxes, profileMaterializationAxes as profileMaterializationAxes$1, renderInputPartsAsText, sameAgentRunControlRef, sha256DigestSchema, workspaceCwdPathForBase } from "@tangle-network/agent-interface";
17
17
  import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
18
18
  import { SDKError, generateIdempotencyKey, isRecord, withRetry } from "@tangle-network/agent-core";
19
19
  import { collectAgentFinalMessageText, collectAgentResponseText, isToolBearingEvent } from "@tangle-network/sandbox";
@@ -2281,6 +2281,14 @@ function readOptionalMcpAttachments(ctx, key, who) {
2281
2281
  if (entries === void 0 || entries.length === 0 || entries.some(([, server]) => server === null || typeof server !== "object")) throw new ValidationError$1(`${who} executor: seam ${JSON.stringify(key)} must be a non-empty map of MCP servers`);
2282
2282
  return value;
2283
2283
  }
2284
+ /** Narrow the Runtime-owned request env seam: absent sends none; present is a non-empty name map. */
2285
+ function readOptionalRuntimeEnv(ctx, key, who) {
2286
+ const value = ctx.seams[key];
2287
+ if (value === void 0) return void 0;
2288
+ const entries = value !== null && typeof value === "object" && !Array.isArray(value) ? Object.values(value) : [];
2289
+ if (entries.length === 0 || entries.some((secret) => typeof secret !== "string" || !secret)) throw new ValidationError$1(`${who} executor: seam ${JSON.stringify(key)} must map names to values`);
2290
+ return value;
2291
+ }
2284
2292
  // src/runtime/supervise/bridge-config.ts
2285
2293
  const bridgeSeamKey = "bridge";
2286
2294
  /** Internal control seam used by Runtime-owned external supervisors. A completion request stops
@@ -2291,6 +2299,9 @@ const bridgeStopSignalKey = "__bridge_stop_signal";
2291
2299
  * them out of its session profile binding. A rebound coordination port therefore cannot move the
2292
2300
  * authored profile digest that binds a durable session. */
2293
2301
  const bridgeRuntimeAttachmentsKey = "__bridge_runtime_attachments";
2302
+ /** Internal secret seam beside {@link bridgeRuntimeAttachmentsKey}: request `env` the bridge lifts
2303
+ * into memory before it records the run, so a secret-ref attachment header resolves to it. */
2304
+ const bridgeRuntimeEnvKey = "__bridge_runtime_env";
2294
2305
  const maxBridgeTimeoutMs = 2147483647;
2295
2306
  function isLoopbackBridgeHost(hostname) {
2296
2307
  const host = hostname.trim().toLowerCase().replace(/^\[/, "").replace(/\]$/, "");
@@ -5527,6 +5538,7 @@ async function* streamBridgeTurn(args, turn) {
5527
5538
  },
5528
5539
  agent_profile: args.profile,
5529
5540
  ...args.runtimeAttachments === void 0 ? {} : { runtime_attachments: { mcp: args.runtimeAttachments } },
5541
+ ...args.runtimeEnv === void 0 ? {} : { env: args.runtimeEnv },
5530
5542
  messages: turn.messages
5531
5543
  };
5532
5544
  ledger.beginTurn();
@@ -5601,13 +5613,13 @@ async function settleFailedTurn(error, args, signals, activeRun, external) {
5601
5613
  function observeChunkIdentity(chunk, ledger, args) {
5602
5614
  const { seam } = args;
5603
5615
  if (chunk.model !== void 0) try {
5604
- if (!observedModelMatchesDeclared(chunk.model, seam.providerModel)) {
5616
+ const verdict = reportedServedModel(chunk.model, seam.providerModel, seam.model);
5617
+ if (verdict === "conflict") {
5605
5618
  args.onProviderIdentityConflict();
5606
5619
  throw new ValidationError$1(`bridgeExecutor: bridge reported model ${JSON.stringify(chunk.model)} but the profile requires ${JSON.stringify(seam.providerModel)}`);
5607
5620
  }
5608
- const isWireModel = chunk.model === seam.model;
5609
- if (!isWireModel && observedModelHasSnapshot(chunk.model)) args.onProviderModel(chunk.model);
5610
- if (!isWireModel) ledger.observedModel = mergeBridgeObservedModel(ledger.observedModel, chunk.model);
5621
+ if (verdict === "record") args.onProviderModel(chunk.model);
5622
+ if (chunk.model !== seam.model) ledger.observedModel = mergeBridgeObservedModel(ledger.observedModel, chunk.model);
5611
5623
  } catch (error) {
5612
5624
  args.onProviderIdentityConflict();
5613
5625
  throw error;
@@ -6423,6 +6435,7 @@ const bridgeExecutor = (spec, ctx) => {
6423
6435
  const base = readSeam(ctx, bridgeSeamKey, "bridge");
6424
6436
  const stopSignal = readOptionalAbortSignal(ctx, bridgeStopSignalKey, "bridge");
6425
6437
  const runtimeAttachments = readOptionalMcpAttachments(ctx, bridgeRuntimeAttachmentsKey, "bridge");
6438
+ const runtimeEnv = readOptionalRuntimeEnv(ctx, bridgeRuntimeEnvKey, "bridge");
6426
6439
  const modelCredential = validateBridgeModelCredential(base.modelCredential, base.bridgeUrl, "bridgeExecutor");
6427
6440
  const effectiveProfile = agentProfileSchema.parse(spec.profile);
6428
6441
  const model = bridgeProfileModel(effectiveProfile, "bridgeExecutor");
@@ -6547,6 +6560,7 @@ const bridgeExecutor = (spec, ctx) => {
6547
6560
  signal,
6548
6561
  ...stopSignal === void 0 ? {} : { stopSignal },
6549
6562
  ...runtimeAttachments === void 0 ? {} : { runtimeAttachments },
6563
+ ...runtimeEnv === void 0 ? {} : { runtimeEnv },
6550
6564
  profile: effectiveProfile,
6551
6565
  seam,
6552
6566
  sessionId,
@@ -7390,6 +7404,120 @@ function publicCreateOptions(create) {
7390
7404
  ...secrets === void 0 ? {} : { secretNames: Array.isArray(secrets) ? [...secrets].sort() : Object.keys(secrets).sort() }
7391
7405
  };
7392
7406
  }
7407
+ // src/runtime/environment-provider/provider-harness-transcript.ts
7408
+ /** Without a trusted port, read the environment and bind it to the exact admitted dispatch. */
7409
+ async function readEnvironmentHarnessTranscript(scope, environment, sourceSignal) {
7410
+ const fallback = await captureHarnessTranscript(environment, scope.profile.harness, sourceSignal);
7411
+ const controlRef = scope.state.workspaceControlRef;
7412
+ if (fallback.status !== "captured" || !scope.node || controlRef?.environmentId !== environment.id) return fallback;
7413
+ return detachedSnapshot({
7414
+ ...fallback,
7415
+ artifact: {
7416
+ ...fallback.artifact,
7417
+ source: {
7418
+ executionId: scope.state.workspaceExecutionId,
7419
+ controlRef,
7420
+ node: scope.node,
7421
+ environmentId: environment.id,
7422
+ profileDigest: canonicalAgentProfileDigest(scope.createProfile),
7423
+ providerSessionId: controlRef.sessionId,
7424
+ nativeSessionId: null,
7425
+ coverageComplete: false
7426
+ }
7427
+ }
7428
+ }, "provider environment transcript source");
7429
+ }
7430
+ /** Select the existing reader or trusted host port; Scope alone persists its result. */
7431
+ async function readProviderHarnessTranscript(scope, environment, sourceSignal) {
7432
+ const capture = scope.options.harnessTranscript;
7433
+ if (!capture) return readEnvironmentHarnessTranscript(scope, environment, sourceSignal);
7434
+ const refused = (reason) => ({
7435
+ status: "unavailable",
7436
+ reason: "capture-failed",
7437
+ skipped: [{
7438
+ path: scope.executionId,
7439
+ reason
7440
+ }]
7441
+ });
7442
+ const handle = scope.state.retained;
7443
+ if (!handle) return refused("Native capture requires a retained provider execution");
7444
+ const control = AgentExactRunControlRefSchema.safeParse(handle.controlRef);
7445
+ const expected = scope.state.workspaceControlRef;
7446
+ const harness = agentHarness(scope.createProfile.harness);
7447
+ if (!control.success || !expected || !scope.node || !harness || control.data.provider !== scope.provider.name || environment.provider !== scope.provider.name || control.data.environmentId !== environment.id || control.data.sessionId !== scope.state.providerSessionId || canonicalCandidateDigest(control.data) !== canonicalCandidateDigest(expected)) return refused("Native capture requires the exact admitted provider, session, execution and Scope identity");
7448
+ const signal = AbortSignal.timeout(HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS);
7449
+ try {
7450
+ return await runAbortable(async () => {
7451
+ const terminal = await handle.status({ signal });
7452
+ if (![
7453
+ "completed",
7454
+ "failed",
7455
+ "cancelled"
7456
+ ].includes(terminal.status ?? "") || canonicalCandidateDigest(terminal.controlRef) !== canonicalCandidateDigest(control.data)) return refused("Native capture requires exact terminal provider proof");
7457
+ const cwd = workspaceCwdPathForBase(scope.options.defaults?.workspace?.cwd, "host", "provider native capture");
7458
+ if (!cwd) return refused("Native capture requires the admitted host working directory");
7459
+ const identity = detachedSnapshot({
7460
+ sessionId: control.data.sessionId,
7461
+ harness,
7462
+ profileDigest: canonicalAgentProfileDigest(scope.createProfile),
7463
+ cwd,
7464
+ node: scope.node,
7465
+ runs: [{
7466
+ runId: control.data.runId,
7467
+ requestDigest: control.data.requestDigest
7468
+ }],
7469
+ controlRef: control.data
7470
+ }, "provider native capture identity");
7471
+ const request = Object.freeze({
7472
+ ...identity,
7473
+ signal
7474
+ });
7475
+ const result = await capture(request);
7476
+ if (result.status === "unavailable") return result;
7477
+ const artifact = result.status === "captured" ? result.artifact : void 0;
7478
+ const binding = artifact?.binding;
7479
+ if (!artifact || artifact.harness !== harness || !binding || binding.kind !== "bridge" && binding.kind !== "provider" || binding.controlRef !== void 0 && !sameAgentRunControlRef(binding.controlRef, control.data) || binding.sessionId !== request.sessionId || binding.profileDigest !== request.profileDigest || canonicalCandidateDigest(binding.node ?? null) !== canonicalCandidateDigest(request.node) || canonicalCandidateDigest(binding.runs) !== canonicalCandidateDigest(request.runs)) return refused("Native capture returned a different or unsupported execution binding");
7480
+ return detachedSnapshot({
7481
+ ...result,
7482
+ artifact: {
7483
+ ...artifact,
7484
+ binding: {
7485
+ ...binding,
7486
+ kind: "provider",
7487
+ controlRef: control.data
7488
+ }
7489
+ }
7490
+ }, "provider native capture");
7491
+ }, signal, "Provider native capture stopped");
7492
+ } catch {
7493
+ return refused("Trusted provider native capture failed or exceeded its bound");
7494
+ }
7495
+ }
7496
+ /**
7497
+ * Retain failed capture as evidence debt until an exact repair has been persisted. Custody is owed
7498
+ * only when a later exact repair could succeed: without a retained provider run, Runtime refuses
7499
+ * before any native read and no repair can bind one, so the explicit failure is the whole record.
7500
+ */
7501
+ async function captureProviderHarnessTranscript(scope, environment, signal) {
7502
+ const repairable = scope.state.retained !== void 0;
7503
+ const capture = await readProviderHarnessTranscript(scope, environment, signal);
7504
+ if (scope.options.harnessTranscript) scope.state.transcriptPreservationRequired = repairable && (capture.status === "unavailable" || (capture.status === "captured" ? capture.coverageComplete !== true || capture.skippedCount > 0 || !!capture.missing?.length : !capture.descriptor.source.coverageComplete || capture.descriptor.skipped.length > 0 || capture.descriptor.missing.length > 0));
7505
+ return capture;
7506
+ }
7507
+ /** A repaired read repays evidence debt only after its exact invocation receipt is durable. */
7508
+ async function persistProviderHarnessTranscript(scope, task, result, retention = scope.retention) {
7509
+ scope.state.transcriptResult = result;
7510
+ try {
7511
+ await retention?.onHarnessTranscript?.(task, scope.state.harnessTranscript, result);
7512
+ if (retention?.onHarnessTranscript) {
7513
+ scope.state.transcriptPersistenceFailed = false;
7514
+ if (!scope.state.sourcePreservationRequired) scope.state.workspaceCleanupPromise = void 0;
7515
+ }
7516
+ } catch (error) {
7517
+ scope.state.transcriptPersistenceFailed = true;
7518
+ throw error;
7519
+ }
7520
+ }
7393
7521
  // src/runtime/environment-provider/provider-environment-teardown.ts
7394
7522
  /** The environment id the latest durable admission names, when creation got that far. */
7395
7523
  function admittedEnvironmentId(retention) {
@@ -7406,7 +7534,7 @@ async function destroyExecutorEnvironment(scope, cleanupSignal) {
7406
7534
  const cleanupPromise = attemptDestroy(scope, cleanupSignal);
7407
7535
  let cleanupReference;
7408
7536
  cleanupReference = cleanupPromise.then((result) => {
7409
- if (!result.destroyed && state.workspaceCleanupPromise === cleanupReference && !state.workspacePreservationRequired) state.workspaceCleanupPromise = void 0;
7537
+ if (!result.destroyed && state.workspaceCleanupPromise === cleanupReference && !state.sourcePreservationRequired) state.workspaceCleanupPromise = void 0;
7410
7538
  return result;
7411
7539
  });
7412
7540
  state.workspaceCleanupPromise = cleanupReference;
@@ -7421,6 +7549,11 @@ async function attemptDestroy(scope, cleanupSignal) {
7421
7549
  detail: "provider native stop was not confirmed; source environment preserved",
7422
7550
  permanent: true
7423
7551
  };
7552
+ if (state.sourcePreservationRequired) return {
7553
+ destroyed: false,
7554
+ detail: "provider native transcript retention is incomplete; source environment preserved",
7555
+ permanent: true
7556
+ };
7424
7557
  if (state.destroyed) return { destroyed: true };
7425
7558
  try {
7426
7559
  await awaitAbortable(Promise.resolve(target.destroy?.()), cleanupSignal);
@@ -7441,7 +7574,7 @@ async function attemptDestroy(scope, cleanupSignal) {
7441
7574
  async function releaseRetainedExecution(scope, signal) {
7442
7575
  const { state, provider, retention } = scope;
7443
7576
  scope.controller.abort();
7444
- if (!state.pending) return [];
7577
+ if (!state.pending && !state.transcriptPreservationRequired && !state.transcriptPersistenceFailed) return [];
7445
7578
  const environmentId = state.retained?.controlRef.environmentId ?? state.environment?.id ?? admittedEnvironmentId(retention);
7446
7579
  if (environmentId === void 0) return [];
7447
7580
  const receipt = (destroyed, detail, permanent) => ({
@@ -7455,7 +7588,7 @@ async function releaseRetainedExecution(scope, signal) {
7455
7588
  const releasePromise = releaseReceipts(scope, environmentId, signal, receipt);
7456
7589
  let releaseReference;
7457
7590
  releaseReference = releasePromise.then((receipts) => {
7458
- if (state.retainedReleasePromise === releaseReference && !receipts.every((entry) => entry.destroyed) && !state.workspacePreservationRequired) state.retainedReleasePromise = void 0;
7591
+ if (state.retainedReleasePromise === releaseReference && !receipts.every((entry) => entry.destroyed) && !state.sourcePreservationRequired) state.retainedReleasePromise = void 0;
7459
7592
  return receipts;
7460
7593
  });
7461
7594
  state.retainedReleasePromise = releaseReference;
@@ -7493,10 +7626,13 @@ async function releaseReceipts(scope, environmentId, signal, receipt) {
7493
7626
  */
7494
7627
  async function captureBeforeDestroy(scope, target, signal) {
7495
7628
  const { state } = scope;
7496
- if (state.harnessTranscript.status !== "captured" && !state.releaseReadTried) {
7629
+ if ((state.harnessTranscript.status === "unavailable" || state.transcriptPreservationRequired || state.transcriptPersistenceFailed) && !state.releaseReadTried) {
7497
7630
  state.releaseReadTried = true;
7498
- const capture = await captureHarnessTranscript(target, scope.profile.harness, signal);
7499
- if (capture.status === "captured") state.harnessTranscript = capture;
7631
+ const capture = await captureProviderHarnessTranscript(scope, target, signal);
7632
+ if (capture.status !== "unavailable") {
7633
+ state.harnessTranscript = capture;
7634
+ await persistProviderHarnessTranscript(scope, state.transcriptTask, state.transcriptResult);
7635
+ }
7500
7636
  }
7501
7637
  }
7502
7638
  // src/runtime/supervise/host-restart.ts
@@ -8473,14 +8609,25 @@ var ProviderTurnObserver = class {
8473
8609
  this.retained = retained;
8474
8610
  this.turnModel = turnModel;
8475
8611
  }
8476
- /** The platform's `effectiveBackend` (on `execution.started` and the terminal event) is the attempt's
8477
- * provider evidence; a model other than the declared one is an identity conflict (the leaf's rule). */
8612
+ /** The platform's `effectiveBackend` (on `execution.started` and the terminal event) is the
8613
+ * attempt's provider evidence; a model other than the declared one is an identity conflict
8614
+ * (the leaf's rule). Without one, a CLI Bridge provider's `provider_models` are judged by the
8615
+ * bridge path's rule. */
8478
8616
  recordServedModel(sandboxEvent) {
8479
- const served = sandboxEventServedBackend(sandboxEvent);
8480
- if (served?.model === void 0) return;
8617
+ const executor = this.args.scope.executor();
8481
8618
  const declared = this.turnModel ?? concreteProfileModel(this.args.profile);
8482
- if (declared !== void 0 && !sameModelId(served.model, declared, [served.provider])) recordRuntimeOwnedProviderIdentityConflict(this.args.scope.executor());
8483
- else recordRuntimeOwnedProviderModel(this.args.scope.executor(), served.model);
8619
+ const served = sandboxEventServedBackend(sandboxEvent);
8620
+ if (served?.model === void 0) {
8621
+ if (declared === void 0) return;
8622
+ for (const model of sandboxEventProviderModels(sandboxEvent)) {
8623
+ const verdict = reportedServedModel(model, declared);
8624
+ if (verdict === "conflict") recordRuntimeOwnedProviderIdentityConflict(executor);
8625
+ else if (verdict === "record") recordRuntimeOwnedProviderModel(executor, model);
8626
+ }
8627
+ return;
8628
+ }
8629
+ if (declared !== void 0 && !sameModelId(served.model, declared, [served.provider])) recordRuntimeOwnedProviderIdentityConflict(executor);
8630
+ else recordRuntimeOwnedProviderModel(executor, served.model);
8484
8631
  }
8485
8632
  async *consume(events) {
8486
8633
  const toolParts = createSandboxToolPartState();
@@ -8949,7 +9096,7 @@ var ProviderTurnSettlement = class {
8949
9096
  /** Read the provider transcript while its environment is still available. */
8950
9097
  async readLiveTranscript() {
8951
9098
  const { args } = this;
8952
- args.scope.state.harnessTranscript = await captureHarnessTranscript(this.environment, args.profile.harness, args.signal);
9099
+ args.scope.state.harnessTranscript = await captureProviderHarnessTranscript(args.scope, this.environment, args.signal);
8953
9100
  }
8954
9101
  /** Commit the consumed turn, validator verdict and measured spend. */
8955
9102
  async *settle() {
@@ -9008,19 +9155,26 @@ var ProviderTurnSettlement = class {
9008
9155
  ...nativeFailure.failure ? { failure: nativeFailure.failure } : {}
9009
9156
  };
9010
9157
  }
9011
- if (this.retained) await args.retention?.onResult(settled);
9158
+ if (this.retained) {
9159
+ await args.retention?.onResult(settled);
9160
+ args.scope.state.artifact = settled;
9161
+ await persistProviderHarnessTranscript(args.scope, args.task, settled, args.retention);
9162
+ }
9012
9163
  args.scope.state.pending = false;
9013
9164
  args.scope.state.artifact = settled;
9014
9165
  }
9015
9166
  /** Record the turn's failure, then capture what evidence its environment still holds. */
9016
9167
  async *fail(error) {
9017
- const { args } = this;
9018
9168
  yield* this.usage.settleTurn();
9019
9169
  this.failure = this.retained && !retainedSessionReplaced(error) ? new RetainedExecutionPendingError(error) : error;
9020
9170
  this.failed = true;
9021
9171
  await this.stopEndedHarness();
9022
- args.scope.state.settleTranscript();
9023
9172
  await this.readLiveTranscript();
9173
+ if (this.retained) try {
9174
+ await persistProviderHarnessTranscript(this.args.scope, this.args.task, this.settled, this.args.retention);
9175
+ } catch (error) {
9176
+ if (this.failure instanceof Error && this.failure.cause === void 0) this.failure.cause = error;
9177
+ }
9024
9178
  }
9025
9179
  /** Stop the harness when required, then settle its environment's custody. */
9026
9180
  async release() {
@@ -9416,7 +9570,10 @@ async function* runProviderExecution(scope, task, signal, recovering = false) {
9416
9570
  let refusalsInARow = 0;
9417
9571
  for (let attempt = 1;; attempt += 1) {
9418
9572
  const continued = attempt > 1;
9573
+ state.transcriptTask = invocation.task;
9574
+ state.transcriptResult = void 0;
9419
9575
  if (continued && state.environment !== void 0) {
9576
+ state.harnessTranscript = harnessTranscriptUnavailable("capture-did-not-run");
9420
9577
  state.resetWorkspace(state.environment, invocation.executionId);
9421
9578
  state.workspaceControlRef = void 0;
9422
9579
  state.providerSessionId = null;
@@ -9439,7 +9596,7 @@ async function pauseForContinuation(scope, invocation, ended, attempt, refusalsB
9439
9596
  const { state, options, provider } = scope;
9440
9597
  const refusal = ended.unavailable;
9441
9598
  const continueInvocation = invocation.retention?.continueInvocation;
9442
- if (refusal === void 0 || continueInvocation === void 0 || state.workspacePreservationRequired) return;
9599
+ if (refusal === void 0 || continueInvocation === void 0 || state.sourcePreservationRequired) return;
9443
9600
  const refusalsInARow = ended.madeProgress ? 1 : refusalsBefore + 1;
9444
9601
  const now = Date.now();
9445
9602
  const reset = unavailableResumeAt(reportedResetAt(refusal, now), now);
@@ -9496,6 +9653,18 @@ var ProviderExecutorState = class {
9496
9653
  retainedReleasePromise;
9497
9654
  releaseReadTried = false;
9498
9655
  workspacePreservationRequired = false;
9656
+ /** Configured native capture did not retain complete evidence; native stop cannot clear it. */
9657
+ transcriptPreservationRequired = false;
9658
+ /** A capture existed but its durable writer failed. A later read alone cannot repay this debt. */
9659
+ transcriptPersistenceFailed = false;
9660
+ /** Any open workspace or transcript custody debt keeps the source environment. */
9661
+ get sourcePreservationRequired() {
9662
+ return this.workspacePreservationRequired || this.transcriptPreservationRequired || this.transcriptPersistenceFailed;
9663
+ }
9664
+ /** Exact current invocation input for a capture recovered during retained release. */
9665
+ transcriptTask;
9666
+ /** This invocation's result, independent of the prior result kept across a continuation. */
9667
+ transcriptResult;
9499
9668
  workspaceRunActive = false;
9500
9669
  providerSessionId = null;
9501
9670
  workspaceControlRef;
@@ -9519,6 +9688,8 @@ var ProviderExecutorState = class {
9519
9688
  this.workspaceCleanupPromise = void 0;
9520
9689
  this.retainedReleasePromise = void 0;
9521
9690
  this.workspacePreservationRequired = false;
9691
+ this.transcriptPreservationRequired = false;
9692
+ this.transcriptPersistenceFailed = false;
9522
9693
  this.destroyed = false;
9523
9694
  }
9524
9695
  resetWorkspace(next, invocationId = this.workspaceExecutionId) {
@@ -9758,7 +9929,7 @@ function heldEnvironments(scope) {
9758
9929
  if (state.destroyed) return [];
9759
9930
  const environmentId = state.environment?.id ?? state.retained?.controlRef.environmentId ?? admittedEnvironmentId(scope.retention);
9760
9931
  if (environmentId === void 0) return [];
9761
- const preserved = state.workspacePreservationRequired;
9932
+ const preserved = state.sourcePreservationRequired;
9762
9933
  return [{
9763
9934
  provider: scope.provider.name,
9764
9935
  environmentId,
@@ -14165,7 +14336,9 @@ function snapshotExecutorConfig(config, mode = "execution") {
14165
14336
  }
14166
14337
  case "provider": {
14167
14338
  if (config.outputFormat !== void 0 && config.steering !== void 0) throw new ValidationError$1("createExecutor(provider): JSON output is not supported with steering");
14168
- const { provider, registry, profileForCreate, taskToTurn, validator, shared, ...decisionData } = config;
14339
+ if (config.harnessTranscript !== void 0 && config.steering !== void 0) throw new ValidationError$1("createExecutor(provider): native capture is not supported with steering");
14340
+ const { provider, registry, profileForCreate, taskToTurn, validator, harnessTranscript, shared, ...decisionData } = config;
14341
+ if (harnessTranscript !== void 0 && typeof harnessTranscript !== "function") throw new ValidationError$1("createExecutor provider: harnessTranscript must be a capture function");
14169
14342
  if (shared !== void 0 && (decisionData.steering !== void 0 || decisionData.placements !== void 0)) throw new ValidationError$1("createExecutor(provider): shared placement cannot combine with steering or placements");
14170
14343
  const snapshot = detachedSnapshot(decisionData, "createExecutor provider config");
14171
14344
  const resolvedProvider = mode === "control" && typeof provider === "string" ? registry?.get(provider) ?? provider : resolveAgentEnvironmentProvider(provider, registry);
@@ -14175,6 +14348,7 @@ function snapshotExecutorConfig(config, mode = "execution") {
14175
14348
  ...profileForCreate === void 0 ? {} : { profileForCreate },
14176
14349
  ...taskToTurn === void 0 ? {} : { taskToTurn },
14177
14350
  ...validator === void 0 ? {} : { validator },
14351
+ ...harnessTranscript === void 0 ? {} : { harnessTranscript },
14178
14352
  ...shared === void 0 ? {} : { shared }
14179
14353
  });
14180
14354
  }
@@ -15294,7 +15468,7 @@ function unconfirmedRecord(node) {
15294
15468
  }
15295
15469
  /**
15296
15470
  * Retry every unconfirmed teardown in the settled tree until each executor confirms destruction
15297
- * or `windowMs` passes, and return what is still unconfirmed.
15471
+ * or `windowMs` from `opensAt` passes, and return what is still unconfirmed.
15298
15472
  *
15299
15473
  * Settled children are evidence about an EXECUTOR, not a cause of run failure, so the barrier
15300
15474
  * never fails the run over them; it asks again and then NAMES what it could not confirm. Backoff
@@ -15305,15 +15479,15 @@ function unconfirmedRecord(node) {
15305
15479
  * failed is released again; otherwise it is kept for a resume and not retried. The window is wall
15306
15480
  * clock, like the timers that pace it, so an injected `now` cannot stall it.
15307
15481
  */
15308
- async function confirmSettledTeardowns(scope, windowMs, release) {
15309
- const closesAt = Date.now() + windowMs;
15482
+ async function confirmSettledTeardowns(scope, windowMs, release, opensAt) {
15483
+ const closesAt = opensAt + windowMs;
15310
15484
  const maxDelayMs = windowMs / 10;
15311
15485
  let delayMs = windowMs / 300;
15312
15486
  let releasing;
15313
15487
  let failure;
15314
15488
  while (failure === void 0 && hasRetriableTeardowns(scope, release)) {
15315
15489
  if (closesAt - Date.now() <= 0) break;
15316
- await pause(Math.min(delayMs, closesAt - Date.now()));
15490
+ await pausable(Math.min(delayMs, closesAt - Date.now())).elapsed;
15317
15491
  delayMs = Math.min(delayMs * 2, maxDelayMs);
15318
15492
  if (release && releasing === void 0) releasing = releaseRetainedEnvironments(scope).finally(() => {
15319
15493
  releasing = void 0;
@@ -15332,10 +15506,6 @@ async function confirmSettledTeardowns(scope, windowMs, release) {
15332
15506
  if (failure !== void 0) throw failure.error;
15333
15507
  return unconfirmedTeardowns(scope);
15334
15508
  }
15335
- /** A wall-clock wait that keeps the process alive until it ends. */
15336
- function pause(ms) {
15337
- return pausable(ms).elapsed;
15338
- }
15339
15509
  /** A wall-clock wait that can be cancelled, so a wait that lost a race holds no timer open. */
15340
15510
  function pausable(ms) {
15341
15511
  if (ms <= 0) return {
@@ -15756,11 +15926,12 @@ async function joinRunChildren(join, settleGraceMs) {
15756
15926
  await drainLiveChildren(scope, join.controller, settleGraceMs);
15757
15927
  await releaseHeldEnvironments(scope);
15758
15928
  join.teardownUnconfirmed = unconfirmedTeardowns(scope);
15759
- await settleManagerWork(scope);
15760
- join.teardownUnconfirmed = unconfirmedTeardowns(scope);
15761
- if (!persistence.failed && join.retainedAtSettlement === "release") join.teardownUnconfirmed = await releaseRetainedEnvironments(scope);
15762
15929
  const releasing = !persistence.failed && join.retainedAtSettlement === "release";
15763
- await confirmRetriableTeardowns(join, releasing);
15930
+ const clock = { windowMs: Math.max(join.opts.teardownConfirmMs ?? 0, RELEASE_DESTROY_MS) };
15931
+ if (releasing) boundRetainedReleases(scope, clock);
15932
+ await Promise.all([settleManagerWork(scope), releasing ? releaseRetainedEnvironments(scope) : void 0]);
15933
+ join.teardownUnconfirmed = unconfirmedTeardowns(scope);
15934
+ await confirmRetriableTeardowns(join, releasing, clock.startedAt ?? Date.now());
15764
15935
  join.teardownUnconfirmed = await unrecoveredRetainedChildren(join);
15765
15936
  for (const node of join.teardownUnconfirmed) await join.opts.journal.appendEvent(join.opts.runId, {
15766
15937
  kind: "teardown-unconfirmed",
@@ -15882,10 +16053,10 @@ async function unrecoveredRetainedChildren(join) {
15882
16053
  * settles over it leaves the sandbox running: cancelling 20 Discovery lanes
15883
16054
  * left 2 workers running. Ask again until confirmed or out of time.
15884
16055
  */
15885
- async function confirmRetriableTeardowns(join, releasing) {
16056
+ async function confirmRetriableTeardowns(join, releasing, opensAt) {
15886
16057
  const { opts, scope } = join;
15887
- const confirmWindowMs = opts.teardownConfirmMs ?? 3e5;
15888
- if (!(join.teardownUnconfirmed.length > 0 && confirmWindowMs > 0 && hasRetriableTeardowns(scope, releasing))) return;
16058
+ const confirmWindowMs = opts.teardownConfirmMs ?? 9e4;
16059
+ if (!(join.teardownUnconfirmed.length > 0 && opensAt + confirmWindowMs > Date.now() && hasRetriableTeardowns(scope, releasing))) return;
15889
16060
  const pending = join.teardownUnconfirmed;
15890
16061
  for (const node of pending) await opts.journal.appendEvent(opts.runId, {
15891
16062
  kind: "teardown-pending",
@@ -15893,7 +16064,7 @@ async function confirmRetriableTeardowns(join, releasing) {
15893
16064
  seq: join.teardownSeq++,
15894
16065
  at: new Date(join.now()).toISOString()
15895
16066
  });
15896
- join.teardownUnconfirmed = await confirmSettledTeardowns(scope, confirmWindowMs, releasing);
16067
+ join.teardownUnconfirmed = await confirmSettledTeardowns(scope, confirmWindowMs, releasing, opensAt);
15897
16068
  const still = new Set(join.teardownUnconfirmed.map((node) => node.id));
15898
16069
  for (const node of pending) {
15899
16070
  if (still.has(node.id)) continue;
@@ -16298,6 +16469,6 @@ async function noWinner(settled, rejection) {
16298
16469
  reason: "no-result-selected"
16299
16470
  };
16300
16471
  }
16301
- export { AUTHORITY_MARKERS as $, readSandboxOutcome as $t, readPromptOptions as A, createPushTraceSource as At, toolResultText as B, assertProfileMaterializes as Bt, captureReusableExecutorConfig as C, bridgeModelRouteRefusal as Ct, createSteerableSandboxSession as D, createCodexRolloutStoreReader as Dt, DEFAULT_SANDBOX_STEERING_MAX_TURNS as E, addHarnessUsage as Et, defaultSelectWinner as F, runWorktreeHarness as Ft, providerAsExecutor as G, promptControlProfileMaterialization as Gt, routerBrain as H, defineProfileMaterializationContract as Ht, codeModeArguments as I, LOCAL_HARNESSES as It, createWorktreeCliExecutor as J, sandboxActProfileMaterialization as Jt, LEAF_CONTINUATION_TASK as K, promptModelProfileMaterialization as Kt, codeModeModelOutput as L, harnessInvocation as Lt, createSandboxLineage as M, bridgeStopSignalKey as Mt, acquireSandbox as N, defaultRunCommand as Nt, runAgentRounds as O, harnessUsageIsEmpty as Ot, TERMINAL_DECISIONS as P, runSettledCommand as Pt, failPendingAfter as Q, projectSandboxOutcome as Qt, createCodeModeTools as R, terminateProcessTreeAndConfirm as Rt, bindReusableExecutorExecutionId as S, bridgeAdmissionRefusal as St, snapshotExecutorConfig as T, ROUTER_PRICE_SOURCE as Tt, createAgentEnvironmentProviderRegistry as U, fullProfileMaterialization as Ut, createRouterTranscript as V, controlProfileMaterialization as Vt, resolveAgentEnvironmentProvider as W, profileMaterializationAxes$1 as Wt, INBOX_RECEIPT_KEY as X, unsupportedProfileDimensions as Xt, createInPlaceCliExecutor as Y, sandboxProfileMaterialization as Yt, createInbox as Z, worktreeCliProfileMaterialization as Zt, isDriverSpec as _, CheckUnavailableError as _t, assertRunParking as a, peerMailTools as at, InMemorySpawnJournal as b, mapExecutorResult as bt, readRunParking as c, DriverAttemptsExhaustedError as ct, bestDelivered as d, classifyDriverFailure as dt, DEFAULT_PEER_MAIL_LIMITS as et, runFinalizer as f, summarizeDriverAttempts as ft, driverExecutorFactory as g, preflightPublicCoordination as gt, driverChild as h, upstreamUnavailableSignal as ht, RunParkedError as i, isPeerMailEnvelope as it, createSandboxForSpec as j, bridgeRuntimeAttachmentsKey as jt, assertBoxlessPromptOptions as k, readCodexRolloutSession as kt, sleepScopeWait as l, HarnessTurnFailedError as lt, createRootHandle as m, undispatchedCredentialExit as mt, createSupervisor as n, claimsAuthority as nt, bindScopeParkingDrain as o, peerMailVerbNames as ot, runTree as p, transientFailureKind as pt, providerAsSandboxClient as q, renderUnsupported as qt, assertResumeLimits as r, createPeerMailbox as rt, isRunParked as s, taskToPrompt$1 as st, DEFAULT_MAX_DEPTH as t, PEER_MAIL_WIRE_KEY as tt, withRunParking as u, abandonablePending as ut, withDriverExecutor as v, gateFactoryOnDeliverable as vt, createExecutor as w, priceTokens as wt, createExecutorRegistry as x, verdictFromJudgeScore as xt, InMemoryResultBlobStore as y, gateOnDeliverable as yt, runCodeMode as z, assertProfileMaterialization as zt };
16472
+ export { AUTHORITY_MARKERS as $, projectSandboxOutcome as $t, readPromptOptions as A, createPushTraceSource as At, toolResultText as B, assertProfileMaterialization as Bt, captureReusableExecutorConfig as C, bridgeModelRouteRefusal as Ct, createSteerableSandboxSession as D, createCodexRolloutStoreReader as Dt, DEFAULT_SANDBOX_STEERING_MAX_TURNS as E, addHarnessUsage as Et, defaultSelectWinner as F, runSettledCommand as Ft, providerAsExecutor as G, profileMaterializationAxes$1 as Gt, routerBrain as H, controlProfileMaterialization as Ht, codeModeArguments as I, runWorktreeHarness as It, createWorktreeCliExecutor as J, renderUnsupported as Jt, LEAF_CONTINUATION_TASK as K, promptControlProfileMaterialization as Kt, codeModeModelOutput as L, LOCAL_HARNESSES as Lt, createSandboxLineage as M, bridgeRuntimeEnvKey as Mt, acquireSandbox as N, bridgeStopSignalKey as Nt, runAgentRounds as O, harnessUsageIsEmpty as Ot, TERMINAL_DECISIONS as P, defaultRunCommand as Pt, failPendingAfter as Q, worktreeCliProfileMaterialization as Qt, createCodeModeTools as R, harnessInvocation as Rt, bindReusableExecutorExecutionId as S, bridgeAdmissionRefusal as St, snapshotExecutorConfig as T, ROUTER_PRICE_SOURCE as Tt, createAgentEnvironmentProviderRegistry as U, defineProfileMaterializationContract as Ut, createRouterTranscript as V, assertProfileMaterializes as Vt, resolveAgentEnvironmentProvider as W, fullProfileMaterialization as Wt, INBOX_RECEIPT_KEY as X, sandboxProfileMaterialization as Xt, createInPlaceCliExecutor as Y, sandboxActProfileMaterialization as Yt, createInbox as Z, unsupportedProfileDimensions as Zt, isDriverSpec as _, CheckUnavailableError as _t, assertRunParking as a, peerMailTools as at, InMemorySpawnJournal as b, mapExecutorResult as bt, readRunParking as c, DriverAttemptsExhaustedError as ct, bestDelivered as d, classifyDriverFailure as dt, readSandboxOutcome as en, DEFAULT_PEER_MAIL_LIMITS as et, runFinalizer as f, summarizeDriverAttempts as ft, driverExecutorFactory as g, preflightPublicCoordination as gt, driverChild as h, upstreamUnavailableSignal as ht, RunParkedError as i, isPeerMailEnvelope as it, createSandboxForSpec as j, bridgeRuntimeAttachmentsKey as jt, assertBoxlessPromptOptions as k, readCodexRolloutSession as kt, sleepScopeWait as l, HarnessTurnFailedError as lt, createRootHandle as m, undispatchedCredentialExit as mt, createSupervisor as n, claimsAuthority as nt, bindScopeParkingDrain as o, peerMailVerbNames as ot, runTree as p, transientFailureKind as pt, providerAsSandboxClient as q, promptModelProfileMaterialization as qt, assertResumeLimits as r, createPeerMailbox as rt, isRunParked as s, taskToPrompt$1 as st, DEFAULT_MAX_DEPTH as t, PEER_MAIL_WIRE_KEY as tt, withRunParking as u, abandonablePending as ut, withDriverExecutor as v, gateFactoryOnDeliverable as vt, createExecutor as w, priceTokens as wt, createExecutorRegistry as x, verdictFromJudgeScore as xt, InMemoryResultBlobStore as y, gateOnDeliverable as yt, runCodeMode as z, terminateProcessTreeAndConfirm as zt };
16302
16473
 
16303
- //# sourceMappingURL=supervisor-C3Fv97vT.js.map
16474
+ //# sourceMappingURL=supervisor-DwdeUC2l.js.map