dsh-model-capability-sync 0.0.0-stage → 0.2.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/CHANGELOG.md +55 -0
- package/LICENSE +21 -0
- package/README.md +237 -2
- package/cordis.patch.yml +8 -0
- package/lib/client.js +1168 -0
- package/lib/client.js.map +7 -0
- package/lib/index.js +445 -0
- package/lib/index.js.map +7 -0
- package/package.json +95 -4
- package/scripts/build-client.mjs +42 -0
- package/scripts/build-host.mjs +22 -0
- package/scripts/smoke.mjs +56 -0
- package/scripts/test-fields.mjs +56 -0
- package/scripts/test-locale.mjs +54 -0
- package/scripts/test-match.mjs +268 -0
- package/scripts/test-rename.mjs +88 -0
- package/scripts/test-sort.mjs +82 -0
- package/scripts/test-write-merge.mjs +104 -0
- package/scripts/verify-package.mjs +64 -0
- package/scripts/warm-cache.mjs +15 -0
- package/src/catalog.ts +204 -0
- package/src/client/SyncSection.tsx +870 -0
- package/src/client/apply.ts +257 -0
- package/src/client/index.ts +6 -0
- package/src/client/locale.ts +158 -0
- package/src/client/rename.ts +157 -0
- package/src/client/shared.ts +197 -0
- package/src/index.ts +150 -0
- package/src/mapping.ts +73 -0
- package/src/match.ts +431 -0
- package/src/sort.ts +174 -0
- package/src/types.ts +136 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,1168 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: "dsh-model-capability-sync", factory: (require) => {
|
|
2
|
+
var module = { exports: {} }; var exports = module.exports;
|
|
3
|
+
"use strict";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/client/index.ts
|
|
23
|
+
var index_exports = {};
|
|
24
|
+
__export(index_exports, {
|
|
25
|
+
apply: () => apply,
|
|
26
|
+
inject: () => inject
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// src/client/SyncSection.tsx
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
|
|
33
|
+
// src/sort.ts
|
|
34
|
+
function modelSortKey(id) {
|
|
35
|
+
const slash = id.lastIndexOf("/");
|
|
36
|
+
if (slash === -1) {
|
|
37
|
+
const folded = id.toLowerCase();
|
|
38
|
+
return { group: folded, name: folded };
|
|
39
|
+
}
|
|
40
|
+
return { group: id.slice(0, slash).toLowerCase(), name: id.slice(slash + 1).toLowerCase() };
|
|
41
|
+
}
|
|
42
|
+
function sourcePrefix(id) {
|
|
43
|
+
const slash = id.indexOf("/");
|
|
44
|
+
return slash <= 0 ? "" : id.slice(0, slash);
|
|
45
|
+
}
|
|
46
|
+
function redirectedSortKey(id, name) {
|
|
47
|
+
const idPrefix = sourcePrefix(id);
|
|
48
|
+
const displayName = name !== "" ? name : id;
|
|
49
|
+
let extracted = "";
|
|
50
|
+
let cleaned = displayName;
|
|
51
|
+
const leadingFullWidthMatch = displayName.match(/^【([^】]+)】\s*/);
|
|
52
|
+
if (leadingFullWidthMatch) {
|
|
53
|
+
extracted = leadingFullWidthMatch[1] ?? "";
|
|
54
|
+
cleaned = displayName.slice(leadingFullWidthMatch[0].length).trim();
|
|
55
|
+
} else {
|
|
56
|
+
const trailingFullWidthMatch = displayName.match(/【([^】]+)】\s*$/);
|
|
57
|
+
if (trailingFullWidthMatch) {
|
|
58
|
+
extracted = trailingFullWidthMatch[1] ?? "";
|
|
59
|
+
cleaned = displayName.slice(0, -trailingFullWidthMatch[0].length).trim();
|
|
60
|
+
} else {
|
|
61
|
+
const halfWidthMatch = displayName.match(/[([]\s*([^)\]]*)\s*[)\]]\s*/);
|
|
62
|
+
if (halfWidthMatch) {
|
|
63
|
+
extracted = halfWidthMatch[1] ?? "";
|
|
64
|
+
cleaned = displayName.replace(halfWidthMatch[0], "").trim();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const sortPrefix = extracted !== "" ? extracted : idPrefix !== "" ? idPrefix : "other";
|
|
69
|
+
const sortName = cleaned !== "" ? cleaned : idPrefix !== "" ? id.slice(idPrefix.length + 1) : id;
|
|
70
|
+
return [sortPrefix.toLowerCase(), sortName.toLowerCase()];
|
|
71
|
+
}
|
|
72
|
+
function compareModelIds(left, right) {
|
|
73
|
+
const a = modelSortKey(left);
|
|
74
|
+
const b = modelSortKey(right);
|
|
75
|
+
if (a.group !== b.group) return a.group < b.group ? -1 : 1;
|
|
76
|
+
if (a.name !== b.name) return a.name < b.name ? -1 : 1;
|
|
77
|
+
if (left === right) return 0;
|
|
78
|
+
return left < right ? -1 : 1;
|
|
79
|
+
}
|
|
80
|
+
function compareRedirected(left, right, nameOf) {
|
|
81
|
+
const [aPrefix, aName] = redirectedSortKey(left, nameOf(left));
|
|
82
|
+
const [bPrefix, bName] = redirectedSortKey(right, nameOf(right));
|
|
83
|
+
if (aPrefix !== bPrefix) return aPrefix < bPrefix ? -1 : 1;
|
|
84
|
+
if (aName !== bName) return aName < bName ? -1 : 1;
|
|
85
|
+
if (left === right) return 0;
|
|
86
|
+
return left < right ? -1 : 1;
|
|
87
|
+
}
|
|
88
|
+
function sortByModelId(items, idOf, nameOf = () => "", mode = "prefix") {
|
|
89
|
+
const copy = [...items];
|
|
90
|
+
if (mode === "redirected") {
|
|
91
|
+
const names = new Map(copy.map((item) => [idOf(item), nameOf(item)]));
|
|
92
|
+
return copy.sort((left, right) => compareRedirected(idOf(left), idOf(right), (id) => names.get(id) ?? ""));
|
|
93
|
+
}
|
|
94
|
+
return copy.sort((left, right) => compareModelIds(idOf(left), idOf(right)));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/client/shared.ts
|
|
98
|
+
var TARGET_DEFAULT = "llm-pi-ai";
|
|
99
|
+
var TARGET_DIRECTORY = {
|
|
100
|
+
"llm-pi-ai": { native: true, nameKey: "nameLlmPiAi" },
|
|
101
|
+
"llm-deepseek": { native: true, nameKey: "nameLlmDeepseek" },
|
|
102
|
+
"llm-deepseek-account": { native: true, nameKey: "nameLlmDeepseekAccount" },
|
|
103
|
+
"llm-newapi": { native: false, nameKey: "nameLlmNewapi" }
|
|
104
|
+
};
|
|
105
|
+
function targetLabelOf(ns, t) {
|
|
106
|
+
const known = TARGET_DIRECTORY[ns];
|
|
107
|
+
if (known === void 0) return `${t("sourcePlugin")} \xB7 ${ns}`;
|
|
108
|
+
return `${known.native ? t("sourceNative") : t("sourcePlugin")} \xB7 ${t(known.nameKey)}`;
|
|
109
|
+
}
|
|
110
|
+
function providersOf(descriptor) {
|
|
111
|
+
const providers = descriptor?.value?.providers;
|
|
112
|
+
return typeof providers === "object" && providers !== null ? providers : {};
|
|
113
|
+
}
|
|
114
|
+
function modelsOf(provider) {
|
|
115
|
+
const models = provider?.models;
|
|
116
|
+
return Array.isArray(models) ? models.filter((entry) => typeof entry === "object" && entry !== null) : [];
|
|
117
|
+
}
|
|
118
|
+
function sortedModelsOf(provider, mode = "prefix") {
|
|
119
|
+
return sortByModelId(
|
|
120
|
+
modelsOf(provider),
|
|
121
|
+
(model) => textOf(model, "id"),
|
|
122
|
+
(model) => textOf(model, "name"),
|
|
123
|
+
mode
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
function textOf(model, key) {
|
|
127
|
+
const value = model[key];
|
|
128
|
+
return typeof value === "string" ? value : "";
|
|
129
|
+
}
|
|
130
|
+
function isBlank(value) {
|
|
131
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
132
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
133
|
+
if (typeof value === "object") return Object.keys(value).length === 0;
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
function withWrittenModels(descriptor, providerKey, models, revision) {
|
|
137
|
+
const providers = providersOf(descriptor);
|
|
138
|
+
const provider = providers[providerKey];
|
|
139
|
+
const nextProviders = provider === void 0 ? providers : { ...providers, [providerKey]: { ...provider, models: [...models] } };
|
|
140
|
+
return {
|
|
141
|
+
...descriptor,
|
|
142
|
+
...revision === void 0 ? {} : { revision },
|
|
143
|
+
value: { ...descriptor.value, providers: nextProviders }
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function parseTokenCount(text) {
|
|
147
|
+
const trimmed = text.trim().replace(/[,_\s]/g, "");
|
|
148
|
+
if (trimmed === "") return void 0;
|
|
149
|
+
const match = /^([0-9]+(?:\.[0-9]+)?)([kKmM])?$/.exec(trimmed);
|
|
150
|
+
if (match === null) return void 0;
|
|
151
|
+
const amount = Number(match[1]);
|
|
152
|
+
if (!Number.isFinite(amount) || amount <= 0) return void 0;
|
|
153
|
+
const suffix = match[2]?.toLowerCase();
|
|
154
|
+
if (suffix === "k") return Math.round(amount * 1e3);
|
|
155
|
+
if (suffix === "m") return Math.round(amount * 1e6);
|
|
156
|
+
return Math.round(amount);
|
|
157
|
+
}
|
|
158
|
+
function mergeFields(base, manual) {
|
|
159
|
+
if (base === void 0) return manual;
|
|
160
|
+
if (manual === void 0) return base;
|
|
161
|
+
return { ...base, ...manual };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/client/rename.ts
|
|
165
|
+
function sourcePrefixOf(id) {
|
|
166
|
+
const slash = id.indexOf("/");
|
|
167
|
+
if (slash <= 0) return "";
|
|
168
|
+
return id.slice(0, slash);
|
|
169
|
+
}
|
|
170
|
+
function bareIdOf(id) {
|
|
171
|
+
const slash = id.indexOf("/");
|
|
172
|
+
if (slash === -1) return id;
|
|
173
|
+
const rest = id.slice(slash + 1);
|
|
174
|
+
return rest === "" ? id : rest;
|
|
175
|
+
}
|
|
176
|
+
function redirectName(id, name) {
|
|
177
|
+
let prefix = sourcePrefixOf(id);
|
|
178
|
+
if (prefix === "") prefix = "other";
|
|
179
|
+
const before = name !== "" ? name : id;
|
|
180
|
+
const prefix_bracket = `\u3010${prefix}\u3011`;
|
|
181
|
+
const prefix_space = `${prefix_bracket} `;
|
|
182
|
+
if (before.startsWith(prefix_space)) {
|
|
183
|
+
return { prefix, before, after: before, changed: false };
|
|
184
|
+
}
|
|
185
|
+
let stripped = before;
|
|
186
|
+
const leadingAnnotations = /^【[^】]*】\s*|\s*\([^)]*\)\s*|\s*\[[^\]]*\]\s*/;
|
|
187
|
+
stripped = stripped.replace(leadingAnnotations, "");
|
|
188
|
+
const trailingAnnotations = /\s*【[^】]*】\s*|\s*\([^)]*\)\s*|\s*\[[^\]]*\]\s*$/;
|
|
189
|
+
while (trailingAnnotations.test(stripped)) {
|
|
190
|
+
stripped = stripped.replace(trailingAnnotations, "");
|
|
191
|
+
}
|
|
192
|
+
const originalPrefix = sourcePrefixOf(id);
|
|
193
|
+
if (originalPrefix !== "") {
|
|
194
|
+
const lead = `${originalPrefix}/`;
|
|
195
|
+
if (stripped.startsWith(lead)) {
|
|
196
|
+
stripped = stripped.slice(lead.length);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const base = stripped.trimEnd() !== "" ? stripped.trimEnd() : bareIdOf(id);
|
|
200
|
+
const after = `${prefix_space}${base}`;
|
|
201
|
+
return { prefix, before, after, changed: after !== before };
|
|
202
|
+
}
|
|
203
|
+
function renameModels(models, selected) {
|
|
204
|
+
let written = 0;
|
|
205
|
+
const next = models.map((model) => {
|
|
206
|
+
const id = textOf(model, "id");
|
|
207
|
+
if (!selected.has(id)) return model;
|
|
208
|
+
const { after, changed } = redirectName(id, textOf(model, "name"));
|
|
209
|
+
if (!changed) return model;
|
|
210
|
+
written += 1;
|
|
211
|
+
return { ...model, name: after };
|
|
212
|
+
});
|
|
213
|
+
return { next, written };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// src/client/SyncSection.tsx
|
|
217
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
218
|
+
function tokens(value) {
|
|
219
|
+
if (typeof value !== "number") return "\u2014";
|
|
220
|
+
if (value >= 1e6) return `${String(Number((value / 1e6).toFixed(1)))}M`;
|
|
221
|
+
if (value >= 1e3) return `${String(Number((value / 1e3).toFixed(0)))}K`;
|
|
222
|
+
return String(value);
|
|
223
|
+
}
|
|
224
|
+
function viaLabel(row, t) {
|
|
225
|
+
switch (row.match?.via) {
|
|
226
|
+
case "alias":
|
|
227
|
+
return t("viaAlias");
|
|
228
|
+
case "exact":
|
|
229
|
+
return t("viaExact");
|
|
230
|
+
case "folded":
|
|
231
|
+
return t("viaFolded");
|
|
232
|
+
case "basename":
|
|
233
|
+
return t("viaBasename");
|
|
234
|
+
case "suffix":
|
|
235
|
+
return t("viaSuffix");
|
|
236
|
+
case "prefix":
|
|
237
|
+
return t("viaPrefix");
|
|
238
|
+
case "vendor":
|
|
239
|
+
return t("viaVendor");
|
|
240
|
+
case "spelling":
|
|
241
|
+
return t("viaSpelling");
|
|
242
|
+
case "name":
|
|
243
|
+
return t("viaName");
|
|
244
|
+
case "nameSuffix":
|
|
245
|
+
return t("viaNameSuffix");
|
|
246
|
+
default:
|
|
247
|
+
return "";
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function mergeModel(model, fields, overwrite, manual) {
|
|
251
|
+
const next = { ...model };
|
|
252
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
253
|
+
if (key === "name" || value === void 0) continue;
|
|
254
|
+
const typed = manual !== void 0 && key in manual;
|
|
255
|
+
if (!typed && !overwrite && !isBlank(next[key])) continue;
|
|
256
|
+
next[key] = value;
|
|
257
|
+
}
|
|
258
|
+
return next;
|
|
259
|
+
}
|
|
260
|
+
function changesBetween(model, fields, overwrite, manual) {
|
|
261
|
+
const next = mergeModel(model, fields, overwrite, manual);
|
|
262
|
+
const changes = [];
|
|
263
|
+
for (const key of Object.keys(fields)) {
|
|
264
|
+
const before = model[key];
|
|
265
|
+
const after = next[key];
|
|
266
|
+
if (JSON.stringify(before) === JSON.stringify(after)) continue;
|
|
267
|
+
changes.push({ key, before, after });
|
|
268
|
+
}
|
|
269
|
+
return changes;
|
|
270
|
+
}
|
|
271
|
+
function imageText(value, t) {
|
|
272
|
+
if (Array.isArray(value) && value.includes("image")) return t("imageYes");
|
|
273
|
+
if (isBlank(value)) return t("fieldEmpty");
|
|
274
|
+
return t("imageNo");
|
|
275
|
+
}
|
|
276
|
+
function reasoningText(value) {
|
|
277
|
+
if (value === false) return "off";
|
|
278
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
279
|
+
const keys = Object.keys(value);
|
|
280
|
+
return keys.length === 0 ? "\u2014" : keys.join(" / ");
|
|
281
|
+
}
|
|
282
|
+
return "\u2014";
|
|
283
|
+
}
|
|
284
|
+
function imageChoice(value) {
|
|
285
|
+
if (Array.isArray(value) && value.includes("image")) return "yes";
|
|
286
|
+
if (isBlank(value)) return "default";
|
|
287
|
+
return "no";
|
|
288
|
+
}
|
|
289
|
+
function liveLabel(row, t) {
|
|
290
|
+
if (row === void 0) return "\u2014";
|
|
291
|
+
if (row.error !== void 0) return t("liveError");
|
|
292
|
+
if (row.input === void 0) return "\u2014";
|
|
293
|
+
return row.input.includes("image") ? t("imageYes") : t("imageNo");
|
|
294
|
+
}
|
|
295
|
+
function valueCell(change, current, format) {
|
|
296
|
+
if (change === void 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-dim", children: format(current) });
|
|
297
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "cs-change", children: [
|
|
298
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-from", children: format(change.before) }),
|
|
299
|
+
" \u2192 ",
|
|
300
|
+
format(change.after)
|
|
301
|
+
] });
|
|
302
|
+
}
|
|
303
|
+
function EditableNumber(props) {
|
|
304
|
+
const { field, model, manual, change, label, onType } = props;
|
|
305
|
+
const typed = manual?.[field];
|
|
306
|
+
const shown = typed !== void 0 ? String(typed) : change === void 0 ? "" : String(model[field] ?? "");
|
|
307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "cs-cell", children: [
|
|
308
|
+
change === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "cs-change", children: [
|
|
309
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-from", children: tokens(change.before) }),
|
|
310
|
+
" \u2192 ",
|
|
311
|
+
tokens(change.after)
|
|
312
|
+
] }),
|
|
313
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
314
|
+
"input",
|
|
315
|
+
{
|
|
316
|
+
className: typed !== void 0 ? "cs-input cs-input--cell cs-input--typed" : "cs-input cs-input--cell",
|
|
317
|
+
"aria-label": label,
|
|
318
|
+
inputMode: "numeric",
|
|
319
|
+
value: typed !== void 0 ? String(typed) : change === void 0 ? isBlank(model[field]) ? "" : tokens(model[field]) : "",
|
|
320
|
+
placeholder: change === void 0 ? tokens(model[field]) : tokens(change.after),
|
|
321
|
+
onChange: (event) => {
|
|
322
|
+
onType(parseTokenCount(event.target.value));
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
)
|
|
326
|
+
] });
|
|
327
|
+
}
|
|
328
|
+
function SyncSection(props) {
|
|
329
|
+
const { t, preview, live, describeSettings, mutateSettings } = props;
|
|
330
|
+
const [status, setStatus] = (0, import_react.useState)("loading");
|
|
331
|
+
const [errorText, setErrorText] = (0, import_react.useState)(void 0);
|
|
332
|
+
const [descriptors, setDescriptors] = (0, import_react.useState)([]);
|
|
333
|
+
const [targetNs, setTargetNs] = (0, import_react.useState)(TARGET_DEFAULT);
|
|
334
|
+
const [providerKey, setProviderKey] = (0, import_react.useState)("");
|
|
335
|
+
const [models, setModels] = (0, import_react.useState)([]);
|
|
336
|
+
const modelsRef = (0, import_react.useRef)([]);
|
|
337
|
+
const [rows, setRows] = (0, import_react.useState)(void 0);
|
|
338
|
+
const [typed, setTyped] = (0, import_react.useState)(/* @__PURE__ */ new Map());
|
|
339
|
+
const [liveRows, setLiveRows] = (0, import_react.useState)(/* @__PURE__ */ new Map());
|
|
340
|
+
const [selected, setSelected] = (0, import_react.useState)(/* @__PURE__ */ new Set());
|
|
341
|
+
const [overwrite, setOverwrite] = (0, import_react.useState)(false);
|
|
342
|
+
const [query, setQuery] = (0, import_react.useState)("");
|
|
343
|
+
const [onlyChanged, setOnlyChanged] = (0, import_react.useState)(false);
|
|
344
|
+
const [sortMode, setSortMode] = (0, import_react.useState)("prefix");
|
|
345
|
+
const [renaming, setRenaming] = (0, import_react.useState)(false);
|
|
346
|
+
const [reordering, setReordering] = (0, import_react.useState)(false);
|
|
347
|
+
const [busy, setBusy] = (0, import_react.useState)("idle");
|
|
348
|
+
const [notice, setNotice] = (0, import_react.useState)(void 0);
|
|
349
|
+
const [catalogInfo, setCatalogInfo] = (0, import_react.useState)(void 0);
|
|
350
|
+
const [staleInfo, setStaleInfo] = (0, import_react.useState)(void 0);
|
|
351
|
+
const plan = (() => {
|
|
352
|
+
if (rows === void 0) return [];
|
|
353
|
+
const stored = new Map(models.map((model) => [textOf(model, "id"), model]));
|
|
354
|
+
return rows.map((row) => {
|
|
355
|
+
const model = stored.get(row.id) ?? {};
|
|
356
|
+
const manual = typed.get(row.id);
|
|
357
|
+
const fields = mergeFields(row.fields, manual);
|
|
358
|
+
return {
|
|
359
|
+
row,
|
|
360
|
+
model,
|
|
361
|
+
...fields === void 0 ? {} : { fields },
|
|
362
|
+
...manual === void 0 ? {} : { manual },
|
|
363
|
+
changes: fields === void 0 ? [] : changesBetween(model, fields, overwrite, manual)
|
|
364
|
+
};
|
|
365
|
+
});
|
|
366
|
+
})();
|
|
367
|
+
const matched = plan.filter((entry) => entry.fields !== void 0);
|
|
368
|
+
const unmatched = plan.filter((entry) => entry.fields === void 0);
|
|
369
|
+
const changing = matched.filter((entry) => entry.changes.length > 0);
|
|
370
|
+
const changeFields = changing.reduce((total, entry) => total + entry.changes.length, 0);
|
|
371
|
+
const liveImage = matched.filter((entry) => liveRows.get(entry.row.id)?.input?.includes("image") === true).length;
|
|
372
|
+
const liveText = matched.filter((entry) => {
|
|
373
|
+
const answer = liveRows.get(entry.row.id);
|
|
374
|
+
return answer?.input !== void 0 && !answer.input.includes("image");
|
|
375
|
+
}).length;
|
|
376
|
+
const load = async (mode = sortMode) => {
|
|
377
|
+
setStatus("loading");
|
|
378
|
+
setErrorText(void 0);
|
|
379
|
+
try {
|
|
380
|
+
const list = await describeSettings();
|
|
381
|
+
setDescriptors(list);
|
|
382
|
+
const candidates2 = list.filter((entry) => Object.keys(providersOf(entry)).length > 0);
|
|
383
|
+
const target = candidates2.find((entry) => entry.ns === TARGET_DEFAULT) ?? candidates2[0];
|
|
384
|
+
if (target === void 0) {
|
|
385
|
+
setStatus("error");
|
|
386
|
+
setErrorText(t("noTarget"));
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const providers = providersOf(target);
|
|
390
|
+
const firstKey = Object.keys(providers)[0] ?? "";
|
|
391
|
+
setTargetNs(target.ns);
|
|
392
|
+
setProviderKey(firstKey);
|
|
393
|
+
putModels(sortedModelsOf(providers[firstKey], mode));
|
|
394
|
+
setRows(void 0);
|
|
395
|
+
setLiveRows(/* @__PURE__ */ new Map());
|
|
396
|
+
setSelected(/* @__PURE__ */ new Set());
|
|
397
|
+
setQuery("");
|
|
398
|
+
setStatus("ready");
|
|
399
|
+
} catch (error) {
|
|
400
|
+
setStatus("error");
|
|
401
|
+
setErrorText(error instanceof Error ? error.message : String(error));
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
(0, import_react.useEffect)(() => {
|
|
405
|
+
void load();
|
|
406
|
+
}, []);
|
|
407
|
+
const showProvider = (ns, key, mode = sortMode) => {
|
|
408
|
+
const providers = providersOf(descriptors.find((entry) => entry.ns === ns));
|
|
409
|
+
const resolved = key !== "" && providers[key] !== void 0 ? key : Object.keys(providers)[0] ?? "";
|
|
410
|
+
setTargetNs(ns);
|
|
411
|
+
setProviderKey(resolved);
|
|
412
|
+
putModels(sortedModelsOf(providers[resolved], mode));
|
|
413
|
+
setRows(void 0);
|
|
414
|
+
setLiveRows(/* @__PURE__ */ new Map());
|
|
415
|
+
setSelected(/* @__PURE__ */ new Set());
|
|
416
|
+
setNotice(void 0);
|
|
417
|
+
setQuery("");
|
|
418
|
+
};
|
|
419
|
+
const refreshLive = async (provider, ids) => {
|
|
420
|
+
try {
|
|
421
|
+
const answer = await live({ provider, ids });
|
|
422
|
+
setLiveRows(answer.ok ? new Map(answer.value.rows.map((row) => [row.id, row])) : /* @__PURE__ */ new Map());
|
|
423
|
+
} catch {
|
|
424
|
+
setLiveRows(/* @__PURE__ */ new Map());
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
const reloadConfig = async () => {
|
|
428
|
+
const list = await describeSettings();
|
|
429
|
+
setDescriptors(list);
|
|
430
|
+
const descriptor2 = list.find((entry) => entry.ns === targetNs);
|
|
431
|
+
if (descriptor2 !== void 0) putModels(sortedModelsOf(providersOf(descriptor2)[providerKey], sortMode));
|
|
432
|
+
};
|
|
433
|
+
const selectChanging = (source, stored, mode) => {
|
|
434
|
+
const byId = new Map(stored.map((model) => [textOf(model, "id"), model]));
|
|
435
|
+
setSelected(new Set(source.filter((row) => row.fields !== void 0 && changesBetween(byId.get(row.id) ?? {}, row.fields, mode).length > 0).map((row) => row.id)));
|
|
436
|
+
};
|
|
437
|
+
const analyze = async (refresh) => {
|
|
438
|
+
setBusy("analyzing");
|
|
439
|
+
setErrorText(void 0);
|
|
440
|
+
setNotice(void 0);
|
|
441
|
+
setStaleInfo(void 0);
|
|
442
|
+
try {
|
|
443
|
+
const ids = models.map((model) => textOf(model, "id")).filter((id) => id.length > 0);
|
|
444
|
+
const names = {};
|
|
445
|
+
for (const model of models) {
|
|
446
|
+
const id = textOf(model, "id");
|
|
447
|
+
const name = textOf(model, "name");
|
|
448
|
+
if (id !== "" && name !== "" && name !== id) names[id] = name;
|
|
449
|
+
}
|
|
450
|
+
const result = await preview({
|
|
451
|
+
ids,
|
|
452
|
+
...Object.keys(names).length > 0 ? { names } : {},
|
|
453
|
+
...refresh ? { refresh: true } : {}
|
|
454
|
+
});
|
|
455
|
+
if (!result.ok) throw new Error(result.error.message);
|
|
456
|
+
setRows(result.value.rows);
|
|
457
|
+
selectChanging(result.value.rows, models, overwrite);
|
|
458
|
+
setCatalogInfo(t("catalogInfo", {
|
|
459
|
+
models: result.value.catalogModels,
|
|
460
|
+
time: new Date(result.value.fetchedAt).toLocaleString()
|
|
461
|
+
}));
|
|
462
|
+
setStaleInfo(result.value.stale === true ? t("catalogStale", { time: new Date(result.value.fetchedAt).toLocaleString() }) : void 0);
|
|
463
|
+
await refreshLive(providerKey, ids);
|
|
464
|
+
} catch (error) {
|
|
465
|
+
setErrorText(error instanceof Error ? error.message : String(error));
|
|
466
|
+
} finally {
|
|
467
|
+
setBusy("idle");
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
const setSortModeAndApply = (mode) => {
|
|
471
|
+
setSortMode(mode);
|
|
472
|
+
const descriptor2 = descriptors.find((entry) => entry.ns === targetNs);
|
|
473
|
+
if (descriptor2 !== void 0) putModels(sortedModelsOf(providersOf(descriptor2)[providerKey], mode));
|
|
474
|
+
};
|
|
475
|
+
const setOverwriteMode = (mode) => {
|
|
476
|
+
setOverwrite(mode);
|
|
477
|
+
if (rows === void 0) return;
|
|
478
|
+
selectChanging(rows, models, mode);
|
|
479
|
+
};
|
|
480
|
+
const putModels = (next) => {
|
|
481
|
+
modelsRef.current = next;
|
|
482
|
+
setModels(next);
|
|
483
|
+
};
|
|
484
|
+
const commitWrite = (ordered, view) => {
|
|
485
|
+
putModels(ordered);
|
|
486
|
+
setDescriptors((previous) => previous.map((entry) => entry.ns === targetNs ? withWrittenModels(entry, providerKey, ordered, view.revision) : entry));
|
|
487
|
+
};
|
|
488
|
+
const doRename = async () => {
|
|
489
|
+
const descriptor2 = descriptors.find((entry) => entry.ns === targetNs);
|
|
490
|
+
if (descriptor2 === void 0) return;
|
|
491
|
+
const live2 = modelsRef.current;
|
|
492
|
+
const targets = new Set(live2.map((model) => textOf(model, "id")));
|
|
493
|
+
if (targets.size === 0) {
|
|
494
|
+
setNotice(t("redirectNoChanges"));
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const renamed = renameModels(live2, targets);
|
|
498
|
+
setRenaming(true);
|
|
499
|
+
setErrorText(void 0);
|
|
500
|
+
setNotice(void 0);
|
|
501
|
+
try {
|
|
502
|
+
const ordered = sortByModelId(renamed.next, (model) => textOf(model, "id"), (model) => textOf(model, "name"), sortMode);
|
|
503
|
+
const view = await mutateSettings(targetNs, [{
|
|
504
|
+
op: "set",
|
|
505
|
+
path: ["providers", providerKey, "models"],
|
|
506
|
+
value: ordered
|
|
507
|
+
}], descriptor2.revision);
|
|
508
|
+
commitWrite(ordered, view);
|
|
509
|
+
setNotice(`${t("redirectApplied", { count: renamed.written })}`);
|
|
510
|
+
} catch (error) {
|
|
511
|
+
setErrorText(error instanceof Error ? error.message : String(error));
|
|
512
|
+
} finally {
|
|
513
|
+
setRenaming(false);
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
const doReorder = async () => {
|
|
517
|
+
const descriptor2 = descriptors.find((entry) => entry.ns === targetNs);
|
|
518
|
+
if (descriptor2 === void 0) return;
|
|
519
|
+
setReordering(true);
|
|
520
|
+
setErrorText(void 0);
|
|
521
|
+
setNotice(void 0);
|
|
522
|
+
try {
|
|
523
|
+
const ordered = sortByModelId(modelsRef.current, (model) => textOf(model, "id"), (model) => textOf(model, "name"), sortMode);
|
|
524
|
+
const view = await mutateSettings(targetNs, [{
|
|
525
|
+
op: "set",
|
|
526
|
+
path: ["providers", providerKey, "models"],
|
|
527
|
+
value: ordered
|
|
528
|
+
}], descriptor2.revision);
|
|
529
|
+
commitWrite(ordered, view);
|
|
530
|
+
setNotice(t("reordered"));
|
|
531
|
+
} catch (error) {
|
|
532
|
+
setErrorText(error instanceof Error ? error.message : String(error));
|
|
533
|
+
} finally {
|
|
534
|
+
setReordering(false);
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
const typeField = (id, key, value) => {
|
|
538
|
+
setTyped((previous) => {
|
|
539
|
+
const next = new Map(previous);
|
|
540
|
+
const current = next.get(id) ?? {};
|
|
541
|
+
const updated = { ...current };
|
|
542
|
+
if (value === void 0) delete updated[key];
|
|
543
|
+
else updated[key] = value;
|
|
544
|
+
if (Object.keys(updated).length === 0) next.delete(id);
|
|
545
|
+
else next.set(id, updated);
|
|
546
|
+
return next;
|
|
547
|
+
});
|
|
548
|
+
};
|
|
549
|
+
const applyRows = async () => {
|
|
550
|
+
const descriptor2 = descriptors.find((entry) => entry.ns === targetNs);
|
|
551
|
+
if (descriptor2 === void 0) return;
|
|
552
|
+
const targets = new Map(changing.filter((entry) => selected.has(entry.row.id) && entry.fields !== void 0).map((entry) => [entry.row.id, entry]));
|
|
553
|
+
if (targets.size === 0) {
|
|
554
|
+
setNotice(t("nothingSelected"));
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
let written = 0;
|
|
558
|
+
const next = modelsRef.current.map((model) => {
|
|
559
|
+
const entry = targets.get(textOf(model, "id"));
|
|
560
|
+
if (entry?.fields === void 0) return model;
|
|
561
|
+
written += 1;
|
|
562
|
+
return mergeModel(model, entry.fields, overwrite, entry.manual);
|
|
563
|
+
});
|
|
564
|
+
setBusy("applying");
|
|
565
|
+
setErrorText(void 0);
|
|
566
|
+
setNotice(void 0);
|
|
567
|
+
try {
|
|
568
|
+
const ordered = sortByModelId(next, (model) => textOf(model, "id"), (model) => textOf(model, "name"), sortMode);
|
|
569
|
+
const view = await mutateSettings(targetNs, [{
|
|
570
|
+
op: "set",
|
|
571
|
+
path: ["providers", providerKey, "models"],
|
|
572
|
+
value: ordered
|
|
573
|
+
}], descriptor2.revision);
|
|
574
|
+
commitWrite(ordered, view);
|
|
575
|
+
setNotice(t("applied", { count: written }));
|
|
576
|
+
await refreshLive(providerKey, next.map((model) => textOf(model, "id")).filter((id) => id.length > 0));
|
|
577
|
+
} catch (error) {
|
|
578
|
+
const code = error?.code;
|
|
579
|
+
if (code === "settings/conflict") {
|
|
580
|
+
try {
|
|
581
|
+
await reloadConfig();
|
|
582
|
+
} catch {
|
|
583
|
+
}
|
|
584
|
+
setNotice(t("conflictReload"));
|
|
585
|
+
} else {
|
|
586
|
+
setErrorText(error instanceof Error ? error.message : String(error));
|
|
587
|
+
}
|
|
588
|
+
} finally {
|
|
589
|
+
setBusy("idle");
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
if (status === "loading") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "cs-hint", children: t("loading") });
|
|
593
|
+
if (status === "error") {
|
|
594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "cs-field", children: [
|
|
595
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "cs-error", children: [
|
|
596
|
+
t("loadFailed"),
|
|
597
|
+
": ",
|
|
598
|
+
errorText
|
|
599
|
+
] }),
|
|
600
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "cs-button", onClick: () => {
|
|
601
|
+
void load();
|
|
602
|
+
}, children: t("retry") })
|
|
603
|
+
] });
|
|
604
|
+
}
|
|
605
|
+
const descriptor = descriptors.find((entry) => entry.ns === targetNs);
|
|
606
|
+
const candidates = descriptors.filter((entry) => Object.keys(providersOf(entry)).length > 0);
|
|
607
|
+
const providerKeys = Object.keys(providersOf(descriptor));
|
|
608
|
+
const needle = query.trim().toLowerCase();
|
|
609
|
+
const visible = plan.filter((entry) => {
|
|
610
|
+
if (onlyChanged && entry.changes.length === 0) return false;
|
|
611
|
+
if (needle === "") return true;
|
|
612
|
+
return entry.row.id.toLowerCase().includes(needle) || entry.row.match?.modelId.toLowerCase().includes(needle) === true;
|
|
613
|
+
});
|
|
614
|
+
const selectable = visible.filter((entry) => entry.changes.length > 0);
|
|
615
|
+
const toggle = (id) => {
|
|
616
|
+
const next = new Set(selected);
|
|
617
|
+
if (next.has(id)) next.delete(id);
|
|
618
|
+
else next.add(id);
|
|
619
|
+
setSelected(next);
|
|
620
|
+
};
|
|
621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
622
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-hint", children: t("intro") }),
|
|
623
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "cs-row", children: [
|
|
624
|
+
candidates.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "cs-field", children: [
|
|
625
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-hint", children: t("writeTarget") }),
|
|
626
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { className: "cs-select", value: targetNs, onChange: (event) => {
|
|
627
|
+
showProvider(event.target.value, "");
|
|
628
|
+
}, children: candidates.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: entry.ns, children: targetLabelOf(entry.ns, t) }, entry.ns)) })
|
|
629
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "cs-field", title: targetNs, children: [
|
|
630
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-hint", children: t("writeTarget") }),
|
|
631
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-target", children: targetLabelOf(targetNs, t) })
|
|
632
|
+
] }),
|
|
633
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "cs-field", children: [
|
|
634
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-hint", children: t("provider") }),
|
|
635
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { className: "cs-select", value: providerKey, onChange: (event) => {
|
|
636
|
+
showProvider(targetNs, event.target.value);
|
|
637
|
+
}, children: providerKeys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: key, children: key }, key)) })
|
|
638
|
+
] }),
|
|
639
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-hint", children: t("modelCount", { count: models.length }) }),
|
|
640
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "cs-field", children: [
|
|
641
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-hint", children: t("sortMode") }),
|
|
642
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
643
|
+
"select",
|
|
644
|
+
{
|
|
645
|
+
className: "cs-select",
|
|
646
|
+
value: sortMode,
|
|
647
|
+
onChange: (event) => {
|
|
648
|
+
setSortModeAndApply(event.target.value);
|
|
649
|
+
},
|
|
650
|
+
children: [
|
|
651
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "prefix", children: t("sortByPrefix") }),
|
|
652
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "redirected", children: t("sortByRedirected") })
|
|
653
|
+
]
|
|
654
|
+
}
|
|
655
|
+
)
|
|
656
|
+
] }),
|
|
657
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-hint", children: t("willSort") })
|
|
658
|
+
] }),
|
|
659
|
+
models.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-hint", children: t("noModels") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "cs-row", children: [
|
|
660
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "cs-button cs-button--primary", disabled: busy !== "idle", onClick: () => {
|
|
661
|
+
void analyze(false);
|
|
662
|
+
}, children: busy === "analyzing" ? t("analyzing") : t("analyze") }),
|
|
663
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "cs-button", disabled: busy !== "idle", onClick: () => {
|
|
664
|
+
void analyze(true);
|
|
665
|
+
}, children: t("refreshCatalog") }),
|
|
666
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "cs-hint", title: t("overwriteHint"), children: [
|
|
667
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: overwrite, onChange: (event) => {
|
|
668
|
+
setOverwriteMode(event.target.checked);
|
|
669
|
+
} }),
|
|
670
|
+
" ",
|
|
671
|
+
t("overwrite")
|
|
672
|
+
] }),
|
|
673
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
674
|
+
"button",
|
|
675
|
+
{
|
|
676
|
+
type: "button",
|
|
677
|
+
className: "cs-button",
|
|
678
|
+
disabled: renaming,
|
|
679
|
+
onClick: () => {
|
|
680
|
+
void doRename();
|
|
681
|
+
},
|
|
682
|
+
children: renaming ? t("redirectApplying") : t("redirectApply")
|
|
683
|
+
}
|
|
684
|
+
),
|
|
685
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
686
|
+
"button",
|
|
687
|
+
{
|
|
688
|
+
type: "button",
|
|
689
|
+
className: "cs-button",
|
|
690
|
+
disabled: reordering,
|
|
691
|
+
onClick: () => {
|
|
692
|
+
void doReorder();
|
|
693
|
+
},
|
|
694
|
+
children: reordering ? t("reordering") : t("reorder")
|
|
695
|
+
}
|
|
696
|
+
)
|
|
697
|
+
] }),
|
|
698
|
+
errorText !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-error", children: errorText }) : null,
|
|
699
|
+
notice !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-hint", children: notice }) : null,
|
|
700
|
+
catalogInfo !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-hint", children: catalogInfo }) : null,
|
|
701
|
+
staleInfo !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-warn", children: staleInfo }) : null,
|
|
702
|
+
rows !== void 0 && plan.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
703
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-hint", children: t("editHint") }),
|
|
704
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "cs-row", children: [
|
|
705
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
706
|
+
"input",
|
|
707
|
+
{
|
|
708
|
+
className: "cs-input",
|
|
709
|
+
type: "search",
|
|
710
|
+
value: query,
|
|
711
|
+
placeholder: t("search"),
|
|
712
|
+
onChange: (event) => {
|
|
713
|
+
setQuery(event.target.value);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
),
|
|
717
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "cs-hint", children: [
|
|
718
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: onlyChanged, onChange: (event) => {
|
|
719
|
+
setOnlyChanged(event.target.checked);
|
|
720
|
+
} }),
|
|
721
|
+
" ",
|
|
722
|
+
t("onlyChanged")
|
|
723
|
+
] }),
|
|
724
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-hint", children: changing.length === 0 ? t("noChanges") : t("changeSummary", { rows: changing.length, fields: changeFields }) })
|
|
725
|
+
] }),
|
|
726
|
+
visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-hint", children: t("filteredEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "cs-table-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { className: "cs-table", children: [
|
|
727
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("colgroup", { children: [
|
|
728
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("col", { className: "cs-col-check" }),
|
|
729
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("col", { className: "cs-col-id" }),
|
|
730
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("col", { className: "cs-col-name" }),
|
|
731
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("col", { className: "cs-col-match" }),
|
|
732
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("col", { className: "cs-col-context" }),
|
|
733
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("col", { className: "cs-col-output" }),
|
|
734
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("col", { className: "cs-col-image" }),
|
|
735
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("col", { className: "cs-col-live" }),
|
|
736
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("col", { className: "cs-col-reasoning" })
|
|
737
|
+
] }),
|
|
738
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
739
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
740
|
+
"input",
|
|
741
|
+
{
|
|
742
|
+
type: "checkbox",
|
|
743
|
+
"aria-label": t("selectAll"),
|
|
744
|
+
checked: selectable.length > 0 && selectable.every((entry) => selected.has(entry.row.id)),
|
|
745
|
+
onChange: (event) => {
|
|
746
|
+
const keep = event.target.checked ? new Set(selectable.map((entry) => entry.row.id)) : /* @__PURE__ */ new Set();
|
|
747
|
+
setSelected(keep);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
) }),
|
|
751
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colModel") }),
|
|
752
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colName") }),
|
|
753
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colMatch") }),
|
|
754
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colContext") }),
|
|
755
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colOutput") }),
|
|
756
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colImage") }),
|
|
757
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { title: t("colLiveHint"), children: t("colLive") }),
|
|
758
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colReasoning") })
|
|
759
|
+
] }) }),
|
|
760
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: visible.map((entry) => {
|
|
761
|
+
const { row, model, changes } = entry;
|
|
762
|
+
const changeOf = (key) => changes.find((change) => change.key === key);
|
|
763
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { className: changes.length > 0 ? "cs-row--changed" : void 0, children: [
|
|
764
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
765
|
+
"input",
|
|
766
|
+
{
|
|
767
|
+
type: "checkbox",
|
|
768
|
+
"aria-label": row.id,
|
|
769
|
+
checked: selected.has(row.id),
|
|
770
|
+
disabled: changes.length === 0,
|
|
771
|
+
onChange: () => {
|
|
772
|
+
toggle(row.id);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
) }),
|
|
776
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "cs-id", children: row.id }),
|
|
777
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: redirectName(row.id, textOf(model, "name")).after }),
|
|
778
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "cs-dim", children: row.match === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-badge", children: t("notListed") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
779
|
+
`${row.match.provider}/${row.match.modelId}`,
|
|
780
|
+
" ",
|
|
781
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-badge", children: viaLabel(row, t) })
|
|
782
|
+
] }) }),
|
|
783
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
784
|
+
EditableNumber,
|
|
785
|
+
{
|
|
786
|
+
field: "contextWindow",
|
|
787
|
+
label: `${row.id} ${t("colContext")}`,
|
|
788
|
+
model,
|
|
789
|
+
manual: entry.manual,
|
|
790
|
+
change: changeOf("contextWindow"),
|
|
791
|
+
onType: (value) => {
|
|
792
|
+
typeField(row.id, "contextWindow", value);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
) }),
|
|
796
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
797
|
+
EditableNumber,
|
|
798
|
+
{
|
|
799
|
+
field: "maxTokens",
|
|
800
|
+
label: `${row.id} ${t("colOutput")}`,
|
|
801
|
+
model,
|
|
802
|
+
manual: entry.manual,
|
|
803
|
+
change: changeOf("maxTokens"),
|
|
804
|
+
onType: (value) => {
|
|
805
|
+
typeField(row.id, "maxTokens", value);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
) }),
|
|
809
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [
|
|
810
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
811
|
+
"select",
|
|
812
|
+
{
|
|
813
|
+
className: entry.manual?.input === void 0 ? "cs-select cs-select--cell" : "cs-select cs-select--cell cs-select--typed",
|
|
814
|
+
"aria-label": `${row.id} ${t("colImage")}`,
|
|
815
|
+
value: imageChoice(entry.manual?.input ?? model.input),
|
|
816
|
+
onChange: (event) => {
|
|
817
|
+
const choice = event.target.value;
|
|
818
|
+
typeField(row.id, "input", choice === "default" ? void 0 : choice === "yes" ? ["text", "image"] : ["text"]);
|
|
819
|
+
},
|
|
820
|
+
children: [
|
|
821
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "default", children: imageText(model.input, t) }),
|
|
822
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "yes", children: t("imageYes") }),
|
|
823
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "no", children: t("imageNo") })
|
|
824
|
+
]
|
|
825
|
+
}
|
|
826
|
+
),
|
|
827
|
+
changeOf("input") === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "cs-change cs-change--block", children: [
|
|
828
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-from", children: imageText(changeOf("input")?.before, t) }),
|
|
829
|
+
" \u2192 ",
|
|
830
|
+
imageText(changeOf("input")?.after, t)
|
|
831
|
+
] })
|
|
832
|
+
] }),
|
|
833
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: liveRows.get(row.id)?.input?.includes("image") === true ? "cs-badge cs-badge--image" : "cs-dim", children: liveLabel(liveRows.get(row.id), t) }) }),
|
|
834
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "cs-dim", children: valueCell(changeOf("reasoningEfforts"), model.reasoningEfforts, reasoningText) })
|
|
835
|
+
] }, row.id);
|
|
836
|
+
}) })
|
|
837
|
+
] }) }),
|
|
838
|
+
liveRows.size > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-hint", children: t("liveSummary", { image: liveImage, text: liveText }) }) : null,
|
|
839
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "cs-row", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
840
|
+
"button",
|
|
841
|
+
{
|
|
842
|
+
type: "button",
|
|
843
|
+
className: "cs-button cs-button--primary",
|
|
844
|
+
disabled: busy !== "idle" || !changing.some((entry) => selected.has(entry.row.id)),
|
|
845
|
+
onClick: () => {
|
|
846
|
+
void applyRows();
|
|
847
|
+
},
|
|
848
|
+
children: busy === "applying" ? t("applying") : t("apply")
|
|
849
|
+
}
|
|
850
|
+
) })
|
|
851
|
+
] }) : null,
|
|
852
|
+
unmatched.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-hint", children: t("unmatchedHint", { count: unmatched.length }) }) : null
|
|
853
|
+
] });
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
// src/client/locale.ts
|
|
857
|
+
var zh = {
|
|
858
|
+
nav: "\u6A21\u578B\u80FD\u529B\u540C\u6B65",
|
|
859
|
+
loading: "\u6B63\u5728\u8BFB\u53D6\u914D\u7F6E\u2026",
|
|
860
|
+
intro: "\u4ECE models.dev \u67E5\u8BE2\u5DF2\u914D\u7F6E\u6A21\u578B\u7684\u80FD\u529B\uFF08\u4E0A\u4E0B\u6587\u7A97\u53E3\u3001\u8F93\u51FA\u4E0A\u9650\u3001\u662F\u5426\u652F\u6301\u56FE\u7247\u3001\u63A8\u7406\u6863\u4F4D\uFF09\uFF0C\u5E76\u5199\u5165\u6240\u9009\u4F9B\u5E94\u5546\u7684\u914D\u7F6E\u3002\u672C\u9875\u53EA\u5199\u914D\u7F6E\uFF0C\u4E0D\u53D1\u9001\u4EFB\u4F55\u63A8\u7406\u8BF7\u6C42\u3002",
|
|
861
|
+
writeTarget: "\u5199\u5165\u4F4D\u7F6E",
|
|
862
|
+
sourceNative: "\u539F\u751F\u914D\u7F6E",
|
|
863
|
+
sourcePlugin: "\u63D2\u4EF6\u914D\u7F6E",
|
|
864
|
+
nameLlmPiAi: "pi-ai \u9002\u914D\u5668",
|
|
865
|
+
nameLlmDeepseek: "DeepSeek \u5B98\u65B9",
|
|
866
|
+
nameLlmDeepseekAccount: "DeepSeek \u8D26\u53F7",
|
|
867
|
+
nameLlmNewapi: "NewAPI",
|
|
868
|
+
provider: "\u4F9B\u5E94\u5546",
|
|
869
|
+
modelCount: "\u5171 {count} \u4E2A\u6A21\u578B",
|
|
870
|
+
willSort: "\u5199\u5165\u65F6\u6309\u300C\u524D\u7F00\u5206\u7EC4 + \u540D\u79F0\u300D\u6392\u5E8F",
|
|
871
|
+
sortMode: "\u6392\u5E8F",
|
|
872
|
+
sortByPrefix: "\u6309\u6A21\u578B\u524D\u7F00\u6392\u5E8F\uFF08\u5206\u7EC4\uFF09",
|
|
873
|
+
sortByRedirected: "\u6309\u91CD\u5B9A\u5411\u540E\u3010\u6765\u6E90\u3011\u540D\u79F0\u6392\u5E8F",
|
|
874
|
+
search: "\u641C\u7D22\u6A21\u578B ID \u6216\u76EE\u5F55 ID",
|
|
875
|
+
onlyChanged: "\u53EA\u770B\u6709\u53D8\u5316\u7684",
|
|
876
|
+
changeSummary: "\u5C06\u4FEE\u6539 {rows} \u884C \xB7 {fields} \u4E2A\u5B57\u6BB5",
|
|
877
|
+
noChanges: "\u6CA1\u6709\u9700\u8981\u5199\u5165\u7684\u53D8\u5316\uFF08\u76EE\u5F55\u503C\u4E0E\u4F60\u73B0\u6709\u914D\u7F6E\u4E00\u81F4\uFF09\u3002",
|
|
878
|
+
filteredEmpty: "\u6CA1\u6709\u7B26\u5408\u7B5B\u9009\u6761\u4EF6\u7684\u6A21\u578B\u3002",
|
|
879
|
+
fieldEmpty: "\u672A\u8BBE\u7F6E",
|
|
880
|
+
conflictReload: "\u914D\u7F6E\u5DF2\u88AB\u5176\u4ED6\u6539\u52A8\u66F4\u65B0\uFF0C\u5DF2\u91CD\u65B0\u8BFB\u53D6\u6700\u65B0\u503C\uFF1B\u8BF7\u786E\u8BA4\u540E\u518D\u70B9\u4E00\u6B21\u300C\u5E94\u7528\u300D\u3002",
|
|
881
|
+
analyze: "\u5206\u6790\u80FD\u529B",
|
|
882
|
+
analyzing: "\u6B63\u5728\u5339\u914D\u2026",
|
|
883
|
+
refreshCatalog: "\u91CD\u65B0\u4E0B\u8F7D\u76EE\u5F55",
|
|
884
|
+
apply: "\u5E94\u7528",
|
|
885
|
+
applying: "\u6B63\u5728\u5199\u5165\u2026",
|
|
886
|
+
applied: "\u5DF2\u5199\u5165 {count} \u4E2A\u6A21\u578B",
|
|
887
|
+
overwrite: "\u8986\u76D6\u5DF2\u6709\u503C",
|
|
888
|
+
overwriteHint: "\u4E0D\u52FE\u9009\u65F6\u53EA\u586B\u7A7A\u767D\u5B57\u6BB5\uFF0C\u4F60\u624B\u586B\u8FC7\u7684\u503C\u4E0D\u4F1A\u88AB\u6539\u5199\u3002",
|
|
889
|
+
selectAll: "\u5168\u9009",
|
|
890
|
+
colModel: "\u6A21\u578B ID",
|
|
891
|
+
colName: "\u540D\u79F0",
|
|
892
|
+
colMatch: "\u5339\u914D",
|
|
893
|
+
colContext: "\u4E0A\u4E0B\u6587",
|
|
894
|
+
colOutput: "\u8F93\u51FA",
|
|
895
|
+
colImage: "\u56FE\u7247",
|
|
896
|
+
colLive: "\u5F53\u524D\u751F\u6548",
|
|
897
|
+
colLiveHint: "\u7531\u771F\u6B63\u63A5\u7BA1\u8FD9\u6761\u8DEF\u7531\u7684\u9002\u914D\u5668\u4E0A\u62A5\uFF0C\u4E5F\u5C31\u662F\u804A\u5929\u8BF7\u6C42\u5B9E\u9645\u770B\u5230\u7684\u503C\u3002\u82E5\u5B83\u4E0E\u300C\u56FE\u7247\u300D\u5217\u4E0D\u4E00\u81F4\uFF0C\u8BF4\u660E\u914D\u7F6E\u88AB\u53E6\u4E00\u4E2A\u63D2\u4EF6\u62A2\u5360\u4E86\u8DEF\u7531\u3002",
|
|
898
|
+
liveError: "\u65E0\u6CD5\u8BFB\u53D6",
|
|
899
|
+
liveSummary: "\u5F53\u524D\u751F\u6548\uFF1A{image} \u4E2A\u652F\u6301\u56FE\u7247\uFF0C{text} \u4E2A\u7EAF\u6587\u672C\u3002\u82E5\u4E0E\u300C\u56FE\u7247\u300D\u5217\u4E0D\u4E00\u81F4\uFF0C\u8BF4\u660E\u8FD9\u6761\u8DEF\u7531\u7531\u522B\u7684\u63D2\u4EF6\u63A5\u7BA1\uFF0C\u5199\u5165\u672C\u914D\u7F6E\u4E0D\u4F1A\u751F\u6548\u3002",
|
|
900
|
+
colReasoning: "\u63A8\u7406\u6863\u4F4D",
|
|
901
|
+
imageYes: "\u652F\u6301",
|
|
902
|
+
imageNo: "\u7EAF\u6587\u672C",
|
|
903
|
+
unmatched: "\u672A\u5339\u914D",
|
|
904
|
+
unmatchedHint: "\u5176\u4E2D {count} \u4E2A\u6A21\u578B\u5728 models.dev \u91CC\u627E\u4E0D\u5230\uFF0C\u80FD\u529B\u53C2\u6570\u53EF\u4EE5\u5728\u4E0A\u8868\u91CC\u624B\u52A8\u586B\u3002",
|
|
905
|
+
editHint: "\u4E0A\u4E0B\u6587 / \u8F93\u51FA / \u56FE\u7247\u53EF\u4EE5\u76F4\u63A5\u5728\u8868\u683C\u91CC\u6539\uFF1A\u76EE\u5F55\u6CA1\u6536\u5F55\u7684\u6A21\u578B\u4E5F\u80FD\u624B\u52A8\u586B\uFF0C\u84DD\u8272\u8868\u793A\u662F\u4F60\u624B\u586B\u7684\u503C\u3002",
|
|
906
|
+
notListed: "\u76EE\u5F55\u672A\u6536\u5F55",
|
|
907
|
+
noModels: "\u8BE5\u4F9B\u5E94\u5546\u4E0B\u8FD8\u6CA1\u6709\u6A21\u578B\u3002",
|
|
908
|
+
noTarget: "\u6CA1\u6709\u627E\u5230\u53EF\u5199\u7684\u914D\u7F6E\u6761\u76EE\uFF08\u9700\u8981\u5DF2\u542F\u7528\u7684 llm-pi-ai \u4F9B\u5E94\u5546\u914D\u7F6E\uFF09\u3002",
|
|
909
|
+
loadFailed: "\u52A0\u8F7D\u5931\u8D25",
|
|
910
|
+
retry: "\u91CD\u8BD5",
|
|
911
|
+
viaAlias: "\u522B\u540D",
|
|
912
|
+
viaName: "\u6309\u540D\u79F0",
|
|
913
|
+
viaNameSuffix: "\u540D\u79F0\u53BB\u53D8\u4F53",
|
|
914
|
+
viaExact: "\u7CBE\u786E",
|
|
915
|
+
viaFolded: "\u5FFD\u7565\u5927\u5C0F\u5199",
|
|
916
|
+
viaBasename: "\u53BB\u524D\u7F00",
|
|
917
|
+
viaSuffix: "\u53BB\u53D8\u4F53\u540E\u7F00",
|
|
918
|
+
viaPrefix: "\u524D\u7F00\u5339\u914D",
|
|
919
|
+
viaVendor: "\u53BB\u4F9B\u5E94\u5546\u524D\u7F00",
|
|
920
|
+
viaSpelling: "\u7A7A\u683C\u8F6C\u6A2A\u7EBF",
|
|
921
|
+
catalogInfo: "\u76EE\u5F55\uFF1A{models} \u4E2A\u6A21\u578B \xB7 {time}",
|
|
922
|
+
catalogStale: "\u5728\u7EBF\u76EE\u5F55\u4E0B\u8F7D\u5931\u8D25\uFF0C\u6B63\u5728\u4F7F\u7528\u672C\u673A\u7F13\u5B58\uFF08{time}\uFF09\u3002\u6570\u636E\u53EF\u80FD\u4E0D\u662F\u6700\u65B0\uFF0C\u5B57\u6BB5\u542B\u4E49\u4E0D\u53D8\u3002",
|
|
923
|
+
nothingSelected: "\u6CA1\u6709\u9009\u4E2D\u4EFB\u4F55\u6A21\u578B\u3002",
|
|
924
|
+
redirectNoChanges: "\u8FD9\u4E9B\u540D\u79F0\u5DF2\u5E26\u6765\u6E90\u524D\u7F00\uFF0C\u65E0\u9700\u6539\u52A8\u3002",
|
|
925
|
+
reorder: "\u91CD\u6392",
|
|
926
|
+
reordering: "\u91CD\u6392\u4E2D...",
|
|
927
|
+
reordered: "\u5DF2\u6309 {mode} \u91CD\u6392\u76EE\u5F55",
|
|
928
|
+
redirectApply: "\u5199\u5165\u540D\u79F0",
|
|
929
|
+
redirectApplying: "\u6B63\u5728\u5199\u5165\u2026",
|
|
930
|
+
redirectApplied: "\u5DF2\u6539\u5199 {count} \u4E2A\u540D\u79F0"
|
|
931
|
+
};
|
|
932
|
+
var en = {
|
|
933
|
+
nav: "Model capabilities",
|
|
934
|
+
loading: "Reading configuration\u2026",
|
|
935
|
+
intro: "Look up capabilities (context window, output cap, image input, reasoning efforts) for the models already configured here, then write them into the selected provider. This page only writes configuration; it never sends a model request.",
|
|
936
|
+
writeTarget: "Write to",
|
|
937
|
+
sourceNative: "Built in",
|
|
938
|
+
sourcePlugin: "Plugin",
|
|
939
|
+
nameLlmPiAi: "pi-ai adapter",
|
|
940
|
+
nameLlmDeepseek: "DeepSeek official",
|
|
941
|
+
nameLlmDeepseekAccount: "DeepSeek account",
|
|
942
|
+
nameLlmNewapi: "NewAPI",
|
|
943
|
+
provider: "Provider",
|
|
944
|
+
modelCount: "{count} models",
|
|
945
|
+
willSort: "Written sorted by vendor prefix, then name",
|
|
946
|
+
sortMode: "Order",
|
|
947
|
+
sortByPrefix: "Sort by model prefix (grouped)",
|
|
948
|
+
sortByRedirected: "Sort by redirected name \u3010source\u3011",
|
|
949
|
+
search: "Search model id or catalog id",
|
|
950
|
+
onlyChanged: "Only rows that change",
|
|
951
|
+
changeSummary: "Will change {rows} rows \xB7 {fields} fields",
|
|
952
|
+
noChanges: "Nothing to write: the catalog agrees with your configuration.",
|
|
953
|
+
filteredEmpty: "No model matches the filter.",
|
|
954
|
+
fieldEmpty: "unset",
|
|
955
|
+
conflictReload: "The configuration changed elsewhere; the latest values were reloaded. Check them, then press Apply again.",
|
|
956
|
+
analyze: "Analyze",
|
|
957
|
+
analyzing: "Matching\u2026",
|
|
958
|
+
refreshCatalog: "Re-download catalog",
|
|
959
|
+
apply: "Apply",
|
|
960
|
+
applying: "Writing\u2026",
|
|
961
|
+
applied: "Wrote {count} models",
|
|
962
|
+
overwrite: "Overwrite existing values",
|
|
963
|
+
overwriteHint: "Unchecked: only blank fields are filled, so values you typed are preserved.",
|
|
964
|
+
selectAll: "Select all",
|
|
965
|
+
colModel: "Model id",
|
|
966
|
+
colName: "Name",
|
|
967
|
+
colMatch: "Match",
|
|
968
|
+
colContext: "Context",
|
|
969
|
+
colOutput: "Output",
|
|
970
|
+
colImage: "Image",
|
|
971
|
+
colLive: "In effect",
|
|
972
|
+
colLiveHint: "Reported by the adapter that actually serves this route \u2014 what a chat request sees. A value that disagrees with the Image column means another plugin owns the route.",
|
|
973
|
+
liveError: "unreadable",
|
|
974
|
+
liveSummary: "In effect: {image} image-capable, {text} text-only. If this disagrees with the Image column, another plugin serves the route and writing this entry changes nothing.",
|
|
975
|
+
colReasoning: "Reasoning",
|
|
976
|
+
imageYes: "yes",
|
|
977
|
+
imageNo: "text only",
|
|
978
|
+
unmatched: "unmatched",
|
|
979
|
+
unmatchedHint: "{count} of these are not in models.dev; type their capability values in the table above.",
|
|
980
|
+
editHint: "Context, output and image can be edited right in the table \u2014 including models the catalog never listed. A blue value is one you typed.",
|
|
981
|
+
notListed: "not listed",
|
|
982
|
+
noModels: "This provider has no models yet.",
|
|
983
|
+
noTarget: "No writable configuration entry found (an enabled llm-pi-ai provider is required).",
|
|
984
|
+
loadFailed: "Load failed",
|
|
985
|
+
retry: "Retry",
|
|
986
|
+
viaAlias: "alias",
|
|
987
|
+
viaName: "by name",
|
|
988
|
+
viaNameSuffix: "name + variant",
|
|
989
|
+
viaExact: "exact",
|
|
990
|
+
viaFolded: "case-folded",
|
|
991
|
+
viaBasename: "basename",
|
|
992
|
+
viaSuffix: "suffix",
|
|
993
|
+
viaPrefix: "prefix match",
|
|
994
|
+
viaVendor: "vendor prefix",
|
|
995
|
+
viaSpelling: "gap as dash",
|
|
996
|
+
catalogInfo: "Catalog: {models} models \xB7 {time}",
|
|
997
|
+
catalogStale: "The online catalog download failed; using the local copy from {time}. The facts still mean the same thing, they may just be older.",
|
|
998
|
+
nothingSelected: "Nothing selected.",
|
|
999
|
+
redirectNoChanges: "These names already carry a source prefix; nothing to change.",
|
|
1000
|
+
reorder: "Reorder",
|
|
1001
|
+
reordering: "Reordering\u2026",
|
|
1002
|
+
reordered: "Reordered by {mode}",
|
|
1003
|
+
redirectApply: "Write names",
|
|
1004
|
+
redirectApplying: "Writing\u2026",
|
|
1005
|
+
redirectApplied: "Rewrote {count} names"
|
|
1006
|
+
};
|
|
1007
|
+
|
|
1008
|
+
// src/client/apply.ts
|
|
1009
|
+
var NS = "settings.capability-sync";
|
|
1010
|
+
var CHANNEL = "/model-capability-sync";
|
|
1011
|
+
function refusalOf(answer) {
|
|
1012
|
+
if (typeof answer !== "object" || answer === null) return void 0;
|
|
1013
|
+
const envelope = answer;
|
|
1014
|
+
if (envelope.ok !== false) return void 0;
|
|
1015
|
+
return {
|
|
1016
|
+
...typeof envelope.error?.code === "string" ? { code: envelope.error.code } : {},
|
|
1017
|
+
message: typeof envelope.error?.message === "string" ? envelope.error.message : "settings request refused"
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
function unwrap(answer) {
|
|
1021
|
+
const refusal = refusalOf(answer);
|
|
1022
|
+
if (refusal !== void 0) {
|
|
1023
|
+
throw Object.assign(new Error(refusal.message), refusal.code === void 0 ? {} : { code: refusal.code });
|
|
1024
|
+
}
|
|
1025
|
+
if (typeof answer === "object" && answer !== null && "ok" in answer && "value" in answer) {
|
|
1026
|
+
return answer.value;
|
|
1027
|
+
}
|
|
1028
|
+
return answer;
|
|
1029
|
+
}
|
|
1030
|
+
function namespacesOf(answer) {
|
|
1031
|
+
const document2 = unwrap(answer);
|
|
1032
|
+
if (Array.isArray(document2)) return document2;
|
|
1033
|
+
const namespaces = document2?.namespaces;
|
|
1034
|
+
if (!Array.isArray(namespaces)) throw new Error("settings.describe returned no namespace list");
|
|
1035
|
+
return namespaces;
|
|
1036
|
+
}
|
|
1037
|
+
var inject = ["slots", "locale", "connection", "remote", "remote.settings"];
|
|
1038
|
+
var SECTION_CSS = `
|
|
1039
|
+
.cs-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
|
|
1040
|
+
.cs-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
|
|
1041
|
+
.cs-select {
|
|
1042
|
+
box-sizing: border-box; padding: 6px 10px; border-radius: 8px;
|
|
1043
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
1044
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
1045
|
+
color: var(--dsw-alias-label-primary);
|
|
1046
|
+
font: inherit; font-size: 13px;
|
|
1047
|
+
}
|
|
1048
|
+
.cs-button {
|
|
1049
|
+
padding: 6px 12px; border-radius: 6px; font: inherit; font-size: 13px;
|
|
1050
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
1051
|
+
background: transparent; color: var(--dsw-alias-label-primary);
|
|
1052
|
+
cursor: pointer;
|
|
1053
|
+
}
|
|
1054
|
+
.cs-button:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
|
|
1055
|
+
.cs-button:disabled { opacity: 0.4; cursor: default; }
|
|
1056
|
+
.cs-button--primary {
|
|
1057
|
+
border-color: transparent;
|
|
1058
|
+
background: var(--dsw-alias-button-primary-fill);
|
|
1059
|
+
color: var(--dsw-alias-label-primary-foreground);
|
|
1060
|
+
}
|
|
1061
|
+
.cs-button--primary:hover:not(:disabled) { background: var(--dsw-alias-button-primary-hover); }
|
|
1062
|
+
.cs-hint { font-size: 12px; color: var(--dsw-alias-label-tertiary); line-height: 18px; }
|
|
1063
|
+
.cs-error { color: var(--dsw-alias-state-error-primary); font-size: 12px; }
|
|
1064
|
+
.cs-warn { color: var(--dsw-alias-state-warning-primary, var(--dsw-alias-label-secondary)); font-size: 12px; line-height: 18px; }
|
|
1065
|
+
.cs-input {
|
|
1066
|
+
box-sizing: border-box; padding: 6px 10px; border-radius: 8px; min-width: 200px;
|
|
1067
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
1068
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
1069
|
+
color: var(--dsw-alias-label-primary);
|
|
1070
|
+
font: inherit; font-size: 13px;
|
|
1071
|
+
}
|
|
1072
|
+
.cs-target { font-size: 13px; color: var(--dsw-alias-label-primary); line-height: 30px; }
|
|
1073
|
+
.cs-table-wrap {
|
|
1074
|
+
max-height: 460px; overflow: auto; margin-bottom: 12px;
|
|
1075
|
+
border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px;
|
|
1076
|
+
}
|
|
1077
|
+
/* Fit the columns to the panel: ids and names wrap rather than push the table
|
|
1078
|
+
wider than the space it has. Scrolling horizontally stays possible as a last
|
|
1079
|
+
resort for a very narrow window, it just is not the normal state. */
|
|
1080
|
+
.cs-table {
|
|
1081
|
+
width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px;
|
|
1082
|
+
table-layout: fixed;
|
|
1083
|
+
}
|
|
1084
|
+
.cs-table col.cs-col-check { width: 28px; }
|
|
1085
|
+
.cs-table col.cs-col-id { width: 17%; }
|
|
1086
|
+
.cs-table col.cs-col-name { width: 17%; }
|
|
1087
|
+
.cs-table col.cs-col-match { width: 19%; }
|
|
1088
|
+
.cs-table col.cs-col-context { width: 9%; }
|
|
1089
|
+
.cs-table col.cs-col-output { width: 9%; }
|
|
1090
|
+
.cs-table col.cs-col-image { width: 8%; }
|
|
1091
|
+
.cs-table col.cs-col-live { width: 7%; }
|
|
1092
|
+
.cs-table col.cs-col-reasoning { width: 14%; }
|
|
1093
|
+
.cs-table th {
|
|
1094
|
+
position: sticky; top: 0; z-index: 1;
|
|
1095
|
+
text-align: left; font-weight: 500; color: var(--dsw-alias-label-secondary);
|
|
1096
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
1097
|
+
padding: 6px 8px; border-bottom: 1px solid var(--dsw-alias-border-l2); white-space: nowrap;
|
|
1098
|
+
}
|
|
1099
|
+
.cs-table td {
|
|
1100
|
+
padding: 6px 8px; border-bottom: 1px solid var(--dsw-alias-border-l2);
|
|
1101
|
+
color: var(--dsw-alias-label-primary); vertical-align: top;
|
|
1102
|
+
}
|
|
1103
|
+
.cs-table tr:last-child td { border-bottom: none; }
|
|
1104
|
+
.cs-row--changed td { background: var(--dsw-alias-bg-layer-2, transparent); }
|
|
1105
|
+
.cs-id { font-variant-numeric: tabular-nums; word-break: break-all; }
|
|
1106
|
+
/* Cells that hold a control keep the row compact and the table inside the panel. */
|
|
1107
|
+
.cs-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
|
1108
|
+
.cs-input--cell, .cs-select--cell {
|
|
1109
|
+
width: 100%; min-width: 0; padding: 2px 4px; font-size: 12px; line-height: 18px;
|
|
1110
|
+
border-radius: 4px;
|
|
1111
|
+
}
|
|
1112
|
+
.cs-input--cell { text-align: right; font-variant-numeric: tabular-nums; }
|
|
1113
|
+
.cs-select--cell { padding-right: 2px; }
|
|
1114
|
+
/* A value the user typed is marked, so it is clear it did not come from the catalog. */
|
|
1115
|
+
.cs-input--typed, .cs-select--typed {
|
|
1116
|
+
border-color: var(--dsw-alias-brand-primary);
|
|
1117
|
+
color: var(--dsw-alias-brand-primary);
|
|
1118
|
+
}
|
|
1119
|
+
.cs-change--block { display: block; white-space: normal; }
|
|
1120
|
+
.cs-dim { color: var(--dsw-alias-label-tertiary); }
|
|
1121
|
+
.cs-change { white-space: nowrap; }
|
|
1122
|
+
.cs-from { color: var(--dsw-alias-label-tertiary); text-decoration: line-through; }
|
|
1123
|
+
.cs-badge {
|
|
1124
|
+
display: inline-block; padding: 0 6px; border-radius: 9px; font-size: 11px; line-height: 18px;
|
|
1125
|
+
border: 1px solid var(--dsw-alias-border-l2); color: var(--dsw-alias-label-secondary);
|
|
1126
|
+
}
|
|
1127
|
+
.cs-badge--image { border-color: var(--dsw-alias-brand-primary); color: var(--dsw-alias-brand-primary); }
|
|
1128
|
+
.cs-unmatched { margin: 8px 0 0; padding-left: 18px; color: var(--dsw-alias-label-tertiary); font-size: 12px; }
|
|
1129
|
+
`;
|
|
1130
|
+
function apply(ctx) {
|
|
1131
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), "model-capability-sync: copy dictionaries");
|
|
1132
|
+
if (typeof document !== "undefined") {
|
|
1133
|
+
ctx.effect(() => {
|
|
1134
|
+
const element = document.createElement("style");
|
|
1135
|
+
element.textContent = SECTION_CSS;
|
|
1136
|
+
document.head.append(element);
|
|
1137
|
+
return () => {
|
|
1138
|
+
element.remove();
|
|
1139
|
+
};
|
|
1140
|
+
}, "model-capability-sync: section styles");
|
|
1141
|
+
}
|
|
1142
|
+
const connection = ctx.get("connection");
|
|
1143
|
+
const remote = ctx.get("remote");
|
|
1144
|
+
const t = ctx.locale.bind(NS);
|
|
1145
|
+
const settingsInjected = () => ({
|
|
1146
|
+
describeSettings: async () => namespacesOf(await remote.settings.describe()),
|
|
1147
|
+
mutateSettings: async (ns, ops, expectedRevision) => {
|
|
1148
|
+
const view = unwrap(await remote.settings.mutate(ns, ops, expectedRevision));
|
|
1149
|
+
if (view === void 0) throw new Error("settings.mutate returned no namespace view");
|
|
1150
|
+
return view;
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
const injected = () => ({
|
|
1154
|
+
...settingsInjected(),
|
|
1155
|
+
preview: (request) => connection.rpc.call(CHANNEL, "preview", request),
|
|
1156
|
+
live: (request) => connection.rpc.call(CHANNEL, "live", request)
|
|
1157
|
+
});
|
|
1158
|
+
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
1159
|
+
name: "settings.section",
|
|
1160
|
+
id: "model-capability-sync",
|
|
1161
|
+
order: 16,
|
|
1162
|
+
label: () => t("nav"),
|
|
1163
|
+
locale: NS,
|
|
1164
|
+
inject: injected
|
|
1165
|
+
}, SyncSection));
|
|
1166
|
+
}
|
|
1167
|
+
return module.exports; } });
|
|
1168
|
+
//# sourceMappingURL=client.js.map
|