@goodandready/dsh-ollama-cloud-provider 0.1.26 → 0.1.29
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 +21 -0
- package/README.md +4 -20
- package/README.ru.md +4 -4
- package/README.zh.md +4 -4
- package/lib/client.js +120 -363
- package/lib/index.d.ts +8 -19
- package/lib/index.js +93 -584
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -40,6 +40,7 @@ window.__ModuleLoader__.load({
|
|
|
40
40
|
quotaCardName: "Ollama Cloud",
|
|
41
41
|
noUsage: "No quota data",
|
|
42
42
|
usageError: "Quota unavailable",
|
|
43
|
+
lastGoodUsage: "Showing the last good usage snapshot.",
|
|
43
44
|
quotaHint: "Balance and usage come from the official /api/balance and /api/usage endpoints. Spend is metered in dollars, not requests.",
|
|
44
45
|
quotaExhausted: "Included credits are nearly exhausted.",
|
|
45
46
|
quotaWarning: "More than 80% of the included credits are used.",
|
|
@@ -132,7 +133,7 @@ window.__ModuleLoader__.load({
|
|
|
132
133
|
discoverHint: "Probe an unsaved endpoint and show its catalog without changing current settings.",
|
|
133
134
|
endpoint: "Endpoint",
|
|
134
135
|
oneShotKey: "One-shot API key",
|
|
135
|
-
oneShotKeyPlaceholder: "optional
|
|
136
|
+
oneShotKeyPlaceholder: "optional",
|
|
136
137
|
oneShotKeyHint: "Used only for this request; never stored, saved or logged.",
|
|
137
138
|
discovering: "Discovering…",
|
|
138
139
|
discoverAction: "Discover models",
|
|
@@ -150,6 +151,8 @@ window.__ModuleLoader__.load({
|
|
|
150
151
|
reasoningEfforts: "Reasoning efforts",
|
|
151
152
|
manualEffortsHint: "Comma-separated levels, e.g. off, low, medium, high.",
|
|
152
153
|
defaultReasoning: "Default effort",
|
|
154
|
+
noKey: "No API key",
|
|
155
|
+
providerCardHint: "Native provider card on the Models page. Open the Ollama Cloud settings section for full configuration.",
|
|
153
156
|
enabled: "Enabled",
|
|
154
157
|
edit: "Edit",
|
|
155
158
|
overrideEditor: "Model overrides",
|
|
@@ -180,26 +183,6 @@ window.__ModuleLoader__.load({
|
|
|
180
183
|
autoRefresh: "Refresh model catalog automatically",
|
|
181
184
|
refreshMinutes: "Refresh interval (minutes)",
|
|
182
185
|
autoRefreshHint: "Mount refresh plus this interval; 0 keeps the mount refresh only.",
|
|
183
|
-
localModels: "Local Ollama models",
|
|
184
|
-
localModelsHint: "List, inspect, pull and remove models on the configured local endpoint. Remove always asks for confirmation.",
|
|
185
|
-
localDisk: "Disk",
|
|
186
|
-
localRunning: "Running",
|
|
187
|
-
localPullPlaceholder: "model name, for example llama3.2",
|
|
188
|
-
localPull: "Pull",
|
|
189
|
-
localPulling: "Pulling…",
|
|
190
|
-
localRefresh: "Reload",
|
|
191
|
-
localNoModels: "No local models.",
|
|
192
|
-
localRunningBadge: "running",
|
|
193
|
-
localShow: "Details",
|
|
194
|
-
localRemove: "Remove",
|
|
195
|
-
localConfirmRemove: "Confirm remove",
|
|
196
|
-
localCancel: "Cancel",
|
|
197
|
-
localModified: "Modified",
|
|
198
|
-
localCapabilities: "Capabilities",
|
|
199
|
-
localPullFailed: "Pull failed",
|
|
200
|
-
localRemoveDone: "removed",
|
|
201
|
-
localRemoveFailed: "Remove failed",
|
|
202
|
-
localShowFailed: "Details unavailable",
|
|
203
186
|
sidebar: "Sidebar",
|
|
204
187
|
serviceStatus: "Service status",
|
|
205
188
|
serviceStatusHint: "Checks the public Ollama Cloud tag endpoint without using your key or quota.",
|
|
@@ -291,6 +274,7 @@ window.__ModuleLoader__.load({
|
|
|
291
274
|
quotaCardName: "Ollama Cloud",
|
|
292
275
|
noUsage: "没有配额数据",
|
|
293
276
|
usageError: "配额不可用",
|
|
277
|
+
lastGoodUsage: "正在显示上次可用的用量快照。",
|
|
294
278
|
quotaHint: "余额和用量来自官方 /api/balance 与 /api/usage。费用按美元计量,而不是按请求数。",
|
|
295
279
|
quotaExhausted: "包含额度即将用完。",
|
|
296
280
|
quotaWarning: "已使用超过 80% 的包含额度。",
|
|
@@ -401,6 +385,8 @@ window.__ModuleLoader__.load({
|
|
|
401
385
|
reasoningEfforts: "推理档位",
|
|
402
386
|
manualEffortsHint: "逗号分隔,例如 off, low, medium, high。",
|
|
403
387
|
defaultReasoning: "默认档位",
|
|
388
|
+
noKey: "无 API 密钥",
|
|
389
|
+
providerCardHint: "模型页面上的原生提供方卡片。完整配置请打开 Ollama Cloud 设置部分。",
|
|
404
390
|
enabled: "启用",
|
|
405
391
|
edit: "编辑",
|
|
406
392
|
overrideEditor: "模型覆盖",
|
|
@@ -431,26 +417,6 @@ window.__ModuleLoader__.load({
|
|
|
431
417
|
autoRefresh: "自动刷新模型目录",
|
|
432
418
|
refreshMinutes: "刷新间隔(分钟)",
|
|
433
419
|
autoRefreshHint: "启动时刷新,并按此间隔刷新;0 仅启动时刷新。",
|
|
434
|
-
localModels: "本地 Ollama 模型",
|
|
435
|
-
localModelsHint: "列出、查看、拉取和删除已配置本地端点上的模型。删除始终需要确认。",
|
|
436
|
-
localDisk: "磁盘",
|
|
437
|
-
localRunning: "运行中",
|
|
438
|
-
localPullPlaceholder: "模型名称,例如 llama3.2",
|
|
439
|
-
localPull: "拉取",
|
|
440
|
-
localPulling: "拉取中…",
|
|
441
|
-
localRefresh: "重新加载",
|
|
442
|
-
localNoModels: "没有本地模型。",
|
|
443
|
-
localRunningBadge: "运行中",
|
|
444
|
-
localShow: "详情",
|
|
445
|
-
localRemove: "删除",
|
|
446
|
-
localConfirmRemove: "确认删除",
|
|
447
|
-
localCancel: "取消",
|
|
448
|
-
localModified: "修改时间",
|
|
449
|
-
localCapabilities: "能力",
|
|
450
|
-
localPullFailed: "拉取失败",
|
|
451
|
-
localRemoveDone: "已删除",
|
|
452
|
-
localRemoveFailed: "删除失败",
|
|
453
|
-
localShowFailed: "详情不可用",
|
|
454
420
|
sidebar: "侧边栏",
|
|
455
421
|
serviceStatus: "服务状态",
|
|
456
422
|
serviceStatusHint: "检查 Ollama Cloud 公共 tag 端点,不使用密钥或额度。",
|
|
@@ -620,80 +586,6 @@ window.__ModuleLoader__.load({
|
|
|
620
586
|
})
|
|
621
587
|
});
|
|
622
588
|
}
|
|
623
|
-
function fetchLocalModels() {
|
|
624
|
-
return call("/dsh-ollama/local/models");
|
|
625
|
-
}
|
|
626
|
-
function fetchLocalShow(model) {
|
|
627
|
-
return call(`/dsh-ollama/local/show?model=${encodeURIComponent(model)}`);
|
|
628
|
-
}
|
|
629
|
-
async function pullLocalModel(model, onProgress) {
|
|
630
|
-
const response = await fetch("/dsh-ollama/local/pull", {
|
|
631
|
-
method: "POST",
|
|
632
|
-
credentials: "same-origin",
|
|
633
|
-
headers: {
|
|
634
|
-
accept: "application/x-ndjson",
|
|
635
|
-
"content-type": "application/json"
|
|
636
|
-
},
|
|
637
|
-
body: JSON.stringify({ model })
|
|
638
|
-
});
|
|
639
|
-
if (!response.ok) {
|
|
640
|
-
const body = await response.json().catch(() => ({}));
|
|
641
|
-
throw new Error(body.error ?? `HTTP ${response.status}`);
|
|
642
|
-
}
|
|
643
|
-
if (response.body === null) throw new Error("empty pull stream");
|
|
644
|
-
const reader = response.body.getReader();
|
|
645
|
-
const decoder = new TextDecoder();
|
|
646
|
-
let buffer = "";
|
|
647
|
-
let last = { status: "starting" };
|
|
648
|
-
const consume = (line) => {
|
|
649
|
-
if (line.trim() === "") return;
|
|
650
|
-
let event;
|
|
651
|
-
try {
|
|
652
|
-
event = JSON.parse(line);
|
|
653
|
-
} catch {
|
|
654
|
-
return;
|
|
655
|
-
}
|
|
656
|
-
if (typeof event.error === "string" && event.error !== "") throw new Error(event.error);
|
|
657
|
-
if (typeof event.status === "string") last = event;
|
|
658
|
-
onProgress(event);
|
|
659
|
-
};
|
|
660
|
-
for (;;) {
|
|
661
|
-
const { done, value } = await reader.read();
|
|
662
|
-
buffer += decoder.decode(value, { stream: !done });
|
|
663
|
-
const lines = buffer.split("\n");
|
|
664
|
-
buffer = lines.pop() ?? "";
|
|
665
|
-
for (const line of lines) consume(line);
|
|
666
|
-
if (done) break;
|
|
667
|
-
}
|
|
668
|
-
if (buffer.trim() !== "") consume(buffer);
|
|
669
|
-
return last;
|
|
670
|
-
}
|
|
671
|
-
function removeLocalModel(model) {
|
|
672
|
-
return call("/dsh-ollama/local/remove", {
|
|
673
|
-
method: "POST",
|
|
674
|
-
body: JSON.stringify({
|
|
675
|
-
model,
|
|
676
|
-
confirm: true
|
|
677
|
-
})
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
function formatBytes(bytes) {
|
|
681
|
-
if (!Number.isFinite(bytes) || bytes <= 0) return "0 B";
|
|
682
|
-
const units = [
|
|
683
|
-
"B",
|
|
684
|
-
"KB",
|
|
685
|
-
"MB",
|
|
686
|
-
"GB",
|
|
687
|
-
"TB"
|
|
688
|
-
];
|
|
689
|
-
let value = bytes;
|
|
690
|
-
let index = 0;
|
|
691
|
-
while (value >= 1024 && index < units.length - 1) {
|
|
692
|
-
value /= 1024;
|
|
693
|
-
index += 1;
|
|
694
|
-
}
|
|
695
|
-
return `${value >= 10 || index === 0 ? value.toFixed(0) : value.toFixed(1)} ${units[index]}`;
|
|
696
|
-
}
|
|
697
589
|
function saveConfig(patch) {
|
|
698
590
|
return call("/dsh-ollama/config", {
|
|
699
591
|
method: "POST",
|
|
@@ -1377,7 +1269,7 @@ window.__ModuleLoader__.load({
|
|
|
1377
1269
|
const worst = worstUsedPercent(report);
|
|
1378
1270
|
const plan = state?.config.planLabel?.trim() ?? "";
|
|
1379
1271
|
const name = plan === "" ? t("quotaCardName") : `${t("quotaCardName")} · ${plan}`;
|
|
1380
|
-
const detail = bars.map((entry) => `${entry.labelKey === void 0 ? entry.label : t(entry.labelKey)}: ${entry.remainingPercent.toFixed(0)}% ${t("remaining")}`).join(" · ");
|
|
1272
|
+
const detail = bars.map((entry) => `${entry.labelKey === void 0 ? entry.label : t(entry.labelKey)}: ${entry.remainingPercent.toFixed(0)}% ${t("remaining")}`).join(" · ") + (state?.usage?.stale === true ? ` · ${t("lastGoodUsage")}` : "");
|
|
1381
1273
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1382
1274
|
type: "button",
|
|
1383
1275
|
className: "ocl-foot",
|
|
@@ -1460,6 +1352,7 @@ window.__ModuleLoader__.load({
|
|
|
1460
1352
|
const bars = quotaBars(activeReport);
|
|
1461
1353
|
const rows = windowRows(activeReport);
|
|
1462
1354
|
const activeAccount = state?.accounts.find((account) => account.active);
|
|
1355
|
+
const stale = usage?.stale === true || state?.usage?.stale === true;
|
|
1463
1356
|
const refresh = () => {
|
|
1464
1357
|
setBusy(true);
|
|
1465
1358
|
refreshState().then(() => load()).finally(() => setBusy(false));
|
|
@@ -1551,6 +1444,10 @@ window.__ModuleLoader__.load({
|
|
|
1551
1444
|
usage.error
|
|
1552
1445
|
]
|
|
1553
1446
|
}),
|
|
1447
|
+
stale ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1448
|
+
className: "ocl-notice",
|
|
1449
|
+
children: t("lastGoodUsage")
|
|
1450
|
+
}) : null,
|
|
1554
1451
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UsageBars, {
|
|
1555
1452
|
bars,
|
|
1556
1453
|
t
|
|
@@ -1911,246 +1808,6 @@ window.__ModuleLoader__.load({
|
|
|
1911
1808
|
function mergeLoadedDraft(current, next, preserve) {
|
|
1912
1809
|
return preserve && current !== null ? current : next;
|
|
1913
1810
|
}
|
|
1914
|
-
// src/client/local-models-card.tsx
|
|
1915
|
-
function isLocalConfig(config) {
|
|
1916
|
-
if (config.apiKeyEnv === "") return true;
|
|
1917
|
-
try {
|
|
1918
|
-
const host = new URL(config.apiBase).hostname;
|
|
1919
|
-
return host === "127.0.0.1" || host === "localhost" || host === "::1" || host === "[::1]";
|
|
1920
|
-
} catch {
|
|
1921
|
-
return false;
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1924
|
-
function LocalModelsCard(props) {
|
|
1925
|
-
const { t, config, onChanged } = props;
|
|
1926
|
-
const [inventory, setInventory] = (0, react.useState)(null);
|
|
1927
|
-
const [details, setDetails] = (0, react.useState)(null);
|
|
1928
|
-
const [error, setError] = (0, react.useState)(null);
|
|
1929
|
-
const [notice, setNotice] = (0, react.useState)(null);
|
|
1930
|
-
const [pullName, setPullName] = (0, react.useState)("");
|
|
1931
|
-
const [pulling, setPulling] = (0, react.useState)(false);
|
|
1932
|
-
const [progress, setProgress] = (0, react.useState)(null);
|
|
1933
|
-
const [confirmRemove, setConfirmRemove] = (0, react.useState)(null);
|
|
1934
|
-
const local = isLocalConfig(config);
|
|
1935
|
-
const load = (0, react.useCallback)(async () => {
|
|
1936
|
-
if (!local) return;
|
|
1937
|
-
try {
|
|
1938
|
-
setInventory(await fetchLocalModels());
|
|
1939
|
-
setError(null);
|
|
1940
|
-
} catch (cause) {
|
|
1941
|
-
setError(cause instanceof Error ? cause.message : "local models failed");
|
|
1942
|
-
}
|
|
1943
|
-
}, [local]);
|
|
1944
|
-
(0, react.useEffect)(() => {
|
|
1945
|
-
load();
|
|
1946
|
-
}, [
|
|
1947
|
-
load,
|
|
1948
|
-
config.apiKeyEnv,
|
|
1949
|
-
config.apiBase
|
|
1950
|
-
]);
|
|
1951
|
-
if (!local) return null;
|
|
1952
|
-
const pull = async () => {
|
|
1953
|
-
const model = pullName.trim();
|
|
1954
|
-
if (model === "" || pulling) return;
|
|
1955
|
-
setPulling(true);
|
|
1956
|
-
setError(null);
|
|
1957
|
-
setNotice(null);
|
|
1958
|
-
setProgress({ status: "starting" });
|
|
1959
|
-
try {
|
|
1960
|
-
const last = await pullLocalModel(model, setProgress);
|
|
1961
|
-
setNotice(`${model}: ${last.status}`);
|
|
1962
|
-
setPullName("");
|
|
1963
|
-
await load();
|
|
1964
|
-
onChanged?.();
|
|
1965
|
-
} catch (cause) {
|
|
1966
|
-
setError(cause instanceof Error ? cause.message : t("localPullFailed"));
|
|
1967
|
-
} finally {
|
|
1968
|
-
setPulling(false);
|
|
1969
|
-
setProgress(null);
|
|
1970
|
-
}
|
|
1971
|
-
};
|
|
1972
|
-
const remove = async (model) => {
|
|
1973
|
-
setError(null);
|
|
1974
|
-
setNotice(null);
|
|
1975
|
-
try {
|
|
1976
|
-
await removeLocalModel(model);
|
|
1977
|
-
setConfirmRemove(null);
|
|
1978
|
-
setDetails((current) => current?.name === model ? null : current);
|
|
1979
|
-
setNotice(`${model}: ${t("localRemoveDone")}`);
|
|
1980
|
-
await load();
|
|
1981
|
-
onChanged?.();
|
|
1982
|
-
} catch (cause) {
|
|
1983
|
-
setError(cause instanceof Error ? cause.message : t("localRemoveFailed"));
|
|
1984
|
-
}
|
|
1985
|
-
};
|
|
1986
|
-
const show = async (model) => {
|
|
1987
|
-
setError(null);
|
|
1988
|
-
try {
|
|
1989
|
-
setDetails(await fetchLocalShow(model));
|
|
1990
|
-
} catch (cause) {
|
|
1991
|
-
setError(cause instanceof Error ? cause.message : t("localShowFailed"));
|
|
1992
|
-
}
|
|
1993
|
-
};
|
|
1994
|
-
const running = new Set(inventory?.running.map((entry) => entry.name) ?? []);
|
|
1995
|
-
const percent = progress?.total !== void 0 && progress.total > 0 ? Math.min(100, Math.round((progress.completed ?? 0) / progress.total * 100)) : null;
|
|
1996
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1997
|
-
className: "ocl-card",
|
|
1998
|
-
children: [
|
|
1999
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
2000
|
-
className: "ocl-card-title",
|
|
2001
|
-
children: t("localModels")
|
|
2002
|
-
}),
|
|
2003
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2004
|
-
className: "ocl-hint",
|
|
2005
|
-
children: t("localModelsHint")
|
|
2006
|
-
}),
|
|
2007
|
-
inventory !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
2008
|
-
className: "ocl-hint",
|
|
2009
|
-
children: [
|
|
2010
|
-
t("localDisk"),
|
|
2011
|
-
": ",
|
|
2012
|
-
formatBytes(inventory.diskBytes),
|
|
2013
|
-
" · ",
|
|
2014
|
-
t("localRunning"),
|
|
2015
|
-
": ",
|
|
2016
|
-
formatBytes(inventory.runningBytes)
|
|
2017
|
-
]
|
|
2018
|
-
}),
|
|
2019
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2020
|
-
className: "ocl-row",
|
|
2021
|
-
children: [
|
|
2022
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2023
|
-
className: "ocl-input",
|
|
2024
|
-
value: pullName,
|
|
2025
|
-
placeholder: t("localPullPlaceholder"),
|
|
2026
|
-
onChange: (event) => setPullName(event.target.value),
|
|
2027
|
-
onKeyDown: (event) => {
|
|
2028
|
-
if (event.key === "Enter") {
|
|
2029
|
-
event.preventDefault();
|
|
2030
|
-
pull();
|
|
2031
|
-
}
|
|
2032
|
-
}
|
|
2033
|
-
}),
|
|
2034
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2035
|
-
type: "button",
|
|
2036
|
-
className: "ocl-button",
|
|
2037
|
-
disabled: pulling || pullName.trim() === "",
|
|
2038
|
-
onClick: () => {
|
|
2039
|
-
pull();
|
|
2040
|
-
},
|
|
2041
|
-
children: pulling ? t("localPulling") : t("localPull")
|
|
2042
|
-
}),
|
|
2043
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2044
|
-
type: "button",
|
|
2045
|
-
className: "ocl-button",
|
|
2046
|
-
onClick: () => {
|
|
2047
|
-
load();
|
|
2048
|
-
},
|
|
2049
|
-
children: t("localRefresh")
|
|
2050
|
-
})
|
|
2051
|
-
]
|
|
2052
|
-
}),
|
|
2053
|
-
progress !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2054
|
-
className: "ocl-row",
|
|
2055
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2056
|
-
className: "ocl-hint",
|
|
2057
|
-
children: percent === null ? progress.status : `${progress.status} · ${percent}%`
|
|
2058
|
-
})
|
|
2059
|
-
}),
|
|
2060
|
-
notice !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2061
|
-
className: "ocl-notice",
|
|
2062
|
-
children: notice
|
|
2063
|
-
}),
|
|
2064
|
-
error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2065
|
-
className: "ocl-error",
|
|
2066
|
-
children: error
|
|
2067
|
-
}),
|
|
2068
|
-
inventory !== null && inventory.models.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2069
|
-
className: "ocl-hint",
|
|
2070
|
-
children: t("localNoModels")
|
|
2071
|
-
}),
|
|
2072
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2073
|
-
className: "ocl-models",
|
|
2074
|
-
children: (inventory?.models ?? []).map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2075
|
-
className: "ocl-model",
|
|
2076
|
-
children: [
|
|
2077
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2078
|
-
className: "ocl-model-name",
|
|
2079
|
-
children: model.name
|
|
2080
|
-
}),
|
|
2081
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2082
|
-
className: "ocl-badge",
|
|
2083
|
-
children: formatBytes(model.size)
|
|
2084
|
-
}),
|
|
2085
|
-
running.has(model.name) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2086
|
-
className: "ocl-badge ocl-badge-ok",
|
|
2087
|
-
children: t("localRunningBadge")
|
|
2088
|
-
}),
|
|
2089
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2090
|
-
type: "button",
|
|
2091
|
-
className: "ocl-button",
|
|
2092
|
-
onClick: () => {
|
|
2093
|
-
show(model.name);
|
|
2094
|
-
},
|
|
2095
|
-
children: t("localShow")
|
|
2096
|
-
}),
|
|
2097
|
-
confirmRemove === model.name ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2098
|
-
type: "button",
|
|
2099
|
-
className: "ocl-button ocl-button-danger",
|
|
2100
|
-
onClick: () => {
|
|
2101
|
-
remove(model.name);
|
|
2102
|
-
},
|
|
2103
|
-
children: t("localConfirmRemove")
|
|
2104
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2105
|
-
type: "button",
|
|
2106
|
-
className: "ocl-button",
|
|
2107
|
-
onClick: () => setConfirmRemove(null),
|
|
2108
|
-
children: t("localCancel")
|
|
2109
|
-
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2110
|
-
type: "button",
|
|
2111
|
-
className: "ocl-button ocl-button-danger",
|
|
2112
|
-
onClick: () => setConfirmRemove(model.name),
|
|
2113
|
-
children: t("localRemove")
|
|
2114
|
-
})
|
|
2115
|
-
]
|
|
2116
|
-
}, model.name))
|
|
2117
|
-
}),
|
|
2118
|
-
details !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2119
|
-
className: "ocl-model-section",
|
|
2120
|
-
children: [
|
|
2121
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2122
|
-
className: "ocl-model-section-head",
|
|
2123
|
-
children: details.name
|
|
2124
|
-
}),
|
|
2125
|
-
details.modifiedAt !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
2126
|
-
className: "ocl-hint",
|
|
2127
|
-
children: [
|
|
2128
|
-
t("localModified"),
|
|
2129
|
-
": ",
|
|
2130
|
-
details.modifiedAt
|
|
2131
|
-
]
|
|
2132
|
-
}),
|
|
2133
|
-
details.details !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2134
|
-
className: "ocl-hint",
|
|
2135
|
-
children: [
|
|
2136
|
-
details.details.family,
|
|
2137
|
-
details.details.parameterSize,
|
|
2138
|
-
details.details.quantization
|
|
2139
|
-
].filter((entry) => entry !== void 0).join(" · ")
|
|
2140
|
-
}),
|
|
2141
|
-
details.capabilities.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
2142
|
-
className: "ocl-hint",
|
|
2143
|
-
children: [
|
|
2144
|
-
t("localCapabilities"),
|
|
2145
|
-
": ",
|
|
2146
|
-
details.capabilities.join(", ")
|
|
2147
|
-
]
|
|
2148
|
-
})
|
|
2149
|
-
]
|
|
2150
|
-
})
|
|
2151
|
-
]
|
|
2152
|
-
});
|
|
2153
|
-
}
|
|
2154
1811
|
// src/client/model-groups.ts
|
|
2155
1812
|
function formatContext(value) {
|
|
2156
1813
|
if (value >= 1e6) return `${(value / 1e6).toFixed(value % 1e6 === 0 ? 0 : 1)}M`;
|
|
@@ -3552,13 +3209,6 @@ window.__ModuleLoader__.load({
|
|
|
3552
3209
|
}, `${model.id}-${index}`))
|
|
3553
3210
|
]
|
|
3554
3211
|
}),
|
|
3555
|
-
state !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LocalModelsCard, {
|
|
3556
|
-
t,
|
|
3557
|
-
config: state.config,
|
|
3558
|
-
onChanged: () => {
|
|
3559
|
-
reloadModels();
|
|
3560
|
-
}
|
|
3561
|
-
}),
|
|
3562
3212
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3563
3213
|
className: "ocl-card",
|
|
3564
3214
|
children: [
|
|
@@ -3916,6 +3566,108 @@ window.__ModuleLoader__.load({
|
|
|
3916
3566
|
]
|
|
3917
3567
|
});
|
|
3918
3568
|
}
|
|
3569
|
+
// src/client/provider-card.tsx
|
|
3570
|
+
function OllamaProviderCardView(props) {
|
|
3571
|
+
const { t, state, error } = props;
|
|
3572
|
+
const report = state?.usage?.report;
|
|
3573
|
+
const bars = quotaBars(report);
|
|
3574
|
+
const worst = worstUsedPercent(report);
|
|
3575
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3576
|
+
className: "ocl-card",
|
|
3577
|
+
"data-ollama-provider-card": "true",
|
|
3578
|
+
children: [
|
|
3579
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3580
|
+
className: "ocl-row",
|
|
3581
|
+
children: [
|
|
3582
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "Ollama Cloud" }),
|
|
3583
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3584
|
+
className: "ocl-badge",
|
|
3585
|
+
children: "ollama-cloud"
|
|
3586
|
+
}),
|
|
3587
|
+
state === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3588
|
+
className: "ocl-badge ocl-badge-warn",
|
|
3589
|
+
children: t("loading")
|
|
3590
|
+
}) : state.key.configured ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3591
|
+
className: "ocl-badge ocl-badge-ok",
|
|
3592
|
+
children: t("keyConfigured")
|
|
3593
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3594
|
+
className: "ocl-badge ocl-badge-warn",
|
|
3595
|
+
children: t("noKey")
|
|
3596
|
+
})
|
|
3597
|
+
]
|
|
3598
|
+
}),
|
|
3599
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3600
|
+
className: "ocl-hint",
|
|
3601
|
+
children: t("providerCardHint")
|
|
3602
|
+
}),
|
|
3603
|
+
error !== void 0 && error !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3604
|
+
className: "ocl-error",
|
|
3605
|
+
children: error
|
|
3606
|
+
}) : null,
|
|
3607
|
+
state !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3608
|
+
className: "ocl-row",
|
|
3609
|
+
children: [
|
|
3610
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
3611
|
+
t("models"),
|
|
3612
|
+
": ",
|
|
3613
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: state.models.length })
|
|
3614
|
+
] }),
|
|
3615
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
3616
|
+
t("transport"),
|
|
3617
|
+
": ",
|
|
3618
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: state.config.transport })
|
|
3619
|
+
] }),
|
|
3620
|
+
bars.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
3621
|
+
t("quotaCardName"),
|
|
3622
|
+
": ",
|
|
3623
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("strong", { children: [worst.toFixed(0), "%"] })
|
|
3624
|
+
] })
|
|
3625
|
+
]
|
|
3626
|
+
}),
|
|
3627
|
+
state?.usage?.stale === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3628
|
+
className: "ocl-notice",
|
|
3629
|
+
children: t("lastGoodUsage")
|
|
3630
|
+
}) : null,
|
|
3631
|
+
bars.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3632
|
+
className: "ocl-models",
|
|
3633
|
+
children: bars.map((bar) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3634
|
+
className: "ocl-row",
|
|
3635
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3636
|
+
className: "ocl-model-name",
|
|
3637
|
+
children: bar.labelKey === void 0 ? bar.label : t(bar.labelKey)
|
|
3638
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3639
|
+
className: "ocl-badge",
|
|
3640
|
+
children: [
|
|
3641
|
+
bar.remainingPercent.toFixed(0),
|
|
3642
|
+
"% ",
|
|
3643
|
+
t("remaining")
|
|
3644
|
+
]
|
|
3645
|
+
})]
|
|
3646
|
+
}, bar.key))
|
|
3647
|
+
})
|
|
3648
|
+
]
|
|
3649
|
+
});
|
|
3650
|
+
}
|
|
3651
|
+
function OllamaProviderCard(props) {
|
|
3652
|
+
const [state, setState] = (0, react.useState)(null);
|
|
3653
|
+
const [error, setError] = (0, react.useState)(null);
|
|
3654
|
+
(0, react.useEffect)(() => {
|
|
3655
|
+
let active = true;
|
|
3656
|
+
fetchState().then((next) => {
|
|
3657
|
+
if (active) setState(next);
|
|
3658
|
+
}).catch((caught) => {
|
|
3659
|
+
if (active) setError(caught instanceof Error ? caught.message : props.t("failed"));
|
|
3660
|
+
});
|
|
3661
|
+
return () => {
|
|
3662
|
+
active = false;
|
|
3663
|
+
};
|
|
3664
|
+
}, [props.t]);
|
|
3665
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OllamaProviderCardView, {
|
|
3666
|
+
t: props.t,
|
|
3667
|
+
state,
|
|
3668
|
+
error
|
|
3669
|
+
});
|
|
3670
|
+
}
|
|
3919
3671
|
// src/client/styles.ts
|
|
3920
3672
|
const CSS_ID = "dsh-ollama-cloud-provider";
|
|
3921
3673
|
const CSS = `
|
|
@@ -4074,6 +3826,11 @@ window.__ModuleLoader__.load({
|
|
|
4074
3826
|
label: () => t("nav"),
|
|
4075
3827
|
locale: NS
|
|
4076
3828
|
}, OllamaCloudSettingsPage));
|
|
3829
|
+
ctx.slots.inject("settings.models.provider-card", () => slots.register({
|
|
3830
|
+
name: "settings.models.provider-card",
|
|
3831
|
+
key: "ollama-cloud",
|
|
3832
|
+
locale: NS
|
|
3833
|
+
}, OllamaProviderCard));
|
|
4077
3834
|
ctx.slots.inject("main", () => slots.register({
|
|
4078
3835
|
name: "main",
|
|
4079
3836
|
key: "ollama-panel",
|
package/lib/index.d.ts
CHANGED
|
@@ -345,16 +345,23 @@ interface UsageReport {
|
|
|
345
345
|
d24?: UsageTotals;
|
|
346
346
|
d7?: UsageTotals;
|
|
347
347
|
d30?: UsageTotals;
|
|
348
|
+
session?: UsageTotals;
|
|
349
|
+
weekly?: UsageTotals;
|
|
350
|
+
monthly?: UsageTotals;
|
|
348
351
|
};
|
|
349
352
|
byModel: Array<{
|
|
350
353
|
model: string;
|
|
351
354
|
} & UsageTotals>;
|
|
355
|
+
byWindow?: Partial<Record<UsageRange, Array<{
|
|
356
|
+
model: string;
|
|
357
|
+
} & UsageTotals>>>;
|
|
352
358
|
range: UsageRange;
|
|
353
359
|
}
|
|
354
360
|
interface UsageResult {
|
|
355
361
|
report?: UsageReport;
|
|
356
362
|
error?: string;
|
|
357
363
|
checkedAt: number;
|
|
364
|
+
stale?: boolean;
|
|
358
365
|
}
|
|
359
366
|
interface UsageReader {
|
|
360
367
|
/** Balance plus the 7-day spend window for one key. */
|
|
@@ -469,8 +476,6 @@ interface RouteDeps {
|
|
|
469
476
|
readonly verifyDesktop?: (req: IncomingMessage) => Promise<boolean>;
|
|
470
477
|
/** Same verifier for private reads; falls back to `verifyDesktop`. */
|
|
471
478
|
readonly verifyHost?: (req: IncomingMessage) => Promise<boolean>;
|
|
472
|
-
/** Test seam for local Ollama inventory and mutation routes. */
|
|
473
|
-
readonly localFetch?: typeof fetch;
|
|
474
479
|
/** Test seam for unsaved-endpoint discovery. */
|
|
475
480
|
readonly discoveryFetch?: typeof fetch;
|
|
476
481
|
}
|
|
@@ -512,22 +517,6 @@ interface EffectiveModel extends OllamaCloudModelMeta {
|
|
|
512
517
|
}
|
|
513
518
|
declare function effectiveModel(id: string, config: ResolvedConfig): EffectiveModel;
|
|
514
519
|
declare function describeModel(meta: EffectiveModel, config: ResolvedConfig): string;
|
|
515
|
-
interface ModelProbe {
|
|
516
|
-
readonly contextWindow?: number;
|
|
517
|
-
readonly input: readonly ('text' | 'image')[];
|
|
518
|
-
readonly reasoning: readonly string[];
|
|
519
|
-
readonly reasoningToggle: boolean;
|
|
520
|
-
readonly tools: boolean;
|
|
521
|
-
readonly available: boolean;
|
|
522
|
-
}
|
|
523
|
-
declare function probeModel(config: ResolvedConfig, model: string, fetchImpl?: typeof fetch): Promise<ModelProbe | undefined>;
|
|
524
|
-
/** Clear all probe entries, or only entries for one endpoint. */
|
|
525
|
-
declare function clearModelProbeCache(baseURL?: string): void;
|
|
526
|
-
declare function modelProbeCacheInfo(): Array<{
|
|
527
|
-
baseURL: string;
|
|
528
|
-
model: string;
|
|
529
|
-
at: number;
|
|
530
|
-
}>;
|
|
531
520
|
declare const name = "llm-ollama-cloud";
|
|
532
521
|
declare const inject: string[];
|
|
533
522
|
/**
|
|
@@ -536,5 +525,5 @@ declare const inject: string[];
|
|
|
536
525
|
* without a restart.
|
|
537
526
|
*/
|
|
538
527
|
declare function apply(ctx: Context, config: Config): void;
|
|
539
|
-
export { type CommandDeps, Config, type Config as OllamaCloudConfig, OllamaCloudAdapter, type OllamaCloudAdapterDeps, PROVIDER, type ResolvedConfig, type ResolvedKey, type RouteDeps, type TransportId, type UsageReport, type UsageResult, type UsageWindow, apply, applyCommands, applyRoutes, classifyResponseError, clearCatalogCache,
|
|
528
|
+
export { type CommandDeps, Config, type Config as OllamaCloudConfig, OllamaCloudAdapter, type OllamaCloudAdapterDeps, PROVIDER, type ResolvedConfig, type ResolvedKey, type RouteDeps, type TransportId, type UsageReport, type UsageResult, type UsageWindow, apply, applyCommands, applyRoutes, classifyResponseError, clearCatalogCache, createKeyPool, createKeyResolver, createUsageReader, describeModel, effectiveModel, inject, name, normalizeBalance, normalizeUsage, resolveConfig };
|
|
540
529
|
//# sourceMappingURL=index.d.ts.map
|