@tangle-network/agent-runtime 0.349.0 → 0.352.1

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 (139) hide show
  1. package/dist/{activation-wBipBkCf.d.ts → activation-BidzGkUQ.d.ts} +2 -24
  2. package/dist/{activation-tNGW73Y9.js → activation-C6zNC2kx.js} +12 -14
  3. package/dist/{activation-tNGW73Y9.js.map → activation-C6zNC2kx.js.map} +1 -1
  4. package/dist/agent.d.ts +8 -12
  5. package/dist/agent.js +9 -12
  6. package/dist/agent.js.map +1 -1
  7. package/dist/{analyst-loop-DZw5QWT9.js → analyst-loop-BZvXCDKy.js} +2 -3
  8. package/dist/{analyst-loop-DZw5QWT9.js.map → analyst-loop-BZvXCDKy.js.map} +1 -1
  9. package/dist/analyst-loop.d.ts +3 -5
  10. package/dist/analyst-loop.js +1 -2
  11. package/dist/{bundle-1xaJEgjq.js → bundle-DeDkJbsr.js} +3 -4
  12. package/dist/{bundle-1xaJEgjq.js.map → bundle-DeDkJbsr.js.map} +1 -1
  13. package/dist/candidate-execution/index.d.ts +13 -33
  14. package/dist/candidate-execution/index.js +16 -18
  15. package/dist/candidate-execution/index.js.map +1 -1
  16. package/dist/chat-turn.d.ts +2 -0
  17. package/dist/chat-turn.js +1 -0
  18. package/dist/{coordination-manager-B2Z_MmL9.js → coordination-manager-B7QadgrI.js} +101 -132
  19. package/dist/{coordination-manager-B2Z_MmL9.js.map → coordination-manager-B7QadgrI.js.map} +1 -1
  20. package/dist/{delegate-Dr-63jFl.js → delegate-CoscoyEo.js} +19 -21
  21. package/dist/delegate-CoscoyEo.js.map +1 -0
  22. package/dist/durable.d.ts +16 -149
  23. package/dist/durable.js +57 -980
  24. package/dist/durable.js.map +1 -1
  25. package/dist/{errors-DodWX-cb.js → errors-AzSuGI23.js} +5 -3
  26. package/dist/errors-AzSuGI23.js.map +1 -0
  27. package/dist/execution-handle-Bd2_nUB6.js +167 -0
  28. package/dist/execution-handle-Bd2_nUB6.js.map +1 -0
  29. package/dist/execution-handle-CujvqgCn.d.ts +130 -0
  30. package/dist/{graph-DPejYB3C.js → graph-mojMML8e.js} +192 -14
  31. package/dist/graph-mojMML8e.js.map +1 -0
  32. package/dist/{improve-DwSahPi1.js → improve-Dm5ZE8mr.js} +36 -53
  33. package/dist/{improve-DwSahPi1.js.map → improve-Dm5ZE8mr.js.map} +1 -1
  34. package/dist/{improvement-adapter-sIthWkcN.d.ts → improvement-adapter-D5GRU1eY.d.ts} +2 -6
  35. package/dist/index.d.ts +41 -89
  36. package/dist/index.js +45 -61
  37. package/dist/index.js.map +1 -1
  38. package/dist/intelligence.d.ts +39 -59
  39. package/dist/intelligence.js +24 -33
  40. package/dist/intelligence.js.map +1 -1
  41. package/dist/journal-store-BJPMUydp.js +3925 -0
  42. package/dist/journal-store-BJPMUydp.js.map +1 -0
  43. package/dist/kernel.d.ts +5 -5
  44. package/dist/kernel.js +12 -11
  45. package/dist/{loop-runner-CP6MfO1b.js → loop-runner-5cL_vZi0.js} +5 -6
  46. package/dist/{loop-runner-CP6MfO1b.js.map → loop-runner-5cL_vZi0.js.map} +1 -1
  47. package/dist/{loop-runner-C6pGq-2l.d.ts → loop-runner-DyLD-aNb.d.ts} +3 -5
  48. package/dist/loop-runner-bin.d.ts +5 -8
  49. package/dist/loop-runner-bin.js +2 -3
  50. package/dist/mcp/bin.js +6 -8
  51. package/dist/mcp/bin.js.map +1 -1
  52. package/dist/mcp/index.d.ts +8 -18
  53. package/dist/mcp/index.js +17 -25
  54. package/dist/mcp/index.js.map +1 -1
  55. package/dist/mcp/memory-bin.js +4 -6
  56. package/dist/mcp/memory-bin.js.map +1 -1
  57. package/dist/{model-policy-CyCUwHed.js → model-policy-C-RGAUW4.js} +11 -13
  58. package/dist/{model-policy-CyCUwHed.js.map → model-policy-C-RGAUW4.js.map} +1 -1
  59. package/dist/placement.d.ts +12 -14
  60. package/dist/placement.js +1 -2
  61. package/dist/platform.d.ts +7 -13
  62. package/dist/platform.js +3 -6
  63. package/dist/platform.js.map +1 -1
  64. package/dist/{prepare-B9wWffjO.js → prepare-XWwsOh8O.js} +50 -69
  65. package/dist/{prepare-B9wWffjO.js.map → prepare-XWwsOh8O.js.map} +1 -1
  66. package/dist/{profile-JLJd2wFG.js → profile-C01SQZKa.js} +58 -92
  67. package/dist/profile-C01SQZKa.js.map +1 -0
  68. package/dist/{profile-materialization-bPm0gGLO.d.ts → profile-materialization-BRY22Oh8.d.ts} +1 -3
  69. package/dist/profiles.d.ts +25 -12
  70. package/dist/profiles.js +52 -11
  71. package/dist/profiles.js.map +1 -1
  72. package/dist/{protected-model-port-DVVh-hEk.d.ts → protected-model-port-IKqhTypD.d.ts} +2 -14
  73. package/dist/{protected-redaction-DFCeo4vg.js → protected-redaction-DilFZch5.js} +2 -3
  74. package/dist/{protected-redaction-DFCeo4vg.js.map → protected-redaction-DilFZch5.js.map} +1 -1
  75. package/dist/{provision-supervisor-C4v2vqDo.js → provision-supervisor-D9pO-iPl.js} +11 -15
  76. package/dist/{provision-supervisor-C4v2vqDo.js.map → provision-supervisor-D9pO-iPl.js.map} +1 -1
  77. package/dist/{run-cancellation-CzFhQGMa.js → run-cancellation-CoJRKvih.js} +6 -7
  78. package/dist/{run-cancellation-CzFhQGMa.js.map → run-cancellation-CoJRKvih.js.map} +1 -1
  79. package/dist/{runtime-CsvGCQpl.js → runtime-BJPXHWbc.js} +652 -215
  80. package/dist/runtime-BJPXHWbc.js.map +1 -0
  81. package/dist/{runtime-hooks-tXpAarhW.js → runtime-hooks-CsW2pfFk.js} +2 -3
  82. package/dist/{runtime-hooks-tXpAarhW.js.map → runtime-hooks-CsW2pfFk.js.map} +1 -1
  83. package/dist/{runtime-hooks-nsqxSUFL.d.ts → runtime-hooks-ZQqPw-0g.d.ts} +1 -3
  84. package/dist/{sandbox-profile-compat-DtuJWFrM.js → sandbox-profile-compat-CXjozdWL.js} +52 -653
  85. package/dist/sandbox-profile-compat-CXjozdWL.js.map +1 -0
  86. package/dist/{search-executor-CCb82Umc.js → search-executor-CQEHMXoT.js} +12 -15
  87. package/dist/{search-executor-CCb82Umc.js.map → search-executor-CQEHMXoT.js.map} +1 -1
  88. package/dist/{server-CKPwZU-I.js → server-U9NGgudQ.js} +19 -30
  89. package/dist/{server-CKPwZU-I.js.map → server-U9NGgudQ.js.map} +1 -1
  90. package/dist/{structural-rollout-DylC_fwU.js → structural-rollout-wMSxE7bn.js} +71 -70
  91. package/dist/structural-rollout-wMSxE7bn.js.map +1 -0
  92. package/dist/{substrate-CGDFTSRh.js → substrate-Db2pp6y3.js} +2 -3
  93. package/dist/{substrate-CGDFTSRh.js.map → substrate-Db2pp6y3.js.map} +1 -1
  94. package/dist/{supervise-BGfm2GlY.js → supervise-CNNhX0ab.js} +460 -195
  95. package/dist/supervise-CNNhX0ab.js.map +1 -0
  96. package/dist/supervision-discovery-CewADdEs.js +772 -0
  97. package/dist/supervision-discovery-CewADdEs.js.map +1 -0
  98. package/dist/{supervisor-wS9Ehz_x.js → supervisor-rK5Y8en6.js} +521 -4320
  99. package/dist/supervisor-rK5Y8en6.js.map +1 -0
  100. package/dist/{task-queue-0fKkoweu.d.ts → task-queue-kefGy79U.d.ts} +1 -3
  101. package/dist/task-queue.d.ts +1 -1
  102. package/dist/task-queue.js +1 -2
  103. package/dist/testing.d.ts +7 -15
  104. package/dist/testing.js +241 -244
  105. package/dist/testing.js.map +1 -1
  106. package/dist/tool-loop.d.ts +16 -19
  107. package/dist/tool-loop.js +2 -3
  108. package/dist/{tool-server-XV4aJwoQ.js → tool-server-CZWd_Opp.js} +3 -4
  109. package/dist/{tool-server-XV4aJwoQ.js.map → tool-server-CZWd_Opp.js.map} +1 -1
  110. package/dist/{top-snapshot-CflmaDgk.js → top-snapshot-DcV7VG4m.js} +179 -163
  111. package/dist/top-snapshot-DcV7VG4m.js.map +1 -0
  112. package/dist/tui/bin.js +50 -81
  113. package/dist/tui/bin.js.map +1 -1
  114. package/dist/tui/index.d.ts +27 -58
  115. package/dist/tui/index.js +2 -2
  116. package/dist/{types-C8BGOCBn.d.ts → types-0uzVKtFW.d.ts} +388 -484
  117. package/dist/{types-Cwrea-bU.d.ts → types-qsqfyQoY.d.ts} +1 -3
  118. package/dist/util-ebWMWzY0.js +624 -0
  119. package/dist/util-ebWMWzY0.js.map +1 -0
  120. package/dist/workspace-store/index.d.ts +12 -22
  121. package/dist/workspace-store/index.js +13 -10
  122. package/dist/workspace-store/index.js.map +1 -1
  123. package/dist/{workspace-streams-BiS4ABah.d.ts → workspace-streams-Dq2Fzk3c.d.ts} +1 -11
  124. package/package.json +31 -26
  125. package/skills/agent-graphs/SKILL.md +17 -4
  126. package/skills/be-ambitious/SKILL.md +46 -0
  127. package/skills/graph-designer/SKILL.md +9 -2
  128. package/dist/delegate-Dr-63jFl.js.map +0 -1
  129. package/dist/errors-DodWX-cb.js.map +0 -1
  130. package/dist/graph-DPejYB3C.js.map +0 -1
  131. package/dist/profile-JLJd2wFG.js.map +0 -1
  132. package/dist/record-events-D93DkpAx.js +0 -263
  133. package/dist/record-events-D93DkpAx.js.map +0 -1
  134. package/dist/runtime-CsvGCQpl.js.map +0 -1
  135. package/dist/sandbox-profile-compat-DtuJWFrM.js.map +0 -1
  136. package/dist/structural-rollout-DylC_fwU.js.map +0 -1
  137. package/dist/supervise-BGfm2GlY.js.map +0 -1
  138. package/dist/supervisor-wS9Ehz_x.js.map +0 -1
  139. package/dist/top-snapshot-CflmaDgk.js.map +0 -1
@@ -1,15 +1,16 @@
1
- import { c as captureRunWriteContext, l as fenceRunWrite, m as __exportAll, p as sha256, r as assertNoSymlinkDescendant, s as writeAtomicDurableFile } from "./record-events-D93DkpAx.js";
2
- import { $n as HarnessTurnFailedError, $r as sandboxProfileMaterialization, A as beginScopeOwnerAttempt, Ai as cappedDoublingMs, An as toOtelAttributes, At as createExecutor, B as assertRecursiveReservationPolicy, Bi as executorFailure, Bn as PEER_MAIL_WIRE_KEY, Cr as bridgeAdmissionRefusal, Ct as readCommittedJsonLines, Di as RetainedExecutionPendingError, En as generateSpanId, F as coordinationMcpAlias, Fn as INBOX_RECEIPT_KEY, G as meterRuntimeOwnedAccounting, Gr as controlProfileMaterialization, Ht as codeModeArguments, I as coordinationProfileToolPrefix, In as createInbox, Ir as bridgeRuntimeAttachmentsKey, J as recordScopeOwnerDriverAttempt, Jn as createActivityLog, Jr as profileMaterializationAxes$1, Jt as routerBrain, K as meterRuntimeOwnedProviderAttempt, Ki as spendFromUsageTotals, Kr as defineProfileMaterializationContract, Kt as toolResultText, L as providerVisibleProfile, Lr as bridgeStopSignalKey, M as recordScopeOwnerMaterialization, Mi as unavailablePauseMs, Mr as RunCancellationReason, N as restoreScopeOwnerAcceptedExecution, Ni as unavailableResumeAt, Nr as linkAbort, Oi as registerRetainedExecutorPreparation, Ot as bindReusableExecutorExecutionId, P as scopeOwnerExecutorNodeContext, Pr as runAbortable, Qn as DriverAttemptsExhaustedError, R as runtimeGraphMetadataKey, Ri as detachedSnapshot, St as readCommittedJsonFile, Tt as withJsonlFileLock, Ui as meterUsageEvent, Un as isPeerMailEnvelope, Ur as assertProfileMaterialization, Ut as codeModeModelOutput, V as deriveNodeExecutionIdentity, Vi as errMessage, Wi as newUsageTotals, Wt as createCodeModeTools, X as prepareScopeRetainedOwnerSeatSwitch, Xn as isLiveNodeStatus, Xr as promptModelProfileMaterialization, Xt as resolveAgentEnvironmentProvider, Y as recordScopeOwnerPause, Yr as promptControlProfileMaterialization, Z as scopeRetainedOwnerResourceReader, Zn as isTerminalNodeStatus, Zr as renderUnsupported, _i as runtimeOwnedPendingExecutorMaterialization, _n as WORKER_TRACE_PROPAGATION, _r as admitContinuationPolicy, a as assertRunParking, ar as upstreamUnavailableSignal, at as beginScopeRetainedOwnerDrive, br as createContinuationKeeper, bt as isNoEntError, c as sleepScopeWait, cr as authoredSeatStages, ct as scopeRetainedOwnerRestorePoint, d as runFinalizer, di as providerAttemptEvidence, dr as CheckUnavailableError, dt as bindScopeRetainedOwnerProvider, ei as unsupportedProfileDimensions, er as abandonablePending, et as abandonScopeRetainedOwnerInvocation, f as runTree, fi as recordRuntimeOwnedDriveHarnessProviderEvidence, fr as gateFactoryOnDeliverable, ft as scopeRetainedOwnerContext, g as isDriverSpec, gi as runtimeOwnedExecutorProviderEvidence, gr as CONTINUATIONS_DIR, h as driverExecutorFactory, hi as runtimeOwnedExecutorMaterialization, i as RunParkedError, ii as authoredAgentIdentity, ir as undispatchedCredentialExit, it as scopeRetainedOwnerResult, j as noteScopeOwnerPlannedExecution, ji as jitteredMs, jt as snapshotExecutorConfig, ki as retainedExecutorSeamKey, kt as captureReusableExecutorConfig, l as withRunParking, ln as persistHarnessTranscript, lr as seatExecutionProfile, lt as noteScopeRetainedOwnerCoordination, m as driverChild, mi as runtimeOwnedExecutorExecutionBinding, n as createSupervisor, nr as classifyDriverFailure, nt as prepareScopeRetainedOwnerTask, o as bindScopeParkingDrain, or as SeatChain, ot as scopeRetainedOwnerTurnEnded, p as createRootHandle, pi as runtimeOwnedDriveHarnessProviderEvidence, pt as scopeRetainedOwnerJournalRoot, q as recordScopeOwnerBarrenPause, qi as assertValidBudget, qr as fullProfileMaterialization, qt as createRouterTranscript, ri as attestRuntimeOwnedScopeOwner, rr as summarizeDriverAttempts, rt as scopeRetainedOwnerPriorSpend, si as inheritRuntimeOwnedExecutorAttestation, sr as SeatChainExhaustedError, st as reconcileScopeRetainedOwnerEnvironment, ti as worktreeCliProfileMaterialization, tr as causedByPartialFailure, tt as consumeScopeRetainedOwnerResult, u as bestDelivered, un as readHarnessTranscript, ut as bindScopeRetainedOwnerEnvironmentId, vi as runtimeOwnedScopeOwnerRuntime, vr as bestComposite, wn as createOtelExporter, wr as bridgeModelRouteRefusal, wt as upsertCommittedJsonLine, x as parseWorkerToolTraceArtifact, xt as prepareJsonlAppend, yr as checkVerdictOf, zi as contentAddress } from "./supervisor-wS9Ehz_x.js";
3
- import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
4
- import { Et as isDeadlineAbortReason, K as chargedTokens, Ot as teardownExecutor, W as addSpend, X as errorMessage, _t as withBudgetResources, dt as withTimeout, et as isAsyncIterable, ft as zeroSpend, gt as resourceTelemetry, kt as teardownSurfaces, mt as addResourceSpend, nt as promptCacheTokenClasses, ot as sleep, ut as unmeteredSpend, xt as DEFAULT_SUCCESSFUL_SHUTDOWN_MS } from "./sandbox-profile-compat-DtuJWFrM.js";
5
- import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, l as profileProviderModel, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-CyCUwHed.js";
6
- import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
7
- import { c as budgetOverspendText, d as safeJsonText, f as createFileRunContext, l as normalizeAnalyzeOnSettle, m as withRunContext, n as createCoordinationToolsForManager, o as createCancelAcknowledger, p as createInMemoryRunContext, s as createSteerAcknowledger, t as createCoordinationTools, u as coordinationVerbNames } from "./coordination-manager-B2Z_MmL9.js";
8
- import { c as writeRunCancellation, i as readRunCancellation, r as readRunCancelRequest, s as watchRunCancellation, t as applyRunCancellation } from "./run-cancellation-CzFhQGMa.js";
9
- import { n as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-XV4aJwoQ.js";
1
+ import { G as cappedDoublingMs, J as unavailableResumeAt, K as jitteredMs, P as RetainedExecutionPendingError, St as newUsageTotals, T as sha256, Tt as assertValidBudget, V as retainedExecutorSeamKey, Xt as __exportAll, a as isNoEntError, at as executorFailure, b as captureRunWriteContext, c as readCommittedJsonLines, ft as errMessage, g as assertNoSymlinkDescendant, l as upsertCommittedJsonLine, o as prepareJsonlAppend, q as unavailablePauseMs, rt as contentAddress, s as readCommittedJsonFile, tt as detachedSnapshot, u as withJsonlFileLock, wt as spendFromUsageTotals, x as fenceRunWrite, xt as meterUsageEvent, y as writeAtomicDurableFile, z as registerRetainedExecutorPreparation } from "./journal-store-BJPMUydp.js";
2
+ import { $ as abandonScopeRetainedOwnerInvocation, $n as authoredSeatStages, $r as inheritRuntimeOwnedExecutorAttestation, A as noteScopeOwnerPlannedExecution, B as deriveNodeExecutionIdentity, Br as profileMaterializationAxes$1, Cr as RunCancellationReason, Dn as createInbox, Dr as bridgeRuntimeAttachmentsKey, En as INBOX_RECEIPT_KEY, F as coordinationProfileToolPrefix, Fr as assertProfileMaterialization, Ft as createCodeModeTools, G as meterRuntimeOwnedProviderAttempt, Gn as abandonablePending, Gr as sandboxProfileMaterialization, Hn as isTerminalNodeStatus, Hr as promptModelProfileMaterialization, I as providerVisibleProfile, J as recordScopeOwnerPause, Jn as summarizeDriverAttempts, K as recordScopeOwnerBarrenPause, Kn as causedByPartialFailure, Kr as unsupportedProfileDimensions, L as runtimeGraphMetadataKey, Lr as controlProfileMaterialization, Lt as toolResultText, M as restoreScopeOwnerAcceptedExecution, N as scopeOwnerExecutorNodeContext, Nt as codeModeArguments, Or as bridgeStopSignalKey, P as coordinationMcpAlias, Pn as isPeerMailEnvelope, Pt as codeModeModelOutput, Qn as SeatChainExhaustedError, Rr as defineProfileMaterializationContract, Rt as createRouterTranscript, St as snapshotExecutorConfig, Tr as runAbortable, Un as DriverAttemptsExhaustedError, Ur as renderUnsupported, Vn as isLiveNodeStatus, Vr as promptControlProfileMaterialization, Vt as resolveAgentEnvironmentProvider, W as meterRuntimeOwnedAccounting, Wn as HarnessTurnFailedError, X as scopeRetainedOwnerResourceReader, Xn as upstreamUnavailableSignal, Xr as authoredAgentIdentity, Y as prepareScopeRetainedOwnerSeatSwitch, Yn as undispatchedCredentialExit, Yr as attestRuntimeOwnedScopeOwner, Zn as SeatChain, _n as generateSpanId, a as assertRunParking, ai as runtimeOwnedDriveHarnessProviderEvidence, at as scopeRetainedOwnerTurnEnded, bt as captureReusableExecutorConfig, c as sleepScopeWait, ci as runtimeOwnedExecutorProviderEvidence, cn as WORKER_TRACE_PROPAGATION, cr as admitContinuationPolicy, ct as noteScopeRetainedOwnerCoordination, d as runFinalizer, dr as createContinuationKeeper, dt as scopeRetainedOwnerContext, en as persistHarnessTranscript, er as seatExecutionProfile, et as consumeScopeRetainedOwnerResult, f as runTree, ft as scopeRetainedOwnerJournalRoot, g as isDriverSpec, h as driverExecutorFactory, hn as createOtelExporter, hr as bridgeModelRouteRefusal, i as RunParkedError, ii as recordRuntimeOwnedDriveHarnessProviderEvidence, it as beginScopeRetainedOwnerDrive, j as recordScopeOwnerMaterialization, jn as PEER_MAIL_WIRE_KEY, k as beginScopeOwnerAttempt, l as withRunParking, li as runtimeOwnedPendingExecutorMaterialization, lr as bestComposite, lt as bindScopeRetainedOwnerEnvironmentId, m as driverChild, mr as bridgeAdmissionRefusal, n as createSupervisor, nr as CheckUnavailableError, nt as scopeRetainedOwnerPriorSpend, o as bindScopeParkingDrain, oi as runtimeOwnedExecutorExecutionBinding, ot as reconcileScopeRetainedOwnerEnvironment, p as createRootHandle, q as recordScopeOwnerDriverAttempt, qn as classifyDriverFailure, qr as worktreeCliProfileMaterialization, ri as providerAttemptEvidence, rr as gateFactoryOnDeliverable, rt as scopeRetainedOwnerResult, si as runtimeOwnedExecutorMaterialization, sr as CONTINUATIONS_DIR, st as scopeRetainedOwnerRestorePoint, tn as readHarnessTranscript, tt as prepareScopeRetainedOwnerTask, u as bestDelivered, ui as runtimeOwnedScopeOwnerRuntime, ur as checkVerdictOf, ut as bindScopeRetainedOwnerProvider, wr as linkAbort, x as parseWorkerToolTraceArtifact, xn as toOtelAttributes, xt as createExecutor, yt as bindReusableExecutorExecutionId, z as assertRecursiveReservationPolicy, zn as createActivityLog, zr as fullProfileMaterialization, zt as routerBrain } from "./supervisor-rK5Y8en6.js";
3
+ import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-AzSuGI23.js";
4
+ import { B as teardownExecutor, C as withTimeout, E as addResourceSpend, N as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, O as resourceTelemetry, R as isDeadlineAbortReason, S as unmeteredSpend, V as teardownSurfaces, c as errorMessage, f as isAsyncIterable, i as chargedTokens, k as withBudgetResources, m as promptCacheTokenClasses, n as addSpend, v as sleep, w as zeroSpend } from "./util-ebWMWzY0.js";
5
+ import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, l as profileProviderModel, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-C-RGAUW4.js";
6
+ import { t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
7
+ import { c as createCancelAcknowledger, d as normalizeAnalyzeOnSettle, f as coordinationVerbNames, g as withRunContext, h as createInMemoryRunContext, l as createSteerAcknowledger, m as createFileRunContext, n as createCoordinationToolsForManager, o as resolveJsonPointer, p as safeJsonText, t as createCoordinationTools, u as budgetOverspendText } from "./coordination-manager-B7QadgrI.js";
8
+ import { c as writeRunCancellation, i as readRunCancellation, r as readRunCancelRequest, s as watchRunCancellation, t as applyRunCancellation } from "./run-cancellation-CoJRKvih.js";
9
+ import { n as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-CZWd_Opp.js";
10
10
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
11
11
  import { toolSpansToTraceAnalysisStore } from "@tangle-network/agent-eval";
12
12
  import { isRecord } from "@tangle-network/agent-core";
13
+ import { z } from "zod";
13
14
  import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
14
15
  import { closeSync, constants, fsyncSync, openSync, writeSync } from "node:fs";
15
16
  import { dirname, join, resolve } from "node:path";
@@ -18,7 +19,7 @@ import { isMaterializerHarness } from "@tangle-network/agent-profile-materialize
18
19
  import { createServer } from "node:http";
19
20
  import { ATTR, agentIdentityAttributes } from "@tangle-network/agent-trace-contract";
20
21
  import { withProfileKb } from "@tangle-network/agent-interface/profile-kb";
21
- //#region src/runtime/supervise/supervise-identity.ts
22
+ // src/runtime/supervise/supervise-identity.ts
22
23
  function externalExecutionId(kind, identity) {
23
24
  return `${kind}-${canonicalCandidateDigest({
24
25
  kind,
@@ -107,8 +108,7 @@ function coordinationEventId(context, event) {
107
108
  event: detachedSnapshot(durableEvent, "supervise coordination event identity")
108
109
  });
109
110
  }
110
- //#endregion
111
- //#region src/runtime/supervise/supervise-option-capture.ts
111
+ // src/runtime/supervise/supervise-option-capture.ts
112
112
  const superviseOptionKeySet = /* @__PURE__ */ new Set([
113
113
  "allowedModels",
114
114
  "analysts",
@@ -259,11 +259,13 @@ function captureSuperviseOptions(opts) {
259
259
  assertNoUncapturedExecutableOption(decisionData);
260
260
  const capturedData = detachedSnapshot(decisionData, "supervise options");
261
261
  const capturedCoordination = coordination === void 0 ? void 0 : (() => {
262
- const { publicUrl, onAudit, ...configuration } = coordination;
262
+ const { publicUrl, onAudit, onReadReady, onControlReady, ...configuration } = coordination;
263
263
  return Object.freeze({
264
264
  ...detachedSnapshot(configuration, "supervise coordination configuration"),
265
265
  ...publicUrl === void 0 ? {} : { publicUrl },
266
- ...onAudit === void 0 ? {} : { onAudit }
266
+ ...onAudit === void 0 ? {} : { onAudit },
267
+ ...onReadReady === void 0 ? {} : { onReadReady },
268
+ ...onControlReady === void 0 ? {} : { onControlReady }
267
269
  });
268
270
  })();
269
271
  const capturedBackend = backend === void 0 ? void 0 : snapshotExecutorConfig(backend);
@@ -356,8 +358,7 @@ function captureSuperviseOptions(opts) {
356
358
  ...otel === void 0 ? {} : { otel }
357
359
  });
358
360
  }
359
- //#endregion
360
- //#region src/runtime/supervise/otel-spans.ts
361
+ // src/runtime/supervise/otel-spans.ts
361
362
  /**
362
363
  * Supervisor tree → OTLP spans. OPT-IN, off by default.
363
364
  *
@@ -737,7 +738,8 @@ function assignBudget(attrs, value) {
737
738
  * default) is DERIVED by content address from namespace and run id, so a resumed run rejoins its trace. */
738
739
  function normalizeTraceId(traceId, runId, namespace) {
739
740
  if (traceId && /^[0-9a-f]{32}$/i.test(traceId)) return traceId.toLowerCase();
740
- return contentAddress(traceId ?? (namespace === void 0 ? runId : `${namespace}\u0000${runId}`)).slice(7, 39);
741
+ const source = traceId ?? (namespace === void 0 ? runId : `${namespace}\u0000${runId}`);
742
+ return contentAddress(source).slice(7, 39);
741
743
  }
742
744
  function msToNano(ms) {
743
745
  return (BigInt(Number.isFinite(ms) ? Math.floor(ms) : 0) * 1000000n).toString();
@@ -751,8 +753,7 @@ function str(value) {
751
753
  function truncate(value) {
752
754
  return value.length > MAX_DETAIL_CHARS ? `${value.slice(0, MAX_DETAIL_CHARS)}…` : value;
753
755
  }
754
- //#endregion
755
- //#region src/runtime/supervise/root-stream.ts
756
+ // src/runtime/supervise/root-stream.ts
756
757
  /**
757
758
  * The root manager's own provider stream, retained where Runtime owns it.
758
759
  *
@@ -927,8 +928,7 @@ async function readRootStream(runDir) {
927
928
  }
928
929
  return records;
929
930
  }
930
- //#endregion
931
- //#region src/runtime/anytime.ts
931
+ // src/runtime/anytime.ts
932
932
  /**
933
933
  * The best-so-far fold — the ONE definition of "how good was the run after k results", shared by
934
934
  * the post-run anytime report below and by the LIVE progress-based stop rules
@@ -1075,8 +1075,7 @@ function renderAnytimeTable(report) {
1075
1075
  }
1076
1076
  return lines.join("\n");
1077
1077
  }
1078
- //#endregion
1079
- //#region src/runtime/supervise/stop-rules.ts
1078
+ // src/runtime/supervise/stop-rules.ts
1080
1079
  /**
1081
1080
  *
1082
1081
  * PROGRESS-BASED STOP RULES — end a long-horizon run for the right reason.
@@ -1273,8 +1272,7 @@ function progressStop(tracker, rule, ledger, scope, now, stallAfterMs) {
1273
1272
  });
1274
1273
  return tracker.evaluate(rule, scope, stallAfterMs !== void 0 ? { stallAfterMs } : void 0);
1275
1274
  }
1276
- //#endregion
1277
- //#region src/runtime/supervise/supervise-agent-options.ts
1275
+ // src/runtime/supervise/supervise-agent-options.ts
1278
1276
  /** A stop rule as a function, or the declared plateau form a record carries as data. */
1279
1277
  function stopRuleOf(rule) {
1280
1278
  if (typeof rule === "function") return rule;
@@ -1291,8 +1289,7 @@ function supervisorTurnOptions(options) {
1291
1289
  ...options.onDriverAttempt ? { onDriverAttempt: options.onDriverAttempt } : {}
1292
1290
  };
1293
1291
  }
1294
- //#endregion
1295
- //#region src/runtime/supervise/graph-edge-ledger.ts
1292
+ // src/runtime/supervise/graph-edge-ledger.ts
1296
1293
  var GraphEdgeLedger = class {
1297
1294
  journal;
1298
1295
  runId;
@@ -1407,8 +1404,7 @@ var GraphEdgeLedger = class {
1407
1404
  }
1408
1405
  };
1409
1406
  const pendingKey = (parentNodeId, assignmentId) => `${parentNodeId ?? ""}\u0000${assignmentId}`;
1410
- //#endregion
1411
- //#region src/runtime/supervise/prompt-registry.ts
1407
+ // src/runtime/supervise/prompt-registry.ts
1412
1408
  /**
1413
1409
  *
1414
1410
  * The kernel prompt registry — versioned prompt text as DATA, addressed by `PromptHandle`.
@@ -1540,8 +1536,7 @@ function kernelPromptRegistry() {
1540
1536
  dumbContinuationPassPrompt
1541
1537
  ]);
1542
1538
  }
1543
- //#endregion
1544
- //#region src/runtime/supervise/graph-topology.ts
1539
+ // src/runtime/supervise/graph-topology.ts
1545
1540
  /**
1546
1541
  * `run_graph`: a graph a manager starts as one subtask. The topology is read from model-written
1547
1542
  * data or a stored graph, validated exactly as `runGraph` validates a root graph, and carried on
@@ -1848,8 +1843,7 @@ function graphSubtaskOf(profile) {
1848
1843
  const raw = profile.metadata?.[runtimeGraphMetadataKey];
1849
1844
  return raw === void 0 ? void 0 : parseGraphSubtaskTopology(raw);
1850
1845
  }
1851
- //#endregion
1852
- //#region src/runtime/supervise/graph-flow.ts
1846
+ // src/runtime/supervise/graph-flow.ts
1853
1847
  /** A flow node's usable settle matched no routes edge leaving it (`unrouted`), or a fired edge named
1854
1848
  * a node that still had a running worker (`target-live`). The flow spawned nothing more; the full
1855
1849
  * evidence rides on the error, shaped like `GraphEdgeCapError`. */
@@ -2330,8 +2324,7 @@ function createFlowRun() {
2330
2324
  failure
2331
2325
  };
2332
2326
  }
2333
- //#endregion
2334
- //#region src/runtime/supervise/graph-overlay.ts
2327
+ // src/runtime/supervise/graph-overlay.ts
2335
2328
  /**
2336
2329
  * The graph layer over the managers that run one `AgentGraph`.
2337
2330
  *
@@ -2632,8 +2625,7 @@ function ledgerAnalyzes(ledger, edge, outcome, bytes, reason, workerId) {
2632
2625
  ...workerId !== void 0 ? { workerId } : {}
2633
2626
  }, true);
2634
2627
  }
2635
- //#endregion
2636
- //#region src/runtime/supervise/flow-brain.ts
2628
+ // src/runtime/supervise/flow-brain.ts
2637
2629
  const flowBrains = /* @__PURE__ */ new WeakSet();
2638
2630
  /**
2639
2631
  * The brain of a flow graph's runtime-owned root manager. It never calls a model: every turn
@@ -2654,8 +2646,7 @@ function runtimeFlowBrain() {
2654
2646
  function isRuntimeFlowBrain(brain) {
2655
2647
  return flowBrains.has(brain);
2656
2648
  }
2657
- //#endregion
2658
- //#region src/runtime/supervise/supervise-budget.ts
2649
+ // src/runtime/supervise/supervise-budget.ts
2659
2650
  /**
2660
2651
  * Which of a driver's budget channels are spent, with their numbers, or `undefined` while none is.
2661
2652
  * The bare 'supervisor budget exhausted' named no channel: on queens21-h22-capture-root-2-20261019c
@@ -2736,8 +2727,7 @@ function unmeteredOwnerCache(total, committed) {
2736
2727
  ...total.cacheBreakdownKnown === false ? { cacheBreakdownKnown: false } : {}
2737
2728
  };
2738
2729
  }
2739
- //#endregion
2740
- //#region src/runtime/tool-loop.ts
2730
+ // src/runtime/tool-loop.ts
2741
2731
  /**
2742
2732
  * THE canonical agentic tool-loop. One inference turn → run any requested tools → fold the
2743
2733
  * results back as `tool` messages → repeat, until the model answers without a tool call or the
@@ -2975,8 +2965,7 @@ async function runBrainLoop(opts) {
2975
2965
  ...retainedCodeMode()
2976
2966
  };
2977
2967
  }
2978
- //#endregion
2979
- //#region src/runtime/supervise/driver-budget-guards.ts
2968
+ // src/runtime/supervise/driver-budget-guards.ts
2980
2969
  /** Spawn-progress is impossible: the pool can't afford another worker AND nothing is in flight to
2981
2970
  * await. A long-horizon driver bounded by the conserved pool stops here instead of spinning (the
2982
2971
  * in-loop budget guard the turn cap alone never provided). Checks BOTH conserved channels: tokens
@@ -3016,8 +3005,7 @@ function deadlinePassed(scope, now) {
3016
3005
  const b = scope.budget;
3017
3006
  return b.deadlineMs > 0 && now() >= b.deadlineMs;
3018
3007
  }
3019
- //#endregion
3020
- //#region src/runtime/supervise/driver-prompt-cache.ts
3008
+ // src/runtime/supervise/driver-prompt-cache.ts
3021
3009
  /** The USD-denominated members of {@link PromptCacheUsage} — the schema, not a guess. Every
3022
3010
  * other known member (`readTokens`, `writeTokens`, `missTokens`) is a token COUNT. */
3023
3011
  const PROMPT_CACHE_USD_FIELDS = /* @__PURE__ */ new Set(["readSavingsUsd"]);
@@ -3133,8 +3121,7 @@ function safeJson(v) {
3133
3121
  return String(v);
3134
3122
  }
3135
3123
  }
3136
- //#endregion
3137
- //#region src/runtime/supervise/driver-tool-dispatch.ts
3124
+ // src/runtime/supervise/driver-tool-dispatch.ts
3138
3125
  /** Run a work tool. A throw is data to the driver (it can recover next turn), not a crash — fold
3139
3126
  * the error back as a string result. null/undefined passes through (the caller treats it as "not
3140
3127
  * handled" and falls to the coordination dispatch). */
@@ -3152,14 +3139,13 @@ async function runTool(tool, args) {
3152
3139
  return { error: errorMessage(e) };
3153
3140
  }
3154
3141
  }
3155
- //#endregion
3156
- //#region src/runtime/supervise/wake.ts
3142
+ // src/runtime/supervise/wake.ts
3157
3143
  /** How long a waiting manager hears nothing before Runtime wakes it to reconsider: 15 min. */
3158
- const DEFAULT_WAKE_HEARTBEAT_MS = 15 * 6e4;
3144
+ const DEFAULT_WAKE_HEARTBEAT_MS = 9e5;
3159
3145
  /** How long a wake waits for more events after its first, while other workers still run: 2 s. */
3160
3146
  const DEFAULT_WAKE_DEBOUNCE_MS = 2e3;
3161
3147
  /** How long before its deadline a manager is woken once to submit its best result: 15 min. */
3162
- const DEFAULT_DEADLINE_WARNING_MS = 15 * 6e4;
3148
+ const DEFAULT_DEADLINE_WARNING_MS = 9e5;
3163
3149
  /** The instruction every manager receives about waiting. */
3164
3150
  const WAIT_BY_ENDING_TURN = "When you are waiting for workers, end your turn. You will be woken with what happened: a worker settled, a finding, a message or answer from your lead, or the deadline approaching.";
3165
3151
  function resolveWakePolicy(policy) {
@@ -3218,8 +3204,7 @@ function composeWakeInput(wake, context) {
3218
3204
  lines.push("", WAIT_BY_ENDING_TURN);
3219
3205
  return lines.join("\n");
3220
3206
  }
3221
- //#endregion
3222
- //#region src/runtime/supervise/driver-brain-turns.ts
3207
+ // src/runtime/supervise/driver-brain-turns.ts
3223
3208
  /** How often a waiting driver applies operator cancels and steers between its turns. */
3224
3209
  const WAITING_CONTROL_POLL_MS = 5e3;
3225
3210
  /** The evidence fault a brain reply carries, if any: identity, transport count, or prompt cache. */
@@ -3466,8 +3451,7 @@ var DriverBrainTurns = class {
3466
3451
  for (const lease of this.leases.splice(0)) lease.release();
3467
3452
  }
3468
3453
  };
3469
- //#endregion
3470
- //#region src/runtime/supervise/driver-tool-surface.ts
3454
+ // src/runtime/supervise/driver-tool-surface.ts
3471
3455
  /** Mount this manager's coordination tools over `scope` and select exactly the granted tools. */
3472
3456
  async function openDriverToolSurface(opts, scope) {
3473
3457
  const ownerReader = opts.spawnResourceReader ?? (opts.spawnResourceRoot === void 0 ? scopeRetainedOwnerResourceReader(scope) : void 0);
@@ -3548,8 +3532,7 @@ async function openDriverToolSurface(opts, scope) {
3548
3532
  })
3549
3533
  };
3550
3534
  }
3551
- //#endregion
3552
- //#region src/runtime/supervise/driver-brain-agent.ts
3535
+ // src/runtime/supervise/driver-brain-agent.ts
3553
3536
  /**
3554
3537
  * Build the intelligent recursive driver. Its `act` is the LLM tool-loop; spawn it as a
3555
3538
  * `driverChild` (`driver-executor.ts`) to run it inside a nested scope, recursively.
@@ -3699,8 +3682,7 @@ function driverInitialMessages(opts, system, task, scope) {
3699
3682
  }] : []
3700
3683
  ];
3701
3684
  }
3702
- //#endregion
3703
- //#region src/runtime/supervise/supervisor-agent-profile.ts
3685
+ // src/runtime/supervise/supervisor-agent-profile.ts
3704
3686
  /**
3705
3687
  * The completion check of a managed child that no `resolveDeliverable` gave a check of its own, a
3706
3688
  * `run_graph` node included: its accepted submission settles it, and the result goes to the manager
@@ -3770,7 +3752,11 @@ function assertRouterArmResourcePolicy(profile) {
3770
3752
  */
3771
3753
  function resolveSupervisorSystemPrompt(profile) {
3772
3754
  const promptSystem = profile.prompt?.systemPrompt;
3773
- const lines = [...profile.prompt?.instructions ?? [], ...resourceInstructionLines(profile.resources?.instructions)];
3755
+ const lines = [
3756
+ ...profile.prompt?.appendSystemPrompt === void 0 ? [] : [profile.prompt.appendSystemPrompt],
3757
+ ...profile.prompt?.instructions ?? [],
3758
+ ...resourceInstructionLines(profile.resources?.instructions)
3759
+ ];
3774
3760
  if (lines.length === 0) return promptSystem;
3775
3761
  return (promptSystem !== void 0 ? [promptSystem, ...lines] : lines).join("\n");
3776
3762
  }
@@ -3780,8 +3766,7 @@ function resolveSupervisorModelId(profile) {
3780
3766
  return concreteProfileModel(profile);
3781
3767
  }
3782
3768
  /** Listener, authenticated remote endpoint, and bounded request policy for one manager. */
3783
- //#endregion
3784
- //#region src/runtime/supervise/supervisor-coordination-observers.ts
3769
+ // src/runtime/supervise/supervisor-coordination-observers.ts
3785
3770
  /** Forward the same declared observer routes to router and external manager coordination. */
3786
3771
  function supervisorCoordinationObservers(deps) {
3787
3772
  return {
@@ -3796,13 +3781,19 @@ function supervisorCoordinationObservers(deps) {
3796
3781
  ...deps.stallAfterMs !== void 0 ? { stallAfterMs: deps.stallAfterMs } : {}
3797
3782
  };
3798
3783
  }
3799
- //#endregion
3800
- //#region src/runtime/supervise/coordination-credentials.ts
3784
+ // src/runtime/supervise/coordination-credentials.ts
3801
3785
  /**
3802
3786
  * The credentials one coordination listener accepts: the manager's bearer token (random, or an HMAC
3803
- * claim set under caller-owned signing keys), the separate read-only token, rotation and the
3787
+ * claim set under caller-owned signing keys), separate read-only and control tokens, rotation and the
3804
3788
  * revocation of every token it replaces.
3805
3789
  */
3790
+ /** Exact operator authority, independent of the manager's authored tool grants. */
3791
+ const coordinationControlToolNames = Object.freeze([
3792
+ "observe_agent",
3793
+ "read_journal",
3794
+ "steer_agent",
3795
+ "cancel_worker"
3796
+ ]);
3806
3797
  /** The bearer token in an `Authorization` header, or an empty buffer. */
3807
3798
  function bearerToken(authorization) {
3808
3799
  return typeof authorization === "string" && authorization.startsWith("Bearer ") ? Buffer.from(authorization.slice(7)) : Buffer.alloc(0);
@@ -3815,6 +3806,7 @@ function createCoordinationCredentials(input) {
3815
3806
  keys: { ...auth.signingKeys.keys }
3816
3807
  } : void 0;
3817
3808
  let readerToken = Buffer.from(randomBytes(32).toString("base64url"));
3809
+ let controllerToken = Buffer.from(randomBytes(32).toString("base64url"));
3818
3810
  let token;
3819
3811
  let expiresAt;
3820
3812
  let headers = Object.freeze({});
@@ -3844,6 +3836,7 @@ function createCoordinationCredentials(input) {
3844
3836
  text = `${payload}.${createHmac("sha256", signingKeys.keys[signingKeys.activeKeyId]).update(payload).digest("base64url")}`;
3845
3837
  }
3846
3838
  readerToken = Buffer.from(randomBytes(32).toString("base64url"));
3839
+ controllerToken = Buffer.from(randomBytes(32).toString("base64url"));
3847
3840
  token = Buffer.from(text);
3848
3841
  headers = Object.freeze({ Authorization: `Bearer ${text}` });
3849
3842
  };
@@ -3864,6 +3857,7 @@ function createCoordinationCredentials(input) {
3864
3857
  return false;
3865
3858
  }
3866
3859
  };
3860
+ const capabilityRefused = (supplied, expected) => input.isClosed() || supplied.length !== expected.length || !timingSafeEqual(supplied, expected) || expiresAt !== void 0 && expiresAt <= Date.now();
3867
3861
  return {
3868
3862
  rotate,
3869
3863
  setAudience: (next) => {
@@ -3873,7 +3867,11 @@ function createCoordinationCredentials(input) {
3873
3867
  if (input.scopeSignal.aborted) return "scope-stopped";
3874
3868
  return valid(supplied) ? void 0 : "credential-refused";
3875
3869
  },
3876
- readerRefused: (supplied) => supplied.length !== readerToken.length || !timingSafeEqual(supplied, readerToken) || expiresAt !== void 0 && expiresAt <= Date.now(),
3870
+ readerRefused: (supplied) => input.scopeSignal.aborted || input.lifetimeSignal?.aborted === true || capabilityRefused(supplied, readerToken),
3871
+ controllerRefused: (supplied) => {
3872
+ if (input.scopeSignal.aborted || input.lifetimeSignal?.aborted) return "scope-stopped";
3873
+ return capabilityRefused(supplied, controllerToken) ? "credential-refused" : void 0;
3874
+ },
3877
3875
  get headers() {
3878
3876
  return headers;
3879
3877
  },
@@ -3882,11 +3880,13 @@ function createCoordinationCredentials(input) {
3882
3880
  },
3883
3881
  get readerToken() {
3884
3882
  return readerToken;
3883
+ },
3884
+ get controllerHeaders() {
3885
+ return Object.freeze({ Authorization: `Bearer ${controllerToken.toString()}` });
3885
3886
  }
3886
3887
  };
3887
3888
  }
3888
- //#endregion
3889
- //#region src/runtime/supervise/coordination-http.ts
3889
+ // src/runtime/supervise/coordination-http.ts
3890
3890
  /** The JSON-RPC error a refusal carries. MCP clients put a non-2xx body into the error the agent
3891
3891
  * sees, so without it the agent reads only `Error POSTing to endpoint:` and a status at best. The
3892
3892
  * messages are fixed text: never a credential, a request body or an arbitrary error string. */
@@ -3930,7 +3930,7 @@ function coordinationHttpLimits(options) {
3930
3930
  const requestTimeoutMs = positive("requestTimeoutMs", options.requestTimeoutMs, 9e4);
3931
3931
  if (requestTimeoutMs > 2147483647) throw new ConfigError("coordination requestTimeoutMs exceeds the timer limit");
3932
3932
  return {
3933
- maxRequestBytes: positive("maxRequestBytes", options.maxRequestBytes, 1024 * 1024),
3933
+ maxRequestBytes: positive("maxRequestBytes", options.maxRequestBytes, 1048576),
3934
3934
  requestTimeoutMs,
3935
3935
  maxConcurrentRequests: positive("maxConcurrentRequests", options.maxConcurrentRequests, 32),
3936
3936
  requestsPerMinute: positive("requestsPerMinute", options.requestsPerMinute, 600),
@@ -4139,8 +4139,7 @@ function coordinationHttpHandler(input) {
4139
4139
  });
4140
4140
  };
4141
4141
  }
4142
- //#endregion
4143
- //#region src/runtime/supervise/coordination-mcp-listener.ts
4142
+ // src/runtime/supervise/coordination-mcp-listener.ts
4144
4143
  /**
4145
4144
  * The HTTP side of one coordination server: which hosts and paths it answers, who may call each
4146
4145
  * (manager, read-only observer, one peer-mail capability), and the public address it advertises.
@@ -4151,6 +4150,7 @@ function openCoordinationListenerState() {
4151
4150
  audiences: /* @__PURE__ */ new Set(),
4152
4151
  paths: /* @__PURE__ */ new Set(["/mcp"]),
4153
4152
  readPaths: /* @__PURE__ */ new Set(),
4153
+ controlPaths: /* @__PURE__ */ new Set(),
4154
4154
  mailPaths: /* @__PURE__ */ new Set()
4155
4155
  };
4156
4156
  }
@@ -4190,6 +4190,31 @@ function readOnlyHandler(ctx, coord) {
4190
4190
  handle: (message) => readMcp.handle(message)
4191
4191
  });
4192
4192
  }
4193
+ /** Operator access calls the same owned-worker handlers, with no spawn/submit/stop authority. */
4194
+ function controlHandler(ctx, coord) {
4195
+ const toolNames = new Set(coordinationControlToolNames);
4196
+ const controlMcp = createStdioToolServer({
4197
+ serverName: "supervisor-control",
4198
+ serverVersion: "1",
4199
+ tools: coord.tools.filter((tool) => toolNames.has(tool.name))
4200
+ });
4201
+ return coordinationHttpHandler({
4202
+ options: ctx.opts,
4203
+ identity: ctx.identity,
4204
+ toolNames,
4205
+ backgroundActions: () => 0,
4206
+ authorize: (req) => {
4207
+ const refused = authority(ctx, req);
4208
+ if (refused) return refused;
4209
+ const credential = ctx.credentials.controllerRefused(bearerToken(req.headers.authorization));
4210
+ return credential === void 0 ? void 0 : {
4211
+ status: 401,
4212
+ reason: credential
4213
+ };
4214
+ },
4215
+ handle: (message) => controlMcp.handle(message)
4216
+ });
4217
+ }
4193
4218
  function managerHandler(ctx, mcp, servedTools, background) {
4194
4219
  return coordinationHttpHandler({
4195
4220
  options: ctx.opts,
@@ -4244,10 +4269,12 @@ function peerMailHandler(ctx, coord, capabilityId) {
4244
4269
  function createCoordinationListener(ctx, bound) {
4245
4270
  const { coord } = bound;
4246
4271
  const readHandler = readOnlyHandler(ctx, coord);
4272
+ const operatorHandler = controlHandler(ctx, coord);
4247
4273
  const peerHandlers = /* @__PURE__ */ new Map();
4248
4274
  const mainHandler = managerHandler(ctx, bound.mcp, bound.servedTools, bound.background);
4249
4275
  return createServer((req, res) => {
4250
4276
  if (ctx.state.readPaths.has(req.url ?? "")) return readHandler(req, res);
4277
+ if (ctx.state.controlPaths.has(req.url ?? "")) return operatorHandler(req, res);
4251
4278
  for (const base of ctx.state.mailPaths) {
4252
4279
  if (!(req.url ?? "").startsWith(base + "/")) continue;
4253
4280
  const capabilityId = (req.url ?? "").slice(base.length + 1);
@@ -4266,8 +4293,7 @@ function createCoordinationListener(ctx, bound) {
4266
4293
  return mainHandler(req, res);
4267
4294
  });
4268
4295
  }
4269
- //#endregion
4270
- //#region src/runtime/supervise/single-flight-tools.ts
4296
+ // src/runtime/supervise/single-flight-tools.ts
4271
4297
  /**
4272
4298
  * Serve method-supplied supervisor tools on the coordination MCP as single-flight, fenced calls.
4273
4299
  *
@@ -4378,8 +4404,7 @@ function toolCallReceipt(tool, receipt, elapsedMs) {
4378
4404
  instruction: `${tool} is still running; nothing failed. Do not call it again: its result arrives with receipt ${receipt} when you are next woken. Continue other work, or end your turn to wait.`
4379
4405
  };
4380
4406
  }
4381
- //#endregion
4382
- //#region src/runtime/supervise/coordination-mcp-tools.ts
4407
+ // src/runtime/supervise/coordination-mcp-tools.ts
4383
4408
  /**
4384
4409
  * Which tools one coordination server serves: the options its coordination tools are built from,
4385
4410
  * and the granted subset of coordination verbs and node tools, fenced and single-flight.
@@ -4463,9 +4488,8 @@ function bindServedTools(opts, coord, fenceMs) {
4463
4488
  background: () => nodeTools.background() + fencedVerbs.background()
4464
4489
  };
4465
4490
  }
4466
- //#endregion
4467
- //#region src/runtime/supervise/coordination-preflight.ts
4468
- const MAX_RESPONSE_BYTES = 1024 * 1024;
4491
+ // src/runtime/supervise/coordination-preflight.ts
4492
+ const MAX_RESPONSE_BYTES = 1048576;
4469
4493
  var CoordinationPreflightError = class extends ConfigError {
4470
4494
  constructor(reason) {
4471
4495
  super(`coordination public endpoint preflight failed: ${reason}`);
@@ -4554,8 +4578,7 @@ async function preflightPublicCoordination(input) {
4554
4578
  linked.release();
4555
4579
  }
4556
4580
  }
4557
- //#endregion
4558
- //#region src/runtime/supervise/coordination-mcp.ts
4581
+ // src/runtime/supervise/coordination-mcp.ts
4559
4582
  /** Hosts that reach only this machine (incl. IPv4-mapped and bracketed IPv6 spellings). A name not
4560
4583
  * recognizably loopback counts as REMOTE: whether it resolves to loopback is unknowable here. */
4561
4584
  function isLoopbackHost(host) {
@@ -4576,6 +4599,7 @@ function assertCoordinationTransport(options) {
4576
4599
  for (const [id, key] of Object.entries(signingKeys.keys)) if (!/^[A-Za-z0-9_-]{1,64}$/.test(id) || typeof key !== "string" || Buffer.byteLength(key) < 32) throw new ConfigError("coordination signing keys require bounded key IDs and at least 32 secret bytes");
4577
4600
  }
4578
4601
  if (options.onReadReady && !options.authentication) throw new ConfigError("coordination read capability publication requires authentication");
4602
+ if (options.onControlReady && !options.authentication) throw new ConfigError("coordination control capability publication requires authentication");
4579
4603
  coordinationHttpLimits(options);
4580
4604
  }
4581
4605
  /** The longest any coordination call holds its response, whatever the request timeout: under the
@@ -4616,6 +4640,7 @@ async function bindCoordinationAddress(ctx, port, addressSignal) {
4616
4640
  state.paths.add(publicAddress.pathname);
4617
4641
  for (const path of state.paths) {
4618
4642
  state.readPaths.add(path.replace(/\/$/, "") + "/read");
4643
+ state.controlPaths.add(path.replace(/\/$/, "") + "/control");
4619
4644
  state.mailPaths.add(path.replace(/\/$/, "") + "/mail");
4620
4645
  }
4621
4646
  if (configured !== void 0) await preflightPublicCoordination({
@@ -4644,6 +4669,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
4644
4669
  identity,
4645
4670
  toolNames: opts.toolNames,
4646
4671
  scopeSignal: opts.scope.signal,
4672
+ lifetimeSignal: lifetime,
4647
4673
  isClosed: () => state.closed
4648
4674
  });
4649
4675
  const ctx = {
@@ -4716,6 +4742,14 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
4716
4742
  get headers() {
4717
4743
  return credentials.headers;
4718
4744
  },
4745
+ get control() {
4746
+ if (!opts.authentication) throw new ConfigError("coordination control access requires authentication");
4747
+ return {
4748
+ ...identity,
4749
+ url: url.replace(/\/$/, "") + "/control",
4750
+ headers: credentials.controllerHeaders
4751
+ };
4752
+ },
4719
4753
  get credentialExpiresAt() {
4720
4754
  return credentials.expiresAt;
4721
4755
  },
@@ -4743,6 +4777,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
4743
4777
  ...handle.readOnly,
4744
4778
  ...identity
4745
4779
  }), opts.scope.signal, "read capability publication aborted");
4780
+ await runAbortable(async () => opts.onControlReady?.(handle.control), opts.scope.signal, "control capability publication aborted");
4746
4781
  } catch (error) {
4747
4782
  await handle.close();
4748
4783
  throw error;
@@ -4752,8 +4787,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
4752
4787
  controls: coord
4753
4788
  };
4754
4789
  }
4755
- //#endregion
4756
- //#region src/runtime/supervise/supervisor-tool-binding.ts
4790
+ // src/runtime/supervise/supervisor-tool-binding.ts
4757
4791
  function createVerbSlot() {
4758
4792
  let bound;
4759
4793
  let waits;
@@ -4842,8 +4876,7 @@ function bindSupervisorNodeObserver(context, observeNodeEvent, onEvent) {
4842
4876
  await onEvent?.(event, record);
4843
4877
  };
4844
4878
  }
4845
- //#endregion
4846
- //#region src/runtime/supervise/worker-control-observer.ts
4879
+ // src/runtime/supervise/worker-control-observer.ts
4847
4880
  /** Observe durable worker controls while the native harness owns the manager's turn loop. */
4848
4881
  function observeWorkerControls(options) {
4849
4882
  const { dir, coord, scope, signal, controlScope, onError } = options;
@@ -4927,8 +4960,7 @@ function observeWorkerControls(options) {
4927
4960
  close: () => closing ??= finish()
4928
4961
  };
4929
4962
  }
4930
- //#endregion
4931
- //#region src/runtime/supervise/supervisor-manager-session.ts
4963
+ // src/runtime/supervise/supervisor-manager-session.ts
4932
4964
  /** Bind this act's node tools and serve its coordination server, then route the lead's messages. */
4933
4965
  async function openManagerSession(config, task, scope) {
4934
4966
  const { deps } = config;
@@ -5078,15 +5110,14 @@ function observeManagerControls(config, session) {
5078
5110
  }
5079
5111
  });
5080
5112
  }
5081
- //#endregion
5082
- //#region src/runtime/supervise/driver-retry-loop.ts
5113
+ // src/runtime/supervise/driver-retry-loop.ts
5083
5114
  const DEFAULT_MAX_CONSECUTIVE_FAILURES = 3;
5084
5115
  const DEFAULT_MAX_ATTEMPTS = Number.POSITIVE_INFINITY;
5085
5116
  const DEFAULT_INITIAL_BACKOFF_MS$1 = 2e3;
5086
5117
  const DEFAULT_MAX_BACKOFF_MS$1 = 3e4;
5087
5118
  const DEFAULT_TRANSIENT_OUTAGE_MS = 9e5;
5088
- const BARREN_PAUSE_FIRST_MS = 5 * 6e4;
5089
- const BARREN_PAUSE_MAX_MS = 60 * 6e4;
5119
+ const BARREN_PAUSE_FIRST_MS = 3e5;
5120
+ const BARREN_PAUSE_MAX_MS = 36e5;
5090
5121
  /** The stops an opted-in root pauses on (`DriverRetryRun.stopPause`). `completed`, `aborted` and a
5091
5122
  * declared `deadline` end the run; `supervise()` refuses `driverRetry.pauseRootStops` beside `retry-disabled`. */
5092
5123
  const PAUSED_STOPS = /* @__PURE__ */ new Set([
@@ -5116,7 +5147,7 @@ function barrenPauseMs(streak, maxBarren) {
5116
5147
  */
5117
5148
  const INSTANT_FAILURE_MS = 3e4;
5118
5149
  const REPEATED_FAILURE_LIMIT = 10;
5119
- const REPEATED_FAILURE_WINDOW_MS = 5 * 6e4;
5150
+ const REPEATED_FAILURE_WINDOW_MS = 3e5;
5120
5151
  /** Consecutive identical reconciliation failures of one pending invocation that resolve it. */
5121
5152
  const SAME_PENDING_LIMIT = 2;
5122
5153
  /**
@@ -5639,8 +5670,7 @@ var DriverRetryLoop = class {
5639
5670
  return true;
5640
5671
  }
5641
5672
  };
5642
- //#endregion
5643
- //#region src/runtime/supervise/driver-retry.ts
5673
+ // src/runtime/supervise/driver-retry.ts
5644
5674
  /**
5645
5675
  * Root-driver retry — the root gets the same second chance a worker's transport already has.
5646
5676
  *
@@ -5777,8 +5807,7 @@ async function runDriverWithRetry(run) {
5777
5807
  if (!await loop.afterCompletion(attempt, before, startedAt)) return;
5778
5808
  }
5779
5809
  }
5780
- //#endregion
5781
- //#region src/runtime/supervise/reentry.ts
5810
+ // src/runtime/supervise/reentry.ts
5782
5811
  /** Continuity when nothing is proven: compose the full state. */
5783
5812
  const UNPROVEN_CONTINUITY = Object.freeze({
5784
5813
  session: "new",
@@ -5899,8 +5928,7 @@ function taskText(task) {
5899
5928
  return String(task);
5900
5929
  }
5901
5930
  }
5902
- //#endregion
5903
- //#region src/runtime/supervise/run-traces.ts
5931
+ // src/runtime/supervise/run-traces.ts
5904
5932
  /**
5905
5933
  * A manager's own run as one trace store: what the continuation's question panel reads.
5906
5934
  *
@@ -6032,8 +6060,7 @@ async function runTraceAnalysisStore(input) {
6032
6060
  const spans = [...records === void 0 || input.root === void 0 ? [] : rootStreamToolSpans(records, input.root.id), ...(await Promise.all(input.workers.map((worker) => workerSpans(worker, input.blobs)))).flat()];
6033
6061
  return spans.length === 0 ? void 0 : toolSpansToTraceAnalysisStore(spans);
6034
6062
  }
6035
- //#endregion
6036
- //#region src/runtime/supervise/supervisor-manager-turns.ts
6063
+ // src/runtime/supervise/supervisor-manager-turns.ts
6037
6064
  /** The finalizer over this act's settled workers; the check it runs is recorded as a check read. */
6038
6065
  function managerFinalizer(deps, session) {
6039
6066
  const { mcp, controls } = session;
@@ -6454,8 +6481,7 @@ async function recordManagerAttempt(loop, record) {
6454
6481
  });
6455
6482
  await loop.config.deps.onDriverAttempt?.(record);
6456
6483
  }
6457
- //#endregion
6458
- //#region src/runtime/supervise/supervisor-external-manager.ts
6484
+ // src/runtime/supervise/supervisor-external-manager.ts
6459
6485
  /** EXTERNAL arm: a caller-driven harness uses the coordination verbs over the live scope. */
6460
6486
  function externalSupervisorAgent(build) {
6461
6487
  const { deps, name } = build;
@@ -6584,8 +6610,7 @@ async function settleManagerOutput(config, mcp, contractDeclared, finalize, cand
6584
6610
  }
6585
6611
  await mcp.finishAnalysis({ status: "done" });
6586
6612
  }
6587
- //#endregion
6588
- //#region src/runtime/supervise/supervisor-router-config.ts
6613
+ // src/runtime/supervise/supervisor-router-config.ts
6589
6614
  /** Validate a manager's coordination authentication and request limits before execution. */
6590
6615
  function assertCoordinationBinding(binding) {
6591
6616
  assertCoordinationTransport(binding ?? {});
@@ -6646,8 +6671,7 @@ function routerBrainFromProfile(profile, router) {
6646
6671
  ...profile.model?.reasoningEffort ? { reasoningEffort: profile.model.reasoningEffort } : {}
6647
6672
  });
6648
6673
  }
6649
- //#endregion
6650
- //#region src/runtime/supervise/supervisor-agent-build.ts
6674
+ // src/runtime/supervise/supervisor-agent-build.ts
6651
6675
  function buildSupervisorAgent(profile, deps, testBrain) {
6652
6676
  const exactProfile = agentProfileSchema.parse(profile);
6653
6677
  assertExecutableAgentProfile(exactProfile, "supervisorAgent");
@@ -6778,8 +6802,7 @@ function routerSupervisorAgent(arm) {
6778
6802
  }
6779
6803
  };
6780
6804
  }
6781
- //#endregion
6782
- //#region src/runtime/supervise/supervisor-agent.ts
6805
+ // src/runtime/supervise/supervisor-agent.ts
6783
6806
  /** Build a supervisor `Agent` from its profile: the brain resolves from `profile.harness`
6784
6807
  * (backend-as-data), the same resolution rule as every worker. */
6785
6808
  function supervisorAgent(profile, deps) {
@@ -6791,8 +6814,7 @@ function supervisorAgentWithTestBrain(profile, deps) {
6791
6814
  const { brain, ...runtimeDeps } = deps;
6792
6815
  return buildSupervisorAgent(profile, runtimeDeps, brain);
6793
6816
  }
6794
- //#endregion
6795
- //#region src/runtime/supervise/supervise-profile-admission.ts
6817
+ // src/runtime/supervise/supervise-profile-admission.ts
6796
6818
  /**
6797
6819
  * NOT a harness-name test — `ExecutorConfig.backend` is a discriminated-union TAG naming HOW a
6798
6820
  * profile is materialized (bridge / sandbox / cli-worktree / cli-in-place / router / cli /
@@ -6815,9 +6837,10 @@ function backendProfileMaterialization(backend) {
6815
6837
  }
6816
6838
  }
6817
6839
  function assertProfileContract(profile, contract, context, runtimeConsumesCoordinationTools = false) {
6840
+ const materializedProfile = runtimeConsumesCoordinationTools ? providerVisibleProfile(profile) : profile;
6818
6841
  assertProfileMaterialization({
6819
6842
  contract,
6820
- changedAxes: profileMaterializationAxes$1(runtimeConsumesCoordinationTools ? providerVisibleProfile(profile) : profile),
6843
+ changedAxes: profileMaterializationAxes$1(materializedProfile),
6821
6844
  context
6822
6845
  });
6823
6846
  }
@@ -6918,6 +6941,7 @@ const routerSupervisorProfileMaterialization = defineProfileMaterializationContr
6918
6941
  "version",
6919
6942
  "tags",
6920
6943
  "systemPrompt",
6944
+ "appendSystemPrompt",
6921
6945
  "instructions",
6922
6946
  "resourceInstructions",
6923
6947
  "resourceFailOnError",
@@ -6956,8 +6980,7 @@ function isExternalSupervisor(profile) {
6956
6980
  function automaticDriverBackendSupported(backend, coordination) {
6957
6981
  return backend.backend === "bridge" || backend.backend === "provider" && !backend.steering && coordination?.authentication !== void 0 && coordination.publicUrl !== void 0;
6958
6982
  }
6959
- //#endregion
6960
- //#region src/runtime/supervise/nested-manager-deps.ts
6983
+ // src/runtime/supervise/nested-manager-deps.ts
6961
6984
  /** Deps for the nested manager of a managed child: coordination wiring, policy and controls. */
6962
6985
  function buildNestedManagerDeps(child) {
6963
6986
  const { env, seat, admitted, spawnContext } = child;
@@ -7091,8 +7114,7 @@ function nestedLogAndControlDeps(child) {
7091
7114
  ...options.runDir === void 0 && options.steerDir === void 0 ? {} : { controlScope: "subtree" }
7092
7115
  };
7093
7116
  }
7094
- //#endregion
7095
- //#region src/runtime/supervise/supervise-runtime-attachments.ts
7117
+ // src/runtime/supervise/supervise-runtime-attachments.ts
7096
7118
  /**
7097
7119
  * The reserved MCP alias one worker's PEER MAIL capability endpoint mounts under.
7098
7120
  *
@@ -7168,8 +7190,7 @@ async function providerAcceptsCoordinationAttachments(backend) {
7168
7190
  * its credential. A value the caller set wins.
7169
7191
  */
7170
7192
  const CLAUDE_CODE_ONE_HOUR_CACHE = "ENABLE_PROMPT_CACHING_1H";
7171
- //#endregion
7172
- //#region src/runtime/supervise/supervise-worker-backend.ts
7193
+ // src/runtime/supervise/supervise-worker-backend.ts
7173
7194
  /**
7174
7195
  * Build the worker seam from a backend (WHERE workers run) + an optional completion oracle (the
7175
7196
  * deliverable check that makes "settled ⟺ delivered" true — the guard against "ran but didn't
@@ -7215,7 +7236,7 @@ function workerFromBackend(backend, deliverable, seams) {
7215
7236
  const boundSessionId = boundBackend.backend === "bridge" ? boundBackend.sessionId : void 0;
7216
7237
  const peerMailAttachment = peerMailRuntimeAttachment(profile, capturedBackend, spawnContext);
7217
7238
  if (spawnContext?.peerMailUrl && boundBackend.backend === "provider" && Object.hasOwn(boundBackend.defaults?.runtimeAttachments?.mcp ?? {}, "agent-runtime-peer-mail")) throw new ValidationError("workerFromBackend: provider defaults contain the reserved peer-mail attachment alias");
7218
- const rawFactory = createExecutor(spawnContext?.peerMailUrl && boundBackend.backend === "provider" ? {
7239
+ const leafBackend = spawnContext?.peerMailUrl && boundBackend.backend === "provider" ? {
7219
7240
  ...boundBackend,
7220
7241
  steering: boundBackend.steering ?? {},
7221
7242
  defaults: {
@@ -7231,7 +7252,8 @@ function workerFromBackend(backend, deliverable, seams) {
7231
7252
  }
7232
7253
  }
7233
7254
  }
7234
- } : boundBackend);
7255
+ } : boundBackend;
7256
+ const rawFactory = createExecutor(leafBackend);
7235
7257
  const baseFactory = deliverable ? gateFactoryOnDeliverable(rawFactory, deliverable) : rawFactory;
7236
7258
  const executorFactory = (spec, ctx) => {
7237
7259
  if (boundSessionId !== void 0 && ctx.node?.nodeId !== void 0) bridgeSessionByWorker.set(ctx.node.nodeId, boundSessionId);
@@ -7317,8 +7339,7 @@ function withModelSubstitution(agent, substitution) {
7317
7339
  }
7318
7340
  };
7319
7341
  }
7320
- //#endregion
7321
- //#region src/runtime/supervise/spawn-admission.ts
7342
+ // src/runtime/supervise/spawn-admission.ts
7322
7343
  /** Authorize one spawn and decide everything about it that does not depend on how it runs. */
7323
7344
  function admitSpawn(env, seat, authoredProfile, spawnContext, recovering) {
7324
7345
  const { options, applyTraceTools, deliverable } = env.setup;
@@ -7370,7 +7391,10 @@ function admitSpawn(env, seat, authoredProfile, spawnContext, recovering) {
7370
7391
  depth
7371
7392
  });
7372
7393
  const security = validateAgentProfileSecurity(authorized, env.securityPolicy);
7373
- if (!security.ok) throw new ValidationError(`supervise: spawned AgentProfile refused: ${security.issues.filter((issue) => issue.level === "error").map((issue) => `${issue.code}${issue.path ? ` at ${issue.path}` : ""}`).join(", ")}`);
7394
+ if (!security.ok) {
7395
+ const details = security.issues.filter((issue) => issue.level === "error").map((issue) => `${issue.code}${issue.path ? ` at ${issue.path}` : ""}`).join(", ");
7396
+ throw new ValidationError(`supervise: spawned AgentProfile refused: ${details}`);
7397
+ }
7374
7398
  assertProfileModelsAllowed(authorized, options.allowedModels);
7375
7399
  const selectedDeliverable = options.resolveDeliverable?.(postAuthorizationContext);
7376
7400
  const childDeliverable = selectedDeliverable === void 0 ? deliverable : selectedDeliverable === null ? void 0 : captureDeliverable(selectedDeliverable, `supervise deliverable for ${JSON.stringify(spawnContext.label)}`);
@@ -7386,8 +7410,228 @@ function admitSpawn(env, seat, authoredProfile, spawnContext, recovering) {
7386
7410
  usesRuntimeCoordination: declaredRuntimeToolNames(authorized).length > 0 || seatManagedLeaf
7387
7411
  };
7388
7412
  }
7389
- //#endregion
7390
- //#region src/runtime/supervise/graph-registry.ts
7413
+ // src/runtime/supervise/graph-file-schema.ts
7414
+ const scalar = z.union([
7415
+ z.string(),
7416
+ z.number().finite(),
7417
+ z.boolean(),
7418
+ z.null()
7419
+ ]);
7420
+ const pointer = z.string().regex(/^(?:\/(?:[^~]|~[01])*)*$/);
7421
+ const matchBase = {
7422
+ node: z.string().min(1).optional(),
7423
+ pointer
7424
+ };
7425
+ const equals = z.strictObject({
7426
+ ...matchBase,
7427
+ equals: scalar
7428
+ });
7429
+ const oneOf = z.strictObject({
7430
+ ...matchBase,
7431
+ in: z.array(scalar)
7432
+ });
7433
+ const exists = z.strictObject({
7434
+ ...matchBase,
7435
+ exists: z.boolean()
7436
+ });
7437
+ const match = z.union([
7438
+ equals,
7439
+ oneOf,
7440
+ exists
7441
+ ]);
7442
+ /** The same data grammar as routes; no executable expressions or additional operators. */
7443
+ const graphRouteWhenSchema = z.union([match, z.strictObject({ all: z.array(match).min(1) })]);
7444
+ const parameter = z.strictObject({
7445
+ default: z.unknown().optional(),
7446
+ type: z.enum([
7447
+ "string",
7448
+ "number",
7449
+ "integer",
7450
+ "boolean",
7451
+ "object",
7452
+ "array",
7453
+ "null"
7454
+ ]).optional()
7455
+ });
7456
+ const command = z.strictObject({
7457
+ command: z.string().min(1),
7458
+ timeoutMs: z.number().int().positive().optional()
7459
+ });
7460
+ const nonnegativeInteger = z.number().int().nonnegative();
7461
+ /** Authoring envelope. Canonical profiles and topology are validated by their existing owners. */
7462
+ const graphFileSchema = z.strictObject({
7463
+ digest: z.string().min(1).optional(),
7464
+ graph: z.string().min(1).optional(),
7465
+ describe: z.string().optional(),
7466
+ params: z.record(z.string().min(1), parameter).optional(),
7467
+ nodes: z.array(z.strictObject({
7468
+ id: z.string().min(1),
7469
+ profile: z.record(z.string(), z.unknown()).optional(),
7470
+ seat: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]).optional(),
7471
+ needs: z.array(z.string().min(1)).optional()
7472
+ })).min(1),
7473
+ entry: z.array(z.union([z.string().min(1), z.strictObject({
7474
+ node: z.string().min(1),
7475
+ task: z.unknown()
7476
+ })])).min(1).optional(),
7477
+ edges: z.array(z.record(z.string(), z.unknown())),
7478
+ gates: z.array(z.unknown()).optional(),
7479
+ budget: z.strictObject({
7480
+ maxIterations: nonnegativeInteger,
7481
+ maxTokens: nonnegativeInteger,
7482
+ maxUsd: z.number().finite().nonnegative().optional(),
7483
+ deadlineMs: nonnegativeInteger.optional(),
7484
+ resources: z.record(z.string(), z.strictObject({
7485
+ unit: z.string().min(1),
7486
+ limit: nonnegativeInteger
7487
+ })).optional()
7488
+ }),
7489
+ check: z.union([
7490
+ equals.extend({ describe: z.string().optional() }),
7491
+ oneOf.extend({ describe: z.string().optional() }),
7492
+ exists.extend({ describe: z.string().optional() }),
7493
+ z.strictObject({
7494
+ describe: z.string().optional(),
7495
+ all: z.array(match).min(1)
7496
+ }),
7497
+ z.strictObject({
7498
+ describe: z.string().optional(),
7499
+ command
7500
+ })
7501
+ ]).optional(),
7502
+ deliverable: z.strictObject({
7503
+ describe: z.string().optional(),
7504
+ checkRef: z.string().min(1),
7505
+ command: command.optional(),
7506
+ when: graphRouteWhenSchema.optional()
7507
+ }).optional(),
7508
+ on: z.unknown().optional()
7509
+ });
7510
+ /** Judge the flow's terminal-output map with RouteWhen's own JSON-pointer semantics. */
7511
+ function checkGraphRoute(when, output) {
7512
+ return ("all" in when ? when.all : [when]).every((condition) => {
7513
+ let document = output;
7514
+ if (condition.node !== void 0) {
7515
+ if (!output || typeof output !== "object" || !Object.hasOwn(output, condition.node)) return false;
7516
+ document = output[condition.node];
7517
+ }
7518
+ const selected = resolveJsonPointer(document, condition.pointer);
7519
+ if ("exists" in condition) return selected.found === condition.exists;
7520
+ if (!selected.found) return false;
7521
+ return "equals" in condition ? selected.value === condition.equals : condition.in.some((value) => value === selected.value);
7522
+ });
7523
+ }
7524
+ // src/runtime/supervise/graph-parameters.ts
7525
+ const triggerPart = z.strictObject({ trigger: z.array(z.string()).min(1) });
7526
+ const literalPart = z.strictObject({ literal: z.string() });
7527
+ /** Explicit authored trigger slots in compiled graph data. An empty list marks fully bound data. */
7528
+ const graphTriggerBindingsSchema = z.array(z.strictObject({
7529
+ path: z.array(z.union([z.string(), z.number().int().nonnegative()])).min(1),
7530
+ mode: z.enum(["value", "text"]),
7531
+ parts: z.array(z.union([literalPart, triggerPart])).min(1)
7532
+ }).superRefine((slot, context) => {
7533
+ if (!slot.parts.some((part) => "trigger" in part) || slot.mode === "value" && (slot.parts.length !== 1 || !("trigger" in slot.parts[0]))) context.addIssue({
7534
+ code: "custom",
7535
+ message: "binding requires authored trigger parts; value slots require one trigger"
7536
+ });
7537
+ }));
7538
+ function readBinding(namespace, keys, bindings) {
7539
+ let found = bindings[namespace];
7540
+ for (const key of keys) {
7541
+ if (!found || typeof found !== "object" || !Object.hasOwn(found, key)) throw new ValidationError(`graph parameters: missing ${[namespace, ...keys].join(".")}`);
7542
+ found = found[key];
7543
+ }
7544
+ if (found === void 0) throw new ValidationError(`graph parameters: missing ${[namespace, ...keys].join(".")}`);
7545
+ return structuredClone(found);
7546
+ }
7547
+ function textValue(value, expression) {
7548
+ if (value !== null && typeof value === "object") throw new ValidationError(`graph parameters: ${expression} needs a whole JSON slot`);
7549
+ return String(value);
7550
+ }
7551
+ function pendingText(parts) {
7552
+ return parts.map((part) => "literal" in part ? part.literal : `\${trigger.${part.trigger.join(".")}}`).join("");
7553
+ }
7554
+ /** Compile authored slots once. Inserted values are data, never recursively parsed templates. */
7555
+ function compileGraphParameters(value, bindings, options = {}) {
7556
+ const visiting = /* @__PURE__ */ new Set();
7557
+ const triggerBindings = [];
7558
+ const bind = (item, path) => {
7559
+ if (typeof item === "string") {
7560
+ if (item.replace(/\$\{[^{}]+\}/g, "").includes("${")) throw new ValidationError("graph parameters: malformed reference");
7561
+ const whole = /^\$\{([^{}]+)\}$/.exec(item);
7562
+ const parts = [];
7563
+ let cursor = 0;
7564
+ let wholeValue;
7565
+ let boundWhole = false;
7566
+ for (const match of item.matchAll(/\$\{([^{}]+)\}/g)) {
7567
+ if (match.index > cursor) parts.push({ literal: item.slice(cursor, match.index) });
7568
+ const [namespace, ...keys] = match[1].split(".");
7569
+ if (namespace !== "params" && namespace !== "trigger" || keys.length === 0) throw new ValidationError(`graph parameters: unsupported reference \${${match[1]}}`);
7570
+ if (options.defer?.includes(namespace)) {
7571
+ if (namespace === "trigger") parts.push({ trigger: keys });
7572
+ else parts.push({ literal: match[0] });
7573
+ } else {
7574
+ const found = readBinding(namespace, keys, bindings);
7575
+ if (whole) {
7576
+ wholeValue = found;
7577
+ boundWhole = true;
7578
+ } else parts.push({ literal: textValue(found, match[1]) });
7579
+ }
7580
+ cursor = match.index + match[0].length;
7581
+ }
7582
+ if (boundWhole) return wholeValue;
7583
+ if (cursor === 0) return item;
7584
+ if (cursor < item.length) parts.push({ literal: item.slice(cursor) });
7585
+ if (parts.some((part) => "trigger" in part)) triggerBindings.push({
7586
+ path,
7587
+ mode: whole ? "value" : "text",
7588
+ parts
7589
+ });
7590
+ return pendingText(parts);
7591
+ }
7592
+ if (!item || typeof item !== "object") return item;
7593
+ if (visiting.has(item)) throw new ValidationError("graph parameters: cyclic data is not JSON");
7594
+ visiting.add(item);
7595
+ const bound = Array.isArray(item) ? item.map((child, index) => bind(child, [...path, index])) : Object.fromEntries(Object.entries(item).map(([key, child]) => [key, bind(child, [...path, key])]));
7596
+ visiting.delete(item);
7597
+ return bound;
7598
+ };
7599
+ return {
7600
+ value: bind(value, []),
7601
+ triggerBindings
7602
+ };
7603
+ }
7604
+ /** Legacy authored-data binding. Compiled graphs use bindCompiledGraphTriggers instead. */
7605
+ function bindGraphParameters(value, bindings, options = {}) {
7606
+ return compileGraphParameters(value, bindings, options).value;
7607
+ }
7608
+ /** Check provenance against the exact provisional values without reading trigger data. */
7609
+ function assertGraphTriggerBindings(value, slots) {
7610
+ const seen = /* @__PURE__ */ new Set();
7611
+ for (const slot of graphTriggerBindingsSchema.parse(slots)) {
7612
+ const key = JSON.stringify(slot.path.map(String));
7613
+ if (seen.has(key)) throw new ValidationError("graph parameters: duplicate trigger binding path");
7614
+ seen.add(key);
7615
+ let found = value;
7616
+ for (const key of slot.path) {
7617
+ if (!found || typeof found !== "object" || !Object.hasOwn(found, key)) throw new ValidationError("graph parameters: trigger binding path does not exist");
7618
+ found = found[key];
7619
+ }
7620
+ if (found !== pendingText(slot.parts)) throw new ValidationError("graph parameters: trigger binding does not match its provisional value");
7621
+ }
7622
+ }
7623
+ /** Only explicitly recorded authored slots bind. Literal parameter/trigger values are untouched. */
7624
+ function bindCompiledGraphTriggers(value, slots, trigger) {
7625
+ assertGraphTriggerBindings(value, slots);
7626
+ const bound = structuredClone(value);
7627
+ for (const slot of slots) {
7628
+ let parent = bound;
7629
+ for (const key of slot.path.slice(0, -1)) parent = parent[key];
7630
+ parent[slot.path.at(-1)] = slot.mode === "value" ? readBinding("trigger", slot.parts[0].trigger, { trigger }) : slot.parts.map((part) => "literal" in part ? part.literal : textValue(readBinding("trigger", part.trigger, { trigger }), `trigger.${part.trigger.join(".")}`)).join("");
7631
+ }
7632
+ return bound;
7633
+ }
7634
+ // src/runtime/supervise/graph-registry.ts
7391
7635
  /**
7392
7636
  * `graph-registry` — the designer's memory: graphs and their outcomes as files.
7393
7637
  *
@@ -7453,11 +7697,18 @@ function digestOfGraph(graph) {
7453
7697
  return storeGraph(graph).digest;
7454
7698
  }
7455
7699
  function storeGraph(graph) {
7700
+ const { describe, checkRef, command, when } = graph.deliverable;
7456
7701
  const content = {
7457
7702
  nodes: graph.nodes,
7458
7703
  edges: graph.edges,
7459
7704
  budget: graph.budget,
7460
- deliverable: { ...graph.deliverable.describe ? { describe: graph.deliverable.describe } : {} },
7705
+ ...graph.triggerBindings === void 0 ? {} : { triggerBindings: graph.triggerBindings },
7706
+ deliverable: {
7707
+ ...describe ? { describe } : {},
7708
+ ...checkRef ? { checkRef } : {},
7709
+ ...command ? { command } : {},
7710
+ ...when ? { when } : {}
7711
+ },
7461
7712
  ...graph.entry === void 0 ? {} : { entry: graph.entry },
7462
7713
  ...graph.gates === void 0 ? {} : { gates: graph.gates }
7463
7714
  };
@@ -7511,16 +7762,28 @@ async function recordGraphRun(reg, graph, record) {
7511
7762
  * Imported observations retain their source identity and never authorize replay.
7512
7763
  * A reader refreshing facts can preserve independently joined labels; an explicit
7513
7764
  * correction leaves preserveLabels unset and replaces the record. */
7514
- async function recordStoredGraphRun(reg, stored, record, options = {}) {
7515
- assertRecord(record);
7516
- if (stored.observed && !record.source) throw new ValidationError("graph-registry: observed graphs require a source run identity");
7517
- if (!stored.observed && !record.finishedAt) throw new ValidationError("graph-registry: native graph runs require a completion timestamp");
7518
- if ((!stored.observed || record.traversals !== void 0) && (!Number.isSafeInteger(record.traversals) || record.traversals < 0)) throw new ValidationError("graph-registry: native graphs require metered traversals; observed counts must be non-negative integers");
7519
- const { digest, ...content } = stored;
7520
- if (graphDigest(content) !== digest) throw new ValidationError("graph-registry: stored graph content does not match its digest");
7521
- if (stored.digest !== record.graphDigest) throw new ValidationError(`graph-registry: record.graphDigest ${record.graphDigest} does not match the supplied graph (${stored.digest}) — record the graph that actually ran`);
7765
+ async function recordStoredGraphRun(reg, definition, record, options = {}) {
7766
+ const { digest, ...content } = definition;
7767
+ const stored = {
7768
+ ...content,
7769
+ digest: digest ?? graphDigest(content)
7770
+ };
7771
+ if (stored.observed && !record) throw new ValidationError("graph-registry: observed graphs require a source run identity");
7772
+ if (record) {
7773
+ assertRecord(record);
7774
+ if (stored.observed && !record.source) throw new ValidationError("graph-registry: observed graphs require a source run identity");
7775
+ if (!stored.observed && !record.finishedAt) throw new ValidationError("graph-registry: native graph runs require a completion timestamp");
7776
+ if ((!stored.observed || record.traversals !== void 0) && (!Number.isSafeInteger(record.traversals) || record.traversals < 0)) throw new ValidationError("graph-registry: native graphs require metered traversals; observed counts must be non-negative integers");
7777
+ if (stored.digest !== record.graphDigest) throw new ValidationError(`graph-registry: record.graphDigest ${record.graphDigest} does not match the supplied graph (${stored.digest}) — record the graph that actually ran`);
7778
+ }
7779
+ if (graphDigest(content) !== stored.digest) throw new ValidationError("graph-registry: stored graph content does not match its digest");
7522
7780
  await mkdir(join(reg.root, GRAPHS_DIR), { recursive: true });
7523
- return withJsonlFileLock(join(reg.root, RECORDS_FILE), async (canonicalPath) => {
7781
+ const file = join(reg.root, RECORDS_FILE);
7782
+ return withJsonlFileLock(file, async (canonicalPath) => {
7783
+ if (!record) {
7784
+ await persistGraph(reg, stored);
7785
+ return stored;
7786
+ }
7524
7787
  let persisted = record;
7525
7788
  if (options.preserveLabels && record.source) {
7526
7789
  const prior = (await readCommittedJsonFile(canonicalPath)).find((row) => row.source?.kind === record.source.kind && row.source.id === record.source.id);
@@ -7548,18 +7811,21 @@ async function recordStoredGraphRun(reg, stored, record, options = {}) {
7548
7811
  }
7549
7812
  }
7550
7813
  assertRecord(persisted);
7551
- const revisionPath = join(reg.root, GRAPHS_DIR, `${stored.digest}.json`);
7552
- try {
7553
- const { digest: existingDigest, ...existing } = JSON.parse(await readFile(revisionPath, "utf8"));
7554
- if (existingDigest !== stored.digest || graphDigest(existing) !== stored.digest) throw new ValidationError("graph-registry: stored graph revision is immutable but its content differs");
7555
- } catch (error) {
7556
- if (!isNoEntError(error)) throw error;
7557
- writeAtomicDurableFile(revisionPath, JSON.stringify(stored), { preserveMode: true });
7558
- }
7814
+ await persistGraph(reg, stored);
7559
7815
  await upsertCommittedJsonLine(canonicalPath, persisted, recordKey);
7560
7816
  return stored;
7561
7817
  });
7562
7818
  }
7819
+ async function persistGraph(reg, stored) {
7820
+ const revisionPath = join(reg.root, GRAPHS_DIR, `${stored.digest}.json`);
7821
+ try {
7822
+ const { digest: existingDigest, ...existing } = JSON.parse(await readFile(revisionPath, "utf8"));
7823
+ if (existingDigest !== stored.digest || graphDigest(existing) !== stored.digest) throw new ValidationError("graph-registry: stored graph revision is immutable but its content differs");
7824
+ } catch (error) {
7825
+ if (!isNoEntError(error)) throw error;
7826
+ writeAtomicDurableFile(revisionPath, JSON.stringify(stored), { preserveMode: true });
7827
+ }
7828
+ }
7563
7829
  /** All records, newest last. */
7564
7830
  async function listGraphRuns(reg) {
7565
7831
  return readCommittedJsonFile(join(reg.root, RECORDS_FILE));
@@ -7698,20 +7964,33 @@ async function lookupGraph(reg, taskDigest) {
7698
7964
  reason: records.length === 0 ? "first run for this task shape" : "no graph delivered for this task shape yet"
7699
7965
  };
7700
7966
  }
7701
- /** Rehydrate a stored graph into a runnable one. The check comes from the
7702
- * CALLER's environment (oracles are environment, never stored). */
7703
- function graphFromStored(stored, check) {
7967
+ /** Rehydrate a stored graph, binding trigger data and an environment-owned named check. */
7968
+ function graphFromStored(stored, environment = {}) {
7704
7969
  if (stored.observed) throw new ValidationError("graphFromStored: observed topology cannot be replayed");
7970
+ const { digest: _digest, observed: _observed, triggerBindings: _triggerBindings, deliverable, ...topology } = stored.triggerBindings !== void 0 ? bindCompiledGraphTriggers(stored, stored.triggerBindings, typeof environment === "function" ? void 0 : environment.trigger ?? {}) : typeof environment === "function" ? stored : bindGraphParameters(stored, { trigger: environment.trigger ?? {} });
7971
+ const selected = typeof environment === "function" ? environment : environment.checks && Object.hasOwn(environment.checks, deliverable.checkRef ?? "") ? environment.checks[deliverable.checkRef] : deliverable.checkRef === "command" ? deliverable.command : deliverable.checkRef === "route" && deliverable.when ? ((out, context) => context ? context.originalVerdict?.valid !== false : checkGraphRoute(deliverable.when, out)) : void 0;
7972
+ if (!selected) throw new ValidationError(`graphFromStored: unknown checkRef ${deliverable.checkRef ?? "(missing)"}`);
7973
+ const materialized = stored.triggerBindings === void 0 ? {} : { triggerBindings: [] };
7974
+ if (typeof selected === "function") {
7975
+ const { command: _command, ...description } = deliverable;
7976
+ return {
7977
+ ...topology,
7978
+ ...materialized,
7979
+ deliverable: {
7980
+ ...description,
7981
+ check: selected
7982
+ }
7983
+ };
7984
+ }
7985
+ const command = selected === deliverable.command ? selected : bindGraphParameters(selected, { trigger: environment.trigger ?? {} });
7705
7986
  return {
7706
- nodes: stored.nodes,
7707
- edges: stored.edges,
7708
- budget: stored.budget,
7987
+ ...topology,
7988
+ ...materialized,
7709
7989
  deliverable: {
7710
- check,
7711
- ...stored.deliverable.describe ? { describe: stored.deliverable.describe } : {}
7712
- },
7713
- ...stored.entry === void 0 ? {} : { entry: stored.entry },
7714
- ...stored.gates === void 0 ? {} : { gates: stored.gates }
7990
+ ...deliverable,
7991
+ command,
7992
+ check: () => false
7993
+ }
7715
7994
  };
7716
7995
  }
7717
7996
  /** Digests present on disk (integrity probe for tests and audits). */
@@ -7722,8 +8001,7 @@ async function storedGraphDigests(reg) {
7722
8001
  return [];
7723
8002
  }
7724
8003
  }
7725
- //#endregion
7726
- //#region src/runtime/supervise/supervise-graph-subtasks.ts
8004
+ // src/runtime/supervise/supervise-graph-subtasks.ts
7727
8005
  /** A stored graph's topology, from the registry `SuperviseOptions.graphRegistry` names. */
7728
8006
  async function storedGraphTopology(dir, digest) {
7729
8007
  if (dir === void 0) throw new ValidationError("run_graph: this run names no graph registry (SuperviseOptions.graphRegistry), so a graphDigest cannot resolve; pass the graph as data");
@@ -7755,8 +8033,7 @@ async function graphSubtaskOutput(overlay, out, flowFailure) {
7755
8033
  ...exhaustedEdges.length === 0 ? {} : { exhaustedEdges }
7756
8034
  };
7757
8035
  }
7758
- //#endregion
7759
- //#region src/runtime/supervise/recursive-worker-factory.ts
8036
+ // src/runtime/supervise/recursive-worker-factory.ts
7760
8037
  /** The factory that spawns the children of one parent seat, leaf or managed. */
7761
8038
  function recursiveWorkerFactoryFor(env, seat) {
7762
8039
  const makeRecursiveWorker = (authoredProfile, spawnContext, recovering = false) => {
@@ -7810,7 +8087,7 @@ function managedWorker(env, seat, admitted, spawnContext) {
7810
8087
  unassessedOutput: false
7811
8088
  };
7812
8089
  const deps = buildNestedManagerDeps(child);
7813
- return withModelSubstitution(driverChild(authorized, ownFlow === void 0 ? supervisorAgent(authorized, deps) : supervisorAgentWithTestBrain(authorized, {
8090
+ const nested = ownFlow === void 0 ? supervisorAgent(authorized, deps) : supervisorAgentWithTestBrain(authorized, {
7814
8091
  ...deps,
7815
8092
  brain: runtimeFlowBrain(),
7816
8093
  routeFlow: ownFlow.route,
@@ -7819,7 +8096,8 @@ function managedWorker(env, seat, admitted, spawnContext) {
7819
8096
  debounceMs: 0,
7820
8097
  ...options.wake
7821
8098
  }
7822
- }), journal, childExecution.ref, () => child.acceptedSubmission, env.recoveryFactories.get(child.childFactory), () => child.unassessedOutput, admitted.seatManagedLeaf ? child.managerDeliverable : void 0, ownGraph ? (out) => graphSubtaskOutput(ownGraph, out, ownFlow?.run.failure) : void 0), admitted.modelSubstitution);
8099
+ });
8100
+ return withModelSubstitution(driverChild(authorized, nested, journal, childExecution.ref, () => child.acceptedSubmission, env.recoveryFactories.get(child.childFactory), () => child.unassessedOutput, admitted.seatManagedLeaf ? child.managerDeliverable : void 0, ownGraph ? (out) => graphSubtaskOutput(ownGraph, out, ownFlow?.run.failure) : void 0), admitted.modelSubstitution);
7823
8101
  }
7824
8102
  /**
7825
8103
  * The root of a `run_graph` subtask carries its graph's topology, and its subtree runs under that
@@ -7889,8 +8167,7 @@ function registerRecovery(env, makeRecursiveWorker) {
7889
8167
  });
7890
8168
  env.recoveryFactories.set(makeRecursiveWorker, factory);
7891
8169
  }
7892
- //#endregion
7893
- //#region src/runtime/supervise/worker-retry.ts
8170
+ // src/runtime/supervise/worker-retry.ts
7894
8171
  /**
7895
8172
  * WORKER-SPAWN RETRY — the second chance `driverRetry` gives the root, given to a leaf.
7896
8173
  *
@@ -8116,8 +8393,7 @@ function defaultSleep(ms, signal) {
8116
8393
  if (ms <= 0 || signal?.aborted) return Promise.resolve();
8117
8394
  return sleep(ms, signal);
8118
8395
  }
8119
- //#endregion
8120
- //#region src/runtime/supervise/supervise-recursive-workers.ts
8396
+ // src/runtime/supervise/supervise-recursive-workers.ts
8121
8397
  function createSuperviseWorkers(setup, cancelDurableRun) {
8122
8398
  const { options, canonicalProfile, rootExecution, guidanceComposer, deliverable, analysts, journal, runId, rootOwnerId, now } = setup;
8123
8399
  const recoveryFactories = /* @__PURE__ */ new WeakMap();
@@ -8192,8 +8468,7 @@ function createSuperviseWorkers(setup, cancelDurableRun) {
8192
8468
  graphOverlays
8193
8469
  };
8194
8470
  }
8195
- //#endregion
8196
- //#region src/runtime/supervise/supervise-registry.ts
8471
+ // src/runtime/supervise/supervise-registry.ts
8197
8472
  /** Resolve one option that may be given as a value OR as a name into `opts.registry`. Both failure
8198
8473
  * modes name the option, the requested name, and the table it was looked up in — a typo must not
8199
8474
  * degrade into a silently unconfigured run (which for `deliverable` means "no run can ever
@@ -8251,8 +8526,7 @@ async function verifyProfilePromotions(table) {
8251
8526
  const { verifySealedExperiment } = await import("@tangle-network/agent-eval/experiment");
8252
8527
  for (const [name, entry] of promoted) if (!await verifySealedExperiment(entry.promotion.experiment)) throw new ValidationError(`supervise: opts.registry.profiles ${JSON.stringify(name)} cites a sealed play whose digest does not match its spec`);
8253
8528
  }
8254
- //#endregion
8255
- //#region src/runtime/supervise/supervise-root-evidence.ts
8529
+ // src/runtime/supervise/supervise-root-evidence.ts
8256
8530
  /**
8257
8531
  * Record what a run-scoped cancel actually did, at the ONE place that observes the run's terminal
8258
8532
  * state: the `supervise()` settle path.
@@ -8326,8 +8600,7 @@ function rootProviderModelEvidence(observations) {
8326
8600
  function rootProviderModelEvidenceFromExecution(evidence) {
8327
8601
  return evidence ?? rootProviderModelEvidence([]);
8328
8602
  }
8329
- //#endregion
8330
- //#region src/runtime/supervise/supervise-root-profile.ts
8603
+ // src/runtime/supervise/supervise-root-profile.ts
8331
8604
  /**
8332
8605
  * The composer `profileGuidance` selects, or `undefined` when no guidance is selected. The result
8333
8606
  * is re-validated as an AgentProfile, and a composition that breaks the schema is refused as a
@@ -8408,8 +8681,7 @@ function rootSpawnResourceRoot(backend) {
8408
8681
  }
8409
8682
  return isLoopbackHost(host) ? resolve(backend.cwd) : void 0;
8410
8683
  }
8411
- //#endregion
8412
- //#region src/runtime/supervise/driver-execution-attempt.ts
8684
+ // src/runtime/supervise/driver-execution-attempt.ts
8413
8685
  /** The failure a terminal artifact reports, as the error a failed harness turn raises. */
8414
8686
  function harnessTurnFailure(runtime, artifact) {
8415
8687
  const reported = executorFailure(artifact);
@@ -8740,8 +9012,7 @@ var DriverExecutionAttempt = class {
8740
9012
  });
8741
9013
  }
8742
9014
  };
8743
- //#endregion
8744
- //#region src/runtime/supervise/manager-drive-session.ts
9015
+ // src/runtime/supervise/manager-drive-session.ts
8745
9016
  /** The profile the provider sees for `profile`, run on `seat` when one is active. */
8746
9017
  function seatProviderProfile(profile, seat) {
8747
9018
  return providerVisibleProfile(seat ? seatExecutionProfile(profile, seat.stage) : profile);
@@ -8902,20 +9173,19 @@ var ManagerDriveSession = class {
8902
9173
  at: new Date(now()).toISOString()
8903
9174
  });
8904
9175
  await seatSelection.onPause(scope.view.root, error.resumeAt, "paused");
8905
- await sleepScopeWait(scope, Math.max(1e3, Date.parse(error.resumeAt) - now()), scope.signal, "seat-wait");
9176
+ const waitMs = Math.max(1e3, Date.parse(error.resumeAt) - now());
9177
+ await sleepScopeWait(scope, waitMs, scope.signal, "seat-wait");
8906
9178
  afterRecheck = true;
8907
9179
  }
8908
9180
  }
8909
9181
  };
8910
- //#endregion
8911
- //#region src/mcp/tools/coordination-request-context.ts
9182
+ // src/mcp/tools/coordination-request-context.ts
8912
9183
  /** The tool-call timeout Runtime asks harnesses to give its coordination server. The Tangle
8913
9184
  * profile materializer writes it as `MCP_TOOL_TIMEOUT` (Claude Code) and `tool_timeout_sec`
8914
9185
  * (Codex) when an attachment declares `metadata.toolTimeoutMs`, so a fenced coordination call
8915
9186
  * that holds its response for its whole fence is never cut off at the 60 s harness default. */
8916
9187
  const COORDINATION_CLIENT_TOOL_TIMEOUT_MS = 3e5;
8917
- //#endregion
8918
- //#region src/runtime/supervise/supervise-driver-attempt.ts
9188
+ // src/runtime/supervise/supervise-driver-attempt.ts
8919
9189
  async function executeDriverAttempt(input) {
8920
9190
  const { state, scope, retainedOwner, turnCap } = input;
8921
9191
  if (!(scope.view.inFlight > 0)) assertDriverBudgetOpen(scope, input.now);
@@ -9070,8 +9340,7 @@ async function providerAttemptFactory(input, providerHarness) {
9070
9340
  }
9071
9341
  });
9072
9342
  }
9073
- //#endregion
9074
- //#region src/runtime/supervise/supervise-driver-session.ts
9343
+ // src/runtime/supervise/supervise-driver-session.ts
9075
9344
  /** Run a harness-brained manager through the same executor factory as its children. The manager's
9076
9345
  * full profile is preserved, the live coordination server is added under one reserved alias, and
9077
9346
  * every streamed turn is charged to the manager's scope before it may continue. */
@@ -9229,8 +9498,7 @@ async function reentryContinuity(backend, scope, retainedOwner) {
9229
9498
  }
9230
9499
  return UNPROVEN_CONTINUITY;
9231
9500
  }
9232
- //#endregion
9233
- //#region src/runtime/supervise/supervise-manager-harness.ts
9501
+ // src/runtime/supervise/supervise-manager-harness.ts
9234
9502
  /**
9235
9503
  * Resolve the harness that drives each manager owner: the caller's resolver or harness, claimed
9236
9504
  * per owner so one steerable harness never serves two managers, or one built from the backend.
@@ -9301,8 +9569,7 @@ function driveHarnessClaims() {
9301
9569
  return harness;
9302
9570
  };
9303
9571
  }
9304
- //#endregion
9305
- //#region src/runtime/supervise/supervise-spawn-preflight.ts
9572
+ // src/runtime/supervise/supervise-spawn-preflight.ts
9306
9573
  /**
9307
9574
  * The pre-flight `supervise` installs for a bridge backend. No new knob: the backend already says
9308
9575
  * where the bridge is, and these are the questions only the bridge can answer.
@@ -9412,8 +9679,7 @@ function composeSpawnPreflights(...preflights) {
9412
9679
  }
9413
9680
  };
9414
9681
  }
9415
- //#endregion
9416
- //#region src/runtime/supervise/supervise-sql-admission.ts
9682
+ // src/runtime/supervise/supervise-sql-admission.ts
9417
9683
  /** What a SQL run context admits, in two phases: identity and worker seam before any compute (a
9418
9684
  * synchronous configuration fault), then coordinator and retained-control capabilities at start. */
9419
9685
  function assertSqlRunOptions(options) {
@@ -9429,8 +9695,7 @@ async function assertSqlRunProvider(options) {
9429
9695
  const capabilities = await provider.capabilities();
9430
9696
  if (!capabilities.retainedControl || !capabilities.streaming.turnIdempotency || !capabilities.streaming.replay || !provider.get) throw new ValidationError("supervise: SQL runContext requires retainedControl, replay, turn idempotency, and provider.get");
9431
9697
  }
9432
- //#endregion
9433
- //#region src/runtime/supervise/supervise-run-setup.ts
9698
+ // src/runtime/supervise/supervise-run-setup.ts
9434
9699
  function prepareSuperviseRun(profile, task, opts, testBrain) {
9435
9700
  const options = captureSuperviseOptions(opts);
9436
9701
  assertSqlRunOptions(options);
@@ -9616,7 +9881,10 @@ function resolveRunRegistry(options) {
9616
9881
  analysts: resolveNamed("analysts", "analysts", options.analysts, options.registry?.analysts),
9617
9882
  profileTable: snapshotProfileTable(options.registry?.profiles, options.allowedModels, options.makeWorkerAgent === void 0 && options.authorizeSpawn === void 0 ? (entry, context) => {
9618
9883
  const security = validateAgentProfileSecurity(entry, options.profileSecurity ?? DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY);
9619
- if (!security.ok) throw new ValidationError(`${context}: ${security.issues.filter((issue) => issue.level === "error").map((issue) => `${issue.code}${issue.path ? ` at ${issue.path}` : ""}`).join(", ")}`);
9884
+ if (!security.ok) {
9885
+ const details = security.issues.filter((issue) => issue.level === "error").map((issue) => `${issue.code}${issue.path ? ` at ${issue.path}` : ""}`).join(", ");
9886
+ throw new ValidationError(`${context}: ${details}`);
9887
+ }
9620
9888
  if (options.backend !== void 0 && options.makeLeafAgent === void 0 && declaredRuntimeToolNames(entry).length === 0) assertBackendProfileMaterialization(entry, options.backend, context);
9621
9889
  } : void 0)
9622
9890
  };
@@ -9683,8 +9951,7 @@ function spawnProfileComposer(options, driver, childrenCanSubmit, composeSpawnPr
9683
9951
  };
9684
9952
  };
9685
9953
  }
9686
- //#endregion
9687
- //#region src/runtime/supervise/supervise-run-lifecycle.ts
9954
+ // src/runtime/supervise/supervise-run-lifecycle.ts
9688
9955
  function superviseInternal(profile, task, opts, testBrain) {
9689
9956
  const setup = prepareSuperviseRun(profile, task, opts, testBrain);
9690
9957
  const { options } = setup;
@@ -9910,8 +10177,7 @@ async function settleSupervisedRun(run, pending, cancellation) {
9910
10177
  ...rootExecution.ref === void 0 ? {} : { execution: rootExecution.ref }
9911
10178
  };
9912
10179
  }
9913
- //#endregion
9914
- //#region src/runtime/supervise/supervise.ts
10180
+ // src/runtime/supervise/supervise.ts
9915
10181
  /** Capabilities a data-only consumer may require before building an opted-in run. `graphTools`:
9916
10182
  * a manager whose profile grants `run_graph` can start an agent graph as one subtask. */
9917
10183
  const superviseFleetCapabilities = Object.freeze({
@@ -9942,7 +10208,6 @@ function superviseWithContext(profile, task, opts, brain) {
9942
10208
  ...signal === void 0 ? {} : { signal }
9943
10209
  }, brain));
9944
10210
  }
9945
- //#endregion
9946
- export { allWorkersStalled as $, serveCoordinationMcp as A, validateFlowGraph as B, storedGraphDigests as C, supervisorAgentWithTestBrain as D, supervisorAgent as E, GraphRouteError as F, createPromptRegistry as G, graphRootProfile as H, createFlowRun as I, dumbContinuationPassPrompt as J, delegatesWorkerBriefPrompt as K, flowRootProfile as L, runBrainLoop as M, runtimeFlowBrain as N, UNPROVEN_CONTINUITY as O, createGraphOverlay as P, promptHandle as Q, journaledGateDecider as R, recordStoredGraphRun as S, workerFromBackend as T, validateGraphTopology as U, defaultEdgeTraversalCap as V, analyzesFindingsReportPrompt as W, kernelPromptRegistry as X, formatPromptHandle as Y, naiveContinuationPrompt as Z, listGraphRuns as _, superviseRootProfile as a, bestSoFar as at, pickBestGraph as b, retryPreSpawnRefusals as c, readRootStream as ct, graphCorpusSummary as d, anyOf as et, graphDigest as f, graph_registry_exports as g, graphRunsFor as h, profileGuidanceComposer as i, areaUnderCurve as it, driverAgent as j, composeReentryTask as k, withWorkerSpawnRetry as l, readRootStreamReceipt as lt, graphRegistry as m, superviseFleetCapabilities as n, plateau as nt, isPreSpawnExecutorFailure as o, plateauLength as ot, graphFromStored as p, dumbContinuationFailPrompt as q, superviseWithTestBrain as r, anytimeReport as rt, resolveWorkerSpawnRetry as s, renderAnytimeTable as st, supervise as t, noProgressFor as tt, digestOfGraph as u, createSupervisorSpanRecorder as ut, loadGraph as v, taskShapeDigest as w, recordGraphRun as x, lookupGraph as y, routeFlowOf as z };
10211
+ export { delegatesWorkerBriefPrompt as $, graphRouteWhenSchema as A, runtimeFlowBrain as B, storedGraphDigests as C, compileGraphParameters as D, bindGraphParameters as E, composeReentryTask as F, journaledGateDecider as G, GraphRouteError as H, serveCoordinationMcp as I, defaultEdgeTraversalCap as J, routeFlowOf as K, coordinationControlToolNames as L, supervisorAgent as M, supervisorAgentWithTestBrain as N, graphTriggerBindingsSchema as O, UNPROVEN_CONTINUITY as P, createPromptRegistry as Q, driverAgent as R, recordStoredGraphRun as S, assertGraphTriggerBindings as T, createFlowRun as U, createGraphOverlay as V, flowRootProfile as W, validateGraphTopology as X, graphRootProfile as Y, analyzesFindingsReportPrompt as Z, listGraphRuns as _, createSupervisorSpanRecorder as _t, superviseRootProfile as a, promptHandle as at, pickBestGraph as b, retryPreSpawnRefusals as c, noProgressFor as ct, graphCorpusSummary as d, areaUnderCurve as dt, dumbContinuationFailPrompt as et, graphDigest as f, bestSoFar as ft, graph_registry_exports as g, readRootStreamReceipt as gt, graphRunsFor as h, readRootStream as ht, profileGuidanceComposer as i, naiveContinuationPrompt as it, workerFromBackend as j, graphFileSchema as k, withWorkerSpawnRetry as l, plateau as lt, graphRegistry as m, renderAnytimeTable as mt, superviseFleetCapabilities as n, formatPromptHandle as nt, isPreSpawnExecutorFailure as o, allWorkersStalled as ot, graphFromStored as p, plateauLength as pt, validateFlowGraph as q, superviseWithTestBrain as r, kernelPromptRegistry as rt, resolveWorkerSpawnRetry as s, anyOf as st, supervise as t, dumbContinuationPassPrompt as tt, digestOfGraph as u, anytimeReport as ut, loadGraph as v, taskShapeDigest as w, recordGraphRun as x, lookupGraph as y, runBrainLoop as z };
9947
10212
 
9948
- //# sourceMappingURL=supervise-BGfm2GlY.js.map
10213
+ //# sourceMappingURL=supervise-CNNhX0ab.js.map