Skip to main content
Glama

Prompt Auto-Optimizer MCP

by sloth-wq
index.ts12.6 kB
/** * GEPA Disaster Recovery System - Main Export * * Comprehensive disaster recovery and state restoration capabilities: * - Automatic state backup and restoration * - Disaster recovery mechanisms * - Component recovery systems * - Data integrity and validation * - Failover and emergency procedures */ // Import classes for local use will be done via re-export // Import types for local use import type { BackupConfig, BackupEntry, RestoreOptions, RestoreResult } from './state-backup-manager'; import type { DisasterRecoveryConfig, DisasterType, DisasterRecoveryExecution } from './disaster-recovery-manager'; import { RecoveryStatus } from './disaster-recovery-manager'; import type { ComponentType, ComponentRecoveryConfig, ComponentHealth, RecoveryStrategy, RecoveryAttempt } from './component-recovery-manager'; import type { IntegrityCheckConfig, IntegrityCheckResult } from './data-integrity-manager'; import type { RecoveryOrchestratorConfig, RecoveryDashboard, RecoveryPlan } from './recovery-orchestrator'; // Import classes for DisasterRecoverySystem import { StateBackupManager } from './state-backup-manager'; import { DisasterRecoveryManager } from './disaster-recovery-manager'; import { ComponentRecoveryManager } from './component-recovery-manager'; import { DataIntegrityManager } from './data-integrity-manager'; import { RecoveryOrchestrator } from './recovery-orchestrator'; // Export classes export { StateBackupManager, DisasterRecoveryManager, ComponentRecoveryManager, DataIntegrityManager, RecoveryOrchestrator }; // Types and Interfaces export type { BackupConfig, BackupEntry, RestoreOptions, RestoreResult } from './state-backup-manager'; export type { DisasterRecoveryConfig, FailoverConfig, DisasterType, RecoveryStatus, RecoveryProcedure, EmergencyShutdownOptions, DisasterRecoveryExecution } from './disaster-recovery-manager'; export type { ComponentType, ComponentStatus, RecoveryStrategy, ComponentRecoveryConfig, ComponentHealth, RecoveryAttempt } from './component-recovery-manager'; export type { IntegrityCheckConfig, IntegrityCheckResult, CorruptionLevel, RepairStrategy, ValidationRule, ChecksumType } from './data-integrity-manager'; export type { RecoveryOrchestratorConfig, RecoveryPlan, RecoveryStep, RecoveryExecution, RecoveryDashboard } from './recovery-orchestrator'; /** * Unified Disaster Recovery System * * Provides centralized coordination of all recovery systems */ export class DisasterRecoverySystem { private static instance: DisasterRecoverySystem; private stateBackupManager: StateBackupManager; private disasterRecoveryManager: DisasterRecoveryManager; private componentRecoveryManager: ComponentRecoveryManager; private dataIntegrityManager: DataIntegrityManager; private recoveryOrchestrator: RecoveryOrchestrator; constructor(config: { backupConfig?: Partial<BackupConfig>; disasterConfig?: Partial<DisasterRecoveryConfig>; componentConfig?: Partial<ComponentRecoveryConfig>; integrityConfig?: Partial<IntegrityCheckConfig>; orchestratorConfig?: Partial<RecoveryOrchestratorConfig>; } = {}) { this.stateBackupManager = new StateBackupManager(config.backupConfig); this.disasterRecoveryManager = new DisasterRecoveryManager(config.disasterConfig); this.componentRecoveryManager = new ComponentRecoveryManager(config.componentConfig); this.dataIntegrityManager = new DataIntegrityManager(config.integrityConfig); this.recoveryOrchestrator = new RecoveryOrchestrator({ stateBackupManager: this.stateBackupManager, disasterRecoveryManager: this.disasterRecoveryManager, componentRecoveryManager: this.componentRecoveryManager, dataIntegrityManager: this.dataIntegrityManager, ...config.orchestratorConfig }); } /** * Get singleton instance */ static getInstance(config?: { backupConfig?: Partial<BackupConfig>; disasterConfig?: Partial<DisasterRecoveryConfig>; componentConfig?: Partial<ComponentRecoveryConfig>; integrityConfig?: Partial<IntegrityCheckConfig>; orchestratorConfig?: Partial<RecoveryOrchestratorConfig>; }): DisasterRecoverySystem { if (!this.instance) { this.instance = new DisasterRecoverySystem(config); } return this.instance; } /** * Initialize comprehensive disaster recovery */ async initialize(): Promise<void> { await Promise.all([ this.stateBackupManager.initialize(), this.disasterRecoveryManager.initialize(), this.componentRecoveryManager.initialize(), this.dataIntegrityManager.initialize(), this.recoveryOrchestrator.initialize() ]); } /** * Create system state backup */ async createSystemBackup(label?: string): Promise<BackupEntry> { return this.recoveryOrchestrator.createSystemBackup(label); } /** * Restore system from backup */ async restoreSystemFromBackup(backupId: string, options?: RestoreOptions): Promise<RestoreResult> { return this.recoveryOrchestrator.restoreSystemFromBackup(backupId, options); } /** * Execute disaster recovery procedure */ async executeDisasterRecovery(disasterType: DisasterType): Promise<DisasterRecoveryExecution> { // Create a disaster plan and execute it through the orchestrator const plan = this.createDisasterRecoveryPlan(disasterType); const orchestratorResult = await this.recoveryOrchestrator.executePlan(plan); // Convert orchestrator result to disaster recovery format return { id: orchestratorResult.id, status: RecoveryStatus.COMPLETED, startTime: orchestratorResult.startTime, endTime: orchestratorResult.endTime || new Date(), currentStep: orchestratorResult.currentStep || 'completed', completedSteps: orchestratorResult.completedSteps, failedSteps: orchestratorResult.failedSteps || [], progress: orchestratorResult.progress, logs: orchestratorResult.logs.map(log => log.message), metrics: { totalDuration: orchestratorResult.metrics.totalDuration, stepsCompleted: orchestratorResult.completedSteps.length, stepsTotal: plan.steps.length, errorsEncountered: orchestratorResult.results.errors.length }, disasterEvent: { id: `disaster-${Date.now()}`, type: disasterType, timestamp: new Date(), severity: 'high', source: 'disaster-recovery-system', description: `Disaster recovery execution for ${disasterType}`, metrics: {}, affectedComponents: [] }, procedure: { id: plan.id, name: plan.name, disasterType: disasterType, steps: plan.steps.map(step => { const baseStep = { id: step.id, name: step.name, description: step.name, action: 'custom' as const, parameters: step.parameters, timeout: step.timeout, critical: step.critical, rollbackPossible: !!step.rollbackStep, }; return step.rollbackStep ? { ...baseStep, rollbackAction: 'rollback' } : baseStep; }), priority: plan.priority, estimatedDuration: plan.estimatedDuration, prerequisites: plan.dependencies } }; } /** * Create disaster recovery plan for specific disaster type */ private createDisasterRecoveryPlan(disasterType: DisasterType): RecoveryPlan { return { id: `disaster-${disasterType}-${Date.now()}`, name: `Disaster Recovery: ${disasterType}`, description: `Automated recovery plan for ${disasterType}`, triggers: [], steps: [ { id: 'assess-damage', name: 'Assess System Damage', type: 'validation', system: 'disaster', parameters: { disasterType }, timeout: 30000, retryCount: 3, critical: true, dependencies: [] }, { id: 'backup-current-state', name: 'Backup Current State', type: 'backup', system: 'backup', parameters: { label: `pre-recovery-${disasterType}` }, timeout: 60000, retryCount: 2, critical: false, dependencies: [] }, { id: 'execute-recovery', name: 'Execute Recovery Procedure', type: 'component_recovery', system: 'component', parameters: { disasterType }, timeout: 120000, retryCount: 3, critical: true, dependencies: ['assess-damage'] } ], priority: 1, estimatedDuration: 300000, dependencies: [], rollbackEnabled: true, autoExecute: true }; } /** * Recover specific component */ async recoverComponent(componentType: ComponentType, strategy?: RecoveryStrategy): Promise<RecoveryAttempt> { return this.componentRecoveryManager.recoverComponent(componentType, strategy); } /** * Perform comprehensive integrity check */ async performIntegrityCheck(): Promise<IntegrityCheckResult[]> { return this.dataIntegrityManager.performComprehensiveCheck(); } /** * Get recovery dashboard information */ async getRecoveryDashboard(): Promise<RecoveryDashboard> { return this.recoveryOrchestrator.getDashboard(); } /** * Emergency shutdown with state preservation */ async emergencyShutdown(reason: string, preserveState = true): Promise<void> { return this.disasterRecoveryManager.emergencyShutdown({ reason, preserveState, notifyOperators: true, gracefulTimeout: 30000, forceKill: false }); } /** * Health check for all recovery systems */ async performHealthCheck(): Promise<{ overall: 'healthy' | 'degraded' | 'critical'; systems: Record<string, ComponentHealth>; recommendations: string[]; }> { const [ backupHealth, disasterHealth, componentHealth, integrityHealth, orchestratorHealth ] = await Promise.all([ this.stateBackupManager.getHealthStatus(), this.disasterRecoveryManager.getHealthStatus(), this.componentRecoveryManager.getHealthStatus(), this.dataIntegrityManager.getHealthStatus(), this.recoveryOrchestrator.getHealthStatus() ]); const systems = { backup: backupHealth, disaster: disasterHealth, component: componentHealth, integrity: integrityHealth, orchestrator: orchestratorHealth }; // Determine overall health const healths = Object.values(systems).map(h => h.status); let overall: 'healthy' | 'degraded' | 'critical' = 'healthy'; if (healths.some(h => h === 'critical')) { overall = 'critical'; } else if (healths.some(h => h === 'degraded')) { overall = 'degraded'; } // Collect recommendations const recommendations = Object.values(systems) .flatMap(h => h.recommendations || []); return { overall, systems, recommendations }; } /** * Cleanup all recovery systems */ async cleanup(): Promise<void> { await Promise.allSettled([ this.stateBackupManager.cleanup(), this.disasterRecoveryManager.cleanup(), this.componentRecoveryManager.cleanup(), this.dataIntegrityManager.cleanup(), this.recoveryOrchestrator.cleanup() ]); } } /** * Convenience functions for common recovery operations */ /** * Quick system backup */ export async function createQuickBackup(label?: string): Promise<BackupEntry> { const recovery = DisasterRecoverySystem.getInstance(); return recovery.createSystemBackup(label); } /** * Quick system restore */ export async function quickRestore(backupId: string): Promise<RestoreResult> { const recovery = DisasterRecoverySystem.getInstance(); return recovery.restoreSystemFromBackup(backupId); } /** * Emergency system recovery */ export async function emergencyRecovery(disasterType: DisasterType): Promise<DisasterRecoveryExecution> { const recovery = DisasterRecoverySystem.getInstance(); return recovery.executeDisasterRecovery(disasterType); } /** * System health check */ export async function checkSystemHealth(): Promise<{ overall: 'healthy' | 'degraded' | 'critical'; systems: Record<string, ComponentHealth>; recommendations: string[]; }> { const recovery = DisasterRecoverySystem.getInstance(); return recovery.performHealthCheck(); }

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