export interface AutoFallbackConfig { /** Auto-revert: fallback ON → OFF when usage drops. */ enabled: boolean; /** Cutoff under which auto-revert flips fallback OFF. */ threshold: number; /** Auto-engage: fallback OFF → ON when usage approaches the cap. */ engageEnabled: boolean; /** Cutoff at/above which auto-engage flips fallback ON. */ engageThreshold: number; } export declare function getAutoFallbackConfig(accountsDirPath: string): AutoFallbackConfig; export declare function setAutoFallbackConfig(accountsDirPath: string, patch: Partial): AutoFallbackConfig; /** * Write smart-fallback defaults (both auto-revert and auto-engage enabled) * when no config file exists yet. Called after `apikey set` and on the first * passthrough that finds a key. Idempotent: no-op if the config file already * exists (preserves deliberate opt-outs). */ export declare function maybeInitSmartFallback(accountsDirPath: string): boolean; /** * Save an API key for an account and, if smart-fallback has never been * configured before, opportunistically turn it on with sane defaults. * Two-step UX flow consolidated here so screens don't have to remember * to chain `setApiKey` → `maybeInitSmartFallback` (and the order between * lock-required vs lock-free calls). * * Returns `{ smartEnabled }` reflecting whether THIS call initialised * smart-fallback (false on every subsequent call once the config exists). */ export declare function saveApiKeyAndMaybeInit(email: string, key: string, accountsDirPath: string): { smartEnabled: boolean; }; interface AutoDisableResult { /** True when this call disabled fallback. False when nothing was done. */ disabled: boolean; fivePct?: number; sevenPct?: number; threshold: number; } /** * Decide whether the configured smart-switch should kick in. When all of * the conditions hold, this turns fallback OFF as a side effect: * - smart-switch is enabled * - fallback is currently ON * - we have a cached usage payload for the active account * - the cache is not in a 429 back-off window * - both 5h and 7d utilisation are strictly below the threshold * (7d is also checked so we don't bounce back to OAuth just to hit * the weekly cap a few minutes later) */ export declare function maybeAutoDisableFallback(accountsDirPath: string, claudeJsonPath: string): AutoDisableResult; interface AutoEngageResult { /** True when this call enabled fallback. False when nothing was done. */ engaged: boolean; fivePct?: number; sevenPct?: number; /** The window that crossed the threshold (5h or 7d), if engaged. */ reason?: '5h' | '7d'; threshold: number; /** Set to a human-readable explanation when we couldn't engage even * though we wanted to (e.g. account has no API key saved). */ blocked?: string; } /** * Mirror of maybeAutoDisableFallback: when fallback is OFF and either * 5h or 7d crosses the engage threshold (defaults to 95%), turn fallback * ON if the active account has an API key saved. So you don't end up * staring at "rate limit reached" inside a long session. * * Decisive differences from auto-revert: * - either window crossing the threshold triggers (not both), * because rate-limit pain is felt as soon as one of the caps hits, * - account must have an API key to inject — we report it as * `blocked: "no API key for "` otherwise so the caller can * surface the problem instead of silently doing nothing. */ export declare function maybeAutoEngageFallback(accountsDirPath: string, claudeJsonPath: string): AutoEngageResult; export {};