shaw
fa1641f05f
fix: keep namespace verbatim on WSv2 forwards and check test type assertions
...
WSv2 egress relays upstream events verbatim without the HTTP-path
namespace restore, so flattening requests that take the WSv2 branch
would surface flattened tool names the client cannot match. Resolve
the WS transport decision before flattening and skip flattening only
when the request will actually go WSv2 (passthrough accounts return
via HTTP before the WSv2 branch and still flatten).
Also check all type assertions in responses_namespace_test.go to
satisfy golangci-lint errcheck.
2026-07-14 14:48:22 +08:00
shaw
252ef8b73a
Merge origin/main into codex/fix-native-responses-namespace
...
Resolve conflict in openai_gateway_passthrough.go streaming path: keep
main's normalizeCompletedImageGenerationStatus normalization ahead of
this branch's namespace restore block, mirroring the established order
in openai_gateway_response_handling.go.
2026-07-14 14:45:04 +08:00
shaw
d41a10111d
Merge remote-tracking branch 'origin/main' into feat/grok-sso-device-oauth
...
# Conflicts:
# frontend/src/api/admin/grok.ts
2026-07-14 10:19:16 +08:00
Wesley Liddick
93f2ccf3a5
Merge pull request #4188 from superman2003/fix/grok-free-quota-429-20260713
...
feat(grok): improve free quota probing and usage display
2026-07-14 10:14:41 +08:00
bestony and multica-agent
966afd1b4b
fix: preserve instrumented client contracts
...
Co-authored-by: multica-agent <github@multica.ai >
2026-07-14 01:29:30 +08:00
bestony and multica-agent
54d228dda5
feat(admin): add opt-in server timing metrics
...
Co-authored-by: multica-agent <github@multica.ai >
2026-07-14 01:29:30 +08:00
jinfeijie bot
ad4bf5c60d
feat(grok): 支持 Web SSO 批量导入并转换为 Build OAuth
...
新增 Grok Web SSO → xAI Device Flow → Grok Build OAuth 导入链路,
支持管理员批量粘贴 SSO key 创建 OAuth 账号。
- 后端:ConvertSSOToBuild、ConvertFromSSO、POST /admin/grok/sso-to-oauth
- 批量:3 worker 并发,失败跳过并汇总 created/failed,worker panic recover
- 无 refresh_token 时写入 expires_at 并强制 auto_pause_on_expired
- 前端:SSO Cookie 导入入口、动态超时、中英文案、部分成功不关弹窗
- 测试:pkg/service/handler/前端超时单测;本地 Docker 真实 SSO e2e 通过
2026-07-14 01:09:07 +08:00
superman2003
c896cacf6d
feat(grok): improve free quota probing and usage
2026-07-13 19:49:56 +08:00
Heatherm Huang
bc5d6ecb46
fix(grok): allow third-party API base URLs
2026-07-13 15:27:57 +08:00
shaw
8315defe8e
Merge branch 'main' into feat/grok-video-edit-extension
2026-07-13 14:50:18 +08:00
Wesley Liddick
d774948e09
Merge pull request #4082 from zuelu/agent/fix-codex-additional-tools-chat-bridge
...
fix(apicompat): 支持 Codex additional_tools 到 Chat Completions 桥接
2026-07-13 14:42:16 +08:00
xingzhi
317de9c04b
fix: support namespace tools in native responses
2026-07-13 14:38:05 +08:00
Wesley Liddick
fbc3f42a22
Merge pull request #4138 from fengshao1227/fix/read-tool-args-streaming
...
fix(apicompat): Read 工具参数实时流式发送,不再依赖 .done 事件
2026-07-13 14:14:08 +08:00
Wesley Liddick
98cc641008
Merge pull request #4134 from yan9651688/fix/usage-window-pagination-local-dates
...
fix: align usage windows, pagination offsets, and local dates
2026-07-13 14:13:34 +08:00
li
b6427d4ec0
fix(apicompat): 流式 Anthropic max_tokens 映射为 incomplete + content_filter 映射为 finish_reason
2026-07-13 12:08:32 +08:00
li
a5d40c9845
fix(apicompat): Read 工具参数实时流式发送,不再依赖 .done 事件
...
Fixes #4114
2026-07-13 11:47:18 +08:00
yan9651688
3605a316af
Keep usage ranges consistent across API and dashboards
...
Expose the active weekly subscription window through /v1/usage, calculate offsets with the same normalized page size used by queries, and keep user-facing date ranges on the browser's local calendar date.
Constraint: Preserve existing response fields and avoid new dependencies
Rejected: Keep duplicate inline date formatters | a shared local-date utility prevents the same UTC regression in both views
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep Offset and Limit based on the same normalized page size
Tested: go test ./internal/pkg/pagination ./internal/handler; go vet ./internal/pkg/pagination ./internal/handler; frontend 923 tests; pnpm typecheck; pnpm lint:check; pnpm build
Not-tested: Live API request against a deployed subscription
Related: #4121
2026-07-13 11:35:46 +08:00
chenjian
909b96edd2
feat: support Grok video edits and extensions
2026-07-13 10:50:42 +08:00
zuelu
ff5c216189
fix(apicompat): bridge Codex additional tools
2026-07-12 11:33:09 +08:00
jjaw
5015b7a1c1
修复 tool_search 参数对象反序列化
2026-07-12 04:53:34 +08:00
Wesley Liddick
e316ebf528
Merge pull request #3989 from xlplbo/fix/codex-mcp-tools-bridge
...
fix(apicompat): 补齐 Codex 0.14x 工具链经 chat 回退桥的转换(custom/tool_search/namespace)
2026-07-10 22:09:25 +08:00
xlplbo and Claude Fable 5
90e9d03dec
fix(apicompat): 强制选择 tool_search 的 tool_choice 降级为指向代理的 function 选择
...
tool_search 工具未被丢弃而是降级为同名 function 代理,此前 tool_choice 过滤
把它连同其他服务端工具类型一起静默丢弃,强制工具搜索被退化为自动选择,
违反调用方明确指定的工具选择语义。改为映射到指向代理的 function 选择;
未声明 type=tool_search 时无可指向的代理,维持丢弃。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01NWQyEgFKKbdve67G6qCoAU
2026-07-10 21:14:33 +08:00
xlplbo and Claude Fable 5
e2b68d1f90
fix(apicompat): tool_choice 仅转发实际存在于转换结果中的工具
...
此前只检查转换后是否还剩任意工具,不校验 tool_choice 指向的工具是否幸存:
强制选择被丢弃的服务端工具(如 web_search)或指向不存在名字时,选择项被
原样转发,chat 上游因 tool_choice 指向未声明工具而 400。改为具名选择项仅
在目标存在于转换后工具集时转发,服务端工具类选择项随工具本身丢弃;
"auto" 等字符串形式保持原样转发。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01NWQyEgFKKbdve67G6qCoAU
2026-07-10 21:06:45 +08:00
xlplbo and Claude Fable 5
a2cdaa6419
fix(apicompat): 内置 tool_search 与同名工具撞名时显式拒绝请求
...
tool_search 服务端工具降级后的代理 function 不能改名(codex 的模型侧按
tool_search 这个名字调用),与客户端声明的同名 function/custom 工具无法
区分:去程产生重复声明,回程会把普通工具的调用劫持还原成 tool_search_call。
与 namespace 摊平撞名的处理一致,在请求转换阶段显式报错(网关 400);
重复声明 type=tool_search 去重后只产出一个代理,不拒绝。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01NWQyEgFKKbdve67G6qCoAU
2026-07-10 21:06:26 +08:00
li
83f169e4fa
fix(apicompat): 补齐 Responses→Anthropic 流式路径的 cache_creation_input_tokens
2026-07-10 20:49:44 +08:00
xlplbo
eb4d005031
Merge remote-tracking branch 'upstream/main'
2026-07-10 20:46:38 +08:00
li
0d28f7f90d
fix(apicompat): Responses↔Anthropic 转换补齐 cache_creation_input_tokens
...
Fixes #3935
2026-07-10 20:40:45 +08:00
shaw
8a51119e39
fix(openai): pair originator with final User-Agent for codex upstream
...
上游 /backend-api/codex 的 404 gating 是配套校验:originator 必须与
User-Agent 首段(首个 '/' 前的 client 名)配套且为官方 codex 身份,
错配(如 originator=codex_cli_rs + UA=codex-tui/...)一律 404;version
头若携带须 >= 0.144.0。
修复:
- pkg/openai 新增 PairCodexClientIdentity:由最终出站 UA 推导配套
originator(含 CODEX_INTERNAL_ORIGINATOR_OVERRIDE 尾部括号组身份恢复、
精确集合大小写归一、长度/字符集校验)
- service 新增 enforceCodexIdentityHeaders 终态收口:originator 按最终
UA 重配,推导不出官方身份整体回退默认 Codex CLI 身份;version 低于
0.144.0 提升为内置版本;originator 缺失时 no-op(保护 messages bridge)
- 接入非透传/透传/WS 三条转发路径(透传与 WS 删除会把 codex-tui 等官方
UA 强改为 codex_cli_rs 造成错配的旧兜底)、用量探针(指纹缓存 UA 与硬
编码 originator 错配)、账号 responses/图像测试(opencode 错配)
- messages 兼容桥构建前显式打 bridge 标记,防止映射到非 gpt-5/codex
模型时收口误改其刻意最小化的请求形态
Fixes #3901
2026-07-10 19:11:26 +08:00
xlplbo and Claude Fable 5
f1082bb78f
fix(apicompat): namespace 摊平名撞名时显式拒绝请求
...
摊平名与顶层 function/custom 工具撞名、或跨 namespace 摊平出同名时,
chat 上游无法按 namespace 区分调用归属:此前重复声明照发上游、回程
固定命中其中一条映射,调用可能被还原到错误工具。这类请求在原生
Responses 上游合法,歧义由摊平转换制造且不可消除,改为在请求转换
阶段直接报错(网关返回 400 invalid_request_error 并点名冲突双方);
同一 (namespace, 子工具) 的重复声明去重后不拒绝。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01NWQyEgFKKbdve67G6qCoAU
2026-07-10 17:38:48 +08:00
xlplbo and Claude Fable 5
7942338328
fix(apicompat): 回程还原 namespace 子工具调用,修复 Codex MCP 工具 unsupported call
...
Codex 0.14x 将 MCP 工具声明为 namespace 工具,chat 桥去程摊平为
"<namespace>__<name>" function 工具后,回程仅原样回传平铺名的
function_call 项;codex 按 namespace+name 路由查不到该名字,所有
MCP 工具调用被判为 unsupported call。
- NamespaceToolNames 构建摊平名 →(namespace, 子工具名)反查表
(摊平名超长带截断哈希,无法按字符串切分还原)
- 非流式/流式回程命中映射时还原为裸子工具名 + namespace 字段,
ResponsesOutput 新增 Namespace 字段并同步 wire 层白名单
- 回退桥入口将映射与 CustomTools/ToolSearchDeclared 一并穿入
已在测试机经 codex exec + MCP server 端到端验证。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01NWQyEgFKKbdve67G6qCoAU
2026-07-10 17:38:17 +08:00
Wesley Liddick
5260a42a0b
Merge pull request #3953 from lyon-le/feat/openai-fast-policy-user-scope
...
feat(openai): 支持用户级 Fast/Flex 策略
2026-07-10 17:31:55 +08:00
Lyonle
f2966530c5
feat(openai): 支持用户级 Fast/Flex 策略
2026-07-10 15:16:09 +08:00
superman2003
de28eba3c8
fix(openai): harden GPT-5.6 billing and usage
2026-07-10 15:13:11 +08:00
Wesley Liddick
8b96acde97
Merge pull request #3898 from Arron196/feat/gpt-5.6-cache-billing-stats
...
feat(openai): 支持 GPT-5.6 系列缓存写入计费与统计
2026-07-10 13:57:29 +08:00
xlplbo and Claude Fable 5
18e26c127c
Merge remote-tracking branch 'upstream/main'
...
解决 backend/internal/service/openai_gateway_responses_chat_fallback.go 冲突:
将本地 tool_search/custom 工具改动(customTools/toolSearch 穿参与流状态标记)
移植到上游重构后的 CC 公共管线;同步适配上游新增调用点
openai_gateway_messages_chat_fallback.go 的 ChatCompletionsResponseToResponses 签名。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01F8zMzeFAumSddraEw1FUeG
2026-07-10 09:27:48 +08:00
benjamin
4a2b10c94e
feat(openai): support GPT-5.6 cache write billing
2026-07-10 09:08:58 +08:00
CHOS1N
ad8afc8a2e
Add parallel_tool_calls compatibility mapping
...
Preserve Chat Completions parallel_tool_calls when converting requests to the Responses API, and map Responses parallel_tool_calls back when falling back to Chat Completions upstreams.
Cover both true and explicit false values so clients can disable parallel tool calls without the field being dropped by omitempty.
2026-07-09 22:52:35 +08:00
Wesley Liddick
10102807e2
Merge pull request #3869 from Birditch/feat/admin-user-role-and-token-ranking
...
feat(admin): 用户角色管理 + 用户 Token 排行
2026-07-09 19:50:01 +08:00
Birditch and Claude Opus 4.8
b062b36646
feat(admin): 用量记录页新增"用户 Token 排行"面板
...
- 在 /admin/usage 新增按用户聚合的 Token 排行表(输入/输出/缓存/总 Token、请求数、费用)
- 支持按列排序、邮箱搜索、Top N (20/50/100/200),点击行下钻到该用户
- 复用现有筛选(用户/时间/模型/分组等)与既有 KPI 卡片、逐条日志
- 后端对 /admin/dashboard/user-breakdown 做加法扩展(向后兼容):
- UserBreakdownItem 增加 input_tokens/output_tokens/cache_tokens
- 新增 sort_by(白名单排序,防注入,缺省仍按 actual_cost)
- 新增 sort_by 转发单元测试;更新 UsageView.spec 稳定桩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-07-09 06:04:22 -04:00
Heatherm Huang
1a0a6ea9a8
fix: stabilize Grok quota probe model
2026-07-09 17:58:31 +08:00
Wesley Liddick
addcb34e14
Merge pull request #3851 from fengshao1227/fix/responses-to-anthropic-instructions-and-developer-role
...
fix(apicompat): ResponsesToAnthropicRequest 补全 instructions 字段并映射 developer role
2026-07-09 16:34:36 +08:00
Wesley Liddick
c842c3166c
Merge pull request #3847 from heathermhuang/codex/grok-45-official-support
...
Add official Grok 4.5 support
2026-07-09 16:07:42 +08:00
li
1785509873
fix(apicompat): ResponsesToAnthropicRequest 补全 instructions 字段并映射 developer role
...
Fixes #3850
2026-07-09 15:34:10 +08:00
Wesley Liddick
dfff28ab05
Merge pull request #3843 from InCerryGit/fix/issue-3540-lenient-json-limit
...
fix(gateway): cap lenient JSON normalization
2026-07-09 14:39:55 +08:00
Heatherm Huang
cccba9a82e
Add official Grok 4.5 support
2026-07-09 14:26:10 +08:00
InCerry
53a5c45bd8
fix(gateway): cap lenient json normalization
...
Fixes #3540
2026-07-09 11:15:52 +08:00
CHOS1N
2fd3539527
Merge remote-tracking branch 'upstream/main' into codex/add-response-format-compat
2026-07-07 20:05:50 +08:00
xlplbo
27e29f0562
feat(apicompat): 添加 tool_search 支持,增强工具调用处理逻辑
2026-07-07 19:19:35 +08:00
xlplbo
75fb3c41c2
fix(apicompat): responses→chat 桥支持 custom 工具,修复 Codex exec 丢失
...
Codex 0.14x 的核心执行工具 exec 是 type=custom(freeform)工具,
responsesToolsToChatTools 丢弃所有非 function 工具,导致模型工具列表中
没有 exec、无法执行任何命令;SSE 序列化层 responsesItemWire 也缺少
custom_tool_call 分支,即使产出该类型 item,call_id/name/input 也会被
白名单剥离。
- custom 工具降级为单一 input:string 参数的 function 工具
- 回程(非流式+流式)按名字还原 custom_tool_call 项/事件
- 历史 custom_tool_call / custom_tool_call_output 项转换(此前被跳过)
- responsesItemWire 补 custom_tool_call 分支
- tools 全部被丢弃时不再转发 tool_choice(修复上游 400
"'tool_choice' is only allowed when 'tools' are specified")
feat(apicompat): chat 桥补齐 tool_search/namespace/字符串工具声明
对齐参考实现(cc-switch transform_codex_chat.rs)的工具类型覆盖:
- tool_search → 固定 function 代理工具(query 必填/limit 可选),
历史项 tool_search_call/tool_search_output 一并转换
- namespace → 子 function 工具摊平为 <namespace>__<name>,
超 64 字符截断加 sha256 短哈希;历史项带 namespace 字段时同规则摊平
- tools: ["name"] 字符串简写按 custom 工具解析
fix(apicompat): 工具调用宣告延迟到类型可判定,兼容 name 迟到的上游
output_item.added 的 custom/function 判定依赖工具名。名字晚于首个分片
到达时,此前会按 function_call 宣告造成 added/done 项类型不一致。
改为存在 custom 工具且名字未到时延迟宣告,宣告时补发已累积的参数增量;
请求无 custom 工具时行为不变。
PR 标题与正文(可直接粘贴)
标题:fix(apicompat): responses→chat 桥丢弃 custom 工具导致 Codex 无法执行命令
正文:
## 问题
OpenAI APIKey 账号接入仅支持 /v1/chat/completions 的第三方上游
(DeepSeek/GLM/Kimi 等)时,Codex 0.14x 客户端文本对话正常,但无法执行
任何命令:exec 调用全部 "aborted",spawn_agent 派出的子智能体永远卡在
running,多轮后模型自述"环境无法执行文件系统命令"放弃。
## 根因
Codex 0.14x 的核心执行工具 exec 是 Responses API 的 custom(freeform)
工具,而非普通 function:
{"type": "custom", "name": "exec", "format": {"type": "grammar", ...}}
两处缺陷叠加:
1. `responsesToolsToChatTools` 丢弃所有非 function 工具
(chatcompletions_responses_bridge.go),模型工具列表中从未出现 exec;
2. SSE 序列化 `responsesItemWire` 按 item 类型白名单重组字段,无
custom_tool_call 分支,call_id/name/input 会被剥离
(responses_stream_event_wire.go)。
次生缺陷:工具全部被丢弃时 tool_choice 仍被转发,部分上游报 400
"'tool_choice' is only allowed when 'tools' are specified"。
## 改动
(三个提交的要点清单,见各提交说明)
设计与 cc-switch 的 Codex chat 转换层(transform_codex_chat.rs /
streaming_codex_chat.rs)对齐:custom 工具降级为 {"input": string}
function 工具;custom 调用的参数增量不可流式还原为自由文本,缓冲至
收尾一次性下发 custom_tool_call_input.delta/done。
## 测试
- 新增 17 个单元测试:请求工具转换、tool_choice 兜底、历史项转换、
非流式/流式回程还原、wire 序列化字段完整性、name 迟到宣告、命名摊平
- `go test ./internal/pkg/apicompat/...` 与 service 相关测试全绿
- 真机验证:Codex CLI 0.142.5 → 本桥 → GLM/DeepSeek 系 chat-only 上游,
exec 实际执行命令并多轮续作正常
## 影响面
仅影响 "APIKey 账号 + 判定不支持 Responses" 的 chat 直转路径:
- OAuth 账号与透传路径不经过本桥(透传为字节级原文转发)
- CC→Responses 反方向仅构造 ResponsesRequest,新增字段带 omitempty
且不赋值,序列化输出不变
- 探测逻辑未动,路由判定不变
- 共享类型改动均为增量容错(新字段 omitempty;UnmarshalJSON 只新增
字符串工具的解析成功路径)
2026-07-07 16:23:44 +08:00
Heatherm Huang
c34db70a88
fix: bridge grok composer image inputs
2026-07-07 10:55:07 +08:00