@tangle-network/agent-runtime 0.259.0 → 0.261.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.
Files changed (73) hide show
  1. package/dist/{activation-Cus2oZaT.d.ts → activation-BpJ2CmXx.d.ts} +2 -2
  2. package/dist/{activation-Btw2npV2.js → activation-BwrMmguq.js} +3 -3
  3. package/dist/{activation-Btw2npV2.js.map → activation-BwrMmguq.js.map} +1 -1
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/{bundle-DXrBPEFw.js → bundle-CvLGRVO-.js} +2 -2
  7. package/dist/{bundle-DXrBPEFw.js.map → bundle-CvLGRVO-.js.map} +1 -1
  8. package/dist/candidate-execution/index.js +5 -4
  9. package/dist/candidate-execution/index.js.map +1 -1
  10. package/dist/{coordination-driver-BmtrkNPu.js → coordination-driver-LmDxHvAO.js} +77 -11
  11. package/dist/coordination-driver-LmDxHvAO.js.map +1 -0
  12. package/dist/{delegate-DJgmZZKH.js → delegate-rkhJf5w7.js} +2 -2
  13. package/dist/{delegate-DJgmZZKH.js.map → delegate-rkhJf5w7.js.map} +1 -1
  14. package/dist/durable.d.ts +285 -57
  15. package/dist/durable.js +637 -108
  16. package/dist/durable.js.map +1 -1
  17. package/dist/{graph-BKRvWzHx.js → graph-Bn3wSH8-.js} +4 -3
  18. package/dist/graph-Bn3wSH8-.js.map +1 -0
  19. package/dist/{improvement-cycle-D0Os0Hg_.js → improvement-cycle-DYiwfjWY.js} +8 -7
  20. package/dist/improvement-cycle-DYiwfjWY.js.map +1 -0
  21. package/dist/{index-sGOO254Q.d.ts → index-tubViIQJ.d.ts} +122 -12
  22. package/dist/index.d.ts +6 -6
  23. package/dist/index.js +9 -9
  24. package/dist/intelligence.d.ts +3 -3
  25. package/dist/intelligence.js +7 -6
  26. package/dist/intelligence.js.map +1 -1
  27. package/dist/kernel.d.ts +4 -4
  28. package/dist/kernel.js +8 -8
  29. package/dist/{loop-runner-bin-DAU4rNIL.d.ts → loop-runner-bin-CL4W2pu1.d.ts} +3 -3
  30. package/dist/{loop-runner-bin-pRlDgm1i.js → loop-runner-bin-Dxqxf91b.js} +3 -3
  31. package/dist/{loop-runner-bin-pRlDgm1i.js.map → loop-runner-bin-Dxqxf91b.js.map} +1 -1
  32. package/dist/loop-runner-bin.d.ts +1 -1
  33. package/dist/loop-runner-bin.js +1 -1
  34. package/dist/mcp/bin.js +3 -3
  35. package/dist/mcp/index.d.ts +5 -5
  36. package/dist/mcp/index.js +4 -4
  37. package/dist/{openai-tools-BsqD1_Zr.d.ts → openai-tools-BlZHd0Nz.d.ts} +2 -2
  38. package/dist/{prepare-RuaAclli.js → prepare-oHUQdC5-.js} +22 -452
  39. package/dist/prepare-oHUQdC5-.js.map +1 -0
  40. package/dist/profile-D3eXNBQV.js +438 -0
  41. package/dist/profile-D3eXNBQV.js.map +1 -0
  42. package/dist/profiles.d.ts +2 -2
  43. package/dist/{protected-model-port-BFhSgMAy.js → protected-model-port-DqF0qDU6.js} +4 -3
  44. package/dist/{protected-model-port-BFhSgMAy.js.map → protected-model-port-DqF0qDU6.js.map} +1 -1
  45. package/dist/{provision-supervisor-B9tf4soF.js → provision-supervisor-By5oGk3t.js} +3 -3
  46. package/dist/{provision-supervisor-B9tf4soF.js.map → provision-supervisor-By5oGk3t.js.map} +1 -1
  47. package/dist/{runtime-DKiucqGX.js → runtime-BbQmK7qe.js} +218 -20
  48. package/dist/runtime-BbQmK7qe.js.map +1 -0
  49. package/dist/{server-DIsiQ6mu.js → server-CHlpLE22.js} +3 -3
  50. package/dist/{server-DIsiQ6mu.js.map → server-CHlpLE22.js.map} +1 -1
  51. package/dist/{stream-agent-turn-DRTFLphI.d.ts → stream-agent-turn-DTgxWXbR.d.ts} +2 -2
  52. package/dist/{structural-rollout-BIBxgW64.js → structural-rollout-Dby60zHe.js} +2 -2
  53. package/dist/{structural-rollout-BIBxgW64.js.map → structural-rollout-Dby60zHe.js.map} +1 -1
  54. package/dist/{substrate-BToFBpfh.d.ts → substrate-CxwdhZri.d.ts} +2 -2
  55. package/dist/{supervise-DsQjhLN-.js → supervise-1QzYAyS2.js} +78 -7
  56. package/dist/supervise-1QzYAyS2.js.map +1 -0
  57. package/dist/{supervisor-CJyzUjc7.js → supervisor-yavsoQQo.js} +84 -9
  58. package/dist/{supervisor-CJyzUjc7.js.map → supervisor-yavsoQQo.js.map} +1 -1
  59. package/dist/testing.d.ts +2 -2
  60. package/dist/testing.js +14 -14
  61. package/dist/tui/index.d.ts +1 -1
  62. package/dist/tui/index.js +1 -1
  63. package/dist/{types-ChewVlpE.d.ts → types-DNCNRu0E.d.ts} +24 -2
  64. package/dist/{workspace-archive-DQGFwvM6.js → workspace-archive-C9lgf77y.js} +11 -11
  65. package/dist/workspace-archive-C9lgf77y.js.map +1 -0
  66. package/package.json +5 -5
  67. package/dist/coordination-driver-BmtrkNPu.js.map +0 -1
  68. package/dist/graph-BKRvWzHx.js.map +0 -1
  69. package/dist/improvement-cycle-D0Os0Hg_.js.map +0 -1
  70. package/dist/prepare-RuaAclli.js.map +0 -1
  71. package/dist/runtime-DKiucqGX.js.map +0 -1
  72. package/dist/supervise-DsQjhLN-.js.map +0 -1
  73. package/dist/workspace-archive-DQGFwvM6.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Hr as AgentRunSpec, Wr as Driver, di as OutputAdapter, gi as Validator } from "./types-ChewVlpE.js";
1
+ import { Gr as Driver, Ur as AgentRunSpec, _i as Validator, fi as OutputAdapter } from "./types-DNCNRu0E.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-BToFBpfh.d.ts.map
284
+ //# sourceMappingURL=substrate-CxwdhZri.d.ts.map
@@ -1,10 +1,10 @@
1
- import { $i as resourceTelemetry, $r as readCommittedJsonLines, An as resolveAgentEnvironmentProvider, Br as profileMaterializationAxes$1, C as restoreScopeOwnerAcceptedExecution, F as prepareScopeRetainedOwnerTask, Fn as registerRetainedExecutorPreparation, Gi as sleep, Hr as promptModelProfileMaterialization, I as scopeRetainedOwnerContext, In as retainedExecutorSeamKey, Ir as assertProfileMaterialization, It as spendFromUsageTotals, Jr as unsupportedProfileDimensions, Kn as linkAbort, Kr as renderUnsupported, Kt as createInbox, L as scopeRetainedOwnerPriorSpend, Li as addSpend, Lr as controlProfileMaterialization, Lt as WORKER_TRACE_PROPAGATION, M as bindScopeRetainedOwnerEnvironmentId, N as bindScopeRetainedOwnerProvider, Nt as meterUsageEvent, P as consumeScopeRetainedOwnerResult, Pt as newUsageTotals, Qi as addResourceSpend, Qr as prepareJsonlAppend, R as scopeRetainedOwnerResourceReader, Rr as defineProfileMaterializationContract, S as recordScopeOwnerMaterialization, Si as detachedSnapshot, Sn as routerBrain, Vr as promptControlProfileMaterialization, Wn as RunCancellationReason, Xi as withTimeout, Xr as worktreeCliProfileMaterialization, Yi as unmeteredSpend, Zi as zeroSpend, Zr as isNoEntError, _ as beginScopeOwnerAttempt, _r as toOtelAttributes, ai as inheritRuntimeOwnedExecutorAttestation, an as bridgeModelRouteRefusal, at as bindReusableExecutorExecutionId, b as meterRuntimeOwnedAccounting, d as defaultUnmetContractSteer, di as runtimeOwnedDriveHarnessProviderEvidence, dn as bridgeStopSignalKey, dt as snapshotExecutorConfig, ea as withBudgetResources, er as contentAddress, et as errMessage, f as runDriverWithRetry, fi as runtimeOwnedExecutorExecutionBinding, gi as runtimeOwnedScopeOwnerRuntime, h as isDriverSpec, hi as runtimeOwnedPendingExecutorMaterialization, ia as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, in as bridgeAdmissionRefusal, jt as assertValidBudget, l as HarnessTurnFailedError, li as providerAttemptEvidence, lt as createExecutor, m as driverExecutorFactory, mi as runtimeOwnedExecutorProviderEvidence, n as createSupervisor, ni as attestRuntimeOwnedScopeOwner, o as runFinalizer, oa as teardownExecutor, ot as captureReusableExecutorConfig, p as driverChild, pi as runtimeOwnedExecutorMaterialization, pr as generateSpanId, qn as runAbortable, r as bestDelivered, rn as executorFailure, s as runTree, sa as teardownSurfaces, t as createRootHandle, ui as recordRuntimeOwnedDriveHarnessProviderEvidence, un as bridgeRuntimeAttachmentsKey, ur as createOtelExporter, w as scopeOwnerExecutorNodeContext, x as meterRuntimeOwnedProviderAttempt, y as deriveNodeExecutionIdentity, z as scopeRetainedOwnerResult, zr as fullProfileMaterialization } from "./supervisor-CJyzUjc7.js";
1
+ import { $i as zeroSpend, B as scopeRetainedOwnerResult, Br as fullProfileMaterialization, C as recordScopeOwnerMaterialization, Cn as routerBrain, F as consumeScopeRetainedOwnerResult, Ft as newUsageTotals, Gn as RunCancellationReason, Hr as promptControlProfileMaterialization, I as prepareScopeRetainedOwnerTask, In as registerRetainedExecutorPreparation, Jn as runAbortable, L as scopeRetainedOwnerContext, Ln as retainedExecutorSeamKey, Lr as assertProfileMaterialization, Lt as spendFromUsageTotals, Mt as assertValidBudget, N as bindScopeRetainedOwnerEnvironmentId, P as bindScopeRetainedOwnerProvider, Pt as meterUsageEvent, Qi as withTimeout, Qr as isNoEntError, R as scopeRetainedOwnerPriorSpend, Rr as controlProfileMaterialization, Rt as WORKER_TRACE_PROPAGATION, S as meterRuntimeOwnedProviderAttempt, T as scopeOwnerExecutorNodeContext, Ur as promptModelProfileMaterialization, Vr as profileMaterializationAxes$1, Yr as unsupportedProfileDimensions, Zi as unmeteredSpend, Zr as worktreeCliProfileMaterialization, _ as assertRecursiveReservationPolicy, _i as runtimeOwnedPendingExecutorMaterialization, an as bridgeAdmissionRefusal, b as deriveNodeExecutionIdentity, ca as teardownExecutor, d as defaultUnmetContractSteer, di as providerAttemptEvidence, dn as bridgeRuntimeAttachmentsKey, dr as createOtelExporter, ea as addResourceSpend, ei as prepareJsonlAppend, f as runDriverWithRetry, fi as recordRuntimeOwnedDriveHarnessProviderEvidence, fn as bridgeStopSignalKey, ft as snapshotExecutorConfig, gi as runtimeOwnedExecutorProviderEvidence, h as isDriverSpec, hi as runtimeOwnedExecutorMaterialization, ii as attestRuntimeOwnedScopeOwner, in as executorFailure, jn as resolveAgentEnvironmentProvider, l as HarnessTurnFailedError, la as teardownSurfaces, m as driverExecutorFactory, mi as runtimeOwnedExecutorExecutionBinding, mr as generateSpanId, n as createSupervisor, na as withBudgetResources, o as runFinalizer, oa as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, on as bridgeModelRouteRefusal, ot as bindReusableExecutorExecutionId, p as driverChild, pi as runtimeOwnedDriveHarnessProviderEvidence, qi as sleep, qn as linkAbort, qr as renderUnsupported, qt as createInbox, r as bestDelivered, s as runTree, si as inheritRuntimeOwnedExecutorAttestation, st as captureReusableExecutorConfig, t as createRootHandle, ta as resourceTelemetry, ti as readCommittedJsonLines, tr as contentAddress, tt as errMessage, ut as createExecutor, v as beginScopeOwnerAttempt, vi as runtimeOwnedScopeOwnerRuntime, vr as toOtelAttributes, w as restoreScopeOwnerAcceptedExecution, wi as detachedSnapshot, x as meterRuntimeOwnedAccounting, z as scopeRetainedOwnerResourceReader, zi as addSpend, zr as defineProfileMaterializationContract } from "./supervisor-yavsoQQo.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-BmtrkNPu.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-LmDxHvAO.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";
@@ -706,6 +706,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
706
706
  ...opts.preflightSpawn ? { preflightSpawn: opts.preflightSpawn } : {},
707
707
  ...opts.resolveSpawnProfile ? { resolveSpawnProfile: opts.resolveSpawnProfile } : {},
708
708
  ...opts.composeSpawnProfile ? { composeSpawnProfile: opts.composeSpawnProfile } : {},
709
+ ...opts.profiles ? { profiles: opts.profiles } : {},
709
710
  ...opts.spawnResourceRoot ? { spawnResourceRoot: opts.spawnResourceRoot } : {},
710
711
  ...ownerReader ? { spawnResourceReader: ownerReader } : {},
711
712
  ...opts.peerMail ? { peerMail: typeof opts.peerMail === "object" && opts.peerMail.limits ? { limits: opts.peerMail.limits } : {} } : {}
@@ -1685,6 +1686,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1685
1686
  makeWorkerAgent: deps.makeWorkerAgent,
1686
1687
  ...deps.authorizeDownMessage ? { authorizeDownMessage: deps.authorizeDownMessage } : {},
1687
1688
  perWorker: deps.perWorker,
1689
+ ...deps.preserveOwnerTurns ? { preserveOwnerTurns: true } : {},
1688
1690
  systemPrompt: resolveSupervisorSystemPrompt(stableProfile) ?? "",
1689
1691
  ...deps.deliverable ? { deliverable: deps.deliverable } : {},
1690
1692
  ...deps.onAcceptedSubmission ? { onAcceptedSubmission: deps.onAcceptedSubmission } : {},
@@ -1703,6 +1705,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1703
1705
  ...deps.preflightSpawn ? { preflightSpawn: deps.preflightSpawn } : {},
1704
1706
  ...deps.resolveSpawnProfile ? { resolveSpawnProfile: deps.resolveSpawnProfile } : {},
1705
1707
  ...deps.composeSpawnProfile ? { composeSpawnProfile: deps.composeSpawnProfile } : {},
1708
+ ...deps.profiles ? { profiles: deps.profiles } : {},
1706
1709
  ...deps.spawnResourceRoot ? { spawnResourceRoot: deps.spawnResourceRoot } : {},
1707
1710
  ...deps.spawnResourceReader ? { spawnResourceReader: deps.spawnResourceReader } : {},
1708
1711
  ...deps.stopRule ? { stopRule: deps.stopRule } : {},
@@ -1803,6 +1806,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1803
1806
  ...deps.preflightSpawn ? { preflightSpawn: deps.preflightSpawn } : {},
1804
1807
  ...deps.resolveSpawnProfile ? { resolveSpawnProfile: deps.resolveSpawnProfile } : {},
1805
1808
  ...deps.composeSpawnProfile ? { composeSpawnProfile: deps.composeSpawnProfile } : {},
1809
+ ...deps.profiles ? { profiles: deps.profiles } : {},
1806
1810
  ...deps.spawnResourceRoot ? { spawnResourceRoot: deps.spawnResourceRoot } : {},
1807
1811
  ...deps.spawnResourceReader ? { spawnResourceReader: deps.spawnResourceReader } : {},
1808
1812
  ...deps.peerMail ? { peerMail: deps.peerMail } : {},
@@ -3020,6 +3024,51 @@ function resolveNamed(option, table, value, registry) {
3020
3024
  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
3025
  return entry;
3022
3026
  }
3027
+ /** Read the profiles table once, before anything is built or spent, and freeze what it returns.
3028
+ * Every entry must parse as an AgentProfile (the schema refuses a credential written as a public
3029
+ * value), be executable, use an allowed model, and carry its table name as `profile.name`.
3030
+ * `assertMountable` applies the spawn path's own mount checks, so an entry that can never be
3031
+ * mounted fails here instead of after a director spent a turn on it. A promoted entry's decision
3032
+ * must promote, and a treatment arm of its sealed play must name the entry's canonical digest;
3033
+ * the seal itself is verified by {@link verifyProfilePromotions}. An empty table is no table. */
3034
+ function snapshotProfileTable(table, allowedModels, assertMountable) {
3035
+ if (table === void 0) return void 0;
3036
+ 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");
3037
+ const entries = /* @__PURE__ */ new Map();
3038
+ for (const name of table.names()) {
3039
+ const at = `opts.registry.profiles ${JSON.stringify(name)}`;
3040
+ if (typeof name !== "string" || name.trim().length === 0 || name !== name.trim()) throw new ConfigError(`supervise: ${at} is not a non-empty trimmed name`);
3041
+ if (entries.has(name)) throw new ConfigError(`supervise: ${at} is listed twice`);
3042
+ const entry = table.resolve(name);
3043
+ if (entry === void 0) throw new ConfigError(`supervise: ${at} is listed, but the table resolved no entry under it`);
3044
+ const parsed = agentProfileSchema.safeParse(entry.profile);
3045
+ if (!parsed.success) throw new ValidationError(`supervise: ${at} is not a valid AgentProfile: ${parsed.error.message}`);
3046
+ const profile = freezeDetached(parsed.data);
3047
+ 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`);
3048
+ assertExecutableAgentProfile(profile, `supervise: ${at}`);
3049
+ assertProfileModelsAllowed(profile, allowedModels);
3050
+ assertMountable?.(profile, `supervise: ${at} would be refused at mount`);
3051
+ const promotion = entry.promotion;
3052
+ if (promotion !== void 0) {
3053
+ 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`);
3054
+ const digest = canonicalAgentProfileDigest(profile);
3055
+ 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}`);
3056
+ }
3057
+ entries.set(name, Object.freeze({
3058
+ profile,
3059
+ ...promotion === void 0 ? {} : { promotion: freezeDetached(promotion) }
3060
+ }));
3061
+ }
3062
+ return entries.size === 0 ? void 0 : entries;
3063
+ }
3064
+ /** Verify the seal of every promoted profiles-table entry. Eval's seal check is asynchronous, so it
3065
+ * runs at the start of the run, before the first model call; a broken seal refuses the run. */
3066
+ async function verifyProfilePromotions(table) {
3067
+ const promoted = [...table ?? []].filter(([, entry]) => entry.promotion !== void 0);
3068
+ if (promoted.length === 0) return;
3069
+ const { verifySealedExperiment } = await import("@tangle-network/agent-eval/experiment");
3070
+ 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`);
3071
+ }
3023
3072
  const superviseOptionKeySet = /* @__PURE__ */ new Set([
3024
3073
  "allowedModels",
3025
3074
  "analysts",
@@ -3059,6 +3108,7 @@ const superviseOptionKeySet = /* @__PURE__ */ new Set([
3059
3108
  "otel",
3060
3109
  "peerMail",
3061
3110
  "perWorker",
3111
+ "reservationPolicy",
3062
3112
  "probes",
3063
3113
  "profileGuidance",
3064
3114
  "profileSecurity",
@@ -3438,13 +3488,22 @@ function profileGuidanceComposer(guidance) {
3438
3488
  return composed.data;
3439
3489
  };
3440
3490
  }
3491
+ /**
3492
+ * The exact root profile `supervise` executes: `profile` parsed as an AgentProfile, with the
3493
+ * selected `profileGuidance` composed. The root's journaled `identity.profileDigest` is this
3494
+ * value's digest, so a reader that must match a recorded root derives it here, not by hand.
3495
+ */
3496
+ function superviseRootProfile(profile, profileGuidance) {
3497
+ const parsedProfile = agentProfileSchema.safeParse(profile);
3498
+ if (!parsedProfile.success) throw new ValidationError(`supervise: invalid AgentProfile: ${parsedProfile.error.message}`);
3499
+ const compose = profileGuidanceComposer(profileGuidance);
3500
+ return freezeDetachedProfile(compose ? compose(parsedProfile.data) : parsedProfile.data);
3501
+ }
3441
3502
  function superviseInternal(profile, task, opts, testBrain) {
3442
3503
  const options = captureSuperviseOptions(opts);
3443
3504
  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
3505
  const composeSpawnProfile = profileGuidanceComposer(options.profileGuidance);
3447
- const canonicalProfile = freezeDetachedProfile(composeSpawnProfile ? composeSpawnProfile(parsedProfile.data) : parsedProfile.data);
3506
+ const canonicalProfile = superviseRootProfile(profile, options.profileGuidance);
3448
3507
  assertExecutableAgentProfile(canonicalProfile, "supervise root");
3449
3508
  const canonicalTask = freezeDetached(task);
3450
3509
  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 +3531,18 @@ function superviseInternal(profile, task, opts, testBrain) {
3472
3531
  const finalizer = resolveNamed("finalizer", "finalizers", options.finalizer, options.registry?.finalizers);
3473
3532
  const analysts = resolveNamed("analysts", "analysts", options.analysts, options.registry?.analysts);
3474
3533
  const probes = resolveNamed("probes", "probes", options.probes, options.registry?.probes);
3534
+ const profileTable = snapshotProfileTable(options.registry?.profiles, options.allowedModels, options.makeWorkerAgent === void 0 && options.authorizeSpawn === void 0 ? (entry, context) => {
3535
+ const security = validateAgentProfileSecurity(entry, options.profileSecurity ?? DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY);
3536
+ if (!security.ok) throw new ValidationError(`${context}: ${security.issues.filter((issue) => issue.level === "error").map((issue) => `${issue.code}${issue.path ? ` at ${issue.path}` : ""}`).join(", ")}`);
3537
+ if (options.backend !== void 0 && options.makeLeafAgent === void 0 && declaredRuntimeToolNames(entry).length === 0) assertBackendProfileMaterialization(entry, options.backend, context);
3538
+ } : void 0);
3475
3539
  assertCoordinationBinding(options.coordination);
3476
3540
  const ctx = options.runDir !== void 0 ? createFileRunContext(options.runDir, { withDriver: true }) : createInMemoryRunContext({ withDriver: true });
3477
3541
  const blobs = options.blobs ?? ctx.blobs;
3478
3542
  const perWorker = options.perWorker ?? defaultPerWorker(options.budget);
3479
3543
  assertValidBudget(perWorker, "supervise perWorker");
3480
3544
  assertPerWorkerWithinPool(perWorker, options.budget);
3545
+ assertRecursiveReservationPolicy(options.reservationPolicy, options.maxDepth ?? 8, options.maxLiveWorkers);
3481
3546
  const journal = options.journal ?? ctx.journal;
3482
3547
  const runId = options.runId ?? "supervise";
3483
3548
  const runNamespace = supervisionRunNamespace(options.runDir, runId);
@@ -3622,6 +3687,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3622
3687
  makeWorkerAgent: childFactory,
3623
3688
  ...authorizeNestedMessage ? { authorizeDownMessage: authorizeNestedMessage } : {},
3624
3689
  perWorker: nestedPerWorker,
3690
+ ...options.reservationPolicy ? { preserveOwnerTurns: true } : {},
3625
3691
  ...options.router ? { router: options.router } : {},
3626
3692
  ...nestedDriveHarness ? { driveHarness: nestedDriveHarness } : {},
3627
3693
  ...options.coordination && isExternalSupervisor(authorized) ? { coordination: options.coordination } : {},
@@ -3648,6 +3714,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3648
3714
  ...spawnPreflight ? { preflightSpawn: spawnPreflight } : {},
3649
3715
  ...options.resolveSpawnProfile ? { resolveSpawnProfile: options.resolveSpawnProfile } : {},
3650
3716
  ...composeSpawnProfile ? { composeSpawnProfile } : {},
3717
+ ...profileTable ? { profiles: profileTable } : {},
3651
3718
  ...options.peerMail ? { peerMail: options.peerMail } : {},
3652
3719
  ...options.stopRule ? { stopRule: options.stopRule } : {},
3653
3720
  ...options.onProgressStop ? { onProgressStop: options.onProgressStop } : {},
@@ -3709,6 +3776,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3709
3776
  };
3710
3777
  const workerFactory = makeWorkerAgent;
3711
3778
  const start = async () => {
3779
+ await verifyProfilePromotions(profileTable);
3712
3780
  const priorCoordination = log ? await log.load(runId, rootOwnerId) : void 0;
3713
3781
  const authorizeRootMessage = authorizeDownFor(canonicalProfile, 1);
3714
3782
  const agentDeps = {
@@ -3716,6 +3784,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3716
3784
  makeWorkerAgent: workerFactory,
3717
3785
  ...authorizeRootMessage ? { authorizeDownMessage: authorizeRootMessage } : {},
3718
3786
  perWorker,
3787
+ ...options.reservationPolicy ? { preserveOwnerTurns: true } : {},
3719
3788
  ...log ? { onEvent: (_event, record) => log.append(runId, record, rootOwnerId) } : {},
3720
3789
  ...deliverable ? { deliverable } : {},
3721
3790
  onProviderModel(model) {
@@ -3727,6 +3796,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3727
3796
  ...spawnPreflight ? { preflightSpawn: spawnPreflight } : {},
3728
3797
  ...options.resolveSpawnProfile ? { resolveSpawnProfile: options.resolveSpawnProfile } : {},
3729
3798
  ...composeSpawnProfile ? { composeSpawnProfile } : {},
3799
+ ...profileTable ? { profiles: profileTable } : {},
3730
3800
  ...spawnResourceRoot === void 0 ? {} : { spawnResourceRoot },
3731
3801
  ...options.peerMail ? { peerMail: options.peerMail } : {},
3732
3802
  ...options.maxLiveWorkers !== void 0 ? { maxLiveWorkers: options.maxLiveWorkers } : {},
@@ -3806,6 +3876,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3806
3876
  ...options.retainedAtSettlement !== void 0 ? { retainedAtSettlement: options.retainedAtSettlement } : {},
3807
3877
  ownerWorkspaceRetention: managerBackend?.backend === "provider" && managerBackend.workspaceRetention !== void 0,
3808
3878
  ...options.maxLiveWorkers !== void 0 ? { maxLiveWorkers: options.maxLiveWorkers } : {},
3879
+ ...options.reservationPolicy ? { reservationPolicy: options.reservationPolicy } : {},
3809
3880
  ...probes ? { probes } : {},
3810
3881
  ...ctx.resume === true ? { resume: true } : {},
3811
3882
  ...options.now ? { now: options.now } : {},
@@ -3880,6 +3951,6 @@ function rootProviderModelEvidenceFromExecution(evidence) {
3880
3951
  return evidence ?? rootProviderModelEvidence([]);
3881
3952
  }
3882
3953
  //#endregion
3883
- export { readRootStreamReceipt as _, workerFromBackend as a, gateOnDeliverable as b, retryPreSpawnRefusals as c, coordinationProfileToolPrefix as d, resolveSupervisorProfile as f, readRootStream as g, ROOT_STREAM_FILE as h, superviseWithTestBrain as i, withWorkerSpawnRetry as l, supervisorAgentWithTestBrain as m, profileGuidanceComposer as n, isPreSpawnExecutorFailure as o, supervisorAgent as p, supervise as r, resolveWorkerSpawnRetry as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, assertCoordinationBinding as u, createSupervisorSpanRecorder as v, mapExecutorResult as x, serveCoordinationMcp as y };
3954
+ export { mapExecutorResult as S, readRootStream as _, superviseWithTestBrain as a, serveCoordinationMcp 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, gateOnDeliverable as x, createSupervisorSpanRecorder as y };
3884
3955
 
3885
- //# sourceMappingURL=supervise-DsQjhLN-.js.map
3956
+ //# sourceMappingURL=supervise-1QzYAyS2.js.map