@tangle-network/agent-runtime 0.121.0 → 0.123.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-DdIpwQ0k.js → activation-B7sTehZB.js} +3 -3
- package/dist/{activation-DdIpwQ0k.js.map → activation-B7sTehZB.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -3
- package/dist/candidate-execution/index.js +4 -4
- package/dist/{candidate-execution-DDkSRPjY.js → candidate-execution-BFpq-Xi6.js} +4 -4
- package/dist/{candidate-execution-DDkSRPjY.js.map → candidate-execution-BFpq-Xi6.js.map} +1 -1
- package/dist/{environment-provider-Bh4nX2qt.d.ts → environment-provider-CEjwunXO.d.ts} +105 -11
- package/dist/{environment-provider-DChfYm2-.js → environment-provider-CY22kUQH.js} +4 -85
- package/dist/environment-provider-CY22kUQH.js.map +1 -0
- package/dist/environment-provider.d.ts +1 -1
- package/dist/environment-provider.js +1 -1
- package/dist/{improvement-cycle-zjR-MXwK.js → improvement-cycle-BcwsSbT-.js} +4 -4
- package/dist/{improvement-cycle-zjR-MXwK.js.map → improvement-cycle-BcwsSbT-.js.map} +1 -1
- package/dist/{index-I35151Fr.d.ts → index-BKSzgMvA.d.ts} +5 -5
- package/dist/{index-BLsKcxNd.d.ts → index-CKply5aj.d.ts} +3 -3
- package/dist/{index-CGADWaa_.d.ts → index-CyXinqJw.d.ts} +1213 -849
- package/dist/index.d.ts +6 -6
- package/dist/index.js +12 -12
- package/dist/intelligence.d.ts +1 -1
- package/dist/intelligence.js +6 -6
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +7 -7
- package/dist/{knowledge-B1B3BsQZ.js → knowledge-Cuvb21T7.js} +5 -5
- package/dist/{knowledge-B1B3BsQZ.js.map → knowledge-Cuvb21T7.js.map} +1 -1
- package/dist/knowledge.d.ts +1 -1
- package/dist/knowledge.js +1 -1
- package/dist/{loop-runner-bin-BeG9vTdE.d.ts → loop-runner-bin-BjnNpN5m.d.ts} +3 -3
- package/dist/{loop-runner-bin-CXJWdfJ4.js → loop-runner-bin-Clhj8gy5.js} +3 -3
- package/dist/{loop-runner-bin-CXJWdfJ4.js.map → loop-runner-bin-Clhj8gy5.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +2 -2
- package/dist/mcp/index.d.ts +3 -3
- package/dist/mcp/index.js +5 -5
- package/dist/{openai-tools-CVgLNp04.js → openai-tools-BwTsBfd-.js} +2 -2
- package/dist/{openai-tools-CVgLNp04.js.map → openai-tools-BwTsBfd-.js.map} +1 -1
- package/dist/{prepare-DpV6np9e.js → prepare--8EvLqCr.js} +2 -2
- package/dist/{prepare-DpV6np9e.js.map → prepare--8EvLqCr.js.map} +1 -1
- package/dist/primeintellect/index.d.ts +1 -1
- package/dist/{protected-model-port-vQLBRoAQ.js → protected-model-port-CXVfOUu_.js} +2 -2
- package/dist/{protected-model-port-vQLBRoAQ.js.map → protected-model-port-CXVfOUu_.js.map} +1 -1
- package/dist/{runtime-Bp3NwC0A.js → runtime-OI7oLLec.js} +463 -52
- package/dist/runtime-OI7oLLec.js.map +1 -0
- package/dist/{spawn-journal-IeXpidO2.js → spawn-journal-DsZKDqeh.js} +5 -3
- package/dist/spawn-journal-DsZKDqeh.js.map +1 -0
- package/dist/{structural-rollout-DQHO3b2Y.js → structural-rollout-C4Jv_7vt.js} +3 -3
- package/dist/{structural-rollout-DQHO3b2Y.js.map → structural-rollout-C4Jv_7vt.js.map} +1 -1
- package/dist/{supervise-BHHMtwP9.js → supervise-Dwq16u8n.js} +451 -55
- package/dist/supervise-Dwq16u8n.js.map +1 -0
- package/dist/{supervisor-CpT9yAxL.js → supervisor-DjZ82HIB.js} +166 -23
- package/dist/supervisor-DjZ82HIB.js.map +1 -0
- package/dist/testing.js +12 -12
- package/dist/{workspace-archive-B4SkNJjw.js → workspace-archive-BQxvkypI.js} +2 -2
- package/dist/{workspace-archive-B4SkNJjw.js.map → workspace-archive-BQxvkypI.js.map} +1 -1
- package/package.json +10 -9
- package/dist/environment-provider-DChfYm2-.js.map +0 -1
- package/dist/runtime-Bp3NwC0A.js.map +0 -1
- package/dist/spawn-journal-IeXpidO2.js.map +0 -1
- package/dist/supervise-BHHMtwP9.js.map +0 -1
- package/dist/supervisor-CpT9yAxL.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { n as AnalystError, r as BackendTransportError, s as PlannerError, u as ValidationError } from "./errors-DEAvWQPy.js";
|
|
2
2
|
import { i as normalizeBackendStreamEvent, o as newRuntimeSession, s as nowIso } from "./backends-CiOCyRHb.js";
|
|
3
|
-
import { i as InMemorySpawnJournal, r as InMemoryResultBlobStore, v as isTraceAnalysisStore } from "./spawn-journal-
|
|
3
|
+
import { i as InMemorySpawnJournal, r as InMemoryResultBlobStore, v as isTraceAnalysisStore } from "./spawn-journal-DsZKDqeh.js";
|
|
4
4
|
import { a as randomSuffix, c as stringifySafe, f as zeroTokenUsage, r as isAbortError, s as sleep, t as addTokenUsage } from "./util-MVgdwuIS.js";
|
|
5
5
|
import { i as redactProtectedValue, r as redactProtectedReason } from "./protected-redaction--F3v1oo8.js";
|
|
6
|
-
import {
|
|
7
|
-
import { C as observe, O as strategyAuthorMethod, b as sample, v as refine, x as sampleThenRefine, y as runAgentic } from "./structural-rollout-
|
|
8
|
-
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-C7iJOWm3.js";
|
|
6
|
+
import { _t as routerChatWithUsage, bt as runBrainLoop, et as rollingDispatch, ht as routerBrain, l as withDriverExecutor, m as settledToIteration, n as createSupervisor } from "./supervisor-DjZ82HIB.js";
|
|
7
|
+
import { C as observe, O as strategyAuthorMethod, b as sample, v as refine, x as sampleThenRefine, y as runAgentic } from "./structural-rollout-C4Jv_7vt.js";
|
|
8
|
+
import { i as notifyRuntimeHookEvent, t as composeRuntimeHooks } from "./runtime-hooks-C7iJOWm3.js";
|
|
9
9
|
import { a as notifySandboxEventObserver, i as mapSandboxToolEvent, r as mapSandboxEvent, t as createSandboxToolPartState } from "./sandbox-events-Yhd1GYWl.js";
|
|
10
|
-
import {
|
|
10
|
+
import { $t as formatPromptHandle, Ct as createWorktreeCliExecutor, Et as createPushTraceSource, Ft as probeSandboxCapabilities, Mt as runAgentRounds, Pt as createSandboxLineage, St as createExecutorRegistry, en as kernelPromptRegistry, in as gateOnDeliverable, jt as defaultSelectWinner, n as supervise, r as workerFromBackend, xt as createExecutor } from "./supervise-Dwq16u8n.js";
|
|
11
11
|
import { CODING_HARNESSES, InMemoryTraceStore, OUTPUT_VALUE, benjaminiHochberg, buildTrajectory, computeFindingId as computeFindingId$1, confidenceInterval, expandProfileAxes, harnessAxisOf, makeFinding as makeFinding$1, pairedBootstrap, paretoFrontier, scoreKnowledgeReadiness, wilcoxonSignedRank, wilson } from "@tangle-network/agent-eval";
|
|
12
12
|
import { heldoutSignificance, runProfileMatrix } from "@tangle-network/agent-eval/campaign";
|
|
13
|
-
import { canonicalCandidateDigest, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
13
|
+
import { agentProfileSchema, canonicalCandidateDigest, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
14
14
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
15
15
|
import { appendFileSync, chmodSync, constants, copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readlinkSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
16
16
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
@@ -1297,6 +1297,36 @@ function resolveSandboxClient(opts) {
|
|
|
1297
1297
|
//#endregion
|
|
1298
1298
|
//#region src/runtime/steering-drivers.ts
|
|
1299
1299
|
/**
|
|
1300
|
+
* Interpret a {@link SteeringDirectiveData} as a loop `Driver` — the ONE interpreter both
|
|
1301
|
+
* control policies share. The directive is data; only `applyContinuation` (how the caller's
|
|
1302
|
+
* opaque Task carries a steering string) remains code, exactly as `taskToPrompt` does.
|
|
1303
|
+
*/
|
|
1304
|
+
function steeringDriver(directive, applyContinuation, name) {
|
|
1305
|
+
const driverName = name ?? directive.kind;
|
|
1306
|
+
const maxIterations = directive.maxTraversals;
|
|
1307
|
+
const continuationFor = (passed) => directive.kind === "naive" ? directive.continuation : passed ? directive.onPass : directive.onFail;
|
|
1308
|
+
const rationale = directive.kind === "naive" ? "naive fixed continuation (no grade signal)" : "dumb pass/fail-only continuation (no grader findings)";
|
|
1309
|
+
return {
|
|
1310
|
+
name: driverName,
|
|
1311
|
+
plan(task, history) {
|
|
1312
|
+
if (history.length === 0) return Promise.resolve([task]);
|
|
1313
|
+
const passed = history[history.length - 1]?.verdict?.valid === true;
|
|
1314
|
+
if (passed) return Promise.resolve([]);
|
|
1315
|
+
if (history.length >= maxIterations) return Promise.resolve([]);
|
|
1316
|
+
return Promise.resolve([applyContinuation(task, continuationFor(passed))]);
|
|
1317
|
+
},
|
|
1318
|
+
decide(history) {
|
|
1319
|
+
return decideUntilValidOrCapped(history, maxIterations);
|
|
1320
|
+
},
|
|
1321
|
+
describePlan() {
|
|
1322
|
+
return {
|
|
1323
|
+
kind: "refine",
|
|
1324
|
+
rationale
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1300
1330
|
* Shared `decide()` for the steering drivers. Verbatim semantics of the
|
|
1301
1331
|
* reference refine driver: a valid iteration anywhere → terminal `'pick-winner'`;
|
|
1302
1332
|
* otherwise `'refine'` (non-terminal, run another shot) while history is under
|
|
@@ -1318,26 +1348,17 @@ function decideUntilValidOrCapped(history, maxIterations) {
|
|
|
1318
1348
|
* attributable to the pass/fail bit, and any lift of `refine` over `dumb` is
|
|
1319
1349
|
* attributable to the grader's findings.
|
|
1320
1350
|
*/
|
|
1351
|
+
/** Thin compatibility wrapper over {@link steeringDriver} for the naive (no-signal) control.
|
|
1352
|
+
* @deprecated The policy is DATA now — build the directive and interpret it:
|
|
1353
|
+
* `steeringDriver({ kind: 'naive', continuation, maxTraversals }, applyContinuation)`. This
|
|
1354
|
+
* wrapper survives for existing callers and will be removed in the next major. */
|
|
1321
1355
|
function naiveDriver(options) {
|
|
1322
1356
|
const { continuation, applyContinuation, maxIterations, name = "naive" } = options;
|
|
1323
|
-
return {
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
if (history.length >= maxIterations) return Promise.resolve([]);
|
|
1329
|
-
return Promise.resolve([applyContinuation(task, continuation)]);
|
|
1330
|
-
},
|
|
1331
|
-
decide(history) {
|
|
1332
|
-
return decideUntilValidOrCapped(history, maxIterations);
|
|
1333
|
-
},
|
|
1334
|
-
describePlan() {
|
|
1335
|
-
return {
|
|
1336
|
-
kind: "refine",
|
|
1337
|
-
rationale: "naive fixed continuation (no grade signal)"
|
|
1338
|
-
};
|
|
1339
|
-
}
|
|
1340
|
-
};
|
|
1357
|
+
return steeringDriver({
|
|
1358
|
+
kind: "naive",
|
|
1359
|
+
continuation,
|
|
1360
|
+
maxTraversals: maxIterations
|
|
1361
|
+
}, applyContinuation, name);
|
|
1341
1362
|
}
|
|
1342
1363
|
/**
|
|
1343
1364
|
* `dumbDriver` — the pass/fail-only steering control.
|
|
@@ -1353,28 +1374,18 @@ function naiveDriver(options) {
|
|
|
1353
1374
|
* grader's `notes`, dumb reads only the pass/fail bit, so the difference is
|
|
1354
1375
|
* exactly the value the findings add over a bare boolean.
|
|
1355
1376
|
*/
|
|
1377
|
+
/** Thin compatibility wrapper over {@link steeringDriver} for the dumb (pass/fail-only) control.
|
|
1378
|
+
* @deprecated The policy is DATA now — build the directive and interpret it:
|
|
1379
|
+
* `steeringDriver({ kind: 'dumb', onPass, onFail, maxTraversals }, applyContinuation)`. This
|
|
1380
|
+
* wrapper survives for existing callers and will be removed in the next major. */
|
|
1356
1381
|
function dumbDriver(options) {
|
|
1357
1382
|
const { onPass, onFail, applyContinuation, maxIterations, name = "dumb" } = options;
|
|
1358
|
-
return {
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
if (history.length >= maxIterations) return Promise.resolve([]);
|
|
1365
|
-
const continuation = passed ? onPass : onFail;
|
|
1366
|
-
return Promise.resolve([applyContinuation(task, continuation)]);
|
|
1367
|
-
},
|
|
1368
|
-
decide(history) {
|
|
1369
|
-
return decideUntilValidOrCapped(history, maxIterations);
|
|
1370
|
-
},
|
|
1371
|
-
describePlan() {
|
|
1372
|
-
return {
|
|
1373
|
-
kind: "refine",
|
|
1374
|
-
rationale: "dumb pass/fail-only continuation (no grader findings)"
|
|
1375
|
-
};
|
|
1376
|
-
}
|
|
1377
|
-
};
|
|
1383
|
+
return steeringDriver({
|
|
1384
|
+
kind: "dumb",
|
|
1385
|
+
onPass,
|
|
1386
|
+
onFail,
|
|
1387
|
+
maxTraversals: maxIterations
|
|
1388
|
+
}, applyContinuation, name);
|
|
1378
1389
|
}
|
|
1379
1390
|
//#endregion
|
|
1380
1391
|
//#region src/runtime/define-leaderboard.ts
|
|
@@ -1383,7 +1394,7 @@ function dumbDriver(options) {
|
|
|
1383
1394
|
*
|
|
1384
1395
|
* A product's harness×model leaderboard is always the same assembly: expand a
|
|
1385
1396
|
* base profile across the harness×model axes (`expandProfileAxes`), run every
|
|
1386
|
-
* (profile, case) cell as a driven loop (`loopDispatch` +
|
|
1397
|
+
* (profile, case) cell as a driven loop (`loopDispatch` + the naive steering directive), score
|
|
1387
1398
|
* with the domain's grader, and emit ONE `runProfileMatrix` call. Each product
|
|
1388
1399
|
* hand-rolled that assembly (~650 lines each) and re-hit the same footguns:
|
|
1389
1400
|
* stale cell-cache reuse, zero-token stub cells, missing model snapshots.
|
|
@@ -1573,11 +1584,11 @@ function defineLeaderboard(spec) {
|
|
|
1573
1584
|
const axis = harnessAxisOf(cellProfile);
|
|
1574
1585
|
const modelId = bareModel(axis?.model ?? models[0] ?? "");
|
|
1575
1586
|
return {
|
|
1576
|
-
driver:
|
|
1587
|
+
driver: steeringDriver({
|
|
1588
|
+
kind: "naive",
|
|
1577
1589
|
continuation: "",
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
}),
|
|
1590
|
+
maxTraversals: shots
|
|
1591
|
+
}, (task) => task, "naive"),
|
|
1581
1592
|
agentRun: {
|
|
1582
1593
|
profile: cellProfile,
|
|
1583
1594
|
taskToPrompt: (s) => `${promptOf(s)}\n\n<!-- independent-attempt:${shotNonce++} -->`,
|
|
@@ -2904,7 +2915,7 @@ async function trajectoryReport(journal, blobs, root, options = {}) {
|
|
|
2904
2915
|
const events = await journal.loadTree(root);
|
|
2905
2916
|
if (events === void 0) throw new Error(`trajectoryReport: no journaled tree for root '${root}'`);
|
|
2906
2917
|
const spawns = events.filter(isNodeCreation).sort(bySeq);
|
|
2907
|
-
const closes = events.filter((ev) => ev.kind !== "spawned" && ev.kind !== "waiting" && ev.kind !== "metered" && ev.kind !== "materialized" && ev.kind !== "execution-bound").sort(bySeq);
|
|
2918
|
+
const closes = events.filter((ev) => ev.kind !== "spawned" && ev.kind !== "waiting" && ev.kind !== "metered" && ev.kind !== "materialized" && ev.kind !== "execution-bound" && ev.kind !== "edge" && ev.kind !== "trace-unpropagated").sort(bySeq);
|
|
2908
2919
|
const nodes = /* @__PURE__ */ new Map();
|
|
2909
2920
|
for (const ev of spawns) nodes.set(ev.id, {
|
|
2910
2921
|
id: ev.id,
|
|
@@ -4648,6 +4659,406 @@ function deriveTurnSignal(callerSignal, timeoutMs) {
|
|
|
4648
4659
|
};
|
|
4649
4660
|
}
|
|
4650
4661
|
//#endregion
|
|
4662
|
+
//#region src/runtime/supervise/graph.ts
|
|
4663
|
+
/**
|
|
4664
|
+
*
|
|
4665
|
+
* `runGraph` — agent graphs: profiles as nodes, registry-backed prompt directives as edges.
|
|
4666
|
+
*
|
|
4667
|
+
* A topology is PLAIN DATA an agent can author in a few lines: nodes are canonical
|
|
4668
|
+
* `AgentProfile`s (the ONLY way a node is described — no role-builder functions), edges are typed
|
|
4669
|
+
* values carrying versioned {@link PromptHandle} directives, `deliverable` (termination) and
|
|
4670
|
+
* `budget` (one conserved pool) are mandatory. Driver↔worker is the two-node cyclic instance;
|
|
4671
|
+
* "agent 3 analyzes 1 and 2 and reports to 1" is ONE edge, not a framework.
|
|
4672
|
+
*
|
|
4673
|
+
* NOT A SECOND SCHEDULER. `runGraph` is an interpretation layer over what already runs:
|
|
4674
|
+
* `supervise()` is the execution core — the same `supervisorAgent`/`driverAgent` machinery,
|
|
4675
|
+
* `makeWorkerAgent` seam, conserved-pool budget, and deliverable-gated settlement every
|
|
4676
|
+
* supervised run uses. (`runLoop` is a deprecated alias of `runAgentRounds` and is deliberately
|
|
4677
|
+
* NOT the substrate here.) What the graph layer ADDS is exactly what a bespoke driver loop never
|
|
4678
|
+
* had:
|
|
4679
|
+
*
|
|
4680
|
+
* 1. **Node pinning** — a spawn names a node (`profile.name` = node id) and the node's canonical
|
|
4681
|
+
* profile is what runs; a driver cannot smuggle capabilities into a worker it did not define.
|
|
4682
|
+
* 2. **Observable edges** — every delegates/analyzes traversal lands in an EDGE LEDGER
|
|
4683
|
+
* (`delivered | stripped | empty | unpropagated`, with byte counts), in memory on
|
|
4684
|
+
* the result AND as `edge` events in the run journal. The motivating incident: a filter
|
|
4685
|
+
* silently replaced 1,700-char steering with 241 chars of boilerplate for three rounds and
|
|
4686
|
+
* NO artifact said so — an unobservable edge cannot be trusted and its directive cannot be
|
|
4687
|
+
* optimized.
|
|
4688
|
+
* 3. **Directives as data** — edge text lives in the prompt registry (`<surface>/v<n>`), so every
|
|
4689
|
+
* edge is a versioned optimization target, never prose hardcoded in a builder function.
|
|
4690
|
+
* 4. **Per-edge traversal caps** — the cyclic-graph backstop. A delegates edge whose cap is
|
|
4691
|
+
* exhausted REFUSES further traversals (fail loud), so a cycle cannot spin the pool dry.
|
|
4692
|
+
*
|
|
4693
|
+
* ORACLES ARE ENVIRONMENT, NEVER NODES. Graders/verifiers must not be addressable in the graph —
|
|
4694
|
+
* an edge to them leaks the rubric. Analysts (`analyzes` edges) are LENSES from the environment's
|
|
4695
|
+
* registry reading trace evidence; they are not nodes either, and a graph that names a node id as
|
|
4696
|
+
* its analyst is refused.
|
|
4697
|
+
*
|
|
4698
|
+
* @experimental
|
|
4699
|
+
*/
|
|
4700
|
+
/** Default per-edge traversal cap — the cyclic-graph backstop when an edge names none. */
|
|
4701
|
+
const defaultEdgeTraversalCap = 32;
|
|
4702
|
+
/** A delegates edge exhausted its traversal cap and the run produced no winner: the cap, not the
|
|
4703
|
+
* task, ended it. Carries the full evidence so failing loud loses nothing. */
|
|
4704
|
+
var GraphEdgeCapError = class extends Error {
|
|
4705
|
+
exhaustedEdges;
|
|
4706
|
+
ledger;
|
|
4707
|
+
result;
|
|
4708
|
+
constructor(exhaustedEdges, ledger, result) {
|
|
4709
|
+
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.`);
|
|
4710
|
+
this.name = "GraphEdgeCapError";
|
|
4711
|
+
this.exhaustedEdges = exhaustedEdges;
|
|
4712
|
+
this.ledger = ledger;
|
|
4713
|
+
this.result = result;
|
|
4714
|
+
}
|
|
4715
|
+
};
|
|
4716
|
+
function edgeId(edge) {
|
|
4717
|
+
return edge.kind === "delegates" ? `delegates:${edge.from}->${edge.to}` : `analyzes:${edge.analyst}:${edge.over.join("+")}->${edge.to}`;
|
|
4718
|
+
}
|
|
4719
|
+
/** Validate the graph and resolve every directive BEFORE any compute is spent — an invalid
|
|
4720
|
+
* topology or an unknown directive is a configuration fault, never a mid-run surprise. */
|
|
4721
|
+
function validateGraph(graph, registry, analysts) {
|
|
4722
|
+
if (!Array.isArray(graph.nodes) || graph.nodes.length === 0) throw new ValidationError("runGraph: graph.nodes must be a non-empty array");
|
|
4723
|
+
if (!Array.isArray(graph.edges) || graph.edges.length === 0) throw new ValidationError("runGraph: graph.edges must be a non-empty array");
|
|
4724
|
+
if (typeof graph.deliverable?.check !== "function") throw new ValidationError("runGraph: graph.deliverable is mandatory (termination oracle)");
|
|
4725
|
+
if (typeof graph.budget !== "object" || graph.budget === null) throw new ValidationError("runGraph: graph.budget is mandatory (the conserved pool)");
|
|
4726
|
+
const byId = /* @__PURE__ */ new Map();
|
|
4727
|
+
for (const node of graph.nodes) {
|
|
4728
|
+
if (typeof node.id !== "string" || node.id.length === 0) throw new ValidationError("runGraph: every node needs a non-empty string id");
|
|
4729
|
+
if (byId.has(node.id)) throw new ValidationError(`runGraph: duplicate node id '${node.id}'`);
|
|
4730
|
+
const parsed = agentProfileSchema.safeParse(node.profile);
|
|
4731
|
+
if (!parsed.success) throw new ValidationError(`runGraph: node '${node.id}' has an invalid AgentProfile: ${parsed.error.message}`);
|
|
4732
|
+
if (node.profile.name !== node.id) throw new ValidationError(`runGraph: node '${node.id}' has profile.name ${JSON.stringify(node.profile.name)} — profile.name IS the node identity (node pinning and analyst routing match on it) and must equal the node id`);
|
|
4733
|
+
byId.set(node.id, node);
|
|
4734
|
+
}
|
|
4735
|
+
const requireNode = (id, where) => {
|
|
4736
|
+
const node = byId.get(id);
|
|
4737
|
+
if (!node) throw new ValidationError(`runGraph: ${where} references unknown node '${id}'`);
|
|
4738
|
+
return node;
|
|
4739
|
+
};
|
|
4740
|
+
const delegates = graph.edges.filter((edge) => edge.kind === "delegates");
|
|
4741
|
+
const analyzes = graph.edges.filter((edge) => edge.kind === "analyzes");
|
|
4742
|
+
if (delegates.length === 0) throw new ValidationError("runGraph: at least one delegates edge is required (who spawns whom)");
|
|
4743
|
+
for (const edge of graph.edges) registry.resolve(edge.directive);
|
|
4744
|
+
for (const edge of delegates) {
|
|
4745
|
+
requireNode(edge.from, edgeId(edge));
|
|
4746
|
+
requireNode(edge.to, edgeId(edge));
|
|
4747
|
+
if (edge.from === edge.to) throw new ValidationError(`runGraph: ${edgeId(edge)} delegates to itself — the driver↔worker cycle is the settle-return loop, not a self-edge`);
|
|
4748
|
+
}
|
|
4749
|
+
const delegatedTo = new Set(delegates.map((edge) => edge.to));
|
|
4750
|
+
const roots = [...new Set(delegates.map((edge) => edge.from))].filter((id) => !delegatedTo.has(id));
|
|
4751
|
+
if (roots.length !== 1) throw new ValidationError(`runGraph: expected exactly ONE root (a node that delegates and is never delegated to), found ${roots.length === 0 ? "none — delegates edges form a cycle with no entry" : roots.join(", ")}. P0 executes driver↔worker(s); nested driver graphs are P3.`);
|
|
4752
|
+
const root = requireNode(roots[0], "root resolution");
|
|
4753
|
+
for (const edge of delegates) if (edge.from !== root.id) throw new ValidationError(`runGraph: ${edgeId(edge)} delegates from a non-root node — P0 executes one driver over its workers (the 2-node cyclic case, star-generalized); deeper delegation is P3`);
|
|
4754
|
+
const analystIds = /* @__PURE__ */ new Set();
|
|
4755
|
+
for (const edge of analyzes) {
|
|
4756
|
+
if (analystIds.has(edge.analyst)) throw new ValidationError(`runGraph: two analyzes edges share analyst '${edge.analyst}' — one analyzes edge per analyst lens (traversals are ledgered by analyst id; a second edge would silently absorb the first's). Register the lens under a second id for a second edge.`);
|
|
4757
|
+
analystIds.add(edge.analyst);
|
|
4758
|
+
if (byId.has(edge.analyst)) throw new ValidationError(`runGraph: ${edgeId(edge)} names node '${edge.analyst}' as its analyst — oracles and analysts are ENVIRONMENT, never nodes; pass a lens id from RunGraphOptions.analysts`);
|
|
4759
|
+
if (!analysts) throw new ValidationError(`runGraph: ${edgeId(edge)} needs RunGraphOptions.analysts (the lens registry its analyst resolves against)`);
|
|
4760
|
+
if (!analysts.kinds.some((kind) => kind.id === edge.analyst)) throw new ValidationError(`runGraph: ${edgeId(edge)} analyst '${edge.analyst}' is not in the analysts registry (known: ${analysts.kinds.map((kind) => kind.id).join(", ") || "none"})`);
|
|
4761
|
+
if (edge.over.length === 0) throw new ValidationError(`runGraph: ${edgeId(edge)} must analyze at least one node`);
|
|
4762
|
+
for (const over of edge.over) requireNode(over, edgeId(edge));
|
|
4763
|
+
requireNode(edge.to, edgeId(edge));
|
|
4764
|
+
}
|
|
4765
|
+
const workers = /* @__PURE__ */ new Map();
|
|
4766
|
+
const delegatesByWorker = /* @__PURE__ */ new Map();
|
|
4767
|
+
for (const edge of delegates) {
|
|
4768
|
+
if (delegatesByWorker.has(edge.to)) throw new ValidationError(`runGraph: node '${edge.to}' is the target of two delegates edges — one delegation directive per worker node (version the directive instead of forking the edge)`);
|
|
4769
|
+
delegatesByWorker.set(edge.to, edge);
|
|
4770
|
+
workers.set(edge.to, requireNode(edge.to, edgeId(edge)));
|
|
4771
|
+
}
|
|
4772
|
+
for (const node of graph.nodes) if (node.id !== root.id && !workers.has(node.id)) throw new ValidationError(`runGraph: node '${node.id}' has no delegates edge to it — an unreachable node never runs`);
|
|
4773
|
+
return {
|
|
4774
|
+
root,
|
|
4775
|
+
workers,
|
|
4776
|
+
delegatesByWorker,
|
|
4777
|
+
analyzes
|
|
4778
|
+
};
|
|
4779
|
+
}
|
|
4780
|
+
const byteLength = (text) => Buffer.byteLength(text, "utf8");
|
|
4781
|
+
function stringifyPayload(payload) {
|
|
4782
|
+
if (typeof payload === "string") return payload;
|
|
4783
|
+
try {
|
|
4784
|
+
return JSON.stringify(payload) ?? String(payload);
|
|
4785
|
+
} catch {
|
|
4786
|
+
return String(payload);
|
|
4787
|
+
}
|
|
4788
|
+
}
|
|
4789
|
+
/**
|
|
4790
|
+
* Execute an {@link AgentGraph}. The root node becomes the supervisor (`supervise()` — the
|
|
4791
|
+
* execution core), each worker node is spawnable BY NODE ID (`spawn_agent` with
|
|
4792
|
+
* `profile: { name: '<node id>' }`; the node's canonical profile is pinned by the graph), each
|
|
4793
|
+
* delegates directive is appended to the worker profile's `prompt.instructions` per traversal,
|
|
4794
|
+
* and each analyzes edge becomes an analyst-on-settle route with a real DESTINATION. Every
|
|
4795
|
+
* traversal is ledgered and journaled.
|
|
4796
|
+
*/
|
|
4797
|
+
function runGraph(graph, opts) {
|
|
4798
|
+
const registry = opts.registry ?? kernelPromptRegistry();
|
|
4799
|
+
const { root, workers, delegatesByWorker, analyzes } = validateGraph(graph, registry, opts.analysts);
|
|
4800
|
+
if (!opts.backend && !opts.makeWorkerAgent) throw new ValidationError("runGraph: provide opts.backend (where nodes run) or opts.makeWorkerAgent");
|
|
4801
|
+
const journal = opts.journal ?? new InMemorySpawnJournal();
|
|
4802
|
+
const blobs = opts.blobs ?? new InMemoryResultBlobStore();
|
|
4803
|
+
const runId = opts.runId ?? `graph-${canonicalCandidateDigest(graph.nodes.map((n) => n.id)).slice(7, 19)}`;
|
|
4804
|
+
const now = opts.now ?? Date.now;
|
|
4805
|
+
const ledger = [];
|
|
4806
|
+
const journaled = /* @__PURE__ */ new Set();
|
|
4807
|
+
const traversalCounts = /* @__PURE__ */ new Map();
|
|
4808
|
+
const exhausted = /* @__PURE__ */ new Set();
|
|
4809
|
+
const exhaustedDelegates = /* @__PURE__ */ new Set();
|
|
4810
|
+
const journalWrites = [];
|
|
4811
|
+
let ledgerSeq = 0;
|
|
4812
|
+
const appendJournal = (entry, nodeIdForEvent) => {
|
|
4813
|
+
if (journaled.has(entry)) return Promise.resolve();
|
|
4814
|
+
journaled.add(entry);
|
|
4815
|
+
const write = journal.appendEvent(runId, {
|
|
4816
|
+
kind: "edge",
|
|
4817
|
+
id: nodeIdForEvent,
|
|
4818
|
+
edge: {
|
|
4819
|
+
kind: entry.kind,
|
|
4820
|
+
from: entry.from,
|
|
4821
|
+
to: entry.to,
|
|
4822
|
+
directive: entry.directive
|
|
4823
|
+
},
|
|
4824
|
+
traversal: entry.traversal,
|
|
4825
|
+
outcome: entry.outcome,
|
|
4826
|
+
bytes: entry.bytes,
|
|
4827
|
+
...entry.reason !== void 0 ? { reason: entry.reason } : {},
|
|
4828
|
+
seq: ledgerSeq++,
|
|
4829
|
+
at: new Date(now()).toISOString()
|
|
4830
|
+
});
|
|
4831
|
+
journalWrites.push(write);
|
|
4832
|
+
return write;
|
|
4833
|
+
};
|
|
4834
|
+
const record = (entry, journalNow) => {
|
|
4835
|
+
const count = (traversalCounts.get(entry.edge) ?? 0) + 1;
|
|
4836
|
+
traversalCounts.set(entry.edge, count);
|
|
4837
|
+
const row = {
|
|
4838
|
+
...entry,
|
|
4839
|
+
traversal: count
|
|
4840
|
+
};
|
|
4841
|
+
ledger.push(row);
|
|
4842
|
+
if (journalNow) appendJournal(row, row.workerId ?? `graph:${row.to}`);
|
|
4843
|
+
return row;
|
|
4844
|
+
};
|
|
4845
|
+
const makeLeaf = opts.makeWorkerAgent ?? workerFromBackend(opts.backend, graph.deliverable);
|
|
4846
|
+
const nodeByWorkerId = /* @__PURE__ */ new Map();
|
|
4847
|
+
const pendingByAssignment = /* @__PURE__ */ new Map();
|
|
4848
|
+
const graphWorker = (authoredProfile, spawnContext) => {
|
|
4849
|
+
const requested = typeof authoredProfile?.name === "string" ? authoredProfile.name : void 0;
|
|
4850
|
+
const node = requested !== void 0 ? workers.get(requested) : void 0;
|
|
4851
|
+
if (!node) throw new ValidationError(`runGraph: spawn_agent 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.`);
|
|
4852
|
+
const edge = delegatesByWorker.get(node.id);
|
|
4853
|
+
const id = edgeId(edge);
|
|
4854
|
+
const cap = edge.maxTraversals ?? 32;
|
|
4855
|
+
if ((traversalCounts.get(id) ?? 0) >= cap) {
|
|
4856
|
+
exhausted.add(id);
|
|
4857
|
+
exhaustedDelegates.add(id);
|
|
4858
|
+
record({
|
|
4859
|
+
edge: id,
|
|
4860
|
+
kind: "delegates",
|
|
4861
|
+
from: edge.from,
|
|
4862
|
+
to: edge.to,
|
|
4863
|
+
directive: formatPromptHandle(edge.directive),
|
|
4864
|
+
outcome: "unpropagated",
|
|
4865
|
+
bytes: 0,
|
|
4866
|
+
reason: `traversal-cap-exhausted (max ${cap})`
|
|
4867
|
+
}, true);
|
|
4868
|
+
throw new ValidationError(`runGraph: delegates edge ${id} exhausted its traversal cap (${cap}) — the cyclic-graph backstop refused this spawn`);
|
|
4869
|
+
}
|
|
4870
|
+
const directiveText = registry.resolve(edge.directive).text;
|
|
4871
|
+
const taskText = stringifyPayload(spawnContext?.task);
|
|
4872
|
+
const bytes = byteLength(directiveText) + byteLength(taskText);
|
|
4873
|
+
const row = record({
|
|
4874
|
+
edge: id,
|
|
4875
|
+
kind: "delegates",
|
|
4876
|
+
from: edge.from,
|
|
4877
|
+
to: edge.to,
|
|
4878
|
+
directive: formatPromptHandle(edge.directive),
|
|
4879
|
+
outcome: bytes === 0 ? "empty" : "delivered",
|
|
4880
|
+
bytes,
|
|
4881
|
+
...bytes === 0 ? { reason: "no directive text and no task payload" } : {}
|
|
4882
|
+
}, false);
|
|
4883
|
+
if (spawnContext?.assignmentId !== void 0) pendingByAssignment.set(spawnContext.assignmentId, row);
|
|
4884
|
+
else appendJournal(row, `graph:${row.to}`);
|
|
4885
|
+
const pinned = directiveText.length === 0 ? node.profile : {
|
|
4886
|
+
...node.profile,
|
|
4887
|
+
prompt: {
|
|
4888
|
+
...node.profile.prompt ?? {},
|
|
4889
|
+
instructions: [...node.profile.prompt?.instructions ?? [], directiveText]
|
|
4890
|
+
}
|
|
4891
|
+
};
|
|
4892
|
+
return makeLeaf(pinned, spawnContext);
|
|
4893
|
+
};
|
|
4894
|
+
const routes = analyzes.map((edge) => edge.to === root.id ? {
|
|
4895
|
+
kind: edge.analyst,
|
|
4896
|
+
over: edge.over
|
|
4897
|
+
} : {
|
|
4898
|
+
kind: edge.analyst,
|
|
4899
|
+
over: edge.over,
|
|
4900
|
+
to: edge.to,
|
|
4901
|
+
directive: registry.resolve(edge.directive).text
|
|
4902
|
+
});
|
|
4903
|
+
const driverAnalyzesBriefs = analyzes.filter((edge) => edge.to === root.id).map((edge) => `Findings from analyst '${edge.analyst}' (over: ${edge.over.join(", ")}) will arrive as finding events.\n${registry.resolve(edge.directive).text}`);
|
|
4904
|
+
const graphBrief = [
|
|
4905
|
+
"AGENT GRAPH: you are the driver node of a fixed topology. You may spawn ONLY these worker",
|
|
4906
|
+
"nodes, by EXACT name (spawn_agent with profile: { name: '<node id>' }; the node's full",
|
|
4907
|
+
"profile is pinned by the graph — any other profile fields you author are ignored):",
|
|
4908
|
+
...[...workers.values()].map((node) => {
|
|
4909
|
+
const cap = delegatesByWorker.get(node.id).maxTraversals ?? 32;
|
|
4910
|
+
const description = typeof node.profile.description === "string" && node.profile.description.length > 0 ? ` — ${node.profile.description}` : "";
|
|
4911
|
+
return `- '${node.id}'${description} (delegation cap: ${cap} traversals)`;
|
|
4912
|
+
}),
|
|
4913
|
+
...driverAnalyzesBriefs.length > 0 ? ["", ...driverAnalyzesBriefs] : []
|
|
4914
|
+
].join("\n");
|
|
4915
|
+
const rootProfile = {
|
|
4916
|
+
...root.profile,
|
|
4917
|
+
prompt: {
|
|
4918
|
+
...root.profile.prompt ?? {},
|
|
4919
|
+
instructions: [...root.profile.prompt?.instructions ?? [], graphBrief]
|
|
4920
|
+
}
|
|
4921
|
+
};
|
|
4922
|
+
const strippedByDigest = /* @__PURE__ */ new Map();
|
|
4923
|
+
const authorizeMessage = opts.authorizeMessage ? (input) => {
|
|
4924
|
+
const decision = opts.authorizeMessage(input);
|
|
4925
|
+
if (decision.instruction !== input.instruction) strippedByDigest.set(canonicalCandidateDigest(decision.instruction), { composedBytes: byteLength(input.instruction) });
|
|
4926
|
+
return decision;
|
|
4927
|
+
} : void 0;
|
|
4928
|
+
const routedAnalyzesByAnalyst = /* @__PURE__ */ new Map();
|
|
4929
|
+
const driverAnalyzesByAnalyst = /* @__PURE__ */ new Map();
|
|
4930
|
+
for (const edge of analyzes) (edge.to === root.id ? driverAnalyzesByAnalyst : routedAnalyzesByAnalyst).set(edge.analyst, edge);
|
|
4931
|
+
const analyzesCapReached = (edge) => {
|
|
4932
|
+
const cap = edge.maxTraversals ?? 32;
|
|
4933
|
+
if ((traversalCounts.get(edgeId(edge)) ?? 0) < cap) return false;
|
|
4934
|
+
exhausted.add(edgeId(edge));
|
|
4935
|
+
return true;
|
|
4936
|
+
};
|
|
4937
|
+
const ledgerAnalyzes = (edge, outcome, bytes, reason, workerId) => {
|
|
4938
|
+
const capped = analyzesCapReached(edge);
|
|
4939
|
+
record({
|
|
4940
|
+
edge: edgeId(edge),
|
|
4941
|
+
kind: "analyzes",
|
|
4942
|
+
from: edge.over.join("+"),
|
|
4943
|
+
to: edge.to,
|
|
4944
|
+
directive: formatPromptHandle(edge.directive),
|
|
4945
|
+
outcome: capped ? "unpropagated" : outcome,
|
|
4946
|
+
bytes,
|
|
4947
|
+
...capped ? { reason: `traversal-cap-exhausted (max ${edge.maxTraversals ?? 32})` } : reason !== void 0 ? { reason } : {},
|
|
4948
|
+
...workerId !== void 0 ? { workerId } : {}
|
|
4949
|
+
}, true);
|
|
4950
|
+
};
|
|
4951
|
+
const onCoordinationEvent = async (_context, _eventId, recordEnvelope) => {
|
|
4952
|
+
const event = recordEnvelope.event;
|
|
4953
|
+
if (event.type === "finding") {
|
|
4954
|
+
const edge = driverAnalyzesByAnalyst.get(event.finding.analyst);
|
|
4955
|
+
if (!edge) return;
|
|
4956
|
+
const sourceNode = nodeByWorkerId.get(event.finding.fromWorker);
|
|
4957
|
+
if (sourceNode === void 0 || !edge.over.includes(sourceNode)) return;
|
|
4958
|
+
const findingsText = event.finding.findings === void 0 ? "" : stringifyPayload(event.finding.findings);
|
|
4959
|
+
const directiveBytes = byteLength(registry.resolve(edge.directive).text);
|
|
4960
|
+
const empty = findingsText.length === 0;
|
|
4961
|
+
ledgerAnalyzes(edge, empty ? "empty" : "delivered", directiveBytes + byteLength(findingsText), empty ? "analyst returned no findings" : void 0, event.finding.fromWorker);
|
|
4962
|
+
return;
|
|
4963
|
+
}
|
|
4964
|
+
if (event.type === "steer") {
|
|
4965
|
+
const down = event.down;
|
|
4966
|
+
if (event.analyst !== void 0) {
|
|
4967
|
+
const edge = routedAnalyzesByAnalyst.get(event.analyst);
|
|
4968
|
+
if (!edge) return;
|
|
4969
|
+
ledgerAnalyzes(edge, down.delivered ? "delivered" : "unpropagated", byteLength(down.instruction), down.delivered ? void 0 : down.outcome, down.toWorker);
|
|
4970
|
+
return;
|
|
4971
|
+
}
|
|
4972
|
+
const nodeId = nodeByWorkerId.get(down.toWorker);
|
|
4973
|
+
if (nodeId === void 0) return;
|
|
4974
|
+
const edge = delegatesByWorker.get(nodeId);
|
|
4975
|
+
if (!edge) return;
|
|
4976
|
+
const stripped = strippedByDigest.get(down.instructionDigest);
|
|
4977
|
+
record({
|
|
4978
|
+
edge: edgeId(edge),
|
|
4979
|
+
kind: "delegates",
|
|
4980
|
+
from: edge.from,
|
|
4981
|
+
to: edge.to,
|
|
4982
|
+
directive: formatPromptHandle(edge.directive),
|
|
4983
|
+
outcome: !down.delivered ? "unpropagated" : stripped ? "stripped" : "delivered",
|
|
4984
|
+
bytes: byteLength(down.instruction),
|
|
4985
|
+
...!down.delivered ? { reason: down.outcome } : stripped ? { reason: `authorization narrowed ${stripped.composedBytes} composed bytes` } : {},
|
|
4986
|
+
workerId: down.toWorker
|
|
4987
|
+
}, true);
|
|
4988
|
+
}
|
|
4989
|
+
};
|
|
4990
|
+
const hooks = composeRuntimeHooks({ onEvent: (event) => {
|
|
4991
|
+
if (event.target !== "agent.spawn" || event.phase !== "after") return;
|
|
4992
|
+
const payload = event.payload;
|
|
4993
|
+
if (typeof payload?.childId !== "string" || typeof payload.assignmentId !== "string") return;
|
|
4994
|
+
const pending = pendingByAssignment.get(payload.assignmentId);
|
|
4995
|
+
if (!pending) return;
|
|
4996
|
+
pendingByAssignment.delete(payload.assignmentId);
|
|
4997
|
+
const bound = {
|
|
4998
|
+
...pending,
|
|
4999
|
+
workerId: payload.childId
|
|
5000
|
+
};
|
|
5001
|
+
ledger[ledger.indexOf(pending)] = bound;
|
|
5002
|
+
nodeByWorkerId.set(payload.childId, bound.to);
|
|
5003
|
+
return appendJournal(bound, payload.childId);
|
|
5004
|
+
} }, opts.hooks);
|
|
5005
|
+
const start = async () => {
|
|
5006
|
+
const result = await supervise(rootProfile, graphTask(graph, root), {
|
|
5007
|
+
budget: graph.budget,
|
|
5008
|
+
deliverable: graph.deliverable,
|
|
5009
|
+
makeWorkerAgent: graphWorker,
|
|
5010
|
+
journal,
|
|
5011
|
+
blobs,
|
|
5012
|
+
runId,
|
|
5013
|
+
hooks,
|
|
5014
|
+
onCoordinationEvent,
|
|
5015
|
+
...routes.length > 0 && opts.analysts ? {
|
|
5016
|
+
analysts: opts.analysts,
|
|
5017
|
+
analyzeOnSettle: routes
|
|
5018
|
+
} : {},
|
|
5019
|
+
...opts.router ? { router: opts.router } : {},
|
|
5020
|
+
...opts.brain ? { brain: opts.brain } : {},
|
|
5021
|
+
...authorizeMessage ? { authorizeMessage } : {},
|
|
5022
|
+
...opts.perWorker ? { perWorker: opts.perWorker } : {},
|
|
5023
|
+
...opts.maxTurns !== void 0 ? { maxTurns: opts.maxTurns } : {},
|
|
5024
|
+
...opts.maxLiveWorkers !== void 0 ? { maxLiveWorkers: opts.maxLiveWorkers } : {},
|
|
5025
|
+
...opts.signal ? { signal: opts.signal } : {},
|
|
5026
|
+
...opts.now ? { now: opts.now } : {},
|
|
5027
|
+
...opts.otel ? { otel: opts.otel } : {},
|
|
5028
|
+
...opts.stallAfterMs !== void 0 ? { stallAfterMs: opts.stallAfterMs } : {},
|
|
5029
|
+
...opts.allowedModels ? { allowedModels: opts.allowedModels } : {}
|
|
5030
|
+
});
|
|
5031
|
+
for (const pending of pendingByAssignment.values()) {
|
|
5032
|
+
const refused = {
|
|
5033
|
+
...pending,
|
|
5034
|
+
outcome: "unpropagated",
|
|
5035
|
+
bytes: 0,
|
|
5036
|
+
reason: `no-live-worker-bound (spawn refused after the factory, or a keyed re-spawn deduplicated to a completed result; ${pending.bytes} composed bytes never crossed)`
|
|
5037
|
+
};
|
|
5038
|
+
ledger[ledger.indexOf(pending)] = refused;
|
|
5039
|
+
await appendJournal(refused, `graph:${refused.to}`);
|
|
5040
|
+
}
|
|
5041
|
+
pendingByAssignment.clear();
|
|
5042
|
+
await Promise.all(journalWrites);
|
|
5043
|
+
const exhaustedEdges = Object.freeze([...exhausted]);
|
|
5044
|
+
const frozenLedger = Object.freeze(ledger.map((row) => Object.freeze({ ...row })));
|
|
5045
|
+
const lifecycleEnded = result.kind === "no-winner" && (result.reason === "aborted" || result.reason === "budget-exhausted");
|
|
5046
|
+
if (result.kind !== "winner" && !lifecycleEnded && exhaustedDelegates.size > 0) throw new GraphEdgeCapError(Object.freeze([...exhaustedDelegates]), frozenLedger, result);
|
|
5047
|
+
return {
|
|
5048
|
+
result,
|
|
5049
|
+
ledger: frozenLedger,
|
|
5050
|
+
exhaustedEdges,
|
|
5051
|
+
runId
|
|
5052
|
+
};
|
|
5053
|
+
};
|
|
5054
|
+
return start();
|
|
5055
|
+
}
|
|
5056
|
+
/** The root task: the graph's own framing. The deliverable (mandatory) is the termination; the
|
|
5057
|
+
* task names what the topology exists to produce. */
|
|
5058
|
+
function graphTask(graph, root) {
|
|
5059
|
+
return graph.deliverable.describe ?? `Deliver the graph's deliverable by driving your worker nodes (root: '${root.id}').`;
|
|
5060
|
+
}
|
|
5061
|
+
//#endregion
|
|
4651
5062
|
//#region src/runtime/supervise/patch-checks.ts
|
|
4652
5063
|
const DEFAULT_MAX_DIFF_LINES = 400;
|
|
4653
5064
|
/**
|
|
@@ -5777,6 +6188,6 @@ function tail(s) {
|
|
|
5777
6188
|
return s.slice(-400);
|
|
5778
6189
|
}
|
|
5779
6190
|
//#endregion
|
|
5780
|
-
export {
|
|
6191
|
+
export { panel as $, runStrategyEvolution as A, defaultAuditorInstruction as At, equalKOnCost as B, secretEnvOfMcpServer as Bt, GraphEdgeCapError as C, leaderboard as Ct, streamAgentTurn as D, renderLeaderboardSvg as Dt, collectAgentTurn as E, renderLeaderboardMarkdown as Et, SandboxRunAbortError as F, sanitizeMcpToolSchema as Ft, createShapeRegistry as G, definePersona as H, openSandboxRun as I, envKeyProvider as It, InMemoryCorpus as J, registerShape as K, printBenchmarkReport as L, mcpSecretEnvMetadataKey as Lt, assertStrategyContract as M, connectStdioMcp as Mt, authorStrategy as N, materializeLocalMcp as Nt, discriminatingMeans as O, renderPairwiseMarkdown as Ot, strategyAuthorContract as P, createMcpEnvironment as Pt, loopUntil as Q, runBenchmark as R, resolveMcpServerLaunch as Rt, runCoderChecks as S, stopSentinel as St, runGraph as T, renderLeaderboardHtml as Tt, runPersonified as U, trajectoryReport as V, builtinShapes as W, fanout as X, renderCorpusToInstructions as Y, flatWidenGate as Z, settledWorkerOut as _, loopCampaignDispatch as _t, localShell as a, buildSteerContext as at, analyzeTrace as b, deterministicCompletion as bt, createVerifierEnvironment as c, inProcessSandboxClient as ct, worktreeFanout as d, dumbDriver as dt, pipeline as et, EVIDENCE_MAX_CHARS as f, naiveDriver as ft, composeWorkerEvidence as g, inlineSandboxClient as gt, closingWorkerNote as h, localSandboxClient as ht, jjWorkspace as i, assertTraceDerivedFindings as it, selectChampion as j, McpSpawnFault as jt, pickChampion as k, auditIntent as kt, failuresAnalyst as l, harvestCorpus as lt, VERIFY_TAIL_CHARS as m, resolveSandboxClient as mt, makeFinding$1 as n, verify as nt, runInWorkspace as o, createScopeAnalyst as ot, NOTE_MAX_CHARS as p, steeringDriver as pt, FileCorpus as q, gitWorkspace as r, widen as rt, createWaterfallCollector as s, registryScopeAnalyst as st, computeFindingId$1 as t, selectValidWinner as tt, superviseSurface as u, defineLeaderboard as ut, copyUntrackedIntoClone as v, loopDispatch as vt, defaultEdgeTraversalCap as w, pairwiseSignificance as wt, patchDelivered as x, sentinelCompletion as xt, withUntrackedArtifacts as y, completionAuthorizes as yt, promotionGate as z, resolveSecretEnv as zt };
|
|
5781
6192
|
|
|
5782
|
-
//# sourceMappingURL=runtime-
|
|
6193
|
+
//# sourceMappingURL=runtime-OI7oLLec.js.map
|