flowcraft 1.0.0 → 2.1.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 (201) hide show
  1. package/README.md +37 -134
  2. package/dist/analysis.d.ts +43 -0
  3. package/dist/analysis.js +3 -0
  4. package/dist/chunk-4PELJWF7.js +29 -0
  5. package/dist/chunk-4PELJWF7.js.map +1 -0
  6. package/dist/chunk-55J6XMHW.js +3 -0
  7. package/dist/{chunk-7XUN3OQT.js.map → chunk-55J6XMHW.js.map} +1 -1
  8. package/dist/chunk-5EHIPX23.js +202 -0
  9. package/dist/chunk-5EHIPX23.js.map +1 -0
  10. package/dist/chunk-5QMPFUKA.js +40 -0
  11. package/dist/chunk-5QMPFUKA.js.map +1 -0
  12. package/dist/chunk-5ZWYSKMH.js +147 -0
  13. package/dist/chunk-5ZWYSKMH.js.map +1 -0
  14. package/dist/chunk-5ZXV3R5D.js +28 -0
  15. package/dist/chunk-5ZXV3R5D.js.map +1 -0
  16. package/dist/chunk-CO5BTPKI.js +410 -0
  17. package/dist/chunk-CO5BTPKI.js.map +1 -0
  18. package/dist/chunk-CSZ6EOWG.js +61 -0
  19. package/dist/chunk-CSZ6EOWG.js.map +1 -0
  20. package/dist/chunk-CYHZ2YVH.js +24 -0
  21. package/dist/chunk-CYHZ2YVH.js.map +1 -0
  22. package/dist/chunk-DSYAC4WB.js +27 -0
  23. package/dist/chunk-DSYAC4WB.js.map +1 -0
  24. package/dist/chunk-HMR2GEGE.js +3 -0
  25. package/dist/{chunk-F2RSES6P.js.map → chunk-HMR2GEGE.js.map} +1 -1
  26. package/dist/chunk-HN72TZY5.js +110 -0
  27. package/dist/chunk-HN72TZY5.js.map +1 -0
  28. package/dist/chunk-KWQHFT7E.js +49 -0
  29. package/dist/chunk-KWQHFT7E.js.map +1 -0
  30. package/dist/chunk-PH2IYZHV.js +48 -0
  31. package/dist/chunk-PH2IYZHV.js.map +1 -0
  32. package/dist/chunk-QRMUKDSP.js +141 -0
  33. package/dist/chunk-QRMUKDSP.js.map +1 -0
  34. package/dist/chunk-UETC63DP.js +65 -0
  35. package/dist/chunk-UETC63DP.js.map +1 -0
  36. package/dist/chunk-UMXW3TCY.js +165 -0
  37. package/dist/chunk-UMXW3TCY.js.map +1 -0
  38. package/dist/context.d.ts +23 -105
  39. package/dist/context.js +1 -1
  40. package/dist/errors.d.ts +15 -31
  41. package/dist/errors.js +1 -1
  42. package/dist/evaluator.d.ts +30 -0
  43. package/dist/evaluator.js +3 -0
  44. package/dist/evaluator.js.map +1 -0
  45. package/dist/flow.d.ts +55 -0
  46. package/dist/flow.js +4 -0
  47. package/dist/flow.js.map +1 -0
  48. package/dist/index.d.ts +15 -16
  49. package/dist/index.js +17 -25
  50. package/dist/linter.d.ts +24 -0
  51. package/dist/linter.js +4 -0
  52. package/dist/linter.js.map +1 -0
  53. package/dist/logger.d.ts +15 -40
  54. package/dist/logger.js +1 -1
  55. package/dist/node.d.ts +1 -0
  56. package/dist/node.js +3 -0
  57. package/dist/node.js.map +1 -0
  58. package/dist/runtime/adapter.d.ts +94 -0
  59. package/dist/runtime/adapter.js +15 -0
  60. package/dist/runtime/adapter.js.map +1 -0
  61. package/dist/runtime/executors.d.ts +26 -0
  62. package/dist/runtime/executors.js +4 -0
  63. package/dist/runtime/executors.js.map +1 -0
  64. package/dist/runtime/index.d.ts +7 -0
  65. package/dist/runtime/index.js +16 -0
  66. package/dist/runtime/runtime.d.ts +34 -0
  67. package/dist/runtime/runtime.js +14 -0
  68. package/dist/runtime/runtime.js.map +1 -0
  69. package/dist/runtime/state.d.ts +21 -0
  70. package/dist/runtime/state.js +4 -0
  71. package/dist/runtime/state.js.map +1 -0
  72. package/dist/runtime/traverser.d.ts +25 -0
  73. package/dist/runtime/traverser.js +5 -0
  74. package/dist/runtime/traverser.js.map +1 -0
  75. package/dist/runtime/types.d.ts +15 -0
  76. package/dist/runtime/types.js +3 -0
  77. package/dist/sanitizer.d.ts +10 -0
  78. package/dist/sanitizer.js +3 -0
  79. package/dist/{utils/sanitize.js.map → sanitizer.js.map} +1 -1
  80. package/dist/serializer.d.ts +16 -0
  81. package/dist/serializer.js +3 -0
  82. package/dist/serializer.js.map +1 -0
  83. package/dist/types-lG3xCzp_.d.ts +206 -0
  84. package/dist/types.d.ts +1 -3
  85. package/dist/types.js +1 -1
  86. package/package.json +10 -21
  87. package/LICENSE +0 -21
  88. package/dist/builder/graph/graph.d.ts +0 -57
  89. package/dist/builder/graph/graph.js +0 -21
  90. package/dist/builder/graph/graph.js.map +0 -1
  91. package/dist/builder/graph/index.d.ts +0 -8
  92. package/dist/builder/graph/index.js +0 -23
  93. package/dist/builder/graph/internal-nodes.d.ts +0 -59
  94. package/dist/builder/graph/internal-nodes.js +0 -20
  95. package/dist/builder/graph/internal-nodes.js.map +0 -1
  96. package/dist/builder/graph/runner.d.ts +0 -51
  97. package/dist/builder/graph/runner.js +0 -21
  98. package/dist/builder/graph/runner.js.map +0 -1
  99. package/dist/builder/graph/types.d.ts +0 -3
  100. package/dist/builder/graph/types.js +0 -3
  101. package/dist/builder/index.d.ts +0 -8
  102. package/dist/builder/index.js +0 -24
  103. package/dist/builder/index.js.map +0 -1
  104. package/dist/builder/patterns.d.ts +0 -136
  105. package/dist/builder/patterns.js +0 -19
  106. package/dist/builder/patterns.js.map +0 -1
  107. package/dist/chunk-3YMBNZ77.js +0 -441
  108. package/dist/chunk-3YMBNZ77.js.map +0 -1
  109. package/dist/chunk-64DNBF5W.js +0 -36
  110. package/dist/chunk-64DNBF5W.js.map +0 -1
  111. package/dist/chunk-6QCXIRLA.js +0 -18
  112. package/dist/chunk-6QCXIRLA.js.map +0 -1
  113. package/dist/chunk-7XUN3OQT.js +0 -3
  114. package/dist/chunk-AOHBHYF6.js +0 -7
  115. package/dist/chunk-AOHBHYF6.js.map +0 -1
  116. package/dist/chunk-BRFMFLR6.js +0 -85
  117. package/dist/chunk-BRFMFLR6.js.map +0 -1
  118. package/dist/chunk-ELEHMJPM.js +0 -13
  119. package/dist/chunk-ELEHMJPM.js.map +0 -1
  120. package/dist/chunk-F2RSES6P.js +0 -3
  121. package/dist/chunk-F6C6J7HK.js +0 -3
  122. package/dist/chunk-F6C6J7HK.js.map +0 -1
  123. package/dist/chunk-GMKJ34T2.js +0 -3
  124. package/dist/chunk-GMKJ34T2.js.map +0 -1
  125. package/dist/chunk-HEO3XL4Z.js +0 -328
  126. package/dist/chunk-HEO3XL4Z.js.map +0 -1
  127. package/dist/chunk-IIKTTIW5.js +0 -56
  128. package/dist/chunk-IIKTTIW5.js.map +0 -1
  129. package/dist/chunk-KOBEU2EM.js +0 -3
  130. package/dist/chunk-KOBEU2EM.js.map +0 -1
  131. package/dist/chunk-L5PK5VL2.js +0 -178
  132. package/dist/chunk-L5PK5VL2.js.map +0 -1
  133. package/dist/chunk-P3RPDZHO.js +0 -36
  134. package/dist/chunk-P3RPDZHO.js.map +0 -1
  135. package/dist/chunk-PNWOW52F.js +0 -19
  136. package/dist/chunk-PNWOW52F.js.map +0 -1
  137. package/dist/chunk-R27FIYR5.js +0 -62
  138. package/dist/chunk-R27FIYR5.js.map +0 -1
  139. package/dist/chunk-S4WFNGQG.js +0 -17
  140. package/dist/chunk-S4WFNGQG.js.map +0 -1
  141. package/dist/chunk-TS3M7MWA.js +0 -3
  142. package/dist/chunk-TS3M7MWA.js.map +0 -1
  143. package/dist/chunk-UY4PNPBX.js +0 -156
  144. package/dist/chunk-UY4PNPBX.js.map +0 -1
  145. package/dist/chunk-VMH2LRM6.js +0 -114
  146. package/dist/chunk-VMH2LRM6.js.map +0 -1
  147. package/dist/chunk-VZDHIOCH.js +0 -76
  148. package/dist/chunk-VZDHIOCH.js.map +0 -1
  149. package/dist/chunk-WGVHM7DU.js +0 -66
  150. package/dist/chunk-WGVHM7DU.js.map +0 -1
  151. package/dist/chunk-WR5PDOPP.js +0 -91
  152. package/dist/chunk-WR5PDOPP.js.map +0 -1
  153. package/dist/chunk-YR433ZDA.js +0 -20
  154. package/dist/chunk-YR433ZDA.js.map +0 -1
  155. package/dist/executors/in-memory.d.ts +0 -39
  156. package/dist/executors/in-memory.js +0 -6
  157. package/dist/executors/in-memory.js.map +0 -1
  158. package/dist/executors/types.d.ts +0 -3
  159. package/dist/executors/types.js +0 -3
  160. package/dist/executors/types.js.map +0 -1
  161. package/dist/functions.d.ts +0 -88
  162. package/dist/functions.js +0 -21
  163. package/dist/functions.js.map +0 -1
  164. package/dist/types-U76Ukj96.d.ts +0 -609
  165. package/dist/utils/analysis.d.ts +0 -75
  166. package/dist/utils/analysis.js +0 -3
  167. package/dist/utils/index.d.ts +0 -8
  168. package/dist/utils/index.js +0 -10
  169. package/dist/utils/index.js.map +0 -1
  170. package/dist/utils/mermaid.d.ts +0 -46
  171. package/dist/utils/mermaid.js +0 -4
  172. package/dist/utils/mermaid.js.map +0 -1
  173. package/dist/utils/middleware.d.ts +0 -11
  174. package/dist/utils/middleware.js +0 -3
  175. package/dist/utils/middleware.js.map +0 -1
  176. package/dist/utils/sanitize.d.ts +0 -19
  177. package/dist/utils/sanitize.js +0 -3
  178. package/dist/utils/sleep.d.ts +0 -9
  179. package/dist/utils/sleep.js +0 -4
  180. package/dist/utils/sleep.js.map +0 -1
  181. package/dist/workflow/AbstractNode.d.ts +0 -3
  182. package/dist/workflow/AbstractNode.js +0 -4
  183. package/dist/workflow/AbstractNode.js.map +0 -1
  184. package/dist/workflow/Flow.d.ts +0 -3
  185. package/dist/workflow/Flow.js +0 -16
  186. package/dist/workflow/Flow.js.map +0 -1
  187. package/dist/workflow/Node.d.ts +0 -3
  188. package/dist/workflow/Node.js +0 -15
  189. package/dist/workflow/Node.js.map +0 -1
  190. package/dist/workflow/index.d.ts +0 -4
  191. package/dist/workflow/index.js +0 -18
  192. package/dist/workflow/index.js.map +0 -1
  193. package/dist/workflow/node-patterns.d.ts +0 -55
  194. package/dist/workflow/node-patterns.js +0 -16
  195. package/dist/workflow/node-patterns.js.map +0 -1
  196. package/dist/workflow/registry.d.ts +0 -17
  197. package/dist/workflow/registry.js +0 -3
  198. package/dist/workflow/registry.js.map +0 -1
  199. /package/dist/{utils/analysis.js.map → analysis.js.map} +0 -0
  200. /package/dist/{builder/graph → runtime}/index.js.map +0 -0
  201. /package/dist/{builder/graph → runtime}/types.js.map +0 -0
@@ -1,66 +0,0 @@
1
- import { ParallelFlow } from './chunk-L5PK5VL2.js';
2
- import { Node } from './chunk-HEO3XL4Z.js';
3
-
4
- // src/builder/graph/internal-nodes.ts
5
- var InputMappingNode = class extends Node {
6
- mappings;
7
- constructor(options) {
8
- super();
9
- const { nodeId, originalId, isSubWorkflow, ...mappings } = options.data;
10
- this.mappings = mappings;
11
- }
12
- async prep({ ctx, logger }) {
13
- for (const [subKey, parentKey] of Object.entries(this.mappings)) {
14
- if (await ctx.has(parentKey)) {
15
- ctx.set(subKey, await ctx.get(parentKey));
16
- } else {
17
- logger.warn(`[InputMapper] Input mapping failed. Key '${parentKey}' not found in context.`);
18
- }
19
- }
20
- }
21
- };
22
- var OutputMappingNode = class extends Node {
23
- mappings;
24
- constructor(options) {
25
- super();
26
- const { nodeId, originalId, isSubWorkflow, ...mappings } = options.data;
27
- this.mappings = mappings;
28
- }
29
- async prep({ ctx, logger }) {
30
- for (const [parentKey, subKey] of Object.entries(this.mappings)) {
31
- if (await ctx.has(subKey)) {
32
- ctx.set(parentKey, await ctx.get(subKey));
33
- } else {
34
- logger.warn(`[OutputMapper] Output mapping failed. Key '${subKey}' not found in context.`);
35
- }
36
- }
37
- }
38
- };
39
- var SubWorkflowContainerNode = class extends Node {
40
- constructor() {
41
- super();
42
- this.isPassthrough = true;
43
- }
44
- async exec() {
45
- }
46
- };
47
- var ParallelBranchContainer = class extends ParallelFlow {
48
- /** A tag to reliably identify this node type in the visualizer. */
49
- isParallelContainer = true;
50
- // This is now a public, mutable property for the executor to populate.
51
- nodesToRun = [];
52
- constructor() {
53
- super();
54
- this.isPassthrough = true;
55
- }
56
- };
57
- var ConditionalJoinNode = class extends Node {
58
- constructor() {
59
- super();
60
- this.isPassthrough = true;
61
- }
62
- };
63
-
64
- export { ConditionalJoinNode, InputMappingNode, OutputMappingNode, ParallelBranchContainer, SubWorkflowContainerNode };
65
- //# sourceMappingURL=chunk-WGVHM7DU.js.map
66
- //# sourceMappingURL=chunk-WGVHM7DU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/builder/graph/internal-nodes.ts"],"names":[],"mappings":";;;;AAYO,IAAM,gBAAA,GAAN,cAAmE,IAAA,CAAqC;AAAA,EACtG,QAAA;AAAA,EACR,YAAY,OAAA,EAA2C;AACtD,IAAA,KAAA,EAAM;AAEN,IAAA,MAAM,EAAE,MAAA,EAAQ,UAAA,EAAY,eAAe,GAAG,QAAA,KAAa,OAAA,CAAQ,IAAA;AACnE,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAAA,EACjB;AAAA,EAEA,MAAM,IAAA,CAAK,EAAE,GAAA,EAAK,QAAO,EAAwC;AAChE,IAAA,KAAA,MAAW,CAAC,QAAQ,SAAS,CAAA,IAAK,OAAO,OAAA,CAAQ,IAAA,CAAK,QAAQ,CAAA,EAAG;AAChE,MAAA,IAAI,MAAM,GAAA,CAAI,GAAA,CAAI,SAAS,CAAA,EAAG;AAC7B,QAAA,GAAA,CAAI,IAAI,MAAA,EAAQ,MAAM,GAAA,CAAI,GAAA,CAAI,SAAS,CAAC,CAAA;AAAA,MACzC,CAAA,MACK;AACJ,QAAA,MAAA,CAAO,IAAA,CAAK,CAAA,yCAAA,EAA4C,SAAS,CAAA,uBAAA,CAAyB,CAAA;AAAA,MAC3F;AAAA,IACD;AAAA,EACD;AACD;AAQO,IAAM,iBAAA,GAAN,cAAoE,IAAA,CAAqC;AAAA,EACvG,QAAA;AAAA,EACR,YAAY,OAAA,EAA2C;AACtD,IAAA,KAAA,EAAM;AAEN,IAAA,MAAM,EAAE,MAAA,EAAQ,UAAA,EAAY,eAAe,GAAG,QAAA,KAAa,OAAA,CAAQ,IAAA;AACnE,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAAA,EACjB;AAAA,EAEA,MAAM,IAAA,CAAK,EAAE,GAAA,EAAK,QAAO,EAAwC;AAChE,IAAA,KAAA,MAAW,CAAC,WAAW,MAAM,CAAA,IAAK,OAAO,OAAA,CAAQ,IAAA,CAAK,QAAQ,CAAA,EAAG;AAChE,MAAA,IAAI,MAAM,GAAA,CAAI,GAAA,CAAI,MAAM,CAAA,EAAG;AAC1B,QAAA,GAAA,CAAI,IAAI,SAAA,EAAW,MAAM,GAAA,CAAI,GAAA,CAAI,MAAM,CAAC,CAAA;AAAA,MACzC,CAAA,MACK;AACJ,QAAA,MAAA,CAAO,IAAA,CAAK,CAAA,2CAAA,EAA8C,MAAM,CAAA,uBAAA,CAAyB,CAAA;AAAA,MAC1F;AAAA,IACD;AAAA,EACD;AACD;AAOO,IAAM,wBAAA,GAAN,cAA2E,IAAA,CAAqC;AAAA,EACtH,WAAA,GAAc;AACb,IAAA,KAAA,EAAM;AACN,IAAA,IAAA,CAAK,aAAA,GAAgB,IAAA;AAAA,EACtB;AAAA,EAEA,MAAM,IAAA,GAAO;AAAA,EAGb;AACD;AAGO,IAAM,uBAAA,GAAN,cAA0E,YAAA,CAAuB;AAAA;AAAA,EAEvF,mBAAA,GAAsB,IAAA;AAAA;AAAA,EAE/B,aAA6B,EAAC;AAAA,EAErC,WAAA,GAAc;AACb,IAAA,KAAA,EAAM;AAEN,IAAA,IAAA,CAAK,aAAA,GAAgB,IAAA;AAAA,EACtB;AACD;AAQO,IAAM,mBAAA,GAAN,cAAsE,IAAA,CAAqC;AAAA,EACjH,WAAA,GAAc;AACb,IAAA,KAAA,EAAM;AACN,IAAA,IAAA,CAAK,aAAA,GAAgB,IAAA;AAAA,EACtB;AACD","file":"chunk-WGVHM7DU.js","sourcesContent":["import type { Context } from '../../context'\nimport type { NodeArgs } from '../../types'\nimport type { AbstractNode } from '../../workflow/index'\nimport { Node } from '../../workflow/index'\nimport { ParallelFlow } from '../patterns'\n\n/**\n * An internal node used by the GraphBuilder to handle the `inputs` mapping\n * of an inlined sub-workflow. It copies data from the parent context scope\n * to the sub-workflow's context scope.\n * @internal\n */\nexport class InputMappingNode<TContext extends Context = Context> extends Node<void, void, any, any, TContext> {\n\tprivate mappings: Record<string, string>\n\tconstructor(options: { data: Record<string, string> }) {\n\t\tsuper()\n\t\t// Exclude the injected nodeId from the mappings\n\t\tconst { nodeId, originalId, isSubWorkflow, ...mappings } = options.data\n\t\tthis.mappings = mappings\n\t}\n\n\tasync prep({ ctx, logger }: NodeArgs<void, void, any, TContext>) {\n\t\tfor (const [subKey, parentKey] of Object.entries(this.mappings)) {\n\t\t\tif (await ctx.has(parentKey)) {\n\t\t\t\tctx.set(subKey, await ctx.get(parentKey))\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlogger.warn(`[InputMapper] Input mapping failed. Key '${parentKey}' not found in context.`)\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * An internal node used by the GraphBuilder to handle the `outputs` mapping\n * of an inlined sub-workflow. It copies data from the sub-workflow's\n * context scope back to the parent's context scope.\n * @internal\n */\nexport class OutputMappingNode<TContext extends Context = Context> extends Node<void, void, any, any, TContext> {\n\tprivate mappings: Record<string, string>\n\tconstructor(options: { data: Record<string, string> }) {\n\t\tsuper()\n\t\t// Exclude the injected nodeId from the mappings\n\t\tconst { nodeId, originalId, isSubWorkflow, ...mappings } = options.data\n\t\tthis.mappings = mappings\n\t}\n\n\tasync prep({ ctx, logger }: NodeArgs<void, void, any, TContext>) {\n\t\tfor (const [parentKey, subKey] of Object.entries(this.mappings)) {\n\t\t\tif (await ctx.has(subKey)) {\n\t\t\t\tctx.set(parentKey, await ctx.get(subKey))\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlogger.warn(`[OutputMapper] Output mapping failed. Key '${subKey}' not found in context.`)\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * A private class used by the builder to represent the sub-workflow container itself.\n * It's a structural node that preserves the original node ID in the flattened graph.\n * @internal\n */\nexport class SubWorkflowContainerNode<TContext extends Context = Context> extends Node<void, void, any, any, TContext> {\n\tconstructor() {\n\t\tsuper()\n\t\tthis.isPassthrough = true\n\t}\n\n\tasync exec() {\n\t\t// This node performs no work; it just acts as a stable entry point.\n\t\t// The graph wiring ensures the InputMappingNode is executed next.\n\t}\n}\n\n/** A private class used by the builder to represent parallel execution blocks. */\nexport class ParallelBranchContainer<TContext extends Context = Context> extends ParallelFlow<TContext> {\n\t/** A tag to reliably identify this node type in the visualizer. */\n\tpublic readonly isParallelContainer = true\n\t// This is now a public, mutable property for the executor to populate.\n\tpublic nodesToRun: AbstractNode[] = []\n\n\tconstructor() {\n\t\tsuper() // Call the parent constructor, which can handle an empty/no-arg state.\n\t\t// semantic flag for distributed executors.\n\t\tthis.isPassthrough = true\n\t}\n}\n\n/**\n * A private class used by the builder to unify conditional branches\n * before they connect to a common successor. This ensures the successor\n * only has one predecessor, preventing false fan-in detection.\n * @internal\n */\nexport class ConditionalJoinNode<TContext extends Context = Context> extends Node<void, void, any, any, TContext> {\n\tconstructor() {\n\t\tsuper()\n\t\tthis.isPassthrough = true // It performs no logic, just structural\n\t}\n}\n"]}
@@ -1,91 +0,0 @@
1
- // src/utils/analysis.ts
2
- function isNodeType(type) {
3
- return (node) => {
4
- return node.type === type;
5
- };
6
- }
7
- function analyzeGraph(graph) {
8
- const typedGraph = graph;
9
- const analysis = {
10
- nodes: /* @__PURE__ */ new Map(),
11
- allNodeIds: [],
12
- startNodeIds: [],
13
- cycles: []
14
- };
15
- if (!typedGraph || !typedGraph.nodes || !typedGraph.nodes.length)
16
- return analysis;
17
- const allNodeIds = typedGraph.nodes.map((node) => node.id);
18
- analysis.allNodeIds = allNodeIds;
19
- const adj = /* @__PURE__ */ new Map();
20
- typedGraph.nodes.forEach((node) => {
21
- analysis.nodes.set(node.id, { ...node, inDegree: 0, outDegree: 0 });
22
- adj.set(node.id, []);
23
- });
24
- typedGraph.edges.forEach((edge) => {
25
- const source = analysis.nodes.get(edge.source);
26
- const target = analysis.nodes.get(edge.target);
27
- if (source)
28
- source.outDegree++;
29
- if (target)
30
- target.inDegree++;
31
- if (adj.has(edge.source))
32
- adj.get(edge.source).push(edge.target);
33
- });
34
- analysis.startNodeIds = allNodeIds.filter((id) => analysis.nodes.get(id).inDegree === 0);
35
- const visited = /* @__PURE__ */ new Set();
36
- const recursionStack = /* @__PURE__ */ new Set();
37
- function detectCycleUtil(nodeId, path) {
38
- visited.add(nodeId);
39
- recursionStack.add(nodeId);
40
- path.push(nodeId);
41
- const neighbors = adj.get(nodeId) || [];
42
- for (const neighbor of neighbors) {
43
- if (recursionStack.has(neighbor)) {
44
- const cycleStartIndex = path.indexOf(neighbor);
45
- const cycle = path.slice(cycleStartIndex);
46
- analysis.cycles.push([...cycle, neighbor]);
47
- } else if (!visited.has(neighbor)) {
48
- detectCycleUtil(neighbor, path);
49
- }
50
- }
51
- recursionStack.delete(nodeId);
52
- path.pop();
53
- }
54
- for (const nodeId of allNodeIds) {
55
- if (!visited.has(nodeId))
56
- detectCycleUtil(nodeId, []);
57
- }
58
- return analysis;
59
- }
60
- function createNodeRule(filter, check) {
61
- return (analysis, _graph) => {
62
- const errors = [];
63
- for (const node of analysis.nodes.values()) {
64
- if (filter(node)) {
65
- const result = check(node);
66
- if (result) {
67
- if (Array.isArray(result))
68
- errors.push(...result);
69
- else
70
- errors.push(result);
71
- }
72
- }
73
- }
74
- return errors;
75
- };
76
- }
77
- var checkForCycles = (analysis) => {
78
- const uniqueCycles = new Set(analysis.cycles.map((c) => c.slice(0, -1).sort().join(",")));
79
- return Array.from(uniqueCycles).map((cycleKey) => {
80
- const representativeCycle = analysis.cycles.find((c) => c.slice(0, -1).sort().join(",") === cycleKey);
81
- return {
82
- nodeId: representativeCycle[0],
83
- type: "CycleDetected",
84
- message: `Cycle detected involving nodes: ${representativeCycle.join(" -> ")}`
85
- };
86
- });
87
- };
88
-
89
- export { analyzeGraph, checkForCycles, createNodeRule, isNodeType };
90
- //# source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,CAAK,YAAY,CAAA,CAAE,GAAA,CAAI,CAAC,QAAA,KAAa;AACjD,IAAA,MAAM,mBAAA,GAAsB,QAAA,CAAS,MAAA,CAAO,IAAA,CAAK,OAAK,CAAA,CAAE,KAAA,CAAM,CAAA,EAAG,EAAE,EAAE,IAAA,EAAK,CAAE,IAAA,CAAK,GAAG,MAAM,QAAQ,CAAA;AAClG,IAAA,OAAO;AAAA,MACN,MAAA,EAAQ,oBAAoB,CAAC,CAAA;AAAA,MAC7B,IAAA,EAAM,eAAA;AAAA,MACN,OAAA,EAAS,CAAA,gCAAA,EAAmC,mBAAA,CAAoB,IAAA,CAAK,MAAM,CAAC,CAAA;AAAA,KAC7E;AAAA,EACD,CAAC,CAAA;AACF","file":"chunk-WR5PDOPP.js","sourcesContent":["import type { GraphNode, NodeTypeMap, TypedGraphNode, TypedWorkflowGraph, WorkflowGraph } from '../builder/graph/types'\n\n/** The rich metadata object returned by the analyzeGraph function. */\nexport interface GraphAnalysis<T extends NodeTypeMap = any> {\n\t/** A map of all nodes, keyed by ID, augmented with their connection degrees. */\n\tnodes: Map<string, TypedGraphNode<T> & { inDegree: number, outDegree: number }>\n\t/** An array of all node IDs in the graph. */\n\tallNodeIds: string[]\n\t/** An array of node IDs that have no incoming edges. */\n\tstartNodeIds: string[]\n\t/** A list of cycles found in the graph. Each cycle is an array of node IDs. */\n\tcycles: string[][]\n}\n\n/** A standard structure for reporting a single validation error. */\nexport interface ValidationError {\n\t/** The ID of the node where the error occurred, if applicable. */\n\tnodeId?: string\n\t/** A category for the error, e.g., 'CycleDetected', 'ConnectionRuleViolation'. */\n\ttype: string\n\t/** A human-readable message explaining the validation failure. */\n\tmessage: string\n}\n\n/**\n * A function that takes a graph analysis and the original graph,\n * and returns an array of validation errors.\n */\nexport type Validator<T extends NodeTypeMap = any> = (\n\tanalysis: GraphAnalysis<T>,\n\tgraph: TypedWorkflowGraph<T>\n) => ValidationError[]\n\n/**\n * A helper function that creates a type guard for filtering nodes by their type.\n * This simplifies writing type-safe validation rules by removing the need for\n * verbose, explicit type guard syntax.\n *\n * @param type The literal string of the node type to check for.\n * @returns A type guard function that narrows the node to its specific type.\n */\nexport function isNodeType<T extends NodeTypeMap, K extends keyof T>(type: K) {\n\treturn (node: TypedGraphNode<T>): node is TypedGraphNode<T> & { type: K } => {\n\t\treturn node.type === type\n\t}\n}\n\n/**\n * Analyzes a declarative workflow graph definition to extract structural metadata.\n * This is a lightweight, static utility that does not instantiate any nodes.\n *\n * @param graph The WorkflowGraph object containing nodes and edges.\n * @returns A GraphAnalysis object containing nodes with degree counts, start nodes, and any cycles.\n */\n// (Typesafe Overload) Analyzes a declarative workflow graph, preserving strong types.\nexport function analyzeGraph<T extends NodeTypeMap>(graph: TypedWorkflowGraph<T>): GraphAnalysis<T>\n// (Untyped Overload) Analyzes a declarative workflow graph with basic types.\nexport function analyzeGraph(graph: WorkflowGraph): GraphAnalysis\n// (Implementation) Analyzes a declarative workflow graph to extract structural metadata.\nexport function analyzeGraph<T extends NodeTypeMap>(graph: TypedWorkflowGraph<T> | WorkflowGraph): GraphAnalysis<T> {\n\tconst typedGraph = graph as TypedWorkflowGraph<T> // Cast for internal consistency\n\tconst analysis: GraphAnalysis<T> = {\n\t\tnodes: new Map(),\n\t\tallNodeIds: [],\n\t\tstartNodeIds: [],\n\t\tcycles: [],\n\t}\n\n\tif (!typedGraph || !typedGraph.nodes || !typedGraph.nodes.length)\n\t\treturn analysis\n\n\tconst allNodeIds = typedGraph.nodes.map(node => node.id)\n\tanalysis.allNodeIds = allNodeIds\n\n\tconst adj: Map<string, string[]> = new Map()\n\ttypedGraph.nodes.forEach((node) => {\n\t\tanalysis.nodes.set(node.id, { ...node, inDegree: 0, outDegree: 0 })\n\t\tadj.set(node.id, [])\n\t})\n\n\ttypedGraph.edges.forEach((edge) => {\n\t\tconst source = analysis.nodes.get(edge.source)\n\t\tconst target = analysis.nodes.get(edge.target)\n\t\tif (source)\n\t\t\tsource.outDegree++\n\t\tif (target)\n\t\t\ttarget.inDegree++\n\t\tif (adj.has(edge.source))\n\t\t\tadj.get(edge.source)!.push(edge.target)\n\t})\n\n\tanalysis.startNodeIds = allNodeIds.filter(id => analysis.nodes.get(id)!.inDegree === 0)\n\n\tconst visited = new Set<string>()\n\tconst recursionStack = new Set<string>()\n\tfunction detectCycleUtil(nodeId: string, path: string[]) {\n\t\tvisited.add(nodeId)\n\t\trecursionStack.add(nodeId)\n\t\tpath.push(nodeId)\n\n\t\tconst neighbors = adj.get(nodeId) || []\n\t\tfor (const neighbor of neighbors) {\n\t\t\tif (recursionStack.has(neighbor)) {\n\t\t\t\tconst cycleStartIndex = path.indexOf(neighbor)\n\t\t\t\tconst cycle = path.slice(cycleStartIndex)\n\t\t\t\tanalysis.cycles.push([...cycle, neighbor])\n\t\t\t}\n\t\t\telse if (!visited.has(neighbor)) {\n\t\t\t\tdetectCycleUtil(neighbor, path)\n\t\t\t}\n\t\t}\n\n\t\trecursionStack.delete(nodeId)\n\t\tpath.pop()\n\t}\n\n\tfor (const nodeId of allNodeIds) {\n\t\tif (!visited.has(nodeId))\n\t\t\tdetectCycleUtil(nodeId, [])\n\t}\n\n\treturn analysis\n}\n\n/**\n * Factory for creating a generic, reusable validator that checks node properties.\n * A single rule can now return multiple errors for a single node.\n *\n * @param filter A predicate to select which nodes this rule applies to.\n * @param check A function that validates a selected node. It can return a single\n * ValidationError, an array of them, or null if the node is valid.\n * @returns A Validator function.\n */\n// (Type-Safe Overload) Creates a validator with strong types based on a NodeTypeMap.\nexport function createNodeRule<T extends NodeTypeMap>(\n\tfilter: (node: TypedGraphNode<T>) => boolean,\n\tcheck: (\n\t\tnode: TypedGraphNode<T> & { inDegree: number, outDegree: number },\n\t) => ValidationError | ValidationError[] | null | undefined,\n): Validator<T>\n// (Untyped Overload) Creates a validator with basic types.\nexport function createNodeRule(\n\tfilter: (node: GraphNode) => boolean,\n\tcheck: (\n\t\tnode: GraphNode & { inDegree: number, outDegree: number },\n\t) => ValidationError | ValidationError[] | null | undefined,\n): Validator\n// (Implementation) Factory for creating a generic, reusable validator.\nexport function createNodeRule(\n\tfilter: (node: any) => boolean,\n\tcheck: (\n\t\tnode: any,\n\t) => ValidationError | ValidationError[] | null | undefined,\n): Validator {\n\treturn (analysis: GraphAnalysis, _graph: WorkflowGraph): ValidationError[] => {\n\t\tconst errors: ValidationError[] = []\n\t\tfor (const node of analysis.nodes.values()) {\n\t\t\tif (filter(node)) {\n\t\t\t\tconst result = check(node)\n\t\t\t\tif (result) {\n\t\t\t\t\tif (Array.isArray(result))\n\t\t\t\t\t\terrors.push(...result)\n\t\t\t\t\telse\n\t\t\t\t\t\terrors.push(result)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn errors\n\t}\n}\n\n/**\n * A built-in validator that reports any cycles found in the graph.\n */\nexport const checkForCycles: Validator = (analysis) => {\n\tconst uniqueCycles = new Set(analysis.cycles.map(c => c.slice(0, -1).sort().join(',')))\n\treturn Array.from(uniqueCycles).map((cycleKey) => {\n\t\tconst representativeCycle = analysis.cycles.find(c => c.slice(0, -1).sort().join(',') === cycleKey)!\n\t\treturn {\n\t\t\tnodeId: representativeCycle[0],\n\t\t\ttype: 'CycleDetected',\n\t\t\tmessage: `Cycle detected involving nodes: ${representativeCycle.join(' -> ')}`,\n\t\t}\n\t})\n}\n"]}
@@ -1,20 +0,0 @@
1
- // src/utils/sanitize.ts
2
- function sanitizeGraph(rawGraph) {
3
- const nodes = rawGraph.nodes.map(({ id, type, data, config }) => ({
4
- id,
5
- type,
6
- data,
7
- ...config && { config }
8
- }));
9
- const edges = rawGraph.edges.map(({ id, source, target, action }) => ({
10
- id,
11
- source,
12
- target,
13
- ...action && { action }
14
- }));
15
- return { nodes, edges };
16
- }
17
-
18
- export { sanitizeGraph };
19
- //# sourceMappingURL=chunk-YR433ZDA.js.map
20
- //# sourceMappingURL=chunk-YR433ZDA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/sanitize.ts"],"names":[],"mappings":";AAWO,SAAS,cAAc,QAAA,EAAyD;AACtF,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,KAAA,CAAM,GAAA,CAAI,CAAC,EAAE,EAAA,EAAI,IAAA,EAAM,IAAA,EAAM,MAAA,EAAO,MAAO;AAAA,IACjE,EAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA;AAAA,IACA,GAAI,MAAA,IAAU,EAAE,MAAA;AAAO,GACxB,CAAE,CAAA;AAEF,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,KAAA,CAAM,GAAA,CAAI,CAAC,EAAE,EAAA,EAAI,MAAA,EAAQ,MAAA,EAAQ,MAAA,EAAO,MAAO;AAAA,IACrE,EAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAI,MAAA,IAAU,EAAE,MAAA;AAAO,GACxB,CAAE,CAAA;AAEF,EAAA,OAAO,EAAE,OAAO,KAAA,EAAM;AACvB","file":"chunk-YR433ZDA.js","sourcesContent":["import type { WorkflowGraph } from '../builder/graph/types'\n\n/**\n * Sanitizes a raw workflow graph object by removing properties that are not\n * relevant to the execution engine, such as UI-specific data.\n *\n * @param rawGraph - The raw graph object, potentially containing extraneous properties.\n * @param rawGraph.nodes - An array of node objects.\n * @param rawGraph.edges - An array of edge objects.\n * @returns A clean, execution-focused `WorkflowGraph` object.\n */\nexport function sanitizeGraph(rawGraph: { nodes: any[], edges: any[] }): WorkflowGraph {\n\tconst nodes = rawGraph.nodes.map(({ id, type, data, config }) => ({\n\t\tid,\n\t\ttype,\n\t\tdata,\n\t\t...(config && { config }),\n\t}))\n\n\tconst edges = rawGraph.edges.map(({ id, source, target, action }) => ({\n\t\tid,\n\t\tsource,\n\t\ttarget,\n\t\t...(action && { action }),\n\t}))\n\n\treturn { nodes, edges }\n}\n"]}
@@ -1,39 +0,0 @@
1
- import { Context } from '../context.js';
2
- import { I as IExecutor, A as AbstractNode, e as Middleware, p as InternalRunOptions, F as Flow, R as RunOptions } from '../types-U76Ukj96.js';
3
- import '../logger.js';
4
-
5
- /**
6
- * The default executor that runs a workflow within a single, in-memory process.
7
- * This class contains the core logic for traversing a workflow graph, applying middleware,
8
- * and handling node execution.
9
- */
10
- declare class InMemoryExecutor implements IExecutor {
11
- /**
12
- * A stateless, reusable method that orchestrates the traversal of a graph.
13
- * It is called by `run()` for top-level flows and by `Flow.exec()` for sub-flows.
14
- * @param startNode The node where the graph traversal begins.
15
- * @param flowMiddleware The middleware array from the containing flow.
16
- * @param context The shared workflow context.
17
- * @param options The internal, normalized run options.
18
- * @returns The final action from the last executed node in the graph.
19
- * @internal
20
- */
21
- _orch<T = any>(startNode: AbstractNode, flowMiddleware: Middleware[], context: Context, options: InternalRunOptions): Promise<T>;
22
- /**
23
- * Executes a given flow with a specific context and options.
24
- * This is the main entry point for the in-memory execution engine.
25
- * @param flow The Flow instance to execute.
26
- * @param context The shared context for the workflow.
27
- * @param options Runtime options, including a logger, abort controller, or initial params.
28
- * @returns A promise that resolves with the final action of the workflow.
29
- */
30
- run<T>(flow: Flow<any, T>, context: Context, options?: RunOptions): Promise<T>;
31
- run(flow: Flow, context: Context, options?: RunOptions): Promise<any>;
32
- /**
33
- * Determines the next node to execute based on the action returned by the current node.
34
- * @internal
35
- */
36
- getNextNode(curr: AbstractNode, action: any): AbstractNode | undefined;
37
- }
38
-
39
- export { InMemoryExecutor };
@@ -1,6 +0,0 @@
1
- export { InMemoryExecutor } from '../chunk-BRFMFLR6.js';
2
- import '../chunk-PNWOW52F.js';
3
- import '../chunk-64DNBF5W.js';
4
- import '../chunk-IIKTTIW5.js';
5
- //# sourceMappingURL=in-memory.js.map
6
- //# sourceMappingURL=in-memory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"in-memory.js"}
@@ -1,3 +0,0 @@
1
- import '../context.js';
2
- import '../logger.js';
3
- export { I as IExecutor, p as InternalRunOptions } from '../types-U76Ukj96.js';
@@ -1,3 +0,0 @@
1
- import '../chunk-TS3M7MWA.js';
2
- //# sourceMappingURL=types.js.map
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}
@@ -1,88 +0,0 @@
1
- import { Context, ContextTransform } from './context.js';
2
- import { P as Params, N as Node, F as Flow } from './types-U76Ukj96.js';
3
- import './logger.js';
4
-
5
- /**
6
- * A type for a pure function that can be executed within a `Node`,
7
- * typically taking the node's `params` as input.
8
- * @template TIn The input type, corresponding to `params`.
9
- * @template TOut The output type, which becomes the node's `execRes`.
10
- */
11
- type NodeFunction<TIn = any, TOut = any> = (input: TIn) => TOut | Promise<TOut>;
12
- /**
13
- * A type for a function that operates on the shared `Context` in addition
14
- * to the node's `params`.
15
- * @template TIn The input type, corresponding to `params`.
16
- * @template TOut The output type, which becomes the node's `execRes`.
17
- */
18
- type ContextFunction<TIn = any, TOut = any, TContext extends Context = Context> = (ctx: TContext, input: TIn) => TOut | Promise<TOut>;
19
- /**
20
- * Creates a `Node` from a simple, pure function that transforms an input to an output.
21
- * The node's `params` object is passed as the input to the function.
22
- *
23
- * @example
24
- * const add = (n: number) => mapNode<{ value: number }, number>(params => params.value + n)
25
- * const add5Node = add(5) // A reusable node that adds 5 to its input parameter.
26
- *
27
- * @param fn A function that takes an input object and returns a result.
28
- * @returns A new `Node` instance that wraps the function.
29
- */
30
- declare function mapNode<TIn extends Params, TOut, TContext extends Context = Context>(fn: NodeFunction<TIn, TOut>): Node<void, TOut, any, TIn, TContext>;
31
- /**
32
- * Creates a `Node` from a function that requires access to the shared `Context`.
33
- * Both the `Context` and the node's `params` are passed as arguments to the function.
34
- *
35
- * @example
36
- * const greeter = contextNode(async (ctx, params: { name: string }) => {
37
- * const language = await ctx.get(LANGUAGE_KEY) || 'en'
38
- * return language === 'en' ? `Hello, ${params.name}` : `Hola, ${params.name}`
39
- * })
40
- *
41
- * @param fn A function that takes the context and an input object, and returns a result.
42
- * @returns A new `Node` instance that wraps the function.
43
- */
44
- declare function contextNode<TIn extends Params, TOut, TContext extends Context = Context>(fn: ContextFunction<TIn, TOut, TContext>): Node<void, TOut, any, TIn, TContext>;
45
- /**
46
- * Creates a `Node` that declaratively applies a series of transformations to the `Context`.
47
- * This is a "side-effect" node used purely for state management; its logic runs in the `prep` phase,
48
- * and it does not produce an `exec` output.
49
- *
50
- * @example
51
- * const USER_ID = contextKey<string>('user_id')
52
- * const userLens = lens(USER_ID)
53
- * const setupUserContext = (userId: string) => transformNode(userLens.set(userId))
54
- *
55
- * @param transforms A sequence of `ContextTransform` functions (e.g., from a lens) to apply.
56
- * @returns A new `Node` instance that will mutate the context when executed.
57
- */
58
- declare function transformNode<TContext extends Context = Context>(...transforms: ContextTransform[]): Node<void, void, any, Params, TContext>;
59
- /**
60
- * A functional-style alias for `SequenceFlow`. It constructs a linear workflow
61
- * where each node executes in the order it is provided.
62
- *
63
- * @example
64
- * const mathPipeline = pipeline(addNode(5), multiplyNode(2))
65
- *
66
- * @param nodes A sequence of `Node` instances to chain together.
67
- * @returns A `Flow` instance representing the linear sequence.
68
- */
69
- declare function pipeline<TContext extends Context = Context>(...nodes: Node<any, any, any, any, TContext>[]): Flow<any, any, Params, TContext>;
70
- /**
71
- * A classic functional composition utility. It takes two functions, `f` and `g`,
72
- * and returns a new function that computes `f(g(x))`.
73
- *
74
- * This is a general-purpose helper, not a `Node` builder itself, but it can be
75
- * used to create more complex `NodeFunction`s to pass to `mapNode`.
76
- *
77
- * @example
78
- * const add5 = (x: number) => x + 5
79
- * const multiply2 = (x: number) => x * 2
80
- * const add5ThenMultiply2 = compose(multiply2, add5) // equivalent to: x => (x + 5) * 2
81
- *
82
- * @param f The outer function, which receives the result of `g`.
83
- * @param g The inner function, which receives the initial input.
84
- * @returns A new `NodeFunction` that combines both operations.
85
- */
86
- declare function compose<A, B, C>(f: NodeFunction<B, C>, g: NodeFunction<A, B>): NodeFunction<A, C>;
87
-
88
- export { type ContextFunction, type NodeFunction, compose, contextNode, mapNode, pipeline, transformNode };
package/dist/functions.js DELETED
@@ -1,21 +0,0 @@
1
- export { compose, contextNode, mapNode, pipeline, transformNode } from './chunk-P3RPDZHO.js';
2
- import './chunk-R27FIYR5.js';
3
- import './chunk-L5PK5VL2.js';
4
- import './chunk-F6C6J7HK.js';
5
- import './chunk-UY4PNPBX.js';
6
- import './chunk-ELEHMJPM.js';
7
- import './chunk-HEO3XL4Z.js';
8
- import './chunk-7XUN3OQT.js';
9
- import './chunk-WR5PDOPP.js';
10
- import './chunk-VMH2LRM6.js';
11
- import './chunk-YR433ZDA.js';
12
- import './chunk-6QCXIRLA.js';
13
- import './chunk-BRFMFLR6.js';
14
- import './chunk-PNWOW52F.js';
15
- import './chunk-VZDHIOCH.js';
16
- import './chunk-S4WFNGQG.js';
17
- import './chunk-64DNBF5W.js';
18
- import './chunk-IIKTTIW5.js';
19
- import './chunk-AOHBHYF6.js';
20
- //# sourceMappingURL=functions.js.map
21
- //# sourceMappingURL=functions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"functions.js"}