@tangle-network/agent-runtime 0.291.0 → 0.292.3
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-BPZL1WCG.js → activation-Cer3QjGB.js} +2 -2
- package/dist/{activation-BPZL1WCG.js.map → activation-Cer3QjGB.js.map} +1 -1
- package/dist/{activation-D8DOMMZc.d.ts → activation-CssIKm0J.d.ts} +3 -3
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/{coordination-driver-CUnF7gfN.js → coordination-driver-CoTfoTNv.js} +2 -2
- package/dist/{coordination-driver-CUnF7gfN.js.map → coordination-driver-CoTfoTNv.js.map} +1 -1
- package/dist/{delegate-B0j4915d.js → delegate-CaeK1_xI.js} +2 -2
- package/dist/{delegate-B0j4915d.js.map → delegate-CaeK1_xI.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +2 -2
- package/dist/{graph-ByPZb_xc.js → graph-tfXugm_A.js} +4 -4
- package/dist/{graph-ByPZb_xc.js.map → graph-tfXugm_A.js.map} +1 -1
- package/dist/{improvement-cycle-DipoyAM3.js → improvement-cycle-CeX2I_TB.js} +3 -3
- package/dist/{improvement-cycle-DipoyAM3.js.map → improvement-cycle-CeX2I_TB.js.map} +1 -1
- package/dist/{index-D-5e8mss.d.ts → index-H2CGSpv6.d.ts} +4 -4
- package/dist/index.d.ts +6 -6
- package/dist/index.js +7 -7
- package/dist/intelligence.d.ts +3 -3
- package/dist/intelligence.js +4 -4
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +8 -8
- package/dist/{loop-runner-bin-DhPBdCux.js → loop-runner-bin-BI2JSnjR.js} +3 -3
- package/dist/{loop-runner-bin-DhPBdCux.js.map → loop-runner-bin-BI2JSnjR.js.map} +1 -1
- package/dist/{loop-runner-bin-Bkw-_LkG.d.ts → loop-runner-bin-CsKO_N_m.d.ts} +3 -3
- 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-De6m7S4Y.d.ts → openai-tools-BoNA2t3H.d.ts} +2 -2
- package/dist/profiles.d.ts +2 -2
- package/dist/{provision-supervisor-DvEpuocs.js → provision-supervisor-DBIKsI2A.js} +3 -3
- package/dist/{provision-supervisor-DvEpuocs.js.map → provision-supervisor-DBIKsI2A.js.map} +1 -1
- package/dist/{runtime-Ba7oK4M1.js → runtime-DDSzPHdr.js} +8 -8
- package/dist/{runtime-Ba7oK4M1.js.map → runtime-DDSzPHdr.js.map} +1 -1
- package/dist/{search-method-Cs6SLt8I.js → search-method-BbplGQmw.js} +2 -2
- package/dist/{search-method-Cs6SLt8I.js.map → search-method-BbplGQmw.js.map} +1 -1
- package/dist/{server-CVRFM3ZF.js → server-D3WeSX4C.js} +3 -3
- package/dist/{server-CVRFM3ZF.js.map → server-D3WeSX4C.js.map} +1 -1
- package/dist/{stream-agent-turn-n3kOukD_.d.ts → stream-agent-turn-DnJkgxgW.d.ts} +5 -4
- package/dist/{substrate-DFWtsdNI.d.ts → substrate-DaVkSZLU.d.ts} +2 -2
- package/dist/{supervise-dYioyGT-.js → supervise-SCAuJ1Pj.js} +3 -3
- package/dist/{supervise-dYioyGT-.js.map → supervise-SCAuJ1Pj.js.map} +1 -1
- package/dist/{supervisor-DpUCJtKC.js → supervisor-B8uT95S1.js} +129 -36
- package/dist/supervisor-B8uT95S1.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-BFcLI8Ge.d.ts → types-Ci1QbSne.d.ts} +2 -1
- package/package.json +2 -1
- package/dist/supervisor-DpUCJtKC.js.map +0 -1
|
@@ -5309,7 +5309,7 @@ function createOtelExporter(config) {
|
|
|
5309
5309
|
body: JSON.stringify(body),
|
|
5310
5310
|
signal: AbortSignal.timeout(timeoutMs)
|
|
5311
5311
|
});
|
|
5312
|
-
const text = await response.text()
|
|
5312
|
+
const text = await response.text();
|
|
5313
5313
|
if (!response.ok) {
|
|
5314
5314
|
const detail = text ? `: ${text.slice(0, 200)}` : "";
|
|
5315
5315
|
drop(batch.length, `HTTP ${response.status} from ${url}${detail}`);
|
|
@@ -5324,6 +5324,7 @@ function createOtelExporter(config) {
|
|
|
5324
5324
|
}
|
|
5325
5325
|
/** The single sender: it drains the queue batch by batch until the queue is empty. */
|
|
5326
5326
|
function drain() {
|
|
5327
|
+
if (sending === void 0 && queue.length === 0) return Promise.resolve();
|
|
5327
5328
|
sending ??= (async () => {
|
|
5328
5329
|
try {
|
|
5329
5330
|
while (queue.length > 0) {
|
|
@@ -8097,15 +8098,18 @@ function spendFromUsageEvents(events) {
|
|
|
8097
8098
|
for (const ev of events) meterUsageEvent(totals, ev);
|
|
8098
8099
|
return spendFromUsageTotals(totals);
|
|
8099
8100
|
}
|
|
8100
|
-
/** Fresh
|
|
8101
|
-
function newUsageTotals() {
|
|
8101
|
+
/** Fresh accounting totals, optionally restored from verified committed spend. */
|
|
8102
|
+
function newUsageTotals(priorSpent) {
|
|
8103
|
+
if (priorSpent !== void 0) assertValidSpend(priorSpent, "prior committed usage");
|
|
8102
8104
|
return {
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8105
|
+
...addResourceSpend(priorSpent?.resources),
|
|
8106
|
+
tokens: priorSpent === void 0 ? zeroTokenUsage() : cloneTokenUsage(priorSpent.tokens),
|
|
8107
|
+
tokensKnown: priorSpent?.tokensKnown !== false,
|
|
8108
|
+
...priorSpent?.tokensProvenance === void 0 ? {} : { tokensProvenance: priorSpent.tokensProvenance },
|
|
8109
|
+
usd: priorSpent?.usd ?? 0,
|
|
8110
|
+
usdEstimated: priorSpent?.usdEstimated ?? 0,
|
|
8111
|
+
usdKnown: priorSpent?.usdKnown !== false,
|
|
8112
|
+
iterations: priorSpent?.iterations ?? 0
|
|
8109
8113
|
};
|
|
8110
8114
|
}
|
|
8111
8115
|
/**
|
|
@@ -10555,9 +10559,11 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10555
10559
|
const createProfile = options.profileForCreate?.(profile) ?? profile;
|
|
10556
10560
|
if (placement && canonicalAgentProfileDigest(createProfile) !== canonicalAgentProfileDigest(profile)) throw new ValidationError("provider placement: profileForCreate cannot change the selected profile");
|
|
10557
10561
|
const executionId = retention?.executionId ?? node?.nodeId ?? `provider-run-${randomUUID()}`;
|
|
10558
|
-
|
|
10559
|
-
|
|
10562
|
+
let workspaceExecutionId = executionId;
|
|
10563
|
+
const resetWorkspaceState = (next, invocationId = workspaceExecutionId) => {
|
|
10564
|
+
if (workspaceEnvironmentId === next.id && workspaceExecutionId === invocationId) return;
|
|
10560
10565
|
workspaceEnvironmentId = next.id;
|
|
10566
|
+
workspaceExecutionId = invocationId;
|
|
10561
10567
|
workspaceSnapshot = void 0;
|
|
10562
10568
|
workspaceProvenance = void 0;
|
|
10563
10569
|
workspaceCoverageComplete = false;
|
|
@@ -10607,7 +10613,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10607
10613
|
workspaceOutcome = outcome;
|
|
10608
10614
|
workspaceCapturePromise = captureProviderWorkspaceSnapshot(workspaceRetention, {
|
|
10609
10615
|
environment: next,
|
|
10610
|
-
executionId,
|
|
10616
|
+
executionId: workspaceExecutionId,
|
|
10611
10617
|
...workspaceControlRef === void 0 ? {} : { controlRef: workspaceControlRef },
|
|
10612
10618
|
...node === void 0 ? {} : { node },
|
|
10613
10619
|
providerSessionId,
|
|
@@ -10740,17 +10746,23 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10740
10746
|
beginWorkspaceExecution();
|
|
10741
10747
|
const linked = linkAbort(ctx.signal, signal, controller.signal);
|
|
10742
10748
|
try {
|
|
10743
|
-
const executionStartedAt = Date.now();
|
|
10749
|
+
const executionStartedAt = Date.now() - (retention?.priorSpent?.ms ?? 0);
|
|
10744
10750
|
let invocation = {
|
|
10745
10751
|
task,
|
|
10746
10752
|
retention,
|
|
10747
10753
|
executionId,
|
|
10748
10754
|
recovering
|
|
10749
10755
|
};
|
|
10750
|
-
let carried;
|
|
10756
|
+
let carried = retention?.priorSpent;
|
|
10751
10757
|
let refusalsInARow = 0;
|
|
10752
10758
|
for (let attempt = 1;; attempt += 1) {
|
|
10753
|
-
const continued =
|
|
10759
|
+
const continued = attempt > 1;
|
|
10760
|
+
if (continued && environment !== void 0) {
|
|
10761
|
+
resetWorkspaceState(environment, invocation.executionId);
|
|
10762
|
+
workspaceControlRef = void 0;
|
|
10763
|
+
providerSessionId = null;
|
|
10764
|
+
workspacePreservationRequired = options.workspaceRetention !== void 0;
|
|
10765
|
+
}
|
|
10754
10766
|
const ended = yield* streamProviderExecutor({
|
|
10755
10767
|
provider,
|
|
10756
10768
|
profile,
|
|
@@ -10765,7 +10777,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10765
10777
|
recovering: invocation.recovering,
|
|
10766
10778
|
...carried === void 0 ? {} : { carried },
|
|
10767
10779
|
executionStartedAt,
|
|
10768
|
-
mayContinue: options.unavailablePause !== false &&
|
|
10780
|
+
mayContinue: options.unavailablePause !== false && invocation.retention?.continueInvocation !== void 0,
|
|
10769
10781
|
onRetained: (handle) => {
|
|
10770
10782
|
retained = handle;
|
|
10771
10783
|
workspaceControlRef = freezeControlRef(handle.controlRef);
|
|
@@ -10805,6 +10817,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10805
10817
|
},
|
|
10806
10818
|
onPublishedSnapshot: (snapshot) => {
|
|
10807
10819
|
workspacePublishedSnapshot = snapshot;
|
|
10820
|
+
if (continued && snapshot !== void 0 && (!options.workspaceRetention?.requireCompleteProvenance || workspaceCoverageComplete)) workspacePreservationRequired = false;
|
|
10808
10821
|
},
|
|
10809
10822
|
captureWorkspace,
|
|
10810
10823
|
workspaceControlRef: () => workspaceControlRef,
|
|
@@ -10817,7 +10830,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10817
10830
|
});
|
|
10818
10831
|
const refusal = ended.unavailable;
|
|
10819
10832
|
const continueInvocation = invocation.retention?.continueInvocation;
|
|
10820
|
-
if (refusal === void 0 || continueInvocation === void 0) return;
|
|
10833
|
+
if (refusal === void 0 || continueInvocation === void 0 || workspacePreservationRequired || workspaceCaptureFailure !== void 0) return;
|
|
10821
10834
|
refusalsInARow = ended.madeProgress ? 1 : refusalsInARow + 1;
|
|
10822
10835
|
const pauseMs = unavailablePauseMs(refusalsInARow, options.unavailablePause || {});
|
|
10823
10836
|
await invocation.retention?.onPause?.({
|
|
@@ -11154,7 +11167,8 @@ async function* streamProviderExecutor(args) {
|
|
|
11154
11167
|
workspaceCapture: providerWorkspaceCaptureReceipt(args, environment, retainedWorkspace, turn.sessionId ?? null)
|
|
11155
11168
|
});
|
|
11156
11169
|
} catch (captureError) {
|
|
11157
|
-
failure = captureError
|
|
11170
|
+
if (captureError instanceof Error && captureError !== error) failure = captureError.cause === void 0 ? Object.assign(captureError, { cause: failure }) : new AggregateError([captureError, failure], captureError.message, { cause: captureError });
|
|
11171
|
+
else failure = captureError;
|
|
11158
11172
|
}
|
|
11159
11173
|
args.onHarnessTranscript(await captureHarnessTranscript(environment, args.profile.harness, linked));
|
|
11160
11174
|
} finally {
|
|
@@ -21704,15 +21718,20 @@ async function prepareInterruptedExecutors(opts, events, signal, now, parentId =
|
|
|
21704
21718
|
* derived from the input sequence exactly as the live scope derived it.
|
|
21705
21719
|
*/
|
|
21706
21720
|
async function leafContinuation(node, owned, latestInput, opts) {
|
|
21707
|
-
const
|
|
21721
|
+
const before = owned.slice(0, owned.indexOf(latestInput));
|
|
21722
|
+
const priorSession = [...before].reverse().flatMap((event) => event.kind === "execution-admitted" && event.admission.phase === "environment" ? [event.admission] : [])[0];
|
|
21708
21723
|
if (priorSession === void 0) throw new RuntimeRunStateError(`cannot recover '${node.id}': its continuation names no environment it continued in`);
|
|
21724
|
+
const priorResult = [...before].reverse().find((event) => event.kind === "execution-result");
|
|
21725
|
+
if (priorResult === void 0) throw new RuntimeRunStateError(`cannot recover '${node.id}': its continuation has no committed predecessor result`);
|
|
21726
|
+
await assertRecordedResult(node, priorResult, owned, opts);
|
|
21709
21727
|
const task = await opts.blobs.get(latestInput.taskRef);
|
|
21710
21728
|
if (task === void 0 || contentAddress(task) !== latestInput.taskRef) throw new RuntimeRunStateError(`continuation task for '${node.id}' is missing or corrupt`);
|
|
21711
21729
|
return {
|
|
21712
21730
|
task,
|
|
21713
21731
|
inputSeq: latestInput.seq,
|
|
21714
21732
|
executionId: leafContinuationExecutionId(node.id, latestInput.seq),
|
|
21715
|
-
priorSession
|
|
21733
|
+
priorSession,
|
|
21734
|
+
priorSpent: priorResult.spent
|
|
21716
21735
|
};
|
|
21717
21736
|
}
|
|
21718
21737
|
async function assertRecordedResult(node, result, events, opts) {
|
|
@@ -23389,6 +23408,7 @@ const pauseRecorders = /* @__PURE__ */ new WeakMap();
|
|
|
23389
23408
|
const driverAttemptRecorders = /* @__PURE__ */ new WeakMap();
|
|
23390
23409
|
const recoveryStarters = /* @__PURE__ */ new WeakMap();
|
|
23391
23410
|
const retainedReleasers = /* @__PURE__ */ new WeakMap();
|
|
23411
|
+
const childDrains = /* @__PURE__ */ new WeakMap();
|
|
23392
23412
|
const retainedSlotClosers = /* @__PURE__ */ new WeakMap();
|
|
23393
23413
|
const teardownRetriers = /* @__PURE__ */ new WeakMap();
|
|
23394
23414
|
const teardownRetriable = /* @__PURE__ */ new WeakMap();
|
|
@@ -23557,6 +23577,10 @@ function hasRetriableTeardowns(scope, release) {
|
|
|
23557
23577
|
function closeScopeAdmission(scope) {
|
|
23558
23578
|
admissionSeals.get(scope)?.();
|
|
23559
23579
|
}
|
|
23580
|
+
/** Join local observers after abort without requiring a writable settlement journal. */
|
|
23581
|
+
async function waitForScopeChildren(scope) {
|
|
23582
|
+
await childDrains.get(scope)?.();
|
|
23583
|
+
}
|
|
23560
23584
|
/** Fail before execution when a reservation policy is malformed. */
|
|
23561
23585
|
function assertRecursiveReservationPolicy(policy) {
|
|
23562
23586
|
if (policy === void 0) return;
|
|
@@ -23907,7 +23931,8 @@ function createScope(args) {
|
|
|
23907
23931
|
const retainedContext = (continuing) => ({
|
|
23908
23932
|
...continuing === void 0 ? {} : {
|
|
23909
23933
|
executionId: continuing.executionId,
|
|
23910
|
-
priorSession: continuing.priorSession
|
|
23934
|
+
priorSession: continuing.priorSession,
|
|
23935
|
+
...continuing.priorSpent === void 0 ? {} : { priorSpent: continuing.priorSpent }
|
|
23911
23936
|
},
|
|
23912
23937
|
admissions,
|
|
23913
23938
|
...markRecoveryReady && continuing === void 0 ? { onReady: markRecoveryReady } : {},
|
|
@@ -23943,10 +23968,12 @@ function createScope(args) {
|
|
|
23943
23968
|
});
|
|
23944
23969
|
inputSeq = nextSeq;
|
|
23945
23970
|
admissions = [];
|
|
23971
|
+
const priorSpent = live.acceptedResult.spent;
|
|
23946
23972
|
live.acceptedResult = void 0;
|
|
23947
23973
|
return retainedContext({
|
|
23948
23974
|
executionId: leafContinuationExecutionId(id, nextSeq),
|
|
23949
|
-
priorSession: environment
|
|
23975
|
+
priorSession: environment,
|
|
23976
|
+
priorSpent
|
|
23950
23977
|
});
|
|
23951
23978
|
}
|
|
23952
23979
|
});
|
|
@@ -23964,7 +23991,8 @@ function createScope(args) {
|
|
|
23964
23991
|
...args.seams,
|
|
23965
23992
|
[retainedExecutorSeamKey]: retainedContext(recovery?.continuation === void 0 ? void 0 : {
|
|
23966
23993
|
executionId: recovery.continuation.executionId,
|
|
23967
|
-
priorSession: recovery.continuation.priorSession
|
|
23994
|
+
priorSession: recovery.continuation.priorSession,
|
|
23995
|
+
priorSpent: recovery.continuation.priorSpent
|
|
23968
23996
|
}),
|
|
23969
23997
|
[nestedScopeSeamKey]: makeNestedScopeSeam(args, workerSlots, permit, id, opts.budget, childDeadlineAtMs, deferredOwner),
|
|
23970
23998
|
...workerTrace ? { [workerTraceSeamKey]: workerTrace } : {},
|
|
@@ -24214,7 +24242,7 @@ function createScope(args) {
|
|
|
24214
24242
|
const childRun = runChild(live, executor, controller, recovery?.continuation?.task ?? task, opts, args.pool, reservation.ticket, args.blobs, now, args.journal, args.root, () => progressSeq++, materializationCommitted, {
|
|
24215
24243
|
complete: async () => pendingEvidence?.complete(),
|
|
24216
24244
|
fail: async () => pendingEvidence?.fail()
|
|
24217
|
-
}, childDeadlineAtMs, recovery !== void 0, closeRetainedWrites, budgetGranted, permit.ready);
|
|
24245
|
+
}, childDeadlineAtMs, recovery !== void 0, closeRetainedWrites, budgetGranted, permit.ready, recovery?.continuation?.priorSpent);
|
|
24218
24246
|
args.pool.attribute(reservation.ticket, { stage: "executing" });
|
|
24219
24247
|
const interactiveBindingCommitted = spawnCommitted.then(async () => {
|
|
24220
24248
|
if (args.interactiveBindingDir === void 0) return;
|
|
@@ -24226,7 +24254,7 @@ function createScope(args) {
|
|
|
24226
24254
|
const ready = await readInteractiveReadyUntilWorkerEnds(live.readInteractiveReady, childRun, controller.signal);
|
|
24227
24255
|
if (ready !== void 0 && (ready.status === "available" || ready.reason !== "interactive-session-not-started")) writeWorkerInteractiveBinding(args.interactiveBindingDir, id, opts.label, args.root, ready, now);
|
|
24228
24256
|
});
|
|
24229
|
-
|
|
24257
|
+
const settled = childRun.then(async (s) => {
|
|
24230
24258
|
let resolution = s;
|
|
24231
24259
|
try {
|
|
24232
24260
|
await interactiveBindingCommitted;
|
|
@@ -24240,6 +24268,8 @@ function createScope(args) {
|
|
|
24240
24268
|
clearChildDeadline?.();
|
|
24241
24269
|
if (cascadeAbort) args.signal.removeEventListener("abort", cascadeAbort);
|
|
24242
24270
|
});
|
|
24271
|
+
settled.catch(() => void 0);
|
|
24272
|
+
live.settled = settled;
|
|
24243
24273
|
return {
|
|
24244
24274
|
ok: true,
|
|
24245
24275
|
handle,
|
|
@@ -24588,6 +24618,14 @@ function createScope(args) {
|
|
|
24588
24618
|
};
|
|
24589
24619
|
}
|
|
24590
24620
|
};
|
|
24621
|
+
childDrains.set(scope, async () => {
|
|
24622
|
+
await Promise.allSettled([...children.values()].map((child) => child.settled));
|
|
24623
|
+
await Promise.allSettled([...settlementWrites]);
|
|
24624
|
+
await Promise.all([...children.values()].map(async (child) => {
|
|
24625
|
+
const nested = child.readNestedScope?.();
|
|
24626
|
+
if (nested !== void 0) await waitForScopeChildren(nested);
|
|
24627
|
+
}));
|
|
24628
|
+
});
|
|
24591
24629
|
admissionSeals.set(scope, () => {
|
|
24592
24630
|
admissionClosed = true;
|
|
24593
24631
|
});
|
|
@@ -25316,7 +25354,8 @@ async function finalizeWait(child, settlement, seq, args, now, handle) {
|
|
|
25316
25354
|
* applied per child). The reservation is reconciled on EVERY path (success, abort, throw)
|
|
25317
25355
|
* so the conserved pool can never leak a reservation.
|
|
25318
25356
|
*/
|
|
25319
|
-
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()) {
|
|
25357
|
+
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(), priorSpent) {
|
|
25358
|
+
if (priorSpent !== void 0) live.spent = detachedSnapshot(priorSpent, "prior committed usage");
|
|
25320
25359
|
let reconciled = false;
|
|
25321
25360
|
let reconciliationError;
|
|
25322
25361
|
let teardownFailure;
|
|
@@ -25418,7 +25457,7 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
|
|
|
25418
25457
|
seq: nextProgressSeq(),
|
|
25419
25458
|
at: new Date(now()).toISOString()
|
|
25420
25459
|
});
|
|
25421
|
-
}, childAbort.signal);
|
|
25460
|
+
}, childAbort.signal, priorSpent);
|
|
25422
25461
|
live.spent = spend;
|
|
25423
25462
|
const reported = executor.resultArtifact();
|
|
25424
25463
|
artifact = await retainOutput(reported, preserveUnknownTelemetry(spend, reported.spent));
|
|
@@ -25786,8 +25825,8 @@ function freezeCorrelation(value) {
|
|
|
25786
25825
|
* turns deep from one that had produced nothing. It also means a worker that THROWS mid-stream
|
|
25787
25826
|
* now reconciles its real partial spend instead of refunding work the provider already billed.
|
|
25788
25827
|
*/
|
|
25789
|
-
async function foldStream(stream, onProgress, signal) {
|
|
25790
|
-
const totals = newUsageTotals();
|
|
25828
|
+
async function foldStream(stream, onProgress, signal, priorSpent) {
|
|
25829
|
+
const totals = newUsageTotals(priorSpent);
|
|
25791
25830
|
const iterator = stream[Symbol.asyncIterator]();
|
|
25792
25831
|
try {
|
|
25793
25832
|
for (;;) {
|
|
@@ -25801,6 +25840,7 @@ async function foldStream(stream, onProgress, signal) {
|
|
|
25801
25840
|
tokens: cloneTokenUsage(totals.tokens),
|
|
25802
25841
|
...totals.tokensKnown ? {} : { tokensKnown: false },
|
|
25803
25842
|
usd: totals.usd,
|
|
25843
|
+
...totals.usdEstimated > 0 ? { usdEstimated: totals.usdEstimated } : {},
|
|
25804
25844
|
...totals.usdKnown ? {} : { usdKnown: false },
|
|
25805
25845
|
...totals.tokensProvenance === void 0 || totals.tokensProvenance === "stream-receipt" ? {} : { tokensProvenance: totals.tokensProvenance },
|
|
25806
25846
|
ms: 0
|
|
@@ -27453,6 +27493,51 @@ async function runFinalizer(finalizer, args) {
|
|
|
27453
27493
|
return await accepted(candidate) ? candidate : void 0;
|
|
27454
27494
|
}
|
|
27455
27495
|
//#endregion
|
|
27496
|
+
//#region src/runtime/supervise/run-persistence.ts
|
|
27497
|
+
/** One failed store operation revokes this controller's writes, never its retained executions. */
|
|
27498
|
+
function guardRunPersistence(journal, blobs, interrupt) {
|
|
27499
|
+
let failure;
|
|
27500
|
+
const pending = /* @__PURE__ */ new Set();
|
|
27501
|
+
const operation = (perform) => {
|
|
27502
|
+
const result = Promise.resolve().then(async () => {
|
|
27503
|
+
if (failure !== void 0) throw failure;
|
|
27504
|
+
try {
|
|
27505
|
+
return await perform();
|
|
27506
|
+
} catch (cause) {
|
|
27507
|
+
if (failure === void 0) {
|
|
27508
|
+
failure = new RuntimeRunStateError(`supervisor: durable state unavailable; restore storage and resume the same run (${cause instanceof Error ? cause.message : String(cause)})`, { cause });
|
|
27509
|
+
interrupt(failure);
|
|
27510
|
+
}
|
|
27511
|
+
throw failure;
|
|
27512
|
+
}
|
|
27513
|
+
});
|
|
27514
|
+
pending.add(result);
|
|
27515
|
+
result.then(() => pending.delete(result), () => pending.delete(result));
|
|
27516
|
+
return result;
|
|
27517
|
+
};
|
|
27518
|
+
return {
|
|
27519
|
+
journal: {
|
|
27520
|
+
loadTree: (root) => operation(() => journal.loadTree(root)),
|
|
27521
|
+
beginTree: (root, at) => operation(() => journal.beginTree(root, at)),
|
|
27522
|
+
appendEvent: (root, event) => operation(() => journal.appendEvent(root, event)),
|
|
27523
|
+
...journal.appendEvents === void 0 ? {} : { appendEvents: (root, events) => operation(() => journal.appendEvents(root, events)) }
|
|
27524
|
+
},
|
|
27525
|
+
blobs: {
|
|
27526
|
+
get: (ref) => operation(() => blobs.get(ref)),
|
|
27527
|
+
put: (ref, artifact) => operation(() => blobs.put(ref, artifact))
|
|
27528
|
+
},
|
|
27529
|
+
get failed() {
|
|
27530
|
+
return failure !== void 0;
|
|
27531
|
+
},
|
|
27532
|
+
async drain() {
|
|
27533
|
+
await Promise.allSettled([...pending]);
|
|
27534
|
+
},
|
|
27535
|
+
assertAvailable() {
|
|
27536
|
+
if (failure !== void 0) throw failure;
|
|
27537
|
+
}
|
|
27538
|
+
};
|
|
27539
|
+
}
|
|
27540
|
+
//#endregion
|
|
27456
27541
|
//#region src/runtime/supervise/supervisor.ts
|
|
27457
27542
|
/**
|
|
27458
27543
|
*
|
|
@@ -27649,10 +27734,14 @@ function createSupervisor() {
|
|
|
27649
27734
|
const slots = resolveWorkerSlots(workerSlots);
|
|
27650
27735
|
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)}`);
|
|
27651
27736
|
if (requestedRetainedAtSettlement !== void 0 && requestedRetainedAtSettlement !== "release" && requestedRetainedAtSettlement !== "keep") throw new ValidationError$1(`supervisor: retainedAtSettlement must be 'release' or 'keep', got ${JSON.stringify(requestedRetainedAtSettlement)}`);
|
|
27737
|
+
const controller = new AbortController();
|
|
27738
|
+
const persistence = guardRunPersistence(journalStore, blobStore, (error) => {
|
|
27739
|
+
controller.abort(error);
|
|
27740
|
+
});
|
|
27652
27741
|
opts = Object.freeze({
|
|
27653
27742
|
...input.options,
|
|
27654
|
-
journal:
|
|
27655
|
-
blobs:
|
|
27743
|
+
journal: persistence.journal,
|
|
27744
|
+
blobs: persistence.blobs,
|
|
27656
27745
|
executors: executorRegistry,
|
|
27657
27746
|
...recoverExecutor ? { recoverExecutor } : {},
|
|
27658
27747
|
...probes === void 0 ? {} : { probes },
|
|
@@ -27731,7 +27820,6 @@ function createSupervisor() {
|
|
|
27731
27820
|
at: runStartedAt
|
|
27732
27821
|
});
|
|
27733
27822
|
}
|
|
27734
|
-
const controller = new AbortController();
|
|
27735
27823
|
let cascadeAborted = false;
|
|
27736
27824
|
const cascadeAbort = (reason) => {
|
|
27737
27825
|
if (controller.signal.aborted) return false;
|
|
@@ -27821,9 +27909,9 @@ function createSupervisor() {
|
|
|
27821
27909
|
const settleGraceMs = !controller.signal.aborted ? boundedSettleGrace(opts.childSettleGraceMs, rootDeadlineAtMs, now) : 0;
|
|
27822
27910
|
try {
|
|
27823
27911
|
teardownUnconfirmed = await drainLiveChildren(openScope, controller, settleGraceMs);
|
|
27824
|
-
if (retainedAtSettlement === "release") teardownUnconfirmed = await releaseRetainedEnvironments(openScope);
|
|
27912
|
+
if (!persistence.failed && retainedAtSettlement === "release") teardownUnconfirmed = await releaseRetainedEnvironments(openScope);
|
|
27825
27913
|
const confirmWindowMs = opts.teardownConfirmMs ?? DEFAULT_TEARDOWN_CONFIRM_MS;
|
|
27826
|
-
const releasing = retainedAtSettlement === "release";
|
|
27914
|
+
const releasing = !persistence.failed && retainedAtSettlement === "release";
|
|
27827
27915
|
if (teardownUnconfirmed.length > 0 && confirmWindowMs > 0 && hasRetriableTeardowns(openScope, releasing)) {
|
|
27828
27916
|
const pending = teardownUnconfirmed;
|
|
27829
27917
|
for (const node of pending) await opts.journal.appendEvent(opts.runId, {
|
|
@@ -27883,7 +27971,7 @@ function createSupervisor() {
|
|
|
27883
27971
|
error
|
|
27884
27972
|
};
|
|
27885
27973
|
}
|
|
27886
|
-
try {
|
|
27974
|
+
if (!persistence.failed) try {
|
|
27887
27975
|
await finalizeScopeOwnerMaterialization(openScope);
|
|
27888
27976
|
} catch (error) {
|
|
27889
27977
|
if (actOutcome?.ok !== false) actOutcome = {
|
|
@@ -27891,10 +27979,15 @@ function createSupervisor() {
|
|
|
27891
27979
|
error
|
|
27892
27980
|
};
|
|
27893
27981
|
}
|
|
27982
|
+
if (persistence.failed) {
|
|
27983
|
+
await waitForScopeChildren(openScope);
|
|
27984
|
+
await persistence.drain();
|
|
27985
|
+
}
|
|
27894
27986
|
executionAborted ||= cascadeAborted;
|
|
27895
27987
|
if (opts.signal) opts.signal.removeEventListener("abort", onCallerAbort);
|
|
27896
27988
|
rootLease?.release();
|
|
27897
27989
|
}
|
|
27990
|
+
persistence.assertAvailable();
|
|
27898
27991
|
const tree = runTree(scope);
|
|
27899
27992
|
const leakedReservations = pool.openReservations();
|
|
27900
27993
|
if (controller.signal.reason instanceof RunCancellationReason) return noWinner();
|
|
@@ -28389,4 +28482,4 @@ function isNonEmptySpend(s) {
|
|
|
28389
28482
|
//#endregion
|
|
28390
28483
|
export { waitUntil as $, projectSandboxOutcome as $i, captureWorkerTraceEvidence as $n, runWorktreeHarness as $r, claimsAuthority as $t, driverExecutorFactory as A, withBudgetResources as Aa, writeAllBytes as Ai, providerAsExecutor as An, mergeTraceEnv as Ar, cliInPlaceExecutor as At, recordScopeOwnerDriverAttempt as B, providerMessageText as Ba, recordRuntimeOwnedDriveHarnessProviderEvidence as Bi, FileResultBlobStore as Bn, createOtelExporter as Br, WORKER_TRACE_PROPAGATION as Bt, createContinuationKeeper as C, throwAbort as Ca, sandboxActProfileMaterialization as Ci, captureBeforeDestroy as Cn, runAbortable as Cr, recoverRetainedInteractiveRun as Ct, passedItems as D, zeroSpend as Da, isNoEntError as Di, runBrainLoop as Dn, readHarnessTranscript as Dr, rollingDispatch as Dt, failedItems as E, withTimeout as Ea, worktreeCliProfileMaterialization as Ei, routerBrain as En, persistHarnessTranscript as Er, queueOf as Et, beginScopeOwnerAttempt as F, armDeadlineTimer as Fa, inheritRuntimeOwnedExecutorAttestation as Fi, createPushTraceSource as Fn, resolveRedactor as Fr, createWorktreeCliExecutor as Ft, settledToIteration as G, runtimeOwnedPendingExecutorMaterialization as Gi, assertContentAddress as Gn, padTraceId as Gr, taskToPrompt as Gt, recordScopeOwnerPause as H, runtimeOwnedExecutorExecutionBinding as Hi, InMemoryResultBlobStore as Hn, generateSpanId as Hr, workerTraceEnv as Ht, createScope as I, teardownExecutor as Ia, knownExecutionBindingReceipt as Ii, decodeToolPart as In, buildLoopOtelSpans as Ir, DEFAULT_SANDBOX_STEERING_MAX_TURNS as It, createWaitProbes as J, unknownMaterializationReceipt as Ji, loadSpawnForest as Jn, createRuntimeStreamEventCollector as Jr, readWorkerProgress as Jt, createWorkerSlots as K, runtimeOwnedScopeOwnerRuntime as Ki, encodeResultBlob as Kn, toOtelAttributes as Kr, DEFAULT_STALL_AFTER_MS as Kt, deriveNodeExecutionIdentity as L, teardownSurfaces as La, knownMaterializationReceipt as Li, sandboxSessionTraceSource as Ln, buildLoopSpanNodes as Lr, createSteerableSandboxSession as Lt, withDriverExecutor as M, abortError$2 as Ma, attestRuntimeOwnedScopeOwner as Mi, resolveAgentEnvironmentProvider as Mn, traceContextToEnv as Mr, createExecutor as Mt, SUBTREE_RESULT_LIMIT as N, awaitAbortable$1 as Na, authoredProfileDigest as Ni, unavailablePauseMs as Nn, defaultRedactor as Nr, createExecutorRegistry as Nt, verdictFromJudgeScore as O, addResourceSpend as Oa, prepareJsonlAppend as Oi, LEAF_CONTINUATION_TASK as On, contentAddress as Or, bindReusableExecutorExecutionId as Ot, assertRecursiveReservationPolicy as P, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as Pa, finalizeRuntimeOwnedPendingExecutor as Pi, unavailableSignalOfFailure as Pn, defaultRedactorIdentityMaterial as Pr, snapshotExecutorConfig as Pt, validateWaitSpec as Q, detachedSnapshot as Qi, WORKER_TOOL_TRACE_SCHEMA_VERSION as Qn, runSettledCommand as Qr, PEER_MAIL_WIRE_KEY as Qt, meterRuntimeOwnedAccounting as R, promptFromAgentTurnInput as Ra, newExecutionAttemptId as Ri, registerRetainedExecutorPreparation as Rn, buildRuntimeEventOtelSpans as Rr, createRouterTranscript as Rt, composeContinuationNote as S, stringifySafe as Sa, renderUnsupported as Si, SandboxEvidenceRetentionError as Sn, linkAbort as Sr, reconnectRetainedInteractiveRun as St, expandQuestions as T, unmeteredSpend as Ta, validateProfileMaterialization as Ti, readPromptOptions as Tn, harnessTranscriptArtifact as Tr, freeSlots as Tt, restoreScopeOwnerAcceptedExecution as U, runtimeOwnedExecutorMaterialization as Ui, InMemorySpawnJournal as Un, loopEventToOtelSpan as Ur, workerTraceHeaders as Ut, recordScopeOwnerMaterialization as V, runtimeOwnedDriveHarnessProviderEvidence as Vi, FileSpawnJournal as Vn, flatOtelSpan as Vr, readWorkerTraceContext as Vt, scopeOwnerExecutorNodeContext as W, runtimeOwnedExecutorProviderEvidence as Wi, SpawnEventIndex as Wn, padSpanId as Wr, workerTraceSeamKey as Wt, pollFor as X, executableAgentSpecSnapshot as Xi, pendingWaits as Xn, sanitizeKnowledgeReadinessReport as Xr, AUTHORITY_MARKERS as Xt, isWaitOutcome as Y, executableAgentProfileSnapshot as Yi, materializeTreeView as Yn, sanitizeAgentRuntimeEvent as Yr, createInbox as Yt, timerAt as Z, detachedFrozen as Zi, replaySpawnTree as Zn, sanitizeRuntimeStreamEvent as Zr, DEFAULT_PEER_MAIL_LIMITS as Zt, CheckUnavailableError as _, hasCompleteCacheBreakdown as _a, promptControlProfileMaterialization as _i, isTerminalDecision as _n, retainedCreateMaterial as _r, workerInteractiveAdmissionFile as _t, collectDelivered as a, extractLlmCallEvent as aa, harnessInvocation as ai, isTerminalNodeStatus as an, ReservationWaitRefused as ar, reconcileScopeRetainedOwnerEnvironment as at, bestComposite as b, randomSuffix as ba, promptResourceProfileMaterialization as bi, probeSandboxCapabilities as bn, RunCancellationReason as br, workerInteractiveBindingFile as bt, runTree as c, mapSandboxToolEvent as ca, parseCodexTokenUsage as ci, addHarnessUsage as cn, meterUsageEvent as cr, scopeRetainedOwnerResourceReader as ct, classifyDriverFailure as d, sandboxProgressEvents as da, AGENT_PROFILE_MATERIALIZATION_AXES as di, readCodexRolloutSession as dn, spendFromUsageTotals as dr, SPAWN_RESOURCE_PATH_MAX_BYTES as dt, readSandboxOutcome as ea, captureWorktreeDiff as ei, createPeerMailbox as en, isTraceAnalysisStore as er, bindScopeRetainedOwnerEnvironmentId as et, runDriverWithRetry as f, sumSandboxUsage as fa, assertProfileMaterialization as fi, bridgeRuntimeAttachmentsKey as fn, errMessage as fr, environmentReader as ft, CONTINUATION_FACTS as g, deleteBoxSafe as ga, profileMaterializationAxes$1 as gi, defaultSelectWinner as gn, startRetainedRunInEnvironment as gr, readWorkerInteractiveAdmissions as gt, CONTINUATIONS_DIR as h, cloneSpend as ha, fullProfileMaterialization as hi, createSandboxForSpec as hn, startRetainedRun as hr, interactiveAdmissionSeamKey as ht, bestDelivered as i, createSandboxUsageLedger as ia, LOCAL_HARNESSES as ii, isLiveNodeStatus as in, BudgetReconcileFault as ir, prepareScopeRetainedOwnerTask as it, isDriverSpec as j, decodeHarnessUsage as ja, attestRuntimeOwnedPendingExecutor as ji, providerAsSandboxClient as jn, readTraceContextFromEnv as jr, cliWorktreeExecutor as jt, driverChild as k, resourceTelemetry as ka, readCommittedJsonLines as ki, createAgentEnvironmentProviderRegistry as kn, createPropagatingTraceEmitter as kr, captureReusableExecutorConfig as kt, DriverAttemptsExhaustedError as l, notifySandboxEventObserver as la, CodexExecutionDiagnosticError as li, createCodexRolloutStoreReader as ln, newUsageTotals as lr, scopeRetainedOwnerRestorePoint as lt, upstreamUnavailableSignal as m, chargedTokens as ma, defineProfileMaterializationContract as mi, TERMINAL_DECISIONS as mn, recoverRetainedRun as mr, resolveSpawnResourcePaths as mt, createRootHandle as n, canonicalStreamEventFromSandboxEvent as na, removeWorktree as ni, peerMailTools as nn, workerTraceAnalysisStore as nr, consumeScopeRetainedOwnerResult as nt, pickBestDelivered as o, isSandboxTerminalEvent as oa, harnessSupportsReasoningEffort as oi, bridgeAdmissionRefusal as on, assertValidBudget as or, scopeRetainedOwnerContext as ot, summarizeDriverAttempts as p, addSpend as pa, controlProfileMaterialization as pi, bridgeStopSignalKey as pn, reconnectRetainedRun as pr, hostDirectoryReader as pt, openSlotGroup as q, unknownExecutionBindingReceipt as qi, insideCursorNamespace as qn, createRuntimeEventCollector as qr, createActivityLog as qt, createSupervisor as r, createSandboxToolPartState as ra, DEFAULT_LOCAL_HARNESS as ri, peerMailVerbNames as rn, executorFailure as rr, noteScopeRetainedOwnerCoordination as rt, runFinalizer as s, mapSandboxEvent as sa, localHarnessExecutable as si, bridgeModelRouteRefusal as sn, createBudgetPool as sr, scopeRetainedOwnerPriorSpend as st, DEFAULT_MAX_DEPTH as t, assertSandboxServedModel as ta, createWorktree as ti, isPeerMailEnvelope as tn, parseWorkerToolTraceArtifact as tr, bindScopeRetainedOwnerProvider as tt, HarnessTurnFailedError as u, sandboxEventServedBackend as ua, terminateProcessTreeAndConfirm as ui, harnessUsageIsEmpty as un, spendFromUsageEvents as ur, scopeRetainedOwnerResult as ut, admitContinuationPolicy as v, isAbortError$2 as va, promptModelProfileMaterialization as vi, runAgentRounds as vn, destroyInteractiveEnvironment as vr, attachWorker as vt, distillFindings as w, throwIfAborted as wa, unsupportedProfileDimensions as wi, assertBoxlessPromptOptions as wn, captureHarnessTranscript as wr, startRetainedInteractiveRun as wt, checkVerdictOf as x, sleep as xa, renderProfileMaterializationIssues as xi, acquireSandbox as xn, abortError as xr, workerInteractiveBindingsDir as xt, admitFinding as y, promptCacheTokenClasses as ya, promptOnlyProfileMaterialization as yi, createSandboxLineage as yn, environmentGone as yr, readWorkerInteractiveBinding as yt, meterRuntimeOwnedProviderAttempt as z, promptOptionsFromAgentTurnInput as za, providerAttemptEvidence as zi, retainedExecutorSeamKey as zn, createOpenInferenceFileExporter as zr, createInPlaceCliExecutor as zt };
|
|
28391
28484
|
|
|
28392
|
-
//# sourceMappingURL=supervisor-
|
|
28485
|
+
//# sourceMappingURL=supervisor-B8uT95S1.js.map
|