yangjianbo
d04b47b3ca
feat(backend): 提交后端审计修复与配套测试改动
2026-02-14 11:23:10 +08:00
yangjianbo
57e8abcb63
fix(openai): 自动透传预检 instructions 并本地 403 拦截
2026-02-14 10:49:01 +08:00
yangjianbo
ed31c54961
fix(openai): 拒绝日志记录原始 User-Agent 便于攻击研判
2026-02-14 09:59:19 +08:00
yangjianbo
4bfa69bffa
fix(openai): 仅记录 codex_cli_only 拒绝日志并输出详细 User-Agent
2026-02-14 09:53:17 +08:00
yangjianbo
f96acf6e27
fix(ops): 修复日志级别过滤并增强OpenAI错误诊断日志
...
- 移除 warn 级别下 access info 的强制入库补写,确保运行时日志级别真实生效
- 将 OpenAI fallback matched 与 passthrough 断流提示按需求降级为 info
- 为 codex_cli_only 与 instructions required 场景补充请求诊断字段(含 User-Agent)
- 出于安全考虑移除请求体预览,仅保留 request_body_size 与白名单头信息
- 新增/更新回归测试,覆盖 Forward 入口到日志落库链路
2026-02-13 19:27:07 +08:00
yangjianbo
2459eafb71
feat: 完善日志
2026-02-13 13:35:47 +08:00
yangjianbo
3734abed4c
feat(openai): 支持 gpt-5.3-codex-spark 并统一 gpt-5.3 到 codex 计费
2026-02-13 09:28:07 +08:00
yangjianbo
abf5de69fb
Merge branch 'main' into test
2026-02-12 23:43:47 +08:00
程序猿MT
174d7c774d
Merge branch 'Wei-Shaw:main' into main
2026-02-12 23:12:41 +08:00
yangjianbo
a9518cc5be
feat(openai): 增加 OAuth 账号 Codex 官方客户端限制开关
...
新增 codex_cli_only 开关并默认关闭,关闭时完全绕过限制逻辑。
在 OpenAI 网关引入统一检测入口,集中判定账号类型、开关与客户端族。
开启后仅放行 codex_cli_rs、codex_vscode、codex_app 客户端家族。
补充后端判定与网关分支测试,并在前端创建/编辑页增加开关配置与回显。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-12 22:32:59 +08:00
yangjianbo
2f190d812a
fix(openai): 透传OAuth强制store/stream并修复Codex识别
2026-02-12 21:02:52 +08:00
yangjianbo
d411cf4472
fix(openai): 收敛自动透传请求头并增强 OAuth 安全兜底
2026-02-12 20:12:15 +08:00
yangjianbo
584cfc3db2
chore(logging): 完成后端日志审计与结构化迁移
...
- 将高密度服务与处理器日志迁移到新日志系统(LegacyPrintf/结构化日志)
- 增加 stdlog bridge 与兼容测试,保留旧日志捕获能力
- 将 OpenAI 断流告警改为结构化 Warn 并改造对应测试为 sink 捕获
- 补齐后端相关文件 logger 引用并通过全量 go test
2026-02-12 19:01:09 +08:00
yangjianbo
84cc651b46
fix(logger): 修复 caller 字段与 OpsSystemLogSink 停止刷盘
...
修复点:
- zap logger 不再强制 AddCallerSkip(1),确保 caller 指向真实调用点
- slog handler 避免重复写 time 字段
- OpsSystemLogSink 优先从字段 component 识别业务组件;停止时 drain 队列并用可用 ctx 刷盘
补充:新增/完善对应单测
2026-02-12 17:42:29 +08:00
yangjianbo
fff1d54858
feat(log): 落地统一日志底座与系统日志运维能力
2026-02-12 16:27:29 +08:00
yangjianbo
a5f29019d9
test(ops): 提升日志链路覆盖率并修复lint阻塞
2026-02-12 16:25:44 +08:00
yangjianbo
af3069073a
chore(lint): 修复 golangci-lint unused
...
- 移除 OpenAIGatewayHandler 未使用字段
- 删除并发缓存中未使用的 Redis 脚本常量
- 将仅供 unit 测试使用的 parseIntegralNumber 移入 unit build tag 文件
2026-02-12 14:20:56 +08:00
yangjianbo
65661f24e2
feat(ops): 运维监控新增 OpenAI Token 请求统计表
...
- 新增管理端接口 /api/v1/admin/ops/dashboard/openai-token-stats,按模型聚合统计 gpt% 请求
- 支持 time_range=30m|1h|1d|15d|30d(默认 30d),支持 platform/group_id 过滤
- 支持分页(page/page_size)或 TopN(top_n)互斥查询
- 前端运维监控页新增统计表卡片,包含空态/错误态与分页/TopN 交互
- 补齐后端与前端测试
2026-02-12 14:20:14 +08:00
yangjianbo
ed2eba9028
fix(gateway): 默认过滤OpenAI透传超时头并补充断流告警
2026-02-12 14:16:18 +08:00
yangjianbo
6533a4647d
fix(openai): 增强自动透传命中日志
2026-02-12 11:41:06 +08:00
yangjianbo
9c910c2049
feat(openai): 支持自动透传开关并透传 User-Agent
...
- OpenAI OAuth/API Key 统一支持自动透传开关,编辑页可开关\n- 透传模式仅替换认证并保留计费/并发/审计,修复 API Key responses 端点拼接\n- Usage 页面显示原始 User-Agent 且不截断,补充回归测试与清单
2026-02-12 10:56:07 +08:00
yangjianbo
61a2bf469a
feat(openai): 极致优化 OAuth 链路并补齐性能守护
...
- 优化 /v1/responses 热路径,减少重复解析与不必要拷贝\n- 优化并发与 token 竞争路径并补齐运行指标\n- 补充 OpenAI/Ops 相关单元测试与回归用例\n- 新增灰度阈值守护与压测脚本,支撑发布验收
2026-02-12 09:41:37 +08:00
yangjianbo
a88bb8684f
fix(openai): 修复 OAuth 透传流式断开与压缩头问题
...
- 透传流式在客户端断开后继续 drain 上游并解析 usage,避免计费信息丢失
- 阻断透传 accept-encoding,避免压缩响应影响 SSE/usage 解析
- 阻断 proxy-authorization,避免透传代理鉴权信息
- 补充回归测试:请求头阻断与断流后 usage 采集
2026-02-11 22:17:38 +08:00
Wesley Liddick
d307d48def
Merge pull request #551 from SilentFlower/opus4.6-think
...
[UPDATE] 增强 Claude Thinking 模式支持与 Opus 4.6 动态预算适配
2026-02-11 20:00:22 +08:00
Wesley Liddick
1bb40084fc
Merge pull request #550 from Tian-orz/feat/antigravity-refresh-token-import
...
feat(antigravity): 支持 Refresh Token 批量导入创建 OAuth 账号
2026-02-11 19:59:52 +08:00
Wesley Liddick
8f0efa16ca
Merge pull request #555 from sususu98/fix/gemini-thoughts-token-billing
...
fix: include Gemini thoughtsTokenCount in output token billing
2026-02-11 19:53:43 +08:00
程序猿MT
8da5fac69e
Merge branch 'Wei-Shaw:main' into main
2026-02-11 18:39:52 +08:00
sususu98
d21d70a5cf
fix: include Gemini thoughtsTokenCount in output token billing
...
Gemini 2.5 Pro/Flash thinking models return thoughtsTokenCount separately
from candidatesTokenCount in usageMetadata, but this field was not parsed
or included in billing calculations, causing thinking tokens to be
unbilled.
- Add ThoughtsTokenCount field to GeminiUsageMetadata struct
- Include thoughtsTokenCount in OutputTokens across all 3 Gemini usage
parsing paths (non-streaming, streaming, compat layer)
- Add tests covering thinking token scenarios
Closes #554
2026-02-11 15:41:54 +08:00
SilentFlower
e73b778d2b
Merge branch 'main' into opus4.6-think
2026-02-11 13:56:30 +08:00
Edric Li
a4a46a8618
✨ feat(antigravity): 添加 onboardUser 支持并修复 project_id 补齐逻辑
...
- 新增 OnboardUser API 客户端方法,支持账号 onboarding 获取 project_id
- loadProjectIDWithRetry 增加 onboard 回退:LoadCodeAssist 未返回 project_id 时自动触发 onboarding
- GetAccessToken 中 project_id 补齐改用轻量 FillProjectID 替代全量 RefreshAccountToken
- 补齐逻辑增加 5 分钟冷却机制,防止频繁重试
- OnboardUser 轮询等待改为 context 感知,支持提前取消
- 提取 mergeCredentials 辅助方法消除重复代码
- 新增 extractProjectIDFromOnboardResponse 和 resolveDefaultTierID 单元测试
2026-02-11 13:41:55 +08:00
SilentFlower
19cca11e00
[UPDATE] 增强 Claude Thinking 模式支持与 Opus 4.6 动态预算适配
...
✨ feat(antigravity): 支持 thinking adaptive 类型并适配 Opus 4.6 动态预算
🧪 test(gateway): 增加 thinking 模式解析与签名块过滤的边界用例测试
2026-02-11 10:31:16 +08:00
Tian
c8f87a9c92
feat(antigravity): 支持 Refresh Token 批量导入创建 OAuth 账号
...
后端新增 ValidateRefreshToken service 方法和 POST /oauth/refresh-token 端点,
前端新增 API/Composable/UI 集成,OAuthAuthorizationFlow i18n 动态化,
支持在 Antigravity 创建账号时批量粘贴 Refresh Token 自动验证并创建账号。
2026-02-11 01:23:21 +08:00
yangjianbo
f1e884ce2b
feat(openai): 增加 OAuth 透传开关
...
- 仅对 Codex CLI 且账号开启时走原样透传(只替换认证)
- 透传模式禁用工具修正/模型替换,并旁路解析 usage 用于计费
- 管理后台增加开关与文案,ops upstream error 记录 passthrough 标记
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-11 00:59:39 +08:00
yangjianbo
86f3124720
perf(service): 优化重试场景 thinking 过滤性能
...
- 避免全量 Unmarshal 请求体,改为仅解析 messages 子树
- 顶层 thinking 使用 sjson 直接删除,减少整体重写
- content 仅在需要修改时延迟分配 new slice
- 增加 FilterThinkingBlocksForRetry 基准测试
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-11 00:47:26 +08:00
yangjianbo
4b309fa8b5
fix(gateway): 优化 ParseGatewayRequest 函数,使用 unsafe 提高性能并增加 JSON 校验
2026-02-10 22:12:24 +08:00
Edric Li
378e476e48
fix: 修复 CI 检查失败
...
- gofmt: 修复 error_passthrough_service.go 格式问题
- errcheck: 修复 error_passthrough_runtime_test.go 类型断言未检查
- staticcheck: if-else 改为 switch (gateway_service.go)
- test: 修复两个测试用例错误使用 MODEL_CAPACITY_EXHAUSTED 导致走错路径
2026-02-10 22:08:49 +08:00
Edric Li
2a1067c82b
Merge remote-tracking branch 'upstream/main'
2026-02-10 21:52:33 +08:00
Edric Li
a54b81cf74
perf: 错误处理性能优化
...
- MatchRule 延迟/限制 body ToLower,先用 statusCode 短路,只在需要关键词匹配时转换且限制 8KB
- 预计算规则的小写关键词/平台和 error code set,消除运行时重复 ToLower 和线性扫描
- MODEL_CAPACITY_EXHAUSTED 全局去重,避免并发请求重复重试同一模型
- 503 重试 body 读取限制从 2MB 降至 8KB
- time.After 替换为 time.NewTimer,防止 context 取消时 timer 泄漏
2026-02-10 21:40:31 +08:00
Edric Li
2d4236f76e
fix: 修复错误透传规则 skip_monitoring 未生效的问题
...
- ops_error_logger: status < 400 分支增加 OpsSkipPassthroughKey 检查
- ops_upstream_context: 新增 checkSkipMonitoringForUpstreamEvent,中间重试/故障转移事件也能触发跳过标记
- gateway_handler/openai_gateway_handler/gemini_v1beta_handler: handleFailoverExhausted 匹配规则后设置 OpsSkipPassthroughKey
- antigravity_gateway_service: writeMappedClaudeError 增加 applyErrorPassthroughRule 调用
2026-02-10 20:56:01 +08:00
yangjianbo
3b0910f664
Merge branch 'main' into test-sora
2026-02-10 18:01:17 +08:00
yangjianbo
e489996713
test(backend): 补充改动代码单元测试覆盖率至 85%+
...
新增 48 个测试用例覆盖修复代码的各分支路径:
- subscription_maintenance_queue: nil receiver/task、Stop 幂等、零值参数 (+6)
- billing_service: CalculateCostWithConfig、错误传播、SoraImageCost 等 (+12)
- timing_wheel_service: Schedule/ScheduleRecurring after Stop (+3)
- sora_media_cleanup_service: nil guard、Start/Stop 各分支、timezone (+10)
- sora_gateway_service: normalizeSoraMediaURLs、buildSoraContent 等辅助函数 (+17)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-10 17:52:10 +08:00
yangjianbo
54fe363257
fix(backend): 修复代码审核发现的 8 个确认问题
...
- P0-1: subscription_maintenance_queue 使用 RWMutex 防止 channel close/send 竞态
- P0-2: billing_service CalculateCostWithLongContext 修复被吞没的 out-range 错误
- P1-1: timing_wheel_service Schedule/ScheduleRecurring 添加 SetTimer 错误日志
- P1-2: sora_gateway_service StoreFromURLs 失败时降级使用原始 URL
- P1-3: concurrency_cache 用 Pipeline 替代 Lua 脚本兼容 Redis Cluster
- P1-6: sora_media_cleanup_service runCleanup 添加 nil cfg/storage 防护
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-10 17:51:49 +08:00
song
b161312183
test(antigravity): 更新单URL策略下的重试断言
2026-02-10 14:36:09 +08:00
程序猿MT
1dd3158c7e
Merge branch 'Wei-Shaw:main' into main
2026-02-10 13:55:51 +08:00
song
1f647b120a
feat(antigravity): 转发与测试支持daily/prod单URL切换
2026-02-10 13:51:29 +08:00
Edric Li
7d0a30fa8f
merge: sync upstream main (antigravity single-account 503 retry)
...
合并上游新增的 Antigravity 单账号 503 退避重试机制,
解决与本地 MODEL_CAPACITY_EXHAUSTED 逻辑的冲突,两者共存。
2026-02-10 12:00:21 +08:00
Edric Li
d95e04fd1f
feat: 错误透传规则支持 skip_monitoring 跳过运维监控记录
...
在每条错误透传规则上新增 skip_monitoring 选项,开启后匹配该规则的错误
不会被记录到 ops_error_logs,减少监控噪音。默认关闭,不影响现有规则。
2026-02-10 11:42:39 +08:00
shaw
5dd83d3cf2
fix: 移除特定system以适配新版cc客户端缓存失效的bug
2026-02-10 10:28:34 +08:00
Wesley Liddick
14e1aac9b5
Merge pull request #533 from GuangYiDing/feat/antigravity-single-account-503-retry
...
feat: Antigravity 单账号分组 503 退避重试机制
2026-02-10 09:59:48 +08:00
yangjianbo
58912d4ac5
perf(backend): 使用 gjson/sjson 优化热路径 JSON 处理
...
将 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: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-10 08:59:30 +08:00