@tangle-network/agent-runtime 0.263.0 → 0.266.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 (58) hide show
  1. package/dist/{activation-D_sIIewf.js → activation-BERiJjx5.js} +2 -2
  2. package/dist/{activation-D_sIIewf.js.map → activation-BERiJjx5.js.map} +1 -1
  3. package/dist/{activation-DJlWM1JN.d.ts → activation-VpxSbDKJ.d.ts} +2 -2
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/{coordination-driver-L9zH0kBx.js → coordination-driver-DdZ-nh_4.js} +73 -39
  7. package/dist/coordination-driver-DdZ-nh_4.js.map +1 -0
  8. package/dist/{delegate-Cv-w2WgY.js → delegate-Ajx_PVyu.js} +3 -3
  9. package/dist/delegate-Ajx_PVyu.js.map +1 -0
  10. package/dist/durable.d.ts +2 -2
  11. package/dist/durable.js +2 -2
  12. package/dist/{graph-Cusg4eAx.js → graph-CK50N9vG.js} +7 -5
  13. package/dist/graph-CK50N9vG.js.map +1 -0
  14. package/dist/{improvement-cycle-_IPwoII2.js → improvement-cycle-GRPoHLm1.js} +3 -3
  15. package/dist/{improvement-cycle-_IPwoII2.js.map → improvement-cycle-GRPoHLm1.js.map} +1 -1
  16. package/dist/{index-DLYBQFyl.d.ts → index-CU2mlMfc.d.ts} +61 -73
  17. package/dist/index.d.ts +6 -6
  18. package/dist/index.js +7 -7
  19. package/dist/intelligence.d.ts +3 -3
  20. package/dist/intelligence.js +3 -3
  21. package/dist/kernel.d.ts +4 -4
  22. package/dist/kernel.js +9 -9
  23. package/dist/{loop-runner-bin-BL8--Dzr.d.ts → loop-runner-bin-XKZXM08Q.d.ts} +3 -3
  24. package/dist/{loop-runner-bin-NWPIxiix.js → loop-runner-bin-cC16EPUq.js} +3 -3
  25. package/dist/{loop-runner-bin-NWPIxiix.js.map → loop-runner-bin-cC16EPUq.js.map} +1 -1
  26. package/dist/loop-runner-bin.d.ts +1 -1
  27. package/dist/loop-runner-bin.js +1 -1
  28. package/dist/mcp/bin.js +3 -3
  29. package/dist/mcp/index.d.ts +5 -5
  30. package/dist/mcp/index.js +4 -4
  31. package/dist/{openai-tools-B9x50W9Y.d.ts → openai-tools-D3ajI_D2.d.ts} +2 -2
  32. package/dist/profiles.d.ts +2 -2
  33. package/dist/{provision-supervisor-CIKvsWDa.js → provision-supervisor-Bf_bPaCv.js} +4 -4
  34. package/dist/{provision-supervisor-CIKvsWDa.js.map → provision-supervisor-Bf_bPaCv.js.map} +1 -1
  35. package/dist/{runtime-4NuCVO6X.js → runtime-hOLlAc1i.js} +938 -18
  36. package/dist/runtime-hOLlAc1i.js.map +1 -0
  37. package/dist/{server-BnYImvnx.js → server-DOb67ohd.js} +3 -3
  38. package/dist/{server-BnYImvnx.js.map → server-DOb67ohd.js.map} +1 -1
  39. package/dist/{stream-agent-turn-Y5rUc6Q-.d.ts → stream-agent-turn-Gw9hLpBn.d.ts} +182 -3
  40. package/dist/{structural-rollout-Bq3PNAun.js → structural-rollout-DV9YoQF6.js} +2 -2
  41. package/dist/{structural-rollout-Bq3PNAun.js.map → structural-rollout-DV9YoQF6.js.map} +1 -1
  42. package/dist/{substrate-Ce302oia.d.ts → substrate-CLt9S9ym.d.ts} +2 -2
  43. package/dist/{supervise-RF3_8PuR.js → supervise--njTtSL3.js} +82 -27
  44. package/dist/supervise--njTtSL3.js.map +1 -0
  45. package/dist/{supervisor-BeW08Ncp.js → supervisor-B8UMAXya.js} +995 -402
  46. package/dist/supervisor-B8UMAXya.js.map +1 -0
  47. package/dist/testing.d.ts +2 -2
  48. package/dist/testing.js +12 -12
  49. package/dist/tui/index.d.ts +1 -1
  50. package/dist/tui/index.js +1 -1
  51. package/dist/{types-C-nszovv.d.ts → types-CrnwLVYQ.d.ts} +217 -38
  52. package/package.json +2 -2
  53. package/dist/coordination-driver-L9zH0kBx.js.map +0 -1
  54. package/dist/delegate-Cv-w2WgY.js.map +0 -1
  55. package/dist/graph-Cusg4eAx.js.map +0 -1
  56. package/dist/runtime-4NuCVO6X.js.map +0 -1
  57. package/dist/supervise-RF3_8PuR.js.map +0 -1
  58. package/dist/supervisor-BeW08Ncp.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Ci as AgentRunSpec, Ki as OutputAdapter, Ti as Driver, Zi as Validator } from "./types-C-nszovv.js";
1
+ import { Fi as Driver, Ni as AgentRunSpec, na as OutputAdapter, sa as Validator } from "./types-CrnwLVYQ.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-Ce302oia.d.ts.map
284
+ //# sourceMappingURL=substrate-CLt9S9ym.d.ts.map
@@ -1,10 +1,10 @@
1
- import { $n as runAbortable, B as prepareScopeRetainedOwnerTask, Bt as newUsageTotals, C as deriveNodeExecutionIdentity, Ci as runtimeOwnedScopeOwnerRuntime, Cr as toOtelAttributes, D as recordScopeOwnerPause, E as recordScopeOwnerMaterialization, G as scopeRetainedOwnerResult, Gr as fullProfileMaterialization, H as scopeRetainedOwnerContext, Hn as retainedExecutorSeamKey, Hr as assertProfileMaterialization, Ht as spendFromUsageTotals, In as resolveAgentEnvironmentProvider, Jr as promptModelProfileMaterialization, Kr as profileMaterializationAxes$1, L as bindScopeRetainedOwnerEnvironmentId, Lt as assertValidBudget, O as restoreScopeOwnerAcceptedExecution, On as routerBrain, Qi as sleep, Qn as linkAbort, Qr as renderUnsupported, Qt as createInbox, R as bindScopeRetainedOwnerProvider, Si as runtimeOwnedPendingExecutorMaterialization, T as meterRuntimeOwnedProviderAttempt, U as scopeRetainedOwnerPriorSpend, Ur as controlProfileMaterialization, Ut as WORKER_TRACE_PROPAGATION, V as reconcileScopeRetainedOwnerEnvironment, Vn as registerRetainedExecutorPreparation, W as scopeRetainedOwnerResourceReader, Wi as addSpend, Wr as defineProfileMaterializationContract, Xn as RunCancellationReason, _ as driverExecutorFactory, _i as recordRuntimeOwnedDriveHarnessProviderEvidence, _n as bridgeStopSignalKey, _t as snapshotExecutorConfig, aa as addResourceSpend, ai as prepareJsonlAppend, b as assertRecursiveReservationPolicy, bi as runtimeOwnedExecutorMaterialization, da as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, dn as bridgeModelRouteRefusal, dt as bindReusableExecutorExecutionId, ei as unsupportedProfileDimensions, f as defaultUnmetContractSteer, fi as inheritRuntimeOwnedExecutorAttestation, ft as captureReusableExecutorConfig, g as driverChild, gi as providerAttemptEvidence, gn as bridgeRuntimeAttachmentsKey, gr as createOtelExporter, ht as createExecutor, ia as zeroSpend, k as scopeOwnerExecutorNodeContext, ki as detachedSnapshot, li as attestRuntimeOwnedScopeOwner, ln as executorFailure, m as summarizeDriverAttempts, ma as teardownSurfaces, n as createSupervisor, na as unmeteredSpend, ni as worktreeCliProfileMaterialization, o as runFinalizer, oa as resourceTelemetry, oi as readCommittedJsonLines, or as contentAddress, ot as errMessage, p as runDriverWithRetry, pa as teardownExecutor, qr as promptControlProfileMaterialization, r as bestDelivered, ra as withTimeout, ri as isNoEntError, s as runTree, sa as withBudgetResources, t as createRootHandle, u as HarnessTurnFailedError, un as bridgeAdmissionRefusal, v as isDriverSpec, vi as runtimeOwnedDriveHarnessProviderEvidence, w as meterRuntimeOwnedAccounting, x as beginScopeOwnerAttempt, xi as runtimeOwnedExecutorProviderEvidence, yi as runtimeOwnedExecutorExecutionBinding, yr as generateSpanId, z as consumeScopeRetainedOwnerResult, zt as meterUsageEvent } from "./supervisor-BeW08Ncp.js";
1
+ import { $r as profileMaterializationAxes$1, A as restoreScopeOwnerAcceptedExecution, Ai as runtimeOwnedScopeOwnerRuntime, An as routerBrain, B as bindScopeRetainedOwnerEnvironmentId, C as beginScopeOwnerAttempt, Ci as providerAttemptEvidence, D as meterRuntimeOwnedProviderAttempt, Di as runtimeOwnedExecutorMaterialization, E as meterRuntimeOwnedAccounting, Ei as runtimeOwnedExecutorExecutionBinding, G as scopeRetainedOwnerContext, Gt as WORKER_TRACE_PROPAGATION, H as consumeScopeRetainedOwnerResult, Ht as newUsageTotals, Ii as detachedSnapshot, J as scopeRetainedOwnerResult, Jn as errMessage, K as scopeRetainedOwnerPriorSpend, Kn as registerRetainedExecutorPreparation, O as recordScopeOwnerMaterialization, Oi as runtimeOwnedExecutorProviderEvidence, Qr as fullProfileMaterialization, S as assertRecursiveReservationPolicy, Sr as createOtelExporter, T as deriveNodeExecutionIdentity, Ti as runtimeOwnedDriveHarnessProviderEvidence, Tr as generateSpanId, U as prepareScopeRetainedOwnerTask, V as bindScopeRetainedOwnerProvider, Vt as meterUsageEvent, W as reconcileScopeRetainedOwnerEnvironment, Wt as spendFromUsageTotals, Xr as controlProfileMaterialization, Yr as assertProfileMaterialization, Zi as addSpend, Zr as defineProfileMaterializationContract, _ as driverChild, aa as sleep, ai as renderUnsupported, ar as runAbortable, ba as teardownExecutor, c as runTree, d as HarnessTurnFailedError, da as zeroSpend, dn as executorFailure, ei as promptControlProfileMaterialization, en as createInbox, fa as addResourceSpend, fi as prepareJsonlAppend, fn as bridgeAdmissionRefusal, fr as contentAddress, ft as bindReusableExecutorExecutionId, gi as attestRuntimeOwnedScopeOwner, gt as createExecutor, h as summarizeDriverAttempts, i as bestDelivered, ir as linkAbort, j as scopeOwnerExecutorNodeContext, k as recordScopeOwnerPause, ki as runtimeOwnedPendingExecutorMaterialization, kr as toOtelAttributes, la as unmeteredSpend, li as worktreeCliProfileMaterialization, m as runDriverWithRetry, ma as withBudgetResources, n as createRootHandle, nr as RunCancellationReason, p as defaultUnmetContractSteer, pa as resourceTelemetry, pi as readCommittedJsonLines, pn as bridgeModelRouteRefusal, pt as captureReusableExecutorConfig, q as scopeRetainedOwnerResourceReader, qn as retainedExecutorSeamKey, r as createSupervisor, s as runFinalizer, si as unsupportedProfileDimensions, ti as promptModelProfileMaterialization, ua as withTimeout, ui as isNoEntError, v as driverExecutorFactory, va as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, vn as bridgeRuntimeAttachmentsKey, vt as snapshotExecutorConfig, wi as recordRuntimeOwnedDriveHarnessProviderEvidence, xa as teardownSurfaces, y as isDriverSpec, yi as inheritRuntimeOwnedExecutorAttestation, yn as bridgeStopSignalKey, zn as resolveAgentEnvironmentProvider, zt as assertValidBudget } from "./supervisor-B8UMAXya.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 { 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-DdZ-nh_4.js";
6
7
  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-L9zH0kBx.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";
@@ -690,7 +690,6 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
690
690
  perWorker: opts.perWorker,
691
691
  ...opts.deliverable ? { deliverable: opts.deliverable } : {},
692
692
  ...opts.onStop ? { onStop: opts.onStop } : {},
693
- ...opts.maxLiveWorkers !== void 0 ? { maxLiveWorkers: opts.maxLiveWorkers } : {},
694
693
  awaitTimeoutMs: opts.awaitTimeoutMs ?? responseFenceMs,
695
694
  ...opts.analysts ? { analysts: opts.analysts } : {},
696
695
  ...opts.analyzeOnSettle ? { analyzeOnSettle: opts.analyzeOnSettle } : {},
@@ -1572,7 +1571,7 @@ function observeWorkerControls(options) {
1572
1571
  const coordinationMcpAlias = "agent-runtime-coordination";
1573
1572
  /** A profile declares Runtime-owned tools with this provider-neutral prefix. */
1574
1573
  const coordinationProfileToolPrefix = `${coordinationMcpAlias.replaceAll("-", "_")}_`;
1575
- const coordinationVerbNameSet = new Set(coordinationVerbNames);
1574
+ const coordinationVerbNameSet$1 = new Set(coordinationVerbNames);
1576
1575
  /** Bare Runtime tool names explicitly enabled by one exact profile. */
1577
1576
  function declaredRuntimeToolNames(profile) {
1578
1577
  const names = Object.entries(profile.tools ?? {}).filter(([name, enabled]) => enabled === true && name.startsWith(coordinationProfileToolPrefix)).map(([name]) => name.slice(coordinationProfileToolPrefix.length));
@@ -1581,7 +1580,7 @@ function declaredRuntimeToolNames(profile) {
1581
1580
  /** Describe Runtime declarations that cannot resolve without a product tool provider. */
1582
1581
  function runtimeToolDeclarationError(profile, hasProductToolResolver, mountedStaticToolNames = []) {
1583
1582
  const mountedStaticToolNameSet = new Set(mountedStaticToolNames);
1584
- const unresolved = declaredRuntimeToolNames(profile).filter((name) => !coordinationVerbNameSet.has(name) && !hasProductToolResolver && !mountedStaticToolNameSet.has(name));
1583
+ const unresolved = declaredRuntimeToolNames(profile).filter((name) => !coordinationVerbNameSet$1.has(name) && !hasProductToolResolver && !mountedStaticToolNameSet.has(name));
1585
1584
  if (unresolved.length === 0) return void 0;
1586
1585
  return `the profile declares ${unresolved.map((name) => JSON.stringify(`${coordinationProfileToolPrefix}${name}`)).join(", ")}, but this run has no resolveSupervisorTools provider or router-mounted static tool for those tools`;
1587
1586
  }
@@ -1780,7 +1779,6 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1780
1779
  ...deps.onAcceptedSubmission ? { onAcceptedSubmission: deps.onAcceptedSubmission } : {},
1781
1780
  toolNames: runtimeToolNames,
1782
1781
  ...nodeTools?.length ? { nodeTools } : {},
1783
- ...deps.maxLiveWorkers !== void 0 ? { maxLiveWorkers: deps.maxLiveWorkers } : {},
1784
1782
  ...deps.extraTools ? { extraTools: deps.extraTools } : {},
1785
1783
  ...deps.executeExtraTool ? { executeExtraTool: deps.executeExtraTool } : {},
1786
1784
  ...deps.analysts ? { analysts: deps.analysts } : {},
@@ -1840,6 +1838,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1840
1838
  } } : {},
1841
1839
  traceSource: () => driveHarness.traceSource?.(),
1842
1840
  progress: () => driveHarness.progress?.(),
1841
+ ...driveHarness.harnessTranscript ? { harnessTranscript: () => driveHarness.harnessTranscript?.() } : {},
1843
1842
  async act(task, scope) {
1844
1843
  const context = nodeContextSeed ? supervisorNodeContext(nodeContextSeed, stableProfile, task, scope) : void 0;
1845
1844
  const priorCoordination = deps.loadPriorCoordination ? await deps.loadPriorCoordination() : deps.priorCoordination;
@@ -1878,7 +1877,6 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1878
1877
  onStop: (reason) => {
1879
1878
  if (!stopController.signal.aborted) stopController.abort(reason ?? "coordination stop");
1880
1879
  },
1881
- ...deps.maxLiveWorkers !== void 0 ? { maxLiveWorkers: deps.maxLiveWorkers } : {},
1882
1880
  ...deps.analysts ? { analysts: deps.analysts } : {},
1883
1881
  ...deps.analyzeOnSettle ? { analyzeOnSettle: deps.analyzeOnSettle } : {},
1884
1882
  ...deps.escalateQuestion ? { escalateQuestion: deps.escalateQuestion } : {},
@@ -2574,6 +2572,34 @@ function assertProfileContract(profile, contract, context, runtimeConsumesCoordi
2574
2572
  * has asynchronously resolved its exact product-tool descriptors. Runtime-owned declarations are
2575
2573
  * not provider tools; unsupported declarations still fail when the coordination surface resolves.
2576
2574
  */
2575
+ /** The child with its manager's Runtime coordination grants, unless the child's author wrote any
2576
+ * coordination entry: an explicit grant or refusal is the author's choice and stands. A refusal
2577
+ * (`false`) grants nothing, so it is removed once it has decided the child stays a leaf; a
2578
+ * harness-less leaf carries no tools axis at all. */
2579
+ function withInheritedSpawnRights(parent, child) {
2580
+ const childTools = child.tools ?? {};
2581
+ const authored = Object.entries(childTools).filter(([name]) => name.startsWith(coordinationProfileToolPrefix));
2582
+ if (authored.length > 0) {
2583
+ if (authored.every(([, enabled]) => enabled !== false)) return child;
2584
+ const kept = Object.entries(childTools).filter(([name, enabled]) => !(name.startsWith(coordinationProfileToolPrefix) && enabled === false));
2585
+ const { tools: _tools, ...rest } = child;
2586
+ return agentProfileSchema.parse(kept.length === 0 ? rest : {
2587
+ ...rest,
2588
+ tools: Object.fromEntries(kept)
2589
+ });
2590
+ }
2591
+ const inherited = Object.entries(parent.tools ?? {}).filter(([name, enabled]) => enabled === true && name.startsWith(coordinationProfileToolPrefix) && coordinationVerbNameSet.has(name.slice(coordinationProfileToolPrefix.length)));
2592
+ if (!inherited.some(([name]) => name === `${coordinationProfileToolPrefix}spawn_worker`)) return child;
2593
+ return agentProfileSchema.parse({
2594
+ ...child,
2595
+ tools: {
2596
+ ...childTools,
2597
+ ...Object.fromEntries(inherited),
2598
+ [`${coordinationProfileToolPrefix}submit_result`]: true
2599
+ }
2600
+ });
2601
+ }
2602
+ const coordinationVerbNameSet = new Set(coordinationVerbNames);
2577
2603
  function profileWithoutDeclaredRuntimeCoordinationTools(profile) {
2578
2604
  return providerVisibleProfile(profile);
2579
2605
  }
@@ -2751,6 +2777,15 @@ const DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY = Object.freeze({
2751
2777
  allowedMcpHosts: defaultAllowedMcpHosts,
2752
2778
  allowConnections: false
2753
2779
  });
2780
+ /**
2781
+ * A manager keeps a dedicated environment. It serves its coordination credential through
2782
+ * create-time environment, and every co-tenant of a shared box could read it.
2783
+ */
2784
+ function managerExecutorConfig(config) {
2785
+ if (config.backend !== "provider" || config.shared === void 0) return config;
2786
+ const { shared: _shared, ...dedicated } = config;
2787
+ return Object.freeze(dedicated);
2788
+ }
2754
2789
  function isExternalSupervisor(profile) {
2755
2790
  return harnessRunsAgent(profile.harness);
2756
2791
  }
@@ -2769,10 +2804,11 @@ async function providerAcceptsCoordinationAttachments(backend) {
2769
2804
  function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns, rootStream) {
2770
2805
  if (maxTurns !== void 0 && maxTurns < 0) throw new ValidationError("driveHarnessFromBackend: maxTurns must be >= 0 (0 lifts the turn cap; bounds become the conserved pool + deadline + abort)");
2771
2806
  const turnCap = maxTurns ?? 0;
2772
- const boundBackend = bindReusableExecutorExecutionId(captureReusableExecutorConfig(backend, "driveHarnessFromBackend"), executionId);
2807
+ const boundBackend = bindReusableExecutorExecutionId(managerExecutorConfig(captureReusableExecutorConfig(backend, "driveHarnessFromBackend")), executionId);
2773
2808
  const baseFactory = createExecutor(boundBackend);
2774
2809
  const ownerRuntime = boundBackend.backend === "provider" ? boundBackend.runtime ?? resolveAgentEnvironmentProvider(boundBackend.provider, boundBackend.registry).name : "cli";
2775
2810
  let activeExecutor;
2811
+ let managerTranscript;
2776
2812
  const drive = async ({ profile, authoredProfile, task, scope, coordinationMcpUrl, coordinationMcpHeaders, stopSignal, coordinationTools, reentry }) => {
2777
2813
  const retainedOwner = boundBackend.backend === "provider" ? scopeRetainedOwnerContext(scope) : void 0;
2778
2814
  if (retainedOwner && boundBackend.backend === "provider") {
@@ -3136,6 +3172,8 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
3136
3172
  failure = error;
3137
3173
  }
3138
3174
  }
3175
+ const capture = executor.harnessTranscript?.();
3176
+ if (capture !== void 0 && (capture.status === "captured" || managerTranscript?.status !== "captured")) managerTranscript = capture;
3139
3177
  if (activeExecutor === executor) activeExecutor = void 0;
3140
3178
  }
3141
3179
  if (failed) throw failure;
@@ -3149,6 +3187,7 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
3149
3187
  drive.deliverReady = () => activeExecutor !== void 0;
3150
3188
  drive.traceSource = () => activeExecutor?.traceSource?.();
3151
3189
  drive.progress = () => activeExecutor?.progress?.();
3190
+ if (boundBackend.backend === "provider") drive.harnessTranscript = () => managerTranscript ?? activeExecutor?.harnessTranscript?.();
3152
3191
  return attestRuntimeOwnedScopeOwner(drive, ownerRuntime);
3153
3192
  }
3154
3193
  /**
@@ -3271,12 +3310,12 @@ const superviseOptionKeySet = /* @__PURE__ */ new Set([
3271
3310
  "extraTools",
3272
3311
  "finalizer",
3273
3312
  "hooks",
3313
+ "inheritSpawnRights",
3274
3314
  "journal",
3275
3315
  "makeLeafAgent",
3276
3316
  "makeWorkerAgent",
3277
3317
  "escalateQuestion",
3278
3318
  "maxDepth",
3279
- "maxLiveWorkers",
3280
3319
  "maxTurns",
3281
3320
  "now",
3282
3321
  "onCoordinationEvent",
@@ -3308,7 +3347,8 @@ const superviseOptionKeySet = /* @__PURE__ */ new Set([
3308
3347
  "repromptOnUnmet",
3309
3348
  "onUnmetContract",
3310
3349
  "workerRetry",
3311
- "onWorkerRetry"
3350
+ "onWorkerRetry",
3351
+ "workerSlots"
3312
3352
  ]);
3313
3353
  /**
3314
3354
  * Refuse a top-level option key `supervise()` reads nowhere, naming it.
@@ -3385,7 +3425,7 @@ function rootSpawnResourceRoot(backend) {
3385
3425
  }
3386
3426
  function captureSuperviseOptions(opts) {
3387
3427
  assertSuperviseOptionKeys(opts, "supervise");
3388
- 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, onUnmetContract, workerRetry, onWorkerRetry, finalizer, now, signal, rootHandle, ...decisionData } = opts;
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, onUnmetContract, workerRetry, onWorkerRetry, finalizer, now, signal, rootHandle, workerSlots, ...decisionData } = opts;
3389
3429
  assertNoUncapturedExecutableOption(decisionData);
3390
3430
  const capturedData = detachedSnapshot(decisionData, "supervise options");
3391
3431
  const capturedCoordination = coordination === void 0 ? void 0 : (() => {
@@ -3449,6 +3489,7 @@ function captureSuperviseOptions(opts) {
3449
3489
  ...resolveSpawnProfile === void 0 ? {} : { resolveSpawnProfile },
3450
3490
  ...blobs === void 0 ? {} : { blobs },
3451
3491
  ...journal === void 0 ? {} : { journal },
3492
+ ...workerSlots === void 0 ? {} : { workerSlots },
3452
3493
  ...probes === void 0 ? {} : { probes },
3453
3494
  ...authorizeSpawn === void 0 ? {} : { authorizeSpawn },
3454
3495
  ...authorizeMessage === void 0 ? {} : { authorizeMessage },
@@ -3547,15 +3588,19 @@ function assertPerWorkerWithinPool(perWorker, pool) {
3547
3588
  ].filter((x) => x !== null);
3548
3589
  if (problems.length > 0) throw new ValidationError(`${problems.join("; ")} — a per-child ceiling cannot exceed the pool it draws from, and accepting it silently leaves the caller believing a knob is in effect when the reservation still clamps the child.`);
3549
3590
  }
3550
- function defaultPerWorker(budget) {
3591
+ /** The slice a child gets when its manager names none: a quarter of the part of the manager's
3592
+ * budget its children may reserve, so four default children fill that part and the manager's
3593
+ * own share stays free for its turns. Each nested manager divides its own slice the same way. */
3594
+ function defaultPerWorker(budget, ownerShare) {
3595
+ const share = (1 - ownerShare) / 4;
3551
3596
  return {
3552
3597
  ...budget.resources === void 0 ? {} : { resources: Object.fromEntries(Object.entries(budget.resources).map(([name, value]) => [name, {
3553
3598
  unit: value.unit,
3554
- limit: Math.floor(value.limit / 4)
3599
+ limit: Math.floor(value.limit * share)
3555
3600
  }])) },
3556
- maxIterations: Math.max(1, Math.floor(budget.maxIterations / 4)),
3557
- maxTokens: Math.max(1, Math.floor(budget.maxTokens / 4)),
3558
- ...budget.maxUsd !== void 0 ? { maxUsd: budget.maxUsd / 4 } : {}
3601
+ maxIterations: Math.max(1, Math.floor(budget.maxIterations * share)),
3602
+ maxTokens: Math.max(1, Math.floor(budget.maxTokens * share)),
3603
+ ...budget.maxUsd !== void 0 ? { maxUsd: budget.maxUsd * share } : {}
3559
3604
  };
3560
3605
  }
3561
3606
  function freezeDetached(value) {
@@ -3716,10 +3761,11 @@ function superviseInternal(profile, task, opts, testBrain) {
3716
3761
  assertCoordinationBinding(options.coordination);
3717
3762
  const ctx = options.runDir !== void 0 ? createFileRunContext(options.runDir, { withDriver: true }) : createInMemoryRunContext({ withDriver: true });
3718
3763
  const blobs = options.blobs ?? ctx.blobs;
3719
- const perWorker = options.perWorker ?? defaultPerWorker(options.budget);
3764
+ assertRecursiveReservationPolicy(options.reservationPolicy);
3765
+ const ownerShare = options.reservationPolicy?.ownerShare ?? 0;
3766
+ const perWorker = options.perWorker ?? defaultPerWorker(options.budget, ownerShare);
3720
3767
  assertValidBudget(perWorker, "supervise perWorker");
3721
3768
  assertPerWorkerWithinPool(perWorker, options.budget);
3722
- assertRecursiveReservationPolicy(options.reservationPolicy, options.maxDepth ?? 8, options.maxLiveWorkers);
3723
3769
  const journal = options.journal ?? ctx.journal;
3724
3770
  const runId = options.runId ?? "supervise";
3725
3771
  const runNamespace = supervisionRunNamespace(options.runDir, runId);
@@ -3737,6 +3783,16 @@ function superviseInternal(profile, task, opts, testBrain) {
3737
3783
  const spawnPreflight = composeSpawnPreflights(profileToolSpawnPreflight(options.makeWorkerAgent === void 0, options.resolveSupervisorTools !== void 0), coordinationChannelSpawnPreflight(options.makeWorkerAgent === void 0, hasCustomDriveHarness, managerBackend, options.coordination), options.backend?.backend === "bridge" ? bridgeSpawnPreflight(options.backend) : void 0);
3738
3784
  const driverMaterialization = hasCustomDriveHarness ? options.driveHarnessMaterialization ?? fullProfileMaterialization : managerBackend && automaticDriverBackendSupported(managerBackend, options.coordination) ? backendProfileMaterialization(managerBackend) : void 0;
3739
3785
  if (isExternalSupervisor(canonicalProfile) && !options.driveHarness && !options.resolveDriveHarness && (!managerBackend || !automaticDriverBackendSupported(managerBackend, options.coordination))) throw new ValidationError(`supervise: external supervisor profile.harness=${JSON.stringify(canonicalProfile.harness)} requires a local bridge, a provider with authenticated coordination.publicUrl and runtime MCP attachments, or an explicit driveHarness with reachable coordination transport`);
3786
+ const externalManagersAvailable = hasCustomDriveHarness || managerBackend !== void 0 && automaticDriverBackendSupported(managerBackend, options.coordination);
3787
+ const canLead = (child) => isExternalSupervisor(child) ? externalManagersAvailable : options.router !== void 0;
3788
+ const childrenCanSubmit = deliverable !== void 0 || options.resolveDeliverable !== void 0;
3789
+ const composeSpawnProfileFor = (parent) => {
3790
+ if (options.inheritSpawnRights === false || options.makeWorkerAgent !== void 0 || !childrenCanSubmit) return composeSpawnProfile;
3791
+ return (authored) => {
3792
+ const composed = composeSpawnProfile ? composeSpawnProfile(authored) : authored;
3793
+ return canLead(composed) ? withInheritedSpawnRights(parent, composed) : composed;
3794
+ };
3795
+ };
3740
3796
  const harnessClaims = /* @__PURE__ */ new WeakMap();
3741
3797
  const claimDriveHarness = (rawHarness, ownerId) => {
3742
3798
  if (typeof rawHarness !== "function") throw new ValidationError("supervise: resolveDriveHarness must return a DriveHarness function");
@@ -3856,7 +3912,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3856
3912
  assertProfileContract(authorized, isExternalSupervisor(authorized) ? driverMaterialization : promptModelProfileMaterialization, `supervise driver ${JSON.stringify(spawnContext.label)}`, true);
3857
3913
  if (managerBackend) assertBridgeProfileMaterializes(profileWithoutDeclaredRuntimeCoordinationTools(authorized), managerBackend, `supervise driver ${JSON.stringify(spawnContext.label)}`);
3858
3914
  const childFactory = makeRecursiveWorkerFor(authorized, childExecution.identity, depth + 1, ownerId);
3859
- const nestedPerWorker = defaultPerWorker(spawnContext.budget);
3915
+ const nestedPerWorker = defaultPerWorker(spawnContext.budget, ownerShare);
3860
3916
  const authorizeNestedMessage = authorizeDownFor(authorized, depth + 1);
3861
3917
  let acceptedSubmission = false;
3862
3918
  return driverChild(authorized, supervisorAgent(authorized, {
@@ -3864,7 +3920,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3864
3920
  makeWorkerAgent: childFactory,
3865
3921
  ...authorizeNestedMessage ? { authorizeDownMessage: authorizeNestedMessage } : {},
3866
3922
  perWorker: nestedPerWorker,
3867
- ...options.reservationPolicy ? { preserveOwnerTurns: true } : {},
3923
+ ...ownerShare > 0 ? { preserveOwnerTurns: true } : {},
3868
3924
  ...options.router ? { router: options.router } : {},
3869
3925
  ...nestedDriveHarness ? { driveHarness: nestedDriveHarness } : {},
3870
3926
  ...options.coordination && isExternalSupervisor(authorized) ? { coordination: options.coordination } : {},
@@ -3890,7 +3946,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3890
3946
  ...options.continuityByProfile ? { continuityByProfile: options.continuityByProfile } : {},
3891
3947
  ...spawnPreflight ? { preflightSpawn: spawnPreflight } : {},
3892
3948
  ...options.resolveSpawnProfile ? { resolveSpawnProfile: options.resolveSpawnProfile } : {},
3893
- ...composeSpawnProfile ? { composeSpawnProfile } : {},
3949
+ ...composeSpawnProfileFor(authorized) ? { composeSpawnProfile: composeSpawnProfileFor(authorized) } : {},
3894
3950
  ...profileTable ? { profiles: profileTable } : {},
3895
3951
  ...options.peerMail ? { peerMail: options.peerMail } : {},
3896
3952
  ...options.stopRule ? { stopRule: options.stopRule } : {},
@@ -3962,7 +4018,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3962
4018
  makeWorkerAgent: workerFactory,
3963
4019
  ...authorizeRootMessage ? { authorizeDownMessage: authorizeRootMessage } : {},
3964
4020
  perWorker,
3965
- ...options.reservationPolicy ? { preserveOwnerTurns: true } : {},
4021
+ ...ownerShare > 0 ? { preserveOwnerTurns: true } : {},
3966
4022
  ...log ? { onEvent: (_event, record) => log.append(runId, record, rootOwnerId) } : {},
3967
4023
  ...deliverable ? { deliverable } : {},
3968
4024
  onProviderModel(model) {
@@ -3976,11 +4032,10 @@ function superviseInternal(profile, task, opts, testBrain) {
3976
4032
  ...options.coordination && isExternalSupervisor(canonicalProfile) ? { coordination: options.coordination } : {},
3977
4033
  ...spawnPreflight ? { preflightSpawn: spawnPreflight } : {},
3978
4034
  ...options.resolveSpawnProfile ? { resolveSpawnProfile: options.resolveSpawnProfile } : {},
3979
- ...composeSpawnProfile ? { composeSpawnProfile } : {},
4035
+ ...composeSpawnProfileFor(canonicalProfile) ? { composeSpawnProfile: composeSpawnProfileFor(canonicalProfile) } : {},
3980
4036
  ...profileTable ? { profiles: profileTable } : {},
3981
4037
  ...spawnResourceRoot === void 0 ? {} : { spawnResourceRoot },
3982
4038
  ...options.peerMail ? { peerMail: options.peerMail } : {},
3983
- ...options.maxLiveWorkers !== void 0 ? { maxLiveWorkers: options.maxLiveWorkers } : {},
3984
4039
  ...options.router ? { router: options.router } : {},
3985
4040
  ...rootDriveHarness ? { driveHarness: rootDriveHarness } : {},
3986
4041
  nodeContext: {
@@ -4051,12 +4106,12 @@ function superviseInternal(profile, task, opts, testBrain) {
4051
4106
  declaration: "deferred",
4052
4107
  authoredProfile: canonicalProfile
4053
4108
  } },
4054
- maxDepth: options.maxDepth ?? 8,
4109
+ maxDepth: options.maxDepth ?? 16,
4055
4110
  ...options.childSettleGraceMs !== void 0 ? { childSettleGraceMs: options.childSettleGraceMs } : {},
4056
4111
  ...options.teardownConfirmMs !== void 0 ? { teardownConfirmMs: options.teardownConfirmMs } : {},
4057
4112
  ...options.retainedAtSettlement !== void 0 ? { retainedAtSettlement: options.retainedAtSettlement } : {},
4058
4113
  ownerWorkspaceRetention: managerBackend?.backend === "provider" && managerBackend.workspaceRetention !== void 0,
4059
- ...options.maxLiveWorkers !== void 0 ? { maxLiveWorkers: options.maxLiveWorkers } : {},
4114
+ ...options.workerSlots !== void 0 ? { workerSlots: options.workerSlots } : {},
4060
4115
  ...options.reservationPolicy ? { reservationPolicy: options.reservationPolicy } : {},
4061
4116
  ...probes ? { probes } : {},
4062
4117
  ...ctx.resume === true ? { resume: true } : {},
@@ -4135,4 +4190,4 @@ function rootProviderModelEvidenceFromExecution(evidence) {
4135
4190
  //#endregion
4136
4191
  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 };
4137
4192
 
4138
- //# sourceMappingURL=supervise-RF3_8PuR.js.map
4193
+ //# sourceMappingURL=supervise--njTtSL3.js.map