1. 31 Mar, 2026 1 commit
  2. 21 Mar, 2026 1 commit
  3. 19 Mar, 2026 1 commit
  4. 15 Mar, 2026 1 commit
  5. 12 Mar, 2026 1 commit
  6. 28 Feb, 2026 1 commit
  7. 24 Feb, 2026 1 commit
    • 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
  8. 22 Feb, 2026 3 commits
  9. 12 Feb, 2026 2 commits
  10. 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
  11. 09 Feb, 2026 2 commits
    • 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
  12. 08 Feb, 2026 7 commits
  13. 07 Feb, 2026 4 commits
  14. 05 Feb, 2026 1 commit
    • shaw's avatar
      feat: 新增全局错误透传规则功能 · 39e05a2d
      shaw authored
      支持管理员配置上游错误如何返回给客户端:
      - 新增 ErrorPassthroughRule 数据模型和 Ent Schema
      - 实现规则的 CRUD API(/admin/error-passthrough-rules)
      - 支持按错误码、关键词匹配,支持 any/all 匹配模式
      - 支持按平台过滤(anthropic/openai/gemini/antigravity)
      - 支持透传或自定义响应状态码和错误消息
      - 实现两级缓存(Redis + 本地内存)和多实例同步
      - 集成到 gateway_handler 的错误处理流程
      - 新增前端管理界面组件
      - 新增单元测试覆盖核心匹配逻辑
      
      优化:
      - 移除 refreshLocalCache 中的冗余排序(数据库已排序)
      - 后端 Validate() 增加匹配条件非空校验
      39e05a2d
  15. 03 Feb, 2026 1 commit
    • bayma888's avatar
      feat(api-key): add independent quota and expiration support · 6146be14
      bayma888 authored
      This feature allows API Keys to have their own quota limits and expiration
      times, independent of the user's balance.
      
      Backend:
      - Add quota, quota_used, expires_at fields to api_key schema
      - Implement IsExpired() and IsQuotaExhausted() checks in middleware
      - Add ResetQuota and ClearExpiration API endpoints
      - Integrate quota billing in gateway handlers (OpenAI, Anthropic, Gemini)
      - Include quota/expiration fields in auth cache for performance
      - Expiration check returns 403, quota exhausted returns 429
      
      Frontend:
      - Add quota and expiration inputs to key create/edit dialog
      - Add quick-select buttons for expiration (+7, +30, +90 days)
      - Add reset quota confirmation dialog
      - Add expires_at column to keys list
      - Add i18n translations for new features (en/zh)
      
      Migration:
      - Add 045_add_api_key_quota.sql for new columns
      6146be14
  16. 02 Feb, 2026 2 commits
  17. 27 Jan, 2026 1 commit
  18. 25 Jan, 2026 1 commit
    • ianshaw's avatar
      feat(gemini): 支持 Gemini CLI 粘性会话与跨账号 thoughtSignature 清理 · 839975b0
      ianshaw authored
      ## 问题背景
      
      1. Gemini CLI 没有明确的会话标识(如 Claude Code 的 metadata.user_id)
      2. thoughtSignature 与具体上游账号强绑定,跨账号使用会导致 400 错误
      3. 粘性会话切换账号或 cache 丢失时,旧签名会导致请求失败
      
      ## 解决方案
      
      ### 1. Gemini CLI 会话标识提取
      
      - 从 `x-gemini-api-privileged-user-id` header 和请求体中的 tmp 目录哈希生成会话标识
      - 组合策略:SHA256(privileged-user-id + ":" + tmp_dir_hash)
      - 正则提取:`/\.gemini/tmp/([A-Fa-f0-9]{64})`
      
      ### 2. 跨账号 thoughtSignature 清理
      
      实现三种场景的智能清理:
      
      1. **Cache 命中 + 账号切换**
         - 粘性会话绑定的账号与当前选择的账号不同时清理
      
      2. **同一请求内 failover 切换**
         - 通过 sessionBoundAccountID 跟踪,检测重试时的账号切换
      
      3. **Gemini CLI + Cache 未命中 + 含签名**
         - 预防性清理,避免 cache 丢失后首次转发就 400
         - 仅对 Gemini CLI 请求且请求体包含 thoughtSignature 时触发
      
      ## 修改内容
      
      ### backend/internal/handler/gemini_v1beta_handler.go
      - 添加 `extractGeminiCLISessionHash` 函数提取 Gemini CLI 会话标识
      - 添加 `isGeminiCLIRequest` 函数识别 Gemini CLI 请求
      - 实现账号切换检测与 thoughtSignature 清理逻辑
      - 添加 `geminiCLITmpDirRegex` 正则表达式
      
      ### backend/internal/service/gateway_service.go
      - 添加 `GetCachedSessionAccountID` 方法查询粘性会话绑定的账号 ID
      
      ### backend/internal/service/gemini_native_signature_cleaner.go (新增)
      - 实现 `CleanGeminiNativeThoughtSignatures` 函数
      - 递归清理 JSON 中的所有 thoughtSignature 字段
      - 支持任意 JSON 顶层类型(object/array)
      
      ### backend/internal/handler/gemini_cli_session_test.go (新增)
      - 测试 Gemini CLI 会话哈希提取逻辑
      - 测试 tmp 目录正则匹配
      - 覆盖有/无 privileged-user-id 的场景
      
      ## 影响范围
      
      - 修复 Gemini CLI 多轮对话时账号切换导致的 400 错误
      - 提高粘性会话的稳定性和容错能力
      - 不影响其他客户端(Claude Code 等)的会话标识生成
      
      ## 测试
      
      - 单元测试:go test -tags=unit ./internal/handler -run TestExtractGeminiCLISessionHash
      - 单元测试:go test -tags=unit ./internal/handler -run TestGeminiCLITmpDirRegex
      - 编译验证:go build ./cmd/server
      839975b0
  19. 16 Jan, 2026 2 commits
    • shaw's avatar
      feat: 添加5h窗口费用控制和会话数量限制 · 73794233
      shaw authored
      - 支持Anthropic OAuth/SetupToken账号的5h窗口费用阈值控制
      - 支持账号级别的并发会话数量限制
      - 使用Redis缓存窗口费用(30秒TTL)减少数据库压力
      - 费用计算基于标准费用(不含账号倍率)
      73794233
    • song's avatar
      feat(gateway): 账户切换次数和 Antigravity 限流时间可配置 · 34d6b0a6
      song authored
      - gateway.max_account_switches: 账户切换最大次数,默认 10
      - gateway.max_account_switches_gemini: Gemini 账户切换次数,默认 3
      - gateway.antigravity_fallback_cooldown_minutes: Antigravity 429 fallback 限流时间,默认 5 分钟
      - Antigravity 429 不再重试,直接标记账户限流
      34d6b0a6
  20. 12 Jan, 2026 2 commits
  21. 11 Jan, 2026 1 commit
    • IanShaw027's avatar
      fix: 临时保存编译错误修复 · fc4ea659
      IanShaw027 authored
      - 添加 LinuxDo 和 Update 配置(从 main 分支缺失)
      - 添加 LinuxDoConnectSyntheticEmailDomain 常量
      - 添加 IsClaudeCodeClient context key
      - 添加 GetLinuxDoConnectOAuthConfig 方法
      - 修复 BindStickySession 调用签名
      - 修复前端 i18n 重复属性
      - 重新生成 wire 依赖注入代码
      
      这个提交准备被合并替换,先保存以防丢失。
      fc4ea659
  22. 09 Jan, 2026 3 commits
    • Edric.Li's avatar
      feat(api-key): 添加 IP 白名单/黑名单限制功能 (#221) · 0a4641c2
      Edric.Li authored
      * feat(api-key): add IP whitelist/blacklist restriction and usage log IP tracking
      
      - Add IP restriction feature for API keys (whitelist/blacklist with CIDR support)
      - Add IP address logging to usage logs (admin-only visibility)
      - Remove billing_type column from usage logs UI (redundant)
      - Use generic "Access denied" error message for security
      
      Backend:
      - New ip package with IP/CIDR validation and matching utilities
      - Database migrations for ip_whitelist, ip_blacklist (api_keys) and ip_address (usage_logs)
      - Middleware IP restriction check after API key validation
      - Input validation for IP/CIDR patterns on create/update
      
      Frontend:
      - API key form with enable toggle for IP restriction
      - Shield icon indicator in table for keys with IP restriction
      - Removed billing_type filter and column from usage views
      
      * fix: update API contract tests for ip_whitelist/ip_blacklist fields
      
      Add ip_whitelist and ip_blacklist fields to expected JSON responses
      in API contract tests to match the new API key schema.
      0a4641c2
    • Edric Li's avatar
      feat(api-key): add IP whitelist/blacklist restriction and usage log IP tracking · 90798f14
      Edric Li authored
      - Add IP restriction feature for API keys (whitelist/blacklist with CIDR support)
      - Add IP address logging to usage logs (admin-only visibility)
      - Remove billing_type column from usage logs UI (redundant)
      - Use generic "Access denied" error message for security
      
      Backend:
      - New ip package with IP/CIDR validation and matching utilities
      - Database migrations for ip_whitelist, ip_blacklist (api_keys) and ip_address (usage_logs)
      - Middleware IP restriction check after API key validation
      - Input validation for IP/CIDR patterns on create/update
      
      Frontend:
      - API key form with enable toggle for IP restriction
      - Shield icon indicator in table for keys with IP restriction
      - Removed billing_type filter and column from usage views
      90798f14
    • IanShaw027's avatar
      feat(网关): 集成运维监控到 API 网关处理器 · fcdf839b
      IanShaw027 authored
      - 在 gateway_handler 中添加请求监控和错误追踪
      - 在 openai_gateway_handler 中集成 ops 指标采集
      - 在 gemini_v1beta_handler 中集成 ops 指标采集
      - 更新 handler 基类支持 ops 错误日志记录
      fcdf839b