@tangle-network/agent-runtime 0.348.1 → 0.350.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{activation-BEGalhOL.js → activation-CfJMyzEs.js} +12 -14
- package/dist/{activation-BEGalhOL.js.map → activation-CfJMyzEs.js.map} +1 -1
- package/dist/{activation-NQZP_mdI.d.ts → activation-DyiHrTlS.d.ts} +2 -24
- package/dist/agent.d.ts +8 -12
- package/dist/agent.js +9 -12
- package/dist/agent.js.map +1 -1
- package/dist/{analyst-loop-DZw5QWT9.js → analyst-loop-BZvXCDKy.js} +2 -3
- package/dist/{analyst-loop-DZw5QWT9.js.map → analyst-loop-BZvXCDKy.js.map} +1 -1
- package/dist/analyst-loop.d.ts +3 -5
- package/dist/analyst-loop.js +1 -2
- package/dist/{bundle-DKQtOO9d.js → bundle-Ze8pd07a.js} +3 -4
- package/dist/{bundle-DKQtOO9d.js.map → bundle-Ze8pd07a.js.map} +1 -1
- package/dist/candidate-execution/index.d.ts +13 -33
- package/dist/candidate-execution/index.js +16 -18
- package/dist/candidate-execution/index.js.map +1 -1
- package/dist/{coordination-manager-Bm6leXc6.js → coordination-manager-BkVfWlMz.js} +101 -132
- package/dist/coordination-manager-BkVfWlMz.js.map +1 -0
- package/dist/{delegate-Cp5-PsaX.js → delegate-DgEie4ad.js} +19 -21
- package/dist/delegate-DgEie4ad.js.map +1 -0
- package/dist/durable.d.ts +13 -23
- package/dist/durable.js +48 -43
- package/dist/durable.js.map +1 -1
- package/dist/{errors-DodWX-cb.js → errors-wuhGvpE3.js} +2 -3
- package/dist/{errors-DodWX-cb.js.map → errors-wuhGvpE3.js.map} +1 -1
- package/dist/{graph-CE_pzU31.js → graph-Cx0FhKSE.js} +192 -15
- package/dist/graph-Cx0FhKSE.js.map +1 -0
- package/dist/{improve-wT11zteg.js → improve-i0HU1-aa.js} +35 -53
- package/dist/{improve-wT11zteg.js.map → improve-i0HU1-aa.js.map} +1 -1
- package/dist/{improvement-adapter-sIthWkcN.d.ts → improvement-adapter-D5GRU1eY.d.ts} +2 -6
- package/dist/index.d.ts +41 -89
- package/dist/index.js +43 -61
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +39 -59
- package/dist/intelligence.js +23 -33
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +5 -5
- package/dist/kernel.js +11 -11
- package/dist/{loop-runner-CZzeeJTG.js → loop-runner-BwN9MhdP.js} +5 -6
- package/dist/{loop-runner-CZzeeJTG.js.map → loop-runner-BwN9MhdP.js.map} +1 -1
- package/dist/{loop-runner-CY5HHhtR.d.ts → loop-runner-DvfOXVx9.d.ts} +3 -5
- package/dist/loop-runner-bin.d.ts +5 -8
- package/dist/loop-runner-bin.js +2 -3
- package/dist/mcp/bin.js +6 -8
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +8 -18
- package/dist/mcp/index.js +17 -25
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-bin.js +4 -6
- package/dist/mcp/memory-bin.js.map +1 -1
- package/dist/{model-policy-CyCUwHed.js → model-policy-GSxWwP-b.js} +11 -13
- package/dist/model-policy-GSxWwP-b.js.map +1 -0
- package/dist/placement.d.ts +12 -14
- package/dist/placement.js +1 -2
- package/dist/platform.d.ts +7 -13
- package/dist/platform.js +3 -6
- package/dist/platform.js.map +1 -1
- package/dist/{prepare-TEEHSJwq.js → prepare-DE8TQnLu.js} +49 -69
- package/dist/{prepare-TEEHSJwq.js.map → prepare-DE8TQnLu.js.map} +1 -1
- package/dist/{profile-6OLpbjvV.js → profile-CAhZDW2T.js} +58 -92
- package/dist/profile-CAhZDW2T.js.map +1 -0
- package/dist/{profile-materialization-bPm0gGLO.d.ts → profile-materialization-BRY22Oh8.d.ts} +1 -3
- package/dist/profiles.d.ts +25 -12
- package/dist/profiles.js +52 -11
- package/dist/profiles.js.map +1 -1
- package/dist/{protected-model-port-DVVh-hEk.d.ts → protected-model-port-IKqhTypD.d.ts} +2 -14
- package/dist/{protected-redaction-DFCeo4vg.js → protected-redaction-DilFZch5.js} +2 -3
- package/dist/{protected-redaction-DFCeo4vg.js.map → protected-redaction-DilFZch5.js.map} +1 -1
- package/dist/{provision-supervisor-CC0HdOHo.js → provision-supervisor-Bde_FF0R.js} +11 -15
- package/dist/{provision-supervisor-CC0HdOHo.js.map → provision-supervisor-Bde_FF0R.js.map} +1 -1
- package/dist/{record-events-D93DkpAx.js → record-events-B2GUgYdz.js} +12 -14
- package/dist/{record-events-D93DkpAx.js.map → record-events-B2GUgYdz.js.map} +1 -1
- package/dist/{run-cancellation-CzFhQGMa.js → run-cancellation-BLy_Zz-w.js} +6 -7
- package/dist/{run-cancellation-CzFhQGMa.js.map → run-cancellation-BLy_Zz-w.js.map} +1 -1
- package/dist/{runtime-B_40dXlF.js → runtime-6Ec9sHRe.js} +833 -215
- package/dist/runtime-6Ec9sHRe.js.map +1 -0
- package/dist/{runtime-hooks-tXpAarhW.js → runtime-hooks-CsW2pfFk.js} +2 -3
- package/dist/{runtime-hooks-tXpAarhW.js.map → runtime-hooks-CsW2pfFk.js.map} +1 -1
- package/dist/{runtime-hooks-nsqxSUFL.d.ts → runtime-hooks-ZQqPw-0g.d.ts} +1 -3
- package/dist/{sandbox-profile-compat-_fEtHPCj.js → sandbox-profile-compat-BxMQ1VXv.js} +62 -44
- package/dist/sandbox-profile-compat-BxMQ1VXv.js.map +1 -0
- package/dist/{search-executor-COd2F2wp.js → search-executor-B7g_5Wjl.js} +12 -17
- package/dist/search-executor-B7g_5Wjl.js.map +1 -0
- package/dist/{server-BGB4R4wQ.js → server-fvEMwGMQ.js} +19 -30
- package/dist/{server-BGB4R4wQ.js.map → server-fvEMwGMQ.js.map} +1 -1
- package/dist/{structural-rollout-Wl_rCuzM.js → structural-rollout-B86bSixU.js} +69 -70
- package/dist/structural-rollout-B86bSixU.js.map +1 -0
- package/dist/{substrate-CGDFTSRh.js → substrate-Db2pp6y3.js} +2 -3
- package/dist/{substrate-CGDFTSRh.js.map → substrate-Db2pp6y3.js.map} +1 -1
- package/dist/{supervise-BUOeThuB.js → supervise-CaeZcgAW.js} +615 -203
- package/dist/supervise-CaeZcgAW.js.map +1 -0
- package/dist/{supervisor-DDy0aEtR.js → supervisor-C1OePYE-.js} +526 -642
- package/dist/supervisor-C1OePYE-.js.map +1 -0
- package/dist/{task-queue-0fKkoweu.d.ts → task-queue-kefGy79U.d.ts} +1 -3
- package/dist/task-queue.d.ts +1 -1
- package/dist/task-queue.js +1 -2
- package/dist/testing.d.ts +8 -16
- package/dist/testing.js +241 -244
- package/dist/testing.js.map +1 -1
- package/dist/tool-loop.d.ts +16 -19
- package/dist/tool-loop.js +2 -3
- package/dist/{tool-server-XV4aJwoQ.js → tool-server-CwuYeW_Z.js} +3 -4
- package/dist/{tool-server-XV4aJwoQ.js.map → tool-server-CwuYeW_Z.js.map} +1 -1
- package/dist/{top-snapshot-CflmaDgk.js → top-snapshot-ChwpTr7A.js} +4 -5
- package/dist/{top-snapshot-CflmaDgk.js.map → top-snapshot-ChwpTr7A.js.map} +1 -1
- package/dist/tui/bin.js +7 -9
- package/dist/tui/bin.js.map +1 -1
- package/dist/tui/index.d.ts +3 -5
- package/dist/tui/index.js +2 -2
- package/dist/{types-hc4cmSc7.d.ts → types-Fowuwdz2.d.ts} +555 -503
- package/dist/{types-Cwrea-bU.d.ts → types-qsqfyQoY.d.ts} +1 -3
- package/dist/workspace-store/index.d.ts +12 -22
- package/dist/workspace-store/index.js +4 -7
- package/dist/workspace-store/index.js.map +1 -1
- package/dist/{workspace-streams-BiS4ABah.d.ts → workspace-streams-Dq2Fzk3c.d.ts} +1 -11
- package/package.json +25 -25
- package/skills/agent-graphs/SKILL.md +19 -4
- package/skills/be-ambitious/SKILL.md +46 -0
- package/skills/graph-designer/SKILL.md +15 -2
- package/skills/profile-authoring/SKILL.md +1 -1
- package/dist/coordination-manager-Bm6leXc6.js.map +0 -1
- package/dist/delegate-Cp5-PsaX.js.map +0 -1
- package/dist/graph-CE_pzU31.js.map +0 -1
- package/dist/model-policy-CyCUwHed.js.map +0 -1
- package/dist/profile-6OLpbjvV.js.map +0 -1
- package/dist/runtime-B_40dXlF.js.map +0 -1
- package/dist/sandbox-profile-compat-_fEtHPCj.js.map +0 -1
- package/dist/search-executor-COd2F2wp.js.map +0 -1
- package/dist/structural-rollout-Wl_rCuzM.js.map +0 -1
- package/dist/supervise-BUOeThuB.js.map +0 -1
- package/dist/supervisor-DDy0aEtR.js.map +0 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { c as captureRunWriteContext, l as fenceRunWrite, m as __exportAll, p as sha256, r as assertNoSymlinkDescendant, s as writeAtomicDurableFile } from "./record-events-
|
|
2
|
-
import { $n as HarnessTurnFailedError,
|
|
3
|
-
import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-
|
|
4
|
-
import {
|
|
5
|
-
import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, l as profileProviderModel, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-
|
|
6
|
-
import { t as composeRuntimeHooks } from "./runtime-hooks-
|
|
7
|
-
import { c as
|
|
8
|
-
import { c as writeRunCancellation, i as readRunCancellation, r as readRunCancelRequest, s as watchRunCancellation, t as applyRunCancellation } from "./run-cancellation-
|
|
9
|
-
import { n as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-
|
|
1
|
+
import { c as captureRunWriteContext, l as fenceRunWrite, m as __exportAll, p as sha256, r as assertNoSymlinkDescendant, s as writeAtomicDurableFile } from "./record-events-B2GUgYdz.js";
|
|
2
|
+
import { $n as HarnessTurnFailedError, A as beginScopeOwnerAttempt, Ai as registerRetainedExecutorPreparation, An as toOtelAttributes, At as createExecutor, B as assertRecursiveReservationPolicy, Bi as detachedSnapshot, Bn as PEER_MAIL_WIRE_KEY, Cr as bridgeAdmissionRefusal, Ct as readCommittedJsonLines, En as generateSpanId, F as coordinationMcpAlias, Fi as unavailableResumeAt, Fn as INBOX_RECEIPT_KEY, G as meterRuntimeOwnedAccounting, Gi as meterUsageEvent, Hi as executorFailure, Ht as codeModeArguments, I as coordinationProfileToolPrefix, In as createInbox, Ir as bridgeRuntimeAttachmentsKey, J as recordScopeOwnerDriverAttempt, Ji as spendFromUsageTotals, Jn as createActivityLog, Jr as fullProfileMaterialization, Jt as routerBrain, K as meterRuntimeOwnedProviderAttempt, Ki as newUsageTotals, Kr as controlProfileMaterialization, Kt as toolResultText, L as providerVisibleProfile, Lr as bridgeStopSignalKey, M as recordScopeOwnerMaterialization, Mi as cappedDoublingMs, Mr as RunCancellationReason, N as restoreScopeOwnerAcceptedExecution, Ni as jitteredMs, Nr as linkAbort, Ot as bindReusableExecutorExecutionId, P as scopeOwnerExecutorNodeContext, Pi as unavailablePauseMs, Pr as runAbortable, Qn as DriverAttemptsExhaustedError, Qr as renderUnsupported, R as runtimeGraphMetadataKey, St as readCommittedJsonFile, Tt as withJsonlFileLock, Ui as errMessage, Un as isPeerMailEnvelope, Ut as codeModeModelOutput, V as deriveNodeExecutionIdentity, Vi as contentAddress, Wr as assertProfileMaterialization, Wt as createCodeModeTools, X as prepareScopeRetainedOwnerSeatSwitch, Xn as isLiveNodeStatus, Xr as promptControlProfileMaterialization, Xt as resolveAgentEnvironmentProvider, Y as recordScopeOwnerPause, Yi as assertValidBudget, Yr as profileMaterializationAxes$1, Z as scopeRetainedOwnerResourceReader, Zn as isTerminalNodeStatus, Zr as promptModelProfileMaterialization, _i as runtimeOwnedExecutorProviderEvidence, _n as WORKER_TRACE_PROPAGATION, _r as admitContinuationPolicy, a as assertRunParking, ai as authoredAgentIdentity, ar as upstreamUnavailableSignal, at as beginScopeRetainedOwnerDrive, br as createContinuationKeeper, bt as isNoEntError, c as sleepScopeWait, ci as inheritRuntimeOwnedExecutorAttestation, cr as authoredSeatStages, ct as scopeRetainedOwnerRestorePoint, d as runFinalizer, dr as CheckUnavailableError, dt as bindScopeRetainedOwnerProvider, ei as sandboxProfileMaterialization, er as abandonablePending, et as abandonScopeRetainedOwnerInvocation, f as runTree, fi as providerAttemptEvidence, fr as gateFactoryOnDeliverable, ft as scopeRetainedOwnerContext, g as isDriverSpec, gi as runtimeOwnedExecutorMaterialization, gr as CONTINUATIONS_DIR, h as driverExecutorFactory, hi as runtimeOwnedExecutorExecutionBinding, i as RunParkedError, ii as attestRuntimeOwnedScopeOwner, ir as undispatchedCredentialExit, it as scopeRetainedOwnerResult, j as noteScopeOwnerPlannedExecution, ji as retainedExecutorSeamKey, jt as snapshotExecutorConfig, ki as RetainedExecutionPendingError, kt as captureReusableExecutorConfig, l as withRunParking, ln as persistHarnessTranscript, lr as seatExecutionProfile, lt as noteScopeRetainedOwnerCoordination, m as driverChild, mi as runtimeOwnedDriveHarnessProviderEvidence, n as createSupervisor, ni as worktreeCliProfileMaterialization, nr as classifyDriverFailure, nt as prepareScopeRetainedOwnerTask, o as bindScopeParkingDrain, or as SeatChain, ot as scopeRetainedOwnerTurnEnded, p as createRootHandle, pi as recordRuntimeOwnedDriveHarnessProviderEvidence, pt as scopeRetainedOwnerJournalRoot, q as recordScopeOwnerBarrenPause, qr as defineProfileMaterializationContract, qt as createRouterTranscript, rr as summarizeDriverAttempts, rt as scopeRetainedOwnerPriorSpend, sr as SeatChainExhaustedError, st as reconcileScopeRetainedOwnerEnvironment, ti as unsupportedProfileDimensions, tr as causedByPartialFailure, tt as consumeScopeRetainedOwnerResult, u as bestDelivered, un as readHarnessTranscript, ut as bindScopeRetainedOwnerEnvironmentId, vi as runtimeOwnedPendingExecutorMaterialization, vr as bestComposite, wn as createOtelExporter, wr as bridgeModelRouteRefusal, wt as upsertCommittedJsonLine, x as parseWorkerToolTraceArtifact, xt as prepareJsonlAppend, yi as runtimeOwnedScopeOwnerRuntime, yr as checkVerdictOf } from "./supervisor-C1OePYE-.js";
|
|
3
|
+
import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-wuhGvpE3.js";
|
|
4
|
+
import { At as teardownSurfaces, Dt as isDeadlineAbortReason, G as addSpend, St as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, Z as errorMessage, _t as resourceTelemetry, dt as unmeteredSpend, ft as withTimeout, ht as addResourceSpend, kt as teardownExecutor, pt as zeroSpend, q as chargedTokens, rt as promptCacheTokenClasses, st as sleep, tt as isAsyncIterable, vt as withBudgetResources } from "./sandbox-profile-compat-BxMQ1VXv.js";
|
|
5
|
+
import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, l as profileProviderModel, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-GSxWwP-b.js";
|
|
6
|
+
import { t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
|
|
7
|
+
import { c as createCancelAcknowledger, d as normalizeAnalyzeOnSettle, f as coordinationVerbNames, g as withRunContext, h as createInMemoryRunContext, l as createSteerAcknowledger, m as createFileRunContext, n as createCoordinationToolsForManager, o as resolveJsonPointer, p as safeJsonText, t as createCoordinationTools, u as budgetOverspendText } from "./coordination-manager-BkVfWlMz.js";
|
|
8
|
+
import { c as writeRunCancellation, i as readRunCancellation, r as readRunCancelRequest, s as watchRunCancellation, t as applyRunCancellation } from "./run-cancellation-BLy_Zz-w.js";
|
|
9
|
+
import { n as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-CwuYeW_Z.js";
|
|
10
10
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
11
11
|
import { toolSpansToTraceAnalysisStore } from "@tangle-network/agent-eval";
|
|
12
12
|
import { isRecord } from "@tangle-network/agent-core";
|
|
13
|
+
import { z } from "zod";
|
|
13
14
|
import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
14
15
|
import { closeSync, constants, fsyncSync, openSync, writeSync } from "node:fs";
|
|
15
16
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -18,7 +19,7 @@ import { isMaterializerHarness } from "@tangle-network/agent-profile-materialize
|
|
|
18
19
|
import { createServer } from "node:http";
|
|
19
20
|
import { ATTR, agentIdentityAttributes } from "@tangle-network/agent-trace-contract";
|
|
20
21
|
import { withProfileKb } from "@tangle-network/agent-interface/profile-kb";
|
|
21
|
-
|
|
22
|
+
// src/runtime/supervise/supervise-identity.ts
|
|
22
23
|
function externalExecutionId(kind, identity) {
|
|
23
24
|
return `${kind}-${canonicalCandidateDigest({
|
|
24
25
|
kind,
|
|
@@ -107,8 +108,7 @@ function coordinationEventId(context, event) {
|
|
|
107
108
|
event: detachedSnapshot(durableEvent, "supervise coordination event identity")
|
|
108
109
|
});
|
|
109
110
|
}
|
|
110
|
-
|
|
111
|
-
//#region src/runtime/supervise/supervise-option-capture.ts
|
|
111
|
+
// src/runtime/supervise/supervise-option-capture.ts
|
|
112
112
|
const superviseOptionKeySet = /* @__PURE__ */ new Set([
|
|
113
113
|
"allowedModels",
|
|
114
114
|
"analysts",
|
|
@@ -259,11 +259,13 @@ function captureSuperviseOptions(opts) {
|
|
|
259
259
|
assertNoUncapturedExecutableOption(decisionData);
|
|
260
260
|
const capturedData = detachedSnapshot(decisionData, "supervise options");
|
|
261
261
|
const capturedCoordination = coordination === void 0 ? void 0 : (() => {
|
|
262
|
-
const { publicUrl, onAudit, ...configuration } = coordination;
|
|
262
|
+
const { publicUrl, onAudit, onReadReady, onControlReady, ...configuration } = coordination;
|
|
263
263
|
return Object.freeze({
|
|
264
264
|
...detachedSnapshot(configuration, "supervise coordination configuration"),
|
|
265
265
|
...publicUrl === void 0 ? {} : { publicUrl },
|
|
266
|
-
...onAudit === void 0 ? {} : { onAudit }
|
|
266
|
+
...onAudit === void 0 ? {} : { onAudit },
|
|
267
|
+
...onReadReady === void 0 ? {} : { onReadReady },
|
|
268
|
+
...onControlReady === void 0 ? {} : { onControlReady }
|
|
267
269
|
});
|
|
268
270
|
})();
|
|
269
271
|
const capturedBackend = backend === void 0 ? void 0 : snapshotExecutorConfig(backend);
|
|
@@ -356,8 +358,7 @@ function captureSuperviseOptions(opts) {
|
|
|
356
358
|
...otel === void 0 ? {} : { otel }
|
|
357
359
|
});
|
|
358
360
|
}
|
|
359
|
-
|
|
360
|
-
//#region src/runtime/supervise/otel-spans.ts
|
|
361
|
+
// src/runtime/supervise/otel-spans.ts
|
|
361
362
|
/**
|
|
362
363
|
* Supervisor tree → OTLP spans. OPT-IN, off by default.
|
|
363
364
|
*
|
|
@@ -737,7 +738,8 @@ function assignBudget(attrs, value) {
|
|
|
737
738
|
* default) is DERIVED by content address from namespace and run id, so a resumed run rejoins its trace. */
|
|
738
739
|
function normalizeTraceId(traceId, runId, namespace) {
|
|
739
740
|
if (traceId && /^[0-9a-f]{32}$/i.test(traceId)) return traceId.toLowerCase();
|
|
740
|
-
|
|
741
|
+
const source = traceId ?? (namespace === void 0 ? runId : `${namespace}\u0000${runId}`);
|
|
742
|
+
return contentAddress(source).slice(7, 39);
|
|
741
743
|
}
|
|
742
744
|
function msToNano(ms) {
|
|
743
745
|
return (BigInt(Number.isFinite(ms) ? Math.floor(ms) : 0) * 1000000n).toString();
|
|
@@ -751,12 +753,11 @@ function str(value) {
|
|
|
751
753
|
function truncate(value) {
|
|
752
754
|
return value.length > MAX_DETAIL_CHARS ? `${value.slice(0, MAX_DETAIL_CHARS)}…` : value;
|
|
753
755
|
}
|
|
754
|
-
|
|
755
|
-
//#region src/runtime/supervise/root-stream.ts
|
|
756
|
+
// src/runtime/supervise/root-stream.ts
|
|
756
757
|
/**
|
|
757
758
|
* The root manager's own provider stream, retained where Runtime owns it.
|
|
758
759
|
*
|
|
759
|
-
* Measured motive (agent-runtime#1233
|
|
760
|
+
* Measured motive (agent-runtime#1233): a CHILD's full event stream — reasoning, text,
|
|
760
761
|
* and tool parts, 28k to 76k reasoning characters per child — is retained in the blob its
|
|
761
762
|
* `settled` record names as `outRef`. The ROOT's stream reached nobody: `driveHarnessFromBackend`
|
|
762
763
|
* drained the root executor for accounting and discarded every `progress` event, and on a
|
|
@@ -773,7 +774,7 @@ function truncate(value) {
|
|
|
773
774
|
*
|
|
774
775
|
* Durability boundary: each line is written synchronously to an `O_APPEND` descriptor before the
|
|
775
776
|
* next event is drained, and the file is fsynced at every drive-attempt boundary and at close, not
|
|
776
|
-
* per line.
|
|
777
|
+
* per line. An fsync per line cost 7.1 ms per event over
|
|
777
778
|
* 1,000 events and 8.1 ms over 5,000 (~80 s for a root emitting ten thousand text deltas, all of
|
|
778
779
|
* it serialized inside the drain loop that also meters the budget); an async `FileHandle.write`
|
|
779
780
|
* still cost 0.9 to 1.1 ms per line in the thread pool the children's journal writes share; a
|
|
@@ -927,8 +928,7 @@ async function readRootStream(runDir) {
|
|
|
927
928
|
}
|
|
928
929
|
return records;
|
|
929
930
|
}
|
|
930
|
-
|
|
931
|
-
//#region src/runtime/anytime.ts
|
|
931
|
+
// src/runtime/anytime.ts
|
|
932
932
|
/**
|
|
933
933
|
* The best-so-far fold — the ONE definition of "how good was the run after k results", shared by
|
|
934
934
|
* the post-run anytime report below and by the LIVE progress-based stop rules
|
|
@@ -1075,8 +1075,7 @@ function renderAnytimeTable(report) {
|
|
|
1075
1075
|
}
|
|
1076
1076
|
return lines.join("\n");
|
|
1077
1077
|
}
|
|
1078
|
-
|
|
1079
|
-
//#region src/runtime/supervise/stop-rules.ts
|
|
1078
|
+
// src/runtime/supervise/stop-rules.ts
|
|
1080
1079
|
/**
|
|
1081
1080
|
*
|
|
1082
1081
|
* PROGRESS-BASED STOP RULES — end a long-horizon run for the right reason.
|
|
@@ -1273,8 +1272,7 @@ function progressStop(tracker, rule, ledger, scope, now, stallAfterMs) {
|
|
|
1273
1272
|
});
|
|
1274
1273
|
return tracker.evaluate(rule, scope, stallAfterMs !== void 0 ? { stallAfterMs } : void 0);
|
|
1275
1274
|
}
|
|
1276
|
-
|
|
1277
|
-
//#region src/runtime/supervise/supervise-agent-options.ts
|
|
1275
|
+
// src/runtime/supervise/supervise-agent-options.ts
|
|
1278
1276
|
/** A stop rule as a function, or the declared plateau form a record carries as data. */
|
|
1279
1277
|
function stopRuleOf(rule) {
|
|
1280
1278
|
if (typeof rule === "function") return rule;
|
|
@@ -1291,8 +1289,7 @@ function supervisorTurnOptions(options) {
|
|
|
1291
1289
|
...options.onDriverAttempt ? { onDriverAttempt: options.onDriverAttempt } : {}
|
|
1292
1290
|
};
|
|
1293
1291
|
}
|
|
1294
|
-
|
|
1295
|
-
//#region src/runtime/supervise/graph-edge-ledger.ts
|
|
1292
|
+
// src/runtime/supervise/graph-edge-ledger.ts
|
|
1296
1293
|
var GraphEdgeLedger = class {
|
|
1297
1294
|
journal;
|
|
1298
1295
|
runId;
|
|
@@ -1407,8 +1404,7 @@ var GraphEdgeLedger = class {
|
|
|
1407
1404
|
}
|
|
1408
1405
|
};
|
|
1409
1406
|
const pendingKey = (parentNodeId, assignmentId) => `${parentNodeId ?? ""}\u0000${assignmentId}`;
|
|
1410
|
-
|
|
1411
|
-
//#region src/runtime/supervise/prompt-registry.ts
|
|
1407
|
+
// src/runtime/supervise/prompt-registry.ts
|
|
1412
1408
|
/**
|
|
1413
1409
|
*
|
|
1414
1410
|
* The kernel prompt registry — versioned prompt text as DATA, addressed by `PromptHandle`.
|
|
@@ -1540,8 +1536,7 @@ function kernelPromptRegistry() {
|
|
|
1540
1536
|
dumbContinuationPassPrompt
|
|
1541
1537
|
]);
|
|
1542
1538
|
}
|
|
1543
|
-
|
|
1544
|
-
//#region src/runtime/supervise/graph-topology.ts
|
|
1539
|
+
// src/runtime/supervise/graph-topology.ts
|
|
1545
1540
|
/**
|
|
1546
1541
|
* `run_graph`: a graph a manager starts as one subtask. The topology is read from model-written
|
|
1547
1542
|
* data or a stored graph, validated exactly as `runGraph` validates a root graph, and carried on
|
|
@@ -1848,8 +1843,7 @@ function graphSubtaskOf(profile) {
|
|
|
1848
1843
|
const raw = profile.metadata?.[runtimeGraphMetadataKey];
|
|
1849
1844
|
return raw === void 0 ? void 0 : parseGraphSubtaskTopology(raw);
|
|
1850
1845
|
}
|
|
1851
|
-
|
|
1852
|
-
//#region src/runtime/supervise/graph-flow.ts
|
|
1846
|
+
// src/runtime/supervise/graph-flow.ts
|
|
1853
1847
|
/** A flow node's usable settle matched no routes edge leaving it (`unrouted`), or a fired edge named
|
|
1854
1848
|
* a node that still had a running worker (`target-live`). The flow spawned nothing more; the full
|
|
1855
1849
|
* evidence rides on the error, shaped like `GraphEdgeCapError`. */
|
|
@@ -2330,8 +2324,7 @@ function createFlowRun() {
|
|
|
2330
2324
|
failure
|
|
2331
2325
|
};
|
|
2332
2326
|
}
|
|
2333
|
-
|
|
2334
|
-
//#region src/runtime/supervise/graph-overlay.ts
|
|
2327
|
+
// src/runtime/supervise/graph-overlay.ts
|
|
2335
2328
|
/**
|
|
2336
2329
|
* The graph layer over the managers that run one `AgentGraph`.
|
|
2337
2330
|
*
|
|
@@ -2632,8 +2625,7 @@ function ledgerAnalyzes(ledger, edge, outcome, bytes, reason, workerId) {
|
|
|
2632
2625
|
...workerId !== void 0 ? { workerId } : {}
|
|
2633
2626
|
}, true);
|
|
2634
2627
|
}
|
|
2635
|
-
|
|
2636
|
-
//#region src/runtime/supervise/flow-brain.ts
|
|
2628
|
+
// src/runtime/supervise/flow-brain.ts
|
|
2637
2629
|
const flowBrains = /* @__PURE__ */ new WeakSet();
|
|
2638
2630
|
/**
|
|
2639
2631
|
* The brain of a flow graph's runtime-owned root manager. It never calls a model: every turn
|
|
@@ -2654,8 +2646,7 @@ function runtimeFlowBrain() {
|
|
|
2654
2646
|
function isRuntimeFlowBrain(brain) {
|
|
2655
2647
|
return flowBrains.has(brain);
|
|
2656
2648
|
}
|
|
2657
|
-
|
|
2658
|
-
//#region src/runtime/supervise/supervise-budget.ts
|
|
2649
|
+
// src/runtime/supervise/supervise-budget.ts
|
|
2659
2650
|
/**
|
|
2660
2651
|
* Which of a driver's budget channels are spent, with their numbers, or `undefined` while none is.
|
|
2661
2652
|
* The bare 'supervisor budget exhausted' named no channel: on queens21-h22-capture-root-2-20261019c
|
|
@@ -2736,8 +2727,7 @@ function unmeteredOwnerCache(total, committed) {
|
|
|
2736
2727
|
...total.cacheBreakdownKnown === false ? { cacheBreakdownKnown: false } : {}
|
|
2737
2728
|
};
|
|
2738
2729
|
}
|
|
2739
|
-
|
|
2740
|
-
//#region src/runtime/tool-loop.ts
|
|
2730
|
+
// src/runtime/tool-loop.ts
|
|
2741
2731
|
/**
|
|
2742
2732
|
* THE canonical agentic tool-loop. One inference turn → run any requested tools → fold the
|
|
2743
2733
|
* results back as `tool` messages → repeat, until the model answers without a tool call or the
|
|
@@ -2975,8 +2965,7 @@ async function runBrainLoop(opts) {
|
|
|
2975
2965
|
...retainedCodeMode()
|
|
2976
2966
|
};
|
|
2977
2967
|
}
|
|
2978
|
-
|
|
2979
|
-
//#region src/runtime/supervise/driver-budget-guards.ts
|
|
2968
|
+
// src/runtime/supervise/driver-budget-guards.ts
|
|
2980
2969
|
/** Spawn-progress is impossible: the pool can't afford another worker AND nothing is in flight to
|
|
2981
2970
|
* await. A long-horizon driver bounded by the conserved pool stops here instead of spinning (the
|
|
2982
2971
|
* in-loop budget guard the turn cap alone never provided). Checks BOTH conserved channels: tokens
|
|
@@ -3016,8 +3005,7 @@ function deadlinePassed(scope, now) {
|
|
|
3016
3005
|
const b = scope.budget;
|
|
3017
3006
|
return b.deadlineMs > 0 && now() >= b.deadlineMs;
|
|
3018
3007
|
}
|
|
3019
|
-
|
|
3020
|
-
//#region src/runtime/supervise/driver-prompt-cache.ts
|
|
3008
|
+
// src/runtime/supervise/driver-prompt-cache.ts
|
|
3021
3009
|
/** The USD-denominated members of {@link PromptCacheUsage} — the schema, not a guess. Every
|
|
3022
3010
|
* other known member (`readTokens`, `writeTokens`, `missTokens`) is a token COUNT. */
|
|
3023
3011
|
const PROMPT_CACHE_USD_FIELDS = /* @__PURE__ */ new Set(["readSavingsUsd"]);
|
|
@@ -3133,8 +3121,7 @@ function safeJson(v) {
|
|
|
3133
3121
|
return String(v);
|
|
3134
3122
|
}
|
|
3135
3123
|
}
|
|
3136
|
-
|
|
3137
|
-
//#region src/runtime/supervise/driver-tool-dispatch.ts
|
|
3124
|
+
// src/runtime/supervise/driver-tool-dispatch.ts
|
|
3138
3125
|
/** Run a work tool. A throw is data to the driver (it can recover next turn), not a crash — fold
|
|
3139
3126
|
* the error back as a string result. null/undefined passes through (the caller treats it as "not
|
|
3140
3127
|
* handled" and falls to the coordination dispatch). */
|
|
@@ -3152,14 +3139,13 @@ async function runTool(tool, args) {
|
|
|
3152
3139
|
return { error: errorMessage(e) };
|
|
3153
3140
|
}
|
|
3154
3141
|
}
|
|
3155
|
-
|
|
3156
|
-
//#region src/runtime/supervise/wake.ts
|
|
3142
|
+
// src/runtime/supervise/wake.ts
|
|
3157
3143
|
/** How long a waiting manager hears nothing before Runtime wakes it to reconsider: 15 min. */
|
|
3158
|
-
const DEFAULT_WAKE_HEARTBEAT_MS =
|
|
3144
|
+
const DEFAULT_WAKE_HEARTBEAT_MS = 9e5;
|
|
3159
3145
|
/** How long a wake waits for more events after its first, while other workers still run: 2 s. */
|
|
3160
3146
|
const DEFAULT_WAKE_DEBOUNCE_MS = 2e3;
|
|
3161
3147
|
/** How long before its deadline a manager is woken once to submit its best result: 15 min. */
|
|
3162
|
-
const DEFAULT_DEADLINE_WARNING_MS =
|
|
3148
|
+
const DEFAULT_DEADLINE_WARNING_MS = 9e5;
|
|
3163
3149
|
/** The instruction every manager receives about waiting. */
|
|
3164
3150
|
const WAIT_BY_ENDING_TURN = "When you are waiting for workers, end your turn. You will be woken with what happened: a worker settled, a finding, a message or answer from your lead, or the deadline approaching.";
|
|
3165
3151
|
function resolveWakePolicy(policy) {
|
|
@@ -3218,8 +3204,7 @@ function composeWakeInput(wake, context) {
|
|
|
3218
3204
|
lines.push("", WAIT_BY_ENDING_TURN);
|
|
3219
3205
|
return lines.join("\n");
|
|
3220
3206
|
}
|
|
3221
|
-
|
|
3222
|
-
//#region src/runtime/supervise/driver-brain-turns.ts
|
|
3207
|
+
// src/runtime/supervise/driver-brain-turns.ts
|
|
3223
3208
|
/** How often a waiting driver applies operator cancels and steers between its turns. */
|
|
3224
3209
|
const WAITING_CONTROL_POLL_MS = 5e3;
|
|
3225
3210
|
/** The evidence fault a brain reply carries, if any: identity, transport count, or prompt cache. */
|
|
@@ -3466,8 +3451,7 @@ var DriverBrainTurns = class {
|
|
|
3466
3451
|
for (const lease of this.leases.splice(0)) lease.release();
|
|
3467
3452
|
}
|
|
3468
3453
|
};
|
|
3469
|
-
|
|
3470
|
-
//#region src/runtime/supervise/driver-tool-surface.ts
|
|
3454
|
+
// src/runtime/supervise/driver-tool-surface.ts
|
|
3471
3455
|
/** Mount this manager's coordination tools over `scope` and select exactly the granted tools. */
|
|
3472
3456
|
async function openDriverToolSurface(opts, scope) {
|
|
3473
3457
|
const ownerReader = opts.spawnResourceReader ?? (opts.spawnResourceRoot === void 0 ? scopeRetainedOwnerResourceReader(scope) : void 0);
|
|
@@ -3548,8 +3532,7 @@ async function openDriverToolSurface(opts, scope) {
|
|
|
3548
3532
|
})
|
|
3549
3533
|
};
|
|
3550
3534
|
}
|
|
3551
|
-
|
|
3552
|
-
//#region src/runtime/supervise/driver-brain-agent.ts
|
|
3535
|
+
// src/runtime/supervise/driver-brain-agent.ts
|
|
3553
3536
|
/**
|
|
3554
3537
|
* Build the intelligent recursive driver. Its `act` is the LLM tool-loop; spawn it as a
|
|
3555
3538
|
* `driverChild` (`driver-executor.ts`) to run it inside a nested scope, recursively.
|
|
@@ -3699,20 +3682,19 @@ function driverInitialMessages(opts, system, task, scope) {
|
|
|
3699
3682
|
}] : []
|
|
3700
3683
|
];
|
|
3701
3684
|
}
|
|
3702
|
-
|
|
3703
|
-
//#region src/runtime/supervise/supervisor-agent-profile.ts
|
|
3685
|
+
// src/runtime/supervise/supervisor-agent-profile.ts
|
|
3704
3686
|
/**
|
|
3705
3687
|
* The completion check of a managed child that no `resolveDeliverable` gave a check of its own, a
|
|
3706
3688
|
* `run_graph` node included: its accepted submission settles it, and the result goes to the manager
|
|
3707
3689
|
* that assigned the task. The run's own check judges the run's result, never a child's narrower
|
|
3708
3690
|
* assignment. Held to the run's check, a child's submission is refused for as long as the run's
|
|
3709
3691
|
* is: every node of test-canary-graph-tools-20261017a, and the `delay` child of
|
|
3710
|
-
* test-retained-root-wake-20261018b (
|
|
3692
|
+
* test-retained-root-wake-20261018b ("Expected: the canary runs to its deadline"), was
|
|
3711
3693
|
* refused at submit_result, never settled, and its manager was never woken with it.
|
|
3712
3694
|
*
|
|
3713
3695
|
* It is the one check a harness manager may hold without a continuation policy: it accepts every
|
|
3714
3696
|
* submission, so there is nothing to send the child back for. test-canary-graph-tools-20261018c and
|
|
3715
|
-
* -d
|
|
3697
|
+
* -d had every harness-run graph lead refused at spawn until this exemption.
|
|
3716
3698
|
*/
|
|
3717
3699
|
const ownSubmissionDeliverable = Object.freeze({
|
|
3718
3700
|
describe: "the result your task asks for; it goes to the manager that assigned the task, and the run's own check judges that manager's result",
|
|
@@ -3770,7 +3752,11 @@ function assertRouterArmResourcePolicy(profile) {
|
|
|
3770
3752
|
*/
|
|
3771
3753
|
function resolveSupervisorSystemPrompt(profile) {
|
|
3772
3754
|
const promptSystem = profile.prompt?.systemPrompt;
|
|
3773
|
-
const lines = [
|
|
3755
|
+
const lines = [
|
|
3756
|
+
...profile.prompt?.appendSystemPrompt === void 0 ? [] : [profile.prompt.appendSystemPrompt],
|
|
3757
|
+
...profile.prompt?.instructions ?? [],
|
|
3758
|
+
...resourceInstructionLines(profile.resources?.instructions)
|
|
3759
|
+
];
|
|
3774
3760
|
if (lines.length === 0) return promptSystem;
|
|
3775
3761
|
return (promptSystem !== void 0 ? [promptSystem, ...lines] : lines).join("\n");
|
|
3776
3762
|
}
|
|
@@ -3780,8 +3766,7 @@ function resolveSupervisorModelId(profile) {
|
|
|
3780
3766
|
return concreteProfileModel(profile);
|
|
3781
3767
|
}
|
|
3782
3768
|
/** Listener, authenticated remote endpoint, and bounded request policy for one manager. */
|
|
3783
|
-
|
|
3784
|
-
//#region src/runtime/supervise/supervisor-coordination-observers.ts
|
|
3769
|
+
// src/runtime/supervise/supervisor-coordination-observers.ts
|
|
3785
3770
|
/** Forward the same declared observer routes to router and external manager coordination. */
|
|
3786
3771
|
function supervisorCoordinationObservers(deps) {
|
|
3787
3772
|
return {
|
|
@@ -3796,13 +3781,19 @@ function supervisorCoordinationObservers(deps) {
|
|
|
3796
3781
|
...deps.stallAfterMs !== void 0 ? { stallAfterMs: deps.stallAfterMs } : {}
|
|
3797
3782
|
};
|
|
3798
3783
|
}
|
|
3799
|
-
|
|
3800
|
-
//#region src/runtime/supervise/coordination-credentials.ts
|
|
3784
|
+
// src/runtime/supervise/coordination-credentials.ts
|
|
3801
3785
|
/**
|
|
3802
3786
|
* The credentials one coordination listener accepts: the manager's bearer token (random, or an HMAC
|
|
3803
|
-
* claim set under caller-owned signing keys),
|
|
3787
|
+
* claim set under caller-owned signing keys), separate read-only and control tokens, rotation and the
|
|
3804
3788
|
* revocation of every token it replaces.
|
|
3805
3789
|
*/
|
|
3790
|
+
/** Exact operator authority, independent of the manager's authored tool grants. */
|
|
3791
|
+
const coordinationControlToolNames = Object.freeze([
|
|
3792
|
+
"observe_agent",
|
|
3793
|
+
"read_journal",
|
|
3794
|
+
"steer_agent",
|
|
3795
|
+
"cancel_worker"
|
|
3796
|
+
]);
|
|
3806
3797
|
/** The bearer token in an `Authorization` header, or an empty buffer. */
|
|
3807
3798
|
function bearerToken(authorization) {
|
|
3808
3799
|
return typeof authorization === "string" && authorization.startsWith("Bearer ") ? Buffer.from(authorization.slice(7)) : Buffer.alloc(0);
|
|
@@ -3815,6 +3806,7 @@ function createCoordinationCredentials(input) {
|
|
|
3815
3806
|
keys: { ...auth.signingKeys.keys }
|
|
3816
3807
|
} : void 0;
|
|
3817
3808
|
let readerToken = Buffer.from(randomBytes(32).toString("base64url"));
|
|
3809
|
+
let controllerToken = Buffer.from(randomBytes(32).toString("base64url"));
|
|
3818
3810
|
let token;
|
|
3819
3811
|
let expiresAt;
|
|
3820
3812
|
let headers = Object.freeze({});
|
|
@@ -3844,6 +3836,7 @@ function createCoordinationCredentials(input) {
|
|
|
3844
3836
|
text = `${payload}.${createHmac("sha256", signingKeys.keys[signingKeys.activeKeyId]).update(payload).digest("base64url")}`;
|
|
3845
3837
|
}
|
|
3846
3838
|
readerToken = Buffer.from(randomBytes(32).toString("base64url"));
|
|
3839
|
+
controllerToken = Buffer.from(randomBytes(32).toString("base64url"));
|
|
3847
3840
|
token = Buffer.from(text);
|
|
3848
3841
|
headers = Object.freeze({ Authorization: `Bearer ${text}` });
|
|
3849
3842
|
};
|
|
@@ -3864,6 +3857,7 @@ function createCoordinationCredentials(input) {
|
|
|
3864
3857
|
return false;
|
|
3865
3858
|
}
|
|
3866
3859
|
};
|
|
3860
|
+
const capabilityRefused = (supplied, expected) => input.isClosed() || supplied.length !== expected.length || !timingSafeEqual(supplied, expected) || expiresAt !== void 0 && expiresAt <= Date.now();
|
|
3867
3861
|
return {
|
|
3868
3862
|
rotate,
|
|
3869
3863
|
setAudience: (next) => {
|
|
@@ -3873,7 +3867,11 @@ function createCoordinationCredentials(input) {
|
|
|
3873
3867
|
if (input.scopeSignal.aborted) return "scope-stopped";
|
|
3874
3868
|
return valid(supplied) ? void 0 : "credential-refused";
|
|
3875
3869
|
},
|
|
3876
|
-
readerRefused: (supplied) =>
|
|
3870
|
+
readerRefused: (supplied) => input.scopeSignal.aborted || input.lifetimeSignal?.aborted === true || capabilityRefused(supplied, readerToken),
|
|
3871
|
+
controllerRefused: (supplied) => {
|
|
3872
|
+
if (input.scopeSignal.aborted || input.lifetimeSignal?.aborted) return "scope-stopped";
|
|
3873
|
+
return capabilityRefused(supplied, controllerToken) ? "credential-refused" : void 0;
|
|
3874
|
+
},
|
|
3877
3875
|
get headers() {
|
|
3878
3876
|
return headers;
|
|
3879
3877
|
},
|
|
@@ -3882,11 +3880,13 @@ function createCoordinationCredentials(input) {
|
|
|
3882
3880
|
},
|
|
3883
3881
|
get readerToken() {
|
|
3884
3882
|
return readerToken;
|
|
3883
|
+
},
|
|
3884
|
+
get controllerHeaders() {
|
|
3885
|
+
return Object.freeze({ Authorization: `Bearer ${controllerToken.toString()}` });
|
|
3885
3886
|
}
|
|
3886
3887
|
};
|
|
3887
3888
|
}
|
|
3888
|
-
|
|
3889
|
-
//#region src/runtime/supervise/coordination-http.ts
|
|
3889
|
+
// src/runtime/supervise/coordination-http.ts
|
|
3890
3890
|
/** The JSON-RPC error a refusal carries. MCP clients put a non-2xx body into the error the agent
|
|
3891
3891
|
* sees, so without it the agent reads only `Error POSTing to endpoint:` and a status at best. The
|
|
3892
3892
|
* messages are fixed text: never a credential, a request body or an arbitrary error string. */
|
|
@@ -3930,7 +3930,7 @@ function coordinationHttpLimits(options) {
|
|
|
3930
3930
|
const requestTimeoutMs = positive("requestTimeoutMs", options.requestTimeoutMs, 9e4);
|
|
3931
3931
|
if (requestTimeoutMs > 2147483647) throw new ConfigError("coordination requestTimeoutMs exceeds the timer limit");
|
|
3932
3932
|
return {
|
|
3933
|
-
maxRequestBytes: positive("maxRequestBytes", options.maxRequestBytes,
|
|
3933
|
+
maxRequestBytes: positive("maxRequestBytes", options.maxRequestBytes, 1048576),
|
|
3934
3934
|
requestTimeoutMs,
|
|
3935
3935
|
maxConcurrentRequests: positive("maxConcurrentRequests", options.maxConcurrentRequests, 32),
|
|
3936
3936
|
requestsPerMinute: positive("requestsPerMinute", options.requestsPerMinute, 600),
|
|
@@ -4139,8 +4139,7 @@ function coordinationHttpHandler(input) {
|
|
|
4139
4139
|
});
|
|
4140
4140
|
};
|
|
4141
4141
|
}
|
|
4142
|
-
|
|
4143
|
-
//#region src/runtime/supervise/coordination-mcp-listener.ts
|
|
4142
|
+
// src/runtime/supervise/coordination-mcp-listener.ts
|
|
4144
4143
|
/**
|
|
4145
4144
|
* The HTTP side of one coordination server: which hosts and paths it answers, who may call each
|
|
4146
4145
|
* (manager, read-only observer, one peer-mail capability), and the public address it advertises.
|
|
@@ -4151,6 +4150,7 @@ function openCoordinationListenerState() {
|
|
|
4151
4150
|
audiences: /* @__PURE__ */ new Set(),
|
|
4152
4151
|
paths: /* @__PURE__ */ new Set(["/mcp"]),
|
|
4153
4152
|
readPaths: /* @__PURE__ */ new Set(),
|
|
4153
|
+
controlPaths: /* @__PURE__ */ new Set(),
|
|
4154
4154
|
mailPaths: /* @__PURE__ */ new Set()
|
|
4155
4155
|
};
|
|
4156
4156
|
}
|
|
@@ -4190,6 +4190,31 @@ function readOnlyHandler(ctx, coord) {
|
|
|
4190
4190
|
handle: (message) => readMcp.handle(message)
|
|
4191
4191
|
});
|
|
4192
4192
|
}
|
|
4193
|
+
/** Operator access calls the same owned-worker handlers, with no spawn/submit/stop authority. */
|
|
4194
|
+
function controlHandler(ctx, coord) {
|
|
4195
|
+
const toolNames = new Set(coordinationControlToolNames);
|
|
4196
|
+
const controlMcp = createStdioToolServer({
|
|
4197
|
+
serverName: "supervisor-control",
|
|
4198
|
+
serverVersion: "1",
|
|
4199
|
+
tools: coord.tools.filter((tool) => toolNames.has(tool.name))
|
|
4200
|
+
});
|
|
4201
|
+
return coordinationHttpHandler({
|
|
4202
|
+
options: ctx.opts,
|
|
4203
|
+
identity: ctx.identity,
|
|
4204
|
+
toolNames,
|
|
4205
|
+
backgroundActions: () => 0,
|
|
4206
|
+
authorize: (req) => {
|
|
4207
|
+
const refused = authority(ctx, req);
|
|
4208
|
+
if (refused) return refused;
|
|
4209
|
+
const credential = ctx.credentials.controllerRefused(bearerToken(req.headers.authorization));
|
|
4210
|
+
return credential === void 0 ? void 0 : {
|
|
4211
|
+
status: 401,
|
|
4212
|
+
reason: credential
|
|
4213
|
+
};
|
|
4214
|
+
},
|
|
4215
|
+
handle: (message) => controlMcp.handle(message)
|
|
4216
|
+
});
|
|
4217
|
+
}
|
|
4193
4218
|
function managerHandler(ctx, mcp, servedTools, background) {
|
|
4194
4219
|
return coordinationHttpHandler({
|
|
4195
4220
|
options: ctx.opts,
|
|
@@ -4244,10 +4269,12 @@ function peerMailHandler(ctx, coord, capabilityId) {
|
|
|
4244
4269
|
function createCoordinationListener(ctx, bound) {
|
|
4245
4270
|
const { coord } = bound;
|
|
4246
4271
|
const readHandler = readOnlyHandler(ctx, coord);
|
|
4272
|
+
const operatorHandler = controlHandler(ctx, coord);
|
|
4247
4273
|
const peerHandlers = /* @__PURE__ */ new Map();
|
|
4248
4274
|
const mainHandler = managerHandler(ctx, bound.mcp, bound.servedTools, bound.background);
|
|
4249
4275
|
return createServer((req, res) => {
|
|
4250
4276
|
if (ctx.state.readPaths.has(req.url ?? "")) return readHandler(req, res);
|
|
4277
|
+
if (ctx.state.controlPaths.has(req.url ?? "")) return operatorHandler(req, res);
|
|
4251
4278
|
for (const base of ctx.state.mailPaths) {
|
|
4252
4279
|
if (!(req.url ?? "").startsWith(base + "/")) continue;
|
|
4253
4280
|
const capabilityId = (req.url ?? "").slice(base.length + 1);
|
|
@@ -4266,8 +4293,7 @@ function createCoordinationListener(ctx, bound) {
|
|
|
4266
4293
|
return mainHandler(req, res);
|
|
4267
4294
|
});
|
|
4268
4295
|
}
|
|
4269
|
-
|
|
4270
|
-
//#region src/runtime/supervise/single-flight-tools.ts
|
|
4296
|
+
// src/runtime/supervise/single-flight-tools.ts
|
|
4271
4297
|
/**
|
|
4272
4298
|
* Serve method-supplied supervisor tools on the coordination MCP as single-flight, fenced calls.
|
|
4273
4299
|
*
|
|
@@ -4378,8 +4404,7 @@ function toolCallReceipt(tool, receipt, elapsedMs) {
|
|
|
4378
4404
|
instruction: `${tool} is still running; nothing failed. Do not call it again: its result arrives with receipt ${receipt} when you are next woken. Continue other work, or end your turn to wait.`
|
|
4379
4405
|
};
|
|
4380
4406
|
}
|
|
4381
|
-
|
|
4382
|
-
//#region src/runtime/supervise/coordination-mcp-tools.ts
|
|
4407
|
+
// src/runtime/supervise/coordination-mcp-tools.ts
|
|
4383
4408
|
/**
|
|
4384
4409
|
* Which tools one coordination server serves: the options its coordination tools are built from,
|
|
4385
4410
|
* and the granted subset of coordination verbs and node tools, fenced and single-flight.
|
|
@@ -4463,9 +4488,8 @@ function bindServedTools(opts, coord, fenceMs) {
|
|
|
4463
4488
|
background: () => nodeTools.background() + fencedVerbs.background()
|
|
4464
4489
|
};
|
|
4465
4490
|
}
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
const MAX_RESPONSE_BYTES = 1024 * 1024;
|
|
4491
|
+
// src/runtime/supervise/coordination-preflight.ts
|
|
4492
|
+
const MAX_RESPONSE_BYTES = 1048576;
|
|
4469
4493
|
var CoordinationPreflightError = class extends ConfigError {
|
|
4470
4494
|
constructor(reason) {
|
|
4471
4495
|
super(`coordination public endpoint preflight failed: ${reason}`);
|
|
@@ -4554,8 +4578,7 @@ async function preflightPublicCoordination(input) {
|
|
|
4554
4578
|
linked.release();
|
|
4555
4579
|
}
|
|
4556
4580
|
}
|
|
4557
|
-
|
|
4558
|
-
//#region src/runtime/supervise/coordination-mcp.ts
|
|
4581
|
+
// src/runtime/supervise/coordination-mcp.ts
|
|
4559
4582
|
/** Hosts that reach only this machine (incl. IPv4-mapped and bracketed IPv6 spellings). A name not
|
|
4560
4583
|
* recognizably loopback counts as REMOTE: whether it resolves to loopback is unknowable here. */
|
|
4561
4584
|
function isLoopbackHost(host) {
|
|
@@ -4576,6 +4599,7 @@ function assertCoordinationTransport(options) {
|
|
|
4576
4599
|
for (const [id, key] of Object.entries(signingKeys.keys)) if (!/^[A-Za-z0-9_-]{1,64}$/.test(id) || typeof key !== "string" || Buffer.byteLength(key) < 32) throw new ConfigError("coordination signing keys require bounded key IDs and at least 32 secret bytes");
|
|
4577
4600
|
}
|
|
4578
4601
|
if (options.onReadReady && !options.authentication) throw new ConfigError("coordination read capability publication requires authentication");
|
|
4602
|
+
if (options.onControlReady && !options.authentication) throw new ConfigError("coordination control capability publication requires authentication");
|
|
4579
4603
|
coordinationHttpLimits(options);
|
|
4580
4604
|
}
|
|
4581
4605
|
/** The longest any coordination call holds its response, whatever the request timeout: under the
|
|
@@ -4616,6 +4640,7 @@ async function bindCoordinationAddress(ctx, port, addressSignal) {
|
|
|
4616
4640
|
state.paths.add(publicAddress.pathname);
|
|
4617
4641
|
for (const path of state.paths) {
|
|
4618
4642
|
state.readPaths.add(path.replace(/\/$/, "") + "/read");
|
|
4643
|
+
state.controlPaths.add(path.replace(/\/$/, "") + "/control");
|
|
4619
4644
|
state.mailPaths.add(path.replace(/\/$/, "") + "/mail");
|
|
4620
4645
|
}
|
|
4621
4646
|
if (configured !== void 0) await preflightPublicCoordination({
|
|
@@ -4644,6 +4669,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
4644
4669
|
identity,
|
|
4645
4670
|
toolNames: opts.toolNames,
|
|
4646
4671
|
scopeSignal: opts.scope.signal,
|
|
4672
|
+
lifetimeSignal: lifetime,
|
|
4647
4673
|
isClosed: () => state.closed
|
|
4648
4674
|
});
|
|
4649
4675
|
const ctx = {
|
|
@@ -4716,6 +4742,14 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
4716
4742
|
get headers() {
|
|
4717
4743
|
return credentials.headers;
|
|
4718
4744
|
},
|
|
4745
|
+
get control() {
|
|
4746
|
+
if (!opts.authentication) throw new ConfigError("coordination control access requires authentication");
|
|
4747
|
+
return {
|
|
4748
|
+
...identity,
|
|
4749
|
+
url: url.replace(/\/$/, "") + "/control",
|
|
4750
|
+
headers: credentials.controllerHeaders
|
|
4751
|
+
};
|
|
4752
|
+
},
|
|
4719
4753
|
get credentialExpiresAt() {
|
|
4720
4754
|
return credentials.expiresAt;
|
|
4721
4755
|
},
|
|
@@ -4743,6 +4777,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
4743
4777
|
...handle.readOnly,
|
|
4744
4778
|
...identity
|
|
4745
4779
|
}), opts.scope.signal, "read capability publication aborted");
|
|
4780
|
+
await runAbortable(async () => opts.onControlReady?.(handle.control), opts.scope.signal, "control capability publication aborted");
|
|
4746
4781
|
} catch (error) {
|
|
4747
4782
|
await handle.close();
|
|
4748
4783
|
throw error;
|
|
@@ -4752,8 +4787,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
4752
4787
|
controls: coord
|
|
4753
4788
|
};
|
|
4754
4789
|
}
|
|
4755
|
-
|
|
4756
|
-
//#region src/runtime/supervise/supervisor-tool-binding.ts
|
|
4790
|
+
// src/runtime/supervise/supervisor-tool-binding.ts
|
|
4757
4791
|
function createVerbSlot() {
|
|
4758
4792
|
let bound;
|
|
4759
4793
|
let waits;
|
|
@@ -4842,8 +4876,7 @@ function bindSupervisorNodeObserver(context, observeNodeEvent, onEvent) {
|
|
|
4842
4876
|
await onEvent?.(event, record);
|
|
4843
4877
|
};
|
|
4844
4878
|
}
|
|
4845
|
-
|
|
4846
|
-
//#region src/runtime/supervise/worker-control-observer.ts
|
|
4879
|
+
// src/runtime/supervise/worker-control-observer.ts
|
|
4847
4880
|
/** Observe durable worker controls while the native harness owns the manager's turn loop. */
|
|
4848
4881
|
function observeWorkerControls(options) {
|
|
4849
4882
|
const { dir, coord, scope, signal, controlScope, onError } = options;
|
|
@@ -4927,8 +4960,7 @@ function observeWorkerControls(options) {
|
|
|
4927
4960
|
close: () => closing ??= finish()
|
|
4928
4961
|
};
|
|
4929
4962
|
}
|
|
4930
|
-
|
|
4931
|
-
//#region src/runtime/supervise/supervisor-manager-session.ts
|
|
4963
|
+
// src/runtime/supervise/supervisor-manager-session.ts
|
|
4932
4964
|
/** Bind this act's node tools and serve its coordination server, then route the lead's messages. */
|
|
4933
4965
|
async function openManagerSession(config, task, scope) {
|
|
4934
4966
|
const { deps } = config;
|
|
@@ -5078,15 +5110,14 @@ function observeManagerControls(config, session) {
|
|
|
5078
5110
|
}
|
|
5079
5111
|
});
|
|
5080
5112
|
}
|
|
5081
|
-
|
|
5082
|
-
//#region src/runtime/supervise/driver-retry-loop.ts
|
|
5113
|
+
// src/runtime/supervise/driver-retry-loop.ts
|
|
5083
5114
|
const DEFAULT_MAX_CONSECUTIVE_FAILURES = 3;
|
|
5084
5115
|
const DEFAULT_MAX_ATTEMPTS = Number.POSITIVE_INFINITY;
|
|
5085
5116
|
const DEFAULT_INITIAL_BACKOFF_MS$1 = 2e3;
|
|
5086
5117
|
const DEFAULT_MAX_BACKOFF_MS$1 = 3e4;
|
|
5087
5118
|
const DEFAULT_TRANSIENT_OUTAGE_MS = 9e5;
|
|
5088
|
-
const BARREN_PAUSE_FIRST_MS =
|
|
5089
|
-
const BARREN_PAUSE_MAX_MS =
|
|
5119
|
+
const BARREN_PAUSE_FIRST_MS = 3e5;
|
|
5120
|
+
const BARREN_PAUSE_MAX_MS = 36e5;
|
|
5090
5121
|
/** The stops an opted-in root pauses on (`DriverRetryRun.stopPause`). `completed`, `aborted` and a
|
|
5091
5122
|
* declared `deadline` end the run; `supervise()` refuses `driverRetry.pauseRootStops` beside `retry-disabled`. */
|
|
5092
5123
|
const PAUSED_STOPS = /* @__PURE__ */ new Set([
|
|
@@ -5116,7 +5147,7 @@ function barrenPauseMs(streak, maxBarren) {
|
|
|
5116
5147
|
*/
|
|
5117
5148
|
const INSTANT_FAILURE_MS = 3e4;
|
|
5118
5149
|
const REPEATED_FAILURE_LIMIT = 10;
|
|
5119
|
-
const REPEATED_FAILURE_WINDOW_MS =
|
|
5150
|
+
const REPEATED_FAILURE_WINDOW_MS = 3e5;
|
|
5120
5151
|
/** Consecutive identical reconciliation failures of one pending invocation that resolve it. */
|
|
5121
5152
|
const SAME_PENDING_LIMIT = 2;
|
|
5122
5153
|
/**
|
|
@@ -5131,7 +5162,7 @@ const SAME_PARTIAL_FAILURE_LIMIT = 2;
|
|
|
5131
5162
|
/**
|
|
5132
5163
|
* Why an aborted run stopped: `deadline` when the root's or the node's own deadline cut it, else
|
|
5133
5164
|
* `aborted`. Read before any failure classification, which calls every failure after an abort
|
|
5134
|
-
* terminal:
|
|
5165
|
+
* terminal: 61 of 62 runs that ended `terminal-error` were a deadline that cut
|
|
5135
5166
|
* a turn.
|
|
5136
5167
|
*/
|
|
5137
5168
|
function abortStop(signal) {
|
|
@@ -5639,8 +5670,7 @@ var DriverRetryLoop = class {
|
|
|
5639
5670
|
return true;
|
|
5640
5671
|
}
|
|
5641
5672
|
};
|
|
5642
|
-
|
|
5643
|
-
//#region src/runtime/supervise/driver-retry.ts
|
|
5673
|
+
// src/runtime/supervise/driver-retry.ts
|
|
5644
5674
|
/**
|
|
5645
5675
|
* Root-driver retry — the root gets the same second chance a worker's transport already has.
|
|
5646
5676
|
*
|
|
@@ -5672,7 +5702,7 @@ var DriverRetryLoop = class {
|
|
|
5672
5702
|
*
|
|
5673
5703
|
* WHAT COUNTS AS PROGRESS was got wrong first. Reading metered spend, settled children and an
|
|
5674
5704
|
* accepted submission measured the filesystem and the meter, never the goal: across 1,422 settled
|
|
5675
|
-
* discovery-lab runs
|
|
5705
|
+
* discovery-lab runs it retried the runs that produced NOTHING 629 of 827 times
|
|
5676
5706
|
* (76.1%) and the runs that HAD left an artifact 21 of 399 times (5.3%). So when the caller
|
|
5677
5707
|
* declares a completion check, spend and settlements alone are NOT progress while it is unmet; only
|
|
5678
5708
|
* a delivery (an accepted submission, a child that passed the check, the contract turning met, or a
|
|
@@ -5690,7 +5720,7 @@ var DriverRetryLoop = class {
|
|
|
5690
5720
|
* `barren-pause` row per pause for an operator alarm, and re-enters. A barren streak never ends the
|
|
5691
5721
|
* run: the check, the deadline, the budget and cancellation do. Progress resets the streak and the
|
|
5692
5722
|
* backoff. There is no count cap and no caller veto (the old prompt-owned loop logged 896 of 1,011
|
|
5693
|
-
* rounds with no progress).
|
|
5723
|
+
* rounds with no progress). The barren bound
|
|
5694
5724
|
* settled a 48-hour run `no-winner` after 14.3 hours, while its last two turns updated its pages
|
|
5695
5725
|
* and waited on its own 2^20 prove.
|
|
5696
5726
|
*
|
|
@@ -5713,7 +5743,7 @@ var DriverRetryLoop = class {
|
|
|
5713
5743
|
* created and then failed its setup (Sandbox's `PartialFailureError`): it meets the same failure on
|
|
5714
5744
|
* every re-entry, so a second identical attempt with no progress stops with `repeated-failure`
|
|
5715
5745
|
* (`SAME_PARTIAL_FAILURE_LIMIT`). A failure that spent tokens without delivering keeps the bounds.
|
|
5716
|
-
*
|
|
5746
|
+
* A Platform restart answered
|
|
5717
5747
|
* `HTTP 502 ... Platform key verification unavailable` from 03:04:34 to 03:09:41Z, and the
|
|
5718
5748
|
* coordinator's twelve attempts ran out at 03:07:12Z with no token spent.
|
|
5719
5749
|
*
|
|
@@ -5731,8 +5761,7 @@ var DriverRetryLoop = class {
|
|
|
5731
5761
|
* still spent pauses again with its own row, and the steer stays queued until a turn reads it.
|
|
5732
5762
|
* After the pause the per-window counters start over and the driver is re-entered: after
|
|
5733
5763
|
* a failure as `driver-failure` with `pausedMs`, after an admission or continuation refusal as the
|
|
5734
|
-
* re-entry it was about to use.
|
|
5735
|
-
* unacceptable!" Measured 2026-10-21 over 259 runs since 10-14: 8 of the 10 stops settled runs that
|
|
5764
|
+
* re-entry it was about to use. Runs must not fail early: over 259 runs, 8 of the 10 stops settled runs that
|
|
5736
5765
|
* nobody solved or stopped, including 17 roots whose harness never streamed.
|
|
5737
5766
|
*/
|
|
5738
5767
|
function assertContinuationPolicy(continuation) {
|
|
@@ -5778,8 +5807,7 @@ async function runDriverWithRetry(run) {
|
|
|
5778
5807
|
if (!await loop.afterCompletion(attempt, before, startedAt)) return;
|
|
5779
5808
|
}
|
|
5780
5809
|
}
|
|
5781
|
-
|
|
5782
|
-
//#region src/runtime/supervise/reentry.ts
|
|
5810
|
+
// src/runtime/supervise/reentry.ts
|
|
5783
5811
|
/** Continuity when nothing is proven: compose the full state. */
|
|
5784
5812
|
const UNPROVEN_CONTINUITY = Object.freeze({
|
|
5785
5813
|
session: "new",
|
|
@@ -5842,7 +5870,7 @@ function composeReentryTask(input) {
|
|
|
5842
5870
|
}
|
|
5843
5871
|
/**
|
|
5844
5872
|
* Why the driver is back, in one clause. The failure's own text stays in the attempt records and
|
|
5845
|
-
* never reaches the driver:
|
|
5873
|
+
* never reaches the driver: a continuation told the details of a provider
|
|
5846
5874
|
* failure spent two of its first four children probing the infrastructure, while its peer, told
|
|
5847
5875
|
* only what to continue, spent all forty-five on the research.
|
|
5848
5876
|
*/
|
|
@@ -5900,8 +5928,7 @@ function taskText(task) {
|
|
|
5900
5928
|
return String(task);
|
|
5901
5929
|
}
|
|
5902
5930
|
}
|
|
5903
|
-
|
|
5904
|
-
//#region src/runtime/supervise/run-traces.ts
|
|
5931
|
+
// src/runtime/supervise/run-traces.ts
|
|
5905
5932
|
/**
|
|
5906
5933
|
* A manager's own run as one trace store: what the continuation's question panel reads.
|
|
5907
5934
|
*
|
|
@@ -6033,8 +6060,7 @@ async function runTraceAnalysisStore(input) {
|
|
|
6033
6060
|
const spans = [...records === void 0 || input.root === void 0 ? [] : rootStreamToolSpans(records, input.root.id), ...(await Promise.all(input.workers.map((worker) => workerSpans(worker, input.blobs)))).flat()];
|
|
6034
6061
|
return spans.length === 0 ? void 0 : toolSpansToTraceAnalysisStore(spans);
|
|
6035
6062
|
}
|
|
6036
|
-
|
|
6037
|
-
//#region src/runtime/supervise/supervisor-manager-turns.ts
|
|
6063
|
+
// src/runtime/supervise/supervisor-manager-turns.ts
|
|
6038
6064
|
/** The finalizer over this act's settled workers; the check it runs is recorded as a check read. */
|
|
6039
6065
|
function managerFinalizer(deps, session) {
|
|
6040
6066
|
const { mcp, controls } = session;
|
|
@@ -6455,8 +6481,7 @@ async function recordManagerAttempt(loop, record) {
|
|
|
6455
6481
|
});
|
|
6456
6482
|
await loop.config.deps.onDriverAttempt?.(record);
|
|
6457
6483
|
}
|
|
6458
|
-
|
|
6459
|
-
//#region src/runtime/supervise/supervisor-external-manager.ts
|
|
6484
|
+
// src/runtime/supervise/supervisor-external-manager.ts
|
|
6460
6485
|
/** EXTERNAL arm: a caller-driven harness uses the coordination verbs over the live scope. */
|
|
6461
6486
|
function externalSupervisorAgent(build) {
|
|
6462
6487
|
const { deps, name } = build;
|
|
@@ -6585,8 +6610,7 @@ async function settleManagerOutput(config, mcp, contractDeclared, finalize, cand
|
|
|
6585
6610
|
}
|
|
6586
6611
|
await mcp.finishAnalysis({ status: "done" });
|
|
6587
6612
|
}
|
|
6588
|
-
|
|
6589
|
-
//#region src/runtime/supervise/supervisor-router-config.ts
|
|
6613
|
+
// src/runtime/supervise/supervisor-router-config.ts
|
|
6590
6614
|
/** Validate a manager's coordination authentication and request limits before execution. */
|
|
6591
6615
|
function assertCoordinationBinding(binding) {
|
|
6592
6616
|
assertCoordinationTransport(binding ?? {});
|
|
@@ -6647,8 +6671,7 @@ function routerBrainFromProfile(profile, router) {
|
|
|
6647
6671
|
...profile.model?.reasoningEffort ? { reasoningEffort: profile.model.reasoningEffort } : {}
|
|
6648
6672
|
});
|
|
6649
6673
|
}
|
|
6650
|
-
|
|
6651
|
-
//#region src/runtime/supervise/supervisor-agent-build.ts
|
|
6674
|
+
// src/runtime/supervise/supervisor-agent-build.ts
|
|
6652
6675
|
function buildSupervisorAgent(profile, deps, testBrain) {
|
|
6653
6676
|
const exactProfile = agentProfileSchema.parse(profile);
|
|
6654
6677
|
assertExecutableAgentProfile(exactProfile, "supervisorAgent");
|
|
@@ -6779,8 +6802,7 @@ function routerSupervisorAgent(arm) {
|
|
|
6779
6802
|
}
|
|
6780
6803
|
};
|
|
6781
6804
|
}
|
|
6782
|
-
|
|
6783
|
-
//#region src/runtime/supervise/supervisor-agent.ts
|
|
6805
|
+
// src/runtime/supervise/supervisor-agent.ts
|
|
6784
6806
|
/** Build a supervisor `Agent` from its profile: the brain resolves from `profile.harness`
|
|
6785
6807
|
* (backend-as-data), the same resolution rule as every worker. */
|
|
6786
6808
|
function supervisorAgent(profile, deps) {
|
|
@@ -6792,8 +6814,7 @@ function supervisorAgentWithTestBrain(profile, deps) {
|
|
|
6792
6814
|
const { brain, ...runtimeDeps } = deps;
|
|
6793
6815
|
return buildSupervisorAgent(profile, runtimeDeps, brain);
|
|
6794
6816
|
}
|
|
6795
|
-
|
|
6796
|
-
//#region src/runtime/supervise/supervise-profile-admission.ts
|
|
6817
|
+
// src/runtime/supervise/supervise-profile-admission.ts
|
|
6797
6818
|
/**
|
|
6798
6819
|
* NOT a harness-name test — `ExecutorConfig.backend` is a discriminated-union TAG naming HOW a
|
|
6799
6820
|
* profile is materialized (bridge / sandbox / cli-worktree / cli-in-place / router / cli /
|
|
@@ -6816,9 +6837,10 @@ function backendProfileMaterialization(backend) {
|
|
|
6816
6837
|
}
|
|
6817
6838
|
}
|
|
6818
6839
|
function assertProfileContract(profile, contract, context, runtimeConsumesCoordinationTools = false) {
|
|
6840
|
+
const materializedProfile = runtimeConsumesCoordinationTools ? providerVisibleProfile(profile) : profile;
|
|
6819
6841
|
assertProfileMaterialization({
|
|
6820
6842
|
contract,
|
|
6821
|
-
changedAxes: profileMaterializationAxes$1(
|
|
6843
|
+
changedAxes: profileMaterializationAxes$1(materializedProfile),
|
|
6822
6844
|
context
|
|
6823
6845
|
});
|
|
6824
6846
|
}
|
|
@@ -6919,6 +6941,7 @@ const routerSupervisorProfileMaterialization = defineProfileMaterializationContr
|
|
|
6919
6941
|
"version",
|
|
6920
6942
|
"tags",
|
|
6921
6943
|
"systemPrompt",
|
|
6944
|
+
"appendSystemPrompt",
|
|
6922
6945
|
"instructions",
|
|
6923
6946
|
"resourceInstructions",
|
|
6924
6947
|
"resourceFailOnError",
|
|
@@ -6957,8 +6980,7 @@ function isExternalSupervisor(profile) {
|
|
|
6957
6980
|
function automaticDriverBackendSupported(backend, coordination) {
|
|
6958
6981
|
return backend.backend === "bridge" || backend.backend === "provider" && !backend.steering && coordination?.authentication !== void 0 && coordination.publicUrl !== void 0;
|
|
6959
6982
|
}
|
|
6960
|
-
|
|
6961
|
-
//#region src/runtime/supervise/nested-manager-deps.ts
|
|
6983
|
+
// src/runtime/supervise/nested-manager-deps.ts
|
|
6962
6984
|
/** Deps for the nested manager of a managed child: coordination wiring, policy and controls. */
|
|
6963
6985
|
function buildNestedManagerDeps(child) {
|
|
6964
6986
|
const { env, seat, admitted, spawnContext } = child;
|
|
@@ -7092,8 +7114,7 @@ function nestedLogAndControlDeps(child) {
|
|
|
7092
7114
|
...options.runDir === void 0 && options.steerDir === void 0 ? {} : { controlScope: "subtree" }
|
|
7093
7115
|
};
|
|
7094
7116
|
}
|
|
7095
|
-
|
|
7096
|
-
//#region src/runtime/supervise/supervise-runtime-attachments.ts
|
|
7117
|
+
// src/runtime/supervise/supervise-runtime-attachments.ts
|
|
7097
7118
|
/**
|
|
7098
7119
|
* The reserved MCP alias one worker's PEER MAIL capability endpoint mounts under.
|
|
7099
7120
|
*
|
|
@@ -7164,13 +7185,12 @@ async function providerAcceptsCoordinationAttachments(backend) {
|
|
|
7164
7185
|
* A manager waits between turns, and a wake can come much later than five minutes after its last
|
|
7165
7186
|
* turn. Claude Code 2.1.289 writes its prompt cache with a five-minute lifetime unless this variable
|
|
7166
7187
|
* is set; a wake after the cache expired re-writes the manager's whole context, about 140K tokens
|
|
7167
|
-
* per turn on a Discovery root
|
|
7188
|
+
* per turn on a Discovery root. That root ran on a subscription and already
|
|
7168
7189
|
* wrote one-hour entries; the variable makes the hour hold for every claude-code manager, whatever
|
|
7169
7190
|
* its credential. A value the caller set wins.
|
|
7170
7191
|
*/
|
|
7171
7192
|
const CLAUDE_CODE_ONE_HOUR_CACHE = "ENABLE_PROMPT_CACHING_1H";
|
|
7172
|
-
|
|
7173
|
-
//#region src/runtime/supervise/supervise-worker-backend.ts
|
|
7193
|
+
// src/runtime/supervise/supervise-worker-backend.ts
|
|
7174
7194
|
/**
|
|
7175
7195
|
* Build the worker seam from a backend (WHERE workers run) + an optional completion oracle (the
|
|
7176
7196
|
* deliverable check that makes "settled ⟺ delivered" true — the guard against "ran but didn't
|
|
@@ -7216,7 +7236,7 @@ function workerFromBackend(backend, deliverable, seams) {
|
|
|
7216
7236
|
const boundSessionId = boundBackend.backend === "bridge" ? boundBackend.sessionId : void 0;
|
|
7217
7237
|
const peerMailAttachment = peerMailRuntimeAttachment(profile, capturedBackend, spawnContext);
|
|
7218
7238
|
if (spawnContext?.peerMailUrl && boundBackend.backend === "provider" && Object.hasOwn(boundBackend.defaults?.runtimeAttachments?.mcp ?? {}, "agent-runtime-peer-mail")) throw new ValidationError("workerFromBackend: provider defaults contain the reserved peer-mail attachment alias");
|
|
7219
|
-
const
|
|
7239
|
+
const leafBackend = spawnContext?.peerMailUrl && boundBackend.backend === "provider" ? {
|
|
7220
7240
|
...boundBackend,
|
|
7221
7241
|
steering: boundBackend.steering ?? {},
|
|
7222
7242
|
defaults: {
|
|
@@ -7232,7 +7252,8 @@ function workerFromBackend(backend, deliverable, seams) {
|
|
|
7232
7252
|
}
|
|
7233
7253
|
}
|
|
7234
7254
|
}
|
|
7235
|
-
} : boundBackend
|
|
7255
|
+
} : boundBackend;
|
|
7256
|
+
const rawFactory = createExecutor(leafBackend);
|
|
7236
7257
|
const baseFactory = deliverable ? gateFactoryOnDeliverable(rawFactory, deliverable) : rawFactory;
|
|
7237
7258
|
const executorFactory = (spec, ctx) => {
|
|
7238
7259
|
if (boundSessionId !== void 0 && ctx.node?.nodeId !== void 0) bridgeSessionByWorker.set(ctx.node.nodeId, boundSessionId);
|
|
@@ -7318,8 +7339,7 @@ function withModelSubstitution(agent, substitution) {
|
|
|
7318
7339
|
}
|
|
7319
7340
|
};
|
|
7320
7341
|
}
|
|
7321
|
-
|
|
7322
|
-
//#region src/runtime/supervise/spawn-admission.ts
|
|
7342
|
+
// src/runtime/supervise/spawn-admission.ts
|
|
7323
7343
|
/** Authorize one spawn and decide everything about it that does not depend on how it runs. */
|
|
7324
7344
|
function admitSpawn(env, seat, authoredProfile, spawnContext, recovering) {
|
|
7325
7345
|
const { options, applyTraceTools, deliverable } = env.setup;
|
|
@@ -7371,7 +7391,10 @@ function admitSpawn(env, seat, authoredProfile, spawnContext, recovering) {
|
|
|
7371
7391
|
depth
|
|
7372
7392
|
});
|
|
7373
7393
|
const security = validateAgentProfileSecurity(authorized, env.securityPolicy);
|
|
7374
|
-
if (!security.ok)
|
|
7394
|
+
if (!security.ok) {
|
|
7395
|
+
const details = security.issues.filter((issue) => issue.level === "error").map((issue) => `${issue.code}${issue.path ? ` at ${issue.path}` : ""}`).join(", ");
|
|
7396
|
+
throw new ValidationError(`supervise: spawned AgentProfile refused: ${details}`);
|
|
7397
|
+
}
|
|
7375
7398
|
assertProfileModelsAllowed(authorized, options.allowedModels);
|
|
7376
7399
|
const selectedDeliverable = options.resolveDeliverable?.(postAuthorizationContext);
|
|
7377
7400
|
const childDeliverable = selectedDeliverable === void 0 ? deliverable : selectedDeliverable === null ? void 0 : captureDeliverable(selectedDeliverable, `supervise deliverable for ${JSON.stringify(spawnContext.label)}`);
|
|
@@ -7387,8 +7410,228 @@ function admitSpawn(env, seat, authoredProfile, spawnContext, recovering) {
|
|
|
7387
7410
|
usesRuntimeCoordination: declaredRuntimeToolNames(authorized).length > 0 || seatManagedLeaf
|
|
7388
7411
|
};
|
|
7389
7412
|
}
|
|
7390
|
-
|
|
7391
|
-
|
|
7413
|
+
// src/runtime/supervise/graph-file-schema.ts
|
|
7414
|
+
const scalar = z.union([
|
|
7415
|
+
z.string(),
|
|
7416
|
+
z.number().finite(),
|
|
7417
|
+
z.boolean(),
|
|
7418
|
+
z.null()
|
|
7419
|
+
]);
|
|
7420
|
+
const pointer = z.string().regex(/^(?:\/(?:[^~]|~[01])*)*$/);
|
|
7421
|
+
const matchBase = {
|
|
7422
|
+
node: z.string().min(1).optional(),
|
|
7423
|
+
pointer
|
|
7424
|
+
};
|
|
7425
|
+
const equals = z.strictObject({
|
|
7426
|
+
...matchBase,
|
|
7427
|
+
equals: scalar
|
|
7428
|
+
});
|
|
7429
|
+
const oneOf = z.strictObject({
|
|
7430
|
+
...matchBase,
|
|
7431
|
+
in: z.array(scalar)
|
|
7432
|
+
});
|
|
7433
|
+
const exists = z.strictObject({
|
|
7434
|
+
...matchBase,
|
|
7435
|
+
exists: z.boolean()
|
|
7436
|
+
});
|
|
7437
|
+
const match = z.union([
|
|
7438
|
+
equals,
|
|
7439
|
+
oneOf,
|
|
7440
|
+
exists
|
|
7441
|
+
]);
|
|
7442
|
+
/** The same data grammar as routes; no executable expressions or additional operators. */
|
|
7443
|
+
const graphRouteWhenSchema = z.union([match, z.strictObject({ all: z.array(match).min(1) })]);
|
|
7444
|
+
const parameter = z.strictObject({
|
|
7445
|
+
default: z.unknown().optional(),
|
|
7446
|
+
type: z.enum([
|
|
7447
|
+
"string",
|
|
7448
|
+
"number",
|
|
7449
|
+
"integer",
|
|
7450
|
+
"boolean",
|
|
7451
|
+
"object",
|
|
7452
|
+
"array",
|
|
7453
|
+
"null"
|
|
7454
|
+
]).optional()
|
|
7455
|
+
});
|
|
7456
|
+
const command = z.strictObject({
|
|
7457
|
+
command: z.string().min(1),
|
|
7458
|
+
timeoutMs: z.number().int().positive().optional()
|
|
7459
|
+
});
|
|
7460
|
+
const nonnegativeInteger = z.number().int().nonnegative();
|
|
7461
|
+
/** Authoring envelope. Canonical profiles and topology are validated by their existing owners. */
|
|
7462
|
+
const graphFileSchema = z.strictObject({
|
|
7463
|
+
digest: z.string().min(1).optional(),
|
|
7464
|
+
graph: z.string().min(1).optional(),
|
|
7465
|
+
describe: z.string().optional(),
|
|
7466
|
+
params: z.record(z.string().min(1), parameter).optional(),
|
|
7467
|
+
nodes: z.array(z.strictObject({
|
|
7468
|
+
id: z.string().min(1),
|
|
7469
|
+
profile: z.record(z.string(), z.unknown()).optional(),
|
|
7470
|
+
seat: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]).optional(),
|
|
7471
|
+
needs: z.array(z.string().min(1)).optional()
|
|
7472
|
+
})).min(1),
|
|
7473
|
+
entry: z.array(z.union([z.string().min(1), z.strictObject({
|
|
7474
|
+
node: z.string().min(1),
|
|
7475
|
+
task: z.unknown()
|
|
7476
|
+
})])).min(1).optional(),
|
|
7477
|
+
edges: z.array(z.record(z.string(), z.unknown())),
|
|
7478
|
+
gates: z.array(z.unknown()).optional(),
|
|
7479
|
+
budget: z.strictObject({
|
|
7480
|
+
maxIterations: nonnegativeInteger,
|
|
7481
|
+
maxTokens: nonnegativeInteger,
|
|
7482
|
+
maxUsd: z.number().finite().nonnegative().optional(),
|
|
7483
|
+
deadlineMs: nonnegativeInteger.optional(),
|
|
7484
|
+
resources: z.record(z.string(), z.strictObject({
|
|
7485
|
+
unit: z.string().min(1),
|
|
7486
|
+
limit: nonnegativeInteger
|
|
7487
|
+
})).optional()
|
|
7488
|
+
}),
|
|
7489
|
+
check: z.union([
|
|
7490
|
+
equals.extend({ describe: z.string().optional() }),
|
|
7491
|
+
oneOf.extend({ describe: z.string().optional() }),
|
|
7492
|
+
exists.extend({ describe: z.string().optional() }),
|
|
7493
|
+
z.strictObject({
|
|
7494
|
+
describe: z.string().optional(),
|
|
7495
|
+
all: z.array(match).min(1)
|
|
7496
|
+
}),
|
|
7497
|
+
z.strictObject({
|
|
7498
|
+
describe: z.string().optional(),
|
|
7499
|
+
command
|
|
7500
|
+
})
|
|
7501
|
+
]).optional(),
|
|
7502
|
+
deliverable: z.strictObject({
|
|
7503
|
+
describe: z.string().optional(),
|
|
7504
|
+
checkRef: z.string().min(1),
|
|
7505
|
+
command: command.optional(),
|
|
7506
|
+
when: graphRouteWhenSchema.optional()
|
|
7507
|
+
}).optional(),
|
|
7508
|
+
on: z.unknown().optional()
|
|
7509
|
+
});
|
|
7510
|
+
/** Judge the flow's terminal-output map with RouteWhen's own JSON-pointer semantics. */
|
|
7511
|
+
function checkGraphRoute(when, output) {
|
|
7512
|
+
return ("all" in when ? when.all : [when]).every((condition) => {
|
|
7513
|
+
let document = output;
|
|
7514
|
+
if (condition.node !== void 0) {
|
|
7515
|
+
if (!output || typeof output !== "object" || !Object.hasOwn(output, condition.node)) return false;
|
|
7516
|
+
document = output[condition.node];
|
|
7517
|
+
}
|
|
7518
|
+
const selected = resolveJsonPointer(document, condition.pointer);
|
|
7519
|
+
if ("exists" in condition) return selected.found === condition.exists;
|
|
7520
|
+
if (!selected.found) return false;
|
|
7521
|
+
return "equals" in condition ? selected.value === condition.equals : condition.in.some((value) => value === selected.value);
|
|
7522
|
+
});
|
|
7523
|
+
}
|
|
7524
|
+
// src/runtime/supervise/graph-parameters.ts
|
|
7525
|
+
const triggerPart = z.strictObject({ trigger: z.array(z.string()).min(1) });
|
|
7526
|
+
const literalPart = z.strictObject({ literal: z.string() });
|
|
7527
|
+
/** Explicit authored trigger slots in compiled graph data. An empty list marks fully bound data. */
|
|
7528
|
+
const graphTriggerBindingsSchema = z.array(z.strictObject({
|
|
7529
|
+
path: z.array(z.union([z.string(), z.number().int().nonnegative()])).min(1),
|
|
7530
|
+
mode: z.enum(["value", "text"]),
|
|
7531
|
+
parts: z.array(z.union([literalPart, triggerPart])).min(1)
|
|
7532
|
+
}).superRefine((slot, context) => {
|
|
7533
|
+
if (!slot.parts.some((part) => "trigger" in part) || slot.mode === "value" && (slot.parts.length !== 1 || !("trigger" in slot.parts[0]))) context.addIssue({
|
|
7534
|
+
code: "custom",
|
|
7535
|
+
message: "binding requires authored trigger parts; value slots require one trigger"
|
|
7536
|
+
});
|
|
7537
|
+
}));
|
|
7538
|
+
function readBinding(namespace, keys, bindings) {
|
|
7539
|
+
let found = bindings[namespace];
|
|
7540
|
+
for (const key of keys) {
|
|
7541
|
+
if (!found || typeof found !== "object" || !Object.hasOwn(found, key)) throw new ValidationError(`graph parameters: missing ${[namespace, ...keys].join(".")}`);
|
|
7542
|
+
found = found[key];
|
|
7543
|
+
}
|
|
7544
|
+
if (found === void 0) throw new ValidationError(`graph parameters: missing ${[namespace, ...keys].join(".")}`);
|
|
7545
|
+
return structuredClone(found);
|
|
7546
|
+
}
|
|
7547
|
+
function textValue(value, expression) {
|
|
7548
|
+
if (value !== null && typeof value === "object") throw new ValidationError(`graph parameters: ${expression} needs a whole JSON slot`);
|
|
7549
|
+
return String(value);
|
|
7550
|
+
}
|
|
7551
|
+
function pendingText(parts) {
|
|
7552
|
+
return parts.map((part) => "literal" in part ? part.literal : `\${trigger.${part.trigger.join(".")}}`).join("");
|
|
7553
|
+
}
|
|
7554
|
+
/** Compile authored slots once. Inserted values are data, never recursively parsed templates. */
|
|
7555
|
+
function compileGraphParameters(value, bindings, options = {}) {
|
|
7556
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
7557
|
+
const triggerBindings = [];
|
|
7558
|
+
const bind = (item, path) => {
|
|
7559
|
+
if (typeof item === "string") {
|
|
7560
|
+
if (item.replace(/\$\{[^{}]+\}/g, "").includes("${")) throw new ValidationError("graph parameters: malformed reference");
|
|
7561
|
+
const whole = /^\$\{([^{}]+)\}$/.exec(item);
|
|
7562
|
+
const parts = [];
|
|
7563
|
+
let cursor = 0;
|
|
7564
|
+
let wholeValue;
|
|
7565
|
+
let boundWhole = false;
|
|
7566
|
+
for (const match of item.matchAll(/\$\{([^{}]+)\}/g)) {
|
|
7567
|
+
if (match.index > cursor) parts.push({ literal: item.slice(cursor, match.index) });
|
|
7568
|
+
const [namespace, ...keys] = match[1].split(".");
|
|
7569
|
+
if (namespace !== "params" && namespace !== "trigger" || keys.length === 0) throw new ValidationError(`graph parameters: unsupported reference \${${match[1]}}`);
|
|
7570
|
+
if (options.defer?.includes(namespace)) {
|
|
7571
|
+
if (namespace === "trigger") parts.push({ trigger: keys });
|
|
7572
|
+
else parts.push({ literal: match[0] });
|
|
7573
|
+
} else {
|
|
7574
|
+
const found = readBinding(namespace, keys, bindings);
|
|
7575
|
+
if (whole) {
|
|
7576
|
+
wholeValue = found;
|
|
7577
|
+
boundWhole = true;
|
|
7578
|
+
} else parts.push({ literal: textValue(found, match[1]) });
|
|
7579
|
+
}
|
|
7580
|
+
cursor = match.index + match[0].length;
|
|
7581
|
+
}
|
|
7582
|
+
if (boundWhole) return wholeValue;
|
|
7583
|
+
if (cursor === 0) return item;
|
|
7584
|
+
if (cursor < item.length) parts.push({ literal: item.slice(cursor) });
|
|
7585
|
+
if (parts.some((part) => "trigger" in part)) triggerBindings.push({
|
|
7586
|
+
path,
|
|
7587
|
+
mode: whole ? "value" : "text",
|
|
7588
|
+
parts
|
|
7589
|
+
});
|
|
7590
|
+
return pendingText(parts);
|
|
7591
|
+
}
|
|
7592
|
+
if (!item || typeof item !== "object") return item;
|
|
7593
|
+
if (visiting.has(item)) throw new ValidationError("graph parameters: cyclic data is not JSON");
|
|
7594
|
+
visiting.add(item);
|
|
7595
|
+
const bound = Array.isArray(item) ? item.map((child, index) => bind(child, [...path, index])) : Object.fromEntries(Object.entries(item).map(([key, child]) => [key, bind(child, [...path, key])]));
|
|
7596
|
+
visiting.delete(item);
|
|
7597
|
+
return bound;
|
|
7598
|
+
};
|
|
7599
|
+
return {
|
|
7600
|
+
value: bind(value, []),
|
|
7601
|
+
triggerBindings
|
|
7602
|
+
};
|
|
7603
|
+
}
|
|
7604
|
+
/** Legacy authored-data binding. Compiled graphs use bindCompiledGraphTriggers instead. */
|
|
7605
|
+
function bindGraphParameters(value, bindings, options = {}) {
|
|
7606
|
+
return compileGraphParameters(value, bindings, options).value;
|
|
7607
|
+
}
|
|
7608
|
+
/** Check provenance against the exact provisional values without reading trigger data. */
|
|
7609
|
+
function assertGraphTriggerBindings(value, slots) {
|
|
7610
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7611
|
+
for (const slot of graphTriggerBindingsSchema.parse(slots)) {
|
|
7612
|
+
const key = JSON.stringify(slot.path.map(String));
|
|
7613
|
+
if (seen.has(key)) throw new ValidationError("graph parameters: duplicate trigger binding path");
|
|
7614
|
+
seen.add(key);
|
|
7615
|
+
let found = value;
|
|
7616
|
+
for (const key of slot.path) {
|
|
7617
|
+
if (!found || typeof found !== "object" || !Object.hasOwn(found, key)) throw new ValidationError("graph parameters: trigger binding path does not exist");
|
|
7618
|
+
found = found[key];
|
|
7619
|
+
}
|
|
7620
|
+
if (found !== pendingText(slot.parts)) throw new ValidationError("graph parameters: trigger binding does not match its provisional value");
|
|
7621
|
+
}
|
|
7622
|
+
}
|
|
7623
|
+
/** Only explicitly recorded authored slots bind. Literal parameter/trigger values are untouched. */
|
|
7624
|
+
function bindCompiledGraphTriggers(value, slots, trigger) {
|
|
7625
|
+
assertGraphTriggerBindings(value, slots);
|
|
7626
|
+
const bound = structuredClone(value);
|
|
7627
|
+
for (const slot of slots) {
|
|
7628
|
+
let parent = bound;
|
|
7629
|
+
for (const key of slot.path.slice(0, -1)) parent = parent[key];
|
|
7630
|
+
parent[slot.path.at(-1)] = slot.mode === "value" ? readBinding("trigger", slot.parts[0].trigger, { trigger }) : slot.parts.map((part) => "literal" in part ? part.literal : textValue(readBinding("trigger", part.trigger, { trigger }), `trigger.${part.trigger.join(".")}`)).join("");
|
|
7631
|
+
}
|
|
7632
|
+
return bound;
|
|
7633
|
+
}
|
|
7634
|
+
// src/runtime/supervise/graph-registry.ts
|
|
7392
7635
|
/**
|
|
7393
7636
|
* `graph-registry` — the designer's memory: graphs and their outcomes as files.
|
|
7394
7637
|
*
|
|
@@ -7415,6 +7658,7 @@ function admitSpawn(env, seat, authoredProfile, spawnContext, recovering) {
|
|
|
7415
7658
|
*/
|
|
7416
7659
|
var graph_registry_exports = /* @__PURE__ */ __exportAll({
|
|
7417
7660
|
digestOfGraph: () => digestOfGraph,
|
|
7661
|
+
graphCorpusSummary: () => graphCorpusSummary,
|
|
7418
7662
|
graphDigest: () => graphDigest,
|
|
7419
7663
|
graphFromStored: () => graphFromStored,
|
|
7420
7664
|
graphRegistry: () => graphRegistry,
|
|
@@ -7424,6 +7668,7 @@ var graph_registry_exports = /* @__PURE__ */ __exportAll({
|
|
|
7424
7668
|
lookupGraph: () => lookupGraph,
|
|
7425
7669
|
pickBestGraph: () => pickBestGraph,
|
|
7426
7670
|
recordGraphRun: () => recordGraphRun,
|
|
7671
|
+
recordStoredGraphRun: () => recordStoredGraphRun,
|
|
7427
7672
|
storedGraphDigests: () => storedGraphDigests,
|
|
7428
7673
|
taskShapeDigest: () => taskShapeDigest
|
|
7429
7674
|
});
|
|
@@ -7452,11 +7697,18 @@ function digestOfGraph(graph) {
|
|
|
7452
7697
|
return storeGraph(graph).digest;
|
|
7453
7698
|
}
|
|
7454
7699
|
function storeGraph(graph) {
|
|
7700
|
+
const { describe, checkRef, command, when } = graph.deliverable;
|
|
7455
7701
|
const content = {
|
|
7456
7702
|
nodes: graph.nodes,
|
|
7457
7703
|
edges: graph.edges,
|
|
7458
7704
|
budget: graph.budget,
|
|
7459
|
-
|
|
7705
|
+
...graph.triggerBindings === void 0 ? {} : { triggerBindings: graph.triggerBindings },
|
|
7706
|
+
deliverable: {
|
|
7707
|
+
...describe ? { describe } : {},
|
|
7708
|
+
...checkRef ? { checkRef } : {},
|
|
7709
|
+
...command ? { command } : {},
|
|
7710
|
+
...when ? { when } : {}
|
|
7711
|
+
},
|
|
7460
7712
|
...graph.entry === void 0 ? {} : { entry: graph.entry },
|
|
7461
7713
|
...graph.gates === void 0 ? {} : { gates: graph.gates }
|
|
7462
7714
|
};
|
|
@@ -7468,10 +7720,26 @@ function storeGraph(graph) {
|
|
|
7468
7720
|
function assertRecord(record) {
|
|
7469
7721
|
if (typeof record.graphDigest !== "string" || record.graphDigest.length === 0) throw new ValidationError("graph-registry: record.graphDigest is required");
|
|
7470
7722
|
if (typeof record.taskDigest !== "string" || record.taskDigest.length === 0) throw new ValidationError("graph-registry: record.taskDigest is required");
|
|
7471
|
-
if (
|
|
7723
|
+
if (!Number.isFinite(Date.parse(record.startedAt))) throw new ValidationError("graph-registry: record.startedAt must be a timestamp");
|
|
7724
|
+
if (![
|
|
7725
|
+
"delivered",
|
|
7726
|
+
"no-winner",
|
|
7727
|
+
"unknown",
|
|
7728
|
+
"running"
|
|
7729
|
+
].includes(record.outcome.kind)) throw new ValidationError("graph-registry: invalid record.outcome.kind");
|
|
7730
|
+
if ((record.outcome.kind === "delivered" || record.outcome.kind === "no-winner") && (!record.finishedAt || !Number.isFinite(Date.parse(record.finishedAt)))) throw new ValidationError("graph-registry: terminal outcomes require record.finishedAt");
|
|
7731
|
+
if ((record.outcome.kind === "unknown" || record.outcome.kind === "running") && !record.outcome.reason) throw new ValidationError("graph-registry: incomplete outcomes require a reason");
|
|
7732
|
+
if (record.source && (!record.source.kind || !record.source.id)) throw new ValidationError("graph-registry: source.kind and source.id are required");
|
|
7733
|
+
if (record.finishedAt && (!Number.isFinite(Date.parse(record.finishedAt)) || Date.parse(record.finishedAt) < Date.parse(record.startedAt))) throw new ValidationError("graph-registry: finishedAt precedes startedAt or is invalid");
|
|
7734
|
+
for (const [channel, value] of Object.entries(record.cost)) if (value !== void 0 && (typeof value !== "number" || !Number.isFinite(value) || value < 0)) throw new ValidationError(`graph-registry: invalid cost.${channel}`);
|
|
7472
7735
|
}
|
|
7473
7736
|
function recordKey(record) {
|
|
7474
7737
|
assertRecord(record);
|
|
7738
|
+
if (record.source) return JSON.stringify([
|
|
7739
|
+
"source",
|
|
7740
|
+
record.source.kind,
|
|
7741
|
+
record.source.id
|
|
7742
|
+
]);
|
|
7475
7743
|
return JSON.stringify([
|
|
7476
7744
|
record.taskDigest,
|
|
7477
7745
|
record.graphDigest,
|
|
@@ -7488,27 +7756,161 @@ function graphRegistry(root) {
|
|
|
7488
7756
|
* Idempotent per (taskDigest, graphDigest, startedAt): a replayed append with
|
|
7489
7757
|
* the same key replaces the prior row rather than duplicating it. */
|
|
7490
7758
|
async function recordGraphRun(reg, graph, record) {
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7759
|
+
return recordStoredGraphRun(reg, storeGraph(graph), record);
|
|
7760
|
+
}
|
|
7761
|
+
/** Store an executable graph or an observed external topology in the same registry.
|
|
7762
|
+
* Imported observations retain their source identity and never authorize replay.
|
|
7763
|
+
* A reader refreshing facts can preserve independently joined labels; an explicit
|
|
7764
|
+
* correction leaves preserveLabels unset and replaces the record. */
|
|
7765
|
+
async function recordStoredGraphRun(reg, definition, record, options = {}) {
|
|
7766
|
+
const { digest, ...content } = definition;
|
|
7767
|
+
const stored = {
|
|
7768
|
+
...content,
|
|
7769
|
+
digest: digest ?? graphDigest(content)
|
|
7770
|
+
};
|
|
7771
|
+
if (stored.observed && !record) throw new ValidationError("graph-registry: observed graphs require a source run identity");
|
|
7772
|
+
if (record) {
|
|
7773
|
+
assertRecord(record);
|
|
7774
|
+
if (stored.observed && !record.source) throw new ValidationError("graph-registry: observed graphs require a source run identity");
|
|
7775
|
+
if (!stored.observed && !record.finishedAt) throw new ValidationError("graph-registry: native graph runs require a completion timestamp");
|
|
7776
|
+
if ((!stored.observed || record.traversals !== void 0) && (!Number.isSafeInteger(record.traversals) || record.traversals < 0)) throw new ValidationError("graph-registry: native graphs require metered traversals; observed counts must be non-negative integers");
|
|
7777
|
+
if (stored.digest !== record.graphDigest) throw new ValidationError(`graph-registry: record.graphDigest ${record.graphDigest} does not match the supplied graph (${stored.digest}) — record the graph that actually ran`);
|
|
7778
|
+
}
|
|
7779
|
+
if (graphDigest(content) !== stored.digest) throw new ValidationError("graph-registry: stored graph content does not match its digest");
|
|
7494
7780
|
await mkdir(join(reg.root, GRAPHS_DIR), { recursive: true });
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7781
|
+
const file = join(reg.root, RECORDS_FILE);
|
|
7782
|
+
return withJsonlFileLock(file, async (canonicalPath) => {
|
|
7783
|
+
if (!record) {
|
|
7784
|
+
await persistGraph(reg, stored);
|
|
7785
|
+
return stored;
|
|
7786
|
+
}
|
|
7787
|
+
let persisted = record;
|
|
7788
|
+
if (options.preserveLabels && record.source) {
|
|
7789
|
+
const prior = (await readCommittedJsonFile(canonicalPath)).find((row) => row.source?.kind === record.source.kind && row.source.id === record.source.id);
|
|
7790
|
+
if (prior) {
|
|
7791
|
+
const taskType = record.taskType ?? prior.taskType;
|
|
7792
|
+
const priorTerminal = prior.outcome.kind === "delivered" || prior.outcome.kind === "no-winner";
|
|
7793
|
+
const incomingUnassessed = record.outcome.kind === "unknown" || record.outcome.kind === "running";
|
|
7794
|
+
if (priorTerminal && incomingUnassessed && prior.startedAt !== record.startedAt) throw new ValidationError("graph-registry: preserving labels requires the same task start and source identity");
|
|
7795
|
+
const evidence = [...prior.evidence ?? [], ...record.evidence ?? []];
|
|
7796
|
+
persisted = {
|
|
7797
|
+
...record,
|
|
7798
|
+
...taskType ? { taskType } : {},
|
|
7799
|
+
...record.unknowns ? { unknowns: record.unknowns.filter((reason) => !(taskType && reason === "task type not explicitly labeled")) } : {},
|
|
7800
|
+
...evidence.length ? { evidence: [...new Map(evidence.map((entry) => [canonicalJson$1(entry), entry])).values()] } : {},
|
|
7801
|
+
...priorTerminal && incomingUnassessed ? {
|
|
7802
|
+
outcome: prior.outcome,
|
|
7803
|
+
finishedAt: prior.finishedAt,
|
|
7804
|
+
cost: {
|
|
7805
|
+
...record.cost,
|
|
7806
|
+
...prior.cost.ms === void 0 ? {} : { ms: prior.cost.ms },
|
|
7807
|
+
...prior.cost.mergeMs === void 0 ? {} : { mergeMs: prior.cost.mergeMs }
|
|
7808
|
+
}
|
|
7809
|
+
} : {}
|
|
7810
|
+
};
|
|
7811
|
+
}
|
|
7812
|
+
}
|
|
7813
|
+
assertRecord(persisted);
|
|
7814
|
+
await persistGraph(reg, stored);
|
|
7815
|
+
await upsertCommittedJsonLine(canonicalPath, persisted, recordKey);
|
|
7498
7816
|
return stored;
|
|
7499
7817
|
});
|
|
7500
7818
|
}
|
|
7819
|
+
async function persistGraph(reg, stored) {
|
|
7820
|
+
const revisionPath = join(reg.root, GRAPHS_DIR, `${stored.digest}.json`);
|
|
7821
|
+
try {
|
|
7822
|
+
const { digest: existingDigest, ...existing } = JSON.parse(await readFile(revisionPath, "utf8"));
|
|
7823
|
+
if (existingDigest !== stored.digest || graphDigest(existing) !== stored.digest) throw new ValidationError("graph-registry: stored graph revision is immutable but its content differs");
|
|
7824
|
+
} catch (error) {
|
|
7825
|
+
if (!isNoEntError(error)) throw error;
|
|
7826
|
+
writeAtomicDurableFile(revisionPath, JSON.stringify(stored), { preserveMode: true });
|
|
7827
|
+
}
|
|
7828
|
+
}
|
|
7501
7829
|
/** All records, newest last. */
|
|
7502
7830
|
async function listGraphRuns(reg) {
|
|
7503
7831
|
return readCommittedJsonFile(join(reg.root, RECORDS_FILE));
|
|
7504
7832
|
}
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7833
|
+
function observedTopology(record) {
|
|
7834
|
+
return record.topologyDigest ?? (record.source ? "unknown" : record.graphDigest);
|
|
7835
|
+
}
|
|
7836
|
+
/** Records for one task shape or deterministic label query, newest last. */
|
|
7837
|
+
async function graphRunsFor(reg, query = {}) {
|
|
7838
|
+
const filters = typeof query === "string" ? { taskDigest: query } : query;
|
|
7839
|
+
return (await listGraphRuns(reg)).filter((row) => (filters.taskDigest === void 0 || row.taskDigest === filters.taskDigest) && (filters.taskType === void 0 || (row.taskType ?? "unknown") === filters.taskType) && (filters.topologyDigest === void 0 || observedTopology(row) === filters.topologyDigest) && (filters.sourceKind === void 0 || (row.source?.kind ?? "native") === filters.sourceKind));
|
|
7840
|
+
}
|
|
7841
|
+
function medianKnown(values) {
|
|
7842
|
+
const known = values.filter((value) => value !== void 0 && Number.isFinite(value) && value >= 0).sort((a, b) => a - b);
|
|
7843
|
+
const middle = Math.floor(known.length / 2);
|
|
7844
|
+
return {
|
|
7845
|
+
count: known.length,
|
|
7846
|
+
median: known.length === 0 ? null : known.length % 2 ? known[middle] : (known[middle - 1] + known[middle]) / 2
|
|
7847
|
+
};
|
|
7848
|
+
}
|
|
7849
|
+
function observedGraphSummary(records) {
|
|
7850
|
+
const groups = /* @__PURE__ */ new Map();
|
|
7851
|
+
for (const record of records) {
|
|
7852
|
+
const key = JSON.stringify([record.taskType ?? "unknown", observedTopology(record)]);
|
|
7853
|
+
const rows = groups.get(key);
|
|
7854
|
+
if (rows) rows.push(record);
|
|
7855
|
+
else groups.set(key, [record]);
|
|
7856
|
+
}
|
|
7857
|
+
const summaries = [...groups.values()].map((runs) => {
|
|
7858
|
+
const assessed = runs.filter((run) => run.outcome.kind === "delivered" || run.outcome.kind === "no-winner");
|
|
7859
|
+
const delivered = assessed.filter((run) => run.outcome.kind === "delivered");
|
|
7860
|
+
const wall = medianKnown(assessed.map((run) => run.cost.ms));
|
|
7861
|
+
const merge = medianKnown(delivered.filter((run) => run.evidence?.some((entry) => entry.kind === "pr-merged")).map((run) => run.cost.mergeMs));
|
|
7862
|
+
const tokens = medianKnown(assessed.map((run) => run.cost.tokens));
|
|
7863
|
+
const human = medianKnown(assessed.map((run) => run.cost.humanMessages));
|
|
7864
|
+
return {
|
|
7865
|
+
taskType: runs[0].taskType ?? "unknown",
|
|
7866
|
+
topologyDigest: observedTopology(runs[0]),
|
|
7867
|
+
delivered: delivered.length,
|
|
7868
|
+
assessed: assessed.length,
|
|
7869
|
+
unknown: runs.length - assessed.length,
|
|
7870
|
+
deliveredRate: assessed.length ? delivered.length / assessed.length : null,
|
|
7871
|
+
medianWallMs: wall.median,
|
|
7872
|
+
wallMsCount: wall.count,
|
|
7873
|
+
medianMergeMs: merge.median,
|
|
7874
|
+
mergeMsCount: merge.count,
|
|
7875
|
+
medianTokens: tokens.median,
|
|
7876
|
+
tokenCount: tokens.count,
|
|
7877
|
+
medianHumanMessages: human.median,
|
|
7878
|
+
humanMessageCount: human.count,
|
|
7879
|
+
runs
|
|
7880
|
+
};
|
|
7881
|
+
});
|
|
7882
|
+
summaries.sort((a, b) => {
|
|
7883
|
+
const delivered = (b.deliveredRate ?? -1) - (a.deliveredRate ?? -1);
|
|
7884
|
+
if (delivered) return delivered;
|
|
7885
|
+
for (const key of [
|
|
7886
|
+
"medianWallMs",
|
|
7887
|
+
"medianTokens",
|
|
7888
|
+
"medianHumanMessages"
|
|
7889
|
+
]) {
|
|
7890
|
+
if (a[key] === b[key]) continue;
|
|
7891
|
+
if (a[key] === null) return 1;
|
|
7892
|
+
if (b[key] === null) return -1;
|
|
7893
|
+
return a[key] - b[key];
|
|
7894
|
+
}
|
|
7895
|
+
return a.taskType.localeCompare(b.taskType) || a.topologyDigest.localeCompare(b.topologyDigest);
|
|
7896
|
+
});
|
|
7897
|
+
return {
|
|
7898
|
+
recordCount: records.length,
|
|
7899
|
+
groups: summaries
|
|
7900
|
+
};
|
|
7901
|
+
}
|
|
7902
|
+
/** Query and rank the same registry records using the opt-in observational
|
|
7903
|
+
* policy: delivery rate, wall time, tokens, then human messages; unknowns last. */
|
|
7904
|
+
async function graphCorpusSummary(reg, query = {}) {
|
|
7905
|
+
return observedGraphSummary(await graphRunsFor(reg, query));
|
|
7508
7906
|
}
|
|
7509
7907
|
/** The documented heuristic: delivered beats failed; among delivered, cheaper
|
|
7510
7908
|
* (tokens, then iterations) wins; ties go to the most recent. */
|
|
7511
|
-
function pickBestGraph(records) {
|
|
7909
|
+
function pickBestGraph(records, options = {}) {
|
|
7910
|
+
if (options.policy === "observed") {
|
|
7911
|
+
const group = observedGraphSummary(records).groups[0];
|
|
7912
|
+
return group && pickBestGraph(group.runs);
|
|
7913
|
+
}
|
|
7512
7914
|
const delivered = records.filter((row) => row.outcome.kind === "delivered");
|
|
7513
7915
|
if (delivered.length === 0) return void 0;
|
|
7514
7916
|
const better = (a, b) => {
|
|
@@ -7534,7 +7936,17 @@ async function loadGraph(reg, digest) {
|
|
|
7534
7936
|
* author a new one — with the reason stated either way (the decision is data). */
|
|
7535
7937
|
async function lookupGraph(reg, taskDigest) {
|
|
7536
7938
|
const records = await graphRunsFor(reg, taskDigest);
|
|
7537
|
-
const
|
|
7939
|
+
const candidates = [];
|
|
7940
|
+
const loaded = /* @__PURE__ */ new Map();
|
|
7941
|
+
for (const record of records) {
|
|
7942
|
+
if (!loaded.has(record.graphDigest)) loaded.set(record.graphDigest, await loadGraph(reg, record.graphDigest));
|
|
7943
|
+
if (!loaded.get(record.graphDigest)?.observed) candidates.push(record);
|
|
7944
|
+
}
|
|
7945
|
+
if (records.length && !candidates.length) return {
|
|
7946
|
+
kind: "author",
|
|
7947
|
+
reason: "only observed topologies are available; author an executable graph"
|
|
7948
|
+
};
|
|
7949
|
+
const best = pickBestGraph(candidates);
|
|
7538
7950
|
if (best) {
|
|
7539
7951
|
const graph = await loadGraph(reg, best.graphDigest);
|
|
7540
7952
|
if (graph) return {
|
|
@@ -7552,19 +7964,33 @@ async function lookupGraph(reg, taskDigest) {
|
|
|
7552
7964
|
reason: records.length === 0 ? "first run for this task shape" : "no graph delivered for this task shape yet"
|
|
7553
7965
|
};
|
|
7554
7966
|
}
|
|
7555
|
-
/** Rehydrate a stored graph
|
|
7556
|
-
|
|
7557
|
-
|
|
7967
|
+
/** Rehydrate a stored graph, binding trigger data and an environment-owned named check. */
|
|
7968
|
+
function graphFromStored(stored, environment = {}) {
|
|
7969
|
+
if (stored.observed) throw new ValidationError("graphFromStored: observed topology cannot be replayed");
|
|
7970
|
+
const { digest: _digest, observed: _observed, triggerBindings: _triggerBindings, deliverable, ...topology } = stored.triggerBindings !== void 0 ? bindCompiledGraphTriggers(stored, stored.triggerBindings, typeof environment === "function" ? void 0 : environment.trigger ?? {}) : typeof environment === "function" ? stored : bindGraphParameters(stored, { trigger: environment.trigger ?? {} });
|
|
7971
|
+
const selected = typeof environment === "function" ? environment : environment.checks && Object.hasOwn(environment.checks, deliverable.checkRef ?? "") ? environment.checks[deliverable.checkRef] : deliverable.checkRef === "command" ? deliverable.command : deliverable.checkRef === "route" && deliverable.when ? ((out, context) => context ? context.originalVerdict?.valid !== false : checkGraphRoute(deliverable.when, out)) : void 0;
|
|
7972
|
+
if (!selected) throw new ValidationError(`graphFromStored: unknown checkRef ${deliverable.checkRef ?? "(missing)"}`);
|
|
7973
|
+
const materialized = stored.triggerBindings === void 0 ? {} : { triggerBindings: [] };
|
|
7974
|
+
if (typeof selected === "function") {
|
|
7975
|
+
const { command: _command, ...description } = deliverable;
|
|
7976
|
+
return {
|
|
7977
|
+
...topology,
|
|
7978
|
+
...materialized,
|
|
7979
|
+
deliverable: {
|
|
7980
|
+
...description,
|
|
7981
|
+
check: selected
|
|
7982
|
+
}
|
|
7983
|
+
};
|
|
7984
|
+
}
|
|
7985
|
+
const command = selected === deliverable.command ? selected : bindGraphParameters(selected, { trigger: environment.trigger ?? {} });
|
|
7558
7986
|
return {
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
budget: stored.budget,
|
|
7987
|
+
...topology,
|
|
7988
|
+
...materialized,
|
|
7562
7989
|
deliverable: {
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
...stored.gates === void 0 ? {} : { gates: stored.gates }
|
|
7990
|
+
...deliverable,
|
|
7991
|
+
command,
|
|
7992
|
+
check: () => false
|
|
7993
|
+
}
|
|
7568
7994
|
};
|
|
7569
7995
|
}
|
|
7570
7996
|
/** Digests present on disk (integrity probe for tests and audits). */
|
|
@@ -7575,8 +8001,7 @@ async function storedGraphDigests(reg) {
|
|
|
7575
8001
|
return [];
|
|
7576
8002
|
}
|
|
7577
8003
|
}
|
|
7578
|
-
|
|
7579
|
-
//#region src/runtime/supervise/supervise-graph-subtasks.ts
|
|
8004
|
+
// src/runtime/supervise/supervise-graph-subtasks.ts
|
|
7580
8005
|
/** A stored graph's topology, from the registry `SuperviseOptions.graphRegistry` names. */
|
|
7581
8006
|
async function storedGraphTopology(dir, digest) {
|
|
7582
8007
|
if (dir === void 0) throw new ValidationError("run_graph: this run names no graph registry (SuperviseOptions.graphRegistry), so a graphDigest cannot resolve; pass the graph as data");
|
|
@@ -7608,8 +8033,7 @@ async function graphSubtaskOutput(overlay, out, flowFailure) {
|
|
|
7608
8033
|
...exhaustedEdges.length === 0 ? {} : { exhaustedEdges }
|
|
7609
8034
|
};
|
|
7610
8035
|
}
|
|
7611
|
-
|
|
7612
|
-
//#region src/runtime/supervise/recursive-worker-factory.ts
|
|
8036
|
+
// src/runtime/supervise/recursive-worker-factory.ts
|
|
7613
8037
|
/** The factory that spawns the children of one parent seat, leaf or managed. */
|
|
7614
8038
|
function recursiveWorkerFactoryFor(env, seat) {
|
|
7615
8039
|
const makeRecursiveWorker = (authoredProfile, spawnContext, recovering = false) => {
|
|
@@ -7663,7 +8087,7 @@ function managedWorker(env, seat, admitted, spawnContext) {
|
|
|
7663
8087
|
unassessedOutput: false
|
|
7664
8088
|
};
|
|
7665
8089
|
const deps = buildNestedManagerDeps(child);
|
|
7666
|
-
|
|
8090
|
+
const nested = ownFlow === void 0 ? supervisorAgent(authorized, deps) : supervisorAgentWithTestBrain(authorized, {
|
|
7667
8091
|
...deps,
|
|
7668
8092
|
brain: runtimeFlowBrain(),
|
|
7669
8093
|
routeFlow: ownFlow.route,
|
|
@@ -7672,7 +8096,8 @@ function managedWorker(env, seat, admitted, spawnContext) {
|
|
|
7672
8096
|
debounceMs: 0,
|
|
7673
8097
|
...options.wake
|
|
7674
8098
|
}
|
|
7675
|
-
})
|
|
8099
|
+
});
|
|
8100
|
+
return withModelSubstitution(driverChild(authorized, nested, journal, childExecution.ref, () => child.acceptedSubmission, env.recoveryFactories.get(child.childFactory), () => child.unassessedOutput, admitted.seatManagedLeaf ? child.managerDeliverable : void 0, ownGraph ? (out) => graphSubtaskOutput(ownGraph, out, ownFlow?.run.failure) : void 0), admitted.modelSubstitution);
|
|
7676
8101
|
}
|
|
7677
8102
|
/**
|
|
7678
8103
|
* The root of a `run_graph` subtask carries its graph's topology, and its subtree runs under that
|
|
@@ -7742,8 +8167,7 @@ function registerRecovery(env, makeRecursiveWorker) {
|
|
|
7742
8167
|
});
|
|
7743
8168
|
env.recoveryFactories.set(makeRecursiveWorker, factory);
|
|
7744
8169
|
}
|
|
7745
|
-
|
|
7746
|
-
//#region src/runtime/supervise/worker-retry.ts
|
|
8170
|
+
// src/runtime/supervise/worker-retry.ts
|
|
7747
8171
|
/**
|
|
7748
8172
|
* WORKER-SPAWN RETRY — the second chance `driverRetry` gives the root, given to a leaf.
|
|
7749
8173
|
*
|
|
@@ -7754,7 +8178,7 @@ function registerRecovery(env, makeRecursiveWorker) {
|
|
|
7754
8178
|
* bridgeExecutor: bridge stream error: host-executor: acquire timeout after 60000ms
|
|
7755
8179
|
* (in_flight=4/4, queued=1)
|
|
7756
8180
|
*
|
|
7757
|
-
*
|
|
8181
|
+
* Two live cells held 2 leads and up to 8
|
|
7758
8182
|
* workers on one bridge whose host executor caps live harness children at 4. A worker spawn that
|
|
7759
8183
|
* queued past the bridge's single 60 s acquire deadline died there, and the run lost that worker
|
|
7760
8184
|
* permanently even though a slot freed seconds later. The bridge retries nothing.
|
|
@@ -7969,8 +8393,7 @@ function defaultSleep(ms, signal) {
|
|
|
7969
8393
|
if (ms <= 0 || signal?.aborted) return Promise.resolve();
|
|
7970
8394
|
return sleep(ms, signal);
|
|
7971
8395
|
}
|
|
7972
|
-
|
|
7973
|
-
//#region src/runtime/supervise/supervise-recursive-workers.ts
|
|
8396
|
+
// src/runtime/supervise/supervise-recursive-workers.ts
|
|
7974
8397
|
function createSuperviseWorkers(setup, cancelDurableRun) {
|
|
7975
8398
|
const { options, canonicalProfile, rootExecution, guidanceComposer, deliverable, analysts, journal, runId, rootOwnerId, now } = setup;
|
|
7976
8399
|
const recoveryFactories = /* @__PURE__ */ new WeakMap();
|
|
@@ -8045,8 +8468,7 @@ function createSuperviseWorkers(setup, cancelDurableRun) {
|
|
|
8045
8468
|
graphOverlays
|
|
8046
8469
|
};
|
|
8047
8470
|
}
|
|
8048
|
-
|
|
8049
|
-
//#region src/runtime/supervise/supervise-registry.ts
|
|
8471
|
+
// src/runtime/supervise/supervise-registry.ts
|
|
8050
8472
|
/** Resolve one option that may be given as a value OR as a name into `opts.registry`. Both failure
|
|
8051
8473
|
* modes name the option, the requested name, and the table it was looked up in — a typo must not
|
|
8052
8474
|
* degrade into a silently unconfigured run (which for `deliverable` means "no run can ever
|
|
@@ -8104,8 +8526,7 @@ async function verifyProfilePromotions(table) {
|
|
|
8104
8526
|
const { verifySealedExperiment } = await import("@tangle-network/agent-eval/experiment");
|
|
8105
8527
|
for (const [name, entry] of promoted) if (!await verifySealedExperiment(entry.promotion.experiment)) throw new ValidationError(`supervise: opts.registry.profiles ${JSON.stringify(name)} cites a sealed play whose digest does not match its spec`);
|
|
8106
8528
|
}
|
|
8107
|
-
|
|
8108
|
-
//#region src/runtime/supervise/supervise-root-evidence.ts
|
|
8529
|
+
// src/runtime/supervise/supervise-root-evidence.ts
|
|
8109
8530
|
/**
|
|
8110
8531
|
* Record what a run-scoped cancel actually did, at the ONE place that observes the run's terminal
|
|
8111
8532
|
* state: the `supervise()` settle path.
|
|
@@ -8179,8 +8600,7 @@ function rootProviderModelEvidence(observations) {
|
|
|
8179
8600
|
function rootProviderModelEvidenceFromExecution(evidence) {
|
|
8180
8601
|
return evidence ?? rootProviderModelEvidence([]);
|
|
8181
8602
|
}
|
|
8182
|
-
|
|
8183
|
-
//#region src/runtime/supervise/supervise-root-profile.ts
|
|
8603
|
+
// src/runtime/supervise/supervise-root-profile.ts
|
|
8184
8604
|
/**
|
|
8185
8605
|
* The composer `profileGuidance` selects, or `undefined` when no guidance is selected. The result
|
|
8186
8606
|
* is re-validated as an AgentProfile, and a composition that breaks the schema is refused as a
|
|
@@ -8261,8 +8681,7 @@ function rootSpawnResourceRoot(backend) {
|
|
|
8261
8681
|
}
|
|
8262
8682
|
return isLoopbackHost(host) ? resolve(backend.cwd) : void 0;
|
|
8263
8683
|
}
|
|
8264
|
-
|
|
8265
|
-
//#region src/runtime/supervise/driver-execution-attempt.ts
|
|
8684
|
+
// src/runtime/supervise/driver-execution-attempt.ts
|
|
8266
8685
|
/** The failure a terminal artifact reports, as the error a failed harness turn raises. */
|
|
8267
8686
|
function harnessTurnFailure(runtime, artifact) {
|
|
8268
8687
|
const reported = executorFailure(artifact);
|
|
@@ -8593,8 +9012,7 @@ var DriverExecutionAttempt = class {
|
|
|
8593
9012
|
});
|
|
8594
9013
|
}
|
|
8595
9014
|
};
|
|
8596
|
-
|
|
8597
|
-
//#region src/runtime/supervise/manager-drive-session.ts
|
|
9015
|
+
// src/runtime/supervise/manager-drive-session.ts
|
|
8598
9016
|
/** The profile the provider sees for `profile`, run on `seat` when one is active. */
|
|
8599
9017
|
function seatProviderProfile(profile, seat) {
|
|
8600
9018
|
return providerVisibleProfile(seat ? seatExecutionProfile(profile, seat.stage) : profile);
|
|
@@ -8755,20 +9173,19 @@ var ManagerDriveSession = class {
|
|
|
8755
9173
|
at: new Date(now()).toISOString()
|
|
8756
9174
|
});
|
|
8757
9175
|
await seatSelection.onPause(scope.view.root, error.resumeAt, "paused");
|
|
8758
|
-
|
|
9176
|
+
const waitMs = Math.max(1e3, Date.parse(error.resumeAt) - now());
|
|
9177
|
+
await sleepScopeWait(scope, waitMs, scope.signal, "seat-wait");
|
|
8759
9178
|
afterRecheck = true;
|
|
8760
9179
|
}
|
|
8761
9180
|
}
|
|
8762
9181
|
};
|
|
8763
|
-
|
|
8764
|
-
//#region src/mcp/tools/coordination-request-context.ts
|
|
9182
|
+
// src/mcp/tools/coordination-request-context.ts
|
|
8765
9183
|
/** The tool-call timeout Runtime asks harnesses to give its coordination server. The Tangle
|
|
8766
9184
|
* profile materializer writes it as `MCP_TOOL_TIMEOUT` (Claude Code) and `tool_timeout_sec`
|
|
8767
9185
|
* (Codex) when an attachment declares `metadata.toolTimeoutMs`, so a fenced coordination call
|
|
8768
9186
|
* that holds its response for its whole fence is never cut off at the 60 s harness default. */
|
|
8769
9187
|
const COORDINATION_CLIENT_TOOL_TIMEOUT_MS = 3e5;
|
|
8770
|
-
|
|
8771
|
-
//#region src/runtime/supervise/supervise-driver-attempt.ts
|
|
9188
|
+
// src/runtime/supervise/supervise-driver-attempt.ts
|
|
8772
9189
|
async function executeDriverAttempt(input) {
|
|
8773
9190
|
const { state, scope, retainedOwner, turnCap } = input;
|
|
8774
9191
|
if (!(scope.view.inFlight > 0)) assertDriverBudgetOpen(scope, input.now);
|
|
@@ -8923,8 +9340,7 @@ async function providerAttemptFactory(input, providerHarness) {
|
|
|
8923
9340
|
}
|
|
8924
9341
|
});
|
|
8925
9342
|
}
|
|
8926
|
-
|
|
8927
|
-
//#region src/runtime/supervise/supervise-driver-session.ts
|
|
9343
|
+
// src/runtime/supervise/supervise-driver-session.ts
|
|
8928
9344
|
/** Run a harness-brained manager through the same executor factory as its children. The manager's
|
|
8929
9345
|
* full profile is preserved, the live coordination server is added under one reserved alias, and
|
|
8930
9346
|
* every streamed turn is charged to the manager's scope before it may continue. */
|
|
@@ -9082,8 +9498,7 @@ async function reentryContinuity(backend, scope, retainedOwner) {
|
|
|
9082
9498
|
}
|
|
9083
9499
|
return UNPROVEN_CONTINUITY;
|
|
9084
9500
|
}
|
|
9085
|
-
|
|
9086
|
-
//#region src/runtime/supervise/supervise-manager-harness.ts
|
|
9501
|
+
// src/runtime/supervise/supervise-manager-harness.ts
|
|
9087
9502
|
/**
|
|
9088
9503
|
* Resolve the harness that drives each manager owner: the caller's resolver or harness, claimed
|
|
9089
9504
|
* per owner so one steerable harness never serves two managers, or one built from the backend.
|
|
@@ -9154,8 +9569,7 @@ function driveHarnessClaims() {
|
|
|
9154
9569
|
return harness;
|
|
9155
9570
|
};
|
|
9156
9571
|
}
|
|
9157
|
-
|
|
9158
|
-
//#region src/runtime/supervise/supervise-spawn-preflight.ts
|
|
9572
|
+
// src/runtime/supervise/supervise-spawn-preflight.ts
|
|
9159
9573
|
/**
|
|
9160
9574
|
* The pre-flight `supervise` installs for a bridge backend. No new knob: the backend already says
|
|
9161
9575
|
* where the bridge is, and these are the questions only the bridge can answer.
|
|
@@ -9265,8 +9679,7 @@ function composeSpawnPreflights(...preflights) {
|
|
|
9265
9679
|
}
|
|
9266
9680
|
};
|
|
9267
9681
|
}
|
|
9268
|
-
|
|
9269
|
-
//#region src/runtime/supervise/supervise-sql-admission.ts
|
|
9682
|
+
// src/runtime/supervise/supervise-sql-admission.ts
|
|
9270
9683
|
/** What a SQL run context admits, in two phases: identity and worker seam before any compute (a
|
|
9271
9684
|
* synchronous configuration fault), then coordinator and retained-control capabilities at start. */
|
|
9272
9685
|
function assertSqlRunOptions(options) {
|
|
@@ -9282,8 +9695,7 @@ async function assertSqlRunProvider(options) {
|
|
|
9282
9695
|
const capabilities = await provider.capabilities();
|
|
9283
9696
|
if (!capabilities.retainedControl || !capabilities.streaming.turnIdempotency || !capabilities.streaming.replay || !provider.get) throw new ValidationError("supervise: SQL runContext requires retainedControl, replay, turn idempotency, and provider.get");
|
|
9284
9697
|
}
|
|
9285
|
-
|
|
9286
|
-
//#region src/runtime/supervise/supervise-run-setup.ts
|
|
9698
|
+
// src/runtime/supervise/supervise-run-setup.ts
|
|
9287
9699
|
function prepareSuperviseRun(profile, task, opts, testBrain) {
|
|
9288
9700
|
const options = captureSuperviseOptions(opts);
|
|
9289
9701
|
assertSqlRunOptions(options);
|
|
@@ -9469,7 +9881,10 @@ function resolveRunRegistry(options) {
|
|
|
9469
9881
|
analysts: resolveNamed("analysts", "analysts", options.analysts, options.registry?.analysts),
|
|
9470
9882
|
profileTable: snapshotProfileTable(options.registry?.profiles, options.allowedModels, options.makeWorkerAgent === void 0 && options.authorizeSpawn === void 0 ? (entry, context) => {
|
|
9471
9883
|
const security = validateAgentProfileSecurity(entry, options.profileSecurity ?? DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY);
|
|
9472
|
-
if (!security.ok)
|
|
9884
|
+
if (!security.ok) {
|
|
9885
|
+
const details = security.issues.filter((issue) => issue.level === "error").map((issue) => `${issue.code}${issue.path ? ` at ${issue.path}` : ""}`).join(", ");
|
|
9886
|
+
throw new ValidationError(`${context}: ${details}`);
|
|
9887
|
+
}
|
|
9473
9888
|
if (options.backend !== void 0 && options.makeLeafAgent === void 0 && declaredRuntimeToolNames(entry).length === 0) assertBackendProfileMaterialization(entry, options.backend, context);
|
|
9474
9889
|
} : void 0)
|
|
9475
9890
|
};
|
|
@@ -9536,8 +9951,7 @@ function spawnProfileComposer(options, driver, childrenCanSubmit, composeSpawnPr
|
|
|
9536
9951
|
};
|
|
9537
9952
|
};
|
|
9538
9953
|
}
|
|
9539
|
-
|
|
9540
|
-
//#region src/runtime/supervise/supervise-run-lifecycle.ts
|
|
9954
|
+
// src/runtime/supervise/supervise-run-lifecycle.ts
|
|
9541
9955
|
function superviseInternal(profile, task, opts, testBrain) {
|
|
9542
9956
|
const setup = prepareSuperviseRun(profile, task, opts, testBrain);
|
|
9543
9957
|
const { options } = setup;
|
|
@@ -9763,8 +10177,7 @@ async function settleSupervisedRun(run, pending, cancellation) {
|
|
|
9763
10177
|
...rootExecution.ref === void 0 ? {} : { execution: rootExecution.ref }
|
|
9764
10178
|
};
|
|
9765
10179
|
}
|
|
9766
|
-
|
|
9767
|
-
//#region src/runtime/supervise/supervise.ts
|
|
10180
|
+
// src/runtime/supervise/supervise.ts
|
|
9768
10181
|
/** Capabilities a data-only consumer may require before building an opted-in run. `graphTools`:
|
|
9769
10182
|
* a manager whose profile grants `run_graph` can start an agent graph as one subtask. */
|
|
9770
10183
|
const superviseFleetCapabilities = Object.freeze({
|
|
@@ -9795,7 +10208,6 @@ function superviseWithContext(profile, task, opts, brain) {
|
|
|
9795
10208
|
...signal === void 0 ? {} : { signal }
|
|
9796
10209
|
}, brain));
|
|
9797
10210
|
}
|
|
9798
|
-
|
|
9799
|
-
export { noProgressFor as $, runBrainLoop as A, graphRootProfile as B, workerFromBackend as C, composeReentryTask as D, UNPROVEN_CONTINUITY as E, flowRootProfile as F, dumbContinuationFailPrompt as G, analyzesFindingsReportPrompt as H, journaledGateDecider as I, kernelPromptRegistry as J, dumbContinuationPassPrompt as K, routeFlowOf as L, createGraphOverlay as M, GraphRouteError as N, serveCoordinationMcp as O, createFlowRun as P, anyOf as Q, validateFlowGraph as R, taskShapeDigest as S, supervisorAgentWithTestBrain as T, createPromptRegistry as U, validateGraphTopology as V, delegatesWorkerBriefPrompt as W, promptHandle as X, naiveContinuationPrompt as Y, allWorkersStalled as Z, loadGraph as _, superviseRootProfile as a, renderAnytimeTable as at, recordGraphRun as b, retryPreSpawnRefusals as c, createSupervisorSpanRecorder as ct, graphDigest as d, plateau as et, graphFromStored as f, listGraphRuns as g, graph_registry_exports as h, profileGuidanceComposer as i, plateauLength as it, runtimeFlowBrain as j, driverAgent as k, withWorkerSpawnRetry as l, graphRunsFor as m, superviseFleetCapabilities as n, areaUnderCurve as nt, isPreSpawnExecutorFailure as o, readRootStream as ot, graphRegistry as p, formatPromptHandle as q, superviseWithTestBrain as r, bestSoFar as rt, resolveWorkerSpawnRetry as s, readRootStreamReceipt as st, supervise as t, anytimeReport as tt, digestOfGraph as u, lookupGraph as v, supervisorAgent as w, storedGraphDigests as x, pickBestGraph as y, defaultEdgeTraversalCap as z };
|
|
10211
|
+
export { delegatesWorkerBriefPrompt as $, graphRouteWhenSchema as A, runtimeFlowBrain as B, storedGraphDigests as C, compileGraphParameters as D, bindGraphParameters as E, composeReentryTask as F, journaledGateDecider as G, GraphRouteError as H, serveCoordinationMcp as I, defaultEdgeTraversalCap as J, routeFlowOf as K, coordinationControlToolNames as L, supervisorAgent as M, supervisorAgentWithTestBrain as N, graphTriggerBindingsSchema as O, UNPROVEN_CONTINUITY as P, createPromptRegistry as Q, driverAgent as R, recordStoredGraphRun as S, assertGraphTriggerBindings as T, createFlowRun as U, createGraphOverlay as V, flowRootProfile as W, validateGraphTopology as X, graphRootProfile as Y, analyzesFindingsReportPrompt as Z, listGraphRuns as _, createSupervisorSpanRecorder as _t, superviseRootProfile as a, promptHandle as at, pickBestGraph as b, retryPreSpawnRefusals as c, noProgressFor as ct, graphCorpusSummary as d, areaUnderCurve as dt, dumbContinuationFailPrompt as et, graphDigest as f, bestSoFar as ft, graph_registry_exports as g, readRootStreamReceipt as gt, graphRunsFor as h, readRootStream as ht, profileGuidanceComposer as i, naiveContinuationPrompt as it, workerFromBackend as j, graphFileSchema as k, withWorkerSpawnRetry as l, plateau as lt, graphRegistry as m, renderAnytimeTable as mt, superviseFleetCapabilities as n, formatPromptHandle as nt, isPreSpawnExecutorFailure as o, allWorkersStalled as ot, graphFromStored as p, plateauLength as pt, validateFlowGraph as q, superviseWithTestBrain as r, kernelPromptRegistry as rt, resolveWorkerSpawnRetry as s, anyOf as st, supervise as t, dumbContinuationPassPrompt as tt, digestOfGraph as u, anytimeReport as ut, loadGraph as v, taskShapeDigest as w, recordGraphRun as x, lookupGraph as y, runBrainLoop as z };
|
|
9800
10212
|
|
|
9801
|
-
//# sourceMappingURL=supervise-
|
|
10213
|
+
//# sourceMappingURL=supervise-CaeZcgAW.js.map
|