UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

162 lines (161 loc) 7.32 kB
/** * @file Typed error hierarchy for the Evaluation/Scoring System. * Uses NeuroLinkFeatureError and createErrorFactory from core infrastructure. */ import { NeuroLinkFeatureError } from "../../core/infrastructure/index.js"; import type { EnhancedEvaluationContext, EvaluationErrorContext } from "../../types/index.js"; /** * Error codes for the Evaluation feature. * These codes help identify specific error scenarios for proper handling. */ export declare const EvaluationErrorCodes: { /** The evaluation process itself failed */ readonly EVALUATION_FAILED: "EVALUATION_FAILED"; /** Failed to parse the evaluation response from the judge LLM */ readonly PARSE_ERROR: "PARSE_ERROR"; /** The requested evaluation strategy was not found in the registry */ readonly STRATEGY_NOT_FOUND: "STRATEGY_NOT_FOUND"; /** The AI provider for evaluation failed */ readonly PROVIDER_ERROR: "PROVIDER_ERROR"; /** Configuration for evaluation is invalid or missing */ readonly CONFIGURATION_ERROR: "CONFIGURATION_ERROR"; /** The custom evaluator function threw an error */ readonly CUSTOM_EVALUATOR_ERROR: "CUSTOM_EVALUATOR_ERROR"; /** Batch evaluation failed for one or more items */ readonly BATCH_EVALUATION_ERROR: "BATCH_EVALUATION_ERROR"; /** Aggregation of evaluation results failed */ readonly AGGREGATION_ERROR: "AGGREGATION_ERROR"; /** Registry operation failed */ readonly REGISTRY_ERROR: "REGISTRY_ERROR"; /** Maximum retry attempts exceeded */ readonly MAX_RETRIES_EXCEEDED: "MAX_RETRIES_EXCEEDED"; /** Timeout during evaluation */ readonly TIMEOUT_ERROR: "TIMEOUT_ERROR"; /** Rate limit hit during evaluation */ readonly RATE_LIMIT_ERROR: "RATE_LIMIT_ERROR"; }; /** * Factory for creating typed evaluation errors. * Uses the createErrorFactory pattern from core infrastructure. */ export declare const evaluationErrors: { codes: { /** The evaluation process itself failed */ readonly EVALUATION_FAILED: "EVALUATION_FAILED"; /** Failed to parse the evaluation response from the judge LLM */ readonly PARSE_ERROR: "PARSE_ERROR"; /** The requested evaluation strategy was not found in the registry */ readonly STRATEGY_NOT_FOUND: "STRATEGY_NOT_FOUND"; /** The AI provider for evaluation failed */ readonly PROVIDER_ERROR: "PROVIDER_ERROR"; /** Configuration for evaluation is invalid or missing */ readonly CONFIGURATION_ERROR: "CONFIGURATION_ERROR"; /** The custom evaluator function threw an error */ readonly CUSTOM_EVALUATOR_ERROR: "CUSTOM_EVALUATOR_ERROR"; /** Batch evaluation failed for one or more items */ readonly BATCH_EVALUATION_ERROR: "BATCH_EVALUATION_ERROR"; /** Aggregation of evaluation results failed */ readonly AGGREGATION_ERROR: "AGGREGATION_ERROR"; /** Registry operation failed */ readonly REGISTRY_ERROR: "REGISTRY_ERROR"; /** Maximum retry attempts exceeded */ readonly MAX_RETRIES_EXCEEDED: "MAX_RETRIES_EXCEEDED"; /** Timeout during evaluation */ readonly TIMEOUT_ERROR: "TIMEOUT_ERROR"; /** Rate limit hit during evaluation */ readonly RATE_LIMIT_ERROR: "RATE_LIMIT_ERROR"; }; create: (code: "EVALUATION_FAILED" | "PARSE_ERROR" | "STRATEGY_NOT_FOUND" | "PROVIDER_ERROR" | "CONFIGURATION_ERROR" | "CUSTOM_EVALUATOR_ERROR" | "BATCH_EVALUATION_ERROR" | "AGGREGATION_ERROR" | "REGISTRY_ERROR" | "MAX_RETRIES_EXCEEDED" | "TIMEOUT_ERROR" | "RATE_LIMIT_ERROR", message: string, options?: { retryable?: boolean; details?: Record<string, unknown>; cause?: Error; } | undefined) => NeuroLinkFeatureError; }; /** * Checks if an error is retryable based on its code. * Transient errors (timeout, rate limit, some provider errors) are retryable. * * @param error - The error to check * @returns true if the error is retryable */ export declare function isRetryableEvaluationError(error: NeuroLinkFeatureError): boolean; /** * Checks if an error is a NeuroLinkFeatureError from the Evaluation feature. * * @param error - The error to check * @returns true if the error is an evaluation error */ export declare function isEvaluationError(error: unknown): error is NeuroLinkFeatureError; /** * Helper function to create an evaluation failed error with context. * * @param message - The error message * @param context - The evaluation context * @param cause - The underlying cause error * @returns A typed NeuroLinkFeatureError */ export declare function createEvaluationFailedError(message: string, context?: EvaluationErrorContext, cause?: Error): NeuroLinkFeatureError; /** * Helper function to create a parse error with raw response. * * @param rawResponse - The raw response that failed to parse * @param cause - The underlying parse error * @returns A typed NeuroLinkFeatureError */ export declare function createParseError(rawResponse: string, cause?: Error): NeuroLinkFeatureError; /** * Helper function to create a strategy not found error. * * @param strategyName - The name of the strategy that was not found * @param availableStrategies - List of available strategies * @returns A typed NeuroLinkFeatureError */ export declare function createStrategyNotFoundError(strategyName: string, availableStrategies?: string[]): NeuroLinkFeatureError; /** * Helper function to create a provider error. * * @param message - The error message * @param provider - The provider that failed * @param cause - The underlying cause error * @returns A typed NeuroLinkFeatureError */ export declare function createProviderError(message: string, provider: string, cause?: Error, options?: { retryable?: boolean; }): NeuroLinkFeatureError; /** * Helper function to create a max retries exceeded error. * * @param attempts - The number of attempts made * @param lastScore - The last evaluation score * @param threshold - The passing threshold * @param context - The evaluation context * @returns A typed NeuroLinkFeatureError */ export declare function createMaxRetriesExceededError(attempts: number, lastScore: number, threshold: number, context?: EvaluationErrorContext): NeuroLinkFeatureError; /** * Helper function to create a batch evaluation error. * * @param failedCount - Number of evaluations that failed * @param totalCount - Total number of evaluations attempted * @param errors - Array of individual errors * @returns A typed NeuroLinkFeatureError */ export declare function createBatchEvaluationError(failedCount: number, totalCount: number, errors: Array<{ index: number; error: Error; }>): NeuroLinkFeatureError; /** * Helper function to create a configuration error. * * @param message - The error message * @param configIssue - Description of the configuration issue * @returns A typed NeuroLinkFeatureError */ export declare function createConfigurationError(message: string, configIssue: string): NeuroLinkFeatureError; /** * Converts an evaluation context to error context for debugging. * * @param context - The enhanced evaluation context * @returns An EvaluationErrorContext */ export declare function contextToErrorContext(context: EnhancedEvaluationContext): EvaluationErrorContext;