@tangle-network/agent-runtime 0.344.0 → 0.348.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 (68) hide show
  1. package/dist/{activation-C5rFWXGj.js → activation-BEGalhOL.js} +2 -2
  2. package/dist/{activation-C5rFWXGj.js.map → activation-BEGalhOL.js.map} +1 -1
  3. package/dist/{activation-CGtGr0qu.d.ts → activation-NQZP_mdI.d.ts} +2 -2
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +3 -3
  6. package/dist/{coordination-manager-T98ZbsEt.js → coordination-manager-Bm6leXc6.js} +22 -19
  7. package/dist/coordination-manager-Bm6leXc6.js.map +1 -0
  8. package/dist/{delegate-CjdtLf1v.js → delegate-Cp5-PsaX.js} +2 -2
  9. package/dist/{delegate-CjdtLf1v.js.map → delegate-Cp5-PsaX.js.map} +1 -1
  10. package/dist/durable.d.ts +7 -2
  11. package/dist/durable.js +127 -115
  12. package/dist/durable.js.map +1 -1
  13. package/dist/{graph-kgzTaNMA.js → graph-CE_pzU31.js} +5 -4
  14. package/dist/graph-CE_pzU31.js.map +1 -0
  15. package/dist/{improve-DevAd83a.js → improve-wT11zteg.js} +6 -6
  16. package/dist/{improve-DevAd83a.js.map → improve-wT11zteg.js.map} +1 -1
  17. package/dist/index.d.ts +3 -3
  18. package/dist/index.js +7 -7
  19. package/dist/intelligence.d.ts +2 -2
  20. package/dist/intelligence.js +3 -3
  21. package/dist/kernel.d.ts +2 -2
  22. package/dist/kernel.js +11 -11
  23. package/dist/{loop-runner-DsVqEv8O.d.ts → loop-runner-CY5HHhtR.d.ts} +2 -2
  24. package/dist/{loop-runner-BM509Zmp.js → loop-runner-CZzeeJTG.js} +2 -2
  25. package/dist/{loop-runner-BM509Zmp.js.map → loop-runner-CZzeeJTG.js.map} +1 -1
  26. package/dist/loop-runner-bin.d.ts +1 -1
  27. package/dist/loop-runner-bin.js +1 -1
  28. package/dist/mcp/bin.js +3 -3
  29. package/dist/mcp/index.d.ts +1 -1
  30. package/dist/mcp/index.js +5 -5
  31. package/dist/mcp/index.js.map +1 -1
  32. package/dist/profiles.d.ts +1 -1
  33. package/dist/{provision-supervisor-CysVhSqV.js → provision-supervisor-CC0HdOHo.js} +5 -5
  34. package/dist/{provision-supervisor-CysVhSqV.js.map → provision-supervisor-CC0HdOHo.js.map} +1 -1
  35. package/dist/{durable-file-DLcrzrjL.js → record-events-D93DkpAx.js} +100 -3
  36. package/dist/record-events-D93DkpAx.js.map +1 -0
  37. package/dist/{run-cancellation-CEDiqfhC.js → run-cancellation-CzFhQGMa.js} +11 -9
  38. package/dist/run-cancellation-CzFhQGMa.js.map +1 -0
  39. package/dist/{runtime-B_93oWEv.js → runtime-B_40dXlF.js} +259 -51
  40. package/dist/runtime-B_40dXlF.js.map +1 -0
  41. package/dist/{search-executor-t05_9Wwk.js → search-executor-COd2F2wp.js} +2 -2
  42. package/dist/{search-executor-t05_9Wwk.js.map → search-executor-COd2F2wp.js.map} +1 -1
  43. package/dist/{server-DjrVWzH2.js → server-BGB4R4wQ.js} +3 -3
  44. package/dist/{server-DjrVWzH2.js.map → server-BGB4R4wQ.js.map} +1 -1
  45. package/dist/{structural-rollout-CpJknIaL.js → structural-rollout-Wl_rCuzM.js} +2 -2
  46. package/dist/{structural-rollout-CpJknIaL.js.map → structural-rollout-Wl_rCuzM.js.map} +1 -1
  47. package/dist/{supervise-BuVVC7Bl.js → supervise-BUOeThuB.js} +122 -63
  48. package/dist/supervise-BUOeThuB.js.map +1 -0
  49. package/dist/{supervisor-D3M9ab1v.js → supervisor-DDy0aEtR.js} +438 -170
  50. package/dist/supervisor-DDy0aEtR.js.map +1 -0
  51. package/dist/testing.d.ts +1 -1
  52. package/dist/testing.js +11 -11
  53. package/dist/{top-snapshot-BGYI6G6K.js → top-snapshot-CflmaDgk.js} +6 -4
  54. package/dist/top-snapshot-CflmaDgk.js.map +1 -0
  55. package/dist/tui/bin.js +2 -2
  56. package/dist/tui/index.d.ts +1 -1
  57. package/dist/tui/index.js +2 -2
  58. package/dist/{types-DztCeYd6.d.ts → types-hc4cmSc7.d.ts} +92 -11
  59. package/package.json +11 -11
  60. package/skills/agent-graphs/SKILL.md +38 -2
  61. package/dist/coordination-manager-T98ZbsEt.js.map +0 -1
  62. package/dist/durable-file-DLcrzrjL.js.map +0 -1
  63. package/dist/graph-kgzTaNMA.js.map +0 -1
  64. package/dist/run-cancellation-CEDiqfhC.js.map +0 -1
  65. package/dist/runtime-B_93oWEv.js.map +0 -1
  66. package/dist/supervise-BuVVC7Bl.js.map +0 -1
  67. package/dist/supervisor-D3M9ab1v.js.map +0 -1
  68. package/dist/top-snapshot-BGYI6G6K.js.map +0 -1
@@ -1,11 +1,11 @@
1
- import { c as __exportAll, n as assertNoSymlinkDescendant, o as writeAtomicDurableFile, s as sha256 } from "./durable-file-DLcrzrjL.js";
2
- import { $ as beginScopeRetainedOwnerDrive, $n as upstreamUnavailableSignal, A as coordinationProfileToolPrefix, An as createInbox, Ar as bridgeStopSignalKey, B as meterRuntimeOwnedProviderAttempt, Bi as assertValidBudget, Br as fullProfileMaterialization, Bt as toolResultText, Ci as cappedDoublingMs, Ct as captureReusableExecutorConfig, D as restoreScopeOwnerAcceptedExecution, Dr as runAbortable, E as recordScopeOwnerMaterialization, Ei as unavailableResumeAt, Er as linkAbort, F as deriveNodeExecutionIdentity, G as scopeRetainedOwnerResourceReader, Gn as isTerminalNodeStatus, H as recordScopeOwnerDriverAttempt, Hn as createActivityLog, Hr as promptControlProfileMaterialization, Ht as routerBrain, Ii as meterUsageEvent, Ir as assertProfileMaterialization, It as codeModeArguments, J as abandonScopeRetainedOwnerInvocation, Jn as abandonablePending, Jr as worktreeCliProfileMaterialization, Kn as DriverAttemptsExhaustedError, Kr as sandboxProfileMaterialization, Li as newUsageTotals, Ln as isPeerMailEnvelope, Lt as codeModeModelOutput, M as runtimeGraphMetadataKey, Mi as contentAddress, Ni as executorFailure, O as scopeOwnerExecutorNodeContext, P as assertRecursiveReservationPolicy, Pi as errMessage, Pn as PEER_MAIL_WIRE_KEY, Q as scopeRetainedOwnerResult, Qn as undispatchedCredentialExit, Rr as controlProfileMaterialization, Rt as createCodeModeTools, Si as retainedExecutorSeamKey, St as bindReusableExecutorExecutionId, T as noteScopeOwnerPlannedExecution, Ti as unavailablePauseMs, Tr as RunCancellationReason, Tt as snapshotExecutorConfig, U as recordScopeOwnerPause, Ur as promptModelProfileMaterialization, V as recordScopeOwnerBarrenPause, Vr as profileMaterializationAxes$1, Vt as createRouterTranscript, W as prepareScopeRetainedOwnerSeatSwitch, Wn as isLiveNodeStatus, Wr as renderUnsupported, Wt as resolveAgentEnvironmentProvider, X as prepareScopeRetainedOwnerTask, Xn as classifyDriverFailure, Xr as attestRuntimeOwnedScopeOwner, Y as consumeScopeRetainedOwnerResult, Yn as causedByPartialFailure, Z as scopeRetainedOwnerPriorSpend, Zn as summarizeDriverAttempts, Zr as authoredAgentIdentity, _r as bridgeModelRouteRefusal, _t as readCommittedJsonLines, a as runFinalizer, ai as recordRuntimeOwnedDriveHarnessProviderEvidence, ar as CheckUnavailableError, at as bindScopeRetainedOwnerProvider, bi as RetainedExecutionPendingError, bn as generateSpanId, c as driverChild, ci as runtimeOwnedExecutorMaterialization, di as runtimeOwnedScopeOwnerRuntime, dn as WORKER_TRACE_PROPAGATION, dr as bestComposite, ei as inheritRuntimeOwnedExecutorAttestation, er as SeatChain, et as scopeRetainedOwnerTurnEnded, fr as checkVerdictOf, gr as bridgeAdmissionRefusal, gt as readCommittedJsonFile, h as parseWorkerToolTraceArtifact, ht as prepareJsonlAppend, i as bestDelivered, ii as providerAttemptEvidence, in as readHarnessTranscript, it as bindScopeRetainedOwnerEnvironmentId, j as providerVisibleProfile, ji as detachedSnapshot, k as coordinationMcpAlias, kn as INBOX_RECEIPT_KEY, kr as bridgeRuntimeAttachmentsKey, l as driverExecutorFactory, li as runtimeOwnedExecutorProviderEvidence, lr as CONTINUATIONS_DIR, mt as isNoEntError, n as createSupervisor, nr as authoredSeatStages, nt as scopeRetainedOwnerRestorePoint, o as runTree, oi as runtimeOwnedDriveHarnessProviderEvidence, or as gateOnDeliverable, ot as scopeRetainedOwnerContext, pr as createContinuationKeeper, qn as HarnessTurnFailedError, qr as unsupportedProfileDimensions, rn as persistHarnessTranscript, rr as seatExecutionProfile, rt as noteScopeRetainedOwnerCoordination, s as createRootHandle, si as runtimeOwnedExecutorExecutionBinding, st as scopeRetainedOwnerJournalRoot, tr as SeatChainExhaustedError, tt as reconcileScopeRetainedOwnerEnvironment, u as isDriverSpec, ui as runtimeOwnedPendingExecutorMaterialization, ur as admitContinuationPolicy, vn as createOtelExporter, vt as upsertCommittedJsonLine, w as beginScopeOwnerAttempt, wi as jitteredMs, wn as toOtelAttributes, wt as createExecutor, xi as registerRetainedExecutorPreparation, yt as withJsonlFileLock, z as meterRuntimeOwnedAccounting, zi as spendFromUsageTotals, zr as defineProfileMaterializationContract } from "./supervisor-D3M9ab1v.js";
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-DDy0aEtR.js";
3
3
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
4
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-_fEtHPCj.js";
5
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
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-T98ZbsEt.js";
8
- import { c as writeRunCancellation, i as readRunCancellation, r as readRunCancelRequest, s as watchRunCancellation, t as applyRunCancellation } from "./run-cancellation-CEDiqfhC.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-Bm6leXc6.js";
8
+ import { c as writeRunCancellation, i as readRunCancellation, r as readRunCancelRequest, s as watchRunCancellation, t as applyRunCancellation } from "./run-cancellation-CzFhQGMa.js";
9
9
  import { n as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-XV4aJwoQ.js";
10
10
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
11
11
  import { toolSpansToTraceAnalysisStore } from "@tangle-network/agent-eval";
@@ -169,6 +169,7 @@ const superviseOptionKeySet = /* @__PURE__ */ new Set([
169
169
  "rootHandle",
170
170
  "router",
171
171
  "runDir",
172
+ "parking",
172
173
  "resume",
173
174
  "segment",
174
175
  "runContext",
@@ -790,6 +791,7 @@ const ROOT_STREAM_FILE = "root-stream.jsonl";
790
791
  /** Create the writer for `<runDir>/root-stream.jsonl`. Nothing touches disk until the first
791
792
  * `beginAttempt`, so a run whose root never drives leaves no file and no receipt. */
792
793
  function createRootStreamSink(runDir, now) {
794
+ const withClaim = captureRunWriteContext();
793
795
  const dir = resolve(runDir);
794
796
  const path = resolve(dir, ROOT_STREAM_FILE);
795
797
  let fd;
@@ -803,63 +805,79 @@ function createRootStreamSink(runDir, now) {
803
805
  const needsSeparator = await prepareJsonlAppend(path);
804
806
  seq = 0;
805
807
  for await (const _record of readCommittedJsonLines(path, { allowMissing: true })) seq += 1;
806
- fd = openSync(path, constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY | (typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0), 384);
807
- if (needsSeparator) writeLine(fd, "");
808
+ fd = fenceRunWrite(() => {
809
+ const writer = openSync(path, constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY | (typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0), 384);
810
+ try {
811
+ if (needsSeparator) writeLine(writer, "");
812
+ return writer;
813
+ } catch (error) {
814
+ closeSync(writer);
815
+ throw error;
816
+ }
817
+ });
808
818
  };
809
819
  return {
810
820
  async beginAttempt() {
811
- if (closed) throw new Error("root stream: beginAttempt after close");
812
- attempt += 1;
813
- if (fd !== void 0) fsyncSync(fd);
814
- await openOnce();
821
+ return withClaim(async () => {
822
+ if (closed) throw new Error("root stream: beginAttempt after close");
823
+ attempt += 1;
824
+ const writer = fd;
825
+ if (writer !== void 0) fenceRunWrite(() => fsyncSync(writer));
826
+ await openOnce();
827
+ });
815
828
  },
816
829
  append(event) {
817
- if (closed) throw new Error("root stream: append after close");
818
- if (fd === void 0) throw new Error("root stream: append before beginAttempt");
819
- const at = new Date(now()).toISOString();
820
- const record = {
821
- seq: seq + 1,
822
- at,
823
- attempt,
824
- event
825
- };
826
- let line;
827
- try {
828
- line = JSON.stringify(record);
829
- } catch (error) {
830
- line = JSON.stringify({
830
+ return withClaim(() => fenceRunWrite(() => {
831
+ if (closed) throw new Error("root stream: append after close");
832
+ if (fd === void 0) throw new Error("root stream: append before beginAttempt");
833
+ const at = new Date(now()).toISOString();
834
+ const record = {
835
+ seq: seq + 1,
836
+ at,
837
+ attempt,
838
+ event
839
+ };
840
+ let line;
841
+ try {
842
+ line = JSON.stringify(record);
843
+ } catch (error) {
844
+ line = JSON.stringify({
845
+ seq: seq + 1,
846
+ at,
847
+ attempt,
848
+ dropped: {
849
+ kind: event.kind,
850
+ reason: errorMessage(error)
851
+ }
852
+ });
853
+ }
854
+ if (line === void 0) line = JSON.stringify({
831
855
  seq: seq + 1,
832
856
  at,
833
857
  attempt,
834
858
  dropped: {
835
859
  kind: event.kind,
836
- reason: errorMessage(error)
860
+ reason: "event serialized to nothing"
837
861
  }
838
862
  });
839
- }
840
- if (line === void 0) line = JSON.stringify({
841
- seq: seq + 1,
842
- at,
843
- attempt,
844
- dropped: {
845
- kind: event.kind,
846
- reason: "event serialized to nothing"
847
- }
848
- });
849
- writeLine(fd, line);
850
- seq += 1;
863
+ writeLine(fd, line);
864
+ seq += 1;
865
+ }));
851
866
  },
852
867
  async close() {
853
- if (closed) throw new Error("root stream: closed twice");
854
- closed = true;
855
- if (fd === void 0) return void 0;
856
- try {
857
- fsyncSync(fd);
858
- } finally {
859
- closeSync(fd);
860
- fd = void 0;
861
- }
862
- return readRootStreamReceipt(dir);
868
+ return withClaim(async () => {
869
+ if (closed) throw new Error("root stream: closed twice");
870
+ closed = true;
871
+ const writer = fd;
872
+ if (writer === void 0) return void 0;
873
+ try {
874
+ fenceRunWrite(() => fsyncSync(writer));
875
+ } finally {
876
+ closeSync(writer);
877
+ fd = void 0;
878
+ }
879
+ return readRootStreamReceipt(dir);
880
+ });
863
881
  }
864
882
  };
865
883
  }
@@ -4895,7 +4913,19 @@ function observeWorkerControls(options) {
4895
4913
  }
4896
4914
  if (failure) throw failure.error;
4897
4915
  };
4898
- return { close: () => closing ??= finish() };
4916
+ return {
4917
+ async pass() {
4918
+ if (!active) return;
4919
+ try {
4920
+ cancellations?.pass("boundary");
4921
+ await steers?.pass("boundary");
4922
+ } catch (error) {
4923
+ fail(error);
4924
+ }
4925
+ if (failure) throw failure.error;
4926
+ },
4927
+ close: () => closing ??= finish()
4928
+ };
4899
4929
  }
4900
4930
  //#endregion
4901
4931
  //#region src/runtime/supervise/supervisor-manager-session.ts
@@ -5741,6 +5771,7 @@ async function runDriverWithRetry(run) {
5741
5771
  try {
5742
5772
  await run.drive(attempt, loop.reentry);
5743
5773
  } catch (error) {
5774
+ if (error instanceof RunParkedError) throw error;
5744
5775
  await loop.afterFailure(error, attempt, before, startedAt);
5745
5776
  continue;
5746
5777
  }
@@ -6063,6 +6094,9 @@ async function driveManagerTurns(inputs) {
6063
6094
  reported: false
6064
6095
  };
6065
6096
  const { mcp } = session;
6097
+ bindScopeParkingDrain(scope, async () => {
6098
+ await mcp.drainResolved();
6099
+ }, () => !session.controls.hasOpenWork({ includeSettled: false }) && session.state.nextTurnInbox.pendingAuthority() === 0);
6066
6100
  const keeper = session.state.keeper;
6067
6101
  const reenteredWorkers = scope.resume?.reentered;
6068
6102
  const reentered = reenteredWorkers === void 0 ? void 0 : {
@@ -6073,14 +6107,26 @@ async function driveManagerTurns(inputs) {
6073
6107
  modelEvents: () => loop.modelEvents
6074
6108
  };
6075
6109
  let driverFailed = true;
6110
+ let parked = false;
6076
6111
  try {
6077
6112
  await runDriverWithRetry({
6078
6113
  ...reentered === void 0 ? {} : { reentered },
6079
- drive: (attempt, reentry) => driveManagerTurn(loop, attempt, reentry),
6114
+ drive: async (attempt, reentry) => {
6115
+ let handedOff = false;
6116
+ try {
6117
+ await driveManagerTurn(loop, attempt, reentry);
6118
+ } catch (error) {
6119
+ handedOff = error instanceof RunParkedError && error.runId === scope.view.root;
6120
+ throw error;
6121
+ } finally {
6122
+ if (!handedOff) await loop.controlPass?.();
6123
+ }
6124
+ },
6080
6125
  progress: () => readManagerProgress(loop),
6081
6126
  budget: () => scope.budget,
6082
6127
  signal: scope.signal,
6083
6128
  stopSignal: session.state.stopController.signal,
6129
+ sleep: (ms, signal) => sleepScopeWait(scope, ms, signal, "paused-root"),
6084
6130
  ...rootStopPause(config, session),
6085
6131
  resolvePending: (failure, failures) => abandonScopeRetainedOwnerInvocation(scope, failure, failures),
6086
6132
  wait: {
@@ -6098,9 +6144,14 @@ async function driveManagerTurns(inputs) {
6098
6144
  onBarrenPause: (pause) => recordScopeOwnerBarrenPause(loop.session.state.scope, pause)
6099
6145
  });
6100
6146
  driverFailed = false;
6147
+ } catch (error) {
6148
+ parked = error instanceof RunParkedError && error.runId === scope.view.root;
6149
+ throw error;
6101
6150
  } finally {
6102
- await driveHarness.closeSeatSegment?.(scope.signal.aborted ? "cancelled" : driverFailed ? "failed" : "completed");
6103
- if (!loop.reported) reportManagerLoop(loop);
6151
+ if (!parked) {
6152
+ await driveHarness.closeSeatSegment?.(scope.signal.aborted ? "cancelled" : driverFailed ? "failed" : "completed");
6153
+ if (!loop.reported) reportManagerLoop(loop);
6154
+ }
6104
6155
  }
6105
6156
  return loop.candidate;
6106
6157
  }
@@ -6474,9 +6525,11 @@ async function actExternalManager(config, task, scope) {
6474
6525
  contractDeclared,
6475
6526
  finalize,
6476
6527
  coordinationTools,
6477
- providerProfile
6528
+ providerProfile,
6529
+ controlPass: () => controlObserver?.pass() ?? Promise.resolve()
6478
6530
  }));
6479
6531
  } catch (error) {
6532
+ if (error instanceof RunParkedError && error.runId === scope.view.root) throw error;
6480
6533
  await mcp.finishAnalysis({
6481
6534
  status: "down",
6482
6535
  reason: errorMessage(error)
@@ -7163,7 +7216,7 @@ function workerFromBackend(backend, deliverable, seams) {
7163
7216
  const boundSessionId = boundBackend.backend === "bridge" ? boundBackend.sessionId : void 0;
7164
7217
  const peerMailAttachment = peerMailRuntimeAttachment(profile, capturedBackend, spawnContext);
7165
7218
  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");
7166
- const baseFactory = createExecutor(spawnContext?.peerMailUrl && boundBackend.backend === "provider" ? {
7219
+ const rawFactory = createExecutor(spawnContext?.peerMailUrl && boundBackend.backend === "provider" ? {
7167
7220
  ...boundBackend,
7168
7221
  steering: boundBackend.steering ?? {},
7169
7222
  defaults: {
@@ -7180,6 +7233,7 @@ function workerFromBackend(backend, deliverable, seams) {
7180
7233
  }
7181
7234
  }
7182
7235
  } : boundBackend);
7236
+ const baseFactory = deliverable ? gateFactoryOnDeliverable(rawFactory, deliverable) : rawFactory;
7183
7237
  const executorFactory = (spec, ctx) => {
7184
7238
  if (boundSessionId !== void 0 && ctx.node?.nodeId !== void 0) bridgeSessionByWorker.set(ctx.node.nodeId, boundSessionId);
7185
7239
  const extraSeams = seams?.();
@@ -7191,11 +7245,10 @@ function workerFromBackend(backend, deliverable, seams) {
7191
7245
  ...peerMailAttachment
7192
7246
  } }
7193
7247
  };
7194
- const built = baseFactory(spec, seamsForChild === ctx.seams ? ctx : {
7248
+ return baseFactory(spec, seamsForChild === ctx.seams ? ctx : {
7195
7249
  ...ctx,
7196
7250
  seams: seamsForChild
7197
7251
  });
7198
- return deliverable ? gateOnDeliverable(built, deliverable) : built;
7199
7252
  };
7200
7253
  return {
7201
7254
  name,
@@ -7666,7 +7719,7 @@ function registerRecovery(env, makeRecursiveWorker) {
7666
7719
  const { options } = env.setup;
7667
7720
  if (options.makeLeafAgent !== void 0 || options.backend?.backend !== "provider" || options.backend.steering) return;
7668
7721
  const factory = registerRetainedExecutorPreparation(createExecutor(options.backend), ({ spawned, profile, task }) => {
7669
- if (!spawned.ownedTreeRoot || !spawned.parent || !spawned.assignmentId || !spawned.identity) return void 0;
7722
+ if (!spawned.parent || !spawned.assignmentId || !spawned.identity) return void 0;
7670
7723
  const execution = {
7671
7724
  ...spawned.identity.candidateDigest ? { candidateDigest: spawned.identity.candidateDigest } : {},
7672
7725
  ...spawned.identity.correlation ? { correlation: spawned.identity.correlation } : {}
@@ -7680,10 +7733,11 @@ function registerRecovery(env, makeRecursiveWorker) {
7680
7733
  ...spawned.key === void 0 ? {} : { key: spawned.key },
7681
7734
  execution
7682
7735
  }, true).executorSpec;
7683
- if (!spec || !isDriverSpec(spec)) return void 0;
7684
- return {
7736
+ if (!spec) return void 0;
7737
+ const factory = isDriverSpec(spec) ? driverExecutorFactory : spec.executorFactory;
7738
+ return factory === void 0 ? void 0 : {
7685
7739
  spec,
7686
- factory: driverExecutorFactory
7740
+ factory
7687
7741
  };
7688
7742
  });
7689
7743
  env.recoveryFactories.set(makeRecursiveWorker, factory);
@@ -7849,6 +7903,8 @@ function retryPreSpawnRefusals(inner, policy, hooks = {}) {
7849
7903
  ...inner.progress ? { progress: () => inner.progress?.() } : {},
7850
7904
  ...inner.traceSource ? { traceSource: () => inner.traceSource?.() } : {},
7851
7905
  ...inner.metered ? { metered: () => inner.metered?.() } : {},
7906
+ ...inner.accounting ? { accounting: () => inner.accounting?.() } : {},
7907
+ ...inner.resultAccepted ? { resultAccepted: () => inner.resultAccepted?.() === true } : {},
7852
7908
  ...inner.harnessTranscript ? { harnessTranscript: () => inner.harnessTranscript?.() } : {},
7853
7909
  ...inner.harnessTranscriptSettled ? { harnessTranscriptSettled: () => inner.harnessTranscriptSettled?.() ?? Promise.resolve() } : {},
7854
7910
  ...inner.interactive === void 0 ? {} : { interactive: () => interactiveOf(inner) },
@@ -7857,6 +7913,7 @@ function retryPreSpawnRefusals(inner, policy, hooks = {}) {
7857
7913
  const restart = () => inner.execute(task, signal);
7858
7914
  return isAsyncIterable(first) ? retryStream(first, restart, signal) : retryOneShot(first, restart, signal);
7859
7915
  },
7916
+ ...inner.recover ? { recover: (task, signal) => inner.recover(task, signal) } : {},
7860
7917
  teardown: (grace) => inner.teardown(grace),
7861
7918
  ...teardownSurfaces(inner),
7862
7919
  resultArtifact: () => inner.resultArtifact()
@@ -8681,7 +8738,8 @@ var ManagerDriveSession = class {
8681
8738
  }
8682
8739
  /** The next seat the chain grants, waiting out every pause the chain is exhausted until. */
8683
8740
  async nextSeat(seatChain, scope, seatSelection, seatJournalRoot, usageLimit, now) {
8684
- let afterRecheck = false;
8741
+ const paused = [...await seatSelection.journal.loadTree(seatJournalRoot) ?? []].reverse().find((event) => event.id === scope.view.root && (event.kind === "seat-paused" || event.kind === "seat-segment" && event.phase === "started"));
8742
+ let afterRecheck = paused?.kind === "seat-paused" && Date.parse(paused.resumeAt) <= now();
8685
8743
  for (;;) try {
8686
8744
  const seat = await seatChain.next(usageLimit && !afterRecheck, afterRecheck);
8687
8745
  this.activeSeat = seat;
@@ -8697,7 +8755,7 @@ var ManagerDriveSession = class {
8697
8755
  at: new Date(now()).toISOString()
8698
8756
  });
8699
8757
  await seatSelection.onPause(scope.view.root, error.resumeAt, "paused");
8700
- await sleep(Math.max(1e3, Date.parse(error.resumeAt) - now()), scope.signal, false);
8758
+ await sleepScopeWait(scope, Math.max(1e3, Date.parse(error.resumeAt) - now()), scope.signal, "seat-wait");
8701
8759
  afterRecheck = true;
8702
8760
  }
8703
8761
  }
@@ -9517,7 +9575,7 @@ async function startSupervisedRun(run) {
9517
9575
  cancellation?.close();
9518
9576
  throw error;
9519
9577
  }
9520
- const result = supervisor.run(agent, canonicalTask, rootRunOptions(run, runDir, hooks, recorder));
9578
+ const result = withRunParking(options.parking, runDir, runId, setup.journal, setup.now, options.signal === void 0 ? run.durableCancellation.signal : AbortSignal.any([options.signal, run.durableCancellation.signal]), () => supervisor.run(agent, canonicalTask, rootRunOptions(run, runDir, hooks, recorder)));
9521
9579
  const settle = () => settleSupervisedRun(run, result, cancellation);
9522
9580
  if (!recorder) return settle();
9523
9581
  try {
@@ -9725,6 +9783,7 @@ function superviseWithTestBrain(profile, task, opts) {
9725
9783
  return superviseWithContext(profile, task, runtimeOptions, brain);
9726
9784
  }
9727
9785
  function superviseWithContext(profile, task, opts, brain) {
9786
+ assertRunParking(opts.parking, opts.runDir !== void 0);
9728
9787
  if (opts.driverRetry?.pauseRootStops === true && opts.driverRetry.enabled === false) throw new ValidationError("supervise: driverRetry.pauseRootStops pauses where a retry would stop; it cannot be combined with driverRetry.enabled: false");
9729
9788
  if (opts.runContext?.acquire === void 0) return superviseInternal(profile, task, opts, brain);
9730
9789
  const options = captureSuperviseOptions(opts);
@@ -9739,4 +9798,4 @@ function superviseWithContext(profile, task, opts, brain) {
9739
9798
  //#endregion
9740
9799
  export { noProgressFor as $, runBrainLoop as A, graphRootProfile as B, workerFromBackend as C, composeReentryTask as D, UNPROVEN_CONTINUITY as E, flowRootProfile as F, dumbContinuationFailPrompt as G, analyzesFindingsReportPrompt as H, journaledGateDecider as I, kernelPromptRegistry as J, dumbContinuationPassPrompt as K, routeFlowOf as L, createGraphOverlay as M, GraphRouteError as N, serveCoordinationMcp as O, createFlowRun as P, anyOf as Q, validateFlowGraph as R, taskShapeDigest as S, supervisorAgentWithTestBrain as T, createPromptRegistry as U, validateGraphTopology as V, delegatesWorkerBriefPrompt as W, promptHandle as X, naiveContinuationPrompt as Y, allWorkersStalled as Z, loadGraph as _, superviseRootProfile as a, renderAnytimeTable as at, recordGraphRun as b, retryPreSpawnRefusals as c, createSupervisorSpanRecorder as ct, graphDigest as d, plateau as et, graphFromStored as f, listGraphRuns as g, graph_registry_exports as h, profileGuidanceComposer as i, plateauLength as it, runtimeFlowBrain as j, driverAgent as k, withWorkerSpawnRetry as l, graphRunsFor as m, superviseFleetCapabilities as n, areaUnderCurve as nt, isPreSpawnExecutorFailure as o, readRootStream as ot, graphRegistry as p, formatPromptHandle as q, superviseWithTestBrain as r, bestSoFar as rt, resolveWorkerSpawnRetry as s, readRootStreamReceipt as st, supervise as t, anytimeReport as tt, digestOfGraph as u, lookupGraph as v, supervisorAgent as w, storedGraphDigests as x, pickBestGraph as y, defaultEdgeTraversalCap as z };
9741
9800
 
9742
- //# sourceMappingURL=supervise-BuVVC7Bl.js.map
9801
+ //# sourceMappingURL=supervise-BUOeThuB.js.map