@hazeljs/agent 0.2.0-beta.8 → 0.2.0-beta.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +192 -21
  2. package/README.md +372 -258
  3. package/coverage/clover.xml +853 -576
  4. package/coverage/lcov-report/index.html +107 -62
  5. package/coverage/lcov.info +1428 -945
  6. package/dist/agent.module.d.ts +16 -1
  7. package/dist/agent.module.d.ts.map +1 -1
  8. package/dist/agent.module.js +14 -5
  9. package/dist/agent.module.js.map +1 -1
  10. package/dist/decorators/delegate.decorator.d.ts +66 -0
  11. package/dist/decorators/delegate.decorator.d.ts.map +1 -0
  12. package/dist/decorators/delegate.decorator.js +108 -0
  13. package/dist/decorators/delegate.decorator.js.map +1 -0
  14. package/dist/executor/agent.executor.d.ts +1 -0
  15. package/dist/executor/agent.executor.d.ts.map +1 -1
  16. package/dist/executor/agent.executor.js +19 -10
  17. package/dist/executor/agent.executor.js.map +1 -1
  18. package/dist/executor/tool.executor.d.ts +3 -1
  19. package/dist/executor/tool.executor.d.ts.map +1 -1
  20. package/dist/executor/tool.executor.js +33 -2
  21. package/dist/executor/tool.executor.js.map +1 -1
  22. package/dist/graph/agent-graph.d.ts +131 -0
  23. package/dist/graph/agent-graph.d.ts.map +1 -0
  24. package/dist/graph/agent-graph.js +462 -0
  25. package/dist/graph/agent-graph.js.map +1 -0
  26. package/dist/graph/agent-graph.types.d.ts +210 -0
  27. package/dist/graph/agent-graph.types.d.ts.map +1 -0
  28. package/dist/graph/agent-graph.types.js +12 -0
  29. package/dist/graph/agent-graph.types.js.map +1 -0
  30. package/dist/index.d.ts +4 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +5 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/prompts/agent-system.prompt.d.ts +10 -0
  35. package/dist/prompts/agent-system.prompt.d.ts.map +1 -0
  36. package/dist/prompts/agent-system.prompt.js +18 -0
  37. package/dist/prompts/agent-system.prompt.js.map +1 -0
  38. package/dist/prompts/index.d.ts +4 -0
  39. package/dist/prompts/index.d.ts.map +1 -0
  40. package/dist/prompts/index.js +20 -0
  41. package/dist/prompts/index.js.map +1 -0
  42. package/dist/prompts/supervisor-routing.prompt.d.ts +9 -0
  43. package/dist/prompts/supervisor-routing.prompt.d.ts.map +1 -0
  44. package/dist/prompts/supervisor-routing.prompt.js +22 -0
  45. package/dist/prompts/supervisor-routing.prompt.js.map +1 -0
  46. package/dist/prompts/supervisor-system.prompt.d.ts +9 -0
  47. package/dist/prompts/supervisor-system.prompt.d.ts.map +1 -0
  48. package/dist/prompts/supervisor-system.prompt.js +21 -0
  49. package/dist/prompts/supervisor-system.prompt.js.map +1 -0
  50. package/dist/runtime/agent.runtime.d.ts +65 -2
  51. package/dist/runtime/agent.runtime.d.ts.map +1 -1
  52. package/dist/runtime/agent.runtime.js +105 -4
  53. package/dist/runtime/agent.runtime.js.map +1 -1
  54. package/dist/supervisor/supervisor.d.ts +81 -0
  55. package/dist/supervisor/supervisor.d.ts.map +1 -0
  56. package/dist/supervisor/supervisor.js +220 -0
  57. package/dist/supervisor/supervisor.js.map +1 -0
  58. package/dist/types/agent.types.d.ts +15 -0
  59. package/dist/types/agent.types.d.ts.map +1 -1
  60. package/dist/types/agent.types.js.map +1 -1
  61. package/dist/types/event.types.d.ts +76 -1
  62. package/dist/types/event.types.d.ts.map +1 -1
  63. package/dist/types/event.types.js +16 -0
  64. package/dist/types/event.types.js.map +1 -1
  65. package/dist/utils/circuit-breaker.d.ts +5 -65
  66. package/dist/utils/circuit-breaker.d.ts.map +1 -1
  67. package/dist/utils/circuit-breaker.js +10 -150
  68. package/dist/utils/circuit-breaker.js.map +1 -1
  69. package/logs/combined.log +1 -1
  70. package/package.json +23 -8
  71. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,131 @@
1
+ /**
2
+ * AgentGraph — Multi-Agent Orchestration Graph
3
+ *
4
+ * Provides a LangGraph-inspired DAG runtime for orchestrating multiple agents.
5
+ * Supports sequential pipelines, conditional routing, and parallel fan-out/fan-in.
6
+ *
7
+ * @example Sequential pipeline
8
+ * ```ts
9
+ * const graph = runtime.createGraph('pipeline')
10
+ * .addNode('researcher', { type: 'agent', agentName: 'ResearchAgent' })
11
+ * .addNode('writer', { type: 'agent', agentName: 'WriterAgent' })
12
+ * .addEdge('researcher', 'writer')
13
+ * .addEdge('writer', END)
14
+ * .setEntryPoint('researcher')
15
+ * .compile();
16
+ *
17
+ * const result = await graph.execute('Write a blog about LLMs');
18
+ * ```
19
+ *
20
+ * @example Conditional routing
21
+ * ```ts
22
+ * const graph = runtime.createGraph('router')
23
+ * .addNode('classifier', { type: 'agent', agentName: 'ClassifierAgent' })
24
+ * .addNode('coder', { type: 'agent', agentName: 'CoderAgent' })
25
+ * .addNode('writer', { type: 'agent', agentName: 'WriterAgent' })
26
+ * .setEntryPoint('classifier')
27
+ * .addConditionalEdge('classifier', state => state.data.type === 'code' ? 'coder' : 'writer')
28
+ * .addEdge('coder', END)
29
+ * .addEdge('writer', END)
30
+ * .compile();
31
+ * ```
32
+ *
33
+ * @example Parallel fan-out / fan-in
34
+ * ```ts
35
+ * const graph = runtime.createGraph('parallel')
36
+ * .addNode('splitter', { type: 'function', fn: splitTask })
37
+ * .addNode('parallel-1', { type: 'parallel', branches: ['agent-a', 'agent-b'] })
38
+ * .addNode('agent-a', { type: 'agent', agentName: 'AgentA' })
39
+ * .addNode('agent-b', { type: 'agent', agentName: 'AgentB' })
40
+ * .addNode('combiner', { type: 'function', fn: combineResults })
41
+ * .addEdge('splitter', 'parallel-1')
42
+ * .addEdge('parallel-1', 'combiner')
43
+ * .addEdge('combiner', END)
44
+ * .setEntryPoint('splitter')
45
+ * .compile();
46
+ * ```
47
+ */
48
+ import { GraphNode, GraphNodeConfig, GraphEdge, RouterFunction, GraphExecutionOptions, GraphExecutionResult, GraphStreamChunk } from './agent-graph.types';
49
+ import { AgentExecutionResult } from '../types/agent.types';
50
+ interface RuntimeLike {
51
+ execute(agentName: string, input: string, options?: Record<string, unknown>): Promise<AgentExecutionResult>;
52
+ getAgentMetadata(agentName: string): {
53
+ description?: string;
54
+ } | undefined;
55
+ }
56
+ /**
57
+ * Fluent builder for constructing a multi-agent graph.
58
+ * Call `.compile()` to get an executable `CompiledGraph`.
59
+ */
60
+ export declare class AgentGraph {
61
+ private readonly graphId;
62
+ private readonly runtime;
63
+ private readonly nodes;
64
+ private readonly edges;
65
+ private entryPoint?;
66
+ constructor(graphId: string, runtime: RuntimeLike);
67
+ /**
68
+ * Add a node to the graph.
69
+ *
70
+ * Node types:
71
+ * - `'agent'` — runs a named agent via AgentRuntime
72
+ * - `'function'` — runs an arbitrary async function
73
+ * - `'parallel'` — fans-out to multiple child nodes concurrently
74
+ */
75
+ addNode(id: string, config: GraphNodeConfig): this;
76
+ /**
77
+ * Add an unconditional directed edge from `from` → `to`.
78
+ * Use `END` as the target to terminate the graph.
79
+ */
80
+ addEdge(from: string, to: string): this;
81
+ /**
82
+ * Add a conditional edge from `from`.
83
+ * The `routerFn` inspects the current `GraphState` and returns the ID of
84
+ * the next node (or `END` to stop).
85
+ *
86
+ * @param routeMap Optional mapping of routerFn return values to node IDs,
87
+ * so you can use short keys like `'code'` → `'CoderNode'`.
88
+ */
89
+ addConditionalEdge(from: string, routerFn: RouterFunction, routeMap?: Record<string, string>): this;
90
+ /** Set the node where graph execution begins */
91
+ setEntryPoint(nodeId: string): this;
92
+ /**
93
+ * Validate the graph and return an executable `CompiledGraph`.
94
+ * Throws if the graph is malformed (missing entry point, dangling edges, etc.)
95
+ */
96
+ compile(): CompiledGraph;
97
+ }
98
+ /**
99
+ * Executable graph produced by `AgentGraph.compile()`.
100
+ */
101
+ export declare class CompiledGraph {
102
+ private readonly graphId;
103
+ private readonly nodes;
104
+ private readonly edges;
105
+ private readonly entryPoint;
106
+ private readonly runtime;
107
+ constructor(graphId: string, nodes: Map<string, GraphNode>, edges: GraphEdge[], entryPoint: string, runtime: RuntimeLike);
108
+ /**
109
+ * Execute the graph synchronously (collects all results before returning).
110
+ */
111
+ execute(input: string, options?: GraphExecutionOptions): Promise<GraphExecutionResult>;
112
+ /**
113
+ * Execute the graph and yield a `GraphStreamChunk` after each node completes.
114
+ * Useful for streaming progress updates to the client in real-time.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * for await (const chunk of graph.stream('Research LLMs')) {
119
+ * console.log(`[${chunk.nodeId}]`, chunk.chunk);
120
+ * }
121
+ * ```
122
+ */
123
+ stream(input: string, options?: GraphExecutionOptions): AsyncGenerator<GraphStreamChunk>;
124
+ private executeNode;
125
+ private executeParallelBranches;
126
+ private defaultMerge;
127
+ private resolveNextNode;
128
+ private applyPatch;
129
+ }
130
+ export {};
131
+ //# sourceMappingURL=agent-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-graph.d.ts","sourceRoot":"","sources":["../../src/graph/agent-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAGH,OAAO,EAGL,SAAS,EACT,eAAe,EACf,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EAEpB,gBAAgB,EAGjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAI5D,UAAU,WAAW;IACnB,OAAO,CACL,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACjC,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CAC3E;AAMD;;;GAGG;AACH,qBAAa,UAAU;IAMnB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,O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,WAAW;YAyEX,uBAAuB;IAqBrC,OAAO,CAAC,YAAY;IAmCpB,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,UAAU;CAUnB"}
@@ -0,0 +1,462 @@
1
+ "use strict";
2
+ /**
3
+ * AgentGraph — Multi-Agent Orchestration Graph
4
+ *
5
+ * Provides a LangGraph-inspired DAG runtime for orchestrating multiple agents.
6
+ * Supports sequential pipelines, conditional routing, and parallel fan-out/fan-in.
7
+ *
8
+ * @example Sequential pipeline
9
+ * ```ts
10
+ * const graph = runtime.createGraph('pipeline')
11
+ * .addNode('researcher', { type: 'agent', agentName: 'ResearchAgent' })
12
+ * .addNode('writer', { type: 'agent', agentName: 'WriterAgent' })
13
+ * .addEdge('researcher', 'writer')
14
+ * .addEdge('writer', END)
15
+ * .setEntryPoint('researcher')
16
+ * .compile();
17
+ *
18
+ * const result = await graph.execute('Write a blog about LLMs');
19
+ * ```
20
+ *
21
+ * @example Conditional routing
22
+ * ```ts
23
+ * const graph = runtime.createGraph('router')
24
+ * .addNode('classifier', { type: 'agent', agentName: 'ClassifierAgent' })
25
+ * .addNode('coder', { type: 'agent', agentName: 'CoderAgent' })
26
+ * .addNode('writer', { type: 'agent', agentName: 'WriterAgent' })
27
+ * .setEntryPoint('classifier')
28
+ * .addConditionalEdge('classifier', state => state.data.type === 'code' ? 'coder' : 'writer')
29
+ * .addEdge('coder', END)
30
+ * .addEdge('writer', END)
31
+ * .compile();
32
+ * ```
33
+ *
34
+ * @example Parallel fan-out / fan-in
35
+ * ```ts
36
+ * const graph = runtime.createGraph('parallel')
37
+ * .addNode('splitter', { type: 'function', fn: splitTask })
38
+ * .addNode('parallel-1', { type: 'parallel', branches: ['agent-a', 'agent-b'] })
39
+ * .addNode('agent-a', { type: 'agent', agentName: 'AgentA' })
40
+ * .addNode('agent-b', { type: 'agent', agentName: 'AgentB' })
41
+ * .addNode('combiner', { type: 'function', fn: combineResults })
42
+ * .addEdge('splitter', 'parallel-1')
43
+ * .addEdge('parallel-1', 'combiner')
44
+ * .addEdge('combiner', END)
45
+ * .setEntryPoint('splitter')
46
+ * .compile();
47
+ * ```
48
+ */
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.CompiledGraph = exports.AgentGraph = void 0;
51
+ const crypto_1 = require("crypto");
52
+ const agent_graph_types_1 = require("./agent-graph.types");
53
+ // ---------------------------------------------------------------------------
54
+ // AgentGraph (builder)
55
+ // ---------------------------------------------------------------------------
56
+ /**
57
+ * Fluent builder for constructing a multi-agent graph.
58
+ * Call `.compile()` to get an executable `CompiledGraph`.
59
+ */
60
+ class AgentGraph {
61
+ constructor(graphId, runtime) {
62
+ this.graphId = graphId;
63
+ this.runtime = runtime;
64
+ this.nodes = new Map();
65
+ this.edges = [];
66
+ // Register the sentinel END node
67
+ this.nodes.set(agent_graph_types_1.END, { id: agent_graph_types_1.END, config: { type: 'function', fn: (s) => s } });
68
+ }
69
+ // -------------------------------------------------------------------------
70
+ // Nodes
71
+ // -------------------------------------------------------------------------
72
+ /**
73
+ * Add a node to the graph.
74
+ *
75
+ * Node types:
76
+ * - `'agent'` — runs a named agent via AgentRuntime
77
+ * - `'function'` — runs an arbitrary async function
78
+ * - `'parallel'` — fans-out to multiple child nodes concurrently
79
+ */
80
+ addNode(id, config) {
81
+ if (id === agent_graph_types_1.END) {
82
+ throw new Error(`"${agent_graph_types_1.END}" is a reserved node ID`);
83
+ }
84
+ if (this.nodes.has(id)) {
85
+ throw new Error(`Node "${id}" is already registered in graph "${this.graphId}"`);
86
+ }
87
+ this.nodes.set(id, { id, config });
88
+ return this;
89
+ }
90
+ // -------------------------------------------------------------------------
91
+ // Edges
92
+ // -------------------------------------------------------------------------
93
+ /**
94
+ * Add an unconditional directed edge from `from` → `to`.
95
+ * Use `END` as the target to terminate the graph.
96
+ */
97
+ addEdge(from, to) {
98
+ this.edges.push({ from, to });
99
+ return this;
100
+ }
101
+ /**
102
+ * Add a conditional edge from `from`.
103
+ * The `routerFn` inspects the current `GraphState` and returns the ID of
104
+ * the next node (or `END` to stop).
105
+ *
106
+ * @param routeMap Optional mapping of routerFn return values to node IDs,
107
+ * so you can use short keys like `'code'` → `'CoderNode'`.
108
+ */
109
+ addConditionalEdge(from, routerFn, routeMap) {
110
+ const condition = routeMap
111
+ ? (state) => {
112
+ const key = routerFn(state);
113
+ return routeMap[key] ?? key;
114
+ }
115
+ : routerFn;
116
+ this.edges.push({ from, condition });
117
+ return this;
118
+ }
119
+ /** Set the node where graph execution begins */
120
+ setEntryPoint(nodeId) {
121
+ this.entryPoint = nodeId;
122
+ return this;
123
+ }
124
+ // -------------------------------------------------------------------------
125
+ // Compile
126
+ // -------------------------------------------------------------------------
127
+ /**
128
+ * Validate the graph and return an executable `CompiledGraph`.
129
+ * Throws if the graph is malformed (missing entry point, dangling edges, etc.)
130
+ */
131
+ compile() {
132
+ if (!this.entryPoint) {
133
+ throw new Error(`Graph "${this.graphId}" has no entry point. Call setEntryPoint() first.`);
134
+ }
135
+ if (!this.nodes.has(this.entryPoint)) {
136
+ throw new Error(`Entry point "${this.entryPoint}" is not a registered node in graph "${this.graphId}"`);
137
+ }
138
+ // Validate all edge references
139
+ for (const edge of this.edges) {
140
+ if (!this.nodes.has(edge.from)) {
141
+ throw new Error(`Edge references unknown source node: "${edge.from}"`);
142
+ }
143
+ if (edge.to && edge.to !== agent_graph_types_1.END && !this.nodes.has(edge.to)) {
144
+ throw new Error(`Edge references unknown target node: "${edge.to}"`);
145
+ }
146
+ }
147
+ // Validate parallel branch references
148
+ for (const [, node] of this.nodes) {
149
+ if (node.config.type === 'parallel') {
150
+ for (const branch of node.config.branches) {
151
+ if (!this.nodes.has(branch)) {
152
+ throw new Error(`Parallel node "${node.id}" references unknown branch node: "${branch}"`);
153
+ }
154
+ }
155
+ }
156
+ }
157
+ return new CompiledGraph(this.graphId, new Map(this.nodes), [...this.edges], this.entryPoint, this.runtime);
158
+ }
159
+ }
160
+ exports.AgentGraph = AgentGraph;
161
+ // ---------------------------------------------------------------------------
162
+ // CompiledGraph (executor)
163
+ // ---------------------------------------------------------------------------
164
+ /**
165
+ * Executable graph produced by `AgentGraph.compile()`.
166
+ */
167
+ class CompiledGraph {
168
+ constructor(graphId, nodes, edges, entryPoint, runtime) {
169
+ this.graphId = graphId;
170
+ this.nodes = nodes;
171
+ this.edges = edges;
172
+ this.entryPoint = entryPoint;
173
+ this.runtime = runtime;
174
+ }
175
+ // -------------------------------------------------------------------------
176
+ // execute()
177
+ // -------------------------------------------------------------------------
178
+ /**
179
+ * Execute the graph synchronously (collects all results before returning).
180
+ */
181
+ async execute(input, options = {}) {
182
+ const executionId = `graph_${(0, crypto_1.randomUUID)()}`;
183
+ const startTime = Date.now();
184
+ const steps = [];
185
+ const nodeExecutions = {};
186
+ let state = {
187
+ input,
188
+ messages: [{ role: 'user', content: input, timestamp: new Date() }],
189
+ data: { ...(options.initialData ?? {}) },
190
+ nodeResults: {},
191
+ metadata: { executionId, graphId: this.graphId, ...options },
192
+ };
193
+ const maxSteps = options.maxSteps ?? 50;
194
+ const timeout = options.timeout ?? 600000;
195
+ const deadline = Date.now() + timeout;
196
+ let currentNodeId = this.entryPoint;
197
+ let stepCount = 0;
198
+ try {
199
+ while (currentNodeId !== agent_graph_types_1.END) {
200
+ if (Date.now() > deadline) {
201
+ throw new Error(`Graph "${this.graphId}" exceeded timeout of ${timeout}ms after ${stepCount} steps`);
202
+ }
203
+ if (stepCount >= maxSteps) {
204
+ throw new Error(`Graph "${this.graphId}" exceeded maxSteps (${maxSteps}). Possible infinite loop.`);
205
+ }
206
+ stepCount++;
207
+ const node = this.nodes.get(currentNodeId);
208
+ if (!node) {
209
+ throw new Error(`Node "${currentNodeId}" not found in graph "${this.graphId}"`);
210
+ }
211
+ state = { ...state, currentNode: currentNodeId };
212
+ const stepStart = Date.now();
213
+ const { nextState, agentResult, parallelBranches } = await this.executeNode(node, state, options);
214
+ state = nextState;
215
+ if (agentResult) {
216
+ nodeExecutions[currentNodeId] = agentResult;
217
+ state = { ...state, nodeResults: { ...state.nodeResults, [currentNodeId]: agentResult } };
218
+ }
219
+ steps.push({
220
+ id: `step_${stepCount}`,
221
+ nodeId: currentNodeId,
222
+ nodeType: node.config.type,
223
+ input: state.input,
224
+ output: state.output,
225
+ duration: Date.now() - stepStart,
226
+ timestamp: new Date(),
227
+ parallelBranches,
228
+ });
229
+ currentNodeId = this.resolveNextNode(currentNodeId, state);
230
+ }
231
+ return {
232
+ graphId: this.graphId,
233
+ executionId,
234
+ state,
235
+ response: state.output,
236
+ steps,
237
+ nodeExecutions,
238
+ duration: Date.now() - startTime,
239
+ completedAt: new Date(),
240
+ success: true,
241
+ };
242
+ }
243
+ catch (error) {
244
+ return {
245
+ graphId: this.graphId,
246
+ executionId,
247
+ state: { ...state, error: error },
248
+ steps,
249
+ nodeExecutions,
250
+ duration: Date.now() - startTime,
251
+ completedAt: new Date(),
252
+ success: false,
253
+ error: error,
254
+ };
255
+ }
256
+ }
257
+ // -------------------------------------------------------------------------
258
+ // stream()
259
+ // -------------------------------------------------------------------------
260
+ /**
261
+ * Execute the graph and yield a `GraphStreamChunk` after each node completes.
262
+ * Useful for streaming progress updates to the client in real-time.
263
+ *
264
+ * @example
265
+ * ```ts
266
+ * for await (const chunk of graph.stream('Research LLMs')) {
267
+ * console.log(`[${chunk.nodeId}]`, chunk.chunk);
268
+ * }
269
+ * ```
270
+ */
271
+ async *stream(input, options = {}) {
272
+ const executionId = `graph_${(0, crypto_1.randomUUID)()}`;
273
+ const maxSteps = options.maxSteps ?? 50;
274
+ const timeout = options.timeout ?? 600000;
275
+ const deadline = Date.now() + timeout;
276
+ let state = {
277
+ input,
278
+ messages: [{ role: 'user', content: input, timestamp: new Date() }],
279
+ data: { ...(options.initialData ?? {}) },
280
+ nodeResults: {},
281
+ metadata: { executionId, graphId: this.graphId, ...options },
282
+ };
283
+ let currentNodeId = this.entryPoint;
284
+ let stepCount = 0;
285
+ while (currentNodeId !== agent_graph_types_1.END) {
286
+ if (Date.now() > deadline || stepCount >= maxSteps)
287
+ break;
288
+ stepCount++;
289
+ const node = this.nodes.get(currentNodeId);
290
+ if (!node)
291
+ break;
292
+ state = { ...state, currentNode: currentNodeId };
293
+ const { nextState, agentResult, parallelBranches } = await this.executeNode(node, state, options);
294
+ state = nextState;
295
+ if (agentResult) {
296
+ state = {
297
+ ...state,
298
+ nodeResults: { ...state.nodeResults, [currentNodeId]: agentResult },
299
+ };
300
+ }
301
+ yield {
302
+ executionId,
303
+ nodeId: currentNodeId,
304
+ nodeType: node.config.type,
305
+ chunk: state.output ?? '',
306
+ nodeOutput: state.output,
307
+ done: false,
308
+ };
309
+ if (parallelBranches) {
310
+ for (const branch of parallelBranches) {
311
+ yield {
312
+ executionId,
313
+ nodeId: branch,
314
+ nodeType: 'agent',
315
+ chunk: state.nodeResults[branch]?.response ?? '',
316
+ nodeOutput: state.nodeResults[branch]?.response,
317
+ done: false,
318
+ };
319
+ }
320
+ }
321
+ currentNodeId = this.resolveNextNode(currentNodeId, state);
322
+ }
323
+ yield {
324
+ executionId,
325
+ nodeId: currentNodeId === agent_graph_types_1.END ? agent_graph_types_1.END : currentNodeId,
326
+ nodeType: 'function',
327
+ chunk: state.output ?? '',
328
+ nodeOutput: state.output,
329
+ done: true,
330
+ };
331
+ }
332
+ // -------------------------------------------------------------------------
333
+ // Node execution
334
+ // -------------------------------------------------------------------------
335
+ async executeNode(node, state, options) {
336
+ const config = node.config;
337
+ // -- function node --
338
+ if (config.type === 'function') {
339
+ const patch = await config.fn(state);
340
+ return { nextState: this.applyPatch(state, patch) };
341
+ }
342
+ // -- agent node --
343
+ if (config.type === 'agent') {
344
+ const agentInput = config.inputMapper ? config.inputMapper(state) : state.input;
345
+ const result = await this.runtime.execute(config.agentName, agentInput, {
346
+ sessionId: options.sessionId,
347
+ userId: options.userId,
348
+ });
349
+ let patch;
350
+ if (config.outputMapper) {
351
+ patch = config.outputMapper(result, state);
352
+ }
353
+ else {
354
+ const newMessage = {
355
+ role: 'assistant',
356
+ content: result.response ?? '',
357
+ nodeId: node.id,
358
+ timestamp: new Date(),
359
+ };
360
+ patch = {
361
+ output: result.response,
362
+ messages: [...state.messages, newMessage],
363
+ };
364
+ }
365
+ return {
366
+ nextState: this.applyPatch(state, patch),
367
+ agentResult: result,
368
+ };
369
+ }
370
+ // -- parallel node --
371
+ if (config.type === 'parallel') {
372
+ const branchResults = await this.executeParallelBranches(config.branches, state, options);
373
+ // Apply custom merge or default
374
+ let patch;
375
+ if (config.mergeStrategy) {
376
+ patch = config.mergeStrategy(branchResults, state);
377
+ }
378
+ else {
379
+ patch = this.defaultMerge(branchResults, state);
380
+ }
381
+ return {
382
+ nextState: this.applyPatch(state, patch),
383
+ parallelBranches: config.branches,
384
+ };
385
+ }
386
+ return { nextState: state };
387
+ }
388
+ // -------------------------------------------------------------------------
389
+ // Parallel execution helpers
390
+ // -------------------------------------------------------------------------
391
+ async executeParallelBranches(branchIds, state, options) {
392
+ const tasks = branchIds.map(async (nodeId) => {
393
+ const node = this.nodes.get(nodeId);
394
+ if (!node) {
395
+ return { nodeId, state, error: new Error(`Branch node "${nodeId}" not found`) };
396
+ }
397
+ try {
398
+ const { nextState, agentResult } = await this.executeNode(node, state, options);
399
+ return { nodeId, state: nextState, agentResult };
400
+ }
401
+ catch (err) {
402
+ return { nodeId, state, error: err };
403
+ }
404
+ });
405
+ return Promise.all(tasks);
406
+ }
407
+ defaultMerge(results, base) {
408
+ const messages = [...base.messages];
409
+ const nodeResults = { ...base.nodeResults };
410
+ const data = { ...base.data };
411
+ const outputs = [];
412
+ for (const r of results) {
413
+ if (r.agentResult) {
414
+ nodeResults[r.nodeId] = r.agentResult;
415
+ if (r.agentResult.response) {
416
+ outputs.push(`[${r.nodeId}]: ${r.agentResult.response}`);
417
+ messages.push({
418
+ role: 'assistant',
419
+ content: r.agentResult.response,
420
+ nodeId: r.nodeId,
421
+ timestamp: new Date(),
422
+ });
423
+ }
424
+ }
425
+ // Merge data from parallel states (last-write wins for conflicts)
426
+ Object.assign(data, r.state.data);
427
+ }
428
+ return {
429
+ output: outputs.join('\n\n---\n\n'),
430
+ messages,
431
+ nodeResults,
432
+ data,
433
+ };
434
+ }
435
+ // -------------------------------------------------------------------------
436
+ // Edge resolution
437
+ // -------------------------------------------------------------------------
438
+ resolveNextNode(fromNodeId, state) {
439
+ const edge = this.edges.find((e) => e.from === fromNodeId);
440
+ if (!edge)
441
+ return agent_graph_types_1.END;
442
+ if (edge.condition) {
443
+ return edge.condition(state);
444
+ }
445
+ return edge.to ?? agent_graph_types_1.END;
446
+ }
447
+ // -------------------------------------------------------------------------
448
+ // State helpers
449
+ // -------------------------------------------------------------------------
450
+ applyPatch(state, patch) {
451
+ return {
452
+ ...state,
453
+ ...patch,
454
+ // Always deep-merge these collections rather than replacing them
455
+ data: { ...state.data, ...(patch.data ?? {}) },
456
+ nodeResults: { ...state.nodeResults, ...(patch.nodeResults ?? {}) },
457
+ messages: patch.messages ?? state.messages,
458
+ };
459
+ }
460
+ }
461
+ exports.CompiledGraph = CompiledGraph;
462
+ //# sourceMappingURL=agent-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-graph.js","sourceRoot":"","sources":["../../src/graph/agent-graph.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;;;AAEH,mCAAoC;AACpC,2DAa6B;AAc7B,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E;;;GAGG;AACH,MAAa,UAAU;IAKrB,YACmB,OAAe,EACf,OAAoB;QADpB,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAa;QANtB,UAAK,GAA2B,IAAI,GAAG,EAAE,CAAC;QAC1C,UAAK,GAAgB,EAAE,CAAC;QAOvC,iCAAiC;QACjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,uBAAG,EAAE,EAAE,EAAE,EAAE,uBAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,E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