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