@goodandready/dsh-ollama-cloud-provider 0.1.23 → 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 +22 -0
- package/README.md +4 -4
- package/README.ru.md +4 -4
- package/README.zh.md +4 -4
- package/lib/client.js +421 -2
- package/lib/index.d.ts +13 -0
- package/lib/index.js +174 -13
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
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
|
+
|
|
13
|
+
## 0.1.24 — 2026-11-05
|
|
14
|
+
|
|
15
|
+
- Added per-model capability/thinking overrides (`modelOverrides`) for
|
|
16
|
+
context, vision, thinking, reasoning efforts/default and enabled; the
|
|
17
|
+
override wins over manual entries and live discovery. Disabled models are
|
|
18
|
+
hidden from the picker.
|
|
19
|
+
- Added a model override editor exposing context, input/output/cacheRead
|
|
20
|
+
prices, visibility, vision/thinking/enabled tri-state and reset-to-live.
|
|
21
|
+
- `/api/show` capability probes remain TTL-cached and are invalidated on local
|
|
22
|
+
pull/remove.
|
|
23
|
+
- Added override precedence and validation tests; 129/129.
|
|
24
|
+
|
|
3
25
|
## 0.1.23 — 2026-11-05
|
|
4
26
|
|
|
5
27
|
- Richer model catalog rows grouped by effective context, collapsible groups,
|
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",
|
|
@@ -137,6 +147,18 @@ window.__ModuleLoader__.load({
|
|
|
137
147
|
manualEffortsHint: "Comma-separated levels, e.g. off, low, medium, high.",
|
|
138
148
|
defaultReasoning: "Default effort",
|
|
139
149
|
enabled: "Enabled",
|
|
150
|
+
edit: "Edit",
|
|
151
|
+
overrideEditor: "Model overrides",
|
|
152
|
+
resetToLive: "Reset to live",
|
|
153
|
+
priceInput: "Input $/1M",
|
|
154
|
+
priceOutput: "Output $/1M",
|
|
155
|
+
priceCacheRead: "Cache read $/1M",
|
|
156
|
+
visibility: "Visibility",
|
|
157
|
+
inherit: "Inherit",
|
|
158
|
+
show: "Show",
|
|
159
|
+
hide: "Hide",
|
|
160
|
+
yes: "Yes",
|
|
161
|
+
no: "No",
|
|
140
162
|
generation: "Generation defaults",
|
|
141
163
|
generationHint: "Native Ollama defaults. Empty fields are not sent; request options still win.",
|
|
142
164
|
temperature: "Temperature",
|
|
@@ -349,6 +371,16 @@ window.__ModuleLoader__.load({
|
|
|
349
371
|
attemptTimeoutHint: "整次尝试超时;每次重试都会创建新的预算。",
|
|
350
372
|
maxOutputTokens: "输出上限(0 = 提供方默认)",
|
|
351
373
|
contextWindow: "上下文窗口覆盖",
|
|
374
|
+
discover: "发现草稿端点",
|
|
375
|
+
discoverHint: "探测未保存的端点并显示目录,不修改当前设置。",
|
|
376
|
+
endpoint: "端点",
|
|
377
|
+
oneShotKey: "一次性 API 密钥",
|
|
378
|
+
oneShotKeyPlaceholder: "本地端点可留空",
|
|
379
|
+
oneShotKeyHint: "仅用于本次请求;不会存储、保存或记录。",
|
|
380
|
+
discovering: "正在发现…",
|
|
381
|
+
discoverAction: "发现模型",
|
|
382
|
+
discoveryFailed: "发现失败",
|
|
383
|
+
currentOnly: "仅预览 — 当前提供方设置不变。",
|
|
352
384
|
contextGroup: "上下文",
|
|
353
385
|
dragOrder: "拖动排序",
|
|
354
386
|
manualModels: "手动目录条目",
|
|
@@ -362,6 +394,18 @@ window.__ModuleLoader__.load({
|
|
|
362
394
|
manualEffortsHint: "逗号分隔,例如 off, low, medium, high。",
|
|
363
395
|
defaultReasoning: "默认档位",
|
|
364
396
|
enabled: "启用",
|
|
397
|
+
edit: "编辑",
|
|
398
|
+
overrideEditor: "模型覆盖",
|
|
399
|
+
resetToLive: "恢复实时值",
|
|
400
|
+
priceInput: "输入 $/1M",
|
|
401
|
+
priceOutput: "输出 $/1M",
|
|
402
|
+
priceCacheRead: "缓存读取 $/1M",
|
|
403
|
+
visibility: "可见性",
|
|
404
|
+
inherit: "继承",
|
|
405
|
+
show: "显示",
|
|
406
|
+
hide: "隐藏",
|
|
407
|
+
yes: "是",
|
|
408
|
+
no: "否",
|
|
365
409
|
generation: "生成默认值",
|
|
366
410
|
generationHint: "Ollama 原生默认值;空字段不发送,请求参数优先。",
|
|
367
411
|
temperature: "Temperature",
|
|
@@ -559,6 +603,15 @@ window.__ModuleLoader__.load({
|
|
|
559
603
|
body: "{}"
|
|
560
604
|
});
|
|
561
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
|
+
}
|
|
562
615
|
function fetchLocalModels() {
|
|
563
616
|
return call("/dsh-ollama/local/models");
|
|
564
617
|
}
|
|
@@ -1715,6 +1768,20 @@ window.__ModuleLoader__.load({
|
|
|
1715
1768
|
tools: model.tools === true
|
|
1716
1769
|
})),
|
|
1717
1770
|
modelOrder: [...state.config.modelOrder ?? []],
|
|
1771
|
+
contextWindowOverrides: Object.fromEntries(Object.entries(state.config.contextWindowOverrides).map(([id, value]) => [id, String(value)])),
|
|
1772
|
+
priceOverrides: Object.fromEntries(Object.entries(state.config.priceOverrides).map(([id, price]) => [id, {
|
|
1773
|
+
input: price.input === void 0 ? "" : String(price.input),
|
|
1774
|
+
output: price.output === void 0 ? "" : String(price.output),
|
|
1775
|
+
cacheRead: price.cacheRead === void 0 ? "" : String(price.cacheRead)
|
|
1776
|
+
}])),
|
|
1777
|
+
modelOverrides: Object.fromEntries(Object.entries(state.config.modelOverrides ?? {}).map(([id, override]) => [id, {
|
|
1778
|
+
contextWindow: override.contextWindow === void 0 ? "" : String(override.contextWindow),
|
|
1779
|
+
image: override.image === void 0 ? "" : override.image ? "yes" : "no",
|
|
1780
|
+
thinking: override.thinking === void 0 ? "" : override.thinking ? "yes" : "no",
|
|
1781
|
+
reasoningEfforts: (override.reasoningEfforts ?? []).join(", "),
|
|
1782
|
+
defaultEffort: override.defaultEffort ?? "",
|
|
1783
|
+
enabled: override.enabled === void 0 ? "" : override.enabled ? "yes" : "no"
|
|
1784
|
+
}])),
|
|
1718
1785
|
showAll: state.config.showAllModels,
|
|
1719
1786
|
modelTransports: { ...state.config.modelTransports }
|
|
1720
1787
|
};
|
|
@@ -1790,6 +1857,27 @@ window.__ModuleLoader__.load({
|
|
|
1790
1857
|
tools: model.tools
|
|
1791
1858
|
})),
|
|
1792
1859
|
modelOrder: draft.modelOrder.filter((id) => id !== ""),
|
|
1860
|
+
contextWindowOverrides: Object.fromEntries(Object.entries(draft.contextWindowOverrides).map(([id, value]) => [id, numberOrNull(value)]).filter((entry) => entry[1] !== null && entry[1] > 0)),
|
|
1861
|
+
priceOverrides: Object.fromEntries(Object.entries(draft.priceOverrides).map(([id, price]) => {
|
|
1862
|
+
const out = {};
|
|
1863
|
+
for (const [field, value] of Object.entries(price)) {
|
|
1864
|
+
const parsed = numberOrNull(value);
|
|
1865
|
+
if (parsed !== null) out[field] = parsed;
|
|
1866
|
+
}
|
|
1867
|
+
return [id, out];
|
|
1868
|
+
}).filter((entry) => Object.keys(entry[1]).length > 0)),
|
|
1869
|
+
modelOverrides: Object.fromEntries(Object.entries(draft.modelOverrides).map(([id, override]) => {
|
|
1870
|
+
const contextWindow = numberOrNull(override.contextWindow);
|
|
1871
|
+
const efforts = stopList(override.reasoningEfforts);
|
|
1872
|
+
return [id, {
|
|
1873
|
+
...contextWindow === null || contextWindow <= 0 ? {} : { contextWindow },
|
|
1874
|
+
...override.image === "" ? {} : { image: override.image === "yes" },
|
|
1875
|
+
...override.thinking === "" ? {} : { thinking: override.thinking === "yes" },
|
|
1876
|
+
...efforts.length === 0 ? {} : { reasoningEfforts: efforts },
|
|
1877
|
+
...override.defaultEffort.trim() === "" ? {} : { defaultEffort: override.defaultEffort.trim() },
|
|
1878
|
+
...override.enabled === "" ? {} : { enabled: override.enabled === "yes" }
|
|
1879
|
+
}];
|
|
1880
|
+
}).filter((entry) => Object.keys(entry[1]).length > 0)),
|
|
1793
1881
|
modelTransports: Object.fromEntries(Object.entries(draft.modelTransports).filter(([, value]) => value !== ""))
|
|
1794
1882
|
};
|
|
1795
1883
|
}
|
|
@@ -2081,6 +2169,219 @@ window.__ModuleLoader__.load({
|
|
|
2081
2169
|
base.splice(insertAt, 0, moved);
|
|
2082
2170
|
return base;
|
|
2083
2171
|
}
|
|
2172
|
+
// src/client/model-override-editor.tsx
|
|
2173
|
+
const blankOverride = {
|
|
2174
|
+
contextWindow: "",
|
|
2175
|
+
image: "",
|
|
2176
|
+
thinking: "",
|
|
2177
|
+
reasoningEfforts: "",
|
|
2178
|
+
defaultEffort: "",
|
|
2179
|
+
enabled: ""
|
|
2180
|
+
};
|
|
2181
|
+
function ModelOverrideEditor(props) {
|
|
2182
|
+
const { model, draft, t, update, close } = props;
|
|
2183
|
+
const override = draft.modelOverrides[model.id] ?? blankOverride;
|
|
2184
|
+
const price = draft.priceOverrides[model.id] ?? {
|
|
2185
|
+
input: "",
|
|
2186
|
+
output: "",
|
|
2187
|
+
cacheRead: ""
|
|
2188
|
+
};
|
|
2189
|
+
const context = draft.contextWindowOverrides[model.id] ?? "";
|
|
2190
|
+
const visibility = draft.modelVisibility[model.id];
|
|
2191
|
+
const updateOverride = (patch) => {
|
|
2192
|
+
update({ modelOverrides: {
|
|
2193
|
+
...draft.modelOverrides,
|
|
2194
|
+
[model.id]: {
|
|
2195
|
+
...override,
|
|
2196
|
+
...patch
|
|
2197
|
+
}
|
|
2198
|
+
} });
|
|
2199
|
+
};
|
|
2200
|
+
const updatePrice = (patch) => {
|
|
2201
|
+
update({ priceOverrides: {
|
|
2202
|
+
...draft.priceOverrides,
|
|
2203
|
+
[model.id]: {
|
|
2204
|
+
...price,
|
|
2205
|
+
...patch
|
|
2206
|
+
}
|
|
2207
|
+
} });
|
|
2208
|
+
};
|
|
2209
|
+
const updateVisibility = (value) => {
|
|
2210
|
+
const next = { ...draft.modelVisibility };
|
|
2211
|
+
if (value === "inherit") delete next[model.id];
|
|
2212
|
+
else next[model.id] = value === "show";
|
|
2213
|
+
update({ modelVisibility: next });
|
|
2214
|
+
};
|
|
2215
|
+
const reset = () => {
|
|
2216
|
+
const nextContext = { ...draft.contextWindowOverrides };
|
|
2217
|
+
const nextPrice = { ...draft.priceOverrides };
|
|
2218
|
+
const nextVisibility = { ...draft.modelVisibility };
|
|
2219
|
+
const nextOverrides = { ...draft.modelOverrides };
|
|
2220
|
+
delete nextContext[model.id];
|
|
2221
|
+
delete nextPrice[model.id];
|
|
2222
|
+
delete nextVisibility[model.id];
|
|
2223
|
+
delete nextOverrides[model.id];
|
|
2224
|
+
update({
|
|
2225
|
+
contextWindowOverrides: nextContext,
|
|
2226
|
+
priceOverrides: nextPrice,
|
|
2227
|
+
modelVisibility: nextVisibility,
|
|
2228
|
+
modelOverrides: nextOverrides
|
|
2229
|
+
});
|
|
2230
|
+
};
|
|
2231
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2232
|
+
className: "ocl-model-section",
|
|
2233
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2234
|
+
className: "ocl-model-section-head",
|
|
2235
|
+
children: [
|
|
2236
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
2237
|
+
t("overrideEditor"),
|
|
2238
|
+
": ",
|
|
2239
|
+
model.id
|
|
2240
|
+
] }),
|
|
2241
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2242
|
+
type: "button",
|
|
2243
|
+
className: "ocl-button",
|
|
2244
|
+
onClick: reset,
|
|
2245
|
+
children: t("resetToLive")
|
|
2246
|
+
}),
|
|
2247
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2248
|
+
type: "button",
|
|
2249
|
+
className: "ocl-button",
|
|
2250
|
+
onClick: close,
|
|
2251
|
+
children: t("close")
|
|
2252
|
+
})
|
|
2253
|
+
]
|
|
2254
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2255
|
+
className: "ocl-grid",
|
|
2256
|
+
children: [
|
|
2257
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2258
|
+
label: t("contextWindow"),
|
|
2259
|
+
value: context,
|
|
2260
|
+
onChange: (value) => update({ contextWindowOverrides: {
|
|
2261
|
+
...draft.contextWindowOverrides,
|
|
2262
|
+
[model.id]: value
|
|
2263
|
+
} })
|
|
2264
|
+
}),
|
|
2265
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2266
|
+
label: t("priceInput"),
|
|
2267
|
+
type: "number",
|
|
2268
|
+
value: price.input,
|
|
2269
|
+
onChange: (value) => updatePrice({ input: value })
|
|
2270
|
+
}),
|
|
2271
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2272
|
+
label: t("priceOutput"),
|
|
2273
|
+
type: "number",
|
|
2274
|
+
value: price.output,
|
|
2275
|
+
onChange: (value) => updatePrice({ output: value })
|
|
2276
|
+
}),
|
|
2277
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2278
|
+
label: t("priceCacheRead"),
|
|
2279
|
+
type: "number",
|
|
2280
|
+
value: price.cacheRead,
|
|
2281
|
+
onChange: (value) => updatePrice({ cacheRead: value })
|
|
2282
|
+
}),
|
|
2283
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2284
|
+
className: "ocl-field",
|
|
2285
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("visibility") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
2286
|
+
className: "ocl-select",
|
|
2287
|
+
value: visibility === void 0 ? "inherit" : visibility ? "show" : "hide",
|
|
2288
|
+
onChange: (event) => updateVisibility(event.target.value),
|
|
2289
|
+
children: [
|
|
2290
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2291
|
+
value: "inherit",
|
|
2292
|
+
children: t("inherit")
|
|
2293
|
+
}),
|
|
2294
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2295
|
+
value: "show",
|
|
2296
|
+
children: t("show")
|
|
2297
|
+
}),
|
|
2298
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2299
|
+
value: "hide",
|
|
2300
|
+
children: t("hide")
|
|
2301
|
+
})
|
|
2302
|
+
]
|
|
2303
|
+
})]
|
|
2304
|
+
}),
|
|
2305
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2306
|
+
className: "ocl-field",
|
|
2307
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("vision") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
2308
|
+
className: "ocl-select",
|
|
2309
|
+
value: override.image,
|
|
2310
|
+
onChange: (event) => updateOverride({ image: event.target.value }),
|
|
2311
|
+
children: [
|
|
2312
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2313
|
+
value: "",
|
|
2314
|
+
children: t("inherit")
|
|
2315
|
+
}),
|
|
2316
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2317
|
+
value: "yes",
|
|
2318
|
+
children: t("yes")
|
|
2319
|
+
}),
|
|
2320
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2321
|
+
value: "no",
|
|
2322
|
+
children: t("no")
|
|
2323
|
+
})
|
|
2324
|
+
]
|
|
2325
|
+
})]
|
|
2326
|
+
}),
|
|
2327
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2328
|
+
className: "ocl-field",
|
|
2329
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("reasoning") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
2330
|
+
className: "ocl-select",
|
|
2331
|
+
value: override.thinking,
|
|
2332
|
+
onChange: (event) => updateOverride({ thinking: event.target.value }),
|
|
2333
|
+
children: [
|
|
2334
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2335
|
+
value: "",
|
|
2336
|
+
children: t("inherit")
|
|
2337
|
+
}),
|
|
2338
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2339
|
+
value: "yes",
|
|
2340
|
+
children: t("yes")
|
|
2341
|
+
}),
|
|
2342
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2343
|
+
value: "no",
|
|
2344
|
+
children: t("no")
|
|
2345
|
+
})
|
|
2346
|
+
]
|
|
2347
|
+
})]
|
|
2348
|
+
}),
|
|
2349
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2350
|
+
className: "ocl-field",
|
|
2351
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("enabled") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
2352
|
+
className: "ocl-select",
|
|
2353
|
+
value: override.enabled,
|
|
2354
|
+
onChange: (event) => updateOverride({ enabled: event.target.value }),
|
|
2355
|
+
children: [
|
|
2356
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2357
|
+
value: "",
|
|
2358
|
+
children: t("inherit")
|
|
2359
|
+
}),
|
|
2360
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2361
|
+
value: "yes",
|
|
2362
|
+
children: t("yes")
|
|
2363
|
+
}),
|
|
2364
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2365
|
+
value: "no",
|
|
2366
|
+
children: t("no")
|
|
2367
|
+
})
|
|
2368
|
+
]
|
|
2369
|
+
})]
|
|
2370
|
+
}),
|
|
2371
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2372
|
+
label: t("reasoningEfforts"),
|
|
2373
|
+
value: override.reasoningEfforts,
|
|
2374
|
+
onChange: (value) => updateOverride({ reasoningEfforts: value })
|
|
2375
|
+
}),
|
|
2376
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2377
|
+
label: t("defaultReasoning"),
|
|
2378
|
+
value: override.defaultEffort,
|
|
2379
|
+
onChange: (value) => updateOverride({ defaultEffort: value })
|
|
2380
|
+
})
|
|
2381
|
+
]
|
|
2382
|
+
})]
|
|
2383
|
+
});
|
|
2384
|
+
}
|
|
2084
2385
|
// src/client/update-state.ts
|
|
2085
2386
|
function updateBadge(status) {
|
|
2086
2387
|
if (status.latestCheckFailed) return "failed";
|
|
@@ -2201,7 +2502,7 @@ window.__ModuleLoader__.load({
|
|
|
2201
2502
|
}
|
|
2202
2503
|
// src/client/settings-page.tsx
|
|
2203
2504
|
function ModelEntry(props) {
|
|
2204
|
-
const { model, visible, transport, onVisible, onTransport, onDragStart, onDrop, dragging, t } = props;
|
|
2505
|
+
const { model, visible, transport, onVisible, onTransport, onDragStart, onDrop, onEdit, dragging, t } = props;
|
|
2205
2506
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2206
2507
|
className: `ocl-model${dragging === true ? " ocl-dragging" : ""}`,
|
|
2207
2508
|
draggable: onDragStart !== void 0,
|
|
@@ -2276,6 +2577,12 @@ window.__ModuleLoader__.load({
|
|
|
2276
2577
|
})
|
|
2277
2578
|
]
|
|
2278
2579
|
}),
|
|
2580
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2581
|
+
type: "button",
|
|
2582
|
+
className: "ocl-button",
|
|
2583
|
+
onClick: onEdit,
|
|
2584
|
+
children: t("edit")
|
|
2585
|
+
}),
|
|
2279
2586
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
2280
2587
|
className: "ocl-select",
|
|
2281
2588
|
value: transport === "" ? model.transport : transport,
|
|
@@ -2303,6 +2610,7 @@ window.__ModuleLoader__.load({
|
|
|
2303
2610
|
const [saving, setSaving] = (0, react.useState)(false);
|
|
2304
2611
|
const [search, setSearch] = (0, react.useState)("");
|
|
2305
2612
|
const [dragId, setDragId] = (0, react.useState)(null);
|
|
2613
|
+
const [editingModel, setEditingModel] = (0, react.useState)(null);
|
|
2306
2614
|
const [collapsedGroups, setCollapsedGroups] = (0, react.useState)({});
|
|
2307
2615
|
const [keyDraft, setKeyDraft] = (0, react.useState)("");
|
|
2308
2616
|
const [accountKeys, setAccountKeys] = (0, react.useState)({});
|
|
@@ -2312,6 +2620,11 @@ window.__ModuleLoader__.load({
|
|
|
2312
2620
|
const [service, setService] = (0, react.useState)(null);
|
|
2313
2621
|
const [serviceBusy, setServiceBusy] = (0, react.useState)(false);
|
|
2314
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);
|
|
2315
2628
|
const load = (0, react.useCallback)(async (preserveDraft = false) => {
|
|
2316
2629
|
setLoading(true);
|
|
2317
2630
|
try {
|
|
@@ -2387,6 +2700,22 @@ window.__ModuleLoader__.load({
|
|
|
2387
2700
|
(0, react.useEffect)(() => {
|
|
2388
2701
|
loadService();
|
|
2389
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
|
+
};
|
|
2390
2719
|
if (loading && state === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2391
2720
|
className: "ocl-hint",
|
|
2392
2721
|
children: t("loading")
|
|
@@ -3084,6 +3413,7 @@ window.__ModuleLoader__.load({
|
|
|
3084
3413
|
if (dragId !== null) moveModel(dragId, model.id);
|
|
3085
3414
|
setDragId(null);
|
|
3086
3415
|
},
|
|
3416
|
+
onEdit: () => setEditingModel(model.id),
|
|
3087
3417
|
onVisible: (visible) => toggleModel(model.id, visible),
|
|
3088
3418
|
onTransport: (transport) => {
|
|
3089
3419
|
const next = { ...draft.modelTransports };
|
|
@@ -3097,6 +3427,16 @@ window.__ModuleLoader__.load({
|
|
|
3097
3427
|
})
|
|
3098
3428
|
]
|
|
3099
3429
|
}),
|
|
3430
|
+
editingModel !== null && state.models.some((model) => model.id === editingModel) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
3431
|
+
className: "ocl-card",
|
|
3432
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelOverrideEditor, {
|
|
3433
|
+
model: state.models.find((model) => model.id === editingModel),
|
|
3434
|
+
draft,
|
|
3435
|
+
t,
|
|
3436
|
+
update,
|
|
3437
|
+
close: () => setEditingModel(null)
|
|
3438
|
+
})
|
|
3439
|
+
}),
|
|
3100
3440
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3101
3441
|
className: "ocl-card",
|
|
3102
3442
|
children: [
|
|
@@ -3398,6 +3738,85 @@ window.__ModuleLoader__.load({
|
|
|
3398
3738
|
]
|
|
3399
3739
|
})]
|
|
3400
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
|
+
}),
|
|
3401
3820
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3402
3821
|
className: "ocl-card",
|
|
3403
3822
|
children: [
|
|
@@ -3534,7 +3953,7 @@ window.__ModuleLoader__.load({
|
|
|
3534
3953
|
.ocl-bar-fill-warn { background: var(--ocl-warning); opacity: 1; }
|
|
3535
3954
|
.ocl-bar-fill-bad { background: var(--ocl-danger); opacity: 1; }
|
|
3536
3955
|
.ocl-models { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow: auto; padding-right: 4px; }
|
|
3537
|
-
.ocl-model { display: grid; grid-template-columns: 16px 22px minmax(0,1fr) 120px; gap: 8px; align-items: center; font-size: 12px; padding: 3px 0; }
|
|
3956
|
+
.ocl-model { display: grid; grid-template-columns: 16px 22px minmax(0,1fr) auto 120px; gap: 8px; align-items: center; font-size: 12px; padding: 3px 0; }
|
|
3538
3957
|
.ocl-drag-handle { cursor: grab; color: var(--ocl-text-secondary); user-select: none; }
|
|
3539
3958
|
.ocl-dragging { opacity: 0.5; }
|
|
3540
3959
|
.ocl-model-group { display: flex; flex-direction: column; gap: 2px; }
|
package/lib/index.d.ts
CHANGED
|
@@ -23,6 +23,14 @@ interface ModelPriceOverride {
|
|
|
23
23
|
* Plugin configuration. Every field except the literal `apiKey` is volatile:
|
|
24
24
|
* the harness projects settings forms from schema fields carrying that marker.
|
|
25
25
|
*/
|
|
26
|
+
interface ModelOverride {
|
|
27
|
+
contextWindow?: number;
|
|
28
|
+
image?: boolean;
|
|
29
|
+
thinking?: boolean;
|
|
30
|
+
reasoningEfforts?: string[];
|
|
31
|
+
defaultEffort?: string;
|
|
32
|
+
enabled?: boolean;
|
|
33
|
+
}
|
|
26
34
|
interface ManualModel {
|
|
27
35
|
id: string;
|
|
28
36
|
enabled?: boolean;
|
|
@@ -66,6 +74,8 @@ interface Config {
|
|
|
66
74
|
modelVisibility?: Record<string, boolean>;
|
|
67
75
|
/** Manual catalog entries and overrides; merged over live discovery. */
|
|
68
76
|
manualModels?: ManualModel[];
|
|
77
|
+
/** Per-model capability/thinking overrides; wins over manual entries. */
|
|
78
|
+
modelOverrides?: Record<string, ModelOverride>;
|
|
69
79
|
/** Stable picker order; ids not listed follow by name. */
|
|
70
80
|
modelOrder?: string[];
|
|
71
81
|
/** Hide models the cloud marks unsupported in the API; defaults to true. */
|
|
@@ -125,6 +135,7 @@ interface ResolvedConfig {
|
|
|
125
135
|
showAllModels: boolean;
|
|
126
136
|
modelVisibility: Readonly<Record<string, boolean>>;
|
|
127
137
|
manualModels: readonly ManualModel[];
|
|
138
|
+
modelOverrides: Readonly<Record<string, ModelOverride>>;
|
|
128
139
|
modelOrder: readonly string[];
|
|
129
140
|
filterModelsByPlan: boolean;
|
|
130
141
|
contextWindow?: number;
|
|
@@ -450,6 +461,8 @@ interface RouteDeps {
|
|
|
450
461
|
readonly verifyHost?: (req: IncomingMessage) => Promise<boolean>;
|
|
451
462
|
/** Test seam for local Ollama inventory and mutation routes. */
|
|
452
463
|
readonly localFetch?: typeof fetch;
|
|
464
|
+
/** Test seam for unsaved-endpoint discovery. */
|
|
465
|
+
readonly discoveryFetch?: typeof fetch;
|
|
453
466
|
}
|
|
454
467
|
/** Register the Host HTTP surface consumed by the browser settings page. */
|
|
455
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;
|
|
@@ -112,6 +112,14 @@ const Config = z.object({
|
|
|
112
112
|
defaultReasoning: z.string(),
|
|
113
113
|
tools: z.boolean()
|
|
114
114
|
})).default([])),
|
|
115
|
+
modelOverrides: markVolatile(z.dict(z.object({
|
|
116
|
+
contextWindow: z.number().min(1).max(1e7).step(1),
|
|
117
|
+
image: z.boolean(),
|
|
118
|
+
thinking: z.boolean(),
|
|
119
|
+
reasoningEfforts: z.array(z.string()),
|
|
120
|
+
defaultEffort: z.string(),
|
|
121
|
+
enabled: z.boolean()
|
|
122
|
+
})).default({})),
|
|
115
123
|
modelOrder: markVolatile(z.array(z.string()).default([])),
|
|
116
124
|
filterModelsByPlan: markVolatile(z.boolean().default(true)),
|
|
117
125
|
contextWindow: markVolatile(z.number().min(1).max(1e7).step(1)),
|
|
@@ -174,6 +182,29 @@ function nonEmptyStrings(value) {
|
|
|
174
182
|
const out = value.filter((entry) => typeof entry === "string" && entry.trim() !== "");
|
|
175
183
|
return out.length === 0 ? void 0 : out;
|
|
176
184
|
}
|
|
185
|
+
function modelOverrideRecord(value) {
|
|
186
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
|
|
187
|
+
const out = {};
|
|
188
|
+
for (const [id, entry] of Object.entries(value)) {
|
|
189
|
+
if (id === "" || id.includes("..") || typeof entry !== "object" || entry === null || Array.isArray(entry)) continue;
|
|
190
|
+
const record = entry;
|
|
191
|
+
const contextWindow = integerInRange(record.contextWindow, 1, 1e7);
|
|
192
|
+
const efforts = Array.isArray(record.reasoningEfforts) ? record.reasoningEfforts.filter((item) => typeof item === "string" && item.trim() !== "") : void 0;
|
|
193
|
+
const thinking = typeof record.thinking === "boolean" ? record.thinking : void 0;
|
|
194
|
+
const normalizedEfforts = thinking === true && (efforts === void 0 || efforts.length === 0) ? ["off", "high"] : thinking === false ? [] : efforts;
|
|
195
|
+
const defaultEffort = typeof record.defaultEffort === "string" && record.defaultEffort.trim() !== "" ? record.defaultEffort.trim() : void 0;
|
|
196
|
+
if (contextWindow === void 0 && typeof record.image !== "boolean" && thinking === void 0 && efforts === void 0 && defaultEffort === void 0 && typeof record.enabled !== "boolean") continue;
|
|
197
|
+
out[id] = {
|
|
198
|
+
...contextWindow === void 0 ? {} : { contextWindow },
|
|
199
|
+
...typeof record.image === "boolean" ? { image: record.image } : {},
|
|
200
|
+
...thinking === void 0 ? {} : { thinking },
|
|
201
|
+
...normalizedEfforts === void 0 ? {} : { reasoningEfforts: normalizedEfforts },
|
|
202
|
+
...defaultEffort === void 0 ? {} : { defaultEffort },
|
|
203
|
+
...typeof record.enabled === "boolean" ? { enabled: record.enabled } : {}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
177
208
|
function manualModelList(value) {
|
|
178
209
|
if (!Array.isArray(value)) return [];
|
|
179
210
|
const out = [];
|
|
@@ -278,6 +309,7 @@ function resolveConfig(config) {
|
|
|
278
309
|
showAllModels: config.showAllModels === true ? true : config.showAllModels === false ? false : visibleModels.length === 0,
|
|
279
310
|
modelVisibility: booleanRecord(config.modelVisibility),
|
|
280
311
|
manualModels: manualModelList(config.manualModels),
|
|
312
|
+
modelOverrides: modelOverrideRecord(config.modelOverrides),
|
|
281
313
|
modelOrder: Array.isArray(config.modelOrder) ? config.modelOrder.filter((id) => typeof id === "string" && id !== "") : [],
|
|
282
314
|
filterModelsByPlan: config.filterModelsByPlan !== false,
|
|
283
315
|
...typeof config.contextWindow === "number" && Number.isInteger(config.contextWindow) && config.contextWindow > 0 ? { contextWindow: config.contextWindow } : {},
|
|
@@ -1399,18 +1431,19 @@ function manualModelFor(id, config) {
|
|
|
1399
1431
|
function effectiveModel(id, config) {
|
|
1400
1432
|
const meta = baseMeta(id, config.apiBase);
|
|
1401
1433
|
const manual = manualModelFor(id, config);
|
|
1434
|
+
const override = config.modelOverrides[id];
|
|
1402
1435
|
return {
|
|
1403
1436
|
...meta,
|
|
1404
1437
|
name: manual?.name ?? meta.name,
|
|
1405
1438
|
transport: config.modelTransports[id] ?? config.transport,
|
|
1406
|
-
contextWindow: config.contextWindowOverrides[id] ?? manual?.contextWindow ?? config.contextWindow ?? meta.contextWindow,
|
|
1439
|
+
contextWindow: config.contextWindowOverrides[id] ?? override?.contextWindow ?? manual?.contextWindow ?? config.contextWindow ?? meta.contextWindow,
|
|
1407
1440
|
maxTokens: manual?.maxTokens ?? meta.maxTokens,
|
|
1408
|
-
input: manual?.image === true ? ["text", "image"] : manual?.image === false ? ["text"] : meta.input,
|
|
1409
|
-
reasoning: manual?.reasoningEfforts ?? meta.reasoning,
|
|
1410
|
-
reasoningToggle: manual?.thinking ?? meta.reasoningToggle,
|
|
1411
|
-
...(manual?.defaultReasoning ?? meta.defaultReasoning) === void 0 ? {} : { defaultReasoning: manual?.defaultReasoning ?? meta.defaultReasoning },
|
|
1441
|
+
input: (override?.image ?? manual?.image) === true ? ["text", "image"] : (override?.image ?? manual?.image) === false ? ["text"] : meta.input,
|
|
1442
|
+
reasoning: override?.reasoningEfforts ?? manual?.reasoningEfforts ?? meta.reasoning,
|
|
1443
|
+
reasoningToggle: override?.thinking ?? manual?.thinking ?? meta.reasoningToggle,
|
|
1444
|
+
...(override?.defaultEffort ?? manual?.defaultReasoning ?? meta.defaultReasoning) === void 0 ? {} : { defaultReasoning: override?.defaultEffort ?? manual?.defaultReasoning ?? meta.defaultReasoning },
|
|
1412
1445
|
tools: manual?.tools ?? meta.tools,
|
|
1413
|
-
available: manual?.enabled === false ? false : meta.available
|
|
1446
|
+
available: override?.enabled === false || manual?.enabled === false ? false : meta.available
|
|
1414
1447
|
};
|
|
1415
1448
|
}
|
|
1416
1449
|
/** Effective per-request output default; `0` means "omit the field". */
|
|
@@ -1427,7 +1460,8 @@ function modelVisible(id, config) {
|
|
|
1427
1460
|
return config.visibleModels.includes(id);
|
|
1428
1461
|
}
|
|
1429
1462
|
function modelAvailable(id, config) {
|
|
1430
|
-
|
|
1463
|
+
const manual = manualModelFor(id, config);
|
|
1464
|
+
if (config.modelOverrides[id]?.enabled === false || manual?.enabled === false) return false;
|
|
1431
1465
|
if (!config.filterModelsByPlan) return true;
|
|
1432
1466
|
return effectiveModel(id, config).available !== false;
|
|
1433
1467
|
}
|
|
@@ -2822,7 +2856,11 @@ var OllamaCloudAdapter = class extends LlmAdapter {
|
|
|
2822
2856
|
async listModels(provider, opts) {
|
|
2823
2857
|
const config = this.deps.config();
|
|
2824
2858
|
const discovered = await refreshCatalog(config, this.fetchImpl);
|
|
2825
|
-
return sortForPicker([.../* @__PURE__ */ new Set([
|
|
2859
|
+
return sortForPicker([.../* @__PURE__ */ new Set([
|
|
2860
|
+
...discovered,
|
|
2861
|
+
...config.manualModels.map((model) => model.id),
|
|
2862
|
+
...Object.keys(config.modelOverrides)
|
|
2863
|
+
])], config, opts?.unfiltered === true).map((id) => {
|
|
2826
2864
|
const model = effectiveModel(id, config);
|
|
2827
2865
|
return {
|
|
2828
2866
|
provider,
|
|
@@ -3929,13 +3967,13 @@ function header(request, name) {
|
|
|
3929
3967
|
const value = request.headers?.[name];
|
|
3930
3968
|
return Array.isArray(value) ? value[0] : value;
|
|
3931
3969
|
}
|
|
3932
|
-
function isLoopback(value) {
|
|
3970
|
+
function isLoopback$1(value) {
|
|
3933
3971
|
const address = value?.toLowerCase().replace(/^\[|\]$/g, "");
|
|
3934
3972
|
return address === "localhost" || address === "localhost." || address === "::1" || address?.startsWith("127.") === true || address?.startsWith("::ffff:127.") === true;
|
|
3935
3973
|
}
|
|
3936
3974
|
function isTrustedUpdateRequest(request) {
|
|
3937
3975
|
if (header(request, UPDATE_HEADER) !== "1") return false;
|
|
3938
|
-
if (!isLoopback(request.socket?.remoteAddress)) return false;
|
|
3976
|
+
if (!isLoopback$1(request.socket?.remoteAddress)) return false;
|
|
3939
3977
|
const site = header(request, "sec-fetch-site");
|
|
3940
3978
|
if (site !== void 0 && site !== "same-origin") return false;
|
|
3941
3979
|
const origin = header(request, "origin");
|
|
@@ -3943,7 +3981,7 @@ function isTrustedUpdateRequest(request) {
|
|
|
3943
3981
|
if (origin === void 0 || host === void 0) return false;
|
|
3944
3982
|
try {
|
|
3945
3983
|
const url = new URL(origin);
|
|
3946
|
-
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;
|
|
3947
3985
|
} catch {
|
|
3948
3986
|
return false;
|
|
3949
3987
|
}
|
|
@@ -4508,6 +4546,86 @@ async function readModelAnalytics(days = 30, priceOverrides = {}) {
|
|
|
4508
4546
|
});
|
|
4509
4547
|
return report;
|
|
4510
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
|
+
}
|
|
4511
4629
|
// src/routes-public.ts
|
|
4512
4630
|
function publicConfig(config) {
|
|
4513
4631
|
return {
|
|
@@ -4525,6 +4643,7 @@ function publicConfig(config) {
|
|
|
4525
4643
|
showAllModels: config.showAllModels,
|
|
4526
4644
|
modelVisibility: config.modelVisibility,
|
|
4527
4645
|
manualModels: config.manualModels,
|
|
4646
|
+
modelOverrides: config.modelOverrides,
|
|
4528
4647
|
modelOrder: config.modelOrder,
|
|
4529
4648
|
filterModelsByPlan: config.filterModelsByPlan,
|
|
4530
4649
|
contextWindow: config.contextWindow ?? null,
|
|
@@ -4668,6 +4787,27 @@ function cleanManualModels(value) {
|
|
|
4668
4787
|
}
|
|
4669
4788
|
return out;
|
|
4670
4789
|
}
|
|
4790
|
+
function cleanModelOverrides(value) {
|
|
4791
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
|
|
4792
|
+
const out = {};
|
|
4793
|
+
for (const [id, entry] of Object.entries(value)) {
|
|
4794
|
+
if (id === "" || id.includes("..") || typeof entry !== "object" || entry === null || Array.isArray(entry)) continue;
|
|
4795
|
+
const record = entry;
|
|
4796
|
+
const efforts = Array.isArray(record.reasoningEfforts) ? record.reasoningEfforts.filter((item) => typeof item === "string" && item.trim() !== "") : void 0;
|
|
4797
|
+
const thinking = typeof record.thinking === "boolean" ? record.thinking : void 0;
|
|
4798
|
+
const normalizedEfforts = thinking === true && (efforts === void 0 || efforts.length === 0) ? ["off", "high"] : thinking === false ? [] : efforts;
|
|
4799
|
+
const outEntry = {
|
|
4800
|
+
...typeof record.contextWindow === "number" && Number.isInteger(record.contextWindow) && record.contextWindow > 0 ? { contextWindow: record.contextWindow } : {},
|
|
4801
|
+
...typeof record.image === "boolean" ? { image: record.image } : {},
|
|
4802
|
+
...thinking === void 0 ? {} : { thinking },
|
|
4803
|
+
...normalizedEfforts === void 0 ? {} : { reasoningEfforts: normalizedEfforts },
|
|
4804
|
+
...typeof record.defaultEffort === "string" && record.defaultEffort.trim() !== "" ? { defaultEffort: record.defaultEffort.trim() } : {},
|
|
4805
|
+
...typeof record.enabled === "boolean" ? { enabled: record.enabled } : {}
|
|
4806
|
+
};
|
|
4807
|
+
if (Object.keys(outEntry).length > 0) out[id] = outEntry;
|
|
4808
|
+
}
|
|
4809
|
+
return out;
|
|
4810
|
+
}
|
|
4671
4811
|
function cleanBooleanRecord(value) {
|
|
4672
4812
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
|
|
4673
4813
|
const out = {};
|
|
@@ -4895,6 +5035,7 @@ function configOps(patch) {
|
|
|
4895
5035
|
if ("modelVisibility" in patch) set("modelVisibility", cleanBooleanRecord(patch.modelVisibility));
|
|
4896
5036
|
if ("manualModels" in patch) set("manualModels", cleanManualModels(patch.manualModels));
|
|
4897
5037
|
if ("modelOrder" in patch) set("modelOrder", cleanStringArray(patch.modelOrder));
|
|
5038
|
+
if ("modelOverrides" in patch) set("modelOverrides", cleanModelOverrides(patch.modelOverrides));
|
|
4898
5039
|
if ("filterModelsByPlan" in patch) set("filterModelsByPlan", patch.filterModelsByPlan === true);
|
|
4899
5040
|
if ("contextWindow" in patch) set("contextWindow", patch.contextWindow);
|
|
4900
5041
|
if ("contextWindowOverrides" in patch) set("contextWindowOverrides", cleanNumberRecord(patch.contextWindowOverrides));
|
|
@@ -5290,8 +5431,10 @@ function applyRoutes(ctx, web, deps) {
|
|
|
5290
5431
|
res.write(`${JSON.stringify(value)}\n`);
|
|
5291
5432
|
};
|
|
5292
5433
|
try {
|
|
5434
|
+
const last = await pullLocalModel(config, model, write, deps.localFetch);
|
|
5435
|
+
clearModelProbeCache(config.apiBase);
|
|
5293
5436
|
write({
|
|
5294
|
-
status:
|
|
5437
|
+
status: last.status,
|
|
5295
5438
|
done: true
|
|
5296
5439
|
});
|
|
5297
5440
|
} catch (error) {
|
|
@@ -5320,6 +5463,7 @@ function applyRoutes(ctx, web, deps) {
|
|
|
5320
5463
|
const model = typeof body.model === "string" ? body.model : "";
|
|
5321
5464
|
try {
|
|
5322
5465
|
await removeLocalModel(config, model, deps.localFetch);
|
|
5466
|
+
clearModelProbeCache(config.apiBase);
|
|
5323
5467
|
json(res, 200, {
|
|
5324
5468
|
ok: true,
|
|
5325
5469
|
model
|
|
@@ -5328,6 +5472,23 @@ function applyRoutes(ctx, web, deps) {
|
|
|
5328
5472
|
json(res, 502, { error: error instanceof Error ? error.message : "remove failed" });
|
|
5329
5473
|
}
|
|
5330
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
|
+
});
|
|
5331
5492
|
route("/dsh-ollama/test", async (req, res) => {
|
|
5332
5493
|
if (!await requirePost(req, res, verifyHost)) return;
|
|
5333
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"
|