Commit Graph
100 Commits
Author SHA1 Message Date
wucm667 510ee451bd feat: support GitHub token for update checks 2026-07-19 11:02:56 +08:00
wucm667 1db10dc559 fix(subscription): renew expired admin assignments 2026-07-18 14:42:22 +08:00
wucm667 8b75dd5576 docs: clarify OpenAI WS mode router prerequisite 2026-07-18 08:37:15 +08:00
wucm667 2594950993 fix: classify transient account exhaustion as 503 instead of 404 2026-07-17 22:10:18 +08:00
wucm667 08e994ad86 fix(frontend): lazy-load Stripe payment dependency 2026-07-16 23:21:58 +08:00
wucm667 d22f4d9b5b fix(openai): use image tool usage for OAuth billing 2026-07-16 08:48:43 +08:00
wucm667 56650d6aed fix(openai): normalize Responses Lite reasoning context 2026-07-15 22:23:57 +08:00
wucm667 2fe7df9b81 fix(openai): reject image models on chat completions 2026-07-15 22:22:51 +08:00
wucm667 b28ac90364 fix(antigravity): preserve manually entered refresh token 2026-07-14 23:58:00 +08:00
wucm667 25e6688af6 [verified] fix: apply long-context pricing to account cost 2026-07-14 22:31:39 +08:00
wucm667 806bb23053 fix: add root Codex models alias 2026-07-14 17:16:24 +08:00
wucm667 6e2bb31281 fix(service): guard compact keepalive writer delegates 2026-07-11 08:52:46 +08:00
wucm667andClaude Opus 4.8 4d4ba64bf7 fix(codex): 剥离续链 message item 的非法 item_* id
OpenAI OAuth 转发续链请求时,type=message 的 item 的 id 被客户端以
item_* 形式回放,但上游要求以 msg 开头,返回 400
"Expected an ID that begins with 'msg'",sub2api 随后向客户端返回 502。
客户端自动重试会不断重放同一份坏上下文,导致连续失败。

filterCodexInputWithOptions 在 PreserveReferences=true 路径下为
type=message 增加与 #3785 (fd64d07e6) 平行的 id 前缀检查:非 msg 开头
即删除。合法的 msg* id 原样保留,不改写 item_* 为 msg_*,因为改写出的
id 未必对应真实上游对象。

原 TestFilterCodexInput_NonToolCallItemKeepsID 以 message + item_msg_001
断言"保留 id",该行为已被上游拒绝,改用 web_search_call 覆盖同一意图。

Fixes #3981

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-10 23:32:34 +08:00
wucm667 1da3501af5 fix: apply error passthrough to OpenAI response.failed streams 2026-07-09 17:59:38 +08:00
wucm667 54859022aa feat: show used quota in groups list 2026-07-09 11:45:59 +08:00
wucm667 7a11b39d6d fix(api-key): check usage log rows close 2026-07-08 15:36:12 +08:00
wucm667 e0d149d511 feat(api-key): show last used IP 2026-07-08 15:26:54 +08:00
wucm667 a23a263513 feat(payment): preview subscription CNY charge in plan editor 2026-07-06 17:52:53 +08:00
wucm667 f881ff7cb0 fix(models): support non-v1 OpenAI models URLs 2026-07-06 17:46:44 +08:00
wucm667 b408edf97b fix(payment): convert subscription CNY pay amount 2026-07-06 10:56:43 +08:00
wucm667 aee9a7ba98 fix(usage): add UTF-8 BOM to CSV export 2026-07-05 08:36:15 +08:00
wucm667 41cdd438d7 fix(gateway): honor Anthropic custom models list 2026-07-05 08:35:34 +08:00
wucm667 b23475ac0c fix(antigravity): refresh server-invalidated tokens 2026-07-05 08:34:34 +08:00
wucm667 4dd3aee5c2 fix(openai): use mapped billing model for responses 2026-07-04 10:04:42 +08:00
wucm667 6bd248fd1f fix(admin): avoid merging Codex access-only imports 2026-07-04 09:53:01 +08:00
wucm667 d0a1443a41 fix(antigravity): allow oauth 401 auto recovery 2026-07-03 15:21:53 +08:00
wucm667 93a3bf3077 Fix refund pending finalization gaps 2026-06-30 10:19:50 +08:00
wucm667 7316d83027 fix(payment): 区分退款 pending 并收敛匿名查单 2026-06-30 10:00:48 +08:00
wucm667 88ca0c1d13 fix(payment): 显示订阅 CNY 换算实付金额 2026-06-27 12:15:39 +08:00
wucm667 ac6e36f96b feat(cli): sub2api-admin 支持 SUB2API_JWT 认证回退 2026-06-26 14:11:25 +08:00
wucm667 40c8252734 fix(apicompat): 规范化 custom 工具 schema 2026-06-26 14:08:03 +08:00
wucm667 650c50e34b fix(antigravity): add project fallback for standard tier 2026-06-25 16:29:33 +08:00
wucm667 55242ffac1 fix(admin): 订单金额币种符号读取 currency 字段 2026-06-25 16:23:45 +08:00
wucm667 2b49d662cc fix(openai): dedupe passthrough function call args 2026-06-25 16:18:11 +08:00
wucm667 c6f375d3ab fix(payment): 订阅订单应用充值汇率换算 2026-06-22 10:33:26 +08:00
wucm667 9f5b57fc96 fix(billing): 防止余额计费持续透支 2026-06-22 10:30:27 +08:00
wucm667 ecedc7c8d3 fix(auth): enforce email bind suffix whitelist 2026-06-19 21:17:45 +08:00
wucm667 ab9987b2e2 fix(gateway): fail over on non-JSON 2xx responses 2026-06-15 11:04:24 +08:00
wucm667 c1c28ac7bb fix(gateway): 解压 zstd 上游响应体 2026-06-12 15:06:01 +08:00
wucm667 edfd5e3736 fix(apicompat): default tool strict to false 2026-06-12 15:01:58 +08:00
wucm667 f8c80bf038 fix(auth): apply promo codes to oauth signups 2026-06-11 18:55:27 +08:00
wucm667 65559ac589 fix(antigravity): merge system role messages 2026-06-11 18:37:00 +08:00
wucm667 da30c59923 fix(openai): fail over image server errors 2026-06-09 13:57:45 +08:00
wucm667 a67b10f468 fix(gateway): anchor responses fallback to input 2026-06-09 13:53:19 +08:00
wucm667 36721d35a8 feat(openai): cool down image rate limits by capability 2026-06-05 18:12:33 +08:00
wucm667 8e27ff20af fix(openai): handle missing messages stream terminal 2026-06-05 18:11:23 +08:00
wucm667 134687782c build(go): bump toolchain to 1.26.4 2026-06-03 09:48:46 +08:00
wucm667 c40a74d983 fix(risk-control): exempt admins from moderation auto-ban 2026-06-03 09:33:37 +08:00
wucm667 04deb819b0 fix(payment): use trade_status for EasyPay query 2026-06-02 14:59:18 +08:00
wucm667 c8cd91e3ce test(openai): 覆盖 failover 请求体重映射 2026-06-01 10:19:24 +08:00
wucm667 bf3787de1f fix(gateway): allow Claude Code count_tokens 2026-05-31 08:43:20 +08:00
wucm667 b65dde634b fix(usage): 修正 OpenAI 5h 用量百分比语义 2026-05-31 08:39:37 +08:00
wucm667andClaude Opus 4.8 c256a5441a feat(admin): 账号用量窗口 5h/7d 增加说明 tooltip
在账号管理列表"用量窗口"列表头增加一个说明性 HelpTooltip,
解释 5h / 7d 是上游账号(如 OpenAI ChatGPT、Claude)官方的滚动
用量窗口限制,由上游设定、非 sub2api 配置、与映射模型无关,且
窗口滚动到期后自动重置、无法在 sub2api 端解除。

复用现有 HelpTooltip 组件(teleport 到 body,避免表格裁剪),
单个 ⓘ 图标置于列表头,避免每行重复。新增 i18n key
admin.accounts.usageWindowsHint(zh/en 同步)。纯展示说明,
不改用量计算与后端逻辑。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-29 20:57:29 +08:00
wucm667andClaude Opus 4.7 c9caadb378 fix(account): address second-round review on quota auto-pause
- TopK initial filter now drops quota-paused accounts: fold the quota check
  into isAccountRequestCompatible so session-hash, TopK pool, and per-candidate
  rechecks all skip paused accounts. Previously the candidate pool was built
  without the quota check, so paused accounts could fill TopK and leave the
  scheduler returning "no available accounts" even with healthy ones available.
- Add per-account explicit disable flags auto_pause_5h_disabled /
  auto_pause_7d_disabled with toggles in EditAccountModal. Without these,
  leaving the account threshold blank silently falls back to the global default,
  so admins could not exempt a single account once a global default existed.
  Disable is per-window: an account can opt out of 5h auto-pause while still
  honoring 7d. Schedule snapshot whitelist includes the new fields, i18n EN/ZH
  updated, threshold-hint text revised to explain "blank = global default".
- Move quota auto-pause settings off the request hot path: replace the per-repo
  TTL+singleflight sync DB read with a per-SettingService stale-while-revalidate
  in-memory snapshot. Get is non-blocking (atomic.Pointer load + async refresh
  on staleness); writes via UpdateOpsAdvancedSettings push directly into the
  cache through an injected sink; wire warms the cache at startup. Adds Warm
  (sync) for tests/init and SetOpenAIQuotaAutoPauseSettings (sink target).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 14:32:45 +08:00
wucm667andClaude Opus 4.8 8b7a822706 fix(account): address review on OpenAI quota auto-pause
- gate previous_response_id sticky path with quota auto-pause check at both
  the snapshot and DB-recheck stages (previously bypassed, #1)
- skip pausing when the usage window already reset to avoid a stale stuck-pause;
  carry codex_*_reset_at / reset_after_seconds / codex_usage_updated_at through
  the scheduler snapshot whitelist (#2)
- remove the incomplete limit mode; percentage threshold only (#3)
- add global default 5h/7d threshold inputs to the Ops settings dialog with
  validation and en/zh i18n (#4)
- downgrade account_auto_paused_by_quota log from Info to Debug; it fires
  per-candidate on the scheduling hot path (#5)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-29 12:20:30 +08:00
wucm667 ead471d64b feat(account): 支持按 5h/7d 用量阈值自动暂停账号调度 2026-05-29 10:47:47 +08:00
wucm667 415d08f255 fix(scheduler): add sticky health escape 2026-05-29 10:25:26 +08:00
wucm667 b15375dfb4 fix(admin): handle already up-to-date updates 2026-05-28 17:27:01 +08:00
wucm667 8f3b211997 ci: retrigger after transient GitHub Actions codeload outage 2026-05-27 09:34:58 +08:00
wucm667 a31b507484 fix(scheduler): 模型404仅冷却账号模型组合 2026-05-26 20:29:48 +08:00
wucm667 b6a38ddab7 feat(admin): 账号管理列表新增创建时间列 2026-05-26 19:59:12 +08:00
wucm667 a9c7a3a095 fix(bedrock): strip context_management when beta is removed 2026-05-25 14:15:39 +08:00
wucm667 1b6a15b485 fix(db-pool): enforce connection lifetime floors 2026-05-23 15:04:24 +08:00
wucm667 199a5bcc69 fix(risk-control): Agent 工具循环中同一用户消息重复审计去重
末尾 role 检查方案:当 messages / input / contents 数组末尾一项不是用户消息
(而是 assistant、tool / function_call_output 等)时,直接跳过内容审计,
从而避免 Agent 工具循环中同一用户输入被反复审计、计费、写日志。

Fixes #2678
2026-05-22 14:54:06 +08:00
wucm667 ffd53343bb fix(deps): 升级 js-cookie 修复安全审计 2026-05-22 13:55:27 +08:00
wucm667 0d5c6f7cc7 feat(risk-control): 内容审计支持按模型生效 2026-05-21 21:18:43 +08:00
wucm667 a5b9b68b76 feat(registration): 支持邮箱白名单后缀通配符 2026-05-21 21:02:26 +08:00
wucm667 ca60cede14 feat(account): 支持测试连接 Chat Completions 路径 2026-05-21 16:37:20 +08:00
wucm667 c4d7edba08 fix(apicompat): map developer role to system 2026-05-21 16:37:05 +08:00
wucm667 3263ca63c7 feat(redeem): add redeem code batch update 2026-05-20 16:08:41 +08:00
wucm667 22ff1acde3 fix(auth): 停用/删除分组后阻断 API Key 2026-05-20 15:52:00 +08:00
wucm667 90b2b2a757 feat(usage): 用户 API Key 用量页支持按日明细 2026-05-20 15:48:38 +08:00
wucm667 cbdfedab38 test(repository): 补充 AES Encryptor 单元测试
为 AESEncryptor(AES-256-GCM)新增纯单元测试,覆盖:
- NewAESEncryptor:合法 32 字节密钥、错误密钥长度(16/24/其他)、空 key 与非法 hex 三条路径
- 加解密往返:ASCII、中文多字节、空字符串、长字符串(> 1 KB)、特殊字符
- Nonce 随机性:相同明文 30 次加密均产生不同密文
- Decrypt 错误路径:非 base64 输入、长度过短、篡改密文体、篡改 GCM 标签
- 跨实例:相同密钥可互解,不同密钥不可互解

仅新增测试文件,不修改任何业务代码。
带 //go:build unit tag,与 go test -tags=unit 入口一致。
2026-05-20 15:44:00 +08:00
wucm667 cae93ae137 fix(openai): /v1/responses respect force chat completions 2026-05-20 14:17:26 +08:00
wucm667 5465003d07 test(group): 补充分组列表可用账号数与总账号数统计正确性的集成测试
修复 #2579 报告的可用账号数等于总数问题:
上游已通过 loadAccountCounts / GetAccountCount 两处 SQL 中的
  COUNT(*) FILTER (WHERE status='active' AND schedulable=true)
正确区分可用账号,但缺少覆盖 active < total 场景的测试,
导致回归容易被忽略。

新增三个集成测试:
- TestListWithFilters_ActiveAccountCount_LessThanTotal
    含 active+schedulable、disabled、active+unschedulable 三类账号,
    断言 AccountCount=3、ActiveAccountCount=1,
    并验证 GetAccountCount 返回值与 ListWithFilters 字段一致。
- TestListWithFilters_RateLimitedAccountCount
    验证 rate_limit_reset_at 未过期的账号计入 ActiveAccountCount(仍可调度),
    同时单独出现在 RateLimitedAccountCount 中。
- TestListWithAccountCountSort_AttachesActiveCount
    通过 SortBy=account_count 触发 listWithAccountCountSort 路径,
    验证排序按 total 而非 active,且两个字段均被正确附加。

Fixes #2579
2026-05-20 11:33:29 +08:00
wucm667 2c14efeaa0 fix(openai-images): 修复图片生成 n 参数透传 2026-05-20 11:28:28 +08:00
wucm667 92ad68a314 feat(channels): 模型定价支持一键同步最新模型
从 LiteLLM 定价目录中读取指定平台的最新模型列表,
将尚未录入的模型以新定价条目(价格留空)的形式追加,
管理员只需点击同步最新模型按钮即可完成操作。

- backend/service: PricingService 新增 ListModelNamesByProvider
- backend/handler: ChannelHandler 新增 SyncPricingModels (GET /api/v1/admin/channels/pricing/sync-models)
- backend/routes: 注册新路由(在 /:id 通配符之前)
- backend/wire_gen: 手动更新 NewChannelHandler 调用
- frontend/api: channels.ts 新增 syncPricingModels
- frontend/i18n: zh.ts / en.ts 新增 5 个 key
- frontend/view: ChannelsView 定价区域标题行新增「同步最新模型」按钮
- tests: pricing_service_test + channel_handler_test 新增单元测试
2026-05-19 20:32:32 +08:00
wucm667 276b5c7755 fix(apicompat): strip temperature/top_p for reasoning models in Responses conversion
gpt-5.x models served via the OpenAI Responses API reject requests that
include temperature or top_p with:
  {"detail":"Unsupported parameter: temperature"}

This caused ClaudeCode agent/subagent tool requests to fail with a 400
error when an OpenAI group had the Messages-format support enabled.

Root cause: AnthropicToResponses and ChatCompletionsToResponses were
unconditionally forwarding temperature and top_p from the incoming
request to the ResponsesRequest, even though all gpt-5.x reasoning
models reject these sampling parameters.

Fix:
- Add isReasoningModel(model string) bool helper that returns true for
  any model whose name starts with "gpt-5".
- Skip temperature and top_p when converting to ResponsesRequest for
  reasoning models. Non-reasoning models (e.g. gpt-4o) are unaffected.
- ResponsesRequest.Temperature and TopP are already *float64 with
  omitempty, so nil values are safely omitted from the JSON body.

Tests:
- TestAnthropicToResponses_TemperatureStrippedForReasoningModel
- TestAnthropicToResponses_TemperatureStrippedForAllGpt5Variants
- TestChatCompletionsToResponses_TemperatureStrippedForReasoningModel
- TestChatCompletionsToResponses_TemperaturePreservedForNonReasoningModel

Fixes #2487
2026-05-19 20:03:16 +08:00
wucm667 e4c7927eff feat(payment): 支持强制移动端统一使用二维码支付 2026-05-19 18:22:12 +08:00
wucm667 e4aaf0af29 feat(redeem): 兑换码支持设置使用有效期 2026-05-19 15:53:28 +08:00
wucm667 6381f9e37d fix(openai): 识别上游静默拒绝并触发 failover 2026-05-19 15:48:36 +08:00
wucm667 271aba1abe fix(ops): exclude IP-denied access from SLA 2026-05-19 15:41:54 +08:00
wucm667 a9a357e9ab fix(setup): 初始化完成后阻止访问 setup 页面 2026-05-19 15:33:02 +08:00
wucm667 df82a3bc69 fix(openai): avoid null content when converting chat-completions to responses
When a chat-completions message has no usable content parts (empty array,
empty text part, or filtered-out image part), marshalChatInputContent
marshalled a nil slice to JSON null. The upstream Responses API rejects a
null content field with HTTP 400. Fall back to an empty string instead.

Fixes #2515
2026-05-17 11:20:05 +08:00
wucm667 44995404ef fix(docker): pin frontend builder pnpm to v9
`corepack prepare pnpm@latest` now resolves to pnpm 11, which promotes
ERR_PNPM_IGNORED_BUILDS to a hard error and breaks the frontend stage of
`docker build`. Pin pnpm to v9 to match the CI workflow
(pnpm/action-setup version: 9) and keep image builds reproducible.

Fixes #2442
2026-05-17 11:19:47 +08:00
wucm667 2ec1d331e0 fix(gateway): return Gemini models for Gemini groups 2026-05-15 11:33:26 +08:00
wucm667 a611742910 fix(gateway): detach upstream context unconditionally for image generation
Image generation requests (forwardOpenAIImagesOAuth and
forwardOpenAIImagesAPIKey) were calling detachStreamUpstreamContext with
parsed.Stream, which for non-streaming requests (Stream=false) simply
returned the original client context unchanged. When the client
disconnected before the upstream completed (30-80s for image gen), the
context cancellation propagated to the upstream HTTP request, causing a
502 error despite the upstream having already started processing.

Switch to detachUpstreamContext (unconditional detach) so the upstream
image generation request is always bound to a background context and
completes regardless of client lifecycle.

Fixes #2310
2026-05-14 18:03:18 +08:00
wucm667 e9637148dd fix(openai): pass service_tier by default 2026-05-14 16:45:31 +08:00
wucm667 f9d5ccdf24 test(gateway): check Gemini chat completion assertions 2026-05-14 15:33:10 +08:00
wucm667 827764d7bd fix(account): preserve combined model restrictions 2026-05-14 15:00:28 +08:00
wucm667 041d138f76 fix(gateway): route Gemini chat completions upstream 2026-05-14 11:48:00 +08:00
wucm667 862819042c feat(openai): 支持后台配置 Responses API 路由 2026-05-14 11:46:24 +08:00
wucm667 61b6272110 fix(payment): apply product affix to subscriptions 2026-05-14 11:36:02 +08:00
wucm667 a5acefcc9e fix(install): 检查 Bash 版本并提示升级 2026-05-14 11:35:07 +08:00
wucm667 4d51e53d20 fix(redeem): 修复批量复制兑换码兼容性 2026-05-14 11:35:00 +08:00
wucm667 679c0865a0 fix(openai): handle versioned compatible base URLs 2026-05-13 11:25:15 +08:00
wucm667 6d69ae87c3 fix(openai): record zero-cost usage for unpriced models 2026-05-09 17:33:35 +08:00
wucm667 65493df95a fix(ccswitch): add codex model to import deeplink 2026-05-08 17:31:36 +08:00
wucm667 bcf4aedcde fix: 修复账户配额跨越时调度快照入队逻辑 2026-04-23 14:53:57 +08:00
wucm667 f5764d8dc6 fix(billing): 计费始终使用用户请求的原始模型,而非映射后的上游模型
当账号配置了模型映射(如 claude-sonnet-4-6 → glm-5.0)时,系统错误地
使用映射后的上游模型名计算费用。由于上游模型(如 glm-5.0)在定价系统中
没有价格配置,导致计费失败后被静默置为 0,用户不被扣费。

修改 forwardResultBillingModel 优先返回请求模型名,并移除 OpenAI 路径
中 BillingModel 字段对计费模型的覆盖逻辑。
2026-03-28 16:22:06 +08:00