diff --git a/src/providers/claude/claude-kiro.js b/src/providers/claude/claude-kiro.js index bc14a69..252fcff 100644 --- a/src/providers/claude/claude-kiro.js +++ b/src/providers/claude/claude-kiro.js @@ -1355,14 +1355,23 @@ async saveCredentialsToFile(filePath, newData) { if (status === 403) { console.log('[Kiro] Received 403. Marking credential as need refresh...'); - // 1. 先刷新 UUID - const newUuid = this._refreshUuid(); - if (newUuid) { - console.log(`[Kiro] UUID refreshed: ${this.uuid} -> ${newUuid}`); - this.uuid = newUuid; + // 检查是否为 temporarily suspended 错误 + const isSuspended = errorMessage && errorMessage.toLowerCase().includes('temporarily is suspended'); + + if (isSuspended) { + // temporarily suspended 错误:直接标记为不健康,不刷新 UUID + console.log('[Kiro] Account temporarily suspended. Marking as unhealthy without UUID refresh...'); + this._markCredentialUnhealthy('403 Forbidden - Account temporarily suspended', error); + } else { + // 其他 403 错误:先刷新 UUID,然后标记需要刷新 + const newUuid = this._refreshUuid(); + if (newUuid) { + console.log(`[Kiro] UUID refreshed: ${this.uuid} -> ${newUuid}`); + this.uuid = newUuid; + } + this._markCredentialNeedRefresh('403 Forbidden', error); } - this._markCredentialNeedRefresh('403 Forbidden', error); // Mark error for credential switch without recording error count error.shouldSwitchCredential = true; error.skipErrorCount = true; @@ -1871,14 +1880,23 @@ async saveCredentialsToFile(filePath, newData) { if (status === 403) { console.log('[Kiro] Received 403 in stream. Marking credential as need refresh...'); - // 1. 先刷新 UUID - const newUuid = this._refreshUuid(); - if (newUuid) { - console.log(`[Kiro] UUID refreshed: ${this.uuid} -> ${newUuid}`); - this.uuid = newUuid; + // 检查是否为 temporarily suspended 错误 + const isSuspended = errorMessage && errorMessage.toLowerCase().includes('temporarily is suspended'); + + if (isSuspended) { + // temporarily suspended 错误:直接标记为不健康,不刷新 UUID + console.log('[Kiro] Account temporarily suspended in stream. Marking as unhealthy without UUID refresh...'); + this._markCredentialUnhealthy('403 Forbidden - Account temporarily suspended', error); + } else { + // 其他 403 错误:先刷新 UUID,然后标记需要刷新 + const newUuid = this._refreshUuid(); + if (newUuid) { + console.log(`[Kiro] UUID refreshed: ${this.uuid} -> ${newUuid}`); + this.uuid = newUuid; + } + this._markCredentialNeedRefresh('403 Forbidden', error); } - this._markCredentialNeedRefresh('403 Forbidden', error); // Mark error for credential switch without recording error count error.shouldSwitchCredential = true; error.skipErrorCount = true; @@ -2770,7 +2788,19 @@ async saveCredentialsToFile(filePath, newData) { if (status === 403) { console.log('[Kiro] Received 403 on getUsageLimits. Marking credential as unhealthy (no retry)...'); - this._markCredentialNeedRefresh('403 Forbidden on usage query', formattedError); + + // 检查是否为 temporarily suspended 错误 + const isSuspended = errorMessage && errorMessage.toLowerCase().includes('temporarily is suspended'); + + if (isSuspended) { + // temporarily suspended 错误:直接标记为不健康,不刷新 UUID + console.log('[Kiro] Account temporarily suspended on usage query. Marking as unhealthy without UUID refresh...'); + this._markCredentialUnhealthy('403 Forbidden - Account temporarily suspended on usage query', formattedError); + } else { + // 其他 403 错误:标记需要刷新 + this._markCredentialNeedRefresh('403 Forbidden on usage query', formattedError); + } + throw formattedError; }