1. 29 Mar, 2026 1 commit
  2. 21 Mar, 2026 1 commit
  3. 20 Mar, 2026 1 commit
    • shaw's avatar
      feat: add max_claude_code_version setting and disable auto-upgrade env var · 01d8286b
      shaw authored
      Add maximum Claude Code version limit to complement the existing minimum
      version check. Refactor the version cache from single-value to unified
      bounds struct (min+max) with a single atomic.Value and singleflight group.
      
      - Backend: new constant, struct field, cache refactor, validation (semver
        format + cross-validation max >= min), gateway enforcement, audit diff
      - Frontend: settings UI input, TypeScript types, zh/en i18n
      - Add CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 to all Claude Code
        tutorials on /keys page (unix/cmd/powershell/vscode settings.json)
      01d8286b
  4. 19 Mar, 2026 1 commit
  5. 15 Mar, 2026 3 commits
    • Ethan0x0000's avatar
      refactor: migrate all handlers to shared endpoint normalization middleware · 7bd1972f
      Ethan0x0000 authored
      - Apply InboundEndpointMiddleware to all gateway route groups
      - Replace normalizedOpenAIInboundEndpoint/normalizedOpenAIUpstreamEndpoint and normalizedGatewayInboundEndpoint/normalizedGatewayUpstreamEndpoint with GetInboundEndpoint/GetUpstreamEndpoint
      - Remove 4 old constants and 4 old normalization functions (-70 lines)
      - Migrate existing endpoint normalization test to new API
      
      Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode
      
      )
      Co-authored-by: default avatarSisyphus <clio-agent@sisyphuslabs.ai>
      7bd1972f
    • Elysia's avatar
      增加测试 · 359e5675
      Elysia authored
      359e5675
    • YanzheL's avatar
      fix: extract and log Claude output_config.effort in usage records · 1bff2292
      YanzheL authored
      Claude's output_config.effort parameter (low/medium/high/max) was not
      being extracted from requests or logged in the reasoning_effort column
      of usage logs. Only the OpenAI path populated this field.
      
      Changes:
      - Extract output_config.effort in ParseGatewayRequest
      - Add ReasoningEffort field to ForwardResult
      - Populate reasoning_effort in both RecordUsage and RecordUsageWithLongContext
      - Guard against overwriting service-set effort values in handler
      - Update stale comments that described reasoning_effort as OpenAI-only
      - Add unit tests for extraction, normalization, and persistence
      1bff2292
  6. 14 Mar, 2026 1 commit
    • Elysia's avatar
      fix(gateway): 防止流式 failover 拼接腐化导致客户端收到双 message_start · 0e237326
      Elysia authored
      
      
      当上游在 SSE 流中途返回 event:error 时,handleStreamingResponse 已将
      部分 SSE 事件写入客户端,但原先的 failover 逻辑仍会切换到下一个账号
      并写入完整流,导致客户端收到两个 message_start 进而产生 400 错误。
      
      修复方案:在每次 Forward 调用前记录 c.Writer.Size(),若 Forward 返回
      UpstreamFailoverError 后 writer 字节数增加,说明 SSE 内容已不可撤销地
      发送给客户端,此时直接调用 handleFailoverExhausted 发送 SSE error 事件
      终止流,而非继续 failover。
      
      Ping-only 场景不受影响:slot 等待期的 ping 字节在 Forward 前后相等,
      正常 failover 流程照常进行。
      Co-Authored-By: default avatarClaude Sonnet 4.6 <noreply@anthropic.com>
      0e237326
  7. 12 Mar, 2026 1 commit
  8. 10 Mar, 2026 1 commit
  9. 09 Mar, 2026 1 commit
  10. 07 Mar, 2026 1 commit
  11. 03 Mar, 2026 2 commits
    • shaw's avatar
      feat: 重构 /v1/usage 端点,支持 quota_limited 和 unrestricted 双模式 · 838dad87
      shaw authored
      - quota_limited 模式:返回 Key 级别的总额度、速率限制窗口用量和过期时间
      - unrestricted 模式:返回订阅限额或钱包余额信息(向后兼容)
      - 新增 model_stats 字段,支持 start_date/end_date 参数查询按模型用量统计
      - 提取 buildUsageData/parseUsageDateRange 等辅助方法,减少主函数复杂度
      - 新增 APIKeyService.GetRateLimitData 和 UsageService.GetAPIKeyModelStats
      838dad87
    • shaw's avatar
      feat: apikey支持5h/1d/7d速率控制 · a80ec5d8
      shaw authored
      a80ec5d8
  12. 02 Mar, 2026 1 commit
    • QTom's avatar
      feat(gateway): 双模式用户消息队列 — 串行队列 + 软性限速 · a9285b8a
      QTom authored
      新增 UMQ (User Message Queue) 双模式支持:
      - serialize: 账号级分布式串行锁 + RPM 自适应延迟(严格限流)
      - throttle: 仅 RPM 自适应前置延迟,不阻塞并发(软性限速)
      
      后端:
      - config: 新增 Mode 字段,保留 Enabled 向后兼容
      - service: 新增 UserMessageQueueService(Lua 锁/延迟算法/清理 worker)
      - repository: 新增 UserMsgQueueCache(Redis Lua acquire/release/force-release)
      - handler: 新增 UserMsgQueueHelper(SSE ping + 等待循环 + throttle)
      - gateway: 按 mode 分支集成 serialize/throttle 逻辑
      - lint: 修复 gofmt rewrite rules、errcheck 类型断言、staticcheck QF1012
      
      前端:
      - 三态选择器 UI(关闭/软性限速/串行队列)替代 toggle 开关
      - BulkEdit 支持 null 语义(不修改)
      - i18n 中英文文案
      
      通过 6 轮专家评审(42 次 review)、golangci-lint、单元测试、集成测试。
      a9285b8a
  13. 01 Mar, 2026 1 commit
    • QTom's avatar
      feat(gateway): 添加 Claude Code 客户端最低版本检查功能 · 4280aca8
      QTom authored
      - 通过 User-Agent 识别 Claude Code 客户端并提取版本号
      - 在网关层验证客户端版本是否满足管理员配置的最低要求
      - 在管理后台提供版本要求配置选项(英文/中文双语)
      - 实现原子缓存 + singleflight 防止并发问题和 thundering herd
      - 使用 context.WithoutCancel 隔离 DB 查询,避免客户端断连影响缓存
      - 双 TTL 策略:60s 正常、5s 错误恢复,保证性能与可用性
      - 仅检查 Claude Code 客户端,其他客户端不受影响
      - 添加完整单元测试覆盖版本提取、比对、上下文操作
      4280aca8
  14. 28 Feb, 2026 4 commits
    • QTom's avatar
      fix: address deep code review issues for RPM limiting · e63c8395
      QTom authored
      - Move IncrementRPM after Forward success to prevent phantom RPM
        consumption during account switch retries
      - Add base_rpm input sanitization (clamp to 0-10000) in Create/Update
      - Add WindowCost scheduling checks to legacy path sticky sessions
        (4 check sites + 4 prefetch sites), fixing pre-existing gap
      - Clean up rpm_strategy/rpm_sticky_buffer when disabling RPM in
        BulkEditModal (JSONB merge cannot delete keys, use empty values)
      - Add json.Number test cases to TestGetBaseRPM/TestGetRPMStickyBuffer
      - Document TOCTOU race as accepted soft-limit design trade-off
      e63c8395
    • QTom's avatar
      fix: address code review issues for RPM limiting feature · 60723757
      QTom authored
      - Use TxPipeline (MULTI/EXEC) instead of Pipeline for atomic INCR+EXPIRE
      - Filter negative values in GetBaseRPM(), update test expectation
      - Add RPM batch query (GetRPMBatch) to account List API
      - Add warn logs for RPM increment failures in gateway handler
      - Reset enableRpmLimit on BulkEditAccountModal close
      - Use union type 'tiered' | 'sticky_exempt' for rpmStrategy refs
      - Add design decision comments for rdb.Time() RTT trade-off
      60723757
    • QTom's avatar
      f648b8e0
    • yangjianbo's avatar
      feat(sync): full code sync from release · bb664d9b
      yangjianbo authored
      bb664d9b
  15. 24 Feb, 2026 2 commits
    • erio's avatar
      fix: enable Gemini model_mapping UI and extend warmup to Antigravity · d8d4b0c0
      erio authored
      - Remove Gemini platform exclusion from model restriction UI in
        Create/Edit account modals (Gemini now supports model_mapping)
      - Remove outdated Gemini model passthrough info cards
      - Add model_mapping field to GeminiCredentials type
      - Extend warmup request interception toggle to Antigravity platform
      - Remove redundant try/catch in API key account creation
      - Remove noisy gateway.request_completed debug log
      - Reorganize Gemini model mapping sections in constants.go
      d8d4b0c0
    • erio's avatar
      refactor: extract failover error handling into FailoverState · 09166a52
      erio authored
      - Extract duplicated failover logic from gateway_handler.go (3 places)
        and gemini_v1beta_handler.go into shared failover_loop.go
      - Introduce FailoverState with HandleFailoverError and HandleSelectionExhausted
      - Move helper functions (needForceCacheBilling, sleepWithContext) into failover_loop.go
      - Add comprehensive unit tests (32+ test cases)
      - Delete redundant gateway_handler_single_account_retry_test.go
      09166a52
  16. 22 Feb, 2026 3 commits
  17. 14 Feb, 2026 1 commit
  18. 12 Feb, 2026 2 commits
  19. 10 Feb, 2026 1 commit
    • Edric Li's avatar
      fix: 修复错误透传规则 skip_monitoring 未生效的问题 · 2d4236f7
      Edric Li authored
      - ops_error_logger: status < 400 分支增加 OpsSkipPassthroughKey 检查
      - ops_upstream_context: 新增 checkSkipMonitoringForUpstreamEvent,中间重试/故障转移事件也能触发跳过标记
      - gateway_handler/openai_gateway_handler/gemini_v1beta_handler: handleFailoverExhausted 匹配规则后设置 OpsSkipPassthroughKey
      - antigravity_gateway_service: writeMappedClaudeError 增加 applyErrorPassthroughRule 调用
      2d4236f7
  20. 09 Feb, 2026 3 commits
    • Edric Li's avatar
      feat: same-account retry before failover for transient errors · d6c2921f
      Edric Li authored
      For retryable transient errors (Google 400 "invalid project resource name"
      and empty stream responses), retry on the same account up to 2 times
      (with 500ms delay) before switching to another account.
      
      - Add RetryableOnSameAccount field to UpstreamFailoverError
      - Add same-account retry loop in both Gemini and Claude/OpenAI handler paths
      - Move temp-unschedule from service layer to handler layer (only after
        all same-account retries exhausted)
      - Reduce temp-unschedule cooldown from 30 minutes to 1 minute
      d6c2921f
    • Rose Ding's avatar
      fix: 单账号分组首次 503 不设模型限流标记,避免后续请求雪崩 · 021abfca
      Rose Ding authored
      单账号 antigravity 分组收到 503 (MODEL_CAPACITY_EXHAUSTED) 时,
      原逻辑会设置 ~29s 模型限流标记。由于只有一个账号无法切换,
      后续所有新请求在预检查时命中限流 → 几毫秒内直接返回 503,
      导致约 30 秒的雪崩窗口。
      
      修复:在 Handler 入口处检查分组是否只有单个 antigravity 账号,
      如果是则提前设置 SingleAccountRetry context 标记,让 Service 层
      首次 503 就走原地重试逻辑(不设限流标记),避免污染后续请求。
      021abfca
    • Rose Ding's avatar
      feat: 添加 Antigravity 单账号 503 退避重试机制 · f6cfab99
      Rose Ding authored
      当分组内只有一个可用账号且上游返回 503 (MODEL_CAPACITY_EXHAUSTED) 时,
      不再设置模型限流+切换账号(因为切换回来还是同一个账号),而是在 Service 层
      原地等待+重试,避免双重等待问题。
      
      主要变更:
      - Handler 层:检测单账号 503 场景,清除排除列表并设置 SingleAccountRetry 标记
      - Service 层:新增 handleSingleAccountRetryInPlace 原地重试逻辑
      - Service 层:预检查跳过单账号模式下的限流检查
      - 新增 ctxkey.SingleAccountRetry 上下文标记
      f6cfab99
  21. 08 Feb, 2026 5 commits
  22. 07 Feb, 2026 3 commits
    • yangjianbo's avatar
      fix(audit): 第二批审计修复 — P0 生产 Bug、安全加固、性能优化、缓存一致性、代码质量 · 2588fa6a
      yangjianbo authored
      
      
      基于 backend-code-audit 审计报告,修复剩余 P0/P1/P2 共 34 项问题:
      
      P0 生产 Bug:
      - 修复 time.Since(time.Now()) 计时逻辑错误 (P0-03)
      - generateRandomID 改用 crypto/rand 替代固定索引 (P0-04)
      - IncrementQuotaUsed 重写为 Ent 原子操作消除 TOCTOU 竞态 (P0-05)
      
      安全加固:
      - gateway/openai handler 错误响应替换为泛化消息,防止内部信息泄露 (P1-14)
      - usage_log_repo dateFormat 参数改用白名单映射,防止 SQL 注入 (P1-16)
      - 默认配置安全加固:sslmode=prefer、response_headers=true、mode=release (P1-18/19, P2-15)
      
      性能优化:
      - gateway handler 循环内 defer 替换为显式 releaseWait 闭包 (P1-02)
      - group_repo/promo_code_repo Count 前 Clone 查询避免状态污染 (P1-03)
      - usage_log_repo 四个查询添加 LIMIT 10000 防止 OOM (P1-07)
      - GetBatchUsageStats 添加时间范围参数,默认最近 30 天 (P1-10)
      - ip.go CIDR 预编译为包级变量 (P1-11)
      - BatchUpdateCredentials 重构为先验证后更新 (P1-13)
      
      缓存一致性:
      - billing_cache 添加 jitteredTTL 防止缓存雪崩 (P2-10)
      - DeductUserBalance/UpdateSubscriptionUsage 错误传播修复 (P2-12)
      - UserService.UpdateBalance 成功后异步失效 billingCache (P2-13)
      
      代码质量:
      - search 截断改为按 rune 处理,支持多字节字符 (P2-01)
      - TLS Handshake 改为 HandshakeContext 支持 context 取消 (P2-07)
      - CORS 预检添加 Access-Control-Max-Age: 86400 (P2-16)
      
      测试覆盖:
      - 新增 user_service_test.go(UpdateBalance 缓存失效 6 个用例)
      - 新增 batch_update_credentials_test.go(fail-fast + 类型验证 7 个用例)
      - 新增 response_transformer_test.go、ip_test.go、usage_log_repo_unit_test.go、search_truncate_test.go
      - 集成测试:IncrementQuotaUsed 并发测试、billing_cache 错误传播测试
      - config_test.go 补充 server.mode/sslmode 默认值断言
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      2588fa6a
    • shaw's avatar
      6aaa4aee
    • erio's avatar
      refactor: remove Anthropic digest chain from Messages handler · 86b503f8
      erio authored
      The digest chain fallback is only needed for Gemini endpoints, not
      for the Anthropic Messages API path. Remove the handler integration
      while keeping the reusable service/repository layer for future use.
      86b503f8