heartcode 0.1.57 → 0.1.59
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 +46 -0
- package/README.md +17 -7
- package/SKILL.md +58 -17
- package/bin/heart.js +1 -1
- package/bin/heartcode.js +47 -24
- package/package.json +1 -1
- package/prompts/agent.md +24 -13
- package/src/agent.js +71 -29
- package/src/client.js +12 -3
- package/src/config.js +14 -2
- package/src/guided.js +26 -17
- package/src/headless.js +61 -14
- package/src/log.js +1 -1
- package/src/rankings.js +4 -3
- package/src/settings.html +218 -14
- package/src/settings.js +78 -3
- package/src/tabs.js +4 -1
- package/src/tools.js +41 -26
- package/src/ui.js +104 -20
package/src/rankings.js
CHANGED
|
@@ -8,11 +8,12 @@ import { readParquet } from './parquet.js'
|
|
|
8
8
|
|
|
9
9
|
const FILE = path.join(HOME, 'rankings.json')
|
|
10
10
|
const WEEK = 7 * 24 * 3600_000
|
|
11
|
-
const VERSION =
|
|
11
|
+
const VERSION = 3 // 2: with each model's score; 3: with the agent ranking and hard prompts; an older file is fetched again
|
|
12
12
|
const FILES = 'https://huggingface.co/datasets/lmarena-ai/leaderboard-dataset/resolve/main' // one Parquet file per ranking: text, webdev, vision, agent
|
|
13
13
|
|
|
14
|
-
// The lists kept (ranking:category): shown on Your models
|
|
15
|
-
|
|
14
|
+
// The lists kept (ranking:category): shown on Your models; the helpers picked for you go by them too
|
|
15
|
+
// (agent: long real tasks, done by the model with tools; hard prompts: the hardest questions)
|
|
16
|
+
const LISTS = ['text:overall', 'text:coding', 'text:hard_prompts', 'webdev:webdev', 'vision:overall', 'agent:overall']
|
|
16
17
|
|
|
17
18
|
export const loadRankings = () => readJson(FILE, null)
|
|
18
19
|
|
package/src/settings.html
CHANGED
|
@@ -307,6 +307,7 @@
|
|
|
307
307
|
.prov-h .by-name input { width: 190px; height: 28px; padding: 0 9px; font-size: 12px; font-family: var(--mono); background: transparent; }
|
|
308
308
|
.prov-h .by-name button, .prov-h > button.small { height: 28px; }
|
|
309
309
|
dialog#gone { width: min(560px, 92vw); }
|
|
310
|
+
dialog#h-test { width: min(560px, 92vw); }
|
|
310
311
|
dialog#gone h2 { color: var(--err); font-family: inherit; font-size: 18px; }
|
|
311
312
|
dialog#gone::backdrop { background: rgba(0, 0, 0, .75); }
|
|
312
313
|
.hello-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
|
|
@@ -427,7 +428,7 @@
|
|
|
427
428
|
.mt-more-pill button:hover:not(:disabled) { background: var(--hover); }
|
|
428
429
|
.mt-more-pill button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
|
|
429
430
|
.mt-more-pill button:disabled { color: var(--faint); cursor: default; }
|
|
430
|
-
.mt, .mt-h.mt-hpick { min-width:
|
|
431
|
+
.mt, .mt-h.mt-hpick { min-width: 1766px; } /* the columns below, their gaps and padding: the header, the selection bar and the rows line up (the rows are drawn a screenful at a time, so this can't come from them) */
|
|
431
432
|
.mt-h input[type=checkbox], .mtable input[type=checkbox] { width: 15px; height: 15px; margin: 0; accent-color: var(--brand); cursor: pointer; }
|
|
432
433
|
.mtable li.picked { background: var(--brand-soft); }
|
|
433
434
|
.mt-rules { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 24px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
|
|
@@ -449,9 +450,9 @@
|
|
|
449
450
|
.pill .again:hover:not(:disabled) { color: var(--text); }
|
|
450
451
|
.pill.on { border-color: var(--accent); background: var(--accent-soft); }
|
|
451
452
|
.pill.on .again { border-left-color: color-mix(in srgb, var(--accent) 40%, transparent); }
|
|
452
|
-
.mt-h, .mtable li { display: grid; grid-template-columns: 14px 18px 40px minmax(200px, 1fr) 104px 62px 46px 66px 56px 76px 76px 76px 112px 86px 124px; /* the last: Test · Request · Edit · ✕, as wide as they are */ align-items: center; column-gap: 6px; padding: 8px 18px; }
|
|
453
|
+
.mt-h, .mtable li { display: grid; grid-template-columns: 14px 18px 40px minmax(200px, 1fr) 104px 450px 62px 46px 66px 56px 76px 76px 76px 112px 86px 124px; /* the last: Test · Request · Edit · ✕, as wide as they are */ align-items: center; column-gap: 6px; padding: 8px 18px; }
|
|
453
454
|
.mt-h button.mid, .mtable .mid { text-align: center; }
|
|
454
|
-
.mt-h > :nth-child(
|
|
455
|
+
.mt-h > :nth-child(15), .mtable .try { padding-left: 12px; } /* Works?: a little room after the right-aligned price */
|
|
455
456
|
.mtable li .acts { justify-content: flex-start; }
|
|
456
457
|
.mt-h { border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 500; color: var(--faint); padding-top: 10px; padding-bottom: 10px; background: var(--panel2); }
|
|
457
458
|
.mt-h button { display: inline; border: 0; background: none !important; padding: 0; font: inherit; color: inherit; text-align: left; white-space: nowrap; transform: none !important; }
|
|
@@ -473,6 +474,28 @@
|
|
|
473
474
|
.mtable .m { font-family: var(--mono); font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
474
475
|
.mtable .p { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
475
476
|
.mtable .yes { color: var(--ok); }
|
|
477
|
+
/* Helper: a switch (can #1 start it for side jobs?), then what it's good at, as pills */
|
|
478
|
+
.hp { display: flex; align-items: center; gap: 4px; min-width: 0; }
|
|
479
|
+
.hp > span:first-child { display: inline-flex; }
|
|
480
|
+
.hp .sw { display: inline-block; width: 30px; height: 18px; margin: 0 4px 0 0; }
|
|
481
|
+
.hp .sw i::after { width: 12px; height: 12px; }
|
|
482
|
+
.hp .sw input:checked + i::after { transform: translateX(12px); }
|
|
483
|
+
.mtable li .hp .jp { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; font-size: 11.5px; font-weight: 400; color: var(--faint); white-space: nowrap; cursor: pointer; transition: background .15s, color .15s, border-color .15s, transform .1s; }
|
|
484
|
+
.mtable li .hp .jp:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
|
|
485
|
+
.mtable li .hp .jp:active:not(:disabled) { transform: scale(.95); }
|
|
486
|
+
.mtable li .hp .jp:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
|
|
487
|
+
.mtable li .hp .jp.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text); font-weight: 500; }
|
|
488
|
+
.mtable li .hp .jp.on::before { content: '✓'; color: var(--accent); font-weight: 700; }
|
|
489
|
+
.mtable li .hp .jp.sug { border-style: dashed; border-color: var(--accent); color: var(--accent); }
|
|
490
|
+
.mtable li .hp .jp.sug::before { content: '+'; font-weight: 700; }
|
|
491
|
+
.mtable li .hp.off .jp:not(.sug) { opacity: .6; }
|
|
492
|
+
/* the helper suggestions, waiting for a yes: beside the list's buttons */
|
|
493
|
+
.hsug { display: inline-flex; align-items: center; gap: 6px; padding: 2px 3px 2px 10px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); color: var(--text); white-space: nowrap; }
|
|
494
|
+
.hsug .ic { color: var(--accent); }
|
|
495
|
+
.hbar { display: contents; }
|
|
496
|
+
.mtable li .hp .jp.saving, .hp .saving .sw { opacity: .55; animation: hp-pulse .9s ease-in-out infinite alternate; pointer-events: none; } /* its save on its way */
|
|
497
|
+
@keyframes hp-pulse { to { opacity: .25; } }
|
|
498
|
+
@media (prefers-reduced-motion: reduce) { .mtable li .hp .jp.saving, .hp .saving .sw { animation: none; } }
|
|
476
499
|
.mtable .no { color: var(--faint); }
|
|
477
500
|
.mtable .src { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
|
|
478
501
|
.mtable .src.warn { color: var(--warn); }
|
|
@@ -541,6 +564,10 @@
|
|
|
541
564
|
button.sorting::after { content: ''; display: inline-block; width: 9px; height: 9px; margin-left: 6px; vertical-align: -1px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; }
|
|
542
565
|
/* Your models: the header's buttons, the list's settings, the toolbar (sticky), the table */
|
|
543
566
|
.mt-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
567
|
+
.h-order { display: inline-flex; align-items: center; gap: 8px; margin-right: 4px; }
|
|
568
|
+
.h-order .mt-setl { white-space: nowrap; }
|
|
569
|
+
.mt-actions .seg { height: 32px; }
|
|
570
|
+
.mt-actions .seg label { padding: 0 11px; font-size: 12.5px; }
|
|
544
571
|
.mt-sets { display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: 12px 18px 4px; } /* with the filters below: one toolbar, 8px between its two lines */
|
|
545
572
|
.mt-mode-sets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
|
|
546
573
|
.mt-set { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
|
@@ -644,6 +671,8 @@
|
|
|
644
671
|
#tip dt { color: var(--faint); }
|
|
645
672
|
#tip dd { margin: 0; }
|
|
646
673
|
#tip .tdesc { color: var(--muted); margin-top: 10px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
|
|
674
|
+
#tip .tjob { font-weight: 650; font-size: 13.5px; }
|
|
675
|
+
#tip .tcover { color: var(--muted); margin-top: 6px; line-height: 1.5; }
|
|
647
676
|
#tip .thint { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--accent); font-weight: 600; }
|
|
648
677
|
#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 8px); padding: 10px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 500; box-shadow: var(--shadow-pop); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px); z-index: 10; }
|
|
649
678
|
#toast.show { opacity: 1; transform: translate(-50%, 0); }
|
|
@@ -937,7 +966,7 @@
|
|
|
937
966
|
<select id="g-effort"></select>
|
|
938
967
|
</div>
|
|
939
968
|
<div class="setting">
|
|
940
|
-
<label class="t" for="g-context"><b>Context window</b><span>How many tokens the model can hold. Leave it on auto unless HeartCode gets it wrong.</span></label>
|
|
969
|
+
<label class="t" for="g-context"><b>Context window</b><span>How many tokens the model can hold. Leave it on auto unless HeartCode gets it wrong: a number here is used for every model, over each model's own.</span></label>
|
|
941
970
|
<input type="number" id="g-context" min="1" placeholder="Auto">
|
|
942
971
|
</div>
|
|
943
972
|
</div>
|
|
@@ -1094,6 +1123,12 @@
|
|
|
1094
1123
|
<div id="imp-list" class="imp-list"></div>
|
|
1095
1124
|
<div class="actions"><span class="spacer"></span><button id="imp-cancel" type="button">Cancel</button><button class="primary" id="imp-go" type="button">Import selected</button></div>
|
|
1096
1125
|
</dialog>
|
|
1126
|
+
<dialog id="h-test" aria-labelledby="h-test-title">
|
|
1127
|
+
<h2 id="h-test-title">Test your models first</h2>
|
|
1128
|
+
<p class="sub">Helpers are picked from the models that answer a short test. None of yours has answered one yet.</p>
|
|
1129
|
+
<p class="sub" id="h-test-cost"></p>
|
|
1130
|
+
<div class="actions"><span class="spacer"></span><button id="h-test-no" type="button" class="ghost">Cancel</button><button id="h-test-go" type="button" class="primary">Test all, then pick</button></div>
|
|
1131
|
+
</dialog>
|
|
1097
1132
|
<dialog id="gone" aria-labelledby="gone-title">
|
|
1098
1133
|
<h2 id="gone-title">Disconnected</h2>
|
|
1099
1134
|
<p class="sub">HeartCode's settings page was turned off, so nothing here can be changed or saved now.</p>
|
|
@@ -1761,6 +1796,7 @@ async function tryAll(only) {
|
|
|
1761
1796
|
const { run } = await api('/api/tests/start', only ? { only: only.map(({ provider, model }) => ({ provider, model })) } : {})
|
|
1762
1797
|
showRun(run)
|
|
1763
1798
|
} catch (e) {
|
|
1799
|
+
afterTests = null // no run: nothing to do after it
|
|
1764
1800
|
toast(e.message, true)
|
|
1765
1801
|
}
|
|
1766
1802
|
}
|
|
@@ -1779,6 +1815,12 @@ function showRun(run) {
|
|
|
1779
1815
|
if (!testingAll) {
|
|
1780
1816
|
for (const [key, r] of Object.entries(TRIES)) if (r.going) r.before ? (TRIES[key] = r.before) : delete TRIES[key] // stopped before it: as it was
|
|
1781
1817
|
job('test-all')
|
|
1818
|
+
if (run?.over && afterTests) {
|
|
1819
|
+
const then = afterTests
|
|
1820
|
+
afterTests = null
|
|
1821
|
+
if (then === 'suggest') suggestNow()
|
|
1822
|
+
else setAuto(true, $('h-auto'))
|
|
1823
|
+
} else if (!run?.over) afterTests = null // never started
|
|
1782
1824
|
if (run?.over) toast(`${run.stopping ? `stopped after ${run.done} of ${run.total}: ` : ''}${run.good} of ${run.done} work${run.good === run.done ? '' : `; ${run.done - run.good} don't (Works? says why, on hover)`}`, run.good < run.done)
|
|
1783
1825
|
} else
|
|
1784
1826
|
job('test-all', {
|
|
@@ -1963,7 +2005,7 @@ function sortable(v, onMove) {
|
|
|
1963
2005
|
const scrolled = () => (scroller === window ? scrollY : scroller.scrollTop)
|
|
1964
2006
|
box.addEventListener('pointerdown', (e) => {
|
|
1965
2007
|
const li = e.target.closest('li.in')
|
|
1966
|
-
if (!li || e.button !== 0 || e.target.closest('button, a, input, select, textarea') || !box.classList.contains('drag')) return
|
|
2008
|
+
if (!li || e.button !== 0 || e.target.closest('button, a, input, select, textarea, .hp') || !box.classList.contains('drag')) return
|
|
1967
2009
|
if (e.pointerType !== 'mouse' && !e.target.closest('.grip')) return // a finger scrolls the list, except on the grip
|
|
1968
2010
|
const n = v.items
|
|
1969
2011
|
const from = Number(li.dataset.i)
|
|
@@ -2351,6 +2393,7 @@ $('pr-save').onclick = () => {
|
|
|
2351
2393
|
RANK = [...list, ...RANK.filter((n) => !list.includes(n))] // providers not in your list now keep their place for later
|
|
2352
2394
|
savePref('rank', RANK)
|
|
2353
2395
|
$('pr').close()
|
|
2396
|
+
if (S.helperOrder === 'provider') api('/api/helper-order', { by: 'provider', rank: RANK }).catch((e) => toast(e.message, true)) // helpers by the new ranking
|
|
2354
2397
|
setSort(SORT.some((x) => x.key === 'provider') ? SORT : [{ key: 'provider', dir: 'down' }, ...SORT]) // sorted by it now
|
|
2355
2398
|
}
|
|
2356
2399
|
const firstDir = (key) => COLS[key].first // up: A to Z, low to high
|
|
@@ -2391,9 +2434,9 @@ function sorted(order) {
|
|
|
2391
2434
|
}
|
|
2392
2435
|
const dirText = (key, dir) => COLS[key].words[dir === 'up' ? 0 : 1] + (key === 'works' ? ' (then not tested, then not working)' : '')
|
|
2393
2436
|
// Filters on the Your models page: which models are shown (and tested by "Test N shown", counted,
|
|
2394
|
-
// sorted, selected by "select all", saved first by Save
|
|
2437
|
+
// sorted, selected by "select all", saved first by Save list). Combined: a model shows when it passes
|
|
2395
2438
|
// all of them. Kept with the page's choices.
|
|
2396
|
-
const NO_FILTER = { text: '', provider: '', works: '', context: 0, tools: false, thinking: false, images: false, free: false }
|
|
2439
|
+
const NO_FILTER = { text: '', provider: '', works: '', context: 0, tools: false, thinking: false, images: false, free: false, helpers: false }
|
|
2397
2440
|
let FILTER = { ...NO_FILTER }
|
|
2398
2441
|
let filtersLoaded = false
|
|
2399
2442
|
const filtering = () => Object.keys(NO_FILTER).some((k) => FILTER[k] !== NO_FILTER[k])
|
|
@@ -2413,6 +2456,7 @@ function passes(t, skip) {
|
|
|
2413
2456
|
const c = can(t)
|
|
2414
2457
|
if ((f.tools && !c.tools) || (f.thinking && !c.thinking) || (f.images && !c.images)) return false
|
|
2415
2458
|
if (f.free && !(t.price?.input === 0 && t.price?.output === 0)) return false
|
|
2459
|
+
if (f.helpers && !helpers()[keyOf(t)] && !HSUG?.[keyOf(t)]) return false // and the ones suggested, while they are
|
|
2416
2460
|
return true
|
|
2417
2461
|
}
|
|
2418
2462
|
const setFilter = (change) => {
|
|
@@ -2446,7 +2490,8 @@ function filterBarOf(order, counts = {}) {
|
|
|
2446
2490
|
toggle('tools', 'Tools', 'only models that call tools'),
|
|
2447
2491
|
toggle('thinking', 'Thinking', 'only models that think'),
|
|
2448
2492
|
toggle('images', 'Images', 'only models that see images'),
|
|
2449
|
-
toggle('free', 'Free', 'only models that cost nothing, in and out')
|
|
2493
|
+
toggle('free', 'Free', 'only models that cost nothing, in and out'),
|
|
2494
|
+
toggle('helpers', 'Helpers', 'only your helpers (the models #1 can start for side jobs), and the ones suggested')))
|
|
2450
2495
|
}
|
|
2451
2496
|
const bar = filterBar
|
|
2452
2497
|
const focused = (el) => document.activeElement === el
|
|
@@ -2503,7 +2548,7 @@ function drawMine(s) {
|
|
|
2503
2548
|
slots.forEach((k, m) => (all[k] = list[m]))
|
|
2504
2549
|
return keep(all, true)
|
|
2505
2550
|
}
|
|
2506
|
-
// Save
|
|
2551
|
+
// Save list: the models HeartCode uses become the ones shown, in the order shown. Filtered: only
|
|
2507
2552
|
// those (asked first; the others stay under Providers, to add back any time)
|
|
2508
2553
|
const saveList = () => {
|
|
2509
2554
|
if (filtered && !confirm(`HeartCode will use only these ${n(view.length)}, in this order.\n\nThe other ${n(order.length - view.length)} stay under Providers: add any back whenever you like.`)) return
|
|
@@ -2522,7 +2567,15 @@ function drawMine(s) {
|
|
|
2522
2567
|
$('mt-lead').textContent = 'The models HeartCode uses, in your order: #1 answers, the next one when it fails.'
|
|
2523
2568
|
const busy = locked()
|
|
2524
2569
|
$('mt-actions').inert = busy
|
|
2570
|
+
// the order helpers are picked in when #1 starts them: your list's, or your provider ranking's
|
|
2571
|
+
const helperOrder = (by) => api('/api/helper-order', { by, rank: RANK }).then((r) => ((S.helperOrder = r.helperOrder), drawMine(S)), (e) => toast(e.message, true))
|
|
2572
|
+
const orderBy = h('span', { className: 'h-order' }, h('span', { className: 'mt-setl', textContent: 'Helpers picked' }),
|
|
2573
|
+
h('div', { className: 'seg', role: 'radiogroup', 'aria-label': 'The order helpers are picked in' },
|
|
2574
|
+
[['own', 'in your order', 'when #1 starts helpers, it picks from them in your list\'s order (the first one that fits the job)'], ['provider', 'by provider', 'when #1 starts helpers, it picks from them by your provider ranking (Order providers), each provider\'s in your list\'s order. Your list itself stays as it is']].map(([v, t, about]) =>
|
|
2575
|
+
h('label', { className: (S.helperOrder ?? 'own') === v ? 'on' : '', title: about },
|
|
2576
|
+
h('input', { type: 'radio', name: 'helper-order', checked: (S.helperOrder ?? 'own') === v, onchange: () => helperOrder(v) }), t))))
|
|
2525
2577
|
put($('mt-actions'),
|
|
2578
|
+
order.some((t) => t.provider !== order[0]?.provider) ? orderBy : null, // one provider: nothing to order by
|
|
2526
2579
|
((why) => h('span', { title: why ?? '' }, h('button', { className: 'small', textContent: 'Order providers', disabled: Boolean(why), title: why ? '' : 'drag your providers into order; the Provider column sorts by it', onclick: openRanking })))( // disabled: why, on a span (a disabled button shows no tooltip in every browser)
|
|
2527
2580
|
!order.some((t) => t.provider !== order[0]?.provider) ? 'All your models are from one provider: nothing to order' : null),
|
|
2528
2581
|
h('button', { className: 'small', textContent: 'Update model info', disabled: !order.length, title: `what each model can do (context, tools, thinking, images, price) from models.dev, and its places in LMArena's public rankings (coding, web apps, vision${S.rankings ? `; rankings from ${new Date(S.rankings.fetched).toLocaleDateString()}` : ''})`, onclick: () => lookUp() }))
|
|
@@ -2541,11 +2594,11 @@ function drawMine(s) {
|
|
|
2541
2594
|
const secsCell = (label, name, about, unit, said) => cell(label, about, num(name, label, said), h('span', { className: 'unit', textContent: unit }))
|
|
2542
2595
|
const settings = h('div', { className: 'mt-sets', inert: busy },
|
|
2543
2596
|
h('div', { className: 'mt-mode-sets' },
|
|
2544
|
-
cell('If one fails', ro.on === 'retries' ? 'a rate limit or outage: that model
|
|
2597
|
+
cell('If one fails', ro.on === 'retries' ? 'a rate limit or outage: that model gets that many tries in all before the next one; any other error moves on at once' : "any error moves on at once, to the next model (after an error from its provider: another provider's first)",
|
|
2545
2598
|
h('select', { onchange: (e) => saveOrder(S.order, 'saved', { on: e.target.value }) },
|
|
2546
2599
|
[['failure', 'go to the next'], ['retries', 'retry it first']].map(([v, t]) => h('option', { value: v, textContent: t, selected: ro.on === v }))),
|
|
2547
2600
|
ro.on === 'retries' ? h('input', { type: 'number', className: 'tries', 'aria-label': 'tries', title: 'tries of the same model first (rate limits, outages)', min: 1, max: 20, value: ro.retries, onchange: (e) => saveOrder(S.order, 'saved', { retries: Number(e.target.value) }) }) : null),
|
|
2548
|
-
secsCell('Give up after', 'replyStart', "a model that hasn't started answering (text, thinking or a tool call) in this many seconds counts as failed", 'sec', (v) => `a model that hasn't started answering in ${v}s counts as failed`),
|
|
2601
|
+
secsCell('Give up after', 'replyStart', "a model that hasn't started answering (text, thinking or a tool call) in this many seconds counts as failed (a streamed reply: a model set up without streaming waits for its whole reply)", 'sec', (v) => `a model that hasn't started answering in ${v}s counts as failed`),
|
|
2549
2602
|
secsCell('Stalled after', 'replyIdle', 'a reply that stops sending anything for this many seconds is stalled: tried again, or the next model', 'sec', (v) => `a reply silent for ${v}s counts as stalled`),
|
|
2550
2603
|
cell('Tests wait', 'how long a test waits for each answer',
|
|
2551
2604
|
h('input', { type: 'number', className: 'tries', min: 1, max: 600, step: 1, value: S.settings.testTimeout ?? 10, 'aria-label': 'Test timeout in seconds', onchange: (e) => {
|
|
@@ -2555,14 +2608,19 @@ function drawMine(s) {
|
|
|
2555
2608
|
} }), h('span', { className: 'unit', textContent: 'sec' })),
|
|
2556
2609
|
cell('New message to', 'the model a new message goes to first',
|
|
2557
2610
|
h('select', { onchange: (e) => saveOrder(S.order, 'saved', { next: e.target.value }) },
|
|
2558
|
-
[['first', '#1'], ['stay', 'the last that worked']].map(([v, t]) => h('option', { value: v, textContent: t, selected: ro.next === v }))))
|
|
2611
|
+
[['first', '#1'], ['stay', 'the last that worked']].map(([v, t]) => h('option', { value: v, textContent: t, selected: ro.next === v })))),
|
|
2612
|
+
cell('Helpers', 'who picks the helpers (the Helper column): HeartCode, from the models that answered their test and the rankings, again whenever those change; or you, with the pills',
|
|
2613
|
+
h('select', { id: 'h-auto', onchange: (e) => setAuto(e.target.value === 'auto', e.target) },
|
|
2614
|
+
[['auto', 'picked for you'], ['manual', 'you pick']].map(([v, t]) => h('option', { value: v, textContent: t, selected: (S.helpersAuto ? 'auto' : 'manual') === v }))))))
|
|
2559
2615
|
|
|
2560
2616
|
// --- beside the filters: what's shown · what you do with it (the sorts show in the column heads) ---
|
|
2561
2617
|
const line = h('div', { className: 'mt-line' },
|
|
2562
2618
|
h('span', { className: 'count', title: SORT.length ? `sorted by ${SORT.map(({ key, dir }) => `${COLS[key].label} ${COLS[key].words[dir === 'up' ? 0 : 1]}`).join(', then ')}; ties keep your order` : '' }, filtered ? [h('b', { textContent: n(shown.length) }), ` of ${n(order.length)}`] : [h('b', { textContent: n(order.length) }), ` model${order.length === 1 ? '' : 's'}`]),
|
|
2563
2619
|
filtering() || SORT.length ? h('button', { className: 'small ghost', textContent: 'Clear', title: 'every filter and the sort off: your whole list, in your order', onclick: clearView }) : null,
|
|
2620
|
+
order.length > 1 ? drawHelperBar() : null,
|
|
2564
2621
|
h('button', { className: 'small', textContent: filtered ? `Test ${n(shown.length)}` : 'Test all', disabled: testingAll || !shown.length, title: `send ${filtered ? 'the models shown' : 'each model'} a short message to see which really answer, and how fast`, onclick: () => tryAll(filtered ? shown : order) }),
|
|
2565
|
-
|
|
2622
|
+
// not on the helpers' view: they're not a list to keep only
|
|
2623
|
+
filtered && FILTER.helpers ? null : h('button', { className: 'small primary', textContent: filtered ? `Use only these ${n(view.length)}` : 'Save list', disabled: !view.length || order.length < 2, title: filtered ? `HeartCode uses only these ${n(view.length)}, in the order shown (the others stay under Providers)` : 'save your list as shown: HeartCode uses them in this order (#1 first)', onclick: saveList }))
|
|
2566
2624
|
|
|
2567
2625
|
// --- the table ---
|
|
2568
2626
|
const all = view.length > 0 && view.every((t) => PICKED.has(keyOf(t)))
|
|
@@ -2582,7 +2640,7 @@ function drawMine(s) {
|
|
|
2582
2640
|
h('button', { className: 'small ghost', textContent: 'Invert', title: "select the ones shown that aren't selected, unselect the ones that are", onclick: () => (view.forEach((t) => (PICKED.has(keyOf(t)) ? PICKED.delete(keyOf(t)) : PICKED.add(keyOf(t)))), (lastPicked = null), drawMine(S)) }),
|
|
2583
2641
|
h('button', { className: 'small ghost', textContent: 'Select none', onclick: () => (PICKED.clear(), drawMine(S)) })))
|
|
2584
2642
|
: h('div', { className: 'mt mt-h' }, h('span'), selectAll,
|
|
2585
|
-
h('span', { textContent: '#', title: 'its place in your list' }), head('model'), head('provider'), head('context', 'num'), head('tools', 'mid'), head('thinking', 'mid'), head('images', 'mid'), head('coding', 'num'), head('web', 'num'), head('vision', 'num'), head('price', 'num'), head('works'), h('span', { className: 'num', textContent: '' }))
|
|
2643
|
+
h('span', { textContent: '#', title: 'its place in your list' }), head('model'), head('provider'), h('span', { textContent: 'Helper', title: '#1 can hand a part of a task to a helper. Switch a model on, and pick what it\'s good at (hover a pill to see what it covers): #1 is told, and picks by it. None switched on: helpers run on the model that answers.' }), head('context', 'num'), head('tools', 'mid'), head('thinking', 'mid'), head('images', 'mid'), head('coding', 'num'), head('web', 'num'), head('vision', 'num'), head('price', 'num'), head('works'), h('span', { className: 'num', textContent: '' }))
|
|
2586
2644
|
const table = view.length ? h('ol', { className: 'mtable' + (view.length < 2 || busy ? '' : ' drag') }) : null
|
|
2587
2645
|
// ticked or not; with Shift, every row from the last one ticked to this one
|
|
2588
2646
|
const pick = (i, e) => {
|
|
@@ -2667,6 +2725,150 @@ const src = (t) => {
|
|
|
2667
2725
|
// a row of the table: one model of your list, in the order shown (at: its place in your order)
|
|
2668
2726
|
const money = (x) => (x == null ? '–' : x === 0 ? '$0' : usd(x))
|
|
2669
2727
|
const priceOf = (t) => (t.price?.input == null && t.price?.output == null ? '–' : t.price.input === 0 && t.price.output === 0 ? 'free' : `${money(t.price.input)} / ${money(t.price.output)}`)
|
|
2728
|
+
// --- Helpers: the models #1 may start for side jobs, and what each is good at (S.helpers: { key: [jobs] }).
|
|
2729
|
+
// A click saves at once, in the background: only that row's cell is redrawn, and the button clicked
|
|
2730
|
+
// shows it's saving. MINE: your latest picks while saves are on their way (each save sends them all,
|
|
2731
|
+
// one after another, so quick clicks don't undo each other).
|
|
2732
|
+
// HSUG: suggestions not taken yet ({ key: [jobs] }), shown dashed until you take or dismiss them.
|
|
2733
|
+
let HSUG = null
|
|
2734
|
+
let MINE = null
|
|
2735
|
+
let saving = Promise.resolve()
|
|
2736
|
+
let unsaved = 0
|
|
2737
|
+
const SAVING = new Set() // 'key|job' (or 'key|on'): the buttons whose save is on its way
|
|
2738
|
+
const helpers = () => MINE ?? S.helpers ?? {}
|
|
2739
|
+
let helperBar = null // the toolbar's part for helpers: the same element every time, filled in place
|
|
2740
|
+
const redrawCell = (k) => {
|
|
2741
|
+
const li = document.querySelector(`.mtable li[data-key="${CSS.escape(k)}"]`)
|
|
2742
|
+
const at = S.order.findIndex((t) => keyOf(t) === k)
|
|
2743
|
+
if (li && at >= 0) li.querySelector('.hp')?.replaceWith(helperCell(S.order[at], at))
|
|
2744
|
+
}
|
|
2745
|
+
function saveHelpers(next, marks = [], done) {
|
|
2746
|
+
MINE = next
|
|
2747
|
+
unsaved++
|
|
2748
|
+
for (const m of marks) SAVING.add(m)
|
|
2749
|
+
const cells = new Set(marks.map((m) => m.split('|')[0]))
|
|
2750
|
+
cells.forEach(redrawCell)
|
|
2751
|
+
drawHelperBar()
|
|
2752
|
+
saving = saving
|
|
2753
|
+
.then(() => api('/api/helpers', { helpers: next }))
|
|
2754
|
+
.then((r) => ((S.helpers = r.helpers), (S.helpersAuto = r.helpersAuto), $('h-auto') && ($('h-auto').value = r.helpersAuto ? 'auto' : 'manual'), done && toast(done)))
|
|
2755
|
+
.catch((e) => toast(e.message, true))
|
|
2756
|
+
.finally(() => {
|
|
2757
|
+
for (const m of marks) SAVING.delete(m)
|
|
2758
|
+
if (!--unsaved) MINE = null // all saved: what the server has is yours
|
|
2759
|
+
cells.forEach(redrawCell)
|
|
2760
|
+
drawHelperBar()
|
|
2761
|
+
})
|
|
2762
|
+
return saving
|
|
2763
|
+
}
|
|
2764
|
+
function setHelper(k, jobs, mark) {
|
|
2765
|
+
const next = { ...helpers() }
|
|
2766
|
+
jobs ? (next[k] = jobs) : delete next[k]
|
|
2767
|
+
if (HSUG?.[k] && jobs) {
|
|
2768
|
+
const left = HSUG[k].filter((j) => !jobs.includes(j))
|
|
2769
|
+
left.length ? (HSUG[k] = left) : delete HSUG[k]
|
|
2770
|
+
if (!Object.keys(HSUG).length) HSUG = null
|
|
2771
|
+
}
|
|
2772
|
+
saveHelpers(next, [`${k}|${mark}`])
|
|
2773
|
+
}
|
|
2774
|
+
function helperCell(t, at) {
|
|
2775
|
+
const k = keyOf(t)
|
|
2776
|
+
const jobs = helpers()[k]
|
|
2777
|
+
const sug = HSUG?.[k] ?? []
|
|
2778
|
+
const busy = locked()
|
|
2779
|
+
return h('span', { className: 'hp' + (jobs ? '' : ' off') },
|
|
2780
|
+
h('span', { className: SAVING.has(`${k}|on`) ? 'saving' : '', title: jobs ? 'a helper: #1 can start it for side jobs (click: not a helper)' : Object.keys(helpers()).length ? 'not a helper (click: #1 can start it for side jobs)' : 'no helpers ticked: #1 can start any of your models (click: only the ones you tick)' },
|
|
2781
|
+
sw({ checked: Boolean(jobs), disabled: busy, 'aria-label': `${t.model} is a helper`, onchange: (e) => setHelper(k, e.target.checked ? (jobs ?? []) : null, 'on') })),
|
|
2782
|
+
Object.entries(S.jobs ?? {}).map(([j, [label, , covers]]) => {
|
|
2783
|
+
const has = Boolean(jobs?.includes(j))
|
|
2784
|
+
const sugd = !has && sug.includes(j)
|
|
2785
|
+
const pill = h('button', { type: 'button', className: 'jp' + (has ? ' on' : sugd ? ' sug' : '') + (SAVING.has(`${k}|${j}`) ? ' saving' : ''), disabled: busy, 'aria-pressed': String(has), 'aria-label': `${label}: ${covers}`, onclick: () => setHelper(k, has ? jobs.filter((x) => x !== j) : [...(jobs ?? []), j], j) }, label)
|
|
2786
|
+
// what the pill means, and what a click does here
|
|
2787
|
+
return withTip(pill, () => [
|
|
2788
|
+
at === 0 ? h('div', { className: 'tcover', textContent: '#1 answers you; as a helper it\'s started when another of your models is answering.' }) : null,
|
|
2789
|
+
h('div', { className: 'tjob', textContent: label }),
|
|
2790
|
+
h('div', { className: 'tcover', textContent: covers }),
|
|
2791
|
+
sugd ? h('div', { className: 'tcover', textContent: `Suggested from ${SUGGEST_WHY[j]}.` }) : null,
|
|
2792
|
+
S.helpersAuto && has ? h('div', { className: 'tcover', textContent: 'Picked for you, from the rankings and the tests.' }) : null,
|
|
2793
|
+
h('div', { className: 'thint', textContent: (has ? `Click: ${t.model} isn't picked for this any more` : `Click: #1 gives these jobs to ${t.model}${jobs ? '' : ' (it becomes a helper)'}`) + (S.helpersAuto ? ' · from then on, you pick' : '') }),
|
|
2794
|
+
])
|
|
2795
|
+
}))
|
|
2796
|
+
}
|
|
2797
|
+
// what each pill's suggestions go by (said in its tooltip)
|
|
2798
|
+
const SUGGEST_WHY = { ui: 'its place in the top half of the web-app ranking (LMArena)', code: 'its place in the top half of the coding ranking (LMArena)', hard: 'it thinks with a context of 128k or more, or its place in the top half of the ranking for long real tasks or the hardest prompts (LMArena)', quick: 'its test: as fast as the middle one of yours or faster (or nothing else fits it)' }
|
|
2799
|
+
// Helpers are picked from the models that answered their test: how many did
|
|
2800
|
+
const working = () => S.order.filter((t) => TRIES[keyOf(t)]?.ok && !TRIES[keyOf(t)].going).length
|
|
2801
|
+
// No test yet: ask before testing them all (each gets a short message, which a paid model charges for);
|
|
2802
|
+
// then: what to do once the run is over ('suggest', or nothing: picked for you does it itself)
|
|
2803
|
+
let afterTests = null
|
|
2804
|
+
function testFirst(then) {
|
|
2805
|
+
const n = (x) => x.toLocaleString()
|
|
2806
|
+
const paid = S.order.filter((t) => t.price && (t.price.input > 0 || t.price.output > 0)).length
|
|
2807
|
+
const unknown = S.order.filter((t) => !t.price).length
|
|
2808
|
+
$('h-test-cost').textContent = `Test all sends each of your ${n(S.order.length)} models a short message. ${paid ? `${n(paid)} of them aren't free: each charges for its few tokens. ` : ''}${unknown ? `${n(unknown)} have no price we know of, and may charge too. ` : ''}When it's done, helpers are ${then === 'suggest' ? 'suggested' : 'picked'} from the ones that worked.`
|
|
2809
|
+
$('h-test-go').onclick = () => {
|
|
2810
|
+
$('h-test').close()
|
|
2811
|
+
afterTests = then
|
|
2812
|
+
tryAll(S.order)
|
|
2813
|
+
}
|
|
2814
|
+
$('h-test-no').onclick = () => $('h-test').close()
|
|
2815
|
+
$('h-test').showModal()
|
|
2816
|
+
}
|
|
2817
|
+
// Picked for you (HeartCode makes them from what's known, again whenever that changes) or by you
|
|
2818
|
+
async function setAuto(on, select) {
|
|
2819
|
+
if (on && !working()) return (select.value = 'manual'), testFirst('auto') // nothing to pick from yet
|
|
2820
|
+
select.disabled = true
|
|
2821
|
+
try {
|
|
2822
|
+
const r = await api('/api/helpers/auto', { on })
|
|
2823
|
+
Object.assign(S, { helpers: r.helpers, helpersAuto: r.helpersAuto })
|
|
2824
|
+
HSUG = null
|
|
2825
|
+
drawMine(S)
|
|
2826
|
+
} catch (e) {
|
|
2827
|
+
toast(e.message, true)
|
|
2828
|
+
select.value = S.helpersAuto ? 'auto' : 'manual'
|
|
2829
|
+
} finally {
|
|
2830
|
+
select.disabled = false
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
|
|
2834
|
+
// Suggest helpers: the server's picks, beside yours (nothing saved until you take them)
|
|
2835
|
+
async function suggestNow(b) {
|
|
2836
|
+
if (b) b.disabled = true
|
|
2837
|
+
const r = await api('/api/helpers/suggest', {}).catch((x) => (toast(x.message, true), null))
|
|
2838
|
+
if (b) b.disabled = false
|
|
2839
|
+
if (!r) return
|
|
2840
|
+
HSUG = Object.keys(r.suggest).length ? r.suggest : null
|
|
2841
|
+
if (!HSUG) return toast(working() ? 'Nothing more to suggest' : 'None of your models worked in the test: nothing to pick from', !working())
|
|
2842
|
+
setFilter({ helpers: true }) // your helpers and the suggested ones, together: not lost among the rest
|
|
2843
|
+
}
|
|
2844
|
+
// The toolbar's helpers part: suggestions waiting (take all · dismiss), or Suggest helpers and Clear
|
|
2845
|
+
// helpers. Each saves at once, its own button saying so.
|
|
2846
|
+
function drawHelperBar() {
|
|
2847
|
+
helperBar ??= h('span', { className: 'hbar' })
|
|
2848
|
+
const order = S.order
|
|
2849
|
+
const n = Object.keys(helpers()).length
|
|
2850
|
+
const busy = (b) => Object.assign(b, { disabled: true, textContent: 'Saving…' })
|
|
2851
|
+
put(helperBar,
|
|
2852
|
+
HSUG ? h('span', { className: 'hsug', title: 'shown dashed in the Helper column: click one to take just that' }, ic('sparkles'),
|
|
2853
|
+
h('span', { textContent: `${Object.keys(HSUG).length} suggested` }),
|
|
2854
|
+
h('button', { className: 'small primary', textContent: 'Take all', onclick: (e) => {
|
|
2855
|
+
busy(e.currentTarget)
|
|
2856
|
+
const next = { ...helpers() }
|
|
2857
|
+
const took = Object.keys(HSUG)
|
|
2858
|
+
for (const [k, jobs] of Object.entries(HSUG)) next[k] = [...new Set([...(next[k] ?? []), ...jobs])]
|
|
2859
|
+
HSUG = null
|
|
2860
|
+
saveHelpers(next, [], `${took.length} model${took.length === 1 ? ' is a helper' : 's are helpers'} now`).then(() => drawMine(S))
|
|
2861
|
+
} }),
|
|
2862
|
+
h('button', { className: 'small ghost', textContent: 'Dismiss', onclick: () => ((HSUG = null), drawMine(S)) })) : null,
|
|
2863
|
+
!HSUG && !S.helpersAuto ? h('button', { className: 'small', title: working() ? `suggest helpers from the ${working()} models that answered their test (their provider switched on), each with what it's good at that it doesn't have yet (from the rankings, its test, thinking and context): you see them first, then take them or not` : 'suggest helpers: your models are tested first (helpers are picked from the ones that answer)', onclick: (e) => (working() ? suggestNow(e.currentTarget) : testFirst('suggest')) }, ic('sparkles'), 'Suggest helpers') : null,
|
|
2864
|
+
!HSUG && n ? h('button', { className: 'small ghost', textContent: 'Clear helpers', title: `none of your models a helper (${n} now): #1 can then start any of your models again, as before`, onclick: (e) => {
|
|
2865
|
+
if (!confirm(`Clear your ${n} helper${n === 1 ? '' : 's'}? #1 can then start any of your models again, as before.`)) return
|
|
2866
|
+
busy(e.currentTarget)
|
|
2867
|
+
saveHelpers({}, [], 'no helpers: #1 can start any of your models again').then(() => (FILTER.helpers ? setFilter({ helpers: false }) : drawMine(S))) // no helpers left to show only
|
|
2868
|
+
} }) : null)
|
|
2869
|
+
return helperBar
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2670
2872
|
function tableRow(t, at, pick) {
|
|
2671
2873
|
const c = can(t)
|
|
2672
2874
|
const ctx = COLS.context.get(t)
|
|
@@ -2684,6 +2886,7 @@ function tableRow(t, at, pick) {
|
|
|
2684
2886
|
h('span', { className: 'n', textContent: `#${at + 1}`, title: SORT.length || filtering() ? 'its place in your list' : '' }),
|
|
2685
2887
|
h('span', { className: 'm' }, h('span', { className: 'name', textContent: t.model, title: t.model }), tag),
|
|
2686
2888
|
h('span', { className: 'p', textContent: isOff(t.provider) ? `${t.provider} · off` : t.provider, title: t.provider }),
|
|
2889
|
+
helperCell(t, at),
|
|
2687
2890
|
h('span', { className: 'num', textContent: ctx ? `${t.tested?.sure === false ? '~' : ''}${kTok(ctx)}` : '–', title: ctx ? `${ctx.toLocaleString()} tokens${t.tested?.sure === false ? ' (assumed: the server and models.dev don\'t say)' : ''}` : '' }),
|
|
2688
2891
|
yes(c.tools), yes(c.thinking), yes(c.images),
|
|
2689
2892
|
rankCell(t, 'coding'), rankCell(t, 'web'), rankCell(t, 'vision'),
|
|
@@ -3581,6 +3784,7 @@ if (token) {
|
|
|
3581
3784
|
gotResult(key, result)
|
|
3582
3785
|
})
|
|
3583
3786
|
events.addEventListener('testrun', (e) => showRun(JSON.parse(e.data)))
|
|
3787
|
+
events.addEventListener('helpers', (e) => ((S.helpers = JSON.parse(e.data).helpers), drawMine(S))) // picked for you again, after a test run
|
|
3584
3788
|
// many at once (thousands of models added): taken in once a frame, the table drawn once
|
|
3585
3789
|
const news = new Map()
|
|
3586
3790
|
events.addEventListener('test', (e) => {
|
package/src/settings.js
CHANGED
|
@@ -8,7 +8,7 @@ import fs from 'node:fs'
|
|
|
8
8
|
import path from 'node:path'
|
|
9
9
|
import crypto from 'node:crypto'
|
|
10
10
|
import os from 'node:os'
|
|
11
|
-
import { HOME, saveConfig, readJson, writeJson, byName, takeIn, whatOf, VERSION, speedOf, SPEED_LIMITS } from './config.js'
|
|
11
|
+
import { HOME, saveConfig, readJson, writeJson, byName, takeIn, whatOf, VERSION, speedOf, SPEED_LIMITS, HELPER_JOBS, helpersOf } from './config.js'
|
|
12
12
|
import { newer } from './update.js'
|
|
13
13
|
import { DEFAULT_SERVERS, mcpAuth, serverName } from './mcp.js'
|
|
14
14
|
import { sections, BUILTIN_PROMPTS, prompt, reloadPrompts } from './prompts.js'
|
|
@@ -55,7 +55,7 @@ const DETAILS = ['full', 'summary']
|
|
|
55
55
|
const FILES = [
|
|
56
56
|
['mcp.json', 'MCP servers: programs that give the model more tools', true, '{\n "mcpServers": {\n "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"] },\n "docs": { "url": "https://mcp.example.com/mcp" }\n }\n}'],
|
|
57
57
|
['hooks.json', 'Your commands, run before or after the model uses a tool (one can block it)', true, '{\n "hooks": {\n "PreToolUse": [\n { "matcher": "run_command", "hooks": [{ "type": "command", "command": "./check-command.sh" }] }\n ]\n }\n}'],
|
|
58
|
-
['keybindings.json', 'Your own keys: an action, or a /command to send', true, '{\n "alt+
|
|
58
|
+
['keybindings.json', 'Your own keys: an action, or a /command to send', true, '{\n "alt+g": "cycle_permissions",\n "alt+r": "/rewind"\n}'],
|
|
59
59
|
['theme.json', 'Your own colors, on top of the theme you chose', true, '{\n "brand": "#ff6b9d",\n "background": "#101014"\n}'],
|
|
60
60
|
['format.json', 'The formatter to run on each kind of file HeartCode writes', true, '{\n ".go": "gofmt -w {file}",\n ".py": "ruff format {file}"\n}'],
|
|
61
61
|
['HEARTCODE.md', 'Your instructions for every project (like AGENTS.md, for all of them)', false, '- Answer briefly.\n- Use pnpm, not npm.'],
|
|
@@ -404,9 +404,46 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
|
|
|
404
404
|
const over = { ...runState(), over: true }
|
|
405
405
|
run = null
|
|
406
406
|
emit('testrun', over)
|
|
407
|
+
if (autoPick()) emit('helpers', { helpers: helpersOf(cfg.helpers) }) // picked for you: what the tests found counts
|
|
407
408
|
}
|
|
408
409
|
}
|
|
409
410
|
|
|
411
|
+
const keyOf = (t) => `${t.provider}/${t.model}`
|
|
412
|
+
|
|
413
|
+
// Helpers picked from what's known: every model of yours (#1 too) that answered its test and whose
|
|
414
|
+
// provider is on, each with the jobs it's good at (at least one): UI & visuals and Code &
|
|
415
|
+
// logic when it's in the top half of LMArena's web-app or coding ranking; Big & hard when it thinks
|
|
416
|
+
// with a big context, or is in the top half of its agent (long real tasks) or hardest-prompts ranking; Quick & cheap when its test was faster than most (or it's good at none of the
|
|
417
|
+
// others). have: picks already made (a job a model has isn't picked again). { key: [jobs] }.
|
|
418
|
+
const pickHelpers = (have = {}) => {
|
|
419
|
+
const ranked = loadRankings()
|
|
420
|
+
const order = [{ provider: cfg.provider, model: cfg.model }, ...rotationOf(cfg).then]
|
|
421
|
+
const pool = order.map((t) => ({ ...t, can: testedOf(t), test: tests[keyOf(t)] })).filter((t) => !cfg.providers[t.provider]?.off && t.test?.ok && t.test.ms != null) // without tool calls too: a helper then works in guided mode
|
|
422
|
+
const top = (t, list) => ((x) => Boolean(x && x.rank / x.of <= 0.5))(rankIn(t.model, list, ranked))
|
|
423
|
+
const times = pool.map((t) => t.test.ms).sort((x, y) => x - y)
|
|
424
|
+
const fast = times[Math.floor((times.length - 1) / 2)] // the middle time: faster than that is quick
|
|
425
|
+
const picks = Object.fromEntries(pool.map((t) => {
|
|
426
|
+
const jobs = [top(t, 'webdev:webdev') && 'ui', top(t, 'text:coding') && 'code', ((t.can?.thinking && t.can.context >= 128_000) || top(t, 'agent:overall') || top(t, 'text:hard_prompts')) && 'hard', t.test.ms <= fast && 'quick'].filter(Boolean)
|
|
427
|
+
return [keyOf(t), jobs.length ? jobs : ['quick']]
|
|
428
|
+
}))
|
|
429
|
+
const out = {}
|
|
430
|
+
for (const [k, jobs] of Object.entries(picks)) {
|
|
431
|
+
const fresh = jobs.filter((j) => !have[k]?.includes(j))
|
|
432
|
+
if (fresh.length) out[k] = fresh
|
|
433
|
+
}
|
|
434
|
+
return out
|
|
435
|
+
}
|
|
436
|
+
// Picked for you: the helpers made again from what's known now (after Update model info, a test run,
|
|
437
|
+
// your list's order changed). true when they changed.
|
|
438
|
+
const autoPick = () => {
|
|
439
|
+
if (cfg.helpersAuto !== true) return false
|
|
440
|
+
const next = pickHelpers()
|
|
441
|
+
if (JSON.stringify(next) === JSON.stringify(helpersOf(cfg.helpers))) return false
|
|
442
|
+
cfg.helpers = Object.keys(next).length ? next : undefined
|
|
443
|
+
save('setting:helpers')
|
|
444
|
+
return true
|
|
445
|
+
}
|
|
446
|
+
|
|
410
447
|
const state = (ranked = loadRankings()) => ({
|
|
411
448
|
providers: Object.entries(byName(cfg.providers))
|
|
412
449
|
.filter(([n]) => n !== cfg.adhoc)
|
|
@@ -418,6 +455,10 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
|
|
|
418
455
|
order: [...(cfg.providers[cfg.provider] && cfg.model ? [{ provider: cfg.provider, model: cfg.model }] : []), ...rotationOf(cfg).then].map((t) => ({ ...t, tested: testedOf(t), known: knownOf(t), price: priceFor(t), ranks: ranksOf(t.model, ranked) })),
|
|
419
456
|
rankings: ranked && { fetched: ranked.fetched, source: ranked.source },
|
|
420
457
|
rotation: (({ then, ...opts }) => opts)(rotationOf(cfg)),
|
|
458
|
+
helpers: helpersOf(cfg.helpers), // { 'provider/model': [jobs] }
|
|
459
|
+
helperOrder: cfg.helperOrder === 'provider' ? 'provider' : 'own', // the order helpers are picked in: your list's, or your provider ranking's
|
|
460
|
+
helpersAuto: cfg.helpersAuto === true, // picked for you (pickHelpers), again whenever what's known changes: the models #1 may start as helpers, and what you picked each for
|
|
461
|
+
jobs: HELPER_JOBS,
|
|
421
462
|
settings: { permissions: cfg.permissions ?? 'all', effort: cfg.effort ?? 'default', theme: cfg.theme ?? 'dark', context: cfg.context ?? null, ...Object.fromEntries(Object.keys(TOGGLES).map((k) => [k, cfg[k] !== false])), logs: kindsOn(cfg), logDetail: cfg.logDetail === 'summary' ? 'summary' : 'full', logDays: logDays(cfg), testTimeout: Number(cfg.testTimeout) > 0 ? Number(cfg.testTimeout) : 10, ...speedOf(cfg) },
|
|
422
463
|
logs: { runs: tilde(path.join(LOGS, 'runs')), requests: tilde(REQUESTS) },
|
|
423
464
|
voice: cfg.voice ? JSON.stringify(cfg.voice, null, 2) : '',
|
|
@@ -440,6 +481,7 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
|
|
|
440
481
|
// LMArena's public rankings, fetched now (with models.dev: Update model info on Your models)
|
|
441
482
|
'POST /api/rankings': async () => {
|
|
442
483
|
if (!(await rankings({ now: true }))) throw new Error("couldn't get the rankings (huggingface.co)")
|
|
484
|
+
autoPick()
|
|
443
485
|
return state()
|
|
444
486
|
},
|
|
445
487
|
'GET /api/log-size': () => logSize(),
|
|
@@ -574,6 +616,33 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
|
|
|
574
616
|
forgetTests()
|
|
575
617
|
return state()
|
|
576
618
|
},
|
|
619
|
+
// the helpers, all at once: { 'provider/model': [jobs] } (a model in it can be started as a helper; its
|
|
620
|
+
// jobs: what you picked it for, told to #1). Models no longer in your list are left out.
|
|
621
|
+
// picked for you (on), or by you (off: the helpers stay as they are, yours to change)
|
|
622
|
+
'POST /api/helpers/auto': ({ on }) => {
|
|
623
|
+
cfg.helpersAuto = on === true ? true : undefined
|
|
624
|
+
if (!autoPick()) save('setting:helpersAuto')
|
|
625
|
+
return { helpers: helpersOf(cfg.helpers), helpersAuto: cfg.helpersAuto === true }
|
|
626
|
+
},
|
|
627
|
+
// Suggest helpers: what would be picked, beside what you have (nothing saved)
|
|
628
|
+
'POST /api/helpers/suggest': () => ({ suggest: pickHelpers(helpersOf(cfg.helpers)) }),
|
|
629
|
+
'POST /api/helpers': ({ helpers }) => {
|
|
630
|
+
if (!helpers || typeof helpers !== 'object') throw new Error('helpers: an object')
|
|
631
|
+
cfg.helpersAuto = undefined // your own picks now
|
|
632
|
+
const yours = new Set(rotationOf(cfg).then.map((t) => `${t.provider}/${t.model}`).concat(cfg.provider && cfg.model ? [`${cfg.provider}/${cfg.model}`] : []))
|
|
633
|
+
const clean = helpersOf(Object.fromEntries(Object.entries(helpers).filter(([k]) => yours.has(k))))
|
|
634
|
+
cfg.helpers = Object.keys(clean).length ? clean : undefined
|
|
635
|
+
save('setting:helpers')
|
|
636
|
+
return { helpers: helpersOf(cfg.helpers), helpersAuto: false } // only these: the page saves a click at once, and the whole state of a long list takes seconds
|
|
637
|
+
},
|
|
638
|
+
// the order helpers are picked in: 'own' (your list's) or 'provider' (your provider ranking's, each
|
|
639
|
+
// provider's in your list's order; rank: the ranking as the page has it, kept for HeartCode to use)
|
|
640
|
+
'POST /api/helper-order': ({ by, rank }) => {
|
|
641
|
+
cfg.helperOrder = by === 'provider' ? 'provider' : undefined
|
|
642
|
+
cfg.providerRank = cfg.helperOrder && (Array.isArray(rank) ? rank.filter((x) => typeof x === 'string') : readJson(PREFS, {}).rank)
|
|
643
|
+
save('setting:helperOrder')
|
|
644
|
+
return { helperOrder: cfg.helperOrder ?? 'own' }
|
|
645
|
+
},
|
|
577
646
|
// the model list, in order (#1 is the model), and when to go on to the next
|
|
578
647
|
'POST /api/order': ({ list, on, retries, next }) => {
|
|
579
648
|
if (!Array.isArray(list)) throw new Error('a list of models is needed')
|
|
@@ -596,6 +665,7 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
|
|
|
596
665
|
ownWrite = Date.now()
|
|
597
666
|
saveConfig(cfg)
|
|
598
667
|
changed(changed1 ? 'model' : 'setting:rotation')
|
|
668
|
+
autoPick() // picked for you: from your list as it is now
|
|
599
669
|
test(clean)
|
|
600
670
|
forgetTests()
|
|
601
671
|
return state()
|
|
@@ -605,7 +675,11 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
|
|
|
605
675
|
// for it stay above). A running HeartCode takes it at once.
|
|
606
676
|
// Test: one short message to the model, to see that it answers (key, access, name, the server
|
|
607
677
|
// itself). In the requests log as a model test. Never throws: { ok, ms, reply } or { ok: false, error }.
|
|
608
|
-
'POST /api/try': ({ provider, model } = {}) =>
|
|
678
|
+
'POST /api/try': async ({ provider, model } = {}) => {
|
|
679
|
+
const r = await testOne({ provider, model: String(model ?? '') })
|
|
680
|
+
if (autoPick()) emit('helpers', { helpers: helpersOf(cfg.helpers) }) // picked for you: what this test found counts
|
|
681
|
+
return r
|
|
682
|
+
},
|
|
609
683
|
// Test, on a model's row: one "Hello" to it, and exactly what was sent and what came back (the
|
|
610
684
|
// key masked), for the page to show. Not streamed, so the answer is the provider's own JSON.
|
|
611
685
|
'POST /api/hello': async ({ provider, model }) => {
|
|
@@ -678,6 +752,7 @@ export function startSettings({ cfg, apply = () => {}, port = 0, root = process.
|
|
|
678
752
|
writeJson(profilePath(c), p)
|
|
679
753
|
changed('profile')
|
|
680
754
|
testNews(`${provider}/${t.model}`, t)
|
|
755
|
+
autoPick() // picked for you: what it can do now counts (thinking, context)
|
|
681
756
|
return state()
|
|
682
757
|
},
|
|
683
758
|
// Measure a tested model's window: one oversized request (client.measureContext); the limit the
|
package/src/tabs.js
CHANGED
|
@@ -139,7 +139,10 @@ export class Tabs {
|
|
|
139
139
|
bottom += (on ? c.brand(`╯${' '.repeat(w)}╰`) : c.ghost(`┴${'─'.repeat(w)}┴`)) + c.ghost('─')
|
|
140
140
|
})
|
|
141
141
|
// the keys that fit whole, the rest left out (never one cut in the middle)
|
|
142
|
-
|
|
142
|
+
// as keybindings.json has them now (one moved or turned off: said so, or left out)
|
|
143
|
+
const k = (a) => this.at?.ui.keyFor?.(a)
|
|
144
|
+
const sw = [k('next_tab'), k('prev_tab')].filter(Boolean).join('/')
|
|
145
|
+
const hints = (this.list.length > 1 ? [k('new_tab') && `${k('new_tab')} open a tab`, k('close_tab') && `${k('close_tab')} close this one`, sw && `${sw} switch tabs`] : [k('new_tab') && `${k('new_tab')} open a new tab`]).filter(Boolean)
|
|
143
146
|
let hint = ''
|
|
144
147
|
for (const h of hints) if (width(mid.replace(/\x1b\[[0-9;]*m/g, '')) + 1 + width(hint ? `${hint} · ${h}` : h) <= cols - 1) hint = hint ? `${hint} · ${h}` : h
|
|
145
148
|
if (hint) mid += ` ${c.faint(hint)}`
|