mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
Unify quota snapshots and oauth refresh handling
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import client from '../client'
|
||||
import type { EndpointAPIKey, AllowedModels } from './types'
|
||||
import type { QuotaStatusSnapshot } from './types'
|
||||
|
||||
// Re-export types for convenience
|
||||
export type { EndpointAPIKey, AllowedModels }
|
||||
@@ -212,9 +213,18 @@ export interface RefreshQuotaResult {
|
||||
results: Array<{
|
||||
key_id: string
|
||||
key_name: string
|
||||
status: 'success' | 'no_metadata' | 'error'
|
||||
// Codex: 额度字段为扁平结构;Antigravity: 返回 { antigravity: { quota_by_model: ... } }
|
||||
status:
|
||||
| 'success'
|
||||
| 'no_metadata'
|
||||
| 'quota_exhausted'
|
||||
| 'workspace_deactivated'
|
||||
| 'auth_invalid'
|
||||
| 'forbidden'
|
||||
| 'banned'
|
||||
| 'error'
|
||||
// provider 级 bucket 数据;前端应按当前 provider_type 包装回 upstream_metadata.<provider_type>
|
||||
metadata?: Record<string, unknown>
|
||||
quota_snapshot?: QuotaStatusSnapshot
|
||||
message?: string
|
||||
status_code?: number
|
||||
}>
|
||||
|
||||
@@ -143,7 +143,7 @@ export interface PoolKeyDetail {
|
||||
model_include_patterns?: string[] | null
|
||||
model_exclude_patterns?: string[] | null
|
||||
proxy?: ProxyConfig | null
|
||||
account_quota: string | null
|
||||
account_quota: string | null // compatibility only; UI should prefer status_snapshot.quota
|
||||
cooldown_reason: string | null
|
||||
cooldown_ttl_seconds: number | null
|
||||
cost_window_usage: number
|
||||
|
||||
@@ -2,3 +2,4 @@ export * from './api-format'
|
||||
export * from './provider'
|
||||
export * from './model'
|
||||
export * from './routing'
|
||||
export * from './statusSnapshot'
|
||||
|
||||
@@ -18,15 +18,45 @@ export interface AccountStatusSnapshot {
|
||||
recoverable?: boolean
|
||||
}
|
||||
|
||||
export interface QuotaWindowSnapshot {
|
||||
code: string
|
||||
label?: string | null
|
||||
scope?: 'account' | 'workspace' | 'model' | string
|
||||
unit?: 'percent' | 'count' | 'usd' | 'tokens' | string
|
||||
model?: string | null
|
||||
used_ratio?: number | null
|
||||
remaining_ratio?: number | null
|
||||
used_value?: number | null
|
||||
remaining_value?: number | null
|
||||
limit_value?: number | null
|
||||
reset_at?: number | null
|
||||
reset_seconds?: number | null
|
||||
window_minutes?: number | null
|
||||
is_exhausted?: boolean | null
|
||||
}
|
||||
|
||||
export interface QuotaCreditsSnapshot {
|
||||
has_credits?: boolean | null
|
||||
balance?: number | null
|
||||
unlimited?: boolean | null
|
||||
}
|
||||
|
||||
export interface QuotaStatusSnapshot {
|
||||
code: 'unknown' | 'ok' | 'exhausted'
|
||||
version?: number | null
|
||||
provider_type?: string | null
|
||||
code: 'unknown' | 'ok' | 'exhausted' | 'cooldown' | 'forbidden' | 'banned' | string
|
||||
label?: string | null
|
||||
reason?: string | null
|
||||
freshness?: 'fresh' | 'stale' | 'unknown' | 'error' | string | null
|
||||
source?: string | null
|
||||
observed_at?: number | null
|
||||
exhausted: boolean
|
||||
usage_ratio?: number | null
|
||||
updated_at?: number | null
|
||||
reset_seconds?: number | null
|
||||
plan_type?: string | null
|
||||
credits?: QuotaCreditsSnapshot | null
|
||||
windows?: QuotaWindowSnapshot[] | null
|
||||
}
|
||||
|
||||
export interface ProviderKeyStatusSnapshot {
|
||||
|
||||
Reference in New Issue
Block a user