superman2003
fc66a30ffc
fix: harden billing concurrency and payment recovery
2026-07-10 10:56:49 +08:00
github-actions[bot]
12d811bd76
chore: sync VERSION to 0.1.149 [skip ci]
2026-07-09 14:57:53 +00:00
Wesley Liddick
dd1a116f48
Merge pull request #3881 from Wei-Shaw/feat/version-rollback
...
feat: 版本徽章新增近3个历史版本在线回退与手动回退指引
v0.1.149
2026-07-09 22:39:41 +08:00
Wesley Liddick
2e61914c48
Merge pull request #3880 from Wei-Shaw/fix/compact-body-signal-sse-bridge
...
fix(compact): body-signal 客户端流式请求的响应合成回 SSE(修复 #3875)
2026-07-09 22:39:31 +08:00
shaw
92b283d9eb
fix: 修复 SSE 桥接 appendEvent 中 errcheck 告警
2026-07-09 22:34:13 +08:00
shaw
1c2e6503c6
feat: 版本徽章新增近3个历史版本在线回退与手动回退指引
...
后端:
- UpdateService 新增 ListRollbackVersions/RollbackToVersion,回退目标强制
限定为比当前版本更旧的近3个正式版本(排除当前/更新/预发布/草稿),
越界返回 400 ROLLBACK_VERSION_NOT_ALLOWED;下载复用既有 HTTPS 域名
白名单 + checksum 校验 + 原子换二进制管线
- GitHubReleaseClient 新增 FetchRecentReleases(releases 列表 API)
- 新增 GET /admin/system/rollback-versions;POST /admin/system/rollback
支持可选 {"version"} body,无 body 保持原 .backup 本地回退行为不变
- 端点均在 /admin 组 adminAuth(IsAdmin+TokenVersion)保护内
前端:
- VersionBadge「已是最新版本」状态下新增版本回退面板:radio 卡片选择
近3个版本,手动回退方式按部署形态 tab 切换(脚本部署 curl 命令 /
Docker 镜像 tag 指引),支持一键复制;release 构建提供一键回退并
复用重启流程;源码构建仅提示不支持在线回退
- 下拉根元素重置 whitespace-normal,修复 sidebar-brand 的
white-space:nowrap 继承导致的长文本溢出裁切
测试:服务层过滤/排序/上限/非法目标拒绝、handler 双模式与鉴权错误映射、
GitHub client 列表拉取、前端 API 请求体行为共 16 个新增用例
2026-07-09 22:30:04 +08:00
shaw
16c0613b21
fix(compact): body-signal 客户端流式请求的响应合成回 SSE
...
v0.1.147 的 body-signal 提升(#3804)把 Codex remote compact v2 的流式
/responses 请求改写为上游 unary /responses/compact(JSON),但把 JSON
文档原样写回给了按 Responses SSE 协议消费的客户端。Codex 只从
response.output_item.done 收集 item 且必须收到 response.completed,
收到 JSON 后报 "stream disconnected before completion: stream closed
before response.completed" 无限重连,每次重连再白烧一次上游 compact
配额(#3875,v0.1.146 无提升逻辑故正常)。
修复保留提升的全部收益(requireCompact 调度过滤、compact 模型映射、
白名单归一化、上游 unary JSON),补上协议转换缺失的响应半程:
- handler 在 body-signal 提升时记录原始 body 的 stream:true 意图
(MarkOpenAICompactClientStream);path-based 请求不标记,Codex v1
unary 协议与链式 sub2api 的 JSON 写回行为保持不变。
- 四个非流式写回点(handleNonStreamingResponse / handleSSEToJSON /
handleNonStreamingResponsePassthrough / handlePassthroughSSEToJSON)
对已标记的 2xx JSON 响应经 writeOpenAICompactSSEBridge 合成最小
Responses SSE:每个 output[] item 一条 response.output_item.done
(原始字段逐字节保留),最后一条 response.completed 携带完整
response 对象。
- 按 codex-rs 解析器硬约束兜底:先 json.Compact 防 pretty JSON 换行
破坏 SSE 帧;response.id 缺失时注入 resp_*(必填 string);usage
缺 input_tokens/output_tokens/total_tokens 整数字段时整体删除,
避免整条 completed 事件解析失败。
- 非 2xx 一律保持 JSON 原样,Codex 依赖 HTTP 状态码走重试链路。
新增 9 个 service 测试 + 4 个 handler 测试覆盖合成形态、id/usage 兜底、
path-based 不受影响、主链路/透传链路/上游 SSE 提取再合成三条端到端。
Fixes #3875
Refs #3777
2026-07-09 21:40:51 +08:00
shaw
1a3cc2a787
refactor: 重新设计用量页布局并新增延迟健康列
...
- /admin/usage 明细区收进单卡片:三个下划线 tab(用量明细/错误请求/用户排行) + 自适应筛选栏 + 内容
- 用户 Token 排行收编为第三个 tab:去掉独立邮箱搜索,懒挂载,点击行下钻回用量明细并回显用户
- 首Token/耗时合并为延迟列(首字/总耗时):阈值 10s/30s/60s 与 1min/3min/5min 四档配色,色条上下两段短渐变过渡(from-40% to-60%),管理端与用户端 /usage 共用
- 时长格式 ≥1min 简化为 Xm Ys、≥1h 为 Xh Ym
- UsageFilters/UsageTable/OpsErrorLogTable 增加 flat 嵌入模式(默认关闭不影响其他使用方)
2026-07-09 21:09:40 +08:00
Wesley Liddick
e2c731abe4
Merge pull request #3873 from Wei-Shaw/fix/post-merge-audit-followups
...
fix: 落实 #3867-#3870 合并审计的全部跟进项
2026-07-09 20:13:21 +08:00
shaw
7918b1a9c5
fix: 落实 #3867-#3870 合并审计的全部跟进项
...
透传规则(跟进 #3868/#3870,refs #3857):
- CC/Messages 4 条协议转换路径改用共享 helper,走语义状态推断 +
body 归一化,使按错误码配置的透传规则也能命中(原先传 0 恒不命中)
- helper 增加 platform 参数:本服务同时承载 openai/grok 平台账号,
规则须按 account.Platform 匹配,消除硬编码平台错配
- /v1/responses 两条路径命中透传规则时补记 ops 上游错误事件,
对齐 CC/Messages 与 antigravity 先例,消除监控盲区
用户角色管理(跟进 #3869):
- 补齐 EN 语言包缺失的 admin.users.form.roleLabel
- 新增"最后一个管理员不可降级"守卫,覆盖跨管理员互降致零 admin 锁死
- 角色变更/创建管理员落审计日志(含操作者 actor_admin_id)
2026-07-09 20:06:09 +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
Wesley Liddick
751cf5eea3
Merge pull request #3870 from fengshao1227/fix/response-failed-passthrough-rules
...
fix(gateway): CC/Messages 路径 SSE response.failed 应用错误透传规则
2026-07-09 19:49:32 +08:00
Wesley Liddick
a8505877ff
Merge pull request #3868 from wucm667/fix/openai-sse-response-failed-error-passthrough
...
fix: OpenAI SSE response.failed 应用错误透传规则
2026-07-09 19:49:04 +08:00
Wesley Liddick
f3380dbd62
Merge pull request #3867 from heathermhuang/codex/postmerge-grok-issues-3848-3861
...
fix: Grok OAuth, image, usage, and quota handling
2026-07-09 19:48:32 +08:00
shaw
feef0bc0b1
chore: update sponsors
2026-07-09 19:08:00 +08:00
github-actions[bot]
0ee51b45f8
chore: sync VERSION to 0.1.147 [skip ci]
2026-07-09 10:10:28 +00:00
li
8f97953e51
fix(gateway): SSE response.failed 应用错误透传规则,不再硬编码 502
...
Fixes #3857
2026-07-09 18:09:37 +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
Birditch and Claude Opus 4.8
64fdc11ec4
feat(admin): 用户创建/编辑支持选择与修改角色 (user/admin)
...
- 创建用户时可指定角色,缺省仍为 user,不再硬编码为普通用户
- 编辑用户时可在 user/admin 之间切换角色
- 后端对角色做 admin/user 合法性校验
- 防锁死保护:管理员不能把自己降级为普通用户(与既有"不能禁用/删除 admin"保护一致;降级其他管理员仍允许)
- 前端创建/编辑弹窗新增角色下拉,复用既有 i18n 文案
- 新增角色创建/更新/非法值/防降级单元测试
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-07-09 06:04:06 -04:00
wucm667
1da3501af5
fix: apply error passthrough to OpenAI response.failed streams
2026-07-09 17:59:38 +08:00
Heatherm Huang
1a0a6ea9a8
fix: stabilize Grok quota probe model
2026-07-09 17:58:31 +08:00
Heatherm Huang
b480545c19
fix: improve Grok OAuth, image, and usage flows
2026-07-09 17:54:08 +08:00
Wesley Liddick
ba1f130d28
Merge pull request #3864 from fengshao1227/fix/frontend-i18n-and-site-logo-sanitize
...
fix(frontend): 补齐 en 语言包缺失 key 并对 site_logo 统一应用 sanitizeUrl
v0.1.147
2026-07-09 17:35:00 +08:00
Wesley Liddick
668c79ea86
Merge pull request #3824 from bestony/worktree/brave-valley-9578
...
feat(keys): sort by current concurrency
2026-07-09 17:25:40 +08:00
li
15c59be787
fix(frontend): 补齐 en 语言包缺失 key 并对 site_logo 统一应用 sanitizeUrl
2026-07-09 17:22:04 +08:00
shaw
49fb18e073
Merge origin/main into worktree/brave-valley-9578
...
Resolve conflict in api_key_repo.go: keep both ListAllByUserID (this PR)
and attachLastUsedIPs/latestUsageLogIPs (main), and have ListAllByUserID
attach last-used IPs so the current_concurrency sort path keeps the
last_used_ip column populated.
2026-07-09 17:17:16 +08:00
Wesley Liddick
14f7a7e603
Merge pull request #3859 from fengshao1227/fix/messages-response-failed-handling
...
fix(messages): /v1/messages 非 cyber response.failed 补全 failover 和错误回写
2026-07-09 17:09:27 +08:00
li
104fd2b6ec
fix(messages): /v1/messages 非 cyber response.failed 补全 failover 和错误回写
2026-07-09 16:49:13 +08:00
Wesley Liddick
0438057c0b
Merge pull request #3816 from Vibeone/fix/ops-inband-sse-error-logging
...
fix(ops): 记录固化 200 SSE 流上的就地错误,修复流内限流不进错误看板
2026-07-09 16:35:29 +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
843dcddea3
Merge pull request #3853 from fengshao1227/fix/messages-transport-failover
...
fix(messages): /v1/messages 传输层错误对齐 failover 链路
2026-07-09 16:34:00 +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
Wesley Liddick
c3df469377
Merge pull request #3855 from Wei-Shaw/fix/grok-video-per-second-billing
...
fix: bill Grok video per second and harden video usage logging
2026-07-09 16:07:23 +08:00
Heatherm Huang
243678e166
Fix Grok 4.5 alias test expectations
2026-07-09 15:50:58 +08:00
li
7468427e44
fix(messages): /v1/messages 传输层错误对齐 failover 链路,不再直接 502
...
Fixes #3850 (part 2)
2026-07-09 15:49:10 +08:00
shaw
d4952154ff
fix: bill Grok video per second and harden video usage logging
...
Follow-up fixes for the #3775 audit findings:
- Bill Grok video generation per second of output, matching the xAI rate
card: parse the request duration (1-15s, upstream default 8s) and compute
cost as per-second price x duration x count. The built-in rate card values
were already xAI per-second prices but were previously charged per video,
undercharging up to 15x with a user-controlled duration.
- Group video_price_* fields are now documented and surfaced as per-second
rates (USD/s); admin UI labels, placeholders and hints updated accordingly.
- Persist video_count/video_resolution/video_duration_seconds on usage_logs
(migration 172) so video billing is auditable, and exempt any row with
video_count > 0 from the image_size check constraint: a video billed via a
token-mode channel price produces billing_mode='token' with image_count=1
and no image_size, which the previous constraint rejected, dropping the
whole billing transaction.
- Only refetch the group in apiKeyWithFreshGroupMediaPricing when the group
object actually looks like it is missing media pricing fields (both media
multipliers zero and all prices nil, impossible for a normally loaded
group), removing a per-usage DB query for groups without overrides.
- Frontend: drop the unused admin.groups.mediaPricing locale block, map
cleared price inputs to null (create) / -1 (update, cleared via backend
normalizePrice) instead of sending "" that failed *float64 unmarshalling,
and align video price placeholders with the text-to-video default model
(grok-imagine-video 0.05/0.07, 1080p only on 1.5 at 0.25).
2026-07-09 15:38:59 +08:00
li
1785509873
fix(apicompat): ResponsesToAnthropicRequest 补全 instructions 字段并映射 developer role
...
Fixes #3850
2026-07-09 15:34:10 +08:00
Wesley Liddick
9ba0fb3084
Merge pull request #3775 from heathermhuang/codex/grok-media-pricing-labels
...
fix: add Grok video pricing controls
2026-07-09 15:03:38 +08:00
Wesley Liddick
b6d2df24d8
Merge pull request #3800 from Ge-limin/feat/codex-models-manifest
...
feat: Codex 客户端模型清单(manifest)透传接口
2026-07-09 14:40:23 +08:00
Wesley Liddick
52da41fd6e
Merge pull request #3809 from hongheshan-svg/fix/upstream-anthropic-429-fallback
...
fix(ratelimit): Anthropic 无 reset 头的 429 也进入兜底冷却,避免账号永不冷却导致的 429 循环
2026-07-09 14:40: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
Wesley Liddick
e2c662e965
Merge pull request #3840 from feitianbubu/fix/crs-sync-frontend-timeout
...
fix(crs-sync): raise frontend sync timeout to 180s
2026-07-09 14:39:39 +08:00
Wesley Liddick
9392d1fc43
Merge pull request #3841 from fengshao1227/fix/html-escape-site-name-and-sanitize-doc-url
...
fix(security): HTML-escape site_name 并对 doc_url 统一应用 sanitizeUrl
2026-07-09 14:39:26 +08:00
Wesley Liddick
9ba6f3c2b0
Merge pull request #3845 from wucm667/feat/groups-quota-used-display
...
feat: 配额操控列表显示已用额度
2026-07-09 14:39:12 +08:00
Wesley Liddick
a57157b9fa
Merge pull request #3822 from wucm667/feat/api-key-last-used-ip
...
feat(api-key): 展示 API Key 最近使用 IP
2026-07-09 14:38:01 +08:00
Wesley Liddick
0118fa3ce2
Merge pull request #3721 from CHOS1N11111/codex/add-response-format-compat
...
Add response_format compatibility mapping
2026-07-09 14:37:46 +08:00
Wesley Liddick
105ac31c37
Merge pull request #3781 from fengshao1227/fix/openai-oauth-empty-mapping-model-guard
...
fix(scheduler): 空 model_mapping 的 OpenAI OAuth 账号不再吸收全部模型
2026-07-09 14:37:33 +08:00
Wesley Liddick
7302be4d13
Merge pull request #3833 from superman2003/fix/security-and-frontend-hardening
...
fix(gateway,frontend): 修复 Gemini 鉴权绕过与前端支付/会话缺陷
2026-07-09 14:37:19 +08:00
Wesley Liddick
636c452535
Merge pull request #3836 from ShuYeJang/main
...
fix(billing): 渠道定价覆盖写穿 fallbackPrices 共享指针导致全局计费污染
2026-07-09 14:37:05 +08:00
Heatherm Huang
cccba9a82e
Add official Grok 4.5 support
2026-07-09 14:26:10 +08:00