feat(oauth): add Qwen OAuth integration

This commit is contained in:
mingholy.lmh
2025-08-08 09:48:31 +08:00
parent ffc2d27ca3
commit ea7dcf8347
37 changed files with 7795 additions and 169 deletions

View File

@@ -8,6 +8,8 @@ import { AuthType } from '../core/contentGenerator.js';
import {
isProQuotaExceededError,
isGenericQuotaExceededError,
isQwenQuotaExceededError,
isQwenThrottlingError,
} from './quotaErrorDetection.js';
export interface HttpError extends Error {
@@ -150,9 +152,23 @@ export async function retryWithBackoff<T>(
}
}
// Track consecutive 429 errors
// Check for Qwen OAuth quota exceeded error - throw immediately without retry
if (authType === AuthType.QWEN_OAUTH && isQwenQuotaExceededError(error)) {
throw new Error(
`Qwen API quota exceeded: Your Qwen API quota has been exhausted. Please wait for your quota to reset.`,
);
}
// Track consecutive 429 errors, but handle Qwen throttling differently
if (errorStatus === 429) {
consecutive429Count++;
// For Qwen throttling errors, we still want to track them for exponential backoff
// but not for quota fallback logic (since Qwen doesn't have model fallback)
if (authType === AuthType.QWEN_OAUTH && isQwenThrottlingError(error)) {
// Keep track of 429s but reset the consecutive count to avoid fallback logic
consecutive429Count = 0;
} else {
consecutive429Count++;
}
} else {
consecutive429Count = 0;
}