1. 10 Feb, 2026 2 commits
    • yangjianbo's avatar
      feat(openai): 增加 OAuth 透传开关 · f1e884ce
      yangjianbo authored
      
      
      - 仅对 Codex CLI 且账号开启时走原样透传(只替换认证)
      
      - 透传模式禁用工具修正/模型替换,并旁路解析 usage 用于计费
      
      - 管理后台增加开关与文案,ops upstream error 记录 passthrough 标记
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      f1e884ce
    • yangjianbo's avatar
      perf(backend): 使用 gjson/sjson 优化热路径 JSON 处理 · 58912d4a
      yangjianbo authored
      
      
      将 API 网关热路径中的 json.Unmarshal+json.Marshal 替换为 gjson 零拷贝查询和 sjson 精准写入:
      - unwrapV1InternalResponse 性能提升 22x(4009ns→182ns),内存分配减少 28.5x
      - unwrapGeminiResponse、extractGeminiUsage、estimateGeminiCountTokens、ParseGeminiRateLimitResetTime 改为接收 []byte 使用 gjson 提取
      - ParseGatewayRequest 的 model/stream/metadata/thinking/max_tokens 改用 gjson 类型安全提取
      - Handler 层(sora/openai)改用 gjson 提取字段、sjson 注入/修改字段,移除 map[string]any 中间变量
      - Sora Client 响应解析改用 gjson ForEach 遍历,减少内存分配
      - 新增约 100 个单元测试用例,所有改动函数覆盖率 >85%
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      58912d4a
  2. 08 Feb, 2026 1 commit
    • erio's avatar
      feat: shuffle accounts within same sort group to prevent thundering herd · 1af06aed
      erio authored
      Add post-sort shuffle for accounts with identical (priority, loadRate,
      lastUsedAt) to break deterministic ordering when concurrent requests
      read the same scheduler snapshot. Applies to both Antigravity and
      OpenAI scheduling paths, plus the sortAccountsByPriorityAndLastUsed
      helper.
      
      Keeps upstream CallCount/ModelLoadInfo scheduling intact; shuffle is
      additive and only randomises within equivalent-rank groups.
      1af06aed
  3. 07 Feb, 2026 6 commits
  4. 06 Feb, 2026 1 commit
  5. 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
  6. 04 Feb, 2026 1 commit
  7. 03 Feb, 2026 3 commits
    • liuxiongfeng's avatar
      fix(openai): 统一 OAuth instructions 处理逻辑,修复 Codex CLI 400 错误 · 9a48b2e9
      liuxiongfeng authored
      - 修改 applyCodexOAuthTransform 函数签名,增加 isCodexCLI 参数
      - 移除 && !isCodexCLI 条件,对所有 OAuth 请求统一处理
      - 新增 applyInstructions/applyCodexCLIInstructions/applyOpenCodeInstructions 辅助函数
      - 新增 isInstructionsEmpty 函数检查 instructions 字段是否为空
      - 添加 Codex CLI 和非 Codex CLI 场景的测试用例
      
      逻辑说明:
      - Codex CLI + 有 instructions: 保持不变
      - Codex CLI + 无 instructions: 补充 opencode 指令
      - 非 Codex CLI: 使用 opencode 指令覆盖
      9a48b2e9
    • 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
    • ducky's avatar
      feat(usage): add reasoning effort column · 53ee6383
      ducky authored
      53ee6383
  8. 02 Feb, 2026 1 commit
  9. 25 Jan, 2026 1 commit
  10. 20 Jan, 2026 2 commits
  11. 19 Jan, 2026 1 commit
  12. 17 Jan, 2026 1 commit
  13. 16 Jan, 2026 1 commit
  14. 15 Jan, 2026 6 commits
    • IanShaw027's avatar
      feat(openai): 添加Codex工具调用自动修正功能 · 539b41f4
      IanShaw027 authored
      实现了完整的Codex工具调用拦截和自动修正系统,解决OpenCode使用Codex模型时的工具调用兼容性问题。
      
      **核心功能:**
      
      1. **工具名称自动映射**
         - apply_patch/applyPatch → edit
         - update_plan/updatePlan → todowrite
         - read_plan/readPlan → todoread
         - search_files/searchFiles → grep
         - list_files/listFiles → glob
         - read_file/readFile → read
         - write_file/writeFile → write
         - execute_bash/executeBash/exec_bash/execBash → bash
      
      2. **工具参数自动修正**
         - bash: 自动移除不支持的 workdir/work_dir 参数
         - edit: 自动将 path 参数重命名为 file_path
         - 支持 JSON 字符串和对象两种参数格式
      
      3. **流式响应集成**
         - 在 SSE 数据流中实时修正工具调用
         - 支持多种 JSON 结构(tool_calls, function_call, delta, choices等)
         - 不影响响应性能和用户体验
      
      4. **统计和监控**
         - 记录每次工具修正的详细信息
         - 提供修正统计数据查询
         - 便于问题排查和性能优化
      
      **实现文件:**
      - `openai_tool_corrector.go`: 工具修正核心逻辑(250行)
      - `openai_tool_corrector_test.go`: 完整的单元测试(380+行)
      - `openai_gateway_service.go`: 流式响应集成
      - `openai_gateway_service_tool_correction_test.go`: 集成测试
      
      **测试覆盖:**
      - 工具名称映射测试(18个映射规则)
      - 参数修正测试(bash workdir、edit path等)
      - SSE数据修正测试(多种JSON结构)
      - 统计功能测试
      - 所有测试通过 
      
      **解决的问题:**
      修复了 OpenCode 使用 sub2api 中转 Codex 时,因工具名称和参数不兼容导致的工具调用失败问题。
      Codex 模型有时会忽略指令文件中的工具映射说明,导致调用不存在的工具(如 apply_patch)。
      现在通过流式响应拦截,自动将错误的工具调用修正为 OpenCode 兼容的格式。
      
      **参考文档:**
      - OpenCode 工具规范: https://opencode.ai/docs/
      - Codex Bridge 指令: backend/internal/service/prompts/codex_opencode_bridge.txt
      539b41f4
    • cyhhao's avatar
      c11f14f3
    • cyhhao's avatar
      98b65e67
    • yangjianbo's avatar
      style: 修复 gofmt 格式化问题 · f862ddc9
      yangjianbo authored
      
      Co-Authored-By: default avatarClaude Opus 4.5 <noreply@anthropic.com>
      f862ddc9
    • yangjianbo's avatar
      feat(网关): 引入 OpenAI/Claude OAuth token 缓存 · 1820389a
      yangjianbo authored
      新增 OpenAI/Claude TokenProvider 与缓存键生成
      扩展 OAuth 缓存失效覆盖更多平台
      统一 OAuth 缓存前缀与依赖注入
      1820389a
    • yangjianbo's avatar
      feat: merge dev · 90bce60b
      yangjianbo authored
      90bce60b
  15. 14 Jan, 2026 4 commits
    • 墨颜's avatar
      feat(计费): 支持账号计费倍率快照与统计展示 · fb99ceac
      墨颜 authored
      - 新增 accounts.rate_multiplier(默认 1.0,允许 0)
      - 使用 usage_logs.account_rate_multiplier 记录倍率快照,避免历史回算
      - 统计/导出/管理端展示账号口径费用(total_cost * account_rate_multiplier)
      fb99ceac
    • ianshaw's avatar
      fix(网关): 修复账号选择中的调度器快照延迟问题 · 25b00abc
      ianshaw authored
      ## 问题描述
      调度器快照更新存在0.5-1秒的延迟(Outbox轮询间隔),导致在账号被限流或过载后的短时间窗口内,
      可能仍会被选中,造成请求失败。
      
      ## 根本原因
      账号选择逻辑依赖调度器快照(listSchedulableAccounts),但快照更新有延迟:
      - Outbox轮询: 每1秒检查一次变更事件
      - 全量重建: 每300秒重建一次
      - 时间窗口: 账号状态变更后0.5-1秒内,快照可能未更新
      
      ## 解决方案
      在账号选择循环中添加IsSchedulable()实时检查,作为第二道防线:
      1. 第一道防线: 调度器快照过滤(可能有延迟)
      2. 第二道防线: IsSchedulable()实时检查(本次修复)
      
      IsSchedulable()会检查:
      - RateLimitResetAt: 限流重置时间
      - OverloadUntil: 过载持续时间
      - TempUnschedulableUntil: 临时不可调度时间
      - Status: 账号状态
      - Schedulable: 可调度标志
      
      ## 修改范围
      ### OpenAI Gateway Service
      - SelectAccountForModelWithExclusions: 添加IsSchedulable()检查
      - SelectAccountWithLoadAwareness: 添加IsSchedulable()检查
      
      ### Gateway Service (Claude/Gemini/Antigravity)
      - 负载感知选择候选账号筛选: 添加IsSchedulable()检查
      - selectAccountForModelWithPlatform: 添加IsSchedulable()检查
      - selectAccountWithMixedScheduling: 添加IsSchedulable()检查
      
      ### 测试用例
      - OpenAI: 添加2个测试用例验证限流账号过滤
      - Gateway: 添加2个测试用例验证限流和过载账号过滤
      
      ### 其他修复
      - ops_repo_preagg.go: 修复platform为NULL时的聚合问题
      
      ## 测试结果
      所有单元测试通过 
      25b00abc
    • IanShaw027's avatar
      refactor(ops): 完善gateway服务ops集成 · 63711067
      IanShaw027 authored
      63711067
    • IanShaw027's avatar
      060699c3
  16. 13 Jan, 2026 1 commit
    • ianshaw's avatar
      fix(openai): 增强 OpenCode 兼容性和模型规范化 · 3d6e01a5
      ianshaw authored
      ## 主要改动
      
      1. **模型规范化扩展到所有账号**
         - 将 Codex 模型规范化(如 gpt-5-nano → gpt-5.1)应用到所有 OpenAI 账号类型
         - 不再仅限于 OAuth 非 CLI 请求
         - 解决 Codex CLI 使用 ChatGPT 账号时的模型兼容性问题
      
      2. **reasoning.effort 参数规范化**
         - 自动将 `minimal` 转换为 `none`
         - 解决 gpt-5.1 模型不支持 `minimal` 值的问题
      
      3. **Session/Conversation ID fallback 机制**
         - 从请求体多个字段提取 session_id/conversation_id
         - 优先级:prompt_cache_key → session_id → conversation_id → previous_response_id
         - 支持 Codex CLI 的会话保持
      
      4. **Tool Call ID fallback**
         - 当 call_id 为空时使用 id 字段作为 fallback
         - 确保 tool call 输出能正确匹配
         - 保留 item_reference 类型的 items
      
      5. **Header 优化**
         - 添加 conversation_id 到允许的 headers
         - 移除删除 session headers 的逻辑
      
      ## 相关 Issue
      - 参考 OpenCode issue #3118 关于 item_reference 的讨论
      3d6e01a5
  17. 12 Jan, 2026 6 commits
    • ianshaw's avatar
      d85288a6
    • ianshaw's avatar
      feat(gateway): 对所有请求(包括 Codex CLI)应用模型映射 · 3402acb6
      ianshaw authored
      - 移除 Codex CLI 的模型映射跳过逻辑
      - 添加详细的模型映射日志,包含账号名称和请求类型
      - 确保所有 OpenAI 请求都能正确应用账号配置的模型映射
      3402acb6
    • ianshaw's avatar
      fix(gateway): 修复 base_url 包含 /chat/completions 时路径拼接错误 · 7fdc25df
      ianshaw authored
      问题:
      - 当账号的 base_url 配置为 https://example.com/v1/chat/completions 时
      - 代码直接追加 /responses,导致路径变成 /v1/chat/completions/responses
      - 上游返回 404 错误
      
      修复:
      - 在追加 /responses 前,先移除 base_url 中的 /chat/completions 后缀
      - 确保最终路径为 https://example.com/v1/responses
      
      影响范围:
      - OpenAI API Key 账号的测试接口
      - OpenAI API Key 账号的实际网关请求
      
      Related-to: #231
      7fdc25df
    • ianshaw's avatar
      fix(gateway): 完善 max_output_tokens 参数处理逻辑 · fe6a3f42
      ianshaw authored
      根据不同平台和账号类型处理 max_output_tokens 参数:
      - OpenAI OAuth (Responses API): 保留 max_output_tokens(支持)
      - OpenAI API Key: 删除 max_output_tokens(不支持)
      - Anthropic (Claude): 转换 max_output_tokens 为 max_tokens
      - Gemini: 删除 max_output_tokens(由 Gemini 专用转换处理)
      - 其他平台: 删除(安全起见)
      
      同时处理 max_completion_tokens 参数,仅在 OpenAI OAuth 时保留。
      
      修复客户端(如 OpenCode)发送不支持参数导致上游返回 400 错误的问题。
      
      Related-to: #231
      fe6a3f42
    • yangjianbo's avatar
      feat(scheduler): 引入调度快照缓存与 outbox 回放 · 3141aa51
      yangjianbo authored
      - 调度热路径优先读 Redis 快照,保留分组排序语义
      - outbox 回放 + 全量重建纠偏,失败重试不推进水位
      - 自动 Atlas 基线对齐并同步调度配置示例
      3141aa51
    • ianshaw's avatar
      feat(gateway): 添加流超时处理机制 · 2a0758bd
      ianshaw authored
      - 添加 StreamTimeoutSettings 配置结构体和系统设置
      - 实现 TimeoutCounterCache Redis 计数器用于累计超时次数
      - 在 RateLimitService 添加 HandleStreamTimeout 方法
      - 在 gateway_service、openai_gateway_service、antigravity_gateway_service 中调用超时处理
      - 添加后端 API 端点 GET/PUT /admin/settings/stream-timeout
      - 添加前端配置界面到系统设置页面
      - 支持配置:启用开关、超时阈值、处理方式、暂停时长、触发阈值、阈值窗口
      
      默认配置:
      - 启用:true
      - 超时阈值:60秒
      - 处理方式:临时不可调度
      - 暂停时长:5分钟
      - 触发阈值:3次
      - 阈值窗口:10分钟
      2a0758bd
  18. 11 Jan, 2026 1 commit