flowcraft 2.10.0 → 2.10.1

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 (127) hide show
  1. package/README.md +3 -3
  2. package/dist/adapter-DzeZVjSE.d.mts +133 -0
  3. package/dist/adapters/index.d.mts +2 -0
  4. package/dist/adapters/index.mjs +3 -0
  5. package/dist/adapters/persistent-event-bus.d.mts +2 -0
  6. package/dist/adapters/persistent-event-bus.mjs +59 -0
  7. package/dist/analysis-B5Twr7sD.d.mts +52 -0
  8. package/dist/analysis.d.mts +2 -0
  9. package/dist/analysis.mjs +164 -0
  10. package/dist/batch-gather-BhF-IzQR.d.mts +8 -0
  11. package/dist/batch-scatter-DD8TU0Wm.d.mts +8 -0
  12. package/dist/container-BKdd-9wf.d.mts +24 -0
  13. package/dist/container-factory-fDY2kkxt.d.mts +17 -0
  14. package/dist/container-factory.d.mts +2 -0
  15. package/dist/container-factory.mjs +23 -0
  16. package/dist/container.d.mts +2 -0
  17. package/dist/container.mjs +43 -0
  18. package/dist/context-ZVtzXuZu.d.mts +64 -0
  19. package/dist/context.d.mts +2 -0
  20. package/dist/context.mjs +145 -0
  21. package/dist/error-mapper-BAv_YQMQ.d.mts +14 -0
  22. package/dist/error-mapper.d.mts +2 -0
  23. package/dist/error-mapper.mjs +37 -0
  24. package/dist/errors-CyyIj3OO.d.mts +21 -0
  25. package/dist/errors.d.mts +2 -0
  26. package/dist/errors.mjs +24 -0
  27. package/dist/evaluator-Dnj5qJ92.d.mts +31 -0
  28. package/dist/evaluator.d.mts +2 -0
  29. package/dist/evaluator.mjs +80 -0
  30. package/dist/flow-CZGpYpl-.d.mts +94 -0
  31. package/dist/flow.d.mts +2 -0
  32. package/dist/flow.mjs +328 -0
  33. package/dist/index-9iG2qHLe.d.mts +1 -0
  34. package/dist/index-Bk0eNZmQ.d.mts +1 -0
  35. package/dist/index-CNgSR_kt.d.mts +1 -0
  36. package/dist/index-CW2WHUXP.d.mts +1 -0
  37. package/dist/index.d.mts +24 -1
  38. package/dist/index.mjs +31 -791
  39. package/dist/linter-B8KALEae.d.mts +25 -0
  40. package/dist/linter.d.mts +2 -0
  41. package/dist/linter.mjs +74 -0
  42. package/dist/logger-BvDgvNHQ.d.mts +19 -0
  43. package/dist/logger.d.mts +2 -0
  44. package/dist/logger.mjs +26 -0
  45. package/dist/node.d.mts +2 -0
  46. package/dist/node.mjs +55 -0
  47. package/dist/nodes/batch-gather.d.mts +2 -0
  48. package/dist/nodes/batch-gather.mjs +47 -0
  49. package/dist/nodes/batch-scatter.d.mts +2 -0
  50. package/dist/nodes/batch-scatter.mjs +52 -0
  51. package/dist/nodes/index.d.mts +7 -0
  52. package/dist/nodes/index.mjs +8 -0
  53. package/dist/nodes/sleep.d.mts +2 -0
  54. package/dist/nodes/sleep.mjs +41 -0
  55. package/dist/nodes/subflow.d.mts +2 -0
  56. package/dist/nodes/subflow.mjs +64 -0
  57. package/dist/nodes/wait.d.mts +2 -0
  58. package/dist/nodes/wait.mjs +12 -0
  59. package/dist/nodes/webhook.d.mts +2 -0
  60. package/dist/nodes/webhook.mjs +24 -0
  61. package/dist/orchestrator-DwMIJRFI.d.mts +8 -0
  62. package/dist/persistent-event-bus-COiQOpWh.d.mts +68 -0
  63. package/dist/replay-CVOy6d_L.d.mts +44 -0
  64. package/dist/runtime/adapter.d.mts +2 -0
  65. package/dist/runtime/adapter.mjs +349 -0
  66. package/dist/runtime/builtin-keys.d.mts +37 -0
  67. package/dist/runtime/builtin-keys.mjs +12 -0
  68. package/dist/runtime/execution-context.d.mts +2 -0
  69. package/dist/runtime/execution-context.mjs +26 -0
  70. package/dist/runtime/executors.d.mts +2 -0
  71. package/dist/runtime/executors.mjs +259 -0
  72. package/dist/runtime/index.d.mts +6 -0
  73. package/dist/runtime/index.mjs +10 -0
  74. package/dist/runtime/node-executor-factory.d.mts +11 -0
  75. package/dist/runtime/node-executor-factory.mjs +41 -0
  76. package/dist/runtime/orchestrator.d.mts +2 -0
  77. package/dist/runtime/orchestrator.mjs +41 -0
  78. package/dist/runtime/orchestrators/replay.d.mts +2 -0
  79. package/dist/{replay-BB11M6K1.mjs → runtime/orchestrators/replay.mjs} +1 -20
  80. package/dist/runtime/orchestrators/step-by-step.d.mts +15 -0
  81. package/dist/runtime/orchestrators/step-by-step.mjs +41 -0
  82. package/dist/runtime/orchestrators/utils.d.mts +2 -0
  83. package/dist/runtime/orchestrators/utils.mjs +79 -0
  84. package/dist/runtime/runtime.d.mts +2 -0
  85. package/dist/runtime/runtime.mjs +425 -0
  86. package/dist/runtime/scheduler.d.mts +2 -0
  87. package/dist/runtime/scheduler.mjs +64 -0
  88. package/dist/runtime/state.d.mts +2 -0
  89. package/dist/runtime/state.mjs +127 -0
  90. package/dist/runtime/traverser.d.mts +2 -0
  91. package/dist/runtime/traverser.mjs +213 -0
  92. package/dist/runtime/types.d.mts +2 -0
  93. package/dist/runtime/types.mjs +1 -0
  94. package/dist/runtime/workflow-logic-handler.d.mts +16 -0
  95. package/dist/runtime/workflow-logic-handler.mjs +159 -0
  96. package/dist/sanitizer-Bi00YjvO.d.mts +11 -0
  97. package/dist/sanitizer.d.mts +2 -0
  98. package/dist/sanitizer.mjs +37 -0
  99. package/dist/sdk.d.mts +1 -2
  100. package/dist/sdk.mjs +1 -2
  101. package/dist/serializer-BnmJr13R.d.mts +17 -0
  102. package/dist/serializer.d.mts +2 -0
  103. package/dist/serializer.mjs +34 -0
  104. package/dist/sleep-DpwYaY5b.d.mts +8 -0
  105. package/dist/subflow-n2IMsRe2.d.mts +8 -0
  106. package/dist/testing/event-logger.d.mts +62 -0
  107. package/dist/testing/event-logger.mjs +98 -0
  108. package/dist/testing/index.d.mts +5 -172
  109. package/dist/testing/index.mjs +6 -276
  110. package/dist/testing/run-with-trace.d.mts +37 -0
  111. package/dist/testing/run-with-trace.mjs +49 -0
  112. package/dist/testing/stepper.d.mts +78 -0
  113. package/dist/testing/stepper.mjs +100 -0
  114. package/dist/types-BcrXJEPI.d.mts +687 -0
  115. package/dist/types.d.mts +2 -0
  116. package/dist/types.mjs +1 -0
  117. package/dist/utils-BUEgr9V2.d.mts +34 -0
  118. package/dist/wait-2Q-LA7V7.d.mts +8 -0
  119. package/dist/webhook-BiCm-HLx.d.mts +12 -0
  120. package/package.json +4 -4
  121. package/dist/index-BXRN44Qf.d.mts +0 -1347
  122. package/dist/index.mjs.map +0 -1
  123. package/dist/replay-BB11M6K1.mjs.map +0 -1
  124. package/dist/runtime-ChsWirQN.mjs +0 -2256
  125. package/dist/runtime-ChsWirQN.mjs.map +0 -1
  126. package/dist/sdk.mjs.map +0 -1
  127. package/dist/testing/index.mjs.map +0 -1
@@ -0,0 +1,145 @@
1
+ //#region src/context.ts
2
+ /**
3
+ * A default, high-performance, in-memory implementation of ISyncContext using a Map.
4
+ */
5
+ var Context = class {
6
+ type = "sync";
7
+ data;
8
+ constructor(initialData = {}) {
9
+ this.data = new Map(Object.entries(initialData));
10
+ }
11
+ get(key) {
12
+ return this.data.get(key);
13
+ }
14
+ set(key, value) {
15
+ this.data.set(key, value);
16
+ }
17
+ has(key) {
18
+ return this.data.has(key);
19
+ }
20
+ delete(key) {
21
+ return this.data.delete(key);
22
+ }
23
+ toJSON() {
24
+ return Object.fromEntries(this.data);
25
+ }
26
+ };
27
+ /**
28
+ * An adapter that provides a consistent, Promise-based view of a synchronous context.
29
+ * This is created by the runtime and is transparent to the node author.
30
+ */
31
+ var AsyncContextView = class {
32
+ type = "async";
33
+ constructor(syncContext) {
34
+ this.syncContext = syncContext;
35
+ }
36
+ get(key) {
37
+ return Promise.resolve(this.syncContext.get(key));
38
+ }
39
+ set(key, value) {
40
+ this.syncContext.set(key, value);
41
+ return Promise.resolve();
42
+ }
43
+ has(key) {
44
+ return Promise.resolve(this.syncContext.has(key));
45
+ }
46
+ delete(key) {
47
+ return Promise.resolve(this.syncContext.delete(key));
48
+ }
49
+ toJSON() {
50
+ return Promise.resolve(this.syncContext.toJSON());
51
+ }
52
+ async patch(_operations) {
53
+ throw new Error("Patch operations not supported by AsyncContextView");
54
+ }
55
+ };
56
+ /**
57
+ * A proxy wrapper that tracks changes to an async context for delta-based persistence.
58
+ * Records all mutations (set/delete operations) to enable efficient partial updates.
59
+ */
60
+ var TrackedAsyncContext = class {
61
+ type = "async";
62
+ deltas = [];
63
+ innerContext;
64
+ eventBus;
65
+ executionId;
66
+ sourceNode;
67
+ constructor(innerContext, eventBus, executionId, sourceNode) {
68
+ this.innerContext = innerContext;
69
+ this.eventBus = eventBus;
70
+ this.executionId = executionId;
71
+ this.sourceNode = sourceNode;
72
+ }
73
+ async get(key) {
74
+ return this.innerContext.get(key);
75
+ }
76
+ async set(key, value) {
77
+ this.deltas.push({
78
+ op: "set",
79
+ key,
80
+ value
81
+ });
82
+ await this.innerContext.set(key, value);
83
+ if (this.eventBus && this.executionId) await this.eventBus.emit({
84
+ type: "context:change",
85
+ payload: {
86
+ sourceNode: this.sourceNode || "unknown",
87
+ key,
88
+ op: "set",
89
+ value,
90
+ executionId: this.executionId
91
+ }
92
+ });
93
+ }
94
+ async has(key) {
95
+ return this.innerContext.has(key);
96
+ }
97
+ async delete(key) {
98
+ this.deltas.push({
99
+ op: "delete",
100
+ key
101
+ });
102
+ const result = await this.innerContext.delete(key);
103
+ if (this.eventBus && this.executionId && result) await this.eventBus.emit({
104
+ type: "context:change",
105
+ payload: {
106
+ sourceNode: this.sourceNode || "unknown",
107
+ key,
108
+ op: "delete",
109
+ executionId: this.executionId
110
+ }
111
+ });
112
+ return result;
113
+ }
114
+ toJSON() {
115
+ return this.innerContext.toJSON();
116
+ }
117
+ async patch(operations) {
118
+ if (this.innerContext.patch) return this.innerContext.patch(operations);
119
+ for (const op of operations) if (op.op === "set") await this.innerContext.set(op.key, op.value);
120
+ else if (op.op === "delete") await this.innerContext.delete(op.key);
121
+ }
122
+ getDeltas() {
123
+ return [...this.deltas];
124
+ }
125
+ clearDeltas() {
126
+ this.deltas = [];
127
+ }
128
+ /**
129
+ * Configures the event emitter for tracking context changes.
130
+ * This enables the context to emit events when set/delete operations occur,
131
+ * allowing for external monitoring and persistence of context mutations.
132
+ *
133
+ * @param eventBus - The event bus instance to emit context change events
134
+ * @param executionId - The unique identifier for the current workflow execution
135
+ * @param sourceNode - Optional identifier for the node that triggered the context change
136
+ */
137
+ configureEventEmitter(eventBus, executionId, sourceNode) {
138
+ this.eventBus = eventBus;
139
+ this.executionId = executionId;
140
+ this.sourceNode = sourceNode;
141
+ }
142
+ };
143
+
144
+ //#endregion
145
+ export { AsyncContextView, Context, TrackedAsyncContext };
@@ -0,0 +1,14 @@
1
+ import { w as WorkflowBlueprint } from "./types-BcrXJEPI.mjs";
2
+
3
+ //#region src/error-mapper.d.ts
4
+ /**
5
+ * Creates an error mapper function that enhances runtime errors with source location information.
6
+ * The mapper looks up node IDs in the provided manifest blueprints and returns enhanced errors
7
+ * that point to the original TypeScript source code.
8
+ *
9
+ * @param manifestBlueprints - The compiled blueprint manifest containing source location data
10
+ * @returns A function that maps errors to enhanced errors with source location information
11
+ */
12
+ declare function createErrorMapper(manifestBlueprints: Record<string, WorkflowBlueprint>): (error: Error) => Error;
13
+ //#endregion
14
+ export { createErrorMapper as t };
@@ -0,0 +1,2 @@
1
+ import { t as createErrorMapper } from "./error-mapper-BAv_YQMQ.mjs";
2
+ export { createErrorMapper };
@@ -0,0 +1,37 @@
1
+ import { FlowcraftError } from "./errors.mjs";
2
+
3
+ //#region src/error-mapper.ts
4
+ /**
5
+ * Creates an error mapper function that enhances runtime errors with source location information.
6
+ * The mapper looks up node IDs in the provided manifest blueprints and returns enhanced errors
7
+ * that point to the original TypeScript source code.
8
+ *
9
+ * @param manifestBlueprints - The compiled blueprint manifest containing source location data
10
+ * @returns A function that maps errors to enhanced errors with source location information
11
+ */
12
+ function createErrorMapper(manifestBlueprints) {
13
+ const locationMap = /* @__PURE__ */ new Map();
14
+ for (const blueprint of Object.values(manifestBlueprints)) {
15
+ for (const node of blueprint.nodes) if (node._sourceLocation) locationMap.set(node.id, node._sourceLocation);
16
+ for (const edge of blueprint.edges) if (edge._sourceLocation) {
17
+ const edgeKey = `${edge.source}-${edge.target}`;
18
+ locationMap.set(edgeKey, edge._sourceLocation);
19
+ }
20
+ }
21
+ return function mapError(error) {
22
+ if (error instanceof FlowcraftError && error.nodeId) {
23
+ const location = locationMap.get(error.nodeId);
24
+ if (location) return /* @__PURE__ */ new Error(`Workflow error at ${location.file}:${location.line}:${location.column}. Original error: ${error.message}`);
25
+ }
26
+ const nodeIdMatch = error.message.match(/nodeId[:\s]+([^\s,]+)/i);
27
+ if (nodeIdMatch) {
28
+ const nodeId = nodeIdMatch[1];
29
+ const location = locationMap.get(nodeId);
30
+ if (location) return /* @__PURE__ */ new Error(`Workflow error at ${location.file}:${location.line}:${location.column}. Original error: ${error.message}`);
31
+ }
32
+ return error;
33
+ };
34
+ }
35
+
36
+ //#endregion
37
+ export { createErrorMapper };
@@ -0,0 +1,21 @@
1
+ //#region src/errors.d.ts
2
+ /**
3
+ * A single, comprehensive error class for the framework.
4
+ * Use this for all errors to ensure consistent structure and easy debugging.
5
+ */
6
+ declare class FlowcraftError extends Error {
7
+ readonly message: string;
8
+ readonly nodeId?: string;
9
+ readonly blueprintId?: string;
10
+ readonly executionId?: string;
11
+ readonly isFatal: boolean;
12
+ constructor(message: string, options?: {
13
+ cause?: Error;
14
+ nodeId?: string;
15
+ blueprintId?: string;
16
+ executionId?: string;
17
+ isFatal?: boolean;
18
+ });
19
+ }
20
+ //#endregion
21
+ export { FlowcraftError as t };
@@ -0,0 +1,2 @@
1
+ import { t as FlowcraftError } from "./errors-CyyIj3OO.mjs";
2
+ export { FlowcraftError };
@@ -0,0 +1,24 @@
1
+ //#region src/errors.ts
2
+ /**
3
+ * A single, comprehensive error class for the framework.
4
+ * Use this for all errors to ensure consistent structure and easy debugging.
5
+ */
6
+ var FlowcraftError = class extends Error {
7
+ message;
8
+ nodeId;
9
+ blueprintId;
10
+ executionId;
11
+ isFatal;
12
+ constructor(message, options = {}) {
13
+ super(message, { cause: options.cause });
14
+ this.name = "FlowcraftError";
15
+ this.message = message;
16
+ this.nodeId = options.nodeId;
17
+ this.blueprintId = options.blueprintId;
18
+ this.executionId = options.executionId;
19
+ this.isFatal = options.isFatal ?? false;
20
+ }
21
+ };
22
+
23
+ //#endregion
24
+ export { FlowcraftError };
@@ -0,0 +1,31 @@
1
+ import { a as IEvaluator } from "./types-BcrXJEPI.mjs";
2
+
3
+ //#region src/evaluator.d.ts
4
+ /**
5
+ * A safe evaluator that only allows simple property access.
6
+ * It cannot execute arbitrary code and is secure for untrusted inputs.
7
+ *
8
+ * Example expressions:
9
+ * - "result.output.status"
10
+ * - "context.user.isAdmin"
11
+ * - "input.value"
12
+ */
13
+ declare class PropertyEvaluator implements IEvaluator {
14
+ evaluate(expression: string, context: Record<string, any>): any;
15
+ }
16
+ /**
17
+ * @warning This evaluator uses `new Function()` and can execute arbitrary
18
+ * JavaScript code. It poses a significant security risk if the expressions
19
+ * are not from a trusted source (e.g., user input).
20
+ *
21
+ * It should only be used in controlled environments where all workflow
22
+ * definitions are static and authored by trusted developers.
23
+ *
24
+ * For safer evaluation, use the default `PropertyEvaluator` or install a
25
+ * sandboxed library like `jsep` to create a custom, secure evaluator.
26
+ */
27
+ declare class UnsafeEvaluator implements IEvaluator {
28
+ evaluate(expression: string, context: Record<string, any>): any;
29
+ }
30
+ //#endregion
31
+ export { UnsafeEvaluator as n, PropertyEvaluator as t };
@@ -0,0 +1,2 @@
1
+ import { n as UnsafeEvaluator, t as PropertyEvaluator } from "./evaluator-Dnj5qJ92.mjs";
2
+ export { PropertyEvaluator, UnsafeEvaluator };
@@ -0,0 +1,80 @@
1
+ //#region src/evaluator.ts
2
+ /**
3
+ * A safe evaluator that only allows simple property access.
4
+ * It cannot execute arbitrary code and is secure for untrusted inputs.
5
+ *
6
+ * Example expressions:
7
+ * - "result.output.status"
8
+ * - "context.user.isAdmin"
9
+ * - "input.value"
10
+ */
11
+ var PropertyEvaluator = class {
12
+ evaluate(expression, context) {
13
+ try {
14
+ if (!/^[a-zA-Z0-9_$.]+$/.test(expression)) {
15
+ console.error(`Error evaluating expression: "${expression}" contains invalid characters.`);
16
+ return;
17
+ }
18
+ const parts = expression.split(".");
19
+ const startKey = parts[0];
20
+ if (!Object.hasOwn(context, startKey)) return;
21
+ let current = context[startKey];
22
+ for (let i = 1; i < parts.length; i++) {
23
+ if (current === null || current === void 0) return;
24
+ current = current[parts[i]];
25
+ }
26
+ return current;
27
+ } catch (error) {
28
+ console.error(`Error evaluating property expression "${expression}":`, error);
29
+ return;
30
+ }
31
+ }
32
+ };
33
+ /**
34
+ * Rewrites an expression so that hyphenated identifiers use bracket notation.
35
+ * E.g. "foo-bar.total" → 'context["foo-bar"].total'
36
+ */
37
+ function rewriteHyphenatedIdentifiers(expression, hyphenatedKeys) {
38
+ let result = expression;
39
+ const sortedKeys = [...hyphenatedKeys].toSorted((a, b) => b.length - a.length);
40
+ for (const key of sortedKeys) {
41
+ if (!key.includes("-")) continue;
42
+ const regex = new RegExp(`(?<![\\w$])${escapeRegex(key)}(?![\\w$-])`, "g");
43
+ result = result.replace(regex, `context["${key}"]`);
44
+ }
45
+ return result;
46
+ }
47
+ function escapeRegex(str) {
48
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
49
+ }
50
+ /**
51
+ * @warning This evaluator uses `new Function()` and can execute arbitrary
52
+ * JavaScript code. It poses a significant security risk if the expressions
53
+ * are not from a trusted source (e.g., user input).
54
+ *
55
+ * It should only be used in controlled environments where all workflow
56
+ * definitions are static and authored by trusted developers.
57
+ *
58
+ * For safer evaluation, use the default `PropertyEvaluator` or install a
59
+ * sandboxed library like `jsep` to create a custom, secure evaluator.
60
+ */
61
+ var UnsafeEvaluator = class {
62
+ evaluate(expression, context) {
63
+ try {
64
+ const validIdentifierRegex = /^[a-z_$][\w$]*$/i;
65
+ const validKeys = Object.keys(context).filter((key) => validIdentifierRegex.test(key));
66
+ const hyphenatedKeys = Object.keys(context).filter((key) => !validIdentifierRegex.test(key) && /^[a-zA-Z0-9_$-]+$/.test(key));
67
+ const validContext = {};
68
+ for (const key of validKeys) validContext[key] = context[key];
69
+ for (const key of hyphenatedKeys) validContext[key] = context[key];
70
+ let rewrittenExpression = rewriteHyphenatedIdentifiers(expression, hyphenatedKeys);
71
+ return new Function("context", ...validKeys, `return ${rewrittenExpression}`)(validContext, ...validKeys.map((k) => validContext[k]));
72
+ } catch (error) {
73
+ console.error(`Error evaluating expression "${expression}":`, error);
74
+ return;
75
+ }
76
+ }
77
+ };
78
+
79
+ //#endregion
80
+ export { PropertyEvaluator, UnsafeEvaluator };
@@ -0,0 +1,94 @@
1
+ import { A as FlowRuntime, C as UIGraph, D as WorkflowResult, d as NodeClass, h as NodeFunction, m as NodeDefinition, n as EdgeDefinition, w as WorkflowBlueprint } from "./types-BcrXJEPI.mjs";
2
+
3
+ //#region src/flow.d.ts
4
+ /**
5
+ * A fluent API for programmatically constructing a WorkflowBlueprint.
6
+ */
7
+ declare class FlowBuilder<TContext extends Record<string, any> = Record<string, any>, TDependencies extends Record<string, any> = Record<string, any>> {
8
+ private blueprint;
9
+ private functionRegistry;
10
+ private loopDefinitions;
11
+ private batchDefinitions;
12
+ private cycleEntryPoints;
13
+ constructor(id: string);
14
+ node<TInput = any, TOutput = any, TAction extends string = string>(id: string, implementation: NodeFunction<TContext, TDependencies, TInput, TOutput, TAction> | NodeClass<TContext, TDependencies, TInput, TOutput, TAction>, options?: Omit<NodeDefinition, 'id' | 'uses'>): this;
15
+ edge(source: string, target: string, options?: Omit<EdgeDefinition, 'source' | 'target'>): this;
16
+ /**
17
+ * Creates a batch processing pattern.
18
+ * It takes an input array, runs a worker node on each item in parallel, and gathers the results.
19
+ * This method augments the Flow's TContext with a new key for the output array.
20
+ *
21
+ * @param id The base ID for this batch operation.
22
+ * @param worker The node implementation to run on each item.
23
+ * @param options Configuration for the batch operation.
24
+ * @returns The Flow instance with an updated context type for chaining.
25
+ */
26
+ batch<TWorkerInput, TWorkerOutput, TWorkerAction extends string, TOutputKey extends string>(id: string, worker: NodeFunction<TContext, TDependencies, TWorkerInput, TWorkerOutput, TWorkerAction> | NodeClass<TContext, TDependencies, TWorkerInput, TWorkerOutput, TWorkerAction>, options: {
27
+ /** The key in the context that holds the input array for the batch. */inputKey: keyof TContext; /** The key in the context where the array of results will be stored. */
28
+ outputKey: TOutputKey; /** The number of items to process in each chunk to limit memory usage. */
29
+ chunkSize?: number;
30
+ }): FlowBuilder<TContext & { [K in TOutputKey]: TWorkerOutput[] }, TDependencies>;
31
+ /**
32
+ * Creates a sleep node that pauses workflow execution for a specified duration.
33
+ * @param id A unique identifier for the sleep node.
34
+ * @param options Configuration for the sleep duration.
35
+ */
36
+ sleep(id: string, options: {
37
+ /** The duration to sleep in milliseconds or a string like '5s', '1m', '2h', '1d'. */duration: number | string;
38
+ }): this;
39
+ /**
40
+ * Creates a wait node that pauses workflow execution for external input.
41
+ * @param id A unique identifier for the wait node.
42
+ * @param options Optional configuration for the wait node.
43
+ */
44
+ wait(id: string, options?: Omit<NodeDefinition, 'id' | 'uses'>): this;
45
+ /**
46
+ * Creates a loop pattern in the workflow graph.
47
+ * @param id A unique identifier for the loop construct.
48
+ * @param options Defines the start, end, and continuation condition of the loop.
49
+ * @param options.startNodeId The ID of the first node inside the loop body.
50
+ * @param options.endNodeId The ID of the last node inside the loop body.
51
+ * @param options.condition An expression that, if true, causes the loop to run again.
52
+ */
53
+ loop(id: string, options: {
54
+ /** The ID of the first node inside the loop body. */startNodeId: string; /** The ID of the last node inside the loop body. */
55
+ endNodeId: string; /** An expression that, if true, causes the loop to run again. */
56
+ condition: string;
57
+ }): this;
58
+ /**
59
+ * Sets the preferred entry point for a cycle in non-DAG workflows.
60
+ * This helps remove ambiguity when the runtime needs to choose a starting node for cycles.
61
+ * @param nodeId The ID of the node to use as the entry point for cycles containing this node.
62
+ */
63
+ setCycleEntryPoint(nodeId: string): this;
64
+ toBlueprint(): WorkflowBlueprint;
65
+ getFunctionRegistry(): Map<string, NodeFunction | NodeClass>;
66
+ /**
67
+ * Runs this flow on the given runtime, automatically passing the function registry.
68
+ * Convenience wrapper around `runtime.run(blueprint, initialState, { functionRegistry })`.
69
+ */
70
+ run(runtime: FlowRuntime<TContext, TDependencies>, initialState?: Partial<TContext> | string, options?: {
71
+ strict?: boolean;
72
+ signal?: AbortSignal;
73
+ concurrency?: number;
74
+ }): Promise<WorkflowResult<TContext>>;
75
+ /**
76
+ * Resumes this flow on the given runtime, automatically passing the function registry.
77
+ * Convenience wrapper around `runtime.resume(blueprint, ...)`.
78
+ */
79
+ resume(runtime: FlowRuntime<TContext, TDependencies>, serializedContext: string, resumeData: {
80
+ output?: any;
81
+ action?: string;
82
+ }, nodeId?: string, options?: {
83
+ strict?: boolean;
84
+ signal?: AbortSignal;
85
+ concurrency?: number;
86
+ }): Promise<WorkflowResult<TContext>>;
87
+ toGraphRepresentation(): UIGraph;
88
+ }
89
+ /**
90
+ * Helper function to create a new Flow builder instance.
91
+ */
92
+ declare function createFlow<TContext extends Record<string, any> = Record<string, any>, TDependencies extends Record<string, any> = Record<string, any>>(id: string): FlowBuilder<TContext, TDependencies>;
93
+ //#endregion
94
+ export { createFlow as n, FlowBuilder as t };
@@ -0,0 +1,2 @@
1
+ import { n as createFlow, t as FlowBuilder } from "./flow-CZGpYpl-.mjs";
2
+ export { FlowBuilder, createFlow };