mirror of
https://github.com/decolua/9router.git
synced 2026-05-08 12:01:28 +00:00
- Added Hermes tool to CLI tools and updated related components.
This commit is contained in:
@@ -41,13 +41,24 @@ export const RETRY_CONFIG = {
|
||||
delayMs: 2000
|
||||
};
|
||||
|
||||
// Default retry config by status code (number of retry attempts)
|
||||
// Default retry config by status code: { attempts, delayMs }
|
||||
// Backward compat: if value is a number, treated as attempts with RETRY_CONFIG.delayMs
|
||||
export const DEFAULT_RETRY_CONFIG = {
|
||||
429: 0, // Rate limit - no retry, use account fallback instead
|
||||
503: 1, // Service unavailable - retry 1 time (transient)
|
||||
502: 1 // Bad gateway - retry 1 time (transient)
|
||||
429: { attempts: 0, delayMs: 0 },
|
||||
502: { attempts: 1, delayMs: 3000 },
|
||||
503: { attempts: 1, delayMs: 2000 }
|
||||
};
|
||||
|
||||
// Normalize a retry entry to { attempts, delayMs }
|
||||
export function resolveRetryEntry(entry) {
|
||||
if (entry == null) return { attempts: 0, delayMs: RETRY_CONFIG.delayMs };
|
||||
if (typeof entry === "number") return { attempts: entry, delayMs: RETRY_CONFIG.delayMs };
|
||||
return {
|
||||
attempts: entry.attempts || 0,
|
||||
delayMs: entry.delayMs != null ? entry.delayMs : RETRY_CONFIG.delayMs
|
||||
};
|
||||
}
|
||||
|
||||
// Requests containing these texts will bypass provider
|
||||
export const SKIP_PATTERNS = [
|
||||
"Please write a 5-10 word title for the following conversation:"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { HTTP_STATUS, RETRY_CONFIG, DEFAULT_RETRY_CONFIG } from "../config/runtimeConfig.js";
|
||||
import { HTTP_STATUS, RETRY_CONFIG, DEFAULT_RETRY_CONFIG, resolveRetryEntry } from "../config/runtimeConfig.js";
|
||||
import { resolveOllamaLocalHost } from "../config/providers.js";
|
||||
import { proxyAwareFetch } from "../utils/proxyFetch.js";
|
||||
|
||||
@@ -124,11 +124,11 @@ export class BaseExecutor {
|
||||
}, proxyOptions);
|
||||
|
||||
// Retry based on status code config
|
||||
const maxRetries = retryConfig[response.status] || 0;
|
||||
const { attempts: maxRetries, delayMs } = resolveRetryEntry(retryConfig[response.status]);
|
||||
if (maxRetries > 0 && retryAttemptsByUrl[urlIndex] < maxRetries) {
|
||||
retryAttemptsByUrl[urlIndex]++;
|
||||
log?.debug?.("RETRY", `${response.status} retry ${retryAttemptsByUrl[urlIndex]}/${maxRetries} after ${RETRY_CONFIG.delayMs / 1000}s`);
|
||||
await new Promise(resolve => setTimeout(resolve, RETRY_CONFIG.delayMs));
|
||||
log?.debug?.("RETRY", `${response.status} retry ${retryAttemptsByUrl[urlIndex]}/${maxRetries} after ${delayMs / 1000}s`);
|
||||
await new Promise(resolve => setTimeout(resolve, delayMs));
|
||||
urlIndex--;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { PROVIDERS } from "../config/providers.js";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { refreshKiroToken } from "../services/tokenRefresh.js";
|
||||
import { proxyAwareFetch } from "../utils/proxyFetch.js";
|
||||
import { HTTP_STATUS, RETRY_CONFIG, DEFAULT_RETRY_CONFIG } from "../config/runtimeConfig.js";
|
||||
import { HTTP_STATUS, RETRY_CONFIG, DEFAULT_RETRY_CONFIG, resolveRetryEntry } from "../config/runtimeConfig.js";
|
||||
|
||||
/**
|
||||
* KiroExecutor - Executor for Kiro AI (AWS CodeWhisperer)
|
||||
@@ -54,11 +54,11 @@ export class KiroExecutor extends BaseExecutor {
|
||||
}, proxyOptions);
|
||||
|
||||
// Check if should retry based on status code
|
||||
const maxRetries = retryConfig[response.status] || 0;
|
||||
const { attempts: maxRetries, delayMs } = resolveRetryEntry(retryConfig[response.status]);
|
||||
if (!response.ok && maxRetries > 0 && retryAttempts < maxRetries) {
|
||||
retryAttempts++;
|
||||
log?.debug?.("RETRY", `${response.status} retry ${retryAttempts}/${maxRetries} after ${RETRY_CONFIG.delayMs / 1000}s`);
|
||||
await new Promise(resolve => setTimeout(resolve, RETRY_CONFIG.delayMs));
|
||||
log?.debug?.("RETRY", `${response.status} retry ${retryAttempts}/${maxRetries} after ${delayMs / 1000}s`);
|
||||
await new Promise(resolve => setTimeout(resolve, delayMs));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user