@tangle-network/agent-runtime 0.327.0 → 0.329.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/{activation-DfhOPF9_.js → activation-BfHpXIo0.js} +2 -2
  2. package/dist/{activation-DfhOPF9_.js.map → activation-BfHpXIo0.js.map} +1 -1
  3. package/dist/{activation-D4kme3Oh.d.ts → activation-CQo8-ir9.d.ts} +2 -2
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +2 -2
  6. package/dist/{coordination-driver-Cd0KpYoT.js → coordination-driver-DsxFmzhm.js} +369 -25
  7. package/dist/coordination-driver-DsxFmzhm.js.map +1 -0
  8. package/dist/{delegate-C6qiH8ti.js → delegate-C-E2pUey.js} +2 -2
  9. package/dist/{delegate-C6qiH8ti.js.map → delegate-C-E2pUey.js.map} +1 -1
  10. package/dist/durable.d.ts +1 -1
  11. package/dist/durable.js +3 -3
  12. package/dist/{graph-7DxUifPo.js → graph-BamfOWzd.js} +13 -6
  13. package/dist/graph-BamfOWzd.js.map +1 -0
  14. package/dist/{improvement-cycle-sd7Y_buy.js → improvement-cycle-BWcUsIgg.js} +3 -3
  15. package/dist/{improvement-cycle-sd7Y_buy.js.map → improvement-cycle-BWcUsIgg.js.map} +1 -1
  16. package/dist/index.d.ts +4 -4
  17. package/dist/index.js +7 -7
  18. package/dist/intelligence.d.ts +2 -2
  19. package/dist/intelligence.js +3 -3
  20. package/dist/kernel.d.ts +2 -2
  21. package/dist/kernel.js +8 -8
  22. package/dist/{loop-runner-bin-DLiEuQAt.js → loop-runner-bin-CVZ5S19W.js} +3 -3
  23. package/dist/{loop-runner-bin-DLiEuQAt.js.map → loop-runner-bin-CVZ5S19W.js.map} +1 -1
  24. package/dist/{loop-runner-bin-DKkrGTge.d.ts → loop-runner-bin-U00bzVay.d.ts} +2 -2
  25. package/dist/loop-runner-bin.d.ts +1 -1
  26. package/dist/loop-runner-bin.js +1 -1
  27. package/dist/mcp/bin.js +3 -3
  28. package/dist/mcp/index.d.ts +2 -2
  29. package/dist/mcp/index.js +4 -4
  30. package/dist/{openai-tools-BTq7nLhg.d.ts → openai-tools-DnA8exP6.d.ts} +2 -2
  31. package/dist/profiles.d.ts +1 -1
  32. package/dist/{provision-supervisor-BCpumw87.js → provision-supervisor-mpEy_KWu.js} +3 -3
  33. package/dist/{provision-supervisor-BCpumw87.js.map → provision-supervisor-mpEy_KWu.js.map} +1 -1
  34. package/dist/{runtime-CfBB9gRz.js → runtime-VteVmwAw.js} +8 -8
  35. package/dist/{runtime-CfBB9gRz.js.map → runtime-VteVmwAw.js.map} +1 -1
  36. package/dist/{search-executor-BgMpZuhl.js → search-executor-eTeXrpkP.js} +2 -2
  37. package/dist/{search-executor-BgMpZuhl.js.map → search-executor-eTeXrpkP.js.map} +1 -1
  38. package/dist/{server-vyi-BhWC.js → server-BGQv06nN.js} +3 -3
  39. package/dist/{server-vyi-BhWC.js.map → server-BGQv06nN.js.map} +1 -1
  40. package/dist/{supervise-Bso1hco7.js → supervise-BIIbQhg7.js} +232 -32
  41. package/dist/supervise-BIIbQhg7.js.map +1 -0
  42. package/dist/{supervisor-hIpqcCJr.js → supervisor-U76PdEPD.js} +31 -6
  43. package/dist/supervisor-U76PdEPD.js.map +1 -0
  44. package/dist/testing.d.ts +1 -1
  45. package/dist/testing.js +12 -12
  46. package/dist/tui/index.d.ts +1 -1
  47. package/dist/tui/index.js +1 -1
  48. package/dist/{types-loG2Pvmj.d.ts → types-B6IAL5Q7.d.ts} +201 -8
  49. package/package.json +1 -1
  50. package/skills/agent-graphs/references/authoring.md +12 -1
  51. package/dist/coordination-driver-Cd0KpYoT.js.map +0 -1
  52. package/dist/graph-7DxUifPo.js.map +0 -1
  53. package/dist/supervise-Bso1hco7.js.map +0 -1
  54. package/dist/supervisor-hIpqcCJr.js.map +0 -1
@@ -1,11 +1,11 @@
1
1
  import { n as assertNoSymlinkDescendant } from "./durable-file-B_eJr6Mb.js";
2
- import { $n as readHarnessTranscript, $r as renderUnsupported, A as scopeOwnerExecutorNodeContext, At as bindReusableExecutorExecutionId, B as consumeScopeRetainedOwnerResult, Bt as createRouterTranscript, C as deriveNodeExecutionIdentity, Ct as checkVerdictOf, D as recordScopeOwnerMaterialization, E as recordScopeOwnerDriverAttempt, F as seatExecutionProfile, Fn as bridgeRuntimeAttachmentsKey, G as scopeRetainedOwnerContext, Gr as defineProfileMaterializationContract, H as prepareScopeRetainedOwnerSeatSwitch, Hr as assertProfileMaterialization, Ht as WORKER_TRACE_PROPAGATION, I as abandonScopeRetainedOwnerInvocation, In as bridgeStopSignalKey, It as snapshotExecutorConfig, J as scopeRetainedOwnerResourceReader, Jn as linkAbort, Jr as promptControlProfileMaterialization, K as scopeRetainedOwnerJournalRoot, Kn as RunCancellationReason, Kr as fullProfileMaterialization, L as beginScopeRetainedOwnerDrive, M as SeatChain, Mi as registerRetainedExecutorPreparation, N as SeatChainExhaustedError, Ni as retainedExecutorSeamKey, O as recordScopeOwnerPause, P as authoredSeatStages, Pt as createExecutor, Qn as persistHarnessTranscript, R as bindScopeRetainedOwnerEnvironmentId, Sa as spendFromUsageTotals, Sr as toOtelAttributes, St as bestComposite, T as meterRuntimeOwnedProviderAttempt, Tn as routerBrain, U as prepareScopeRetainedOwnerTask, V as noteScopeRetainedOwnerCoordination, W as reconcileScopeRetainedOwnerEnvironment, Wr as controlProfileMaterialization, X as scopeRetainedOwnerResult, Y as scopeRetainedOwnerRestorePoint, Yn as runAbortable, Yr as promptModelProfileMaterialization, Yt as createActivityLog, Z as scopeRetainedOwnerTurnEnded, Zt as createInbox, _ as isDriverSpec, _a as assertValidBudget, _i as runtimeOwnedExecutorExecutionBinding, _t as CONTINUATIONS_DIR, at as runtimeGraphMetadataKey, b as assertRecursiveReservationPolicy, ba as newUsageTotals, bi as runtimeOwnedPendingExecutorMaterialization, bt as admitContinuationPolicy, c as runTree, ca as parseWorkerToolTraceArtifact, cn as bridgeAdmissionRefusal, en as PEER_MAIL_WIRE_KEY, f as runDriverWithRetry, fa as detachedSnapshot, g as driverExecutorFactory, gi as runtimeOwnedDriveHarnessProviderEvidence, gr as createOtelExporter, h as driverChild, hi as recordRuntimeOwnedDriveHarnessProviderEvidence, ht as gateOnDeliverable, i as bestDelivered, ii as worktreeCliProfileMaterialization, it as providerVisibleProfile, jn as resolveAgentEnvironmentProvider, jt as captureReusableExecutorConfig, k as restoreScopeOwnerAcceptedExecution, ln as bridgeModelRouteRefusal, ma as errMessage, mi as providerAttemptEvidence, n as createRootHandle, ni as unsupportedProfileDimensions, nt as coordinationMcpAlias, oi as attestRuntimeOwnedScopeOwner, on as isLiveNodeStatus, p as summarizeDriverAttempts, pa as executorFailure, q as scopeRetainedOwnerPriorSpend, qr as profileMaterializationAxes$1, r as createSupervisor, rn as isPeerMailEnvelope, rt as coordinationProfileToolPrefix, s as runFinalizer, si as authoredAgentIdentity, ti as sandboxProfileMaterialization, u as HarnessTurnFailedError, ua as contentAddress, ui as inheritRuntimeOwnedExecutorAttestation, vi as runtimeOwnedExecutorMaterialization, vr as generateSpanId, w as meterRuntimeOwnedAccounting, wt as createContinuationKeeper, x as beginScopeOwnerAttempt, xi as runtimeOwnedScopeOwnerRuntime, ya as meterUsageEvent, yi as runtimeOwnedExecutorProviderEvidence, yt as CheckUnavailableError, z as bindScopeRetainedOwnerProvider } from "./supervisor-hIpqcCJr.js";
2
+ import { $n as persistHarnessTranscript, A as restoreScopeOwnerAcceptedExecution, B as bindScopeRetainedOwnerProvider, C as deriveNodeExecutionIdentity, Ca as spendFromUsageTotals, Cr as toOtelAttributes, Ct as bestComposite, D as recordScopeOwnerDriverAttempt, E as noteScopeOwnerPlannedExecution, En as routerBrain, F as authoredSeatStages, Ft as createExecutor, G as reconcileScopeRetainedOwnerEnvironment, Gr as controlProfileMaterialization, H as noteScopeRetainedOwnerCoordination, I as seatExecutionProfile, In as bridgeRuntimeAttachmentsKey, J as scopeRetainedOwnerPriorSpend, Jr as profileMaterializationAxes$1, K as scopeRetainedOwnerContext, Kr as defineProfileMaterializationContract, L as abandonScopeRetainedOwnerInvocation, Ln as bridgeStopSignalKey, Lt as snapshotExecutorConfig, Mn as resolveAgentEnvironmentProvider, Mt as captureReusableExecutorConfig, N as SeatChain, Ni as registerRetainedExecutorPreparation, O as recordScopeOwnerMaterialization, P as SeatChainExhaustedError, Pi as retainedExecutorSeamKey, Q as scopeRetainedOwnerTurnEnded, Qt as createInbox, R as beginScopeRetainedOwnerDrive, Si as runtimeOwnedScopeOwnerRuntime, T as meterRuntimeOwnedProviderAttempt, Tt as createContinuationKeeper, U as prepareScopeRetainedOwnerSeatSwitch, Ur as assertProfileMaterialization, Ut as WORKER_TRACE_PROPAGATION, V as consumeScopeRetainedOwnerResult, Vt as createRouterTranscript, W as prepareScopeRetainedOwnerTask, X as scopeRetainedOwnerRestorePoint, Xn as runAbortable, Xr as promptModelProfileMaterialization, Xt as createActivityLog, Y as scopeRetainedOwnerResourceReader, Yn as linkAbort, Yr as promptControlProfileMaterialization, Z as scopeRetainedOwnerResult, _ as isDriverSpec, _i as runtimeOwnedDriveHarnessProviderEvidence, _r as createOtelExporter, ai as worktreeCliProfileMaterialization, at as providerVisibleProfile, b as assertRecursiveReservationPolicy, ba as meterUsageEvent, bi as runtimeOwnedExecutorProviderEvidence, bt as CheckUnavailableError, c as runTree, ci as authoredAgentIdentity, da as contentAddress, di as inheritRuntimeOwnedExecutorAttestation, ei as renderUnsupported, er as readHarnessTranscript, f as runDriverWithRetry, g as driverExecutorFactory, gi as recordRuntimeOwnedDriveHarnessProviderEvidence, gt as gateOnDeliverable, h as driverChild, ha as errMessage, hi as providerAttemptEvidence, i as bestDelivered, in as isPeerMailEnvelope, it as coordinationProfileToolPrefix, j as scopeOwnerExecutorNodeContext, jt as bindReusableExecutorExecutionId, k as recordScopeOwnerPause, la as parseWorkerToolTraceArtifact, ln as bridgeAdmissionRefusal, ma as executorFailure, n as createRootHandle, ni as sandboxProfileMaterialization, ot as runtimeGraphMetadataKey, p as summarizeDriverAttempts, pa as detachedSnapshot, q as scopeRetainedOwnerJournalRoot, qn as RunCancellationReason, qr as fullProfileMaterialization, r as createSupervisor, ri as unsupportedProfileDimensions, rt as coordinationMcpAlias, s as runFinalizer, si as attestRuntimeOwnedScopeOwner, sn as isLiveNodeStatus, tn as PEER_MAIL_WIRE_KEY, u as HarnessTurnFailedError, un as bridgeModelRouteRefusal, va as assertValidBudget, vi as runtimeOwnedExecutorExecutionBinding, vt as CONTINUATIONS_DIR, w as meterRuntimeOwnedAccounting, wt as checkVerdictOf, x as beginScopeOwnerAttempt, xa as newUsageTotals, xi as runtimeOwnedPendingExecutorMaterialization, xt as admitContinuationPolicy, yi as runtimeOwnedExecutorMaterialization, yr as generateSpanId, z as bindScopeRetainedOwnerEnvironmentId } from "./supervisor-U76PdEPD.js";
3
3
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
4
4
  import { $ as isAsyncIterable$1, Ot as teardownExecutor, U as addSpend, Y as errorMessage, at as sleep, dt as zeroSpend, gt as withBudgetResources, ht as resourceTelemetry, kt as teardownSurfaces, lt as unmeteredSpend, pt as addResourceSpend, ut as withTimeout, xt as DEFAULT_SUCCESSFUL_SHUTDOWN_MS } from "./sandbox-profile-compat-CVgQWb7T.js";
5
5
  import { a as readCommittedJsonLines, n as isNoEntError, r as prepareJsonlAppend } from "./jsonl-file-DBv31uPi.js";
6
- import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-CyCUwHed.js";
6
+ import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, l as profileProviderModel, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-CyCUwHed.js";
7
7
  import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
8
- import { C as createFileRunContext, F as createCoordinationToolsForManager, N as coordinationVerbNames, O as applyRunCancellation, T as withRunContext, c as refreshedWake, g as progressStop, h as plateau, k as watchRunCancellation, l as resolveWakePolicy, n as createSteerAcknowledger, o as composeWakeInput, p as createProgressTracker, r as driverAgent, s as deadlineWarningAt, t as createCancelAcknowledger, w as createInMemoryRunContext } from "./coordination-driver-Cd0KpYoT.js";
8
+ import { C as createFileRunContext, F as createCoordinationToolsForManager, N as coordinationVerbNames, O as applyRunCancellation, T as withRunContext, c as refreshedWake, g as progressStop, h as plateau, k as watchRunCancellation, l as resolveWakePolicy, n as createSteerAcknowledger, o as composeWakeInput, p as createProgressTracker, r as driverAgent, s as deadlineWarningAt, t as createCancelAcknowledger, w as createInMemoryRunContext } from "./coordination-driver-DsxFmzhm.js";
9
9
  import { r as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-Dqer2M4_.js";
10
10
  import { c as loadGraph, i as graphRegistry } from "./graph-registry-DAI6KNXB.js";
11
11
  import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-Cu8H7aeh.js";
@@ -650,6 +650,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
650
650
  ...opts.onStop ? { onStop: opts.onStop } : {},
651
651
  ...opts.analysts ? { analysts: opts.analysts } : {},
652
652
  ...opts.analyzeOnSettle ? { analyzeOnSettle: opts.analyzeOnSettle } : {},
653
+ ...opts.mapOnSettle ? { mapOnSettle: opts.mapOnSettle } : {},
653
654
  ...opts.sourceEvidenceRefs ? { sourceEvidenceRefs: opts.sourceEvidenceRefs } : {},
654
655
  ...opts.peerAudit ? { peerAudit: opts.peerAudit } : {},
655
656
  ...opts.watchWorkers ? { watchWorkers: opts.watchWorkers } : {},
@@ -1059,14 +1060,19 @@ function kernelPromptRegistry() {
1059
1060
  * run as a subtask is one subtree of the caller's run, spending from the caller's conserved pool.
1060
1061
  *
1061
1062
  * Nothing here schedules anything. It produces the values a manager's construction takes
1062
- * (`authorizeSpawn`, `resolveSpawnProfile`, `analyzeOnSettle`, `continuityByProfile`) and
1063
- * observes what the kernel reports back (spawn bindings, steers, findings).
1063
+ * (`authorizeSpawn`, `resolveSpawnProfile`, `analyzeOnSettle`, `mapOnSettle`,
1064
+ * `continuityByProfile`) and observes what the kernel reports back (spawn bindings, steers,
1065
+ * findings, map steps).
1064
1066
  */
1065
1067
  /** Default per-edge traversal cap — the cyclic-graph backstop when an edge names none. */
1066
1068
  const defaultEdgeTraversalCap = 32;
1069
+ const mapItemFailurePolicies = ["all-or-refuse", "settled-subset"];
1067
1070
  function edgeId(edge) {
1068
- return edge.kind === "delegates" ? `delegates:${edge.from}->${edge.to}` : `analyzes:${edge.analyst}:${edge.over.join("+")}->${edge.to}`;
1071
+ if (edge.kind === "delegates") return `delegates:${edge.from}->${edge.to}`;
1072
+ if (edge.kind === "maps") return `maps:${edge.from}->${edge.to ?? "graph"}->${edge.join}`;
1073
+ return `analyzes:${edge.analyst}:${edge.over.join("+")}->${edge.to}`;
1069
1074
  }
1075
+ const isPositiveInteger = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
1070
1076
  /** Validate a topology and resolve every directive BEFORE any compute is spent — an invalid
1071
1077
  * topology or an unknown directive is a configuration fault, never a mid-run surprise. */
1072
1078
  function validateGraphTopology(nodes, edges, registry, analysts) {
@@ -1087,8 +1093,13 @@ function validateGraphTopology(nodes, edges, registry, analysts) {
1087
1093
  if (!node) throw new ValidationError(`runGraph: ${where} references unknown node '${id}'`);
1088
1094
  return node;
1089
1095
  };
1096
+ for (const edge of edges) {
1097
+ const kind = edge.kind;
1098
+ if (kind !== "delegates" && kind !== "analyzes" && kind !== "maps") throw new ValidationError(`runGraph: edge kind ${JSON.stringify(kind)} is not 'delegates', 'analyzes' or 'maps'`);
1099
+ }
1090
1100
  const delegates = edges.filter((edge) => edge.kind === "delegates");
1091
1101
  const analyzes = edges.filter((edge) => edge.kind === "analyzes");
1102
+ const maps = edges.filter((edge) => edge.kind === "maps");
1092
1103
  if (delegates.length === 0) throw new ValidationError("runGraph: at least one delegates edge is required (who spawns whom)");
1093
1104
  for (const edge of edges) registry.resolve(edge.directive);
1094
1105
  for (const edge of delegates) {
@@ -1133,31 +1144,101 @@ function validateGraphTopology(nodes, edges, registry, analysts) {
1133
1144
  delegatesByWorker.set(edge.to, edge);
1134
1145
  workers.set(edge.to, requireNode(edge.to, edgeId(edge)));
1135
1146
  }
1136
- for (const node of nodes) if (node.id !== root.id && !workers.has(node.id) && !analystNodes.has(node.id)) throw new ValidationError(`runGraph: node '${node.id}' has no delegates edge to it — an unreachable node never runs`);
1147
+ const { mapNodes, mapItemNames } = validateMaps(maps, {
1148
+ byId,
1149
+ root,
1150
+ workers,
1151
+ analystNodes,
1152
+ registry,
1153
+ analysts
1154
+ });
1155
+ for (const node of nodes) if (node.id !== root.id && !workers.has(node.id) && !analystNodes.has(node.id) && !mapNodes.has(node.id)) throw new ValidationError(`runGraph: node '${node.id}' has no delegates edge to it — an unreachable node never runs`);
1137
1156
  return {
1138
1157
  root,
1139
1158
  workers,
1140
1159
  delegatesByWorker,
1141
1160
  analyzes,
1142
- analystNodes
1161
+ analystNodes,
1162
+ maps,
1163
+ mapNodes,
1164
+ mapItemNames
1165
+ };
1166
+ }
1167
+ /**
1168
+ * Refuse a maps edge the runtime could not run as authored. A map's item and join nodes are the
1169
+ * runtime's to spawn, so neither may be the root, a delegates target, an analyst, or a node of
1170
+ * another map: a second way to reach the node would make its ledger rows and its pinning ambiguous.
1171
+ * The source must be a node that settles as a worker: a delegates target, or another map's join.
1172
+ */
1173
+ function validateMaps(maps, graph) {
1174
+ const mapNodes = /* @__PURE__ */ new Map();
1175
+ const mapItemNames = /* @__PURE__ */ new Map();
1176
+ const joins = /* @__PURE__ */ new Set();
1177
+ for (const edge of maps) {
1178
+ const id = edgeId(edge);
1179
+ const refuse = (why) => {
1180
+ throw new ValidationError(`runGraph: ${id} ${why}`);
1181
+ };
1182
+ if (edge.continuity !== void 0) refuse("carries continuity — every map item is a fresh session over its own element");
1183
+ if (typeof edge.pointer !== "string" || edge.pointer !== "" && !edge.pointer.startsWith("/")) refuse(`has pointer ${JSON.stringify(edge.pointer)} — a JSON pointer is '' or starts with '/'`);
1184
+ if (!isPositiveInteger(edge.maxItems)) refuse("needs maxItems as a positive integer");
1185
+ if (!isPositiveInteger(edge.concurrency)) refuse(`has concurrency ${JSON.stringify(edge.concurrency)} — it needs a positive integer; concurrency throttles the items, so a value below 1 could never start one`);
1186
+ if (!mapItemFailurePolicies.includes(edge.onItemFailure)) refuse(`needs onItemFailure 'all-or-refuse' or 'settled-subset'`);
1187
+ if (edge.itemBudget !== void 0 && (typeof edge.itemBudget !== "object" || edge.itemBudget === null || Array.isArray(edge.itemBudget))) refuse("has an itemBudget that is not a budget object");
1188
+ if (edge.to === void 0 === (edge.graph === void 0)) refuse("needs exactly one of to (an item node) or graph (a graph run per item)");
1189
+ if (typeof edge.join !== "string") refuse("needs a join node");
1190
+ if (edge.to !== void 0 && edge.to === edge.join) refuse("joins into its own item node");
1191
+ for (const nodeId of edge.to === void 0 ? [edge.join] : [edge.to, edge.join]) {
1192
+ const node = graph.byId.get(nodeId);
1193
+ if (!node) refuse(`references unknown node '${nodeId}'`);
1194
+ if (nodeId === graph.root.id || graph.workers.has(nodeId) || graph.analystNodes.has(nodeId) || mapNodes.has(nodeId)) refuse(`names node '${nodeId}', which the graph already reaches another way — a map's item and join nodes are spawned only by their maps edge, never as the root, a delegates target, an analyst, or a node of another map`);
1195
+ mapNodes.set(nodeId, node);
1196
+ }
1197
+ joins.add(edge.join);
1198
+ if (edge.to !== void 0) mapItemNames.set(id, edge.to);
1199
+ else try {
1200
+ const prepared = prepareGraphSubtask(parseGraphSubtaskTopology(edge.graph), {
1201
+ registry: graph.registry,
1202
+ ...graph.analysts ? { analysts: graph.analysts } : {}
1203
+ });
1204
+ mapItemNames.set(id, prepared.root);
1205
+ } catch (error) {
1206
+ refuse(`has a graph item that cannot run: ${errMessage(error)}`);
1207
+ }
1208
+ }
1209
+ for (const edge of maps) {
1210
+ if (!graph.byId.has(edge.from)) throw new ValidationError(`runGraph: ${edgeId(edge)} references unknown node '${edge.from}'`);
1211
+ if (!graph.workers.has(edge.from) && !joins.has(edge.from)) throw new ValidationError(`runGraph: ${edgeId(edge)} maps over '${edge.from}', which never settles as a worker — a map's source is a delegates target or another map's join`);
1212
+ if (edge.from === edge.join) throw new ValidationError(`runGraph: ${edgeId(edge)} maps over its own join`);
1213
+ }
1214
+ return {
1215
+ mapNodes,
1216
+ mapItemNames
1143
1217
  };
1144
1218
  }
1145
1219
  /** The root node's canonical profile with the graph brief appended: which nodes the driver may
1146
1220
  * spawn, by exact name, each with its delegation cap and continuity. */
1147
1221
  function graphRootProfile(validated, registry) {
1148
- const { root, workers, delegatesByWorker, analyzes, analystNodes } = validated;
1222
+ const { root, workers, delegatesByWorker, analyzes, analystNodes, maps, mapItemNames } = validated;
1149
1223
  const driverAnalyzesBriefs = analyzes.filter((edge) => edge.to === root.id).map((edge) => analystNodes.has(edge.analyst) ? `Findings from analyst '${edge.analyst}' (a tool-equipped analyst agent node, over: ${edge.over.join(", ")}) will arrive as finding events.` : `Findings from analyst '${edge.analyst}' (over: ${edge.over.join(", ")}) will arrive as finding events.\n${registry.resolve(edge.directive).text}`);
1224
+ const workerLines = [...workers.values()].map((node) => {
1225
+ const edge = delegatesByWorker.get(node.id);
1226
+ const cap = edge.maxTraversals ?? 32;
1227
+ const description = typeof node.profile.description === "string" && node.profile.description.length > 0 ? ` — ${node.profile.description}` : "";
1228
+ const continuityNote = edge.continuity === "resume" ? "; continuity: resume — each spawn after the first re-attaches to this node's latest settled session (spawn again to continue it; steer while it is live)" : "";
1229
+ return `- '${node.id}'${description} (delegation cap: ${cap} traversals${continuityNote})`;
1230
+ });
1231
+ const mapLines = maps.map((edge) => `- when '${edge.from}' settles, the runtime runs '${mapItemNames.get(edgeId(edge))}'${edge.to === void 0 ? " (a graph)" : ""} once per element of ${edge.pointer === "" ? "its result" : `${JSON.stringify(edge.pointer)} in its result`} (at most ${edge.maxItems} elements, ${edge.concurrency} at a time), then '${edge.join}' with the ordered results; '${edge.join}' settles to you like a worker, and a refused map arrives as a map event`);
1150
1232
  const graphBrief = [
1151
1233
  "AGENT GRAPH: you are the driver node of a fixed topology. You may spawn ONLY these worker",
1152
1234
  "nodes, by EXACT name (spawn_worker with profile: { name: '<node id>' }; the node's full",
1153
1235
  "profile is pinned by the graph — any other profile fields you author are ignored):",
1154
- ...[...workers.values()].map((node) => {
1155
- const edge = delegatesByWorker.get(node.id);
1156
- const cap = edge.maxTraversals ?? 32;
1157
- const description = typeof node.profile.description === "string" && node.profile.description.length > 0 ? ` — ${node.profile.description}` : "";
1158
- const continuityNote = edge.continuity === "resume" ? "; continuity: resume — each spawn after the first re-attaches to this node's latest settled session (spawn again to continue it; steer while it is live)" : "";
1159
- return `- '${node.id}'${description} (delegation cap: ${cap} traversals${continuityNote})`;
1160
- }),
1236
+ ...workerLines,
1237
+ ...mapLines.length > 0 ? [
1238
+ "",
1239
+ "MAPS (the runtime spawns these nodes; never spawn them yourself):",
1240
+ ...mapLines
1241
+ ] : [],
1161
1242
  ...driverAnalyzesBriefs.length > 0 ? ["", ...driverAnalyzesBriefs] : []
1162
1243
  ].join("\n");
1163
1244
  return {
@@ -1177,14 +1258,37 @@ function stringifyPayload(payload) {
1177
1258
  return String(payload);
1178
1259
  }
1179
1260
  }
1261
+ /** Each graph's pinning, mapped to the product authority it wraps. */
1262
+ const productAuthorities = /* @__PURE__ */ new WeakMap();
1263
+ /**
1264
+ * The product authority behind a spawn authority. A graph started inside a run composes its own
1265
+ * pinning with the run's product authority. When that run is itself a graph (`runGraph`), the run's
1266
+ * `authorizeSpawn` is the outer graph's pinning, which would refuse every node of the inner graph,
1267
+ * so the inner graph composes with the authority the outer pinning wraps instead.
1268
+ */
1269
+ function productSpawnAuthority(authorize) {
1270
+ return authorize !== void 0 && productAuthorities.has(authorize) ? productAuthorities.get(authorize) : authorize;
1271
+ }
1272
+ /** A node profile with an edge directive appended to its standing instructions. */
1273
+ function withDirective(profile, directiveText) {
1274
+ if (directiveText.length === 0) return profile;
1275
+ return {
1276
+ ...profile,
1277
+ prompt: {
1278
+ ...profile.prompt ?? {},
1279
+ instructions: [...profile.prompt?.instructions ?? [], directiveText]
1280
+ }
1281
+ };
1282
+ }
1180
1283
  /**
1181
1284
  * Build the graph layer for one validated graph. Each delegates directive is appended to the
1182
1285
  * worker profile's `prompt.instructions` per traversal, each analyzes edge becomes an
1183
1286
  * analyst-on-settle route with a real DESTINATION, and every traversal is ledgered and journaled.
1184
1287
  */
1185
1288
  function createGraphOverlay(validated, opts) {
1186
- const { root, workers, delegatesByWorker, analyzes, analystNodes } = validated;
1289
+ const { root, workers, delegatesByWorker, analyzes, analystNodes, maps, mapNodes, mapItemNames } = validated;
1187
1290
  const { registry, journal, runId, now } = opts;
1291
+ const mapsById = new Map(maps.map((edge) => [edgeId(edge), edge]));
1188
1292
  const ledger = [];
1189
1293
  const journaled = /* @__PURE__ */ new Set();
1190
1294
  const traversalCounts = /* @__PURE__ */ new Map();
@@ -1215,6 +1319,7 @@ function createGraphOverlay(validated, opts) {
1215
1319
  continuity: entry.continuity,
1216
1320
  bytes: entry.bytes,
1217
1321
  ...entry.reason !== void 0 ? { reason: entry.reason } : {},
1322
+ ...entry.map !== void 0 ? { map: entry.map } : {},
1218
1323
  seq: ledgerSeq++,
1219
1324
  at: new Date(now()).toISOString()
1220
1325
  });
@@ -1256,6 +1361,7 @@ function createGraphOverlay(validated, opts) {
1256
1361
  if (!analystNode || requested !== analystNode.id) throw new ValidationError(`runGraph: analyst run for ${JSON.stringify(input.analyst)} does not name an analyst node of this graph (analyst nodes: ${[...analystNodes.keys()].join(", ") || "none"})`);
1257
1362
  return analystNode.profile;
1258
1363
  }
1364
+ if (input.map !== void 0) return pinMapSpawn(input, requested);
1259
1365
  if (input.profile.metadata?.["agentRuntimeGraph"] !== void 0) throw new ValidationError("runGraph: a node of a graph cannot start another graph — run_graph inside a graph is refused; add the work as nodes of this graph instead");
1260
1366
  const node = requested !== void 0 ? workers.get(requested) : void 0;
1261
1367
  if (!node) throw new ValidationError(`runGraph: spawn_worker named profile ${JSON.stringify(requested)} which is not a worker node of this graph (nodes: ${[...workers.keys()].join(", ")}). Spawn by node id: profile.name selects the node; the node profile itself is pinned by the graph.`);
@@ -1298,18 +1404,31 @@ function createGraphOverlay(validated, opts) {
1298
1404
  const stale = pendingByAssignment.get(key);
1299
1405
  if (stale !== void 0) settleUnbound(stale);
1300
1406
  pendingByAssignment.set(key, row);
1301
- return directiveText.length === 0 ? node.profile : {
1302
- ...node.profile,
1303
- prompt: {
1304
- ...node.profile.prompt ?? {},
1305
- instructions: [...node.profile.prompt?.instructions ?? [], directiveText]
1306
- }
1407
+ return withDirective(node.profile, directiveText);
1408
+ };
1409
+ const pinMapSpawn = (input, requested) => {
1410
+ const marker = input.map;
1411
+ const edge = mapsById.get(marker.edge);
1412
+ const refuse = (why) => {
1413
+ throw new ValidationError(`runGraph: map spawn for ${JSON.stringify(marker.edge)} ${why}`);
1307
1414
  };
1415
+ if (edge === void 0) return refuse("names no maps edge of this graph");
1416
+ if (marker.role === "join") {
1417
+ if (requested !== edge.join) refuse(`names ${JSON.stringify(requested)}, not its join`);
1418
+ return mapNodes.get(edge.join).profile;
1419
+ }
1420
+ if (edge.to !== void 0) {
1421
+ if (requested !== edge.to) refuse(`names ${JSON.stringify(requested)}, not its item node`);
1422
+ return withDirective(mapNodes.get(edge.to).profile, registry.resolve(edge.directive).text);
1423
+ }
1424
+ const carried = graphSubtaskOf(input.profile);
1425
+ if (carried === void 0 || canonicalCandidateDigest(carried) !== canonicalCandidateDigest(parseGraphSubtaskTopology(edge.graph))) refuse("carries a graph other than its maps edge's");
1426
+ return input.profile;
1308
1427
  };
1309
1428
  const composeGuidance = (profile) => opts.guidance ? opts.guidance(profile) : profile;
1310
1429
  const resolveSpawnProfile = (authored) => {
1311
1430
  const requested = typeof authored.name === "string" ? authored.name : void 0;
1312
- const node = (requested !== void 0 ? workers.get(requested) : void 0) ?? (requested !== void 0 ? analystNodes.get(requested) : void 0);
1431
+ const node = requested === void 0 ? void 0 : workers.get(requested) ?? analystNodes.get(requested) ?? mapNodes.get(requested);
1313
1432
  return node ? composeGuidance(node.profile) : authored;
1314
1433
  };
1315
1434
  const authorizeSpawn = (input) => {
@@ -1320,6 +1439,7 @@ function createGraphOverlay(validated, opts) {
1320
1439
  profile: pinned
1321
1440
  });
1322
1441
  };
1442
+ productAuthorities.set(authorizeSpawn, opts.authorizeSpawn);
1323
1443
  const routes = analyzes.map((edge) => {
1324
1444
  const analystNode = analystNodes.get(edge.analyst);
1325
1445
  if (analystNode) return {
@@ -1339,6 +1459,17 @@ function createGraphOverlay(validated, opts) {
1339
1459
  directive: registry.resolve(edge.directive).text
1340
1460
  };
1341
1461
  });
1462
+ const mapRoutes = maps.map((edge) => ({
1463
+ edge: edgeId(edge),
1464
+ from: edge.from,
1465
+ pointer: edge.pointer,
1466
+ item: edge.to !== void 0 ? { profile: mapNodes.get(edge.to).profile } : { graph: edge.graph },
1467
+ join: mapNodes.get(edge.join).profile,
1468
+ maxItems: edge.maxItems,
1469
+ concurrency: edge.concurrency,
1470
+ onItemFailure: edge.onItemFailure,
1471
+ ...edge.itemBudget !== void 0 ? { itemBudget: edge.itemBudget } : {}
1472
+ }));
1342
1473
  const continuityByProfile = {};
1343
1474
  for (const [nodeId, edge] of delegatesByWorker) if (edge.continuity !== void 0) continuityByProfile[nodeId] = edge.continuity;
1344
1475
  const strippedByDigest = /* @__PURE__ */ new Map();
@@ -1374,6 +1505,31 @@ function createGraphOverlay(validated, opts) {
1374
1505
  }, true);
1375
1506
  };
1376
1507
  const onCoordinationEvent = (event) => {
1508
+ if (event.type === "map") {
1509
+ const step = event.map;
1510
+ const edge = mapsById.get(step.edge);
1511
+ if (!edge) return;
1512
+ const itemName = mapItemNames.get(step.edge);
1513
+ if (step.workerId !== void 0) nodeByWorkerId.set(step.workerId, step.phase === "join" ? edge.join : itemName);
1514
+ const directiveBytes = step.phase === "item" && step.workerId !== void 0 && edge.to !== void 0 ? byteLength(registry.resolve(edge.directive).text) : 0;
1515
+ record({
1516
+ edge: step.edge,
1517
+ kind: "maps",
1518
+ from: step.phase === "join" ? itemName : edge.from,
1519
+ to: step.phase === "join" ? edge.join : itemName,
1520
+ directive: formatPromptHandle(edge.directive),
1521
+ outcome: step.outcome,
1522
+ continuity: "fresh",
1523
+ bytes: step.bytes + directiveBytes,
1524
+ ...step.reason !== void 0 ? { reason: step.reason } : {},
1525
+ workerId: step.phase === "expand" ? step.sourceWorker : step.workerId,
1526
+ map: {
1527
+ phase: step.phase,
1528
+ ...step.index !== void 0 ? { index: step.index } : {}
1529
+ }
1530
+ }, true);
1531
+ return;
1532
+ }
1377
1533
  if (event.type === "finding") {
1378
1534
  const edge = driverAnalyzesByAnalyst.get(event.finding.analyst);
1379
1535
  if (!edge) return;
@@ -1438,6 +1594,7 @@ function createGraphOverlay(validated, opts) {
1438
1594
  };
1439
1595
  return {
1440
1596
  routes,
1597
+ maps: mapRoutes,
1441
1598
  continuityByProfile,
1442
1599
  authorizeSpawn,
1443
1600
  resolveSpawnProfile,
@@ -1491,7 +1648,11 @@ function parseGraphSubtaskTopology(raw) {
1491
1648
  ...edge,
1492
1649
  directive
1493
1650
  };
1494
- throw new ValidationError(`run_graph: ${where}.kind must be 'delegates' or 'analyzes'`);
1651
+ if (edge.kind === "maps") return {
1652
+ ...edge,
1653
+ directive
1654
+ };
1655
+ throw new ValidationError(`run_graph: ${where}.kind must be 'delegates', 'analyzes' or 'maps'`);
1495
1656
  })
1496
1657
  };
1497
1658
  }
@@ -2587,6 +2748,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2587
2748
  ...deps.executeExtraTool ? { executeExtraTool: deps.executeExtraTool } : {},
2588
2749
  ...deps.analysts ? { analysts: deps.analysts } : {},
2589
2750
  ...deps.analyzeOnSettle ? { analyzeOnSettle: deps.analyzeOnSettle } : {},
2751
+ ...deps.mapOnSettle ? { mapOnSettle: deps.mapOnSettle } : {},
2590
2752
  ...deps.sourceEvidenceRefs ? { sourceEvidenceRefs: deps.sourceEvidenceRefs } : {},
2591
2753
  ...deps.peerAudit ? { peerAudit: deps.peerAudit } : {},
2592
2754
  ...deps.escalateQuestion ? { escalateQuestion: deps.escalateQuestion } : {},
@@ -2706,6 +2868,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2706
2868
  },
2707
2869
  ...deps.analysts ? { analysts: deps.analysts } : {},
2708
2870
  ...deps.analyzeOnSettle ? { analyzeOnSettle: deps.analyzeOnSettle } : {},
2871
+ ...deps.mapOnSettle ? { mapOnSettle: deps.mapOnSettle } : {},
2709
2872
  ...deps.sourceEvidenceRefs ? { sourceEvidenceRefs: deps.sourceEvidenceRefs } : {},
2710
2873
  ...deps.peerAudit ? { peerAudit: deps.peerAudit } : {},
2711
2874
  ...deps.escalateQuestion ? { escalateQuestion: deps.escalateQuestion } : {},
@@ -2990,6 +3153,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2990
3153
  try {
2991
3154
  const wake = await controls.awaitWake({
2992
3155
  attempt: nextAttempt,
3156
+ quietWhileProgressing: true,
2993
3157
  signal: AbortSignal.any([scope.signal, stopController.signal]),
2994
3158
  heartbeatMs: wakePolicy.heartbeatMs,
2995
3159
  ...deps.peerMailUrl ? { alsoWakeOn: peerInbox.pending() > 0 ? Promise.resolve() : peerInbox.nextDelivery() } : {},
@@ -4256,6 +4420,7 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
4256
4420
  if (pending !== void 0) {
4257
4421
  if (pending.runtime !== executor.runtime || pending.binding.attemptId !== scopeOwnerExecutorNodeContext(scope).attemptId) throw new ValidationError("driveHarnessFromBackend: pending executor did not bind the kernel-minted attempt");
4258
4422
  if (canonicalAgentProfileDigest(pending.declaration.effectiveProfile) !== canonicalAgentProfileDigest(providerDriverProfile)) throw new ValidationError("driveHarnessFromBackend: pending executor changed the provider-visible AgentProfile before execution");
4423
+ noteScopeOwnerPlannedExecution(scope, pending.declaration.execution);
4259
4424
  } else {
4260
4425
  await publishMaterialization(declaration, executionBinding);
4261
4426
  ownerMaterializationPublished = true;
@@ -4543,6 +4708,7 @@ const superviseOptionKeySet = /* @__PURE__ */ new Set([
4543
4708
  "allowedModels",
4544
4709
  "analysts",
4545
4710
  "analyzeOnSettle",
4711
+ "mapOnSettle",
4546
4712
  "authorizeMessage",
4547
4713
  "authorizeSpawn",
4548
4714
  "backend",
@@ -5311,6 +5477,7 @@ function superviseInternal(profile, task, opts, testBrain) {
5311
5477
  };
5312
5478
  }
5313
5479
  } } : void 0;
5480
+ const productAuthority = productSpawnAuthority(options.authorizeSpawn);
5314
5481
  const graphOverlayFor = (topology) => {
5315
5482
  const registry = kernelPromptRegistry();
5316
5483
  const overlay = createGraphOverlay(validateGraphTopology(topology.nodes, topology.edges, registry, analysts), {
@@ -5319,7 +5486,7 @@ function superviseInternal(profile, task, opts, testBrain) {
5319
5486
  runId,
5320
5487
  now,
5321
5488
  ...guidanceComposer ? { guidance: guidanceComposer } : {},
5322
- ...options.authorizeSpawn ? { authorizeSpawn: options.authorizeSpawn } : {},
5489
+ ...productAuthority ? { authorizeSpawn: productAuthority } : {},
5323
5490
  subtask: true
5324
5491
  });
5325
5492
  graphOverlays.add(overlay);
@@ -5347,6 +5514,7 @@ function superviseInternal(profile, task, opts, testBrain) {
5347
5514
  ...spawnContext.key !== void 0 ? { key: spawnContext.key } : {},
5348
5515
  depth,
5349
5516
  ...spawnContext.analyst !== void 0 ? { analyst: spawnContext.analyst } : {},
5517
+ ...spawnContext.map !== void 0 ? { map: spawnContext.map } : {},
5350
5518
  ...spawnContext.continuity !== void 0 ? { continuity: spawnContext.continuity } : {}
5351
5519
  });
5352
5520
  const authorize = graph?.authorizeSpawn ?? options.authorizeSpawn;
@@ -5356,6 +5524,7 @@ function superviseInternal(profile, task, opts, testBrain) {
5356
5524
  });
5357
5525
  if (typeof decision !== "object" || decision === null || Array.isArray(decision)) throw new ValidationError("supervise: authorizeSpawn must return an AuthorizedSpawn");
5358
5526
  const authorized = freezeDetachedProfile(applyTraceTools(decision.profile));
5527
+ const modelSubstitution = spawnModelSubstitution(input, authorized);
5359
5528
  const childExecution = canonicalExecution(authorized, spawnContext.task, decision.execution, `supervise spawn ${JSON.stringify(spawnContext.label)}`);
5360
5529
  const authorizedContext = Object.freeze({
5361
5530
  ...spawnContext,
@@ -5382,14 +5551,14 @@ function superviseInternal(profile, task, opts, testBrain) {
5382
5551
  const seatManagedLeaf = authoredSeatStages(authorized) !== void 0 && declaredRuntimeToolNames(authorized).length === 0 && isExternalSupervisor(authorized);
5383
5552
  if (!(declaredRuntimeToolNames(authorized).length > 0 || seatManagedLeaf)) {
5384
5553
  if (childDeliverable !== deliverable && !options.backend) throw new ValidationError("supervise: resolveDeliverable selected a per-spawn deliverable but there is no backend to derive that leaf from; makeLeafAgent owns its own completion check");
5385
- return (childDeliverable === deliverable ? makeLeaf : withRetry(workerFromBackend(options.backend, childDeliverable)))(authorized, Object.freeze({
5554
+ return withModelSubstitution((childDeliverable === deliverable ? makeLeaf : withRetry(workerFromBackend(options.backend, childDeliverable)))(authorized, Object.freeze({
5386
5555
  ...authorizedContext,
5387
5556
  assignmentId: workerAssignmentNamespace(runNamespace, parentOwnerId, spawnContext.assignmentId)
5388
- }));
5557
+ })), modelSubstitution);
5389
5558
  }
5390
5559
  const ownerId = childCoordinationOwner(parentOwnerId, childExecution.identity, spawnContext, depth);
5391
5560
  const subtask = graphSubtaskOf(authorized);
5392
- if (subtask !== void 0 && graph !== void 0) throw new ValidationError("supervise: a node of a graph cannot start another graph; add the work as nodes");
5561
+ if (subtask !== void 0 && graph !== void 0 && spawnContext.map === void 0) throw new ValidationError("supervise: a node of a graph cannot start another graph; add the work as nodes");
5393
5562
  const ownGraph = subtask === void 0 ? void 0 : graphOverlayFor(subtask);
5394
5563
  const subtreeGraph = ownGraph ?? graph;
5395
5564
  const ownSubmission = selectedDeliverable === void 0 && (subtreeGraph !== void 0 || deliverable !== void 0);
@@ -5413,6 +5582,7 @@ function superviseInternal(profile, task, opts, testBrain) {
5413
5582
  const runMessageAuthority = authorizeDownFor(authorized, depth + 1);
5414
5583
  const authorizeNestedMessage = subtreeGraph && runMessageAuthority ? subtreeGraph.observeMessages(runMessageAuthority) : runMessageAuthority;
5415
5584
  const nestedAnalyzeOnSettle = subtreeGraph ? subtreeGraph.routes.length > 0 ? subtreeGraph.routes : void 0 : options.analyzeOnSettle;
5585
+ const nestedMapOnSettle = subtreeGraph ? subtreeGraph.maps.length > 0 ? subtreeGraph.maps : void 0 : options.mapOnSettle;
5416
5586
  const nestedContinuity = subtreeGraph ? Object.keys(subtreeGraph.continuityByProfile).length > 0 ? subtreeGraph.continuityByProfile : void 0 : options.continuityByProfile;
5417
5587
  const runResolveSpawnProfile = options.resolveSpawnProfile;
5418
5588
  const nestedResolveSpawnProfile = subtreeGraph ? (authored) => {
@@ -5427,7 +5597,7 @@ function superviseInternal(profile, task, opts, testBrain) {
5427
5597
  let acceptedSubmission = false;
5428
5598
  let unassessedOutput = false;
5429
5599
  const peerAudit = depth === 1 ? peerAuditFor(spawnContext.parentNodeId) : void 0;
5430
- return driverChild(authorized, supervisorAgent(authorized, {
5600
+ return withModelSubstitution(driverChild(authorized, supervisorAgent(authorized, {
5431
5601
  ...spawnContext.peerMailUrl ? { peerMailUrl: spawnContext.peerMailUrl } : {},
5432
5602
  ...peerAudit ? { peerAudit } : {},
5433
5603
  blobs,
@@ -5464,6 +5634,7 @@ function superviseInternal(profile, task, opts, testBrain) {
5464
5634
  ...options.watchWorkers ? { watchWorkers: options.watchWorkers } : {},
5465
5635
  ...options.stallAfterMs !== void 0 ? { stallAfterMs: options.stallAfterMs } : {},
5466
5636
  ...options.wake !== void 0 ? { wake: options.wake } : {},
5637
+ ...nestedMapOnSettle ? { mapOnSettle: nestedMapOnSettle } : {},
5467
5638
  ...nestedContinuity ? { continuityByProfile: nestedContinuity } : {},
5468
5639
  ...spawnPreflight ? { preflightSpawn: spawnPreflight } : {},
5469
5640
  ...nestedResolveSpawnProfile ? { resolveSpawnProfile: nestedResolveSpawnProfile } : {},
@@ -5495,7 +5666,7 @@ function superviseInternal(profile, task, opts, testBrain) {
5495
5666
  },
5496
5667
  ...options.steerDir === void 0 ? {} : { steerDir: resolve(options.steerDir) },
5497
5668
  ...options.runDir === void 0 && options.steerDir === void 0 ? {} : { controlScope: "subtree" }
5498
- }), journal, childExecution.ref, () => acceptedSubmission, recoveryFactories.get(childFactory), () => unassessedOutput, seatManagedLeaf ? managerDeliverable : void 0, ownGraph ? (out) => graphSubtaskOutput(ownGraph, out) : void 0);
5669
+ }), journal, childExecution.ref, () => acceptedSubmission, recoveryFactories.get(childFactory), () => unassessedOutput, seatManagedLeaf ? managerDeliverable : void 0, ownGraph ? (out) => graphSubtaskOutput(ownGraph, out) : void 0), modelSubstitution);
5499
5670
  };
5500
5671
  if (options.makeLeafAgent === void 0 && options.backend?.backend === "provider" && !options.backend.steering) {
5501
5672
  const factory = registerRetainedExecutorPreparation(createExecutor(options.backend), ({ spawned, profile, task }) => {
@@ -5590,6 +5761,7 @@ function superviseInternal(profile, task, opts, testBrain) {
5590
5761
  ...options.watchWorkers ? { watchWorkers: options.watchWorkers } : {},
5591
5762
  ...options.stallAfterMs !== void 0 ? { stallAfterMs: options.stallAfterMs } : {},
5592
5763
  ...options.wake !== void 0 ? { wake: options.wake } : {},
5764
+ ...options.mapOnSettle ? { mapOnSettle: options.mapOnSettle } : {},
5593
5765
  ...options.continuityByProfile ? { continuityByProfile: options.continuityByProfile } : {},
5594
5766
  ...options.stopRule ? { stopRule: stopRuleOf(options.stopRule) } : {},
5595
5767
  ...options.onProgressStop ? { onProgressStop: options.onProgressStop } : {},
@@ -5753,7 +5925,35 @@ function rootProviderModelEvidence(observations) {
5753
5925
  function rootProviderModelEvidenceFromExecution(evidence) {
5754
5926
  return evidence ?? rootProviderModelEvidence([]);
5755
5927
  }
5928
+ /**
5929
+ * The route a spawn authorization replaced, when the parent authored part of it. Only a part the
5930
+ * parent named counts: authorization filling an omitted harness or provider is not a substitution.
5931
+ */
5932
+ function spawnModelSubstitution(authored, authorized) {
5933
+ const harness = agentHarness(authored.harness);
5934
+ const provider = authored.model?.provider?.trim() || void 0;
5935
+ const model = profileProviderModel(authored);
5936
+ if (model === void 0) return void 0;
5937
+ if (!(harness !== void 0 && harness !== agentHarness(authorized.harness) || provider !== void 0 && provider !== authorized.model?.provider?.trim() || model !== profileProviderModel(authorized))) return void 0;
5938
+ return Object.freeze({
5939
+ requested: profileBridgeWireModel(authored) ?? model,
5940
+ ran: profileBridgeWireModel(authorized) ?? "unspecified"
5941
+ });
5942
+ }
5943
+ /** The worker agent with the substitution on its spec, which Scope journals on `spawned`. */
5944
+ function withModelSubstitution(agent, substitution) {
5945
+ if (substitution === void 0) return agent;
5946
+ const spec = agent.executorSpec;
5947
+ if (spec === void 0) return agent;
5948
+ return {
5949
+ ...agent,
5950
+ executorSpec: {
5951
+ ...spec,
5952
+ modelSubstitution: substitution
5953
+ }
5954
+ };
5955
+ }
5756
5956
  //#endregion
5757
5957
  export { dumbContinuationPassPrompt as A, defaultEdgeTraversalCap as C, createPromptRegistry as D, analyzesFindingsReportPrompt as E, serveCoordinationMcp as F, kernelPromptRegistry as M, naiveContinuationPrompt as N, delegatesWorkerBriefPrompt as O, promptHandle as P, createGraphOverlay as S, validateGraphTopology as T, readRootStream as _, superviseRootProfile as a, composeReentryTask as b, isPreSpawnExecutorFailure as c, withWorkerSpawnRetry as d, assertCoordinationBinding as f, ROOT_STREAM_FILE as g, supervisorAgentWithTestBrain as h, superviseFleetCapabilities as i, formatPromptHandle as j, dumbContinuationFailPrompt as k, resolveWorkerSpawnRetry as l, supervisorAgent as m, profileGuidanceComposer as n, superviseWithTestBrain as o, resolveSupervisorProfile as p, supervise as r, workerFromBackend as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, retryPreSpawnRefusals as u, readRootStreamReceipt as v, graphRootProfile as w, createSupervisorSpanRecorder as x, UNPROVEN_CONTINUITY as y };
5758
5958
 
5759
- //# sourceMappingURL=supervise-Bso1hco7.js.map
5959
+ //# sourceMappingURL=supervise-BIIbQhg7.js.map