@goodandready/dsh-ollama-cloud-provider 0.1.40 → 0.1.41
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 +15 -3
- package/README.md +64 -23
- package/README.ru.md +78 -18
- package/README.zh.md +86 -17
- package/lib/client.js +160 -97
- package/lib/config.js +2 -2
- package/lib/credentials.d.ts +1 -3
- package/lib/credentials.js +6 -6
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -4
- package/lib/quota-model.js +5 -6
- package/lib/routes-values.js +10 -96
- package/lib/routes.js +2 -1
- package/lib/transports/ndjson.js +2 -25
- package/lib/transports/sse.js +2 -25
- package/lib/transports/stream-reader.js +31 -0
- package/package.json +3 -3
package/lib/client.js
CHANGED
|
@@ -29,6 +29,7 @@ window.__ModuleLoader__.load({
|
|
|
29
29
|
save: "Save",
|
|
30
30
|
saving: "Saving…",
|
|
31
31
|
settingsReadOnly: "Settings are read-only in this host.",
|
|
32
|
+
editModel: "Edit model",
|
|
32
33
|
unsaved: "Unsaved changes",
|
|
33
34
|
discard: "Discard",
|
|
34
35
|
close: "Close",
|
|
@@ -56,6 +57,16 @@ window.__ModuleLoader__.load({
|
|
|
56
57
|
quotaWeekly: "Weekly window",
|
|
57
58
|
until: "until",
|
|
58
59
|
purchased: "Purchased",
|
|
60
|
+
now: "now",
|
|
61
|
+
minutesShort: "m",
|
|
62
|
+
hoursShort: "h",
|
|
63
|
+
daysShort: "d",
|
|
64
|
+
quotaWindow: "Quota window",
|
|
65
|
+
reason_rule: "rule",
|
|
66
|
+
reason_sticky: "sticky",
|
|
67
|
+
reason_pinned: "pinned",
|
|
68
|
+
reason_default: "default",
|
|
69
|
+
reason_rotation: "rotation",
|
|
59
70
|
range: "Range",
|
|
60
71
|
last24h: "Last 24 hours",
|
|
61
72
|
last7d: "Last 7 days",
|
|
@@ -277,6 +288,7 @@ window.__ModuleLoader__.load({
|
|
|
277
288
|
save: "保存",
|
|
278
289
|
saving: "保存中…",
|
|
279
290
|
settingsReadOnly: "当前宿主机的设置为只读。",
|
|
291
|
+
editModel: "编辑模型",
|
|
280
292
|
unsaved: "有未保存的更改",
|
|
281
293
|
discard: "放弃",
|
|
282
294
|
close: "关闭",
|
|
@@ -304,6 +316,16 @@ window.__ModuleLoader__.load({
|
|
|
304
316
|
quotaWeekly: "每周窗口",
|
|
305
317
|
until: "至",
|
|
306
318
|
purchased: "已购买",
|
|
319
|
+
now: "现在",
|
|
320
|
+
minutesShort: "分",
|
|
321
|
+
hoursShort: "小时",
|
|
322
|
+
daysShort: "天",
|
|
323
|
+
quotaWindow: "配额窗口",
|
|
324
|
+
reason_rule: "规则",
|
|
325
|
+
reason_sticky: "粘性会话",
|
|
326
|
+
reason_pinned: "固定账号",
|
|
327
|
+
reason_default: "默认",
|
|
328
|
+
reason_rotation: "轮换",
|
|
307
329
|
range: "范围",
|
|
308
330
|
last24h: "最近 24 小时",
|
|
309
331
|
last7d: "最近 7 天",
|
|
@@ -506,6 +528,46 @@ window.__ModuleLoader__.load({
|
|
|
506
528
|
latestVersion: "最新"
|
|
507
529
|
}
|
|
508
530
|
};
|
|
531
|
+
// src/client/format.ts
|
|
532
|
+
function relativeLabel(deltaMs, t) {
|
|
533
|
+
if (!Number.isFinite(deltaMs)) return t("now");
|
|
534
|
+
if (deltaMs <= 0) return t("now");
|
|
535
|
+
const minutes = Math.round(deltaMs / 6e4);
|
|
536
|
+
if (minutes < 60) return `${Math.max(1, minutes)}${t("minutesShort")}`;
|
|
537
|
+
const hours = Math.round(deltaMs / 36e5);
|
|
538
|
+
if (hours < 24) return `${hours}${t("hoursShort")}`;
|
|
539
|
+
return `${Math.round(deltaMs / 864e5)}${t("daysShort")}`;
|
|
540
|
+
}
|
|
541
|
+
function activeLocale() {
|
|
542
|
+
if (typeof document === "undefined") return void 0;
|
|
543
|
+
const lang = document.documentElement.getAttribute("lang") ?? "";
|
|
544
|
+
if (lang === "") return void 0;
|
|
545
|
+
try {
|
|
546
|
+
const normalized = lang.replace(/_/g, "-");
|
|
547
|
+
Intl.getCanonicalLocales(normalized);
|
|
548
|
+
return normalized;
|
|
549
|
+
} catch {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function formatTime(value) {
|
|
554
|
+
return new Date(value).toLocaleTimeString(activeLocale());
|
|
555
|
+
}
|
|
556
|
+
function formatDate(value) {
|
|
557
|
+
return new Date(value).toLocaleDateString(activeLocale());
|
|
558
|
+
}
|
|
559
|
+
function formatDateTime(value) {
|
|
560
|
+
return new Date(value).toLocaleString(activeLocale(), {
|
|
561
|
+
month: "2-digit",
|
|
562
|
+
day: "2-digit",
|
|
563
|
+
hour: "2-digit",
|
|
564
|
+
minute: "2-digit"
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function creditsDetail(values, t) {
|
|
568
|
+
const base = `${values.remaining.toFixed(2)} / ${values.allowance.toFixed(2)} ${t("remaining")}`;
|
|
569
|
+
return values.purchased > 0 ? `${base} · ${t("purchased")} ${values.purchased.toFixed(2)}` : base;
|
|
570
|
+
}
|
|
509
571
|
// src/quota-model.ts
|
|
510
572
|
function bar(key, label, usedPercent, extra = {}) {
|
|
511
573
|
const labelKey = key === "included" ? "quotaIncludedCredits" : key === "fiveHour" ? "quotaFiveHour" : key === "weekly" ? "quotaWeekly" : void 0;
|
|
@@ -534,8 +596,7 @@ window.__ModuleLoader__.load({
|
|
|
534
596
|
if (report === void 0) return [];
|
|
535
597
|
if (report.kind === "credits" && report.credits !== void 0) {
|
|
536
598
|
const credits = report.credits;
|
|
537
|
-
return [bar("included", "
|
|
538
|
-
detail: `$${credits.includedRemaining.toFixed(2)} of $${credits.includedAllowance.toFixed(2)} left` + (credits.purchased > 0 ? ` · $${credits.purchased.toFixed(2)} purchased` : ""),
|
|
599
|
+
return [bar("included", "", credits.includedAllowance > 0 ? (credits.includedAllowance - credits.includedRemaining) / credits.includedAllowance * 100 : 0, {
|
|
539
600
|
detailValues: {
|
|
540
601
|
remaining: credits.includedRemaining,
|
|
541
602
|
allowance: credits.includedAllowance,
|
|
@@ -544,7 +605,7 @@ window.__ModuleLoader__.load({
|
|
|
544
605
|
...credits.periodUntil === void 0 ? {} : { resetsAt: credits.periodUntil }
|
|
545
606
|
})];
|
|
546
607
|
}
|
|
547
|
-
return [legacyBar("fiveHour", "
|
|
608
|
+
return [legacyBar("fiveHour", "", report.legacy?.fiveHour), legacyBar("weekly", "", report.legacy?.weekly)].filter((entry) => entry !== void 0);
|
|
548
609
|
}
|
|
549
610
|
function worstUsedPercent(report) {
|
|
550
611
|
return quotaBars(report).reduce((worst, entry) => Math.max(worst, entry.usedPercent), 0);
|
|
@@ -554,19 +615,19 @@ window.__ModuleLoader__.load({
|
|
|
554
615
|
return [
|
|
555
616
|
report.windows.d24 === void 0 ? void 0 : {
|
|
556
617
|
key: "24h",
|
|
557
|
-
label: "
|
|
618
|
+
label: "",
|
|
558
619
|
labelKey: "last24h",
|
|
559
620
|
totals: report.windows.d24
|
|
560
621
|
},
|
|
561
622
|
report.windows.d7 === void 0 ? void 0 : {
|
|
562
623
|
key: "7d",
|
|
563
|
-
label: "
|
|
624
|
+
label: "",
|
|
564
625
|
labelKey: "last7d",
|
|
565
626
|
totals: report.windows.d7
|
|
566
627
|
},
|
|
567
628
|
report.windows.d30 === void 0 ? void 0 : {
|
|
568
629
|
key: "30d",
|
|
569
|
-
label: "
|
|
630
|
+
label: "",
|
|
570
631
|
labelKey: "last30d",
|
|
571
632
|
totals: report.windows.d30
|
|
572
633
|
}
|
|
@@ -902,18 +963,15 @@ window.__ModuleLoader__.load({
|
|
|
902
963
|
]
|
|
903
964
|
});
|
|
904
965
|
}
|
|
905
|
-
function untilText(epoch) {
|
|
906
|
-
|
|
907
|
-
if (delta >= 864e5) return `${Math.round(delta / 864e5)}d`;
|
|
908
|
-
if (delta >= 36e5) return `${Math.round(delta / 36e5)}h`;
|
|
909
|
-
return `${Math.max(1, Math.round(delta / 6e4))}m`;
|
|
966
|
+
function untilText(epoch, t) {
|
|
967
|
+
return relativeLabel(Math.max(0, epoch - Date.now()), t);
|
|
910
968
|
}
|
|
911
969
|
function accountMark(account, t) {
|
|
912
970
|
if (account === void 0 || account.mark === "") return void 0;
|
|
913
971
|
if (account.mark === "invalid-credential") return t("markInvalid");
|
|
914
972
|
const label = account.mark === "quota" ? t("markQuota") : account.mark === "rate-limit" ? t("markRateLimit") : t("markTransport");
|
|
915
973
|
if (account.coolingUntil <= 0) return label;
|
|
916
|
-
return `${label} · ${untilText(account.coolingUntil)}`;
|
|
974
|
+
return `${label} · ${untilText(account.coolingUntil, t)}`;
|
|
917
975
|
}
|
|
918
976
|
// src/client/usage-analytics.tsx
|
|
919
977
|
function compact(value) {
|
|
@@ -1134,18 +1192,11 @@ window.__ModuleLoader__.load({
|
|
|
1134
1192
|
if (percent >= 75) return "ocl-bar-fill ocl-bar-fill-warn";
|
|
1135
1193
|
return "ocl-bar-fill";
|
|
1136
1194
|
}
|
|
1137
|
-
function reset(iso) {
|
|
1195
|
+
function reset(iso, t) {
|
|
1138
1196
|
if (iso === void 0) return "";
|
|
1139
1197
|
const date = new Date(iso);
|
|
1140
1198
|
if (Number.isNaN(date.getTime())) return "";
|
|
1141
|
-
|
|
1142
|
-
const relative = delta <= 0 ? "now" : delta >= 864e5 ? `${Math.round(delta / 864e5)}d` : delta >= 36e5 ? `${Math.round(delta / 36e5)}h` : `${Math.max(1, Math.round(delta / 6e4))}m`;
|
|
1143
|
-
return `${date.toLocaleString([], {
|
|
1144
|
-
month: "2-digit",
|
|
1145
|
-
day: "2-digit",
|
|
1146
|
-
hour: "2-digit",
|
|
1147
|
-
minute: "2-digit"
|
|
1148
|
-
})} (${relative})`;
|
|
1199
|
+
return `${formatDateTime(date.getTime())} (${relativeLabel(date.getTime() - Date.now(), t)})`;
|
|
1149
1200
|
}
|
|
1150
1201
|
function UsageBars(props) {
|
|
1151
1202
|
const { bars, t } = props;
|
|
@@ -1159,8 +1210,8 @@ window.__ModuleLoader__.load({
|
|
|
1159
1210
|
className: "ocl-bar-row",
|
|
1160
1211
|
children: [
|
|
1161
1212
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1162
|
-
title: entry.labelKey
|
|
1163
|
-
children: entry.labelKey
|
|
1213
|
+
title: t(entry.labelKey ?? "quotaWindow"),
|
|
1214
|
+
children: t(entry.labelKey ?? "quotaWindow")
|
|
1164
1215
|
}),
|
|
1165
1216
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1166
1217
|
className: "ocl-bar",
|
|
@@ -1170,28 +1221,17 @@ window.__ModuleLoader__.load({
|
|
|
1170
1221
|
})
|
|
1171
1222
|
}),
|
|
1172
1223
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1173
|
-
title: entry.resetsAt === void 0 ? void 0 :
|
|
1224
|
+
title: entry.resetsAt === void 0 ? void 0 : formatDateTime(entry.resetsAt),
|
|
1174
1225
|
children: [
|
|
1175
1226
|
entry.remainingPercent.toFixed(0),
|
|
1176
1227
|
"% ",
|
|
1177
1228
|
t("remaining"),
|
|
1178
|
-
entry.resetsAt === void 0 ? "" : ` · ${reset(entry.resetsAt)}`
|
|
1229
|
+
entry.resetsAt === void 0 ? "" : ` · ${reset(entry.resetsAt, t)}`
|
|
1179
1230
|
]
|
|
1180
1231
|
}),
|
|
1181
|
-
entry.detailValues === void 0 ?
|
|
1182
|
-
className: "ocl-hint",
|
|
1183
|
-
children: entry.detail
|
|
1184
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1232
|
+
entry.detailValues === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1185
1233
|
className: "ocl-hint",
|
|
1186
|
-
children:
|
|
1187
|
-
"$",
|
|
1188
|
-
entry.detailValues.remaining.toFixed(2),
|
|
1189
|
-
" / $",
|
|
1190
|
-
entry.detailValues.allowance.toFixed(2),
|
|
1191
|
-
" ",
|
|
1192
|
-
t("remaining"),
|
|
1193
|
-
entry.detailValues.purchased > 0 ? ` · ${t("purchased")} $${entry.detailValues.purchased.toFixed(2)}` : ""
|
|
1194
|
-
]
|
|
1234
|
+
children: creditsDetail(entry.detailValues, t)
|
|
1195
1235
|
})
|
|
1196
1236
|
]
|
|
1197
1237
|
}, entry.key))
|
|
@@ -1264,15 +1304,11 @@ window.__ModuleLoader__.load({
|
|
|
1264
1304
|
})]
|
|
1265
1305
|
});
|
|
1266
1306
|
}
|
|
1267
|
-
function resetLabel(iso) {
|
|
1307
|
+
function resetLabel(iso, t) {
|
|
1268
1308
|
if (iso === void 0) return "";
|
|
1269
1309
|
const date = new Date(iso);
|
|
1270
1310
|
if (Number.isNaN(date.getTime())) return "";
|
|
1271
|
-
|
|
1272
|
-
if (delta <= 0) return "now";
|
|
1273
|
-
if (delta >= 864e5) return `${Math.round(delta / 864e5)}d`;
|
|
1274
|
-
if (delta >= 36e5) return `${Math.round(delta / 36e5)}h`;
|
|
1275
|
-
return `${Math.max(1, Math.round(delta / 6e4))}m`;
|
|
1311
|
+
return relativeLabel(date.getTime() - Date.now(), t);
|
|
1276
1312
|
}
|
|
1277
1313
|
function QuotaCard(props) {
|
|
1278
1314
|
const { t, open } = props;
|
|
@@ -1307,7 +1343,7 @@ window.__ModuleLoader__.load({
|
|
|
1307
1343
|
const worst = worstUsedPercent(report);
|
|
1308
1344
|
const plan = state?.config.planLabel?.trim() ?? "";
|
|
1309
1345
|
const name = plan === "" ? t("quotaCardName") : `${t("quotaCardName")} · ${plan}`;
|
|
1310
|
-
const detail = bars.map((entry) => `${entry.labelKey
|
|
1346
|
+
const detail = bars.map((entry) => `${t(entry.labelKey ?? "quotaWindow")}: ${entry.remainingPercent.toFixed(0)}% ${t("remaining")}`).join(" · ") + (state?.usage?.stale === true ? ` · ${t("lastGoodUsage")}` : "");
|
|
1311
1347
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1312
1348
|
type: "button",
|
|
1313
1349
|
className: "ocl-foot",
|
|
@@ -1338,14 +1374,14 @@ window.__ModuleLoader__.load({
|
|
|
1338
1374
|
className: "ocl-footHead",
|
|
1339
1375
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1340
1376
|
className: "ocl-footLabel",
|
|
1341
|
-
children: entry.labelKey
|
|
1377
|
+
children: t(entry.labelKey ?? "quotaWindow")
|
|
1342
1378
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1343
1379
|
className: "ocl-footAmount",
|
|
1344
1380
|
children: [
|
|
1345
1381
|
entry.remainingPercent.toFixed(0),
|
|
1346
1382
|
"% ",
|
|
1347
1383
|
t("remaining"),
|
|
1348
|
-
entry.resetsAt === void 0 ? "" : ` · ${resetLabel(entry.resetsAt)}`
|
|
1384
|
+
entry.resetsAt === void 0 ? "" : ` · ${resetLabel(entry.resetsAt, t)}`
|
|
1349
1385
|
]
|
|
1350
1386
|
})]
|
|
1351
1387
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -1599,10 +1635,10 @@ window.__ModuleLoader__.load({
|
|
|
1599
1635
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("model") }),
|
|
1600
1636
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("routing") })
|
|
1601
1637
|
] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: state.routing.map((row, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
1602
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children:
|
|
1638
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTime(row.at) }),
|
|
1603
1639
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row.account }),
|
|
1604
1640
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row.model }),
|
|
1605
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", { children: [row.reason, row.ok ? "" : ` · ${t("routingFailed")}${row.error === void 0 ? "" : ` (${row.error})`}`] })
|
|
1641
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", { children: [t(`reason_${row.reason}`), row.ok ? "" : ` · ${t("routingFailed")}${row.error === void 0 ? "" : ` (${row.error})`}`] })
|
|
1606
1642
|
] }, `${row.at}-${index}`)) })]
|
|
1607
1643
|
})
|
|
1608
1644
|
}),
|
|
@@ -2599,10 +2635,11 @@ window.__ModuleLoader__.load({
|
|
|
2599
2635
|
className: "ocl-notice",
|
|
2600
2636
|
children: notice
|
|
2601
2637
|
}),
|
|
2602
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
2638
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
2603
2639
|
className: "ocl-card",
|
|
2640
|
+
open: true,
|
|
2604
2641
|
children: [
|
|
2605
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
2642
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
|
|
2606
2643
|
className: "ocl-card-title",
|
|
2607
2644
|
children: [
|
|
2608
2645
|
t("key"),
|
|
@@ -2719,10 +2756,10 @@ window.__ModuleLoader__.load({
|
|
|
2719
2756
|
})
|
|
2720
2757
|
]
|
|
2721
2758
|
}),
|
|
2722
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
2759
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
2723
2760
|
className: "ocl-card",
|
|
2724
2761
|
children: [
|
|
2725
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
2762
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
|
|
2726
2763
|
className: "ocl-card-title",
|
|
2727
2764
|
children: t("serviceStatus")
|
|
2728
2765
|
}),
|
|
@@ -2736,7 +2773,7 @@ window.__ModuleLoader__.load({
|
|
|
2736
2773
|
children: [
|
|
2737
2774
|
service.latencyMs,
|
|
2738
2775
|
" ms · ",
|
|
2739
|
-
|
|
2776
|
+
formatTime(service.checkedAt)
|
|
2740
2777
|
]
|
|
2741
2778
|
}),
|
|
2742
2779
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
@@ -2760,10 +2797,11 @@ window.__ModuleLoader__.load({
|
|
|
2760
2797
|
})
|
|
2761
2798
|
]
|
|
2762
2799
|
}),
|
|
2763
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
2800
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
2764
2801
|
className: "ocl-card",
|
|
2802
|
+
open: worst >= 80,
|
|
2765
2803
|
children: [
|
|
2766
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
2804
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
|
|
2767
2805
|
className: "ocl-card-title",
|
|
2768
2806
|
children: [
|
|
2769
2807
|
t("quota"),
|
|
@@ -2774,7 +2812,8 @@ window.__ModuleLoader__.load({
|
|
|
2774
2812
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2775
2813
|
type: "button",
|
|
2776
2814
|
className: "ocl-button",
|
|
2777
|
-
onClick: () => {
|
|
2815
|
+
onClick: (event) => {
|
|
2816
|
+
event.stopPropagation();
|
|
2778
2817
|
refresh();
|
|
2779
2818
|
},
|
|
2780
2819
|
children: t("refresh")
|
|
@@ -2816,10 +2855,10 @@ window.__ModuleLoader__.load({
|
|
|
2816
2855
|
})
|
|
2817
2856
|
]
|
|
2818
2857
|
}),
|
|
2819
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
2858
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
2820
2859
|
className: "ocl-card",
|
|
2821
2860
|
children: [
|
|
2822
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
2861
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
|
|
2823
2862
|
className: "ocl-card-title",
|
|
2824
2863
|
children: [t("accounts"), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2825
2864
|
className: "ocl-badge",
|
|
@@ -2886,11 +2925,11 @@ window.__ModuleLoader__.load({
|
|
|
2886
2925
|
className: "ocl-accountUsage",
|
|
2887
2926
|
children: [quotaBars(known.usage.report).map((bar) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2888
2927
|
className: "ocl-badge",
|
|
2889
|
-
title: bar.
|
|
2890
|
-
children: [bar.
|
|
2928
|
+
title: bar.detailValues === void 0 ? t(bar.labelKey ?? "quotaWindow") : creditsDetail(bar.detailValues, t),
|
|
2929
|
+
children: [bar.detailValues === void 0 ? t(bar.labelKey ?? "quotaWindow") : creditsDetail(bar.detailValues, t), bar.resetsAt === void 0 ? "" : ` · ${t("until")} ${formatDate(bar.resetsAt)}`]
|
|
2891
2930
|
}, bar.key)), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2892
2931
|
className: "ocl-hint",
|
|
2893
|
-
children:
|
|
2932
|
+
children: formatTime(known.usage.checkedAt)
|
|
2894
2933
|
})]
|
|
2895
2934
|
}),
|
|
2896
2935
|
known?.usage?.report?.windows.d7 === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -3005,10 +3044,10 @@ window.__ModuleLoader__.load({
|
|
|
3005
3044
|
})
|
|
3006
3045
|
]
|
|
3007
3046
|
}),
|
|
3008
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
3047
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
3009
3048
|
className: "ocl-card",
|
|
3010
3049
|
children: [
|
|
3011
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
3050
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
|
|
3012
3051
|
className: "ocl-card-title",
|
|
3013
3052
|
children: t("modelAccountRules")
|
|
3014
3053
|
}),
|
|
@@ -3066,10 +3105,10 @@ window.__ModuleLoader__.load({
|
|
|
3066
3105
|
})
|
|
3067
3106
|
]
|
|
3068
3107
|
}),
|
|
3069
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
3108
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
3070
3109
|
className: "ocl-card",
|
|
3071
3110
|
children: [
|
|
3072
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
3111
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
|
|
3073
3112
|
className: "ocl-card-title",
|
|
3074
3113
|
children: t("routing")
|
|
3075
3114
|
}),
|
|
@@ -3091,10 +3130,10 @@ window.__ModuleLoader__.load({
|
|
|
3091
3130
|
})
|
|
3092
3131
|
]
|
|
3093
3132
|
}),
|
|
3094
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
3133
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
3095
3134
|
className: "ocl-card",
|
|
3096
3135
|
children: [
|
|
3097
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
3136
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
|
|
3098
3137
|
className: "ocl-card-title",
|
|
3099
3138
|
children: [
|
|
3100
3139
|
t("models"),
|
|
@@ -3109,7 +3148,8 @@ window.__ModuleLoader__.load({
|
|
|
3109
3148
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3110
3149
|
type: "button",
|
|
3111
3150
|
className: "ocl-button",
|
|
3112
|
-
onClick: () => {
|
|
3151
|
+
onClick: (event) => {
|
|
3152
|
+
event.stopPropagation();
|
|
3113
3153
|
reloadModels();
|
|
3114
3154
|
},
|
|
3115
3155
|
children: t("refresh")
|
|
@@ -3117,20 +3157,26 @@ window.__ModuleLoader__.load({
|
|
|
3117
3157
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3118
3158
|
type: "button",
|
|
3119
3159
|
className: "ocl-button",
|
|
3120
|
-
onClick: () =>
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3160
|
+
onClick: (event) => {
|
|
3161
|
+
event.stopPropagation();
|
|
3162
|
+
update({
|
|
3163
|
+
showAll: true,
|
|
3164
|
+
visibleModels: state.models.map((model) => model.id)
|
|
3165
|
+
});
|
|
3166
|
+
},
|
|
3124
3167
|
children: t("showAll")
|
|
3125
3168
|
}),
|
|
3126
3169
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3127
3170
|
type: "button",
|
|
3128
3171
|
className: "ocl-button",
|
|
3129
|
-
onClick: () =>
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3172
|
+
onClick: (event) => {
|
|
3173
|
+
event.stopPropagation();
|
|
3174
|
+
update({
|
|
3175
|
+
showAll: false,
|
|
3176
|
+
visibleModels: [],
|
|
3177
|
+
modelVisibility: {}
|
|
3178
|
+
});
|
|
3179
|
+
},
|
|
3134
3180
|
children: t("hideAll")
|
|
3135
3181
|
})
|
|
3136
3182
|
]
|
|
@@ -3251,25 +3297,32 @@ window.__ModuleLoader__.load({
|
|
|
3251
3297
|
})
|
|
3252
3298
|
]
|
|
3253
3299
|
}),
|
|
3254
|
-
editingModel !== null && state.models.some((model) => model.id === editingModel) && /* @__PURE__ */ (0, react_jsx_runtime.
|
|
3300
|
+
editingModel !== null && state.models.some((model) => model.id === editingModel) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
3255
3301
|
className: "ocl-card",
|
|
3256
|
-
|
|
3302
|
+
open: true,
|
|
3303
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
|
|
3304
|
+
className: "ocl-card-title",
|
|
3305
|
+
children: t("editModel")
|
|
3306
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelOverrideEditor, {
|
|
3257
3307
|
model: state.models.find((model) => model.id === editingModel),
|
|
3258
3308
|
draft,
|
|
3259
3309
|
t,
|
|
3260
3310
|
update,
|
|
3261
3311
|
close: () => setEditingModel(null)
|
|
3262
|
-
})
|
|
3312
|
+
})]
|
|
3263
3313
|
}),
|
|
3264
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
3314
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
3265
3315
|
className: "ocl-card",
|
|
3266
3316
|
children: [
|
|
3267
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
3317
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
|
|
3268
3318
|
className: "ocl-card-title",
|
|
3269
3319
|
children: [t("manualModels"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3270
3320
|
type: "button",
|
|
3271
3321
|
className: "ocl-button",
|
|
3272
|
-
onClick:
|
|
3322
|
+
onClick: (event) => {
|
|
3323
|
+
event.stopPropagation();
|
|
3324
|
+
addManualModel();
|
|
3325
|
+
},
|
|
3273
3326
|
children: t("addManualModel")
|
|
3274
3327
|
})]
|
|
3275
3328
|
}),
|
|
@@ -3360,10 +3413,10 @@ window.__ModuleLoader__.load({
|
|
|
3360
3413
|
}, model.uid))
|
|
3361
3414
|
]
|
|
3362
3415
|
}),
|
|
3363
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
3416
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
3364
3417
|
className: "ocl-card",
|
|
3365
3418
|
children: [
|
|
3366
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
3419
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
|
|
3367
3420
|
className: "ocl-card-title",
|
|
3368
3421
|
children: t("generation")
|
|
3369
3422
|
}),
|
|
@@ -3456,9 +3509,9 @@ window.__ModuleLoader__.load({
|
|
|
3456
3509
|
})
|
|
3457
3510
|
]
|
|
3458
3511
|
}),
|
|
3459
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
3512
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
3460
3513
|
className: "ocl-card",
|
|
3461
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
3514
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
|
|
3462
3515
|
className: "ocl-card-title",
|
|
3463
3516
|
children: t("advanced")
|
|
3464
3517
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -3579,10 +3632,11 @@ window.__ModuleLoader__.load({
|
|
|
3579
3632
|
]
|
|
3580
3633
|
})]
|
|
3581
3634
|
}),
|
|
3582
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
3635
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
3583
3636
|
className: "ocl-card",
|
|
3637
|
+
open: discoverError !== null,
|
|
3584
3638
|
children: [
|
|
3585
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
3639
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
|
|
3586
3640
|
className: "ocl-card-title",
|
|
3587
3641
|
children: t("discover")
|
|
3588
3642
|
}),
|
|
@@ -3658,10 +3712,10 @@ window.__ModuleLoader__.load({
|
|
|
3658
3712
|
})
|
|
3659
3713
|
]
|
|
3660
3714
|
}),
|
|
3661
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
3715
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
3662
3716
|
className: "ocl-card",
|
|
3663
3717
|
children: [
|
|
3664
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
3718
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
|
|
3665
3719
|
className: "ocl-card-title",
|
|
3666
3720
|
children: t("sidebar")
|
|
3667
3721
|
}),
|
|
@@ -3789,7 +3843,7 @@ window.__ModuleLoader__.load({
|
|
|
3789
3843
|
className: "ocl-row",
|
|
3790
3844
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3791
3845
|
className: "ocl-model-name",
|
|
3792
|
-
children: bar.labelKey
|
|
3846
|
+
children: t(bar.labelKey ?? "quotaWindow")
|
|
3793
3847
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3794
3848
|
className: "ocl-badge",
|
|
3795
3849
|
children: [
|
|
@@ -3852,8 +3906,15 @@ window.__ModuleLoader__.load({
|
|
|
3852
3906
|
.ocl-head { display: flex; flex-direction: column; gap: 4px; }
|
|
3853
3907
|
.ocl-title { font-size: 18px; font-weight: 650; margin: 0; }
|
|
3854
3908
|
.ocl-hint { font-size: 12px; opacity: 0.72; line-height: 1.5; margin: 0; }
|
|
3855
|
-
.ocl-card { border: 1px solid var(--ocl-border); border-radius:
|
|
3856
|
-
.ocl-card
|
|
3909
|
+
.ocl-card { border: 1px solid var(--ocl-border); border-radius: 12px; background: var(--ocl-fill); display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; }
|
|
3910
|
+
details.ocl-card { padding: 0; }
|
|
3911
|
+
.ocl-card-title { font-size: 15px; font-weight: 600; line-height: 1.4; margin: 0; display: flex; align-items: center; gap: 8px; }
|
|
3912
|
+
summary.ocl-card-title { padding: 14px 16px; cursor: pointer; list-style: none; }
|
|
3913
|
+
summary.ocl-card-title::-webkit-details-marker { display: none; }
|
|
3914
|
+
summary.ocl-card-title::after { content: ''; width: 7px; height: 7px; margin-left: auto; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform .16s; color: var(--ocl-text-tertiary); }
|
|
3915
|
+
details.ocl-card[open] > summary.ocl-card-title::after { transform: rotate(225deg); }
|
|
3916
|
+
details.ocl-card > *:not(.ocl-card-title) { margin-left: 16px; margin-right: 16px; }
|
|
3917
|
+
details.ocl-card > *:not(.ocl-card-title):last-child { margin-bottom: 14px; }
|
|
3857
3918
|
.ocl-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
3858
3919
|
.ocl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
|
|
3859
3920
|
.ocl-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
|
|
@@ -3972,8 +4033,10 @@ window.__ModuleLoader__.load({
|
|
|
3972
4033
|
* the sidebar, and the center panel it opens.
|
|
3973
4034
|
*/
|
|
3974
4035
|
function apply(ctx) {
|
|
3975
|
-
ctx.effect(() => ctx.locale.register(NS,
|
|
3976
|
-
|
|
4036
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
4037
|
+
en: dictionaries.en,
|
|
4038
|
+
zh: dictionaries.zh
|
|
4039
|
+
}), "dsh-ollama-cloud-provider: dictionaries");
|
|
3977
4040
|
ctx.effect(() => injectCss(), "dsh-ollama-cloud-provider: styles");
|
|
3978
4041
|
const t = ctx.locale.bind(NS);
|
|
3979
4042
|
const slots = ctx.slots;
|
package/lib/config.js
CHANGED
|
@@ -7,7 +7,7 @@ const DEFAULT_API_BASE = "https://ollama.com";
|
|
|
7
7
|
const DEFAULT_OPENAI_BASE = "https://ollama.com/v1";
|
|
8
8
|
const DEFAULT_USAGE_URL = "https://ollama.com/api/usage";
|
|
9
9
|
const DEFAULT_BALANCE_URL = "https://ollama.com/api/balance";
|
|
10
|
-
const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.
|
|
10
|
+
const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.41";
|
|
11
11
|
const DEFAULT_CONTEXT_WINDOW = 131072;
|
|
12
12
|
const DEFAULT_MAX_TOKENS = 32768;
|
|
13
13
|
const DEFAULT_GENERATE_MAX_TOKENS = 131072;
|
|
@@ -288,6 +288,6 @@ function resolveConfig(config) {
|
|
|
288
288
|
userAgent: typeof config.userAgent === "string" && config.userAgent !== "" ? config.userAgent : DEFAULT_USER_AGENT
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
|
-
export { Config, DEFAULT_API_BASE, DEFAULT_API_KEY_ENV, DEFAULT_BALANCE_URL, DEFAULT_CONTEXT_WINDOW, DEFAULT_GENERATE_MAX_TOKENS, DEFAULT_MAX_TOKENS, DEFAULT_OPENAI_BASE, DEFAULT_USAGE_URL, DEFAULT_USER_AGENT, NS, resolveConfig, unwrapVolatileConfig };
|
|
291
|
+
export { Config, DEFAULT_API_BASE, DEFAULT_API_KEY_ENV, DEFAULT_BALANCE_URL, DEFAULT_CONTEXT_WINDOW, DEFAULT_GENERATE_MAX_TOKENS, DEFAULT_MAX_TOKENS, DEFAULT_OPENAI_BASE, DEFAULT_USAGE_URL, DEFAULT_USER_AGENT, NS, booleanRecord, manualModelList, modelOverrideRecord, numberRecord, priceRecord, resolveConfig, ruleList, transportRecord, unwrapVolatileConfig };
|
|
292
292
|
|
|
293
293
|
//# sourceMappingURL=config.js.map
|
package/lib/credentials.d.ts
CHANGED
|
@@ -17,7 +17,5 @@ interface KeyPool {
|
|
|
17
17
|
* Keys are deduplicated; a slot without a resolvable value is skipped.
|
|
18
18
|
*/
|
|
19
19
|
declare function createKeyPool(ctx: Context, config: () => ResolvedConfig): KeyPool;
|
|
20
|
-
|
|
21
|
-
declare function createKeyResolver(ctx: Context, config: () => ResolvedConfig): KeyResolver;
|
|
22
|
-
export { KeyPool, KeyResolver, ResolvedKey, createKeyPool, createKeyResolver };
|
|
20
|
+
export { KeyPool, KeyResolver, ResolvedKey, createKeyPool };
|
|
23
21
|
//# sourceMappingURL=credentials.d.ts.map
|
package/lib/credentials.js
CHANGED
|
@@ -20,6 +20,10 @@ async function resolveRef(ctx, refName) {
|
|
|
20
20
|
source: ambient.source
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
+
function accountLabel(label, index) {
|
|
24
|
+
const trimmed = typeof label === "string" ? label.trim() : "";
|
|
25
|
+
return trimmed === "" ? `account-${index + 2}` : trimmed;
|
|
26
|
+
}
|
|
23
27
|
function slotsOf(config) {
|
|
24
28
|
const slots = [{
|
|
25
29
|
label: "default",
|
|
@@ -27,7 +31,7 @@ function slotsOf(config) {
|
|
|
27
31
|
refName: config.apiKeyEnv
|
|
28
32
|
}];
|
|
29
33
|
for (const [index, account] of config.accounts.entries()) {
|
|
30
|
-
const label =
|
|
34
|
+
const label = accountLabel(account.label, index);
|
|
31
35
|
const literal = typeof account.apiKey === "string" && account.apiKey.trim() !== "" ? account.apiKey.trim() : void 0;
|
|
32
36
|
const refName = typeof account.apiKeyEnv === "string" && account.apiKeyEnv.trim() !== "" ? account.apiKeyEnv.trim() : void 0;
|
|
33
37
|
if (literal === void 0 && refName === void 0) continue;
|
|
@@ -96,10 +100,6 @@ function createKeyPool(ctx, config) {
|
|
|
96
100
|
function missingKey(config) {
|
|
97
101
|
return new LlmError(`llm-ollama-cloud: no API key. Store ${config.apiKeyEnv} through the credentials service, export it in the launching environment, or set config.apiKey in the composition. Create a key at https://ollama.com/settings/keys.`, "MISSING_CREDENTIAL");
|
|
98
102
|
}
|
|
99
|
-
|
|
100
|
-
function createKeyResolver(ctx, config) {
|
|
101
|
-
return createKeyPool(ctx, config).resolve;
|
|
102
|
-
}
|
|
103
|
-
export { createKeyPool, createKeyResolver };
|
|
103
|
+
export { accountLabel, createKeyPool };
|
|
104
104
|
|
|
105
105
|
//# sourceMappingURL=credentials.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OllamaCloudAdapter, OllamaCloudAdapterDeps } from "./adapter.js";
|
|
2
2
|
import { Config, ResolvedConfig, TransportId, resolveConfig } from "./config.js";
|
|
3
3
|
import { PROVIDER } from "./provider-ids.js";
|
|
4
|
-
import { ResolvedKey, createKeyPool
|
|
4
|
+
import { ResolvedKey, createKeyPool } from "./credentials.js";
|
|
5
5
|
import { CommandDeps, applyCommands } from "./commands.js";
|
|
6
6
|
import { RouteDeps, applyRoutes } from "./routes.js";
|
|
7
7
|
import { UsageReport, UsageResult, UsageWindow, createUsageReader, normalizeBalance, normalizeUsage } from "./usage.js";
|
|
@@ -16,5 +16,5 @@ declare const inject: string[];
|
|
|
16
16
|
* without a restart.
|
|
17
17
|
*/
|
|
18
18
|
declare function apply(ctx: Context, config: Config): void;
|
|
19
|
-
export { type CommandDeps, Config, OllamaCloudAdapter, type OllamaCloudAdapterDeps, type Config as OllamaCloudConfig, PROVIDER, type ResolvedConfig, type ResolvedKey, type RouteDeps, type TransportId, type UsageReport, type UsageResult, type UsageWindow, apply, applyCommands, applyRoutes, classifyResponseError, clearCatalogCache, createKeyPool,
|
|
19
|
+
export { type CommandDeps, Config, OllamaCloudAdapter, type OllamaCloudAdapterDeps, type Config as OllamaCloudConfig, PROVIDER, type ResolvedConfig, type ResolvedKey, type RouteDeps, type TransportId, type UsageReport, type UsageResult, type UsageWindow, apply, applyCommands, applyRoutes, classifyResponseError, clearCatalogCache, createKeyPool, createUsageReader, describeModel, effectiveModel, inject, name, normalizeBalance, normalizeUsage, resolveConfig };
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|