Skip to main content
Glama

Prompt Auto-Optimizer MCP

by sloth-wq
index.ts•9.14 kB
/** * GEPA E2E Integration Test Suite Entry Point * * This module exports all E2E testing components and provides * a unified interface for running comprehensive integration tests. */ // Core E2E Testing Components import { E2ETestRunner } from './e2e-test-runner'; import type { E2ETestConfig, E2ETestResults } from './e2e-test-runner'; import type { ScenarioResult } from './test-scenarios'; import { E2ETestHelpers, type MCPToolResult, type MemoryStats, type ComponentRecoveryResult, type CrossSystemSyncResult, type DataRecoveryResult, type CorruptionDetectionResult } from './test-helpers'; import { PerformanceBenchmarks, type BenchmarkResult, type ComprehensiveBenchmarkResult, type ConcurrentLoadResult, type MemoryProfile, type RegressionAnalysis } from './performance-benchmarks'; export { E2ETestRunner, type E2ETestConfig, type E2ETestResults, type ScenarioResult, E2ETestHelpers, type MCPToolResult, type MemoryStats, type ComponentRecoveryResult, type CrossSystemSyncResult, type DataRecoveryResult, type CorruptionDetectionResult, PerformanceBenchmarks, type BenchmarkResult, type ComprehensiveBenchmarkResult, type ConcurrentLoadResult, type MemoryProfile, type RegressionAnalysis }; /** * Quick E2E Test Runner Function * * Provides a simple interface to run the complete E2E test suite * with default configuration. */ export async function runE2ETestSuite(config?: Partial<E2ETestConfig>): Promise<E2ETestResults> { const defaultConfig: Partial<E2ETestConfig> = { maxConcurrentTests: 3, defaultTimeout: 60000, performanceThresholds: { evolutionTime: 30000, trajectoryRecording: 1000, paretoFrontierQuery: 500, memoryOperations: 100, }, retryOptions: { maxRetries: 3, baseDelay: 1000, }, }; const finalConfig = { ...defaultConfig, ...config }; const testRunner = new E2ETestRunner(finalConfig); try { await testRunner.initialize(); const results = await testRunner.runAllTests(); await testRunner.cleanup(); return results; } catch (error) { await testRunner.cleanup(); throw error; } } /** * Run Performance Benchmarks Only * * Executes only the performance benchmarking suite without * running the full E2E test suite. */ export async function runPerformanceBenchmarks(config?: Partial<E2ETestConfig>): Promise<ComprehensiveBenchmarkResult> { const testRunner = new E2ETestRunner(config); try { await testRunner.initialize(); // Create new PerformanceBenchmarks instance since environment is private const benchmarks = new PerformanceBenchmarks({ thresholds: config?.performanceThresholds || { evolutionTime: 30000, trajectoryRecording: 1000, paretoFrontierQuery: 500, memoryOperations: 100, }, maxConcurrentTests: config?.maxConcurrentTests || 3, }); const results = await benchmarks.runComprehensiveBenchmarks(); await testRunner.cleanup(); return results; } catch (error) { await testRunner.cleanup(); throw error; } } /** * Validate E2E Test Environment * * Checks if the environment is properly configured for E2E testing * without running the actual tests. */ export async function validateE2EEnvironment(config?: Partial<E2ETestConfig>): Promise<{ valid: boolean; issues: string[]; recommendations: string[]; }> { const testRunner = new E2ETestRunner(config); try { await testRunner.initialize(); // Create new E2ETestHelpers instance since environment is private const testHelpers = new E2ETestHelpers({ tempDir: './temp/validation', timeout: config?.defaultTimeout || 60000, retryOptions: config?.retryOptions || { maxRetries: 3, baseDelay: 1000 }, }); const validation = await testHelpers.validateEnvironment(); await testRunner.cleanup(); const recommendations: string[] = []; if (validation.issues.length > 0) { recommendations.push('Fix environment issues before running E2E tests'); recommendations.push('Ensure sufficient disk space and memory are available'); recommendations.push('Verify all required dependencies are installed'); } else { recommendations.push('Environment is ready for E2E testing'); recommendations.push('Consider running performance benchmarks first'); } return { valid: validation.valid, issues: validation.issues, recommendations, }; } catch (error) { await testRunner.cleanup(); return { valid: false, issues: [`Environment validation failed: ${error}`], recommendations: [ 'Check GEPA component initialization', 'Verify test directory permissions', 'Ensure adequate system resources', ], }; } } /** * Generate E2E Test Report * * Creates a comprehensive report of E2E test results including * performance metrics, memory usage, and error analysis. */ export function generateE2ETestReport(results: E2ETestResults): { summary: string; detailedMetrics: Record<string, any>; recommendations: string[]; } { const successRate = (results.passedTests / results.totalTests) * 100; const executionTimeMinutes = (results.executionTime / 1000 / 60).toFixed(2); const summary = ` šŸ“Š GEPA E2E Test Results Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ āœ… Tests Passed: ${results.passedTests}/${results.totalTests} (${successRate.toFixed(1)}%) ā±ļø Execution Time: ${executionTimeMinutes} minutes šŸ’¾ Peak Memory: ${(results.memoryUsage.peakUsage / 1024 / 1024).toFixed(1)}MB šŸ”„ Concurrent Operations: ${results.performanceMetrics.concurrentOperations} Performance Metrics: • Evolution Time: ${results.performanceMetrics.avgEvolutionTime}ms (avg) • Trajectory Recording: ${results.performanceMetrics.avgTrajectoryRecording}ms (avg) • Pareto Queries: ${results.performanceMetrics.avgParetoQuery}ms (avg) • Memory Operations: ${results.performanceMetrics.avgMemoryOperation}ms (avg) ${results.memoryUsage.leakDetected ? 'āš ļø Memory leak detected' : 'āœ… No memory leaks detected'} ${results.errorSummary.criticalErrors.length > 0 ? `🚨 ${results.errorSummary.criticalErrors.length} critical errors` : 'āœ… No critical errors'} ${results.errorSummary.recoveredErrors.length > 0 ? `šŸ”„ ${results.errorSummary.recoveredErrors.length} errors recovered` : ''} `.trim(); const detailedMetrics = { testExecution: { totalTests: results.totalTests, passedTests: results.passedTests, failedTests: results.failedTests, skippedTests: results.skippedTests, successRate: successRate, executionTime: results.executionTime, }, performance: results.performanceMetrics, memory: results.memoryUsage, errors: results.errorSummary, }; const recommendations: string[] = []; if (successRate < 95) { recommendations.push('Investigate test failures to improve stability'); } if (results.memoryUsage.leakDetected) { recommendations.push('Address memory leaks before production deployment'); } if (results.performanceMetrics.avgEvolutionTime > 30000) { recommendations.push('Optimize evolution algorithms for better performance'); } if (results.errorSummary.criticalErrors.length > 0) { recommendations.push('Fix critical errors identified during testing'); } if (successRate >= 95 && !results.memoryUsage.leakDetected) { recommendations.push('System is ready for production deployment'); } return { summary, detailedMetrics, recommendations, }; } /** * Export test configuration constants for external use */ export const DEFAULT_E2E_CONFIG: E2ETestConfig = { maxConcurrentTests: 3, defaultTimeout: 60000, performanceThresholds: { evolutionTime: 30000, trajectoryRecording: 1000, paretoFrontierQuery: 500, memoryOperations: 100, }, retryOptions: { maxRetries: 3, baseDelay: 1000, }, }; /** * CLI-friendly test runner for npm scripts */ export async function runE2EFromCLI(): Promise<void> { try { // eslint-disable-next-line no-console console.log('šŸš€ Starting GEPA E2E Test Suite...'); const results = await runE2ETestSuite(); const report = generateE2ETestReport(results); // eslint-disable-next-line no-console console.log('\n' + report.summary); if (report.recommendations.length > 0) { // eslint-disable-next-line no-console console.log('\nšŸ’” Recommendations:'); report.recommendations.forEach(rec => // eslint-disable-next-line no-console console.log(` • ${rec}`)); } // Exit with appropriate code const exitCode = results.passedTests === results.totalTests ? 0 : 1; process.exit(exitCode); } catch (error) { // eslint-disable-next-line no-console console.error('āŒ E2E Test Suite Failed:', error); process.exit(1); } }

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/sloth-wq/prompt-auto-optimizer-mcp'

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