MCPcopy Index your code
hub / github.com/simstudioai/sim / build

Method build

apps/sim/executor/dag/builder.ts:52–111  ·  view source on GitHub ↗
(workflow: SerializedWorkflow, options: DAGBuildOptions = {})

Source from the content-addressed store, hash-verified

50 private edgeConstructor = new EdgeConstructor()
51
52 build(workflow: SerializedWorkflow, options: DAGBuildOptions = {}): DAG {
53 const { triggerBlockId, savedIncomingEdges, includeAllBlocks } = options
54
55 const dag: DAG = {
56 nodes: new Map(),
57 loopConfigs: new Map(),
58 parallelConfigs: new Map(),
59 }
60
61 this.initializeConfigs(workflow, dag)
62
63 const reachableBlocks = this.pathConstructor.execute(workflow, triggerBlockId, includeAllBlocks)
64
65 this.loopConstructor.execute(dag, reachableBlocks)
66 this.parallelConstructor.execute(dag, reachableBlocks)
67
68 const { blocksInLoops, blocksInParallels, pauseTriggerMapping } = this.nodeConstructor.execute(
69 workflow,
70 dag,
71 reachableBlocks
72 )
73
74 this.edgeConstructor.execute(
75 workflow,
76 dag,
77 blocksInParallels,
78 blocksInLoops,
79 reachableBlocks,
80 pauseTriggerMapping
81 )
82
83 if (savedIncomingEdges) {
84 logger.info('Restoring DAG incoming edges from snapshot', {
85 nodeCount: Object.keys(savedIncomingEdges).length,
86 })
87
88 for (const [nodeId, incomingEdgeArray] of Object.entries(savedIncomingEdges)) {
89 const node = dag.nodes.get(nodeId)
90
91 if (node) {
92 node.incomingEdges = new Set(incomingEdgeArray)
93 }
94 }
95 }
96
97 // Validate loop and parallel structure
98 this.validateSubflowStructure(dag)
99
100 logger.info('DAG built', {
101 totalNodes: dag.nodes.size,
102 loopCount: dag.loopConfigs.size,
103 parallelCount: dag.parallelConfigs.size,
104 allNodeIds: Array.from(dag.nodes.keys()),
105 triggerNodes: Array.from(dag.nodes.values())
106 .filter((n) => n.metadata?.isResumeTrigger)
107 .map((n) => ({ id: n.id, originalBlockId: n.metadata?.originalBlockId })),
108 })
109

Callers 9

store.test.tsFile · 0.45
MarksLabFunction · 0.45
mainFunction · 0.45
builder.test.tsFile · 0.45
executeMethod · 0.45
executeFromBlockMethod · 0.45
executor.test.tsFile · 0.45

Calls 5

initializeConfigsMethod · 0.95
infoMethod · 0.80
executeMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected