import { z } from 'zod';

export const stepRetryConfigSchema = z.object({
  /** Maximum number of retry attempts (1–5 inclusive). */
  max_attempts: z
    .number()
    .int()
    .min(1, 'max_attempts must be at least 1')
    .max(5, 'max_attempts must be at most 5'),

  /** Milliseconds to wait between retry attempts (1000–60000). */
  delay_ms: z
    .number()
    .int()
    .min(1000, 'delay_ms must be at least 1000')
    .max(60000, 'delay_ms must be at most 60000')
    .optional(),

  /** Which errors trigger a retry. Defaults to 'transient'. */
  on_error: z
    .enum(['transient', 'all'])
    .default('transient'),
});

export type StepRetryConfig = z.infer<typeof stepRetryConfigSchema>;