@goodandready/dsh-ollama-cloud-provider 0.1.29 → 0.1.31

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,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.31 — 2026-11-06
4
+
5
+ - Robustness: wrapped ndjson streaming chunk and tail JSON parsing in try/catch
6
+ to safely discard or report corrupted chunks without aborting the connection abruptly (#97).
7
+ - Route Security: restricted `readOnly` check in route handlers to non-GET methods only
8
+ (`req.method !== 'GET'`), avoiding premature rejects on idempotent read probes (#98).
9
+ - Deterministic Tests: enforced `--test-concurrency=1` in `package.json` test runner
10
+ to ensure deterministic test order and prevent timer/teardown races under Node 24 (#99).
11
+ - UI Defaults: explicitly verified and locked invariant that all on-screen UI badges and
12
+ widgets (specifically `showSidebarQuota`) remain disabled by default (`false`) and must
13
+ be explicitly enabled by user in settings (#100).
14
+
15
+ ## 0.1.30 — 2026-11-05
16
+
17
+ - Security: credential writes now accept only the configured default/account
18
+ refs; the allowlist no longer falls through to every `OLLAMA_*` name.
19
+ - Security: private-read host verification uses the local socket origin instead
20
+ of the request Host and rejects a public 404 probe, closing DNS-rebinding
21
+ cookie/SSRF exposure while preserving DSH's authenticated-404 behavior.
22
+ - Security: unsaved-endpoint discovery now requires HTTPS and rejects
23
+ loopback/link-local/private/reserved addresses; test-only private targets are
24
+ explicit.
25
+ - Build: declared `react-dom` and `@types/react-dom`; clean `npm ci` now passes
26
+ the full test/build gate. Added host-verification coverage; 132/132.
27
+
3
28
  ## 0.1.29 — 2026-11-05
4
29
 
5
30
  - Made the plugin cloud-only. Removed the local endpoint mode, local model
package/README.md CHANGED
@@ -121,17 +121,17 @@ npm pack
121
121
  Install the published package:
122
122
 
123
123
  ```bash
124
- dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.29
124
+ dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.31
125
125
  # DSH Desktop:
126
- dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.29
126
+ dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.31
127
127
  ```
128
128
 
129
129
  Or install the packed tarball into a profile:
130
130
 
131
131
  ```bash
132
- dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.29.tgz
132
+ dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.31.tgz
133
133
  # DSH Desktop:
134
- dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.29.tgz
134
+ dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.31.tgz
135
135
  ```
136
136
 
137
137
  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.29
106
+ dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.31
107
107
  # DSH Desktop:
108
- dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.29
108
+ dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.31
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.29.tgz
114
+ dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.31.tgz
115
115
  # DSH Desktop:
116
- dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.29.tgz
116
+ dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.31.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.29
105
+ dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.31
106
106
  # DSH 桌面端:
107
- dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.29
107
+ dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.31
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.29.tgz
113
+ dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.31.tgz
114
114
  # DSH 桌面端:
115
- dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.29.tgz
115
+ dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.31.tgz
116
116
  ```
117
117
 
118
118
  安装完成后重启 dsh 或 DSH 桌面端,在模型列表中选择 **Ollama Cloud** 即可。
package/lib/index.js CHANGED
@@ -9,6 +9,8 @@ import { credentialRef } from "@deepseek-ai/dsh-credentials";
9
9
  import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
10
10
  import { spawn } from "node:child_process";
11
11
  import { fileURLToPath } from "node:url";
12
+ import { lookup } from "node:dns/promises";
13
+ import { isIP } from "node:net";
12
14
  import { WebError } from "@deepseek-ai/dsh-web";
13
15
  // src/account-rules.ts
14
16
  function glob(pattern) {
@@ -122,7 +124,7 @@ const DEFAULT_API_BASE = "https://ollama.com";
122
124
  const DEFAULT_OPENAI_BASE = "https://ollama.com/v1";
123
125
  const DEFAULT_USAGE_URL = "https://ollama.com/api/usage";
124
126
  const DEFAULT_BALANCE_URL = "https://ollama.com/api/balance";
125
- const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.29";
127
+ const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.31";
126
128
  const DEFAULT_CONTEXT_WINDOW = 131072;
127
129
  const DEFAULT_MAX_TOKENS = 32768;
128
130
  const DEFAULT_GENERATE_MAX_TOKENS = 131072;
@@ -2247,13 +2249,24 @@ async function* ndjsonObjects(body, idleTimeoutMs, signal) {
2247
2249
  const line = buffer.slice(0, boundary).trim();
2248
2250
  buffer = buffer.slice(boundary + 1);
2249
2251
  if (line === "") continue;
2250
- const parsed = JSON.parse(line);
2252
+ let parsed;
2253
+ try {
2254
+ parsed = JSON.parse(line);
2255
+ } catch (error) {
2256
+ bestEffortFailed("ndjson line parse failed", error);
2257
+ continue;
2258
+ }
2251
2259
  if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) yield parsed;
2252
2260
  }
2253
2261
  }
2254
2262
  const tail = buffer.trim();
2255
2263
  if (tail !== "") {
2256
- const parsed = JSON.parse(tail);
2264
+ let parsed;
2265
+ try {
2266
+ parsed = JSON.parse(tail);
2267
+ } catch (error) {
2268
+ bestEffortFailed("ndjson tail parse failed", error);
2269
+ }
2257
2270
  if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) yield parsed;
2258
2271
  }
2259
2272
  } finally {
@@ -4230,6 +4243,36 @@ function normalizeBase(raw) {
4230
4243
  if (url.username !== "" || url.password !== "") throw new DiscoveryError("endpoint URL must not contain credentials");
4231
4244
  return sanitizeUrl(value);
4232
4245
  }
4246
+ function isPrivateV4(address) {
4247
+ const parts = address.split(".").map(Number);
4248
+ if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) return true;
4249
+ const [a, b] = parts;
4250
+ return a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a === 192 && b === 0 || a === 198 && (b === 18 || b === 19) || a >= 224;
4251
+ }
4252
+ function isPrivateAddress(address) {
4253
+ const clean = address.toLowerCase().replace(/^\[|\]$/g, "");
4254
+ if (isIP(clean) === 4) return isPrivateV4(clean);
4255
+ if (isIP(clean) !== 6) return true;
4256
+ return clean === "::1" || clean === "::" || clean.startsWith("fc") || clean.startsWith("fd") || /^fe[89ab]/.test(clean) || clean.startsWith("ff") || clean.startsWith("2001:db8") || clean.startsWith("::ffff:");
4257
+ }
4258
+ async function assertPublicEndpoint(base, options) {
4259
+ if (options.allowPrivate === true) return;
4260
+ const url = new URL(base);
4261
+ if (url.protocol !== "https:") throw new DiscoveryError("endpoint must use https");
4262
+ const host = url.hostname.toLowerCase().replace(/^\[|\]$/g, "");
4263
+ if (host === "localhost" || host.endsWith(".localhost")) throw new DiscoveryError("private endpoint refused");
4264
+ let addresses;
4265
+ if (isIP(host) !== 0) addresses = [host];
4266
+ else try {
4267
+ addresses = (await lookup(host, {
4268
+ all: true,
4269
+ verbatim: true
4270
+ })).map((entry) => entry.address);
4271
+ } catch {
4272
+ throw new DiscoveryError("could not resolve endpoint");
4273
+ }
4274
+ if (addresses.length === 0 || addresses.some(isPrivateAddress)) throw new DiscoveryError("private endpoint refused");
4275
+ }
4233
4276
  function idsOf(payload) {
4234
4277
  if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return [];
4235
4278
  const record = payload;
@@ -4263,8 +4306,9 @@ async function get(url, key, fetchImpl, signal) {
4263
4306
  * Discover a catalog for an unsaved endpoint with a one-shot key.
4264
4307
  * This function performs no persistence and never includes the key in errors.
4265
4308
  */
4266
- async function discoverModels(rawBase, key, fetchImpl = fetch) {
4309
+ async function discoverModels(rawBase, key, fetchImpl = fetch, options = {}) {
4267
4310
  const base = normalizeBase(rawBase);
4311
+ await assertPublicEndpoint(base, options);
4268
4312
  const budget = AbortSignal.timeout(DISCOVERY_TIMEOUT_MS);
4269
4313
  let payload;
4270
4314
  try {
@@ -4528,12 +4572,17 @@ function desktopShellRequest(req) {
4528
4572
  const cookie = req.headers.cookie ?? "";
4529
4573
  return agent.includes("@deepseek-ai/dsh-desktop/") && cookie.includes("dsh-auth-");
4530
4574
  }
4575
+ function localVerificationOrigin(req) {
4576
+ const port = req.socket.localPort;
4577
+ if (port === void 0 || port <= 0) return void 0;
4578
+ return `${req.socket.encrypted === true ? "https" : "http"}://127.0.0.1:${port}`;
4579
+ }
4531
4580
  async function defaultVerifyHost(req) {
4532
- const host = req.headers.host;
4581
+ const localOrigin = localVerificationOrigin(req);
4533
4582
  const cookie = req.headers.cookie;
4534
- if (host === void 0 || host === "" || cookie === void 0 || cookie === "") return false;
4583
+ if (localOrigin === void 0 || cookie === void 0 || cookie === "") return false;
4535
4584
  try {
4536
- const response = await fetch(`http://${host}/api/version`, {
4585
+ const response = await fetch(`${localOrigin}/api/version`, {
4537
4586
  headers: {
4538
4587
  cookie,
4539
4588
  accept: "application/json"
@@ -4543,6 +4592,15 @@ async function defaultVerifyHost(req) {
4543
4592
  });
4544
4593
  await response.body?.cancel();
4545
4594
  if (response.status >= 300 && response.status < 400) return false;
4595
+ if (response.status === 404) {
4596
+ const anonymous = await fetch(`${localOrigin}/api/version`, {
4597
+ headers: { accept: "application/json" },
4598
+ redirect: "manual",
4599
+ signal: AbortSignal.timeout(2500)
4600
+ });
4601
+ await anonymous.body?.cancel();
4602
+ return anonymous.status === 401 || anonymous.status === 403;
4603
+ }
4546
4604
  return response.status < 500 && response.status !== 401 && response.status !== 403;
4547
4605
  } catch {
4548
4606
  return false;
@@ -4658,7 +4716,7 @@ function canWriteCredentialRef(config, ref) {
4658
4716
  if (!isCredentialRef(ref)) return false;
4659
4717
  if (ref === config.apiKeyEnv) return true;
4660
4718
  for (const account of config.accounts) if (typeof account.apiKeyEnv === "string" && account.apiKeyEnv.trim() === ref) return true;
4661
- return true;
4719
+ return false;
4662
4720
  }
4663
4721
  function configOps(patch) {
4664
4722
  const ops = [];
@@ -4856,7 +4914,7 @@ function applyRoutes(ctx, web, deps) {
4856
4914
  }));
4857
4915
  };
4858
4916
  const readOnly = (req, res) => {
4859
- if (req.method !== "GET" && req.method !== "POST") {
4917
+ if (req.method !== "GET") {
4860
4918
  json(res, 405, { error: "GET required" });
4861
4919
  return false;
4862
4920
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-ollama-cloud-provider",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
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/reasoning.test.ts tests/catalog-cache.test.ts tests/attempt.test.ts tests/model-groups.test.tsx tests/discovery.test.ts tests/sanitize.test.ts tests/retry.test.ts tests/provider-card.test.tsx",
76
+ "test": "node --import tsx --test --test-concurrency=1 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/reasoning.test.ts tests/catalog-cache.test.ts tests/attempt.test.ts tests/model-groups.test.tsx tests/discovery.test.ts tests/sanitize.test.ts tests/retry.test.ts tests/provider-card.test.tsx tests/host-verification.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"
@@ -120,7 +120,9 @@
120
120
  "@deepseek-ai/schemastery": "~3.19.0",
121
121
  "@types/node": "^22.0.0",
122
122
  "@types/react": "^18.3.1",
123
+ "@types/react-dom": "18.3.7",
123
124
  "react": "^18.3.1",
125
+ "react-dom": "18.3.1",
124
126
  "tsdown": "^0.22.2",
125
127
  "tsx": "^4.23.12",
126
128
  "typescript": "^5.7.2"