mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
fix: use codex quota refresh for account checks
This commit is contained in:
@@ -21,8 +21,8 @@ pub use providers::{
|
||||
AntigravityProviderPoolAdapter, ChatGptWebProviderPoolAdapter, CodexProviderPoolAdapter,
|
||||
DefaultProviderPoolAdapter, KiroPoolQuotaAuthInput, KiroProviderPoolAdapter,
|
||||
UnsupportedQuotaProviderPoolAdapter, ANTIGRAVITY_FETCH_AVAILABLE_MODELS_PATH,
|
||||
CHATGPT_WEB_CONVERSATION_INIT_PATH, CHATGPT_WEB_DEFAULT_BASE_URL, CODEX_BACKEND_ME_URL,
|
||||
CODEX_WHAM_USAGE_URL, KIRO_USAGE_LIMITS_PATH, KIRO_USAGE_SDK_VERSION,
|
||||
CHATGPT_WEB_CONVERSATION_INIT_PATH, CHATGPT_WEB_DEFAULT_BASE_URL, CODEX_WHAM_USAGE_URL,
|
||||
KIRO_USAGE_LIMITS_PATH, KIRO_USAGE_SDK_VERSION,
|
||||
};
|
||||
pub use quota::{
|
||||
provider_pool_key_account_quota_exhausted, provider_pool_key_scheduling_label,
|
||||
@@ -87,8 +87,6 @@ mod tests {
|
||||
assert!(service.supports_quota_refresh("codex"));
|
||||
assert!(service.supports_quota_refresh("antigravity"));
|
||||
assert!(!service.supports_quota_refresh("gemini_cli"));
|
||||
assert!(service.supports_account_self_check("codex"));
|
||||
assert!(!service.supports_account_self_check("gemini_cli"));
|
||||
assert_eq!(
|
||||
service.quota_refresh_unsupported_message("claude_code"),
|
||||
"Claude Code 暂不支持自动刷新额度:上游没有稳定可用的账号额度查询接口"
|
||||
@@ -119,7 +117,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codex_quota_request_uses_backend_me_probe_endpoint() {
|
||||
fn codex_quota_request_uses_wham_usage_endpoint() {
|
||||
let spec = build_codex_pool_quota_request(
|
||||
"key-1",
|
||||
Some(("authorization".to_string(), "Bearer access".to_string())),
|
||||
@@ -129,7 +127,7 @@ mod tests {
|
||||
.expect("spec should build");
|
||||
|
||||
assert_eq!(spec.method, "GET");
|
||||
assert_eq!(spec.url, "https://chatgpt.com/backend-api/me");
|
||||
assert_eq!(spec.url, "https://chatgpt.com/backend-api/wham/usage");
|
||||
assert_eq!(
|
||||
spec.headers.get("authorization").map(String::as_str),
|
||||
Some("Bearer access")
|
||||
@@ -138,7 +136,7 @@ mod tests {
|
||||
spec.headers.get("accept").map(String::as_str),
|
||||
Some("application/json")
|
||||
);
|
||||
assert_eq!(spec.model_name.as_deref(), Some("codex-backend-me"));
|
||||
assert_eq!(spec.model_name.as_deref(), Some("codex-wham-usage"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -53,21 +53,6 @@ pub trait ProviderPoolAdapter: Send + Sync {
|
||||
"找不到有效端点".to_string()
|
||||
}
|
||||
|
||||
fn supports_account_self_check(&self) -> bool {
|
||||
self.supports_quota_refresh()
|
||||
}
|
||||
|
||||
fn account_self_check_endpoint(
|
||||
&self,
|
||||
endpoints: &[StoredProviderCatalogEndpoint],
|
||||
include_inactive: bool,
|
||||
) -> Option<StoredProviderCatalogEndpoint> {
|
||||
if !self.supports_account_self_check() {
|
||||
return None;
|
||||
}
|
||||
self.quota_refresh_endpoint(endpoints, include_inactive)
|
||||
}
|
||||
|
||||
fn normalize_plan_tier(&self, value: &str) -> Option<String> {
|
||||
normalize_provider_plan_tier(value, self.provider_type())
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ use crate::quota::{
|
||||
};
|
||||
use crate::quota_refresh::ProviderPoolQuotaRequestSpec;
|
||||
|
||||
pub const CODEX_BACKEND_ME_URL: &str = "https://chatgpt.com/backend-api/me";
|
||||
pub const CODEX_WHAM_USAGE_URL: &str = CODEX_BACKEND_ME_URL;
|
||||
pub const CODEX_WHAM_USAGE_URL: &str = "https://chatgpt.com/backend-api/wham/usage";
|
||||
const PLACEHOLDER_API_KEY: &str = "__placeholder__";
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
@@ -111,13 +110,13 @@ pub fn build_codex_pool_quota_request(
|
||||
provider_name: "codex".to_string(),
|
||||
quota_kind: "codex".to_string(),
|
||||
method: "GET".to_string(),
|
||||
url: CODEX_BACKEND_ME_URL.to_string(),
|
||||
url: CODEX_WHAM_USAGE_URL.to_string(),
|
||||
headers,
|
||||
content_type: None,
|
||||
json_body: None,
|
||||
client_api_format: "openai:responses".to_string(),
|
||||
provider_api_format: "openai:responses".to_string(),
|
||||
model_name: Some("codex-backend-me".to_string()),
|
||||
model_name: Some("codex-wham-usage".to_string()),
|
||||
accept_invalid_certs: false,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ pub use chatgpt_web::{
|
||||
CHATGPT_WEB_DEFAULT_BASE_URL,
|
||||
};
|
||||
pub use codex::CodexProviderPoolAdapter;
|
||||
pub use codex::{build_codex_pool_quota_request, CODEX_BACKEND_ME_URL, CODEX_WHAM_USAGE_URL};
|
||||
pub use codex::{build_codex_pool_quota_request, CODEX_WHAM_USAGE_URL};
|
||||
pub use default::DefaultProviderPoolAdapter;
|
||||
pub use kiro::KiroProviderPoolAdapter;
|
||||
pub use kiro::{
|
||||
|
||||
@@ -104,20 +104,6 @@ impl ProviderPoolService {
|
||||
.quota_refresh_missing_endpoint_message()
|
||||
}
|
||||
|
||||
pub fn supports_account_self_check(&self, provider_type: &str) -> bool {
|
||||
self.adapter(provider_type).supports_account_self_check()
|
||||
}
|
||||
|
||||
pub fn account_self_check_endpoint_for_provider(
|
||||
&self,
|
||||
provider_type: &str,
|
||||
endpoints: &[StoredProviderCatalogEndpoint],
|
||||
include_inactive: bool,
|
||||
) -> Option<StoredProviderCatalogEndpoint> {
|
||||
self.adapter(provider_type)
|
||||
.account_self_check_endpoint(endpoints, include_inactive)
|
||||
}
|
||||
|
||||
pub fn normalize_scheduling_presets(
|
||||
&self,
|
||||
provider_type: &str,
|
||||
|
||||
Reference in New Issue
Block a user