@goodandready/dsh-ollama-cloud-provider 0.1.39 → 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/lib/client.js CHANGED
@@ -28,6 +28,8 @@ window.__ModuleLoader__.load({
28
28
  refresh: "Refresh",
29
29
  save: "Save",
30
30
  saving: "Saving…",
31
+ settingsReadOnly: "Settings are read-only in this host.",
32
+ editModel: "Edit model",
31
33
  unsaved: "Unsaved changes",
32
34
  discard: "Discard",
33
35
  close: "Close",
@@ -55,6 +57,16 @@ window.__ModuleLoader__.load({
55
57
  quotaWeekly: "Weekly window",
56
58
  until: "until",
57
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",
58
70
  range: "Range",
59
71
  last24h: "Last 24 hours",
60
72
  last7d: "Last 7 days",
@@ -275,6 +287,8 @@ window.__ModuleLoader__.load({
275
287
  refresh: "刷新",
276
288
  save: "保存",
277
289
  saving: "保存中…",
290
+ settingsReadOnly: "当前宿主机的设置为只读。",
291
+ editModel: "编辑模型",
278
292
  unsaved: "有未保存的更改",
279
293
  discard: "放弃",
280
294
  close: "关闭",
@@ -302,6 +316,16 @@ window.__ModuleLoader__.load({
302
316
  quotaWeekly: "每周窗口",
303
317
  until: "至",
304
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: "轮换",
305
329
  range: "范围",
306
330
  last24h: "最近 24 小时",
307
331
  last7d: "最近 7 天",
@@ -504,6 +528,46 @@ window.__ModuleLoader__.load({
504
528
  latestVersion: "最新"
505
529
  }
506
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
+ }
507
571
  // src/quota-model.ts
508
572
  function bar(key, label, usedPercent, extra = {}) {
509
573
  const labelKey = key === "included" ? "quotaIncludedCredits" : key === "fiveHour" ? "quotaFiveHour" : key === "weekly" ? "quotaWeekly" : void 0;
@@ -532,8 +596,7 @@ window.__ModuleLoader__.load({
532
596
  if (report === void 0) return [];
533
597
  if (report.kind === "credits" && report.credits !== void 0) {
534
598
  const credits = report.credits;
535
- return [bar("included", "Included credits", credits.includedAllowance > 0 ? (credits.includedAllowance - credits.includedRemaining) / credits.includedAllowance * 100 : 0, {
536
- 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, {
537
600
  detailValues: {
538
601
  remaining: credits.includedRemaining,
539
602
  allowance: credits.includedAllowance,
@@ -542,7 +605,7 @@ window.__ModuleLoader__.load({
542
605
  ...credits.periodUntil === void 0 ? {} : { resetsAt: credits.periodUntil }
543
606
  })];
544
607
  }
545
- return [legacyBar("fiveHour", "5-hour window", report.legacy?.fiveHour), legacyBar("weekly", "Weekly window", report.legacy?.weekly)].filter((entry) => entry !== void 0);
608
+ return [legacyBar("fiveHour", "", report.legacy?.fiveHour), legacyBar("weekly", "", report.legacy?.weekly)].filter((entry) => entry !== void 0);
546
609
  }
547
610
  function worstUsedPercent(report) {
548
611
  return quotaBars(report).reduce((worst, entry) => Math.max(worst, entry.usedPercent), 0);
@@ -552,19 +615,19 @@ window.__ModuleLoader__.load({
552
615
  return [
553
616
  report.windows.d24 === void 0 ? void 0 : {
554
617
  key: "24h",
555
- label: "24 hours",
618
+ label: "",
556
619
  labelKey: "last24h",
557
620
  totals: report.windows.d24
558
621
  },
559
622
  report.windows.d7 === void 0 ? void 0 : {
560
623
  key: "7d",
561
- label: "7 days",
624
+ label: "",
562
625
  labelKey: "last7d",
563
626
  totals: report.windows.d7
564
627
  },
565
628
  report.windows.d30 === void 0 ? void 0 : {
566
629
  key: "30d",
567
- label: "30 days",
630
+ label: "",
568
631
  labelKey: "last30d",
569
632
  totals: report.windows.d30
570
633
  }
@@ -900,18 +963,15 @@ window.__ModuleLoader__.load({
900
963
  ]
901
964
  });
902
965
  }
903
- function untilText(epoch) {
904
- const delta = Math.max(0, epoch - Date.now());
905
- if (delta >= 864e5) return `${Math.round(delta / 864e5)}d`;
906
- if (delta >= 36e5) return `${Math.round(delta / 36e5)}h`;
907
- return `${Math.max(1, Math.round(delta / 6e4))}m`;
966
+ function untilText(epoch, t) {
967
+ return relativeLabel(Math.max(0, epoch - Date.now()), t);
908
968
  }
909
969
  function accountMark(account, t) {
910
970
  if (account === void 0 || account.mark === "") return void 0;
911
971
  if (account.mark === "invalid-credential") return t("markInvalid");
912
972
  const label = account.mark === "quota" ? t("markQuota") : account.mark === "rate-limit" ? t("markRateLimit") : t("markTransport");
913
973
  if (account.coolingUntil <= 0) return label;
914
- return `${label} · ${untilText(account.coolingUntil)}`;
974
+ return `${label} · ${untilText(account.coolingUntil, t)}`;
915
975
  }
916
976
  // src/client/usage-analytics.tsx
917
977
  function compact(value) {
@@ -1132,18 +1192,11 @@ window.__ModuleLoader__.load({
1132
1192
  if (percent >= 75) return "ocl-bar-fill ocl-bar-fill-warn";
1133
1193
  return "ocl-bar-fill";
1134
1194
  }
1135
- function reset(iso) {
1195
+ function reset(iso, t) {
1136
1196
  if (iso === void 0) return "";
1137
1197
  const date = new Date(iso);
1138
1198
  if (Number.isNaN(date.getTime())) return "";
1139
- const delta = date.getTime() - Date.now();
1140
- 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`;
1141
- return `${date.toLocaleString([], {
1142
- month: "2-digit",
1143
- day: "2-digit",
1144
- hour: "2-digit",
1145
- minute: "2-digit"
1146
- })} (${relative})`;
1199
+ return `${formatDateTime(date.getTime())} (${relativeLabel(date.getTime() - Date.now(), t)})`;
1147
1200
  }
1148
1201
  function UsageBars(props) {
1149
1202
  const { bars, t } = props;
@@ -1157,8 +1210,8 @@ window.__ModuleLoader__.load({
1157
1210
  className: "ocl-bar-row",
1158
1211
  children: [
1159
1212
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1160
- title: entry.labelKey === void 0 ? entry.label : t(entry.labelKey),
1161
- children: entry.labelKey === void 0 ? entry.label : t(entry.labelKey)
1213
+ title: t(entry.labelKey ?? "quotaWindow"),
1214
+ children: t(entry.labelKey ?? "quotaWindow")
1162
1215
  }),
1163
1216
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1164
1217
  className: "ocl-bar",
@@ -1168,28 +1221,17 @@ window.__ModuleLoader__.load({
1168
1221
  })
1169
1222
  }),
1170
1223
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1171
- title: entry.resetsAt === void 0 ? void 0 : new Date(entry.resetsAt).toLocaleString(),
1224
+ title: entry.resetsAt === void 0 ? void 0 : formatDateTime(entry.resetsAt),
1172
1225
  children: [
1173
1226
  entry.remainingPercent.toFixed(0),
1174
1227
  "% ",
1175
1228
  t("remaining"),
1176
- entry.resetsAt === void 0 ? "" : ` · ${reset(entry.resetsAt)}`
1229
+ entry.resetsAt === void 0 ? "" : ` · ${reset(entry.resetsAt, t)}`
1177
1230
  ]
1178
1231
  }),
1179
- entry.detailValues === void 0 ? entry.detail === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1232
+ entry.detailValues === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1180
1233
  className: "ocl-hint",
1181
- children: entry.detail
1182
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1183
- className: "ocl-hint",
1184
- children: [
1185
- "$",
1186
- entry.detailValues.remaining.toFixed(2),
1187
- " / $",
1188
- entry.detailValues.allowance.toFixed(2),
1189
- " ",
1190
- t("remaining"),
1191
- entry.detailValues.purchased > 0 ? ` · ${t("purchased")} $${entry.detailValues.purchased.toFixed(2)}` : ""
1192
- ]
1234
+ children: creditsDetail(entry.detailValues, t)
1193
1235
  })
1194
1236
  ]
1195
1237
  }, entry.key))
@@ -1262,15 +1304,11 @@ window.__ModuleLoader__.load({
1262
1304
  })]
1263
1305
  });
1264
1306
  }
1265
- function resetLabel(iso) {
1307
+ function resetLabel(iso, t) {
1266
1308
  if (iso === void 0) return "";
1267
1309
  const date = new Date(iso);
1268
1310
  if (Number.isNaN(date.getTime())) return "";
1269
- const delta = date.getTime() - Date.now();
1270
- if (delta <= 0) return "now";
1271
- if (delta >= 864e5) return `${Math.round(delta / 864e5)}d`;
1272
- if (delta >= 36e5) return `${Math.round(delta / 36e5)}h`;
1273
- return `${Math.max(1, Math.round(delta / 6e4))}m`;
1311
+ return relativeLabel(date.getTime() - Date.now(), t);
1274
1312
  }
1275
1313
  function QuotaCard(props) {
1276
1314
  const { t, open } = props;
@@ -1305,7 +1343,7 @@ window.__ModuleLoader__.load({
1305
1343
  const worst = worstUsedPercent(report);
1306
1344
  const plan = state?.config.planLabel?.trim() ?? "";
1307
1345
  const name = plan === "" ? t("quotaCardName") : `${t("quotaCardName")} · ${plan}`;
1308
- 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")}` : "");
1346
+ const detail = bars.map((entry) => `${t(entry.labelKey ?? "quotaWindow")}: ${entry.remainingPercent.toFixed(0)}% ${t("remaining")}`).join(" · ") + (state?.usage?.stale === true ? ` · ${t("lastGoodUsage")}` : "");
1309
1347
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1310
1348
  type: "button",
1311
1349
  className: "ocl-foot",
@@ -1336,14 +1374,14 @@ window.__ModuleLoader__.load({
1336
1374
  className: "ocl-footHead",
1337
1375
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1338
1376
  className: "ocl-footLabel",
1339
- children: entry.labelKey === void 0 ? entry.label : t(entry.labelKey)
1377
+ children: t(entry.labelKey ?? "quotaWindow")
1340
1378
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1341
1379
  className: "ocl-footAmount",
1342
1380
  children: [
1343
1381
  entry.remainingPercent.toFixed(0),
1344
1382
  "% ",
1345
1383
  t("remaining"),
1346
- entry.resetsAt === void 0 ? "" : ` · ${resetLabel(entry.resetsAt)}`
1384
+ entry.resetsAt === void 0 ? "" : ` · ${resetLabel(entry.resetsAt, t)}`
1347
1385
  ]
1348
1386
  })]
1349
1387
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -1360,6 +1398,7 @@ window.__ModuleLoader__.load({
1360
1398
  const { t, close } = props;
1361
1399
  const { state, error, load } = useHostState(6e4);
1362
1400
  const [busy, setBusy] = (0, react.useState)(false);
1401
+ const [actionError, setActionError] = (0, react.useState)(null);
1363
1402
  const [range, setRange] = (0, react.useState)("7d");
1364
1403
  const [usage, setUsage] = (0, react.useState)(null);
1365
1404
  const [analytics, setAnalytics] = (0, react.useState)(null);
@@ -1391,7 +1430,17 @@ window.__ModuleLoader__.load({
1391
1430
  const stale = usage?.stale === true || state?.usage?.stale === true;
1392
1431
  const refresh = () => {
1393
1432
  setBusy(true);
1394
- refreshState().then(() => load()).finally(() => setBusy(false));
1433
+ setActionError(null);
1434
+ (async () => {
1435
+ try {
1436
+ await refreshState();
1437
+ await load();
1438
+ } catch (caught) {
1439
+ setActionError(caught instanceof Error ? caught.message : String(caught));
1440
+ } finally {
1441
+ setBusy(false);
1442
+ }
1443
+ })();
1395
1444
  };
1396
1445
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1397
1446
  className: "ocl-panel",
@@ -1451,6 +1500,14 @@ window.__ModuleLoader__.load({
1451
1500
  error
1452
1501
  ]
1453
1502
  }),
1503
+ actionError === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
1504
+ className: "ocl-error",
1505
+ children: [
1506
+ t("failed"),
1507
+ ": ",
1508
+ actionError
1509
+ ]
1510
+ }),
1454
1511
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
1455
1512
  className: "ocl-card",
1456
1513
  children: [
@@ -1578,10 +1635,10 @@ window.__ModuleLoader__.load({
1578
1635
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("model") }),
1579
1636
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("routing") })
1580
1637
  ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: state.routing.map((row, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
1581
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: new Date(row.at).toLocaleTimeString() }),
1638
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTime(row.at) }),
1582
1639
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row.account }),
1583
1640
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row.model }),
1584
- /* @__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})`}`] })
1585
1642
  ] }, `${row.at}-${index}`)) })]
1586
1643
  })
1587
1644
  }),
@@ -1700,7 +1757,8 @@ window.__ModuleLoader__.load({
1700
1757
  visibleModels: state.config.showAllModels ? allIds : [...state.config.visibleModels],
1701
1758
  filterModelsByPlan: state.config.filterModelsByPlan,
1702
1759
  modelVisibility: { ...state.config.modelVisibility },
1703
- manualModels: (state.config.manualModels ?? []).map((model) => ({
1760
+ manualModels: (state.config.manualModels ?? []).map((model, index) => ({
1761
+ uid: `manual-${index}`,
1704
1762
  id: model.id,
1705
1763
  enabled: model.enabled !== false,
1706
1764
  name: model.name ?? "",
@@ -1731,105 +1789,141 @@ window.__ModuleLoader__.load({
1731
1789
  modelTransports: { ...state.config.modelTransports }
1732
1790
  };
1733
1791
  }
1734
- function numberOrNull(text) {
1792
+ /**
1793
+ * An empty field means "unset", never "substitute a default". The schema owns
1794
+ * the default, so an explicit null is the only value that cannot silently
1795
+ * replace what the user typed.
1796
+ */
1797
+ function numberOrNull(text, field = "value") {
1735
1798
  const trimmed = text.trim();
1736
1799
  if (trimmed === "") return null;
1737
1800
  const value = Number(trimmed);
1738
- if (!Number.isInteger(value) || value < 0) throw new Error(`Invalid number: ${text}`);
1801
+ if (!Number.isInteger(value) || value < 0) throw new Error(`${field} must be a non-negative integer`);
1739
1802
  return value;
1740
1803
  }
1741
- function boundedNumber(text, min, max, integer) {
1804
+ function boundedNumber(text, min, max, integer, field = "value") {
1742
1805
  const trimmed = text.trim();
1743
1806
  if (trimmed === "") return null;
1744
1807
  const value = Number(trimmed);
1745
- if (!Number.isFinite(value) || value < min || value > max || integer && !Number.isInteger(value)) throw new Error(`Invalid number: ${text}`);
1808
+ if (!Number.isFinite(value) || value < min || value > max || integer && !Number.isInteger(value)) throw new Error(`${field} must be ${integer ? "an integer " : ""}between ${min} and ${max}`);
1746
1809
  return value;
1747
1810
  }
1748
1811
  function stopList(text) {
1749
1812
  return text.split(/[\n,]/).map((entry) => entry.trim()).filter((entry) => entry !== "");
1750
1813
  }
1751
- function patchOf(draft) {
1814
+ function draftPatch(draft) {
1815
+ const errors = {};
1816
+ const field = (name, compute) => {
1817
+ try {
1818
+ return compute();
1819
+ } catch (error) {
1820
+ errors[name] = error instanceof Error ? error.message : String(error);
1821
+ return null;
1822
+ }
1823
+ };
1824
+ const manualModels = [];
1825
+ draft.manualModels.forEach((model, index) => {
1826
+ const id = model.id.trim();
1827
+ if (id === "") return;
1828
+ const name = `manualModels[${index}]`;
1829
+ try {
1830
+ const contextWindow = numberOrNull(model.contextWindow, `${name}.contextWindow`);
1831
+ const maxTokens = numberOrNull(model.maxTokens, `${name}.maxTokens`);
1832
+ manualModels.push({
1833
+ id,
1834
+ enabled: model.enabled,
1835
+ ...model.name.trim() === "" ? {} : { name: model.name.trim() },
1836
+ ...contextWindow === null ? {} : { contextWindow },
1837
+ ...maxTokens === null ? {} : { maxTokens },
1838
+ image: model.image,
1839
+ thinking: model.thinking,
1840
+ ...stopList(model.reasoningEfforts).length === 0 ? {} : { reasoningEfforts: stopList(model.reasoningEfforts) },
1841
+ ...model.defaultReasoning.trim() === "" ? {} : { defaultReasoning: model.defaultReasoning.trim() },
1842
+ tools: model.tools
1843
+ });
1844
+ } catch (error) {
1845
+ errors[name] = error instanceof Error ? error.message : String(error);
1846
+ }
1847
+ });
1752
1848
  return {
1753
- apiKeyEnv: draft.apiKeyEnv.trim(),
1754
- apiBase: draft.apiBase.trim(),
1755
- openAiBase: draft.openAiBase.trim(),
1756
- usageUrl: draft.usageUrl.trim(),
1757
- balanceUrl: draft.balanceUrl.trim(),
1758
- transport: draft.transport,
1759
- requestTimeoutMs: numberOrNull(draft.requestTimeoutMs) ?? 3e5,
1760
- streamIdleTimeoutMs: numberOrNull(draft.streamIdleTimeoutMs) ?? 3e5,
1761
- attemptTimeoutMs: boundedNumber(draft.attemptTimeoutMs, 0, 36e5, true) ?? 0,
1762
- retryMaxRetries: boundedNumber(draft.retryMaxRetries, 0, 10, true) ?? 0,
1763
- retryBaseDelayMs: boundedNumber(draft.retryBaseDelayMs, 0, 6e4, true) ?? 250,
1764
- retryMaxDelayMs: boundedNumber(draft.retryMaxDelayMs, 0, 12e4, true) ?? 2e3,
1765
- retryJitter: boundedNumber(draft.retryJitter, 0, 1, false) ?? .2,
1766
- maxOutputTokens: numberOrNull(draft.maxOutputTokens),
1767
- contextWindow: numberOrNull(draft.contextWindow),
1768
- temperature: boundedNumber(draft.temperature, 0, 2, false),
1769
- topK: boundedNumber(draft.topK, 1, 1e6, true),
1770
- topP: boundedNumber(draft.topP, 0, 1, false),
1771
- minP: boundedNumber(draft.minP, 0, 1, false),
1772
- seed: boundedNumber(draft.seed, 0, 4294967295, true),
1773
- repeatPenalty: boundedNumber(draft.repeatPenalty, 0, 2, false),
1774
- repeatLastN: boundedNumber(draft.repeatLastN, -1, 1e6, true),
1775
- numCtx: boundedNumber(draft.numCtx, 1, 1e7, true),
1776
- keepAlive: draft.keepAlive.trim(),
1777
- stop: stopList(draft.stop),
1778
- autoRefresh: draft.autoRefresh,
1779
- refreshMinutes: boundedNumber(draft.refreshMinutes, 0, 10080, true) ?? 1440,
1780
- showSidebarQuota: draft.showSidebarQuota,
1781
- planLabel: draft.planLabel.trim(),
1782
- activeAccount: draft.activeAccount.trim(),
1783
- accounts: draft.accounts.map((account) => ({
1784
- label: account.label.trim(),
1785
- apiKeyEnv: account.apiKeyEnv.trim()
1786
- })).filter((account) => account.label !== "" || account.apiKeyEnv !== ""),
1787
- modelAccountRules: draft.modelAccountRules.map((rule) => ({
1788
- pattern: rule.pattern.trim(),
1789
- account: rule.account.trim()
1790
- })).filter((rule) => rule.pattern !== "" && rule.account !== ""),
1791
- stickySession: draft.stickySession,
1792
- visibleModels: draft.showAll ? [] : draft.visibleModels,
1793
- showAllModels: draft.showAll,
1794
- filterModelsByPlan: draft.filterModelsByPlan,
1795
- modelVisibility: draft.showAll ? draft.modelVisibility : Object.fromEntries(Object.entries(draft.modelVisibility).filter(([id, val]) => val === false || draft.visibleModels.includes(id))),
1796
- manualModels: draft.manualModels.filter((model) => model.id.trim() !== "").map((model) => ({
1797
- id: model.id.trim(),
1798
- enabled: model.enabled,
1799
- ...model.name.trim() === "" ? {} : { name: model.name.trim() },
1800
- ...numberOrNull(model.contextWindow) === null ? {} : { contextWindow: numberOrNull(model.contextWindow) },
1801
- ...numberOrNull(model.maxTokens) === null ? {} : { maxTokens: numberOrNull(model.maxTokens) },
1802
- image: model.image,
1803
- thinking: model.thinking,
1804
- ...stopList(model.reasoningEfforts).length === 0 ? {} : { reasoningEfforts: stopList(model.reasoningEfforts) },
1805
- ...model.defaultReasoning.trim() === "" ? {} : { defaultReasoning: model.defaultReasoning.trim() },
1806
- tools: model.tools
1807
- })),
1808
- modelOrder: draft.modelOrder.filter((id) => id !== ""),
1809
- contextWindowOverrides: Object.fromEntries(Object.entries(draft.contextWindowOverrides).map(([id, value]) => [id, numberOrNull(value)]).filter((entry) => entry[1] !== null && entry[1] > 0)),
1810
- priceOverrides: Object.fromEntries(Object.entries(draft.priceOverrides).map(([id, price]) => {
1811
- const out = {};
1812
- for (const [field, value] of Object.entries(price)) {
1813
- const parsed = numberOrNull(value);
1814
- if (parsed !== null) out[field] = parsed;
1815
- }
1816
- return [id, out];
1817
- }).filter((entry) => Object.keys(entry[1]).length > 0)),
1818
- modelOverrides: Object.fromEntries(Object.entries(draft.modelOverrides).map(([id, override]) => {
1819
- const contextWindow = numberOrNull(override.contextWindow);
1820
- const efforts = stopList(override.reasoningEfforts);
1821
- return [id, {
1822
- ...contextWindow === null || contextWindow <= 0 ? {} : { contextWindow },
1823
- ...override.image === "" ? {} : { image: override.image === "yes" },
1824
- ...override.thinking === "" ? {} : { thinking: override.thinking === "yes" },
1825
- ...efforts.length === 0 ? {} : { reasoningEfforts: efforts },
1826
- ...override.defaultEffort.trim() === "" ? {} : { defaultEffort: override.defaultEffort.trim() },
1827
- ...override.enabled === "" ? {} : { enabled: override.enabled === "yes" }
1828
- }];
1829
- }).filter((entry) => Object.keys(entry[1]).length > 0)),
1830
- modelTransports: Object.fromEntries(Object.entries(draft.modelTransports).filter(([, value]) => value !== ""))
1849
+ patch: {
1850
+ apiKeyEnv: draft.apiKeyEnv.trim(),
1851
+ apiBase: draft.apiBase.trim(),
1852
+ openAiBase: draft.openAiBase.trim(),
1853
+ usageUrl: draft.usageUrl.trim(),
1854
+ balanceUrl: draft.balanceUrl.trim(),
1855
+ transport: draft.transport,
1856
+ requestTimeoutMs: field("requestTimeoutMs", () => numberOrNull(draft.requestTimeoutMs, "requestTimeoutMs")),
1857
+ streamIdleTimeoutMs: field("streamIdleTimeoutMs", () => numberOrNull(draft.streamIdleTimeoutMs, "streamIdleTimeoutMs")),
1858
+ attemptTimeoutMs: field("attemptTimeoutMs", () => boundedNumber(draft.attemptTimeoutMs, 0, 36e5, true, "attemptTimeoutMs")),
1859
+ retryMaxRetries: field("retryMaxRetries", () => boundedNumber(draft.retryMaxRetries, 0, 10, true, "retryMaxRetries")),
1860
+ retryBaseDelayMs: field("retryBaseDelayMs", () => boundedNumber(draft.retryBaseDelayMs, 0, 6e4, true, "retryBaseDelayMs")),
1861
+ retryMaxDelayMs: field("retryMaxDelayMs", () => boundedNumber(draft.retryMaxDelayMs, 0, 12e4, true, "retryMaxDelayMs")),
1862
+ retryJitter: field("retryJitter", () => boundedNumber(draft.retryJitter, 0, 1, false, "retryJitter")),
1863
+ maxOutputTokens: field("maxOutputTokens", () => numberOrNull(draft.maxOutputTokens, "maxOutputTokens")),
1864
+ contextWindow: field("contextWindow", () => numberOrNull(draft.contextWindow, "contextWindow")),
1865
+ temperature: field("temperature", () => boundedNumber(draft.temperature, 0, 2, false, "temperature")),
1866
+ topK: field("topK", () => boundedNumber(draft.topK, 1, 1e6, true, "topK")),
1867
+ topP: field("topP", () => boundedNumber(draft.topP, 0, 1, false, "topP")),
1868
+ minP: field("minP", () => boundedNumber(draft.minP, 0, 1, false, "minP")),
1869
+ seed: field("seed", () => boundedNumber(draft.seed, 0, 4294967295, true, "seed")),
1870
+ repeatPenalty: field("repeatPenalty", () => boundedNumber(draft.repeatPenalty, 0, 2, false, "repeatPenalty")),
1871
+ repeatLastN: field("repeatLastN", () => boundedNumber(draft.repeatLastN, -1, 1e6, true, "repeatLastN")),
1872
+ numCtx: field("numCtx", () => boundedNumber(draft.numCtx, 1, 1e7, true, "numCtx")),
1873
+ keepAlive: draft.keepAlive.trim(),
1874
+ stop: stopList(draft.stop),
1875
+ autoRefresh: draft.autoRefresh,
1876
+ refreshMinutes: field("refreshMinutes", () => boundedNumber(draft.refreshMinutes, 0, 10080, true, "refreshMinutes")),
1877
+ showSidebarQuota: draft.showSidebarQuota,
1878
+ planLabel: draft.planLabel.trim(),
1879
+ activeAccount: draft.activeAccount.trim(),
1880
+ accounts: draft.accounts.map((account) => ({
1881
+ label: account.label.trim(),
1882
+ apiKeyEnv: account.apiKeyEnv.trim()
1883
+ })).filter((account) => account.label !== "" || account.apiKeyEnv !== ""),
1884
+ modelAccountRules: draft.modelAccountRules.map((rule) => ({
1885
+ pattern: rule.pattern.trim(),
1886
+ account: rule.account.trim()
1887
+ })).filter((rule) => rule.pattern !== "" && rule.account !== ""),
1888
+ stickySession: draft.stickySession,
1889
+ visibleModels: draft.showAll ? [] : draft.visibleModels,
1890
+ showAllModels: draft.showAll,
1891
+ filterModelsByPlan: draft.filterModelsByPlan,
1892
+ modelVisibility: draft.showAll ? draft.modelVisibility : Object.fromEntries(Object.entries(draft.modelVisibility).filter(([id, val]) => val === false || draft.visibleModels.includes(id))),
1893
+ manualModels,
1894
+ modelOrder: draft.modelOrder.filter((id) => id !== ""),
1895
+ contextWindowOverrides: field("contextWindowOverrides", () => Object.fromEntries(Object.entries(draft.contextWindowOverrides).map(([id, value]) => [id, numberOrNull(value, `contextWindowOverrides.${id}`)]).filter((entry) => entry[1] !== null && entry[1] > 0))) ?? {},
1896
+ priceOverrides: field("priceOverrides", () => Object.fromEntries(Object.entries(draft.priceOverrides).map(([id, price]) => {
1897
+ const out = {};
1898
+ for (const [name, value] of Object.entries(price)) {
1899
+ const parsed = numberOrNull(value, `priceOverrides.${id}.${name}`);
1900
+ if (parsed !== null) out[name] = parsed;
1901
+ }
1902
+ return [id, out];
1903
+ }).filter((entry) => Object.keys(entry[1]).length > 0))) ?? {},
1904
+ modelOverrides: field("modelOverrides", () => Object.fromEntries(Object.entries(draft.modelOverrides).map(([id, override]) => {
1905
+ const contextWindow = numberOrNull(override.contextWindow, `modelOverrides.${id}.contextWindow`);
1906
+ const efforts = stopList(override.reasoningEfforts);
1907
+ return [id, {
1908
+ ...contextWindow === null || contextWindow <= 0 ? {} : { contextWindow },
1909
+ ...override.image === "" ? {} : { image: override.image === "yes" },
1910
+ ...override.thinking === "" ? {} : { thinking: override.thinking === "yes" },
1911
+ ...efforts.length === 0 ? {} : { reasoningEfforts: efforts },
1912
+ ...override.defaultEffort.trim() === "" ? {} : { defaultEffort: override.defaultEffort.trim() },
1913
+ ...override.enabled === "" ? {} : { enabled: override.enabled === "yes" }
1914
+ }];
1915
+ }).filter((entry) => Object.keys(entry[1]).length > 0))) ?? {},
1916
+ modelTransports: Object.fromEntries(Object.entries(draft.modelTransports).filter(([, value]) => value !== ""))
1917
+ },
1918
+ errors
1831
1919
  };
1832
1920
  }
1921
+ function patchOf(draft) {
1922
+ const { patch, errors } = draftPatch(draft);
1923
+ const first = Object.values(errors)[0];
1924
+ if (first !== void 0) throw new Error(first);
1925
+ return patch;
1926
+ }
1833
1927
  function same(a, b) {
1834
1928
  return JSON.stringify(patchOf(a)) === JSON.stringify(patchOf(b));
1835
1929
  }
@@ -2210,8 +2304,13 @@ window.__ModuleLoader__.load({
2210
2304
  });
2211
2305
  }
2212
2306
  // src/client/settings-page.tsx
2307
+ let manualRowSeq = 0;
2308
+ function nextManualUid() {
2309
+ manualRowSeq += 1;
2310
+ return `manual-${Date.now().toString(36)}-${manualRowSeq}`;
2311
+ }
2213
2312
  function ModelEntry(props) {
2214
- const { model, visible, transport, onVisible, onTransport, onDragStart, onDrop, onEdit, dragging, t } = props;
2313
+ const { model, visible, transport, onVisible, onTransport, onDragStart, onDrop, onDragEnd, onEdit, dragging, t } = props;
2215
2314
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2216
2315
  className: `ocl-model${dragging === true ? " ocl-dragging" : ""}`,
2217
2316
  draggable: onDragStart !== void 0,
@@ -2220,6 +2319,7 @@ window.__ModuleLoader__.load({
2220
2319
  if (onDrop !== void 0) event.preventDefault();
2221
2320
  },
2222
2321
  onDrop,
2322
+ onDragEnd,
2223
2323
  children: [
2224
2324
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2225
2325
  className: "ocl-drag-handle",
@@ -2312,6 +2412,7 @@ window.__ModuleLoader__.load({
2312
2412
  function OllamaCloudSettingsPage(props) {
2313
2413
  const { t } = props;
2314
2414
  const [state, setState] = (0, react.useState)(null);
2415
+ const configWritable = state?.configWritable !== false;
2315
2416
  const [draft, setDraft] = (0, react.useState)(null);
2316
2417
  const [original, setOriginal] = (0, react.useState)(null);
2317
2418
  const [error, setError] = (0, react.useState)(null);
@@ -2362,9 +2463,15 @@ window.__ModuleLoader__.load({
2362
2463
  }, []);
2363
2464
  const save = (0, react.useCallback)(async () => {
2364
2465
  if (draft === null) return;
2466
+ const { patch, errors } = draftPatch(draft);
2467
+ const failed = Object.entries(errors);
2468
+ if (failed.length > 0) {
2469
+ setError(failed.map(([name, message]) => `${name}: ${message}`).join("; "));
2470
+ return;
2471
+ }
2365
2472
  setSaving(true);
2366
2473
  try {
2367
- await saveConfig(patchOf(draft));
2474
+ await saveConfig(patch);
2368
2475
  window.dispatchEvent(new Event(CONFIG_CHANGED_EVENT));
2369
2476
  setNotice(t("saved"));
2370
2477
  setError(null);
@@ -2473,6 +2580,7 @@ window.__ModuleLoader__.load({
2473
2580
  };
2474
2581
  const addManualModel = () => {
2475
2582
  update({ manualModels: [...draft.manualModels, {
2583
+ uid: nextManualUid(),
2476
2584
  id: "",
2477
2585
  enabled: true,
2478
2586
  name: "",
@@ -2527,10 +2635,11 @@ window.__ModuleLoader__.load({
2527
2635
  className: "ocl-notice",
2528
2636
  children: notice
2529
2637
  }),
2530
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2638
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
2531
2639
  className: "ocl-card",
2640
+ open: true,
2532
2641
  children: [
2533
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
2642
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
2534
2643
  className: "ocl-card-title",
2535
2644
  children: [
2536
2645
  t("key"),
@@ -2647,10 +2756,10 @@ window.__ModuleLoader__.load({
2647
2756
  })
2648
2757
  ]
2649
2758
  }),
2650
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2759
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
2651
2760
  className: "ocl-card",
2652
2761
  children: [
2653
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2762
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
2654
2763
  className: "ocl-card-title",
2655
2764
  children: t("serviceStatus")
2656
2765
  }),
@@ -2664,7 +2773,7 @@ window.__ModuleLoader__.load({
2664
2773
  children: [
2665
2774
  service.latencyMs,
2666
2775
  " ms · ",
2667
- new Date(service.checkedAt).toLocaleTimeString()
2776
+ formatTime(service.checkedAt)
2668
2777
  ]
2669
2778
  }),
2670
2779
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
@@ -2688,10 +2797,11 @@ window.__ModuleLoader__.load({
2688
2797
  })
2689
2798
  ]
2690
2799
  }),
2691
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2800
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
2692
2801
  className: "ocl-card",
2802
+ open: worst >= 80,
2693
2803
  children: [
2694
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
2804
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
2695
2805
  className: "ocl-card-title",
2696
2806
  children: [
2697
2807
  t("quota"),
@@ -2702,7 +2812,8 @@ window.__ModuleLoader__.load({
2702
2812
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2703
2813
  type: "button",
2704
2814
  className: "ocl-button",
2705
- onClick: () => {
2815
+ onClick: (event) => {
2816
+ event.stopPropagation();
2706
2817
  refresh();
2707
2818
  },
2708
2819
  children: t("refresh")
@@ -2744,10 +2855,10 @@ window.__ModuleLoader__.load({
2744
2855
  })
2745
2856
  ]
2746
2857
  }),
2747
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2858
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
2748
2859
  className: "ocl-card",
2749
2860
  children: [
2750
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
2861
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
2751
2862
  className: "ocl-card-title",
2752
2863
  children: [t("accounts"), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2753
2864
  className: "ocl-badge",
@@ -2814,11 +2925,11 @@ window.__ModuleLoader__.load({
2814
2925
  className: "ocl-accountUsage",
2815
2926
  children: [quotaBars(known.usage.report).map((bar) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2816
2927
  className: "ocl-badge",
2817
- title: bar.detail,
2818
- children: [bar.detail ?? `${bar.label}: ${bar.remainingPercent.toFixed(0)}% ${t("remaining")}`, bar.resetsAt === void 0 ? "" : ` · ${t("until")} ${new Date(bar.resetsAt).toLocaleDateString()}`]
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)}`]
2819
2930
  }, bar.key)), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2820
2931
  className: "ocl-hint",
2821
- children: new Date(known.usage.checkedAt).toLocaleTimeString()
2932
+ children: formatTime(known.usage.checkedAt)
2822
2933
  })]
2823
2934
  }),
2824
2935
  known?.usage?.report?.windows.d7 === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -2840,25 +2951,25 @@ window.__ModuleLoader__.load({
2840
2951
  type: "password",
2841
2952
  placeholder: t("pasteKey"),
2842
2953
  "aria-label": `${t("pasteKey")} (${account.label})`,
2843
- value: accountKeys[account.label] ?? "",
2954
+ value: accountKeys[index] ?? "",
2844
2955
  onChange: (event) => {
2845
2956
  setAccountKeys((current) => ({
2846
2957
  ...current,
2847
- [account.label]: event.target.value
2958
+ [index]: event.target.value
2848
2959
  }));
2849
2960
  }
2850
2961
  }),
2851
2962
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2852
2963
  type: "button",
2853
2964
  className: "ocl-button ocl-button-primary",
2854
- disabled: (accountKeys[account.label] ?? "").trim() === "",
2965
+ disabled: (accountKeys[index] ?? "").trim() === "",
2855
2966
  onClick: () => {
2856
2967
  const ref = account.apiKeyEnv.trim();
2857
2968
  if (ref === "") return;
2858
- saveKey(ref, (accountKeys[account.label] ?? "").trim()).then(() => {
2969
+ saveKey(ref, (accountKeys[index] ?? "").trim()).then(() => {
2859
2970
  setAccountKeys((current) => ({
2860
2971
  ...current,
2861
- [account.label]: ""
2972
+ [index]: ""
2862
2973
  }));
2863
2974
  setNotice(t("saved"));
2864
2975
  return load(true);
@@ -2933,10 +3044,10 @@ window.__ModuleLoader__.load({
2933
3044
  })
2934
3045
  ]
2935
3046
  }),
2936
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3047
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
2937
3048
  className: "ocl-card",
2938
3049
  children: [
2939
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3050
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
2940
3051
  className: "ocl-card-title",
2941
3052
  children: t("modelAccountRules")
2942
3053
  }),
@@ -2994,10 +3105,10 @@ window.__ModuleLoader__.load({
2994
3105
  })
2995
3106
  ]
2996
3107
  }),
2997
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3108
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
2998
3109
  className: "ocl-card",
2999
3110
  children: [
3000
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3111
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
3001
3112
  className: "ocl-card-title",
3002
3113
  children: t("routing")
3003
3114
  }),
@@ -3019,10 +3130,10 @@ window.__ModuleLoader__.load({
3019
3130
  })
3020
3131
  ]
3021
3132
  }),
3022
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3133
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
3023
3134
  className: "ocl-card",
3024
3135
  children: [
3025
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
3136
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
3026
3137
  className: "ocl-card-title",
3027
3138
  children: [
3028
3139
  t("models"),
@@ -3037,7 +3148,8 @@ window.__ModuleLoader__.load({
3037
3148
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3038
3149
  type: "button",
3039
3150
  className: "ocl-button",
3040
- onClick: () => {
3151
+ onClick: (event) => {
3152
+ event.stopPropagation();
3041
3153
  reloadModels();
3042
3154
  },
3043
3155
  children: t("refresh")
@@ -3045,20 +3157,26 @@ window.__ModuleLoader__.load({
3045
3157
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3046
3158
  type: "button",
3047
3159
  className: "ocl-button",
3048
- onClick: () => update({
3049
- showAll: true,
3050
- visibleModels: state.models.map((model) => model.id)
3051
- }),
3160
+ onClick: (event) => {
3161
+ event.stopPropagation();
3162
+ update({
3163
+ showAll: true,
3164
+ visibleModels: state.models.map((model) => model.id)
3165
+ });
3166
+ },
3052
3167
  children: t("showAll")
3053
3168
  }),
3054
3169
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3055
3170
  type: "button",
3056
3171
  className: "ocl-button",
3057
- onClick: () => update({
3058
- showAll: false,
3059
- visibleModels: [],
3060
- modelVisibility: {}
3061
- }),
3172
+ onClick: (event) => {
3173
+ event.stopPropagation();
3174
+ update({
3175
+ showAll: false,
3176
+ visibleModels: [],
3177
+ modelVisibility: {}
3178
+ });
3179
+ },
3062
3180
  children: t("hideAll")
3063
3181
  })
3064
3182
  ]
@@ -3164,6 +3282,7 @@ window.__ModuleLoader__.load({
3164
3282
  if (dragId !== null) moveModel(dragId, model.id);
3165
3283
  setDragId(null);
3166
3284
  },
3285
+ onDragEnd: () => setDragId(null),
3167
3286
  onEdit: () => setEditingModel(model.id),
3168
3287
  onVisible: (visible) => toggleModel(model.id, visible),
3169
3288
  onTransport: (transport) => {
@@ -3178,25 +3297,32 @@ window.__ModuleLoader__.load({
3178
3297
  })
3179
3298
  ]
3180
3299
  }),
3181
- editingModel !== null && state.models.some((model) => model.id === editingModel) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
3300
+ editingModel !== null && state.models.some((model) => model.id === editingModel) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
3182
3301
  className: "ocl-card",
3183
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelOverrideEditor, {
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, {
3184
3307
  model: state.models.find((model) => model.id === editingModel),
3185
3308
  draft,
3186
3309
  t,
3187
3310
  update,
3188
3311
  close: () => setEditingModel(null)
3189
- })
3312
+ })]
3190
3313
  }),
3191
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3314
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
3192
3315
  className: "ocl-card",
3193
3316
  children: [
3194
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
3317
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
3195
3318
  className: "ocl-card-title",
3196
3319
  children: [t("manualModels"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3197
3320
  type: "button",
3198
3321
  className: "ocl-button",
3199
- onClick: addManualModel,
3322
+ onClick: (event) => {
3323
+ event.stopPropagation();
3324
+ addManualModel();
3325
+ },
3200
3326
  children: t("addManualModel")
3201
3327
  })]
3202
3328
  }),
@@ -3284,13 +3410,13 @@ window.__ModuleLoader__.load({
3284
3410
  children: t("removeManualModel")
3285
3411
  })
3286
3412
  ]
3287
- }, `${model.id}-${index}`))
3413
+ }, model.uid))
3288
3414
  ]
3289
3415
  }),
3290
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3416
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
3291
3417
  className: "ocl-card",
3292
3418
  children: [
3293
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3419
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
3294
3420
  className: "ocl-card-title",
3295
3421
  children: t("generation")
3296
3422
  }),
@@ -3383,9 +3509,9 @@ window.__ModuleLoader__.load({
3383
3509
  })
3384
3510
  ]
3385
3511
  }),
3386
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3512
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
3387
3513
  className: "ocl-card",
3388
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3514
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
3389
3515
  className: "ocl-card-title",
3390
3516
  children: t("advanced")
3391
3517
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -3506,10 +3632,11 @@ window.__ModuleLoader__.load({
3506
3632
  ]
3507
3633
  })]
3508
3634
  }),
3509
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3635
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
3510
3636
  className: "ocl-card",
3637
+ open: discoverError !== null,
3511
3638
  children: [
3512
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3639
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
3513
3640
  className: "ocl-card-title",
3514
3641
  children: t("discover")
3515
3642
  }),
@@ -3585,10 +3712,10 @@ window.__ModuleLoader__.load({
3585
3712
  })
3586
3713
  ]
3587
3714
  }),
3588
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3715
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
3589
3716
  className: "ocl-card",
3590
3717
  children: [
3591
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3718
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
3592
3719
  className: "ocl-card-title",
3593
3720
  children: t("sidebar")
3594
3721
  }),
@@ -3613,12 +3740,16 @@ window.__ModuleLoader__.load({
3613
3740
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3614
3741
  type: "button",
3615
3742
  className: "ocl-button ocl-button-primary",
3616
- disabled: !dirty || saving,
3743
+ disabled: !dirty || saving || !configWritable,
3617
3744
  onClick: () => {
3618
3745
  save();
3619
3746
  },
3620
3747
  children: saving ? t("saving") : t("save")
3621
3748
  }),
3749
+ configWritable ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3750
+ className: "ocl-badge ocl-badge-warn",
3751
+ children: t("settingsReadOnly")
3752
+ }),
3622
3753
  dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3623
3754
  className: "ocl-badge ocl-badge-warn",
3624
3755
  children: t("unsaved")
@@ -3712,7 +3843,7 @@ window.__ModuleLoader__.load({
3712
3843
  className: "ocl-row",
3713
3844
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3714
3845
  className: "ocl-model-name",
3715
- children: bar.labelKey === void 0 ? bar.label : t(bar.labelKey)
3846
+ children: t(bar.labelKey ?? "quotaWindow")
3716
3847
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3717
3848
  className: "ocl-badge",
3718
3849
  children: [
@@ -3775,8 +3906,15 @@ window.__ModuleLoader__.load({
3775
3906
  .ocl-head { display: flex; flex-direction: column; gap: 4px; }
3776
3907
  .ocl-title { font-size: 18px; font-weight: 650; margin: 0; }
3777
3908
  .ocl-hint { font-size: 12px; opacity: 0.72; line-height: 1.5; margin: 0; }
3778
- .ocl-card { border: 1px solid var(--ocl-border); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--ocl-fill); }
3779
- .ocl-card-title { font-size: 13px; font-weight: 650; margin: 0; display: flex; align-items: center; gap: 8px; }
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; }
3780
3918
  .ocl-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
3781
3919
  .ocl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
3782
3920
  .ocl-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
@@ -3895,8 +4033,10 @@ window.__ModuleLoader__.load({
3895
4033
  * the sidebar, and the center panel it opens.
3896
4034
  */
3897
4035
  function apply(ctx) {
3898
- ctx.effect(() => ctx.locale.register(NS, "en", dictionaries.en), "dsh-ollama-cloud-provider: en copy");
3899
- ctx.effect(() => ctx.locale.register(NS, "zh", dictionaries.zh), "dsh-ollama-cloud-provider: zh copy");
4036
+ ctx.effect(() => ctx.locale.register(NS, {
4037
+ en: dictionaries.en,
4038
+ zh: dictionaries.zh
4039
+ }), "dsh-ollama-cloud-provider: dictionaries");
3900
4040
  ctx.effect(() => injectCss(), "dsh-ollama-cloud-provider: styles");
3901
4041
  const t = ctx.locale.bind(NS);
3902
4042
  const slots = ctx.slots;