// App-level outline mode adapter for the server-side classroom pipeline. // The package generator remains responsible for parsing, ids, and normalization; // this adapter swaps only the prompt used for the existing Interactive Mode. import type { AICallFn, UserRequirements } from '@openmaic/generation'; import { MAX_PDF_CONTENT_CHARS } from '@/lib/constants/generation'; import { buildPrompt, PROMPT_IDS } from '@/lib/prompts'; export interface ClassroomOutlineModeContext { pdfText?: string; researchContext?: string; teacherContext?: string; userProfile?: string; availableImages?: string; hasSourceImages?: boolean; imageGenerationEnabled?: boolean; videoGenerationEnabled?: boolean; } export function buildInteractiveClassroomOutlinePrompt( requirements: UserRequirements, context: ClassroomOutlineModeContext = {}, ): { system: string; user: string } { const imageEnabled = context.imageGenerationEnabled ?? false; const videoEnabled = context.videoGenerationEnabled ?? false; const prompts = buildPrompt(PROMPT_IDS.INTERACTIVE_OUTLINES, { requirement: requirements.requirement, pdfContent: context.pdfText ? context.pdfText.substring(0, MAX_PDF_CONTENT_CHARS) : 'None', availableImages: context.availableImages || 'No images available', researchContext: context.researchContext || 'None', hasSourceImages: context.hasSourceImages ?? false, imageEnabled, videoEnabled, mediaEnabled: imageEnabled || videoEnabled, teacherContext: context.teacherContext || '', userProfile: context.userProfile || '', }); if (!prompts) throw new Error('Interactive outline prompt template not found'); return prompts; } export function applyClassroomOutlineMode( baseAiCall: AICallFn, requirements: UserRequirements, context: ClassroomOutlineModeContext = {}, ): AICallFn { if (!requirements.interactiveMode) return baseAiCall; const prompts = buildInteractiveClassroomOutlinePrompt(requirements, context); return (_systemPrompt, _userPrompt, images) => baseAiCall(prompts.system, prompts.user, images); }