dsh-sub2api 0.13.0 → 0.13.2

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,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.2
4
+
5
+ - `model_not_found` now names the model and points at the picker, instead of
6
+ letting the raw JSON through. Verified against the live gateway: asking for a
7
+ model outside the group returns
8
+ `Model "x" is not available for this group`, which the host keeps sending until
9
+ the user picks another.
10
+ - **Two matchers were too wide and are now narrowed.** Probing them turned up a
11
+ real false positive: `model has no context length metadata` — a diagnostic, not
12
+ an overflow — was being answered with "start a new conversation". The rule now
13
+ only matches sentences an upstream uses when the *input* is too long, and a
14
+ regression test pins both traps.
15
+ - Not changed, because measurement said so: a 2 MB request body and 30 concurrent
16
+ requests both succeed on the gateway, so neither needs a special message.
17
+
18
+ ## 0.13.1
19
+
20
+ - **Two more gateway failures now read as instructions.** Both were reproduced
21
+ against the live gateway before the wording was written.
22
+ - `GROUP_DELETED` — a key whose group was deleted still carries the group id,
23
+ so every call fails and nothing in the panel shows why. 27 such keys exist
24
+ on the gateway today. The message now says to rebuild the key.
25
+ - Context overflow — the gateway nests the real message inside a JSON string,
26
+ so users got an escaped blob ending in a trace id. It now says to start a new
27
+ conversation or pick a model with a bigger window.
28
+
3
29
  ## 0.13.0
4
30
 
5
31
  - **Out of balance now says so, and where to fix it.** The gateway answers both
package/lib/adapter.js CHANGED
@@ -354,6 +354,50 @@ export function describeStreamFailure(error, emitted, attempts) {
354
354
  );
355
355
  }
356
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
+ // Deliberately narrow. "context length" alone matches diagnostics like "model
373
+ // has no context length metadata", which is a different failure and would get
374
+ // advice that makes no sense. Every alternative here is a sentence the
375
+ // upstream actually uses when the *input* is too long.
376
+ if (
377
+ /longer than the model.s context length|exceeds? the context window|context window.*exceed|prompt is too long|maximum context length is|input is longer than/i.test(
378
+ said,
379
+ )
380
+ ) {
381
+ return new Sub2ApiError(
382
+ "这条会话已经超过模型能接受的上下文长度了。开一个新会话,或在模型选择器里换一个上下文更大的模型。",
383
+ { code: "CONTEXT_WINDOW_EXCEEDED", status, cause: error },
384
+ );
385
+ }
386
+
387
+ // The model is gone from the group: a catalogue refresh happened while a
388
+ // conversation still had it selected, or an allowlist removed it. The host
389
+ // keeps sending it until the user picks another, so the message has to point
390
+ // at the picker rather than at the gateway.
391
+ if (/model_not_found|is not available for this group|model.*not.*found/i.test(said)) {
392
+ // The message may arrive plain or with the quotes still escaped, depending
393
+ // on how many layers of JSON the gateway wrapped it in.
394
+ const named = said.match(/Model\s*\\?["']([^"'\\]+)\\?["']/i)?.[1];
395
+ return new Sub2ApiError(
396
+ `${named === undefined ? "这个模型" : `模型 ${named}`} 当前分组已经不再提供了。在模型选择器里换一个模型,或到 设置 → dsh-sub2api 点「刷新」重新同步目录。`,
397
+ { code: "model_not_found", status, cause: error },
398
+ );
399
+ }
400
+
357
401
  if (status !== undefined && status >= 500) {
358
402
  // sub2api answers this exact sentence for "my upstream failed", which in
359
403
  // practice means the account pool has nothing usable for this model — a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-sub2api",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
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",