dsh-sub2api 0.4.2 → 0.5.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 +33 -0
- package/README.md +15 -0
- package/lib/client.js +81 -10
- package/lib/constants.js +15 -0
- package/lib/index.js +43 -1
- package/lib/panel-store.js +21 -2
- package/lib/routes.js +1 -1
- package/lib/sub2api/catalog.js +36 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
- **`deepseek-flash` ships with the plugin.** A zero-balance account gets
|
|
6
|
+
`403 INSUFFICIENT_BALANCE` from `/v1/models`, which used to leave the model
|
|
7
|
+
picker completely empty — an install that looks broken. One entry is always
|
|
8
|
+
offered now, with the measured 1,048,576-token window, and a real catalogue
|
|
9
|
+
replaces it as soon as one arrives.
|
|
10
|
+
- **Installing switches DSH's default model to `sub2api/deepseek-flash`.** Done
|
|
11
|
+
through the host's `agentDefaultModel` service, so it is written into the
|
|
12
|
+
profile and survives restarts. Once only: pick another provider afterwards and
|
|
13
|
+
the plugin leaves that alone.
|
|
14
|
+
- Fixed a regression this introduced while it was being built: the auto-sync
|
|
15
|
+
after a top-up keyed off "the catalogue is empty", which can no longer be true,
|
|
16
|
+
so it never ran once the built-in existed. It now asks the catalogue whether
|
|
17
|
+
the *upstream* is empty.
|
|
18
|
+
- The panel tags the built-in model so its presence is not mistaken for an
|
|
19
|
+
upstream listing.
|
|
20
|
+
|
|
21
|
+
## 0.4.3
|
|
22
|
+
|
|
23
|
+
Interface polish, driven by an audit against the host's real design tokens.
|
|
24
|
+
|
|
25
|
+
- **Dark mode actually uses the warning colour.** The panel asked for
|
|
26
|
+
`--dsw-alias-state-warning-primary`; DSH defines `state-warn-primary`. The name
|
|
27
|
+
never matched, so the amber fell back to a light-mode value on dark surfaces.
|
|
28
|
+
- Keyboard focus is visible again: inline styles cannot express `:focus-visible`,
|
|
29
|
+
so one scoped stylesheet carries the ring, and buttons, rows and inputs gained
|
|
30
|
+
hover and pressed states that work on both themes.
|
|
31
|
+
- `prefers-reduced-motion` is respected.
|
|
32
|
+
- Model search matches the display name as well as the id, appears from five
|
|
33
|
+
models instead of nine, and reports how many matched.
|
|
34
|
+
- Progress bars are 6px tall with a real `progressbar` role and value.
|
|
35
|
+
|
|
3
36
|
## 0.4.2
|
|
4
37
|
|
|
5
38
|
Recharge and key handling, which are the two places where a mistake costs
|
package/README.md
CHANGED
|
@@ -65,6 +65,21 @@ dsh plugin add dsh-sub2api
|
|
|
65
65
|
|
|
66
66
|
---
|
|
67
67
|
|
|
68
|
+
## 内置模型与默认模型
|
|
69
|
+
|
|
70
|
+
安装后有两件事自动发生:
|
|
71
|
+
|
|
72
|
+
**1. DSH 的默认模型被改成 `sub2api/deepseek-flash`**
|
|
73
|
+
|
|
74
|
+
写进 profile 配置(`agent-default-model`),重启后依然生效。**只做一次** ——
|
|
75
|
+
你之后手动换成别的 provider,插件不会再抢回来。
|
|
76
|
+
|
|
77
|
+
**2. 永远自带一个 `deepseek-flash`**
|
|
78
|
+
|
|
79
|
+
零余额账号请求 `/v1/models` 会拿到 `403 INSUFFICIENT_BALANCE`,以前结果是模型选择器**完全空白**,装完像坏了一样。现在无论有没有余额、有没有同步成功,列表里至少有一个 `deepseek-flash`(上下文 1,048,576,实测值);上游真的返回后,真实目录会覆盖它。
|
|
80
|
+
|
|
81
|
+
面板里它带一个「内置」标签,避免被误认为是上游列出来的。
|
|
82
|
+
|
|
68
83
|
## 聊天输入框右下角的余额徽章
|
|
69
84
|
|
|
70
85
|
插件在对话输入框的右下角(`conversation.input.right`)常驻一个小徽章:
|
package/lib/client.js
CHANGED
|
@@ -159,10 +159,41 @@ window.__ModuleLoader__.load({
|
|
|
159
159
|
base: "var(--dsw-alias-bg-base, #ffffff)",
|
|
160
160
|
accent: "var(--dsw-alias-state-business-primary, #2563eb)",
|
|
161
161
|
ok: "var(--dsw-alias-state-success-primary, #15803d)",
|
|
162
|
-
warn
|
|
162
|
+
// DSH names it `warn`, not `warning`: the wrong name silently falls back
|
|
163
|
+
// to this light-mode amber and reads badly on a dark surface.
|
|
164
|
+
warn: "var(--dsw-alias-state-warn-primary, #b45309)",
|
|
163
165
|
bad: "var(--dsw-alias-state-error-primary, #dc2626)",
|
|
164
166
|
};
|
|
165
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Focus rings for keyboard users.
|
|
170
|
+
*
|
|
171
|
+
* Everything here is inline styles, which cannot express `:focus-visible`,
|
|
172
|
+
* so a single scoped stylesheet carries the rule and the roots opt in with
|
|
173
|
+
* `data-sub2api`.
|
|
174
|
+
*/
|
|
175
|
+
const FOCUS_CSS = [
|
|
176
|
+
"[data-sub2api] :focus-visible{outline:2px solid " + C.accent + ";outline-offset:2px;border-radius:8px}",
|
|
177
|
+
"[data-sub2api] input:focus-visible{outline-offset:1px}",
|
|
178
|
+
"[data-sub2api] button:focus:not(:focus-visible){outline:none}",
|
|
179
|
+
// A neutral overlay reads correctly on both light and dark surfaces,
|
|
180
|
+
// which `filter: brightness()` does not.
|
|
181
|
+
"[data-sub2api] [data-sub2api-btn]:not(:disabled):hover{box-shadow:inset 0 0 0 999px rgba(127,127,127,.09)}",
|
|
182
|
+
"[data-sub2api] [data-sub2api-btn]:not(:disabled):active{box-shadow:inset 0 0 0 999px rgba(127,127,127,.16)}",
|
|
183
|
+
"[data-sub2api] [data-sub2api-row]:hover{background:rgba(127,127,127,.055)}",
|
|
184
|
+
"@media (prefers-reduced-motion: reduce){[data-sub2api] *{transition:none!important;animation:none!important}}",
|
|
185
|
+
].join("");
|
|
186
|
+
|
|
187
|
+
function installFocusStyles(doc) {
|
|
188
|
+
const id = "sub2api-focus";
|
|
189
|
+
if (!doc || typeof doc.getElementById !== "function") return;
|
|
190
|
+
if (doc.getElementById(id)) return;
|
|
191
|
+
const style = doc.createElement("style");
|
|
192
|
+
style.id = id;
|
|
193
|
+
style.textContent = FOCUS_CSS;
|
|
194
|
+
(doc.head || doc.documentElement).appendChild(style);
|
|
195
|
+
}
|
|
196
|
+
|
|
166
197
|
const T = {
|
|
167
198
|
card: {
|
|
168
199
|
border: "0.5px solid " + C.line,
|
|
@@ -215,7 +246,11 @@ window.__ModuleLoader__.load({
|
|
|
215
246
|
// Destructive: rebuilding the key revokes the one in use.
|
|
216
247
|
danger: { border: "1px solid " + C.bad, background: "transparent", color: C.bad },
|
|
217
248
|
};
|
|
218
|
-
return h("button", {
|
|
249
|
+
return h("button", {
|
|
250
|
+
"data-sub2api-btn": "",
|
|
251
|
+
style: { ...base, ...(variants[variant] || {}), ...style },
|
|
252
|
+
...rest,
|
|
253
|
+
}, children);
|
|
219
254
|
}
|
|
220
255
|
|
|
221
256
|
function Card({ title, meta, children, id, aside }) {
|
|
@@ -341,8 +376,17 @@ window.__ModuleLoader__.load({
|
|
|
341
376
|
h("div", { style: { display: "flex", justifyContent: "space-between", fontSize: 11.5, color: C.muted } },
|
|
342
377
|
h("span", null, label),
|
|
343
378
|
h("span", null, Math.round(p) + "%")),
|
|
344
|
-
h("div", {
|
|
345
|
-
|
|
379
|
+
h("div", {
|
|
380
|
+
role: "progressbar",
|
|
381
|
+
"aria-label": label + "用量",
|
|
382
|
+
"aria-valuenow": Math.round(p),
|
|
383
|
+
"aria-valuemin": 0,
|
|
384
|
+
"aria-valuemax": 100,
|
|
385
|
+
style: { height: 6, borderRadius: 999, background: C.sunken, marginTop: 4, overflow: "hidden" },
|
|
386
|
+
},
|
|
387
|
+
h("div", {
|
|
388
|
+
style: { width: p + "%", height: "100%", background: tone, borderRadius: 999, transition: "width 240ms ease" },
|
|
389
|
+
})),
|
|
346
390
|
);
|
|
347
391
|
}
|
|
348
392
|
|
|
@@ -998,6 +1042,7 @@ window.__ModuleLoader__.load({
|
|
|
998
1042
|
};
|
|
999
1043
|
|
|
1000
1044
|
return h("div", {
|
|
1045
|
+
"data-sub2api-row": "",
|
|
1001
1046
|
style: {
|
|
1002
1047
|
display: "flex",
|
|
1003
1048
|
alignItems: "center",
|
|
@@ -1005,6 +1050,7 @@ window.__ModuleLoader__.load({
|
|
|
1005
1050
|
padding: "7px 12px",
|
|
1006
1051
|
borderTop: "0.5px solid " + C.line,
|
|
1007
1052
|
fontSize: 13,
|
|
1053
|
+
transition: "background 120ms ease",
|
|
1008
1054
|
},
|
|
1009
1055
|
},
|
|
1010
1056
|
h("input", {
|
|
@@ -1016,6 +1062,19 @@ window.__ModuleLoader__.load({
|
|
|
1016
1062
|
h("code", {
|
|
1017
1063
|
style: { ...T.mono, flex: "1 1 auto", minWidth: 0, overflow: "hidden", textOverflow: "ellipsis" },
|
|
1018
1064
|
}, model.id),
|
|
1065
|
+
model.builtin === true
|
|
1066
|
+
? h("span", {
|
|
1067
|
+
title: "插件自带,上游没有返回时也能用",
|
|
1068
|
+
style: {
|
|
1069
|
+
fontSize: 11,
|
|
1070
|
+
padding: "0 6px",
|
|
1071
|
+
borderRadius: 999,
|
|
1072
|
+
border: "0.5px solid " + C.line,
|
|
1073
|
+
color: C.muted,
|
|
1074
|
+
whiteSpace: "nowrap",
|
|
1075
|
+
},
|
|
1076
|
+
}, "内置")
|
|
1077
|
+
: null,
|
|
1019
1078
|
editing
|
|
1020
1079
|
? h("span", { style: { display: "flex", gap: 6, alignItems: "center" } },
|
|
1021
1080
|
h("input", {
|
|
@@ -1069,7 +1128,10 @@ window.__ModuleLoader__.load({
|
|
|
1069
1128
|
|
|
1070
1129
|
const filtered = useMemo(() => {
|
|
1071
1130
|
const q = query.trim().toLowerCase();
|
|
1072
|
-
|
|
1131
|
+
if (q === "") return everything;
|
|
1132
|
+
return everything.filter((m) =>
|
|
1133
|
+
m.id.toLowerCase().includes(q) || String(m.displayName ?? "").toLowerCase().includes(q),
|
|
1134
|
+
);
|
|
1073
1135
|
}, [everything, query]);
|
|
1074
1136
|
|
|
1075
1137
|
const toggle = (id) => {
|
|
@@ -1139,13 +1201,18 @@ window.__ModuleLoader__.load({
|
|
|
1139
1201
|
),
|
|
1140
1202
|
expanded
|
|
1141
1203
|
? h("div", null,
|
|
1142
|
-
everything.length >
|
|
1143
|
-
? h("div", { style: { marginBottom: 8 } },
|
|
1204
|
+
everything.length > 4
|
|
1205
|
+
? h("div", { style: { marginBottom: 8, display: "flex", gap: 8, alignItems: "center" } },
|
|
1144
1206
|
h(TextField, {
|
|
1145
|
-
placeholder: "搜索模型",
|
|
1207
|
+
placeholder: "搜索模型 id 或名称",
|
|
1146
1208
|
value: query,
|
|
1147
1209
|
onChange: (e) => setQuery(e.target.value),
|
|
1148
|
-
|
|
1210
|
+
style: { flex: 1 },
|
|
1211
|
+
}),
|
|
1212
|
+
query.trim() === ""
|
|
1213
|
+
? null
|
|
1214
|
+
: h("span", { style: { ...T.hint, whiteSpace: "nowrap" } },
|
|
1215
|
+
`${filtered.length} / ${everything.length}`))
|
|
1149
1216
|
: null,
|
|
1150
1217
|
h("div", {
|
|
1151
1218
|
style: { maxHeight: 300, overflow: "auto", border: "0.5px solid " + C.line, borderRadius: 12 },
|
|
@@ -1436,7 +1503,10 @@ window.__ModuleLoader__.load({
|
|
|
1436
1503
|
}
|
|
1437
1504
|
|
|
1438
1505
|
function Section() {
|
|
1439
|
-
|
|
1506
|
+
useEffect(() => {
|
|
1507
|
+
installFocusStyles(typeof document === "undefined" ? undefined : document);
|
|
1508
|
+
}, []);
|
|
1509
|
+
return h("div", { "data-sub2api": "" }, h(Boundary, null, h(SectionInner, null)));
|
|
1440
1510
|
}
|
|
1441
1511
|
|
|
1442
1512
|
// ------------------------------------------------------------ badge
|
|
@@ -1481,6 +1551,7 @@ window.__ModuleLoader__.load({
|
|
|
1481
1551
|
|
|
1482
1552
|
return h("button", {
|
|
1483
1553
|
type: "button",
|
|
1554
|
+
"data-sub2api": "",
|
|
1484
1555
|
title: detail,
|
|
1485
1556
|
"aria-label": `Psapi ${known ? "余额 " + money(balance) : "余额未知"},点击${low ? "去充值" : "刷新"}`,
|
|
1486
1557
|
onClick,
|
package/lib/constants.js
CHANGED
|
@@ -73,6 +73,21 @@ export const DEFAULT_CONTEXT_WINDOW = 128000;
|
|
|
73
73
|
* Only families with direct evidence belong here: a figure larger than the real
|
|
74
74
|
* limit turns every long request into a 400, and a smaller one compacts early.
|
|
75
75
|
*/
|
|
76
|
+
/**
|
|
77
|
+
* The model a fresh install always offers, upstream or not.
|
|
78
|
+
*
|
|
79
|
+
* Installing the plugin on a zero-balance account returns `403
|
|
80
|
+
* INSUFFICIENT_BALANCE` from `/v1/models`, which used to leave the picker
|
|
81
|
+
* completely empty — an install that looks broken. One entry is declared
|
|
82
|
+
* locally so the plugin is usable the moment it lands, and the real catalogue
|
|
83
|
+
* replaces it as soon as it arrives.
|
|
84
|
+
*/
|
|
85
|
+
export const BUILTIN_MODEL = {
|
|
86
|
+
id: "deepseek-flash",
|
|
87
|
+
name: "deepseek-flash",
|
|
88
|
+
builtin: true,
|
|
89
|
+
};
|
|
90
|
+
|
|
76
91
|
export const KNOWN_CONTEXT = [
|
|
77
92
|
// Measured on sub.pscly.cc: 897,791 tokens accepted, 1,050,041 rejected with
|
|
78
93
|
// "maximum context length is 1048576 tokens".
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @module dsh-sub2api
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { PROVIDER, PLUGIN_NAME, SETTINGS_NS } from "./constants.js";
|
|
12
|
+
import { PROVIDER, PLUGIN_NAME, SETTINGS_NS, BUILTIN_MODEL } from "./constants.js";
|
|
13
13
|
import { readFileSync } from "node:fs";
|
|
14
14
|
import { resolveConfig } from "./config.js";
|
|
15
15
|
import { Sub2ApiAdapter } from "./adapter.js";
|
|
@@ -208,6 +208,48 @@ export function apply(ctx, rawConfig = {}) {
|
|
|
208
208
|
if (typeof ctx.inject === "function") ctx.inject(["llm"], mountDiscovery);
|
|
209
209
|
else if (optional(ctx, "llm") !== undefined) mountDiscovery(ctx);
|
|
210
210
|
|
|
211
|
+
// 2.5) Make this the default model for new conversations, once per install.
|
|
212
|
+
//
|
|
213
|
+
// `agentDefaultModel` is the host service that owns that selection and
|
|
214
|
+
// writes it into the profile, so the choice survives restarts. It runs
|
|
215
|
+
// once: a user who later picks another provider keeps that choice.
|
|
216
|
+
if (typeof ctx.inject === "function") {
|
|
217
|
+
ctx.inject(["agentDefaultModel"], (defaultCtx) => {
|
|
218
|
+
defaultCtx.effect(() => {
|
|
219
|
+
let cancelled = false;
|
|
220
|
+
void (async () => {
|
|
221
|
+
try {
|
|
222
|
+
await panel.load();
|
|
223
|
+
if (cancelled || panel.defaultModelApplied()) return;
|
|
224
|
+
// `ctx.get` is the canonical accessor and works on hosts that do
|
|
225
|
+
// not project injected services onto the context object.
|
|
226
|
+
const service =
|
|
227
|
+
typeof defaultCtx.get === "function"
|
|
228
|
+
? defaultCtx.get("agentDefaultModel")
|
|
229
|
+
: defaultCtx.agentDefaultModel;
|
|
230
|
+
if (service === undefined) return;
|
|
231
|
+
|
|
232
|
+
const current = typeof service.currentSelection === "function" ? service.currentSelection() : undefined;
|
|
233
|
+
if (current?.provider === PROVIDER && current?.model === BUILTIN_MODEL.id) {
|
|
234
|
+
await panel.markDefaultModelApplied();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
await service.saveSelection({ provider: PROVIDER, model: BUILTIN_MODEL.id });
|
|
238
|
+
await panel.markDefaultModelApplied();
|
|
239
|
+
logger.info(`[sub2api] 已把 DSH 默认模型设为 ${PROVIDER}/${BUILTIN_MODEL.id}`);
|
|
240
|
+
} catch (error) {
|
|
241
|
+
logger.warn(
|
|
242
|
+
`[sub2api] 设置默认模型失败(不影响使用):${error instanceof Error ? error.message : error}`,
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
})();
|
|
246
|
+
return () => {
|
|
247
|
+
cancelled = true;
|
|
248
|
+
};
|
|
249
|
+
}, "sub2api: default-model");
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
211
253
|
// 3) Browser routes.
|
|
212
254
|
//
|
|
213
255
|
// `webServer` is registered by another plugin, so at this moment it may not
|
package/lib/panel-store.js
CHANGED
|
@@ -23,7 +23,7 @@ export class PanelStore {
|
|
|
23
23
|
this.deps = deps;
|
|
24
24
|
this.logger = deps.logger ?? { warn() {} };
|
|
25
25
|
/** @type {PanelState} */
|
|
26
|
-
this.state = { visible: [], contextOverrides: {} };
|
|
26
|
+
this.state = { visible: [], contextOverrides: {}, defaultModelApplied: false };
|
|
27
27
|
this.loaded = false;
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -57,6 +57,24 @@ export class PanelStore {
|
|
|
57
57
|
return this.state;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Whether this install already pointed DSH's default model here.
|
|
62
|
+
*
|
|
63
|
+
* Once only: if the user later picks another provider on purpose, the plugin
|
|
64
|
+
* must not fight them for it on every start.
|
|
65
|
+
* @returns {boolean}
|
|
66
|
+
*/
|
|
67
|
+
defaultModelApplied() {
|
|
68
|
+
return this.state.defaultModelApplied === true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** @returns {Promise<void>} */
|
|
72
|
+
async markDefaultModelApplied() {
|
|
73
|
+
if (this.state.defaultModelApplied === true) return;
|
|
74
|
+
this.state.defaultModelApplied = true;
|
|
75
|
+
await this.#persist();
|
|
76
|
+
}
|
|
77
|
+
|
|
60
78
|
/** @returns {string[]} allowlist; empty means "show every model" */
|
|
61
79
|
visible() {
|
|
62
80
|
return this.state.visible;
|
|
@@ -109,6 +127,7 @@ export class PanelStore {
|
|
|
109
127
|
return {
|
|
110
128
|
visible: [...this.state.visible],
|
|
111
129
|
contextOverrides: { ...this.state.contextOverrides },
|
|
130
|
+
defaultModelApplied: this.state.defaultModelApplied === true,
|
|
112
131
|
};
|
|
113
132
|
}
|
|
114
133
|
|
|
@@ -127,7 +146,7 @@ export class PanelStore {
|
|
|
127
146
|
/** @returns {PanelState} */
|
|
128
147
|
function normalizeState(raw) {
|
|
129
148
|
/** @type {PanelState} */
|
|
130
|
-
const state = { visible: [], contextOverrides: {} };
|
|
149
|
+
const state = { visible: [], contextOverrides: {}, defaultModelApplied: raw?.defaultModelApplied === true };
|
|
131
150
|
|
|
132
151
|
const list = Array.isArray(raw?.visible) ? raw.visible : Array.isArray(raw?.ids) ? raw.ids : [];
|
|
133
152
|
state.visible = cleanIds(list);
|
package/lib/routes.js
CHANGED
|
@@ -68,7 +68,7 @@ export function makeRoutes(deps) {
|
|
|
68
68
|
const failedAt = catalog.lastError?.at;
|
|
69
69
|
if (!blockedByBalance && typeof failedAt === "number" && now - failedAt < 120000) return;
|
|
70
70
|
|
|
71
|
-
const empty = catalog.
|
|
71
|
+
const empty = catalog.isEmpty();
|
|
72
72
|
const funded = Number.isFinite(balance) && balance > 0;
|
|
73
73
|
if (empty ? !funded : !catalog.stale) return;
|
|
74
74
|
|
package/lib/sub2api/catalog.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
VISION_HINTS,
|
|
20
20
|
} from "../constants.js";
|
|
21
21
|
import { Sub2ApiError } from "../util.js";
|
|
22
|
+
import { BUILTIN_MODEL } from "../constants.js";
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* @typedef {object} ModelRecord
|
|
@@ -213,11 +214,38 @@ export class ModelCatalog {
|
|
|
213
214
|
* back chain is config → upstream → measured table → conservative default,
|
|
214
215
|
* and `contextSource` records which one answered.
|
|
215
216
|
*/
|
|
217
|
+
/**
|
|
218
|
+
* Whether the upstream has told us nothing yet.
|
|
219
|
+
*
|
|
220
|
+
* Distinct from `visible().length === 0`, which can no longer happen: the
|
|
221
|
+
* built-in model is always offered. Callers that key off "the catalogue is
|
|
222
|
+
* empty" mean this one — otherwise the built-in silently disables the
|
|
223
|
+
* auto-sync that runs after a top-up.
|
|
224
|
+
* @returns {boolean}
|
|
225
|
+
*/
|
|
226
|
+
isEmpty() {
|
|
227
|
+
return this.models.length === 0;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Upstream models in display order, with the built-in always present.
|
|
232
|
+
*
|
|
233
|
+
* The built-in sits last so a real catalogue reads first; when upstream also
|
|
234
|
+
* lists the same id, upstream wins — its metadata is fresher than ours.
|
|
235
|
+
* @returns {Array<ModelRecord & {builtin?: boolean}>}
|
|
236
|
+
*/
|
|
237
|
+
catalogue() {
|
|
238
|
+
const has = this.models.some((model) => model.id === BUILTIN_MODEL.id);
|
|
239
|
+
return has ? [...this.models] : [...this.models, { ...BUILTIN_MODEL }];
|
|
240
|
+
}
|
|
241
|
+
|
|
216
242
|
visible() {
|
|
217
243
|
const allow = this.allowed();
|
|
244
|
+
const keep = (model) =>
|
|
245
|
+
model.builtin === true || allow.length === 0 || allow.includes(model.id);
|
|
218
246
|
|
|
219
|
-
return this.
|
|
220
|
-
.filter(
|
|
247
|
+
return this.catalogue()
|
|
248
|
+
.filter(keep)
|
|
221
249
|
.map((model) => ({ ...model, ...this.resolveContext(model) }));
|
|
222
250
|
}
|
|
223
251
|
|
|
@@ -264,7 +292,11 @@ export class ModelCatalog {
|
|
|
264
292
|
error: this.lastError ?? null,
|
|
265
293
|
needsRecharge: this.lastError?.code === "INSUFFICIENT_BALANCE",
|
|
266
294
|
allowed: this.allowed(),
|
|
267
|
-
all: this.
|
|
295
|
+
all: this.catalogue().map((model) => ({
|
|
296
|
+
id: model.id,
|
|
297
|
+
name: model.name,
|
|
298
|
+
builtin: model.builtin === true,
|
|
299
|
+
})),
|
|
268
300
|
models: this.visible().map((model) => ({
|
|
269
301
|
id: model.id,
|
|
270
302
|
name: model.name,
|
|
@@ -274,6 +306,7 @@ export class ModelCatalog {
|
|
|
274
306
|
reasoningEfforts: this.reasoningFor(model.id)?.efforts.map((e) => e.name) ?? null,
|
|
275
307
|
vision: model.vision === true,
|
|
276
308
|
ownedBy: model.ownedBy ?? null,
|
|
309
|
+
builtin: model.builtin === true,
|
|
277
310
|
})),
|
|
278
311
|
};
|
|
279
312
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-sub2api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
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",
|