Skip to main content
Glama
review-board.js24 kB
// Review Board - Coordinates Creative Director, Brand Guardian, and QA Auditor import { agentRegistry } from './agent-registry.js'; export class ReviewBoard { constructor() { this.reviewStages = ['creative', 'brand', 'qa', 'final']; this.brandRules = new Map(); this.qualityChecklists = new Map(); this.initialized = false; } async initialize() { if (this.initialized) return; await this.loadBrandGuidelines(); await this.loadQualityChecklists(); this.initialized = true; console.log('👥 Review Board initialized'); } async loadBrandGuidelines() { try { const { Pool } = await import('pg'); const pool = new Pool({ connectionString: process.env.DATABASE_URL }); const query = `SELECT * FROM brand_guidelines WHERE enabled = true ORDER BY priority DESC`; const result = await pool.query(query); for (const row of result.rows) { this.brandRules.set(row.name, { id: row.id, category: row.category, rules: row.rules, priority: row.priority }); } // Insert default brand guidelines if none exist if (result.rows.length === 0) { await this.createDefaultBrandGuidelines(pool); } await pool.end(); } catch (error) { console.error('❌ Failed to load brand guidelines:', error); } } async loadQualityChecklists() { try { const { Pool } = await import('pg'); const pool = new Pool({ connectionString: process.env.DATABASE_URL }); const query = `SELECT * FROM checklists ORDER BY stage, name`; const result = await pool.query(query); for (const row of result.rows) { this.qualityChecklists.set(`${row.stage}_${row.name}`, { id: row.id, name: row.name, stage: row.stage, items: row.items }); } // Create default checklists if none exist if (result.rows.length === 0) { await this.createDefaultChecklists(pool); } await pool.end(); } catch (error) { console.error('❌ Failed to load quality checklists:', error); } } // Creative Director Review - Claude evaluates creative quality, character consistency, story flow async creativeReview(task, artifact, requirements) { console.log('🎨 Creative Director reviewing artifact...'); const creativeDirector = agentRegistry.getAgent('creative_director'); const reviewPrompt = ` You are the Creative Director for a puppet production studio. Review this production artifact for creative quality and alignment with requirements. Task: ${task.step} Requirements: ${JSON.stringify(requirements, null, 2)} Artifact Details: ${JSON.stringify(artifact, null, 2)} Evaluate based on: 1. Creative Quality - Does it meet professional creative standards? 2. Character Consistency - Are characters true to their established traits? 3. Story Flow - Does it advance the narrative effectively? 4. Visual/Audio Appeal - Is it engaging for the target audience? 5. Brand Alignment - Does it fit the overall production style? Requirements Analysis: - Does it fulfill all specified requirements? - Are there any creative opportunities missed? - Does it maintain puppet show charm and appeal? Provide detailed feedback with: - Overall assessment (APPROVED/NEEDS_REVISION/REJECTED) - Specific issues found - Creative suggestions for improvement - Strengths to maintain Return a JSON response with your review. `; const systemPrompt = `You are an expert Creative Director with deep experience in puppet productions, storytelling, character development, and visual appeal. You understand what makes content engaging, authentic, and professionally polished. Always provide constructive feedback that maintains creative vision while ensuring quality.`; try { const response = await agentRegistry.callAgent('creative_director', reviewPrompt, { systemPrompt: systemPrompt, jsonMode: true, maxTokens: 2048 }); if (!response.success) { throw new Error(`Creative review failed: ${response.error}`); } const review = JSON.parse(response.response); // Record review in database await this.recordReview(task.id, 'creative', creativeDirector.id, review); const approved = review.assessment?.toUpperCase() === 'APPROVED'; return { stage: 'creative', approved: approved, assessment: review.assessment, issues: review.issues || [], suggestions: review.suggestions || [], strengths: review.strengths || [], feedback: review, reviewer: 'creative_director', timestamp: new Date().toISOString() }; } catch (error) { console.error('❌ Creative review failed:', error); return { stage: 'creative', approved: false, error: error.message, reviewer: 'creative_director', timestamp: new Date().toISOString() }; } } // Brand Guardian Review - Claude checks brand compliance and style consistency async brandReview(task, artifact, creativeReview) { console.log('🛡️ Brand Guardian reviewing artifact...'); const brandGuardian = agentRegistry.getAgent('brand_guardian'); // Get applicable brand rules for this artifact type const applicableRules = Array.from(this.brandRules.values()).filter(rule => rule.category === 'all' || rule.category === artifact.artifact_type || rule.category === task.step ); const reviewPrompt = ` You are the Brand Guardian for a puppet production studio. Ensure this artifact complies with brand guidelines and maintains consistent style. Task: ${task.step} Artifact Type: ${artifact.artifact_type} Artifact Details: ${JSON.stringify(artifact, null, 2)} Previous Creative Review: ${JSON.stringify(creativeReview, null, 2)} Brand Guidelines to Check: ${JSON.stringify(applicableRules, null, 2)} Brand Compliance Check: 1. Visual Style - Consistent with established brand aesthetics? 2. Tone & Voice - Matches brand personality and values? 3. Character Representation - Aligns with brand character standards? 4. Content Appropriateness - Suitable for target audience? 5. Logo/Branding Usage - Correct application of brand elements? Quality Standards: - Professional production quality - Age-appropriate content - Cultural sensitivity - Technical specifications met Provide: - Overall compliance (APPROVED/NEEDS_REVISION/REJECTED) - Specific compliance issues - Required corrections - Brand enhancement suggestions Return a JSON response with your brand review. `; const systemPrompt = `You are a Brand Guardian responsible for maintaining consistent brand identity, ensuring compliance with guidelines, and protecting brand reputation. You understand the importance of cohesive brand experience across all production elements while supporting creative excellence.`; try { const response = await agentRegistry.callAgent('brand_guardian', reviewPrompt, { systemPrompt: systemPrompt, jsonMode: true, maxTokens: 2048 }); if (!response.success) { throw new Error(`Brand review failed: ${response.error}`); } const review = JSON.parse(response.response); // Record review in database await this.recordReview(task.id, 'brand', brandGuardian.id, review); const approved = review.compliance?.toUpperCase() === 'APPROVED'; return { stage: 'brand', approved: approved, compliance: review.compliance, issues: review.issues || [], corrections: review.corrections || [], suggestions: review.suggestions || [], feedback: review, reviewer: 'brand_guardian', timestamp: new Date().toISOString() }; } catch (error) { console.error('❌ Brand review failed:', error); return { stage: 'brand', approved: false, error: error.message, reviewer: 'brand_guardian', timestamp: new Date().toISOString() }; } } // QA Auditor Review - GPT-5 performs technical quality checks and validates specifications async qaReview(task, artifact, qualityChecks) { console.log('🔍 QA Auditor reviewing artifact...'); const qaAuditor = agentRegistry.getAgent('qa_auditor'); // Get applicable quality checklists for this task const applicableChecklists = Array.from(this.qualityChecklists.values()).filter(checklist => checklist.stage === 'qa' && (checklist.name.includes(task.step) || checklist.name === 'general') ); const reviewPrompt = ` You are the QA Auditor for a puppet production studio. Perform comprehensive technical quality assurance on this production artifact. Task: ${task.step} Artifact Type: ${artifact.artifact_type} Artifact Details: ${JSON.stringify(artifact, null, 2)} Quality Checks Required: ${JSON.stringify(qualityChecks, null, 2)} Quality Checklists: ${JSON.stringify(applicableChecklists, null, 2)} Technical QA Review Areas: 1. File/Asset Quality: - File integrity and format compliance - Resolution/quality specifications met - File size within acceptable limits - Proper naming conventions used 2. Content Specifications: - Duration/length requirements met - Scene numbering and continuity correct - Audio-visual synchronization (if applicable) - Text accuracy and formatting 3. Production Standards: - Output format compatible with next steps - Metadata properly embedded - Dependencies satisfied - Error-free generation 4. Integration Readiness: - Compatible with downstream tools - Proper scene/character references - Consistent data structure Automated Checks (if applicable): - Image dimensions and aspect ratios - Audio length matches scene requirements - JSON structure validation - File accessibility and paths Provide: - Overall quality assessment (PASS/FAIL/CONDITIONAL_PASS) - Specific technical issues found - Required fixes before approval - Recommended improvements - Risk assessment for downstream steps Return a JSON response with detailed QA results. `; const systemPrompt = `You are a meticulous QA Auditor with expertise in production quality assurance, technical specifications, and process validation. You ensure all artifacts meet professional standards and are ready for the next production phase. You catch technical issues before they cause downstream problems.`; try { const response = await agentRegistry.callAgent('qa_auditor', reviewPrompt, { systemPrompt: systemPrompt, jsonMode: true, maxTokens: 3072 }); if (!response.success) { throw new Error(`QA review failed: ${response.error}`); } const review = JSON.parse(response.response); // Record review in database await this.recordReview(task.id, 'qa', qaAuditor.id, review); const approved = review.assessment?.toUpperCase() === 'PASS' || review.assessment?.toUpperCase() === 'CONDITIONAL_PASS'; return { stage: 'qa', approved: approved, assessment: review.assessment, issues: review.issues || [], fixes_required: review.fixes_required || [], improvements: review.improvements || [], risk_assessment: review.risk_assessment, feedback: review, reviewer: 'qa_auditor', timestamp: new Date().toISOString() }; } catch (error) { console.error('❌ QA review failed:', error); return { stage: 'qa', approved: false, error: error.message, reviewer: 'qa_auditor', timestamp: new Date().toISOString() }; } } // Final Review - Overall production readiness async finalReview(workflow, results) { console.log('🏆 Conducting final production review...'); const orchestrator = agentRegistry.getAgent('orchestrator'); const finalReviewPrompt = ` You are conducting the final review for a completed puppet production workflow. Workflow: ${workflow.name} Description: ${workflow.description} Production Results: - Completed Tasks: ${results.completedTasks.length} - Generated Artifacts: ${results.artifacts.length} - Approval Records: ${results.approvals.length} - Errors Encountered: ${results.errors.length} Results Summary: ${JSON.stringify(results, null, 2)} Final Review Criteria: 1. Completeness - All required production steps completed? 2. Quality - All artifacts meet professional standards? 3. Consistency - Character and story continuity maintained? 4. Technical Readiness - Ready for final video assembly? 5. Brand Compliance - Meets all brand guidelines? Error Analysis: - Were any critical errors encountered? - Do any errors impact final production quality? - Are there any unresolved issues? Overall Assessment: - Is the production ready for final delivery? - What are the key strengths of this production? - Are there any remaining risks or concerns? Provide final production approval with: - APPROVED/NEEDS_WORK/REJECTED status - Summary of production quality - Any final recommendations - Risk assessment for delivery Return a JSON response with the final review. `; try { const response = await agentRegistry.callAgent('orchestrator', finalReviewPrompt, { systemPrompt: 'You are an expert production supervisor conducting final quality assurance. Provide thorough assessment of production readiness.', jsonMode: true, maxTokens: 2048 }); if (!response.success) { throw new Error(`Final review failed: ${response.error}`); } const review = JSON.parse(response.response); const approved = review.status?.toUpperCase() === 'APPROVED'; return { stage: 'final', approved: approved, status: review.status, summary: review.summary, strengths: review.strengths || [], recommendations: review.recommendations || [], risk_assessment: review.risk_assessment, feedback: review, reviewer: 'orchestrator', timestamp: new Date().toISOString() }; } catch (error) { console.error('❌ Final review failed:', error); return { stage: 'final', approved: false, error: error.message, reviewer: 'orchestrator', timestamp: new Date().toISOString() }; } } async recordReview(taskId, stage, agentId, reviewData) { try { const { Pool } = await import('pg'); const pool = new Pool({ connectionString: process.env.DATABASE_URL }); const status = this.determineApprovalStatus(reviewData); const query = ` INSERT INTO approvals (task_id, stage, by_agent, status, notes, feedback) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id `; const result = await pool.query(query, [ taskId, stage, agentId, status, reviewData.summary || reviewData.assessment || 'Review completed', JSON.stringify(reviewData) ]); await pool.end(); return result.rows[0].id; } catch (error) { console.error('❌ Failed to record review:', error); } } determineApprovalStatus(reviewData) { if (reviewData.assessment === 'APPROVED' || reviewData.compliance === 'APPROVED' || reviewData.assessment === 'PASS' || reviewData.status === 'APPROVED') { return 'approved'; } else if (reviewData.assessment === 'REJECTED' || reviewData.compliance === 'REJECTED' || reviewData.assessment === 'FAIL' || reviewData.status === 'REJECTED') { return 'rejected'; } else { return 'needs_revision'; } } async createDefaultBrandGuidelines(pool) { const defaultGuidelines = [ { name: 'Puppet Character Standards', category: 'character', rules: { style: 'Friendly, approachable puppet aesthetic', colors: 'Bright, vibrant but not overwhelming', size: 'Proportionate to puppet show standards', expressions: 'Clear emotions, family-friendly' }, priority: 10 }, { name: 'Content Guidelines', category: 'all', rules: { tone: 'Educational, entertaining, positive', language: 'Age-appropriate, clear, engaging', themes: 'Learning, friendship, problem-solving', content_rating: 'Family-friendly, G-rated' }, priority: 10 }, { name: 'Visual Production Standards', category: 'visual', rules: { resolution: 'HD quality minimum', lighting: 'Well-lit, clear visibility', composition: 'Balanced, engaging framing', continuity: 'Consistent visual style' }, priority: 8 } ]; for (const guideline of defaultGuidelines) { await pool.query( `INSERT INTO brand_guidelines (name, category, rules, priority) VALUES ($1, $2, $3, $4)`, [guideline.name, guideline.category, JSON.stringify(guideline.rules), guideline.priority] ); } console.log('📋 Created default brand guidelines'); } async createDefaultChecklists(pool) { const defaultChecklists = [ { name: 'Character QA', stage: 'qa', items: { checklist: [ 'Character image meets resolution requirements', 'Character traits properly documented', 'Puppet form conversion successful', 'Character consistency maintained', 'Voice profile created if required' ] } }, { name: 'Script QA', stage: 'qa', items: { checklist: [ 'Script meets duration requirements', 'Dialogue appropriate for puppet format', 'Character voices properly assigned', 'Scene transitions logical', 'Story arc complete and engaging' ] } }, { name: 'Scene QA', stage: 'qa', items: { checklist: [ 'All scenes properly numbered', 'Visual direction clear and actionable', 'Character assignments correct', 'Scene duration appropriate', 'Continuity between scenes maintained' ] } }, { name: 'Audio QA', stage: 'qa', items: { checklist: [ 'Audio quality meets standards', 'Voice matches character profile', 'Duration matches scene requirements', 'Audio levels consistent', 'No audio artifacts or distortion' ] } }, { name: 'Final Production QA', stage: 'qa', items: { checklist: [ 'All production artifacts generated', 'FFmpeg commands ready for execution', 'File paths and references correct', 'Production manifest complete', 'Ready for final video assembly' ] } } ]; for (const checklist of defaultChecklists) { await pool.query( `INSERT INTO checklists (name, stage, items) VALUES ($1, $2, $3)`, [checklist.name, checklist.stage, JSON.stringify(checklist.items)] ); } console.log('✅ Created default quality checklists'); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bermingham85/mcp-puppet-pipeline'

If you have feedback or need assistance with the MCP directory API, please join our Discord server