@tangle-network/agent-runtime 10.0.4 → 10.0.6
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 +36 -0
- package/dist/{activation-38MolXIP.js → activation-B3qLMoog.js} +2 -2
- package/dist/{activation-38MolXIP.js.map → activation-B3qLMoog.js.map} +1 -1
- package/dist/{activation-Ckx0yHjT.d.ts → activation-CT-rr2-5.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +4 -4
- package/dist/{continuation-CL4B1Y4M.js → continuation-Bccak14N.js} +3 -3
- package/dist/{continuation-CL4B1Y4M.js.map → continuation-Bccak14N.js.map} +1 -1
- package/dist/{delegate-dhNeiaH_.js → delegate-BFP1uCNY.js} +2 -2
- package/dist/{delegate-dhNeiaH_.js.map → delegate-BFP1uCNY.js.map} +1 -1
- package/dist/{driver-control-acknowledgers-C6GaGBf_.js → driver-control-acknowledgers-jdlf49OQ.js} +13 -11
- package/dist/driver-control-acknowledgers-jdlf49OQ.js.map +1 -0
- package/dist/durable-file-iPCEs_-s.js +1 -0
- package/dist/{durable-file-lXnojyij.js → durable-file-pao7FijS.js} +7 -11
- package/dist/durable-file-pao7FijS.js.map +1 -0
- package/dist/durable-writer-thread.js +5 -5
- package/dist/durable.d.ts +4 -1
- package/dist/durable.js +22 -16
- package/dist/durable.js.map +1 -1
- package/dist/{failure-cause-DoCCGLDH.js → failure-cause-DvYGlOEV.js} +13 -5
- package/dist/{failure-cause-DoCCGLDH.js.map → failure-cause-DvYGlOEV.js.map} +1 -1
- package/dist/{graph-CwLg3LGC.js → graph-CiApRth2.js} +10 -14
- package/dist/graph-CiApRth2.js.map +1 -0
- package/dist/{graph-registry-Bs6mGKou.js → graph-registry-CGKyYabE.js} +1 -1
- package/dist/{graph-registry-DtGd03zk.js → graph-registry-CRskE_Yp.js} +4 -4
- package/dist/{graph-registry-DtGd03zk.js.map → graph-registry-CRskE_Yp.js.map} +1 -1
- package/dist/{improve-C_LKfgH9.js → improve-LJaiGxdI.js} +8 -8
- package/dist/{improve-C_LKfgH9.js.map → improve-LJaiGxdI.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/{jsonl-file-DyzefaZ6.js → jsonl-file-vE9H9UXa.js} +3 -3
- package/dist/{jsonl-file-DyzefaZ6.js.map → jsonl-file-vE9H9UXa.js.map} +1 -1
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +20 -20
- package/dist/{loop-runner-LWqWf8FD.d.ts → loop-runner-D6egvap-.d.ts} +2 -2
- package/dist/{loop-runner-BS3ru-yj.js → loop-runner-Dgow637w.js} +2 -2
- package/dist/{loop-runner-BS3ru-yj.js.map → loop-runner-Dgow637w.js.map} +1 -1
- 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-DZnL8Yj9.js → model-policy-DTbTFyOG.js} +12 -6
- package/dist/model-policy-DTbTFyOG.js.map +1 -0
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.js +1 -1
- package/dist/{provision-supervisor-D8N0l2DM.js → provision-supervisor-DLOeyFHV.js} +8 -8
- package/dist/{provision-supervisor-D8N0l2DM.js.map → provision-supervisor-DLOeyFHV.js.map} +1 -1
- package/dist/{result-blob-store-DfTcyQ05.js → result-blob-store-BMMzqpHa.js} +4 -4
- package/dist/{result-blob-store-DfTcyQ05.js.map → result-blob-store-BMMzqpHa.js.map} +1 -1
- package/dist/{run-cancellation-D3qc9wAD.js → run-cancellation-Bv7ooTJa.js} +129 -54
- package/dist/run-cancellation-Bv7ooTJa.js.map +1 -0
- package/dist/{run-lock-D1xnb9ve.js → run-lock-Ckakh1Uq.js} +3 -3
- package/dist/{run-lock-D1xnb9ve.js.map → run-lock-Ckakh1Uq.js.map} +1 -1
- package/dist/{run-reopen-DVM5AEKV.js → run-reopen-KAnkEJV4.js} +7 -7
- package/dist/{run-reopen-DVM5AEKV.js.map → run-reopen-KAnkEJV4.js.map} +1 -1
- package/dist/{run-state-tgQ-S9Ln.js → run-state-Bcci4zIN.js} +7 -7
- package/dist/{run-state-tgQ-S9Ln.js.map → run-state-Bcci4zIN.js.map} +1 -1
- package/dist/{runtime-BTECV05R.js → runtime-DCo0OP4n.js} +46 -55
- package/dist/runtime-DCo0OP4n.js.map +1 -0
- package/dist/{search-executor-Uco2_KTB.js → search-executor-Dn5YmHsg.js} +5 -5
- package/dist/{search-executor-Uco2_KTB.js.map → search-executor-Dn5YmHsg.js.map} +1 -1
- package/dist/{server-BMp24-xn.js → server-DxpG9y6W.js} +4 -4
- package/dist/{server-BMp24-xn.js.map → server-DxpG9y6W.js.map} +1 -1
- package/dist/{settle-record-au3w7bQG.js → settle-record-DMdeNy8A.js} +4 -4
- package/dist/{settle-record-au3w7bQG.js.map → settle-record-DMdeNy8A.js.map} +1 -1
- package/dist/{structural-rollout-D8wufVJI.js → structural-rollout-DOmjcEMD.js} +5 -5
- package/dist/{structural-rollout-D8wufVJI.js.map → structural-rollout-DOmjcEMD.js.map} +1 -1
- package/dist/{supervise-DtVdvZpr.js → supervise-D7jtypE-.js} +34 -29
- package/dist/supervise-D7jtypE-.js.map +1 -0
- package/dist/{supervise-identity-S5XwgaF3.js → supervise-identity-QavM_M4r.js} +4 -4
- package/dist/{supervise-identity-S5XwgaF3.js.map → supervise-identity-QavM_M4r.js.map} +1 -1
- package/dist/{supervision-discovery-Cqu4NxPV.js → supervision-discovery-CFZnbNTB.js} +6 -9
- package/dist/supervision-discovery-CFZnbNTB.js.map +1 -0
- package/dist/{supervisor-CHgCAMjm.js → supervisor-BFs4u2Vo.js} +147 -73
- package/dist/supervisor-BFs4u2Vo.js.map +1 -0
- package/dist/{supervisor-accounting-CZ7i4cd5.js → supervisor-accounting-CgipDzYg.js} +59 -20
- package/dist/supervisor-accounting-CgipDzYg.js.map +1 -0
- package/dist/{supervisor-root-contract-D70KTGXF.js → supervisor-root-contract-Ca5xp0Vg.js} +3 -3
- package/dist/{supervisor-root-contract-D70KTGXF.js.map → supervisor-root-contract-Ca5xp0Vg.js.map} +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +11 -11
- package/dist/{tool-server-DQCdu3am.js → tool-server-Cb7LBW4e.js} +2 -2
- package/dist/{tool-server-DQCdu3am.js.map → tool-server-Cb7LBW4e.js.map} +1 -1
- package/dist/{top-web-COrMqTRC.js → top-web-oDO4xhNE.js} +8 -8
- package/dist/{top-web-COrMqTRC.js.map → top-web-oDO4xhNE.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-9xsn2GGY.d.ts → types-CKsn_wgO.d.ts} +26 -4
- package/package.json +1 -1
- package/dist/driver-control-acknowledgers-C6GaGBf_.js.map +0 -1
- package/dist/durable-file-DJ3JsA4B.js +0 -1
- package/dist/durable-file-lXnojyij.js.map +0 -1
- package/dist/graph-CwLg3LGC.js.map +0 -1
- package/dist/model-policy-DZnL8Yj9.js.map +0 -1
- package/dist/run-cancellation-D3qc9wAD.js.map +0 -1
- package/dist/runtime-BTECV05R.js.map +0 -1
- package/dist/supervise-DtVdvZpr.js.map +0 -1
- package/dist/supervision-discovery-Cqu4NxPV.js.map +0 -1
- package/dist/supervisor-CHgCAMjm.js.map +0 -1
- package/dist/supervisor-accounting-CZ7i4cd5.js.map +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Ar as
|
|
1
|
+
import { $ as appendTeardownConfirmation, $r as runtimeOwnedScopeOwnerRuntime, Ar as attestRuntimeOwnedDeferredExecutor, At as RELEASE_DESTROY_MS, Bn as environmentGone, Br as newExecutionAttemptId, Cn as verifyWorkspaceMarker, Ct as unconfirmedTeardowns, Dn as reconnectRetainedRun, En as mintRetainedIdentity, Gn as mergeTraceEnv, Gr as recordRuntimeOwnedProviderIdentityConflict, Hn as workerTraceEnv, Ir as finalizeRuntimeOwnedPendingExecutor, Jr as runtimeOwnedExecutorExecutionBinding, Kr as recordRuntimeOwnedProviderModel, L as resolveWorkerSlots, Lr as inheritRuntimeOwnedExecutorAttestation, Lt as finalizeScopeOwnerMaterialization, Mr as attestRuntimeOwnedPendingExecutor, On as recoverRetainedRun, Qr as runtimeOwnedScopeOwnerControl, R as prepareScopeResume, Sn as stopRetainedNativeExecution, Sr as isLiveNodeStatus, St as startScopeRecoveries, Tn as assertRetainedRunReplayMaterial, U as nestedScopeSeamKey, Un as workerTraceHeaders, Ur as recordRuntimeOwnedProviderAttemptStart, Vn as WORKER_TRACE_PROPAGATION, Wr as recordRuntimeOwnedProviderDispatchNotStarted, Xt as scopeRetainedOwnerSettled, Yr as runtimeOwnedExecutorMaterialization, Z as appendSpawnEvents, _n as executorObservation, _t as registerNestedTeardownScope, an as owners, ar as HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS, br as describeToolArgs, bt as retryUnconfirmedTeardowns, ci as RetainedRunProviderContractError, ct as closeRetainedSlots, di as exactSession, fi as freezeControlRef, fn as attestNestedDriverTreeOwner, gi as promptOptionsFromAgentTurnInput, hn as SpawnEventIndex, in as bindScopeRetainedOwnerProvider, jr as attestRuntimeOwnedExecutor, kn as startRetainedRun, kr as subscriptionUsageLimitSignal, li as assertEventBinding, ln as loadSpawnForest, lr as harnessTranscriptFromLines, lt as closeScopeAdmission, mi as sameControlCoordinates, mn as nestedDriverTreeRoot, n as terminalAccounting, ni as executableAgentProfileSnapshot, nn as scopeRetainedOwnerCheckpointing, nt as assertRecursiveReservationPolicy, on as scopeOwnerLiabilities, pi as retainedSessionReplaced, pn as driverRuntime, r as createScope, ri as executableAgentSpecSnapshot, sr as captureHarnessTranscript, st as boundRetainedReleases, t as isNonEmptySpend, ui as awaitAbortable, un as ownedTreeRootSpawn, ur as harnessTranscriptUnavailable, ut as hasRetriableTeardowns, vt as releaseHeldEnvironments, wn as RetainedMaterializationTimeoutError, wt as waitForScopeChildren, xn as describeRetainedNativeStops, xt as settleManagerWork, yn as observeModelRequest, yr as createActivityLog, yt as releaseRetainedEnvironments } from "./supervisor-accounting-CgipDzYg.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
|
-
import { _ as runAbortable, f as sha256, g as linkAbort, m as abortReason, p as RunCancellationReason } from "./jsonl-file-
|
|
3
|
+
import { _ as runAbortable, f as sha256, g as linkAbort, m as abortReason, p as RunCancellationReason } from "./jsonl-file-vE9H9UXa.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 {
|
|
7
|
+
import { A as unavailableSignalOfFailure, At as recordValue, B as runtimeFailureRemediationSchema, C as cappedDoublingMs, Ct as sameModelId, D as reportedResetAt, E as printedStatus, Et as sandboxTerminalUsageField, F as contentRef, G as credentialCommandExit, H as turnFailurePolicy, K as isCredentialRefusal, L as executorFailureInfra, O as unavailablePauseMs, P as contentAddress, Q as createBudgetPool, S as UNAVAILABLE_STATUSES, St as notifySandboxEventObserver, T as placementRefusal, Tt as sandboxEventServedBackend, U as turnRemediationOf, V as turnFailureOf, W as hashJson, _ as retainedExecutorContext, _t as canonicalSandboxUsageMode, c as DISPATCH_NOT_ADMITTED_CODE, dt as sandboxProgressEvents, f as isProvisioningRefusal, gt as assertSandboxServedModel, i as runtimeProviderCode, k as unavailableResumeAt, kt as parseCodexUsageRecord, l as RetainedExecutionPendingError, lt as sandboxLeafOutputFromEvents, mt as extractTransportEventIdentity, n as runtimeFailureCause, ot as createSandboxToolPartState, p as isSchemaRejection, s as DISPATCH_EXECUTION_CHANGED_CODE, t as reportedFailureCause, u as TRANSPORT_ERROR_CODES, ut as sandboxOutputMarker, v as retainedExecutorSeamKey, vt as createSandboxTurnEventCollector, wt as sandboxEventProviderModels, x as UNAVAILABLE_CODES, xt as isSandboxTerminalEvent, yt as createSandboxUsageLedger } from "./failure-cause-DvYGlOEV.js";
|
|
8
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-
|
|
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-DTbTFyOG.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
|
-
import { i as checkVerdictOf, s as isFiniteNumber } from "./continuation-
|
|
13
|
-
import {
|
|
14
|
-
import { t as PROTOCOL_VERSION } from "./tool-server-
|
|
12
|
+
import { i as checkVerdictOf, s as isFiniteNumber } from "./continuation-Bccak14N.js";
|
|
13
|
+
import { r as appendRunLines, u as writeAtomicDurableFile } from "./durable-file-pao7FijS.js";
|
|
14
|
+
import { t as PROTOCOL_VERSION } from "./tool-server-Cb7LBW4e.js";
|
|
15
15
|
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-CsW2pfFk.js";
|
|
16
|
-
import { n as encodeResultBlob } from "./result-blob-store-
|
|
17
|
-
import { a as recordRootReentered, c as rootMaterializationReceipt, i as changesRootProfile, l as rootStartedAtMs, o as recordRootSegment, r as assertRootIdentity, s as rootExecutionBindingReceipt, t as assertResumeContract } from "./supervisor-root-contract-
|
|
16
|
+
import { n as encodeResultBlob } from "./result-blob-store-BMMzqpHa.js";
|
|
17
|
+
import { a as recordRootReentered, c as rootMaterializationReceipt, i as changesRootProfile, l as rootStartedAtMs, o as recordRootSegment, r as assertRootIdentity, s as rootExecutionBindingReceipt, t as assertResumeContract } from "./supervisor-root-contract-Ca5xp0Vg.js";
|
|
18
18
|
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, workspaceCwdPathForBase } from "@tangle-network/agent-interface";
|
|
19
19
|
import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
|
|
20
20
|
import { SDKError, generateIdempotencyKey, isRecord, withRetry } from "@tangle-network/agent-core";
|
|
@@ -25,7 +25,7 @@ import { constants, createReadStream, existsSync } from "node:fs";
|
|
|
25
25
|
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep, win32 } from "node:path";
|
|
26
26
|
import { spawn } from "node:child_process";
|
|
27
27
|
import { access, chmod, copyFile, mkdir, mkdtemp, open, readFile, readdir, realpath, rm, rmdir, stat, symlink, writeFile } from "node:fs/promises";
|
|
28
|
-
import { CODEX_DISABLED_FEATURE_ARGS, applyWorkspacePlan, assertWorkspacePlanSupported, hashWorkspacePlan, materializeProfile, resolveAgentProfileResources } from "@tangle-network/agent-profile-materialize";
|
|
28
|
+
import { CODEX_DISABLED_FEATURE_ARGS, applyWorkspacePlan, assertWorkspacePlanSupported, hashWorkspacePlan, materializeProfile, qualifyModelId, resolveAgentProfileResources } from "@tangle-network/agent-profile-materialize";
|
|
29
29
|
import { stripVTControlCharacters } from "node:util";
|
|
30
30
|
import { homedir, hostname, tmpdir } from "node:os";
|
|
31
31
|
import { request } from "node:http";
|
|
@@ -592,7 +592,7 @@ function harnessProfileModel(harness, profile) {
|
|
|
592
592
|
if (!model) return void 0;
|
|
593
593
|
const provider = profile.model?.provider?.trim();
|
|
594
594
|
if (!provider) return model;
|
|
595
|
-
if (harness === "opencode") return
|
|
595
|
+
if (harness === "opencode") return qualifyModelId(provider, model);
|
|
596
596
|
if (harness === "kimi-code") return model;
|
|
597
597
|
const nativeProvider = harness === "codex" ? "openai" : "anthropic";
|
|
598
598
|
if (provider !== nativeProvider) throw new Error(`harnessInvocation: ${harness} cannot materialize model provider ${JSON.stringify(provider)}; expected ${nativeProvider}`);
|
|
@@ -7653,30 +7653,37 @@ const CAPACITY_RETRY_WINDOW_MS = 6e5;
|
|
|
7653
7653
|
* resent under one execution id once and replays its events
|
|
7654
7654
|
* (apps/sidecar/tests/integration/run-stream-resend.test.ts). `retry` waits, Retry-After at least, then doubling to `retryUntil`,
|
|
7655
7655
|
* 30 s per wait, and answers true; any other error, an abort or a spent window answers false.
|
|
7656
|
-
*
|
|
7657
|
-
*
|
|
7656
|
+
* A placement refusal waits for room until `deadlineMs` when the run has one, else for the
|
|
7657
|
+
* capacity window, before the same retained invocation counts as a failed attempt; `refused` is
|
|
7658
|
+
* the refusal the last wait was for, which a wait the signal cut ends on instead of the abort.
|
|
7658
7659
|
* `settled` opens a new window after progress; the caller's signal still bounds every wait.
|
|
7659
7660
|
*/
|
|
7660
|
-
function hostRestartReconnect(signal,
|
|
7661
|
+
function hostRestartReconnect(signal, deadlineMs = 0) {
|
|
7661
7662
|
let since;
|
|
7662
7663
|
let waits = 0;
|
|
7664
|
+
let refused;
|
|
7663
7665
|
const ms = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
7664
7666
|
return {
|
|
7665
7667
|
async retry(error) {
|
|
7666
|
-
const capacity =
|
|
7668
|
+
const capacity = placementRefusal(error);
|
|
7667
7669
|
const code = (cause) => Reflect.get(cause, "code") === "HOST_AGENT_RESTARTING";
|
|
7668
7670
|
const refusal = capacity ?? causeChain(error).find(code);
|
|
7669
7671
|
if (refusal === void 0 || signal.aborted) return false;
|
|
7670
|
-
since ??= now();
|
|
7671
|
-
const left = since +
|
|
7672
|
+
since ??= Date.now();
|
|
7673
|
+
const left = (capacity === void 0 ? since + HOST_RESTART_WINDOW_MS : deadlineMs > 0 ? deadlineMs : since + CAPACITY_RETRY_WINDOW_MS) - Date.now();
|
|
7672
7674
|
if (left <= 0) return false;
|
|
7673
|
-
|
|
7675
|
+
refused = capacity;
|
|
7676
|
+
const wanted = Math.max(ms(Reflect.get(refusal, "retryAfterMs")), ms(Reflect.get(refusal, "retryUntil")) - Date.now(), cappedDoublingMs(++waits, 1e3, 3e4));
|
|
7674
7677
|
await sleep(Math.min(left, 3e4, wanted), signal);
|
|
7675
7678
|
return !signal.aborted;
|
|
7676
7679
|
},
|
|
7680
|
+
get refused() {
|
|
7681
|
+
return refused;
|
|
7682
|
+
},
|
|
7677
7683
|
settled() {
|
|
7678
7684
|
since = void 0;
|
|
7679
7685
|
waits = 0;
|
|
7686
|
+
refused = void 0;
|
|
7680
7687
|
}
|
|
7681
7688
|
};
|
|
7682
7689
|
}
|
|
@@ -7944,14 +7951,29 @@ function resultFromEvents(events, fallbackText) {
|
|
|
7944
7951
|
events
|
|
7945
7952
|
};
|
|
7946
7953
|
}
|
|
7947
|
-
/**
|
|
7954
|
+
/**
|
|
7955
|
+
* The JSON value that ends the final message settles it: the whole message, a fence ending it, or,
|
|
7956
|
+
* when it has no json fence, a line-start object ending it (the Bridge's rule in cli-bridge
|
|
7957
|
+
* src/runs/final-output.ts). Text after the value, including after a json fence, keeps it refused.
|
|
7958
|
+
*/
|
|
7948
7959
|
function finalJsonValue(text) {
|
|
7949
7960
|
if (text === void 0) return "";
|
|
7950
7961
|
try {
|
|
7951
7962
|
JSON.parse(text);
|
|
7952
7963
|
return text;
|
|
7953
7964
|
} catch {}
|
|
7954
|
-
|
|
7965
|
+
const fenced = /```(?:json)?[ \t]*\r?\n((?:(?!```)[\s\S])*)```\s*$/i.exec(text)?.[1];
|
|
7966
|
+
if (fenced !== void 0) return fenced;
|
|
7967
|
+
if (/```json[ \t]*\r?\n[\s\S]*?\r?\n```/i.test(text)) return text;
|
|
7968
|
+
if (!text.trimEnd().endsWith("}")) return text;
|
|
7969
|
+
for (let i = text.lastIndexOf("\n{"); i > 0; i = text.lastIndexOf("\n{", i - 1)) {
|
|
7970
|
+
const candidate = text.slice(i + 1);
|
|
7971
|
+
try {
|
|
7972
|
+
JSON.parse(candidate);
|
|
7973
|
+
return candidate;
|
|
7974
|
+
} catch {}
|
|
7975
|
+
}
|
|
7976
|
+
return text;
|
|
7955
7977
|
}
|
|
7956
7978
|
/** Decode only the final assistant message, keeping the stream as evidence. A stream not wholly
|
|
7957
7979
|
* read is refused, not left pending: no later read completes an ended turn's stream. */
|
|
@@ -8065,6 +8087,7 @@ var RetainedObservation = class {
|
|
|
8065
8087
|
lastObservedAt = 0;
|
|
8066
8088
|
silenceHandledAt;
|
|
8067
8089
|
exactResult;
|
|
8090
|
+
exactResultFailure;
|
|
8068
8091
|
exactResultSettled = false;
|
|
8069
8092
|
exactResultSettledAt = 0;
|
|
8070
8093
|
observedFrames = 0;
|
|
@@ -8181,11 +8204,14 @@ var RetainedObservation = class {
|
|
|
8181
8204
|
this.exactResult = awaitAbortable(Promise.resolve().then(read), this.signal);
|
|
8182
8205
|
const settle = (...failed) => {
|
|
8183
8206
|
if (this.observedFrames === 0) this.lastObservedAt = Date.now();
|
|
8184
|
-
const
|
|
8207
|
+
const rejected = failed.length > 0;
|
|
8208
|
+
const quotaRefused = rejected && exactQuotaRefusal(failed[0]) !== void 0;
|
|
8209
|
+
const retry = !retried && rejected && !quotaRefused;
|
|
8185
8210
|
if (retry) this.exactResult = void 0;
|
|
8186
8211
|
else {
|
|
8187
8212
|
this.exactResultSettled = true;
|
|
8188
8213
|
this.exactResultSettledAt = Date.now();
|
|
8214
|
+
if (rejected && !quotaRefused) this.exactResultFailure = { error: new Error(`retained provider exact-result read failed: ${observationFailureText({ error: failed[0] })}`, { cause: failed[0] }) };
|
|
8189
8215
|
}
|
|
8190
8216
|
for (const wake of [...this.exactWakers]) wake();
|
|
8191
8217
|
if (retry) this.readExactResult(true);
|
|
@@ -8307,7 +8333,7 @@ var RetainedObservation = class {
|
|
|
8307
8333
|
try {
|
|
8308
8334
|
while (true) {
|
|
8309
8335
|
if (this.framesAfterResult >= RETAINED_OBSERVATION_BATCH_EVENTS) {
|
|
8310
|
-
this.failure ??= { error: streamFailure(`retained provider stream sent ${RETAINED_OBSERVATION_BATCH_EVENTS} frames after its exact result; the rest were not read`) };
|
|
8336
|
+
this.failure ??= this.exactResultFailure ?? { error: streamFailure(`retained provider stream sent ${RETAINED_OBSERVATION_BATCH_EVENTS} frames after its exact result; the rest were not read`) };
|
|
8311
8337
|
return true;
|
|
8312
8338
|
}
|
|
8313
8339
|
if (this.observedFrames % RETAINED_OBSERVATION_BATCH_EVENTS === 0 && this.observedFrames) await awaitAbortable(new Promise((resolve) => setImmediate(resolve)), this.signal);
|
|
@@ -8325,7 +8351,7 @@ var RetainedObservation = class {
|
|
|
8325
8351
|
return false;
|
|
8326
8352
|
}
|
|
8327
8353
|
if (observed.kind === "exact-result") {
|
|
8328
|
-
this.failure ??= { error: streamFailure("retained provider stream remained open after its exact result") };
|
|
8354
|
+
this.failure ??= this.exactResultFailure ?? { error: streamFailure("retained provider stream remained open after its exact result") };
|
|
8329
8355
|
return true;
|
|
8330
8356
|
}
|
|
8331
8357
|
this.pendingRead = void 0;
|
|
@@ -8553,7 +8579,7 @@ async function retainedExecution(args, retention, turn, selectedTurn, signal) {
|
|
|
8553
8579
|
executionAdmitted: args.recovering && retention.admissions.some((admission) => admission.phase === "dispatched")
|
|
8554
8580
|
};
|
|
8555
8581
|
const admissions = [...retention.admissions];
|
|
8556
|
-
const restart = hostRestartReconnect(signal);
|
|
8582
|
+
const restart = hostRestartReconnect(signal, retention.deadlineMs);
|
|
8557
8583
|
let reattach = false;
|
|
8558
8584
|
const onAdmission = async (admission) => {
|
|
8559
8585
|
if (admission.phase === "dispatched") proof.executionAdmitted = true;
|
|
@@ -8595,8 +8621,10 @@ async function retainedExecution(args, retention, turn, selectedTurn, signal) {
|
|
|
8595
8621
|
events: new RetainedObservation(handle, signal, retention).observe(session),
|
|
8596
8622
|
retained: true
|
|
8597
8623
|
};
|
|
8598
|
-
} catch (
|
|
8599
|
-
if (reattach = await restart.retry(
|
|
8624
|
+
} catch (thrown) {
|
|
8625
|
+
if (reattach = await restart.retry(thrown)) continue;
|
|
8626
|
+
const placing = admissions.every((admission) => admission.phase === "intent");
|
|
8627
|
+
const error = signal.aborted && placing ? restart.refused ?? thrown : thrown;
|
|
8600
8628
|
if (error instanceof RetainedMaterializationTimeoutError) throw error;
|
|
8601
8629
|
if (proof.admitted && !retainedSessionReplaced(error)) throw new RetainedExecutionPendingError(error, proof.executionAdmitted ? "execution" : "admission");
|
|
8602
8630
|
throw error;
|
|
@@ -12682,6 +12710,22 @@ const TERMINAL_STATUS = /* @__PURE__ */ new Set([
|
|
|
12682
12710
|
"stopped"
|
|
12683
12711
|
]);
|
|
12684
12712
|
/**
|
|
12713
|
+
* No box reached `running` within the ready budget. The platform did not refuse the shape, so a
|
|
12714
|
+
* later attempt can land: `failure` is the canonical `capacity` classification, which a supervised
|
|
12715
|
+
* node waits out and re-enters instead of failing its run. The message names the last refusal or
|
|
12716
|
+
* the box's last status; `cause` is that refusal.
|
|
12717
|
+
*/
|
|
12718
|
+
var SandboxAcquireTimeoutError = class extends Error {
|
|
12719
|
+
failure = {
|
|
12720
|
+
kind: "capacity",
|
|
12721
|
+
code: "sandbox_acquire_timeout"
|
|
12722
|
+
};
|
|
12723
|
+
constructor(message, options) {
|
|
12724
|
+
super(message, options);
|
|
12725
|
+
this.name = "SandboxAcquireTimeoutError";
|
|
12726
|
+
}
|
|
12727
|
+
};
|
|
12728
|
+
/**
|
|
12685
12729
|
* Cold-start-resilient sandbox acquisition: create by name, observe readiness from the sandbox's own status (not the create call), and re-attach after gateway timeouts.
|
|
12686
12730
|
*
|
|
12687
12731
|
* @experimental
|
|
@@ -12691,7 +12735,7 @@ async function acquireSandbox(client, options, acquire = {}) {
|
|
|
12691
12735
|
const now = acquire.now ?? Date.now;
|
|
12692
12736
|
const sleep$1 = acquire.sleep ?? ((ms) => sleep(ms, acquire.signal));
|
|
12693
12737
|
const pollMs = acquire.pollIntervalMs ?? 3e3;
|
|
12694
|
-
const
|
|
12738
|
+
const budgetMs = acquire.readyTimeoutMs ?? 6e5;
|
|
12695
12739
|
const appearScans = 5;
|
|
12696
12740
|
const name = options.name ?? acquire.name ?? `loop-sbx-${randomUuid()}`;
|
|
12697
12741
|
const createOpts = {
|
|
@@ -12699,53 +12743,60 @@ async function acquireSandbox(client, options, acquire = {}) {
|
|
|
12699
12743
|
name
|
|
12700
12744
|
};
|
|
12701
12745
|
const c = client;
|
|
12702
|
-
let
|
|
12703
|
-
|
|
12704
|
-
while (now() < deadline) {
|
|
12705
|
-
throwIfAborted(acquire.signal);
|
|
12746
|
+
for (let misses = 1;; misses += 1) {
|
|
12747
|
+
let boxed = false;
|
|
12706
12748
|
try {
|
|
12707
|
-
|
|
12708
|
-
|
|
12709
|
-
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
|
|
12749
|
+
const deadline = now() + budgetMs;
|
|
12750
|
+
let lastErr;
|
|
12751
|
+
let attempt = 0;
|
|
12752
|
+
while (now() < deadline) {
|
|
12753
|
+
throwIfAborted(acquire.signal);
|
|
12754
|
+
try {
|
|
12755
|
+
const box = await client.create(createOpts, acquire.signal === void 0 ? void 0 : { signal: acquire.signal });
|
|
12756
|
+
boxed = true;
|
|
12757
|
+
return await waitReadyOrDestroy(box, deadline, pollMs, acquire.signal, now, sleep$1);
|
|
12758
|
+
} catch (err) {
|
|
12759
|
+
throwIfAborted(acquire.signal);
|
|
12760
|
+
if (!isRetryable(err)) throw err;
|
|
12761
|
+
lastErr = err;
|
|
12762
|
+
if (typeof c.list === "function") for (let scan = 0; scan < appearScans && now() < deadline; scan += 1) {
|
|
12763
|
+
const found = (await c.list().catch(() => []))?.find((b) => b.name === name);
|
|
12764
|
+
if (found) {
|
|
12765
|
+
boxed = true;
|
|
12766
|
+
return await waitReadyOrDestroy(found, deadline, pollMs, acquire.signal, now, sleep$1);
|
|
12767
|
+
}
|
|
12768
|
+
if (scan < 4) await sleep$1(pollMs);
|
|
12769
|
+
}
|
|
12770
|
+
attempt += 1;
|
|
12771
|
+
await sleep$1(Math.min(pollMs * attempt, 15e3));
|
|
12772
|
+
}
|
|
12716
12773
|
}
|
|
12717
|
-
|
|
12718
|
-
|
|
12774
|
+
throw new SandboxAcquireTimeoutError(`acquireSandbox: could not acquire a running sandbox "${name}" within ${budgetMs} ms${lastErr instanceof Error ? `: ${lastErr.message}` : ""}`, { cause: lastErr instanceof Error ? lastErr : void 0 });
|
|
12775
|
+
} catch (error) {
|
|
12776
|
+
if (!(error instanceof SandboxAcquireTimeoutError && !boxed) || misses >= 3) throw error;
|
|
12777
|
+
await sleep$1(unavailablePauseMs(misses));
|
|
12719
12778
|
}
|
|
12720
12779
|
}
|
|
12721
|
-
throw new ValidationError$1(`acquireSandbox: could not acquire a running sandbox "${name}" within budget`, { cause: lastErr instanceof Error ? lastErr : void 0 });
|
|
12722
12780
|
}
|
|
12723
|
-
/**
|
|
12724
|
-
* that never reaches `running` (abort, terminal status,
|
|
12781
|
+
/** Wait for `running`. No status (minimal fakes) = ready. Terminal status throws. Any throw tears
|
|
12782
|
+
* the box down (best-effort) so a box that never reaches `running` (abort, terminal status,
|
|
12783
|
+
* budget) does not leak. */
|
|
12725
12784
|
async function waitReadyOrDestroy(box, deadline, pollMs, signal, now, sleep) {
|
|
12726
12785
|
try {
|
|
12727
|
-
|
|
12786
|
+
for (;;) {
|
|
12787
|
+
throwIfAborted(signal);
|
|
12788
|
+
const status = box.status;
|
|
12789
|
+
if (typeof status !== "string" || status === "running") return box;
|
|
12790
|
+
if (TERMINAL_STATUS.has(status)) throw new ValidationError$1(`acquireSandbox: sandbox ${box.id ?? "(unknown)"} is ${status}${box.error ? `: ${box.error}` : ""}`);
|
|
12791
|
+
if (now() >= deadline) throw new SandboxAcquireTimeoutError(`acquireSandbox: sandbox ${box.id ?? "(unknown)"} not running within budget (last status: ${status}${box.error ? `: ${box.error}` : ""})`);
|
|
12792
|
+
await sleep(pollMs);
|
|
12793
|
+
if (typeof box.refresh === "function") await box.refresh();
|
|
12794
|
+
}
|
|
12728
12795
|
} catch (err) {
|
|
12729
12796
|
await deleteBoxSafe(box);
|
|
12730
12797
|
throw err;
|
|
12731
12798
|
}
|
|
12732
12799
|
}
|
|
12733
|
-
/** Wait for `running`. No status (minimal fakes) = ready. Terminal status throws. */
|
|
12734
|
-
async function waitUntilReady(box, deadline, pollMs, signal, now, sleep) {
|
|
12735
|
-
for (;;) {
|
|
12736
|
-
throwIfAborted(signal);
|
|
12737
|
-
const status = readStatus(box);
|
|
12738
|
-
if (status === void 0 || status === "running") return box;
|
|
12739
|
-
if (TERMINAL_STATUS.has(status)) throw new ValidationError$1(`acquireSandbox: sandbox ${box.id ?? "(unknown)"} is ${status}${box.error ? `: ${box.error}` : ""}`);
|
|
12740
|
-
if (now() >= deadline) throw new ValidationError$1(`acquireSandbox: sandbox ${box.id ?? "(unknown)"} not running within budget (last status: ${status})`);
|
|
12741
|
-
await sleep(pollMs);
|
|
12742
|
-
if (typeof box.refresh === "function") await box.refresh();
|
|
12743
|
-
}
|
|
12744
|
-
}
|
|
12745
|
-
function readStatus(box) {
|
|
12746
|
-
const s = box.status;
|
|
12747
|
-
return typeof s === "string" ? s : void 0;
|
|
12748
|
-
}
|
|
12749
12800
|
function isRetryable(err) {
|
|
12750
12801
|
if (!err || typeof err !== "object") return false;
|
|
12751
12802
|
const e = err;
|
|
@@ -15484,7 +15535,8 @@ async function withRunParking(policy, runDir, runId, journal, now, signal, run)
|
|
|
15484
15535
|
waits: /* @__PURE__ */ new Map(),
|
|
15485
15536
|
parked,
|
|
15486
15537
|
park,
|
|
15487
|
-
handingOff: false
|
|
15538
|
+
handingOff: false,
|
|
15539
|
+
rootWakes: 0
|
|
15488
15540
|
}, run);
|
|
15489
15541
|
}
|
|
15490
15542
|
/** Run the root execution so a park decided by any of the run's waits rejects it at once. */
|
|
@@ -15500,6 +15552,22 @@ function raceRunParking(runId, scope, seal, run) {
|
|
|
15500
15552
|
return Promise.race([running, context.parked]);
|
|
15501
15553
|
}
|
|
15502
15554
|
/**
|
|
15555
|
+
* Await a root's wake on its children's events. Only here, or in its own parkable wait, is a root
|
|
15556
|
+
* free of work of its own, so only here may a child's wait park it. A park ends this wait, and a
|
|
15557
|
+
* wake that lands while the park is published takes no new step.
|
|
15558
|
+
*/
|
|
15559
|
+
async function awaitRootWake(scope, wake) {
|
|
15560
|
+
const context = parkingContext.getStore();
|
|
15561
|
+
if (context === void 0 || context.root?.scope !== scope) return wake;
|
|
15562
|
+
context.rootWakes += 1;
|
|
15563
|
+
try {
|
|
15564
|
+
const woken = await Promise.race([wake, context.parked]);
|
|
15565
|
+
return context.handingOff ? await context.parked : woken;
|
|
15566
|
+
} finally {
|
|
15567
|
+
context.rootWakes -= 1;
|
|
15568
|
+
}
|
|
15569
|
+
}
|
|
15570
|
+
/**
|
|
15503
15571
|
* Sleep through the existing wait path. The run may hand off once every live node is waiting
|
|
15504
15572
|
* here: the root on its own wait, any node on a seat reset at least SEAT_PARK_MIN_MS away. A run
|
|
15505
15573
|
* with other active work keeps its normal wait. No timer survives the handoff, and no provider
|
|
@@ -15565,14 +15633,19 @@ async function parkRun(context, waits, idleSince, events) {
|
|
|
15565
15633
|
wakeAt: new Date(earliest.wakeAt).toISOString()
|
|
15566
15634
|
};
|
|
15567
15635
|
for (const held of heldScopes(context)) closeScopeAdmission(held);
|
|
15568
|
-
|
|
15569
|
-
|
|
15570
|
-
|
|
15571
|
-
|
|
15572
|
-
|
|
15573
|
-
|
|
15574
|
-
|
|
15575
|
-
|
|
15636
|
+
try {
|
|
15637
|
+
await context.journal.appendEvent(context.runId, {
|
|
15638
|
+
kind: "run-parked",
|
|
15639
|
+
id: context.runId,
|
|
15640
|
+
...parking,
|
|
15641
|
+
seq: events.filter((event) => event.kind === "run-parked").length,
|
|
15642
|
+
at: new Date(context.now()).toISOString()
|
|
15643
|
+
});
|
|
15644
|
+
if (context.runDir !== void 0) await writeParkingProjection(context.runDir, context.runId, parking);
|
|
15645
|
+
} catch (failure) {
|
|
15646
|
+
context.park(failure);
|
|
15647
|
+
throw failure;
|
|
15648
|
+
}
|
|
15576
15649
|
const error = new RunParkedError(context.runId, parking);
|
|
15577
15650
|
if (waits.some((wait) => wait.scope !== root.scope)) root.seal(error);
|
|
15578
15651
|
context.park(error);
|
|
@@ -15587,6 +15660,7 @@ function heldScopes(context) {
|
|
|
15587
15660
|
function runIdle(context) {
|
|
15588
15661
|
const root = context.root;
|
|
15589
15662
|
if (root === void 0) return false;
|
|
15663
|
+
if (!context.waits.has(context.runId) && context.rootWakes === 0) return false;
|
|
15590
15664
|
if (heldScopes(context).some((held) => parkingDrains.get(held)?.idle() === false || held.workerCapacity.unconfirmed.length > 0)) return false;
|
|
15591
15665
|
return !(root.scope.observeTree?.() ?? root.scope.view).nodes.some((node) => node.id !== context.runId && isLiveNodeStatus(node.status) && !context.waits.has(node.id));
|
|
15592
15666
|
}
|
|
@@ -16505,6 +16579,6 @@ async function noWinner(settled, rejection) {
|
|
|
16505
16579
|
reason: "no-result-selected"
|
|
16506
16580
|
};
|
|
16507
16581
|
}
|
|
16508
|
-
export {
|
|
16582
|
+
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, awaitRootWake 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, assertRunParking 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, RunParkedError 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 };
|
|
16509
16583
|
|
|
16510
|
-
//# sourceMappingURL=supervisor-
|
|
16584
|
+
//# sourceMappingURL=supervisor-BFs4u2Vo.js.map
|