@tangle-network/agent-runtime 0.225.5 → 0.226.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 (51) hide show
  1. package/dist/{activation-Boyh7-Bk.js → activation-BOIqqsCw.js} +2 -2
  2. package/dist/{activation-Boyh7-Bk.js.map → activation-BOIqqsCw.js.map} +1 -1
  3. package/dist/{activation-CsfCkAdZ.d.ts → activation-Dv8TBXAS.d.ts} +2 -2
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +2 -2
  6. package/dist/{coordination-driver-B5NtPTE1.js → coordination-driver-DxHQLK8i.js} +2 -2
  7. package/dist/{coordination-driver-B5NtPTE1.js.map → coordination-driver-DxHQLK8i.js.map} +1 -1
  8. package/dist/{delegate-DRVxCsVg.js → delegate-DHpAEq6-.js} +2 -2
  9. package/dist/{delegate-DRVxCsVg.js.map → delegate-DHpAEq6-.js.map} +1 -1
  10. package/dist/durable.d.ts +39 -3
  11. package/dist/durable.js +7 -5
  12. package/dist/durable.js.map +1 -1
  13. package/dist/{graph-BweGIXuL.js → graph-BkeA7dEi.js} +3 -3
  14. package/dist/{graph-BweGIXuL.js.map → graph-BkeA7dEi.js.map} +1 -1
  15. package/dist/{improvement-cycle-DCKn8HT0.js → improvement-cycle-B9gBkr_0.js} +3 -3
  16. package/dist/{improvement-cycle-DCKn8HT0.js.map → improvement-cycle-B9gBkr_0.js.map} +1 -1
  17. package/dist/{index-ClXIBpKe.d.ts → index-DAIij88v.d.ts} +10 -2
  18. package/dist/index.d.ts +4 -4
  19. package/dist/index.js +7 -7
  20. package/dist/intelligence.d.ts +2 -2
  21. package/dist/intelligence.js +3 -3
  22. package/dist/kernel.d.ts +3 -3
  23. package/dist/kernel.js +8 -8
  24. package/dist/{loop-runner-bin-DXzs4Rjq.js → loop-runner-bin-B0nQvskW.js} +3 -3
  25. package/dist/{loop-runner-bin-DXzs4Rjq.js.map → loop-runner-bin-B0nQvskW.js.map} +1 -1
  26. package/dist/{loop-runner-bin-BRfsk-9d.d.ts → loop-runner-bin-CN1rstwC.d.ts} +3 -3
  27. package/dist/loop-runner-bin.d.ts +1 -1
  28. package/dist/loop-runner-bin.js +1 -1
  29. package/dist/mcp/bin.js +3 -3
  30. package/dist/mcp/index.d.ts +2 -2
  31. package/dist/mcp/index.js +4 -4
  32. package/dist/{provision-supervisor-B0BFvUQ1.js → provision-supervisor-Dfuc4gK0.js} +3 -3
  33. package/dist/{provision-supervisor-B0BFvUQ1.js.map → provision-supervisor-Dfuc4gK0.js.map} +1 -1
  34. package/dist/{runtime-BuAJH9FK.js → runtime-Dqik43o3.js} +8 -8
  35. package/dist/{runtime-BuAJH9FK.js.map → runtime-Dqik43o3.js.map} +1 -1
  36. package/dist/{server-_U6iIJkV.js → server-C12kUoSM.js} +3 -3
  37. package/dist/{server-_U6iIJkV.js.map → server-C12kUoSM.js.map} +1 -1
  38. package/dist/{stream-agent-turn-wlsHQiUv.d.ts → stream-agent-turn-Dy-QleSb.d.ts} +22 -2
  39. package/dist/{structural-rollout-DDjlhogU.js → structural-rollout-Zog2WEZo.js} +2 -2
  40. package/dist/{structural-rollout-DDjlhogU.js.map → structural-rollout-Zog2WEZo.js.map} +1 -1
  41. package/dist/{supervise-qYms7HSb.js → supervise-CtXJ-lWb.js} +180 -10
  42. package/dist/supervise-CtXJ-lWb.js.map +1 -0
  43. package/dist/{supervisor-D1j1RRJy.js → supervisor-DCQxXRR8.js} +1 -6
  44. package/dist/supervisor-DCQxXRR8.js.map +1 -0
  45. package/dist/testing.d.ts +2 -2
  46. package/dist/testing.js +12 -12
  47. package/dist/tui/index.d.ts +1 -1
  48. package/dist/tui/index.js +1 -1
  49. package/package.json +1 -1
  50. package/dist/supervise-qYms7HSb.js.map +0 -1
  51. package/dist/supervisor-D1j1RRJy.js.map +0 -1
@@ -1,13 +1,16 @@
1
- import { $n as generateSpanId, $r as runtimeOwnedExecutorProviderEvidence, Ai as sleep, At as WORKER_TRACE_PROPAGATION, C as scopeOwnerExecutorNodeContext, Cr as defineProfileMaterializationContract, Dn as registerRetainedExecutorPreparation, Dr as promptModelProfileMaterialization, Dt as newUsageTotals, Er as promptControlProfileMaterialization, Et as meterUsageEvent, F as scopeRetainedOwnerResult, Fi as withTimeout, Fr as worktreeCliProfileMaterialization, Gi as teardownExecutor, Ii as zeroSpend, Jr as providerAttemptEvidence, Li as addResourceSpend, M as prepareScopeRetainedOwnerTask, Mn as runAbortable, N as scopeRetainedOwnerContext, Nr as unsupportedProfileDimensions, On as retainedExecutorSeamKey, P as scopeRetainedOwnerPriorSpend, Pi as unmeteredSpend, Q as captureReusableExecutorConfig, Qr as runtimeOwnedExecutorMaterialization, Ri as resourceTelemetry, S as restoreScopeOwnerAcceptedExecution, Si as addSpend, Sn as resolveAgentEnvironmentProvider, Sr as controlProfileMaterialization, St as contentAddress, Tr as profileMaterializationAxes$1, Ui as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, Vr as attestRuntimeOwnedScopeOwner, Wr as inheritRuntimeOwnedExecutorAttestation, Xn as createOtelExporter, Xr as runtimeOwnedDriveHarnessProviderEvidence, Xt as bridgeAdmissionRefusal, Yr as recordRuntimeOwnedDriveHarnessProviderEvidence, Z as bindReusableExecutorExecutionId, Zr as runtimeOwnedExecutorExecutionBinding, Zt as bridgeModelRouteRefusal, b as meterRuntimeOwnedProviderAttempt, d as runDriverWithRetry, ei as runtimeOwnedPendingExecutorMaterialization, f as driverChild, g as beginScopeOwnerAttempt, j as consumeScopeRetainedOwnerResult, jr as renderUnsupported, kn as RunCancellationReason, kt as spendFromUsageTotals, m as isDriverSpec, mn as routerBrain, n as createSupervisor, nn as bridgeRuntimeAttachmentsKey, o as runFinalizer, p as driverExecutorFactory, r as bestDelivered, rn as bridgeStopSignalKey, rr as toOtelAttributes, rt as snapshotExecutorConfig, s as runTree, si as detachedSnapshot, t as createRootHandle, ti as runtimeOwnedScopeOwnerRuntime, tt as createExecutor, u as defaultUnmetContractSteer, v as deriveNodeExecutionIdentity, wr as fullProfileMaterialization, wt as assertValidBudget, x as recordScopeOwnerMaterialization, xr as assertProfileMaterialization, y as meterRuntimeOwnedAccounting, zi as withBudgetResources, zt as createInbox } from "./supervisor-D1j1RRJy.js";
1
+ import { $n as generateSpanId, $r as runtimeOwnedExecutorProviderEvidence, Ai as sleep, At as WORKER_TRACE_PROPAGATION, C as scopeOwnerExecutorNodeContext, Cr as defineProfileMaterializationContract, Dn as registerRetainedExecutorPreparation, Dr as promptModelProfileMaterialization, Dt as newUsageTotals, Er as promptControlProfileMaterialization, Et as meterUsageEvent, F as scopeRetainedOwnerResult, Fi as withTimeout, Fr as worktreeCliProfileMaterialization, Gi as teardownExecutor, Ii as zeroSpend, Ir as isNoEntError, Jr as providerAttemptEvidence, Li as addResourceSpend, Lr as parseCommittedJsonLines, M as prepareScopeRetainedOwnerTask, Mn as runAbortable, N as scopeRetainedOwnerContext, Nr as unsupportedProfileDimensions, On as retainedExecutorSeamKey, P as scopeRetainedOwnerPriorSpend, Pi as unmeteredSpend, Q as captureReusableExecutorConfig, Qr as runtimeOwnedExecutorMaterialization, Ri as resourceTelemetry, Rr as prepareJsonlAppend, S as restoreScopeOwnerAcceptedExecution, Si as addSpend, Sn as resolveAgentEnvironmentProvider, Sr as controlProfileMaterialization, St as contentAddress, Tr as profileMaterializationAxes$1, Ui as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, Vr as attestRuntimeOwnedScopeOwner, Wr as inheritRuntimeOwnedExecutorAttestation, Xn as createOtelExporter, Xr as runtimeOwnedDriveHarnessProviderEvidence, Xt as bridgeAdmissionRefusal, Yr as recordRuntimeOwnedDriveHarnessProviderEvidence, Z as bindReusableExecutorExecutionId, Zr as runtimeOwnedExecutorExecutionBinding, Zt as bridgeModelRouteRefusal, b as meterRuntimeOwnedProviderAttempt, d as runDriverWithRetry, ei as runtimeOwnedPendingExecutorMaterialization, f as driverChild, g as beginScopeOwnerAttempt, j as consumeScopeRetainedOwnerResult, jr as renderUnsupported, kn as RunCancellationReason, kt as spendFromUsageTotals, m as isDriverSpec, mn as routerBrain, n as createSupervisor, nn as bridgeRuntimeAttachmentsKey, o as runFinalizer, p as driverExecutorFactory, r as bestDelivered, rn as bridgeStopSignalKey, rr as toOtelAttributes, rt as snapshotExecutorConfig, s as runTree, si as detachedSnapshot, t as createRootHandle, ti as runtimeOwnedScopeOwnerRuntime, tt as createExecutor, u as defaultUnmetContractSteer, v as deriveNodeExecutionIdentity, wr as fullProfileMaterialization, wt as assertValidBudget, x as recordScopeOwnerMaterialization, xr as assertProfileMaterialization, y as meterRuntimeOwnedAccounting, zi as withBudgetResources, zt as createInbox } from "./supervisor-DCQxXRR8.js";
2
2
  import { i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
3
3
  import { a as concreteProfileModel, c as profileModelExecutionSettings, d as agentHarness, f as harnessRunsAgent, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile } from "./model-policy-BbSCSak0.js";
4
4
  import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
5
+ import { n as assertNoSymlinkDescendant } from "./durable-file-D24y9zg7.js";
5
6
  import { t as createStdioToolServer } from "./tool-server-BJbCPhoW.js";
6
- import { D as coordinationVerbNames, O as createCoordinationTools, S as watchRunCancellation, c as createProgressTracker, d as progressStop, r as driverAgent, v as createFileRunContext, w as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, x as applyRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-B5NtPTE1.js";
7
+ import { D as coordinationVerbNames, O as createCoordinationTools, S as watchRunCancellation, c as createProgressTracker, d as progressStop, r as driverAgent, v as createFileRunContext, w as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, x as applyRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-DxHQLK8i.js";
7
8
  import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-hZREkcfu.js";
8
9
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
9
10
  import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
11
+ import { closeSync, constants, fsyncSync, openSync, writeSync } from "node:fs";
10
12
  import { resolve } from "node:path";
13
+ import { mkdir, readFile } from "node:fs/promises";
11
14
  import { isMaterializerHarness } from "@tangle-network/agent-profile-materialize";
12
15
  import { createServer } from "node:http";
13
16
  //#region src/runtime/supervise/completion-gate.ts
@@ -1084,6 +1087,164 @@ function truncate(value) {
1084
1087
  return value.length > MAX_DETAIL_CHARS ? `${value.slice(0, MAX_DETAIL_CHARS)}…` : value;
1085
1088
  }
1086
1089
  //#endregion
1090
+ //#region src/runtime/supervise/root-stream.ts
1091
+ /**
1092
+ * The root manager's own provider stream, retained where Runtime owns it.
1093
+ *
1094
+ * Measured motive (agent-runtime#1233, 2026-09-15): a CHILD's full event stream — reasoning, text,
1095
+ * and tool parts, 28k to 76k reasoning characters per child — is retained in the blob its
1096
+ * `settled` record names as `outRef`. The ROOT's stream reached nobody: `driveHarnessFromBackend`
1097
+ * drained the root executor for accounting and discarded every `progress` event, and on a
1098
+ * `winner` run `result.outRef` is the SELECTED CHILD's artifact, not the root's. A root that died
1099
+ * at its join barrier (fourier-e, 63 children) left a 607-byte `failure.json` and nothing it
1100
+ * thought; the Lab's only transcript of a root was a post-hoc scrape of the harness's own
1101
+ * database.
1102
+ *
1103
+ * `<runDir>/root-stream.jsonl` is the record: one JSONL line per `ExecutorProgressEvent`, written
1104
+ * AS IT ARRIVES, so a root whose process is killed mid-turn keeps every line already written. The
1105
+ * file itself is the evidence; the receipt (`ref`, the content address of the file's bytes, and
1106
+ * `events`, its committed line count) is what `result.json` and `failure.json` carry. The winner's
1107
+ * `outRef` keeps its meaning; this is a separate reference.
1108
+ *
1109
+ * Durability boundary: each line is written synchronously to an `O_APPEND` descriptor before the
1110
+ * next event is drained, and the file is fsynced at every drive-attempt boundary and at close, not
1111
+ * per line. Measured 2026-09-15 on this host's APFS: an fsync per line cost 7.1 ms per event over
1112
+ * 1,000 events and 8.1 ms over 5,000 (~80 s for a root emitting ten thousand text deltas, all of
1113
+ * it serialized inside the drain loop that also meters the budget); an async `FileHandle.write`
1114
+ * still cost 0.9 to 1.1 ms per line in the thread pool the children's journal writes share; a
1115
+ * `writeSync` costs 6 µs. A process kill loses nothing written; only a kernel crash or power
1116
+ * loss can drop lines written since the last fsync, and the reader's torn-tail rule keeps such a
1117
+ * file readable.
1118
+ *
1119
+ * The bridge wire carries text and tool calls only: cli-bridge's SSE frames decode
1120
+ * `delta.content` and `delta.tool_calls`, never a reasoning delta. A bridge-placed root's retained
1121
+ * stream is therefore text plus tool calls; reasoning arrives only on the provider/sandbox path,
1122
+ * which projects `message.part.updated` reasoning parts to `reasoning_delta`.
1123
+ */
1124
+ /** The root stream: one JSONL line per progress event the root's executor observed. */
1125
+ const ROOT_STREAM_FILE = "root-stream.jsonl";
1126
+ /** Create the writer for `<runDir>/root-stream.jsonl`. Nothing touches disk until the first
1127
+ * `beginAttempt`, so a run whose root never drives leaves no file and no receipt. */
1128
+ function createRootStreamSink(runDir, now) {
1129
+ const dir = resolve(runDir);
1130
+ const path = resolve(dir, ROOT_STREAM_FILE);
1131
+ let fd;
1132
+ let attempt = 0;
1133
+ let seq = 0;
1134
+ let closed = false;
1135
+ const openOnce = async () => {
1136
+ if (fd !== void 0) return;
1137
+ await mkdir(dir, { recursive: true });
1138
+ assertNoSymlinkDescendant(dir, path, "root stream");
1139
+ const needsSeparator = await prepareJsonlAppend(path);
1140
+ seq = (await readRootStream(dir) ?? []).length;
1141
+ fd = openSync(path, constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY | (typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0), 384);
1142
+ if (needsSeparator) writeLine(fd, "");
1143
+ };
1144
+ return {
1145
+ async beginAttempt() {
1146
+ if (closed) throw new Error("root stream: beginAttempt after close");
1147
+ attempt += 1;
1148
+ if (fd !== void 0) fsyncSync(fd);
1149
+ await openOnce();
1150
+ },
1151
+ append(event) {
1152
+ if (closed) throw new Error("root stream: append after close");
1153
+ if (fd === void 0) throw new Error("root stream: append before beginAttempt");
1154
+ const at = new Date(now()).toISOString();
1155
+ const record = {
1156
+ seq: seq + 1,
1157
+ at,
1158
+ attempt,
1159
+ event
1160
+ };
1161
+ let line;
1162
+ try {
1163
+ line = JSON.stringify(record);
1164
+ } catch (error) {
1165
+ line = JSON.stringify({
1166
+ seq: seq + 1,
1167
+ at,
1168
+ attempt,
1169
+ dropped: {
1170
+ kind: event.kind,
1171
+ reason: errorMessage(error)
1172
+ }
1173
+ });
1174
+ }
1175
+ if (line === void 0) line = JSON.stringify({
1176
+ seq: seq + 1,
1177
+ at,
1178
+ attempt,
1179
+ dropped: {
1180
+ kind: event.kind,
1181
+ reason: "event serialized to nothing"
1182
+ }
1183
+ });
1184
+ writeLine(fd, line);
1185
+ seq += 1;
1186
+ },
1187
+ async close() {
1188
+ if (closed) throw new Error("root stream: closed twice");
1189
+ closed = true;
1190
+ if (fd === void 0) return void 0;
1191
+ try {
1192
+ fsyncSync(fd);
1193
+ } finally {
1194
+ closeSync(fd);
1195
+ fd = void 0;
1196
+ }
1197
+ return readRootStreamReceipt(dir);
1198
+ }
1199
+ };
1200
+ }
1201
+ /** `writeSync` may legally make a short write; loop until the whole line and its newline land. */
1202
+ function writeLine(fd, line) {
1203
+ const bytes = Buffer.from(`${line}\n`, "utf8");
1204
+ let offset = 0;
1205
+ while (offset < bytes.byteLength) {
1206
+ const written = writeSync(fd, bytes, offset, bytes.byteLength - offset);
1207
+ if (written <= 0) throw new Error(`root stream: append made no progress at byte ${offset}`);
1208
+ offset += written;
1209
+ }
1210
+ }
1211
+ /**
1212
+ * The receipt for the root stream a run directory holds, recomputed from the file's bytes, or
1213
+ * `undefined` when the directory holds none. This is what a run that never settled — a root that
1214
+ * died mid-turn — gets on its failure record, and it equals what `close()` returned for a run
1215
+ * that did.
1216
+ */
1217
+ async function readRootStreamReceipt(runDir) {
1218
+ const path = resolve(runDir, ROOT_STREAM_FILE);
1219
+ let bytes;
1220
+ try {
1221
+ bytes = await readFile(path);
1222
+ } catch (error) {
1223
+ if (isNoEntError(error)) return void 0;
1224
+ throw error;
1225
+ }
1226
+ return Object.freeze({
1227
+ ref: `sha256:${createHash("sha256").update(bytes).digest("hex")}`,
1228
+ events: parseCommittedJsonLines(bytes.toString("utf8"), path).length
1229
+ });
1230
+ }
1231
+ /** Every committed line of the root stream, in order, or `undefined` when there is no file. A
1232
+ * torn final line from a process that died mid-write is not a record and is left out. */
1233
+ async function readRootStream(runDir) {
1234
+ const path = resolve(runDir, ROOT_STREAM_FILE);
1235
+ let text;
1236
+ try {
1237
+ text = await readFile(path, "utf8");
1238
+ } catch (error) {
1239
+ if (isNoEntError(error)) return void 0;
1240
+ throw error;
1241
+ }
1242
+ return parseCommittedJsonLines(text, path);
1243
+ }
1244
+ function errorMessage(error) {
1245
+ return error instanceof Error ? error.message : String(error);
1246
+ }
1247
+ //#endregion
1087
1248
  //#region src/runtime/supervise/supervisor-agent.ts
1088
1249
  /**
1089
1250
  * `supervisorAgent` — build a supervisor `Agent` FROM its profile. The brain is resolved from
@@ -2195,7 +2356,7 @@ async function providerAcceptsCoordinationAttachments(backend) {
2195
2356
  /** Run a harness-brained manager through the same executor factory as its children. The manager's
2196
2357
  * full profile is preserved, the live coordination server is added under one reserved alias, and
2197
2358
  * every streamed turn is charged to the manager's scope before it may continue. */
2198
- function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns) {
2359
+ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns, rootStream) {
2199
2360
  if (maxTurns !== void 0 && maxTurns < 0) throw new ValidationError("driveHarnessFromBackend: maxTurns must be >= 0 (0 lifts the turn cap; bounds become the conserved pool + deadline + abort)");
2200
2361
  const turnCap = maxTurns ?? 0;
2201
2362
  const boundBackend = bindReusableExecutorExecutionId(captureReusableExecutorConfig(backend, "driveHarnessFromBackend"), executionId);
@@ -2426,6 +2587,7 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns)
2426
2587
  if (executor.budgetExempt) throw new ValidationError(`driveHarnessFromBackend: runtime ${JSON.stringify(executor.runtime)} does not report usage and cannot drive a budgeted supervisor`);
2427
2588
  started = true;
2428
2589
  if (retainedOwner?.admissions.length && !executor.recover) throw new ValidationError("retained owner executor does not support recovery");
2590
+ await rootStream?.beginAttempt();
2429
2591
  const run = retainedOwner?.admissions.length ? executor.recover(originalTask, scope.signal) : executor.execute(originalTask, scope.signal);
2430
2592
  if (isAsyncIterable(run)) {
2431
2593
  let turns = 0;
@@ -2433,7 +2595,8 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns)
2433
2595
  await meterPending();
2434
2596
  turns += 1;
2435
2597
  if (turnStop !== void 0 && turns >= turnCap && !turnStop.signal.aborted) turnStop.abort(`supervise: maxTurns ${turnCap} reached`);
2436
- } else if (event.kind !== "progress") pendingUsage.push(event);
2598
+ } else if (event.kind === "progress") rootStream?.append(event.progress);
2599
+ else pendingUsage.push(event);
2437
2600
  await meterPending();
2438
2601
  const artifact = executor.resultArtifact();
2439
2602
  const terminalResources = withBudgetResources({
@@ -3009,6 +3172,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3009
3172
  const log = ctx.coordinationLog;
3010
3173
  const rootOwnerId = rootCoordinationOwner(rootExecution.identity);
3011
3174
  const rootProviderModels = [];
3175
+ const rootStreamSink = options.runDir === void 0 ? void 0 : createRootStreamSink(resolve(options.runDir), options.now ?? Date.now);
3012
3176
  const observeNodeEvent = options.onCoordinationEvent ? async (context, event, record) => {
3013
3177
  await options.onCoordinationEvent?.(context, coordinationEventId(context, event), record);
3014
3178
  } : void 0;
@@ -3044,7 +3208,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3044
3208
  return managerBackend && automaticDriverBackendSupported(managerBackend, options.coordination) ? driveHarnessFromBackend(managerBackend, externalExecutionId("supervised-manager", {
3045
3209
  runNamespace,
3046
3210
  ownerId: context.ownerId
3047
- }), options.now ?? Date.now, options.maxTurns) : void 0;
3211
+ }), options.now ?? Date.now, options.maxTurns, context.depth === 0 ? rootStreamSink : void 0) : void 0;
3048
3212
  };
3049
3213
  const rootDriveHarness = isExternalSupervisor(canonicalProfile) ? driveHarnessForOwner(freezeDetached({
3050
3214
  runId,
@@ -3329,17 +3493,23 @@ function superviseInternal(profile, task, opts, testBrain) {
3329
3493
  });
3330
3494
  const settle = async () => {
3331
3495
  let result;
3496
+ let rootStream;
3332
3497
  try {
3333
3498
  result = await run;
3334
3499
  } finally {
3335
- cancellation?.close();
3336
- cancellation?.check();
3500
+ try {
3501
+ rootStream = await rootStreamSink?.close();
3502
+ } finally {
3503
+ cancellation?.close();
3504
+ cancellation?.check();
3505
+ }
3337
3506
  }
3338
3507
  recordRunCancellationOutcome(options.runDir, result, now);
3339
3508
  const rootProviderModel = ctx.resume === true ? rootProviderModelEvidence([]) : rootProviderModels.length > 0 ? rootProviderModelEvidence(rootProviderModels) : rootDriveHarness === void 0 ? rootProviderModelEvidence([]) : rootProviderModelEvidenceFromExecution(runtimeOwnedDriveHarnessProviderEvidence(rootDriveHarness));
3340
3509
  return {
3341
3510
  ...result,
3342
- rootProviderModel
3511
+ rootProviderModel,
3512
+ ...rootStream === void 0 ? {} : { rootStream }
3343
3513
  };
3344
3514
  };
3345
3515
  if (!recorder) return settle();
@@ -3386,6 +3556,6 @@ function rootProviderModelEvidenceFromExecution(evidence) {
3386
3556
  return evidence ?? rootProviderModelEvidence([]);
3387
3557
  }
3388
3558
  //#endregion
3389
- export { mapExecutorResult as _, isPreSpawnExecutorFailure as a, withWorkerSpawnRetry as c, resolveSupervisorProfile as d, supervisorAgent as f, gateOnDeliverable as g, serveCoordinationMcp as h, workerFromBackend as i, assertCoordinationBinding as l, createSupervisorSpanRecorder as m, supervise as n, resolveWorkerSpawnRetry as o, supervisorAgentWithTestBrain as p, superviseWithTestBrain as r, retryPreSpawnRefusals as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, coordinationProfileToolPrefix as u };
3559
+ export { createSupervisorSpanRecorder as _, isPreSpawnExecutorFailure as a, mapExecutorResult as b, withWorkerSpawnRetry as c, resolveSupervisorProfile as d, supervisorAgent as f, readRootStreamReceipt as g, readRootStream as h, workerFromBackend as i, assertCoordinationBinding as l, ROOT_STREAM_FILE as m, supervise as n, resolveWorkerSpawnRetry as o, supervisorAgentWithTestBrain as p, superviseWithTestBrain as r, retryPreSpawnRefusals as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, coordinationProfileToolPrefix as u, serveCoordinationMcp as v, gateOnDeliverable as y };
3390
3560
 
3391
- //# sourceMappingURL=supervise-qYms7HSb.js.map
3561
+ //# sourceMappingURL=supervise-CtXJ-lWb.js.map