1. 05 Jan, 2026 4 commits
    • Jiahao Luo's avatar
      feat(crs-sync): improve error messages and add private IP allowlist support · 204190f8
      Jiahao Luo authored
      ## Changes
      
      ### 1. Enhanced Error Messages
      - Modified CRS sync error handling to show detailed error messages
      - Changed from generic "internal error" to "CRS sync failed: <details>"
      - Helps diagnose connection issues with private CRS deployments
      
      ### 2. Security Configuration
      - Added SECURITY_URL_ALLOWLIST_ALLOW_PRIVATE_HOSTS environment variable
      - Allows administrators to enable/disable private IP access for CRS sync
      - Production default: false (secure)
      - Test environment default: true (convenient for internal testing)
      
      ### 3. Flexible Configuration Support
      - Added config.yaml mount support in both production and test environments
      - Supports dual configuration methods:
        * config.yaml for detailed/complex configurations
        * Environment variables for quick overrides
      - Priority: ENV vars > config.yaml > defaults
      
      ## Use Case
      Enables CRS sync from internal deployments where CRS resolves to private IPs
      (e.g., 10.x.x.x, 192.168.x.x) while maintaining security by default.
      
      ## Files Modified
      - backend/internal/handler/admin/account_handler.go
      - deploy/docker-compose.yml
      - deploy/docker-compose-test.yml
      204190f8
    • Yuhao Jiang's avatar
      fix(后端): 修复 Turnstile Secret Key 留空保留当前值不生效的问题 · 411ebe4d
      Yuhao Jiang authored
      前端显示"密钥已配置,留空以保留当前值",但后端验证逻辑直接
      要求该字段非空,导致修改其他设置时报错。
      
      修复方案:
      - 当 TurnstileSecretKey 为空时,检查 previousSettings 是否有已保存的值
      - 如果有,使用已保存的值而非返回错误
      - 同时移除重复获取 currentSettings 的代码,直接复用 previousSettings
      
      🤖 Generated with [Claude Code](https://claude.ai/code
      
      )
      Co-Authored-By: default avatarClaude <noreply@anthropic.com>
      411ebe4d
    • ianshaw's avatar
      fix(antigravity): 扩展 isSignatureRelatedError 检测 thinking 结构错误 · ae3d6fd7
      ianshaw authored
      - 添加对 "Expected thinking/redacted_thinking" 错误的检测
      - 修复 antigravity 服务中 thinking 模式启用时的结构约束错误
      - 确保此类错误能触发重试逻辑
      ae3d6fd7
    • ianshaw's avatar
      fix: 修复空content处理及更新Gemini使用指南链接 · 118ca5cf
      ianshaw authored
      - 修复FilterThinkingBlocksForRetry对空content数组的处理
      - docker-compose添加SECURITY_URL_ALLOWLIST_UPSTREAM_HOSTS配置
      - 更新Gemini使用指南链接:检查归属地、修改归属地、激活Gemini Web
      118ca5cf
  2. 04 Jan, 2026 36 commits
    • IanShaw027's avatar
      fix(backend): 修复 CI 失败问题 · 06216aad
      IanShaw027 authored
      修复内容:
      1. 修复 6 个 golangci-lint 错误
         - 3 个 errcheck 错误:在 gateway_request_test.go 中添加类型断言检查
         - 3 个 gofmt 格式化问题:修复代码格式
      2. 修复 API 契约测试失败
         - 在测试中添加缺失的字段:enable_identity_patch 和 identity_patch_prompt
      
      所有测试和 linter 检查现已通过。
      06216aad
    • IanShaw027's avatar
      fix: 修复代码审查报告中的4个关键问题 · f60f943d
      IanShaw027 authored
      1. 资源管理冗余(ForwardGemini双重Close)
         - 错误分支读取body后立即关闭原始body,用内存副本重新包装
         - defer添加nil guard,避免重复关闭
         - fallback成功时显式关闭旧body,确保连接释放
      
      2. Schema校验丢失(cleanJSONSchema移除字段无感知)
         - 新增schemaCleaningWarningsEnabled()支持环境变量控制
         - 实现warnSchemaKeyRemovedOnce()在非release模式下告警
         - 移除关键验证字段时输出warning,包含key和path
      
      3. UI响应式风险(UsersView操作菜单硬编码定位)
         - 菜单改为先粗定位、渲染后测量、再clamp到视口内
         - 添加max-height + overflow-auto,超出时可滚动
         - 增强交互:点击其它位置/滚动/resize自动关闭或重新定位
      
      4. 身份补丁干扰(TransformClaudeToGemini默认注入)
         - 新增TransformOptions + TransformClaudeToGeminiWithOptions
         - 系统设置新增enable_identity_patch、identity_patch_prompt
         - 完整打通handler/dto/service/frontend配置链路
         - 默认保持启用,向后兼容现有行为
      
      测试:
      - 后端单测全量通过:go test ./...
      - 前端类型检查通过:npm run typecheck
      f60f943d
    • IanShaw027's avatar
      feat(backend): 为 JSON Schema 清理添加警告日志 · bfcc562c
      IanShaw027 authored
      改进 cleanJSONSchema 函数:
      - 新增 schemaValidationKeys 映射表,标记关键验证字段
      - 新增 warnSchemaKeyRemovedOnce 函数,在移除关键验证字段时输出警告(每个 key 仅警告一次)
      - 支持通过环境变量 SUB2API_SCHEMA_CLEAN_WARN 控制警告开关
      - 默认在非 release 模式下启用警告,便于开发调试
      
      此改进响应代码审查建议,帮助开发者识别可能影响模型输出质量的 Schema 字段移除。
      bfcc562c
    • IanShaw027's avatar
      fix(backend): 改进 thinking/tool block 签名处理和重试策略 · 87426e5d
      IanShaw027 authored
      主要改动:
      - request_transformer: thinking block 缺少签名时降级为文本而非丢弃,保留内容并在上层禁用 thinking mode
      - antigravity_gateway_service: 新增两阶段降级策略,先处理 thinking blocks,如仍失败且涉及 tool 签名错误则进一步降级 tool blocks
      - gateway_request: 新增 FilterSignatureSensitiveBlocksForRetry 函数,支持将 tool_use/tool_result 降级为文本
      - gateway_request: 改进 FilterThinkingBlocksForRetry,禁用顶层 thinking 配置以避免结构约束冲突
      - gateway_service: 实现保守的两阶段重试逻辑,优先保留内容,仅在必要时降级工具调用
      - 新增 antigravity_gateway_service_test.go 测试签名块剥离逻辑
      - 更新相关测试用例以验证降级行为
      
      此修复解决了跨平台/账户切换时历史消息签名失效导致的请求失败问题。
      87426e5d
    • yangjianbo's avatar
      fix(后端): 修复 lint 失败并清理无用代码 · 5dd8b880
      yangjianbo authored
      修正测试中的 APIKey 名称引用
      移除不可达返回与未使用函数
      统一 gofmt 格式并处理 Close 错误
      5dd8b880
    • IanShaw027's avatar
      fix(backend): 修复 P0/P1 严重安全和稳定性问题 · 7122b3b3
      IanShaw027 authored
      P0 严重问题修复:
      - 优化重试机制:降至 5 次 + 指数退避 + 10s 上限,防止请求堆积
      - 修复 SSE 错误格式:符合 Anthropic API 规范,添加错误类型标准化
      
      P1 重要问题修复:
      - 防止 DOS 攻击:使用 io.LimitReader 限制请求体 10MB,流式解析
      - 修复计费数据丢失:改为同步计费,使用独立 context 防止中断
      
      技术细节:
      - 新增 retryBackoffDelay() 和 sleepWithContext() 支持 context 取消
      - 新增 normalizeAnthropicErrorType() 和 sanitizePublicErrorMessage()
      - 新增 parseGatewayRequestStream() 实现流式解析
      - 新增 recordUsageSync() 确保计费数据持久化
      
      影响:
      - 极端场景重试时间从 30s 降至 ≤10s
      - 防止高并发 OOM 攻击
      - 消除计费数据丢失风险
      - 提升客户端兼容性
      7122b3b3
    • IanShaw027's avatar
    • yangjianbo's avatar
      fix(流式): 以上游读取判定超时并调大事件缓冲 · 7489da49
      yangjianbo authored
      - 以读取时间戳判定流式间隔超时,避免下游阻塞误判
      - antigravity 流式读取使用 MaxLineSize 配置
      - 事件通道缓冲提升到 16
      
      测试: go test ./...
      7489da49
    • yangjianbo's avatar
      fix(流式): 提升SSE稳定性并统一超时配置 · 73ffb585
      yangjianbo authored
      - 扩展SSE行长与间隔超时处理,补充keepalive
      
      - 写入失败与超长行时发送错误事件,修复并发释放
      
      - 同步默认配置与示例配置,更新Caddy超时/压缩规则
      
      - 新增OpenAI流式超时与超长行测试
      
      测试: go test ./...
      73ffb585
    • IanShaw027's avatar
      fix(lint): 修复所有 Go 命名规范问题 · a4953785
      IanShaw027 authored
      - 全局替换 ApiKey → APIKey(类型、字段、方法、变量)
      - 修复所有 initialism 命名(API, SMTP, HTML, URL 等)
      - 添加所有缺失的包注释
      - 修复导出符号的注释格式
      
      主要修改:
      - ApiKey → APIKey(所有出现的地方)
      - ApiKeyID → APIKeyID
      - ApiKeyIDs → APIKeyIDs
      - TestSmtpConnection → TestSMTPConnection
      - HtmlURL → HTMLURL
      - 添加 20+ 个包注释
      - 修复 10+ 个导出符号注释格式
      
      验证结果:
      - ✓ golangci-lint: 0 issues
      - ✓ 单元测试: 通过
      - ✓ 集成测试: 通过
      a4953785
    • IanShaw027's avatar
      fix(ci): 修复 CI 检查失败问题 · d92e71a1
      IanShaw027 authored
      - 重新生成 Wire 依赖注入代码(修复服务构造函数签名不匹配)
      - 修复集成测试中的 err 变量重复声明
      - 临时禁用 golangci-lint 的命名规范检查(ST1000/ST1003/ST1020/ST1021/ST1022)
        - 这些只是代码风格问题,不影响功能
        - 后续将创建专门的 PR 系统地修复命名规范
      
      测试结果:
      - ✓ golangci-lint: 通过(0 issues)
      - ✓ 单元测试: 通过
      - ✓ 集成测试: 通过
      d92e71a1
    • IanShaw027's avatar
    • shaw's avatar
      a5275595
    • IanShaw027's avatar
    • IanShaw027's avatar
    • IanShaw027's avatar
      refactor(settings): 规范化缩写词命名并优化前端帮助界面 · 2632a710
      IanShaw027 authored
      - 后端:将 Smtp/Api/Doc 字段改为 SMTP/API/Doc(遵循 Go 命名规范)
      - 前端:添加 Gemini 帮助按钮,简化配额说明展示
      2632a710
    • song's avatar
      style: gofmt · 63453fbf
      song authored
      63453fbf
    • song's avatar
    • song's avatar
      fix: 转发失败日志添加账户ID信息 · 3932bf03
      song authored
      3932bf03
    • song's avatar
      ce242232
    • song's avatar
      0aa21691
    • song's avatar
      fix: 恢复 thinking block 处理逻辑 · 60afc7f3
      song authored
      - 修复合并冲突导致的逻辑错误
      - Gemini 模型使用 dummy signature
      - Claude 模型跳过无 signature 的 thinking block
      - 删除未使用的 isValidThoughtSignature 函数
      60afc7f3
    • song's avatar
      fix(antigravity): 优化 token 刷新错误处理 · 1dd35211
      song authored
      - 不可重试错误(invalid_grant等)直接标记 error,不重试
      - 其他错误仅记录日志,不标记 error(可能是临时网络问题)
      - 仅影响 Antigravity 账户,其他平台保持原有逻辑
      1dd35211
    • song's avatar
    • song's avatar
      fix: 移除 antigravity 模块中的 [Debug] 日志 · c8e55ab2
      song authored
      这些调试日志不应在生产环境中输出。
      c8e55ab2
    • IanShaw027's avatar
      feat(gemini): 完善 Gemini OAuth 配额系统和用量显示 · a185ad11
      IanShaw027 authored
      主要改动:
      - 后端:重构 Gemini 配额服务,支持多层级配额策略(GCP Standard/Free, Google One, AI Studio, Code Assist)
      - 后端:优化 OAuth 服务,增强 tier_id 识别和存储逻辑
      - 后端:改进用量统计服务,支持不同平台的配额查询
      - 后端:优化限流服务,增加临时解除调度状态管理
      - 前端:统一四种授权方式的用量显示格式和徽标样式
      - 前端:增强账户配额信息展示,支持多种配额类型
      - 前端:改进创建和重新授权模态框的用户体验
      - 国际化:完善中英文配额相关文案
      - 移除 CHANGELOG.md 文件
      
      测试:所有单元测试通过
      a185ad11
    • shaw's avatar
    • shaw's avatar
      feat(proxy): 统一代理配置并支持 SOCKS5H 协议 · 70e9329e
      shaw authored
      - 新增 proxyutil 包,统一 HTTP/HTTPS/SOCKS5/SOCKS5H 代理配置逻辑
      - SOCKS5H 支持服务端 DNS 解析,避免本地 DNS 泄露
      - 移除 ProxyStrict 宽松模式,代理失败直接返回错误不回退直连
      - 前端代理管理页面支持 SOCKS5H 协议的添加/编辑/批量导入
      - 补充 IPv6 地址和特殊字符密码的边界测试
      70e9329e
    • shaw's avatar
      a11c71ce
    • IanShaw027's avatar
      feat(backend): 增加 Google One tier 判断的详细调试日志 · cc4cc806
      IanShaw027 authored
      **目的:**
      排查 Google One 账户 tier 判断不准确的问题(2TB 存储空间应显示 AI Premium,实际显示 Personal)
      
      **新增日志:**
      1. FetchGoogleOneTier:
         - LoadCodeAssist API 调用结果(是否返回 tier)
         - Drive API 调用结果(存储空间大小、TB 单位)
         - 最终推断的 tier
      
      2. inferGoogleOneTier:
         - 输入的存储空间(bytes 和 TB)
         - 匹配的存储层级和返回的 tier
         - 每个判断分支的详细信息
      
      **调试信息包含:**
      - LoadCodeAssist vs Drive API 的使用情况
      - 存储空间 bytes → TB 转换
      - tier 推断的完整过程
      - 每个存储层级的阈值检查
      
      用户可以重新授权 Google One 账户,后端日志将显示详细的 tier 判断过程。
      cc4cc806
    • shaw's avatar
      d9b15879
    • IanShaw027's avatar
      fix(lint): 修复 golangci-lint 检查问题 · 537af60e
      IanShaw027 authored
      - usage_service: 修复 tx.Rollback 未检查错误返回值 (errcheck)
      - antigravity_gateway: 修复重试逻辑中的无效赋值 (ineffassign)
      - antigravity_gateway: 完善重试成功/失败的分支逻辑
      537af60e
    • ianshaw's avatar
      fix(gateway): 优化 thinking block 重试逻辑 · aad4163d
      ianshaw authored
      - 保留用户的 thinking.type=enabled 设置(不再禁用)
      - 只移除历史消息中的 thinking/redacted_thinking blocks
      - 处理过滤后空消息:跳过 assistant 消息,user 消息添加占位符
      - 增强错误检测:覆盖 signature、Expected thinking、empty content 错误
      - 添加重试成功/失败日志便于排查
      aad4163d
    • ianshaw's avatar
      fix(test): 优化账户测试逻辑和默认模型配置 · cc86f944
      ianshaw authored
      - 更新默认模型列表顺序,gemini-2.0-flash 作为首选
      - OpenAI API Key 账户优先使用 Chat Completions API,兼容第三方代理
      - 重构 OAuth 和 API Key 测试逻辑为独立方法
      - 修复 Gemini 流处理中 finishReason 检查顺序
      cc86f944
    • ianshaw's avatar
      fix(usage): 使用日志事务和幂等性修复 · 71bf5b9e
      ianshaw authored
      - UsageLogRepository.Create 返回 inserted 标志
      - UsageService 使用事务保证原子性
      - 避免重复扣费(幂等重试场景)
      - 更新依赖注入和测试
      71bf5b9e
    • ianshaw's avatar
      fix(gateway): 完善 thinking block 重试和 cache nil 检查 · 7eda43c9
      ianshaw authored
      - 使用 FilterThinkingBlocksForRetry 替代 FilterThinkingBlocks
      - count_tokens 增加 thinking block 签名错误重试
      - cache nil 检查防止空指针
      - shouldBill 逻辑修复避免重复扣费
      - 移除 debug 日志
      7eda43c9