@tangle-network/agent-runtime 0.324.0 → 0.325.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.
- package/dist/{activation-CmWGOW1x.js → activation--9-iyGR8.js} +2 -2
- package/dist/{activation-CmWGOW1x.js.map → activation--9-iyGR8.js.map} +1 -1
- package/dist/{activation-CB2npL7F.d.ts → activation-Q3CJgiCu.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/{coordination-driver-CNEeqMoh.js → coordination-driver-DkkUVe9g.js} +242 -139
- package/dist/coordination-driver-DkkUVe9g.js.map +1 -0
- package/dist/{delegate-C6oOTFB6.js → delegate-BDsaIl2K.js} +2 -2
- package/dist/{delegate-C6oOTFB6.js.map → delegate-BDsaIl2K.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +60 -21
- package/dist/durable.js.map +1 -1
- package/dist/graph-Cuz6Ubzd.js +348 -0
- package/dist/graph-Cuz6Ubzd.js.map +1 -0
- package/dist/{improvement-cycle-U74a-YKi.js → improvement-cycle-B5Z8cHKx.js} +3 -3
- package/dist/{improvement-cycle-U74a-YKi.js.map → improvement-cycle-B5Z8cHKx.js.map} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -7
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +3 -3
- package/dist/kernel.d.ts +1 -1
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-BfcTX4-n.js → loop-runner-bin-C16VR9cI.js} +3 -3
- package/dist/{loop-runner-bin-BfcTX4-n.js.map → loop-runner-bin-C16VR9cI.js.map} +1 -1
- package/dist/{loop-runner-bin-CkchKbaB.d.ts → loop-runner-bin-Co7JKSwi.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +3 -3
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-BR3rRmmC.d.ts → openai-tools-CbgZrQJ_.d.ts} +2 -2
- package/dist/profiles.d.ts +1 -1
- package/dist/{provision-supervisor-DhPJqazM.js → provision-supervisor-4BoHpGFJ.js} +3 -3
- package/dist/{provision-supervisor-DhPJqazM.js.map → provision-supervisor-4BoHpGFJ.js.map} +1 -1
- package/dist/{runtime-B9-ZiYFa.js → runtime-B9X_U-aV.js} +9 -9
- package/dist/{runtime-B9-ZiYFa.js.map → runtime-B9X_U-aV.js.map} +1 -1
- package/dist/{search-executor-CtNb_lIB.js → search-executor-C-b4NaFl.js} +2 -2
- package/dist/{search-executor-CtNb_lIB.js.map → search-executor-C-b4NaFl.js.map} +1 -1
- package/dist/{server-BLYiq6fK.js → server-CcHaXgUT.js} +3 -3
- package/dist/{server-BLYiq6fK.js.map → server-CcHaXgUT.js.map} +1 -1
- package/dist/{supervise-FOCAUADN.js → supervise-BlaB4CeL.js} +734 -18
- package/dist/supervise-BlaB4CeL.js.map +1 -0
- package/dist/{supervisor-DnKhkhKc.js → supervisor-fq4JGynd.js} +26 -9
- package/dist/{supervisor-DnKhkhKc.js.map → supervisor-fq4JGynd.js.map} +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +12 -12
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-ytkoP4VV.d.ts → types-5r334mcg.d.ts} +577 -508
- package/package.json +1 -1
- package/skills/profile-authoring/SKILL.md +1 -1
- package/dist/coordination-driver-CNEeqMoh.js.map +0 -1
- package/dist/graph-BKmo7d42.js +0 -805
- package/dist/graph-BKmo7d42.js.map +0 -1
- package/dist/supervise-FOCAUADN.js.map +0 -1
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { $i as InMemorySpawnJournal, Qi as InMemoryResultBlobStore, Xi as FileResultBlobStore, Zi as FileSpawnJournal } from "./supervisor-fq4JGynd.js";
|
|
2
|
+
import { i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
|
|
3
|
+
import { v as harnessRunsAgent } from "./model-policy-CyCUwHed.js";
|
|
4
|
+
import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
|
|
5
|
+
import { T as withRunContext } from "./coordination-driver-DkkUVe9g.js";
|
|
6
|
+
import { M as kernelPromptRegistry, S as createGraphOverlay, T as validateGraphTopology, n as profileGuidanceComposer, o as superviseWithTestBrain, r as supervise, w as graphRootProfile } from "./supervise-BlaB4CeL.js";
|
|
7
|
+
import { canonicalCandidateDigest } from "@tangle-network/agent-interface";
|
|
8
|
+
import { resolve } from "node:path";
|
|
9
|
+
//#region src/runtime/supervise/graph.ts
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* `runGraph` — agent graphs: profiles as nodes, registry-backed prompt directives as edges.
|
|
13
|
+
*
|
|
14
|
+
* A topology is PLAIN DATA an agent can author in a few lines: nodes are canonical
|
|
15
|
+
* `AgentProfile`s (the ONLY way a node is described — no role-builder functions), edges are typed
|
|
16
|
+
* values carrying versioned {@link PromptHandle} directives, `deliverable` (termination) and
|
|
17
|
+
* `budget` (one conserved pool) are mandatory. Driver↔worker is the two-node cyclic instance;
|
|
18
|
+
* "agent 3 analyzes 1 and 2 and reports to 1" is ONE edge, not a framework.
|
|
19
|
+
*
|
|
20
|
+
* NOT A SECOND SCHEDULER. `runGraph` is an interpretation layer over what already runs:
|
|
21
|
+
* `supervise()` is the execution core — the same `supervisorAgent`/`driverAgent` machinery,
|
|
22
|
+
* backend-derived worker path (authorized, classified, recursive), conserved-pool budget, and
|
|
23
|
+
* deliverable-gated settlement every
|
|
24
|
+
* supervised run uses. (`runAgentRounds` is deliberately NOT the substrate here.) What the graph
|
|
25
|
+
* layer ADDS is exactly what a bespoke driver loop never
|
|
26
|
+
* had:
|
|
27
|
+
*
|
|
28
|
+
* 1. **Node pinning** — a spawn names a node (`profile.name` = node id) and the node's canonical
|
|
29
|
+
* profile is what runs; a driver cannot smuggle capabilities into a worker it did not define.
|
|
30
|
+
* 2. **Observable edges** — every delegates/analyzes traversal lands in an EDGE LEDGER
|
|
31
|
+
* (`delivered | stripped | empty | unpropagated`, with byte counts), in memory on
|
|
32
|
+
* the result AND as `edge` events in the run journal. The motivating incident: a filter
|
|
33
|
+
* silently replaced 1,700-char steering with 241 chars of boilerplate for three rounds and
|
|
34
|
+
* NO artifact said so — an unobservable edge cannot be trusted and its directive cannot be
|
|
35
|
+
* optimized.
|
|
36
|
+
* 3. **Directives as data** — edge text lives in the prompt registry (`<surface>/v<n>`), so every
|
|
37
|
+
* edge is a versioned optimization target, never prose hardcoded in a builder function.
|
|
38
|
+
* 4. **Per-edge traversal caps** — the cyclic-graph backstop. A delegates edge whose cap is
|
|
39
|
+
* exhausted REFUSES further traversals (fail loud), so a cycle cannot spin the pool dry.
|
|
40
|
+
* 5. **Continuity as data** — a delegates edge may declare `continuity: 'resume'`, so each spawn
|
|
41
|
+
* after the node's first re-attaches to its latest SETTLED session (the spawn context hands
|
|
42
|
+
* the executor seam `resume: { ofWorker, sequence }`; the kernel keeps identity, ordering,
|
|
43
|
+
* ledger truth, and the one conserved pool). Every ledger row states how its hop continued:
|
|
44
|
+
* `'fresh' | 'resume'` for spawns, `'steer'` for mid-run deliveries — fresh respawns, session
|
|
45
|
+
* resumes, and live steers are all plain data, each a ledgered fact.
|
|
46
|
+
*
|
|
47
|
+
* ORACLES ARE ENVIRONMENT, NEVER WORKERS. Graders/verifiers must not be spawnable in the graph —
|
|
48
|
+
* a delegates edge to them leaks the rubric. An `analyzes` edge names its analyst in one of two
|
|
49
|
+
* forms: a LENS id from the environment's registry (a pure function over trace evidence), or the
|
|
50
|
+
* id of a graph NODE — a tool-equipped analyst AGENT spawned on each matching settle with the
|
|
51
|
+
* node's pinned profile, whose settle output IS the findings. Either way the oracle doctrine
|
|
52
|
+
* holds: an analyst node can never be a delegates target (refused loudly), so no driver can hand
|
|
53
|
+
* it work, and an id living in both the registry and the nodes is refused as ambiguous.
|
|
54
|
+
*
|
|
55
|
+
* @experimental
|
|
56
|
+
*/
|
|
57
|
+
/** A delegates edge exhausted its traversal cap and the run produced no winner: the cap, not the
|
|
58
|
+
* task, ended it. Carries the full evidence so failing loud loses nothing. */
|
|
59
|
+
var GraphEdgeCapError = class extends Error {
|
|
60
|
+
exhaustedEdges;
|
|
61
|
+
ledger;
|
|
62
|
+
result;
|
|
63
|
+
constructor(exhaustedEdges, ledger, result) {
|
|
64
|
+
super(`runGraph: edge traversal cap exhausted on ${exhaustedEdges.join(", ")} and the run delivered no winner — the cap (the cyclic-graph backstop), not the task, ended this run. Raise maxTraversals on the edge or fix the cycle; the full edge ledger and the supervised result ride on this error.`);
|
|
65
|
+
this.name = "GraphEdgeCapError";
|
|
66
|
+
this.exhaustedEdges = exhaustedEdges;
|
|
67
|
+
this.ledger = ledger;
|
|
68
|
+
this.result = result;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Every `SuperviseOptions` key, partitioned by what `runGraph` does with it.
|
|
73
|
+
*
|
|
74
|
+
* `runGraph` starts one `supervise()` run, so every option that run honors is a graph option too
|
|
75
|
+
* unless the graph itself owns the value. This used to be an opt-in list written by hand, and the
|
|
76
|
+
* hand lost: 25 of 49 keys never reached `supervise()` from a graph, including `childSettleGraceMs`
|
|
77
|
+
* (a root-driver failure tore down children that had ALREADY computed the deliverable) and
|
|
78
|
+
* `driverRetry` (agent-runtime#963). Each absence was discovered by losing a run.
|
|
79
|
+
*
|
|
80
|
+
* The four lists below must cover `keyof SuperviseOptions` exactly. `everySuperviseOptionIsClassified`
|
|
81
|
+
* below fails to COMPILE, naming the offender, when a key belongs to none of them — so the next
|
|
82
|
+
* option added to `supervise()` cannot go missing here silently. It has to be classified, and
|
|
83
|
+
* classifying it as forwarded is one word.
|
|
84
|
+
*/
|
|
85
|
+
/** The graph derives these from the `AgentGraph` itself; a caller value would be overwritten. */
|
|
86
|
+
const GRAPH_OWNED_SUPERVISE_OPTIONS = [
|
|
87
|
+
"rootDriverFromBackend",
|
|
88
|
+
"resolveSpawnProfile",
|
|
89
|
+
"budget",
|
|
90
|
+
"deliverable",
|
|
91
|
+
"makeWorkerAgent",
|
|
92
|
+
"onCoordinationEvent",
|
|
93
|
+
"analyzeOnSettle",
|
|
94
|
+
"continuityByProfile",
|
|
95
|
+
"inheritSpawnRights"
|
|
96
|
+
];
|
|
97
|
+
/** Caller-facing on `RunGraphOptions`, but the graph wraps or defaults the value before it goes in:
|
|
98
|
+
* `hooks` composes with the graph's own spawn-binding hook, `authorizeMessage` is wrapped so a
|
|
99
|
+
* narrowed instruction ledgers `stripped`, `authorizeSpawn` runs AFTER the graph has pinned the
|
|
100
|
+
* node (so a product sees the canonical profile, never the driver's stub), `makeLeafAgent` is the
|
|
101
|
+
* caller's leaf override slotted under the graph's pinning, `analysts` rides only with analyze
|
|
102
|
+
* routes, and `journal`/`blobs`/`runId` get graph defaults. */
|
|
103
|
+
const GRAPH_TRANSFORMED_SUPERVISE_OPTIONS = [
|
|
104
|
+
"hooks",
|
|
105
|
+
"authorizeMessage",
|
|
106
|
+
"authorizeSpawn",
|
|
107
|
+
"makeLeafAgent",
|
|
108
|
+
"analysts",
|
|
109
|
+
"journal",
|
|
110
|
+
"blobs",
|
|
111
|
+
"runId"
|
|
112
|
+
];
|
|
113
|
+
/** Not reachable from a graph, with the reason. `registry` is a NAME COLLISION, not a policy:
|
|
114
|
+
* `RunGraphOptions.registry` is the directive `PromptRegistry` and `SuperviseOptions.registry` is
|
|
115
|
+
* the `SuperviseRegistry` name→value table. Two different types under one name; the graph's wins.
|
|
116
|
+
* Giving the supervise one a graph channel means renaming a public option, so it is recorded here
|
|
117
|
+
* rather than silently dropped. */
|
|
118
|
+
const GRAPH_REFUSED_SUPERVISE_OPTIONS = ["registry"];
|
|
119
|
+
/**
|
|
120
|
+
* Forwarded to the root `supervise()` VERBATIM. Everything not owned, transformed, or refused
|
|
121
|
+
* above belongs here — the default is "a graph honors it", not "someone remembered to add it".
|
|
122
|
+
*/
|
|
123
|
+
const GRAPH_FORWARDED_SUPERVISE_OPTIONS = [
|
|
124
|
+
"backend",
|
|
125
|
+
"profileGuidance",
|
|
126
|
+
"escalateQuestion",
|
|
127
|
+
"rootHandle",
|
|
128
|
+
"signal",
|
|
129
|
+
"execution",
|
|
130
|
+
"resolveDeliverable",
|
|
131
|
+
"coordination",
|
|
132
|
+
"peerMail",
|
|
133
|
+
"peerAudit",
|
|
134
|
+
"traceTools",
|
|
135
|
+
"driverBackend",
|
|
136
|
+
"profileSecurity",
|
|
137
|
+
"authorizeSpawn",
|
|
138
|
+
"router",
|
|
139
|
+
"driveHarness",
|
|
140
|
+
"selectSeat",
|
|
141
|
+
"driverRetry",
|
|
142
|
+
"onDriverAttempt",
|
|
143
|
+
"workerRetry",
|
|
144
|
+
"onWorkerRetry",
|
|
145
|
+
"continuation",
|
|
146
|
+
"childSettleGraceMs",
|
|
147
|
+
"teardownConfirmMs",
|
|
148
|
+
"retainedAtSettlement",
|
|
149
|
+
"resolveDriveHarness",
|
|
150
|
+
"driveHarnessMaterialization",
|
|
151
|
+
"resolveSupervisorTools",
|
|
152
|
+
"extraTools",
|
|
153
|
+
"executeExtraTool",
|
|
154
|
+
"recoverExecutor",
|
|
155
|
+
"perWorker",
|
|
156
|
+
"reservationPolicy",
|
|
157
|
+
"deadlineCheckIn",
|
|
158
|
+
"workerSlots",
|
|
159
|
+
"watchWorkers",
|
|
160
|
+
"stallAfterMs",
|
|
161
|
+
"wake",
|
|
162
|
+
"runDir",
|
|
163
|
+
"resume",
|
|
164
|
+
"segment",
|
|
165
|
+
"runContext",
|
|
166
|
+
"steerDir",
|
|
167
|
+
"stopRule",
|
|
168
|
+
"onProgressStop",
|
|
169
|
+
"maxDepth",
|
|
170
|
+
"maxTurns",
|
|
171
|
+
"compaction",
|
|
172
|
+
"now",
|
|
173
|
+
"allowedModels",
|
|
174
|
+
"finalizer",
|
|
175
|
+
"otel",
|
|
176
|
+
"graphRegistry"
|
|
177
|
+
];
|
|
178
|
+
/**
|
|
179
|
+
* Every key `RunGraphOptions` accepts, as data: the forwarded and transformed `SuperviseOptions`
|
|
180
|
+
* keys, the name-colliding `registry`, and the graph's own `brain`. `GRAPH_OWNED_SUPERVISE_OPTIONS`
|
|
181
|
+
* is deliberately absent — a caller value for one of those is overwritten by the graph, so it is
|
|
182
|
+
* refused by name rather than discarded.
|
|
183
|
+
*
|
|
184
|
+
* The assignment below fails to COMPILE, naming the key, when `RunGraphOptions` declares something
|
|
185
|
+
* this list does not carry.
|
|
186
|
+
*/
|
|
187
|
+
const runGraphOptionKeys = [
|
|
188
|
+
...GRAPH_FORWARDED_SUPERVISE_OPTIONS,
|
|
189
|
+
...GRAPH_TRANSFORMED_SUPERVISE_OPTIONS,
|
|
190
|
+
...GRAPH_REFUSED_SUPERVISE_OPTIONS,
|
|
191
|
+
"brain"
|
|
192
|
+
];
|
|
193
|
+
const runGraphOptionKeySet = new Set(runGraphOptionKeys);
|
|
194
|
+
const graphOwnedOptionKeySet = new Set(GRAPH_OWNED_SUPERVISE_OPTIONS);
|
|
195
|
+
/**
|
|
196
|
+
* Refuse an option key the graph would not read, naming it and saying which kind it is.
|
|
197
|
+
*
|
|
198
|
+
* A graph-owned key is the sharper case: it type-checks against a widened `SuperviseOptions`
|
|
199
|
+
* value, the graph derives its own value and overwrites the caller's, the run succeeds, and the
|
|
200
|
+
* capability the caller asked for is not there. The rename of the leaf seam from `makeWorkerAgent`
|
|
201
|
+
* to `makeLeafAgent` is the shape of the failure — the old name stayed a valid `SuperviseOptions`
|
|
202
|
+
* key AND a graph-owned one, so a caller that kept passing it got a run with no leaf override and
|
|
203
|
+
* no complaint.
|
|
204
|
+
*/
|
|
205
|
+
function assertRunGraphOptionKeys(opts) {
|
|
206
|
+
const graphOwned = [];
|
|
207
|
+
const unknown = [];
|
|
208
|
+
for (const key of Object.keys(opts)) {
|
|
209
|
+
if (runGraphOptionKeySet.has(key)) continue;
|
|
210
|
+
if (graphOwnedOptionKeySet.has(key)) graphOwned.push(key);
|
|
211
|
+
else unknown.push(key);
|
|
212
|
+
}
|
|
213
|
+
if (graphOwned.length > 0) throw new ConfigError(`runGraph: ${graphOwned.sort().join(", ")} — the graph derives this from the AgentGraph itself, so a caller value is overwritten and the capability it asks for would silently be absent`);
|
|
214
|
+
if (unknown.length > 0) throw new ConfigError(`runGraph: unknown option ${unknown.sort().join(", ")} — no reader consults that name, so the value would be discarded and the capability it asks for would silently be absent`);
|
|
215
|
+
}
|
|
216
|
+
/** Copy every forwarded option the caller actually set. Absent stays absent: `supervise()` and the
|
|
217
|
+
* graph must not disagree about what "unset" means. */
|
|
218
|
+
function forwardedSuperviseOptions(opts) {
|
|
219
|
+
const forwarded = {};
|
|
220
|
+
for (const key of GRAPH_FORWARDED_SUPERVISE_OPTIONS) {
|
|
221
|
+
const value = opts[key];
|
|
222
|
+
if (value !== void 0) forwarded[key] = value;
|
|
223
|
+
}
|
|
224
|
+
return forwarded;
|
|
225
|
+
}
|
|
226
|
+
/** Validate the graph and resolve every directive BEFORE any compute is spent — an invalid
|
|
227
|
+
* topology or an unknown directive is a configuration fault, never a mid-run surprise. */
|
|
228
|
+
function validateGraph(graph, registry, analysts) {
|
|
229
|
+
if (!Array.isArray(graph.nodes) || graph.nodes.length === 0) throw new ValidationError("runGraph: graph.nodes must be a non-empty array");
|
|
230
|
+
if (!Array.isArray(graph.edges) || graph.edges.length === 0) throw new ValidationError("runGraph: graph.edges must be a non-empty array");
|
|
231
|
+
if (typeof graph.deliverable?.check !== "function") throw new ValidationError("runGraph: graph.deliverable is mandatory (termination oracle)");
|
|
232
|
+
if (typeof graph.budget !== "object" || graph.budget === null) throw new ValidationError("runGraph: graph.budget is mandatory (the conserved pool)");
|
|
233
|
+
return validateGraphTopology(graph.nodes, graph.edges, registry, analysts);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Execute an {@link AgentGraph}. The root node becomes the supervisor (`supervise()` — the
|
|
237
|
+
* execution core), each worker node is spawnable BY NODE ID (`spawn_worker` with
|
|
238
|
+
* `profile: { name: '<node id>' }`; the node's canonical profile is pinned by the graph), each
|
|
239
|
+
* delegates directive is appended to the worker profile's `prompt.instructions` per traversal,
|
|
240
|
+
* and each analyzes edge becomes an analyst-on-settle route with a real DESTINATION. Every
|
|
241
|
+
* traversal is ledgered and journaled.
|
|
242
|
+
*/
|
|
243
|
+
function runGraph(graph, opts) {
|
|
244
|
+
const { brain, ...runtimeOptions } = opts;
|
|
245
|
+
return superviseAgentGraph(graph, runtimeOptions, brain);
|
|
246
|
+
}
|
|
247
|
+
/** Alias for graph tests written before `RunGraphOptions.brain` was production. The production
|
|
248
|
+
* entry accepts the same shape; this wrapper only keeps the `/testing` import path working. */
|
|
249
|
+
function runGraphWithTestBrain(graph, opts) {
|
|
250
|
+
const { brain, ...runtimeOptions } = opts;
|
|
251
|
+
return superviseAgentGraph(graph, runtimeOptions, brain);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* The graph supervise run, as its own entry: the engine's `run-graph` preset node executes exactly
|
|
255
|
+
* this, so the preset and `runGraph` are the same code path by construction (agent-runtime#982).
|
|
256
|
+
*/
|
|
257
|
+
/**
|
|
258
|
+
* Every refusal a graph earns before any compute, in one place: the authoring contract. `runGraph`
|
|
259
|
+
* calls it FIRST so a malformed graph throws synchronously, exactly as it did before the engine
|
|
260
|
+
* preset (agent-runtime#982) moved execution behind a promise.
|
|
261
|
+
*/
|
|
262
|
+
function assertRunGraphAuthoring(graph, opts, brain) {
|
|
263
|
+
assertRunGraphOptionKeys(opts);
|
|
264
|
+
const validated = validateGraph(graph, opts.registry ?? kernelPromptRegistry(), opts.analysts);
|
|
265
|
+
const { root } = validated;
|
|
266
|
+
if (brain && opts.driverBackend) throw new ValidationError("runGraph: brain and driverBackend are mutually exclusive — a caller brain makes the root model calls, a driverBackend places a harness that makes its own");
|
|
267
|
+
if (brain && harnessRunsAgent(root.profile.harness)) throw new ValidationError(`runGraph: root node '${root.id}' declares harness '${root.profile.harness}', so the harness drives it — a caller brain applies only to a router-brained root (profile.harness omitted or 'cli-base')`);
|
|
268
|
+
if (!opts.backend && !opts.makeLeafAgent) throw new ValidationError("runGraph: provide opts.backend (where nodes run) or opts.makeLeafAgent");
|
|
269
|
+
return validated;
|
|
270
|
+
}
|
|
271
|
+
function superviseAgentGraph(graph, opts, brain) {
|
|
272
|
+
const registry = opts.registry ?? kernelPromptRegistry();
|
|
273
|
+
if (opts.runContext?.acquire !== void 0) return withRunContext(opts.runContext, opts.signal, (runContext, signal) => superviseAgentGraph(graph, {
|
|
274
|
+
...opts,
|
|
275
|
+
runContext,
|
|
276
|
+
...signal === void 0 ? {} : { signal }
|
|
277
|
+
}, brain));
|
|
278
|
+
const validated = assertRunGraphAuthoring(graph, opts, brain);
|
|
279
|
+
const { root } = validated;
|
|
280
|
+
const journal = opts.journal ?? opts.runContext?.journal ?? (opts.runDir !== void 0 ? new FileSpawnJournal(`${resolve(opts.runDir)}/spawn-journal.jsonl`) : new InMemorySpawnJournal());
|
|
281
|
+
const blobs = opts.blobs ?? opts.runContext?.blobs ?? (opts.runDir !== void 0 ? new FileResultBlobStore(`${resolve(opts.runDir)}/blobs`) : new InMemoryResultBlobStore());
|
|
282
|
+
const runId = opts.runId ?? opts.runContext?.runId ?? `graph-${canonicalCandidateDigest(graph.nodes.map((n) => n.id)).slice(7, 19)}`;
|
|
283
|
+
const now = opts.now ?? Date.now;
|
|
284
|
+
const guidance = profileGuidanceComposer(opts.profileGuidance);
|
|
285
|
+
const overlay = createGraphOverlay(validated, {
|
|
286
|
+
registry,
|
|
287
|
+
journal,
|
|
288
|
+
runId,
|
|
289
|
+
now,
|
|
290
|
+
...guidance ? { guidance } : {},
|
|
291
|
+
...opts.authorizeSpawn ? { authorizeSpawn: opts.authorizeSpawn } : {}
|
|
292
|
+
});
|
|
293
|
+
const callerAuthorizeMessage = opts.authorizeMessage;
|
|
294
|
+
const authorizeMessage = overlay.observeMessages((input) => callerAuthorizeMessage ? callerAuthorizeMessage(input) : { instruction: input.instruction });
|
|
295
|
+
const hooks = composeRuntimeHooks({ onEvent: (event) => {
|
|
296
|
+
if (event.target !== "agent.spawn" || event.phase !== "after") return;
|
|
297
|
+
const payload = event.payload;
|
|
298
|
+
if (typeof payload?.childId !== "string" || typeof payload.assignmentId !== "string") return;
|
|
299
|
+
return overlay.bindSpawn(event.parentId, payload.assignmentId, payload.childId);
|
|
300
|
+
} }, opts.hooks);
|
|
301
|
+
const rootProfile = graphRootProfile(validated, registry);
|
|
302
|
+
const start = async () => {
|
|
303
|
+
const superviseOptions = {
|
|
304
|
+
...forwardedSuperviseOptions(opts),
|
|
305
|
+
rootDriverFromBackend: false,
|
|
306
|
+
budget: graph.budget,
|
|
307
|
+
deliverable: graph.deliverable,
|
|
308
|
+
authorizeSpawn: overlay.authorizeSpawn,
|
|
309
|
+
resolveSpawnProfile: overlay.resolveSpawnProfile,
|
|
310
|
+
inheritSpawnRights: false,
|
|
311
|
+
...opts.makeLeafAgent ? { makeLeafAgent: opts.makeLeafAgent } : {},
|
|
312
|
+
journal,
|
|
313
|
+
blobs,
|
|
314
|
+
runId,
|
|
315
|
+
hooks,
|
|
316
|
+
onCoordinationEvent: async (_context, _eventId, record) => overlay.onCoordinationEvent(record.event),
|
|
317
|
+
...overlay.routes.length > 0 ? {
|
|
318
|
+
analyzeOnSettle: overlay.routes,
|
|
319
|
+
...opts.analysts ? { analysts: opts.analysts } : {}
|
|
320
|
+
} : {},
|
|
321
|
+
...Object.keys(overlay.continuityByProfile).length > 0 ? { continuityByProfile: overlay.continuityByProfile } : {},
|
|
322
|
+
authorizeMessage
|
|
323
|
+
};
|
|
324
|
+
const result = brain === void 0 ? await supervise(rootProfile, graphTask(graph, root), superviseOptions) : await superviseWithTestBrain(rootProfile, graphTask(graph, root), {
|
|
325
|
+
...superviseOptions,
|
|
326
|
+
brain
|
|
327
|
+
});
|
|
328
|
+
const { ledger, exhaustedEdges, exhaustedDelegates } = await overlay.settle();
|
|
329
|
+
const lifecycleEnded = result.kind === "no-winner" && (result.reason === "aborted" || result.reason === "cancelled" || result.reason === "budget-exhausted");
|
|
330
|
+
if (result.kind !== "winner" && !lifecycleEnded && exhaustedDelegates.length > 0) throw new GraphEdgeCapError(exhaustedDelegates, ledger, result);
|
|
331
|
+
return {
|
|
332
|
+
result,
|
|
333
|
+
ledger,
|
|
334
|
+
exhaustedEdges,
|
|
335
|
+
runId
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
return start();
|
|
339
|
+
}
|
|
340
|
+
/** The root task: the graph's own framing. The deliverable (mandatory) is the termination; the
|
|
341
|
+
* task names what the topology exists to produce. */
|
|
342
|
+
function graphTask(graph, root) {
|
|
343
|
+
return graph.deliverable.describe ?? `Deliver the graph's deliverable by driving your worker nodes (root: '${root.id}').`;
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
export { superviseAgentGraph as i, runGraph as n, runGraphWithTestBrain as r, GraphEdgeCapError as t };
|
|
347
|
+
|
|
348
|
+
//# sourceMappingURL=graph-Cuz6Ubzd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-Cuz6Ubzd.js","names":[],"sources":["../src/runtime/supervise/graph.ts"],"sourcesContent":["/**\n *\n * `runGraph` — agent graphs: profiles as nodes, registry-backed prompt directives as edges.\n *\n * A topology is PLAIN DATA an agent can author in a few lines: nodes are canonical\n * `AgentProfile`s (the ONLY way a node is described — no role-builder functions), edges are typed\n * values carrying versioned {@link PromptHandle} directives, `deliverable` (termination) and\n * `budget` (one conserved pool) are mandatory. Driver↔worker is the two-node cyclic instance;\n * \"agent 3 analyzes 1 and 2 and reports to 1\" is ONE edge, not a framework.\n *\n * NOT A SECOND SCHEDULER. `runGraph` is an interpretation layer over what already runs:\n * `supervise()` is the execution core — the same `supervisorAgent`/`driverAgent` machinery,\n * backend-derived worker path (authorized, classified, recursive), conserved-pool budget, and\n * deliverable-gated settlement every\n * supervised run uses. (`runAgentRounds` is deliberately NOT the substrate here.) What the graph\n * layer ADDS is exactly what a bespoke driver loop never\n * had:\n *\n * 1. **Node pinning** — a spawn names a node (`profile.name` = node id) and the node's canonical\n * profile is what runs; a driver cannot smuggle capabilities into a worker it did not define.\n * 2. **Observable edges** — every delegates/analyzes traversal lands in an EDGE LEDGER\n * (`delivered | stripped | empty | unpropagated`, with byte counts), in memory on\n * the result AND as `edge` events in the run journal. The motivating incident: a filter\n * silently replaced 1,700-char steering with 241 chars of boilerplate for three rounds and\n * NO artifact said so — an unobservable edge cannot be trusted and its directive cannot be\n * optimized.\n * 3. **Directives as data** — edge text lives in the prompt registry (`<surface>/v<n>`), so every\n * edge is a versioned optimization target, never prose hardcoded in a builder function.\n * 4. **Per-edge traversal caps** — the cyclic-graph backstop. A delegates edge whose cap is\n * exhausted REFUSES further traversals (fail loud), so a cycle cannot spin the pool dry.\n * 5. **Continuity as data** — a delegates edge may declare `continuity: 'resume'`, so each spawn\n * after the node's first re-attaches to its latest SETTLED session (the spawn context hands\n * the executor seam `resume: { ofWorker, sequence }`; the kernel keeps identity, ordering,\n * ledger truth, and the one conserved pool). Every ledger row states how its hop continued:\n * `'fresh' | 'resume'` for spawns, `'steer'` for mid-run deliveries — fresh respawns, session\n * resumes, and live steers are all plain data, each a ledgered fact.\n *\n * ORACLES ARE ENVIRONMENT, NEVER WORKERS. Graders/verifiers must not be spawnable in the graph —\n * a delegates edge to them leaks the rubric. An `analyzes` edge names its analyst in one of two\n * forms: a LENS id from the environment's registry (a pure function over trace evidence), or the\n * id of a graph NODE — a tool-equipped analyst AGENT spawned on each matching settle with the\n * node's pinned profile, whose settle output IS the findings. Either way the oracle doctrine\n * holds: an analyst node can never be a delegates target (refused loudly), so no driver can hand\n * it work, and an id living in both the registry and the nodes is refused as ambiguous.\n *\n * @experimental\n */\n\nimport { resolve } from 'node:path'\nimport { type AgentProfile, canonicalCandidateDigest } from '@tangle-network/agent-interface'\nimport {\n FileResultBlobStore,\n FileSpawnJournal,\n InMemoryResultBlobStore,\n InMemorySpawnJournal,\n} from '../../durable/spawn-journal'\nimport { ConfigError, ValidationError } from '../../errors'\nimport type { AnalystRegistry, ContinuityMode, MakeWorkerAgent } from '../../mcp/tools/coordination'\nimport { composeRuntimeHooks, type RuntimeHooks } from '../../runtime-hooks'\nimport { harnessRunsAgent } from '../harness-role'\nimport type { ToolLoopChat } from '../tool-loop'\nimport type { DeliverableSpec } from './completion-gate'\nimport {\n createGraphOverlay,\n graphRootProfile,\n type ValidatedGraph,\n validateGraphTopology,\n} from './graph-overlay'\nimport { kernelPromptRegistry, type PromptHandle, type PromptRegistry } from './prompt-registry'\nimport { withRunContext } from './run-context'\nimport {\n profileGuidanceComposer,\n type SuperviseOptions,\n supervise,\n superviseWithTestBrain,\n} from './supervise'\nimport type { Budget, NodeId, ResultBlobStore, SpawnJournal, SupervisedResult } from './types'\n\nexport { defaultEdgeTraversalCap } from './graph-overlay'\n\n// ── The algebra ────────────────────────────────────────────────────────────────\n\n/** A graph node: an id and a canonical `AgentProfile`. The profile is the ONLY way a node is\n * described — its `prompt.systemPrompt` is the standing role (the 0.117 canonical resolution;\n * never a legacy top-level-only reduction), its tools/mcp/resources are its capabilities. */\nexport interface GraphNode {\n readonly id: NodeId\n readonly profile: AgentProfile\n}\n\nexport type GraphEdge =\n /** Work flows down. The delegation directive is DATA → versionable, sweepable, optimizable.\n * Each spawn of `to` by `from` — and each mid-run steer from `from` to a live `to` worker —\n * is one traversal. */\n | {\n readonly kind: 'delegates'\n readonly from: NodeId\n readonly to: NodeId\n readonly directive: PromptHandle\n /** Cyclic-graph backstop: traversals beyond this REFUSE (fail loud). Default\n * {@link defaultEdgeTraversalCap}. */\n readonly maxTraversals?: number\n /** Default continuity for this edge's SPAWN traversals. `'resume'` makes every spawn after\n * the node's first re-attach to its most recent SETTLED worker: a NEW live worker whose\n * spawn context carries `resume: { ofWorker, sequence }` for the executor seam, spending\n * from the same conserved pool — the node's first spawn is effectively `'fresh'`, and a\n * spawn while a prior worker is still live refuses loudly (steer is the live channel).\n * The driver's per-call `spawn_worker` `continuity` argument overrides either way. Omit =\n * `'fresh'` (today's behavior, byte-identical). Caps count resumes exactly like fresh\n * spawns. */\n readonly continuity?: ContinuityMode\n }\n /** Findings flow anywhere: an analyst over N nodes' settled traces, delivered to ONE node.\n * With a LENS analyst the directive wraps the findings for the recipient; with a NODE analyst\n * the directive is the analyst agent's task and the findings are its settle output. */\n | {\n readonly kind: 'analyzes'\n /** The analyst REFERENCE, in one of two forms: a lens id resolved against\n * `RunGraphOptions.analysts` (environment), or the id of a graph NODE with no delegates\n * edge pointing at it — then each matching settle spawns that node's pinned profile as a\n * tool-equipped analyst WORKER (same spawn machinery, conserved budget, trace join) whose\n * task is this edge's directive plus the settled worker's trace evidence and whose settle\n * output is the findings. An id that is both a node and a registry lens is refused. */\n readonly analyst: string\n readonly over: ReadonlyArray<NodeId>\n readonly to: NodeId\n readonly directive: PromptHandle\n /** Observability cap: traversals beyond this are LEDGERED as exhausted (`unpropagated`).\n * Only delegates caps refuse traversal — they are what close the spawn cycle. */\n readonly maxTraversals?: number\n }\n\nexport interface AgentGraph {\n readonly nodes: ReadonlyArray<GraphNode>\n readonly edges: ReadonlyArray<GraphEdge>\n /** Termination is mandatory, not optional: the independent completion oracle. */\n readonly deliverable: DeliverableSpec<unknown>\n /** One conserved pool across the whole graph — cycles without conservation never terminate. */\n readonly budget: Budget\n}\n\n// ── The edge ledger ────────────────────────────────────────────────────────────\n\nexport type EdgeDeliveryOutcome = 'delivered' | 'stripped' | 'empty' | 'unpropagated'\n\n/** How one ledgered hop CONTINUED: a spawn traversal stamps its effective spawn mode\n * (`'fresh'` | `'resume'`), and every mid-run delivery into an already-live recipient — a\n * driver steer leg and every analyzes delivery (routed steer or driver-destined finding) —\n * stamps `'steer'`. Zero ambiguity: every row carries exactly one of the three. */\nexport type TraversalContinuity = ContinuityMode | 'steer'\n\n/** One recorded edge traversal — the in-memory row; the journal twin is the `edge` SpawnEvent. */\nexport interface EdgeTraversal {\n /** Stable edge id: `delegates:<from>-><to>` or `analyzes:<analyst>:<over…>-><to>`. */\n readonly edge: string\n readonly kind: 'delegates' | 'analyzes'\n readonly from: string\n readonly to: string\n /** The resolved directive reference (`<surface>/v<n>`). */\n readonly directive: string\n /** 1-based per-edge ordinal. */\n readonly traversal: number\n readonly outcome: EdgeDeliveryOutcome\n /** How this hop continued — see {@link TraversalContinuity}. */\n readonly continuity: TraversalContinuity\n /** Bytes of directive + payload that actually crossed the edge. */\n readonly bytes: number\n readonly reason?: string\n /** The concrete worker node id, once known. */\n readonly workerId?: string\n}\n\n/** A delegates edge exhausted its traversal cap and the run produced no winner: the cap, not the\n * task, ended it. Carries the full evidence so failing loud loses nothing. */\nexport class GraphEdgeCapError extends Error {\n readonly exhaustedEdges: ReadonlyArray<string>\n readonly ledger: ReadonlyArray<EdgeTraversal>\n readonly result: SupervisedResult<unknown>\n constructor(\n exhaustedEdges: ReadonlyArray<string>,\n ledger: ReadonlyArray<EdgeTraversal>,\n result: SupervisedResult<unknown>,\n ) {\n super(\n `runGraph: edge traversal cap exhausted on ${exhaustedEdges.join(', ')} and the run ` +\n 'delivered no winner — the cap (the cyclic-graph backstop), not the task, ended this run. ' +\n 'Raise maxTraversals on the edge or fix the cycle; the full edge ledger and the ' +\n 'supervised result ride on this error.',\n )\n this.name = 'GraphEdgeCapError'\n this.exhaustedEdges = exhaustedEdges\n this.ledger = ledger\n this.result = result\n }\n}\n\n// ── Options / result ───────────────────────────────────────────────────────────\n\n/**\n * Every `SuperviseOptions` key, partitioned by what `runGraph` does with it.\n *\n * `runGraph` starts one `supervise()` run, so every option that run honors is a graph option too\n * unless the graph itself owns the value. This used to be an opt-in list written by hand, and the\n * hand lost: 25 of 49 keys never reached `supervise()` from a graph, including `childSettleGraceMs`\n * (a root-driver failure tore down children that had ALREADY computed the deliverable) and\n * `driverRetry` (agent-runtime#963). Each absence was discovered by losing a run.\n *\n * The four lists below must cover `keyof SuperviseOptions` exactly. `everySuperviseOptionIsClassified`\n * below fails to COMPILE, naming the offender, when a key belongs to none of them — so the next\n * option added to `supervise()` cannot go missing here silently. It has to be classified, and\n * classifying it as forwarded is one word.\n */\n\n/** The graph derives these from the `AgentGraph` itself; a caller value would be overwritten. */\nconst GRAPH_OWNED_SUPERVISE_OPTIONS = [\n 'rootDriverFromBackend',\n 'resolveSpawnProfile',\n 'budget',\n 'deliverable',\n 'makeWorkerAgent',\n 'onCoordinationEvent',\n 'analyzeOnSettle',\n 'continuityByProfile',\n // A graph pins every node and its delegation edges; a node never gains spawn rights it lacks.\n 'inheritSpawnRights',\n] as const\n\n/** Caller-facing on `RunGraphOptions`, but the graph wraps or defaults the value before it goes in:\n * `hooks` composes with the graph's own spawn-binding hook, `authorizeMessage` is wrapped so a\n * narrowed instruction ledgers `stripped`, `authorizeSpawn` runs AFTER the graph has pinned the\n * node (so a product sees the canonical profile, never the driver's stub), `makeLeafAgent` is the\n * caller's leaf override slotted under the graph's pinning, `analysts` rides only with analyze\n * routes, and `journal`/`blobs`/`runId` get graph defaults. */\nconst GRAPH_TRANSFORMED_SUPERVISE_OPTIONS = [\n 'hooks',\n 'authorizeMessage',\n 'authorizeSpawn',\n 'makeLeafAgent',\n 'analysts',\n 'journal',\n 'blobs',\n 'runId',\n] as const\n\n/** Not reachable from a graph, with the reason. `registry` is a NAME COLLISION, not a policy:\n * `RunGraphOptions.registry` is the directive `PromptRegistry` and `SuperviseOptions.registry` is\n * the `SuperviseRegistry` name→value table. Two different types under one name; the graph's wins.\n * Giving the supervise one a graph channel means renaming a public option, so it is recorded here\n * rather than silently dropped. */\nconst GRAPH_REFUSED_SUPERVISE_OPTIONS = ['registry'] as const\n\n/**\n * Forwarded to the root `supervise()` VERBATIM. Everything not owned, transformed, or refused\n * above belongs here — the default is \"a graph honors it\", not \"someone remembered to add it\".\n */\nconst GRAPH_FORWARDED_SUPERVISE_OPTIONS = [\n 'backend',\n // Forwarded: composes guidance into the root and into profiles a manager authors. The graph also\n // composes each PINNED node profile, because pinning replaces the composed `{ name }` stub.\n 'profileGuidance',\n // Forwarded, not graph-owned: a graph pins WHICH nodes run, never who answers a question one of\n // them raises. Without it a graph run's `ask_parent` would always report `no-parent` even when\n // the caller wired an inbox.\n 'escalateQuestion',\n 'rootHandle',\n 'signal',\n 'execution',\n 'resolveDeliverable',\n 'coordination',\n 'peerMail',\n 'peerAudit',\n 'traceTools',\n 'driverBackend',\n 'profileSecurity',\n 'authorizeSpawn',\n 'router',\n 'driveHarness',\n 'selectSeat',\n 'driverRetry',\n 'onDriverAttempt',\n 'workerRetry',\n 'onWorkerRetry',\n 'continuation',\n 'childSettleGraceMs',\n 'teardownConfirmMs',\n 'retainedAtSettlement',\n 'resolveDriveHarness',\n 'driveHarnessMaterialization',\n 'resolveSupervisorTools',\n 'extraTools',\n 'executeExtraTool',\n 'recoverExecutor',\n 'perWorker',\n 'reservationPolicy',\n 'deadlineCheckIn',\n 'workerSlots',\n 'watchWorkers',\n 'stallAfterMs',\n 'wake',\n 'runDir',\n 'resume',\n 'segment',\n 'runContext',\n 'steerDir',\n 'stopRule',\n 'onProgressStop',\n 'maxDepth',\n 'maxTurns',\n 'compaction',\n 'now',\n 'allowedModels',\n 'finalizer',\n 'otel',\n // Forwarded: the registry a manager's `run_graph` resolves stored graphs against. A node of this\n // graph cannot start another graph (pinning refuses it), so it matters to no node here.\n 'graphRegistry',\n] as const\n\ntype ClassifiedSuperviseOption =\n | (typeof GRAPH_OWNED_SUPERVISE_OPTIONS)[number]\n | (typeof GRAPH_TRANSFORMED_SUPERVISE_OPTIONS)[number]\n | (typeof GRAPH_REFUSED_SUPERVISE_OPTIONS)[number]\n | (typeof GRAPH_FORWARDED_SUPERVISE_OPTIONS)[number]\n\n/**\n * Every key `RunGraphOptions` accepts, as data: the forwarded and transformed `SuperviseOptions`\n * keys, the name-colliding `registry`, and the graph's own `brain`. `GRAPH_OWNED_SUPERVISE_OPTIONS`\n * is deliberately absent — a caller value for one of those is overwritten by the graph, so it is\n * refused by name rather than discarded.\n *\n * The assignment below fails to COMPILE, naming the key, when `RunGraphOptions` declares something\n * this list does not carry.\n */\nconst runGraphOptionKeys = [\n ...GRAPH_FORWARDED_SUPERVISE_OPTIONS,\n ...GRAPH_TRANSFORMED_SUPERVISE_OPTIONS,\n ...GRAPH_REFUSED_SUPERVISE_OPTIONS,\n 'brain',\n] as const\n\ntype UnlistedRunGraphOption = Exclude<keyof RunGraphOptions, (typeof runGraphOptionKeys)[number]>\nconst everyRunGraphOptionIsListed: UnlistedRunGraphOption extends never\n ? true\n : UnlistedRunGraphOption = true\nvoid everyRunGraphOptionIsListed\n\nconst runGraphOptionKeySet: ReadonlySet<string> = new Set<string>(runGraphOptionKeys)\nconst graphOwnedOptionKeySet: ReadonlySet<string> = new Set<string>(GRAPH_OWNED_SUPERVISE_OPTIONS)\n\n/**\n * Refuse an option key the graph would not read, naming it and saying which kind it is.\n *\n * A graph-owned key is the sharper case: it type-checks against a widened `SuperviseOptions`\n * value, the graph derives its own value and overwrites the caller's, the run succeeds, and the\n * capability the caller asked for is not there. The rename of the leaf seam from `makeWorkerAgent`\n * to `makeLeafAgent` is the shape of the failure — the old name stayed a valid `SuperviseOptions`\n * key AND a graph-owned one, so a caller that kept passing it got a run with no leaf override and\n * no complaint.\n */\nfunction assertRunGraphOptionKeys(opts: RunGraphOptions): void {\n const graphOwned: string[] = []\n const unknown: string[] = []\n for (const key of Object.keys(opts)) {\n if (runGraphOptionKeySet.has(key)) continue\n if (graphOwnedOptionKeySet.has(key)) graphOwned.push(key)\n else unknown.push(key)\n }\n if (graphOwned.length > 0) {\n throw new ConfigError(\n `runGraph: ${graphOwned.sort().join(', ')} — the graph derives this from the AgentGraph ` +\n 'itself, so a caller value is overwritten and the capability it asks for would silently ' +\n 'be absent',\n )\n }\n if (unknown.length > 0) {\n throw new ConfigError(\n `runGraph: unknown option ${unknown.sort().join(', ')} — no reader consults that name, so ` +\n 'the value would be discarded and the capability it asks for would silently be absent',\n )\n }\n}\n\n/** A `SuperviseOptions` key in none of the four lists makes this assignment fail, and the compiler\n * error names the key. Classify it — `GRAPH_FORWARDED_SUPERVISE_OPTIONS` is usually the answer. */\ntype UnclassifiedSuperviseOption = Exclude<keyof SuperviseOptions, ClassifiedSuperviseOption>\nconst everySuperviseOptionIsClassified: UnclassifiedSuperviseOption extends never\n ? true\n : UnclassifiedSuperviseOption = true\nvoid everySuperviseOptionIsClassified\n\n/** `backend` and `driverBackend` keep graph-specific documentation below.\n *\n * Do not inherit and redeclare them through an indexed access type.\n * TypeScript 7 correctly treats `SuperviseOptions['backend']` as including `undefined`, which makes\n * that redeclaration wider than the exact optional property inherited from `SuperviseOptions`.\n */\ntype GraphInheritedSuperviseOption = Exclude<\n (typeof GRAPH_FORWARDED_SUPERVISE_OPTIONS)[number],\n 'backend' | 'driverBackend'\n>\n\n/** Copy every forwarded option the caller actually set. Absent stays absent: `supervise()` and the\n * graph must not disagree about what \"unset\" means. */\nfunction forwardedSuperviseOptions(\n opts: RunGraphOptions,\n): Pick<SuperviseOptions, (typeof GRAPH_FORWARDED_SUPERVISE_OPTIONS)[number]> {\n const forwarded: Record<string, unknown> = {}\n for (const key of GRAPH_FORWARDED_SUPERVISE_OPTIONS) {\n const value = (opts as Record<string, unknown>)[key]\n if (value !== undefined) forwarded[key] = value\n }\n return forwarded as Pick<SuperviseOptions, (typeof GRAPH_FORWARDED_SUPERVISE_OPTIONS)[number]>\n}\n\n/**\n * Options for one `runGraph` run.\n *\n * Extends every forwarded `SuperviseOptions` key, so a graph honors what a `supervise()` run\n * honors WITHOUT anyone restating it here. Only the graph-specific members and the ones whose\n * graph semantics differ are declared below; everything else inherits its type AND its\n * documentation from `SuperviseOptions`, which is the one owner of both.\n */\nexport interface RunGraphOptions extends Pick<SuperviseOptions, GraphInheritedSuperviseOption> {\n /** WHERE worker nodes run — the executor backend. Provide this OR `makeLeafAgent`. Forwarded to\n * `supervise()`, which derives every authorized leaf from it. A node that declares\n * `agent_runtime_coordination_spawn_worker` becomes a nested supervisor instead, whose own\n * leaves are derived the same way. */\n readonly backend?: Exclude<SuperviseOptions['backend'], undefined>\n /** WHERE the ROOT node's harness brain runs — forwarded to `supervise()` verbatim (see\n * `SuperviseOptions.driverBackend`). Needed when the root node's profile declares an external\n * harness (`codex`, `claude-code`, `opencode`): that root is driven by the harness, not by the\n * router brain, and automatic execution supports a local `bridge`. Unlike `supervise()`, this\n * does NOT default to `backend`: a graph's `backend` places WORKER nodes, so the root driver\n * is selected only by this field. Omit = no harness driver, which is correct for a root whose\n * `profile.harness` is omitted or `cli-base` (that root runs on the router brain). */\n readonly driverBackend?: Exclude<SuperviseOptions['driverBackend'], undefined>\n /** Leaf-execution override (offline tests / advanced). `runGraph` still owns node pinning,\n * directive delivery, and the edge ledger AROUND this seam — only the leaf `act` is yours.\n * Slots INSIDE the kernel's authorized path (`SuperviseOptions.makeLeafAgent`), so a node that\n * declares the spawn tool still becomes a nested supervisor even under an offline leaf. */\n readonly makeLeafAgent?: MakeWorkerAgent\n /** The ROOT driver's inference seam — a caller-owned `ToolLoopChat` that makes every root\n * model call. Use it when the root's decisions must be caller-owned orchestration (a\n * deterministic conversation driver, a persona loop with its own LLM calls) rather than a\n * router-derived model call. The graph machinery around the seam is unchanged: node pinning,\n * directive delivery, the edge ledger, and the journal twin all run the same shipped path,\n * and the root profile keeps prompt control (`prompt-control-execution` materialization —\n * `systemPrompt`/`instructions` still apply). What moves to the caller with the brain:\n * model selection and provider-identity validation (`expectedModel` cannot be enforced on a\n * call the runtime did not place) and per-turn usage reporting (a brain that reports no\n * usage meters nothing into the pool). Omit = the router brain derived from the root\n * profile — the unchanged default. Mutually exclusive with `driverBackend`, and refused\n * when the root profile declares an external harness (that root is driven BY the harness). */\n readonly brain?: ToolLoopChat\n /** Caller-side runtime hooks (telemetry, policy, product extensions). Composed AFTER the\n * graph's own spawn-binding hook on the SAME event stream — the graph never swallows the\n * seam supervise() exposes. */\n readonly hooks?: RuntimeHooks\n /** The analyst lens registry `analyzes` edges resolve against. ENVIRONMENT — needed only for\n * lens analysts; an analyzes edge naming a graph NODE as its analyst needs no registry. */\n readonly analysts?: AnalystRegistry\n /** Directive registry. Default: the seeded kernel registry (`kernelPromptRegistry()`).\n *\n * NOT `SuperviseOptions.registry`, which is the `SuperviseRegistry` name→value table for\n * code-valued options. The two share a name and nothing else, and this one wins here — see\n * `GRAPH_REFUSED_SUPERVISE_OPTIONS`. */\n readonly registry?: PromptRegistry\n /** The run journal the edge ledger and every spawn/settle ride. Default: in-memory. */\n readonly journal?: SpawnJournal\n readonly blobs?: ResultBlobStore\n readonly runId?: string\n /** Product authority over every steer/answer instruction (the filter seam). `runGraph` observes\n * what it CHANGES: a narrowed instruction ledgers its steer traversal as `stripped`. */\n readonly authorizeMessage?: SuperviseOptions['authorizeMessage']\n}\n\nexport interface GraphResult<Out = unknown> {\n readonly result: SupervisedResult<Out>\n /** Every edge traversal, in occurrence order — the observable-edge contract. */\n readonly ledger: ReadonlyArray<EdgeTraversal>\n /** Edge ids whose traversal cap was hit — analyzes exhaustion included (observable here, never\n * a refusal). A DELEGATES cap paired with a `no-winner` result THROWS\n * ({@link GraphEdgeCapError}) instead of returning: only delegates caps refuse spawns, so only\n * they can have ended the run. A LIFECYCLE no-winner (`aborted` / `budget-exhausted`) returns\n * normally even with an exhausted delegates cap — the abort or the pool, not the cap, ended\n * that run, and the exhaustion stays observable here. */\n readonly exhaustedEdges: ReadonlyArray<string>\n readonly runId: string\n}\n\n/** `RunGraphOptions` with the brain REQUIRED — the shape the `/testing` entry's\n * `runGraphWithTestBrain` keeps accepting now that `brain` is a production option. */\nexport interface RunGraphTestOptions extends RunGraphOptions {\n readonly brain: ToolLoopChat\n}\n\n// ── Validation ─────────────────────────────────────────────────────────────────\n\n/** Validate the graph and resolve every directive BEFORE any compute is spent — an invalid\n * topology or an unknown directive is a configuration fault, never a mid-run surprise. */\nfunction validateGraph(\n graph: AgentGraph,\n registry: PromptRegistry,\n analysts: AnalystRegistry | undefined,\n): ValidatedGraph {\n if (!Array.isArray(graph.nodes) || graph.nodes.length === 0) {\n throw new ValidationError('runGraph: graph.nodes must be a non-empty array')\n }\n if (!Array.isArray(graph.edges) || graph.edges.length === 0) {\n throw new ValidationError('runGraph: graph.edges must be a non-empty array')\n }\n if (typeof graph.deliverable?.check !== 'function') {\n throw new ValidationError('runGraph: graph.deliverable is mandatory (termination oracle)')\n }\n if (typeof graph.budget !== 'object' || graph.budget === null) {\n throw new ValidationError('runGraph: graph.budget is mandatory (the conserved pool)')\n }\n return validateGraphTopology(graph.nodes, graph.edges, registry, analysts)\n}\n\n// ── The runner ─────────────────────────────────────────────────────────────────\n\n/**\n * Execute an {@link AgentGraph}. The root node becomes the supervisor (`supervise()` — the\n * execution core), each worker node is spawnable BY NODE ID (`spawn_worker` with\n * `profile: { name: '<node id>' }`; the node's canonical profile is pinned by the graph), each\n * delegates directive is appended to the worker profile's `prompt.instructions` per traversal,\n * and each analyzes edge becomes an analyst-on-settle route with a real DESTINATION. Every\n * traversal is ledgered and journaled.\n */\nexport function runGraph(graph: AgentGraph, opts: RunGraphOptions): Promise<GraphResult> {\n const { brain, ...runtimeOptions } = opts\n return superviseAgentGraph(graph, runtimeOptions, brain)\n}\n\n/** Alias for graph tests written before `RunGraphOptions.brain` was production. The production\n * entry accepts the same shape; this wrapper only keeps the `/testing` import path working. */\nexport function runGraphWithTestBrain(\n graph: AgentGraph,\n opts: RunGraphTestOptions,\n): Promise<GraphResult> {\n const { brain, ...runtimeOptions } = opts\n return superviseAgentGraph(graph, runtimeOptions, brain)\n}\n\n/**\n * The graph supervise run, as its own entry: the engine's `run-graph` preset node executes exactly\n * this, so the preset and `runGraph` are the same code path by construction (agent-runtime#982).\n */\n/**\n * Every refusal a graph earns before any compute, in one place: the authoring contract. `runGraph`\n * calls it FIRST so a malformed graph throws synchronously, exactly as it did before the engine\n * preset (agent-runtime#982) moved execution behind a promise.\n */\nexport function assertRunGraphAuthoring(\n graph: AgentGraph,\n opts: RunGraphOptions,\n brain?: ToolLoopChat,\n): ReturnType<typeof validateGraph> {\n assertRunGraphOptionKeys(opts)\n const registry = opts.registry ?? kernelPromptRegistry()\n const validated = validateGraph(graph, registry, opts.analysts)\n const { root } = validated\n // A caller brain and a harness driver are two answers to WHO makes the root's calls: refuse the\n // contradiction before any compute, and refuse a harness-driven root outright — the harness IS\n // that root's brain, so a supplied one would be silently ignored downstream.\n if (brain && opts.driverBackend) {\n throw new ValidationError(\n 'runGraph: brain and driverBackend are mutually exclusive — a caller brain makes the root model calls, a driverBackend places a harness that makes its own',\n )\n }\n if (brain && harnessRunsAgent(root.profile.harness)) {\n throw new ValidationError(\n `runGraph: root node '${root.id}' declares harness '${root.profile.harness}', so the harness drives it — a caller brain applies only to a router-brained root (profile.harness omitted or 'cli-base')`,\n )\n }\n if (!opts.backend && !opts.makeLeafAgent) {\n throw new ValidationError(\n 'runGraph: provide opts.backend (where nodes run) or opts.makeLeafAgent',\n )\n }\n return validated\n}\n\nexport function superviseAgentGraph(\n graph: AgentGraph,\n opts: RunGraphOptions,\n brain?: ToolLoopChat,\n): Promise<GraphResult> {\n const registry = opts.registry ?? kernelPromptRegistry()\n if (opts.runContext?.acquire !== undefined) {\n return withRunContext(opts.runContext, opts.signal, (runContext, signal) =>\n superviseAgentGraph(\n graph,\n {\n ...opts,\n runContext,\n ...(signal === undefined ? {} : { signal }),\n },\n brain,\n ),\n )\n }\n const validated = assertRunGraphAuthoring(graph, opts, brain)\n const { root } = validated\n // A durable graph needs its journal AND blob store on disk. `supervise()` already resolves this\n // for its own context (`options.journal ?? createFileRunContext(runDir).journal`), but the graph\n // passes an explicit `journal`/`blobs` — the edge ledger's twin writes ride on it — so the graph\n // must do the same resolution itself or its in-memory default SHADOWS the file stores supervise\n // would have built: `runGraph({ runDir })` journaled only to the process, a second process\n // silently restarted the run from scratch, and `runDir/spawn-journal.jsonl` never existed.\n // Layout owner: `createFileRunContext` (run-context.ts); keep these paths byte-identical to it.\n const journal =\n opts.journal ??\n opts.runContext?.journal ??\n (opts.runDir !== undefined\n ? new FileSpawnJournal(`${resolve(opts.runDir)}/spawn-journal.jsonl`)\n : new InMemorySpawnJournal())\n const blobs =\n opts.blobs ??\n opts.runContext?.blobs ??\n (opts.runDir !== undefined\n ? new FileResultBlobStore(`${resolve(opts.runDir)}/blobs`)\n : new InMemoryResultBlobStore())\n const runId =\n opts.runId ??\n opts.runContext?.runId ??\n `graph-${canonicalCandidateDigest(graph.nodes.map((n) => n.id)).slice('sha256:'.length, 'sha256:'.length + 12)}`\n const now = opts.now ?? Date.now\n\n // The graph layer: node pinning, analyst routes, continuity defaults and the edge ledger. A\n // `run_graph` subtask builds the same overlay around its nested manager.\n // `profileGuidance` composes the profile a manager authors, but a graph then swaps that\n // `{ name }` stub for the pinned node profile. Compose the pinned profile too, so every node\n // that runs carries its harness and model guidance. Composition is idempotent.\n const guidance = profileGuidanceComposer(opts.profileGuidance)\n const overlay = createGraphOverlay(validated, {\n registry,\n journal,\n runId,\n now,\n ...(guidance ? { guidance } : {}),\n ...(opts.authorizeSpawn ? { authorizeSpawn: opts.authorizeSpawn } : {}),\n })\n // Always present: the kernel refuses steer/answer whenever spawn authorization is on (the\n // graph's pinning IS spawn authorization), so a graph with no caller filter passes instructions\n // through unchanged rather than losing its steer channel. Only a caller filter can strip.\n const callerAuthorizeMessage = opts.authorizeMessage\n const authorizeMessage = overlay.observeMessages<\n Parameters<NonNullable<SuperviseOptions['authorizeMessage']>>[0]\n >((input) =>\n callerAuthorizeMessage ? callerAuthorizeMessage(input) : { instruction: input.instruction },\n )\n\n // ── Spawn-hook: bind ledger rows to concrete worker ids, then journal them ──\n const graphHooks: RuntimeHooks = {\n onEvent: (event) => {\n if (event.target !== 'agent.spawn' || event.phase !== 'after') return\n const payload = event.payload as { childId?: unknown; assignmentId?: unknown } | undefined\n if (typeof payload?.childId !== 'string' || typeof payload.assignmentId !== 'string') return\n return overlay.bindSpawn(event.parentId, payload.assignmentId, payload.childId)\n },\n }\n const hooks = composeRuntimeHooks(graphHooks, opts.hooks)\n const rootProfile = graphRootProfile(validated, registry)\n\n // Every configuration fault above throws SYNCHRONOUSLY (matching `supervise()`'s own\n // contract); only the run itself is asynchronous.\n const start = async (): Promise<GraphResult> => {\n const superviseOptions = {\n // Every forwarded option the caller set, including the ones nobody thought to list here.\n // `backend` rides along: the kernel derives every authorized LEAF from it, under the graph's\n // pinning. The root driver stays an explicit `driverBackend` choice: `rootDriverFromBackend:\n // false` stops supervise() defaulting one from the other, so where workers run never selects\n // where the root runs (the axis split every graph caller relies on).\n ...forwardedSuperviseOptions(opts),\n rootDriverFromBackend: false,\n // Graph-owned values come after the spread: the graph, not the caller, decides these.\n budget: graph.budget,\n deliverable: graph.deliverable,\n authorizeSpawn: overlay.authorizeSpawn,\n resolveSpawnProfile: overlay.resolveSpawnProfile,\n inheritSpawnRights: false,\n ...(opts.makeLeafAgent ? { makeLeafAgent: opts.makeLeafAgent } : {}),\n journal,\n blobs,\n runId,\n hooks,\n onCoordinationEvent: async (\n _context: unknown,\n _eventId: unknown,\n record: { readonly event: Parameters<typeof overlay.onCoordinationEvent>[0] },\n ) => overlay.onCoordinationEvent(record.event),\n // Lens routes resolve against the registry; agent routes carry their own analyst profile,\n // so a graph whose only analysts are nodes needs no registry at all.\n ...(overlay.routes.length > 0\n ? {\n analyzeOnSettle: overlay.routes,\n ...(opts.analysts ? { analysts: opts.analysts } : {}),\n }\n : {}),\n ...(Object.keys(overlay.continuityByProfile).length > 0\n ? { continuityByProfile: overlay.continuityByProfile }\n : {}),\n authorizeMessage,\n } satisfies SuperviseOptions\n const result =\n brain === undefined\n ? await supervise(rootProfile, graphTask(graph, root), superviseOptions)\n : await superviseWithTestBrain(rootProfile, graphTask(graph, root), {\n ...superviseOptions,\n brain,\n })\n\n const { ledger, exhaustedEdges, exhaustedDelegates } = await overlay.settle()\n // A LIFECYCLE ending (caller abort, exhausted budget) is its own complete explanation: the\n // cap did not end that run even when it was exhausted along the way, and blaming it would\n // misattribute the ending (and turn a caller-initiated abort into a throw). The exhaustion\n // stays observable in `exhaustedEdges` either way.\n const lifecycleEnded =\n result.kind === 'no-winner' &&\n (result.reason === 'aborted' ||\n result.reason === 'cancelled' ||\n result.reason === 'budget-exhausted')\n if (result.kind !== 'winner' && !lifecycleEnded && exhaustedDelegates.length > 0) {\n // Fail LOUD: the backstop, not the task, ended this run. The evidence rides on the error.\n // Only DELEGATES caps refuse spawns, so only they can be the cause named here.\n throw new GraphEdgeCapError(exhaustedDelegates, ledger, result)\n }\n return { result, ledger, exhaustedEdges, runId }\n }\n\n return start()\n}\n\n/** The root task: the graph's own framing. The deliverable (mandatory) is the termination; the\n * task names what the topology exists to produce. */\nfunction graphTask(graph: AgentGraph, root: GraphNode): string {\n const describe = graph.deliverable.describe\n return (\n describe ?? `Deliver the graph's deliverable by driving your worker nodes (root: '${root.id}').`\n )\n}\n"],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as syncDurableDirectory, i as publishExclusiveDurableFile } from "./durable-file-B_eJr6Mb.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Br as terminateProcessTreeAndConfirm, Jn as linkAbort, Or as runSettledCommand, Pt as createExecutor, Yn as runAbortable, da as detachedSnapshot } from "./supervisor-fq4JGynd.js";
|
|
3
3
|
import { i as ConfigError } from "./errors-DodWX-cb.js";
|
|
4
|
-
import { E as defaultStructuralRolloutPolicy, Q as streamAgentTurn, Y as optimizerMethod, Z as collectAgentTurn, a as reconcileInterruptedSearchCalls, b as improveSearchCost, c as searchExecutor, d as taggedLedger, i as isSearchEnvironmentFault, n as assertSearchLanes, s as searchCallTags, v as decideClosedSearch } from "./search-executor-
|
|
4
|
+
import { E as defaultStructuralRolloutPolicy, Q as streamAgentTurn, Y as optimizerMethod, Z as collectAgentTurn, a as reconcileInterruptedSearchCalls, b as improveSearchCost, c as searchExecutor, d as taggedLedger, i as isSearchEnvironmentFault, n as assertSearchLanes, s as searchCallTags, v as decideClosedSearch } from "./search-executor-C-b4NaFl.js";
|
|
5
5
|
import { B as verifyCanonicalCandidateDocument, L as immutableCandidateValue, M as canonicalCandidateBytes$1, N as canonicalCandidateDigest$1, P as canonicalCandidateDocument, R as omitTopLevelDigest, xt as armDeadlineTimer, z as sha256Bytes$1 } from "./workspace-streams-CcoARX4v.js";
|
|
6
6
|
import { a as concreteProfileModel, t as assertExecutableAgentProfile } from "./model-policy-CyCUwHed.js";
|
|
7
7
|
import { t as runAnalystLoop } from "./analyst-loop-DZw5QWT9.js";
|
|
@@ -4090,4 +4090,4 @@ function sameOrderedValues(left, right) {
|
|
|
4090
4090
|
//#endregion
|
|
4091
4091
|
export { commandVerifier as $, agentImprovementTargetInput as A, assertCandidateValidator as B, optimizationActivationReceiptFromMetadata as C, agentImprovementProfileSurfaceDigest as D, agentImprovementProfileDiffs as E, isAgentImprovementProfileSurface as F, rawTraceDistiller as G, parseExecutionRef as H, isAgentProfileMeasuredSurface as I, normalizeRolloutPolicy as J, ROLLOUT_POLICY_EXTENSION as K, improve as L, agentProfileImprovementStateDigest as M, assertProfileImprovementTargetsShareIdentity as N, agentImprovementProfileSurfaceInput as O, buildAgentImprovementActivationTargets as P, agenticGenerator as Q, createCommandProfileTrainer as R, createOptimizationActivationReceipt as S, AGENT_PROFILE_MEASURED_SURFACES as T, privateValuePaths as U, assertProfileTrainingIsHeldOut as V, withMethodRuntimeControls as W, serializeRolloutPolicy as X, parseRolloutPolicy as Y, structuralRolloutPolicyFromProfile as Z, profilePolicyWithBudget as _, executeAgentCandidateExperimentCell as a, profileTaskScenarioIdentity as b, requireSealedCandidateExperiment as c, verifyAgentImprovementActivation as d, defaultBuildPrompt as et, verifyAgentImprovementProposal as f, profileImprovementMetadata as g, createProfileImprovementCostLedger as h, createAgentImprovementProposal as i, agentImprovementTargetProfileDiffs as j, agentImprovementTargetDigest as k, reviewAgentImprovementProposal as l, verifyCandidateExecutionEvidence as m, createAgentImprovementActivation as n, proposeAgentImprovement as o, verifyAgentImprovementReview as p, applyRolloutPolicyToProfile as q, createAgentImprovementMeasuredComparison as r, proposeAgentProfileImprovement as s, AgentCandidateExperimentCellExecutionError as t, runAgentCandidateExperiment as u, profilePreparationAccounting as v, AGENT_IMPROVEMENT_PROFILE_SURFACES as w, sealProfileImprovementBenchmark as x, profileStateDigest as y, searchMethod as z };
|
|
4092
4092
|
|
|
4093
|
-
//# sourceMappingURL=improvement-cycle-
|
|
4093
|
+
//# sourceMappingURL=improvement-cycle-B5Z8cHKx.js.map
|