import { z } from 'zod';

export const ProviderOverrideSchema = z.object({
  extends: z.enum(['acp']).optional(),
  label: z.string().min(1).optional(),
  description: z.string().optional(),
  command: z.array(z.string().min(1)).min(1).optional(),
  env: z.record(z.string()).optional(),
  enabled: z.boolean().optional(),
  order: z.number().int().optional(),
  models: z.array(z.object({ id: z.string(), label: z.string() })).optional(),
  additionalModels: z.array(z.object({ id: z.string(), label: z.string() })).optional(),
});

export const CoderProvidersFileSchema = z.object({
  providers: z.record(ProviderOverrideSchema).default({}),
});

export const ProviderConfigPatchSchema = z.object({
  providers: z.record(ProviderOverrideSchema.nullable()).default({}),
});

export type ProviderOverride = z.infer<typeof ProviderOverrideSchema>;
export type CoderProvidersFile = z.infer<typeof CoderProvidersFileSchema>;
export type ProviderConfigPatch = z.infer<typeof ProviderConfigPatchSchema>;
