1. 27 Mar, 2026 1 commit
    • shaw's avatar
      feat(tls-fingerprint): 新增 TLS 指纹 Profile 数据库管理及代码质量优化 · 1854050d
      shaw authored
      新增功能:
      - 新增 TLS 指纹 Profile CRUD 管理(Ent schema + 迁移 + Admin API + 前端管理界面)
      - 支持账号绑定数据库中的自定义 TLS Profile,或随机选择(profile_id=-1)
      - HTTPUpstream.DoWithTLS 接口从 bool 改为 *tlsfingerprint.Profile,支持按账号指定 Profile
      - AccountUsageService 注入 TLSFingerprintProfileService,统一 usage 场景与网关的 Profile 解析逻辑
      
      代码优化:
      - 删除已被 TLSFingerprintProfileService 完全取代的 registry.go 死代码(418 行)
      - 提取 3 个 dialer 的重复 TLS 握手逻辑为 performTLSHandshake() 共用函数
      - 修复 GetTLSFingerprintProfileID 缺少 json.Number 处理的 bug
      - gateway_service.Forward 中 ResolveTLSProfile 从重试循环内重复调用改为预解析局部变量
      - 删除冗余的 buildClientHelloSpec() 单行 wrapper 和 int64(e.ID) 无效转换
      - tls_fingerprint_profile_cache.go 日志从 log.Printf 改为 slog 结构化日志
      - dialer_capture_test.go 添加 //go:build integration 标签,防止 CI 失败
      - 去重 TestProfileExpectation 类型至共享 test_types_test.go
      - 修复 9 个测试文件缺少 tlsfingerprint import 的编译错误
      - 修复 error_policy_integration_test.go 中 handleError 回调签名被错误替换的问题
      1854050d
  2. 26 Mar, 2026 1 commit
    • shaw's avatar
      feat: 网关请求头 wire casing 保持、转发行为开关、调试日志增强及 accept-encoding 恢复 · b20e1422
      shaw authored
      - 新增 header_util.go,通过 setHeaderRaw/getHeaderRaw/addHeaderRaw 绕过
        Go 的 canonical-case 规范化,保持真实 Claude CLI 抓包的请求头大小写
        (如 "x-app" 而非 "X-App","X-Stainless-OS" 而非 "X-Stainless-Os")
      - 新增管理后台开关:指纹统一化(默认开启)和 metadata 透传(默认关闭),
        使用 atomic.Value + singleflight 缓存模式,60s TTL
      - 调试日志从控制台 body 打印升级为文件级完整快照
        (按真实 wire 顺序输出 headers + 格式化 JSON body + 上下文元数据)
      - 恢复 accept-encoding 到白名单,在 http_upstream.go 新增 decompressResponseBody
        处理 gzip/brotli/deflate 解压(Go 显式设置 Accept-Encoding 时不会自动解压)
      - OAuth 服务 axios UA 从 1.8.4 更新至 1.13.6
      - 测试断言改用 getHeaderRaw 适配 raw header 存储方式
      b20e1422
  3. 19 Mar, 2026 1 commit
  4. 17 Mar, 2026 1 commit
  5. 12 Mar, 2026 1 commit
  6. 05 Mar, 2026 1 commit
  7. 28 Feb, 2026 1 commit
  8. 26 Feb, 2026 3 commits
    • alfadb's avatar
    • alfadb's avatar
      fix(gateway): return 404 instead of fake 200 for unsupported count_tokens endpoint · 94895314
      alfadb authored
      PR #635 returned HTTP 200 with {"input_tokens": 0} when upstream doesn't
      support count_tokens (404). This caused Claude Code CLI to trust the zero
      value, believing context uses 0 tokens, so auto-compression never triggers.
      
      Fix: return 404 with proper error body so CLI falls back to its local
      tokenizer for accurate estimation. Return nil (not error) to avoid
      polluting ops error metrics with expected 404s.
      
      Affected paths:
      - Passthrough APIKey accounts: upstream 404 now passed through as 404
      - Antigravity accounts: same fix (was also returning fake 200)
      94895314
    • alfadb's avatar
      fix: count_tokens 端点不支持时降级返回空值 (404 only) · 03bcd94a
      alfadb authored
      第三方 Anthropic 中转站通常不支持 /v1/messages/count_tokens 端点,
      上游返回 404 时降级返回 {input_tokens: 0},客户端 fallback 到本地估算。
      
      - 仅匹配 404 状态码,语义明确:端点不存在
      - 其他错误 (400/429/500) 保留原始处理链和 ops 遥测
      - 无需解析错误消息内容,不依赖字符串匹配
      - 新增 table-driven 测试覆盖 fallback 和 non-fallback 路径
      03bcd94a
  9. 21 Feb, 2026 2 commits