@tangle-network/agent-runtime 10.0.0 → 10.0.1

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 (73) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/{activation-CEGkyzEG.js → activation-C_BenzIu.js} +2 -2
  3. package/dist/{activation-CEGkyzEG.js.map → activation-C_BenzIu.js.map} +1 -1
  4. package/dist/{activation-CDlOqX5a.d.ts → activation-s6dGGify.d.ts} +2 -2
  5. package/dist/agent.d.ts +1 -1
  6. package/dist/agent.js +3 -3
  7. package/dist/{delegate-V2Nz8GgO.js → delegate-BOren4c7.js} +2 -2
  8. package/dist/{delegate-V2Nz8GgO.js.map → delegate-BOren4c7.js.map} +1 -1
  9. package/dist/{driver-control-acknowledgers-CJDYLJmW.js → driver-control-acknowledgers-ByKwAgCI.js} +25 -5
  10. package/dist/driver-control-acknowledgers-ByKwAgCI.js.map +1 -0
  11. package/dist/durable.d.ts +1 -1
  12. package/dist/durable.js +9 -9
  13. package/dist/{failure-cause-BI7cfDWx.js → failure-cause-DoCCGLDH.js} +30 -18
  14. package/dist/{failure-cause-BI7cfDWx.js.map → failure-cause-DoCCGLDH.js.map} +1 -1
  15. package/dist/{graph-wJOMQ1kC.js → graph-BXONYT1o.js} +6 -6
  16. package/dist/{graph-wJOMQ1kC.js.map → graph-BXONYT1o.js.map} +1 -1
  17. package/dist/{improve-DOjywiPq.js → improve-CS2GIF5O.js} +5 -5
  18. package/dist/{improve-DOjywiPq.js.map → improve-CS2GIF5O.js.map} +1 -1
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +10 -10
  21. package/dist/intelligence.d.ts +2 -2
  22. package/dist/intelligence.js +4 -4
  23. package/dist/kernel.d.ts +2 -2
  24. package/dist/kernel.js +13 -13
  25. package/dist/{loop-runner-DwxZbYW5.d.ts → loop-runner-C0B3PexH.d.ts} +2 -2
  26. package/dist/loop-runner-bin.d.ts +1 -1
  27. package/dist/loop-runner-bin.js +1 -1
  28. package/dist/{loop-runner-CPTOzSol.js → loop-runner-ftyZP4st.js} +2 -2
  29. package/dist/{loop-runner-CPTOzSol.js.map → loop-runner-ftyZP4st.js.map} +1 -1
  30. package/dist/mcp/bin.js +3 -3
  31. package/dist/mcp/index.d.ts +1 -1
  32. package/dist/mcp/index.js +6 -6
  33. package/dist/mcp/memory-bin.js +1 -1
  34. package/dist/profiles.d.ts +1 -1
  35. package/dist/{provision-supervisor-B1_Kow9m.js → provision-supervisor-CauovUHn.js} +5 -5
  36. package/dist/{provision-supervisor-B1_Kow9m.js.map → provision-supervisor-CauovUHn.js.map} +1 -1
  37. package/dist/{run-cancellation-D5m6JHPH.js → run-cancellation-NMNVuYiO.js} +2 -2
  38. package/dist/{run-cancellation-D5m6JHPH.js.map → run-cancellation-NMNVuYiO.js.map} +1 -1
  39. package/dist/{run-state-DKOXe08H.js → run-state-COyIVOVb.js} +5 -5
  40. package/dist/{run-state-DKOXe08H.js.map → run-state-COyIVOVb.js.map} +1 -1
  41. package/dist/{runtime-C5cWSMqU.js → runtime-DYaRDLKn.js} +13 -13
  42. package/dist/{runtime-C5cWSMqU.js.map → runtime-DYaRDLKn.js.map} +1 -1
  43. package/dist/{search-executor-CA6fTYWz.js → search-executor-Drd_N9YO.js} +4 -4
  44. package/dist/{search-executor-CA6fTYWz.js.map → search-executor-Drd_N9YO.js.map} +1 -1
  45. package/dist/{server-C8Z3vYdI.js → server-Dk9B1WFf.js} +4 -4
  46. package/dist/{server-C8Z3vYdI.js.map → server-Dk9B1WFf.js.map} +1 -1
  47. package/dist/{settle-record-BDxPAO4m.js → settle-record-YdkkHzqw.js} +2 -2
  48. package/dist/{settle-record-BDxPAO4m.js.map → settle-record-YdkkHzqw.js.map} +1 -1
  49. package/dist/{structural-rollout-B0HPcP9G.js → structural-rollout-DbZAkHTq.js} +4 -4
  50. package/dist/{structural-rollout-B0HPcP9G.js.map → structural-rollout-DbZAkHTq.js.map} +1 -1
  51. package/dist/{supervise-Dvj-8S6D.js → supervise-B5hb0my3.js} +46 -14
  52. package/dist/supervise-B5hb0my3.js.map +1 -0
  53. package/dist/{supervision-discovery-CbrwcgJy.js → supervision-discovery-ChkTxilL.js} +3 -3
  54. package/dist/{supervision-discovery-CbrwcgJy.js.map → supervision-discovery-ChkTxilL.js.map} +1 -1
  55. package/dist/{supervisor-DwdeUC2l.js → supervisor-DpwcTrTh.js} +229 -38
  56. package/dist/supervisor-DpwcTrTh.js.map +1 -0
  57. package/dist/{supervisor-accounting-C48Yo9QC.js → supervisor-accounting-QiXnF-EW.js} +42 -11
  58. package/dist/supervisor-accounting-QiXnF-EW.js.map +1 -0
  59. package/dist/testing.d.ts +1 -1
  60. package/dist/testing.js +11 -11
  61. package/dist/{tool-server-DsCeBr-C.js → tool-server-DQCdu3am.js} +2 -2
  62. package/dist/{tool-server-DsCeBr-C.js.map → tool-server-DQCdu3am.js.map} +1 -1
  63. package/dist/{top-web-CTOq4psb.js → top-web-E85Fk8pH.js} +6 -6
  64. package/dist/{top-web-CTOq4psb.js.map → top-web-E85Fk8pH.js.map} +1 -1
  65. package/dist/tui/bin.js +3 -3
  66. package/dist/tui/index.d.ts +1 -1
  67. package/dist/tui/index.js +2 -2
  68. package/dist/{types-lnF0wIJW.d.ts → types-dv295cpm.d.ts} +5728 -5697
  69. package/package.json +5 -5
  70. package/dist/driver-control-acknowledgers-CJDYLJmW.js.map +0 -1
  71. package/dist/supervise-Dvj-8S6D.js.map +0 -1
  72. package/dist/supervisor-DwdeUC2l.js.map +0 -1
  73. package/dist/supervisor-accounting-C48Yo9QC.js.map +0 -1
@@ -1,19 +1,19 @@
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";
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-QiXnF-EW.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, 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
- 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";
7
+ import { B as turnFailurePolicy, Ct as sandboxEventServedBackend, D as unavailableResumeAt, Dt as parseCodexUsageRecord, E as unavailablePauseMs, F as executorFailureInfra, H as hashJson, M as contentAddress, N as contentRef, O as unavailableSignalOfFailure, Ot as recordValue, R as runtimeFailureRemediationSchema, S as cappedDoublingMs, St as sandboxEventProviderModels, T as reportedResetAt, U as credentialCommandExit, V as turnRemediationOf, W as isCredentialRefusal, X as createBudgetPool, _ as retainedExecutorContext, _t as createSandboxUsageLedger, b as UNAVAILABLE_CODES, bt as notifySandboxEventObserver, c as DISPATCH_NOT_ADMITTED_CODE, ct as sandboxOutputMarker, f as isProvisioningRefusal, ft as extractTransportEventIdentity, gt as createSandboxTurnEventCollector, ht as canonicalSandboxUsageMode, i as runtimeProviderCode, it as createSandboxToolPartState, l as RetainedExecutionPendingError, lt as sandboxProgressEvents, mt as assertSandboxServedModel, n as runtimeFailureCause, p as isSchemaRejection, s as DISPATCH_EXECUTION_CHANGED_CODE, st as sandboxLeafOutputFromEvents, t as reportedFailureCause, u as TRANSPORT_ERROR_CODES, v as retainedExecutorSeamKey, w as printedStatus, wt as sandboxTerminalUsageField, x as UNAVAILABLE_STATUSES, xt as sameModelId, yt as isSandboxTerminalEvent, z as turnFailureOf } from "./failure-cause-DoCCGLDH.js";
8
+ import { a as errMessage, i as causeChain, l as errorText, n as detachedSnapshot, o as errorHttpStatus, s as errorProperty, t as detachedFrozen, u as defaultRedactor } from "./snapshot-BKI_w3JD.js";
9
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
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-DsCeBr-C.js";
14
+ import { t as PROTOCOL_VERSION } from "./tool-server-DQCdu3am.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, sameAgentRunControlRef, sha256DigestSchema, workspaceCwdPathForBase } from "@tangle-network/agent-interface";
16
+ import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentExactRunControlRefSchema, AgentFileOutputPolicySchema, AgentRetainedFilePublicationSchema, 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";
@@ -57,7 +57,8 @@ function projectSandboxOutcome(outcome) {
57
57
  failure: reportedFailureCause({
58
58
  error: reason,
59
59
  errorCode: outcome.errorCode,
60
- statusCode: outcome.statusCode
60
+ statusCode: outcome.statusCode,
61
+ remediation: turnRemediationOf(outcome)
61
62
  })
62
63
  };
63
64
  return {
@@ -5125,6 +5126,8 @@ var HarnessTurnFailedError = class extends Error {
5125
5126
  /** The shared HTTP error reader also uses this status for persisted diagnostics. */
5126
5127
  status;
5127
5128
  failure;
5129
+ /** The producer's quota reset, which `reportedResetAt` holds a capacity pause to. */
5130
+ resetAt;
5128
5131
  constructor(runtime, failure) {
5129
5132
  super(`${runtime} harness turn ended with a failed outcome` + (failure.errorCode === void 0 ? "" : ` (${failure.errorCode})`) + `: ${failure.error}`);
5130
5133
  this.name = "HarnessTurnFailedError";
@@ -5132,6 +5135,7 @@ var HarnessTurnFailedError = class extends Error {
5132
5135
  this.reported = failure.error;
5133
5136
  if (failure.failure !== void 0) this.failure = failure.failure;
5134
5137
  if (failure.errorCode !== void 0) this.errorCode = failure.errorCode;
5138
+ if (failure.resetAt !== void 0) this.resetAt = failure.resetAt;
5135
5139
  if (failure.statusCode !== void 0) {
5136
5140
  this.statusCode = failure.statusCode;
5137
5141
  this.status = failure.statusCode;
@@ -7544,9 +7548,10 @@ async function attemptDestroy(scope, cleanupSignal) {
7544
7548
  const { state, provider } = scope;
7545
7549
  const target = state.environment;
7546
7550
  if (target === void 0) return { destroyed: true };
7547
- if (state.workspacePreservationRequired) return {
7551
+ await state.fileOutput?.settled();
7552
+ if (state.sourcePreservationRequired) return {
7548
7553
  destroyed: false,
7549
- detail: "provider native stop was not confirmed; source environment preserved",
7554
+ detail: "provider source custody is unresolved; environment preserved",
7550
7555
  permanent: true
7551
7556
  };
7552
7557
  if (state.sourcePreservationRequired) return {
@@ -7737,6 +7742,7 @@ function providerFailureEvent(event, sandboxEvent) {
7737
7742
  const errorCode = failureCode(sandboxEvent.data) ?? failureCode(outcome) ?? failureCode(result);
7738
7743
  const statusCode = failureStatusCode(sandboxEvent.data) ?? failureStatusCode(outcome) ?? failureStatusCode(result);
7739
7744
  const failure = turnFailureOf(sandboxEvent.data) ?? turnFailureOf(outcome) ?? turnFailureOf(result);
7745
+ const remediation = turnRemediationOf(sandboxEvent.data) ?? turnRemediationOf(outcome) ?? turnRemediationOf(result);
7740
7746
  return {
7741
7747
  type: "result",
7742
7748
  data: {
@@ -7744,7 +7750,8 @@ function providerFailureEvent(event, sandboxEvent) {
7744
7750
  ...detail ? { error: detail } : {},
7745
7751
  ...errorCode ? { errorCode } : {},
7746
7752
  ...statusCode === void 0 ? {} : { statusCode },
7747
- ...failure === void 0 ? {} : { failure }
7753
+ ...failure === void 0 ? {} : { failure },
7754
+ ...remediation === void 0 ? {} : { remediation }
7748
7755
  }
7749
7756
  };
7750
7757
  }
@@ -7800,9 +7807,11 @@ function createProviderFailureLedger() {
7800
7807
  for (const frame of failures) tracker.observe(frame);
7801
7808
  const outcome = tracker.finish();
7802
7809
  const failure = turnFailureOf(outcome) ?? failures.slice().reverse().map((frame) => turnFailureOf(frame.data)).find((value) => value !== void 0);
7810
+ const remediation = failures.slice().reverse().map((frame) => turnRemediationOf(frame.data)).find((value) => value !== void 0);
7803
7811
  return outcome === void 0 ? void 0 : {
7804
7812
  ...outcome,
7805
- failure
7813
+ failure,
7814
+ ...remediation === void 0 ? {} : { remediation }
7806
7815
  };
7807
7816
  }
7808
7817
  };
@@ -7816,6 +7825,20 @@ function failureDetail(value) {
7816
7825
  return typeof value?.detail === "string" ? value.detail : void 0;
7817
7826
  }
7818
7827
  /** Preserve the Sandbox outcome's numeric HTTP metadata across the provider adapter. */
7828
+ /** The executor envelope of a failed turn: the ledger's outcome as Runtime's retry reads it, quota reset included. */
7829
+ function failedTurnOutcome(outcome) {
7830
+ if (outcome?.status !== "failed") return void 0;
7831
+ const statusCode = failureStatusCode(outcome);
7832
+ return {
7833
+ success: false,
7834
+ ...outcome.failure === void 0 ? {} : { failure: outcome.failure },
7835
+ ...outcome.error ? { error: outcome.error } : {},
7836
+ ...outcome.errorCode ? { errorCode: outcome.errorCode } : {},
7837
+ ...statusCode === void 0 ? {} : { statusCode },
7838
+ ...outcome.remediation === void 0 ? {} : { remediation: outcome.remediation },
7839
+ ...outcome.resetAt ? { resetAt: outcome.resetAt } : {}
7840
+ };
7841
+ }
7819
7842
  function failureStatusCode(value) {
7820
7843
  const statusCode = recordValue(value)?.statusCode;
7821
7844
  return typeof statusCode === "number" && Number.isInteger(statusCode) && statusCode >= 400 && statusCode <= 599 ? statusCode : void 0;
@@ -8041,6 +8064,7 @@ var RetainedObservation = class {
8041
8064
  silenceHandledAt;
8042
8065
  exactResult;
8043
8066
  exactResultSettled = false;
8067
+ exactResultSettledAt = 0;
8044
8068
  observedFrames = 0;
8045
8069
  framesAfterResult = 0;
8046
8070
  exactWakers = /* @__PURE__ */ new Set();
@@ -8157,7 +8181,10 @@ var RetainedObservation = class {
8157
8181
  if (this.observedFrames === 0) this.lastObservedAt = Date.now();
8158
8182
  const retry = !retried && failed.length > 0 && !exactQuotaRefusal(failed[0]);
8159
8183
  if (retry) this.exactResult = void 0;
8160
- else this.exactResultSettled = true;
8184
+ else {
8185
+ this.exactResultSettled = true;
8186
+ this.exactResultSettledAt = Date.now();
8187
+ }
8161
8188
  for (const wake of [...this.exactWakers]) wake();
8162
8189
  if (retry) this.readExactResult(true);
8163
8190
  };
@@ -8185,7 +8212,7 @@ var RetainedObservation = class {
8185
8212
  wake = setImmediate(() => {
8186
8213
  const close = () => {
8187
8214
  if (!this.exactResultSettled) return;
8188
- const flowing = this.sawTerminal ? 0 : RETAINED_TAIL_FLOW_MS - (Date.now() - this.lastObservedAt);
8215
+ const flowing = this.sawTerminal ? 0 : RETAINED_TAIL_FLOW_MS - (Date.now() - Math.max(this.lastObservedAt, this.exactResultSettledAt));
8189
8216
  if (flowing <= 0) {
8190
8217
  wake = setImmediate(() => resolve({ kind: "exact-result" }));
8191
8218
  return;
@@ -8437,6 +8464,7 @@ function retainedDispatchMaterial(args, retention, selectedTurn, signal) {
8437
8464
  };
8438
8465
  return {
8439
8466
  material: {
8467
+ ...args.options.outputFile === void 0 ? {} : { outputFile: args.options.outputFile },
8440
8468
  environment: {
8441
8469
  ...args.options.defaults,
8442
8470
  ...restore === void 0 ? {} : { workspace: {
@@ -8573,10 +8601,11 @@ async function retainedExecution(args, retention, turn, selectedTurn, signal) {
8573
8601
  }
8574
8602
  }
8575
8603
  async function providerExecutionSource(args, turn, signal) {
8576
- const selectedTurn = subscriptionTurnProfile(turn, args.profile);
8604
+ const selectedTurn = subscriptionTurnProfile(turn, args.options.outputFile !== void 0 ? args.createProfile : args.profile);
8577
8605
  AgentTurnInputSchema.parse(selectedTurn);
8578
8606
  const needsMcp = hasRuntimeMcpAttachments(args.options.defaults);
8579
8607
  const capabilities = args.retention || needsMcp ? await args.provider.capabilities() : void 0;
8608
+ if (args.options.outputFile !== void 0 && (capabilities?.retainedControl === void 0 || capabilities.workspace.retainFileOutput !== true)) throw new Error("file output requires a provider with exact retained-file publication support");
8580
8609
  assertRuntimeMcpAttachments(args.provider.name, args.options.defaults, capabilities);
8581
8610
  if (args.retention !== void 0 && capabilities?.retainedControl !== void 0) return retainedExecution(args, args.retention, turn, selectedTurn, signal);
8582
8611
  if (args.recovering) throw new Error(`provider ${args.provider.name} cannot recover retained executions`);
@@ -8591,6 +8620,83 @@ async function providerExecutionSource(args, turn, signal) {
8591
8620
  retained: false
8592
8621
  };
8593
8622
  }
8623
+ // src/runtime/environment-provider/provider-file-output.ts
8624
+ /** One invocation's first file transaction. Nothing consults a later node admission or retries
8625
+ * a lost stop acknowledgment. The existing evidence and result writers own its persistence. */
8626
+ var ProviderFileOutput = class {
8627
+ args;
8628
+ pending;
8629
+ output;
8630
+ committed = false;
8631
+ constructor(args) {
8632
+ this.args = args;
8633
+ }
8634
+ get accepted() {
8635
+ return this.output;
8636
+ }
8637
+ get requiresPreservation() {
8638
+ return this.pending !== void 0 && !this.committed;
8639
+ }
8640
+ resultCommitted() {
8641
+ if (this.output) {
8642
+ this.committed = true;
8643
+ this.args.scope.state.fileOutputRequired = false;
8644
+ }
8645
+ }
8646
+ async settled() {
8647
+ await this.pending?.catch(() => void 0);
8648
+ }
8649
+ withSubmission(candidate, accept) {
8650
+ if (this.pending) return Promise.reject(new CheckUnavailableError("file output already reserved by the original submission"));
8651
+ const { args } = this;
8652
+ const handle = args.scope.state.retained;
8653
+ const environment = args.scope.state.environment;
8654
+ const submission = detachedFrozen(candidate);
8655
+ const policy = args.options.outputFile;
8656
+ const work = async () => {
8657
+ if (!handle || !environment || !args.node || !policy || !handle.retainFileOutput || !args.retention?.onEvidence) throw new CheckUnavailableError("file output has no exact retained source or durable evidence writer");
8658
+ const controlRef = detachedFrozen(handle.controlRef);
8659
+ await args.retention.onEvidence({
8660
+ kind: "retained-file-output-pending",
8661
+ invocationId: args.executionId,
8662
+ node: args.node,
8663
+ controlRef,
8664
+ policy,
8665
+ submissionRef: contentAddress(submission),
8666
+ submission
8667
+ });
8668
+ const receipt = await handle.retainFileOutput({
8669
+ controlRef,
8670
+ policy
8671
+ }, { signal: args.signal });
8672
+ if (receipt.status !== "published") throw new CheckUnavailableError(`file output unavailable: ${receipt.reason}`);
8673
+ const publication = AgentRetainedFilePublicationSchema.parse(receipt.publication);
8674
+ if (!sameControlCoordinates(publication.controlRef, controlRef) || !sameControlCoordinates(handle.controlRef, controlRef) || args.scope.state.retained !== handle || args.scope.state.environment !== environment || canonicalCandidateDigest(publication.policy) !== canonicalCandidateDigest(policy)) throw new CheckUnavailableError("file publication does not belong to the original invocation and policy");
8675
+ const output = detachedFrozen({
8676
+ kind: "retained-file-output",
8677
+ version: 1,
8678
+ invocationId: args.executionId,
8679
+ node: args.node,
8680
+ submissionRef: contentAddress(submission),
8681
+ submission,
8682
+ policyDigest: canonicalCandidateDigest(policy),
8683
+ publication
8684
+ });
8685
+ await args.retention.onEvidence(output);
8686
+ args.scope.state.harnessStopped = true;
8687
+ return accept(output, () => {
8688
+ this.output = output;
8689
+ });
8690
+ };
8691
+ this.pending = work().catch((error) => {
8692
+ if (error instanceof CheckUnavailableError) throw error;
8693
+ throw new CheckUnavailableError("the original file transaction could not be verified or committed");
8694
+ });
8695
+ const custody = this.pending.then(() => void 0, () => void 0);
8696
+ args.retention?.onEndOfTurnWork?.(custody);
8697
+ return this.pending;
8698
+ }
8699
+ };
8594
8700
  // src/runtime/environment-provider/provider-turn-observer.ts
8595
8701
  /** Reads one turn's provider events into archive, text, failures, trace steps, progress and usage. */
8596
8702
  var ProviderTurnObserver = class {
@@ -9063,6 +9169,7 @@ var ProviderTurnSettlement = class {
9063
9169
  /** The artifact this turn settled with. Its presence separates "the work finished and the
9064
9170
  * resource would not release" from "the work never finished". */
9065
9171
  settled;
9172
+ commitStarted = false;
9066
9173
  /** The body's own failure, held so a throwing teardown `finally` cannot mask it. */
9067
9174
  failure;
9068
9175
  failed = false;
@@ -9101,6 +9208,8 @@ var ProviderTurnSettlement = class {
9101
9208
  /** Commit the consumed turn, validator verdict and measured spend. */
9102
9209
  async *settle() {
9103
9210
  const { args, usage } = this;
9211
+ const file = args.scope.state.fileOutput;
9212
+ await file?.settled();
9104
9213
  yield* usage.settleTurn();
9105
9214
  yield* usage.settleUnpricedWork();
9106
9215
  if ((args.options.requireTerminalEvent ?? true) && !this.observer.terminal) throw new ValidationError(`providerAsExecutor(${args.provider.name}): stream ended without a terminal result/done/status event`);
@@ -9124,16 +9233,10 @@ var ProviderTurnSettlement = class {
9124
9233
  });
9125
9234
  const settledResult = result;
9126
9235
  const jsonOutput = args.options.outputFormat === "json";
9127
- if (jsonOutput) await args.retention?.onEvidence?.(settledResult);
9128
- const output = jsonOutput && outcome?.status !== "failed" ? jsonResultFromEvents(result.events) : { out: settledResult };
9129
- const statusCode = failureStatusCode(outcome);
9130
- const nativeFailure = outcome?.status === "failed" ? {
9131
- success: false,
9132
- ...outcome.failure === void 0 ? {} : { failure: outcome.failure },
9133
- ...outcome.error ? { error: outcome.error } : {},
9134
- ...outcome.errorCode ? { errorCode: outcome.errorCode } : {},
9135
- ...statusCode === void 0 ? {} : { statusCode }
9136
- } : void 0;
9236
+ if (jsonOutput || file) await args.retention?.onEvidence?.(settledResult);
9237
+ if (file && !file.accepted) throw new CheckUnavailableError("file output has no independently accepted submission; candidate custody remains held");
9238
+ const output = file?.accepted ? { out: file.accepted } : jsonOutput && outcome?.status !== "failed" ? jsonResultFromEvents(result.events) : { out: settledResult };
9239
+ const nativeFailure = failedTurnOutcome(outcome);
9137
9240
  const settled = {
9138
9241
  ...jsonOutput ? { outputFormat: "json" } : {},
9139
9242
  ...nativeFailure ? { outcome: nativeFailure } : {},
@@ -9142,7 +9245,6 @@ var ProviderTurnSettlement = class {
9142
9245
  ...verdict ? { verdict } : {},
9143
9246
  spent: executionSpent
9144
9247
  };
9145
- this.settled = settled;
9146
9248
  if (args.mayContinue && this.retained && nativeFailure) {
9147
9249
  const transport = nativeFailure.failure === void 0 ? nativeFailure.errorCode : nativeFailure.failure.kind === "infra" ? nativeFailure.failure.code : void 0;
9148
9250
  const signal = unavailableSignalOfFailure({
@@ -9155,16 +9257,52 @@ var ProviderTurnSettlement = class {
9155
9257
  ...nativeFailure.failure ? { failure: nativeFailure.failure } : {}
9156
9258
  };
9157
9259
  }
9260
+ await this.commit(settled);
9261
+ }
9262
+ /** Commit the result durably once; its transcript persists after it. A persistence throw
9263
+ * reaches `fail`, which reports the committed turn as pending and keeps the source. */
9264
+ async commit(settled) {
9265
+ const { args } = this;
9266
+ this.commitStarted = true;
9158
9267
  if (this.retained) {
9159
9268
  await args.retention?.onResult(settled);
9160
9269
  args.scope.state.artifact = settled;
9161
- await persistProviderHarnessTranscript(args.scope, args.task, settled, args.retention);
9162
9270
  }
9271
+ args.scope.state.fileOutput?.resultCommitted();
9272
+ this.settled = settled;
9273
+ if (this.retained) await persistProviderHarnessTranscript(args.scope, args.task, settled, args.retention);
9163
9274
  args.scope.state.pending = false;
9164
9275
  args.scope.state.artifact = settled;
9165
9276
  }
9166
9277
  /** Record the turn's failure, then capture what evidence its environment still holds. */
9167
- async *fail(error) {
9278
+ async *fail(cause) {
9279
+ let error = cause;
9280
+ const { args } = this;
9281
+ const file = args.scope.state.fileOutput;
9282
+ await file?.settled();
9283
+ if (file?.accepted && !this.commitStarted) {
9284
+ yield* this.usage.settleTurn();
9285
+ await this.readLiveTranscript();
9286
+ const settled = {
9287
+ out: file.accepted,
9288
+ outRef: contentRef(`provider:${args.provider.name}`, file.accepted),
9289
+ outcome: {
9290
+ success: false,
9291
+ error: errorText(error)
9292
+ },
9293
+ spent: this.usage.spend(this.started)
9294
+ };
9295
+ await args.retention?.onEvidence?.({
9296
+ nativeFailure: errorText(error),
9297
+ invocationId: args.executionId
9298
+ });
9299
+ try {
9300
+ await this.commit(settled);
9301
+ return;
9302
+ } catch (persistence) {
9303
+ error = persistence;
9304
+ }
9305
+ }
9168
9306
  yield* this.usage.settleTurn();
9169
9307
  this.failure = this.retained && !retainedSessionReplaced(error) ? new RetainedExecutionPendingError(error) : error;
9170
9308
  this.failed = true;
@@ -9179,6 +9317,7 @@ var ProviderTurnSettlement = class {
9179
9317
  /** Stop the harness when required, then settle its environment's custody. */
9180
9318
  async release() {
9181
9319
  const { args } = this;
9320
+ await args.scope.state.fileOutput?.settled();
9182
9321
  await this.stopEndedHarness();
9183
9322
  const held = this.retained && this.settled !== void 0 && !this.failed && this.unavailable === void 0 && args.retention?.preserveEnvironment !== true && args.retention?.holdOnSettle?.(this.settled.spent) === true;
9184
9323
  if (held) args.scope.state.holdingForContinuation = true;
@@ -9433,6 +9572,7 @@ async function* streamProviderExecutor(args) {
9433
9572
  const source = await providerExecutionSource(args, turn, args.signal);
9434
9573
  const environment = source.environment;
9435
9574
  await args.onEnvironment(environment);
9575
+ args.scope.state.fileOutput = args.options.outputFile !== void 0 ? new ProviderFileOutput(args) : void 0;
9436
9576
  const usage = new ProviderUsageAccount(args, turn.model);
9437
9577
  const observer = new ProviderTurnObserver(args, usage, source.retained, turn.model);
9438
9578
  const settlement = new ProviderTurnSettlement(args, environment, source.retained, observer, usage, started);
@@ -9628,6 +9768,9 @@ async function pauseForContinuation(scope, invocation, ended, attempt, refusalsB
9628
9768
  var ProviderExecutorState = class {
9629
9769
  callerSignal;
9630
9770
  workspaceExecutionId;
9771
+ fileOutput;
9772
+ /** Reconstructed from the frozen file policy too: process loss cannot erase capture debt. */
9773
+ fileOutputRequired = false;
9631
9774
  environment;
9632
9775
  artifact;
9633
9776
  retained;
@@ -9657,9 +9800,9 @@ var ProviderExecutorState = class {
9657
9800
  transcriptPreservationRequired = false;
9658
9801
  /** A capture existed but its durable writer failed. A later read alone cannot repay this debt. */
9659
9802
  transcriptPersistenceFailed = false;
9660
- /** Any open workspace or transcript custody debt keeps the source environment. */
9803
+ /** Any open workspace, file-output or transcript custody debt keeps the source environment. */
9661
9804
  get sourcePreservationRequired() {
9662
- return this.workspacePreservationRequired || this.transcriptPreservationRequired || this.transcriptPersistenceFailed;
9805
+ return this.workspacePreservationRequired || this.fileOutputRequired || this.fileOutput?.requiresPreservation === true || this.transcriptPreservationRequired || this.transcriptPersistenceFailed;
9663
9806
  }
9664
9807
  /** Exact current invocation input for a capture recovered during retained release. */
9665
9808
  transcriptTask;
@@ -9700,12 +9843,13 @@ var ProviderExecutorState = class {
9700
9843
  }
9701
9844
  };
9702
9845
  // src/runtime/environment-provider/provider-materialization.ts
9703
- function providerMaterialization(provider, createProfile, node, executionId, retention, options, placement) {
9846
+ function providerMaterialization(provider, authoredProfile, createProfile, node, executionId, retention, options, placement) {
9704
9847
  const attemptId = node?.attemptId ?? newExecutionAttemptId(executionId);
9705
9848
  const providerModel = concreteProfileModel(createProfile);
9706
9849
  const tokenLimits = enforceTokenLimits(profileModelExecutionSettings(createProfile, `providerAsExecutor(${provider.name})`, "provider").tokenLimits, "provider", `providerAsExecutor(${provider.name})`);
9707
9850
  return {
9708
9851
  plannedDeclaration: {
9852
+ ...authoredProfile.outputFile === void 0 ? {} : { authoredProfile },
9709
9853
  effectiveProfile: createProfile,
9710
9854
  backend: provider.name,
9711
9855
  model: providerModel ? {
@@ -9726,6 +9870,7 @@ function providerMaterialization(provider, createProfile, node, executionId, ret
9726
9870
  destroyOnSettle: retention?.preserveEnvironment ? false : options.destroyOnSettle ?? true,
9727
9871
  requireTerminalEvent: options.requireTerminalEvent ?? true,
9728
9872
  ...options.outputFormat === void 0 ? {} : { outputFormat: options.outputFormat },
9873
+ ...options.outputFile === void 0 ? {} : { outputFile: options.outputFile },
9729
9874
  tokenLimits,
9730
9875
  ...placement ? { placement } : {}
9731
9876
  }
@@ -9756,7 +9901,7 @@ function createProviderNativeControl(provider, retention, managerStop, state) {
9756
9901
  const cancelRetainedOnManagerStop = (handle) => {
9757
9902
  if (managerStop === void 0) return;
9758
9903
  const cancel = () => {
9759
- if (state.retained !== handle || !state.workspaceRunActive) return;
9904
+ if (state.retained !== handle || !state.workspaceRunActive || state.harnessStopped) return;
9760
9905
  handle.cancel({
9761
9906
  operationId: `manager-stop:${randomUUID()}`,
9762
9907
  reason: String(managerStop.reason ?? "the manager stopped")
@@ -9798,6 +9943,7 @@ function createProviderNativeControl(provider, retention, managerStop, state) {
9798
9943
  * release records what it kept.
9799
9944
  */
9800
9945
  const withoutRunningHarness = (release) => async (signal) => {
9946
+ if (state.harnessStopped) return release(signal);
9801
9947
  const stop = await awaitAbortable(stopNativeExecution(), signal).catch(() => void 0);
9802
9948
  const stopped = stop === void 0 ? "native stop unconfirmed: no exact dispatch or cleanup interrupted" : describeRetainedNativeStops([stop]);
9803
9949
  const environmentId = (state.retained?.controlRef ?? admittedControlRef(retention))?.environmentId ?? admittedEnvironmentId(retention);
@@ -9831,14 +9977,33 @@ function admittedControlRef(retention) {
9831
9977
  const NATIVE_STOP_TIMEOUT_MS = 3e4;
9832
9978
  // src/runtime/environment-provider/provider-executor-lifecycle.ts
9833
9979
  function createProviderExecutor(provider, profile, ctx, options, placement) {
9980
+ options = {
9981
+ ...options,
9982
+ ...providerOutputOptions(profile, options)
9983
+ };
9834
9984
  const node = detachedSnapshot(ctx.node, "provider executor node");
9835
9985
  const retention = retainedExecutorContext(ctx);
9836
- if (options.outputFormat !== void 0 && (options.outputFormat !== "json" || retention?.onEvidence === void 0 || options.requireTerminalEvent === false)) throw new ValidationError("providerAsExecutor: JSON output requires Runtime-owned durable evidence and a native terminal receipt");
9986
+ if ((options.outputFormat !== void 0 || options.outputFile !== void 0) && (options.outputFormat !== void 0 && options.outputFormat !== "json" || retention?.onEvidence === void 0 || options.requireTerminalEvent === false)) throw new ValidationError("providerAsExecutor: structured output requires Runtime-owned durable evidence and a native terminal receipt");
9987
+ if (options.outputFormat !== void 0 && options.outputFile !== void 0) throw new ValidationError("providerAsExecutor: file output is selected by outputFile alone and excludes JSON output");
9988
+ if (options.outputFile !== void 0) {
9989
+ const policy = AgentFileOutputPolicySchema.parse(options.outputFile);
9990
+ options = {
9991
+ ...options,
9992
+ outputFile: policy,
9993
+ defaults: {
9994
+ ...options.defaults,
9995
+ retain: { paths: [.../* @__PURE__ */ new Set([...options.defaults?.retain?.paths ?? [], policy.path])] }
9996
+ }
9997
+ };
9998
+ if (!node || options.validator) throw new ValidationError("providerAsExecutor: file output requires a Runtime node and a completion check over retained bytes, not a live-box validator");
9999
+ }
9837
10000
  const managerStop = readOptionalAbortSignal(ctx, bridgeStopSignalKey, "provider");
9838
- const createProfile = options.profileForCreate?.(profile) ?? profile;
9839
- if (placement && canonicalAgentProfileDigest(createProfile) !== canonicalAgentProfileDigest(profile)) throw new ValidationError("provider placement: profileForCreate cannot change the selected profile");
10001
+ const { outputFile: _outputFile, ...nativeProfile } = profile;
10002
+ const createProfile = options.profileForCreate?.(nativeProfile) ?? nativeProfile;
10003
+ if (placement && canonicalAgentProfileDigest(createProfile) !== canonicalAgentProfileDigest(nativeProfile)) throw new ValidationError("provider placement: profileForCreate cannot change the selected profile");
9840
10004
  const executionId = retention?.executionId ?? node?.nodeId ?? `provider-run-${randomUUID()}`;
9841
10005
  const state = new ProviderExecutorState(ctx.signal, executionId);
10006
+ state.fileOutputRequired = options.outputFile !== void 0;
9842
10007
  state.pending = admittedEnvironmentId(retention) !== void 0;
9843
10008
  state.workspaceControlRef = admittedControlRef(retention);
9844
10009
  state.providerSessionId = state.workspaceControlRef?.sessionId ?? null;
@@ -9856,7 +10021,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
9856
10021
  controller: new AbortController(),
9857
10022
  nativeControl: createProviderNativeControl(provider, retention, managerStop, state),
9858
10023
  trace: createPushTraceSource({ runId: executionId }),
9859
- materialization: providerMaterialization(provider, createProfile, node, executionId, retention, options, placement),
10024
+ materialization: providerMaterialization(provider, profile, createProfile, node, executionId, retention, options, placement),
9860
10025
  continuationTask: LEAF_CONTINUATION_TASK,
9861
10026
  executor: () => executor
9862
10027
  };
@@ -9864,6 +10029,11 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
9864
10029
  const run = (task, signal, recovering = false) => runProviderExecution(scope, task, signal, recovering);
9865
10030
  executor = {
9866
10031
  runtime: options.runtime ?? provider.name,
10032
+ ...options.outputFile !== void 0 ? { withFileOutput: (submission, accept) => {
10033
+ const current = state.fileOutput;
10034
+ if (!current) return Promise.reject(new ValidationError("file output has no active retained invocation"));
10035
+ return current.withSubmission(submission, accept);
10036
+ } } : {},
9867
10037
  execute: run,
9868
10038
  recover: (task, signal) => run(task, signal, true),
9869
10039
  cancel: (request) => cancelExecution(scope, request),
@@ -9961,6 +10131,16 @@ function heldForContinuation(scope) {
9961
10131
  * infrastructure (discovery-lab AGENTS.md). */
9962
10132
  const LEAF_CONTINUATION_TASK = "Your previous turn was interrupted before it finished. This is the same task in the same session: your conversation so far and the files in your workspace are where you left them. Continue from where you stopped. Do not start over.";
9963
10133
  // src/runtime/environment-provider/provider-executor-admission.ts
10134
+ /** Resolve the authored per-profile output policy before a provider executor is constructed.
10135
+ * Backend-wide output remains the default for profiles that do not select a file. */
10136
+ function providerOutputOptions(profile, defaults) {
10137
+ if (profile.outputFile === void 0) return {};
10138
+ if (defaults.outputFile !== void 0 && canonicalCandidateDigest(defaults.outputFile) !== canonicalCandidateDigest(profile.outputFile)) throw new ValidationError("profile outputFile conflicts with the provider output policy");
10139
+ return {
10140
+ outputFormat: void 0,
10141
+ outputFile: detachedSnapshot(profile.outputFile, "profile outputFile")
10142
+ };
10143
+ }
9964
10144
  /** Adapt an environment provider into an `ExecutorFactory` for `createExecutor`.
9965
10145
  *
9966
10146
  * `createExecutor({ backend: 'provider', provider })` is the composition most callers want; it
@@ -9972,6 +10152,10 @@ const LEAF_CONTINUATION_TASK = "Your previous turn was interrupted before it fin
9972
10152
  *
9973
10153
  * @experimental */
9974
10154
  function providerAsExecutor(provider, options = {}) {
10155
+ if (options.outputFile !== void 0) options = {
10156
+ ...options,
10157
+ outputFile: detachedSnapshot(options.outputFile, "file output policy")
10158
+ };
9975
10159
  const captured = options.placements === void 0 ? options : {
9976
10160
  ...options,
9977
10161
  placements: detachedSnapshot(options.placements, "provider placements"),
@@ -14335,7 +14519,8 @@ function snapshotExecutorConfig(config, mode = "execution") {
14335
14519
  });
14336
14520
  }
14337
14521
  case "provider": {
14338
- if (config.outputFormat !== void 0 && config.steering !== void 0) throw new ValidationError$1("createExecutor(provider): JSON output is not supported with steering");
14522
+ if (config.outputFile !== void 0 && config.shared !== void 0) throw new ValidationError$1("createExecutor(provider): file output requires a dedicated retained environment");
14523
+ if ((config.outputFormat ?? config.outputFile) !== void 0 && config.steering !== void 0) throw new ValidationError$1("createExecutor(provider): JSON output is not supported with steering");
14339
14524
  if (config.harnessTranscript !== void 0 && config.steering !== void 0) throw new ValidationError$1("createExecutor(provider): native capture is not supported with steering");
14340
14525
  const { provider, registry, profileForCreate, taskToTurn, validator, harnessTranscript, shared, ...decisionData } = config;
14341
14526
  if (harnessTranscript !== void 0 && typeof harnessTranscript !== "function") throw new ValidationError$1("createExecutor provider: harnessTranscript must be a capture function");
@@ -14468,6 +14653,7 @@ function createExecutor(config) {
14468
14653
  const captured = snapshotExecutorConfig(config);
14469
14654
  return (rawSpec, ctx) => {
14470
14655
  const spec = executableAgentSpecSnapshot(rawSpec, `createExecutor(${captured.backend})`);
14656
+ if (spec.profile.outputFile !== void 0 && captured.backend !== "provider") throw new ValidationError$1("profile outputFile requires a retained provider backend");
14471
14657
  const { backend, ...seamData } = captured;
14472
14658
  const seam = Object.freeze(seamData);
14473
14659
  const seamed = {
@@ -14485,7 +14671,12 @@ function createExecutor(config) {
14485
14671
  case "cli-worktree": return cliWorktreeExecutor(spec, seamed);
14486
14672
  case "cli-in-place": return cliInPlaceExecutor(spec, seamed);
14487
14673
  case "provider": {
14488
- const originalSeam = readSeam(seamed, providerSeamKey, "provider");
14674
+ const declared = readSeam(seamed, providerSeamKey, "provider");
14675
+ const originalSeam = {
14676
+ ...declared,
14677
+ ...providerOutputOptions(spec.profile, declared)
14678
+ };
14679
+ if (originalSeam.outputFile !== void 0 && (originalSeam.steering !== void 0 || originalSeam.shared !== void 0)) throw new ValidationError$1("profile outputFile requires a dedicated retained provider without steering");
14489
14680
  const selected = originalSeam.steering ? selectProviderPlacement(spec.profile, originalSeam) : void 0;
14490
14681
  const providerSeam = selected?.options ?? originalSeam;
14491
14682
  const provider = resolveAgentEnvironmentProvider(providerSeam.provider, providerSeam.registry);
@@ -16469,6 +16660,6 @@ async function noWinner(settled, rejection) {
16469
16660
  reason: "no-result-selected"
16470
16661
  };
16471
16662
  }
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 };
16663
+ export { failPendingAfter as $, worktreeCliProfileMaterialization as $t, readPromptOptions as A, readCodexRolloutSession as At, toolResultText as B, terminateProcessTreeAndConfirm as Bt, captureReusableExecutorConfig as C, bridgeAdmissionRefusal as Ct, createSteerableSandboxSession as D, addHarnessUsage as Dt, DEFAULT_SANDBOX_STEERING_MAX_TURNS as E, ROUTER_PRICE_SOURCE as Et, defaultSelectWinner as F, defaultRunCommand as Ft, providerAsExecutor as G, fullProfileMaterialization as Gt, routerBrain as H, assertProfileMaterializes as Ht, codeModeArguments as I, runSettledCommand as It, providerAsSandboxClient as J, promptModelProfileMaterialization as Jt, providerOutputOptions as K, profileMaterializationAxes$1 as Kt, codeModeModelOutput as L, runWorktreeHarness as Lt, createSandboxLineage as M, bridgeRuntimeAttachmentsKey as Mt, acquireSandbox as N, bridgeRuntimeEnvKey as Nt, runAgentRounds as O, createCodexRolloutStoreReader as Ot, TERMINAL_DECISIONS as P, bridgeStopSignalKey as Pt, createInbox as Q, unsupportedProfileDimensions as Qt, createCodeModeTools as R, LOCAL_HARNESSES as Rt, bindReusableExecutorExecutionId as S, verdictFromJudgeScore as St, snapshotExecutorConfig as T, priceTokens as Tt, createAgentEnvironmentProviderRegistry as U, controlProfileMaterialization as Ut, createRouterTranscript as V, assertProfileMaterialization as Vt, resolveAgentEnvironmentProvider as W, defineProfileMaterializationContract as Wt, createInPlaceCliExecutor as X, sandboxActProfileMaterialization as Xt, createWorktreeCliExecutor as Y, renderUnsupported as Yt, INBOX_RECEIPT_KEY as Z, sandboxProfileMaterialization as Zt, isDriverSpec as _, preflightPublicCoordination as _t, assertRunParking as a, isPeerMailEnvelope as at, InMemorySpawnJournal as b, gateOnDeliverable as bt, readRunParking as c, taskToPrompt$1 as ct, bestDelivered as d, abandonablePending as dt, projectSandboxOutcome as en, AUTHORITY_MARKERS as et, runFinalizer as f, classifyDriverFailure as ft, driverExecutorFactory as g, upstreamUnavailableSignal as gt, driverChild as h, undispatchedCredentialExit as ht, RunParkedError as i, createPeerMailbox as it, createSandboxForSpec as j, createPushTraceSource as jt, assertBoxlessPromptOptions as k, harnessUsageIsEmpty as kt, sleepScopeWait as l, DriverAttemptsExhaustedError as lt, createRootHandle as m, transientFailureKind as mt, createSupervisor as n, PEER_MAIL_WIRE_KEY as nt, bindScopeParkingDrain as o, peerMailTools as ot, runTree as p, summarizeDriverAttempts as pt, LEAF_CONTINUATION_TASK as q, promptControlProfileMaterialization as qt, assertResumeLimits as r, claimsAuthority as rt, isRunParked as s, peerMailVerbNames as st, DEFAULT_MAX_DEPTH as t, readSandboxOutcome as tn, DEFAULT_PEER_MAIL_LIMITS as tt, withRunParking as u, HarnessTurnFailedError as ut, withDriverExecutor as v, CheckUnavailableError as vt, createExecutor as w, bridgeModelRouteRefusal as wt, createExecutorRegistry as x, mapExecutorResult as xt, InMemoryResultBlobStore as y, gateFactoryOnDeliverable as yt, runCodeMode as z, harnessInvocation as zt };
16473
16664
 
16474
- //# sourceMappingURL=supervisor-DwdeUC2l.js.map
16665
+ //# sourceMappingURL=supervisor-DpwcTrTh.js.map