墨颜
ec24a3c361
Merge branch 'Wei-Shaw:main' into main
2026-01-14 16:42:30 +08:00
墨颜
d89e797bfc
Merge branch 'main' of https://github.com/whoismonay/sub2api
2026-01-14 16:30:32 +08:00
IanShaw027
55e469c7fe
fix(ops): 优化错误日志过滤和查询逻辑
...
后端改动:
- 添加 resolved 参数默认值处理(向后兼容,默认显示未解决错误)
- 新增 status_codes_other 查询参数支持
- 移除 service 层的高级设置过滤逻辑,简化错误日志查询流程
前端改动:
- 完善错误日志相关组件的国际化支持
- 优化 Ops 监控面板和设置对话框的用户体验
2026-01-14 16:26:33 +08:00
墨颜
fb99ceacc7
feat(计费): 支持账号计费倍率快照与统计展示
...
- 新增 accounts.rate_multiplier(默认 1.0,允许 0)
- 使用 usage_logs.account_rate_multiplier 记录倍率快照,避免历史回算
- 统计/导出/管理端展示账号口径费用(total_cost * account_rate_multiplier)
2026-01-14 16:12:08 +08:00
yangjianbo
daf10907e4
fix(认证): 修复 OAuth token 缓存失效与 401 处理
...
新增 token 缓存失效接口并在刷新后清理
401 限流支持自定义规则与可配置冷却时间
补齐缓存失效与 401 处理测试
测试: make test
2026-01-14 15:55:44 +08:00
Wesley Liddick
b3b2868f55
Merge pull request #278 from IanShaw027/fix/openai-account-schedulability-check
...
fix(网关): 修复账号选择中的调度器快照延迟问题
2026-01-14 15:52:35 +08:00
ianshaw
25b00abca1
fix(网关): 修复账号选择中的调度器快照延迟问题
...
## 问题描述
调度器快照更新存在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时的聚合问题
## 测试结果
所有单元测试通过 ✅
2026-01-13 22:49:26 -08:00
IanShaw027
8d0767352b
fix(ops): 修复ops handler逻辑
2026-01-14 14:30:41 +08:00
IanShaw027
918a253851
feat(frontend): 完善ops监控面板和组件功能
2026-01-14 14:30:18 +08:00
IanShaw027
63711067e6
refactor(ops): 完善gateway服务ops集成
2026-01-14 14:30:00 +08:00
IanShaw027
7158b38897
refactor(ops): 优化ops repository数据访问层
2026-01-14 14:29:39 +08:00
IanShaw027
7f317b9093
feat(ops): 增强ops核心服务功能和重试机制
2026-01-14 14:29:19 +08:00
IanShaw027
7c4309ea24
feat(ops): 添加ops handler和路由配置
2026-01-14 14:29:01 +08:00
IanShaw027
5013290486
feat(frontend): 优化ops监控UI组件
2026-01-14 12:41:24 +08:00
IanShaw027
8cf3e9a620
feat(frontend): 更新ops API接口和国际化文案
2026-01-14 12:41:05 +08:00
IanShaw027
060699c3b8
refactor(ops): 更新gateway服务集成ops功能
2026-01-14 12:40:49 +08:00
IanShaw027
2ca6c631ac
refactor(ops): 重构ops handler和repository层
2026-01-14 12:40:34 +08:00
IanShaw027
967e25878f
refactor(ops): 重构ops核心服务层代码
2026-01-14 12:40:12 +08:00
IanShaw027
182683814b
refactor(ops): 移除duration相关告警指标,简化监控配置
...
主要改动:
- 移除 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
2026-01-14 10:52:56 +08:00
shaw
99cbfa1567
fix(admin): 修复退款金额精度问题
...
- 显示完整余额精度,避免四舍五入导致的退款失败
- 添加"全部"按钮,一键填入完整余额
- 移除最小金额限制,支持任意正数金额
2026-01-14 10:22:31 +08:00
Wesley Liddick
3f8c8d70ad
Merge pull request #274 from mt21625457/main
...
fix(openai): OAuth 请求强制 store=false
2026-01-14 09:53:09 +08:00
yangjianbo
9c567fad92
fix(网关): 优化 OAuth 请求中 store 参数的处理逻辑
2026-01-14 09:46:10 +08:00
IanShaw027
33f58d583d
fix(ops): 修复告警状态验证和错误处理逻辑
...
- 增强告警事件状态验证,添加合法状态值检查
- 移除重试逻辑中的遗留字段赋值
- 修正仓库不可用时的错误类型
- 格式化测试文件代码
2026-01-14 09:39:18 +08:00
yangjianbo
0abb3a6843
Merge branch 'main' of https://github.com/mt21625457/aicodex2api
2026-01-14 09:22:37 +08:00
yangjianbo
3663951d11
fix(网关): OAuth 请求强制 store=false
...
避免上游 Store 必须为 false 的错误
仅在缺失或 true 时写回 store
测试: go test ./internal/service -run TestApplyCodexOAuthTransform
测试: make test-backend(golangci-lint 已单独执行)
2026-01-14 09:17:58 +08:00
IanShaw027
1e169685f4
feat(i18n): 添加ops新功能的国际化文案
...
- 新增告警静默相关的中英文翻译
- 补充错误分类和重试状态的文案
- 完善ops管理界面的提示信息
2026-01-14 09:04:09 +08:00
IanShaw027
f38a3e7585
feat(ui): 优化ops监控面板和组件功能
...
- 增强告警事件卡片的交互和静默功能
- 完善错误详情弹窗的展示和操作
- 优化错误日志表格的筛选和排序
- 新增重试和解决状态的UI支持
2026-01-14 09:03:59 +08:00
IanShaw027
b8da5d45ce
feat(api): 扩展前端ops API接口
...
- 新增告警静默相关API调用
- 增强错误日志查询和过滤接口
- 添加重试和解决状态管理接口
2026-01-14 09:03:45 +08:00
IanShaw027
659df6e220
feat(handler): 新增ops管理接口和路由
...
- 添加告警静默管理接口
- 扩展错误日志查询和操作接口
- 新增重试和解决状态相关端点
- 完善错误日志记录功能
2026-01-14 09:03:35 +08:00
IanShaw027
d601768016
feat(service): 增强ops业务逻辑和告警功能
...
- 实现告警静默功能的业务逻辑
- 优化错误分类和重试机制
- 扩展告警评估和通知功能
- 完善错误解决和重试结果处理
2026-01-14 09:03:16 +08:00
IanShaw027
16ddc6a83b
feat(repository): 扩展ops数据访问层功能
...
- 新增告警静默相关数据库操作
- 增强错误日志查询和统计功能
- 优化重试结果和解决状态的存储
2026-01-14 09:03:01 +08:00
IanShaw027
340dc9cadb
feat(db): 添加ops告警静默和错误分类优化迁移
...
- 添加ops告警静默功能的数据库结构
- 优化错误分类和重试结果字段标准化
2026-01-14 09:02:45 +08:00
Wesley Liddick
55fced3942
Merge pull request #269 from mt21625457/main
...
fix: 修复opencode 适配openai 套餐的错误,通过sub2api完美转发 opencode
2026-01-13 17:33:07 +08:00
yangjianbo
7bbf49fd65
为类型断言补充 ok 校验并添加中文说明,避免 errcheck 报错(backend/internal/service/
...
openai_codex_transform_test.go:36、backend/internal/service/
openai_codex_transform_test.go:89、backend/internal/service/
openai_codex_transform_test.go:104)。
2026-01-13 17:22:57 +08:00
yangjianbo
eea6c2d02c
fix(网关): 补齐Codex指令回退与输入过滤
2026-01-13 17:02:31 +08:00
yangjianbo
70eaa450db
fix(网关): 修复工具续链校验与存储策略
...
完善 function_call_output 续链校验与引用匹配
续链场景强制 store=true,过滤 input 时避免副作用
补充续链判断与过滤相关单元测试
测试: go test ./...
2026-01-13 16:47:35 +08:00
Wesley Liddick
55796a118d
Merge pull request #264 from IanShaw027/fix/openai-opencode-compatibility
...
fix(openai): 增强 OpenCode 兼容性和模型规范化
2026-01-13 16:01:37 +08:00
ianshaw
d7fa47d732
refactor(openai): 移除不必要的 seedOpenAISessionHeaders 函数
2026-01-12 20:38:46 -08:00
ianshaw
3d6e01a58f
fix(openai): 增强 OpenCode 兼容性和模型规范化
...
## 主要改动
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 的讨论
2026-01-12 20:18:53 -08:00
IanShaw027
f9713e8733
fix(codex): 添加codex CLI instructions fallback机制
...
## 问题
- 使用OpenAI API key时,opencode客户端可能因instructions不兼容而报错
- 依赖外部GitHub获取instructions,网络故障时会失败
## 解决方案
1. 将codex CLI标准instructions嵌入到项目中
2. 实现自动fallback机制:
- 优先使用opencode GitHub的instructions
- 失败时自动fallback到本地codex CLI instructions
3. 添加辅助函数用于错误检测和手动替换
## 改动
- 新增: internal/service/prompts/codex_cli_instructions.md
- 从codex项目复制的标准instructions
- 使用go:embed嵌入到二进制文件
- 修改: internal/service/openai_codex_transform.go
- 添加embed支持
- 增强getOpenCodeCodexHeader()的fallback逻辑
- 新增GetCodexCLIInstructions()公开函数
- 新增ReplaceWithCodexInstructions()用于手动替换
- 新增IsInstructionError()用于错误检测
## 优势
- 零停机:GitHub不可用时仍能正常工作
- 离线可用:不依赖外部网络
- 兼容性:使用标准codex CLI instructions
- 部署简单:instructions嵌入到二进制文件
2026-01-13 11:14:32 +08:00
yangjianbo
0e44829720
Merge branch 'main' into dev
2026-01-13 10:29:12 +08:00
shaw
93db889a10
fix: Gemini OpenCode 教程 baseURL 改为 v1beta
2026-01-13 09:52:37 +08:00
Wesley Liddick
0df7385c4e
Merge pull request #226 from xilu0/main
...
feat(gateway): 优化 Antigravity/Gemini 思考块处理 此提交解决了思考块 (thinking blocks) 在转发过程中的兼容性问题
2026-01-13 09:39:43 +08:00
Wesley Liddick
1a3fa6411c
Merge pull request #260 from IanShaw027/fix/sync-openai-gpt5-models
...
fix: 同步 OpenAI GPT-5 模型列表并完善参数处理
2026-01-13 09:31:00 +08:00
Wesley Liddick
64614756d1
Merge pull request #259 from cyhhao/main
...
fix: adjust OpenCode OpenAI example store placement
2026-01-13 09:30:26 +08:00
Wesley Liddick
bb1fd54d4d
Merge pull request #257 from Edric-Li/feat/ops-fullscreen-scrollbar
...
feat(ops): 添加运维监控全屏模式 & 优化滚动条
2026-01-13 09:29:25 +08:00
ianshaw
d85288a6c0
Revert "fix(gateway): 修复 base_url 包含 /chat/completions 时路径拼接错误"
...
This reverts commit 7fdc25df3c .
2026-01-12 13:29:04 -08:00
ianshaw
3402acb606
feat(gateway): 对所有请求(包括 Codex CLI)应用模型映射
...
- 移除 Codex CLI 的模型映射跳过逻辑
- 添加详细的模型映射日志,包含账号名称和请求类型
- 确保所有 OpenAI 请求都能正确应用账号配置的模型映射
2026-01-12 13:23:05 -08:00
ianshaw
7fdc25df3c
fix(gateway): 修复 base_url 包含 /chat/completions 时路径拼接错误
...
问题:
- 当账号的 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
2026-01-12 11:39:45 -08:00
ianshaw
ea699cbdc2
docs(frontend): 完善 OpenCode 配置说明
...
更新 API 密钥页面 OpenCode 配置提示信息:
- 补充支持 opencode.jsonc 后缀名
- 说明可使用默认 provider(openai/anthropic/google)或自定义 provider_id
- 说明 API Key 支持直接配置或通过 /connect 命令配置
- 保留"示例仅供参考,模型与选项可按需调整"的提示
配置文件路径:~/.config/opencode/opencode.json(或 opencode.jsonc)
2026-01-12 11:17:47 -08:00