import type { Address, Hex } from 'viem'; type ErrorCode = 'VALIDATION_ERROR' | 'INSUFFICIENT_LIQUIDITY' | 'NOT_FOUND' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'KEY_SCOPE_DENIED' | 'CONFLICT' | 'UNPROCESSABLE_CONTENT' | 'TOO_MANY_REQUESTS' | 'SETTLEMENT_QUOTE_ERROR' | 'SETTLEMENT_EXECUTION_ERROR' | 'SIMULATION_FAILED' | 'EXTERNAL_SERVICE_TIMEOUT' | 'RELAYER_MARKET_UNAVAILABLE' | 'INTERNAL_ERROR'; interface ValidationIssue { message: string; context?: Record; } interface ErrorDetail { message: string; context?: Record; } interface BaseErrorParams { message: string; traceId?: string; statusCode?: number; } type SimulationAction = 'claim' | 'fill'; type SimulationRetryHint = 'RE_PREPARE' | 'RETRY_LATER'; type SimulationErrorCategory = 'QUOTE_EXPIRED' | 'ORDER_EXPIRED' | 'PERMIT_EXPIRED' | 'PERMIT2_NONCE_CONSUMED' | 'EXECUTOR_NONCE_CONSUMED' | 'INVALID_SIGNATURE' | 'INVALID_PERMIT2_SIGNATURE' | 'INVALID_CONTRACT_SIGNATURE' | 'INVALID_SIGNER' | 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_ALLOWANCE' | 'ACCOUNT_CREATION_FAILED' | 'ACCOUNT_UNAUTHORIZED' | 'ADAPTER_CALL_FAILED' | 'EXECUTION_FAILED' | 'CLAIM_FAILED' | 'ROUTER_PAUSED' | 'ADAPTER_NOT_FOUND' | 'PANIC' | 'REQUIRE_FAILED' | 'UNCLASSIFIED_REVERT' | 'EMPTY_REVERT'; interface SimulationCall { chainId?: string; to?: Address; data?: Hex; value?: string; } interface SimulationDetails { stateOverride?: unknown; blockNumber?: string; relayer?: Address; simulationUrls?: string[]; } interface SimulationFailureSimulation { success: false; action?: SimulationAction; chainId?: string; call?: SimulationCall; errorSelector?: string; errorName?: string; errorArgs?: Record; errorCategory?: SimulationErrorCategory; details?: SimulationDetails; } interface SimulationFailureDetails { nonce?: string; category?: SimulationErrorCategory; errorSelector?: string; errorName?: string; errorArgs?: Record; retryable?: boolean; retryHint?: SimulationRetryHint; simulations?: SimulationFailureSimulation[]; } declare class OrchestratorError extends Error { readonly code: ErrorCode | 'UNKNOWN'; readonly traceId: string; readonly statusCode?: number; constructor(params: BaseErrorParams & { code?: ErrorCode | 'UNKNOWN'; }); } declare class ValidationError extends OrchestratorError { readonly issues: ValidationIssue[]; constructor(params: BaseErrorParams & { issues?: ValidationIssue[]; }); } declare class InsufficientLiquidityError extends OrchestratorError { readonly availableIntents: Record[]; readonly unfillable: Record; constructor(params: BaseErrorParams & { availableIntents: Record[]; unfillable: Record; }); } declare class NotFoundError extends OrchestratorError { constructor(params: BaseErrorParams); } declare class UnauthorizedError extends OrchestratorError { constructor(params: BaseErrorParams); } declare class ForbiddenError extends OrchestratorError { constructor(params: BaseErrorParams & { code?: ErrorCode; }); } /** * Thrown when an API key's scope denies the request. * * Subclass of `ForbiddenError` carrying the failed `scope` and the * `required` / `actual` levels — distinct from a generic 403 so integrators * can prompt the user to widen the key's scope rather than rotate it. */ declare class KeyScopeDeniedError extends ForbiddenError { readonly scope: string; readonly required: string | boolean; readonly actual: string | boolean; constructor(params: BaseErrorParams & { scope: string; required: string | boolean; actual: string | boolean; }); } declare class ConflictError extends OrchestratorError { constructor(params: BaseErrorParams); } declare class UnprocessableContentError extends OrchestratorError { readonly details: ErrorDetail[]; constructor(params: BaseErrorParams & { details?: ErrorDetail[]; }); } /** Per-client sponsorship cap a quote can breach. Mirrors the orchestrator's * `SponsorLimits` keys: per-intent gas, per-intent bridge fee, or the * per-intent aggregate. */ declare const SPONSOR_LIMIT_KEYS: readonly ["gasPerIntentUSD", "bridgeFeePerIntentUSD", "perIntentUSD"]; type SponsorLimitKey = (typeof SPONSOR_LIMIT_KEYS)[number]; /** * A configured per-client sponsorship cap was exceeded by a quote. * * A `422 UNPROCESSABLE_CONTENT` specialization: the integrator's sponsor * policy sets a per-intent USD ceiling (gas, bridge-fee, or aggregate) and * this quote's sponsored coverage would exceed it. Distinct from * {@link InsufficientSponsorBalanceError} (a funds shortfall) — a cap breach * is deterministic and does NOT clear by topping up the sponsorship balance; * the cap itself must be raised or the intent made cheaper. * * Extends {@link UnprocessableContentError} and keeps `code` as * `'UNPROCESSABLE_CONTENT'` (the wire does not yet carry a dedicated code), so * existing handling of that error still catches it. `sponsorAddress` is * populated only for the pre-fold check; the post-fold multi-candidate * rejection omits it, so treat every field as best-effort. */ declare class SponsorLimitExceededError extends UnprocessableContentError { readonly limitKey?: SponsorLimitKey; readonly capUsd?: number; readonly coverageUsd?: number; readonly sponsorAddress?: string; constructor(params: BaseErrorParams & { details?: ErrorDetail[]; limitKey?: SponsorLimitKey; capUsd?: number; coverageUsd?: number; sponsorAddress?: string; }); } /** * The sponsor's prefunded balance cannot cover the sponsored categories for a * quote. * * A `422 UNPROCESSABLE_CONTENT` specialization. Coverage is all-or-nothing: * `failedCategories` lists the enabled categories (`gas`, `bridgeFee`, * `swapFee`) that could not be covered. Unlike * {@link SponsorLimitExceededError} (a configured policy cap), this clears once * the sponsorship balance is topped up. * * Extends {@link UnprocessableContentError} and keeps `code` as * `'UNPROCESSABLE_CONTENT'`, so existing handling of that error still catches * it. */ declare class InsufficientSponsorBalanceError extends UnprocessableContentError { readonly failedCategories: string[]; readonly sponsorAddress?: string; readonly remainingBalanceUsd?: number; readonly totalSponsoredUsd?: number; constructor(params: BaseErrorParams & { details?: ErrorDetail[]; failedCategories?: string[]; sponsorAddress?: string; remainingBalanceUsd?: number; totalSponsoredUsd?: number; }); } declare class RateLimitedError extends OrchestratorError { readonly retryAfter?: string; constructor(params: BaseErrorParams & { retryAfter?: string; }); } declare class SettlementQuoteError extends OrchestratorError { constructor(params: BaseErrorParams); } declare class SettlementExecutionError extends OrchestratorError { constructor(params: BaseErrorParams); } declare class SimulationFailedError extends OrchestratorError { readonly nonce?: string; readonly category?: SimulationErrorCategory; readonly errorSelector?: string; readonly errorName?: string; readonly errorArgs?: Record; readonly retryable: boolean; readonly retryHint?: SimulationRetryHint; readonly simulations: SimulationFailureSimulation[]; constructor(params: BaseErrorParams & SimulationFailureDetails); } declare class ExternalServiceTimeoutError extends OrchestratorError { constructor(params: BaseErrorParams); } declare class RelayerMarketUnavailableError extends OrchestratorError { constructor(params: BaseErrorParams); } declare class InternalServerError extends OrchestratorError { constructor(params: BaseErrorParams); } interface ErrorEnvelope { code: ErrorCode; message: string; traceId: string; details?: unknown; } declare function parseErrorEnvelope(envelope: ErrorEnvelope, statusCode: number, retryAfter?: string): OrchestratorError; declare function isOrchestratorError(error: unknown): error is OrchestratorError; declare function isRateLimited(error: unknown): error is RateLimitedError; declare function isValidationError(error: unknown): error is ValidationError; declare function isAuthError(error: unknown): error is UnauthorizedError | ForbiddenError; declare function isSimulationFailed(error: unknown): error is SimulationFailedError; declare function isSponsorLimitExceeded(error: unknown): error is SponsorLimitExceededError; declare function isInsufficientSponsorBalance(error: unknown): error is InsufficientSponsorBalanceError; /** Either sponsor failure: a configured cap breach or a balance shortfall. */ declare function isSponsorError(error: unknown): error is SponsorLimitExceededError | InsufficientSponsorBalanceError; declare function isRetryable(error: unknown): boolean; /** * Detects transport-level failures (connection reset, socket closed, DNS, TLS) * that `fetch` rejects with instead of returning an HTTP response. Unlike HTTP * errors — which the client converts into typed {@link OrchestratorError}s — * these carry no status and bubble up untyped, so {@link isRetryable} misses * them. They are safe to retry for idempotent reads (e.g. intent-status * polling). We match by `code` and message across the cause chain — never by * error type: `fetch` rejects network failures as `TypeError`, but `TypeError` * is also thrown for logic bugs, bad URLs, and response-decoding errors that * must NOT be retried (`waitForExecution` has no SDK-side deadline). Runtimes * differ (Bun throws a plain `Error` with a socket message; undici/Node a * `TypeError` with a coded `cause`), hence both signals. Caller-initiated * aborts are excluded so deadlines/cancellation still propagate. */ declare function isConnectionError(error: unknown): boolean; export type { ErrorCode, ErrorDetail, ErrorEnvelope, SimulationAction, SimulationCall, SimulationDetails, SimulationErrorCategory, SimulationFailureDetails, SimulationFailureSimulation, SimulationRetryHint, SponsorLimitKey, ValidationIssue, }; export { parseErrorEnvelope, isOrchestratorError, isRetryable, isConnectionError, isAuthError, isValidationError, isRateLimited, isSimulationFailed, isSponsorLimitExceeded, isInsufficientSponsorBalance, isSponsorError, OrchestratorError, ValidationError, InsufficientLiquidityError, SponsorLimitExceededError, InsufficientSponsorBalanceError, NotFoundError, UnauthorizedError, ForbiddenError, KeyScopeDeniedError, ConflictError, UnprocessableContentError, RateLimitedError, SettlementQuoteError, SettlementExecutionError, SimulationFailedError, ExternalServiceTimeoutError, RelayerMarketUnavailableError, InternalServerError, }; //# sourceMappingURL=errors.d.ts.map