@goodandready/dsh-ollama-cloud-provider 0.1.39 → 0.1.40
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 +11 -0
- package/README.md +4 -4
- package/README.ru.md +4 -4
- package/README.zh.md +4 -4
- package/lib/adapter.js +9 -2
- package/lib/catalog-cache.js +8 -2
- package/lib/catalog-scheduler.js +34 -0
- package/lib/catalog.js +23 -14
- package/lib/client.js +171 -94
- package/lib/config.js +18 -5
- package/lib/discovery.js +74 -6
- package/lib/index.js +14 -10
- package/lib/request-log.js +12 -3
- package/lib/routes-values.js +17 -4
- package/lib/routes.js +11 -6
- package/lib/status.js +1 -0
- package/lib/transports/ndjson.js +10 -3
- package/lib/transports/openai-chat.js +32 -3
- package/lib/transports/sse.js +11 -3
- package/lib/usage.js +17 -10
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.40 — 2026-11-21
|
|
4
|
+
|
|
5
|
+
- Settings: an empty numeric field is now unset (`null`) instead of being replaced by a default, invalid values are reported per field and block the save, and `configWritable` disables Save on a read-only host (#140).
|
|
6
|
+
- Settings: manual-model rows keep a stable identity while editing, account key buffers are tied to the row, and a cancelled drag clears its state (#141).
|
|
7
|
+
- Catalog: cold loads are single-flight, a failed refresh is stored with a zero timestamp instead of looking fresh, and one scheduler reads `autoRefresh`/`refreshMinutes` on every tick (#139).
|
|
8
|
+
- Diagnostics: a catalog failure surfaces as `providerError` instead of an empty model list, the local usage rate limit is reported as a rate limit, and quota refresh errors are shown (#144).
|
|
9
|
+
- Transports: tool-call ids stay stable within a block even when the upstream id arrives late, NDJSON/SSE frames are capped at 1 MiB, idle timeouts keep their `TIMEOUT` code, and readers are cancelled cleanly (#145, #152).
|
|
10
|
+
- Security: `redirect: 'error'` on every key-bearing request, `0600/0700` state files, prototype keys ignored, discovery pinned to the validated IP, `providerError`/`source` redacted (#152).
|
|
11
|
+
|
|
12
|
+
194 tests.
|
|
13
|
+
|
|
3
14
|
## 0.1.39 — 2026-11-15
|
|
4
15
|
|
|
5
16
|
- Security: loopback Host detection now requires an IP literal, so a DNS-rebinding page can no longer pass the read host gate or the update endpoint (#135).
|
package/README.md
CHANGED
|
@@ -128,17 +128,17 @@ npm pack
|
|
|
128
128
|
Install the published package:
|
|
129
129
|
|
|
130
130
|
```bash
|
|
131
|
-
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
131
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.40
|
|
132
132
|
# DSH Desktop:
|
|
133
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
133
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.40
|
|
134
134
|
```
|
|
135
135
|
|
|
136
136
|
Or install the packed tarball into a profile:
|
|
137
137
|
|
|
138
138
|
```bash
|
|
139
|
-
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
139
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.40.tgz
|
|
140
140
|
# DSH Desktop:
|
|
141
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
141
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.40.tgz
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
Restart dsh (or DSH Desktop), then pick **Ollama Cloud** in the model picker.
|
package/README.ru.md
CHANGED
|
@@ -110,17 +110,17 @@ npm pack
|
|
|
110
110
|
Установка опубликованного пакета из npm:
|
|
111
111
|
|
|
112
112
|
```bash
|
|
113
|
-
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
113
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.40
|
|
114
114
|
# DSH Desktop:
|
|
115
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
115
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.40
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
Либо установка из упакованного tarball:
|
|
119
119
|
|
|
120
120
|
```bash
|
|
121
|
-
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
121
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.40.tgz
|
|
122
122
|
# DSH Desktop:
|
|
123
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
123
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.40.tgz
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
После установки перезапустите dsh (или DSH Desktop) и выберите **Ollama Cloud** в списке моделей.
|
package/README.zh.md
CHANGED
|
@@ -109,17 +109,17 @@ npm pack
|
|
|
109
109
|
从 npm 安装已发布版本:
|
|
110
110
|
|
|
111
111
|
```bash
|
|
112
|
-
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
112
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.40
|
|
113
113
|
# DSH 桌面端:
|
|
114
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
114
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.40
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
或通过打包文件安装:
|
|
118
118
|
|
|
119
119
|
```bash
|
|
120
|
-
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
120
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.40.tgz
|
|
121
121
|
# DSH 桌面端:
|
|
122
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
122
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.40.tgz
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
安装完成后重启 dsh 或 DSH 桌面端,在模型列表中选择 **Ollama Cloud** 即可。
|
package/lib/adapter.js
CHANGED
|
@@ -31,10 +31,16 @@ function effortName(id) {
|
|
|
31
31
|
}
|
|
32
32
|
async function atomicWriteFile(filePath, data) {
|
|
33
33
|
const dir = dirname(filePath);
|
|
34
|
-
await mkdir(dir, {
|
|
34
|
+
await mkdir(dir, {
|
|
35
|
+
recursive: true,
|
|
36
|
+
mode: 448
|
|
37
|
+
});
|
|
35
38
|
const tmp = join(dir, `.${basename(filePath)}.${randomUUID()}.tmp`);
|
|
36
39
|
try {
|
|
37
|
-
await writeFile(tmp, data,
|
|
40
|
+
await writeFile(tmp, data, {
|
|
41
|
+
encoding: "utf8",
|
|
42
|
+
mode: 384
|
|
43
|
+
});
|
|
38
44
|
await rename(tmp, filePath);
|
|
39
45
|
} catch (error) {
|
|
40
46
|
await rm(tmp, { force: true }).catch((err) => bestEffortFailed("atomicWriteFile:rm-tmp", err));
|
|
@@ -394,6 +400,7 @@ var OllamaCloudAdapter = class extends LlmAdapter {
|
|
|
394
400
|
method: "POST",
|
|
395
401
|
headers,
|
|
396
402
|
body: JSON.stringify(body),
|
|
403
|
+
redirect: "error",
|
|
397
404
|
signal: controller.signal
|
|
398
405
|
});
|
|
399
406
|
if (attempt < policy.maxRetries && isRetryableStatus(response.status)) {
|
package/lib/catalog-cache.js
CHANGED
|
@@ -56,8 +56,14 @@ async function saveCatalogSnapshot(baseURL, ids, meta) {
|
|
|
56
56
|
meta
|
|
57
57
|
};
|
|
58
58
|
try {
|
|
59
|
-
await mkdir(dirname(path), {
|
|
60
|
-
|
|
59
|
+
await mkdir(dirname(path), {
|
|
60
|
+
recursive: true,
|
|
61
|
+
mode: 448
|
|
62
|
+
});
|
|
63
|
+
await writeFile(temp, `${JSON.stringify(payload)}\n`, {
|
|
64
|
+
encoding: "utf8",
|
|
65
|
+
mode: 384
|
|
66
|
+
});
|
|
61
67
|
await rename(temp, path);
|
|
62
68
|
} catch (error) {
|
|
63
69
|
bestEffortFailed("catalog cache write failed", error);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/catalog-scheduler.ts
|
|
2
|
+
/**
|
|
3
|
+
* The single owner of periodic catalog refresh. It re-reads the live settings on
|
|
4
|
+
* every tick, so changing `autoRefresh` or `refreshMinutes` applies without a
|
|
5
|
+
* restart, and it never runs two refreshes for the same due moment.
|
|
6
|
+
*/
|
|
7
|
+
function createCatalogScheduler(options) {
|
|
8
|
+
const now = options.now ?? Date.now;
|
|
9
|
+
let last = now();
|
|
10
|
+
const check = () => {
|
|
11
|
+
try {
|
|
12
|
+
const config = options.current();
|
|
13
|
+
if (!config.autoRefresh) return;
|
|
14
|
+
const minutes = Math.floor(config.refreshMinutes);
|
|
15
|
+
if (!Number.isFinite(minutes) || minutes <= 0) return;
|
|
16
|
+
const at = now();
|
|
17
|
+
if (at - last < minutes * 6e4) return;
|
|
18
|
+
last = at;
|
|
19
|
+
const result = options.refresh();
|
|
20
|
+
if (result !== void 0) Promise.resolve(result).catch((error) => options.onError?.(error));
|
|
21
|
+
} catch (error) {
|
|
22
|
+
options.onError?.(error);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const timer = setInterval(check, options.tickMs ?? 6e4);
|
|
26
|
+
timer.unref?.();
|
|
27
|
+
return {
|
|
28
|
+
check,
|
|
29
|
+
dispose: () => clearInterval(timer)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export { createCatalogScheduler };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=catalog-scheduler.js.map
|
package/lib/catalog.js
CHANGED
|
@@ -7,7 +7,6 @@ import { formatPrice, priceFor } from "./pricing.js";
|
|
|
7
7
|
import { normalizeThinking } from "./reasoning.js";
|
|
8
8
|
import { modelsUrlFor, tagsUrlFor } from "./routing.js";
|
|
9
9
|
// src/catalog.ts
|
|
10
|
-
const CATALOG_TTL_MS = 6e5;
|
|
11
10
|
const CATALOG_TIMEOUT_MS = 15e3;
|
|
12
11
|
const liveMeta = /* @__PURE__ */ new Map();
|
|
13
12
|
const cache = /* @__PURE__ */ new Map();
|
|
@@ -125,6 +124,7 @@ async function fetchJson(url, config, fetchImpl, signal) {
|
|
|
125
124
|
accept: "application/json",
|
|
126
125
|
"user-agent": config.userAgent
|
|
127
126
|
},
|
|
127
|
+
redirect: "error",
|
|
128
128
|
signal
|
|
129
129
|
});
|
|
130
130
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
@@ -154,10 +154,27 @@ async function refreshCatalog(config, fetchImpl = fetch, force = false) {
|
|
|
154
154
|
}
|
|
155
155
|
const cached = cache.get(key);
|
|
156
156
|
if (!force && cached !== void 0) {
|
|
157
|
-
|
|
157
|
+
const ttl = catalogTtlMs(config);
|
|
158
|
+
if (ttl > 0 && (cached.at === 0 || Date.now() - cached.at >= ttl)) refreshShared(config, fetchImpl, key, true);
|
|
158
159
|
return cached.ids;
|
|
159
160
|
}
|
|
160
|
-
return
|
|
161
|
+
return refreshShared(config, fetchImpl, key, cached !== void 0);
|
|
162
|
+
}
|
|
163
|
+
function catalogTtlMs(config) {
|
|
164
|
+
if (!config.autoRefresh || config.refreshMinutes <= 0) return 0;
|
|
165
|
+
return Math.max(1, Math.floor(config.refreshMinutes)) * 6e4;
|
|
166
|
+
}
|
|
167
|
+
function refreshShared(config, fetchImpl, key, keepOnFailure) {
|
|
168
|
+
const existing = inflight.get(key);
|
|
169
|
+
if (existing !== void 0) return existing;
|
|
170
|
+
const task = refreshNow(config, fetchImpl, key, keepOnFailure, generation).catch((error) => {
|
|
171
|
+
bestEffortFailed("catalog:fetchModels", error);
|
|
172
|
+
return cache.get(key)?.ids ?? Object.keys(GENERATED_MODELS);
|
|
173
|
+
}).finally(() => {
|
|
174
|
+
if (inflight.get(key) === task) inflight.delete(key);
|
|
175
|
+
});
|
|
176
|
+
inflight.set(key, task);
|
|
177
|
+
return task;
|
|
161
178
|
}
|
|
162
179
|
async function refreshNow(config, fetchImpl, key, keepOnFailure, epoch) {
|
|
163
180
|
const budget = createAttemptBudget(CATALOG_TIMEOUT_MS);
|
|
@@ -176,6 +193,7 @@ async function refreshNow(config, fetchImpl, key, keepOnFailure, epoch) {
|
|
|
176
193
|
if (live.length > 0) {
|
|
177
194
|
const ids = adoptLive(live, tags, key);
|
|
178
195
|
if (ids.length > 0) {
|
|
196
|
+
if (epoch !== generation) return ids;
|
|
179
197
|
cache.set(key, {
|
|
180
198
|
at: Date.now(),
|
|
181
199
|
ids
|
|
@@ -190,6 +208,7 @@ async function refreshNow(config, fetchImpl, key, keepOnFailure, epoch) {
|
|
|
190
208
|
if (discovered.length > 0) {
|
|
191
209
|
for (const liveKey of liveMeta.keys()) if (liveKey.startsWith(`${key}|`)) liveMeta.delete(liveKey);
|
|
192
210
|
const ids = discovered;
|
|
211
|
+
if (epoch !== generation) return ids;
|
|
193
212
|
cache.set(key, {
|
|
194
213
|
at: Date.now(),
|
|
195
214
|
ids
|
|
@@ -204,21 +223,11 @@ async function refreshNow(config, fetchImpl, key, keepOnFailure, epoch) {
|
|
|
204
223
|
}
|
|
205
224
|
const fallback = Object.keys(GENERATED_MODELS);
|
|
206
225
|
if (epoch === generation) cache.set(key, {
|
|
207
|
-
at:
|
|
226
|
+
at: 0,
|
|
208
227
|
ids: fallback
|
|
209
228
|
});
|
|
210
229
|
return fallback;
|
|
211
230
|
}
|
|
212
|
-
function refreshInBackground(config, fetchImpl, key) {
|
|
213
|
-
if (inflight.has(key)) return;
|
|
214
|
-
const task = refreshNow(config, fetchImpl, key, true, generation).catch((err) => {
|
|
215
|
-
bestEffortFailed("catalog:fetchModels", err);
|
|
216
|
-
return cache.get(key)?.ids ?? Object.keys(GENERATED_MODELS);
|
|
217
|
-
}).finally(() => {
|
|
218
|
-
inflight.delete(key);
|
|
219
|
-
});
|
|
220
|
-
inflight.set(key, task);
|
|
221
|
-
}
|
|
222
231
|
function clearCatalogCache() {
|
|
223
232
|
generation += 1;
|
|
224
233
|
cache.clear();
|