flowcraft 2.7.1 → 2.8.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.
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/persistent-event-bus.d.ts +1 -1
- package/dist/analysis.d.ts +1 -1
- package/dist/{chunk-N63S5NEG.js → chunk-26VTGQAF.js} +4 -8
- package/dist/chunk-26VTGQAF.js.map +1 -0
- package/dist/{chunk-BCMR7Y4U.js → chunk-4JUPOFSL.js} +4 -4
- package/dist/{chunk-BCMR7Y4U.js.map → chunk-4JUPOFSL.js.map} +1 -1
- package/dist/{chunk-7EMUOH77.js → chunk-5A24LVGQ.js} +3 -3
- package/dist/{chunk-7EMUOH77.js.map → chunk-5A24LVGQ.js.map} +1 -1
- package/dist/{chunk-U7DKCIWT.js → chunk-BV6MXL74.js} +3 -3
- package/dist/{chunk-U7DKCIWT.js.map → chunk-BV6MXL74.js.map} +1 -1
- package/dist/{chunk-BEHVGFIM.js → chunk-CIXL7AKH.js} +7 -7
- package/dist/{chunk-BEHVGFIM.js.map → chunk-CIXL7AKH.js.map} +1 -1
- package/dist/{chunk-7M6FHFHP.js → chunk-E6ICIXVR.js} +4 -4
- package/dist/{chunk-7M6FHFHP.js.map → chunk-E6ICIXVR.js.map} +1 -1
- package/dist/{chunk-XZZWIJ4G.js → chunk-K446NZ4E.js} +3 -3
- package/dist/{chunk-XZZWIJ4G.js.map → chunk-K446NZ4E.js.map} +1 -1
- package/dist/{chunk-WWGFIYKW.js → chunk-OOJEXFYY.js} +11 -11
- package/dist/chunk-OOJEXFYY.js.map +1 -0
- package/dist/{chunk-HXSK5P2X.js → chunk-PU2VTWJD.js} +23 -9
- package/dist/chunk-PU2VTWJD.js.map +1 -0
- package/dist/{chunk-DV2CXHOY.js → chunk-QA2WDZPV.js} +3 -3
- package/dist/{chunk-DV2CXHOY.js.map → chunk-QA2WDZPV.js.map} +1 -1
- package/dist/{chunk-RAZWRNAJ.js → chunk-VZ4BRDBK.js} +3 -3
- package/dist/{chunk-RAZWRNAJ.js.map → chunk-VZ4BRDBK.js.map} +1 -1
- package/dist/{chunk-AKDL2ZX7.js → chunk-X5RJOZY2.js} +17 -25
- package/dist/chunk-X5RJOZY2.js.map +1 -0
- package/dist/{chunk-H4JTZYIT.js → chunk-ZKINHLMS.js} +80 -22
- package/dist/chunk-ZKINHLMS.js.map +1 -0
- package/dist/container-factory.d.ts +1 -1
- package/dist/container-factory.js +4 -4
- package/dist/container.js +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/error-mapper.d.ts +1 -1
- package/dist/evaluator.d.ts +1 -1
- package/dist/flow.d.ts +1 -3
- package/dist/flow.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -10
- package/dist/linter.d.ts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/nodes/batch-gather.d.ts +1 -1
- package/dist/nodes/batch-scatter.d.ts +1 -1
- package/dist/nodes/sleep.d.ts +1 -1
- package/dist/nodes/subflow.d.ts +1 -1
- package/dist/nodes/subflow.js +2 -2
- package/dist/nodes/wait.d.ts +1 -1
- package/dist/nodes/webhook.d.ts +1 -1
- package/dist/runtime/adapter.d.ts +1 -1
- package/dist/runtime/adapter.js +8 -8
- package/dist/runtime/execution-context.d.ts +1 -1
- package/dist/runtime/executors.d.ts +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +8 -8
- package/dist/runtime/node-executor-factory.d.ts +1 -1
- package/dist/runtime/orchestrator.d.ts +1 -1
- package/dist/runtime/orchestrator.js +2 -2
- package/dist/runtime/orchestrators/replay.d.ts +1 -1
- package/dist/runtime/orchestrators/step-by-step.d.ts +1 -1
- package/dist/runtime/orchestrators/step-by-step.js +2 -2
- package/dist/runtime/orchestrators/utils.d.ts +1 -1
- package/dist/runtime/orchestrators/utils.js +1 -1
- package/dist/runtime/runtime.d.ts +1 -1
- package/dist/runtime/runtime.js +7 -7
- package/dist/runtime/scheduler.d.ts +1 -1
- package/dist/runtime/state.d.ts +1 -1
- package/dist/runtime/traverser.d.ts +1 -1
- package/dist/runtime/traverser.js +2 -1
- package/dist/runtime/types.d.ts +1 -1
- package/dist/runtime/workflow-logic-handler.d.ts +1 -1
- package/dist/runtime/workflow-logic-handler.js +1 -1
- package/dist/sanitizer.d.ts +1 -1
- package/dist/serializer.d.ts +1 -1
- package/dist/testing/event-logger.d.ts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +11 -11
- package/dist/testing/run-with-trace.d.ts +1 -1
- package/dist/testing/run-with-trace.js +9 -9
- package/dist/testing/stepper.d.ts +1 -1
- package/dist/testing/stepper.js +4 -4
- package/dist/{types-CKhffqyb.d.ts → types-Biip2gLh.d.ts} +11 -1
- package/dist/types.d.ts +1 -1
- package/package.json +59 -59
- package/LICENSE +0 -21
- package/dist/chunk-AKDL2ZX7.js.map +0 -1
- package/dist/chunk-H4JTZYIT.js.map +0 -1
- package/dist/chunk-HXSK5P2X.js.map +0 -1
- package/dist/chunk-N63S5NEG.js.map +0 -1
- package/dist/chunk-WWGFIYKW.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IOrchestrator, z as FlowcraftEvent, L as ExecutionContext, G as GraphTraverser, K as WorkflowResult } from '../../types-
|
|
1
|
+
import { I as IOrchestrator, z as FlowcraftEvent, L as ExecutionContext, G as GraphTraverser, K as WorkflowResult } from '../../types-Biip2gLh.js';
|
|
2
2
|
import '../../errors.js';
|
|
3
3
|
import '../../container.js';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IOrchestrator, L as ExecutionContext, G as GraphTraverser, K as WorkflowResult } from '../../types-
|
|
1
|
+
import { I as IOrchestrator, L as ExecutionContext, G as GraphTraverser, K as WorkflowResult } from '../../types-Biip2gLh.js';
|
|
2
2
|
import '../../errors.js';
|
|
3
3
|
import '../../container.js';
|
|
4
4
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { StepByStepOrchestrator } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
export { StepByStepOrchestrator } from '../../chunk-VZ4BRDBK.js';
|
|
2
|
+
import '../../chunk-26VTGQAF.js';
|
|
3
3
|
import '../../chunk-BCRWXTWX.js';
|
|
4
4
|
//# sourceMappingURL=step-by-step.js.map
|
|
5
5
|
//# sourceMappingURL=step-by-step.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as WorkflowBlueprint, W as WorkflowState, N as NodeExecutionResult, G as GraphTraverser } from '../../types-
|
|
1
|
+
import { h as WorkflowBlueprint, W as WorkflowState, N as NodeExecutionResult, G as GraphTraverser } from '../../types-Biip2gLh.js';
|
|
2
2
|
import '../../errors.js';
|
|
3
3
|
import '../../container.js';
|
|
4
4
|
|
package/dist/runtime/runtime.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export { FlowRuntime } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { FlowRuntime } from '../chunk-CIXL7AKH.js';
|
|
2
|
+
import '../chunk-PU2VTWJD.js';
|
|
3
3
|
import '../chunk-DL7KVYZF.js';
|
|
4
4
|
import '../chunk-LM4ACVHL.js';
|
|
5
5
|
import '../chunk-ONH7PIJZ.js';
|
|
6
6
|
import '../chunk-BC4G7OM6.js';
|
|
7
7
|
import '../chunk-RM677CNU.js';
|
|
8
8
|
import '../chunk-HNHM3FDK.js';
|
|
9
|
-
import '../chunk-
|
|
10
|
-
import '../chunk-
|
|
9
|
+
import '../chunk-5A24LVGQ.js';
|
|
10
|
+
import '../chunk-ZKINHLMS.js';
|
|
11
11
|
import '../chunk-IDTYHLDQ.js';
|
|
12
12
|
import '../chunk-I53JB2KW.js';
|
|
13
13
|
import '../chunk-TKSSRS5U.js';
|
|
14
14
|
import '../chunk-ZLW4QOTS.js';
|
|
15
|
-
import '../chunk-
|
|
16
|
-
import '../chunk-
|
|
15
|
+
import '../chunk-QA2WDZPV.js';
|
|
16
|
+
import '../chunk-26VTGQAF.js';
|
|
17
17
|
import '../chunk-L3MX5MTA.js';
|
|
18
18
|
import '../chunk-L46TQXCV.js';
|
|
19
19
|
import '../chunk-4PELJWF7.js';
|
|
20
20
|
import '../chunk-6RKHCJUU.js';
|
|
21
|
-
import '../chunk-
|
|
21
|
+
import '../chunk-OOJEXFYY.js';
|
|
22
22
|
import '../chunk-ZETQCNEF.js';
|
|
23
23
|
import '../chunk-BCRWXTWX.js';
|
|
24
24
|
import '../chunk-PH2IYZHV.js';
|
package/dist/runtime/state.d.ts
CHANGED
package/dist/runtime/types.d.ts
CHANGED
|
@@ -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-
|
|
1
|
+
export { e as ExecutionServices, I as IOrchestrator, f as IRuntime, N as NodeExecutionResult, b as NodeExecutor, d as NodeExecutorFactory } from '../types-Biip2gLh.js';
|
|
2
2
|
import '../errors.js';
|
|
3
3
|
import '../container.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { x as IEvaluator, A as IEventBus, h as WorkflowBlueprint, m as NodeResult, s as ContextImplementation, j as NodeDefinition, k as EdgeDefinition } from '../types-
|
|
1
|
+
import { x as IEvaluator, A as IEventBus, h as WorkflowBlueprint, m as NodeResult, s as ContextImplementation, j as NodeDefinition, k as EdgeDefinition } from '../types-Biip2gLh.js';
|
|
2
2
|
import '../errors.js';
|
|
3
3
|
import '../container.js';
|
|
4
4
|
|
package/dist/sanitizer.d.ts
CHANGED
package/dist/serializer.d.ts
CHANGED
package/dist/testing/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { IEventStore, InMemoryEventStore, PersistentEventBusAdapter } from '../a
|
|
|
2
2
|
export { InMemoryEventLogger } from './event-logger.js';
|
|
3
3
|
export { runWithTrace } from './run-with-trace.js';
|
|
4
4
|
export { IWorkflowStepper, createStepper } from './stepper.js';
|
|
5
|
-
import '../types-
|
|
5
|
+
import '../types-Biip2gLh.js';
|
|
6
6
|
import '../errors.js';
|
|
7
7
|
import '../container.js';
|
package/dist/testing/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { runWithTrace } from '../chunk-
|
|
1
|
+
export { runWithTrace } from '../chunk-K446NZ4E.js';
|
|
2
2
|
export { InMemoryEventLogger } from '../chunk-7EBKWATZ.js';
|
|
3
|
-
export { createStepper } from '../chunk-
|
|
4
|
-
import '../chunk-
|
|
3
|
+
export { createStepper } from '../chunk-4JUPOFSL.js';
|
|
4
|
+
import '../chunk-VZ4BRDBK.js';
|
|
5
5
|
import '../chunk-HFJXYY4E.js';
|
|
6
6
|
import '../chunk-UNORA7EM.js';
|
|
7
7
|
import '../chunk-NVLZFLYM.js';
|
|
8
|
-
import '../chunk-
|
|
9
|
-
import '../chunk-
|
|
10
|
-
import '../chunk-
|
|
8
|
+
import '../chunk-BV6MXL74.js';
|
|
9
|
+
import '../chunk-CIXL7AKH.js';
|
|
10
|
+
import '../chunk-PU2VTWJD.js';
|
|
11
11
|
import '../chunk-DL7KVYZF.js';
|
|
12
12
|
import '../chunk-LM4ACVHL.js';
|
|
13
13
|
import '../chunk-ONH7PIJZ.js';
|
|
@@ -16,19 +16,19 @@ export { InMemoryEventStore, PersistentEventBusAdapter } from '../chunk-2TSADFQX
|
|
|
16
16
|
import '../chunk-BC4G7OM6.js';
|
|
17
17
|
import '../chunk-RM677CNU.js';
|
|
18
18
|
import '../chunk-HNHM3FDK.js';
|
|
19
|
-
import '../chunk-
|
|
20
|
-
import '../chunk-
|
|
19
|
+
import '../chunk-5A24LVGQ.js';
|
|
20
|
+
import '../chunk-ZKINHLMS.js';
|
|
21
21
|
import '../chunk-IDTYHLDQ.js';
|
|
22
22
|
import '../chunk-I53JB2KW.js';
|
|
23
23
|
import '../chunk-TKSSRS5U.js';
|
|
24
24
|
import '../chunk-ZLW4QOTS.js';
|
|
25
|
-
import '../chunk-
|
|
26
|
-
import '../chunk-
|
|
25
|
+
import '../chunk-QA2WDZPV.js';
|
|
26
|
+
import '../chunk-26VTGQAF.js';
|
|
27
27
|
import '../chunk-L3MX5MTA.js';
|
|
28
28
|
import '../chunk-L46TQXCV.js';
|
|
29
29
|
import '../chunk-4PELJWF7.js';
|
|
30
30
|
import '../chunk-6RKHCJUU.js';
|
|
31
|
-
import '../chunk-
|
|
31
|
+
import '../chunk-OOJEXFYY.js';
|
|
32
32
|
import '../chunk-ZETQCNEF.js';
|
|
33
33
|
import '../chunk-BCRWXTWX.js';
|
|
34
34
|
import '../chunk-PH2IYZHV.js';
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export { runWithTrace } from '../chunk-
|
|
1
|
+
export { runWithTrace } from '../chunk-K446NZ4E.js';
|
|
2
2
|
import '../chunk-7EBKWATZ.js';
|
|
3
3
|
import '../chunk-HFJXYY4E.js';
|
|
4
4
|
import '../chunk-UNORA7EM.js';
|
|
5
5
|
import '../chunk-NVLZFLYM.js';
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
6
|
+
import '../chunk-BV6MXL74.js';
|
|
7
|
+
import '../chunk-CIXL7AKH.js';
|
|
8
|
+
import '../chunk-PU2VTWJD.js';
|
|
9
9
|
import '../chunk-DL7KVYZF.js';
|
|
10
10
|
import '../chunk-LM4ACVHL.js';
|
|
11
11
|
import '../chunk-ONH7PIJZ.js';
|
|
12
12
|
import '../chunk-BC4G7OM6.js';
|
|
13
13
|
import '../chunk-RM677CNU.js';
|
|
14
14
|
import '../chunk-HNHM3FDK.js';
|
|
15
|
-
import '../chunk-
|
|
16
|
-
import '../chunk-
|
|
15
|
+
import '../chunk-5A24LVGQ.js';
|
|
16
|
+
import '../chunk-ZKINHLMS.js';
|
|
17
17
|
import '../chunk-IDTYHLDQ.js';
|
|
18
18
|
import '../chunk-I53JB2KW.js';
|
|
19
19
|
import '../chunk-TKSSRS5U.js';
|
|
20
20
|
import '../chunk-ZLW4QOTS.js';
|
|
21
|
-
import '../chunk-
|
|
22
|
-
import '../chunk-
|
|
21
|
+
import '../chunk-QA2WDZPV.js';
|
|
22
|
+
import '../chunk-26VTGQAF.js';
|
|
23
23
|
import '../chunk-L3MX5MTA.js';
|
|
24
24
|
import '../chunk-L46TQXCV.js';
|
|
25
25
|
import '../chunk-4PELJWF7.js';
|
|
26
26
|
import '../chunk-6RKHCJUU.js';
|
|
27
|
-
import '../chunk-
|
|
27
|
+
import '../chunk-OOJEXFYY.js';
|
|
28
28
|
import '../chunk-ZETQCNEF.js';
|
|
29
29
|
import '../chunk-BCRWXTWX.js';
|
|
30
30
|
import '../chunk-PH2IYZHV.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { W as WorkflowState, G as GraphTraverser, K as WorkflowResult, c as FlowRuntime, h as WorkflowBlueprint, o as NodeFunction, p as NodeClass } from '../types-
|
|
1
|
+
import { W as WorkflowState, G as GraphTraverser, K as WorkflowResult, c as FlowRuntime, h as WorkflowBlueprint, o as NodeFunction, p as NodeClass } from '../types-Biip2gLh.js';
|
|
2
2
|
import '../errors.js';
|
|
3
3
|
import '../container.js';
|
|
4
4
|
|
package/dist/testing/stepper.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { createStepper } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { createStepper } from '../chunk-4JUPOFSL.js';
|
|
2
|
+
import '../chunk-VZ4BRDBK.js';
|
|
3
|
+
import '../chunk-ZKINHLMS.js';
|
|
4
4
|
import '../chunk-ZLW4QOTS.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-26VTGQAF.js';
|
|
6
6
|
import '../chunk-L3MX5MTA.js';
|
|
7
7
|
import '../chunk-L46TQXCV.js';
|
|
8
8
|
import '../chunk-ZETQCNEF.js';
|
|
@@ -150,8 +150,10 @@ interface ReadyNode {
|
|
|
150
150
|
declare class GraphTraverser {
|
|
151
151
|
private frontier;
|
|
152
152
|
private allPredecessors;
|
|
153
|
+
private allSuccessors;
|
|
153
154
|
private dynamicBlueprint;
|
|
154
155
|
private completedNodes;
|
|
156
|
+
private nodesInLoops;
|
|
155
157
|
constructor(blueprint: WorkflowBlueprint, isStrictMode?: boolean);
|
|
156
158
|
/**
|
|
157
159
|
* Clears all nodes from the execution frontier.
|
|
@@ -166,7 +168,9 @@ declare class GraphTraverser {
|
|
|
166
168
|
*/
|
|
167
169
|
static fromState(blueprint: WorkflowBlueprint, state: WorkflowState<any>): GraphTraverser;
|
|
168
170
|
private isFallbackNode;
|
|
169
|
-
private
|
|
171
|
+
private getJoinStrategy;
|
|
172
|
+
private filterNodesInLoops;
|
|
173
|
+
private getAllLoopSuccessors;
|
|
170
174
|
getReadyNodes(): ReadyNode[];
|
|
171
175
|
hasMoreWork(): boolean;
|
|
172
176
|
markNodeCompleted(nodeId: string, result: NodeResult<any, any>, nextNodes: NodeDefinition[]): void;
|
|
@@ -175,6 +179,12 @@ declare class GraphTraverser {
|
|
|
175
179
|
getCompletedNodes(): Set<string>;
|
|
176
180
|
getDynamicBlueprint(): WorkflowBlueprint;
|
|
177
181
|
getAllPredecessors(): Map<string, Set<string>>;
|
|
182
|
+
getAllSuccessors(): Map<string, Set<string>>;
|
|
183
|
+
getPredecessors(nodeId: string): Set<string>;
|
|
184
|
+
getSuccessors(nodeId: string): Set<string>;
|
|
185
|
+
getNodesInLoop(id: string): Set<string>;
|
|
186
|
+
resetNodeCompletion(nodeId: string): void;
|
|
187
|
+
getNode(nodeId: string, blueprint: WorkflowBlueprint): NodeDefinition | undefined;
|
|
178
188
|
addDynamicNode(_nodeId: string, dynamicNode: NodeDefinition, predecessorId: string, gatherNodeId?: string): void;
|
|
179
189
|
/**
|
|
180
190
|
* Manually adds a node ID back to the execution frontier.
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './errors.js';
|
|
2
|
-
export { s as ContextImplementation, k as EdgeDefinition, z as FlowcraftEvent, u as IAsyncContext, x as IEvaluator, A as IEventBus, y as ILogger, D as ISerializer, t as ISyncContext, M as Middleware, p as NodeClass, l as NodeConfig, n as NodeContext, j as NodeDefinition, o as NodeFunction, q as NodeImplementation, r as NodeRegistry, m as NodeResult, P as PatchOperation, v as RuntimeDependencies, w as RuntimeOptions, S as SourceLocation, U as UIGraph, h as WorkflowBlueprint, g as WorkflowBlueprintMetadata, H as WorkflowError, K as WorkflowResult, J as WorkflowStatus } from './types-
|
|
2
|
+
export { s as ContextImplementation, k as EdgeDefinition, z as FlowcraftEvent, u as IAsyncContext, x as IEvaluator, A as IEventBus, y as ILogger, D as ISerializer, t as ISyncContext, M as Middleware, p as NodeClass, l as NodeConfig, n as NodeContext, j as NodeDefinition, o as NodeFunction, q as NodeImplementation, r as NodeRegistry, m as NodeResult, P as PatchOperation, v as RuntimeDependencies, w as RuntimeOptions, S as SourceLocation, U as UIGraph, h as WorkflowBlueprint, g as WorkflowBlueprintMetadata, H as WorkflowError, K as WorkflowResult, J as WorkflowStatus } from './types-Biip2gLh.js';
|
|
3
3
|
import './container.js';
|
package/package.json
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
2
|
+
"name": "flowcraft",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.8.0",
|
|
5
|
+
"description": "A lightweight workflow engine",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://flowcraft.js.org",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/gorango/flowcraft.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": "https://github.com/gorango/flowcraft/issues",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"agentic-workflows",
|
|
15
|
+
"ai-agent",
|
|
16
|
+
"background-jobs",
|
|
17
|
+
"dag",
|
|
18
|
+
"data-pipelines",
|
|
19
|
+
"declarative-workflows",
|
|
20
|
+
"distributed-systems",
|
|
21
|
+
"etl",
|
|
22
|
+
"llm-orchestration",
|
|
23
|
+
"orchestration",
|
|
24
|
+
"rag",
|
|
25
|
+
"state-machine",
|
|
26
|
+
"workflow-engine"
|
|
27
|
+
],
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./sdk": {
|
|
34
|
+
"types": "./dist/sdk.d.ts",
|
|
35
|
+
"import": "./dist/sdk.js"
|
|
36
|
+
},
|
|
37
|
+
"./testing": {
|
|
38
|
+
"types": "./dist/testing/index.d.ts",
|
|
39
|
+
"import": "./dist/testing/index.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"dev": "tsup --watch",
|
|
47
|
+
"build": "tsup",
|
|
48
|
+
"typecheck": "tsc --noEmit",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"test:watch": "vitest",
|
|
51
|
+
"test:coverage": "vitest run --coverage"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^25.3.3",
|
|
55
|
+
"@vitest/coverage-v8": "4.0.4",
|
|
56
|
+
"tsup": "^8.5.1",
|
|
57
|
+
"typescript": "^5.9.3",
|
|
58
|
+
"vitest": "^4.0.18"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Feathers
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE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AAK,EAAE,GAAG,IAAA,EAAM,MAAA,EAAQ,SAAS,CAAA;AAAA,MAC1C;AAAA,IACD;AAEA,IAAA,KAAA,MAAW,IAAA,IAAQ,UAAU,KAAA,EAAO;AACnC,MAAA,IAAI,CAAC,cAAA,CAAe,GAAA,CAAI,IAAA,CAAK,EAAE,CAAA,EAAG;AACjC,QAAA,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA,MAClB;AAAA,IACD;AAEA,IAAA,KAAA,MAAW,IAAA,IAAQ,UAAU,KAAA,EAAO;AACnC,MAAA,IAAI,CAAC,cAAA,CAAe,GAAA,CAAI,IAAA,CAAK,MAAM,CAAA,IAAK,CAAC,cAAA,CAAe,GAAA,CAAI,IAAA,CAAK,MAAM,CAAA,EAAG;AACzE,QAAA,MAAM,eAAe,OAAA,CAAQ,IAAA;AAAA,UAC5B,CAAC,CAAA,KAAM,CAAA,CAAE,MAAA,KAAW,IAAA,CAAK,MAAA,IAAU,CAAA,CAAE,MAAA,KAAW,IAAA,CAAK,MAAA,IAAU,CAAA,CAAE,MAAA,KAAW,IAAA,CAAK;AAAA,SAClF;AACA,QAAA,IAAI,CAAC,YAAA,EAAc;AAClB,UAAA,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA,QAClB;AAAA,MACD;AAAA,IACD;AAEA,IAAA,OAAO,EAAE,KAAA,EAAO,OAAA,EAAS,KAAA,EAAO,OAAA,EAAQ;AAAA,EACzC;AACD;AAKO,SAAS,WAGd,EAAA,EAAkD;AACnD,EAAA,OAAO,IAAI,YAAY,EAAE,CAAA;AAC1B","file":"chunk-AKDL2ZX7.js","sourcesContent":["import { isNodeClass } from './node'\nimport type { EdgeDefinition, NodeClass, NodeDefinition, NodeFunction, UIGraph, WorkflowBlueprint } 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 FlowBuilder<\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): FlowBuilder<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\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\tthis.blueprint.nodes?.push({\n\t\t\tid: scatterId,\n\t\t\tuses: 'batch-scatter',\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\tthis.blueprint.nodes?.push({\n\t\t\tid: gatherId,\n\t\t\tuses: 'batch-gather',\n\t\t\tparams: { outputKey, gatherNodeId: gatherId },\n\t\t\tconfig: { joinStrategy: 'all' },\n\t\t})\n\n\t\tthis.edge(scatterId, gatherId)\n\n\t\treturn this as unknown as FlowBuilder<TContext & { [K in TOutputKey]: TWorkerOutput[] }, TDependencies>\n\t}\n\n\t/**\n\t * Creates a sleep node that pauses workflow execution for a specified duration.\n\t * @param id A unique identifier for the sleep node.\n\t * @param options Configuration for the sleep duration.\n\t */\n\tsleep(\n\t\tid: string,\n\t\toptions: {\n\t\t\t/** The duration to sleep in milliseconds or a string like '5s', '1m', '2h', '1d'. */\n\t\t\tduration: number | string\n\t\t},\n\t): this {\n\t\tconst nodeDef: NodeDefinition = {\n\t\t\tid,\n\t\t\tuses: 'sleep',\n\t\t\tparams: { duration: options.duration },\n\t\t}\n\t\tthis.blueprint.nodes?.push(nodeDef)\n\t\treturn this\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\tthis.blueprint.nodes?.push({\n\t\t\tid: controllerId,\n\t\t\tuses: 'loop-controller',\n\t\t\tparams: { condition },\n\t\t\tconfig: { joinStrategy: 'any' },\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}`,\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\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): FlowBuilder<TContext, TDependencies> {\n\treturn new FlowBuilder(id)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/traverser.ts"],"names":[],"mappings":";;;AASO,IAAM,cAAA,GAAN,MAAM,eAAA,CAAe;AAAA,EACnB,QAAA,uBAAe,GAAA,EAAY;AAAA,EAC3B,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,cAAA,uBAAqB,GAAA,EAAY;AAAA,EAEzC,WAAA,CAAY,SAAA,EAA8B,YAAA,GAAwB,KAAA,EAAO;AACxE,IAAA,IAAA,CAAK,gBAAA,GAAmB,gBAAgB,SAAS,CAAA;AACjD,IAAA,IAAA,CAAK,eAAA,uBAAsB,GAAA,EAAyB;AACpD,IAAA,KAAA,MAAW,IAAA,IAAQ,IAAA,CAAK,gBAAA,CAAiB,KAAA,EAAO;AAC/C,MAAA,IAAA,CAAK,gBAAgB,GAAA,CAAI,IAAA,CAAK,EAAA,kBAAI,IAAI,KAAK,CAAA;AAAA,IAC5C;AACA,IAAA,KAAA,MAAW,IAAA,IAAQ,IAAA,CAAK,gBAAA,CAAiB,KAAA,EAAO;AAC/C,MAAA,IAAA,CAAK,gBAAgB,GAAA,CAAI,IAAA,CAAK,MAAM,CAAA,EAAG,GAAA,CAAI,KAAK,MAAM,CAAA;AAAA,IACvD;AACA,IAAA,MAAM,QAAA,GAAW,iBAAiB,SAAS,CAAA;AAC3C,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,GAAA,CAAI,QAAA,CAAS,YAAA,CAAa,MAAA,CAAO,CAAC,EAAA,KAAO,CAAC,IAAA,CA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kBAAA,GAA+C;AAC9C,IAAA,OAAO,IAAA,CAAK,eAAA;AAAA,EACb;AAAA,EAEA,cAAA,CAAe,OAAA,EAAiB,WAAA,EAA6B,aAAA,EAAuB,YAAA,EAA6B;AAChH,IAAA,IAAA,CAAK,gBAAA,CAAiB,KAAA,CAAM,IAAA,CAAK,WAAW,CAAA;AAC5C,IAAA,IAAA,CAAK,eAAA,CAAgB,IAAI,WAAA,CAAY,EAAA,sBAAQ,GAAA,CAAI,CAAC,aAAa,CAAC,CAAC,CAAA;AACjE,IAAA,IAAI,YAAA,EAAc;AACjB,MAAA,IAAA,CAAK,gBAAgB,GAAA,CAAI,YAAY,CAAA,EAAG,GAAA,CAAI,YAAY,EAAE,CAAA;AAAA,IAC3D;AACA,IAAA,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,WAAA,CAAY,EAAE,CAAA;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,cAAc,MAAA,EAAsB;AAC1C,IAAA,IAAA,CAAK,QAAA,CAAS,IAAI,MAAM,CAAA;AAAA,EACzB;AACD","file":"chunk-H4JTZYIT.js","sourcesContent":["import { analyzeBlueprint } from '../analysis'\nimport type { NodeDefinition, NodeResult, WorkflowBlueprint } from '../types'\nimport type { WorkflowState } from './state'\n\nexport interface ReadyNode {\n\tnodeId: string\n\tnodeDef: NodeDefinition\n}\n\nexport class GraphTraverser {\n\tprivate frontier = new Set<string>()\n\tprivate allPredecessors: Map<string, Set<string>>\n\tprivate dynamicBlueprint: WorkflowBlueprint\n\tprivate completedNodes = new Set<string>()\n\n\tconstructor(blueprint: WorkflowBlueprint, isStrictMode: boolean = false) {\n\t\tthis.dynamicBlueprint = structuredClone(blueprint) as WorkflowBlueprint\n\t\tthis.allPredecessors = new Map<string, Set<string>>()\n\t\tfor (const node of this.dynamicBlueprint.nodes) {\n\t\t\tthis.allPredecessors.set(node.id, new Set())\n\t\t}\n\t\tfor (const edge of this.dynamicBlueprint.edges) {\n\t\t\tthis.allPredecessors.get(edge.target)?.add(edge.source)\n\t\t}\n\t\tconst analysis = analyzeBlueprint(blueprint)\n\t\tthis.frontier = new Set(analysis.startNodeIds.filter((id) => !this.isFallbackNode(id)))\n\t\tif (this.frontier.size === 0 && analysis.cycles.length > 0 && !isStrictMode) {\n\t\t\tconst uniqueStartNodes = new Set<string>()\n\t\t\tconst cycleEntryPoints = new Set(blueprint.metadata?.cycleEntryPoints || [])\n\t\t\tfor (const cycle of analysis.cycles) {\n\t\t\t\tif (cycle.length > 0) {\n\t\t\t\t\tconst entryPoint = cycle.find((node) => cycleEntryPoints.has(node))\n\t\t\t\t\tuniqueStartNodes.add(entryPoint || cycle[0])\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.frontier = new Set(uniqueStartNodes)\n\t\t}\n\t}\n\n\t/**\n\t * Clears all nodes from the execution frontier.\n\t */\n\tpublic clearFrontier(): void {\n\t\tthis.frontier.clear()\n\t}\n\n\t/**\n\t * Creates and initializes a GraphTraverser from a saved workflow state.\n\t * This is the correct way to prepare a traverser for a `resume` operation.\n\t * @param blueprint The workflow blueprint.\n\t * @param state The workflow state being resumed.\n\t * @returns A configured GraphTraverser instance.\n\t */\n\tpublic static fromState(blueprint: WorkflowBlueprint, state: WorkflowState<any>): GraphTraverser {\n\t\tconst traverser = new GraphTraverser(blueprint)\n\n\t\t// clear auto-populated frontier from constructor\n\t\ttraverser.clearFrontier()\n\n\t\t// re-hydrate the set of completed nodes\n\t\tconst completedNodes = state.getCompletedNodes()\n\t\ttraverser.completedNodes = new Set(completedNodes)\n\n\t\tfor (const node of traverser.dynamicBlueprint.nodes) {\n\t\t\tif (traverser.completedNodes.has(node.id)) continue\n\n\t\t\tconst requiredPredecessors = traverser.allPredecessors.get(node.id)\n\t\t\tconst joinStrategy = traverser.getEffectiveJoinStrategy(node.id)\n\n\t\t\t// if no predecessors and not completed, it's a start node and should be in the frontier\n\t\t\tif (!requiredPredecessors || requiredPredecessors.size === 0) {\n\t\t\t\ttraverser.frontier.add(node.id)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst completedPredecessors = [...requiredPredecessors].filter((p) => traverser.completedNodes.has(p))\n\t\t\tconst isReady =\n\t\t\t\tjoinStrategy === 'any'\n\t\t\t\t\t? completedPredecessors.length > 0\n\t\t\t\t\t: completedPredecessors.length === requiredPredecessors.size\n\n\t\t\tif (isReady) traverser.frontier.add(node.id)\n\t\t}\n\n\t\treturn traverser\n\t}\n\n\tprivate isFallbackNode(nodeId: string): boolean {\n\t\treturn this.dynamicBlueprint.nodes.some((n) => n.config?.fallback === nodeId)\n\t}\n\n\tprivate getEffectiveJoinStrategy(nodeId: string): 'any' | 'all' {\n\t\tconst node = this.dynamicBlueprint.nodes.find((n) => n.id === nodeId)\n\t\tconst baseJoinStrategy = node?.config?.joinStrategy || 'all'\n\n\t\tif (node?.uses === 'loop-controller') {\n\t\t\treturn 'any'\n\t\t}\n\n\t\tconst predecessors = this.allPredecessors.get(nodeId)\n\t\tif (predecessors) {\n\t\t\tfor (const predecessorId of predecessors) {\n\t\t\t\tconst predecessorNode = this.dynamicBlueprint.nodes.find((n) => n.id === predecessorId)\n\t\t\t\tif (predecessorNode?.uses === 'loop-controller') {\n\t\t\t\t\treturn 'any'\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn baseJoinStrategy\n\t}\n\n\tgetReadyNodes(): ReadyNode[] {\n\t\tconst readyNodes: ReadyNode[] = []\n\t\tfor (const nodeId of this.frontier) {\n\t\t\tconst nodeDef = this.dynamicBlueprint.nodes.find((n) => n.id === nodeId)\n\t\t\tif (nodeDef) {\n\t\t\t\treadyNodes.push({ nodeId, nodeDef })\n\t\t\t}\n\t\t}\n\t\tthis.frontier.clear()\n\t\treturn readyNodes\n\t}\n\n\thasMoreWork(): boolean {\n\t\treturn this.frontier.size > 0\n\t}\n\n\tmarkNodeCompleted(nodeId: string, result: NodeResult<any, any>, nextNodes: NodeDefinition[]): void {\n\t\tthis.completedNodes.add(nodeId)\n\n\t\tif (result?.dynamicNodes && result.dynamicNodes.length > 0) {\n\t\t\tconst gatherNodeId = result.output?.gatherNodeId\n\t\t\tfor (const dynamicNode of result.dynamicNodes) {\n\t\t\t\tthis.dynamicBlueprint.nodes.push(dynamicNode)\n\t\t\t\tthis.allPredecessors.set(dynamicNode.id, new Set([nodeId]))\n\t\t\t\tif (gatherNodeId) {\n\t\t\t\t\tthis.allPredecessors.get(gatherNodeId)?.add(dynamicNode.id)\n\t\t\t\t}\n\t\t\t\tthis.frontier.add(dynamicNode.id)\n\t\t\t}\n\t\t}\n\n\t\tfor (const node of nextNodes) {\n\t\t\tconst joinStrategy = this.getEffectiveJoinStrategy(node.id)\n\t\t\tif (joinStrategy !== 'any' && this.completedNodes.has(node.id)) continue\n\n\t\t\tconst requiredPredecessors = this.allPredecessors.get(node.id)\n\t\t\tif (!requiredPredecessors) continue\n\n\t\t\tconst isReady =\n\t\t\t\tjoinStrategy === 'any'\n\t\t\t\t\t? requiredPredecessors.has(nodeId)\n\t\t\t\t\t: [...requiredPredecessors].every((p) => this.completedNodes.has(p))\n\n\t\t\tif (isReady) {\n\t\t\t\tthis.frontier.add(node.id)\n\t\t\t}\n\t\t}\n\n\t\tif (nextNodes.length === 0) {\n\t\t\tfor (const [potentialNextId, predecessors] of this.allPredecessors) {\n\t\t\t\tif (predecessors.has(nodeId) && !this.completedNodes.has(potentialNextId)) {\n\t\t\t\t\tconst joinStrategy = this.getEffectiveJoinStrategy(potentialNextId)\n\t\t\t\t\tconst isReady =\n\t\t\t\t\t\tjoinStrategy === 'any'\n\t\t\t\t\t\t\t? predecessors.has(nodeId)\n\t\t\t\t\t\t\t: [...predecessors].every((p) => this.completedNodes.has(p))\n\t\t\t\t\tif (isReady) {\n\t\t\t\t\t\tthis.frontier.add(potentialNextId)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tgetAllNodeIds(): Set<string> {\n\t\treturn new Set(this.dynamicBlueprint.nodes.map((n) => n.id))\n\t}\n\n\tgetFallbackNodeIds(): Set<string> {\n\t\tconst fallbackNodeIds = new Set<string>()\n\t\tfor (const node of this.dynamicBlueprint.nodes) {\n\t\t\tif (node.config?.fallback) fallbackNodeIds.add(node.config.fallback)\n\t\t}\n\t\treturn fallbackNodeIds\n\t}\n\n\tgetCompletedNodes(): Set<string> {\n\t\treturn new Set(this.completedNodes)\n\t}\n\n\tgetDynamicBlueprint(): WorkflowBlueprint {\n\t\treturn this.dynamicBlueprint\n\t}\n\n\tgetAllPredecessors(): Map<string, Set<string>> {\n\t\treturn this.allPredecessors\n\t}\n\n\taddDynamicNode(_nodeId: string, dynamicNode: NodeDefinition, predecessorId: string, gatherNodeId?: string): void {\n\t\tthis.dynamicBlueprint.nodes.push(dynamicNode)\n\t\tthis.allPredecessors.set(dynamicNode.id, new Set([predecessorId]))\n\t\tif (gatherNodeId) {\n\t\t\tthis.allPredecessors.get(gatherNodeId)?.add(dynamicNode.id)\n\t\t}\n\t\tthis.frontier.add(dynamicNode.id)\n\t}\n\n\t/**\n\t * Manually adds a node ID back to the execution frontier.\n\t * Used by orchestrators that need fine-grained control over steps.\n\t * @param nodeId The ID of the node to add to the frontier.\n\t */\n\tpublic addToFrontier(nodeId: string): void {\n\t\tthis.frontier.add(nodeId)\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/workflow-logic-handler.ts"],"names":[],"mappings":";;;;AAYO,IAAM,uBAAN,MAA2B;AAAA,EACjC,WAAA,CACkB,WACA,QAAA,EAChB;AAFgB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AACA,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AAAA,EACf;AAAA,EAEH,MAAa,kBAAA,CACZ,SAAA,EACA,eAAA,EACA,MAAA,EACA,SACA,WAAA,EAC4D;AAC5D,IAAA,IAAI,CAAC,MAAA,EAAQ,OAAO,EAAC;AAErB,IAAA,IAAI,qBAAA,GAAwB,e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AAA,GAAY,YAAY,UAAU,CAAA,CAAA;AACxC,YAAA,IAAI,MAAM,YAAA,CAAa,GAAA,CAAI,SAAgB,CAAA,EAAG;AAC7C,cAAA,KAAA,CAAM,GAAG,CAAA,GAAI,MAAM,YAAA,CAAa,IAAI,SAAgB,CAAA;AAAA,YACrD,CAAA,MAAO;AACN,cAAA,KAAA,CAAM,GAAG,CAAA,GAAI,MAAM,YAAA,CAAa,IAAI,UAAiB,CAAA;AAAA,YACtD;AAAA,UACD;AAAA,QACD;AACA,QAAA,OAAO,KAAA;AAAA,MACR;AAAA,IACD;AAEA,IAAA,MAAM,QAAA,GAAW,CAAA,QAAA,EAAW,OAAA,CAAQ,EAAE,CAAA,CAAA;AACtC,IAAA,OAAO,MAAM,YAAA,CAAa,GAAA,CAAI,QAAe,CAAA;AAAA,EAC9C;AACD","file":"chunk-HXSK5P2X.js","sourcesContent":["import { AsyncContextView } from '../context'\nimport { FlowcraftError } from '../errors'\nimport type {\n\tContextImplementation,\n\tEdgeDefinition,\n\tIEvaluator,\n\tIEventBus,\n\tNodeDefinition,\n\tNodeResult,\n\tWorkflowBlueprint,\n} from '../types'\n\nexport class WorkflowLogicHandler {\n\tconstructor(\n\t\tprivate readonly evaluator: IEvaluator,\n\t\tprivate readonly eventBus: IEventBus,\n\t) {}\n\n\tpublic async determineNextNodes(\n\t\tblueprint: WorkflowBlueprint,\n\t\tcompletedNodeId: string,\n\t\tresult: NodeResult<any, any>,\n\t\tcontext: ContextImplementation<any>,\n\t\texecutionId?: string,\n\t): Promise<{ node: NodeDefinition; edge: EdgeDefinition }[]> {\n\t\tif (!result) return []\n\n\t\tlet effectiveSourceNodeId = completedNodeId\n\t\tconst completedNodeDef = blueprint.nodes.find((n) => n.id === completedNodeId)\n\t\tif (completedNodeDef?.uses === 'loop-controller' && result.action !== 'continue')\n\t\t\t// act as if the loop's end node just finished\n\t\t\teffectiveSourceNodeId = completedNodeDef.params?.endNodeId\n\n\t\tlet directOutgoingEdges = blueprint.edges.filter((edge) => edge.source === effectiveSourceNodeId)\n\t\tif (effectiveSourceNodeId !== completedNodeId)\n\t\t\t// breaking from a loop, ignore the edge that leads back to the controller\n\t\t\tdirectOutgoingEdges = directOutgoingEdges.filter((edge) => edge.target !== completedNodeId)\n\n\t\tconst nodesThisIsAFallbackFor = blueprint.nodes.filter((n) => n.config?.fallback === completedNodeId)\n\t\tconst inheritedOutgoingEdges = nodesThisIsAFallbackFor.flatMap((originalNode) =>\n\t\t\tblueprint.edges.filter((edge) => edge.source === originalNode.id),\n\t\t)\n\t\tconst allPossibleEdges = [...directOutgoingEdges, ...inheritedOutgoingEdges]\n\t\tconst outgoingEdges = [\n\t\t\t...new Map(\n\t\t\t\tallPossibleEdges.map((edge) => [\n\t\t\t\t\t`${edge.source}-${edge.target}-${edge.action || ''}-${edge.condition || ''}`,\n\t\t\t\t\tedge,\n\t\t\t\t]),\n\t\t\t).values(),\n\t\t]\n\n\t\tconst matched: { node: NodeDefinition; edge: EdgeDefinition }[] = []\n\t\tconst evaluateEdge = async (edge: EdgeDefinition): Promise<boolean> => {\n\t\t\tif (!edge.condition) return true\n\t\t\tconst contextData = context.type === 'sync' ? context.toJSON() : await context.toJSON()\n\t\t\tconst evaluationResult = !!this.evaluator.evaluate(edge.condition, {\n\t\t\t\t...contextData,\n\t\t\t\tresult,\n\t\t\t})\n\t\t\tawait this.eventBus.emit({\n\t\t\t\ttype: 'edge:evaluate',\n\t\t\t\tpayload: { source: edge.source, target: edge.target, condition: edge.condition, result: evaluationResult },\n\t\t\t})\n\t\t\treturn evaluationResult\n\t\t}\n\n\t\tif (result.action) {\n\t\t\tconst actionEdges = outgoingEdges.filter((edge) => edge.action === result.action)\n\t\t\tfor (const edge of actionEdges) {\n\t\t\t\tif (await evaluateEdge(edge)) {\n\t\t\t\t\tconst targetNode = blueprint.nodes.find((n) => n.id === edge.target)\n\t\t\t\t\tif (targetNode) matched.push({ node: targetNode, edge })\n\t\t\t\t} else {\n\t\t\t\t\tawait this.eventBus.emit({\n\t\t\t\t\t\ttype: 'node:skipped',\n\t\t\t\t\t\tpayload: { nodeId: completedNodeId, edge, executionId: executionId || '', blueprintId: blueprint.id },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (matched.length === 0) {\n\t\t\tconst defaultEdges = outgoingEdges.filter((edge) => !edge.action)\n\t\t\tfor (const edge of defaultEdges) {\n\t\t\t\tif (await evaluateEdge(edge)) {\n\t\t\t\t\tconst targetNode = blueprint.nodes.find((n) => n.id === edge.target)\n\t\t\t\t\tif (targetNode) matched.push({ node: targetNode, edge })\n\t\t\t\t} else {\n\t\t\t\t\tawait this.eventBus.emit({\n\t\t\t\t\t\ttype: 'node:skipped',\n\t\t\t\t\t\tpayload: { nodeId: completedNodeId, edge, executionId: executionId || '', blueprintId: blueprint.id },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn matched\n\t}\n\n\tpublic async applyEdgeTransform(\n\t\tedge: EdgeDefinition,\n\t\tsourceResult: NodeResult<any, any>,\n\t\ttargetNode: NodeDefinition,\n\t\tcontext: ContextImplementation<any>,\n\t\tallPredecessors?: Map<string, Set<string>>,\n\t\texecutionId?: string,\n\t): Promise<void> {\n\t\tconst asyncContext = context.type === 'sync' ? new AsyncContextView(context) : context\n\t\tconst predecessors = allPredecessors?.get(targetNode.id)\n\t\tconst hasSinglePredecessor = predecessors && predecessors.size === 1\n\t\tconst hasExplicitInputs = targetNode.inputs !== undefined\n\t\tconst hasEdgeTransform = edge.transform !== undefined\n\n\t\tif (!hasExplicitInputs && !hasSinglePredecessor && !hasEdgeTransform) {\n\t\t\treturn\n\t\t}\n\n\t\tconst finalInput = edge.transform\n\t\t\t? this.evaluator.evaluate(edge.transform, {\n\t\t\t\t\tinput: sourceResult.output,\n\t\t\t\t\tcontext: await asyncContext.toJSON(),\n\t\t\t\t})\n\t\t\t: sourceResult.output\n\t\tconst inputKey = `_inputs.${targetNode.id}`\n\t\tawait asyncContext.set(inputKey as any, finalInput)\n\t\tawait this.eventBus.emit({\n\t\t\ttype: 'context:change',\n\t\t\tpayload: {\n\t\t\t\tsourceNode: edge.source,\n\t\t\t\tkey: inputKey,\n\t\t\t\top: 'set',\n\t\t\t\tvalue: finalInput,\n\t\t\t\texecutionId: executionId || 'unknown',\n\t\t\t},\n\t\t})\n\t\tif (!hasExplicitInputs) {\n\t\t\ttargetNode.inputs = inputKey\n\t\t}\n\t}\n\n\tpublic async resolveNodeInput(\n\t\tnodeId: string,\n\t\tblueprint: WorkflowBlueprint,\n\t\tcontext: ContextImplementation<any>,\n\t): Promise<any> {\n\t\tconst nodeDef = blueprint.nodes.find((n) => n.id === nodeId)\n\t\tif (!nodeDef) {\n\t\t\tthrow new FlowcraftError(`Node '${nodeId}' not found in blueprint.`, {\n\t\t\t\tnodeId,\n\t\t\t\tblueprintId: blueprint.id,\n\t\t\t\tisFatal: false,\n\t\t\t})\n\t\t}\n\t\tconst asyncContext = context.type === 'sync' ? new AsyncContextView(context) : context\n\t\tif (nodeDef.inputs) {\n\t\t\tif (typeof nodeDef.inputs === 'string') {\n\t\t\t\tconst key = nodeDef.inputs\n\t\t\t\tif (key.startsWith('_')) return await asyncContext.get(key as any)\n\t\t\t\tconst outputKey = `_outputs.${key}`\n\t\t\t\tif (await asyncContext.has(outputKey as any)) {\n\t\t\t\t\treturn await asyncContext.get(outputKey as any)\n\t\t\t\t}\n\t\t\t\treturn await asyncContext.get(key as any)\n\t\t\t}\n\t\t\tif (typeof nodeDef.inputs === 'object') {\n\t\t\t\tconst input: Record<string, any> = {}\n\t\t\t\tfor (const key in nodeDef.inputs) {\n\t\t\t\t\tconst contextKey = nodeDef.inputs[key]\n\t\t\t\t\tif (contextKey.startsWith('_')) {\n\t\t\t\t\t\tinput[key] = await asyncContext.get(contextKey as any)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst outputKey = `_outputs.${contextKey}`\n\t\t\t\t\t\tif (await asyncContext.has(outputKey as any)) {\n\t\t\t\t\t\t\tinput[key] = await asyncContext.get(outputKey as any)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tinput[key] = await asyncContext.get(contextKey as any)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn input\n\t\t\t}\n\t\t}\n\t\t// Default to standardized input key\n\t\tconst inputKey = `_inputs.${nodeDef.id}`\n\t\treturn await asyncContext.get(inputKey as any)\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/orchestrators/utils.ts"],"names":["nodeId"],"mappings":";;;AAMA,eAAsB,aACrB,UAAA,EACA,SAAA,EACA,KAAA,EACA,eAAA,EACA,SACA,cAAA,EAMC;AACD,EAAA,MAAM,WAAA,GAAc,kBAAkB,UAAA,CAAW,MAAA;AACjD,EAAA,MAAM,UAGF,EAAC;AAEL,EAAA,KAAA,IAAS,IAAI,CAAA,EAAG,CAAA,GAAI,UAAA,CAAW,MAAA,EAAQ,KAAK,WAAA,EAAa;AACxD,IAAA,MAAM,KAAA,GAAQ,UAAA,CAAW,KAAA,CAAM,CAAA,EAAG,IAAI,WAAW,CAAA;AACjD,IAAA,MAAM,gBAAgB,KAAA,CAAM,GAAA,CAAI,OAAO,EAAE,QAAO,KAAM;AACrD,MAAA,IAAI;AACH,QAAA,MAAM,QAAA,GAAW,gBAAgB,MAAM,CAAA;AACvC,QAAA,IAAI,CAAC,QAAA,EAAU,MAAM,IAAI,KAAA,CAAM,CAAA,qBAAA,EAAwB,MAAM,CAAA,CAAE,CAAA;AAC/D,QAAA,MAAM,eAAA,GAAkB,MAAM,QAAA,CAAS,OAAA;AAAA,UACtC,MAAM,OAAA,CAAQ,gBAAA,CAAiB,QAAQ,SAAA,EAAW,KAAA,CAAM,YAAY;AAAA,SACrE;AACA,QAAA,OAAA,CAAQ,IAAA,CAAK;AAAA,UACZ,MAAA,EAAQ,WAAA;AAAA,UACR,KAAA,EAAO,EAAE,MAAA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,GAAkB,UAAU,KAAA,CAAM,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,cAAc,CAAA;AAE3E,MAAA,IAAI,CAAC,eAAA,EAAiB;AACrB,QAAA,MAAM,aAAA,GAAgB,IAAI,cAAA,CAAe,CAAA,eAAA,EAAkB,cAAc,CAAA,yBAAA,CAAA,EAA6B;AAAA,UACrG,MAAA;AAAA,UACA,KAAA,EAAO;AAAA,SACP,CAAA;AACD,QAAA,KAAA,CAAM,QAAA,CAAS,QAAQ,aAAa,CAAA;AAAA,MACrC,CAAA,MAAO;AACN,QAAA,KAAA,CAAM,gBAAA,CAAiB,QAAQ,IAAI,CAAA;AACnC,QAAA,KAAA,CAAM,oBAAA,EAAqB;AAE3B,QAAA,SAAA,CAAU,iBAAA,CAAkB,QAAQ,EAAE,MAAA,EAAQ,YAAY,MAAA,EAAQ,IAAA,EAAM,iBAAA,EAAmB,IAAA,EAAK,EAAG;AAAA,UAClG;AAAA,SACA,CAAA;AAAA,MACF;AAAA,IACD,CAAA,MAAO;AACN,MAAA,KAAA,CAAM,QAAA,CAAS,MAAA,EAAQ,eAAA,CAAgB,KAAK,CAAA;AAAA,IAC7C;AAAA,EACD;AACD","file":"chunk-N63S5NEG.js","sourcesContent":["import { FlowcraftError } from '../../errors'\nimport type { NodeDefinition, WorkflowBlueprint } from '../../types'\nimport type { NodeExecutionResult } from '../executors'\nimport type { WorkflowState } from '../state'\nimport type { GraphTraverser } from '../traverser'\n\nexport async function executeBatch(\n\treadyNodes: Array<{ nodeId: string; nodeDef: any }>,\n\tblueprint: WorkflowBlueprint,\n\tstate: WorkflowState<any>,\n\texecutorFactory: (nodeId: string) => any,\n\truntime: any,\n\tmaxConcurrency?: number,\n): Promise<\n\tArray<\n\t\t| { status: 'fulfilled'; value: { nodeId: string; executionResult: NodeExecutionResult } }\n\t\t| { status: 'rejected'; reason: { nodeId: string; error: unknown } }\n\t>\n> {\n\tconst concurrency = maxConcurrency || readyNodes.length\n\tconst results: Array<\n\t\t| { status: 'fulfilled'; value: { nodeId: string; executionResult: NodeExecutionResult } }\n\t\t| { status: 'rejected'; reason: { nodeId: string; error: unknown } }\n\t> = []\n\n\tfor (let i = 0; i < readyNodes.length; i += concurrency) {\n\t\tconst batch = readyNodes.slice(i, i + concurrency)\n\t\tconst batchPromises = batch.map(async ({ nodeId }) => {\n\t\t\ttry {\n\t\t\t\tconst executor = executorFactory(nodeId)\n\t\t\t\tif (!executor) throw new Error(`No executor for node ${nodeId}`)\n\t\t\t\tconst executionResult = await executor.execute(\n\t\t\t\t\tawait runtime.resolveNodeInput(nodeId, blueprint, state.getContext()),\n\t\t\t\t)\n\t\t\t\tresults.push({\n\t\t\t\t\tstatus: 'fulfilled' as const,\n\t\t\t\t\tvalue: { nodeId, executionResult },\n\t\t\t\t})\n\t\t\t} catch (error) {\n\t\t\t\tresults.push({\n\t\t\t\t\tstatus: 'rejected' as const,\n\t\t\t\t\treason: { nodeId, error },\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\tawait Promise.all(batchPromises)\n\t}\n\n\treturn results\n}\n\nexport async function processResults(\n\tsettledResults: Array<\n\t\t| { status: 'fulfilled'; value: { nodeId: string; executionResult: NodeExecutionResult } }\n\t\t| { status: 'rejected'; reason: { nodeId: string; error: unknown } }\n\t>,\n\ttraverser: GraphTraverser,\n\tstate: WorkflowState<any>,\n\truntime: any,\n\t_blueprint: WorkflowBlueprint,\n\texecutionId?: string,\n): Promise<void> {\n\tfor (const promiseResult of settledResults) {\n\t\tif (promiseResult.status === 'rejected') {\n\t\t\tconst { nodeId, error } = promiseResult.reason\n\t\t\tif (error instanceof FlowcraftError && error.message.includes('cancelled')) {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tstate.addError(nodeId, error as Error)\n\t\t\tcontinue\n\t\t}\n\n\t\tconst { nodeId, executionResult } = promiseResult.value\n\n\t\tif (executionResult.status === 'success') {\n\t\t\tconst result = executionResult.result\n\t\t\tif (result) {\n\t\t\t\tstate.addCompletedNode(nodeId, result.output)\n\t\t\t\tif (result._fallbackExecuted) {\n\t\t\t\t\tstate.markFallbackExecuted()\n\t\t\t\t}\n\n\t\t\t\tif (result.dynamicNodes && result.dynamicNodes.length > 0) {\n\t\t\t\t\tconst gatherNodeId = result.output?.gatherNodeId\n\t\t\t\t\tfor (const dynamicNode of result.dynamicNodes) {\n\t\t\t\t\t\ttraverser.addDynamicNode(dynamicNode.id, dynamicNode, nodeId, gatherNodeId)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst matched = await runtime.determineNextNodes(\n\t\t\t\ttraverser.getDynamicBlueprint(),\n\t\t\t\tnodeId,\n\t\t\t\tresult,\n\t\t\t\tstate.getContext(),\n\t\t\t\texecutionId,\n\t\t\t)\n\n\t\t\tconst loopControllerMatch = matched.find(\n\t\t\t\t(m: { node: NodeDefinition; edge: any }) => m.node.uses === 'loop-controller',\n\t\t\t)\n\t\t\tconst finalMatched = loopControllerMatch ? [loopControllerMatch] : matched\n\n\t\t\tfor (const { node, edge } of finalMatched) {\n\t\t\t\tawait runtime.applyEdgeTransform(\n\t\t\t\t\tedge,\n\t\t\t\t\tresult,\n\t\t\t\t\tnode,\n\t\t\t\t\tstate.getContext(),\n\t\t\t\t\ttraverser.getAllPredecessors(),\n\t\t\t\t\texecutionId,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\ttraverser.markNodeCompleted(\n\t\t\t\tnodeId,\n\t\t\t\tresult,\n\t\t\t\tfinalMatched.map((m: { node: NodeDefinition; edge: any }) => m.node),\n\t\t\t)\n\t\t} else if (executionResult.status === 'failed_with_fallback') {\n\t\t\tconst { fallbackNodeId, error } = executionResult\n\t\t\tconst blueprint = traverser.getDynamicBlueprint()\n\t\t\tconst fallbackNodeDef = blueprint.nodes.find((n) => n.id === fallbackNodeId)\n\n\t\t\tif (!fallbackNodeDef) {\n\t\t\t\tconst notFoundError = new FlowcraftError(`Fallback node '${fallbackNodeId}' not found in blueprint.`, {\n\t\t\t\t\tnodeId,\n\t\t\t\t\tcause: error,\n\t\t\t\t})\n\t\t\t\tstate.addError(nodeId, notFoundError)\n\t\t\t} else {\n\t\t\t\tstate.addCompletedNode(nodeId, null)\n\t\t\t\tstate.markFallbackExecuted()\n\n\t\t\t\ttraverser.markNodeCompleted(nodeId, { action: 'fallback', output: null, _fallbackExecuted: true }, [\n\t\t\t\t\tfallbackNodeDef,\n\t\t\t\t])\n\t\t\t}\n\t\t} else {\n\t\t\tstate.addError(nodeId, executionResult.error)\n\t\t}\n\t}\n}\n"]}
|