dsh-sub2api 0.2.8 → 0.2.9
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 +10 -0
- package/lib/index.js +28 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.9
|
|
4
|
+
|
|
5
|
+
- Mount the panel routes by **waiting for `webServer`**, not by sampling it once
|
|
6
|
+
during `apply`. The service is registered by a plugin that loads after this
|
|
7
|
+
one, so `ctx.get("webServer")` was undefined at that moment and every
|
|
8
|
+
`/api/sub2api/*` route was silently skipped — the settings page then showed
|
|
9
|
+
only "HTTP 404:响应不是 JSON". Found by installing the plugin into a real
|
|
10
|
+
DSH profile and watching it 404.
|
|
11
|
+
- Same treatment for `llm` and `webServer` on hosts without `ctx.inject`.
|
|
12
|
+
|
|
3
13
|
## 0.2.8
|
|
4
14
|
|
|
5
15
|
- The panel no longer depends on the provider registration succeeding. A
|
package/lib/index.js
CHANGED
|
@@ -118,16 +118,19 @@ export function apply(ctx, rawConfig = {}) {
|
|
|
118
118
|
logger,
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
-
const adapter =
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
const adapter =
|
|
122
|
+
Sub2ApiAdapter === undefined
|
|
123
|
+
? undefined
|
|
124
|
+
: new Sub2ApiAdapter({
|
|
125
|
+
ctx,
|
|
126
|
+
catalog,
|
|
127
|
+
apiBase: () => cfg().apiBase,
|
|
128
|
+
apiKeyEnv: () => cfg().apiKeyEnv,
|
|
129
|
+
timeoutMs: () => cfg().requestTimeoutMs,
|
|
130
|
+
idleTimeoutMs: () => cfg().streamIdleTimeoutMs,
|
|
131
|
+
transportRetries: () => cfg().retries,
|
|
132
|
+
logger,
|
|
133
|
+
});
|
|
131
134
|
|
|
132
135
|
const deps = { api, session, catalog, adapter, cfg, logger };
|
|
133
136
|
|
|
@@ -140,6 +143,10 @@ export function apply(ctx, rawConfig = {}) {
|
|
|
140
143
|
/** @type {{replace?: (providers: string[]) => void} | undefined} */
|
|
141
144
|
let adapterHandle;
|
|
142
145
|
const mountProvider = (llmCtx) => {
|
|
146
|
+
if (adapter === undefined) {
|
|
147
|
+
logger.warn("[sub2api] adapter 未加载,provider 路由未注册(面板仍可用)");
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
143
150
|
llmCtx.effect(() => {
|
|
144
151
|
try {
|
|
145
152
|
const providers = llmCtx.llm.registerConfigurableProviders([
|
|
@@ -202,10 +209,14 @@ export function apply(ctx, rawConfig = {}) {
|
|
|
202
209
|
else if (optional(ctx, "llm") !== undefined) mountDiscovery(ctx);
|
|
203
210
|
|
|
204
211
|
// 3) Browser routes.
|
|
205
|
-
|
|
206
|
-
|
|
212
|
+
//
|
|
213
|
+
// `webServer` is registered by another plugin, so at this moment it may not
|
|
214
|
+
// exist yet: reading it once here is why a correctly installed plugin could
|
|
215
|
+
// answer 404. `ctx.inject` waits for the service before mounting.
|
|
216
|
+
const mountRoutes = (webCtx) => webCtx.effect(() => {
|
|
217
|
+
const webServer = webCtx.webServer;
|
|
207
218
|
if (webServer === undefined || typeof webServer.register !== "function") {
|
|
208
|
-
logger.warn("[sub2api]
|
|
219
|
+
logger.warn("[sub2api] 宿主的 webServer 不可用,面板路由未注册(设置页会显示 404)");
|
|
209
220
|
return () => {};
|
|
210
221
|
}
|
|
211
222
|
const routes = makeRoutes({
|
|
@@ -226,6 +237,10 @@ export function apply(ctx, rawConfig = {}) {
|
|
|
226
237
|
return () => disposers.forEach((dispose) => dispose?.());
|
|
227
238
|
}, "sub2api: routes");
|
|
228
239
|
|
|
240
|
+
if (typeof ctx.inject === "function") ctx.inject(["webServer"], mountRoutes);
|
|
241
|
+
else if (optional(ctx, "webServer") !== undefined) mountRoutes(ctx);
|
|
242
|
+
else logger.warn("[sub2api] 宿主没有 webServer 服务,面板路由未注册(设置页会显示 404)");
|
|
243
|
+
|
|
229
244
|
// 4) Slash command for the terminal surface, where the panel does not exist.
|
|
230
245
|
ctx.effect(() => {
|
|
231
246
|
const dispose = applyCommands(ctx, { api, session, catalog, cfg });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-sub2api",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Sub2API 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",
|