@tangle-network/agent-runtime 9.0.16 → 10.0.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 (93) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/dist/{activation-DgT20fzX.js → activation-C_BenzIu.js} +2 -2
  3. package/dist/{activation-DgT20fzX.js.map → activation-C_BenzIu.js.map} +1 -1
  4. package/dist/{activation-y6NAn3sW.d.ts → activation-s6dGGify.d.ts} +7 -8
  5. package/dist/agent.d.ts +1 -1
  6. package/dist/agent.js +3 -3
  7. package/dist/candidate-execution/index.d.ts +3 -0
  8. package/dist/candidate-execution/index.js +10 -3
  9. package/dist/candidate-execution/index.js.map +1 -1
  10. package/dist/{delegate-Cmu5OF3M.js → delegate-BOren4c7.js} +2 -2
  11. package/dist/{delegate-Cmu5OF3M.js.map → delegate-BOren4c7.js.map} +1 -1
  12. package/dist/{coordination-manager-CFtnSLPw.js → driver-control-acknowledgers-ByKwAgCI.js} +1062 -1042
  13. package/dist/driver-control-acknowledgers-ByKwAgCI.js.map +1 -0
  14. package/dist/durable.d.ts +5 -5
  15. package/dist/durable.js +13 -13
  16. package/dist/durable.js.map +1 -1
  17. package/dist/{failure-cause-WifbY42M.js → failure-cause-DoCCGLDH.js} +42 -18
  18. package/dist/failure-cause-DoCCGLDH.js.map +1 -0
  19. package/dist/{graph-DqtIiS94.js → graph-BXONYT1o.js} +8 -8
  20. package/dist/{graph-DqtIiS94.js.map → graph-BXONYT1o.js.map} +1 -1
  21. package/dist/{graph-registry-B_1C7qye.js → graph-registry-DxhlgHdA.js} +1 -1
  22. package/dist/{graph-registry-BbZN5deo.js → graph-registry-j9t9J0KT.js} +11 -12
  23. package/dist/{graph-registry-BbZN5deo.js.map → graph-registry-j9t9J0KT.js.map} +1 -1
  24. package/dist/{improve-B0vNv6e7.js → improve-CS2GIF5O.js} +42 -26
  25. package/dist/{improve-B0vNv6e7.js.map → improve-CS2GIF5O.js.map} +1 -1
  26. package/dist/index.d.ts +38 -6
  27. package/dist/index.js +59 -20
  28. package/dist/index.js.map +1 -1
  29. package/dist/intelligence.d.ts +93 -63
  30. package/dist/intelligence.js +166 -73
  31. package/dist/intelligence.js.map +1 -1
  32. package/dist/kernel.d.ts +3 -3
  33. package/dist/kernel.js +16 -15
  34. package/dist/{loop-runner-CfMOsISJ.d.ts → loop-runner-C0B3PexH.d.ts} +2 -2
  35. package/dist/loop-runner-bin.d.ts +1 -1
  36. package/dist/loop-runner-bin.js +1 -1
  37. package/dist/{loop-runner-BvVdDdZC.js → loop-runner-ftyZP4st.js} +2 -2
  38. package/dist/{loop-runner-BvVdDdZC.js.map → loop-runner-ftyZP4st.js.map} +1 -1
  39. package/dist/mcp/bin.js +3 -3
  40. package/dist/mcp/index.d.ts +1 -1
  41. package/dist/mcp/index.js +7 -7
  42. package/dist/mcp/memory-bin.js +1 -1
  43. package/dist/{model-policy-CZwhXp8O.js → model-policy-CqDuBTq-.js} +12 -2
  44. package/dist/model-policy-CqDuBTq-.js.map +1 -0
  45. package/dist/{prepare-Cw4ZaN01.js → prepare-DT-ibRsm.js} +2 -2
  46. package/dist/{prepare-Cw4ZaN01.js.map → prepare-DT-ibRsm.js.map} +1 -1
  47. package/dist/profiles.d.ts +1 -1
  48. package/dist/profiles.js +1 -1
  49. package/dist/{provision-supervisor-BjKluSKl.js → provision-supervisor-CauovUHn.js} +6 -6
  50. package/dist/{provision-supervisor-BjKluSKl.js.map → provision-supervisor-CauovUHn.js.map} +1 -1
  51. package/dist/{run-cancellation-BvGEEwRG.js → run-cancellation-NMNVuYiO.js} +2 -2
  52. package/dist/{run-cancellation-BvGEEwRG.js.map → run-cancellation-NMNVuYiO.js.map} +1 -1
  53. package/dist/{run-state-Dd_AjWd6.js → run-state-COyIVOVb.js} +5 -5
  54. package/dist/{run-state-Dd_AjWd6.js.map → run-state-COyIVOVb.js.map} +1 -1
  55. package/dist/{runtime-7VEM9muH.js → runtime-DYaRDLKn.js} +191 -24
  56. package/dist/runtime-DYaRDLKn.js.map +1 -0
  57. package/dist/{search-executor-Dqtm1fOC.js → search-executor-Drd_N9YO.js} +5 -5
  58. package/dist/{search-executor-Dqtm1fOC.js.map → search-executor-Drd_N9YO.js.map} +1 -1
  59. package/dist/{server-B8Kmit_v.js → server-Dk9B1WFf.js} +4 -4
  60. package/dist/{server-B8Kmit_v.js.map → server-Dk9B1WFf.js.map} +1 -1
  61. package/dist/{settle-record-BvH2-Ao5.js → settle-record-YdkkHzqw.js} +2 -2
  62. package/dist/{settle-record-BvH2-Ao5.js.map → settle-record-YdkkHzqw.js.map} +1 -1
  63. package/dist/{structural-rollout-CYc8PE2N.js → structural-rollout-DbZAkHTq.js} +5 -5
  64. package/dist/{structural-rollout-CYc8PE2N.js.map → structural-rollout-DbZAkHTq.js.map} +1 -1
  65. package/dist/{supervise-BayNu7qZ.js → supervise-B5hb0my3.js} +2426 -2336
  66. package/dist/supervise-B5hb0my3.js.map +1 -0
  67. package/dist/{supervision-discovery-Ca4QO4rG.js → supervision-discovery-ChkTxilL.js} +3 -3
  68. package/dist/{supervision-discovery-Ca4QO4rG.js.map → supervision-discovery-ChkTxilL.js.map} +1 -1
  69. package/dist/{supervisor-Bx21Hy27.js → supervisor-DpwcTrTh.js} +437 -75
  70. package/dist/supervisor-DpwcTrTh.js.map +1 -0
  71. package/dist/{supervisor-accounting-StDNW1YT.js → supervisor-accounting-QiXnF-EW.js} +541 -344
  72. package/dist/supervisor-accounting-QiXnF-EW.js.map +1 -0
  73. package/dist/testing.d.ts +1 -1
  74. package/dist/testing.js +11 -11
  75. package/dist/{tool-server-CirrqFlr.js → tool-server-DQCdu3am.js} +2 -2
  76. package/dist/{tool-server-CirrqFlr.js.map → tool-server-DQCdu3am.js.map} +1 -1
  77. package/dist/{top-web-Cg7ywIkF.js → top-web-E85Fk8pH.js} +6 -6
  78. package/dist/{top-web-Cg7ywIkF.js.map → top-web-E85Fk8pH.js.map} +1 -1
  79. package/dist/tui/bin.js +3 -3
  80. package/dist/tui/index.d.ts +1 -1
  81. package/dist/tui/index.js +2 -2
  82. package/dist/{types-_j53efrk.d.ts → types-dv295cpm.d.ts} +9907 -9784
  83. package/dist/{workspace-streams-BakRr-Pl.js → workspace-streams-C7PGLAUd.js} +3 -3
  84. package/dist/workspace-streams-C7PGLAUd.js.map +1 -0
  85. package/package.json +8 -7
  86. package/dist/coordination-manager-CFtnSLPw.js.map +0 -1
  87. package/dist/failure-cause-WifbY42M.js.map +0 -1
  88. package/dist/model-policy-CZwhXp8O.js.map +0 -1
  89. package/dist/runtime-7VEM9muH.js.map +0 -1
  90. package/dist/supervise-BayNu7qZ.js.map +0 -1
  91. package/dist/supervisor-Bx21Hy27.js.map +0 -1
  92. package/dist/supervisor-accounting-StDNW1YT.js.map +0 -1
  93. package/dist/workspace-streams-BakRr-Pl.js.map +0 -1
@@ -2,16 +2,16 @@ import { c as RetainedInteractiveAdmissionError, d as RetainedRunDispatchBinding
2
2
  import { a as readCommittedJsonLines, c as appendCommittedJsonLine, f as deadlineSignal, h as signalAbortError, l as sha256, m as runAbortable, r as prepareJsonlAppend, s as withJsonlFileLock, t as isNoEntError, u as RunCancellationReason } from "./jsonl-file-BhuxeejY.js";
3
3
  import { c as checkInIdleMs, d as teardownExecutor, n as CHILD_DEADLINE_REASON, o as armDeadlineTimer, s as boundedChildDeadlineAt, u as singleFlightTeardown } from "./deadline-CySmJ_0S.js";
4
4
  import { A as withBudgetResources, C as unreportedSpend, D as addResourceSpend, T as zeroSpend, a as cloneSpend, c as errorMessage, f as isAsyncIterable, i as chargedTokens, k as resourceTelemetry, n as addSpend, o as cloneTokenUsage, t as abortError, v as sleep } from "./util-qsH5cC9S.js";
5
- import { Et as recordValue, F as executorFailure, G as budgetLeaseUpdates, I as executorFailureInfra, J as completedLeafBacking, K as budgetLeases, L as executorFailureReason, M as traceRootWriter, N as contentAddress, Q as newUsageTotals, W as BudgetReconcileFault, X as refreshBudgetLease, Y as createBudgetPool, Z as meterUsageEvent, dt as extractTransportEventIdentity, et as spendFromUsageTotals, f as executorEvidenceWriter, ft as parseCanonicalTransportEvent, g as prepareRetainedExecutor, h as leafContinuationExecutionId, n as runtimeFailureCause, nt as assertValidSpend, o as settlementFailureCause, q as budgetRecoverySeeds, s as BUDGET_CONTINUATION_TASK, t as reportedFailureCause, tt as assertValidBudget, u as RetainedExecutionPendingError, y as retainedExecutorSeamKey } from "./failure-cause-WifbY42M.js";
6
- import { a as errMessage, f as resolveRedactor, l as errorText, n as detachedSnapshot, r as shareParsedStrings, u as defaultRedactor } from "./snapshot-BKI_w3JD.js";
7
- import { p as canonicalObservedModelParts, t as assertExecutableAgentProfile } from "./model-policy-CZwhXp8O.js";
8
- import { h as workspaceLimits, i as readAgentCandidateWorkspaceArtifactFiles, m as safeArchivePath, y as verifiedArtifactChunks } from "./workspace-streams-BakRr-Pl.js";
5
+ import { $ as newUsageTotals, F as executorFailureInfra, G as BudgetReconcileFault, I as executorFailureReason, J as budgetRecoverySeeds, K as budgetLeaseUpdates, M as contentAddress, Ot as recordValue, P as executorFailure, Q as meterUsageEvent, X as createBudgetPool, Y as completedLeafBacking, Z as refreshBudgetLease, a as settlementFailureCause, d as executorEvidenceWriter, ft as extractTransportEventIdentity, h as prepareRetainedExecutor, j as traceRootWriter, l as RetainedExecutionPendingError, m as leafContinuationExecutionId, n as runtimeFailureCause, nt as assertValidBudget, o as BUDGET_CONTINUATION_TASK, pt as parseCanonicalTransportEvent, q as budgetLeases, rt as assertValidSpend, t as reportedFailureCause, tt as spendFromUsageTotals, v as retainedExecutorSeamKey } from "./failure-cause-DoCCGLDH.js";
6
+ import { a as errMessage, f as resolveRedactor, i as causeChain, l as errorText, n as detachedSnapshot, r as shareParsedStrings, u as defaultRedactor } from "./snapshot-BKI_w3JD.js";
7
+ import { p as canonicalObservedModelParts, t as assertExecutableAgentProfile } from "./model-policy-CqDuBTq-.js";
8
+ import { b as verifiedArtifactChunks, g as workspaceLimits, h as safeArchivePath, i as readAgentCandidateWorkspaceArtifactFiles } from "./workspace-streams-C7PGLAUd.js";
9
9
  import { a as writeAtomicDurableFile, n as assertNoSymlinkDescendant, o as captureRunWriteContext, r as publishExclusiveDurableFile, s as fenceRunWrite, t as appendDurableFile } from "./durable-file-DstVeHcj.js";
10
10
  import { b as sha256Bytes$1, g as deepFreezeCandidate } from "./output-artifacts-AqkZ8lO2.js";
11
11
  import { a as withPursuitContext, i as notifyRuntimeHookEvent } from "./runtime-hooks-CsW2pfFk.js";
12
12
  import * as traceContract from "@tangle-network/agent-trace-contract";
13
13
  import { ATTR, OPERATION_NAME_ATTR, toW3CSpanId, toW3CTraceId } from "@tangle-network/agent-trace-contract";
14
- import { AgentEnvironmentCapabilitiesSchema, AgentExactRunControlRefSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStatusSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentNativeContextContinuationResultSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, AgentTurnResultSchema, ContextTransferReceiptSchema, ContextTransferRequestSchema, InteractionAcknowledgementSchema, InteractionResponseCommandSchema, NativeContextBoundaryProofSchema, NativeContextContinuationRequestSchema, RuntimeEventEnvelopeSchema, TerminalReplayWindowSchema, TerminalSessionRefSchema, agentCandidateArtifactRefSchema, agentCandidateWorkspaceManifestMaterialSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentNativeContextContinuationResultMatchesRequest, agentProfileSchema, agentRunCancellationAcknowledgementMatchesRequest, agentRunCancellationRequestDigest, agentWorkspaceSnapshotRefDigest, canonicalAgentProfileDigest, canonicalCandidateDigest, contextTransferReceiptMatches, exactAgentInteractiveSessionStart, nativeContextContinuationTurnDigest, sha256DigestSchema, workspaceCheckpointRequestDigest, workspaceCheckpointResultMatchesRequest, workspaceCleanupAcknowledgementMatches, workspaceCleanupRequestDigest } from "@tangle-network/agent-interface";
14
+ import { AgentEnvironmentCapabilitiesSchema, AgentExactRunControlRefSchema, AgentFileOutputPolicySchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStatusSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentNativeContextContinuationResultSchema, AgentRetainedFilePublicationSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, AgentTurnResultSchema, ContextTransferReceiptSchema, ContextTransferRequestSchema, InteractionAcknowledgementSchema, InteractionResponseCommandSchema, NativeContextBoundaryProofSchema, NativeContextContinuationRequestSchema, RuntimeEventEnvelopeSchema, TerminalReplayWindowSchema, TerminalSessionRefSchema, agentCandidateArtifactRefSchema, agentCandidateWorkspaceManifestMaterialSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentNativeContextContinuationResultMatchesRequest, agentProfileSchema, agentRunCancellationAcknowledgementMatchesRequest, agentRunCancellationRequestDigest, agentWorkspaceSnapshotRefDigest, canonicalAgentProfileDigest, canonicalCandidateDigest, contextTransferReceiptMatches, exactAgentInteractiveSessionStart, nativeContextContinuationTurnDigest, sha256DigestSchema, workspaceCheckpointRequestDigest, workspaceCheckpointResultMatchesRequest, workspaceCleanupAcknowledgementMatches, workspaceCleanupRequestDigest } from "@tangle-network/agent-interface";
15
15
  import { isToolSpan, toolSpansToTraceAnalysisStore } from "@tangle-network/agent-eval";
16
16
  import { isRecord } from "@tangle-network/agent-core";
17
17
  import { z } from "zod";
@@ -20,6 +20,7 @@ import { createHash, randomUUID } from "node:crypto";
20
20
  import { appendFileSync, closeSync, constants, existsSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, statSync, unlinkSync, writeSync } from "node:fs";
21
21
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
22
22
  import { mkdir, open, realpath, stat } from "node:fs/promises";
23
+ import { BOUND_HARNESS_SESSION_READ_LIMITS, HARNESS_TRANSCRIPT_DENY, readBoundHarnessSessions } from "@tangle-network/harness-sessions";
23
24
  import { decodeOtlpAttributes, msToUnixNano, otlpTraceExport, readOtlpPartialSuccess, toOtlpAttributes } from "@tangle-network/agent-trace-contract/otlp";
24
25
  import { lockHolderVerdict, lockIdentity, parseLockHolderRecord, readLockHolderIdentity } from "@tangle-network/agent-eval/lock-holder";
25
26
  // src/runtime/turn-input.ts
@@ -1176,6 +1177,7 @@ const sourceSchema = z.object({
1176
1177
  profileDigest: digest,
1177
1178
  providerSessionId: text.nullable(),
1178
1179
  nativeSessionId: text.nullable(),
1180
+ nativeSessionIds: z.array(text).min(1).max(1e3).optional(),
1179
1181
  coverageComplete: z.boolean(),
1180
1182
  incompleteReason: z.string().optional()
1181
1183
  });
@@ -1195,6 +1197,17 @@ const skippedSchema = z.object({
1195
1197
  path: text,
1196
1198
  reason: text
1197
1199
  });
1200
+ const omittedSchema = z.object({
1201
+ path: text,
1202
+ reason: z.enum([
1203
+ "harness-install",
1204
+ "harness-cache",
1205
+ "credential"
1206
+ ]),
1207
+ bytes: count.optional(),
1208
+ sha256: digest.optional(),
1209
+ attribution: attributionSchema
1210
+ });
1198
1211
  const retainedSchema = z.object({
1199
1212
  kind: z.literal("retained-harness-transcript"),
1200
1213
  schemaVersion: z.literal(1),
@@ -1210,13 +1223,12 @@ const retainedSchema = z.object({
1210
1223
  }),
1211
1224
  files: z.array(fileSchema),
1212
1225
  skipped: z.array(skippedSchema),
1226
+ omitted: z.array(omittedSchema).optional(),
1213
1227
  missing: z.array(z.string())
1214
1228
  });
1215
1229
  /** One native capture/read bound per child; replay resolves references rather than copying bytes. */
1216
1230
  const HARNESS_TRANSCRIPT_READ_LIMITS = Object.freeze({
1217
- maxFileBytes: 2097152,
1218
- maxTotalBytes: 16777216,
1219
- maxFiles: 1e3,
1231
+ ...BOUND_HARNESS_SESSION_READ_LIMITS,
1220
1232
  maxManifestBytes: 16777216
1221
1233
  });
1222
1234
  /** Validate persisted descriptors before trusting their identity, locators, or inventory. */
@@ -1224,11 +1236,17 @@ function parseRetainedHarnessTranscript(value) {
1224
1236
  const parsed = retainedSchema.safeParse(value);
1225
1237
  if (!parsed.success) throw new ValidationError(`Invalid retained harness transcript: ${parsed.error.message}`);
1226
1238
  const paths = /* @__PURE__ */ new Set();
1239
+ const ids = parsed.data.source.nativeSessionIds;
1240
+ if (ids && (new Set(ids).size !== ids.length || !ids.includes(parsed.data.source.nativeSessionId ?? ""))) throw new ValidationError("Retained transcript native identities are ambiguous");
1227
1241
  for (const file of parsed.data.files) {
1228
1242
  if (paths.has(file.path)) throw new ValidationError(`Retained transcript repeats native identity: ${file.path}`);
1229
1243
  paths.add(file.path);
1230
1244
  if (file.path !== nativeIdentity(file.attribution)) throw new ValidationError(`Retained transcript native identity does not match its attribution: ${file.path}`);
1231
1245
  }
1246
+ for (const file of parsed.data.omitted ?? []) {
1247
+ if (paths.has(file.path) || file.path !== nativeIdentity(file.attribution)) throw new ValidationError("Retained transcript omission conflicts with its native inventory");
1248
+ paths.add(file.path);
1249
+ }
1232
1250
  return deepFreezeCandidate(parsed.data);
1233
1251
  }
1234
1252
  function nativeIdentity(attribution) {
@@ -1253,10 +1271,23 @@ function retainHarnessTranscript(receipt, harness) {
1253
1271
  function nativeDigest(value) {
1254
1272
  return typeof value === "string" && /^[0-9a-f]{64}$/.test(value) ? `sha256:${value}` : value;
1255
1273
  }
1274
+ /** Every native conversation observed across this exact execution's attempts, in order. */
1275
+ function retainedNativeSessionIds(receipt) {
1276
+ const observedIds = [...new Set((receipt.provenance.attempts ?? []).filter((attempt) => attempt.executionId === (receipt.controlRef?.executionId ?? receipt.executionId)).flatMap((attempt) => attempt.nativeSessionIds))];
1277
+ const nativeSessionIds = receipt.nativeSessionIds ?? (observedIds.length > 0 ? [.../* @__PURE__ */ new Set([...observedIds, ...receipt.nativeSessionId ? [receipt.nativeSessionId] : []])] : void 0);
1278
+ if (nativeSessionIds && observedIds.some((id) => !nativeSessionIds.includes(id))) throw new ValidationError("Retained transcript omits an observed native execution attempt");
1279
+ return nativeSessionIds;
1280
+ }
1256
1281
  function retainedCapture(receipt, harness) {
1257
- const { snapshot, provenance, ...source } = receipt;
1282
+ const { snapshot, provenance, ...originalSource } = receipt;
1283
+ const nativeSessionIds = retainedNativeSessionIds(receipt);
1284
+ const source = {
1285
+ ...originalSource,
1286
+ ...nativeSessionIds ? { nativeSessionIds } : {}
1287
+ };
1258
1288
  const files = [];
1259
1289
  const skipped = [];
1290
+ const omitted = [];
1260
1291
  const missing = [...provenance.missing];
1261
1292
  for (const session of provenance.sessions ?? []) {
1262
1293
  if (session.executionId !== receipt.executionId || session.backendType !== harness) throw new ValidationError("Retained transcript session has a different execution or harness");
@@ -1273,6 +1304,16 @@ function retainedCapture(receipt, harness) {
1273
1304
  rootScope: entry.rootScope,
1274
1305
  nativePath: entry.path
1275
1306
  };
1307
+ if (entry.contentOmitted !== void 0) {
1308
+ omitted.push(omittedSchema.parse({
1309
+ path: nativeIdentity(attribution),
1310
+ reason: entry.contentOmitted,
1311
+ bytes: entry.sizeBytes,
1312
+ ...nativeDigest(entry.sha256) === null ? {} : { sha256: nativeDigest(entry.sha256) },
1313
+ attribution
1314
+ }));
1315
+ continue;
1316
+ }
1276
1317
  const parsed = fileSchema.safeParse({
1277
1318
  path: nativeIdentity(attribution),
1278
1319
  bytes: entry.sizeBytes,
@@ -1289,15 +1330,20 @@ function retainedCapture(receipt, harness) {
1289
1330
  missing.push(`${nativeIdentity(attribution)}: ${reason}`);
1290
1331
  }
1291
1332
  }
1292
- for (const entry of session.nativeStore.excludedPaths) skipped.push({
1293
- path: nativeIdentity({
1333
+ for (const entry of session.nativeStore.excludedPaths) {
1334
+ const attribution = {
1294
1335
  providerSessionId: session.id,
1295
1336
  ...entry.sourceId === void 0 ? {} : { sourceId: entry.sourceId },
1296
1337
  rootScope: entry.rootScope,
1297
1338
  nativePath: entry.path
1298
- }),
1299
- reason: entry.reason
1300
- });
1339
+ };
1340
+ omitted.push({
1341
+ path: nativeIdentity(attribution),
1342
+ reason: entry.reason,
1343
+ bytes: entry.sizeBytes,
1344
+ attribution
1345
+ });
1346
+ }
1301
1347
  }
1302
1348
  if (files.length === 0) missing.push("No native files declared by provider capture");
1303
1349
  const descriptor = parseRetainedHarnessTranscript({
@@ -1315,6 +1361,7 @@ function retainedCapture(receipt, harness) {
1315
1361
  },
1316
1362
  files,
1317
1363
  skipped,
1364
+ ...omitted.length ? { omitted } : {},
1318
1365
  missing
1319
1366
  });
1320
1367
  if (files.length === 0) return deepFreezeCandidate({
@@ -1422,7 +1469,8 @@ async function resolveHarnessTranscriptCapture(capture, options = {}) {
1422
1469
  files.push({
1423
1470
  path: file.path,
1424
1471
  bytes: file.bytes,
1425
- content
1472
+ content,
1473
+ attribution: file.attribution
1426
1474
  });
1427
1475
  } catch {
1428
1476
  skipped.push({
@@ -1436,69 +1484,23 @@ async function resolveHarnessTranscriptCapture(capture, options = {}) {
1436
1484
  harness: descriptor.harness,
1437
1485
  source: descriptor.source,
1438
1486
  files,
1439
- skipped
1487
+ skipped,
1488
+ ...descriptor.omitted ? { omitted: descriptor.omitted } : {}
1440
1489
  });
1441
1490
  }
1442
- /** Credential-shaped paths are refused even when a producer lists them. */
1443
- const HARNESS_TRANSCRIPT_DENY = /(^|\/)(auth\.json|\.credentials\.json|credentials|\.netrc|\.env(\..*)?|secrets?(\.|$)|.*\.(pem|key|p12|pfx)|id_[a-z0-9_]+)$/iu;
1444
- /** Verify a bound native family without owning a store, filesystem layout or native parser. */
1445
- async function readBoundHarnessSessions(input) {
1446
- const files = [];
1447
- const sessions = /* @__PURE__ */ new Map();
1448
- const parents = /* @__PURE__ */ new Map();
1449
- const paths = /* @__PURE__ */ new Set();
1450
- const pathBytes = workspaceLimits(void 0).maxPathBytes;
1451
- const pending = [input.nativeSessionId];
1452
- let total = 0;
1453
- while (pending.length) {
1454
- const id = pending.shift();
1455
- if (sessions.has(id)) continue;
1456
- const candidates = input.files.filter((file) => file.nativeSessionId === id);
1457
- if (!candidates.length) throw new ValidationError("The exact native session or a recorded child was not retained");
1458
- for (const file of candidates) {
1459
- input.signal?.throwIfAborted();
1460
- if (files.length >= HARNESS_TRANSCRIPT_READ_LIMITS.maxFiles) throw new ValidationError("Native file count exceeds the capture bound");
1461
- safeArchivePath(file.path, pathBytes);
1462
- if (HARNESS_TRANSCRIPT_DENY.test(file.path) || paths.has(file.path)) throw new ValidationError("Native file path is denied or repeated");
1463
- paths.add(file.path);
1464
- const read = () => input.read(file, input.signal);
1465
- const bytes = input.signal ? await runAbortable(read, input.signal, "Native source read stopped") : await read();
1466
- total += bytes.byteLength;
1467
- if (bytes.byteLength > HARNESS_TRANSCRIPT_READ_LIMITS.maxFileBytes || total > HARNESS_TRANSCRIPT_READ_LIMITS.maxTotalBytes) throw new ValidationError("Native bytes exceed the capture bound");
1468
- const actual = sha256Bytes$1(bytes);
1469
- if (file.sha256 && file.sha256.replace(/^sha256:/, "") !== actual.slice(7) || file.byteLength !== void 0 && file.byteLength !== bytes.byteLength) throw new ValidationError("Captured native session bytes changed");
1470
- const session = input.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes), file);
1471
- if (session.nativeSessionId !== id || session.integrity.truncated || session.integrity.unparsedRecords || session.integrity.gaps.length) throw new ValidationError("Native session identity or integrity did not match its binding");
1472
- if (session.parentNativeSessionId && parents.has(id) && session.parentNativeSessionId !== parents.get(id)) throw new ValidationError("Native child has a different recorded parent");
1473
- const prior = files.find((value) => value.nativeSessionId === id);
1474
- if (prior && prior.sha256 !== actual) throw new ValidationError("Native session copies are ambiguous");
1475
- files.push({
1476
- path: file.path,
1477
- nativeSessionId: id,
1478
- sha256: actual,
1479
- byteLength: bytes.byteLength
1480
- });
1481
- if (!prior) sessions.set(id, session);
1482
- }
1483
- for (const child of sessions.get(id).children) {
1484
- if (parents.has(child.nativeSessionId) && parents.get(child.nativeSessionId) !== id) throw new ValidationError("Native child has ambiguous recorded parents");
1485
- parents.set(child.nativeSessionId, id);
1486
- if (!sessions.has(child.nativeSessionId)) pending.push(child.nativeSessionId);
1487
- }
1488
- }
1489
- return {
1490
- files,
1491
- sessions: [...sessions.values()]
1492
- };
1491
+ /** Compatibility entry. The shared reader owns native-family integrity; Runtime
1492
+ * retains its archive path policy, abort behavior and public error identity. */
1493
+ async function readBoundHarnessSessions$1(input) {
1494
+ return readBoundHarnessSessions({
1495
+ ...input,
1496
+ validatePath: (path) => {
1497
+ safeArchivePath(path, workspaceLimits(void 0).maxPathBytes);
1498
+ },
1499
+ failure: (message) => new ValidationError(message),
1500
+ read: (file, signal) => signal ? runAbortable(() => input.read(file, signal), signal, "Native source read stopped") : input.read(file)
1501
+ });
1493
1502
  }
1494
1503
  // src/runtime/harness-transcript.ts
1495
- /**
1496
- * Persist a harness transcript receipt beside the supervisor tool trace.
1497
- * Provider workspace retention supplies an attributed descriptor whose bytes stay in the
1498
- * original verified archive. Environments without retention use the bounded read/exec
1499
- * fallback below. Neither path embeds transcript content in settlement events.
1500
- * Readers request metadata without archive I/O, or explicitly resolve bounded text content.
1501
- */
1502
1504
  const { maxFileBytes: MAX_FILE_BYTES, maxTotalBytes: MAX_TOTAL_BYTES, maxFiles: MAX_FILES } = HARNESS_TRANSCRIPT_READ_LIMITS;
1503
1505
  /** Where each harness keeps the session files that hold the conversation. */
1504
1506
  const HARNESS_ROOTS = Object.freeze({
@@ -1946,9 +1948,9 @@ function capturedTranscript(artifact, coverageComplete) {
1946
1948
  }
1947
1949
  /** Local native bytes enter the same artifact/settlement path as every other transcript. */
1948
1950
  async function captureBoundHarnessTranscript(input) {
1949
- if (input.binding.nativeSessionId !== input.nativeSessionId || !input.binding.sessionId || !/^sha256:[a-f0-9]{64}$/.test(input.binding.profileDigest) || !input.binding.runs.length || input.binding.runs.some((run) => !run.runId || !/^sha256:[a-f0-9]{64}$/.test(run.requestDigest))) throw new ValidationError("Native capture binding is incomplete");
1951
+ if (input.binding.nativeSessionId !== input.nativeSessionId || JSON.stringify(input.binding.nativeSessionIds ?? [input.binding.nativeSessionId]) !== JSON.stringify(input.nativeSessionIds ?? [input.nativeSessionId]) || !input.binding.sessionId || !/^sha256:[a-f0-9]{64}$/.test(input.binding.profileDigest) || !input.binding.runs.length || input.binding.runs.some((run) => !run.runId || !/^sha256:[a-f0-9]{64}$/.test(run.requestDigest))) throw new ValidationError("Native capture binding is incomplete");
1950
1952
  const files = [];
1951
- await readBoundHarnessSessions({
1953
+ await readBoundHarnessSessions$1({
1952
1954
  ...input,
1953
1955
  read: async (file, signal) => {
1954
1956
  const bytes = await input.read(file, signal);
@@ -4043,6 +4045,14 @@ function createRetainedRunHandle(environment, session, initialControlRef, capabi
4043
4045
  get capabilities() {
4044
4046
  return structuredClone(measuredCapabilities);
4045
4047
  },
4048
+ ...environment.retainFileOutput && measuredCapabilities.workspace?.retainFileOutput === true ? { retainFileOutput: async (...args) => {
4049
+ control.sync();
4050
+ if (!sameControlCoordinates(control.current, args[0].controlRef)) return {
4051
+ status: "unavailable",
4052
+ reason: "original retained execution is no longer current"
4053
+ };
4054
+ return environment.retainFileOutput(...args);
4055
+ } } : {},
4046
4056
  status: (options) => retainedStatus(control, clock, options),
4047
4057
  events: (options) => {
4048
4058
  control.sync();
@@ -4251,6 +4261,10 @@ async function startRetainedRun(options) {
4251
4261
  if (options.intent === void 0) await admitDurably(onAdmission, intent);
4252
4262
  else assertExactRetainedRunIntent(options.intent, intent, () => retainedRunIntent(options, identity, contextTransfer, { providerOptions: options.turn.providerOptions }));
4253
4263
  const providerCapabilities = await assertRetainedCapabilities(options.provider);
4264
+ if (options.outputFile !== void 0) {
4265
+ AgentFileOutputPolicySchema.parse(options.outputFile);
4266
+ if (providerCapabilities.workspace.retainFileOutput !== true || !options.environment.retain?.paths.includes(options.outputFile.path)) throw new Error("retained file output requires declared provider support and retention of the output path");
4267
+ }
4254
4268
  if (transferReceipt !== void 0) assertRetainedContextTransferCapability(providerCapabilities);
4255
4269
  assertRequestedInteractionCapabilities(options.provider.name, options.turn.interactions, providerCapabilities);
4256
4270
  options.environment.signal?.throwIfAborted();
@@ -4278,6 +4292,7 @@ async function startRetainedRun(options) {
4278
4292
  try {
4279
4293
  capabilities = retainedCapabilitiesForEnvironment(options.provider.name, providerCapabilities, environment);
4280
4294
  if (transferReceipt !== void 0) assertRetainedContextTransferCapability(capabilities);
4295
+ if (options.outputFile !== void 0 && (capabilities.workspace.retainFileOutput !== true || !environment.retainFileOutput)) throw new Error("this environment cannot publish the declared retained file output");
4281
4296
  assertRequestedInteractionCapabilities(options.provider.name, options.turn.interactions, capabilities);
4282
4297
  if (!environment.dispatch || !environment.session) {
4283
4298
  teardownFailure = "retained run could not start and its unused environment could not be destroyed";
@@ -4589,11 +4604,13 @@ function retainedRunIntent(options, identity, contextTransfer, turnFields) {
4589
4604
  turnId: options.turn.turnId,
4590
4605
  sessionId: identity.sessionId,
4591
4606
  executionId: identity.executionId,
4592
- requestedProfileDigest
4607
+ requestedProfileDigest,
4608
+ ...options.outputFile === void 0 ? {} : { outputFilePolicyDigest: canonicalCandidateDigest(options.outputFile) }
4593
4609
  };
4594
4610
  const requestDigest = canonicalCandidateDigest({
4595
4611
  kind: turnFields === void 0 ? "retained-run-intent.v2" : "retained-run-intent.v1",
4596
4612
  ...material,
4613
+ ...options.outputFile === void 0 ? {} : { outputFile: options.outputFile },
4597
4614
  ...options.existingEnvironmentId === void 0 ? {} : { existingEnvironmentId: options.existingEnvironmentId },
4598
4615
  ...receipt === void 0 ? {} : { contextTransferReceiptDigest: canonicalCandidateDigest({
4599
4616
  ...receipt,
@@ -4630,6 +4647,7 @@ function parseRetainedRunIntent(value, expected) {
4630
4647
  for (const [key, value] of Object.entries(record)) if (key !== "phase" && (typeof value !== "string" || value.length === 0)) throw new Error(`retained run intent field "${key}" is invalid`);
4631
4648
  assertDigest$2(record.requestedProfileDigest, "retained run intent profile digest");
4632
4649
  assertDigest$2(record.requestDigest, "retained run intent request digest");
4650
+ if (record.outputFilePolicyDigest !== void 0) assertDigest$2(record.outputFilePolicyDigest, "retained run intent file policy digest");
4633
4651
  return stable;
4634
4652
  }
4635
4653
  function assertDigest$2(value, label) {
@@ -4920,7 +4938,7 @@ var SpawnEventIndex = class {
4920
4938
  if (event.kind === "admission-granted" && node.grantClock && (event.deadlineArmedAt !== node.grantClock.deadlineArmedAt || event.deadlineAt !== node.grantClock.deadlineAt)) throw new Error(`spawn journal corrupted: admission deadline changed for '${event.id}'`);
4921
4939
  }
4922
4940
  if (event.kind === "execution-evidence") {
4923
- if (!node?.spawned || !/^sha256:[0-9a-f]{64}$/.test(event.outRef)) throw new Error("spawn journal corrupted: executor evidence has no spawned node or valid content reference");
4941
+ if (!node?.spawned || !/^sha256:[0-9a-f]{64}$/.test(event.outRef) || event.attemptId !== void 0 && (typeof event.attemptId !== "string" || !event.attemptId)) throw new Error("spawn journal corrupted: executor evidence has no spawned node, valid content reference or attempt");
4924
4942
  }
4925
4943
  if (event.kind === "materialized") {
4926
4944
  if (node?.materialized) throw new Error(`spawn journal corrupted: duplicate materialization receipt for node '${event.id}' in tree '${this.root}'`);
@@ -5455,6 +5473,81 @@ function ownedTreeRootSpawn(spawn) {
5455
5473
  const { parent: _parent, ownedTreeRoot: _ownedTreeRoot, ...root } = spawn;
5456
5474
  return root;
5457
5475
  }
5476
+ // src/runtime/supervise/retained-owner-state.ts
5477
+ const owners = /* @__PURE__ */ new WeakMap();
5478
+ /** Bound native custody, read from its canonical receipts without probing another provider. */
5479
+ function scopeOwnerLiabilities(scope, events) {
5480
+ const state = owners.get(scope);
5481
+ if (!state) return {
5482
+ environmentHeld: false,
5483
+ invocationUnsettled: false,
5484
+ measuredResources: /* @__PURE__ */ new Map()
5485
+ };
5486
+ const held = /* @__PURE__ */ new Set();
5487
+ const destroyed = /* @__PURE__ */ new Set();
5488
+ const forks = /* @__PURE__ */ new Set();
5489
+ const key = (provider, id) => JSON.stringify([provider, id]);
5490
+ const forkKey = (provider, id, environmentId) => JSON.stringify([
5491
+ provider,
5492
+ id,
5493
+ environmentId ?? null
5494
+ ]);
5495
+ let invocationUnsettled = false;
5496
+ let environment;
5497
+ const measurements = /* @__PURE__ */ new Map();
5498
+ for (const event of events) {
5499
+ if (event.id !== state.args.nodeId) continue;
5500
+ if (event.kind === "execution-admitted") {
5501
+ invocationUnsettled = true;
5502
+ if (event.admission.phase === "environment") {
5503
+ environment = key(event.admission.provider, event.admission.environmentId);
5504
+ held.add(environment);
5505
+ destroyed.delete(environment);
5506
+ measurements.delete(environment);
5507
+ }
5508
+ } else if (event.kind === "execution-result") {
5509
+ invocationUnsettled = false;
5510
+ if (environment !== void 0) measurements.set(environment, new Map(Object.entries(event.spent.resources ?? {}).flatMap(([name, value]) => value.known ? [[name, value.unit]] : [])));
5511
+ } else if (event.kind === "environment-teardown" && event.destroyed) {
5512
+ held.delete(key(event.provider, event.environmentId));
5513
+ destroyed.add(key(event.provider, event.environmentId));
5514
+ } else if (event.kind === "workspace-checkpoint-fork-requested") forks.add(forkKey(event.provider, event.idempotencyKey));
5515
+ else if (event.kind === "workspace-checkpoint-fork-ready") {
5516
+ forks.delete(forkKey(event.provider, event.fork.idempotencyKey));
5517
+ forks.add(forkKey(event.provider, event.fork.idempotencyKey, event.fork.environmentId));
5518
+ } else if (event.kind === "workspace-checkpoint-fork-teardown" && event.destroyed) {
5519
+ forks.delete(forkKey(event.provider, event.fork.idempotencyKey));
5520
+ forks.delete(forkKey(event.provider, event.fork.idempotencyKey, event.fork.environmentId));
5521
+ }
5522
+ }
5523
+ const live = state.liveEnvironmentId?.();
5524
+ if (live !== void 0 && (state.provider === void 0 || !destroyed.has(key(state.provider.name, live)))) held.add(key(state.provider?.name ?? "", live));
5525
+ const measuredResources = new Map(measurements.get([...held][0] ?? "") ?? []);
5526
+ for (const reference of held) for (const [name, unit] of measuredResources) if (measurements.get(reference)?.get(name) !== unit) measuredResources.delete(name);
5527
+ if (forks.size > 0 || invocationUnsettled) measuredResources.clear();
5528
+ return {
5529
+ environmentHeld: held.size > 0 || forks.size > 0,
5530
+ invocationUnsettled,
5531
+ measuredResources
5532
+ };
5533
+ }
5534
+ function scopeRetainedOwnerContext(scope) {
5535
+ return owners.get(scope)?.context;
5536
+ }
5537
+ /** The journal tree that owns this manager turn, including nested driver children. */
5538
+ function scopeRetainedOwnerJournalRoot(scope) {
5539
+ return owners.get(scope)?.args.rootId;
5540
+ }
5541
+ /** Bind the provider that owns native stop, checkpoint and environment acknowledgements. */
5542
+ function bindScopeRetainedOwnerProvider(scope, provider) {
5543
+ const state = owners.get(scope);
5544
+ if (state) state.provider = provider;
5545
+ }
5546
+ /** Bind the resolver for the owner's current environment id. Admissions alone miss a provider that never writes an environment admission. */
5547
+ function bindScopeRetainedOwnerEnvironmentId(scope, liveEnvironmentId) {
5548
+ const state = owners.get(scope);
5549
+ if (state) state.liveEnvironmentId = liveEnvironmentId;
5550
+ }
5458
5551
  // src/runtime/supervise/retained-owner-checkpoint-requests.ts
5459
5552
  /** Reconstruct authority for this source only; a replacement cannot own its snapshots. */
5460
5553
  async function checkpointHandle(state, sourceEnvironmentId, signal) {
@@ -5670,81 +5763,6 @@ async function settleCaptureForks(state, parent) {
5670
5763
  }
5671
5764
  return unresolved;
5672
5765
  }
5673
- // src/runtime/supervise/retained-owner-state.ts
5674
- const owners = /* @__PURE__ */ new WeakMap();
5675
- /** Bound native custody, read from its canonical receipts without probing another provider. */
5676
- function scopeOwnerLiabilities(scope, events) {
5677
- const state = owners.get(scope);
5678
- if (!state) return {
5679
- environmentHeld: false,
5680
- invocationUnsettled: false,
5681
- measuredResources: /* @__PURE__ */ new Map()
5682
- };
5683
- const held = /* @__PURE__ */ new Set();
5684
- const destroyed = /* @__PURE__ */ new Set();
5685
- const forks = /* @__PURE__ */ new Set();
5686
- const key = (provider, id) => JSON.stringify([provider, id]);
5687
- const forkKey = (provider, id, environmentId) => JSON.stringify([
5688
- provider,
5689
- id,
5690
- environmentId ?? null
5691
- ]);
5692
- let invocationUnsettled = false;
5693
- let environment;
5694
- const measurements = /* @__PURE__ */ new Map();
5695
- for (const event of events) {
5696
- if (event.id !== state.args.nodeId) continue;
5697
- if (event.kind === "execution-admitted") {
5698
- invocationUnsettled = true;
5699
- if (event.admission.phase === "environment") {
5700
- environment = key(event.admission.provider, event.admission.environmentId);
5701
- held.add(environment);
5702
- destroyed.delete(environment);
5703
- measurements.delete(environment);
5704
- }
5705
- } else if (event.kind === "execution-result") {
5706
- invocationUnsettled = false;
5707
- if (environment !== void 0) measurements.set(environment, new Map(Object.entries(event.spent.resources ?? {}).flatMap(([name, value]) => value.known ? [[name, value.unit]] : [])));
5708
- } else if (event.kind === "environment-teardown" && event.destroyed) {
5709
- held.delete(key(event.provider, event.environmentId));
5710
- destroyed.add(key(event.provider, event.environmentId));
5711
- } else if (event.kind === "workspace-checkpoint-fork-requested") forks.add(forkKey(event.provider, event.idempotencyKey));
5712
- else if (event.kind === "workspace-checkpoint-fork-ready") {
5713
- forks.delete(forkKey(event.provider, event.fork.idempotencyKey));
5714
- forks.add(forkKey(event.provider, event.fork.idempotencyKey, event.fork.environmentId));
5715
- } else if (event.kind === "workspace-checkpoint-fork-teardown" && event.destroyed) {
5716
- forks.delete(forkKey(event.provider, event.fork.idempotencyKey));
5717
- forks.delete(forkKey(event.provider, event.fork.idempotencyKey, event.fork.environmentId));
5718
- }
5719
- }
5720
- const live = state.liveEnvironmentId?.();
5721
- if (live !== void 0 && (state.provider === void 0 || !destroyed.has(key(state.provider.name, live)))) held.add(key(state.provider?.name ?? "", live));
5722
- const measuredResources = new Map(measurements.get([...held][0] ?? "") ?? []);
5723
- for (const reference of held) for (const [name, unit] of measuredResources) if (measurements.get(reference)?.get(name) !== unit) measuredResources.delete(name);
5724
- if (forks.size > 0 || invocationUnsettled) measuredResources.clear();
5725
- return {
5726
- environmentHeld: held.size > 0 || forks.size > 0,
5727
- invocationUnsettled,
5728
- measuredResources
5729
- };
5730
- }
5731
- function scopeRetainedOwnerContext(scope) {
5732
- return owners.get(scope)?.context;
5733
- }
5734
- /** The journal tree that owns this manager turn, including nested driver children. */
5735
- function scopeRetainedOwnerJournalRoot(scope) {
5736
- return owners.get(scope)?.args.rootId;
5737
- }
5738
- /** Bind the provider that owns native stop, checkpoint and environment acknowledgements. */
5739
- function bindScopeRetainedOwnerProvider(scope, provider) {
5740
- const state = owners.get(scope);
5741
- if (state) state.provider = provider;
5742
- }
5743
- /** Bind the resolver for the owner's current environment id. Admissions alone miss a provider that never writes an environment admission. */
5744
- function bindScopeRetainedOwnerEnvironmentId(scope, liveEnvironmentId) {
5745
- const state = owners.get(scope);
5746
- if (state) state.liveEnvironmentId = liveEnvironmentId;
5747
- }
5748
5766
  // src/runtime/supervise/retained-owner-checkpoint-rotation.ts
5749
5767
  /** Checkpoint after a coordination call once the last one is older than {@link WORKSPACE_CHECKPOINT_MIN_INTERVAL_MS}. It never delays the call, and a failure leaves the previous restore point. */
5750
5768
  function noteScopeRetainedOwnerCoordination(scope) {
@@ -5899,8 +5917,10 @@ function ownerWorkspaceAttempts(events, nodeId) {
5899
5917
  } else if (event.kind === "execution-admitted" && event.admission.phase === "dispatched") {
5900
5918
  current?.admissions.push(event.admission);
5901
5919
  current?.controlByEnvironment.set(event.admission.controlRef.environmentId, event.admission.controlRef);
5902
- } else if (event.kind === "execution-admitted") current?.admissions.push(event.admission);
5903
- else if (event.kind === "execution-bound") {
5920
+ } else if (event.kind === "execution-admitted") {
5921
+ current?.admissions.push(event.admission);
5922
+ if (current && event.admission.phase === "intent" && event.admission.outputFilePolicyDigest) current.outputFilePolicyDigest = current.outputFilePolicyDigest === void 0 || current.outputFilePolicyDigest === event.admission.outputFilePolicyDigest ? event.admission.outputFilePolicyDigest : "conflicting-file-policies";
5923
+ } else if (event.kind === "execution-bound") {
5904
5924
  if (current !== void 0 && current.result === void 0) current.binding = event.binding;
5905
5925
  } else if (event.kind === "execution-result") {
5906
5926
  current ??= fresh();
@@ -5917,7 +5937,7 @@ async function ownerWorkspaceRetentionFailures(events, owner) {
5917
5937
  const failures = /* @__PURE__ */ new Map();
5918
5938
  for (const index of attempts.keys()) {
5919
5939
  const attempt = withLaterEvidence(attempts, index);
5920
- if (attempt.workspaceRetention !== true) continue;
5940
+ if (attempt.workspaceRetention !== true && attempt.outputFilePolicyDigest === void 0) continue;
5921
5941
  if (attempt.environmentIds.size === 0) continue;
5922
5942
  if (attempt.environmentIds.size > 1) {
5923
5943
  for (const environmentId of attempt.environmentIds) failures.set(environmentId, UNVERIFIED_SOURCE);
@@ -5945,6 +5965,13 @@ function withLaterEvidence(attempts, index) {
5945
5965
  /** Undefined when a receipt authorizes destroying the source. Otherwise why it stays. */
5946
5966
  async function ownerAttemptHasCapture(attempt, environmentId, blobs, owner, allowPartialProcessCapture = false) {
5947
5967
  const controlRef = attempt.controlByEnvironment.get(environmentId);
5968
+ if (attempt.outputFilePolicyDigest !== void 0) {
5969
+ const output = attempt.result === void 0 ? void 0 : recordValue(await storedOutput(blobs, attempt.result.outRef));
5970
+ const publication = AgentRetainedFilePublicationSchema.safeParse(output?.publication);
5971
+ const node = owner === void 0 ? void 0 : ownerCaptureIdentity(attempt, owner).node;
5972
+ if (!output || output.kind !== "retained-file-output" || output.version !== 1 || output.invocationId !== attempt.executionId || output.policyDigest !== attempt.outputFilePolicyDigest || !Object.hasOwn(output, "submission") || !recordValue(output.node) || output.submissionRef !== contentAddress(output.submission) || !node || contentAddress(output.node) !== contentAddress(node) || !publication.success || !controlRef || !sameControlCoordinates(publication.data.controlRef, controlRef) || canonicalCandidateDigest(publication.data.policy) !== attempt.outputFilePolicyDigest) return UNVERIFIED_SOURCE;
5973
+ if (attempt.workspaceRetention !== true) return void 0;
5974
+ }
5948
5975
  const receipts = [...attempt.result === void 0 || attempt.result.outputFormat === "json" ? [] : [attempt.result.outRef], ...attempt.evidence.map((event) => event.outRef)];
5949
5976
  const identity = owner === void 0 ? void 0 : ownerCaptureIdentity(attempt, owner);
5950
5977
  let verified = false;
@@ -5985,7 +6012,7 @@ function ownerCaptureIdentity(attempt, owner) {
5985
6012
  };
5986
6013
  }
5987
6014
  /** Recover evidence before reuse. Failed unverified turns keep their invocation; accepted turns owe evidence. */
5988
- async function reconcileOwnerWorkspaceBeforeReuse(state, signal) {
6015
+ async function reconcileOwnerWorkspaceBeforeReuse(state, signal, reconnecting = false) {
5989
6016
  const { args } = state;
5990
6017
  const indebted = /* @__PURE__ */ new Set();
5991
6018
  const events = await args.journal.loadTree(args.rootId) ?? [];
@@ -5996,10 +6023,13 @@ async function reconcileOwnerWorkspaceBeforeReuse(state, signal) {
5996
6023
  const reusing = new Set(latest.environmentIds);
5997
6024
  if (latest.result === void 0 && state.priorSession !== void 0) reusing.add(state.priorSession.environmentId);
5998
6025
  for (const attempt of attempts) {
5999
- if (attempt.workspaceRetention !== true || attempt.result === void 0) continue;
6026
+ if ((attempt.workspaceRetention !== true || attempt.result === void 0) && attempt.outputFilePolicyDigest === void 0) continue;
6027
+ if (reconnecting && attempt === latest && attempt.result === void 0) continue;
6000
6028
  for (const environmentId of attempt.environmentIds) {
6001
6029
  if (!reusing.has(environmentId) || unusable.has(environmentId)) continue;
6002
6030
  if (await ownerAttemptHasCapture(attempt, environmentId, args.blobs, args, true) === void 0) continue;
6031
+ if (attempt.outputFilePolicyDigest !== void 0) throw new RetainedExecutionPendingError(/* @__PURE__ */ new Error(UNVERIFIED_SOURCE), "unobservable");
6032
+ if (attempt.result === void 0) continue;
6003
6033
  signal.throwIfAborted();
6004
6034
  const failure = capturePendingMessage(attempt.executionId ?? args.nodeId, /* @__PURE__ */ new Error("client capture writers are retired; a persisted verified receipt is required"));
6005
6035
  if (executorFailureReason(attempt.result) === void 0) await owePendingEvidence(state, events, attempt, environmentId, failure);
@@ -6341,6 +6371,35 @@ async function scopeRetainedOwnerSettled(scope) {
6341
6371
  await scopeRetainedOwnerTurnEnded(scope);
6342
6372
  await state.releasing?.catch(() => void 0);
6343
6373
  }
6374
+ // src/runtime/supervise/harness-transcript-evidence.ts
6375
+ /**
6376
+ * Bind one capture to the input and output of the exact attempt that produced it. The record holds
6377
+ * content only; the attempt id names the journal row that cites it, so equal evidence keeps one
6378
+ * content address across runs.
6379
+ */
6380
+ async function recordHarnessTranscriptEvidence(args) {
6381
+ const task = detachedSnapshot(args.task, "execution transcript input");
6382
+ const taskRef = contentAddress(task);
6383
+ await args.blobs.put(taskRef, task);
6384
+ const { attemptId, ...node } = args.node;
6385
+ const evidence = {
6386
+ kind: "harness-transcript",
6387
+ schemaVersion: 1,
6388
+ node,
6389
+ taskRef,
6390
+ ...args.outRef === void 0 ? {} : { outRef: args.outRef },
6391
+ harnessTranscript: args.harnessTranscript
6392
+ };
6393
+ for (const rootId of new Set(args.roots)) await executorEvidenceWriter({
6394
+ journal: args.journal,
6395
+ blobs: args.blobs,
6396
+ rootId,
6397
+ nodeId: args.node.nodeId,
6398
+ attemptId,
6399
+ nextSequence: () => 0,
6400
+ now: args.now
6401
+ })(evidence);
6402
+ }
6344
6403
  // src/runtime/supervise/provider-visible-profile.ts
6345
6404
  /** Runtime-owned coordination is mounted under this MCP alias. */
6346
6405
  const coordinationMcpAlias = "agent-runtime-coordination";
@@ -6351,7 +6410,7 @@ const coordinationProfileToolPrefix = `${coordinationMcpAlias.replaceAll("-", "_
6351
6410
  const runtimeGraphMetadataKey = "agentRuntimeGraph";
6352
6411
  /** Remove Runtime-only grants, seat policy and graph topology from the provider-facing profile. */
6353
6412
  function providerVisibleProfile(profile) {
6354
- const { seats: _seats, ...withoutSeats } = profile;
6413
+ const { seats: _seats, outputFile: _outputFile, ...withoutSeats } = profile;
6355
6414
  const visible = withoutRuntimeGraph(withoutSeats);
6356
6415
  if (profile.tools === void 0) return visible;
6357
6416
  const providerTools = Object.fromEntries(Object.entries(profile.tools).filter(([name]) => !name.startsWith(coordinationProfileToolPrefix)));
@@ -6529,6 +6588,49 @@ function scopeOwnerExecutorNodeContext(scope) {
6529
6588
  attemptId: state.attemptId
6530
6589
  });
6531
6590
  }
6591
+ /**
6592
+ * @internal Hold this scope's settlement until a driver attempt's transcript record finishes. A
6593
+ * cancelled run settles without waiting for its root driver; the hold keeps that record from
6594
+ * landing after the run has returned. Call the returned release once the attempt is done.
6595
+ */
6596
+ function holdScopeOwnerTranscript(scope) {
6597
+ const state = ownerMaterializationStates.get(scope);
6598
+ if (state === void 0) return () => {};
6599
+ let release;
6600
+ const hold = new Promise((resolve) => {
6601
+ release = resolve;
6602
+ });
6603
+ state.transcriptHolds ??= /* @__PURE__ */ new Set();
6604
+ const holds = state.transcriptHolds;
6605
+ holds.add(hold);
6606
+ return () => {
6607
+ holds.delete(hold);
6608
+ release();
6609
+ };
6610
+ }
6611
+ /** Retain every manager attempt's native evidence without accepting another execution result. */
6612
+ async function recordScopeOwnerHarnessTranscript(scope, task, capture, result) {
6613
+ const state = ownerMaterializationState(scope);
6614
+ const node = scopeOwnerExecutorNodeContext(scope);
6615
+ const input = detachedSnapshot(task, "manager execution input");
6616
+ await serializedOwnerWrite(state, async () => {
6617
+ const output = result?.out === void 0 ? void 0 : detachedSnapshot(result.out, "manager execution output");
6618
+ const outRef = output === void 0 ? void 0 : contentAddress(output);
6619
+ if (outRef !== void 0) await state.blobs.put(outRef, output);
6620
+ const harnessTranscript = await persistHarnessTranscript(capture, state.blobs);
6621
+ await recordHarnessTranscriptEvidence({
6622
+ node,
6623
+ task: input,
6624
+ ...outRef === void 0 ? {} : { outRef },
6625
+ harnessTranscript,
6626
+ journal: state.journal,
6627
+ roots: [state.root, state.retainedRoot],
6628
+ blobs: state.blobs,
6629
+ now: state.now
6630
+ });
6631
+ if (harnessTranscript.status === "unavailable" && capture.status !== "unavailable") throw new ValidationError("manager transcript capture could not be persisted");
6632
+ });
6633
+ }
6532
6634
  /** Reuse a committed owner invocation without inventing another provider attempt. @internal */
6533
6635
  async function restoreScopeOwnerAcceptedExecution(scope) {
6534
6636
  const state = ownerMaterializationState(scope);
@@ -6557,6 +6659,8 @@ async function restoreScopeOwnerAcceptedExecution(scope) {
6557
6659
  async function finalizeScopeOwnerMaterialization(scope) {
6558
6660
  const state = ownerMaterializationStates.get(scope);
6559
6661
  if (state === void 0) return;
6662
+ const holds = state.transcriptHolds;
6663
+ if (holds?.size) await settleHarnessTranscript({ harnessTranscriptSettled: () => Promise.all(holds).then(() => void 0) });
6560
6664
  await serializedOwnerWrite(state, () => finalizeOwnerMaterialization(state));
6561
6665
  }
6562
6666
  async function finalizeOwnerMaterialization(state) {
@@ -6802,6 +6906,10 @@ function registerScopeRetainedOwner(scope, args) {
6802
6906
  now: args.now,
6803
6907
  traceRoots
6804
6908
  }),
6909
+ onHarnessTranscript: async (task, capture, result) => {
6910
+ if (!ownerMaterializationStates.has(scope)) return;
6911
+ await recordScopeOwnerHarnessTranscript(scope, task, capture, result);
6912
+ },
6805
6913
  onEndOfTurnWork: (work) => {
6806
6914
  preemptRotationCaptures(state);
6807
6915
  const prior = state.turnEnd;
@@ -6931,7 +7039,10 @@ async function prepareScopeRetainedOwnerTask(scope, task, session = "native") {
6931
7039
  const accepted = [...attempt].reverse().find((event) => event.kind === "execution-result");
6932
7040
  if (accepted?.kind === "execution-result") state.acceptedRef = accepted;
6933
7041
  }
6934
- if (state.taskRef !== void 0 && state.acceptedRef === void 0) await abandonInputAdmittedIntoDebt(state, await reconcileOwnerWorkspaceBeforeReuse(state, scope.signal));
7042
+ if (state.taskRef !== void 0 && state.acceptedRef === void 0) {
7043
+ const abandoned = latestInput?.kind === "execution-input" && owned.slice(owned.indexOf(latestInput)).some((event) => event.kind === "execution-abandoned");
7044
+ await abandonInputAdmittedIntoDebt(state, await reconcileOwnerWorkspaceBeforeReuse(state, scope.signal, session === "native" && !abandoned));
7045
+ }
6935
7046
  const unusable = unusableEnvironmentIds(owned);
6936
7047
  const currentEnvironment = state.admissions.find((admission) => admission.phase === "environment");
6937
7048
  if (state.acceptedRef === void 0 && currentEnvironment?.phase === "environment" && unusable.has(currentEnvironment.environmentId)) {
@@ -7046,8 +7157,9 @@ function retainedOwnerReleaseRetriable(scope) {
7046
7157
  /** One budget for every checkpoint lookup, delete and fork cleanup this release starts. Work cut short keeps its checkpoint and source. */
7047
7158
  const RELEASE_CHECKPOINT_CAPTURES_MS = 9e5;
7048
7159
  /** A release's wait for its destroys; a delete grows with the retained workspace it seals (Sandbox
7049
- * 2026-11-11: 2-4 s at 1 MB, 30 s at 300 MB, 72 s at 1 GB). A later release joins the rest. */
7050
- const RELEASE_DESTROY_MS = 3e5;
7160
+ * 2026-11-11: 2-4 s at 1 MB, 30 s at 300 MB, 72 s at 1 GB). A later release joins the rest. A
7161
+ * settling run's whole teardown fits in one such wait, so a cancel settles in about this long. */
7162
+ const RELEASE_DESTROY_MS = 9e4;
7051
7163
  /**
7052
7164
  * Release the owner's environment once no turn of it will run again. A second call joins the one
7053
7165
  * in flight. The end-of-turn capture finishes before destroy. `capturesMs` bounds checkpoint work.
@@ -7098,9 +7210,18 @@ async function releaseOwnerEnvironment(state, provider, capturesMs, destroyMs) {
7098
7210
  }
7099
7211
  const forksUnresolved = await settleCaptureForks(state, captures.signal);
7100
7212
  for (const { event } of checkpointFailures) pendingSources.add(event.environmentId);
7101
- const destroyDeadline = AbortSignal.timeout(destroyMs);
7102
- const destroys = new Map([...environments].filter((id) => !released.has(id) && !retentionFailures.has(id) && !pendingSources.has(id)).map((id) => {
7103
- const wait = runAbortable(() => ownerEnvironmentDestroy(state, provider, id), destroyDeadline, () => /* @__PURE__ */ new Error(`destroy still running after ${destroyMs} ms`));
7213
+ const held = state.held ??= /* @__PURE__ */ new Map();
7214
+ const asking = [...environments].filter((id) => !released.has(id) && !retentionFailures.has(id) && !pendingSources.has(id) && !held.has(id));
7215
+ const clock = state.releaseClock;
7216
+ if (clock !== void 0 && asking.length > 0) {
7217
+ clock.startedAt ??= Date.now();
7218
+ state.releaseDestroysAt ??= Date.now();
7219
+ }
7220
+ const left = clock?.startedAt === void 0 ? Number.POSITIVE_INFINITY : Math.max(clock.startedAt + clock.windowMs, (state.releaseDestroysAt ?? Date.now()) + destroyMs) - Date.now();
7221
+ const waitMs = Math.max(0, Math.min(destroyMs, left));
7222
+ const destroyDeadline = AbortSignal.timeout(waitMs);
7223
+ const destroys = new Map(asking.map((id) => {
7224
+ const wait = runAbortable(() => ownerEnvironmentDestroy(state, provider, id), destroyDeadline, () => /* @__PURE__ */ new Error(`destroy still running after ${waitMs} ms`));
7104
7225
  wait.catch(() => void 0);
7105
7226
  return [id, wait];
7106
7227
  }));
@@ -7108,24 +7229,33 @@ async function releaseOwnerEnvironment(state, provider, capturesMs, destroyMs) {
7108
7229
  if (released.has(environmentId)) continue;
7109
7230
  let destroyed = false;
7110
7231
  let detail;
7111
- const retentionReason = retentionFailures.get(environmentId);
7232
+ const asked = destroys.get(environmentId);
7233
+ const heldBefore = asked === void 0 ? held.get(environmentId) : void 0;
7234
+ const retentionReason = retentionFailures.get(environmentId) ?? heldBefore;
7112
7235
  const nativeHold = retentionReason?.startsWith("native session copy incomplete:") === true;
7113
7236
  if (retentionReason !== void 0 || pendingSources.has(environmentId)) {
7114
7237
  detail = !nativeHold && pendingSources.has(environmentId) ? "checkpoint cleanup unresolved: source preserved for exact lookup and cleanup" : retentionReason;
7115
7238
  preserved.push(environmentId);
7116
7239
  lastDetail = detail;
7117
7240
  } else try {
7118
- await destroys.get(environmentId);
7241
+ await asked;
7119
7242
  destroyed = true;
7120
7243
  } catch (error) {
7121
- detail = `retained owner environment cleanup was not confirmed: ${errMessage(error).slice(0, 500)}`;
7122
- unconfirmed.push(environmentId);
7244
+ detail = held.get(environmentId) ?? `retained owner environment cleanup was not confirmed: ${errMessage(error).slice(0, 500)}`;
7123
7245
  lastDetail = detail;
7124
- if (!(error instanceof PermanentReleaseRefusal)) retriable = true;
7246
+ if (held.has(environmentId)) preserved.push(environmentId);
7247
+ else {
7248
+ unconfirmed.push(environmentId);
7249
+ if (!(error instanceof PermanentReleaseRefusal)) retriable = true;
7250
+ }
7125
7251
  }
7126
7252
  if (!destroyed && !state.destroys?.has(environmentId)) {
7127
7253
  const runs = unsettledOwnerRuns(events, args.nodeId, environmentId);
7128
- if (runs.length > 0) {
7254
+ if (runs.length > 0 && held.has(environmentId)) {
7255
+ const stops = runs.map((run) => `native execution ${run.executionId} ${HELD_STOP}; ${NATIVE_STOP_UNCONFIRMED}`);
7256
+ detail = `${detail}; ${stops.join("; ")}`;
7257
+ lastDetail = detail;
7258
+ } else if (runs.length > 0) {
7129
7259
  const stops = await Promise.all(runs.map((controlRef) => stopRetainedNativeExecution({
7130
7260
  provider,
7131
7261
  controlRef,
@@ -7189,6 +7319,15 @@ async function releaseOwnerEnvironment(state, provider, capturesMs, destroyMs) {
7189
7319
  }, ...checkpointTeardowns] : checkpointTeardowns;
7190
7320
  }
7191
7321
  var PermanentReleaseRefusal = class extends Error {};
7322
+ const HELD_STOP = "stop not attempted: its provider holds the environment under a retention hold and a reconnect would wake it";
7323
+ /**
7324
+ * A provider that keeps an environment under a retention hold refuses its delete until the hold is
7325
+ * released: 409 `RETENTION_HOLD`, or a refusal whose message names the hold. The holder, not this
7326
+ * release, decides when the environment goes.
7327
+ */
7328
+ function retentionHoldRefusal(error) {
7329
+ return causeChain(error).some((cause) => Reflect.get(cause, "code") === "RETENTION_HOLD") || /\bunder retention hold\b/iu.test(errMessage(error));
7330
+ }
7192
7331
  /** A destroy in flight this long is presumed lost, and the next release asks the provider again. */
7193
7332
  const RELEASE_DESTROY_ABANDONED_MS = 9e5;
7194
7333
  /**
@@ -7213,8 +7352,9 @@ function ownerEnvironmentDestroy(state, provider, environmentId) {
7213
7352
  since: Date.now()
7214
7353
  };
7215
7354
  destroys.set(environmentId, entry);
7216
- destroy.catch(() => {
7355
+ destroy.catch((error) => {
7217
7356
  if (destroys.get(environmentId) === entry) destroys.delete(environmentId);
7357
+ if (retentionHoldRefusal(error)) (state.held ??= /* @__PURE__ */ new Map()).set(environmentId, `environment kept: its provider refuses deletion under a retention hold (${errMessage(error).slice(0, 500)})`);
7218
7358
  });
7219
7359
  return destroy;
7220
7360
  }
@@ -7745,17 +7885,34 @@ async function startScopeRecoveries(scope) {
7745
7885
  * root is live, and never on a resumable interruption, since the open slot and the live
7746
7886
  * environment are exactly what a resume recovers. One `environment-teardown` receipt is journaled
7747
7887
  * per environment, on this scope's own tree; a nested manager reaches its children through
7748
- * `Executor.releaseRetained`, and its nested scope journals theirs.
7888
+ * `Executor.releaseRetained`, and its nested scope journals theirs. The children, the nested
7889
+ * managers and this scope's own owner release at once, so a tree waits one destroy wait, not one
7890
+ * per level.
7749
7891
  */
7750
7892
  async function releaseRetainedEnvironments(scope) {
7751
7893
  releasingScopes.add(scope);
7752
- const release = retainedReleasers.get(scope);
7753
- if (release) await release();
7754
- await releaseNestedManagerEnvironments(scope);
7755
- ownerUnconfirmedByScope.set(scope, await releaseScopeRetainedOwnerEnvironment(scope));
7756
- await scopeSeatAccountingUpdates.get(scope)?.();
7894
+ await releaseScope(scope, true);
7757
7895
  return unconfirmedTeardowns(scope);
7758
7896
  }
7897
+ /** Release a scope's retained children and its own owner, and with `nested` its nested managers'
7898
+ * trees, all at once. */
7899
+ async function releaseScope(scope, nested) {
7900
+ await Promise.all([
7901
+ retainedReleasers.get(scope)?.(),
7902
+ nested && releaseNestedManagerEnvironments(scope),
7903
+ releaseScopeRetainedOwnerEnvironment(scope).then((unconfirmed) => {
7904
+ ownerUnconfirmedByScope.set(scope, unconfirmed);
7905
+ })
7906
+ ]);
7907
+ await scopeSeatAccountingUpdates.get(scope)?.();
7908
+ }
7909
+ /** @internal Bound every owner release in this scope's tree by the settling run's one teardown
7910
+ * clock, so no destroy wait at any level outlasts it. */
7911
+ function boundRetainedReleases(scope, clock) {
7912
+ const owner = owners.get(scope);
7913
+ if (owner !== void 0) owner.releaseClock = clock;
7914
+ for (const nested of nestedManagerScopes(scope)) boundRetainedReleases(nested, clock);
7915
+ }
7759
7916
  /** The manager scopes this scope's children own, read live. */
7760
7917
  function nestedManagerScopes(scope) {
7761
7918
  return nestedManagerScopeReaders.get(scope)?.() ?? [];
@@ -7775,15 +7932,8 @@ async function releaseNestedManagerEnvironments(scope) {
7775
7932
  * last end-of-turn capture, so it runs beside the settlement; later calls join it.
7776
7933
  */
7777
7934
  function releaseManagerEnvironment(scope) {
7778
- let release = managerEnvironmentReleases.get(scope);
7779
- if (release === void 0) {
7780
- release = Promise.all([retainedReleasers.get(scope)?.(), releaseScopeRetainedOwnerEnvironment(scope).then((unconfirmed) => {
7781
- ownerUnconfirmedByScope.set(scope, unconfirmed);
7782
- })]).then(async () => {
7783
- await scopeSeatAccountingUpdates.get(scope)?.();
7784
- });
7785
- managerEnvironmentReleases.set(scope, release);
7786
- }
7935
+ const release = managerEnvironmentReleases.get(scope) ?? releaseScope(scope, false);
7936
+ managerEnvironmentReleases.set(scope, release);
7787
7937
  return release;
7788
7938
  }
7789
7939
  /**
@@ -8875,150 +9025,6 @@ async function appendNodeMaterialization(args, id, seq, receipt, binding, now) {
8875
9025
  at
8876
9026
  });
8877
9027
  }
8878
- // src/runtime/supervise/scope-child-retention.ts
8879
- /** Own the retained child invocation and its durable writes. */
8880
- function createChildRetention({ args, controller, id, ordinal, attemptId, identity, recovery, opts, now, traceRoots, markRecoveryReady, admission, readLive, completeEvidence }) {
8881
- const retainedWrites = /* @__PURE__ */ new Set();
8882
- let retainedWritesClosed = false;
8883
- const retainedWrite = (write) => {
8884
- controller.signal.throwIfAborted();
8885
- if (retainedWritesClosed) throw new ValidationError("retained child writer is closed");
8886
- const pending = write();
8887
- retainedWrites.add(pending);
8888
- pending.then(() => retainedWrites.delete(pending), () => retainedWrites.delete(pending));
8889
- return pending;
8890
- };
8891
- const closeRetainedWrites = async () => {
8892
- retainedWritesClosed = true;
8893
- await Promise.allSettled([...retainedWrites]);
8894
- };
8895
- let admissions = [...recovery?.admissions ?? []];
8896
- let inputSeq = recovery?.continuation?.inputSeq ?? ordinal;
8897
- let pauseSeq = 0;
8898
- const onAdmission = (admission) => retainedWrite(async () => {
8899
- controller.signal.throwIfAborted();
8900
- const existing = admissions.find((record) => record.phase === admission.phase);
8901
- if (existing) {
8902
- if (contentAddress(existing) !== contentAddress(admission)) throw new ValidationError("scope retained admission conflicts with its committed phase");
8903
- return;
8904
- }
8905
- if (identity?.taskDigest === void 0) throw new ValidationError("retained execution requires a canonical task identity");
8906
- await args.journal.appendEvent(args.root, {
8907
- kind: "execution-admitted",
8908
- id,
8909
- admission: detachedSnapshot(admission, "retained admission"),
8910
- seq: ordinal,
8911
- at: new Date(now()).toISOString()
8912
- });
8913
- admissions.push(detachedSnapshot(admission, "retained admission"));
8914
- notifyExecutionAdmitted(args.hooks, args.root, id, admission, now, attemptId);
8915
- readLive().recoveryPending = true;
8916
- controller.signal.throwIfAborted();
8917
- });
8918
- const onResult = (result) => retainedWrite(async () => {
8919
- controller.signal.throwIfAborted();
8920
- assertValidSpend(result.spent, "retained executor result");
8921
- executorFailureReason(result);
8922
- await completeEvidence();
8923
- const outRef = contentAddress(result.out);
8924
- await args.blobs.put(outRef, result.out);
8925
- controller.signal.throwIfAborted();
8926
- const traceRoot = await traceRoots.write(outRef, result);
8927
- await args.journal.appendEvent(args.root, {
8928
- kind: "execution-result",
8929
- id,
8930
- outRef,
8931
- ...traceRoot === void 0 ? {} : { traceRoot },
8932
- spent: result.spent,
8933
- ...result.verdict ? { verdict: result.verdict } : {},
8934
- ...result.outcome ? { outcome: result.outcome } : {},
8935
- ...result.outputFormat === void 0 ? {} : { outputFormat: result.outputFormat },
8936
- seq: ordinal,
8937
- at: new Date(now()).toISOString()
8938
- });
8939
- readLive().acceptedResult = detachedSnapshot({
8940
- ...result,
8941
- outRef
8942
- }, "accepted retained child result");
8943
- readLive().recoveryPending = false;
8944
- });
8945
- const onPause = (pause) => retainedWrite(async () => {
8946
- await args.journal.appendEvent(args.root, {
8947
- kind: "paused",
8948
- id,
8949
- ...pause,
8950
- seq: pauseSeq++,
8951
- at: new Date(now()).toISOString()
8952
- });
8953
- });
8954
- const holdMs = args.budgetStopHoldMs ?? 6e5;
8955
- const holdOnSettle = opts.key !== void 0 && holdMs > 0 ? (spent) => overBudget(opts.budget, spent) || admission.deadlineAtMs !== void 0 && now() > admission.deadlineAtMs : void 0;
8956
- const retainedContext = (continuing) => ({
8957
- ...continuing === void 0 ? {} : {
8958
- executionId: continuing.executionId,
8959
- priorSession: continuing.priorSession,
8960
- ...continuing.priorSpent === void 0 ? {} : { priorSpent: continuing.priorSpent }
8961
- },
8962
- admissions,
8963
- ...holdOnSettle === void 0 ? {} : { holdOnSettle },
8964
- ...markRecoveryReady && continuing === void 0 ? { onReady: markRecoveryReady } : {},
8965
- onAdmission,
8966
- onResult,
8967
- onEvidence: executorEvidenceWriter({
8968
- journal: args.journal,
8969
- blobs: args.blobs,
8970
- rootId: args.root,
8971
- nodeId: id,
8972
- nextSequence: () => ordinal,
8973
- now,
8974
- traceRoots
8975
- }),
8976
- onPause,
8977
- continueInvocation: async (nextTask) => {
8978
- controller.signal.throwIfAborted();
8979
- const live = readLive();
8980
- if (live.acceptedResult === void 0) throw new ValidationError("scope: a retained child continues only after its invocation committed a result");
8981
- const environment = admissions.find((record) => record.phase === "environment");
8982
- if (environment?.phase !== "environment") throw new ValidationError("scope: a retained child continues only in an environment it was admitted to");
8983
- const snapshot = detachedSnapshot(nextTask, "retained child continuation");
8984
- const taskRef = contentAddress(snapshot);
8985
- const nextSeq = inputSeq + 1;
8986
- await retainedWrite(async () => {
8987
- await args.blobs.put(taskRef, snapshot);
8988
- controller.signal.throwIfAborted();
8989
- await args.journal.appendEvent(args.root, {
8990
- kind: "execution-input",
8991
- id,
8992
- taskRef,
8993
- seq: nextSeq,
8994
- at: new Date(now()).toISOString()
8995
- });
8996
- });
8997
- inputSeq = nextSeq;
8998
- admissions = [];
8999
- const priorSpent = live.acceptedResult.spent;
9000
- live.acceptedResult = void 0;
9001
- return retainedContext({
9002
- executionId: leafContinuationExecutionId(id, nextSeq),
9003
- priorSession: environment,
9004
- priorSpent
9005
- });
9006
- }
9007
- });
9008
- return {
9009
- retainedContext,
9010
- closeRetainedWrites,
9011
- holdMs,
9012
- readEnvironmentAdmission: () => {
9013
- const admission = admissions.find((record) => record.phase === "environment");
9014
- return admission?.phase === "environment" ? admission : void 0;
9015
- }
9016
- };
9017
- }
9018
- /** Whether a settled spend exceeds the budget it was given, by the channels the pool reconciles. */
9019
- function overBudget(budget, spent) {
9020
- return budget.maxTokens !== void 0 && chargedTokens(spent.tokens) > budget.maxTokens || budget.maxIterations !== void 0 && spent.iterations > budget.maxIterations || budget.maxUsd !== void 0 && spent.usdKnown !== false && spent.usd > budget.maxUsd;
9021
- }
9022
9028
  // src/durable/spawn-journal/record-events.ts
9023
9029
  /** Decode historical envelopes; readers own event validation. @internal */
9024
9030
  function spawnJournalRecordEvents(record, invalid = "throw") {
@@ -10148,6 +10154,10 @@ var ChildExecutionAttempt = class {
10148
10154
  }
10149
10155
  async persistTranscript() {
10150
10156
  this.transcriptEvidence ??= await persistHarnessTranscript(readHarnessTranscript(this.executor), this.blobs);
10157
+ if (!this.live.transcriptEvidenceRecorded) {
10158
+ await this.live.recordTranscriptEvidence?.(this.transcriptEvidence, this.retainedOutputRef);
10159
+ this.live.transcriptEvidenceRecorded = true;
10160
+ }
10151
10161
  return this.transcriptEvidence;
10152
10162
  }
10153
10163
  async teardown(grace) {
@@ -12346,12 +12356,23 @@ var WorkerEvents = class {
12346
12356
  * row, its spawn journal record and hook, and the settlement chain that closes it. `scope-spawn`
12347
12357
  * sequences them; each builder here owns one record.
12348
12358
  */
12359
+ /** The child's node coordinates, shared by its executor context and its transcript evidence. */
12360
+ function childNode(args, child) {
12361
+ return {
12362
+ rootId: args.root,
12363
+ parentId: args.parentId,
12364
+ nodeId: child.id,
12365
+ depth: args.depth + 1,
12366
+ attemptId: child.attemptId,
12367
+ ...child.identity ? { identity: child.identity } : {}
12368
+ };
12369
+ }
12349
12370
  /**
12350
12371
  * Seed THIS scope's keystone deps into the child's `ExecutorContext.seams`, so a DRIVER child can
12351
12372
  * mount a nested `Scope` at `depth+1` over a pool backed by THIS reservation. Leaves ignore it.
12352
12373
  */
12353
12374
  function childExecutorContext(args, child, controller, seams) {
12354
- const { id, identity, recovery, continuing, opts } = child;
12375
+ const { id, recovery, continuing, opts } = child;
12355
12376
  const interactiveBindingDir = args.interactiveBindingDir;
12356
12377
  const observation = createExecutorObservation(args.hooks, {
12357
12378
  rootId: args.root,
@@ -12361,14 +12382,7 @@ function childExecutorContext(args, child, controller, seams) {
12361
12382
  }, seams.onProgress);
12362
12383
  return {
12363
12384
  signal: controller.signal,
12364
- node: {
12365
- rootId: args.root,
12366
- parentId: args.parentId,
12367
- nodeId: id,
12368
- depth: args.depth + 1,
12369
- attemptId: child.attemptId,
12370
- ...identity ? { identity } : {}
12371
- },
12385
+ node: childNode(args, child),
12372
12386
  seams: {
12373
12387
  ...args.seams,
12374
12388
  [executorObservationSeamKey]: observation,
@@ -12436,9 +12450,20 @@ function liveChildRecord(args, child, executor, start) {
12436
12450
  attemptId: child.attemptId
12437
12451
  }, () => {}))),
12438
12452
  id,
12453
+ executionTask: child.task,
12439
12454
  status: start.granted ? "acquiring" : "queued",
12440
12455
  runtime: executor.runtime,
12441
12456
  ...ownedTreeRoot === void 0 ? {} : { ownedTreeRoot },
12457
+ ...ownedTreeRoot === void 0 && executor.harnessTranscript ? { recordTranscriptEvidence: (harnessTranscript, outRef) => recordHarnessTranscriptEvidence({
12458
+ node: childNode(args, child),
12459
+ task: live.executionTask,
12460
+ harnessTranscript,
12461
+ ...outRef === void 0 ? {} : { outRef },
12462
+ journal: args.journal,
12463
+ roots: [args.root],
12464
+ blobs: args.blobs,
12465
+ now
12466
+ }) } : {},
12442
12467
  ...identity ? { identity } : {},
12443
12468
  ...modelSubstitution === void 0 ? {} : { modelSubstitution },
12444
12469
  budget: opts.budget,
@@ -12621,6 +12646,171 @@ async function resolveChildSettlement(live, ran, interactiveBindingCommitted, ho
12621
12646
  }
12622
12647
  return resolution;
12623
12648
  }
12649
+ // src/runtime/supervise/scope-child-retention.ts
12650
+ /** Own the retained child invocation and its durable writes. */
12651
+ function createChildRetention({ args, controller, id, ordinal, attemptId, identity, recovery, opts, now, traceRoots, markRecoveryReady, admission, readLive, completeEvidence }) {
12652
+ const retainedWrites = /* @__PURE__ */ new Set();
12653
+ let retainedWritesClosed = false;
12654
+ const retainedWrite = (write) => {
12655
+ controller.signal.throwIfAborted();
12656
+ if (retainedWritesClosed) throw new ValidationError("retained child writer is closed");
12657
+ const pending = write();
12658
+ retainedWrites.add(pending);
12659
+ pending.then(() => retainedWrites.delete(pending), () => retainedWrites.delete(pending));
12660
+ return pending;
12661
+ };
12662
+ const closeRetainedWrites = async () => {
12663
+ retainedWritesClosed = true;
12664
+ await Promise.allSettled([...retainedWrites]);
12665
+ };
12666
+ let admissions = [...recovery?.admissions ?? []];
12667
+ let inputSeq = recovery?.continuation?.inputSeq ?? ordinal;
12668
+ let pauseSeq = 0;
12669
+ const onAdmission = (admission) => retainedWrite(async () => {
12670
+ controller.signal.throwIfAborted();
12671
+ const existing = admissions.find((record) => record.phase === admission.phase);
12672
+ if (existing) {
12673
+ if (contentAddress(existing) !== contentAddress(admission)) throw new ValidationError("scope retained admission conflicts with its committed phase");
12674
+ return;
12675
+ }
12676
+ if (identity?.taskDigest === void 0) throw new ValidationError("retained execution requires a canonical task identity");
12677
+ await args.journal.appendEvent(args.root, {
12678
+ kind: "execution-admitted",
12679
+ id,
12680
+ admission: detachedSnapshot(admission, "retained admission"),
12681
+ seq: ordinal,
12682
+ at: new Date(now()).toISOString()
12683
+ });
12684
+ admissions.push(detachedSnapshot(admission, "retained admission"));
12685
+ notifyExecutionAdmitted(args.hooks, args.root, id, admission, now, attemptId);
12686
+ readLive().recoveryPending = true;
12687
+ controller.signal.throwIfAborted();
12688
+ });
12689
+ const onResult = (result) => retainedWrite(async () => {
12690
+ controller.signal.throwIfAborted();
12691
+ assertValidSpend(result.spent, "retained executor result");
12692
+ executorFailureReason(result);
12693
+ await completeEvidence();
12694
+ const outRef = contentAddress(result.out);
12695
+ await args.blobs.put(outRef, result.out);
12696
+ controller.signal.throwIfAborted();
12697
+ const traceRoot = await traceRoots.write(outRef, result);
12698
+ await args.journal.appendEvent(args.root, {
12699
+ kind: "execution-result",
12700
+ id,
12701
+ outRef,
12702
+ ...traceRoot === void 0 ? {} : { traceRoot },
12703
+ spent: result.spent,
12704
+ ...result.verdict ? { verdict: result.verdict } : {},
12705
+ ...result.outcome ? { outcome: result.outcome } : {},
12706
+ ...result.outputFormat === void 0 ? {} : { outputFormat: result.outputFormat },
12707
+ seq: ordinal,
12708
+ at: new Date(now()).toISOString()
12709
+ });
12710
+ readLive().acceptedResult = detachedSnapshot({
12711
+ ...result,
12712
+ outRef
12713
+ }, "accepted retained child result");
12714
+ readLive().recoveryPending = false;
12715
+ });
12716
+ const onPause = (pause) => retainedWrite(async () => {
12717
+ await args.journal.appendEvent(args.root, {
12718
+ kind: "paused",
12719
+ id,
12720
+ ...pause,
12721
+ seq: pauseSeq++,
12722
+ at: new Date(now()).toISOString()
12723
+ });
12724
+ });
12725
+ const holdMs = args.budgetStopHoldMs ?? 6e5;
12726
+ const holdOnSettle = opts.key !== void 0 && holdMs > 0 ? (spent) => overBudget(opts.budget, spent) || admission.deadlineAtMs !== void 0 && now() > admission.deadlineAtMs : void 0;
12727
+ const retainedContext = (continuing) => ({
12728
+ ...continuing === void 0 ? {} : {
12729
+ executionId: continuing.executionId,
12730
+ priorSession: continuing.priorSession,
12731
+ ...continuing.priorSpent === void 0 ? {} : { priorSpent: continuing.priorSpent }
12732
+ },
12733
+ admissions,
12734
+ ...holdOnSettle === void 0 ? {} : { holdOnSettle },
12735
+ ...markRecoveryReady && continuing === void 0 ? { onReady: markRecoveryReady } : {},
12736
+ onAdmission,
12737
+ onResult,
12738
+ onEvidence: executorEvidenceWriter({
12739
+ journal: args.journal,
12740
+ blobs: args.blobs,
12741
+ rootId: args.root,
12742
+ nodeId: id,
12743
+ nextSequence: () => ordinal,
12744
+ now,
12745
+ traceRoots
12746
+ }),
12747
+ onHarnessTranscript: async (task, capture, result) => {
12748
+ const harnessTranscript = await persistHarnessTranscript(capture, args.blobs);
12749
+ await recordHarnessTranscriptEvidence({
12750
+ node: childNode(args, {
12751
+ id,
12752
+ attemptId,
12753
+ identity
12754
+ }),
12755
+ task,
12756
+ ...result?.out === void 0 ? {} : { outRef: contentAddress(result.out) },
12757
+ harnessTranscript,
12758
+ journal: args.journal,
12759
+ roots: [args.root],
12760
+ blobs: args.blobs,
12761
+ now
12762
+ });
12763
+ if (harnessTranscript.status === "unavailable" && capture.status !== "unavailable") throw new ValidationError("provider transcript capture could not be persisted");
12764
+ readLive().transcriptEvidenceRecorded = true;
12765
+ },
12766
+ onPause,
12767
+ continueInvocation: async (nextTask) => {
12768
+ controller.signal.throwIfAborted();
12769
+ const live = readLive();
12770
+ if (live.acceptedResult === void 0) throw new ValidationError("scope: a retained child continues only after its invocation committed a result");
12771
+ const environment = admissions.find((record) => record.phase === "environment");
12772
+ if (environment?.phase !== "environment") throw new ValidationError("scope: a retained child continues only in an environment it was admitted to");
12773
+ const snapshot = detachedSnapshot(nextTask, "retained child continuation");
12774
+ const taskRef = contentAddress(snapshot);
12775
+ const nextSeq = inputSeq + 1;
12776
+ await retainedWrite(async () => {
12777
+ await args.blobs.put(taskRef, snapshot);
12778
+ controller.signal.throwIfAborted();
12779
+ await args.journal.appendEvent(args.root, {
12780
+ kind: "execution-input",
12781
+ id,
12782
+ taskRef,
12783
+ seq: nextSeq,
12784
+ at: new Date(now()).toISOString()
12785
+ });
12786
+ });
12787
+ inputSeq = nextSeq;
12788
+ live.executionTask = snapshot;
12789
+ live.transcriptEvidenceRecorded = false;
12790
+ admissions = [];
12791
+ const priorSpent = live.acceptedResult.spent;
12792
+ live.acceptedResult = void 0;
12793
+ return retainedContext({
12794
+ executionId: leafContinuationExecutionId(id, nextSeq),
12795
+ priorSession: environment,
12796
+ priorSpent
12797
+ });
12798
+ }
12799
+ });
12800
+ return {
12801
+ retainedContext,
12802
+ closeRetainedWrites,
12803
+ holdMs,
12804
+ readEnvironmentAdmission: () => {
12805
+ const admission = admissions.find((record) => record.phase === "environment");
12806
+ return admission?.phase === "environment" ? admission : void 0;
12807
+ }
12808
+ };
12809
+ }
12810
+ /** Whether a settled spend exceeds the budget it was given, by the channels the pool reconciles. */
12811
+ function overBudget(budget, spent) {
12812
+ return budget.maxTokens !== void 0 && chargedTokens(spent.tokens) > budget.maxTokens || budget.maxIterations !== void 0 && spent.iterations > budget.maxIterations || budget.maxUsd !== void 0 && spent.usdKnown !== false && spent.usd > budget.maxUsd;
12813
+ }
12624
12814
  // src/runtime/supervise/scope-key-registry.ts
12625
12815
  /**
12626
12816
  * The semantic-key registry (`SpawnOpts.key`), seeded from the journal on resume and updated as
@@ -13201,7 +13391,14 @@ function bindChildTeardown(scope, args, children, now) {
13201
13391
  return child.teardownRetry;
13202
13392
  }));
13203
13393
  });
13204
- retainedReleasers.set(scope, async () => {
13394
+ let sweeping;
13395
+ retainedReleasers.set(scope, () => {
13396
+ sweeping ??= sweepRetained().finally(() => {
13397
+ sweeping = void 0;
13398
+ });
13399
+ return sweeping;
13400
+ });
13401
+ async function sweepRetained() {
13205
13402
  const held = retainedHeld();
13206
13403
  const released = await Promise.all(held.map(async (child) => {
13207
13404
  child.cleanupConfirmed = false;
@@ -13236,7 +13433,7 @@ function bindChildTeardown(scope, args, children, now) {
13236
13433
  await child.admission.prepareAccounting?.();
13237
13434
  if (child.cleanupConfirmed) await closeRetainedSlot(child, "released", prior);
13238
13435
  }
13239
- });
13436
+ }
13240
13437
  const closeRetainedSlot = async (child, state, prior) => {
13241
13438
  if (child.recoveryPending !== true || child.resolved?.kind !== "down" || child.settledSeq === void 0 || child.settledAt === void 0 || child.retainedExecution === "released" || child.retainedExecution === "release-unconfirmed" || prior.some((event) => event.id === child.id && closesCursorSlot(event))) return;
13242
13439
  child.budgetViolation = child.retainedViolation;
@@ -13979,6 +14176,6 @@ function unknownChannels(spend) {
13979
14176
  function isNonEmptySpend(s) {
13980
14177
  return s.iterations > 0 || s.tokens.input > 0 || s.tokens.output > 0 || s.usd > 0 || s.ms > 0 || s.tokensKnown === false || s.usdKnown === false || Object.values(s.resources ?? {}).some((resource) => resource.amount > 0 || !resource.known);
13981
14178
  }
13982
- export { queueOf as $, captureHarnessTranscript as $n, RetainedRunProviderContractError as $r, loadSpawnForest as $t, openSlotGroup as A, verifyObserverRecords as An, knownMaterializationReceipt as Ar, noteScopeOwnerPlannedExecution as At, readWorkerInteractiveBinding as B, buildLoopSpanNodes as Bn, runtimeOwnedExecutorMaterialization as Br, scopeRetainedOwnerSettled as Bt, workerCancellationsDir as C, retainedCreateMaterial as Cn, attestRuntimeOwnedPendingExecutor as Cr, abandonScopeRetainedOwnerInvocation as Ct, writeWorkerSteer as D, FileObserverJournal as Dn, finalizeRuntimeOwnedPendingExecutor as Dr, scopeRetainedOwnerResult as Dt, writeWorkerCancellation as E, prepareInteractiveDelegation as En, authoredProfileDigest as Er, scopeRetainedOwnerPriorSpend as Et, parseWorkerToolTraceArtifact as F, workerTraceHeaders as Fn, recordRuntimeOwnedProviderDispatchNotStarted as Fr, coordinationMcpAlias as Ft, appendSpawnEvents as G, generateSpanId as Gn, unknownExecutionBindingReceipt as Gr, noteScopeRetainedOwnerCoordination as Gt, recoverRetainedInteractiveRun as H, createOpenInferenceFileExporter as Hn, runtimeOwnedPendingExecutorMaterialization as Hr, assertRetainedOwnerCoordinationRekey as Ht, workerTraceAnalysisStore as I, createPropagatingTraceEmitter as In, recordRuntimeOwnedProviderIdentityConflict as Ir, coordinationProfileToolPrefix as It, reenteredWorkers as J, createRuntimeStreamEventCollector as Jn, executableAgentSpecSnapshot as Jr, bindScopeRetainedOwnerProvider as Jt, spawnJournalRecordEvents as K, loopEventToOtelSpan as Kn, unknownMaterializationReceipt as Kr, scopeRetainedOwnerCheckpointing as Kt, nestedScopeSeamKey as L, mergeTraceEnv as Ln, recordRuntimeOwnedProviderModel as Lr, providerVisibleProfile as Lt, prepareScopeResume as M, environmentGone as Mn, providerAttemptEvidence as Mr, restoreScopeOwnerAcceptedExecution as Mt, replaySpawnTree as N, WORKER_TRACE_PROPAGATION as Nn, recordRuntimeOwnedDriveHarnessProviderEvidence as Nr, scopeOwnerExecutionObservation as Nt, writeWorkerSteerAcknowledgement as O, createFileObserverHooks as On, inheritRuntimeOwnedExecutorAttestation as Or, beginScopeOwnerAttempt as Ot, isTraceAnalysisStore as P, workerTraceEnv as Pn, recordRuntimeOwnedProviderAttemptStart as Pr, scopeOwnerExecutorNodeContext as Pt, freeSlots as Q, captureBoundHarnessTranscript as Qn, runtimeFlowBrain as Qr, scopeRetainedOwnerJournalRoot as Qt, interactiveAdmissionSeamKey as R, readTraceContextFromEnv as Rn, runtimeOwnedDriveHarnessProviderEvidence as Rr, runtimeGraphMetadataKey as Rt, workerCancelRequestsFile as S, startRetainedRunInEnvironment as Sn, attestRuntimeOwnedExecutor as Sr, resolveSpawnResourcePaths as St, workerSteerRequestsDir as T, offerInteractiveControl as Tn, authoredAgentIdentity as Tr, prepareScopeRetainedOwnerTask as Tt, startRetainedInteractiveRun as U, createOtelExporter as Un, runtimeOwnedScopeOwnerControl as Ur, reconcileScopeRetainedOwnerEnvironment as Ut, reconnectRetainedInteractiveRun as V, buildRuntimeEventOtelSpans as Vn, runtimeOwnedExecutorProviderEvidence as Vr, scopeRetainedOwnerTurnEnded as Vt, FileSpawnJournal as W, flatOtelSpan as Wn, runtimeOwnedScopeOwnerRuntime as Wr, scopeRetainedOwnerRestorePoint as Wt, assertRecursiveReservationPolicy as X, sanitizeRuntimeStreamEvent as Xn, runtimeCheckFactory as Xr, scopeOwnerLiabilities as Xt, settledToIteration as Y, sanitizeKnowledgeReadinessReport as Yn, isRuntimeFlowBrain as Yr, owners as Yt, deriveNodeExecutionIdentity as Z, HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS as Zn, runtimeFlowAgent as Zr, scopeRetainedOwnerContext as Zt, readWorkerSteerAcknowledgement as _, assertRetainedRunReplayMaterial as _n, SeatPauseError as _r, waitForScopeChildren as _t, createRootStreamSink as a, sameControlCoordinates as ai, FileResultBlobStore as an, HARNESS_TRANSCRIPT_READ_LIMITS as ar, meterRuntimeOwnedProviderAttempt as at, supervisorRunDir as b, recoverRetainedRun as bn, subscriptionUsageLimitSignal as br, scopeRetainedOwnerResourceReader as bt, readRootStreamReceipt as c, providerMessageText as ci, insideCursorNamespace as cn, retainHarnessTranscript as cr, recordScopeOwnerDriverAttempt as ct, claimWorkerSteerDelivery as d, observeModelRequest as dn, describeToolArgs as dr, releaseHeldEnvironments as dt, assertEventBinding as ei, ownedTreeRootSpawn as en, harnessTranscriptArtifact as er, rollingDispatch as et, fileEscalateQuestion as f, NATIVE_STOP_UNCONFIRMED as fn, readWorkerProgress as fr, releaseRetainedEnvironments as ft, readWorkerCancellation as g, RetainedMaterializationTimeoutError as gn, SeatChain as gr, unconfirmedTeardowns as gt, readWorkerCancelRequests as h, verifyWorkspaceMarker as hn, SEAT_RECHECK_MS as hr, startScopeRecoveries as ht, ROOT_STREAM_FILE as i, retainedSessionReplaced as ii, nestedDriverTreeRoot as in, readHarnessTranscript as ir, meterRuntimeOwnedAccounting as it, resolveWorkerSlots as j, destroyInteractiveEnvironment as jn, newExecutionAttemptId as jr, recordScopeOwnerMaterialization as jt, createWorkerSlots as k, observerRecordDigest as kn, knownExecutionBindingReceipt as kr, finalizeScopeOwnerMaterialization as kt, appendWorkerControlEvent as l, executorObservation as ln, DEFAULT_STALL_AFTER_MS as lr, recordScopeOwnerPause as lt, legacySupervisorRunsRoot as m, stopRetainedNativeExecution as mn, isTerminalNodeStatus as mr, settleManagerWork as mt, terminalAccounting as n, exactSession as ni, attestNestedDriverTreeOwner as nn, harnessTranscriptUnavailable as nr, closeScopeAdmission as nt, nodeStreamFile as o, promptFromAgentTurnInput as oi, encodeResultBlob as on, readBoundHarnessSessions as or, pauseScopeSeatAdmission as ot, legacySupervisorRunDir as p, describeRetainedNativeStops as pn, isLiveNodeStatus as pr, retryUnconfirmedTeardowns as pt, appendTeardownConfirmation as q, createRuntimeEventCollector as qn, executableAgentProfileSnapshot as qr, bindScopeRetainedOwnerEnvironmentId as qt, createScope as r, freezeControlRef as ri, driverRuntime as rn, persistHarnessTranscript as rr, hasRetriableTeardowns as rt, readRootStream as s, promptOptionsFromAgentTurnInput as si, SpawnEventIndex as sn, resolveHarnessTranscriptCapture as sr, recordScopeOwnerBarrenPause as st, isNonEmptySpend as t, awaitAbortable$1 as ti, materializeTreeView as tn, harnessTranscriptFromLines as tr, closeRetainedSlots as tt, cancelWorker as u, executorObservationSeamKey as un, createActivityLog as ur, registerNestedTeardownScope as ut, readWorkerSteerRequests as v, mintRetainedIdentity as vn, authoredSeatStages as vr, prepareScopeRetainedOwnerSeatSwitch as vt, workerInboxFileFromEventDir as w, acceptedInteractiveControl as wn, attestRuntimeOwnedScopeOwner as wr, consumeScopeRetainedOwnerResult as wt, supervisorRunsRoot as x, startRetainedRun as xn, attestRuntimeOwnedDeferredExecutor as xr, environmentReader as xt, safeWorkerFile as y, reconnectRetainedRun as yn, seatExecutionProfile as yr, releaseScopeRetainedOwnerForSeatPause as yt, attachWorker as z, buildLoopOtelSpans as zn, runtimeOwnedExecutorExecutionBinding as zr, beginScopeRetainedOwnerDrive as zt };
14179
+ export { queueOf as $, sanitizeKnowledgeReadinessReport as $n, executableAgentSpecSnapshot as $r, owners as $t, openSlotGroup as A, prepareInteractiveDelegation as An, authoredAgentIdentity as Ar, beginScopeOwnerAttempt as At, readWorkerInteractiveBinding as B, createPropagatingTraceEmitter as Bn, recordRuntimeOwnedProviderDispatchNotStarted as Br, coordinationProfileToolPrefix as Bt, workerCancellationsDir as C, reconnectRetainedRun as Cn, authoredSeatStages as Cr, resolveSpawnResourcePaths as Ct, writeWorkerSteer as D, retainedCreateMaterial as Dn, attestRuntimeOwnedExecutor as Dr, prepareScopeRetainedOwnerTask as Dt, writeWorkerCancellation as E, startRetainedRunInEnvironment as En, attestRuntimeOwnedDeferredExecutor as Er, consumeScopeRetainedOwnerResult as Et, parseWorkerToolTraceArtifact as F, destroyInteractiveEnvironment as Fn, knownMaterializationReceipt as Fr, recordScopeOwnerMaterialization as Ft, appendSpawnEvents as G, buildRuntimeEventOtelSpans as Gn, runtimeOwnedExecutorMaterialization as Gr, scopeRetainedOwnerTurnEnded as Gt, recoverRetainedInteractiveRun as H, readTraceContextFromEnv as Hn, recordRuntimeOwnedProviderModel as Hr, runtimeGraphMetadataKey as Ht, workerTraceAnalysisStore as I, environmentGone as In, newExecutionAttemptId as Ir, restoreScopeOwnerAcceptedExecution as It, reenteredWorkers as J, flatOtelSpan as Jn, runtimeOwnedScopeOwnerControl as Jr, scopeRetainedOwnerRestorePoint as Jt, spawnJournalRecordEvents as K, createOpenInferenceFileExporter as Kn, runtimeOwnedExecutorProviderEvidence as Kr, assertRetainedOwnerCoordinationRekey as Kt, nestedScopeSeamKey as L, WORKER_TRACE_PROPAGATION as Ln, providerAttemptEvidence as Lr, scopeOwnerExecutionObservation as Lt, prepareScopeResume as M, createFileObserverHooks as Mn, finalizeRuntimeOwnedPendingExecutor as Mr, holdScopeOwnerTranscript as Mt, replaySpawnTree as N, observerRecordDigest as Nn, inheritRuntimeOwnedExecutorAttestation as Nr, noteScopeOwnerPlannedExecution as Nt, writeWorkerSteerAcknowledgement as O, acceptedInteractiveControl as On, attestRuntimeOwnedPendingExecutor as Or, scopeRetainedOwnerPriorSpend as Ot, isTraceAnalysisStore as P, verifyObserverRecords as Pn, knownExecutionBindingReceipt as Pr, recordScopeOwnerHarnessTranscript as Pt, freeSlots as Q, createRuntimeStreamEventCollector as Qn, executableAgentProfileSnapshot as Qr, bindScopeRetainedOwnerProvider as Qt, interactiveAdmissionSeamKey as R, workerTraceEnv as Rn, recordRuntimeOwnedDriveHarnessProviderEvidence as Rr, scopeOwnerExecutorNodeContext as Rt, workerCancelRequestsFile as S, mintRetainedIdentity as Sn, SeatPauseError as Sr, environmentReader as St, workerSteerRequestsDir as T, startRetainedRun as Tn, subscriptionUsageLimitSignal as Tr, abandonScopeRetainedOwnerInvocation as Tt, startRetainedInteractiveRun as U, buildLoopOtelSpans as Un, runtimeOwnedDriveHarnessProviderEvidence as Ur, beginScopeRetainedOwnerDrive as Ut, reconnectRetainedInteractiveRun as V, mergeTraceEnv as Vn, recordRuntimeOwnedProviderIdentityConflict as Vr, providerVisibleProfile as Vt, FileSpawnJournal as W, buildLoopSpanNodes as Wn, runtimeOwnedExecutorExecutionBinding as Wr, scopeRetainedOwnerSettled as Wt, assertRecursiveReservationPolicy as X, loopEventToOtelSpan as Xn, unknownExecutionBindingReceipt as Xr, scopeRetainedOwnerCheckpointing as Xt, settledToIteration as Y, generateSpanId as Yn, runtimeOwnedScopeOwnerRuntime as Yr, noteScopeRetainedOwnerCoordination as Yt, deriveNodeExecutionIdentity as Z, createRuntimeEventCollector as Zn, unknownMaterializationReceipt as Zr, bindScopeRetainedOwnerEnvironmentId as Zt, readWorkerSteerAcknowledgement as _, describeRetainedNativeStops as _n, readWorkerProgress as _r, unconfirmedTeardowns as _t, createRootStreamSink as a, assertEventBinding as ai, materializeTreeView as an, harnessTranscriptFromLines as ar, meterRuntimeOwnedAccounting as at, supervisorRunDir as b, RetainedMaterializationTimeoutError as bn, SEAT_RECHECK_MS as br, releaseScopeRetainedOwnerForSeatPause as bt, readRootStreamReceipt as c, freezeControlRef as ci, nestedDriverTreeRoot as cn, readHarnessTranscript as cr, recordScopeOwnerBarrenPause as ct, claimWorkerSteerDelivery as d, promptFromAgentTurnInput as di, SpawnEventIndex as dn, readBoundHarnessSessions$1 as dr, registerNestedTeardownScope as dt, isRuntimeFlowBrain as ei, scopeOwnerLiabilities as en, sanitizeRuntimeStreamEvent as er, rollingDispatch as et, fileEscalateQuestion as f, promptOptionsFromAgentTurnInput as fi, insideCursorNamespace as fn, resolveHarnessTranscriptCapture as fr, releaseHeldEnvironments as ft, readWorkerCancellation as g, NATIVE_STOP_UNCONFIRMED as gn, describeToolArgs as gr, startScopeRecoveries as gt, readWorkerCancelRequests as h, observeModelRequest as hn, createActivityLog as hr, settleManagerWork as ht, ROOT_STREAM_FILE as i, RetainedRunProviderContractError as ii, ownedTreeRootSpawn as in, harnessTranscriptArtifact as ir, hasRetriableTeardowns as it, resolveWorkerSlots as j, FileObserverJournal as jn, authoredProfileDigest as jr, finalizeScopeOwnerMaterialization as jt, createWorkerSlots as k, offerInteractiveControl as kn, attestRuntimeOwnedScopeOwner as kr, scopeRetainedOwnerResult as kt, appendWorkerControlEvent as l, retainedSessionReplaced as li, FileResultBlobStore as ln, settleHarnessTranscript as lr, recordScopeOwnerDriverAttempt as lt, legacySupervisorRunsRoot as m, executorObservationSeamKey as mn, DEFAULT_STALL_AFTER_MS as mr, retryUnconfirmedTeardowns as mt, terminalAccounting as n, runtimeFlowAgent as ni, scopeRetainedOwnerJournalRoot as nn, captureBoundHarnessTranscript as nr, closeRetainedSlots as nt, nodeStreamFile as o, awaitAbortable$1 as oi, attestNestedDriverTreeOwner as on, harnessTranscriptUnavailable as or, meterRuntimeOwnedProviderAttempt as ot, legacySupervisorRunDir as p, providerMessageText as pi, executorObservation as pn, retainHarnessTranscript as pr, releaseRetainedEnvironments as pt, appendTeardownConfirmation as q, createOtelExporter as qn, runtimeOwnedPendingExecutorMaterialization as qr, reconcileScopeRetainedOwnerEnvironment as qt, createScope as r, runtimeFlowBrain as ri, loadSpawnForest as rn, captureHarnessTranscript as rr, closeScopeAdmission as rt, readRootStream as s, exactSession as si, driverRuntime as sn, persistHarnessTranscript as sr, pauseScopeSeatAdmission as st, isNonEmptySpend as t, runtimeCheckFactory as ti, scopeRetainedOwnerContext as tn, HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS as tr, boundRetainedReleases as tt, cancelWorker as u, sameControlCoordinates as ui, encodeResultBlob as un, HARNESS_TRANSCRIPT_READ_LIMITS as ur, recordScopeOwnerPause as ut, readWorkerSteerRequests as v, stopRetainedNativeExecution as vn, isLiveNodeStatus as vr, waitForScopeChildren as vt, workerInboxFileFromEventDir as w, recoverRetainedRun as wn, seatExecutionProfile as wr, RELEASE_DESTROY_MS as wt, supervisorRunsRoot as x, assertRetainedRunReplayMaterial as xn, SeatChain as xr, scopeRetainedOwnerResourceReader as xt, safeWorkerFile as y, verifyWorkspaceMarker as yn, isTerminalNodeStatus as yr, prepareScopeRetainedOwnerSeatSwitch as yt, attachWorker as z, workerTraceHeaders as zn, recordRuntimeOwnedProviderAttemptStart as zr, coordinationMcpAlias as zt };
13983
14180
 
13984
- //# sourceMappingURL=supervisor-accounting-StDNW1YT.js.map
14181
+ //# sourceMappingURL=supervisor-accounting-QiXnF-EW.js.map