11import { createLogger } from '@sim/logger'
22import type { Edge } from 'reactflow'
3- import { BlockPathCalculator } from '@/lib/workflows/blocks/block-path-calculator'
43import type { CanonicalModeOverrides } from '@/lib/workflows/subblocks/visibility'
54import {
65 buildCanonicalIndex ,
@@ -153,13 +152,6 @@ export class Serializer {
153152 const safeLoops = Object . keys ( canonicalLoops ) . length > 0 ? canonicalLoops : loops || { }
154153 const safeParallels =
155154 Object . keys ( canonicalParallels ) . length > 0 ? canonicalParallels : parallels || { }
156- const accessibleBlocksMap = this . computeAccessibleBlockIds (
157- blocks ,
158- edges ,
159- safeLoops ,
160- safeParallels
161- )
162-
163155 if ( validateRequired ) {
164156 this . validateSubflowsBeforeExecution ( blocks , safeLoops , safeParallels )
165157 }
@@ -170,7 +162,6 @@ export class Serializer {
170162 this . serializeBlock ( block , {
171163 validateRequired,
172164 allBlocks : blocks ,
173- accessibleBlocksMap,
174165 } )
175166 ) ,
176167 connections : edges . map ( ( edge ) => ( {
@@ -201,7 +192,6 @@ export class Serializer {
201192 options : {
202193 validateRequired : boolean
203194 allBlocks : Record < string , BlockState >
204- accessibleBlocksMap : Map < string , Set < string > >
205195 }
206196 ) : SerializedBlock {
207197 // Special handling for subflow blocks (loops, parallels, etc.)
@@ -540,46 +530,6 @@ export class Serializer {
540530 }
541531 }
542532
543- private computeAccessibleBlockIds (
544- blocks : Record < string , BlockState > ,
545- edges : Edge [ ] ,
546- loops : Record < string , Loop > ,
547- parallels : Record < string , Parallel >
548- ) : Map < string , Set < string > > {
549- const accessibleMap = new Map < string , Set < string > > ( )
550- const simplifiedEdges = edges . map ( ( edge ) => ( { source : edge . source , target : edge . target } ) )
551-
552- const starterBlock = Object . values ( blocks ) . find ( ( block ) => block . type === 'starter' )
553-
554- Object . keys ( blocks ) . forEach ( ( blockId ) => {
555- const ancestorIds = BlockPathCalculator . findAllPathNodes ( simplifiedEdges , blockId )
556- const accessibleIds = new Set < string > ( ancestorIds )
557- accessibleIds . add ( blockId )
558-
559- if ( starterBlock && ancestorIds . includes ( starterBlock . id ) ) {
560- accessibleIds . add ( starterBlock . id )
561- }
562-
563- Object . values ( loops ) . forEach ( ( loop ) => {
564- if ( ! loop ?. nodes ) return
565- if ( loop . nodes . includes ( blockId ) ) {
566- loop . nodes . forEach ( ( nodeId ) => accessibleIds . add ( nodeId ) )
567- }
568- } )
569-
570- Object . values ( parallels ) . forEach ( ( parallel ) => {
571- if ( ! parallel ?. nodes ) return
572- if ( parallel . nodes . includes ( blockId ) ) {
573- parallel . nodes . forEach ( ( nodeId ) => accessibleIds . add ( nodeId ) )
574- }
575- } )
576-
577- accessibleMap . set ( blockId , accessibleIds )
578- } )
579-
580- return accessibleMap
581- }
582-
583533 private selectToolId ( blockConfig : any , params : Record < string , any > ) : string {
584534 try {
585535 return blockConfig . tools . config ?. tool
0 commit comments