/** All structured error codes for the CLI */ export declare const ERROR_CODES: { readonly INVALID_PARAMS: { readonly code: "INVALID_PARAMS"; readonly status: 400; readonly retryable: false; }; readonly SYMBOL_NOT_FOUND: { readonly code: "SYMBOL_NOT_FOUND"; readonly status: 404; readonly retryable: false; }; readonly ORDER_NOT_FOUND: { readonly code: "ORDER_NOT_FOUND"; readonly status: 404; readonly retryable: false; }; readonly POSITION_NOT_FOUND: { readonly code: "POSITION_NOT_FOUND"; readonly status: 404; readonly retryable: false; }; readonly INSUFFICIENT_BALANCE: { readonly code: "INSUFFICIENT_BALANCE"; readonly status: 400; readonly retryable: false; }; readonly MARGIN_INSUFFICIENT: { readonly code: "MARGIN_INSUFFICIENT"; readonly status: 400; readonly retryable: false; }; readonly SIZE_TOO_SMALL: { readonly code: "SIZE_TOO_SMALL"; readonly status: 400; readonly retryable: false; }; readonly SIZE_TOO_LARGE: { readonly code: "SIZE_TOO_LARGE"; readonly status: 400; readonly retryable: false; }; readonly RISK_VIOLATION: { readonly code: "RISK_VIOLATION"; readonly status: 403; readonly retryable: false; }; readonly DUPLICATE_ORDER: { readonly code: "DUPLICATE_ORDER"; readonly status: 409; readonly retryable: false; }; readonly NO_SIGNER_AVAILABLE: { readonly code: "NO_SIGNER_AVAILABLE"; readonly status: 401; readonly retryable: false; }; readonly AGENT_NOT_REGISTERED: { readonly code: "AGENT_NOT_REGISTERED"; readonly status: 401; readonly retryable: false; }; readonly AGENT_EXPIRED: { readonly code: "AGENT_EXPIRED"; readonly status: 401; readonly retryable: false; }; readonly POLICY_DENIED: { readonly code: "POLICY_DENIED"; readonly status: 403; readonly retryable: false; }; readonly KEY_NOT_FOUND: { readonly code: "KEY_NOT_FOUND"; readonly status: 404; readonly retryable: false; }; readonly WALLET_LOCKED: { readonly code: "WALLET_LOCKED"; readonly status: 423; readonly retryable: false; }; readonly APPROVE_PARTIAL: { readonly code: "APPROVE_PARTIAL"; readonly status: 500; readonly retryable: false; }; readonly APPROVE_FAILED: { readonly code: "APPROVE_FAILED"; readonly status: 500; readonly retryable: false; }; readonly LOCK_HELD: { readonly code: "LOCK_HELD"; readonly status: 423; readonly retryable: true; readonly retryAfterMs: 5000; }; readonly PASSPHRASE_REQUIRED: { readonly code: "PASSPHRASE_REQUIRED"; readonly status: 401; readonly retryable: false; }; readonly NOT_IMPLEMENTED: { readonly code: "NOT_IMPLEMENTED"; readonly status: 501; readonly retryable: false; }; readonly EXCHANGE_UNREACHABLE: { readonly code: "EXCHANGE_UNREACHABLE"; readonly status: 503; readonly retryable: true; }; readonly RATE_LIMITED: { readonly code: "RATE_LIMITED"; readonly status: 429; readonly retryable: true; readonly retryAfterMs: 1000; }; readonly PRICE_STALE: { readonly code: "PRICE_STALE"; readonly status: 503; readonly retryable: true; }; readonly SIGNATURE_FAILED: { readonly code: "SIGNATURE_FAILED"; readonly status: 500; readonly retryable: false; }; readonly EXCHANGE_ERROR: { readonly code: "EXCHANGE_ERROR"; readonly status: 502; readonly retryable: true; }; readonly TIMEOUT: { readonly code: "TIMEOUT"; readonly status: 504; readonly retryable: true; }; readonly UNKNOWN: { readonly code: "UNKNOWN"; readonly status: 500; readonly retryable: false; }; }; export type ErrorCode = keyof typeof ERROR_CODES; export interface StructuredError { code: ErrorCode; message: string; status: number; retryable: boolean; retryAfterMs?: number; exchange?: string; details?: Record; /** Actionable hint for automated callers (AC-19) */ remediation?: string; } /** * Extract a human-readable message from any thrown value. * Handles Error instances, plain objects with a `.message` field (string OR object), * and circular-safe stringification fallback. */ export declare function extractErrorMessage(err: unknown): string; /** * Classify an error from any exchange into a structured error code. * * If the input is already a PerpError, return its structured payload verbatim * — the typed code and remediation are the source of truth and must not be * re-derived from message text. Pattern-matching only kicks in for plain * Error instances or unknown thrown values. Codex v0.12.12 final QA #2. */ export declare function classifyError(err: unknown, exchange?: string): StructuredError; /** Custom error class that carries a structured error code */ export declare class PerpError extends Error { readonly structured: StructuredError; constructor(code: ErrorCode, message: string, details?: Record); }