@tangle-network/agent-runtime 10.0.0 → 10.0.2
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.
- package/CHANGELOG.md +24 -0
- package/dist/{activation-CEGkyzEG.js → activation-B0DHGRtB.js} +2 -2
- package/dist/{activation-CEGkyzEG.js.map → activation-B0DHGRtB.js.map} +1 -1
- package/dist/{activation-CDlOqX5a.d.ts → activation-D0Sp7wMc.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -3
- package/dist/{delegate-V2Nz8GgO.js → delegate-Co5iUyS0.js} +2 -2
- package/dist/{delegate-V2Nz8GgO.js.map → delegate-Co5iUyS0.js.map} +1 -1
- package/dist/{driver-control-acknowledgers-CJDYLJmW.js → driver-control-acknowledgers-B1Qx2JUz.js} +68 -12
- package/dist/driver-control-acknowledgers-B1Qx2JUz.js.map +1 -0
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +9 -9
- package/dist/{failure-cause-BI7cfDWx.js → failure-cause-DoCCGLDH.js} +30 -18
- package/dist/{failure-cause-BI7cfDWx.js.map → failure-cause-DoCCGLDH.js.map} +1 -1
- package/dist/{graph-wJOMQ1kC.js → graph-uc4eT1wR.js} +7 -7
- package/dist/{graph-wJOMQ1kC.js.map → graph-uc4eT1wR.js.map} +1 -1
- package/dist/{improve-DOjywiPq.js → improve-BM0HlzMi.js} +6 -6
- package/dist/{improve-DOjywiPq.js.map → improve-BM0HlzMi.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +11 -11
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +4 -4
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +15 -15
- package/dist/{loop-runner-CPTOzSol.js → loop-runner-CRC-RE4D.js} +2 -2
- package/dist/{loop-runner-CPTOzSol.js.map → loop-runner-CRC-RE4D.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/{loop-runner-DwxZbYW5.d.ts → loop-runner-npLkvCU5.d.ts} +2 -2
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +7 -7
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/{model-policy-CqDuBTq-.js → model-policy-DZnL8Yj9.js} +13 -2
- package/dist/{model-policy-CqDuBTq-.js.map → model-policy-DZnL8Yj9.js.map} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.js +1 -1
- package/dist/{provision-supervisor-B1_Kow9m.js → provision-supervisor-CJrMGyZW.js} +6 -6
- package/dist/{provision-supervisor-B1_Kow9m.js.map → provision-supervisor-CJrMGyZW.js.map} +1 -1
- package/dist/{run-cancellation-D5m6JHPH.js → run-cancellation-CBP3Bmad.js} +2 -2
- package/dist/{run-cancellation-D5m6JHPH.js.map → run-cancellation-CBP3Bmad.js.map} +1 -1
- package/dist/{run-state-DKOXe08H.js → run-state-BnhCVbTY.js} +5 -5
- package/dist/{run-state-DKOXe08H.js.map → run-state-BnhCVbTY.js.map} +1 -1
- package/dist/{runtime-C5cWSMqU.js → runtime-BqSaWTEY.js} +14 -14
- package/dist/{runtime-C5cWSMqU.js.map → runtime-BqSaWTEY.js.map} +1 -1
- package/dist/{search-executor-CA6fTYWz.js → search-executor-C9TN-KgI.js} +5 -5
- package/dist/{search-executor-CA6fTYWz.js.map → search-executor-C9TN-KgI.js.map} +1 -1
- package/dist/{server-C8Z3vYdI.js → server-CcMa8Lt9.js} +4 -4
- package/dist/{server-C8Z3vYdI.js.map → server-CcMa8Lt9.js.map} +1 -1
- package/dist/{settle-record-BDxPAO4m.js → settle-record-BtjYZabI.js} +2 -2
- package/dist/{settle-record-BDxPAO4m.js.map → settle-record-BtjYZabI.js.map} +1 -1
- package/dist/{structural-rollout-B0HPcP9G.js → structural-rollout-2oRJjwyM.js} +5 -5
- package/dist/{structural-rollout-B0HPcP9G.js.map → structural-rollout-2oRJjwyM.js.map} +1 -1
- package/dist/{supervise-Dvj-8S6D.js → supervise-BrgtzJf3.js} +47 -15
- package/dist/supervise-BrgtzJf3.js.map +1 -0
- package/dist/{supervision-discovery-CbrwcgJy.js → supervision-discovery-DLMm3UOr.js} +3 -3
- package/dist/{supervision-discovery-CbrwcgJy.js.map → supervision-discovery-DLMm3UOr.js.map} +1 -1
- package/dist/{supervisor-DwdeUC2l.js → supervisor-ACffs_W4.js} +248 -49
- package/dist/supervisor-ACffs_W4.js.map +1 -0
- package/dist/{supervisor-accounting-C48Yo9QC.js → supervisor-accounting-BlJqoP3k.js} +43 -12
- package/dist/supervisor-accounting-BlJqoP3k.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +11 -11
- package/dist/{tool-server-DsCeBr-C.js → tool-server-DQCdu3am.js} +2 -2
- package/dist/{tool-server-DsCeBr-C.js.map → tool-server-DQCdu3am.js.map} +1 -1
- package/dist/{top-web-CTOq4psb.js → top-web-PYyzBMsK.js} +6 -6
- package/dist/{top-web-CTOq4psb.js.map → top-web-PYyzBMsK.js.map} +1 -1
- package/dist/tui/bin.js +3 -3
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{types-lnF0wIJW.d.ts → types-DX1OGeHE.d.ts} +5736 -5692
- package/package.json +5 -5
- package/dist/driver-control-acknowledgers-CJDYLJmW.js.map +0 -1
- package/dist/supervise-Dvj-8S6D.js.map +0 -1
- package/dist/supervisor-DwdeUC2l.js.map +0 -1
- 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-
|
|
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-BlJqoP3k.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,
|
|
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 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-
|
|
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
|
+
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-DZnL8Yj9.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-
|
|
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 {
|
|
@@ -4009,7 +4010,7 @@ function newTurnTally() {
|
|
|
4009
4010
|
usdKnown: true,
|
|
4010
4011
|
knownCostSubtotal: 0,
|
|
4011
4012
|
costProvenance: void 0,
|
|
4012
|
-
estimatedCostSubtotal: 0,
|
|
4013
|
+
estimatedCostSubtotal: void 0,
|
|
4013
4014
|
inputTokens: 0,
|
|
4014
4015
|
outputTokens: 0
|
|
4015
4016
|
};
|
|
@@ -4140,9 +4141,10 @@ var BridgeSessionLedger = class {
|
|
|
4140
4141
|
}
|
|
4141
4142
|
}
|
|
4142
4143
|
if (typeof chunk.estimatedCost === "number") {
|
|
4143
|
-
const
|
|
4144
|
+
const subtotal = turn.estimatedCostSubtotal ?? 0;
|
|
4145
|
+
const increment = chunk.costScope === "total" ? chunk.estimatedCost - subtotal : chunk.estimatedCost;
|
|
4144
4146
|
if (increment < 0) throw new ValidationError$1("bridgeExecutor: total estimated cost decreased within a turn");
|
|
4145
|
-
turn.estimatedCostSubtotal
|
|
4147
|
+
turn.estimatedCostSubtotal = subtotal + increment;
|
|
4146
4148
|
this.estimatedUsd += increment;
|
|
4147
4149
|
this.sawEstimatedUsd = true;
|
|
4148
4150
|
}
|
|
@@ -4191,7 +4193,14 @@ var BridgeSessionLedger = class {
|
|
|
4191
4193
|
}
|
|
4192
4194
|
priceUnreceiptedTurn(providerModel, credentialSource) {
|
|
4193
4195
|
const { turn } = this;
|
|
4194
|
-
const
|
|
4196
|
+
const estimate = credentialSource === "subscription" ? void 0 : turn.estimatedCostSubtotal;
|
|
4197
|
+
const priced = estimate !== void 0 ? {
|
|
4198
|
+
kind: "cost",
|
|
4199
|
+
usd: estimate,
|
|
4200
|
+
usdKnown: false,
|
|
4201
|
+
usdEstimated: estimate,
|
|
4202
|
+
provenance: "catalog-estimate"
|
|
4203
|
+
} : turn.knownCostSubtotal === 0 ? priceUnreceiptedWork({
|
|
4195
4204
|
inputTokens: turn.inputTokens,
|
|
4196
4205
|
outputTokens: turn.outputTokens,
|
|
4197
4206
|
model: this.observedModel ?? providerModel,
|
|
@@ -5125,6 +5134,8 @@ var HarnessTurnFailedError = class extends Error {
|
|
|
5125
5134
|
/** The shared HTTP error reader also uses this status for persisted diagnostics. */
|
|
5126
5135
|
status;
|
|
5127
5136
|
failure;
|
|
5137
|
+
/** The producer's quota reset, which `reportedResetAt` holds a capacity pause to. */
|
|
5138
|
+
resetAt;
|
|
5128
5139
|
constructor(runtime, failure) {
|
|
5129
5140
|
super(`${runtime} harness turn ended with a failed outcome` + (failure.errorCode === void 0 ? "" : ` (${failure.errorCode})`) + `: ${failure.error}`);
|
|
5130
5141
|
this.name = "HarnessTurnFailedError";
|
|
@@ -5132,6 +5143,7 @@ var HarnessTurnFailedError = class extends Error {
|
|
|
5132
5143
|
this.reported = failure.error;
|
|
5133
5144
|
if (failure.failure !== void 0) this.failure = failure.failure;
|
|
5134
5145
|
if (failure.errorCode !== void 0) this.errorCode = failure.errorCode;
|
|
5146
|
+
if (failure.resetAt !== void 0) this.resetAt = failure.resetAt;
|
|
5135
5147
|
if (failure.statusCode !== void 0) {
|
|
5136
5148
|
this.statusCode = failure.statusCode;
|
|
5137
5149
|
this.status = failure.statusCode;
|
|
@@ -7544,9 +7556,10 @@ async function attemptDestroy(scope, cleanupSignal) {
|
|
|
7544
7556
|
const { state, provider } = scope;
|
|
7545
7557
|
const target = state.environment;
|
|
7546
7558
|
if (target === void 0) return { destroyed: true };
|
|
7547
|
-
|
|
7559
|
+
await state.fileOutput?.settled();
|
|
7560
|
+
if (state.sourcePreservationRequired) return {
|
|
7548
7561
|
destroyed: false,
|
|
7549
|
-
detail: "provider
|
|
7562
|
+
detail: "provider source custody is unresolved; environment preserved",
|
|
7550
7563
|
permanent: true
|
|
7551
7564
|
};
|
|
7552
7565
|
if (state.sourcePreservationRequired) return {
|
|
@@ -7737,6 +7750,7 @@ function providerFailureEvent(event, sandboxEvent) {
|
|
|
7737
7750
|
const errorCode = failureCode(sandboxEvent.data) ?? failureCode(outcome) ?? failureCode(result);
|
|
7738
7751
|
const statusCode = failureStatusCode(sandboxEvent.data) ?? failureStatusCode(outcome) ?? failureStatusCode(result);
|
|
7739
7752
|
const failure = turnFailureOf(sandboxEvent.data) ?? turnFailureOf(outcome) ?? turnFailureOf(result);
|
|
7753
|
+
const remediation = turnRemediationOf(sandboxEvent.data) ?? turnRemediationOf(outcome) ?? turnRemediationOf(result);
|
|
7740
7754
|
return {
|
|
7741
7755
|
type: "result",
|
|
7742
7756
|
data: {
|
|
@@ -7744,7 +7758,8 @@ function providerFailureEvent(event, sandboxEvent) {
|
|
|
7744
7758
|
...detail ? { error: detail } : {},
|
|
7745
7759
|
...errorCode ? { errorCode } : {},
|
|
7746
7760
|
...statusCode === void 0 ? {} : { statusCode },
|
|
7747
|
-
...failure === void 0 ? {} : { failure }
|
|
7761
|
+
...failure === void 0 ? {} : { failure },
|
|
7762
|
+
...remediation === void 0 ? {} : { remediation }
|
|
7748
7763
|
}
|
|
7749
7764
|
};
|
|
7750
7765
|
}
|
|
@@ -7800,9 +7815,11 @@ function createProviderFailureLedger() {
|
|
|
7800
7815
|
for (const frame of failures) tracker.observe(frame);
|
|
7801
7816
|
const outcome = tracker.finish();
|
|
7802
7817
|
const failure = turnFailureOf(outcome) ?? failures.slice().reverse().map((frame) => turnFailureOf(frame.data)).find((value) => value !== void 0);
|
|
7818
|
+
const remediation = failures.slice().reverse().map((frame) => turnRemediationOf(frame.data)).find((value) => value !== void 0);
|
|
7803
7819
|
return outcome === void 0 ? void 0 : {
|
|
7804
7820
|
...outcome,
|
|
7805
|
-
failure
|
|
7821
|
+
failure,
|
|
7822
|
+
...remediation === void 0 ? {} : { remediation }
|
|
7806
7823
|
};
|
|
7807
7824
|
}
|
|
7808
7825
|
};
|
|
@@ -7816,6 +7833,20 @@ function failureDetail(value) {
|
|
|
7816
7833
|
return typeof value?.detail === "string" ? value.detail : void 0;
|
|
7817
7834
|
}
|
|
7818
7835
|
/** Preserve the Sandbox outcome's numeric HTTP metadata across the provider adapter. */
|
|
7836
|
+
/** The executor envelope of a failed turn: the ledger's outcome as Runtime's retry reads it, quota reset included. */
|
|
7837
|
+
function failedTurnOutcome(outcome) {
|
|
7838
|
+
if (outcome?.status !== "failed") return void 0;
|
|
7839
|
+
const statusCode = failureStatusCode(outcome);
|
|
7840
|
+
return {
|
|
7841
|
+
success: false,
|
|
7842
|
+
...outcome.failure === void 0 ? {} : { failure: outcome.failure },
|
|
7843
|
+
...outcome.error ? { error: outcome.error } : {},
|
|
7844
|
+
...outcome.errorCode ? { errorCode: outcome.errorCode } : {},
|
|
7845
|
+
...statusCode === void 0 ? {} : { statusCode },
|
|
7846
|
+
...outcome.remediation === void 0 ? {} : { remediation: outcome.remediation },
|
|
7847
|
+
...outcome.resetAt ? { resetAt: outcome.resetAt } : {}
|
|
7848
|
+
};
|
|
7849
|
+
}
|
|
7819
7850
|
function failureStatusCode(value) {
|
|
7820
7851
|
const statusCode = recordValue(value)?.statusCode;
|
|
7821
7852
|
return typeof statusCode === "number" && Number.isInteger(statusCode) && statusCode >= 400 && statusCode <= 599 ? statusCode : void 0;
|
|
@@ -8041,6 +8072,7 @@ var RetainedObservation = class {
|
|
|
8041
8072
|
silenceHandledAt;
|
|
8042
8073
|
exactResult;
|
|
8043
8074
|
exactResultSettled = false;
|
|
8075
|
+
exactResultSettledAt = 0;
|
|
8044
8076
|
observedFrames = 0;
|
|
8045
8077
|
framesAfterResult = 0;
|
|
8046
8078
|
exactWakers = /* @__PURE__ */ new Set();
|
|
@@ -8157,7 +8189,10 @@ var RetainedObservation = class {
|
|
|
8157
8189
|
if (this.observedFrames === 0) this.lastObservedAt = Date.now();
|
|
8158
8190
|
const retry = !retried && failed.length > 0 && !exactQuotaRefusal(failed[0]);
|
|
8159
8191
|
if (retry) this.exactResult = void 0;
|
|
8160
|
-
else
|
|
8192
|
+
else {
|
|
8193
|
+
this.exactResultSettled = true;
|
|
8194
|
+
this.exactResultSettledAt = Date.now();
|
|
8195
|
+
}
|
|
8161
8196
|
for (const wake of [...this.exactWakers]) wake();
|
|
8162
8197
|
if (retry) this.readExactResult(true);
|
|
8163
8198
|
};
|
|
@@ -8185,7 +8220,7 @@ var RetainedObservation = class {
|
|
|
8185
8220
|
wake = setImmediate(() => {
|
|
8186
8221
|
const close = () => {
|
|
8187
8222
|
if (!this.exactResultSettled) return;
|
|
8188
|
-
const flowing = this.sawTerminal ? 0 : RETAINED_TAIL_FLOW_MS - (Date.now() - this.lastObservedAt);
|
|
8223
|
+
const flowing = this.sawTerminal ? 0 : RETAINED_TAIL_FLOW_MS - (Date.now() - Math.max(this.lastObservedAt, this.exactResultSettledAt));
|
|
8189
8224
|
if (flowing <= 0) {
|
|
8190
8225
|
wake = setImmediate(() => resolve({ kind: "exact-result" }));
|
|
8191
8226
|
return;
|
|
@@ -8231,12 +8266,12 @@ var RetainedObservation = class {
|
|
|
8231
8266
|
const identity = extractTransportEventIdentity(event);
|
|
8232
8267
|
const eventId = identity.eventId ?? identity.cursor;
|
|
8233
8268
|
if (eventId !== void 0) {
|
|
8234
|
-
const digest =
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8269
|
+
const digest = sha256(JSON.stringify([
|
|
8270
|
+
event.type,
|
|
8271
|
+
event.data,
|
|
8272
|
+
event.usage ?? null,
|
|
8273
|
+
event.normalized ?? null
|
|
8274
|
+
]));
|
|
8240
8275
|
const prior = this.seenEvents.get(eventId);
|
|
8241
8276
|
if (prior !== void 0) {
|
|
8242
8277
|
if (prior !== digest) throw new RetainedRunProviderContractError(`provider replay changed retained event ${eventId}`, { code: "RETAINED_EVENT_DUPLICATE_CHANGED" });
|
|
@@ -8437,6 +8472,7 @@ function retainedDispatchMaterial(args, retention, selectedTurn, signal) {
|
|
|
8437
8472
|
};
|
|
8438
8473
|
return {
|
|
8439
8474
|
material: {
|
|
8475
|
+
...args.options.outputFile === void 0 ? {} : { outputFile: args.options.outputFile },
|
|
8440
8476
|
environment: {
|
|
8441
8477
|
...args.options.defaults,
|
|
8442
8478
|
...restore === void 0 ? {} : { workspace: {
|
|
@@ -8573,10 +8609,11 @@ async function retainedExecution(args, retention, turn, selectedTurn, signal) {
|
|
|
8573
8609
|
}
|
|
8574
8610
|
}
|
|
8575
8611
|
async function providerExecutionSource(args, turn, signal) {
|
|
8576
|
-
const selectedTurn = subscriptionTurnProfile(turn, args.profile);
|
|
8612
|
+
const selectedTurn = subscriptionTurnProfile(turn, args.options.outputFile !== void 0 ? args.createProfile : args.profile);
|
|
8577
8613
|
AgentTurnInputSchema.parse(selectedTurn);
|
|
8578
8614
|
const needsMcp = hasRuntimeMcpAttachments(args.options.defaults);
|
|
8579
8615
|
const capabilities = args.retention || needsMcp ? await args.provider.capabilities() : void 0;
|
|
8616
|
+
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
8617
|
assertRuntimeMcpAttachments(args.provider.name, args.options.defaults, capabilities);
|
|
8581
8618
|
if (args.retention !== void 0 && capabilities?.retainedControl !== void 0) return retainedExecution(args, args.retention, turn, selectedTurn, signal);
|
|
8582
8619
|
if (args.recovering) throw new Error(`provider ${args.provider.name} cannot recover retained executions`);
|
|
@@ -8591,6 +8628,83 @@ async function providerExecutionSource(args, turn, signal) {
|
|
|
8591
8628
|
retained: false
|
|
8592
8629
|
};
|
|
8593
8630
|
}
|
|
8631
|
+
// src/runtime/environment-provider/provider-file-output.ts
|
|
8632
|
+
/** One invocation's first file transaction. Nothing consults a later node admission or retries
|
|
8633
|
+
* a lost stop acknowledgment. The existing evidence and result writers own its persistence. */
|
|
8634
|
+
var ProviderFileOutput = class {
|
|
8635
|
+
args;
|
|
8636
|
+
pending;
|
|
8637
|
+
output;
|
|
8638
|
+
committed = false;
|
|
8639
|
+
constructor(args) {
|
|
8640
|
+
this.args = args;
|
|
8641
|
+
}
|
|
8642
|
+
get accepted() {
|
|
8643
|
+
return this.output;
|
|
8644
|
+
}
|
|
8645
|
+
get requiresPreservation() {
|
|
8646
|
+
return this.pending !== void 0 && !this.committed;
|
|
8647
|
+
}
|
|
8648
|
+
resultCommitted() {
|
|
8649
|
+
if (this.output) {
|
|
8650
|
+
this.committed = true;
|
|
8651
|
+
this.args.scope.state.fileOutputRequired = false;
|
|
8652
|
+
}
|
|
8653
|
+
}
|
|
8654
|
+
async settled() {
|
|
8655
|
+
await this.pending?.catch(() => void 0);
|
|
8656
|
+
}
|
|
8657
|
+
withSubmission(candidate, accept) {
|
|
8658
|
+
if (this.pending) return Promise.reject(new CheckUnavailableError("file output already reserved by the original submission"));
|
|
8659
|
+
const { args } = this;
|
|
8660
|
+
const handle = args.scope.state.retained;
|
|
8661
|
+
const environment = args.scope.state.environment;
|
|
8662
|
+
const submission = detachedFrozen(candidate);
|
|
8663
|
+
const policy = args.options.outputFile;
|
|
8664
|
+
const work = async () => {
|
|
8665
|
+
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");
|
|
8666
|
+
const controlRef = detachedFrozen(handle.controlRef);
|
|
8667
|
+
await args.retention.onEvidence({
|
|
8668
|
+
kind: "retained-file-output-pending",
|
|
8669
|
+
invocationId: args.executionId,
|
|
8670
|
+
node: args.node,
|
|
8671
|
+
controlRef,
|
|
8672
|
+
policy,
|
|
8673
|
+
submissionRef: contentAddress(submission),
|
|
8674
|
+
submission
|
|
8675
|
+
});
|
|
8676
|
+
const receipt = await handle.retainFileOutput({
|
|
8677
|
+
controlRef,
|
|
8678
|
+
policy
|
|
8679
|
+
}, { signal: args.signal });
|
|
8680
|
+
if (receipt.status !== "published") throw new CheckUnavailableError(`file output unavailable: ${receipt.reason}`);
|
|
8681
|
+
const publication = AgentRetainedFilePublicationSchema.parse(receipt.publication);
|
|
8682
|
+
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");
|
|
8683
|
+
const output = detachedFrozen({
|
|
8684
|
+
kind: "retained-file-output",
|
|
8685
|
+
version: 1,
|
|
8686
|
+
invocationId: args.executionId,
|
|
8687
|
+
node: args.node,
|
|
8688
|
+
submissionRef: contentAddress(submission),
|
|
8689
|
+
submission,
|
|
8690
|
+
policyDigest: canonicalCandidateDigest(policy),
|
|
8691
|
+
publication
|
|
8692
|
+
});
|
|
8693
|
+
await args.retention.onEvidence(output);
|
|
8694
|
+
args.scope.state.harnessStopped = true;
|
|
8695
|
+
return accept(output, () => {
|
|
8696
|
+
this.output = output;
|
|
8697
|
+
});
|
|
8698
|
+
};
|
|
8699
|
+
this.pending = work().catch((error) => {
|
|
8700
|
+
if (error instanceof CheckUnavailableError) throw error;
|
|
8701
|
+
throw new CheckUnavailableError("the original file transaction could not be verified or committed");
|
|
8702
|
+
});
|
|
8703
|
+
const custody = this.pending.then(() => void 0, () => void 0);
|
|
8704
|
+
args.retention?.onEndOfTurnWork?.(custody);
|
|
8705
|
+
return this.pending;
|
|
8706
|
+
}
|
|
8707
|
+
};
|
|
8594
8708
|
// src/runtime/environment-provider/provider-turn-observer.ts
|
|
8595
8709
|
/** Reads one turn's provider events into archive, text, failures, trace steps, progress and usage. */
|
|
8596
8710
|
var ProviderTurnObserver = class {
|
|
@@ -9063,6 +9177,7 @@ var ProviderTurnSettlement = class {
|
|
|
9063
9177
|
/** The artifact this turn settled with. Its presence separates "the work finished and the
|
|
9064
9178
|
* resource would not release" from "the work never finished". */
|
|
9065
9179
|
settled;
|
|
9180
|
+
commitStarted = false;
|
|
9066
9181
|
/** The body's own failure, held so a throwing teardown `finally` cannot mask it. */
|
|
9067
9182
|
failure;
|
|
9068
9183
|
failed = false;
|
|
@@ -9101,6 +9216,8 @@ var ProviderTurnSettlement = class {
|
|
|
9101
9216
|
/** Commit the consumed turn, validator verdict and measured spend. */
|
|
9102
9217
|
async *settle() {
|
|
9103
9218
|
const { args, usage } = this;
|
|
9219
|
+
const file = args.scope.state.fileOutput;
|
|
9220
|
+
await file?.settled();
|
|
9104
9221
|
yield* usage.settleTurn();
|
|
9105
9222
|
yield* usage.settleUnpricedWork();
|
|
9106
9223
|
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 +9241,10 @@ var ProviderTurnSettlement = class {
|
|
|
9124
9241
|
});
|
|
9125
9242
|
const settledResult = result;
|
|
9126
9243
|
const jsonOutput = args.options.outputFormat === "json";
|
|
9127
|
-
if (jsonOutput) await args.retention?.onEvidence?.(settledResult);
|
|
9128
|
-
|
|
9129
|
-
const
|
|
9130
|
-
const nativeFailure = outcome
|
|
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;
|
|
9244
|
+
if (jsonOutput || file) await args.retention?.onEvidence?.(settledResult);
|
|
9245
|
+
if (file && !file.accepted) throw new CheckUnavailableError("file output has no independently accepted submission; candidate custody remains held");
|
|
9246
|
+
const output = file?.accepted ? { out: file.accepted } : jsonOutput && outcome?.status !== "failed" ? jsonResultFromEvents(result.events) : { out: settledResult };
|
|
9247
|
+
const nativeFailure = failedTurnOutcome(outcome);
|
|
9137
9248
|
const settled = {
|
|
9138
9249
|
...jsonOutput ? { outputFormat: "json" } : {},
|
|
9139
9250
|
...nativeFailure ? { outcome: nativeFailure } : {},
|
|
@@ -9142,7 +9253,6 @@ var ProviderTurnSettlement = class {
|
|
|
9142
9253
|
...verdict ? { verdict } : {},
|
|
9143
9254
|
spent: executionSpent
|
|
9144
9255
|
};
|
|
9145
|
-
this.settled = settled;
|
|
9146
9256
|
if (args.mayContinue && this.retained && nativeFailure) {
|
|
9147
9257
|
const transport = nativeFailure.failure === void 0 ? nativeFailure.errorCode : nativeFailure.failure.kind === "infra" ? nativeFailure.failure.code : void 0;
|
|
9148
9258
|
const signal = unavailableSignalOfFailure({
|
|
@@ -9155,16 +9265,52 @@ var ProviderTurnSettlement = class {
|
|
|
9155
9265
|
...nativeFailure.failure ? { failure: nativeFailure.failure } : {}
|
|
9156
9266
|
};
|
|
9157
9267
|
}
|
|
9268
|
+
await this.commit(settled);
|
|
9269
|
+
}
|
|
9270
|
+
/** Commit the result durably once; its transcript persists after it. A persistence throw
|
|
9271
|
+
* reaches `fail`, which reports the committed turn as pending and keeps the source. */
|
|
9272
|
+
async commit(settled) {
|
|
9273
|
+
const { args } = this;
|
|
9274
|
+
this.commitStarted = true;
|
|
9158
9275
|
if (this.retained) {
|
|
9159
9276
|
await args.retention?.onResult(settled);
|
|
9160
9277
|
args.scope.state.artifact = settled;
|
|
9161
|
-
await persistProviderHarnessTranscript(args.scope, args.task, settled, args.retention);
|
|
9162
9278
|
}
|
|
9279
|
+
args.scope.state.fileOutput?.resultCommitted();
|
|
9280
|
+
this.settled = settled;
|
|
9281
|
+
if (this.retained) await persistProviderHarnessTranscript(args.scope, args.task, settled, args.retention);
|
|
9163
9282
|
args.scope.state.pending = false;
|
|
9164
9283
|
args.scope.state.artifact = settled;
|
|
9165
9284
|
}
|
|
9166
9285
|
/** Record the turn's failure, then capture what evidence its environment still holds. */
|
|
9167
|
-
async *fail(
|
|
9286
|
+
async *fail(cause) {
|
|
9287
|
+
let error = cause;
|
|
9288
|
+
const { args } = this;
|
|
9289
|
+
const file = args.scope.state.fileOutput;
|
|
9290
|
+
await file?.settled();
|
|
9291
|
+
if (file?.accepted && !this.commitStarted) {
|
|
9292
|
+
yield* this.usage.settleTurn();
|
|
9293
|
+
await this.readLiveTranscript();
|
|
9294
|
+
const settled = {
|
|
9295
|
+
out: file.accepted,
|
|
9296
|
+
outRef: contentRef(`provider:${args.provider.name}`, file.accepted),
|
|
9297
|
+
outcome: {
|
|
9298
|
+
success: false,
|
|
9299
|
+
error: errorText(error)
|
|
9300
|
+
},
|
|
9301
|
+
spent: this.usage.spend(this.started)
|
|
9302
|
+
};
|
|
9303
|
+
await args.retention?.onEvidence?.({
|
|
9304
|
+
nativeFailure: errorText(error),
|
|
9305
|
+
invocationId: args.executionId
|
|
9306
|
+
});
|
|
9307
|
+
try {
|
|
9308
|
+
await this.commit(settled);
|
|
9309
|
+
return;
|
|
9310
|
+
} catch (persistence) {
|
|
9311
|
+
error = persistence;
|
|
9312
|
+
}
|
|
9313
|
+
}
|
|
9168
9314
|
yield* this.usage.settleTurn();
|
|
9169
9315
|
this.failure = this.retained && !retainedSessionReplaced(error) ? new RetainedExecutionPendingError(error) : error;
|
|
9170
9316
|
this.failed = true;
|
|
@@ -9179,6 +9325,7 @@ var ProviderTurnSettlement = class {
|
|
|
9179
9325
|
/** Stop the harness when required, then settle its environment's custody. */
|
|
9180
9326
|
async release() {
|
|
9181
9327
|
const { args } = this;
|
|
9328
|
+
await args.scope.state.fileOutput?.settled();
|
|
9182
9329
|
await this.stopEndedHarness();
|
|
9183
9330
|
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
9331
|
if (held) args.scope.state.holdingForContinuation = true;
|
|
@@ -9433,6 +9580,7 @@ async function* streamProviderExecutor(args) {
|
|
|
9433
9580
|
const source = await providerExecutionSource(args, turn, args.signal);
|
|
9434
9581
|
const environment = source.environment;
|
|
9435
9582
|
await args.onEnvironment(environment);
|
|
9583
|
+
args.scope.state.fileOutput = args.options.outputFile !== void 0 ? new ProviderFileOutput(args) : void 0;
|
|
9436
9584
|
const usage = new ProviderUsageAccount(args, turn.model);
|
|
9437
9585
|
const observer = new ProviderTurnObserver(args, usage, source.retained, turn.model);
|
|
9438
9586
|
const settlement = new ProviderTurnSettlement(args, environment, source.retained, observer, usage, started);
|
|
@@ -9628,6 +9776,9 @@ async function pauseForContinuation(scope, invocation, ended, attempt, refusalsB
|
|
|
9628
9776
|
var ProviderExecutorState = class {
|
|
9629
9777
|
callerSignal;
|
|
9630
9778
|
workspaceExecutionId;
|
|
9779
|
+
fileOutput;
|
|
9780
|
+
/** Reconstructed from the frozen file policy too: process loss cannot erase capture debt. */
|
|
9781
|
+
fileOutputRequired = false;
|
|
9631
9782
|
environment;
|
|
9632
9783
|
artifact;
|
|
9633
9784
|
retained;
|
|
@@ -9657,9 +9808,9 @@ var ProviderExecutorState = class {
|
|
|
9657
9808
|
transcriptPreservationRequired = false;
|
|
9658
9809
|
/** A capture existed but its durable writer failed. A later read alone cannot repay this debt. */
|
|
9659
9810
|
transcriptPersistenceFailed = false;
|
|
9660
|
-
/** Any open workspace or transcript custody debt keeps the source environment. */
|
|
9811
|
+
/** Any open workspace, file-output or transcript custody debt keeps the source environment. */
|
|
9661
9812
|
get sourcePreservationRequired() {
|
|
9662
|
-
return this.workspacePreservationRequired || this.transcriptPreservationRequired || this.transcriptPersistenceFailed;
|
|
9813
|
+
return this.workspacePreservationRequired || this.fileOutputRequired || this.fileOutput?.requiresPreservation === true || this.transcriptPreservationRequired || this.transcriptPersistenceFailed;
|
|
9663
9814
|
}
|
|
9664
9815
|
/** Exact current invocation input for a capture recovered during retained release. */
|
|
9665
9816
|
transcriptTask;
|
|
@@ -9700,12 +9851,13 @@ var ProviderExecutorState = class {
|
|
|
9700
9851
|
}
|
|
9701
9852
|
};
|
|
9702
9853
|
// src/runtime/environment-provider/provider-materialization.ts
|
|
9703
|
-
function providerMaterialization(provider, createProfile, node, executionId, retention, options, placement) {
|
|
9854
|
+
function providerMaterialization(provider, authoredProfile, createProfile, node, executionId, retention, options, placement) {
|
|
9704
9855
|
const attemptId = node?.attemptId ?? newExecutionAttemptId(executionId);
|
|
9705
9856
|
const providerModel = concreteProfileModel(createProfile);
|
|
9706
9857
|
const tokenLimits = enforceTokenLimits(profileModelExecutionSettings(createProfile, `providerAsExecutor(${provider.name})`, "provider").tokenLimits, "provider", `providerAsExecutor(${provider.name})`);
|
|
9707
9858
|
return {
|
|
9708
9859
|
plannedDeclaration: {
|
|
9860
|
+
...authoredProfile.outputFile === void 0 ? {} : { authoredProfile },
|
|
9709
9861
|
effectiveProfile: createProfile,
|
|
9710
9862
|
backend: provider.name,
|
|
9711
9863
|
model: providerModel ? {
|
|
@@ -9726,6 +9878,7 @@ function providerMaterialization(provider, createProfile, node, executionId, ret
|
|
|
9726
9878
|
destroyOnSettle: retention?.preserveEnvironment ? false : options.destroyOnSettle ?? true,
|
|
9727
9879
|
requireTerminalEvent: options.requireTerminalEvent ?? true,
|
|
9728
9880
|
...options.outputFormat === void 0 ? {} : { outputFormat: options.outputFormat },
|
|
9881
|
+
...options.outputFile === void 0 ? {} : { outputFile: options.outputFile },
|
|
9729
9882
|
tokenLimits,
|
|
9730
9883
|
...placement ? { placement } : {}
|
|
9731
9884
|
}
|
|
@@ -9756,7 +9909,7 @@ function createProviderNativeControl(provider, retention, managerStop, state) {
|
|
|
9756
9909
|
const cancelRetainedOnManagerStop = (handle) => {
|
|
9757
9910
|
if (managerStop === void 0) return;
|
|
9758
9911
|
const cancel = () => {
|
|
9759
|
-
if (state.retained !== handle || !state.workspaceRunActive) return;
|
|
9912
|
+
if (state.retained !== handle || !state.workspaceRunActive || state.harnessStopped) return;
|
|
9760
9913
|
handle.cancel({
|
|
9761
9914
|
operationId: `manager-stop:${randomUUID()}`,
|
|
9762
9915
|
reason: String(managerStop.reason ?? "the manager stopped")
|
|
@@ -9798,6 +9951,7 @@ function createProviderNativeControl(provider, retention, managerStop, state) {
|
|
|
9798
9951
|
* release records what it kept.
|
|
9799
9952
|
*/
|
|
9800
9953
|
const withoutRunningHarness = (release) => async (signal) => {
|
|
9954
|
+
if (state.harnessStopped) return release(signal);
|
|
9801
9955
|
const stop = await awaitAbortable(stopNativeExecution(), signal).catch(() => void 0);
|
|
9802
9956
|
const stopped = stop === void 0 ? "native stop unconfirmed: no exact dispatch or cleanup interrupted" : describeRetainedNativeStops([stop]);
|
|
9803
9957
|
const environmentId = (state.retained?.controlRef ?? admittedControlRef(retention))?.environmentId ?? admittedEnvironmentId(retention);
|
|
@@ -9831,14 +9985,33 @@ function admittedControlRef(retention) {
|
|
|
9831
9985
|
const NATIVE_STOP_TIMEOUT_MS = 3e4;
|
|
9832
9986
|
// src/runtime/environment-provider/provider-executor-lifecycle.ts
|
|
9833
9987
|
function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
9988
|
+
options = {
|
|
9989
|
+
...options,
|
|
9990
|
+
...providerOutputOptions(profile, options)
|
|
9991
|
+
};
|
|
9834
9992
|
const node = detachedSnapshot(ctx.node, "provider executor node");
|
|
9835
9993
|
const retention = retainedExecutorContext(ctx);
|
|
9836
|
-
if (options.outputFormat !== void 0 && (options.outputFormat !== "json" || retention?.onEvidence === void 0 || options.requireTerminalEvent === false)) throw new ValidationError("providerAsExecutor:
|
|
9994
|
+
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");
|
|
9995
|
+
if (options.outputFormat !== void 0 && options.outputFile !== void 0) throw new ValidationError("providerAsExecutor: file output is selected by outputFile alone and excludes JSON output");
|
|
9996
|
+
if (options.outputFile !== void 0) {
|
|
9997
|
+
const policy = AgentFileOutputPolicySchema.parse(options.outputFile);
|
|
9998
|
+
options = {
|
|
9999
|
+
...options,
|
|
10000
|
+
outputFile: policy,
|
|
10001
|
+
defaults: {
|
|
10002
|
+
...options.defaults,
|
|
10003
|
+
retain: { paths: [.../* @__PURE__ */ new Set([...options.defaults?.retain?.paths ?? [], policy.path])] }
|
|
10004
|
+
}
|
|
10005
|
+
};
|
|
10006
|
+
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");
|
|
10007
|
+
}
|
|
9837
10008
|
const managerStop = readOptionalAbortSignal(ctx, bridgeStopSignalKey, "provider");
|
|
9838
|
-
const
|
|
9839
|
-
|
|
10009
|
+
const { outputFile: _outputFile, ...nativeProfile } = profile;
|
|
10010
|
+
const createProfile = options.profileForCreate?.(nativeProfile) ?? nativeProfile;
|
|
10011
|
+
if (placement && canonicalAgentProfileDigest(createProfile) !== canonicalAgentProfileDigest(nativeProfile)) throw new ValidationError("provider placement: profileForCreate cannot change the selected profile");
|
|
9840
10012
|
const executionId = retention?.executionId ?? node?.nodeId ?? `provider-run-${randomUUID()}`;
|
|
9841
10013
|
const state = new ProviderExecutorState(ctx.signal, executionId);
|
|
10014
|
+
state.fileOutputRequired = options.outputFile !== void 0;
|
|
9842
10015
|
state.pending = admittedEnvironmentId(retention) !== void 0;
|
|
9843
10016
|
state.workspaceControlRef = admittedControlRef(retention);
|
|
9844
10017
|
state.providerSessionId = state.workspaceControlRef?.sessionId ?? null;
|
|
@@ -9856,7 +10029,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
9856
10029
|
controller: new AbortController(),
|
|
9857
10030
|
nativeControl: createProviderNativeControl(provider, retention, managerStop, state),
|
|
9858
10031
|
trace: createPushTraceSource({ runId: executionId }),
|
|
9859
|
-
materialization: providerMaterialization(provider, createProfile, node, executionId, retention, options, placement),
|
|
10032
|
+
materialization: providerMaterialization(provider, profile, createProfile, node, executionId, retention, options, placement),
|
|
9860
10033
|
continuationTask: LEAF_CONTINUATION_TASK,
|
|
9861
10034
|
executor: () => executor
|
|
9862
10035
|
};
|
|
@@ -9864,6 +10037,11 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
9864
10037
|
const run = (task, signal, recovering = false) => runProviderExecution(scope, task, signal, recovering);
|
|
9865
10038
|
executor = {
|
|
9866
10039
|
runtime: options.runtime ?? provider.name,
|
|
10040
|
+
...options.outputFile !== void 0 ? { withFileOutput: (submission, accept) => {
|
|
10041
|
+
const current = state.fileOutput;
|
|
10042
|
+
if (!current) return Promise.reject(new ValidationError("file output has no active retained invocation"));
|
|
10043
|
+
return current.withSubmission(submission, accept);
|
|
10044
|
+
} } : {},
|
|
9867
10045
|
execute: run,
|
|
9868
10046
|
recover: (task, signal) => run(task, signal, true),
|
|
9869
10047
|
cancel: (request) => cancelExecution(scope, request),
|
|
@@ -9961,6 +10139,16 @@ function heldForContinuation(scope) {
|
|
|
9961
10139
|
* infrastructure (discovery-lab AGENTS.md). */
|
|
9962
10140
|
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
10141
|
// src/runtime/environment-provider/provider-executor-admission.ts
|
|
10142
|
+
/** Resolve the authored per-profile output policy before a provider executor is constructed.
|
|
10143
|
+
* Backend-wide output remains the default for profiles that do not select a file. */
|
|
10144
|
+
function providerOutputOptions(profile, defaults) {
|
|
10145
|
+
if (profile.outputFile === void 0) return {};
|
|
10146
|
+
if (defaults.outputFile !== void 0 && canonicalCandidateDigest(defaults.outputFile) !== canonicalCandidateDigest(profile.outputFile)) throw new ValidationError("profile outputFile conflicts with the provider output policy");
|
|
10147
|
+
return {
|
|
10148
|
+
outputFormat: void 0,
|
|
10149
|
+
outputFile: detachedSnapshot(profile.outputFile, "profile outputFile")
|
|
10150
|
+
};
|
|
10151
|
+
}
|
|
9964
10152
|
/** Adapt an environment provider into an `ExecutorFactory` for `createExecutor`.
|
|
9965
10153
|
*
|
|
9966
10154
|
* `createExecutor({ backend: 'provider', provider })` is the composition most callers want; it
|
|
@@ -9972,6 +10160,10 @@ const LEAF_CONTINUATION_TASK = "Your previous turn was interrupted before it fin
|
|
|
9972
10160
|
*
|
|
9973
10161
|
* @experimental */
|
|
9974
10162
|
function providerAsExecutor(provider, options = {}) {
|
|
10163
|
+
if (options.outputFile !== void 0) options = {
|
|
10164
|
+
...options,
|
|
10165
|
+
outputFile: detachedSnapshot(options.outputFile, "file output policy")
|
|
10166
|
+
};
|
|
9975
10167
|
const captured = options.placements === void 0 ? options : {
|
|
9976
10168
|
...options,
|
|
9977
10169
|
placements: detachedSnapshot(options.placements, "provider placements"),
|
|
@@ -14335,7 +14527,8 @@ function snapshotExecutorConfig(config, mode = "execution") {
|
|
|
14335
14527
|
});
|
|
14336
14528
|
}
|
|
14337
14529
|
case "provider": {
|
|
14338
|
-
if (config.
|
|
14530
|
+
if (config.outputFile !== void 0 && config.shared !== void 0) throw new ValidationError$1("createExecutor(provider): file output requires a dedicated retained environment");
|
|
14531
|
+
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
14532
|
if (config.harnessTranscript !== void 0 && config.steering !== void 0) throw new ValidationError$1("createExecutor(provider): native capture is not supported with steering");
|
|
14340
14533
|
const { provider, registry, profileForCreate, taskToTurn, validator, harnessTranscript, shared, ...decisionData } = config;
|
|
14341
14534
|
if (harnessTranscript !== void 0 && typeof harnessTranscript !== "function") throw new ValidationError$1("createExecutor provider: harnessTranscript must be a capture function");
|
|
@@ -14468,6 +14661,7 @@ function createExecutor(config) {
|
|
|
14468
14661
|
const captured = snapshotExecutorConfig(config);
|
|
14469
14662
|
return (rawSpec, ctx) => {
|
|
14470
14663
|
const spec = executableAgentSpecSnapshot(rawSpec, `createExecutor(${captured.backend})`);
|
|
14664
|
+
if (spec.profile.outputFile !== void 0 && captured.backend !== "provider") throw new ValidationError$1("profile outputFile requires a retained provider backend");
|
|
14471
14665
|
const { backend, ...seamData } = captured;
|
|
14472
14666
|
const seam = Object.freeze(seamData);
|
|
14473
14667
|
const seamed = {
|
|
@@ -14485,7 +14679,12 @@ function createExecutor(config) {
|
|
|
14485
14679
|
case "cli-worktree": return cliWorktreeExecutor(spec, seamed);
|
|
14486
14680
|
case "cli-in-place": return cliInPlaceExecutor(spec, seamed);
|
|
14487
14681
|
case "provider": {
|
|
14488
|
-
const
|
|
14682
|
+
const declared = readSeam(seamed, providerSeamKey, "provider");
|
|
14683
|
+
const originalSeam = {
|
|
14684
|
+
...declared,
|
|
14685
|
+
...providerOutputOptions(spec.profile, declared)
|
|
14686
|
+
};
|
|
14687
|
+
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
14688
|
const selected = originalSeam.steering ? selectProviderPlacement(spec.profile, originalSeam) : void 0;
|
|
14490
14689
|
const providerSeam = selected?.options ?? originalSeam;
|
|
14491
14690
|
const provider = resolveAgentEnvironmentProvider(providerSeam.provider, providerSeam.registry);
|
|
@@ -16469,6 +16668,6 @@ async function noWinner(settled, rejection) {
|
|
|
16469
16668
|
reason: "no-result-selected"
|
|
16470
16669
|
};
|
|
16471
16670
|
}
|
|
16472
|
-
export {
|
|
16671
|
+
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
16672
|
|
|
16474
|
-
//# sourceMappingURL=supervisor-
|
|
16673
|
+
//# sourceMappingURL=supervisor-ACffs_W4.js.map
|