dsh-gateway-provider 1.0.12 → 1.1.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/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. Config lives in the
88
- `llm-newapi:` section of `~/.dsh/settings.yaml` (the settings page edits
89
- the same keys). The frequently used ones:
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
- 全部可选 —— 下表每项都有可用默认值。配置写在 `~/.dsh/settings.yaml` 的 `llm-newapi:` 段(设置页改的就是同一批键)。常用项:
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
- /** User-settings namespace whose section overrides this entry. */
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. `settings.yaml` is a
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
- let current = () => config;
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: NS,
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(NS, async (request) => {
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
- ctx.inject(["settings"], (settingsCtx) => {
416
- settingsCtx.settings.installSection(ctx, NS, Config, config, {
417
- setSource: (source) => {
418
- current = source;
419
- },
420
- onChange: ensureRegistration,
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.0.12",
3
+ "version": "1.1.0",
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": "^0.1.2-rc.1",
74
- "@deepseek-ai/dsh-launch-environment": "^0.1.2-rc.1",
75
- "@deepseek-ai/dsh-llm": "^0.1.2-rc.1",
76
- "@deepseek-ai/dsh-timeout": "^0.1.2-rc.1",
73
+ "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
74
+ "@deepseek-ai/dsh-launch-environment": "0.2.0-rc.2",
75
+ "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
76
+ "@deepseek-ai/dsh-timeout": "0.2.0-rc.2",
77
77
  "@deepseek-ai/schemastery": "^3.18.1"
78
78
  }
79
79
  }