@tangle-network/agent-runtime 2.0.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/{activation-BuK2H7qx.d.ts → activation-BpkpEn0T.d.ts} +2 -2
  2. package/dist/{activation-ZQWz04u8.js → activation-D9KoX_R4.js} +2 -2
  3. package/dist/{activation-ZQWz04u8.js.map → activation-D9KoX_R4.js.map} +1 -1
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +3 -3
  6. package/dist/{coordination-manager-COU_d7WX.js → coordination-manager-CqZGCqjV.js} +4 -4
  7. package/dist/{coordination-manager-COU_d7WX.js.map → coordination-manager-CqZGCqjV.js.map} +1 -1
  8. package/dist/{delegate-CgwzTdz1.js → delegate-B5XFrkTg.js} +2 -2
  9. package/dist/{delegate-CgwzTdz1.js.map → delegate-B5XFrkTg.js.map} +1 -1
  10. package/dist/durable.d.ts +12 -1
  11. package/dist/durable.js +35 -7
  12. package/dist/durable.js.map +1 -1
  13. package/dist/{graph-qqGNh-Ot.js → graph-Ds6VUJzW.js} +5 -5
  14. package/dist/{graph-qqGNh-Ot.js.map → graph-Ds6VUJzW.js.map} +1 -1
  15. package/dist/{improve-BuZ-I8DP.js → improve-DbfENElN.js} +5 -5
  16. package/dist/{improve-BuZ-I8DP.js.map → improve-DbfENElN.js.map} +1 -1
  17. package/dist/index.d.ts +3 -3
  18. package/dist/index.js +8 -8
  19. package/dist/intelligence.d.ts +2 -2
  20. package/dist/intelligence.js +3 -3
  21. package/dist/kernel.d.ts +1 -1
  22. package/dist/kernel.js +11 -11
  23. package/dist/{loop-runner-CIs7TAOP.js → loop-runner-CL_5TsT8.js} +2 -2
  24. package/dist/{loop-runner-CIs7TAOP.js.map → loop-runner-CL_5TsT8.js.map} +1 -1
  25. package/dist/{loop-runner-BpLTU_J4.d.ts → loop-runner-DjYZrgqT.d.ts} +2 -2
  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 +4 -4
  31. package/dist/profiles.d.ts +1 -1
  32. package/dist/{provision-supervisor-NMotOvIw.js → provision-supervisor-Cmej51pt.js} +4 -5
  33. package/dist/{provision-supervisor-NMotOvIw.js.map → provision-supervisor-Cmej51pt.js.map} +1 -1
  34. package/dist/{journal-store-BpCOCDoO.js → root-stream-To4qAc0e.js} +767 -13
  35. package/dist/root-stream-To4qAc0e.js.map +1 -0
  36. package/dist/run-cancellation-BhP0Nw6G.js +229 -0
  37. package/dist/run-cancellation-BhP0Nw6G.js.map +1 -0
  38. package/dist/{runtime-B82MOpch.js → runtime-Dm8QlK_z.js} +11 -11
  39. package/dist/{runtime-B82MOpch.js.map → runtime-Dm8QlK_z.js.map} +1 -1
  40. package/dist/{search-executor-__X1VKnU.js → search-executor-CN2Axxt9.js} +3 -3
  41. package/dist/{search-executor-__X1VKnU.js.map → search-executor-CN2Axxt9.js.map} +1 -1
  42. package/dist/{server-Bgm6LPIm.js → server-DlKT7AgQ.js} +3 -3
  43. package/dist/{server-Bgm6LPIm.js.map → server-DlKT7AgQ.js.map} +1 -1
  44. package/dist/{structural-rollout-s8W19Mws.js → structural-rollout-BPz5dLDB.js} +3 -3
  45. package/dist/{structural-rollout-s8W19Mws.js.map → structural-rollout-BPz5dLDB.js.map} +1 -1
  46. package/dist/{supervise-zs42gsTU.js → supervise-BtjM7_0G.js} +19 -191
  47. package/dist/supervise-BtjM7_0G.js.map +1 -0
  48. package/dist/{supervision-discovery-C3t0Xw-T.js → supervision-discovery-CVpmTroK.js} +2 -2
  49. package/dist/{supervision-discovery-C3t0Xw-T.js.map → supervision-discovery-CVpmTroK.js.map} +1 -1
  50. package/dist/{supervisor-L7u3pQ1j.js → supervisor-BsW69Ccw.js} +125 -29
  51. package/dist/supervisor-BsW69Ccw.js.map +1 -0
  52. package/dist/testing.d.ts +1 -1
  53. package/dist/testing.js +11 -11
  54. package/dist/{top-web-DiPLqVwm.js → top-web-Bjb_UlNI.js} +23 -7
  55. package/dist/top-web-Bjb_UlNI.js.map +1 -0
  56. package/dist/tui/bin.js +3 -2
  57. package/dist/tui/bin.js.map +1 -1
  58. package/dist/tui/index.d.ts +1 -1
  59. package/dist/tui/index.js +2 -2
  60. package/dist/{types-BfnQq-_k.d.ts → types-BDmLQLNj.d.ts} +7 -4
  61. package/package.json +2 -2
  62. package/dist/journal-store-BpCOCDoO.js.map +0 -1
  63. package/dist/run-cancellation-Cpm-BIUu.js +0 -743
  64. package/dist/run-cancellation-Cpm-BIUu.js.map +0 -1
  65. package/dist/supervise-zs42gsTU.js.map +0 -1
  66. package/dist/supervisor-L7u3pQ1j.js.map +0 -1
  67. package/dist/top-web-DiPLqVwm.js.map +0 -1
@@ -1,13 +1,12 @@
1
- import { $ as abandonScopeRetainedOwnerInvocation, $n as gateFactoryOnDeliverable, $r as providerAttemptEvidence, $t as persistHarnessTranscript, A as noteScopeOwnerPlannedExecution, An as isPeerMailEnvelope, B as deriveNodeExecutionIdentity, Bn as HarnessTurnFailedError, Bt as resolveAgentEnvironmentProvider, Cn as createInbox, Cr as bridgeRuntimeAttachmentsKey, Dn as PEER_MAIL_WIRE_KEY, F as coordinationProfileToolPrefix, Fn as createActivityLog, Fr as fullProfileMaterialization, G as meterRuntimeOwnedProviderAttempt, Gn as undispatchedCredentialExit, Gr as attestRuntimeOwnedScopeOwner, Hn as causedByPartialFailure, Hr as unsupportedProfileDimensions, I as providerVisibleProfile, Ir as profileMaterializationAxes$1, It as toolResultText, J as recordScopeOwnerPause, Jn as SeatChainExhaustedError, K as recordScopeOwnerBarrenPause, Kn as upstreamUnavailableSignal, Kr as authoredAgentIdentity, L as runtimeGraphMetadataKey, Ln as isLiveNodeStatus, Lr as promptControlProfileMaterialization, Lt as createRouterTranscript, M as restoreScopeOwnerAcceptedExecution, Mt as codeModeArguments, N as scopeOwnerExecutorNodeContext, Nr as controlProfileMaterialization, Nt as codeModeModelOutput, P as coordinationMcpAlias, Pr as defineProfileMaterializationContract, Pt as createCodeModeTools, Qn as CheckUnavailableError, Rn as isTerminalNodeStatus, Rr as promptModelProfileMaterialization, Rt as routerBrain, Sn as INBOX_RECEIPT_KEY, Un as classifyDriverFailure, Ur as worktreeCliProfileMaterialization, Vn as abandonablePending, Vr as sandboxProfileMaterialization, W as meterRuntimeOwnedAccounting, Wn as summarizeDriverAttempts, X as scopeRetainedOwnerResourceReader, Xn as seatExecutionProfile, Y as prepareScopeRetainedOwnerSeatSwitch, Yn as authoredSeatStages, Yr as inheritRuntimeOwnedExecutorAttestation, a as assertRunParking, ai as runtimeOwnedPendingExecutorMaterialization, ar as bestComposite, at as scopeRetainedOwnerTurnEnded, br as linkAbort, bt as createExecutor, c as sleepScopeWait, ct as noteScopeRetainedOwnerCoordination, d as runFinalizer, di as isRuntimeFlowBrain, dr as bridgeModelRouteRefusal, dt as scopeRetainedOwnerContext, ei as recordRuntimeOwnedDriveHarnessProviderEvidence, en as readHarnessTranscript, et as consumeScopeRetainedOwnerResult, f as runTree, fi as runtimeFlowAgent, ft as scopeRetainedOwnerJournalRoot, g as isDriverSpec, gn as generateSpanId, h as driverExecutorFactory, i as RunParkedError, ii as runtimeOwnedExecutorProviderEvidence, ir as admitContinuationPolicy, it as beginScopeRetainedOwnerDrive, j as recordScopeOwnerMaterialization, jr as assertProfileMaterialization, k as beginScopeOwnerAttempt, l as withRunParking, lt as bindScopeRetainedOwnerEnvironmentId, m as driverChild, mn as createOtelExporter, n as createSupervisor, ni as runtimeOwnedExecutorExecutionBinding, nt as scopeRetainedOwnerPriorSpend, o as bindScopeParkingDrain, oi as runtimeOwnedScopeOwnerRuntime, or as checkVerdictOf, ot as reconcileScopeRetainedOwnerEnvironment, p as createRootHandle, pi as runtimeFlowBrain, q as recordScopeOwnerDriverAttempt, qn as SeatChain, ri as runtimeOwnedExecutorMaterialization, rr as CONTINUATIONS_DIR, rt as scopeRetainedOwnerResult, sn as WORKER_TRACE_PROPAGATION, sr as createContinuationKeeper, st as scopeRetainedOwnerRestorePoint, ti as runtimeOwnedDriveHarnessProviderEvidence, tt as prepareScopeRetainedOwnerTask, u as bestDelivered, ur as bridgeAdmissionRefusal, ut as bindScopeRetainedOwnerProvider, vt as bindReusableExecutorExecutionId, wr as bridgeStopSignalKey, x as parseWorkerToolTraceArtifact, xr as runAbortable, xt as snapshotExecutorConfig, yr as RunCancellationReason, yt as captureReusableExecutorConfig, z as assertRecursiveReservationPolicy, zn as DriverAttemptsExhaustedError, zr as renderUnsupported } from "./supervisor-L7u3pQ1j.js";
1
+ import { $ as abandonScopeRetainedOwnerInvocation, $n as gateFactoryOnDeliverable, $r as providerAttemptEvidence, $t as persistHarnessTranscript, A as noteScopeOwnerPlannedExecution, An as isPeerMailEnvelope, B as deriveNodeExecutionIdentity, Bn as HarnessTurnFailedError, Bt as resolveAgentEnvironmentProvider, Cn as createInbox, Cr as bridgeRuntimeAttachmentsKey, Dn as PEER_MAIL_WIRE_KEY, F as coordinationProfileToolPrefix, Fn as createActivityLog, Fr as fullProfileMaterialization, G as meterRuntimeOwnedProviderAttempt, Gn as undispatchedCredentialExit, Gr as attestRuntimeOwnedScopeOwner, Hn as causedByPartialFailure, Hr as unsupportedProfileDimensions, I as providerVisibleProfile, Ir as profileMaterializationAxes$1, It as toolResultText, J as recordScopeOwnerPause, Jn as SeatChainExhaustedError, K as recordScopeOwnerBarrenPause, Kn as upstreamUnavailableSignal, Kr as authoredAgentIdentity, L as runtimeGraphMetadataKey, Ln as isLiveNodeStatus, Lr as promptControlProfileMaterialization, Lt as createRouterTranscript, M as restoreScopeOwnerAcceptedExecution, Mt as codeModeArguments, N as scopeOwnerExecutorNodeContext, Nr as controlProfileMaterialization, Nt as codeModeModelOutput, P as coordinationMcpAlias, Pr as defineProfileMaterializationContract, Pt as createCodeModeTools, Qn as CheckUnavailableError, Rn as isTerminalNodeStatus, Rr as promptModelProfileMaterialization, Rt as routerBrain, Sn as INBOX_RECEIPT_KEY, Un as classifyDriverFailure, Ur as worktreeCliProfileMaterialization, Vn as abandonablePending, Vr as sandboxProfileMaterialization, W as meterRuntimeOwnedAccounting, Wn as summarizeDriverAttempts, X as scopeRetainedOwnerResourceReader, Xn as seatExecutionProfile, Y as prepareScopeRetainedOwnerSeatSwitch, Yn as authoredSeatStages, Yr as inheritRuntimeOwnedExecutorAttestation, a as assertRunParking, ai as runtimeOwnedPendingExecutorMaterialization, ar as bestComposite, at as scopeRetainedOwnerTurnEnded, br as linkAbort, bt as createExecutor, c as sleepScopeWait, ct as noteScopeRetainedOwnerCoordination, d as runFinalizer, di as isRuntimeFlowBrain, dr as bridgeModelRouteRefusal, dt as scopeRetainedOwnerContext, ei as recordRuntimeOwnedDriveHarnessProviderEvidence, en as readHarnessTranscript, et as consumeScopeRetainedOwnerResult, f as runTree, fi as runtimeFlowAgent, ft as scopeRetainedOwnerJournalRoot, g as isDriverSpec, gn as generateSpanId, h as driverExecutorFactory, i as RunParkedError, ii as runtimeOwnedExecutorProviderEvidence, ir as admitContinuationPolicy, it as beginScopeRetainedOwnerDrive, j as recordScopeOwnerMaterialization, jr as assertProfileMaterialization, k as beginScopeOwnerAttempt, l as withRunParking, lt as bindScopeRetainedOwnerEnvironmentId, m as driverChild, mn as createOtelExporter, n as createSupervisor, ni as runtimeOwnedExecutorExecutionBinding, nt as scopeRetainedOwnerPriorSpend, o as bindScopeParkingDrain, oi as runtimeOwnedScopeOwnerRuntime, or as checkVerdictOf, ot as reconcileScopeRetainedOwnerEnvironment, p as createRootHandle, pi as runtimeFlowBrain, q as recordScopeOwnerDriverAttempt, qn as SeatChain, ri as runtimeOwnedExecutorMaterialization, rr as CONTINUATIONS_DIR, rt as scopeRetainedOwnerResult, sn as WORKER_TRACE_PROPAGATION, sr as createContinuationKeeper, st as scopeRetainedOwnerRestorePoint, ti as runtimeOwnedDriveHarnessProviderEvidence, tt as prepareScopeRetainedOwnerTask, u as bestDelivered, ur as bridgeAdmissionRefusal, ut as bindScopeRetainedOwnerProvider, vt as bindReusableExecutorExecutionId, wr as bridgeStopSignalKey, x as parseWorkerToolTraceArtifact, xr as runAbortable, xt as snapshotExecutorConfig, yr as RunCancellationReason, yt as captureReusableExecutorConfig, z as assertRecursiveReservationPolicy, zn as DriverAttemptsExhaustedError, zr as renderUnsupported } from "./supervisor-BsW69Ccw.js";
2
2
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-AzSuGI23.js";
3
3
  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-BX20UJ9X.js";
4
- import { $ as newUsageTotals, D as registerRetainedExecutorPreparation, F as unavailablePauseMs, H as contentAddress, I as unavailableResumeAt, N as cappedDoublingMs, P as jitteredMs, Q as meterUsageEvent, S as RetainedExecutionPendingError, W as executorFailure, k as retainedExecutorSeamKey, nt as assertValidBudget, tt as spendFromUsageTotals } from "./journal-store-BpCOCDoO.js";
5
- import { d as detachedSnapshot, i as prepareJsonlAppend, m as errMessage, n as isNoEntError, o as readCommittedJsonLines } from "./jsonl-file-BBP9Dz9w.js";
4
+ import { G as RetainedExecutionPendingError, Q as retainedExecutorSeamKey, St as newUsageTotals, Tt as assertValidBudget, X as registerRetainedExecutorPreparation, at as unavailableResumeAt, dt as contentAddress, i as readRootStream, it as unavailablePauseMs, n as createRootStreamSink, nt as cappedDoublingMs, pt as executorFailure, rt as jitteredMs, t as ROOT_STREAM_FILE, wt as spendFromUsageTotals, xt as meterUsageEvent } from "./root-stream-To4qAc0e.js";
5
+ import { d as detachedSnapshot, m as errMessage } from "./jsonl-file-BBP9Dz9w.js";
6
6
  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";
7
- import { n as assertNoSymlinkDescendant, o as captureRunWriteContext, s as fenceRunWrite } from "./durable-file-DstVeHcj.js";
8
7
  import { t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
9
- import { c as createSteerAcknowledger, d as coordinationVerbNames, f as createFileRunContext, l as budgetOverspendText, m as withRunContext, n as createCoordinationToolsForManager, p as createInMemoryRunContext, s as createCancelAcknowledger, t as createCoordinationTools, u as normalizeAnalyzeOnSettle } from "./coordination-manager-COU_d7WX.js";
10
- import { c as writeRunCancellation, i as readRunCancellation, r as readRunCancelRequest, s as watchRunCancellation, t as applyRunCancellation } from "./run-cancellation-Cpm-BIUu.js";
8
+ import { c as createSteerAcknowledger, d as coordinationVerbNames, f as createFileRunContext, l as budgetOverspendText, m as withRunContext, n as createCoordinationToolsForManager, p as createInMemoryRunContext, s as createCancelAcknowledger, t as createCoordinationTools, u as normalizeAnalyzeOnSettle } from "./coordination-manager-CqZGCqjV.js";
9
+ import { c as writeRunCancellation, i as readRunCancellation, r as readRunCancelRequest, s as watchRunCancellation, t as applyRunCancellation } from "./run-cancellation-BhP0Nw6G.js";
11
10
  import { o as safeJsonText } from "./coordination-map-routing-CUvwHAtv.js";
12
11
  import { n as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-CZWd_Opp.js";
13
12
  import { a as graphRegistry, c as loadGraph } from "./graph-registry-72DlMnUl.js";
@@ -16,9 +15,7 @@ import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDige
16
15
  import { toolSpansToTraceAnalysisStore } from "@tangle-network/agent-eval";
17
16
  import { isRecord } from "@tangle-network/agent-core";
18
17
  import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
19
- import { closeSync, constants, fsyncSync, openSync, writeSync } from "node:fs";
20
18
  import { dirname, resolve } from "node:path";
21
- import { mkdir } from "node:fs/promises";
22
19
  import { isMaterializerHarness } from "@tangle-network/agent-profile-materialize";
23
20
  import { createServer } from "node:http";
24
21
  import { msToUnixNano, toOtlpAttributes } from "@tangle-network/agent-trace-contract/otlp";
@@ -754,181 +751,6 @@ function str(value) {
754
751
  function truncate(value) {
755
752
  return value.length > MAX_DETAIL_CHARS ? `${value.slice(0, MAX_DETAIL_CHARS)}…` : value;
756
753
  }
757
- // src/runtime/supervise/root-stream.ts
758
- /**
759
- * The root manager's own provider stream, retained where Runtime owns it.
760
- *
761
- * Measured motive (agent-runtime#1233): a CHILD's full event stream — reasoning, text,
762
- * and tool parts, 28k to 76k reasoning characters per child — is retained in the blob its
763
- * `settled` record names as `outRef`. The ROOT's stream reached nobody: `driveHarnessFromBackend`
764
- * drained the root executor for accounting and discarded every `progress` event, and on a
765
- * `winner` run `result.outRef` is the SELECTED CHILD's artifact, not the root's. A root that died
766
- * at its join barrier (fourier-e, 63 children) left a 607-byte `failure.json` and nothing it
767
- * thought; the Lab's only transcript of a root was a post-hoc scrape of the harness's own
768
- * database.
769
- *
770
- * `<runDir>/root-stream.jsonl` is the record: one JSONL line per `ExecutorProgressEvent`, written
771
- * AS IT ARRIVES, so a root whose process is killed mid-turn keeps every line already written. The
772
- * file itself is the evidence; the receipt (`ref`, the content address of the file's bytes, and
773
- * `events`, its committed line count) is what `result.json` and `failure.json` carry. The winner's
774
- * `outRef` keeps its meaning; this is a separate reference.
775
- *
776
- * Durability boundary: each line is written synchronously to an `O_APPEND` descriptor before the
777
- * next event is drained, and the file is fsynced at every drive-attempt boundary and at close, not
778
- * per line. An fsync per line cost 7.1 ms per event over
779
- * 1,000 events and 8.1 ms over 5,000 (~80 s for a root emitting ten thousand text deltas, all of
780
- * it serialized inside the drain loop that also meters the budget); an async `FileHandle.write`
781
- * still cost 0.9 to 1.1 ms per line in the thread pool the children's journal writes share; a
782
- * `writeSync` costs 6 µs. A process kill loses nothing written; only a kernel crash or power
783
- * loss can drop lines written since the last fsync, and the reader's torn-tail rule keeps such a
784
- * file readable.
785
- *
786
- * The bridge wire carries text and tool calls only: cli-bridge's SSE frames decode
787
- * `delta.content` and `delta.tool_calls`, never a reasoning delta. A bridge-placed root's retained
788
- * stream is therefore text plus tool calls; reasoning arrives only on the provider/sandbox path,
789
- * which projects `message.part.updated` reasoning parts to `reasoning_delta`.
790
- */
791
- /** The root stream: one JSONL line per progress event the root's executor observed. */
792
- const ROOT_STREAM_FILE = "root-stream.jsonl";
793
- /** Create the writer for `<runDir>/root-stream.jsonl`. Nothing touches disk until the first
794
- * `beginAttempt`, so a run whose root never drives leaves no file and no receipt. */
795
- function createRootStreamSink(runDir, now) {
796
- const withClaim = captureRunWriteContext();
797
- const dir = resolve(runDir);
798
- const path = resolve(dir, ROOT_STREAM_FILE);
799
- let fd;
800
- let attempt = 0;
801
- let seq = 0;
802
- let closed = false;
803
- const openOnce = async () => {
804
- if (fd !== void 0) return;
805
- await mkdir(dir, { recursive: true });
806
- assertNoSymlinkDescendant(dir, path, "root stream");
807
- const needsSeparator = await prepareJsonlAppend(path);
808
- seq = 0;
809
- for await (const _record of readCommittedJsonLines(path, { allowMissing: true })) seq += 1;
810
- fd = fenceRunWrite(() => {
811
- const writer = openSync(path, constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY | (typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0), 384);
812
- try {
813
- if (needsSeparator) writeLine(writer, "");
814
- return writer;
815
- } catch (error) {
816
- closeSync(writer);
817
- throw error;
818
- }
819
- });
820
- };
821
- return {
822
- async beginAttempt() {
823
- return withClaim(async () => {
824
- if (closed) throw new Error("root stream: beginAttempt after close");
825
- attempt += 1;
826
- const writer = fd;
827
- if (writer !== void 0) fenceRunWrite(() => fsyncSync(writer));
828
- await openOnce();
829
- });
830
- },
831
- append(event) {
832
- return withClaim(() => fenceRunWrite(() => {
833
- if (closed) throw new Error("root stream: append after close");
834
- if (fd === void 0) throw new Error("root stream: append before beginAttempt");
835
- const at = new Date(now()).toISOString();
836
- const record = {
837
- seq: seq + 1,
838
- at,
839
- attempt,
840
- event
841
- };
842
- let line;
843
- try {
844
- line = JSON.stringify(record);
845
- } catch (error) {
846
- line = JSON.stringify({
847
- seq: seq + 1,
848
- at,
849
- attempt,
850
- dropped: {
851
- kind: event.kind,
852
- reason: errorMessage(error)
853
- }
854
- });
855
- }
856
- if (line === void 0) line = JSON.stringify({
857
- seq: seq + 1,
858
- at,
859
- attempt,
860
- dropped: {
861
- kind: event.kind,
862
- reason: "event serialized to nothing"
863
- }
864
- });
865
- writeLine(fd, line);
866
- seq += 1;
867
- }));
868
- },
869
- async close() {
870
- return withClaim(async () => {
871
- if (closed) throw new Error("root stream: closed twice");
872
- closed = true;
873
- const writer = fd;
874
- if (writer === void 0) return void 0;
875
- try {
876
- fenceRunWrite(() => fsyncSync(writer));
877
- } finally {
878
- closeSync(writer);
879
- fd = void 0;
880
- }
881
- return readRootStreamReceipt(dir);
882
- });
883
- }
884
- };
885
- }
886
- /** `writeSync` may legally make a short write; loop until the whole line and its newline land. */
887
- function writeLine(fd, line) {
888
- const bytes = Buffer.from(`${line}\n`, "utf8");
889
- let offset = 0;
890
- while (offset < bytes.byteLength) {
891
- const written = writeSync(fd, bytes, offset, bytes.byteLength - offset);
892
- if (written <= 0) throw new Error(`root stream: append made no progress at byte ${offset}`);
893
- offset += written;
894
- }
895
- }
896
- /**
897
- * The receipt for the root stream a run directory holds, recomputed from the file's bytes, or
898
- * `undefined` when the directory holds none. This is what a run that never settled — a root that
899
- * died mid-turn — gets on its failure record, and it equals what `close()` returned for a run
900
- * that did.
901
- */
902
- async function readRootStreamReceipt(runDir) {
903
- const path = resolve(runDir, ROOT_STREAM_FILE);
904
- const hash = createHash("sha256");
905
- let events = 0;
906
- try {
907
- for await (const _record of readCommittedJsonLines(path, { onBytes: (bytes) => {
908
- hash.update(bytes);
909
- } })) events += 1;
910
- } catch (error) {
911
- if (isNoEntError(error)) return void 0;
912
- throw error;
913
- }
914
- return Object.freeze({
915
- ref: `sha256:${hash.digest("hex")}`,
916
- events
917
- });
918
- }
919
- /** Every committed line of the root stream, in order, or `undefined` when there is no file. A
920
- * torn final line from a process that died mid-write is not a record and is left out. */
921
- async function readRootStream(runDir) {
922
- const path = resolve(runDir, ROOT_STREAM_FILE);
923
- const records = [];
924
- try {
925
- for await (const record of readCommittedJsonLines(path)) records.push(record);
926
- } catch (error) {
927
- if (isNoEntError(error)) return void 0;
928
- throw error;
929
- }
930
- return records;
931
- }
932
754
  // src/runtime/anytime.ts
933
755
  /**
934
756
  * The best-so-far fold — the ONE definition of "how good was the run after k results", shared by
@@ -6025,14 +5847,20 @@ async function workerSpans(worker, blobs) {
6025
5847
  }));
6026
5848
  }
6027
5849
  /**
6028
- * The store over a manager's run: its own root stream when it has one, and every settled worker's
6029
- * tool trace. `undefined` when the run has recorded no span yet, which is not a store a panel can
6030
- * read: agent-eval refuses an empty trace, because it cannot tell a tool-free run from a failed
6031
- * capture.
5850
+ * Every span of a manager's run: its own root stream, then each settled worker's tool trace. A
5851
+ * worker trace the blob store lost throws, because missing evidence is not an empty trace.
6032
5852
  */
6033
- async function runTraceAnalysisStore(input) {
5853
+ async function runToolSpans(input) {
6034
5854
  const records = input.root === void 0 ? void 0 : await input.root.read();
6035
- 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()];
5855
+ return [...records === void 0 || input.root === void 0 ? [] : rootStreamToolSpans(records, input.root.id), ...(await Promise.all(input.workers.map((worker) => workerSpans(worker, input.blobs)))).flat()];
5856
+ }
5857
+ /**
5858
+ * The store over a manager's run. `undefined` when the run has recorded no span yet, which is not a
5859
+ * store a panel can read: agent-eval refuses an empty trace, because it cannot tell a tool-free run
5860
+ * from a failed capture.
5861
+ */
5862
+ async function runTraceAnalysisStore(input) {
5863
+ const spans = await runToolSpans(input);
6036
5864
  return spans.length === 0 ? void 0 : toolSpansToTraceAnalysisStore(spans);
6037
5865
  }
6038
5866
  // src/runtime/supervise/supervisor-manager-turns.ts
@@ -9590,6 +9418,6 @@ function superviseWithContext(profile, task, opts, brain) {
9590
9418
  ...signal === void 0 ? {} : { signal }
9591
9419
  }, brain));
9592
9420
  }
9593
- export { createPromptRegistry as A, noProgressFor as B, journaledGateDecider as C, graphRootProfile as D, defaultEdgeTraversalCap as E, kernelPromptRegistry as F, plateauLength as G, anytimeReport as H, naiveContinuationPrompt as I, readRootStreamReceipt as J, renderAnytimeTable as K, promptHandle as L, dumbContinuationFailPrompt as M, dumbContinuationPassPrompt as N, validateGraphTopology as O, formatPromptHandle as P, allWorkersStalled as R, flowRootProfile as S, validateFlowGraph as T, areaUnderCurve as U, plateau as V, bestSoFar as W, createSupervisorSpanRecorder as Y, driverAgent as _, superviseRootProfile as a, GraphRouteError as b, retryPreSpawnRefusals as c, supervisorAgent as d, supervisorAgentWithTestBrain as f, coordinationControlToolNames as g, serveCoordinationMcp as h, profileGuidanceComposer as i, delegatesWorkerBriefPrompt as j, analyzesFindingsReportPrompt as k, withWorkerSpawnRetry as l, composeReentryTask as m, superviseFleetCapabilities as n, isPreSpawnExecutorFailure as o, UNPROVEN_CONTINUITY as p, readRootStream as q, superviseWithTestBrain as r, resolveWorkerSpawnRetry as s, supervise as t, workerFromBackend as u, runBrainLoop as v, routeFlowOf as w, createFlowRun as x, createGraphOverlay as y, anyOf as z };
9421
+ export { analyzesFindingsReportPrompt as A, anyOf as B, flowRootProfile as C, defaultEdgeTraversalCap as D, validateFlowGraph as E, formatPromptHandle as F, bestSoFar as G, plateau as H, kernelPromptRegistry as I, createSupervisorSpanRecorder as J, plateauLength as K, naiveContinuationPrompt as L, delegatesWorkerBriefPrompt as M, dumbContinuationFailPrompt as N, graphRootProfile as O, dumbContinuationPassPrompt as P, promptHandle as R, createFlowRun as S, routeFlowOf as T, anytimeReport as U, noProgressFor as V, areaUnderCurve as W, coordinationControlToolNames as _, superviseRootProfile as a, createGraphOverlay as b, retryPreSpawnRefusals as c, supervisorAgent as d, supervisorAgentWithTestBrain as f, serveCoordinationMcp as g, composeReentryTask as h, profileGuidanceComposer as i, createPromptRegistry as j, validateGraphTopology as k, withWorkerSpawnRetry as l, UNPROVEN_CONTINUITY as m, superviseFleetCapabilities as n, isPreSpawnExecutorFailure as o, runToolSpans as p, renderAnytimeTable as q, superviseWithTestBrain as r, resolveWorkerSpawnRetry as s, supervise as t, workerFromBackend as u, driverAgent as v, journaledGateDecider as w, GraphRouteError as x, runBrainLoop as y, allWorkersStalled as z };
9594
9422
 
9595
- //# sourceMappingURL=supervise-zs42gsTU.js.map
9423
+ //# sourceMappingURL=supervise-BtjM7_0G.js.map