UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

144 lines 4.73 kB
/** * Comprehensive Auto-Correction Engine * * This engine aggressively auto-corrects user input using: * 1. Real swagger defaults from the API * 2. Safe operational fallbacks * 3. URL protocol fixing * 4. Field name corrections * 5. Enum fuzzy matching * 6. Format validation and auto-repair * * Philosophy: Be smart about fixing obvious mistakes, provide clear feedback */ export interface CorrectionResult { correctedData: any; corrections: CorrectionDetails[]; userMessage: string; wasCorrected: boolean; } export interface CorrectionDetails { field: string; original: any; corrected: any; reason: string; type: 'swagger_default' | 'safety_fallback' | 'url_fix' | 'field_rename' | 'enum_correction' | 'format_fix' | 'template_field_strip'; } export declare class ComprehensiveAutoCorrector { private static logger; /** * Main auto-correction entry point */ static autoCorrect(entityType: string, userInput: any, context?: { platform?: string; isTemplateMode?: boolean; operation?: string; }): CorrectionResult; /** * Fix common field name mistakes (entity-aware) */ private static correctFieldNames; /** * Fix URL protocols - add https:// if missing (recursive) */ private static fixUrlProtocols; /** * Apply enum fuzzy matching */ private static correctEnumValues; /** * Apply nested enum corrections specifically for Web Experimentation * CRITICAL: Only applies to Web Experimentation, NOT Feature Flags */ private static correctNestedWebExperimentationEnums; /** * Apply real swagger defaults */ private static applySwaggerDefaults; /** * Apply safety fallbacks for missing critical fields */ private static applySafetyFallbacks; /** * Apply platform-specific corrections */ private static applyPlatformSpecificCorrections; /** * Check if entity has required fields with invalid values */ private static hasRequiredFieldsWithInvalidValues; /** * Validate and fix data formats */ private static validateAndFixFormats; /** * Preserve nested array structure during JSON serialization * Prevents arrays like ["or", {...}] from being converted to {"0": "or", "1": {...}} */ private static preserveNestedArrayStructure; /** * Deep preprocess arrays to prevent corruption during JSON.stringify */ private static deepPreprocessArrays; /** * Fix weight and traffic allocation fields with smart conversions */ private static fixWeightAndTrafficAllocation; /** * Fix metrics validation - ensure sum aggregators have field parameter and other API requirements */ private static fixMetricsValidation; /** * Convert various weight formats to basis points */ private static convertToBasisPoints; /** * Get descriptive reason for weight conversion */ private static getWeightConversionReason; /** * Generate user-friendly correction message */ private static generateUserMessage; /** * Extract condition data from malformed strings using regex */ private static extractConditionDataFromMalformed; /** * Fix audience condition types using typo mappings */ private static fixAudienceConditionTypes; /** * Apply personalization-specific corrections * Personalization experiments have different requirements than A/B tests */ private static applyPersonalizationCorrections; /** * Apply experiment update-specific corrections * Handles format conversions for intuitive update formats from AI agents */ private static applyExperimentUpdateCorrections; /** * Create default A/B test variations when missing * Standard default is "off" variation with 100% traffic allocation for Feature Experimentation */ private static createDefaultABTestVariations; /** * Transform audience conditions to the proper format expected by Optimizely API * This centralizes all audience_conditions format fixes in one place */ private static transformAudienceConditions; /** * Strip fields that don't belong to specific UPDATE templates */ private static stripInvalidTemplateFields; /** * Auto-detect and add missing template markers for UPDATE operations */ private static addMissingTemplateMarker; /** * Generate entity-specific error guidance for prescriptive error messages */ private static getEntitySpecificErrorGuidance; } //# sourceMappingURL=ComprehensiveAutoCorrector.d.ts.map