@tangle-network/agent-runtime 0.271.0 → 0.273.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/{activation-DGbFPGR3.js → activation-Cx2dKA_l.js} +2 -2
  2. package/dist/{activation-DGbFPGR3.js.map → activation-Cx2dKA_l.js.map} +1 -1
  3. package/dist/{activation-BrJmwTLB.d.ts → activation-IfDlhR3J.d.ts} +2 -2
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/candidate-execution/index.js +2 -2
  7. package/dist/{coordination-driver-iBGMKDvB.js → coordination-driver-CkcW4dxU.js} +155 -80
  8. package/dist/coordination-driver-CkcW4dxU.js.map +1 -0
  9. package/dist/{delegate-DOqUvaIz.js → delegate-Dvb1-mE-.js} +2 -2
  10. package/dist/{delegate-DOqUvaIz.js.map → delegate-Dvb1-mE-.js.map} +1 -1
  11. package/dist/durable.d.ts +3 -572
  12. package/dist/durable.js +92 -18
  13. package/dist/durable.js.map +1 -1
  14. package/dist/{graph-DnMcepkN.js → graph-C69Uxtzt.js} +14 -8
  15. package/dist/graph-C69Uxtzt.js.map +1 -0
  16. package/dist/{improvement-cycle-1IyRJo5h.js → improvement-cycle-CO2HRCQq.js} +4 -4
  17. package/dist/{improvement-cycle-1IyRJo5h.js.map → improvement-cycle-CO2HRCQq.js.map} +1 -1
  18. package/dist/{index-CL1dduJd.d.ts → index-D2ipSqkP.d.ts} +4318 -3102
  19. package/dist/index.d.ts +6 -450
  20. package/dist/index.js +14 -11
  21. package/dist/index.js.map +1 -1
  22. package/dist/intelligence.d.ts +3 -3
  23. package/dist/intelligence.js +5 -5
  24. package/dist/kernel.d.ts +4 -4
  25. package/dist/kernel.js +9 -9
  26. package/dist/{loop-runner-bin-BPZ9tt1W.js → loop-runner-bin-B9MIq9O7.js} +3 -3
  27. package/dist/{loop-runner-bin-BPZ9tt1W.js.map → loop-runner-bin-B9MIq9O7.js.map} +1 -1
  28. package/dist/{loop-runner-bin-O_vM1w8Y.d.ts → loop-runner-bin-ThlwVkvo.d.ts} +3 -3
  29. package/dist/loop-runner-bin.d.ts +1 -1
  30. package/dist/loop-runner-bin.js +1 -1
  31. package/dist/mcp/bin.js +3 -3
  32. package/dist/mcp/index.d.ts +5 -5
  33. package/dist/mcp/index.js +4 -4
  34. package/dist/{openai-tools-DWHxpwx2.d.ts → openai-tools-Bb0mAr5z.d.ts} +2 -2
  35. package/dist/{prepare-oHUQdC5-.js → prepare-DVlvGP7V.js} +2 -2
  36. package/dist/{prepare-oHUQdC5-.js.map → prepare-DVlvGP7V.js.map} +1 -1
  37. package/dist/profiles.d.ts +2 -2
  38. package/dist/{protected-model-port-DqF0qDU6.js → protected-model-port-BrWgsCnl.js} +2 -2
  39. package/dist/{protected-model-port-DqF0qDU6.js.map → protected-model-port-BrWgsCnl.js.map} +1 -1
  40. package/dist/{protected-redaction--F3v1oo8.js → protected-redaction-DylCC_ot.js} +14 -20
  41. package/dist/protected-redaction-DylCC_ot.js.map +1 -0
  42. package/dist/{provision-supervisor-Cy8pqE95.js → provision-supervisor-BKAvsDtP.js} +3 -3
  43. package/dist/{provision-supervisor-Cy8pqE95.js.map → provision-supervisor-BKAvsDtP.js.map} +1 -1
  44. package/dist/{runtime-DVjIH1eo.js → runtime-CHxXrUeZ.js} +2079 -1441
  45. package/dist/runtime-CHxXrUeZ.js.map +1 -0
  46. package/dist/{server-CN9vzbSe.js → server-2OeFrEVG.js} +3 -3
  47. package/dist/{server-CN9vzbSe.js.map → server-2OeFrEVG.js.map} +1 -1
  48. package/dist/{stream-agent-turn-DbEsKgb_.d.ts → stream-agent-turn-ewm3BZAp.d.ts} +15 -16
  49. package/dist/{structural-rollout-I92sIfNl.js → structural-rollout-DCUprNpH.js} +2 -2
  50. package/dist/{structural-rollout-I92sIfNl.js.map → structural-rollout-DCUprNpH.js.map} +1 -1
  51. package/dist/{substrate-CbC03Vzo.d.ts → substrate-VKjmrksz.d.ts} +2 -2
  52. package/dist/{supervise-DJ_1i9vj.js → supervise-Dej5aSDa.js} +211 -48
  53. package/dist/supervise-Dej5aSDa.js.map +1 -0
  54. package/dist/{supervisor-Cvd5mf7x.js → supervisor-DdKPGluv.js} +952 -221
  55. package/dist/supervisor-DdKPGluv.js.map +1 -0
  56. package/dist/testing.d.ts +2 -2
  57. package/dist/testing.js +60 -60
  58. package/dist/tui/index.d.ts +1 -1
  59. package/dist/tui/index.js +1 -1
  60. package/dist/{types-Bo7z5aG5.d.ts → types-DMRc3jru.d.ts} +356 -64
  61. package/package.json +5 -5
  62. package/dist/coordination-driver-iBGMKDvB.js.map +0 -1
  63. package/dist/graph-DnMcepkN.js.map +0 -1
  64. package/dist/protected-redaction--F3v1oo8.js.map +0 -1
  65. package/dist/runtime-DVjIH1eo.js.map +0 -1
  66. package/dist/supervise-DJ_1i9vj.js.map +0 -1
  67. package/dist/supervisor-Cvd5mf7x.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Ii as Driver, Pi as AgentRunSpec, ca as Validator, ra as OutputAdapter } from "./types-Bo7z5aG5.js";
1
+ import { Ca as OutputAdapter, Oa as Validator, ea as AgentRunSpec, na as Driver } from "./types-DMRc3jru.js";
2
2
  import { AgentProfile } from "@tangle-network/agent-interface";
3
3
  //#region src/profiles/coder.d.ts
4
4
  /**
@@ -281,4 +281,4 @@ interface UiFinding {
281
281
  }
282
282
  //#endregion
283
283
  export { CoderTask as _, UiFindingSeverity as a, KnowledgeUpdate as c, ResearchSource as d, ResearchTask as f, researcherProfile as g, multiHarnessResearcherFanout as h, UiFindingScreenshot as i, MultiHarnessResearcherFanoutOptions as l, createResearcherValidator as m, UI_LENSES as n, UiLens as o, ResearcherProfileOptions as p, UiFinding as r, KnowledgeItem as s, UI_FINDING_SEVERITIES as t, ResearchOutput as u, coderTaskToPrompt as v };
284
- //# sourceMappingURL=substrate-CbC03Vzo.d.ts.map
284
+ //# sourceMappingURL=substrate-VKjmrksz.d.ts.map
@@ -1,9 +1,9 @@
1
- import { $r as controlProfileMaterialization, A as restoreScopeOwnerAcceptedExecution, Ai as runtimeOwnedExecutorMaterialization, B as bindScopeRetainedOwnerEnvironmentId, C as beginScopeOwnerAttempt, Ca as teardownExecutor, D as meterRuntimeOwnedProviderAttempt, Di as recordRuntimeOwnedDriveHarnessProviderEvidence, E as meterRuntimeOwnedAccounting, Ei as providerAttemptEvidence, G as scopeRetainedOwnerContext, Gt as newUsageTotals, H as consumeScopeRetainedOwnerResult, Hn as resolveAgentEnvironmentProvider, Ht as assertValidBudget, J as scopeRetainedOwnerResult, Jt as WORKER_TRACE_PROPAGATION, K as scopeRetainedOwnerPriorSpend, Mi as runtimeOwnedPendingExecutorMaterialization, Mr as toOtelAttributes, Ni as runtimeOwnedScopeOwnerRuntime, Nn as routerBrain, O as recordScopeOwnerMaterialization, Oi as runtimeOwnedDriveHarnessProviderEvidence, Or as generateSpanId, Qr as assertProfileMaterialization, S as assertRecursiveReservationPolicy, Si as inheritRuntimeOwnedExecutorAttestation, Sn as bridgeStopSignalKey, T as deriveNodeExecutionIdentity, Tr as createOtelExporter, U as prepareScopeRetainedOwnerTask, V as bindScopeRetainedOwnerProvider, W as reconcileScopeRetainedOwnerEnvironment, Wt as meterUsageEvent, Xn as retainedExecutorSeamKey, Yn as registerRetainedExecutorPreparation, Zn as errMessage, _ as driverChild, _a as withBudgetResources, ar as RunCancellationReason, c as runTree, ca as sleep, ci as renderUnsupported, cr as runAbortable, d as HarnessTurnFailedError, ea as addSpend, ei as defineProfileMaterializationContract, fa as unmeteredSpend, fi as worktreeCliProfileMaterialization, ft as bindReusableExecutorExecutionId, ga as resourceTelemetry, gi as readCommittedJsonLines, gn as bridgeModelRouteRefusal, gt as createExecutor, h as summarizeDriverAttempts, ha as addResourceSpend, hi as prepareJsonlAppend, hn as bridgeAdmissionRefusal, hr as contentAddress, i as bestDelivered, ii as promptModelProfileMaterialization, j as scopeOwnerExecutorNodeContext, ji as runtimeOwnedExecutorProviderEvidence, k as recordScopeOwnerPause, ki as runtimeOwnedExecutorExecutionBinding, m as runDriverWithRetry, ma as zeroSpend, mn as executorFailure, n as createRootHandle, ni as profileMaterializationAxes$1, p as defaultUnmetContractSteer, pa as withTimeout, pi as isNoEntError, pt as captureReusableExecutorConfig, q as scopeRetainedOwnerResourceReader, qt as spendFromUsageTotals, r as createSupervisor, ri as promptControlProfileMaterialization, rn as createInbox, s as runFinalizer, sr as linkAbort, ti as fullProfileMaterialization, ui as unsupportedProfileDimensions, v as driverExecutorFactory, vt as snapshotExecutorConfig, wa as teardownSurfaces, xa as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, xn as bridgeRuntimeAttachmentsKey, y as isDriverSpec, yi as attestRuntimeOwnedScopeOwner, zi as detachedSnapshot } from "./supervisor-Cvd5mf7x.js";
1
+ import { $ as bindScopeRetainedOwnerProvider, $i as detachedSnapshot, A as driverExecutorFactory, Aa as resourceTelemetry, Ai as readCommittedJsonLines, At as snapshotExecutorConfig, B as recordScopeOwnerMaterialization, Bi as providerAttemptEvidence, C as createContinuationKeeper, Da as withTimeout, Di as isNoEntError, Dn as executorFailure, Dr as persistHarnessTranscript, Ea as unmeteredSpend, Ei as worktreeCliProfileMaterialization, F as beginScopeOwnerAttempt, Fa as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, Fn as bridgeStopSignalKey, Gi as runtimeOwnedExecutorProviderEvidence, H as restoreScopeOwnerAcceptedExecution, Hi as runtimeOwnedDriveHarnessProviderEvidence, Hr as generateSpanId, Ii as inheritRuntimeOwnedExecutorAttestation, Ki as runtimeOwnedPendingExecutorMaterialization, Kn as routerBrain, Kr as toOtelAttributes, L as deriveNodeExecutionIdentity, La as teardownExecutor, Ni as attestRuntimeOwnedScopeOwner, Oa as zeroSpend, On as bridgeAdmissionRefusal, Or as readHarnessTranscript, Ot as createExecutor, P as assertRecursiveReservationPolicy, Pn as bridgeRuntimeAttachmentsKey, Pt as createRouterTranscript, Q as bindScopeRetainedOwnerEnvironmentId, R as meterRuntimeOwnedAccounting, Ra as teardownSurfaces, Sa as sleep, Si as renderUnsupported, Tt as captureReusableExecutorConfig, U as scopeOwnerExecutorNodeContext, Ui as runtimeOwnedExecutorExecutionBinding, V as recordScopeOwnerPause, Vi as recordRuntimeOwnedDriveHarnessProviderEvidence, Wi as runtimeOwnedExecutorMaterialization, _ as CheckUnavailableError, _i as promptControlProfileMaterialization, at as scopeRetainedOwnerResourceReader, b as bestComposite, br as linkAbort, c as runTree, cr as registerRetainedExecutorPreparation, et as consumeScopeRetainedOwnerResult, f as runDriverWithRetry, fi as assertProfileMaterialization, gi as profileMaterializationAxes$1, gn as createInbox, h as CONTINUATIONS_DIR, hi as fullProfileMaterialization, i as bestDelivered, in as newUsageTotals, it as scopeRetainedOwnerPriorSpend, j as isDriverSpec, ja as withBudgetResources, k as driverChild, ka as addResourceSpend, ki as prepareJsonlAppend, kn as bridgeModelRouteRefusal, kr as contentAddress, lr as retainedExecutorSeamKey, ma as addSpend, mi as defineProfileMaterializationContract, n as createRootHandle, nt as reconcileScopeRetainedOwnerEnvironment, on as spendFromUsageTotals, ot as scopeRetainedOwnerResult, p as summarizeDriverAttempts, pi as controlProfileMaterialization, qi as runtimeOwnedScopeOwnerRuntime, r as createSupervisor, rn as meterUsageEvent, rt as scopeRetainedOwnerContext, s as runFinalizer, sn as WORKER_TRACE_PROPAGATION, tn as assertValidBudget, tr as resolveAgentEnvironmentProvider, tt as prepareScopeRetainedOwnerTask, u as HarnessTurnFailedError, ur as errMessage, v as admitContinuationPolicy, vi as promptModelProfileMaterialization, vr as RunCancellationReason, wi as unsupportedProfileDimensions, wt as bindReusableExecutorExecutionId, x as checkVerdictOf, xr as runAbortable, z as meterRuntimeOwnedProviderAttempt, zr as createOtelExporter } from "./supervisor-DdKPGluv.js";
2
2
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
3
3
  import { a as concreteProfileModel, c as profileModelExecutionSettings, d as agentHarness, f as harnessRunsAgent, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile } from "./model-policy-BbSCSak0.js";
4
4
  import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
5
5
  import { n as assertNoSymlinkDescendant } from "./durable-file-DWQA4ooo.js";
6
- import { D as coordinationVerbNames, S as watchRunCancellation, c as createProgressTracker, d as progressStop, k as createCoordinationToolsForManager, n as createSteerAcknowledger, r as driverAgent, t as createCancelAcknowledger, v as createFileRunContext, w as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, x as applyRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-iBGMKDvB.js";
6
+ import { C as applyRunCancellation, E as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, b as withRunContext, c as createProgressTracker, d as progressStop, j as createCoordinationToolsForManager, k as coordinationVerbNames, n as createSteerAcknowledger, r as driverAgent, t as createCancelAcknowledger, u as plateau, v as createFileRunContext, w as watchRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-CkcW4dxU.js";
7
7
  import { r as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-Dqer2M4_.js";
8
8
  import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-vwd4SwX_.js";
9
9
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
@@ -12,6 +12,7 @@ import { closeSync, constants, fsyncSync, openSync, writeSync } from "node:fs";
12
12
  import { resolve } from "node:path";
13
13
  import { mkdir } from "node:fs/promises";
14
14
  import { isMaterializerHarness } from "@tangle-network/agent-profile-materialize";
15
+ import { ATTR } from "@tangle-network/agent-trace-contract";
15
16
  import { createServer } from "node:http";
16
17
  import { withProfileKb } from "@tangle-network/agent-interface/profile-kb";
17
18
  //#region src/runtime/supervise/completion-gate.ts
@@ -48,7 +49,7 @@ function gateOnDeliverable(inner, deliverable) {
48
49
  const check = async (out, baseScore) => {
49
50
  let delivered;
50
51
  try {
51
- delivered = await deliverable.check(out) === true;
52
+ delivered = checkVerdictOf(await deliverable.check(out)).pass;
52
53
  } catch {
53
54
  delivered = false;
54
55
  }
@@ -689,6 +690,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
689
690
  ...opts.authorizeDownMessage ? { authorizeDownMessage: opts.authorizeDownMessage } : {},
690
691
  perWorker: opts.perWorker,
691
692
  ...opts.deliverable ? { deliverable: opts.deliverable } : {},
693
+ ...opts.readContinuation ? { readContinuation: opts.readContinuation } : {},
692
694
  ...opts.onStop ? { onStop: opts.onStop } : {},
693
695
  awaitTimeoutMs: opts.awaitTimeoutMs ?? responseFenceMs,
694
696
  ...opts.analysts ? { analysts: opts.analysts } : {},
@@ -977,6 +979,21 @@ function createSupervisorSpanRecorder(opts) {
977
979
  const open = /* @__PURE__ */ new Map();
978
980
  const spanIdOf = /* @__PURE__ */ new Map([[opts.runId, rootSpanId]]);
979
981
  let finished = false;
982
+ /**
983
+ * The span a node's event hangs under. A parent node whose span this recorder never opened (it
984
+ * ran in an earlier process) leaves the child on the root span, which is a placeholder, not a
985
+ * recorded parent.
986
+ */
987
+ const parentSpan = (parentId) => {
988
+ const spanId = parentId === void 0 ? void 0 : spanIdOf.get(parentId);
989
+ return spanId ? {
990
+ spanId,
991
+ confidence: "explicit"
992
+ } : {
993
+ spanId: rootSpanId,
994
+ confidence: "unknown"
995
+ };
996
+ };
980
997
  /** Every export is best-effort: a throwing exporter must never reach the run. */
981
998
  const emit = (span) => {
982
999
  try {
@@ -1006,7 +1023,7 @@ function createSupervisorSpanRecorder(opts) {
1006
1023
  const isWait = runtime === "wait";
1007
1024
  const attrs = {
1008
1025
  ...base,
1009
- "openinference.span.kind": isWait ? "CHAIN" : "AGENT",
1026
+ [ATTR.spanKind]: isWait ? "CHAIN" : "AGENT",
1010
1027
  "agent.name": label,
1011
1028
  "tangle.supervise.node.id": childId,
1012
1029
  "tangle.supervise.node.label": label,
@@ -1016,14 +1033,22 @@ function createSupervisorSpanRecorder(opts) {
1016
1033
  if (event.parentId) attrs["tangle.supervise.node.parent_id"] = event.parentId;
1017
1034
  if (runtime) attrs["tangle.supervise.node.runtime"] = runtime;
1018
1035
  if (typeof p.depth === "number") attrs["tangle.supervise.node.depth"] = p.depth;
1036
+ const key = str(p.key);
1037
+ const operation = str(p.assignmentId) ?? key;
1038
+ if (operation) attrs[ATTR.operationId] = operation;
1039
+ const attempt = str(p.attemptId);
1040
+ if (attempt) attrs[ATTR.attemptId] = attempt;
1041
+ if (key) attrs[ATTR.idempotencyKey] = key;
1019
1042
  if (typeof event.stepIndex === "number") attrs["tangle.supervise.node.ordinal"] = event.stepIndex;
1020
1043
  if (p.resumed === true) attrs["tangle.supervise.node.resumed"] = true;
1021
1044
  assignBudget(attrs, p.budget);
1045
+ const parent = parentSpan(event.parentId);
1046
+ attrs[ATTR.parentConfidence] = parent.confidence;
1022
1047
  const spanId = generateSpanId();
1023
1048
  spanIdOf.set(childId, spanId);
1024
1049
  open.set(childId, {
1025
1050
  spanId,
1026
- parentSpanId: event.parentId && spanIdOf.get(event.parentId) || rootSpanId,
1051
+ parentSpanId: parent.spanId,
1027
1052
  name: label,
1028
1053
  startMs: event.timestamp,
1029
1054
  attrs
@@ -1060,10 +1085,15 @@ function createSupervisorSpanRecorder(opts) {
1060
1085
  function onTurn(event) {
1061
1086
  const p = record(event.payload);
1062
1087
  const parentId = event.parentId;
1063
- const parentSpanId = parentId && spanIdOf.get(parentId) || rootSpanId;
1088
+ const parent = parentId ? parentSpan(parentId) : {
1089
+ spanId: rootSpanId,
1090
+ confidence: "explicit"
1091
+ };
1092
+ const parentSpanId = parent.spanId;
1064
1093
  const attrs = {
1065
1094
  ...base,
1066
- "openinference.span.kind": "LLM",
1095
+ [ATTR.parentConfidence]: parent.confidence,
1096
+ [ATTR.spanKind]: "LLM",
1067
1097
  "inference.observation_kind": "LLM",
1068
1098
  "tangle.supervise.node.kind": "inference"
1069
1099
  };
@@ -1121,17 +1151,27 @@ function createSupervisorSpanRecorder(opts) {
1121
1151
  "tangle.supervise.node.id": nodeId
1122
1152
  }, STATUS_UNSET));
1123
1153
  open.clear();
1124
- emit(span(rootSpanId, opts.parentSpanId, "supervisor.run", rootStartMs, endMs, rootAttrs(base, opts.agentName ?? "supervisor", outcome), rootStatus(outcome), rootMessage(outcome)));
1154
+ emit(span(rootSpanId, opts.parentSpanId, "supervisor.run", rootStartMs, endMs, {
1155
+ ...rootAttrs(base, opts.agentName ?? "supervisor", outcome),
1156
+ ...opts.parentSpanId ? { [ATTR.parentConfidence]: "explicit" } : {}
1157
+ }, rootStatus(outcome), rootMessage(outcome)));
1158
+ } catch {}
1159
+ try {
1125
1160
  await exporter.flush();
1161
+ } catch (error) {
1162
+ const s = exporter.stats();
1163
+ console.warn(`[agent-runtime] supervisor span export dropped ${s.dropped} span(s): ${s.lastError ?? String(error)}`);
1164
+ } finally {
1126
1165
  if (ownsExporter) await exporter.shutdown();
1127
- } catch {}
1128
- }
1166
+ }
1167
+ },
1168
+ stats: () => exporter.stats()
1129
1169
  };
1130
1170
  }
1131
1171
  function rootAttrs(base, agentName, outcome) {
1132
1172
  const attrs = {
1133
1173
  ...base,
1134
- "openinference.span.kind": "AGENT",
1174
+ [ATTR.spanKind]: "AGENT",
1135
1175
  "inference.observation_kind": "AGENT",
1136
1176
  "agent.name": agentName,
1137
1177
  "inference.agent_name": agentName,
@@ -1283,7 +1323,7 @@ function composeReentryTask(input) {
1283
1323
  * only what to continue, spent all forty-five on the research.
1284
1324
  */
1285
1325
  function whyLine(reentry) {
1286
- if (reentry.reason === "unmet-contract") return `Your previous turn ended with the completion check unmet (re-prompt ${reentry.reprompt}).`;
1326
+ if (reentry.reason === "unmet-contract") return `Your previous turn ended with the completion check unmet (continuation ${reentry.continuation}).`;
1287
1327
  return reentry.reason === "upstream-unavailable" ? "Your previous turn was interrupted before it finished; the run itself is intact." : `Your previous turn ended before it finished (retry ${reentry.retry}); the run itself is intact.`;
1288
1328
  }
1289
1329
  function environmentLine(continuity) {
@@ -1755,18 +1795,20 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1755
1795
  if (harness === null && coordination !== void 0) throw new ConfigError("supervisorAgent: coordination binding is only meaningful for a harness-brained supervisor (profile.harness set). A router-brained supervisor calls the coordination verbs in process and serves no MCP, so this binding would be silently ignored.");
1756
1796
  if (harness === null && deps.peerMail) throw new ValidationError("supervisorAgent: peerMail is only served by a harness-brained supervisor (profile.harness set). A router-brained supervisor serves no coordination MCP listener, so there is no peer-mail post office to mint worker capabilities from.");
1757
1797
  if (harness !== null && deps.compaction) throw new ValidationError("supervisorAgent: compaction is only supported for router-brained supervisors (profile.harness omitted or cli-base)");
1758
- if (harness === null && (deps.repromptOnUnmet !== void 0 || deps.onUnmetContract !== void 0)) throw new ValidationError("supervisorAgent: repromptOnUnmet/onUnmetContract apply to an EXTERNAL-harness supervisor only (profile.harness set). A router-brained supervisor runs its own turn loop in process, so this option would be silently ignored.");
1759
- if (deps.repromptOnUnmet !== void 0 && deps.repromptOnUnmet !== "until-complete" && (!Number.isInteger(deps.repromptOnUnmet) || deps.repromptOnUnmet < 0)) throw new ValidationError("supervisorAgent: repromptOnUnmet must be a non-negative integer or 'until-complete' (0 = never re-prompt)");
1760
- const repromptEnabled = deps.repromptOnUnmet === "until-complete" || (deps.repromptOnUnmet ?? 0) > 0;
1761
- if (deps.onUnmetContract !== void 0 && !repromptEnabled) throw new ValidationError("supervisorAgent: onUnmetContract needs repromptOnUnmet >= 1 or 'until-complete'");
1762
- if (repromptEnabled && deps.deliverable === void 0) throw new ValidationError("supervisorAgent: repromptOnUnmet needs a `deliverable` completion check — with no check there is no contract that can be unmet, and every run would re-prompt");
1798
+ if (harness === null && deps.continuation !== void 0) throw new ValidationError("supervisorAgent: continuation applies to an EXTERNAL-harness supervisor only (profile.harness set). A router-brained supervisor runs its own turn loop in process, so the policy would be silently ignored.");
1799
+ if (deps.continuation !== void 0 && deps.deliverable === void 0) throw new ValidationError("supervisorAgent: continuation needs a `deliverable` completion check — with no check there is no contract that can be unmet");
1800
+ if (harness !== null && deps.deliverable !== void 0 && deps.continuation === void 0) throw new ValidationError("supervisorAgent: a manager with a completion check needs a continuation policy (deadline, maxBarren, the note profile and switches). Runtime supplies no default: how long to send a director back, and what to tell it, is the record's decision");
1801
+ if (deps.deliverable !== void 0 && runtimeToolNames.includes("stop")) throw new ValidationError(`supervisorAgent: the profile grants ${coordinationProfileToolPrefix}stop to a manager with a completion check. Such a manager ends only through submit_result (the check passes) or report_blocked (a failed probe); remove stop from its tools`);
1802
+ const continuationDeadlineMs = deps.continuation === void 0 ? void 0 : admitContinuationPolicy(deps.continuation, "supervisorAgent");
1763
1803
  if (harness === null) {
1764
1804
  assertRouterArmResourcePolicy(stableProfile);
1765
1805
  const brain = testBrain ?? routerBrainFromProfile(stableProfile, stableRouter);
1766
1806
  const inbox = createInbox();
1807
+ const transcript = createRouterTranscript();
1767
1808
  const build = (priorCoordination, nodeTools, onEvent, slot) => driverAgent({
1768
1809
  name,
1769
1810
  brain,
1811
+ transcript,
1770
1812
  ...testBrain === void 0 ? { expectedModel: resolveSupervisorModelId(stableProfile) } : {},
1771
1813
  ...deps.onProviderModel ? { onProviderModel: deps.onProviderModel } : {},
1772
1814
  blobs: deps.blobs,
@@ -1815,6 +1857,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1815
1857
  deliver(message) {
1816
1858
  return inbox.deliver(message);
1817
1859
  },
1860
+ harnessTranscript: () => transcript.capture(),
1818
1861
  async act(task, scope) {
1819
1862
  const context = nodeContextSeed ? supervisorNodeContext(nodeContextSeed, stableProfile, task, scope) : void 0;
1820
1863
  const priorCoordination = await deps.loadPriorCoordination?.();
@@ -1862,6 +1905,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1862
1905
  deps.onProgressStop?.(decision.reason);
1863
1906
  if (!stopController.signal.aborted) stopController.abort(decision.reason);
1864
1907
  } : nodeObserver;
1908
+ let keeper;
1865
1909
  const { handle: mcp, controls } = await serveCoordinationMcpForManager({
1866
1910
  scope,
1867
1911
  blobs: deps.blobs,
@@ -1874,6 +1918,10 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1874
1918
  actorId: context.ownerId
1875
1919
  } } : {},
1876
1920
  ...deps.deliverable ? { deliverable: deps.deliverable } : {},
1921
+ ...deps.continuation ? { readContinuation: (n) => keeper?.read(n) ?? {
1922
+ found: false,
1923
+ reason: "no continuation has been sent"
1924
+ } } : {},
1877
1925
  onStop: (reason) => {
1878
1926
  if (!stopController.signal.aborted) stopController.abort(reason ?? "coordination stop");
1879
1927
  },
@@ -1935,27 +1983,93 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1935
1983
  }
1936
1984
  const baseTokensLeft = scope.budget.tokensLeft;
1937
1985
  const contractDeclared = deps.deliverable !== void 0;
1938
- const maxReprompts = deps.repromptOnUnmet ?? 0;
1986
+ const continuation = deps.continuation;
1987
+ if (continuation !== void 0 && deps.deliverable !== void 0) keeper = createContinuationKeeper({
1988
+ policy: continuation,
1989
+ task,
1990
+ ...deps.deliverable.describe === void 0 ? {} : { owed: deps.deliverable.describe },
1991
+ ...deps.deliverable.feedback === void 0 ? {} : { feedback: deps.deliverable.feedback },
1992
+ ...deps.deliverable.sealed === true ? { sealed: true } : {},
1993
+ reads: () => controls.checkReads(),
1994
+ workers: () => {
1995
+ const labels = new Map((scope.view?.nodes ?? []).map((node) => [node.id, node.label]));
1996
+ return mcp.settled().map((worker) => ({
1997
+ id: worker.id,
1998
+ label: labels.get(worker.id) ?? worker.id
1999
+ }));
2000
+ },
2001
+ ...deps.continuationDir === void 0 ? {} : { dir: deps.continuationDir },
2002
+ ...deps.rootStreamPath === void 0 ? {} : { rootStreamPath: deps.rootStreamPath },
2003
+ canReadMore: runtimeToolNames.includes("read_continuation")
2004
+ });
1939
2005
  let candidate;
2006
+ const finalizerDeliverable = deps.deliverable === void 0 ? void 0 : {
2007
+ ...deps.deliverable,
2008
+ check: async (out) => {
2009
+ let verdict;
2010
+ try {
2011
+ verdict = checkVerdictOf(await deps.deliverable?.check(out));
2012
+ } catch (error) {
2013
+ controls.recordCheckRead({
2014
+ source: "turn-end",
2015
+ unavailable: error instanceof Error ? error.message : String(error)
2016
+ });
2017
+ throw error;
2018
+ }
2019
+ controls.recordCheckRead({
2020
+ source: "turn-end",
2021
+ verdict
2022
+ });
2023
+ return verdict;
2024
+ }
2025
+ };
1940
2026
  const finalize = () => runFinalizer(deps.finalizer ?? bestDelivered, {
1941
2027
  settled: mcp.settled(),
1942
2028
  blobs: deps.blobs,
1943
2029
  tree: runTree(scope),
1944
2030
  budget: scope.budget,
1945
- ...deps.deliverable ? { deliverable: deps.deliverable } : {}
2031
+ ...finalizerDeliverable ? { deliverable: finalizerDeliverable } : {}
1946
2032
  });
1947
2033
  const readProgress = () => {
1948
2034
  const settled = mcp.settled();
1949
2035
  const deliveredCount = settled.filter((w) => w.status === "done" && w.valid === true).length;
1950
2036
  const submitted = Boolean(mcp.submittedResult());
2037
+ const composite = bestComposite(controls.checkReads());
1951
2038
  return {
1952
2039
  poolTokensSpent: baseTokensLeft - scope.budget.tokensLeft,
1953
2040
  settledCount: settled.length,
1954
2041
  submitted,
1955
2042
  deliveredCount,
1956
- contract: !contractDeclared ? "none" : submitted || candidate !== void 0 ? "met" : "unmet"
2043
+ contract: !contractDeclared ? "none" : submitted || candidate !== void 0 ? "met" : "unmet",
2044
+ ...composite === void 0 ? {} : { composite }
1957
2045
  };
1958
2046
  };
2047
+ /**
2048
+ * The check runs when a turn ends without an accepted result. A read already taken in this
2049
+ * turn stands (the manager just heard it); otherwise a check that judges state reads the
2050
+ * run now. A check that could not run is not a verdict: the loop pauses.
2051
+ */
2052
+ const readCheckAtTurnEnd = async (attempt) => {
2053
+ const deliverable = deps.deliverable;
2054
+ if (deliverable === void 0) return;
2055
+ const last = controls.checkReads().filter((read) => read.attempt === attempt).at(-1);
2056
+ if (last === void 0 && deliverable.checkState !== void 0) try {
2057
+ const verdict = checkVerdictOf(await deliverable.checkState());
2058
+ controls.recordCheckRead({
2059
+ source: "turn-end",
2060
+ verdict
2061
+ });
2062
+ return;
2063
+ } catch (error) {
2064
+ const message = error instanceof Error ? error.message : String(error);
2065
+ controls.recordCheckRead({
2066
+ source: "turn-end",
2067
+ unavailable: message
2068
+ });
2069
+ throw new CheckUnavailableError(`the completion check could not run: ${message}`, { cause: error });
2070
+ }
2071
+ if (last?.unavailable !== void 0) throw new CheckUnavailableError(`the completion check could not run: ${last.unavailable}`);
2072
+ };
1959
2073
  const loopRecords = [];
1960
2074
  let environmentReplacements = 0;
1961
2075
  const describe = deps.deliverable?.describe;
@@ -1966,7 +2080,8 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1966
2080
  ...summarizeDriverAttempts(loopRecords),
1967
2081
  environmentReplacements,
1968
2082
  ...closedBy === void 0 ? {} : { closedBy },
1969
- ...stopReason === void 0 ? {} : { stopReason }
2083
+ ...stopReason === void 0 ? {} : { stopReason },
2084
+ continuations: keeper?.entries() ?? []
1970
2085
  });
1971
2086
  };
1972
2087
  try {
@@ -2017,19 +2132,18 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2017
2132
  if (contractDeclared && !mcp.submittedResult()) {
2018
2133
  await mcp.drainResolved();
2019
2134
  candidate = await finalize();
2135
+ if (candidate === void 0 && !mcp.isStopped()) await readCheckAtTurnEnd(attempt);
2020
2136
  }
2021
2137
  },
2022
2138
  progress: readProgress,
2023
2139
  budget: () => scope.budget,
2024
2140
  signal: scope.signal,
2025
2141
  ...deps.driverRetry ? { policy: deps.driverRetry } : {},
2026
- ...repromptEnabled ? { reprompt: {
2027
- maxReprompts,
2028
- ...deps.deliverable?.describe === void 0 ? {} : { describe: deps.deliverable.describe },
2029
- onUnmetContract: async (context) => {
2030
- if (mcp.isStopped() || progressStopReason !== void 0) return "stop";
2031
- return await deps.onUnmetContract?.(context) ?? { steer: defaultUnmetContractSteer(context) };
2032
- }
2142
+ ...continuation !== void 0 && keeper !== void 0 && continuationDeadlineMs ? { continuation: {
2143
+ maxBarren: continuation.maxBarren,
2144
+ deadlineMs: continuationDeadlineMs,
2145
+ compose: (context) => keeper.compose(context),
2146
+ closed: () => mcp.isStopped() || progressStopReason !== void 0
2033
2147
  } } : {},
2034
2148
  onAttempt: async (record) => {
2035
2149
  loopRecords.push(record);
@@ -3338,6 +3452,7 @@ const superviseOptionKeySet = /* @__PURE__ */ new Set([
3338
3452
  "router",
3339
3453
  "runDir",
3340
3454
  "resume",
3455
+ "runContext",
3341
3456
  "runId",
3342
3457
  "signal",
3343
3458
  "stallAfterMs",
@@ -3345,8 +3460,7 @@ const superviseOptionKeySet = /* @__PURE__ */ new Set([
3345
3460
  "steerDir",
3346
3461
  "stopRule",
3347
3462
  "watchWorkers",
3348
- "repromptOnUnmet",
3349
- "onUnmetContract",
3463
+ "continuation",
3350
3464
  "workerRetry",
3351
3465
  "onWorkerRetry",
3352
3466
  "workerSlots",
@@ -3368,11 +3482,16 @@ function assertSuperviseOptionKeys(opts, context) {
3368
3482
  function captureDeliverable(deliverable, context) {
3369
3483
  if (typeof deliverable !== "object" || deliverable === null || Array.isArray(deliverable)) throw new ValidationError(`${context}: deliverable must be an object`);
3370
3484
  if (typeof deliverable.check !== "function") throw new ValidationError(`${context}: deliverable.check must be a function`);
3371
- if (deliverable.explainFailure !== void 0 && typeof deliverable.explainFailure !== "function") throw new ValidationError(`${context}: deliverable.explainFailure must be a function`);
3485
+ if (deliverable.checkState !== void 0 && typeof deliverable.checkState !== "function") throw new ValidationError(`${context}: deliverable.checkState must be a function`);
3486
+ if (deliverable.feedback !== void 0 && deliverable.feedback !== "verbatim" && deliverable.feedback !== "pass-only") throw new ValidationError(`${context}: deliverable.feedback must be 'verbatim' or 'pass-only'`);
3372
3487
  return Object.freeze({
3373
- ...detachedSnapshot({ describe: deliverable.describe }, `${context} configuration`),
3488
+ ...detachedSnapshot({
3489
+ describe: deliverable.describe,
3490
+ ...deliverable.feedback === void 0 ? {} : { feedback: deliverable.feedback },
3491
+ ...deliverable.sealed === void 0 ? {} : { sealed: deliverable.sealed === true }
3492
+ }, `${context} configuration`),
3374
3493
  check: deliverable.check,
3375
- ...deliverable.explainFailure === void 0 ? {} : { explainFailure: deliverable.explainFailure }
3494
+ ...deliverable.checkState === void 0 ? {} : { checkState: deliverable.checkState }
3376
3495
  });
3377
3496
  }
3378
3497
  Object.freeze([...[
@@ -3388,7 +3507,6 @@ Object.freeze([...[
3388
3507
  "onCoordinationEvent",
3389
3508
  "onDriverAttempt",
3390
3509
  "onProgressStop",
3391
- "onUnmetContract",
3392
3510
  "onWorkerRetry",
3393
3511
  "recoverExecutor",
3394
3512
  "resolveDeliverable",
@@ -3428,7 +3546,7 @@ function rootSpawnResourceRoot(backend) {
3428
3546
  }
3429
3547
  function captureSuperviseOptions(opts) {
3430
3548
  assertSuperviseOptionKeys(opts, "supervise");
3431
- const { backend, coordination, driverBackend, deliverable, resolveDeliverable, router, compaction, watchWorkers, analysts, makeWorkerAgent, makeLeafAgent, recoverExecutor, resume, resolveSpawnProfile, blobs, journal, probes, registry, hooks, otel, authorizeSpawn, authorizeMessage, driveHarness, resolveDriveHarness, resolveSupervisorTools, escalateQuestion, onCoordinationEvent, executeExtraTool, stopRule, onProgressStop, onDriverAttempt, onUnmetContract, workerRetry, onWorkerRetry, finalizer, now, signal, rootHandle, workerSlots, ...decisionData } = opts;
3549
+ const { backend, coordination, driverBackend, deliverable, resolveDeliverable, router, compaction, watchWorkers, analysts, makeWorkerAgent, makeLeafAgent, recoverExecutor, resume, resolveSpawnProfile, blobs, journal, runContext, probes, registry, hooks, otel, authorizeSpawn, authorizeMessage, driveHarness, resolveDriveHarness, resolveSupervisorTools, escalateQuestion, onCoordinationEvent, executeExtraTool, stopRule, onProgressStop, onDriverAttempt, continuation, workerRetry, onWorkerRetry, finalizer, now, signal, rootHandle, workerSlots, ...decisionData } = opts;
3432
3550
  assertNoUncapturedExecutableOption(decisionData);
3433
3551
  const capturedData = detachedSnapshot(decisionData, "supervise options");
3434
3552
  const capturedCoordination = coordination === void 0 ? void 0 : (() => {
@@ -3476,6 +3594,14 @@ function captureSuperviseOptions(opts) {
3476
3594
  run: analysts.run,
3477
3595
  ...typeof analysts.register === "function" ? { register: analysts.register } : {}
3478
3596
  });
3597
+ const capturedContinuation = continuation === void 0 ? void 0 : (() => {
3598
+ const { runPanel, append, ...policy } = continuation;
3599
+ return Object.freeze({
3600
+ ...detachedSnapshot(policy, "supervise continuation"),
3601
+ ...runPanel === void 0 ? {} : { runPanel },
3602
+ ...append === void 0 ? {} : { append }
3603
+ });
3604
+ })();
3479
3605
  return Object.freeze({
3480
3606
  ...capturedData,
3481
3607
  ...capturedCoordination === void 0 ? {} : { coordination: capturedCoordination },
@@ -3494,6 +3620,7 @@ function captureSuperviseOptions(opts) {
3494
3620
  ...blobs === void 0 ? {} : { blobs },
3495
3621
  ...journal === void 0 ? {} : { journal },
3496
3622
  ...resume === void 0 ? {} : { resume },
3623
+ ...runContext === void 0 ? {} : { runContext },
3497
3624
  ...workerSlots === void 0 ? {} : { workerSlots },
3498
3625
  ...probes === void 0 ? {} : { probes },
3499
3626
  ...authorizeSpawn === void 0 ? {} : { authorizeSpawn },
@@ -3507,7 +3634,7 @@ function captureSuperviseOptions(opts) {
3507
3634
  ...stopRule === void 0 ? {} : { stopRule },
3508
3635
  ...onProgressStop === void 0 ? {} : { onProgressStop },
3509
3636
  ...onDriverAttempt === void 0 ? {} : { onDriverAttempt },
3510
- ...onUnmetContract === void 0 ? {} : { onUnmetContract },
3637
+ ...capturedContinuation === void 0 ? {} : { continuation: capturedContinuation },
3511
3638
  ...capturedWorkerRetry === void 0 ? {} : { workerRetry: capturedWorkerRetry },
3512
3639
  ...onWorkerRetry === void 0 ? {} : { onWorkerRetry },
3513
3640
  ...finalizer === void 0 ? {} : { finalizer },
@@ -3693,12 +3820,18 @@ function coordinationEventId(context, event) {
3693
3820
  /** One-call supervisor: build + run a supervisor from its exact profile. @stable */
3694
3821
  function supervise(profile, task, opts) {
3695
3822
  if ("brain" in opts) throw new ValidationError("supervise: direct brain injection is test-only; production execution derives the model call from AgentProfile");
3696
- return superviseInternal(profile, task, opts);
3823
+ return superviseWithContext(profile, task, opts);
3824
+ }
3825
+ /** A stop rule as a function, or the declared plateau form a record carries as data. */
3826
+ function stopRuleOf(rule) {
3827
+ if (typeof rule === "function") return rule;
3828
+ if (typeof rule === "object" && rule !== null && "plateau" in rule) return plateau(rule.plateau);
3829
+ throw new ValidationError("supervise: stopRule must be a StopRule or { plateau: { window, minDelta } }");
3697
3830
  }
3698
3831
  /** Deterministic scripted-brain path for tests. Not exported from Runtime's main entry. */
3699
3832
  function superviseWithTestBrain(profile, task, opts) {
3700
3833
  const { brain, ...runtimeOptions } = opts;
3701
- return superviseInternal(profile, task, runtimeOptions, brain);
3834
+ return superviseWithContext(profile, task, runtimeOptions, brain);
3702
3835
  }
3703
3836
  /**
3704
3837
  * The composer `profileGuidance` selects, or `undefined` when no guidance is selected. The result
@@ -3726,8 +3859,23 @@ function superviseRootProfile(profile, profileGuidance) {
3726
3859
  const compose = profileGuidanceComposer(profileGuidance);
3727
3860
  return freezeDetachedProfile(compose ? compose(parsedProfile.data) : parsedProfile.data);
3728
3861
  }
3862
+ function superviseWithContext(profile, task, opts, brain) {
3863
+ if (opts.runContext?.acquire === void 0) return superviseInternal(profile, task, opts, brain);
3864
+ const options = captureSuperviseOptions(opts);
3865
+ const capturedProfile = freezeDetached(profile);
3866
+ const capturedTask = freezeDetached(task);
3867
+ return withRunContext(opts.runContext, options.signal, (runContext, signal) => superviseInternal(capturedProfile, capturedTask, {
3868
+ ...options,
3869
+ runContext,
3870
+ ...signal === void 0 ? {} : { signal }
3871
+ }, brain));
3872
+ }
3729
3873
  function superviseInternal(profile, task, opts, testBrain) {
3730
3874
  const options = captureSuperviseOptions(opts);
3875
+ if (options.runContext?.durability === "sql") {
3876
+ if (options.runDir !== void 0 || options.journal !== void 0 && options.journal !== options.runContext.journal || options.blobs !== void 0 && options.blobs !== options.runContext.blobs || options.runId !== void 0 && options.runId !== options.runContext.runId) throw new ValidationError("supervise: SQL runContext cannot be mixed with another run identity or persistence path");
3877
+ if (options.backend?.backend !== "provider" || options.makeWorkerAgent || options.makeLeafAgent) throw new ValidationError("supervise: SQL runContext requires backend-derived retained provider workers");
3878
+ }
3731
3879
  assertValidBudget(options.budget, "supervise budget");
3732
3880
  const composeSpawnProfile = profileGuidanceComposer(options.profileGuidance);
3733
3881
  const canonicalProfile = superviseRootProfile(profile, options.profileGuidance);
@@ -3764,7 +3912,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3764
3912
  if (options.backend !== void 0 && options.makeLeafAgent === void 0 && declaredRuntimeToolNames(entry).length === 0) assertBackendProfileMaterialization(entry, options.backend, context);
3765
3913
  } : void 0);
3766
3914
  assertCoordinationBinding(options.coordination);
3767
- const ctx = options.runDir !== void 0 ? createFileRunContext(options.runDir, { withDriver: true }) : createInMemoryRunContext({ withDriver: true });
3915
+ const ctx = options.runContext ?? (options.runDir !== void 0 ? createFileRunContext(options.runDir, { withDriver: true }) : createInMemoryRunContext({ withDriver: true }));
3768
3916
  const blobs = options.blobs ?? ctx.blobs;
3769
3917
  assertRecursiveReservationPolicy(options.reservationPolicy);
3770
3918
  const ownerShare = options.reservationPolicy?.ownerShare ?? 0;
@@ -3772,8 +3920,8 @@ function superviseInternal(profile, task, opts, testBrain) {
3772
3920
  assertValidBudget(perWorker, "supervise perWorker");
3773
3921
  assertPerWorkerWithinPool(perWorker, options.budget);
3774
3922
  const journal = options.journal ?? ctx.journal;
3775
- const runId = options.runId ?? "supervise";
3776
- const runNamespace = supervisionRunNamespace(options.runDir, runId);
3923
+ const runId = options.runId ?? ctx.runId ?? "supervise";
3924
+ const runNamespace = ctx.namespace ?? supervisionRunNamespace(options.runDir, runId);
3777
3925
  const log = ctx.coordinationLog;
3778
3926
  const rootOwnerId = rootCoordinationOwner(rootExecution.identity);
3779
3927
  const rootProviderModels = [];
@@ -3954,7 +4102,7 @@ function superviseInternal(profile, task, opts, testBrain) {
3954
4102
  ...composeSpawnProfileFor(authorized) ? { composeSpawnProfile: composeSpawnProfileFor(authorized) } : {},
3955
4103
  ...profileTable ? { profiles: profileTable } : {},
3956
4104
  ...options.peerMail ? { peerMail: options.peerMail } : {},
3957
- ...options.stopRule ? { stopRule: options.stopRule } : {},
4105
+ ...options.stopRule ? { stopRule: stopRuleOf(options.stopRule) } : {},
3958
4106
  ...options.onProgressStop ? { onProgressStop: options.onProgressStop } : {},
3959
4107
  ...options.maxTurns !== void 0 ? { maxTurns: options.maxTurns } : {},
3960
4108
  ...options.compaction ? { compaction: options.compaction } : {},
@@ -3964,8 +4112,10 @@ function superviseInternal(profile, task, opts, testBrain) {
3964
4112
  ...childDeliverable ? { onAcceptedSubmission: () => {
3965
4113
  acceptedSubmission = true;
3966
4114
  } } : {},
3967
- ...options.repromptOnUnmet !== void 0 ? { repromptOnUnmet: options.repromptOnUnmet } : {},
3968
- ...options.onUnmetContract ? { onUnmetContract: options.onUnmetContract } : {},
4115
+ ...childDeliverable && options.continuation && isExternalSupervisor(authorized) ? {
4116
+ continuation: options.continuation,
4117
+ ...options.runDir === void 0 ? {} : { continuationDir: resolve(options.runDir, CONTINUATIONS_DIR, "managers", encodeURIComponent(ownerId)) }
4118
+ } : {},
3969
4119
  ...log ? {
3970
4120
  onEvent: (_event, record) => log.append(runId, record, ownerId),
3971
4121
  loadPriorCoordination: () => log.load(runId, ownerId)
@@ -4015,6 +4165,12 @@ function superviseInternal(profile, task, opts, testBrain) {
4015
4165
  const workerFactory = makeWorkerAgent;
4016
4166
  let rootContinuation;
4017
4167
  const start = async () => {
4168
+ if (ctx.durability === "sql") {
4169
+ if (options.backend?.backend !== "provider" || options.backend.steering || options.driveHarness || options.resolveDriveHarness || options.driverBackend) throw new ValidationError("supervise: SQL runContext requires a local coordinator and non-steering retained provider workers");
4170
+ const provider = resolveAgentEnvironmentProvider(options.backend.provider, options.backend.registry);
4171
+ const capabilities = await provider.capabilities();
4172
+ if (!capabilities.retainedControl || !capabilities.streaming.turnIdempotency || !capabilities.streaming.replay || !provider.get) throw new ValidationError("supervise: SQL runContext requires retainedControl, replay, turn idempotency, and provider.get");
4173
+ }
4018
4174
  await verifyProfilePromotions(profileTable);
4019
4175
  const priorCoordination = log ? await log.load(runId, rootOwnerId) : void 0;
4020
4176
  const authorizeRootMessage = authorizeDownFor(canonicalProfile, 1);
@@ -4064,14 +4220,19 @@ function superviseInternal(profile, task, opts, testBrain) {
4064
4220
  ...options.stallAfterMs !== void 0 ? { stallAfterMs: options.stallAfterMs } : {},
4065
4221
  ...options.awaitTimeoutMs !== void 0 ? { awaitTimeoutMs: options.awaitTimeoutMs } : {},
4066
4222
  ...options.continuityByProfile ? { continuityByProfile: options.continuityByProfile } : {},
4067
- ...options.stopRule ? { stopRule: options.stopRule } : {},
4223
+ ...options.stopRule ? { stopRule: stopRuleOf(options.stopRule) } : {},
4068
4224
  ...options.onProgressStop ? { onProgressStop: options.onProgressStop } : {},
4069
4225
  ...options.maxTurns !== void 0 ? { maxTurns: options.maxTurns } : {},
4070
4226
  ...options.compaction ? { compaction: options.compaction } : {},
4071
4227
  ...options.driverRetry ? { driverRetry: options.driverRetry } : {},
4072
4228
  ...options.onDriverAttempt ? { onDriverAttempt: options.onDriverAttempt } : {},
4073
- ...options.repromptOnUnmet !== void 0 ? { repromptOnUnmet: options.repromptOnUnmet } : {},
4074
- ...options.onUnmetContract ? { onUnmetContract: options.onUnmetContract } : {},
4229
+ ...deliverable && options.continuation && isExternalSupervisor(canonicalProfile) ? {
4230
+ continuation: options.continuation,
4231
+ ...options.runDir === void 0 ? {} : {
4232
+ continuationDir: resolve(options.runDir, CONTINUATIONS_DIR),
4233
+ rootStreamPath: resolve(options.runDir, ROOT_STREAM_FILE)
4234
+ }
4235
+ } : {},
4075
4236
  ...options.runDir === void 0 || runControl === void 0 ? {} : {
4076
4237
  controlDir: resolve(options.runDir),
4077
4238
  abortRun: cancelDurableRun
@@ -4141,11 +4302,13 @@ function superviseInternal(profile, task, opts, testBrain) {
4141
4302
  }
4142
4303
  }
4143
4304
  recordRunCancellationOutcome(options.runDir, result, now);
4305
+ const rootHarnessTranscript = rootDriveHarness === void 0 ? void 0 : await persistHarnessTranscript(readHarnessTranscript(rootDriveHarness), blobs);
4144
4306
  const rootProviderModel = ctx.resume === true ? rootProviderModelEvidence([]) : rootProviderModels.length > 0 ? rootProviderModelEvidence(rootProviderModels) : rootDriveHarness === void 0 ? rootProviderModelEvidence([]) : rootProviderModelEvidenceFromExecution(runtimeOwnedDriveHarnessProviderEvidence(rootDriveHarness));
4145
4307
  return {
4146
4308
  ...result,
4147
4309
  rootProviderModel,
4148
4310
  ...rootStream === void 0 ? {} : { rootStream },
4311
+ ...rootHarnessTranscript === void 0 ? {} : { rootHarnessTranscript },
4149
4312
  ...rootContinuation === void 0 ? {} : { continuation: rootContinuation }
4150
4313
  };
4151
4314
  };
@@ -4195,4 +4358,4 @@ function rootProviderModelEvidenceFromExecution(evidence) {
4195
4358
  //#endregion
4196
4359
  export { gateOnDeliverable as C, serveCoordinationMcp as S, readRootStream as _, superviseWithTestBrain as a, composeReentryTask as b, resolveWorkerSpawnRetry as c, assertCoordinationBinding as d, coordinationProfileToolPrefix as f, ROOT_STREAM_FILE as g, supervisorAgentWithTestBrain as h, superviseRootProfile as i, retryPreSpawnRefusals as l, supervisorAgent as m, profileGuidanceComposer as n, workerFromBackend as o, resolveSupervisorProfile as p, supervise as r, isPreSpawnExecutorFailure as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, withWorkerSpawnRetry as u, readRootStreamReceipt as v, mapExecutorResult as w, createSupervisorSpanRecorder as x, UNPROVEN_CONTINUITY as y };
4197
4360
 
4198
- //# sourceMappingURL=supervise-DJ_1i9vj.js.map
4361
+ //# sourceMappingURL=supervise-Dej5aSDa.js.map