mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
Anthropic OAuth/setup-token accounts now expose a Fable-only 7d window in 429 responses (anthropic-ratelimit-unified-7d_oi-*). Previously, a 429 triggered solely by this window fell through to the legacy path and marked the whole account rate limited (picking the sooner 5h/7d reset) even though 5h/7d were still "allowed". Backend: - HandleUpstreamError: when only 7d_oi is rejected/exceeded, set a model-level rate limit (scope "claude-fable-5") and skip account-level SetRateLimited / session-window rewrite / temp-unsched entirely. Real 5h/7d exhaustion keeps the exact legacy account-level behavior. - modelRateLimitKeysForRequest: append the Fable family scope for any mapped Anthropic model containing "fable", so claude-fable-5[1m] and other variants are excluded from scheduling together. - Passive sampling: collect 7d_oi utilization/reset into Extra (passive_usage_7d_oi_*), including from the 429 response itself so the usage bar doesn't freeze at a stale value during the limit window; cleared on 5h window reset like the existing 7d keys. - Usage API: new seven_day_fable window in UsageInfo. GetPassiveUsage builds it from passive samples; active queries parse the upstream seven_day_overage_included field (claim name from the representative-claim header) and fall back to passive data when the upstream usage API doesn't return it, so the active-query button keeps the bar populated. seven_day_sonnet handling is preserved unchanged. Frontend: - /admin/accounts usage cell renders a "7d F" (amber) progress bar next to the existing 5h / 7d / 7d S bars for Anthropic OAuth/setup-token accounts.