1. 02 Apr, 2026 1 commit
  2. 25 Mar, 2026 1 commit
  3. 22 Mar, 2026 1 commit
  4. 19 Mar, 2026 1 commit
    • shaw's avatar
      feat: Anthropic 账号被动用量采样,页面默认展示被动数据 · 525cdb88
      shaw authored
      从上游 /v1/messages 响应头被动采集 5h/7d utilization 并存储到
      Account.Extra,页面加载时直接读取本地数据而非调用外部 Usage API。
      用户可点击"查询"按钮主动拉取最新数据,主动查询结果自动回写被动缓存。
      
      后端:
      - UpdateSessionWindow 合并采集 5h + 7d headers 为单次 DB 写入
      - 新增 GetPassiveUsage 从 Extra 构建 UsageInfo (复用 estimateSetupTokenUsage)
      - GetUsage 主动查询后 syncActiveToPassive 回写被动缓存
      - passive_usage_ 前缀注册为 scheduler-neutral
      
      前端:
      - Anthropic 账号 mount/refresh 默认 source=passive
      - 新增"被动采样"标签和"查询"按钮 (带 loading 动画)
      525cdb88
  5. 18 Mar, 2026 1 commit
    • shaw's avatar
      feat: add 529 overload cooldown toggle and duration settings in admin gateway page · bf3d6c0e
      shaw authored
      Move 529 overload cooldown configuration from config file to admin
      settings UI. Adds an enable/disable toggle and configurable cooldown
      duration (1-120 min) under /admin/settings gateway tab, stored as
      JSON in the settings table.
      
      When disabled, 529 errors are logged but accounts are no longer
      paused from scheduling. Falls back to config file value when DB
      is unreachable or settingService is nil.
      bf3d6c0e
  6. 17 Mar, 2026 1 commit
    • haruka's avatar
      fix(review): address Copilot PR feedback · 869952d1
      haruka authored
      
      
      - Add compile-time interface assertion for sessionWindowMockRepo
      - Fix flaky fallback test by capturing time.Now() before calling UpdateSessionWindow
      - Replace stale hardcoded timestamps with dynamic future values
      - Add millisecond detection and bounds validation for reset header timestamp
      - Use pause/resume pattern for interval in UsageProgressBar to avoid idle timers on large lists
      - Fix gofmt comment alignment
      Co-Authored-By: default avatarClaude Sonnet 4.6 <noreply@anthropic.com>
      869952d1
  7. 16 Mar, 2026 1 commit
    • Elysia's avatar
      fix(usage): use real reset header for session window instead of prediction · 668e1647
      Elysia authored
      
      
      The 5h window reset time displayed for Setup Token accounts was inaccurate
      because UpdateSessionWindow predicted the window end as "current hour + 5h"
      instead of reading the actual `anthropic-ratelimit-unified-5h-reset` response
      header. This caused the countdown to differ from the official Claude page.
      
      Backend: parse the reset header (Unix timestamp) and use it as the real
      window end, falling back to the hour-truncated prediction only when the
      header is absent. Also correct stale predictions when a subsequent request
      provides the real reset time.
      
      Frontend: add a reactive 60s timer so the reset countdown in
      UsageProgressBar ticks down in real-time instead of freezing at the
      initial value.
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      668e1647
  8. 15 Mar, 2026 2 commits
    • erio's avatar
      refactor: replace sync.Map credits state with AICredits rate limit key · 8a260def
      erio authored
      Replace process-memory sync.Map + per-model runtime state with a single
      "AICredits" key in model_rate_limits, making credits exhaustion fully
      isomorphic with model-level rate limiting.
      
      Scheduler: rate-limited accounts with overages enabled + credits available
      are now scheduled instead of excluded.
      
      Forwarding: when model is rate-limited + credits available, inject credits
      proactively without waiting for a 429 round trip.
      
      Storage: credits exhaustion stored as model_rate_limits["AICredits"] with
      5h duration, reusing SetModelRateLimit/isRateLimitActiveForKey.
      
      Frontend: show credits_active (yellow ) when model rate-limited but
      credits available, credits_exhausted (red) when AICredits key active.
      
      Tests: add unit tests for shouldMarkCreditsExhausted, injectEnabledCreditTypes,
      clearCreditsExhausted, and update existing overages tests.
      8a260def
    • SilentFlower's avatar
      feat: implement resolveCreditsOveragesModelKey function to stabilize model key... · 17e40333
      SilentFlower authored
      feat: implement resolveCreditsOveragesModelKey function to stabilize model key resolution for credit overages
      17e40333
  9. 13 Mar, 2026 2 commits
    • erio's avatar
      fix: restore OAuth 401 temp-unschedulable for Gemini, update Antigravity tests · 45456fa2
      erio authored
      The 403 detection PR changed the 401 handler condition from
      `account.Type == AccountTypeOAuth` to
      `account.Type == AccountTypeOAuth && account.Platform == PlatformOpenAI`,
      which accidentally excluded Gemini OAuth from the temp-unschedulable path.
      
      Fix: use `!= PlatformAntigravity` instead, preserving Gemini behavior
      while correctly excluding Antigravity (whose 401 is handled by
      applyErrorPolicy's temp_unschedulable_rules).
      
      Update tests to reflect Antigravity's new 401 semantics:
      - HandleUpstreamError: Antigravity OAuth 401 now uses SetError
      - CheckErrorPolicy: Antigravity 401 second hit stays TempUnscheduled
      - DB fallback: split into Gemini (escalates) and Antigravity (stays temp)
      45456fa2
    • erio's avatar
      feat(antigravity): add 403 forbidden status detection, classification and display · 6344fa2a
      erio authored
      Backend:
      - Detect and classify 403 responses into three types:
        validation (account needs Google verification),
        violation (terms of service / banned),
        forbidden (generic 403)
      - Extract verification/appeal URLs from 403 response body
        (structured JSON parsing with regex fallback)
      - Add needs_verify, is_banned, needs_reauth, error_code fields
        to UsageInfo (omitempty for zero impact on other platforms)
      - Handle 403 in request path: classify and permanently set account error
      - Save validation_url in error_message for degraded path recovery
      - Enrich usage with account error on both success and degraded paths
      - Add singleflight dedup for usage requests with independent context
      - Differentiate cache TTL: success/403 → 3min, errors → 1min
      - Return degraded UsageInfo instead of HTTP 500 on quota fetch errors
      
      Frontend:
      - Display forbidden status badges with color coding (red for banned,
        amber for needs verification, gray for generic)
      - Show clickable verification/appeal URL links
      - Display needs_reauth and degraded error states in usage cell
      - Add Antigravity tier label badge next to platform type
      
      Tests:
      - Comprehensive unit tests for classifyForbiddenType (7 cases)
      - Unit tests for extractValidationURL (8 cases including unicode escapes)
      - Integration test for FetchQuota forbidden path
      6344fa2a
  10. 08 Mar, 2026 1 commit
  11. 07 Mar, 2026 2 commits
    • kyx236's avatar
      feat(admin): 支持定时测试自动恢复并统一账号恢复入口 · 0c29468f
      kyx236 authored
      - 为定时测试计划增加 auto_recover 配置,补齐前后端类型、接口、仓储与数据库迁移
      - 在定时测试成功后自动恢复账号 error、rate-limit 等可恢复运行时状态
      - 新增 /admin/accounts/:id/recover-state 接口,合并原有重置状态与清限流操作
      - 更新账号管理菜单与定时测试面板,补充自动恢复开关、说明提示和状态展示
      - 补充账号恢复、限流清理与仓储同步相关测试
      0c29468f
    • 神乐's avatar
      0debe0a8
  12. 06 Mar, 2026 1 commit
  13. 04 Mar, 2026 2 commits
  14. 02 Mar, 2026 1 commit
    • zqq61's avatar
      fix: OAuth 401 不再永久锁死账号,改用临时不可调度实现自动恢复 · ec6bcfeb
      zqq61 authored
      OAuth 账号收到 401 时,原逻辑同时设置 expires_at=now() 和 SetError(),
      但刷新服务只查询 status=active 的账号,导致 error 状态的账号永远无法
      被刷新服务拾取,expires_at=now() 实际上是死代码。
      
      修复:
      - OAuth 401 使用 SetTempUnschedulable 替代 SetError,保持 status=active
      - 新增 oauth_401_cooldown_minutes 配置项(默认 10 分钟)
      - 刷新成功后同步清除 DB 和 Redis 中的临时不可调度状态
      - 不可重试错误检查(invalid_grant 等)从 Antigravity 推广到所有平台
      - 可重试错误耗尽后不再标记 error,下个刷新周期继续重试
      
      恢复流程:
      OAuth 401 → temp_unschedulable + expires_at=now → 刷新服务拾取
        → 成功: 清除 temp_unschedulable → 自动恢复
        → invalid_grant: SetError → 永久禁用
        → 网络错误: 仅记日志 → 下周期重试
      ec6bcfeb
  15. 28 Feb, 2026 1 commit
  16. 22 Feb, 2026 1 commit
  17. 13 Feb, 2026 1 commit
    • shaw's avatar
      fix: Anthropic 429 限流使用精确的窗口重置时间而非聚合最大值 · e6814314
      shaw authored
      当账号仅触发 5h 窗口限流时,旧逻辑从聚合头
      anthropic-ratelimit-unified-reset 读取重置时间,该值为所有窗口的
      最大值(即 7d 重置时间),导致账号被标记为不可调度约 6 天。
      
      新增 calculateAnthropic429ResetTime 函数,解析 Anthropic 的
      per-window 头(5h-utilization/reset、7d-utilization/reset、
      surpassed-threshold),判断实际触发的窗口并使用对应的重置时间:
      - 仅 5h 超标 → 使用 5h-reset(约 5 小时)
      - 仅 7d 超标 → 使用 7d-reset
      - 两者均超标 → 使用 7d-reset(较长冷却)
      - per-window 头不存在 → 回退到聚合头(向后兼容)
      e6814314
  18. 09 Feb, 2026 1 commit
  19. 08 Feb, 2026 1 commit
  20. 07 Feb, 2026 1 commit
    • erio's avatar
      feat(antigravity): comprehensive enhancements - model mapping, rate limiting, scheduling & ops · 5e98445b
      erio authored
      Key changes:
      - Upgrade model mapping: Opus 4.5 → Opus 4.6-thinking with precise matching
      - Unified rate limiting: scope-level → model-level with Redis snapshot sync
      - Load-balanced scheduling by call count with smart retry mechanism
      - Force cache billing support
      - Model identity injection in prompts with leak prevention
      - Thinking mode auto-handling (max_tokens/budget_tokens fix)
      - Frontend: whitelist mode toggle, model mapping validation, status indicators
      - Gemini session fallback with Redis Trie O(L) matching
      - Ops: enhanced concurrency monitoring, account availability, retry logic
      - Migration scripts: 049-051 for model mapping unification
      5e98445b
  21. 02 Feb, 2026 1 commit
  22. 26 Jan, 2026 1 commit
    • ianshaw's avatar
      fix(ratelimit): 修复 OpenAI usage_limit_reached 错误的重置时间解析 · a55cfebd
      ianshaw authored
      - 问题:OpenAI 的 usage_limit_reached 错误(需 37 小时重置)被错误地设置为 5 分钟
      - 原因:handle429 只检查 Anthropic 响应头,没有解析 OpenAI 响应体中的 resets_in_seconds
      - 修复:新增 parseOpenAIRateLimitResetTime 函数解析 OpenAI 响应体
      - 影响:避免调度器不断尝试已达配额上限的账户
      a55cfebd
  23. 25 Jan, 2026 1 commit
  24. 19 Jan, 2026 1 commit
  25. 18 Jan, 2026 1 commit
  26. 16 Jan, 2026 1 commit
  27. 15 Jan, 2026 4 commits
  28. 14 Jan, 2026 2 commits
    • longgexx's avatar
      fix(admin): 修复使用记录页面趋势图筛选联动和日期选择问题 · 806f402b
      longgexx authored
         修复两个问题:
         1. Token使用趋势图和模型分布图未响应筛选条件
         2. 上午时段选择今天刷新后日期回退到前一天
      
         前端修改:
         - 更新 dashboard API 类型定义,添加 model、account_id、group_id、stream 参数支持
         - 修改 UsageView 趋势图加载逻辑,传递所有筛选参数到后端
         - 修复日期格式化函数,使用本地时区避免 UTC 转换导致的日期偏移
      
         后端修改:
         - Handler 层:接收并解析所有筛选参数(model、account_id、group_id、stream)
         - Service 层:传递完整的筛选参数到 Repository 层
         - Repository 层:SQL 查询动态添加所有过滤条件
         - 更新接口定义和所有调用点以保持一致性
      
         影响范围:
         - /admin/dashboard/trend 端点现支持完整筛选
         - /admin/dashboard/models 端点现支持完整筛选
         - 用户在后台使用记录页面选择任意筛选条件时,趋势图和模型分布图会实时响应
         - 日期选择器在任何时区下都能正确保持今天的选择
      806f402b
    • yangjianbo's avatar
      fix(认证): 修复 OAuth token 缓存失效与 401 处理 · daf10907
      yangjianbo authored
      新增 token 缓存失效接口并在刷新后清理
      401 限流支持自定义规则与可配置冷却时间
      补齐缓存失效与 401 处理测试
      测试: make test
      daf10907
  29. 12 Jan, 2026 2 commits
    • ianshaw's avatar
      fix(gateway): 自定义错误码触发停止调度 · 6dcb2763
      ianshaw authored
      - 修改 HandleUpstreamError 逻辑,启用自定义错误码时所有在列表中的错误码都会停止调度
      - 添加 handleCustomErrorCode 函数处理自定义错误码的账号停用
      - 前端添加 429/529 错误码的警告提示,因为这些错误码已有内置处理机制
      - 更新 EditAccountModal、CreateAccountModal、BulkEditAccountModal 的错误码添加逻辑
      6dcb2763
    • ianshaw's avatar
      feat(gateway): 添加流超时处理机制 · 2a0758bd
      ianshaw authored
      - 添加 StreamTimeoutSettings 配置结构体和系统设置
      - 实现 TimeoutCounterCache Redis 计数器用于累计超时次数
      - 在 RateLimitService 添加 HandleStreamTimeout 方法
      - 在 gateway_service、openai_gateway_service、antigravity_gateway_service 中调用超时处理
      - 添加后端 API 端点 GET/PUT /admin/settings/stream-timeout
      - 添加前端配置界面到系统设置页面
      - 支持配置:启用开关、超时阈值、处理方式、暂停时长、触发阈值、阈值窗口
      
      默认配置:
      - 启用:true
      - 超时阈值:60秒
      - 处理方式:临时不可调度
      - 暂停时长:5分钟
      - 触发阈值:3次
      - 阈值窗口:10分钟
      2a0758bd
  30. 11 Jan, 2026 1 commit
    • IanShaw027's avatar
      feat(ops): 实现上游错误事件记录与查询功能 · 7ebca553
      IanShaw027 authored
      **新增功能**:
      - 新建ops_upstream_error_events表存储上游服务错误详情
      - 支持记录上游429/529/5xx错误的详细上下文信息
      - 提供按时间范围查询上游错误事件的API
      
      **后端改动**:
      1. 模型层(ops_models.go, ops_port.go):
         - 新增UpstreamErrorEvent结构体
         - 扩展Repository接口支持上游错误事件CRUD
      
      2. 仓储层(ops_repo.go):
         - 实现InsertUpstreamErrorEvent写入上游错误
         - 实现GetUpstreamErrorEvents按时间范围查询
      
      3. 服务层(ops_service.go, ops_upstream_context.go):
         - ops_service: 新增GetUpstreamErrorEvents查询方法
         - ops_upstream_context: 封装上游错误上下文构建逻辑
      
      4. Handler层(ops_error_logger.go):
         - 新增GetUpstreamErrorsHandler处理上游错误查询请求
      
      5. Gateway层集成:
         - antigravity_gateway_service.go: 429/529错误时记录上游事件
         - gateway_service.go: OpenAI 429/5xx错误时记录
         - gemini_messages_compat_service.go: Gemini 429/5xx错误时记录
         - openai_gateway_service.go: OpenAI 429/5xx错误时记录
         - ratelimit_service.go: 429限流错误时记录
      
      **数据记录字段**:
      - request_id: 关联ops_logs主记录
      - platform/model: 上游服务标识
      - status_code/error_message: 错误详情
      - request_headers/response_body: 调试信息(可选)
      - created_at: 错误发生时间
      7ebca553
  31. 09 Jan, 2026 1 commit
    • Song Siyu's avatar
      feat: antigravity 配额域限流 + SSE 上限 (#222) · 7d1fe818
      Song Siyu authored
      * fix: 添加 gemini-3-flash 前缀映射支持 gemini-3-flash-preview
      
      * feat(antigravity): 增强请求参数和注入 Antigravity 身份 system prompt
      
      * feat: antigravity 配额域限流
      
      * chore: 调整 SSE 单行上限到 25MB
      
      * chore: 提升 SSE 单行上限到 40MB
      7d1fe818