flowcraft 2.2.0 → 2.3.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 (147) hide show
  1. package/README.md +40 -34
  2. package/dist/analysis.d.ts +3 -1
  3. package/dist/chunk-33NO4PUJ.js +74 -0
  4. package/dist/chunk-33NO4PUJ.js.map +1 -0
  5. package/dist/chunk-5KKSQWSC.js +90 -0
  6. package/dist/chunk-5KKSQWSC.js.map +1 -0
  7. package/dist/{chunk-QLGJUDQF.js → chunk-6INWPSZT.js} +6 -6
  8. package/dist/chunk-6INWPSZT.js.map +1 -0
  9. package/dist/chunk-BC4G7OM6.js +42 -0
  10. package/dist/chunk-BC4G7OM6.js.map +1 -0
  11. package/dist/chunk-BCRWXTWX.js +21 -0
  12. package/dist/chunk-BCRWXTWX.js.map +1 -0
  13. package/dist/{chunk-ZCHFZBGL.js → chunk-C4HYIJI3.js} +120 -5
  14. package/dist/chunk-C4HYIJI3.js.map +1 -0
  15. package/dist/chunk-CD3Q4N6V.js +13 -0
  16. package/dist/chunk-CD3Q4N6V.js.map +1 -0
  17. package/dist/chunk-CD4FUZOJ.js +114 -0
  18. package/dist/chunk-CD4FUZOJ.js.map +1 -0
  19. package/dist/chunk-CY755I7I.js +25 -0
  20. package/dist/chunk-CY755I7I.js.map +1 -0
  21. package/dist/chunk-DL7KVYZF.js +39 -0
  22. package/dist/chunk-DL7KVYZF.js.map +1 -0
  23. package/dist/chunk-FRKO3WX4.js +32 -0
  24. package/dist/chunk-FRKO3WX4.js.map +1 -0
  25. package/dist/chunk-G53CSLBF.js +54 -0
  26. package/dist/chunk-G53CSLBF.js.map +1 -0
  27. package/dist/chunk-G5BGBPFP.js +172 -0
  28. package/dist/chunk-G5BGBPFP.js.map +1 -0
  29. package/dist/chunk-HAZ26F3P.js +98 -0
  30. package/dist/chunk-HAZ26F3P.js.map +1 -0
  31. package/dist/chunk-IB2BISIC.js +446 -0
  32. package/dist/chunk-IB2BISIC.js.map +1 -0
  33. package/dist/{chunk-U5V5O5MN.js → chunk-LNK7LZER.js} +5 -3
  34. package/dist/chunk-LNK7LZER.js.map +1 -0
  35. package/dist/chunk-MCGK3FXQ.js +143 -0
  36. package/dist/chunk-MCGK3FXQ.js.map +1 -0
  37. package/dist/chunk-MUYLRTSR.js +82 -0
  38. package/dist/chunk-MUYLRTSR.js.map +1 -0
  39. package/dist/chunk-NVJ3ZO3P.js +3 -0
  40. package/dist/{chunk-HMR2GEGE.js.map → chunk-NVJ3ZO3P.js.map} +1 -1
  41. package/dist/chunk-NVLZFLYM.js +3 -0
  42. package/dist/chunk-NVLZFLYM.js.map +1 -0
  43. package/dist/chunk-ONH7PIJZ.js +300 -0
  44. package/dist/chunk-ONH7PIJZ.js.map +1 -0
  45. package/dist/chunk-QNYXQKFW.js +25 -0
  46. package/dist/chunk-QNYXQKFW.js.map +1 -0
  47. package/dist/chunk-RM677CNU.js +52 -0
  48. package/dist/chunk-RM677CNU.js.map +1 -0
  49. package/dist/chunk-WWGFIYKW.js +47 -0
  50. package/dist/chunk-WWGFIYKW.js.map +1 -0
  51. package/dist/chunk-XNRIM27H.js +76 -0
  52. package/dist/chunk-XNRIM27H.js.map +1 -0
  53. package/dist/container-factory.d.ts +17 -0
  54. package/dist/container-factory.js +13 -0
  55. package/dist/container-factory.js.map +1 -0
  56. package/dist/container.d.ts +23 -0
  57. package/dist/container.js +3 -0
  58. package/dist/container.js.map +1 -0
  59. package/dist/context.d.ts +3 -1
  60. package/dist/errors.d.ts +18 -17
  61. package/dist/errors.js +1 -1
  62. package/dist/evaluator.d.ts +3 -1
  63. package/dist/flow.d.ts +12 -2
  64. package/dist/flow.js +2 -2
  65. package/dist/index.d.ts +7 -8
  66. package/dist/index.js +26 -14
  67. package/dist/linter.d.ts +3 -1
  68. package/dist/logger.d.ts +3 -1
  69. package/dist/node.d.ts +3 -1
  70. package/dist/node.js +1 -1
  71. package/dist/nodes/batch-gather.d.ts +9 -0
  72. package/dist/nodes/batch-gather.js +4 -0
  73. package/dist/nodes/batch-gather.js.map +1 -0
  74. package/dist/nodes/batch-scatter.d.ts +9 -0
  75. package/dist/nodes/batch-scatter.js +4 -0
  76. package/dist/nodes/batch-scatter.js.map +1 -0
  77. package/dist/nodes/subflow.d.ts +9 -0
  78. package/dist/nodes/subflow.js +10 -0
  79. package/dist/nodes/subflow.js.map +1 -0
  80. package/dist/nodes/wait.d.ts +9 -0
  81. package/dist/nodes/wait.js +4 -0
  82. package/dist/nodes/wait.js.map +1 -0
  83. package/dist/runtime/adapter.d.ts +3 -5
  84. package/dist/runtime/adapter.js +19 -9
  85. package/dist/runtime/execution-context.d.ts +3 -0
  86. package/dist/runtime/execution-context.js +6 -0
  87. package/dist/runtime/execution-context.js.map +1 -0
  88. package/dist/runtime/executors.d.ts +3 -26
  89. package/dist/runtime/executors.js +2 -2
  90. package/dist/runtime/index.d.ts +5 -7
  91. package/dist/runtime/index.js +21 -10
  92. package/dist/runtime/node-executor-factory.d.ts +12 -0
  93. package/dist/runtime/node-executor-factory.js +6 -0
  94. package/dist/runtime/node-executor-factory.js.map +1 -0
  95. package/dist/runtime/orchestrator.d.ts +9 -0
  96. package/dist/runtime/orchestrator.js +8 -0
  97. package/dist/runtime/orchestrator.js.map +1 -0
  98. package/dist/runtime/orchestrators/step-by-step.d.ts +16 -0
  99. package/dist/runtime/orchestrators/step-by-step.js +5 -0
  100. package/dist/runtime/orchestrators/step-by-step.js.map +1 -0
  101. package/dist/runtime/orchestrators/utils.d.ts +35 -0
  102. package/dist/runtime/orchestrators/utils.js +4 -0
  103. package/dist/runtime/orchestrators/utils.js.map +1 -0
  104. package/dist/runtime/runtime.d.ts +3 -41
  105. package/dist/runtime/runtime.js +18 -8
  106. package/dist/runtime/state.d.ts +3 -21
  107. package/dist/runtime/state.js +2 -1
  108. package/dist/runtime/traverser.d.ts +3 -26
  109. package/dist/runtime/traverser.js +1 -2
  110. package/dist/runtime/types.d.ts +3 -16
  111. package/dist/runtime/types.js +1 -1
  112. package/dist/runtime/workflow-logic-handler.d.ts +17 -0
  113. package/dist/runtime/workflow-logic-handler.js +5 -0
  114. package/dist/runtime/workflow-logic-handler.js.map +1 -0
  115. package/dist/sanitizer.d.ts +3 -1
  116. package/dist/serializer.d.ts +3 -1
  117. package/dist/testing/event-logger.d.ts +63 -0
  118. package/dist/testing/event-logger.js +3 -0
  119. package/dist/testing/event-logger.js.map +1 -0
  120. package/dist/testing/index.d.ts +6 -0
  121. package/dist/testing/index.js +31 -0
  122. package/dist/testing/index.js.map +1 -0
  123. package/dist/testing/run-with-trace.d.ts +38 -0
  124. package/dist/testing/run-with-trace.js +29 -0
  125. package/dist/testing/run-with-trace.js.map +1 -0
  126. package/dist/testing/stepper.d.ts +79 -0
  127. package/dist/testing/stepper.js +11 -0
  128. package/dist/testing/stepper.js.map +1 -0
  129. package/dist/types-ezHUBdpL.d.ts +564 -0
  130. package/dist/types.d.ts +3 -1
  131. package/package.json +55 -51
  132. package/LICENSE +0 -21
  133. package/dist/chunk-5ZXV3R5D.js +0 -28
  134. package/dist/chunk-5ZXV3R5D.js.map +0 -1
  135. package/dist/chunk-GEKDR2SS.js +0 -201
  136. package/dist/chunk-GEKDR2SS.js.map +0 -1
  137. package/dist/chunk-HMR2GEGE.js +0 -3
  138. package/dist/chunk-M2FRTT2K.js +0 -144
  139. package/dist/chunk-M2FRTT2K.js.map +0 -1
  140. package/dist/chunk-OTS5YJ3S.js +0 -494
  141. package/dist/chunk-OTS5YJ3S.js.map +0 -1
  142. package/dist/chunk-QLGJUDQF.js.map +0 -1
  143. package/dist/chunk-U5V5O5MN.js.map +0 -1
  144. package/dist/chunk-VSGQDLBF.js +0 -61
  145. package/dist/chunk-VSGQDLBF.js.map +0 -1
  146. package/dist/chunk-ZCHFZBGL.js.map +0 -1
  147. package/dist/types-CsTeXTiA.d.ts +0 -222
@@ -0,0 +1,38 @@
1
+ import { c as FlowRuntime, g as WorkflowBlueprint, J as WorkflowResult } from '../types-ezHUBdpL.js';
2
+ import '../errors.js';
3
+ import '../container.js';
4
+
5
+ /**
6
+ * A test helper that executes a workflow and automatically prints a detailed
7
+ * execution trace to the console if the workflow fails.
8
+ *
9
+ * @example
10
+ * // In your test file (e.g., my-workflow.test.ts)
11
+ * it('should process data correctly', async () => {
12
+ * const flow = createFlow('my-flow')
13
+ * .node('a', async () => ({ output: 1 }))
14
+ * .node('b', async ({ input }) => ({ output: input + 1 })) // Bug: returns { output: 3 }
15
+ * .edge('a', 'b')
16
+ *
17
+ * const runtime = new FlowRuntime({})
18
+ *
19
+ * // If this test fails, a full, human-readable trace of the execution
20
+ * // (inputs, outputs, context changes) is printed to the console.
21
+ * const result = await runWithTrace(runtime, flow.toBlueprint())
22
+ *
23
+ * expect(result.context.b).toBe(2)
24
+ * })
25
+ *
26
+ * @param runtime The original FlowRuntime instance (its options will be used).
27
+ * @param blueprint The WorkflowBlueprint to execute.
28
+ * @param initialState The initial state for the workflow run.
29
+ * @param options Additional options for the run.
30
+ * @returns The WorkflowResult if successful.
31
+ */
32
+ declare function runWithTrace<TContext extends Record<string, any>>(runtime: FlowRuntime<TContext, any>, blueprint: WorkflowBlueprint, initialState?: Partial<TContext> | string, options?: {
33
+ functionRegistry?: Map<string, any>;
34
+ strict?: boolean;
35
+ signal?: AbortSignal;
36
+ }): Promise<WorkflowResult<Record<string, any>>>;
37
+
38
+ export { runWithTrace };
@@ -0,0 +1,29 @@
1
+ export { runWithTrace } from '../chunk-CY755I7I.js';
2
+ import '../chunk-MUYLRTSR.js';
3
+ import '../chunk-NVJ3ZO3P.js';
4
+ import '../chunk-NVLZFLYM.js';
5
+ import '../chunk-6INWPSZT.js';
6
+ import '../chunk-IB2BISIC.js';
7
+ import '../chunk-MCGK3FXQ.js';
8
+ import '../chunk-DL7KVYZF.js';
9
+ import '../chunk-ONH7PIJZ.js';
10
+ import '../chunk-5KKSQWSC.js';
11
+ import '../chunk-CD3Q4N6V.js';
12
+ import '../chunk-G5BGBPFP.js';
13
+ import '../chunk-DSYAC4WB.js';
14
+ import '../chunk-BC4G7OM6.js';
15
+ import '../chunk-RM677CNU.js';
16
+ import '../chunk-233SESC2.js';
17
+ import '../chunk-33NO4PUJ.js';
18
+ import '../chunk-HAZ26F3P.js';
19
+ import '../chunk-FRKO3WX4.js';
20
+ import '../chunk-CD4FUZOJ.js';
21
+ import '../chunk-4PELJWF7.js';
22
+ import '../chunk-CYHZ2YVH.js';
23
+ import '../chunk-WWGFIYKW.js';
24
+ import '../chunk-R3HQXIEL.js';
25
+ import '../chunk-BCRWXTWX.js';
26
+ import '../chunk-PH2IYZHV.js';
27
+ import '../chunk-LNK7LZER.js';
28
+ //# sourceMappingURL=run-with-trace.js.map
29
+ //# sourceMappingURL=run-with-trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"run-with-trace.js"}
@@ -0,0 +1,79 @@
1
+ import { W as WorkflowState, G as GraphTraverser, J as WorkflowResult, c as FlowRuntime, g as WorkflowBlueprint, n as NodeFunction, o as NodeClass } from '../types-ezHUBdpL.js';
2
+ import '../errors.js';
3
+ import '../container.js';
4
+
5
+ /**
6
+ * Represents the controlled, step-by-step execution of a workflow.
7
+ * Returned by the `createStepper` utility.
8
+ */
9
+ interface IWorkflowStepper<TContext extends Record<string, any>> {
10
+ /** The current state of the workflow. Can be inspected after each step. */
11
+ readonly state: WorkflowState<TContext>;
12
+ /** The graph traverser instance. Can be used to inspect the frontier or completed nodes. */
13
+ readonly traverser: GraphTraverser;
14
+ /**
15
+ * Executes the next "turn" or batch of ready nodes in the workflow.
16
+ * @param options Optional configuration for this specific step, like a cancellation signal.
17
+ * @returns A `WorkflowResult` representing the state after the step, or `null` if the workflow has already completed.
18
+ */
19
+ next(options?: {
20
+ signal?: AbortSignal;
21
+ concurrency?: number;
22
+ }): Promise<WorkflowResult<TContext> | null>;
23
+ /**
24
+ * Reverts the workflow to its previous state.
25
+ * @returns The `WorkflowResult` of the previous state, or `null` if there is no history to revert to.
26
+ */
27
+ prev(): Promise<WorkflowResult<TContext> | null>;
28
+ /**
29
+ * Resets the stepper to its initial state, clearing all progress and history.
30
+ */
31
+ reset(): void;
32
+ /**
33
+ * A convenience method to check if the workflow has any more steps to run.
34
+ * @returns `true` if the workflow is complete or stalled, `false` otherwise.
35
+ */
36
+ isDone(): boolean;
37
+ }
38
+ /**
39
+ * A test utility that creates a stepper to execute a workflow one "turn" at a time.
40
+ * This is invaluable for debugging and writing fine-grained tests where you need to
41
+ * assert the state of the workflow after each logical step.
42
+ *
43
+ * @example
44
+ * // In your test file
45
+ * it('should correctly execute step-by-step', async () => {
46
+ * const runtime = new FlowRuntime({ ... });
47
+ * const flow = createFlow('test')
48
+ * .node('a', async () => ({ output: 10 }))
49
+ * .node('b', async ({ input }) => ({ output: input * 2 }))
50
+ * .edge('a', 'b');
51
+ *
52
+ * const stepper = await createStepper(runtime, flow.toBlueprint(), flow.getFunctionRegistry());
53
+ *
54
+ * // First step (executes node 'a')
55
+ * const result1 = await stepper.next();
56
+ * expect(stepper.isDone()).toBe(false);
57
+ * expect(result1.status).toBe('stalled');
58
+ * expect(result1.context._outputs.a).toBe(10);
59
+ *
60
+ * // Second step (executes node 'b')
61
+ * const result2 = await stepper.next();
62
+ * expect(stepper.isDone()).toBe(true);
63
+ * expect(result2.status).toBe('completed');
64
+ * expect(result2.context._outputs.b).toBe(20);
65
+ *
66
+ * // Final step (no more work)
67
+ * const result3 = await stepper.next();
68
+ * expect(result3).toBeNull();
69
+ * });
70
+ *
71
+ * @param runtime The `FlowRuntime` instance, used for its configuration.
72
+ * @param blueprint The `WorkflowBlueprint` to execute.
73
+ * @param functionRegistry The function registry from createFlow, containing the node implementations.
74
+ * @param initialState The initial state for the workflow run.
75
+ * @returns A Promise that resolves to an `IWorkflowStepper` instance.
76
+ */
77
+ declare function createStepper<TContext extends Record<string, any>, TDependencies extends Record<string, any>>(runtime: FlowRuntime<TContext, TDependencies>, blueprint: WorkflowBlueprint, functionRegistry: Map<string, NodeFunction | NodeClass>, initialState?: Partial<TContext>): Promise<IWorkflowStepper<TContext>>;
78
+
79
+ export { type IWorkflowStepper, createStepper };
@@ -0,0 +1,11 @@
1
+ export { createStepper } from '../chunk-XNRIM27H.js';
2
+ import '../chunk-G53CSLBF.js';
3
+ import '../chunk-G5BGBPFP.js';
4
+ import '../chunk-233SESC2.js';
5
+ import '../chunk-HAZ26F3P.js';
6
+ import '../chunk-FRKO3WX4.js';
7
+ import '../chunk-CD4FUZOJ.js';
8
+ import '../chunk-R3HQXIEL.js';
9
+ import '../chunk-BCRWXTWX.js';
10
+ //# sourceMappingURL=stepper.js.map
11
+ //# sourceMappingURL=stepper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"stepper.js"}