flowcraft 2.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 (86) hide show
  1. package/README.md +1 -1
  2. package/dist/analysis.d.ts +1 -1
  3. package/dist/analysis.js +1 -1
  4. package/dist/{chunk-VFC342WL.js → chunk-4PELJWF7.js} +6 -6
  5. package/dist/chunk-4PELJWF7.js.map +1 -0
  6. package/dist/chunk-5EHIPX23.js +202 -0
  7. package/dist/chunk-5EHIPX23.js.map +1 -0
  8. package/dist/{chunk-DSZSR7UE.js → chunk-5QMPFUKA.js} +2 -2
  9. package/dist/chunk-5QMPFUKA.js.map +1 -0
  10. package/dist/{chunk-6DNEDIIT.js → chunk-5ZWYSKMH.js} +47 -23
  11. package/dist/chunk-5ZWYSKMH.js.map +1 -0
  12. package/dist/{chunk-WXT3YEWU.js → chunk-5ZXV3R5D.js} +2 -2
  13. package/dist/chunk-5ZXV3R5D.js.map +1 -0
  14. package/dist/{chunk-RYTIQZIB.js → chunk-CO5BTPKI.js} +160 -53
  15. package/dist/chunk-CO5BTPKI.js.map +1 -0
  16. package/dist/{chunk-UYPIWXZG.js → chunk-CSZ6EOWG.js} +9 -10
  17. package/dist/chunk-CSZ6EOWG.js.map +1 -0
  18. package/dist/chunk-CYHZ2YVH.js +24 -0
  19. package/dist/chunk-CYHZ2YVH.js.map +1 -0
  20. package/dist/{chunk-J3RNCPED.js → chunk-DSYAC4WB.js} +2 -2
  21. package/dist/chunk-DSYAC4WB.js.map +1 -0
  22. package/dist/{chunk-M23P46ZL.js → chunk-HN72TZY5.js} +10 -5
  23. package/dist/chunk-HN72TZY5.js.map +1 -0
  24. package/dist/{chunk-MICPMOTW.js → chunk-KWQHFT7E.js} +2 -2
  25. package/dist/chunk-KWQHFT7E.js.map +1 -0
  26. package/dist/chunk-PH2IYZHV.js +48 -0
  27. package/dist/chunk-PH2IYZHV.js.map +1 -0
  28. package/dist/{chunk-734J4PTM.js → chunk-QRMUKDSP.js} +56 -15
  29. package/dist/chunk-QRMUKDSP.js.map +1 -0
  30. package/dist/{chunk-RAZXOMZC.js → chunk-UETC63DP.js} +7 -6
  31. package/dist/chunk-UETC63DP.js.map +1 -0
  32. package/dist/{chunk-RW4FH7IL.js → chunk-UMXW3TCY.js} +60 -30
  33. package/dist/chunk-UMXW3TCY.js.map +1 -0
  34. package/dist/context.d.ts +5 -5
  35. package/dist/context.js +1 -1
  36. package/dist/errors.js +1 -1
  37. package/dist/evaluator.d.ts +21 -13
  38. package/dist/evaluator.js +1 -1
  39. package/dist/flow.d.ts +4 -3
  40. package/dist/flow.js +2 -2
  41. package/dist/index.d.ts +2 -1
  42. package/dist/index.js +15 -15
  43. package/dist/linter.d.ts +1 -1
  44. package/dist/linter.js +2 -2
  45. package/dist/logger.d.ts +5 -5
  46. package/dist/logger.js +1 -1
  47. package/dist/node.d.ts +1 -1
  48. package/dist/node.js +1 -1
  49. package/dist/runtime/adapter.d.ts +20 -4
  50. package/dist/runtime/adapter.js +13 -13
  51. package/dist/runtime/executors.d.ts +7 -7
  52. package/dist/runtime/executors.js +2 -2
  53. package/dist/runtime/index.d.ts +1 -1
  54. package/dist/runtime/index.js +13 -13
  55. package/dist/runtime/runtime.d.ts +7 -6
  56. package/dist/runtime/runtime.js +12 -12
  57. package/dist/runtime/state.d.ts +2 -2
  58. package/dist/runtime/state.js +2 -2
  59. package/dist/runtime/traverser.d.ts +4 -3
  60. package/dist/runtime/traverser.js +3 -3
  61. package/dist/runtime/types.d.ts +1 -1
  62. package/dist/sanitizer.d.ts +1 -1
  63. package/dist/sanitizer.js +1 -1
  64. package/dist/serializer.d.ts +2 -1
  65. package/dist/serializer.js +1 -1
  66. package/dist/{types-CZN_FcB6.d.ts → types-lG3xCzp_.d.ts} +27 -22
  67. package/dist/types.d.ts +1 -1
  68. package/package.json +2 -2
  69. package/dist/chunk-6DNEDIIT.js.map +0 -1
  70. package/dist/chunk-734J4PTM.js.map +0 -1
  71. package/dist/chunk-DSZSR7UE.js.map +0 -1
  72. package/dist/chunk-GTZC6PQI.js +0 -22
  73. package/dist/chunk-GTZC6PQI.js.map +0 -1
  74. package/dist/chunk-J3RNCPED.js.map +0 -1
  75. package/dist/chunk-M23P46ZL.js.map +0 -1
  76. package/dist/chunk-MICPMOTW.js.map +0 -1
  77. package/dist/chunk-NPAJNLXQ.js +0 -106
  78. package/dist/chunk-NPAJNLXQ.js.map +0 -1
  79. package/dist/chunk-RAZXOMZC.js.map +0 -1
  80. package/dist/chunk-REH55ZXV.js +0 -13
  81. package/dist/chunk-REH55ZXV.js.map +0 -1
  82. package/dist/chunk-RW4FH7IL.js.map +0 -1
  83. package/dist/chunk-RYTIQZIB.js.map +0 -1
  84. package/dist/chunk-UYPIWXZG.js.map +0 -1
  85. package/dist/chunk-VFC342WL.js.map +0 -1
  86. package/dist/chunk-WXT3YEWU.js.map +0 -1
package/dist/linter.js CHANGED
@@ -1,4 +1,4 @@
1
- export { lintBlueprint } from './chunk-RAZXOMZC.js';
2
- import './chunk-M23P46ZL.js';
1
+ export { lintBlueprint } from './chunk-UETC63DP.js';
2
+ import './chunk-HN72TZY5.js';
3
3
  //# sourceMappingURL=linter.js.map
4
4
  //# sourceMappingURL=linter.js.map
package/dist/logger.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { l as ILogger } from './types-CZN_FcB6.js';
1
+ import { l as ILogger } from './types-lG3xCzp_.js';
2
2
 
3
3
  /** A logger implementation that outputs to the console. */
4
4
  declare class ConsoleLogger implements ILogger {
@@ -9,10 +9,10 @@ declare class ConsoleLogger implements ILogger {
9
9
  }
10
10
  /** A logger implementation that does nothing (no-op). */
11
11
  declare class NullLogger implements ILogger {
12
- debug(): void;
13
- info(): void;
14
- warn(): void;
15
- error(): void;
12
+ debug(_message: string, _meta?: Record<string, any>): void;
13
+ info(_message: string, _meta?: Record<string, any>): void;
14
+ warn(_message: string, _meta?: Record<string, any>): void;
15
+ error(_message: string, _meta?: Record<string, any>): void;
16
16
  }
17
17
 
18
18
  export { ConsoleLogger, NullLogger };
package/dist/logger.js CHANGED
@@ -1,3 +1,3 @@
1
- export { ConsoleLogger, NullLogger } from './chunk-VFC342WL.js';
1
+ export { ConsoleLogger, NullLogger } from './chunk-4PELJWF7.js';
2
2
  //# sourceMappingURL=logger.js.map
3
3
  //# sourceMappingURL=logger.js.map
package/dist/node.d.ts CHANGED
@@ -1 +1 @@
1
- export { B as BaseNode, i as isNodeClass } from './types-CZN_FcB6.js';
1
+ export { B as BaseNode, i as isNodeClass } from './types-lG3xCzp_.js';
package/dist/node.js CHANGED
@@ -1,3 +1,3 @@
1
- export { BaseNode, isNodeClass } from './chunk-DSZSR7UE.js';
1
+ export { BaseNode, isNodeClass } from './chunk-5QMPFUKA.js';
2
2
  //# sourceMappingURL=node.js.map
3
3
  //# sourceMappingURL=node.js.map
@@ -1,7 +1,7 @@
1
- import { j as RuntimeOptions, n as ISerializer, h as IAsyncContext, p as WorkflowResult } from '../types-CZN_FcB6.js';
1
+ import { j as RuntimeOptions, n as ISerializer, h as IAsyncContext, p as WorkflowResult, W as WorkflowBlueprint } from '../types-lG3xCzp_.js';
2
2
  import { FlowRuntime } from './runtime.js';
3
- import './types.js';
4
3
  import './state.js';
4
+ import './types.js';
5
5
 
6
6
  /**
7
7
  * Defines the contract for an atomic, distributed key-value store required by
@@ -65,14 +65,30 @@ declare abstract class BaseDistributedAdapter {
65
65
  payload?: WorkflowResult;
66
66
  reason?: string;
67
67
  }): Promise<void>;
68
+ /**
69
+ * Hook called at the start of job processing. Subclasses can override this
70
+ * to perform additional setup (e.g., timestamp tracking for reconciliation).
71
+ */
72
+ protected onJobStart(_runId: string, _blueprintId: string, _nodeId: string): Promise<void>;
68
73
  /**
69
74
  * The main handler for processing a single job from the queue.
70
75
  */
71
- private handleJob;
76
+ protected handleJob(job: JobPayload): Promise<void>;
72
77
  /**
73
78
  * Encapsulates the fan-in join logic using the coordination store.
74
79
  */
75
- private isReadyForFanIn;
80
+ protected isReadyForFanIn(runId: string, blueprint: WorkflowBlueprint, targetNodeId: string): Promise<boolean>;
81
+ /**
82
+ * Reconciles the state of a workflow run. It inspects the persisted
83
+ * context to find completed nodes, determines the next set of executable
84
+ * nodes (the frontier), and enqueues jobs for them if they aren't
85
+ * already running. This is the core of the resume functionality.
86
+ *
87
+ * @param runId The unique ID of the workflow execution to reconcile.
88
+ * @returns The set of node IDs that were enqueued for execution.
89
+ */
90
+ reconcile(runId: string): Promise<Set<string>>;
91
+ private calculateResumedFrontier;
76
92
  }
77
93
 
78
94
  export { type AdapterOptions, BaseDistributedAdapter, type ICoordinationStore, type JobPayload };
@@ -1,15 +1,15 @@
1
- export { BaseDistributedAdapter } from '../chunk-NPAJNLXQ.js';
2
- import '../chunk-RYTIQZIB.js';
3
- import '../chunk-UYPIWXZG.js';
4
- import '../chunk-RW4FH7IL.js';
5
- import '../chunk-J3RNCPED.js';
6
- import '../chunk-REH55ZXV.js';
7
- import '../chunk-734J4PTM.js';
8
- import '../chunk-MICPMOTW.js';
9
- import '../chunk-WXT3YEWU.js';
10
- import '../chunk-GTZC6PQI.js';
11
- import '../chunk-DSZSR7UE.js';
12
- import '../chunk-M23P46ZL.js';
13
- import '../chunk-VFC342WL.js';
1
+ export { BaseDistributedAdapter } from '../chunk-5EHIPX23.js';
2
+ import '../chunk-CO5BTPKI.js';
3
+ import '../chunk-CSZ6EOWG.js';
4
+ import '../chunk-UMXW3TCY.js';
5
+ import '../chunk-DSYAC4WB.js';
6
+ import '../chunk-CYHZ2YVH.js';
7
+ import '../chunk-QRMUKDSP.js';
8
+ import '../chunk-KWQHFT7E.js';
9
+ import '../chunk-5ZXV3R5D.js';
10
+ import '../chunk-PH2IYZHV.js';
11
+ import '../chunk-5QMPFUKA.js';
12
+ import '../chunk-HN72TZY5.js';
13
+ import '../chunk-4PELJWF7.js';
14
14
  //# sourceMappingURL=adapter.js.map
15
15
  //# sourceMappingURL=adapter.js.map
@@ -1,26 +1,26 @@
1
- import { N as NodeDefinition, c as NodeContext, b as NodeResult, d as NodeFunction, m as IEventBus, B as BaseNode, C as ContextImplementation } from '../types-CZN_FcB6.js';
1
+ import { N as NodeDefinition, c as NodeContext, b as NodeResult, d as NodeFunction, m as IEventBus, e as NodeClass, C as ContextImplementation } from '../types-lG3xCzp_.js';
2
2
 
3
3
  interface ExecutionStrategy {
4
- execute: (nodeDef: NodeDefinition, context: NodeContext<any, any>, executionId?: string, signal?: AbortSignal) => Promise<NodeResult>;
4
+ execute: (nodeDef: NodeDefinition, context: NodeContext<any, any, any>, executionId?: string, signal?: AbortSignal) => Promise<NodeResult<any, any>>;
5
5
  }
6
6
  declare class FunctionNodeExecutor implements ExecutionStrategy {
7
7
  private implementation;
8
8
  private maxRetries;
9
9
  private eventBus;
10
10
  constructor(implementation: NodeFunction, maxRetries: number, eventBus: IEventBus);
11
- execute(nodeDef: NodeDefinition, context: NodeContext<any, any>, executionId?: string, signal?: AbortSignal): Promise<NodeResult>;
11
+ execute(nodeDef: NodeDefinition, context: NodeContext<any, any, any>, executionId?: string, signal?: AbortSignal): Promise<NodeResult<any, any>>;
12
12
  }
13
13
  declare class ClassNodeExecutor implements ExecutionStrategy {
14
14
  private implementation;
15
15
  private maxRetries;
16
16
  private eventBus;
17
- constructor(implementation: typeof BaseNode, maxRetries: number, eventBus: IEventBus);
18
- execute(nodeDef: NodeDefinition, context: NodeContext<any, any>, executionId?: string, signal?: AbortSignal): Promise<NodeResult>;
17
+ constructor(implementation: NodeClass, maxRetries: number, eventBus: IEventBus);
18
+ execute(nodeDef: NodeDefinition, context: NodeContext<any, any, any>, executionId?: string, signal?: AbortSignal): Promise<NodeResult<any, any>>;
19
19
  }
20
20
  declare class BuiltInNodeExecutor implements ExecutionStrategy {
21
21
  private executeBuiltIn;
22
- constructor(executeBuiltIn: (nodeDef: NodeDefinition, context: ContextImplementation<any>) => Promise<NodeResult>);
23
- execute(nodeDef: NodeDefinition, context: NodeContext<any, any>): Promise<NodeResult>;
22
+ constructor(executeBuiltIn: (nodeDef: NodeDefinition, context: ContextImplementation<any>) => Promise<NodeResult<any, any>>);
23
+ execute(nodeDef: NodeDefinition, context: NodeContext<Record<string, unknown>, Record<string, unknown>, any>): Promise<NodeResult<any, any>>;
24
24
  }
25
25
 
26
26
  export { BuiltInNodeExecutor, ClassNodeExecutor, type ExecutionStrategy, FunctionNodeExecutor };
@@ -1,4 +1,4 @@
1
- export { BuiltInNodeExecutor, ClassNodeExecutor, FunctionNodeExecutor } from '../chunk-734J4PTM.js';
2
- import '../chunk-WXT3YEWU.js';
1
+ export { BuiltInNodeExecutor, ClassNodeExecutor, FunctionNodeExecutor } from '../chunk-QRMUKDSP.js';
2
+ import '../chunk-5ZXV3R5D.js';
3
3
  //# sourceMappingURL=executors.js.map
4
4
  //# sourceMappingURL=executors.js.map
@@ -3,5 +3,5 @@ export { BuiltInNodeExecutor, ClassNodeExecutor, ExecutionStrategy, FunctionNode
3
3
  export { FlowRuntime } from './runtime.js';
4
4
  export { WorkflowState } from './state.js';
5
5
  export { GraphTraverser } from './traverser.js';
6
- import '../types-CZN_FcB6.js';
6
+ import '../types-lG3xCzp_.js';
7
7
  import './types.js';
@@ -1,16 +1,16 @@
1
1
  import '../chunk-HMR2GEGE.js';
2
- export { BaseDistributedAdapter } from '../chunk-NPAJNLXQ.js';
3
- export { FlowRuntime } from '../chunk-RYTIQZIB.js';
4
- export { WorkflowState } from '../chunk-UYPIWXZG.js';
5
- export { GraphTraverser } from '../chunk-RW4FH7IL.js';
6
- import '../chunk-J3RNCPED.js';
7
- import '../chunk-REH55ZXV.js';
8
- export { BuiltInNodeExecutor, ClassNodeExecutor, FunctionNodeExecutor } from '../chunk-734J4PTM.js';
9
- import '../chunk-MICPMOTW.js';
10
- import '../chunk-WXT3YEWU.js';
11
- import '../chunk-GTZC6PQI.js';
12
- import '../chunk-DSZSR7UE.js';
13
- import '../chunk-M23P46ZL.js';
14
- import '../chunk-VFC342WL.js';
2
+ export { BaseDistributedAdapter } from '../chunk-5EHIPX23.js';
3
+ export { FlowRuntime } from '../chunk-CO5BTPKI.js';
4
+ export { WorkflowState } from '../chunk-CSZ6EOWG.js';
5
+ export { GraphTraverser } from '../chunk-UMXW3TCY.js';
6
+ import '../chunk-DSYAC4WB.js';
7
+ import '../chunk-CYHZ2YVH.js';
8
+ export { BuiltInNodeExecutor, ClassNodeExecutor, FunctionNodeExecutor } from '../chunk-QRMUKDSP.js';
9
+ import '../chunk-KWQHFT7E.js';
10
+ import '../chunk-5ZXV3R5D.js';
11
+ import '../chunk-PH2IYZHV.js';
12
+ import '../chunk-5QMPFUKA.js';
13
+ import '../chunk-HN72TZY5.js';
14
+ import '../chunk-4PELJWF7.js';
15
15
  //# sourceMappingURL=index.js.map
16
16
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
- import { j as RuntimeOptions, W as WorkflowBlueprint, p as WorkflowResult, b as NodeResult, C as ContextImplementation, N as NodeDefinition, E as EdgeDefinition } from '../types-CZN_FcB6.js';
2
- import { IRuntime } from './types.js';
1
+ import { j as RuntimeOptions, W as WorkflowBlueprint, p as WorkflowResult, b as NodeResult, C as ContextImplementation, N as NodeDefinition, E as EdgeDefinition } from '../types-lG3xCzp_.js';
3
2
  import { WorkflowState } from './state.js';
3
+ import { IRuntime } from './types.js';
4
4
 
5
5
  declare class FlowRuntime<TContext extends Record<string, any>, TDependencies extends Record<string, any>> implements IRuntime<TContext, TDependencies> {
6
6
  private registry;
@@ -17,17 +17,18 @@ declare class FlowRuntime<TContext extends Record<string, any>, TDependencies ex
17
17
  functionRegistry?: Map<string, any>;
18
18
  strict?: boolean;
19
19
  signal?: AbortSignal;
20
+ concurrency?: number;
20
21
  }): Promise<WorkflowResult<TContext>>;
21
- executeNode(blueprint: WorkflowBlueprint, nodeId: string, state: WorkflowState<TContext>, allPredecessors?: Map<string, Set<string>>, functionRegistry?: Map<string, any>, executionId?: string, signal?: AbortSignal): Promise<NodeResult>;
22
+ executeNode(blueprint: WorkflowBlueprint, nodeId: string, state: WorkflowState<TContext>, allPredecessors?: Map<string, Set<string>>, functionRegistry?: Map<string, any>, executionId?: string, signal?: AbortSignal): Promise<NodeResult<any, any>>;
22
23
  private getExecutor;
23
24
  private executeWithFallback;
24
- determineNextNodes(blueprint: WorkflowBlueprint, nodeId: string, result: NodeResult, context: ContextImplementation<TContext>): Promise<{
25
+ determineNextNodes(blueprint: WorkflowBlueprint, nodeId: string, result: NodeResult<any, any>, context: ContextImplementation<TContext>): Promise<{
25
26
  node: NodeDefinition;
26
27
  edge: EdgeDefinition;
27
28
  }[]>;
28
- applyEdgeTransform(edge: EdgeDefinition, sourceResult: NodeResult, targetNode: NodeDefinition, context: ContextImplementation<TContext>, allPredecessors?: Map<string, Set<string>>): Promise<void>;
29
+ applyEdgeTransform(edge: EdgeDefinition, sourceResult: NodeResult<any, any>, targetNode: NodeDefinition, context: ContextImplementation<TContext>, allPredecessors?: Map<string, Set<string>>): Promise<void>;
29
30
  private _resolveNodeInput;
30
- protected _executeBuiltInNode(nodeDef: NodeDefinition, contextImpl: ContextImplementation<TContext>): Promise<NodeResult>;
31
+ protected _executeBuiltInNode(nodeDef: NodeDefinition, contextImpl: ContextImplementation<TContext>): Promise<NodeResult<any, any>>;
31
32
  }
32
33
 
33
34
  export { FlowRuntime };
@@ -1,14 +1,14 @@
1
- export { FlowRuntime } from '../chunk-RYTIQZIB.js';
2
- import '../chunk-UYPIWXZG.js';
3
- import '../chunk-RW4FH7IL.js';
4
- import '../chunk-J3RNCPED.js';
5
- import '../chunk-REH55ZXV.js';
6
- import '../chunk-734J4PTM.js';
7
- import '../chunk-MICPMOTW.js';
8
- import '../chunk-WXT3YEWU.js';
9
- import '../chunk-GTZC6PQI.js';
10
- import '../chunk-DSZSR7UE.js';
11
- import '../chunk-M23P46ZL.js';
12
- import '../chunk-VFC342WL.js';
1
+ export { FlowRuntime } from '../chunk-CO5BTPKI.js';
2
+ import '../chunk-CSZ6EOWG.js';
3
+ import '../chunk-UMXW3TCY.js';
4
+ import '../chunk-DSYAC4WB.js';
5
+ import '../chunk-CYHZ2YVH.js';
6
+ import '../chunk-QRMUKDSP.js';
7
+ import '../chunk-KWQHFT7E.js';
8
+ import '../chunk-5ZXV3R5D.js';
9
+ import '../chunk-PH2IYZHV.js';
10
+ import '../chunk-5QMPFUKA.js';
11
+ import '../chunk-HN72TZY5.js';
12
+ import '../chunk-4PELJWF7.js';
13
13
  //# sourceMappingURL=runtime.js.map
14
14
  //# sourceMappingURL=runtime.js.map
@@ -1,4 +1,4 @@
1
- import { C as ContextImplementation, o as WorkflowError, p as WorkflowResult, n as ISerializer } from '../types-CZN_FcB6.js';
1
+ import { C as ContextImplementation, o as WorkflowError, p as WorkflowResult, n as ISerializer } from '../types-lG3xCzp_.js';
2
2
 
3
3
  declare class WorkflowState<TContext extends Record<string, any>> {
4
4
  private _completedNodes;
@@ -14,7 +14,7 @@ declare class WorkflowState<TContext extends Record<string, any>> {
14
14
  getCompletedNodes(): Set<string>;
15
15
  getErrors(): WorkflowError[];
16
16
  getAnyFallbackExecuted(): boolean;
17
- getStatus(allNodeIds: Set<string>, fallbackNodeIds: Set<string>): WorkflowResult['status'];
17
+ getStatus(allNodeIds: Set<string>, _fallbackNodeIds: Set<string>): WorkflowResult['status'];
18
18
  toResult(serializer: ISerializer): WorkflowResult<TContext>;
19
19
  }
20
20
 
@@ -1,4 +1,4 @@
1
- export { WorkflowState } from '../chunk-UYPIWXZG.js';
2
- import '../chunk-MICPMOTW.js';
1
+ export { WorkflowState } from '../chunk-CSZ6EOWG.js';
2
+ import '../chunk-KWQHFT7E.js';
3
3
  //# sourceMappingURL=state.js.map
4
4
  //# sourceMappingURL=state.js.map
@@ -1,20 +1,21 @@
1
- import { W as WorkflowBlueprint } from '../types-CZN_FcB6.js';
1
+ import { W as WorkflowBlueprint } from '../types-lG3xCzp_.js';
2
2
  import { WorkflowState } from './state.js';
3
3
  import { IRuntime } from './types.js';
4
4
 
5
5
  declare class GraphTraverser<TContext extends Record<string, any>, TDependencies extends Record<string, any>> {
6
- private blueprint;
7
6
  private runtime;
8
7
  private state;
9
8
  private functionRegistry;
10
9
  private executionId;
11
10
  private signal?;
11
+ private concurrency?;
12
12
  private frontier;
13
13
  private allPredecessors;
14
14
  private dynamicBlueprint;
15
- constructor(blueprint: WorkflowBlueprint, runtime: IRuntime<TContext, TDependencies>, state: WorkflowState<TContext>, functionRegistry: Map<string, any> | undefined, executionId: string, signal?: AbortSignal | undefined);
15
+ constructor(blueprint: WorkflowBlueprint, runtime: IRuntime<TContext, TDependencies>, state: WorkflowState<TContext>, functionRegistry: Map<string, any> | undefined, executionId: string, signal?: AbortSignal | undefined, concurrency?: number | undefined);
16
16
  private isFallbackNode;
17
17
  traverse(): Promise<void>;
18
+ private executeWithConcurrency;
18
19
  private handleDynamicNodes;
19
20
  getAllNodeIds(): Set<string>;
20
21
  getFallbackNodeIds(): Set<string>;
@@ -1,5 +1,5 @@
1
- export { GraphTraverser } from '../chunk-RW4FH7IL.js';
2
- import '../chunk-WXT3YEWU.js';
3
- import '../chunk-M23P46ZL.js';
1
+ export { GraphTraverser } from '../chunk-UMXW3TCY.js';
2
+ import '../chunk-5ZXV3R5D.js';
3
+ import '../chunk-HN72TZY5.js';
4
4
  //# sourceMappingURL=traverser.js.map
5
5
  //# sourceMappingURL=traverser.js.map
@@ -1,4 +1,4 @@
1
- import { R as RuntimeDependencies, j as RuntimeOptions, W as WorkflowBlueprint, b as NodeResult, C as ContextImplementation, N as NodeDefinition, E as EdgeDefinition } from '../types-CZN_FcB6.js';
1
+ import { R as RuntimeDependencies, j as RuntimeOptions, W as WorkflowBlueprint, b as NodeResult, C as ContextImplementation, N as NodeDefinition, E as EdgeDefinition } from '../types-lG3xCzp_.js';
2
2
  import { WorkflowState } from './state.js';
3
3
 
4
4
  /** Interface for the core runtime operations used by the traverser. */
@@ -1,4 +1,4 @@
1
- import { W as WorkflowBlueprint } from './types-CZN_FcB6.js';
1
+ import { W as WorkflowBlueprint } from './types-lG3xCzp_.js';
2
2
 
3
3
  /**
4
4
  * Sanitizes a raw workflow blueprint by removing extra properties
package/dist/sanitizer.js CHANGED
@@ -1,3 +1,3 @@
1
- export { sanitizeBlueprint } from './chunk-J3RNCPED.js';
1
+ export { sanitizeBlueprint } from './chunk-DSYAC4WB.js';
2
2
  //# sourceMappingURL=sanitizer.js.map
3
3
  //# sourceMappingURL=sanitizer.js.map
@@ -1,4 +1,4 @@
1
- import { n as ISerializer } from './types-CZN_FcB6.js';
1
+ import { n as ISerializer } from './types-lG3xCzp_.js';
2
2
 
3
3
  /**
4
4
  * A default serializer using standard JSON.
@@ -8,6 +8,7 @@ import { n as ISerializer } from './types-CZN_FcB6.js';
8
8
  * serializer like `superjson` if working with complex data types.
9
9
  */
10
10
  declare class JsonSerializer implements ISerializer {
11
+ private hasWarned;
11
12
  serialize(data: Record<string, any>): string;
12
13
  deserialize(text: string): Record<string, any>;
13
14
  }
@@ -1,3 +1,3 @@
1
- export { JsonSerializer } from './chunk-REH55ZXV.js';
1
+ export { JsonSerializer } from './chunk-CYHZ2YVH.js';
2
2
  //# sourceMappingURL=serializer.js.map
3
3
  //# sourceMappingURL=serializer.js.map
@@ -1,5 +1,3 @@
1
- /** eslint-disable unused-imports/no-unused-vars */
2
-
3
1
  /** A type guard to reliably distinguish a NodeClass from a NodeFunction. */
4
2
  declare function isNodeClass(impl: any): impl is NodeClass;
5
3
  /**
@@ -7,36 +5,36 @@ declare function isNodeClass(impl: any): impl is NodeClass;
7
5
  * This class is generic, allowing implementations to specify the exact context
8
6
  * and dependency types they expect.
9
7
  */
10
- declare abstract class BaseNode<TContext extends Record<string, any> = Record<string, any>, TDependencies extends RuntimeDependencies = RuntimeDependencies> {
11
- protected params: Record<string, any>;
8
+ declare abstract class BaseNode<TContext extends Record<string, any> = Record<string, any>, TDependencies extends RuntimeDependencies = RuntimeDependencies, TInput = any, TOutput = any, TAction extends string = string> {
9
+ protected params?: Record<string, any> | undefined;
12
10
  /**
13
11
  * @param params Static parameters for this node instance, passed from the blueprint.
14
12
  */
15
- constructor(params: Record<string, any>);
13
+ constructor(params?: Record<string, any> | undefined);
16
14
  /**
17
15
  * Phase 1: Gathers and prepares data for execution. This phase is NOT retried on failure.
18
16
  * @param context The node's execution context.
19
17
  * @returns The data needed for the `exec` phase.
20
18
  */
21
- prep(context: NodeContext<TContext, TDependencies>): Promise<any>;
19
+ prep(context: NodeContext<TContext, TDependencies, TInput>): Promise<any>;
22
20
  /**
23
21
  * Phase 2: Performs the core, isolated logic. This is the ONLY phase that is retried.
24
22
  * @param prepResult The data returned from the `prep` phase.
25
23
  * @param context The node's execution context.
26
24
  */
27
- abstract exec(prepResult: any, context: NodeContext<TContext, TDependencies>): Promise<Omit<NodeResult, 'error'>>;
25
+ abstract exec(prepResult: any, context: NodeContext<TContext, TDependencies, TInput>): Promise<Omit<NodeResult<TOutput, TAction>, 'error'>>;
28
26
  /**
29
27
  * Phase 3: Processes the result and saves state. This phase is NOT retried.
30
28
  * @param execResult The successful result from the `exec` or `fallback` phase.
31
29
  * @param _context The node's execution context.
32
30
  */
33
- post(execResult: Omit<NodeResult, 'error'>, _context: NodeContext<TContext, TDependencies>): Promise<NodeResult>;
31
+ post(execResult: Omit<NodeResult<TOutput, TAction>, 'error'>, _context: NodeContext<TContext, TDependencies, TInput>): Promise<NodeResult<TOutput, TAction>>;
34
32
  /**
35
33
  * An optional safety net that runs if all `exec` retries fail.
36
34
  * @param error The final error from the last `exec` attempt.
37
35
  * @param _context The node's execution context.
38
36
  */
39
- fallback(error: Error, _context: NodeContext<TContext, TDependencies>): Promise<Omit<NodeResult, 'error'>>;
37
+ fallback(error: Error, _context: NodeContext<TContext, TDependencies, TInput>): Promise<Omit<NodeResult<TOutput, TAction>, 'error'>>;
40
38
  }
41
39
 
42
40
  /** The central, serializable representation of a workflow. */
@@ -80,9 +78,9 @@ interface NodeConfig {
80
78
  joinStrategy?: 'all' | 'any';
81
79
  }
82
80
  /** The required return type for any node implementation. */
83
- interface NodeResult<TOutput = any> {
81
+ interface NodeResult<TOutput = any, TAction extends string = string> {
84
82
  output?: TOutput;
85
- action?: string;
83
+ action?: TAction;
86
84
  error?: {
87
85
  message: string;
88
86
  [key: string]: any;
@@ -93,11 +91,11 @@ interface NodeResult<TOutput = any> {
93
91
  _fallbackExecuted?: boolean;
94
92
  }
95
93
  /** The context object passed to every node's execution logic. */
96
- interface NodeContext<TContext extends Record<string, any> = Record<string, any>, TDependencies extends RuntimeDependencies = RuntimeDependencies> {
94
+ interface NodeContext<TContext extends Record<string, any> = Record<string, any>, TDependencies extends RuntimeDependencies = RuntimeDependencies, TInput = any> {
97
95
  /** The async-only interface for interacting with the workflow's state. */
98
96
  context: IAsyncContext<TContext>;
99
97
  /** The primary input data for this node, typically from its predecessor. */
100
- input?: any;
98
+ input?: TInput;
101
99
  /** Static parameters defined in the blueprint. */
102
100
  params: Record<string, any>;
103
101
  /** Shared, runtime-level dependencies (e.g., database clients, loggers). */
@@ -106,9 +104,9 @@ interface NodeContext<TContext extends Record<string, any> = Record<string, any>
106
104
  signal?: AbortSignal;
107
105
  }
108
106
  /** A simple function-based node implementation. */
109
- type NodeFunction<TContext extends Record<string, any> = Record<string, any>, TDependencies extends RuntimeDependencies = RuntimeDependencies> = (context: NodeContext<TContext, TDependencies>) => Promise<NodeResult>;
107
+ type NodeFunction<TContext extends Record<string, any> = Record<string, any>, TDependencies extends RuntimeDependencies = RuntimeDependencies, TInput = any, TOutput = any, TAction extends string = string> = (context: NodeContext<TContext, TDependencies, TInput>) => Promise<NodeResult<TOutput, TAction>>;
110
108
  /** Represents a constructor for any concrete class that extends the abstract BaseNode. */
111
- type NodeClass = new (params?: any) => BaseNode<any, any>;
109
+ type NodeClass<TContext extends Record<string, any> = Record<string, any>, TDependencies extends RuntimeDependencies = RuntimeDependencies, TInput = any, TOutput = any, TAction extends string = string> = new (params?: Record<string, any>) => BaseNode<TContext, TDependencies, TInput, TOutput, TAction>;
112
110
  /** A union of all possible node implementation types. */
113
111
  type NodeImplementation = NodeFunction | NodeClass;
114
112
  /** A registry mapping node types to their implementations. */
@@ -120,8 +118,8 @@ interface ISyncContext<TContext extends Record<string, any> = Record<string, any
120
118
  readonly type: 'sync';
121
119
  get: <K extends keyof TContext>(key: K) => TContext[K] | undefined;
122
120
  set: <K extends keyof TContext>(key: K, value: TContext[K]) => void;
123
- has: (key: keyof TContext) => boolean;
124
- delete: (key: keyof TContext) => boolean;
121
+ has: <K extends keyof TContext>(key: K) => boolean;
122
+ delete: <K extends keyof TContext>(key: K) => boolean;
125
123
  toJSON: () => Record<string, any>;
126
124
  }
127
125
  /** The asynchronous context interface for remote or distributed state. */
@@ -129,8 +127,8 @@ interface IAsyncContext<TContext extends Record<string, any> = Record<string, an
129
127
  readonly type: 'async';
130
128
  get: <K extends keyof TContext>(key: K) => Promise<TContext[K] | undefined>;
131
129
  set: <K extends keyof TContext>(key: K, value: TContext[K]) => Promise<void>;
132
- has: (key: keyof TContext) => Promise<boolean>;
133
- delete: (key: keyof TContext) => Promise<boolean>;
130
+ has: <K extends keyof TContext>(key: K) => Promise<boolean>;
131
+ delete: <K extends keyof TContext>(key: K) => Promise<boolean>;
134
132
  toJSON: () => Promise<Record<string, any>>;
135
133
  }
136
134
  /** Generic for any set of dependencies. */
@@ -140,7 +138,7 @@ interface RuntimeDependencies {
140
138
  /** Configuration options for the FlowRuntime. */
141
139
  interface RuntimeOptions<TDependencies extends RuntimeDependencies = RuntimeDependencies> {
142
140
  /** A registry of globally available node implementations. */
143
- registry?: Record<string, NodeFunction | NodeClass>;
141
+ registry?: Record<string, NodeFunction | NodeClass | typeof BaseNode>;
144
142
  /** A registry of all available workflow blueprints for subflow execution. */
145
143
  blueprints?: Record<string, WorkflowBlueprint>;
146
144
  /** Shared dependencies to be injected into every node. */
@@ -149,7 +147,12 @@ interface RuntimeOptions<TDependencies extends RuntimeDependencies = RuntimeDepe
149
147
  logger?: ILogger;
150
148
  /** A pluggable event bus for observability. */
151
149
  eventBus?: IEventBus;
152
- /** A pluggable evaluator for edge conditions and transforms. */
150
+ /**
151
+ * A pluggable evaluator for edge conditions and transforms.
152
+ * @default new PropertyEvaluator() - A safe evaluator for simple property access.
153
+ * For complex logic, provide a custom implementation or use the `UnsafeEvaluator`
154
+ * (not recommended for production).
155
+ */
153
156
  evaluator?: IEvaluator;
154
157
  /** An array of middleware to wrap node execution. */
155
158
  middleware?: Middleware[];
@@ -189,9 +192,11 @@ interface WorkflowError {
189
192
  nodeId: string;
190
193
  message: string;
191
194
  originalError?: any;
195
+ timestamp: string;
196
+ stack?: string;
192
197
  }
193
198
  /** The final result of a workflow execution. */
194
- interface WorkflowResult<TContext = any> {
199
+ interface WorkflowResult<TContext = Record<string, any>> {
195
200
  context: TContext;
196
201
  serializedContext: string;
197
202
  status: 'completed' | 'failed' | 'stalled' | 'cancelled';
package/dist/types.d.ts CHANGED
@@ -1 +1 @@
1
- export { C as ContextImplementation, E as EdgeDefinition, h as IAsyncContext, k as IEvaluator, m as IEventBus, l as ILogger, n as ISerializer, I as ISyncContext, M as Middleware, e as NodeClass, a as NodeConfig, c as NodeContext, N as NodeDefinition, d as NodeFunction, f as NodeImplementation, g as NodeRegistry, b as NodeResult, R as RuntimeDependencies, j as RuntimeOptions, W as WorkflowBlueprint, o as WorkflowError, p as WorkflowResult } from './types-CZN_FcB6.js';
1
+ export { C as ContextImplementation, E as EdgeDefinition, h as IAsyncContext, k as IEvaluator, m as IEventBus, l as ILogger, n as ISerializer, I as ISyncContext, M as Middleware, e as NodeClass, a as NodeConfig, c as NodeContext, N as NodeDefinition, d as NodeFunction, f as NodeImplementation, g as NodeRegistry, b as NodeResult, R as RuntimeDependencies, j as RuntimeOptions, W as WorkflowBlueprint, o as WorkflowError, p as WorkflowResult } from './types-lG3xCzp_.js';
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "flowcraft",
3
3
  "type": "module",
4
- "version": "2.0.0",
4
+ "version": "2.1.0",
5
5
  "description": "A lightweight workflow framework",
6
6
  "license": "MIT",
7
- "homepage": "https://github.com/gorango/flowcraft",
7
+ "homepage": "https://flowcraft.js.org",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/gorango/flowcraft.git"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/flow.ts"],"names":[],"mappings":";;;AAMO,IAAM,OAAN,MAGL;AAAA,EACO,SAAA;AAAA,EACA,gBAAA;AAAA,EACA,iBAAA;AAAA,EAER,YAAY,EAAA,EAAY;AACvB,IAAA,IAAA,CAAK,SAAA,GAAY,EAAE,EAAA,EAAI,KAAA,EAAO,EAAC,EAAG,KAAA,EAAO,EAAC,EAAE;AAC5C,IAAA,IAAA,CAAK,gBAAA,uBAAuB,GAAA,EAAI;AAChC,IAAA,IAAA,CAAK,iBAAA,uBAAwB,GAAA,EAAI;AAAA,EAClC;AAAA,EAEA,IAAA,CACC,EAAA,EACA,cAAA,EACA,OAAA,EACO;AACP,IAAA,IAAI,OAAA;AAEJ,IAAA,IAAI,WAAA,CAAY,cAAc,CAAA,EAAG;AAChC,MAAA,OAAA,GAAW,cAAA,CAAe,IAAA,IAAQ,cAAA,CAAe,IAAA,KAAS,UAAA,GACvD,cAAA,CAAe,IAAA,GACf,CAAA,MAAA,EAAS,UAAA,CAAW,MAAA,CAAO,UAAA,EAAY,CAAA,CAAA;AAC1C,MAAA,IAAA,CAAK,gBAAA,CAAiB,GAAA,CAAI,OAAA,EAAS,cAAc,CAAA;AAAA,IAClD,CAAA,MACK;AACJ,MAAA,OAAA,GAAU,CAAA,GAAA,EAAM,UAAA,CAAW,MAAA,CAAO,UAAA,EAAY,CAAA,CAAA;AAC9C,MAAA,IAAA,CAAK,gBAAA,CAAiB,GAAA,CAAI,OAAA,EAAS,cAA8B,CAAA;AAAA,IAClE;AAEA,IAAA,MAAM,UAA0B,EAAE,EAAA,EAAI,IAAA,EAAM,OAAA,EAAS,GAAG,OAAA,EAAQ;AAChE,IAAA,IAAA,CAAK,SAAA,CAAU,KAAA,CAAO,IAAA,CAAK,OAAO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ass } from './node'\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\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}\n\n\tnode(\n\t\tid: string,\n\t\timplementation: NodeFunction<TContext, TDependencies> | NodeClass,\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 = (implementation.name && implementation.name !== 'BaseNode')\n\t\t\t\t? implementation.name\n\t\t\t\t: `class_${globalThis.crypto.randomUUID()}`\n\t\t\tthis.functionRegistry.set(usesKey, implementation)\n\t\t}\n\t\telse {\n\t\t\tusesKey = `fn_${globalThis.crypto.randomUUID()}`\n\t\t\tthis.functionRegistry.set(usesKey, implementation 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 * @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 * @param options.inputKey The key in the context that holds the input array for the batch.\n\t * @param options.outputKey The key in the context where the array of results will be stored.\n\t * @returns The Flow instance for chaining.\n\t */\n\tbatch(id: string, worker: NodeFunction<TContext, TDependencies> | NodeClass, options: {\n\t\t/** The key in the context that holds the input array for the batch. */\n\t\tinputKey: string\n\t\t/** The key in the context where the array of results will be stored. */\n\t\toutputKey: string\n\t}): this {\n\t\tconst { inputKey, outputKey } = options\n\t\tconst scatterId = `${id}_scatter`\n\t\tconst gatherId = `${id}_gather`\n\n\t\t// Register the user's worker implementation under a unique key.\n\t\tlet workerUsesKey: string\n\t\tif (isNodeClass(worker)) {\n\t\t\tworkerUsesKey = (worker.name && worker.name !== 'BaseNode') ? worker.name : `class_batch_worker_${globalThis.crypto.randomUUID()}`\n\t\t\tthis.functionRegistry.set(workerUsesKey, worker)\n\t\t}\n\t\telse {\n\t\t\tworkerUsesKey = `fn_batch_worker_${globalThis.crypto.randomUUID()}`\n\t\t\tthis.functionRegistry.set(workerUsesKey, worker as NodeFunction)\n\t\t}\n\n\t\t// Scatter Node: A built-in node that 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', // This is a special, built-in node type\n\t\t\tinputs: inputKey,\n\t\t\tparams: { workerUsesKey, outputKey, gatherNodeId: gatherId },\n\t\t})\n\n\t\t// Gather Node: A built-in node that 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 node type\n\t\t\tparams: { outputKey },\n\t\t\tconfig: { joinStrategy: 'all' }, // Important: Must wait for all scattered jobs\n\t\t})\n\n\t\t// Edge to connect the scatter and gather nodes. The orchestrator will manage the dynamic workers.\n\t\tthis.edge(scatterId, gatherId)\n\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(id: string, options: {\n\t\t/** The ID of the first node inside the loop body. */\n\t\tstartNodeId: string\n\t\t/** The ID of the last node inside the loop body. */\n\t\tendNodeId: string\n\t\t/** An expression that, if true, causes the loop to run again. */\n\t\tcondition: string\n\t}): this {\n\t\tconst { startNodeId, endNodeId, condition } = options\n\t\tconst controllerId = `${id}-loop`\n\n\t\t// Store the generated ID against the user-provided loop ID\n\t\tthis.loopControllerIds.set(id, controllerId)\n\n\t\t// Add the controller node, which evaluates the loop condition.\n\t\t// Set joinStrategy='any' to allow re-execution on each loop iteration\n\t\tthis.blueprint.nodes!.push({\n\t\t\tid: controllerId,\n\t\t\tuses: 'loop-controller', // Special built-in node type\n\t\t\tparams: { condition },\n\t\t\tconfig: { joinStrategy: 'any' },\n\t\t})\n\n\t\t// Connect the end of the loop body to the controller.\n\t\tthis.edge(endNodeId, controllerId)\n\n\t\t// Connect the controller back to the start of the loop if the condition is met.\n\t\t// Use a transform to pass the end node's value to the start node for the next iteration.\n\t\tthis.edge(controllerId, startNodeId, { action: 'continue', transform: `context.${endNodeId}` })\n\n\t\t// Set the start and end nodes to use 'any' join strategy so they can re-execute\n\t\t// Start node: executes when either its initial predecessor OR the loop controller completes\n\t\t// End node: needs to re-execute on each loop iteration\n\t\tconst startNode = this.blueprint.nodes!.find(n => n.id === startNodeId)\n\t\tif (startNode)\n\t\t\tstartNode.config = { ...startNode.config, joinStrategy: 'any' }\n\n\t\tconst endNode = this.blueprint.nodes!.find(n => n.id === endNodeId)\n\t\tif (endNode)\n\t\t\tendNode.config = { ...endNode.config, joinStrategy: 'any' }\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\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\t\treturn this.blueprint as WorkflowBlueprint\n\t}\n\n\tgetFunctionRegistry() {\n\t\treturn this.functionRegistry\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/runtime/executors.ts"],"names":[],"mappings":";;;AAaO,IAAM,uBAAN,MAAwD;AAAA,EAC9D,WAAA,CACS,cAAA,EACA,UAAA,EACA,QAAA,EACP;AAHO,IAAA,IAAA,CAAA,cAAA,GAAA,cAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AAAA,EACL;AAAA,EAEJ,MAAM,OAAA,CACL,OAAA,EACA,OAAA,EACA,aACA,MAAA,EACsB;AACtB,IAAA,IAAI,SAAA;AACJ,IAAA,KAAA,IAAS,OAAA,GAAU,CAAA,EAAG,OAAA,IAAW,IAAA,CAAK,YAAY,OAAA,EAAA,EAAW;AAC5D,MAAA,IAAI;AACH,QAAA,MAAA,EAAQ,cAAA,EAAe;AACvB,QAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,cAAA,CAAe,OAAO,CAAA;AAChD,QAAA,IAAI,UAAU,CAAA,EAAG;AAChB,UAAA,OAAA,CAAQ,YAAA,CAAa,MAAA,CAAO,IAAA,CAAK,CAAA,oCAAA,CAAA,EAAwC,EAAE,QAAQ,OAAA,CAAQ,EAAA,EAAI,OAAA,EAAS,WAAA,EAAa,CAAA;AAAA,QACtH;AACA,QAAA,OAAO,MAAA;AAAA,MACR,SACO,KAAA,EAAO;AACb,QAAA,SAAA,GAAY,KAAA;AACZ,QAAA,IAAI,KAAA,YAAiB,YAAA,IAAgB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AAA,EACsB;AACtB,IAAA,OAAO,IAAA,CAAK,cAAA,CAAe,OAAA,EAAS,OAAA,CAAQ,OAAqC,CAAA;AAAA,EAClF;AACD","file":"chunk-734J4PTM.js","sourcesContent":["import type { BaseNode } from '../node'\nimport type { ContextImplementation, IEventBus, NodeContext, NodeDefinition, NodeFunction, NodeResult } from '../types'\nimport { CancelledWorkflowError, FatalNodeExecutionError } from '../errors'\n\nexport interface ExecutionStrategy {\n\texecute: (\n\t\tnodeDef: NodeDefinition,\n\t\tcontext: NodeContext<any, any>,\n\t\texecutionId?: string,\n\t\tsignal?: AbortSignal,\n\t) => Promise<NodeResult>\n}\n\nexport class FunctionNodeExecutor implements ExecutionStrategy {\n\tconstructor(\n\t\tprivate implementation: NodeFunction,\n\t\tprivate maxRetries: number,\n\t\tprivate eventBus: IEventBus,\n\t) { }\n\n\tasync execute(\n\t\tnodeDef: NodeDefinition,\n\t\tcontext: NodeContext<any, any>,\n\t\texecutionId?: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<NodeResult> {\n\t\tlet lastError: any\n\t\tfor (let attempt = 1; attempt <= this.maxRetries; attempt++) {\n\t\t\ttry {\n\t\t\t\tsignal?.throwIfAborted()\n\t\t\t\tconst result = await this.implementation(context)\n\t\t\t\tif (attempt > 1) {\n\t\t\t\t\tcontext.dependencies.logger.info(`Node execution succeeded after retry`, { nodeId: nodeDef.id, attempt, executionId })\n\t\t\t\t}\n\t\t\t\treturn result\n\t\t\t}\n\t\t\tcatch (error) {\n\t\t\t\tlastError = error\n\t\t\t\tif (error instanceof DOMException && error.name === 'AbortError') {\n\t\t\t\t\tthrow new CancelledWorkflowError('Workflow cancelled')\n\t\t\t\t}\n\t\t\t\tif (error instanceof FatalNodeExecutionError)\n\t\t\t\t\tbreak\n\t\t\t\tif (attempt < this.maxRetries) {\n\t\t\t\t\tcontext.dependencies.logger.warn(`Node execution failed, retrying`, { nodeId: nodeDef.id, attempt, maxRetries: this.maxRetries, error: error instanceof Error ? error.message : String(error), executionId })\n\t\t\t\t\tawait this.eventBus.emit('node:retry', { blueprintId: context.dependencies.blueprint?.id || '', nodeId: nodeDef.id, attempt, executionId })\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tcontext.dependencies.logger.error(`Node execution failed after all retries`, { nodeId: nodeDef.id, attempts: this.maxRetries, error: error instanceof Error ? error.message : String(error), executionId })\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow lastError\n\t}\n}\n\nexport class ClassNodeExecutor implements ExecutionStrategy {\n\tconstructor(\n\t\tprivate implementation: typeof BaseNode,\n\t\tprivate maxRetries: number,\n\t\tprivate eventBus: IEventBus,\n\t) { }\n\n\tasync execute(\n\t\tnodeDef: NodeDefinition,\n\t\tcontext: NodeContext<any, any>,\n\t\texecutionId?: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<NodeResult> {\n\t\tconst instance = new (this.implementation as new (params: Record<string, any>) => BaseNode)(nodeDef.params || {})\n\t\ttry {\n\t\t\tsignal?.throwIfAborted()\n\t\t\tconst prepResult = await instance.prep(context)\n\t\t\tlet execResult: Omit<NodeResult, 'error'>\n\t\t\tlet lastError: any\n\t\t\tfor (let attempt = 1; attempt <= this.maxRetries; attempt++) {\n\t\t\t\ttry {\n\t\t\t\t\tsignal?.throwIfAborted()\n\t\t\t\t\texecResult = await instance.exec(prepResult, context)\n\t\t\t\t\tlastError = undefined\n\t\t\t\t\tif (attempt > 1) {\n\t\t\t\t\t\tcontext.dependencies.logger.info(`Node execution succeeded after retry`, { nodeId: nodeDef.id, attempt, executionId })\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcatch (error) {\n\t\t\t\t\tlastError = error\n\t\t\t\t\tif (error instanceof DOMException && error.name === 'AbortError') {\n\t\t\t\t\t\tthrow new CancelledWorkflowError('Workflow cancelled')\n\t\t\t\t\t}\n\t\t\t\t\tif (error instanceof FatalNodeExecutionError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tif (attempt < this.maxRetries) {\n\t\t\t\t\t\tcontext.dependencies.logger.warn(`Node execution failed, retrying`, { nodeId: nodeDef.id, attempt, maxRetries: this.maxRetries, error: error instanceof Error ? error.message : String(error), executionId })\n\t\t\t\t\t\tawait this.eventBus.emit('node:retry', { blueprintId: context.dependencies.blueprint?.id || '', nodeId: nodeDef.id, attempt, executionId })\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tcontext.dependencies.logger.error(`Node execution failed after all retries`, { nodeId: nodeDef.id, attempts: this.maxRetries, error: error instanceof Error ? error.message : String(error), executionId })\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (lastError) {\n\t\t\t\tsignal?.throwIfAborted()\n\t\t\t\texecResult = await instance.fallback(lastError, context)\n\t\t\t}\n\t\t\tsignal?.throwIfAborted()\n\t\t\treturn await instance.post(execResult!, context)\n\t\t}\n\t\tcatch (error) {\n\t\t\tif (error instanceof DOMException && error.name === 'AbortError') {\n\t\t\t\tthrow new CancelledWorkflowError('Workflow cancelled')\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n}\n\nexport class BuiltInNodeExecutor implements ExecutionStrategy {\n\tconstructor(\n\t\tprivate executeBuiltIn: (nodeDef: NodeDefinition, context: ContextImplementation<any>) => Promise<NodeResult>,\n\t) { }\n\n\tasync execute(\n\t\tnodeDef: NodeDefinition,\n\t\tcontext: NodeContext<any, any>,\n\t): Promise<NodeResult> {\n\t\treturn this.executeBuiltIn(nodeDef, context.context as ContextImplementation<any>)\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/node.ts"],"names":[],"mappings":";AAKO,SAAS,YAAY,IAAA,EAA8B;AACzD,EAAA,OAAO,OAAO,IAAA,KAAS,UAAA,IAAc,CAAC,CAAC,KAAK,SAAA,EAAW,IAAA;AACxD;AAOO,IAAe,WAAf,MAGL;AAAA;AAAA;AAAA;AAAA,EAID,YAAsB,MAAA,EAA6B;AAA7B,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOrD,MAAM,KAAK,OAAA,EAA6D;AACvE,IAAA,OAAO,OAAA,CAAQ,KAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,IAAA,CAAK,UAAA,EAAuC,QAAA,EAAqE;AACtH,IAAA,OAAO,UAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,QAAA,CAAS,KAAA,EAAc,QAAA,EAAoF;AAEhH,IAAA,MAAM,KAAA;AAAA,EACP;AACD","file":"chunk-DSZSR7UE.js","sourcesContent":["/** eslint-disable unused-imports/no-unused-vars */\n\nimport type { NodeClass, NodeContext, NodeResult, RuntimeDependencies } from './types'\n\n/** A type guard to reliably distinguish a NodeClass from a NodeFunction. */\nexport function isNodeClass(impl: any): impl is NodeClass {\n\treturn typeof impl === 'function' && !!impl.prototype?.exec\n}\n\n/**\n * A structured, class-based node for complex logic with a safe, granular lifecycle.\n * This class is generic, allowing implementations to specify the exact context\n * and dependency types they expect.\n */\nexport abstract class BaseNode<\n\tTContext extends Record<string, any> = Record<string, any>,\n\tTDependencies extends RuntimeDependencies = RuntimeDependencies,\n> {\n\t/**\n\t * @param params Static parameters for this node instance, passed from the blueprint.\n\t */\n\tconstructor(protected params: Record<string, any>) { }\n\n\t/**\n\t * Phase 1: Gathers and prepares data for execution. This phase is NOT retried on failure.\n\t * @param context The node's execution context.\n\t * @returns The data needed for the `exec` phase.\n\t */\n\tasync prep(context: NodeContext<TContext, TDependencies>): Promise<any> {\n\t\treturn context.input\n\t}\n\n\t/**\n\t * Phase 2: Performs the core, isolated logic. This is the ONLY phase that is retried.\n\t * @param prepResult The data returned from the `prep` phase.\n\t * @param context The node's execution context.\n\t */\n\tabstract exec(prepResult: any, context: NodeContext<TContext, TDependencies>): Promise<Omit<NodeResult, 'error'>>\n\n\t/**\n\t * Phase 3: Processes the result and saves state. This phase is NOT retried.\n\t * @param execResult The successful result from the `exec` or `fallback` phase.\n\t * @param _context The node's execution context.\n\t */\n\tasync post(execResult: Omit<NodeResult, 'error'>, _context: NodeContext<TContext, TDependencies>): Promise<NodeResult> {\n\t\treturn execResult\n\t}\n\n\t/**\n\t * An optional safety net that runs if all `exec` retries fail.\n\t * @param error The final error from the last `exec` attempt.\n\t * @param _context The node's execution context.\n\t */\n\tasync fallback(error: Error, _context: NodeContext<TContext, TDependencies>): Promise<Omit<NodeResult, 'error'>> {\n\t\t// By default, re-throw the error, failing the node.\n\t\tthrow error\n\t}\n}\n"]}
@@ -1,22 +0,0 @@
1
- // src/evaluator.ts
2
- var SimpleEvaluator = class {
3
- evaluate(expression, context) {
4
- try {
5
- const validIdentifierRegex = /^[a-z_$][\w$]*$/i;
6
- const validKeys = Object.keys(context).filter((key) => validIdentifierRegex.test(key));
7
- const validContext = {};
8
- for (const key of validKeys) {
9
- validContext[key] = context[key];
10
- }
11
- const sandbox = new Function(...validKeys, `return ${expression}`);
12
- return sandbox(...validKeys.map((k) => validContext[k]));
13
- } catch (error) {
14
- console.error(`Error evaluating expression "${expression}":`, error);
15
- return void 0;
16
- }
17
- }
18
- };
19
-
20
- export { SimpleEvaluator };
21
- //# sourceMappingURL=chunk-GTZC6PQI.js.map
22
- //# sourceMappingURL=chunk-GTZC6PQI.js.map