dsh-sub2api 0.12.0 → 0.13.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.0
4
+
5
+ - **Out of balance now says so, and where to fix it.** The gateway answers both
6
+ `/v1/models` and `/v1/chat/completions` with `INSUFFICIENT_BALANCE` on a
7
+ zero-balance account, and the plugin passed that raw 403 through — a message
8
+ that reads like a key or permission problem. Measured on a live gateway: 62 of
9
+ 108 accounts carry a zero balance, so this is the single most common reason a
10
+ fresh install cannot talk. It is now a sentence with the next step.
11
+ - The empty conversation screen also warns while the balance is zero, next to
12
+ the existing "not signed in" line, so the wall is visible before the first
13
+ message instead of after it.
14
+
15
+ ## 0.12.1
16
+
17
+ - **An English README.** The plugin list judges language by the share of CJK
18
+ characters, so a Chinese-only README gets flagged as "Chinese only" on the
19
+ detail page — which is the first thing most visitors read. `README.en.md` is
20
+ now the counterpart, linked from both.
21
+ - Screenshots are published for storefronts to surface on the detail page.
22
+
3
23
  ## 0.12.0
4
24
 
5
25
  - **Works with any sub2api deployment, not just the one this plugin ships with.**
package/README.en.md ADDED
@@ -0,0 +1,181 @@
1
+ # dsh-sub2api
2
+
3
+ English | [中文](README.md)
4
+
5
+ Connect a [sub2api](https://github.com/Wei-Shaw/sub2api) gateway to DeepSeek Harness. Install it, sign in once with an email and password, and you are done.
6
+
7
+ **One plugin, two ways to use it:**
8
+
9
+ - **The hosted Psapi gateway** — `sub.svpai.net` is the default, so installing and signing in is all there is to it.
10
+ - **Your own sub2api deployment** — change "gateway address" in the settings to your domain. Everything else is identical: sign-in or sign-up, key provisioning, model sync, balance, recharge, redeem codes.
11
+
12
+ > sub2api is an open-source gateway and plenty of people run their own. This
13
+ > plugin is not tied to any one of them: sign-in, keys, the model catalogue,
14
+ > balance and recharge all go through the gateway's own API, so any deployment
15
+ > that speaks sub2api will work.
16
+
17
+ If your deployment has no pay centre, leave the recharge address empty — balance,
18
+ models and keys keep working, and the recharge card simply does not appear.
19
+
20
+ After installing, open **Settings → dsh-sub2api** and enter an email and password
21
+ once. The rest is automatic:
22
+
23
+ - Existing account: signed in. New email: registered, without leaving DSH.
24
+ - A dedicated key named `dsh` is created on the account and stored in the local credential store.
25
+ - The upstream model catalogue is synced into the model picker — no base URL, API key or model list to type.
26
+ - Balance, usage, subscription, redeem codes, recharge and diagnostics live in one panel.
27
+
28
+ The first conversation needs no manual configuration. If a step did not take
29
+ effect, the panel's **Run diagnostics** names the exact step that failed.
30
+
31
+ ```
32
+ npm: dsh-sub2api https://www.npmjs.com/package/dsh-sub2api
33
+ repo: pscly/dsh-sub2api https://github.com/pscly/dsh-sub2api
34
+ install: dsh plugin add dsh-sub2api requires DSH >= 0.2.2-rc.1, then restart DSH
35
+ ```
36
+
37
+ ![settings panel](https://raw.githubusercontent.com/pscly/dsh-sub2api/main/assets/screenshots/panel.png)
38
+
39
+ ## Three steps
40
+
41
+ 1. Install and restart DSH: `dsh plugin add dsh-sub2api`
42
+ 2. Open **Settings → dsh-sub2api** and enter an email and password
43
+ 3. Pick one of the gateway's models in the picker and start talking
44
+
45
+ No API key, no base URL, no model list to prepare — the account, the key and the
46
+ catalogue all become ready on their own.
47
+
48
+ ---
49
+
50
+ ## What it removes
51
+
52
+ Wiring up a gateway by hand takes four steps: get an account, create a key in the
53
+ dashboard, paste the key into settings, remember the model names. Any one of them
54
+ going wrong is where people stop.
55
+
56
+ | By hand | With this plugin |
57
+ |---|---|
58
+ | Register (sometimes in a browser) | Email and password in the panel |
59
+ | Create an API key and copy it | A key named `dsh` is created for you |
60
+ | Paste the key into settings | Written to the credential store |
61
+ | Type the base URL and model list | Synced from `/v1/models` |
62
+ | Guess what broke | **Run diagnostics** names the failing step |
63
+
64
+ ## Model context windows are measured, not assumed
65
+
66
+ Most OpenAI-compatible gateways return model names from `/v1/models` with **no
67
+ context length at all**, so a client falls back to 128k — and a model that
68
+ actually takes 950k gets shown as 128k, which is what makes long sessions fail
69
+ with a confusing 400 from upstream.
70
+
71
+ This plugin carries measured values for 24 models, and the method is public:
72
+
73
+ - Technical write-up and the full table: [docs/context-windows.md](docs/context-windows.md) ([web version](docs/context-windows.html))
74
+ - The data itself: [`lib/model-registry.js`](lib/model-registry.js), every row tagged `measured` or `open`
75
+ - The scripts that produce it: `scripts/measure-context.mjs`, `scripts/build-model-registry.mjs`
76
+
77
+ Measurements always win over the open registry, because the open registry is
78
+ wrong in both directions for a real gateway — it claimed 922,000 for a model that
79
+ takes 524,288, and 500,000 for one that takes 131,072. Over-claiming is the
80
+ dangerous direction: the client compacts too late and the upstream answers 400.
81
+
82
+ ## Install
83
+
84
+ ### npm (recommended)
85
+
86
+ ```sh
87
+ dsh plugin --profile web add dsh-sub2api
88
+ ```
89
+
90
+ ### From GitHub
91
+
92
+ ```sh
93
+ dsh plugin --profile web add github:pscly/dsh-sub2api
94
+ ```
95
+
96
+ A GitHub install runs build scripts at first use, which pnpm blocks until you
97
+ approve them. If it stops with `ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED`, DSH prints
98
+ the exact line to add under `allowBuilds` in your profile's
99
+ `pnpm-workspace.yaml`; retry after adding it.
100
+
101
+ ### Requirements
102
+
103
+ - DSH `>= 0.2.2-rc.1`
104
+ - A sub2api gateway (the hosted one, or your own)
105
+
106
+ ## Configuration
107
+
108
+ Everything has a working default; you only touch this if you self-host.
109
+
110
+ | Key | Default | Meaning |
111
+ |---|---|---|
112
+ | `apiBase` | `https://sub.svpai.net` | Gateway address; a trailing `/v1` is stripped |
113
+ | `payBase` | `https://pay.svpai.net` | Recharge page. **Empty means "no pay centre"** |
114
+ | `keyName` | `dsh` | Name of the API key created on the account |
115
+ | `visibleModels` | `[]` | Allowlist for the model picker; empty shows everything |
116
+ | `contextWindow` | unset | Force one window for every model |
117
+ | `defaultContextWindow` | `128000` | Used only when nothing else knows the real value |
118
+ | `retries` | `2` | Retries before the first chunk, for dropped connections and 5xx |
119
+
120
+ ## Commands and tools
121
+
122
+ - `/sub2api [status|models|balance|recharge|help]`
123
+ - Tools exposed to the agent: connection status, model list, balance
124
+
125
+ ## How it works
126
+
127
+ The plugin registers one provider route (`sub2api`) and speaks the
128
+ OpenAI-compatible protocol through `@dsh-ai-providers/openai-compatible`, so it
129
+ inherits the harness's own transport behaviour: streaming, idle timeouts, context
130
+ handling and reasoning efforts.
131
+
132
+ Signing in is a two-part flow against the gateway's control API: authenticate,
133
+ then ensure a key exists and belongs to a group. A key without a group is
134
+ rejected by the gateway with `API key is not assigned to any group`, so the
135
+ plugin treats an ungrouped key as one to replace rather than reuse — a login that
136
+ looks successful and fails on the first message is the worst outcome available.
137
+
138
+ Retries only happen **before the first streamed chunk**, so a partially shown
139
+ answer is never repeated. A dropped connection, a 5xx, a rate limit or an empty
140
+ response is retried; a 401, a quota rejection or a context overflow is returned
141
+ immediately, because asking again cannot change those answers.
142
+
143
+ ## Errors you may see
144
+
145
+ ### `还没有登录 dsh-sub2api`
146
+
147
+ The plugin refuses before sending anything, rather than letting a keyless request
148
+ come back as `401 API key is required in Authorization header` — a message about
149
+ credentials, for someone who simply has not signed in. Open Settings and sign in.
150
+
151
+ ### `the endpoint answered 502 Bad Gateway: Upstream service temporarily unavailable`
152
+
153
+ This comes from the gateway, not the plugin: the account pool has no usable
154
+ upstream for that model right now. Check the gateway log:
155
+
156
+ ```sh
157
+ docker logs --since 1h sub2api | grep account_select_failed | tail -5
158
+ ```
159
+
160
+ The counts in the log (`excluded`, `model_not_supported`, `runtime_blocked`) say
161
+ which. Retrying cannot conjure capacity, so the plugin reports it instead.
162
+
163
+ ### A model shows 128k but should show more
164
+
165
+ The gateway did not report a window and the model is not in the measured table.
166
+ Fill it in from the panel, or run the measurement script above.
167
+
168
+ ## Development
169
+
170
+ ```sh
171
+ npm install
172
+ node scripts/link-host.mjs # link the host packages an installed DSH provides
173
+ npm test
174
+ ```
175
+
176
+ Tests are offline: a fake gateway, a fake pay centre and a fake host, so no
177
+ network and no credentials are needed.
178
+
179
+ ## License
180
+
181
+ GPL-3.0-only. See [LICENSE](LICENSE).
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # dsh-sub2api
2
2
 
3
+ [English](README.en.md) | 中文
4
+
3
5
  在 DeepSeek Harness 里接入 [sub2api](https://github.com/Wei-Shaw/sub2api) 网关。装完填一次邮箱和密码就能用。
4
6
 
5
7
  **两种用法,同一个插件:**
Binary file
@@ -0,0 +1,173 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>OpenAI 兼容网关的模型上下文上限怎么测(含 24 个模型实测值)</title>
7
+ <meta name="description" content="多数 OpenAI 兼容网关的 /v1/models 不返回上下文长度,客户端只能按 128k 兜底。这里给出不用文档、直接向服务端问出真实上限的方法,附 24 个模型在 sub2api 网关上的实测结果。">
8
+ <style>
9
+ :root {
10
+ --fg: #1a1d21; --muted: #5b6472; --line: rgba(0,0,0,.10);
11
+ --bg: #fff; --sunken: #f6f7f9; --accent: #2563eb;
12
+ }
13
+ @media (prefers-color-scheme: dark) {
14
+ :root { --fg:#e8eaed; --muted:#9aa3b0; --line:rgba(255,255,255,.14);
15
+ --bg:#14181e; --sunken:#1d222a; --accent:#5b95f7; }
16
+ }
17
+ * { box-sizing: border-box; }
18
+ body {
19
+ margin: 0; padding: 48px 20px 96px; background: var(--bg); color: var(--fg);
20
+ font: 16px/1.75 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
21
+ "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
22
+ }
23
+ main { max-width: 760px; margin: 0 auto; }
24
+ h1 { font-size: 30px; line-height: 1.35; margin: 0 0 8px; letter-spacing: -.01em; }
25
+ h2 { font-size: 20px; margin: 44px 0 12px; letter-spacing: -.01em; }
26
+ .sub { color: var(--muted); margin: 0 0 32px; font-size: 15px; }
27
+ p { margin: 14px 0; }
28
+ a { color: var(--accent); }
29
+ code {
30
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em;
31
+ background: var(--sunken); padding: .15em .4em; border-radius: 5px;
32
+ }
33
+ pre {
34
+ background: var(--sunken); padding: 14px 16px; border-radius: 10px;
35
+ overflow: auto; font-size: 13.5px; line-height: 1.6;
36
+ border: .5px solid var(--line);
37
+ }
38
+ pre code { background: none; padding: 0; }
39
+ table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 14.5px; }
40
+ th, td { text-align: left; padding: 8px 10px; border-bottom: .5px solid var(--line); }
41
+ th { font-weight: 600; color: var(--muted); font-size: 13px; letter-spacing: .02em; }
42
+ td:last-child, th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
43
+ .note {
44
+ border-left: 3px solid var(--accent); background: var(--sunken);
45
+ padding: 12px 16px; border-radius: 0 8px 8px 0; margin: 20px 0;
46
+ }
47
+ .foot { margin-top: 56px; padding-top: 20px; border-top: .5px solid var(--line);
48
+ color: var(--muted); font-size: 13.5px; }
49
+ </style>
50
+ </head>
51
+ <body>
52
+ <main>
53
+
54
+ <h1>模型菜单显示 128k,不代表模型只有 128k</h1>
55
+ <p class="sub">一份不用查文档、直接向服务端问出真实上下文上限的方法,附 24 个模型实测值</p>
56
+
57
+ <p>如果你在用 DeepSeek Harness、Cherry Studio、LobeChat 或者任何接入 OpenAI 兼容
58
+ 网关的客户端,可能遇到过这种情况:所有模型的上下文都显示 128k,包括那些明明是
59
+ 100 万上下文的模型。</p>
60
+
61
+ <p>原因不在客户端。多数网关的 <code>/v1/models</code> <strong>只返回模型名,一个容量字段
62
+ 都没有</strong>。客户端拿不到数字,只能按默认值兜底——128k 就是这么来的。</p>
63
+
64
+ <h2>不用文档,直接问服务端</h2>
65
+
66
+ <p>服务端其实会告诉你答案,只是不在模型列表里,而在<strong>报错</strong>里。</p>
67
+
68
+ <p>发一个超过上限的 prompt,请求会在<strong>生成之前</strong>被拒绝,错误信息里带着真实上限:</p>
69
+
70
+ <pre><code>POST /v1/chat/completions
71
+ {
72
+ "model": "deepseek-flash",
73
+ "messages": [{"role": "user", "content": "a a a ... (110 万个词)"}],
74
+ "max_tokens": 1
75
+ }
76
+
77
+ → 400
78
+ This model's maximum context length is 1048576 tokens;
79
+ the prompt has 1100031 tokens</code></pre>
80
+
81
+ <div class="note">
82
+ <strong>被拒绝的请求不计费。</strong>计费发生在生成阶段,而在那之前就被拒了。
83
+ 这一整轮 56 个模型测下来,花了不到 1 元人民币。
84
+ </div>
85
+
86
+ <h2>不报数字的模型怎么办</h2>
87
+
88
+ <p>有些模型只说 <code>Your input exceeds the context window of this model</code>,
89
+ 不给具体数字。这种情况用二分法:从一个已知能过的大小开始,翻倍直到被拒,
90
+ 然后在「能过」和「过不了」之间二分。</p>
91
+
92
+ <p>取<strong>被拒绝的最小值</strong>作为上限。这个值永远不会高估——而高估是危险的方向:
93
+ 客户端会等到上下文远超真实上限才做压缩,然后收到上游的 400,用户看到的就是
94
+ 一条莫名其妙的失败。</p>
95
+
96
+ <h2>实测结果</h2>
97
+
98
+ <p>以下是 2026-11 在一个自建 sub2api 网关上的实测值。<code>measured</code> 是实测,
99
+ 不是从任何文档抄的。</p>
100
+
101
+ <table>
102
+ <thead><tr><th>模型</th><th>上下文上限</th></tr></thead>
103
+ <tbody>
104
+ <tr><td><code>muse-image</code></td><td>2,097,152</td></tr>
105
+ <tr><td><code>muse-spark</code></td><td>2,097,152</td></tr>
106
+ <tr><td><code>deepseek-flash</code></td><td>1,048,576</td></tr>
107
+ <tr><td><code>deepseek-pro</code></td><td>1,048,576</td></tr>
108
+ <tr><td><code>deepseek-v4-pro</code></td><td>1,048,576</td></tr>
109
+ <tr><td><code>deepseek-v4.1-flash</code></td><td>1,048,576</td></tr>
110
+ <tr><td><code>glm-5.3</code></td><td>1,048,576</td></tr>
111
+ <tr><td><code>qwen3.8-max</code></td><td>1,015,808</td></tr>
112
+ <tr><td><code>codex-auto-review</code></td><td>950,272</td></tr>
113
+ <tr><td><code>gpt-5.6-luna</code></td><td>950,272</td></tr>
114
+ <tr><td><code>gpt-5.6-sol</code></td><td>950,272</td></tr>
115
+ <tr><td><code>gpt-6-sol</code></td><td>950,272</td></tr>
116
+ <tr><td><code>gpt-6.1-sol</code></td><td>950,272</td></tr>
117
+ <tr><td><code>gpt-6.2-sol</code></td><td>950,272</td></tr>
118
+ <tr><td><code>gpt-reserve</code></td><td>950,272</td></tr>
119
+ <tr><td><code>gpt-6.2-astra</code></td><td>524,288</td></tr>
120
+ <tr><td><code>muse-video</code></td><td>262,144</td></tr>
121
+ <tr><td><code>grok-4.7</code></td><td>131,072</td></tr>
122
+ </tbody>
123
+ </table>
124
+
125
+ <div class="note">
126
+ <strong>同代模型可能差一倍。</strong> <code>gpt-6.2-astra</code> 是 524,288,
127
+ 而同代的 <code>gpt-6.2-sol</code> 是 950,272。按模型名里的版本号猜家族值,
128
+ 一定会猜错。
129
+ </div>
130
+
131
+ <h2>开源的容量表也不能全信</h2>
132
+
133
+ <p>拿 LiteLLM 的公开注册表(7,194 条)和我实测的值逐条对照,它对不上的比例不低,
134
+ 而且<strong>偏高</strong>的次数更多:</p>
135
+
136
+ <table>
137
+ <thead><tr><th>模型</th><th>实测</th><th>开源表</th><th>偏差</th></tr></thead>
138
+ <tbody>
139
+ <tr><td><code>gpt-6.2-astra</code></td><td>524,288</td><td>922,000</td><td>+397,712</td></tr>
140
+ <tr><td><code>grok-4.7</code></td><td>131,072</td><td>500,000</td><td>+368,928</td></tr>
141
+ <tr><td><code>gpt-6-sol</code></td><td>950,272</td><td>922,000</td><td>−28,272</td></tr>
142
+ <tr><td><code>deepseek-flash</code></td><td>1,048,576</td><td>1,000,000</td><td>−48,576</td></tr>
143
+ </tbody>
144
+ </table>
145
+
146
+ <p>所以正确的顺序是:<strong>能实测就实测,实测不到才用开源表兜底</strong>,
147
+ 并且要标明哪个是哪个。</p>
148
+
149
+ <h2>现成的实现</h2>
150
+
151
+ <p>如果你在用 DeepSeek Harness,这个插件已经把上面整套做完了,装上即用:</p>
152
+
153
+ <pre><code>dsh plugin add dsh-sub2api</code></pre>
154
+
155
+ <p>它会在设置页让你用邮箱和密码登录 sub2api 网关,自动建密钥、同步模型目录,
156
+ 并从表里读上下文容量——不会把 95 万上下文的模型显示成 128k。装完默认模型就已经
157
+ 指向可用模型,选择器不会是空的。</p>
158
+
159
+ <p>实测脚本也在仓库里,可以对着你自己的网关跑一遍:</p>
160
+
161
+ <pre><code>node scripts/measure-context.mjs --key sk-... --out /tmp/ctx.json
162
+ node scripts/build-model-registry.mjs /tmp/ctx.json</code></pre>
163
+
164
+ <p>仓库:<a href="https://github.com/pscly/dsh-sub2api">github.com/pscly/dsh-sub2api</a></p>
165
+
166
+ <div class="foot">
167
+ 数据采集时间:2026 年 11 月 · 网关 <code>sub.svpai.net</code> ·
168
+ 所有数值来自被拒绝的请求,未产生生成计费
169
+ </div>
170
+
171
+ </main>
172
+ </body>
173
+ </html>
@@ -0,0 +1,81 @@
1
+ # 24 个模型的上下文上限实测(DeepSeek Harness / sub2api 网关)
2
+
3
+ 模型菜单里显示 128k,不代表模型只有 128k。多数 OpenAI 兼容网关的 `/v1/models`
4
+ 只返回模型名,**一个容量字段都没有**,客户端只能按默认值兜底,于是所有模型都被
5
+ 显示成 128k。
6
+
7
+ 这份数据是实测的,不是抄文档的。
8
+
9
+ ## 怎么测的
10
+
11
+ 给模型发一个超过它上限的 prompt,服务端会在**生成之前**拒绝,并在错误信息里报出
12
+ 真实上限:
13
+
14
+ ```
15
+ This model's maximum context length is 1048576 tokens;
16
+ the prompt has 1100031 tokens
17
+ ```
18
+
19
+ 不报数字的模型(比如 gpt 系列只说 `Your input exceeds the context window`),就用
20
+ 二分法在「能过」和「过不了」之间逼近,取被拒绝的最小值——**这个值永远不会高估**。
21
+
22
+ 被拒绝的请求不计费。整轮 56 个模型测下来花了不到 1 元,其中 24 个报出了明确数字。
23
+
24
+ ## 实测结果(24 个模型)
25
+
26
+ | 模型 | 上下文上限 |
27
+ |---|---|
28
+ | `muse-image` | 2,097,152 |
29
+ | `muse-spark` | 2,097,152 |
30
+ | `deepseek-flash` | 1,048,576 |
31
+ | `deepseek-pro` | 1,048,576 |
32
+ | `deepseek-v4-pro` | 1,048,576 |
33
+ | `deepseek-v4.1-flash` | 1,048,576 |
34
+ | `deepseek/deepseek-v4-pro` | 1,048,576 |
35
+ | `deepseek/deepseek-v4.1-flash` | 1,048,576 |
36
+ | `glm-5.3` | 1,048,576 |
37
+ | `qwen3.8-max` | 1,015,808 |
38
+ | `codex-auto-review` | 950,272 |
39
+ | `gpt-5.6-luna` | 950,272 |
40
+ | `gpt-5.6-sol` | 950,272 |
41
+ | `gpt-5.6-terra` | 950,272 |
42
+ | `gpt-6-astra` | 950,272 |
43
+ | `gpt-6-luna` | 950,272 |
44
+ | `gpt-6-sol` | 950,272 |
45
+ | `gpt-6.1-sol` | 950,272 |
46
+ | `gpt-6.1-terra` | 950,272 |
47
+ | `gpt-6.2-sol` | 950,272 |
48
+ | `gpt-reserve` | 950,272 |
49
+ | `gpt-6.2-astra` | 524,288 |
50
+ | `muse-video` | 262,144 |
51
+ | `grok-4.7` | 131,072 |
52
+
53
+ ## 两个值得注意的地方
54
+
55
+ **同代模型容量可能差一倍。** `gpt-6.2-astra` 是 524,288,而同代的 `gpt-6.2-sol`
56
+ 是 950,272。按前缀猜家族值一定会出错。
57
+
58
+ **开源的容量表在这个网关上不准。** 拿 LiteLLM 的公开注册表(7,194 条)对照,
59
+ 它给 `gpt-6.2-astra` 写的是 922,000(实际 524,288),给 `grok-4.7` 写的是
60
+ 500,000(实际 131,072)——**都是高估**。高估是最危险的方向:客户端会等到上下文
61
+ 远超真实上限才压缩,然后收到上游的 400。
62
+
63
+ ## 怎么用
64
+
65
+ 如果你在用 DeepSeek Harness,装这个插件后容量直接从表里读,不用自己填:
66
+
67
+ ```sh
68
+ dsh plugin add dsh-sub2api
69
+ ```
70
+
71
+ 数据在 [`lib/model-registry.js`](../lib/model-registry.js),每条都标了来源
72
+ (`measured` = 实测,`open` = 开源注册表)。仓库里带了复现脚本:
73
+
74
+ ```sh
75
+ node scripts/measure-context.mjs --key sk-... --out /tmp/ctx.json
76
+ node scripts/build-model-registry.mjs /tmp/ctx.json
77
+ ```
78
+
79
+ ---
80
+
81
+ 数据采集:2026-11 / 网关 `sub.svpai.net` / 未计费拒绝请求
package/lib/adapter.js CHANGED
@@ -342,6 +342,18 @@ export function describeStreamFailure(error, emitted, attempts) {
342
342
  const status = failureStatus(error);
343
343
  const said = plainText(error?.message ?? error);
344
344
 
345
+ // Out of balance is the most common reason a fresh install cannot talk, and
346
+ // the raw error is `INSUFFICIENT_BALANCE` from a 403 — which reads like a
347
+ // permissions or key problem. It is neither: the account simply has no
348
+ // credit. Naming that, and where to fix it, is the difference between a user
349
+ // topping up and a user uninstalling.
350
+ if (/INSUFFICIENT_BALANCE|insufficient.*balance|余额不足|quota.*exceed/i.test(said)) {
351
+ return new Sub2ApiError(
352
+ `账户余额不足,无法调用模型${retryNote}。打开 设置 → dsh-sub2api 点「去充值」,到账后会自动恢复。`,
353
+ { code: "QUOTA", status, cause: error },
354
+ );
355
+ }
356
+
345
357
  if (status !== undefined && status >= 500) {
346
358
  // sub2api answers this exact sentence for "my upstream failed", which in
347
359
  // practice means the account pool has nothing usable for this model — a
package/lib/client.js CHANGED
@@ -1567,7 +1567,30 @@ window.__ModuleLoader__.load({
1567
1567
  */
1568
1568
  function LoginNudge() {
1569
1569
  const { state } = useStatus();
1570
- if (state === null || state.loggedIn === true) return null;
1570
+ if (state === null) return null;
1571
+
1572
+ // Signed in with no credit is the second wall a new user hits, and it is
1573
+ // silent until they send a message. Say it on the same line that covers
1574
+ // "not signed in", because both mean "you cannot use this yet".
1575
+ if (state.loggedIn === true) {
1576
+ const balance = Number(state.profile?.balance);
1577
+ if (Number.isFinite(balance) && balance <= 0) {
1578
+ return h("button", {
1579
+ type: "button",
1580
+ "data-sub2api": "",
1581
+ onClick: () => toastStore.push("打开 设置 → dsh-sub2api,点「去充值」", "ok"),
1582
+ style: {
1583
+ display: "inline-flex", alignItems: "center", gap: 8,
1584
+ padding: "8px 14px", borderRadius: 999,
1585
+ border: "0.5px solid " + C.bad, background: C.surface,
1586
+ color: C.bad, fontSize: 12.5, cursor: "pointer", maxWidth: "100%",
1587
+ },
1588
+ },
1589
+ h("span", { style: { width: 7, height: 7, borderRadius: 999, background: C.bad, flex: "0 0 7px" } }),
1590
+ h("span", null, "账户余额为 0,现在还不能调用模型 —— 去 设置 → dsh-sub2api 充值"));
1591
+ }
1592
+ return null;
1593
+ }
1571
1594
 
1572
1595
  return h("button", {
1573
1596
  type: "button",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-sub2api",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Sub2API provider for DeepSeek Harness (DSH): email sign-in, automatic API key and model provisioning, one panel for balance and recharge. Works with the hosted gateway or your own sub2api deployment",
5
5
  "type": "module",
6
6
  "license": "GPL-3.0-only",
@@ -16,7 +16,9 @@
16
16
  "README.md",
17
17
  "assets",
18
18
  "cordis.patch.yml",
19
- "lib"
19
+ "lib",
20
+ "README.en.md",
21
+ "docs"
20
22
  ],
21
23
  "dsh": {
22
24
  "bundle": {