@tangle-network/agent-runtime 9.0.7 → 9.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/{activation-BA4WLqwN.js → activation-BuKAzxZB.js} +4 -4
- package/dist/{activation-BA4WLqwN.js.map → activation-BuKAzxZB.js.map} +1 -1
- package/dist/{activation-OSYxeVWi.d.ts → activation-CVVpVGyG.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +4 -4
- package/dist/{bundle-CcpL2lfr.js → bundle-9NLb1WO3.js} +2 -2
- package/dist/{bundle-CcpL2lfr.js.map → bundle-9NLb1WO3.js.map} +1 -1
- package/dist/candidate-execution/index.js +5 -4
- package/dist/candidate-execution/index.js.map +1 -1
- package/dist/{continuation-DDPfLw2w.js → continuation-CZaeHEzQ.js} +2 -2
- package/dist/{continuation-DDPfLw2w.js.map → continuation-CZaeHEzQ.js.map} +1 -1
- package/dist/{coordination-manager-CawAzVwE.js → coordination-manager-B-Ugh18D.js} +6 -6
- package/dist/{coordination-manager-CawAzVwE.js.map → coordination-manager-B-Ugh18D.js.map} +1 -1
- package/dist/deadline-CySmJ_0S.js +134 -0
- package/dist/deadline-CySmJ_0S.js.map +1 -0
- package/dist/{delegate-CXtDKuZm.js → delegate-Dizy-1ZC.js} +2 -2
- package/dist/{delegate-CXtDKuZm.js.map → delegate-Dizy-1ZC.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +13 -13
- package/dist/{failure-cause-W0o778qO.js → failure-cause-WifbY42M.js} +2 -2
- package/dist/{failure-cause-W0o778qO.js.map → failure-cause-WifbY42M.js.map} +1 -1
- package/dist/{graph-wQhBJwV_.js → graph-Bf3axJxp.js} +210 -300
- package/dist/graph-Bf3axJxp.js.map +1 -0
- package/dist/{graph-registry-Dbm8QhbA.js → graph-registry-B_1C7qye.js} +1 -1
- package/dist/{graph-registry-D0FE9VpR.js → graph-registry-BbZN5deo.js} +282 -6
- package/dist/graph-registry-BbZN5deo.js.map +1 -0
- package/dist/{improve-CKQwcCz1.js → improve-JThdxpGB.js} +8 -9
- package/dist/{improve-CKQwcCz1.js.map → improve-JThdxpGB.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -102
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +7 -7
- package/dist/{jsonl-file-DsxVI0E_.js → jsonl-file-BhuxeejY.js} +114 -2
- package/dist/jsonl-file-BhuxeejY.js.map +1 -0
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +17 -16
- package/dist/{loop-runner-CCdQ1pmE.d.ts → loop-runner-40_tD2d4.d.ts} +2 -2
- package/dist/{loop-runner-3Acu4nGM.js → loop-runner-D8FP4oEN.js} +2 -2
- package/dist/{loop-runner-3Acu4nGM.js.map → loop-runner-D8FP4oEN.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +7 -7
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/output-artifacts-AqkZ8lO2.js +331 -0
- package/dist/output-artifacts-AqkZ8lO2.js.map +1 -0
- package/dist/{prepare-D7WwIddG.js → prepare-Cw4ZaN01.js} +5 -4
- package/dist/{prepare-D7WwIddG.js.map → prepare-Cw4ZaN01.js.map} +1 -1
- package/dist/{profile-BT0X-dm5.js → profile-Cxl_Ajl2.js} +2 -2
- package/dist/{profile-BT0X-dm5.js.map → profile-Cxl_Ajl2.js.map} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{provision-supervisor-Cm6RLHuw.js → provision-supervisor-BDAXc65B.js} +8 -6
- package/dist/{provision-supervisor-Cm6RLHuw.js.map → provision-supervisor-BDAXc65B.js.map} +1 -1
- package/dist/{run-cancellation-B4-1Rt4u.js → run-cancellation-Cy9ie5cQ.js} +3 -3
- package/dist/{run-cancellation-B4-1Rt4u.js.map → run-cancellation-Cy9ie5cQ.js.map} +1 -1
- package/dist/{run-state-D1LkVTBQ.js → run-state-9FP-wBWK.js} +6 -6
- package/dist/{run-state-D1LkVTBQ.js.map → run-state-9FP-wBWK.js.map} +1 -1
- package/dist/{runtime-Bpad93aK.js → runtime-Czu2SSMy.js} +50 -25
- package/dist/{runtime-Bpad93aK.js.map → runtime-Czu2SSMy.js.map} +1 -1
- package/dist/{search-executor-D8TxXXSY.js → search-executor-Dl_WUQeH.js} +6 -6
- package/dist/{search-executor-D8TxXXSY.js.map → search-executor-Dl_WUQeH.js.map} +1 -1
- package/dist/{server-ctFbmRE5.js → server-Dbge7VDj.js} +5 -5
- package/dist/{server-ctFbmRE5.js.map → server-Dbge7VDj.js.map} +1 -1
- package/dist/{settle-record-BmXd-_3O.js → settle-record-tgpwk6QF.js} +3 -3
- package/dist/{settle-record-BmXd-_3O.js.map → settle-record-tgpwk6QF.js.map} +1 -1
- package/dist/{structural-rollout-DXymZ3go.js → structural-rollout-DUMYWwZ3.js} +7 -6
- package/dist/{structural-rollout-DXymZ3go.js.map → structural-rollout-DUMYWwZ3.js.map} +1 -1
- package/dist/{supervise-BTjv6h7v.js → supervise-BpcWjDMr.js} +12 -10
- package/dist/{supervise-BTjv6h7v.js.map → supervise-BpcWjDMr.js.map} +1 -1
- package/dist/{supervision-discovery-DzYBmrJC.js → supervision-discovery-Hekh50FG.js} +5 -5
- package/dist/{supervision-discovery-DzYBmrJC.js.map → supervision-discovery-Hekh50FG.js.map} +1 -1
- package/dist/{supervisor-Cnn37lon.js → supervisor-CdrDXnOJ.js} +9 -8
- package/dist/{supervisor-Cnn37lon.js.map → supervisor-CdrDXnOJ.js.map} +1 -1
- package/dist/{supervisor-accounting-BMrdsYxz.js → supervisor-accounting-us4w7tG6.js} +65 -154
- package/dist/supervisor-accounting-us4w7tG6.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +13 -13
- package/dist/{tool-server-Df-Uy99W.js → tool-server-CirrqFlr.js} +2 -2
- package/dist/{tool-server-Df-Uy99W.js.map → tool-server-CirrqFlr.js.map} +1 -1
- package/dist/{top-web-Qk6x-A9O.js → top-web-xSGEh02D.js} +7 -7
- package/dist/{top-web-Qk6x-A9O.js.map → top-web-xSGEh02D.js.map} +1 -1
- package/dist/tui/bin.js +3 -3
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{types-KQkbyDmn.d.ts → types-DRijOelA.d.ts} +189 -164
- package/dist/{util-fcckrkKp.js → util-qsH5cC9S.js} +3 -132
- package/dist/util-qsH5cC9S.js.map +1 -0
- package/dist/{workspace-streams-DA9R3j-p.js → workspace-streams-BakRr-Pl.js} +9 -330
- package/dist/workspace-streams-BakRr-Pl.js.map +1 -0
- package/package.json +1 -1
- package/dist/graph-registry-D0FE9VpR.js.map +0 -1
- package/dist/graph-wQhBJwV_.js.map +0 -1
- package/dist/jsonl-file-DsxVI0E_.js.map +0 -1
- package/dist/supervisor-accounting-BMrdsYxz.js.map +0 -1
- package/dist/util-fcckrkKp.js.map +0 -1
- package/dist/workspace-streams-DA9R3j-p.js.map +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { c as RetainedInteractiveAdmissionError, d as RetainedRunDispatchBindingError, f as RuntimeRunStateError, l as RetainedInteractiveBindingError, m as ValidationError, r as BackendTransportError, u as RetainedRunAdmissionError } from "./errors-DG8yufqX.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { a as readCommittedJsonLines, c as appendCommittedJsonLine, f as deadlineSignal, h as signalAbortError, l as sha256, m as runAbortable, r as prepareJsonlAppend, s as withJsonlFileLock, t as isNoEntError, u as RunCancellationReason } from "./jsonl-file-BhuxeejY.js";
|
|
3
|
+
import { c as checkInIdleMs, d as teardownExecutor, n as CHILD_DEADLINE_REASON, o as armDeadlineTimer, s as boundedChildDeadlineAt, u as singleFlightTeardown } from "./deadline-CySmJ_0S.js";
|
|
4
|
+
import { A as withBudgetResources, C as unreportedSpend, D as addResourceSpend, T as zeroSpend, a as cloneSpend, c as errorMessage, f as isAsyncIterable, i as chargedTokens, k as resourceTelemetry, n as addSpend, o as cloneTokenUsage, t as abortError, v as sleep } from "./util-qsH5cC9S.js";
|
|
5
|
+
import { Et as recordValue, F as executorFailure, G as budgetLeaseUpdates, I as executorFailureInfra, J as completedLeafBacking, K as budgetLeases, L as executorFailureReason, M as traceRootWriter, N as contentAddress, Q as newUsageTotals, W as BudgetReconcileFault, X as refreshBudgetLease, Y as createBudgetPool, Z as meterUsageEvent, dt as extractTransportEventIdentity, et as spendFromUsageTotals, f as executorEvidenceWriter, ft as parseCanonicalTransportEvent, g as prepareRetainedExecutor, h as leafContinuationExecutionId, n as runtimeFailureCause, nt as assertValidSpend, o as settlementFailureCause, q as budgetRecoverySeeds, s as BUDGET_CONTINUATION_TASK, t as reportedFailureCause, tt as assertValidBudget, u as RetainedExecutionPendingError, y as retainedExecutorSeamKey } from "./failure-cause-WifbY42M.js";
|
|
4
6
|
import { a as errMessage, f as resolveRedactor, l as errorText, n as detachedSnapshot, r as shareParsedStrings, u as defaultRedactor } from "./snapshot-BKI_w3JD.js";
|
|
5
7
|
import { t as assertExecutableAgentProfile } from "./model-policy-CZwhXp8O.js";
|
|
6
|
-
import {
|
|
7
|
-
import { F as deepFreezeCandidate, h as workspaceLimits, i as readAgentCandidateWorkspaceArtifactFiles, j as verifiedArtifactChunks, m as safeArchivePath, z as sha256Bytes$1 } from "./workspace-streams-DA9R3j-p.js";
|
|
8
|
+
import { h as workspaceLimits, i as readAgentCandidateWorkspaceArtifactFiles, m as safeArchivePath, y as verifiedArtifactChunks } from "./workspace-streams-BakRr-Pl.js";
|
|
8
9
|
import { a as writeAtomicDurableFile, n as assertNoSymlinkDescendant, o as captureRunWriteContext, r as publishExclusiveDurableFile, s as fenceRunWrite, t as appendDurableFile } from "./durable-file-DstVeHcj.js";
|
|
10
|
+
import { b as sha256Bytes$1, g as deepFreezeCandidate } from "./output-artifacts-AqkZ8lO2.js";
|
|
9
11
|
import { a as withPursuitContext, i as notifyRuntimeHookEvent } from "./runtime-hooks-CsW2pfFk.js";
|
|
10
12
|
import * as traceContract from "@tangle-network/agent-trace-contract";
|
|
11
13
|
import { ATTR, OPERATION_NAME_ATTR, toW3CSpanId, toW3CTraceId } from "@tangle-network/agent-trace-contract";
|
|
@@ -98,118 +100,6 @@ function promptPartFromInputPart(part) {
|
|
|
98
100
|
url: part.url
|
|
99
101
|
};
|
|
100
102
|
}
|
|
101
|
-
// src/runtime/supervise/abortable.ts
|
|
102
|
-
/** Provenance of an explicit cancellation, preserved through every abort link. */
|
|
103
|
-
var RunCancellationReason = class extends Error {
|
|
104
|
-
source;
|
|
105
|
-
operationId;
|
|
106
|
-
operator;
|
|
107
|
-
constructor(source, reason, operationId, operator) {
|
|
108
|
-
super(reason);
|
|
109
|
-
this.source = source;
|
|
110
|
-
this.operationId = operationId;
|
|
111
|
-
this.operator = operator;
|
|
112
|
-
this.name = "RunCancellationReason";
|
|
113
|
-
}
|
|
114
|
-
toString() {
|
|
115
|
-
return this.message;
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
/** The signal's explicit reason, or the caller's fallback when none was supplied. */
|
|
119
|
-
function abortReason(signal, fallback) {
|
|
120
|
-
const reason = signal.reason;
|
|
121
|
-
if (reason instanceof RunCancellationReason) return reason;
|
|
122
|
-
if (typeof reason === "string" && reason.length > 0) return reason;
|
|
123
|
-
if (reason instanceof Error && reason.name !== "AbortError" && reason.message.length > 0) return reason.message;
|
|
124
|
-
return fallback;
|
|
125
|
-
}
|
|
126
|
-
/** An `AbortError` carrying the signal's own string reason, or `fallback` when it states none. */
|
|
127
|
-
function signalAbortError(signal, fallback) {
|
|
128
|
-
const reason = abortReason(signal, fallback);
|
|
129
|
-
const error = new Error(reason instanceof Error ? reason.message : typeof reason === "string" && reason.length > 0 ? reason : fallback);
|
|
130
|
-
error.name = "AbortError";
|
|
131
|
-
return error;
|
|
132
|
-
}
|
|
133
|
-
/** A parent abort stops the call at once. The timeout still bounds a parent that stays open. */
|
|
134
|
-
function deadlineSignal(parent, ms) {
|
|
135
|
-
const timeout = AbortSignal.timeout(ms);
|
|
136
|
-
return parent === void 0 ? timeout : AbortSignal.any([parent, timeout]);
|
|
137
|
-
}
|
|
138
|
-
/** Cascade source aborts and preserve their reason; release removes the source listeners. */
|
|
139
|
-
function linkAbort(...sources) {
|
|
140
|
-
const controller = new AbortController();
|
|
141
|
-
const listeners = [];
|
|
142
|
-
const release = () => {
|
|
143
|
-
for (const { source, onAbort } of listeners) source.removeEventListener("abort", onAbort);
|
|
144
|
-
listeners.length = 0;
|
|
145
|
-
};
|
|
146
|
-
const abort = (reason) => {
|
|
147
|
-
release();
|
|
148
|
-
controller.abort(reason);
|
|
149
|
-
};
|
|
150
|
-
const alreadyAborted = sources.find((source) => source.aborted);
|
|
151
|
-
if (alreadyAborted !== void 0) {
|
|
152
|
-
controller.abort(abortReason(alreadyAborted, "aborted by parent scope"));
|
|
153
|
-
return {
|
|
154
|
-
signal: controller.signal,
|
|
155
|
-
abort,
|
|
156
|
-
release
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
for (const source of sources) {
|
|
160
|
-
const onAbort = () => abort(abortReason(source, "aborted by parent scope"));
|
|
161
|
-
listeners.push({
|
|
162
|
-
source,
|
|
163
|
-
onAbort
|
|
164
|
-
});
|
|
165
|
-
source.addEventListener("abort", onAbort, { once: true });
|
|
166
|
-
}
|
|
167
|
-
return {
|
|
168
|
-
signal: controller.signal,
|
|
169
|
-
abort,
|
|
170
|
-
release
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
/** Settle work against cancellation once, observing the losing promise.
|
|
174
|
-
* Defer abort one microtask so already-completed work wins. An action's own abort listener
|
|
175
|
-
* cannot win this race: this function subscribes before invoking it.
|
|
176
|
-
*/
|
|
177
|
-
async function runAbortable(act, signal, fallback) {
|
|
178
|
-
const aborted = () => typeof fallback === "string" ? signalAbortError(signal, fallback) : fallback();
|
|
179
|
-
if (signal.aborted) throw aborted();
|
|
180
|
-
return await new Promise((resolve, reject) => {
|
|
181
|
-
let settled = false;
|
|
182
|
-
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
183
|
-
const onAbort = () => {
|
|
184
|
-
queueMicrotask(() => {
|
|
185
|
-
if (settled) return;
|
|
186
|
-
settled = true;
|
|
187
|
-
cleanup();
|
|
188
|
-
reject(aborted());
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
192
|
-
let work;
|
|
193
|
-
try {
|
|
194
|
-
work = Promise.resolve(act());
|
|
195
|
-
} catch (error) {
|
|
196
|
-
cleanup();
|
|
197
|
-
reject(error);
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
work.then((value) => {
|
|
201
|
-
if (settled) return;
|
|
202
|
-
settled = true;
|
|
203
|
-
cleanup();
|
|
204
|
-
resolve(value);
|
|
205
|
-
}, (error) => {
|
|
206
|
-
if (settled) return;
|
|
207
|
-
settled = true;
|
|
208
|
-
cleanup();
|
|
209
|
-
reject(error);
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
103
|
// src/runtime/retained-run-binding.ts
|
|
214
104
|
function exactSession(environment, controlRef) {
|
|
215
105
|
if (environment.id !== controlRef.environmentId || environment.provider !== controlRef.provider) throw new Error("provider reconstructed a different retained environment");
|
|
@@ -962,7 +852,7 @@ var SeatChain = class {
|
|
|
962
852
|
await this.reconcile(events);
|
|
963
853
|
const starts = events.filter((event) => event.phase === "started");
|
|
964
854
|
const last = starts.at(-1);
|
|
965
|
-
const closed = last && events.
|
|
855
|
+
const closed = last && events.find((event) => event.phase === "ended" && event.segmentIndex === last.segmentIndex);
|
|
966
856
|
if (last && !closed && afterUsageLimit) await this.end(last, "usage-limit");
|
|
967
857
|
const resume = last && !closed && !afterUsageLimit;
|
|
968
858
|
const segmentIndex = resume ? last.segmentIndex : (last?.segmentIndex ?? -1) + 1;
|
|
@@ -970,7 +860,8 @@ var SeatChain = class {
|
|
|
970
860
|
let earliestReset;
|
|
971
861
|
for (let stageIndex = firstStageIndex; stageIndex < stages.length; stageIndex += 1) {
|
|
972
862
|
const stage = stages[stageIndex];
|
|
973
|
-
const
|
|
863
|
+
const rebind = last && stageIndex === last.stageIndex && !afterUsageLimit && closed?.reason !== "usage-limit";
|
|
864
|
+
const excludedSeatIds = (afterRecheck ? [] : starts).filter((event) => event.stageIndex === stageIndex && (!rebind || event.seat !== last.seat)).map((event) => event.seat);
|
|
974
865
|
const prior = last === void 0 ? void 0 : {
|
|
975
866
|
seat: last.seat,
|
|
976
867
|
harness: last.harness,
|
|
@@ -978,7 +869,7 @@ var SeatChain = class {
|
|
|
978
869
|
model: last.model
|
|
979
870
|
};
|
|
980
871
|
const preceding = resume ? starts.at(-2) : last;
|
|
981
|
-
const requiresNativeTurnGrant = Boolean(preceding && preceding.provider === stage.provider && preceding.harness === stage.harness && (!
|
|
872
|
+
const requiresNativeTurnGrant = Boolean(preceding && preceding.provider === stage.provider && preceding.harness === stage.harness && (!rebind || preceding.seat !== last.seat));
|
|
982
873
|
const selection = checkedSeatSelection(stage, await this.select({
|
|
983
874
|
profile: this.profile,
|
|
984
875
|
nodeId: this.nodeId,
|
|
@@ -989,7 +880,7 @@ var SeatChain = class {
|
|
|
989
880
|
requiresNativeTurnGrant,
|
|
990
881
|
...retainedEnvironmentId === void 0 ? {} : { retainedEnvironmentId },
|
|
991
882
|
...prior === void 0 ? {} : { previous: prior },
|
|
992
|
-
...
|
|
883
|
+
...rebind ? { resumeSeatId: last.seat } : {}
|
|
993
884
|
}));
|
|
994
885
|
if ("resumeAt" in selection) {
|
|
995
886
|
const reset = Date.parse(selection.resumeAt);
|
|
@@ -997,7 +888,7 @@ var SeatChain = class {
|
|
|
997
888
|
if (resume) break;
|
|
998
889
|
continue;
|
|
999
890
|
}
|
|
1000
|
-
if (
|
|
891
|
+
if (rebind && selection.seat !== last.seat) throw new ValidationError("selectSeat: resume changed the committed seat");
|
|
1001
892
|
if (excludedSeatIds.includes(selection.seat)) throw new ValidationError("selectSeat: selected an exhausted seat");
|
|
1002
893
|
if (preceding && preceding.seat !== selection.seat && preceding.provider === stage.provider && preceding.harness === stage.harness && selection.nativeTurnGrant !== true) throw new ValidationError("selectSeat: same-environment seat requires a verified native turn grant");
|
|
1003
894
|
const active = {
|
|
@@ -7142,11 +7033,14 @@ function retainedOwnerReleaseRetriable(scope) {
|
|
|
7142
7033
|
}
|
|
7143
7034
|
/** One budget for every checkpoint lookup, delete and fork cleanup this release starts. Work cut short keeps its checkpoint and source. */
|
|
7144
7035
|
const RELEASE_CHECKPOINT_CAPTURES_MS = 9e5;
|
|
7036
|
+
/** A release's wait for its destroys; a delete grows with the retained workspace it seals (Sandbox
|
|
7037
|
+
* 2026-11-11: 2-4 s at 1 MB, 30 s at 300 MB, 72 s at 1 GB). A later release joins the rest. */
|
|
7038
|
+
const RELEASE_DESTROY_MS = 3e5;
|
|
7145
7039
|
/**
|
|
7146
7040
|
* Release the owner's environment once no turn of it will run again. A second call joins the one
|
|
7147
7041
|
* in flight. The end-of-turn capture finishes before destroy. `capturesMs` bounds checkpoint work.
|
|
7148
7042
|
*/
|
|
7149
|
-
function releaseScopeRetainedOwnerEnvironment(scope, { capturesMs = RELEASE_CHECKPOINT_CAPTURES_MS } = {}) {
|
|
7043
|
+
function releaseScopeRetainedOwnerEnvironment(scope, { capturesMs = RELEASE_CHECKPOINT_CAPTURES_MS, destroyMs = RELEASE_DESTROY_MS } = {}) {
|
|
7150
7044
|
const state = owners.get(scope);
|
|
7151
7045
|
const provider = state?.provider;
|
|
7152
7046
|
if (state === void 0 || provider === void 0) return Promise.resolve([]);
|
|
@@ -7154,14 +7048,14 @@ function releaseScopeRetainedOwnerEnvironment(scope, { capturesMs = RELEASE_CHEC
|
|
|
7154
7048
|
const tracked = (async () => {
|
|
7155
7049
|
await ownerDriveEnded(state);
|
|
7156
7050
|
await scopeRetainedOwnerTurnEnded(scope);
|
|
7157
|
-
return await releaseOwnerEnvironment(state, provider, capturesMs);
|
|
7051
|
+
return await releaseOwnerEnvironment(state, provider, capturesMs, destroyMs);
|
|
7158
7052
|
})().finally(() => {
|
|
7159
7053
|
if (state.releasing === tracked) delete state.releasing;
|
|
7160
7054
|
});
|
|
7161
7055
|
state.releasing = tracked;
|
|
7162
7056
|
return tracked;
|
|
7163
7057
|
}
|
|
7164
|
-
async function releaseOwnerEnvironment(state, provider, capturesMs) {
|
|
7058
|
+
async function releaseOwnerEnvironment(state, provider, capturesMs, destroyMs) {
|
|
7165
7059
|
const { args } = state;
|
|
7166
7060
|
state.checkpointsUnavailable ??= "released";
|
|
7167
7061
|
await state.checkpointing?.catch(() => void 0);
|
|
@@ -7192,6 +7086,12 @@ async function releaseOwnerEnvironment(state, provider, capturesMs) {
|
|
|
7192
7086
|
}
|
|
7193
7087
|
const forksUnresolved = await settleCaptureForks(state, captures.signal);
|
|
7194
7088
|
for (const { event } of checkpointFailures) pendingSources.add(event.environmentId);
|
|
7089
|
+
const destroyDeadline = AbortSignal.timeout(destroyMs);
|
|
7090
|
+
const destroys = new Map([...environments].filter((id) => !released.has(id) && !retentionFailures.has(id) && !pendingSources.has(id)).map((id) => {
|
|
7091
|
+
const wait = runAbortable(() => ownerEnvironmentDestroy(state, provider, id), destroyDeadline, () => /* @__PURE__ */ new Error(`destroy still running after ${destroyMs} ms`));
|
|
7092
|
+
wait.catch(() => void 0);
|
|
7093
|
+
return [id, wait];
|
|
7094
|
+
}));
|
|
7195
7095
|
for (const environmentId of environments) {
|
|
7196
7096
|
if (released.has(environmentId)) continue;
|
|
7197
7097
|
let destroyed = false;
|
|
@@ -7202,35 +7102,16 @@ async function releaseOwnerEnvironment(state, provider, capturesMs) {
|
|
|
7202
7102
|
detail = !nativeHold && pendingSources.has(environmentId) ? "checkpoint cleanup unresolved: source preserved for exact lookup and cleanup" : retentionReason;
|
|
7203
7103
|
preserved.push(environmentId);
|
|
7204
7104
|
lastDetail = detail;
|
|
7205
|
-
} else {
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
const environment = await provider.get(environmentId);
|
|
7214
|
-
if (environment === null) return;
|
|
7215
|
-
if (environment.id !== environmentId || environment.provider !== provider.name) {
|
|
7216
|
-
permanent = true;
|
|
7217
|
-
throw new Error("provider returned another retained environment");
|
|
7218
|
-
}
|
|
7219
|
-
if (!environment.destroy) {
|
|
7220
|
-
permanent = true;
|
|
7221
|
-
throw new Error("provider cannot destroy the retained environment");
|
|
7222
|
-
}
|
|
7223
|
-
await environment.destroy();
|
|
7224
|
-
}, AbortSignal.timeout(3e4), "retained owner cleanup timed out");
|
|
7225
|
-
destroyed = true;
|
|
7226
|
-
} catch (error) {
|
|
7227
|
-
detail = `retained owner environment cleanup was not confirmed: ${errMessage(error).slice(0, 500)}`;
|
|
7228
|
-
unconfirmed.push(environmentId);
|
|
7229
|
-
lastDetail = detail;
|
|
7230
|
-
if (!permanent) retriable = true;
|
|
7231
|
-
}
|
|
7105
|
+
} else try {
|
|
7106
|
+
await destroys.get(environmentId);
|
|
7107
|
+
destroyed = true;
|
|
7108
|
+
} catch (error) {
|
|
7109
|
+
detail = `retained owner environment cleanup was not confirmed: ${errMessage(error).slice(0, 500)}`;
|
|
7110
|
+
unconfirmed.push(environmentId);
|
|
7111
|
+
lastDetail = detail;
|
|
7112
|
+
if (!(error instanceof PermanentReleaseRefusal)) retriable = true;
|
|
7232
7113
|
}
|
|
7233
|
-
if (!destroyed) {
|
|
7114
|
+
if (!destroyed && !state.destroys?.has(environmentId)) {
|
|
7234
7115
|
const runs = unsettledOwnerRuns(events, args.nodeId, environmentId);
|
|
7235
7116
|
if (runs.length > 0) {
|
|
7236
7117
|
const stops = await Promise.all(runs.map((controlRef) => stopRetainedNativeExecution({
|
|
@@ -7295,6 +7176,36 @@ async function releaseOwnerEnvironment(state, provider, capturesMs) {
|
|
|
7295
7176
|
...lastDetail === void 0 ? {} : { detail: lastDetail }
|
|
7296
7177
|
}, ...checkpointTeardowns] : checkpointTeardowns;
|
|
7297
7178
|
}
|
|
7179
|
+
var PermanentReleaseRefusal = class extends Error {};
|
|
7180
|
+
/** A destroy in flight this long is presumed lost, and the next release asks the provider again. */
|
|
7181
|
+
const RELEASE_DESTROY_ABANDONED_MS = 9e5;
|
|
7182
|
+
/**
|
|
7183
|
+
* The environment's one destroy, joined by this process's later releases instead of a reconnect to
|
|
7184
|
+
* a box being removed, which a native-capture provider refuses while its sidecar deprovisions. A
|
|
7185
|
+
* failed or abandoned destroy is forgotten: the next release asks again, and absence confirms it.
|
|
7186
|
+
*/
|
|
7187
|
+
function ownerEnvironmentDestroy(state, provider, environmentId) {
|
|
7188
|
+
const destroys = state.destroys ??= /* @__PURE__ */ new Map();
|
|
7189
|
+
const joined = destroys.get(environmentId);
|
|
7190
|
+
if (joined !== void 0 && Date.now() - joined.since < RELEASE_DESTROY_ABANDONED_MS) return joined.destroy;
|
|
7191
|
+
const destroy = (async () => {
|
|
7192
|
+
if (!provider.get) throw new PermanentReleaseRefusal("provider cannot reconstruct the retained environment");
|
|
7193
|
+
const environment = await provider.get(environmentId);
|
|
7194
|
+
if (environment === null) return;
|
|
7195
|
+
if (environment.id !== environmentId || environment.provider !== provider.name) throw new PermanentReleaseRefusal("provider returned another retained environment");
|
|
7196
|
+
if (!environment.destroy) throw new PermanentReleaseRefusal("provider cannot destroy the retained environment");
|
|
7197
|
+
await environment.destroy();
|
|
7198
|
+
})();
|
|
7199
|
+
const entry = {
|
|
7200
|
+
destroy,
|
|
7201
|
+
since: Date.now()
|
|
7202
|
+
};
|
|
7203
|
+
destroys.set(environmentId, entry);
|
|
7204
|
+
destroy.catch(() => {
|
|
7205
|
+
if (destroys.get(environmentId) === entry) destroys.delete(environmentId);
|
|
7206
|
+
});
|
|
7207
|
+
return destroy;
|
|
7208
|
+
}
|
|
7298
7209
|
/**
|
|
7299
7210
|
* The owner's dispatched executions in one environment whose turn committed no result. A turn
|
|
7300
7211
|
* with a result has ended; one without may still be running even after a later turn started.
|
|
@@ -14064,6 +13975,6 @@ function unknownChannels(spend) {
|
|
|
14064
13975
|
function isNonEmptySpend(s) {
|
|
14065
13976
|
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);
|
|
14066
13977
|
}
|
|
14067
|
-
export { queueOf as $, captureHarnessTranscript as $n, RetainedRunProviderContractError as $r, loadSpawnForest as $t, openSlotGroup as A, verifyObserverRecords as An, knownMaterializationReceipt as Ar, noteScopeOwnerPlannedExecution as At, readWorkerInteractiveBinding as B, buildLoopSpanNodes as Bn, runtimeOwnedExecutorMaterialization as Br, scopeRetainedOwnerSettled as Bt, workerCancellationsDir as C, retainedCreateMaterial as Cn, attestRuntimeOwnedPendingExecutor as Cr, abandonScopeRetainedOwnerInvocation as Ct, writeWorkerSteer as D, FileObserverJournal as Dn, finalizeRuntimeOwnedPendingExecutor as Dr, scopeRetainedOwnerResult as Dt, writeWorkerCancellation as E, prepareInteractiveDelegation as En, authoredProfileDigest as Er, scopeRetainedOwnerPriorSpend as Et, parseWorkerToolTraceArtifact as F, workerTraceHeaders as Fn, recordRuntimeOwnedProviderDispatchNotStarted as Fr, coordinationMcpAlias as Ft, appendSpawnEvents as G, generateSpanId as Gn, unknownExecutionBindingReceipt as Gr, noteScopeRetainedOwnerCoordination as Gt, recoverRetainedInteractiveRun as H, createOpenInferenceFileExporter as Hn, runtimeOwnedPendingExecutorMaterialization as Hr, assertRetainedOwnerCoordinationRekey as Ht, workerTraceAnalysisStore as I, createPropagatingTraceEmitter as In, recordRuntimeOwnedProviderIdentityConflict as Ir, coordinationProfileToolPrefix as It, reenteredWorkers as J, createRuntimeStreamEventCollector as Jn, executableAgentSpecSnapshot as Jr, bindScopeRetainedOwnerProvider as Jt, spawnJournalRecordEvents as K, loopEventToOtelSpan as Kn, unknownMaterializationReceipt as Kr, scopeRetainedOwnerCheckpointing as Kt, nestedScopeSeamKey as L, mergeTraceEnv as Ln, recordRuntimeOwnedProviderModel as Lr, providerVisibleProfile as Lt, prepareScopeResume as M, environmentGone as Mn, providerAttemptEvidence as Mr, restoreScopeOwnerAcceptedExecution as Mt, replaySpawnTree as N, WORKER_TRACE_PROPAGATION as Nn, recordRuntimeOwnedDriveHarnessProviderEvidence as Nr, scopeOwnerExecutionObservation as Nt, writeWorkerSteerAcknowledgement as O, createFileObserverHooks as On, inheritRuntimeOwnedExecutorAttestation as Or, beginScopeOwnerAttempt as Ot, isTraceAnalysisStore as P, workerTraceEnv as Pn, recordRuntimeOwnedProviderAttemptStart as Pr, scopeOwnerExecutorNodeContext as Pt, freeSlots as Q, captureBoundHarnessTranscript as Qn, runtimeFlowBrain as Qr, scopeRetainedOwnerJournalRoot as Qt, interactiveAdmissionSeamKey as R, readTraceContextFromEnv as Rn, runtimeOwnedDriveHarnessProviderEvidence as Rr, runtimeGraphMetadataKey as Rt, workerCancelRequestsFile as S, startRetainedRunInEnvironment as Sn, attestRuntimeOwnedExecutor as Sr, resolveSpawnResourcePaths as St, workerSteerRequestsDir as T, offerInteractiveControl as Tn, authoredAgentIdentity as Tr, prepareScopeRetainedOwnerTask as Tt, startRetainedInteractiveRun as U, createOtelExporter as Un, runtimeOwnedScopeOwnerControl as Ur, reconcileScopeRetainedOwnerEnvironment as Ut, reconnectRetainedInteractiveRun as V, buildRuntimeEventOtelSpans as Vn, runtimeOwnedExecutorProviderEvidence as Vr, scopeRetainedOwnerTurnEnded as Vt, FileSpawnJournal as W, flatOtelSpan as Wn, runtimeOwnedScopeOwnerRuntime as Wr, scopeRetainedOwnerRestorePoint as Wt, assertRecursiveReservationPolicy as X, sanitizeRuntimeStreamEvent as Xn, runtimeCheckFactory as Xr, scopeOwnerLiabilities as Xt, settledToIteration as Y, sanitizeKnowledgeReadinessReport as Yn, isRuntimeFlowBrain as Yr, owners as Yt, deriveNodeExecutionIdentity as Z, HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS as Zn, runtimeFlowAgent as Zr, scopeRetainedOwnerContext as Zt, readWorkerSteerAcknowledgement as _, assertRetainedRunReplayMaterial as _n, SeatPauseError as _r, waitForScopeChildren as _t, createRootStreamSink as a, sameControlCoordinates as ai, FileResultBlobStore as an, HARNESS_TRANSCRIPT_READ_LIMITS as ar, meterRuntimeOwnedProviderAttempt as at, supervisorRunDir as b, recoverRetainedRun as bn, subscriptionUsageLimitSignal as br, scopeRetainedOwnerResourceReader as bt, readRootStreamReceipt as c,
|
|
13978
|
+
export { queueOf as $, captureHarnessTranscript as $n, RetainedRunProviderContractError as $r, loadSpawnForest as $t, openSlotGroup as A, verifyObserverRecords as An, knownMaterializationReceipt as Ar, noteScopeOwnerPlannedExecution as At, readWorkerInteractiveBinding as B, buildLoopSpanNodes as Bn, runtimeOwnedExecutorMaterialization as Br, scopeRetainedOwnerSettled as Bt, workerCancellationsDir as C, retainedCreateMaterial as Cn, attestRuntimeOwnedPendingExecutor as Cr, abandonScopeRetainedOwnerInvocation as Ct, writeWorkerSteer as D, FileObserverJournal as Dn, finalizeRuntimeOwnedPendingExecutor as Dr, scopeRetainedOwnerResult as Dt, writeWorkerCancellation as E, prepareInteractiveDelegation as En, authoredProfileDigest as Er, scopeRetainedOwnerPriorSpend as Et, parseWorkerToolTraceArtifact as F, workerTraceHeaders as Fn, recordRuntimeOwnedProviderDispatchNotStarted as Fr, coordinationMcpAlias as Ft, appendSpawnEvents as G, generateSpanId as Gn, unknownExecutionBindingReceipt as Gr, noteScopeRetainedOwnerCoordination as Gt, recoverRetainedInteractiveRun as H, createOpenInferenceFileExporter as Hn, runtimeOwnedPendingExecutorMaterialization as Hr, assertRetainedOwnerCoordinationRekey as Ht, workerTraceAnalysisStore as I, createPropagatingTraceEmitter as In, recordRuntimeOwnedProviderIdentityConflict as Ir, coordinationProfileToolPrefix as It, reenteredWorkers as J, createRuntimeStreamEventCollector as Jn, executableAgentSpecSnapshot as Jr, bindScopeRetainedOwnerProvider as Jt, spawnJournalRecordEvents as K, loopEventToOtelSpan as Kn, unknownMaterializationReceipt as Kr, scopeRetainedOwnerCheckpointing as Kt, nestedScopeSeamKey as L, mergeTraceEnv as Ln, recordRuntimeOwnedProviderModel as Lr, providerVisibleProfile as Lt, prepareScopeResume as M, environmentGone as Mn, providerAttemptEvidence as Mr, restoreScopeOwnerAcceptedExecution as Mt, replaySpawnTree as N, WORKER_TRACE_PROPAGATION as Nn, recordRuntimeOwnedDriveHarnessProviderEvidence as Nr, scopeOwnerExecutionObservation as Nt, writeWorkerSteerAcknowledgement as O, createFileObserverHooks as On, inheritRuntimeOwnedExecutorAttestation as Or, beginScopeOwnerAttempt as Ot, isTraceAnalysisStore as P, workerTraceEnv as Pn, recordRuntimeOwnedProviderAttemptStart as Pr, scopeOwnerExecutorNodeContext as Pt, freeSlots as Q, captureBoundHarnessTranscript as Qn, runtimeFlowBrain as Qr, scopeRetainedOwnerJournalRoot as Qt, interactiveAdmissionSeamKey as R, readTraceContextFromEnv as Rn, runtimeOwnedDriveHarnessProviderEvidence as Rr, runtimeGraphMetadataKey as Rt, workerCancelRequestsFile as S, startRetainedRunInEnvironment as Sn, attestRuntimeOwnedExecutor as Sr, resolveSpawnResourcePaths as St, workerSteerRequestsDir as T, offerInteractiveControl as Tn, authoredAgentIdentity as Tr, prepareScopeRetainedOwnerTask as Tt, startRetainedInteractiveRun as U, createOtelExporter as Un, runtimeOwnedScopeOwnerControl as Ur, reconcileScopeRetainedOwnerEnvironment as Ut, reconnectRetainedInteractiveRun as V, buildRuntimeEventOtelSpans as Vn, runtimeOwnedExecutorProviderEvidence as Vr, scopeRetainedOwnerTurnEnded as Vt, FileSpawnJournal as W, flatOtelSpan as Wn, runtimeOwnedScopeOwnerRuntime as Wr, scopeRetainedOwnerRestorePoint as Wt, assertRecursiveReservationPolicy as X, sanitizeRuntimeStreamEvent as Xn, runtimeCheckFactory as Xr, scopeOwnerLiabilities as Xt, settledToIteration as Y, sanitizeKnowledgeReadinessReport as Yn, isRuntimeFlowBrain as Yr, owners as Yt, deriveNodeExecutionIdentity as Z, HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS as Zn, runtimeFlowAgent as Zr, scopeRetainedOwnerContext as Zt, readWorkerSteerAcknowledgement as _, assertRetainedRunReplayMaterial as _n, SeatPauseError as _r, waitForScopeChildren as _t, createRootStreamSink as a, sameControlCoordinates as ai, FileResultBlobStore as an, HARNESS_TRANSCRIPT_READ_LIMITS as ar, meterRuntimeOwnedProviderAttempt as at, supervisorRunDir as b, recoverRetainedRun as bn, subscriptionUsageLimitSignal as br, scopeRetainedOwnerResourceReader as bt, readRootStreamReceipt as c, providerMessageText as ci, insideCursorNamespace as cn, retainHarnessTranscript as cr, recordScopeOwnerDriverAttempt as ct, claimWorkerSteerDelivery as d, observeModelRequest as dn, describeToolArgs as dr, releaseHeldEnvironments as dt, assertEventBinding as ei, ownedTreeRootSpawn as en, harnessTranscriptArtifact as er, rollingDispatch as et, fileEscalateQuestion as f, NATIVE_STOP_UNCONFIRMED as fn, readWorkerProgress as fr, releaseRetainedEnvironments as ft, readWorkerCancellation as g, RetainedMaterializationTimeoutError as gn, SeatChain as gr, unconfirmedTeardowns as gt, readWorkerCancelRequests as h, verifyWorkspaceMarker as hn, SEAT_RECHECK_MS as hr, startScopeRecoveries as ht, ROOT_STREAM_FILE as i, retainedSessionReplaced as ii, nestedDriverTreeRoot as in, readHarnessTranscript as ir, meterRuntimeOwnedAccounting as it, resolveWorkerSlots as j, destroyInteractiveEnvironment as jn, newExecutionAttemptId as jr, recordScopeOwnerMaterialization as jt, createWorkerSlots as k, observerRecordDigest as kn, knownExecutionBindingReceipt as kr, finalizeScopeOwnerMaterialization as kt, appendWorkerControlEvent as l, executorObservation as ln, DEFAULT_STALL_AFTER_MS as lr, recordScopeOwnerPause as lt, legacySupervisorRunsRoot as m, stopRetainedNativeExecution as mn, isTerminalNodeStatus as mr, settleManagerWork as mt, terminalAccounting as n, exactSession as ni, attestNestedDriverTreeOwner as nn, harnessTranscriptUnavailable as nr, closeScopeAdmission as nt, nodeStreamFile as o, promptFromAgentTurnInput as oi, encodeResultBlob as on, readBoundHarnessSessions as or, pauseScopeSeatAdmission as ot, legacySupervisorRunDir as p, describeRetainedNativeStops as pn, isLiveNodeStatus as pr, retryUnconfirmedTeardowns as pt, appendTeardownConfirmation as q, createRuntimeEventCollector as qn, executableAgentProfileSnapshot as qr, bindScopeRetainedOwnerEnvironmentId as qt, createScope as r, freezeControlRef as ri, driverRuntime as rn, persistHarnessTranscript as rr, hasRetriableTeardowns as rt, readRootStream as s, promptOptionsFromAgentTurnInput as si, SpawnEventIndex as sn, resolveHarnessTranscriptCapture as sr, recordScopeOwnerBarrenPause as st, isNonEmptySpend as t, awaitAbortable$1 as ti, materializeTreeView as tn, harnessTranscriptFromLines as tr, closeRetainedSlots as tt, cancelWorker as u, executorObservationSeamKey as un, createActivityLog as ur, registerNestedTeardownScope as ut, readWorkerSteerRequests as v, mintRetainedIdentity as vn, authoredSeatStages as vr, prepareScopeRetainedOwnerSeatSwitch as vt, workerInboxFileFromEventDir as w, acceptedInteractiveControl as wn, attestRuntimeOwnedScopeOwner as wr, consumeScopeRetainedOwnerResult as wt, supervisorRunsRoot as x, startRetainedRun as xn, attestRuntimeOwnedDeferredExecutor as xr, environmentReader as xt, safeWorkerFile as y, reconnectRetainedRun as yn, seatExecutionProfile as yr, releaseScopeRetainedOwnerForSeatPause as yt, attachWorker as z, buildLoopOtelSpans as zn, runtimeOwnedExecutorExecutionBinding as zr, beginScopeRetainedOwnerDrive as zt };
|
|
14068
13979
|
|
|
14069
|
-
//# sourceMappingURL=supervisor-accounting-
|
|
13980
|
+
//# sourceMappingURL=supervisor-accounting-us4w7tG6.js.map
|