yangjianbo
bde9dbc57a
feat(anthropic): 支持 API Key 自动透传并优化透传链路性能
...
- 新增 Anthropic API Key 自动透传开关与后端透传分支(仅替换认证)
- 账号编辑页新增自动透传开关,默认关闭
- 优化透传性能:SSE usage 解析 gjson 快路径、减少请求体重复拷贝、优化流式写回与非流式 usage 解析
- 补充单元测试与 benchmark,确保 Claude OAuth 路径不受影响
2026-02-21 14:16:18 +08:00
yangjianbo
f323174d07
fix(openai): 修复 codex_cli_only 误拦截并补充 codex 家族识别
...
- 为 codex_cli_only 增加 originator 判定通道,避免仅依赖 User-Agent 误拦截
- 扩展官方客户端家族标识,补充 codex_chatgpt_desktop 等常见前缀
- 新增并更新单元测试与网关透传回归测试,覆盖 UA 与 originator 组合场景
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-21 12:06:24 +08:00
yangjianbo
03f69dd394
fix(proxy): 将401/405质量检测结果调整为告警
2026-02-20 14:42:07 +08:00
yangjianbo
d14c24bbf3
feat(proxy): 持久化质量检测结果并在列表展示
2026-02-20 12:13:04 +08:00
yangjianbo
48dc011b2a
test(admin,service): 修复代理质量与计费单测口径
2026-02-19 21:39:31 +08:00
yangjianbo
b341810e60
fix(sora): 优化 challenge 重试与调试日志
2026-02-19 21:38:04 +08:00
yangjianbo
46d9aee6dd
feat(proxy,sora): 增强代理质量检测与Sora稳定性并修复审查问题
2026-02-19 21:18:35 +08:00
yangjianbo
36a1a7998b
feat(sora): 强制Sora走curl_cffi sidecar并完善校验测试
2026-02-19 20:29:31 +08:00
yangjianbo
40498aac9d
feat(sora): 对齐sora2api分镜角色去水印与挑战错误治理
2026-02-19 20:04:10 +08:00
yangjianbo
440b87094a
fix(sora): 增强 Cloudflare 挑战识别并收敛 Sora 请求链路
...
- 在 failover 场景透传上游响应头并识别 Cloudflare challenge/cf-ray
- 统一 Sora 任务请求的 UA 与代理使用,sentinel 与业务请求保持一致
- 修复流式错误事件 JSON 转义问题并补充相关单元测试
2026-02-19 15:09:58 +08:00
yangjianbo
0832dfb32e
fix(sora): 默认开启 TLS 指纹并支持显式关闭
2026-02-19 08:30:54 +08:00
yangjianbo
be09188bda
feat(account-test): 增强 Sora 账号测试能力探测与弹窗交互
...
- 后端新增 Sora2 邀请码与剩余额度探测,并补充对应结果解析
- Sora 测试流程补齐请求头与 Cloudflare 场景提示,完善单测覆盖
- 前端测试弹窗对 Sora 账号改为免选模型流程,并新增中英文提示文案
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-19 08:29:51 +08:00
yangjianbo
5d2219d299
fix(sora): 修复令牌刷新请求格式与流式错误转义
...
- 将 refresh_token 恢复请求改为表单编码并匹配 OAuth 约定
- 流式错误改为 JSON 序列化,避免消息含引号或换行导致 SSE 非法
- 补充 Sora token 恢复与 failover 流式错误透传回归测试
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-19 08:23:00 +08:00
yangjianbo
900cce20a1
feat(sora): 对齐 Sora OAuth 流程并隔离网关请求路径
...
- 新增并接通 Sora 专用 OAuth 接口与 ST/RT 换取能力
- 完成前端 Sora 授权、RT/ST 手动导入与账号创建流程
- 强化 Sora token 恢复、转发日志与网关路由隔离行为
- 补充后端服务层与路由层相关测试覆盖
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-19 08:02:56 +08:00
yangjianbo
5d9667d27a
Merge branch 'main' into test
...
# Conflicts:
# backend/cmd/server/VERSION
# backend/ent/migrate/schema.go
# backend/ent/mutation.go
# backend/ent/runtime/runtime.go
# backend/ent/usagelog.go
# backend/ent/usagelog/usagelog.go
# backend/ent/usagelog/where.go
# backend/ent/usagelog_create.go
# backend/ent/usagelog_update.go
# backend/internal/repository/usage_log_repo.go
# backend/internal/server/api_contract_test.go
# backend/internal/server/middleware/cors.go
# backend/internal/service/gateway_service.go
2026-02-18 20:16:31 +08:00
yangjianbo
fad04ca995
Merge branch 'main' of https://github.com/mt21625457/aicodex2api
2026-02-18 20:10:32 +08:00
shaw
074bd0dfda
fix: 临时移除context-1m-2025-08-07以确保避免sonnet1m触发429
2026-02-18 18:41:30 +08:00
Wesley Liddick
beceb45d23
Merge pull request #591 from miraserver/main
...
feat: add Cache TTL Override per account
2026-02-18 15:59:25 +08:00
John Doe
3d1f03c286
feat: add Cache TTL Override per account + bump VERSION to 0.1.83
...
- Account-level cache TTL override: rewrite Anthropic cache_creation
token classification (5m↔1h) in streaming/non-streaming responses
- New DB field cache_ttl_overridden in usage_log for billing tracking
- Migration 055_add_cache_ttl_overridden
- Frontend: CacheTTL override toggle in account create/edit modals
- Ent schema regenerated for new usage_log fields
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-17 14:19:24 +03:00
0-don
8ff40f52e0
fix: remove unsupported parameters from Codex model requests
2026-02-17 00:06:32 +01:00
yangjianbo
6577f2ef03
fix(gateway): 避免SSE delta将缓存创建明细重置为0
...
- 仅在 delta 中 5m/1h 值大于0时覆盖 usage 明细
- 新增回归测试覆盖 delta 默认 0 不应覆盖 message_start 非零值
- 迁移 054 在删除 legacy 字段前追加一次回填,避免升级实例丢失历史写入
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-16 13:23:12 +08:00
yangjianbo
41d0383fb7
merge(test): 合并 main 并解决前端筛选器冲突
2026-02-15 22:04:06 +08:00
程序猿MT
1cf51b14f7
Merge branch 'Wei-Shaw:main' into main
2026-02-15 20:49:14 +08:00
shaw
a817cafe3d
feat: 区分 Anthropic 5m/1h 缓存创建 token 的差异化计费
...
Anthropic API 的 cache_creation 对象区分了 ephemeral_5m 和 ephemeral_1h
两种缓存创建 token,1h 单价远高于 5m(如 claude-3-5-haiku: 5m=$1/MTok,
1h=$6/MTok)。此前系统统一按 5m 单价计费,导致计费偏低。
后端:
- pricing_service: 加载 LiteLLM 的 cache_creation_input_token_cost_above_1hr
- billing_service: GetModelPricing 启用分类计费(安全守卫 1h>5m),
CalculateCost 按 5m/1h 分别计费,无明细时回退到 5m 单价
- gateway_service: parseSSEUsage/handleNonStreamingResponse 用 gjson
提取嵌套 cache_creation 对象的 ephemeral_5m/1h_input_tokens
- antigravity_gateway_service: extractSSEUsage/extractClaudeUsage 同步提取
- usage_log: 修复 GORM column tag 确保写入正确的数据库列
- 新增迁移 054: 删除 GORM 自动生成的重复列
前端:
- 使用记录 tooltip 展示 5m/1h 缓存创建明细(带彩色 badge 区分)
- 表格单元格缓存写入数值旁显示 1h 标识
2026-02-14 18:15:35 +08:00
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
shaw
e681431454
fix: Anthropic 429 限流使用精确的窗口重置时间而非聚合最大值
...
当账号仅触发 5h 窗口限流时,旧逻辑从聚合头
anthropic-ratelimit-unified-reset 读取重置时间,该值为所有窗口的
最大值(即 7d 重置时间),导致账号被标记为不可调度约 6 天。
新增 calculateAnthropic429ResetTime 函数,解析 Anthropic 的
per-window 头(5h-utilization/reset、7d-utilization/reset、
surpassed-threshold),判断实际触发的窗口并使用对应的重置时间:
- 仅 5h 超标 → 使用 5h-reset(约 5 小时)
- 仅 7d 超标 → 使用 7d-reset
- 两者均超标 → 使用 7d-reset(较长冷却)
- per-window 头不存在 → 回退到聚合头(向后兼容)
2026-02-14 00:21:56 +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
kyx236
fe1d46a8ea
feat(admin): Add group filtering for account listings
...
- Add groupID parameter to ListAccounts and ListWithFilters methods
- Implement account filtering by group ID in repository query
- Add group query parameter parsing in account handler
- Update all ListAccounts/ListWithFilters call sites with groupID parameter
- Add group filter UI component to AccountTableFilters
- Add i18n translations for group filter label in English and Chinese
- Update API contract and test stubs to reflect new signature
- Enable filtering accounts by their assigned groups in admin panel
2026-02-12 03:47:06 +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