flowcraft 2.8.0 → 2.8.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.
Files changed (228) hide show
  1. package/README.md +1 -1
  2. package/dist/index-D3dyjW2G.d.mts +1269 -0
  3. package/dist/index.d.mts +2 -0
  4. package/dist/index.mjs +727 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/dist/replay-BB11M6K1.mjs +107 -0
  7. package/dist/replay-BB11M6K1.mjs.map +1 -0
  8. package/dist/runtime-CmefIAu_.mjs +2216 -0
  9. package/dist/runtime-CmefIAu_.mjs.map +1 -0
  10. package/dist/{sdk.d.ts → sdk.d.mts} +14 -12
  11. package/dist/sdk.mjs +29 -0
  12. package/dist/sdk.mjs.map +1 -0
  13. package/dist/testing/index.d.mts +172 -0
  14. package/dist/testing/index.mjs +277 -0
  15. package/dist/testing/index.mjs.map +1 -0
  16. package/package.json +13 -13
  17. package/dist/adapters/index.d.ts +0 -4
  18. package/dist/adapters/index.js +0 -4
  19. package/dist/adapters/index.js.map +0 -1
  20. package/dist/adapters/persistent-event-bus.d.ts +0 -69
  21. package/dist/adapters/persistent-event-bus.js +0 -3
  22. package/dist/adapters/persistent-event-bus.js.map +0 -1
  23. package/dist/analysis.d.ts +0 -53
  24. package/dist/analysis.js +0 -3
  25. package/dist/analysis.js.map +0 -1
  26. package/dist/chunk-26VTGQAF.js +0 -103
  27. package/dist/chunk-26VTGQAF.js.map +0 -1
  28. package/dist/chunk-27STBUGG.js +0 -44
  29. package/dist/chunk-27STBUGG.js.map +0 -1
  30. package/dist/chunk-2TSADFQX.js +0 -46
  31. package/dist/chunk-2TSADFQX.js.map +0 -1
  32. package/dist/chunk-3Y5O5EGB.js +0 -3
  33. package/dist/chunk-3Y5O5EGB.js.map +0 -1
  34. package/dist/chunk-4JUPOFSL.js +0 -76
  35. package/dist/chunk-4JUPOFSL.js.map +0 -1
  36. package/dist/chunk-4PELJWF7.js +0 -29
  37. package/dist/chunk-4PELJWF7.js.map +0 -1
  38. package/dist/chunk-55J6XMHW.js +0 -3
  39. package/dist/chunk-55J6XMHW.js.map +0 -1
  40. package/dist/chunk-5A24LVGQ.js +0 -90
  41. package/dist/chunk-5A24LVGQ.js.map +0 -1
  42. package/dist/chunk-6RKHCJUU.js +0 -29
  43. package/dist/chunk-6RKHCJUU.js.map +0 -1
  44. package/dist/chunk-7EBKWATZ.js +0 -86
  45. package/dist/chunk-7EBKWATZ.js.map +0 -1
  46. package/dist/chunk-BC4G7OM6.js +0 -42
  47. package/dist/chunk-BC4G7OM6.js.map +0 -1
  48. package/dist/chunk-BCRWXTWX.js +0 -21
  49. package/dist/chunk-BCRWXTWX.js.map +0 -1
  50. package/dist/chunk-BV6MXL74.js +0 -340
  51. package/dist/chunk-BV6MXL74.js.map +0 -1
  52. package/dist/chunk-CIXL7AKH.js +0 -532
  53. package/dist/chunk-CIXL7AKH.js.map +0 -1
  54. package/dist/chunk-DL7KVYZF.js +0 -39
  55. package/dist/chunk-DL7KVYZF.js.map +0 -1
  56. package/dist/chunk-E6ICIXVR.js +0 -25
  57. package/dist/chunk-E6ICIXVR.js.map +0 -1
  58. package/dist/chunk-HFJXYY4E.js +0 -3
  59. package/dist/chunk-HFJXYY4E.js.map +0 -1
  60. package/dist/chunk-HNHM3FDK.js +0 -52
  61. package/dist/chunk-HNHM3FDK.js.map +0 -1
  62. package/dist/chunk-I53JB2KW.js +0 -26
  63. package/dist/chunk-I53JB2KW.js.map +0 -1
  64. package/dist/chunk-IDTYHLDQ.js +0 -16
  65. package/dist/chunk-IDTYHLDQ.js.map +0 -1
  66. package/dist/chunk-IKOTX22J.js +0 -85
  67. package/dist/chunk-IKOTX22J.js.map +0 -1
  68. package/dist/chunk-K446NZ4E.js +0 -25
  69. package/dist/chunk-K446NZ4E.js.map +0 -1
  70. package/dist/chunk-L3MX5MTA.js +0 -33
  71. package/dist/chunk-L3MX5MTA.js.map +0 -1
  72. package/dist/chunk-L46TQXCV.js +0 -144
  73. package/dist/chunk-L46TQXCV.js.map +0 -1
  74. package/dist/chunk-LM4ACVHL.js +0 -73
  75. package/dist/chunk-LM4ACVHL.js.map +0 -1
  76. package/dist/chunk-LNK7LZER.js +0 -51
  77. package/dist/chunk-LNK7LZER.js.map +0 -1
  78. package/dist/chunk-NVLZFLYM.js +0 -3
  79. package/dist/chunk-NVLZFLYM.js.map +0 -1
  80. package/dist/chunk-ONH7PIJZ.js +0 -300
  81. package/dist/chunk-ONH7PIJZ.js.map +0 -1
  82. package/dist/chunk-OOJEXFYY.js +0 -47
  83. package/dist/chunk-OOJEXFYY.js.map +0 -1
  84. package/dist/chunk-PH2IYZHV.js +0 -48
  85. package/dist/chunk-PH2IYZHV.js.map +0 -1
  86. package/dist/chunk-PU2VTWJD.js +0 -164
  87. package/dist/chunk-PU2VTWJD.js.map +0 -1
  88. package/dist/chunk-QA2WDZPV.js +0 -74
  89. package/dist/chunk-QA2WDZPV.js.map +0 -1
  90. package/dist/chunk-RM677CNU.js +0 -52
  91. package/dist/chunk-RM677CNU.js.map +0 -1
  92. package/dist/chunk-TKSSRS5U.js +0 -39
  93. package/dist/chunk-TKSSRS5U.js.map +0 -1
  94. package/dist/chunk-UNORA7EM.js +0 -103
  95. package/dist/chunk-UNORA7EM.js.map +0 -1
  96. package/dist/chunk-VZ4BRDBK.js +0 -54
  97. package/dist/chunk-VZ4BRDBK.js.map +0 -1
  98. package/dist/chunk-X5RJOZY2.js +0 -279
  99. package/dist/chunk-X5RJOZY2.js.map +0 -1
  100. package/dist/chunk-ZETQCNEF.js +0 -139
  101. package/dist/chunk-ZETQCNEF.js.map +0 -1
  102. package/dist/chunk-ZKINHLMS.js +0 -230
  103. package/dist/chunk-ZKINHLMS.js.map +0 -1
  104. package/dist/chunk-ZLW4QOTS.js +0 -192
  105. package/dist/chunk-ZLW4QOTS.js.map +0 -1
  106. package/dist/container-factory.d.ts +0 -17
  107. package/dist/container-factory.js +0 -13
  108. package/dist/container-factory.js.map +0 -1
  109. package/dist/container.d.ts +0 -23
  110. package/dist/container.js +0 -3
  111. package/dist/container.js.map +0 -1
  112. package/dist/context.d.ts +0 -65
  113. package/dist/context.js +0 -3
  114. package/dist/context.js.map +0 -1
  115. package/dist/error-mapper.d.ts +0 -15
  116. package/dist/error-mapper.js +0 -4
  117. package/dist/error-mapper.js.map +0 -1
  118. package/dist/errors.d.ts +0 -20
  119. package/dist/errors.js +0 -3
  120. package/dist/errors.js.map +0 -1
  121. package/dist/evaluator.d.ts +0 -32
  122. package/dist/evaluator.js +0 -3
  123. package/dist/evaluator.js.map +0 -1
  124. package/dist/flow.d.ts +0 -83
  125. package/dist/flow.js +0 -4
  126. package/dist/flow.js.map +0 -1
  127. package/dist/index.d.ts +0 -18
  128. package/dist/index.js +0 -38
  129. package/dist/index.js.map +0 -1
  130. package/dist/linter.d.ts +0 -26
  131. package/dist/linter.js +0 -4
  132. package/dist/linter.js.map +0 -1
  133. package/dist/logger.d.ts +0 -20
  134. package/dist/logger.js +0 -3
  135. package/dist/logger.js.map +0 -1
  136. package/dist/node.d.ts +0 -3
  137. package/dist/node.js +0 -3
  138. package/dist/node.js.map +0 -1
  139. package/dist/nodes/batch-gather.d.ts +0 -9
  140. package/dist/nodes/batch-gather.js +0 -4
  141. package/dist/nodes/batch-gather.js.map +0 -1
  142. package/dist/nodes/batch-scatter.d.ts +0 -9
  143. package/dist/nodes/batch-scatter.js +0 -4
  144. package/dist/nodes/batch-scatter.js.map +0 -1
  145. package/dist/nodes/sleep.d.ts +0 -9
  146. package/dist/nodes/sleep.js +0 -4
  147. package/dist/nodes/sleep.js.map +0 -1
  148. package/dist/nodes/subflow.d.ts +0 -9
  149. package/dist/nodes/subflow.js +0 -10
  150. package/dist/nodes/subflow.js.map +0 -1
  151. package/dist/nodes/wait.d.ts +0 -9
  152. package/dist/nodes/wait.js +0 -4
  153. package/dist/nodes/wait.js.map +0 -1
  154. package/dist/nodes/webhook.d.ts +0 -13
  155. package/dist/nodes/webhook.js +0 -4
  156. package/dist/nodes/webhook.js.map +0 -1
  157. package/dist/runtime/adapter.d.ts +0 -114
  158. package/dist/runtime/adapter.js +0 -28
  159. package/dist/runtime/adapter.js.map +0 -1
  160. package/dist/runtime/builtin-keys.d.ts +0 -38
  161. package/dist/runtime/builtin-keys.js +0 -10
  162. package/dist/runtime/builtin-keys.js.map +0 -1
  163. package/dist/runtime/execution-context.d.ts +0 -3
  164. package/dist/runtime/execution-context.js +0 -6
  165. package/dist/runtime/execution-context.js.map +0 -1
  166. package/dist/runtime/executors.d.ts +0 -3
  167. package/dist/runtime/executors.js +0 -4
  168. package/dist/runtime/executors.js.map +0 -1
  169. package/dist/runtime/index.d.ts +0 -7
  170. package/dist/runtime/index.js +0 -31
  171. package/dist/runtime/index.js.map +0 -1
  172. package/dist/runtime/node-executor-factory.d.ts +0 -12
  173. package/dist/runtime/node-executor-factory.js +0 -6
  174. package/dist/runtime/node-executor-factory.js.map +0 -1
  175. package/dist/runtime/orchestrator.d.ts +0 -9
  176. package/dist/runtime/orchestrator.js +0 -8
  177. package/dist/runtime/orchestrator.js.map +0 -1
  178. package/dist/runtime/orchestrators/replay.d.ts +0 -45
  179. package/dist/runtime/orchestrators/replay.js +0 -3
  180. package/dist/runtime/orchestrators/replay.js.map +0 -1
  181. package/dist/runtime/orchestrators/step-by-step.d.ts +0 -16
  182. package/dist/runtime/orchestrators/step-by-step.js +0 -5
  183. package/dist/runtime/orchestrators/step-by-step.js.map +0 -1
  184. package/dist/runtime/orchestrators/utils.d.ts +0 -35
  185. package/dist/runtime/orchestrators/utils.js +0 -4
  186. package/dist/runtime/orchestrators/utils.js.map +0 -1
  187. package/dist/runtime/runtime.d.ts +0 -3
  188. package/dist/runtime/runtime.js +0 -27
  189. package/dist/runtime/runtime.js.map +0 -1
  190. package/dist/runtime/scheduler.d.ts +0 -3
  191. package/dist/runtime/scheduler.js +0 -3
  192. package/dist/runtime/scheduler.js.map +0 -1
  193. package/dist/runtime/state.d.ts +0 -3
  194. package/dist/runtime/state.js +0 -5
  195. package/dist/runtime/state.js.map +0 -1
  196. package/dist/runtime/traverser.d.ts +0 -3
  197. package/dist/runtime/traverser.js +0 -5
  198. package/dist/runtime/traverser.js.map +0 -1
  199. package/dist/runtime/types.d.ts +0 -3
  200. package/dist/runtime/types.js +0 -3
  201. package/dist/runtime/types.js.map +0 -1
  202. package/dist/runtime/workflow-logic-handler.d.ts +0 -17
  203. package/dist/runtime/workflow-logic-handler.js +0 -5
  204. package/dist/runtime/workflow-logic-handler.js.map +0 -1
  205. package/dist/sanitizer.d.ts +0 -12
  206. package/dist/sanitizer.js +0 -3
  207. package/dist/sanitizer.js.map +0 -1
  208. package/dist/sdk.js +0 -20
  209. package/dist/sdk.js.map +0 -1
  210. package/dist/serializer.d.ts +0 -18
  211. package/dist/serializer.js +0 -3
  212. package/dist/serializer.js.map +0 -1
  213. package/dist/testing/event-logger.d.ts +0 -63
  214. package/dist/testing/event-logger.js +0 -3
  215. package/dist/testing/event-logger.js.map +0 -1
  216. package/dist/testing/index.d.ts +0 -7
  217. package/dist/testing/index.js +0 -37
  218. package/dist/testing/index.js.map +0 -1
  219. package/dist/testing/run-with-trace.d.ts +0 -38
  220. package/dist/testing/run-with-trace.js +0 -33
  221. package/dist/testing/run-with-trace.js.map +0 -1
  222. package/dist/testing/stepper.d.ts +0 -79
  223. package/dist/testing/stepper.js +0 -11
  224. package/dist/testing/stepper.js.map +0 -1
  225. package/dist/types-Biip2gLh.d.ts +0 -676
  226. package/dist/types.d.ts +0 -3
  227. package/dist/types.js +0 -3
  228. package/dist/types.js.map +0 -1
@@ -1,53 +0,0 @@
1
- import { h as WorkflowBlueprint, z as FlowcraftEvent } from './types-Biip2gLh.js';
2
- import './errors.js';
3
- import './container.js';
4
-
5
- /**
6
- * A list of cycles found in the graph. Each cycle is an array of node IDs.
7
- */
8
- type Cycles = string[][];
9
- /**
10
- * Analysis result for a workflow blueprint
11
- */
12
- interface BlueprintAnalysis {
13
- /** Cycles found in the graph */
14
- cycles: Cycles;
15
- /** Node IDs that have no incoming edges (start nodes) */
16
- startNodeIds: string[];
17
- /** Node IDs that have no outgoing edges (terminal nodes) */
18
- terminalNodeIds: string[];
19
- /** Total number of nodes */
20
- nodeCount: number;
21
- /** Total number of edges */
22
- edgeCount: number;
23
- /** Whether the graph is a valid DAG (no cycles) */
24
- isDag: boolean;
25
- }
26
- /**
27
- * Analyzes a workflow blueprint to detect cycles using an iterative DFS algorithm.
28
- * This avoids stack overflow issues for deep graphs compared to the recursive version.
29
- * @param blueprint The WorkflowBlueprint object containing nodes and edges.
30
- * @returns An array of cycles found. Each cycle is represented as an array of node IDs.
31
- */
32
- declare function checkForCycles(blueprint: WorkflowBlueprint): Cycles;
33
- /**
34
- * Generates Mermaid diagram syntax from a WorkflowBlueprint
35
- * @param blueprint The WorkflowBlueprint object containing nodes and edges
36
- * @returns Mermaid syntax string for the flowchart
37
- */
38
- declare function generateMermaid(blueprint: WorkflowBlueprint): string;
39
- /**
40
- * Generates Mermaid diagram syntax from a WorkflowBlueprint with execution history styling
41
- * @param blueprint The WorkflowBlueprint object containing nodes and edges
42
- * @param events Array of FlowcraftEvent objects from the workflow execution
43
- * @returns Mermaid syntax string for the flowchart with execution path highlighting
44
- */
45
- declare function generateMermaidForRun(blueprint: WorkflowBlueprint, events: FlowcraftEvent[]): string;
46
- /**
47
- * Analyzes a workflow blueprint and returns comprehensive analysis
48
- * @param blueprint The WorkflowBlueprint object containing nodes and edges
49
- * @returns Analysis result with cycles, start nodes, terminal nodes, and other metrics
50
- */
51
- declare function analyzeBlueprint(blueprint: WorkflowBlueprint): BlueprintAnalysis;
52
-
53
- export { type BlueprintAnalysis, type Cycles, analyzeBlueprint, checkForCycles, generateMermaid, generateMermaidForRun };
package/dist/analysis.js DELETED
@@ -1,3 +0,0 @@
1
- export { analyzeBlueprint, checkForCycles, generateMermaid, generateMermaidForRun } from './chunk-ZLW4QOTS.js';
2
- //# sourceMappingURL=analysis.js.map
3
- //# sourceMappingURL=analysis.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"analysis.js"}
@@ -1,103 +0,0 @@
1
- import { FlowcraftError } from './chunk-BCRWXTWX.js';
2
-
3
- // src/runtime/orchestrators/utils.ts
4
- async function executeBatch(readyNodes, blueprint, state, executorFactory, runtime, maxConcurrency) {
5
- const concurrency = maxConcurrency || readyNodes.length;
6
- const results = [];
7
- for (let i = 0; i < readyNodes.length; i += concurrency) {
8
- const batch = readyNodes.slice(i, i + concurrency);
9
- const batchPromises = batch.map(async ({ nodeId }) => {
10
- try {
11
- const executor = executorFactory(nodeId);
12
- if (!executor) throw new Error(`No executor for node ${nodeId}`);
13
- const executionResult = await executor.execute(
14
- await runtime.resolveNodeInput(nodeId, blueprint, state.getContext())
15
- );
16
- results.push({
17
- status: "fulfilled",
18
- value: { nodeId, executionResult }
19
- });
20
- } catch (error) {
21
- results.push({
22
- status: "rejected",
23
- reason: { nodeId, error }
24
- });
25
- }
26
- });
27
- await Promise.all(batchPromises);
28
- }
29
- return results;
30
- }
31
- async function processResults(settledResults, traverser, state, runtime, _blueprint, executionId) {
32
- for (const promiseResult of settledResults) {
33
- if (promiseResult.status === "rejected") {
34
- const { nodeId: nodeId2, error } = promiseResult.reason;
35
- if (error instanceof FlowcraftError && error.message.includes("cancelled")) {
36
- throw error;
37
- }
38
- state.addError(nodeId2, error);
39
- continue;
40
- }
41
- const { nodeId, executionResult } = promiseResult.value;
42
- if (executionResult.status === "success") {
43
- const result = executionResult.result;
44
- if (result) {
45
- state.addCompletedNode(nodeId, result.output);
46
- if (result._fallbackExecuted) {
47
- state.markFallbackExecuted();
48
- }
49
- if (result.dynamicNodes && result.dynamicNodes.length > 0) {
50
- const gatherNodeId = result.output?.gatherNodeId;
51
- for (const dynamicNode of result.dynamicNodes) {
52
- traverser.addDynamicNode(dynamicNode.id, dynamicNode, nodeId, gatherNodeId);
53
- }
54
- }
55
- }
56
- const matched = await runtime.determineNextNodes(
57
- traverser.getDynamicBlueprint(),
58
- nodeId,
59
- result,
60
- state.getContext(),
61
- executionId
62
- );
63
- for (const { node, edge } of matched) {
64
- await runtime.applyEdgeTransform(
65
- edge,
66
- result,
67
- node,
68
- state.getContext(),
69
- traverser.getAllPredecessors(),
70
- executionId
71
- );
72
- }
73
- traverser.markNodeCompleted(
74
- nodeId,
75
- result,
76
- matched.map((m) => m.node)
77
- );
78
- } else if (executionResult.status === "failed_with_fallback") {
79
- const { fallbackNodeId, error } = executionResult;
80
- const blueprint = traverser.getDynamicBlueprint();
81
- const fallbackNodeDef = blueprint.nodes.find((n) => n.id === fallbackNodeId);
82
- if (!fallbackNodeDef) {
83
- const notFoundError = new FlowcraftError(`Fallback node '${fallbackNodeId}' not found in blueprint.`, {
84
- nodeId,
85
- cause: error
86
- });
87
- state.addError(nodeId, notFoundError);
88
- } else {
89
- state.addCompletedNode(nodeId, null);
90
- state.markFallbackExecuted();
91
- traverser.markNodeCompleted(nodeId, { action: "fallback", output: null, _fallbackExecuted: true }, [
92
- fallbackNodeDef
93
- ]);
94
- }
95
- } else {
96
- state.addError(nodeId, executionResult.error);
97
- }
98
- }
99
- }
100
-
101
- export { executeBatch, processResults };
102
- //# sourceMappingURL=chunk-26VTGQAF.js.map
103
- //# sourceMappingURL=chunk-26VTGQAF.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/runtime/orchestrators/utils.ts"],"names":["nodeId"],"mappings":";;;AAMA,eAAsB,aACrB,UAAA,EACA,SAAA,EACA,KAAA,EACA,eAAA,EACA,SACA,cAAA,EAMC;AACD,EAAA,MAAM,WAAA,GAAc,kBAAkB,UAAA,CAAW,MAAA;AACjD,EAAA,MAAM,UAGF,EAAC;AAEL,EAAA,KAAA,IAAS,IAAI,CAAA,EAAG,CAAA,GAAI,UAAA,CAAW,MAAA,EAAQ,KAAK,WAAA,EAAa;AACxD,IAAA,MAAM,KAAA,GAAQ,UAAA,CAAW,KAAA,CAAM,CAAA,EAAG,IAAI,WAAW,CAAA;AACjD,IAAA,M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AAA,QACA,OAAA,CAAQ,GAAA,CAAI,CAAC,CAAA,KAA2C,EAAE,IAAI;AAAA,OAC/D;AAAA,IACD,CAAA,MAAA,IAAW,eAAA,CAAgB,MAAA,KAAW,sBAAA,EAAwB;AAC7D,MAAA,MAAM,EAAE,cAAA,EAAgB,KAAA,EAAM,GAAI,eAAA;AAClC,MAAA,MAAM,SAAA,GAAY,UAAU,mBAAA,EAAoB;AAChD,MAAA,MAAM,eAAA,GAAkB,UAAU,KAAA,CAAM,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,cAAc,CAAA;AAE3E,MAAA,IAAI,CAAC,eAAA,EAAiB;AACrB,QAAA,MAAM,aAAA,GAAgB,IAAI,cAAA,CAAe,CAAA,eAAA,EAAkB,cAAc,CAAA,yBAAA,CAAA,EAA6B;AAAA,UACrG,MAAA;AAAA,UACA,KAAA,EAAO;AAAA,SACP,CAAA;AACD,QAAA,KAAA,CAAM,QAAA,CAAS,QAAQ,aAAa,CAAA;AAAA,MACrC,CAAA,MAAO;AACN,QAAA,KAAA,CAAM,gBAAA,CAAiB,QAAQ,IAAI,CAAA;AACnC,QAAA,KAAA,CAAM,oBAAA,EAAqB;AAE3B,QAAA,SAAA,CAAU,iBAAA,CAAkB,QAAQ,EAAE,MAAA,EAAQ,YAAY,MAAA,EAAQ,IAAA,EAAM,iBAAA,EAAmB,IAAA,EAAK,EAAG;AAAA,UAClG;AAAA,SACA,CAAA;AAAA,MACF;AAAA,IACD,CAAA,MAAO;AACN,MAAA,KAAA,CAAM,QAAA,CAAS,MAAA,EAAQ,eAAA,CAAgB,KAAK,CAAA;AAAA,IAC7C;AAAA,EACD;AACD","file":"chunk-26VTGQAF.js","sourcesContent":["import { FlowcraftError } from '../../errors'\nimport type { NodeDefinition, WorkflowBlueprint } from '../../types'\nimport type { NodeExecutionResult } from '../executors'\nimport type { WorkflowState } from '../state'\nimport type { GraphTraverser } from '../traverser'\n\nexport async function executeBatch(\n\treadyNodes: Array<{ nodeId: string; nodeDef: any }>,\n\tblueprint: WorkflowBlueprint,\n\tstate: WorkflowState<any>,\n\texecutorFactory: (nodeId: string) => any,\n\truntime: any,\n\tmaxConcurrency?: number,\n): Promise<\n\tArray<\n\t\t| { status: 'fulfilled'; value: { nodeId: string; executionResult: NodeExecutionResult } }\n\t\t| { status: 'rejected'; reason: { nodeId: string; error: unknown } }\n\t>\n> {\n\tconst concurrency = maxConcurrency || readyNodes.length\n\tconst results: Array<\n\t\t| { status: 'fulfilled'; value: { nodeId: string; executionResult: NodeExecutionResult } }\n\t\t| { status: 'rejected'; reason: { nodeId: string; error: unknown } }\n\t> = []\n\n\tfor (let i = 0; i < readyNodes.length; i += concurrency) {\n\t\tconst batch = readyNodes.slice(i, i + concurrency)\n\t\tconst batchPromises = batch.map(async ({ nodeId }) => {\n\t\t\ttry {\n\t\t\t\tconst executor = executorFactory(nodeId)\n\t\t\t\tif (!executor) throw new Error(`No executor for node ${nodeId}`)\n\t\t\t\tconst executionResult = await executor.execute(\n\t\t\t\t\tawait runtime.resolveNodeInput(nodeId, blueprint, state.getContext()),\n\t\t\t\t)\n\t\t\t\tresults.push({\n\t\t\t\t\tstatus: 'fulfilled' as const,\n\t\t\t\t\tvalue: { nodeId, executionResult },\n\t\t\t\t})\n\t\t\t} catch (error) {\n\t\t\t\tresults.push({\n\t\t\t\t\tstatus: 'rejected' as const,\n\t\t\t\t\treason: { nodeId, error },\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\tawait Promise.all(batchPromises)\n\t}\n\n\treturn results\n}\n\nexport async function processResults(\n\tsettledResults: Array<\n\t\t| { status: 'fulfilled'; value: { nodeId: string; executionResult: NodeExecutionResult } }\n\t\t| { status: 'rejected'; reason: { nodeId: string; error: unknown } }\n\t>,\n\ttraverser: GraphTraverser,\n\tstate: WorkflowState<any>,\n\truntime: any,\n\t_blueprint: WorkflowBlueprint,\n\texecutionId?: string,\n): Promise<void> {\n\tfor (const promiseResult of settledResults) {\n\t\tif (promiseResult.status === 'rejected') {\n\t\t\tconst { nodeId, error } = promiseResult.reason\n\t\t\tif (error instanceof FlowcraftError && error.message.includes('cancelled')) {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tstate.addError(nodeId, error as Error)\n\t\t\tcontinue\n\t\t}\n\n\t\tconst { nodeId, executionResult } = promiseResult.value\n\n\t\tif (executionResult.status === 'success') {\n\t\t\tconst result = executionResult.result\n\t\t\tif (result) {\n\t\t\t\tstate.addCompletedNode(nodeId, result.output)\n\t\t\t\tif (result._fallbackExecuted) {\n\t\t\t\t\tstate.markFallbackExecuted()\n\t\t\t\t}\n\n\t\t\t\tif (result.dynamicNodes && result.dynamicNodes.length > 0) {\n\t\t\t\t\tconst gatherNodeId = result.output?.gatherNodeId\n\t\t\t\t\tfor (const dynamicNode of result.dynamicNodes) {\n\t\t\t\t\t\ttraverser.addDynamicNode(dynamicNode.id, dynamicNode, nodeId, gatherNodeId)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst matched = await runtime.determineNextNodes(\n\t\t\t\ttraverser.getDynamicBlueprint(),\n\t\t\t\tnodeId,\n\t\t\t\tresult,\n\t\t\t\tstate.getContext(),\n\t\t\t\texecutionId,\n\t\t\t)\n\n\t\t\tfor (const { node, edge } of matched) {\n\t\t\t\tawait runtime.applyEdgeTransform(\n\t\t\t\t\tedge,\n\t\t\t\t\tresult,\n\t\t\t\t\tnode,\n\t\t\t\t\tstate.getContext(),\n\t\t\t\t\ttraverser.getAllPredecessors(),\n\t\t\t\t\texecutionId,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\ttraverser.markNodeCompleted(\n\t\t\t\tnodeId,\n\t\t\t\tresult,\n\t\t\t\tmatched.map((m: { node: NodeDefinition; edge: any }) => m.node),\n\t\t\t)\n\t\t} else if (executionResult.status === 'failed_with_fallback') {\n\t\t\tconst { fallbackNodeId, error } = executionResult\n\t\t\tconst blueprint = traverser.getDynamicBlueprint()\n\t\t\tconst fallbackNodeDef = blueprint.nodes.find((n) => n.id === fallbackNodeId)\n\n\t\t\tif (!fallbackNodeDef) {\n\t\t\t\tconst notFoundError = new FlowcraftError(`Fallback node '${fallbackNodeId}' not found in blueprint.`, {\n\t\t\t\t\tnodeId,\n\t\t\t\t\tcause: error,\n\t\t\t\t})\n\t\t\t\tstate.addError(nodeId, notFoundError)\n\t\t\t} else {\n\t\t\t\tstate.addCompletedNode(nodeId, null)\n\t\t\t\tstate.markFallbackExecuted()\n\n\t\t\t\ttraverser.markNodeCompleted(nodeId, { action: 'fallback', output: null, _fallbackExecuted: true }, [\n\t\t\t\t\tfallbackNodeDef,\n\t\t\t\t])\n\t\t\t}\n\t\t} else {\n\t\t\tstate.addError(nodeId, executionResult.error)\n\t\t}\n\t}\n}\n"]}
@@ -1,44 +0,0 @@
1
- import { FlowcraftError } from './chunk-BCRWXTWX.js';
2
-
3
- // src/error-mapper.ts
4
- function createErrorMapper(manifestBlueprints) {
5
- const locationMap = /* @__PURE__ */ new Map();
6
- for (const blueprint of Object.values(manifestBlueprints)) {
7
- for (const node of blueprint.nodes) {
8
- if (node._sourceLocation) {
9
- locationMap.set(node.id, node._sourceLocation);
10
- }
11
- }
12
- for (const edge of blueprint.edges) {
13
- if (edge._sourceLocation) {
14
- const edgeKey = `${edge.source}-${edge.target}`;
15
- locationMap.set(edgeKey, edge._sourceLocation);
16
- }
17
- }
18
- }
19
- return function mapError(error) {
20
- if (error instanceof FlowcraftError && error.nodeId) {
21
- const location = locationMap.get(error.nodeId);
22
- if (location) {
23
- return new Error(
24
- `Workflow error at ${location.file}:${location.line}:${location.column}. Original error: ${error.message}`
25
- );
26
- }
27
- }
28
- const nodeIdMatch = error.message.match(/nodeId[:\s]+([^\s,]+)/i);
29
- if (nodeIdMatch) {
30
- const nodeId = nodeIdMatch[1];
31
- const location = locationMap.get(nodeId);
32
- if (location) {
33
- return new Error(
34
- `Workflow error at ${location.file}:${location.line}:${location.column}. Original error: ${error.message}`
35
- );
36
- }
37
- }
38
- return error;
39
- };
40
- }
41
-
42
- export { createErrorMapper };
43
- //# sourceMappingURL=chunk-27STBUGG.js.map
44
- //# sourceMappingURL=chunk-27STBUGG.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/error-mapper.ts"],"names":[],"mappings":";;;AAWO,SAAS,kBAAkB,kBAAA,EAAuD;AACxF,EAAA,MAAM,WAAA,uBAAkB,GAAA,EAA4B;AAGpD,EAAA,KAAA,MAAW,SAAA,IAAa,MAAA,CAAO,MAAA,CAAO,kBAAkB,CAAA,EAAG;AAC1D,IAAA,KAAA,MAAW,IAAA,IAAQ,UAAU,KAAA,EAAO;AACnC,MAAA,IAAI,KAAK,eAAA,EAAiB;AACzB,QAAA,WAAA,CAAY,GAAA,CAAI,IAAA,CAAK,EAAA,EAAI,IAAA,CAAK,eAAe,CAAA;AAAA,MAC9C;AAAA,IACD;AACA,IAAA,KAAA,MAAW,IAAA,IAAQ,UAAU,KAAA,EAAO;AACnC,MAAA,IAAI,KAAK,eAAA,EAAiB;AACzB,QAAA,MAAM,UAAU,CAAA,EAAG,IAAA,CAAK,MAAM,CAAA,CAAA,EAAI,KAAK,MAAM,CAAA,CAAA;AAC7C,QAAA,WAAA,CAAY,GAAA,CAAI,OAAA,EAAS,IAAA,CAAK,eAAe,CAAA;AAAA,MAC9C;AAAA,IACD;AAAA,EACD;AAEA,EAAA,OAAO,SAAS,SAAS,KAAA,EAAqB;AAC7C,IAAA,IAAI,KAAA,YAAiB,cAAA,IAAkB,KAAA,CAAM,MAAA,EAAQ;AACpD,MAAA,MAAM,QAAA,GAAW,WAAA,CAAY,GAAA,CAAI,KAAA,CAAM,MAAM,CAAA;AAC7C,MAAA,IAAI,QAAA,EAAU;AACb,QAAA,OAAO,IAAI,KAAA;AAAA,UACV,CAAA,kBAAA,EAAqB,QAAA,CAAS,IAAI,CAAA,CAAA,EAAI,QAAA,CAAS,IAAI,CAAA,CAAA,EAAI,QAAA,CAAS,MAAM,CAAA,kBAAA,EAAqB,KAAA,CAAM,OAAO,CAAA;AAAA,SACzG;AAAA,MACD;AAAA,IACD;AAGA,IAAA,MAAM,WAAA,GAAc,KAAA,CAAM,OAAA,CAAQ,KAAA,CAAM,wBAAwB,CAAA;AAChE,IAAA,IAAI,WAAA,EAAa;AAChB,MAAA,MAAM,MAAA,GAAS,YAAY,CAAC,CAAA;AAC5B,MAAA,MAAM,QAAA,GAAW,WAAA,CAAY,GAAA,CAAI,MAAM,CAAA;AACvC,MAAA,IAAI,QAAA,EAAU;AACb,QAAA,OAAO,IAAI,KAAA;AAAA,UACV,CAAA,kBAAA,EAAqB,QAAA,CAAS,IAAI,CAAA,CAAA,EAAI,QAAA,CAAS,IAAI,CAAA,CAAA,EAAI,QAAA,CAAS,MAAM,CAAA,kBAAA,EAAqB,KAAA,CAAM,OAAO,CAAA;AAAA,SACzG;AAAA,MACD;AAAA,IACD;AAEA,IAAA,OAAO,KAAA;AAAA,EACR,CAAA;AACD","file":"chunk-27STBUGG.js","sourcesContent":["import { FlowcraftError } from './errors'\nimport type { SourceLocation, WorkflowBlueprint } from './types'\n\n/**\n * Creates an error mapper function that enhances runtime errors with source location information.\n * The mapper looks up node IDs in the provided manifest blueprints and returns enhanced errors\n * that point to the original TypeScript source code.\n *\n * @param manifestBlueprints - The compiled blueprint manifest containing source location data\n * @returns A function that maps errors to enhanced errors with source location information\n */\nexport function createErrorMapper(manifestBlueprints: Record<string, WorkflowBlueprint>) {\n\tconst locationMap = new Map<string, SourceLocation>()\n\n\t// build a quick lookup map\n\tfor (const blueprint of Object.values(manifestBlueprints)) {\n\t\tfor (const node of blueprint.nodes) {\n\t\t\tif (node._sourceLocation) {\n\t\t\t\tlocationMap.set(node.id, node._sourceLocation)\n\t\t\t}\n\t\t}\n\t\tfor (const edge of blueprint.edges) {\n\t\t\tif (edge._sourceLocation) {\n\t\t\t\tconst edgeKey = `${edge.source}-${edge.target}`\n\t\t\t\tlocationMap.set(edgeKey, edge._sourceLocation)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn function mapError(error: Error): Error {\n\t\tif (error instanceof FlowcraftError && error.nodeId) {\n\t\t\tconst location = locationMap.get(error.nodeId)\n\t\t\tif (location) {\n\t\t\t\treturn new Error(\n\t\t\t\t\t`Workflow error at ${location.file}:${location.line}:${location.column}. Original error: ${error.message}`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\t// try to extract nodeId from error message\n\t\tconst nodeIdMatch = error.message.match(/nodeId[:\\s]+([^\\s,]+)/i)\n\t\tif (nodeIdMatch) {\n\t\t\tconst nodeId = nodeIdMatch[1]\n\t\t\tconst location = locationMap.get(nodeId)\n\t\t\tif (location) {\n\t\t\t\treturn new Error(\n\t\t\t\t\t`Workflow error at ${location.file}:${location.line}:${location.column}. Original error: ${error.message}`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\treturn error\n\t}\n}\n"]}
@@ -1,46 +0,0 @@
1
- // src/adapters/persistent-event-bus.ts
2
- var PersistentEventBusAdapter = class {
3
- constructor(store) {
4
- this.store = store;
5
- }
6
- /**
7
- * Emit an event by storing it persistently.
8
- * Also emits to console for debugging (can be made configurable).
9
- */
10
- async emit(event) {
11
- let executionId = "unknown";
12
- if ("executionId" in event.payload) {
13
- executionId = event.payload.executionId;
14
- }
15
- await this.store.store(event, executionId);
16
- }
17
- };
18
- var InMemoryEventStore = class {
19
- events = /* @__PURE__ */ new Map();
20
- async store(event, executionId) {
21
- if (!this.events.has(executionId)) {
22
- this.events.set(executionId, []);
23
- }
24
- this.events.get(executionId)?.push(event);
25
- }
26
- async retrieve(executionId) {
27
- return this.events.get(executionId) || [];
28
- }
29
- async retrieveMultiple(executionIds) {
30
- const result = /* @__PURE__ */ new Map();
31
- for (const id of executionIds) {
32
- result.set(id, await this.retrieve(id));
33
- }
34
- return result;
35
- }
36
- /**
37
- * Clear all stored events (useful for testing).
38
- */
39
- clear() {
40
- this.events.clear();
41
- }
42
- };
43
-
44
- export { InMemoryEventStore, PersistentEventBusAdapter };
45
- //# sour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AAM,IAAA,CAAK,QAAA,CAAS,EAAE,CAAC,CAAA;AAAA,IACvC;AACA,IAAA,OAAO,MAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA,GAAc;AACb,IAAA,IAAA,CAAK,OAAO,KAAA,EAAM;AAAA,EACnB;AACD","file":"chunk-2TSADFQX.js","sourcesContent":["import type { FlowcraftEvent, IEventBus } from '../types'\n\n/**\n * Interface for a persistent storage mechanism for events.\n * Implementations can store events in databases, log streams, files, etc.\n */\nexport interface IEventStore {\n\t/**\n\t * Store an event persistently.\n\t * @param event The event to store\n\t * @param executionId The execution ID for grouping events\n\t */\n\tstore(event: FlowcraftEvent, executionId: string): Promise<void>\n\n\t/**\n\t * Retrieve all events for a specific execution.\n\t * @param executionId The execution ID\n\t * @returns Array of events in chronological order\n\t */\n\tretrieve(executionId: string): Promise<FlowcraftEvent[]>\n\n\t/**\n\t * Retrieve events for multiple executions.\n\t * @param executionIds Array of execution IDs\n\t * @returns Map of execution ID to array of events\n\t */\n\tretrieveMultiple(executionIds: string[]): Promise<Map<string, FlowcraftEvent[]>>\n}\n\n/**\n * A pluggable event bus adapter that persists all workflow events\n * to a configurable storage backend, enabling time-travel debugging and replay.\n *\n * @example\n * ```typescript\n * // Using a database-backed store\n * const eventStore = new DatabaseEventStore(dbConnection)\n * const eventBus = new PersistentEventBusAdapter(eventStore)\n * const runtime = new FlowRuntime({ eventBus })\n *\n * // Later, replay the execution\n * const events = await eventStore.retrieve(executionId)\n * const finalState = await runtime.replay(blueprint, events)\n * ```\n */\nexport class PersistentEventBusAdapter implements IEventBus {\n\tconstructor(private store: IEventStore) {}\n\n\t/**\n\t * Emit an event by storing it persistently.\n\t * Also emits to console for debugging (can be made configurable).\n\t */\n\tasync emit(event: FlowcraftEvent): Promise<void> {\n\t\tlet executionId = 'unknown'\n\t\tif ('executionId' in event.payload) {\n\t\t\texecutionId = event.payload.executionId as string\n\t\t}\n\t\tawait this.store.store(event, executionId)\n\t}\n}\n\n/**\n * Simple in-memory event store for testing and development.\n * Not suitable for production use.\n */\nexport class InMemoryEventStore implements IEventStore {\n\tprivate events = new Map<string, FlowcraftEvent[]>()\n\n\tasync store(event: FlowcraftEvent, executionId: string): Promise<void> {\n\t\tif (!this.events.has(executionId)) {\n\t\t\tthis.events.set(executionId, [])\n\t\t}\n\t\tthis.events.get(executionId)?.push(event)\n\t}\n\n\tasync retrieve(executionId: string): Promise<FlowcraftEvent[]> {\n\t\treturn this.events.get(executionId) || []\n\t}\n\n\tasync retrieveMultiple(executionIds: string[]): Promise<Map<string, FlowcraftEvent[]>> {\n\t\tconst result = new Map<string, FlowcraftEvent[]>()\n\t\tfor (const id of executionIds) {\n\t\t\tresult.set(id, await this.retrieve(id))\n\t\t}\n\t\treturn result\n\t}\n\n\t/**\n\t * Clear all stored events (useful for testing).\n\t */\n\tclear(): void {\n\t\tthis.events.clear()\n\t}\n}\n"]}
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=chunk-3Y5O5EGB.js.map
3
- //# sourceMappingURL=chunk-3Y5O5EGB.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-3Y5O5EGB.js"}
@@ -1,76 +0,0 @@
1
- import { StepByStepOrchestrator } from './chunk-VZ4BRDBK.js';
2
- import { GraphTraverser } from './chunk-ZKINHLMS.js';
3
- import { ExecutionContext } from './chunk-L3MX5MTA.js';
4
- import { WorkflowState } from './chunk-L46TQXCV.js';
5
-
6
- // src/testing/stepper.ts
7
- async function createStepper(runtime, blueprint, functionRegistry, initialState = {}) {
8
- const _initialBlueprint = structuredClone(blueprint);
9
- const _initialState = structuredClone(initialState);
10
- let state;
11
- let traverser;
12
- const history = [];
13
- const orchestrator = new StepByStepOrchestrator();
14
- const executionId = globalThis.crypto?.randomUUID();
15
- const nodeRegistry = new Map([...runtime.registry, ...functionRegistry]);
16
- const initialize = () => {
17
- state = new WorkflowState(_initialState);
18
- traverser = new GraphTraverser(_initialBlueprint);
19
- history.length = 0;
20
- };
21
- initialize();
22
- const stepper = {
23
- get state() {
24
- return state;
25
- },
26
- get traverser() {
27
- return traverser;
28
- },
29
- isDone() {
30
- return !traverser.hasMoreWork() && !state.isAwaiting();
31
- },
32
- reset() {
33
- initialize();
34
- },
35
- async prev() {
36
- const previousStateJson = history.pop();
37
- if (!previousStateJson) {
38
- return null;
39
- }
40
- const previousStateData = runtime.serializer.deserialize(previousStateJson);
41
- state = new WorkflowState(previousStateData);
42
- traverser = GraphTraverser.fromState(_initialBlueprint, state);
43
- return state.toResult(runtime.serializer, void 0);
44
- },
45
- async next(options = {}) {
46
- if (stepper.isDone()) {
47
- return null;
48
- }
49
- const serializedContext = (await state.toResult(runtime.serializer, void 0)).serializedContext;
50
- history.push(serializedContext);
51
- const executionContext = new ExecutionContext(
52
- _initialBlueprint,
53
- state,
54
- nodeRegistry,
55
- executionId,
56
- runtime,
57
- {
58
- logger: runtime.logger,
59
- eventBus: runtime.eventBus,
60
- serializer: runtime.serializer,
61
- evaluator: runtime.evaluator,
62
- middleware: runtime.middleware,
63
- dependencies: runtime.dependencies
64
- },
65
- options.signal,
66
- options.concurrency
67
- );
68
- return orchestrator.run(executionContext, traverser);
69
- }
70
- };
71
- return stepper;
72
- }
73
-
74
- export { createStepper };
75
- //# sourceMappingURL=chunk-4JUPOFSL.js.map
76
- //# sourceMappingURL=chunk-4JUPOFSL.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/testing/stepper.ts"],"names":[],"mappings":";;;;;;AAkFA,eAAsB,cACrB,OAAA,EACA,SAAA,EACA,gBAAA,EACA,YAAA,GAAkC,EAAC,EACG;AACtC,EAAA,MAAM,iBAAA,GAAoB,gBAAgB,SAAS,CAAA;AACnD,EAAA,MAAM,aAAA,GAAgB,gBAAgB,YAAY,CAAA;AAElD,EAAA,IAAI,KAAA;AACJ,EAAA,IAAI,SAAA;AACJ,EAAA,MAAM,UAAoB,EAAC;AAE3B,EAAA,MAAM,YAAA,GAAe,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CAAA;AAAA,IACA,MAAM,IAAA,CAAK,OAAA,GAA0D,EAAC,EAAG;AACxE,MAAA,IAAI,OAAA,CAAQ,QAAO,EAAG;AACrB,QAAA,OAAO,IAAA;AAAA,MACR;AAEA,MAAA,MAAM,qBAAqB,MAAM,KAAA,CAAM,SAAS,OAAA,CAAQ,UAAA,EAAY,MAAS,CAAA,EAAG,iBAAA;AAChF,MAAA,OAAA,CAAQ,KAAK,iBAAiB,CAAA;AAE9B,MAAA,MAAM,mBAAmB,IAAI,gBAAA;AAAA,QAC5B,iBAAA;AAAA,QACA,KAAA;AAAA,QACA,YAAA;AAAA,QACA,WAAA;AAAA,QACA,OAAA;AAAA,QACA;AAAA,UACC,QAAQ,OAAA,CAAQ,MAAA;AAAA,UAChB,UAAU,OAAA,CAAQ,QAAA;AAAA,UAClB,YAAY,OAAA,CAAQ,UAAA;AAAA,UACpB,WAAW,OAAA,CAAQ,SAAA;AAAA,UACnB,YAAY,OAAA,CAAQ,UAAA;AAAA,UACpB,cAAc,OAAA,CAAQ;AAAA,SACvB;AAAA,QACA,OAAA,CAAQ,MAAA;AAAA,QACR,OAAA,CAAQ;AAAA,OACT;AACA,MAAA,OAAO,YAAA,CAAa,GAAA,CAAI,gBAAA,EAAkB,SAAS,CAAA;AAAA,IACpD;AAAA,GACD;AAEA,EAAA,OAAO,OAAA;AACR","file":"chunk-4JUPOFSL.js","sourcesContent":["import type { FlowRuntime } from '../runtime'\nimport { ExecutionContext } from '../runtime/execution-context'\nimport { StepByStepOrchestrator } from '../runtime/orchestrators/step-by-step'\nimport { WorkflowState } from '../runtime/state'\nimport { GraphTraverser } from '../runtime/traverser'\nimport type { NodeClass, NodeFunction, WorkflowBlueprint, WorkflowResult } from '../types'\n\n/**\n * Represents the controlled, step-by-step execution of a workflow.\n * Returned by the `createStepper` utility.\n */\nexport interface IWorkflowStepper<TContext extends Record<string, any>> {\n\t/** The current state of the workflow. Can be inspected after each step. */\n\treadonly state: WorkflowState<TContext>\n\n\t/** The graph traverser instance. Can be used to inspect the frontier or completed nodes. */\n\treadonly traverser: GraphTraverser\n\n\t/**\n\t * Executes the next \"turn\" or batch of ready nodes in the workflow.\n\t * @param options Optional configuration for this specific step, like a cancellation signal.\n\t * @returns A `WorkflowResult` representing the state after the step, or `null` if the workflow has already completed.\n\t */\n\tnext(options?: { signal?: AbortSignal; concurrency?: number }): Promise<WorkflowResult<TContext> | null>\n\n\t/**\n\t * Reverts the workflow to its previous state.\n\t * @returns The `WorkflowResult` of the previous state, or `null` if there is no history to revert to.\n\t */\n\tprev(): Promise<WorkflowResult<TContext> | null>\n\n\t/**\n\t * Resets the stepper to its initial state, clearing all progress and history.\n\t */\n\treset(): void\n\n\t/**\n\t * A convenience method to check if the workflow has any more steps to run.\n\t * @returns `true` if the workflow is complete or stalled, `false` otherwise.\n\t */\n\tisDone(): boolean\n}\n\n/**\n * A test utility that creates a stepper to execute a workflow one \"turn\" at a time.\n * This is invaluable for debugging and writing fine-grained tests where you need to\n * assert the state of the workflow after each logical step.\n *\n * @example\n * // In your test file\n * it('should correctly execute step-by-step', async () => {\n * const runtime = new FlowRuntime({ ... });\n * const flow = createFlow('test')\n * .node('a', async () => ({ output: 10 }))\n * .node('b', async ({ input }) => ({ output: input * 2 }))\n * .edge('a', 'b');\n *\n * const stepper = await createStepper(runtime, flow.toBlueprint(), flow.getFunctionRegistry());\n *\n * // First step (executes node 'a')\n * const result1 = await stepper.next();\n * expect(stepper.isDone()).toBe(false);\n * expect(result1.status).toBe('stalled');\n * expect(result1.context._outputs.a).toBe(10);\n *\n * // Second step (executes node 'b')\n * const result2 = await stepper.next();\n * expect(stepper.isDone()).toBe(true);\n * expect(result2.status).toBe('completed');\n * expect(result2.context._outputs.b).toBe(20);\n *\n * // Final step (no more work)\n * const result3 = await stepper.next();\n * expect(result3).toBeNull();\n * });\n *\n * @param runtime The `FlowRuntime` instance, used for its configuration.\n * @param blueprint The `WorkflowBlueprint` to execute.\n * @param functionRegistry The function registry from createFlow, containing the node implementations.\n * @param initialState The initial state for the workflow run.\n * @returns A Promise that resolves to an `IWorkflowStepper` instance.\n */\nexport async function createStepper<TContext extends Record<string, any>, TDependencies extends Record<string, any>>(\n\truntime: FlowRuntime<TContext, TDependencies>,\n\tblueprint: WorkflowBlueprint,\n\tfunctionRegistry: Map<string, NodeFunction | NodeClass>,\n\tinitialState: Partial<TContext> = {},\n): Promise<IWorkflowStepper<TContext>> {\n\tconst _initialBlueprint = structuredClone(blueprint)\n\tconst _initialState = structuredClone(initialState)\n\n\tlet state: WorkflowState<TContext>\n\tlet traverser: GraphTraverser\n\tconst history: string[] = []\n\n\tconst orchestrator = new StepByStepOrchestrator()\n\tconst executionId = globalThis.crypto?.randomUUID()\n\tconst nodeRegistry = new Map([...runtime.registry, ...functionRegistry])\n\n\tconst initialize = () => {\n\t\tstate = new WorkflowState<TContext>(_initialState)\n\t\ttraverser = new GraphTraverser(_initialBlueprint)\n\t\thistory.length = 0\n\t}\n\n\tinitialize()\n\n\tconst stepper: IWorkflowStepper<TContext> = {\n\t\tget state() {\n\t\t\treturn state\n\t\t},\n\t\tget traverser() {\n\t\t\treturn traverser\n\t\t},\n\t\tisDone() {\n\t\t\treturn !traverser.hasMoreWork() && !state.isAwaiting()\n\t\t},\n\t\treset() {\n\t\t\tinitialize()\n\t\t},\n\t\tasync prev() {\n\t\t\tconst previousStateJson = history.pop()\n\t\t\tif (!previousStateJson) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\tconst previousStateData = runtime.serializer.deserialize(previousStateJson) as Partial<TContext>\n\n\t\t\tstate = new WorkflowState(previousStateData)\n\t\t\ttraverser = GraphTraverser.fromState(_initialBlueprint, state)\n\n\t\t\treturn state.toResult(runtime.serializer, undefined)\n\t\t},\n\t\tasync next(options: { signal?: AbortSignal; concurrency?: number } = {}) {\n\t\t\tif (stepper.isDone()) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\tconst serializedContext = (await state.toResult(runtime.serializer, undefined)).serializedContext\n\t\t\thistory.push(serializedContext)\n\n\t\t\tconst executionContext = new ExecutionContext(\n\t\t\t\t_initialBlueprint,\n\t\t\t\tstate,\n\t\t\t\tnodeRegistry,\n\t\t\t\texecutionId,\n\t\t\t\truntime,\n\t\t\t\t{\n\t\t\t\t\tlogger: runtime.logger,\n\t\t\t\t\teventBus: runtime.eventBus,\n\t\t\t\t\tserializer: runtime.serializer,\n\t\t\t\t\tevaluator: runtime.evaluator,\n\t\t\t\t\tmiddleware: runtime.middleware,\n\t\t\t\t\tdependencies: runtime.dependencies,\n\t\t\t\t},\n\t\t\t\toptions.signal,\n\t\t\t\toptions.concurrency,\n\t\t\t)\n\t\t\treturn orchestrator.run(executionContext, traverser)\n\t\t},\n\t}\n\n\treturn stepper\n}\n"]}
@@ -1,29 +0,0 @@
1
- // src/logger.ts
2
- var ConsoleLogger = class {
3
- debug(message, meta) {
4
- console.debug(`[DEBUG] ${message}`, meta || "");
5
- }
6
- info(message, meta) {
7
- console.info(`[INFO] ${message}`, meta || "");
8
- }
9
- warn(message, meta) {
10
- console.warn(`[WARN] ${message}`, meta || "");
11
- }
12
- error(message, meta) {
13
- console.error(`[ERROR] ${message}`, meta || "");
14
- }
15
- };
16
- var NullLogger = class {
17
- debug(_message, _meta) {
18
- }
19
- info(_message, _meta) {
20
- }
21
- warn(_message, _meta) {
22
- }
23
- error(_message, _meta) {
24
- }
25
- };
26
-
27
- export { ConsoleLogger, NullLogger };
28
- //# sourceMappingURL=chunk-4PELJWF7.js.map
29
- //# sourceMappingURL=chunk-4PELJWF7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/logger.ts"],"names":[],"mappings":";AAGO,IAAM,gBAAN,MAAuC;AAAA,EAC7C,KAAA,CAAM,SAAiB,IAAA,EAAkC;AACxD,IAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,QAAA,EAAW,OAAO,CAAA,CAAA,EAAI,QAAQ,EAAE,CAAA;AAAA,EAC/C;AAAA,EAEA,IAAA,CAAK,SAAiB,IAAA,EAAkC;AACvD,IAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,OAAA,EAAU,OAAO,CAAA,CAAA,EAAI,QAAQ,EAAE,CAAA;AAAA,EAC7C;AAAA,EAEA,IAAA,CAAK,SAAiB,IAAA,EAAkC;AACvD,IAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,OAAA,EAAU,OAAO,CAAA,CAAA,EAAI,QAAQ,EAAE,CAAA;AAAA,EAC7C;AAAA,EAEA,KAAA,CAAM,SAAiB,IAAA,EAAkC;AACxD,IAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,QAAA,EAAW,OAAO,CAAA,CAAA,EAAI,QAAQ,EAAE,CAAA;AAAA,EAC/C;AACD;AAGO,IAAM,aAAN,MAAoC;AAAA,EAC1C,KAAA,CAAM,UAAkB,KAAA,EAAmC;AAAA,EAAC;AAAA,EAC5D,IAAA,CAAK,UAAkB,KAAA,EAAmC;AAAA,EAAC;AAAA,EAC3D,IAAA,CAAK,UAAkB,KAAA,EAAmC;AAAA,EAAC;AAAA,EAC3D,KAAA,CAAM,UAAkB,KAAA,EAAmC;AAAA,EAAC;AAC7D","file":"chunk-4PELJWF7.js","sourcesContent":["import type { ILogger } from './types'\n\n/** A logger implementation that outputs to the console. */\nexport class ConsoleLogger implements ILogger {\n\tdebug(message: string, meta?: Record<string, any>): void {\n\t\tconsole.debug(`[DEBUG] ${message}`, meta || '')\n\t}\n\n\tinfo(message: string, meta?: Record<string, any>): void {\n\t\tconsole.info(`[INFO] ${message}`, meta || '')\n\t}\n\n\twarn(message: string, meta?: Record<string, any>): void {\n\t\tconsole.warn(`[WARN] ${message}`, meta || '')\n\t}\n\n\terror(message: string, meta?: Record<string, any>): void {\n\t\tconsole.error(`[ERROR] ${message}`, meta || '')\n\t}\n}\n\n/** A logger implementation that does nothing (no-op). */\nexport class NullLogger implements ILogger {\n\tdebug(_message: string, _meta?: Record<string, any>): void {}\n\tinfo(_message: string, _meta?: Record<string, any>): void {}\n\twarn(_message: string, _meta?: Record<string, any>): void {}\n\terror(_message: string, _meta?: Record<string, any>): void {}\n}\n"]}
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=chunk-55J6XMHW.js.map
3
- //# sourceMappingURL=chunk-55J6XMHW.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-55J6XMHW.js"}
@@ -1,90 +0,0 @@
1
- import { GraphTraverser } from './chunk-ZKINHLMS.js';
2
- import { analyzeBlueprint } from './chunk-ZLW4QOTS.js';
3
- import { ExecutionContext } from './chunk-L3MX5MTA.js';
4
- import { WorkflowState } from './chunk-L46TQXCV.js';
5
- import { FlowcraftError } from './chunk-BCRWXTWX.js';
6
- import { BaseNode } from './chunk-LNK7LZER.js';
7
-
8
- // src/nodes/subflow.ts
9
- var SubflowNode = class extends BaseNode {
10
- async exec(_prepResult, context) {
11
- const { blueprintId, inputs, outputs } = this.params ?? {};
12
- const { runtime, workflowState } = context.dependencies;
13
- if (!blueprintId) {
14
- throw new FlowcraftError(`Subflow node '${this.nodeId}' is missing 'blueprintId' parameter.`, { isFatal: true });
15
- }
16
- const subBlueprint = runtime.blueprints?.[blueprintId] || runtime.runtime?.blueprints?.[blueprintId];
17
- if (!subBlueprint) {
18
- throw new FlowcraftError(`Sub-blueprint '${blueprintId}' not found in runtime registry.`, { isFatal: true });
19
- }
20
- const subflowInitialContext = {};
21
- if (inputs) {
22
- for (const [targetKey, sourceKey] of Object.entries(inputs)) {
23
- let value = await context.context.get(sourceKey);
24
- if (value === void 0) {
25
- value = await context.context.get(`_outputs.${sourceKey}`);
26
- }
27
- subflowInitialContext[targetKey] = value;
28
- }
29
- } else if (context.input !== void 0) {
30
- const subAnalysis2 = analyzeBlueprint(subBlueprint);
31
- for (const startNodeId of subAnalysis2.startNodeIds) {
32
- const inputKey = `_inputs.${startNodeId}`;
33
- subflowInitialContext[inputKey] = context.input;
34
- }
35
- }
36
- const subflowState = new WorkflowState(subflowInitialContext);
37
- const subflowExecContext = new ExecutionContext(
38
- subBlueprint,
39
- subflowState,
40
- runtime.nodeRegistry,
41
- runtime.executionId,
42
- runtime.runtime,
43
- runtime.services,
44
- runtime.signal,
45
- runtime.concurrency
46
- );
47
- const subflowTraverser = new GraphTraverser(subBlueprint);
48
- const subflowResult = await runtime.runtime.orchestrator.run(subflowExecContext, subflowTraverser);
49
- if (subflowResult.status === "awaiting") {
50
- await workflowState.markAsAwaiting(this.nodeId ?? "");
51
- const subflowStateKey = `_subflowState.${this.nodeId}`;
52
- await context.context.set(subflowStateKey, subflowResult.serializedContext);
53
- return { output: void 0 };
54
- }
55
- if (subflowResult.status !== "completed") {
56
- const firstError = subflowResult.errors?.[0];
57
- const errorMessage = firstError?.message || "Unknown error";
58
- throw new FlowcraftError(
59
- `Sub-workflow '${blueprintId}' did not complete successfully. Status: ${subflowResult.status}. Error: ${errorMessage}`,
60
- {
61
- cause: firstError,
62
- nodeId: this.nodeId,
63
- blueprintId
64
- }
65
- );
66
- }
67
- const subflowFinalContext = subflowResult.context;
68
- if (outputs) {
69
- for (const [parentKey, subKey] of Object.entries(outputs)) {
70
- const value = subflowFinalContext[`_outputs.${subKey}`] ?? subflowFinalContext[subKey];
71
- await context.context.set(parentKey, value);
72
- }
73
- return { output: subflowFinalContext };
74
- }
75
- const subAnalysis = analyzeBlueprint(subBlueprint);
76
- if (subAnalysis.terminalNodeIds.length === 1) {
77
- const terminalId = subAnalysis.terminalNodeIds[0];
78
- return { output: subflowFinalContext[`_outputs.${terminalId}`] };
79
- }
80
- const terminalOutputs = {};
81
- for (const terminalId of subAnalysis.terminalNodeIds) {
82
- terminalOutputs[terminalId] = subflowFinalContext[`_outputs.${terminalId}`];
83
- }
84
- return { output: terminalOutputs };
85
- }
86
- };
87
-
88
- export { SubflowNode };
89
- //# sourceMappingURL=chunk-5A24LVGQ.js.map
90
- //# sourceMappingURL=chunk-5A24LVGQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/nodes/subflow.ts"],"names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A,EAAgB;AAAA,EAClC;AACD","file":"chunk-5A24LVGQ.js","sourcesContent":["import { analyzeBlueprint } from '../analysis'\nimport { FlowcraftError } from '../errors'\nimport { BaseNode } from '../node'\nimport { ExecutionContext } from '../runtime/execution-context'\nimport { WorkflowState } from '../runtime/state'\nimport { GraphTraverser } from '../runtime/traverser'\nimport type { NodeContext, NodeResult } from '../types'\n\nexport class SubflowNode extends BaseNode {\n\tasync exec(\n\t\t_prepResult: any,\n\t\tcontext: NodeContext<Record<string, any>, any, any>,\n\t): Promise<Omit<NodeResult, 'error'>> {\n\t\tconst { blueprintId, inputs, outputs } = this.params ?? {}\n\t\tconst { runtime, workflowState } = context.dependencies\n\n\t\tif (!blueprintId) {\n\t\t\tthrow new FlowcraftError(`Subflow node '${this.nodeId}' is missing 'blueprintId' parameter.`, { isFatal: true })\n\t\t}\n\n\t\tconst subBlueprint =\n\t\t\t(runtime as any).blueprints?.[blueprintId] || (runtime as any).runtime?.blueprints?.[blueprintId]\n\t\tif (!subBlueprint) {\n\t\t\tthrow new FlowcraftError(`Sub-blueprint '${blueprintId}' not found in runtime registry.`, { isFatal: true })\n\t\t}\n\n\t\tconst subflowInitialContext: Record<string, any> = {}\n\n\t\tif (inputs) {\n\t\t\t// explicit inputs\n\t\t\tfor (const [targetKey, sourceKey] of Object.entries(inputs as Record<string, string>)) {\n\t\t\t\tlet value = await context.context.get(sourceKey as any)\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tvalue = await context.context.get(`_outputs.${sourceKey}` as any)\n\t\t\t\t}\n\t\t\t\tsubflowInitialContext[targetKey] = value\n\t\t\t}\n\t\t} else if (context.input !== undefined) {\n\t\t\t// pass the parent node's input to the subflow's start nodes\n\t\t\tconst subAnalysis = analyzeBlueprint(subBlueprint)\n\t\t\tfor (const startNodeId of subAnalysis.startNodeIds) {\n\t\t\t\tconst inputKey = `_inputs.${startNodeId}`\n\t\t\t\tsubflowInitialContext[inputKey] = context.input\n\t\t\t}\n\t\t}\n\n\t\tconst subflowState = new WorkflowState(subflowInitialContext)\n\t\tconst subflowExecContext = new ExecutionContext(\n\t\t\tsubBlueprint,\n\t\t\tsubflowState,\n\t\t\truntime.nodeRegistry,\n\t\t\truntime.executionId,\n\t\t\truntime.runtime,\n\t\t\truntime.services,\n\t\t\truntime.signal,\n\t\t\truntime.concurrency,\n\t\t)\n\t\tconst subflowTraverser = new GraphTraverser(subBlueprint)\n\n\t\tconst subflowResult = await runtime.runtime.orchestrator.run(subflowExecContext, subflowTraverser)\n\n\t\tif (subflowResult.status === 'awaiting') {\n\t\t\tawait workflowState.markAsAwaiting(this.nodeId ?? '')\n\t\t\tconst subflowStateKey = `_subflowState.${this.nodeId}`\n\t\t\tawait context.context.set(subflowStateKey as any, subflowResult.serializedContext)\n\t\t\treturn { output: undefined }\n\t\t}\n\n\t\tif (subflowResult.status !== 'completed') {\n\t\t\tconst firstError = subflowResult.errors?.[0]\n\t\t\tconst errorMessage = firstError?.message || 'Unknown error'\n\t\t\tthrow new FlowcraftError(\n\t\t\t\t`Sub-workflow '${blueprintId}' did not complete successfully. Status: ${subflowResult.status}. Error: ${errorMessage}`,\n\t\t\t\t{\n\t\t\t\t\tcause: firstError,\n\t\t\t\t\tnodeId: this.nodeId,\n\t\t\t\t\tblueprintId,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\n\t\tconst subflowFinalContext = subflowResult.context as Record<string, any>\n\n\t\tif (outputs) {\n\t\t\tfor (const [parentKey, subKey] of Object.entries(outputs as Record<string, string>)) {\n\t\t\t\tconst value = subflowFinalContext[`_outputs.${subKey}`] ?? subflowFinalContext[subKey]\n\t\t\t\tawait context.context.set(parentKey as any, value)\n\t\t\t}\n\t\t\treturn { output: subflowFinalContext }\n\t\t}\n\n\t\tconst subAnalysis = analyzeBlueprint(subBlueprint)\n\t\tif (subAnalysis.terminalNodeIds.length === 1) {\n\t\t\tconst terminalId = subAnalysis.terminalNodeIds[0]\n\t\t\treturn { output: subflowFinalContext[`_outputs.${terminalId}`] }\n\t\t}\n\n\t\tconst terminalOutputs: Record<string, any> = {}\n\t\tfor (const terminalId of subAnalysis.terminalNodeIds) {\n\t\t\tterminalOutputs[terminalId] = subflowFinalContext[`_outputs.${terminalId}`]\n\t\t}\n\t\treturn { output: terminalOutputs }\n\t}\n}\n"]}
@@ -1,29 +0,0 @@
1
- // src/serializer.ts
2
- var JsonSerializer = class {
3
- hasWarned = false;
4
- serialize(data) {
5
- for (const value of Object.values(data)) {
6
- if (value instanceof Map || value instanceof Set || value instanceof Date) {
7
- if (!this.hasWarned) {
8
- console.warn(
9
- "[Flowcraft] Warning: Default JsonSerializer does not support Map, Set, or Date types. Data may be lost. Consider providing a custom ISerializer (e.g., using superjson)."
10
- );
11
- this.hasWarned = true;
12
- }
13
- }
14
- }
15
- try {
16
- return JSON.stringify(data);
17
- } catch {
18
- console.warn("[Flowcraft] Warning: Circular reference detected in context. Using safe serialization.");
19
- return JSON.stringify({ _circularReference: true, message: "Context contains circular references" });
20
- }
21
- }
22
- deserialize(text) {
23
- return JSON.parse(text);
24
- }
25
- };
26
-
27
- export { JsonSerializer };
28
- //# sourceMappingURL=chunk-6RKHCJUU.js.map
29
- //# sourceMappingURL=chunk-6RKHCJUU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/serializer.ts"],"names":[],"mappings":";AASO,IAAM,iBAAN,MAA4C;AAAA,EAC1C,SAAA,GAAY,KAAA;AAAA,EAEpB,UAAU,IAAA,EAAmC;AAC5C,IAAA,KAAA,MAAW,KAAA,IAAS,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,EAAG;AACxC,MAAA,IAAI,KAAA,YAAiB,GAAA,IAAO,KAAA,YAAiB,GAAA,IAAO,iBAAiB,IAAA,EAAM;AAC1E,QAAA,IAAI,CAAC,KAAK,SAAA,EAAW;AACpB,UAAA,OAAA,CAAQ,IAAA;AAAA,YACP;AAAA,WACD;AACA,UAAA,IAAA,CAAK,SAAA,GAAY,IAAA;AAAA,QAClB;AAAA,MACD;AAAA,IACD;AACA,IAAA,IAAI;AACH,MAAA,OAAO,IAAA,CAAK,UAAU,IAAI,CAAA;AAAA,IAC3B,CAAA,CAAA,MAAQ;AACP,MAAA,OAAA,CAAQ,KAAK,wFAAwF,CAAA;AACrG,MAAA,OAAO,KAAK,SAAA,CAAU,EAAE,oBAAoB,IAAA,EAAM,OAAA,EAAS,wCAAwC,CAAA;AAAA,IACpG;AAAA,EACD;AAAA,EAEA,YAAY,IAAA,EAAmC;AAC9C,IAAA,OAAO,IAAA,CAAK,MAAM,IAAI,CAAA;AAAA,EACvB;AACD","file":"chunk-6RKHCJUU.js","sourcesContent":["import type { ISerializer } from './types'\n\n/**\n * A default serializer using standard JSON.\n *\n * @warning This implementation is lossy and does not handle complex data types\n * like `Date`, `Map`, `Set`, `undefined`, etc. It is recommended to provide a robust\n * serializer like `superjson` if working with complex data types.\n */\nexport class JsonSerializer implements ISerializer {\n\tprivate hasWarned = false\n\n\tserialize(data: Record<string, any>): string {\n\t\tfor (const value of Object.values(data)) {\n\t\t\tif (value instanceof Map || value instanceof Set || value instanceof Date) {\n\t\t\t\tif (!this.hasWarned) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t'[Flowcraft] Warning: Default JsonSerializer does not support Map, Set, or Date types. Data may be lost. Consider providing a custom ISerializer (e.g., using superjson).',\n\t\t\t\t\t)\n\t\t\t\t\tthis.hasWarned = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\treturn JSON.stringify(data)\n\t\t} catch {\n\t\t\tconsole.warn('[Flowcraft] Warning: Circular reference detected in context. Using safe serialization.')\n\t\t\treturn JSON.stringify({ _circularReference: true, message: 'Context contains circular references' })\n\t\t}\n\t}\n\n\tdeserialize(text: string): Record<string, any> {\n\t\treturn JSON.parse(text)\n\t}\n}\n"]}