shaw
40ea3aebad
feat: add OAuth outbound transport plugin system
2026-08-24 09:03:37 +08:00
Wesley Liddick
219368ec6d
Merge pull request #5654 from zninggo/fix/composite-video-generation
...
fix(gateway): Composite 分组放行视频生成端点
2026-08-21 21:27:17 +08:00
Wesley Liddick
7d9c958482
Merge pull request #5810 from Pluviobyte/codex/fix-responses-input-tokens
...
fix(codex): handle Responses input token preflight
2026-08-19 14:43:33 +08:00
Kingsley
58e147fba6
feat(composite): support Codex endpoints
2026-08-19 04:40:32 +00:00
Rain
bfac49fef9
fix(codex): handle responses input token preflight
2026-08-19 11:34:18 +08:00
Randark
901a0439f1
feat: 国产供应商一等支持(Kimi/Zhipu/DeepSeek 多协议 + 配额/余额监控)
...
后端:
- 协议凭证维度 credentials[api_protocol] ∈ chat_completions(默认)/anthropic/responses(deepseek)
- /v1/messages 零转换直通原生 Anthropic 端点(kimi/zhipu/deepseek),CC/Responses
入站交叉组合走 apicompat 双向转换链(responses/chat_completions anthropic-native 转发器)
- count_tokens:anthropic 协议透传原生端点;其余 CN 协议本地 tiktoken 估算
- Coding Plan 额度探测(5h/weekly 滚动窗口)+ payg 余额探测(kimi/deepseek),
deepseek 双币种 CNY+USD 明细,任一币种达标不停调
- 周期任务 [CNBalance] 并发探测 + 预算随工作量放大;响应式 429 冷却到最早窗口
重置点;余额不足可恢复临时停调;智谱 CREDIT_LIMIT 不污染窗口解析
- CC→anthropic 流式客户端断开后继续排水上游保住 usage 计量
前端:
- 创建/编辑弹窗 account_mode + api_protocol + base_url 联动预设(含 watcher 竞态防护)
- 用量单元格:kimi/zhipu coding 显示 5h/weekly 窗口,kimi/deepseek payg 显示余额,
多币种并列展示;探测失败保留快照;挂载自动探测 5min 去抖
- 调度阈值设置面板补 kimi/zhipu 平台(对齐后端 AllowedSchedulingThresholdPlatforms)
2026-08-15 10:37:51 +00:00
zninggo
1e1798d90d
fix(gateway): Composite 分组放行视频生成端点
...
视频状态(/videos/:id)与内容下载(/videos/:id/content)都已放行
PlatformComposite, 唯独创建端点仅放行 PlatformGrok. Composite 分组
用户配好模型路由后可查询可下载, 唯独创建 404.
补齐放行判断, 与另外两个视频端点保持一致; 其他平台行为不变.
2026-08-15 01:20:26 +08:00
IanShaw027
0de6d7e9ba
feat: 新增独立 /x_search,走原生 x_search 并沿用搜索计费
...
Grok 分组原先只有 /web_search,无法带 handle/日期过滤,也无法走
xAI 的 x_search tool。
- POST /x_search(仅 Grok 分组),复用 web_search 的审计、failover 与按次计费
- 上游 Responses 强制 x_search;计费模型记为 grok-x-search
2026-08-13 07:49:19 +08:00
shaw
d92edc01be
Merge origin/main into feat/channel-monitor-v2-ops-ui
...
Resolves three conflicts, all of the "both branches appended to the same
block" shape. Every one is resolved as a union of both sides; nothing from
either parent is dropped.
- handler/admin/setting_handler_update.go: keep ChannelMonitorHideThroughput
(V2) alongside GrokDefaultTextModel / GrokCrossClientModelMapEnabled /
GrokDefaultBaseURLMode (#5408 ). UpdateSettings writes every key on each
save, so dropping either side would reset those settings to zero values.
- service/domain_constants.go: keep SettingKeyChannelMonitorHideThroughput
and the three SettingKeyGrok* constants.
- repository/migrations_runner.go: keep the 195 checksum rule (V2) and the
218/219/220 rules (#5408 ).
2026-08-09 12:11:35 +08:00
IanShaw027
a54a4b674b
fix(grok): clear golangci errcheck and gofmt on free-quota path
...
Check the sync.Map type assertion in free-quota refresh coalescing, and
gofmt migration checksum rules plus prompt-audit route map alignment.
2026-08-08 22:52:31 +08:00
IanShaw027
7eb1310701
fix(grok): close free-by-default billing and related review blockers
...
H1/H2: bill search and voice with code defaults when group prices are
nil (explicit 0 remains free); bump API key auth snapshot to v19 and
refresh incomplete media/search/audio projections.
M1–M6: free-quota soft gate fails open on cache miss with background
refresh and 60s default TTL; correct password_auth config docs; default
cross-client model map to true (→ grok-4.5); audit /tts and /web_search;
exclude composite from migration 220 video-price clears; never let a
search surcharge mask token pricing failures.
2026-08-08 14:39:22 +08:00
IanShaw027
07b46e93e4
fix(grok): 修正 voice 路由推导、视频价归一化与门禁缓存驻留
...
- custom-voices endpoint 改由匹配到的路由模板推导(c.FullPath())。
原实现按请求 URL 字面后缀判 /audio,voice_id 恰为 "audio" 时
GET /custom-voices/audio 会被改写成 custom-voices/audio/audio,
把档案查询变成音频下载。补 voice_id="audio" 的路由推导测试。
- NormalizeVideoModelPrices 不再把无法识别的分辨率静默折算成 480p:
新增 LookupVideoBillingResolution 报告未知档位,配置解析路径丢弃并告警,
运行时计费仍走 OrDefault 兜底。model/tier 两层遍历改为排序遍历,
多个别名收敛到同一 family 时结果不再随 Go map 顺序漂移,冲突单价告警。
- grok free quota 软门禁缓存新增过期淘汰。条目按 account_id 键控且只写不删,
账号下线后会驻留至进程结束;淘汰只挂在已受 TTL 约束的查询路径上,
不影响缓存命中热路径。
- 迁移 220 清空非 Grok 分组视频价前先落快照表 groups_video_price_backup_220,
原 UPDATE 不可回滚。
- 简化 grok_search_count 两处等价冗余的事件类型分支。
2026-08-08 11:02:22 +08:00
IanShaw027
35faaa6d21
feat(grok): register custom-voices CRUD and audio download gateway routes
...
Forward list/get/patch/delete and reference-audio paths with safe path segment
encoding, method passthrough, and empty-body GET/DELETE handling.
2026-08-08 08:48:38 +08:00
IanShaw027
165b072908
fix(grok): gateway media/voice routing, models, and status UI polish
...
Align gateway Grok media/voice paths and model lists, harden upstream failure
and quota handling, clear non-Grok video generation config migration, and polish
temp-unsched/status indicators with model whitelist updates.
2026-08-08 01:07:27 +08:00
IanShaw027
61b975b5dd
test(grok): 对齐跨客户端映射与路由审计契约
2026-08-07 16:45:25 +08:00
IanShaw027
79df1647d4
feat(grok): 账单绝对金额、调度阈值 UI、搜索/Voice 计费与 /v1/web_search
...
- BillingSummary 输出 prepaid/monthly_used/on_demand 绝对金额,并映射官方 7d/30d 进度条
- 账号编辑页支持 credentials.account_scheduling_threshold 覆盖;Settings 文案细化
- groups.search_price_per_1k + 管理端/缓存全链路;SearchCount/AudioUsage 请求级计费
- Voice TTS/STT/Realtime 成功路径 RecordUsage;独立 /v1/web_search 原生 Grok 搜索
2026-08-07 15:52:55 +08:00
IanShaw027
99ad01f6de
feat(grok): 网关 Voice TTS/STT/Realtime 与分组音频定价
...
- 中继 xAI Voice HTTP(/tts /stt /custom-voices)与 Realtime WS(/realtime)
仅 Grok 分组可用;账号选调度沿用 chat 能力,不依赖创作中心
- Voice URL 固定走 api.x.ai(CLI proxy base 自动回落)
- 分组级 audio_realtime / TTS / STT 单价:schema + migration 218 +
admin API + GroupsView 表单与 i18n(无创作中心 UI)
2026-08-07 15:08:39 +08:00
IanShaw027
7c62382d04
feat(grok): 吸收调度阈值、配额解析、批量用量与 CLI 身份
...
从 personal-dev 取优并接线到 feat/grok-complete-integration:
- 调度阈值:grok_sched_* 写入、ApplyAccountSchedulingThreshold、
account_scheduling_thresholds 设置与 Settings UI、网关过滤
- 配额头:x-rate-limit 别名、相对秒 reset、tier/entitlement 扩展
- 批量 usage:GetUsageBatch + POST /usage/batch + AccountsView 合并加载
- CLI 身份:xai.cli_identity 统一 pin/UA;service 层 applyGrokCLIHeaders
与 transport 最终改写对齐;media eligibility 模块落地
- UsageCell:月度 cents→USD 与 30d 进度条展示
保留既有 failure taxonomy / sticky / free recovery 等 HEAD cools。
2026-08-07 14:53:18 +08:00
IanShaw027
d0930c4bdb
fix(grok): 完善密码与SSO授权能力控制
2026-08-07 14:13:07 +08:00
IanShaw027
370bdcf695
feat(grok): 补齐密码登录与 SSO 校验,统一 OAuth 凭证形态
...
在 main 既有 SSO→Build 批量导入之上增加 sso-token 校验与账号密码授权。
密码仅用于换取 SSO 再转 Build OAuth,明文与 raw SSO 均不落库。
2026-08-07 12:38:49 +08:00
IanShaw027
4245cb41f4
fix(channel-monitor-v2): 修复 CI golangci-lint 与 admin settings 契约测试
...
处理 rows.Close errcheck、gofmt、空 recover 分支 staticcheck,并同步
GET /api/v1/admin/settings 契约期望中的 mode 与 hide_throughput 字段。
2026-08-07 11:21:13 +08:00
IanShaw027
a5beecb92a
feat(channel-monitor-v2): 接入模式开关、路由门控与依赖注入
...
注册 admin/user 路由与 feature/mode 守卫,串联 Wire DI 与设置读写,
公开 channel_monitor_mode 与 hide_throughput 等运行时标志。
2026-08-07 11:05:32 +08:00
lyen1688
e592c5f9e0
新增腾讯天御验证码认证门禁
2026-08-04 15:09:29 +08:00
shaw
54a2bcfd15
fix(openai): harden reset-credit refresh and account recovery
...
Review follow-ups on the reset-credit caching flow:
- Recover account state BEFORE (and independently of) the reset-credit
display cache. A failed cache refresh could previously abort the run and
leave the account rate-limited — the very reason the credit was spent
(#3672 / #3740 ). The recovered account row is now returned even when the
cache refresh fails.
- Run the post-reset bookkeeping on a detached, time-boxed context and give
the panel reset call a larger timeout. A client abort no longer strands a
consumed (non-refundable) credit with an unrecovered account, and the
chained upstream calls can no longer exceed the client timeout and invite a
retry that spends a second credit.
- Persist the reset-credit snapshot through POST /accounts/:id/quota/refresh
instead of a side-effecting GET flag, so the write is covered by the audit
middleware. A rejected snapshot write now degrades to cache_persisted=false
instead of turning a successful upstream read into a 502 that left the card
without a credit count and the reset button permanently disabled.
- Reject snapshots whose positive count carries no expiration entries, and
drop expired credits (clamping the count) when rehydrating, so a stale
cache can no longer light up the reset button.
- Keep nil quota / rate-limit services nil in the handler's interface fields;
storing a nil *Service made the "not enabled" guards non-nil.
- Time-box the usage-refresh suppression and reuse handleAccountUpdated so the
patched row also enters the auto-refresh silent window.
2026-08-03 14:40:55 +08:00
Wesley Liddick
d9fba8fe78
Merge pull request #5101 from Tongzai123/feat/admin-select-all-filtered-results
...
feat(admin): 支持按筛选结果全选账号
2026-08-01 08:54:38 +08:00
shaw
017f6bbd5e
fix(gateway): 收紧上游 URL 路径片段校验
...
网关有若干位置会把客户端可控的字符串拼进上游请求的 URL path(Responses
子路径、Gemini 模型名)。此前这些字符串未经校验直接参与拼接,可能改变上游
请求的路径结构,使实际发出的请求与客户端意图不一致。
- 新增 internal/service/upstream_path_guard.go:路径片段闭集允许清单
(\w + `-` + `.`),拒绝空片段、纯点片段、超长片段与过深后缀
- /responses/*subpath 三条路由入口新增守卫,不可转发的子路径直接 404;
service 层同时保证不产出不合规后缀,拼接函数再兜底一层
- Gemini AI Studio 原先 5 处重复的 URL 拼接收敛为唯一构造点
buildGeminiAIStudioModelActionURL(校验模型片段 + action 白名单)
- Gemini native / GetModel handler 增加入口校验;ForwardAIStudioGET 逐片段校验
- Grok video 端点的 request_id 增加片段合规校验
合法子路径(/compact、/compact/detail、/{id}/cancel 形态)与既有模型名行为
不变,通配路由保留。
2026-07-31 16:11:45 +08:00
Litong
a35ff9613e
feat(admin): 为账号批量删除增加并发限制
2026-07-30 18:03:54 +08:00
feeeei
720c405e35
feat: add model plaza with group-scoped pricing showcase
...
- public /model-plaza page (standalone + admin-embedded) listing groups
with discounted effective prices alongside LiteLLM official reference
- faceted platform/group/rate filters: cross-dimension options gray out
instead of disappearing, platform-tinted chips via accent color-mix
- paid-price columns highlighted with per-platform tint band
- OptionalJWT middleware so anonymous and signed-in users share one route
- admin settings: enable switch, require-auth switch, markdown description
2026-07-28 16:19:41 +08:00
Wesley Liddick
2e432173f7
Merge pull request #4920 from alexj11324/feat/passkey-auth
...
feat: add passkey authentication
2026-07-28 14:58:37 +08:00
shaw
fead4c7ec3
feat(security): add panel API rate limiting to protect DB from high-frequency requests
...
用户可高频刷面板接口(usage/dashboard 等重聚合查询)直接打爆数据库:
现有限流器只覆盖登录/注册等公开认证入口,登录后的全部面板端点无任何限流。
三层防护(阈值均可在后台可视化配置,panel_rate_limit_settings):
1. 认证面板接口按「用户 ID」限流,与来源 IP 无关——反向代理/NAT 共享出口
(所有请求源地址坍缩为 127.0.0.1 等)不会互相误伤:
- Global 档(默认 240 rpm/账号):user/auth/payment/admin 全部登录后路由
- Heavy 档(默认 60 rpm/账号):/usage、/usage/dashboard/*、
/user/api-keys/:id/usage/daily 等重 SQL 聚合端点叠加计数
- 管理员默认豁免(可关闭)
2. 无认证公开接口(/api/v1/settings/*,每次请求都查 DB)按安全客户端 IP
限流(默认 300 rpm/IP);回环/私网/链路本地地址(反代内部转发地址)
一律跳过计数,杜绝把整条反代链路合并进同一个桶造成大面积误拦截。
3. 修复既有隐患:auth 入口限流的 IP 取值从 c.ClientIP() 切换到与审计日志/
会话绑定/API Key ACL 同源的安全客户端 IP 解析(尊重后台「信任反代转发
IP」开关快照)。原实现下默认反代部署(未配置 server.trusted_proxies)
所有用户共享同一个登录限流桶,既会全员误拦也可被单人恶意占满形成登录
DoS;开关关闭时行为与原来完全一致。
工程约束:
- 配置热路径走进程内缓存(atomic.Value + singleflight,60s TTL),
限流中间件零 DB 访问;保存后当前节点立即生效
- 面板限流 Redis 故障 fail-open(auth 入口保持原有 fail-close)
- 429 响应携带 Retry-After;错误码 RATE_LIMITED
- 支付 webhook / 公开支付回调有意不挂限流
- 新增 GET/PUT /api/v1/admin/settings/panel-rate-limit;设置页安全 tab
新增「面板接口限流」卡片(zh/en i18n 全量)
测试:rate_limiter/panel_rate_limit/setting_panel_rate_limit 单测全绿;
routes、handler/admin、-tags unit 契约测试通过;前端 vue-tsc/ESLint/
SettingsView spec(26/26,含新增交互用例)/i18n 守卫全部通过。
2026-07-27 15:12:51 +08:00
Zhixuan Jiang
cc62979aa7
feat: add passkey authentication
2026-07-26 09:50:28 -04:00
song
db6fbdbf29
fix(openai): satisfy Live CI checks
2026-07-25 12:51:20 +08:00
song
e6eb23eaac
feat(openai): add Live gateway support
2026-07-25 12:50:46 +08:00
alfadb
5ac4a9fac2
feat(ollama): 支持 Cloud 官方用量自动刷新
2026-07-23 15:50:44 +08:00
Heatherm Huang
ca6b192728
fix: preserve composite video content routing
2026-07-23 09:26:43 +08:00
Heatherm Huang
cb81e17fea
test: align composite route contracts after rebase
2026-07-23 09:20:52 +08:00
Heatherm Huang
1c7959d0de
fix: allow composite grok chat completions
2026-07-23 09:20:52 +08:00
Heatherm Huang
1d2dfab86d
fix: allow composite grok messages routing
2026-07-23 09:20:52 +08:00
Heatherm Huang
06e7d12640
Fix composite Grok video status routing
2026-07-23 09:20:52 +08:00
Heatherm Huang
3a683fff55
Fix composite route alias attribution
2026-07-23 09:20:52 +08:00
Heatherm Huang
a008b63c16
Add composite group route registry
2026-07-23 09:20:18 +08:00
Heatherm Huang
ebc1028771
Add composite group routing
2026-07-23 09:19:24 +08:00
shaw
a90c18cbea
Merge branch 'main' into fix/issues-4561-4562-4566-4582
...
Resolve const-block conflict in openai_gateway_grok_cache.go:
keep #4590 's client tool cache constants, drop grokFreeRolling24hTokenLimit
(moved to pkg/xai as IsGrokFreeRolling24hTokenLimit with legacy 2M support).
2026-07-20 11:25:11 +08:00
Wesley Liddick
bfabfe60c8
Merge pull request #4593 from StarryKira/fix/image-storage-env-unreachable
...
fix: 异步生图开关配了却不生效(环境变量被静默丢弃 + 迁移到后台开关)
2026-07-20 09:20:15 +08:00
haruka and Claude Opus 4.8
b08cab91a9
feat(image-storage): 异步生图对象存储改为后台配置,保存即生效
...
此前开启异步生图必须改服务器上的 config.yaml 并重启容器(#4542),且若想
复用已配置的备份 S3,还得把同一套凭证再填一遍(#4458)。
- 新增 ImageStorageSettingService:配置存 settings 表,SecretAccessKey 经
SecretEncryptor 加密落库、读回脱敏、留空表示沿用旧值,与备份 S3 配置同一套做法。
- reuse_backup_s3(默认开)直接借用 backup_s3_config 的端点与密钥,只用自己的
bucket/prefix 区分对象,因此备份走 backups/、图片走 images/,且密钥不会在库里存两份。
- ImageTaskService 的启用状态改由 ImageStorageResolver 在运行时解析并缓存,
保存设置后 Invalidate 使下次请求重建客户端——不再需要重启。
- repository 侧由提供实例改为提供工厂,客户端才可能在运行期重建。
- 轮询接口的门控从 enabled() 放宽为 Pollable():关掉开关只拒绝新提交,
已受理的任务仍可取回结果,不再被中途吞掉。
- config.yaml 的 image_storage 保留为回落,后台从未保存过时沿用,
升级前已用配置文件开启的部署不受影响。
- 管理端 GET/PUT/POST /admin/backups/image-storage,PUT 与备份 S3 配置一样要求
step-up 2FA:改写存储目标同样能把生成内容导向外部账号。
注:go generate ./cmd/server 在当前 upstream 基线上即失败(securityaudit.
PromptAdminService 缺 provider),故 wire_gen.go 为手工同步。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01VHreE5pzCkSYz7J45fmd2Y
2026-07-19 00:56:21 -07:00
superman2003
1433fbc44d
fix(grok): estimate messages count tokens locally
2026-07-19 12:17:23 +08:00
shaw
8a95a46a69
Merge origin/main into codex/secure-protected-video-content-4498
...
Resolve conflicts with main:
- service/grok_media.go: keep both post-response blocks — #4497 's empty
image-output failover (main) runs first for image endpoints, then this
branch's video-status content-URL rewrite; the endpoint conditions are
mutually exclusive
- handler/openai_gateway_credential_failover_loop_test.go: mark the stub
OAuth accounts media-eligible via the grok_media_eligible extra override,
because this branch moved grok media failover coverage to the generation
endpoint, which is now gated by #4540 's paid-eligibility probe on main
2026-07-18 21:31:28 +08:00
Wesley Liddick
774ff5d8c8
Merge pull request #4515 from BenjaminAaron196/feat/filter-noise-rejected-requests
...
(fix) 过滤入口拒绝日志并强化鉴权安全边界
2026-07-18 20:46:50 +08:00
Vz7797
3f6b5c7bd7
fix(grok): proxy protected video content through upstream account
...
(cherry picked from commit a01177e294 )
2026-07-18 14:37:25 +08:00
shaw
539bfc8bad
feat(security): 敏感操作 step-up 2FA 开关化,安全开关默认关闭
...
新增系统设置 step_up_enabled(默认关闭),把敏感操作 2FA 门控做成可开关;
同时将会话 IP/UA 绑定默认值从开启改为关闭,避免用户因 IP 变动登录后掉线。
## 新增功能
- 敏感操作 step-up 2FA 总开关 step_up_enabled(默认关闭):关闭时账号/代理导出、
备份创建/下载、S3 配置修改、提升管理员等操作恢复门控引入前的直接放行行为;
开启后要求当前会话在 15 分钟内完成过 TOTP step-up 验证。
## 优化改进
- 会话 IP/UA 绑定默认改为关闭(功能保留,可在设置页按需开启)。
- 开启 step-up 开关需操作者本人已启用 TOTP(防自锁);关闭开关本身作为敏感操作,
需通过 step-up 验证(防止攻击者拿到会话后先关闸再导出/备份)。
- 两个安全开关请求字段改为可空指针(省略=保持现值),避免旧客户端全量保存时
静默重置安全开关。
- 备份恢复(整库覆盖可回滚安全设置)纳入 step-up 门控。
- 审计摘要 diffSettings 补记 step_up_enabled / session_binding_enabled 变更。
## Bug 修复
- 修复 BackupView 恢复操作 409(恢复进行中)判断未适配 apiClient 扁平化错误对象。
2026-07-18 10:46:42 +08:00