@goodandready/dsh-ollama-cloud-provider 0.1.24 → 0.1.26

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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.26 — 2026-11-05
4
+
5
+ - Added configurable pre-response retry/backoff (`retryMaxRetries`, base/max
6
+ delay, jitter). Only headers/pre-first-token failures retry; post-token
7
+ streams never retry, and account rotation is not duplicated.
8
+ - Sanitized endpoint URLs, provider errors, status errors and web errors:
9
+ userinfo and secret query parameters are stripped, control characters and
10
+ tokens are redacted, and long messages are bounded before logs/UI.
11
+ - Added retry/backoff and sanitizer tests, plus a 503 retry adapter test;
12
+ 137/137.
13
+
14
+ ## 0.1.25 — 2026-11-05
15
+
16
+ - Added safe model discovery against an unsaved endpoint with an optional
17
+ one-shot key. The key is used only for that request and is never persisted,
18
+ saved or logged; discovery has no state side effects.
19
+ - Discovery returns a draft catalog preview (v1/models with tags fallback),
20
+ rejects invalid/credential-bearing URLs, and keeps the current provider
21
+ settings unchanged.
22
+ - Added discovery UI and 401/no-leak/invalid-URL tests; 132/132.
23
+
3
24
  ## 0.1.24 — 2026-11-05
4
25
 
5
26
  - Added per-model capability/thinking overrides (`modelOverrides`) for
package/README.md CHANGED
@@ -137,17 +137,17 @@ npm pack
137
137
  Install the published package:
138
138
 
139
139
  ```bash
140
- dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.24
140
+ dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.26
141
141
  # DSH Desktop:
142
- dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.24
142
+ dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.26
143
143
  ```
144
144
 
145
145
  Or install the packed tarball into a profile:
146
146
 
147
147
  ```bash
148
- dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.24.tgz
148
+ dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.26.tgz
149
149
  # DSH Desktop:
150
- dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.24.tgz
150
+ dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.26.tgz
151
151
  ```
152
152
 
153
153
  Restart dsh (or DSH Desktop), then pick **Ollama Cloud** in the model picker.
package/README.ru.md CHANGED
@@ -103,17 +103,17 @@ npm pack
103
103
  Установка опубликованного пакета из npm:
104
104
 
105
105
  ```bash
106
- dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.24
106
+ dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.26
107
107
  # DSH Desktop:
108
- dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.24
108
+ dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.26
109
109
  ```
110
110
 
111
111
  Либо установка из упакованного tarball:
112
112
 
113
113
  ```bash
114
- dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.24.tgz
114
+ dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.26.tgz
115
115
  # DSH Desktop:
116
- dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.24.tgz
116
+ dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.26.tgz
117
117
  ```
118
118
 
119
119
  После установки перезапустите dsh (или DSH Desktop) и выберите **Ollama Cloud** в списке моделей.
package/README.zh.md CHANGED
@@ -102,17 +102,17 @@ npm pack
102
102
  从 npm 安装已发布版本:
103
103
 
104
104
  ```bash
105
- dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.24
105
+ dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.26
106
106
  # DSH 桌面端:
107
- dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.24
107
+ dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.26
108
108
  ```
109
109
 
110
110
  或通过打包文件安装:
111
111
 
112
112
  ```bash
113
- dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.24.tgz
113
+ dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.26.tgz
114
114
  # DSH 桌面端:
115
- dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.24.tgz
115
+ dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.26.tgz
116
116
  ```
117
117
 
118
118
  安装完成后重启 dsh 或 DSH 桌面端,在模型列表中选择 **Ollama Cloud** 即可。
package/lib/client.js CHANGED
@@ -122,8 +122,22 @@ window.__ModuleLoader__.load({
122
122
  streamIdleTimeoutMs: "Stream idle timeout (ms)",
123
123
  attemptTimeoutMs: "Attempt budget (ms, 0 = off)",
124
124
  attemptTimeoutHint: "Whole-attempt timeout; a fresh budget is created for every retry.",
125
+ retryMaxRetries: "Retry attempts",
126
+ retryBaseDelayMs: "Retry base delay (ms)",
127
+ retryMaxDelayMs: "Retry max delay (ms)",
128
+ retryJitter: "Retry jitter (0–1)",
125
129
  maxOutputTokens: "Output limit (0 = provider default)",
126
130
  contextWindow: "Context window override",
131
+ discover: "Discover draft endpoint",
132
+ discoverHint: "Probe an unsaved endpoint and show its catalog without changing current settings.",
133
+ endpoint: "Endpoint",
134
+ oneShotKey: "One-shot API key",
135
+ oneShotKeyPlaceholder: "optional for local endpoints",
136
+ oneShotKeyHint: "Used only for this request; never stored, saved or logged.",
137
+ discovering: "Discovering…",
138
+ discoverAction: "Discover models",
139
+ discoveryFailed: "Discovery failed",
140
+ currentOnly: "Preview only — current provider settings are unchanged.",
127
141
  contextGroup: "context",
128
142
  dragOrder: "Drag to reorder",
129
143
  manualModels: "Manual catalog entries",
@@ -359,8 +373,22 @@ window.__ModuleLoader__.load({
359
373
  streamIdleTimeoutMs: "流空闲超时(毫秒)",
360
374
  attemptTimeoutMs: "单次尝试预算(毫秒,0 = 关闭)",
361
375
  attemptTimeoutHint: "整次尝试超时;每次重试都会创建新的预算。",
376
+ retryMaxRetries: "重试次数",
377
+ retryBaseDelayMs: "重试基础延迟(毫秒)",
378
+ retryMaxDelayMs: "重试最大延迟(毫秒)",
379
+ retryJitter: "重试抖动(0–1)",
362
380
  maxOutputTokens: "输出上限(0 = 提供方默认)",
363
381
  contextWindow: "上下文窗口覆盖",
382
+ discover: "发现草稿端点",
383
+ discoverHint: "探测未保存的端点并显示目录,不修改当前设置。",
384
+ endpoint: "端点",
385
+ oneShotKey: "一次性 API 密钥",
386
+ oneShotKeyPlaceholder: "本地端点可留空",
387
+ oneShotKeyHint: "仅用于本次请求;不会存储、保存或记录。",
388
+ discovering: "正在发现…",
389
+ discoverAction: "发现模型",
390
+ discoveryFailed: "发现失败",
391
+ currentOnly: "仅预览 — 当前提供方设置不变。",
364
392
  contextGroup: "上下文",
365
393
  dragOrder: "拖动排序",
366
394
  manualModels: "手动目录条目",
@@ -583,6 +611,15 @@ window.__ModuleLoader__.load({
583
611
  body: "{}"
584
612
  });
585
613
  }
614
+ function discoverModels(apiBase, apiKey) {
615
+ return call("/dsh-ollama/discover", {
616
+ method: "POST",
617
+ body: JSON.stringify({
618
+ apiBase,
619
+ apiKey
620
+ })
621
+ });
622
+ }
586
623
  function fetchLocalModels() {
587
624
  return call("/dsh-ollama/local/models");
588
625
  }
@@ -1703,6 +1740,10 @@ window.__ModuleLoader__.load({
1703
1740
  requestTimeoutMs: String(state.config.requestTimeoutMs),
1704
1741
  streamIdleTimeoutMs: String(state.config.streamIdleTimeoutMs),
1705
1742
  attemptTimeoutMs: String(state.config.attemptTimeoutMs ?? 0),
1743
+ retryMaxRetries: String(state.config.retryMaxRetries ?? 0),
1744
+ retryBaseDelayMs: String(state.config.retryBaseDelayMs ?? 250),
1745
+ retryMaxDelayMs: String(state.config.retryMaxDelayMs ?? 2e3),
1746
+ retryJitter: String(state.config.retryJitter ?? .2),
1706
1747
  maxOutputTokens: textOf(state.config.maxOutputTokens),
1707
1748
  contextWindow: textOf(state.config.contextWindow),
1708
1749
  temperature: textOf(state.config.temperature),
@@ -1785,6 +1826,10 @@ window.__ModuleLoader__.load({
1785
1826
  requestTimeoutMs: numberOrNull(draft.requestTimeoutMs) ?? 3e5,
1786
1827
  streamIdleTimeoutMs: numberOrNull(draft.streamIdleTimeoutMs) ?? 3e5,
1787
1828
  attemptTimeoutMs: boundedNumber(draft.attemptTimeoutMs, 0, 36e5, true) ?? 0,
1829
+ retryMaxRetries: boundedNumber(draft.retryMaxRetries, 0, 10, true) ?? 0,
1830
+ retryBaseDelayMs: boundedNumber(draft.retryBaseDelayMs, 0, 6e4, true) ?? 250,
1831
+ retryMaxDelayMs: boundedNumber(draft.retryMaxDelayMs, 0, 12e4, true) ?? 2e3,
1832
+ retryJitter: boundedNumber(draft.retryJitter, 0, 1, false) ?? .2,
1788
1833
  maxOutputTokens: numberOrNull(draft.maxOutputTokens),
1789
1834
  contextWindow: numberOrNull(draft.contextWindow),
1790
1835
  temperature: boundedNumber(draft.temperature, 0, 2, false),
@@ -2591,6 +2636,11 @@ window.__ModuleLoader__.load({
2591
2636
  const [service, setService] = (0, react.useState)(null);
2592
2637
  const [serviceBusy, setServiceBusy] = (0, react.useState)(false);
2593
2638
  const [serviceError, setServiceError] = (0, react.useState)(null);
2639
+ const [discoverBase, setDiscoverBase] = (0, react.useState)("");
2640
+ const [discoverKey, setDiscoverKey] = (0, react.useState)("");
2641
+ const [discoverResult, setDiscoverResult] = (0, react.useState)(null);
2642
+ const [discovering, setDiscovering] = (0, react.useState)(false);
2643
+ const [discoverError, setDiscoverError] = (0, react.useState)(null);
2594
2644
  const load = (0, react.useCallback)(async (preserveDraft = false) => {
2595
2645
  setLoading(true);
2596
2646
  try {
@@ -2666,6 +2716,22 @@ window.__ModuleLoader__.load({
2666
2716
  (0, react.useEffect)(() => {
2667
2717
  loadService();
2668
2718
  }, [loadService]);
2719
+ const runDiscovery = async () => {
2720
+ const base = discoverBase.trim() || draft?.apiBase || "";
2721
+ if (base === "" || discovering) return;
2722
+ setDiscovering(true);
2723
+ setDiscoverError(null);
2724
+ try {
2725
+ const result = await discoverModels(base, discoverKey);
2726
+ setDiscoverResult(result);
2727
+ setDiscoverKey("");
2728
+ } catch (caught) {
2729
+ setDiscoverResult(null);
2730
+ setDiscoverError(caught instanceof Error ? caught.message : t("discoveryFailed"));
2731
+ } finally {
2732
+ setDiscovering(false);
2733
+ }
2734
+ };
2669
2735
  if (loading && state === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2670
2736
  className: "ocl-hint",
2671
2737
  children: t("loading")
@@ -3667,6 +3733,30 @@ window.__ModuleLoader__.load({
3667
3733
  value: draft.attemptTimeoutMs,
3668
3734
  onChange: (value) => update({ attemptTimeoutMs: value })
3669
3735
  }),
3736
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3737
+ label: t("retryMaxRetries"),
3738
+ type: "number",
3739
+ value: draft.retryMaxRetries,
3740
+ onChange: (value) => update({ retryMaxRetries: value })
3741
+ }),
3742
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3743
+ label: t("retryBaseDelayMs"),
3744
+ type: "number",
3745
+ value: draft.retryBaseDelayMs,
3746
+ onChange: (value) => update({ retryBaseDelayMs: value })
3747
+ }),
3748
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3749
+ label: t("retryMaxDelayMs"),
3750
+ type: "number",
3751
+ value: draft.retryMaxDelayMs,
3752
+ onChange: (value) => update({ retryMaxDelayMs: value })
3753
+ }),
3754
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3755
+ label: t("retryJitter"),
3756
+ type: "number",
3757
+ value: draft.retryJitter,
3758
+ onChange: (value) => update({ retryJitter: value })
3759
+ }),
3670
3760
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
3671
3761
  label: t("maxOutputTokens"),
3672
3762
  type: "number",
@@ -3688,6 +3778,85 @@ window.__ModuleLoader__.load({
3688
3778
  ]
3689
3779
  })]
3690
3780
  }),
3781
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3782
+ className: "ocl-card",
3783
+ children: [
3784
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3785
+ className: "ocl-card-title",
3786
+ children: t("discover")
3787
+ }),
3788
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3789
+ className: "ocl-hint",
3790
+ children: t("discoverHint")
3791
+ }),
3792
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3793
+ className: "ocl-field",
3794
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("endpoint") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3795
+ className: "ocl-input",
3796
+ value: discoverBase,
3797
+ placeholder: draft.apiBase,
3798
+ onChange: (event) => setDiscoverBase(event.target.value)
3799
+ })]
3800
+ }),
3801
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3802
+ className: "ocl-field",
3803
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("oneShotKey") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3804
+ className: "ocl-input",
3805
+ type: "password",
3806
+ autoComplete: "off",
3807
+ value: discoverKey,
3808
+ placeholder: t("oneShotKeyPlaceholder"),
3809
+ onChange: (event) => setDiscoverKey(event.target.value)
3810
+ })]
3811
+ }),
3812
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3813
+ className: "ocl-hint",
3814
+ children: t("oneShotKeyHint")
3815
+ }),
3816
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3817
+ type: "button",
3818
+ className: "ocl-button",
3819
+ disabled: discovering,
3820
+ onClick: () => {
3821
+ runDiscovery();
3822
+ },
3823
+ children: discovering ? t("discovering") : t("discoverAction")
3824
+ }),
3825
+ discoverError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3826
+ className: "ocl-error",
3827
+ children: discoverError
3828
+ }),
3829
+ discoverResult !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3830
+ className: "ocl-model-section",
3831
+ children: [
3832
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3833
+ className: "ocl-model-section-head",
3834
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
3835
+ discoverResult.base,
3836
+ " · ",
3837
+ discoverResult.models.length,
3838
+ " ",
3839
+ t("modelCount")
3840
+ ] })
3841
+ }),
3842
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3843
+ className: "ocl-hint",
3844
+ children: t("currentOnly")
3845
+ }),
3846
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3847
+ className: "ocl-models",
3848
+ children: discoverResult.models.slice(0, 100).map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3849
+ className: "ocl-model",
3850
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3851
+ className: "ocl-model-name",
3852
+ children: model
3853
+ })
3854
+ }, model))
3855
+ })
3856
+ ]
3857
+ })
3858
+ ]
3859
+ }),
3691
3860
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3692
3861
  className: "ocl-card",
3693
3862
  children: [
package/lib/index.d.ts CHANGED
@@ -66,6 +66,12 @@ interface Config {
66
66
  streamIdleTimeoutMs?: number;
67
67
  /** Whole-attempt budget; 0 disables the independent budget. */
68
68
  attemptTimeoutMs?: number;
69
+ /** Pre-response retry count; 0 disables internal retries. */
70
+ retryMaxRetries?: number;
71
+ retryBaseDelayMs?: number;
72
+ retryMaxDelayMs?: number;
73
+ /** Jitter fraction, 0..1. */
74
+ retryJitter?: number;
69
75
  /** Visible-model allowlist; empty with `showAllModels:false` means none. */
70
76
  visibleModels?: string[];
71
77
  /** Explicit all-models switch; absent means derive from `visibleModels`. */
@@ -131,6 +137,10 @@ interface ResolvedConfig {
131
137
  requestTimeoutMs: number;
132
138
  streamIdleTimeoutMs: number;
133
139
  attemptTimeoutMs: number;
140
+ retryMaxRetries: number;
141
+ retryBaseDelayMs: number;
142
+ retryMaxDelayMs: number;
143
+ retryJitter: number;
134
144
  visibleModels: readonly string[];
135
145
  showAllModels: boolean;
136
146
  modelVisibility: Readonly<Record<string, boolean>>;
@@ -461,6 +471,8 @@ interface RouteDeps {
461
471
  readonly verifyHost?: (req: IncomingMessage) => Promise<boolean>;
462
472
  /** Test seam for local Ollama inventory and mutation routes. */
463
473
  readonly localFetch?: typeof fetch;
474
+ /** Test seam for unsaved-endpoint discovery. */
475
+ readonly discoveryFetch?: typeof fetch;
464
476
  }
465
477
  /** Register the Host HTTP surface consumed by the browser settings page. */
466
478
  declare function applyRoutes(ctx: Context, web: WebServer, deps: RouteDeps): void;
package/lib/index.js CHANGED
@@ -33,14 +33,59 @@ function orderKeysForModel(keys, model, rules) {
33
33
  if (preferred === void 0) return keys;
34
34
  return [preferred, ...keys.filter((entry) => entry !== preferred)];
35
35
  }
36
+ // src/sanitize.ts
37
+ const SECRET_QUERY = /* @__PURE__ */ new Set([
38
+ "api_key",
39
+ "apikey",
40
+ "key",
41
+ "token",
42
+ "access_token",
43
+ "refresh_token",
44
+ "password",
45
+ "passwd",
46
+ "secret",
47
+ "client_secret",
48
+ "sig",
49
+ "signature",
50
+ "credential",
51
+ "code",
52
+ "auth"
53
+ ]);
54
+ const MAX_TEXT = 300;
55
+ function redactText(value, max = MAX_TEXT) {
56
+ let text = value.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, "").replace(/\r?\n/g, " ").replace(/\s+/g, " ").trim();
57
+ text = text.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi, "Bearer [redacted]").replace(/\bsk-[A-Za-z0-9_-]{8,}\b/g, "sk-[redacted]").replace(/\b(api[_-]?key|token|secret|password|authorization)\s*[:=]\s*[^\s&,"']+/gi, "$1=[redacted]");
58
+ return text.length > max ? `${text.slice(0, Math.max(0, max - 1))}…` : text;
59
+ }
60
+ function sanitizeUrl(raw) {
61
+ try {
62
+ const url = new URL(raw);
63
+ url.username = "";
64
+ url.password = "";
65
+ url.hash = "";
66
+ for (const key of [...url.searchParams.keys()]) if (SECRET_QUERY.has(key.toLowerCase())) url.searchParams.delete(key);
67
+ return url.toString().replace(/\/$/, "");
68
+ } catch {
69
+ return redactText(raw);
70
+ }
71
+ }
72
+ function safeErrorMessage(error, fallback = "request failed") {
73
+ const text = error instanceof Error ? error.message : typeof error === "string" ? error : fallback;
74
+ return redactText(text === "" ? fallback : text);
75
+ }
36
76
  // src/best-effort.ts
77
+ /**
78
+ * One place for deliberately ignored failures. Every call names what was
79
+ * skipped; when a host logger is registered the label and message go to debug
80
+ * instead of disappearing.
81
+ */
37
82
  let sink;
38
83
  function setBestEffortLogger(logger) {
39
84
  sink = logger;
40
85
  }
41
86
  function bestEffortFailed(label, error) {
42
87
  try {
43
- sink?.debug?.(`${label}: ${error instanceof Error ? error.message : String(error)}`);
88
+ sink?.debug?.(`${label}: ${redactText(error instanceof Error ? error.message : String(error))}`);
44
89
  } catch {}
45
90
  }
46
91
  // src/attempt.ts
@@ -77,7 +122,7 @@ const DEFAULT_API_BASE = "https://ollama.com";
77
122
  const DEFAULT_OPENAI_BASE = "https://ollama.com/v1";
78
123
  const DEFAULT_USAGE_URL = "https://ollama.com/api/usage";
79
124
  const DEFAULT_BALANCE_URL = "https://ollama.com/api/balance";
80
- const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.24";
125
+ const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.26";
81
126
  const DEFAULT_CONTEXT_WINDOW = 131072;
82
127
  const DEFAULT_MAX_TOKENS = 32768;
83
128
  const DEFAULT_GENERATE_MAX_TOKENS = 131072;
@@ -97,6 +142,10 @@ const Config = z.object({
97
142
  requestTimeoutMs: markVolatile(z.number().min(1).max(2147483647).default(3e5)),
98
143
  streamIdleTimeoutMs: markVolatile(z.number().min(1).max(2147483647).default(3e5)),
99
144
  attemptTimeoutMs: markVolatile(z.number().min(0).max(36e5).step(1).default(0)),
145
+ retryMaxRetries: markVolatile(z.number().min(0).max(10).step(1).default(0)),
146
+ retryBaseDelayMs: markVolatile(z.number().min(0).max(6e4).step(1).default(250)),
147
+ retryMaxDelayMs: markVolatile(z.number().min(0).max(12e4).step(1).default(2e3)),
148
+ retryJitter: markVolatile(z.number().min(0).max(1).default(.2)),
100
149
  visibleModels: markVolatile(z.array(z.string()).default([])),
101
150
  showAllModels: markVolatile(z.boolean()),
102
151
  modelVisibility: markVolatile(z.dict(z.boolean()).default({})),
@@ -305,6 +354,10 @@ function resolveConfig(config) {
305
354
  requestTimeoutMs: positiveInt(config.requestTimeoutMs, 3e5),
306
355
  streamIdleTimeoutMs: positiveInt(config.streamIdleTimeoutMs, 3e5),
307
356
  attemptTimeoutMs: typeof config.attemptTimeoutMs === "number" && Number.isInteger(config.attemptTimeoutMs) && config.attemptTimeoutMs >= 0 && config.attemptTimeoutMs <= 36e5 ? config.attemptTimeoutMs : 0,
357
+ retryMaxRetries: typeof config.retryMaxRetries === "number" && Number.isInteger(config.retryMaxRetries) && config.retryMaxRetries >= 0 && config.retryMaxRetries <= 10 ? config.retryMaxRetries : 0,
358
+ retryBaseDelayMs: positiveInt(config.retryBaseDelayMs, 250),
359
+ retryMaxDelayMs: positiveInt(config.retryMaxDelayMs, 2e3),
360
+ retryJitter: typeof config.retryJitter === "number" && config.retryJitter >= 0 && config.retryJitter <= 1 ? config.retryJitter : .2,
308
361
  visibleModels,
309
362
  showAllModels: config.showAllModels === true ? true : config.showAllModels === false ? false : visibleModels.length === 0,
310
363
  modelVisibility: booleanRecord(config.modelVisibility),
@@ -1535,7 +1588,7 @@ function isQuotaText(detail) {
1535
1588
  */
1536
1589
  function classifyResponseError(status, text, headers) {
1537
1590
  const body = parseErrorBody(text);
1538
- const message = body.message ?? (text.trim() === "" ? `HTTP ${status}` : text.trim().slice(0, 500));
1591
+ const message = redactText(body.message ?? (text.trim() === "" ? `HTTP ${status}` : text.trim().slice(0, 500)));
1539
1592
  const detail = `${body.type ?? ""} ${message}`.toLowerCase();
1540
1593
  const retry = retryAfterMs(headers);
1541
1594
  const options = {
@@ -2042,6 +2095,27 @@ function buildChatBody(options, model, config, images) {
2042
2095
  ...stop === void 0 || stop.length === 0 ? {} : { stop }
2043
2096
  };
2044
2097
  }
2098
+ // src/retry.ts
2099
+ function retryPolicy(value) {
2100
+ const integer = (number, fallback) => typeof number === "number" && Number.isInteger(number) && number >= 0 ? number : fallback;
2101
+ const jitter = typeof value.retryJitter === "number" && value.retryJitter >= 0 && value.retryJitter <= 1 ? value.retryJitter : .2;
2102
+ const baseDelayMs = integer(value.retryBaseDelayMs, 250);
2103
+ return {
2104
+ maxRetries: integer(value.retryMaxRetries, 0),
2105
+ baseDelayMs,
2106
+ maxDelayMs: Math.max(baseDelayMs, integer(value.retryMaxDelayMs, 2e3)),
2107
+ jitter
2108
+ };
2109
+ }
2110
+ function retryDelay(attempt, policy, random = Math.random) {
2111
+ const exponential = policy.baseDelayMs * 2 ** Math.max(0, attempt);
2112
+ const capped = Math.min(policy.maxDelayMs, exponential);
2113
+ const spread = capped * policy.jitter;
2114
+ return Math.max(0, Math.round(capped - spread + random() * spread * 2));
2115
+ }
2116
+ function isRetryableStatus(status) {
2117
+ return status === 408 || status === 429 || status >= 500;
2118
+ }
2045
2119
  // src/provider-ids.ts
2046
2120
  /** Provider route owned by this plugin. */
2047
2121
  const PROVIDER = "ollama-cloud";
@@ -3012,7 +3086,7 @@ var OllamaCloudAdapter = class extends LlmAdapter {
3012
3086
  logAttempt(true);
3013
3087
  return;
3014
3088
  } catch (error) {
3015
- const classified = budget.timedOut ? new LlmError(`Ollama Cloud attempt exceeded ${config.attemptTimeoutMs}ms`, "TIMEOUT", { cause: error }) : error instanceof LlmError ? error : new LlmError(error instanceof Error ? error.message : "Ollama Cloud request failed", "TRANSPORT", { cause: error });
3089
+ const classified = budget.timedOut ? new LlmError(`Ollama Cloud attempt exceeded ${config.attemptTimeoutMs}ms`, "TIMEOUT", { cause: error }) : error instanceof LlmError ? error : new LlmError(error instanceof Error ? redactText(error.message) : "Ollama Cloud request failed", "TRANSPORT", { cause: error });
3016
3090
  logAttempt(false, classified.code);
3017
3091
  if (started || options.signal?.aborted === true) throw budget.timedOut ? classified : error;
3018
3092
  lastError = classified;
@@ -3128,29 +3202,53 @@ var OllamaCloudAdapter = class extends LlmAdapter {
3128
3202
  accept: model.transport === "openai-chat" ? "text/event-stream" : "application/x-ndjson",
3129
3203
  "user-agent": config.userAgent
3130
3204
  };
3131
- const controller = new AbortController();
3132
- let timedOut = false;
3133
- const onAbort = () => controller.abort(signal?.reason);
3134
- signal?.addEventListener("abort", onAbort, { once: true });
3135
- const timer = setTimeout(() => {
3136
- timedOut = true;
3137
- controller.abort();
3138
- }, config.requestTimeoutMs);
3139
- timer.unref?.();
3140
- try {
3141
- return await this.fetchImpl(url, {
3142
- method: "POST",
3143
- headers,
3144
- body: JSON.stringify(body),
3145
- signal: controller.signal
3146
- });
3147
- } catch (error) {
3148
- if (signal?.aborted === true) throw signal.reason ?? error;
3149
- if (timedOut) throw new LlmError(`Ollama Cloud did not return response headers within ${config.requestTimeoutMs}ms`, "TIMEOUT", { cause: error });
3150
- throw error;
3151
- } finally {
3152
- clearTimeout(timer);
3153
- signal?.removeEventListener("abort", onAbort);
3205
+ const policy = retryPolicy(config);
3206
+ const wait = async (attempt) => {
3207
+ await new Promise((resolve) => setTimeout(resolve, retryDelay(attempt, policy)));
3208
+ signal?.throwIfAborted();
3209
+ };
3210
+ for (let attempt = 0;; attempt += 1) {
3211
+ const controller = new AbortController();
3212
+ let timedOut = false;
3213
+ const onAbort = () => controller.abort(signal?.reason);
3214
+ signal?.addEventListener("abort", onAbort, { once: true });
3215
+ const timer = setTimeout(() => {
3216
+ timedOut = true;
3217
+ controller.abort();
3218
+ }, config.requestTimeoutMs);
3219
+ timer.unref?.();
3220
+ try {
3221
+ const response = await this.fetchImpl(url, {
3222
+ method: "POST",
3223
+ headers,
3224
+ body: JSON.stringify(body),
3225
+ signal: controller.signal
3226
+ });
3227
+ if (attempt < policy.maxRetries && isRetryableStatus(response.status)) {
3228
+ await response.body?.cancel();
3229
+ await wait(attempt);
3230
+ continue;
3231
+ }
3232
+ return response;
3233
+ } catch (error) {
3234
+ if (signal?.aborted === true) throw signal.reason ?? error;
3235
+ if (timedOut) {
3236
+ const timeout = new LlmError(`Ollama Cloud did not return response headers within ${config.requestTimeoutMs}ms`, "TIMEOUT", { cause: error });
3237
+ if (attempt < policy.maxRetries) {
3238
+ await wait(attempt);
3239
+ continue;
3240
+ }
3241
+ throw timeout;
3242
+ }
3243
+ if (attempt < policy.maxRetries) {
3244
+ await wait(attempt);
3245
+ continue;
3246
+ }
3247
+ throw error;
3248
+ } finally {
3249
+ clearTimeout(timer);
3250
+ signal?.removeEventListener("abort", onAbort);
3251
+ }
3154
3252
  }
3155
3253
  }
3156
3254
  keyId(key) {
@@ -3625,7 +3723,7 @@ async function modelsText(deps) {
3625
3723
  return `- ${model.id} · ${tags.join(" · ")}`;
3626
3724
  }).join("\n");
3627
3725
  } catch (error) {
3628
- return `Models unavailable: ${error instanceof Error ? error.message : String(error)}`;
3726
+ return `Models unavailable: ${safeErrorMessage(error)}`;
3629
3727
  }
3630
3728
  }
3631
3729
  async function testText(deps, model) {
@@ -3658,7 +3756,7 @@ async function testText(deps, model) {
3658
3756
  } catch (error) {
3659
3757
  return {
3660
3758
  ok: false,
3661
- text: `${model}: failed — ${error instanceof Error ? error.message : String(error)}`
3759
+ text: `${model}: failed — ${safeErrorMessage(error)}`
3662
3760
  };
3663
3761
  }
3664
3762
  }
@@ -3809,7 +3907,7 @@ function applyCommands(ctx, deps) {
3809
3907
  } catch (error) {
3810
3908
  return {
3811
3909
  kind: "error",
3812
- text: error instanceof Error ? error.message : "local command failed"
3910
+ text: safeErrorMessage(error, "local command failed")
3813
3911
  };
3814
3912
  }
3815
3913
  }
@@ -3967,13 +4065,13 @@ function header(request, name) {
3967
4065
  const value = request.headers?.[name];
3968
4066
  return Array.isArray(value) ? value[0] : value;
3969
4067
  }
3970
- function isLoopback(value) {
4068
+ function isLoopback$1(value) {
3971
4069
  const address = value?.toLowerCase().replace(/^\[|\]$/g, "");
3972
4070
  return address === "localhost" || address === "localhost." || address === "::1" || address?.startsWith("127.") === true || address?.startsWith("::ffff:127.") === true;
3973
4071
  }
3974
4072
  function isTrustedUpdateRequest(request) {
3975
4073
  if (header(request, UPDATE_HEADER) !== "1") return false;
3976
- if (!isLoopback(request.socket?.remoteAddress)) return false;
4074
+ if (!isLoopback$1(request.socket?.remoteAddress)) return false;
3977
4075
  const site = header(request, "sec-fetch-site");
3978
4076
  if (site !== void 0 && site !== "same-origin") return false;
3979
4077
  const origin = header(request, "origin");
@@ -3981,7 +4079,7 @@ function isTrustedUpdateRequest(request) {
3981
4079
  if (origin === void 0 || host === void 0) return false;
3982
4080
  try {
3983
4081
  const url = new URL(origin);
3984
- return (url.protocol === "http:" || url.protocol === "https:") && isLoopback(url.hostname) && url.host === host;
4082
+ return (url.protocol === "http:" || url.protocol === "https:") && isLoopback$1(url.hostname) && url.host === host;
3985
4083
  } catch {
3986
4084
  return false;
3987
4085
  }
@@ -4546,19 +4644,103 @@ async function readModelAnalytics(days = 30, priceOverrides = {}) {
4546
4644
  });
4547
4645
  return report;
4548
4646
  }
4647
+ // src/discovery.ts
4648
+ const DISCOVERY_TIMEOUT_MS = 15e3;
4649
+ var DiscoveryError = class extends Error {
4650
+ status;
4651
+ constructor(message, status) {
4652
+ super(message);
4653
+ this.status = status;
4654
+ this.name = "DiscoveryError";
4655
+ }
4656
+ };
4657
+ function normalizeBase(raw) {
4658
+ const value = raw.trim().replace(/\/+$/, "");
4659
+ let url;
4660
+ try {
4661
+ url = new URL(value);
4662
+ } catch {
4663
+ throw new DiscoveryError("invalid endpoint URL");
4664
+ }
4665
+ if (url.protocol !== "http:" && url.protocol !== "https:") throw new DiscoveryError("endpoint must use http or https");
4666
+ if (url.username !== "" || url.password !== "") throw new DiscoveryError("endpoint URL must not contain credentials");
4667
+ return sanitizeUrl(value);
4668
+ }
4669
+ function isLoopback(url) {
4670
+ try {
4671
+ const host = new URL(url).hostname;
4672
+ return host === "127.0.0.1" || host === "localhost" || host === "::1" || host === "[::1]";
4673
+ } catch {
4674
+ return false;
4675
+ }
4676
+ }
4677
+ function idsOf(payload) {
4678
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return [];
4679
+ const record = payload;
4680
+ const fromData = Array.isArray(record.data) ? record.data.map((entry) => {
4681
+ if (typeof entry !== "object" || entry === null) return void 0;
4682
+ const id = entry.id;
4683
+ return typeof id === "string" && id !== "" ? id : void 0;
4684
+ }).filter((id) => id !== void 0) : [];
4685
+ if (fromData.length > 0) return fromData;
4686
+ return Array.isArray(record.models) ? record.models.map((entry) => {
4687
+ if (typeof entry !== "object" || entry === null) return void 0;
4688
+ const item = entry;
4689
+ const id = typeof item.name === "string" ? item.name : item.model;
4690
+ return typeof id === "string" && id !== "" ? id : void 0;
4691
+ }).filter((id) => id !== void 0) : [];
4692
+ }
4693
+ async function get(url, key, fetchImpl, signal) {
4694
+ const response = await fetchImpl(url, {
4695
+ method: "GET",
4696
+ headers: {
4697
+ accept: "application/json",
4698
+ ...key === "" ? {} : { authorization: `Bearer ${key}` }
4699
+ },
4700
+ redirect: "error",
4701
+ signal
4702
+ });
4703
+ if (!response.ok) throw new DiscoveryError(`endpoint answered ${response.status}`, response.status);
4704
+ return response.json();
4705
+ }
4706
+ /**
4707
+ * Discover a catalog for an unsaved endpoint with a one-shot key.
4708
+ * This function performs no persistence and never includes the key in errors.
4709
+ */
4710
+ async function discoverModels(rawBase, key, fetchImpl = fetch) {
4711
+ const base = normalizeBase(rawBase);
4712
+ const budget = AbortSignal.timeout(DISCOVERY_TIMEOUT_MS);
4713
+ let payload;
4714
+ try {
4715
+ payload = await get(`${base}/v1/models`, key, fetchImpl, budget);
4716
+ } catch (error) {
4717
+ if (error instanceof DiscoveryError && error.status === 401) throw error;
4718
+ if (error instanceof DiscoveryError && error.status === 404) payload = await get(`${base}/api/tags`, key, fetchImpl, budget);
4719
+ else throw error;
4720
+ }
4721
+ return {
4722
+ base,
4723
+ models: [...new Set(idsOf(payload))],
4724
+ local: isLoopback(base)
4725
+ };
4726
+ }
4549
4727
  // src/routes-public.ts
4550
4728
  function publicConfig(config) {
4551
4729
  return {
4552
4730
  apiKeyEnv: config.apiKeyEnv,
4553
- apiBase: config.apiBase,
4554
- openAiBase: config.openAiBase,
4555
- usageUrl: config.usageUrl,
4556
- balanceUrl: config.balanceUrl,
4731
+ apiBase: sanitizeUrl(config.apiBase),
4732
+ openAiBase: sanitizeUrl(config.openAiBase),
4733
+ usageUrl: sanitizeUrl(config.usageUrl),
4734
+ balanceUrl: sanitizeUrl(config.balanceUrl),
4557
4735
  transport: config.transport,
4558
4736
  modelTransports: config.modelTransports,
4559
4737
  requestTimeoutMs: config.requestTimeoutMs,
4560
4738
  streamIdleTimeoutMs: config.streamIdleTimeoutMs,
4561
4739
  attemptTimeoutMs: config.attemptTimeoutMs,
4740
+ retryMaxRetries: config.retryMaxRetries,
4741
+ retryBaseDelayMs: config.retryBaseDelayMs,
4742
+ retryMaxDelayMs: config.retryMaxDelayMs,
4743
+ retryJitter: config.retryJitter,
4562
4744
  visibleModels: config.visibleModels,
4563
4745
  showAllModels: config.showAllModels,
4564
4746
  modelVisibility: config.modelVisibility,
@@ -4628,7 +4810,7 @@ async function probeService(config, fetchImpl = fetch) {
4628
4810
  status: null,
4629
4811
  latencyMs: Date.now() - started,
4630
4812
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
4631
- error: controller.signal.aborted ? "timeout" : error instanceof Error ? error.message : String(error)
4813
+ error: controller.signal.aborted ? "timeout" : safeErrorMessage(error)
4632
4814
  };
4633
4815
  } finally {
4634
4816
  clearTimeout(timer);
@@ -4763,10 +4945,14 @@ function cleanPrices(value) {
4763
4945
  // src/routes.ts
4764
4946
  const MAX_BODY_BYTES = 262144;
4765
4947
  function json(res, status, value) {
4948
+ const safe = typeof value === "object" && value !== null && !Array.isArray(value) && typeof value.error === "string" ? {
4949
+ ...value,
4950
+ error: safeErrorMessage(value.error)
4951
+ } : value;
4766
4952
  res.statusCode = status;
4767
4953
  res.setHeader("content-type", "application/json; charset=utf-8");
4768
4954
  res.setHeader("cache-control", "no-store");
4769
- res.end(JSON.stringify(value));
4955
+ res.end(JSON.stringify(safe));
4770
4956
  }
4771
4957
  function sourceHost(value) {
4772
4958
  if (value === void 0 || value === "") return void 0;
@@ -4950,6 +5136,10 @@ function configOps(patch) {
4950
5136
  if ("requestTimeoutMs" in patch) set("requestTimeoutMs", patch.requestTimeoutMs);
4951
5137
  if ("streamIdleTimeoutMs" in patch) set("streamIdleTimeoutMs", patch.streamIdleTimeoutMs);
4952
5138
  if ("attemptTimeoutMs" in patch) set("attemptTimeoutMs", patch.attemptTimeoutMs);
5139
+ if ("retryMaxRetries" in patch) set("retryMaxRetries", patch.retryMaxRetries);
5140
+ if ("retryBaseDelayMs" in patch) set("retryBaseDelayMs", patch.retryBaseDelayMs);
5141
+ if ("retryMaxDelayMs" in patch) set("retryMaxDelayMs", patch.retryMaxDelayMs);
5142
+ if ("retryJitter" in patch) set("retryJitter", patch.retryJitter);
4953
5143
  if ("visibleModels" in patch) set("visibleModels", cleanStringArray(patch.visibleModels));
4954
5144
  if ("showAllModels" in patch) set("showAllModels", patch.showAllModels === true);
4955
5145
  if ("modelVisibility" in patch) set("modelVisibility", cleanBooleanRecord(patch.modelVisibility));
@@ -5392,6 +5582,23 @@ function applyRoutes(ctx, web, deps) {
5392
5582
  json(res, 502, { error: error instanceof Error ? error.message : "remove failed" });
5393
5583
  }
5394
5584
  });
5585
+ route("/dsh-ollama/discover", async (req, res) => {
5586
+ if (!await requirePost(req, res, verifyHost)) return;
5587
+ let body;
5588
+ try {
5589
+ body = await readJson(req);
5590
+ } catch (error) {
5591
+ json(res, 400, { error: error instanceof Error ? error.message : "invalid body" });
5592
+ return;
5593
+ }
5594
+ const apiBase = typeof body.apiBase === "string" ? body.apiBase : "";
5595
+ const apiKey = typeof body.apiKey === "string" ? body.apiKey : "";
5596
+ try {
5597
+ json(res, 200, await discoverModels(apiBase, apiKey, deps.discoveryFetch));
5598
+ } catch (error) {
5599
+ json(res, 400, { error: error instanceof Error ? error.message : "discovery failed" });
5600
+ }
5601
+ });
5395
5602
  route("/dsh-ollama/test", async (req, res) => {
5396
5603
  if (!await requirePost(req, res, verifyHost)) return;
5397
5604
  let body;
@@ -5965,6 +6172,7 @@ async function postOnce(options, url, payload, caller) {
5965
6172
  if (apiKey === void 0) throw new WebError("ollama-cloud web capabilities need an API key; configure the credential reference through plugin settings", "OLLAMA_WEB_MISSING_CREDENTIAL");
5966
6173
  const fetchImpl = options.fetch ?? fetch;
5967
6174
  const timeoutMs = options.timeoutMs ?? 15e3;
6175
+ const safeUrl = sanitizeUrl(url);
5968
6176
  const budget = createAttemptBudget(timeoutMs, caller);
5969
6177
  let response;
5970
6178
  try {
@@ -5983,15 +6191,15 @@ async function postOnce(options, url, payload, caller) {
5983
6191
  budget.dispose();
5984
6192
  if (budget.callerAborted) throw new WebError("ollama-cloud web request aborted by caller", "ABORTED", { cause: error });
5985
6193
  if (budget.timedOut) throw new WebError(`ollama-cloud web request timed out after ${timeoutMs}ms`, "OLLAMA_WEB_TIMEOUT", { cause: error });
5986
- if (isRedirectFailure(error)) throw new WebError(`${url} attempted a redirect`, "WEB_PROVIDER_ERROR", { cause: error });
5987
- const detail = error instanceof Error && error.message !== "" ? `: ${error.message}` : "";
5988
- throw new WebError(`could not reach ${url}${detail}`, "OLLAMA_WEB_TRANSPORT", { cause: error });
6194
+ if (isRedirectFailure(error)) throw new WebError(`${safeUrl} attempted a redirect`, "WEB_PROVIDER_ERROR", { cause: error });
6195
+ const detail = error instanceof Error && error.message !== "" ? `: ${redactText(error.message)}` : "";
6196
+ throw new WebError(`could not reach ${safeUrl}${detail}`, "OLLAMA_WEB_TRANSPORT", { cause: error });
5989
6197
  }
5990
6198
  if (!response.ok) {
5991
6199
  budget.dispose();
5992
6200
  await response.body?.cancel();
5993
6201
  const hint = response.status === 401 || response.status === 403 ? "; check the API key" : "";
5994
- throw new WebError(`${url} answered ${response.status}${hint}`, "WEB_PROVIDER_ERROR");
6202
+ throw new WebError(`${safeUrl} answered ${response.status}${hint}`, "WEB_PROVIDER_ERROR");
5995
6203
  }
5996
6204
  try {
5997
6205
  return {
@@ -6001,7 +6209,7 @@ async function postOnce(options, url, payload, caller) {
6001
6209
  } catch (error) {
6002
6210
  if (budget.callerAborted) throw new WebError("ollama-cloud web request aborted by caller", "ABORTED", { cause: error });
6003
6211
  if (budget.timedOut) throw new WebError(`ollama-cloud web request timed out after ${timeoutMs}ms`, "OLLAMA_WEB_TIMEOUT", { cause: error });
6004
- throw new WebError(`${url} did not answer with JSON`, "OLLAMA_WEB_BAD_REPLY", { cause: error });
6212
+ throw new WebError(`${safeUrl} did not answer with JSON`, "OLLAMA_WEB_BAD_REPLY", { cause: error });
6005
6213
  } finally {
6006
6214
  budget.dispose();
6007
6215
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-ollama-cloud-provider",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "Ollama Cloud LLM provider plugin for DeepSeek Harness (dsh).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -73,7 +73,7 @@
73
73
  "build": "tsdown",
74
74
  "prepare": "tsdown 1>&2",
75
75
  "typecheck": "tsc --noEmit",
76
- "test": "node --import tsx --test tests/core.test.ts tests/usage.test.ts tests/adapter.test.ts tests/routes.test.ts tests/native.test.ts tests/openai-chat.test.ts tests/commands.test.ts tests/tui-settings.test.ts tests/analytics.test.ts tests/apply.test.ts tests/account-rules.test.ts tests/request-log.test.ts tests/image-budget.test.ts tests/tool-schema.test.ts tests/tools.test.ts tests/plugin-updater.test.ts tests/compat.test.ts tests/status.test.ts tests/settings-draft.test.ts tests/update-state.test.ts tests/ui-render.test.tsx tests/update-card-view.test.tsx tests/web.test.ts tests/mock-ollama.test.ts tests/local.test.ts tests/reasoning.test.ts tests/catalog-cache.test.ts tests/local-models.test.ts tests/attempt.test.ts tests/model-groups.test.tsx",
76
+ "test": "node --import tsx --test tests/core.test.ts tests/usage.test.ts tests/adapter.test.ts tests/routes.test.ts tests/native.test.ts tests/openai-chat.test.ts tests/commands.test.ts tests/tui-settings.test.ts tests/analytics.test.ts tests/apply.test.ts tests/account-rules.test.ts tests/request-log.test.ts tests/image-budget.test.ts tests/tool-schema.test.ts tests/tools.test.ts tests/plugin-updater.test.ts tests/compat.test.ts tests/status.test.ts tests/settings-draft.test.ts tests/update-state.test.ts tests/ui-render.test.tsx tests/update-card-view.test.tsx tests/web.test.ts tests/mock-ollama.test.ts tests/local.test.ts tests/reasoning.test.ts tests/catalog-cache.test.ts tests/local-models.test.ts tests/attempt.test.ts tests/model-groups.test.tsx tests/discovery.test.ts tests/sanitize.test.ts tests/retry.test.ts",
77
77
  "check": "npm run typecheck && npm test && npm run build",
78
78
  "release": "npm run check && npm pack",
79
79
  "sync:models": "node scripts/sync-models.mjs"