athanor 2.4.1 → 3.1.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/AGENTS.md +9 -9
- package/README.md +73 -23
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +3 -2
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/llama.d.ts.map +1 -1
- package/dist/adapters/llama.js +21 -0
- package/dist/adapters/llama.js.map +1 -1
- package/dist/app/models.d.ts +2 -1
- package/dist/app/models.d.ts.map +1 -1
- package/dist/app/models.js +50 -16
- package/dist/app/models.js.map +1 -1
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +1 -1
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +24 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/model-commands.d.ts.map +1 -1
- package/dist/cli/model-commands.js +24 -16
- package/dist/cli/model-commands.js.map +1 -1
- package/dist/cli/preset-commands.d.ts +16 -6
- package/dist/cli/preset-commands.d.ts.map +1 -1
- package/dist/cli/preset-commands.js +64 -32
- package/dist/cli/preset-commands.js.map +1 -1
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +7 -2
- package/dist/config/index.js.map +1 -1
- package/dist/control/server.d.ts +4 -1
- package/dist/control/server.d.ts.map +1 -1
- package/dist/control/server.js +4 -2
- package/dist/control/server.js.map +1 -1
- package/dist/discovery/scanner.d.ts +5 -2
- package/dist/discovery/scanner.d.ts.map +1 -1
- package/dist/discovery/scanner.js +100 -1
- package/dist/discovery/scanner.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/presets/compound.d.ts +22 -0
- package/dist/presets/compound.d.ts.map +1 -0
- package/dist/presets/compound.js +371 -0
- package/dist/presets/compound.js.map +1 -0
- package/dist/presets/edit.d.ts +5 -2
- package/dist/presets/edit.d.ts.map +1 -1
- package/dist/presets/edit.js +75 -12
- package/dist/presets/edit.js.map +1 -1
- package/dist/presets/recipes.d.ts +18 -11
- package/dist/presets/recipes.d.ts.map +1 -1
- package/dist/presets/recipes.js +116 -24
- package/dist/presets/recipes.js.map +1 -1
- package/dist/registry/index.d.ts +2 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +40 -6
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/materialize.d.ts +2 -1
- package/dist/registry/materialize.d.ts.map +1 -1
- package/dist/registry/materialize.js +72 -7
- package/dist/registry/materialize.js.map +1 -1
- package/dist/registry/recommend.d.ts +1 -1
- package/dist/registry/recommend.d.ts.map +1 -1
- package/dist/registry/recommend.js +1 -1
- package/dist/registry/recommend.js.map +1 -1
- package/dist/router/server.d.ts.map +1 -1
- package/dist/router/server.js +45 -2
- package/dist/router/server.js.map +1 -1
- package/dist/supervisor/index.d.ts.map +1 -1
- package/dist/supervisor/index.js +24 -6
- package/dist/supervisor/index.js.map +1 -1
- package/dist/supervisor/telemetry.js +1 -1
- package/dist/supervisor/telemetry.js.map +1 -1
- package/dist/sync/pi.js +4 -4
- package/dist/sync/pi.js.map +1 -1
- package/dist/types/index.d.ts +27 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui/App.js +1 -1
- package/dist/ui/App.js.map +1 -1
- package/dist/ui/PresetEditor.d.ts +6 -0
- package/dist/ui/PresetEditor.d.ts.map +1 -1
- package/dist/ui/PresetEditor.js +347 -70
- package/dist/ui/PresetEditor.js.map +1 -1
- package/dist/ui/clipboard.d.ts +4 -0
- package/dist/ui/clipboard.d.ts.map +1 -0
- package/dist/ui/clipboard.js +77 -0
- package/dist/ui/clipboard.js.map +1 -0
- package/dist/ui/useDownloads.d.ts.map +1 -1
- package/dist/ui/useDownloads.js +3 -4
- package/dist/ui/useDownloads.js.map +1 -1
- package/package.json +1 -1
package/dist/ui/PresetEditor.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useState } from "react";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { Box, Text, useInput } from "ink";
|
|
4
4
|
import { getModel } from "../registry/index.js";
|
|
5
5
|
import { mergedConfigFor } from "../adapters/index.js";
|
|
6
6
|
import { supervisor } from "../supervisor/index.js";
|
|
7
|
-
import { setFlavor,
|
|
8
|
-
import { listKeys,
|
|
9
|
-
import {
|
|
7
|
+
import { setFlavor, setFormula } from "../app/models.js";
|
|
8
|
+
import { listKeys, setFormulaFields, unsetFormulaFields } from "../presets/edit.js";
|
|
9
|
+
import { COMPOUND_KNOBS, getCategoriesForRuntime, inferCompoundState, applyCompoundSelection } from "../presets/compound.js";
|
|
10
|
+
import { deleteUserFormula, findMatchingFormula, listFormulas, formulaToRuntime, saveUserFormula } from "../presets/recipes.js";
|
|
11
|
+
import { copyToClipboard, formatPresetCopyText } from "./clipboard.js";
|
|
10
12
|
function errMsg(err) {
|
|
11
13
|
if (err instanceof Error)
|
|
12
14
|
return err.message;
|
|
13
15
|
return String(err);
|
|
14
16
|
}
|
|
15
17
|
function presetValueFor(entry, jsonName) {
|
|
16
|
-
|
|
18
|
+
const active = entry.formula ?? entry.preset;
|
|
19
|
+
if (!active || active.runtime !== entry.runtime)
|
|
17
20
|
return undefined;
|
|
18
|
-
const bag =
|
|
21
|
+
const bag = active.runtime === "mlx" ? active.mlx : active.llama;
|
|
19
22
|
return bag[jsonName];
|
|
20
23
|
}
|
|
21
24
|
export const STANDARD_CTX_SIZES = [
|
|
@@ -132,6 +135,42 @@ export function cycleFloat(currentStr, direction, step, min, max, fallback) {
|
|
|
132
135
|
const clamped = Math.max(min, Math.min(max, next));
|
|
133
136
|
return Math.round(clamped * 100) / 100;
|
|
134
137
|
}
|
|
138
|
+
export const CACHE_TYPES = ["f16", "q8_0", "q4_0", "q4_1", "iq4_nl", "q5_0", "q5_1", "bf16", "f32"];
|
|
139
|
+
export function getNextCacheType(currentStr, direction) {
|
|
140
|
+
const idx = CACHE_TYPES.indexOf(currentStr);
|
|
141
|
+
if (idx < 0)
|
|
142
|
+
return CACHE_TYPES[0];
|
|
143
|
+
if (direction === "left") {
|
|
144
|
+
return CACHE_TYPES[Math.max(0, idx - 1)];
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
return CACHE_TYPES[Math.min(CACHE_TYPES.length - 1, idx + 1)];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
export const FLASH_ATTN_MODES = ["auto", "on", "off"];
|
|
151
|
+
export function getNextFlashAttn(currentStr, direction) {
|
|
152
|
+
const idx = FLASH_ATTN_MODES.indexOf(currentStr);
|
|
153
|
+
if (idx < 0)
|
|
154
|
+
return FLASH_ATTN_MODES[0];
|
|
155
|
+
if (direction === "left") {
|
|
156
|
+
return FLASH_ATTN_MODES[Math.max(0, idx - 1)];
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
return FLASH_ATTN_MODES[Math.min(FLASH_ATTN_MODES.length - 1, idx + 1)];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export const SPECULATIVE_MODES = ["auto", "enabled", "disabled"];
|
|
163
|
+
export function getNextSpeculativeMode(currentStr, direction) {
|
|
164
|
+
const idx = SPECULATIVE_MODES.indexOf(currentStr);
|
|
165
|
+
if (idx < 0)
|
|
166
|
+
return SPECULATIVE_MODES[0];
|
|
167
|
+
if (direction === "left") {
|
|
168
|
+
return SPECULATIVE_MODES[Math.max(0, idx - 1)];
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
return SPECULATIVE_MODES[Math.min(SPECULATIVE_MODES.length - 1, idx + 1)];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
135
174
|
export const CYCLABLE_KEYS = [
|
|
136
175
|
"contextWindow",
|
|
137
176
|
"ctxSize",
|
|
@@ -149,23 +188,67 @@ export const CYCLABLE_KEYS = [
|
|
|
149
188
|
"repeatPenalty",
|
|
150
189
|
"presencePenalty",
|
|
151
190
|
"frequencyPenalty",
|
|
152
|
-
"repeatLastN"
|
|
191
|
+
"repeatLastN",
|
|
192
|
+
"cacheTypeK",
|
|
193
|
+
"cacheTypeV",
|
|
194
|
+
"flashAttn",
|
|
195
|
+
"specDraftCacheTypeK",
|
|
196
|
+
"specDraftCacheTypeV",
|
|
197
|
+
"speculativeMode",
|
|
198
|
+
"reasoningEffort"
|
|
153
199
|
];
|
|
154
200
|
export const PresetEditor = ({ entryId, width = 88, onClose }) => {
|
|
155
201
|
const initial = getModel(entryId);
|
|
156
202
|
const [entry, setEntry] = useState(initial);
|
|
203
|
+
const [mode, setMode] = useState("simple");
|
|
157
204
|
const [cursor, setCursor] = useState(0);
|
|
158
205
|
const [edit, setEdit] = useState(null);
|
|
206
|
+
const [activeRecipeName, setActiveRecipeName] = useState(null);
|
|
207
|
+
const [savingRecipe, setSavingRecipe] = useState(null);
|
|
208
|
+
const [recipesList, setRecipesList] = useState(() => listFormulas());
|
|
159
209
|
const [notice, setNotice] = useState("");
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
210
|
+
const [clearConfirmPending, setClearConfirmPending] = useState(false);
|
|
211
|
+
// Reset clear confirmation after 3 seconds
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
if (!clearConfirmPending)
|
|
214
|
+
return;
|
|
215
|
+
const timer = setTimeout(() => {
|
|
216
|
+
setClearConfirmPending(false);
|
|
217
|
+
setNotice("");
|
|
218
|
+
}, 3000);
|
|
219
|
+
return () => clearTimeout(timer);
|
|
220
|
+
}, [clearConfirmPending]);
|
|
221
|
+
const compoundKnobs = useMemo(() => {
|
|
222
|
+
if (!entry)
|
|
223
|
+
return [];
|
|
224
|
+
return COMPOUND_KNOBS.filter(k => {
|
|
225
|
+
if (!k.runtimes.includes(entry.runtime))
|
|
226
|
+
return false;
|
|
227
|
+
if (k.id === "reasoningEffort" && !entry.reasoningEffort)
|
|
228
|
+
return false;
|
|
229
|
+
return true;
|
|
230
|
+
});
|
|
231
|
+
}, [entry]);
|
|
232
|
+
const categories = useMemo(() => {
|
|
233
|
+
if (!entry)
|
|
234
|
+
return [];
|
|
235
|
+
return getCategoriesForRuntime(entry.runtime);
|
|
236
|
+
}, [entry]);
|
|
237
|
+
const allKeys = useMemo(() => (entry ? listKeys(entry.runtime) : []), [entry]);
|
|
238
|
+
const effective = useMemo(() => (entry ? mergedConfigFor(entry) : {}), [entry]);
|
|
239
|
+
const compoundState = useMemo(() => {
|
|
240
|
+
if (!entry)
|
|
241
|
+
return {};
|
|
242
|
+
return inferCompoundState(entry, effective);
|
|
243
|
+
}, [entry, effective]);
|
|
244
|
+
// In Advanced mode, flat items represent all tunable keys
|
|
245
|
+
const totalItems = mode === "simple" ? compoundKnobs.length : allKeys.length;
|
|
163
246
|
function refresh(msg) {
|
|
164
247
|
setEntry(getModel(entryId));
|
|
165
248
|
setNotice(msg);
|
|
166
249
|
}
|
|
167
|
-
function persistPreset(
|
|
168
|
-
|
|
250
|
+
function persistPreset(formula, msg) {
|
|
251
|
+
setFormula(entryId, formula);
|
|
169
252
|
refresh(msg);
|
|
170
253
|
}
|
|
171
254
|
function persistFlavor(mlxFlavor, msg) {
|
|
@@ -178,6 +261,69 @@ export const PresetEditor = ({ entryId, width = 88, onClose }) => {
|
|
|
178
261
|
onClose("");
|
|
179
262
|
return;
|
|
180
263
|
}
|
|
264
|
+
// Tab key toggles between Simple and Advanced modes
|
|
265
|
+
if (key.tab) {
|
|
266
|
+
setMode(m => (m === "simple" ? "advanced" : "simple"));
|
|
267
|
+
setCursor(0);
|
|
268
|
+
setEdit(null);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (savingRecipe) {
|
|
272
|
+
if (key.escape) {
|
|
273
|
+
setSavingRecipe(null);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (key.return) {
|
|
277
|
+
const name = savingRecipe.buffer.trim();
|
|
278
|
+
if (!name) {
|
|
279
|
+
setNotice("error: formula name cannot be empty");
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const active = entry.formula ?? entry.preset;
|
|
283
|
+
const formula = {
|
|
284
|
+
name,
|
|
285
|
+
description: `Custom formula saved from ${entry.slug}`,
|
|
286
|
+
mlx: active?.runtime === "mlx" ? active.mlx : undefined,
|
|
287
|
+
llama: active?.runtime === "llama.cpp" ? active.llama : undefined,
|
|
288
|
+
source: "user"
|
|
289
|
+
};
|
|
290
|
+
saveUserFormula(formula);
|
|
291
|
+
setRecipesList(listFormulas());
|
|
292
|
+
setActiveRecipeName(name);
|
|
293
|
+
setSavingRecipe(null);
|
|
294
|
+
setNotice(`✓ formula "${name}" saved`);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (key.upArrow || key.downArrow) {
|
|
298
|
+
const dir = key.upArrow ? -1 : 1;
|
|
299
|
+
const allNames = recipesList.map(r => r.name);
|
|
300
|
+
if (allNames.length > 0) {
|
|
301
|
+
const nextIdx = (savingRecipe.cycleIndex + dir + allNames.length) % allNames.length;
|
|
302
|
+
const nextName = allNames[nextIdx];
|
|
303
|
+
setSavingRecipe({ buffer: nextName, cycleIndex: nextIdx });
|
|
304
|
+
}
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if (key.tab) {
|
|
308
|
+
const prefix = savingRecipe.buffer.trim().toLowerCase();
|
|
309
|
+
if (prefix) {
|
|
310
|
+
const match = recipesList.find(r => r.name.toLowerCase().startsWith(prefix) && r.name.toLowerCase() !== prefix);
|
|
311
|
+
if (match) {
|
|
312
|
+
const idx = recipesList.indexOf(match);
|
|
313
|
+
setSavingRecipe({ buffer: match.name, cycleIndex: idx >= 0 ? idx : 0 });
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (key.backspace || key.delete) {
|
|
319
|
+
setSavingRecipe(s => (s ? { ...s, buffer: s.buffer.slice(0, -1) } : s));
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (input && /^[a-zA-Z0-9_-]$/.test(input)) {
|
|
323
|
+
setSavingRecipe(s => (s ? { ...s, buffer: s.buffer + input } : s));
|
|
324
|
+
}
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
181
327
|
if (edit) {
|
|
182
328
|
if (key.escape) {
|
|
183
329
|
setEdit(null);
|
|
@@ -185,8 +331,8 @@ export const PresetEditor = ({ entryId, width = 88, onClose }) => {
|
|
|
185
331
|
}
|
|
186
332
|
if (key.return) {
|
|
187
333
|
try {
|
|
188
|
-
const
|
|
189
|
-
persistPreset(
|
|
334
|
+
const formula = setFormulaFields(entry, [[edit.jsonName, edit.buffer]]);
|
|
335
|
+
persistPreset(formula, `updated ${edit.jsonName} = ${edit.buffer}`);
|
|
190
336
|
setEdit(null);
|
|
191
337
|
}
|
|
192
338
|
catch (err) {
|
|
@@ -233,21 +379,40 @@ export const PresetEditor = ({ entryId, width = 88, onClose }) => {
|
|
|
233
379
|
else if (edit.jsonName === "repeatLastN") {
|
|
234
380
|
nextVal = getNextRepeatLastN(edit.buffer, dir);
|
|
235
381
|
}
|
|
382
|
+
else if (["cacheTypeK", "cacheTypeV", "specDraftCacheTypeK", "specDraftCacheTypeV"].includes(edit.jsonName)) {
|
|
383
|
+
nextVal = getNextCacheType(edit.buffer, dir);
|
|
384
|
+
}
|
|
385
|
+
else if (edit.jsonName === "flashAttn") {
|
|
386
|
+
nextVal = getNextFlashAttn(edit.buffer, dir);
|
|
387
|
+
}
|
|
388
|
+
else if (edit.jsonName === "speculativeMode") {
|
|
389
|
+
nextVal = getNextSpeculativeMode(edit.buffer, dir);
|
|
390
|
+
}
|
|
391
|
+
else if (edit.jsonName === "reasoningEffort") {
|
|
392
|
+
const options = entry.reasoningEffort?.enum ?? ["xhigh", "medium", "low"];
|
|
393
|
+
const idx = options.indexOf(edit.buffer);
|
|
394
|
+
if (idx < 0) {
|
|
395
|
+
nextVal = dir === "left" ? options[options.length - 1] : options[0];
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
nextVal = dir === "left" ? options[Math.max(0, idx - 1)] : options[Math.min(options.length - 1, idx + 1)];
|
|
399
|
+
}
|
|
400
|
+
}
|
|
236
401
|
if (nextVal !== undefined) {
|
|
237
|
-
setEdit(e => e ? { ...e, buffer: String(nextVal) } : e);
|
|
402
|
+
setEdit(e => (e ? { ...e, buffer: String(nextVal) } : e));
|
|
238
403
|
return;
|
|
239
404
|
}
|
|
240
405
|
}
|
|
241
406
|
if (key.backspace || key.delete) {
|
|
242
|
-
setEdit(e => e ? { ...e, buffer: e.buffer.slice(0, -1) } : e);
|
|
407
|
+
setEdit(e => (e ? { ...e, buffer: e.buffer.slice(0, -1) } : e));
|
|
243
408
|
return;
|
|
244
409
|
}
|
|
245
|
-
const spec =
|
|
410
|
+
const spec = allKeys.find(k => k.jsonName === edit.jsonName);
|
|
246
411
|
const isStringField = spec?.type === "string";
|
|
247
412
|
if (input) {
|
|
248
413
|
const allowed = isStringField ? /^[a-zA-Z0-9_\-./:]$/ : /^[0-9.-]$/;
|
|
249
414
|
if (allowed.test(input)) {
|
|
250
|
-
setEdit(e => e ? { ...e, buffer: e.buffer + input } : e);
|
|
415
|
+
setEdit(e => (e ? { ...e, buffer: e.buffer + input } : e));
|
|
251
416
|
}
|
|
252
417
|
}
|
|
253
418
|
return;
|
|
@@ -256,83 +421,195 @@ export const PresetEditor = ({ entryId, width = 88, onClose }) => {
|
|
|
256
421
|
onClose(notice);
|
|
257
422
|
return;
|
|
258
423
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
424
|
+
// Up / Down navigation
|
|
425
|
+
if (key.downArrow) {
|
|
426
|
+
setCursor(c => Math.min(totalItems - 1, c + 1));
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if (key.upArrow) {
|
|
262
430
|
setCursor(c => Math.max(0, c - 1));
|
|
263
|
-
|
|
264
|
-
const spec = keys[cursor];
|
|
265
|
-
if (spec) {
|
|
266
|
-
const existing = presetValueFor(entry, spec.jsonName);
|
|
267
|
-
const start = existing !== undefined ? String(existing) : String(effective[spec.jsonName] ?? "");
|
|
268
|
-
setEdit({ jsonName: spec.jsonName, buffer: start });
|
|
269
|
-
}
|
|
431
|
+
return;
|
|
270
432
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
433
|
+
// SIMPLE MODE: Left/Right directly cycles compound options
|
|
434
|
+
if (mode === "simple") {
|
|
435
|
+
const knob = compoundKnobs[cursor];
|
|
436
|
+
if (knob && (key.leftArrow || key.rightArrow)) {
|
|
437
|
+
const dir = key.leftArrow ? "left" : "right";
|
|
438
|
+
const currentVal = compoundState[knob.id];
|
|
439
|
+
const optKeys = knob.options.map(o => o.key);
|
|
440
|
+
const curIdx = optKeys.indexOf(currentVal ?? "");
|
|
441
|
+
let nextIdx = 0;
|
|
442
|
+
if (curIdx >= 0) {
|
|
443
|
+
nextIdx = dir === "left" ? Math.max(0, curIdx - 1) : Math.min(optKeys.length - 1, curIdx + 1);
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
nextIdx = dir === "left" ? 0 : optKeys.length - 1;
|
|
447
|
+
}
|
|
448
|
+
const nextOption = knob.options[nextIdx];
|
|
449
|
+
if (nextOption) {
|
|
450
|
+
const updated = applyCompoundSelection(entry, knob.id, nextOption.key);
|
|
451
|
+
persistPreset(updated, `${knob.label} → ${nextOption.label}`);
|
|
452
|
+
}
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (key.return && knob) {
|
|
456
|
+
// Open edit buffer for custom input on context or GPU
|
|
457
|
+
if (knob.id === "contextWindow") {
|
|
458
|
+
const field = entry.runtime === "mlx" ? "contextWindow" : "ctxSize";
|
|
459
|
+
setEdit({ jsonName: field, buffer: String(effective[field] ?? "") });
|
|
460
|
+
}
|
|
461
|
+
else if (knob.id === "gpuOffload") {
|
|
462
|
+
setEdit({ jsonName: "nGpuLayers", buffer: String(effective.nGpuLayers ?? "") });
|
|
463
|
+
}
|
|
274
464
|
return;
|
|
275
|
-
try {
|
|
276
|
-
const preset = unsetPresetFields(entry, [spec.jsonName]);
|
|
277
|
-
persistPreset(preset, `unset ${spec.jsonName}`);
|
|
278
465
|
}
|
|
279
|
-
|
|
280
|
-
|
|
466
|
+
}
|
|
467
|
+
// ADVANCED MODE: Enter opens buffer
|
|
468
|
+
if (mode === "advanced") {
|
|
469
|
+
if (cursor < allKeys.length) {
|
|
470
|
+
const spec = allKeys[cursor];
|
|
471
|
+
if (spec && key.return) {
|
|
472
|
+
const existing = presetValueFor(entry, spec.jsonName);
|
|
473
|
+
const start = existing !== undefined ? String(existing) : String(effective[spec.jsonName] ?? "");
|
|
474
|
+
setEdit({ jsonName: spec.jsonName, buffer: start });
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
// Dedicated hotkeys
|
|
480
|
+
if (input === "s") {
|
|
481
|
+
const matching = findMatchingFormula(entry, recipesList);
|
|
482
|
+
const initialName = activeRecipeName ||
|
|
483
|
+
matching?.name ||
|
|
484
|
+
(recipesList.find(r => r.source === "user")?.name ?? `${entry.slug}-custom`);
|
|
485
|
+
const initialIdx = recipesList.findIndex(r => r.name === initialName);
|
|
486
|
+
setSavingRecipe({ buffer: initialName, cycleIndex: initialIdx >= 0 ? initialIdx : 0 });
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
if (input === "y") {
|
|
490
|
+
const textToCopy = formatPresetCopyText(entry, effective);
|
|
491
|
+
const ok = copyToClipboard(textToCopy);
|
|
492
|
+
if (ok) {
|
|
493
|
+
setNotice("✓ copied configuration & command to clipboard!");
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
setNotice("error: unable to access system clipboard");
|
|
497
|
+
}
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
// Two-tap confirm for 'c' (clear formula)
|
|
501
|
+
if (input === "c") {
|
|
502
|
+
if (clearConfirmPending) {
|
|
503
|
+
persistPreset(undefined, "formula cleared");
|
|
504
|
+
setActiveRecipeName(null);
|
|
505
|
+
setClearConfirmPending(false);
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
setClearConfirmPending(true);
|
|
509
|
+
setNotice("⚠ press 'c' again within 3s to confirm clearing formula");
|
|
281
510
|
}
|
|
511
|
+
return;
|
|
282
512
|
}
|
|
283
|
-
|
|
284
|
-
|
|
513
|
+
if (input === "d") {
|
|
514
|
+
const customFormulas = recipesList.filter(r => r.source === "user");
|
|
515
|
+
const targetName = activeRecipeName || customFormulas[0]?.name;
|
|
516
|
+
if (targetName && deleteUserFormula(targetName)) {
|
|
517
|
+
setRecipesList(listFormulas());
|
|
518
|
+
setActiveRecipeName(null);
|
|
519
|
+
setNotice(`✓ formula "${targetName}" deleted`);
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
setNotice("error: no custom formula found to delete");
|
|
523
|
+
}
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
// Any other key resets clear confirmation
|
|
527
|
+
if (clearConfirmPending) {
|
|
528
|
+
setClearConfirmPending(false);
|
|
529
|
+
}
|
|
530
|
+
if (input === "u") {
|
|
531
|
+
if (mode === "advanced" && cursor < allKeys.length) {
|
|
532
|
+
const spec = allKeys[cursor];
|
|
533
|
+
if (!spec)
|
|
534
|
+
return;
|
|
535
|
+
try {
|
|
536
|
+
const formula = unsetFormulaFields(entry, [spec.jsonName]);
|
|
537
|
+
persistPreset(formula, `unset ${spec.jsonName}`);
|
|
538
|
+
}
|
|
539
|
+
catch (err) {
|
|
540
|
+
setNotice(`error: ${errMsg(err)}`);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
else if (mode === "simple") {
|
|
544
|
+
const knob = compoundKnobs[cursor];
|
|
545
|
+
if (knob?.id === "kvCache") {
|
|
546
|
+
const formula = unsetFormulaFields(entry, ["cacheTypeK", "cacheTypeV"]);
|
|
547
|
+
persistPreset(formula, "reset KV cache to defaults");
|
|
548
|
+
}
|
|
549
|
+
else if (knob?.id === "speculative") {
|
|
550
|
+
const formula = unsetFormulaFields(entry, ["speculativeMode", "specType", "specDraftNgl", "specDraftModel"]);
|
|
551
|
+
persistPreset(formula, "reset speculative decoding to defaults");
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return;
|
|
285
555
|
}
|
|
286
|
-
|
|
287
|
-
// Toggle MLX flavor (lm <-> vlm). Mirrors cmdFlavor: warn when
|
|
288
|
-
// flipping to vlm on a model that has no detected vision tower,
|
|
289
|
-
// and append a restart hint when the model is currently running
|
|
290
|
-
// since the change only takes effect on a fresh spawn.
|
|
556
|
+
if (input === "v" && entry.runtime === "mlx") {
|
|
291
557
|
const next = entry.mlxFlavor === "vlm" ? "lm" : "vlm";
|
|
292
558
|
const noVlmCap = !(entry.mlxCapabilities ?? []).includes("vlm");
|
|
293
559
|
const running = supervisor.list().some(i => i.id === entry.id);
|
|
294
|
-
const warn = next === "vlm" && noVlmCap
|
|
295
|
-
? " · ⚠ no vision tower detected, mlx_vlm.server may fail to load" : "";
|
|
560
|
+
const warn = next === "vlm" && noVlmCap ? " · ⚠ no vision tower detected, mlx_vlm.server may fail to load" : "";
|
|
296
561
|
const restart = running ? " · restart to apply" : "";
|
|
297
562
|
persistFlavor(next, `flavor → mlx-${next}${warn}${restart}`);
|
|
563
|
+
return;
|
|
298
564
|
}
|
|
299
|
-
|
|
565
|
+
// Number hotkeys 1-7 apply formulas immediately
|
|
566
|
+
if (input && /^[1-7]$/.test(input)) {
|
|
300
567
|
const idx = Number(input) - 1;
|
|
301
|
-
const r =
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
568
|
+
const r = recipesList[idx];
|
|
569
|
+
if (r) {
|
|
570
|
+
const formula = formulaToRuntime(r, entry.runtime);
|
|
571
|
+
persistPreset(formula, `formula: ${r.name}`);
|
|
572
|
+
setActiveRecipeName(r.name);
|
|
573
|
+
}
|
|
306
574
|
}
|
|
307
575
|
});
|
|
308
576
|
if (!entry) {
|
|
309
577
|
return (_jsx(Box, { width: width, flexDirection: "column", borderStyle: "round", borderColor: "red", padding: 1, backgroundColor: "black", children: _jsx(Text, { color: "red", backgroundColor: "black", children: "model not found" }) }));
|
|
310
578
|
}
|
|
311
|
-
// For MLX entries, surface the active server explicitly (lm vs vlm)
|
|
312
579
|
const isMlx = entry.runtime === "mlx";
|
|
313
580
|
const isVlm = isMlx && entry.mlxFlavor === "vlm";
|
|
314
581
|
const hasVlmCap = isMlx && (entry.mlxCapabilities ?? []).includes("vlm");
|
|
315
582
|
const runtimeLabel = isMlx ? `mlx-${entry.mlxFlavor ?? "lm"}` : entry.runtime;
|
|
316
|
-
const _innerWidth = Math.max(24, width - 4);
|
|
317
583
|
const keyColWidth = 22;
|
|
584
|
+
// Advanced mode scrolling
|
|
318
585
|
const MAX_VISIBLE_KEYS = 8;
|
|
319
|
-
const
|
|
320
|
-
const
|
|
321
|
-
const
|
|
586
|
+
const activeKeyCursor = Math.min(cursor, allKeys.length - 1);
|
|
587
|
+
const windowStart = Math.max(0, Math.min(activeKeyCursor - Math.floor(MAX_VISIBLE_KEYS / 2), allKeys.length - MAX_VISIBLE_KEYS));
|
|
588
|
+
const windowEnd = Math.min(allKeys.length, windowStart + MAX_VISIBLE_KEYS);
|
|
589
|
+
const visibleKeys = allKeys.slice(windowStart, windowEnd);
|
|
322
590
|
const countAbove = windowStart;
|
|
323
|
-
const countBelow =
|
|
324
|
-
return (_jsxs(Box, { width: width, flexDirection: "column", borderStyle: "round", borderColor: "cyan", padding: 1, backgroundColor: "black", children: [
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
591
|
+
const countBelow = allKeys.length - windowEnd;
|
|
592
|
+
return (_jsxs(Box, { width: width, flexDirection: "column", borderStyle: "round", borderColor: "cyan", padding: 1, backgroundColor: "black", children: [_jsxs(Box, { justifyContent: "space-between", children: [_jsxs(Text, { bold: true, color: "cyan", backgroundColor: "black", children: ["Formula editor ", mode === "advanced" ? "[ADVANCED]" : "[SIMPLE]"] }), _jsxs(Text, { dimColor: true, backgroundColor: "black", children: ["[Tab] ", mode === "simple" ? "Switch to Advanced" : "Switch to Simple"] })] }), _jsxs(Text, { wrap: "truncate-end", backgroundColor: "black", children: [_jsxs(Text, { backgroundColor: "black", children: [entry.slug, " "] }), _jsxs(Text, { dimColor: true, backgroundColor: "black", children: ["(", runtimeLabel, ")"] })] }), isMlx && hasVlmCap && !isVlm ? (_jsxs(Text, { dimColor: true, wrap: "truncate-end", backgroundColor: "black", children: ["vision tower detected \u2014 press", " ", _jsx(Text, { bold: true, color: "cyan", backgroundColor: "black", children: "v" }), " ", "to switch to mlx-vlm"] })) : null, _jsx(Text, { backgroundColor: "black", children: " " }), mode === "simple" ? (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { dimColor: true, backgroundColor: "black", children: "Smart controls (\u25C0 / \u25B6 to cycle, \u23CE to edit custom value)" }), _jsx(Text, { backgroundColor: "black", children: " " }), compoundKnobs.map((knob, idx) => {
|
|
593
|
+
const active = idx === cursor;
|
|
594
|
+
const currentKey = compoundState[knob.id];
|
|
595
|
+
return (_jsxs(Box, { flexDirection: "row", marginBottom: 0, children: [_jsxs(Text, { color: active ? "cyan" : undefined, backgroundColor: "black", children: [active ? "▸" : " ", " ", _jsx(Text, { bold: active, children: knob.label.padEnd(16) })] }), _jsx(Text, { backgroundColor: "black", children: " \u25C0 " }), knob.options.map((opt, optIdx) => {
|
|
596
|
+
const isSelected = currentKey === opt.key;
|
|
597
|
+
return (_jsxs(Text, { backgroundColor: "black", children: [optIdx > 0 ? " · " : "", isSelected ? (_jsxs(Text, { bold: true, color: "cyan", backgroundColor: "black", children: ["[", opt.label, "]"] })) : (_jsx(Text, { dimColor: true, backgroundColor: "black", children: opt.label }))] }, opt.key));
|
|
598
|
+
}), currentKey === "custom" ? (_jsxs(Text, { color: "yellow", backgroundColor: "black", children: [" ", "\u00B7 [custom]"] })) : null, _jsx(Text, { backgroundColor: "black", children: " \u25B6" })] }, knob.id));
|
|
599
|
+
})] })) : (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { dimColor: true, backgroundColor: "black", children: ["Tunable keys (override marked with *)", allKeys.length > MAX_VISIBLE_KEYS ? ` · showing ${windowStart + 1}-${windowEnd} of ${allKeys.length}` : ""] }), countAbove > 0 ? (_jsxs(Text, { dimColor: true, backgroundColor: "black", children: [" ", "\u25B2 ", countAbove, " more above"] })) : null, visibleKeys.map((k, relIndex) => {
|
|
600
|
+
const i = windowStart + relIndex;
|
|
601
|
+
const override = presetValueFor(entry, k.jsonName);
|
|
602
|
+
const value = override !== undefined ? override : effective[k.jsonName];
|
|
603
|
+
const marker = override !== undefined ? "*" : " ";
|
|
604
|
+
const active = i === cursor;
|
|
605
|
+
const label = k.aliases[0].padEnd(Math.max(8, keyColWidth - 2));
|
|
606
|
+
// Check if this key starts a category
|
|
607
|
+
const matchingCat = categories.find(c => c.keys[0] === k.jsonName);
|
|
608
|
+
return (_jsxs(Box, { flexDirection: "column", children: [matchingCat ? (_jsxs(Text, { bold: true, color: "yellow", backgroundColor: "black", children: ["\u25BC ", matchingCat.name] })) : null, _jsxs(Text, { color: active ? "cyan" : undefined, backgroundColor: "black", wrap: "truncate-end", children: [active ? "▸" : " ", " ", label, " ", String(value).padStart(7), " ", marker, " ", _jsx(Text, { dimColor: true, backgroundColor: "black", children: k.help })] })] }, k.jsonName));
|
|
609
|
+
}), countBelow > 0 ? (_jsxs(Text, { dimColor: true, backgroundColor: "black", children: [" ", "\u25BC ", countBelow, " more below"] })) : null] })), _jsx(Text, { backgroundColor: "black", children: " " }), _jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: "gray", paddingX: 1, children: [_jsx(Text, { dimColor: true, backgroundColor: "black", children: "Formulas (1-7 to apply \u00B7 s to save custom \u00B7 d to delete):" }), _jsx(Text, { wrap: "truncate-end", backgroundColor: "black", children: recipesList.slice(0, 7).map((r, i) => (_jsxs(Text, { backgroundColor: "black", children: [i > 0 ? " " : "", _jsxs(Text, { bold: true, color: "cyan", backgroundColor: "black", children: [i + 1, "."] }), " ", _jsx(Text, { color: r.source === "user" ? "magenta" : undefined, backgroundColor: "black", children: r.name })] }, r.name))) })] }), _jsx(Text, { backgroundColor: "black", children: " " }), savingRecipe ? ((() => {
|
|
610
|
+
const target = recipesList.find(r => r.name === savingRecipe.buffer.trim());
|
|
611
|
+
const badge = target?.source === "user" ? (_jsxs(Text, { color: "magenta", backgroundColor: "black", children: [" ", "[updates user formula]"] })) : target?.source === "builtin" ? (_jsxs(Text, { color: "yellow", backgroundColor: "black", children: [" ", "[overrides builtin]"] })) : (_jsxs(Text, { color: "cyan", backgroundColor: "black", children: [" ", "[new formula]"] }));
|
|
612
|
+
return (_jsxs(Text, { wrap: "truncate-end", backgroundColor: "black", children: ["save formula as:", " ", _jsx(Text, { bold: true, color: "cyan", backgroundColor: "black", children: savingRecipe.buffer || "_" }), badge, " ", _jsx(Text, { dimColor: true, backgroundColor: "black", children: "(\u23CE save \u00B7 \u2191\u2193 cycle names \u00B7 tab complete \u00B7 esc cancel)" })] }));
|
|
613
|
+
})()) : edit ? (_jsxs(Text, { wrap: "truncate-end", backgroundColor: "black", children: ["editing ", _jsx(Text, { bold: true, backgroundColor: "black", children: edit.jsonName }), " = ", _jsx(Text, { color: "cyan", backgroundColor: "black", children: edit.buffer || "_" }), " ", _jsxs(Text, { dimColor: true, backgroundColor: "black", children: ["(\u23CE save \u00B7 esc cancel", CYCLABLE_KEYS.includes(edit.jsonName) ? " · ◀/▶ cycle" : "", ")"] })] })) : (_jsxs(Text, { dimColor: true, wrap: "truncate-end", backgroundColor: "black", children: [mode === "simple" ? "↑↓ select · ◀/▶ cycle · ⏎ custom" : "↑↓ nav · ⏎ edit · u unset", " \u00B7 Tab ", mode === "simple" ? "advanced" : "simple", " \u00B7 1-7 formula \u00B7 s save \u00B7 y copy \u00B7 c clear \u00B7 esc close"] })), notice ? (_jsx(Text, { color: notice.startsWith("⚠") ? "yellow" : notice.startsWith("✓") ? "green" : "yellow", wrap: "truncate-end", backgroundColor: "black", children: notice })) : null] }));
|
|
337
614
|
};
|
|
338
615
|
//# sourceMappingURL=PresetEditor.js.map
|