dsh-newapi-provider 0.0.0-stage → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zenVibeCoding
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/PUBLISHING.md ADDED
@@ -0,0 +1,130 @@
1
+ # 发布清单(维护者用)
2
+
3
+ 本文件是 `dsh-newapi-provider` 的发布材料。**npm 发布、仓库转公开、插件市场投稿都需要人工确认后单独执行**,自动化流程不代替这三步。
4
+
5
+ ## 当前状态(2026-10-23)
6
+
7
+ | 项目 | 状态 |
8
+ | --- | --- |
9
+ | 版本 | 0.8.1(未发布) |
10
+ | 包名 | `dsh-newapi-provider` — npm 上仍是 404,名称可用 |
11
+ | 仓库 | https://github.com/zenVibeCoding/dsh-newapi-provider (公开,已加 `dsh-plugin` topic) |
12
+ | 许可证 | MIT,作者 `zenVibeCoding` |
13
+ | 验证环境 | DSH 0.2.1-rc.2 / Node.js 22.19+,`engines.dsh: >=0.2.1-rc.1 <0.3.0-0` |
14
+ | 离线测试 | `npm test`,103 项全过 |
15
+ | 打包 | 19 个文件,无凭据/本机路径 |
16
+ | 真实生图 | **未验证**(网关返回 503 无可用渠道) |
17
+ | 真实视频 | **未验证**(无视频渠道),工具为实验性 |
18
+
19
+ ## 发布前必须完成
20
+
21
+ 1. **在网关侧配好至少一个可用的生图渠道**,跑通一次真实生图并确认附件落盘。
22
+ 2. 如能取得视频渠道,跑通一次「提交 → 轮询 → 下载 → 附件」。
23
+ 3. 在连接的 DSH 窗口检查设置页三个标签、渠道编辑弹窗、模型编辑弹窗的实际观感。
24
+ 4. 更新 README「当前验证范围与限制」,把已验证项写实,未验证项保持明示。
25
+ 5. 确认版本号与 `client.js` 里 `data-newapi-provider-version` 一致。
26
+
27
+ ## 打包检查
28
+
29
+ ```sh
30
+ npm test
31
+ node --check index.js
32
+ node --check client.js
33
+ npm pack --dry-run --ignore-scripts
34
+ ```
35
+
36
+ 预期:19 个文件,只含 `index.js`、`client.js`、`lib/*.js`、`cordis.patch.yml`、`locale/*.json`、`icon.svg`、`README*.md`、`PUBLISHING.md`、`LICENSE`、`package.json`。
37
+
38
+ **不得包含**:`test/`、`node_modules`、`docs/`、个人网关地址或令牌、`.credentials*`、调研笔记(`~/dsh-newapi-plugin`)、会话截图。发布前自查:
39
+
40
+ ```sh
41
+ npm pack --dry-run --ignore-scripts 2>&1 | grep -Ei 'credential|secret|sk-|/Users/'
42
+ ```
43
+
44
+ ## 第一步:npm 发布
45
+
46
+ 当前 `npm whoami` 报 `ENEEDAUTH`,需要先登录:
47
+
48
+ ```sh
49
+ npm login # 浏览器 OAuth;或 npm login --auth-type=legacy
50
+ npm whoami
51
+
52
+ cd ~/dsh-newapi-provider
53
+ git status --short # 应为干净
54
+ npm view dsh-newapi-provider version # 期望 404
55
+
56
+ npm publish --access public # 开了 2FA 会提示 --otp <code>
57
+ ```
58
+
59
+ 发布后立刻验证(不要只看 npm 网页缓存):
60
+
61
+ ```sh
62
+ npm view dsh-newapi-provider version # 期望 0.8.1
63
+ npm view dsh-newapi-provider dist.tarball
64
+ ```
65
+
66
+ 装一次真实回归(用临时 profile 或先卸载本地 link 安装):
67
+
68
+ ```sh
69
+ dsh plugin add dsh-newapi-provider # 走 npm 而非本地目录
70
+ ```
71
+
72
+ - 包名已被占用时不要硬发,先定后缀(如 `dsh-newapi-provider-community`)并同步 README、`cordis.patch.yml`、locale 标题。
73
+ - 之后发新版只改版本号 → 提交 → `npm publish`,不要复用已发布的版本号。
74
+
75
+ ## 第二步:插件市场投稿
76
+
77
+ 已核对 `awesome-dsh-plugin` 的 [contributing.md](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin/blob/main/contributing.md),规则如下:
78
+
79
+ - **一个文件就是全部投稿**:PR 新增 `data/plugins/<owner>__<repo>.yml`,不要手改 README(README 由脚本生成)。
80
+ - 只有 `description.en` 必填,中文描述可选(缺了维护者会补)。
81
+ - 仓库 `package.json` 必须声明 `dsh.bundle`(本仓库有 `{"bundle":{"patch":"./cordis.patch.yml"}}`)。
82
+ - 仓库需含真实可用代码;**创建满 1 天**(CI 自动查)。
83
+ - 仓库需加 `dsh-plugin` topic(已完成)。
84
+ - 描述必须属实,不带营销词;分类要贴合实际功能。
85
+
86
+ **时间门槛**:仓库创建于 2026-10-23 07:01 UTC,需满 24 小时,即 **2026-10-24 15:01(东八区)之后**再提 PR。
87
+
88
+ 投稿文件内容(保存为 `data/plugins/zenVibeCoding__dsh-newapi-provider.yml`):
89
+
90
+ ```yaml
91
+ url: https://github.com/zenVibeCoding/dsh-newapi-provider
92
+ name: zenVibeCoding/dsh-newapi-provider
93
+ category: model
94
+ description:
95
+ en: 'New API gateway provider: multi-channel models with context and modality details, quota, and image and video generation.'
96
+ zh: 'New API 网关提供商:多渠道模型管理与上下文/多模态标注、额度查询,以及生图与视频生成。'
97
+ ```
98
+
99
+ > 描述里有 `: ` 必须加引号,否则 YAML 解析失败。
100
+
101
+ 提交步骤:
102
+
103
+ ```sh
104
+ gh repo fork awesome-dsh-plugin/awesome-dsh-plugin --clone
105
+ cd awesome-dsh-plugin
106
+ # 写入上面那个 yml(文件名必须是 owner__repo.yml)
107
+ git checkout -b add-dsh-newapi-provider
108
+ git add data/plugins/zenVibeCoding__dsh-newapi-provider.yml
109
+ git commit -m "Add dsh-newapi-provider"
110
+ git push -u origin add-dsh-newapi-provider
111
+ gh pr create --fill
112
+ ```
113
+
114
+ 分类备选:`model`(模型接入,最贴合)。若维护者认为更偏 UI,会直接改,不会打回。
115
+
116
+ ## 其他收录入口
117
+
118
+ 除了主列表,还有几个市场会自动抓取带 `dsh-plugin` topic 的仓库(如 `dsh-market`、`bradeGithub/DSH-Plugins-Marketplace` 等),加了 topic 后通常会被自动收录,无需逐个投稿。以各仓库说明为准。
119
+
120
+ ## 版本与兼容
121
+
122
+ - 语义化版本:破坏性配置变更升 minor 前,先写迁移说明(参考 README 的 v0.7.0 改名章节)。
123
+ - 路由 id 一旦发布就不要随意更改:改动会让已有会话失去模型选择。
124
+ - 数据结构变更(`channels`、`enabledModels`、`models`)必须保持向后兼容,或在 README 写清迁移步骤。
125
+
126
+ ## 已知未完成项(可写进「限制」)
127
+
128
+ - 旧令牌在轮换后仍保留在凭据库,需要「无进行中视频任务引用」的清理规则。
129
+ - 重启后视频任务不会重新唤醒发起它的对话。
130
+ - 部分历史样式未被使用,可在发布前清理。
package/README.md CHANGED
@@ -1,3 +1,126 @@
1
- # Temporary Holding Version
1
+ # New API Provider
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ English · [中文](README.zh.md)
4
+
5
+ A New API gateway workbench for DeepSeek Harness: several gateways with one active at a time, per-gateway model lists and parameter overrides, quota, and image and experimental video generation. **Development build; not published to npm yet.**
6
+
7
+ ![Settings → New API Provider: gateways and connections](docs/screenshots/channels.png)
8
+
9
+ ## Preview
10
+
11
+ | Model capabilities | Fetch models |
12
+ | --- | --- |
13
+ | ![Per-gateway model list with vendor marks, context/output limits, modalities and test results](docs/screenshots/models.png) | ![Fetch models dialog grouped by kind, with new / added / removed-upstream states](docs/screenshots/discover.png) |
14
+ | **Model editor** | **Sidebar quota** |
15
+ | ![Model editor: display name, upstream mapping, context window, output cap and input modalities](docs/screenshots/editor.png) | ![Active gateway's quota at the sidebar foot](docs/screenshots/sidebar.png) |
16
+
17
+ The screenshots render this plugin's real components and stylesheet with sample data; gateway names, URLs and amounts are examples. The UI follows the DSH theme, so colours adapt to your skin and dark mode.
18
+
19
+ ## Features
20
+
21
+ - Save multiple gateways and activate exactly one. Each keeps its own URL, credential reference, model list and model overrides.
22
+ - Channel-scoped model management: fetch what a gateway lists, choose which models appear in DSH, test one model, remove with undo, add models the gateway does not list.
23
+ - Capability data from models.dev (context window, output cap, modalities, reasoning), correctable per model, with an optional per-model upstream name mapping.
24
+ - Token quota plus account balance when the token is allowed to query it; unlimited tokens show used quota instead of a negative remainder.
25
+ - Generate images as durable DSH attachments; experimental video through the unified `/v1/videos` interface with background polling and restart recovery.
26
+
27
+ ## Requirements and local installation
28
+
29
+ Verified runtime: **DSH 0.2.1-rc.2**, Node.js 22.19+. Install the local project directory with DSH's plugin manager, refresh the page, then open **Settings → New API Provider**. No separate web server is needed. Do not install this name from npm before it is published.
30
+
31
+ This replaces, rather than depends on, `dsh-gateway-provider`; two adapters cannot own the same provider route. The development installation uses the `newapi-provider` route.
32
+
33
+ ## Migrating from the former name (v0.7.0)
34
+
35
+ The plugin was called `dsh-newapi-studio`. The rename covers the package, the loader row and provider route (`newapi-provider`), the HTTP prefix (`/newapi-provider/api/`) and the data directory (`plugin-data/dsh-newapi-provider`).
36
+
37
+ To migrate an existing installation, back up the profile patch and plugin data, then keep each channel's id, credential reference, model list and overrides while moving the data directory to the new name. This release does not read the old directory automatically. Keep existing credential references even if they contain `STUDIO`: they still hold the working tokens; new references use the `NEWAPI_PROVIDER_` prefix.
38
+
39
+ Sessions pinned to the old `newapi-studio` route must pick models again under the new route. Other adapters are unaffected. Tool names (`newapi_channels`, `newapi_models`, …) did not change.
40
+
41
+ ## Gateways
42
+
43
+ 1. **Add gateway**: name, site URL and a New API calling token.
44
+ 2. **Test connection** reads the model list only and does not make paid model calls; it also shows the gateway version and model counts.
45
+ 3. **Activate** switches every subsequent call made through this plugin, or tick "activate after saving".
46
+ 4. Switching never rewrites other adapters or your default provider.
47
+ 5. Submitted video tasks keep their originating gateway and are never polled on a newly activated one.
48
+
49
+ Legacy flat `baseURL` / `apiKeyEnv` settings are still readable and are migrated to `channels` on the first settings-page save. Tokens live only in the DSH credential service: they are never echoed to the browser, never written into gateway configuration, never sent to a changed address without being re-entered, and are redacted from errors. Configuration writes carry a revision, so a stale editor gets a conflict instead of overwriting another window.
50
+
51
+ ## Balance
52
+
53
+ - Quota comes from `GET /api/usage/token/` (note the trailing slash).
54
+ - Amounts are converted with `/api/status` (`quota_per_unit`, `quota_display_type`, `usd_exchange_rate`), never the top-up price.
55
+ - A token that allows user-quota queries also reports the account balance.
56
+ - Both numbers are the site's own; a present catalog or balance does not prove an upstream channel can serve a model.
57
+
58
+ ## Per-gateway model lists
59
+
60
+ Each gateway keeps an independent list, even when two gateways point at the same site with the same token:
61
+
62
+ - **Model capabilities tab** has a gateway picker; the active gateway is marked and its list edits apply to that gateway only.
63
+ - **Fetch models** reads the gateway catalog with a search box plus status (new / added / removed upstream) and kind filters; filtering only changes what is listed, never the current selection. The list scrolls on its own and the action bar stays in view.
64
+ - **Remove** only removes the model from this gateway; custom parameters can be kept and the removal can be undone briefly.
65
+ - **Add manually** is for models the gateway can serve but does not list.
66
+ - Gateways created in this version start with an empty list; channels saved before the feature existed stay in automatic mode (all gateway models) until their first edit, which materialises the list from what the gateway currently lists.
67
+
68
+ ## Testing models
69
+
70
+ - **Chat models**: one minimal streaming request. The result remembers success, total latency, first packet time and a redacted error. A stream that only sends `[DONE]` counts as a failure, because it carries no protocol response.
71
+ - **Image/video models**: a real generation, so each test asks for confirmation first. Image tests show a preview when the URL is safe to embed; a signed URL is recorded as generated without exposing it.
72
+ - **Batch test** covers the chat models currently filtered, three at a time. Stopping prevents queued requests; requests already sent still finish and may be billed.
73
+ - Tests are billed requests: chat tests send a tiny completion, image/video tests generate.
74
+
75
+ ## Model names and mapping
76
+
77
+ - **Local model id**: the stable id used by sessions and the model list; never changed by the editor.
78
+ - **Display name** (`name`): label only.
79
+ - **Upstream model name** (`upstreamModel`): the `model` actually sent. Empty means the local id. Mapping is one hop and applies to chat, image generation, image edits, video and model tests.
80
+ - The editor previews the mapping, resolves automatic protocol/capabilities/pricing from the mapping target, and lets input modalities and reasoning follow the catalog or be pinned. Reset clears every override including the mapping.
81
+
82
+ Capability data is a hint, not proof: a relay may list a model and still fail to serve it. DSH chat currently accepts text and image input only; PDF, audio and video tags are informational.
83
+
84
+ ## Tools
85
+
86
+ | Tool | Purpose |
87
+ | --- | --- |
88
+ | `newapi_balance` | Quota of the active gateway's token (and account, when allowed). Free. |
89
+ | `newapi_models` | Models of a gateway (`channelId` optional, defaults to active) with kind, limits, modalities, pricing, mapping. Free. |
90
+ | `newapi_channels` | `list`, `test`, `save`, `activate`, `delete`, `model_override`, `models_discover`, `models_set`, `model_test`. Writes need a revision. |
91
+ | `newapi_image_generate` | Text-to-image, or image editing when `inputImages` is given. Saves attachments. |
92
+ | `newapi_video_generate` | Submits a video task and returns its id. Billed per task. |
93
+ | `newapi_video_status` | Lists or checks video tasks and returns the saved file. |
94
+
95
+ Settings-page actions and these tools share one service, so nothing can drift between the UI and the agent.
96
+
97
+ ## Paid results (v0.7.1)
98
+
99
+ - A video submission that loses the connection or returns an unreadable body after HTTP 200 is reported as **submission unknown, possibly billed**, and is never resent automatically.
100
+ - A video that finished upstream but failed to download stays **generated, retrying download**. Only GET requests are retried, against refreshed URLs; when the recovery deadline passes it becomes **generated, download unsuccessful**. Do not regenerate.
101
+ - Concurrent status checks of one task share a single flow, and unloading the plugin aborts in-flight requests so a stale instance cannot overwrite the new cache.
102
+ - Failed paid requests are never retried automatically.
103
+
104
+ ## Verification status
105
+
106
+ - Real chat, model discovery, quota and per-channel lists have been exercised against a local New API instance.
107
+ - A real image request was rejected with HTTP 503 (no available upstream channel). Successful paid image generation is therefore **not yet verified**; the attachment pipeline is covered by offline tests.
108
+ - Video is **experimental**: no real video channel was available. Submission, polling, download recovery, restart recovery and duplicate-submission prevention are covered offline only.
109
+ - The settings page has been rendered and checked locally against the plugin stylesheet; final visual acceptance requires the connected DSH window.
110
+
111
+ ## Development
112
+
113
+ ```sh
114
+ npm test
115
+ node --check index.js
116
+ node --check client.js
117
+ npm pack --dry-run --ignore-scripts
118
+ ```
119
+
120
+ DSH runtime imports are optional peerDependencies supplied by the host, so no DSH package is installed or copied here. Tests use local fake gateways and never read personal credentials.
121
+
122
+ npm publishing, creating a public repository and marketplace submission are separate manual steps; see [PUBLISHING.md](PUBLISHING.md). Keep personal gateway data, credentials, research notes and session screenshots out of the package.
123
+
124
+ MIT License. Uses public DSH exports and pi-ai protocol implementations; no third-party plugin source is vendored.
125
+
126
+ Vendor marks in the model list come from [LobeHub Icons](https://github.com/lobehub/lobe-icons) (`@lobehub/icons-static-svg` 1.97.0, MIT License), inlined as SVG so the page makes no remote image requests. Brand marks belong to their respective owners and only identify a model's vendor.
package/README.zh.md ADDED
@@ -0,0 +1,142 @@
1
+ # New API Provider
2
+
3
+ [English](README.md) · 中文
4
+
5
+ DeepSeek Harness 的 New API 渠道与模型工作台。**开发中,尚未发布到 npm。**
6
+
7
+ ![设置 → New API 提供商:渠道与连接](docs/screenshots/channels.png)
8
+
9
+ ## 效果预览
10
+
11
+ | 模型能力 | 获取模型列表 |
12
+ | --- | --- |
13
+ | ![按渠道独立的模型清单:厂商图标、上下文/输出上限、输入能力与测试结果](docs/screenshots/models.png) | ![获取模型列表:按类型分组,区分新增 / 已添加 / 网关已下架](docs/screenshots/discover.png) |
14
+ | **模型参数编辑** | **侧栏额度** |
15
+ | ![模型编辑器:显示名称、上游映射、上下文窗口、最大输出与输入能力](docs/screenshots/editor.png) | ![侧栏底部显示当前激活渠道的额度](docs/screenshots/sidebar.png) |
16
+
17
+ 截图使用插件真实的组件与样式渲染,数据为示例(渠道名、地址、金额均为虚构)。界面跟随 DSH 主题,配色会随你的皮肤和深色模式变化。
18
+
19
+ ## 能做什么
20
+
21
+ - 保存多个网关,每个渠道独立保存地址、凭据引用与模型参数;一次只激活一个。
22
+ - 在「渠道与连接」中新增、编辑、测试、激活和删除渠道。
23
+ - 查询令牌的剩余额度和已用量;无限额度显示累计已用,不展示无意义的负余额。
24
+ - 从网关发现模型,从 models.dev 补充上下文、输出上限和输入/输出能力。
25
+ - 在「模型能力」中搜索模型,直接编辑上下文、输出上限、模型类型、输入能力与显隐。
26
+ - 生图工具返回 DSH 图片附件;视频工具使用统一 `/v1/videos` 接口后台轮询。
27
+
28
+ ## 环境与安装
29
+
30
+ 目前验证环境为 DSH **0.2.1-rc.2**,Node.js 22.19 或以上;Web 与 Desktop 配置页通过 DSH 原生插槽显示。不需要单独启动网页服务器。
31
+
32
+ 通过 DSH 的插件管理工具安装本地项目目录。安装后刷新现有 DSH 页面,打开「设置 → New API 提供商」。未发布到 npm 前不要直接执行 `npm install dsh-newapi-provider`。
33
+
34
+ 本插件不依赖 `dsh-gateway-provider`。若需要保留旧会话的 provider 名称,可使用相同的 `providerId`,但不能让两个适配器占用同一路由。当前开发安装保留独立的 `newapi-provider` 路由。
35
+
36
+ ## 从旧开发名称迁移(v0.7.0)
37
+
38
+ 旧名称为 `dsh-newapi-studio`。此版本统一改为 `dsh-newapi-provider`:配置行与模型路由为 `newapi-provider`,HTTP 接口为 `/newapi-provider/api/`,数据目录为 `plugin-data/dsh-newapi-provider`。
39
+
40
+ 已有安装迁移时需先备份配置和数据,再保留各渠道的 ID、凭据引用、模型清单及覆盖参数,将旧数据目录迁移至新名称。不要直接新装后丢弃旧配置;本版本不自动从旧目录读取。既有凭据引用即使含有 `STUDIO` 也应保留,新建引用使用 `NEWAPI_PROVIDER_` 前缀,无需复制令牌。
41
+
42
+ 使用旧 `newapi-studio` 路由的会话需要重新选择新路由下的模型;其他适配器不受影响。工具名 `newapi_channels`、`newapi_models` 等保持不变。
43
+
44
+ ## 渠道管理
45
+
46
+ 1. 点击「添加渠道」,填写名称、New API 站点地址与调用令牌。
47
+ 2. 「测试连接」只查询模型目录,不产生生成费用;能列出模型不代表上游渠道实际可调用。
48
+ 3. 保存后点击「激活此渠道」,或勾选「保存后激活」。
49
+ 4. 切换影响所有通过本插件路由发起的后续调用,不修改官方适配器或其他插件。
50
+ 5. 已提交视频任务保持原始渠道,不应转向新激活的网关轮询。
51
+
52
+ 现有单渠道 `baseURL` / `apiKeyEnv` 配置可继续读取;第一次在页面保存渠道时迁移到 `channels` 数组。凭据只经 DSH 凭据服务读写,不在渠道配置中存明文,也不把已有令牌发回浏览器。
53
+
54
+ 模型覆盖属于渠道;在编辑器里修改参数时,绑定打开编辑器时的渠道。出现配置冲突提示后应刷新再编辑,避免覆盖另一个窗口的修改。
55
+
56
+ ## 额度含义
57
+
58
+ - 主接口为 `GET /api/usage/token/`,注意末尾斜杠。
59
+ - 金额换算使用 `/api/status` 的 `quota_per_unit`、`quota_display_type` 和 `usd_exchange_rate`,不使用充值单价 `price`。
60
+ - 在 New API 为令牌开启「允许查询用户额度」后,较新版本可同时返回账户余额。
61
+ - 这些数字来自站点;模型目录存在、余额可查,都不保证站点已配置可调用的上游。
62
+
63
+ ## 模型清单与测试(v0.3.0 起,v0.6.0 支持按渠道独立)
64
+
65
+ 每个渠道独立维护自己的模型清单,即使两个渠道指向同一个站点、使用同一个令牌也互不影响:
66
+
67
+ - 「模型能力」页顶部有渠道切换器。激活的渠道带标记,编辑只作用于当前选中的渠道。
68
+ - 「获取模型列表」只读取网关目录,可按模型 ID/厂商搜索,并按状态(新增/已添加/网关已下架)和类型(对话/生图/视频/其他)筛选;筛选只影响显示,已勾选的模型不会丢失。列表自身滚动,底部操作栏始终可见。
69
+ - 新增渠道的清单默认为空;旧渠道兼容原自动模式,第一次添加或删除时按网关当前目录物化清单。
70
+ - 删除只影响当前渠道,不删除上游模型;可以保留自定义参数,并短暂提供撤销。刷新不会把删除的模型自动加回来。
71
+ - 「手动添加」适合网关未列出但可调用的自定义模型。已从网关下架的模型会单独标注,不自动删除。
72
+ - 对话模型测试发送一条很短的真实请求,**会产生调用费用**,显示总耗时、首包时间、最近结果和脱敏错误。首包时间不等于首字时间。
73
+ - 生图/视频测试每次需要二次确认,实际产生一个生成任务;视频提交成功只显示「任务已接受」,不等于生成验证通过。
74
+ - 批量测试只针对当前筛选下的对话模型,最多3个并发。停止阻止后续排队请求;已发出的请求仍会完成并可能计费。
75
+ - 当前测试器支持 OpenAI Chat、Responses 和 Anthropic Messages;Gemini专用协议测试会明确提示暂不支持,不会悄悄换协议测试。
76
+
77
+ ## 模型名称映射(v0.4.0)
78
+
79
+ 在模型编辑器的「名称与映射」中,三个名称各司其职:
80
+
81
+ - **本地模型 ID**:会话和已启用清单使用的稳定 ID,不在此处修改。
82
+ - **显示名称**(`name`):只改变 DSH 中的显示。
83
+ - **上游映射模型名**(`upstreamModel`):真实请求中的 `model`,留空使用本地 ID。映射只进行一次,不会递归追踪其他模型的映射。
84
+
85
+ 例如本地模型 ID 为 `my-chat`、显示名称为「主力模型」、映射为网关支持的模型 ID,选择器和会话仍使用 `my-chat`,网关收到映射后的名称。对话、生图、编辑图片、视频及模型测试都使用同一映射。
86
+
87
+ 编辑器显示请求映射预览。自动协议、能力、额度参数和定价优先从映射目标补全,手动覆盖仍然优先;输入能力可选自动或自定义,推理支持也可恢复为跟随目录。恢复默认会清除该模型的全部覆盖,包括上游映射。
88
+
89
+ 当前映射有离线回归覆盖;未对真实上游追加付费映射调用。SDK 的模型专属请求兼容逻辑仍可能依赖本地 ID,所以跨厂商或跨模型系列映射需要检查协议、容量和能力是否合适。
90
+
91
+ ## 模型与多模态
92
+
93
+ models.dev 数据有缓存。精确匹配优先,无法匹配时使用默认值;基础模型匹配、默认值与手动覆盖均在界面标出。切勿把猜测的能力当作网关实测结果。
94
+
95
+ DSH 当前对话接口只支持文本和图片输入。PDF、音频、视频标签表示目录元数据,不能据此直接向 DSH 对话发送这些内容。生图、视频模型供生成工具使用,不作为聊天模型出现。
96
+
97
+ ## 工具
98
+
99
+ | 工具 | 用途 |
100
+ | --- | --- |
101
+ | `newapi_balance` | 查询当前激活渠道的令牌额度(允许时也含账户余额)。免费。 |
102
+ | `newapi_models` | 列出某个渠道的模型(`channelId` 可选,默认激活渠道),含类型、上限、多模态、定价与映射。免费。 |
103
+ | `newapi_channels` | `list`、`test`、`save`、`activate`、`delete`、`model_override`、`models_discover`、`models_set`、`model_test`;写入需要 `revision`。 |
104
+ | `newapi_image_generate` | 文生图;传 `inputImages` 时调用图片编辑接口,结果存为附件。 |
105
+ | `newapi_video_generate` | 提交视频任务并返回任务 ID,按任务计费。 |
106
+ | `newapi_video_status` | 列出或查询视频任务,返回已保存的文件。 |
107
+
108
+ 设置页操作与这些工具共用同一套服务,界面与 agent 不会产生分叉。
109
+
110
+ **生图和视频可能扣费。** 提交结果不确定时不会自动重新提交;请先到网关任务日志核对。停止本地观察任务不代表取消网关端生成或退款。
111
+
112
+ ## 付费结果保护(v0.7.1)
113
+
114
+ - 视频提交在收到响应头后断流、超时或响应不可解析,显示「提交结果未知,可能已计费」;不会自动重发提交。
115
+ - 视频上游已生成、仅下载失败时显示「已生成,等待下载重试」。仅重试 GET 状态/下载,重新获取可能过期的下载链接;下载恢复期限届满则显示「已生成,下载未成功」。不要因此重新生成。
116
+ - 同一任务的并发查询合并为一个请求流程,卸载时中止在途网络请求,防止旧实例覆盖新实例缓存。
117
+ - 模型测试必须有有效协议响应,仅有 `[DONE]` 不算成功。签名图片链接无法安全展示时仍记录已生成,不暴露签名链接;界面明确提示不要因没有预览而重复生成。
118
+ - 本轮只使用离线假网关回归。视频仍属实验性功能,尚无真实视频渠道完成端到端验证。
119
+
120
+ ## 当前验证范围与限制
121
+
122
+ - 对话、目录与额度:已在本地 New API 上验证过。
123
+ - 生图真实调用曾返回 503「无可用渠道」;模拟网关的附件保存链路通过,真实生成成功尚未验证。
124
+ - 视频没有真实上游渠道,只做离线提交、后台轮询、下载、重启恢复与不重复提交测试,属于实验性能力。
125
+ - 页面最新视觉效果仍需在连接的 DSH 窗口确认;不能以插槽注册成功代替视觉验收。
126
+
127
+ ## 开发
128
+
129
+ ```sh
130
+ npm test
131
+ node --check index.js
132
+ node --check client.js
133
+ npm pack --dry-run --ignore-scripts
134
+ ```
135
+
136
+ 无需安装或复制 DSH 官方包;运行时引用通过 optional peerDependencies 声明,由 DSH 宿主提供。测试不依赖真实网关、不读取用户密钥。
137
+
138
+ npm 发布、创建公开仓库和插件市场投稿是独立的人工确认步骤,见 [PUBLISHING.md](PUBLISHING.md)。测试与发布包都不应包含个人网关数据、凭据、调研记录或会话截图。
139
+
140
+ MIT License。使用 DSH 的公开导出与 pi-ai 协议实现,不包含第三方插件的源码副本。
141
+
142
+ 模型列表中的厂商图标来自 [LobeHub Icons](https://github.com/lobehub/lobe-icons)(`@lobehub/icons-static-svg` 1.97.0,MIT License),以内嵌 SVG 形式打包,不发起外部图片请求。各品牌标识归其所有者,仅用于标明模型所属厂商。