1. 11 Apr, 2026 2 commits
    • shuanbao0's avatar
      fix(gateway): 剥离 Cursor raw body 透传路径中 Codex 不支持的 Responses API 参数 · 422e25c9
      shuanbao0 authored
      
      
      在前一个 commit 的 isResponsesShape 短路路径基础上,补充对 Cursor 云端
      带过来的、Codex 上游统一不支持的顶层 Responses API 参数的剥离:
      
        - prompt_cache_retention
        - safety_identifier
        - metadata
        - stream_options
      
      根因补充:这条 raw-body 透传路径为了保留 Cursor 的 input 数组整体结构,
      不再经过 ChatCompletionsRequest 的反序列化过滤,所以这些 Go 结构体里
      没有对应字段的参数会被原样发到上游,上游返回:
          Unsupported parameter: <field>
      常规 Chat Completions 转换路径天然通过 ChatCompletionsRequest 丢弃未知字段,
      不受影响;此处仅在 isResponsesShape 分支内用 sjson.DeleteBytes 显式过滤,
      作用域最小。剥离列表与 openai_gateway_service.go:2034 的
      unsupportedFields 语义对齐。
      
      另外在 applyCodexOAuthTransform 的 OAuth 兜底 strip 列表里同步追加
      prompt_cache_retention,作为对该函数所有其他 OAuth 调用点的 defense
      in depth(当前只有 Cursor 路径的短路已在前面剥过,但保留这一层更稳)。
      
      测试:
      - TestCursorMixedShape_StripsUnsupportedFields — 验证所有 4 个字段都被剥
      - TestApplyCodexOAuthTransform_StripsPromptCacheRetention — OAuth 兜底路径
      Co-Authored-By: default avatarClaude Opus 4.6 (1M context) <noreply@anthropic.com>
      422e25c9
    • shuanbao0's avatar
      fix(gateway): 兼容 Cursor /v1/chat/completions 的 Responses API body · b7edc3ed
      shuanbao0 authored
      
      
      Cursor 云端 (User-Agent: Go-http-client/2.0) 发往 /v1/chat/completions 的
      body 使用 Responses API 格式:
          {"model":"gpt-5.4","input":[{"role":"system","content":"..."}],"stream":true}
      
      原代码用 ChatCompletionsRequest 反序列化,该结构体没有 Input 字段,
      Cursor 的 input 数组被静默丢弃,ChatCompletionsToResponses 转换后产出
      input: null,Codex 上游以 "Invalid type for 'input': expected a string,
      but got an object" 拒绝请求(上游 typeof null === 'object')。
      
      修复:在 ForwardAsChatCompletions 里用 gjson 检测 body shape,当 input
      存在且 messages 缺失时,跳过 Chat→Responses 转换,用 sjson 仅改写 model
      字段后原样透传 body。billing 所需的 ServiceTier 和 Reasoning.Effort 通过
      gjson 从 raw body 提取,下游 codex OAuth transform 路径保持不变。
      
      测试:新增 openai_cursor_warmup_pipeline_test.go,覆盖 5 个 shape 检测
      用例(正向/标准请求不误伤/两字段共存/空 body/JSON 回读)。
      Co-Authored-By: default avatarClaude Opus 4.6 (1M context) <noreply@anthropic.com>
      b7edc3ed
  2. 10 Apr, 2026 4 commits
  3. 09 Apr, 2026 17 commits
  4. 08 Apr, 2026 6 commits
    • ius's avatar
      265687b5
    • github-actions[bot]'s avatar
      0d69c0cd
    • shaw's avatar
      fix: resolve errcheck lint and add missing enable_cch_signing to test · b982076e
      shaw authored
      - Suppress errcheck for xxhash Digest.Write (never returns error)
      - Add enable_cch_signing field to settings API contract test
      b982076e
    • shaw's avatar
      fix: bump Go from 1.26.1 to 1.26.2 to resolve 6 stdlib CVEs · 7060596a
      shaw authored
      Fixes GO-2026-4947, GO-2026-4946, GO-2026-4870, GO-2026-4869,
      GO-2026-4866, GO-2026-4865 in crypto/x509, crypto/tls, archive/tar,
      and html/template.
      7060596a
    • shaw's avatar
      feat: sync billing header cc_version with User-Agent and add opt-in CCH signing · e51c9e50
      shaw authored
      - Sync cc_version in x-anthropic-billing-header with the fingerprint
        User-Agent version, preserving the message-derived suffix
      - Implement xxHash64-based CCH signing to replace the cch=00000
        placeholder with a computed hash
      - Add admin toggle (enable_cch_signing) under gateway forwarding settings,
        disabled by default
      e51c9e50
    • shaw's avatar
      fix: 修复非CC客户端OAuth伪装被Anthropic检测为第三方应用的问题 · 1c9a2128
      shaw authored
      commit f3aa54b7 的 rewriteSystemForNonClaudeCode 未能通过 Anthropic 第三方检测,
      根因是两个关键信号与真实 Claude Code 不一致:
      
      1. anthropic-beta 头缺少 claude-code-20250219:伪装路径主动将该 beta
         加入 drop set 并移除,但 Anthropic 依赖此 beta 识别 Claude Code 请求。
         修复:非 haiku 模型的伪装请求强制包含 claude-code beta。
      
      2. system 字段使用 string 格式而非 array+cache_control:真实 Claude Code
         始终以 [{type,text,cache_control:{type:"ephemeral"}}] 发送 system,
         string 格式成为第三方检测信号。
         修复:rewriteSystemForNonClaudeCode 改为注入 array 格式。
      
      附带调整:stripSystemCacheControl 按 system 是否被重写动态决定,
      重写时保留 CC prompt 的 cache_control,未重写时(haiku/已含CC前缀)
      保持原有剥离行为。
      1c9a2128
  5. 07 Apr, 2026 7 commits
  6. 05 Apr, 2026 4 commits
    • erio's avatar
      refactor(channel): split long functions, extract shared validation, move... · 9151d34d
      erio authored
      refactor(channel): split long functions, extract shared validation, move billing validation to service
      
      - Split Update (98→25 lines), buildCache (54→20 lines), Create (51→25 lines)
        into focused sub-functions: applyUpdateInput, checkGroupConflicts,
        fetchChannelData, populateChannelCache, storeErrorCache, getOldGroupIDs,
        invalidateAuthCacheForGroups
      - Extract validateChannelConfig to eliminate duplicated validation calls
        between Create and Update
      - Move validatePricingBillingMode from handler to service layer for
        proper separation of concerns
      - Add error logging to IsModelRestricted (was silently swallowing errors)
      - Add 12 new tests: ToUsageFields, billing mode validation, antigravity
        wildcard mapping isolation, Create/Update mapping conflict integration
      9151d34d
    • github-actions[bot]'s avatar
      58df2f0b
    • erio's avatar
      fix: remove cross-platform pricing/mapping leakage for antigravity groups · c5688fef
      erio authored
      Antigravity groups were incorrectly matching pricing and model mapping
      entries from anthropic/gemini platform tabs. Each platform should be
      strictly isolated — antigravity groups only use antigravity-tagged pricing.
      c5688fef
    • erio's avatar
      fix: gofmt formatting · 19655a15
      erio authored
      19655a15