dsh-sub2api 0.13.1 → 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,20 @@
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
+
3
18
  ## 0.13.1
4
19
 
5
20
  - **Two more gateway failures now read as instructions.** Both were reproduced
package/lib/adapter.js CHANGED
@@ -369,13 +369,35 @@ export function describeStreamFailure(error, emitted, attempts) {
369
369
  // message, so what reaches the user is an escaped blob ending in a trace id.
370
370
  // The host will have compacted already; when this still fires, the real
371
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)) {
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
+ ) {
373
381
  return new Sub2ApiError(
374
382
  "这条会话已经超过模型能接受的上下文长度了。开一个新会话,或在模型选择器里换一个上下文更大的模型。",
375
383
  { code: "CONTEXT_WINDOW_EXCEEDED", status, cause: error },
376
384
  );
377
385
  }
378
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
+
379
401
  if (status !== undefined && status >= 500) {
380
402
  // sub2api answers this exact sentence for "my upstream failed", which in
381
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.1",
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",