@tradalab/lyra 3.15.0 → 3.17.0
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/README.md +2 -2
- package/dist/blocks/index.d.ts +121 -5
- package/dist/blocks/index.js +494 -169
- package/dist/blocks/index.js.map +1 -1
- package/dist/chunk-5XFDQRXV.js +9 -0
- package/dist/chunk-5XFDQRXV.js.map +1 -0
- package/dist/chunk-A3T2BEQH.js +45 -0
- package/dist/chunk-A3T2BEQH.js.map +1 -0
- package/dist/{chunk-4ILJ3M7K.js → chunk-ASSRDIKG.js} +138 -5
- package/dist/chunk-ASSRDIKG.js.map +1 -0
- package/dist/{chunk-U4HIZXI6.js → chunk-KSF233MC.js} +3 -3
- package/dist/chunk-KSF233MC.js.map +1 -0
- package/dist/{chunk-VEWKPOMS.js → chunk-OH3OMK7A.js} +13 -3
- package/dist/{chunk-VEWKPOMS.js.map → chunk-OH3OMK7A.js.map} +1 -1
- package/dist/chunk-UAZAKUTL.js +65 -0
- package/dist/chunk-UAZAKUTL.js.map +1 -0
- package/dist/{chunk-SQELPQZU.js → chunk-UNRT3B6P.js} +6 -16
- package/dist/chunk-UNRT3B6P.js.map +1 -0
- package/dist/connection-color-DxEs04ll.d.ts +54 -0
- package/dist/data-table/index.d.ts +182 -5
- package/dist/data-table/index.js +657 -78
- package/dist/data-table/index.js.map +1 -1
- package/dist/people/index.js +26 -10
- package/dist/people/index.js.map +1 -1
- package/dist/{plate-picker-CXxUGyNz.d.ts → plate-picker-dhKLjz_6.d.ts} +1 -1
- package/dist/shell/index.d.ts +4 -2
- package/dist/shell/index.js +11 -5
- package/dist/shell/index.js.map +1 -1
- package/dist/ui/index.d.ts +18 -2
- package/dist/ui/index.js +4 -4
- package/dist/utils/index.d.ts +27 -1
- package/dist/utils/index.js +3 -1
- package/package.json +3 -1
- package/dist/chunk-4ILJ3M7K.js.map +0 -1
- package/dist/chunk-PL37KFRJ.js +0 -3
- package/dist/chunk-PL37KFRJ.js.map +0 -1
- package/dist/chunk-SQELPQZU.js.map +0 -1
- package/dist/chunk-U4HIZXI6.js.map +0 -1
package/dist/blocks/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Label, Combobox, ComboboxInput, ComboboxContent, ComboboxEmpty, ComboboxList, ComboboxItem, Drawer, DrawerTrigger, DrawerContent, DrawerHeader, DrawerTitle, DrawerDescription, Spinner, Alert, AlertDescription, FieldGroup, FieldSet, FieldLegend, FieldDescription, Field, FieldContent, FieldLabel,
|
|
3
|
-
export { PreferenceScript } from '../chunk-
|
|
4
|
-
import { NativeSelect, NativeSelectOption } from '../chunk-
|
|
2
|
+
import { Label, Badge, Combobox, ComboboxInput, ComboboxContent, ComboboxEmpty, ComboboxList, ComboboxItem, Drawer, DrawerTrigger, DrawerContent, DrawerHeader, DrawerTitle, DrawerDescription, Spinner, Alert, AlertDescription, FieldGroup, FieldSet, FieldLegend, FieldDescription, Field, FieldContent, FieldLabel, FieldSeparator, Progress } from '../chunk-ASSRDIKG.js';
|
|
3
|
+
export { PreferenceScript } from '../chunk-ASSRDIKG.js';
|
|
4
|
+
import { NativeSelect, NativeSelectOption } from '../chunk-KSF233MC.js';
|
|
5
5
|
export { useCompact, usePlate } from '../chunk-AIULLZYM.js';
|
|
6
|
-
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, RadioGroup, RadioGroupItem, Switch } from '../chunk-
|
|
7
|
-
export { PlatePicker } from '../chunk-
|
|
6
|
+
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, RadioGroup, RadioGroupItem, Switch } from '../chunk-UNRT3B6P.js';
|
|
7
|
+
export { PlatePicker } from '../chunk-UNRT3B6P.js';
|
|
8
8
|
export { BEARING_PLATES, PLATES, derivePlate, isPlate } from '../chunk-D7DMRCDY.js';
|
|
9
|
-
import '../chunk-
|
|
9
|
+
import '../chunk-OH3OMK7A.js';
|
|
10
|
+
import { isConnectionColor, CONNECTION_COLOR_NAMES, CONNECTION_COLORS, addTag } from '../chunk-A3T2BEQH.js';
|
|
10
11
|
import { Dialog, DialogOverlay, DialogContent, DialogTitle, DialogDescription } from '../chunk-L4LQCVOF.js';
|
|
12
|
+
import { foldText } from '../chunk-5XFDQRXV.js';
|
|
11
13
|
import { Avatar, AvatarImage, AvatarFallback } from '../chunk-VXW3K5O5.js';
|
|
12
14
|
import { Button, Input } from '../chunk-VGOGWZCF.js';
|
|
13
15
|
import { cn } from '../chunk-XH55BHUU.js';
|
|
@@ -16,7 +18,7 @@ import { createContext, useState, useContext, useCallback, useMemo, useId } from
|
|
|
16
18
|
import { Slot } from 'radix-ui';
|
|
17
19
|
import { FormProvider, Controller, useFormContext } from 'react-hook-form';
|
|
18
20
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
19
|
-
import { ChevronRight, CheckIcon, CopyIcon, PlusIcon, FolderOpen, Folder, File } from 'lucide-react';
|
|
21
|
+
import { ChevronRight, XIcon, CheckIcon, CopyIcon, RefreshCwIcon, PlusIcon, ListIcon, FolderOpen, Folder, File } from 'lucide-react';
|
|
20
22
|
|
|
21
23
|
var Form = FormProvider;
|
|
22
24
|
var FormFieldContext = React5.createContext(null);
|
|
@@ -171,12 +173,8 @@ var useConfirm = () => {
|
|
|
171
173
|
};
|
|
172
174
|
|
|
173
175
|
// src/blocks/tree/data.ts
|
|
174
|
-
var ASCII = /^[ -~]*$/;
|
|
175
176
|
var DIGITS = /\d+/g;
|
|
176
|
-
var naturalKey = (name) =>
|
|
177
|
-
const s = ASCII.test(name) ? name.toLowerCase() : name.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().replace(/đ/g, "d");
|
|
178
|
-
return s.replace(DIGITS, (d) => d.padStart(20, "0"));
|
|
179
|
-
};
|
|
177
|
+
var naturalKey = (name) => foldText(name).replace(DIGITS, (d) => d.padStart(20, "0"));
|
|
180
178
|
var rank = (item) => item.isGroup ? 0 : 1;
|
|
181
179
|
var cmp = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
182
180
|
function sortTree(items, compare) {
|
|
@@ -585,6 +583,145 @@ var TreeIcon = ({ icon, hasChildren = false, className, ...props }) => {
|
|
|
585
583
|
return /* @__PURE__ */ jsx("div", { className: cn("mr-2 flex h-4 w-4 items-center justify-center text-muted-foreground transition-transform", className), ...props, children: icon || getDefaultIcon() });
|
|
586
584
|
};
|
|
587
585
|
var TreeLabel = ({ className, ...props }) => /* @__PURE__ */ jsx("span", { className: cn("font flex-1 truncate text-sm", className), ...props });
|
|
586
|
+
function StatTile({ label, value, tone = "default", className }) {
|
|
587
|
+
const bad = tone === "bad";
|
|
588
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "stat-tile", "data-tone": tone, className: cn("border p-2", bad && "border-destructive", className), children: [
|
|
589
|
+
/* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground", children: label }),
|
|
590
|
+
/* @__PURE__ */ jsx("p", { className: cn("font-mono text-lg tabular-nums", bad && "text-destructive"), children: value })
|
|
591
|
+
] });
|
|
592
|
+
}
|
|
593
|
+
function BarList({ items, className }) {
|
|
594
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "bar-list", className: cn("grid content-start gap-1", className), children: items.map((item) => {
|
|
595
|
+
const ratio = Number.isNaN(item.ratio) ? 0 : Math.min(1, Math.max(0, item.ratio));
|
|
596
|
+
const width = `${Math.round(ratio * 100)}%`;
|
|
597
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
598
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "absolute inset-y-0 left-0 bg-primary/10", style: { width } }),
|
|
599
|
+
/* @__PURE__ */ jsx("span", { className: "relative min-w-0 flex-1 truncate font-mono text-xs", children: item.label }),
|
|
600
|
+
/* @__PURE__ */ jsx("span", { className: "relative font-mono text-xs tabular-nums", children: item.value })
|
|
601
|
+
] });
|
|
602
|
+
const cls = "relative flex items-center gap-2 px-1 py-0.5 text-left";
|
|
603
|
+
return item.onSelect ? /* @__PURE__ */ jsx("button", { type: "button", title: item.label, className: cn(cls, "hover:bg-muted/50"), onClick: item.onSelect, children: body }, item.key) : /* @__PURE__ */ jsx("div", { title: item.label, className: cls, children: body }, item.key);
|
|
604
|
+
}) });
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// src/blocks/connection/storage.ts
|
|
608
|
+
function loadExpanded(key) {
|
|
609
|
+
try {
|
|
610
|
+
const raw = JSON.parse(globalThis.localStorage?.getItem(key) ?? "[]");
|
|
611
|
+
return new Set(Array.isArray(raw) ? raw.filter((x) => typeof x === "string") : []);
|
|
612
|
+
} catch {
|
|
613
|
+
return /* @__PURE__ */ new Set();
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
function saveExpanded(key, ids) {
|
|
617
|
+
try {
|
|
618
|
+
globalThis.localStorage?.setItem(key, JSON.stringify([...ids]));
|
|
619
|
+
} catch {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
function ColorSwatches({ value, onChange, emptyLabel, labels, className, ...aria }) {
|
|
624
|
+
const current = isConnectionColor(value) ? value : "";
|
|
625
|
+
return /* @__PURE__ */ jsxs("div", { role: "group", ...aria, className: cn("flex flex-wrap items-center gap-2", className), children: [
|
|
626
|
+
/* @__PURE__ */ jsx(
|
|
627
|
+
Swatch,
|
|
628
|
+
{
|
|
629
|
+
label: emptyLabel,
|
|
630
|
+
selected: current === "",
|
|
631
|
+
onSelect: () => onChange(""),
|
|
632
|
+
className: "border border-dashed border-muted-foreground/50"
|
|
633
|
+
}
|
|
634
|
+
),
|
|
635
|
+
CONNECTION_COLOR_NAMES.map((color) => /* @__PURE__ */ jsx(
|
|
636
|
+
Swatch,
|
|
637
|
+
{
|
|
638
|
+
label: labels?.[color] ?? color,
|
|
639
|
+
selected: current === color,
|
|
640
|
+
onSelect: () => onChange(color),
|
|
641
|
+
className: CONNECTION_COLORS[color].swatch
|
|
642
|
+
},
|
|
643
|
+
color
|
|
644
|
+
))
|
|
645
|
+
] });
|
|
646
|
+
}
|
|
647
|
+
function Swatch({ label, selected, onSelect, className }) {
|
|
648
|
+
return /* @__PURE__ */ jsx(
|
|
649
|
+
"button",
|
|
650
|
+
{
|
|
651
|
+
type: "button",
|
|
652
|
+
"aria-pressed": selected,
|
|
653
|
+
"aria-label": label,
|
|
654
|
+
title: label,
|
|
655
|
+
onClick: onSelect,
|
|
656
|
+
className: cn(
|
|
657
|
+
"size-5 shrink-0 cursor-pointer rounded-full ring-offset-background transition-shadow focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
|
|
658
|
+
selected && "ring-2 ring-foreground ring-offset-2",
|
|
659
|
+
className
|
|
660
|
+
)
|
|
661
|
+
}
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
function TagInput({ value, onChange, suggestions = [], placeholder, removeLabel, className, disabled, ...aria }) {
|
|
665
|
+
const listId = useId();
|
|
666
|
+
const [draft, setDraft] = useState("");
|
|
667
|
+
const tags = useMemo(() => (value ?? []).reduce(addTag, []), [value]);
|
|
668
|
+
const commit = () => {
|
|
669
|
+
const next = draft.split(",").reduce(addTag, tags);
|
|
670
|
+
if (next !== tags) onChange([...next]);
|
|
671
|
+
setDraft("");
|
|
672
|
+
};
|
|
673
|
+
const onKeyDown = (e) => {
|
|
674
|
+
if (e.nativeEvent.isComposing || e.keyCode === 229) return;
|
|
675
|
+
if (e.key === "Enter" || e.key === ",") {
|
|
676
|
+
e.preventDefault();
|
|
677
|
+
commit();
|
|
678
|
+
} else if (e.key === "Backspace" && draft === "" && tags.length > 0) {
|
|
679
|
+
onChange(tags.slice(0, -1));
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
return /* @__PURE__ */ jsxs(
|
|
683
|
+
"div",
|
|
684
|
+
{
|
|
685
|
+
className: cn(
|
|
686
|
+
"flex min-h-8 w-full flex-wrap items-center gap-1 border border-input bg-transparent px-2 py-1 text-xs dark:bg-input/30",
|
|
687
|
+
"focus-within:border-ring focus-within:ring-1 focus-within:ring-ring/50",
|
|
688
|
+
"has-[input[aria-invalid=true]]:border-destructive has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50",
|
|
689
|
+
className
|
|
690
|
+
),
|
|
691
|
+
children: [
|
|
692
|
+
tags.map((tag) => /* @__PURE__ */ jsxs(Badge, { variant: "secondary", className: "gap-1 pr-1", children: [
|
|
693
|
+
tag,
|
|
694
|
+
/* @__PURE__ */ jsx(
|
|
695
|
+
"button",
|
|
696
|
+
{
|
|
697
|
+
type: "button",
|
|
698
|
+
"aria-label": removeLabel ? removeLabel(tag) : `Remove ${tag}`,
|
|
699
|
+
disabled,
|
|
700
|
+
className: "text-muted-foreground hover:text-foreground",
|
|
701
|
+
onClick: () => onChange(tags.filter((x) => x !== tag)),
|
|
702
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "size-3" })
|
|
703
|
+
}
|
|
704
|
+
)
|
|
705
|
+
] }, tag)),
|
|
706
|
+
/* @__PURE__ */ jsx(
|
|
707
|
+
"input",
|
|
708
|
+
{
|
|
709
|
+
...aria,
|
|
710
|
+
disabled,
|
|
711
|
+
value: draft,
|
|
712
|
+
list: listId,
|
|
713
|
+
onChange: (e) => setDraft(e.target.value),
|
|
714
|
+
onKeyDown,
|
|
715
|
+
onBlur: commit,
|
|
716
|
+
placeholder: tags.length === 0 ? placeholder : void 0,
|
|
717
|
+
className: "min-w-24 flex-1 bg-transparent outline-none placeholder:text-muted-foreground"
|
|
718
|
+
}
|
|
719
|
+
),
|
|
720
|
+
/* @__PURE__ */ jsx("datalist", { id: listId, children: suggestions.reduce(addTag, []).filter((s) => !tags.some((x) => x.toLowerCase() === s.toLowerCase())).map((s) => /* @__PURE__ */ jsx("option", { value: s }, s)) })
|
|
721
|
+
]
|
|
722
|
+
}
|
|
723
|
+
);
|
|
724
|
+
}
|
|
588
725
|
var FALLBACK_ZONES = [
|
|
589
726
|
"UTC",
|
|
590
727
|
"Asia/Ho_Chi_Minh",
|
|
@@ -600,14 +737,22 @@ var FALLBACK_ZONES = [
|
|
|
600
737
|
"America/Los_Angeles"
|
|
601
738
|
];
|
|
602
739
|
var IANA_PRIMARY = {
|
|
740
|
+
"Africa/Asmera": "Africa/Asmara",
|
|
603
741
|
"America/Buenos_Aires": "America/Argentina/Buenos_Aires",
|
|
742
|
+
"America/Catamarca": "America/Argentina/Catamarca",
|
|
743
|
+
"America/Cordoba": "America/Argentina/Cordoba",
|
|
604
744
|
"America/Godthab": "America/Nuuk",
|
|
745
|
+
"America/Indianapolis": "America/Indiana/Indianapolis",
|
|
746
|
+
"America/Jujuy": "America/Argentina/Jujuy",
|
|
747
|
+
"America/Louisville": "America/Kentucky/Louisville",
|
|
748
|
+
"America/Mendoza": "America/Argentina/Mendoza",
|
|
605
749
|
"Asia/Calcutta": "Asia/Kolkata",
|
|
606
750
|
"Asia/Katmandu": "Asia/Kathmandu",
|
|
607
751
|
"Asia/Rangoon": "Asia/Yangon",
|
|
608
752
|
"Asia/Saigon": "Asia/Ho_Chi_Minh",
|
|
609
753
|
"Atlantic/Faeroe": "Atlantic/Faroe",
|
|
610
754
|
"Europe/Kiev": "Europe/Kyiv",
|
|
755
|
+
"Pacific/Enderbury": "Pacific/Kanton",
|
|
611
756
|
"Pacific/Ponape": "Pacific/Pohnpei",
|
|
612
757
|
"Pacific/Truk": "Pacific/Chuuk"
|
|
613
758
|
};
|
|
@@ -760,6 +905,22 @@ function AvatarTile({ src, alt, fallback, className }) {
|
|
|
760
905
|
/* @__PURE__ */ jsx(AvatarFallback, { className: "rounded-none text-xs", children: fallback })
|
|
761
906
|
] });
|
|
762
907
|
}
|
|
908
|
+
function AuthCard({ title, description, logo, brand, footer, children, className }) {
|
|
909
|
+
return /* @__PURE__ */ jsx("main", { className: cn("flex min-h-svh items-center justify-center p-4", className), children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-sm flex-col gap-6", children: [
|
|
910
|
+
logo || brand ? /* @__PURE__ */ jsxs("div", { "data-slot": "auth-card-brand", className: "flex items-center justify-center gap-2 font-semibold", children: [
|
|
911
|
+
logo,
|
|
912
|
+
brand ? /* @__PURE__ */ jsx("span", { children: brand }) : null
|
|
913
|
+
] }) : null,
|
|
914
|
+
/* @__PURE__ */ jsxs(Card, { children: [
|
|
915
|
+
/* @__PURE__ */ jsxs(CardHeader, { children: [
|
|
916
|
+
/* @__PURE__ */ jsx(CardTitle, { className: "text-xl", children: title }),
|
|
917
|
+
description ? /* @__PURE__ */ jsx(CardDescription, { children: description }) : null
|
|
918
|
+
] }),
|
|
919
|
+
children ? /* @__PURE__ */ jsx(CardContent, { children }) : null
|
|
920
|
+
] }),
|
|
921
|
+
footer
|
|
922
|
+
] }) });
|
|
923
|
+
}
|
|
763
924
|
function MobileSheet({ title, description, trigger, open, onOpenChange, className, children }) {
|
|
764
925
|
return /* @__PURE__ */ jsxs(Drawer, { open, onOpenChange, children: [
|
|
765
926
|
trigger && /* @__PURE__ */ jsx(DrawerTrigger, { asChild: true, children: trigger }),
|
|
@@ -1060,7 +1221,15 @@ var FALLBACK3 = {
|
|
|
1060
1221
|
keyRemove: "Remove key",
|
|
1061
1222
|
running: "Running on this computer",
|
|
1062
1223
|
addFound: "Add",
|
|
1063
|
-
retry: "Retry"
|
|
1224
|
+
retry: "Retry",
|
|
1225
|
+
readOnly: "These settings were saved by a newer version of this app, so they can only be read here.",
|
|
1226
|
+
driversFailed: "Provider types could not be loaded, so no provider can be added or edited.",
|
|
1227
|
+
driverUnknown: "This app does not know this provider's type, so it cannot be edited here.",
|
|
1228
|
+
refresh: "Refresh",
|
|
1229
|
+
models: "Models",
|
|
1230
|
+
modelsEmpty: "No model downloaded yet.",
|
|
1231
|
+
deleteModel: "Delete",
|
|
1232
|
+
pullPlaceholder: "Model name to download"
|
|
1064
1233
|
};
|
|
1065
1234
|
var CAPABILITY = {
|
|
1066
1235
|
chat: "chat",
|
|
@@ -1091,16 +1260,26 @@ function serves(slot, p) {
|
|
|
1091
1260
|
return slot.needs.every((c) => p.capabilities.includes(c)) && (!slot.local_only || p.local);
|
|
1092
1261
|
}
|
|
1093
1262
|
var pullKey = (provider, model) => `${provider}/${model}`;
|
|
1094
|
-
function
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1263
|
+
function totals(p) {
|
|
1264
|
+
let done = 0;
|
|
1265
|
+
let total = 0;
|
|
1266
|
+
for (const l of Object.values(p.layers)) {
|
|
1267
|
+
done += l.done;
|
|
1268
|
+
total += l.total;
|
|
1269
|
+
}
|
|
1270
|
+
return { done, total };
|
|
1271
|
+
}
|
|
1272
|
+
function LlmSettings({ api, labels, className, header, footer }) {
|
|
1099
1273
|
const t = { ...FALLBACK3, ...labels };
|
|
1274
|
+
const f = labels?.format ?? {};
|
|
1100
1275
|
const cap = (c) => labels?.capabilities?.[c] ?? CAPABILITY[c] ?? c;
|
|
1276
|
+
const size = (bytes) => f.size?.(bytes) ?? sizeOf(bytes);
|
|
1277
|
+
const nameOf = (pid) => api.providerName?.(pid) ?? pid;
|
|
1278
|
+
const slotLabel = (s) => f.slotLabel?.(s) ?? s.label;
|
|
1101
1279
|
const id = React5.useId();
|
|
1102
1280
|
const [state, setState] = React5.useState(null);
|
|
1103
1281
|
const [drivers, setDrivers] = React5.useState([]);
|
|
1282
|
+
const [driversError, setDriversError] = React5.useState(null);
|
|
1104
1283
|
const [found, setFound] = React5.useState([]);
|
|
1105
1284
|
const [loadError, setLoadError] = React5.useState(null);
|
|
1106
1285
|
const [error, setError] = React5.useState(null);
|
|
@@ -1111,22 +1290,29 @@ function LlmSettings({
|
|
|
1111
1290
|
const [models, setModels] = React5.useState({});
|
|
1112
1291
|
const [typed, setTyped] = React5.useState({});
|
|
1113
1292
|
const [pulls, setPulls] = React5.useState({});
|
|
1293
|
+
const [library, setLibrary] = React5.useState(null);
|
|
1294
|
+
const [pullName, setPullName] = React5.useState("");
|
|
1295
|
+
const failed = (err) => {
|
|
1296
|
+
if (!api.isCanceled?.(err)) setError(messageOf2(err));
|
|
1297
|
+
};
|
|
1114
1298
|
const load = React5.useCallback(() => {
|
|
1115
1299
|
setLoadError(null);
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
setDrivers(d);
|
|
1120
|
-
},
|
|
1121
|
-
(err) => setLoadError(messageOf2(err))
|
|
1122
|
-
);
|
|
1300
|
+
setDriversError(null);
|
|
1301
|
+
api.state().then(setState, (err) => setLoadError(messageOf2(err)));
|
|
1302
|
+
api.drivers().then(setDrivers, (err) => setDriversError(messageOf2(err)));
|
|
1123
1303
|
api.detect?.().then(setFound, () => {
|
|
1124
1304
|
});
|
|
1125
1305
|
}, [api]);
|
|
1126
1306
|
React5.useEffect(load, [load]);
|
|
1127
1307
|
React5.useEffect(() => {
|
|
1128
1308
|
if (!api.onPull) return;
|
|
1129
|
-
return api.onPull(
|
|
1309
|
+
return api.onPull(
|
|
1310
|
+
(p) => setPulls((prev) => {
|
|
1311
|
+
const key = pullKey(p.provider, p.model);
|
|
1312
|
+
const was = prev[key] ?? { provider: p.provider, model: p.model, status: "", layers: {} };
|
|
1313
|
+
return { ...prev, [key]: { ...was, status: p.status, layers: { ...was.layers, [p.digest ?? ""]: { done: p.done, total: p.total } } } };
|
|
1314
|
+
})
|
|
1315
|
+
);
|
|
1130
1316
|
}, [api]);
|
|
1131
1317
|
const listModels = React5.useCallback(
|
|
1132
1318
|
(provider2) => {
|
|
@@ -1147,12 +1333,36 @@ function LlmSettings({
|
|
|
1147
1333
|
setError(null);
|
|
1148
1334
|
try {
|
|
1149
1335
|
setState(await action());
|
|
1336
|
+
return true;
|
|
1150
1337
|
} catch (err) {
|
|
1151
|
-
|
|
1338
|
+
failed(err);
|
|
1339
|
+
return false;
|
|
1152
1340
|
} finally {
|
|
1153
1341
|
setBusy(false);
|
|
1154
1342
|
}
|
|
1155
1343
|
};
|
|
1344
|
+
const bindSlot = async (slot, provider2, model) => {
|
|
1345
|
+
if (await change(() => api.bind(slot, provider2, model))) api.onBound?.(slot, provider2, model);
|
|
1346
|
+
};
|
|
1347
|
+
const startPull = (provider2, model) => {
|
|
1348
|
+
const key = pullKey(provider2, model);
|
|
1349
|
+
const end = () => setPulls((prev) => {
|
|
1350
|
+
const rest = { ...prev };
|
|
1351
|
+
delete rest[key];
|
|
1352
|
+
return rest;
|
|
1353
|
+
});
|
|
1354
|
+
setPulls((prev) => ({ ...prev, [key]: { provider: provider2, model, status: "", layers: {} } }));
|
|
1355
|
+
api.pull?.(provider2, model).then(
|
|
1356
|
+
(done) => {
|
|
1357
|
+
end();
|
|
1358
|
+
if (done) listModels(provider2);
|
|
1359
|
+
},
|
|
1360
|
+
(err) => {
|
|
1361
|
+
end();
|
|
1362
|
+
failed(err);
|
|
1363
|
+
}
|
|
1364
|
+
);
|
|
1365
|
+
};
|
|
1156
1366
|
if (!state) {
|
|
1157
1367
|
if (!loadError) return /* @__PURE__ */ jsx(Spinner, { className });
|
|
1158
1368
|
return /* @__PURE__ */ jsx(Alert, { variant: "destructive", className, children: /* @__PURE__ */ jsxs(AlertDescription, { className: "flex items-center justify-between gap-3", children: [
|
|
@@ -1160,17 +1370,19 @@ function LlmSettings({
|
|
|
1160
1370
|
/* @__PURE__ */ jsx(Button, { size: "xs", variant: "outline", onClick: load, children: t.retry })
|
|
1161
1371
|
] }) });
|
|
1162
1372
|
}
|
|
1373
|
+
const readOnly = Boolean(state.read_only);
|
|
1374
|
+
const locked = busy || readOnly;
|
|
1163
1375
|
const provider = (pid) => state.providers.find((p) => p.id === pid);
|
|
1164
1376
|
const saveDraft = async () => {
|
|
1165
1377
|
if (!draft) return;
|
|
1166
1378
|
const d = drivers.find((x) => x.name === draft.driver);
|
|
1167
1379
|
const values = {};
|
|
1168
1380
|
const secrets = {};
|
|
1169
|
-
for (const
|
|
1170
|
-
if (
|
|
1171
|
-
if (draft.values[
|
|
1172
|
-
} else if (
|
|
1173
|
-
secrets[
|
|
1381
|
+
for (const f2 of d?.fields ?? []) {
|
|
1382
|
+
if (f2.kind !== "secret") {
|
|
1383
|
+
if (draft.values[f2.key]) values[f2.key] = draft.values[f2.key];
|
|
1384
|
+
} else if (f2.key in draft.secrets) {
|
|
1385
|
+
secrets[f2.key] = draft.secrets[f2.key];
|
|
1174
1386
|
}
|
|
1175
1387
|
}
|
|
1176
1388
|
setBusy(true);
|
|
@@ -1184,7 +1396,7 @@ function LlmSettings({
|
|
|
1184
1396
|
});
|
|
1185
1397
|
setDraft(null);
|
|
1186
1398
|
} catch (err) {
|
|
1187
|
-
setDraftError(messageOf2(err));
|
|
1399
|
+
if (!api.isCanceled?.(err)) setDraftError(messageOf2(err));
|
|
1188
1400
|
} finally {
|
|
1189
1401
|
setBusy(false);
|
|
1190
1402
|
}
|
|
@@ -1200,11 +1412,29 @@ function LlmSettings({
|
|
|
1200
1412
|
for (let i = 2; taken.has(pid); i++) pid = `${name}-${i}`;
|
|
1201
1413
|
return { driver, id: pid, values, secrets: {} };
|
|
1202
1414
|
};
|
|
1415
|
+
const removeProvider = (p) => {
|
|
1416
|
+
if (api.confirmsDelete) void change(() => api.deleteProvider(p.id));
|
|
1417
|
+
else setRemoving(p.id);
|
|
1418
|
+
};
|
|
1419
|
+
const removeModel = async (pid, model) => {
|
|
1420
|
+
setRemoving(null);
|
|
1421
|
+
setBusy(true);
|
|
1422
|
+
setError(null);
|
|
1423
|
+
try {
|
|
1424
|
+
await api.deleteModel?.(pid, model);
|
|
1425
|
+
listModels(pid);
|
|
1426
|
+
} catch (err) {
|
|
1427
|
+
failed(err);
|
|
1428
|
+
} finally {
|
|
1429
|
+
setBusy(false);
|
|
1430
|
+
}
|
|
1431
|
+
};
|
|
1203
1432
|
const form = (d) => {
|
|
1204
1433
|
const spec = drivers.find((x) => x.name === d.driver);
|
|
1205
1434
|
const set = (patch) => setDraft({ ...d, ...patch });
|
|
1206
1435
|
return /* @__PURE__ */ jsxs("div", { className: "bg-muted/30 flex flex-col gap-3 border px-3 py-3", "data-testid": "provider-form", children: [
|
|
1207
1436
|
draftError ? /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsx(AlertDescription, { children: draftError }) }) : null,
|
|
1437
|
+
d.existing && !spec ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: t.driverUnknown }) : null,
|
|
1208
1438
|
d.existing ? null : /* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [
|
|
1209
1439
|
/* @__PURE__ */ jsxs(Field, { children: [
|
|
1210
1440
|
/* @__PURE__ */ jsx(FieldLabel, { htmlFor: `${id}-driver`, children: t.driver }),
|
|
@@ -1216,23 +1446,25 @@ function LlmSettings({
|
|
|
1216
1446
|
/* @__PURE__ */ jsx(FieldDescription, { children: t.idHint })
|
|
1217
1447
|
] })
|
|
1218
1448
|
] }),
|
|
1219
|
-
spec?.fields.map((
|
|
1220
|
-
const fid = `${id}-f-${
|
|
1221
|
-
|
|
1222
|
-
|
|
1449
|
+
spec?.fields.map((fd) => {
|
|
1450
|
+
const fid = `${id}-f-${fd.key}`;
|
|
1451
|
+
const label = f.fieldLabel?.(d.driver, fd) ?? fd.label;
|
|
1452
|
+
const description = f.fieldDescription?.(d.driver, fd) ?? fd.description;
|
|
1453
|
+
if (fd.kind === "bool") {
|
|
1454
|
+
const on = (d.values[fd.key] ?? fd.default ?? "false") === "true";
|
|
1223
1455
|
return /* @__PURE__ */ jsxs(Field, { orientation: "horizontal", children: [
|
|
1224
1456
|
/* @__PURE__ */ jsxs(FieldContent, { children: [
|
|
1225
|
-
/* @__PURE__ */ jsx(FieldLabel, { htmlFor: fid, children:
|
|
1226
|
-
|
|
1457
|
+
/* @__PURE__ */ jsx(FieldLabel, { htmlFor: fid, children: label }),
|
|
1458
|
+
description ? /* @__PURE__ */ jsx(FieldDescription, { children: description }) : null
|
|
1227
1459
|
] }),
|
|
1228
|
-
/* @__PURE__ */ jsx(Switch, { id: fid, size: "sm", checked: on, onCheckedChange: (v) => set({ values: { ...d.values, [
|
|
1229
|
-
] },
|
|
1460
|
+
/* @__PURE__ */ jsx(Switch, { id: fid, size: "sm", checked: on, onCheckedChange: (v) => set({ values: { ...d.values, [fd.key]: v ? "true" : "false" } }) })
|
|
1461
|
+
] }, fd.key);
|
|
1230
1462
|
}
|
|
1231
|
-
if (
|
|
1232
|
-
const saved = d.existing?.secrets.includes(
|
|
1233
|
-
const cleared = d.secrets[
|
|
1463
|
+
if (fd.kind === "secret") {
|
|
1464
|
+
const saved = d.existing?.secrets.includes(fd.key) ?? false;
|
|
1465
|
+
const cleared = d.secrets[fd.key] === "" && saved;
|
|
1234
1466
|
return /* @__PURE__ */ jsxs(Field, { children: [
|
|
1235
|
-
/* @__PURE__ */ jsx(FieldLabel, { htmlFor: fid, children:
|
|
1467
|
+
/* @__PURE__ */ jsx(FieldLabel, { htmlFor: fid, children: label }),
|
|
1236
1468
|
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
1237
1469
|
/* @__PURE__ */ jsx(
|
|
1238
1470
|
Input,
|
|
@@ -1241,52 +1473,123 @@ function LlmSettings({
|
|
|
1241
1473
|
type: "password",
|
|
1242
1474
|
autoComplete: "off",
|
|
1243
1475
|
placeholder: saved && !cleared ? t.keyKeep : void 0,
|
|
1244
|
-
value: d.secrets[
|
|
1476
|
+
value: d.secrets[fd.key] ?? "",
|
|
1245
1477
|
onChange: (e) => {
|
|
1246
|
-
const secrets = { ...d.secrets, [
|
|
1247
|
-
if (e.target.value === "" && !cleared) delete secrets[
|
|
1478
|
+
const secrets = { ...d.secrets, [fd.key]: e.target.value };
|
|
1479
|
+
if (e.target.value === "" && !cleared) delete secrets[fd.key];
|
|
1248
1480
|
set({ secrets });
|
|
1249
1481
|
}
|
|
1250
1482
|
}
|
|
1251
1483
|
),
|
|
1252
|
-
saved && !cleared ? /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => set({ secrets: { ...d.secrets, [
|
|
1484
|
+
saved && !cleared ? /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => set({ secrets: { ...d.secrets, [fd.key]: "" } }), children: t.keyRemove }) : null
|
|
1253
1485
|
] }),
|
|
1254
|
-
|
|
1255
|
-
] },
|
|
1486
|
+
description ? /* @__PURE__ */ jsx(FieldDescription, { children: description }) : null
|
|
1487
|
+
] }, fd.key);
|
|
1256
1488
|
}
|
|
1257
1489
|
return /* @__PURE__ */ jsxs(Field, { children: [
|
|
1258
|
-
/* @__PURE__ */ jsx(FieldLabel, { htmlFor: fid, children:
|
|
1490
|
+
/* @__PURE__ */ jsx(FieldLabel, { htmlFor: fid, children: label }),
|
|
1259
1491
|
/* @__PURE__ */ jsx(
|
|
1260
1492
|
Input,
|
|
1261
1493
|
{
|
|
1262
1494
|
id: fid,
|
|
1263
|
-
type:
|
|
1495
|
+
type: fd.kind === "url" ? "url" : "text",
|
|
1264
1496
|
spellCheck: false,
|
|
1265
|
-
placeholder:
|
|
1266
|
-
required:
|
|
1267
|
-
value: d.values[
|
|
1268
|
-
onChange: (e) => set({ values: { ...d.values, [
|
|
1497
|
+
placeholder: fd.default,
|
|
1498
|
+
required: fd.required,
|
|
1499
|
+
value: d.values[fd.key] ?? "",
|
|
1500
|
+
onChange: (e) => set({ values: { ...d.values, [fd.key]: e.target.value } })
|
|
1269
1501
|
}
|
|
1270
1502
|
),
|
|
1271
|
-
|
|
1272
|
-
] },
|
|
1503
|
+
description ? /* @__PURE__ */ jsx(FieldDescription, { children: description }) : null
|
|
1504
|
+
] }, fd.key);
|
|
1273
1505
|
}),
|
|
1274
1506
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
1275
1507
|
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", disabled: busy, onClick: () => setDraft(null), children: t.cancel }),
|
|
1276
|
-
/* @__PURE__ */ jsx(Button, { size: "sm", disabled:
|
|
1508
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", disabled: locked || !d.id || !spec, onClick: () => void saveDraft(), children: t.save })
|
|
1277
1509
|
] })
|
|
1278
1510
|
] });
|
|
1279
1511
|
};
|
|
1280
|
-
const
|
|
1512
|
+
const progress = (p, testId) => {
|
|
1513
|
+
const { done, total } = totals(p);
|
|
1514
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", "data-testid": testId, children: [
|
|
1515
|
+
/* @__PURE__ */ jsx(Progress, { className: "flex-1", value: total > 0 ? done / total * 100 : 0 }),
|
|
1516
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground w-28 text-right text-xs tabular-nums", children: total > 0 ? `${size(done)} / ${size(total)}` : f.pullStatus?.(p.status) ?? p.status }),
|
|
1517
|
+
api.cancelPull ? /* @__PURE__ */ jsx(Button, { size: "xs", variant: "ghost", onClick: () => void api.cancelPull?.(p.provider, p.model), children: t.cancel }) : null
|
|
1518
|
+
] });
|
|
1519
|
+
};
|
|
1520
|
+
const modelLibrary = (p) => {
|
|
1521
|
+
const list = models[p.id];
|
|
1522
|
+
const pending = Object.values(pulls).filter((x) => x.provider === p.id);
|
|
1523
|
+
const slots = state.slots.filter((s) => serves(s, p));
|
|
1524
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-muted/30 flex flex-col gap-2 border-t px-3 py-3", "data-testid": `models-${p.id}`, children: [
|
|
1525
|
+
list === void 0 ? /* @__PURE__ */ jsx(Spinner, {}) : list.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: t.modelsEmpty }) : /* @__PURE__ */ jsx("ul", { className: "divide-y border", children: list.map((m) => {
|
|
1526
|
+
const confirm = removing === `model:${p.id}/${m.id}`;
|
|
1527
|
+
return /* @__PURE__ */ jsxs("li", { className: "flex flex-wrap items-center gap-2 px-3 py-2", "data-testid": `model-${m.id}`, children: [
|
|
1528
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate font-mono text-xs", children: m.id }),
|
|
1529
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: [m.parameter_size, m.quantization, m.size ? size(m.size) : ""].filter(Boolean).join(" \xB7 ") }),
|
|
1530
|
+
slots.filter((s) => !(s.provider === p.id && s.model === m.id)).map((s) => /* @__PURE__ */ jsx(Button, { size: "xs", variant: "outline", disabled: locked, onClick: () => void bindSlot(s.name, p.id, m.id), children: f.useFor?.(slotLabel(s)) ?? `Use for ${slotLabel(s)}` }, s.name)),
|
|
1531
|
+
api.deleteModel ? confirm ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1532
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", variant: "ghost", onClick: () => setRemoving(null), children: t.keep }),
|
|
1533
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", variant: "destructive", disabled: locked, onClick: () => void removeModel(p.id, m.id), children: t.deleteModel })
|
|
1534
|
+
] }) : /* @__PURE__ */ jsx(
|
|
1535
|
+
Button,
|
|
1536
|
+
{
|
|
1537
|
+
size: "xs",
|
|
1538
|
+
variant: "ghost",
|
|
1539
|
+
disabled: locked,
|
|
1540
|
+
onClick: () => api.confirmsDelete ? void removeModel(p.id, m.id) : setRemoving(`model:${p.id}/${m.id}`),
|
|
1541
|
+
children: t.deleteModel
|
|
1542
|
+
}
|
|
1543
|
+
) : null
|
|
1544
|
+
] }, m.id);
|
|
1545
|
+
}) }),
|
|
1546
|
+
pending.map((x) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1547
|
+
/* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: x.model }),
|
|
1548
|
+
progress(x, `library-pull-${x.model}`)
|
|
1549
|
+
] }, x.model)),
|
|
1550
|
+
api.pull ? /* @__PURE__ */ jsxs(
|
|
1551
|
+
"form",
|
|
1552
|
+
{
|
|
1553
|
+
className: "flex gap-2",
|
|
1554
|
+
onSubmit: (e) => {
|
|
1555
|
+
e.preventDefault();
|
|
1556
|
+
const name = pullName.trim();
|
|
1557
|
+
if (!name) return;
|
|
1558
|
+
startPull(p.id, name);
|
|
1559
|
+
setPullName("");
|
|
1560
|
+
},
|
|
1561
|
+
children: [
|
|
1562
|
+
/* @__PURE__ */ jsx(
|
|
1563
|
+
Input,
|
|
1564
|
+
{
|
|
1565
|
+
"aria-label": t.pullPlaceholder,
|
|
1566
|
+
placeholder: t.pullPlaceholder,
|
|
1567
|
+
spellCheck: false,
|
|
1568
|
+
disabled: locked,
|
|
1569
|
+
value: pullName,
|
|
1570
|
+
onChange: (e) => setPullName(e.target.value)
|
|
1571
|
+
}
|
|
1572
|
+
),
|
|
1573
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", size: "sm", variant: "outline", disabled: locked || !pullName.trim(), children: t.download })
|
|
1574
|
+
]
|
|
1575
|
+
}
|
|
1576
|
+
) : null
|
|
1577
|
+
] });
|
|
1578
|
+
};
|
|
1579
|
+
const unused = found.filter((f2) => !state.providers.some((p) => p.values.base_url === f2.base_url));
|
|
1281
1580
|
return (
|
|
1282
1581
|
// min-w-0 on every FieldSet: a fieldset is min-content wide by default, so one long URL
|
|
1283
1582
|
// would widen the whole screen instead of truncating.
|
|
1284
1583
|
/* @__PURE__ */ jsxs(FieldGroup, { className, children: [
|
|
1584
|
+
readOnly ? /* @__PURE__ */ jsx(Alert, { "data-testid": "llm-read-only", children: /* @__PURE__ */ jsx(AlertDescription, { children: t.readOnly }) }) : null,
|
|
1285
1585
|
error ? /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsx(AlertDescription, { children: error }) }) : null,
|
|
1586
|
+
header,
|
|
1286
1587
|
/* @__PURE__ */ jsxs(FieldSet, { className: "min-w-0", children: [
|
|
1287
1588
|
/* @__PURE__ */ jsx(FieldLegend, { children: t.slots }),
|
|
1288
1589
|
/* @__PURE__ */ jsx(FieldDescription, { children: t.slotsHint }),
|
|
1289
1590
|
/* @__PURE__ */ jsx("ul", { className: "divide-y border", children: state.slots.map((slot) => {
|
|
1591
|
+
const label = slotLabel(slot);
|
|
1592
|
+
const description = f.slotDescription?.(slot) ?? slot.description;
|
|
1290
1593
|
const current = provider(slot.provider);
|
|
1291
1594
|
const choices = state.providers.filter((p) => p.id === slot.provider || serves(slot, p));
|
|
1292
1595
|
const known = slot.provider ? models[slot.provider] : void 0;
|
|
@@ -1297,25 +1600,25 @@ function LlmSettings({
|
|
|
1297
1600
|
const missing = known !== void 0 && chosen !== "" && !known.some((m) => m.id === chosen);
|
|
1298
1601
|
const commit = () => {
|
|
1299
1602
|
if (!slot.provider || draftModel === (slot.model ?? "")) return;
|
|
1300
|
-
void
|
|
1603
|
+
void bindSlot(slot.name, slot.provider, draftModel);
|
|
1301
1604
|
};
|
|
1302
1605
|
return /* @__PURE__ */ jsxs("li", { className: "flex flex-col gap-2 px-3 py-3", "data-testid": `slot-${slot.name}`, children: [
|
|
1303
1606
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start gap-x-6 gap-y-2", children: [
|
|
1304
1607
|
/* @__PURE__ */ jsxs("div", { className: "min-w-40 flex-1", children: [
|
|
1305
1608
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1306
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children:
|
|
1609
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: label }),
|
|
1307
1610
|
slot.local_only ? /* @__PURE__ */ jsx(Badge, { variant: "outline", title: t.localOnlyHint, children: t.localOnly }) : null
|
|
1308
1611
|
] }),
|
|
1309
|
-
|
|
1612
|
+
description ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: description }) : null
|
|
1310
1613
|
] }),
|
|
1311
1614
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full gap-2 sm:w-auto", children: [
|
|
1312
1615
|
/* @__PURE__ */ jsxs(
|
|
1313
1616
|
NativeSelect,
|
|
1314
1617
|
{
|
|
1315
|
-
"aria-label": `${
|
|
1618
|
+
"aria-label": f.slotProvider?.(label) ?? `${label}: ${t.providers}`,
|
|
1316
1619
|
className: "sm:w-40",
|
|
1317
1620
|
value: slot.provider ?? "",
|
|
1318
|
-
disabled:
|
|
1621
|
+
disabled: locked,
|
|
1319
1622
|
onChange: (e) => {
|
|
1320
1623
|
const next = e.target.value;
|
|
1321
1624
|
setTyped((prev) => {
|
|
@@ -1323,24 +1626,42 @@ function LlmSettings({
|
|
|
1323
1626
|
delete rest[slot.name];
|
|
1324
1627
|
return rest;
|
|
1325
1628
|
});
|
|
1326
|
-
|
|
1629
|
+
if (!next) {
|
|
1630
|
+
void change(() => api.unbind(slot.name));
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
const was = slot.model ?? "";
|
|
1634
|
+
const have = models[next];
|
|
1635
|
+
const keep = (list) => was && list.some((m) => m.id === was) ? was : "";
|
|
1636
|
+
if (have || !was) {
|
|
1637
|
+
void bindSlot(slot.name, next, keep(have ?? []));
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
setBusy(true);
|
|
1641
|
+
api.models(next).then(
|
|
1642
|
+
(ms) => {
|
|
1643
|
+
setModels((prev) => ({ ...prev, [next]: ms }));
|
|
1644
|
+
void bindSlot(slot.name, next, keep(ms));
|
|
1645
|
+
},
|
|
1646
|
+
() => void bindSlot(slot.name, next, "")
|
|
1647
|
+
);
|
|
1327
1648
|
},
|
|
1328
1649
|
children: [
|
|
1329
1650
|
/* @__PURE__ */ jsx(NativeSelectOption, { value: "", children: t.notSet }),
|
|
1330
|
-
choices.map((p) => /* @__PURE__ */ jsx(NativeSelectOption, { value: p.id, children: p.id }, p.id))
|
|
1651
|
+
choices.map((p) => /* @__PURE__ */ jsx(NativeSelectOption, { value: p.id, children: nameOf(p.id) }, p.id))
|
|
1331
1652
|
]
|
|
1332
1653
|
}
|
|
1333
1654
|
),
|
|
1334
1655
|
/* @__PURE__ */ jsx(
|
|
1335
1656
|
Input,
|
|
1336
1657
|
{
|
|
1337
|
-
"aria-label": `${
|
|
1658
|
+
"aria-label": f.slotModel?.(label) ?? `${label}: ${t.model}`,
|
|
1338
1659
|
title: t.modelHint,
|
|
1339
1660
|
className: "sm:w-56 [&::-webkit-calendar-picker-indicator]:opacity-30",
|
|
1340
1661
|
list: `${id}-models-${slot.name}`,
|
|
1341
1662
|
spellCheck: false,
|
|
1342
1663
|
placeholder: t.model,
|
|
1343
|
-
disabled:
|
|
1664
|
+
disabled: locked || !slot.provider,
|
|
1344
1665
|
value: draftModel,
|
|
1345
1666
|
onChange: (e) => setTyped((prev) => ({ ...prev, [slot.name]: e.target.value })),
|
|
1346
1667
|
onBlur: commit,
|
|
@@ -1349,51 +1670,16 @@ function LlmSettings({
|
|
|
1349
1670
|
}
|
|
1350
1671
|
}
|
|
1351
1672
|
),
|
|
1352
|
-
/* @__PURE__ */ jsx("datalist", { id: `${id}-models-${slot.name}`, children: known?.map((m) => /* @__PURE__ */ jsx("option", { value: m.id, children: [m.parameter_size, m.quantization, m.size ?
|
|
1673
|
+
/* @__PURE__ */ jsx("datalist", { id: `${id}-models-${slot.name}`, children: known?.map((m) => /* @__PURE__ */ jsx("option", { value: m.id, children: [m.parameter_size, m.quantization, m.size ? size(m.size) : ""].filter(Boolean).join(" \xB7 ") }, m.id)) })
|
|
1353
1674
|
] })
|
|
1354
1675
|
] }),
|
|
1355
1676
|
slot.error ? /* @__PURE__ */ jsx("p", { className: "text-destructive text-xs", children: slot.error }) : null,
|
|
1356
1677
|
api.slotNote?.(slot.name),
|
|
1357
1678
|
current?.manages && api.pull && missing && !pulling ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-3", children: [
|
|
1358
1679
|
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: t.notDownloaded }),
|
|
1359
|
-
/* @__PURE__ */
|
|
1360
|
-
Button,
|
|
1361
|
-
{
|
|
1362
|
-
size: "xs",
|
|
1363
|
-
variant: "outline",
|
|
1364
|
-
disabled: busy,
|
|
1365
|
-
onClick: () => {
|
|
1366
|
-
const key = pullKey(current.id, chosen);
|
|
1367
|
-
const end = () => setPulls((prev) => {
|
|
1368
|
-
const rest = { ...prev };
|
|
1369
|
-
delete rest[key];
|
|
1370
|
-
return rest;
|
|
1371
|
-
});
|
|
1372
|
-
setPulls((prev) => ({ ...prev, [key]: { provider: current.id, model: chosen, status: "", done: 0, total: 0 } }));
|
|
1373
|
-
api.pull?.(current.id, chosen).then(
|
|
1374
|
-
(done) => {
|
|
1375
|
-
end();
|
|
1376
|
-
if (done) listModels(current.id);
|
|
1377
|
-
},
|
|
1378
|
-
(err) => {
|
|
1379
|
-
end();
|
|
1380
|
-
setError(messageOf2(err));
|
|
1381
|
-
}
|
|
1382
|
-
);
|
|
1383
|
-
},
|
|
1384
|
-
children: [
|
|
1385
|
-
t.download,
|
|
1386
|
-
" ",
|
|
1387
|
-
chosen
|
|
1388
|
-
]
|
|
1389
|
-
}
|
|
1390
|
-
)
|
|
1680
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", variant: "outline", disabled: locked, onClick: () => startPull(current.id, chosen), children: f.downloadModel?.(chosen) ?? `${t.download} ${chosen}` })
|
|
1391
1681
|
] }) : null,
|
|
1392
|
-
pulling && current ?
|
|
1393
|
-
/* @__PURE__ */ jsx(Progress, { className: "flex-1", value: pull.total > 0 ? pull.done / pull.total * 100 : 0 }),
|
|
1394
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground w-28 text-right text-xs tabular-nums", children: pull.total > 0 ? `${sizeOf(pull.done)} / ${sizeOf(pull.total)}` : pull.status }),
|
|
1395
|
-
api.cancelPull ? /* @__PURE__ */ jsx(Button, { size: "xs", variant: "ghost", onClick: () => void api.cancelPull?.(current.id, pull.model), children: t.cancel }) : null
|
|
1396
|
-
] }) : null
|
|
1682
|
+
pulling && current ? progress(pull, `pull-${slot.name}`) : null
|
|
1397
1683
|
] }, slot.name);
|
|
1398
1684
|
}) })
|
|
1399
1685
|
] }),
|
|
@@ -1404,95 +1690,134 @@ function LlmSettings({
|
|
|
1404
1690
|
/* @__PURE__ */ jsx(FieldLegend, { children: t.providers }),
|
|
1405
1691
|
/* @__PURE__ */ jsx(FieldDescription, { children: t.providersHint })
|
|
1406
1692
|
] }),
|
|
1407
|
-
/* @__PURE__ */ jsxs(
|
|
1408
|
-
Button,
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1693
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
1694
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", disabled: busy, "aria-label": t.refresh, title: t.refresh, onClick: () => {
|
|
1695
|
+
setModels({});
|
|
1696
|
+
load();
|
|
1697
|
+
}, children: /* @__PURE__ */ jsx(RefreshCwIcon, {}) }),
|
|
1698
|
+
/* @__PURE__ */ jsxs(
|
|
1699
|
+
Button,
|
|
1700
|
+
{
|
|
1701
|
+
size: "sm",
|
|
1702
|
+
variant: "outline",
|
|
1703
|
+
disabled: locked || drivers.length === 0,
|
|
1704
|
+
onClick: () => startDraft(newDraft(drivers[0]?.name ?? "")),
|
|
1705
|
+
children: [
|
|
1706
|
+
/* @__PURE__ */ jsx(PlusIcon, {}),
|
|
1707
|
+
t.add
|
|
1708
|
+
]
|
|
1709
|
+
}
|
|
1710
|
+
)
|
|
1711
|
+
] })
|
|
1420
1712
|
] }),
|
|
1713
|
+
driversError ? /* @__PURE__ */ jsxs("p", { className: "text-destructive text-xs", "data-testid": "drivers-failed", children: [
|
|
1714
|
+
t.driversFailed,
|
|
1715
|
+
" ",
|
|
1716
|
+
driversError
|
|
1717
|
+
] }) : null,
|
|
1421
1718
|
draft && !draft.existing ? form(draft) : null,
|
|
1422
1719
|
state.providers.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: t.providersEmpty }) : /* @__PURE__ */ jsx("ul", { className: "divide-y border", children: state.providers.map(
|
|
1423
|
-
(p) => draft?.existing?.id === p.id ? /* @__PURE__ */ jsx("li", { className: "p-0", children: form(draft) }, p.id) : /* @__PURE__ */ jsxs("li", {
|
|
1424
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1425
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
1426
|
-
/* @__PURE__ */
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1720
|
+
(p) => draft?.existing?.id === p.id ? /* @__PURE__ */ jsx("li", { className: "p-0", children: form(draft) }, p.id) : /* @__PURE__ */ jsxs("li", { "data-testid": `provider-${p.id}`, children: [
|
|
1721
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-3 py-2", children: [
|
|
1722
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
1723
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1724
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium", children: nameOf(p.id) }),
|
|
1725
|
+
p.driver !== p.id ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: p.driver ?? t.byApp }) : null
|
|
1726
|
+
] }),
|
|
1727
|
+
/* @__PURE__ */ jsxs("div", { className: "text-muted-foreground flex flex-wrap items-center gap-x-2 text-xs [&>*:not(:first-child)]:before:mr-2 [&>*:not(:first-child)]:before:content-['\xB7']", children: [
|
|
1728
|
+
p.values.base_url ? /* @__PURE__ */ jsx("span", { className: "max-w-64 truncate font-mono", title: p.values.base_url, children: hostOf(p.values.base_url) }) : null,
|
|
1729
|
+
/* @__PURE__ */ jsx("span", { children: p.local ? t.thisMachine : t.remote }),
|
|
1730
|
+
p.secrets.length > 0 ? /* @__PURE__ */ jsx("span", { children: t.keySaved }) : null,
|
|
1731
|
+
p.capabilities.length > 0 ? /* @__PURE__ */ jsx("span", { children: p.capabilities.map(cap).join(", ") }) : null
|
|
1732
|
+
] }),
|
|
1733
|
+
p.error ? /* @__PURE__ */ jsx("p", { className: "text-destructive text-xs", children: p.error }) : null
|
|
1434
1734
|
] }),
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
p.editable ? removing === p.id ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1438
|
-
/* @__PURE__ */ jsx(Button, { size: "xs", variant: "ghost", onClick: () => setRemoving(null), children: t.keep }),
|
|
1439
|
-
/* @__PURE__ */ jsxs(
|
|
1735
|
+
api.providerExtra?.(p),
|
|
1736
|
+
p.manages ? /* @__PURE__ */ jsxs(
|
|
1440
1737
|
Button,
|
|
1441
1738
|
{
|
|
1442
1739
|
size: "xs",
|
|
1443
|
-
variant: "
|
|
1444
|
-
|
|
1740
|
+
variant: library === p.id ? "secondary" : "ghost",
|
|
1741
|
+
"aria-expanded": library === p.id,
|
|
1445
1742
|
onClick: () => {
|
|
1446
|
-
|
|
1447
|
-
|
|
1743
|
+
const open = library === p.id ? null : p.id;
|
|
1744
|
+
setLibrary(open);
|
|
1745
|
+
if (open) listModels(open);
|
|
1448
1746
|
},
|
|
1449
1747
|
children: [
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
p.id
|
|
1748
|
+
/* @__PURE__ */ jsx(ListIcon, {}),
|
|
1749
|
+
t.models
|
|
1453
1750
|
]
|
|
1454
1751
|
}
|
|
1455
|
-
)
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1752
|
+
) : null,
|
|
1753
|
+
p.editable ? removing === p.id ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1754
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", variant: "ghost", onClick: () => setRemoving(null), children: t.keep }),
|
|
1755
|
+
/* @__PURE__ */ jsx(
|
|
1756
|
+
Button,
|
|
1757
|
+
{
|
|
1758
|
+
size: "xs",
|
|
1759
|
+
variant: "destructive",
|
|
1760
|
+
disabled: locked,
|
|
1761
|
+
onClick: () => {
|
|
1762
|
+
setRemoving(null);
|
|
1763
|
+
void change(() => api.deleteProvider(p.id));
|
|
1764
|
+
},
|
|
1765
|
+
children: f.removeProvider?.(nameOf(p.id)) ?? `${t.removeConfirm} ${nameOf(p.id)}`
|
|
1766
|
+
}
|
|
1767
|
+
)
|
|
1768
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1769
|
+
/* @__PURE__ */ jsx(
|
|
1770
|
+
Button,
|
|
1771
|
+
{
|
|
1772
|
+
size: "xs",
|
|
1773
|
+
variant: "ghost",
|
|
1774
|
+
"aria-label": f.editProvider?.(nameOf(p.id)) ?? `${t.edit} ${nameOf(p.id)}`,
|
|
1775
|
+
disabled: locked,
|
|
1776
|
+
onClick: () => startDraft({ existing: p, driver: p.driver ?? "", id: p.id, values: { ...p.values }, secrets: {} }),
|
|
1777
|
+
children: t.edit
|
|
1778
|
+
}
|
|
1779
|
+
),
|
|
1780
|
+
/* @__PURE__ */ jsx(
|
|
1781
|
+
Button,
|
|
1782
|
+
{
|
|
1783
|
+
size: "xs",
|
|
1784
|
+
variant: "ghost",
|
|
1785
|
+
"aria-label": f.removeProvider?.(nameOf(p.id)) ?? `${t.remove} ${nameOf(p.id)}`,
|
|
1786
|
+
disabled: locked,
|
|
1787
|
+
onClick: () => removeProvider(p),
|
|
1788
|
+
children: t.remove
|
|
1789
|
+
}
|
|
1790
|
+
)
|
|
1791
|
+
] }) : null
|
|
1792
|
+
] }),
|
|
1793
|
+
library === p.id ? modelLibrary(p) : null
|
|
1470
1794
|
] }, p.id)
|
|
1471
1795
|
) }),
|
|
1472
1796
|
unused.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1473
1797
|
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: t.running }),
|
|
1474
|
-
/* @__PURE__ */ jsx("ul", { className: "divide-y border border-dashed", children: unused.map((
|
|
1475
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm", children:
|
|
1476
|
-
|
|
1477
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground min-w-0 flex-1 truncate font-mono text-xs", children:
|
|
1798
|
+
/* @__PURE__ */ jsx("ul", { className: "divide-y border border-dashed", children: unused.map((f2) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-3 px-3 py-2", children: [
|
|
1799
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: f2.name }),
|
|
1800
|
+
f2.version ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: f2.version }) : null,
|
|
1801
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground min-w-0 flex-1 truncate font-mono text-xs", children: f2.base_url }),
|
|
1478
1802
|
/* @__PURE__ */ jsx(
|
|
1479
1803
|
Button,
|
|
1480
1804
|
{
|
|
1481
1805
|
size: "xs",
|
|
1482
1806
|
variant: "outline",
|
|
1483
|
-
"aria-label": `${t.addFound} ${
|
|
1484
|
-
disabled:
|
|
1485
|
-
onClick: () => startDraft(newDraft(
|
|
1807
|
+
"aria-label": labels?.format?.addFound?.(f2.name) ?? `${t.addFound} ${f2.name}`,
|
|
1808
|
+
disabled: locked || !drivers.some((d) => d.name === f2.driver),
|
|
1809
|
+
onClick: () => startDraft(newDraft(f2.driver, { base_url: f2.base_url }, f2.name)),
|
|
1486
1810
|
children: t.addFound
|
|
1487
1811
|
}
|
|
1488
1812
|
)
|
|
1489
|
-
] },
|
|
1813
|
+
] }, f2.base_url)) })
|
|
1490
1814
|
] }) : null
|
|
1491
|
-
] })
|
|
1815
|
+
] }),
|
|
1816
|
+
footer
|
|
1492
1817
|
] })
|
|
1493
1818
|
);
|
|
1494
1819
|
}
|
|
1495
1820
|
|
|
1496
|
-
export { AvatarTile, ChoiceDrawer, ConfirmContext, ConfirmDialog, ConfirmProvider, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, LlmSettings, McpSettings, MobileSheet, OptionPicker, Panel, PanelCard, TreeDndProvider, TreeExpander, TreeIcon, TreeLabel, TreeLines, TreeNode, TreeNodeContent, TreeNodeTrigger, TreeProvider, TreeView, TzPicker, filterTree, flattenTree, moveId, planDrop, sameOrder, sortTree, useConfirm, useFormField, useTreeDndNode, useTreeDndRoot };
|
|
1821
|
+
export { AuthCard, AvatarTile, BarList, ChoiceDrawer, ColorSwatches, ConfirmContext, ConfirmDialog, ConfirmProvider, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, LlmSettings, McpSettings, MobileSheet, OptionPicker, Panel, PanelCard, StatTile, TagInput, TreeDndProvider, TreeExpander, TreeIcon, TreeLabel, TreeLines, TreeNode, TreeNodeContent, TreeNodeTrigger, TreeProvider, TreeView, TzPicker, filterTree, flattenTree, loadExpanded, moveId, planDrop, sameOrder, saveExpanded, sortTree, useConfirm, useFormField, useTreeDndNode, useTreeDndRoot };
|
|
1497
1822
|
//# sourceMappingURL=index.js.map
|
|
1498
1823
|
//# sourceMappingURL=index.js.map
|