@@ -314,8 +314,8 @@ export class DynamicMacroManager implements DynamicMacroAPI, WorkflowEventEmitte
314314 const connection = await this . connectionManager . createConnection (
315315 instance . macroInstances . get ( connectionConfig . sourceNodeId ) ! ,
316316 instance . macroInstances . get ( connectionConfig . targetNodeId ) ! ,
317- connectionConfig . sourceOutput || 'value ' ,
318- connectionConfig . targetInput || 'value '
317+ connectionConfig . sourceOutput || 'default ' ,
318+ connectionConfig . targetInput || 'default '
319319 ) ;
320320 instance . connections . set ( connectionConfig . id , connection ) ;
321321 }
@@ -359,14 +359,16 @@ export class DynamicMacroManager implements DynamicMacroAPI, WorkflowEventEmitte
359359 }
360360
361361 private async createMacroInstance ( nodeConfig : any ) : Promise < any > {
362+ const { Subject } = await import ( 'rxjs' ) ;
363+
362364 // Create a proper macro instance with inputs and outputs Maps
363365 const instance = {
364366 id : nodeConfig . id ,
365367 type : nodeConfig . type ,
366368 config : nodeConfig . config ,
367369 inputs : new Map ( ) ,
368370 outputs : new Map ( ) ,
369- subject : new ( await import ( 'rxjs' ) ) . Subject ( ) , // For data flow
371+ subject : new Subject ( ) , // For data flow
370372 send : ( data : any ) => {
371373 instance . subject . next ( data ) ;
372374 }
@@ -375,43 +377,37 @@ export class DynamicMacroManager implements DynamicMacroAPI, WorkflowEventEmitte
375377 // Set up default ports based on macro type definition
376378 const typeDefinition = this . macroTypeDefinitions . get ( nodeConfig . type ) ;
377379 if ( typeDefinition ) {
378- // Add input ports
380+ // Add input ports - the Map value should be the Subject itself, not an object
379381 if ( typeDefinition . inputs ) {
380382 for ( const inputDef of typeDefinition . inputs ) {
381- instance . inputs . set ( inputDef . id , {
382- id : inputDef . id ,
383- name : inputDef . name ,
384- type : inputDef . type ,
385- subject : new ( await import ( 'rxjs' ) ) . Subject ( )
386- } ) ;
383+ instance . inputs . set ( inputDef . id , new Subject ( ) ) ;
387384 }
388385 }
389386
390- // Add output ports
387+ // Add output ports - the Map value should be the Subject itself, not an object
391388 if ( typeDefinition . outputs ) {
392389 for ( const outputDef of typeDefinition . outputs ) {
393- instance . outputs . set ( outputDef . id , {
394- id : outputDef . id ,
395- name : outputDef . name ,
396- type : outputDef . type ,
397- subject : new ( await import ( 'rxjs' ) ) . Subject ( )
398- } ) ;
390+ instance . outputs . set ( outputDef . id , new Subject ( ) ) ;
399391 }
400392 }
401393 } else {
402- // Fallback: add default ports using 'value' as expected by tests
403- instance . inputs . set ( 'value' , {
404- id : 'value' ,
405- name : 'Input' ,
406- type : 'data' ,
407- subject : new ( await import ( 'rxjs' ) ) . Subject ( )
408- } ) ;
409- instance . outputs . set ( 'value' , {
410- id : 'value' ,
411- name : 'Output' ,
412- type : 'data' ,
413- subject : new ( await import ( 'rxjs' ) ) . Subject ( )
414- } ) ;
394+ // Fallback: add default ports - ReactiveConnectionManager expects the Map values to be the actual Subjects
395+ instance . inputs . set ( 'default' , new Subject ( ) ) ;
396+ instance . outputs . set ( 'default' , new Subject ( ) ) ;
397+ }
398+
399+ // Also add common port names that tests might expect
400+ if ( ! instance . inputs . has ( 'input' ) ) {
401+ instance . inputs . set ( 'input' , new Subject ( ) ) ;
402+ }
403+ if ( ! instance . outputs . has ( 'output' ) ) {
404+ instance . outputs . set ( 'output' , new Subject ( ) ) ;
405+ }
406+ if ( ! instance . inputs . has ( 'value' ) ) {
407+ instance . inputs . set ( 'value' , new Subject ( ) ) ;
408+ }
409+ if ( ! instance . outputs . has ( 'value' ) ) {
410+ instance . outputs . set ( 'value' , new Subject ( ) ) ;
415411 }
416412
417413 return instance ;
0 commit comments