/**
 * Analysis Workflow State Schema
 */

import { z } from 'zod';

export const analysisStateSchema = z.object({
  workspace: z.string().describe('Local workspace path'),
  
  repos: z.array(z.object({
    name: z.string(),
    url: z.string().url(),
    path: z.string().optional(),
    branch: z.string().default('main'),
    isPrimary: z.boolean().default(false),
  })).optional().describe('Repository configurations'),
  
  ticketContext: z.object({
    key: z.string().regex(/^[A-Z]+-\d+$/, 'Invalid ticket format (expected PROJ-123)').optional(),
    ticketKey: z.string().optional(),
    summary: z.string().min(1).describe('Ticket summary/title'),
    description: z.any().optional().describe('Ticket description (string or ADF object)'),
    acceptanceCriteria: z.string().optional(),
    type: z.string().optional(),
    priority: z.string().optional(),
    labels: z.array(z.string()).optional(),
    components: z.array(z.string()).optional(),
  }).describe('Jira/ticket context'),
  
  promptsDir: z.string().optional().describe('Path to prompts directory'),
  githubToken: z.string().optional().describe('GitHub personal access token'),
  model: z.string().default('auto').describe('AI model to use'),
  nodeConfigs: z.record(z.string(), z.any()).optional().describe('Per-node configuration overrides'),
  
  EXECUTION_ID: z.string().nullable().optional(),
  PROGRESS_QUEUE_URL: z.string().url().nullable().optional(),
  PROGRESS_API_URL: z.string().url().nullable().optional(),
  SQS_AUTH_TOKEN: z.string().nullable().optional(),
  PROJECT_API_TOKEN: z.string().nullable().optional(),
});
