/** * MCP Error Codes * * Machine-readable error codes for MCP tool responses. * Part of the Lex 1.0.0 contract - orchestrators can branch on these codes. * * @example * ```typescript * if (response.error?.code === MCPErrorCode.INVALID_MODULE_ID) { * // Handle module ID validation failure * } * ``` */ /** * Error codes for MCP tool operations * * Naming convention: CATEGORY_SPECIFIC_ERROR * - VALIDATION_* : Input validation errors * - STORAGE_* : Database/storage errors * - POLICY_* : Policy-related errors * - INTERNAL_* : Unexpected internal errors */ export declare enum MCPErrorCode { /** Required field is missing */ VALIDATION_REQUIRED_FIELD = "VALIDATION_REQUIRED_FIELD", /** Field has invalid format or type */ VALIDATION_INVALID_FORMAT = "VALIDATION_INVALID_FORMAT", /** Module ID does not match any module in policy */ VALIDATION_INVALID_MODULE_ID = "VALIDATION_INVALID_MODULE_ID", /** module_scope array is empty */ VALIDATION_EMPTY_MODULE_SCOPE = "VALIDATION_EMPTY_MODULE_SCOPE", /** status_snapshot structure is invalid */ VALIDATION_INVALID_STATUS = "VALIDATION_INVALID_STATUS", /** Image data is malformed or unsupported */ VALIDATION_INVALID_IMAGE = "VALIDATION_INVALID_IMAGE", /** Path provided does not exist or is inaccessible */ VALIDATION_INVALID_PATH = "VALIDATION_INVALID_PATH", /** Failed to save frame to database */ STORAGE_WRITE_FAILED = "STORAGE_WRITE_FAILED", /** Failed to read from database */ STORAGE_READ_FAILED = "STORAGE_READ_FAILED", /** Failed to delete from database */ STORAGE_DELETE_FAILED = "STORAGE_DELETE_FAILED", /** Failed to store image attachment */ STORAGE_IMAGE_FAILED = "STORAGE_IMAGE_FAILED", /** Frame with given ID was not found */ STORAGE_FRAME_NOT_FOUND = "STORAGE_FRAME_NOT_FOUND", /** Policy file not found or unreadable */ POLICY_NOT_FOUND = "POLICY_NOT_FOUND", /** Policy file has invalid structure */ POLICY_INVALID = "POLICY_INVALID", /** Unknown tool name requested */ INTERNAL_UNKNOWN_TOOL = "INTERNAL_UNKNOWN_TOOL", /** Unknown MCP method requested */ INTERNAL_UNKNOWN_METHOD = "INTERNAL_UNKNOWN_METHOD", /** Unexpected internal error */ INTERNAL_ERROR = "INTERNAL_ERROR" } /** * Error code metadata for agent introspection */ export interface MCPErrorCodeMetadata { /** Error category (validation, storage, policy, internal) */ category: "validation" | "storage" | "policy" | "internal"; /** Whether the error is potentially retryable (e.g., transient storage issues) */ retryable: boolean; } /** * Metadata map for all error codes * Agents can use this to understand error categories and retry behavior */ export declare const MCP_ERROR_METADATA: Record; /** * MCP Error with structured code and metadata */ export declare class MCPError extends Error { readonly code: MCPErrorCode; readonly metadata?: Record; constructor(code: MCPErrorCode, message: string, metadata?: Record); /** * Convert to MCP response error format */ toResponse(): { error: { code: string; message: string; metadata?: Record; }; }; } /** * Helper to create validation errors with suggestions */ export declare function createValidationError(code: MCPErrorCode, message: string, suggestions?: string[]): MCPError; /** * Helper to create module ID validation error with available modules */ export declare function createModuleIdError(invalidIds: string[], suggestions: string[], availableModules: string[]): MCPError;