1. 16 Jan, 2026 7 commits
  2. 15 Jan, 2026 14 commits
    • IanShaw027's avatar
      fix(lint): 修复剩余的errcheck错误 · 41584008
      IanShaw027 authored
      修复了测试文件中剩余的6处类型断言未检查错误:
      - 第115-118行:choices.message.tool_calls 的类型断言链
      - 第140和145行:multiple tool calls 测试的类型断言
      - 第343和345行:ComplexSSEData 测试的类型断言
      
      **修复模式:**
      所有类型断言都改为使用 ok 检查:
      ```go
      // 修复前
      choices := payload["choices"].([]any)
      
      // 修复后
      choices, ok := payload["choices"].([]any)
      if !ok || len(choices) == 0 {
          t.Fatal("No choices found in result")
      }
      ```
      
      **测试验证:**
      -  TestCorrectToolCallsInSSEData - 所有子测试通过
      -  TestComplexSSEData - 通过
      -  TestCorrectToolParameters - 通过
      -  所有类型断言都有 ok 检查
      -  添加了数组长度验证
      
      现在所有 errcheck 错误都已修复。
      41584008
    • IanShaw027's avatar
      fix(lint): 修复golangci-lint检查发现的问题 · c4f6c89b
      IanShaw027 authored
      修复了4个lint问题:
      1. errcheck (3处): 在测试中添加类型断言的ok检查
      2. govet copylocks (1处): 将mutex从ToolCorrectionStats移到CodexToolCorrector
      
      **详细修改:**
      
      1. **openai_tool_corrector_test.go**
         - 添加了类型断言的ok检查,避免panic
         - 在解析JSON后检查payload结构的有效性
         - 改进错误处理和测试可靠性
      
      2. **openai_tool_corrector.go**
         - 将sync.RWMutex从ToolCorrectionStats移到CodexToolCorrector
         - 避免在GetStats()返回时复制mutex
         - 保持线程安全的同时符合Go最佳实践
      
      **测试验证:**
      - 所有单元测试通过 
      - go vet 检查通过 
      - 代码编译正常 
      c4f6c89b
    • 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
    • IanShaw027's avatar
      fix(ops): 调整健康分数权重以修复CI测试 · b2ff326c
      IanShaw027 authored
      - 将业务健康和基础设施健康的权重从80/20调整为70/30
      - 使基础设施故障(DB/Redis)对总分影响更明显
      - 修复三个失败的测试用例:
        * DB故障: 92→88 (期望70-90)
        * Redis故障: 96→94 (期望85-95)
        * 业务降级: 82→84.5 (期望84-85)
      b2ff326c
    • IanShaw027's avatar
      refactor(ops): 优化任务心跳和组件刷新机制 · 23aa69f5
      IanShaw027 authored
      后端改动:
      - 添加 ops_job_heartbeats.last_result 字段记录任务执行结果
      - 优化告警评估器统计信息(规则数/事件数/邮件数)
      - 统一各定时任务的心跳记录格式
      
      前端改动:
      - 重构 OpsConcurrencyCard 使用父组件统一控制刷新节奏
      - 移除独立的 5 秒刷新定时器,改用 refreshToken 机制
      - 修复 TypeScript 类型错误
      23aa69f5
    • IanShaw027's avatar
      refactor(ops): 调整健康得分权重 · 93b5b747
      IanShaw027 authored
      - 业务健康权重从 70% 提升到 80%
      - 基础设施健康权重从 30% 降低到 20%
      - 更加关注业务指标(SLA、错误率等)对整体健康的影响
      93b5b747
    • yangjianbo's avatar
      style: 修复 gofmt 格式化问题 · f862ddc9
      yangjianbo authored
      
      Co-Authored-By: default avatarClaude Opus 4.5 <noreply@anthropic.com>
      f862ddc9
    • yangjianbo's avatar
      fix(OAuth缓存): 修复缓存键冲突、401强制刷新及Redis降级处理 · 5b37e9ae
      yangjianbo authored
      
      
      - Gemini 缓存键统一增加 gemini: 前缀,避免与其他平台命名空间冲突
      - OAuth 账号 401 错误时设置 expires_at=now 并持久化,强制下次请求刷新 token
      - Redis 锁获取失败时降级为无锁刷新,仅在 token 接近过期时执行,并检查 ctx 取消状态
      Co-Authored-By: default avatarClaude Opus 4.5 <noreply@anthropic.com>
      5b37e9ae
    • yangjianbo's avatar
      feat(网关): 引入 OpenAI/Claude OAuth token 缓存 · 1820389a
      yangjianbo authored
      新增 OpenAI/Claude TokenProvider 与缓存键生成
      扩展 OAuth 缓存失效覆盖更多平台
      统一 OAuth 缓存前缀与依赖注入
      1820389a
    • LLLLLLiulei's avatar
      feat: add proxy geo location · aab44f9f
      LLLLLLiulei authored
      aab44f9f
    • yangjianbo's avatar
      feat: merge dev · 90bce60b
      yangjianbo authored
      90bce60b
    • yangjianbo's avatar
      fix(认证): OAuth 401 直接标记错误状态 · a458e684
      yangjianbo authored
      - OAuth 401 清理缓存并设置错误状态
      
      - 移除 oauth_401_cooldown_minutes 配置及示例
      
      - 更新 401 相关单测
      
      破坏性变更: OAuth 401 不再临时不可调度,需手动恢复
      a458e684
    • LLLLLLiulei's avatar
      Revert "feat: add proxy geo location" · 87b46629
      LLLLLLiulei authored
      This reverts commit 09c4f82927ddce1c9528c146a26457f53d02b034.
      87b46629
    • LLLLLLiulei's avatar
      feat: add proxy geo location · 3a100339
      LLLLLLiulei authored
      3a100339
  3. 14 Jan, 2026 19 commits
    • IanShaw027's avatar
      2daf13c4
    • IanShaw027's avatar
      feat(ops): 添加用户信息显示和搜索功能 · 2a6fb1e4
      IanShaw027 authored
      - 在错误日志列表和详情中显示用户邮箱
      - 在 GetErrorLogByID 中关联 users 表获取用户邮箱
      - 在 OpsErrorLogFilter 中添加 UserQuery 字段
      - 在 buildOpsErrorLogsWhere 中添加用户邮箱搜索条件
      - 在 GetErrorLogs handler 中支持 user_query 参数
      2a6fb1e4
    • IanShaw027's avatar
      feat(ops): 添加上游响应体字段到错误事件 · 9e6cd36a
      IanShaw027 authored
      - 在 OpsUpstreamErrorEvent 中添加 UpstreamResponseBody 字段
      - 用于存储上游服务返回的响应内容
      - 区分客户端响应和上游响应
      9e6cd36a
    • IanShaw027's avatar
      fix(lint): 修复 golangci-lint 检查问题 · 841d7ef2
      IanShaw027 authored
      - 格式化代码(gofmt)
      - 修复空指针检查(staticcheck)
      - 删除未使用的函数(unused)
      841d7ef2
    • IanShaw027's avatar
      refactor(ops): 使用TTFT替代Duration作为健康分数指标 · a7a49be8
      IanShaw027 authored
      - 业务健康分数:错误率 50% + TTFT 50%
      - TTFT 阈值:1s → 100分,3s → 0分
      - TTFT 对 AI 服务的用户体验更有意义
      - 更新所有相关测试用例期望值
      a7a49be8
    • IanShaw027's avatar
      refactor(ops): 优化健康分数计算逻辑和阈值 · d5eab7da
      IanShaw027 authored
      - 移除 SLA 组件(与错误率重复)
      - 恢复延迟组件,阈值调整为 1s-2s
      - 错误率阈值调整为 1%-10%(更宽松)
      - 业务健康分数:错误率 50% + 延迟 50%
      - 更新所有相关测试用例期望值
      d5eab7da
    • IanShaw027's avatar
      test(ops): 修复健康分数测试用例期望值 · 9b102415
      IanShaw027 authored
      - 更新 TestComputeBusinessHealth 中 SLA 95% 边界测试的期望值
      - 更新 TestComputeDashboardHealthScore 中中等健康度测试的期望值
      - 适配移除延迟组件后的新健康分数计算逻辑
      9b102415
    • IanShaw027's avatar
      fix(ops): 优化错误日志查询和详情展示 · 9584af5c
      IanShaw027 authored
      - 新增 GetErrorLogByID 接口用于获取单个错误日志详情
      - 优化 GetErrorLogs 过滤逻辑,简化参数处理
      - 简化前端错误详情模态框代码,提升可维护性
      - 更新相关 API 接口和 i18n 翻译
      9584af5c
    • longgexx's avatar
      fix(admin): 修复使用记录页面趋势图筛选联动和日期选择问题 · 806f402b
      longgexx authored
         修复两个问题:
         1. Token使用趋势图和模型分布图未响应筛选条件
         2. 上午时段选择今天刷新后日期回退到前一天
      
         前端修改:
         - 更新 dashboard API 类型定义,添加 model、account_id、group_id、stream 参数支持
         - 修改 UsageView 趋势图加载逻辑,传递所有筛选参数到后端
         - 修复日期格式化函数,使用本地时区避免 UTC 转换导致的日期偏移
      
         后端修改:
         - Handler 层:接收并解析所有筛选参数(model、account_id、group_id、stream)
         - Service 层:传递完整的筛选参数到 Repository 层
         - Repository 层:SQL 查询动态添加所有过滤条件
         - 更新接口定义和所有调用点以保持一致性
      
         影响范围:
         - /admin/dashboard/trend 端点现支持完整筛选
         - /admin/dashboard/models 端点现支持完整筛选
         - 用户在后台使用记录页面选择任意筛选条件时,趋势图和模型分布图会实时响应
         - 日期选择器在任何时区下都能正确保持今天的选择
      806f402b
    • LLLLLLiulei's avatar
      feat: enhance proxy management · 9bdb45be
      LLLLLLiulei authored
      9bdb45be
    • IanShaw027's avatar
      fix(ops): 优化错误日志过滤和查询逻辑 · 55e469c7
      IanShaw027 authored
      后端改动:
      - 添加 resolved 参数默认值处理(向后兼容,默认显示未解决错误)
      - 新增 status_codes_other 查询参数支持
      - 移除 service 层的高级设置过滤逻辑,简化错误日志查询流程
      
      前端改动:
      - 完善错误日志相关组件的国际化支持
      - 优化 Ops 监控面板和设置对话框的用户体验
      55e469c7
    • 墨颜's avatar
      feat(计费): 支持账号计费倍率快照与统计展示 · fb99ceac
      墨颜 authored
      - 新增 accounts.rate_multiplier(默认 1.0,允许 0)
      - 使用 usage_logs.account_rate_multiplier 记录倍率快照,避免历史回算
      - 统计/导出/管理端展示账号口径费用(total_cost * account_rate_multiplier)
      fb99ceac
    • yangjianbo's avatar
      fix(认证): 修复 OAuth token 缓存失效与 401 处理 · daf10907
      yangjianbo authored
      新增 token 缓存失效接口并在刷新后清理
      401 限流支持自定义规则与可配置冷却时间
      补齐缓存失效与 401 处理测试
      测试: make test
      daf10907
    • 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
      7f317b90
    • IanShaw027's avatar
      060699c3
    • IanShaw027's avatar
      refactor(ops): 重构ops核心服务层代码 · 967e2587
      IanShaw027 authored
      967e2587
    • IanShaw027's avatar
      refactor(ops): 移除duration相关告警指标,简化监控配置 · 18268381
      IanShaw027 authored
      主要改动:
      - 移除 p95_latency_ms 和 p99_latency_ms 告警指标类型
      - 移除配置中的 latency_p99_ms_max 阈值设置
      - 简化健康分数计算(移除latency权重,重新归一化SLA和错误率)
      - 移除duration相关的诊断规则和阈值检查
      - 统一术语:延迟 → 请求时长
      - 保留duration数据展示,但不再用于告警判断
      - 聚焦TTFT作为主要的响应速度告警指标
      
      影响范围:
      - Backend: handler, service, models, tests
      - Frontend: API types, i18n, components
      18268381