dsh-sub2api 0.9.1 → 0.10.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,35 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.0
4
+
5
+ - **The gateway and the pay centre moved.** Defaults are now
6
+ `https://sub.svpai.net` and `https://pay.svpai.net`. The old hosts
7
+ (`sub.pscly.cc`, `pay.pscly.cc`) no longer answer at all, so this is a required
8
+ migration, not a preference.
9
+ - **Existing installs follow automatically.** A profile that still names the old
10
+ host has it rewritten to the new one with the rest of the URL preserved — the
11
+ user does not have to find the setting. A self-hosted gateway is left
12
+ completely alone: only those two exact hosts are rewritten.
13
+ - The model cache records which gateway produced it and is ignored when that
14
+ changes, so a cache filled from the old host cannot keep offering a catalogue
15
+ the new one no longer serves.
16
+ - Registry rebuilt for the 52 models the gateway lists today, which brings the
17
+ measured windows for the whole gpt and deepseek families along with the Claude
18
+ entries the open registry knows (1,000,000).
19
+
20
+ ## 0.9.2
21
+
22
+ - README opens with what the plugin is and what installing it gets you, not with
23
+ a description of who runs the gateway. The second paragraph is now a
24
+ four-item list of what happens automatically after one email and password
25
+ (sign in or sign up, the `dsh` key, the model directory, the panel), and the
26
+ duplicated paragraph further down became a three-step "get started" block.
27
+ Someone who has never seen Psapi can now tell from the first screen that
28
+ nothing has to be configured by hand.
29
+ - The npm description says the same thing in the same voice, so the package
30
+ page and the plugin-market card no longer describe the plugin differently
31
+ from the README.
32
+
3
33
  ## 0.9.1
4
34
 
5
35
  - The plugin calls itself **dsh-sub2api** everywhere a user can see it: the
@@ -369,7 +399,7 @@ something real.
369
399
 
370
400
  - Drop the manual-reconciliation copy. The recharge hint no longer promises a
371
401
  human review step, and the order-status wording says "正在确认到账" instead of
372
- "正在核账". The equivalent wording on pay.pscly.cc's checkout page and status
402
+ "正在核账". The equivalent wording on pay.svpai.net's checkout page and status
373
403
  payload was changed to match.
374
404
 
375
405
  ## 0.1.2
package/README.md CHANGED
@@ -1,8 +1,15 @@
1
1
  # dsh-sub2api
2
2
 
3
- 把自建的 **Psapi**(`sub.pscly.cc`,网关软件是开源的 [sub2api](https://github.com/Wei-Shaw/sub2api))接进 DeepSeek Harness(DSH)。
3
+ **Psapi 官方 DSH 插件**:在 DeepSeek Harness 里接入 Psapi AI 网关(`sub.svpai.net`,网关内核为开源项目 [sub2api](https://github.com/Wei-Shaw/sub2api)),安装后即可开箱使用。
4
4
 
5
- 装完之后,在 **设置 → dsh-sub2api** 里填一次邮箱和密码就能用:插件自己判断该登录还是注册,注册后自动创建名为 `dsh` 的 API 密钥、写进本机凭据库,并把上游模型同步进模型选择器。余额、用量、订阅、兑换码、充值和技术支持都在同一个面板里。
5
+ 装完只需在 **设置 → dsh-sub2api** 填入一次邮箱和密码,其余全部自动完成:
6
+
7
+ - 已有账号直接登录,没有账号自动注册,无需跳转浏览器
8
+ - 自动在账号下创建专用密钥 `dsh`,并写入本机凭据库
9
+ - 自动同步上游模型目录到模型选择器,不必手填接口地址、API Key 或模型名
10
+ - 余额、用量、订阅、兑换码、充值与运行诊断集中在同一个面板
11
+
12
+ 首次对话不需要任何手动配置;若某一步没有生效,面板内的「运行诊断」会直接指出问题出在哪一项。
6
13
 
7
14
  ```
8
15
  npm: dsh-sub2api https://www.npmjs.com/package/dsh-sub2api
@@ -12,9 +19,13 @@ repo: pscly/dsh-sub2api https://github.com/pscly/dsh-sub2api
12
19
 
13
20
  ![设置页面板](https://raw.githubusercontent.com/pscly/dsh-sub2api/main/assets/screenshots/panel.png)
14
21
 
15
- 装好之后你不需要碰任何接口地址或密钥:**邮箱 + 密码**就够了。插件自己判断该登录还是注册,
16
- 在账号下建一个名为 `dsh` 的密钥存档,把模型同步进选择器,并把余额、用量、订阅、兑换码、
17
- 充值集中在一个面板里。
22
+ ## 三步上手
23
+
24
+ 1. 安装插件并重启 DSH:`dsh plugin add dsh-sub2api`
25
+ 2. 打开 **设置 → dsh-sub2api**,填入邮箱和密码
26
+ 3. 在模型选择器里选中 Psapi 的模型,直接开始对话
27
+
28
+ 不需要准备 API Key、接口地址或模型清单——账号、密钥与模型目录都会自动就绪。详细安装方式见下一节。
18
29
 
19
30
  ---
20
31
 
@@ -187,15 +198,15 @@ Agent 工具(只读):`sub2api_status`、`sub2api_models`。模型可以回
187
198
  - id: llm-sub2api
188
199
  name: "dsh-sub2api"
189
200
  config:
190
- apiBase: "https://sub.pscly.cc"
191
- payBase: "https://pay.pscly.cc"
201
+ apiBase: "https://sub.svpai.net"
202
+ payBase: "https://pay.svpai.net"
192
203
  apiKeyEnv: SUB2API_API_KEY
193
204
  ```
194
205
 
195
206
  | 字段 | 默认值 | 说明 |
196
207
  |---|---|---|
197
- | `apiBase` | `https://sub.pscly.cc` | 中转站地址,末尾 `/v1` 会被去掉 |
198
- | `payBase` | `https://pay.pscly.cc` | 充值中转站地址 |
208
+ | `apiBase` | `https://sub.svpai.net` | 中转站地址,末尾 `/v1` 会被去掉 |
209
+ | `payBase` | `https://pay.svpai.net` | 充值中转站地址 |
199
210
  | `apiKeyEnv` | `SUB2API_API_KEY` | 存 API Key 的凭据引用名 |
200
211
  | `keyName` | `dsh` | 自动创建/复用的密钥名 |
201
212
  | `groupId` | 自动选择 | 强制指定密钥所属分组 |
@@ -358,7 +369,7 @@ llm-sub2api:
358
369
 
359
370
  ## 常见报错
360
371
 
361
- ### `https://sub.pscly.cc/v1 could not be reached or the connection dropped: fetch failed`
372
+ ### `https://sub.svpai.net/v1 could not be reached or the connection dropped: fetch failed`
362
373
 
363
374
  这是**传输层**的失败(不是网关返回的业务错误):TCP/TLS 连接没建立起来,或者建立后被对端断开。
364
375
 
package/lib/config.js CHANGED
@@ -56,13 +56,46 @@ export function field(config, key, fallback) {
56
56
  * announceToAgent: boolean,
57
57
  * }}
58
58
  */
59
+ /**
60
+ * Hosts this plugin used to ship with, and where they moved.
61
+ *
62
+ * A user who configured the plugin before the move has the old host written
63
+ * into their profile config, so changing the default alone would leave them
64
+ * pointing at a domain that no longer resolves. The old host is only rewritten
65
+ * when the configured value still names it — a self-hosted gateway is left
66
+ * completely alone.
67
+ * @type {Record<string, string>}
68
+ */
69
+ const MOVED_HOSTS = {
70
+ "sub.pscly.cc": "sub.svpai.net",
71
+ "pay.pscly.cc": "pay.svpai.net",
72
+ };
73
+
74
+ /**
75
+ * Follow a moved host, preserving the rest of the URL.
76
+ * @param {string} url
77
+ * @returns {string}
78
+ */
79
+ function followMovedHost(url) {
80
+ let parsed;
81
+ try {
82
+ parsed = new URL(url);
83
+ } catch {
84
+ return url;
85
+ }
86
+ const moved = MOVED_HOSTS[parsed.hostname.toLowerCase()];
87
+ if (moved === undefined) return url;
88
+ parsed.hostname = moved;
89
+ return parsed.toString().replace(/\/+$/, "");
90
+ }
91
+
59
92
  export function resolveConfig(config) {
60
93
  const dshHome = process.env.DSH_HOME ?? join(homedir(), ".dsh");
61
94
  const configuredKeyName = String(field(config, "keyName", "")).trim();
62
95
 
63
96
  return {
64
- apiBase: normalizeBaseUrl(field(config, "apiBase", "https://sub.pscly.cc")),
65
- payBase: normalizeBaseUrl(field(config, "payBase", "https://pay.pscly.cc")),
97
+ apiBase: followMovedHost(normalizeBaseUrl(field(config, "apiBase", "https://sub.svpai.net"))),
98
+ payBase: followMovedHost(normalizeBaseUrl(field(config, "payBase", "https://pay.svpai.net"))),
66
99
  apiKeyEnv: String(field(config, "apiKeyEnv", API_KEY_REF)),
67
100
  groupId: toPositiveInt(field(config, "groupId", undefined)),
68
101
  keyName: configuredKeyName === "" ? KEY_NAME : configuredKeyName,
package/lib/constants.js CHANGED
@@ -89,7 +89,7 @@ export const BUILTIN_MODEL = {
89
89
  };
90
90
 
91
91
  export const KNOWN_CONTEXT = [
92
- // Measured on sub.pscly.cc: 897,791 tokens accepted, 1,050,041 rejected with
92
+ // Measured on sub.svpai.net: 897,791 tokens accepted, 1,050,041 rejected with
93
93
  // "maximum context length is 1048576 tokens".
94
94
  { match: "deepseek-v4.1-flash", contextWindow: 1048576 },
95
95
  { match: "deepseek-flash", contextWindow: 1048576 },
package/lib/index.js CHANGED
@@ -53,7 +53,7 @@ export const VERSION = (() => {
53
53
  const SECTION_ORDER = 172;
54
54
 
55
55
  const GUIDANCE =
56
- "本机已安装 dsh-sub2api 插件:它把 sub2api(sub.pscly.cc)中转站接入 DSH。用户在 设置 → dsh-sub2api 用一个邮箱和密码完成登录或注册,插件会自动在该账号下创建名为 dsh 的 API 密钥、写入本机凭据库,并同步上游模型目录,模型随后出现在模型选择器的 dsh-sub2api 分组里。余额、订阅进度与充值入口也在同一面板;充值走 pay.pscly.cc,点「去支付」会在新标签页打开。可用命令 /sub2api 查看状态。用户提到「sub2api / 中转站 / 我的网关 / 余额充值」时即指本插件。";
56
+ "本机已安装 dsh-sub2api 插件:它把 sub2api(sub.svpai.net)中转站接入 DSH。用户在 设置 → dsh-sub2api 用一个邮箱和密码完成登录或注册,插件会自动在该账号下创建名为 dsh 的 API 密钥、写入本机凭据库,并同步上游模型目录,模型随后出现在模型选择器的 dsh-sub2api 分组里。余额、订阅进度与充值入口也在同一面板;充值走 pay.svpai.net,点「去支付」会在新标签页打开。可用命令 /sub2api 查看状态。用户提到「sub2api / 中转站 / 我的网关 / 余额充值」时即指本插件。";
57
57
 
58
58
  /**
59
59
  * Mount the provider, panel routes and tools.
@@ -21,6 +21,13 @@
21
21
  */
22
22
  export const MODEL_REGISTRY = {
23
23
  "claude-haiku-5-5": { contextWindow: 1000000, source: "open" },
24
+ "claude-opus-4-7": { contextWindow: 1000000, source: "open" },
25
+ "claude-opus-4-8": { contextWindow: 1000000, source: "open" },
26
+ "claude-opus-5": { contextWindow: 1000000, source: "open" },
27
+ "claude-opus-5-5": { contextWindow: 1000000, source: "open" },
28
+ "claude-sonnet-4-6": { contextWindow: 1000000, source: "open" },
29
+ "claude-sonnet-5": { contextWindow: 1000000, source: "open" },
30
+ "claude-sonnet-5-5": { contextWindow: 1000000, source: "open" },
24
31
  "codex-auto-review": { contextWindow: 950272, source: "measured" },
25
32
  "deepseek-flash": { contextWindow: 1048576, source: "measured" },
26
33
  "deepseek-pro": { contextWindow: 1048576, source: "measured" },
@@ -96,10 +103,10 @@ export function registryFacts(id) {
96
103
  if (!lower.startsWith(name)) continue;
97
104
  const next = lower.charAt(name.length);
98
105
  // A prefix match must stop at a model boundary, not inside a version.
99
- // `glm-5` is not `glm-5.2`: a dot (or digit) after a known id that itself
100
- // ends in a digit is a version continuation, so the shorter id does not
101
- // describe the longer one. `.` stays a valid separator for namespaces such
102
- // as `zai-org.GLM`, which do not end in a digit.
106
+ // "glm-5" is not "glm-5.2": a dot or digit after a known id that itself ends
107
+ // in a digit is a version continuation, so the shorter id does not describe
108
+ // the longer one. A dot stays a valid separator for namespaces such as
109
+ // "zai-org.GLM", which do not end in a digit.
103
110
  if (next !== "") {
104
111
  const endsInDigit = /[0-9]$/.test(name);
105
112
  const versionish = next === "." || /[0-9]/.test(next);
package/lib/schema.js CHANGED
@@ -21,8 +21,8 @@ const text = (fallback, description) =>
21
21
  const count = (description) => z.natural().description(description).volatile();
22
22
 
23
23
  export const Config = z.object({
24
- apiBase: text("https://sub.pscly.cc", "中转站地址;末尾的 /v1 会被自动去掉"),
25
- payBase: text("https://pay.pscly.cc", "充值中转站地址(独立服务)"),
24
+ apiBase: text("https://sub.svpai.net", "中转站地址;末尾的 /v1 会被自动去掉"),
25
+ payBase: text("https://pay.svpai.net", "充值中转站地址(独立服务)"),
26
26
  apiKeyEnv: text(API_KEY_REF, "存放 API Key 的凭据引用名"),
27
27
  keyName: text(KEY_NAME, "自动创建/复用的密钥名称"),
28
28
  groupId: count("强制指定密钥所属分组;留空则跟随账号的默认分组"),
@@ -76,6 +76,12 @@ export class ModelCatalog {
76
76
  try {
77
77
  const text = await readFile(this.deps.cachePath(), "utf8");
78
78
  const parsed = JSON.parse(text);
79
+ const current = this.deps.apiBase?.() ?? "";
80
+ const cachedFor = typeof parsed?.base === "string" ? parsed.base : "";
81
+ if (cachedFor !== "" && current !== "" && cachedFor !== current) {
82
+ this.logger.info?.(`[sub2api] 缓存来自 ${cachedFor},与当前 ${current} 不符,忽略`);
83
+ return;
84
+ }
79
85
  if (Array.isArray(parsed?.models)) {
80
86
  this.models = parsed.models.filter(isModelRecord);
81
87
  this.fetchedAt = Number(parsed.fetchedAt) || 0;
@@ -375,7 +381,18 @@ export class ModelCatalog {
375
381
  await mkdir(dirname(path), { recursive: true });
376
382
  await writeFile(
377
383
  path,
378
- JSON.stringify({ fetchedAt: this.fetchedAt, models: this.models }, null, 0),
384
+ JSON.stringify(
385
+ {
386
+ fetchedAt: this.fetchedAt,
387
+ // A cache filled from a different gateway describes a different
388
+ // catalogue; using it would offer models the current one may not
389
+ // serve.
390
+ base: this.deps.apiBase?.() ?? "",
391
+ models: this.models,
392
+ },
393
+ null,
394
+ 0,
395
+ ),
379
396
  { mode: 0o600 },
380
397
  );
381
398
  } catch (error) {
package/lib/tools.js CHANGED
@@ -27,7 +27,7 @@ function statusTool(deps) {
27
27
  return defineTool({
28
28
  name: "sub2api_status",
29
29
  description:
30
- "查看 dsh-sub2api(sub.pscly.cc 中转站)在本机的接入状态:是否已登录、账号邮箱、余额、API 密钥是否已保存(只返回掩码)、订阅进度、已同步的模型数量。不会返回任何明文密钥。",
30
+ "查看 dsh-sub2api(sub.svpai.net 中转站)在本机的接入状态:是否已登录、账号邮箱、余额、API 密钥是否已保存(只返回掩码)、订阅进度、已同步的模型数量。不会返回任何明文密钥。",
31
31
  parameters: {},
32
32
  output: {
33
33
  schema: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-sub2api",
3
- "version": "0.9.1",
4
- "description": "Psapi (sub.pscly.cc) provider for DeepSeek Harness: zero-friction signup, auto-provisioned API key, upstream model sync, balance and recharge",
3
+ "version": "0.10.0",
4
+ "description": "Official Psapi provider for DeepSeek Harness: email sign-in or sign-up, automatic key and model provisioning, one panel for balance and recharge",
5
5
  "type": "module",
6
6
  "license": "GPL-3.0-only",
7
7
  "main": "./lib/index.js",