@tangle-network/agent-runtime 0.264.0 → 0.266.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{activation-DHFdvps3.js → activation-BERiJjx5.js} +2 -2
- package/dist/{activation-DHFdvps3.js.map → activation-BERiJjx5.js.map} +1 -1
- package/dist/{activation-Bx4kfVU3.d.ts → activation-VpxSbDKJ.d.ts} +2 -2
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/{coordination-driver-Bz-H17bC.js → coordination-driver-DdZ-nh_4.js} +73 -39
- package/dist/coordination-driver-DdZ-nh_4.js.map +1 -0
- package/dist/{delegate-CwbWhX5W.js → delegate-Ajx_PVyu.js} +3 -3
- package/dist/delegate-Ajx_PVyu.js.map +1 -0
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +2 -2
- package/dist/{graph-5NrpTg0h.js → graph-CK50N9vG.js} +7 -5
- package/dist/graph-CK50N9vG.js.map +1 -0
- package/dist/{improvement-cycle-WRWcFyuO.js → improvement-cycle-GRPoHLm1.js} +3 -3
- package/dist/{improvement-cycle-WRWcFyuO.js.map → improvement-cycle-GRPoHLm1.js.map} +1 -1
- package/dist/{index-9wXpbjbX.d.ts → index-CU2mlMfc.d.ts} +59 -73
- 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-DPewOZMn.d.ts → loop-runner-bin-XKZXM08Q.d.ts} +3 -3
- package/dist/{loop-runner-bin-DC1Lm0nM.js → loop-runner-bin-cC16EPUq.js} +3 -3
- package/dist/{loop-runner-bin-DC1Lm0nM.js.map → loop-runner-bin-cC16EPUq.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-ByTMUJcD.d.ts → openai-tools-D3ajI_D2.d.ts} +2 -2
- package/dist/profiles.d.ts +2 -2
- package/dist/{provision-supervisor-BZ6_uBGR.js → provision-supervisor-Bf_bPaCv.js} +4 -4
- package/dist/{provision-supervisor-BZ6_uBGR.js.map → provision-supervisor-Bf_bPaCv.js.map} +1 -1
- package/dist/{runtime-CUZC75EX.js → runtime-hOLlAc1i.js} +938 -18
- package/dist/runtime-hOLlAc1i.js.map +1 -0
- package/dist/{server-KpdpN627.js → server-DOb67ohd.js} +3 -3
- package/dist/{server-KpdpN627.js.map → server-DOb67ohd.js.map} +1 -1
- package/dist/{stream-agent-turn-D1zelVx6.d.ts → stream-agent-turn-Gw9hLpBn.d.ts} +182 -3
- package/dist/{structural-rollout-D17I5CwF.js → structural-rollout-DV9YoQF6.js} +2 -2
- package/dist/{structural-rollout-D17I5CwF.js.map → structural-rollout-DV9YoQF6.js.map} +1 -1
- package/dist/{substrate-qQphD9f0.d.ts → substrate-CLt9S9ym.d.ts} +2 -2
- package/dist/{supervise-_DTVHXPC.js → supervise--njTtSL3.js} +77 -27
- package/dist/supervise--njTtSL3.js.map +1 -0
- package/dist/{supervisor-C26k7X5-.js → supervisor-B8UMAXya.js} +990 -401
- package/dist/supervisor-B8UMAXya.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-BV14WTyW.d.ts → types-CrnwLVYQ.d.ts} +204 -34
- package/package.json +2 -2
- package/dist/coordination-driver-Bz-H17bC.js.map +0 -1
- package/dist/delegate-CwbWhX5W.js.map +0 -1
- package/dist/graph-5NrpTg0h.js.map +0 -1
- package/dist/runtime-CUZC75EX.js.map +0 -1
- package/dist/supervise-_DTVHXPC.js.map +0 -1
- package/dist/supervisor-C26k7X5-.js.map +0 -1
|
@@ -5930,7 +5930,13 @@ const HARNESS_ROOTS = Object.freeze({
|
|
|
5930
5930
|
".claude/todos"
|
|
5931
5931
|
]),
|
|
5932
5932
|
codex: Object.freeze([".codex/sessions", ".codex/history.jsonl"]),
|
|
5933
|
-
opencode: Object.freeze([
|
|
5933
|
+
opencode: Object.freeze([
|
|
5934
|
+
".local/share/opencode/storage",
|
|
5935
|
+
".local/share/opencode/export",
|
|
5936
|
+
".local/share/opencode/log",
|
|
5937
|
+
".opencode/sessions",
|
|
5938
|
+
".opencode/messages"
|
|
5939
|
+
]),
|
|
5934
5940
|
pi: Object.freeze([".pi/agent/sessions"])
|
|
5935
5941
|
});
|
|
5936
5942
|
/**
|
|
@@ -7533,6 +7539,67 @@ function priceUnreceiptedWork(work) {
|
|
|
7533
7539
|
};
|
|
7534
7540
|
}
|
|
7535
7541
|
//#endregion
|
|
7542
|
+
//#region src/runtime/supervise/error-message.ts
|
|
7543
|
+
const maxCauseDepth = 4;
|
|
7544
|
+
const maxMessageLength = 32768;
|
|
7545
|
+
const maxPartLength = 2048;
|
|
7546
|
+
/** A persisted failure must explain its wrappers without exporting credentials or unbounded data. */
|
|
7547
|
+
function errorText(value) {
|
|
7548
|
+
let text;
|
|
7549
|
+
try {
|
|
7550
|
+
text = typeof value === "string" ? value : JSON.stringify(value) ?? String(value);
|
|
7551
|
+
} catch {
|
|
7552
|
+
text = "[unprintable rejection]";
|
|
7553
|
+
}
|
|
7554
|
+
return String(defaultRedactor(text)).slice(0, maxMessageLength);
|
|
7555
|
+
}
|
|
7556
|
+
function errorProperty(error, field) {
|
|
7557
|
+
try {
|
|
7558
|
+
const value = error[field];
|
|
7559
|
+
return value === void 0 ? void 0 : errorText(value).slice(0, field === "name" ? 256 : maxMessageLength);
|
|
7560
|
+
} catch {
|
|
7561
|
+
return `[unreadable error ${field}]`;
|
|
7562
|
+
}
|
|
7563
|
+
}
|
|
7564
|
+
/** An HTTP status carried on a thrown error, read without trusting its getter. Provider SDKs put
|
|
7565
|
+
* one on their own error classes, so this is how a refusal is recognised outside the transport
|
|
7566
|
+
* taxonomy — for the persisted message here, and for the driver's retry verdict. */
|
|
7567
|
+
function errorHttpStatus(error) {
|
|
7568
|
+
try {
|
|
7569
|
+
const status = Reflect.get(error, "status");
|
|
7570
|
+
return typeof status === "number" && Number.isInteger(status) && status >= 100 && status <= 599 ? status : void 0;
|
|
7571
|
+
} catch {
|
|
7572
|
+
return;
|
|
7573
|
+
}
|
|
7574
|
+
}
|
|
7575
|
+
/** Shared by child settlements, driver attempts, and the final no-winner result. */
|
|
7576
|
+
function errMessage(error) {
|
|
7577
|
+
const parts = [];
|
|
7578
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7579
|
+
let current = error;
|
|
7580
|
+
for (let depth = 0; depth <= maxCauseDepth; depth += 1) try {
|
|
7581
|
+
if (!(current instanceof Error)) {
|
|
7582
|
+
parts.push(errorText(current).slice(0, maxPartLength));
|
|
7583
|
+
break;
|
|
7584
|
+
}
|
|
7585
|
+
if (seen.has(current)) {
|
|
7586
|
+
parts.push("[circular]");
|
|
7587
|
+
break;
|
|
7588
|
+
}
|
|
7589
|
+
seen.add(current);
|
|
7590
|
+
const status = errorHttpStatus(current);
|
|
7591
|
+
const message = (status === void 0 ? "" : `HTTP ${status}: `) + (errorProperty(current, "message") ?? "");
|
|
7592
|
+
parts.push((depth === 0 ? message : `${errorProperty(current, "name")}: ${message}`).slice(0, maxPartLength));
|
|
7593
|
+
current = current.cause;
|
|
7594
|
+
if (current === void 0 || current === null) break;
|
|
7595
|
+
if (depth === maxCauseDepth) parts.push("[cause chain truncated]");
|
|
7596
|
+
} catch {
|
|
7597
|
+
parts.push("[unreadable error cause]");
|
|
7598
|
+
break;
|
|
7599
|
+
}
|
|
7600
|
+
return parts.join(": caused by ").slice(0, maxMessageLength);
|
|
7601
|
+
}
|
|
7602
|
+
//#endregion
|
|
7536
7603
|
//#region src/runtime/supervise/retained-executor.ts
|
|
7537
7604
|
/** Scope owns the durable writer; provider executors only publish sanitized admissions. */
|
|
7538
7605
|
const retainedExecutorSeamKey = "runtime.retainedExecutor";
|
|
@@ -7637,6 +7704,11 @@ var RetainedExecutionPendingError = class extends Error {
|
|
|
7637
7704
|
this.pendingCause = resolved;
|
|
7638
7705
|
}
|
|
7639
7706
|
};
|
|
7707
|
+
/** The execution id of a leaf's later invocation, derived from its `execution-input` sequence so
|
|
7708
|
+
* a recovery derives the same one. A first invocation keeps the node id. */
|
|
7709
|
+
function leafContinuationExecutionId(nodeId, inputSeq) {
|
|
7710
|
+
return `${nodeId}:input:${inputSeq}`;
|
|
7711
|
+
}
|
|
7640
7712
|
const retainedPreparations = /* @__PURE__ */ new WeakMap();
|
|
7641
7713
|
/** Reconstruct an admitted manager through its original composition boundary. @internal */
|
|
7642
7714
|
function registerRetainedExecutorPreparation(factory, prepare) {
|
|
@@ -7875,6 +7947,75 @@ function sandboxSessionTraceSource(box, sessionId, opts = {}) {
|
|
|
7875
7947
|
});
|
|
7876
7948
|
}
|
|
7877
7949
|
//#endregion
|
|
7950
|
+
//#region src/runtime/supervise/upstream-unavailable.ts
|
|
7951
|
+
/**
|
|
7952
|
+
* An upstream that cannot serve NOW: how Runtime recognizes one, and how long an agent waits for it.
|
|
7953
|
+
*
|
|
7954
|
+
* A model provider's exhausted quota, a rate limit, an overload, or the router's own refused
|
|
7955
|
+
* credential is not a fault in the agent: the same request succeeds when capacity returns. A
|
|
7956
|
+
* driver that meets one re-enters after a pause (`runDriverWithRetry`), and a leaf continues in
|
|
7957
|
+
* its environment after the same pause (`providerAsExecutor`). Both read the refusal and the pause
|
|
7958
|
+
* from here, so an outage costs a director and its workers the same number of turns.
|
|
7959
|
+
*
|
|
7960
|
+
* This module imports nothing, so the provider executor can read it without the error classes of
|
|
7961
|
+
* `../../errors`.
|
|
7962
|
+
*/
|
|
7963
|
+
/**
|
|
7964
|
+
* Machine codes that say the upstream cannot serve now rather than that the request is wrong.
|
|
7965
|
+
* Each is a code an upstream publishes, not prose: the router's
|
|
7966
|
+
* (`lib/model-substitution.ts`, `lib/upstream-error-triage.ts`) and the OpenAI- and Anthropic-shaped
|
|
7967
|
+
* error types a relayed body carries.
|
|
7968
|
+
*/
|
|
7969
|
+
const UNAVAILABLE_CODES = /* @__PURE__ */ new Set([
|
|
7970
|
+
"provider_quota_exhausted",
|
|
7971
|
+
"provider_quota_exceeded",
|
|
7972
|
+
"provider_rate_limit",
|
|
7973
|
+
"upstream_unavailable",
|
|
7974
|
+
"provider_key_invalid",
|
|
7975
|
+
"rate_limit_exceeded",
|
|
7976
|
+
"rate_limit_error",
|
|
7977
|
+
"overloaded_error"
|
|
7978
|
+
]);
|
|
7979
|
+
/** 429 Too Many Requests, 503 Service Unavailable, and 529, which Anthropic uses for overload. */
|
|
7980
|
+
const UNAVAILABLE_STATUSES = /* @__PURE__ */ new Set([
|
|
7981
|
+
429,
|
|
7982
|
+
503,
|
|
7983
|
+
529
|
|
7984
|
+
]);
|
|
7985
|
+
/**
|
|
7986
|
+
* A harness that flattens the router's JSON body into its own failure text leaves the router's
|
|
7987
|
+
* code in that text: `opencode execution failed: No provider served model "..."
|
|
7988
|
+
* (provider_quota_exhausted)`. The code is matched as a whole token, and a status only in the
|
|
7989
|
+
* `status code <n>` framing a harness prints, so prose that merely mentions a quota does not match.
|
|
7990
|
+
*/
|
|
7991
|
+
function unavailableSignalInText(text) {
|
|
7992
|
+
for (const token of text.toLowerCase().matchAll(/[a-z_]+/gu)) if (UNAVAILABLE_CODES.has(token[0])) return token[0];
|
|
7993
|
+
const status = text.match(/\bstatus code (\d{3})\b/u)?.[1];
|
|
7994
|
+
return status !== void 0 && UNAVAILABLE_STATUSES.has(Number(status)) ? `http-${status}` : void 0;
|
|
7995
|
+
}
|
|
7996
|
+
/**
|
|
7997
|
+
* The code or status that marks a failed turn outcome as an upstream capacity refusal, or
|
|
7998
|
+
* `undefined`. The outcome's own `errorCode` decides first; the failure text is read only when no
|
|
7999
|
+
* code decided, because a harness CLI reports the router's refusal as text.
|
|
8000
|
+
*/
|
|
8001
|
+
function unavailableSignalOfFailure(failure) {
|
|
8002
|
+
const code = failure.errorCode?.toLowerCase();
|
|
8003
|
+
if (code !== void 0 && UNAVAILABLE_CODES.has(code)) return code;
|
|
8004
|
+
return unavailableSignalInText(failure.error);
|
|
8005
|
+
}
|
|
8006
|
+
const DEFAULT_UNAVAILABLE_PAUSE_MS = 15e3;
|
|
8007
|
+
const DEFAULT_MAX_UNAVAILABLE_PAUSE_MS = 3e5;
|
|
8008
|
+
/**
|
|
8009
|
+
* The pause after the `consecutive`-th refusal in a row (1-based): the first pause, doubled per
|
|
8010
|
+
* earlier refusal, up to the ceiling. The one rule for a driver that re-enters and a leaf that
|
|
8011
|
+
* continues in its environment, so an outage costs both the same number of turns.
|
|
8012
|
+
*/
|
|
8013
|
+
function unavailablePauseMs(consecutive, policy = {}) {
|
|
8014
|
+
const first = Math.max(0, policy.unavailablePauseMs ?? DEFAULT_UNAVAILABLE_PAUSE_MS);
|
|
8015
|
+
const ceiling = Math.max(first, policy.maxUnavailablePauseMs ?? DEFAULT_MAX_UNAVAILABLE_PAUSE_MS);
|
|
8016
|
+
return Math.min(ceiling, first * 2 ** Math.max(0, consecutive - 1));
|
|
8017
|
+
}
|
|
8018
|
+
//#endregion
|
|
7878
8019
|
//#region src/runtime/environment-provider.ts
|
|
7879
8020
|
var ValidationError = class extends Error {
|
|
7880
8021
|
constructor(message, options) {
|
|
@@ -8043,6 +8184,11 @@ function providerTurnDefaults(options, context) {
|
|
|
8043
8184
|
const { prompt: _prompt, parts: _parts, model: _model, sessionId: _sessionId, signal: _signal, ...turn } = turnInputFromPrompt("", options);
|
|
8044
8185
|
return turn;
|
|
8045
8186
|
}
|
|
8187
|
+
/** What a leaf is told when it continues after a refused turn. The session carries its
|
|
8188
|
+
* conversation and the environment its files, so the instruction names neither the provider nor
|
|
8189
|
+
* the refusal: a director told the details of a provider failure spent its children probing the
|
|
8190
|
+
* infrastructure (discovery-lab AGENTS.md, measured 2026-09-11). */
|
|
8191
|
+
const LEAF_CONTINUATION_TASK = "Your previous turn was interrupted before it finished. This is the same task in the same session: your conversation so far and the files in your workspace are where you left them. Continue from where you stopped. Do not start over.";
|
|
8046
8192
|
/**
|
|
8047
8193
|
* Merge the declared turn defaults under one mapped turn.
|
|
8048
8194
|
*
|
|
@@ -8089,6 +8235,16 @@ function providerAsExecutor(provider, options = {}) {
|
|
|
8089
8235
|
return createProviderExecutor(provider, profile, ctx, selected.options, selected.identity);
|
|
8090
8236
|
};
|
|
8091
8237
|
}
|
|
8238
|
+
/**
|
|
8239
|
+
* Run a provider under a placement Runtime chose for the whole execution, such as a shared box.
|
|
8240
|
+
* The identity lands in the execution's materialization plan and binding, exactly where a
|
|
8241
|
+
* declared {@link ProviderPlacement} lands, so a record says which placement served it.
|
|
8242
|
+
* @internal
|
|
8243
|
+
*/
|
|
8244
|
+
function placedProviderExecutor(provider, options, identity) {
|
|
8245
|
+
if (options.placements !== void 0) throw new ValidationError("placedProviderExecutor: placements select within one provider");
|
|
8246
|
+
return (spec, ctx) => createProviderExecutor(provider, spec.profile, ctx, options, identity);
|
|
8247
|
+
}
|
|
8092
8248
|
function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
8093
8249
|
if (options.workspaceRetention !== void 0) assertProviderWorkspaceRetentionPort(options.workspaceRetention, `providerAsExecutor(${provider.name})`);
|
|
8094
8250
|
const controller = new AbortController();
|
|
@@ -8283,51 +8439,95 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
8283
8439
|
beginWorkspaceExecution();
|
|
8284
8440
|
const linked = linkAbort(ctx.signal, signal, controller.signal);
|
|
8285
8441
|
try {
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
profile,
|
|
8289
|
-
createProfile,
|
|
8442
|
+
const executionStartedAt = Date.now();
|
|
8443
|
+
let invocation = {
|
|
8290
8444
|
task,
|
|
8291
|
-
signal: linked.signal,
|
|
8292
|
-
...node === void 0 ? {} : { node },
|
|
8293
|
-
options,
|
|
8294
8445
|
retention,
|
|
8295
8446
|
executionId,
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8447
|
+
recovering
|
|
8448
|
+
};
|
|
8449
|
+
let carried;
|
|
8450
|
+
let refusalsInARow = 0;
|
|
8451
|
+
for (let attempt = 1;; attempt += 1) {
|
|
8452
|
+
const continued = carried !== void 0;
|
|
8453
|
+
const ended = yield* streamProviderExecutor({
|
|
8454
|
+
provider,
|
|
8455
|
+
profile,
|
|
8456
|
+
createProfile,
|
|
8457
|
+
task: invocation.task,
|
|
8458
|
+
signal: linked.signal,
|
|
8459
|
+
...node === void 0 ? {} : { node },
|
|
8460
|
+
options,
|
|
8461
|
+
retention: invocation.retention,
|
|
8462
|
+
executionId: invocation.executionId,
|
|
8463
|
+
trace,
|
|
8464
|
+
recovering: invocation.recovering,
|
|
8465
|
+
...carried === void 0 ? {} : { carried },
|
|
8466
|
+
executionStartedAt,
|
|
8467
|
+
mayContinue: options.unavailablePause !== false && options.workspaceRetention === void 0 && invocation.retention?.continueInvocation !== void 0,
|
|
8468
|
+
onRetained: (handle) => {
|
|
8469
|
+
retained = handle;
|
|
8470
|
+
},
|
|
8471
|
+
onPending: (value) => {
|
|
8472
|
+
pending = value;
|
|
8473
|
+
},
|
|
8474
|
+
onEnvironment: (env) => {
|
|
8475
|
+
if (continued) {
|
|
8476
|
+
if (env.id !== environment?.id) throw new ValidationError(`providerAsExecutor(${provider.name}): a continuation ran in environment ${env.id}, not ${environment?.id ?? "<none>"}`);
|
|
8477
|
+
environment = env;
|
|
8478
|
+
return;
|
|
8313
8479
|
}
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8480
|
+
environment = env;
|
|
8481
|
+
resetWorkspaceState(env);
|
|
8482
|
+
if (harnessTranscript.status === "unavailable" && harnessTranscript.reason === "execution-never-started") harnessTranscript = harnessTranscriptUnavailable("capture-did-not-run");
|
|
8483
|
+
finalizeRuntimeOwnedPendingExecutor(executor, {
|
|
8484
|
+
...plannedDeclaration,
|
|
8485
|
+
execution: {
|
|
8486
|
+
kind: "environment",
|
|
8487
|
+
id: env.id
|
|
8488
|
+
}
|
|
8489
|
+
}, plannedBinding);
|
|
8490
|
+
},
|
|
8491
|
+
onArtifact: (next) => {
|
|
8492
|
+
artifact = next;
|
|
8493
|
+
},
|
|
8494
|
+
onHarnessTranscript: (next) => {
|
|
8495
|
+
harnessTranscript = next;
|
|
8496
|
+
},
|
|
8497
|
+
onUnsettledFailure: () => {
|
|
8498
|
+
workspacePreservationRequired = true;
|
|
8499
|
+
},
|
|
8500
|
+
onPublishedSnapshot: (snapshot) => {
|
|
8501
|
+
workspacePublishedSnapshot = snapshot;
|
|
8502
|
+
},
|
|
8503
|
+
captureWorkspace,
|
|
8504
|
+
destroyEnvironment
|
|
8505
|
+
});
|
|
8506
|
+
const refusal = ended.unavailable;
|
|
8507
|
+
const continueInvocation = invocation.retention?.continueInvocation;
|
|
8508
|
+
if (refusal === void 0 || continueInvocation === void 0) return;
|
|
8509
|
+
refusalsInARow = ended.madeProgress ? 1 : refusalsInARow + 1;
|
|
8510
|
+
const pauseMs = unavailablePauseMs(refusalsInARow, options.unavailablePause || {});
|
|
8511
|
+
await invocation.retention?.onPause?.({
|
|
8512
|
+
attempt,
|
|
8513
|
+
signal: refusal.signal,
|
|
8514
|
+
cause: refusal.cause,
|
|
8515
|
+
attemptMs: ended.durationMs,
|
|
8516
|
+
pauseMs,
|
|
8517
|
+
madeProgress: ended.madeProgress
|
|
8518
|
+
});
|
|
8519
|
+
await sleep(pauseMs, linked.signal);
|
|
8520
|
+
linked.signal.throwIfAborted();
|
|
8521
|
+
const next = await continueInvocation(LEAF_CONTINUATION_TASK);
|
|
8522
|
+
if (next.executionId === void 0) throw new ValidationError(`providerAsExecutor(${provider.name}): a continuation has no execution id of its own`);
|
|
8523
|
+
carried = ended.spent;
|
|
8524
|
+
invocation = {
|
|
8525
|
+
task: LEAF_CONTINUATION_TASK,
|
|
8526
|
+
retention: next,
|
|
8527
|
+
executionId: next.executionId,
|
|
8528
|
+
recovering: false
|
|
8529
|
+
};
|
|
8530
|
+
}
|
|
8331
8531
|
} finally {
|
|
8332
8532
|
linked.release();
|
|
8333
8533
|
workspaceRunActive = false;
|
|
@@ -8487,6 +8687,7 @@ async function* streamProviderExecutor(args) {
|
|
|
8487
8687
|
let settled;
|
|
8488
8688
|
let failure;
|
|
8489
8689
|
let failed = false;
|
|
8690
|
+
let unavailable;
|
|
8490
8691
|
try {
|
|
8491
8692
|
const toolParts = createSandboxToolPartState();
|
|
8492
8693
|
for await (const event of source.events) {
|
|
@@ -8531,7 +8732,7 @@ async function* streamProviderExecutor(args) {
|
|
|
8531
8732
|
};
|
|
8532
8733
|
}
|
|
8533
8734
|
if ((args.options.requireTerminalEvent ?? true) && !terminal) throw new ValidationError(`providerAsExecutor(${args.provider.name}): stream ended without a terminal result/done/status event`);
|
|
8534
|
-
yield { kind: "iteration" };
|
|
8735
|
+
if (args.carried === void 0) yield { kind: "iteration" };
|
|
8535
8736
|
const harnessTranscript = await captureHarnessTranscript(environment, args.profile.harness, linked);
|
|
8536
8737
|
args.onHarnessTranscript(harnessTranscript);
|
|
8537
8738
|
const outcome = failures.finish();
|
|
@@ -8549,6 +8750,13 @@ async function* streamProviderExecutor(args) {
|
|
|
8549
8750
|
...sawCostEstimate ? { usdEstimated } : {},
|
|
8550
8751
|
ms: Date.now() - started
|
|
8551
8752
|
};
|
|
8753
|
+
const executionSpent = args.carried === void 0 ? spent : {
|
|
8754
|
+
...addSpend(args.carried, {
|
|
8755
|
+
...spent,
|
|
8756
|
+
iterations: 0
|
|
8757
|
+
}),
|
|
8758
|
+
ms: Date.now() - args.executionStartedAt
|
|
8759
|
+
};
|
|
8552
8760
|
const verdict = await args.options.validator?.validate(result, {
|
|
8553
8761
|
iteration: 0,
|
|
8554
8762
|
...args.node === void 0 ? {} : { node: args.node },
|
|
@@ -8570,7 +8778,15 @@ async function* streamProviderExecutor(args) {
|
|
|
8570
8778
|
outRef: contentRef$1(`provider:${args.provider.name}`, settledResult),
|
|
8571
8779
|
out: settledResult,
|
|
8572
8780
|
...verdict ? { verdict } : {},
|
|
8573
|
-
spent
|
|
8781
|
+
spent: executionSpent
|
|
8782
|
+
};
|
|
8783
|
+
const refusal = args.mayContinue && source.retained && result.outcome?.status === "failed" ? unavailableSignalOfFailure({
|
|
8784
|
+
error: result.outcome.error ?? "",
|
|
8785
|
+
...result.outcome.errorCode ? { errorCode: result.outcome.errorCode } : {}
|
|
8786
|
+
}) : void 0;
|
|
8787
|
+
if (refusal !== void 0) unavailable = {
|
|
8788
|
+
signal: refusal,
|
|
8789
|
+
cause: errorText(result.outcome?.error ?? "")
|
|
8574
8790
|
};
|
|
8575
8791
|
if (source.retained) await args.retention?.onResult(settled);
|
|
8576
8792
|
args.onPending(false);
|
|
@@ -8592,7 +8808,7 @@ async function* streamProviderExecutor(args) {
|
|
|
8592
8808
|
}
|
|
8593
8809
|
args.onHarnessTranscript(await captureHarnessTranscript(environment, args.profile.harness, linked));
|
|
8594
8810
|
} finally {
|
|
8595
|
-
if ((!source.retained || settled !== void 0 && !failed) && !(source.retained && args.retention?.preserveEnvironment) && (args.options.destroyOnSettle ?? true)) {
|
|
8811
|
+
if ((!source.retained || settled !== void 0 && !failed) && !(source.retained && args.retention?.preserveEnvironment) && !(unavailable !== void 0 && !failed) && (args.options.destroyOnSettle ?? true)) {
|
|
8596
8812
|
const cleanup = await args.destroyEnvironment();
|
|
8597
8813
|
if (!cleanup.destroyed) {
|
|
8598
8814
|
const error = new Error(cleanup.detail ?? "provider environment teardown was not confirmed");
|
|
@@ -8612,6 +8828,12 @@ async function* streamProviderExecutor(args) {
|
|
|
8612
8828
|
}
|
|
8613
8829
|
}
|
|
8614
8830
|
if (failed) throw failure;
|
|
8831
|
+
return {
|
|
8832
|
+
...unavailable === void 0 ? {} : { unavailable },
|
|
8833
|
+
...settled === void 0 ? {} : { spent: settled.spent },
|
|
8834
|
+
madeProgress: tokens.input > 0 || tokens.output > 0 || usd > 0,
|
|
8835
|
+
durationMs: Date.now() - started
|
|
8836
|
+
};
|
|
8615
8837
|
/**
|
|
8616
8838
|
* The catalog price of this execution's whole token total, under the first model id the catalog
|
|
8617
8839
|
* knows. Undefined when none prices, so an unpriced model settles with no estimate at all rather
|
|
@@ -8636,6 +8858,14 @@ async function* streamProviderExecutor(args) {
|
|
|
8636
8858
|
if (priced.usdKnown === false && priced.usdEstimated !== void 0) return priced.usdEstimated;
|
|
8637
8859
|
}
|
|
8638
8860
|
}
|
|
8861
|
+
/** This invocation's cumulative tokens as the execution's: a continuation adds what its earlier
|
|
8862
|
+
* invocations already reported. */
|
|
8863
|
+
function executionTokens(own) {
|
|
8864
|
+
if (args.carried === void 0) return own;
|
|
8865
|
+
const total = cloneTokenUsage(args.carried.tokens);
|
|
8866
|
+
addTokenUsage(total, own);
|
|
8867
|
+
return total;
|
|
8868
|
+
}
|
|
8639
8869
|
function* creditUsage(receipt, event) {
|
|
8640
8870
|
if (receipt === void 0) return;
|
|
8641
8871
|
if (receipt.model !== (args.profile.name ?? "agent")) observedModel = receipt.model;
|
|
@@ -8649,7 +8879,7 @@ async function* streamProviderExecutor(args) {
|
|
|
8649
8879
|
yield {
|
|
8650
8880
|
kind: "tokens",
|
|
8651
8881
|
mode: "cumulative",
|
|
8652
|
-
...tokens,
|
|
8882
|
+
...executionTokens(tokens),
|
|
8653
8883
|
...receipt.tokensKnown === false ? { tokensKnown: false } : {}
|
|
8654
8884
|
};
|
|
8655
8885
|
}
|
|
@@ -14468,7 +14698,7 @@ function readWorkerProgress(scope, executor, now, stallAfterMs = DEFAULT_STALL_A
|
|
|
14468
14698
|
startedAt: scope.startedAt,
|
|
14469
14699
|
lastActivityAt,
|
|
14470
14700
|
idleMs,
|
|
14471
|
-
stalled: live && idleMs > stallAfterMs,
|
|
14701
|
+
stalled: live && scope.status !== "queued" && idleMs > stallAfterMs,
|
|
14472
14702
|
stallAfterMs,
|
|
14473
14703
|
turns: executor?.turns ?? scope.turns,
|
|
14474
14704
|
tokens: scope.tokens,
|
|
@@ -14478,7 +14708,8 @@ function readWorkerProgress(scope, executor, now, stallAfterMs = DEFAULT_STALL_A
|
|
|
14478
14708
|
pendingMessages: executor?.pendingMessages ?? 0,
|
|
14479
14709
|
recentActivity: executor?.recentActivity ?? [],
|
|
14480
14710
|
...executor?.derived?.length ? { derived: executor.derived } : {},
|
|
14481
|
-
...note ? { note } : {}
|
|
14711
|
+
...note ? { note } : {},
|
|
14712
|
+
...scope.team ? { team: scope.team } : {}
|
|
14482
14713
|
};
|
|
14483
14714
|
}
|
|
14484
14715
|
//#endregion
|
|
@@ -15646,6 +15877,12 @@ function mergeBridgeObservedModel(current, next) {
|
|
|
15646
15877
|
* then a ceiling, not a measurement. It does not close admission the way the dollar channel does:
|
|
15647
15878
|
* tokens are always capped, so one unreported turn must not end the run.
|
|
15648
15879
|
*
|
|
15880
|
+
* A reservation the free balance cannot cover now can WAIT instead of failing (`reserve(b, holder,
|
|
15881
|
+
* { wait: true })`) when it would fit once the reservations still open return. It holds nothing
|
|
15882
|
+
* while it waits, so conservation is untouched. Waiting reservations are granted in the order they
|
|
15883
|
+
* asked, as settlements return budget, and are refused once no open reservation is left to return
|
|
15884
|
+
* any: then nothing could ever cover them.
|
|
15885
|
+
*
|
|
15649
15886
|
* A pool can be RESTORED from a prior process's durable record (same-host restart): measured
|
|
15650
15887
|
* committed spend is debited exactly once, and each child journaled as started but never settled
|
|
15651
15888
|
* is charged at its full declared ceiling — restart never mints capacity, and the unknown flags
|
|
@@ -15667,6 +15904,19 @@ var BudgetReconcileFault = class extends Error {
|
|
|
15667
15904
|
if (budgetViolation !== void 0) this.budgetViolation = budgetViolation;
|
|
15668
15905
|
}
|
|
15669
15906
|
};
|
|
15907
|
+
/**
|
|
15908
|
+
* A waiting reservation that can never be granted: every open reservation settled and the free
|
|
15909
|
+
* balance still cannot cover it. `shortfalls` are the channels that did not fit at that moment.
|
|
15910
|
+
*/
|
|
15911
|
+
var ReservationWaitRefused = class extends Error {
|
|
15912
|
+
reason = "budget-exhausted";
|
|
15913
|
+
shortfalls;
|
|
15914
|
+
constructor(shortfalls) {
|
|
15915
|
+
super(`budget-exhausted: nothing left running could return enough budget for this worker (${shortfalls.map((shortfall) => `${shortfall.channel} requested ${shortfall.requested}, free ${shortfall.free}`).join("; ")})`);
|
|
15916
|
+
this.name = "ReservationWaitRefused";
|
|
15917
|
+
this.shortfalls = shortfalls;
|
|
15918
|
+
}
|
|
15919
|
+
};
|
|
15670
15920
|
/** Reject malformed ceilings before they can mint capacity through negative reservations. */
|
|
15671
15921
|
function assertValidBudget(budget, label = "budget") {
|
|
15672
15922
|
const safeInteger = (value, field) => {
|
|
@@ -15877,71 +16127,143 @@ function createBudgetPool(root, runStartedAtMs, restore = {}) {
|
|
|
15877
16127
|
}
|
|
15878
16128
|
let nextTicketId = 0;
|
|
15879
16129
|
const open = /* @__PURE__ */ new Map();
|
|
15880
|
-
|
|
15881
|
-
|
|
15882
|
-
|
|
15883
|
-
|
|
15884
|
-
|
|
15885
|
-
|
|
15886
|
-
}
|
|
15887
|
-
for (const name of Object.keys(b.resources ?? {})) if (!resources.has(name)) throw new ValidationError$1(`resource ${name}: root must declare its limit`);
|
|
16130
|
+
/** Tickets admitted to wait for budget, in the order they asked. Each is also in `open`. */
|
|
16131
|
+
const waiting = [];
|
|
16132
|
+
/** Open tickets that hold nothing: waiting, or refused and not yet reconciled. */
|
|
16133
|
+
const holdingNothing = /* @__PURE__ */ new Set();
|
|
16134
|
+
/** Every channel `b` does not fit, measured against the free balance less `keep`. */
|
|
16135
|
+
function shortfallsFor(b, keep) {
|
|
15888
16136
|
const wantTokens = b.maxTokens;
|
|
15889
16137
|
const wantUsd = b.maxUsd ?? 0;
|
|
15890
16138
|
const wantIterations = b.maxIterations;
|
|
15891
16139
|
const shortfalls = [];
|
|
15892
|
-
const short = (channel, requested, free, closedByUnknownSpend = false) => {
|
|
16140
|
+
const short = (channel, requested, free, held, closedByUnknownSpend = false) => {
|
|
15893
16141
|
shortfalls.push({
|
|
15894
16142
|
channel,
|
|
15895
16143
|
requested,
|
|
15896
16144
|
free: closedByUnknownSpend ? 0 : Math.max(0, free),
|
|
16145
|
+
...closedByUnknownSpend || held <= 0 ? {} : { held },
|
|
15897
16146
|
...closedByUnknownSpend ? { closedByUnknownSpend: true } : {}
|
|
15898
16147
|
});
|
|
15899
16148
|
};
|
|
15900
16149
|
for (const [name, state] of resources) {
|
|
15901
16150
|
const limit = b.resources[name].limit;
|
|
15902
|
-
if (!state.known) short(`resource:${name}`, limit, 0, true);
|
|
15903
|
-
else if (limit > state.remaining) short(`resource:${name}`, limit, state.remaining);
|
|
15904
|
-
}
|
|
15905
|
-
if (usdCapped && usdTainted) short("usd", wantUsd, 0, true);
|
|
15906
|
-
|
|
15907
|
-
|
|
15908
|
-
if (
|
|
15909
|
-
|
|
15910
|
-
|
|
15911
|
-
|
|
15912
|
-
|
|
15913
|
-
|
|
15914
|
-
|
|
15915
|
-
|
|
15916
|
-
|
|
15917
|
-
|
|
16151
|
+
if (!state.known) short(`resource:${name}`, limit, 0, 0, true);
|
|
16152
|
+
else if (limit > state.remaining) short(`resource:${name}`, limit, state.remaining, state.reserved);
|
|
16153
|
+
}
|
|
16154
|
+
if (usdCapped && usdTainted) short("usd", wantUsd, 0, 0, true);
|
|
16155
|
+
const tokensFree = freeTokens - (keep?.tokens ?? 0);
|
|
16156
|
+
const iterationsFree = freeIterations - (keep?.iterations ?? 0);
|
|
16157
|
+
if (wantTokens > tokensFree) short("tokens", wantTokens, tokensFree, reservedTokens);
|
|
16158
|
+
if (wantIterations > iterationsFree) short("iterations", wantIterations, iterationsFree, reservedIterations);
|
|
16159
|
+
const usdFree = freeUsd - (keep?.usd ?? 0);
|
|
16160
|
+
if (usdCapped && !usdTainted && wantUsd > usdFree) short("usd", wantUsd, usdFree, reservedUsd);
|
|
16161
|
+
return shortfalls;
|
|
16162
|
+
}
|
|
16163
|
+
/** Whether every short channel would fit once the open reservations return what they hold. */
|
|
16164
|
+
function fitsAfterRefunds(shortfalls) {
|
|
16165
|
+
return shortfalls.every((shortfall) => shortfall.closedByUnknownSpend !== true && shortfall.requested <= shortfall.free + (shortfall.held ?? 0));
|
|
16166
|
+
}
|
|
16167
|
+
/** Move `b` from free to reserved. The caller has checked that it fits. */
|
|
16168
|
+
function take(b) {
|
|
15918
16169
|
for (const [name, state] of resources) {
|
|
15919
16170
|
const amount = b.resources[name].limit;
|
|
15920
16171
|
state.remaining -= amount;
|
|
15921
16172
|
state.reserved += amount;
|
|
15922
16173
|
}
|
|
15923
|
-
freeTokens -=
|
|
15924
|
-
reservedTokens +=
|
|
15925
|
-
freeIterations -=
|
|
15926
|
-
reservedIterations +=
|
|
16174
|
+
freeTokens -= b.maxTokens;
|
|
16175
|
+
reservedTokens += b.maxTokens;
|
|
16176
|
+
freeIterations -= b.maxIterations;
|
|
16177
|
+
reservedIterations += b.maxIterations;
|
|
16178
|
+
const wantUsd = b.maxUsd ?? 0;
|
|
15927
16179
|
if (wantUsd > 0) {
|
|
15928
16180
|
freeUsd -= wantUsd;
|
|
15929
16181
|
reservedUsd += wantUsd;
|
|
15930
16182
|
}
|
|
16183
|
+
}
|
|
16184
|
+
function ticketFor(id, b) {
|
|
16185
|
+
return {
|
|
16186
|
+
id,
|
|
16187
|
+
reserved: {
|
|
16188
|
+
...b.resources === void 0 ? {} : { resources: Object.fromEntries(Object.entries(b.resources).map(([name, value]) => [name, { ...value }])) },
|
|
16189
|
+
tokens: b.maxTokens,
|
|
16190
|
+
usd: b.maxUsd ?? 0,
|
|
16191
|
+
iterations: b.maxIterations,
|
|
16192
|
+
usdBudgeted: b.maxUsd !== void 0
|
|
16193
|
+
}
|
|
16194
|
+
};
|
|
16195
|
+
}
|
|
16196
|
+
/** Grant waiting tickets in the order they asked while the head fits. When the head does not
|
|
16197
|
+
* fit and no reservation is held that could return budget, nothing can ever cover it: refuse
|
|
16198
|
+
* it, and go on with the next. */
|
|
16199
|
+
function grantWaiting() {
|
|
16200
|
+
while (waiting.length > 0) {
|
|
16201
|
+
const head = waiting[0];
|
|
16202
|
+
const shortfalls = shortfallsFor(head.budget, head.keep);
|
|
16203
|
+
if (shortfalls.length === 0) {
|
|
16204
|
+
waiting.shift();
|
|
16205
|
+
take(head.budget);
|
|
16206
|
+
holdingNothing.delete(head.ticket.id);
|
|
16207
|
+
head.grant();
|
|
16208
|
+
continue;
|
|
16209
|
+
}
|
|
16210
|
+
if (open.size > holdingNothing.size) return;
|
|
16211
|
+
waiting.shift();
|
|
16212
|
+
head.refuse(new ReservationWaitRefused(shortfalls));
|
|
16213
|
+
}
|
|
16214
|
+
}
|
|
16215
|
+
function reserve(b, holder = { stage: "admitted" }, options = {}) {
|
|
16216
|
+
assertValidBudget(b, "reservation budget");
|
|
16217
|
+
for (const [name, state] of resources) {
|
|
16218
|
+
const wanted = b.resources?.[name];
|
|
16219
|
+
if (!wanted) throw new ValidationError$1(`resource ${name}: child must declare its limit`);
|
|
16220
|
+
if (wanted.unit !== state.unit) throw new ValidationError$1(`resource ${name}: unit mismatch`);
|
|
16221
|
+
}
|
|
16222
|
+
for (const name of Object.keys(b.resources ?? {})) if (!resources.has(name)) throw new ValidationError$1(`resource ${name}: root must declare its limit`);
|
|
16223
|
+
const wantUsd = b.maxUsd ?? 0;
|
|
16224
|
+
const keep = options.keep;
|
|
16225
|
+
const shortfalls = shortfallsFor(b, keep);
|
|
16226
|
+
if (shortfalls.length === 0 && wantUsd > 0 && !usdCapped) return {
|
|
16227
|
+
ok: false,
|
|
16228
|
+
reason: "usd-unbudgeted"
|
|
16229
|
+
};
|
|
16230
|
+
const queueAhead = options.wait === true && waiting.length > 0;
|
|
16231
|
+
if (shortfalls.length === 0 && !queueAhead) {
|
|
16232
|
+
take(b);
|
|
16233
|
+
const id = nextTicketId++;
|
|
16234
|
+
open.set(id, holder);
|
|
16235
|
+
return {
|
|
16236
|
+
ok: true,
|
|
16237
|
+
ticket: ticketFor(id, b)
|
|
16238
|
+
};
|
|
16239
|
+
}
|
|
16240
|
+
if (options.wait !== true || !fitsAfterRefunds(shortfalls)) return {
|
|
16241
|
+
ok: false,
|
|
16242
|
+
reason: "budget-exhausted",
|
|
16243
|
+
shortfalls
|
|
16244
|
+
};
|
|
15931
16245
|
const id = nextTicketId++;
|
|
15932
16246
|
open.set(id, holder);
|
|
16247
|
+
const ticket = ticketFor(id, b);
|
|
16248
|
+
let grant;
|
|
16249
|
+
let refuse;
|
|
16250
|
+
const granted = new Promise((resolve, reject) => {
|
|
16251
|
+
grant = resolve;
|
|
16252
|
+
refuse = reject;
|
|
16253
|
+
});
|
|
16254
|
+
granted.catch(() => void 0);
|
|
16255
|
+
holdingNothing.add(id);
|
|
16256
|
+
waiting.push({
|
|
16257
|
+
ticket,
|
|
16258
|
+
budget: b,
|
|
16259
|
+
keep,
|
|
16260
|
+
grant,
|
|
16261
|
+
refuse
|
|
16262
|
+
});
|
|
15933
16263
|
return {
|
|
15934
16264
|
ok: true,
|
|
15935
|
-
ticket
|
|
15936
|
-
|
|
15937
|
-
reserved: {
|
|
15938
|
-
...b.resources === void 0 ? {} : { resources: Object.fromEntries(Object.entries(b.resources).map(([name, value]) => [name, { ...value }])) },
|
|
15939
|
-
tokens: wantTokens,
|
|
15940
|
-
usd: wantUsd,
|
|
15941
|
-
iterations: wantIterations,
|
|
15942
|
-
usdBudgeted: b.maxUsd !== void 0
|
|
15943
|
-
}
|
|
15944
|
-
}
|
|
16265
|
+
ticket,
|
|
16266
|
+
granted
|
|
15945
16267
|
};
|
|
15946
16268
|
}
|
|
15947
16269
|
function attribute(ticket, holder) {
|
|
@@ -15956,7 +16278,18 @@ function createBudgetPool(root, runStartedAtMs, restore = {}) {
|
|
|
15956
16278
|
if (!open.has(ticket.id)) throw new Error(`budget pool: reconcile of unknown or already-settled ticket ${ticket.id}`);
|
|
15957
16279
|
assertValidSpend(spent, `budget pool ticket ${ticket.id} spend`);
|
|
15958
16280
|
validateResourceUnits(spent);
|
|
15959
|
-
const
|
|
16281
|
+
const heldNothing = holdingNothing.delete(ticket.id);
|
|
16282
|
+
if (heldNothing) {
|
|
16283
|
+
const index = waiting.findIndex((entry) => entry.ticket.id === ticket.id);
|
|
16284
|
+
if (index >= 0) waiting.splice(index, 1);
|
|
16285
|
+
}
|
|
16286
|
+
const held = heldNothing ? {
|
|
16287
|
+
tokens: 0,
|
|
16288
|
+
usd: 0,
|
|
16289
|
+
iterations: 0,
|
|
16290
|
+
resources: void 0
|
|
16291
|
+
} : ticket.reserved;
|
|
16292
|
+
const { tokens: rTokens, usd: rUsd, iterations: rIterations } = held;
|
|
15960
16293
|
const unknownUnderCap = usdCapped && spent.usdKnown === false;
|
|
15961
16294
|
const spentTokens = chargedTokens(spent.tokens);
|
|
15962
16295
|
const usdBudgeted = ticket.reserved.usdBudgeted !== false;
|
|
@@ -15995,9 +16328,10 @@ function createBudgetPool(root, runStartedAtMs, restore = {}) {
|
|
|
15995
16328
|
freeUsd = 0;
|
|
15996
16329
|
} else freeUsd += rUsd - spent.usd;
|
|
15997
16330
|
} else committedUsd += spent.usd;
|
|
15998
|
-
const resourceSettlement = commitResources(spent,
|
|
16331
|
+
const resourceSettlement = commitResources(spent, held.resources ?? {});
|
|
15999
16332
|
fault ??= resourceSettlement.fault;
|
|
16000
16333
|
overspent.push(...resourceSettlement.overspent);
|
|
16334
|
+
grantWaiting();
|
|
16001
16335
|
const violation = overspent.length === 0 ? void 0 : Object.freeze({ overspent: Object.freeze(overspent.map((entry) => Object.freeze(entry))) });
|
|
16002
16336
|
if (fault !== void 0) throw new BudgetReconcileFault(`budget pool: ${fault}`, violation);
|
|
16003
16337
|
return violation;
|
|
@@ -17007,6 +17341,7 @@ async function replaySpawnTree(journal, blobs, root) {
|
|
|
17007
17341
|
...ev.harnessTranscript === void 0 ? {} : { harnessTranscript: ev.harnessTranscript },
|
|
17008
17342
|
...ev.retainedExecution === void 0 ? {} : { retainedExecution: ev.retainedExecution },
|
|
17009
17343
|
...ev.retainedPendingCause === void 0 ? {} : { retainedPendingCause: ev.retainedPendingCause },
|
|
17344
|
+
...ev.subtree === void 0 ? {} : { subtree: ev.subtree },
|
|
17010
17345
|
...settlementTime(ev.at),
|
|
17011
17346
|
seq: ev.seq
|
|
17012
17347
|
});
|
|
@@ -17027,6 +17362,7 @@ async function replaySpawnTree(journal, blobs, root) {
|
|
|
17027
17362
|
...ev.harnessTranscript === void 0 ? {} : { harnessTranscript: ev.harnessTranscript },
|
|
17028
17363
|
...ev.retainedExecution === void 0 ? {} : { retainedExecution: ev.retainedExecution },
|
|
17029
17364
|
...ev.retainedPendingCause === void 0 ? {} : { retainedPendingCause: ev.retainedPendingCause },
|
|
17365
|
+
...ev.subtree === void 0 ? {} : { subtree: ev.subtree },
|
|
17030
17366
|
...settlementTime(ev.at),
|
|
17031
17367
|
seq: ev.seq
|
|
17032
17368
|
});
|
|
@@ -17048,6 +17384,7 @@ async function replaySpawnTree(journal, blobs, root) {
|
|
|
17048
17384
|
...budgetViolationOf(ev),
|
|
17049
17385
|
trace,
|
|
17050
17386
|
...ev.harnessTranscript === void 0 ? {} : { harnessTranscript: ev.harnessTranscript },
|
|
17387
|
+
...ev.subtree === void 0 ? {} : { subtree: ev.subtree },
|
|
17051
17388
|
...settlementTime(ev.at),
|
|
17052
17389
|
seq: ev.seq
|
|
17053
17390
|
});
|
|
@@ -19289,7 +19626,8 @@ function snapshotExecutorConfig(config) {
|
|
|
19289
19626
|
});
|
|
19290
19627
|
}
|
|
19291
19628
|
case "provider": {
|
|
19292
|
-
const { provider, registry, profileForCreate, taskToTurn, validator, workspaceRetention, ...decisionData } = config;
|
|
19629
|
+
const { provider, registry, profileForCreate, taskToTurn, validator, workspaceRetention, shared, ...decisionData } = config;
|
|
19630
|
+
if (shared !== void 0 && (decisionData.steering !== void 0 || decisionData.placements !== void 0 || workspaceRetention !== void 0)) throw new ValidationError$1("createExecutor(provider): shared placement cannot combine with steering, placements, or workspaceRetention");
|
|
19293
19631
|
const snapshot = detachedSnapshot(decisionData, "createExecutor provider config");
|
|
19294
19632
|
const resolvedProvider = resolveAgentEnvironmentProvider(provider, registry);
|
|
19295
19633
|
return Object.freeze({
|
|
@@ -19298,7 +19636,8 @@ function snapshotExecutorConfig(config) {
|
|
|
19298
19636
|
...profileForCreate === void 0 ? {} : { profileForCreate },
|
|
19299
19637
|
...taskToTurn === void 0 ? {} : { taskToTurn },
|
|
19300
19638
|
...validator === void 0 ? {} : { validator },
|
|
19301
|
-
...workspaceRetention === void 0 ? {} : { workspaceRetention }
|
|
19639
|
+
...workspaceRetention === void 0 ? {} : { workspaceRetention },
|
|
19640
|
+
...shared === void 0 ? {} : { shared }
|
|
19302
19641
|
});
|
|
19303
19642
|
}
|
|
19304
19643
|
case "sandbox": {
|
|
@@ -19490,13 +19829,22 @@ function createExecutor(config) {
|
|
|
19490
19829
|
return wrapper;
|
|
19491
19830
|
}
|
|
19492
19831
|
const profileForCreate = providerSeam.profileForCreate;
|
|
19832
|
+
const exactProfileForCreate = (profile) => {
|
|
19833
|
+
const prepared = executableAgentProfileSnapshot(profileForCreate?.(profile) ?? profile, "createExecutor(provider)");
|
|
19834
|
+
if (canonicalAgentProfileDigest(prepared) !== canonicalAgentProfileDigest(profile)) throw new ValidationError$1("createExecutor(provider): profileForCreate changed the exact AgentProfile; execution overlays are not allowed");
|
|
19835
|
+
return prepared;
|
|
19836
|
+
};
|
|
19837
|
+
const shared = providerSeam.shared;
|
|
19838
|
+
if (shared !== void 0 && shared.refusal(spec.profile) === void 0) {
|
|
19839
|
+
const { provider: _provider, registry: _registry, shared: _shared, defaults: _defaults, ...turnOptions } = providerSeam;
|
|
19840
|
+
return placedProviderExecutor(shared.providerFor(seamed.node === void 0 ? {} : { nodeId: seamed.node.nodeId }), {
|
|
19841
|
+
...turnOptions,
|
|
19842
|
+
profileForCreate: exactProfileForCreate
|
|
19843
|
+
}, shared.identity)(spec, seamed);
|
|
19844
|
+
}
|
|
19493
19845
|
return providerAsExecutor(provider, {
|
|
19494
19846
|
...providerSeam,
|
|
19495
|
-
profileForCreate:
|
|
19496
|
-
const prepared = executableAgentProfileSnapshot(profileForCreate?.(profile) ?? profile, "createExecutor(provider)");
|
|
19497
|
-
if (canonicalAgentProfileDigest(prepared) !== canonicalAgentProfileDigest(profile)) throw new ValidationError$1("createExecutor(provider): profileForCreate changed the exact AgentProfile; execution overlays are not allowed");
|
|
19498
|
-
return prepared;
|
|
19499
|
-
}
|
|
19847
|
+
profileForCreate: exactProfileForCreate
|
|
19500
19848
|
})(spec, seamed);
|
|
19501
19849
|
}
|
|
19502
19850
|
case "sandbox": {
|
|
@@ -19710,28 +20058,12 @@ function singleShotDriver(maxIterations) {
|
|
|
19710
20058
|
* recorded and STOPS further admission — the loop then drains what is already live and returns.
|
|
19711
20059
|
* It never retries a rejected spawn against the same pool, and it never spawns past `width`.
|
|
19712
20060
|
*
|
|
19713
|
-
* ──
|
|
19714
|
-
*
|
|
19715
|
-
*
|
|
19716
|
-
*
|
|
19717
|
-
*
|
|
19718
|
-
*
|
|
19719
|
-
* level. One shared Scope counter bounds every spawned manager and leaf in the recursive tree;
|
|
19720
|
-
* `spawn_worker` fails closed with `error: 'max-live-workers'` past it. Unset ⇒ NO tree cap.
|
|
19721
|
-
* `CoordinationToolsOptions.maxLiveWorkers` remains the local form for a toolbox mounted on a
|
|
19722
|
-
* caller-owned Scope that has no tree limit.
|
|
19723
|
-
* 2. `SandboxLineage`'s `maxConcurrency` / `DEFAULT_FORK_CONCURRENCY = 4`
|
|
19724
|
-
* (`src/runtime/sandbox-lineage.ts`) — kernel level. How many BOXES one `runAgentRounds` fork wave
|
|
19725
|
-
* provisions at once. It bounds a single leaf's fanout, not the supervisor's worker count.
|
|
19726
|
-
* 3. A host's own live-box governor (e.g. the kernel's `ComputeGovernor`, `maxSandboxes = 4`) — fleet
|
|
19727
|
-
* level. How many sandboxes may exist across the whole host process.
|
|
19728
|
-
*
|
|
19729
|
-
* The honest effective limit on simultaneous WORKERS is the minimum of the caps that apply to the
|
|
19730
|
-
* worker layer — (1) and (3). (2) is a different unit (boxes per fork wave inside one leaf) and
|
|
19731
|
-
* must not be min'd into it, or a 4-way fork inside one worker reads as a 4-worker ceiling.
|
|
19732
|
-
* `effectiveConcurrency` computes that minimum in one place so a host derives ONE number and
|
|
19733
|
-
* passes it to BOTH `maxLiveWorkers` and this dispatcher's `width`, instead of leaving a fleet
|
|
19734
|
-
* governor of 4 and an unset worker fence as unrelated numbers.
|
|
20061
|
+
* ── Concurrency ────────────────────────────────────────────────────────────────────────────────
|
|
20062
|
+
*
|
|
20063
|
+
* `width` bounds the children THIS dispatcher holds in flight. The tree-wide bound on working
|
|
20064
|
+
* agents is `SuperviseOptions.workerSlots` (`./worker-slots`): a spawn past it is queued by the
|
|
20065
|
+
* scope, not refused, so a `width` above the free slots only lengthens the allocator's queue.
|
|
20066
|
+
* `SandboxLineage`'s fork concurrency bounds boxes inside ONE leaf's fork wave, a different unit.
|
|
19735
20067
|
*
|
|
19736
20068
|
* ── Why this is not a copy of the kernel's batch loop ──────────────────────────────────────────
|
|
19737
20069
|
*
|
|
@@ -19820,23 +20152,6 @@ function freeSlots(liveCount, cap) {
|
|
|
19820
20152
|
if (cap === void 0 || cap <= 0) return null;
|
|
19821
20153
|
return Math.max(0, cap - liveCount);
|
|
19822
20154
|
}
|
|
19823
|
-
/**
|
|
19824
|
-
* The ONE honest effective limit on simultaneous workers: the minimum of the caps that actually
|
|
19825
|
-
* bound the worker layer. Ignores unset/non-positive caps; returns `undefined` when no cap applies
|
|
19826
|
-
* (uncapped — the conserved pool remains the only fence).
|
|
19827
|
-
*
|
|
19828
|
-
* Deliberately does NOT fold in `SandboxLineage`'s fork concurrency: that bounds boxes inside ONE
|
|
19829
|
-
* leaf's fork wave, a different unit. Folding it in would report a 4-worker ceiling for what is
|
|
19830
|
-
* really a 4-box fanout inside a single worker.
|
|
19831
|
-
*
|
|
19832
|
-
* Use it once, at the top of a run, and pass the result to BOTH `maxLiveWorkers` and a
|
|
19833
|
-
* dispatcher's `width` — that is what turns three unrelated numbers into one.
|
|
19834
|
-
*/
|
|
19835
|
-
function effectiveConcurrency(caps) {
|
|
19836
|
-
const applicable = [caps.maxLiveWorkers, caps.maxSandboxes].filter((c) => typeof c === "number" && c > 0);
|
|
19837
|
-
if (applicable.length === 0) return void 0;
|
|
19838
|
-
return Math.min(...applicable);
|
|
19839
|
-
}
|
|
19840
20155
|
/** Convenience: a `DispatchUnit` factory over a fixed array of tasks, for the common case where
|
|
19841
20156
|
* the queue is known up front and only the refill behavior is wanted. */
|
|
19842
20157
|
function queueOf(units, budget) {
|
|
@@ -19856,67 +20171,6 @@ function queueOf(units, budget) {
|
|
|
19856
20171
|
};
|
|
19857
20172
|
}
|
|
19858
20173
|
//#endregion
|
|
19859
|
-
//#region src/runtime/supervise/error-message.ts
|
|
19860
|
-
const maxCauseDepth = 4;
|
|
19861
|
-
const maxMessageLength = 32768;
|
|
19862
|
-
const maxPartLength = 2048;
|
|
19863
|
-
/** A persisted failure must explain its wrappers without exporting credentials or unbounded data. */
|
|
19864
|
-
function errorText(value) {
|
|
19865
|
-
let text;
|
|
19866
|
-
try {
|
|
19867
|
-
text = typeof value === "string" ? value : JSON.stringify(value) ?? String(value);
|
|
19868
|
-
} catch {
|
|
19869
|
-
text = "[unprintable rejection]";
|
|
19870
|
-
}
|
|
19871
|
-
return String(defaultRedactor(text)).slice(0, maxMessageLength);
|
|
19872
|
-
}
|
|
19873
|
-
function errorProperty(error, field) {
|
|
19874
|
-
try {
|
|
19875
|
-
const value = error[field];
|
|
19876
|
-
return value === void 0 ? void 0 : errorText(value).slice(0, field === "name" ? 256 : maxMessageLength);
|
|
19877
|
-
} catch {
|
|
19878
|
-
return `[unreadable error ${field}]`;
|
|
19879
|
-
}
|
|
19880
|
-
}
|
|
19881
|
-
/** An HTTP status carried on a thrown error, read without trusting its getter. Provider SDKs put
|
|
19882
|
-
* one on their own error classes, so this is how a refusal is recognised outside the transport
|
|
19883
|
-
* taxonomy — for the persisted message here, and for the driver's retry verdict. */
|
|
19884
|
-
function errorHttpStatus(error) {
|
|
19885
|
-
try {
|
|
19886
|
-
const status = Reflect.get(error, "status");
|
|
19887
|
-
return typeof status === "number" && Number.isInteger(status) && status >= 100 && status <= 599 ? status : void 0;
|
|
19888
|
-
} catch {
|
|
19889
|
-
return;
|
|
19890
|
-
}
|
|
19891
|
-
}
|
|
19892
|
-
/** Shared by child settlements, driver attempts, and the final no-winner result. */
|
|
19893
|
-
function errMessage(error) {
|
|
19894
|
-
const parts = [];
|
|
19895
|
-
const seen = /* @__PURE__ */ new Set();
|
|
19896
|
-
let current = error;
|
|
19897
|
-
for (let depth = 0; depth <= maxCauseDepth; depth += 1) try {
|
|
19898
|
-
if (!(current instanceof Error)) {
|
|
19899
|
-
parts.push(errorText(current).slice(0, maxPartLength));
|
|
19900
|
-
break;
|
|
19901
|
-
}
|
|
19902
|
-
if (seen.has(current)) {
|
|
19903
|
-
parts.push("[circular]");
|
|
19904
|
-
break;
|
|
19905
|
-
}
|
|
19906
|
-
seen.add(current);
|
|
19907
|
-
const status = errorHttpStatus(current);
|
|
19908
|
-
const message = (status === void 0 ? "" : `HTTP ${status}: `) + (errorProperty(current, "message") ?? "");
|
|
19909
|
-
parts.push((depth === 0 ? message : `${errorProperty(current, "name")}: ${message}`).slice(0, maxPartLength));
|
|
19910
|
-
current = current.cause;
|
|
19911
|
-
if (current === void 0 || current === null) break;
|
|
19912
|
-
if (depth === maxCauseDepth) parts.push("[cause chain truncated]");
|
|
19913
|
-
} catch {
|
|
19914
|
-
parts.push("[unreadable error cause]");
|
|
19915
|
-
break;
|
|
19916
|
-
}
|
|
19917
|
-
return parts.join(": caused by ").slice(0, maxMessageLength);
|
|
19918
|
-
}
|
|
19919
|
-
//#endregion
|
|
19920
20174
|
//#region src/runtime/retained-interactive-handle.ts
|
|
19921
20175
|
function createRetainedInteractiveRunHandle(environment, inputRef, capabilities, requestedStart) {
|
|
19922
20176
|
const ref = freezeInteractiveRef(inputRef);
|
|
@@ -20727,7 +20981,8 @@ function settlementFields(subject, settlement) {
|
|
|
20727
20981
|
...settlement.providerModel ? { providerModel: settlement.providerModel } : {},
|
|
20728
20982
|
...subject.budgetViolation ? { budgetViolation: subject.budgetViolation } : {},
|
|
20729
20983
|
trace: settlement.trace,
|
|
20730
|
-
...settlement.harnessTranscript ? { harnessTranscript: settlement.harnessTranscript } : {}
|
|
20984
|
+
...settlement.harnessTranscript ? { harnessTranscript: settlement.harnessTranscript } : {},
|
|
20985
|
+
...subject.subtree === void 0 ? {} : { subtree: subject.subtree }
|
|
20731
20986
|
};
|
|
20732
20987
|
}
|
|
20733
20988
|
/** `cancelled` keeps its `source` from the subject's own cancellation reason, so a released
|
|
@@ -20899,7 +21154,10 @@ async function prepareInterruptedExecutors(opts, events, signal, now, parentId =
|
|
|
20899
21154
|
for (const node of interrupted) {
|
|
20900
21155
|
signal.throwIfAborted();
|
|
20901
21156
|
const owned = events.filter((event) => event.id === node.id);
|
|
20902
|
-
const
|
|
21157
|
+
const inputs = owned.filter((event) => event.kind === "execution-input");
|
|
21158
|
+
const latestInput = inputs.at(-1);
|
|
21159
|
+
const current = latestInput === void 0 || inputs.length === 1 ? owned : owned.slice(owned.indexOf(latestInput));
|
|
21160
|
+
const recorded = current.find((event) => event.kind === "execution-result");
|
|
20903
21161
|
if (recorded) {
|
|
20904
21162
|
await assertRecordedResult(node, recorded, owned, opts);
|
|
20905
21163
|
if (!rootBudget) throw new RuntimeRunStateError("retained results have no original root budget");
|
|
@@ -20921,10 +21179,9 @@ async function prepareInterruptedExecutors(opts, events, signal, now, parentId =
|
|
|
20921
21179
|
});
|
|
20922
21180
|
continue;
|
|
20923
21181
|
}
|
|
20924
|
-
const admissions =
|
|
21182
|
+
const admissions = current.flatMap((event) => event.kind === "execution-admitted" ? [event.admission] : []);
|
|
20925
21183
|
if (!opts.recoverExecutor || admissions.length === 0 && !node.ownedTreeRoot) continue;
|
|
20926
|
-
const
|
|
20927
|
-
const taskRef = input?.kind === "execution-input" ? input.taskRef : void 0;
|
|
21184
|
+
const taskRef = inputs[0]?.taskRef;
|
|
20928
21185
|
if (!node.profileRef || !taskRef || !node.identity?.profileDigest || !node.identity.taskDigest) throw new RuntimeRunStateError(`cannot recover '${node.id}' without exact profile and task bytes`);
|
|
20929
21186
|
const profile = agentProfileSchema.parse(await opts.blobs.get(node.profileRef));
|
|
20930
21187
|
const task = await opts.blobs.get(taskRef);
|
|
@@ -20943,12 +21200,14 @@ async function prepareInterruptedExecutors(opts, events, signal, now, parentId =
|
|
|
20943
21200
|
if (!prepared) continue;
|
|
20944
21201
|
}
|
|
20945
21202
|
const priorMaterialization = owned.find((event) => event.kind === "materialized")?.receipt;
|
|
21203
|
+
const continuation = latestInput !== void 0 && inputs.length > 1 && node.ownedTreeRoot === void 0 ? await leafContinuation(node, owned, latestInput, opts) : void 0;
|
|
20946
21204
|
recoveries.push({
|
|
20947
21205
|
...detachedSnapshot({
|
|
20948
21206
|
spawned: node,
|
|
20949
21207
|
task,
|
|
20950
21208
|
admissions,
|
|
20951
|
-
...priorMaterialization === void 0 ? {} : { priorMaterialization }
|
|
21209
|
+
...priorMaterialization === void 0 ? {} : { priorMaterialization },
|
|
21210
|
+
...continuation === void 0 ? {} : { continuation }
|
|
20952
21211
|
}, "retained child recovery"),
|
|
20953
21212
|
spec: prepared?.spec ?? {
|
|
20954
21213
|
profile,
|
|
@@ -20984,6 +21243,23 @@ async function prepareInterruptedExecutors(opts, events, signal, now, parentId =
|
|
|
20984
21243
|
recoveries
|
|
20985
21244
|
};
|
|
20986
21245
|
}
|
|
21246
|
+
/**
|
|
21247
|
+
* The later invocation a leaf was running when its process stopped: its own task, and the
|
|
21248
|
+
* environment admission of the invocation before it, which it continued in. The execution id is
|
|
21249
|
+
* derived from the input sequence exactly as the live scope derived it.
|
|
21250
|
+
*/
|
|
21251
|
+
async function leafContinuation(node, owned, latestInput, opts) {
|
|
21252
|
+
const priorSession = [...owned.slice(0, owned.indexOf(latestInput))].reverse().flatMap((event) => event.kind === "execution-admitted" && event.admission.phase === "environment" ? [event.admission] : [])[0];
|
|
21253
|
+
if (priorSession === void 0) throw new RuntimeRunStateError(`cannot recover '${node.id}': its continuation names no environment it continued in`);
|
|
21254
|
+
const task = await opts.blobs.get(latestInput.taskRef);
|
|
21255
|
+
if (task === void 0 || contentAddress(task) !== latestInput.taskRef) throw new RuntimeRunStateError(`continuation task for '${node.id}' is missing or corrupt`);
|
|
21256
|
+
return {
|
|
21257
|
+
task,
|
|
21258
|
+
inputSeq: latestInput.seq,
|
|
21259
|
+
executionId: leafContinuationExecutionId(node.id, latestInput.seq),
|
|
21260
|
+
priorSession
|
|
21261
|
+
};
|
|
21262
|
+
}
|
|
20987
21263
|
async function assertRecordedResult(node, result, events, opts) {
|
|
20988
21264
|
const before = events.slice(0, events.indexOf(result));
|
|
20989
21265
|
const receipt = before.find((event) => event.kind === "materialized")?.receipt;
|
|
@@ -22088,6 +22364,230 @@ function defaultSleep$1(ms, signal) {
|
|
|
22088
22364
|
return sleep(ms, signal);
|
|
22089
22365
|
}
|
|
22090
22366
|
//#endregion
|
|
22367
|
+
//#region src/runtime/supervise/worker-slots.ts
|
|
22368
|
+
/**
|
|
22369
|
+
* Worker slots: the one bound on how many spawned agents work at the same time.
|
|
22370
|
+
*
|
|
22371
|
+
* Every scope of a supervised tree draws from one allocator. A host that runs several trees in one
|
|
22372
|
+
* process can pass the same allocator to each of them, and the bound then holds across all of them.
|
|
22373
|
+
*
|
|
22374
|
+
* A spawn past the bound is never refused. It keeps its reserved budget slice and waits in a queue,
|
|
22375
|
+
* and it starts when a slot frees. The queue releases the deepest spawn first and then the oldest,
|
|
22376
|
+
* so a subtree that is already paid for finishes before the tree grows wider.
|
|
22377
|
+
*
|
|
22378
|
+
* A slot counts a working agent: a spawned agent that runs with no running child of its own. A
|
|
22379
|
+
* manager whose children are all running is waiting on them, so its first running child takes over
|
|
22380
|
+
* the manager's slot and the manager takes it back when its last running child ends. This makes
|
|
22381
|
+
* nested waits deadlock-free: a manager can always run one child on its own slot, so a queued subtree
|
|
22382
|
+
* always keeps a path to completion, whatever the bound and however deep the tree.
|
|
22383
|
+
*
|
|
22384
|
+
* The bound therefore limits working agents, not environments. The environments alive at one time
|
|
22385
|
+
* can exceed it by the number of managers that have a running child. The conserved budget pool and
|
|
22386
|
+
* the deadline bound the total work; this allocator only bounds how much of it runs at once.
|
|
22387
|
+
*
|
|
22388
|
+
* @experimental
|
|
22389
|
+
*/
|
|
22390
|
+
const allocatorStates = /* @__PURE__ */ new WeakMap();
|
|
22391
|
+
/**
|
|
22392
|
+
* Create a worker-slot allocator. `max` omitted, `0`, or negative leaves concurrency bounded by the
|
|
22393
|
+
* budget alone, and every spawn starts at once. Pass the returned allocator as `workerSlots` to each
|
|
22394
|
+
* run that should share one bound.
|
|
22395
|
+
*/
|
|
22396
|
+
function createWorkerSlots(max) {
|
|
22397
|
+
const bound = normalizeWorkerSlotBound(max);
|
|
22398
|
+
const state = {
|
|
22399
|
+
max: bound,
|
|
22400
|
+
working: 0,
|
|
22401
|
+
order: 0,
|
|
22402
|
+
waiters: []
|
|
22403
|
+
};
|
|
22404
|
+
const slots = Object.freeze({
|
|
22405
|
+
max: bound,
|
|
22406
|
+
get working() {
|
|
22407
|
+
return state.working;
|
|
22408
|
+
},
|
|
22409
|
+
get queued() {
|
|
22410
|
+
return state.waiters.length;
|
|
22411
|
+
}
|
|
22412
|
+
});
|
|
22413
|
+
allocatorStates.set(slots, state);
|
|
22414
|
+
return slots;
|
|
22415
|
+
}
|
|
22416
|
+
/** Accept a bound or an allocator; a number creates an allocator for one tree. */
|
|
22417
|
+
function resolveWorkerSlots(value) {
|
|
22418
|
+
if (value === void 0 || typeof value === "number") return createWorkerSlots(value);
|
|
22419
|
+
if (!allocatorStates.has(value)) throw new ValidationError$1("workerSlots must be a number or an allocator from createWorkerSlots");
|
|
22420
|
+
return value;
|
|
22421
|
+
}
|
|
22422
|
+
/** @internal Open the group of one scope's children. */
|
|
22423
|
+
function openSlotGroup(slots, owner) {
|
|
22424
|
+
const state = allocatorStates.get(slots);
|
|
22425
|
+
if (state === void 0) throw new ValidationError$1("openSlotGroup: allocator was not created by createWorkerSlots");
|
|
22426
|
+
const issued = owner === void 0 ? void 0 : deferredPermits.get(owner)?.() ?? owner;
|
|
22427
|
+
const ownerState = issued === void 0 ? void 0 : permitStates.get(issued);
|
|
22428
|
+
if (owner !== void 0 && ownerState === void 0) throw new ValidationError$1("openSlotGroup: owner permit was not issued by this allocator");
|
|
22429
|
+
const group = {
|
|
22430
|
+
owner: ownerState,
|
|
22431
|
+
running: 0,
|
|
22432
|
+
queued: 0
|
|
22433
|
+
};
|
|
22434
|
+
if (ownerState !== void 0) {
|
|
22435
|
+
if (ownerState.children !== void 0) throw new ValidationError$1("openSlotGroup: a permit owns at most one group of children");
|
|
22436
|
+
ownerState.children = group;
|
|
22437
|
+
}
|
|
22438
|
+
return {
|
|
22439
|
+
acquire: (depth, options) => acquire(state, group, depth, options?.force === true),
|
|
22440
|
+
get running() {
|
|
22441
|
+
return group.running;
|
|
22442
|
+
},
|
|
22443
|
+
get queued() {
|
|
22444
|
+
return group.queued;
|
|
22445
|
+
}
|
|
22446
|
+
};
|
|
22447
|
+
}
|
|
22448
|
+
const permitStates = /* @__PURE__ */ new WeakMap();
|
|
22449
|
+
/** Each deferred permit's reader of the permit it acquired, once it has acquired one. */
|
|
22450
|
+
const deferredPermits = /* @__PURE__ */ new WeakMap();
|
|
22451
|
+
/**
|
|
22452
|
+
* @internal A slot requested only once `after` resolves. A spawn that waits for budget takes no
|
|
22453
|
+
* slot while it waits, so it cannot hold a slot that the work it waits on needs. `ready` rejects
|
|
22454
|
+
* when `after` does; `release` before then withdraws the request.
|
|
22455
|
+
*/
|
|
22456
|
+
function deferSlot(after, acquire) {
|
|
22457
|
+
let inner;
|
|
22458
|
+
let released = false;
|
|
22459
|
+
const ready = after.then(() => {
|
|
22460
|
+
if (released) return;
|
|
22461
|
+
inner = acquire();
|
|
22462
|
+
return inner.ready;
|
|
22463
|
+
});
|
|
22464
|
+
ready.catch(() => void 0);
|
|
22465
|
+
const handle = {
|
|
22466
|
+
ready,
|
|
22467
|
+
get granted() {
|
|
22468
|
+
return inner?.granted ?? false;
|
|
22469
|
+
},
|
|
22470
|
+
release() {
|
|
22471
|
+
if (released) return;
|
|
22472
|
+
released = true;
|
|
22473
|
+
inner?.release();
|
|
22474
|
+
}
|
|
22475
|
+
};
|
|
22476
|
+
deferredPermits.set(handle, () => inner);
|
|
22477
|
+
return handle;
|
|
22478
|
+
}
|
|
22479
|
+
function acquire(state, group, depth, force) {
|
|
22480
|
+
if (!Number.isSafeInteger(depth) || depth < 0) throw new ValidationError$1(`worker slots: depth must be a non-negative integer, got ${depth}`);
|
|
22481
|
+
const permit = {
|
|
22482
|
+
group,
|
|
22483
|
+
granted: false,
|
|
22484
|
+
released: false,
|
|
22485
|
+
counted: false
|
|
22486
|
+
};
|
|
22487
|
+
let resolveReady;
|
|
22488
|
+
const ready = new Promise((resolve) => {
|
|
22489
|
+
resolveReady = resolve;
|
|
22490
|
+
});
|
|
22491
|
+
const grant = () => {
|
|
22492
|
+
grantPermit(state, permit);
|
|
22493
|
+
resolveReady();
|
|
22494
|
+
};
|
|
22495
|
+
if (force || costOf(group) === 0 || hasCapacity(state)) grant();
|
|
22496
|
+
else {
|
|
22497
|
+
group.queued += 1;
|
|
22498
|
+
const waiter = {
|
|
22499
|
+
permit,
|
|
22500
|
+
depth,
|
|
22501
|
+
order: state.order++,
|
|
22502
|
+
grant
|
|
22503
|
+
};
|
|
22504
|
+
state.waiters.push(waiter);
|
|
22505
|
+
}
|
|
22506
|
+
const handle = {
|
|
22507
|
+
ready,
|
|
22508
|
+
get granted() {
|
|
22509
|
+
return permit.granted;
|
|
22510
|
+
},
|
|
22511
|
+
release() {
|
|
22512
|
+
if (permit.released) return;
|
|
22513
|
+
permit.released = true;
|
|
22514
|
+
if (!permit.granted) {
|
|
22515
|
+
withdraw(state, permit);
|
|
22516
|
+
return;
|
|
22517
|
+
}
|
|
22518
|
+
releasePermit(state, permit);
|
|
22519
|
+
pump(state);
|
|
22520
|
+
}
|
|
22521
|
+
};
|
|
22522
|
+
permitStates.set(handle, permit);
|
|
22523
|
+
return handle;
|
|
22524
|
+
}
|
|
22525
|
+
/** A child of `group` adds a working unit unless its manager is working on its own slot now, in
|
|
22526
|
+
* which case the child takes that slot over. */
|
|
22527
|
+
function costOf(group) {
|
|
22528
|
+
const owner = group.owner;
|
|
22529
|
+
return owner?.granted && !owner.released && owner.counted ? 0 : 1;
|
|
22530
|
+
}
|
|
22531
|
+
function hasCapacity(state) {
|
|
22532
|
+
return state.max === void 0 || state.working < state.max;
|
|
22533
|
+
}
|
|
22534
|
+
function grantPermit(state, permit) {
|
|
22535
|
+
const group = permit.group;
|
|
22536
|
+
if (costOf(group) === 0) group.owner.counted = false;
|
|
22537
|
+
else state.working += 1;
|
|
22538
|
+
permit.granted = true;
|
|
22539
|
+
permit.counted = true;
|
|
22540
|
+
group.running += 1;
|
|
22541
|
+
}
|
|
22542
|
+
function releasePermit(state, permit) {
|
|
22543
|
+
if ((permit.children?.running ?? 0) > 0) return;
|
|
22544
|
+
const group = permit.group;
|
|
22545
|
+
group.running -= 1;
|
|
22546
|
+
if (group.running < 0) throw new ValidationError$1("worker slots: a group released more than it ran");
|
|
22547
|
+
if (!permit.counted) return;
|
|
22548
|
+
permit.counted = false;
|
|
22549
|
+
const owner = group.owner;
|
|
22550
|
+
if (group.running === 0 && owner !== void 0 && owner.granted) {
|
|
22551
|
+
owner.counted = true;
|
|
22552
|
+
if (owner.released) releasePermit(state, owner);
|
|
22553
|
+
return;
|
|
22554
|
+
}
|
|
22555
|
+
state.working -= 1;
|
|
22556
|
+
if (state.working < 0) throw new ValidationError$1("worker slots: released more than granted");
|
|
22557
|
+
}
|
|
22558
|
+
function withdraw(state, permit) {
|
|
22559
|
+
const index = state.waiters.findIndex((waiter) => waiter.permit === permit);
|
|
22560
|
+
if (index === -1) return;
|
|
22561
|
+
state.waiters.splice(index, 1);
|
|
22562
|
+
permit.group.queued -= 1;
|
|
22563
|
+
}
|
|
22564
|
+
/** Grant every waiter that can run: any waiter whose manager is working on its own slot, and then
|
|
22565
|
+
* the deepest and oldest waiters while capacity remains. */
|
|
22566
|
+
function pump(state) {
|
|
22567
|
+
for (;;) {
|
|
22568
|
+
let chosen;
|
|
22569
|
+
for (let index = 0; index < state.waiters.length; index++) {
|
|
22570
|
+
const waiter = state.waiters[index];
|
|
22571
|
+
if (costOf(waiter.permit.group) === 0) {
|
|
22572
|
+
chosen = index;
|
|
22573
|
+
break;
|
|
22574
|
+
}
|
|
22575
|
+
if (!hasCapacity(state)) continue;
|
|
22576
|
+
const best = chosen === void 0 ? void 0 : state.waiters[chosen];
|
|
22577
|
+
if (best === void 0 || waiter.depth > best.depth || waiter.depth === best.depth && waiter.order < best.order) chosen = index;
|
|
22578
|
+
}
|
|
22579
|
+
if (chosen === void 0) return;
|
|
22580
|
+
const [waiter] = state.waiters.splice(chosen, 1);
|
|
22581
|
+
waiter.permit.group.queued -= 1;
|
|
22582
|
+
waiter.grant();
|
|
22583
|
+
}
|
|
22584
|
+
}
|
|
22585
|
+
function normalizeWorkerSlotBound(value) {
|
|
22586
|
+
if (value === void 0 || value <= 0) return void 0;
|
|
22587
|
+
if (!Number.isSafeInteger(value)) throw new ValidationError$1(`workerSlots must be a positive safe integer, or 0 or less for no bound, got ${String(value)}`);
|
|
22588
|
+
return value;
|
|
22589
|
+
}
|
|
22590
|
+
//#endregion
|
|
22091
22591
|
//#region src/runtime/supervise/scope.ts
|
|
22092
22592
|
/**
|
|
22093
22593
|
*
|
|
@@ -22130,6 +22630,17 @@ const nestedTeardownScopes = /* @__PURE__ */ new WeakMap();
|
|
|
22130
22630
|
* kept for a resume any longer. */
|
|
22131
22631
|
const releasingScopes = /* @__PURE__ */ new WeakSet();
|
|
22132
22632
|
const admissionSeals = /* @__PURE__ */ new WeakMap();
|
|
22633
|
+
/** Each scope's reader of its own team, for the settlement its owner writes one level up. */
|
|
22634
|
+
const subtreeReaders = /* @__PURE__ */ new WeakMap();
|
|
22635
|
+
/** Each scope's reader of its live team, for the progress its owner's lead reads mid-flight. */
|
|
22636
|
+
const liveTeamReaders = /* @__PURE__ */ new WeakMap();
|
|
22637
|
+
/** How many of a manager's direct children its summary lists; the counts always cover all. */
|
|
22638
|
+
const SUBTREE_RESULT_LIMIT = 8;
|
|
22639
|
+
/** @internal The bounded account of the children a scope spawned and everything below them.
|
|
22640
|
+
* `undefined` when the scope spawned no worker. */
|
|
22641
|
+
function subtreeSummaryOf(scope) {
|
|
22642
|
+
return subtreeReaders.get(scope)?.();
|
|
22643
|
+
}
|
|
22133
22644
|
/** Per-child bound on a retained release: one remote destroy, answered or abandoned. */
|
|
22134
22645
|
const RETAINED_RELEASE_TIMEOUT_MS = 3e4;
|
|
22135
22646
|
/**
|
|
@@ -22257,13 +22768,11 @@ function hasRetriableTeardowns(scope, release) {
|
|
|
22257
22768
|
function closeScopeAdmission(scope) {
|
|
22258
22769
|
admissionSeals.get(scope)?.();
|
|
22259
22770
|
}
|
|
22260
|
-
/** Fail before execution when
|
|
22261
|
-
function assertRecursiveReservationPolicy(policy
|
|
22771
|
+
/** Fail before execution when a reservation policy is malformed. */
|
|
22772
|
+
function assertRecursiveReservationPolicy(policy) {
|
|
22262
22773
|
if (policy === void 0) return;
|
|
22263
22774
|
if (typeof policy !== "object" || policy === null || Object.keys(policy).some((key) => key !== "ownerShare")) throw new ValidationError$1("reservationPolicy accepts only ownerShare");
|
|
22264
22775
|
if (!Number.isFinite(policy.ownerShare) || policy.ownerShare <= 0 || policy.ownerShare >= 1) throw new ValidationError$1("reservationPolicy.ownerShare must be greater than 0 and less than 1");
|
|
22265
|
-
if (!Number.isSafeInteger(maxDepth) || maxDepth === void 0 || maxDepth < 2) throw new ValidationError$1("reservationPolicy requires maxDepth >= 2");
|
|
22266
|
-
if (!Number.isSafeInteger(maxLiveWorkers) || maxLiveWorkers === void 0 || maxLiveWorkers < maxDepth) throw new ValidationError$1("reservationPolicy requires maxLiveWorkers >= maxDepth to preserve a descendant path");
|
|
22267
22776
|
}
|
|
22268
22777
|
/**
|
|
22269
22778
|
* The recursion seam key. A `Scope` seeds a value of this on each child's
|
|
@@ -22272,7 +22781,7 @@ function assertRecursiveReservationPolicy(policy, maxDepth, maxLiveWorkers) {
|
|
|
22272
22781
|
* here so the scope and the driver-executor agree on the seam without a circular import.
|
|
22273
22782
|
*/
|
|
22274
22783
|
const nestedScopeSeamKey = "nested-scope";
|
|
22275
|
-
function makeNestedScopeSeam(args,
|
|
22784
|
+
function makeNestedScopeSeam(args, workerSlots, childSlot, childNodeId, childBudget, childDeadlineAtMs, deferredOwner) {
|
|
22276
22785
|
const now = args.now ?? Date.now;
|
|
22277
22786
|
const mountScope = (nestedRoot, signal, restored) => {
|
|
22278
22787
|
const mountedAtMs = now();
|
|
@@ -22291,7 +22800,8 @@ function makeNestedScopeSeam(args, liveWorkerCapacity, childNodeId, childBudget,
|
|
|
22291
22800
|
seams: args.seams,
|
|
22292
22801
|
depth: args.depth + 1,
|
|
22293
22802
|
...args.maxDepth !== void 0 ? { maxDepth: args.maxDepth } : {},
|
|
22294
|
-
|
|
22803
|
+
workerSlots,
|
|
22804
|
+
slotOwner: childSlot,
|
|
22295
22805
|
...args.reservationPolicy ? {
|
|
22296
22806
|
reservationPolicy: args.reservationPolicy,
|
|
22297
22807
|
ownerBudget: nestedBudget
|
|
@@ -22330,12 +22840,10 @@ function createScope(args) {
|
|
|
22330
22840
|
const settlementWrites = /* @__PURE__ */ new Set();
|
|
22331
22841
|
let admissionClosed = false;
|
|
22332
22842
|
const interactiveBindingDir = args.interactiveBindingDir;
|
|
22333
|
-
const
|
|
22334
|
-
|
|
22335
|
-
live: 0
|
|
22336
|
-
};
|
|
22843
|
+
const workerSlots = args.workerSlots ?? createWorkerSlots();
|
|
22844
|
+
const slotGroup = openSlotGroup(workerSlots, args.slotOwner);
|
|
22337
22845
|
const reservationPolicy = args.reservationPolicy;
|
|
22338
|
-
assertRecursiveReservationPolicy(reservationPolicy
|
|
22846
|
+
assertRecursiveReservationPolicy(reservationPolicy);
|
|
22339
22847
|
if (reservationPolicy && !args.ownerBudget) throw new ValidationError$1("reservationPolicy requires the owning scope budget");
|
|
22340
22848
|
const ownerBudget = args.ownerBudget;
|
|
22341
22849
|
const ownerFloor = reservationPolicy && ownerBudget ? {
|
|
@@ -22343,11 +22851,12 @@ function createScope(args) {
|
|
|
22343
22851
|
iterations: Math.ceil(ownerBudget.maxIterations * reservationPolicy.ownerShare),
|
|
22344
22852
|
...ownerBudget.maxUsd === void 0 ? {} : { usd: ownerBudget.maxUsd * reservationPolicy.ownerShare }
|
|
22345
22853
|
} : void 0;
|
|
22346
|
-
const admissionMax = reservationPolicy && liveWorkerCapacity.max !== void 0 && args.maxDepth !== void 0 ? liveWorkerCapacity.max - Math.max(0, args.maxDepth - (args.depth + 1)) : liveWorkerCapacity.max;
|
|
22347
22854
|
let spawnOrdinal = args.resumeFrom ? args.resumeFrom.maxSpawnOrdinal + 1 : 0;
|
|
22348
22855
|
let cursorSeq = args.resumeFrom ? args.resumeFrom.maxCursorSeq + 1 : 0;
|
|
22349
22856
|
let waitOrdinal = args.resumeFrom ? args.resumeFrom.maxWaitOrdinal + 1 : 0;
|
|
22350
22857
|
let meterSeq = 0;
|
|
22858
|
+
let ownerTurns = 0;
|
|
22859
|
+
let ownerLastTurnAt = 0;
|
|
22351
22860
|
let progressSeq = 0;
|
|
22352
22861
|
const now = args.now ?? Date.now;
|
|
22353
22862
|
const unclaimedWaits = new Map((args.resumeFrom?.waits ?? []).map((w) => [w.label, w]));
|
|
@@ -22464,54 +22973,21 @@ function createScope(args) {
|
|
|
22464
22973
|
reason: "depth-exceeded"
|
|
22465
22974
|
};
|
|
22466
22975
|
if (typeof agentOrFactory !== "function") prepared ??= prepare();
|
|
22467
|
-
if (!recovery && admissionMax !== void 0 && liveWorkerCapacity.live >= admissionMax) return {
|
|
22468
|
-
ok: false,
|
|
22469
|
-
reason: "max-live-workers"
|
|
22470
|
-
};
|
|
22471
|
-
if (!recovery && ownerFloor) {
|
|
22472
|
-
const available = args.pool.readout();
|
|
22473
|
-
const shortfalls = [];
|
|
22474
|
-
const short = (channel, requested, free) => {
|
|
22475
|
-
if (requested > free) shortfalls.push({
|
|
22476
|
-
channel,
|
|
22477
|
-
requested,
|
|
22478
|
-
free: Math.max(0, free)
|
|
22479
|
-
});
|
|
22480
|
-
};
|
|
22481
|
-
short("tokens", opts.budget.maxTokens, available.tokensLeft - ownerFloor.tokens);
|
|
22482
|
-
short("iterations", opts.budget.maxIterations, available.iterationsLeft - ownerFloor.iterations);
|
|
22483
|
-
if (ownerFloor.usd !== void 0) short("usd", opts.budget.maxUsd ?? 0, available.usdLeft - ownerFloor.usd);
|
|
22484
|
-
if (shortfalls.length > 0) return {
|
|
22485
|
-
ok: false,
|
|
22486
|
-
reason: "budget-exhausted",
|
|
22487
|
-
shortfalls
|
|
22488
|
-
};
|
|
22489
|
-
}
|
|
22490
|
-
const permit = acquireLiveWorker(liveWorkerCapacity);
|
|
22491
|
-
if (!permit.ok) return {
|
|
22492
|
-
ok: false,
|
|
22493
|
-
reason: "max-live-workers"
|
|
22494
|
-
};
|
|
22495
22976
|
const assignment = opts.assignmentId ?? opts.key;
|
|
22496
22977
|
let reservation;
|
|
22497
|
-
|
|
22498
|
-
|
|
22499
|
-
|
|
22500
|
-
|
|
22501
|
-
|
|
22502
|
-
|
|
22503
|
-
|
|
22504
|
-
|
|
22505
|
-
|
|
22506
|
-
|
|
22507
|
-
|
|
22508
|
-
|
|
22509
|
-
|
|
22510
|
-
ok: false,
|
|
22511
|
-
reason: reservation.reason,
|
|
22512
|
-
...reservation.shortfalls === void 0 ? {} : { shortfalls: reservation.shortfalls }
|
|
22513
|
-
};
|
|
22514
|
-
}
|
|
22978
|
+
reservation = args.pool.reserve(opts.budget, {
|
|
22979
|
+
...assignment === void 0 ? {} : { assignment },
|
|
22980
|
+
label: opts.label,
|
|
22981
|
+
stage: "admitted"
|
|
22982
|
+
}, recovery ? {} : {
|
|
22983
|
+
wait: true,
|
|
22984
|
+
...ownerFloor ? { keep: ownerFloor } : {}
|
|
22985
|
+
});
|
|
22986
|
+
if (!reservation.ok) return {
|
|
22987
|
+
ok: false,
|
|
22988
|
+
reason: reservation.reason,
|
|
22989
|
+
...reservation.shortfalls === void 0 ? {} : { shortfalls: reservation.shortfalls }
|
|
22990
|
+
};
|
|
22515
22991
|
let spec;
|
|
22516
22992
|
let resolved;
|
|
22517
22993
|
let identity;
|
|
@@ -22521,7 +22997,6 @@ function createScope(args) {
|
|
|
22521
22997
|
identity = prepared.identity;
|
|
22522
22998
|
if (opts.key !== void 0 && !isCompleteIdentity(identity)) {
|
|
22523
22999
|
args.pool.reconcile(reservation.ticket, withBudgetResources(zeroSpend(), opts.budget, true));
|
|
22524
|
-
permit.release();
|
|
22525
23000
|
return {
|
|
22526
23001
|
ok: false,
|
|
22527
23002
|
reason: "invalid-identity"
|
|
@@ -22535,9 +23010,10 @@ function createScope(args) {
|
|
|
22535
23010
|
resolved = outcome;
|
|
22536
23011
|
} catch (error) {
|
|
22537
23012
|
args.pool.reconcile(reservation.ticket, withBudgetResources(zeroSpend(), opts.budget, true));
|
|
22538
|
-
permit.release();
|
|
22539
23013
|
throw error;
|
|
22540
23014
|
}
|
|
23015
|
+
const budgetGranted = reservation.granted;
|
|
23016
|
+
const permit = budgetGranted === void 0 ? slotGroup.acquire(args.depth + 1, { force: recovery !== void 0 }) : deferSlot(budgetGranted, () => slotGroup.acquire(args.depth + 1));
|
|
22541
23017
|
let cascadeAbort;
|
|
22542
23018
|
let clearChildDeadline;
|
|
22543
23019
|
try {
|
|
@@ -22562,7 +23038,6 @@ function createScope(args) {
|
|
|
22562
23038
|
const recoveryReady = recovery?.spawned.ownedTreeRoot === void 0 ? void 0 : new Promise((resolve) => {
|
|
22563
23039
|
markRecoveryReady = resolve;
|
|
22564
23040
|
});
|
|
22565
|
-
const admissions = [...recovery?.admissions ?? []];
|
|
22566
23041
|
const retainedWrites = /* @__PURE__ */ new Set();
|
|
22567
23042
|
let retainedWritesClosed = false;
|
|
22568
23043
|
const retainedWrite = (write) => {
|
|
@@ -22577,6 +23052,99 @@ function createScope(args) {
|
|
|
22577
23052
|
retainedWritesClosed = true;
|
|
22578
23053
|
await Promise.allSettled([...retainedWrites]);
|
|
22579
23054
|
};
|
|
23055
|
+
let admissions = [...recovery?.admissions ?? []];
|
|
23056
|
+
let inputSeq = recovery?.continuation?.inputSeq ?? ordinal;
|
|
23057
|
+
let pauseSeq = 0;
|
|
23058
|
+
const onAdmission = (admission) => retainedWrite(async () => {
|
|
23059
|
+
controller.signal.throwIfAborted();
|
|
23060
|
+
const existing = admissions.find((record) => record.phase === admission.phase);
|
|
23061
|
+
if (existing) {
|
|
23062
|
+
if (contentAddress(existing) !== contentAddress(admission)) throw new ValidationError$1("scope retained admission conflicts with its committed phase");
|
|
23063
|
+
return;
|
|
23064
|
+
}
|
|
23065
|
+
if (identity?.taskDigest === void 0) throw new ValidationError$1("retained execution requires a canonical task identity");
|
|
23066
|
+
await args.journal.appendEvent(args.root, {
|
|
23067
|
+
kind: "execution-admitted",
|
|
23068
|
+
id,
|
|
23069
|
+
admission: detachedSnapshot(admission, "retained admission"),
|
|
23070
|
+
seq: ordinal,
|
|
23071
|
+
at: new Date(now()).toISOString()
|
|
23072
|
+
});
|
|
23073
|
+
admissions.push(detachedSnapshot(admission, "retained admission"));
|
|
23074
|
+
live.recoveryPending = true;
|
|
23075
|
+
controller.signal.throwIfAborted();
|
|
23076
|
+
});
|
|
23077
|
+
const onResult = (result) => retainedWrite(async () => {
|
|
23078
|
+
controller.signal.throwIfAborted();
|
|
23079
|
+
assertValidSpend(result.spent, "retained executor result");
|
|
23080
|
+
executorFailureReason(result);
|
|
23081
|
+
await pendingEvidence?.complete();
|
|
23082
|
+
const outRef = contentAddress(result.out);
|
|
23083
|
+
await args.blobs.put(outRef, result.out);
|
|
23084
|
+
controller.signal.throwIfAborted();
|
|
23085
|
+
await args.journal.appendEvent(args.root, {
|
|
23086
|
+
kind: "execution-result",
|
|
23087
|
+
id,
|
|
23088
|
+
outRef,
|
|
23089
|
+
spent: result.spent,
|
|
23090
|
+
...result.verdict ? { verdict: result.verdict } : {},
|
|
23091
|
+
...result.outcome ? { outcome: result.outcome } : {},
|
|
23092
|
+
seq: ordinal,
|
|
23093
|
+
at: new Date(now()).toISOString()
|
|
23094
|
+
});
|
|
23095
|
+
live.acceptedResult = detachedSnapshot({
|
|
23096
|
+
...result,
|
|
23097
|
+
outRef
|
|
23098
|
+
}, "accepted retained child result");
|
|
23099
|
+
live.recoveryPending = false;
|
|
23100
|
+
});
|
|
23101
|
+
const onPause = (pause) => retainedWrite(async () => {
|
|
23102
|
+
await args.journal.appendEvent(args.root, {
|
|
23103
|
+
kind: "paused",
|
|
23104
|
+
id,
|
|
23105
|
+
...pause,
|
|
23106
|
+
seq: pauseSeq++,
|
|
23107
|
+
at: new Date(now()).toISOString()
|
|
23108
|
+
});
|
|
23109
|
+
});
|
|
23110
|
+
const retainedContext = (continuing) => ({
|
|
23111
|
+
...continuing === void 0 ? {} : {
|
|
23112
|
+
executionId: continuing.executionId,
|
|
23113
|
+
priorSession: continuing.priorSession
|
|
23114
|
+
},
|
|
23115
|
+
admissions,
|
|
23116
|
+
...markRecoveryReady && continuing === void 0 ? { onReady: markRecoveryReady } : {},
|
|
23117
|
+
onAdmission,
|
|
23118
|
+
onResult,
|
|
23119
|
+
onPause,
|
|
23120
|
+
continueInvocation: async (nextTask) => {
|
|
23121
|
+
controller.signal.throwIfAborted();
|
|
23122
|
+
if (live.acceptedResult === void 0) throw new ValidationError$1("scope: a retained child continues only after its invocation committed a result");
|
|
23123
|
+
const environment = admissions.find((record) => record.phase === "environment");
|
|
23124
|
+
if (environment?.phase !== "environment") throw new ValidationError$1("scope: a retained child continues only in an environment it was admitted to");
|
|
23125
|
+
const snapshot = detachedSnapshot(nextTask, "retained child continuation");
|
|
23126
|
+
const taskRef = contentAddress(snapshot);
|
|
23127
|
+
const nextSeq = inputSeq + 1;
|
|
23128
|
+
await retainedWrite(async () => {
|
|
23129
|
+
await args.blobs.put(taskRef, snapshot);
|
|
23130
|
+
controller.signal.throwIfAborted();
|
|
23131
|
+
await args.journal.appendEvent(args.root, {
|
|
23132
|
+
kind: "execution-input",
|
|
23133
|
+
id,
|
|
23134
|
+
taskRef,
|
|
23135
|
+
seq: nextSeq,
|
|
23136
|
+
at: new Date(now()).toISOString()
|
|
23137
|
+
});
|
|
23138
|
+
});
|
|
23139
|
+
inputSeq = nextSeq;
|
|
23140
|
+
admissions = [];
|
|
23141
|
+
live.acceptedResult = void 0;
|
|
23142
|
+
return retainedContext({
|
|
23143
|
+
executionId: leafContinuationExecutionId(id, nextSeq),
|
|
23144
|
+
priorSession: environment
|
|
23145
|
+
});
|
|
23146
|
+
}
|
|
23147
|
+
});
|
|
22580
23148
|
const ctx = {
|
|
22581
23149
|
signal: controller.signal,
|
|
22582
23150
|
node: {
|
|
@@ -22589,54 +23157,11 @@ function createScope(args) {
|
|
|
22589
23157
|
},
|
|
22590
23158
|
seams: {
|
|
22591
23159
|
...args.seams,
|
|
22592
|
-
[retainedExecutorSeamKey]: {
|
|
22593
|
-
|
|
22594
|
-
|
|
22595
|
-
|
|
22596
|
-
|
|
22597
|
-
const existing = admissions.find((record) => record.phase === admission.phase);
|
|
22598
|
-
if (existing) {
|
|
22599
|
-
if (contentAddress(existing) !== contentAddress(admission)) throw new ValidationError$1("scope retained admission conflicts with its committed phase");
|
|
22600
|
-
return;
|
|
22601
|
-
}
|
|
22602
|
-
if (identity?.taskDigest === void 0) throw new ValidationError$1("retained execution requires a canonical task identity");
|
|
22603
|
-
await args.journal.appendEvent(args.root, {
|
|
22604
|
-
kind: "execution-admitted",
|
|
22605
|
-
id,
|
|
22606
|
-
admission: detachedSnapshot(admission, "retained admission"),
|
|
22607
|
-
seq: ordinal,
|
|
22608
|
-
at: new Date(now()).toISOString()
|
|
22609
|
-
});
|
|
22610
|
-
admissions.push(detachedSnapshot(admission, "retained admission"));
|
|
22611
|
-
live.recoveryPending = true;
|
|
22612
|
-
controller.signal.throwIfAborted();
|
|
22613
|
-
}),
|
|
22614
|
-
onResult: (result) => retainedWrite(async () => {
|
|
22615
|
-
controller.signal.throwIfAborted();
|
|
22616
|
-
assertValidSpend(result.spent, "retained executor result");
|
|
22617
|
-
executorFailureReason(result);
|
|
22618
|
-
await pendingEvidence?.complete();
|
|
22619
|
-
const outRef = contentAddress(result.out);
|
|
22620
|
-
await args.blobs.put(outRef, result.out);
|
|
22621
|
-
controller.signal.throwIfAborted();
|
|
22622
|
-
await args.journal.appendEvent(args.root, {
|
|
22623
|
-
kind: "execution-result",
|
|
22624
|
-
id,
|
|
22625
|
-
outRef,
|
|
22626
|
-
spent: result.spent,
|
|
22627
|
-
...result.verdict ? { verdict: result.verdict } : {},
|
|
22628
|
-
...result.outcome ? { outcome: result.outcome } : {},
|
|
22629
|
-
seq: ordinal,
|
|
22630
|
-
at: new Date(now()).toISOString()
|
|
22631
|
-
});
|
|
22632
|
-
live.acceptedResult = detachedSnapshot({
|
|
22633
|
-
...result,
|
|
22634
|
-
outRef
|
|
22635
|
-
}, "accepted retained child result");
|
|
22636
|
-
live.recoveryPending = false;
|
|
22637
|
-
})
|
|
22638
|
-
},
|
|
22639
|
-
[nestedScopeSeamKey]: makeNestedScopeSeam(args, liveWorkerCapacity, id, opts.budget, childDeadlineAtMs, deferredOwner),
|
|
23160
|
+
[retainedExecutorSeamKey]: retainedContext(recovery?.continuation === void 0 ? void 0 : {
|
|
23161
|
+
executionId: recovery.continuation.executionId,
|
|
23162
|
+
priorSession: recovery.continuation.priorSession
|
|
23163
|
+
}),
|
|
23164
|
+
[nestedScopeSeamKey]: makeNestedScopeSeam(args, workerSlots, permit, id, opts.budget, childDeadlineAtMs, deferredOwner),
|
|
22640
23165
|
...workerTrace ? { [workerTraceSeamKey]: workerTrace } : {},
|
|
22641
23166
|
...interactiveBindingDir ? { [interactiveAdmissionSeamKey]: (admission) => Promise.resolve(writeWorkerInteractiveAdmission(interactiveBindingDir, id, admission, now)).then(() => void 0) } : {}
|
|
22642
23167
|
}
|
|
@@ -22668,7 +23193,7 @@ function createScope(args) {
|
|
|
22668
23193
|
});
|
|
22669
23194
|
const live = {
|
|
22670
23195
|
id,
|
|
22671
|
-
status: "acquiring",
|
|
23196
|
+
status: permit.granted ? "acquiring" : "queued",
|
|
22672
23197
|
runtime: executor.runtime,
|
|
22673
23198
|
...ownedTreeRoot === void 0 ? {} : { ownedTreeRoot },
|
|
22674
23199
|
...identity ? { identity } : {},
|
|
@@ -22877,10 +23402,10 @@ function createScope(args) {
|
|
|
22877
23402
|
startedAt
|
|
22878
23403
|
}
|
|
22879
23404
|
}, { signal: args.signal });
|
|
22880
|
-
const childRun = runChild(live, executor, controller, task, opts, args.pool, reservation.ticket, args.blobs, now, args.journal, args.root, () => progressSeq++, materializationCommitted, {
|
|
23405
|
+
const childRun = runChild(live, executor, controller, recovery?.continuation?.task ?? task, opts, args.pool, reservation.ticket, args.blobs, now, args.journal, args.root, () => progressSeq++, materializationCommitted, {
|
|
22881
23406
|
complete: async () => pendingEvidence?.complete(),
|
|
22882
23407
|
fail: async () => pendingEvidence?.fail()
|
|
22883
|
-
}, childDeadlineAtMs, recovery !== void 0, closeRetainedWrites);
|
|
23408
|
+
}, childDeadlineAtMs, recovery !== void 0, closeRetainedWrites, budgetGranted, permit.ready);
|
|
22884
23409
|
args.pool.attribute(reservation.ticket, { stage: "executing" });
|
|
22885
23410
|
const interactiveBindingCommitted = spawnCommitted.then(async () => {
|
|
22886
23411
|
if (args.interactiveBindingDir === void 0) return;
|
|
@@ -23138,14 +23663,16 @@ function createScope(args) {
|
|
|
23138
23663
|
} catch {
|
|
23139
23664
|
fromExecutor = void 0;
|
|
23140
23665
|
}
|
|
23666
|
+
const team = liveTeamOf(child);
|
|
23141
23667
|
return readWorkerProgress({
|
|
23142
23668
|
id: child.id,
|
|
23143
23669
|
status: child.status,
|
|
23144
23670
|
steerable: child.deliver !== void 0 && !child.delivered,
|
|
23145
23671
|
startedAt: child.startedAt,
|
|
23146
|
-
lastActivityAt: child.lastActivityAt,
|
|
23672
|
+
lastActivityAt: Math.max(child.lastActivityAt, team?.lastActivityAt ?? 0),
|
|
23147
23673
|
...addResourceSpend(child.spent.resources),
|
|
23148
|
-
turns: child.spent.iterations,
|
|
23674
|
+
turns: Math.max(child.spent.iterations, team?.ownerTurns ?? 0),
|
|
23675
|
+
...team && team.agents > 0 ? { team: teamProgress(team) } : {},
|
|
23149
23676
|
tokens: child.spent.tokens,
|
|
23150
23677
|
...child.spent.tokensKnown === false ? { tokensKnown: false } : {},
|
|
23151
23678
|
usd: child.spent.usd,
|
|
@@ -23192,6 +23719,8 @@ function createScope(args) {
|
|
|
23192
23719
|
} catch (error) {
|
|
23193
23720
|
observeError = error;
|
|
23194
23721
|
}
|
|
23722
|
+
ownerLastTurnAt = now();
|
|
23723
|
+
if (!accountingOnly) ownerTurns += 1;
|
|
23195
23724
|
await args.journal.appendEvent(args.root, {
|
|
23196
23725
|
kind: "metered",
|
|
23197
23726
|
id: args.parentId,
|
|
@@ -23243,8 +23772,9 @@ function createScope(args) {
|
|
|
23243
23772
|
},
|
|
23244
23773
|
get workerCapacity() {
|
|
23245
23774
|
return {
|
|
23246
|
-
|
|
23247
|
-
|
|
23775
|
+
working: workerSlots.working,
|
|
23776
|
+
queued: workerSlots.queued,
|
|
23777
|
+
freeSlots: freeSlots(workerSlots.working, workerSlots.max),
|
|
23248
23778
|
unconfirmed: Object.freeze([...children.values()].filter((child) => isTerminalNodeStatus(child.status) && !child.cleanupConfirmed).map((child) => unconfirmedTeardownOf(child, releasingScopes.has(scope))))
|
|
23249
23779
|
};
|
|
23250
23780
|
}
|
|
@@ -23252,6 +23782,8 @@ function createScope(args) {
|
|
|
23252
23782
|
admissionSeals.set(scope, () => {
|
|
23253
23783
|
admissionClosed = true;
|
|
23254
23784
|
});
|
|
23785
|
+
subtreeReaders.set(scope, () => summarizeTeam(children.values()));
|
|
23786
|
+
liveTeamReaders.set(scope, () => readLiveTeam(children.values(), ownerTurns, ownerLastTurnAt));
|
|
23255
23787
|
runtimeOwnedProviderMeters.set(scope, async (spend, providerModel, detail, accountingOnly) => meterInternal(spend, detail, providerModel, accountingOnly));
|
|
23256
23788
|
let pauseSeq = 0;
|
|
23257
23789
|
pauseRecorders.set(scope, async (pause) => {
|
|
@@ -23740,6 +24272,9 @@ async function appendAcknowledged(journal, root, event) {
|
|
|
23740
24272
|
async function finalizeSettlement(child, settlement, seq, args, now) {
|
|
23741
24273
|
const handle = frozenHandle(child);
|
|
23742
24274
|
if (child.wait) return finalizeWait(child, settlement, seq, args, now, handle);
|
|
24275
|
+
const nestedScope = child.readNestedScope?.();
|
|
24276
|
+
const subtree = nestedScope === void 0 ? void 0 : subtreeSummaryOf(nestedScope);
|
|
24277
|
+
if (subtree !== void 0) child.subtree = subtree;
|
|
23743
24278
|
const settledAt = now();
|
|
23744
24279
|
child.settledAt = settledAt;
|
|
23745
24280
|
child.settledSeq = seq;
|
|
@@ -23782,6 +24317,7 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
|
|
|
23782
24317
|
...settlement.infra === void 0 ? {} : { infra: settlement.infra },
|
|
23783
24318
|
...retainedExecution,
|
|
23784
24319
|
spent: child.spent,
|
|
24320
|
+
...subtree === void 0 ? {} : { subtree },
|
|
23785
24321
|
...settledNodeEvidence(child, settlement, settledAt)
|
|
23786
24322
|
}
|
|
23787
24323
|
}, { signal: args.signal });
|
|
@@ -23796,6 +24332,7 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
|
|
|
23796
24332
|
...child.budgetViolation ? { budgetViolation: child.budgetViolation } : {},
|
|
23797
24333
|
trace: settlement.trace,
|
|
23798
24334
|
...settlement.harnessTranscript ? { harnessTranscript: settlement.harnessTranscript } : {},
|
|
24335
|
+
...subtree === void 0 ? {} : { subtree },
|
|
23799
24336
|
settledAt,
|
|
23800
24337
|
seq
|
|
23801
24338
|
};
|
|
@@ -23816,6 +24353,7 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
|
|
|
23816
24353
|
...child.budgetViolation ? { budgetViolation: child.budgetViolation } : {},
|
|
23817
24354
|
trace: settlement.trace,
|
|
23818
24355
|
...settlement.harnessTranscript ? { harnessTranscript: settlement.harnessTranscript } : {},
|
|
24356
|
+
...subtree === void 0 ? {} : { subtree },
|
|
23819
24357
|
seq,
|
|
23820
24358
|
at
|
|
23821
24359
|
});
|
|
@@ -23834,6 +24372,7 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
|
|
|
23834
24372
|
score: settlement.verdict?.score,
|
|
23835
24373
|
valid: settlement.verdict?.valid,
|
|
23836
24374
|
spent: settlement.spent,
|
|
24375
|
+
...subtree === void 0 ? {} : { subtree },
|
|
23837
24376
|
...settledNodeEvidence(child, settlement, settledAt)
|
|
23838
24377
|
}
|
|
23839
24378
|
}, { signal: args.signal });
|
|
@@ -23848,6 +24387,7 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
|
|
|
23848
24387
|
...child.budgetViolation ? { budgetViolation: child.budgetViolation } : {},
|
|
23849
24388
|
trace: settlement.trace,
|
|
23850
24389
|
...settlement.harnessTranscript ? { harnessTranscript: settlement.harnessTranscript } : {},
|
|
24390
|
+
...subtree === void 0 ? {} : { subtree },
|
|
23851
24391
|
settledAt,
|
|
23852
24392
|
seq
|
|
23853
24393
|
};
|
|
@@ -23925,7 +24465,7 @@ async function finalizeWait(child, settlement, seq, args, now, handle) {
|
|
|
23925
24465
|
* applied per child). The reservation is reconciled on EVERY path (success, abort, throw)
|
|
23926
24466
|
* so the conserved pool can never leak a reservation.
|
|
23927
24467
|
*/
|
|
23928
|
-
async function runChild(live, executor, childAbort, task, opts, pool, ticket, blobs, now, journal, journalRoot, nextProgressSeq, executionReady, executionEvidence, deadlineAtMs, recovering = false, closeRetainedWrites = async () => {}) {
|
|
24468
|
+
async function runChild(live, executor, childAbort, task, opts, pool, ticket, blobs, now, journal, journalRoot, nextProgressSeq, executionReady, executionEvidence, deadlineAtMs, recovering = false, closeRetainedWrites = async () => {}, budgetReady = void 0, slotReady = Promise.resolve()) {
|
|
23929
24469
|
let reconciled = false;
|
|
23930
24470
|
let reconciliationError;
|
|
23931
24471
|
let teardownFailure;
|
|
@@ -24010,6 +24550,8 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
|
|
|
24010
24550
|
try {
|
|
24011
24551
|
await executionReady;
|
|
24012
24552
|
if (childAbort.signal.aborted) throw abortError(childAbort.signal, "execution aborted");
|
|
24553
|
+
if (budgetReady !== void 0) await awaitAbortable(budgetReady, childAbort.signal);
|
|
24554
|
+
await awaitAbortable(slotReady, childAbort.signal);
|
|
24013
24555
|
live.status = "running";
|
|
24014
24556
|
started = true;
|
|
24015
24557
|
const ran = recovering ? executor.recover(task, childAbort.signal) : executor.execute(task, childAbort.signal);
|
|
@@ -24186,25 +24728,114 @@ function settledToIteration(settled) {
|
|
|
24186
24728
|
tokenUsage: cloneTokenUsage(settled.spent.tokens)
|
|
24187
24729
|
};
|
|
24188
24730
|
}
|
|
24189
|
-
|
|
24190
|
-
|
|
24191
|
-
|
|
24192
|
-
|
|
24731
|
+
/** Summarize one scope's children and everything below them, listing the best direct children
|
|
24732
|
+
* and counting the rest. Wait-states are not agents and are left out. */
|
|
24733
|
+
/** The live team a child manager leads, read through the nested scope it owns. */
|
|
24734
|
+
function liveTeamOf(child) {
|
|
24735
|
+
let nested;
|
|
24736
|
+
try {
|
|
24737
|
+
nested = child.readNestedScope?.();
|
|
24738
|
+
} catch {
|
|
24739
|
+
return;
|
|
24740
|
+
}
|
|
24741
|
+
return nested === void 0 ? void 0 : liveTeamReaders.get(nested)?.();
|
|
24193
24742
|
}
|
|
24194
|
-
function
|
|
24195
|
-
|
|
24196
|
-
|
|
24197
|
-
|
|
24198
|
-
|
|
24199
|
-
|
|
24200
|
-
|
|
24201
|
-
|
|
24202
|
-
|
|
24203
|
-
|
|
24204
|
-
|
|
24743
|
+
function teamProgress(team) {
|
|
24744
|
+
const { lastActivityAt: _lastActivityAt, ownerTurns: _ownerTurns, ...counts } = team;
|
|
24745
|
+
return Object.freeze(counts);
|
|
24746
|
+
}
|
|
24747
|
+
/** Latest activity an executor names, or 0. A throwing read is no evidence of activity. */
|
|
24748
|
+
function executorActivityAt(child) {
|
|
24749
|
+
try {
|
|
24750
|
+
const recent = child.readProgress?.()?.recentActivity;
|
|
24751
|
+
return recent?.length ? recent[recent.length - 1]?.at ?? 0 : 0;
|
|
24752
|
+
} catch {
|
|
24753
|
+
return 0;
|
|
24754
|
+
}
|
|
24755
|
+
}
|
|
24756
|
+
/** Count a scope's team at every depth and find its newest activity. Live members are read through
|
|
24757
|
+
* their own nested scopes; settled members contribute the summary their settlement carried. */
|
|
24758
|
+
function readLiveTeam(children, ownerTurns, ownerLastTurnAt) {
|
|
24759
|
+
let agents = 0;
|
|
24760
|
+
let depth = 0;
|
|
24761
|
+
let working = 0;
|
|
24762
|
+
let queued = 0;
|
|
24763
|
+
let done = 0;
|
|
24764
|
+
let down = 0;
|
|
24765
|
+
let lastActivityAt = ownerLastTurnAt;
|
|
24766
|
+
for (const child of children) {
|
|
24767
|
+
if (child.wait) continue;
|
|
24768
|
+
agents += 1;
|
|
24769
|
+
lastActivityAt = Math.max(lastActivityAt, child.lastActivityAt, child.settledAt ?? 0, executorActivityAt(child));
|
|
24770
|
+
if (child.status === "done") done += 1;
|
|
24771
|
+
else if (child.status === "failed" || child.status === "cancelled") down += 1;
|
|
24772
|
+
else if (child.status === "queued" || child.status === "pending") queued += 1;
|
|
24773
|
+
else working += 1;
|
|
24774
|
+
const below = isTerminalNodeStatus(child.status) ? child.subtree : liveTeamOf(child);
|
|
24775
|
+
if (below === void 0 || below.agents === 0) continue;
|
|
24776
|
+
agents += below.agents;
|
|
24777
|
+
depth = Math.max(depth, below.depth);
|
|
24778
|
+
done += below.done;
|
|
24779
|
+
down += below.down;
|
|
24780
|
+
if ("working" in below) {
|
|
24781
|
+
working += below.working;
|
|
24782
|
+
queued += below.queued;
|
|
24783
|
+
lastActivityAt = Math.max(lastActivityAt, below.lastActivityAt);
|
|
24205
24784
|
}
|
|
24785
|
+
}
|
|
24786
|
+
return {
|
|
24787
|
+
agents,
|
|
24788
|
+
depth: agents === 0 ? 0 : depth + 1,
|
|
24789
|
+
working,
|
|
24790
|
+
queued,
|
|
24791
|
+
done,
|
|
24792
|
+
down,
|
|
24793
|
+
lastActivityAt,
|
|
24794
|
+
ownerTurns
|
|
24206
24795
|
};
|
|
24207
24796
|
}
|
|
24797
|
+
function summarizeTeam(children) {
|
|
24798
|
+
let agents = 0;
|
|
24799
|
+
let depth = 0;
|
|
24800
|
+
let done = 0;
|
|
24801
|
+
let down = 0;
|
|
24802
|
+
let members = 0;
|
|
24803
|
+
const results = [];
|
|
24804
|
+
for (const child of children) {
|
|
24805
|
+
if (child.wait) continue;
|
|
24806
|
+
members += 1;
|
|
24807
|
+
const below = child.subtree;
|
|
24808
|
+
agents += 1 + (below?.agents ?? 0);
|
|
24809
|
+
depth = Math.max(depth, 1 + (below?.depth ?? 0));
|
|
24810
|
+
done += below?.done ?? 0;
|
|
24811
|
+
down += below?.down ?? 0;
|
|
24812
|
+
const status = child.status === "done" ? "done" : child.status === "failed" || child.status === "cancelled" ? "down" : void 0;
|
|
24813
|
+
if (status === void 0) continue;
|
|
24814
|
+
if (status === "done") done += 1;
|
|
24815
|
+
else down += 1;
|
|
24816
|
+
const score = child.resolved?.kind === "done" ? child.resolved.verdict?.score : void 0;
|
|
24817
|
+
results.push({
|
|
24818
|
+
id: child.id,
|
|
24819
|
+
label: child.label,
|
|
24820
|
+
status,
|
|
24821
|
+
...child.outRef === void 0 ? {} : { outRef: child.outRef },
|
|
24822
|
+
...score === void 0 ? {} : { score },
|
|
24823
|
+
agents: below?.agents ?? 0,
|
|
24824
|
+
order: child.settledSeq ?? Number.MAX_SAFE_INTEGER
|
|
24825
|
+
});
|
|
24826
|
+
}
|
|
24827
|
+
if (members === 0) return void 0;
|
|
24828
|
+
results.sort((a, b) => (a.status === b.status ? 0 : a.status === "done" ? -1 : 1) || (b.score ?? Number.NEGATIVE_INFINITY) - (a.score ?? Number.NEGATIVE_INFINITY) || a.order - b.order);
|
|
24829
|
+
const listed = results.slice(0, 8).map(({ order: _order, ...result }) => Object.freeze(result));
|
|
24830
|
+
return Object.freeze({
|
|
24831
|
+
agents,
|
|
24832
|
+
depth,
|
|
24833
|
+
done,
|
|
24834
|
+
down,
|
|
24835
|
+
results: Object.freeze(listed),
|
|
24836
|
+
omitted: members - listed.length
|
|
24837
|
+
});
|
|
24838
|
+
}
|
|
24208
24839
|
function makeTreeView(root, children) {
|
|
24209
24840
|
const nodes = [...children.values()].map((c) => ({
|
|
24210
24841
|
id: c.id,
|
|
@@ -24231,7 +24862,7 @@ function makeTreeView(root, children) {
|
|
|
24231
24862
|
return {
|
|
24232
24863
|
root,
|
|
24233
24864
|
nodes,
|
|
24234
|
-
inFlight: nodes.filter((n) => n.status === "running" || n.status === "acquiring").length,
|
|
24865
|
+
inFlight: nodes.filter((n) => n.status === "running" || n.status === "acquiring" || n.status === "queued").length,
|
|
24235
24866
|
waiting: nodes.filter((n) => n.status === "waiting").length
|
|
24236
24867
|
};
|
|
24237
24868
|
}
|
|
@@ -24954,8 +25585,6 @@ const DEFAULT_MAX_ATTEMPTS = 8;
|
|
|
24954
25585
|
const DEFAULT_MAX_BARREN_REPROMPTS = 2;
|
|
24955
25586
|
const DEFAULT_INITIAL_BACKOFF_MS = 2e3;
|
|
24956
25587
|
const DEFAULT_MAX_BACKOFF_MS = 3e4;
|
|
24957
|
-
const DEFAULT_UNAVAILABLE_PAUSE_MS = 15e3;
|
|
24958
|
-
const DEFAULT_MAX_UNAVAILABLE_PAUSE_MS = 3e5;
|
|
24959
25588
|
/**
|
|
24960
25589
|
* Bridge error classes the bridge itself never retries: a request that fails identically on
|
|
24961
25590
|
* every attempt, mapped below 5xx on its HTTP path (`parse_error` 400, the other two 501). On the
|
|
@@ -24991,39 +25620,6 @@ var HarnessTurnFailedError = class extends Error {
|
|
|
24991
25620
|
}
|
|
24992
25621
|
};
|
|
24993
25622
|
/**
|
|
24994
|
-
* Machine codes that say the upstream cannot serve now rather than that the request is wrong.
|
|
24995
|
-
* Each is a code an upstream publishes, not prose: the router's
|
|
24996
|
-
* (`lib/model-substitution.ts`, `lib/upstream-error-triage.ts`) and the OpenAI- and Anthropic-shaped
|
|
24997
|
-
* error types a relayed body carries.
|
|
24998
|
-
*/
|
|
24999
|
-
const UNAVAILABLE_CODES = /* @__PURE__ */ new Set([
|
|
25000
|
-
"provider_quota_exhausted",
|
|
25001
|
-
"provider_quota_exceeded",
|
|
25002
|
-
"provider_rate_limit",
|
|
25003
|
-
"upstream_unavailable",
|
|
25004
|
-
"provider_key_invalid",
|
|
25005
|
-
"rate_limit_exceeded",
|
|
25006
|
-
"rate_limit_error",
|
|
25007
|
-
"overloaded_error"
|
|
25008
|
-
]);
|
|
25009
|
-
/** 429 Too Many Requests, 503 Service Unavailable, and 529, which Anthropic uses for overload. */
|
|
25010
|
-
const UNAVAILABLE_STATUSES = /* @__PURE__ */ new Set([
|
|
25011
|
-
429,
|
|
25012
|
-
503,
|
|
25013
|
-
529
|
|
25014
|
-
]);
|
|
25015
|
-
/**
|
|
25016
|
-
* A harness that flattens the router's JSON body into its own failure text leaves the router's
|
|
25017
|
-
* code in that text: `opencode execution failed: No provider served model "..."
|
|
25018
|
-
* (provider_quota_exhausted)`. The code is matched as a whole token, and a status only in the
|
|
25019
|
-
* `status code <n>` framing a harness prints, so prose that merely mentions a quota does not match.
|
|
25020
|
-
*/
|
|
25021
|
-
function unavailableSignalInText(text) {
|
|
25022
|
-
for (const token of text.toLowerCase().matchAll(/[a-z_]+/gu)) if (UNAVAILABLE_CODES.has(token[0])) return token[0];
|
|
25023
|
-
const status = text.match(/\bstatus code (\d{3})\b/u)?.[1];
|
|
25024
|
-
return status !== void 0 && UNAVAILABLE_STATUSES.has(Number(status)) ? `http-${status}` : void 0;
|
|
25025
|
-
}
|
|
25026
|
-
/**
|
|
25027
25623
|
* The code or status that marks `error` as an upstream capacity refusal, or `undefined`.
|
|
25028
25624
|
*
|
|
25029
25625
|
* A structured field is read first: a turn outcome's `errorCode`, a transport error's
|
|
@@ -25032,11 +25628,10 @@ function unavailableSignalInText(text) {
|
|
|
25032
25628
|
*/
|
|
25033
25629
|
function upstreamUnavailableSignal(error) {
|
|
25034
25630
|
if (!(error instanceof Error)) return void 0;
|
|
25035
|
-
if (error instanceof HarnessTurnFailedError) {
|
|
25036
|
-
|
|
25037
|
-
|
|
25038
|
-
|
|
25039
|
-
}
|
|
25631
|
+
if (error instanceof HarnessTurnFailedError) return unavailableSignalOfFailure({
|
|
25632
|
+
error: error.message,
|
|
25633
|
+
...error.errorCode === void 0 ? {} : { errorCode: error.errorCode }
|
|
25634
|
+
});
|
|
25040
25635
|
if (error instanceof BackendTransportError) {
|
|
25041
25636
|
const code = error.upstreamCode?.toLowerCase();
|
|
25042
25637
|
if (code !== void 0 && UNAVAILABLE_CODES.has(code)) return code;
|
|
@@ -25182,8 +25777,6 @@ async function runDriverWithRetry(run) {
|
|
|
25182
25777
|
const maxAttempts = Math.max(1, policy.maxAttempts ?? DEFAULT_MAX_ATTEMPTS);
|
|
25183
25778
|
const initialBackoff = Math.max(0, policy.initialBackoffMs ?? DEFAULT_INITIAL_BACKOFF_MS);
|
|
25184
25779
|
const maxBackoff = Math.max(initialBackoff, policy.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS);
|
|
25185
|
-
const unavailablePause = Math.max(0, policy.unavailablePauseMs ?? DEFAULT_UNAVAILABLE_PAUSE_MS);
|
|
25186
|
-
const maxUnavailablePause = Math.max(unavailablePause, policy.maxUnavailablePauseMs ?? DEFAULT_MAX_UNAVAILABLE_PAUSE_MS);
|
|
25187
25780
|
const maxReprompts = run.reprompt?.maxReprompts ?? 0;
|
|
25188
25781
|
if (maxReprompts === "until-complete") {
|
|
25189
25782
|
const deadline = run.budget().deadlineMs;
|
|
@@ -25272,7 +25865,7 @@ async function runDriverWithRetry(run) {
|
|
|
25272
25865
|
}
|
|
25273
25866
|
pauses += 1;
|
|
25274
25867
|
consecutivePauses = progressed ? 1 : consecutivePauses + 1;
|
|
25275
|
-
const pause =
|
|
25868
|
+
const pause = unavailablePauseMs(consecutivePauses, policy);
|
|
25276
25869
|
await emit({
|
|
25277
25870
|
attempt,
|
|
25278
25871
|
durationMs,
|
|
@@ -25553,12 +26146,8 @@ function assertResumeContract(events, opts) {
|
|
|
25553
26146
|
if (roots.length !== 1 || roots[0]?.id !== opts.runId) throw new RuntimeRunStateError(`supervisor: resumed run '${opts.runId}' must contain exactly one root identity event; found ${roots.length}`);
|
|
25554
26147
|
const recorded = roots[0];
|
|
25555
26148
|
if (contentAddress(recorded.budget) !== contentAddress(opts.budget)) throw new RuntimeRunStateError(`supervisor: resume budget mismatch for run '${opts.runId}'; use a new runId to change limits`);
|
|
25556
|
-
const expectedAdmission = opts.reservationPolicy ? {
|
|
25557
|
-
|
|
25558
|
-
maxDepth: opts.maxDepth ?? defaultMaxDepth,
|
|
25559
|
-
maxLiveWorkers: opts.maxLiveWorkers
|
|
25560
|
-
} : void 0;
|
|
25561
|
-
if (contentAddress(recorded.recursiveAdmission ?? null) !== contentAddress(expectedAdmission ?? null)) throw new RuntimeRunStateError(`supervisor: resume reservation policy or fleet limits mismatch for run '${opts.runId}'; use a new runId`);
|
|
26149
|
+
const expectedAdmission = opts.reservationPolicy ? { policy: opts.reservationPolicy } : void 0;
|
|
26150
|
+
if (contentAddress(recorded.recursiveAdmission ?? null) !== contentAddress(expectedAdmission ?? null)) throw new RuntimeRunStateError(`supervisor: resume reservation policy mismatch for run '${opts.runId}'; use a new runId`);
|
|
25562
26151
|
if (!sameOptionalIdentity(recorded.identity, opts.rootIdentity)) throw new RuntimeRunStateError(`supervisor: resume identity mismatch for run '${opts.runId}'; ${describeIdentityMismatch(recorded.identity, opts.rootIdentity)}`);
|
|
25563
26152
|
const receipts = events.filter((event) => event.kind === "materialized" && event.id === opts.runId);
|
|
25564
26153
|
const expectedReceipt = rootMaterializationReceipt(opts);
|
|
@@ -25655,9 +26244,11 @@ function rootStartedAtMs(root) {
|
|
|
25655
26244
|
if (!Number.isFinite(startedAt)) throw new RuntimeRunStateError(`supervisor: root event for '${root.id}' has an invalid timestamp '${root.at}'`);
|
|
25656
26245
|
return startedAt;
|
|
25657
26246
|
}
|
|
25658
|
-
/** The default
|
|
25659
|
-
*
|
|
25660
|
-
|
|
26247
|
+
/** The default recursion-depth ceiling. The conserved pool is what bounds a tree's depth: every
|
|
26248
|
+
* level draws its slice from the level above, so a tree ends when its slices run out. This
|
|
26249
|
+
* ceiling only stops a runaway recursion that keeps spawning tiny slices, so it sits well above
|
|
26250
|
+
* any depth a budget can usefully pay for. */
|
|
26251
|
+
const DEFAULT_MAX_DEPTH = 16;
|
|
25661
26252
|
/**
|
|
25662
26253
|
* Normalize an arbitrary rejection into the serializable triple the result carries. A driver may
|
|
25663
26254
|
* reject with anything (a string, a plain object, a null-prototype value), and the whole point of
|
|
@@ -25682,7 +26273,7 @@ function describeRejection(error) {
|
|
|
25682
26273
|
function createSupervisor() {
|
|
25683
26274
|
let attached;
|
|
25684
26275
|
async function run(root, task, opts) {
|
|
25685
|
-
const { budget, rootIdentity, rootMaterialization, runId, journal: journalStore, blobs: blobStore, executors: executorRegistry, recoverExecutor, probes, maxDepth,
|
|
26276
|
+
const { budget, rootIdentity, rootMaterialization, runId, journal: journalStore, blobs: blobStore, executors: executorRegistry, recoverExecutor, probes, maxDepth, workerSlots, reservationPolicy, maxRestarts, withinMs, childSettleGraceMs, teardownConfirmMs, resume, retainedAtSettlement: requestedRetainedAtSettlement, ownerWorkspaceRetention, now: suppliedNow, signal, hooks, workerTrace, workerTraceUnpropagated, interactiveBindingDir } = opts;
|
|
25686
26277
|
const input = detachedSnapshot({
|
|
25687
26278
|
task,
|
|
25688
26279
|
options: {
|
|
@@ -25691,7 +26282,7 @@ function createSupervisor() {
|
|
|
25691
26282
|
...rootIdentity === void 0 ? {} : { rootIdentity },
|
|
25692
26283
|
...rootMaterialization === void 0 ? {} : { rootMaterialization },
|
|
25693
26284
|
...maxDepth === void 0 ? {} : { maxDepth },
|
|
25694
|
-
...
|
|
26285
|
+
...typeof workerSlots === "number" ? { workerSlots } : {},
|
|
25695
26286
|
...reservationPolicy === void 0 ? {} : { reservationPolicy },
|
|
25696
26287
|
...maxRestarts === void 0 ? {} : { maxRestarts },
|
|
25697
26288
|
...withinMs === void 0 ? {} : { withinMs },
|
|
@@ -25703,7 +26294,8 @@ function createSupervisor() {
|
|
|
25703
26294
|
...interactiveBindingDir === void 0 ? {} : { interactiveBindingDir }
|
|
25704
26295
|
}
|
|
25705
26296
|
}, "supervisor.run");
|
|
25706
|
-
assertRecursiveReservationPolicy(reservationPolicy
|
|
26297
|
+
assertRecursiveReservationPolicy(reservationPolicy);
|
|
26298
|
+
const slots = resolveWorkerSlots(workerSlots);
|
|
25707
26299
|
if (teardownConfirmMs !== void 0 && (typeof teardownConfirmMs !== "number" || !Number.isFinite(teardownConfirmMs) || teardownConfirmMs < 0)) throw new ValidationError$1(`supervisor: teardownConfirmMs must be a nonnegative finite number of milliseconds, got ${JSON.stringify(teardownConfirmMs)}`);
|
|
25708
26300
|
if (requestedRetainedAtSettlement !== void 0 && requestedRetainedAtSettlement !== "release" && requestedRetainedAtSettlement !== "keep") throw new ValidationError$1(`supervisor: retainedAtSettlement must be 'release' or 'keep', got ${JSON.stringify(requestedRetainedAtSettlement)}`);
|
|
25709
26301
|
opts = Object.freeze({
|
|
@@ -25766,11 +26358,7 @@ function createSupervisor() {
|
|
|
25766
26358
|
label: "root",
|
|
25767
26359
|
budget: opts.budget,
|
|
25768
26360
|
runtime: rootRuntime,
|
|
25769
|
-
...opts.reservationPolicy ? { recursiveAdmission: {
|
|
25770
|
-
policy: opts.reservationPolicy,
|
|
25771
|
-
maxDepth: opts.maxDepth ?? defaultMaxDepth,
|
|
25772
|
-
maxLiveWorkers: opts.maxLiveWorkers
|
|
25773
|
-
} } : {},
|
|
26361
|
+
...opts.reservationPolicy ? { recursiveAdmission: { policy: opts.reservationPolicy } } : {},
|
|
25774
26362
|
...opts.rootIdentity ? { identity: opts.rootIdentity } : {},
|
|
25775
26363
|
seq: 0,
|
|
25776
26364
|
at: runStartedAt
|
|
@@ -25820,8 +26408,8 @@ function createSupervisor() {
|
|
|
25820
26408
|
executors: opts.executors,
|
|
25821
26409
|
seams: { [retainedOwnerWorkspaceRetentionSeamKey]: ownerWorkspaceRetention === true },
|
|
25822
26410
|
depth: 0,
|
|
25823
|
-
maxDepth: opts.maxDepth ??
|
|
25824
|
-
|
|
26411
|
+
maxDepth: opts.maxDepth ?? 16,
|
|
26412
|
+
workerSlots: slots,
|
|
25825
26413
|
...opts.reservationPolicy ? {
|
|
25826
26414
|
reservationPolicy: opts.reservationPolicy,
|
|
25827
26415
|
ownerBudget: opts.budget
|
|
@@ -26231,13 +26819,14 @@ function pausable(ms) {
|
|
|
26231
26819
|
/** The unconfirmed set as one error clause: the count plus the node ids behind it. One integer is
|
|
26232
26820
|
* not actionable after a six-hour run. */
|
|
26233
26821
|
function describeUnconfirmed(scope) {
|
|
26234
|
-
const
|
|
26822
|
+
const unconfirmed = scope.workerCapacity.unconfirmed;
|
|
26823
|
+
const named = unconfirmed.map((node) => `${node.id} (${[
|
|
26235
26824
|
node.label,
|
|
26236
26825
|
node.runtime,
|
|
26237
26826
|
node.status,
|
|
26238
26827
|
...(node.environments ?? []).map((environment) => `${environment.provider}:${environment.environmentId}`)
|
|
26239
26828
|
].join(", ")})`).join(", ");
|
|
26240
|
-
return `${
|
|
26829
|
+
return `${unconfirmed.length} executor resource(s) not confirmed destroyed${named.length > 0 ? `: ${named}` : ""}`;
|
|
26241
26830
|
}
|
|
26242
26831
|
/** The settle window a driver's children actually get: the caller's grace, never past an explicit
|
|
26243
26832
|
* run deadline. `null` means no timer. `0` (the default) cascades immediately. */
|
|
@@ -26411,6 +27000,6 @@ function isNonEmptySpend(s) {
|
|
|
26411
27000
|
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);
|
|
26412
27001
|
}
|
|
26413
27002
|
//#endregion
|
|
26414
|
-
export {
|
|
27003
|
+
export { interactiveAdmissionSeamKey as $, cloneSpend as $i, retainedCreateMaterial as $n, profileMaterializationAxes$1 as $r, readWorkerProgress as $t, restoreScopeOwnerAcceptedExecution as A, runtimeOwnedScopeOwnerRuntime as Ai, routerBrain as An, createRuntimeEventCollector as Ar, pendingWaits as At, bindScopeRetainedOwnerEnvironmentId as B, canonicalStreamEventFromSandboxEvent as Bi, sandboxClientAsProvider as Bn, DEFAULT_LOCAL_HARNESS as Br, createBudgetPool as Bt, beginScopeOwnerAttempt as C, promptOptionsFromAgentTurnInput as Ca, providerAttemptEvidence as Ci, isTerminalDecision as Cn, exportEvalRuns as Cr, FileResultBlobStore as Ct, meterRuntimeOwnedProviderAttempt as D, runtimeOwnedExecutorMaterialization as Di, acquireSandbox as Dn, padSpanId as Dr, insideCursorNamespace as Dt, meterRuntimeOwnedAccounting as E, runtimeOwnedExecutorExecutionBinding as Ei, probeSandboxCapabilities as En, loopEventToOtelSpan as Er, InMemorySpawnJournal as Et, isWaitOutcome as F, detachedFrozen as Fi, LEAF_CONTINUATION_TASK as Fn, runSettledCommand as Fr, parseWorkerToolTraceArtifact as Ft, scopeRetainedOwnerContext as G, mapSandboxEvent as Gi, sandboxSessionTraceSource as Gn, parseCodexTokenUsage as Gr, WORKER_TRACE_PROPAGATION as Gt, consumeScopeRetainedOwnerResult as H, createSandboxUsageLedger as Hi, unavailableSignalOfFailure as Hn, harnessInvocation as Hr, newUsageTotals as Ht, pollFor as I, detachedSnapshot as Ii, createAgentEnvironmentProviderRegistry as In, runWorktreeHarness as Ir, workerTraceAnalysisStore as It, scopeRetainedOwnerResult as J, sandboxEventServedBackend as Ji, errMessage as Jn, AGENT_PROFILE_MATERIALIZATION_AXES as Jr, workerTraceHeaders as Jt, scopeRetainedOwnerPriorSpend as K, mapSandboxToolEvent as Ki, registerRetainedExecutorPreparation as Kn, CodexExecutionDiagnosticError as Kr, readWorkerTraceContext as Kt, timerAt as L, projectSandboxOutcome as Li, providerAsExecutor as Ln, captureWorktreeDiff as Lr, BudgetReconcileFault as Lt, settledToIteration as M, unknownMaterializationReceipt as Mi, canonicalObservedModelParts as Mn, sanitizeAgentRuntimeEvent as Mr, WORKER_TOOL_TRACE_SCHEMA_VERSION as Mt, createWorkerSlots as N, executableAgentProfileSnapshot as Ni, observedModelMatchesDeclared as Nn, sanitizeKnowledgeReadinessReport as Nr, captureWorkerTraceEvidence as Nt, recordScopeOwnerMaterialization as O, runtimeOwnedExecutorProviderEvidence as Oi, assertBoxlessPromptOptions as On, padTraceId as Or, loadSpawnForest as Ot, createWaitProbes as P, executableAgentSpecSnapshot as Pi, DEFAULT_SANDBOX_IDLE_TIMEOUT_SECONDS as Pn, sanitizeRuntimeStreamEvent as Pr, isTraceAnalysisStore as Pt, resolveSpawnResourcePaths as Q, chargedTokens as Qi, startRetainedRunInEnvironment as Qn, fullProfileMaterialization as Qr, createActivityLog as Qt, validateWaitSpec as R, readSandboxOutcome as Ri, providerAsSandboxClient as Rn, createWorktree as Rr, ReservationWaitRefused as Rt, assertRecursiveReservationPolicy as S, promptFromAgentTurnInput as Sa, newExecutionAttemptId as Si, defaultSelectWinner as Sn, createOtelExporter as Sr, createInPlaceCliExecutor as St, deriveNodeExecutionIdentity as T, runtimeOwnedDriveHarnessProviderEvidence as Ti, createSandboxLineage as Tn, generateSpanId as Tr, InMemoryResultBlobStore as Tt, prepareScopeRetainedOwnerTask as U, extractLlmCallEvent as Ui, createPushTraceSource as Un, harnessSupportsReasoningEffort as Ur, spendFromUsageEvents as Ut, bindScopeRetainedOwnerProvider as V, createSandboxToolPartState as Vi, unavailablePauseMs as Vn, LOCAL_HARNESSES as Vr, meterUsageEvent as Vt, reconcileScopeRetainedOwnerEnvironment as W, isSandboxTerminalEvent as Wi, decodeToolPart as Wn, localHarnessExecutable as Wr, spendFromUsageTotals as Wt, environmentReader as X, sumSandboxUsage as Xi, recoverRetainedRun as Xn, controlProfileMaterialization as Xr, taskToPrompt as Xt, SPAWN_RESOURCE_PATH_MAX_BYTES as Y, sandboxProgressEvents as Yi, reconnectRetainedRun as Yn, assertProfileMaterialization as Yr, workerTraceSeamKey as Yt, hostDirectoryReader as Z, addSpend as Zi, startRetainedRun as Zn, defineProfileMaterializationContract as Zr, DEFAULT_STALL_AFTER_MS as Zt, driverChild as _, awaitAbortable$1 as _a, authoredProfileDigest as _i, readCodexRolloutSession as _n, INTELLIGENCE_WIRE_VERSION as _r, createExecutorRegistry as _t, collectDelivered as a, sleep as aa, renderUnsupported as ai, createPeerMailbox as an, runAbortable as ar, workerInteractiveBindingsDir as at, withDriverExecutor as b, teardownExecutor as ba, knownExecutionBindingReceipt as bi, TERMINAL_DECISIONS as bn, buildRuntimeEventOtelSpans as br, DEFAULT_SANDBOX_STEERING_MAX_TURNS as bt, runTree as c, throwIfAborted as ca, validateProfileMaterialization as ci, peerMailVerbNames as cn, resolveRedactor as cr, startRetainedInteractiveRun as ct, HarnessTurnFailedError as d, zeroSpend as da, parseCommittedJsonLines as di, executorFailure as dn, persistHarnessTranscript as dr, rollingDispatch as dt, deleteBoxSafe as ea, promptControlProfileMaterialization as ei, createInbox as en, destroyInteractiveEnvironment as er, readWorkerInteractiveAdmissions as et, classifyDriverFailure as f, addResourceSpend as fa, prepareJsonlAppend as fi, bridgeAdmissionRefusal as fn, contentAddress as fr, bindReusableExecutorExecutionId as ft, upstreamUnavailableSignal as g, abortError$2 as ga, attestRuntimeOwnedScopeOwner as gi, harnessUsageIsEmpty as gn, traceContextToEnv as gr, createExecutor as gt, summarizeDriverAttempts as h, decodeHarnessUsage as ha, attestRuntimeOwnedPendingExecutor as hi, createCodexRolloutStoreReader as hn, readTraceContextFromEnv as hr, cliWorktreeExecutor as ht, bestDelivered as i, randomSuffix as ia, renderProfileMaterializationIssues as ii, claimsAuthority as in, linkAbort as ir, workerInteractiveBindingFile as it, scopeOwnerExecutorNodeContext as j, unknownExecutionBindingReceipt as ji, runBrainLoop as jn, createRuntimeStreamEventCollector as jr, replaySpawnTree as jt, recordScopeOwnerPause as k, runtimeOwnedPendingExecutorMaterialization as ki, readPromptOptions as kn, toOtelAttributes as kr, materializeTreeView as kt, DEFAULT_MAX_BARREN_REPROMPTS as l, unmeteredSpend as la, worktreeCliProfileMaterialization as li, isLiveNodeStatus as ln, captureHarnessTranscript as lr, freeSlots as lt, runDriverWithRetry as m, withBudgetResources as ma, writeAllBytes as mi, addHarnessUsage as mn, mergeTraceEnv as mr, cliInPlaceExecutor as mt, createRootHandle as n, isAbortError$2 as na, promptOnlyProfileMaterialization as ni, DEFAULT_PEER_MAIL_LIMITS as nn, RunCancellationReason as nr, attachWorker as nt, pickBestDelivered as o, stringifySafe as oa, sandboxActProfileMaterialization as oi, isPeerMailEnvelope as on, defaultRedactor as or, reconnectRetainedInteractiveRun as ot, defaultUnmetContractSteer as p, resourceTelemetry as pa, readCommittedJsonLines as pi, bridgeModelRouteRefusal as pn, createPropagatingTraceEmitter as pr, captureReusableExecutorConfig as pt, scopeRetainedOwnerResourceReader as q, notifySandboxEventObserver as qi, retainedExecutorSeamKey as qn, terminateProcessTreeAndConfirm as qr, workerTraceEnv as qt, createSupervisor as r, promptCacheTokenClasses as ra, promptResourceProfileMaterialization as ri, PEER_MAIL_WIRE_KEY as rn, abortError as rr, readWorkerInteractiveBinding as rt, runFinalizer as s, throwAbort as sa, unsupportedProfileDimensions as si, peerMailTools as sn, defaultRedactorIdentityMaterial as sr, recoverRetainedInteractiveRun as st, DEFAULT_MAX_DEPTH as t, hasCompleteCacheBreakdown as ta, promptModelProfileMaterialization as ti, AUTHORITY_MARKERS as tn, environmentGone as tr, workerInteractiveAdmissionFile as tt, DriverAttemptsExhaustedError as u, withTimeout as ua, isNoEntError as ui, isTerminalNodeStatus as un, harnessTranscriptArtifact as ur, queueOf as ut, driverExecutorFactory as v, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as va, finalizeRuntimeOwnedPendingExecutor as vi, bridgeRuntimeAttachmentsKey as vn, buildLoopOtelSpans as vr, snapshotExecutorConfig as vt, createScope as w, providerMessageText as wa, recordRuntimeOwnedDriveHarnessProviderEvidence as wi, runAgentRounds as wn, flatOtelSpan as wr, FileSpawnJournal as wt, SUBTREE_RESULT_LIMIT as x, teardownSurfaces as xa, knownMaterializationReceipt as xi, createSandboxForSpec as xn, createOpenInferenceFileExporter as xr, createSteerableSandboxSession as xt, isDriverSpec as y, armDeadlineTimer as ya, inheritRuntimeOwnedExecutorAttestation as yi, bridgeStopSignalKey as yn, buildLoopSpanNodes as yr, createWorktreeCliExecutor as yt, waitUntil as z, assertSandboxServedModel as zi, resolveAgentEnvironmentProvider as zn, removeWorktree as zr, assertValidBudget as zt };
|
|
26415
27004
|
|
|
26416
|
-
//# sourceMappingURL=supervisor-
|
|
27005
|
+
//# sourceMappingURL=supervisor-B8UMAXya.js.map
|