@tangle-network/agent-runtime 0.259.1 → 0.262.0
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-Btw2npV2.js → activation-C0AoYRgS.js} +3 -3
- package/dist/{activation-Btw2npV2.js.map → activation-C0AoYRgS.js.map} +1 -1
- package/dist/{activation-Cus2oZaT.d.ts → activation-CozZXBTg.d.ts} +2 -2
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/{bundle-DXrBPEFw.js → bundle-CvLGRVO-.js} +2 -2
- package/dist/{bundle-DXrBPEFw.js.map → bundle-CvLGRVO-.js.map} +1 -1
- package/dist/candidate-execution/index.js +5 -4
- package/dist/candidate-execution/index.js.map +1 -1
- package/dist/{coordination-driver-BmtrkNPu.js → coordination-driver-COGC8FK2.js} +377 -32
- package/dist/coordination-driver-COGC8FK2.js.map +1 -0
- package/dist/{delegate-DJgmZZKH.js → delegate-BC7Au73v.js} +2 -2
- package/dist/{delegate-DJgmZZKH.js.map → delegate-BC7Au73v.js.map} +1 -1
- package/dist/durable.d.ts +285 -57
- package/dist/durable.js +637 -108
- package/dist/durable.js.map +1 -1
- package/dist/{graph-BKRvWzHx.js → graph-DgODOGWN.js} +4 -3
- package/dist/graph-DgODOGWN.js.map +1 -0
- package/dist/{improvement-cycle-D0Os0Hg_.js → improvement-cycle-DirqO-fX.js} +8 -7
- package/dist/improvement-cycle-DirqO-fX.js.map +1 -0
- package/dist/{index-sGOO254Q.d.ts → index-B8tXCisZ.d.ts} +251 -293
- package/dist/index.d.ts +6 -6
- package/dist/index.js +9 -9
- package/dist/intelligence.d.ts +3 -3
- package/dist/intelligence.js +7 -6
- 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-DAU4rNIL.d.ts → loop-runner-bin-BaZd1XIm.d.ts} +3 -3
- package/dist/{loop-runner-bin-pRlDgm1i.js → loop-runner-bin-C9P1ELVv.js} +3 -3
- package/dist/{loop-runner-bin-pRlDgm1i.js.map → loop-runner-bin-C9P1ELVv.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +6 -6
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-BsqD1_Zr.d.ts → openai-tools-CHwN_S24.d.ts} +2 -2
- package/dist/{prepare-RuaAclli.js → prepare-oHUQdC5-.js} +22 -452
- package/dist/prepare-oHUQdC5-.js.map +1 -0
- package/dist/profile-D3eXNBQV.js +438 -0
- package/dist/profile-D3eXNBQV.js.map +1 -0
- package/dist/profiles.d.ts +2 -2
- package/dist/{protected-model-port-BFhSgMAy.js → protected-model-port-DqF0qDU6.js} +4 -3
- package/dist/{protected-model-port-BFhSgMAy.js.map → protected-model-port-DqF0qDU6.js.map} +1 -1
- package/dist/{provision-supervisor-B9tf4soF.js → provision-supervisor-9FMwo-Es.js} +3 -3
- package/dist/{provision-supervisor-B9tf4soF.js.map → provision-supervisor-9FMwo-Es.js.map} +1 -1
- package/dist/{runtime-DKiucqGX.js → runtime-BXWVW51r.js} +218 -20
- package/dist/runtime-BXWVW51r.js.map +1 -0
- package/dist/{server-DIsiQ6mu.js → server-6g6KFwUC.js} +3 -3
- package/dist/{server-DIsiQ6mu.js.map → server-6g6KFwUC.js.map} +1 -1
- package/dist/{stream-agent-turn-DRTFLphI.d.ts → stream-agent-turn-u28hoxuR.d.ts} +2 -2
- package/dist/{structural-rollout-BIBxgW64.js → structural-rollout-WEfWpjub.js} +2 -2
- package/dist/{structural-rollout-BIBxgW64.js.map → structural-rollout-WEfWpjub.js.map} +1 -1
- package/dist/{substrate-BToFBpfh.d.ts → substrate-BeQiXkpa.d.ts} +2 -2
- package/dist/{supervise-DsQjhLN-.js → supervise-BeAI8-On.js} +295 -51
- package/dist/supervise-BeAI8-On.js.map +1 -0
- package/dist/{supervisor-CJyzUjc7.js → supervisor-BGGvnXvV.js} +243 -24
- package/dist/{supervisor-CJyzUjc7.js.map → supervisor-BGGvnXvV.js.map} +1 -1
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +14 -14
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-ChewVlpE.d.ts → types-CP3iQ8Ji.d.ts} +376 -4
- package/dist/{workspace-archive-DQGFwvM6.js → workspace-archive-C9lgf77y.js} +11 -11
- package/dist/workspace-archive-C9lgf77y.js.map +1 -0
- package/package.json +5 -5
- package/dist/coordination-driver-BmtrkNPu.js.map +0 -1
- package/dist/graph-BKRvWzHx.js.map +0 -1
- package/dist/improvement-cycle-D0Os0Hg_.js.map +0 -1
- package/dist/prepare-RuaAclli.js.map +0 -1
- package/dist/runtime-DKiucqGX.js.map +0 -1
- package/dist/supervise-DsQjhLN-.js.map +0 -1
- package/dist/workspace-archive-DQGFwvM6.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ci as Driver, Wi as OutputAdapter, Yi as Validator, xi as AgentRunSpec } from "./types-CP3iQ8Ji.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-BeQiXkpa.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as scopeRetainedOwnerContext, Bn as retainedExecutorSeamKey, Br as assertProfileMaterialization, Bt as spendFromUsageTotals, C as meterRuntimeOwnedAccounting, D as scopeOwnerExecutorNodeContext, Di as detachedSnapshot, E as restoreScopeOwnerAcceptedExecution, En as routerBrain, F as bindScopeRetainedOwnerEnvironmentId, Ft as assertValidBudget, Gr as promptControlProfileMaterialization, H as scopeRetainedOwnerResourceReader, Hi as addSpend, Hr as defineProfileMaterializationContract, I as bindScopeRetainedOwnerProvider, Jn as RunCancellationReason, Kr as promptModelProfileMaterialization, L as consumeScopeRetainedOwnerResult, Lt as meterUsageEvent, Pn as resolveAgentEnvironmentProvider, Qr as unsupportedProfileDimensions, R as prepareScopeRetainedOwnerTask, Rt as newUsageTotals, S as deriveNodeExecutionIdentity, T as recordScopeOwnerMaterialization, U as scopeRetainedOwnerResult, Ur as fullProfileMaterialization, V as scopeRetainedOwnerPriorSpend, Vr as controlProfileMaterialization, Vt as WORKER_TRACE_PROPAGATION, Wr as profileMaterializationAxes$1, Xi as sleep, Xn as linkAbort, Xr as renderUnsupported, Xt as createInbox, Zn as runAbortable, _ as isDriverSpec, _i as runtimeOwnedExecutorExecutionBinding, _r as generateSpanId, aa as withBudgetResources, b as beginScopeOwnerAttempt, bi as runtimeOwnedPendingExecutorMaterialization, cn as bridgeAdmissionRefusal, da as teardownExecutor, ea as unmeteredSpend, ei as worktreeCliProfileMaterialization, f as defaultUnmetContractSteer, fa as teardownSurfaces, g as driverExecutorFactory, gi as runtimeOwnedDriveHarnessProviderEvidence, h as driverChild, hi as recordRuntimeOwnedDriveHarnessProviderEvidence, hn as bridgeStopSignalKey, ht as snapshotExecutorConfig, ia as resourceTelemetry, ii as readCommittedJsonLines, ir as contentAddress, it as errMessage, la as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, ln as bridgeModelRouteRefusal, lt as bindReusableExecutorExecutionId, m as summarizeDriverAttempts, mi as providerAttemptEvidence, mn as bridgeRuntimeAttachmentsKey, mr as createOtelExporter, n as createSupervisor, na as zeroSpend, o as runFinalizer, p as runDriverWithRetry, pt as createExecutor, r as bestDelivered, ra as addResourceSpend, ri as prepareJsonlAppend, s as runTree, si as attestRuntimeOwnedScopeOwner, sn as executorFailure, t as createRootHandle, ta as withTimeout, ti as isNoEntError, u as HarnessTurnFailedError, ui as inheritRuntimeOwnedExecutorAttestation, ut as captureReusableExecutorConfig, vi as runtimeOwnedExecutorMaterialization, w as meterRuntimeOwnedProviderAttempt, xi as runtimeOwnedScopeOwnerRuntime, xr as toOtelAttributes, y as assertRecursiveReservationPolicy, yi as runtimeOwnedExecutorProviderEvidence, z as reconcileScopeRetainedOwnerEnvironment, zn as registerRetainedExecutorPreparation } from "./supervisor-BGGvnXvV.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
6
|
import { n as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-x9NEhvHZ.js";
|
|
7
|
-
import { D as coordinationVerbNames, S as watchRunCancellation, c as createProgressTracker, d as progressStop, k as createCoordinationToolsForManager, n as createSteerAcknowledger, r as driverAgent, t as createCancelAcknowledger, v as createFileRunContext, w as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, x as applyRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-
|
|
7
|
+
import { D as coordinationVerbNames, S as watchRunCancellation, c as createProgressTracker, d as progressStop, k as createCoordinationToolsForManager, n as createSteerAcknowledger, r as driverAgent, t as createCancelAcknowledger, v as createFileRunContext, w as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, x as applyRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-COGC8FK2.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";
|
|
@@ -680,7 +680,9 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
680
680
|
const audiences = /* @__PURE__ */ new Set();
|
|
681
681
|
const paths = /* @__PURE__ */ new Set(["/mcp"]);
|
|
682
682
|
const ownerReader = opts.spawnResourceReader ?? (opts.spawnResourceRoot === void 0 ? scopeRetainedOwnerResourceReader(opts.scope) : void 0);
|
|
683
|
+
let probeableByName;
|
|
683
684
|
const coord = createCoordinationToolsForManager({
|
|
685
|
+
resolveProbeTool: (name) => probeableByName?.get(name),
|
|
684
686
|
scope: opts.scope,
|
|
685
687
|
blobs: opts.blobs,
|
|
686
688
|
makeWorkerAgent: opts.makeWorkerAgent,
|
|
@@ -706,6 +708,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
706
708
|
...opts.preflightSpawn ? { preflightSpawn: opts.preflightSpawn } : {},
|
|
707
709
|
...opts.resolveSpawnProfile ? { resolveSpawnProfile: opts.resolveSpawnProfile } : {},
|
|
708
710
|
...opts.composeSpawnProfile ? { composeSpawnProfile: opts.composeSpawnProfile } : {},
|
|
711
|
+
...opts.profiles ? { profiles: opts.profiles } : {},
|
|
709
712
|
...opts.spawnResourceRoot ? { spawnResourceRoot: opts.spawnResourceRoot } : {},
|
|
710
713
|
...ownerReader ? { spawnResourceReader: ownerReader } : {},
|
|
711
714
|
...opts.peerMail ? { peerMail: typeof opts.peerMail === "object" && opts.peerMail.limits ? { limits: opts.peerMail.limits } : {} } : {}
|
|
@@ -730,6 +733,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
730
733
|
if (tool === void 0) throw new ValidationError(`serveCoordinationMcp: requested tool ${JSON.stringify(name)} is unavailable`);
|
|
731
734
|
return tool;
|
|
732
735
|
});
|
|
736
|
+
probeableByName = new Map(servedTools.map((tool) => [tool.name, tool]));
|
|
733
737
|
const mcp = createStdioToolServer({
|
|
734
738
|
serverName: "coordination",
|
|
735
739
|
serverVersion: "1",
|
|
@@ -1226,6 +1230,90 @@ function truncate(value) {
|
|
|
1226
1230
|
return value.length > MAX_DETAIL_CHARS ? `${value.slice(0, MAX_DETAIL_CHARS)}…` : value;
|
|
1227
1231
|
}
|
|
1228
1232
|
//#endregion
|
|
1233
|
+
//#region src/runtime/supervise/reentry.ts
|
|
1234
|
+
/** Continuity when nothing is proven: compose the full state. */
|
|
1235
|
+
const UNPROVEN_CONTINUITY = Object.freeze({
|
|
1236
|
+
session: "new",
|
|
1237
|
+
environment: "unknown",
|
|
1238
|
+
workspace: "unknown"
|
|
1239
|
+
});
|
|
1240
|
+
/** Compose the task for one re-entered drive. */
|
|
1241
|
+
function composeReentryTask(input) {
|
|
1242
|
+
const { reentry, continuity, state } = input;
|
|
1243
|
+
if (reentry.reason === "unmet-contract" && continuity.session === "continued") {
|
|
1244
|
+
const changes = stateLines(state, false);
|
|
1245
|
+
return [reentry.steer, ...changes.length > 0 ? ["", ...changes] : []].join("\n");
|
|
1246
|
+
}
|
|
1247
|
+
return [
|
|
1248
|
+
`You are re-entering a run that is already in progress (driver attempt ${input.attempt}). This is the same run and the same objective, not a new one.`,
|
|
1249
|
+
whyLine(reentry),
|
|
1250
|
+
environmentLine(continuity),
|
|
1251
|
+
"",
|
|
1252
|
+
"## Objective",
|
|
1253
|
+
"",
|
|
1254
|
+
"This is the original task of the run, unchanged:",
|
|
1255
|
+
"",
|
|
1256
|
+
taskText(input.originalTask),
|
|
1257
|
+
"",
|
|
1258
|
+
"## Completion check",
|
|
1259
|
+
"",
|
|
1260
|
+
input.contract === void 0 || input.contract.trim().length === 0 ? "The run ends when submit_result passes the independent check." : `The run ends when submit_result passes the independent check. It expects: ${input.contract.trim()}`,
|
|
1261
|
+
...reentry.reason === "unmet-contract" ? [
|
|
1262
|
+
"",
|
|
1263
|
+
"What is still unmet:",
|
|
1264
|
+
"",
|
|
1265
|
+
reentry.steer
|
|
1266
|
+
] : [],
|
|
1267
|
+
"",
|
|
1268
|
+
"## Run state, from the coordinator",
|
|
1269
|
+
"",
|
|
1270
|
+
...stateLines(state, true),
|
|
1271
|
+
"",
|
|
1272
|
+
"## What to do now",
|
|
1273
|
+
"",
|
|
1274
|
+
"Continue the run from this state.",
|
|
1275
|
+
"Receive the waiting events with await_event, and read the output of every settled worker before you spawn anything new.",
|
|
1276
|
+
"Do not spawn a replacement for a worker that is running or has settled.",
|
|
1277
|
+
"Your coordination tools are served by the same coordinator as before, and the state above comes from it."
|
|
1278
|
+
].join("\n");
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Why the driver is back, in one clause. The failure's own text stays in the attempt records and
|
|
1282
|
+
* never reaches the driver: measured 2026-09-11, a continuation told the details of a provider
|
|
1283
|
+
* failure spent two of its first four children probing the infrastructure, while its peer, told
|
|
1284
|
+
* only what to continue, spent all forty-five on the research.
|
|
1285
|
+
*/
|
|
1286
|
+
function whyLine(reentry) {
|
|
1287
|
+
return reentry.reason === "unmet-contract" ? `Your previous turn ended with the completion check unmet (re-prompt ${reentry.reprompt}).` : `Your previous turn ended before it finished (retry ${reentry.retry}); the run itself is intact.`;
|
|
1288
|
+
}
|
|
1289
|
+
function environmentLine(continuity) {
|
|
1290
|
+
if (continuity.environment === "same") return `You run in the same environment as before${continuity.environmentId === void 0 ? "" : ` (${continuity.environmentId})`}, and your files are where you left them.`;
|
|
1291
|
+
if (continuity.environment === "replaced") return `Your previous environment${continuity.previousEnvironmentId === void 0 ? "" : ` (${continuity.previousEnvironmentId})`} is gone, and you run in a new one. ` + (continuity.workspace === "kept" ? "Its files were carried over." : "Files you wrote there are not here. The coordinator and the knowledge store kept everything below.");
|
|
1292
|
+
return "You may be in a new environment. Check for files before you rely on them; the coordinator kept everything below.";
|
|
1293
|
+
}
|
|
1294
|
+
function stateLines(state, full) {
|
|
1295
|
+
const lines = [];
|
|
1296
|
+
if (full || state.journalRows > state.journalReadTo) lines.push(`Journal: ${state.journalRows} rows. You last read up to row ${state.journalReadTo}; call read_journal with sinceRow ${state.journalReadTo} to read what happened since, or sinceRow 0 to read the whole run.`);
|
|
1297
|
+
if (state.live.length > 0) lines.push(`Workers running: ${state.live.map((worker) => `${worker.id} (${worker.label}, ${worker.status})`).join("; ")}.`);
|
|
1298
|
+
else if (full) lines.push("Workers running: none.");
|
|
1299
|
+
const settled = full ? state.settled : state.settled.filter((worker) => !worker.delivered);
|
|
1300
|
+
if (settled.length > 0) lines.push(`Workers settled${full ? "" : " that you have not received"}: ${settled.map((worker) => `${worker.id} (${worker.status}${worker.valid === void 0 ? "" : worker.valid ? ", passed its check" : ", did not pass its check"}${worker.delivered ? "" : ", not yet received"})`).join("; ")}. Read an output with observe_agent and the worker id.`);
|
|
1301
|
+
else if (full) lines.push("Workers settled: none.");
|
|
1302
|
+
if (state.waiting.length > 0) lines.push(`Events waiting for you in await_event: ${state.waiting.length} (${state.waiting.map((event) => event.worker === void 0 ? event.type : `${event.type} from ${event.worker}`).join("; ")}).`);
|
|
1303
|
+
else if (full) lines.push("Events waiting for you in await_event: none.");
|
|
1304
|
+
if (state.unacknowledged.length > 0) lines.push(`Events delivered to a turn that did not finish, so treat them as unread: ${state.unacknowledged.map((event) => `#${event.seq} ${event.type}${event.worker === void 0 ? "" : ` from ${event.worker}`}`).join("; ")}. Pass their numbers in await_event's acknowledge once you have processed them.`);
|
|
1305
|
+
if (state.lastRejection !== void 0) lines.push(`Your last submit_result was refused: ${state.lastRejection.reason}`);
|
|
1306
|
+
return lines;
|
|
1307
|
+
}
|
|
1308
|
+
function taskText(task) {
|
|
1309
|
+
if (typeof task === "string") return task;
|
|
1310
|
+
try {
|
|
1311
|
+
return JSON.stringify(task, null, 2) ?? String(task);
|
|
1312
|
+
} catch {
|
|
1313
|
+
return String(task);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
//#endregion
|
|
1229
1317
|
//#region src/runtime/supervise/root-stream.ts
|
|
1230
1318
|
/**
|
|
1231
1319
|
* The root manager's own provider stream, retained where Runtime owns it.
|
|
@@ -1685,6 +1773,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1685
1773
|
makeWorkerAgent: deps.makeWorkerAgent,
|
|
1686
1774
|
...deps.authorizeDownMessage ? { authorizeDownMessage: deps.authorizeDownMessage } : {},
|
|
1687
1775
|
perWorker: deps.perWorker,
|
|
1776
|
+
...deps.preserveOwnerTurns ? { preserveOwnerTurns: true } : {},
|
|
1688
1777
|
systemPrompt: resolveSupervisorSystemPrompt(stableProfile) ?? "",
|
|
1689
1778
|
...deps.deliverable ? { deliverable: deps.deliverable } : {},
|
|
1690
1779
|
...deps.onAcceptedSubmission ? { onAcceptedSubmission: deps.onAcceptedSubmission } : {},
|
|
@@ -1703,6 +1792,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1703
1792
|
...deps.preflightSpawn ? { preflightSpawn: deps.preflightSpawn } : {},
|
|
1704
1793
|
...deps.resolveSpawnProfile ? { resolveSpawnProfile: deps.resolveSpawnProfile } : {},
|
|
1705
1794
|
...deps.composeSpawnProfile ? { composeSpawnProfile: deps.composeSpawnProfile } : {},
|
|
1795
|
+
...deps.profiles ? { profiles: deps.profiles } : {},
|
|
1706
1796
|
...deps.spawnResourceRoot ? { spawnResourceRoot: deps.spawnResourceRoot } : {},
|
|
1707
1797
|
...deps.spawnResourceReader ? { spawnResourceReader: deps.spawnResourceReader } : {},
|
|
1708
1798
|
...deps.stopRule ? { stopRule: deps.stopRule } : {},
|
|
@@ -1803,6 +1893,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1803
1893
|
...deps.preflightSpawn ? { preflightSpawn: deps.preflightSpawn } : {},
|
|
1804
1894
|
...deps.resolveSpawnProfile ? { resolveSpawnProfile: deps.resolveSpawnProfile } : {},
|
|
1805
1895
|
...deps.composeSpawnProfile ? { composeSpawnProfile: deps.composeSpawnProfile } : {},
|
|
1896
|
+
...deps.profiles ? { profiles: deps.profiles } : {},
|
|
1806
1897
|
...deps.spawnResourceRoot ? { spawnResourceRoot: deps.spawnResourceRoot } : {},
|
|
1807
1898
|
...deps.spawnResourceReader ? { spawnResourceReader: deps.spawnResourceReader } : {},
|
|
1808
1899
|
...deps.peerMail ? { peerMail: deps.peerMail } : {},
|
|
@@ -1866,49 +1957,89 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1866
1957
|
contract: !contractDeclared ? "none" : submitted || candidate !== void 0 ? "met" : "unmet"
|
|
1867
1958
|
};
|
|
1868
1959
|
};
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1960
|
+
const loopRecords = [];
|
|
1961
|
+
let environmentReplacements = 0;
|
|
1962
|
+
const describe = deps.deliverable?.describe;
|
|
1963
|
+
const settleLoop = () => {
|
|
1964
|
+
const stopReason = controls.stopReason() ?? progressStopReason;
|
|
1965
|
+
const closedBy = mcp.submittedResult() ? "result-accepted" : controls.blocked() !== void 0 ? "blocked" : mcp.isStopped() ? "stop" : progressStopReason !== void 0 ? "stop-rule" : void 0;
|
|
1966
|
+
deps.onDriverLoopSettled?.({
|
|
1967
|
+
...summarizeDriverAttempts(loopRecords),
|
|
1968
|
+
environmentReplacements,
|
|
1969
|
+
...closedBy === void 0 ? {} : { closedBy },
|
|
1970
|
+
...stopReason === void 0 ? {} : { stopReason }
|
|
1971
|
+
});
|
|
1972
|
+
};
|
|
1973
|
+
try {
|
|
1974
|
+
await runDriverWithRetry({
|
|
1975
|
+
drive: async (attempt, reentry) => {
|
|
1976
|
+
candidate = void 0;
|
|
1977
|
+
if (deps.controlDir !== void 0 && deps.abortRun !== void 0) applyRunCancellation(deps.controlDir, deps.abortRun, () => (/* @__PURE__ */ new Date()).toISOString());
|
|
1978
|
+
scope.signal.throwIfAborted();
|
|
1979
|
+
beginScopeOwnerAttempt(scope, attempt);
|
|
1980
|
+
controls.beginDriverAttempt(attempt);
|
|
1981
|
+
const compose = reentry === void 0 ? void 0 : (continuity) => composeReentryTask({
|
|
1982
|
+
originalTask: task,
|
|
1983
|
+
...describe === void 0 ? {} : { contract: describe },
|
|
1984
|
+
reentry,
|
|
1985
|
+
continuity,
|
|
1986
|
+
state: controls.reentryState(),
|
|
1987
|
+
attempt
|
|
1887
1988
|
});
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1989
|
+
harnessInvocationActive = true;
|
|
1990
|
+
let completed = false;
|
|
1991
|
+
try {
|
|
1992
|
+
await driveHarness({
|
|
1993
|
+
profile: providerProfile,
|
|
1994
|
+
authoredProfile: stableProfile,
|
|
1995
|
+
...profilePrompt !== void 0 ? { systemPrompt: profilePrompt } : {},
|
|
1996
|
+
task: compose === void 0 ? task : compose(UNPROVEN_CONTINUITY),
|
|
1997
|
+
...compose === void 0 ? {} : { reentry: {
|
|
1998
|
+
compose,
|
|
1999
|
+
onContinuity: (continuity) => {
|
|
2000
|
+
if (continuity.environment === "replaced") environmentReplacements += 1;
|
|
2001
|
+
}
|
|
2002
|
+
} },
|
|
2003
|
+
scope,
|
|
2004
|
+
coordinationMcpUrl: mcp.url,
|
|
2005
|
+
coordinationMcpHeaders: mcp.headers,
|
|
2006
|
+
stopSignal: stopController.signal,
|
|
2007
|
+
coordinationTools
|
|
2008
|
+
});
|
|
2009
|
+
completed = true;
|
|
2010
|
+
} catch (error) {
|
|
2011
|
+
if (!mcp.submittedResult() && !mcp.isStopped()) throw error;
|
|
2012
|
+
completed = true;
|
|
2013
|
+
} finally {
|
|
2014
|
+
harnessInvocationActive = false;
|
|
2015
|
+
if (completed) await controls.endDriverAttempt("completed");
|
|
2016
|
+
else await controls.endDriverAttempt("failed").catch(() => void 0);
|
|
2017
|
+
}
|
|
2018
|
+
if (contractDeclared && !mcp.submittedResult()) {
|
|
2019
|
+
await mcp.drainResolved();
|
|
2020
|
+
candidate = await finalize();
|
|
2021
|
+
}
|
|
2022
|
+
},
|
|
2023
|
+
progress: readProgress,
|
|
2024
|
+
budget: () => scope.budget,
|
|
2025
|
+
signal: scope.signal,
|
|
2026
|
+
...deps.driverRetry ? { policy: deps.driverRetry } : {},
|
|
2027
|
+
...repromptEnabled ? { reprompt: {
|
|
2028
|
+
maxReprompts,
|
|
2029
|
+
...deps.deliverable?.describe === void 0 ? {} : { describe: deps.deliverable.describe },
|
|
2030
|
+
onUnmetContract: async (context) => {
|
|
2031
|
+
if (mcp.isStopped() || progressStopReason !== void 0) return "stop";
|
|
2032
|
+
return await deps.onUnmetContract?.(context) ?? { steer: defaultUnmetContractSteer(context) };
|
|
2033
|
+
}
|
|
2034
|
+
} } : {},
|
|
2035
|
+
onAttempt: async (record) => {
|
|
2036
|
+
loopRecords.push(record);
|
|
2037
|
+
await deps.onDriverAttempt?.(record);
|
|
1896
2038
|
}
|
|
1897
|
-
}
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
...deps.driverRetry ? { policy: deps.driverRetry } : {},
|
|
1902
|
-
...repromptEnabled ? { reprompt: {
|
|
1903
|
-
maxReprompts,
|
|
1904
|
-
...deps.deliverable?.describe === void 0 ? {} : { describe: deps.deliverable.describe },
|
|
1905
|
-
onUnmetContract: async (context) => {
|
|
1906
|
-
if (mcp.isStopped()) return "stop";
|
|
1907
|
-
return await deps.onUnmetContract?.(context) ?? { steer: defaultUnmetContractSteer(context) };
|
|
1908
|
-
}
|
|
1909
|
-
} } : {},
|
|
1910
|
-
...deps.onDriverAttempt ? { onAttempt: deps.onDriverAttempt } : {}
|
|
1911
|
-
});
|
|
2039
|
+
});
|
|
2040
|
+
} finally {
|
|
2041
|
+
settleLoop();
|
|
2042
|
+
}
|
|
1912
2043
|
if (!contractDeclared) await mcp.drainResolved();
|
|
1913
2044
|
const submitted = mcp.submittedResult();
|
|
1914
2045
|
if (submitted) {
|
|
@@ -2633,7 +2764,7 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
|
|
|
2633
2764
|
const baseFactory = createExecutor(boundBackend);
|
|
2634
2765
|
const ownerRuntime = boundBackend.backend === "provider" ? boundBackend.runtime ?? resolveAgentEnvironmentProvider(boundBackend.provider, boundBackend.registry).name : "cli";
|
|
2635
2766
|
let activeExecutor;
|
|
2636
|
-
const drive = async ({ profile, authoredProfile, task, scope, coordinationMcpUrl, coordinationMcpHeaders, stopSignal, coordinationTools }) => {
|
|
2767
|
+
const drive = async ({ profile, authoredProfile, task, scope, coordinationMcpUrl, coordinationMcpHeaders, stopSignal, coordinationTools, reentry }) => {
|
|
2637
2768
|
const retainedOwner = boundBackend.backend === "provider" ? scopeRetainedOwnerContext(scope) : void 0;
|
|
2638
2769
|
if (retainedOwner && boundBackend.backend === "provider") {
|
|
2639
2770
|
bindScopeRetainedOwnerProvider(scope, resolveAgentEnvironmentProvider(boundBackend.provider, boundBackend.registry));
|
|
@@ -2643,7 +2774,13 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
|
|
|
2643
2774
|
return execution?.kind === "environment" ? execution.id : void 0;
|
|
2644
2775
|
});
|
|
2645
2776
|
}
|
|
2646
|
-
|
|
2777
|
+
let driveTask = task;
|
|
2778
|
+
if (reentry !== void 0) {
|
|
2779
|
+
const continuity = await reentryContinuity(boundBackend, scope, retainedOwner !== void 0);
|
|
2780
|
+
reentry.onContinuity?.(continuity);
|
|
2781
|
+
driveTask = reentry.compose(continuity);
|
|
2782
|
+
}
|
|
2783
|
+
const originalTask = retainedOwner ? await prepareScopeRetainedOwnerTask(scope, driveTask) : driveTask;
|
|
2647
2784
|
const acceptedOwner = retainedOwner ? await scopeRetainedOwnerResult(scope) : void 0;
|
|
2648
2785
|
if (acceptedOwner) {
|
|
2649
2786
|
await restoreScopeOwnerAcceptedExecution(scope);
|
|
@@ -3005,6 +3142,41 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
|
|
|
3005
3142
|
drive.progress = () => activeExecutor?.progress?.();
|
|
3006
3143
|
return attestRuntimeOwnedScopeOwner(drive, ownerRuntime);
|
|
3007
3144
|
}
|
|
3145
|
+
/**
|
|
3146
|
+
* What the next drive of a harness-brained manager continues, as far as its backend proves it.
|
|
3147
|
+
*
|
|
3148
|
+
* A bridge reattaches the harness session by its durable execution id. A retained provider owner
|
|
3149
|
+
* continues in the environment it last used while the provider still holds it, and a deliberate
|
|
3150
|
+
* later invocation there continues the same harness session. A provider without retained control
|
|
3151
|
+
* creates a new environment for every drive and releases the old one. Anything else is unproven.
|
|
3152
|
+
*/
|
|
3153
|
+
async function reentryContinuity(backend, scope, retainedOwner) {
|
|
3154
|
+
if (backend.backend === "bridge") return {
|
|
3155
|
+
session: "continued",
|
|
3156
|
+
environment: "same",
|
|
3157
|
+
workspace: "kept"
|
|
3158
|
+
};
|
|
3159
|
+
if (backend.backend !== "provider" || !retainedOwner) return UNPROVEN_CONTINUITY;
|
|
3160
|
+
if ((await resolveAgentEnvironmentProvider(backend.provider, backend.registry).capabilities()).retainedControl === void 0) return {
|
|
3161
|
+
session: "new",
|
|
3162
|
+
environment: "replaced",
|
|
3163
|
+
workspace: "lost"
|
|
3164
|
+
};
|
|
3165
|
+
const environment = await reconcileScopeRetainedOwnerEnvironment(scope);
|
|
3166
|
+
if (environment.state === "live") return {
|
|
3167
|
+
session: "continued",
|
|
3168
|
+
environment: "same",
|
|
3169
|
+
environmentId: environment.environmentId,
|
|
3170
|
+
workspace: "kept"
|
|
3171
|
+
};
|
|
3172
|
+
if (environment.state === "lost") return {
|
|
3173
|
+
session: "new",
|
|
3174
|
+
environment: "replaced",
|
|
3175
|
+
previousEnvironmentId: environment.environmentId,
|
|
3176
|
+
workspace: "lost"
|
|
3177
|
+
};
|
|
3178
|
+
return UNPROVEN_CONTINUITY;
|
|
3179
|
+
}
|
|
3008
3180
|
function isAsyncIterable(value) {
|
|
3009
3181
|
return value !== null && typeof value === "object" && Symbol.asyncIterator in value && typeof value[Symbol.asyncIterator] === "function";
|
|
3010
3182
|
}
|
|
@@ -3020,6 +3192,51 @@ function resolveNamed(option, table, value, registry) {
|
|
|
3020
3192
|
if (entry === void 0) throw new ConfigError(`supervise: opts.${option} = ${JSON.stringify(value)} is not in opts.registry.${table} — the table resolved no entry under that name`);
|
|
3021
3193
|
return entry;
|
|
3022
3194
|
}
|
|
3195
|
+
/** Read the profiles table once, before anything is built or spent, and freeze what it returns.
|
|
3196
|
+
* Every entry must parse as an AgentProfile (the schema refuses a credential written as a public
|
|
3197
|
+
* value), be executable, use an allowed model, and carry its table name as `profile.name`.
|
|
3198
|
+
* `assertMountable` applies the spawn path's own mount checks, so an entry that can never be
|
|
3199
|
+
* mounted fails here instead of after a director spent a turn on it. A promoted entry's decision
|
|
3200
|
+
* must promote, and a treatment arm of its sealed play must name the entry's canonical digest;
|
|
3201
|
+
* the seal itself is verified by {@link verifyProfilePromotions}. An empty table is no table. */
|
|
3202
|
+
function snapshotProfileTable(table, allowedModels, assertMountable) {
|
|
3203
|
+
if (table === void 0) return void 0;
|
|
3204
|
+
if (typeof table.names !== "function" || typeof table.resolve !== "function") throw new ConfigError("supervise: opts.registry.profiles must implement resolve(name) and names(): a director can spawn only the names it is shown");
|
|
3205
|
+
const entries = /* @__PURE__ */ new Map();
|
|
3206
|
+
for (const name of table.names()) {
|
|
3207
|
+
const at = `opts.registry.profiles ${JSON.stringify(name)}`;
|
|
3208
|
+
if (typeof name !== "string" || name.trim().length === 0 || name !== name.trim()) throw new ConfigError(`supervise: ${at} is not a non-empty trimmed name`);
|
|
3209
|
+
if (entries.has(name)) throw new ConfigError(`supervise: ${at} is listed twice`);
|
|
3210
|
+
const entry = table.resolve(name);
|
|
3211
|
+
if (entry === void 0) throw new ConfigError(`supervise: ${at} is listed, but the table resolved no entry under it`);
|
|
3212
|
+
const parsed = agentProfileSchema.safeParse(entry.profile);
|
|
3213
|
+
if (!parsed.success) throw new ValidationError(`supervise: ${at} is not a valid AgentProfile: ${parsed.error.message}`);
|
|
3214
|
+
const profile = freezeDetached(parsed.data);
|
|
3215
|
+
if (profile.name !== name) throw new ValidationError(`supervise: ${at} holds profile.name ${JSON.stringify(profile.name)}; a table entry is spawned and continued by its name, so the two must be equal`);
|
|
3216
|
+
assertExecutableAgentProfile(profile, `supervise: ${at}`);
|
|
3217
|
+
assertProfileModelsAllowed(profile, allowedModels);
|
|
3218
|
+
assertMountable?.(profile, `supervise: ${at} would be refused at mount`);
|
|
3219
|
+
const promotion = entry.promotion;
|
|
3220
|
+
if (promotion !== void 0) {
|
|
3221
|
+
if (promotion.decision?.promote !== true) throw new ValidationError(`supervise: ${at} cites a PairedPromotionDecision that did not promote; list it without promotion to run it as exploratory`);
|
|
3222
|
+
const digest = canonicalAgentProfileDigest(profile);
|
|
3223
|
+
if (!(promotion.experiment?.spec?.arms ?? []).some((arm) => arm.role === "treatment" && arm.profileDigest === digest)) throw new ValidationError(`supervise: ${at} cites sealed play ${JSON.stringify(promotion.experiment?.spec?.id)}, but no treatment arm of it names this profile's digest ${digest}`);
|
|
3224
|
+
}
|
|
3225
|
+
entries.set(name, Object.freeze({
|
|
3226
|
+
profile,
|
|
3227
|
+
...promotion === void 0 ? {} : { promotion: freezeDetached(promotion) }
|
|
3228
|
+
}));
|
|
3229
|
+
}
|
|
3230
|
+
return entries.size === 0 ? void 0 : entries;
|
|
3231
|
+
}
|
|
3232
|
+
/** Verify the seal of every promoted profiles-table entry. Eval's seal check is asynchronous, so it
|
|
3233
|
+
* runs at the start of the run, before the first model call; a broken seal refuses the run. */
|
|
3234
|
+
async function verifyProfilePromotions(table) {
|
|
3235
|
+
const promoted = [...table ?? []].filter(([, entry]) => entry.promotion !== void 0);
|
|
3236
|
+
if (promoted.length === 0) return;
|
|
3237
|
+
const { verifySealedExperiment } = await import("@tangle-network/agent-eval/experiment");
|
|
3238
|
+
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`);
|
|
3239
|
+
}
|
|
3023
3240
|
const superviseOptionKeySet = /* @__PURE__ */ new Set([
|
|
3024
3241
|
"allowedModels",
|
|
3025
3242
|
"analysts",
|
|
@@ -3059,6 +3276,7 @@ const superviseOptionKeySet = /* @__PURE__ */ new Set([
|
|
|
3059
3276
|
"otel",
|
|
3060
3277
|
"peerMail",
|
|
3061
3278
|
"perWorker",
|
|
3279
|
+
"reservationPolicy",
|
|
3062
3280
|
"probes",
|
|
3063
3281
|
"profileGuidance",
|
|
3064
3282
|
"profileSecurity",
|
|
@@ -3438,13 +3656,22 @@ function profileGuidanceComposer(guidance) {
|
|
|
3438
3656
|
return composed.data;
|
|
3439
3657
|
};
|
|
3440
3658
|
}
|
|
3659
|
+
/**
|
|
3660
|
+
* The exact root profile `supervise` executes: `profile` parsed as an AgentProfile, with the
|
|
3661
|
+
* selected `profileGuidance` composed. The root's journaled `identity.profileDigest` is this
|
|
3662
|
+
* value's digest, so a reader that must match a recorded root derives it here, not by hand.
|
|
3663
|
+
*/
|
|
3664
|
+
function superviseRootProfile(profile, profileGuidance) {
|
|
3665
|
+
const parsedProfile = agentProfileSchema.safeParse(profile);
|
|
3666
|
+
if (!parsedProfile.success) throw new ValidationError(`supervise: invalid AgentProfile: ${parsedProfile.error.message}`);
|
|
3667
|
+
const compose = profileGuidanceComposer(profileGuidance);
|
|
3668
|
+
return freezeDetachedProfile(compose ? compose(parsedProfile.data) : parsedProfile.data);
|
|
3669
|
+
}
|
|
3441
3670
|
function superviseInternal(profile, task, opts, testBrain) {
|
|
3442
3671
|
const options = captureSuperviseOptions(opts);
|
|
3443
3672
|
assertValidBudget(options.budget, "supervise budget");
|
|
3444
|
-
const parsedProfile = agentProfileSchema.safeParse(profile);
|
|
3445
|
-
if (!parsedProfile.success) throw new ValidationError(`supervise: invalid AgentProfile: ${parsedProfile.error.message}`);
|
|
3446
3673
|
const composeSpawnProfile = profileGuidanceComposer(options.profileGuidance);
|
|
3447
|
-
const canonicalProfile =
|
|
3674
|
+
const canonicalProfile = superviseRootProfile(profile, options.profileGuidance);
|
|
3448
3675
|
assertExecutableAgentProfile(canonicalProfile, "supervise root");
|
|
3449
3676
|
const canonicalTask = freezeDetached(task);
|
|
3450
3677
|
if (options.makeWorkerAgent && options.authorizeSpawn) throw new ValidationError("supervise: authorizeSpawn cannot be combined with caller-owned makeWorkerAgent; use makeLeafAgent to override leaf execution inside the authorized path, or use backend-derived workers");
|
|
@@ -3472,12 +3699,18 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3472
3699
|
const finalizer = resolveNamed("finalizer", "finalizers", options.finalizer, options.registry?.finalizers);
|
|
3473
3700
|
const analysts = resolveNamed("analysts", "analysts", options.analysts, options.registry?.analysts);
|
|
3474
3701
|
const probes = resolveNamed("probes", "probes", options.probes, options.registry?.probes);
|
|
3702
|
+
const profileTable = snapshotProfileTable(options.registry?.profiles, options.allowedModels, options.makeWorkerAgent === void 0 && options.authorizeSpawn === void 0 ? (entry, context) => {
|
|
3703
|
+
const security = validateAgentProfileSecurity(entry, options.profileSecurity ?? DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY);
|
|
3704
|
+
if (!security.ok) throw new ValidationError(`${context}: ${security.issues.filter((issue) => issue.level === "error").map((issue) => `${issue.code}${issue.path ? ` at ${issue.path}` : ""}`).join(", ")}`);
|
|
3705
|
+
if (options.backend !== void 0 && options.makeLeafAgent === void 0 && declaredRuntimeToolNames(entry).length === 0) assertBackendProfileMaterialization(entry, options.backend, context);
|
|
3706
|
+
} : void 0);
|
|
3475
3707
|
assertCoordinationBinding(options.coordination);
|
|
3476
3708
|
const ctx = options.runDir !== void 0 ? createFileRunContext(options.runDir, { withDriver: true }) : createInMemoryRunContext({ withDriver: true });
|
|
3477
3709
|
const blobs = options.blobs ?? ctx.blobs;
|
|
3478
3710
|
const perWorker = options.perWorker ?? defaultPerWorker(options.budget);
|
|
3479
3711
|
assertValidBudget(perWorker, "supervise perWorker");
|
|
3480
3712
|
assertPerWorkerWithinPool(perWorker, options.budget);
|
|
3713
|
+
assertRecursiveReservationPolicy(options.reservationPolicy, options.maxDepth ?? 8, options.maxLiveWorkers);
|
|
3481
3714
|
const journal = options.journal ?? ctx.journal;
|
|
3482
3715
|
const runId = options.runId ?? "supervise";
|
|
3483
3716
|
const runNamespace = supervisionRunNamespace(options.runDir, runId);
|
|
@@ -3622,6 +3855,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3622
3855
|
makeWorkerAgent: childFactory,
|
|
3623
3856
|
...authorizeNestedMessage ? { authorizeDownMessage: authorizeNestedMessage } : {},
|
|
3624
3857
|
perWorker: nestedPerWorker,
|
|
3858
|
+
...options.reservationPolicy ? { preserveOwnerTurns: true } : {},
|
|
3625
3859
|
...options.router ? { router: options.router } : {},
|
|
3626
3860
|
...nestedDriveHarness ? { driveHarness: nestedDriveHarness } : {},
|
|
3627
3861
|
...options.coordination && isExternalSupervisor(authorized) ? { coordination: options.coordination } : {},
|
|
@@ -3648,6 +3882,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3648
3882
|
...spawnPreflight ? { preflightSpawn: spawnPreflight } : {},
|
|
3649
3883
|
...options.resolveSpawnProfile ? { resolveSpawnProfile: options.resolveSpawnProfile } : {},
|
|
3650
3884
|
...composeSpawnProfile ? { composeSpawnProfile } : {},
|
|
3885
|
+
...profileTable ? { profiles: profileTable } : {},
|
|
3651
3886
|
...options.peerMail ? { peerMail: options.peerMail } : {},
|
|
3652
3887
|
...options.stopRule ? { stopRule: options.stopRule } : {},
|
|
3653
3888
|
...options.onProgressStop ? { onProgressStop: options.onProgressStop } : {},
|
|
@@ -3708,7 +3943,9 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3708
3943
|
durableCancellation.abort(request === void 0 ? new Error(reason) : new RunCancellationReason(request.source, reason, request.operationId));
|
|
3709
3944
|
};
|
|
3710
3945
|
const workerFactory = makeWorkerAgent;
|
|
3946
|
+
let rootContinuation;
|
|
3711
3947
|
const start = async () => {
|
|
3948
|
+
await verifyProfilePromotions(profileTable);
|
|
3712
3949
|
const priorCoordination = log ? await log.load(runId, rootOwnerId) : void 0;
|
|
3713
3950
|
const authorizeRootMessage = authorizeDownFor(canonicalProfile, 1);
|
|
3714
3951
|
const agentDeps = {
|
|
@@ -3716,17 +3953,22 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3716
3953
|
makeWorkerAgent: workerFactory,
|
|
3717
3954
|
...authorizeRootMessage ? { authorizeDownMessage: authorizeRootMessage } : {},
|
|
3718
3955
|
perWorker,
|
|
3956
|
+
...options.reservationPolicy ? { preserveOwnerTurns: true } : {},
|
|
3719
3957
|
...log ? { onEvent: (_event, record) => log.append(runId, record, rootOwnerId) } : {},
|
|
3720
3958
|
...deliverable ? { deliverable } : {},
|
|
3721
3959
|
onProviderModel(model) {
|
|
3722
3960
|
rootProviderModels.push(model);
|
|
3723
3961
|
},
|
|
3962
|
+
onDriverLoopSettled(record) {
|
|
3963
|
+
rootContinuation = record;
|
|
3964
|
+
},
|
|
3724
3965
|
...priorCoordination && (priorCoordination.questions.length > 0 || priorCoordination.findings.length > 0 || priorCoordination.continuations.length > 0 || priorCoordination.deliveryEvidence.length > 0 || priorCoordination.records.some((record) => record.event.type === "submission")) ? { priorCoordination } : {},
|
|
3725
3966
|
...finalizer ? { finalizer } : {},
|
|
3726
3967
|
...options.coordination && isExternalSupervisor(canonicalProfile) ? { coordination: options.coordination } : {},
|
|
3727
3968
|
...spawnPreflight ? { preflightSpawn: spawnPreflight } : {},
|
|
3728
3969
|
...options.resolveSpawnProfile ? { resolveSpawnProfile: options.resolveSpawnProfile } : {},
|
|
3729
3970
|
...composeSpawnProfile ? { composeSpawnProfile } : {},
|
|
3971
|
+
...profileTable ? { profiles: profileTable } : {},
|
|
3730
3972
|
...spawnResourceRoot === void 0 ? {} : { spawnResourceRoot },
|
|
3731
3973
|
...options.peerMail ? { peerMail: options.peerMail } : {},
|
|
3732
3974
|
...options.maxLiveWorkers !== void 0 ? { maxLiveWorkers: options.maxLiveWorkers } : {},
|
|
@@ -3806,6 +4048,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3806
4048
|
...options.retainedAtSettlement !== void 0 ? { retainedAtSettlement: options.retainedAtSettlement } : {},
|
|
3807
4049
|
ownerWorkspaceRetention: managerBackend?.backend === "provider" && managerBackend.workspaceRetention !== void 0,
|
|
3808
4050
|
...options.maxLiveWorkers !== void 0 ? { maxLiveWorkers: options.maxLiveWorkers } : {},
|
|
4051
|
+
...options.reservationPolicy ? { reservationPolicy: options.reservationPolicy } : {},
|
|
3809
4052
|
...probes ? { probes } : {},
|
|
3810
4053
|
...ctx.resume === true ? { resume: true } : {},
|
|
3811
4054
|
...options.now ? { now: options.now } : {},
|
|
@@ -3833,7 +4076,8 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3833
4076
|
return {
|
|
3834
4077
|
...result,
|
|
3835
4078
|
rootProviderModel,
|
|
3836
|
-
...rootStream === void 0 ? {} : { rootStream }
|
|
4079
|
+
...rootStream === void 0 ? {} : { rootStream },
|
|
4080
|
+
...rootContinuation === void 0 ? {} : { continuation: rootContinuation }
|
|
3837
4081
|
};
|
|
3838
4082
|
};
|
|
3839
4083
|
if (!recorder) return settle();
|
|
@@ -3880,6 +4124,6 @@ function rootProviderModelEvidenceFromExecution(evidence) {
|
|
|
3880
4124
|
return evidence ?? rootProviderModelEvidence([]);
|
|
3881
4125
|
}
|
|
3882
4126
|
//#endregion
|
|
3883
|
-
export {
|
|
4127
|
+
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 };
|
|
3884
4128
|
|
|
3885
|
-
//# sourceMappingURL=supervise-
|
|
4129
|
+
//# sourceMappingURL=supervise-BeAI8-On.js.map
|