bazilion 0.50.0 → 0.52.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/dist/cli.js +316 -90
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +1378 -364
- package/dist/daemon.js.map +1 -1
- package/dist/web/client/assets/AddProviderDialog-BiGLKnu2.js +1 -0
- package/dist/web/client/assets/ConfigPage-DvBzy2MN.js +1 -0
- package/dist/web/client/assets/ConfirmDialog-CiZ5tk9R.js +1 -0
- package/dist/web/client/assets/ConnectionsView-Czkpm2JY.js +1 -0
- package/dist/web/client/assets/Dialog-s_kPtI-W.js +1 -0
- package/dist/web/client/assets/ModelMenu-BfUPoRjV.js +1 -0
- package/dist/web/client/assets/SectionTabs-DENNb6Nw.js +1 -0
- package/dist/web/client/assets/Segmented-Dh77vmpp.js +1 -0
- package/dist/web/client/assets/SkillFindings-Xng11qqx.js +1 -0
- package/dist/web/client/assets/SkillsPicker-hI3YXvib.js +1 -0
- package/dist/web/client/assets/SpawnDialog-CKWFQ6jk.js +1 -0
- package/dist/web/client/assets/Tabs-f6bHvCGn.js +1 -0
- package/dist/web/client/assets/TeamForm-kda1HYZG.js +1 -0
- package/dist/web/client/assets/TeamThread-2rm1JGSk.js +1 -0
- package/dist/web/client/assets/UnsavedChangesGuard-nx6dv2Yw.js +1 -0
- package/dist/web/client/assets/_id-B72mIpcE.js +1 -0
- package/dist/web/client/assets/_id-Bzavnza1.js +1 -0
- package/dist/web/client/assets/access-Yw9jODuk.js +1 -0
- package/dist/web/client/assets/agents-C9xoyL7o.js +1 -0
- package/dist/web/client/assets/agents-TviG16wx.js +1 -0
- package/dist/web/client/assets/api-HC_YzjBy.js +1 -0
- package/dist/web/client/assets/arrow-right-Gm_FDWJ_.js +1 -0
- package/dist/web/client/assets/attention-DmURtlJm.js +1 -0
- package/dist/web/client/assets/check-BjgKoGvU.js +1 -0
- package/dist/web/client/assets/chevron-right-CUZiA2aG.js +1 -0
- package/dist/web/client/assets/config-UZz_mjO5.js +1 -0
- package/dist/web/client/assets/createLucideIcon-C6gOo8sD.js +1 -0
- package/dist/web/client/assets/dist-BWppw70N.js +41 -0
- package/dist/web/client/assets/dist-D2dwY7MR.js +1 -0
- package/dist/web/client/assets/index-Df1oUtAP.js +14 -0
- package/dist/web/client/assets/link-Cbztlp_R.js +1 -0
- package/dist/web/client/assets/login-CPfdaqsV.js +1 -0
- package/dist/web/client/assets/mcp-FlYnNon0.js +1 -0
- package/dist/web/client/assets/model-facts-DoB6QD5y.js +1 -0
- package/dist/web/client/assets/parts-tIDBNsYA.js +1 -0
- package/dist/web/client/assets/plus-CWrKMtvA.js +1 -0
- package/dist/web/client/assets/routes-BZaWCoQj.js +76 -0
- package/dist/web/client/assets/save-f9O-CQia.js +1 -0
- package/dist/web/client/assets/skills-C7yDPC8s.js +1 -0
- package/dist/web/client/assets/style-DDuTFJUu.js +7 -0
- package/dist/web/client/assets/styles-BviXU81u.css +2 -0
- package/dist/web/client/assets/system-CL3Kz36L.js +1 -0
- package/dist/web/client/assets/teams-CQTEF5gV.js +1 -0
- package/dist/web/client/assets/teams-DQ7SqVyF.js +1 -0
- package/dist/web/client/assets/telegram-BLgxtGhZ.js +1 -0
- package/dist/web/client/assets/tools-pOQyGVYo.js +1 -0
- package/dist/web/client/assets/use-resource-C3MBZJop.js +1 -0
- package/dist/web/client/assets/welcome-Hr6JpMef.js +1 -0
- package/dist/web/client/assets/wrench-6BEIqKDn.js +1 -0
- package/dist/web/server/assets/AddProviderDialog-Tn4AskPm.js +613 -0
- package/dist/web/server/assets/{ConfigPage-DSLM5CLw.js → ConfigPage-DqDUujmt.js} +4 -4
- package/dist/web/server/assets/ConfirmDialog-DfaJ--A6.js +52 -0
- package/dist/web/server/assets/{ConnectionsView-DVLNH81Y.js → ConnectionsView-DAG-zNBz.js} +7 -5
- package/dist/web/server/assets/{ConfirmDialog-CvLZgbfY.js → Dialog-aup_yJv5.js} +3 -50
- package/dist/web/server/assets/ModelMenu-DUY9aHkE.js +138 -0
- package/dist/web/server/assets/{Rail-D8LhjS38.js → Rail-BIC_4ptO.js} +8 -66
- package/dist/web/server/assets/{SectionTabs-CNcvxbR8.js → SectionTabs-BGsrf-UQ.js} +5 -4
- package/dist/web/server/assets/Segmented-3ZLdqa5U.js +18 -0
- package/dist/web/server/assets/{SkillFindings-DX8lCMG7.js → SkillFindings-BdATze1A.js} +1 -1
- package/dist/web/server/assets/{SpawnDialog-Brmkl_ll.js → SpawnDialog-D_SMPCG_.js} +11 -8
- package/dist/web/server/assets/{TeamForm-CvQAs2FA.js → TeamForm-ilBaeLI4.js} +1 -1
- package/dist/web/server/assets/{TeamThread-BNJi6gPM.js → TeamThread-DuLlGDcw.js} +4 -19
- package/dist/web/server/assets/{UnsavedChangesGuard-B3Lpl08z.js → UnsavedChangesGuard-DrOvPV14.js} +1 -1
- package/dist/web/server/assets/{_id-CO1PgvyG.js → _id-BsZcsabI.js} +11 -11
- package/dist/web/server/assets/{_id-CA3QO7J5.js → _id-D8Kj0F30.js} +2 -2
- package/dist/web/server/assets/{_id-DIXUiIaB.js → _id-DJnYgisy.js} +2 -2
- package/dist/web/server/assets/{_id-E2N4gZ4O.js → _id-QYifTM9w.js} +3 -3
- package/dist/web/server/assets/{_id-BH1631a8.js → _id-yN0z7VqE.js} +6 -6
- package/dist/web/server/assets/_tanstack-start-manifest_v-D6zrzUC7.js +223 -0
- package/dist/web/server/assets/{tokens-CEdl8puR.js → access-C_pupPks.js} +3 -3
- package/dist/web/server/assets/{tokens-CsqoRt5T.js → access-DKOpcHIJ.js} +10 -10
- package/dist/web/server/assets/{tokens-ByPTGFBQ.js → access-GMGed5O8.js} +5 -5
- package/dist/web/server/assets/{agents-DrkEwIpR.js → agents-B6OR3x99.js} +14 -14
- package/dist/web/server/assets/{agents-CalSKogx.js → agents-B7642eRO.js} +5 -5
- package/dist/web/server/assets/{agents-DPZVni4Q.js → agents-BJ-_oC2e.js} +2 -2
- package/dist/web/server/assets/{agents-CdZvooeQ.js → agents-CjV0w-Zy.js} +2 -2
- package/dist/web/server/assets/{agents-C63VycUw.js → agents-Dy_Q-9lG.js} +3 -3
- package/dist/web/server/assets/{attention-DIyX3VMB.js → attention-CLP4HYBz.js} +3 -3
- package/dist/web/server/assets/{attention-BbE4yc-V.js → attention-DS3O9UmJ.js} +2 -2
- package/dist/web/server/assets/config-DjTGA4iZ.js +17 -0
- package/dist/web/server/assets/config-Q7livfa3.js +1215 -0
- package/dist/web/server/assets/config-X7qWbbpH.js +20 -0
- package/dist/web/server/assets/{Page-KIL1CsME.js → createSsrRpc-GCCF14VW.js} +17 -2
- package/dist/web/server/assets/{mcp-Cf7KzOJ9.js → mcp-BI-FD-JI.js} +5 -5
- package/dist/web/server/assets/{mcp-DE14q5c0.js → mcp-ZARSOxZW.js} +2 -2
- package/dist/web/server/assets/model-facts-mrfrWQne.js +136 -0
- package/dist/web/server/assets/parts-B31PJkhi.js +190 -0
- package/dist/web/server/assets/{router-w2yPgmC1.js → router-Dh2-IvLL.js} +69 -81
- package/dist/web/server/assets/{routes-1FEodTRm.js → routes-BJIJWCIE.js} +3 -3
- package/dist/web/server/assets/{routes-D1NHwz6f.js → routes-C9NawqcV.js} +22 -15
- package/dist/web/server/assets/{routes-B6AO0LjK.js → routes-CDskMy5C.js} +2 -2
- package/dist/web/server/assets/{skills-DC1OTc8n.js → skills-BqLq3ZXq.js} +5 -5
- package/dist/web/server/assets/{skills-CA17GjuZ.js → skills-StN15QhC.js} +2 -2
- package/dist/web/server/assets/system-BtRA2HUs.js +138 -0
- package/dist/web/server/assets/system-Dl-1RhoP.js +12 -0
- package/dist/web/server/assets/system-DtswhLW6.js +18 -0
- package/dist/web/server/assets/{teams-D6Tx-Jyn.js → teams-5PMGvHuM.js} +2 -2
- package/dist/web/server/assets/{teams-OzHTyVi9.js → teams-COaU0wN9.js} +4 -4
- package/dist/web/server/assets/{teams-Cg-QQWpH.js → teams-Ca8W4mvl.js} +5 -5
- package/dist/web/server/assets/{teams-Bm63mbTt.js → teams-CbIPKf99.js} +2 -2
- package/dist/web/server/assets/{telegram-Gy7_9yih.js → telegram-CGol0CKX2.js} +3 -3
- package/dist/web/server/assets/{telegram-xU-vXgef.js → telegram-Cv0D4gyz.js} +5 -5
- package/dist/web/server/assets/{telegram-BJ4l_TA_.js → telegram-Yx8nm6Ei.js} +5 -5
- package/dist/web/server/assets/tools-C-wwWjLI.js +12 -0
- package/dist/web/server/assets/tools-OfD22R-C.js +502 -0
- package/dist/web/server/assets/tools-ioJcPzMW.js +12 -0
- package/dist/web/server/assets/use-resource-DVzK0toP.js +63 -0
- package/dist/web/server/assets/utils-C_uf36nf.js +8 -0
- package/dist/web/server/assets/welcome-CxXMI4HI.js +15 -0
- package/dist/web/server/assets/welcome-FFEbrNT1.js +319 -0
- package/dist/web/server/assets/welcome-jxmpE_Jb.js +26 -0
- package/dist/web/server/assets/{workspace-DeEYMPDX.js → workspace-DaitCM0t.js} +1 -8
- package/dist/web/server/server.js +27 -19
- package/dist/worker.js +277 -153
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/web/client/assets/ConfigPage-_FY--9PB.js +0 -1
- package/dist/web/client/assets/ConfirmDialog-BblXqMVb.js +0 -1
- package/dist/web/client/assets/ConnectionsView-BZHJysCa.js +0 -1
- package/dist/web/client/assets/FieldRow-k05wfDy9.js +0 -1
- package/dist/web/client/assets/ModelSelect-CvOHjUyB.js +0 -1
- package/dist/web/client/assets/SectionTabs-DlfXtepS.js +0 -1
- package/dist/web/client/assets/SkillFindings-CHf5ZGY0.js +0 -1
- package/dist/web/client/assets/SkillsPicker-Cr87y_W-.js +0 -1
- package/dist/web/client/assets/SpawnDialog-C-Ujb4bC.js +0 -1
- package/dist/web/client/assets/Tabs-D0LgBNIk.js +0 -1
- package/dist/web/client/assets/TeamForm-D6EAAF7m.js +0 -1
- package/dist/web/client/assets/TeamThread-DpUOwMoi.js +0 -1
- package/dist/web/client/assets/UnsavedChangesGuard-DTUP7hwu.js +0 -1
- package/dist/web/client/assets/_id-C94dgBDe.js +0 -1
- package/dist/web/client/assets/_id-CxmEfoEp.js +0 -1
- package/dist/web/client/assets/agents-C-bJ5R_0.js +0 -1
- package/dist/web/client/assets/agents-odqBNx-A.js +0 -1
- package/dist/web/client/assets/api-CPzQ_z9m.js +0 -1
- package/dist/web/client/assets/arrow-right-Dyta3p06.js +0 -1
- package/dist/web/client/assets/attention-D0e7o7fh.js +0 -1
- package/dist/web/client/assets/chevron-right-B2YEg9rw.js +0 -1
- package/dist/web/client/assets/config-B7Y5MtpM.js +0 -3
- package/dist/web/client/assets/createLucideIcon-Cgab8gqu.js +0 -1
- package/dist/web/client/assets/index-CNVw44IE.js +0 -54
- package/dist/web/client/assets/jsx-runtime-bzQ4Vb5N.js +0 -1
- package/dist/web/client/assets/link-ClwtaO_E.js +0 -1
- package/dist/web/client/assets/login-Br1F4rQx.js +0 -1
- package/dist/web/client/assets/mcp-B8bIAY6k.js +0 -1
- package/dist/web/client/assets/routes-BZdlkRdC.js +0 -76
- package/dist/web/client/assets/save-ZqeB_I-c.js +0 -1
- package/dist/web/client/assets/services-CPJxDrVG.js +0 -1
- package/dist/web/client/assets/skills-DE_kQQGj.js +0 -1
- package/dist/web/client/assets/style-BWShXY3e.js +0 -7
- package/dist/web/client/assets/styles-Tney8jZq.css +0 -2
- package/dist/web/client/assets/teams-AcuSLc3I.js +0 -1
- package/dist/web/client/assets/teams-tRamPg7O.js +0 -1
- package/dist/web/client/assets/telegram-Ku69-GAv.js +0 -1
- package/dist/web/client/assets/tokens-DuLNZMgi.js +0 -1
- package/dist/web/client/assets/welcome-CrQk6n6I.js +0 -1
- package/dist/web/server/assets/FieldRow-DQBzMtcR.js +0 -173
- package/dist/web/server/assets/ModelSelect-Vwro6OkL.js +0 -43
- package/dist/web/server/assets/_tanstack-start-manifest_v-BVfrV7LQ.js +0 -191
- package/dist/web/server/assets/config-3tPtOmPE.js +0 -12
- package/dist/web/server/assets/config-DJGZiPBJ.js +0 -798
- package/dist/web/server/assets/config-rUqhMjIs.js +0 -25
- package/dist/web/server/assets/createSsrRpc-6LHNEsSK.js +0 -16
- package/dist/web/server/assets/services-BjroGXgC.js +0 -74
- package/dist/web/server/assets/services-Cdk40QHq.js +0 -13
- package/dist/web/server/assets/services-DsHRLL8q.js +0 -12
- package/dist/web/server/assets/welcome-O6Rjd7yO.js +0 -93
|
@@ -0,0 +1,1215 @@
|
|
|
1
|
+
import { C as api, T as errorMessage, u as Button } from "./workspace-DaitCM0t.js";
|
|
2
|
+
import { r as useResource } from "./use-resource-DVzK0toP.js";
|
|
3
|
+
import { t as Dialog } from "./Dialog-aup_yJv5.js";
|
|
4
|
+
import { t as ConfirmDialog } from "./ConfirmDialog-DfaJ--A6.js";
|
|
5
|
+
import { t as Segmented } from "./Segmented-3ZLdqa5U.js";
|
|
6
|
+
import { d as providerStatus, f as usedByLine, i as factsLine, l as modelName, o as matchesModel, r as credentialLine, t as ago, u as priceLine } from "./model-facts-mrfrWQne.js";
|
|
7
|
+
import { t as Route } from "./config-DjTGA4iZ.js";
|
|
8
|
+
import { t as ConfigPage } from "./ConfigPage-DqDUujmt.js";
|
|
9
|
+
import { a as SearchField, c as Switch, i as ProviderAvatar, l as Waiting, n as FailureBox, o as SetupCard, r as ModelRow, s as StateChip, t as Chip } from "./parts-B31PJkhi.js";
|
|
10
|
+
import { t as AddProviderDialog } from "./AddProviderDialog-Tn4AskPm.js";
|
|
11
|
+
import { useId, useMemo, useState } from "react";
|
|
12
|
+
import { useRouter } from "@tanstack/react-router";
|
|
13
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { AlertTriangle, Check, ChevronRight, Images, MessageSquare, Plug, Plus, X } from "lucide-react";
|
|
15
|
+
//#region src/components/setup/ModelPicker.tsx
|
|
16
|
+
var FILTERS = [
|
|
17
|
+
{
|
|
18
|
+
id: "all",
|
|
19
|
+
label: "All"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: "images",
|
|
23
|
+
label: "Sees images"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "reasoning",
|
|
27
|
+
label: "Reasoning"
|
|
28
|
+
}
|
|
29
|
+
];
|
|
30
|
+
/** Rows of one provider shown at once; a search narrows the rest down. */
|
|
31
|
+
var MAX_ROWS = 80;
|
|
32
|
+
/**
|
|
33
|
+
* Choose the chat models Agents may use, across every connected provider: names, sizes and prices
|
|
34
|
+
* from the bundled catalog, plus what each provider reports itself. Saving replaces each changed
|
|
35
|
+
* provider's list.
|
|
36
|
+
*/
|
|
37
|
+
function ModelPicker({ providers, chat, onClose, onSaved, onAddProvider }) {
|
|
38
|
+
const [query, setQuery] = useState("");
|
|
39
|
+
const [filter, setFilter] = useState("all");
|
|
40
|
+
const [dated, setDated] = useState(false);
|
|
41
|
+
const [picked, setPicked] = useState(null);
|
|
42
|
+
const [saving, setSaving] = useState(false);
|
|
43
|
+
const [error, setError] = useState(null);
|
|
44
|
+
const catalogs = useResource(async (signal) => {
|
|
45
|
+
const loaded = await Promise.all(providers.map(async (provider) => {
|
|
46
|
+
return {
|
|
47
|
+
provider,
|
|
48
|
+
catalog: await api(`/api/config/providers/${encodeURIComponent(provider.id)}/catalog`, { signal })
|
|
49
|
+
};
|
|
50
|
+
}));
|
|
51
|
+
setPicked(Object.fromEntries(loaded.map(({ provider, catalog }) => [provider.id, catalog.models.filter((model) => model.selected).map((model) => model.id)])));
|
|
52
|
+
return loaded;
|
|
53
|
+
}, [providers.map((provider) => provider.id).join(",")]);
|
|
54
|
+
const picks = picked ?? {};
|
|
55
|
+
const isPicked = (provider, model) => picks[provider]?.includes(model) ?? false;
|
|
56
|
+
const toggle = (provider, model) => setPicked((current) => {
|
|
57
|
+
const list = current?.[provider] ?? [];
|
|
58
|
+
return {
|
|
59
|
+
...current,
|
|
60
|
+
[provider]: list.includes(model) ? list.filter((id) => id !== model) : [...list, model]
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
const shown = (model, provider) => {
|
|
64
|
+
if (query) return matchesModel(model, query);
|
|
65
|
+
if (model.dated && !dated && !isPicked(provider.id, model.id)) return false;
|
|
66
|
+
if (filter === "images") return model.images === true;
|
|
67
|
+
if (filter === "reasoning") return model.reasoning === true;
|
|
68
|
+
return true;
|
|
69
|
+
};
|
|
70
|
+
const changed = useMemo(() => (catalogs.data ?? []).filter(({ provider, catalog }) => {
|
|
71
|
+
const before = catalog.models.filter((model) => model.selected).map((model) => model.id);
|
|
72
|
+
const after = picks[provider.id] ?? [];
|
|
73
|
+
return before.length !== after.length || before.some((id) => !after.includes(id));
|
|
74
|
+
}), [catalogs.data, picks]);
|
|
75
|
+
const stranded = chat.filter((model) => model.usedBy.agents > 0 && changed.some(({ provider }) => provider.id === model.provider) && !isPicked(model.provider, model.id));
|
|
76
|
+
const total = Object.values(picks).reduce((sum, list) => sum + list.length, 0);
|
|
77
|
+
async function save() {
|
|
78
|
+
setSaving(true);
|
|
79
|
+
setError(null);
|
|
80
|
+
try {
|
|
81
|
+
for (const { provider } of changed) await api(`/api/config/providers/${encodeURIComponent(provider.id)}/models`, {
|
|
82
|
+
method: "PUT",
|
|
83
|
+
body: { models: picks[provider.id] ?? [] }
|
|
84
|
+
});
|
|
85
|
+
await onSaved();
|
|
86
|
+
onClose();
|
|
87
|
+
} catch (cause) {
|
|
88
|
+
setError(errorMessage(cause));
|
|
89
|
+
setSaving(false);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return /* @__PURE__ */ jsxs(Dialog, {
|
|
93
|
+
title: "Chat models",
|
|
94
|
+
description: "Tick the models your Agents may use. Each Agent and each template picks one of them.",
|
|
95
|
+
onClose,
|
|
96
|
+
busy: saving,
|
|
97
|
+
className: "top-[4dvh] max-h-[92dvh] max-w-3xl translate-y-0 content-start",
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ jsxs("div", {
|
|
100
|
+
className: "flex flex-wrap items-center gap-2",
|
|
101
|
+
children: [/* @__PURE__ */ jsx(SearchField, {
|
|
102
|
+
label: "Search models",
|
|
103
|
+
placeholder: "Search by name, for example haiku",
|
|
104
|
+
value: query,
|
|
105
|
+
onChange: setQuery,
|
|
106
|
+
className: "flex-1 basis-60"
|
|
107
|
+
}), /* @__PURE__ */ jsx(Segmented, {
|
|
108
|
+
label: "Show",
|
|
109
|
+
value: filter,
|
|
110
|
+
options: FILTERS,
|
|
111
|
+
onChange: setFilter
|
|
112
|
+
})]
|
|
113
|
+
}),
|
|
114
|
+
/* @__PURE__ */ jsxs("div", {
|
|
115
|
+
className: "max-h-[min(58dvh,36rem)] min-h-40 overflow-y-auto rounded-xl border border-border",
|
|
116
|
+
children: [
|
|
117
|
+
catalogs.loading && !catalogs.data && /* @__PURE__ */ jsx("div", {
|
|
118
|
+
className: "p-4 text-sm text-muted-foreground",
|
|
119
|
+
children: "Reading the model lists…"
|
|
120
|
+
}),
|
|
121
|
+
catalogs.error && /* @__PURE__ */ jsx("div", {
|
|
122
|
+
role: "alert",
|
|
123
|
+
className: "p-4 text-sm text-danger",
|
|
124
|
+
children: catalogs.error
|
|
125
|
+
}),
|
|
126
|
+
catalogs.data?.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
127
|
+
className: "p-4 text-sm text-muted-foreground",
|
|
128
|
+
children: "No provider is connected yet. Add one to see its models here."
|
|
129
|
+
}),
|
|
130
|
+
(catalogs.data ?? []).map(({ provider, catalog }) => {
|
|
131
|
+
const matching = catalog.models.filter((model) => shown(model, provider));
|
|
132
|
+
const rows = matching.slice(0, MAX_ROWS);
|
|
133
|
+
const hiddenDated = catalog.models.filter((model) => model.dated && !isPicked(provider.id, model.id)).length;
|
|
134
|
+
if (query && matching.length === 0) return null;
|
|
135
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
136
|
+
"aria-label": provider.displayName,
|
|
137
|
+
children: [
|
|
138
|
+
/* @__PURE__ */ jsxs("div", {
|
|
139
|
+
className: "flex flex-wrap items-baseline gap-x-2 border-b border-border bg-muted/50 px-4 py-2",
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ jsx("h3", {
|
|
142
|
+
className: "m-0 font-body text-[0.72rem] font-bold uppercase tracking-[0.08em] text-muted-foreground",
|
|
143
|
+
children: provider.displayName
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ jsxs("span", {
|
|
146
|
+
className: "text-xs text-muted-foreground",
|
|
147
|
+
children: [
|
|
148
|
+
(picks[provider.id] ?? []).length,
|
|
149
|
+
" of ",
|
|
150
|
+
catalog.models.length,
|
|
151
|
+
" in use"
|
|
152
|
+
]
|
|
153
|
+
}),
|
|
154
|
+
catalog.listError && /* @__PURE__ */ jsxs("span", {
|
|
155
|
+
className: "text-xs text-warning",
|
|
156
|
+
children: ["Its own list could not be read: ", catalog.listError]
|
|
157
|
+
})
|
|
158
|
+
]
|
|
159
|
+
}),
|
|
160
|
+
rows.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
161
|
+
className: "border-b border-border px-4 py-3 text-sm text-muted-foreground",
|
|
162
|
+
children: catalog.models.length === 0 ? "It lists no model." : "Nothing matches."
|
|
163
|
+
}),
|
|
164
|
+
rows.map((model) => /* @__PURE__ */ jsx(ModelRow, {
|
|
165
|
+
model: {
|
|
166
|
+
...model,
|
|
167
|
+
suggested: false
|
|
168
|
+
},
|
|
169
|
+
connect: provider.connect,
|
|
170
|
+
checked: isPicked(provider.id, model.id),
|
|
171
|
+
disabled: saving,
|
|
172
|
+
onToggle: () => toggle(provider.id, model.id),
|
|
173
|
+
className: "px-4 hover:bg-accent/30"
|
|
174
|
+
}, model.id)),
|
|
175
|
+
matching.length > rows.length && /* @__PURE__ */ jsxs("div", {
|
|
176
|
+
className: "border-b border-border px-4 py-2 text-xs text-muted-foreground",
|
|
177
|
+
children: [matching.length - rows.length, " more: search to narrow them down."]
|
|
178
|
+
}),
|
|
179
|
+
!query && hiddenDated > 0 && /* @__PURE__ */ jsx("div", {
|
|
180
|
+
className: "border-b border-border px-4 py-1.5",
|
|
181
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
182
|
+
type: "button",
|
|
183
|
+
onClick: () => setDated((open) => !open),
|
|
184
|
+
className: "text-xs font-semibold text-primary",
|
|
185
|
+
children: dated ? "Hide dated versions" : `Show ${hiddenDated} dated ${hiddenDated === 1 ? "version" : "versions"} of the same models`
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
}, provider.id);
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
}),
|
|
193
|
+
stranded.length > 0 && /* @__PURE__ */ jsxs("p", {
|
|
194
|
+
role: "status",
|
|
195
|
+
className: "m-0 rounded-xl bg-warning/10 px-3 py-2 text-sm text-warning",
|
|
196
|
+
children: [
|
|
197
|
+
stranded.map((model) => modelName(model)).join(", "),
|
|
198
|
+
" ",
|
|
199
|
+
stranded.length === 1 ? "is" : "are",
|
|
200
|
+
" in use by Agents. They are refused until you give them another model in their Agent tab."
|
|
201
|
+
]
|
|
202
|
+
}),
|
|
203
|
+
error && /* @__PURE__ */ jsx("p", {
|
|
204
|
+
role: "alert",
|
|
205
|
+
className: "m-0 rounded-xl bg-danger/10 px-3 py-2 text-sm text-danger",
|
|
206
|
+
children: error
|
|
207
|
+
}),
|
|
208
|
+
/* @__PURE__ */ jsxs("div", {
|
|
209
|
+
className: "flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-frost pt-4",
|
|
210
|
+
children: [
|
|
211
|
+
/* @__PURE__ */ jsx("span", {
|
|
212
|
+
className: "min-w-0 flex-1 basis-40 text-sm text-muted-foreground",
|
|
213
|
+
children: total === 1 ? "1 model in Chat" : `${total} models in Chat`
|
|
214
|
+
}),
|
|
215
|
+
/* @__PURE__ */ jsx("button", {
|
|
216
|
+
type: "button",
|
|
217
|
+
onClick: onAddProvider,
|
|
218
|
+
className: "text-sm font-semibold text-primary",
|
|
219
|
+
children: "A model from another provider?"
|
|
220
|
+
}),
|
|
221
|
+
/* @__PURE__ */ jsx(Button, {
|
|
222
|
+
variant: "ghost",
|
|
223
|
+
disabled: saving,
|
|
224
|
+
onClick: onClose,
|
|
225
|
+
children: "Cancel"
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ jsx(Button, {
|
|
228
|
+
variant: "primary",
|
|
229
|
+
disabled: saving || changed.length === 0,
|
|
230
|
+
onClick: () => void save(),
|
|
231
|
+
children: saving ? "Saving…" : "Save"
|
|
232
|
+
})
|
|
233
|
+
]
|
|
234
|
+
})
|
|
235
|
+
]
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region src/components/setup/ModelsCards.tsx
|
|
240
|
+
var ROW = "flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5";
|
|
241
|
+
/** The line above the cards: whether everything Agents rely on answers, and what does not. */
|
|
242
|
+
function StatusLine({ providers, chat, now, onOpen, onTestAll, testing }) {
|
|
243
|
+
const on = providers.filter((provider) => provider.enabled);
|
|
244
|
+
if (on.length === 0) return null;
|
|
245
|
+
const broken = on.filter((provider) => provider.state === "failing" || provider.state === "incomplete");
|
|
246
|
+
const untested = on.filter((provider) => provider.state === "untested" && provider.models.length > 0);
|
|
247
|
+
if (broken.length > 0) return /* @__PURE__ */ jsx("div", {
|
|
248
|
+
className: "grid gap-2",
|
|
249
|
+
children: broken.map((provider) => {
|
|
250
|
+
const models = chat.filter((model) => model.provider === provider.id);
|
|
251
|
+
const agents = models.reduce((sum, model) => sum + model.usedBy.agents, 0);
|
|
252
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
253
|
+
role: "status",
|
|
254
|
+
className: "flex flex-wrap items-center gap-3 rounded-2xl border border-warning/35 bg-warning/10 px-4 py-3 text-sm",
|
|
255
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
256
|
+
className: "flex min-w-0 flex-1 basis-64 items-start gap-3",
|
|
257
|
+
children: [/* @__PURE__ */ jsx(AlertTriangle, {
|
|
258
|
+
className: "mt-0.5 size-5 shrink-0 text-warning",
|
|
259
|
+
"aria-hidden": "true"
|
|
260
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
261
|
+
className: "min-w-0",
|
|
262
|
+
children: [
|
|
263
|
+
/* @__PURE__ */ jsxs("span", {
|
|
264
|
+
className: "font-semibold text-foreground",
|
|
265
|
+
children: [provider.check?.failure?.title ?? `${provider.displayName}: ${providerStatus(provider, now).label.toLowerCase()}`, "."]
|
|
266
|
+
}),
|
|
267
|
+
" ",
|
|
268
|
+
/* @__PURE__ */ jsx("span", {
|
|
269
|
+
className: "text-muted-foreground",
|
|
270
|
+
children: models.length === 0 ? "No chat model runs on it." : `${models.length === 1 ? "1 chat model runs" : `${models.length} chat models run`} on it${agents === 0 ? "" : `, used by ${agents === 1 ? "1 Agent" : `${agents} Agents`}`}.`
|
|
271
|
+
})
|
|
272
|
+
]
|
|
273
|
+
})]
|
|
274
|
+
}), /* @__PURE__ */ jsxs(Button, {
|
|
275
|
+
variant: "ghost",
|
|
276
|
+
onClick: () => onOpen(provider.id),
|
|
277
|
+
children: ["Open ", provider.displayName]
|
|
278
|
+
})]
|
|
279
|
+
}, provider.id);
|
|
280
|
+
})
|
|
281
|
+
});
|
|
282
|
+
if (untested.length > 0) return /* @__PURE__ */ jsxs("div", {
|
|
283
|
+
role: "status",
|
|
284
|
+
className: "flex flex-wrap items-center gap-3 rounded-2xl border border-border bg-card px-4 py-3 text-sm shadow-baziu-sm",
|
|
285
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
286
|
+
className: "min-w-0 flex-1 basis-72",
|
|
287
|
+
children: [
|
|
288
|
+
/* @__PURE__ */ jsx("span", {
|
|
289
|
+
className: "font-semibold text-foreground",
|
|
290
|
+
children: untested.length === 1 ? `${untested[0]?.displayName} has not been tested.` : `${untested.length} providers have not been tested.`
|
|
291
|
+
}),
|
|
292
|
+
" ",
|
|
293
|
+
/* @__PURE__ */ jsx("span", {
|
|
294
|
+
className: "text-muted-foreground",
|
|
295
|
+
children: "A test sends one short message to the cheapest model of each."
|
|
296
|
+
})
|
|
297
|
+
]
|
|
298
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
299
|
+
variant: "ghost",
|
|
300
|
+
disabled: testing,
|
|
301
|
+
onClick: onTestAll,
|
|
302
|
+
children: testing ? "Testing…" : untested.length === 1 ? "Test it" : "Test them"
|
|
303
|
+
})]
|
|
304
|
+
});
|
|
305
|
+
const working = on.filter((provider) => provider.state === "working");
|
|
306
|
+
if (working.length === 0) return null;
|
|
307
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
308
|
+
role: "status",
|
|
309
|
+
className: "flex flex-wrap items-center gap-3 rounded-2xl border border-success/30 bg-success/10 px-4 py-3 text-sm",
|
|
310
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
311
|
+
className: "flex min-w-0 flex-1 basis-64 items-start gap-3",
|
|
312
|
+
children: [/* @__PURE__ */ jsx(Check, {
|
|
313
|
+
className: "mt-0.5 size-5 shrink-0 text-success",
|
|
314
|
+
"aria-hidden": "true"
|
|
315
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
316
|
+
className: "min-w-0",
|
|
317
|
+
children: [
|
|
318
|
+
/* @__PURE__ */ jsx("span", {
|
|
319
|
+
className: "font-semibold text-foreground",
|
|
320
|
+
children: working.length === 1 ? "Your provider answers." : "Every provider answers."
|
|
321
|
+
}),
|
|
322
|
+
" ",
|
|
323
|
+
/* @__PURE__ */ jsxs("span", {
|
|
324
|
+
className: "text-muted-foreground",
|
|
325
|
+
children: [chat.length === 1 ? "1 chat model" : `${chat.length} chat models`, " for your Agents."]
|
|
326
|
+
})
|
|
327
|
+
]
|
|
328
|
+
})]
|
|
329
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
330
|
+
variant: "ghost",
|
|
331
|
+
disabled: testing,
|
|
332
|
+
onClick: onTestAll,
|
|
333
|
+
children: testing ? "Testing…" : "Test again"
|
|
334
|
+
})]
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
/** Chat: the models Agents think with, each with what it can do, its price and who uses it. */
|
|
338
|
+
function ChatModelsCard({ chat, hasProviders, onPick, onChanged }) {
|
|
339
|
+
const [removing, setRemoving] = useState(null);
|
|
340
|
+
const [error, setError] = useState(null);
|
|
341
|
+
async function remove(model) {
|
|
342
|
+
const models = chat.filter((entry) => entry.provider === model.provider && entry.id !== model.id).map((entry) => entry.id);
|
|
343
|
+
await api(`/api/config/providers/${encodeURIComponent(model.provider)}/models`, {
|
|
344
|
+
method: "PUT",
|
|
345
|
+
body: { models }
|
|
346
|
+
});
|
|
347
|
+
await onChanged();
|
|
348
|
+
}
|
|
349
|
+
function askToRemove(model) {
|
|
350
|
+
setError(null);
|
|
351
|
+
if (model.usedBy.agents > 0 || model.usedBy.templates.length > 0) setRemoving(model);
|
|
352
|
+
else remove(model).catch((cause) => setError(errorMessage(cause)));
|
|
353
|
+
}
|
|
354
|
+
return /* @__PURE__ */ jsxs(SetupCard, {
|
|
355
|
+
labelledBy: "setup-chat",
|
|
356
|
+
icon: /* @__PURE__ */ jsx(MessageSquare, { className: "size-5" }),
|
|
357
|
+
title: "Chat",
|
|
358
|
+
description: "The models Agents think with. Each Agent and each template uses one of them.",
|
|
359
|
+
action: /* @__PURE__ */ jsxs(Button, {
|
|
360
|
+
variant: "primary",
|
|
361
|
+
disabled: !hasProviders,
|
|
362
|
+
onClick: onPick,
|
|
363
|
+
children: [/* @__PURE__ */ jsx(Plus, {
|
|
364
|
+
className: "size-4",
|
|
365
|
+
"aria-hidden": "true"
|
|
366
|
+
}), "Add models"]
|
|
367
|
+
}),
|
|
368
|
+
children: [
|
|
369
|
+
chat.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
370
|
+
"aria-hidden": "true",
|
|
371
|
+
className: `${ROW} hidden bg-muted/50 py-2 text-[0.7rem] font-bold uppercase tracking-[0.08em] text-muted-foreground lg:flex`,
|
|
372
|
+
children: [
|
|
373
|
+
/* @__PURE__ */ jsx("span", {
|
|
374
|
+
className: "min-w-0 flex-[2.2] basis-52",
|
|
375
|
+
children: "Model"
|
|
376
|
+
}),
|
|
377
|
+
/* @__PURE__ */ jsx("span", {
|
|
378
|
+
className: "w-28 shrink-0",
|
|
379
|
+
children: "Provider"
|
|
380
|
+
}),
|
|
381
|
+
/* @__PURE__ */ jsx("span", {
|
|
382
|
+
className: "min-w-0 flex-[2] basis-48",
|
|
383
|
+
children: "Can do"
|
|
384
|
+
}),
|
|
385
|
+
/* @__PURE__ */ jsx("span", {
|
|
386
|
+
className: "w-40 shrink-0",
|
|
387
|
+
children: "Price per 1M tokens"
|
|
388
|
+
}),
|
|
389
|
+
/* @__PURE__ */ jsx("span", {
|
|
390
|
+
className: "min-w-0 flex-[1.4] basis-36",
|
|
391
|
+
children: "Used by"
|
|
392
|
+
}),
|
|
393
|
+
/* @__PURE__ */ jsx("span", { className: "w-8 shrink-0" })
|
|
394
|
+
]
|
|
395
|
+
}),
|
|
396
|
+
chat.map((model) => {
|
|
397
|
+
const down = model.providerState === "failing" || model.providerState === "incomplete";
|
|
398
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
399
|
+
className: `${ROW} min-h-16 py-2.5`,
|
|
400
|
+
children: [
|
|
401
|
+
/* @__PURE__ */ jsxs("div", {
|
|
402
|
+
className: "min-w-0 flex-[2.2] basis-52",
|
|
403
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
404
|
+
className: "text-[0.95rem] font-semibold text-foreground",
|
|
405
|
+
children: modelName(model)
|
|
406
|
+
}), model.name && /* @__PURE__ */ jsx("div", {
|
|
407
|
+
className: "break-all font-mono text-[0.72rem] text-muted-foreground",
|
|
408
|
+
children: model.id
|
|
409
|
+
})]
|
|
410
|
+
}),
|
|
411
|
+
/* @__PURE__ */ jsx("div", {
|
|
412
|
+
className: "w-28 shrink-0 text-sm",
|
|
413
|
+
children: model.providerName
|
|
414
|
+
}),
|
|
415
|
+
/* @__PURE__ */ jsx("div", {
|
|
416
|
+
className: `min-w-0 flex-[2] basis-48 text-[0.82rem] ${down ? "font-semibold text-warning" : "text-muted-foreground"}`,
|
|
417
|
+
children: down ? `${model.providerName} is not working` : factsLine(model, model.providerConnect)
|
|
418
|
+
}),
|
|
419
|
+
/* @__PURE__ */ jsx("div", {
|
|
420
|
+
className: "w-40 shrink-0 text-[0.82rem]",
|
|
421
|
+
children: priceLine(model, model.providerConnect)
|
|
422
|
+
}),
|
|
423
|
+
/* @__PURE__ */ jsx("div", {
|
|
424
|
+
className: "min-w-0 flex-[1.4] basis-36 text-[0.82rem] text-muted-foreground",
|
|
425
|
+
children: usedByLine(model.usedBy)
|
|
426
|
+
}),
|
|
427
|
+
/* @__PURE__ */ jsx("button", {
|
|
428
|
+
type: "button",
|
|
429
|
+
"aria-label": `Remove ${modelName(model)} from Chat`,
|
|
430
|
+
onClick: () => askToRemove(model),
|
|
431
|
+
className: "flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted hover:text-danger",
|
|
432
|
+
children: /* @__PURE__ */ jsx(X, {
|
|
433
|
+
className: "size-4",
|
|
434
|
+
"aria-hidden": "true"
|
|
435
|
+
})
|
|
436
|
+
})
|
|
437
|
+
]
|
|
438
|
+
}, model.value);
|
|
439
|
+
}),
|
|
440
|
+
chat.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
441
|
+
className: `${ROW} py-5 text-sm text-muted-foreground`,
|
|
442
|
+
children: hasProviders ? "No chat model yet. Agents cannot answer until one is added." : "No chat model yet. Add a provider below, and its models appear here."
|
|
443
|
+
}),
|
|
444
|
+
error && /* @__PURE__ */ jsx("div", {
|
|
445
|
+
role: "alert",
|
|
446
|
+
className: `${ROW} py-3 text-sm text-danger`,
|
|
447
|
+
children: error
|
|
448
|
+
}),
|
|
449
|
+
/* @__PURE__ */ jsx(ConfirmDialog, {
|
|
450
|
+
open: removing !== null,
|
|
451
|
+
onOpenChange: (open) => {
|
|
452
|
+
if (!open) setRemoving(null);
|
|
453
|
+
},
|
|
454
|
+
title: `Remove ${removing ? modelName(removing) : ""} from Chat?`,
|
|
455
|
+
description: removing && /* @__PURE__ */ jsxs("p", {
|
|
456
|
+
className: "m-0",
|
|
457
|
+
children: [
|
|
458
|
+
"It is used by ",
|
|
459
|
+
usedByLine(removing.usedBy),
|
|
460
|
+
".",
|
|
461
|
+
" ",
|
|
462
|
+
removing.usedBy.agents > 0 && "Those Agents are refused until you give them another model in their Agent tab. ",
|
|
463
|
+
removing.usedBy.templates.length > 0 && "An Agent template on it moves to another model by itself."
|
|
464
|
+
]
|
|
465
|
+
}),
|
|
466
|
+
confirmLabel: "Remove from Chat",
|
|
467
|
+
onConfirm: async () => {
|
|
468
|
+
if (removing) await remove(removing);
|
|
469
|
+
}
|
|
470
|
+
})
|
|
471
|
+
]
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
/** Images: one model draws for every Agent, through one provider's account, or nothing does. */
|
|
475
|
+
function ImagesCard({ images, onConnect, onChanged }) {
|
|
476
|
+
const [saving, setSaving] = useState(null);
|
|
477
|
+
const [error, setError] = useState(null);
|
|
478
|
+
const selected = images.routes.find((route) => route.id === images.selected);
|
|
479
|
+
const on = selected?.ready === true;
|
|
480
|
+
const shown = saving ?? images.selected;
|
|
481
|
+
async function choose(id) {
|
|
482
|
+
setSaving(id);
|
|
483
|
+
setError(null);
|
|
484
|
+
try {
|
|
485
|
+
await api("/api/config/fields/BAZILION_IMAGE_MODEL", {
|
|
486
|
+
method: "PUT",
|
|
487
|
+
body: { value: id }
|
|
488
|
+
});
|
|
489
|
+
await onChanged();
|
|
490
|
+
} catch (cause) {
|
|
491
|
+
setError(errorMessage(cause));
|
|
492
|
+
} finally {
|
|
493
|
+
setSaving(null);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
const row = (id, body, ready, tail) => /* @__PURE__ */ jsxs("label", {
|
|
497
|
+
className: `${ROW} m-0 min-h-[3.25rem] py-2 ${ready ? "cursor-pointer" : ""} ${shown === id ? "bg-accent/40" : ""}`,
|
|
498
|
+
children: [
|
|
499
|
+
/* @__PURE__ */ jsx("input", {
|
|
500
|
+
type: "radio",
|
|
501
|
+
name: "image-model",
|
|
502
|
+
checked: shown === id,
|
|
503
|
+
disabled: !ready || saving !== null,
|
|
504
|
+
onChange: () => void choose(id),
|
|
505
|
+
className: "m-0 size-[18px] shrink-0 accent-[var(--color-sapphire)]"
|
|
506
|
+
}),
|
|
507
|
+
body,
|
|
508
|
+
/* @__PURE__ */ jsx("span", {
|
|
509
|
+
className: "ml-auto flex shrink-0 justify-end sm:w-44",
|
|
510
|
+
children: tail
|
|
511
|
+
})
|
|
512
|
+
]
|
|
513
|
+
}, id);
|
|
514
|
+
return /* @__PURE__ */ jsxs(SetupCard, {
|
|
515
|
+
labelledBy: "setup-images",
|
|
516
|
+
icon: /* @__PURE__ */ jsx(Images, { className: "size-5" }),
|
|
517
|
+
title: "Images",
|
|
518
|
+
description: "What Agents draw with. One model for every Agent, up to four images a turn.",
|
|
519
|
+
action: /* @__PURE__ */ jsx(Chip, {
|
|
520
|
+
tone: on ? "success" : selected ? "warning" : "neutral",
|
|
521
|
+
children: on ? `On: ${selected.model}` : selected ? `Needs ${selected.needs}` : "Off"
|
|
522
|
+
}),
|
|
523
|
+
children: [
|
|
524
|
+
images.routes.map((route) => row(route.id, /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
|
|
525
|
+
className: "min-w-0 flex-[1.6] basis-60 text-[0.95rem]",
|
|
526
|
+
children: [
|
|
527
|
+
/* @__PURE__ */ jsx("span", {
|
|
528
|
+
className: `font-semibold ${route.ready ? "text-foreground" : "text-muted-foreground"}`,
|
|
529
|
+
children: route.model
|
|
530
|
+
}),
|
|
531
|
+
" ",
|
|
532
|
+
/* @__PURE__ */ jsxs("span", {
|
|
533
|
+
className: "text-muted-foreground",
|
|
534
|
+
children: ["through ", route.providerName]
|
|
535
|
+
})
|
|
536
|
+
]
|
|
537
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
538
|
+
className: "min-w-0 flex-1 basis-44 text-[0.82rem] text-muted-foreground",
|
|
539
|
+
children: route.billing
|
|
540
|
+
})] }), route.ready, route.ready ? /* @__PURE__ */ jsx("span", {
|
|
541
|
+
className: "text-[0.82rem] font-semibold text-success",
|
|
542
|
+
children: "Ready"
|
|
543
|
+
}) : /* @__PURE__ */ jsx(Button, {
|
|
544
|
+
variant: "ghost",
|
|
545
|
+
onClick: () => onConnect(route.provider),
|
|
546
|
+
children: route.provider === "openai-codex" ? "Sign in" : `Connect ${route.providerName}`
|
|
547
|
+
}))),
|
|
548
|
+
row("off", /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
549
|
+
className: "min-w-0 flex-[1.6] basis-60 text-[0.95rem] font-semibold text-foreground",
|
|
550
|
+
children: "Off"
|
|
551
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
552
|
+
className: "min-w-0 flex-1 basis-44 text-[0.82rem] text-muted-foreground",
|
|
553
|
+
children: "Agents have no image tool"
|
|
554
|
+
})] }), true, null),
|
|
555
|
+
images.selected !== "off" && !selected && /* @__PURE__ */ jsxs("div", {
|
|
556
|
+
role: "alert",
|
|
557
|
+
className: `${ROW} py-3 text-sm text-warning`,
|
|
558
|
+
children: [
|
|
559
|
+
"BAZILION_IMAGE_MODEL is set to “",
|
|
560
|
+
images.selected,
|
|
561
|
+
"”, which is not an image route. Choose one above."
|
|
562
|
+
]
|
|
563
|
+
}),
|
|
564
|
+
error && /* @__PURE__ */ jsx("div", {
|
|
565
|
+
role: "alert",
|
|
566
|
+
className: `${ROW} py-3 text-sm text-danger`,
|
|
567
|
+
children: error
|
|
568
|
+
})
|
|
569
|
+
]
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
/** Providers: the accounts and local servers in use, each with what it serves and its state. */
|
|
573
|
+
function ProvidersCard({ providers, total, images, now, onOpen, onAdd }) {
|
|
574
|
+
const drawing = images.routes.find((route) => route.id === images.selected && route.ready);
|
|
575
|
+
return /* @__PURE__ */ jsxs(SetupCard, {
|
|
576
|
+
labelledBy: "setup-providers",
|
|
577
|
+
icon: /* @__PURE__ */ jsx(Plug, { className: "size-5" }),
|
|
578
|
+
title: "Providers",
|
|
579
|
+
description: "The accounts and local servers your models run on.",
|
|
580
|
+
action: /* @__PURE__ */ jsxs(Button, {
|
|
581
|
+
variant: "primary",
|
|
582
|
+
onClick: onAdd,
|
|
583
|
+
children: [/* @__PURE__ */ jsx(Plus, {
|
|
584
|
+
className: "size-4",
|
|
585
|
+
"aria-hidden": "true"
|
|
586
|
+
}), "Add a provider"]
|
|
587
|
+
}),
|
|
588
|
+
children: [
|
|
589
|
+
providers.map((provider) => {
|
|
590
|
+
const count = provider.enabled ? provider.models.length : 0;
|
|
591
|
+
const uses = [count > 0 ? `Chat: ${count === 1 ? "1 model" : `${count} models`}` : null, drawing?.provider === provider.id ? "Images" : null].filter(Boolean);
|
|
592
|
+
const status = providerStatus(provider, now);
|
|
593
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
594
|
+
type: "button",
|
|
595
|
+
onClick: () => onOpen(provider.id),
|
|
596
|
+
className: `${ROW} min-h-[4.25rem] w-full py-3 text-left transition-colors hover:bg-accent/30`,
|
|
597
|
+
children: [
|
|
598
|
+
/* @__PURE__ */ jsx(ProviderAvatar, {
|
|
599
|
+
name: provider.displayName,
|
|
600
|
+
tone: status.tone
|
|
601
|
+
}),
|
|
602
|
+
/* @__PURE__ */ jsxs("span", {
|
|
603
|
+
className: "min-w-0 flex-[1.6] basis-56",
|
|
604
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
605
|
+
className: "block text-[0.95rem] font-semibold text-foreground",
|
|
606
|
+
children: provider.displayName
|
|
607
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
608
|
+
className: "block truncate text-[0.82rem] text-muted-foreground",
|
|
609
|
+
children: credentialLine(provider)
|
|
610
|
+
})]
|
|
611
|
+
}),
|
|
612
|
+
/* @__PURE__ */ jsx("span", {
|
|
613
|
+
className: "min-w-0 flex-1 basis-40 text-[0.82rem] text-muted-foreground",
|
|
614
|
+
children: uses.length > 0 ? uses.join(" · ") : "Not used yet"
|
|
615
|
+
}),
|
|
616
|
+
/* @__PURE__ */ jsx(StateChip, {
|
|
617
|
+
provider,
|
|
618
|
+
now
|
|
619
|
+
}),
|
|
620
|
+
/* @__PURE__ */ jsx(ChevronRight, {
|
|
621
|
+
className: "size-4 shrink-0 text-muted-foreground",
|
|
622
|
+
"aria-hidden": "true"
|
|
623
|
+
})
|
|
624
|
+
]
|
|
625
|
+
}, provider.id);
|
|
626
|
+
}),
|
|
627
|
+
providers.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
628
|
+
className: `${ROW} py-5 text-sm text-muted-foreground`,
|
|
629
|
+
children: "No provider yet. Add one to give your Agents a model."
|
|
630
|
+
}),
|
|
631
|
+
/* @__PURE__ */ jsxs("div", {
|
|
632
|
+
className: `${ROW} bg-muted/50 py-3 text-[0.82rem] text-muted-foreground`,
|
|
633
|
+
children: [total - providers.length, " more can be added: a ChatGPT plan, API keys from OpenAI, Anthropic, Google and many others, or a model server on this computer."]
|
|
634
|
+
})
|
|
635
|
+
]
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region src/components/FieldRow.tsx
|
|
640
|
+
/** One provider setting, saved on its own (secrets are stored encrypted). */
|
|
641
|
+
function FieldRow({ field }) {
|
|
642
|
+
const router = useRouter();
|
|
643
|
+
const path = `/api/config/fields/${encodeURIComponent(field.envVar)}`;
|
|
644
|
+
const inputId = useId();
|
|
645
|
+
const descriptionId = `${inputId}-description`;
|
|
646
|
+
const [value, setValue] = useState(field.kind === "config" ? field.value ?? "" : "");
|
|
647
|
+
const [busy, setBusy] = useState(false);
|
|
648
|
+
const [err, setErr] = useState(null);
|
|
649
|
+
const [savedAt, setSavedAt] = useState(null);
|
|
650
|
+
const [confirmRemove, setConfirmRemove] = useState(false);
|
|
651
|
+
const secretBlank = field.kind === "secret" && value.trim().length === 0;
|
|
652
|
+
async function save(e) {
|
|
653
|
+
e.preventDefault();
|
|
654
|
+
if (secretBlank) {
|
|
655
|
+
setErr(field.set ? "Paste a replacement value, or use remove credential to explicitly clear the stored secret." : "A secret value is required.");
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
setBusy(true);
|
|
659
|
+
setErr(null);
|
|
660
|
+
try {
|
|
661
|
+
await api(path, {
|
|
662
|
+
method: "PUT",
|
|
663
|
+
body: { value }
|
|
664
|
+
});
|
|
665
|
+
setSavedAt(Date.now());
|
|
666
|
+
if (field.kind === "secret") setValue("");
|
|
667
|
+
await router.invalidate();
|
|
668
|
+
} catch (e) {
|
|
669
|
+
setErr(errorMessage(e));
|
|
670
|
+
} finally {
|
|
671
|
+
setBusy(false);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
async function removeSecret() {
|
|
675
|
+
await api(path, { method: "DELETE" });
|
|
676
|
+
setValue("");
|
|
677
|
+
setErr(null);
|
|
678
|
+
setSavedAt(Date.now());
|
|
679
|
+
await router.invalidate();
|
|
680
|
+
}
|
|
681
|
+
return /* @__PURE__ */ jsxs("form", {
|
|
682
|
+
onSubmit: save,
|
|
683
|
+
className: "grid grid-cols-1 gap-2 border-b py-3 last:border-0 md:grid-cols-[12rem_minmax(0,1fr)_auto_auto] md:items-center",
|
|
684
|
+
children: [
|
|
685
|
+
/* @__PURE__ */ jsxs("div", {
|
|
686
|
+
className: "min-w-0",
|
|
687
|
+
children: [
|
|
688
|
+
/* @__PURE__ */ jsx("label", {
|
|
689
|
+
htmlFor: inputId,
|
|
690
|
+
className: "text-sm font-medium text-foreground",
|
|
691
|
+
children: field.label
|
|
692
|
+
}),
|
|
693
|
+
field.description && /* @__PURE__ */ jsx("div", {
|
|
694
|
+
id: descriptionId,
|
|
695
|
+
className: "text-xs text-muted-foreground mt-0.5",
|
|
696
|
+
children: field.description
|
|
697
|
+
}),
|
|
698
|
+
/* @__PURE__ */ jsxs("details", {
|
|
699
|
+
className: "mt-1 text-xs text-muted-foreground",
|
|
700
|
+
children: [/* @__PURE__ */ jsx("summary", {
|
|
701
|
+
className: "cursor-pointer",
|
|
702
|
+
children: "Advanced identifier"
|
|
703
|
+
}), /* @__PURE__ */ jsx("code", {
|
|
704
|
+
className: "mt-1 inline-block break-all font-mono",
|
|
705
|
+
children: field.envVar
|
|
706
|
+
})]
|
|
707
|
+
})
|
|
708
|
+
]
|
|
709
|
+
}),
|
|
710
|
+
/* @__PURE__ */ jsx("div", {
|
|
711
|
+
className: "min-w-0",
|
|
712
|
+
children: field.kind === "config" ? /* @__PURE__ */ jsx("input", {
|
|
713
|
+
id: inputId,
|
|
714
|
+
type: "text",
|
|
715
|
+
"aria-describedby": field.description ? descriptionId : void 0,
|
|
716
|
+
value,
|
|
717
|
+
onChange: (e) => setValue(e.target.value),
|
|
718
|
+
placeholder: field.placeholder ?? "",
|
|
719
|
+
className: "w-full rounded-md border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-ring/30"
|
|
720
|
+
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("input", {
|
|
721
|
+
id: inputId,
|
|
722
|
+
type: "password",
|
|
723
|
+
"aria-describedby": field.description ? descriptionId : void 0,
|
|
724
|
+
value,
|
|
725
|
+
onChange: (e) => setValue(e.target.value),
|
|
726
|
+
placeholder: field.set ? "(paste to replace stored value)" : field.placeholder ?? "paste key…",
|
|
727
|
+
autoComplete: "off",
|
|
728
|
+
className: "w-full rounded-md border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-ring/30"
|
|
729
|
+
}), field.set && /* @__PURE__ */ jsx("p", {
|
|
730
|
+
className: "mt-1 text-xs text-muted-foreground",
|
|
731
|
+
children: "Blank keeps the current credential. Removal is a separate explicit action."
|
|
732
|
+
})] })
|
|
733
|
+
}),
|
|
734
|
+
/* @__PURE__ */ jsxs("span", {
|
|
735
|
+
className: "text-xs",
|
|
736
|
+
children: [field.kind === "secret" && field.set && /* @__PURE__ */ jsx("span", {
|
|
737
|
+
className: "rounded-full bg-success/10 text-success px-1.5 py-0.5",
|
|
738
|
+
title: `preview: ${field.preview ?? ""}`,
|
|
739
|
+
children: "set"
|
|
740
|
+
}), savedAt && Date.now() - savedAt < 2e3 && /* @__PURE__ */ jsx("span", {
|
|
741
|
+
role: "status",
|
|
742
|
+
className: "text-success ml-2",
|
|
743
|
+
children: "saved ✓"
|
|
744
|
+
})]
|
|
745
|
+
}),
|
|
746
|
+
/* @__PURE__ */ jsxs("div", {
|
|
747
|
+
className: "flex flex-wrap gap-2 md:justify-self-end",
|
|
748
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
749
|
+
variant: "ghost",
|
|
750
|
+
type: "submit",
|
|
751
|
+
disabled: busy || secretBlank,
|
|
752
|
+
className: "text-xs",
|
|
753
|
+
children: "save"
|
|
754
|
+
}), field.kind === "secret" && field.set && /* @__PURE__ */ jsx(Button, {
|
|
755
|
+
variant: "danger",
|
|
756
|
+
className: "text-xs",
|
|
757
|
+
onClick: () => setConfirmRemove(true),
|
|
758
|
+
children: "remove"
|
|
759
|
+
})]
|
|
760
|
+
}),
|
|
761
|
+
err && /* @__PURE__ */ jsx("p", {
|
|
762
|
+
role: "alert",
|
|
763
|
+
className: "text-xs text-danger md:col-span-4",
|
|
764
|
+
children: err
|
|
765
|
+
}),
|
|
766
|
+
/* @__PURE__ */ jsx(ConfirmDialog, {
|
|
767
|
+
open: confirmRemove,
|
|
768
|
+
title: `Remove ${field.label}?`,
|
|
769
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
770
|
+
"This permanently deletes the stored ",
|
|
771
|
+
/* @__PURE__ */ jsx("code", {
|
|
772
|
+
className: "font-mono",
|
|
773
|
+
children: field.envVar
|
|
774
|
+
}),
|
|
775
|
+
" ",
|
|
776
|
+
"credential. Features that use it will fail until you save a replacement."
|
|
777
|
+
] }),
|
|
778
|
+
confirmLabel: "remove stored credential",
|
|
779
|
+
onConfirm: removeSecret,
|
|
780
|
+
onOpenChange: setConfirmRemove
|
|
781
|
+
})
|
|
782
|
+
]
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
//#endregion
|
|
786
|
+
//#region src/components/setup/ProviderSheet.tsx
|
|
787
|
+
var HEADING = "m-0 font-body text-[0.72rem] font-bold uppercase tracking-[0.08em] text-muted-foreground";
|
|
788
|
+
/**
|
|
789
|
+
* One provider: whether it answers, its credentials, its models in Chat, and the rarer settings.
|
|
790
|
+
* Every change here reloads the page behind it.
|
|
791
|
+
*/
|
|
792
|
+
function ProviderSheet({ provider, chat, imageRoutes, imageSelected, onClose, onChanged, onPickModels, onReconnect }) {
|
|
793
|
+
const now = useMemo(() => Date.now(), []);
|
|
794
|
+
const [busy, setBusy] = useState(null);
|
|
795
|
+
const [error, setError] = useState(null);
|
|
796
|
+
const [showMore, setShowMore] = useState(false);
|
|
797
|
+
const [confirmDisconnect, setConfirmDisconnect] = useState(false);
|
|
798
|
+
const path = `/api/config/providers/${encodeURIComponent(provider.id)}`;
|
|
799
|
+
const { state, check } = provider;
|
|
800
|
+
const signin = provider.connect === "signin";
|
|
801
|
+
const mainFields = provider.fields.filter((field) => !field.advanced);
|
|
802
|
+
const advancedFields = provider.fields.filter((field) => field.advanced);
|
|
803
|
+
const agents = chat.reduce((sum, model) => sum + model.usedBy.agents, 0);
|
|
804
|
+
const drawing = imageRoutes.find((route) => route.id === imageSelected);
|
|
805
|
+
async function run(kind, work) {
|
|
806
|
+
setBusy(kind);
|
|
807
|
+
setError(null);
|
|
808
|
+
try {
|
|
809
|
+
await work();
|
|
810
|
+
await onChanged();
|
|
811
|
+
} catch (cause) {
|
|
812
|
+
setError(errorMessage(cause));
|
|
813
|
+
} finally {
|
|
814
|
+
setBusy(null);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
const test = () => run("test", () => api(`${path}/test`, { method: "POST" }));
|
|
818
|
+
const setEnabled = (enabled) => run("switch", () => api(`${path}/enabled`, {
|
|
819
|
+
method: "PUT",
|
|
820
|
+
body: { enabled }
|
|
821
|
+
}));
|
|
822
|
+
const signIn = () => run("signin", () => api("/api/auth/openai/login", { method: "POST" }));
|
|
823
|
+
async function disconnect() {
|
|
824
|
+
await api(path, { method: "DELETE" });
|
|
825
|
+
await onChanged();
|
|
826
|
+
onClose();
|
|
827
|
+
}
|
|
828
|
+
const canTest = provider.models.length > 0;
|
|
829
|
+
const testButton = (label, primary = false) => /* @__PURE__ */ jsx(Button, {
|
|
830
|
+
variant: primary ? "primary" : "ghost",
|
|
831
|
+
disabled: busy !== null,
|
|
832
|
+
onClick: () => void test(),
|
|
833
|
+
children: label
|
|
834
|
+
});
|
|
835
|
+
return /* @__PURE__ */ jsxs(Dialog, {
|
|
836
|
+
title: provider.displayName,
|
|
837
|
+
description: provider.hint,
|
|
838
|
+
onClose,
|
|
839
|
+
busy: busy === "signin",
|
|
840
|
+
className: "top-[4dvh] max-h-[92dvh] max-w-2xl translate-y-0 content-start gap-5",
|
|
841
|
+
children: [
|
|
842
|
+
busy === "test" ? /* @__PURE__ */ jsx("div", {
|
|
843
|
+
className: "rounded-2xl border border-border bg-muted/40 p-4",
|
|
844
|
+
children: /* @__PURE__ */ jsx(Waiting, { children: "Asking for a short reply…" })
|
|
845
|
+
}) : busy === "signin" ? /* @__PURE__ */ jsx("div", {
|
|
846
|
+
className: "rounded-2xl border border-border bg-muted/40 p-4",
|
|
847
|
+
children: /* @__PURE__ */ jsx(Waiting, { children: "Waiting for the ChatGPT sign-in in the browser…" })
|
|
848
|
+
}) : state === "working" && check ? /* @__PURE__ */ jsxs("div", {
|
|
849
|
+
role: "status",
|
|
850
|
+
className: "flex flex-wrap items-center gap-3 rounded-2xl border border-success/30 bg-success/10 p-4 text-sm",
|
|
851
|
+
children: [
|
|
852
|
+
/* @__PURE__ */ jsx(Check, {
|
|
853
|
+
className: "size-5 shrink-0 text-success",
|
|
854
|
+
"aria-hidden": "true"
|
|
855
|
+
}),
|
|
856
|
+
/* @__PURE__ */ jsxs("div", {
|
|
857
|
+
className: "min-w-0 flex-1 basis-48",
|
|
858
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
859
|
+
className: "font-semibold text-foreground",
|
|
860
|
+
children: [
|
|
861
|
+
check.modelName ?? check.model,
|
|
862
|
+
" answered in ",
|
|
863
|
+
((check.ms ?? 0) / 1e3).toFixed(1),
|
|
864
|
+
" s"
|
|
865
|
+
]
|
|
866
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
867
|
+
className: "text-muted-foreground",
|
|
868
|
+
children: ["Tested ", ago(check.at, now)]
|
|
869
|
+
})]
|
|
870
|
+
}),
|
|
871
|
+
testButton("Test again")
|
|
872
|
+
]
|
|
873
|
+
}) : state === "failing" && check?.failure ? /* @__PURE__ */ jsxs(FailureBox, {
|
|
874
|
+
failure: check.failure,
|
|
875
|
+
children: [
|
|
876
|
+
/* @__PURE__ */ jsxs("span", {
|
|
877
|
+
className: "mr-auto self-center text-xs text-muted-foreground",
|
|
878
|
+
children: ["Tried ", ago(check.at, now)]
|
|
879
|
+
}),
|
|
880
|
+
check.failure.kind === "credentials" && /* @__PURE__ */ jsx(Button, {
|
|
881
|
+
variant: "ghost",
|
|
882
|
+
onClick: signin ? () => void signIn() : onReconnect,
|
|
883
|
+
children: signin ? "Sign in again" : "Replace the key"
|
|
884
|
+
}),
|
|
885
|
+
testButton("Try again", true)
|
|
886
|
+
]
|
|
887
|
+
}) : state === "incomplete" ? /* @__PURE__ */ jsxs("div", {
|
|
888
|
+
role: "status",
|
|
889
|
+
className: "flex flex-wrap items-center gap-3 rounded-2xl border border-warning/35 bg-warning/10 p-4 text-sm",
|
|
890
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
891
|
+
className: "min-w-0 flex-1 basis-48",
|
|
892
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
893
|
+
className: "font-semibold text-foreground",
|
|
894
|
+
children: signin ? "Not signed in" : "Switched on, but its credentials are missing"
|
|
895
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
896
|
+
className: "text-muted-foreground",
|
|
897
|
+
children: "Agents on its models are refused until it is connected again."
|
|
898
|
+
})]
|
|
899
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
900
|
+
variant: "primary",
|
|
901
|
+
onClick: signin ? () => void signIn() : onReconnect,
|
|
902
|
+
children: signin ? "Sign in with ChatGPT" : "Connect"
|
|
903
|
+
})]
|
|
904
|
+
}) : state === "off" ? /* @__PURE__ */ jsxs("div", {
|
|
905
|
+
role: "status",
|
|
906
|
+
className: "flex flex-wrap items-center gap-3 rounded-2xl border border-border bg-muted/40 p-4 text-sm",
|
|
907
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
908
|
+
className: "min-w-0 flex-1 basis-48",
|
|
909
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
910
|
+
className: "font-semibold text-foreground",
|
|
911
|
+
children: provider.models.length === 0 ? "Saved, not in use" : "Turned off"
|
|
912
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
913
|
+
className: "text-muted-foreground",
|
|
914
|
+
children: provider.models.length === 0 ? "Connect it to choose its models and test it." : "Its models are out of Chat until you turn it on again. What is saved stays saved."
|
|
915
|
+
})]
|
|
916
|
+
}), provider.models.length === 0 ? /* @__PURE__ */ jsx(Button, {
|
|
917
|
+
variant: "primary",
|
|
918
|
+
disabled: busy !== null,
|
|
919
|
+
onClick: onReconnect,
|
|
920
|
+
children: "Connect"
|
|
921
|
+
}) : /* @__PURE__ */ jsx(Button, {
|
|
922
|
+
variant: "primary",
|
|
923
|
+
disabled: busy !== null || !provider.configured,
|
|
924
|
+
onClick: () => void setEnabled(true),
|
|
925
|
+
children: "Turn on"
|
|
926
|
+
})]
|
|
927
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
928
|
+
role: "status",
|
|
929
|
+
className: "flex flex-wrap items-center gap-3 rounded-2xl border border-border bg-muted/40 p-4 text-sm",
|
|
930
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
931
|
+
className: "min-w-0 flex-1 basis-48",
|
|
932
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
933
|
+
className: "font-semibold text-foreground",
|
|
934
|
+
children: "Not tested yet"
|
|
935
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
936
|
+
className: "text-muted-foreground",
|
|
937
|
+
children: canTest ? "A test sends one short message to its cheapest model in Chat." : "It has no model in Chat, so there is nothing to ask."
|
|
938
|
+
})]
|
|
939
|
+
}), canTest && testButton("Test now", true)]
|
|
940
|
+
}),
|
|
941
|
+
error && /* @__PURE__ */ jsx("p", {
|
|
942
|
+
role: "alert",
|
|
943
|
+
className: "m-0 rounded-xl bg-danger/10 px-3 py-2 text-sm text-danger",
|
|
944
|
+
children: error
|
|
945
|
+
}),
|
|
946
|
+
/* @__PURE__ */ jsxs("section", {
|
|
947
|
+
"aria-label": "Credentials",
|
|
948
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
949
|
+
className: HEADING,
|
|
950
|
+
children: signin ? "Sign-in" : provider.connect === "local" ? "Address" : "Credentials"
|
|
951
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
952
|
+
className: "mt-2 flex flex-wrap items-center gap-3",
|
|
953
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
954
|
+
className: "min-w-0 flex-1 basis-56 text-sm",
|
|
955
|
+
children: signin ? provider.configured ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
956
|
+
"Signed in with your ChatGPT account",
|
|
957
|
+
provider.account && /* @__PURE__ */ jsxs("span", {
|
|
958
|
+
className: "text-muted-foreground",
|
|
959
|
+
children: [
|
|
960
|
+
" (",
|
|
961
|
+
provider.account,
|
|
962
|
+
")"
|
|
963
|
+
]
|
|
964
|
+
}),
|
|
965
|
+
". Bazilion renews the sign-in by itself."
|
|
966
|
+
] }) : "Not signed in." : mainFields.length === 0 ? /* @__PURE__ */ jsx("span", {
|
|
967
|
+
className: "text-muted-foreground",
|
|
968
|
+
children: provider.configured ? "Read from the environment of the machine Bazilion runs on." : "Not found in the environment of the machine Bazilion runs on."
|
|
969
|
+
}) : /* @__PURE__ */ jsx("dl", {
|
|
970
|
+
className: "m-0 grid gap-1",
|
|
971
|
+
children: mainFields.map((field) => /* @__PURE__ */ jsxs("div", {
|
|
972
|
+
className: "flex flex-wrap gap-x-2",
|
|
973
|
+
children: [/* @__PURE__ */ jsx("dt", {
|
|
974
|
+
className: "text-muted-foreground",
|
|
975
|
+
children: field.label
|
|
976
|
+
}), /* @__PURE__ */ jsx("dd", {
|
|
977
|
+
className: "m-0 min-w-0 break-all font-mono text-[0.85em]",
|
|
978
|
+
children: field.kind === "secret" ? field.set ? `${field.preview ?? "saved"}, stored encrypted` : "not saved" : field.value || (provider.address ?? "not set")
|
|
979
|
+
})]
|
|
980
|
+
}, field.envVar))
|
|
981
|
+
})
|
|
982
|
+
}), signin ? /* @__PURE__ */ jsx(Button, {
|
|
983
|
+
variant: "ghost",
|
|
984
|
+
disabled: busy !== null,
|
|
985
|
+
onClick: () => void signIn(),
|
|
986
|
+
children: provider.configured ? "Sign in again" : "Sign in with ChatGPT"
|
|
987
|
+
}) : mainFields.length > 0 && /* @__PURE__ */ jsx(Button, {
|
|
988
|
+
variant: "ghost",
|
|
989
|
+
disabled: busy !== null,
|
|
990
|
+
onClick: onReconnect,
|
|
991
|
+
children: provider.connect === "local" ? "Change the address" : mainFields.some((field) => field.kind === "secret" && !field.set) ? "Add the key" : "Replace the key"
|
|
992
|
+
})]
|
|
993
|
+
})]
|
|
994
|
+
}),
|
|
995
|
+
/* @__PURE__ */ jsxs("section", {
|
|
996
|
+
"aria-label": "Its models in Chat",
|
|
997
|
+
children: [
|
|
998
|
+
/* @__PURE__ */ jsxs("div", {
|
|
999
|
+
className: "flex items-center gap-3",
|
|
1000
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
1001
|
+
className: `${HEADING} flex-1`,
|
|
1002
|
+
children: "Its models in Chat"
|
|
1003
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
1004
|
+
type: "button",
|
|
1005
|
+
onClick: onPickModels,
|
|
1006
|
+
className: "text-sm font-semibold text-primary",
|
|
1007
|
+
children: "Choose models"
|
|
1008
|
+
})]
|
|
1009
|
+
}),
|
|
1010
|
+
/* @__PURE__ */ jsxs("ul", {
|
|
1011
|
+
className: "m-0 mt-2 list-none divide-y divide-border overflow-hidden rounded-xl border border-border p-0",
|
|
1012
|
+
children: [provider.models.length === 0 && /* @__PURE__ */ jsx("li", {
|
|
1013
|
+
className: "px-3 py-2.5 text-sm text-muted-foreground",
|
|
1014
|
+
children: "None of its models is in Chat."
|
|
1015
|
+
}), provider.models.map((id) => {
|
|
1016
|
+
const model = chat.find((entry) => entry.id === id);
|
|
1017
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
1018
|
+
className: "flex flex-wrap items-center gap-x-3 px-3 py-2.5 text-sm",
|
|
1019
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1020
|
+
className: "min-w-0 flex-1 basis-40 font-semibold text-foreground",
|
|
1021
|
+
children: model ? modelName(model) : id
|
|
1022
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1023
|
+
className: "text-muted-foreground",
|
|
1024
|
+
children: model ? usedByLine(model.usedBy) : "Out of Chat while this is turned off"
|
|
1025
|
+
})]
|
|
1026
|
+
}, id);
|
|
1027
|
+
})]
|
|
1028
|
+
}),
|
|
1029
|
+
imageRoutes.length > 0 && /* @__PURE__ */ jsx("p", {
|
|
1030
|
+
className: "m-0 mt-2 text-sm text-muted-foreground",
|
|
1031
|
+
children: drawing ? `Images are drawn by ${drawing.model} through this provider.` : `Can also draw images: ${[...new Set(imageRoutes.map((route) => route.model))].join(", ")}.`
|
|
1032
|
+
})
|
|
1033
|
+
]
|
|
1034
|
+
}),
|
|
1035
|
+
/* @__PURE__ */ jsxs("section", {
|
|
1036
|
+
"aria-label": "More settings",
|
|
1037
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
1038
|
+
type: "button",
|
|
1039
|
+
"aria-expanded": showMore,
|
|
1040
|
+
onClick: () => setShowMore((open) => !open),
|
|
1041
|
+
className: "flex items-center gap-1.5 text-sm font-semibold text-foreground",
|
|
1042
|
+
children: [/* @__PURE__ */ jsx(ChevronRight, {
|
|
1043
|
+
className: `size-4 text-muted-foreground transition-transform ${showMore ? "rotate-90" : ""}`,
|
|
1044
|
+
"aria-hidden": "true"
|
|
1045
|
+
}), "More settings"]
|
|
1046
|
+
}), showMore && /* @__PURE__ */ jsxs("div", {
|
|
1047
|
+
className: "mt-2 grid gap-3 rounded-xl border border-border bg-muted/40 p-4",
|
|
1048
|
+
children: [
|
|
1049
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1050
|
+
className: "flex items-center gap-3",
|
|
1051
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1052
|
+
className: "min-w-0 flex-1 text-sm",
|
|
1053
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1054
|
+
className: "font-semibold text-foreground",
|
|
1055
|
+
children: "Agents may use this provider"
|
|
1056
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1057
|
+
className: "text-muted-foreground",
|
|
1058
|
+
children: "Turn off to pause it without removing what is saved."
|
|
1059
|
+
})]
|
|
1060
|
+
}), /* @__PURE__ */ jsx(Switch, {
|
|
1061
|
+
checked: provider.enabled,
|
|
1062
|
+
label: "Agents may use this provider",
|
|
1063
|
+
disabled: busy !== null || !provider.enabled && !provider.configured,
|
|
1064
|
+
onChange: (enabled) => void setEnabled(enabled)
|
|
1065
|
+
})]
|
|
1066
|
+
}),
|
|
1067
|
+
advancedFields.map((field) => /* @__PURE__ */ jsx(FieldRow, { field }, field.envVar)),
|
|
1068
|
+
provider.fields.length > 0 && /* @__PURE__ */ jsxs("p", {
|
|
1069
|
+
className: "m-0 text-xs text-muted-foreground",
|
|
1070
|
+
children: [
|
|
1071
|
+
"Setting names, for ",
|
|
1072
|
+
/* @__PURE__ */ jsx("code", { children: "bazilion config set" }),
|
|
1073
|
+
" and the daemon’s environment:",
|
|
1074
|
+
" ",
|
|
1075
|
+
provider.fields.map((field) => field.envVar).join(", "),
|
|
1076
|
+
". A value set in the environment wins over the one saved here."
|
|
1077
|
+
]
|
|
1078
|
+
})
|
|
1079
|
+
]
|
|
1080
|
+
})]
|
|
1081
|
+
}),
|
|
1082
|
+
/* @__PURE__ */ jsxs("section", {
|
|
1083
|
+
"aria-label": "Disconnect",
|
|
1084
|
+
className: "border-t border-frost pt-4",
|
|
1085
|
+
children: [/* @__PURE__ */ jsxs(Button, {
|
|
1086
|
+
variant: "danger",
|
|
1087
|
+
disabled: busy !== null,
|
|
1088
|
+
onClick: () => setConfirmDisconnect(true),
|
|
1089
|
+
children: ["Disconnect ", provider.displayName]
|
|
1090
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
1091
|
+
className: "m-0 mt-2 text-sm text-muted-foreground",
|
|
1092
|
+
children: [
|
|
1093
|
+
"Removes",
|
|
1094
|
+
" ",
|
|
1095
|
+
signin ? "the sign-in" : provider.connect === "local" ? "the address" : "the key",
|
|
1096
|
+
", its models from Chat and its test."
|
|
1097
|
+
]
|
|
1098
|
+
})]
|
|
1099
|
+
}),
|
|
1100
|
+
/* @__PURE__ */ jsx(ConfirmDialog, {
|
|
1101
|
+
open: confirmDisconnect,
|
|
1102
|
+
onOpenChange: setConfirmDisconnect,
|
|
1103
|
+
title: `Disconnect ${provider.displayName}?`,
|
|
1104
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1105
|
+
/* @__PURE__ */ jsxs("p", {
|
|
1106
|
+
className: "m-0",
|
|
1107
|
+
children: [
|
|
1108
|
+
"This removes",
|
|
1109
|
+
" ",
|
|
1110
|
+
signin ? "the saved ChatGPT sign-in" : provider.connect === "local" ? "the saved address" : "the saved credentials",
|
|
1111
|
+
" ",
|
|
1112
|
+
"and takes its ",
|
|
1113
|
+
provider.models.length === 1 ? "model" : "models",
|
|
1114
|
+
" out of Chat."
|
|
1115
|
+
]
|
|
1116
|
+
}),
|
|
1117
|
+
agents > 0 && /* @__PURE__ */ jsxs("p", {
|
|
1118
|
+
className: "m-0 mt-2",
|
|
1119
|
+
children: [agents === 1 ? "1 Agent runs" : `${agents} Agents run`, " on its models and will be refused until given another model. Agent templates move to another model by themselves."]
|
|
1120
|
+
}),
|
|
1121
|
+
drawing && /* @__PURE__ */ jsx("p", {
|
|
1122
|
+
className: "m-0 mt-2",
|
|
1123
|
+
children: "Image generation stops until another route is chosen."
|
|
1124
|
+
})
|
|
1125
|
+
] }),
|
|
1126
|
+
confirmLabel: `Disconnect ${provider.displayName}`,
|
|
1127
|
+
onConfirm: disconnect
|
|
1128
|
+
})
|
|
1129
|
+
]
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
//#endregion
|
|
1133
|
+
//#region src/routes/config/index.tsx?tsr-split=component
|
|
1134
|
+
function ModelsPage() {
|
|
1135
|
+
const { providers, models, now } = Route.useLoaderData();
|
|
1136
|
+
const search = Route.useSearch();
|
|
1137
|
+
const navigate = Route.useNavigate();
|
|
1138
|
+
const router = useRouter();
|
|
1139
|
+
const [testing, setTesting] = useState(false);
|
|
1140
|
+
const listed = providers.filter((provider) => provider.listed);
|
|
1141
|
+
const usable = listed.filter((provider) => provider.enabled);
|
|
1142
|
+
const open = (next) => void navigate({ search: next });
|
|
1143
|
+
const close = () => open({});
|
|
1144
|
+
const reload = () => router.invalidate({ sync: true });
|
|
1145
|
+
const sheet = providers.find((provider) => provider.id === search.provider && provider.listed);
|
|
1146
|
+
async function testAll() {
|
|
1147
|
+
setTesting(true);
|
|
1148
|
+
try {
|
|
1149
|
+
await Promise.all(usable.filter((provider) => provider.models.length > 0).map((provider) => api(`/api/config/providers/${encodeURIComponent(provider.id)}/test`, { method: "POST" }).catch(() => void 0)));
|
|
1150
|
+
await reload();
|
|
1151
|
+
} finally {
|
|
1152
|
+
setTesting(false);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
return /* @__PURE__ */ jsxs(ConfigPage, {
|
|
1156
|
+
title: "Models",
|
|
1157
|
+
description: "What your Agents think and draw with, and the accounts behind it.",
|
|
1158
|
+
children: [
|
|
1159
|
+
/* @__PURE__ */ jsx(StatusLine, {
|
|
1160
|
+
providers: listed,
|
|
1161
|
+
chat: models.chat,
|
|
1162
|
+
now,
|
|
1163
|
+
testing,
|
|
1164
|
+
onOpen: (id) => open({ provider: id }),
|
|
1165
|
+
onTestAll: () => void testAll()
|
|
1166
|
+
}),
|
|
1167
|
+
/* @__PURE__ */ jsx(ChatModelsCard, {
|
|
1168
|
+
chat: models.chat,
|
|
1169
|
+
hasProviders: usable.length > 0,
|
|
1170
|
+
onPick: () => open({ pick: true }),
|
|
1171
|
+
onChanged: reload
|
|
1172
|
+
}),
|
|
1173
|
+
/* @__PURE__ */ jsx(ImagesCard, {
|
|
1174
|
+
images: models.images,
|
|
1175
|
+
onConnect: (id) => open({ add: id }),
|
|
1176
|
+
onChanged: reload
|
|
1177
|
+
}),
|
|
1178
|
+
/* @__PURE__ */ jsx(ProvidersCard, {
|
|
1179
|
+
providers: listed,
|
|
1180
|
+
total: providers.length,
|
|
1181
|
+
images: models.images,
|
|
1182
|
+
now,
|
|
1183
|
+
onOpen: (id) => open({ provider: id }),
|
|
1184
|
+
onAdd: () => open({ add: "new" })
|
|
1185
|
+
}),
|
|
1186
|
+
search.add && /* @__PURE__ */ jsx(AddProviderDialog, {
|
|
1187
|
+
providers,
|
|
1188
|
+
imageRoutes: models.images.routes,
|
|
1189
|
+
start: search.add === "new" ? void 0 : search.add,
|
|
1190
|
+
onClose: close,
|
|
1191
|
+
onConnected: reload,
|
|
1192
|
+
onOpenProvider: (id) => open({ provider: id })
|
|
1193
|
+
}, search.add),
|
|
1194
|
+
search.pick && /* @__PURE__ */ jsx(ModelPicker, {
|
|
1195
|
+
providers: usable,
|
|
1196
|
+
chat: models.chat,
|
|
1197
|
+
onClose: close,
|
|
1198
|
+
onSaved: reload,
|
|
1199
|
+
onAddProvider: () => open({ add: "new" })
|
|
1200
|
+
}),
|
|
1201
|
+
sheet && /* @__PURE__ */ jsx(ProviderSheet, {
|
|
1202
|
+
provider: sheet,
|
|
1203
|
+
chat: models.chat.filter((model) => model.provider === sheet.id),
|
|
1204
|
+
imageRoutes: models.images.routes.filter((route) => route.provider === sheet.id),
|
|
1205
|
+
imageSelected: models.images.selected,
|
|
1206
|
+
onClose: close,
|
|
1207
|
+
onChanged: reload,
|
|
1208
|
+
onPickModels: () => open({ pick: true }),
|
|
1209
|
+
onReconnect: () => open({ add: sheet.id })
|
|
1210
|
+
}, sheet.id)
|
|
1211
|
+
]
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
//#endregion
|
|
1215
|
+
export { ModelsPage as component };
|