dsh-sub2api 0.10.3 → 0.11.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 +19 -0
- package/lib/adapter.js +12 -0
- package/lib/client.js +49 -0
- package/package.json +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.11.1
|
|
4
|
+
|
|
5
|
+
- Discoverability. The package description and keywords now lead with the terms
|
|
6
|
+
people actually search for — `sub2api`, `dsh-sub2api`, `openai-compatible`,
|
|
7
|
+
`balance`, `recharge` — instead of only the brand name. Searching npm for
|
|
8
|
+
"sub2api" did not surface this package at all, which is the gateway's own name.
|
|
9
|
+
|
|
10
|
+
## 0.11.0
|
|
11
|
+
|
|
12
|
+
- **Not being signed in now says so.** A request made without a login used to
|
|
13
|
+
leave the plugin, reach the gateway, and come back as `401 API key is required
|
|
14
|
+
in Authorization header` — a message about a key, for a user whose problem is
|
|
15
|
+
that they never signed in. The adapter refuses before touching the transport
|
|
16
|
+
and answers instead: 还没有登录 dsh-sub2api。打开 设置 → dsh-sub2api,用一个邮箱和密码
|
|
17
|
+
登录或注册即可。
|
|
18
|
+
- **A reminder on the screen an empty conversation opens on.** While nobody is
|
|
19
|
+
signed in, `conversation.hero.options` shows a single line pointing at
|
|
20
|
+
设置 → dsh-sub2api. It disappears the moment a login exists.
|
|
21
|
+
|
|
3
22
|
## 0.10.3
|
|
4
23
|
|
|
5
24
|
- **A request can no longer go out with no key.** When the adapter could not
|
package/lib/adapter.js
CHANGED
|
@@ -156,6 +156,18 @@ export class Sub2ApiAdapter extends LlmAdapter {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
async *stream(options) {
|
|
159
|
+
// Refuse before touching the transport. A request with no key leaves here,
|
|
160
|
+
// comes back as "401 API key is required in Authorization header", and sends
|
|
161
|
+
// the user looking for a broken key when the real answer is "you are not
|
|
162
|
+
// signed in". Checking here turns that into a sentence they can act on.
|
|
163
|
+
const key = await this.deps.session?.()?.apiKey?.().catch(() => undefined);
|
|
164
|
+
if (typeof key !== "string" || key === "") {
|
|
165
|
+
throw new Sub2ApiError(
|
|
166
|
+
"还没有登录 dsh-sub2api。打开 设置 → dsh-sub2api,用一个邮箱和密码登录或注册即可。",
|
|
167
|
+
{ code: "not_logged_in" },
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
159
171
|
const service = await this.#service();
|
|
160
172
|
const route = service.routes()[0];
|
|
161
173
|
// An empty `models` array still yields a route object; without this check
|
package/lib/client.js
CHANGED
|
@@ -1550,6 +1550,42 @@ window.__ModuleLoader__.load({
|
|
|
1550
1550
|
return h("div", { "data-sub2api": "" }, h(Boundary, null, h(SectionInner, null)));
|
|
1551
1551
|
}
|
|
1552
1552
|
|
|
1553
|
+
// ------------------------------------------------------ login nudge
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* The line shown on the empty conversation screen while nobody is signed in.
|
|
1557
|
+
*
|
|
1558
|
+
* A user who installs the plugin and starts typing gets a 401; saying why on
|
|
1559
|
+
* the screen they are already looking at is the difference between "this
|
|
1560
|
+
* thing is broken" and "there is one step left". Renders nothing once a
|
|
1561
|
+
* login exists, so it never becomes furniture.
|
|
1562
|
+
*/
|
|
1563
|
+
function LoginNudge() {
|
|
1564
|
+
const { state } = useStatus();
|
|
1565
|
+
if (state === null || state.loggedIn === true) return null;
|
|
1566
|
+
|
|
1567
|
+
return h("button", {
|
|
1568
|
+
type: "button",
|
|
1569
|
+
"data-sub2api": "",
|
|
1570
|
+
onClick: () => toastStore.push("打开 设置 → dsh-sub2api 登录或注册", "ok"),
|
|
1571
|
+
style: {
|
|
1572
|
+
display: "inline-flex",
|
|
1573
|
+
alignItems: "center",
|
|
1574
|
+
gap: 8,
|
|
1575
|
+
padding: "8px 14px",
|
|
1576
|
+
borderRadius: 999,
|
|
1577
|
+
border: "0.5px solid " + C.line,
|
|
1578
|
+
background: C.surface,
|
|
1579
|
+
color: C.second,
|
|
1580
|
+
fontSize: 12.5,
|
|
1581
|
+
cursor: "pointer",
|
|
1582
|
+
maxWidth: "100%",
|
|
1583
|
+
},
|
|
1584
|
+
},
|
|
1585
|
+
h("span", { style: { width: 7, height: 7, borderRadius: 999, background: C.warn, flex: "0 0 7px" } }),
|
|
1586
|
+
h("span", null, "还没登录 dsh-sub2api —— 去 设置 → dsh-sub2api 登录后即可使用这里的模型"));
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1553
1589
|
// ------------------------------------------------------------ badge
|
|
1554
1590
|
|
|
1555
1591
|
/**
|
|
@@ -1689,6 +1725,18 @@ window.__ModuleLoader__.load({
|
|
|
1689
1725
|
} catch {
|
|
1690
1726
|
// The sidebar slot is optional.
|
|
1691
1727
|
}
|
|
1728
|
+
try {
|
|
1729
|
+
// The hero area is what an empty conversation opens on, so the reminder
|
|
1730
|
+
// is already in view when someone starts typing without a login.
|
|
1731
|
+
ctx.slots.inject("conversation.hero.options", () =>
|
|
1732
|
+
ctx.slots.register(
|
|
1733
|
+
{ name: "conversation.hero.options", id: "sub2api-login" },
|
|
1734
|
+
LoginNudge,
|
|
1735
|
+
),
|
|
1736
|
+
);
|
|
1737
|
+
} catch {
|
|
1738
|
+
// Older hosts without the hero slot simply do not show the reminder.
|
|
1739
|
+
}
|
|
1692
1740
|
try {
|
|
1693
1741
|
ctx.slots.inject("conversation.input.right", () =>
|
|
1694
1742
|
ctx.slots.register(
|
|
@@ -1705,6 +1753,7 @@ window.__ModuleLoader__.load({
|
|
|
1705
1753
|
exports.inject = inject;
|
|
1706
1754
|
exports.Section = Section;
|
|
1707
1755
|
exports.BalanceBadge = BalanceBadge;
|
|
1756
|
+
exports.LoginNudge = LoginNudge;
|
|
1708
1757
|
// Exposed for the load test: pure read/write of the remembered layout.
|
|
1709
1758
|
exports.__sections = { readOpenSections, DEFAULT_OPEN, OPEN_KEY };
|
|
1710
1759
|
return module.exports;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-sub2api",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.11.1",
|
|
4
|
+
"description": "Sub2API / Psapi provider for DeepSeek Harness (DSH): sign in with an email, the plugin creates its own API key, syncs the model catalogue, and keeps balance, usage and recharge in one panel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "GPL-3.0-only",
|
|
7
7
|
"main": "./lib/index.js",
|
|
@@ -61,11 +61,17 @@
|
|
|
61
61
|
"dsh",
|
|
62
62
|
"dsh-plugin",
|
|
63
63
|
"deepseek-harness",
|
|
64
|
+
"dsh-sub2api",
|
|
65
|
+
"sub2api",
|
|
64
66
|
"psapi",
|
|
65
|
-
"provider",
|
|
66
67
|
"llm",
|
|
68
|
+
"provider",
|
|
67
69
|
"relay",
|
|
68
|
-
"gateway"
|
|
70
|
+
"gateway",
|
|
71
|
+
"openai-compatible",
|
|
72
|
+
"model-router",
|
|
73
|
+
"balance",
|
|
74
|
+
"recharge"
|
|
69
75
|
],
|
|
70
76
|
"scripts": {
|
|
71
77
|
"test": "node test/all.mjs",
|