dsh-sub2api 0.3.0 → 0.4.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/lib/commands.js CHANGED
@@ -27,7 +27,7 @@ const HELP = [
27
27
  export function commandDefinition(deps) {
28
28
  return {
29
29
  name: "sub2api",
30
- description: "Sub2API 中转站:账号、密钥、余额与可用模型",
30
+ description: "Psapi 中转站:账号、密钥、余额与可用模型",
31
31
  input: { hint: "[status|models|balance|recharge]" },
32
32
  handler: async (invocation) => {
33
33
  const verb = String(invocation?.rawInput ?? "").trim().split(/\s+/)[0]?.toLowerCase() ?? "";
@@ -42,7 +42,7 @@ export function commandDefinition(deps) {
42
42
  } catch (error) {
43
43
  return {
44
44
  kind: "error",
45
- text: `Sub2API:${error instanceof Error ? error.message : String(error)}`,
45
+ text: `Psapi:${error instanceof Error ? error.message : String(error)}`,
46
46
  };
47
47
  }
48
48
  },
@@ -67,8 +67,8 @@ async function statusText(deps) {
67
67
 
68
68
  if (session === undefined) {
69
69
  return [
70
- "Sub2API:尚未登录。",
71
- `在 DSH 的 设置 → Sub2API 里用一个邮箱和密码登录或注册即可(${deps.cfg().apiBase})。`,
70
+ "Psapi:尚未登录。",
71
+ `在 DSH 的 设置 → Psapi 里用一个邮箱和密码登录或注册即可(${deps.cfg().apiBase})。`,
72
72
  ].join("\n");
73
73
  }
74
74
 
@@ -77,7 +77,7 @@ async function statusText(deps) {
77
77
  const models = deps.catalog.visible();
78
78
 
79
79
  const lines = [
80
- `Sub2API · ${deps.cfg().apiBase}`,
80
+ `Psapi · ${deps.cfg().apiBase}`,
81
81
  `账号   ${profile?.email ?? session.email ?? "已登录"}`,
82
82
  `余额   ${money(profile?.balance)}`,
83
83
  `密钥   ${apiKey ? maskSecret(apiKey) : "尚未创建"}`,
@@ -126,7 +126,7 @@ async function modelsText(deps) {
126
126
  const reason = deps.catalog.lastError?.message;
127
127
  return reason
128
128
  ? `没有可用模型:${reason}`
129
- : "没有可用模型。登录后在 设置 → Sub2API 里点「刷新模型」。";
129
+ : "没有可用模型。登录后在 设置 → Psapi 里点「刷新模型」。";
130
130
  }
131
131
  const lines = models.map((model) => {
132
132
  const bits = [`${Math.round((model.contextWindow ?? 0) / 1000)}k`];
package/lib/constants.js CHANGED
@@ -47,7 +47,7 @@ export const TOKEN_REFRESH_LEAD_MS = 60 * 1000;
47
47
  export const KEY_PAGE_SIZE = 100;
48
48
 
49
49
  /**
50
- * Currency of every amount this plugin shows. Sub2API quotes quota in yuan and
50
+ * Currency of every amount this plugin shows. Psapi quotes quota in yuan and
51
51
  * treats one quota unit as one yuan ("1 额度 = 1 元"), so the panel never uses a
52
52
  * foreign-currency figure.
53
53
  */
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。用户在 设置 → Sub2API 用一个邮箱和密码完成登录或注册,插件会自动在该账号下创建名为 dsh 的 API 密钥、写入本机凭据库,并同步上游模型目录,模型随后出现在模型选择器的 Sub2API 分组里。余额、订阅进度与充值入口也在同一面板;充值走 pay.pscly.cc,点「去支付」会在新标签页打开。可用命令 /sub2api 查看状态。用户提到「sub2api / 中转站 / 我的网关 / 余额充值」时即指本插件。";
56
+ "本机已安装 dsh-sub2api 插件:它把 sub2api(sub.pscly.cc)中转站接入 DSH。用户在 设置 → Psapi 用一个邮箱和密码完成登录或注册,插件会自动在该账号下创建名为 dsh 的 API 密钥、写入本机凭据库,并同步上游模型目录,模型随后出现在模型选择器的 Psapi 分组里。余额、订阅进度与充值入口也在同一面板;充值走 pay.pscly.cc,点「去支付」会在新标签页打开。可用命令 /sub2api 查看状态。用户提到「sub2api / 中转站 / 我的网关 / 余额充值」时即指本插件。";
57
57
 
58
58
  /**
59
59
  * Mount the provider, panel routes and tools.
@@ -152,7 +152,7 @@ export function apply(ctx, rawConfig = {}) {
152
152
  const providers = llmCtx.llm.registerConfigurableProviders([
153
153
  {
154
154
  provider: PROVIDER,
155
- displayName: "Sub2API",
155
+ displayName: "Psapi",
156
156
  settingsNs: SETTINGS_NS,
157
157
  settingsPath: [],
158
158
  },
package/lib/pay.js CHANGED
@@ -235,7 +235,11 @@ async function payFailureMessage(response, fallback) {
235
235
  .replace(/<[^>]+>/g, " ")
236
236
  .replace(/\s+/g, " ")
237
237
  .trim();
238
- const known = visible.match(/(缺少 Sub2API 用户上下文|Sub2API 用户校验失败[^ ]*|Sub2API 用户身份不匹配)/);
238
+ // The pay centre spells the site name its own way; accept either, because the
239
+ // two services are deployed separately and their wording can drift.
240
+ const known = visible.match(
241
+ /(缺少 (?:Psapi|Sub2API) 用户上下文|(?:Psapi|Sub2API) 用户校验失败[^ ]*|(?:Psapi|Sub2API) 用户身份不匹配)/,
242
+ );
239
243
  if (known) return known[0];
240
244
  if (response.status === 403) return `${fallback}:登录状态已失效(403)`;
241
245
  if (response.status === 419) return `${fallback}:支付页会话过期(419)`;
@@ -94,7 +94,7 @@ export function isEmailTaken(error) {
94
94
  /** Re-word a transport failure so the panel can say something actionable. */
95
95
  function translateLogin(error) {
96
96
  if (error instanceof Sub2ApiError && error.code === "network") {
97
- return new Sub2ApiError("连不上 Sub2API,请检查网络或服务地址", { code: "network" });
97
+ return new Sub2ApiError("连不上 Psapi,请检查网络或服务地址", { code: "network" });
98
98
  }
99
99
  return error;
100
100
  }
@@ -84,7 +84,7 @@ export class SessionStore {
84
84
  async accessToken(signal) {
85
85
  const session = await this.read();
86
86
  if (session === undefined) {
87
- throw new Sub2ApiError("尚未登录 Sub2API", { code: "not_logged_in" });
87
+ throw new Sub2ApiError("尚未登录 Psapi", { code: "not_logged_in" });
88
88
  }
89
89
  if (session.expiresAt > Date.now() + TOKEN_REFRESH_LEAD_MS || !session.refreshToken) {
90
90
  return session.accessToken;
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
- "查看 Sub2API(sub.pscly.cc 中转站)在本机的接入状态:是否已登录、账号邮箱、余额、API 密钥是否已保存(只返回掩码)、订阅进度、已同步的模型数量。不会返回任何明文密钥。",
30
+ "查看 Psapi(sub.pscly.cc 中转站)在本机的接入状态:是否已登录、账号邮箱、余额、API 密钥是否已保存(只返回掩码)、订阅进度、已同步的模型数量。不会返回任何明文密钥。",
31
31
  parameters: {},
32
32
  output: {
33
33
  schema: {
@@ -55,7 +55,7 @@ function statusTool(deps) {
55
55
  if (stored === undefined) {
56
56
  return {
57
57
  ok: false,
58
- message: `尚未登录 Sub2API。请让用户在 DSH 的 设置 → Sub2API 面板用一个邮箱和密码完成登录或注册(插件会自动创建名为 dsh 的密钥)。站点:${deps.cfg().apiBase}`,
58
+ message: `尚未登录 Psapi。请让用户在 DSH 的 设置 → Psapi 面板用一个邮箱和密码完成登录或注册(插件会自动创建名为 dsh 的密钥)。站点:${deps.cfg().apiBase}`,
59
59
  loggedIn: false,
60
60
  hasKey: false,
61
61
  modelCount: deps.catalog.visible().length,
@@ -93,7 +93,7 @@ function modelsTool(deps) {
93
93
  return defineTool({
94
94
  name: "sub2api_models",
95
95
  description:
96
- "列出 Sub2API 中转站当前可用的模型 id(来自上游 /v1/models,与模型选择器一致)。需要先登录。返回 id、显示名、上下文窗口与是否支持图片。",
96
+ "列出 Psapi 中转站当前可用的模型 id(来自上游 /v1/models,与模型选择器一致)。需要先登录。返回 id、显示名、上下文窗口与是否支持图片。",
97
97
  parameters: {
98
98
  limit: {
99
99
  type: "number",
@@ -133,7 +133,7 @@ function modelsTool(deps) {
133
133
  if (models.length === 0) {
134
134
  return {
135
135
  ok: false,
136
- message: "还没有同步到任何模型。请在 设置 → Sub2API 面板登录后点「刷新模型」。",
136
+ message: "还没有同步到任何模型。请在 设置 → Psapi 面板登录后点「刷新模型」。",
137
137
  count: 0,
138
138
  models: [],
139
139
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-sub2api",
3
- "version": "0.3.0",
4
- "description": "Sub2API provider for DeepSeek Harness: zero-friction signup, auto-provisioned API key, upstream model sync, balance and recharge",
3
+ "version": "0.4.1",
4
+ "description": "Psapi (sub.pscly.cc) provider for DeepSeek Harness: zero-friction signup, auto-provisioned API key, upstream model sync, balance and recharge",
5
5
  "type": "module",
6
6
  "license": "GPL-3.0-only",
7
7
  "main": "./lib/index.js",
@@ -60,7 +60,7 @@
60
60
  "dsh",
61
61
  "dsh-plugin",
62
62
  "deepseek-harness",
63
- "sub2api",
63
+ "psapi",
64
64
  "provider",
65
65
  "llm",
66
66
  "relay",