2026-02-03 11:28:22 +09:00
|
|
|
/**
|
|
|
|
|
* Runtime Fallback Hook - Constants
|
|
|
|
|
*
|
|
|
|
|
* Default values and configuration constants for the runtime fallback feature.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import type { RuntimeFallbackConfig } from "../../config"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Default configuration values for runtime fallback
|
|
|
|
|
*/
|
|
|
|
|
export const DEFAULT_CONFIG: Required<RuntimeFallbackConfig> = {
|
|
|
|
|
enabled: true,
|
2026-02-21 16:24:18 +09:00
|
|
|
retry_on_errors: [429, 500, 502, 503, 504],
|
2026-02-03 11:28:22 +09:00
|
|
|
max_fallback_attempts: 3,
|
|
|
|
|
cooldown_seconds: 60,
|
2026-02-12 13:10:55 -05:00
|
|
|
timeout_seconds: 30,
|
2026-02-03 11:28:22 +09:00
|
|
|
notify_on_fallback: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Error patterns that indicate rate limiting or temporary failures
|
|
|
|
|
* These are checked in addition to HTTP status codes
|
|
|
|
|
*/
|
|
|
|
|
export const RETRYABLE_ERROR_PATTERNS = [
|
|
|
|
|
/rate.?limit/i,
|
|
|
|
|
/too.?many.?requests/i,
|
|
|
|
|
/quota.?exceeded/i,
|
2026-02-12 17:13:34 -05:00
|
|
|
/usage\s+limit\s+has\s+been\s+reached/i,
|
2026-02-03 11:28:22 +09:00
|
|
|
/service.?unavailable/i,
|
|
|
|
|
/overloaded/i,
|
|
|
|
|
/temporarily.?unavailable/i,
|
|
|
|
|
/try.?again/i,
|
2026-02-11 16:59:26 -05:00
|
|
|
/credit.*balance.*too.*low/i,
|
|
|
|
|
/insufficient.?(?:credits?|funds?|balance)/i,
|
2026-02-05 23:15:05 +09:00
|
|
|
/(?:^|\s)429(?:\s|$)/,
|
|
|
|
|
/(?:^|\s)503(?:\s|$)/,
|
|
|
|
|
/(?:^|\s)529(?:\s|$)/,
|
2026-02-03 11:28:22 +09:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hook name for identification and logging
|
|
|
|
|
*/
|
|
|
|
|
export const HOOK_NAME = "runtime-fallback"
|