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

194 lines (193 loc) 5.83 kB
/** * Server Adapter Error Classes * * Typed error hierarchy for server adapters following NeuroLink error patterns. */ import { type ErrorCategoryType, type ErrorSeverityType, type ServerAdapterErrorCodeType, type ServerAdapterErrorContext } from "../types/index.js"; /** * Base error class for server adapter errors */ export declare class ServerAdapterError extends Error { readonly code: ServerAdapterErrorCodeType; readonly category: ErrorCategoryType; readonly severity: ErrorSeverityType; readonly retryable: boolean; readonly retryAfterMs?: number; readonly requestId?: string; readonly path?: string; readonly method?: string; readonly details?: Record<string, unknown>; readonly cause?: Error; constructor(message: string, code: ServerAdapterErrorCodeType, context?: Partial<ServerAdapterErrorContext>); /** * Convert to JSON for API responses */ toJSON(): Record<string, unknown>; /** * Get HTTP status code for this error */ getHttpStatus(): number; } /** * Configuration error */ export declare class ConfigurationError extends ServerAdapterError { constructor(message: string, details?: Record<string, unknown>, cause?: Error); } /** * Route conflict error */ export declare class RouteConflictError extends ServerAdapterError { constructor(path: string, method: string, existingRoute?: string); } /** * Route not found error */ export declare class RouteNotFoundError extends ServerAdapterError { constructor(path: string, method: string, requestId?: string); } /** * Validation error */ export declare class ValidationError extends ServerAdapterError { readonly errors: Array<{ field: string; message: string; value?: unknown; }>; constructor(errors: Array<{ field: string; message: string; value?: unknown; }>, requestId?: string); } /** * Authentication error */ export declare class AuthenticationError extends ServerAdapterError { constructor(message?: string, requestId?: string); } /** * Invalid authentication error */ export declare class InvalidAuthenticationError extends ServerAdapterError { constructor(message?: string, requestId?: string); } /** * Authorization error */ export declare class AuthorizationError extends ServerAdapterError { constructor(message?: string, requestId?: string, requiredPermissions?: string[]); } /** * Rate limit error */ export declare class RateLimitError extends ServerAdapterError { constructor(retryAfterMs: number, message?: string, requestId?: string); } /** * Timeout error */ export declare class TimeoutError extends ServerAdapterError { constructor(timeoutMs: number, operation?: string, requestId?: string); } /** * Handler error */ export declare class HandlerError extends ServerAdapterError { constructor(message: string, cause?: Error, requestId?: string, path?: string, method?: string); } /** * Streaming error */ export declare class StreamingError extends ServerAdapterError { constructor(message: string, cause?: Error, requestId?: string); } /** * Stream aborted error */ export declare class StreamAbortedError extends ServerAdapterError { constructor(reason?: string, requestId?: string); } /** * WebSocket error */ export declare class WebSocketError extends ServerAdapterError { constructor(message: string, cause?: Error, connectionId?: string); } /** * WebSocket connection failed error */ export declare class WebSocketConnectionError extends ServerAdapterError { constructor(message?: string, cause?: Error); } /** * Server start error */ export declare class ServerStartError extends ServerAdapterError { constructor(message: string, cause?: Error, port?: number, host?: string); } /** * Server stop error */ export declare class ServerStopError extends ServerAdapterError { constructor(message: string, cause?: Error); } /** * Already running error */ export declare class AlreadyRunningError extends ServerAdapterError { constructor(port?: number, host?: string); } /** * Not running error */ export declare class NotRunningError extends ServerAdapterError { constructor(); } /** * Shutdown timeout error * Thrown when graceful shutdown exceeds the configured timeout */ export declare class ShutdownTimeoutError extends ServerAdapterError { readonly timeoutMs: number; readonly remainingConnections: number; constructor(timeoutMs: number, remainingConnections: number); } /** * Drain timeout error * Thrown when connection draining exceeds the configured timeout */ export declare class DrainTimeoutError extends ServerAdapterError { readonly timeoutMs: number; readonly remainingConnections: number; constructor(timeoutMs: number, remainingConnections: number); } /** * Invalid lifecycle state error * Thrown when attempting an operation in an invalid lifecycle state */ export declare class InvalidLifecycleStateError extends ServerAdapterError { readonly currentState: string; readonly expectedStates: string[]; readonly operation: string; constructor(operation: string, currentState: string, expectedStates: string[]); } /** * Missing dependency error */ export declare class MissingDependencyError extends ServerAdapterError { constructor(dependency: string, framework: string, installCommand?: string); } /** * Error recovery strategies */ export declare const ErrorRecoveryStrategies: Record<ErrorCategoryType, { strategy: "retry" | "exponentialBackoff" | "circuitBreak" | "fail"; maxRetries: number; baseDelayMs: number; }>; /** * Helper to wrap errors as ServerAdapterError */ export declare function wrapError(error: unknown, requestId?: string, path?: string, method?: string): ServerAdapterError;