flowcraft 2.3.1 → 2.4.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 (86) hide show
  1. package/dist/analysis.d.ts +1 -1
  2. package/dist/{chunk-C4HYIJI3.js → chunk-7PBANEG3.js} +16 -2
  3. package/dist/chunk-7PBANEG3.js.map +1 -0
  4. package/dist/{chunk-HKX7WQLS.js → chunk-CHG6O6JX.js} +38 -8
  5. package/dist/chunk-CHG6O6JX.js.map +1 -0
  6. package/dist/{chunk-XNRIM27H.js → chunk-GIJOZ3AN.js} +4 -4
  7. package/dist/{chunk-XNRIM27H.js.map → chunk-GIJOZ3AN.js.map} +1 -1
  8. package/dist/{chunk-CD3Q4N6V.js → chunk-GVF7GQXQ.js} +6 -3
  9. package/dist/chunk-GVF7GQXQ.js.map +1 -0
  10. package/dist/{chunk-ZNL7ZXPR.js → chunk-J3HZD5ES.js} +26 -21
  11. package/dist/chunk-J3HZD5ES.js.map +1 -0
  12. package/dist/{chunk-MKNZBKSR.js → chunk-K6LPGUPR.js} +4 -4
  13. package/dist/{chunk-MKNZBKSR.js.map → chunk-K6LPGUPR.js.map} +1 -1
  14. package/dist/{chunk-FRKO3WX4.js → chunk-KXXEA5VE.js} +3 -3
  15. package/dist/{chunk-FRKO3WX4.js.map → chunk-KXXEA5VE.js.map} +1 -1
  16. package/dist/chunk-LJ4COM7S.js +20 -0
  17. package/dist/chunk-LJ4COM7S.js.map +1 -0
  18. package/dist/chunk-LM4ACVHL.js +73 -0
  19. package/dist/chunk-LM4ACVHL.js.map +1 -0
  20. package/dist/{chunk-33NO4PUJ.js → chunk-NDWVLU7J.js} +3 -3
  21. package/dist/{chunk-33NO4PUJ.js.map → chunk-NDWVLU7J.js.map} +1 -1
  22. package/dist/{chunk-CD4FUZOJ.js → chunk-OO3FF3DF.js} +22 -8
  23. package/dist/chunk-OO3FF3DF.js.map +1 -0
  24. package/dist/{chunk-QNYXQKFW.js → chunk-OZZP5YI6.js} +3 -3
  25. package/dist/{chunk-QNYXQKFW.js.map → chunk-OZZP5YI6.js.map} +1 -1
  26. package/dist/{chunk-BN4MV36K.js → chunk-VN2JKKAE.js} +3 -3
  27. package/dist/{chunk-BN4MV36K.js.map → chunk-VN2JKKAE.js.map} +1 -1
  28. package/dist/container-factory.d.ts +1 -1
  29. package/dist/container-factory.js +4 -4
  30. package/dist/context.d.ts +1 -1
  31. package/dist/evaluator.d.ts +1 -1
  32. package/dist/flow.d.ts +10 -1
  33. package/dist/flow.js +1 -1
  34. package/dist/index.d.ts +1 -1
  35. package/dist/index.js +12 -10
  36. package/dist/linter.d.ts +1 -1
  37. package/dist/logger.d.ts +1 -1
  38. package/dist/node.d.ts +1 -1
  39. package/dist/nodes/batch-gather.d.ts +1 -1
  40. package/dist/nodes/batch-scatter.d.ts +1 -1
  41. package/dist/nodes/sleep.d.ts +9 -0
  42. package/dist/nodes/sleep.js +4 -0
  43. package/dist/nodes/sleep.js.map +1 -0
  44. package/dist/nodes/subflow.d.ts +1 -1
  45. package/dist/nodes/subflow.js +3 -3
  46. package/dist/nodes/wait.d.ts +1 -1
  47. package/dist/nodes/wait.js +1 -1
  48. package/dist/runtime/adapter.d.ts +2 -1
  49. package/dist/runtime/adapter.js +10 -8
  50. package/dist/runtime/execution-context.d.ts +1 -1
  51. package/dist/runtime/execution-context.js +2 -2
  52. package/dist/runtime/executors.d.ts +1 -1
  53. package/dist/runtime/index.d.ts +1 -1
  54. package/dist/runtime/index.js +10 -8
  55. package/dist/runtime/node-executor-factory.d.ts +1 -1
  56. package/dist/runtime/orchestrator.d.ts +1 -1
  57. package/dist/runtime/orchestrator.js +3 -3
  58. package/dist/runtime/orchestrators/step-by-step.d.ts +1 -1
  59. package/dist/runtime/orchestrators/utils.d.ts +1 -1
  60. package/dist/runtime/runtime.d.ts +1 -1
  61. package/dist/runtime/runtime.js +9 -7
  62. package/dist/runtime/scheduler.d.ts +3 -0
  63. package/dist/runtime/scheduler.js +3 -0
  64. package/dist/runtime/scheduler.js.map +1 -0
  65. package/dist/runtime/state.d.ts +1 -1
  66. package/dist/runtime/state.js +1 -1
  67. package/dist/runtime/traverser.d.ts +1 -1
  68. package/dist/runtime/types.d.ts +1 -1
  69. package/dist/runtime/workflow-logic-handler.d.ts +1 -1
  70. package/dist/sanitizer.d.ts +1 -1
  71. package/dist/serializer.d.ts +1 -1
  72. package/dist/testing/event-logger.d.ts +1 -1
  73. package/dist/testing/index.d.ts +1 -1
  74. package/dist/testing/index.js +13 -11
  75. package/dist/testing/run-with-trace.d.ts +1 -1
  76. package/dist/testing/run-with-trace.js +11 -9
  77. package/dist/testing/stepper.d.ts +1 -1
  78. package/dist/testing/stepper.js +3 -3
  79. package/dist/{types-ezHUBdpL.d.ts → types-DWCZW68f.d.ts} +29 -2
  80. package/dist/types.d.ts +1 -1
  81. package/package.json +1 -1
  82. package/dist/chunk-C4HYIJI3.js.map +0 -1
  83. package/dist/chunk-CD3Q4N6V.js.map +0 -1
  84. package/dist/chunk-CD4FUZOJ.js.map +0 -1
  85. package/dist/chunk-HKX7WQLS.js.map +0 -1
  86. package/dist/chunk-ZNL7ZXPR.js.map +0 -1
@@ -1,4 +1,4 @@
1
- export { WaitNode } from '../chunk-CD3Q4N6V.js';
1
+ export { WaitNode } from '../chunk-GVF7GQXQ.js';
2
2
  import '../chunk-LNK7LZER.js';
3
3
  //# sourceMappingURL=wait.js.map
4
4
  //# sourceMappingURL=wait.js.map
@@ -1,4 +1,4 @@
1
- import { v as RuntimeOptions, c as FlowRuntime, A as ISerializer, t as IAsyncContext, J as WorkflowResult, g as WorkflowBlueprint } from '../types-ezHUBdpL.js';
1
+ import { v as RuntimeOptions, c as FlowRuntime, A as ISerializer, x as ILogger, t as IAsyncContext, J as WorkflowResult, g as WorkflowBlueprint } from '../types-DWCZW68f.js';
2
2
  import '../errors.js';
3
3
  import '../container.js';
4
4
 
@@ -35,6 +35,7 @@ declare abstract class BaseDistributedAdapter {
35
35
  protected readonly runtime: FlowRuntime<any, any>;
36
36
  protected readonly store: ICoordinationStore;
37
37
  protected readonly serializer: ISerializer;
38
+ protected readonly logger: ILogger;
38
39
  constructor(options: AdapterOptions);
39
40
  /**
40
41
  * Starts the worker, which begins listening for and processing jobs from the queue.
@@ -1,19 +1,21 @@
1
- export { BaseDistributedAdapter } from '../chunk-ZNL7ZXPR.js';
2
- import '../chunk-HKX7WQLS.js';
1
+ export { BaseDistributedAdapter } from '../chunk-J3HZD5ES.js';
2
+ import '../chunk-CHG6O6JX.js';
3
+ import '../chunk-DL7KVYZF.js';
4
+ import '../chunk-LM4ACVHL.js';
3
5
  import '../chunk-MCGK3FXQ.js';
4
- import '../chunk-MKNZBKSR.js';
6
+ import '../chunk-LJ4COM7S.js';
7
+ import '../chunk-K6LPGUPR.js';
5
8
  import '../chunk-G5BGBPFP.js';
6
- import '../chunk-CD3Q4N6V.js';
7
- import '../chunk-DL7KVYZF.js';
9
+ import '../chunk-GVF7GQXQ.js';
8
10
  import '../chunk-ONH7PIJZ.js';
9
11
  import '../chunk-DSYAC4WB.js';
10
12
  import '../chunk-BC4G7OM6.js';
11
13
  import '../chunk-RM677CNU.js';
12
14
  import '../chunk-233SESC2.js';
13
- import '../chunk-33NO4PUJ.js';
15
+ import '../chunk-NDWVLU7J.js';
14
16
  import '../chunk-HAZ26F3P.js';
15
- import '../chunk-FRKO3WX4.js';
16
- import '../chunk-CD4FUZOJ.js';
17
+ import '../chunk-KXXEA5VE.js';
18
+ import '../chunk-OO3FF3DF.js';
17
19
  import '../chunk-4PELJWF7.js';
18
20
  import '../chunk-CYHZ2YVH.js';
19
21
  import '../chunk-WWGFIYKW.js';
@@ -1,3 +1,3 @@
1
- export { K as ExecutionContext } from '../types-ezHUBdpL.js';
1
+ export { K as ExecutionContext } from '../types-DWCZW68f.js';
2
2
  import '../errors.js';
3
3
  import '../container.js';
@@ -1,5 +1,5 @@
1
- export { ExecutionContext } from '../chunk-FRKO3WX4.js';
2
- import '../chunk-CD4FUZOJ.js';
1
+ export { ExecutionContext } from '../chunk-KXXEA5VE.js';
2
+ import '../chunk-OO3FF3DF.js';
3
3
  import '../chunk-R3HQXIEL.js';
4
4
  import '../chunk-BCRWXTWX.js';
5
5
  //# sourceMappingURL=execution-context.js.map
@@ -1,3 +1,3 @@
1
1
  import '../errors.js';
2
- export { C as ClassNodeExecutor, E as ExecutionStrategy, F as FunctionNodeExecutor, N as NodeExecutionResult, b as NodeExecutor, a as NodeExecutorConfig } from '../types-ezHUBdpL.js';
2
+ export { C as ClassNodeExecutor, E as ExecutionStrategy, F as FunctionNodeExecutor, N as NodeExecutionResult, b as NodeExecutor, a as NodeExecutorConfig } from '../types-DWCZW68f.js';
3
3
  import '../container.js';
@@ -1,5 +1,5 @@
1
1
  export { AdapterOptions, BaseDistributedAdapter, ICoordinationStore, JobPayload } from './adapter.js';
2
- export { C as ClassNodeExecutor, e as ExecutionServices, E as ExecutionStrategy, c as FlowRuntime, F as FunctionNodeExecutor, G as GraphTraverser, I as IOrchestrator, f as IRuntime, N as NodeExecutionResult, b as NodeExecutor, a as NodeExecutorConfig, d as NodeExecutorFactory, R as ReadyNode, W as WorkflowState } from '../types-ezHUBdpL.js';
2
+ export { C as ClassNodeExecutor, e as ExecutionServices, E as ExecutionStrategy, c as FlowRuntime, F as FunctionNodeExecutor, G as GraphTraverser, I as IOrchestrator, f as IRuntime, N as NodeExecutionResult, b as NodeExecutor, a as NodeExecutorConfig, d as NodeExecutorFactory, R as ReadyNode, W as WorkflowState } from '../types-DWCZW68f.js';
3
3
  export { DefaultOrchestrator } from './orchestrator.js';
4
4
  export { executeBatch, processResults } from './orchestrators/utils.js';
5
5
  import '../errors.js';
@@ -1,21 +1,23 @@
1
1
  import '../chunk-NVJ3ZO3P.js';
2
2
  import '../chunk-NVLZFLYM.js';
3
- export { BaseDistributedAdapter } from '../chunk-ZNL7ZXPR.js';
4
- export { FlowRuntime } from '../chunk-HKX7WQLS.js';
3
+ export { BaseDistributedAdapter } from '../chunk-J3HZD5ES.js';
4
+ export { FlowRuntime } from '../chunk-CHG6O6JX.js';
5
+ import '../chunk-DL7KVYZF.js';
6
+ import '../chunk-LM4ACVHL.js';
5
7
  import '../chunk-MCGK3FXQ.js';
6
- import '../chunk-MKNZBKSR.js';
8
+ import '../chunk-LJ4COM7S.js';
9
+ import '../chunk-K6LPGUPR.js';
7
10
  export { GraphTraverser } from '../chunk-G5BGBPFP.js';
8
- import '../chunk-CD3Q4N6V.js';
9
- import '../chunk-DL7KVYZF.js';
11
+ import '../chunk-GVF7GQXQ.js';
10
12
  export { ClassNodeExecutor, FunctionNodeExecutor, NodeExecutor } from '../chunk-ONH7PIJZ.js';
11
13
  import '../chunk-DSYAC4WB.js';
12
14
  import '../chunk-BC4G7OM6.js';
13
15
  import '../chunk-RM677CNU.js';
14
16
  import '../chunk-233SESC2.js';
15
- export { DefaultOrchestrator } from '../chunk-33NO4PUJ.js';
17
+ export { DefaultOrchestrator } from '../chunk-NDWVLU7J.js';
16
18
  export { executeBatch, processResults } from '../chunk-HAZ26F3P.js';
17
- import '../chunk-FRKO3WX4.js';
18
- export { WorkflowState } from '../chunk-CD4FUZOJ.js';
19
+ import '../chunk-KXXEA5VE.js';
20
+ export { WorkflowState } from '../chunk-OO3FF3DF.js';
19
21
  import '../chunk-4PELJWF7.js';
20
22
  import '../chunk-CYHZ2YVH.js';
21
23
  import '../chunk-WWGFIYKW.js';
@@ -1,4 +1,4 @@
1
- import { z as IEventBus, K as ExecutionContext, b as NodeExecutor } from '../types-ezHUBdpL.js';
1
+ import { z as IEventBus, K as ExecutionContext, b as NodeExecutor } from '../types-DWCZW68f.js';
2
2
  import '../errors.js';
3
3
  import '../container.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { I as IOrchestrator, K as ExecutionContext, G as GraphTraverser, J as WorkflowResult } from '../types-ezHUBdpL.js';
1
+ import { I as IOrchestrator, K as ExecutionContext, G as GraphTraverser, J as WorkflowResult } from '../types-DWCZW68f.js';
2
2
  import '../errors.js';
3
3
  import '../container.js';
4
4
 
@@ -1,7 +1,7 @@
1
- export { DefaultOrchestrator } from '../chunk-33NO4PUJ.js';
1
+ export { DefaultOrchestrator } from '../chunk-NDWVLU7J.js';
2
2
  import '../chunk-HAZ26F3P.js';
3
- import '../chunk-FRKO3WX4.js';
4
- import '../chunk-CD4FUZOJ.js';
3
+ import '../chunk-KXXEA5VE.js';
4
+ import '../chunk-OO3FF3DF.js';
5
5
  import '../chunk-R3HQXIEL.js';
6
6
  import '../chunk-BCRWXTWX.js';
7
7
  //# sourceMappingURL=orchestrator.js.map
@@ -1,4 +1,4 @@
1
- import { I as IOrchestrator, K as ExecutionContext, G as GraphTraverser, J as WorkflowResult } from '../../types-ezHUBdpL.js';
1
+ import { I as IOrchestrator, K as ExecutionContext, G as GraphTraverser, J as WorkflowResult } from '../../types-DWCZW68f.js';
2
2
  import '../../errors.js';
3
3
  import '../../container.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { g as WorkflowBlueprint, W as WorkflowState, N as NodeExecutionResult, G as GraphTraverser } from '../../types-ezHUBdpL.js';
1
+ import { g as WorkflowBlueprint, W as WorkflowState, N as NodeExecutionResult, G as GraphTraverser } from '../../types-DWCZW68f.js';
2
2
  import '../../errors.js';
3
3
  import '../../container.js';
4
4
 
@@ -1,3 +1,3 @@
1
1
  import '../container.js';
2
- export { c as FlowRuntime } from '../types-ezHUBdpL.js';
2
+ export { c as FlowRuntime } from '../types-DWCZW68f.js';
3
3
  import '../errors.js';
@@ -1,18 +1,20 @@
1
- export { FlowRuntime } from '../chunk-HKX7WQLS.js';
1
+ export { FlowRuntime } from '../chunk-CHG6O6JX.js';
2
+ import '../chunk-DL7KVYZF.js';
3
+ import '../chunk-LM4ACVHL.js';
2
4
  import '../chunk-MCGK3FXQ.js';
3
- import '../chunk-MKNZBKSR.js';
5
+ import '../chunk-LJ4COM7S.js';
6
+ import '../chunk-K6LPGUPR.js';
4
7
  import '../chunk-G5BGBPFP.js';
5
- import '../chunk-CD3Q4N6V.js';
6
- import '../chunk-DL7KVYZF.js';
8
+ import '../chunk-GVF7GQXQ.js';
7
9
  import '../chunk-ONH7PIJZ.js';
8
10
  import '../chunk-DSYAC4WB.js';
9
11
  import '../chunk-BC4G7OM6.js';
10
12
  import '../chunk-RM677CNU.js';
11
13
  import '../chunk-233SESC2.js';
12
- import '../chunk-33NO4PUJ.js';
14
+ import '../chunk-NDWVLU7J.js';
13
15
  import '../chunk-HAZ26F3P.js';
14
- import '../chunk-FRKO3WX4.js';
15
- import '../chunk-CD4FUZOJ.js';
16
+ import '../chunk-KXXEA5VE.js';
17
+ import '../chunk-OO3FF3DF.js';
16
18
  import '../chunk-4PELJWF7.js';
17
19
  import '../chunk-CYHZ2YVH.js';
18
20
  import '../chunk-WWGFIYKW.js';
@@ -0,0 +1,3 @@
1
+ export { L as AwaitingWorkflow, O as WorkflowScheduler } from '../types-DWCZW68f.js';
2
+ import '../errors.js';
3
+ import '../container.js';
@@ -0,0 +1,3 @@
1
+ export { WorkflowScheduler } from '../chunk-LM4ACVHL.js';
2
+ //# sourceMappingURL=scheduler.js.map
3
+ //# sourceMappingURL=scheduler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"scheduler.js"}
@@ -1,3 +1,3 @@
1
- export { W as WorkflowState } from '../types-ezHUBdpL.js';
1
+ export { W as WorkflowState } from '../types-DWCZW68f.js';
2
2
  import '../errors.js';
3
3
  import '../container.js';
@@ -1,4 +1,4 @@
1
- export { WorkflowState } from '../chunk-CD4FUZOJ.js';
1
+ export { WorkflowState } from '../chunk-OO3FF3DF.js';
2
2
  import '../chunk-R3HQXIEL.js';
3
3
  import '../chunk-BCRWXTWX.js';
4
4
  //# sourceMappingURL=state.js.map
@@ -1,3 +1,3 @@
1
- export { G as GraphTraverser, R as ReadyNode } from '../types-ezHUBdpL.js';
1
+ export { G as GraphTraverser, R as ReadyNode } from '../types-DWCZW68f.js';
2
2
  import '../errors.js';
3
3
  import '../container.js';
@@ -1,3 +1,3 @@
1
- export { e as ExecutionServices, I as IOrchestrator, f as IRuntime, N as NodeExecutionResult, b as NodeExecutor, d as NodeExecutorFactory } from '../types-ezHUBdpL.js';
1
+ export { e as ExecutionServices, I as IOrchestrator, f as IRuntime, N as NodeExecutionResult, b as NodeExecutor, d as NodeExecutorFactory } from '../types-DWCZW68f.js';
2
2
  import '../errors.js';
3
3
  import '../container.js';
@@ -1,4 +1,4 @@
1
- import { w as IEvaluator, z as IEventBus, g as WorkflowBlueprint, l as NodeResult, r as ContextImplementation, h as NodeDefinition, j as EdgeDefinition } from '../types-ezHUBdpL.js';
1
+ import { w as IEvaluator, z as IEventBus, g as WorkflowBlueprint, l as NodeResult, r as ContextImplementation, h as NodeDefinition, j as EdgeDefinition } from '../types-DWCZW68f.js';
2
2
  import '../errors.js';
3
3
  import '../container.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { g as WorkflowBlueprint } from './types-ezHUBdpL.js';
1
+ import { g as WorkflowBlueprint } from './types-DWCZW68f.js';
2
2
  import './errors.js';
3
3
  import './container.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { A as ISerializer } from './types-ezHUBdpL.js';
1
+ import { A as ISerializer } from './types-DWCZW68f.js';
2
2
  import './errors.js';
3
3
  import './container.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { z as IEventBus, y as FlowcraftEvent } from '../types-ezHUBdpL.js';
1
+ import { z as IEventBus, y as FlowcraftEvent } from '../types-DWCZW68f.js';
2
2
  import '../errors.js';
3
3
  import '../container.js';
4
4
 
@@ -1,6 +1,6 @@
1
1
  export { InMemoryEventLogger } from './event-logger.js';
2
2
  export { runWithTrace } from './run-with-trace.js';
3
3
  export { IWorkflowStepper, createStepper } from './stepper.js';
4
- import '../types-ezHUBdpL.js';
4
+ import '../types-DWCZW68f.js';
5
5
  import '../errors.js';
6
6
  import '../container.js';
@@ -1,25 +1,27 @@
1
- export { runWithTrace } from '../chunk-BN4MV36K.js';
2
- export { createStepper } from '../chunk-XNRIM27H.js';
3
- import '../chunk-G53CSLBF.js';
1
+ export { runWithTrace } from '../chunk-VN2JKKAE.js';
4
2
  export { InMemoryEventLogger } from '../chunk-MUYLRTSR.js';
3
+ export { createStepper } from '../chunk-GIJOZ3AN.js';
4
+ import '../chunk-G53CSLBF.js';
5
5
  import '../chunk-NVJ3ZO3P.js';
6
6
  import '../chunk-NVLZFLYM.js';
7
- import '../chunk-ZNL7ZXPR.js';
8
- import '../chunk-HKX7WQLS.js';
7
+ import '../chunk-J3HZD5ES.js';
8
+ import '../chunk-CHG6O6JX.js';
9
+ import '../chunk-DL7KVYZF.js';
10
+ import '../chunk-LM4ACVHL.js';
9
11
  import '../chunk-MCGK3FXQ.js';
10
- import '../chunk-MKNZBKSR.js';
12
+ import '../chunk-LJ4COM7S.js';
13
+ import '../chunk-K6LPGUPR.js';
11
14
  import '../chunk-G5BGBPFP.js';
12
- import '../chunk-CD3Q4N6V.js';
13
- import '../chunk-DL7KVYZF.js';
15
+ import '../chunk-GVF7GQXQ.js';
14
16
  import '../chunk-ONH7PIJZ.js';
15
17
  import '../chunk-DSYAC4WB.js';
16
18
  import '../chunk-BC4G7OM6.js';
17
19
  import '../chunk-RM677CNU.js';
18
20
  import '../chunk-233SESC2.js';
19
- import '../chunk-33NO4PUJ.js';
21
+ import '../chunk-NDWVLU7J.js';
20
22
  import '../chunk-HAZ26F3P.js';
21
- import '../chunk-FRKO3WX4.js';
22
- import '../chunk-CD4FUZOJ.js';
23
+ import '../chunk-KXXEA5VE.js';
24
+ import '../chunk-OO3FF3DF.js';
23
25
  import '../chunk-4PELJWF7.js';
24
26
  import '../chunk-CYHZ2YVH.js';
25
27
  import '../chunk-WWGFIYKW.js';
@@ -1,4 +1,4 @@
1
- import { c as FlowRuntime, g as WorkflowBlueprint, J as WorkflowResult } from '../types-ezHUBdpL.js';
1
+ import { c as FlowRuntime, g as WorkflowBlueprint, J as WorkflowResult } from '../types-DWCZW68f.js';
2
2
  import '../errors.js';
3
3
  import '../container.js';
4
4
 
@@ -1,23 +1,25 @@
1
- export { runWithTrace } from '../chunk-BN4MV36K.js';
1
+ export { runWithTrace } from '../chunk-VN2JKKAE.js';
2
2
  import '../chunk-MUYLRTSR.js';
3
3
  import '../chunk-NVJ3ZO3P.js';
4
4
  import '../chunk-NVLZFLYM.js';
5
- import '../chunk-ZNL7ZXPR.js';
6
- import '../chunk-HKX7WQLS.js';
5
+ import '../chunk-J3HZD5ES.js';
6
+ import '../chunk-CHG6O6JX.js';
7
+ import '../chunk-DL7KVYZF.js';
8
+ import '../chunk-LM4ACVHL.js';
7
9
  import '../chunk-MCGK3FXQ.js';
8
- import '../chunk-MKNZBKSR.js';
10
+ import '../chunk-LJ4COM7S.js';
11
+ import '../chunk-K6LPGUPR.js';
9
12
  import '../chunk-G5BGBPFP.js';
10
- import '../chunk-CD3Q4N6V.js';
11
- import '../chunk-DL7KVYZF.js';
13
+ import '../chunk-GVF7GQXQ.js';
12
14
  import '../chunk-ONH7PIJZ.js';
13
15
  import '../chunk-DSYAC4WB.js';
14
16
  import '../chunk-BC4G7OM6.js';
15
17
  import '../chunk-RM677CNU.js';
16
18
  import '../chunk-233SESC2.js';
17
- import '../chunk-33NO4PUJ.js';
19
+ import '../chunk-NDWVLU7J.js';
18
20
  import '../chunk-HAZ26F3P.js';
19
- import '../chunk-FRKO3WX4.js';
20
- import '../chunk-CD4FUZOJ.js';
21
+ import '../chunk-KXXEA5VE.js';
22
+ import '../chunk-OO3FF3DF.js';
21
23
  import '../chunk-4PELJWF7.js';
22
24
  import '../chunk-CYHZ2YVH.js';
23
25
  import '../chunk-WWGFIYKW.js';
@@ -1,4 +1,4 @@
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';
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-DWCZW68f.js';
2
2
  import '../errors.js';
3
3
  import '../container.js';
4
4
 
@@ -1,10 +1,10 @@
1
- export { createStepper } from '../chunk-XNRIM27H.js';
1
+ export { createStepper } from '../chunk-GIJOZ3AN.js';
2
2
  import '../chunk-G53CSLBF.js';
3
3
  import '../chunk-G5BGBPFP.js';
4
4
  import '../chunk-233SESC2.js';
5
5
  import '../chunk-HAZ26F3P.js';
6
- import '../chunk-FRKO3WX4.js';
7
- import '../chunk-CD4FUZOJ.js';
6
+ import '../chunk-KXXEA5VE.js';
7
+ import '../chunk-OO3FF3DF.js';
8
8
  import '../chunk-R3HQXIEL.js';
9
9
  import '../chunk-BCRWXTWX.js';
10
10
  //# sourceMappingURL=stepper.js.map
@@ -50,6 +50,27 @@ declare abstract class BaseNode<TContext extends Record<string, any> = Record<st
50
50
  recover(_error: Error, _context: NodeContext<TContext, TDependencies, TInput>): Promise<void>;
51
51
  }
52
52
 
53
+ interface AwaitingWorkflow {
54
+ executionId: string;
55
+ blueprintId: string;
56
+ serializedContext: string;
57
+ awaitingNodeId: string;
58
+ wakeUpAt: string;
59
+ }
60
+ declare class WorkflowScheduler {
61
+ private runtime;
62
+ private activeWorkflows;
63
+ private intervalId?;
64
+ private checkIntervalMs;
65
+ constructor(runtime: FlowRuntime<any, any>, checkIntervalMs?: number);
66
+ start(): void;
67
+ stop(): void;
68
+ registerAwaitingWorkflow(executionId: string, blueprintId: string, serializedContext: string, awaitingNodeId: string, wakeUpAt: string): void;
69
+ unregisterWorkflow(executionId: string): void;
70
+ private checkAndResumeWorkflows;
71
+ getActiveWorkflows(): AwaitingWorkflow[];
72
+ }
73
+
53
74
  declare class WorkflowState<TContext extends Record<string, any>> {
54
75
  private _completedNodes;
55
76
  private errors;
@@ -57,6 +78,7 @@ declare class WorkflowState<TContext extends Record<string, any>> {
57
78
  private context;
58
79
  private _isAwaiting;
59
80
  private _awaitingNodeIds;
81
+ private _awaitingDetails;
60
82
  constructor(initialData: Partial<TContext>);
61
83
  addCompletedNode(nodeId: string, output: any): Promise<void>;
62
84
  addError(nodeId: string, error: Error): void;
@@ -66,9 +88,10 @@ declare class WorkflowState<TContext extends Record<string, any>> {
66
88
  getCompletedNodes(): Set<string>;
67
89
  getErrors(): WorkflowError[];
68
90
  getAnyFallbackExecuted(): boolean;
69
- markAsAwaiting(nodeId: string): void;
91
+ markAsAwaiting(nodeId: string, details?: any): void;
70
92
  isAwaiting(): boolean;
71
93
  getAwaitingNodeIds(): string[];
94
+ getAwaitingDetails(nodeId: string): any;
72
95
  clearAwaiting(nodeId?: string): void;
73
96
  getStatus(isTraversalComplete?: boolean): WorkflowResult['status'];
74
97
  toResult(serializer: ISerializer): Promise<WorkflowResult<TContext>>;
@@ -197,6 +220,8 @@ declare class FlowRuntime<TContext extends Record<string, any>, TDependencies ex
197
220
  options: RuntimeOptions<TDependencies>;
198
221
  private readonly logicHandler;
199
222
  private readonly executorFactory;
223
+ scheduler: WorkflowScheduler;
224
+ getBlueprint(id: string): WorkflowBlueprint | undefined;
200
225
  constructor(container: DIContainer, options?: RuntimeOptions<TDependencies>);
201
226
  constructor(options: RuntimeOptions<TDependencies>);
202
227
  private _setupExecutionContext;
@@ -206,6 +231,8 @@ declare class FlowRuntime<TContext extends Record<string, any>, TDependencies ex
206
231
  signal?: AbortSignal;
207
232
  concurrency?: number;
208
233
  }): Promise<WorkflowResult<TContext>>;
234
+ startScheduler(): void;
235
+ stopScheduler(): void;
209
236
  private _setupResumedExecutionContext;
210
237
  resume(blueprint: WorkflowBlueprint, serializedContext: string, resumeData: {
211
238
  output?: any;
@@ -561,4 +588,4 @@ interface UIGraph {
561
588
  }>;
562
589
  }
563
590
 
564
- export { type ISerializer as A, BaseNode as B, ClassNodeExecutor as C, type WorkflowError as D, type ExecutionStrategy as E, FunctionNodeExecutor as F, GraphTraverser as G, type WorkflowStatus as H, type IOrchestrator as I, type WorkflowResult as J, ExecutionContext as K, type Middleware as M, type NodeExecutionResult as N, type ReadyNode as R, type UIGraph as U, WorkflowState as W, type NodeExecutorConfig as a, NodeExecutor as b, FlowRuntime as c, type NodeExecutorFactory as d, type ExecutionServices as e, type IRuntime as f, type WorkflowBlueprint as g, type NodeDefinition as h, isNodeClass as i, type EdgeDefinition as j, type NodeConfig as k, type NodeResult as l, type NodeContext as m, type NodeFunction as n, type NodeClass as o, type NodeImplementation as p, type NodeRegistry as q, type ContextImplementation as r, type ISyncContext as s, type IAsyncContext as t, type RuntimeDependencies as u, type RuntimeOptions as v, type IEvaluator as w, type ILogger as x, type FlowcraftEvent as y, type IEventBus as z };
591
+ export { type ISerializer as A, BaseNode as B, ClassNodeExecutor as C, type WorkflowError as D, type ExecutionStrategy as E, FunctionNodeExecutor as F, GraphTraverser as G, type WorkflowStatus as H, type IOrchestrator as I, type WorkflowResult as J, ExecutionContext as K, type AwaitingWorkflow as L, type Middleware as M, type NodeExecutionResult as N, WorkflowScheduler as O, type ReadyNode as R, type UIGraph as U, WorkflowState as W, type NodeExecutorConfig as a, NodeExecutor as b, FlowRuntime as c, type NodeExecutorFactory as d, type ExecutionServices as e, type IRuntime as f, type WorkflowBlueprint as g, type NodeDefinition as h, isNodeClass as i, type EdgeDefinition as j, type NodeConfig as k, type NodeResult as l, type NodeContext as m, type NodeFunction as n, type NodeClass as o, type NodeImplementation as p, type NodeRegistry as q, type ContextImplementation as r, type ISyncContext as s, type IAsyncContext as t, type RuntimeDependencies as u, type RuntimeOptions as v, type IEvaluator as w, type ILogger as x, type FlowcraftEvent as y, type IEventBus as z };
package/dist/types.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import './errors.js';
2
- export { r as ContextImplementation, j as EdgeDefinition, y as FlowcraftEvent, t as IAsyncContext, w as IEvaluator, z as IEventBus, x as ILogger, A as ISerializer, s as ISyncContext, M as Middleware, o as NodeClass, k as NodeConfig, m as NodeContext, h as NodeDefinition, n as NodeFunction, p as NodeImplementation, q as NodeRegistry, l as NodeResult, u as RuntimeDependencies, v as RuntimeOptions, U as UIGraph, g as WorkflowBlueprint, D as WorkflowError, J as WorkflowResult, H as WorkflowStatus } from './types-ezHUBdpL.js';
2
+ export { r as ContextImplementation, j as EdgeDefinition, y as FlowcraftEvent, t as IAsyncContext, w as IEvaluator, z as IEventBus, x as ILogger, A as ISerializer, s as ISyncContext, M as Middleware, o as NodeClass, k as NodeConfig, m as NodeContext, h as NodeDefinition, n as NodeFunction, p as NodeImplementation, q as NodeRegistry, l as NodeResult, u as RuntimeDependencies, v as RuntimeOptions, U as UIGraph, g as WorkflowBlueprint, D as WorkflowError, J as WorkflowResult, H as WorkflowStatus } from './types-DWCZW68f.js';
3
3
  import './container.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "flowcraft",
3
3
  "type": "module",
4
- "version": "2.3.1",
4
+ "version": "2.4.0",
5
5
  "description": "A lightweight workflow framework",
6
6
  "license": "MIT",
7
7
  "homepage": "https://flowcraft.js.org",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/flow.ts"],"names":[],"mappings":";;;AAMA,IAAI,WAAA,GAAc,CAAA;AAClB,SAAS,cAAc,EAAA,EAAwF;AAC9G,EAAA,MAAM,MAAA,GAAS,GAAG,QAAA,EAAS;AAC3B,EAAA,IAAI,IAAA,GAAO,CAAA;AACX,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,MAAA,CAAO,QAAQ,CAAA,EAAA,EAAK;AACvC,IAAA,MAAM,IAAA,GAAO,MAAA,CAAO,UAAA,CAAW,CAAC,CAAA;AAChC,IAAA,IAAA,GAAA,CAAQ,IAAA,IAAQ,KAAK,IAAA,GAAO,IAAA;AAC5B,IAAA,IAAA,GAAO,IAAA,GAAO,IAAA;AAAA,EACf;AAEA,EAAA,OAAA,CAAQ,KAAK,GAAA,CAAI,IAAI,CAAA,GAAI,WAAA,EAAA,EAAe,SAAS,EAAE,CAAA;AACpD;AAKO,IAAM,OAAN,MAGL;AAAA,EACO,SAAA;AAAA,EACA,gBAAA;AAAA,EACA,i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ueprint } from './types'\n\n/**\n * Generates a deterministic hash for a function based on its source code and a unique counter.\n */\nlet hashCounter = 0\nfunction _hashFunction(fn: NodeFunction<any, any, any, any, any> | NodeClass<any, any, any, any, any>): string {\n\tconst source = fn.toString()\n\tlet hash = 0\n\tfor (let i = 0; i < source.length; i++) {\n\t\tconst char = source.charCodeAt(i)\n\t\thash = (hash << 5) - hash + char\n\t\thash = hash & hash // Convert to 32-bit integer\n\t}\n\t// Add counter to ensure uniqueness even for identical functions\n\treturn (Math.abs(hash) + hashCounter++).toString(16)\n}\n\n/**\n * A fluent API for programmatically constructing a WorkflowBlueprint.\n */\nexport class Flow<\n\tTContext extends Record<string, any> = Record<string, any>,\n\tTDependencies extends Record<string, any> = Record<string, any>,\n> {\n\tprivate blueprint: Partial<WorkflowBlueprint>\n\tprivate functionRegistry: Map<string, NodeFunction | NodeClass>\n\tprivate loopControllerIds: Map<string, string>\n\tprivate loopDefinitions: Array<{\n\t\tid: string\n\t\tstartNodeId: string\n\t\tendNodeId: string\n\t\tcondition: string\n\t}>\n\tprivate batchDefinitions: Array<{\n\t\tid: string\n\t\tscatterId: string\n\t\tgatherId: string\n\t}>\n\tprivate cycleEntryPoints: Map<string, string>\n\n\tconstructor(id: string) {\n\t\tthis.blueprint = { id, nodes: [], edges: [] }\n\t\tthis.functionRegistry = new Map()\n\t\tthis.loopControllerIds = new Map()\n\t\tthis.loopDefinitions = []\n\t\tthis.batchDefinitions = []\n\t\tthis.cycleEntryPoints = new Map()\n\t}\n\n\tnode<TInput = any, TOutput = any, TAction extends string = string>(\n\t\tid: string,\n\t\timplementation:\n\t\t\t| NodeFunction<TContext, TDependencies, TInput, TOutput, TAction>\n\t\t\t| NodeClass<TContext, TDependencies, TInput, TOutput, TAction>,\n\t\toptions?: Omit<NodeDefinition, 'id' | 'uses'>,\n\t): this {\n\t\tlet usesKey: string\n\n\t\tif (isNodeClass(implementation)) {\n\t\t\tusesKey =\n\t\t\t\timplementation.name && implementation.name !== 'BaseNode'\n\t\t\t\t\t? implementation.name\n\t\t\t\t\t: `class_${_hashFunction(implementation)}`\n\t\t\tthis.functionRegistry.set(usesKey, implementation)\n\t\t} else {\n\t\t\tusesKey = `fn_${_hashFunction(implementation)}`\n\t\t\tthis.functionRegistry.set(usesKey, implementation as unknown as NodeFunction)\n\t\t}\n\n\t\tconst nodeDef: NodeDefinition = { id, uses: usesKey, ...options }\n\t\tthis.blueprint.nodes?.push(nodeDef)\n\t\treturn this\n\t}\n\n\tedge(source: string, target: string, options?: Omit<EdgeDefinition, 'source' | 'target'>): this {\n\t\tconst edgeDef: EdgeDefinition = { source, target, ...options }\n\t\tthis.blueprint.edges?.push(edgeDef)\n\t\treturn this\n\t}\n\n\t/**\n\t * Creates a batch processing pattern.\n\t * It takes an input array, runs a worker node on each item in parallel, and gathers the results.\n\t * This method augments the Flow's TContext with a new key for the output array.\n\t *\n\t * @param id The base ID for this batch operation.\n\t * @param worker The node implementation to run on each item.\n\t * @param options Configuration for the batch operation.\n\t * @returns The Flow instance with an updated context type for chaining.\n\t */\n\tbatch<TWorkerInput, TWorkerOutput, TWorkerAction extends string, TOutputKey extends string>(\n\t\tid: string,\n\t\tworker:\n\t\t\t| NodeFunction<TContext, TDependencies, TWorkerInput, TWorkerOutput, TWorkerAction>\n\t\t\t| NodeClass<TContext, TDependencies, TWorkerInput, TWorkerOutput, TWorkerAction>,\n\t\toptions: {\n\t\t\t/** The key in the context that holds the input array for the batch. */\n\t\t\tinputKey: keyof TContext\n\t\t\t/** The key in the context where the array of results will be stored. */\n\t\t\toutputKey: TOutputKey\n\t\t\t/** The number of items to process in each chunk to limit memory usage. */\n\t\t\tchunkSize?: number\n\t\t},\n\t): Flow<TContext & { [K in TOutputKey]: TWorkerOutput[] }, TDependencies> {\n\t\tconst { inputKey, outputKey } = options\n\t\tconst scatterId = `${id}_scatter`\n\t\tconst gatherId = `${id}_gather`\n\n\t\tthis.batchDefinitions.push({ id, scatterId, gatherId })\n\n\t\t// register worker implementation under a unique key.\n\t\tlet workerUsesKey: string\n\t\tif (isNodeClass(worker)) {\n\t\t\tworkerUsesKey =\n\t\t\t\tworker.name && worker.name !== 'BaseNode' ? worker.name : `class_batch_worker_${_hashFunction(worker)}`\n\t\t\tthis.functionRegistry.set(workerUsesKey, worker)\n\t\t} else {\n\t\t\tworkerUsesKey = `fn_batch_worker_${_hashFunction(worker)}`\n\t\t\tthis.functionRegistry.set(workerUsesKey, worker as unknown as NodeFunction)\n\t\t}\n\n\t\t// scatter node: takes an array and dynamically schedules worker nodes\n\t\tthis.blueprint.nodes?.push({\n\t\t\tid: scatterId,\n\t\t\tuses: 'batch-scatter', // built-in\n\t\t\tinputs: inputKey as string,\n\t\t\tparams: { workerUsesKey, outputKey: outputKey as string, gatherNodeId: gatherId, chunkSize: options.chunkSize },\n\t\t})\n\n\t\t// gather node: waits for all workers to finish and collects the results\n\t\tthis.blueprint.nodes?.push({\n\t\t\tid: gatherId,\n\t\t\tuses: 'batch-gather', // built-in\n\t\t\tparams: { outputKey, gatherNodeId: gatherId },\n\t\t\tconfig: { joinStrategy: 'all' }, // important: must wait for all scattered jobs\n\t\t})\n\n\t\t// edge to connect scatter and gather nodes, orchestrator will manage dynamic workers\n\t\tthis.edge(scatterId, gatherId)\n\n\t\treturn this as unknown as Flow<TContext & { [K in TOutputKey]: TWorkerOutput[] }, TDependencies>\n\t}\n\n\t/**\n\t * Creates a wait node that pauses workflow execution for external input.\n\t * @param id A unique identifier for the wait node.\n\t * @param options Optional configuration for the wait node.\n\t */\n\twait(id: string, options?: Omit<NodeDefinition, 'id' | 'uses'>): this {\n\t\tconst nodeDef: NodeDefinition = { id, uses: 'wait', ...options }\n\t\tthis.blueprint.nodes?.push(nodeDef)\n\t\treturn this\n\t}\n\n\t/**\n\t * Creates a loop pattern in the workflow graph.\n\t * @param id A unique identifier for the loop construct.\n\t * @param options Defines the start, end, and continuation condition of the loop.\n\t * @param options.startNodeId The ID of the first node inside the loop body.\n\t * @param options.endNodeId The ID of the last node inside the loop body.\n\t * @param options.condition An expression that, if true, causes the loop to run again.\n\t */\n\tloop(\n\t\tid: string,\n\t\toptions: {\n\t\t\t/** The ID of the first node inside the loop body. */\n\t\t\tstartNodeId: string\n\t\t\t/** The ID of the last node inside the loop body. */\n\t\t\tendNodeId: string\n\t\t\t/** An expression that, if true, causes the loop to run again. */\n\t\t\tcondition: string\n\t\t},\n\t): this {\n\t\tconst { startNodeId, endNodeId, condition } = options\n\t\tconst controllerId = `${id}-loop`\n\n\t\tthis.loopControllerIds.set(id, controllerId)\n\n\t\tthis.loopDefinitions.push({ id, startNodeId, endNodeId, condition })\n\n\t\t// controller node: evaluates the loop condition\n\t\tthis.blueprint.nodes?.push({\n\t\t\tid: controllerId,\n\t\t\tuses: 'loop-controller', // built-in\n\t\t\tparams: { condition },\n\t\t\tconfig: { joinStrategy: 'any' }, // to allow re-execution on each loop iteration\n\t\t})\n\n\t\tthis.edge(endNodeId, controllerId)\n\n\t\tthis.edge(controllerId, startNodeId, {\n\t\t\taction: 'continue',\n\t\t\ttransform: `context.${endNodeId}`, // pass the end node's value to the start node\n\t\t})\n\n\t\treturn this\n\t}\n\n\tgetLoopControllerId(id: string): string {\n\t\tconst controllerId = this.loopControllerIds.get(id)\n\t\tif (!controllerId) {\n\t\t\tthrow new Error(`Loop with id '${id}' not found. Ensure you have defined it using the .loop() method.`)\n\t\t}\n\t\treturn controllerId\n\t}\n\n\t/**\n\t * Sets the preferred entry point for a cycle in non-DAG workflows.\n\t * This helps remove ambiguity when the runtime needs to choose a starting node for cycles.\n\t * @param nodeId The ID of the node to use as the entry point for cycles containing this node.\n\t */\n\tsetCycleEntryPoint(nodeId: string): this {\n\t\tthis.cycleEntryPoints.set(nodeId, nodeId)\n\t\treturn this\n\t}\n\n\ttoBlueprint(): WorkflowBlueprint {\n\t\tif (!this.blueprint.nodes || this.blueprint.nodes.length === 0) {\n\t\t\tthrow new Error('Cannot build a blueprint with no nodes.')\n\t\t}\n\n\t\tconst finalEdges: EdgeDefinition[] = []\n\t\tconst processedOriginalEdges = new Set<EdgeDefinition>()\n\t\tconst allOriginalEdges = this.blueprint.edges || []\n\n\t\t// loop edge re-wiring\n\t\tfor (const loopDef of this.loopDefinitions) {\n\t\t\tconst controllerId = this.getLoopControllerId(loopDef.id)\n\t\t\tconst edgesToRewire = allOriginalEdges.filter((e) => e.source === loopDef.endNodeId && e.target !== controllerId)\n\t\t\tfor (const edge of edgesToRewire) {\n\t\t\t\tfinalEdges.push({ ...edge, source: controllerId, action: edge.action || 'break' })\n\t\t\t\tprocessedOriginalEdges.add(edge)\n\t\t\t}\n\t\t}\n\n\t\t// batch edge re-wiring\n\t\tfor (const batchDef of this.batchDefinitions) {\n\t\t\tconst incomingEdges = allOriginalEdges.filter((e) => e.target === batchDef.id)\n\t\t\tfor (const edge of incomingEdges) {\n\t\t\t\tfinalEdges.push({ ...edge, target: batchDef.scatterId })\n\t\t\t\tprocessedOriginalEdges.add(edge)\n\t\t\t}\n\n\t\t\tconst outgoingEdges = allOriginalEdges.filter((e) => e.source === batchDef.id)\n\t\t\tfor (const edge of outgoingEdges) {\n\t\t\t\tfinalEdges.push({ ...edge, source: batchDef.gatherId })\n\t\t\t\tprocessedOriginalEdges.add(edge)\n\t\t\t}\n\t\t}\n\n\t\t// all remaining edges\n\t\tfor (const edge of allOriginalEdges) {\n\t\t\tif (!processedOriginalEdges.has(edge)) {\n\t\t\t\tfinalEdges.push(edge)\n\t\t\t}\n\t\t}\n\t\tthis.blueprint.edges = finalEdges\n\n\t\tfor (const loopDef of this.loopDefinitions) {\n\t\t\tconst startNode = this.blueprint.nodes?.find((n) => n.id === loopDef.startNodeId)\n\t\t\tconst endNode = this.blueprint.nodes?.find((n) => n.id === loopDef.endNodeId)\n\n\t\t\tif (!startNode) {\n\t\t\t\tthrow new Error(`Loop '${loopDef.id}' references non-existent start node '${loopDef.startNodeId}'.`)\n\t\t\t}\n\t\t\tif (!endNode) {\n\t\t\t\tthrow new Error(`Loop '${loopDef.id}' references non-existent end node '${loopDef.endNodeId}'.`)\n\t\t\t}\n\n\t\t\tstartNode.config = { ...startNode.config, joinStrategy: 'any' }\n\t\t\tendNode.config = { ...endNode.config, joinStrategy: 'any' }\n\t\t}\n\n\t\tif (this.cycleEntryPoints.size > 0) {\n\t\t\tthis.blueprint.metadata = {\n\t\t\t\t...this.blueprint.metadata,\n\t\t\t\tcycleEntryPoints: Array.from(this.cycleEntryPoints.keys()),\n\t\t\t}\n\t\t}\n\n\t\treturn this.blueprint as WorkflowBlueprint\n\t}\n\n\tgetFunctionRegistry() {\n\t\treturn this.functionRegistry\n\t}\n\n\ttoGraphRepresentation(): UIGraph {\n\t\tconst blueprint = this.toBlueprint()\n\t\tconst uiNodes: UIGraph['nodes'] = []\n\t\tconst uiEdges: UIGraph['edges'] = []\n\n\t\tconst ignoredNodeIds = new Set<string>()\n\n\t\t// replace loop-controllers with direct, cyclical edges\n\t\tfor (const loopDef of this.loopDefinitions) {\n\t\t\tconst controllerId = this.loopControllerIds.get(loopDef.id)\n\t\t\tif (!controllerId) continue\n\n\t\t\tignoredNodeIds.add(controllerId)\n\n\t\t\t// direct edge from the end of loop to start\n\t\t\tuiEdges.push({\n\t\t\t\tsource: loopDef.endNodeId,\n\t\t\t\ttarget: loopDef.startNodeId,\n\t\t\t\tdata: {\n\t\t\t\t\tisLoopback: true,\n\t\t\t\t\tcondition: loopDef.condition,\n\t\t\t\t\tlabel: `continue if: ${loopDef.condition}`,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\t// re-wire any 'break' edges\n\t\t\tconst breakEdges = blueprint.edges.filter((edge) => edge.source === controllerId && edge.action === 'break')\n\t\t\tfor (const breakEdge of breakEdges) {\n\t\t\t\tuiEdges.push({\n\t\t\t\t\t...breakEdge,\n\t\t\t\t\tsource: loopDef.endNodeId,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// replace scatter/gather pairs with a single representative \"worker\" node\n\t\tconst scatterNodes = blueprint.nodes.filter((n) => n.uses === 'batch-scatter')\n\t\tfor (const scatterNode of scatterNodes) {\n\t\t\tconst gatherNodeId = scatterNode.params?.gatherNodeId\n\t\t\tif (!gatherNodeId) continue\n\n\t\t\tignoredNodeIds.add(scatterNode.id)\n\t\t\tignoredNodeIds.add(gatherNodeId)\n\n\t\t\t// single node to represent parallel work\n\t\t\tconst batchId = scatterNode.id.replace('_scatter', '')\n\t\t\tconst gatherNode = blueprint.nodes.find((n) => n.id === gatherNodeId)\n\n\t\t\tuiNodes.push({\n\t\t\t\tid: batchId,\n\t\t\t\tuses: scatterNode.params?.workerUsesKey,\n\t\t\t\ttype: 'batch-worker',\n\t\t\t\tdata: {\n\t\t\t\t\tlabel: `Batch: ${batchId}`,\n\t\t\t\t\tisBatchPlaceholder: true,\n\t\t\t\t\tworkerUsesKey: scatterNode.params?.workerUsesKey,\n\t\t\t\t\tinputKey: scatterNode.inputs,\n\t\t\t\t\toutputKey: gatherNode?.params?.outputKey,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\t// re-wire incoming edges\n\t\t\tconst incomingEdges = blueprint.edges.filter((e) => e.target === scatterNode.id)\n\t\t\tfor (const edge of incomingEdges) {\n\t\t\t\tuiEdges.push({ ...edge, target: batchId })\n\t\t\t}\n\n\t\t\t// re-wire outgoing edges\n\t\t\tconst outgoingEdges = blueprint.edges.filter((e) => e.source === gatherNodeId)\n\t\t\tfor (const edge of outgoingEdges) {\n\t\t\t\tuiEdges.push({ ...edge, source: batchId })\n\t\t\t}\n\t\t}\n\n\t\tfor (const node of blueprint.nodes) {\n\t\t\tif (!ignoredNodeIds.has(node.id)) {\n\t\t\t\tuiNodes.push(node)\n\t\t\t}\n\t\t}\n\n\t\tfor (const edge of blueprint.edges) {\n\t\t\tif (!ignoredNodeIds.has(edge.source) && !ignoredNodeIds.has(edge.target)) {\n\t\t\t\tconst alreadyAdded = uiEdges.some(\n\t\t\t\t\t(e) => e.source === edge.source && e.target === edge.target && e.action === edge.action,\n\t\t\t\t)\n\t\t\t\tif (!alreadyAdded) {\n\t\t\t\t\tuiEdges.push(edge)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { nodes: uiNodes, edges: uiEdges }\n\t}\n}\n\n/**\n * Helper function to create a new Flow builder instance.\n */\nexport function createFlow<\n\tTContext extends Record<string, any> = Record<string, any>,\n\tTDependencies extends Record<string, any> = Record<string, any>,\n>(id: string): Flow<TContext, TDependencies> {\n\treturn new Flow(id)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/nodes/wait.ts"],"names":[],"mappings":";;;AAGO,IAAM,QAAA,GAAN,cAAuB,QAAA,CAAS;AAAA,EACtC,MAAM,IAAA,CACL,WAAA,EACA,OAAA,EACqC;AACrC,IAAA,OAAA,CAAQ,YAAA,CAAa,aAAA,CAAc,cAAA,CAAe,IAAA,CAAK,UAAU,EAAE,CAAA;AACnE,IAAA,OAAO,EAAE,QAAQ,MAAA,EAAU;AAAA,EAC5B;AACD","file":"chunk-CD3Q4N6V.js","sourcesContent":["import { BaseNode } from '../node'\nimport type { NodeContext, NodeResult } from '../types'\n\nexport class WaitNode 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\tcontext.dependencies.workflowState.markAsAwaiting(this.nodeId ?? '')\n\t\treturn { output: undefined }\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/runtime/state.ts"],"names":[],"mappings":";;;;AAIO,IAAM,gBAAN,MAA0D;AAAA,EACxD,eAAA,uBAAsB,GAAA,EAAY;AAAA,EAClC,SAA0B,EAAC;AAAA,EAC3B,mBAAA,GAAsB,KAAA;AAAA,EACtB,OAAA;AAAA,EACA,WAAA,GAAc,KAAA;AAAA,EACd,gBAAA,uBAAuB,GAAA,EAAY;AAAA,EAE3C,YAAY,WAAA,EAAgC;AAC3C,IAAA,IAAA,CAAK,UAAU,IAAI,gBAAA,CAAiB,IAAI,OAAA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A,GAAS,CAAA,GAAI,KAAK,MAAA,GAAS;AAAA,KAChD;AAAA,EACD;AACD","file":"chunk-CD4FUZOJ.js","sourcesContent":["import { AsyncContextView, Context as SyncContext } from '../context'\nimport { FlowcraftError } from '../errors'\nimport type { IAsyncContext, ISerializer, WorkflowError, WorkflowResult } from '../types'\n\nexport class WorkflowState<TContext extends Record<string, any>> {\n\tprivate _completedNodes = new Set<string>()\n\tprivate errors: WorkflowError[] = []\n\tprivate anyFallbackExecuted = false\n\tprivate context: IAsyncContext<TContext>\n\tprivate _isAwaiting = false\n\tprivate _awaitingNodeIds = new Set<string>()\n\n\tconstructor(initialData: Partial<TContext>) {\n\t\tthis.context = new AsyncContextView(new SyncContext<TContext>(initialData))\n\t\tif ((initialData as any)._awaitingNodeIds) {\n\t\t\tthis._isAwaiting = true\n\t\t\tconst awaitingIds = (initialData as any)._awaitingNodeIds\n\t\t\tif (Array.isArray(awaitingIds)) {\n\t\t\t\tfor (const id of awaitingIds) {\n\t\t\t\t\tthis._awaitingNodeIds.add(id)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const key of Object.keys(initialData)) {\n\t\t\tif (key.startsWith('_outputs.')) {\n\t\t\t\tconst nodeId = key.substring('_outputs.'.length)\n\t\t\t\tthis._completedNodes.add(nodeId)\n\t\t\t}\n\t\t}\n\t}\n\n\tasync addCompletedNode(nodeId: string, output: any) {\n\t\tthis._completedNodes.add(nodeId)\n\t\tawait this.context.set(`_outputs.${nodeId}` as any, output)\n\t}\n\n\taddError(nodeId: string, error: Error) {\n\t\tconst flowcraftError = new FlowcraftError(error.message, {\n\t\t\tcause: error,\n\t\t\tnodeId,\n\t\t\tisFatal: false,\n\t\t})\n\t\tthis.errors.push({\n\t\t\t...flowcraftError,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\toriginalError: error, // Legacy compatibility\n\t\t})\n\t}\n\n\tclearError(nodeId: string) {\n\t\tthis.errors = this.errors.filter((err) => err.nodeId !== nodeId)\n\t}\n\n\tmarkFallbackExecuted() {\n\t\tthis.anyFallbackExecuted = true\n\t}\n\n\tgetContext(): IAsyncContext<TContext> {\n\t\treturn this.context\n\t}\n\n\tgetCompletedNodes(): Set<string> {\n\t\treturn new Set(this._completedNodes)\n\t}\n\n\tgetErrors(): WorkflowError[] {\n\t\treturn this.errors\n\t}\n\n\tgetAnyFallbackExecuted(): boolean {\n\t\treturn this.anyFallbackExecuted\n\t}\n\n\tmarkAsAwaiting(nodeId: string): void {\n\t\tthis._isAwaiting = true\n\t\tthis._awaitingNodeIds.add(nodeId)\n\t\tconst awaitingArray = Array.from(this._awaitingNodeIds)\n\t\tthis.context.set('_awaitingNodeIds' as any, awaitingArray)\n\t}\n\n\tisAwaiting(): boolean {\n\t\treturn this._isAwaiting && this._awaitingNodeIds.size > 0\n\t}\n\n\tgetAwaitingNodeIds(): string[] {\n\t\treturn Array.from(this._awaitingNodeIds)\n\t}\n\n\tclearAwaiting(nodeId?: string): void {\n\t\tif (nodeId) {\n\t\t\tthis._awaitingNodeIds.delete(nodeId)\n\t\t} else {\n\t\t\tthis._awaitingNodeIds.clear()\n\t\t}\n\t\tthis._isAwaiting = this._awaitingNodeIds.size > 0\n\t\tconst awaitingArray = Array.from(this._awaitingNodeIds)\n\t\tif (awaitingArray.length > 0) {\n\t\t\tthis.context.set('_awaitingNodeIds' as any, awaitingArray)\n\t\t} else {\n\t\t\tthis.context.delete('_awaitingNodeIds' as any)\n\t\t}\n\t}\n\n\tgetStatus(isTraversalComplete = false): WorkflowResult['status'] {\n\t\tif (this._isAwaiting) return 'awaiting'\n\t\tif (this.anyFallbackExecuted) return 'completed'\n\t\tif (this.errors.length > 0) return 'failed'\n\t\tif (isTraversalComplete) return 'completed'\n\t\treturn 'stalled'\n\t}\n\n\tasync toResult(serializer: ISerializer): Promise<WorkflowResult<TContext>> {\n\t\tconst contextJSON = (await this.context.toJSON()) as TContext\n\t\tif (!this._isAwaiting && (contextJSON as any)._awaitingNodeIds) {\n\t\t\tdelete (contextJSON as any)._awaitingNodeIds\n\t\t}\n\t\treturn {\n\t\t\tcontext: contextJSON,\n\t\t\tserializedContext: serializer.serialize(contextJSON),\n\t\t\tstatus: this.getStatus(),\n\t\t\terrors: this.errors.length > 0 ? this.errors : undefined,\n\t\t}\n\t}\n}\n"]}