@tangle-network/agent-runtime 8.0.1 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/{activation-8AdN-3r4.js → activation-BrBDs0Yj.js} +3 -3
- package/dist/{activation-8AdN-3r4.js.map → activation-BrBDs0Yj.js.map} +1 -1
- package/dist/{activation-xxvLF1-1.d.ts → activation-Cvw_7nrn.d.ts} +2 -2
- package/dist/agent.d.ts +3 -3
- package/dist/agent.js +2 -2
- package/dist/agent.js.map +1 -1
- package/dist/candidate-execution/index.js +2 -2
- package/dist/{continuation-CIyKnS1Q.js → continuation-DDPfLw2w.js} +2 -2
- package/dist/{continuation-CIyKnS1Q.js.map → continuation-DDPfLw2w.js.map} +1 -1
- package/dist/{coordination-manager-DAGPerJy.js → coordination-manager-DKmQGzBB.js} +9 -10
- package/dist/coordination-manager-DKmQGzBB.js.map +1 -0
- package/dist/{delegate-CoaNr0hO.js → delegate-eayHBLHB.js} +2 -2
- package/dist/{delegate-CoaNr0hO.js.map → delegate-eayHBLHB.js.map} +1 -1
- package/dist/durable.d.ts +33 -2
- package/dist/durable.js +75 -14
- package/dist/durable.js.map +1 -1
- package/dist/{graph-pFTeNZ-G.js → graph-Cdhyxi8E.js} +10 -10
- package/dist/graph-Cdhyxi8E.js.map +1 -0
- package/dist/{graph-registry-czAwYwNj.js → graph-registry-D3cY0BJU.js} +3 -3
- package/dist/{graph-registry-czAwYwNj.js.map → graph-registry-D3cY0BJU.js.map} +1 -1
- package/dist/{graph-registry-uTIyyy7A.js → graph-registry-DTeb6qhB.js} +1 -1
- package/dist/{improve-I43jex8v.js → improve-CnTEGkF6.js} +6 -6
- package/dist/{improve-I43jex8v.js.map → improve-CnTEGkF6.js.map} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +12 -12
- package/dist/intelligence.d.ts +4 -4
- package/dist/intelligence.js +6 -6
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +15 -15
- package/dist/{loop-runner-BGwhcn1p.d.ts → loop-runner-Bd9Ieh5w.d.ts} +2 -2
- package/dist/{loop-runner-BN4KozR0.js → loop-runner-CGt9nTw7.js} +3 -3
- package/dist/{loop-runner-BN4KozR0.js.map → loop-runner-CGt9nTw7.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 +6 -6
- package/dist/{prepare-BnF8nGIg.js → prepare-D7WwIddG.js} +2 -2
- package/dist/{prepare-BnF8nGIg.js.map → prepare-D7WwIddG.js.map} +1 -1
- package/dist/{profile-CD25rTJF.js → profile-BT0X-dm5.js} +2 -2
- package/dist/{profile-CD25rTJF.js.map → profile-BT0X-dm5.js.map} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{provision-supervisor-DvzayGpe.js → provision-supervisor-B-ULubUf.js} +6 -6
- package/dist/{provision-supervisor-DvzayGpe.js.map → provision-supervisor-B-ULubUf.js.map} +1 -1
- package/dist/{run-cancellation-C5__aBKW.js → run-cancellation-DZn4OSl8.js} +2 -2
- package/dist/{run-cancellation-C5__aBKW.js.map → run-cancellation-DZn4OSl8.js.map} +1 -1
- package/dist/{run-state-CJAaxqfp.js → run-state-nbF5NNGy.js} +6 -6
- package/dist/{run-state-CJAaxqfp.js.map → run-state-nbF5NNGy.js.map} +1 -1
- package/dist/{runtime-CuwHe8_K.js → runtime-CPL2lhgf.js} +98 -30
- package/dist/runtime-CPL2lhgf.js.map +1 -0
- package/dist/{search-executor-DAjm-NlG.js → search-executor-2xqDTDNO.js} +3 -3
- package/dist/{search-executor-DAjm-NlG.js.map → search-executor-2xqDTDNO.js.map} +1 -1
- package/dist/{server-BUpNUn5D.js → server-DHZq2AG7.js} +3 -3
- package/dist/{server-BUpNUn5D.js.map → server-DHZq2AG7.js.map} +1 -1
- package/dist/{settle-record-CeBdBuxP.js → settle-record-B95oiypS.js} +3 -3
- package/dist/{settle-record-CeBdBuxP.js.map → settle-record-B95oiypS.js.map} +1 -1
- package/dist/{structural-rollout-CqxBKxKY.js → structural-rollout-BHNqBUV0.js} +8 -5
- package/dist/structural-rollout-BHNqBUV0.js.map +1 -0
- package/dist/{supervise-Cdqj_oe4.js → supervise-DkhIZyD_.js} +16 -16
- package/dist/supervise-DkhIZyD_.js.map +1 -0
- package/dist/{supervision-discovery-CW-ildZ-.js → supervision-discovery-DUpm_6nQ.js} +2 -2
- package/dist/{supervision-discovery-CW-ildZ-.js.map → supervision-discovery-DUpm_6nQ.js.map} +1 -1
- package/dist/{supervisor-D-eT-6Tu.js → supervisor-BhcXPxAk.js} +180 -95
- package/dist/supervisor-BhcXPxAk.js.map +1 -0
- package/dist/{supervisor-accounting-Ow6CChpB.js → supervisor-accounting-BB22j3hu.js} +46 -31
- package/dist/supervisor-accounting-BB22j3hu.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +12 -12
- package/dist/{top-web-BuYMkJN4.js → top-web-DsFGyUlS.js} +5 -5
- package/dist/{top-web-BuYMkJN4.js.map → top-web-DsFGyUlS.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-C_qbnw9N.d.ts → types-CwGD-823.d.ts} +43 -32
- package/dist/viewer/styles.css +29 -237
- package/dist/viewer/workspace-viewer.js +2 -2
- package/package.json +11 -11
- package/dist/coordination-manager-DAGPerJy.js.map +0 -1
- package/dist/graph-pFTeNZ-G.js.map +0 -1
- package/dist/runtime-CuwHe8_K.js.map +0 -1
- package/dist/structural-rollout-CqxBKxKY.js.map +0 -1
- package/dist/supervise-Cdqj_oe4.js.map +0 -1
- package/dist/supervisor-D-eT-6Tu.js.map +0 -1
- package/dist/supervisor-accounting-Ow6CChpB.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $
|
|
1
|
+
import { $r as assertEventBinding, $t as loadSpawnForest, Ar as newExecutionAttemptId, Bt as scopeRetainedOwnerSettled, Dr as inheritRuntimeOwnedExecutorAttestation, Er as finalizeRuntimeOwnedPendingExecutor, Fr as recordRuntimeOwnedProviderIdentityConflict, G as appendSpawnEvents, Gr as unknownMaterializationReceipt, Hr as runtimeOwnedScopeOwnerControl, In as mergeTraceEnv, Ir as recordRuntimeOwnedProviderModel, J as reenteredWorkers, Jt as bindScopeRetainedOwnerProvider, Kr as executableAgentProfileSnapshot, Kt as scopeRetainedOwnerCheckpointing, L as nestedScopeSeamKey, M as prepareScopeResume, Mn as WORKER_TRACE_PROPAGATION, Nn as workerTraceEnv, Nr as recordRuntimeOwnedProviderAttemptStart, Or as knownExecutionBindingReceipt, Pn as workerTraceHeaders, Pr as recordRuntimeOwnedProviderDispatchNotStarted, Qn as captureHarnessTranscript, Qr as RetainedRunProviderContractError, Rr as runtimeOwnedExecutorExecutionBinding, Sr as attestRuntimeOwnedPendingExecutor, Ur as runtimeOwnedScopeOwnerRuntime, Wr as unknownExecutionBindingReceipt, X as assertRecursiveReservationPolicy, Xn as HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS, Xt as scopeOwnerLiabilities, Yt as owners, _n as mintRetainedIdentity, _t as waitForScopeChildren, ai as RunCancellationReason, bn as startRetainedRun, br as attestRuntimeOwnedDeferredExecutor, ci as runAbortable, di as promptOptionsFromAgentTurnInput, dn as observeModelRequest, dt as releaseHeldEnvironments, ei as awaitAbortable, en as ownedTreeRootSpawn, er as harnessTranscriptFromLines, fn as describeRetainedNativeStops, fr as isLiveNodeStatus, ft as releaseRetainedEnvironments, gn as assertRetainedRunReplayMaterial, gt as unconfirmedTeardowns, hn as RetainedMaterializationTimeoutError, ht as startScopeRecoveries, ii as sameControlCoordinates, in as nestedDriverTreeRoot, j as resolveWorkerSlots, jn as environmentGone, kr as knownMaterializationReceipt, kt as finalizeScopeOwnerMaterialization, ln as executorObservation, lr as createActivityLog, mn as verifyWorkspaceMarker, mt as settleManagerWork, n as terminalAccounting, ni as freezeControlRef, nn as attestNestedDriverTreeOwner, nt as closeScopeAdmission, oi as abortReason, on as encodeResultBlob, pn as stopRetainedNativeExecution, pt as retryUnconfirmedTeardowns, q as appendTeardownConfirmation, qr as executableAgentSpecSnapshot, r as createScope, ri as retainedSessionReplaced, rn as driverRuntime, rt as hasRetriableTeardowns, si as linkAbort, sn as SpawnEventIndex, t as isNonEmptySpend, ti as exactSession, tr as harnessTranscriptUnavailable, tt as closeRetainedSlots, ur as describeToolArgs, ut as registerNestedTeardownScope, vn as reconnectRetainedRun, xr as attestRuntimeOwnedExecutor, yn as recoverRetainedRun, yr as subscriptionUsageLimitSignal, zr as runtimeOwnedExecutorMaterialization } from "./supervisor-accounting-BB22j3hu.js";
|
|
2
2
|
import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError$1, r as BackendTransportError, t as AgentEvalError } from "./errors-DG8yufqX.js";
|
|
3
3
|
import { C as unreportedSpend, D as addResourceSpend, E as zeroTokenUsage, F as ROOT_DEADLINE_REASON, H as teardownSurfaces, I as armDeadlineTimer, S as unmeteredSpend, T as zeroSpend, _ as roundBoxMinutes, b as throwAbort, c as errorMessage, d as isAbortError, f as isAsyncIterable, g as randomUuid, h as randomSuffix, j as ACCEPTED_RESULT_GRACE_MS, m as promptCacheTokenClasses, n as addSpend, o as cloneTokenUsage, p as mapWithConcurrency, r as addTokenUsage, s as deleteBoxSafe, v as sleep, w as withTimeout, x as throwIfAborted, y as stringifySafe, z as isDeadlineAbortReason } from "./util-fcckrkKp.js";
|
|
4
4
|
import { t as runTaskQueue } from "./task-queue-DbpZAp6C.js";
|
|
@@ -8,7 +8,7 @@ import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutio
|
|
|
8
8
|
import { r as nativeSystemPrompt, t as assertSandboxProfileCompatibility } from "./sandbox-profile-compat-l-SLQnGb.js";
|
|
9
9
|
import { l as sha256 } from "./jsonl-file-DsxVI0E_.js";
|
|
10
10
|
import { V as hasControlCharacter } from "./workspace-streams-DA9R3j-p.js";
|
|
11
|
-
import { i as checkVerdictOf, s as isFiniteNumber } from "./continuation-
|
|
11
|
+
import { i as checkVerdictOf, s as isFiniteNumber } from "./continuation-DDPfLw2w.js";
|
|
12
12
|
import { a as writeAtomicDurableFile, s as fenceRunWrite } from "./durable-file-DstVeHcj.js";
|
|
13
13
|
import { t as PROTOCOL_VERSION } from "./tool-server-DYwRbi0I.js";
|
|
14
14
|
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-CsW2pfFk.js";
|
|
@@ -6959,14 +6959,8 @@ function createInPlaceCliExecutor(options) {
|
|
|
6959
6959
|
});
|
|
6960
6960
|
const result = await running;
|
|
6961
6961
|
const spent = {
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
input: 0,
|
|
6965
|
-
output: 0
|
|
6966
|
-
},
|
|
6967
|
-
tokensKnown: false,
|
|
6968
|
-
usd: 0,
|
|
6969
|
-
ms: Date.now() - started
|
|
6962
|
+
...unmeteredSpend(Date.now() - started),
|
|
6963
|
+
iterations: 1
|
|
6970
6964
|
};
|
|
6971
6965
|
const exit = result.harness;
|
|
6972
6966
|
const failed = exit.exitCode !== 0 || exit.timedOut;
|
|
@@ -7145,7 +7139,7 @@ function createWorktreeCliExecutor(options) {
|
|
|
7145
7139
|
},
|
|
7146
7140
|
...usage ? {} : { tokensKnown: false },
|
|
7147
7141
|
usd: 0,
|
|
7148
|
-
|
|
7142
|
+
usdKnown: false,
|
|
7149
7143
|
ms: Date.now() - started
|
|
7150
7144
|
};
|
|
7151
7145
|
artifact = {
|
|
@@ -7498,13 +7492,6 @@ async function captureBeforeDestroy(scope, target, signal) {
|
|
|
7498
7492
|
if (capture.status === "captured") state.harnessTranscript = capture;
|
|
7499
7493
|
}
|
|
7500
7494
|
}
|
|
7501
|
-
// src/runtime/environment-provider/provider-validation-error.ts
|
|
7502
|
-
var ValidationError = class extends Error {
|
|
7503
|
-
constructor(message, options) {
|
|
7504
|
-
super(message, options);
|
|
7505
|
-
this.name = "ValidationError";
|
|
7506
|
-
}
|
|
7507
|
-
};
|
|
7508
7495
|
// src/runtime/environment-provider/provider-event-projection.ts
|
|
7509
7496
|
function sandboxEventFromEnvironmentEvent(event) {
|
|
7510
7497
|
const normalized = event.normalized;
|
|
@@ -7751,28 +7738,41 @@ function resultFromEvents(events, fallbackText) {
|
|
|
7751
7738
|
events
|
|
7752
7739
|
};
|
|
7753
7740
|
}
|
|
7754
|
-
/**
|
|
7741
|
+
/** A non-JSON final message settles the fenced block ending it; trailing text keeps it refused. */
|
|
7742
|
+
function finalJsonValue(text) {
|
|
7743
|
+
if (text === void 0) return "";
|
|
7744
|
+
try {
|
|
7745
|
+
JSON.parse(text);
|
|
7746
|
+
return text;
|
|
7747
|
+
} catch {}
|
|
7748
|
+
return /```(?:json)?[ \t]*\r?\n((?:(?!```)[\s\S])*)```\s*$/i.exec(text)?.[1] ?? text;
|
|
7749
|
+
}
|
|
7750
|
+
/** Decode only the final assistant message, keeping the stream as evidence. A stream not wholly
|
|
7751
|
+
* read is refused, not left pending: no later read completes an ended turn's stream. */
|
|
7755
7752
|
function jsonResultFromEvents(events) {
|
|
7756
|
-
if (events.some((event) => event.type === "result" && event.data.eventStreamComplete === false))
|
|
7753
|
+
if (events.some((event) => event.type === "result" && event.data.eventStreamComplete === false)) return refusedJson("complete native event observation is required");
|
|
7757
7754
|
const projected = events.map(sandboxEventFromEnvironmentEvent);
|
|
7758
7755
|
const text = collectAgentFinalMessageText(projected) ?? (projected.some(isToolBearingEvent) ? void 0 : collectAgentResponseText(projected));
|
|
7759
7756
|
try {
|
|
7760
|
-
return { out: JSON.parse(text
|
|
7757
|
+
return { out: JSON.parse(finalJsonValue(text), (_key, value) => {
|
|
7761
7758
|
if (typeof value === "number" && !Number.isFinite(value)) throw new SyntaxError("JSON number is not finite");
|
|
7762
7759
|
return value;
|
|
7763
7760
|
}) };
|
|
7764
7761
|
} catch (error) {
|
|
7765
7762
|
if (!(error instanceof SyntaxError)) throw error;
|
|
7766
|
-
return {
|
|
7767
|
-
out: null,
|
|
7768
|
-
outcome: {
|
|
7769
|
-
success: false,
|
|
7770
|
-
error: `provider JSON output: ${text === void 0 ? "missing final assistant message" : "invalid final assistant JSON"}; return only a JSON value after tool use`,
|
|
7771
|
-
errorCode: "RUNTIME_OUTPUT_FORMAT_INVALID"
|
|
7772
|
-
}
|
|
7773
|
-
};
|
|
7763
|
+
return refusedJson(`${text === void 0 ? "missing final assistant message" : "invalid final assistant JSON"}; return only a JSON value after tool use`);
|
|
7774
7764
|
}
|
|
7775
7765
|
}
|
|
7766
|
+
function refusedJson(reason) {
|
|
7767
|
+
return {
|
|
7768
|
+
out: null,
|
|
7769
|
+
outcome: {
|
|
7770
|
+
success: false,
|
|
7771
|
+
error: `provider JSON output: ${reason}`,
|
|
7772
|
+
errorCode: "RUNTIME_OUTPUT_FORMAT_INVALID"
|
|
7773
|
+
}
|
|
7774
|
+
};
|
|
7775
|
+
}
|
|
7776
7776
|
function textFromEnvironmentEvent(event) {
|
|
7777
7777
|
if (event.normalized?.type === "message.part.updated") return typeof event.normalized.delta === "string" ? event.normalized.delta : "";
|
|
7778
7778
|
const data = event.data;
|
|
@@ -8120,6 +8120,13 @@ var RetainedObservation = class {
|
|
|
8120
8120
|
}
|
|
8121
8121
|
}
|
|
8122
8122
|
};
|
|
8123
|
+
// src/runtime/environment-provider/provider-validation-error.ts
|
|
8124
|
+
var ValidationError = class extends Error {
|
|
8125
|
+
constructor(message, options) {
|
|
8126
|
+
super(message, options);
|
|
8127
|
+
this.name = "ValidationError";
|
|
8128
|
+
}
|
|
8129
|
+
};
|
|
8123
8130
|
// src/runtime/environment-provider/provider-turn-input.ts
|
|
8124
8131
|
/**
|
|
8125
8132
|
* Lower the seam's prompt options onto turn fields, through the one mapper this module already
|
|
@@ -14985,9 +14992,11 @@ var RunParkedError = class extends Error {
|
|
|
14985
14992
|
}
|
|
14986
14993
|
};
|
|
14987
14994
|
const DEFAULT_PARK_AFTER_MS = 6e4;
|
|
14995
|
+
/** A seat reset nearer than this is slept through in place; requeueing costs more than it frees. */
|
|
14996
|
+
const SEAT_PARK_MIN_MS = 3e5;
|
|
14988
14997
|
const parkingContext = new AsyncLocalStorage();
|
|
14989
14998
|
const parkingDrains = /* @__PURE__ */ new WeakMap();
|
|
14990
|
-
/** Drain committed child work through the existing manager ledger before testing
|
|
14999
|
+
/** Drain committed child work through the existing manager ledger before testing idleness. */
|
|
14991
15000
|
function bindScopeParkingDrain(scope, drain, idle) {
|
|
14992
15001
|
parkingDrains.set(scope, {
|
|
14993
15002
|
drain,
|
|
@@ -14997,96 +15006,168 @@ function bindScopeParkingDrain(scope, drain, idle) {
|
|
|
14997
15006
|
/** Validate at intake, before any execution or ownership acquisition. */
|
|
14998
15007
|
function assertRunParking(policy, durable) {
|
|
14999
15008
|
if (policy === void 0) return;
|
|
15000
|
-
if (!durable) throw new ValidationError$1("supervise: parking requires runDir");
|
|
15009
|
+
if (!durable) throw new ValidationError$1("supervise: parking requires runDir or a SQL runContext");
|
|
15001
15010
|
if (policy === null || typeof policy !== "object" || policy.afterMs !== void 0 && (!Number.isFinite(policy.afterMs) || policy.afterMs < 0)) throw new ValidationError$1("supervise: parking.afterMs must be a nonnegative finite number");
|
|
15002
15011
|
}
|
|
15003
|
-
/**
|
|
15012
|
+
/** Whether this error is the current run's own park, which every scope of the run propagates. */
|
|
15013
|
+
function isRunParked(error, scope) {
|
|
15014
|
+
return error instanceof RunParkedError && (error.runId === scope.view.root || error.runId === parkingContext.getStore()?.runId);
|
|
15015
|
+
}
|
|
15016
|
+
/**
|
|
15017
|
+
* Scope the handoff to one execution, preserving the original wake time on an early re-entry.
|
|
15018
|
+
* The journal's `run-parked` event is the durable record; `parking.json` is its runDir projection.
|
|
15019
|
+
*/
|
|
15004
15020
|
async function withRunParking(policy, runDir, runId, journal, now, signal, run) {
|
|
15005
|
-
if (policy === void 0
|
|
15021
|
+
if (policy === void 0) return parkingContext.exit(run);
|
|
15006
15022
|
const events = await journal.loadTree(runId) ?? [];
|
|
15007
15023
|
const previous = [...events].reverse().find((event) => event.kind === "run-parked");
|
|
15008
15024
|
const transition = [...events].reverse().find((event) => event.id === runId && (event.kind === "run-parked" || event.kind === "root-reentered" || event.kind === "reopened"));
|
|
15009
15025
|
const current = transition?.kind === "run-parked" ? transition : void 0;
|
|
15010
15026
|
if (current !== void 0 && Date.parse(current.wakeAt) > now() && !signal?.aborted) {
|
|
15011
|
-
await writeParkingProjection(runDir, runId, current);
|
|
15027
|
+
if (runDir !== void 0) await writeParkingProjection(runDir, runId, current);
|
|
15012
15028
|
throw new RunParkedError(runId, parkingRecordOf(current));
|
|
15013
15029
|
}
|
|
15014
|
-
if (previous !== void 0) await
|
|
15015
|
-
|
|
15016
|
-
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
|
|
15030
|
+
if (previous !== void 0 && runDir !== void 0) await writeParkingProjection(runDir, runId, previous, now());
|
|
15031
|
+
let park;
|
|
15032
|
+
const parked = new Promise((_, reject) => {
|
|
15033
|
+
park = reject;
|
|
15034
|
+
});
|
|
15035
|
+
parked.catch(() => void 0);
|
|
15020
15036
|
return parkingContext.run({
|
|
15021
15037
|
runDir,
|
|
15022
15038
|
runId,
|
|
15023
15039
|
journal,
|
|
15024
15040
|
now,
|
|
15025
|
-
afterMs: policy.afterMs ?? DEFAULT_PARK_AFTER_MS
|
|
15041
|
+
afterMs: policy.afterMs ?? DEFAULT_PARK_AFTER_MS,
|
|
15042
|
+
waits: /* @__PURE__ */ new Map(),
|
|
15043
|
+
parked,
|
|
15044
|
+
park,
|
|
15045
|
+
handingOff: false
|
|
15026
15046
|
}, run);
|
|
15027
15047
|
}
|
|
15048
|
+
/** Run the root execution so a park decided by any of the run's waits rejects it at once. */
|
|
15049
|
+
function raceRunParking(runId, scope, seal, run) {
|
|
15050
|
+
const context = parkingContext.getStore();
|
|
15051
|
+
if (context === void 0 || context.runId !== runId) return run();
|
|
15052
|
+
context.root = {
|
|
15053
|
+
scope,
|
|
15054
|
+
seal
|
|
15055
|
+
};
|
|
15056
|
+
const running = run();
|
|
15057
|
+
running.catch(() => void 0);
|
|
15058
|
+
return Promise.race([running, context.parked]);
|
|
15059
|
+
}
|
|
15028
15060
|
/**
|
|
15029
|
-
* Sleep through the existing wait path.
|
|
15030
|
-
*
|
|
15031
|
-
*
|
|
15061
|
+
* Sleep through the existing wait path. The run may hand off once every live node is waiting
|
|
15062
|
+
* here: the root on its own wait, any node on a seat reset at least SEAT_PARK_MIN_MS away. A run
|
|
15063
|
+
* with other active work keeps its normal wait. No timer survives the handoff, and no provider
|
|
15064
|
+
* work is cancelled or terminal settlement written for parking.
|
|
15032
15065
|
*/
|
|
15033
15066
|
async function sleepScopeWait(scope, ms, signal, reason) {
|
|
15034
15067
|
if (ms <= 0 || signal.aborted) return;
|
|
15035
15068
|
const context = parkingContext.getStore();
|
|
15036
|
-
const
|
|
15037
|
-
if (context === void 0 ||
|
|
15069
|
+
const node = scope.view.root;
|
|
15070
|
+
if (context === void 0 || node !== context.runId && reason !== "seat-wait") return sleep(ms, signal, false);
|
|
15071
|
+
const floor = reason === "seat-wait" ? Math.max(context.afterMs, SEAT_PARK_MIN_MS) : context.afterMs;
|
|
15038
15072
|
const since = context.now();
|
|
15039
|
-
const deadline = scope.
|
|
15040
|
-
const wakeAt = Math.min(since + ms, deadline
|
|
15041
|
-
if (wakeAt - since <=
|
|
15042
|
-
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
|
|
15046
|
-
|
|
15047
|
-
|
|
15048
|
-
|
|
15049
|
-
|
|
15050
|
-
|
|
15051
|
-
|
|
15052
|
-
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
15056
|
-
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
|
|
15065
|
-
idleSince
|
|
15066
|
-
|
|
15073
|
+
const deadline = Math.min(deadlineOf(scope), context.root ? deadlineOf(context.root.scope) : Number.POSITIVE_INFINITY);
|
|
15074
|
+
const wakeAt = Math.min(since + ms, deadline);
|
|
15075
|
+
if (wakeAt - since <= floor) return sleep(ms, signal, false);
|
|
15076
|
+
context.waits.set(node, {
|
|
15077
|
+
scope,
|
|
15078
|
+
wakeAt,
|
|
15079
|
+
floor,
|
|
15080
|
+
reason: wakeAt === deadline && wakeAt < since + ms ? "deadline" : reason
|
|
15081
|
+
});
|
|
15082
|
+
try {
|
|
15083
|
+
let idleSince = runIdle(context) ? since : void 0;
|
|
15084
|
+
for (;;) {
|
|
15085
|
+
const remaining = Math.max(0, wakeAt - context.now());
|
|
15086
|
+
if (remaining <= floor) return await Promise.race([sleep(remaining, signal, false), context.parked]);
|
|
15087
|
+
const checkMs = context.afterMs || (idleSince === void 0 ? DEFAULT_PARK_AFTER_MS : 0);
|
|
15088
|
+
await Promise.race([sleep(Math.min(checkMs, remaining), signal, false), context.parked]);
|
|
15089
|
+
if (signal.aborted) return;
|
|
15090
|
+
for (const held of heldScopes(context)) await parkingDrains.get(held)?.drain();
|
|
15091
|
+
if (!runIdle(context)) {
|
|
15092
|
+
idleSince = void 0;
|
|
15093
|
+
continue;
|
|
15094
|
+
}
|
|
15095
|
+
if (idleSince === void 0) {
|
|
15096
|
+
idleSince = context.now();
|
|
15097
|
+
continue;
|
|
15098
|
+
}
|
|
15099
|
+
if (context.now() - idleSince < context.afterMs) continue;
|
|
15100
|
+
const events = await context.journal.loadTree(context.runId) ?? [];
|
|
15101
|
+
if (signal.aborted) return;
|
|
15102
|
+
if (await invocationUnresolved(context, events) || !runIdle(context)) {
|
|
15103
|
+
idleSince = void 0;
|
|
15104
|
+
continue;
|
|
15105
|
+
}
|
|
15106
|
+
const at = context.now();
|
|
15107
|
+
const waits = [...context.waits.values()];
|
|
15108
|
+
if (waits.some((wait) => wait.wakeAt - at <= wait.floor)) continue;
|
|
15109
|
+
await parkRun(context, waits, idleSince, events);
|
|
15067
15110
|
}
|
|
15068
|
-
|
|
15069
|
-
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
|
|
15078
|
-
|
|
15079
|
-
|
|
15080
|
-
|
|
15081
|
-
|
|
15082
|
-
|
|
15111
|
+
} finally {
|
|
15112
|
+
context.waits.delete(node);
|
|
15113
|
+
}
|
|
15114
|
+
}
|
|
15115
|
+
async function parkRun(context, waits, idleSince, events) {
|
|
15116
|
+
if (context.handingOff) return context.parked;
|
|
15117
|
+
context.handingOff = true;
|
|
15118
|
+
const root = context.root;
|
|
15119
|
+
const earliest = waits.reduce((first, wait) => wait.wakeAt < first.wakeAt ? wait : first);
|
|
15120
|
+
const parking = {
|
|
15121
|
+
reason: earliest.reason,
|
|
15122
|
+
since: new Date(idleSince).toISOString(),
|
|
15123
|
+
wakeAt: new Date(earliest.wakeAt).toISOString()
|
|
15124
|
+
};
|
|
15125
|
+
for (const held of heldScopes(context)) closeScopeAdmission(held);
|
|
15126
|
+
await context.journal.appendEvent(context.runId, {
|
|
15127
|
+
kind: "run-parked",
|
|
15128
|
+
id: context.runId,
|
|
15129
|
+
...parking,
|
|
15130
|
+
seq: events.filter((event) => event.kind === "run-parked").length,
|
|
15131
|
+
at: new Date(context.now()).toISOString()
|
|
15132
|
+
});
|
|
15133
|
+
if (context.runDir !== void 0) await writeParkingProjection(context.runDir, context.runId, parking);
|
|
15134
|
+
const error = new RunParkedError(context.runId, parking);
|
|
15135
|
+
if (waits.some((wait) => wait.scope !== root.scope)) root.seal(error);
|
|
15136
|
+
context.park(error);
|
|
15137
|
+
throw error;
|
|
15138
|
+
}
|
|
15139
|
+
function heldScopes(context) {
|
|
15140
|
+
const scopes = new Set([...context.waits.values()].map((wait) => wait.scope));
|
|
15141
|
+
if (context.root) scopes.add(context.root.scope);
|
|
15142
|
+
return [...scopes];
|
|
15143
|
+
}
|
|
15144
|
+
/** Every live node is in a parkable wait, and no scope holds open work or unconfirmed capacity. */
|
|
15145
|
+
function runIdle(context) {
|
|
15146
|
+
const root = context.root;
|
|
15147
|
+
if (root === void 0) return false;
|
|
15148
|
+
if (heldScopes(context).some((held) => parkingDrains.get(held)?.idle() === false || held.workerCapacity.unconfirmed.length > 0)) return false;
|
|
15149
|
+
return !(root.scope.observeTree?.() ?? root.scope.view).nodes.some((node) => node.id !== context.runId && isLiveNodeStatus(node.status) && !context.waits.has(node.id));
|
|
15150
|
+
}
|
|
15151
|
+
/** The owners' own receipts decide: an admitted invocation without its result may still compute. */
|
|
15152
|
+
async function invocationUnresolved(context, rootEvents) {
|
|
15153
|
+
for (const held of heldScopes(context)) {
|
|
15154
|
+
const rootId = owners.get(held)?.args.rootId;
|
|
15155
|
+
if (rootId === void 0) continue;
|
|
15156
|
+
const events = rootId === context.runId ? rootEvents : await context.journal.loadTree(rootId);
|
|
15157
|
+
if (scopeOwnerLiabilities(held, events ?? []).invocationUnsettled) return true;
|
|
15083
15158
|
}
|
|
15159
|
+
return false;
|
|
15160
|
+
}
|
|
15161
|
+
function deadlineOf(scope) {
|
|
15162
|
+
const deadline = scope.budget.deadlineMs;
|
|
15163
|
+
return deadline > 0 ? deadline : Number.POSITIVE_INFINITY;
|
|
15084
15164
|
}
|
|
15085
|
-
async function writeParkingProjection(runDir, runId, parking) {
|
|
15165
|
+
async function writeParkingProjection(runDir, runId, parking, resumedAt) {
|
|
15086
15166
|
await writeAtomicDurableFile(resolve(runDir, "parking.json"), JSON.stringify({
|
|
15087
|
-
status: "parked",
|
|
15167
|
+
status: resumedAt === void 0 ? "parked" : "resuming",
|
|
15088
15168
|
runId,
|
|
15089
|
-
...parkingRecordOf(parking)
|
|
15169
|
+
...parkingRecordOf(parking),
|
|
15170
|
+
...resumedAt === void 0 ? {} : { resumedAt: new Date(resumedAt).toISOString() }
|
|
15090
15171
|
}));
|
|
15091
15172
|
}
|
|
15092
15173
|
function parkingRecordOf(record) {
|
|
@@ -15524,6 +15605,10 @@ function guardRunPersistence(journal, blobs, interrupt) {
|
|
|
15524
15605
|
},
|
|
15525
15606
|
assertAvailable() {
|
|
15526
15607
|
if (failure !== void 0) throw failure;
|
|
15608
|
+
},
|
|
15609
|
+
/** Refuse every later write with `error`, without interrupting the retained executions. */
|
|
15610
|
+
seal(error) {
|
|
15611
|
+
failure ??= error;
|
|
15527
15612
|
}
|
|
15528
15613
|
};
|
|
15529
15614
|
}
|
|
@@ -16003,7 +16088,7 @@ async function executeRoot(root) {
|
|
|
16003
16088
|
ok: true,
|
|
16004
16089
|
out: await runAbortable(() => {
|
|
16005
16090
|
rootStarted = true;
|
|
16006
|
-
return root.run
|
|
16091
|
+
return raceRunParking(opts.runId, scope, persistence.seal, root.run);
|
|
16007
16092
|
}, controller.signal, "supervisor aborted")
|
|
16008
16093
|
};
|
|
16009
16094
|
} catch (error) {
|
|
@@ -16136,6 +16221,6 @@ async function noWinner(settled, rejection) {
|
|
|
16136
16221
|
reason: "no-result-selected"
|
|
16137
16222
|
};
|
|
16138
16223
|
}
|
|
16139
|
-
export {
|
|
16224
|
+
export { AUTHORITY_MARKERS as $, readSandboxOutcome as $t, readPromptOptions as A, createPushTraceSource as At, toolResultText as B, assertProfileMaterializes as Bt, captureReusableExecutorConfig as C, bridgeModelRouteRefusal as Ct, createSteerableSandboxSession as D, createCodexRolloutStoreReader as Dt, DEFAULT_SANDBOX_STEERING_MAX_TURNS as E, addHarnessUsage as Et, defaultSelectWinner as F, runWorktreeHarness as Ft, providerAsExecutor as G, promptControlProfileMaterialization as Gt, routerBrain as H, defineProfileMaterializationContract as Ht, codeModeArguments as I, LOCAL_HARNESSES as It, createWorktreeCliExecutor as J, sandboxActProfileMaterialization as Jt, LEAF_CONTINUATION_TASK as K, promptModelProfileMaterialization as Kt, codeModeModelOutput as L, harnessInvocation as Lt, createSandboxLineage as M, bridgeStopSignalKey as Mt, acquireSandbox as N, defaultRunCommand as Nt, runAgentRounds as O, harnessUsageIsEmpty as Ot, TERMINAL_DECISIONS as P, runSettledCommand as Pt, failPendingAfter as Q, projectSandboxOutcome as Qt, createCodeModeTools as R, terminateProcessTreeAndConfirm as Rt, bindReusableExecutorExecutionId as S, bridgeAdmissionRefusal as St, snapshotExecutorConfig as T, ROUTER_PRICE_SOURCE as Tt, createAgentEnvironmentProviderRegistry as U, fullProfileMaterialization as Ut, createRouterTranscript as V, controlProfileMaterialization as Vt, resolveAgentEnvironmentProvider as W, profileMaterializationAxes$1 as Wt, INBOX_RECEIPT_KEY as X, unsupportedProfileDimensions as Xt, createInPlaceCliExecutor as Y, sandboxProfileMaterialization as Yt, createInbox as Z, worktreeCliProfileMaterialization as Zt, isDriverSpec as _, CheckUnavailableError as _t, assertRunParking as a, peerMailTools as at, InMemorySpawnJournal as b, mapExecutorResult as bt, readRunParking as c, DriverAttemptsExhaustedError as ct, bestDelivered as d, classifyDriverFailure as dt, DEFAULT_PEER_MAIL_LIMITS as et, runFinalizer as f, summarizeDriverAttempts as ft, driverExecutorFactory as g, preflightPublicCoordination as gt, driverChild as h, upstreamUnavailableSignal as ht, RunParkedError as i, isPeerMailEnvelope as it, createSandboxForSpec as j, bridgeRuntimeAttachmentsKey as jt, assertBoxlessPromptOptions as k, readCodexRolloutSession as kt, sleepScopeWait as l, HarnessTurnFailedError as lt, createRootHandle as m, undispatchedCredentialExit as mt, createSupervisor as n, claimsAuthority as nt, bindScopeParkingDrain as o, peerMailVerbNames as ot, runTree as p, transientFailureKind as pt, providerAsSandboxClient as q, renderUnsupported as qt, assertResumeLimits as r, createPeerMailbox as rt, isRunParked as s, taskToPrompt$1 as st, DEFAULT_MAX_DEPTH as t, PEER_MAIL_WIRE_KEY as tt, withRunParking as u, abandonablePending as ut, withDriverExecutor as v, gateFactoryOnDeliverable as vt, createExecutor as w, priceTokens as wt, createExecutorRegistry as x, verdictFromJudgeScore as xt, InMemoryResultBlobStore as y, gateOnDeliverable as yt, runCodeMode as z, assertProfileMaterialization as zt };
|
|
16140
16225
|
|
|
16141
|
-
//# sourceMappingURL=supervisor-
|
|
16226
|
+
//# sourceMappingURL=supervisor-BhcXPxAk.js.map
|