@tangle-network/agent-runtime 0.262.0 → 0.263.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/dist/{activation-CozZXBTg.d.ts → activation-DJlWM1JN.d.ts} +2 -2
- package/dist/{activation-C0AoYRgS.js → activation-D_sIIewf.js} +2 -2
- package/dist/{activation-C0AoYRgS.js.map → activation-D_sIIewf.js.map} +1 -1
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/{coordination-driver-COGC8FK2.js → coordination-driver-L9zH0kBx.js} +2 -2
- package/dist/{coordination-driver-COGC8FK2.js.map → coordination-driver-L9zH0kBx.js.map} +1 -1
- package/dist/{delegate-BC7Au73v.js → delegate-Cv-w2WgY.js} +2 -2
- package/dist/{delegate-BC7Au73v.js.map → delegate-Cv-w2WgY.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +2 -2
- package/dist/{graph-DgODOGWN.js → graph-Cusg4eAx.js} +3 -3
- package/dist/{graph-DgODOGWN.js.map → graph-Cusg4eAx.js.map} +1 -1
- package/dist/{improvement-cycle-DirqO-fX.js → improvement-cycle-_IPwoII2.js} +3 -3
- package/dist/{improvement-cycle-DirqO-fX.js.map → improvement-cycle-_IPwoII2.js.map} +1 -1
- package/dist/{index-B8tXCisZ.d.ts → index-DLYBQFyl.d.ts} +4 -4
- package/dist/index.d.ts +6 -6
- package/dist/index.js +7 -7
- package/dist/intelligence.d.ts +3 -3
- package/dist/intelligence.js +3 -3
- package/dist/kernel.d.ts +4 -4
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-BaZd1XIm.d.ts → loop-runner-bin-BL8--Dzr.d.ts} +3 -3
- package/dist/{loop-runner-bin-C9P1ELVv.js → loop-runner-bin-NWPIxiix.js} +3 -3
- package/dist/{loop-runner-bin-C9P1ELVv.js.map → loop-runner-bin-NWPIxiix.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 +5 -5
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-CHwN_S24.d.ts → openai-tools-B9x50W9Y.d.ts} +2 -2
- package/dist/profiles.d.ts +2 -2
- package/dist/{provision-supervisor-9FMwo-Es.js → provision-supervisor-CIKvsWDa.js} +3 -3
- package/dist/{provision-supervisor-9FMwo-Es.js.map → provision-supervisor-CIKvsWDa.js.map} +1 -1
- package/dist/{runtime-BXWVW51r.js → runtime-4NuCVO6X.js} +8 -8
- package/dist/{runtime-BXWVW51r.js.map → runtime-4NuCVO6X.js.map} +1 -1
- package/dist/{server-6g6KFwUC.js → server-BnYImvnx.js} +3 -3
- package/dist/{server-6g6KFwUC.js.map → server-BnYImvnx.js.map} +1 -1
- package/dist/{stream-agent-turn-u28hoxuR.d.ts → stream-agent-turn-Y5rUc6Q-.d.ts} +2 -2
- package/dist/{structural-rollout-WEfWpjub.js → structural-rollout-Bq3PNAun.js} +2 -2
- package/dist/{structural-rollout-WEfWpjub.js.map → structural-rollout-Bq3PNAun.js.map} +1 -1
- package/dist/{substrate-BeQiXkpa.d.ts → substrate-Ce302oia.d.ts} +2 -2
- package/dist/{supervise-BeAI8-On.js → supervise-RF3_8PuR.js} +13 -4
- package/dist/supervise-RF3_8PuR.js.map +1 -0
- package/dist/{supervisor-BGGvnXvV.js → supervisor-BeW08Ncp.js} +179 -21
- package/dist/supervisor-BeW08Ncp.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +12 -12
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-CP3iQ8Ji.d.ts → types-C-nszovv.d.ts} +72 -10
- package/package.json +1 -1
- package/dist/supervise-BeAI8-On.js.map +0 -1
- package/dist/supervisor-BGGvnXvV.js.map +0 -1
|
@@ -241,7 +241,7 @@ function exactContinuedControlRef(candidate, initial) {
|
|
|
241
241
|
return controlRef;
|
|
242
242
|
}
|
|
243
243
|
function assertInteractionBinding(controlRef, command) {
|
|
244
|
-
if (command.binding.runId !== controlRef.runId || command.binding.
|
|
244
|
+
if (command.binding.runId !== controlRef.runId || command.binding.environmentId !== controlRef.environmentId || command.binding.sessionId !== controlRef.sessionId || command.binding.executionId !== controlRef.executionId) throw new Error("interaction response command does not target this retained run");
|
|
245
245
|
}
|
|
246
246
|
function assertBoundaryBinding(controlRef, proof) {
|
|
247
247
|
if (proof.runId !== controlRef.runId || proof.provider !== controlRef.provider || proof.environmentId !== controlRef.environmentId || proof.sessionId !== controlRef.sessionId || proof.executionId !== controlRef.executionId || proof.requestDigest !== controlRef.requestDigest) throw new Error("native context proof does not identify this retained run");
|
|
@@ -355,11 +355,11 @@ function assertEventBinding(source, controlRef) {
|
|
|
355
355
|
if (checkSessionId && value.sessionId !== void 0 && value.sessionId !== controlRef.sessionId) throw new Error("provider returned an event for another retained session");
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
/** Validate the
|
|
358
|
+
/** Validate the retained coordinates. The nested provider names the inner adapter. */
|
|
359
359
|
function assertCanonicalEventBinding(controlRef, event) {
|
|
360
360
|
if (event.type !== "interaction") return;
|
|
361
361
|
const binding = event.request.binding;
|
|
362
|
-
if (binding.runId !== controlRef.runId || binding.
|
|
362
|
+
if (binding.runId !== controlRef.runId || binding.environmentId !== controlRef.environmentId || binding.sessionId !== controlRef.sessionId || binding.executionId !== controlRef.executionId || binding.interactionId !== event.request.id) throw new Error("provider returned an interaction for another retained execution");
|
|
363
363
|
}
|
|
364
364
|
function isRecord$3(value) {
|
|
365
365
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -9539,7 +9539,7 @@ function assertSandboxStatusBinding(status, controlRef) {
|
|
|
9539
9539
|
}
|
|
9540
9540
|
function assertInteractionCommandScope(command, controlRef) {
|
|
9541
9541
|
if (controlRef === void 0) return;
|
|
9542
|
-
if (command.binding.runId !== controlRef.runId || command.binding.
|
|
9542
|
+
if (command.binding.runId !== controlRef.runId || command.binding.environmentId !== controlRef.environmentId || command.binding.sessionId !== controlRef.sessionId || command.binding.executionId !== controlRef.executionId) throw new ValidationError("interaction response targeted a different execution");
|
|
9543
9543
|
}
|
|
9544
9544
|
function assertCancellationScope(request, controlRef) {
|
|
9545
9545
|
if (controlRef === void 0) throw new ValidationError("durable cancellation requires an exact wrapper run control reference");
|
|
@@ -13870,6 +13870,7 @@ function executorFailureReason(result) {
|
|
|
13870
13870
|
const PLATFORM_FAILURE_CODES = new Set([
|
|
13871
13871
|
"QUOTA_EXCEEDED",
|
|
13872
13872
|
"provider_quota_exceeded",
|
|
13873
|
+
"provider_quota_exhausted",
|
|
13873
13874
|
"buffer.overflow",
|
|
13874
13875
|
"TIMEOUT",
|
|
13875
13876
|
"ECONNRESET",
|
|
@@ -13893,7 +13894,7 @@ const PLATFORM_FAILURE_MESSAGES = [
|
|
|
13893
13894
|
/exceeds its JSON bound/u,
|
|
13894
13895
|
/No provider served model/u,
|
|
13895
13896
|
/Invalid API key/u,
|
|
13896
|
-
/provider_quota_exceeded|QUOTA_EXCEEDED|rate limit/iu,
|
|
13897
|
+
/provider_quota_exceeded|provider_quota_exhausted|QUOTA_EXCEEDED|rate limit/iu,
|
|
13897
13898
|
/is at its box cap/u,
|
|
13898
13899
|
/could not materialize the seat credential/u,
|
|
13899
13900
|
/OpenCode exited while a model step was still in progress/u,
|
|
@@ -16882,6 +16883,7 @@ const outsideKinds = /* @__PURE__ */ new Set([
|
|
|
16882
16883
|
"teardown-confirmed",
|
|
16883
16884
|
"environment-teardown",
|
|
16884
16885
|
"trace-unpropagated",
|
|
16886
|
+
"paused",
|
|
16885
16887
|
"node-inputs-resolved",
|
|
16886
16888
|
"edge-verdict",
|
|
16887
16889
|
"join-state"
|
|
@@ -16952,6 +16954,7 @@ async function replaySpawnTree(journal, blobs, root) {
|
|
|
16952
16954
|
if (ev.kind === "teardown-pending" || ev.kind === "teardown-confirmed") continue;
|
|
16953
16955
|
if (ev.kind === "environment-teardown") continue;
|
|
16954
16956
|
if (ev.kind === "trace-unpropagated") continue;
|
|
16957
|
+
if (ev.kind === "paused") continue;
|
|
16955
16958
|
if (ev.kind === "node-inputs-resolved") continue;
|
|
16956
16959
|
if (ev.kind === "edge-verdict") continue;
|
|
16957
16960
|
if (ev.kind === "join-state") continue;
|
|
@@ -22114,6 +22117,7 @@ function defaultSleep$1(ms, signal) {
|
|
|
22114
22117
|
*/
|
|
22115
22118
|
/** Runtime-owned provider evidence is written through this private scope capability. */
|
|
22116
22119
|
const runtimeOwnedProviderMeters = /* @__PURE__ */ new WeakMap();
|
|
22120
|
+
const pauseRecorders = /* @__PURE__ */ new WeakMap();
|
|
22117
22121
|
const recoveryStarters = /* @__PURE__ */ new WeakMap();
|
|
22118
22122
|
const retainedReleasers = /* @__PURE__ */ new WeakMap();
|
|
22119
22123
|
const teardownRetriers = /* @__PURE__ */ new WeakMap();
|
|
@@ -23249,6 +23253,16 @@ function createScope(args) {
|
|
|
23249
23253
|
admissionClosed = true;
|
|
23250
23254
|
});
|
|
23251
23255
|
runtimeOwnedProviderMeters.set(scope, async (spend, providerModel, detail, accountingOnly) => meterInternal(spend, detail, providerModel, accountingOnly));
|
|
23256
|
+
let pauseSeq = 0;
|
|
23257
|
+
pauseRecorders.set(scope, async (pause) => {
|
|
23258
|
+
await args.journal.appendEvent(args.root, {
|
|
23259
|
+
kind: "paused",
|
|
23260
|
+
id: args.parentId,
|
|
23261
|
+
...pause,
|
|
23262
|
+
seq: pauseSeq++,
|
|
23263
|
+
at: new Date(now()).toISOString()
|
|
23264
|
+
});
|
|
23265
|
+
});
|
|
23252
23266
|
if (args.ownerMaterialization !== void 0) {
|
|
23253
23267
|
const authoredProfile = args.ownerMaterialization.authoredProfile === void 0 ? void 0 : detachedSnapshot(args.ownerMaterialization.authoredProfile, "scope owner authored profile");
|
|
23254
23268
|
ownerMaterializationStates.set(scope, {
|
|
@@ -23406,6 +23420,15 @@ function meterRuntimeOwnedProviderAttempt(scope, spend, providerModel, detail) {
|
|
|
23406
23420
|
if (meter === void 0) throw new ValidationError$1("scope: Runtime-owned provider meter is not bound to this scope");
|
|
23407
23421
|
return meter(spend, providerModel, detail);
|
|
23408
23422
|
}
|
|
23423
|
+
/**
|
|
23424
|
+
* @internal Journal that this scope's owner paused on an unavailable upstream. The pause is the
|
|
23425
|
+
* owner's, so it is recorded against the owner node, beside its `metered` turns.
|
|
23426
|
+
*/
|
|
23427
|
+
function recordScopeOwnerPause(scope, pause) {
|
|
23428
|
+
const record = pauseRecorders.get(scope);
|
|
23429
|
+
if (record === void 0) throw new ValidationError$1("scope: pause recorder is not bound to this scope");
|
|
23430
|
+
return record(pause);
|
|
23431
|
+
}
|
|
23409
23432
|
/** @internal Meter Runtime-owned accounting that does not represent provider execution. */
|
|
23410
23433
|
function meterRuntimeOwnedAccounting(scope, spend, detail) {
|
|
23411
23434
|
const meter = runtimeOwnedProviderMeters.get(scope);
|
|
@@ -24844,7 +24867,8 @@ function unreportedSpend(total, prior) {
|
|
|
24844
24867
|
* Nothing here restarts children or replays work — it re-enters the driver, and the bridge backend
|
|
24845
24868
|
* reattaches the harness session because the execution id is bound durably per node.
|
|
24846
24869
|
*
|
|
24847
|
-
* Two classifications decide everything, and both are conservative
|
|
24870
|
+
* Two classifications decide everything a failure means, and both are conservative (a third, for
|
|
24871
|
+
* an upstream out of capacity, is described below):
|
|
24848
24872
|
*
|
|
24849
24873
|
* - TERMINAL failures are Runtime's own refusals: a `ValidationError`/`ConfigError` guard, an
|
|
24850
24874
|
* exhausted budget, an abort, a client-side transport status (401/404/422). Runtime meant them,
|
|
@@ -24892,6 +24916,16 @@ function unreportedSpend(total, prior) {
|
|
|
24892
24916
|
* read only the count cap, budget, and deadline, so a director with `repromptOnUnmet: 100` or
|
|
24893
24917
|
* `'until-complete'` that delivered nothing was re-prompted until the budget or deadline ended it;
|
|
24894
24918
|
* the old prompt-owned loop logged 896 of 1,011 rounds with no progress.
|
|
24919
|
+
*
|
|
24920
|
+
* A THIRD CLASS sits between the two: the upstream said "not now". A model provider's exhausted
|
|
24921
|
+
* quota, a rate limit, or an overloaded service (HTTP 429, 503, 529, or the router's own codes for
|
|
24922
|
+
* them) is not an accident in the driver and not a decision by Runtime; the same request succeeds
|
|
24923
|
+
* when capacity returns. Such a failure PAUSES the driver and re-enters it. A pause consumes neither
|
|
24924
|
+
* `maxAttempts` nor the barren streak, so only the deadline, the budget, and cancellation bound it.
|
|
24925
|
+
* Measured 2026-09-24 on play anomaly-referee-v3d: during the router's flash quota outage four of
|
|
24926
|
+
* five lead lanes ended `driver-failed` between minutes 101 and 118, after 12 to 13 attempts, while
|
|
24927
|
+
* the router answered some turns in between (one lead spent 1.7M and 3.3M input tokens on two of
|
|
24928
|
+
* them) and each run's budget and 8-hour deadline were almost untouched.
|
|
24895
24929
|
*/
|
|
24896
24930
|
/**
|
|
24897
24931
|
* The instruction a completed-but-undelivered drive is re-entered with when the caller supplies no
|
|
@@ -24917,6 +24951,8 @@ const DEFAULT_MAX_ATTEMPTS = 8;
|
|
|
24917
24951
|
const DEFAULT_MAX_BARREN_REPROMPTS = 2;
|
|
24918
24952
|
const DEFAULT_INITIAL_BACKOFF_MS = 2e3;
|
|
24919
24953
|
const DEFAULT_MAX_BACKOFF_MS = 3e4;
|
|
24954
|
+
const DEFAULT_UNAVAILABLE_PAUSE_MS = 15e3;
|
|
24955
|
+
const DEFAULT_MAX_UNAVAILABLE_PAUSE_MS = 3e5;
|
|
24920
24956
|
/**
|
|
24921
24957
|
* Bridge error classes the bridge itself never retries: a request that fails identically on
|
|
24922
24958
|
* every attempt, mapped below 5xx on its HTTP path (`parse_error` 400, the other two 501). On the
|
|
@@ -24952,25 +24988,92 @@ var HarnessTurnFailedError = class extends Error {
|
|
|
24952
24988
|
}
|
|
24953
24989
|
};
|
|
24954
24990
|
/**
|
|
24955
|
-
*
|
|
24956
|
-
*
|
|
24957
|
-
*
|
|
24958
|
-
*
|
|
24991
|
+
* Machine codes that say the upstream is out of capacity rather than that the request is wrong.
|
|
24992
|
+
* Each is a code an upstream publishes, not prose: the router's
|
|
24993
|
+
* (`lib/model-substitution.ts`, `lib/upstream-error-triage.ts`) and the OpenAI- and Anthropic-shaped
|
|
24994
|
+
* error types a relayed body carries.
|
|
24995
|
+
*/
|
|
24996
|
+
const UNAVAILABLE_CODES = /* @__PURE__ */ new Set([
|
|
24997
|
+
"provider_quota_exhausted",
|
|
24998
|
+
"provider_quota_exceeded",
|
|
24999
|
+
"provider_rate_limit",
|
|
25000
|
+
"upstream_unavailable",
|
|
25001
|
+
"rate_limit_exceeded",
|
|
25002
|
+
"rate_limit_error",
|
|
25003
|
+
"overloaded_error"
|
|
25004
|
+
]);
|
|
25005
|
+
/** 429 Too Many Requests, 503 Service Unavailable, and 529, which Anthropic uses for overload. */
|
|
25006
|
+
const UNAVAILABLE_STATUSES = /* @__PURE__ */ new Set([
|
|
25007
|
+
429,
|
|
25008
|
+
503,
|
|
25009
|
+
529
|
|
25010
|
+
]);
|
|
25011
|
+
/**
|
|
25012
|
+
* A harness that flattens the router's JSON body into its own failure text leaves the router's
|
|
25013
|
+
* code in that text: `opencode execution failed: No provider served model "..."
|
|
25014
|
+
* (provider_quota_exhausted)`. The code is matched as a whole token, and a status only in the
|
|
25015
|
+
* `status code <n>` framing a harness prints, so prose that merely mentions a quota does not match.
|
|
25016
|
+
*/
|
|
25017
|
+
function unavailableSignalInText(text) {
|
|
25018
|
+
for (const token of text.toLowerCase().matchAll(/[a-z_]+/gu)) if (UNAVAILABLE_CODES.has(token[0])) return token[0];
|
|
25019
|
+
const status = text.match(/\bstatus code (\d{3})\b/u)?.[1];
|
|
25020
|
+
return status !== void 0 && UNAVAILABLE_STATUSES.has(Number(status)) ? `http-${status}` : void 0;
|
|
25021
|
+
}
|
|
25022
|
+
/**
|
|
25023
|
+
* The code or status that marks `error` as an upstream capacity refusal, or `undefined`.
|
|
25024
|
+
*
|
|
25025
|
+
* A structured field is read first: a turn outcome's `errorCode`, a transport error's
|
|
25026
|
+
* `upstreamCode` and `status`, a provider SDK error's `status`. The failure text is read only when
|
|
25027
|
+
* no structured field decided, because a harness CLI reports the router's refusal as text.
|
|
25028
|
+
*/
|
|
25029
|
+
function upstreamUnavailableSignal(error) {
|
|
25030
|
+
if (!(error instanceof Error)) return void 0;
|
|
25031
|
+
if (error instanceof HarnessTurnFailedError) {
|
|
25032
|
+
const code = error.errorCode?.toLowerCase();
|
|
25033
|
+
if (code !== void 0 && UNAVAILABLE_CODES.has(code)) return code;
|
|
25034
|
+
return unavailableSignalInText(error.message);
|
|
25035
|
+
}
|
|
25036
|
+
if (error instanceof BackendTransportError) {
|
|
25037
|
+
const code = error.upstreamCode?.toLowerCase();
|
|
25038
|
+
if (code !== void 0 && UNAVAILABLE_CODES.has(code)) return code;
|
|
25039
|
+
if (error.status !== void 0) return UNAVAILABLE_STATUSES.has(error.status) ? `http-${error.status}` : void 0;
|
|
25040
|
+
return unavailableSignalInText(errorProperty(error, "message") ?? "");
|
|
25041
|
+
}
|
|
25042
|
+
if (error instanceof AgentEvalError$1) return void 0;
|
|
25043
|
+
const status = errorHttpStatus(error);
|
|
25044
|
+
if (status !== void 0) return UNAVAILABLE_STATUSES.has(status) ? `http-${status}` : void 0;
|
|
25045
|
+
return unavailableSignalInText(errorProperty(error, "message") ?? "");
|
|
25046
|
+
}
|
|
25047
|
+
/** True when the upstream refused for capacity and the same request will succeed later. */
|
|
25048
|
+
function isUpstreamUnavailable(error) {
|
|
25049
|
+
return upstreamUnavailableSignal(error) !== void 0;
|
|
25050
|
+
}
|
|
25051
|
+
/**
|
|
25052
|
+
* Classify one driver failure. Runtime's own typed refusals are decisions and stay terminal; an
|
|
25053
|
+
* upstream capacity refusal is `unavailable`; anything else foreign is an accident and is
|
|
25054
|
+
* retryable. A `BackendTransportError` is split by status because the taxonomy already promises
|
|
25055
|
+
* consumers may branch on it: a 5xx/408 is the upstream having a bad moment, a 429/503/529 is the
|
|
25056
|
+
* upstream out of capacity, and a 401/404/422 is a request that will fail identically forever. The
|
|
24959
25057
|
* bridge's own never-retry classes are terminal whether or not a status rides with them.
|
|
24960
25058
|
*/
|
|
24961
25059
|
function classifyDriverFailure(error, signal) {
|
|
24962
25060
|
if (signal?.aborted) return "terminal";
|
|
24963
25061
|
if (error instanceof Error && errorProperty(error, "name") === "AbortError") return "terminal";
|
|
24964
|
-
if (error instanceof HarnessTurnFailedError)
|
|
25062
|
+
if (error instanceof HarnessTurnFailedError) {
|
|
25063
|
+
if (error.errorCode !== void 0 && DETERMINISTIC_BRIDGE_CODES.has(error.errorCode)) return "terminal";
|
|
25064
|
+
return isUpstreamUnavailable(error) ? "unavailable" : "transient";
|
|
25065
|
+
}
|
|
24965
25066
|
if (error instanceof BackendTransportError) {
|
|
24966
25067
|
if (error.upstreamCode !== void 0 && DETERMINISTIC_BRIDGE_CODES.has(error.upstreamCode)) return "terminal";
|
|
25068
|
+
if (isUpstreamUnavailable(error)) return "unavailable";
|
|
24967
25069
|
const status = error.status;
|
|
24968
25070
|
if (status === void 0) return "transient";
|
|
24969
|
-
if (status === 408 || status
|
|
25071
|
+
if (status === 408 || status >= 500) return "transient";
|
|
24970
25072
|
return "terminal";
|
|
24971
25073
|
}
|
|
24972
25074
|
if (error instanceof ValidationError$1 || error instanceof ConfigError || error instanceof RuntimeRunStateError) return "terminal";
|
|
24973
25075
|
if (error instanceof AgentEvalError$1) return "terminal";
|
|
25076
|
+
if (isUpstreamUnavailable(error)) return "unavailable";
|
|
24974
25077
|
return foreignHttpStatusVerdict(error) ?? "transient";
|
|
24975
25078
|
}
|
|
24976
25079
|
/**
|
|
@@ -24983,15 +25086,16 @@ function classifyDriverFailure(error, signal) {
|
|
|
24983
25086
|
* times per node while the run showed a durable intent and no other event, so eleven of twelve
|
|
24984
25087
|
* roots sat for 25 minutes with nothing to diagnose. The status was on the error the whole time.
|
|
24985
25088
|
*
|
|
24986
|
-
* Reading it applies the same rule the transport branch already promises consumers: 408
|
|
24987
|
-
*
|
|
24988
|
-
*
|
|
25089
|
+
* Reading it applies the same rule the transport branch already promises consumers: 408 and 5xx
|
|
25090
|
+
* are the upstream having a bad moment, and any other 4xx is a request that will fail identically
|
|
25091
|
+
* forever. The capacity statuses were answered before this point. Anything without a plain numeric
|
|
25092
|
+
* status keeps the historical default.
|
|
24989
25093
|
*/
|
|
24990
25094
|
function foreignHttpStatusVerdict(error) {
|
|
24991
25095
|
if (!(error instanceof Error)) return void 0;
|
|
24992
25096
|
const status = errorHttpStatus(error);
|
|
24993
25097
|
if (status === void 0 || status < 400) return void 0;
|
|
24994
|
-
if (status === 408 || status
|
|
25098
|
+
if (status === 408 || status >= 500) return "transient";
|
|
24995
25099
|
return "terminal";
|
|
24996
25100
|
}
|
|
24997
25101
|
/** The budget's own verdict on whether another attempt may run at all. */
|
|
@@ -25028,7 +25132,9 @@ var DriverAttemptsExhaustedError = class extends RuntimeRunStateError {
|
|
|
25028
25132
|
const last = attempts[attempts.length - 1];
|
|
25029
25133
|
const causeText = cause instanceof Error ? `${errorProperty(cause, "name")}: ${errMessage(cause)}` : errMessage(cause);
|
|
25030
25134
|
const firstFailure = attempts.find((attempt) => attempt.error !== void 0)?.error;
|
|
25031
|
-
|
|
25135
|
+
const pauses = attempts.filter((attempt) => attempt.classification === "unavailable");
|
|
25136
|
+
const pausedMs = pauses.reduce((sum, attempt) => sum + (attempt.retryInMs ?? 0), 0);
|
|
25137
|
+
super(`supervisor driver failed after ${attempts.length} attempt(s) — stopped by ${stop}; ` + (pauses.length === 0 ? "" : `${pauses.length} attempt(s) met an unavailable upstream and paused ${Math.round(pausedMs / 1e3)} s in total; `) + (firstFailure !== void 0 && firstFailure !== last?.error ? `first failure: ${errorText(firstFailure)}; ` : "") + `last cause: ${causeText}` + (last?.classification ? ` (classified ${last.classification})` : ""), { cause });
|
|
25032
25138
|
this.attempts = Object.freeze([...attempts]);
|
|
25033
25139
|
this.stop = stop;
|
|
25034
25140
|
}
|
|
@@ -25039,10 +25145,13 @@ function summarizeDriverAttempts(records) {
|
|
|
25039
25145
|
for (const record of records) if (record.madeProgress) barren = 0;
|
|
25040
25146
|
else if (record.error === void 0 && record.reentry !== void 0 && record.contract === "unmet") barren += 1;
|
|
25041
25147
|
const last = records.at(-1);
|
|
25148
|
+
const refused = records.filter((record) => record.classification === "unavailable");
|
|
25042
25149
|
return {
|
|
25043
25150
|
attempts: records.length,
|
|
25044
25151
|
reprompts: records.filter((record) => record.reprompted === true).length,
|
|
25045
|
-
failureRetries: records.filter((record) => record.error !== void 0 && record.retryInMs !== void 0).length,
|
|
25152
|
+
failureRetries: records.filter((record) => record.error !== void 0 && record.retryInMs !== void 0 && record.classification !== "unavailable").length,
|
|
25153
|
+
unavailablePauses: refused.filter((record) => record.retryInMs !== void 0).length,
|
|
25154
|
+
unavailableMs: refused.reduce((sum, record) => sum + record.durationMs + (record.retryInMs ?? 0), 0),
|
|
25046
25155
|
barrenReentries: barren,
|
|
25047
25156
|
ended: last?.stop ?? "unrecorded",
|
|
25048
25157
|
...last?.repromptRefusedBy === void 0 ? {} : { repromptRefusedBy: last.repromptRefusedBy }
|
|
@@ -25069,6 +25178,8 @@ async function runDriverWithRetry(run) {
|
|
|
25069
25178
|
const maxAttempts = Math.max(1, policy.maxAttempts ?? DEFAULT_MAX_ATTEMPTS);
|
|
25070
25179
|
const initialBackoff = Math.max(0, policy.initialBackoffMs ?? DEFAULT_INITIAL_BACKOFF_MS);
|
|
25071
25180
|
const maxBackoff = Math.max(initialBackoff, policy.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS);
|
|
25181
|
+
const unavailablePause = Math.max(0, policy.unavailablePauseMs ?? DEFAULT_UNAVAILABLE_PAUSE_MS);
|
|
25182
|
+
const maxUnavailablePause = Math.max(unavailablePause, policy.maxUnavailablePauseMs ?? DEFAULT_MAX_UNAVAILABLE_PAUSE_MS);
|
|
25072
25183
|
const maxReprompts = run.reprompt?.maxReprompts ?? 0;
|
|
25073
25184
|
if (maxReprompts === "until-complete") {
|
|
25074
25185
|
const deadline = run.budget().deadlineMs;
|
|
@@ -25079,6 +25190,8 @@ async function runDriverWithRetry(run) {
|
|
|
25079
25190
|
let consecutiveBarren = 0;
|
|
25080
25191
|
let barrenReentries = 0;
|
|
25081
25192
|
let failures = 0;
|
|
25193
|
+
let consecutivePauses = 0;
|
|
25194
|
+
let pauses = 0;
|
|
25082
25195
|
let reprompts = 0;
|
|
25083
25196
|
let reentry;
|
|
25084
25197
|
const emit = async (record) => {
|
|
@@ -25130,10 +25243,54 @@ async function runDriverWithRetry(run) {
|
|
|
25130
25243
|
try {
|
|
25131
25244
|
await run.drive(attempt, reentry);
|
|
25132
25245
|
} catch (error) {
|
|
25133
|
-
failures += 1;
|
|
25134
25246
|
const durationMs = now() - startedAt;
|
|
25135
25247
|
const classification = classifyDriverFailure(error, run.signal);
|
|
25136
25248
|
const progressed = madeProgress(before, run.progress());
|
|
25249
|
+
if (classification === "unavailable") {
|
|
25250
|
+
if (progressed) barrenReentries = 0;
|
|
25251
|
+
const stop = (() => {
|
|
25252
|
+
if (!retryEnabled) return "retry-disabled";
|
|
25253
|
+
if (run.signal.aborted) return "aborted";
|
|
25254
|
+
return budgetStop(run.budget(), now());
|
|
25255
|
+
})();
|
|
25256
|
+
const unavailableSignal = upstreamUnavailableSignal(error) ?? "unavailable";
|
|
25257
|
+
if (stop !== void 0) {
|
|
25258
|
+
await emit({
|
|
25259
|
+
attempt,
|
|
25260
|
+
durationMs,
|
|
25261
|
+
error: errMessage(error),
|
|
25262
|
+
classification,
|
|
25263
|
+
madeProgress: progressed,
|
|
25264
|
+
unavailableSignal,
|
|
25265
|
+
stop
|
|
25266
|
+
});
|
|
25267
|
+
throw new DriverAttemptsExhaustedError(error, attempts, stop);
|
|
25268
|
+
}
|
|
25269
|
+
pauses += 1;
|
|
25270
|
+
consecutivePauses = progressed ? 1 : consecutivePauses + 1;
|
|
25271
|
+
const pause = Math.min(maxUnavailablePause, unavailablePause * 2 ** Math.max(0, consecutivePauses - 1));
|
|
25272
|
+
await emit({
|
|
25273
|
+
attempt,
|
|
25274
|
+
durationMs,
|
|
25275
|
+
error: errMessage(error),
|
|
25276
|
+
classification,
|
|
25277
|
+
madeProgress: progressed,
|
|
25278
|
+
unavailableSignal,
|
|
25279
|
+
retryInMs: pause
|
|
25280
|
+
});
|
|
25281
|
+
reentry = {
|
|
25282
|
+
reason: "upstream-unavailable",
|
|
25283
|
+
signal: unavailableSignal,
|
|
25284
|
+
pause: pauses
|
|
25285
|
+
};
|
|
25286
|
+
await sleep(pause, run.signal);
|
|
25287
|
+
if (run.signal.aborted) throw new DriverAttemptsExhaustedError(error, attempts, "aborted");
|
|
25288
|
+
const afterPause = budgetStop(run.budget(), now());
|
|
25289
|
+
if (afterPause) throw new DriverAttemptsExhaustedError(error, attempts, afterPause);
|
|
25290
|
+
continue;
|
|
25291
|
+
}
|
|
25292
|
+
consecutivePauses = 0;
|
|
25293
|
+
failures += 1;
|
|
25137
25294
|
const stop = (() => {
|
|
25138
25295
|
if (classification === "terminal") return "terminal-error";
|
|
25139
25296
|
if (!retryEnabled) return "retry-disabled";
|
|
@@ -25178,6 +25335,7 @@ async function runDriverWithRetry(run) {
|
|
|
25178
25335
|
continue;
|
|
25179
25336
|
}
|
|
25180
25337
|
consecutiveBarren = 0;
|
|
25338
|
+
consecutivePauses = 0;
|
|
25181
25339
|
const durationMs = now() - startedAt;
|
|
25182
25340
|
const after = run.progress();
|
|
25183
25341
|
const progressed = madeProgress(before, after);
|
|
@@ -26249,6 +26407,6 @@ function isNonEmptySpend(s) {
|
|
|
26249
26407
|
return s.iterations > 0 || s.tokens.input > 0 || s.tokens.output > 0 || s.usd > 0 || s.ms > 0 || s.tokensKnown === false || s.usdKnown === false || Object.values(s.resources ?? {}).some((resource) => resource.amount > 0 || !resource.known);
|
|
26250
26408
|
}
|
|
26251
26409
|
//#endregion
|
|
26252
|
-
export {
|
|
26410
|
+
export { attachWorker as $, stringifySafe as $i, runAbortable as $n, sandboxActProfileMaterialization as $r, AUTHORITY_MARKERS as $t, settledToIteration as A, projectSandboxOutcome as Ai, canonicalObservedModelParts as An, runWorktreeHarness as Ar, replaySpawnTree as At, prepareScopeRetainedOwnerTask as B, notifySandboxEventObserver as Bi, sandboxSessionTraceSource as Bn, terminateProcessTreeAndConfirm as Br, newUsageTotals as Bt, deriveNodeExecutionIdentity as C, runtimeOwnedScopeOwnerRuntime as Ci, createSandboxLineage as Cn, toOtelAttributes as Cr, FileSpawnJournal as Ct, recordScopeOwnerPause as D, executableAgentSpecSnapshot as Di, readPromptOptions as Dn, sanitizeKnowledgeReadinessReport as Dr, loadSpawnForest as Dt, recordScopeOwnerMaterialization as E, executableAgentProfileSnapshot as Ei, assertBoxlessPromptOptions as En, sanitizeAgentRuntimeEvent as Er, insideCursorNamespace as Et, validateWaitSpec as F, createSandboxUsageLedger as Fi, providerAsSandboxClient as Fn, LOCAL_HARNESSES as Fr, workerTraceAnalysisStore as Ft, scopeRetainedOwnerResult as G, chargedTokens as Gi, startRetainedRun as Gn, fullProfileMaterialization as Gr, workerTraceEnv as Gt, scopeRetainedOwnerContext as H, sandboxProgressEvents as Hi, retainedExecutorSeamKey as Hn, assertProfileMaterialization as Hr, spendFromUsageTotals as Ht, waitUntil as I, extractLlmCallEvent as Ii, resolveAgentEnvironmentProvider as In, harnessSupportsReasoningEffort as Ir, BudgetReconcileFault as It, hostDirectoryReader as J, hasCompleteCacheBreakdown as Ji, destroyInteractiveEnvironment as Jn, promptModelProfileMaterialization as Jr, taskToPrompt as Jt, SPAWN_RESOURCE_PATH_MAX_BYTES as K, cloneSpend as Ki, startRetainedRunInEnvironment as Kn, profileMaterializationAxes$1 as Kr, workerTraceHeaders as Kt, bindScopeRetainedOwnerEnvironmentId as L, isSandboxTerminalEvent as Li, sandboxClientAsProvider as Ln, localHarnessExecutable as Lr, assertValidBudget as Lt, isWaitOutcome as M, assertSandboxServedModel as Mi, DEFAULT_SANDBOX_IDLE_TIMEOUT_SECONDS as Mn, createWorktree as Mr, captureWorkerTraceEvidence as Mt, pollFor as N, canonicalStreamEventFromSandboxEvent as Ni, createAgentEnvironmentProviderRegistry as Nn, removeWorktree as Nr, isTraceAnalysisStore as Nt, restoreScopeOwnerAcceptedExecution as O, detachedFrozen as Oi, routerBrain as On, sanitizeRuntimeStreamEvent as Or, materializeTreeView as Ot, timerAt as P, createSandboxToolPartState as Pi, providerAsExecutor as Pn, DEFAULT_LOCAL_HARNESS as Pr, parseWorkerToolTraceArtifact as Pt, workerInteractiveAdmissionFile as Q, sleep as Qi, linkAbort as Qn, renderUnsupported as Qr, createInbox as Qt, bindScopeRetainedOwnerProvider as R, mapSandboxEvent as Ri, createPushTraceSource as Rn, parseCodexTokenUsage as Rr, createBudgetPool as Rt, createScope as S, runtimeOwnedPendingExecutorMaterialization as Si, runAgentRounds as Sn, padTraceId as Sr, FileResultBlobStore as St, meterRuntimeOwnedProviderAttempt as T, unknownMaterializationReceipt as Ti, acquireSandbox as Tn, createRuntimeStreamEventCollector as Tr, InMemorySpawnJournal as Tt, scopeRetainedOwnerPriorSpend as U, sumSandboxUsage as Ui, reconnectRetainedRun as Un, controlProfileMaterialization as Ur, WORKER_TRACE_PROPAGATION as Ut, reconcileScopeRetainedOwnerEnvironment as V, sandboxEventServedBackend as Vi, registerRetainedExecutorPreparation as Vn, AGENT_PROFILE_MATERIALIZATION_AXES as Vr, spendFromUsageEvents as Vt, scopeRetainedOwnerResourceReader as W, addSpend as Wi, recoverRetainedRun as Wn, defineProfileMaterializationContract as Wr, readWorkerTraceContext as Wt, interactiveAdmissionSeamKey as X, promptCacheTokenClasses as Xi, RunCancellationReason as Xn, promptResourceProfileMaterialization as Xr, createActivityLog as Xt, resolveSpawnResourcePaths as Y, isAbortError$2 as Yi, environmentGone as Yn, promptOnlyProfileMaterialization as Yr, DEFAULT_STALL_AFTER_MS as Yt, readWorkerInteractiveAdmissions as Z, randomSuffix as Zi, abortError as Zn, renderProfileMaterializationIssues as Zr, readWorkerProgress as Zt, driverExecutorFactory as _, providerMessageText as _a, recordRuntimeOwnedDriveHarnessProviderEvidence as _i, bridgeStopSignalKey as _n, exportEvalRuns as _r, snapshotExecutorConfig as _t, pickBestDelivered as a, addResourceSpend as aa, prepareJsonlAppend as ai, peerMailTools as an, persistHarnessTranscript as ar, startRetainedInteractiveRun as at, assertRecursiveReservationPolicy as b, runtimeOwnedExecutorMaterialization as bi, defaultSelectWinner as bn, loopEventToOtelSpan as br, createSteerableSandboxSession as bt, DEFAULT_MAX_BARREN_REPROMPTS as c, decodeHarnessUsage as ca, attestRuntimeOwnedPendingExecutor as ci, isTerminalNodeStatus as cn, mergeTraceEnv as cr, freeSlots as ct, classifyDriverFailure as d, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as da, finalizeRuntimeOwnedPendingExecutor as di, bridgeModelRouteRefusal as dn, INTELLIGENCE_WIRE_VERSION as dr, bindReusableExecutorExecutionId as dt, throwAbort as ea, unsupportedProfileDimensions as ei, DEFAULT_PEER_MAIL_LIMITS as en, defaultRedactor as er, readWorkerInteractiveBinding as et, defaultUnmetContractSteer as f, armDeadlineTimer as fa, inheritRuntimeOwnedExecutorAttestation as fi, addHarnessUsage as fn, buildLoopOtelSpans as fr, captureReusableExecutorConfig as ft, driverChild as g, promptOptionsFromAgentTurnInput as ga, providerAttemptEvidence as gi, bridgeRuntimeAttachmentsKey as gn, createOtelExporter as gr, createExecutorRegistry as gt, upstreamUnavailableSignal as h, promptFromAgentTurnInput as ha, newExecutionAttemptId as hi, readCodexRolloutSession as hn, createOpenInferenceFileExporter as hr, createExecutor as ht, collectDelivered as i, zeroSpend as ia, parseCommittedJsonLines as ii, isPeerMailEnvelope as in, harnessTranscriptArtifact as ir, recoverRetainedInteractiveRun as it, createWaitProbes as j, readSandboxOutcome as ji, observedModelMatchesDeclared as jn, captureWorktreeDiff as jr, WORKER_TOOL_TRACE_SCHEMA_VERSION as jt, scopeOwnerExecutorNodeContext as k, detachedSnapshot as ki, runBrainLoop as kn, runSettledCommand as kr, pendingWaits as kt, DriverAttemptsExhaustedError as l, abortError$2 as la, attestRuntimeOwnedScopeOwner as li, executorFailure as ln, readTraceContextFromEnv as lr, queueOf as lt, summarizeDriverAttempts as m, teardownSurfaces as ma, knownMaterializationReceipt as mi, harnessUsageIsEmpty as mn, buildRuntimeEventOtelSpans as mr, cliWorktreeExecutor as mt, createSupervisor as n, unmeteredSpend as na, worktreeCliProfileMaterialization as ni, claimsAuthority as nn, resolveRedactor as nr, workerInteractiveBindingsDir as nt, runFinalizer as o, resourceTelemetry as oa, readCommittedJsonLines as oi, peerMailVerbNames as on, contentAddress as or, errMessage as ot, runDriverWithRetry as p, teardownExecutor as pa, knownExecutionBindingReceipt as pi, createCodexRolloutStoreReader as pn, buildLoopSpanNodes as pr, cliInPlaceExecutor as pt, environmentReader as q, deleteBoxSafe as qi, retainedCreateMaterial as qn, promptControlProfileMaterialization as qr, workerTraceSeamKey as qt, bestDelivered as r, withTimeout as ra, isNoEntError as ri, createPeerMailbox as rn, captureHarnessTranscript as rr, reconnectRetainedInteractiveRun as rt, runTree as s, withBudgetResources as sa, writeAllBytes as si, isLiveNodeStatus as sn, createPropagatingTraceEmitter as sr, effectiveConcurrency as st, createRootHandle as t, throwIfAborted as ta, validateProfileMaterialization as ti, PEER_MAIL_WIRE_KEY as tn, defaultRedactorIdentityMaterial as tr, workerInteractiveBindingFile as tt, HarnessTurnFailedError as u, awaitAbortable$1 as ua, authoredProfileDigest as ui, bridgeAdmissionRefusal as un, traceContextToEnv as ur, rollingDispatch as ut, isDriverSpec as v, runtimeOwnedDriveHarnessProviderEvidence as vi, TERMINAL_DECISIONS as vn, flatOtelSpan as vr, createWorktreeCliExecutor as vt, meterRuntimeOwnedAccounting as w, unknownExecutionBindingReceipt as wi, probeSandboxCapabilities as wn, createRuntimeEventCollector as wr, InMemoryResultBlobStore as wt, beginScopeOwnerAttempt as x, runtimeOwnedExecutorProviderEvidence as xi, isTerminalDecision as xn, padSpanId as xr, createInPlaceCliExecutor as xt, withDriverExecutor as y, runtimeOwnedExecutorExecutionBinding as yi, createSandboxForSpec as yn, generateSpanId as yr, DEFAULT_SANDBOX_STEERING_MAX_TURNS as yt, consumeScopeRetainedOwnerResult as z, mapSandboxToolEvent as zi, decodeToolPart as zn, CodexExecutionDiagnosticError as zr, meterUsageEvent as zt };
|
|
26253
26411
|
|
|
26254
|
-
//# sourceMappingURL=supervisor-
|
|
26412
|
+
//# sourceMappingURL=supervisor-BeW08Ncp.js.map
|