@tangle-network/agent-runtime 0.266.0 → 0.273.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{activation-BERiJjx5.js → activation-Cx2dKA_l.js} +2 -2
- package/dist/{activation-BERiJjx5.js.map → activation-Cx2dKA_l.js.map} +1 -1
- package/dist/{activation-VpxSbDKJ.d.ts → activation-IfDlhR3J.d.ts} +4 -4
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/candidate-execution/index.js +2 -2
- package/dist/{coordination-driver-DdZ-nh_4.js → coordination-driver-CkcW4dxU.js} +173 -92
- package/dist/coordination-driver-CkcW4dxU.js.map +1 -0
- package/dist/{delegate-Ajx_PVyu.js → delegate-Dvb1-mE-.js} +2 -2
- package/dist/{delegate-Ajx_PVyu.js.map → delegate-Dvb1-mE-.js.map} +1 -1
- package/dist/durable.d.ts +3 -571
- package/dist/durable.js +93 -19
- package/dist/durable.js.map +1 -1
- package/dist/{graph-CK50N9vG.js → graph-C69Uxtzt.js} +17 -8
- package/dist/graph-C69Uxtzt.js.map +1 -0
- package/dist/{improvement-cycle-GRPoHLm1.js → improvement-cycle-CO2HRCQq.js} +10 -10
- package/dist/improvement-cycle-CO2HRCQq.js.map +1 -0
- package/dist/{index-CU2mlMfc.d.ts → index-D2ipSqkP.d.ts} +4335 -3055
- package/dist/index.d.ts +7 -451
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +9 -3
- package/dist/intelligence.js +13 -7
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +4 -4
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-cC16EPUq.js → loop-runner-bin-B9MIq9O7.js} +3 -3
- package/dist/{loop-runner-bin-cC16EPUq.js.map → loop-runner-bin-B9MIq9O7.js.map} +1 -1
- package/dist/{loop-runner-bin-XKZXM08Q.d.ts → loop-runner-bin-ThlwVkvo.d.ts} +3 -3
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +12 -6
- package/dist/mcp/index.js +7 -7
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/{memory-server-Cn8LbAxO.js → memory-server-DXQ8IxGR.js} +2 -2
- package/dist/{memory-server-Cn8LbAxO.js.map → memory-server-DXQ8IxGR.js.map} +1 -1
- package/dist/{openai-tools-D3ajI_D2.d.ts → openai-tools-Bb0mAr5z.d.ts} +2 -2
- package/dist/{prepare-oHUQdC5-.js → prepare-DVlvGP7V.js} +2 -2
- package/dist/{prepare-oHUQdC5-.js.map → prepare-DVlvGP7V.js.map} +1 -1
- package/dist/profiles.d.ts +2 -2
- package/dist/{protected-model-port-DqF0qDU6.js → protected-model-port-BrWgsCnl.js} +2 -2
- package/dist/{protected-model-port-DqF0qDU6.js.map → protected-model-port-BrWgsCnl.js.map} +1 -1
- package/dist/{protected-redaction--F3v1oo8.js → protected-redaction-DylCC_ot.js} +14 -20
- package/dist/protected-redaction-DylCC_ot.js.map +1 -0
- package/dist/{provision-supervisor-Bf_bPaCv.js → provision-supervisor-BKAvsDtP.js} +3 -3
- package/dist/{provision-supervisor-Bf_bPaCv.js.map → provision-supervisor-BKAvsDtP.js.map} +1 -1
- package/dist/{runtime-hOLlAc1i.js → runtime-CHxXrUeZ.js} +1714 -854
- package/dist/runtime-CHxXrUeZ.js.map +1 -0
- package/dist/{server-DOb67ohd.js → server-2OeFrEVG.js} +4 -4
- package/dist/{server-DOb67ohd.js.map → server-2OeFrEVG.js.map} +1 -1
- package/dist/{stream-agent-turn-Gw9hLpBn.d.ts → stream-agent-turn-ewm3BZAp.d.ts} +34 -17
- package/dist/{structural-rollout-DV9YoQF6.js → structural-rollout-DCUprNpH.js} +2 -2
- package/dist/{structural-rollout-DV9YoQF6.js.map → structural-rollout-DCUprNpH.js.map} +1 -1
- package/dist/{substrate-CLt9S9ym.d.ts → substrate-VKjmrksz.d.ts} +2 -2
- package/dist/{supervise--njTtSL3.js → supervise-Dej5aSDa.js} +220 -52
- package/dist/supervise-Dej5aSDa.js.map +1 -0
- package/dist/{supervisor-B8UMAXya.js → supervisor-DdKPGluv.js} +1233 -303
- package/dist/supervisor-DdKPGluv.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +62 -62
- package/dist/testing.js.map +1 -1
- package/dist/{tool-server-x9NEhvHZ.js → tool-server-Dqer2M4_.js} +30 -12
- package/dist/tool-server-Dqer2M4_.js.map +1 -0
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-CrnwLVYQ.d.ts → types-DMRc3jru.d.ts} +463 -105
- package/package.json +6 -5
- package/dist/coordination-driver-DdZ-nh_4.js.map +0 -1
- package/dist/graph-CK50N9vG.js.map +0 -1
- package/dist/improvement-cycle-GRPoHLm1.js.map +0 -1
- package/dist/protected-redaction--F3v1oo8.js.map +0 -1
- package/dist/runtime-hOLlAc1i.js.map +0 -1
- package/dist/supervise--njTtSL3.js.map +0 -1
- package/dist/supervisor-B8UMAXya.js.map +0 -1
- package/dist/tool-server-x9NEhvHZ.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ca as OutputAdapter, Oa as Validator, ea as AgentRunSpec, na as Driver } from "./types-DMRc3jru.js";
|
|
2
2
|
import { AgentProfile } from "@tangle-network/agent-interface";
|
|
3
3
|
//#region src/profiles/coder.d.ts
|
|
4
4
|
/**
|
|
@@ -281,4 +281,4 @@ interface UiFinding {
|
|
|
281
281
|
}
|
|
282
282
|
//#endregion
|
|
283
283
|
export { CoderTask as _, UiFindingSeverity as a, KnowledgeUpdate as c, ResearchSource as d, ResearchTask as f, researcherProfile as g, multiHarnessResearcherFanout as h, UiFindingScreenshot as i, MultiHarnessResearcherFanoutOptions as l, createResearcherValidator as m, UI_LENSES as n, UiLens as o, ResearcherProfileOptions as p, UiFinding as r, KnowledgeItem as s, UI_FINDING_SEVERITIES as t, ResearchOutput as u, coderTaskToPrompt as v };
|
|
284
|
-
//# sourceMappingURL=substrate-
|
|
284
|
+
//# sourceMappingURL=substrate-VKjmrksz.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { $
|
|
1
|
+
import { $ as bindScopeRetainedOwnerProvider, $i as detachedSnapshot, A as driverExecutorFactory, Aa as resourceTelemetry, Ai as readCommittedJsonLines, At as snapshotExecutorConfig, B as recordScopeOwnerMaterialization, Bi as providerAttemptEvidence, C as createContinuationKeeper, Da as withTimeout, Di as isNoEntError, Dn as executorFailure, Dr as persistHarnessTranscript, Ea as unmeteredSpend, Ei as worktreeCliProfileMaterialization, F as beginScopeOwnerAttempt, Fa as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, Fn as bridgeStopSignalKey, Gi as runtimeOwnedExecutorProviderEvidence, H as restoreScopeOwnerAcceptedExecution, Hi as runtimeOwnedDriveHarnessProviderEvidence, Hr as generateSpanId, Ii as inheritRuntimeOwnedExecutorAttestation, Ki as runtimeOwnedPendingExecutorMaterialization, Kn as routerBrain, Kr as toOtelAttributes, L as deriveNodeExecutionIdentity, La as teardownExecutor, Ni as attestRuntimeOwnedScopeOwner, Oa as zeroSpend, On as bridgeAdmissionRefusal, Or as readHarnessTranscript, Ot as createExecutor, P as assertRecursiveReservationPolicy, Pn as bridgeRuntimeAttachmentsKey, Pt as createRouterTranscript, Q as bindScopeRetainedOwnerEnvironmentId, R as meterRuntimeOwnedAccounting, Ra as teardownSurfaces, Sa as sleep, Si as renderUnsupported, Tt as captureReusableExecutorConfig, U as scopeOwnerExecutorNodeContext, Ui as runtimeOwnedExecutorExecutionBinding, V as recordScopeOwnerPause, Vi as recordRuntimeOwnedDriveHarnessProviderEvidence, Wi as runtimeOwnedExecutorMaterialization, _ as CheckUnavailableError, _i as promptControlProfileMaterialization, at as scopeRetainedOwnerResourceReader, b as bestComposite, br as linkAbort, c as runTree, cr as registerRetainedExecutorPreparation, et as consumeScopeRetainedOwnerResult, f as runDriverWithRetry, fi as assertProfileMaterialization, gi as profileMaterializationAxes$1, gn as createInbox, h as CONTINUATIONS_DIR, hi as fullProfileMaterialization, i as bestDelivered, in as newUsageTotals, it as scopeRetainedOwnerPriorSpend, j as isDriverSpec, ja as withBudgetResources, k as driverChild, ka as addResourceSpend, ki as prepareJsonlAppend, kn as bridgeModelRouteRefusal, kr as contentAddress, lr as retainedExecutorSeamKey, ma as addSpend, mi as defineProfileMaterializationContract, n as createRootHandle, nt as reconcileScopeRetainedOwnerEnvironment, on as spendFromUsageTotals, ot as scopeRetainedOwnerResult, p as summarizeDriverAttempts, pi as controlProfileMaterialization, qi as runtimeOwnedScopeOwnerRuntime, r as createSupervisor, rn as meterUsageEvent, rt as scopeRetainedOwnerContext, s as runFinalizer, sn as WORKER_TRACE_PROPAGATION, tn as assertValidBudget, tr as resolveAgentEnvironmentProvider, tt as prepareScopeRetainedOwnerTask, u as HarnessTurnFailedError, ur as errMessage, v as admitContinuationPolicy, vi as promptModelProfileMaterialization, vr as RunCancellationReason, wi as unsupportedProfileDimensions, wt as bindReusableExecutorExecutionId, x as checkVerdictOf, xr as runAbortable, z as meterRuntimeOwnedProviderAttempt, zr as createOtelExporter } from "./supervisor-DdKPGluv.js";
|
|
2
2
|
import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
|
|
3
3
|
import { a as concreteProfileModel, c as profileModelExecutionSettings, d as agentHarness, f as harnessRunsAgent, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile } from "./model-policy-BbSCSak0.js";
|
|
4
4
|
import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
|
|
5
5
|
import { n as assertNoSymlinkDescendant } from "./durable-file-DWQA4ooo.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { C as applyRunCancellation, E as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, b as withRunContext, c as createProgressTracker, d as progressStop, j as createCoordinationToolsForManager, k as coordinationVerbNames, n as createSteerAcknowledger, r as driverAgent, t as createCancelAcknowledger, u as plateau, v as createFileRunContext, w as watchRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-CkcW4dxU.js";
|
|
7
|
+
import { r as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-Dqer2M4_.js";
|
|
8
8
|
import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-vwd4SwX_.js";
|
|
9
9
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
10
10
|
import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
@@ -12,6 +12,7 @@ import { closeSync, constants, fsyncSync, openSync, writeSync } from "node:fs";
|
|
|
12
12
|
import { resolve } from "node:path";
|
|
13
13
|
import { mkdir } from "node:fs/promises";
|
|
14
14
|
import { isMaterializerHarness } from "@tangle-network/agent-profile-materialize";
|
|
15
|
+
import { ATTR } from "@tangle-network/agent-trace-contract";
|
|
15
16
|
import { createServer } from "node:http";
|
|
16
17
|
import { withProfileKb } from "@tangle-network/agent-interface/profile-kb";
|
|
17
18
|
//#region src/runtime/supervise/completion-gate.ts
|
|
@@ -48,7 +49,7 @@ function gateOnDeliverable(inner, deliverable) {
|
|
|
48
49
|
const check = async (out, baseScore) => {
|
|
49
50
|
let delivered;
|
|
50
51
|
try {
|
|
51
|
-
delivered = await deliverable.check(out)
|
|
52
|
+
delivered = checkVerdictOf(await deliverable.check(out)).pass;
|
|
52
53
|
} catch {
|
|
53
54
|
delivered = false;
|
|
54
55
|
}
|
|
@@ -689,6 +690,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
689
690
|
...opts.authorizeDownMessage ? { authorizeDownMessage: opts.authorizeDownMessage } : {},
|
|
690
691
|
perWorker: opts.perWorker,
|
|
691
692
|
...opts.deliverable ? { deliverable: opts.deliverable } : {},
|
|
693
|
+
...opts.readContinuation ? { readContinuation: opts.readContinuation } : {},
|
|
692
694
|
...opts.onStop ? { onStop: opts.onStop } : {},
|
|
693
695
|
awaitTimeoutMs: opts.awaitTimeoutMs ?? responseFenceMs,
|
|
694
696
|
...opts.analysts ? { analysts: opts.analysts } : {},
|
|
@@ -977,6 +979,21 @@ function createSupervisorSpanRecorder(opts) {
|
|
|
977
979
|
const open = /* @__PURE__ */ new Map();
|
|
978
980
|
const spanIdOf = /* @__PURE__ */ new Map([[opts.runId, rootSpanId]]);
|
|
979
981
|
let finished = false;
|
|
982
|
+
/**
|
|
983
|
+
* The span a node's event hangs under. A parent node whose span this recorder never opened (it
|
|
984
|
+
* ran in an earlier process) leaves the child on the root span, which is a placeholder, not a
|
|
985
|
+
* recorded parent.
|
|
986
|
+
*/
|
|
987
|
+
const parentSpan = (parentId) => {
|
|
988
|
+
const spanId = parentId === void 0 ? void 0 : spanIdOf.get(parentId);
|
|
989
|
+
return spanId ? {
|
|
990
|
+
spanId,
|
|
991
|
+
confidence: "explicit"
|
|
992
|
+
} : {
|
|
993
|
+
spanId: rootSpanId,
|
|
994
|
+
confidence: "unknown"
|
|
995
|
+
};
|
|
996
|
+
};
|
|
980
997
|
/** Every export is best-effort: a throwing exporter must never reach the run. */
|
|
981
998
|
const emit = (span) => {
|
|
982
999
|
try {
|
|
@@ -1006,7 +1023,7 @@ function createSupervisorSpanRecorder(opts) {
|
|
|
1006
1023
|
const isWait = runtime === "wait";
|
|
1007
1024
|
const attrs = {
|
|
1008
1025
|
...base,
|
|
1009
|
-
|
|
1026
|
+
[ATTR.spanKind]: isWait ? "CHAIN" : "AGENT",
|
|
1010
1027
|
"agent.name": label,
|
|
1011
1028
|
"tangle.supervise.node.id": childId,
|
|
1012
1029
|
"tangle.supervise.node.label": label,
|
|
@@ -1016,14 +1033,22 @@ function createSupervisorSpanRecorder(opts) {
|
|
|
1016
1033
|
if (event.parentId) attrs["tangle.supervise.node.parent_id"] = event.parentId;
|
|
1017
1034
|
if (runtime) attrs["tangle.supervise.node.runtime"] = runtime;
|
|
1018
1035
|
if (typeof p.depth === "number") attrs["tangle.supervise.node.depth"] = p.depth;
|
|
1036
|
+
const key = str(p.key);
|
|
1037
|
+
const operation = str(p.assignmentId) ?? key;
|
|
1038
|
+
if (operation) attrs[ATTR.operationId] = operation;
|
|
1039
|
+
const attempt = str(p.attemptId);
|
|
1040
|
+
if (attempt) attrs[ATTR.attemptId] = attempt;
|
|
1041
|
+
if (key) attrs[ATTR.idempotencyKey] = key;
|
|
1019
1042
|
if (typeof event.stepIndex === "number") attrs["tangle.supervise.node.ordinal"] = event.stepIndex;
|
|
1020
1043
|
if (p.resumed === true) attrs["tangle.supervise.node.resumed"] = true;
|
|
1021
1044
|
assignBudget(attrs, p.budget);
|
|
1045
|
+
const parent = parentSpan(event.parentId);
|
|
1046
|
+
attrs[ATTR.parentConfidence] = parent.confidence;
|
|
1022
1047
|
const spanId = generateSpanId();
|
|
1023
1048
|
spanIdOf.set(childId, spanId);
|
|
1024
1049
|
open.set(childId, {
|
|
1025
1050
|
spanId,
|
|
1026
|
-
parentSpanId:
|
|
1051
|
+
parentSpanId: parent.spanId,
|
|
1027
1052
|
name: label,
|
|
1028
1053
|
startMs: event.timestamp,
|
|
1029
1054
|
attrs
|
|
@@ -1060,10 +1085,15 @@ function createSupervisorSpanRecorder(opts) {
|
|
|
1060
1085
|
function onTurn(event) {
|
|
1061
1086
|
const p = record(event.payload);
|
|
1062
1087
|
const parentId = event.parentId;
|
|
1063
|
-
const
|
|
1088
|
+
const parent = parentId ? parentSpan(parentId) : {
|
|
1089
|
+
spanId: rootSpanId,
|
|
1090
|
+
confidence: "explicit"
|
|
1091
|
+
};
|
|
1092
|
+
const parentSpanId = parent.spanId;
|
|
1064
1093
|
const attrs = {
|
|
1065
1094
|
...base,
|
|
1066
|
-
|
|
1095
|
+
[ATTR.parentConfidence]: parent.confidence,
|
|
1096
|
+
[ATTR.spanKind]: "LLM",
|
|
1067
1097
|
"inference.observation_kind": "LLM",
|
|
1068
1098
|
"tangle.supervise.node.kind": "inference"
|
|
1069
1099
|
};
|
|
@@ -1121,17 +1151,27 @@ function createSupervisorSpanRecorder(opts) {
|
|
|
1121
1151
|
"tangle.supervise.node.id": nodeId
|
|
1122
1152
|
}, STATUS_UNSET));
|
|
1123
1153
|
open.clear();
|
|
1124
|
-
emit(span(rootSpanId, opts.parentSpanId, "supervisor.run", rootStartMs, endMs,
|
|
1154
|
+
emit(span(rootSpanId, opts.parentSpanId, "supervisor.run", rootStartMs, endMs, {
|
|
1155
|
+
...rootAttrs(base, opts.agentName ?? "supervisor", outcome),
|
|
1156
|
+
...opts.parentSpanId ? { [ATTR.parentConfidence]: "explicit" } : {}
|
|
1157
|
+
}, rootStatus(outcome), rootMessage(outcome)));
|
|
1158
|
+
} catch {}
|
|
1159
|
+
try {
|
|
1125
1160
|
await exporter.flush();
|
|
1161
|
+
} catch (error) {
|
|
1162
|
+
const s = exporter.stats();
|
|
1163
|
+
console.warn(`[agent-runtime] supervisor span export dropped ${s.dropped} span(s): ${s.lastError ?? String(error)}`);
|
|
1164
|
+
} finally {
|
|
1126
1165
|
if (ownsExporter) await exporter.shutdown();
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1166
|
+
}
|
|
1167
|
+
},
|
|
1168
|
+
stats: () => exporter.stats()
|
|
1129
1169
|
};
|
|
1130
1170
|
}
|
|
1131
1171
|
function rootAttrs(base, agentName, outcome) {
|
|
1132
1172
|
const attrs = {
|
|
1133
1173
|
...base,
|
|
1134
|
-
|
|
1174
|
+
[ATTR.spanKind]: "AGENT",
|
|
1135
1175
|
"inference.observation_kind": "AGENT",
|
|
1136
1176
|
"agent.name": agentName,
|
|
1137
1177
|
"inference.agent_name": agentName,
|
|
@@ -1283,7 +1323,7 @@ function composeReentryTask(input) {
|
|
|
1283
1323
|
* only what to continue, spent all forty-five on the research.
|
|
1284
1324
|
*/
|
|
1285
1325
|
function whyLine(reentry) {
|
|
1286
|
-
if (reentry.reason === "unmet-contract") return `Your previous turn ended with the completion check unmet (
|
|
1326
|
+
if (reentry.reason === "unmet-contract") return `Your previous turn ended with the completion check unmet (continuation ${reentry.continuation}).`;
|
|
1287
1327
|
return reentry.reason === "upstream-unavailable" ? "Your previous turn was interrupted before it finished; the run itself is intact." : `Your previous turn ended before it finished (retry ${reentry.retry}); the run itself is intact.`;
|
|
1288
1328
|
}
|
|
1289
1329
|
function environmentLine(continuity) {
|
|
@@ -1755,18 +1795,20 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1755
1795
|
if (harness === null && coordination !== void 0) throw new ConfigError("supervisorAgent: coordination binding is only meaningful for a harness-brained supervisor (profile.harness set). A router-brained supervisor calls the coordination verbs in process and serves no MCP, so this binding would be silently ignored.");
|
|
1756
1796
|
if (harness === null && deps.peerMail) throw new ValidationError("supervisorAgent: peerMail is only served by a harness-brained supervisor (profile.harness set). A router-brained supervisor serves no coordination MCP listener, so there is no peer-mail post office to mint worker capabilities from.");
|
|
1757
1797
|
if (harness !== null && deps.compaction) throw new ValidationError("supervisorAgent: compaction is only supported for router-brained supervisors (profile.harness omitted or cli-base)");
|
|
1758
|
-
if (harness === null &&
|
|
1759
|
-
if (deps.
|
|
1760
|
-
|
|
1761
|
-
if (deps.
|
|
1762
|
-
|
|
1798
|
+
if (harness === null && deps.continuation !== void 0) throw new ValidationError("supervisorAgent: continuation applies to an EXTERNAL-harness supervisor only (profile.harness set). A router-brained supervisor runs its own turn loop in process, so the policy would be silently ignored.");
|
|
1799
|
+
if (deps.continuation !== void 0 && deps.deliverable === void 0) throw new ValidationError("supervisorAgent: continuation needs a `deliverable` completion check — with no check there is no contract that can be unmet");
|
|
1800
|
+
if (harness !== null && deps.deliverable !== void 0 && deps.continuation === void 0) throw new ValidationError("supervisorAgent: a manager with a completion check needs a continuation policy (deadline, maxBarren, the note profile and switches). Runtime supplies no default: how long to send a director back, and what to tell it, is the record's decision");
|
|
1801
|
+
if (deps.deliverable !== void 0 && runtimeToolNames.includes("stop")) throw new ValidationError(`supervisorAgent: the profile grants ${coordinationProfileToolPrefix}stop to a manager with a completion check. Such a manager ends only through submit_result (the check passes) or report_blocked (a failed probe); remove stop from its tools`);
|
|
1802
|
+
const continuationDeadlineMs = deps.continuation === void 0 ? void 0 : admitContinuationPolicy(deps.continuation, "supervisorAgent");
|
|
1763
1803
|
if (harness === null) {
|
|
1764
1804
|
assertRouterArmResourcePolicy(stableProfile);
|
|
1765
1805
|
const brain = testBrain ?? routerBrainFromProfile(stableProfile, stableRouter);
|
|
1766
1806
|
const inbox = createInbox();
|
|
1807
|
+
const transcript = createRouterTranscript();
|
|
1767
1808
|
const build = (priorCoordination, nodeTools, onEvent, slot) => driverAgent({
|
|
1768
1809
|
name,
|
|
1769
1810
|
brain,
|
|
1811
|
+
transcript,
|
|
1770
1812
|
...testBrain === void 0 ? { expectedModel: resolveSupervisorModelId(stableProfile) } : {},
|
|
1771
1813
|
...deps.onProviderModel ? { onProviderModel: deps.onProviderModel } : {},
|
|
1772
1814
|
blobs: deps.blobs,
|
|
@@ -1815,6 +1857,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1815
1857
|
deliver(message) {
|
|
1816
1858
|
return inbox.deliver(message);
|
|
1817
1859
|
},
|
|
1860
|
+
harnessTranscript: () => transcript.capture(),
|
|
1818
1861
|
async act(task, scope) {
|
|
1819
1862
|
const context = nodeContextSeed ? supervisorNodeContext(nodeContextSeed, stableProfile, task, scope) : void 0;
|
|
1820
1863
|
const priorCoordination = await deps.loadPriorCoordination?.();
|
|
@@ -1862,6 +1905,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1862
1905
|
deps.onProgressStop?.(decision.reason);
|
|
1863
1906
|
if (!stopController.signal.aborted) stopController.abort(decision.reason);
|
|
1864
1907
|
} : nodeObserver;
|
|
1908
|
+
let keeper;
|
|
1865
1909
|
const { handle: mcp, controls } = await serveCoordinationMcpForManager({
|
|
1866
1910
|
scope,
|
|
1867
1911
|
blobs: deps.blobs,
|
|
@@ -1874,6 +1918,10 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1874
1918
|
actorId: context.ownerId
|
|
1875
1919
|
} } : {},
|
|
1876
1920
|
...deps.deliverable ? { deliverable: deps.deliverable } : {},
|
|
1921
|
+
...deps.continuation ? { readContinuation: (n) => keeper?.read(n) ?? {
|
|
1922
|
+
found: false,
|
|
1923
|
+
reason: "no continuation has been sent"
|
|
1924
|
+
} } : {},
|
|
1877
1925
|
onStop: (reason) => {
|
|
1878
1926
|
if (!stopController.signal.aborted) stopController.abort(reason ?? "coordination stop");
|
|
1879
1927
|
},
|
|
@@ -1935,27 +1983,93 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1935
1983
|
}
|
|
1936
1984
|
const baseTokensLeft = scope.budget.tokensLeft;
|
|
1937
1985
|
const contractDeclared = deps.deliverable !== void 0;
|
|
1938
|
-
const
|
|
1986
|
+
const continuation = deps.continuation;
|
|
1987
|
+
if (continuation !== void 0 && deps.deliverable !== void 0) keeper = createContinuationKeeper({
|
|
1988
|
+
policy: continuation,
|
|
1989
|
+
task,
|
|
1990
|
+
...deps.deliverable.describe === void 0 ? {} : { owed: deps.deliverable.describe },
|
|
1991
|
+
...deps.deliverable.feedback === void 0 ? {} : { feedback: deps.deliverable.feedback },
|
|
1992
|
+
...deps.deliverable.sealed === true ? { sealed: true } : {},
|
|
1993
|
+
reads: () => controls.checkReads(),
|
|
1994
|
+
workers: () => {
|
|
1995
|
+
const labels = new Map((scope.view?.nodes ?? []).map((node) => [node.id, node.label]));
|
|
1996
|
+
return mcp.settled().map((worker) => ({
|
|
1997
|
+
id: worker.id,
|
|
1998
|
+
label: labels.get(worker.id) ?? worker.id
|
|
1999
|
+
}));
|
|
2000
|
+
},
|
|
2001
|
+
...deps.continuationDir === void 0 ? {} : { dir: deps.continuationDir },
|
|
2002
|
+
...deps.rootStreamPath === void 0 ? {} : { rootStreamPath: deps.rootStreamPath },
|
|
2003
|
+
canReadMore: runtimeToolNames.includes("read_continuation")
|
|
2004
|
+
});
|
|
1939
2005
|
let candidate;
|
|
2006
|
+
const finalizerDeliverable = deps.deliverable === void 0 ? void 0 : {
|
|
2007
|
+
...deps.deliverable,
|
|
2008
|
+
check: async (out) => {
|
|
2009
|
+
let verdict;
|
|
2010
|
+
try {
|
|
2011
|
+
verdict = checkVerdictOf(await deps.deliverable?.check(out));
|
|
2012
|
+
} catch (error) {
|
|
2013
|
+
controls.recordCheckRead({
|
|
2014
|
+
source: "turn-end",
|
|
2015
|
+
unavailable: error instanceof Error ? error.message : String(error)
|
|
2016
|
+
});
|
|
2017
|
+
throw error;
|
|
2018
|
+
}
|
|
2019
|
+
controls.recordCheckRead({
|
|
2020
|
+
source: "turn-end",
|
|
2021
|
+
verdict
|
|
2022
|
+
});
|
|
2023
|
+
return verdict;
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
1940
2026
|
const finalize = () => runFinalizer(deps.finalizer ?? bestDelivered, {
|
|
1941
2027
|
settled: mcp.settled(),
|
|
1942
2028
|
blobs: deps.blobs,
|
|
1943
2029
|
tree: runTree(scope),
|
|
1944
2030
|
budget: scope.budget,
|
|
1945
|
-
...
|
|
2031
|
+
...finalizerDeliverable ? { deliverable: finalizerDeliverable } : {}
|
|
1946
2032
|
});
|
|
1947
2033
|
const readProgress = () => {
|
|
1948
2034
|
const settled = mcp.settled();
|
|
1949
2035
|
const deliveredCount = settled.filter((w) => w.status === "done" && w.valid === true).length;
|
|
1950
2036
|
const submitted = Boolean(mcp.submittedResult());
|
|
2037
|
+
const composite = bestComposite(controls.checkReads());
|
|
1951
2038
|
return {
|
|
1952
2039
|
poolTokensSpent: baseTokensLeft - scope.budget.tokensLeft,
|
|
1953
2040
|
settledCount: settled.length,
|
|
1954
2041
|
submitted,
|
|
1955
2042
|
deliveredCount,
|
|
1956
|
-
contract: !contractDeclared ? "none" : submitted || candidate !== void 0 ? "met" : "unmet"
|
|
2043
|
+
contract: !contractDeclared ? "none" : submitted || candidate !== void 0 ? "met" : "unmet",
|
|
2044
|
+
...composite === void 0 ? {} : { composite }
|
|
1957
2045
|
};
|
|
1958
2046
|
};
|
|
2047
|
+
/**
|
|
2048
|
+
* The check runs when a turn ends without an accepted result. A read already taken in this
|
|
2049
|
+
* turn stands (the manager just heard it); otherwise a check that judges state reads the
|
|
2050
|
+
* run now. A check that could not run is not a verdict: the loop pauses.
|
|
2051
|
+
*/
|
|
2052
|
+
const readCheckAtTurnEnd = async (attempt) => {
|
|
2053
|
+
const deliverable = deps.deliverable;
|
|
2054
|
+
if (deliverable === void 0) return;
|
|
2055
|
+
const last = controls.checkReads().filter((read) => read.attempt === attempt).at(-1);
|
|
2056
|
+
if (last === void 0 && deliverable.checkState !== void 0) try {
|
|
2057
|
+
const verdict = checkVerdictOf(await deliverable.checkState());
|
|
2058
|
+
controls.recordCheckRead({
|
|
2059
|
+
source: "turn-end",
|
|
2060
|
+
verdict
|
|
2061
|
+
});
|
|
2062
|
+
return;
|
|
2063
|
+
} catch (error) {
|
|
2064
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2065
|
+
controls.recordCheckRead({
|
|
2066
|
+
source: "turn-end",
|
|
2067
|
+
unavailable: message
|
|
2068
|
+
});
|
|
2069
|
+
throw new CheckUnavailableError(`the completion check could not run: ${message}`, { cause: error });
|
|
2070
|
+
}
|
|
2071
|
+
if (last?.unavailable !== void 0) throw new CheckUnavailableError(`the completion check could not run: ${last.unavailable}`);
|
|
2072
|
+
};
|
|
1959
2073
|
const loopRecords = [];
|
|
1960
2074
|
let environmentReplacements = 0;
|
|
1961
2075
|
const describe = deps.deliverable?.describe;
|
|
@@ -1966,7 +2080,8 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1966
2080
|
...summarizeDriverAttempts(loopRecords),
|
|
1967
2081
|
environmentReplacements,
|
|
1968
2082
|
...closedBy === void 0 ? {} : { closedBy },
|
|
1969
|
-
...stopReason === void 0 ? {} : { stopReason }
|
|
2083
|
+
...stopReason === void 0 ? {} : { stopReason },
|
|
2084
|
+
continuations: keeper?.entries() ?? []
|
|
1970
2085
|
});
|
|
1971
2086
|
};
|
|
1972
2087
|
try {
|
|
@@ -2017,19 +2132,18 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
2017
2132
|
if (contractDeclared && !mcp.submittedResult()) {
|
|
2018
2133
|
await mcp.drainResolved();
|
|
2019
2134
|
candidate = await finalize();
|
|
2135
|
+
if (candidate === void 0 && !mcp.isStopped()) await readCheckAtTurnEnd(attempt);
|
|
2020
2136
|
}
|
|
2021
2137
|
},
|
|
2022
2138
|
progress: readProgress,
|
|
2023
2139
|
budget: () => scope.budget,
|
|
2024
2140
|
signal: scope.signal,
|
|
2025
2141
|
...deps.driverRetry ? { policy: deps.driverRetry } : {},
|
|
2026
|
-
...
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
return await deps.onUnmetContract?.(context) ?? { steer: defaultUnmetContractSteer(context) };
|
|
2032
|
-
}
|
|
2142
|
+
...continuation !== void 0 && keeper !== void 0 && continuationDeadlineMs ? { continuation: {
|
|
2143
|
+
maxBarren: continuation.maxBarren,
|
|
2144
|
+
deadlineMs: continuationDeadlineMs,
|
|
2145
|
+
compose: (context) => keeper.compose(context),
|
|
2146
|
+
closed: () => mcp.isStopped() || progressStopReason !== void 0
|
|
2033
2147
|
} } : {},
|
|
2034
2148
|
onAttempt: async (record) => {
|
|
2035
2149
|
loopRecords.push(record);
|
|
@@ -3337,6 +3451,8 @@ const superviseOptionKeySet = /* @__PURE__ */ new Set([
|
|
|
3337
3451
|
"rootHandle",
|
|
3338
3452
|
"router",
|
|
3339
3453
|
"runDir",
|
|
3454
|
+
"resume",
|
|
3455
|
+
"runContext",
|
|
3340
3456
|
"runId",
|
|
3341
3457
|
"signal",
|
|
3342
3458
|
"stallAfterMs",
|
|
@@ -3344,11 +3460,11 @@ const superviseOptionKeySet = /* @__PURE__ */ new Set([
|
|
|
3344
3460
|
"steerDir",
|
|
3345
3461
|
"stopRule",
|
|
3346
3462
|
"watchWorkers",
|
|
3347
|
-
"
|
|
3348
|
-
"onUnmetContract",
|
|
3463
|
+
"continuation",
|
|
3349
3464
|
"workerRetry",
|
|
3350
3465
|
"onWorkerRetry",
|
|
3351
|
-
"workerSlots"
|
|
3466
|
+
"workerSlots",
|
|
3467
|
+
"recoverExecutor"
|
|
3352
3468
|
]);
|
|
3353
3469
|
/**
|
|
3354
3470
|
* Refuse a top-level option key `supervise()` reads nowhere, naming it.
|
|
@@ -3366,11 +3482,16 @@ function assertSuperviseOptionKeys(opts, context) {
|
|
|
3366
3482
|
function captureDeliverable(deliverable, context) {
|
|
3367
3483
|
if (typeof deliverable !== "object" || deliverable === null || Array.isArray(deliverable)) throw new ValidationError(`${context}: deliverable must be an object`);
|
|
3368
3484
|
if (typeof deliverable.check !== "function") throw new ValidationError(`${context}: deliverable.check must be a function`);
|
|
3369
|
-
if (deliverable.
|
|
3485
|
+
if (deliverable.checkState !== void 0 && typeof deliverable.checkState !== "function") throw new ValidationError(`${context}: deliverable.checkState must be a function`);
|
|
3486
|
+
if (deliverable.feedback !== void 0 && deliverable.feedback !== "verbatim" && deliverable.feedback !== "pass-only") throw new ValidationError(`${context}: deliverable.feedback must be 'verbatim' or 'pass-only'`);
|
|
3370
3487
|
return Object.freeze({
|
|
3371
|
-
...detachedSnapshot({
|
|
3488
|
+
...detachedSnapshot({
|
|
3489
|
+
describe: deliverable.describe,
|
|
3490
|
+
...deliverable.feedback === void 0 ? {} : { feedback: deliverable.feedback },
|
|
3491
|
+
...deliverable.sealed === void 0 ? {} : { sealed: deliverable.sealed === true }
|
|
3492
|
+
}, `${context} configuration`),
|
|
3372
3493
|
check: deliverable.check,
|
|
3373
|
-
...deliverable.
|
|
3494
|
+
...deliverable.checkState === void 0 ? {} : { checkState: deliverable.checkState }
|
|
3374
3495
|
});
|
|
3375
3496
|
}
|
|
3376
3497
|
Object.freeze([...[
|
|
@@ -3386,8 +3507,8 @@ Object.freeze([...[
|
|
|
3386
3507
|
"onCoordinationEvent",
|
|
3387
3508
|
"onDriverAttempt",
|
|
3388
3509
|
"onProgressStop",
|
|
3389
|
-
"onUnmetContract",
|
|
3390
3510
|
"onWorkerRetry",
|
|
3511
|
+
"recoverExecutor",
|
|
3391
3512
|
"resolveDeliverable",
|
|
3392
3513
|
"resolveDriveHarness",
|
|
3393
3514
|
"resolveSpawnProfile",
|
|
@@ -3425,7 +3546,7 @@ function rootSpawnResourceRoot(backend) {
|
|
|
3425
3546
|
}
|
|
3426
3547
|
function captureSuperviseOptions(opts) {
|
|
3427
3548
|
assertSuperviseOptionKeys(opts, "supervise");
|
|
3428
|
-
const { backend, coordination, driverBackend, deliverable, resolveDeliverable, router, compaction, watchWorkers, analysts, makeWorkerAgent, makeLeafAgent, resolveSpawnProfile, blobs, journal, probes, registry, hooks, otel, authorizeSpawn, authorizeMessage, driveHarness, resolveDriveHarness, resolveSupervisorTools, escalateQuestion, onCoordinationEvent, executeExtraTool, stopRule, onProgressStop, onDriverAttempt,
|
|
3549
|
+
const { backend, coordination, driverBackend, deliverable, resolveDeliverable, router, compaction, watchWorkers, analysts, makeWorkerAgent, makeLeafAgent, recoverExecutor, resume, resolveSpawnProfile, blobs, journal, runContext, probes, registry, hooks, otel, authorizeSpawn, authorizeMessage, driveHarness, resolveDriveHarness, resolveSupervisorTools, escalateQuestion, onCoordinationEvent, executeExtraTool, stopRule, onProgressStop, onDriverAttempt, continuation, workerRetry, onWorkerRetry, finalizer, now, signal, rootHandle, workerSlots, ...decisionData } = opts;
|
|
3429
3550
|
assertNoUncapturedExecutableOption(decisionData);
|
|
3430
3551
|
const capturedData = detachedSnapshot(decisionData, "supervise options");
|
|
3431
3552
|
const capturedCoordination = coordination === void 0 ? void 0 : (() => {
|
|
@@ -3473,6 +3594,14 @@ function captureSuperviseOptions(opts) {
|
|
|
3473
3594
|
run: analysts.run,
|
|
3474
3595
|
...typeof analysts.register === "function" ? { register: analysts.register } : {}
|
|
3475
3596
|
});
|
|
3597
|
+
const capturedContinuation = continuation === void 0 ? void 0 : (() => {
|
|
3598
|
+
const { runPanel, append, ...policy } = continuation;
|
|
3599
|
+
return Object.freeze({
|
|
3600
|
+
...detachedSnapshot(policy, "supervise continuation"),
|
|
3601
|
+
...runPanel === void 0 ? {} : { runPanel },
|
|
3602
|
+
...append === void 0 ? {} : { append }
|
|
3603
|
+
});
|
|
3604
|
+
})();
|
|
3476
3605
|
return Object.freeze({
|
|
3477
3606
|
...capturedData,
|
|
3478
3607
|
...capturedCoordination === void 0 ? {} : { coordination: capturedCoordination },
|
|
@@ -3486,9 +3615,12 @@ function captureSuperviseOptions(opts) {
|
|
|
3486
3615
|
...capturedAnalysts === void 0 ? {} : { analysts: capturedAnalysts },
|
|
3487
3616
|
...makeWorkerAgent === void 0 ? {} : { makeWorkerAgent },
|
|
3488
3617
|
...makeLeafAgent === void 0 ? {} : { makeLeafAgent },
|
|
3618
|
+
...recoverExecutor === void 0 ? {} : { recoverExecutor },
|
|
3489
3619
|
...resolveSpawnProfile === void 0 ? {} : { resolveSpawnProfile },
|
|
3490
3620
|
...blobs === void 0 ? {} : { blobs },
|
|
3491
3621
|
...journal === void 0 ? {} : { journal },
|
|
3622
|
+
...resume === void 0 ? {} : { resume },
|
|
3623
|
+
...runContext === void 0 ? {} : { runContext },
|
|
3492
3624
|
...workerSlots === void 0 ? {} : { workerSlots },
|
|
3493
3625
|
...probes === void 0 ? {} : { probes },
|
|
3494
3626
|
...authorizeSpawn === void 0 ? {} : { authorizeSpawn },
|
|
@@ -3502,7 +3634,7 @@ function captureSuperviseOptions(opts) {
|
|
|
3502
3634
|
...stopRule === void 0 ? {} : { stopRule },
|
|
3503
3635
|
...onProgressStop === void 0 ? {} : { onProgressStop },
|
|
3504
3636
|
...onDriverAttempt === void 0 ? {} : { onDriverAttempt },
|
|
3505
|
-
...
|
|
3637
|
+
...capturedContinuation === void 0 ? {} : { continuation: capturedContinuation },
|
|
3506
3638
|
...capturedWorkerRetry === void 0 ? {} : { workerRetry: capturedWorkerRetry },
|
|
3507
3639
|
...onWorkerRetry === void 0 ? {} : { onWorkerRetry },
|
|
3508
3640
|
...finalizer === void 0 ? {} : { finalizer },
|
|
@@ -3688,12 +3820,18 @@ function coordinationEventId(context, event) {
|
|
|
3688
3820
|
/** One-call supervisor: build + run a supervisor from its exact profile. @stable */
|
|
3689
3821
|
function supervise(profile, task, opts) {
|
|
3690
3822
|
if ("brain" in opts) throw new ValidationError("supervise: direct brain injection is test-only; production execution derives the model call from AgentProfile");
|
|
3691
|
-
return
|
|
3823
|
+
return superviseWithContext(profile, task, opts);
|
|
3824
|
+
}
|
|
3825
|
+
/** A stop rule as a function, or the declared plateau form a record carries as data. */
|
|
3826
|
+
function stopRuleOf(rule) {
|
|
3827
|
+
if (typeof rule === "function") return rule;
|
|
3828
|
+
if (typeof rule === "object" && rule !== null && "plateau" in rule) return plateau(rule.plateau);
|
|
3829
|
+
throw new ValidationError("supervise: stopRule must be a StopRule or { plateau: { window, minDelta } }");
|
|
3692
3830
|
}
|
|
3693
3831
|
/** Deterministic scripted-brain path for tests. Not exported from Runtime's main entry. */
|
|
3694
3832
|
function superviseWithTestBrain(profile, task, opts) {
|
|
3695
3833
|
const { brain, ...runtimeOptions } = opts;
|
|
3696
|
-
return
|
|
3834
|
+
return superviseWithContext(profile, task, runtimeOptions, brain);
|
|
3697
3835
|
}
|
|
3698
3836
|
/**
|
|
3699
3837
|
* The composer `profileGuidance` selects, or `undefined` when no guidance is selected. The result
|
|
@@ -3721,8 +3859,23 @@ function superviseRootProfile(profile, profileGuidance) {
|
|
|
3721
3859
|
const compose = profileGuidanceComposer(profileGuidance);
|
|
3722
3860
|
return freezeDetachedProfile(compose ? compose(parsedProfile.data) : parsedProfile.data);
|
|
3723
3861
|
}
|
|
3862
|
+
function superviseWithContext(profile, task, opts, brain) {
|
|
3863
|
+
if (opts.runContext?.acquire === void 0) return superviseInternal(profile, task, opts, brain);
|
|
3864
|
+
const options = captureSuperviseOptions(opts);
|
|
3865
|
+
const capturedProfile = freezeDetached(profile);
|
|
3866
|
+
const capturedTask = freezeDetached(task);
|
|
3867
|
+
return withRunContext(opts.runContext, options.signal, (runContext, signal) => superviseInternal(capturedProfile, capturedTask, {
|
|
3868
|
+
...options,
|
|
3869
|
+
runContext,
|
|
3870
|
+
...signal === void 0 ? {} : { signal }
|
|
3871
|
+
}, brain));
|
|
3872
|
+
}
|
|
3724
3873
|
function superviseInternal(profile, task, opts, testBrain) {
|
|
3725
3874
|
const options = captureSuperviseOptions(opts);
|
|
3875
|
+
if (options.runContext?.durability === "sql") {
|
|
3876
|
+
if (options.runDir !== void 0 || options.journal !== void 0 && options.journal !== options.runContext.journal || options.blobs !== void 0 && options.blobs !== options.runContext.blobs || options.runId !== void 0 && options.runId !== options.runContext.runId) throw new ValidationError("supervise: SQL runContext cannot be mixed with another run identity or persistence path");
|
|
3877
|
+
if (options.backend?.backend !== "provider" || options.makeWorkerAgent || options.makeLeafAgent) throw new ValidationError("supervise: SQL runContext requires backend-derived retained provider workers");
|
|
3878
|
+
}
|
|
3726
3879
|
assertValidBudget(options.budget, "supervise budget");
|
|
3727
3880
|
const composeSpawnProfile = profileGuidanceComposer(options.profileGuidance);
|
|
3728
3881
|
const canonicalProfile = superviseRootProfile(profile, options.profileGuidance);
|
|
@@ -3759,7 +3912,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3759
3912
|
if (options.backend !== void 0 && options.makeLeafAgent === void 0 && declaredRuntimeToolNames(entry).length === 0) assertBackendProfileMaterialization(entry, options.backend, context);
|
|
3760
3913
|
} : void 0);
|
|
3761
3914
|
assertCoordinationBinding(options.coordination);
|
|
3762
|
-
const ctx = options.runDir !== void 0 ? createFileRunContext(options.runDir, { withDriver: true }) : createInMemoryRunContext({ withDriver: true });
|
|
3915
|
+
const ctx = options.runContext ?? (options.runDir !== void 0 ? createFileRunContext(options.runDir, { withDriver: true }) : createInMemoryRunContext({ withDriver: true }));
|
|
3763
3916
|
const blobs = options.blobs ?? ctx.blobs;
|
|
3764
3917
|
assertRecursiveReservationPolicy(options.reservationPolicy);
|
|
3765
3918
|
const ownerShare = options.reservationPolicy?.ownerShare ?? 0;
|
|
@@ -3767,8 +3920,8 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3767
3920
|
assertValidBudget(perWorker, "supervise perWorker");
|
|
3768
3921
|
assertPerWorkerWithinPool(perWorker, options.budget);
|
|
3769
3922
|
const journal = options.journal ?? ctx.journal;
|
|
3770
|
-
const runId = options.runId ?? "supervise";
|
|
3771
|
-
const runNamespace = supervisionRunNamespace(options.runDir, runId);
|
|
3923
|
+
const runId = options.runId ?? ctx.runId ?? "supervise";
|
|
3924
|
+
const runNamespace = ctx.namespace ?? supervisionRunNamespace(options.runDir, runId);
|
|
3772
3925
|
const log = ctx.coordinationLog;
|
|
3773
3926
|
const rootOwnerId = rootCoordinationOwner(rootExecution.identity);
|
|
3774
3927
|
const rootProviderModels = [];
|
|
@@ -3949,7 +4102,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3949
4102
|
...composeSpawnProfileFor(authorized) ? { composeSpawnProfile: composeSpawnProfileFor(authorized) } : {},
|
|
3950
4103
|
...profileTable ? { profiles: profileTable } : {},
|
|
3951
4104
|
...options.peerMail ? { peerMail: options.peerMail } : {},
|
|
3952
|
-
...options.stopRule ? { stopRule: options.stopRule } : {},
|
|
4105
|
+
...options.stopRule ? { stopRule: stopRuleOf(options.stopRule) } : {},
|
|
3953
4106
|
...options.onProgressStop ? { onProgressStop: options.onProgressStop } : {},
|
|
3954
4107
|
...options.maxTurns !== void 0 ? { maxTurns: options.maxTurns } : {},
|
|
3955
4108
|
...options.compaction ? { compaction: options.compaction } : {},
|
|
@@ -3959,8 +4112,10 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3959
4112
|
...childDeliverable ? { onAcceptedSubmission: () => {
|
|
3960
4113
|
acceptedSubmission = true;
|
|
3961
4114
|
} } : {},
|
|
3962
|
-
...options.
|
|
3963
|
-
|
|
4115
|
+
...childDeliverable && options.continuation && isExternalSupervisor(authorized) ? {
|
|
4116
|
+
continuation: options.continuation,
|
|
4117
|
+
...options.runDir === void 0 ? {} : { continuationDir: resolve(options.runDir, CONTINUATIONS_DIR, "managers", encodeURIComponent(ownerId)) }
|
|
4118
|
+
} : {},
|
|
3964
4119
|
...log ? {
|
|
3965
4120
|
onEvent: (_event, record) => log.append(runId, record, ownerId),
|
|
3966
4121
|
loadPriorCoordination: () => log.load(runId, ownerId)
|
|
@@ -4010,6 +4165,12 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4010
4165
|
const workerFactory = makeWorkerAgent;
|
|
4011
4166
|
let rootContinuation;
|
|
4012
4167
|
const start = async () => {
|
|
4168
|
+
if (ctx.durability === "sql") {
|
|
4169
|
+
if (options.backend?.backend !== "provider" || options.backend.steering || options.driveHarness || options.resolveDriveHarness || options.driverBackend) throw new ValidationError("supervise: SQL runContext requires a local coordinator and non-steering retained provider workers");
|
|
4170
|
+
const provider = resolveAgentEnvironmentProvider(options.backend.provider, options.backend.registry);
|
|
4171
|
+
const capabilities = await provider.capabilities();
|
|
4172
|
+
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");
|
|
4173
|
+
}
|
|
4013
4174
|
await verifyProfilePromotions(profileTable);
|
|
4014
4175
|
const priorCoordination = log ? await log.load(runId, rootOwnerId) : void 0;
|
|
4015
4176
|
const authorizeRootMessage = authorizeDownFor(canonicalProfile, 1);
|
|
@@ -4059,14 +4220,19 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4059
4220
|
...options.stallAfterMs !== void 0 ? { stallAfterMs: options.stallAfterMs } : {},
|
|
4060
4221
|
...options.awaitTimeoutMs !== void 0 ? { awaitTimeoutMs: options.awaitTimeoutMs } : {},
|
|
4061
4222
|
...options.continuityByProfile ? { continuityByProfile: options.continuityByProfile } : {},
|
|
4062
|
-
...options.stopRule ? { stopRule: options.stopRule } : {},
|
|
4223
|
+
...options.stopRule ? { stopRule: stopRuleOf(options.stopRule) } : {},
|
|
4063
4224
|
...options.onProgressStop ? { onProgressStop: options.onProgressStop } : {},
|
|
4064
4225
|
...options.maxTurns !== void 0 ? { maxTurns: options.maxTurns } : {},
|
|
4065
4226
|
...options.compaction ? { compaction: options.compaction } : {},
|
|
4066
4227
|
...options.driverRetry ? { driverRetry: options.driverRetry } : {},
|
|
4067
4228
|
...options.onDriverAttempt ? { onDriverAttempt: options.onDriverAttempt } : {},
|
|
4068
|
-
...options.
|
|
4069
|
-
|
|
4229
|
+
...deliverable && options.continuation && isExternalSupervisor(canonicalProfile) ? {
|
|
4230
|
+
continuation: options.continuation,
|
|
4231
|
+
...options.runDir === void 0 ? {} : {
|
|
4232
|
+
continuationDir: resolve(options.runDir, CONTINUATIONS_DIR),
|
|
4233
|
+
rootStreamPath: resolve(options.runDir, ROOT_STREAM_FILE)
|
|
4234
|
+
}
|
|
4235
|
+
} : {},
|
|
4070
4236
|
...options.runDir === void 0 || runControl === void 0 ? {} : {
|
|
4071
4237
|
controlDir: resolve(options.runDir),
|
|
4072
4238
|
abortRun: cancelDurableRun
|
|
@@ -4099,7 +4265,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4099
4265
|
journal,
|
|
4100
4266
|
blobs,
|
|
4101
4267
|
executors: ctx.executors,
|
|
4102
|
-
...recoveryFactories.get(workerFactory) ? { recoverExecutor: recoveryFactories.get(workerFactory) } : {},
|
|
4268
|
+
...options.recoverExecutor ?? recoveryFactories.get(workerFactory) ? { recoverExecutor: options.recoverExecutor ?? recoveryFactories.get(workerFactory) } : {},
|
|
4103
4269
|
rootIdentity: rootExecution.identity,
|
|
4104
4270
|
...rootOwnerRuntime === void 0 ? {} : { rootMaterialization: {
|
|
4105
4271
|
runtime: rootOwnerRuntime,
|
|
@@ -4114,7 +4280,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4114
4280
|
...options.workerSlots !== void 0 ? { workerSlots: options.workerSlots } : {},
|
|
4115
4281
|
...options.reservationPolicy ? { reservationPolicy: options.reservationPolicy } : {},
|
|
4116
4282
|
...probes ? { probes } : {},
|
|
4117
|
-
...ctx.resume === true ? { resume: true } : {},
|
|
4283
|
+
...ctx.resume === true || options.runDir === void 0 && options.resume === true ? { resume: true } : {},
|
|
4118
4284
|
...options.now ? { now: options.now } : {},
|
|
4119
4285
|
signal: options.signal ? AbortSignal.any([options.signal, durableCancellation.signal]) : durableCancellation.signal,
|
|
4120
4286
|
...hooks ? { hooks } : {},
|
|
@@ -4136,11 +4302,13 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4136
4302
|
}
|
|
4137
4303
|
}
|
|
4138
4304
|
recordRunCancellationOutcome(options.runDir, result, now);
|
|
4305
|
+
const rootHarnessTranscript = rootDriveHarness === void 0 ? void 0 : await persistHarnessTranscript(readHarnessTranscript(rootDriveHarness), blobs);
|
|
4139
4306
|
const rootProviderModel = ctx.resume === true ? rootProviderModelEvidence([]) : rootProviderModels.length > 0 ? rootProviderModelEvidence(rootProviderModels) : rootDriveHarness === void 0 ? rootProviderModelEvidence([]) : rootProviderModelEvidenceFromExecution(runtimeOwnedDriveHarnessProviderEvidence(rootDriveHarness));
|
|
4140
4307
|
return {
|
|
4141
4308
|
...result,
|
|
4142
4309
|
rootProviderModel,
|
|
4143
4310
|
...rootStream === void 0 ? {} : { rootStream },
|
|
4311
|
+
...rootHarnessTranscript === void 0 ? {} : { rootHarnessTranscript },
|
|
4144
4312
|
...rootContinuation === void 0 ? {} : { continuation: rootContinuation }
|
|
4145
4313
|
};
|
|
4146
4314
|
};
|
|
@@ -4190,4 +4358,4 @@ function rootProviderModelEvidenceFromExecution(evidence) {
|
|
|
4190
4358
|
//#endregion
|
|
4191
4359
|
export { gateOnDeliverable as C, serveCoordinationMcp as S, readRootStream as _, superviseWithTestBrain as a, composeReentryTask as b, resolveWorkerSpawnRetry as c, assertCoordinationBinding as d, coordinationProfileToolPrefix as f, ROOT_STREAM_FILE as g, supervisorAgentWithTestBrain as h, superviseRootProfile as i, retryPreSpawnRefusals as l, supervisorAgent as m, profileGuidanceComposer as n, workerFromBackend as o, resolveSupervisorProfile as p, supervise as r, isPreSpawnExecutorFailure as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, withWorkerSpawnRetry as u, readRootStreamReceipt as v, mapExecutorResult as w, createSupervisorSpanRecorder as x, UNPROVEN_CONTINUITY as y };
|
|
4192
4360
|
|
|
4193
|
-
//# sourceMappingURL=supervise
|
|
4361
|
+
//# sourceMappingURL=supervise-Dej5aSDa.js.map
|