/** * Generation Types - Two-Stage Content Generation System * * Stage 1: User requirements + documents → Scene Outlines (per-page) * Stage 2: Scene Outlines → Full Scenes (slide/quiz/interactive/pbl with actions) */ import type { ActionType } from './action'; import type { MediaGenerationRequest } from '@/lib/media/types'; // ==================== PDF Image Types ==================== /** * Image extracted from PDF with metadata */ export interface PdfImage { id: string; // e.g., "img_1", "img_2" src: string; // base64 data URL (empty when stored in IndexedDB) pageNumber: number; // Page number in PDF description?: string; // Optional description for AI context storageId?: string; // Reference to IndexedDB (session_xxx_img_1) width?: number; // Image width (px or normalized) height?: number; // Image height (px or normalized) } /** * Image mapping for post-processing: image_id → base64 URL */ export type ImageMapping = Record; // ==================== Stage 1 Input ==================== export interface UploadedDocument { id: string; name: string; // Original filename type: 'pdf' | 'docx' | 'pptx' | 'txt' | 'md' | 'image' | 'other'; size: number; // Bytes uploadedAt: Date; contentSummary?: string; // Placeholder for parsing extractedTopics?: string[]; // Placeholder for parsing pageCount?: number; storageRef?: string; } /** * Simplified user requirements for course generation * All details (topic, duration, style, etc.) should be included in the requirement text */ export interface UserRequirements { requirement: string; // Single free-form text for all user input userNickname?: string; // Student nickname for personalization userBio?: string; // Student background for personalization webSearch?: boolean; // Enable web search for richer context interactiveMode?: boolean; // Enable Interactive Mode for interactive-first generation } // ==================== Stage 1 Output: Scene Outlines (Simplified) ==================== /** * Widget outline configuration for interactive scenes * Unified for both normal and ultra modes */ export interface WidgetOutline { // Common field concept?: string; // Type-specific fields keyVariables?: string[]; // simulation diagramType?: 'flowchart' | 'mindmap' | 'hierarchy' | 'system'; // diagram language?: 'python' | 'javascript' | 'typescript' | 'java' | 'cpp'; // code gameType?: 'quiz' | 'puzzle' | 'strategy' | 'card' | 'action'; // game visualizationType?: 'molecular' | 'solar' | 'anatomy' | 'geometry' | 'physics' | 'custom'; // visualization3d objects?: string[]; // visualization3d interactions?: string[]; // visualization3d challenge?: string; // game - description of what player does playerControls?: string[]; // game - what player controls nodeCount?: number; // diagram - approximate node count challengeType?: string; // code - type of coding challenge } /** * Simplified scene outline * Gives AI more freedom, only requiring intent description and key points */ export interface SceneOutline { id: string; type: 'slide' | 'quiz' | 'interactive' | 'pbl'; title: string; description: string; // 1-2 sentences describing the purpose keyPoints: string[]; // 3-5 core key points teachingObjective?: string; estimatedDuration?: number; // seconds order: number; languageNote?: string; // LLM-inferred language note for this scene // Suggested image IDs (from PDF-extracted images) suggestedImageIds?: string[]; // e.g., ["img_1", "img_3"] // AI-generated media requests (when PDF images are insufficient) mediaGenerations?: MediaGenerationRequest[]; // e.g., [{ type: 'image', prompt: '...', elementId: 'gen_img_1' }] // Quiz-specific config quizConfig?: { questionCount: number; difficulty: 'easy' | 'medium' | 'hard'; questionTypes: ('single' | 'multiple' | 'text')[]; }; /** * @deprecated Use widgetType + widgetOutline instead * Legacy interactive config - kept for backward compatibility only */ interactiveConfig?: { conceptName: string; conceptOverview: string; designIdea: string; subject?: string; }; // PBL-specific config pblConfig?: { projectTopic: string; projectDescription: string; targetSkills: string[]; issueCount?: number; }; // Widget fields (required for type === 'interactive' in unified mode) widgetType?: WidgetType; widgetOutline?: WidgetOutline; } // ==================== Stage 3 Output: Generated Content ==================== import type { PPTElement, SlideBackground } from './slides'; import type { QuizQuestion } from './stage'; /** * AI-generated slide content */ export interface GeneratedSlideContent { elements: PPTElement[]; background?: SlideBackground; remark?: string; } /** * AI-generated quiz content */ export interface GeneratedQuizContent { questions: QuizQuestion[]; } // ==================== PBL Generation Types ==================== import type { PBLProjectConfig } from '@/lib/pbl/types'; /** * AI-generated PBL content */ export interface GeneratedPBLContent { projectConfig: PBLProjectConfig; } // ==================== Interactive Generation Types ==================== import type { WidgetConfig, TeacherAction, WidgetType } from './widgets'; /** * Scientific model output from scientific modeling stage */ export interface ScientificModel { core_formulas: string[]; mechanism: string[]; constraints: string[]; forbidden_errors: string[]; } /** * AI-generated interactive content */ export interface GeneratedInteractiveContent { html: string; scientificModel?: ScientificModel; widgetType?: WidgetType; widgetConfig?: WidgetConfig; teacherActions?: TeacherAction[]; } // ==================== Legacy Types (for compatibility) ==================== export interface SuggestedSlideElement { type: 'text' | 'image' | 'shape' | 'chart' | 'latex' | 'line'; purpose: 'title' | 'subtitle' | 'content' | 'example' | 'diagram' | 'formula' | 'highlight'; contentHint: string; position?: 'top' | 'center' | 'bottom' | 'left' | 'right'; chartType?: 'bar' | 'line' | 'pie' | 'radar'; textOutline?: string[]; } export interface SuggestedQuizQuestion { type: 'single' | 'multiple' | 'short_answer'; questionOutline: string; suggestedOptions?: string[]; targetConceptId?: string; difficulty: 'easy' | 'medium' | 'hard'; } export interface SuggestedAction { type: ActionType; description: string; timing?: 'start' | 'middle' | 'end' | 'after-content'; } // ==================== Generation Session ==================== export interface GenerationProgress { currentStage: 1 | 2 | 3; overallProgress: number; // 0-100 stageProgress: number; // 0-100 statusMessage: string; scenesGenerated: number; totalScenes: number; errors?: string[]; } export interface GenerationSession { id: string; requirements: UserRequirements; sceneOutlines?: SceneOutline[]; progress: GenerationProgress; startedAt: Date; completedAt?: Date; generatedStageId?: string; }