/**
 * Delay Step — wait N seconds before continuing.
 * Config: { seconds: 30 }
 */

import { registerStepExecutor } from '../pipeline-engine';
import { PipelineStep, PipelineContext, StepExecutorResult } from '../../types/pipeline';

async function executeDelay(
  step: PipelineStep,
  _context: PipelineContext,
  _executionId: number
): Promise<StepExecutorResult> {
  const seconds = Number(step.config.seconds) || 0;

  if (seconds > 0) {
    console.log(`[PIPELINE:delay] Waiting ${seconds}s`);
    await new Promise(resolve => setTimeout(resolve, seconds * 1000));
  }

  return { success: true, output: { delayed_seconds: seconds } };
}

registerStepExecutor('delay', executeDelay);
