Skip to content

chore: merge upstream main (72f3dc7da) into fork-main - #2

Merged
AdoreJc merged 106 commits into
fork-mainfrom
sync/upstream-72f3dc7da
Nov 5, 2026
Merged

AdoreJc merged 106 commits into
fork-mainfrom
sync/upstream-72f3dc7da

Conversation

@AdoreJc

@AdoreJc AdoreJc commented Nov 5, 2026

Copy link
Copy Markdown
Owner

HQ-Task: T261105-01

This pull request was AI-generated (Claude Code, Claude Fable 5.1) on behalf of the repository owner; git author AdoreJC is not one of the upstream core developers.

Agent

  • Tool: Claude Code (desktop app, Code tab)
  • Tool version: Claude Code desktop, 2026-11
  • Model (full id): claude-fable-5-1
  • Host (CLI / IDE / GitHub coding agent / other): desktop app
  • Date (UTC): 2026-11-06

Links

User request

  • Verbatim:

新任务 HQ-Task T261105-01:把 upstream 的更新并入 fork-main。背景:PR #1 已 squash 合并为 fork-main 上的 37a1960(fork-main = ca2cae6 + OAuth 功能);fork 的 main 已快进到 upstream/main 72f3dc7(比 ca2cae6 多 105 个提交)。用户决定 main 只跟随 upstream,fork 自己的功能都在 fork-main 上。

  1. git fetch origin,从 origin/fork-main 切新分支 sync/upstream-72f3dc7da … 2. git merge origin/main(即 upstream 72f3dc7)。解决冲突:与 OAuth 功能无关的文件以 upstream 为准;涉及 … 要两边都保留 … 保留合并提交(不要 rebase、不要 squash)。
  2. 验证 … 4. push 分支,gh pr create --repo AdoreJc/new-api --base fork-main … 只开 PR,不合并。5. 在测试机上用这个分支重建 … 替换 new-api-t03。
  • Later constraints or corrections from the user (quote, or none): "仍按 B 级规则:不读 .env,不 force push,不碰测试机上其他容器,不写 HQ 目录。"

Out of scope — refuse

  • Matched: no
  • If yes, what was told to the user (stop here; do not open a PR): not applicable

Open gate — do not open unless all are satisfied

  • Out of scope (including pass-through-only forwarding): no
  • Usage / configuration / integration (answered instead of opening): no
  • Required issue facts present without invention: yes (merge task, no issue)
  • Verification is actual commands or steps and observed results, not only go build or tests passed: yes
  • Body is short and factual; no unfiltered AI-generated text: yes
  • Open: yes
  • If no, what was told to the user (stop here): not applicable

Kind

  • Bug fix
  • New feature
  • Performance / refactor
  • Docs
  • Other: merge upstream main into the fork's feature branch

Issue facts

  • Actual behavior: fork-main is 105 commits behind upstream main (ca2cae6 → 72f3dc7).
  • Impact: the fork's OAuth feature cannot pick up upstream fixes until merged.
  • Frequency: not applicable (one-off sync).
  • Evidence that the problem is in new-api rather than the client or upstream: not applicable.
  • Applicable types and their fields (relay / billing / frontend / deployment; write "not applicable" otherwise): not applicable.

Change

One merge commit (a9849bc, parents 37a1960 and 72f3dc7), no rebase, no squash. Git auto-merged everything except the seven locale files, which were resolved as: upstream's file text as is, plus the 75 keys the OAuth feature added (inserted in alphabetical position, our values); the 11 keys upstream removed are dropped; the escaped footer.newapi.projectAttributionSuffix key is kept in upstream's form. A diff of each resolved file against upstream's version shows only added lines.

Numbering: upstream added no channel type above 63, so ChannelTypeClaudeOAuth = 64, APITypeClaudeOAuth and the web constant CHANNEL_TYPE_CLAUDE_OAUTH = 64 are unchanged. Upstream's changes to relay/channel/api_request.go, relay/channel/claude/*, controller/channel.go, controller/channel-test.go, main.go, router/channel-router.go, web/src/features/channels/* merged cleanly and the OAuth wiring (routes, adaptor registration, auto-refresh task start, drawer buttons, usage dialogs) is present in the merged files.

Research

Duplicate / prior art

Docs and code

  • https://docs.newapi.ai/ : not relevant to a merge.
  • https://deepwiki.com/QuantumNous/new-api : not relevant to a merge.
  • README / repo docs: AGENTS.md (locale files must keep every web console message key in all seven files; protected attribution identifiers untouched).
  • Code paths and what they imply for this change: web/scripts/sync-i18n.mjs unchanged upstream; relay/channel/api_request.go DoApiRequest signature unchanged, so claude_oauth.Adaptor.DoRequest still compiles.

Alternatives considered

  • Option A: rebase fork-main onto upstream (rejected: owner asked for a merge commit).
  • Option B: resolve locale conflicts by hand per hunk (rejected: 7 files, same hunks; the scripted three-way resolution is verifiable by diff against upstream).
  • Why this approach: keeps history, keeps both sides, result is diff-checkable.

Files

Path Why
web/src/i18n/locales/{en,zh,zh-TW,fr,ru,ja,vi}.json only conflicted files; upstream text + the OAuth feature's 75 keys
everything else in the merge upstream commits ca2cae6..72f3dc7, auto-merged

Behavior

  • Before: fork-main = ca2cae6 + OAuth feature.
  • After: fork-main = 72f3dc7 + OAuth feature.
  • Explicit non-goals / leftover work: none.

Verification

  • Commands and results:
    • GOWORK=off go build ./... → ok (toolchain go1.26.10 downloaded per upstream go.mod); GOWORK=off go vet ./... → clean.
    • GOWORK=off go test ./controller/ -run 'Claude|Codex' -count=1 → ok (all 26 Claude/Codex tests pass on the merged tree).
    • cd relaykit && GOWORK=off go build ./... && go test ./... → no failures; same for tokenkit.
    • GOWORK=off go test ./relay/... -count=1 → only relay/channel TestUpstreamGetBody_HTTP2CannotRetryWithoutGetBody (and once ..._HTTP2RetryAfterGracefulGoAway_PassThrough) fail intermittently; both pass alone, and the same package alternates pass/fail on a clean checkout of upstream 72f3dc7 in this Windows environment, so pre-existing and unrelated to the merge.
    • cd web && bun install --frozen-lockfile → ok. bun run typecheck now runs bun check -b, which needs Bun 1.4.4 (package.json packageManager); this machine has Bun 1.4.0, so the equivalent bun x tsgo -b was run → exit 0, no errors.
    • bun run test → 2493 tests passed; bun run build → success.
    • bun run i18n:sync after the merge → no file changed (the resolved locales are already in sync).
    • Locale resolution check: for each of the 7 files, diff <(git show :3:file) file → 75 added lines, 0 removed; escaped attribution key present in all 7.
  • Manual steps and observed result: test host (Docker, Windows): branch fetched into the existing clone (reset to a9849bc), image new-api-fork:sync-72f3dc7da built (upstream moved the base images to oven/bun:1.4.4 and golang:1.26.10-alpine; pulling them needed an empty per-task DOCKER_CONFIG because Docker Desktop's credential helper fails in a non-interactive SSH logon), container new-api-t03 replaced on port 39682 with the same data directory. Log: "database migration started", "system is already initialized", both credential auto-refresh tasks started, "ready in 321 ms", no panic; GET /api/status → 200. Console: signed in as the test admin, the channel list shows the Claude Subscription (OAuth) channel, its usage dialog opens with HTTP 200 and the real 5-hour (33%) and 7-day (39%) windows, and the reset-credits section loads (0 available). No reset was applied. Note: the first container swap ran against a failed build and left 39682 down for about one minute until the previous image was restarted; nothing else on the host was touched.
  • UI: screenshot or recording (or why none): none; text checks via the console and the API only.
  • Tests added or updated, or why none: none; merge only.
  • Databases / providers / platforms exercised: SQLite in the test container (data directory reused across the image swap, no schema change in the OAuth feature; upstream migrations ran on container start).
  • Not verified: MySQL/PostgreSQL startup of the merged tree; real relay traffic after the merge.

Risks

  • Failure modes: an upstream behavior change in the Claude adaptor or the channel drawer that the OAuth tests do not cover.
  • Billing / quota / auth impact: none beyond upstream's own changes.
  • Follow-ups: none.

Scope check

  • Single focused change: yes
  • Secrets included: no
  • Out of scope (Coding Plan / reverse-engineered channel / third-party wrapper / Codex / pass-through-only forwarding): no

🤖 Generated with Claude Code

Calcium-Ion and others added 30 commits October 16, 2026 14:45
Add an opt-in Mantle interface with top-level cache_control, API key and
SigV4 authentication, and native Claude response handling. Keep InvokeModel
as the default for existing AWS channels.

Strip hop-by-hop headers before signing and map the dated Haiku alias to
Mantle's model ID. Cover signatures over HTTP/1.1 and HTTP/2, cache usage,
legacy routing, and channel configuration with regression tests.

Refs QuantumNous#4791
* fix(middleware): 过载哨兵改用容器口径并加入连续性与新鲜度判定

checkSystemPerformance 依赖 common.SystemStatus,而 updateSystemStatus 用
cpu.Percent(0,false) 与 mem.VirtualMemory() 采样,两者都是宿主机口径
(/proc/stat、/proc/meminfo),不具备 cgroup 感知。容器化部署下度量的是
宿主机而非本进程:容器配额 2 核时 /proc/stat 仍暴露宿主机全部核心,同节点
其它工作负载会把该值推高,导致正常 relay 流量被 503 system_cpu_overloaded
拒绝。同时该判定对单次采样即时生效,瞬时尖峰即可熔断。

本次调整:
- 新增 common/container_usage.go:优先按容器 cgroup 配额计算自身 CPU 与内存
  占用(v2 cpu.max/cpu.stat/memory.max/memory.current,兼容 v1),容器口径
  不可用时回退宿主机口径;
- 过载判定要求连续 3 次采样(约 15 秒)超阈值,任一采样回落即恢复;
- 采样超过 30 秒未刷新时哨兵不再熔断,避免状态陈旧误伤流量;
- 中间件改为消费采样结果中的过载标记,错误码与 503 语义不变。

验证:go build ./...、go test ./common/... ./middleware/... 通过;新增
容器口径与判定行为单测。

* fix(monitor): correct container CPU and memory overload detection

---------

Co-authored-by: seefs001 <i@seefs.me>
…l 字段 (QuantumNous#7855)

* fix(relayconvert): preserve input_image detail in Chat/Claude -> Responses conversion

* fix(relayconvert): preserve original image detail in Responses

Preserve all supported image detail levels during Chat to Responses conversion instead of downgrading original to auto.

Use bogus for unknown-detail fallback coverage and verify auto defaults for Claude message and tool-result images.

---------

Co-authored-by: seefs001 <i@seefs.me>
… rules (QuantumNous#7840)

The usage-log model badge resolves its icon from MODEL_PROVIDER_RULES by model
name only. clef (Cloudflare) and the NVIDIA families without an nvidia prefix
(nv-embed, nv-rerank, riva-, parakeet-, canary-, nemoretriever) matched no rule
and fell back to the plain dot.

Co-authored-by: xuu1998 <xuu1998@users.noreply.github.com>
… dark mode (QuantumNous#7571)

Dark Reader checks html.dark / color-scheme only once during page load,
but the theme class was added by ThemeProvider after React mounted.
Resolve the saved theme in an inline head script and declare
color-scheme: dark on .dark.
A task plugin can offer two billing modes, such as per task for some
models and per second for others. An administrator who prices a model
per second leaves its per-task price at zero. The model card, the list
view and the detail page then showed that unused zero price next to
the real one, and it read as a free item.

A usage price that is zero in every tier is now hidden when another
usage price is set. A model priced at zero throughout still shows its
zero prices. The card also drops the tier name when a model has a
single tier, since that name was always the editor's default "base".
Support priority ordering in table and card views with automatic priority calculation, same-tier and between-tier drop targets, live previews, conflict detection, and undo.

Keep drag mode off by default and place its toggle before Batch Operations. Consolidate sorting controls and preserve the shared visibility and view controls.
Keep table drop targets stable, use compact previews, and prevent
accidental mode switches and leftover row transforms.

Add first-use guides for card and table views with automatic playback,
pause and replay controls, and translations for all seven locales.
)

SMTP settings now only decide whether mail can be sent. Verification
codes, password reset, email binding and account security mails depend
on SMTP alone, and no notification switch affects them.

Admins get a site-wide low balance reminder switch, on by default, next
to the SMTP settings. The default threshold is entered as an amount.

Users choose which notifications they receive. Low balance reminders are
on for everyone by default. Admins can also turn channel notifications
and upstream model update notices on or off. The root user receives
channel notifications until it turns them off. Other admins receive them
after they turn them on.

A low balance reminder is sent once, when a charge takes the balance
below the threshold. A top-up above the threshold arms it again.

Channel notifications reach every admin who has them on, in that admin's
language. Email binding codes and account security mails follow the
account's language.

Saving notification settings no longer clears the language, the sidebar
layout or the billing preference.

Existing settings keep their behavior, and old clients that do not send
the new fields keep the stored switches. Webhook, Bark and Gotify
payloads are unchanged.
…reasoning modifiers (QuantumNous#7867)

* fix(model): find channels for @-modified model names without the memory cache

With the channel memory cache off (no Redis and MEMORY_CACHE_ENABLED
unset), channel selection matched abilities by the exact requested name,
so a name such as deepseek-flash@effort:max found no channel. Retry with
the routing name when the exact name has no channel, as the cached path
already does.

* feat(deepseek): support V4.1 Flash, the Search and Fetch APIs, and @ reasoning modifiers

Follows the DeepSeek API update of 2026-10-17.

- Default models: deepseek-flash and deepseek-v4-pro, each with -none,
  -low and -max, plus deepseek-search and deepseek-fetch. The retired
  deepseek-chat, deepseek-reasoner and deepseek-v4-flash names are no
  longer listed.
- Thinking: the -none/-low/-max tails also work on deepseek-flash.
  @thinking and @effort now reach DeepSeek's own fields on Chat
  (thinking, reasoning_effort), Anthropic (thinking, output_config.effort)
  and Responses (reasoning.effort), and take precedence over the tails.
- Built-in prices: peak/off-peak expressions for deepseek-flash (also the
  deepseek-v4-flash aliases) and deepseek-v4-pro, and $0.75 per 1,000
  requests for deepseek-search and deepseek-fetch.
- Server-side search: searches and page fetches DeepSeek runs for Claude
  Code and Codex bill at $0.75 per 1,000 under deepseek_search and
  deepseek_fetch, whatever model name the client sent. Searches whose
  results already arrived stay billed when a stream ends before its final
  usage; this also applies to Alibaba's Anthropic endpoint.
- New endpoints POST /v1/tools/search and /v1/tools/fetch relay the
  DeepSeek APIs like /v1/alpha/search. A call is charged only when
  DeepSeek returns results or page content.

* fix(deepseek): price /v1/tools/search and /v1/tools/fetch by endpoint

A model named in the request body chose the billing model, so a body such
as {"query":"...","model":"deepseek-flash"} was priced as a chat model with
no tokens and the search or fetch cost nothing. Both endpoints now always
use their routing name, deepseek-search or deepseek-fetch. DeepSeek ignores
the body field, so the body is still forwarded unchanged.

* fix(deepseek): bill Claude-format page fetches at the DeepSeek Fetch price

usage.server_tool_use.web_fetch_requests always went to the web_fetch
tool price, which has no built-in value, while only searches used the
DeepSeek key. A channel can now name its own fetch key next to the search
key, and DeepSeek channels bill reported fetches under deepseek_fetch. A
channel retry clears it like the search key.
…QuantumNous#7877)

* fix(notify): keep notification limit window from resetting every hour

The rate-limit key included the current clock hour, so the count reset on
every hour boundary and NOTIFICATION_LIMIT_DURATION_MINUTE above 60 had no
effect. Drop the hour suffix so the window runs for the configured duration
from the first notification, and make the Redis counter atomic with
SETNX+INCR in one transaction.

* fix(notify): fall back to default for nonpositive notification window

A zero or negative NOTIFICATION_LIMIT_DURATION_MINUTE left the Redis
counter without an expiry (or failed the SET), which blocked quota
notifications for good once the counter filled.

* test(notify): cover the Redis notification limit window
)

* fix(audit): index audit log ordering

* test(audit): isolate PostgreSQL migration checks
* fix(relay): keep Claude streams alive during preparation and retries

* fix(relay): retain failed outcomes for keepalive stream errors

* fix(relay): wait one interval before sending keepalive

* fix(relay): synchronize request keepalive handoff before headers

Stop and join the request keepalive before the stream scanner copies upstream
headers. The scanner then owns subsequent ping and data writes through its
shared write mutex.

Add regression coverage for an immediate stream and for the first keepalive
committing response headers. Before the fix, the latter case reports a data
race between Header.Clone and copyCodexSSEHeaders.

Validation: GOWORK=off GOCACHE=/private/tmp/new-api-pr7857-review-go-cache go test -race -p 2 -parallel 1 ./controller ./relay/channel ./relay/helper -run 'TestRelayKeepAlive|TestRelayStreamErrorAfterKeepAlive|TestStreamKeepAlive|TestDoRequest|TestNewTaskAPIRequest|TestProcessHeaderOverride|TestStreamScannerHandler_' -count=1
Result: all three packages passed on Go 1.26.6, darwin/arm64.
git diff --check passed.

---------

Co-authored-by: Calcium-Ion <i@caion.me>
* feat(email): add Resend delivery provider

Add Resend as an alternative to SMTP with separately editable sender address
and name, credential-safe configuration status, and validation before activation.
Preserve the target repository's email notification and balance reminder settings.
Only Resend changes are transplanted from hicoderai/new-api; no landing,
legal-document, model-group, pricing, branding, or dependency changes are included.

Validation: Go common/controller email regression tests; 19 frontend email and
notification tests; frontend production build; tsgo typecheck; touched-file lint.
Frontend validation uses the target lockfile's Axios 1.18.1 with local cached tools.

Security references: OWASP Authentication, Session Management, and Forgot Password
Cheat Sheets. Tests cover credential non-disclosure, invalid activation, sanitized
transport errors, and no automatic retry or fallback; token and session flows
are unchanged.
https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html
https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html
https://cheatsheetseries.owasp.org/cheatsheets/Forgot_Password_Cheat_Sheet.html

* fix(email): log Resend rejections and translate Resend errors

Resend's reason for a rejected or failed send now goes to the server log.
People who asked for the email still see the short error.
Resend and email method errors are translatable messages in all seven
languages.
The email settings hints are shorter and reuse the existing key hint.
The new frontend files carry the license header, the sender name check
passes lint, and test fixtures use neutral names.

* fix(email): check Resend settings while Resend is active

Saving the sender address or API key now checks the whole Resend setup
while Resend sends the mail. A typo the form accepts, such as
notify..team@example.com, is rejected instead of breaking every send.
Resend's error text and network errors are quoted in the server log.

---------

Co-authored-by: CaIon <i@caion.me>
…#7773)

* feat(dashboard): show cache usage alongside total tokens

* fix(dashboard): align cache stat descriptions and fix typecheck
* fix(task): honor channel header overrides for submission and polling

Apply the existing Request Header Override configuration after task plugin
headers, including per-task, batch and realtime queries. Resolve api_key
from the credential used for that request and skip client-only placeholders
when polling has no original client request. Reuse the HTTP header resolver
without changing plugin contracts or adding provider-specific settings.

Keep polling redirects visible, matching submission and utils.fetch, so a
custom credential header cannot be forwarded to a redirect destination.
Document configuration and cover precedence, saved keys, absent client
context, invalid values, redirects and all polling initialization paths.

Validation with Go 1.26.4 and GOWORK=off:
- make test: root, relaykit and tokenkit passed before the realtime follow-up
- go test ./relay ./relay/channel ./relay/channel/task/jsplugin ./service -count=1: passed after the follow-up
- go vet ./... and go build ./...: passed after the follow-up
- Independent read-only review: passed

Scoped security review used OWASP ASVS 5.0.0 and the Authentication,
Session Management and REST Security cheat sheets. Credentials remain in
headers, client headers are not persisted, and redirects are not followed.
No live provider calls or production deployment were performed.
https://owasp.org/www-project-application-security-verification-standard/
https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html
https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html
https://cheatsheetseries.owasp.org/cheatsheets/REST_Security_Cheat_Sheet.html

* fix(task): follow poll redirects and override content request headers

Polling follows redirects again through the shared HTTP client, which
checks every hop against the SSRF protection settings. Refusing them
turned each poll of a redirecting upstream into a failure, and after
enough failures the task was failed and refunded.

Credentialed content requests now carry the channel header overrides,
as submission and polling do. Credentialless links, utils.fetch and the
Host header stay as the plugin builds them.

* fix(task): settle tasks that a realtime query sees finish

Fetching a Gemini or Vertex task queries the upstream directly. When
that query saw the task finish, it wrote the final status itself, so
the poller skipped the task and never settled or refunded it: a failed
task kept its charge. Hand that transition to the poller's single-task
update, which records the status and settles exactly once.

---------
Co-authored-by: CaIon <i@caion.me>
* feat: add ali MultimodalEmbedding qwen3-vl-embedding

* fix: report image/video tokens in qwen3-vl-embedding usage for billing

* fix(ali): serve every Bailian multimodal embedding model natively

Route qwen2.5-vl-embedding, the tongyi-embedding-vision series and
multimodal-embedding-v1, dated snapshots included, to the native
multimodal-embedding endpoint like qwen3-vl-embedding. Text embedding
models stay in compatible mode.

Take tongyi-embedding-vision's text and image tokens from
input_tokens_details so the image ratio applies to its image tokens,
and set total_tokens to the billed input tokens: tongyi counts its
unpriced output_tokens in total_tokens. A response without usage bills
the request estimate, as compatible mode does. Return an error code
carried in a 200 body as a 500, close the response body when reading
it fails, and fold the input conversion into one function.

Count the text, image and video parts of embedding input in the request
estimate the way chat content is counted, so image calls are pre-charged
and a response without usage is not free. With the default settings no
image is downloaded for the estimate.

* fix(gemini): reject embedding input that is not plain text

Gemini embeds text only, so the converter kept the strings and dropped
image, video and text parts. The embedding request estimate now counts
those parts, and Gemini embeddings bill that estimate, so a dropped part
would be charged without ever reaching Gemini. A part now fails the
request with a 400 that skips retries, before anything is sent or charged.

---------

Co-authored-by: CaIon <i@caion.me>
…es for Claude (QuantumNous#7921)

* fix(relaykit): keep tool calls when merging adjacent assistant messages

Adjacent assistant messages with string content were merged keeping only
the second message's tool calls, so tool results for the first message's
calls had no matching tool_use and Claude rejected the request.

- concatenate both messages' tool calls in input order
- skip the "..." placeholder of a tool-call message in the merged text

* fix(relaykit): preserve literal ellipses in assistant message merges

---------

Co-authored-by: seefs001 <i@seefs.me>
- Retry the Lua rate limiter with EVAL when Redis returns NOSCRIPT
- Add regression coverage for Redis script cache flush recovery
)

DeepSeek /user/balance returns both USD and CNY wallets. An account
funded in CNY reports USD 0.00, and getDeepSeekBalanceUSD returned that
zero before ever reading the CNY entry.

Only short-circuit on a positive USD balance. When the USD wallet is 0
and CNY holds funds, convert CNY with USDExchangeRate; a lone zero USD
wallet still returns 0 instead of an error.
A task retry that moved to another plugin or channel kept the previous
attempt's usage expression. A retry from an expression-priced plugin to
one priced per request charged, and later settled, at the first plugin's
price. Each attempt now prices itself from scratch.

A retry to a more expensive channel was topped up only after the
upstream had accepted the task. A user who could not cover the
difference went into arrears, or the task was dropped while the upstream
was already running it. The retry now raises the reservation before the
request is sent, with the same balance check as the first pre-consume,
and a channel the balance cannot cover is never called.

A wallet top-up taken before submission replaced the amount held by the
first pre-consume instead of adding to it, so a request that then failed
refunded only the top-up. Image requests whose quantity was raised
before submission were affected too. The full amount is now refunded.
The email binding audit test failed now and then because it searched the
whole audit JSON for the six-digit code. Audit event and request IDs start
with a long run of time digits, so a random code sometimes appeared inside
one of them. Treat only a code that no other digit touches as a leak.
Reuse the channel base host and plugin allowedHosts for redirected query
credentials. Keep anonymous redirects working, prevent credentials from
returning after an untrusted hop, and restrict body replay to trusted hosts.
Preserve SSRF and redirect limits, reject HTTPS downgrades, and redact signed
URLs from redirect-policy errors. Document the existing allowedHosts contract.

Validation: go test ./relay/channel/task/jsplugin -count=1
Passed against clean 6347fb0aa plus this patch, without an overlay.
Covers single/batch polling, 301/302/303/307/308, host and port boundaries,
multi-hop credentials, SSRF, downgrade rejection, and real HTTP receivers.

Related OWASP ASVS v5.0.0 controls: 14.2.3, 1.3.6, 12.3.1, 16.2.5.
https://github.com/OWASP/ASVS/tree/v5.0.0/5.0/en
…QuantumNous#7931)

Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.18.3 to 1.18.7.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Commits](klauspost/compress@v1.18.3...v1.18.7)

---
updated-dependencies:
- dependency-name: github.com/klauspost/compress
  dependency-version: 1.18.7
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…s#7838)

Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 4.1.10 to 5.0.4.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md)
- [Commits](https://github.com/vitest-dev/vitest/commits/v5.0.4/packages/vitest)

---
updated-dependencies:
- dependency-name: vitest
  dependency-version: 5.0.4
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
seefs001 and others added 22 commits October 30, 2026 17:39
Upgrade the direct dependency and override to address GHSA-cg2g-xh64-v4q7.

Regenerate bun.lock with Bun and update the third-party license inventory.
* fix(profile): honor global sidebar visibility

* fix(profile): wait for sidebar status
…r as the vendors do (QuantumNous#8117)

* feat(plugins): serve task plugins at the vendors' own paths

A vendor SDK or plain HTTP client can now point at the gateway and keep the
vendor's official paths. Every plugin route is also served under
/{plugin key}, and that address always runs that plugin.

- Plugins declare the vendor's official paths and the gateway adds the
  /{key} copy. Existing prefixed addresses keep working, including /ali
  for Alibaba Bailian.
- Several plugins may declare the same path. A submit runs on the plugin
  whose channel is selected; a query is answered by the plugin that owns
  the task.
- Under the gateway's own path segments (/api, /v1, /v1beta and so on)
  only built-in plugins get top-level paths; other plugins are served at
  their /{key} address. Plugin keys cannot reuse these segments.
- Jimeng uses the official Bearer API (/api/common/v3/submit_task_v2 and
  get_result_v2). The /jimeng/ route, which requests could not reach, is
  removed.
- MiniMax supports the official v1 query with ?task_id= and
  /v1/files/retrieve. The unimplemented GET /v1/files/{id} placeholder is
  removed. Vertex AI also accepts v1beta1 paths.
- Vidu routes accept Authorization: Token, and Google routes accept
  x-goog-api-key and ?key=. The key is redacted from logs.
- Gemini Veo results are read from generatedSamples, so their videos
  download again. Vertex AI videos returned inline are fetched again when
  downloaded.
- GET /v1/videos/{id} answers tasks created on xAI's routes in xAI's
  format, and :predictLongRunning requests reach the Veo plugin.
- Enabling, activating or promoting a plugin version is refused when it
  conflicts with another plugin, and force no longer skips that check.
- The plugin page lists each endpoint once, with a switch between the
  vendor path and the /{key} address. Legacy addresses are folded away.

* fix(logging): use the shared query credential masking for key=

The access log already masks credentials passed in the query string,
key included. A second redaction for the Gemini ?key= form rewrote it to
key=[REDACTED], so the log showed two masking styles and the masking
tests failed. Only the shared masking remains.

The Gemini native routes take ?key= out of the URL. With no query left,
the log fell back to the path gin recorded on arrival, which still
carried the key. The log now writes the path alone in that case, and the
plugin API document no longer says the key is logged as key=[REDACTED].

* feat(plugins): answer native plugin routes as the vendors do

A request sent to a vendor's own path now reaches the vendor as the client
wrote it, and the client gets the vendor's reply shape and status. The
gateway answers a native request with its own 400 only when it cannot tell
the model, cannot price the request, or cannot provide the feature; the
vendor checks everything else.

- New gateway rejections of that kind on native routes: callback_url on
  Ark, Kling, Vidu and MiniMax; Kling external_task_id and a body with
  model but no model_name; xAI storage_options, which was dropped
  silently; and for Jimeng, req_json on get_result_v2, a req_key the
  plugin cannot price, and frames other than 121 or 241. A value the
  plugin cannot read reserves the model's dearest tier, and settlement is
  unchanged.
- Native bodies are sent as the client wrote them. Plugins no longer fill
  in MiniMax-H3's duration, resolution and ratio or Vidu's
  movement_amplitude and images: null, drop Vidu's bgm: false, turn
  Jimeng's image and images into image_urls, or merge Ark's content.
  Kling requests no longer carry an added aspect_ratio 1:1, cfg_scale 0.5
  or model field; without a size Kling uses its own 16:9. DashScope
  requests go to the endpoint the client called.
- Replies keep each vendor's shapes and error codes. A native presenter
  may answer with the vendor's own status through a reply wrapper
  ({__status, __headers, __body}): xAI answers a pending video with 202,
  DashScope an unknown task with 200 UNKNOWN. A task the gateway failed
  shows as failed instead of still running. xAI's native query shows a
  video that failed but was charged as failed with xAI's usage, instead of
  done; billing is unchanged.
- A native client that asks the vendor for a stream (Seedream with
  stream: true, Wan interleaved output with X-DashScope-Sse: enable) gets
  the vendor's events as they arrive. Once an event has reached the
  client the task settles and is never refunded: a finished stream bills
  what was delivered, and a stream that stopped early bills the
  reservation and cuts the client's connection, so a downstream gateway
  keeps its reservation too. The client leaving does not cancel the
  upstream request, which TASK_PLUGIN_PROTOCOL_TIMEOUT_SECONDS bounds. A
  JSON reply from an older new-api upstream is still accepted.
- Routes that keep no result (retainResult: false) accept replies up to
  MAX_FILE_DOWNLOAD_MB, so b64_json images fit.
- Native decoders get the client's request headers, without gateway
  credentials, as ctx.requestHeaders.
- Native routes accept a channel's model aliases and case variants of
  model names, as the gateway's own formats do, also on routes that list
  their models.
- Kling lists kling-v2-5-turbo, kling-v2-6 and kling-v3, priced in units
  per mode, sound and voice; Kling retired kling-v1, kling-v1-6 and
  kling-v2-master on 2026-09-15. Vidu lists its current models, from
  viduq4-preview to vidu1.5.
- Clients of /v1/videos and the other gateway formats can no longer pass
  a native body through the field the plugins use for it internally.

* feat(plugins): add Kling 4.0 to the kling plugin

Kling 4.0 takes the model in the path and has its own request shape, so
the plugin serves POST /text-to-video/kling-4.0, /image-to-video/kling-4.0
and /omni-video/kling-4.0 as native routes, and answers GET
/tasks?task_ids= for their tasks. /v1/videos and the Responses API send
kling-4.0 as text-to-video or image-to-video, with size picking 720p or
1080p.

Billing follows Kling's price list: units per output second by
resolution, or, with an input video, twice the output, or input plus
output when the input is longer. Kling picks the length when the request
has none and only Kling knows how long an input video is, so the
reservation covers the longest of each. A task settles on the units Kling
deducted, or, when Kling took cash, on the durations it reports.

Kling 4.0 Flash has no published price yet and is left out.

* chore(plugins): bump the task plugins this branch changes

Each of these plugins now declares its vendor's own paths and answers
native requests as the vendor does; kling also adds Kling 4.0. That is
new behavior in every one of them, so each takes a minor version:
alibaba 1.5.0, doubao 1.4.0, google 1.2.0, hailuo 1.4.0, jimeng 1.2.0,
kling 1.2.0, vertex-ai 1.2.0, vidu 1.2.0 and xai 1.2.0.
…ize (QuantumNous#8118)

Kling 4.0 makes videos of 3 to 30 seconds. The plugin accepted 1 to 3600,
so a longer or shorter duration was reserved and then refunded when Kling
refused it. It is now refused before anything is reserved.

A /v1/videos size now gets the nearest of Kling's text-to-video aspect
ratios, 21:9 included for Kling 4.0, and Kling 4.0 takes 720p or 1080p by
the size's shorter side. Before, only four sizes were mapped: 720x720 was
reserved at 1080p and 1792x1024 was sent as 1:1. A size that is not
WIDTHxHEIGHT is refused.
…ntumNous#8119)

Since the gateway also serves every route under /{key}, a plugin that
declared both a top-level route and the same route under its key failed
to load with "duplicate route". TypeSafe 1.2.0, already published,
declares POST /v1/systemone and POST /typesafe/v1/systemone and stopped
loading. The declared address now serves the copy, so the host no longer
adds it a second time.
…sert fails (QuantumNous#8121)

A native route relays the vendor's SSE events to the client as they arrive.
If the final reserve or the task insert then failed, the controller refunded
the whole reservation. The client kept the images and paid nothing.

Once the first event reaches the client, the controller no longer refunds.
A failed reserve no longer stops the submission. Settlement charges the
actual quota and may overdraw the token, as ordinary settlement does. A
failed task insert still settles the charge and writes the consume log.
)

* perf: read and edit request JSON and base64 with moego

Switch gjson/sjson to moego/ojson and base64 on media, file and plugin
paths to moego/base64. Both keep the same results on valid input.

- Param overrides apply every edit to one ojson.Doc and write the body
  once, instead of copying the whole body for each edit.
- The video proxy and the audio check validate base64 without decoding
  it; plugin icons and inlined plugin files build data URLs directly.
- Login, password, OAuth and signature code keeps gjson and
  encoding/base64.

* perf: rewrite request fields without re-encoding the whole body

Removing disabled fields, the Responses WebSocket create event, AWS Mantle
and pass-through bodies, the OpenAI usage patch, alpha search, video result
redaction and image SSE events now edit the body with ojson.Doc instead of
decoding it into a map and encoding it again. Everything the gateway does
not touch keeps the client's member order, number spelling and characters.

- A key the client repeats is removed or rewritten in every copy, so an
  upstream that reads the last copy sees the same value the gateway routed
  and billed. A key that appears once is rewritten in place.
- Image responses and the video proxy read large values without copying
  them.

* perf: keep member order in param override merges and prune_objects

Merging an object (append/prepend) now replaces existing members where
they stand and appends new members, sorted by key, at the end. prune_objects
deletes the matching objects from the body in place instead of encoding
the pruned part, or the whole body, again. Everything else keeps the
client's member order, number spelling and characters.
…ous#6420)

xAIStreamHandler only copied prompt_tokens/total_tokens/completion_tokens
when converting the xAI stream usage, dropping prompt_tokens_details
(cached_tokens) and completion_tokens_details. As a result cached tokens
from streaming grok requests never reach the log, and cache pricing is
never applied — cached prompt tokens are billed at the full input rate.
Non-stream requests already keep these fields via xAIHandler.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
…mNous#8172)

IncrementFailedAttempts kept the stale counter after a lockout window
expired, so the first wrong code after expiry computed MaxFailAttempts+1
and re-locked the account for the full LockoutDuration. When the stored
lockout has expired, start a new window at 1 and clear locked_until.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat(channel): return IDs of newly created channels

1. Preserve the success envelope and return created IDs for single and batch requests.

2. Keep generated IDs in the input slice and propagate panics after transaction rollback.

3. Document the response and cover duplicate credentials, chunk boundaries, empty batches, and rollback.

* feat(channel): map creation results to original inputs

Return input_index and channel_id for each accepted input while preserving existing IDs and credential parsing. Cover filtered empty inputs, duplicate keys, Vertex JSON, and multi-key channels in the API contract tests and OpenAPI examples.
* feat(gemini): add Argon fields and reasoning mappings

* feat(vertex): add per-channel v1beta1 endpoint switch
* fix(auth): verify Redis authentication cache integrity

* fix(auth): repair auth cache hashes with unreadable fields

A token cache hash with a field that cannot be parsed, or with a stray
DeletedAt field, fell back to the database on every request and was
never rewritten. Repairs now read the stored signature on its own,
drop DeletedAt, and replace quota counters that are not integers in
both the token and user caches. Valid counters are still kept.
- Count pricing issues only for models an enabled channel serves, under
  its own name, a case variant or an alias. Stale saved prices still count.
- List built-in prices only when they are saved or a channel serves them.
- Keep deletions as drafts: a deleted row stays in the table with Undo
  until saved, and a row without a saved price has no delete action.
- Show old and new prices on changed rows and in the editor, and confirm
  every save with a per-model list of current and new prices.
- Count and confirm expression price edits; the form fields now take
  precedence over the option keys loaded with the page.
- On phones, give the tabs their own scrollable row and move secondary
  actions into a menu.
# Conflicts:
#	web/src/i18n/locales/en.json
#	web/src/i18n/locales/fr.json
#	web/src/i18n/locales/ja.json
#	web/src/i18n/locales/ru.json
#	web/src/i18n/locales/vi.json
#	web/src/i18n/locales/zh-TW.json
#	web/src/i18n/locales/zh.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.