William Drake and Claude Opus 5.5
52c123e6f4
fix(billing): hold inflight reservation until billing lands; price estimate like billing; wire remaining endpoints
...
Address gaps found in adversarial verification of the in-flight balance
reservation:
- Early release: the reservation is now a ref-counted handle carried on the
request context. Billing tasks submitted via submit*UsageRecordTask take a
ref and return it only after RecordUsage has run; with reservation enabled
the balance cache is deducted synchronously inside the billing task, so the
reservation is released only after admission can see the deduction. Dropped
tasks return their ref immediately. The reservation is renewed every ttl/3
while the handler runs; after the handler returns it is no longer renewed,
so the post-handler hold is bounded by one TTL.
- Estimate: use the same billing model (channel mapping + BillingModelSource,
max over requested/mapped when ambiguous) and ModelPricingResolver (group
ModelPricing incl. wildcards, channel per_request/image/video/token
overrides), default/group/user rate + peak multiplier, plus image, video,
audio and search surcharge kinds. Unpriced requests fail open with a
throttled log; new billing.inflight_reservation.fail_closed_on_unpriced
(default false) rejects them instead.
- Wire images, embeddings, web/x search, alpha search, grok media generation,
grok realtime/voice, OpenAI-platform /v1/messages and ResponsesWebSocket
(session-level reservation with renewal).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com >
2026-09-28 16:14:43 -04:00
William Drake and Claude Opus 5.5
43f88c99aa
fix(billing): reserve in-flight balance to prevent concurrent overdraft
...
Balance-mode admission only checked cached balance > threshold, so N
concurrent expensive requests could all pass and overdraw the user.
Add a Redis in-flight reservation: at admission estimate a conservative
per-request cost (input estimate + output price x max_tokens, times rate
multiplier) and atomically require cached_balance - inflight >= estimate
(first in-flight request always admitted). Reservations are released via
defer on every path and expire by TTL. Fails open on estimation / Redis
errors. Configurable via billing.inflight_reservation (enabled by default).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com >
2026-09-28 14:20:49 -04:00
Wesley Liddick
b3c7038cf4
Merge pull request #7526 from HuntercodeT/fix/passthrough-model-discovery-merge
...
fix(gateway): let OpenAI passthrough accounts supplement model discovery instead of hiding mapped models
2026-09-28 10:49:01 +08:00
Wesley Liddick
79c18ec836
Merge pull request #7609 from feeeei/fix/client-disconnect-499
...
fix(gateway): 客户端断开统一标记 499,不再被记成 502/200 上游错误
2026-09-28 10:04:07 +08:00
feeeei
f4f8ff04db
fix(gateway): 客户端断开统一标记 499,不再被记成 502/200 上游错误
...
客户端在响应提交前断开时,只有排队/换号阶段和 OpenAI 的兜底写入会标 499。
Claude 非流式与 Gemini 的 Chat Completions / Messages / Responses 兼容入口
在等待上游时断开,由 GatewayHandler.ensureForwardErrorResponse 补写 502;
Gemini 原生入口什么都不写,落成 200 并被 ops 记成一条 provider 的
"Recovered upstream error";Antigravity 回写 502。这些行都按上游失败计入
SLA 与上游错误数。
- GatewayHandler.ensureForwardErrorResponse 补客户端断开检查,与 OpenAI 版一致
- GatewayHandler 的 Messages / ChatCompletions / Responses 与 Gemini 原生入口:
首次选号失败时先判断客户端断开;ChatCompletions / Responses 循环开头改用
failoverClientGone,不再直接 return 落成 200
- Gemini 原生入口:forward 失败时补 499 标记;并发槽错误改走
concurrencyErrorResponse 统一映射(断开 499、排队满/超时 429、其余 503)
- Antigravity 上游响应前断开回写 499;googleapi 与 Antigravity 的 Google 错误
格式把 499 映射为 CANCELLED
- OpenAI alpha search 非 failover 错误分支补断开检查
- Claude / Gemini / OpenAI 传输层错误:请求 context 已取消时不记 ops 上游事件
- ops:IgnoreContextCanceled 开启时跳过没有上游错误上下文的 499;带上游错误的
499(上游失败后客户端没等到换号结果就离开)仍按上游失败落库
计费不变:Gemini 流式中途断开的用量处理不在本次范围。新增 handler/service
单测覆盖各入口的断开场景与 ops 过滤规则。
2026-09-26 17:13:10 +08:00
Achord Chan
510b680fca
Merge upstream main and retain upstream scheduler test fix
2026-09-26 15:47:52 +08:00
alfadb
d0731be2f0
fix(opencode): lite 列表 DTO 补 opencode_go_usage,修复列表页显示余额
2026-09-23 15:26:44 +08:00
alfadb
ae2735cdb6
feat(opencode): 用量窗口支持同 Key 组共享、活动防抖与超窗强刷
...
与 Ollama Cloud usage 对齐:OpenCode Go 作为同 Key 聚合订阅,
多个 openai/apikey/base_url=opencode.ai/zen/go/v1 账号共享同一份
用量状态与刷新节奏:
- 组共享:组指纹 sha256("opencode.ai\0"+api_key);auto_refresh 开关
与 snapshot 按组写(事务 + FOR NO KEY UPDATE + 锚点 CAS + 纯合并,
写 snapshot 不会抹掉开关);列表/详情经 ResolveAccounts 组内共享;
账号换 Key → IdentityChanged → 组级关闭 auto_refresh 并清快照
- 活动防抖 + 超窗强刷:settings 新增 debounce_minutes(默认 1,
1-60,必须小于 interval_minutes);模型请求活动经网关 5 处调用点
驱动刷新,due = min(lastUsed+debounce, fetchedAt+maxWait),
成功路径有 5 分钟最小抓取间隔,失败路径退避优先
- 手动刷新限频 10s→30s 且按组;singleflight/RunDue 按组去重;
ListDue 在 SQL 内按组算 due(CTE 分组取组内 MAX(last_used_at))
验证:go build + 五包回归 OK;新增组共享/三态 due/组单飞/
IdentityChanged/debounce 校验单测全绿;vitest 11 例全绿;
vue-tsc 零错误。
2026-09-23 15:26:35 +08:00
alfadb
6624947b62
feat(opencode): 支持 OpenCode Go 官方用量窗口查询与自动刷新
...
OpenCode Go 上游(https://opencode.ai/zen/go/v1)官方提供用量端点
GET /zen/go/v1/usage(Bearer 复用消费 key),返回 rolling(5h)/weekly/monthly
三窗口的 percent 与 resetsAt。本提交为 openai apikey 账号(base_url 为
opencode.ai/zen/go/v1)接入该用量窗口:
- 后端:OpenCodeGoUsageService——手动刷新(每账号 10s 节流)、
周期自动刷新(全局开关 + 账号开关双开启,interval 5-1440 分钟,
leader lock + 每轮 20 账号 + 并发 4)、失败指数退避(上限 24h)、
Retry-After 尊重;401→unauthorized、403→failed;snapshot 持久化于
accounts.extra(单账号写入,无分组 CAS、无会话加密)
- admin API:settings GET/PUT、/:id/opencode-go-usage GET、
auto-refresh PUT、refresh POST(与 Ollama Cloud usage 同构)
- 前端:账号列表行内三窗口进度条(复用 UsageProgressBar)、
编辑弹窗内配置面板(详情+手动刷新+auto-refresh)、全局设置卡片、
en/zh i18n
验证:
- 上游端点已用生产真实 Go key 实测 200,响应
{"usage":{"rolling":{"status":"ok","percent":6,...},...}}(2026-08-13)
- go build ./... OK;service/handler/repo/dto/cmd 全量回归 OK
- 新增单测 20 例(解析 401/403/畸形 JSON、退避、节流等)全绿
- frontend vitest 新增 7 例 + Ollama 回归 4 例全绿;vue-tsc 零错误
2026-09-23 15:26:35 +08:00
Wesley Liddick
afd069b169
Merge pull request #7532 from alfadb/feature/claude-cli-version-sync
...
feat(claude): 自动同步 Claude Code 客户端版本号,无需改代码跟随官方版本
2026-09-23 14:54:36 +08:00
alfadb
ca08825935
feat(claude): 自动同步 Claude Code 客户端版本号
...
出站伪装用的 Claude Code 版本号此前硬编码在 claude.CLICurrentVersion,
只能靠环境变量 SUB2API_CLAUDE_CLI_VERSION 覆盖且需重启;Anthropic 抬高
版本下限时(如 Opus 5.5 要求 >= 2.1.280)必须改代码发版才能跟上。
改为每小时从官方 GitHub Releases 同步最新稳定版,无需重启也无需发版。
- 新增 ClaudeCodeVersionSyncService:1 小时间隔,数据源 anthropics/claude-code
的 releases/latest,失败回退最近 30 条列表;过滤 draft/prerelease;
只向前推进,拉取失败保留上次值不降级;面板可关闭
- 新增三个设置项:claude_code_client_version(管理员手动固定)、
claude_code_client_version_synced(同步服务独占写)、
claude_code_version_auto_sync_enabled(开关,默认开)
- 取值优先级:面板手动值 -> 同步值 -> SUB2API_CLAUDE_CLI_VERSION -> 内置基线,
每层经 IsSupportedCLIVersion 校验,含 60s 缓存与 singleflight
- 版本号运行期化:claude.DefaultHeaders 由包级 var 改为函数,新增
EffectiveCLIVersion/DefaultUserAgent 与 SetCLIVersionResolver(未注入时
与 CLIVersion() 等价);identity 的 defaultFingerprint 不再在包 init 固化,
指纹下限与主版本超前校验改用运行期值
- 守住一致性铁律:buildUpstreamRequest 与 count_tokens 各取一次 UA 字符串,
同时喂给出站 User-Agent 头与请求体 billing 的 cc_version,避免缓存翻转
瞬间头体版本不一致被判非正版客户端
- 管理后台设置页新增配置区块,含中英文案与「当前同步到」只读展示
2026-09-23 13:35:44 +08:00
HuntercodeT
ecba49f711
fix(gateway): let OpenAI passthrough accounts supplement model discovery instead of hiding mapped models
...
A single passthrough account made GetAvailableModels return nil for the whole
group, so every other account's model_mapping was dropped from /v1/models and
the Codex catalog. Treat passthrough accounts like unmapped ones: skip their
(possibly stale) mapping and let supplementUnmappedOpenAIModels add the
default set, while ordinary accounts' mappings still reach the list.
Refs #6647 , #7517
2026-09-23 11:51:06 +08:00
Achord Chan
b5b5f1f94b
fix(model-plaza): apply independent video billing multipliers
2026-09-23 11:28:41 +08:00
lyy0709
c4c2e66070
feat(models): support GPT-6 Sol, Luna and Claude Opus 5.5
2026-09-23 11:27:49 +08:00
Wesley Liddick
d8d5e1dd35
Merge pull request #7282 from feeeei/feat/affiliate-offline-withdrawal
...
feat(affiliate): 提取记录支持登记线下提现
2026-09-23 11:20:32 +08:00
Wesley Liddick
59a00631ed
Merge pull request #7478 from superzcj/codex/simple-mode-key-window-limits
...
feat: optionally enforce API-key spending windows in simple mode
2026-09-23 11:19:17 +08:00
Wesley Liddick
b2d6b954a1
Merge pull request #7090 from Brisbanehuang/codex/scheduling-rate-account-fallback
...
fix(scheduler): 无有效探测时回退账号倍率,支持 OAuth 参考倍率留空
2026-09-23 11:18:37 +08:00
Wesley Liddick
1947add842
Merge pull request #7288 from feeeei/feat/backup-monthly-archive
...
feat(backup): 支持月度归档与独立保留策略
2026-09-23 11:18:08 +08:00
Wesley Liddick
0dd71286f2
Merge pull request #7060 from heathermhuang/fix/composite-image-models-6076
...
fix(images): allow compatible Gemini models on API-key upstreams
2026-09-23 10:07:02 +08:00
Wesley Liddick
5ad7cf4fb9
Merge pull request #7300 from lizhaoxinlizhaoxin2-lab/fix/responses-stream-error-schema
...
fix(responses): emit protocol-correct stream errors once
2026-09-23 10:03:00 +08:00
zhangcj
3b336b2eca
feat: optionally enforce API-key spending windows in simple mode
2026-09-23 08:17:48 +08:00
feeeei
c19204289d
fix(affiliate): 线下提现登记按 Idempotency-Key 幂等
...
登记请求只有金额,提交成功但响应丢失时,管理员重试会把同一笔站外打款再扣
一次返利额度。现在一次登记由 Idempotency-Key 标识,数据库在同一事务内以唯一
约束去重:
- user_affiliate_ledger 新增 operation_id(幂等键派生的 SHA-256)与部分唯一
索引(迁移 240);接口要求 Idempotency-Key,缺失或非法返回 400
- 事务内先以 operation_id 写入占位流水,再解冻、扣减并补写额度快照;同键
重试返回首笔流水的结果并带 X-Idempotency-Replayed,不重复扣减;同键换了
用户或金额返回 409 IDEMPOTENCY_KEY_CONFLICT;额度不足时占位随事务回滚
- 并发的同键请求在唯一索引上等待先到者:先到者提交则返回同一条流水,回滚
则自行登记
- 弹窗在网络错误、超时、5xx、408/409 时锁定用户与金额,重试沿用同一请求与
幂等键;幂等键按管理员、用户、金额暂存于 sessionStorage,登记有确定结果后
释放
2026-09-23 01:24:59 +08:00
Wesley Liddick
fa9f104a93
Merge pull request #7169 from HuntercodeT/fix/gemini-mixed-model-listing
...
fix(gateway): list mixed Antigravity models for Gemini groups
2026-09-22 21:56:04 +08:00
Wesley Liddick
c619ff8474
Merge pull request #7404 from a408665321/codex/fix-oauth-credentials-merge
...
fix(account): preserve model mapping on OAuth reauth
2026-09-22 20:29:01 +08:00
Wesley Liddick
738ef1c73c
Merge pull request #7442 from wucm667/fix/issue-7436-image-balance-error
...
fix(images): preserve insufficient balance failures
2026-09-22 20:27:23 +08:00
nagi330
935db68517
feat(grok):add grok 4.7 support
2026-09-22 10:30:01 +08:00
wucm667
de98bdff1e
fix(images): preserve insufficient balance failures
2026-09-21 10:23:10 +08:00
haruka
b8d52fad34
feat(billing): support configurable reasoning effort multipliers
2026-09-20 16:41:49 +08:00
haruka
fc96132e72
fix(openai): harden referral outcomes and isolate HTTP transport
2026-09-20 15:47:53 +08:00
a408665321
63c079d873
fix(account): preserve settings on OAuth reauth
2026-09-20 14:39:36 +08:00
haruka
5090ffe05e
feat(openai): show Codex credits and manage referral invitations
2026-09-20 14:38:29 +08:00
Brisbanehuang
783a0a9830
feat(content-audit): add independent TypeSafe engine profiles
2026-09-19 20:52:31 -04:00
Wesley Liddick
aea725f2ea
Merge pull request #7247 from Qiaogun/codex/seedance-native-api
...
feat: 支持 Seedance / Ark 原生视频任务 API
2026-09-19 12:11:17 +08:00
shaw
c63bd14a02
feat(plugin): generic host services + read-only status bridge channel
...
Extend the local plugin system's host<->plugin contract with generic,
capability-neutral facilities, so transport plugins can be built on top
without embedding plugin-specific logic in the host.
Host services (plugin dials a broker-provided HostService gRPC):
- per-plugin namespaced KV store (key/value size and TTL bounded)
- account directory: ListAccounts + ResolveOutboundIdentity, restricted to
the accounts a plugin's declared capability already covers
- InitHostServices lifecycle hook; plugins that don't implement it run
unchanged and are simply offered no host services
Read-only runtime status channel:
- HealthResponse gains an opaque, plugin-defined status_json produced
passively (no config apply, no upstream call, no side effects)
- GET /admin/plugins/:id/status (ungated) and the plugin.status UI-bridge
verb map to Health, so a status UI can poll live state without a step-up
prompt or a "test" side effect
- config.test no longer force-shows a host success toast; the plugin UI owns
result presentation, so plugins that read status do not spam toasts
Document the UI-bridge verb taxonomy (read vs mutate/test gating) and the
status contract under pkg/pluginapi.
2026-09-19 11:25:56 +08:00
lizhaoxinlizhaoxin2-lab
cf10d6d01d
fix(responses): emit protocol-correct stream errors once
2026-09-18 12:38:05 +08:00
HuntercodeT
c12d0131cb
fix(gateway): list mixed antigravity models for gemini groups
2026-09-18 09:03:41 +08:00
feeeei
a9ff663387
feat(backup): 支持月度归档与独立保留策略
2026-09-18 06:56:27 +08:00
feeeei
57b7dbdc85
feat(affiliate): 提取记录支持登记线下提现
...
管理员在站外给邀请人打款后,系统里原本无法扣减对应的返利额度,用户仍可把
这部分额度转入余额。现在可在「邀请返利 → 提取记录」点「登记线下提现」,
从该用户的可提取返利额度中扣除已打款金额:
- POST /api/v1/admin/affiliates/users/:user_id/withdraw,请求体只含 amount,
金额按 8 位小数舍入后校验
- 先解冻已到期的冻结额度,再以 aff_quota >= amount 为条件原子扣减,写入
action=withdraw 的流水并带额度快照;额度不足返回 AFFILIATE_QUOTA_INSUFFICIENT
- 不新增字段与迁移:线下提现复用已有 action 列区分,操作人由管理端审计日志记录
- 提取记录同时列出转入余额与线下提现,新增「类型」列
- 弹窗选择用户后展示可提取额度,支持一键填入全部;从未产生返利的用户按 0 处理
返利记录改为 LEFT JOIN 订单与被邀请人,兑换码、管理员充值来源的返利也会出现
在明细中,接口里订单相关字段与被邀请人 ID 可为 null。
2026-09-17 23:42:02 +08:00
Wesley Liddick
18328aed05
Merge pull request #7212 from wucm667/feat/issue-7203-redemption-pagination
...
feat(redeem): paginate user redemption history
2026-09-17 16:43:06 +08:00
Cai
aba34524f1
feat: support native Seedance Ark video task API
2026-09-17 04:14:14 +09:00
wucm667
a9ed218989
feat(redeem): paginate user redemption history
2026-09-16 13:19:15 +08:00
HuntercodeT
da74bf13a4
fix(gemini): discover antigravity mappings in native model lists
2026-09-15 16:50:46 +08:00
Wesley Liddick
25c21aedda
Merge pull request #7129 from kk-418/fix/grok-build-responses-sequence-number
...
fix(responses): 始终在 Responses SSE 中写出 sequence_number 避免反序列化失败
2026-09-15 15:28:33 +08:00
Wesley Liddick
1920a7d687
Merge pull request #7091 from SavitarC/feat/subscription-bulk-actions
...
feat: 支持订阅管理批量操作
2026-09-15 08:57:27 +08:00
Wesley Liddick
dd2e6b3680
Merge pull request #7076 from Shen-An/fix/antigravity-refresh-warning
...
fix(admin): surface partial Antigravity refresh warnings
2026-09-15 08:54:06 +08:00
cikenerd and Cursor
087987070b
fix(responses): 为 grok-build 始终写出 sequence_number
...
网关合成/重编的 Responses SSE 因 omitempty 或缺字段丢掉 sequence_number,
grok-build 会整轮反序列化失败。合成失败帧、compact 桥接和转换 wire JSON
一律写出该字段,0 也保留。
Fixes #7128
Co-authored-by: Cursor <cursoragent@cursor.com >
2026-09-14 11:45:53 +08:00
chihao.ou
28a4ea914d
fix(proxy): allow explicitly clearing stored credentials
2026-09-13 17:23:24 +08:00
SavitarC
e3cce574d7
fix: serialize subscription extensions
2026-09-13 12:33:35 +08:00
Brisbanehuang
b18e4ce455
fix(scheduler): 为调度倍率补充账号倍率回退
2026-09-13 00:14:16 -04:00
SavitarC
3d6c207723
feat: 支持订阅管理批量操作
2026-09-13 11:49:03 +08:00