/** * SSA 计划验证 Schema (Zod) */ import { z } from 'zod'; // 护栏配置 Schema export const guardrailConfigSchema = z.object({ name: z.string(), check_code: z.string().optional(), threshold: z.string().optional(), action_type: z.enum(['Block', 'Warn', 'Switch']).default('Warn'), action_target: z.string().optional(), status: z.enum(['pending', 'passed', 'failed', 'switched']).default('pending') }); // 分析计划 Schema export const analysisPlanSchema = z.object({ tool_code: z.string().regex(/^ST_[A-Z_]+$/, 'tool_code must match ST_XXX pattern'), tool_name: z.string().min(1), reasoning: z.string(), params: z.record(z.any()), guardrails: z.array(guardrailConfigSchema).optional(), confidence: z.number().min(0).max(1).optional() }); // 执行请求 Schema export const executeRequestSchema = z.object({ plan: analysisPlanSchema, confirm: z.boolean().default(true) }); // 咨询消息 Schema export const consultMessageSchema = z.object({ message: z.string().min(1, 'Message cannot be empty') }); // 类型导出 export type GuardrailConfig = z.infer; export type AnalysisPlan = z.infer; export type ExecuteRequest = z.infer; export type ConsultMessage = z.infer;