@goodandready/dsh-ollama-cloud-provider 0.1.4 → 0.1.6

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,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.6 — 2026-10-22
4
+
5
+ - Accept the DSH Desktop renderer origin `dsh-app://app` on write routes after
6
+ the loopback Host and socket checks. Without this explicit exception the
7
+ same-origin guard in 0.1.5 rejected every Desktop settings write (#28).
8
+
9
+ ## 0.1.5 — 2026-10-22
10
+
11
+ - Write routes now require an `Origin` or `Referer` whose host matches `Host`;
12
+ a request with neither is rejected with 403. This closes the LAN-bridge path
13
+ that rewrites both Host and socket to loopback (#28).
14
+ - Added route-guard tests for 405, non-loopback Host/socket, cross-origin and
15
+ missing sources, plus native stream parser tests for text, thinking, tool
16
+ calls, in-band quota errors, aborts, idle timeouts, abrupt closes and empty
17
+ streams (#26).
18
+ - `prepare` now sends tsdown output to stderr, so `npm pack --json` stays
19
+ parseable and preflight can inspect the package (#25).
20
+ - DESIGN.md now records the 64-token Test connection budget and its reason (#27).
21
+
3
22
  ## 0.1.4 — 2026-10-21
4
23
 
5
24
  - Model list rows now use the reference three-column grid: badges live inside
package/README.md CHANGED
@@ -103,17 +103,17 @@ npm pack
103
103
  Install the published package:
104
104
 
105
105
  ```bash
106
- dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.4
106
+ dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.6
107
107
  # DSH Desktop:
108
- dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.4
108
+ dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.6
109
109
  ```
110
110
 
111
111
  Or install the packed tarball into a profile:
112
112
 
113
113
  ```bash
114
- dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.4.tgz
114
+ dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.6.tgz
115
115
  # DSH Desktop:
116
- dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.4.tgz
116
+ dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.6.tgz
117
117
  ```
118
118
 
119
119
  Restart dsh (or DSH Desktop), then pick **Ollama Cloud** in the model picker.
@@ -194,7 +194,7 @@ Open **Settings → Ollama Cloud**:
194
194
  - **Sidebar** — show or hide the quota card, and an optional plan label (for example `PRO`) shown next to the provider name.
195
195
  - **Plugin update** — current/latest version and **Update now**.
196
196
 
197
- The Host serves `/dsh-ollama/state`, `/health`, `/analytics`, `/usage`, `/balance`, `/config`, `/key`, `/key/clear`, `/refresh`, `/models/refresh`, `/test` and `/update`. Writes require JSON, are refused for cross-origin requests, and are restricted to loopback (`127.0.0.1` / `::1`).
197
+ The Host serves `/dsh-ollama/state`, `/health`, `/analytics`, `/usage`, `/balance`, `/config`, `/key`, `/key/clear`, `/refresh`, `/models/refresh`, `/test` and `/update`. Writes require JSON, an `Origin` or `Referer` matching `Host` (the Desktop renderer's `dsh-app://app` origin is accepted after loopback checks), and are restricted to loopback (`127.0.0.1` / `::1`); a write without either source header is rejected with 403.
198
198
 
199
199
  ## Command
200
200
 
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.4
106
+ dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.6
107
107
  # DSH Desktop:
108
- dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.4
108
+ dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.6
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.4.tgz
114
+ dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.6.tgz
115
115
  # DSH Desktop:
116
- dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.4.tgz
116
+ dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.6.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.4
105
+ dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.6
106
106
  # DSH 桌面端:
107
- dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.4
107
+ dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.6
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.4.tgz
113
+ dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.6.tgz
114
114
  # DSH 桌面端:
115
- dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.4.tgz
115
+ dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.6.tgz
116
116
  ```
117
117
 
118
118
  安装完成后重启 dsh 或 DSH 桌面端,在模型列表中选择 **Ollama Cloud** 即可。
package/lib/index.js CHANGED
@@ -51,7 +51,7 @@ const DEFAULT_API_BASE = "https://ollama.com";
51
51
  const DEFAULT_OPENAI_BASE = "https://ollama.com/v1";
52
52
  const DEFAULT_USAGE_URL = "https://ollama.com/api/usage";
53
53
  const DEFAULT_BALANCE_URL = "https://ollama.com/api/balance";
54
- const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.4";
54
+ const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.6";
55
55
  const DEFAULT_CONTEXT_WINDOW = 131072;
56
56
  const DEFAULT_MAX_TOKENS = 32768;
57
57
  const DEFAULT_GENERATE_MAX_TOKENS = 131072;
@@ -3659,6 +3659,38 @@ function json(res, status, value) {
3659
3659
  res.setHeader("cache-control", "no-store");
3660
3660
  res.end(JSON.stringify(value));
3661
3661
  }
3662
+ function sourceHost(value) {
3663
+ if (value === void 0 || value === "") return void 0;
3664
+ try {
3665
+ return new URL(value).host;
3666
+ } catch {
3667
+ return;
3668
+ }
3669
+ }
3670
+ /**
3671
+ * The Desktop renderer runs on `dsh-app://app`; its relative fetch reaches the
3672
+ * loopback host with that Origin. The request must still pass the loopback
3673
+ * Host check below and the loopback socket check in `requirePost`.
3674
+ */
3675
+ const DESKTOP_ORIGIN = "dsh-app://app";
3676
+ /**
3677
+ * Write routes must prove a same-origin browser context. A LAN bridge that
3678
+ * rewrites Host and socket to loopback would otherwise let any non-browser
3679
+ * client write keys and settings without an Origin. Fail closed when neither
3680
+ * Origin nor Referer is present.
3681
+ */
3682
+ function writeSourceError(req) {
3683
+ const host = req.headers.host;
3684
+ if (host === void 0 || host === "") return "request host required";
3685
+ const origin = req.headers.origin;
3686
+ if (origin !== void 0 && origin !== "") {
3687
+ if (origin === DESKTOP_ORIGIN) return void 0;
3688
+ return sourceHost(origin) === host ? void 0 : "cross-origin request refused";
3689
+ }
3690
+ const referer = req.headers.referer;
3691
+ if (referer === void 0 || referer === "") return "request origin required";
3692
+ return sourceHost(referer) === host ? void 0 : "cross-origin request refused";
3693
+ }
3662
3694
  function allowedOrigin(req) {
3663
3695
  const origin = req.headers.origin;
3664
3696
  if (origin === void 0 || origin === "") return true;
@@ -3709,8 +3741,9 @@ function requirePost(req, res) {
3709
3741
  json(res, 403, { error: "non-loopback Host refused" });
3710
3742
  return false;
3711
3743
  }
3712
- if (!allowedOrigin(req)) {
3713
- json(res, 403, { error: "cross-origin request refused" });
3744
+ const sourceError = writeSourceError(req);
3745
+ if (sourceError !== void 0) {
3746
+ json(res, 403, { error: sourceError });
3714
3747
  return false;
3715
3748
  }
3716
3749
  const remote = req.socket.remoteAddress ?? "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-ollama-cloud-provider",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Ollama Cloud LLM provider plugin for DeepSeek Harness (dsh).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -66,9 +66,9 @@
66
66
  },
67
67
  "scripts": {
68
68
  "build": "tsdown",
69
- "prepare": "tsdown",
69
+ "prepare": "tsdown 1>&2",
70
70
  "typecheck": "tsc --noEmit",
71
- "test": "node --import tsx --test tests/core.test.ts tests/usage.test.ts tests/adapter.test.ts tests/routes.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",
71
+ "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/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",
72
72
  "check": "npm run typecheck && npm test && npm run build",
73
73
  "release": "npm run check && npm pack",
74
74
  "sync:models": "node scripts/sync-models.mjs"