@tangle-network/agent-runtime 10.0.3 → 10.0.5
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 +30 -0
- package/dist/{activation-kitznAHo.js → activation-DvvM7gG5.js} +2 -2
- package/dist/{activation-kitznAHo.js.map → activation-DvvM7gG5.js.map} +1 -1
- package/dist/{activation-DbSxPRUW.d.ts → activation-DyFt-GHq.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -3
- package/dist/{continuation-BDeKJgV3.js → continuation-Bccak14N.js} +3 -3
- package/dist/{continuation-BDeKJgV3.js.map → continuation-Bccak14N.js.map} +1 -1
- package/dist/{delegate-D8yX_2K7.js → delegate-YBqrrbq7.js} +2 -2
- package/dist/{delegate-D8yX_2K7.js.map → delegate-YBqrrbq7.js.map} +1 -1
- package/dist/{driver-control-acknowledgers-BTSr3Znq.js → driver-control-acknowledgers-CNNRjIo9.js} +99 -57
- package/dist/{driver-control-acknowledgers-BTSr3Znq.js.map → driver-control-acknowledgers-CNNRjIo9.js.map} +1 -1
- package/dist/durable-file-iPCEs_-s.js +1 -0
- package/dist/{durable-file-DUcTDWJD.js → durable-file-pao7FijS.js} +10 -3
- package/dist/{durable-file-DUcTDWJD.js.map → durable-file-pao7FijS.js.map} +1 -1
- package/dist/durable-writer-thread.js +5 -5
- package/dist/durable.d.ts +4 -1
- package/dist/durable.js +21 -15
- package/dist/durable.js.map +1 -1
- package/dist/failure-cause-DoCCGLDH.js.map +1 -1
- package/dist/{graph-4ep9laIH.js → graph-CUUtx7qT.js} +8 -12
- package/dist/{graph-4ep9laIH.js.map → graph-CUUtx7qT.js.map} +1 -1
- package/dist/{graph-registry-B-EGvJ-3.js → graph-registry-CGKyYabE.js} +1 -1
- package/dist/{graph-registry-BxEBeihr.js → graph-registry-CRskE_Yp.js} +4 -4
- package/dist/{graph-registry-BxEBeihr.js.map → graph-registry-CRskE_Yp.js.map} +1 -1
- package/dist/{improve-CJf87tBs.js → improve-Cy8PZUdw.js} +8 -8
- package/dist/{improve-CJf87tBs.js.map → improve-Cy8PZUdw.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -10
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +4 -4
- package/dist/{jsonl-file-CVAWegN-.js → jsonl-file-vE9H9UXa.js} +3 -3
- package/dist/{jsonl-file-CVAWegN-.js.map → jsonl-file-vE9H9UXa.js.map} +1 -1
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +19 -19
- package/dist/{loop-runner-Ckj-Zz3-.js → loop-runner-BwkX4ViS.js} +2 -2
- package/dist/{loop-runner-Ckj-Zz3-.js.map → loop-runner-BwkX4ViS.js.map} +1 -1
- package/dist/{loop-runner-CayC8e9K.d.ts → loop-runner-Icc1iBR-.d.ts} +2 -2
- 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 +6 -6
- package/dist/{model-policy-DZnL8Yj9.js → model-policy-DTbTFyOG.js} +12 -6
- package/dist/model-policy-DTbTFyOG.js.map +1 -0
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.js +1 -1
- package/dist/{provision-supervisor-NjROV7AQ.js → provision-supervisor-Dtn8RjHe.js} +7 -7
- package/dist/{provision-supervisor-NjROV7AQ.js.map → provision-supervisor-Dtn8RjHe.js.map} +1 -1
- package/dist/{result-blob-store-BR-BVZrg.js → result-blob-store-UGXQYACQ.js} +3 -3
- package/dist/{result-blob-store-BR-BVZrg.js.map → result-blob-store-UGXQYACQ.js.map} +1 -1
- package/dist/{run-cancellation-C9V1lYhq.js → run-cancellation-BpUQZqBS.js} +3 -3
- package/dist/{run-cancellation-C9V1lYhq.js.map → run-cancellation-BpUQZqBS.js.map} +1 -1
- package/dist/{run-lock-Y3u9kwM0.js → run-lock-Ckakh1Uq.js} +3 -3
- package/dist/{run-lock-Y3u9kwM0.js.map → run-lock-Ckakh1Uq.js.map} +1 -1
- package/dist/{run-reopen-CHYTHk7x.js → run-reopen-BvF3Gjj9.js} +6 -6
- package/dist/{run-reopen-CHYTHk7x.js.map → run-reopen-BvF3Gjj9.js.map} +1 -1
- package/dist/{run-state-DgKo8_tO.js → run-state-CZcFJjHn.js} +7 -7
- package/dist/{run-state-DgKo8_tO.js.map → run-state-CZcFJjHn.js.map} +1 -1
- package/dist/{runtime-CdthBQUs.js → runtime-BvDaNyFf.js} +44 -53
- package/dist/runtime-BvDaNyFf.js.map +1 -0
- package/dist/{search-executor-Bb0WuI_Z.js → search-executor-DWQW-9WN.js} +4 -4
- package/dist/{search-executor-Bb0WuI_Z.js.map → search-executor-DWQW-9WN.js.map} +1 -1
- package/dist/{server-BCtyL7jH.js → server-D5GpuQnT.js} +3 -3
- package/dist/{server-BCtyL7jH.js.map → server-D5GpuQnT.js.map} +1 -1
- package/dist/{settle-record-Beh-sXBW.js → settle-record-BFhJigPW.js} +4 -4
- package/dist/{settle-record-Beh-sXBW.js.map → settle-record-BFhJigPW.js.map} +1 -1
- package/dist/{structural-rollout-BRfSDPkv.js → structural-rollout-D1pZn6Cu.js} +4 -4
- package/dist/{structural-rollout-BRfSDPkv.js.map → structural-rollout-D1pZn6Cu.js.map} +1 -1
- package/dist/{supervise-DTUYxnoJ.js → supervise-fmugf6Y2.js} +16 -15
- package/dist/supervise-fmugf6Y2.js.map +1 -0
- package/dist/{supervise-identity-eMF-h1uP.js → supervise-identity-7_7DUghQ.js} +4 -4
- package/dist/{supervise-identity-eMF-h1uP.js.map → supervise-identity-7_7DUghQ.js.map} +1 -1
- package/dist/{supervision-discovery-CAUsSDno.js → supervision-discovery-DwRtZNdy.js} +5 -8
- package/dist/supervision-discovery-DwRtZNdy.js.map +1 -0
- package/dist/{supervisor-BtRRFbgF.js → supervisor-BlACe-uO.js} +126 -61
- package/dist/supervisor-BlACe-uO.js.map +1 -0
- package/dist/{supervisor-accounting-Cuehs4te.js → supervisor-accounting-DuFyM-_h.js} +159 -57
- package/dist/supervisor-accounting-DuFyM-_h.js.map +1 -0
- package/dist/{supervisor-root-contract-CmFKzPps.js → supervisor-root-contract-DCMw4u0V.js} +2 -2
- package/dist/{supervisor-root-contract-CmFKzPps.js.map → supervisor-root-contract-DCMw4u0V.js.map} +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +11 -11
- package/dist/{top-web-D-wuEVdM.js → top-web-C5vhiOFA.js} +7 -7
- package/dist/{top-web-D-wuEVdM.js.map → top-web-C5vhiOFA.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-PBoTtcbX.d.ts → types-CFmKHKiN.d.ts} +16 -3
- package/package.json +1 -1
- package/dist/durable-file-XqOyDf7q.js +0 -1
- package/dist/model-policy-DZnL8Yj9.js.map +0 -1
- package/dist/runtime-CdthBQUs.js.map +0 -1
- package/dist/supervise-DTUYxnoJ.js.map +0 -1
- package/dist/supervision-discovery-CAUsSDno.js.map +0 -1
- package/dist/supervisor-BtRRFbgF.js.map +0 -1
- package/dist/supervisor-accounting-Cuehs4te.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
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 { _ as runAbortable, c as withJsonlFileLock, d as journalFileStamp, f as sha256, h as deadlineSignal, l as appendCommittedJsonLine, o as readCommittedJsonLines, p as RunCancellationReason, r as prepareJsonlAppend, t as isNoEntError, v as signalAbortError } from "./jsonl-file-
|
|
2
|
+
import { _ as runAbortable, c as withJsonlFileLock, d as journalFileStamp, f as sha256, h as deadlineSignal, l as appendCommittedJsonLine, o as readCommittedJsonLines, p as RunCancellationReason, r as prepareJsonlAppend, t as isNoEntError, v as signalAbortError } from "./jsonl-file-vE9H9UXa.js";
|
|
3
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
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
5
|
import { $ as newUsageTotals, F as executorFailureInfra, G as BudgetReconcileFault, I as executorFailureReason, J as budgetRecoverySeeds, K as budgetLeaseUpdates, M as contentAddress, Ot as recordValue, P as executorFailure, Q as meterUsageEvent, X as createBudgetPool, Y as completedLeafBacking, Z as refreshBudgetLease, a as settlementFailureCause, d as executorEvidenceWriter, ft as extractTransportEventIdentity, h as prepareRetainedExecutor, j as traceRootWriter, l as RetainedExecutionPendingError, m as leafContinuationExecutionId, n as runtimeFailureCause, nt as assertValidBudget, o as BUDGET_CONTINUATION_TASK, pt as parseCanonicalTransportEvent, q as budgetLeases, rt as assertValidSpend, t as reportedFailureCause, tt as spendFromUsageTotals, v as retainedExecutorSeamKey } from "./failure-cause-DoCCGLDH.js";
|
|
6
6
|
import { a as errMessage, f as resolveRedactor, i as causeChain, l as errorText, n as detachedSnapshot, r as shareParsedStrings, u as defaultRedactor } from "./snapshot-BKI_w3JD.js";
|
|
7
|
-
import { p as canonicalObservedModelParts, t as assertExecutableAgentProfile } from "./model-policy-
|
|
7
|
+
import { p as canonicalObservedModelParts, t as assertExecutableAgentProfile } from "./model-policy-DTbTFyOG.js";
|
|
8
8
|
import { b as verifiedArtifactChunks, g as workspaceLimits, h as safeArchivePath, i as readAgentCandidateWorkspaceArtifactFiles } from "./workspace-streams-C7PGLAUd.js";
|
|
9
|
-
import { a as assertNoSymlinkDescendant, b as
|
|
9
|
+
import { a as assertNoSymlinkDescendant, b as captureRunWriteContext, c as publishExclusiveFenced, d as writeAtomicDurableFileAsync, i as appendRunLinesFenced, n as appendDurableFile, o as publishExclusiveDurableFile, r as appendRunLines, s as publishExclusiveDurableFileAsync, u as writeAtomicDurableFile, v as runFencedAlways, x as fenceRunWrite, y as runFencedAsync } from "./durable-file-pao7FijS.js";
|
|
10
10
|
import { b as sha256Bytes$1, g as deepFreezeCandidate } from "./output-artifacts-AqkZ8lO2.js";
|
|
11
11
|
import { a as withPursuitContext, i as notifyRuntimeHookEvent } from "./runtime-hooks-CsW2pfFk.js";
|
|
12
12
|
import * as traceContract from "@tangle-network/agent-trace-contract";
|
|
@@ -4196,18 +4196,48 @@ function mintRetainedIdentity(idempotencyKey, turnId) {
|
|
|
4196
4196
|
}
|
|
4197
4197
|
/** Bound from a durable intent until `provider.create` resolves. */
|
|
4198
4198
|
const RETAINED_ENVIRONMENT_MATERIALIZATION_MS = 12e4;
|
|
4199
|
-
/**
|
|
4199
|
+
/**
|
|
4200
|
+
* Creates per admission. A create that does not answer within the bound, or that Sandbox answers
|
|
4201
|
+
* `OPERATION_FAILED`, is tried again with the same idempotency key after a pause of an eighth of
|
|
4202
|
+
* the bound (at most 15 s). The last failure stops the driver, named. Nothing was dispatched.
|
|
4203
|
+
* (#2670)
|
|
4204
|
+
*/
|
|
4205
|
+
const RETAINED_CREATE_TRIES = 3;
|
|
4206
|
+
/** Create never reached an environment. The message names the stage and creates; driver stops. */
|
|
4200
4207
|
var RetainedMaterializationTimeoutError = class extends Error {
|
|
4208
|
+
creates;
|
|
4201
4209
|
stage = "intent";
|
|
4202
|
-
constructor() {
|
|
4203
|
-
|
|
4210
|
+
constructor(creates = 1) {
|
|
4211
|
+
const tried = creates > 1 ? ` after ${creates} creates` : "";
|
|
4212
|
+
super(`retained run reached stage intent and did not materialize an environment${tried}`);
|
|
4213
|
+
this.creates = creates;
|
|
4204
4214
|
this.name = "RetainedMaterializationTimeoutError";
|
|
4205
4215
|
}
|
|
4206
4216
|
};
|
|
4207
|
-
|
|
4208
|
-
|
|
4217
|
+
/** Sandbox's catalogued server failure (`OPERATION_FAILED`, 500): a keyed create may run again. */
|
|
4218
|
+
function operationFailed(error) {
|
|
4219
|
+
if (!(error instanceof Error)) return false;
|
|
4220
|
+
try {
|
|
4221
|
+
return [Reflect.get(error, "code"), Reflect.get(error, "catalogCode")].includes("OPERATION_FAILED");
|
|
4222
|
+
} catch {
|
|
4223
|
+
return false;
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
async function createRetainedEnvironment(options, parent) {
|
|
4227
|
+
const bound = options.materializationTimeoutMs ?? RETAINED_ENVIRONMENT_MATERIALIZATION_MS;
|
|
4228
|
+
const aborted = () => parent?.aborted === true;
|
|
4229
|
+
for (let create = 1;; create += 1) try {
|
|
4230
|
+
return await createRetainedEnvironmentOnce(options, parent, bound, create);
|
|
4231
|
+
} catch (error) {
|
|
4232
|
+
if (!(error instanceof RetainedMaterializationTimeoutError || operationFailed(error)) || create === RETAINED_CREATE_TRIES || aborted()) throw error;
|
|
4233
|
+
await sleep(Math.min(15e3, Math.ceil(bound / 8)), parent);
|
|
4234
|
+
if (aborted()) throw parent?.reason instanceof Error ? parent.reason : error;
|
|
4235
|
+
}
|
|
4236
|
+
}
|
|
4237
|
+
function createRetainedEnvironmentOnce(options, parent, bound, create) {
|
|
4238
|
+
const timeout = AbortSignal.timeout(bound);
|
|
4209
4239
|
const signal = parent === void 0 ? timeout : AbortSignal.any([parent, timeout]);
|
|
4210
|
-
const
|
|
4240
|
+
const created = options.provider.create({
|
|
4211
4241
|
...options.environment,
|
|
4212
4242
|
signal,
|
|
4213
4243
|
metadata: retainedEnvironmentMetadata(options.environment.metadata, options.environment.idempotencyKey)
|
|
@@ -4215,19 +4245,19 @@ function createRetainedEnvironment(options, parent) {
|
|
|
4215
4245
|
const timedOut = () => timeout.aborted && parent?.aborted !== true;
|
|
4216
4246
|
return new Promise((resolve, reject) => {
|
|
4217
4247
|
const fail = () => {
|
|
4218
|
-
reject(timedOut() ? new RetainedMaterializationTimeoutError() : parent?.reason instanceof Error ? parent.reason : /* @__PURE__ */ new Error("retained run materialization aborted"));
|
|
4248
|
+
reject(timedOut() ? new RetainedMaterializationTimeoutError(create) : parent?.reason instanceof Error ? parent.reason : /* @__PURE__ */ new Error("retained run materialization aborted"));
|
|
4219
4249
|
};
|
|
4220
4250
|
if (signal.aborted) {
|
|
4221
4251
|
fail();
|
|
4222
4252
|
return;
|
|
4223
4253
|
}
|
|
4224
4254
|
signal.addEventListener("abort", fail, { once: true });
|
|
4225
|
-
|
|
4255
|
+
created.then((environment) => {
|
|
4226
4256
|
signal.removeEventListener("abort", fail);
|
|
4227
4257
|
resolve(environment);
|
|
4228
4258
|
}, (error) => {
|
|
4229
4259
|
signal.removeEventListener("abort", fail);
|
|
4230
|
-
reject(timedOut() ? new RetainedMaterializationTimeoutError() : error);
|
|
4260
|
+
reject(timedOut() ? new RetainedMaterializationTimeoutError(create) : error);
|
|
4231
4261
|
});
|
|
4232
4262
|
});
|
|
4233
4263
|
}
|
|
@@ -9490,6 +9520,19 @@ function readWorkerInteractiveBinding(eventDir, workerId) {
|
|
|
9490
9520
|
* @internal
|
|
9491
9521
|
*/
|
|
9492
9522
|
function writeWorkerInteractiveBinding(eventDir, workerId, label, journalRoot, session, now = Date.now) {
|
|
9523
|
+
const pending = prepareBinding(eventDir, workerId, label, journalRoot, session, now);
|
|
9524
|
+
if ("existing" in pending) return pending.existing;
|
|
9525
|
+
return settleBinding(eventDir, pending.binding, publishExclusiveDurableFile(pending.file, bindingText(pending.binding)));
|
|
9526
|
+
}
|
|
9527
|
+
/** `writeWorkerInteractiveBinding` without blocking the calling thread on the disk. @internal */
|
|
9528
|
+
async function writeWorkerInteractiveBindingAsync(eventDir, workerId, label, journalRoot, session, now = Date.now) {
|
|
9529
|
+
const pending = prepareBinding(eventDir, workerId, label, journalRoot, session, now);
|
|
9530
|
+
if ("existing" in pending) return pending.existing;
|
|
9531
|
+
return settleBinding(eventDir, pending.binding, await publishExclusiveDurableFileAsync(pending.file, bindingText(pending.binding)));
|
|
9532
|
+
}
|
|
9533
|
+
const bindingText = (binding) => `${JSON.stringify(binding, null, 2)}\n`;
|
|
9534
|
+
/** The binding to publish and its file, or the identical binding already published. */
|
|
9535
|
+
function prepareBinding(eventDir, workerId, label, journalRoot, session, now) {
|
|
9493
9536
|
const id = stableText$1(workerId, "worker id");
|
|
9494
9537
|
const workerLabel = stableText$1(label, "worker label");
|
|
9495
9538
|
const root = stableText$1(journalRoot, "journal root");
|
|
@@ -9521,10 +9564,17 @@ function writeWorkerInteractiveBinding(eventDir, workerId, label, journalRoot, s
|
|
|
9521
9564
|
const existing = readWorkerInteractiveBinding(eventDir, id);
|
|
9522
9565
|
if (existing !== void 0) {
|
|
9523
9566
|
assertSameBinding(existing, binding);
|
|
9524
|
-
return existing;
|
|
9567
|
+
return { existing };
|
|
9525
9568
|
}
|
|
9526
|
-
|
|
9527
|
-
|
|
9569
|
+
return {
|
|
9570
|
+
binding,
|
|
9571
|
+
file
|
|
9572
|
+
};
|
|
9573
|
+
}
|
|
9574
|
+
/** The published binding: this one, or the identical winner of a concurrent publication. */
|
|
9575
|
+
function settleBinding(eventDir, binding, published) {
|
|
9576
|
+
if (published) return binding;
|
|
9577
|
+
const winner = readWorkerInteractiveBinding(eventDir, binding.workerId);
|
|
9528
9578
|
if (winner === void 0) throw new Error(`worker interactive binding publication lost its winner`);
|
|
9529
9579
|
assertSameBinding(winner, binding);
|
|
9530
9580
|
return winner;
|
|
@@ -11568,6 +11618,39 @@ function workerSteerAcknowledgementFile(eventDir, operationId) {
|
|
|
11568
11618
|
* @stable
|
|
11569
11619
|
*/
|
|
11570
11620
|
function writeWorkerSteer(rootDir, supervisorId, worker, options) {
|
|
11621
|
+
const steer = prepareWorkerSteer(rootDir, supervisorId, worker, options);
|
|
11622
|
+
const admitted = admitSteerRequest(steer.file, steer.request);
|
|
11623
|
+
if (admitted.replayed) return replayedSteer(steer, admitted);
|
|
11624
|
+
for (const projection of steerProjections(steer)) try {
|
|
11625
|
+
appendRunLines(projection.file, projection.lines, projection.options);
|
|
11626
|
+
} catch {}
|
|
11627
|
+
return {
|
|
11628
|
+
worker: steer.workerId,
|
|
11629
|
+
file: steer.file,
|
|
11630
|
+
request: steer.request,
|
|
11631
|
+
replayed: false
|
|
11632
|
+
};
|
|
11633
|
+
}
|
|
11634
|
+
/**
|
|
11635
|
+
* Admit one steer like `writeWorkerSteer`, without blocking the calling thread on the disk.
|
|
11636
|
+
* The request file is published by the durable writer whether or not the caller holds a run claim
|
|
11637
|
+
* (a coordinator outside the run holds none), so an event loop that admits steers keeps running
|
|
11638
|
+
* while the file and its directory reach disk. Same admission, replay and conflict rules.
|
|
11639
|
+
* @stable
|
|
11640
|
+
*/
|
|
11641
|
+
async function writeWorkerSteerAsync(rootDir, supervisorId, worker, options) {
|
|
11642
|
+
const steer = prepareWorkerSteer(rootDir, supervisorId, worker, options);
|
|
11643
|
+
const admitted = await admitSteerRequestAsync(steer.file, steer.request);
|
|
11644
|
+
if (admitted.replayed) return replayedSteer(steer, admitted);
|
|
11645
|
+
for (const projection of steerProjections(steer)) await runFencedAlways("appendRunLines", appendRunLinesFenced, projection.file, projection.lines, projection.options).catch(() => {});
|
|
11646
|
+
return {
|
|
11647
|
+
worker: steer.workerId,
|
|
11648
|
+
file: steer.file,
|
|
11649
|
+
request: steer.request,
|
|
11650
|
+
replayed: false
|
|
11651
|
+
};
|
|
11652
|
+
}
|
|
11653
|
+
function prepareWorkerSteer(rootDir, supervisorId, worker, options) {
|
|
11571
11654
|
const workerId = worker.trim();
|
|
11572
11655
|
if (!workerId) throw new Error("writeWorkerSteer: worker id is empty");
|
|
11573
11656
|
const operationId = options.operationId.trim();
|
|
@@ -11578,17 +11661,16 @@ function writeWorkerSteer(rootDir, supervisorId, worker, options) {
|
|
|
11578
11661
|
const interrupt = options.interrupt === true;
|
|
11579
11662
|
if (options.eventDir !== void 0 && !options.eventDir.trim()) throw new Error("writeWorkerSteer: eventDir is empty");
|
|
11580
11663
|
const dir = options.eventDir === void 0 ? supervisorRunDir(rootDir, supervisorId) : resolve(options.eventDir);
|
|
11581
|
-
const requestDigest = workerSteerRequestDigest({
|
|
11582
|
-
operationId,
|
|
11583
|
-
worker: workerId,
|
|
11584
|
-
message: trimmed,
|
|
11585
|
-
source,
|
|
11586
|
-
interrupt
|
|
11587
|
-
});
|
|
11588
11664
|
const request = {
|
|
11589
11665
|
schemaVersion: 1,
|
|
11590
11666
|
operationId,
|
|
11591
|
-
requestDigest
|
|
11667
|
+
requestDigest: workerSteerRequestDigest({
|
|
11668
|
+
operationId,
|
|
11669
|
+
worker: workerId,
|
|
11670
|
+
message: trimmed,
|
|
11671
|
+
source,
|
|
11672
|
+
interrupt
|
|
11673
|
+
}),
|
|
11592
11674
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11593
11675
|
source,
|
|
11594
11676
|
worker: workerId,
|
|
@@ -11599,36 +11681,48 @@ function writeWorkerSteer(rootDir, supervisorId, worker, options) {
|
|
|
11599
11681
|
assertNoSymlinkDescendant(dir, file, "steer request");
|
|
11600
11682
|
mkdirSync(workerSteerRequestsDir(dir), { recursive: true });
|
|
11601
11683
|
assertNoSymlinkDescendant(dir, file, "steer request");
|
|
11602
|
-
|
|
11603
|
-
|
|
11684
|
+
return {
|
|
11685
|
+
dir,
|
|
11686
|
+
file,
|
|
11687
|
+
operationId,
|
|
11688
|
+
workerId,
|
|
11689
|
+
request
|
|
11690
|
+
};
|
|
11691
|
+
}
|
|
11692
|
+
function replayedSteer({ dir, file, operationId }, admitted) {
|
|
11693
|
+
const acknowledgement = readWorkerSteerAcknowledgement(dir, operationId);
|
|
11694
|
+
return {
|
|
11604
11695
|
worker: admitted.request.worker,
|
|
11605
11696
|
file,
|
|
11606
11697
|
request: admitted.request,
|
|
11607
|
-
...
|
|
11698
|
+
...acknowledgement === void 0 ? {} : { acknowledgement },
|
|
11608
11699
|
replayed: true
|
|
11609
11700
|
};
|
|
11701
|
+
}
|
|
11702
|
+
/** The readable projections the admission winner appends: the worker's inbox line and control event. */
|
|
11703
|
+
function steerProjections({ dir, operationId, workerId, request }) {
|
|
11610
11704
|
mkdirSync(supervisorWorkersDir(dir), { recursive: true });
|
|
11611
|
-
const
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
} catch {}
|
|
11615
|
-
appendWorkerControlEvent(dir, workerId, {
|
|
11705
|
+
const event = {
|
|
11706
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11707
|
+
label: workerId,
|
|
11616
11708
|
kind: "message",
|
|
11617
11709
|
direction: "down",
|
|
11618
|
-
source,
|
|
11710
|
+
source: request.source,
|
|
11619
11711
|
operationId,
|
|
11620
|
-
requestDigest,
|
|
11621
|
-
message:
|
|
11622
|
-
interrupt,
|
|
11712
|
+
requestDigest: request.requestDigest,
|
|
11713
|
+
message: request.message,
|
|
11714
|
+
interrupt: request.interrupt,
|
|
11623
11715
|
queued: true,
|
|
11624
11716
|
delivered: false
|
|
11625
|
-
});
|
|
11626
|
-
return {
|
|
11627
|
-
worker: workerId,
|
|
11628
|
-
file,
|
|
11629
|
-
request,
|
|
11630
|
-
replayed: false
|
|
11631
11717
|
};
|
|
11718
|
+
return [{
|
|
11719
|
+
file: workerInboxFileFromEventDir(dir, workerId),
|
|
11720
|
+
lines: [`${JSON.stringify(request)}\n`]
|
|
11721
|
+
}, {
|
|
11722
|
+
file: workerControlLogFile(dir, workerId),
|
|
11723
|
+
lines: [`${JSON.stringify(event)}\n`],
|
|
11724
|
+
options: { directory: supervisorWorkersDir(dir) }
|
|
11725
|
+
}];
|
|
11632
11726
|
}
|
|
11633
11727
|
/** Read every atomically admitted request for one exact worker id, in admission order. @stable */
|
|
11634
11728
|
function readWorkerSteerRequests(eventDir, worker) {
|
|
@@ -11670,7 +11764,7 @@ function readWorkerSteerAcknowledgement(eventDir, operationId) {
|
|
|
11670
11764
|
* Returns `true` only to the process that created the pre-delivery record.
|
|
11671
11765
|
* @internal
|
|
11672
11766
|
*/
|
|
11673
|
-
function claimWorkerSteerDelivery(eventDir, record) {
|
|
11767
|
+
async function claimWorkerSteerDelivery(eventDir, record) {
|
|
11674
11768
|
const exact = parseWorkerSteerAcknowledgement(record);
|
|
11675
11769
|
if (exact.effect !== "unknown") throw new Error("steer delivery claim must use effect unknown");
|
|
11676
11770
|
const request = readWorkerSteerRequest(eventDir, exact.operationId);
|
|
@@ -11680,13 +11774,13 @@ function claimWorkerSteerDelivery(eventDir, record) {
|
|
|
11680
11774
|
mkdirSync(dir, { recursive: true });
|
|
11681
11775
|
assertNoSymlinkDescendant(eventDir, dir, "steer acknowledgement");
|
|
11682
11776
|
const file = workerSteerAcknowledgementFile(eventDir, exact.operationId);
|
|
11683
|
-
if (
|
|
11777
|
+
if (await publishExclusiveDurableFileAsync(file, `${JSON.stringify(exact, null, 2)}\n`)) return true;
|
|
11684
11778
|
const winner = readWorkerSteerAcknowledgement(eventDir, exact.operationId);
|
|
11685
11779
|
if (winner === void 0 || winner.operationId !== exact.operationId || winner.requestDigest !== exact.requestDigest) throw new Error("steer delivery claim conflicts with another operation");
|
|
11686
11780
|
return false;
|
|
11687
11781
|
}
|
|
11688
11782
|
/** Atomically replace the runtime acknowledgement for one steer operation. @internal */
|
|
11689
|
-
function writeWorkerSteerAcknowledgement(eventDir, record) {
|
|
11783
|
+
async function writeWorkerSteerAcknowledgement(eventDir, record) {
|
|
11690
11784
|
const exact = parseWorkerSteerAcknowledgement(record);
|
|
11691
11785
|
const request = readWorkerSteerRequest(eventDir, exact.operationId);
|
|
11692
11786
|
if (request === void 0 || request.requestDigest !== exact.requestDigest) throw new Error("steer acknowledgement does not match an admitted request");
|
|
@@ -11697,7 +11791,7 @@ function writeWorkerSteerAcknowledgement(eventDir, record) {
|
|
|
11697
11791
|
const file = workerSteerAcknowledgementFile(eventDir, exact.operationId);
|
|
11698
11792
|
const prior = readWorkerSteerAcknowledgement(eventDir, exact.operationId);
|
|
11699
11793
|
if (prior !== void 0 && prior.effect !== "unknown" && canonicalCandidateDigest(prior) !== canonicalCandidateDigest(exact)) throw new Error(`steer operation '${exact.operationId}' already has a terminal acknowledgement`);
|
|
11700
|
-
|
|
11794
|
+
await writeAtomicDurableFileAsync(file, `${JSON.stringify(exact, null, 2)}\n`);
|
|
11701
11795
|
}
|
|
11702
11796
|
/** The directory holding every cancellation artifact of one run (request inbox + acknowledgements). */
|
|
11703
11797
|
function workerCancellationsDir(eventDir) {
|
|
@@ -11896,15 +11990,23 @@ function operationFileHash(operationId) {
|
|
|
11896
11990
|
return sha256(id);
|
|
11897
11991
|
}
|
|
11898
11992
|
function admitSteerRequest(file, request) {
|
|
11993
|
+
return replayedSteerRequest(file, request) ?? steerAdmission(file, request, publishExclusiveDurableFile(file, steerRequestText(request)));
|
|
11994
|
+
}
|
|
11995
|
+
async function admitSteerRequestAsync(file, request) {
|
|
11996
|
+
return replayedSteerRequest(file, request) ?? steerAdmission(file, request, await runFencedAlways("publishExclusiveDurableFile", publishExclusiveFenced, file, steerRequestText(request)));
|
|
11997
|
+
}
|
|
11998
|
+
const steerRequestText = (request) => `${JSON.stringify(request, null, 2)}\n`;
|
|
11999
|
+
function replayedSteerRequest(file, request) {
|
|
11899
12000
|
const existing = readWorkerSteerRequestFile(file);
|
|
11900
|
-
if (existing
|
|
11901
|
-
|
|
11902
|
-
|
|
11903
|
-
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
12001
|
+
if (existing === void 0) return void 0;
|
|
12002
|
+
assertSameSteerRequest(existing, request);
|
|
12003
|
+
return {
|
|
12004
|
+
request: existing,
|
|
12005
|
+
replayed: true
|
|
12006
|
+
};
|
|
12007
|
+
}
|
|
12008
|
+
function steerAdmission(file, request, published) {
|
|
12009
|
+
if (published) return {
|
|
11908
12010
|
request,
|
|
11909
12011
|
replayed: false
|
|
11910
12012
|
};
|
|
@@ -12561,7 +12663,7 @@ function bindInteractiveWorker(args, live, label, childRun, signal, spawnCommitt
|
|
|
12561
12663
|
if (ready === void 0 || notStarted(ready)) return;
|
|
12562
12664
|
session = ready;
|
|
12563
12665
|
}
|
|
12564
|
-
|
|
12666
|
+
await writeWorkerInteractiveBindingAsync(args.interactiveBindingDir, live.id, label, args.root, session, now);
|
|
12565
12667
|
});
|
|
12566
12668
|
}
|
|
12567
12669
|
/**
|
|
@@ -13866,7 +13968,7 @@ function aggregateProviderModelEvidence(forest) {
|
|
|
13866
13968
|
base = identity.base;
|
|
13867
13969
|
snapshot ??= identity.snapshot;
|
|
13868
13970
|
if (identity.snapshot !== void 0) {
|
|
13869
|
-
canonicalModels.add(
|
|
13971
|
+
canonicalModels.add(identity.canonical);
|
|
13870
13972
|
if (canonicalModels.size > 1) markConflict();
|
|
13871
13973
|
}
|
|
13872
13974
|
}
|
|
@@ -14123,6 +14225,6 @@ function unknownChannels(spend) {
|
|
|
14123
14225
|
function isNonEmptySpend(s) {
|
|
14124
14226
|
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);
|
|
14125
14227
|
}
|
|
14126
|
-
export {
|
|
14228
|
+
export { reenteredWorkers as $, loopEventToOtelSpan as $n, unknownExecutionBindingReceipt as $r, scopeRetainedOwnerRestorePoint as $t, writeWorkerCancellation as A, retainedCreateMaterial as An, attestRuntimeOwnedExecutor as Ar, abandonScopeRetainedOwnerInvocation as At, parseWorkerToolTraceArtifact as B, WORKER_TRACE_PROPAGATION as Bn, providerAttemptEvidence as Br, recordScopeOwnerMaterialization as Bt, safeWorkerFile as C, RetainedMaterializationTimeoutError as Cn, SEAT_RECHECK_MS as Cr, waitForScopeChildren as Ct, workerCancellationsDir as D, recoverRetainedRun as Dn, seatExecutionProfile as Dr, environmentReader as Dt, workerCancelRequestsFile as E, reconnectRetainedRun as En, authoredSeatStages as Er, scopeRetainedOwnerResourceReader as Et, openSlotGroup as F, createFileObserverHooks as Fn, finalizeRuntimeOwnedPendingExecutor as Fr, beginScopeOwnerAttempt as Ft, readWorkerInteractiveBinding as G, readTraceContextFromEnv as Gn, recordRuntimeOwnedProviderModel as Gr, coordinationProfileToolPrefix as Gt, nestedScopeSeamKey as H, workerTraceHeaders as Hn, recordRuntimeOwnedProviderAttemptStart as Hr, scopeOwnerExecutionObservation as Ht, resolveWorkerSlots as I, observerRecordDigest as In, inheritRuntimeOwnedExecutorAttestation as Ir, finalizeScopeOwnerMaterialization as It, startRetainedInteractiveRun as J, buildRuntimeEventOtelSpans as Jn, runtimeOwnedExecutorMaterialization as Jr, beginScopeRetainedOwnerDrive as Jt, reconnectRetainedInteractiveRun as K, buildLoopOtelSpans as Kn, runtimeOwnedDriveHarnessProviderEvidence as Kr, providerVisibleProfile as Kt, prepareScopeResume as L, verifyObserverRecords as Ln, knownExecutionBindingReceipt as Lr, holdScopeOwnerTranscript as Lt, writeWorkerSteerAcknowledgement as M, offerInteractiveControl as Mn, attestRuntimeOwnedScopeOwner as Mr, prepareScopeRetainedOwnerTask as Mt, writeWorkerSteerAsync as N, prepareInteractiveDelegation as Nn, authoredAgentIdentity as Nr, scopeRetainedOwnerPriorSpend as Nt, workerInboxFileFromEventDir as O, startRetainedRun as On, subscriptionUsageLimitSignal as Or, resolveSpawnResourcePaths as Ot, createWorkerSlots as P, FileObserverJournal as Pn, authoredProfileDigest as Pr, scopeRetainedOwnerResult as Pt, appendTeardownConfirmation as Q, generateSpanId as Qn, runtimeOwnedScopeOwnerRuntime as Qr, reconcileScopeRetainedOwnerEnvironment as Qt, replaySpawnTree as R, destroyInteractiveEnvironment as Rn, knownMaterializationReceipt as Rr, noteScopeOwnerPlannedExecution as Rt, readWorkerSteerRequests as S, verifyWorkspaceMarker as Sn, isTerminalNodeStatus as Sr, unconfirmedTeardowns as St, supervisorRunsRoot as T, mintRetainedIdentity as Tn, SeatPauseError as Tr, releaseScopeRetainedOwnerForSeatPause as Tt, interactiveAdmissionSeamKey as U, createPropagatingTraceEmitter as Un, recordRuntimeOwnedProviderDispatchNotStarted as Ur, scopeOwnerExecutorNodeContext as Ut, workerTraceAnalysisStore as V, workerTraceEnv as Vn, recordRuntimeOwnedDriveHarnessProviderEvidence as Vr, restoreScopeOwnerAcceptedExecution as Vt, attachWorker as W, mergeTraceEnv as Wn, recordRuntimeOwnedProviderIdentityConflict as Wr, coordinationMcpAlias as Wt, appendSpawnEvents as X, createOtelExporter as Xn, runtimeOwnedPendingExecutorMaterialization as Xr, scopeRetainedOwnerTurnEnded as Xt, FileSpawnJournal as Y, createOpenInferenceFileExporter as Yn, runtimeOwnedExecutorProviderEvidence as Yr, scopeRetainedOwnerSettled as Yt, spawnJournalRecordEvents as Z, flatOtelSpan as Zn, runtimeOwnedScopeOwnerControl as Zr, assertRetainedOwnerCoordinationRekey as Zt, legacySupervisorRunDir as _, executorObservationSeamKey as _n, DEFAULT_STALL_AFTER_MS as _r, releaseHeldEnvironments as _t, closeStreamFile as a, runtimeFlowAgent as ai, scopeOwnerLiabilities as an, captureBoundHarnessTranscript as ar, rollingDispatch as at, readWorkerCancellation as b, describeRetainedNativeStops as bn, readWorkerProgress as br, settleManagerWork as bt, openStreamFileFenced as c, assertEventBinding as ci, loadSpawnForest as cn, harnessTranscriptFromLines as cr, closeScopeAdmission as ct, syncStreamFileFenced as d, freezeControlRef as di, attestNestedDriverTreeOwner as dn, readHarnessTranscript as dr, meterRuntimeOwnedProviderAttempt as dt, unknownMaterializationReceipt as ei, noteScopeRetainedOwnerCoordination as en, createRuntimeEventCollector as er, settledToIteration as et, writeStreamLinesFenced as f, retainedSessionReplaced as fi, driverRuntime as fn, settleHarnessTranscript as fr, pauseScopeSeatAdmission as ft, fileEscalateQuestion as g, providerMessageText as gi, executorObservation as gn, retainHarnessTranscript as gr, registerNestedTeardownScope as gt, claimWorkerSteerDelivery as h, promptOptionsFromAgentTurnInput as hi, insideCursorNamespace as hn, resolveHarnessTranscriptCapture as hr, recordScopeOwnerPause as ht, ROOT_STREAM_FILE as i, runtimeCheckFactory as ii, owners as in, HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS as ir, queueOf as it, writeWorkerSteer as j, acceptedInteractiveControl as jn, attestRuntimeOwnedPendingExecutor as jr, consumeScopeRetainedOwnerResult as jt, workerSteerRequestsDir as k, startRetainedRunInEnvironment as kn, attestRuntimeOwnedDeferredExecutor as kr, RELEASE_DESTROY_MS as kt, readRootStream as l, awaitAbortable$1 as li, ownedTreeRootSpawn as ln, harnessTranscriptUnavailable as lr, hasRetriableTeardowns as lt, cancelWorker as m, promptFromAgentTurnInput as mi, SpawnEventIndex as mn, readBoundHarnessSessions$1 as mr, recordScopeOwnerDriverAttempt as mt, terminalAccounting as n, executableAgentSpecSnapshot as ni, bindScopeRetainedOwnerEnvironmentId as nn, sanitizeKnowledgeReadinessReport as nr, deriveNodeExecutionIdentity as nt, createRootStreamSink as o, runtimeFlowBrain as oi, scopeRetainedOwnerContext as on, captureHarnessTranscript as or, boundRetainedReleases as ot, appendWorkerControlEvent as p, sameControlCoordinates as pi, nestedDriverTreeRoot as pn, HARNESS_TRANSCRIPT_READ_LIMITS as pr, recordScopeOwnerBarrenPause as pt, recoverRetainedInteractiveRun as q, buildLoopSpanNodes as qn, runtimeOwnedExecutorExecutionBinding as qr, runtimeGraphMetadataKey as qt, createScope as r, isRuntimeFlowBrain as ri, bindScopeRetainedOwnerProvider as rn, sanitizeRuntimeStreamEvent as rr, freeSlots as rt, nodeStreamFile as s, RetainedRunProviderContractError as si, scopeRetainedOwnerJournalRoot as sn, harnessTranscriptArtifact as sr, closeRetainedSlots as st, isNonEmptySpend as t, executableAgentProfileSnapshot as ti, scopeRetainedOwnerCheckpointing as tn, createRuntimeStreamEventCollector as tr, assertRecursiveReservationPolicy as tt, readRootStreamReceipt as u, exactSession as ui, materializeTreeView as un, persistHarnessTranscript as ur, meterRuntimeOwnedAccounting as ut, legacySupervisorRunsRoot as v, observeModelRequest as vn, createActivityLog as vr, releaseRetainedEnvironments as vt, supervisorRunDir as w, assertRetainedRunReplayMaterial as wn, SeatChain as wr, prepareScopeRetainedOwnerSeatSwitch as wt, readWorkerSteerAcknowledgement as x, stopRetainedNativeExecution as xn, isLiveNodeStatus as xr, startScopeRecoveries as xt, readWorkerCancelRequests as y, NATIVE_STOP_UNCONFIRMED as yn, describeToolArgs as yr, retryUnconfirmedTeardowns as yt, isTraceAnalysisStore as z, environmentGone as zn, newExecutionAttemptId as zr, recordScopeOwnerHarnessTranscript as zt };
|
|
14127
14229
|
|
|
14128
|
-
//# sourceMappingURL=supervisor-accounting-
|
|
14230
|
+
//# sourceMappingURL=supervisor-accounting-DuFyM-_h.js.map
|