mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
fix: 修复 Antigravity beta 参数和 Kiro 403 状态处理
- Antigravity: 移除 v1internal 请求中不支持的 beta 查询参数 - Kiro: 将 403 状态码统一视为账户异常,而非仅检测特定关键词
This commit is contained in:
@@ -50,6 +50,9 @@ def build_antigravity_url(
|
|||||||
if is_stream:
|
if is_stream:
|
||||||
effective_query_params.setdefault("alt", "sse")
|
effective_query_params.setdefault("alt", "sse")
|
||||||
|
|
||||||
|
# 移除 v1internal 不支持的查询参数
|
||||||
|
effective_query_params.pop("beta", None)
|
||||||
|
|
||||||
url = f"{str(base_url).rstrip('/')}{path}"
|
url = f"{str(base_url).rstrip('/')}{path}"
|
||||||
if effective_query_params:
|
if effective_query_params:
|
||||||
query_string = urlencode(effective_query_params, doseq=True)
|
query_string = urlencode(effective_query_params, doseq=True)
|
||||||
|
|||||||
@@ -115,11 +115,14 @@ async def fetch_kiro_usage_limits(
|
|||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
response_text = (response.text or "").strip()
|
response_text = (response.text or "").strip()
|
||||||
|
|
||||||
# 检测账户封禁(403/423 + 特定错误信息)
|
# 检测账户封禁(403/423 均视为封禁)
|
||||||
|
# 对于 Kiro,403 表示账户权限被拒绝(无论是封禁、权限不足还是其他原因),
|
||||||
|
# 都应该标记为异常状态,以便管理员及时处理
|
||||||
is_banned = False
|
is_banned = False
|
||||||
ban_reason = None
|
ban_reason = None
|
||||||
if response.status_code in (403, 423):
|
if response.status_code in (403, 423):
|
||||||
# 检测封禁相关错误(正则模式,通过 re.search 匹配)
|
is_banned = True
|
||||||
|
# 检测封禁相关错误(用于提供更详细的原因说明)
|
||||||
banned_keywords = [
|
banned_keywords = [
|
||||||
"AccountSuspendedException",
|
"AccountSuspendedException",
|
||||||
"account.*suspend",
|
"account.*suspend",
|
||||||
@@ -129,19 +132,22 @@ async def fetch_kiro_usage_limits(
|
|||||||
]
|
]
|
||||||
for keyword in banned_keywords:
|
for keyword in banned_keywords:
|
||||||
if re.search(keyword, response_text, re.IGNORECASE):
|
if re.search(keyword, response_text, re.IGNORECASE):
|
||||||
is_banned = True
|
|
||||||
ban_reason = (
|
ban_reason = (
|
||||||
response_text[:200] if response_text else f"HTTP {response.status_code}"
|
response_text[:200] if response_text else f"HTTP {response.status_code}"
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
if not is_banned and response.status_code == 423:
|
# 如果没有匹配到特定关键词,使用通用原因
|
||||||
# 423 Locked 通常表示账户被锁定/封禁
|
if not ban_reason:
|
||||||
is_banned = True
|
if response.status_code == 423:
|
||||||
ban_reason = response_text[:200] if response_text else "HTTP 423 Locked"
|
ban_reason = response_text[:200] if response_text else "HTTP 423 Locked"
|
||||||
|
else:
|
||||||
|
ban_reason = (
|
||||||
|
response_text[:200] if response_text else "HTTP 403 权限被拒绝"
|
||||||
|
)
|
||||||
|
|
||||||
error_msg = {
|
error_msg = {
|
||||||
401: "认证失败,Token 无效或已过期",
|
401: "认证失败,Token 无效或已过期",
|
||||||
403: "账户已封禁" if is_banned else "权限不足,无法获取使用额度",
|
403: "账户异常,权限被拒绝",
|
||||||
423: "账户已封禁",
|
423: "账户已封禁",
|
||||||
429: "请求过于频繁,已被限流",
|
429: "请求过于频繁,已被限流",
|
||||||
}.get(response.status_code, "获取使用额度失败")
|
}.get(response.status_code, "获取使用额度失败")
|
||||||
|
|||||||
Reference in New Issue
Block a user