import { Module } from '@nestjs/common';
import { InMemoryInteractionCoordinationPort } from '@mosaicstack/coord';
import { CoordService } from './coord.service.js';
import { CoordController } from './coord.controller.js';
import { InteractionCoordinationController } from './interaction-coordination.controller.js';
import {
  COORDINATION_CONFIG,
  COORDINATION_PORT,
  InteractionCoordinationService,
} from './interaction-coordination.service.js';

@Module({
  providers: [
    CoordService,
    {
      provide: COORDINATION_PORT,
      useFactory: (): InMemoryInteractionCoordinationPort =>
        new InMemoryInteractionCoordinationPort(),
    },
    {
      provide: COORDINATION_CONFIG,
      useFactory: () => ({
        interactionAgentId: process.env['MOSAIC_AGENT_NAME'],
        orchestrationAgentId: process.env['MOSAIC_ORCHESTRATOR_AGENT_NAME'],
      }),
    },
    InteractionCoordinationService,
  ],
  controllers: [CoordController, InteractionCoordinationController],
  exports: [CoordService, InteractionCoordinationService],
})
export class CoordModule {}
