dsh-sub2api 0.12.1 → 0.13.1
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 +23 -0
- package/lib/adapter.js +34 -0
- package/lib/client.js +24 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.1
|
|
4
|
+
|
|
5
|
+
- **Two more gateway failures now read as instructions.** Both were reproduced
|
|
6
|
+
against the live gateway before the wording was written.
|
|
7
|
+
- `GROUP_DELETED` — a key whose group was deleted still carries the group id,
|
|
8
|
+
so every call fails and nothing in the panel shows why. 27 such keys exist
|
|
9
|
+
on the gateway today. The message now says to rebuild the key.
|
|
10
|
+
- Context overflow — the gateway nests the real message inside a JSON string,
|
|
11
|
+
so users got an escaped blob ending in a trace id. It now says to start a new
|
|
12
|
+
conversation or pick a model with a bigger window.
|
|
13
|
+
|
|
14
|
+
## 0.13.0
|
|
15
|
+
|
|
16
|
+
- **Out of balance now says so, and where to fix it.** The gateway answers both
|
|
17
|
+
`/v1/models` and `/v1/chat/completions` with `INSUFFICIENT_BALANCE` on a
|
|
18
|
+
zero-balance account, and the plugin passed that raw 403 through — a message
|
|
19
|
+
that reads like a key or permission problem. Measured on a live gateway: 62 of
|
|
20
|
+
108 accounts carry a zero balance, so this is the single most common reason a
|
|
21
|
+
fresh install cannot talk. It is now a sentence with the next step.
|
|
22
|
+
- The empty conversation screen also warns while the balance is zero, next to
|
|
23
|
+
the existing "not signed in" line, so the wall is visible before the first
|
|
24
|
+
message instead of after it.
|
|
25
|
+
|
|
3
26
|
## 0.12.1
|
|
4
27
|
|
|
5
28
|
- **An English README.** The plugin list judges language by the share of CJK
|
package/lib/adapter.js
CHANGED
|
@@ -342,6 +342,40 @@ 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
|
+
|
|
357
|
+
// A key whose group was deleted still carries the group id, so every call is
|
|
358
|
+
// rejected with GROUP_DELETED and the user has no way to act on it: nothing
|
|
359
|
+
// in the panel shows a broken group. The fix is to re-provision, which the
|
|
360
|
+
// plugin can do, but only if it says so plainly.
|
|
361
|
+
if (/GROUP_DELETED|分组已删除|group.*deleted/i.test(said)) {
|
|
362
|
+
return new Sub2ApiError(
|
|
363
|
+
"密钥所属的分组已被站点删除,这个密钥无法再调用模型。在 设置 → dsh-sub2api 里点「重建」换一个新密钥即可。",
|
|
364
|
+
{ code: "group_deleted", status, cause: error },
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// The gateway reports a context overflow as a nested JSON string inside the
|
|
369
|
+
// message, so what reaches the user is an escaped blob ending in a trace id.
|
|
370
|
+
// The host will have compacted already; when this still fires, the real
|
|
371
|
+
// advice is "start a new conversation or pick a model with a bigger window".
|
|
372
|
+
if (/longer than the model.s context length|context length|context window|prompt is too long|maximum context/i.test(said)) {
|
|
373
|
+
return new Sub2ApiError(
|
|
374
|
+
"这条会话已经超过模型能接受的上下文长度了。开一个新会话,或在模型选择器里换一个上下文更大的模型。",
|
|
375
|
+
{ code: "CONTEXT_WINDOW_EXCEEDED", status, cause: error },
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
|
|
345
379
|
if (status !== undefined && status >= 500) {
|
|
346
380
|
// sub2api answers this exact sentence for "my upstream failed", which in
|
|
347
381
|
// 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
|
|
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.
|
|
3
|
+
"version": "0.13.1",
|
|
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",
|