@ai.ntellect/core 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/.mocharc.json +1 -1
  2. package/README.md +311 -272
  3. package/dist/graph/controller.js +63 -0
  4. package/dist/graph/engine.js +563 -0
  5. package/dist/index.js +6 -6
  6. package/dist/memory/adapters/meilisearch/index.js +249 -0
  7. package/dist/memory/adapters/redis/index.js +96 -0
  8. package/dist/memory/index.js +9 -0
  9. package/dist/services/agenda.js +115 -0
  10. package/dist/services/embedding.js +40 -0
  11. package/dist/services/queue.js +99 -103
  12. package/dist/test/graph/controller.test.js +170 -0
  13. package/dist/test/graph/engine.test.js +465 -0
  14. package/dist/test/memory/adapters/meilisearch.test.js +250 -0
  15. package/dist/test/memory/adapters/redis.test.js +143 -0
  16. package/dist/test/memory/base.test.js +209 -0
  17. package/dist/test/services/agenda.test.js +230 -0
  18. package/dist/test/services/queue.test.js +258 -0
  19. package/dist/types/index.js +2 -0
  20. package/dist/utils/generate-object.js +32 -11
  21. package/dist/utils/inject-actions.js +2 -2
  22. package/dist/utils/queue-item-transformer.js +2 -2
  23. package/dist/utils/state-manager.js +20 -0
  24. package/graph/controller.ts +60 -0
  25. package/{services/workflow.ts → graph/engine.ts} +331 -113
  26. package/index.ts +7 -7
  27. package/interfaces/index.ts +119 -0
  28. package/memory/adapters/meilisearch/index.ts +286 -0
  29. package/memory/adapters/redis/index.ts +103 -0
  30. package/memory/index.ts +22 -0
  31. package/package.json +7 -2
  32. package/services/agenda.ts +48 -43
  33. package/services/embedding.ts +26 -0
  34. package/services/queue.ts +2 -29
  35. package/test/.env.test +4 -0
  36. package/test/graph/controller.test.ts +186 -0
  37. package/test/graph/engine.test.ts +563 -0
  38. package/test/memory/adapters/meilisearch.test.ts +297 -0
  39. package/test/memory/adapters/redis.test.ts +160 -0
  40. package/test/memory/base.test.ts +229 -0
  41. package/test/services/agenda.test.ts +280 -0
  42. package/test/services/queue.test.ts +286 -44
  43. package/tsconfig.json +10 -10
  44. package/types/index.ts +270 -0
  45. package/utils/generate-object.js +111 -0
  46. package/utils/header-builder.js +34 -0
  47. package/utils/inject-actions.js +16 -0
  48. package/utils/queue-item-transformer.js +24 -0
  49. package/utils/queue-item-transformer.ts +8 -11
  50. package/utils/sanitize-results.js +60 -0
  51. package/utils/schema-generator.js +46 -0
  52. package/utils/state-manager.js +20 -0
  53. package/utils/state-manager.ts +17 -12
  54. package/.nvmrc +0 -1
  55. package/README.FR.md +0 -916
  56. package/agent/index.ts +0 -151
  57. package/agent/workflow/conditions.ts +0 -16
  58. package/agent/workflow/handlers/interpreter.handler.ts +0 -48
  59. package/agent/workflow/handlers/memory.handler.ts +0 -106
  60. package/agent/workflow/handlers/orchestrator.handler.ts +0 -23
  61. package/agent/workflow/handlers/queue.handler.ts +0 -34
  62. package/agent/workflow/handlers/scheduler.handler.ts +0 -61
  63. package/agent/workflow/index.ts +0 -62
  64. package/dist/agent/index.d.ts +0 -38
  65. package/dist/agent/index.js +0 -143
  66. package/dist/agent/tools/get-rss.d.ts +0 -16
  67. package/dist/agent/tools/get-rss.js +0 -62
  68. package/dist/bull.d.ts +0 -1
  69. package/dist/bull.js +0 -9
  70. package/dist/examples/index.d.ts +0 -2
  71. package/dist/examples/index.js +0 -89
  72. package/dist/index.d.ts +0 -7
  73. package/dist/llm/interpreter/context.d.ts +0 -15
  74. package/dist/llm/interpreter/context.js +0 -89
  75. package/dist/llm/interpreter/index.d.ts +0 -21
  76. package/dist/llm/interpreter/index.js +0 -87
  77. package/dist/llm/memory-manager/context.d.ts +0 -2
  78. package/dist/llm/memory-manager/context.js +0 -22
  79. package/dist/llm/memory-manager/index.d.ts +0 -17
  80. package/dist/llm/memory-manager/index.js +0 -107
  81. package/dist/llm/orchestrator/context.d.ts +0 -2
  82. package/dist/llm/orchestrator/context.js +0 -23
  83. package/dist/llm/orchestrator/index.d.ts +0 -44
  84. package/dist/llm/orchestrator/index.js +0 -139
  85. package/dist/llm/orchestrator/types.d.ts +0 -12
  86. package/dist/memory/cache.d.ts +0 -22
  87. package/dist/memory/cache.js +0 -165
  88. package/dist/memory/persistent.d.ts +0 -57
  89. package/dist/memory/persistent.js +0 -189
  90. package/dist/services/queue.d.ts +0 -13
  91. package/dist/services/redis-cache.d.ts +0 -37
  92. package/dist/services/redis-cache.js +0 -93
  93. package/dist/services/scheduler.d.ts +0 -40
  94. package/dist/services/scheduler.js +0 -99
  95. package/dist/services/telegram-monitor.d.ts +0 -0
  96. package/dist/services/telegram-monitor.js +0 -118
  97. package/dist/t.d.ts +0 -46
  98. package/dist/t.js +0 -102
  99. package/dist/test.d.ts +0 -0
  100. package/dist/test.js +0 -438
  101. package/dist/types.d.ts +0 -258
  102. package/dist/types.js +0 -22
  103. package/dist/utils/generate-object.d.ts +0 -12
  104. package/dist/utils/header-builder.d.ts +0 -11
  105. package/dist/utils/inject-actions.d.ts +0 -2
  106. package/dist/utils/queue-item-transformer.d.ts +0 -7
  107. package/dist/utils/sanitize-results.d.ts +0 -17
  108. package/dist/utils/schema-generator.d.ts +0 -16
  109. package/examples/actions/get-rss.ts +0 -71
  110. package/examples/index.ts +0 -98
  111. package/index.html +0 -42
  112. package/llm/dynamic-condition/example.ts +0 -36
  113. package/llm/dynamic-condition/index.ts +0 -108
  114. package/llm/interpreter/context.ts +0 -94
  115. package/llm/interpreter/index.ts +0 -140
  116. package/llm/memory-manager/context.ts +0 -19
  117. package/llm/memory-manager/index.ts +0 -115
  118. package/llm/orchestrator/context.ts +0 -19
  119. package/llm/orchestrator/index.ts +0 -192
  120. package/llm/orchestrator/types.ts +0 -14
  121. package/memory/cache.ts +0 -221
  122. package/memory/persistent.ts +0 -265
  123. package/script.js +0 -167
  124. package/services/cache.ts +0 -298
  125. package/services/telegram-monitor.ts +0 -138
  126. package/t.py +0 -79
  127. package/t.ts +0 -25
  128. package/test/llm/orchestrator.test.ts +0 -47
  129. package/test/llm/synthesizer.test.ts +0 -31
  130. package/types.ts +0 -367
  131. /package/dist/{llm/orchestrator/types.js → interfaces/index.js} +0 -0
@@ -0,0 +1,563 @@
1
+ import { GraphEngine } from "@/graph/engine";
2
+ import { Persistence, RealTimeNotifier } from "@/interfaces";
3
+ import { GraphDefinition, SharedState } from "@/types";
4
+ import { expect } from "chai";
5
+ import { z } from "zod";
6
+
7
+ /**
8
+ * Test suite for the Graph service
9
+ * This suite tests the workflow execution engine that manages state transitions and node execution
10
+ */
11
+ describe("Graph", () => {
12
+ /**
13
+ * Test schema definition using Zod
14
+ * Defines the structure and validation rules for the workflow state
15
+ */
16
+ const TestSchema = z.object({
17
+ status: z.string(),
18
+ step: z.number(),
19
+ });
20
+
21
+ type TestState = z.infer<typeof TestSchema>;
22
+
23
+ let graph: GraphEngine<TestState>;
24
+ /**
25
+ * Test definition of a simple workflow graph
26
+ * Contains 3 nodes: start -> process -> end
27
+ * Each node updates the state with new status and step values
28
+ */
29
+ const testDefinition: GraphDefinition<TestState> = {
30
+ name: "simple-workflow",
31
+ entryNode: "start",
32
+ nodes: {
33
+ start: {
34
+ name: "start",
35
+ description: "Starting node",
36
+ execute: async (_params: any, state: SharedState<TestState>) => {
37
+ return graph.updateState({
38
+ context: {
39
+ ...state.context,
40
+ status: "started",
41
+ step: 1,
42
+ },
43
+ });
44
+ },
45
+ relationships: [{ name: "process" }],
46
+ },
47
+ process: {
48
+ name: "process",
49
+ description: "Processing node",
50
+ execute: async (_params: any, state: SharedState<TestState>) => {
51
+ return graph.updateState({
52
+ context: {
53
+ ...state.context,
54
+ status: "processing",
55
+ step: 2,
56
+ },
57
+ });
58
+ },
59
+ condition: (state) => state.context.step === 1,
60
+ relationships: [{ name: "end" }],
61
+ },
62
+ end: {
63
+ name: "end",
64
+ description: "End node",
65
+ execute: async (_params: any, state: SharedState<TestState>) => {
66
+ return graph.updateState({
67
+ context: {
68
+ ...state.context,
69
+ status: "completed",
70
+ step: 3,
71
+ },
72
+ });
73
+ },
74
+ relationships: [],
75
+ },
76
+ },
77
+ schema: TestSchema,
78
+ };
79
+
80
+ beforeEach(() => {
81
+ graph = new GraphEngine(testDefinition);
82
+ });
83
+
84
+ describe("Workflow Execution", () => {
85
+ /**
86
+ * Tests the complete execution flow of the workflow
87
+ * Verifies that state transitions occur correctly from start to end
88
+ */
89
+ it("should execute the complete workflow sequence", async () => {
90
+ const initialState: SharedState<TestState> = {
91
+ context: {
92
+ status: "init",
93
+ step: 0,
94
+ },
95
+ };
96
+
97
+ // Initialiser le graph avec l'état initial
98
+ graph = new GraphEngine(testDefinition, {
99
+ schema: TestSchema,
100
+ initialState,
101
+ });
102
+
103
+ // Exécuter le workflow
104
+ await graph.execute(initialState, "start");
105
+ const result = graph.getState();
106
+
107
+ expect(result.context).to.deep.equal({
108
+ status: "completed",
109
+ step: 3,
110
+ });
111
+ });
112
+
113
+ /**
114
+ * Tests that conditional logic in nodes is respected
115
+ * The process node should only execute when step === 1
116
+ */
117
+ it("should respect conditions in workflow", async () => {
118
+ const initialState: SharedState<TestState> = {
119
+ context: {
120
+ status: "init",
121
+ step: 2,
122
+ },
123
+ };
124
+
125
+ // Initialiser le graph avec l'état initial
126
+ graph = new GraphEngine(testDefinition, {
127
+ schema: TestSchema,
128
+ initialState,
129
+ });
130
+
131
+ await graph.execute(initialState, "process");
132
+ const result = graph.getState();
133
+
134
+ expect(result.context).to.deep.equal({
135
+ status: "init",
136
+ step: 2,
137
+ });
138
+ });
139
+ });
140
+
141
+ describe("Graph Management", () => {
142
+ it("should add a new node to the graph", () => {
143
+ const newNode = {
144
+ name: "new-node",
145
+ description: "A new test node",
146
+ execute: async (_params: any, state: SharedState<TestState>) => {
147
+ return graph.updateState({
148
+ context: {
149
+ ...state.context,
150
+ status: "new",
151
+ step: 4,
152
+ },
153
+ });
154
+ },
155
+ };
156
+
157
+ graph.addNode(newNode, {
158
+ relationships: [{ name: "end" }],
159
+ });
160
+
161
+ expect(graph.nodes.has("new-node")).to.be.true;
162
+ const addedNode = graph.nodes.get("new-node");
163
+ expect(addedNode?.relationships).to.have.lengthOf(1);
164
+ });
165
+
166
+ it("should update existing graph with new definition", () => {
167
+ const newDefinition: GraphDefinition<TestState> = {
168
+ name: "updated-workflow",
169
+ entryNode: "start",
170
+ nodes: {
171
+ ...testDefinition.nodes,
172
+ "new-step": {
173
+ name: "new-step",
174
+ description: "New step node",
175
+ execute: async (_params: any, state: SharedState<TestState>) => {
176
+ return graph.updateState({
177
+ context: {
178
+ ...state.context,
179
+ status: "new-step",
180
+ step: 4,
181
+ },
182
+ });
183
+ },
184
+ relationships: [],
185
+ },
186
+ },
187
+ schema: TestSchema,
188
+ };
189
+
190
+ graph.updateGraph(newDefinition);
191
+ expect(graph.nodes.has("new-step")).to.be.true;
192
+ });
193
+ });
194
+
195
+ describe("State Management", () => {
196
+ it("should properly update and retrieve state", async () => {
197
+ const newState: SharedState<TestState> = {
198
+ context: {
199
+ status: "test",
200
+ step: 5,
201
+ },
202
+ };
203
+
204
+ graph.setState(newState);
205
+ const retrievedState = graph.getState();
206
+
207
+ expect(retrievedState.context).to.deep.equal(newState.context);
208
+ });
209
+
210
+ it("should merge states correctly when updating partially", () => {
211
+ const initialState: SharedState<TestState> = {
212
+ context: {
213
+ status: "initial",
214
+ step: 1,
215
+ },
216
+ };
217
+
218
+ graph.setState(initialState);
219
+
220
+ const partialUpdate = {
221
+ context: {
222
+ status: "updated",
223
+ },
224
+ };
225
+
226
+ const updatedState = graph.updateState(partialUpdate);
227
+
228
+ expect(updatedState.context).to.deep.equal({
229
+ status: "updated",
230
+ step: 1,
231
+ });
232
+ });
233
+ });
234
+
235
+ describe("Error Handling", () => {
236
+ it("should handle execution errors gracefully", async () => {
237
+ const errorNode = {
238
+ name: "error-node",
239
+ execute: async () => {
240
+ throw new Error("Test error");
241
+ },
242
+ };
243
+
244
+ graph.addNode(errorNode, {});
245
+
246
+ let errorCaught = false;
247
+ try {
248
+ await graph.execute(
249
+ { context: { status: "test", step: 1 } },
250
+ "error-node",
251
+ undefined,
252
+ (error) => {
253
+ expect(error.message).to.equal("Test error");
254
+ errorCaught = true;
255
+ }
256
+ );
257
+ } catch (error) {
258
+ expect(error).to.be.instanceOf(Error);
259
+ expect((error as Error).message).to.equal("Test error");
260
+ }
261
+
262
+ expect(errorCaught).to.be.true;
263
+ });
264
+
265
+ it("should validate state against schema", async () => {
266
+ // Créer un nouveau graph avec validation stricte
267
+ const strictGraph = new GraphEngine(testDefinition, {
268
+ schema: TestSchema,
269
+ initialState: {
270
+ context: {
271
+ status: "init",
272
+ step: 0,
273
+ },
274
+ },
275
+ });
276
+
277
+ const invalidState: SharedState<any> = {
278
+ context: {
279
+ status: 123, // Should be string
280
+ step: "invalid", // Should be number
281
+ },
282
+ };
283
+
284
+ try {
285
+ await strictGraph.execute(invalidState, "start");
286
+ // Si on arrive ici, le test doit échouer car on s'attend à une erreur
287
+ expect.fail("Expected validation error but none was thrown");
288
+ } catch (error) {
289
+ expect(error).to.be.instanceOf(Error);
290
+ const errorMessage = (error as Error).message;
291
+ expect(
292
+ errorMessage.includes("Expected string") ||
293
+ errorMessage.includes("Expected number") ||
294
+ errorMessage.includes("validation")
295
+ ).to.be.true;
296
+ }
297
+ });
298
+ });
299
+
300
+ describe("Parallel Execution", () => {
301
+ /**
302
+ * Tests concurrent execution of multiple nodes
303
+ * Important: The execution order is not guaranteed due to async nature
304
+ * @param concurrency - Maximum number of nodes that can execute simultaneously
305
+ */
306
+ it("should execute multiple nodes in parallel", async () => {
307
+ const executionOrder: string[] = [];
308
+
309
+ const parallelNodes = ["node1", "node2", "node3"].map((name) => ({
310
+ name,
311
+ execute: async (_params: any, state: SharedState<TestState>) => {
312
+ executionOrder.push(name);
313
+ await new Promise((resolve) => setTimeout(resolve, 10));
314
+ return state;
315
+ },
316
+ }));
317
+
318
+ parallelNodes.forEach((node) => {
319
+ graph.addNode(node, {});
320
+ });
321
+
322
+ await graph.executeParallel(
323
+ { context: { status: "test", step: 1 } },
324
+ ["node1", "node2", "node3"],
325
+ 2
326
+ );
327
+
328
+ expect(executionOrder).to.have.lengthOf(3);
329
+ expect(executionOrder).to.include.members(["node1", "node2", "node3"]);
330
+ });
331
+ });
332
+
333
+ describe("Event Handling", () => {
334
+ /**
335
+ * Tests the event emission and handling system
336
+ * Events can trigger node execution asynchronously
337
+ * Note: Uses setTimeout to ensure event processing completes
338
+ */
339
+ it("should emit and handle events correctly", async () => {
340
+ const eventNode = {
341
+ name: "event-node",
342
+ execute: async (_params: any, state: SharedState<TestState>) => {
343
+ return graph.updateState({
344
+ context: {
345
+ ...state.context,
346
+ status: "event-triggered",
347
+ step: 10,
348
+ },
349
+ });
350
+ },
351
+ events: ["test-event"],
352
+ };
353
+
354
+ graph.addNode(eventNode, { events: ["test-event"] });
355
+
356
+ // Émettre l'événement
357
+ graph.emit("test-event", {
358
+ state: { context: { status: "init", step: 0 } },
359
+ });
360
+
361
+ // Attendre un peu pour que l'événement soit traité
362
+ await new Promise((resolve) => setTimeout(resolve, 50));
363
+
364
+ const state = graph.getState();
365
+ expect(state.context.status).to.equal("event-triggered");
366
+ expect(state.context.status).to.equal("event-triggered");
367
+ });
368
+ });
369
+
370
+ describe("Subgraph Integration", () => {
371
+ /**
372
+ * Tests nested workflow execution through subgraphs
373
+ * Subgraphs allow modular workflow composition
374
+ * The main graph can delegate execution to subgraphs
375
+ */
376
+ it("should execute subgraph as part of main graph", async () => {
377
+ const subGraphDef: GraphDefinition<TestState> = {
378
+ name: "sub-workflow",
379
+ entryNode: "sub-start",
380
+ nodes: {
381
+ "sub-start": {
382
+ name: "sub-start",
383
+ execute: async (_params: any, state: SharedState<TestState>) => {
384
+ return graph.updateState({
385
+ context: {
386
+ ...state.context,
387
+ status: "sub-completed",
388
+ step: 100,
389
+ },
390
+ });
391
+ },
392
+ relationships: [],
393
+ },
394
+ },
395
+ schema: TestSchema,
396
+ };
397
+
398
+ const subGraph = new GraphEngine(subGraphDef);
399
+ graph.addSubGraph(subGraph, "sub-start", "sub-workflow");
400
+
401
+ const initialState: SharedState<TestState> = {
402
+ context: {
403
+ status: "init",
404
+ step: 0,
405
+ },
406
+ };
407
+
408
+ await graph.execute(initialState, "sub-workflow");
409
+ const state = graph.getState();
410
+
411
+ expect(state.context.status).to.equal("sub-completed");
412
+ expect(state.context.step).to.equal(100);
413
+ });
414
+ });
415
+
416
+ describe("Global Context Management", () => {
417
+ it("should manage global context correctly", () => {
418
+ graph.addToContext("testKey", "testValue");
419
+ expect(graph.getContext("testKey")).to.equal("testValue");
420
+
421
+ graph.removeFromContext("testKey");
422
+ expect(graph.getContext("testKey")).to.be.undefined;
423
+ });
424
+
425
+ it("should handle multiple context values", () => {
426
+ graph.addToContext("key1", "value1");
427
+ graph.addToContext("key2", { nested: "value2" });
428
+
429
+ expect(graph.getContext("key1")).to.equal("value1");
430
+ expect(graph.getContext("key2")).to.deep.equal({ nested: "value2" });
431
+ });
432
+ });
433
+
434
+ describe("Graph Visualization", () => {
435
+ it("should generate valid mermaid diagram", () => {
436
+ const diagram = graph.generateMermaidDiagram("Test Workflow");
437
+ expect(diagram).to.include("flowchart TD");
438
+ expect(diagram).to.include("subgraph Test Workflow");
439
+ expect(diagram).to.include("start");
440
+ expect(diagram).to.include("process");
441
+ expect(diagram).to.include("end");
442
+ });
443
+ });
444
+
445
+ describe("Schema Visualization", () => {
446
+ /**
447
+ * Tests the schema visualization functionality
448
+ * This helps developers understand the workflow structure
449
+ * The visualization includes:
450
+ * - Node relationships
451
+ * - State schema
452
+ * - Validation rules
453
+ */
454
+ it("should generate schema visualization", () => {
455
+ // Créer un nouveau graph avec un schéma pour le test
456
+ const graphWithSchema = new GraphEngine(testDefinition, {
457
+ schema: TestSchema,
458
+ });
459
+
460
+ const schemaVisualization = graphWithSchema.visualizeSchema();
461
+
462
+ // Vérifier les sections attendues dans la visualisation
463
+ expect(schemaVisualization).to.include("📋 Graph:");
464
+ expect(schemaVisualization).to.include("🔷 Nodes:");
465
+
466
+ // Vérifier les détails du schéma
467
+ expect(schemaVisualization).to.satisfy((text: string) => {
468
+ return text.includes("status:") && text.includes("step:");
469
+ });
470
+
471
+ // Vérifier la présence des nœuds
472
+ expect(schemaVisualization).to.include("start");
473
+ expect(schemaVisualization).to.include("process");
474
+ expect(schemaVisualization).to.include("end");
475
+ });
476
+ });
477
+
478
+ describe("Persistence Integration", () => {
479
+ it("should work with persistence layer", async () => {
480
+ const mockPersistence: Persistence<TestState> = {
481
+ saveState: async (graphName, state, currentNode) => {
482
+ expect(graphName).to.equal("simple-workflow");
483
+ expect(state.context).to.exist;
484
+ expect(currentNode).to.exist;
485
+ },
486
+ loadState: async () => null,
487
+ };
488
+
489
+ graph.setPersistence(mockPersistence);
490
+ await graph.execute({ context: { status: "init", step: 0 } }, "start");
491
+ });
492
+ });
493
+
494
+ describe("Real-time Notifications", () => {
495
+ /**
496
+ * Tests the notification system during workflow execution
497
+ * Notifications are sent for:
498
+ * - Node execution start
499
+ * - Node execution completion
500
+ * - State updates
501
+ * - Error events
502
+ */
503
+ it("should send notifications during execution", async () => {
504
+ const notifications: any[] = [];
505
+ const mockNotifier: RealTimeNotifier = {
506
+ notify: (event, data) => {
507
+ notifications.push({ event, data });
508
+ },
509
+ };
510
+
511
+ graph.setNotifier(mockNotifier);
512
+ await graph.execute({ context: { status: "init", step: 0 } }, "start");
513
+
514
+ expect(notifications).to.have.length.greaterThan(0);
515
+ expect(notifications[0].event).to.equal("nodeExecutionStarted");
516
+ expect(notifications).to.deep.include.members([
517
+ {
518
+ event: "nodeExecutionCompleted",
519
+ data: {
520
+ workflow: "simple-workflow",
521
+ node: "start",
522
+ state: {
523
+ context: {
524
+ status: "started",
525
+ step: 1,
526
+ },
527
+ },
528
+ },
529
+ },
530
+ ]);
531
+ });
532
+ });
533
+
534
+ describe("Cycle Detection", () => {
535
+ /**
536
+ * Tests the cycle detection mechanism
537
+ * Cycles in workflow definitions can cause infinite loops
538
+ * The graph constructor should detect and prevent cyclic dependencies
539
+ */
540
+ it("should detect cycles in graph", () => {
541
+ const cyclicDefinition: GraphDefinition<TestState> = {
542
+ name: "cyclic-workflow",
543
+ entryNode: "node1",
544
+ nodes: {
545
+ node1: {
546
+ name: "node1",
547
+ execute: async (state) => state,
548
+ relationships: [{ name: "node2" }],
549
+ },
550
+ node2: {
551
+ name: "node2",
552
+ execute: async (state) => state,
553
+ relationships: [{ name: "node1" }],
554
+ },
555
+ },
556
+ };
557
+
558
+ expect(
559
+ () => new GraphEngine(cyclicDefinition, { autoDetectCycles: true })
560
+ ).to.throw;
561
+ });
562
+ });
563
+ });