dsh-model-capability-sync 0.1.0 → 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/README.md +238 -114
- package/lib/client.js +486 -64
- package/lib/client.js.map +4 -4
- package/lib/index.js +144 -31
- package/lib/index.js.map +3 -3
- package/package.json +10 -3
- 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/src/client/SyncSection.tsx +364 -144
- package/src/client/apply.ts +41 -7
- package/src/client/locale.ts +38 -4
- package/src/client/rename.ts +157 -0
- package/src/client/shared.ts +197 -0
- package/src/index.ts +9 -7
- package/src/mapping.ts +3 -1
- package/src/match.ts +329 -28
- package/src/sort.ts +118 -6
- package/src/types.ts +17 -1
package/lib/client.js
CHANGED
|
@@ -39,6 +39,36 @@ function modelSortKey(id) {
|
|
|
39
39
|
}
|
|
40
40
|
return { group: id.slice(0, slash).toLowerCase(), name: id.slice(slash + 1).toLowerCase() };
|
|
41
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
|
+
}
|
|
42
72
|
function compareModelIds(left, right) {
|
|
43
73
|
const a = modelSortKey(left);
|
|
44
74
|
const b = modelSortKey(right);
|
|
@@ -47,12 +77,24 @@ function compareModelIds(left, right) {
|
|
|
47
77
|
if (left === right) return 0;
|
|
48
78
|
return left < right ? -1 : 1;
|
|
49
79
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
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)));
|
|
52
95
|
}
|
|
53
96
|
|
|
54
|
-
// src/client/
|
|
55
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
97
|
+
// src/client/shared.ts
|
|
56
98
|
var TARGET_DEFAULT = "llm-pi-ai";
|
|
57
99
|
var TARGET_DIRECTORY = {
|
|
58
100
|
"llm-pi-ai": { native: true, nameKey: "nameLlmPiAi" },
|
|
@@ -65,10 +107,6 @@ function targetLabelOf(ns, t) {
|
|
|
65
107
|
if (known === void 0) return `${t("sourcePlugin")} \xB7 ${ns}`;
|
|
66
108
|
return `${known.native ? t("sourceNative") : t("sourcePlugin")} \xB7 ${t(known.nameKey)}`;
|
|
67
109
|
}
|
|
68
|
-
function textOf(model, key) {
|
|
69
|
-
const value = model[key];
|
|
70
|
-
return typeof value === "string" ? value : "";
|
|
71
|
-
}
|
|
72
110
|
function providersOf(descriptor) {
|
|
73
111
|
const providers = descriptor?.value?.providers;
|
|
74
112
|
return typeof providers === "object" && providers !== null ? providers : {};
|
|
@@ -77,9 +115,106 @@ function modelsOf(provider) {
|
|
|
77
115
|
const models = provider?.models;
|
|
78
116
|
return Array.isArray(models) ? models.filter((entry) => typeof entry === "object" && entry !== null) : [];
|
|
79
117
|
}
|
|
80
|
-
function sortedModelsOf(provider) {
|
|
81
|
-
return sortByModelId(
|
|
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;
|
|
82
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");
|
|
83
218
|
function tokens(value) {
|
|
84
219
|
if (typeof value !== "number") return "\u2014";
|
|
85
220
|
if (value >= 1e6) return `${String(Number((value / 1e6).toFixed(1)))}M`;
|
|
@@ -98,27 +233,32 @@ function viaLabel(row, t) {
|
|
|
98
233
|
return t("viaBasename");
|
|
99
234
|
case "suffix":
|
|
100
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");
|
|
101
246
|
default:
|
|
102
247
|
return "";
|
|
103
248
|
}
|
|
104
249
|
}
|
|
105
|
-
function
|
|
106
|
-
if (value === void 0 || value === null || value === "") return true;
|
|
107
|
-
if (Array.isArray(value)) return value.length === 0;
|
|
108
|
-
if (typeof value === "object") return Object.keys(value).length === 0;
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
function mergeModel(model, fields, overwrite) {
|
|
250
|
+
function mergeModel(model, fields, overwrite, manual) {
|
|
112
251
|
const next = { ...model };
|
|
113
252
|
for (const [key, value] of Object.entries(fields)) {
|
|
114
253
|
if (key === "name" || value === void 0) continue;
|
|
115
|
-
|
|
254
|
+
const typed = manual !== void 0 && key in manual;
|
|
255
|
+
if (!typed && !overwrite && !isBlank(next[key])) continue;
|
|
116
256
|
next[key] = value;
|
|
117
257
|
}
|
|
118
258
|
return next;
|
|
119
259
|
}
|
|
120
|
-
function changesBetween(model, fields, overwrite) {
|
|
121
|
-
const next = mergeModel(model, fields, overwrite);
|
|
260
|
+
function changesBetween(model, fields, overwrite, manual) {
|
|
261
|
+
const next = mergeModel(model, fields, overwrite, manual);
|
|
122
262
|
const changes = [];
|
|
123
263
|
for (const key of Object.keys(fields)) {
|
|
124
264
|
const before = model[key];
|
|
@@ -141,6 +281,11 @@ function reasoningText(value) {
|
|
|
141
281
|
}
|
|
142
282
|
return "\u2014";
|
|
143
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
|
+
}
|
|
144
289
|
function liveLabel(row, t) {
|
|
145
290
|
if (row === void 0) return "\u2014";
|
|
146
291
|
if (row.error !== void 0) return t("liveError");
|
|
@@ -155,6 +300,31 @@ function valueCell(change, current, format) {
|
|
|
155
300
|
format(change.after)
|
|
156
301
|
] });
|
|
157
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
|
+
}
|
|
158
328
|
function SyncSection(props) {
|
|
159
329
|
const { t, preview, live, describeSettings, mutateSettings } = props;
|
|
160
330
|
const [status, setStatus] = (0, import_react.useState)("loading");
|
|
@@ -163,12 +333,17 @@ function SyncSection(props) {
|
|
|
163
333
|
const [targetNs, setTargetNs] = (0, import_react.useState)(TARGET_DEFAULT);
|
|
164
334
|
const [providerKey, setProviderKey] = (0, import_react.useState)("");
|
|
165
335
|
const [models, setModels] = (0, import_react.useState)([]);
|
|
336
|
+
const modelsRef = (0, import_react.useRef)([]);
|
|
166
337
|
const [rows, setRows] = (0, import_react.useState)(void 0);
|
|
338
|
+
const [typed, setTyped] = (0, import_react.useState)(/* @__PURE__ */ new Map());
|
|
167
339
|
const [liveRows, setLiveRows] = (0, import_react.useState)(/* @__PURE__ */ new Map());
|
|
168
340
|
const [selected, setSelected] = (0, import_react.useState)(/* @__PURE__ */ new Set());
|
|
169
341
|
const [overwrite, setOverwrite] = (0, import_react.useState)(false);
|
|
170
342
|
const [query, setQuery] = (0, import_react.useState)("");
|
|
171
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);
|
|
172
347
|
const [busy, setBusy] = (0, import_react.useState)("idle");
|
|
173
348
|
const [notice, setNotice] = (0, import_react.useState)(void 0);
|
|
174
349
|
const [catalogInfo, setCatalogInfo] = (0, import_react.useState)(void 0);
|
|
@@ -178,16 +353,19 @@ function SyncSection(props) {
|
|
|
178
353
|
const stored = new Map(models.map((model) => [textOf(model, "id"), model]));
|
|
179
354
|
return rows.map((row) => {
|
|
180
355
|
const model = stored.get(row.id) ?? {};
|
|
181
|
-
const
|
|
356
|
+
const manual = typed.get(row.id);
|
|
357
|
+
const fields = mergeFields(row.fields, manual);
|
|
182
358
|
return {
|
|
183
359
|
row,
|
|
184
360
|
model,
|
|
185
|
-
|
|
361
|
+
...fields === void 0 ? {} : { fields },
|
|
362
|
+
...manual === void 0 ? {} : { manual },
|
|
363
|
+
changes: fields === void 0 ? [] : changesBetween(model, fields, overwrite, manual)
|
|
186
364
|
};
|
|
187
365
|
});
|
|
188
366
|
})();
|
|
189
|
-
const matched = plan.filter((entry) => entry.
|
|
190
|
-
const unmatched = plan.filter((entry) => entry.
|
|
367
|
+
const matched = plan.filter((entry) => entry.fields !== void 0);
|
|
368
|
+
const unmatched = plan.filter((entry) => entry.fields === void 0);
|
|
191
369
|
const changing = matched.filter((entry) => entry.changes.length > 0);
|
|
192
370
|
const changeFields = changing.reduce((total, entry) => total + entry.changes.length, 0);
|
|
193
371
|
const liveImage = matched.filter((entry) => liveRows.get(entry.row.id)?.input?.includes("image") === true).length;
|
|
@@ -195,7 +373,7 @@ function SyncSection(props) {
|
|
|
195
373
|
const answer = liveRows.get(entry.row.id);
|
|
196
374
|
return answer?.input !== void 0 && !answer.input.includes("image");
|
|
197
375
|
}).length;
|
|
198
|
-
const load = async () => {
|
|
376
|
+
const load = async (mode = sortMode) => {
|
|
199
377
|
setStatus("loading");
|
|
200
378
|
setErrorText(void 0);
|
|
201
379
|
try {
|
|
@@ -212,7 +390,7 @@ function SyncSection(props) {
|
|
|
212
390
|
const firstKey = Object.keys(providers)[0] ?? "";
|
|
213
391
|
setTargetNs(target.ns);
|
|
214
392
|
setProviderKey(firstKey);
|
|
215
|
-
|
|
393
|
+
putModels(sortedModelsOf(providers[firstKey], mode));
|
|
216
394
|
setRows(void 0);
|
|
217
395
|
setLiveRows(/* @__PURE__ */ new Map());
|
|
218
396
|
setSelected(/* @__PURE__ */ new Set());
|
|
@@ -226,12 +404,12 @@ function SyncSection(props) {
|
|
|
226
404
|
(0, import_react.useEffect)(() => {
|
|
227
405
|
void load();
|
|
228
406
|
}, []);
|
|
229
|
-
const showProvider = (ns, key) => {
|
|
407
|
+
const showProvider = (ns, key, mode = sortMode) => {
|
|
230
408
|
const providers = providersOf(descriptors.find((entry) => entry.ns === ns));
|
|
231
409
|
const resolved = key !== "" && providers[key] !== void 0 ? key : Object.keys(providers)[0] ?? "";
|
|
232
410
|
setTargetNs(ns);
|
|
233
411
|
setProviderKey(resolved);
|
|
234
|
-
|
|
412
|
+
putModels(sortedModelsOf(providers[resolved], mode));
|
|
235
413
|
setRows(void 0);
|
|
236
414
|
setLiveRows(/* @__PURE__ */ new Map());
|
|
237
415
|
setSelected(/* @__PURE__ */ new Set());
|
|
@@ -250,7 +428,7 @@ function SyncSection(props) {
|
|
|
250
428
|
const list = await describeSettings();
|
|
251
429
|
setDescriptors(list);
|
|
252
430
|
const descriptor2 = list.find((entry) => entry.ns === targetNs);
|
|
253
|
-
if (descriptor2 !== void 0)
|
|
431
|
+
if (descriptor2 !== void 0) putModels(sortedModelsOf(providersOf(descriptor2)[providerKey], sortMode));
|
|
254
432
|
};
|
|
255
433
|
const selectChanging = (source, stored, mode) => {
|
|
256
434
|
const byId = new Map(stored.map((model) => [textOf(model, "id"), model]));
|
|
@@ -263,7 +441,17 @@ function SyncSection(props) {
|
|
|
263
441
|
setStaleInfo(void 0);
|
|
264
442
|
try {
|
|
265
443
|
const ids = models.map((model) => textOf(model, "id")).filter((id) => id.length > 0);
|
|
266
|
-
const
|
|
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
|
+
});
|
|
267
455
|
if (!result.ok) throw new Error(result.error.message);
|
|
268
456
|
setRows(result.value.rows);
|
|
269
457
|
selectChanging(result.value.rows, models, overwrite);
|
|
@@ -279,37 +467,111 @@ function SyncSection(props) {
|
|
|
279
467
|
setBusy("idle");
|
|
280
468
|
}
|
|
281
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
|
+
};
|
|
282
475
|
const setOverwriteMode = (mode) => {
|
|
283
476
|
setOverwrite(mode);
|
|
284
477
|
if (rows === void 0) return;
|
|
285
478
|
selectChanging(rows, models, mode);
|
|
286
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
|
+
};
|
|
287
549
|
const applyRows = async () => {
|
|
288
550
|
const descriptor2 = descriptors.find((entry) => entry.ns === targetNs);
|
|
289
551
|
if (descriptor2 === void 0) return;
|
|
290
|
-
const targets = new Map(changing.filter((entry) => selected.has(entry.row.id)).map((entry) => [entry.row.id, entry]));
|
|
552
|
+
const targets = new Map(changing.filter((entry) => selected.has(entry.row.id) && entry.fields !== void 0).map((entry) => [entry.row.id, entry]));
|
|
291
553
|
if (targets.size === 0) {
|
|
292
554
|
setNotice(t("nothingSelected"));
|
|
293
555
|
return;
|
|
294
556
|
}
|
|
295
557
|
let written = 0;
|
|
296
|
-
const next =
|
|
558
|
+
const next = modelsRef.current.map((model) => {
|
|
297
559
|
const entry = targets.get(textOf(model, "id"));
|
|
298
|
-
if (entry?.
|
|
560
|
+
if (entry?.fields === void 0) return model;
|
|
299
561
|
written += 1;
|
|
300
|
-
return mergeModel(model, entry.
|
|
562
|
+
return mergeModel(model, entry.fields, overwrite, entry.manual);
|
|
301
563
|
});
|
|
302
564
|
setBusy("applying");
|
|
303
565
|
setErrorText(void 0);
|
|
304
566
|
setNotice(void 0);
|
|
305
567
|
try {
|
|
568
|
+
const ordered = sortByModelId(next, (model) => textOf(model, "id"), (model) => textOf(model, "name"), sortMode);
|
|
306
569
|
const view = await mutateSettings(targetNs, [{
|
|
307
570
|
op: "set",
|
|
308
571
|
path: ["providers", providerKey, "models"],
|
|
309
|
-
value:
|
|
572
|
+
value: ordered
|
|
310
573
|
}], descriptor2.revision);
|
|
311
|
-
|
|
312
|
-
setDescriptors((previous) => previous.map((entry) => entry.ns === targetNs && typeof view.revision === "number" ? { ...entry, revision: view.revision } : entry));
|
|
574
|
+
commitWrite(ordered, view);
|
|
313
575
|
setNotice(t("applied", { count: written }));
|
|
314
576
|
await refreshLive(providerKey, next.map((model) => textOf(model, "id")).filter((id) => id.length > 0));
|
|
315
577
|
} catch (error) {
|
|
@@ -344,7 +606,7 @@ function SyncSection(props) {
|
|
|
344
606
|
const candidates = descriptors.filter((entry) => Object.keys(providersOf(entry)).length > 0);
|
|
345
607
|
const providerKeys = Object.keys(providersOf(descriptor));
|
|
346
608
|
const needle = query.trim().toLowerCase();
|
|
347
|
-
const visible =
|
|
609
|
+
const visible = plan.filter((entry) => {
|
|
348
610
|
if (onlyChanged && entry.changes.length === 0) return false;
|
|
349
611
|
if (needle === "") return true;
|
|
350
612
|
return entry.row.id.toLowerCase().includes(needle) || entry.row.match?.modelId.toLowerCase().includes(needle) === true;
|
|
@@ -375,6 +637,23 @@ function SyncSection(props) {
|
|
|
375
637
|
}, children: providerKeys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: key, children: key }, key)) })
|
|
376
638
|
] }),
|
|
377
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
|
+
] }),
|
|
378
657
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-hint", children: t("willSort") })
|
|
379
658
|
] }),
|
|
380
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: [
|
|
@@ -390,13 +669,38 @@ function SyncSection(props) {
|
|
|
390
669
|
} }),
|
|
391
670
|
" ",
|
|
392
671
|
t("overwrite")
|
|
393
|
-
] })
|
|
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
|
+
)
|
|
394
697
|
] }),
|
|
395
698
|
errorText !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-error", children: errorText }) : null,
|
|
396
699
|
notice !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-hint", children: notice }) : null,
|
|
397
700
|
catalogInfo !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-hint", children: catalogInfo }) : null,
|
|
398
701
|
staleInfo !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-warn", children: staleInfo }) : null,
|
|
399
|
-
rows !== void 0 &&
|
|
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") }),
|
|
400
704
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "cs-row", children: [
|
|
401
705
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
402
706
|
"input",
|
|
@@ -420,6 +724,17 @@ function SyncSection(props) {
|
|
|
420
724
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cs-hint", children: changing.length === 0 ? t("noChanges") : t("changeSummary", { rows: changing.length, fields: changeFields }) })
|
|
421
725
|
] }),
|
|
422
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
|
+
] }),
|
|
423
738
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
424
739
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
425
740
|
"input",
|
|
@@ -434,6 +749,7 @@ function SyncSection(props) {
|
|
|
434
749
|
}
|
|
435
750
|
) }),
|
|
436
751
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colModel") }),
|
|
752
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colName") }),
|
|
437
753
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colMatch") }),
|
|
438
754
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colContext") }),
|
|
439
755
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colOutput") }),
|
|
@@ -441,7 +757,8 @@ function SyncSection(props) {
|
|
|
441
757
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { title: t("colLiveHint"), children: t("colLive") }),
|
|
442
758
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: t("colReasoning") })
|
|
443
759
|
] }) }),
|
|
444
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: visible.map((
|
|
760
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: visible.map((entry) => {
|
|
761
|
+
const { row, model, changes } = entry;
|
|
445
762
|
const changeOf = (key) => changes.find((change) => change.key === key);
|
|
446
763
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { className: changes.length > 0 ? "cs-row--changed" : void 0, children: [
|
|
447
764
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -457,14 +774,62 @@ function SyncSection(props) {
|
|
|
457
774
|
}
|
|
458
775
|
) }),
|
|
459
776
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "cs-id", children: row.id }),
|
|
460
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
461
|
-
|
|
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}`,
|
|
462
780
|
" ",
|
|
463
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
|
+
] })
|
|
464
832
|
] }),
|
|
465
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: valueCell(changeOf("contextWindow"), model.contextWindow, tokens) }),
|
|
466
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: valueCell(changeOf("maxTokens"), model.maxTokens, tokens) }),
|
|
467
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: valueCell(changeOf("input"), model.input, (value) => imageText(value, t)) }),
|
|
468
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) }) }),
|
|
469
834
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "cs-dim", children: valueCell(changeOf("reasoningEfforts"), model.reasoningEfforts, reasoningText) })
|
|
470
835
|
] }, row.id);
|
|
@@ -484,16 +849,7 @@ function SyncSection(props) {
|
|
|
484
849
|
}
|
|
485
850
|
) })
|
|
486
851
|
] }) : null,
|
|
487
|
-
unmatched.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.
|
|
488
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-hint", children: t("unmatchedHint") }),
|
|
489
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "cs-unmatched", children: unmatched.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
490
|
-
entry.row.id,
|
|
491
|
-
entry.row.reason === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "cs-dim", children: [
|
|
492
|
-
" \u2014 ",
|
|
493
|
-
entry.row.reason
|
|
494
|
-
] })
|
|
495
|
-
] }, entry.row.id)) })
|
|
496
|
-
] }) : null
|
|
852
|
+
unmatched.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "cs-hint", children: t("unmatchedHint", { count: unmatched.length }) }) : null
|
|
497
853
|
] });
|
|
498
854
|
}
|
|
499
855
|
|
|
@@ -512,6 +868,9 @@ var zh = {
|
|
|
512
868
|
provider: "\u4F9B\u5E94\u5546",
|
|
513
869
|
modelCount: "\u5171 {count} \u4E2A\u6A21\u578B",
|
|
514
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",
|
|
515
874
|
search: "\u641C\u7D22\u6A21\u578B ID \u6216\u76EE\u5F55 ID",
|
|
516
875
|
onlyChanged: "\u53EA\u770B\u6709\u53D8\u5316\u7684",
|
|
517
876
|
changeSummary: "\u5C06\u4FEE\u6539 {rows} \u884C \xB7 {fields} \u4E2A\u5B57\u6BB5",
|
|
@@ -529,6 +888,7 @@ var zh = {
|
|
|
529
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",
|
|
530
889
|
selectAll: "\u5168\u9009",
|
|
531
890
|
colModel: "\u6A21\u578B ID",
|
|
891
|
+
colName: "\u540D\u79F0",
|
|
532
892
|
colMatch: "\u5339\u914D",
|
|
533
893
|
colContext: "\u4E0A\u4E0B\u6587",
|
|
534
894
|
colOutput: "\u8F93\u51FA",
|
|
@@ -541,20 +901,33 @@ var zh = {
|
|
|
541
901
|
imageYes: "\u652F\u6301",
|
|
542
902
|
imageNo: "\u7EAF\u6587\u672C",
|
|
543
903
|
unmatched: "\u672A\u5339\u914D",
|
|
544
|
-
unmatchedHint: "\
|
|
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",
|
|
545
907
|
noModels: "\u8BE5\u4F9B\u5E94\u5546\u4E0B\u8FD8\u6CA1\u6709\u6A21\u578B\u3002",
|
|
546
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",
|
|
547
909
|
loadFailed: "\u52A0\u8F7D\u5931\u8D25",
|
|
548
910
|
retry: "\u91CD\u8BD5",
|
|
549
911
|
viaAlias: "\u522B\u540D",
|
|
912
|
+
viaName: "\u6309\u540D\u79F0",
|
|
913
|
+
viaNameSuffix: "\u540D\u79F0\u53BB\u53D8\u4F53",
|
|
550
914
|
viaExact: "\u7CBE\u786E",
|
|
551
915
|
viaFolded: "\u5FFD\u7565\u5927\u5C0F\u5199",
|
|
552
916
|
viaBasename: "\u53BB\u524D\u7F00",
|
|
553
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",
|
|
554
921
|
catalogInfo: "\u76EE\u5F55\uFF1A{models} \u4E2A\u6A21\u578B \xB7 {time}",
|
|
555
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",
|
|
556
923
|
nothingSelected: "\u6CA1\u6709\u9009\u4E2D\u4EFB\u4F55\u6A21\u578B\u3002",
|
|
557
|
-
|
|
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"
|
|
558
931
|
};
|
|
559
932
|
var en = {
|
|
560
933
|
nav: "Model capabilities",
|
|
@@ -570,6 +943,9 @@ var en = {
|
|
|
570
943
|
provider: "Provider",
|
|
571
944
|
modelCount: "{count} models",
|
|
572
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",
|
|
573
949
|
search: "Search model id or catalog id",
|
|
574
950
|
onlyChanged: "Only rows that change",
|
|
575
951
|
changeSummary: "Will change {rows} rows \xB7 {fields} fields",
|
|
@@ -587,6 +963,7 @@ var en = {
|
|
|
587
963
|
overwriteHint: "Unchecked: only blank fields are filled, so values you typed are preserved.",
|
|
588
964
|
selectAll: "Select all",
|
|
589
965
|
colModel: "Model id",
|
|
966
|
+
colName: "Name",
|
|
590
967
|
colMatch: "Match",
|
|
591
968
|
colContext: "Context",
|
|
592
969
|
colOutput: "Output",
|
|
@@ -599,20 +976,33 @@ var en = {
|
|
|
599
976
|
imageYes: "yes",
|
|
600
977
|
imageNo: "text only",
|
|
601
978
|
unmatched: "unmatched",
|
|
602
|
-
unmatchedHint: "
|
|
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",
|
|
603
982
|
noModels: "This provider has no models yet.",
|
|
604
983
|
noTarget: "No writable configuration entry found (an enabled llm-pi-ai provider is required).",
|
|
605
984
|
loadFailed: "Load failed",
|
|
606
985
|
retry: "Retry",
|
|
607
986
|
viaAlias: "alias",
|
|
987
|
+
viaName: "by name",
|
|
988
|
+
viaNameSuffix: "name + variant",
|
|
608
989
|
viaExact: "exact",
|
|
609
990
|
viaFolded: "case-folded",
|
|
610
991
|
viaBasename: "basename",
|
|
611
992
|
viaSuffix: "suffix",
|
|
993
|
+
viaPrefix: "prefix match",
|
|
994
|
+
viaVendor: "vendor prefix",
|
|
995
|
+
viaSpelling: "gap as dash",
|
|
612
996
|
catalogInfo: "Catalog: {models} models \xB7 {time}",
|
|
613
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.",
|
|
614
998
|
nothingSelected: "Nothing selected.",
|
|
615
|
-
|
|
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"
|
|
616
1006
|
};
|
|
617
1007
|
|
|
618
1008
|
// src/client/apply.ts
|
|
@@ -684,7 +1074,22 @@ var SECTION_CSS = `
|
|
|
684
1074
|
max-height: 460px; overflow: auto; margin-bottom: 12px;
|
|
685
1075
|
border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px;
|
|
686
1076
|
}
|
|
687
|
-
|
|
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%; }
|
|
688
1093
|
.cs-table th {
|
|
689
1094
|
position: sticky; top: 0; z-index: 1;
|
|
690
1095
|
text-align: left; font-weight: 500; color: var(--dsw-alias-label-secondary);
|
|
@@ -698,6 +1103,20 @@ var SECTION_CSS = `
|
|
|
698
1103
|
.cs-table tr:last-child td { border-bottom: none; }
|
|
699
1104
|
.cs-row--changed td { background: var(--dsw-alias-bg-layer-2, transparent); }
|
|
700
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; }
|
|
701
1120
|
.cs-dim { color: var(--dsw-alias-label-tertiary); }
|
|
702
1121
|
.cs-change { white-space: nowrap; }
|
|
703
1122
|
.cs-from { color: var(--dsw-alias-label-tertiary); text-decoration: line-through; }
|
|
@@ -723,9 +1142,7 @@ function apply(ctx) {
|
|
|
723
1142
|
const connection = ctx.get("connection");
|
|
724
1143
|
const remote = ctx.get("remote");
|
|
725
1144
|
const t = ctx.locale.bind(NS);
|
|
726
|
-
const
|
|
727
|
-
preview: (request) => connection.rpc.call(CHANNEL, "preview", request),
|
|
728
|
-
live: (request) => connection.rpc.call(CHANNEL, "live", request),
|
|
1145
|
+
const settingsInjected = () => ({
|
|
729
1146
|
describeSettings: async () => namespacesOf(await remote.settings.describe()),
|
|
730
1147
|
mutateSettings: async (ns, ops, expectedRevision) => {
|
|
731
1148
|
const view = unwrap(await remote.settings.mutate(ns, ops, expectedRevision));
|
|
@@ -733,6 +1150,11 @@ function apply(ctx) {
|
|
|
733
1150
|
return view;
|
|
734
1151
|
}
|
|
735
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
|
+
});
|
|
736
1158
|
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
737
1159
|
name: "settings.section",
|
|
738
1160
|
id: "model-capability-sync",
|