flowcraft 1.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -134
- package/dist/analysis.d.ts +43 -0
- package/dist/analysis.js +3 -0
- package/dist/chunk-4PELJWF7.js +29 -0
- package/dist/chunk-4PELJWF7.js.map +1 -0
- package/dist/chunk-55J6XMHW.js +3 -0
- package/dist/{chunk-7XUN3OQT.js.map → chunk-55J6XMHW.js.map} +1 -1
- package/dist/chunk-5EHIPX23.js +202 -0
- package/dist/chunk-5EHIPX23.js.map +1 -0
- package/dist/chunk-5QMPFUKA.js +40 -0
- package/dist/chunk-5QMPFUKA.js.map +1 -0
- package/dist/chunk-5ZWYSKMH.js +147 -0
- package/dist/chunk-5ZWYSKMH.js.map +1 -0
- package/dist/chunk-5ZXV3R5D.js +28 -0
- package/dist/chunk-5ZXV3R5D.js.map +1 -0
- package/dist/chunk-CO5BTPKI.js +410 -0
- package/dist/chunk-CO5BTPKI.js.map +1 -0
- package/dist/chunk-CSZ6EOWG.js +61 -0
- package/dist/chunk-CSZ6EOWG.js.map +1 -0
- package/dist/chunk-CYHZ2YVH.js +24 -0
- package/dist/chunk-CYHZ2YVH.js.map +1 -0
- package/dist/chunk-DSYAC4WB.js +27 -0
- package/dist/chunk-DSYAC4WB.js.map +1 -0
- package/dist/chunk-HMR2GEGE.js +3 -0
- package/dist/{chunk-F2RSES6P.js.map → chunk-HMR2GEGE.js.map} +1 -1
- package/dist/chunk-HN72TZY5.js +110 -0
- package/dist/chunk-HN72TZY5.js.map +1 -0
- package/dist/chunk-KWQHFT7E.js +49 -0
- package/dist/chunk-KWQHFT7E.js.map +1 -0
- package/dist/chunk-PH2IYZHV.js +48 -0
- package/dist/chunk-PH2IYZHV.js.map +1 -0
- package/dist/chunk-QRMUKDSP.js +141 -0
- package/dist/chunk-QRMUKDSP.js.map +1 -0
- package/dist/chunk-UETC63DP.js +65 -0
- package/dist/chunk-UETC63DP.js.map +1 -0
- package/dist/chunk-UMXW3TCY.js +165 -0
- package/dist/chunk-UMXW3TCY.js.map +1 -0
- package/dist/context.d.ts +23 -105
- package/dist/context.js +1 -1
- package/dist/errors.d.ts +15 -31
- package/dist/errors.js +1 -1
- package/dist/evaluator.d.ts +30 -0
- package/dist/evaluator.js +3 -0
- package/dist/evaluator.js.map +1 -0
- package/dist/flow.d.ts +55 -0
- package/dist/flow.js +4 -0
- package/dist/flow.js.map +1 -0
- package/dist/index.d.ts +15 -16
- package/dist/index.js +17 -25
- package/dist/linter.d.ts +24 -0
- package/dist/linter.js +4 -0
- package/dist/linter.js.map +1 -0
- package/dist/logger.d.ts +15 -40
- package/dist/logger.js +1 -1
- package/dist/node.d.ts +1 -0
- package/dist/node.js +3 -0
- package/dist/node.js.map +1 -0
- package/dist/runtime/adapter.d.ts +94 -0
- package/dist/runtime/adapter.js +15 -0
- package/dist/runtime/adapter.js.map +1 -0
- package/dist/runtime/executors.d.ts +26 -0
- package/dist/runtime/executors.js +4 -0
- package/dist/runtime/executors.js.map +1 -0
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime/index.js +16 -0
- package/dist/runtime/runtime.d.ts +34 -0
- package/dist/runtime/runtime.js +14 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/runtime/state.d.ts +21 -0
- package/dist/runtime/state.js +4 -0
- package/dist/runtime/state.js.map +1 -0
- package/dist/runtime/traverser.d.ts +25 -0
- package/dist/runtime/traverser.js +5 -0
- package/dist/runtime/traverser.js.map +1 -0
- package/dist/runtime/types.d.ts +15 -0
- package/dist/runtime/types.js +3 -0
- package/dist/sanitizer.d.ts +10 -0
- package/dist/sanitizer.js +3 -0
- package/dist/{utils/sanitize.js.map → sanitizer.js.map} +1 -1
- package/dist/serializer.d.ts +16 -0
- package/dist/serializer.js +3 -0
- package/dist/serializer.js.map +1 -0
- package/dist/types-lG3xCzp_.d.ts +206 -0
- package/dist/types.d.ts +1 -3
- package/dist/types.js +1 -1
- package/package.json +10 -21
- package/LICENSE +0 -21
- package/dist/builder/graph/graph.d.ts +0 -57
- package/dist/builder/graph/graph.js +0 -21
- package/dist/builder/graph/graph.js.map +0 -1
- package/dist/builder/graph/index.d.ts +0 -8
- package/dist/builder/graph/index.js +0 -23
- package/dist/builder/graph/internal-nodes.d.ts +0 -59
- package/dist/builder/graph/internal-nodes.js +0 -20
- package/dist/builder/graph/internal-nodes.js.map +0 -1
- package/dist/builder/graph/runner.d.ts +0 -51
- package/dist/builder/graph/runner.js +0 -21
- package/dist/builder/graph/runner.js.map +0 -1
- package/dist/builder/graph/types.d.ts +0 -3
- package/dist/builder/graph/types.js +0 -3
- package/dist/builder/index.d.ts +0 -8
- package/dist/builder/index.js +0 -24
- package/dist/builder/index.js.map +0 -1
- package/dist/builder/patterns.d.ts +0 -136
- package/dist/builder/patterns.js +0 -19
- package/dist/builder/patterns.js.map +0 -1
- package/dist/chunk-3YMBNZ77.js +0 -441
- package/dist/chunk-3YMBNZ77.js.map +0 -1
- package/dist/chunk-64DNBF5W.js +0 -36
- package/dist/chunk-64DNBF5W.js.map +0 -1
- package/dist/chunk-6QCXIRLA.js +0 -18
- package/dist/chunk-6QCXIRLA.js.map +0 -1
- package/dist/chunk-7XUN3OQT.js +0 -3
- package/dist/chunk-AOHBHYF6.js +0 -7
- package/dist/chunk-AOHBHYF6.js.map +0 -1
- package/dist/chunk-BRFMFLR6.js +0 -85
- package/dist/chunk-BRFMFLR6.js.map +0 -1
- package/dist/chunk-ELEHMJPM.js +0 -13
- package/dist/chunk-ELEHMJPM.js.map +0 -1
- package/dist/chunk-F2RSES6P.js +0 -3
- package/dist/chunk-F6C6J7HK.js +0 -3
- package/dist/chunk-F6C6J7HK.js.map +0 -1
- package/dist/chunk-GMKJ34T2.js +0 -3
- package/dist/chunk-GMKJ34T2.js.map +0 -1
- package/dist/chunk-HEO3XL4Z.js +0 -328
- package/dist/chunk-HEO3XL4Z.js.map +0 -1
- package/dist/chunk-IIKTTIW5.js +0 -56
- package/dist/chunk-IIKTTIW5.js.map +0 -1
- package/dist/chunk-KOBEU2EM.js +0 -3
- package/dist/chunk-KOBEU2EM.js.map +0 -1
- package/dist/chunk-L5PK5VL2.js +0 -178
- package/dist/chunk-L5PK5VL2.js.map +0 -1
- package/dist/chunk-P3RPDZHO.js +0 -36
- package/dist/chunk-P3RPDZHO.js.map +0 -1
- package/dist/chunk-PNWOW52F.js +0 -19
- package/dist/chunk-PNWOW52F.js.map +0 -1
- package/dist/chunk-R27FIYR5.js +0 -62
- package/dist/chunk-R27FIYR5.js.map +0 -1
- package/dist/chunk-S4WFNGQG.js +0 -17
- package/dist/chunk-S4WFNGQG.js.map +0 -1
- package/dist/chunk-TS3M7MWA.js +0 -3
- package/dist/chunk-TS3M7MWA.js.map +0 -1
- package/dist/chunk-UY4PNPBX.js +0 -156
- package/dist/chunk-UY4PNPBX.js.map +0 -1
- package/dist/chunk-VMH2LRM6.js +0 -114
- package/dist/chunk-VMH2LRM6.js.map +0 -1
- package/dist/chunk-VZDHIOCH.js +0 -76
- package/dist/chunk-VZDHIOCH.js.map +0 -1
- package/dist/chunk-WGVHM7DU.js +0 -66
- package/dist/chunk-WGVHM7DU.js.map +0 -1
- package/dist/chunk-WR5PDOPP.js +0 -91
- package/dist/chunk-WR5PDOPP.js.map +0 -1
- package/dist/chunk-YR433ZDA.js +0 -20
- package/dist/chunk-YR433ZDA.js.map +0 -1
- package/dist/executors/in-memory.d.ts +0 -39
- package/dist/executors/in-memory.js +0 -6
- package/dist/executors/in-memory.js.map +0 -1
- package/dist/executors/types.d.ts +0 -3
- package/dist/executors/types.js +0 -3
- package/dist/executors/types.js.map +0 -1
- package/dist/functions.d.ts +0 -88
- package/dist/functions.js +0 -21
- package/dist/functions.js.map +0 -1
- package/dist/types-U76Ukj96.d.ts +0 -609
- package/dist/utils/analysis.d.ts +0 -75
- package/dist/utils/analysis.js +0 -3
- package/dist/utils/index.d.ts +0 -8
- package/dist/utils/index.js +0 -10
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/mermaid.d.ts +0 -46
- package/dist/utils/mermaid.js +0 -4
- package/dist/utils/mermaid.js.map +0 -1
- package/dist/utils/middleware.d.ts +0 -11
- package/dist/utils/middleware.js +0 -3
- package/dist/utils/middleware.js.map +0 -1
- package/dist/utils/sanitize.d.ts +0 -19
- package/dist/utils/sanitize.js +0 -3
- package/dist/utils/sleep.d.ts +0 -9
- package/dist/utils/sleep.js +0 -4
- package/dist/utils/sleep.js.map +0 -1
- package/dist/workflow/AbstractNode.d.ts +0 -3
- package/dist/workflow/AbstractNode.js +0 -4
- package/dist/workflow/AbstractNode.js.map +0 -1
- package/dist/workflow/Flow.d.ts +0 -3
- package/dist/workflow/Flow.js +0 -16
- package/dist/workflow/Flow.js.map +0 -1
- package/dist/workflow/Node.d.ts +0 -3
- package/dist/workflow/Node.js +0 -15
- package/dist/workflow/Node.js.map +0 -1
- package/dist/workflow/index.d.ts +0 -4
- package/dist/workflow/index.js +0 -18
- package/dist/workflow/index.js.map +0 -1
- package/dist/workflow/node-patterns.d.ts +0 -55
- package/dist/workflow/node-patterns.js +0 -16
- package/dist/workflow/node-patterns.js.map +0 -1
- package/dist/workflow/registry.d.ts +0 -17
- package/dist/workflow/registry.js +0 -3
- package/dist/workflow/registry.js.map +0 -1
- /package/dist/{utils/analysis.js.map → analysis.js.map} +0 -0
- /package/dist/{builder/graph → runtime}/index.js.map +0 -0
- /package/dist/{builder/graph → runtime}/types.js.map +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/builder/graph/graph.ts","../src/builder/graph/runner.ts"],"names":["result"],"mappings":";;;;;;;;AAqCO,SAAS,mBAGd,QAAA,EAA+D;AAChE,EAAA,MAAM,aAAA,uBAAkC,GAAA,EAAI;AAE5C,EAAA,KAAA,MAAW,OAAO,QAAA,EAAU;AAC3B,IAAA,IAAI,MAAA,CAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,UAAU,GAAG,CAAA;AACrD,M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AA;AAAA,EAOO,WAAA,CAAY,MAAoB,MAAA,EAAuC;AAG7E,IAAA,OAAO,IAAA,CAAK,UAAA,CAAW,GAAA,CAAI,MAAM,IAAI,CAAC,CAAA;AAAA,EACvC;AACD","file":"chunk-3YMBNZ77.js","sourcesContent":["import type { Logger } from '../../logger'\nimport type { AbstractNode, Flow } from '../../workflow/index'\nimport type {\n\tBlueprintBuildResult,\n\tBuildResult,\n\tGraphBuilderOptions,\n\tGraphEdge,\n\tGraphNode,\n\tNodeRegistry,\n\tNodeTypeMap,\n\tOriginalPredecessorIdMap,\n\tPredecessorIdMap,\n\tSubWorkflowResolver,\n\tTypedNodeRegistry,\n\tTypedWorkflowGraph,\n\tWorkflowBlueprint,\n\tWorkflowGraph,\n} from './types'\nimport { NullLogger } from '../../logger'\nimport { DEFAULT_ACTION } from '../../types'\nimport { generateMermaidGraph } from '../../utils/mermaid'\nimport {\n\tConditionalJoinNode,\n\tInputMappingNode,\n\tOutputMappingNode,\n\tParallelBranchContainer,\n\tSubWorkflowContainerNode,\n} from './internal-nodes'\nimport { BlueprintExecutor } from './runner'\n\n/**\n * A smart factory that takes an object of custom node classes and returns a fully\n * prepared `NodeRegistry` map with all internal nodes required by the GraphBuilder.\n *\n * @param registry An object where keys are node type strings and values are the corresponding Node constructors.\n * @returns A `Map` instance ready to be used by the `GraphBuilder` or a custom executor.\n */\nexport function createNodeRegistry<\n\tTNodeMap extends NodeTypeMap,\n\tTContext = object,\n>(registry: TypedNodeRegistry<TNodeMap, TContext>): NodeRegistry {\n\tconst finalRegistry: NodeRegistry = new Map()\n\n\tfor (const key in registry) {\n\t\tif (Object.prototype.hasOwnProperty.call(registry, key))\n\t\t\tfinalRegistry.set(key, registry[key])\n\t}\n\n\tif (!finalRegistry.has('__internal_input_mapper__'))\n\t\tfinalRegistry.set('__internal_input_mapper__', InputMappingNode as any)\n\tif (!finalRegistry.has('__internal_output_mapper__'))\n\t\tfinalRegistry.set('__internal_output_mapper__', OutputMappingNode as any)\n\tif (!finalRegistry.has('__internal_sub_workflow_container__'))\n\t\tfinalRegistry.set('__internal_sub_workflow_container__', SubWorkflowContainerNode as any)\n\tif (!finalRegistry.has('__internal_conditional_join__'))\n\t\tfinalRegistry.set('__internal_conditional_join__', ConditionalJoinNode as any)\n\tif (!finalRegistry.has('__internal_parallel_container__'))\n\t\tfinalRegistry.set('__internal_parallel_container__', ParallelBranchContainer as any)\n\n\treturn finalRegistry\n}\n\n/**\n * Constructs a serializable `WorkflowBlueprint` from a declarative `WorkflowGraph` definition.\n * The blueprint is a static, storable artifact that can be executed by a `BlueprintExecutor`.\n * @template TNodeMap A `NodeTypeMap` for validating type-safe graph definitions.\n * @template TContext The shape of the dependency injection context object.\n */\nexport class GraphBuilder<\n\tTNodeMap extends NodeTypeMap,\n\tTContext extends object = object,\n> {\n\tprivate registry: Map<string, new (...args: any[]) => AbstractNode>\n\tprivate subWorkflowNodeTypes: string[]\n\tprivate conditionalNodeTypes: string[]\n\tprivate subWorkflowResolver?: SubWorkflowResolver\n\tprivate logger: Logger\n\n\t/**\n\t * @param registry A type-safe object or a `Map` where keys are node `type` strings and\n\t * values are the corresponding `Node` class constructors. For type-safety, use `createNodeRegistry`.\n\t * @param nodeOptionsContext An optional object that is passed to every node's\n\t * constructor, useful for dependency injection (e.g., passing a database client or the builder itself).\n\t */\n\t// type-safe overload\n\tconstructor(registry: TypedNodeRegistry<TNodeMap, TContext>, nodeOptionsContext?: TContext, options?: GraphBuilderOptions, logger?: Logger)\n\t// untyped overload\n\tconstructor(registry: NodeRegistry, nodeOptionsContext?: Record<string, any>, options?: GraphBuilderOptions, logger?: Logger)\n\t// handle both cases\n\tconstructor(\n\t\tregistry: TypedNodeRegistry<TNodeMap, TContext> | NodeRegistry,\n\t\tprivate nodeOptionsContext: TContext | Record<string, any> = {},\n\t\toptions: GraphBuilderOptions = {},\n\t\tlogger: Logger = new NullLogger(),\n\t) {\n\t\tthis.logger = logger\n\t\tthis.registry = registry instanceof Map\n\t\t\t? registry\n\t\t\t: createNodeRegistry(registry as TypedNodeRegistry<TNodeMap, TContext>)\n\t\tthis.subWorkflowNodeTypes = options.subWorkflowNodeTypes ?? []\n\t\tthis.conditionalNodeTypes = options.conditionalNodeTypes ?? []\n\t\tthis.subWorkflowResolver = options.subWorkflowResolver\n\t}\n\n\tprivate _logMermaid(flow: Flow) {\n\t\tif (!(this.logger instanceof NullLogger)) {\n\t\t\tthis.logger.info('[GraphBuilder] Flattened Graph')\n\t\t\tconst mermaid = generateMermaidGraph(flow)\n\t\t\tmermaid.split('\\n').forEach(line => this.logger.info(line))\n\t\t}\n\t}\n\n\tprivate _flattenGraph(graph: WorkflowGraph, idPrefix = ''): WorkflowGraph {\n\t\tconst finalNodes: GraphNode[] = []\n\t\tconst finalEdges: GraphEdge[] = []\n\n\t\tconst localNodeIds = new Set(graph.nodes.map(n => n.id))\n\n\t\tfor (const node of graph.nodes) {\n\t\t\tconst prefixedNodeId = `${idPrefix}${node.id}`\n\t\t\tconst sanitizedId = prefixedNodeId.replace(/:/g, '_').replace(/\\W/g, '')\n\n\t\t\tconst isRegisteredSubWorkflow = this.subWorkflowNodeTypes.includes(node.type)\n\t\t\tconst hasWorkflowId = node.data && 'workflowId' in node.data\n\t\t\tconst newNodeData = JSON.parse(JSON.stringify(node.data || {}))\n\n\t\t\tif (newNodeData.inputs) {\n\t\t\t\tconst inputs = newNodeData.inputs as Record<string, string | string[]>\n\t\t\t\tfor (const [templateKey, sourcePathOrPaths] of Object.entries(inputs)) {\n\t\t\t\t\tconst sourcePaths = Array.isArray(sourcePathOrPaths) ? sourcePathOrPaths : [sourcePathOrPaths]\n\t\t\t\t\tconst newSourcePaths = sourcePaths.map((sourcePath) => {\n\t\t\t\t\t\tif (localNodeIds.has(sourcePath))\n\t\t\t\t\t\t\treturn `${idPrefix}${sourcePath}`\n\t\t\t\t\t\treturn sourcePath\n\t\t\t\t\t})\n\t\t\t\t\tinputs[templateKey] = Array.isArray(sourcePathOrPaths) ? newSourcePaths : newSourcePaths[0]\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isRegisteredSubWorkflow) {\n\t\t\t\tif (!this.subWorkflowResolver)\n\t\t\t\t\tthrow new Error('GraphBuilder: `subWorkflowResolver` must be provided in options to handle sub-workflows.')\n\n\t\t\t\tconst subWorkflowData = node.data as any\n\t\t\t\tconst subWorkflowId = subWorkflowData.workflowId\n\t\t\t\tconst subGraph: WorkflowGraph | undefined = this.subWorkflowResolver.getGraph(subWorkflowId)\n\t\t\t\tif (!subGraph)\n\t\t\t\t\tthrow new Error(`Sub-workflow with ID ${subWorkflowId} not found in resolver.`)\n\n\t\t\t\tfinalNodes.push({\n\t\t\t\t\tid: prefixedNodeId,\n\t\t\t\t\ttype: '__internal_sub_workflow_container__',\n\t\t\t\t\tdata: { ...newNodeData, originalId: node.id },\n\t\t\t\t})\n\n\t\t\t\tconst inputMapperId = `${sanitizedId}_input_mapper`\n\t\t\t\tconst outputMapperId = `${sanitizedId}_output_mapper`\n\t\t\t\tfinalNodes.push({\n\t\t\t\t\tid: inputMapperId,\n\t\t\t\t\ttype: '__internal_input_mapper__',\n\t\t\t\t\tdata: { ...(subWorkflowData.inputs || {}), originalId: node.id },\n\t\t\t\t})\n\t\t\t\tfinalNodes.push({\n\t\t\t\t\tid: outputMapperId,\n\t\t\t\t\ttype: '__internal_output_mapper__',\n\t\t\t\t\tdata: { ...(subWorkflowData.outputs || {}), originalId: node.id },\n\t\t\t\t})\n\n\t\t\t\tconst inlinedSubGraph = this._flattenGraph(subGraph, `${prefixedNodeId}:`)\n\t\t\t\tconst augmentedInlinedNodes = inlinedSubGraph.nodes.map(n => ({\n\t\t\t\t\t...n,\n\t\t\t\t\tdata: { ...(n.data || {}), isSubWorkflow: true },\n\t\t\t\t}))\n\t\t\t\tfinalNodes.push(...augmentedInlinedNodes)\n\t\t\t\tfinalEdges.push(...inlinedSubGraph.edges)\n\n\t\t\t\tfinalEdges.push({ source: prefixedNodeId, target: inputMapperId })\n\n\t\t\t\tconst subGraphStartIds = inlinedSubGraph.nodes.map(n => n.id).filter(id => !inlinedSubGraph.edges.some(e => e.target === id))\n\t\t\t\tfor (const startId of subGraphStartIds)\n\t\t\t\t\tfinalEdges.push({ source: inputMapperId, target: startId })\n\n\t\t\t\tconst subGraphTerminalIds = inlinedSubGraph.nodes.map(n => n.id).filter(id => !inlinedSubGraph.edges.some(e => e.source === id))\n\t\t\t\tfor (const terminalId of subGraphTerminalIds)\n\t\t\t\t\tfinalEdges.push({ source: terminalId, target: outputMapperId })\n\t\t\t}\n\t\t\telse if (hasWorkflowId) {\n\t\t\t\tthrow new Error(`Node with ID '${node.id}' has a 'workflowId' but its type '${node.type}' is not in 'subWorkflowNodeTypes'.`)\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfinalNodes.push({ ...node, id: prefixedNodeId, data: { ...newNodeData, originalId: node.id } })\n\t\t\t}\n\t\t}\n\n\t\t// Pass 2: Re-wire all original edges to connect to the correct nodes in the flattened graph.\n\t\tfor (const edge of graph.edges) {\n\t\t\tconst sourceNode = graph.nodes.find(n => n.id === edge.source)!\n\t\t\tconst prefixedSourceId = `${idPrefix}${edge.source}`\n\t\t\tconst prefixedTargetId = `${idPrefix}${edge.target}`\n\n\t\t\tconst isSourceSub = this.subWorkflowNodeTypes.includes(sourceNode.type)\n\t\t\tconst sanitizedSourceId = prefixedSourceId.replace(/:/g, '_').replace(/\\W/g, '')\n\n\t\t\tif (isSourceSub)\n\t\t\t\tfinalEdges.push({ ...edge, source: `${sanitizedSourceId}_output_mapper`, target: prefixedTargetId })\n\t\t\telse\n\t\t\t\tfinalEdges.push({ ...edge, source: prefixedSourceId, target: prefixedTargetId })\n\t\t}\n\t\treturn { nodes: finalNodes, edges: finalEdges }\n\t}\n\n\t/**\n\t * Builds a runnable `Flow` from a graph definition for immediate in-memory execution.\n\t * @param graph The `WorkflowGraph` object describing the flow.\n\t * @param log Whether to log the graph after flattening. Defaults to `false`.\n\t * @returns A `BuildResult` object containing the executable `flow` and a `nodeMap`.\n\t */\n\tpublic build(graph: TypedWorkflowGraph<TNodeMap>, log?: boolean): BuildResult\n\tpublic build(graph: WorkflowGraph, log?: boolean): BuildResult\n\tpublic build(graph: TypedWorkflowGraph<TNodeMap> | WorkflowGraph, log?: boolean): BuildResult {\n\t\tconst { blueprint } = this.buildBlueprint(graph as WorkflowGraph)\n\t\tconst executor = new BlueprintExecutor(blueprint, this.registry, this.nodeOptionsContext)\n\n\t\tif (log)\n\t\t\tthis._logMermaid(executor.flow)\n\n\t\treturn {\n\t\t\tflow: executor.flow,\n\t\t\tnodeMap: executor.nodeMap,\n\t\t\tpredecessorCountMap: new Map(Object.entries(blueprint.predecessorCountMap)),\n\t\t\tpredecessorIdMap: new Map(Object.entries(blueprint.originalPredecessorIdMap).map(([k, v]) => [k, v])),\n\t\t\toriginalPredecessorIdMap: new Map(Object.entries(blueprint.originalPredecessorIdMap).map(([k, v]) => [k, v])),\n\t\t}\n\t}\n\n\t/**\n\t * Builds a serializable `WorkflowBlueprint` from a graph definition.\n\t * This is the recommended method for preparing a workflow for a distributed environment.\n\t * @param graph The `WorkflowGraph` object describing the flow.\n\t * @returns A `BlueprintBuildResult` object containing the serializable `blueprint`.\n\t */\n\t// type-safe overload\n\tpublic buildBlueprint(graph: TypedWorkflowGraph<TNodeMap>): BlueprintBuildResult\n\t// untyped overload\n\tpublic buildBlueprint(graph: WorkflowGraph): BlueprintBuildResult\n\t// single implementation that handles both cases\n\tpublic buildBlueprint(graph: TypedWorkflowGraph<TNodeMap> | WorkflowGraph): BlueprintBuildResult {\n\t\tconst flatGraph = this._flattenGraph(graph as WorkflowGraph)\n\n\t\tconst conditionalNodes = flatGraph.nodes.filter(n => this.conditionalNodeTypes.includes(n.type))\n\t\tfor (const conditionalNode of conditionalNodes) {\n\t\t\tconst branches = flatGraph.edges\n\t\t\t\t.filter(e => e.source === conditionalNode.id)\n\t\t\t\t.map(e => e.target)\n\n\t\t\tif (branches.length > 1) {\n\t\t\t\tconst convergenceTargetId = this._findConditionalConvergence(branches, flatGraph)\n\t\t\t\tif (convergenceTargetId) {\n\t\t\t\t\tconst joinNodeId = `${conditionalNode.id}__conditional_join`\n\t\t\t\t\tif (!flatGraph.nodes.some(n => n.id === joinNodeId)) {\n\t\t\t\t\t\tthis.logger.debug(`[GraphBuilder] Inserting conditional join node for '${conditionalNode.id}' converging at '${convergenceTargetId}'`)\n\t\t\t\t\t\tflatGraph.nodes.push({ id: joinNodeId, type: '__internal_conditional_join__', data: {} })\n\t\t\t\t\t\tconst branchTerminalIds = this._findBranchTerminals(branches, convergenceTargetId, flatGraph)\n\t\t\t\t\t\tconst terminalsToReroute = new Set(branchTerminalIds)\n\t\t\t\t\t\tif (flatGraph.edges.some(e => e.source === conditionalNode.id && e.target === convergenceTargetId)) {\n\t\t\t\t\t\t\tterminalsToReroute.add(conditionalNode.id)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (const terminalId of terminalsToReroute) {\n\t\t\t\t\t\t\tconst edgesToUpdate = flatGraph.edges.filter(e => e.source === terminalId && e.target === convergenceTargetId)\n\t\t\t\t\t\t\tfor (const edge of edgesToUpdate) {\n\t\t\t\t\t\t\t\tedge.target = joinNodeId\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tflatGraph.edges.push({ source: joinNodeId, target: convergenceTargetId })\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst edgeGroups = flatGraph.edges.reduce((acc, edge) => {\n\t\t\tif (!acc.has(edge.source))\n\t\t\t\tacc.set(edge.source, new Map())\n\t\t\tconst sourceActions = acc.get(edge.source)!\n\t\t\tconst action = edge.action || DEFAULT_ACTION\n\t\t\tif (!sourceActions.has(action))\n\t\t\t\tsourceActions.set(action, [])\n\t\t\tsourceActions.get(action)!.push(edge.target)\n\t\t\treturn acc\n\t\t}, new Map<string, Map<any, string[]>>())\n\n\t\tconst nodesToProcess = [...flatGraph.nodes]\n\t\tfor (const sourceNode of nodesToProcess) {\n\t\t\tconst actions = edgeGroups.get(sourceNode.id)\n\t\t\tif (!actions)\n\t\t\t\tcontinue\n\n\t\t\tfor (const [action, successors] of actions.entries()) {\n\t\t\t\tif (successors.length > 1 && !this.conditionalNodeTypes.includes(sourceNode.type)) {\n\t\t\t\t\tconst parallelNodeId = `${sourceNode.id}__parallel_container`\n\t\t\t\t\tif (!flatGraph.nodes.some(n => n.id === parallelNodeId)) {\n\t\t\t\t\t\tflatGraph.nodes.push({ id: parallelNodeId, type: '__internal_parallel_container__', data: {} })\n\t\t\t\t\t\tconst edgesToReplace = flatGraph.edges.filter(e => e.source === sourceNode.id && (e.action || DEFAULT_ACTION) === action)\n\t\t\t\t\t\tflatGraph.edges = flatGraph.edges.filter(e => !edgesToReplace.includes(e))\n\t\t\t\t\t\tflatGraph.edges.push({ source: sourceNode.id, target: parallelNodeId, action: action === DEFAULT_ACTION ? undefined : String(action) })\n\t\t\t\t\t\tsuccessors.forEach(succId => flatGraph.edges.push({ source: parallelNodeId, target: succId }))\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst { predecessorIdMap, originalPredecessorIdMap } = this._createPredecessorIdMaps(flatGraph)\n\t\tconst predecessorCountMap = new Map<string, number>()\n\t\tfor (const [key, val] of predecessorIdMap.entries()) {\n\t\t\tpredecessorCountMap.set(key, val.length)\n\t\t}\n\n\t\tconst allNodeIds = new Set(flatGraph.nodes.map(n => n.id))\n\t\tfor (const id of allNodeIds) {\n\t\t\tif (!predecessorCountMap.has(id))\n\t\t\t\tpredecessorCountMap.set(id, 0)\n\t\t}\n\n\t\tconst allTargetIds = new Set(flatGraph.edges.map(e => e.target))\n\t\tconst startNodeIds = [...allNodeIds].filter(id => !allTargetIds.has(id))\n\t\tlet startNodeId: string\n\n\t\tif (startNodeIds.length === 0 && allNodeIds.size > 0)\n\t\t\tthrow new Error('GraphBuilder: This graph has a cycle and no clear start node.')\n\n\t\tif (startNodeIds.length === 1) {\n\t\t\tstartNodeId = startNodeIds[0]\n\t\t}\n\t\telse {\n\t\t\tstartNodeId = '__root_parallel_start'\n\t\t\tif (!flatGraph.nodes.some(n => n.id === startNodeId)) {\n\t\t\t\tflatGraph.nodes.push({ id: startNodeId, type: '__internal_parallel_container__', data: {} })\n\t\t\t\tfor (const id of startNodeIds)\n\t\t\t\t\tflatGraph.edges.push({ source: startNodeId, target: id })\n\t\t\t}\n\t\t}\n\n\t\tconst blueprint: WorkflowBlueprint = {\n\t\t\tnodes: flatGraph.nodes,\n\t\t\tedges: flatGraph.edges,\n\t\t\tstartNodeId,\n\t\t\tpredecessorCountMap: Object.fromEntries(predecessorCountMap.entries()),\n\t\t\toriginalPredecessorIdMap: Object.fromEntries(originalPredecessorIdMap.entries()),\n\t\t}\n\n\t\treturn { blueprint }\n\t}\n\n\tprivate _createPredecessorIdMaps(\n\t\tgraph: WorkflowGraph,\n\t): { predecessorIdMap: PredecessorIdMap, originalPredecessorIdMap: OriginalPredecessorIdMap } {\n\t\tconst predecessorIdMap: PredecessorIdMap = new Map()\n\t\tfor (const edge of graph.edges) {\n\t\t\tif (!predecessorIdMap.has(edge.target))\n\t\t\t\tpredecessorIdMap.set(edge.target, [])\n\t\t\tpredecessorIdMap.get(edge.target)!.push(edge.source)\n\t\t}\n\n\t\tconst originalPredecessorIdMap: OriginalPredecessorIdMap = new Map()\n\t\tconst nodeDataMap = new Map(graph.nodes.map(n => [n.id, n]))\n\t\tconst memo = new Map<string, string[]>()\n\n\t\tconst findOriginalProducers = (nodeId: string): string[] => {\n\t\t\tif (memo.has(nodeId))\n\t\t\t\treturn memo.get(nodeId)!\n\n\t\t\tconst nodeData = nodeDataMap.get(nodeId)\n\t\t\tif (!nodeData)\n\t\t\t\treturn []\n\n\t\t\tconst selfType = nodeData.type\n\t\t\tconst selfOriginalId = nodeData.data?.originalId ?? nodeId\n\n\t\t\t// Base Case: User-defined nodes are always the source of data.\n\t\t\tif (!selfType.startsWith('__internal_')) {\n\t\t\t\tconst result = [selfOriginalId]\n\t\t\t\tmemo.set(nodeId, result)\n\t\t\t\treturn result\n\t\t\t}\n\n\t\t\t// Special Case: The output mapper acts as the logical source for anything\n\t\t\t// outside the sub-workflow. It represents the sub-workflow's result.\n\t\t\tif (selfType === '__internal_output_mapper__') {\n\t\t\t\t// The originalId of the output_mapper is the ID of the container.\n\t\t\t\tconst result = [selfOriginalId]\n\t\t\t\tmemo.set(nodeId, result)\n\t\t\t\treturn result\n\t\t\t}\n\n\t\t\t// Recursive Step: For all other internal nodes (input_mapper, container, join),\n\t\t\t// they are transparent wiring. Look through them.\n\t\t\tconst directPredecessors = predecessorIdMap.get(nodeId) || []\n\t\t\tconst producers = new Set<string>()\n\t\t\tfor (const predId of directPredecessors) {\n\t\t\t\tfindOriginalProducers(predId).forEach(p => producers.add(p))\n\t\t\t}\n\n\t\t\tconst result = Array.from(producers)\n\t\t\tmemo.set(nodeId, result)\n\t\t\treturn result\n\t\t}\n\n\t\tfor (const targetId of nodeDataMap.keys()) {\n\t\t\tconst mapKey = targetId\n\n\t\t\tconst directPredecessors = predecessorIdMap.get(targetId) || []\n\t\t\tconst producers = new Set<string>()\n\t\t\tfor (const predId of directPredecessors)\n\t\t\t\tfindOriginalProducers(predId).forEach(p => producers.add(p))\n\n\t\t\tif (producers.size > 0)\n\t\t\t\toriginalPredecessorIdMap.set(mapKey, Array.from(producers))\n\t\t}\n\n\t\treturn { predecessorIdMap, originalPredecessorIdMap }\n\t}\n\n\tprivate _findBranchTerminals(branchStarts: string[], targetId: string, graph: WorkflowGraph): string[] {\n\t\tconst terminals: string[] = []\n\t\tfor (const start of branchStarts) {\n\t\t\tconst queue: string[] = [start]\n\t\t\tconst visitedInBranch = new Set<string>()\n\n\t\t\twhile (queue.length > 0) {\n\t\t\t\tconst currentId = queue.shift()!\n\t\t\t\tif (visitedInBranch.has(currentId))\n\t\t\t\t\tcontinue\n\t\t\t\tvisitedInBranch.add(currentId)\n\n\t\t\t\tconst successors = graph.edges.filter(e => e.source === currentId).map(e => e.target)\n\n\t\t\t\tif (successors.includes(targetId)) {\n\t\t\t\t\tif (!terminals.includes(currentId)) {\n\t\t\t\t\t\tterminals.push(currentId)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfor (const successorId of successors) {\n\t\t\t\t\t\tif (!visitedInBranch.has(successorId)) {\n\t\t\t\t\t\t\tqueue.push(successorId)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn terminals\n\t}\n\n\tprivate _findConditionalConvergence(branchStarts: string[], graph: WorkflowGraph): string | undefined {\n\t\tif (branchStarts.length <= 1)\n\t\t\treturn undefined\n\n\t\tconst queue: string[] = [...branchStarts]\n\t\t// Map<nodeId, Set<startNodeId>>\n\t\tconst visitedBy = new Map<string, Set<string>>()\n\t\tbranchStarts.forEach(startId => visitedBy.set(startId, new Set([startId])))\n\n\t\tlet head = 0\n\t\twhile (head < queue.length) {\n\t\t\tconst currentId = queue[head++]!\n\t\t\tconst successors = graph.edges.filter(e => e.source === currentId).map(e => e.target)\n\n\t\t\tfor (const successorId of successors) {\n\t\t\t\tif (!visitedBy.has(successorId))\n\t\t\t\t\tvisitedBy.set(successorId, new Set())\n\n\t\t\t\tconst visitorSet = visitedBy.get(successorId)!\n\t\t\t\tconst startingPointsVistingThisNode = visitedBy.get(currentId)!\n\n\t\t\t\tfor (const startNodeId of startingPointsVistingThisNode)\n\t\t\t\t\tvisitorSet.add(startNodeId)\n\n\t\t\t\t// If this node has been visited by paths originating from ALL unique branches, it's the one.\n\t\t\t\tif (visitorSet.size === branchStarts.length)\n\t\t\t\t\treturn successorId\n\n\t\t\t\tif (!queue.includes(successorId))\n\t\t\t\t\tqueue.push(successorId)\n\t\t\t}\n\t\t}\n\n\t\treturn undefined\n\t}\n}\n","import type { Context } from '../../context'\nimport type { IExecutor } from '../../executors/types'\nimport type { RunOptions } from '../../types'\nimport type { AbstractNode } from '../../workflow/index'\nimport type { GraphNode, NodeRegistry, TypedNodeRegistry, WorkflowBlueprint } from './types'\nimport { InMemoryExecutor } from '../../executors/in-memory'\nimport { DEFAULT_ACTION } from '../../types'\nimport { Flow } from '../../workflow/index'\nimport { createNodeRegistry } from './graph'\nimport { ParallelBranchContainer } from './internal-nodes'\n\n/**\n * An execution engine that hydrates a runnable `Flow` from a serializable\n * `WorkflowBlueprint` and runs it. This is the recommended executor for\n * distributed systems where the workflow is built once and executed many times by workers.\n */\nexport class BlueprintExecutor implements IExecutor {\n\tpublic readonly flow: Flow\n\tpublic readonly nodeMap: Map<string, AbstractNode>\n\tprivate readonly registry: NodeRegistry\n\n\tconstructor(\n\t\tprivate blueprint: WorkflowBlueprint,\n\t\tregistry: NodeRegistry | TypedNodeRegistry<any, any>,\n\t\tprivate nodeOptionsContext: Record<string, any> = {},\n\t) {\n\t\tthis.registry = registry instanceof Map ? registry : createNodeRegistry(registry)\n\t\tthis.nodeMap = this._createNodeMap(blueprint.nodes)\n\t\tthis._wireGraph()\n\t\tconst startNode = this.nodeMap.get(blueprint.startNodeId)\n\t\tif (!startNode)\n\t\t\tthrow new Error(`Blueprint start node with ID '${blueprint.startNodeId}' not found in hydrated node map.`)\n\n\t\tthis.flow = new Flow(startNode)\n\t\tthis._populateContainers()\n\t}\n\n\tprivate _populateContainers(): void {\n\t\tfor (const node of this.nodeMap.values()) {\n\t\t\tif (node instanceof ParallelBranchContainer)\n\t\t\t\tnode.nodesToRun = Array.from(node.successors.values()).flat()\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves a hydrated node instance from the blueprint by its ID.\n\t * This is useful for workers that need to execute a specific node from the graph.\n\t * @param nodeId The ID of the node to retrieve.\n\t * @returns The `AbstractNode` instance if found, otherwise `undefined`.\n\t */\n\tpublic getNode(nodeId: string): AbstractNode | undefined {\n\t\treturn this.nodeMap.get(nodeId)\n\t}\n\n\t/**\n\t * Instantiates all node objects from the blueprint's definition.\n\t * @private\n\t */\n\tprivate _createNodeMap(nodes: GraphNode[]): Map<string, AbstractNode> {\n\t\tconst nodeMap = new Map<string, AbstractNode>()\n\t\tfor (const graphNode of nodes) {\n\t\t\tconst NodeClass = this.registry.get(graphNode.type)\n\t\t\tif (!NodeClass)\n\t\t\t\tthrow new Error(`BlueprintExecutor: Node type '${graphNode.type}' not found in registry.`)\n\n\t\t\tconst nodeOptions = {\n\t\t\t\t...this.nodeOptionsContext,\n\t\t\t\tdata: { ...graphNode.data, nodeId: graphNode.id },\n\t\t\t}\n\t\t\tconst executableNode = new NodeClass(nodeOptions).withId(graphNode.id).withGraphData(graphNode)\n\t\t\tnodeMap.set(graphNode.id, executableNode)\n\t\t}\n\t\treturn nodeMap\n\t}\n\n\t/**\n\t * Wires the hydrated node instances together based on the blueprint's edges.\n\t * @private\n\t */\n\tprivate _wireGraph(): void {\n\t\tconst edgeGroups = new Map<string, Map<any, AbstractNode[]>>()\n\t\tfor (const edge of this.blueprint.edges) {\n\t\t\tconst sourceId = edge.source\n\t\t\tconst action = edge.action || DEFAULT_ACTION\n\t\t\tconst targetNode = this.nodeMap.get(edge.target)\n\t\t\tif (!targetNode)\n\t\t\t\tcontinue // Should not happen in a valid blueprint\n\n\t\t\tif (!edgeGroups.has(sourceId))\n\t\t\t\tedgeGroups.set(sourceId, new Map())\n\t\t\tconst sourceActions = edgeGroups.get(sourceId)!\n\t\t\tif (!sourceActions.has(action))\n\t\t\t\tsourceActions.set(action, [])\n\t\t\tsourceActions.get(action)!.push(targetNode)\n\t\t}\n\n\t\tfor (const [sourceId, actions] of edgeGroups.entries()) {\n\t\t\tconst sourceNode = this.nodeMap.get(sourceId)!\n\t\t\tfor (const [action, successors] of actions.entries()) {\n\t\t\t\tfor (const successor of successors)\n\t\t\t\t\tsourceNode.next(successor, action)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Executes the flow defined by the blueprint.\n\t * @param flow The flow to execute.\n\t * @param context The shared context for the workflow.\n\t * @param options Runtime options, including a logger, abort controller, or initial params.\n\t * @returns A promise that resolves with the final action of the workflow.\n\t */\n\tpublic async run<T>(flow: Flow<any, T>, context: Context, options?: RunOptions): Promise<T> {\n\t\tif (flow !== this.flow) {\n\t\t\tthrow new Error(\n\t\t\t\t'BlueprintExecutor is specialized and can only run the flow instance it was constructed with. '\n\t\t\t\t+ 'To run an arbitrary flow, use an InMemoryExecutor instance.',\n\t\t\t)\n\t\t}\n\n\t\tconst inMemoryExecutor = new InMemoryExecutor()\n\t\tconst finalOptions = { ...options, executor: this }\n\t\treturn inMemoryExecutor.run(this.flow, context, finalOptions)\n\t}\n\n\t/**\n\t * Determines the next node to execute based on the action returned by the current node.\n\t * For distributed systems, this logic would live on the orchestrator.\n\t * @internal\n\t */\n\tpublic getNextNode(curr: AbstractNode, action: any): AbstractNode | undefined {\n\t\t// In a simple execution, we take the first successor for a given action.\n\t\t// Parallelism is handled by specific container nodes.\n\t\treturn curr.successors.get(action)?.[0]\n\t}\n}\n"]}
|
package/dist/chunk-64DNBF5W.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// src/errors.ts
|
|
2
|
-
var AbortError = class extends Error {
|
|
3
|
-
constructor(message = "Workflow aborted") {
|
|
4
|
-
super(message);
|
|
5
|
-
this.name = "AbortError";
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
var WorkflowError = class extends Error {
|
|
9
|
-
/**
|
|
10
|
-
* @param message The error message.
|
|
11
|
-
* @param nodeName The name of the `Node` class where the error occurred.
|
|
12
|
-
* @param phase The lifecycle phase (`'prep'`, `'exec'`, or `'post'`) where the error was thrown.
|
|
13
|
-
* @param originalError The underlying error that was caught and wrapped.
|
|
14
|
-
*/
|
|
15
|
-
constructor(message, nodeName, phase, originalError) {
|
|
16
|
-
const combinedMessage = originalError ? `${message}: ${originalError.message}` : message;
|
|
17
|
-
super(combinedMessage);
|
|
18
|
-
this.nodeName = nodeName;
|
|
19
|
-
this.phase = phase;
|
|
20
|
-
this.originalError = originalError;
|
|
21
|
-
this.name = "WorkflowError";
|
|
22
|
-
if (originalError?.stack)
|
|
23
|
-
this.stack = `${this.stack}
|
|
24
|
-
Caused by: ${originalError.stack}`;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
var FatalWorkflowError = class extends WorkflowError {
|
|
28
|
-
constructor(message, nodeName, phase, originalError) {
|
|
29
|
-
super(message, nodeName, phase, originalError);
|
|
30
|
-
this.name = "FatalWorkflowError";
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { AbortError, FatalWorkflowError, WorkflowError };
|
|
35
|
-
//# sourceMappingURL=chunk-64DNBF5W.js.map
|
|
36
|
-
//# sourceMappingURL=chunk-64DNBF5W.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts"],"names":[],"mappings":";AAIO,IAAM,UAAA,GAAN,cAAyB,KAAA,CAAM;AAAA,EACrC,WAAA,CAAY,UAAU,kBAAA,EAAoB;AACzC,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,YAAA;AAAA,EACb;AACD;AAMO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxC,WAAA,CACC,OAAA,EACgB,QAAA,EACA,KAAA,EACA,aAAA,EACf;AACD,IAAA,MAAM,kBAAkB,aAAA,GACrB,CAAA,EAAG,OAAO,CAAA,EAAA,EAAK,aAAA,CAAc,OAAO,CAAA,CAAA,GACpC,OAAA;AAEH,IAAA,KAAA,CAAM,eAAe,CAAA;AARL,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AACA,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AACA,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA;AAOhB,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AACZ,IAAA,IAAI,aAAA,EAAe,KAAA;AAClB,MAAA,IAAA,CAAK,KAAA,GAAQ,CAAA,EAAG,IAAA,CAAK,KAAK;AAAA,WAAA,EAAgB,cAAc,KAAK,CAAA,CAAA;AAAA,EAC/D;AACD;AASO,IAAM,kBAAA,GAAN,cAAiC,aAAA,CAAc;AAAA,EACrD,WAAA,CACC,OAAA,EACA,QAAA,EACA,KAAA,EACA,aAAA,EACC;AACD,IAAA,KAAA,CAAM,OAAA,EAAS,QAAA,EAAU,KAAA,EAAO,aAAa,CAAA;AAC7C,IAAA,IAAA,CAAK,IAAA,GAAO,oBAAA;AAAA,EACb;AACD","file":"chunk-64DNBF5W.js","sourcesContent":["/**\n * Error thrown when a workflow is gracefully aborted via an `AbortSignal`.\n * This error is caught by the execution engine to halt the flow.\n */\nexport class AbortError extends Error {\n\tconstructor(message = 'Workflow aborted') {\n\t\tsuper(message)\n\t\tthis.name = 'AbortError'\n\t}\n}\n\n/**\n * A custom error class for failures within a workflow, providing additional\n * context about where and when the error occurred.\n */\nexport class WorkflowError extends Error {\n\t/**\n\t * @param message The error message.\n\t * @param nodeName The name of the `Node` class where the error occurred.\n\t * @param phase The lifecycle phase (`'prep'`, `'exec'`, or `'post'`) where the error was thrown.\n\t * @param originalError The underlying error that was caught and wrapped.\n\t */\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly nodeName: string,\n\t\tpublic readonly phase: 'prep' | 'exec' | 'post',\n\t\tpublic readonly originalError?: Error,\n\t) {\n\t\tconst combinedMessage = originalError\n\t\t\t? `${message}: ${originalError.message}`\n\t\t\t: message\n\n\t\tsuper(combinedMessage)\n\t\tthis.name = 'WorkflowError'\n\t\tif (originalError?.stack)\n\t\t\tthis.stack = `${this.stack}\\nCaused by: ${originalError.stack}`\n\t}\n}\n\n/**\n * An error thrown by a node to indicate a non-recoverable failure.\n *\n * When an executor catches this error, it should immediately terminate the\n * entire workflow run, bypassing any remaining retries, fallbacks, or\n * subsequent nodes in the graph.\n */\nexport class FatalWorkflowError extends WorkflowError {\n\tconstructor(\n\t\tmessage: string,\n\t\tnodeName: string,\n\t\tphase: 'prep' | 'exec' | 'post',\n\t\toriginalError?: Error,\n\t) {\n\t\tsuper(message, nodeName, phase, originalError)\n\t\tthis.name = 'FatalWorkflowError'\n\t}\n}\n"]}
|
package/dist/chunk-6QCXIRLA.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AbortError } from './chunk-64DNBF5W.js';
|
|
2
|
-
|
|
3
|
-
// src/utils/sleep.ts
|
|
4
|
-
async function sleep(ms, signal) {
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
if (signal?.aborted)
|
|
7
|
-
return reject(new AbortError());
|
|
8
|
-
const timeoutId = setTimeout(resolve, ms);
|
|
9
|
-
signal?.addEventListener("abort", () => {
|
|
10
|
-
clearTimeout(timeoutId);
|
|
11
|
-
reject(new AbortError());
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { sleep };
|
|
17
|
-
//# sourceMappingURL=chunk-6QCXIRLA.js.map
|
|
18
|
-
//# sourceMappingURL=chunk-6QCXIRLA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/sleep.ts"],"names":[],"mappings":";;;AAQA,eAAsB,KAAA,CAAM,IAAY,MAAA,EAAqC;AAC5E,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,OAAA,EAAS,MAAA,KAAW;AACvC,IAAA,IAAI,MAAA,EAAQ,OAAA;AACX,MAAA,OAAO,MAAA,CAAO,IAAI,UAAA,EAAY,CAAA;AAE/B,IAAA,MAAM,SAAA,GAAY,UAAA,CAAW,OAAA,EAAS,EAAE,CAAA;AACxC,IAAA,MAAA,EAAQ,gBAAA,CAAiB,SAAS,MAAM;AACvC,MAAA,YAAA,CAAa,SAAS,CAAA;AACtB,MAAA,MAAA,CAAO,IAAI,YAAY,CAAA;AAAA,IACxB,CAAC,CAAA;AAAA,EACF,CAAC,CAAA;AACF","file":"chunk-6QCXIRLA.js","sourcesContent":["import { AbortError } from '../errors'\n\n/**\n * An abortable `sleep` utility that pauses execution for a specified duration.\n * It will reject with an `AbortError` if the provided `AbortSignal` is triggered.\n * @param ms The number of milliseconds to sleep.\n * @param signal An optional `AbortSignal` to listen for cancellation.\n */\nexport async function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted)\n\t\t\treturn reject(new AbortError())\n\n\t\tconst timeoutId = setTimeout(resolve, ms)\n\t\tsignal?.addEventListener('abort', () => {\n\t\t\tclearTimeout(timeoutId)\n\t\t\treject(new AbortError())\n\t\t})\n\t})\n}\n"]}
|
package/dist/chunk-7XUN3OQT.js
DELETED
package/dist/chunk-AOHBHYF6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";AASO,IAAM,cAAA,GAAiB,OAAO,SAAS;AAGvC,IAAM,aAAA,GAAgB,OAAO,eAAe","file":"chunk-AOHBHYF6.js","sourcesContent":["import type { Context } from './context'\nimport type { IExecutor } from './executors/types'\nimport type { Logger } from './logger'\nimport type { AbstractNode } from './workflow/index'\n\n/** A generic type for key-value parameters. */\nexport type Params = Record<string, any>\n\n/** The default action returned by a node for linear progression. */\nexport const DEFAULT_ACTION = Symbol('default')\n\n/** The action returned by a `.filter()` node when the predicate fails. */\nexport const FILTER_FAILED = Symbol('filter_failed')\n\n/**\n * The standard arguments object passed to a node's lifecycle methods.\n * @template PrepRes The type of the `prepRes` property.\n * @template ExecRes The type of the `execRes` property.\n * @template TParams The type for the node's static parameters.\n */\nexport interface NodeArgs<\n\tPrepRes = any,\n\tExecRes = any,\n\tTParams extends Params = Params,\n\tTContext extends Context = Context,\n> {\n\t/** The shared, mutable context for the workflow run. */\n\tctx: TContext\n\t/** The static parameters for the node, merged from the node and flow's `withParams`. */\n\tparams: TParams\n\t/** An `AbortController` to gracefully cancel the workflow. */\n\tcontroller?: AbortController\n\t/** An `AbortSignal` for handling cancellation. */\n\tsignal?: AbortSignal\n\t/** The logger instance for the workflow run. */\n\tlogger: Logger\n\t/** The result of the `prep` phase. */\n\tprepRes: PrepRes\n\t/** The result of the `exec` phase. */\n\texecRes: ExecRes\n\t/** The final error object, available only in `execFallback`. */\n\terror?: Error\n\t/** The name of the Node's constructor, for logging. */\n\tname?: string\n\t/** A reference to the current `IExecutor` running the flow. */\n\texecutor?: IExecutor\n\t/** The actual node instance being executed. */\n\tnode?: AbstractNode\n\t/** A shared set to track visited nodes within a parallel block, preventing race conditions. @internal */\n\tvisitedInParallel?: Set<AbstractNode>\n}\n\n/**\n * The context object passed to a node's internal `_run` method.\n * @internal\n */\nexport interface NodeRunContext<TContext extends Context = Context> {\n\tctx: TContext\n\tparams: Params\n\tsignal?: AbortSignal\n\tlogger: Logger\n\texecutor?: IExecutor\n\t/** A shared set to track visited nodes within a parallel block. @internal */\n\tvisitedInParallel?: Set<AbstractNode>\n}\n\n/** Options for configuring a `Node` instance. */\nexport interface NodeOptions {\n\t/** The total number of times the `exec` phase will be attempted. Defaults to `1`. */\n\tmaxRetries?: number\n\t/** The time in milliseconds to wait between failed `exec` attempts. Defaults to `0`. */\n\twait?: number\n}\n\n/** Options for running a top-level `Flow`. */\nexport interface RunOptions {\n\t/** An `AbortController` to gracefully cancel the workflow. */\n\tcontroller?: AbortController\n\t/** An `AbortSignal` for handling cancellation. */\n\tsignal?: AbortSignal\n\t/** A `Logger` instance to receive logs from the execution engine. */\n\tlogger?: Logger\n\t/** Top-level parameters to be merged into the context for the entire run. */\n\tparams?: Params\n\t/** A custom `IExecutor` instance to run the workflow. Defaults to `InMemoryExecutor`. */\n\texecutor?: IExecutor\n}\n\n/** The function signature for the `next` function passed to middleware. */\nexport type MiddlewareNext<T = any> = (args: NodeArgs) => Promise<T>\n/** The function signature for a middleware function. */\nexport type Middleware<T = any> = (args: NodeArgs, next: MiddlewareNext<T>) => Promise<T>\n"]}
|
package/dist/chunk-BRFMFLR6.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { applyMiddleware } from './chunk-PNWOW52F.js';
|
|
2
|
-
import { AbortError } from './chunk-64DNBF5W.js';
|
|
3
|
-
import { NullLogger } from './chunk-IIKTTIW5.js';
|
|
4
|
-
|
|
5
|
-
// src/executors/in-memory.ts
|
|
6
|
-
var InMemoryExecutor = class {
|
|
7
|
-
/**
|
|
8
|
-
* A stateless, reusable method that orchestrates the traversal of a graph.
|
|
9
|
-
* It is called by `run()` for top-level flows and by `Flow.exec()` for sub-flows.
|
|
10
|
-
* @param startNode The node where the graph traversal begins.
|
|
11
|
-
* @param flowMiddleware The middleware array from the containing flow.
|
|
12
|
-
* @param context The shared workflow context.
|
|
13
|
-
* @param options The internal, normalized run options.
|
|
14
|
-
* @returns The final action from the last executed node in the graph.
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
async _orch(startNode, flowMiddleware, context, options) {
|
|
18
|
-
let currentNode = startNode;
|
|
19
|
-
let nextNode;
|
|
20
|
-
let action;
|
|
21
|
-
const { logger, signal } = options;
|
|
22
|
-
const visitedInParallel = /* @__PURE__ */ new Set();
|
|
23
|
-
while (currentNode) {
|
|
24
|
-
if (signal?.aborted)
|
|
25
|
-
throw new AbortError();
|
|
26
|
-
if (visitedInParallel.has(currentNode)) {
|
|
27
|
-
currentNode = this.getNextNode(currentNode, void 0);
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
const nodeArgs = {
|
|
31
|
-
ctx: context,
|
|
32
|
-
params: { ...options.params, ...currentNode.params },
|
|
33
|
-
signal,
|
|
34
|
-
logger,
|
|
35
|
-
prepRes: void 0,
|
|
36
|
-
execRes: void 0,
|
|
37
|
-
name: currentNode.constructor.name,
|
|
38
|
-
executor: options.executor,
|
|
39
|
-
node: currentNode,
|
|
40
|
-
visitedInParallel
|
|
41
|
-
};
|
|
42
|
-
const chain = applyMiddleware(flowMiddleware, currentNode);
|
|
43
|
-
action = await chain(nodeArgs);
|
|
44
|
-
nextNode = this.getNextNode(currentNode, action);
|
|
45
|
-
if (!nextNode)
|
|
46
|
-
return action;
|
|
47
|
-
currentNode = nextNode;
|
|
48
|
-
}
|
|
49
|
-
return void 0;
|
|
50
|
-
}
|
|
51
|
-
async run(flow, context, options) {
|
|
52
|
-
const logger = options?.logger ?? new NullLogger();
|
|
53
|
-
const combinedParams = { ...flow.params, ...options?.params };
|
|
54
|
-
const internalOptions = {
|
|
55
|
-
logger,
|
|
56
|
-
signal: options?.signal ?? options?.controller?.signal,
|
|
57
|
-
params: combinedParams,
|
|
58
|
-
executor: this
|
|
59
|
-
};
|
|
60
|
-
if (!flow.startNode) {
|
|
61
|
-
logger.debug(`Executor is running a logic-bearing flow: ${flow.constructor.name}`);
|
|
62
|
-
const chain = applyMiddleware(flow.middleware, flow);
|
|
63
|
-
return await chain({
|
|
64
|
-
...internalOptions,
|
|
65
|
-
ctx: context,
|
|
66
|
-
prepRes: void 0,
|
|
67
|
-
execRes: void 0,
|
|
68
|
-
name: flow.constructor.name
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return this._orch(flow.startNode, flow.middleware, context, internalOptions);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Determines the next node to execute based on the action returned by the current node.
|
|
75
|
-
* @internal
|
|
76
|
-
*/
|
|
77
|
-
getNextNode(curr, action) {
|
|
78
|
-
const nextNodes = curr.successors.get(action);
|
|
79
|
-
return nextNodes?.[0];
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export { InMemoryExecutor };
|
|
84
|
-
//# sourceMappingURL=chunk-BRFMFLR6.js.map
|
|
85
|
-
//# sourceMappingURL=chunk-BRFMFLR6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/executors/in-memory.ts"],"names":[],"mappings":";;;;;AAaO,IAAM,mBAAN,MAA4C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWlD,MAAa,KAAA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oB,OAAA,EAAkB,OAAA,EAAkC;AAC3F,IAAA,MAAM,MAAA,GAAS,OAAA,EAAS,MAAA,IAAU,IAAI,UAAA,EAAW;AACjD,IAAA,MAAM,iBAAiB,EAAE,GAAG,KAAK,MAAA,EAAQ,GAAG,SAAS,MAAA,EAAO;AAE5D,IAAA,MAAM,eAAA,GAAsC;AAAA,MAC3C,MAAA;AAAA,MACA,MAAA,EAAQ,OAAA,EAAS,MAAA,IAAU,OAAA,EAAS,UAAA,EAAY,MAAA;AAAA,MAChD,MAAA,EAAQ,cAAA;AAAA,MACR,QAAA,EAAU;AAAA,KACX;AAEA,IAAA,IAAI,CAAC,KAAK,SAAA,EAAW;AACpB,MAAA,MAAA,CAAO,KAAA,CAAM,CAAA,0CAAA,EAA6C,IAAA,CAAK,WAAA,CAAY,IAAI,CAAA,CAAE,CAAA;AACjF,MAAA,MAAM,KAAA,GAAQ,eAAA,CAAgB,IAAA,CAAK,UAAA,EAAY,IAAI,CAAA;AACnD,MAAA,OAAO,MAAM,KAAA,CAAM;AAAA,QAClB,GAAG,eAAA;AAAA,QACH,GAAA,EAAK,OAAA;AAAA,QACL,OAAA,EAAS,MAAA;AAAA,QACT,OAAA,EAAS,MAAA;AAAA,QACT,IAAA,EAAM,KAAK,WAAA,CAAY;AAAA,OACvB,CAAA;AAAA,IACF;AAEA,IAAA,OAAO,KAAK,KAAA,CAAS,IAAA,CAAK,WAAW,IAAA,CAAK,UAAA,EAAY,SAAS,eAAe,CAAA;AAAA,EAC/E;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,WAAA,CAAY,MAAoB,MAAA,EAAuC;AAC7E,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,UAAA,CAAW,GAAA,CAAI,MAAM,CAAA;AAG5C,IAAA,OAAO,YAAY,CAAC,CAAA;AAAA,EACrB;AACD","file":"chunk-BRFMFLR6.js","sourcesContent":["import type { Context } from '../context'\nimport type { Middleware, NodeArgs, RunOptions } from '../types'\nimport type { AbstractNode, Flow } from '../workflow/index'\nimport type { IExecutor, InternalRunOptions } from './types'\nimport { AbortError } from '../errors'\nimport { NullLogger } from '../logger'\nimport { applyMiddleware } from '../utils/middleware'\n\n/**\n * The default executor that runs a workflow within a single, in-memory process.\n * This class contains the core logic for traversing a workflow graph, applying middleware,\n * and handling node execution.\n */\nexport class InMemoryExecutor implements IExecutor {\n\t/**\n\t * A stateless, reusable method that orchestrates the traversal of a graph.\n\t * It is called by `run()` for top-level flows and by `Flow.exec()` for sub-flows.\n\t * @param startNode The node where the graph traversal begins.\n\t * @param flowMiddleware The middleware array from the containing flow.\n\t * @param context The shared workflow context.\n\t * @param options The internal, normalized run options.\n\t * @returns The final action from the last executed node in the graph.\n\t * @internal\n\t */\n\tpublic async _orch<T = any>(\n\t\tstartNode: AbstractNode,\n\t\tflowMiddleware: Middleware[],\n\t\tcontext: Context,\n\t\toptions: InternalRunOptions,\n\t): Promise<T> {\n\t\tlet currentNode: AbstractNode | undefined = startNode\n\t\tlet nextNode: AbstractNode | undefined\n\t\tlet action: any\n\n\t\tconst { logger, signal } = options\n\t\tconst visitedInParallel = new Set<AbstractNode>()\n\n\t\twhile (currentNode) {\n\t\t\tif (signal?.aborted)\n\t\t\t\tthrow new AbortError()\n\n\t\t\tif (visitedInParallel.has(currentNode)) {\n\t\t\t\tcurrentNode = this.getNextNode(currentNode, undefined)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst nodeArgs: NodeArgs = {\n\t\t\t\tctx: context,\n\t\t\t\tparams: { ...options.params, ...currentNode.params },\n\t\t\t\tsignal,\n\t\t\t\tlogger,\n\t\t\t\tprepRes: undefined,\n\t\t\t\texecRes: undefined,\n\t\t\t\tname: currentNode.constructor.name,\n\t\t\t\texecutor: options.executor,\n\t\t\t\tnode: currentNode,\n\t\t\t\tvisitedInParallel,\n\t\t\t}\n\n\t\t\tconst chain = applyMiddleware(flowMiddleware, currentNode)\n\t\t\taction = await chain(nodeArgs)\n\t\t\tnextNode = this.getNextNode(currentNode, action)\n\n\t\t\tif (!nextNode)\n\t\t\t\treturn action as T\n\n\t\t\tcurrentNode = nextNode\n\t\t}\n\n\t\treturn undefined as T\n\t}\n\n\t/**\n\t * Executes a given flow with a specific context and options.\n\t * This is the main entry point for the in-memory execution engine.\n\t * @param flow The Flow instance to execute.\n\t * @param context The shared context for the workflow.\n\t * @param options Runtime options, including a logger, abort controller, or initial params.\n\t * @returns A promise that resolves with the final action of the workflow.\n\t */\n\tpublic run<T>(flow: Flow<any, T>, context: Context, options?: RunOptions): Promise<T>\n\tpublic run(flow: Flow, context: Context, options?: RunOptions): Promise<any>\n\tpublic async run<T>(flow: Flow<any, T>, context: Context, options?: RunOptions): Promise<T> {\n\t\tconst logger = options?.logger ?? new NullLogger()\n\t\tconst combinedParams = { ...flow.params, ...options?.params }\n\n\t\tconst internalOptions: InternalRunOptions = {\n\t\t\tlogger,\n\t\t\tsignal: options?.signal ?? options?.controller?.signal,\n\t\t\tparams: combinedParams,\n\t\t\texecutor: this,\n\t\t}\n\n\t\tif (!flow.startNode) {\n\t\t\tlogger.debug(`Executor is running a logic-bearing flow: ${flow.constructor.name}`)\n\t\t\tconst chain = applyMiddleware(flow.middleware, flow)\n\t\t\treturn await chain({\n\t\t\t\t...internalOptions,\n\t\t\t\tctx: context,\n\t\t\t\tprepRes: undefined,\n\t\t\t\texecRes: undefined,\n\t\t\t\tname: flow.constructor.name,\n\t\t\t})\n\t\t}\n\n\t\treturn this._orch<T>(flow.startNode, flow.middleware, context, internalOptions)\n\t}\n\n\t/**\n\t * Determines the next node to execute based on the action returned by the current node.\n\t * @internal\n\t */\n\tpublic getNextNode(curr: AbstractNode, action: any): AbstractNode | undefined {\n\t\tconst nextNodes = curr.successors.get(action)\n\t\t// For the in-memory executor, we take the first successor for a given action.\n\t\t// Parallelism is handled by specific container nodes like ParallelFlow.\n\t\treturn nextNodes?.[0]\n\t}\n}\n"]}
|
package/dist/chunk-ELEHMJPM.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Node } from './chunk-HEO3XL4Z.js';
|
|
2
|
-
|
|
3
|
-
// src/workflow/node-patterns.ts
|
|
4
|
-
var ExecNode = class extends Node {
|
|
5
|
-
};
|
|
6
|
-
var PreNode = class extends Node {
|
|
7
|
-
};
|
|
8
|
-
var PostNode = class extends Node {
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export { ExecNode, PostNode, PreNode };
|
|
12
|
-
//# sourceMappingURL=chunk-ELEHMJPM.js.map
|
|
13
|
-
//# sourceMappingURL=chunk-ELEHMJPM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/workflow/node-patterns.ts"],"names":[],"mappings":";;;AAYO,IAAe,QAAA,GAAf,cAIG,IAAA,CAA4C;AAQtD;AASO,IAAe,OAAA,GAAf,cAGG,IAAA,CAAyC;AAOnD;AAUO,IAAe,QAAA,GAAf,cAIG,IAAA,CAA6C;AAQvD","file":"chunk-ELEHMJPM.js","sourcesContent":["import type { Context } from '../context'\nimport type { NodeArgs, Params } from '../types'\nimport { Node } from './Node'\n\n/**\n * A simplified base class for nodes that only need to perform a core action.\n * This pattern is ideal for nodes that receive their inputs via `params` and\n * produce an output, without needing `prep` or complex `post` branching logic.\n *\n * @template ExecRes The type of data returned by the `exec` phase.\n * @template TParams The type for the node's static parameters.\n */\nexport abstract class ExecNode<\n\tExecRes = any,\n\tTParams extends Params = Params,\n\tTContext extends Context = Context,\n> extends Node<void, ExecRes, any, TParams, TContext> {\n\t/**\n\t * (Lifecycle) Performs the core, isolated logic of the node.\n\t * This is the only phase that is retried on failure. It should not access the `Context` directly.\n\t * @param args The arguments for the node, including `prepRes`.\n\t * @returns The result of the execution.\n\t */\n\tabstract override exec(args: NodeArgs<void, void, TParams, TContext>): Promise<ExecRes>\n}\n\n/**\n * A simplified base class for nodes that only perform a side effect, such as\n * modifying the `Context` or logging. These nodes do not produce an `exec` result.\n * Their logic is typically placed in the `prep` phase.\n *\n * @template TParams The type for the node's static parameters.\n */\nexport abstract class PreNode<\n\tTParams extends Params = Params,\n\tTContext extends Context = Context,\n> extends Node<void, void, any, TParams, TContext> {\n\t/**\n\t * (Lifecycle) Prepares data or performs a side effect. Runs once before `exec`.\n\t * This is the ideal place to read from or write to the `Context`.\n\t * @param args The arguments for the node, including `ctx` and `params`.\n\t */\n\tabstract override prep(args: NodeArgs<void, void, TParams, TContext>): Promise<void>\n}\n\n/**\n * A simplified base class for nodes that make a branching decision.\n * This pattern is ideal for routing the workflow based on data in the `Context`.\n * The branching logic is placed in the `post` phase, which returns a custom action string.\n *\n * @template PostRes The type of the \"action\" string returned by the `post` phase.\n * @template TParams The type for the node's static parameters.\n */\nexport abstract class PostNode<\n\tPostRes = any,\n\tTParams extends Params = Params,\n\tTContext extends Context = Context,\n> extends Node<void, void, PostRes, TParams, TContext> {\n\t/**\n\t * (Lifecycle) Processes results and determines the next step. Runs once after `exec`.\n\t * This is the ideal place to write data to the `Context` and return an action.\n\t * @param args The arguments for the node, including `execRes`.\n\t * @returns An \"action\" string to determine which successor to execute next.\n\t */\n\tabstract override post(args: NodeArgs<void, void, TParams, TContext>): Promise<PostRes>\n}\n"]}
|
package/dist/chunk-F2RSES6P.js
DELETED
package/dist/chunk-F6C6J7HK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-F6C6J7HK.js"}
|
package/dist/chunk-GMKJ34T2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-GMKJ34T2.js"}
|