@tangle-network/agent-runtime 7.0.0 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/README.md +0 -3
- package/dist/{activation-Ba9IAgQ3.js → activation-8AdN-3r4.js} +4 -4
- package/dist/{activation-Ba9IAgQ3.js.map → activation-8AdN-3r4.js.map} +1 -1
- package/dist/{activation-DIkTEBWF.d.ts → activation-xxvLF1-1.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -3
- package/dist/{bundle-Cy5igJdv.js → bundle-CcpL2lfr.js} +2 -2
- package/dist/{bundle-Cy5igJdv.js.map → bundle-CcpL2lfr.js.map} +1 -1
- package/dist/candidate-execution/index.js +4 -4
- package/dist/continuation-CIyKnS1Q.js +451 -0
- package/dist/continuation-CIyKnS1Q.js.map +1 -0
- package/dist/{coordination-manager-DQZ2u6L-.js → coordination-manager-DAGPerJy.js} +194 -148
- package/dist/coordination-manager-DAGPerJy.js.map +1 -0
- package/dist/{coordination-map-routing-CKRNZSaV.js → coordination-map-routing-XZXTlCmn.js} +2 -4
- package/dist/coordination-map-routing-XZXTlCmn.js.map +1 -0
- package/dist/{delegate-DFLSVjFG.js → delegate-CoaNr0hO.js} +3 -3
- package/dist/{delegate-DFLSVjFG.js.map → delegate-CoaNr0hO.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +13 -12
- package/dist/durable.js.map +1 -1
- package/dist/{errors-AzSuGI23.js → errors-DG8yufqX.js} +8 -1
- package/dist/errors-DG8yufqX.js.map +1 -0
- package/dist/{failure-cause-rJTm_Tx8.js → failure-cause-CVB-YE88.js} +12 -8
- package/dist/{failure-cause-rJTm_Tx8.js.map → failure-cause-CVB-YE88.js.map} +1 -1
- package/dist/graph-pFTeNZ-G.js +1793 -0
- package/dist/graph-pFTeNZ-G.js.map +1 -0
- package/dist/{graph-registry-7X2nrreR.js → graph-registry-czAwYwNj.js} +133 -9
- package/dist/graph-registry-czAwYwNj.js.map +1 -0
- package/dist/{graph-registry-gYbq4L5Z.js → graph-registry-uTIyyy7A.js} +1 -1
- package/dist/{improve-BolbYegO.js → improve-I43jex8v.js} +19 -48
- package/dist/improve-I43jex8v.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +16 -16
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +8 -8
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +16 -15
- package/dist/{loop-runner-Cs9IJ6Nk.d.ts → loop-runner-BGwhcn1p.d.ts} +2 -2
- package/dist/{loop-runner-C9W3T_3T.js → loop-runner-BN4KozR0.js} +3 -3
- package/dist/{loop-runner-C9W3T_3T.js.map → loop-runner-BN4KozR0.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 +7 -5
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +9 -9
- package/dist/mcp/memory-bin.js +2 -2
- package/dist/{model-policy-JOcg3NRs.js → model-policy-CZwhXp8O.js} +15 -10
- package/dist/model-policy-CZwhXp8O.js.map +1 -0
- package/dist/{prepare-Dtfk_Wi_.js → prepare-BnF8nGIg.js} +4 -4
- package/dist/{prepare-Dtfk_Wi_.js.map → prepare-BnF8nGIg.js.map} +1 -1
- package/dist/{profile-CNSQjOes.js → profile-CD25rTJF.js} +4 -4
- package/dist/{profile-CNSQjOes.js.map → profile-CD25rTJF.js.map} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.js +2 -2
- package/dist/{provision-supervisor-BQFHjCtN.js → provision-supervisor-DvzayGpe.js} +8 -8
- package/dist/{provision-supervisor-BQFHjCtN.js.map → provision-supervisor-DvzayGpe.js.map} +1 -1
- package/dist/{run-cancellation-B84X8ZAP.js → run-cancellation-C5__aBKW.js} +4 -4
- package/dist/{run-cancellation-B84X8ZAP.js.map → run-cancellation-C5__aBKW.js.map} +1 -1
- package/dist/{run-state-Dh1bGERI.js → run-state-CJAaxqfp.js} +5 -5
- package/dist/{run-state-Dh1bGERI.js.map → run-state-CJAaxqfp.js.map} +1 -1
- package/dist/{runtime-C9F1PG2A.js → runtime-CuwHe8_K.js} +76 -987
- package/dist/runtime-CuwHe8_K.js.map +1 -0
- package/dist/{sandbox-profile-compat-oFGWESLn.js → sandbox-profile-compat-l-SLQnGb.js} +2 -2
- package/dist/{sandbox-profile-compat-oFGWESLn.js.map → sandbox-profile-compat-l-SLQnGb.js.map} +1 -1
- package/dist/{search-executor-CKR9_6NR.js → search-executor-DAjm-NlG.js} +17 -46
- package/dist/search-executor-DAjm-NlG.js.map +1 -0
- package/dist/{server-Dh3SQGQT.js → server-BUpNUn5D.js} +32 -8
- package/dist/{server-Dh3SQGQT.js.map → server-BUpNUn5D.js.map} +1 -1
- package/dist/{settle-record-C6LdVvok.js → settle-record-CeBdBuxP.js} +2 -2
- package/dist/{settle-record-C6LdVvok.js.map → settle-record-CeBdBuxP.js.map} +1 -1
- package/dist/{snapshot-Cgj2Wzi6.js → snapshot-BKI_w3JD.js} +19 -5
- package/dist/snapshot-BKI_w3JD.js.map +1 -0
- package/dist/{structural-rollout-Dapf2aZY.js → structural-rollout-CqxBKxKY.js} +18 -54
- package/dist/structural-rollout-CqxBKxKY.js.map +1 -0
- package/dist/{supervise-xwl2D6q3.js → supervise-Cdqj_oe4.js} +101 -111
- package/dist/supervise-Cdqj_oe4.js.map +1 -0
- package/dist/{supervision-discovery-B47U8TH5.js → supervision-discovery-CW-ildZ-.js} +4 -4
- package/dist/{supervision-discovery-B47U8TH5.js.map → supervision-discovery-CW-ildZ-.js.map} +1 -1
- package/dist/{supervisor-gC-u_PRk.js → supervisor-D-eT-6Tu.js} +206 -693
- package/dist/supervisor-D-eT-6Tu.js.map +1 -0
- package/dist/{supervisor-accounting-DxLQ_TQe.js → supervisor-accounting-Ow6CChpB.js} +434 -423
- package/dist/supervisor-accounting-Ow6CChpB.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +61 -61
- package/dist/{tool-server-Dg350Bgz.js → tool-server-DYwRbi0I.js} +3 -3
- package/dist/{tool-server-Dg350Bgz.js.map → tool-server-DYwRbi0I.js.map} +1 -1
- package/dist/{top-web-BJLnFQdr.js → top-web-BuYMkJN4.js} +9 -7
- package/dist/{top-web-BJLnFQdr.js.map → top-web-BuYMkJN4.js.map} +1 -1
- package/dist/tui/bin.js +3 -3
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{types-Jg274chm.d.ts → types-C_qbnw9N.d.ts} +1335 -1413
- package/dist/{util-C_cdPNC4.js → util-fcckrkKp.js} +39 -113
- package/dist/util-fcckrkKp.js.map +1 -0
- package/dist/viewer/report-viewer.js +90 -90
- package/dist/viewer/runtime-viewer/AgentGraphCanvas-P_PFS2Ko-B7S6Fwwy.js +563 -0
- package/dist/viewer/runtime-viewer/latest-events-wofY6ifW-B8_bfLwI.js +17870 -0
- package/dist/viewer/styles.css +1592 -7027
- package/dist/viewer/workspace-viewer.js +10926 -10522
- package/dist/{workspace-streams-B7yNMahl.js → workspace-streams-DA9R3j-p.js} +2 -2
- package/dist/{workspace-streams-B7yNMahl.js.map → workspace-streams-DA9R3j-p.js.map} +1 -1
- package/package.json +9 -9
- package/dist/coordination-manager-DQZ2u6L-.js.map +0 -1
- package/dist/coordination-map-routing-CKRNZSaV.js.map +0 -1
- package/dist/errors-AzSuGI23.js.map +0 -1
- package/dist/graph-BjQF2syl.js +0 -579
- package/dist/graph-BjQF2syl.js.map +0 -1
- package/dist/graph-registry-7X2nrreR.js.map +0 -1
- package/dist/improve-BolbYegO.js.map +0 -1
- package/dist/model-policy-JOcg3NRs.js.map +0 -1
- package/dist/runtime-C9F1PG2A.js.map +0 -1
- package/dist/search-executor-CKR9_6NR.js.map +0 -1
- package/dist/snapshot-Cgj2Wzi6.js.map +0 -1
- package/dist/structural-rollout-Dapf2aZY.js.map +0 -1
- package/dist/supervise-xwl2D6q3.js.map +0 -1
- package/dist/supervisor-accounting-DxLQ_TQe.js.map +0 -1
- package/dist/supervisor-gC-u_PRk.js.map +0 -1
- package/dist/util-C_cdPNC4.js.map +0 -1
- package/dist/viewer/runtime-viewer/AgentGraphCanvas-DGq7_u8--C6yDfIUT.js +0 -8555
- package/dist/viewer/runtime-viewer/latest-events-CRq9sGkK-CfoBl1dP.js +0 -9592
- package/dist/viewer/runtime-viewer/sandbox-ui-BEziPi7D.css +0 -2
package/dist/graph-BjQF2syl.js
DELETED
|
@@ -1,579 +0,0 @@
|
|
|
1
|
-
import { Wr as runtimeFlowBrain } from "./supervisor-accounting-DxLQ_TQe.js";
|
|
2
|
-
import { i as ConfigError, m as ValidationError } from "./errors-AzSuGI23.js";
|
|
3
|
-
import { M as contentAddress } from "./failure-cause-rJTm_Tx8.js";
|
|
4
|
-
import { zt as defaultRunCommand } from "./supervisor-gC-u_PRk.js";
|
|
5
|
-
import { v as harnessRunsAgent } from "./model-policy-JOcg3NRs.js";
|
|
6
|
-
import { a as readCommittedJsonLines, c as appendCommittedJsonLine, s as withJsonlFileLock } from "./jsonl-file-DsxVI0E_.js";
|
|
7
|
-
import { t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
|
|
8
|
-
import { f as createFileRunContext, m as withRunContext, p as createInMemoryRunContext } from "./coordination-manager-DQZ2u6L-.js";
|
|
9
|
-
import { M as kernelPromptRegistry, S as validateFlowGraph, T as validateGraphTopology, _ as GraphRouteError, b as journaledGateDecider, g as createGraphOverlay, i as profileGuidanceComposer, r as superviseWithTestBrain, t as supervise, v as createFlowRun, w as graphRootProfile, x as routeFlowOf, y as flowRootProfile } from "./supervise-xwl2D6q3.js";
|
|
10
|
-
import { canonicalCandidateDigest } from "@tangle-network/agent-interface";
|
|
11
|
-
import { mkdirSync, realpathSync } from "node:fs";
|
|
12
|
-
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
13
|
-
// src/runtime/supervise/graph-backend.ts
|
|
14
|
-
/** Graph nodes expose JSON outputs through Runtime's resumable execution transports. */
|
|
15
|
-
function graphExecutionOptions(options) {
|
|
16
|
-
if (options.makeLeafAgent) return options;
|
|
17
|
-
const backend = options.backend;
|
|
18
|
-
if (backend) return backend.backend === "bridge" || backend.backend === "provider" ? {
|
|
19
|
-
...options,
|
|
20
|
-
backend: {
|
|
21
|
-
...backend,
|
|
22
|
-
outputFormat: "json"
|
|
23
|
-
}
|
|
24
|
-
} : options;
|
|
25
|
-
const bridgeUrl = process.env.CLI_BRIDGE_URL;
|
|
26
|
-
const bridgeBearer = process.env.BRIDGE_BEARER ?? process.env.CLI_BRIDGE_BEARER;
|
|
27
|
-
if (!bridgeUrl || !bridgeBearer) throw new ValidationError("runGraph: start CLI Bridge and supply backend: { backend: \"bridge\", bridgeUrl, bridgeBearer, cwd }, or configure CLI_BRIDGE_URL and BRIDGE_BEARER");
|
|
28
|
-
return {
|
|
29
|
-
...options,
|
|
30
|
-
backend: {
|
|
31
|
-
backend: "bridge",
|
|
32
|
-
bridgeUrl,
|
|
33
|
-
bridgeBearer,
|
|
34
|
-
cwd: process.cwd(),
|
|
35
|
-
outputFormat: "json"
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
// src/runtime/supervise/stored-graph-check.ts
|
|
40
|
-
/** Driver-owned journal identity. Worker output never supplies any part of this authority. */
|
|
41
|
-
function receiptKey(receipt) {
|
|
42
|
-
return contentAddress({
|
|
43
|
-
binding: receipt.binding,
|
|
44
|
-
checkDigest: receipt.checkDigest,
|
|
45
|
-
nodeName: receipt.nodeName,
|
|
46
|
-
nodeId: receipt.nodeId,
|
|
47
|
-
attemptId: receipt.attemptId,
|
|
48
|
-
outputDigest: receipt.outputDigest
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function isReceipt(value) {
|
|
52
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
53
|
-
const row = value;
|
|
54
|
-
if (row.version !== 1 || ![
|
|
55
|
-
"key",
|
|
56
|
-
"binding",
|
|
57
|
-
"checkDigest",
|
|
58
|
-
"nodeName",
|
|
59
|
-
"nodeId",
|
|
60
|
-
"attemptId",
|
|
61
|
-
"outputDigest",
|
|
62
|
-
"output"
|
|
63
|
-
].every((key) => typeof row[key] === "string") || !row.nodeName || !row.nodeId || !row.attemptId || !(row.exitCode === null || Number.isSafeInteger(row.exitCode)) || typeof row.outputTruncated !== "boolean" || typeof row.nativeValid !== "boolean" || typeof row.valid !== "boolean") return false;
|
|
64
|
-
const receipt = value;
|
|
65
|
-
return receipt.key === receiptKey(receipt) && receipt.valid === (receipt.exitCode === 0 && receipt.nativeValid);
|
|
66
|
-
}
|
|
67
|
-
function within(directory, path) {
|
|
68
|
-
const offset = relative(directory, path);
|
|
69
|
-
return offset === "" || !isAbsolute(offset) && offset !== ".." && !offset.startsWith("../");
|
|
70
|
-
}
|
|
71
|
-
/** Lower a named check onto the local workspace, with evidence in the driver's durable state.
|
|
72
|
-
* The run directory has the same trust boundary as RunContext journals: keep it outside the
|
|
73
|
-
* worker workspace and do not mount it into the worker. A remote Bridge cannot run a host check.
|
|
74
|
-
* Provider validators are refused because their context does not identify the admitted node.
|
|
75
|
-
*/
|
|
76
|
-
function bindGraphCommand(graph, options) {
|
|
77
|
-
const { command: definition, ...deliverable } = graph.deliverable;
|
|
78
|
-
if (!definition) return {
|
|
79
|
-
graph,
|
|
80
|
-
options
|
|
81
|
-
};
|
|
82
|
-
const { command, timeoutMs = 6e4 } = definition;
|
|
83
|
-
if (!command.trim() || !Number.isSafeInteger(timeoutMs) || timeoutMs <= 0) throw new ValidationError("graphFromStored: command check needs a command and positive timeoutMs");
|
|
84
|
-
const backend = options.backend;
|
|
85
|
-
if (options.makeLeafAgent || !backend) throw new ValidationError("runGraph: command checks require an explicit execution backend");
|
|
86
|
-
const workspace = backend.backend === "bridge" ? backend.cwd : backend.backend === "cli-in-place" ? backend.workspacePath : void 0;
|
|
87
|
-
if (!workspace || backend.backend === "bridge" && ![
|
|
88
|
-
"localhost",
|
|
89
|
-
"127.0.0.1",
|
|
90
|
-
"[::1]"
|
|
91
|
-
].includes(new URL(backend.bridgeUrl).hostname)) throw new ValidationError("runGraph: command checks require a loopback Bridge or local CLI workspace; provider node binding is unsupported");
|
|
92
|
-
if (!options.runDir) throw new ValidationError("runGraph: command checks require a driver-owned runDir outside the workspace");
|
|
93
|
-
const cwd = realpathSync(workspace);
|
|
94
|
-
mkdirSync(options.runDir, { recursive: true });
|
|
95
|
-
const runDir = realpathSync(options.runDir);
|
|
96
|
-
if (within(cwd, runDir)) throw new ValidationError("runGraph: command check runDir must be outside the worker workspace");
|
|
97
|
-
const file = join(runDir, "command-checks.jsonl");
|
|
98
|
-
const checkDigest = contentAddress({
|
|
99
|
-
command,
|
|
100
|
-
timeoutMs,
|
|
101
|
-
cwd
|
|
102
|
-
});
|
|
103
|
-
const binding = contentAddress({
|
|
104
|
-
graph: {
|
|
105
|
-
...graph,
|
|
106
|
-
deliverable: {
|
|
107
|
-
...deliverable,
|
|
108
|
-
check: void 0
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
runId: options.runId ?? options.runContext?.runId,
|
|
112
|
-
checkDigest
|
|
113
|
-
});
|
|
114
|
-
const nodeNames = new Set(graph.nodes.map((node) => node.id));
|
|
115
|
-
const checkFinal = async (out) => {
|
|
116
|
-
if (!out || typeof out !== "object" || Array.isArray(out)) return false;
|
|
117
|
-
const entries = Object.entries(out);
|
|
118
|
-
if (entries.length === 0 || entries.some(([name]) => !nodeNames.has(name))) return false;
|
|
119
|
-
return withJsonlFileLock(file, async (canonicalPath) => {
|
|
120
|
-
if (within(cwd, canonicalPath)) return false;
|
|
121
|
-
const latest = /* @__PURE__ */ new Map();
|
|
122
|
-
for await (const raw of readCommittedJsonLines(canonicalPath, { allowMissing: true })) {
|
|
123
|
-
if (!isReceipt(raw)) return false;
|
|
124
|
-
if (raw.binding !== binding || raw.checkDigest !== checkDigest) continue;
|
|
125
|
-
latest.set(contentAddress([raw.nodeName, raw.outputDigest]), raw);
|
|
126
|
-
}
|
|
127
|
-
return entries.every(([name, output]) => latest.get(contentAddress([name, contentAddress(output)]))?.valid === true);
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
const checkLeaf = async (out, context) => {
|
|
131
|
-
const node = context.node;
|
|
132
|
-
const nodeName = context.profile.name;
|
|
133
|
-
if (!node || !node.nodeId || !node.attemptId || !nodeName || !nodeNames.has(nodeName)) return false;
|
|
134
|
-
const outputDigest = contentAddress(out);
|
|
135
|
-
let result;
|
|
136
|
-
try {
|
|
137
|
-
result = await defaultRunCommand({
|
|
138
|
-
command,
|
|
139
|
-
cwd,
|
|
140
|
-
timeoutMs,
|
|
141
|
-
signal: context.signal
|
|
142
|
-
});
|
|
143
|
-
} catch (error) {
|
|
144
|
-
result = {
|
|
145
|
-
exitCode: null,
|
|
146
|
-
output: error instanceof Error ? error.message : String(error)
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
const bytes = Buffer.from(result.output);
|
|
150
|
-
const limit = 65536;
|
|
151
|
-
const receipt = {
|
|
152
|
-
version: 1,
|
|
153
|
-
binding,
|
|
154
|
-
checkDigest,
|
|
155
|
-
nodeName,
|
|
156
|
-
nodeId: node.nodeId,
|
|
157
|
-
attemptId: node.attemptId,
|
|
158
|
-
outputDigest,
|
|
159
|
-
exitCode: result.exitCode,
|
|
160
|
-
output: bytes.subarray(0, limit).toString("utf8"),
|
|
161
|
-
outputTruncated: bytes.length > limit,
|
|
162
|
-
nativeValid: context.originalVerdict?.valid !== false,
|
|
163
|
-
valid: result.exitCode === 0 && context.originalVerdict?.valid !== false
|
|
164
|
-
};
|
|
165
|
-
await withJsonlFileLock(file, async (canonicalPath) => {
|
|
166
|
-
if (within(cwd, canonicalPath)) throw new ValidationError("runGraph: command receipt journal resolves inside worker workspace");
|
|
167
|
-
await appendCommittedJsonLine(canonicalPath, {
|
|
168
|
-
...receipt,
|
|
169
|
-
key: receiptKey(receipt)
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
return receipt.valid;
|
|
173
|
-
};
|
|
174
|
-
return {
|
|
175
|
-
graph: {
|
|
176
|
-
...graph,
|
|
177
|
-
deliverable: {
|
|
178
|
-
...deliverable,
|
|
179
|
-
check: (out, context) => context === void 0 ? checkFinal(out) : checkLeaf(out, context)
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
options
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
// src/runtime/supervise/graph.ts
|
|
186
|
-
/**
|
|
187
|
-
*
|
|
188
|
-
* `runGraph` — agent graphs: profiles as nodes, registry-backed prompt directives as edges.
|
|
189
|
-
*
|
|
190
|
-
* A topology is PLAIN DATA an agent can author in a few lines: nodes are canonical
|
|
191
|
-
* `AgentProfile`s (the ONLY way a node is described — no role-builder functions), edges are typed
|
|
192
|
-
* values carrying versioned {@link PromptHandle} directives, `deliverable` (termination) and
|
|
193
|
-
* `budget` (one conserved pool) are mandatory. Driver↔worker is the two-node cyclic instance;
|
|
194
|
-
* "agent 3 analyzes 1 and 2 and reports to 1" is ONE edge, not a framework.
|
|
195
|
-
*
|
|
196
|
-
* NOT A SECOND SCHEDULER. `runGraph` is an interpretation layer over what already runs:
|
|
197
|
-
* `supervise()` is the execution core — the same `supervisorAgent`/`driverAgent` machinery,
|
|
198
|
-
* backend-derived worker path (authorized, classified, recursive), conserved-pool budget, and
|
|
199
|
-
* deliverable-gated settlement every
|
|
200
|
-
* supervised run uses. (`runAgentRounds` is deliberately NOT the substrate here.) What the graph
|
|
201
|
-
* layer ADDS is exactly what a bespoke driver loop never
|
|
202
|
-
* had:
|
|
203
|
-
*
|
|
204
|
-
* 1. **Node pinning** — a spawn names a node (`profile.name` = node id) and the node's canonical
|
|
205
|
-
* profile is what runs; a driver cannot smuggle capabilities into a worker it did not define.
|
|
206
|
-
* 2. **Observable edges** — every delegates/analyzes/maps/routes traversal lands in an EDGE LEDGER
|
|
207
|
-
* (`delivered | stripped | empty | unpropagated | failed`, with byte counts), in memory on
|
|
208
|
-
* the result AND as `edge` events in the run journal. The motivating incident: a filter
|
|
209
|
-
* silently replaced 1,700-char steering with 241 chars of boilerplate for three rounds and
|
|
210
|
-
* NO artifact said so — an unobservable edge cannot be trusted and its directive cannot be
|
|
211
|
-
* optimized.
|
|
212
|
-
* 3. **Directives as data** — edge text lives in the prompt registry (`<surface>/v<n>`), so every
|
|
213
|
-
* edge is a versioned optimization target, never prose hardcoded in a builder function.
|
|
214
|
-
* 4. **Per-edge traversal caps** — the cyclic-graph backstop. A delegates edge whose cap is
|
|
215
|
-
* exhausted REFUSES further traversals (fail loud), so a cycle cannot spin the pool dry.
|
|
216
|
-
* 5. **Continuity as data** — a delegates edge may declare `continuity: 'resume'`, so each spawn
|
|
217
|
-
* after the node's first re-attaches to its latest SETTLED session (the spawn context hands
|
|
218
|
-
* the executor seam `resume: { ofWorker, sequence }`; the kernel keeps identity, ordering,
|
|
219
|
-
* ledger truth, and the one conserved pool). Every ledger row states how its hop continued:
|
|
220
|
-
* `'fresh' | 'resume'` for spawns, `'steer'` for mid-run deliveries — fresh respawns, session
|
|
221
|
-
* resumes, and live steers are all plain data, each a ledgered fact.
|
|
222
|
-
* 6. **Fan-out over a run-time list** — a `maps` edge takes the array a JSON pointer selects in a
|
|
223
|
-
* node's settled result and runs one item per element, then hands the ordered results to a
|
|
224
|
-
* join node. The runtime spawns every item and the join when the source settles, so the
|
|
225
|
-
* driver spends no model turn on them; each item is a spawn through the same authorized path,
|
|
226
|
-
* reserving from the same conserved pool, and every expansion, item and join is a ledger row.
|
|
227
|
-
* 7. **Flow graphs** — with `entry` set, no node is a root: Runtime spawns the entries and fires
|
|
228
|
-
* `routes` edges on each settle (`graph-flow.ts`), so a fixed order, a branch, a bounded repair
|
|
229
|
-
* loop and a stop rule are graph data. The root manager is Runtime's own and never calls a
|
|
230
|
-
* model; every entry and route spawn takes the same authorized path a map item takes.
|
|
231
|
-
*
|
|
232
|
-
* ORACLES ARE ENVIRONMENT, NEVER WORKERS. Graders/verifiers must not be spawnable in the graph —
|
|
233
|
-
* a delegates edge to them leaks the rubric. An `analyzes` edge names its analyst in one of two
|
|
234
|
-
* forms: a LENS id from the environment's registry (a pure function over trace evidence), or the
|
|
235
|
-
* id of a graph NODE — a tool-equipped analyst AGENT spawned on each matching settle with the
|
|
236
|
-
* node's pinned profile, whose settle output IS the findings. Either way the oracle doctrine
|
|
237
|
-
* holds: an analyst node can never be a delegates target (refused loudly), so no driver can hand
|
|
238
|
-
* it work, and an id living in both the registry and the nodes is refused as ambiguous.
|
|
239
|
-
*
|
|
240
|
-
* @experimental
|
|
241
|
-
*/
|
|
242
|
-
/** A delegates edge exhausted its traversal cap and the run produced no winner: the cap, not the
|
|
243
|
-
* task, ended it. Carries the full evidence so failing loud loses nothing. */
|
|
244
|
-
var GraphEdgeCapError = class extends Error {
|
|
245
|
-
exhaustedEdges;
|
|
246
|
-
ledger;
|
|
247
|
-
result;
|
|
248
|
-
constructor(exhaustedEdges, ledger, result) {
|
|
249
|
-
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.`);
|
|
250
|
-
this.name = "GraphEdgeCapError";
|
|
251
|
-
this.exhaustedEdges = exhaustedEdges;
|
|
252
|
-
this.ledger = ledger;
|
|
253
|
-
this.result = result;
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
/**
|
|
257
|
-
* Every `SuperviseOptions` key, partitioned by what `runGraph` does with it.
|
|
258
|
-
*
|
|
259
|
-
* `runGraph` starts one `supervise()` run, so every option that run honors is a graph option too
|
|
260
|
-
* unless the graph itself owns the value. This used to be an opt-in list written by hand, and the
|
|
261
|
-
* hand lost: 25 of 49 keys never reached `supervise()` from a graph, including `childSettleGraceMs`
|
|
262
|
-
* (a root-driver failure tore down children that had ALREADY computed the deliverable) and
|
|
263
|
-
* `driverRetry` (agent-runtime#963). Each absence was discovered by losing a run.
|
|
264
|
-
*
|
|
265
|
-
* The four lists below must cover `keyof SuperviseOptions` exactly. `everySuperviseOptionIsClassified`
|
|
266
|
-
* below fails to COMPILE, naming the offender, when a key belongs to none of them — so the next
|
|
267
|
-
* option added to `supervise()` cannot go missing here silently. It has to be classified, and
|
|
268
|
-
* classifying it as forwarded is one word.
|
|
269
|
-
*/
|
|
270
|
-
/** The graph derives these from the `AgentGraph` itself; a caller value would be overwritten. */
|
|
271
|
-
const GRAPH_OWNED_SUPERVISE_OPTIONS = [
|
|
272
|
-
"rootDriverFromBackend",
|
|
273
|
-
"resolveSpawnProfile",
|
|
274
|
-
"budget",
|
|
275
|
-
"deliverable",
|
|
276
|
-
"makeWorkerAgent",
|
|
277
|
-
"onCoordinationEvent",
|
|
278
|
-
"analyzeOnSettle",
|
|
279
|
-
"mapOnSettle",
|
|
280
|
-
"routeFlow",
|
|
281
|
-
"continuityByProfile",
|
|
282
|
-
"inheritSpawnRights",
|
|
283
|
-
"promptRegistry"
|
|
284
|
-
];
|
|
285
|
-
/** Caller-facing on `RunGraphOptions`, but the graph wraps or defaults the value before it goes in:
|
|
286
|
-
* `hooks` composes with the graph's own spawn-binding hook, `authorizeMessage` is wrapped so a
|
|
287
|
-
* narrowed instruction ledgers `stripped`, `authorizeSpawn` runs AFTER the graph has pinned the
|
|
288
|
-
* node (so a product sees the canonical profile, never the driver's stub), `makeLeafAgent` is the
|
|
289
|
-
* caller's leaf override slotted under the graph's pinning, `analysts` rides only with analyze
|
|
290
|
-
* routes, and `journal`/`blobs`/`runId` get graph defaults. */
|
|
291
|
-
const GRAPH_TRANSFORMED_SUPERVISE_OPTIONS = [
|
|
292
|
-
"hooks",
|
|
293
|
-
"authorizeMessage",
|
|
294
|
-
"authorizeSpawn",
|
|
295
|
-
"makeLeafAgent",
|
|
296
|
-
"analysts",
|
|
297
|
-
"journal",
|
|
298
|
-
"blobs",
|
|
299
|
-
"runId",
|
|
300
|
-
"decideGate"
|
|
301
|
-
];
|
|
302
|
-
/** Not reachable from a graph, with the reason. `registry` is a NAME COLLISION, not a policy:
|
|
303
|
-
* `RunGraphOptions.registry` is the directive `PromptRegistry` and `SuperviseOptions.registry` is
|
|
304
|
-
* the `SuperviseRegistry` name→value table. Two different types under one name; the graph's wins.
|
|
305
|
-
* Giving the supervise one a graph channel means renaming a public option, so it is recorded here
|
|
306
|
-
* rather than silently dropped. */
|
|
307
|
-
const GRAPH_REFUSED_SUPERVISE_OPTIONS = ["registry"];
|
|
308
|
-
/**
|
|
309
|
-
* Forwarded to the root `supervise()` VERBATIM. Everything not owned, transformed, or refused
|
|
310
|
-
* above belongs here — the default is "a graph honors it", not "someone remembered to add it".
|
|
311
|
-
*/
|
|
312
|
-
const GRAPH_FORWARDED_SUPERVISE_OPTIONS = [
|
|
313
|
-
"parking",
|
|
314
|
-
"backend",
|
|
315
|
-
"profileGuidance",
|
|
316
|
-
"escalateQuestion",
|
|
317
|
-
"rootHandle",
|
|
318
|
-
"signal",
|
|
319
|
-
"execution",
|
|
320
|
-
"resolveDeliverable",
|
|
321
|
-
"coordination",
|
|
322
|
-
"peerMail",
|
|
323
|
-
"peerAudit",
|
|
324
|
-
"traceTools",
|
|
325
|
-
"driverBackend",
|
|
326
|
-
"profileSecurity",
|
|
327
|
-
"authorizeSpawn",
|
|
328
|
-
"router",
|
|
329
|
-
"driveHarness",
|
|
330
|
-
"selectSeat",
|
|
331
|
-
"driverRetry",
|
|
332
|
-
"onDriverAttempt",
|
|
333
|
-
"continuation",
|
|
334
|
-
"childSettleGraceMs",
|
|
335
|
-
"teardownConfirmMs",
|
|
336
|
-
"retainedAtSettlement",
|
|
337
|
-
"resolveDriveHarness",
|
|
338
|
-
"driveHarnessMaterialization",
|
|
339
|
-
"resolveSupervisorTools",
|
|
340
|
-
"extraTools",
|
|
341
|
-
"executeExtraTool",
|
|
342
|
-
"recoverExecutor",
|
|
343
|
-
"perWorker",
|
|
344
|
-
"reservationPolicy",
|
|
345
|
-
"deadlineCheckIn",
|
|
346
|
-
"budgetStopHoldMs",
|
|
347
|
-
"workerSlots",
|
|
348
|
-
"watchWorkers",
|
|
349
|
-
"stallAfterMs",
|
|
350
|
-
"wake",
|
|
351
|
-
"runDir",
|
|
352
|
-
"resume",
|
|
353
|
-
"segment",
|
|
354
|
-
"runContext",
|
|
355
|
-
"steerDir",
|
|
356
|
-
"stopRule",
|
|
357
|
-
"onProgressStop",
|
|
358
|
-
"maxDepth",
|
|
359
|
-
"maxTurns",
|
|
360
|
-
"compaction",
|
|
361
|
-
"now",
|
|
362
|
-
"allowedModels",
|
|
363
|
-
"finalizer",
|
|
364
|
-
"otel",
|
|
365
|
-
"graphRegistry"
|
|
366
|
-
];
|
|
367
|
-
/**
|
|
368
|
-
* Every key `RunGraphOptions` accepts, as data: the forwarded and transformed `SuperviseOptions`
|
|
369
|
-
* keys, the name-colliding `registry`, and the graph's own `brain`. `GRAPH_OWNED_SUPERVISE_OPTIONS`
|
|
370
|
-
* is deliberately absent — a caller value for one of those is overwritten by the graph, so it is
|
|
371
|
-
* refused by name rather than discarded.
|
|
372
|
-
*
|
|
373
|
-
* The assignment below fails to COMPILE, naming the key, when `RunGraphOptions` declares something
|
|
374
|
-
* this list does not carry.
|
|
375
|
-
*/
|
|
376
|
-
const runGraphOptionKeys = [
|
|
377
|
-
...GRAPH_FORWARDED_SUPERVISE_OPTIONS,
|
|
378
|
-
...GRAPH_TRANSFORMED_SUPERVISE_OPTIONS,
|
|
379
|
-
...GRAPH_REFUSED_SUPERVISE_OPTIONS,
|
|
380
|
-
"brain"
|
|
381
|
-
];
|
|
382
|
-
const runGraphOptionKeySet = new Set(runGraphOptionKeys);
|
|
383
|
-
const graphOwnedOptionKeySet = new Set(GRAPH_OWNED_SUPERVISE_OPTIONS);
|
|
384
|
-
/**
|
|
385
|
-
* Refuse an option key the graph would not read, naming it and saying which kind it is.
|
|
386
|
-
*
|
|
387
|
-
* A graph-owned key is the sharper case: it type-checks against a widened `SuperviseOptions`
|
|
388
|
-
* value, the graph derives its own value and overwrites the caller's, the run succeeds, and the
|
|
389
|
-
* capability the caller asked for is not there. The rename of the leaf seam from `makeWorkerAgent`
|
|
390
|
-
* to `makeLeafAgent` is the shape of the failure — the old name stayed a valid `SuperviseOptions`
|
|
391
|
-
* key AND a graph-owned one, so a caller that kept passing it got a run with no leaf override and
|
|
392
|
-
* no complaint.
|
|
393
|
-
*/
|
|
394
|
-
function assertRunGraphOptionKeys(opts) {
|
|
395
|
-
const graphOwned = [];
|
|
396
|
-
const unknown = [];
|
|
397
|
-
for (const key of Object.keys(opts)) {
|
|
398
|
-
if (runGraphOptionKeySet.has(key)) continue;
|
|
399
|
-
if (graphOwnedOptionKeySet.has(key)) graphOwned.push(key);
|
|
400
|
-
else unknown.push(key);
|
|
401
|
-
}
|
|
402
|
-
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`);
|
|
403
|
-
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`);
|
|
404
|
-
}
|
|
405
|
-
/** Copy every forwarded option the caller actually set. Absent stays absent: `supervise()` and the
|
|
406
|
-
* graph must not disagree about what "unset" means. */
|
|
407
|
-
function forwardedSuperviseOptions(opts) {
|
|
408
|
-
const forwarded = {};
|
|
409
|
-
for (const key of GRAPH_FORWARDED_SUPERVISE_OPTIONS) {
|
|
410
|
-
const value = opts[key];
|
|
411
|
-
if (value !== void 0) forwarded[key] = value;
|
|
412
|
-
}
|
|
413
|
-
return forwarded;
|
|
414
|
-
}
|
|
415
|
-
/** Validate the graph and resolve every directive BEFORE any compute is spent — an invalid
|
|
416
|
-
* topology or an unknown directive is a configuration fault, never a mid-run surprise. */
|
|
417
|
-
function validateGraph(graph, registry, analysts) {
|
|
418
|
-
if (graph.entry === void 0) {
|
|
419
|
-
if (!Array.isArray(graph.nodes) || graph.nodes.length === 0) throw new ValidationError("runGraph: graph.nodes must be a non-empty array");
|
|
420
|
-
if (!Array.isArray(graph.edges) || graph.edges.length === 0) throw new ValidationError("runGraph: graph.edges must be a non-empty array");
|
|
421
|
-
}
|
|
422
|
-
if (typeof graph.deliverable?.check !== "function") throw new ValidationError("runGraph: graph.deliverable is mandatory (termination oracle)");
|
|
423
|
-
if (typeof graph.budget !== "object" || graph.budget === null) throw new ValidationError("runGraph: graph.budget is mandatory (the conserved pool)");
|
|
424
|
-
if (graph.entry !== void 0) return validateFlowGraph(graph, registry, analysts);
|
|
425
|
-
if (graph.gates !== void 0) throw new ValidationError("runGraph: graph.gates needs graph.entry");
|
|
426
|
-
return validateGraphTopology(graph.nodes, graph.edges, registry, analysts);
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* Execute an {@link AgentGraph}. A flow graph (`entry` set) runs from its entries and routes edges
|
|
430
|
-
* under a runtime-owned root that places no model call. Otherwise the root node becomes the
|
|
431
|
-
* supervisor (`supervise()` — the execution core), each worker node is spawnable BY NODE ID
|
|
432
|
-
* (`spawn_worker` with `profile: { name: '<node id>' }`; the node's canonical profile is pinned by
|
|
433
|
-
* the graph), each
|
|
434
|
-
* delegates directive is appended to the worker profile's `prompt.instructions` per traversal,
|
|
435
|
-
* and each analyzes edge becomes an analyst-on-settle route with a real DESTINATION. Every
|
|
436
|
-
* traversal is ledgered and journaled.
|
|
437
|
-
*/
|
|
438
|
-
function runGraph(graph, opts) {
|
|
439
|
-
const { brain, ...runtimeOptions } = graphExecutionOptions(opts);
|
|
440
|
-
return superviseAgentGraph(graph, runtimeOptions, brain);
|
|
441
|
-
}
|
|
442
|
-
/** Alias for graph tests written before `RunGraphOptions.brain` was production. The production
|
|
443
|
-
* entry accepts the same shape; this wrapper only keeps the `/testing` import path working. */
|
|
444
|
-
function runGraphWithTestBrain(graph, opts) {
|
|
445
|
-
const { brain, ...runtimeOptions } = opts;
|
|
446
|
-
return superviseAgentGraph(graph, runtimeOptions, brain);
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* The graph supervise run, as its own entry: the engine's `run-graph` preset node executes exactly
|
|
450
|
-
* this, so the preset and `runGraph` are the same code path by construction (agent-runtime#982).
|
|
451
|
-
*/
|
|
452
|
-
/**
|
|
453
|
-
* Every refusal a graph earns before any compute, in one place: the authoring contract. `runGraph`
|
|
454
|
-
* calls it FIRST so a malformed graph throws synchronously, exactly as it did before the engine
|
|
455
|
-
* preset (agent-runtime#982) moved execution behind a promise.
|
|
456
|
-
*/
|
|
457
|
-
function assertRunGraphAuthoring(graph, opts, brain) {
|
|
458
|
-
assertRunGraphOptionKeys(opts);
|
|
459
|
-
const validated = validateGraph(graph, opts.registry ?? kernelPromptRegistry(), opts.analysts);
|
|
460
|
-
const requireLeaves = () => {
|
|
461
|
-
if (!opts.backend && !opts.makeLeafAgent) throw new ValidationError("runGraph: provide opts.backend (where nodes run) or opts.makeLeafAgent");
|
|
462
|
-
};
|
|
463
|
-
if (validated.flow !== void 0) {
|
|
464
|
-
const rootOptions = [...brain ? ["brain"] : [], ...[
|
|
465
|
-
"driverBackend",
|
|
466
|
-
"finalizer",
|
|
467
|
-
"maxTurns",
|
|
468
|
-
"compaction"
|
|
469
|
-
].filter((key) => opts[key] !== void 0)];
|
|
470
|
-
if (rootOptions.length > 0) throw new ValidationError(`runGraph: ${rootOptions.join(", ")} with graph.entry — a flow graph has no root manager: Runtime spawns its entries and traverses its routes edges, and the graph owns the run's output`);
|
|
471
|
-
if ((graph.gates?.length ?? 0) > 0 && opts.decideGate === void 0) throw new ValidationError("runGraph: graph.gates needs opts.decideGate to answer them");
|
|
472
|
-
requireLeaves();
|
|
473
|
-
return validated;
|
|
474
|
-
}
|
|
475
|
-
const { root } = validated;
|
|
476
|
-
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");
|
|
477
|
-
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')`);
|
|
478
|
-
requireLeaves();
|
|
479
|
-
return validated;
|
|
480
|
-
}
|
|
481
|
-
function superviseAgentGraph(graph, opts, brain) {
|
|
482
|
-
if (graph.deliverable.command !== void 0) {
|
|
483
|
-
const bound = bindGraphCommand(graph, opts);
|
|
484
|
-
return superviseAgentGraph(bound.graph, bound.options, brain);
|
|
485
|
-
}
|
|
486
|
-
const registry = opts.registry ?? kernelPromptRegistry();
|
|
487
|
-
if (opts.runContext?.acquire !== void 0) return withRunContext(opts.runContext, opts.signal, (runContext, signal) => superviseAgentGraph(graph, {
|
|
488
|
-
...opts,
|
|
489
|
-
runContext,
|
|
490
|
-
...signal === void 0 ? {} : { signal }
|
|
491
|
-
}, brain));
|
|
492
|
-
const validated = assertRunGraphAuthoring(graph, opts, brain);
|
|
493
|
-
const context = opts.runContext ?? (opts.runDir === void 0 ? createInMemoryRunContext() : createFileRunContext(resolve(opts.runDir)));
|
|
494
|
-
const journal = opts.journal ?? context.journal;
|
|
495
|
-
const blobs = opts.blobs ?? context.blobs;
|
|
496
|
-
const runId = opts.runId ?? opts.runContext?.runId ?? `graph-${canonicalCandidateDigest(graph.nodes.map((n) => n.id)).slice(7, 19)}`;
|
|
497
|
-
const now = opts.now ?? Date.now;
|
|
498
|
-
const guidance = profileGuidanceComposer(opts.profileGuidance);
|
|
499
|
-
const overlay = createGraphOverlay(validated, {
|
|
500
|
-
registry,
|
|
501
|
-
journal,
|
|
502
|
-
runId,
|
|
503
|
-
now,
|
|
504
|
-
...guidance ? { guidance } : {},
|
|
505
|
-
...opts.authorizeSpawn ? { authorizeSpawn: opts.authorizeSpawn } : {}
|
|
506
|
-
});
|
|
507
|
-
const flow = validated.flow === void 0 ? void 0 : createFlowRun(overlay.nodeOfWorker);
|
|
508
|
-
const callerAuthorizeMessage = opts.authorizeMessage;
|
|
509
|
-
const authorizeMessage = overlay.observeMessages((input) => callerAuthorizeMessage ? callerAuthorizeMessage(input) : { instruction: input.instruction });
|
|
510
|
-
const hooks = composeRuntimeHooks({ onEvent: (event) => {
|
|
511
|
-
if (event.target !== "agent.spawn" || event.phase !== "after") return;
|
|
512
|
-
const payload = event.payload;
|
|
513
|
-
if (typeof payload?.childId !== "string" || typeof payload.assignmentId !== "string") return;
|
|
514
|
-
return overlay.bindSpawn(event.parentId, payload.assignmentId, payload.childId);
|
|
515
|
-
} }, opts.hooks);
|
|
516
|
-
const rootProfile = flow === void 0 ? graphRootProfile(validated, registry) : flowRootProfile;
|
|
517
|
-
const rootBrain = flow === void 0 ? brain : runtimeFlowBrain();
|
|
518
|
-
const task = flow === void 0 ? graph.deliverable.describe ?? `Deliver the graph's deliverable by driving your worker nodes (root: '${validated.root.id}').` : graph.deliverable.describe ?? "Runtime runs this flow graph from its entries.";
|
|
519
|
-
const start = async () => {
|
|
520
|
-
const superviseOptions = {
|
|
521
|
-
...forwardedSuperviseOptions(opts),
|
|
522
|
-
rootDriverFromBackend: flow !== void 0,
|
|
523
|
-
budget: graph.budget,
|
|
524
|
-
deliverable: flow?.routeCheck(graph.deliverable) ?? graph.deliverable,
|
|
525
|
-
authorizeSpawn: overlay.authorizeSpawn,
|
|
526
|
-
resolveSpawnProfile: overlay.resolveSpawnProfile,
|
|
527
|
-
inheritSpawnRights: false,
|
|
528
|
-
promptRegistry: registry,
|
|
529
|
-
...opts.makeLeafAgent ? { makeLeafAgent: opts.makeLeafAgent } : {},
|
|
530
|
-
journal,
|
|
531
|
-
blobs,
|
|
532
|
-
runId,
|
|
533
|
-
hooks,
|
|
534
|
-
onCoordinationEvent: async (context, _eventId, record) => {
|
|
535
|
-
if (record.event.type === "route" && context.depth !== 0) return;
|
|
536
|
-
overlay.onCoordinationEvent(record.event);
|
|
537
|
-
flow?.observe(record.event);
|
|
538
|
-
},
|
|
539
|
-
...overlay.routes.length > 0 ? {
|
|
540
|
-
analyzeOnSettle: overlay.routes,
|
|
541
|
-
...opts.analysts ? { analysts: opts.analysts } : {}
|
|
542
|
-
} : {},
|
|
543
|
-
...overlay.maps.length > 0 ? { mapOnSettle: overlay.maps } : {},
|
|
544
|
-
...Object.keys(overlay.continuityByProfile).length > 0 ? { continuityByProfile: overlay.continuityByProfile } : {},
|
|
545
|
-
...flow === void 0 ? {} : {
|
|
546
|
-
routeFlow: routeFlowOf(validated),
|
|
547
|
-
...opts.decideGate && { decideGate: journaledGateDecider(opts.decideGate, journal, runId) },
|
|
548
|
-
finalizer: flow.finalizer,
|
|
549
|
-
wake: {
|
|
550
|
-
debounceMs: 0,
|
|
551
|
-
...opts.wake
|
|
552
|
-
}
|
|
553
|
-
},
|
|
554
|
-
authorizeMessage
|
|
555
|
-
};
|
|
556
|
-
const supervised = rootBrain === void 0 ? await supervise(rootProfile, task, superviseOptions) : await superviseWithTestBrain(rootProfile, task, {
|
|
557
|
-
...superviseOptions,
|
|
558
|
-
brain: rootBrain
|
|
559
|
-
});
|
|
560
|
-
const { ledger, exhaustedEdges, exhaustedDelegates } = await overlay.settle();
|
|
561
|
-
const concluded = flow?.conclude(supervised);
|
|
562
|
-
if (concluded?.kind === "unrouted") throw new GraphRouteError(concluded.unrouted, ledger, supervised);
|
|
563
|
-
const result = concluded?.result ?? supervised;
|
|
564
|
-
const stopped = concluded?.stopped;
|
|
565
|
-
const lifecycleEnded = result.kind === "no-winner" && (result.reason === "aborted" || result.reason === "cancelled" || result.reason === "budget-exhausted" || result.reason === "deadline");
|
|
566
|
-
if (result.kind !== "winner" && !lifecycleEnded && exhaustedDelegates.length > 0) throw new GraphEdgeCapError(exhaustedDelegates, ledger, result);
|
|
567
|
-
return {
|
|
568
|
-
result,
|
|
569
|
-
ledger,
|
|
570
|
-
exhaustedEdges,
|
|
571
|
-
runId,
|
|
572
|
-
...stopped ? { stopped } : {}
|
|
573
|
-
};
|
|
574
|
-
};
|
|
575
|
-
return start();
|
|
576
|
-
}
|
|
577
|
-
export { graphExecutionOptions as a, superviseAgentGraph as i, runGraph as n, runGraphWithTestBrain as r, GraphEdgeCapError as t };
|
|
578
|
-
|
|
579
|
-
//# sourceMappingURL=graph-BjQF2syl.js.map
|