dsh-gateway-provider 1.0.12 → 1.1.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/README.md +5 -3
- package/docs/README.zh.md +1 -1
- package/index.js +29 -13
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -84,9 +84,11 @@ Everything lives in **Settings → Gateway Models**:
|
|
|
84
84
|
|
|
85
85
|
## Configuration reference
|
|
86
86
|
|
|
87
|
-
Optional — everything below has a working default.
|
|
88
|
-
`llm-newapi
|
|
89
|
-
the
|
|
87
|
+
Optional — everything below has a working default. With dsh ≥ 0.2 config
|
|
88
|
+
lives in the `llm-newapi` entry of the profile
|
|
89
|
+
(`~/.dsh/profiles/<name>/cordis.patch.yml`; the settings page edits the same
|
|
90
|
+
data). A pre-0.2 `~/.dsh/settings.yaml` section is imported automatically on
|
|
91
|
+
the first start where the plugin loads. The frequently used ones:
|
|
90
92
|
|
|
91
93
|
| Key | Default | Meaning |
|
|
92
94
|
| --- | --- | --- |
|
package/docs/README.zh.md
CHANGED
|
@@ -52,7 +52,7 @@ dsh --profile web
|
|
|
52
52
|
|
|
53
53
|
## 配置参考
|
|
54
54
|
|
|
55
|
-
全部可选 ——
|
|
55
|
+
全部可选 —— 下表每项都有可用默认值。dsh ≥ 0.2 配置存在 profile 的 `llm-newapi` entry(`~/.dsh/profiles/<name>/cordis.patch.yml`,设置页改的就是同一份数据);旧版 `~/.dsh/settings.yaml` 的 `llm-newapi:` 段会在插件可加载后的首次启动自动迁入。常用项:
|
|
56
56
|
|
|
57
57
|
| 键 | 默认值 | 含义 |
|
|
58
58
|
| --- | --- | --- |
|
package/index.js
CHANGED
|
@@ -39,7 +39,11 @@ import { DEFAULT_ENDPOINT_PRIORITY, deriveProtocolURLs } from "./lib/protocols.j
|
|
|
39
39
|
export const name = "llm-newapi";
|
|
40
40
|
export const inject = ["llm"];
|
|
41
41
|
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Settings namespace this plugin serves. dsh 0.2 keys settings (and model
|
|
44
|
+
* discovery) by the loader entry id; cordis.patch.yml declares the entry as
|
|
45
|
+
* `llm-newapi`, so the ids coincide and this remains the fallback name.
|
|
46
|
+
*/
|
|
43
47
|
const NS = "llm-newapi";
|
|
44
48
|
/** The legacy single provider route (kept for backwards compatibility). */
|
|
45
49
|
export const PROVIDER = "newapi";
|
|
@@ -60,7 +64,8 @@ const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 600_000;
|
|
|
60
64
|
const DEFAULT_CATALOG_TTL_MS = 30 * 60 * 1000;
|
|
61
65
|
|
|
62
66
|
/**
|
|
63
|
-
* String field tolerant of hand-edited YAML scalars.
|
|
67
|
+
* String field tolerant of hand-edited YAML scalars. The profile patch
|
|
68
|
+
* (`cordis.patch.yml`, and pre-0.2 `settings.yaml` imports) is a
|
|
64
69
|
* user-editable document parsed with YAML 1.2 core semantics: an unquoted
|
|
65
70
|
* `true` / `false` / `True` / `FALSE` round-trips as a boolean and an
|
|
66
71
|
* unquoted digit run as a number, long before the value reaches a strict
|
|
@@ -183,7 +188,7 @@ export const Config = z.object({
|
|
|
183
188
|
// ---- Additional gateways ----
|
|
184
189
|
/** Additional gateways; each becomes a `gateway:<id>` provider route. */
|
|
185
190
|
gateways: z.array(GatewaySchema).default([]),
|
|
186
|
-
});
|
|
191
|
+
}).volatile();
|
|
187
192
|
|
|
188
193
|
/**
|
|
189
194
|
* Normalize one gateway entry into the connection facts the adapter needs.
|
|
@@ -306,7 +311,12 @@ export function resolveGateways(config, environment) {
|
|
|
306
311
|
}
|
|
307
312
|
|
|
308
313
|
export function apply(ctx, config) {
|
|
309
|
-
|
|
314
|
+
/** Settings namespace this entry serves: the loader entry id, else the legacy name. */
|
|
315
|
+
const settingsNs = ctx.fiber.entry?.options.id ?? NS;
|
|
316
|
+
// dsh 0.2 hands apply() a volatile config reference (a frozen { get } whose
|
|
317
|
+
// snapshot updates after every settings write); plain objects from older
|
|
318
|
+
// harnesses pass through unchanged.
|
|
319
|
+
const current = () => (typeof config?.get === "function" ? config.get() : config);
|
|
310
320
|
let lastRaw;
|
|
311
321
|
let resolved = null;
|
|
312
322
|
/** Resolve (and cache) the gateway list from the current config snapshot. */
|
|
@@ -376,7 +386,7 @@ export function apply(ctx, config) {
|
|
|
376
386
|
const entries = gateways.map((g, i) => ({
|
|
377
387
|
provider: g.provider,
|
|
378
388
|
displayName: g.label,
|
|
379
|
-
settingsNs
|
|
389
|
+
settingsNs,
|
|
380
390
|
settingsPath: i === 0 ? [] : ["gateways", String(g.id)],
|
|
381
391
|
declared: i > 0,
|
|
382
392
|
}));
|
|
@@ -390,7 +400,7 @@ export function apply(ctx, config) {
|
|
|
390
400
|
ensureRegistration();
|
|
391
401
|
|
|
392
402
|
/** Expose model discovery so the web UI can fetch a gateway's model list. */
|
|
393
|
-
ctx.llm.registerModelDiscovery(
|
|
403
|
+
ctx.llm.registerModelDiscovery(settingsNs, async (request) => {
|
|
394
404
|
const env = launchEnvironmentOf(ctx);
|
|
395
405
|
const gateways = resolve();
|
|
396
406
|
const gw = request.provider !== undefined ? gateways.find((g) => g.provider === request.provider) : gateways[0];
|
|
@@ -412,12 +422,18 @@ export function apply(ctx, config) {
|
|
|
412
422
|
}
|
|
413
423
|
});
|
|
414
424
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
425
|
+
// dsh 0.2 settings contract: the volatile-marked Config schema is picked
|
|
426
|
+
// up by the settings service automatically (installSection is gone). Settings
|
|
427
|
+
// writes land in the profile and the loader emits loader/volatile-update;
|
|
428
|
+
// re-resolve and re-register then. resolve() holds the last good snapshot
|
|
429
|
+
// when an update arrives invalid, so the catch only guards registration
|
|
430
|
+
// races (e.g. a provider-route conflict on a mid-flight update).
|
|
431
|
+
ctx.on("loader/volatile-update", () => {
|
|
432
|
+
try {
|
|
433
|
+
ensureRegistration();
|
|
434
|
+
} catch (error) {
|
|
435
|
+
ctx.logger.error("llm-newapi: keeping the last good configuration after a settings update");
|
|
436
|
+
ctx.logger.error(error);
|
|
437
|
+
}
|
|
422
438
|
});
|
|
423
439
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-gateway-provider",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Generic LLM gateway model provider plugin for DeepSeek Harness: mounts newapi / LiteLLM / Higress / any OpenAI-compatible gateway as provider routes, auto-discovers the model list, enriches every model with models.dev parameters, and dispatches each model over its native wire protocol (OpenAI / Anthropic / Gemini) via the pi-ai SDK",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
73
|
-
"@deepseek-ai/dsh-credentials": "
|
|
74
|
-
"@deepseek-ai/dsh-launch-environment": "
|
|
75
|
-
"@deepseek-ai/dsh-llm": "
|
|
76
|
-
"@deepseek-ai/dsh-timeout": "
|
|
73
|
+
"@deepseek-ai/dsh-credentials": "0.2.1-rc.2",
|
|
74
|
+
"@deepseek-ai/dsh-launch-environment": "0.2.1-rc.2",
|
|
75
|
+
"@deepseek-ai/dsh-llm": "0.2.1-rc.2",
|
|
76
|
+
"@deepseek-ai/dsh-timeout": "0.2.1-rc.2",
|
|
77
77
|
"@deepseek-ai/schemastery": "^3.18.1"
|
|
78
78
|
}
|
|
79
79
|
}
|