refactor: add recovery mode + shared JSON/error/fetch utilities
- GroupQueue recovery mode: limit to 3 concurrent agents for 60s after restart to prevent API rate-limit storms (configurable via env vars) - getErrorMessage: replace 14 occurrences of instanceof Error pattern - readJsonFile/writeJsonFile: replace 19 occurrences of JSON+fs pattern - fetchWithTimeout: replace 3 occurrences of AbortController pattern 354/354 tests passing
This commit is contained in:
@@ -8,8 +8,15 @@
|
||||
import { shouldRotateClaudeToken } from './agent-error-detection.js';
|
||||
import { logger } from './logger.js';
|
||||
import { getErrorMessage } from './utils.js';
|
||||
import { detectFallbackTrigger, markPrimaryCooldown } from './provider-fallback.js';
|
||||
import { rotateToken, getTokenCount, markTokenHealthy } from './token-rotation.js';
|
||||
import {
|
||||
detectFallbackTrigger,
|
||||
markPrimaryCooldown,
|
||||
} from './provider-fallback.js';
|
||||
import {
|
||||
rotateToken,
|
||||
getTokenCount,
|
||||
markTokenHealthy,
|
||||
} from './token-rotation.js';
|
||||
|
||||
// ── Types ────────────────────────────────────────────────────────
|
||||
|
||||
@@ -115,7 +122,10 @@ export async function runClaudeRotationLoop(
|
||||
|
||||
// ── Success with null result (MAE-specific, TaskScheduler ignores) ──
|
||||
if (!attempt.sawOutput && attempt.sawSuccessNullResult) {
|
||||
return { type: 'needs-fallback', trigger: { reason: 'success-null-result' } };
|
||||
return {
|
||||
type: 'needs-fallback',
|
||||
trigger: { reason: 'success-null-result' },
|
||||
};
|
||||
}
|
||||
|
||||
// ── Error status ──
|
||||
|
||||
Reference in New Issue
Block a user