/** * Common Error Codes for Adapters * * This module provides error code constants for common error scenarios * that adapters encounter. These codes align with the core ERROR_CODES * from @wavespec/types but are exposed at the adapter-kit level * for convenient use when building error patterns. * * Using these constants ensures: * - Consistent error codes across all adapters * - Consistency with the harness error catalog * - Type-safe error code references * - Easier maintenance (centralized definitions) * * ## Code Categories * - Connection Errors: ECONNREFUSED, ENOTFOUND, ECONNRESET, DNS failures * - HTTP Status Codes: 401, 403, 404, 429, 500, 502, 503 * - Protocol Errors: Parse errors, invalid responses, protocol violations * - Timeout Errors: Operation timeouts, request timeouts * - Authentication Errors: Auth failures, authorization failures * - Resource Errors: Tool not found, prompt not found, resource not found * * @module @wavespec/kit/error * @example * ```typescript * import { ERROR_CODES } from "@wavespec/kit/error"; * * const pattern: ErrorPattern = { * match: /econnrefused/i, * code: ERROR_CODES.CONNECTION_REFUSED, * hint: "Server refused connection", * fix: "Check server is running" * }; * ``` */ /** * Common error codes for adapters * * These map to standard harness error codes, making them reusable * across HTTP, MCP, OpenAI Agents, and other adapters. * * All codes are exported as constants for type safety. */ export declare const ERROR_CODES: { /** * Connection refused - server actively rejected connection * Maps to: ADAPTER_CONNECTION_FAILED */ readonly CONNECTION_REFUSED: "ADAPTER_CONNECTION_FAILED"; /** * Connection timeout - unable to reach server * Maps to: OPERATION_TIMEOUT */ readonly CONNECTION_TIMEOUT: "OPERATION_TIMEOUT"; /** * Connection reset - connection was forcibly closed by server * Maps to: ADAPTER_CONNECTION_FAILED */ readonly CONNECTION_RESET: "ADAPTER_CONNECTION_FAILED"; /** * DNS lookup failed - hostname could not be resolved * Maps to: ADAPTER_CONNECTION_FAILED */ readonly DNS_RESOLUTION_FAILED: "ADAPTER_CONNECTION_FAILED"; /** * Network unreachable - system cannot reach the network * Maps to: ADAPTER_CONNECTION_FAILED */ readonly NETWORK_UNREACHABLE: "ADAPTER_CONNECTION_FAILED"; /** * Host unreachable - specific host cannot be reached * Maps to: ADAPTER_CONNECTION_FAILED */ readonly HOST_UNREACHABLE: "ADAPTER_CONNECTION_FAILED"; /** * HTTP 400 Bad Request - invalid request parameters * Maps to: INVALID_TOOL_ARGUMENTS */ readonly HTTP_400_BAD_REQUEST: "INVALID_TOOL_ARGUMENTS"; /** * HTTP 401 Unauthorized - authentication required or failed * Maps to: ADAPTER_CONNECTION_FAILED (auth is connection concern) */ readonly HTTP_401_UNAUTHORIZED: "ADAPTER_CONNECTION_FAILED"; /** * HTTP 403 Forbidden - authenticated but not authorized * Maps to: ADAPTER_CONNECTION_FAILED (permission is connection concern) */ readonly HTTP_403_FORBIDDEN: "ADAPTER_CONNECTION_FAILED"; /** * HTTP 404 Not Found - resource does not exist * Maps to: TOOL_NOT_FOUND (can be tool, resource, prompt, endpoint) */ readonly HTTP_404_NOT_FOUND: "TOOL_NOT_FOUND"; /** * HTTP 408 Request Timeout - server timed out waiting for request * Maps to: OPERATION_TIMEOUT */ readonly HTTP_408_REQUEST_TIMEOUT: "OPERATION_TIMEOUT"; /** * HTTP 429 Too Many Requests - rate limited * Maps to: TEST_EXECUTION_ERROR (rate limiting is a test concern) */ readonly HTTP_429_RATE_LIMIT: "TEST_EXECUTION_ERROR"; /** * HTTP 500 Internal Server Error - server bug * Maps to: SERVER_ERROR */ readonly HTTP_500_SERVER_ERROR: "SERVER_ERROR"; /** * HTTP 502 Bad Gateway - upstream server error * Maps to: ADAPTER_CONNECTION_FAILED (service unavailable) */ readonly HTTP_502_BAD_GATEWAY: "ADAPTER_CONNECTION_FAILED"; /** * HTTP 503 Service Unavailable - server temporarily down * Maps to: ADAPTER_CONNECTION_FAILED (service unavailable) */ readonly HTTP_503_SERVICE_UNAVAILABLE: "ADAPTER_CONNECTION_FAILED"; /** * HTTP 504 Gateway Timeout - upstream server timeout * Maps to: OPERATION_TIMEOUT */ readonly HTTP_504_GATEWAY_TIMEOUT: "OPERATION_TIMEOUT"; /** * Generic protocol error - invalid protocol response or state * Maps to: MCP_PROTOCOL_ERROR (most specific available) */ readonly PROTOCOL_ERROR: "MCP_PROTOCOL_ERROR"; /** * Parse error - could not parse response (JSON, XML, etc.) * Maps to: INVALID_JSON_RESPONSE */ readonly PARSE_ERROR: "INVALID_JSON_RESPONSE"; /** * Invalid response - response missing required fields * Maps to: MCP_PROTOCOL_ERROR (protocol violation) */ readonly INVALID_RESPONSE: "MCP_PROTOCOL_ERROR"; /** * Malformed response - response structure is invalid * Maps to: MCP_PROTOCOL_ERROR */ readonly MALFORMED_RESPONSE: "MCP_PROTOCOL_ERROR"; /** * Operation timeout - operation exceeded configured timeout * Maps to: OPERATION_TIMEOUT */ readonly OPERATION_TIMEOUT: "OPERATION_TIMEOUT"; /** * Request timeout - HTTP request exceeded timeout * Maps to: OPERATION_TIMEOUT */ readonly REQUEST_TIMEOUT: "OPERATION_TIMEOUT"; /** * Connection timeout - could not establish connection in time * Maps to: OPERATION_TIMEOUT */ readonly CONNECT_TIMEOUT: "OPERATION_TIMEOUT"; /** * Authentication failed - invalid credentials or token * Maps to: ADAPTER_CONNECTION_FAILED (auth is connection concern) */ readonly AUTHENTICATION_FAILED: "ADAPTER_CONNECTION_FAILED"; /** * Authorization failed - insufficient permissions * Maps to: ADAPTER_CONNECTION_FAILED */ readonly AUTHORIZATION_FAILED: "ADAPTER_CONNECTION_FAILED"; /** * Invalid token - token is malformed or expired * Maps to: ADAPTER_CONNECTION_FAILED */ readonly INVALID_TOKEN: "ADAPTER_CONNECTION_FAILED"; /** * Token expired - authentication token has expired * Maps to: ADAPTER_CONNECTION_FAILED */ readonly TOKEN_EXPIRED: "ADAPTER_CONNECTION_FAILED"; /** * Tool not found - requested tool does not exist * Maps to: TOOL_NOT_FOUND */ readonly TOOL_NOT_FOUND: "TOOL_NOT_FOUND"; /** * Prompt not found - requested prompt does not exist * Maps to: PROMPT_NOT_FOUND */ readonly PROMPT_NOT_FOUND: "PROMPT_NOT_FOUND"; /** * Resource not found - requested resource does not exist * Maps to: RESOURCE_NOT_FOUND */ readonly RESOURCE_NOT_FOUND: "RESOURCE_NOT_FOUND"; /** * Invalid tool arguments - tool called with wrong arguments * Maps to: INVALID_TOOL_ARGUMENTS */ readonly INVALID_TOOL_ARGUMENTS: "INVALID_TOOL_ARGUMENTS"; /** * Certificate validation failed - SSL/TLS certificate invalid * Maps to: ADAPTER_CONNECTION_FAILED (connection concern) */ readonly CERTIFICATE_VALIDATION_FAILED: "ADAPTER_CONNECTION_FAILED"; /** * SSL/TLS error - general SSL/TLS error * Maps to: ADAPTER_CONNECTION_FAILED */ readonly SSL_TLS_ERROR: "ADAPTER_CONNECTION_FAILED"; /** * Certificate expired - SSL/TLS certificate has expired * Maps to: ADAPTER_CONNECTION_FAILED */ readonly CERTIFICATE_EXPIRED: "ADAPTER_CONNECTION_FAILED"; /** * Certificate hostname mismatch - certificate doesn't match hostname * Maps to: ADAPTER_CONNECTION_FAILED */ readonly CERTIFICATE_HOSTNAME_MISMATCH: "ADAPTER_CONNECTION_FAILED"; /** * Unknown error - error type could not be determined * Maps to: TEST_EXECUTION_ERROR (generic test failure) */ readonly UNKNOWN_ERROR: "TEST_EXECUTION_ERROR"; /** * Server error - generic server-side error * Maps to: SERVER_ERROR */ readonly SERVER_ERROR: "SERVER_ERROR"; /** * Test execution error - test failed to execute * Maps to: TEST_EXECUTION_ERROR */ readonly TEST_EXECUTION_ERROR: "TEST_EXECUTION_ERROR"; }; /** * Type for error code strings (for type safety) * * Ensures only valid error codes are used in patterns. */ export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES]; /** * Get the harness error code name from an ERROR_CODES value * * Useful for documentation and debugging. * * @example * ```typescript * const code = ERROR_CODES.CONNECTION_REFUSED; // "ADAPTER_CONNECTION_FAILED" * const name = getErrorCodeName(code); // "ADAPTER_CONNECTION_FAILED" * ``` */ export declare function getErrorCodeName(code: string): string; //# sourceMappingURL=codes.d.ts.map