/**
 * config-schemas.ts
 *
 * Zod schemas for the promptfoo provider config blocks read by the
 * agent-observer providers. Promptfoo passes config as
 * `Record<string, unknown>`; parsing it once at the constructor turns
 * those untyped reads into a typed struct and surfaces typos / wrong
 * shapes as clear `ZodError`s instead of silent `undefined` reads.
 *
 * Lives in `eval` (not `core`) because these schemas are 1:1 with the
 * providers' constructor surfaces and have no consumers outside this
 * package. See docs/work-items/W0004.json.
 */
import { z } from "zod";
// ---------------------------------------------------------------------------
// Shared sub-schemas
// ---------------------------------------------------------------------------
/**
 * `RecorderOptions` is owned by `proxy.ts` and has its own resolution
 * logic. We accept any object here and let RequestRecorder do the rest;
 * no double-validation at this boundary.
 */
const ObserverOptionsSchema = z.record(z.string(), z.unknown());
const ReasoningSchema = z.object({
    effort: z.string().optional(),
    summary: z.string().optional(),
});
// ---------------------------------------------------------------------------
// AgenticProvider config
// ---------------------------------------------------------------------------
export const AgenticProviderConfigSchema = z.object({
    agentMode: z.enum(["naive", "optimized"]).optional(),
    allowedOrigins: z.array(z.string()).optional(),
    apiKey: z.string().optional(),
    customHeaders: z.record(z.string(), z.string()).optional(),
    docBaseUrl: z.string().optional(),
    llmsTxtUrl: z.string().optional(),
    max_completion_tokens: z.number().optional(),
    max_output_tokens: z.number().optional(),
    max_tokens: z.number().optional(),
    maxToolRounds: z.number().optional(),
    model: z.string().optional(),
    observe: z.boolean().optional(),
    observerOptions: ObserverOptionsSchema.optional(),
    priorityDomain: z.string().optional(),
    provider: z.enum(["anthropic", "openai"]).optional(),
    searchMode: z.enum(["off", "open", "origin-only"]).optional(),
    temperature: z.number().optional(),
});
// ---------------------------------------------------------------------------
// InstrumentedProvider config (provider.ts — wraps OpenAI directly)
// ---------------------------------------------------------------------------
export const InstrumentedProviderConfigSchema = z.object({
    apiKey: z.string().optional(),
    max_output_tokens: z.number().optional(),
    max_tokens: z.number().optional(),
    model: z.string().optional(),
    modelName: z.string().optional(),
    observe: z.boolean().optional(),
    observerOptions: ObserverOptionsSchema.optional(),
    reasoning: ReasoningSchema.optional(),
    reasoning_effort: z.string().optional(),
    temperature: z.number().optional(),
    verbosity: z.string().optional(),
});
