fix: update backoff configuration and improve CLI detection messages

- Added installation guides for manual configuration in DroidToolCard.js and other tool cards to assist users in setting up the necessary CLI tools.
This commit is contained in:
decolua
2026-04-17 12:51:08 +07:00
parent afe09f3f14
commit 6ab9927a28
7 changed files with 95 additions and 47 deletions

View File

@@ -31,7 +31,7 @@ export const DEFAULT_ERROR_MESSAGES = {
// Exponential backoff config for rate limits
export const BACKOFF_CONFIG = {
base: 1000,
max: 3 * 60 * 1000,
max: 4 * 60 * 1000,
maxLevel: 15
};

View File

@@ -2,12 +2,13 @@ import { ERROR_RULES, BACKOFF_CONFIG, TRANSIENT_COOLDOWN_MS } from "../config/er
/**
* Calculate exponential backoff cooldown for rate limits (429)
* Level 0: 1s, Level 1: 2s, Level 2: 4s... → max 2 min
* Level 1: 1s, Level 2: 2s, Level 3: 4s... → max 4 min
* @param {number} backoffLevel - Current backoff level
* @returns {number} Cooldown in milliseconds
*/
export function getQuotaCooldown(backoffLevel = 0) {
const cooldown = BACKOFF_CONFIG.base * Math.pow(2, backoffLevel);
const level = Math.max(0, backoffLevel - 1);
const cooldown = BACKOFF_CONFIG.base * Math.pow(2, level);
return Math.min(cooldown, BACKOFF_CONFIG.max);
}
@@ -29,7 +30,7 @@ export function checkFallbackError(status, errorText, backoffLevel = 0) {
if (rule.text && lowerError && lowerError.includes(rule.text)) {
if (rule.backoff) {
const newLevel = Math.min(backoffLevel + 1, BACKOFF_CONFIG.maxLevel);
return { shouldFallback: true, cooldownMs: getQuotaCooldown(backoffLevel), newBackoffLevel: newLevel };
return { shouldFallback: true, cooldownMs: getQuotaCooldown(newLevel), newBackoffLevel: newLevel };
}
return { shouldFallback: true, cooldownMs: rule.cooldownMs };
}
@@ -38,7 +39,7 @@ export function checkFallbackError(status, errorText, backoffLevel = 0) {
if (rule.status && rule.status === status) {
if (rule.backoff) {
const newLevel = Math.min(backoffLevel + 1, BACKOFF_CONFIG.maxLevel);
return { shouldFallback: true, cooldownMs: getQuotaCooldown(backoffLevel), newBackoffLevel: newLevel };
return { shouldFallback: true, cooldownMs: getQuotaCooldown(newLevel), newBackoffLevel: newLevel };
}
return { shouldFallback: true, cooldownMs: rule.cooldownMs };
}