@goodandready/dsh-ollama-cloud-provider 0.1.24 → 0.1.25
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 +10 -0
- package/README.md +4 -4
- package/README.ru.md +4 -4
- package/README.zh.md +4 -4
- package/lib/client.js +129 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +101 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.25 — 2026-11-05
|
|
4
|
+
|
|
5
|
+
- Added safe model discovery against an unsaved endpoint with an optional
|
|
6
|
+
one-shot key. The key is used only for that request and is never persisted,
|
|
7
|
+
saved or logged; discovery has no state side effects.
|
|
8
|
+
- Discovery returns a draft catalog preview (v1/models with tags fallback),
|
|
9
|
+
rejects invalid/credential-bearing URLs, and keeps the current provider
|
|
10
|
+
settings unchanged.
|
|
11
|
+
- Added discovery UI and 401/no-leak/invalid-URL tests; 132/132.
|
|
12
|
+
|
|
3
13
|
## 0.1.24 — 2026-11-05
|
|
4
14
|
|
|
5
15
|
- 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.
|
|
140
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.25
|
|
141
141
|
# DSH Desktop:
|
|
142
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
142
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.25
|
|
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.
|
|
148
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.25.tgz
|
|
149
149
|
# DSH Desktop:
|
|
150
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
150
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.25.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.
|
|
106
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.25
|
|
107
107
|
# DSH Desktop:
|
|
108
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
108
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.25
|
|
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.
|
|
114
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.25.tgz
|
|
115
115
|
# DSH Desktop:
|
|
116
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
116
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.25.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.
|
|
105
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.25
|
|
106
106
|
# DSH 桌面端:
|
|
107
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
107
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.25
|
|
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.
|
|
113
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.25.tgz
|
|
114
114
|
# DSH 桌面端:
|
|
115
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
115
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.25.tgz
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
安装完成后重启 dsh 或 DSH 桌面端,在模型列表中选择 **Ollama Cloud** 即可。
|
package/lib/client.js
CHANGED
|
@@ -124,6 +124,16 @@ window.__ModuleLoader__.load({
|
|
|
124
124
|
attemptTimeoutHint: "Whole-attempt timeout; a fresh budget is created for every retry.",
|
|
125
125
|
maxOutputTokens: "Output limit (0 = provider default)",
|
|
126
126
|
contextWindow: "Context window override",
|
|
127
|
+
discover: "Discover draft endpoint",
|
|
128
|
+
discoverHint: "Probe an unsaved endpoint and show its catalog without changing current settings.",
|
|
129
|
+
endpoint: "Endpoint",
|
|
130
|
+
oneShotKey: "One-shot API key",
|
|
131
|
+
oneShotKeyPlaceholder: "optional for local endpoints",
|
|
132
|
+
oneShotKeyHint: "Used only for this request; never stored, saved or logged.",
|
|
133
|
+
discovering: "Discovering…",
|
|
134
|
+
discoverAction: "Discover models",
|
|
135
|
+
discoveryFailed: "Discovery failed",
|
|
136
|
+
currentOnly: "Preview only — current provider settings are unchanged.",
|
|
127
137
|
contextGroup: "context",
|
|
128
138
|
dragOrder: "Drag to reorder",
|
|
129
139
|
manualModels: "Manual catalog entries",
|
|
@@ -361,6 +371,16 @@ window.__ModuleLoader__.load({
|
|
|
361
371
|
attemptTimeoutHint: "整次尝试超时;每次重试都会创建新的预算。",
|
|
362
372
|
maxOutputTokens: "输出上限(0 = 提供方默认)",
|
|
363
373
|
contextWindow: "上下文窗口覆盖",
|
|
374
|
+
discover: "发现草稿端点",
|
|
375
|
+
discoverHint: "探测未保存的端点并显示目录,不修改当前设置。",
|
|
376
|
+
endpoint: "端点",
|
|
377
|
+
oneShotKey: "一次性 API 密钥",
|
|
378
|
+
oneShotKeyPlaceholder: "本地端点可留空",
|
|
379
|
+
oneShotKeyHint: "仅用于本次请求;不会存储、保存或记录。",
|
|
380
|
+
discovering: "正在发现…",
|
|
381
|
+
discoverAction: "发现模型",
|
|
382
|
+
discoveryFailed: "发现失败",
|
|
383
|
+
currentOnly: "仅预览 — 当前提供方设置不变。",
|
|
364
384
|
contextGroup: "上下文",
|
|
365
385
|
dragOrder: "拖动排序",
|
|
366
386
|
manualModels: "手动目录条目",
|
|
@@ -583,6 +603,15 @@ window.__ModuleLoader__.load({
|
|
|
583
603
|
body: "{}"
|
|
584
604
|
});
|
|
585
605
|
}
|
|
606
|
+
function discoverModels(apiBase, apiKey) {
|
|
607
|
+
return call("/dsh-ollama/discover", {
|
|
608
|
+
method: "POST",
|
|
609
|
+
body: JSON.stringify({
|
|
610
|
+
apiBase,
|
|
611
|
+
apiKey
|
|
612
|
+
})
|
|
613
|
+
});
|
|
614
|
+
}
|
|
586
615
|
function fetchLocalModels() {
|
|
587
616
|
return call("/dsh-ollama/local/models");
|
|
588
617
|
}
|
|
@@ -2591,6 +2620,11 @@ window.__ModuleLoader__.load({
|
|
|
2591
2620
|
const [service, setService] = (0, react.useState)(null);
|
|
2592
2621
|
const [serviceBusy, setServiceBusy] = (0, react.useState)(false);
|
|
2593
2622
|
const [serviceError, setServiceError] = (0, react.useState)(null);
|
|
2623
|
+
const [discoverBase, setDiscoverBase] = (0, react.useState)("");
|
|
2624
|
+
const [discoverKey, setDiscoverKey] = (0, react.useState)("");
|
|
2625
|
+
const [discoverResult, setDiscoverResult] = (0, react.useState)(null);
|
|
2626
|
+
const [discovering, setDiscovering] = (0, react.useState)(false);
|
|
2627
|
+
const [discoverError, setDiscoverError] = (0, react.useState)(null);
|
|
2594
2628
|
const load = (0, react.useCallback)(async (preserveDraft = false) => {
|
|
2595
2629
|
setLoading(true);
|
|
2596
2630
|
try {
|
|
@@ -2666,6 +2700,22 @@ window.__ModuleLoader__.load({
|
|
|
2666
2700
|
(0, react.useEffect)(() => {
|
|
2667
2701
|
loadService();
|
|
2668
2702
|
}, [loadService]);
|
|
2703
|
+
const runDiscovery = async () => {
|
|
2704
|
+
const base = discoverBase.trim() || draft?.apiBase || "";
|
|
2705
|
+
if (base === "" || discovering) return;
|
|
2706
|
+
setDiscovering(true);
|
|
2707
|
+
setDiscoverError(null);
|
|
2708
|
+
try {
|
|
2709
|
+
const result = await discoverModels(base, discoverKey);
|
|
2710
|
+
setDiscoverResult(result);
|
|
2711
|
+
setDiscoverKey("");
|
|
2712
|
+
} catch (caught) {
|
|
2713
|
+
setDiscoverResult(null);
|
|
2714
|
+
setDiscoverError(caught instanceof Error ? caught.message : t("discoveryFailed"));
|
|
2715
|
+
} finally {
|
|
2716
|
+
setDiscovering(false);
|
|
2717
|
+
}
|
|
2718
|
+
};
|
|
2669
2719
|
if (loading && state === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2670
2720
|
className: "ocl-hint",
|
|
2671
2721
|
children: t("loading")
|
|
@@ -3688,6 +3738,85 @@ window.__ModuleLoader__.load({
|
|
|
3688
3738
|
]
|
|
3689
3739
|
})]
|
|
3690
3740
|
}),
|
|
3741
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3742
|
+
className: "ocl-card",
|
|
3743
|
+
children: [
|
|
3744
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
3745
|
+
className: "ocl-card-title",
|
|
3746
|
+
children: t("discover")
|
|
3747
|
+
}),
|
|
3748
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3749
|
+
className: "ocl-hint",
|
|
3750
|
+
children: t("discoverHint")
|
|
3751
|
+
}),
|
|
3752
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3753
|
+
className: "ocl-field",
|
|
3754
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("endpoint") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3755
|
+
className: "ocl-input",
|
|
3756
|
+
value: discoverBase,
|
|
3757
|
+
placeholder: draft.apiBase,
|
|
3758
|
+
onChange: (event) => setDiscoverBase(event.target.value)
|
|
3759
|
+
})]
|
|
3760
|
+
}),
|
|
3761
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3762
|
+
className: "ocl-field",
|
|
3763
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("oneShotKey") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3764
|
+
className: "ocl-input",
|
|
3765
|
+
type: "password",
|
|
3766
|
+
autoComplete: "off",
|
|
3767
|
+
value: discoverKey,
|
|
3768
|
+
placeholder: t("oneShotKeyPlaceholder"),
|
|
3769
|
+
onChange: (event) => setDiscoverKey(event.target.value)
|
|
3770
|
+
})]
|
|
3771
|
+
}),
|
|
3772
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3773
|
+
className: "ocl-hint",
|
|
3774
|
+
children: t("oneShotKeyHint")
|
|
3775
|
+
}),
|
|
3776
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3777
|
+
type: "button",
|
|
3778
|
+
className: "ocl-button",
|
|
3779
|
+
disabled: discovering,
|
|
3780
|
+
onClick: () => {
|
|
3781
|
+
runDiscovery();
|
|
3782
|
+
},
|
|
3783
|
+
children: discovering ? t("discovering") : t("discoverAction")
|
|
3784
|
+
}),
|
|
3785
|
+
discoverError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3786
|
+
className: "ocl-error",
|
|
3787
|
+
children: discoverError
|
|
3788
|
+
}),
|
|
3789
|
+
discoverResult !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3790
|
+
className: "ocl-model-section",
|
|
3791
|
+
children: [
|
|
3792
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3793
|
+
className: "ocl-model-section-head",
|
|
3794
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
3795
|
+
discoverResult.base,
|
|
3796
|
+
" · ",
|
|
3797
|
+
discoverResult.models.length,
|
|
3798
|
+
" ",
|
|
3799
|
+
t("modelCount")
|
|
3800
|
+
] })
|
|
3801
|
+
}),
|
|
3802
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3803
|
+
className: "ocl-hint",
|
|
3804
|
+
children: t("currentOnly")
|
|
3805
|
+
}),
|
|
3806
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3807
|
+
className: "ocl-models",
|
|
3808
|
+
children: discoverResult.models.slice(0, 100).map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3809
|
+
className: "ocl-model",
|
|
3810
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3811
|
+
className: "ocl-model-name",
|
|
3812
|
+
children: model
|
|
3813
|
+
})
|
|
3814
|
+
}, model))
|
|
3815
|
+
})
|
|
3816
|
+
]
|
|
3817
|
+
})
|
|
3818
|
+
]
|
|
3819
|
+
}),
|
|
3691
3820
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3692
3821
|
className: "ocl-card",
|
|
3693
3822
|
children: [
|
package/lib/index.d.ts
CHANGED
|
@@ -461,6 +461,8 @@ interface RouteDeps {
|
|
|
461
461
|
readonly verifyHost?: (req: IncomingMessage) => Promise<boolean>;
|
|
462
462
|
/** Test seam for local Ollama inventory and mutation routes. */
|
|
463
463
|
readonly localFetch?: typeof fetch;
|
|
464
|
+
/** Test seam for unsaved-endpoint discovery. */
|
|
465
|
+
readonly discoveryFetch?: typeof fetch;
|
|
464
466
|
}
|
|
465
467
|
/** Register the Host HTTP surface consumed by the browser settings page. */
|
|
466
468
|
declare function applyRoutes(ctx: Context, web: WebServer, deps: RouteDeps): void;
|
package/lib/index.js
CHANGED
|
@@ -77,7 +77,7 @@ const DEFAULT_API_BASE = "https://ollama.com";
|
|
|
77
77
|
const DEFAULT_OPENAI_BASE = "https://ollama.com/v1";
|
|
78
78
|
const DEFAULT_USAGE_URL = "https://ollama.com/api/usage";
|
|
79
79
|
const DEFAULT_BALANCE_URL = "https://ollama.com/api/balance";
|
|
80
|
-
const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.
|
|
80
|
+
const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.25";
|
|
81
81
|
const DEFAULT_CONTEXT_WINDOW = 131072;
|
|
82
82
|
const DEFAULT_MAX_TOKENS = 32768;
|
|
83
83
|
const DEFAULT_GENERATE_MAX_TOKENS = 131072;
|
|
@@ -3967,13 +3967,13 @@ function header(request, name) {
|
|
|
3967
3967
|
const value = request.headers?.[name];
|
|
3968
3968
|
return Array.isArray(value) ? value[0] : value;
|
|
3969
3969
|
}
|
|
3970
|
-
function isLoopback(value) {
|
|
3970
|
+
function isLoopback$1(value) {
|
|
3971
3971
|
const address = value?.toLowerCase().replace(/^\[|\]$/g, "");
|
|
3972
3972
|
return address === "localhost" || address === "localhost." || address === "::1" || address?.startsWith("127.") === true || address?.startsWith("::ffff:127.") === true;
|
|
3973
3973
|
}
|
|
3974
3974
|
function isTrustedUpdateRequest(request) {
|
|
3975
3975
|
if (header(request, UPDATE_HEADER) !== "1") return false;
|
|
3976
|
-
if (!isLoopback(request.socket?.remoteAddress)) return false;
|
|
3976
|
+
if (!isLoopback$1(request.socket?.remoteAddress)) return false;
|
|
3977
3977
|
const site = header(request, "sec-fetch-site");
|
|
3978
3978
|
if (site !== void 0 && site !== "same-origin") return false;
|
|
3979
3979
|
const origin = header(request, "origin");
|
|
@@ -3981,7 +3981,7 @@ function isTrustedUpdateRequest(request) {
|
|
|
3981
3981
|
if (origin === void 0 || host === void 0) return false;
|
|
3982
3982
|
try {
|
|
3983
3983
|
const url = new URL(origin);
|
|
3984
|
-
return (url.protocol === "http:" || url.protocol === "https:") && isLoopback(url.hostname) && url.host === host;
|
|
3984
|
+
return (url.protocol === "http:" || url.protocol === "https:") && isLoopback$1(url.hostname) && url.host === host;
|
|
3985
3985
|
} catch {
|
|
3986
3986
|
return false;
|
|
3987
3987
|
}
|
|
@@ -4546,6 +4546,86 @@ async function readModelAnalytics(days = 30, priceOverrides = {}) {
|
|
|
4546
4546
|
});
|
|
4547
4547
|
return report;
|
|
4548
4548
|
}
|
|
4549
|
+
// src/discovery.ts
|
|
4550
|
+
const DISCOVERY_TIMEOUT_MS = 15e3;
|
|
4551
|
+
var DiscoveryError = class extends Error {
|
|
4552
|
+
status;
|
|
4553
|
+
constructor(message, status) {
|
|
4554
|
+
super(message);
|
|
4555
|
+
this.status = status;
|
|
4556
|
+
this.name = "DiscoveryError";
|
|
4557
|
+
}
|
|
4558
|
+
};
|
|
4559
|
+
function normalizeBase(raw) {
|
|
4560
|
+
const value = raw.trim().replace(/\/+$/, "");
|
|
4561
|
+
let url;
|
|
4562
|
+
try {
|
|
4563
|
+
url = new URL(value);
|
|
4564
|
+
} catch {
|
|
4565
|
+
throw new DiscoveryError("invalid endpoint URL");
|
|
4566
|
+
}
|
|
4567
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") throw new DiscoveryError("endpoint must use http or https");
|
|
4568
|
+
if (url.username !== "" || url.password !== "") throw new DiscoveryError("endpoint URL must not contain credentials");
|
|
4569
|
+
return value;
|
|
4570
|
+
}
|
|
4571
|
+
function isLoopback(url) {
|
|
4572
|
+
try {
|
|
4573
|
+
const host = new URL(url).hostname;
|
|
4574
|
+
return host === "127.0.0.1" || host === "localhost" || host === "::1" || host === "[::1]";
|
|
4575
|
+
} catch {
|
|
4576
|
+
return false;
|
|
4577
|
+
}
|
|
4578
|
+
}
|
|
4579
|
+
function idsOf(payload) {
|
|
4580
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return [];
|
|
4581
|
+
const record = payload;
|
|
4582
|
+
const fromData = Array.isArray(record.data) ? record.data.map((entry) => {
|
|
4583
|
+
if (typeof entry !== "object" || entry === null) return void 0;
|
|
4584
|
+
const id = entry.id;
|
|
4585
|
+
return typeof id === "string" && id !== "" ? id : void 0;
|
|
4586
|
+
}).filter((id) => id !== void 0) : [];
|
|
4587
|
+
if (fromData.length > 0) return fromData;
|
|
4588
|
+
return Array.isArray(record.models) ? record.models.map((entry) => {
|
|
4589
|
+
if (typeof entry !== "object" || entry === null) return void 0;
|
|
4590
|
+
const item = entry;
|
|
4591
|
+
const id = typeof item.name === "string" ? item.name : item.model;
|
|
4592
|
+
return typeof id === "string" && id !== "" ? id : void 0;
|
|
4593
|
+
}).filter((id) => id !== void 0) : [];
|
|
4594
|
+
}
|
|
4595
|
+
async function get(url, key, fetchImpl, signal) {
|
|
4596
|
+
const response = await fetchImpl(url, {
|
|
4597
|
+
method: "GET",
|
|
4598
|
+
headers: {
|
|
4599
|
+
accept: "application/json",
|
|
4600
|
+
...key === "" ? {} : { authorization: `Bearer ${key}` }
|
|
4601
|
+
},
|
|
4602
|
+
redirect: "error",
|
|
4603
|
+
signal
|
|
4604
|
+
});
|
|
4605
|
+
if (!response.ok) throw new DiscoveryError(`endpoint answered ${response.status}`, response.status);
|
|
4606
|
+
return response.json();
|
|
4607
|
+
}
|
|
4608
|
+
/**
|
|
4609
|
+
* Discover a catalog for an unsaved endpoint with a one-shot key.
|
|
4610
|
+
* This function performs no persistence and never includes the key in errors.
|
|
4611
|
+
*/
|
|
4612
|
+
async function discoverModels(rawBase, key, fetchImpl = fetch) {
|
|
4613
|
+
const base = normalizeBase(rawBase);
|
|
4614
|
+
const budget = AbortSignal.timeout(DISCOVERY_TIMEOUT_MS);
|
|
4615
|
+
let payload;
|
|
4616
|
+
try {
|
|
4617
|
+
payload = await get(`${base}/v1/models`, key, fetchImpl, budget);
|
|
4618
|
+
} catch (error) {
|
|
4619
|
+
if (error instanceof DiscoveryError && error.status === 401) throw error;
|
|
4620
|
+
if (error instanceof DiscoveryError && error.status === 404) payload = await get(`${base}/api/tags`, key, fetchImpl, budget);
|
|
4621
|
+
else throw error;
|
|
4622
|
+
}
|
|
4623
|
+
return {
|
|
4624
|
+
base,
|
|
4625
|
+
models: [...new Set(idsOf(payload))],
|
|
4626
|
+
local: isLoopback(base)
|
|
4627
|
+
};
|
|
4628
|
+
}
|
|
4549
4629
|
// src/routes-public.ts
|
|
4550
4630
|
function publicConfig(config) {
|
|
4551
4631
|
return {
|
|
@@ -5392,6 +5472,23 @@ function applyRoutes(ctx, web, deps) {
|
|
|
5392
5472
|
json(res, 502, { error: error instanceof Error ? error.message : "remove failed" });
|
|
5393
5473
|
}
|
|
5394
5474
|
});
|
|
5475
|
+
route("/dsh-ollama/discover", async (req, res) => {
|
|
5476
|
+
if (!await requirePost(req, res, verifyHost)) return;
|
|
5477
|
+
let body;
|
|
5478
|
+
try {
|
|
5479
|
+
body = await readJson(req);
|
|
5480
|
+
} catch (error) {
|
|
5481
|
+
json(res, 400, { error: error instanceof Error ? error.message : "invalid body" });
|
|
5482
|
+
return;
|
|
5483
|
+
}
|
|
5484
|
+
const apiBase = typeof body.apiBase === "string" ? body.apiBase : "";
|
|
5485
|
+
const apiKey = typeof body.apiKey === "string" ? body.apiKey : "";
|
|
5486
|
+
try {
|
|
5487
|
+
json(res, 200, await discoverModels(apiBase, apiKey, deps.discoveryFetch));
|
|
5488
|
+
} catch (error) {
|
|
5489
|
+
json(res, 400, { error: error instanceof Error ? error.message : "discovery failed" });
|
|
5490
|
+
}
|
|
5491
|
+
});
|
|
5395
5492
|
route("/dsh-ollama/test", async (req, res) => {
|
|
5396
5493
|
if (!await requirePost(req, res, verifyHost)) return;
|
|
5397
5494
|
let body;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-ollama-cloud-provider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
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",
|
|
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"
|