Repository navigation
chore: 合并上游 main (b388140ac) 到 fork-main - #46
Conversation
…ntumNous#8287) DeepSeek Chat Completions rejects the developer role. Rewrite developer messages as system messages before sending them upstream; the Responses API accepts developer and is left unchanged.
* feat(payment): 易支付支持 RSA 签名方式 支付设置新增「签名方式」,可在 MD5 与 RSA 之间二选一。默认 MD5,已配置 MD5 的站点升级后行为不变。 - RSA 模式用商户私钥签名下单请求,跳转 /api/pay/submit;充值和订阅回调用平台公钥验签,MD5 签名的回调会被拒绝 - 保存时校验密钥:RSA 生效期间商户私钥和平台公钥必须能解析,切换到 RSA 前要先保存两把密钥;读取设置时不返回密钥 - 设置页选择 MD5 时只显示商户密钥,选择 RSA 时显示商户私钥和平台公钥;七种语言补齐文案 - go-epay 升级到 v0.0.6 * refactor(payment): 易支付签名设置改用 payment_setting 注册配置 签名方式、商户私钥、平台公钥改为 PaymentSetting 的字段,键名为 payment_setting.epay_sign_type、payment_setting.epay_merchant_private_key、payment_setting.epay_platform_public_key,由配置管理器统一加载和保存,不再在 option.go 里逐项初始化和赋值。 - 保存校验移到 operation_setting.ValidateEpaySignOption,规则不变 - 读取设置时不返回以 private_key 结尾的配置项;平台公钥可以正常显示和修改
* fix(channels): reset model redirect sync state when switching channels * fix(channels): rebase batch redirect sync on current mappings and add regression tests
- moejs 迁到 github.com/MoeForge/moejs v0.1.0,Dockerfile、Electron 构建与发布流程的 PGO 路径同步更新;发布附带 THIRD-PARTY-LICENSES.md,并补充 moejs 附带的第三方声明。 - moego 升级到 v0.1.0-alpha.2:宿主 JSON 编解码经 common/kitutil 封装改用 moego/json,根模块和 relaykit 生产代码的 regexp 改用 moego/regexp。 - 内存中的请求体由校验器零拷贝解析;磁盘缓存的请求体经独立文件读取器解码,且只接受一个 JSON 值,尾随内容会被拒绝。 - 模型/分组提取与重复 model 键检测、渠道亲和 JSON 路径、任务协议 stream/background 标志、multipart 解析在磁盘模式下不再把整份请求体读进内存。图片透传直接转发已存储的请求体,并校验最终发往上游的 n。 - 出站请求体各自持有读取位置。此前透传重试共用存储游标,上一次尝试仍在发送时,下一次尝试可能发出残缺的请求体。收到响应头后不再提前关闭请求体,避免中断仍在发送的请求体。 - 表达式计费只在表达式使用 param() 时冻结请求体,其余情况不再读取并保留整份请求体。
…marketplace (QuantumNous#8271) * feat(plugins): add provider plugins, request plugins and a community marketplace - Provider plugins turn an upstream vendor into a channel type: routes, protocol conversion, models, static keys, sign-in flows with token refresh, balance queries, per-channel config and a scheduled hook. - Request plugins run on requests and replies (ingress, request, outbound, egress, reply, report), with instances by scope, model ranges, dry runs and per-log records. Built-ins: request filter, request redaction, parameter override, auto reasoning effort, image compression and content moderation. Sensitive words move into a request filter instance on first start. - Node sync: a system_sync_topics table lets every node reload settings, channels, plugins and other data within seconds, and the system info page shows each node's state. - Marketplace: a community source next to the official one, lookup by plugin code for official and community plugins, key rules for community plugins, install counts and takedown warnings. * docs(plugins): name request protocols and host-only members in the plugin API - Protocol names: ctx.format and samples use relaykit's protocol names. The spec lists the client paths and body of each name, so every host passes the same names to plugins. - Host-specific members: channel, group, user, token, channelTypes, channelOther and utils.paramOverride exist only on new-api. The types mark them optional. - Relay routes: the spec now writes out the route keys and the converters each incoming path accepts. The schema lists the converter names. * feat(plugins): show recommended plugins from the official list too The site now marks official plugins as recommended in its index. The built-in official and community lists both get a Recommended group; lists added by the administrator still cannot recommend plugins. * feat(plugins): fall back to www.newapi.pro when www.newapi.ai does not answer Plugin lists, plugin files and logos from www.newapi.ai are downloaded from www.newapi.pro, the mainland China site, when newapi.ai gives no answer within 10 seconds; the browser remembers this for a day. The marketplace toolbar has a download site picker: Auto, or Mainland China to always use www.newapi.pro. Saved source addresses stay on newapi.ai, and every file is still checked against its sha256. Community install counts go to newapi.ai first and to newapi.pro when newapi.ai cannot be reached. * fix(plugins): leaving the page does not switch the plugin site to www.newapi.pro Reloading or leaving the marketplace cancels requests still running. That was read as www.newapi.ai not answering, so the browser moved to www.newapi.pro for a day although newapi.ai was reachable. Requests cut off by leaving the page are no longer counted. * feat(plugins): choose the plugin download site by hand The marketplace no longer switches between plugin sites by itself. The toolbar menu lists the main site www.newapi.ai, the backup site www.newapi.pro and the other plugin lists; picking an entry is the only thing that changes where plugins are downloaded from, and the main site can always be picked again. A browser that the earlier automatic switch had moved to www.newapi.pro opens on the main site again. The download site, the source choice and managing sources now share one menu in the list header. * feat(plugins): show plugin usage guides and require README and changelog Every marketplace plugin version now ships a usage guide, README.md, and a changelog, CHANGELOG.md, next to plugin.js. The install dialog shows the guide in the reader's language when a translation is listed, falls back to English, and links to the source file. A guide or changelog that breaks the format is reported with its file, line and rule instead of being shown. The plugin API document describes both formats, the translations they may list, and the checks the community marketplace runs before it accepts a version: readme_missing, readme_invalid, changelog_missing and changelog_invalid. Versions accepted before these checks are not checked again. * fix(plugins): address review findings on plugin parts, limits and access - Only the root user reads request plugin instance configs; an admin who may bind instances to channels gets them without configs. - Outbound hooks that grow the body are held to MAX_REQUEST_BODY_MB, as ingress hooks are, and answer 413 without a retry. - An admin who cannot read plugin options keeps the balance and model list actions on plugin channels; the server answers whether they work. - Reading the parts of a plugin source gives up when the source does not parse or code elsewhere refers to meta, as the meta preview does. * fix(plugins): address review findings on request processing, documents and node sync - PDF checks resolve indirect parameters and bound every value the parser allocates or loops on: predictor columns, object stream counts, nested object streams, cross-reference streams and ToUnicode ranges. Font and CMap work checks the deadline. - A WebP frame must match its declared canvas, and keyword search stops at its match limit. - Request processing treats a body as JSON whenever the gateway parses it as JSON, keeps Gemini reply parts in place, scopes instances by the settled auto group, hides channel header overrides from plugin param overrides, and captures replies only for report instances in scope. - Request processing no longer follows the plugin master switch, which now covers plugin tasks and channels only. - json.patch copies stop at MAX_REQUEST_BODY_MB, and provider prepareRequest effects past it answer 413. - Image billing reads the count from the final upstream body, including the count members of SiliconFlow, Imagen and Replicate and the Imagen default. - Automatic channel status changes no longer reload every node's channel cache. A credential refresh holds no channel lock while it waits on the vendor. A key that needs login is disabled and the request can retry. - Balance requests must go to the channel host or allowedHosts, and provider stream events a plugin drops keep the stream alive. - Node sync: OAuth provider writes bump inside their transaction, a failed startup load is retried, and each node is judged by its own topics. - request-filter checks the text the old sensitive-word check did, request-redact and content-moderation handle large inputs, and image-compress lossless mode leaves JPEG and WebP alone. * fix(plugins): address the second review on balances, egress and routes - Channel other_info writes (status changes, balance queries and manual multi-key actions) only land while other_info is still the value read, and retry otherwise, so a write on one node no longer overwrites another node's balance or status reason. They write only their own columns. - On the Responses path egress reads the body after the channel finalizes it, which is the body sent upstream. - The Vertex AI plugin picks the region by the model the client asked for, as the built-in Vertex AI channel does. - /request-processing and /security are reserved route namespaces, and a test checks that every console page is reserved. - The plugin API docs say what egress reads on a provider plugin channel. * feat(channels): run the balance update as a system task with progress "Update all balances" now queues a channel_balance system task instead of starting a goroutine guarded by an in-process flag. The task row holds the progress (enabled channels queried of total), so any node can answer it, and its active key keeps one run at a time across nodes. The CHANNEL_UPDATE_FREQUENCY schedule becomes the same task's schedule, so manual and scheduled runs no longer overlap. GET /api/channel/update_balance answers with the task id, and with the running one when a run is already queued. GET /api/channel/update_balance/task/:task_id, under the same channel permission, returns the status, progress and failure of balance update tasks only. The channel list follows the task, reloads as more channels are queried and once more at the end, and reports how the run ended. * feat(system): sync nodes through system tasks and clean up task history Node sync no longer needs its own table. A write to synced data adds a pending sync_<topic> system task. Every node polls the newest task of each topic it keeps every 3 s and reloads when that task is newer than the one it applied. Custom OAuth providers still add their task inside the write transaction, and lock the newest task of the topic first, so tasks commit in id order. The master marks a sync task succeeded once every online node that keeps the topic has applied it. Until then the task shows how many nodes have applied it and why the others have not. The system_sync_topics table is gone. A composite (type, id) index answers the newest task of a type from the index. The latest-per-type and earliest-pending queries now read ids first, because MySQL 5.7 scanned the whole table for them. A daily system_task_cleanup task deletes finished system tasks older than system_task_setting.retention_days (default 30, at least 1), in batches. It never deletes active tasks or the newest task of any type. The retention is set under Operations > Log maintenance.
The Vertex AI plugin now reads the channel deployment region (QuantumNous#8271), which the published 1.3.0 does not. Give that code its own version so the built-in plugin matches the marketplace again.
Upgrade frontend dependencies, keeping the newer of this branch's targets and main's versions. - Notable upgrades: motion 13, nanoid 6, jsdom 30, @base-ui/react 1.7, lucide-react 1.34, @rsbuild/core 2.2, recharts 3.10.1, shadcn 4.19, react 19.2.8, react-hook-form 7.86, @hookform/resolvers 5.9. - Kept main's pins: dompurify 3.4.17 and katex 0.18.2. - oxlint stays on 1.74: 1.79 splits the React Compiler rule and reports 158 new errors on existing components. - sonner 2.0.8 replays active toasts to a newly mounted Toaster, so the marketplace install dialog test now dismisses toasts between cases.
…#6928) Show live password strength feedback that follows the account password policy (8–128 characters). - Sign-up, change password, setup wizard and the admin user drawer show a strength meter, the length requirement and optional tips for a stronger password. Only the length blocks submission. - Strength is rated mainly by length. Common passwords, one repeated character and straight runs such as 12345678 or qwertyui are marked as easy to guess, but only when they make up the whole password. - The confirmation field says whether the passwords match, and a mismatch is shown only once. - Password fields get a labelled show/hide button and link their hints for screen readers. - Removed the unused 20-character limit and its translations.
…mNous#6955) The notification settings restructure from this branch is already on main (QuantumNous#7868). What remains is a wording fix in the payment compliance notice. - zh, zh-TW, ja, ru, vi and fr now say "super administrator" in the notice that locks payment, redemption codes, subscription plans and invitation rewards, matching the rest of the UI. - fr: replaced the stray Chinese word in "codes de兑换" with "codes d’échange".
…mNous#8320) react-router-devtools 1.167.1 ships router-devtools-core 1.168.1, which calls interpolatePath() with one object, but it resolved the top-level router-core 1.171.34, where interpolatePath takes positional arguments. In dev mode the devtools panel threw "path.endsWith is not a function" on every route change. - Bump @tanstack/react-router to ^1.170.41 and @tanstack/react-router-devtools to ^1.167.2. - The router, the devtools and the router plugin now share one router-core, 1.171.34. - Production builds do not include the devtools.
…#8323) A fieldset's default min-width is its content width, so a long line in the plugin settings JSON editor widened the fieldset past the grid column and pushed the plugin settings out of the channel drawer. Set min-w-0 so the fieldset shrinks with its column and the editor scrolls long lines itself.
…ntumNous#8322) - rc.50 依赖的 moego v0.1.0-alpha.2 只按 AES-NI 选用 hashAES 内核,而该内核是 VEX 编码,需要 AVX。在有 AES-NI、没有 AVX 的 CPU(如 Celeron J4125)上,解析不少于 128 字节的请求 JSON 时进程因 SIGILL 退出,容器反复重启。 - alpha.3 在这类 CPU 上改用 SSE 编码的 AES 指令,结果与其他 CPU 相同。根模块和 relaykit 同步升级,THIRD-PARTY-LICENSES 中的版本号同步更新。 Fixes QuantumNous#8314
The plugin site's marketplace list shows meta.description on one line and cuts longer summaries off with an ellipsis. Measured on the live list at desktop width, the summary column is 572 px at 14 px: 40 Chinese characters fit and 41 do not, and real summaries of up to 80 columns (CJK and full-width punctuation counting as two) all fit. Add a "Plugin summary length" section to the API reference recommending at most 80 columns per locale, with guidance on what to leave to the usage guide, and point the manifest table and the Meta type at it.
把上游 QuantumNous/new-api main(b388140ac,15 个提交)并入 fork-main,保留上游历史。 上游带来插件体系(provider plugins、request plugins、插件市场)、易支付 RSA 签名、 请求体按需流式读取、多节点同步主题等;fork 自有功能全部保留。 冲突 28 个文件:两边各自追加的内容都保留;语言文件以上游文本为准再加回 fork 新增的 key。 HQ-Task: T261113-16 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
上游把全局敏感词检查退役,启动时把词表迁到请求过滤插件实例并删除旧选项。 内容审计内置的 default 关键词表原本直接读这份全局词表,合并后已无数据来源: 该表现在为空、不再命中,自建关键词表不受影响。测试随之调整。 HQ-Task: T261113-16 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
上游易支付签名方式测试与 fork 支付网关开关测试各自构造表单默认值, 合并后表单同时要求两边新增的字段,补齐后类型检查与用例恢复通过。 HQ-Task: T261113-16 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
端到端补充结果(HQ-Task: T261113-16)用最终 head
接口抽查(三库的全新实例上,管理员登录后):
升级时观察到的两点:
未做:在浏览器里登录后逐页点开(只做了接口与路由层面的抽查);带真实上游的中转流量。 测试容器、镜像与数据已清理。 |
|
HQ-Review R1 @ 299e7f6: REQUEST_CHANGES 审查范围:只看合并本身( 已核对、没有问题的部分:
需要处理:
其他:
|
上游退役全局敏感词检查后,内容审计里名为 default 的关键词表失去了词表来源。 之前的适配让它恒不命中,只靠内容审计关键词模式做审核的站点升级后会静默失效。 现在升级时先把原敏感词复制成一个名为 default 的普通存储词表,再执行上游的迁移: - 内容审计配置和审核策略规则里对 default 的引用无需改写,升级前会命中的词升级后仍命中, 与旧的全局敏感词开关是否打开无关; - 迁移幂等:旧选项被上游迁移删除后不再执行;已存在同名词表时不覆盖; 复制失败时本次启动不执行上游迁移,词表留到下次启动; - default 不再是内置表,可像其他词表一样编辑、删除;相应移除接口里的 builtin 字段、 失效的报错与界面文案。 HQ-Task: T261113-16 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
HQ-Review R1 处理结果(HQ-Task: T261113-16)新 head 1. [阻塞] 内容审计 做法:升级时把原全局敏感词复制成一个名为
2–4. 非阻塞项:按要求不在本 PR 处理。 验证(
|
升级前(09cca3d97) |
升级后第一次启动 | 第二次启动 | |
|---|---|---|---|
| 含敏感词的请求 | 403 content_moderation_blocked,事件 keyword_block / default |
同左 | 同左 |
| 不含敏感词的请求 | 通过审核,到达上游(测试渠道地址无效,500 do_request_failed) |
同左 | 同左 |
default 词表 |
2 个词(内置) | 2 个词(存储) | 2 个词,未重复复制 |
| 渠道 / 用户 / 令牌 / 公告 | 1 / 2 / 1 / 有 | 不变 | 不变 |
SQLite、MySQL 8.4.13、PostgreSQL 17.12 结果一致。升级日志依次出现“复制 2 个敏感词到关键词表 default”和上游的“敏感词移到请求过滤实例”;上游迁出的那个过滤实例因旧开关关闭而处于停用状态,不影响上面的结果。启动日志里除这两次请求自身的错误外没有其他报错。
- 全新 SQLite 库:启动 200、日志无报错;关键词表列表为空;新建名为
default的词表成功。
未做:浏览器登录后的逐页检查;没有为词表列表界面新增前端用例(现有内容审计前端测试 13 个通过)。
测试容器、镜像与数据已清理。
|
补充(HQ-Task: T261113-16):fork-main 合入 #47 后与本分支在 en、zh 两个语言文件上冲突,已把 在 |
|
HQ-Review R2 @ 849e0b6: APPROVE 本轮只审 R1 之后的两个提交: R1 第 1 项(升级后 逐项核对(a8def85d9):
849e0b6(并入 fork-main):remerge-diff 只在 测试(本机 Windows,git archive 导出 849e0b6 的代码): 不阻塞的意见:
结论:R1 的阻塞项已修复,两个新提交没有引入阻塞问题。本结论只适用于 849e0b6;按 B 级规则,合并需要用户批准。 |
用户目标:先把 fork 同步到上游最新,再做后续功能与向上游贡献。
HQ-Task: T261113-16
本 PR 由 AI(Claude Code)生成。请用普通合并提交合并(不要 squash),以保留上游历史。
内容
mainb388140ac(15 个提交:插件体系 feat(plugins): add provider plugins, request plugins and a community marketplace QuantumNous/new-api#8271、易支付 RSA feat(payment): 易支付支持 RSA 签名方式 QuantumNous/new-api#8291、请求体按需流式读取 perf: 升级 MoeForge moejs/moego,请求体按需流式读取 QuantumNous/new-api#8311、多节点同步主题等)并入fork-main。合并提交e2c79a519(父09cca3d97+b388140ac)。83fdd4e80(feat(system): 多站点地址访问控制台 (HQ-Task T261113-11) #42、feat(subscriptions): 绑定时自动启用手动禁用的 OAuth 渠道,释放时恢复禁用;Codex OAuth 失败显示错误码 (HQ-Task T261113-10) #43),已再合入(299e7f626),只有 7 个语言文件冲突。45a2e656b与a8def85d9(内容审计 default 关键词表,后者为最终做法)、a19af8e7f(两个支付设置测试补字段)。冲突解法(28 个文件)
constant/api_type.go(fork 的 ClaudeOAuth 在前,值不变;上游 ProviderPlugin 在后,均不落库)、controller/channel_authz.go、i18n/keys.go、i18n/locales/{en,zh-CN,zh-TW}.yaml、common/log_text.zh-CN.json、main.go、model/system_task.go、setting/operation_setting/payment_setting.go、service/openai_chat_responses_mode.go、web/src/features/system-info/constants.ts、web/src/hooks/use-sidebar-data.tscontroller/channel.go:上游新的密钥更新流程 + fork 的自动重置配置保留与复制时清空成本字段controller/codex_usage.go:保留 fork 重写的实现service/codex_credential_refresh.go:fork 的持久化 + 上游的同步主题通知model/channel.go:字段两边都留;Update/UpdateChannelStatus用上游新签名并保留 fork 的冷却清除model/channel_constraint.go:上游的插件中转判断 + fork 的 body_rewritten 过滤model/option.go:上游易支付签名校验 + fork 的发信/审计选项校验;随上游移除敏感词选项channel-mutate-drawer.tsx、model-price-cell.tsx:两边逻辑合并上游退役敏感词检查后的处理
上游退役了全局敏感词检查(启动时把词表迁到请求过滤插件实例并删除旧选项)。内容审计里名为
default的关键词表原本直接读这份词表。提交a8def85d9在上游迁移之前先把原词表复制成一个名为default的普通存储词表,配置与审核策略规则里对它的引用不用改,升级前会命中的词升级后仍命中;default之后可像其他词表一样编辑、删除。验证见评论。验证
以下在
299e7f626上运行,a8def85d9上已全部复跑并通过(见评论)(macOS arm64 原生,Go 1.26.10,Bun 1.4.4):make test:63 个包 ok、0 失败(根模块 +relaykit+tokenkit);relaykit、tokenkit各自GOWORK=off go build ./...通过。bun install --frozen-lockfile通过;bun run typecheck通过;bun run test275 个文件 / 3095 个用例全过;bun run build通过。go test有 controller、middleware、relay/channel 等包失败,属该环境已知问题,上面的 macOS 结果为准。45a2e656b构建):/api/status200,启动日志无 error/panic;登录后渠道列表、插件列表(17 个)、插件市场源、插件运行状态、请求插件实例、提示词审计配置、审核策略、内容审计配置与关键词表、选项、用户、令牌接口均返回成功。09cca3d97构建在 SQLite、MySQL 8.4.13、PostgreSQL 17.12 上各起一个实例并建好数据(一个渠道、一个用户、一个令牌、敏感词与公告选项),启动日志无报错。