@kwirthmagnify/kwirth-common-ai 0.5.76 → 0.5.77
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/front.js +13 -50
- package/package.json +1 -1
package/dist/front.js
CHANGED
|
@@ -49,27 +49,22 @@ const material_1 = require("@mui/material");
|
|
|
49
49
|
That is why the "no deep imports" rule is only for PLUGINS — there it breaks @emotion, which loads a
|
|
50
50
|
copy of its own — and common-front and common-ai are the documented exception.
|
|
51
51
|
*/
|
|
52
|
-
const Download_1 = __importDefault(require("@mui/icons-material/Download"));
|
|
53
|
-
const Upload_1 = __importDefault(require("@mui/icons-material/Upload"));
|
|
54
52
|
const Visibility_1 = __importDefault(require("@mui/icons-material/Visibility"));
|
|
55
53
|
const VisibilityOff_1 = __importDefault(require("@mui/icons-material/VisibilityOff"));
|
|
56
|
-
const downloadJson = async (data, filename) => {
|
|
57
|
-
var _a;
|
|
58
|
-
const json = JSON.stringify(data, null, 2);
|
|
59
|
-
const tauri = window.__TAURI__;
|
|
60
|
-
if ((_a = tauri === null || tauri === void 0 ? void 0 : tauri.core) === null || _a === void 0 ? void 0 : _a.invoke) {
|
|
61
|
-
await tauri.core.invoke('save_file_dialog', { filename, content: json });
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const blob = new Blob([json], { type: 'application/json' });
|
|
65
|
-
const url = URL.createObjectURL(blob);
|
|
66
|
-
const a = document.createElement('a');
|
|
67
|
-
a.href = url;
|
|
68
|
-
a.download = filename;
|
|
69
|
-
a.click();
|
|
70
|
-
URL.revokeObjectURL(url);
|
|
71
|
-
};
|
|
72
54
|
const index_1 = require("./index");
|
|
55
|
+
/*
|
|
56
|
+
🔴 These dialogs HAVE NO Import/Export of their own, and that is deliberate — do not add them back.
|
|
57
|
+
|
|
58
|
+
Both lists travel in the core's configuration bundle, under `core/sharedAi` ('AI providers and
|
|
59
|
+
models'), which is reached from ☰ → Kwirth export / Kwirth import. It writes to the very same
|
|
60
|
+
configmap and secret these dialogs do, so a second door onto the same store could only diverge from
|
|
61
|
+
it — and it had: the local export emitted a hand-written subset of the provider, so the prices and
|
|
62
|
+
the limits added on 2026-10-26 were silently dropped, and the local import replaced the whole list
|
|
63
|
+
from an unvalidated file, with a `catch {}` that said nothing when the file was not one.
|
|
64
|
+
|
|
65
|
+
The bundle also honours the 'Include credentials' tick (see `redactSharedAi` in the core), which a
|
|
66
|
+
plain download of the list in clear could not.
|
|
67
|
+
*/
|
|
73
68
|
/*
|
|
74
69
|
The height of the content of BOTH config dialogs, and the one number that keeps them still.
|
|
75
70
|
|
|
@@ -185,7 +180,6 @@ exports.LlmSelector = LlmSelector;
|
|
|
185
180
|
const AiConfigLlm = (props) => {
|
|
186
181
|
var _a, _b, _c;
|
|
187
182
|
const [llms, setLlms] = (0, react_1.useState)(JSON.parse(JSON.stringify(props.llms)));
|
|
188
|
-
const importLlmRef = (0, react_1.useRef)(null);
|
|
189
183
|
const [selectedIndex, setSelectedIndex] = (0, react_1.useState)(null);
|
|
190
184
|
const [showPassword, setShowPassword] = (0, react_1.useState)(false);
|
|
191
185
|
const [id, setId] = (0, react_1.useState)('');
|
|
@@ -314,21 +308,6 @@ const AiConfigLlm = (props) => {
|
|
|
314
308
|
react_1.default.createElement(material_1.Button, { color: 'error', onClick: onRemove, disabled: selectedIndex === null }, "Remove"),
|
|
315
309
|
react_1.default.createElement(material_1.Button, { variant: 'contained', onClick: onAdd, disabled: !id || !model }, selectedIndex !== null ? 'Update' : 'Add')))),
|
|
316
310
|
react_1.default.createElement(material_1.DialogActions, null,
|
|
317
|
-
react_1.default.createElement("input", { ref: importLlmRef, type: 'file', accept: '.json', style: { display: 'none' }, onChange: e => {
|
|
318
|
-
var _a;
|
|
319
|
-
const f = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
320
|
-
if (!f)
|
|
321
|
-
return;
|
|
322
|
-
const reader = new FileReader();
|
|
323
|
-
reader.onload = ev => { try {
|
|
324
|
-
setLlms(JSON.parse(ev.target.result));
|
|
325
|
-
}
|
|
326
|
-
catch (_a) { } };
|
|
327
|
-
reader.readAsText(f);
|
|
328
|
-
e.target.value = '';
|
|
329
|
-
} }),
|
|
330
|
-
react_1.default.createElement(material_1.Button, { variant: 'outlined', startIcon: react_1.default.createElement(Upload_1.default, { fontSize: 'small' }), onClick: () => { var _a; return (_a = importLlmRef.current) === null || _a === void 0 ? void 0 : _a.click(); } }, "Import"),
|
|
331
|
-
react_1.default.createElement(material_1.Button, { variant: 'outlined', startIcon: react_1.default.createElement(Download_1.default, { fontSize: 'small' }), onClick: () => downloadJson(llms, 'kwirth-llms.json') }, "Export"),
|
|
332
311
|
react_1.default.createElement(material_1.Box, { flex: 1 }),
|
|
333
312
|
react_1.default.createElement(material_1.Button, { onClick: () => props.onClose(llms), variant: 'contained' }, "OK"),
|
|
334
313
|
react_1.default.createElement(material_1.Button, { onClick: () => props.onClose(undefined), variant: 'outlined' }, "Cancel"))));
|
|
@@ -337,7 +316,6 @@ exports.AiConfigLlm = AiConfigLlm;
|
|
|
337
316
|
const AiConfigProvider = (props) => {
|
|
338
317
|
var _a, _b;
|
|
339
318
|
const [providers, setProviders] = (0, react_1.useState)(JSON.parse(JSON.stringify(props.providers)));
|
|
340
|
-
const importProvRef = (0, react_1.useRef)(null);
|
|
341
319
|
const [selectedIndex, setSelectedIndex] = (0, react_1.useState)(null);
|
|
342
320
|
const [showPassword, setShowPassword] = (0, react_1.useState)(false);
|
|
343
321
|
const [loadingModels, setLoadingModels] = (0, react_1.useState)(false);
|
|
@@ -465,21 +443,6 @@ const AiConfigProvider = (props) => {
|
|
|
465
443
|
react_1.default.createElement(material_1.Button, { variant: 'text', color: 'error', onClick: onRemove, disabled: selectedIndex === null }, "Remove"),
|
|
466
444
|
react_1.default.createElement(material_1.Button, { variant: 'contained', onClick: onAdd, disabled: !providerName.trim() || !providerType }, selectedIndex !== null ? 'Update' : 'Add')))),
|
|
467
445
|
react_1.default.createElement(material_1.DialogActions, { sx: { p: 2 } },
|
|
468
|
-
react_1.default.createElement("input", { ref: importProvRef, type: 'file', accept: '.json', style: { display: 'none' }, onChange: e => {
|
|
469
|
-
var _a;
|
|
470
|
-
const f = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
471
|
-
if (!f)
|
|
472
|
-
return;
|
|
473
|
-
const reader = new FileReader();
|
|
474
|
-
reader.onload = ev => { try {
|
|
475
|
-
setProviders(JSON.parse(ev.target.result));
|
|
476
|
-
}
|
|
477
|
-
catch (_a) { } };
|
|
478
|
-
reader.readAsText(f);
|
|
479
|
-
e.target.value = '';
|
|
480
|
-
} }),
|
|
481
|
-
react_1.default.createElement(material_1.Button, { variant: 'outlined', startIcon: react_1.default.createElement(Upload_1.default, { fontSize: 'small' }), onClick: () => { var _a; return (_a = importProvRef.current) === null || _a === void 0 ? void 0 : _a.click(); } }, "Import"),
|
|
482
|
-
react_1.default.createElement(material_1.Button, { variant: 'outlined', startIcon: react_1.default.createElement(Download_1.default, { fontSize: 'small' }), onClick: () => downloadJson(providers.map(p => { var _a; return (Object.assign({ name: p.name, type: (_a = p.type) !== null && _a !== void 0 ? _a : p.name, key: p.key }, (p.endpoint ? { endpoint: p.endpoint } : {}))); }), 'kwirth-providers.json') }, "Export"),
|
|
483
446
|
react_1.default.createElement(material_1.Box, { flex: 1 }),
|
|
484
447
|
react_1.default.createElement(material_1.Button, { onClick: () => props.onClose(providers), variant: 'contained' }, "Save"),
|
|
485
448
|
react_1.default.createElement(material_1.Button, { onClick: () => props.onClose(undefined), variant: 'outlined' }, "Cancel"))));
|