flowcraft 2.7.1 → 2.8.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.
- package/README.md +1 -1
- package/dist/index-D3dyjW2G.d.mts +1269 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +727 -0
- package/dist/index.mjs.map +1 -0
- package/dist/replay-BB11M6K1.mjs +107 -0
- package/dist/replay-BB11M6K1.mjs.map +1 -0
- package/dist/runtime-CmefIAu_.mjs +2216 -0
- package/dist/runtime-CmefIAu_.mjs.map +1 -0
- package/dist/{sdk.d.ts → sdk.d.mts} +14 -12
- package/dist/sdk.mjs +29 -0
- package/dist/sdk.mjs.map +1 -0
- package/dist/testing/index.d.mts +172 -0
- package/dist/testing/index.mjs +277 -0
- package/dist/testing/index.mjs.map +1 -0
- package/package.json +59 -59
- package/LICENSE +0 -21
- package/dist/adapters/index.d.ts +0 -4
- package/dist/adapters/index.js +0 -4
- package/dist/adapters/index.js.map +0 -1
- package/dist/adapters/persistent-event-bus.d.ts +0 -69
- package/dist/adapters/persistent-event-bus.js +0 -3
- package/dist/adapters/persistent-event-bus.js.map +0 -1
- package/dist/analysis.d.ts +0 -53
- package/dist/analysis.js +0 -3
- package/dist/analysis.js.map +0 -1
- package/dist/chunk-27STBUGG.js +0 -44
- package/dist/chunk-27STBUGG.js.map +0 -1
- package/dist/chunk-2TSADFQX.js +0 -46
- package/dist/chunk-2TSADFQX.js.map +0 -1
- package/dist/chunk-3Y5O5EGB.js +0 -3
- package/dist/chunk-3Y5O5EGB.js.map +0 -1
- package/dist/chunk-4PELJWF7.js +0 -29
- package/dist/chunk-4PELJWF7.js.map +0 -1
- package/dist/chunk-55J6XMHW.js +0 -3
- package/dist/chunk-55J6XMHW.js.map +0 -1
- package/dist/chunk-6RKHCJUU.js +0 -29
- package/dist/chunk-6RKHCJUU.js.map +0 -1
- package/dist/chunk-7EBKWATZ.js +0 -86
- package/dist/chunk-7EBKWATZ.js.map +0 -1
- package/dist/chunk-7EMUOH77.js +0 -90
- package/dist/chunk-7EMUOH77.js.map +0 -1
- package/dist/chunk-7M6FHFHP.js +0 -25
- package/dist/chunk-7M6FHFHP.js.map +0 -1
- package/dist/chunk-AKDL2ZX7.js +0 -287
- package/dist/chunk-AKDL2ZX7.js.map +0 -1
- package/dist/chunk-BC4G7OM6.js +0 -42
- package/dist/chunk-BC4G7OM6.js.map +0 -1
- package/dist/chunk-BCMR7Y4U.js +0 -76
- package/dist/chunk-BCMR7Y4U.js.map +0 -1
- package/dist/chunk-BCRWXTWX.js +0 -21
- package/dist/chunk-BCRWXTWX.js.map +0 -1
- package/dist/chunk-BEHVGFIM.js +0 -532
- package/dist/chunk-BEHVGFIM.js.map +0 -1
- package/dist/chunk-DL7KVYZF.js +0 -39
- package/dist/chunk-DL7KVYZF.js.map +0 -1
- package/dist/chunk-DV2CXHOY.js +0 -74
- package/dist/chunk-DV2CXHOY.js.map +0 -1
- package/dist/chunk-H4JTZYIT.js +0 -172
- package/dist/chunk-H4JTZYIT.js.map +0 -1
- package/dist/chunk-HFJXYY4E.js +0 -3
- package/dist/chunk-HFJXYY4E.js.map +0 -1
- package/dist/chunk-HNHM3FDK.js +0 -52
- package/dist/chunk-HNHM3FDK.js.map +0 -1
- package/dist/chunk-HXSK5P2X.js +0 -150
- package/dist/chunk-HXSK5P2X.js.map +0 -1
- package/dist/chunk-I53JB2KW.js +0 -26
- package/dist/chunk-I53JB2KW.js.map +0 -1
- package/dist/chunk-IDTYHLDQ.js +0 -16
- package/dist/chunk-IDTYHLDQ.js.map +0 -1
- package/dist/chunk-IKOTX22J.js +0 -85
- package/dist/chunk-IKOTX22J.js.map +0 -1
- package/dist/chunk-L3MX5MTA.js +0 -33
- package/dist/chunk-L3MX5MTA.js.map +0 -1
- package/dist/chunk-L46TQXCV.js +0 -144
- package/dist/chunk-L46TQXCV.js.map +0 -1
- package/dist/chunk-LM4ACVHL.js +0 -73
- package/dist/chunk-LM4ACVHL.js.map +0 -1
- package/dist/chunk-LNK7LZER.js +0 -51
- package/dist/chunk-LNK7LZER.js.map +0 -1
- package/dist/chunk-N63S5NEG.js +0 -107
- package/dist/chunk-N63S5NEG.js.map +0 -1
- package/dist/chunk-NVLZFLYM.js +0 -3
- package/dist/chunk-NVLZFLYM.js.map +0 -1
- package/dist/chunk-ONH7PIJZ.js +0 -300
- package/dist/chunk-ONH7PIJZ.js.map +0 -1
- package/dist/chunk-PH2IYZHV.js +0 -48
- package/dist/chunk-PH2IYZHV.js.map +0 -1
- package/dist/chunk-RAZWRNAJ.js +0 -54
- package/dist/chunk-RAZWRNAJ.js.map +0 -1
- package/dist/chunk-RM677CNU.js +0 -52
- package/dist/chunk-RM677CNU.js.map +0 -1
- package/dist/chunk-TKSSRS5U.js +0 -39
- package/dist/chunk-TKSSRS5U.js.map +0 -1
- package/dist/chunk-U7DKCIWT.js +0 -340
- package/dist/chunk-U7DKCIWT.js.map +0 -1
- package/dist/chunk-UNORA7EM.js +0 -103
- package/dist/chunk-UNORA7EM.js.map +0 -1
- package/dist/chunk-WWGFIYKW.js +0 -47
- package/dist/chunk-WWGFIYKW.js.map +0 -1
- package/dist/chunk-XZZWIJ4G.js +0 -25
- package/dist/chunk-XZZWIJ4G.js.map +0 -1
- package/dist/chunk-ZETQCNEF.js +0 -139
- package/dist/chunk-ZETQCNEF.js.map +0 -1
- package/dist/chunk-ZLW4QOTS.js +0 -192
- package/dist/chunk-ZLW4QOTS.js.map +0 -1
- package/dist/container-factory.d.ts +0 -17
- package/dist/container-factory.js +0 -13
- package/dist/container-factory.js.map +0 -1
- package/dist/container.d.ts +0 -23
- package/dist/container.js +0 -3
- package/dist/container.js.map +0 -1
- package/dist/context.d.ts +0 -65
- package/dist/context.js +0 -3
- package/dist/context.js.map +0 -1
- package/dist/error-mapper.d.ts +0 -15
- package/dist/error-mapper.js +0 -4
- package/dist/error-mapper.js.map +0 -1
- package/dist/errors.d.ts +0 -20
- package/dist/errors.js +0 -3
- package/dist/errors.js.map +0 -1
- package/dist/evaluator.d.ts +0 -32
- package/dist/evaluator.js +0 -3
- package/dist/evaluator.js.map +0 -1
- package/dist/flow.d.ts +0 -85
- package/dist/flow.js +0 -4
- package/dist/flow.js.map +0 -1
- package/dist/index.d.ts +0 -18
- package/dist/index.js +0 -38
- package/dist/index.js.map +0 -1
- package/dist/linter.d.ts +0 -26
- package/dist/linter.js +0 -4
- package/dist/linter.js.map +0 -1
- package/dist/logger.d.ts +0 -20
- package/dist/logger.js +0 -3
- package/dist/logger.js.map +0 -1
- package/dist/node.d.ts +0 -3
- package/dist/node.js +0 -3
- package/dist/node.js.map +0 -1
- package/dist/nodes/batch-gather.d.ts +0 -9
- package/dist/nodes/batch-gather.js +0 -4
- package/dist/nodes/batch-gather.js.map +0 -1
- package/dist/nodes/batch-scatter.d.ts +0 -9
- package/dist/nodes/batch-scatter.js +0 -4
- package/dist/nodes/batch-scatter.js.map +0 -1
- package/dist/nodes/sleep.d.ts +0 -9
- package/dist/nodes/sleep.js +0 -4
- package/dist/nodes/sleep.js.map +0 -1
- package/dist/nodes/subflow.d.ts +0 -9
- package/dist/nodes/subflow.js +0 -10
- package/dist/nodes/subflow.js.map +0 -1
- package/dist/nodes/wait.d.ts +0 -9
- package/dist/nodes/wait.js +0 -4
- package/dist/nodes/wait.js.map +0 -1
- package/dist/nodes/webhook.d.ts +0 -13
- package/dist/nodes/webhook.js +0 -4
- package/dist/nodes/webhook.js.map +0 -1
- package/dist/runtime/adapter.d.ts +0 -114
- package/dist/runtime/adapter.js +0 -28
- package/dist/runtime/adapter.js.map +0 -1
- package/dist/runtime/builtin-keys.d.ts +0 -38
- package/dist/runtime/builtin-keys.js +0 -10
- package/dist/runtime/builtin-keys.js.map +0 -1
- package/dist/runtime/execution-context.d.ts +0 -3
- package/dist/runtime/execution-context.js +0 -6
- package/dist/runtime/execution-context.js.map +0 -1
- package/dist/runtime/executors.d.ts +0 -3
- package/dist/runtime/executors.js +0 -4
- package/dist/runtime/executors.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -7
- package/dist/runtime/index.js +0 -31
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/node-executor-factory.d.ts +0 -12
- package/dist/runtime/node-executor-factory.js +0 -6
- package/dist/runtime/node-executor-factory.js.map +0 -1
- package/dist/runtime/orchestrator.d.ts +0 -9
- package/dist/runtime/orchestrator.js +0 -8
- package/dist/runtime/orchestrator.js.map +0 -1
- package/dist/runtime/orchestrators/replay.d.ts +0 -45
- package/dist/runtime/orchestrators/replay.js +0 -3
- package/dist/runtime/orchestrators/replay.js.map +0 -1
- package/dist/runtime/orchestrators/step-by-step.d.ts +0 -16
- package/dist/runtime/orchestrators/step-by-step.js +0 -5
- package/dist/runtime/orchestrators/step-by-step.js.map +0 -1
- package/dist/runtime/orchestrators/utils.d.ts +0 -35
- package/dist/runtime/orchestrators/utils.js +0 -4
- package/dist/runtime/orchestrators/utils.js.map +0 -1
- package/dist/runtime/runtime.d.ts +0 -3
- package/dist/runtime/runtime.js +0 -27
- package/dist/runtime/runtime.js.map +0 -1
- package/dist/runtime/scheduler.d.ts +0 -3
- package/dist/runtime/scheduler.js +0 -3
- package/dist/runtime/scheduler.js.map +0 -1
- package/dist/runtime/state.d.ts +0 -3
- package/dist/runtime/state.js +0 -5
- package/dist/runtime/state.js.map +0 -1
- package/dist/runtime/traverser.d.ts +0 -3
- package/dist/runtime/traverser.js +0 -4
- package/dist/runtime/traverser.js.map +0 -1
- package/dist/runtime/types.d.ts +0 -3
- package/dist/runtime/types.js +0 -3
- package/dist/runtime/types.js.map +0 -1
- package/dist/runtime/workflow-logic-handler.d.ts +0 -17
- package/dist/runtime/workflow-logic-handler.js +0 -5
- package/dist/runtime/workflow-logic-handler.js.map +0 -1
- package/dist/sanitizer.d.ts +0 -12
- package/dist/sanitizer.js +0 -3
- package/dist/sanitizer.js.map +0 -1
- package/dist/sdk.js +0 -20
- package/dist/sdk.js.map +0 -1
- package/dist/serializer.d.ts +0 -18
- package/dist/serializer.js +0 -3
- package/dist/serializer.js.map +0 -1
- package/dist/testing/event-logger.d.ts +0 -63
- package/dist/testing/event-logger.js +0 -3
- package/dist/testing/event-logger.js.map +0 -1
- package/dist/testing/index.d.ts +0 -7
- package/dist/testing/index.js +0 -37
- package/dist/testing/index.js.map +0 -1
- package/dist/testing/run-with-trace.d.ts +0 -38
- package/dist/testing/run-with-trace.js +0 -33
- package/dist/testing/run-with-trace.js.map +0 -1
- package/dist/testing/stepper.d.ts +0 -79
- package/dist/testing/stepper.js +0 -11
- package/dist/testing/stepper.js.map +0 -1
- package/dist/types-CKhffqyb.d.ts +0 -666
- package/dist/types.d.ts +0 -3
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { z as FlowcraftEvent, A as IEventBus } from '../types-CKhffqyb.js';
|
|
2
|
-
import '../errors.js';
|
|
3
|
-
import '../container.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Interface for a persistent storage mechanism for events.
|
|
7
|
-
* Implementations can store events in databases, log streams, files, etc.
|
|
8
|
-
*/
|
|
9
|
-
interface IEventStore {
|
|
10
|
-
/**
|
|
11
|
-
* Store an event persistently.
|
|
12
|
-
* @param event The event to store
|
|
13
|
-
* @param executionId The execution ID for grouping events
|
|
14
|
-
*/
|
|
15
|
-
store(event: FlowcraftEvent, executionId: string): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Retrieve all events for a specific execution.
|
|
18
|
-
* @param executionId The execution ID
|
|
19
|
-
* @returns Array of events in chronological order
|
|
20
|
-
*/
|
|
21
|
-
retrieve(executionId: string): Promise<FlowcraftEvent[]>;
|
|
22
|
-
/**
|
|
23
|
-
* Retrieve events for multiple executions.
|
|
24
|
-
* @param executionIds Array of execution IDs
|
|
25
|
-
* @returns Map of execution ID to array of events
|
|
26
|
-
*/
|
|
27
|
-
retrieveMultiple(executionIds: string[]): Promise<Map<string, FlowcraftEvent[]>>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* A pluggable event bus adapter that persists all workflow events
|
|
31
|
-
* to a configurable storage backend, enabling time-travel debugging and replay.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* // Using a database-backed store
|
|
36
|
-
* const eventStore = new DatabaseEventStore(dbConnection)
|
|
37
|
-
* const eventBus = new PersistentEventBusAdapter(eventStore)
|
|
38
|
-
* const runtime = new FlowRuntime({ eventBus })
|
|
39
|
-
*
|
|
40
|
-
* // Later, replay the execution
|
|
41
|
-
* const events = await eventStore.retrieve(executionId)
|
|
42
|
-
* const finalState = await runtime.replay(blueprint, events)
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
declare class PersistentEventBusAdapter implements IEventBus {
|
|
46
|
-
private store;
|
|
47
|
-
constructor(store: IEventStore);
|
|
48
|
-
/**
|
|
49
|
-
* Emit an event by storing it persistently.
|
|
50
|
-
* Also emits to console for debugging (can be made configurable).
|
|
51
|
-
*/
|
|
52
|
-
emit(event: FlowcraftEvent): Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Simple in-memory event store for testing and development.
|
|
56
|
-
* Not suitable for production use.
|
|
57
|
-
*/
|
|
58
|
-
declare class InMemoryEventStore implements IEventStore {
|
|
59
|
-
private events;
|
|
60
|
-
store(event: FlowcraftEvent, executionId: string): Promise<void>;
|
|
61
|
-
retrieve(executionId: string): Promise<FlowcraftEvent[]>;
|
|
62
|
-
retrieveMultiple(executionIds: string[]): Promise<Map<string, FlowcraftEvent[]>>;
|
|
63
|
-
/**
|
|
64
|
-
* Clear all stored events (useful for testing).
|
|
65
|
-
*/
|
|
66
|
-
clear(): void;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export { type IEventStore, InMemoryEventStore, PersistentEventBusAdapter };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"persistent-event-bus.js"}
|
package/dist/analysis.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { h as WorkflowBlueprint, z as FlowcraftEvent } from './types-CKhffqyb.js';
|
|
2
|
-
import './errors.js';
|
|
3
|
-
import './container.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A list of cycles found in the graph. Each cycle is an array of node IDs.
|
|
7
|
-
*/
|
|
8
|
-
type Cycles = string[][];
|
|
9
|
-
/**
|
|
10
|
-
* Analysis result for a workflow blueprint
|
|
11
|
-
*/
|
|
12
|
-
interface BlueprintAnalysis {
|
|
13
|
-
/** Cycles found in the graph */
|
|
14
|
-
cycles: Cycles;
|
|
15
|
-
/** Node IDs that have no incoming edges (start nodes) */
|
|
16
|
-
startNodeIds: string[];
|
|
17
|
-
/** Node IDs that have no outgoing edges (terminal nodes) */
|
|
18
|
-
terminalNodeIds: string[];
|
|
19
|
-
/** Total number of nodes */
|
|
20
|
-
nodeCount: number;
|
|
21
|
-
/** Total number of edges */
|
|
22
|
-
edgeCount: number;
|
|
23
|
-
/** Whether the graph is a valid DAG (no cycles) */
|
|
24
|
-
isDag: boolean;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Analyzes a workflow blueprint to detect cycles using an iterative DFS algorithm.
|
|
28
|
-
* This avoids stack overflow issues for deep graphs compared to the recursive version.
|
|
29
|
-
* @param blueprint The WorkflowBlueprint object containing nodes and edges.
|
|
30
|
-
* @returns An array of cycles found. Each cycle is represented as an array of node IDs.
|
|
31
|
-
*/
|
|
32
|
-
declare function checkForCycles(blueprint: WorkflowBlueprint): Cycles;
|
|
33
|
-
/**
|
|
34
|
-
* Generates Mermaid diagram syntax from a WorkflowBlueprint
|
|
35
|
-
* @param blueprint The WorkflowBlueprint object containing nodes and edges
|
|
36
|
-
* @returns Mermaid syntax string for the flowchart
|
|
37
|
-
*/
|
|
38
|
-
declare function generateMermaid(blueprint: WorkflowBlueprint): string;
|
|
39
|
-
/**
|
|
40
|
-
* Generates Mermaid diagram syntax from a WorkflowBlueprint with execution history styling
|
|
41
|
-
* @param blueprint The WorkflowBlueprint object containing nodes and edges
|
|
42
|
-
* @param events Array of FlowcraftEvent objects from the workflow execution
|
|
43
|
-
* @returns Mermaid syntax string for the flowchart with execution path highlighting
|
|
44
|
-
*/
|
|
45
|
-
declare function generateMermaidForRun(blueprint: WorkflowBlueprint, events: FlowcraftEvent[]): string;
|
|
46
|
-
/**
|
|
47
|
-
* Analyzes a workflow blueprint and returns comprehensive analysis
|
|
48
|
-
* @param blueprint The WorkflowBlueprint object containing nodes and edges
|
|
49
|
-
* @returns Analysis result with cycles, start nodes, terminal nodes, and other metrics
|
|
50
|
-
*/
|
|
51
|
-
declare function analyzeBlueprint(blueprint: WorkflowBlueprint): BlueprintAnalysis;
|
|
52
|
-
|
|
53
|
-
export { type BlueprintAnalysis, type Cycles, analyzeBlueprint, checkForCycles, generateMermaid, generateMermaidForRun };
|
package/dist/analysis.js
DELETED
package/dist/analysis.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"analysis.js"}
|
package/dist/chunk-27STBUGG.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { FlowcraftError } from './chunk-BCRWXTWX.js';
|
|
2
|
-
|
|
3
|
-
// src/error-mapper.ts
|
|
4
|
-
function createErrorMapper(manifestBlueprints) {
|
|
5
|
-
const locationMap = /* @__PURE__ */ new Map();
|
|
6
|
-
for (const blueprint of Object.values(manifestBlueprints)) {
|
|
7
|
-
for (const node of blueprint.nodes) {
|
|
8
|
-
if (node._sourceLocation) {
|
|
9
|
-
locationMap.set(node.id, node._sourceLocation);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
for (const edge of blueprint.edges) {
|
|
13
|
-
if (edge._sourceLocation) {
|
|
14
|
-
const edgeKey = `${edge.source}-${edge.target}`;
|
|
15
|
-
locationMap.set(edgeKey, edge._sourceLocation);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return function mapError(error) {
|
|
20
|
-
if (error instanceof FlowcraftError && error.nodeId) {
|
|
21
|
-
const location = locationMap.get(error.nodeId);
|
|
22
|
-
if (location) {
|
|
23
|
-
return new Error(
|
|
24
|
-
`Workflow error at ${location.file}:${location.line}:${location.column}. Original error: ${error.message}`
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const nodeIdMatch = error.message.match(/nodeId[:\s]+([^\s,]+)/i);
|
|
29
|
-
if (nodeIdMatch) {
|
|
30
|
-
const nodeId = nodeIdMatch[1];
|
|
31
|
-
const location = locationMap.get(nodeId);
|
|
32
|
-
if (location) {
|
|
33
|
-
return new Error(
|
|
34
|
-
`Workflow error at ${location.file}:${location.line}:${location.column}. Original error: ${error.message}`
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return error;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export { createErrorMapper };
|
|
43
|
-
//# sourceMappingURL=chunk-27STBUGG.js.map
|
|
44
|
-
//# sourceMappingURL=chunk-27STBUGG.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error-mapper.ts"],"names":[],"mappings":";;;AAWO,SAAS,kBAAkB,kBAAA,EAAuD;AACxF,EAAA,MAAM,WAAA,uBAAkB,GAAA,EAA4B;AAGpD,EAAA,KAAA,MAAW,SAAA,IAAa,MAAA,CAAO,MAAA,CAAO,kBAAkB,CAAA,EAAG;AAC1D,IAAA,KAAA,MAAW,IAAA,IAAQ,UAAU,KAAA,EAAO;AACnC,MAAA,IAAI,KAAK,eAAA,EAAiB;AACzB,QAAA,WAAA,CAAY,GAAA,CAAI,IAAA,CAAK,EAAA,EAAI,IAAA,CAAK,eAAe,CAAA;AAAA,MAC9C;AAAA,IACD;AACA,IAAA,KAAA,MAAW,IAAA,IAAQ,UAAU,KAAA,EAAO;AACnC,MAAA,IAAI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esContent":["import { FlowcraftError } from './errors'\nimport type { SourceLocation, WorkflowBlueprint } from './types'\n\n/**\n * Creates an error mapper function that enhances runtime errors with source location information.\n * The mapper looks up node IDs in the provided manifest blueprints and returns enhanced errors\n * that point to the original TypeScript source code.\n *\n * @param manifestBlueprints - The compiled blueprint manifest containing source location data\n * @returns A function that maps errors to enhanced errors with source location information\n */\nexport function createErrorMapper(manifestBlueprints: Record<string, WorkflowBlueprint>) {\n\tconst locationMap = new Map<string, SourceLocation>()\n\n\t// build a quick lookup map\n\tfor (const blueprint of Object.values(manifestBlueprints)) {\n\t\tfor (const node of blueprint.nodes) {\n\t\t\tif (node._sourceLocation) {\n\t\t\t\tlocationMap.set(node.id, node._sourceLocation)\n\t\t\t}\n\t\t}\n\t\tfor (const edge of blueprint.edges) {\n\t\t\tif (edge._sourceLocation) {\n\t\t\t\tconst edgeKey = `${edge.source}-${edge.target}`\n\t\t\t\tlocationMap.set(edgeKey, edge._sourceLocation)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn function mapError(error: Error): Error {\n\t\tif (error instanceof FlowcraftError && error.nodeId) {\n\t\t\tconst location = locationMap.get(error.nodeId)\n\t\t\tif (location) {\n\t\t\t\treturn new Error(\n\t\t\t\t\t`Workflow error at ${location.file}:${location.line}:${location.column}. Original error: ${error.message}`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\t// try to extract nodeId from error message\n\t\tconst nodeIdMatch = error.message.match(/nodeId[:\\s]+([^\\s,]+)/i)\n\t\tif (nodeIdMatch) {\n\t\t\tconst nodeId = nodeIdMatch[1]\n\t\t\tconst location = locationMap.get(nodeId)\n\t\t\tif (location) {\n\t\t\t\treturn new Error(\n\t\t\t\t\t`Workflow error at ${location.file}:${location.line}:${location.column}. Original error: ${error.message}`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\treturn error\n\t}\n}\n"]}
|
package/dist/chunk-2TSADFQX.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// src/adapters/persistent-event-bus.ts
|
|
2
|
-
var PersistentEventBusAdapter = class {
|
|
3
|
-
constructor(store) {
|
|
4
|
-
this.store = store;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Emit an event by storing it persistently.
|
|
8
|
-
* Also emits to console for debugging (can be made configurable).
|
|
9
|
-
*/
|
|
10
|
-
async emit(event) {
|
|
11
|
-
let executionId = "unknown";
|
|
12
|
-
if ("executionId" in event.payload) {
|
|
13
|
-
executionId = event.payload.executionId;
|
|
14
|
-
}
|
|
15
|
-
await this.store.store(event, executionId);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
var InMemoryEventStore = class {
|
|
19
|
-
events = /* @__PURE__ */ new Map();
|
|
20
|
-
async store(event, executionId) {
|
|
21
|
-
if (!this.events.has(executionId)) {
|
|
22
|
-
this.events.set(executionId, []);
|
|
23
|
-
}
|
|
24
|
-
this.events.get(executionId)?.push(event);
|
|
25
|
-
}
|
|
26
|
-
async retrieve(executionId) {
|
|
27
|
-
return this.events.get(executionId) || [];
|
|
28
|
-
}
|
|
29
|
-
async retrieveMultiple(executionIds) {
|
|
30
|
-
const result = /* @__PURE__ */ new Map();
|
|
31
|
-
for (const id of executionIds) {
|
|
32
|
-
result.set(id, await this.retrieve(id));
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Clear all stored events (useful for testing).
|
|
38
|
-
*/
|
|
39
|
-
clear() {
|
|
40
|
-
this.events.clear();
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export { InMemoryEventStore, PersistentEventBusAdapter };
|
|
45
|
-
//# sourceMappingURL=chunk-2TSADFQX.js.map
|
|
46
|
-
//# sourceMappingURL=chunk-2TSADFQX.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/persistent-event-bus.ts"],"names":[],"mappings":";AA6CO,IAAM,4BAAN,MAAqD;AAAA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A,EAAM;AAAA,EACnB;AACD","file":"chunk-2TSADFQX.js","sourcesContent":["import type { FlowcraftEvent, IEventBus } from '../types'\n\n/**\n * Interface for a persistent storage mechanism for events.\n * Implementations can store events in databases, log streams, files, etc.\n */\nexport interface IEventStore {\n\t/**\n\t * Store an event persistently.\n\t * @param event The event to store\n\t * @param executionId The execution ID for grouping events\n\t */\n\tstore(event: FlowcraftEvent, executionId: string): Promise<void>\n\n\t/**\n\t * Retrieve all events for a specific execution.\n\t * @param executionId The execution ID\n\t * @returns Array of events in chronological order\n\t */\n\tretrieve(executionId: string): Promise<FlowcraftEvent[]>\n\n\t/**\n\t * Retrieve events for multiple executions.\n\t * @param executionIds Array of execution IDs\n\t * @returns Map of execution ID to array of events\n\t */\n\tretrieveMultiple(executionIds: string[]): Promise<Map<string, FlowcraftEvent[]>>\n}\n\n/**\n * A pluggable event bus adapter that persists all workflow events\n * to a configurable storage backend, enabling time-travel debugging and replay.\n *\n * @example\n * ```typescript\n * // Using a database-backed store\n * const eventStore = new DatabaseEventStore(dbConnection)\n * const eventBus = new PersistentEventBusAdapter(eventStore)\n * const runtime = new FlowRuntime({ eventBus })\n *\n * // Later, replay the execution\n * const events = await eventStore.retrieve(executionId)\n * const finalState = await runtime.replay(blueprint, events)\n * ```\n */\nexport class PersistentEventBusAdapter implements IEventBus {\n\tconstructor(private store: IEventStore) {}\n\n\t/**\n\t * Emit an event by storing it persistently.\n\t * Also emits to console for debugging (can be made configurable).\n\t */\n\tasync emit(event: FlowcraftEvent): Promise<void> {\n\t\tlet executionId = 'unknown'\n\t\tif ('executionId' in event.payload) {\n\t\t\texecutionId = event.payload.executionId as string\n\t\t}\n\t\tawait this.store.store(event, executionId)\n\t}\n}\n\n/**\n * Simple in-memory event store for testing and development.\n * Not suitable for production use.\n */\nexport class InMemoryEventStore implements IEventStore {\n\tprivate events = new Map<string, FlowcraftEvent[]>()\n\n\tasync store(event: FlowcraftEvent, executionId: string): Promise<void> {\n\t\tif (!this.events.has(executionId)) {\n\t\t\tthis.events.set(executionId, [])\n\t\t}\n\t\tthis.events.get(executionId)?.push(event)\n\t}\n\n\tasync retrieve(executionId: string): Promise<FlowcraftEvent[]> {\n\t\treturn this.events.get(executionId) || []\n\t}\n\n\tasync retrieveMultiple(executionIds: string[]): Promise<Map<string, FlowcraftEvent[]>> {\n\t\tconst result = new Map<string, FlowcraftEvent[]>()\n\t\tfor (const id of executionIds) {\n\t\t\tresult.set(id, await this.retrieve(id))\n\t\t}\n\t\treturn result\n\t}\n\n\t/**\n\t * Clear all stored events (useful for testing).\n\t */\n\tclear(): void {\n\t\tthis.events.clear()\n\t}\n}\n"]}
|
package/dist/chunk-3Y5O5EGB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-3Y5O5EGB.js"}
|
package/dist/chunk-4PELJWF7.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// src/logger.ts
|
|
2
|
-
var ConsoleLogger = class {
|
|
3
|
-
debug(message, meta) {
|
|
4
|
-
console.debug(`[DEBUG] ${message}`, meta || "");
|
|
5
|
-
}
|
|
6
|
-
info(message, meta) {
|
|
7
|
-
console.info(`[INFO] ${message}`, meta || "");
|
|
8
|
-
}
|
|
9
|
-
warn(message, meta) {
|
|
10
|
-
console.warn(`[WARN] ${message}`, meta || "");
|
|
11
|
-
}
|
|
12
|
-
error(message, meta) {
|
|
13
|
-
console.error(`[ERROR] ${message}`, meta || "");
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
var NullLogger = class {
|
|
17
|
-
debug(_message, _meta) {
|
|
18
|
-
}
|
|
19
|
-
info(_message, _meta) {
|
|
20
|
-
}
|
|
21
|
-
warn(_message, _meta) {
|
|
22
|
-
}
|
|
23
|
-
error(_message, _meta) {
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export { ConsoleLogger, NullLogger };
|
|
28
|
-
//# sourceMappingURL=chunk-4PELJWF7.js.map
|
|
29
|
-
//# sourceMappingURL=chunk-4PELJWF7.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/logger.ts"],"names":[],"mappings":";AAGO,IAAM,gBAAN,MAAuC;AAAA,EAC7C,KAAA,CAAM,SAAiB,IAAA,EAAkC;AACxD,IAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,QAAA,EAAW,OAAO,CAAA,CAAA,EAAI,QAAQ,EAAE,CAAA;AAAA,EAC/C;AAAA,EAEA,IAAA,CAAK,SAAiB,IAAA,EAAkC;AACvD,IAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,OAAA,EAAU,OAAO,CAAA,CAAA,EAAI,QAAQ,EAAE,CAAA;AAAA,EAC7C;AAAA,EAEA,IAAA,CAAK,SAAiB,IAAA,EAAkC;AACvD,IAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,OAAA,EAAU,OAAO,CAAA,CAAA,EAAI,QAAQ,EAAE,CAAA;AAAA,EAC7C;AAAA,EAEA,KAAA,CAAM,SAAiB,IAAA,EAAkC;AACxD,IAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,QAAA,EAAW,OAAO,CAAA,CAAA,EAAI,QAAQ,EAAE,CAAA;AAAA,EAC/C;AACD;AAGO,IAAM,aAAN,MAAoC;AAAA,EAC1C,KAAA,CAAM,UAAkB,KAAA,EAAmC;AAAA,EAAC;AAAA,EAC5D,IAAA,CAAK,UAAkB,KAAA,EAAmC;AAAA,EAAC;AAAA,EAC3D,IAAA,CAAK,UAAkB,KAAA,EAAmC;AAAA,EAAC;AAAA,EAC3D,KAAA,CAAM,UAAkB,KAAA,EAAmC;AAAA,EAAC;AAC7D","file":"chunk-4PELJWF7.js","sourcesContent":["import type { ILogger } from './types'\n\n/** A logger implementation that outputs to the console. */\nexport class ConsoleLogger implements ILogger {\n\tdebug(message: string, meta?: Record<string, any>): void {\n\t\tconsole.debug(`[DEBUG] ${message}`, meta || '')\n\t}\n\n\tinfo(message: string, meta?: Record<string, any>): void {\n\t\tconsole.info(`[INFO] ${message}`, meta || '')\n\t}\n\n\twarn(message: string, meta?: Record<string, any>): void {\n\t\tconsole.warn(`[WARN] ${message}`, meta || '')\n\t}\n\n\terror(message: string, meta?: Record<string, any>): void {\n\t\tconsole.error(`[ERROR] ${message}`, meta || '')\n\t}\n}\n\n/** A logger implementation that does nothing (no-op). */\nexport class NullLogger implements ILogger {\n\tdebug(_message: string, _meta?: Record<string, any>): void {}\n\tinfo(_message: string, _meta?: Record<string, any>): void {}\n\twarn(_message: string, _meta?: Record<string, any>): void {}\n\terror(_message: string, _meta?: Record<string, any>): void {}\n}\n"]}
|
package/dist/chunk-55J6XMHW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-55J6XMHW.js"}
|
package/dist/chunk-6RKHCJUU.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// src/serializer.ts
|
|
2
|
-
var JsonSerializer = class {
|
|
3
|
-
hasWarned = false;
|
|
4
|
-
serialize(data) {
|
|
5
|
-
for (const value of Object.values(data)) {
|
|
6
|
-
if (value instanceof Map || value instanceof Set || value instanceof Date) {
|
|
7
|
-
if (!this.hasWarned) {
|
|
8
|
-
console.warn(
|
|
9
|
-
"[Flowcraft] Warning: Default JsonSerializer does not support Map, Set, or Date types. Data may be lost. Consider providing a custom ISerializer (e.g., using superjson)."
|
|
10
|
-
);
|
|
11
|
-
this.hasWarned = true;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
return JSON.stringify(data);
|
|
17
|
-
} catch {
|
|
18
|
-
console.warn("[Flowcraft] Warning: Circular reference detected in context. Using safe serialization.");
|
|
19
|
-
return JSON.stringify({ _circularReference: true, message: "Context contains circular references" });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
deserialize(text) {
|
|
23
|
-
return JSON.parse(text);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export { JsonSerializer };
|
|
28
|
-
//# sourceMappingURL=chunk-6RKHCJUU.js.map
|
|
29
|
-
//# sourceMappingURL=chunk-6RKHCJUU.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/serializer.ts"],"names":[],"mappings":";AASO,IAAM,iBAAN,MAA4C;AAAA,EAC1C,SAAA,GAAY,KAAA;AAAA,EAEpB,UAAU,IAAA,EAAmC;AAC5C,IAAA,KAAA,MAAW,KAAA,IAAS,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,EAAG;AACxC,MAAA,IAAI,KAAA,YAAiB,GAAA,IAAO,KAAA,YAAiB,GAAA,IAAO,iBAAiB,IAAA,EAAM;AAC1E,QAAA,IAAI,CAAC,KAAK,SAAA,EAAW;AACpB,UAAA,OAAA,CAAQ,IAAA;AAAA,YACP;AAAA,WACD;AACA,UAAA,IAAA,CAAK,SAAA,GAAY,IAAA;AAAA,QAClB;AAAA,MACD;AAAA,IACD;AACA,IAAA,IAAI;AACH,MAAA,OAAO,IAAA,CAAK,UAAU,IAAI,CAAA;AAAA,IAC3B,CAAA,CAAA,MAAQ;AACP,MAAA,OAAA,CAAQ,KAAK,wFAAwF,CAAA;AACrG,MAAA,OAAO,KAAK,SAAA,CAAU,EAAE,oBAAoB,IAAA,EAAM,OAAA,EAAS,wCAAwC,CAAA;AAAA,IACpG;AAAA,EACD;AAAA,EAEA,YAAY,IAAA,EAAmC;AAC9C,IAAA,OAAO,IAAA,CAAK,MAAM,IAAI,CAAA;AAAA,EACvB;AACD","file":"chunk-6RKHCJUU.js","sourcesContent":["import type { ISerializer } from './types'\n\n/**\n * A default serializer using standard JSON.\n *\n * @warning This implementation is lossy and does not handle complex data types\n * like `Date`, `Map`, `Set`, `undefined`, etc. It is recommended to provide a robust\n * serializer like `superjson` if working with complex data types.\n */\nexport class JsonSerializer implements ISerializer {\n\tprivate hasWarned = false\n\n\tserialize(data: Record<string, any>): string {\n\t\tfor (const value of Object.values(data)) {\n\t\t\tif (value instanceof Map || value instanceof Set || value instanceof Date) {\n\t\t\t\tif (!this.hasWarned) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t'[Flowcraft] Warning: Default JsonSerializer does not support Map, Set, or Date types. Data may be lost. Consider providing a custom ISerializer (e.g., using superjson).',\n\t\t\t\t\t)\n\t\t\t\t\tthis.hasWarned = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\treturn JSON.stringify(data)\n\t\t} catch {\n\t\t\tconsole.warn('[Flowcraft] Warning: Circular reference detected in context. Using safe serialization.')\n\t\t\treturn JSON.stringify({ _circularReference: true, message: 'Context contains circular references' })\n\t\t}\n\t}\n\n\tdeserialize(text: string): Record<string, any> {\n\t\treturn JSON.parse(text)\n\t}\n}\n"]}
|
package/dist/chunk-7EBKWATZ.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// src/testing/event-logger.ts
|
|
2
|
-
var InMemoryEventLogger = class {
|
|
3
|
-
events = [];
|
|
4
|
-
/**
|
|
5
|
-
* Clears all captured events.
|
|
6
|
-
*/
|
|
7
|
-
clear() {
|
|
8
|
-
this.events.length = 0;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* The `emit` method required by the IEventBus interface.
|
|
12
|
-
* It simply pushes the received event into the internal events array.
|
|
13
|
-
* @param event The FlowcraftEvent to record.
|
|
14
|
-
*/
|
|
15
|
-
async emit(event) {
|
|
16
|
-
this.events.push(event);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Finds the first event of a specific type.
|
|
20
|
-
* @param type The event type to find (e.g., 'node:error').
|
|
21
|
-
* @returns The first matching event, or undefined if not found.
|
|
22
|
-
*/
|
|
23
|
-
find(type) {
|
|
24
|
-
return this.events.find((e) => e.type === type);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Filters events to find all occurrences of a specific type.
|
|
28
|
-
* @param type The event type to filter by.
|
|
29
|
-
* @returns An array of matching events.
|
|
30
|
-
*/
|
|
31
|
-
filter(type) {
|
|
32
|
-
return this.events.filter((e) => e.type === type);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Prints a formatted log of all captured events to the console.
|
|
36
|
-
* Ideal for debugging failing tests.
|
|
37
|
-
* @param title A title for the log output.
|
|
38
|
-
*/
|
|
39
|
-
printLog(title = "Workflow Execution Trace") {
|
|
40
|
-
console.log(`
|
|
41
|
-
--- ${title} ---`);
|
|
42
|
-
if (this.events.length === 0) {
|
|
43
|
-
console.log("No events were captured.");
|
|
44
|
-
console.log("----------------------------------\n");
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
this.events.forEach((event, index) => {
|
|
48
|
-
const { type, payload } = event;
|
|
49
|
-
console.log(`
|
|
50
|
-
[${index + 1}] ${type}`);
|
|
51
|
-
switch (type) {
|
|
52
|
-
case "node:start":
|
|
53
|
-
console.log(` - Node: "${payload.nodeId}" | Input: ${JSON.stringify(payload.input)}`);
|
|
54
|
-
break;
|
|
55
|
-
case "edge:evaluate":
|
|
56
|
-
console.log(` - Edge: "${payload.source}" -> "${payload.target}"`);
|
|
57
|
-
console.log(` - Condition: ${payload.condition || "N/A"} | Result: ${payload.result}`);
|
|
58
|
-
break;
|
|
59
|
-
case "context:change":
|
|
60
|
-
if (payload.op === "set") {
|
|
61
|
-
console.log(
|
|
62
|
-
` - Node "${payload.sourceNode}" wrote to context -> Key: "${payload.key}" | Value: ${JSON.stringify(payload.value)}`
|
|
63
|
-
);
|
|
64
|
-
} else if (payload.op === "delete") {
|
|
65
|
-
console.log(` - Node "${payload.sourceNode}" deleted from context -> Key: "${payload.key}"`);
|
|
66
|
-
}
|
|
67
|
-
break;
|
|
68
|
-
case "node:finish":
|
|
69
|
-
console.log(` - Node: "${payload.nodeId}" | Result: ${JSON.stringify(payload.result)}`);
|
|
70
|
-
break;
|
|
71
|
-
case "node:error":
|
|
72
|
-
console.log(` - Node: "${payload.nodeId}"`);
|
|
73
|
-
console.error(" - Error:", payload.error);
|
|
74
|
-
break;
|
|
75
|
-
default:
|
|
76
|
-
console.log(` - Payload: ${JSON.stringify(payload, null, 2)}`);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
console.log(`
|
|
80
|
-
--- End of Trace ---`);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export { InMemoryEventLogger };
|
|
85
|
-
//# sourceMappingURL=chunk-7EBKWATZ.js.map
|
|
86
|
-
//# sourceMappingURL=chunk-7EBKWATZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/testing/event-logger.ts"],"names":[],"mappings":";AAwBO,IAAM,sBAAN,MAA+C;AAAA,EACrC,SAA2B,EAAC;AAAA;AAAA;AAAA;AAAA,EAKrC,KAAA,GAAc;AACpB,IAAA,IAAA,CAAK,OAAO,MAAA,GAAS,CAAA;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,KAAK,KAAA,EAAsC;AACvD,IAAA,IAAA,CAAK,MAAA,CAAO,KAAK,KAAK,CAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,KAAuC,IAAA,EAA2D;AACxG,IAAA,OAAO,KAAK,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,IAAI,CAAA;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,OAAyC,IAAA,EAAiD;AAChG,IAAA,OAAO,KAAK,MAAA,CAAO,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,IAAI,CAAA;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,QAAA,CAAS,QAAQ,0BAAA,EAAkC;AACzD,IAAA,OAAA,CAAQ,GAAA,CAAI;AAAA,IAAA,EAAS,KAAK,CAAA,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AAA;AAAA,aACrH;AAAA,UACD,CAAA,MAAA,IAAW,OAAA,CAAQ,EAAA,KAAO,QAAA,EAAU;AACnC,YAAA,OAAA,CAAQ,IAAI,CAAA,UAAA,EAAa,OAAA,CAAQ,UAAU,CAAA,gCAAA,EAAmC,OAAA,CAAQ,GAAG,CAAA,CAAA,CAAG,CAAA;AAAA,UAC7F;AACA,UAAA;AAAA,QACD,KAAK,aAAA;AACJ,UAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,WAAA,EAAc,OAAA,CAAQ,MAAM,CAAA,YAAA,EAAe,KAAK,SAAA,CAAU,OAAA,CAAQ,MAAM,CAAC,CAAA,CAAE,CAAA;AACvF,UAAA;AAAA,QACD,KAAK,YAAA;AACJ,UAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,WAAA,EAAc,OAAA,CAAQ,MAAM,CAAA,CAAA,CAAG,CAAA;AAC3C,UAAA,OAAA,CAAQ,KAAA,CAAM,YAAA,EAAc,OAAA,CAAQ,KAAK,CAAA;AACzC,UAAA;AAAA,QACD;AACC,UAAA,OAAA,CAAQ,GAAA,CAAI,gBAAgB,IAAA,CAAK,SAAA,CAAU,SAAS,IAAA,EAAM,CAAC,CAAC,CAAA,CAAE,CAAA;AAAA;AAChE,IACD,CAAC,CAAA;AACD,IAAA,OAAA,CAAQ,GAAA,CAAI;AAAA,oBAAA,CAAwB,CAAA;AAAA,EACrC;AACD","file":"chunk-7EBKWATZ.js","sourcesContent":["import type { FlowcraftEvent, IEventBus } from '../types'\n\n/**\n * A test utility that implements IEventBus to capture all workflow events\n * in memory, acting as a \"flight recorder\" for behavioral testing.\n *\n * @example\n * // In your test file (e.g., resiliency.test.ts)\n * it('should retry a node on failure', async () => {\n * const eventLogger = new InMemoryEventLogger();\n * const runtime = new FlowRuntime({ eventBus: eventLogger });\n *\n * const flow = createFlow('retry-flow')\n * .node('api-call', vi.fn().mockRejectedValueOnce(new Error('fail')), {\n * config: { maxRetries: 2 },\n * });\n *\n * await runtime.run(flow.toBlueprint());\n *\n * // Assert against the captured event history to prove behavior.\n * const retryEvents = eventLogger.filter('node:retry');\n * expect(retryEvents).toHaveLength(1); // The first attempt is not a \"retry\"\n * });\n */\nexport class InMemoryEventLogger implements IEventBus {\n\tpublic readonly events: FlowcraftEvent[] = []\n\n\t/**\n\t * Clears all captured events.\n\t */\n\tpublic clear(): void {\n\t\tthis.events.length = 0\n\t}\n\n\t/**\n\t * The `emit` method required by the IEventBus interface.\n\t * It simply pushes the received event into the internal events array.\n\t * @param event The FlowcraftEvent to record.\n\t */\n\tpublic async emit(event: FlowcraftEvent): Promise<void> {\n\t\tthis.events.push(event)\n\t}\n\n\t/**\n\t * Finds the first event of a specific type.\n\t * @param type The event type to find (e.g., 'node:error').\n\t * @returns The first matching event, or undefined if not found.\n\t */\n\tpublic find<T extends FlowcraftEvent['type']>(type: T): Extract<FlowcraftEvent, { type: T }> | undefined {\n\t\treturn this.events.find((e) => e.type === type) as Extract<FlowcraftEvent, { type: T }> | undefined\n\t}\n\n\t/**\n\t * Filters events to find all occurrences of a specific type.\n\t * @param type The event type to filter by.\n\t * @returns An array of matching events.\n\t */\n\tpublic filter<T extends FlowcraftEvent['type']>(type: T): Extract<FlowcraftEvent, { type: T }>[] {\n\t\treturn this.events.filter((e) => e.type === type) as Extract<FlowcraftEvent, { type: T }>[]\n\t}\n\n\t/**\n\t * Prints a formatted log of all captured events to the console.\n\t * Ideal for debugging failing tests.\n\t * @param title A title for the log output.\n\t */\n\tpublic printLog(title = 'Workflow Execution Trace'): void {\n\t\tconsole.log(`\\n--- ${title} ---`)\n\t\tif (this.events.length === 0) {\n\t\t\tconsole.log('No events were captured.')\n\t\t\tconsole.log('----------------------------------\\n')\n\t\t\treturn\n\t\t}\n\n\t\tthis.events.forEach((event, index) => {\n\t\t\tconst { type, payload } = event\n\t\t\tconsole.log(`\\n[${index + 1}] ${type}`)\n\n\t\t\t// Custom formatting for a more intuitive trace\n\t\t\tswitch (type) {\n\t\t\t\tcase 'node:start':\n\t\t\t\t\tconsole.log(` - Node: \"${payload.nodeId}\" | Input: ${JSON.stringify(payload.input)}`)\n\t\t\t\t\tbreak\n\t\t\t\tcase 'edge:evaluate':\n\t\t\t\t\tconsole.log(` - Edge: \"${payload.source}\" -> \"${payload.target}\"`)\n\t\t\t\t\tconsole.log(` - Condition: ${payload.condition || 'N/A'} | Result: ${payload.result}`)\n\t\t\t\t\tbreak\n\t\t\t\tcase 'context:change':\n\t\t\t\t\tif (payload.op === 'set') {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` - Node \"${payload.sourceNode}\" wrote to context -> Key: \"${payload.key}\" | Value: ${JSON.stringify(payload.value)}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t} else if (payload.op === 'delete') {\n\t\t\t\t\t\tconsole.log(` - Node \"${payload.sourceNode}\" deleted from context -> Key: \"${payload.key}\"`)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tcase 'node:finish':\n\t\t\t\t\tconsole.log(` - Node: \"${payload.nodeId}\" | Result: ${JSON.stringify(payload.result)}`)\n\t\t\t\t\tbreak\n\t\t\t\tcase 'node:error':\n\t\t\t\t\tconsole.log(` - Node: \"${payload.nodeId}\"`)\n\t\t\t\t\tconsole.error(' - Error:', payload.error)\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tconsole.log(` - Payload: ${JSON.stringify(payload, null, 2)}`)\n\t\t\t}\n\t\t})\n\t\tconsole.log(`\\n--- End of Trace ---`)\n\t}\n}\n"]}
|
package/dist/chunk-7EMUOH77.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { GraphTraverser } from './chunk-H4JTZYIT.js';
|
|
2
|
-
import { analyzeBlueprint } from './chunk-ZLW4QOTS.js';
|
|
3
|
-
import { ExecutionContext } from './chunk-L3MX5MTA.js';
|
|
4
|
-
import { WorkflowState } from './chunk-L46TQXCV.js';
|
|
5
|
-
import { FlowcraftError } from './chunk-BCRWXTWX.js';
|
|
6
|
-
import { BaseNode } from './chunk-LNK7LZER.js';
|
|
7
|
-
|
|
8
|
-
// src/nodes/subflow.ts
|
|
9
|
-
var SubflowNode = class extends BaseNode {
|
|
10
|
-
async exec(_prepResult, context) {
|
|
11
|
-
const { blueprintId, inputs, outputs } = this.params ?? {};
|
|
12
|
-
const { runtime, workflowState } = context.dependencies;
|
|
13
|
-
if (!blueprintId) {
|
|
14
|
-
throw new FlowcraftError(`Subflow node '${this.nodeId}' is missing 'blueprintId' parameter.`, { isFatal: true });
|
|
15
|
-
}
|
|
16
|
-
const subBlueprint = runtime.blueprints?.[blueprintId] || runtime.runtime?.blueprints?.[blueprintId];
|
|
17
|
-
if (!subBlueprint) {
|
|
18
|
-
throw new FlowcraftError(`Sub-blueprint '${blueprintId}' not found in runtime registry.`, { isFatal: true });
|
|
19
|
-
}
|
|
20
|
-
const subflowInitialContext = {};
|
|
21
|
-
if (inputs) {
|
|
22
|
-
for (const [targetKey, sourceKey] of Object.entries(inputs)) {
|
|
23
|
-
let value = await context.context.get(sourceKey);
|
|
24
|
-
if (value === void 0) {
|
|
25
|
-
value = await context.context.get(`_outputs.${sourceKey}`);
|
|
26
|
-
}
|
|
27
|
-
subflowInitialContext[targetKey] = value;
|
|
28
|
-
}
|
|
29
|
-
} else if (context.input !== void 0) {
|
|
30
|
-
const subAnalysis2 = analyzeBlueprint(subBlueprint);
|
|
31
|
-
for (const startNodeId of subAnalysis2.startNodeIds) {
|
|
32
|
-
const inputKey = `_inputs.${startNodeId}`;
|
|
33
|
-
subflowInitialContext[inputKey] = context.input;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const subflowState = new WorkflowState(subflowInitialContext);
|
|
37
|
-
const subflowExecContext = new ExecutionContext(
|
|
38
|
-
subBlueprint,
|
|
39
|
-
subflowState,
|
|
40
|
-
runtime.nodeRegistry,
|
|
41
|
-
runtime.executionId,
|
|
42
|
-
runtime.runtime,
|
|
43
|
-
runtime.services,
|
|
44
|
-
runtime.signal,
|
|
45
|
-
runtime.concurrency
|
|
46
|
-
);
|
|
47
|
-
const subflowTraverser = new GraphTraverser(subBlueprint);
|
|
48
|
-
const subflowResult = await runtime.runtime.orchestrator.run(subflowExecContext, subflowTraverser);
|
|
49
|
-
if (subflowResult.status === "awaiting") {
|
|
50
|
-
await workflowState.markAsAwaiting(this.nodeId ?? "");
|
|
51
|
-
const subflowStateKey = `_subflowState.${this.nodeId}`;
|
|
52
|
-
await context.context.set(subflowStateKey, subflowResult.serializedContext);
|
|
53
|
-
return { output: void 0 };
|
|
54
|
-
}
|
|
55
|
-
if (subflowResult.status !== "completed") {
|
|
56
|
-
const firstError = subflowResult.errors?.[0];
|
|
57
|
-
const errorMessage = firstError?.message || "Unknown error";
|
|
58
|
-
throw new FlowcraftError(
|
|
59
|
-
`Sub-workflow '${blueprintId}' did not complete successfully. Status: ${subflowResult.status}. Error: ${errorMessage}`,
|
|
60
|
-
{
|
|
61
|
-
cause: firstError,
|
|
62
|
-
nodeId: this.nodeId,
|
|
63
|
-
blueprintId
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
const subflowFinalContext = subflowResult.context;
|
|
68
|
-
if (outputs) {
|
|
69
|
-
for (const [parentKey, subKey] of Object.entries(outputs)) {
|
|
70
|
-
const value = subflowFinalContext[`_outputs.${subKey}`] ?? subflowFinalContext[subKey];
|
|
71
|
-
await context.context.set(parentKey, value);
|
|
72
|
-
}
|
|
73
|
-
return { output: subflowFinalContext };
|
|
74
|
-
}
|
|
75
|
-
const subAnalysis = analyzeBlueprint(subBlueprint);
|
|
76
|
-
if (subAnalysis.terminalNodeIds.length === 1) {
|
|
77
|
-
const terminalId = subAnalysis.terminalNodeIds[0];
|
|
78
|
-
return { output: subflowFinalContext[`_outputs.${terminalId}`] };
|
|
79
|
-
}
|
|
80
|
-
const terminalOutputs = {};
|
|
81
|
-
for (const terminalId of subAnalysis.terminalNodeIds) {
|
|
82
|
-
terminalOutputs[terminalId] = subflowFinalContext[`_outputs.${terminalId}`];
|
|
83
|
-
}
|
|
84
|
-
return { output: terminalOutputs };
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export { SubflowNode };
|
|
89
|
-
//# sourceMappingURL=chunk-7EMUOH77.js.map
|
|
90
|
-
//# sourceMappingURL=chunk-7EMUOH77.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/nodes/subflow.ts"],"names":["subAnalysis"],"mappings":";;;;;;;;AAQO,IAAM,WAAA,GAAN,cAA0B,QAAA,CAAS;AAAA,EACzC,MAAM,IAAA,CACL,WAAA,EACA,OAAA,EACqC;AACrC,IAAA,MAAM,EAAE,WAAA,EAAa,MAAA,EAAQ,SAAQ,GAAI,IAAA,CAAK,UAAU,EAAC;AACzD,IAAA,MAAM,EAAE,OAAA,EAAS,aAAA,EAAc,GAAI,OAAA,CAAQ,YAAA;AAE3C,IAAA,IAAI,CAAC,WAAA,EAAa;AACjB,MAAA,MAAM,IAAI,eAAe,CAAA,cAAA,EAAiB,IAAA,CAAK,MAAM,CAAA,qCAAA,CAAA,EAAyC,EAAE,OAAA,EAAS,IAAA,EAAM,CAAA;AAAA,IAChH;AAEA,IAAA,MAAM,YAAA,GACJ,QAAgB,UAAA,GAAa,WAAW,KAAM,OAAA,CAAgB,OAAA,EAAS,aAAa,WAAW,CAAA;AACjG,IAAA,IAAI,CAAC,YAAA,EAAc;AAClB,MAAA,MAAM,IAAI,eAAe,CAAA,eAAA,EAAkB,WAAW,oCAAoC,EAAE,OAAA,EAAS,MAAM,CAAA;AAAA,IAC5G;AAEA,IAAA,MAAM,wBAA6C,EAAC;AAEpD,IAAA,IAAI,MAAA,EAAQ;AAEX,MAAA,KAAA,MAAW,CAAC,SAAA,EAAW,SAAS,KAAK,MAAA,CAAO,OAAA,CAAQ,MAAgC,CAAA,EAAG;AACtF,QAAA,IAAI,KAAA,GAAQ,MAAM,OAAA,CAAQ,OAAA,CAAQ,IAAI,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AAA,SAAA,EAAY,UAAU,EAAE,CAAA,EAAE;AAAA,IAChE;AAEA,IAAA,MAAM,kBAAuC,EAAC;AAC9C,IAAA,KAAA,MAAW,UAAA,IAAc,YAAY,eAAA,EAAiB;AACrD,MAAA,eAAA,CAAgB,UAAU,CAAA,GAAI,mBAAA,CAAoB,CAAA,SAAA,EAAY,UAAU,CAAA,CAAE,CAAA;AAAA,IAC3E;AACA,IAAA,OAAO,EAAE,QAAQ,eAAA,EAAgB;AAAA,EAClC;AACD","file":"chunk-7EMUOH77.js","sourcesContent":["import { analyzeBlueprint } from '../analysis'\nimport { FlowcraftError } from '../errors'\nimport { BaseNode } from '../node'\nimport { ExecutionContext } from '../runtime/execution-context'\nimport { WorkflowState } from '../runtime/state'\nimport { GraphTraverser } from '../runtime/traverser'\nimport type { NodeContext, NodeResult } from '../types'\n\nexport class SubflowNode extends BaseNode {\n\tasync exec(\n\t\t_prepResult: any,\n\t\tcontext: NodeContext<Record<string, any>, any, any>,\n\t): Promise<Omit<NodeResult, 'error'>> {\n\t\tconst { blueprintId, inputs, outputs } = this.params ?? {}\n\t\tconst { runtime, workflowState } = context.dependencies\n\n\t\tif (!blueprintId) {\n\t\t\tthrow new FlowcraftError(`Subflow node '${this.nodeId}' is missing 'blueprintId' parameter.`, { isFatal: true })\n\t\t}\n\n\t\tconst subBlueprint =\n\t\t\t(runtime as any).blueprints?.[blueprintId] || (runtime as any).runtime?.blueprints?.[blueprintId]\n\t\tif (!subBlueprint) {\n\t\t\tthrow new FlowcraftError(`Sub-blueprint '${blueprintId}' not found in runtime registry.`, { isFatal: true })\n\t\t}\n\n\t\tconst subflowInitialContext: Record<string, any> = {}\n\n\t\tif (inputs) {\n\t\t\t// explicit inputs\n\t\t\tfor (const [targetKey, sourceKey] of Object.entries(inputs as Record<string, string>)) {\n\t\t\t\tlet value = await context.context.get(sourceKey as any)\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tvalue = await context.context.get(`_outputs.${sourceKey}` as any)\n\t\t\t\t}\n\t\t\t\tsubflowInitialContext[targetKey] = value\n\t\t\t}\n\t\t} else if (context.input !== undefined) {\n\t\t\t// pass the parent node's input to the subflow's start nodes\n\t\t\tconst subAnalysis = analyzeBlueprint(subBlueprint)\n\t\t\tfor (const startNodeId of subAnalysis.startNodeIds) {\n\t\t\t\tconst inputKey = `_inputs.${startNodeId}`\n\t\t\t\tsubflowInitialContext[inputKey] = context.input\n\t\t\t}\n\t\t}\n\n\t\tconst subflowState = new WorkflowState(subflowInitialContext)\n\t\tconst subflowExecContext = new ExecutionContext(\n\t\t\tsubBlueprint,\n\t\t\tsubflowState,\n\t\t\truntime.nodeRegistry,\n\t\t\truntime.executionId,\n\t\t\truntime.runtime,\n\t\t\truntime.services,\n\t\t\truntime.signal,\n\t\t\truntime.concurrency,\n\t\t)\n\t\tconst subflowTraverser = new GraphTraverser(subBlueprint)\n\n\t\tconst subflowResult = await runtime.runtime.orchestrator.run(subflowExecContext, subflowTraverser)\n\n\t\tif (subflowResult.status === 'awaiting') {\n\t\t\tawait workflowState.markAsAwaiting(this.nodeId ?? '')\n\t\t\tconst subflowStateKey = `_subflowState.${this.nodeId}`\n\t\t\tawait context.context.set(subflowStateKey as any, subflowResult.serializedContext)\n\t\t\treturn { output: undefined }\n\t\t}\n\n\t\tif (subflowResult.status !== 'completed') {\n\t\t\tconst firstError = subflowResult.errors?.[0]\n\t\t\tconst errorMessage = firstError?.message || 'Unknown error'\n\t\t\tthrow new FlowcraftError(\n\t\t\t\t`Sub-workflow '${blueprintId}' did not complete successfully. Status: ${subflowResult.status}. Error: ${errorMessage}`,\n\t\t\t\t{\n\t\t\t\t\tcause: firstError,\n\t\t\t\t\tnodeId: this.nodeId,\n\t\t\t\t\tblueprintId,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\n\t\tconst subflowFinalContext = subflowResult.context as Record<string, any>\n\n\t\tif (outputs) {\n\t\t\tfor (const [parentKey, subKey] of Object.entries(outputs as Record<string, string>)) {\n\t\t\t\tconst value = subflowFinalContext[`_outputs.${subKey}`] ?? subflowFinalContext[subKey]\n\t\t\t\tawait context.context.set(parentKey as any, value)\n\t\t\t}\n\t\t\treturn { output: subflowFinalContext }\n\t\t}\n\n\t\tconst subAnalysis = analyzeBlueprint(subBlueprint)\n\t\tif (subAnalysis.terminalNodeIds.length === 1) {\n\t\t\tconst terminalId = subAnalysis.terminalNodeIds[0]\n\t\t\treturn { output: subflowFinalContext[`_outputs.${terminalId}`] }\n\t\t}\n\n\t\tconst terminalOutputs: Record<string, any> = {}\n\t\tfor (const terminalId of subAnalysis.terminalNodeIds) {\n\t\t\tterminalOutputs[terminalId] = subflowFinalContext[`_outputs.${terminalId}`]\n\t\t}\n\t\treturn { output: terminalOutputs }\n\t}\n}\n"]}
|
package/dist/chunk-7M6FHFHP.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DefaultOrchestrator } from './chunk-DV2CXHOY.js';
|
|
2
|
-
import { NullLogger } from './chunk-4PELJWF7.js';
|
|
3
|
-
import { JsonSerializer } from './chunk-6RKHCJUU.js';
|
|
4
|
-
import { DIContainer, ServiceTokens } from './chunk-WWGFIYKW.js';
|
|
5
|
-
import { PropertyEvaluator } from './chunk-PH2IYZHV.js';
|
|
6
|
-
|
|
7
|
-
// src/container-factory.ts
|
|
8
|
-
function createDefaultContainer(options = {}) {
|
|
9
|
-
const container = new DIContainer();
|
|
10
|
-
container.register(ServiceTokens.Logger, options.logger || new NullLogger());
|
|
11
|
-
container.register(ServiceTokens.Serializer, options.serializer || new JsonSerializer());
|
|
12
|
-
container.register(ServiceTokens.Evaluator, options.evaluator || new PropertyEvaluator());
|
|
13
|
-
container.register(ServiceTokens.EventBus, options.eventBus || { emit: async () => {
|
|
14
|
-
} });
|
|
15
|
-
container.register(ServiceTokens.Middleware, options.middleware || []);
|
|
16
|
-
container.register(ServiceTokens.NodeRegistry, options.registry || {});
|
|
17
|
-
container.register(ServiceTokens.BlueprintRegistry, options.blueprints || {});
|
|
18
|
-
container.register(ServiceTokens.Dependencies, options.dependencies || {});
|
|
19
|
-
container.registerFactory(ServiceTokens.Orchestrator, () => new DefaultOrchestrator());
|
|
20
|
-
return container;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { createDefaultContainer };
|
|
24
|
-
//# sourceMappingURL=chunk-7M6FHFHP.js.map
|
|
25
|
-
//# sourceMappingURL=chunk-7M6FHFHP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/container-factory.ts"],"names":[],"mappings":";;;;;;;AA4BO,SAAS,sBAAA,CACf,OAAA,GAA2C,EAAC,EAC9B;AACd,EAAA,MAAM,SAAA,GAAY,IAAI,WAAA,EAAY;AAElC,EAAA,SAAA,CAAU,SAAS,aAAA,CAAc,MAAA,EAAQ,QAAQ,MAAA,IAAU,IAAI,YAAY,CAAA;AAC3E,EAAA,SAAA,CAAU,SAAS,aAAA,CAAc,UAAA,EAAY,QAAQ,UAAA,IAAc,IAAI,gBAAgB,CAAA;AACvF,EAAA,SAAA,CAAU,SAAS,aAAA,CAAc,SAAA,EAAW,QAAQ,SAAA,IAAa,IAAI,mBAAmB,CAAA;AACxF,EAAA,SAAA,CAAU,SAAS,aAAA,CAAc,QAAA,EAAU,QAAQ,QAAA,IAAY,EAAE,MAAM,YAAY;AAAA,EAAC,GAAG,CAAA;AACvF,EAAA,SAAA,CAAU,SAAS,aAAA,CAAc,UAAA,EAAY,OAAA,CAAQ,UAAA,IAAc,EAAE,CAAA;AACrE,EAAA,SAAA,CAAU,SAAS,aAAA,CAAc,YAAA,EAAc,OAAA,CAAQ,QAAA,IAAY,EAAE,CAAA;AACrE,EAAA,SAAA,CAAU,SAAS,aAAA,CAAc,iBAAA,EAAmB,OAAA,CAAQ,UAAA,IAAc,EAAE,CAAA;AAC5E,EAAA,SAAA,CAAU,SAAS,aAAA,CAAc,YAAA,EAAc,OAAA,CAAQ,YAAA,IAAiB,EAAoB,CAAA;AAE5F,EAAA,SAAA,CAAU,gBAAgB,aAAA,CAAc,YAAA,EAAc,MAAM,IAAI,qBAAqB,CAAA;AAErF,EAAA,OAAO,SAAA;AACR","file":"chunk-7M6FHFHP.js","sourcesContent":["import { DIContainer, ServiceTokens } from './container'\nimport { PropertyEvaluator } from './evaluator'\nimport { NullLogger } from './logger'\nimport { DefaultOrchestrator } from './runtime/orchestrator'\nimport { JsonSerializer } from './serializer'\nimport type {\n\tIEvaluator,\n\tIEventBus,\n\tILogger,\n\tISerializer,\n\tMiddleware,\n\tNodeClass,\n\tNodeFunction,\n\tRuntimeDependencies,\n\tWorkflowBlueprint,\n} from './types'\n\nexport interface ContainerOptions<TDependencies extends RuntimeDependencies = RuntimeDependencies> {\n\tlogger?: ILogger\n\tserializer?: ISerializer\n\tevaluator?: IEvaluator\n\teventBus?: IEventBus\n\tmiddleware?: Middleware[]\n\tregistry?: Record<string, NodeFunction | NodeClass>\n\tblueprints?: Record<string, WorkflowBlueprint>\n\tdependencies?: TDependencies\n}\n\nexport function createDefaultContainer<TDependencies extends RuntimeDependencies = RuntimeDependencies>(\n\toptions: ContainerOptions<TDependencies> = {},\n): DIContainer {\n\tconst container = new DIContainer()\n\n\tcontainer.register(ServiceTokens.Logger, options.logger || new NullLogger())\n\tcontainer.register(ServiceTokens.Serializer, options.serializer || new JsonSerializer())\n\tcontainer.register(ServiceTokens.Evaluator, options.evaluator || new PropertyEvaluator())\n\tcontainer.register(ServiceTokens.EventBus, options.eventBus || { emit: async () => {} })\n\tcontainer.register(ServiceTokens.Middleware, options.middleware || [])\n\tcontainer.register(ServiceTokens.NodeRegistry, options.registry || {})\n\tcontainer.register(ServiceTokens.BlueprintRegistry, options.blueprints || {})\n\tcontainer.register(ServiceTokens.Dependencies, options.dependencies || ({} as TDependencies))\n\n\tcontainer.registerFactory(ServiceTokens.Orchestrator, () => new DefaultOrchestrator())\n\n\treturn container\n}\n"]}
|