Files
alzeo/dashboard/static/js/ops.js
T
Hasan BasbunarandClaude Opus 5.5 b73eac92df v1.59: the Inkling 2 Mini lane (inkling), on SGLang's own image for it, in every lane list
install-inkling.sh serves Thinking Machines' Inkling 2 Mini (thinkingmachines/Inkling-2-Mini at its pinned
revision, Apache-2.0: a looped mixture of experts, 26.4B parameters with 3.4B active, text and images in) with
the DSpark draft head its checkpoint carries, on the text port behind the proxy, as model inkling-2-mini. The
engine is SGLang from the image its cookbook gives the model (lmsysorg/sglang:inkling-2-mini, by the digest of
its arm64 build), with the cookbook's DGX Spark recipe and its DSpark arm word for word, as the reference box
measured it on 2026-11-22: a static share of 0.45, FA4, bfloat16, pages of 128, 8 draft tokens verified per
step, MAX_JOBS=4 and the four SGLANG_OPT_* variables, xgrammar, images on, the inkling reasoning and inkling2
tool-call parsers; the model's window of 1,048,576 tokens and the 48 requests SGLang set itself, said so that
no later default moves them; and what every SGLang lane of this box passes besides (the key by --config, the
scheduler parked when idle, the metrics, the cache report). Its fetch pins refs/main, through which SGLang
reads the draft head by the model's name. Its caches keep the kernels its engine compiles at its first start.

The lane in every list: the registry, boxmem (refused on a 64 GB box: measured on a 128 GB one only), every
engine unit's Conflicts= and After=, the proxy's hold units and its pair's lane names, install.sh
(--with-inkling, --no-inkling, on demand by default, its boot kept by an update, its proof, its summary line),
switch-model.sh (target inkling), prepare-lane.sh, uninstall.sh (its image is its own: the uninstall takes its
tag and a prune reclaims it), check-pins.sh, the cockpit's sudoers lines, the CI's lists and gates, and
lane-templates-check.py (its template as published, rendered for every client shape as SGLang hands them).

The cockpit follows it as an SGLang text lane (the canary, the pool guard and the autoheal are its own), with
its card, its names, its note with the reference box's measures, its engine, its boot default (222 s
measured), its journal and its container; its mark is a plain badge of Thinking Machines' initials, no icon
set having one.

Its clients: opencode's provider inkling (oc-inkling.py), images in, five variants each a level its template
reads by name, a pair of 374,000 and 32,000 that fits the pool measured at its window, and oc-fit-limits.py
keeping that output as its ceiling whatever its window (ANSWER_CAPPED), as its card recommends limits on
output tokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 07:20:13 +01:00

947 lines
72 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use strict";
/* Traffic, Machine, Library, Logs and Settings: the views you open to look closer. */
// ── Traffic ───────────────────────────────────────────────────────────────────
// With no text engine the counters say so: they read '…', a value on its way, for as long as
// the box served nothing (found by the monkey check, 2026-10-02; the page before the
// redesign of 2026-09-30 said "no engine")
on('engine_fast', d => {
const none = !d.load, l = (d.load || [])[0] || {};
setText('tr-run', none ? 'none' : String(runningReqs(l)));
setText('tr-wait', none ? 'none' : String(waitingReqs(l)));
setText('tr-tok', none ? 'none' : fmtN(physTokens(l)));
if (none){ SERIES.req = []; } else push('req', runningReqs(l));
drawSpark($('tr-spark'), 'req', cssVar('--brand'), Math.max(4, F.maxRun || 4), {empty: none ? 'no text engine' : 'quiet so far'});
});
// said after the whole payload: which lane serves is the lifecycle's, read after this one
afterApply(() => {
const none = F.noEngine || !textReady(), n = loadWords(F.load || {});
cap('tr-cap', none ? (imageServing() ? 'no text engine: the image lane serves' : videoServing() ? 'no text engine: the video lane serves' : transcribeServing() ? 'no text engine: the NVIDIA Nemotron Transcribe lane serves' : 'no text engine')
: (n && F.prompt ? n + ', computing a prompt' : n) || 'idle', none ? '' : n ? 'ok' : '', n && !none ? 'live' : true);
});
on('decode', d => {
const t = d.decode, u = d.usage || {};
if (!d.lane && (servingEngine() || [])[0] === KOLIBRI_UNIT){
// The scheduler lines these read are SGLang's, and the server reads none off the Kolibri lane
// (lane null): Kolibri runs no draft model, and its cache's use is vLLM's own count
// (kolibri_load). Both read "none" while it served (found in review, 2026-10-14).
const l = F.load || {};
setText('tr-acc', 'no draft model');
setText('tr-kv', l.num_tokens ? (100 * (l.num_used_tokens || 0) / l.num_tokens).toFixed(1) + ' %' : 'idle');
return;
}
if (!d.lane && isVllmTable((servingEngine() || [])[0])){
// the same vLLM counters as Kolibri's, and a drafter (the Qwen3.8 Flash-Next FP4-Local lane's MTP head
// counts as one): its mean acceptance over the last seconds, as vLLM counts it
// (nemotron_load), idle when no draft came in them; the Liquid AI LFM3 lane runs none
const l = F.load || {};
setText('tr-acc', (servingEngine() || [])[0] === LFM3_UNIT ? 'no draft model'
: l.accept_len != null ? l.accept_len.toFixed(2) : 'idle');
setText('tr-kv', l.num_tokens ? (100 * (l.num_used_tokens || 0) / l.num_tokens).toFixed(1) + ' %' : 'idle');
return;
}
if (!d.lane && isLlamacpp((servingEngine() || [])[0])){
// llama.cpp's own counters (llamacpp_load): the acceptance of its drafts (its n-gram lookup's and its DFlash2
// draft's) over the last seconds, read with vLLM's formula, idle when no draft came in them; it publishes no gauge
// of its KV cache
const l = F.load || {};
setText('tr-acc', l.accept_len != null ? l.accept_len.toFixed(2) : 'idle');
setText('tr-kv', 'not published by llama.cpp');
return;
}
if (!d.lane){ setText('tr-acc', 'none'); setText('tr-kv', 'none'); return; }
setText('tr-acc', t ? t.accept_len.toFixed(2) : 'idle');
setText('tr-kv', t ? (100 * t.token_usage).toFixed(1) + ' %' : u.tokens ? (100 * u.tokens).toFixed(0) + ' %' : 'idle');
});
// ── the last 5 minutes, from the engine's own counters (engine_metrics.py) ──────
// On SGLang each request is counted once, when it finishes, and the cockpit's canary is taken
// out; vLLM counts its tokens and latencies at every step, and a request, its wait and its
// prefill once it finishes (vllm/v1/metrics/stats.py). A speed holds no idle time on either.
// The window is the cockpit's, so a reload of the page loses nothing.
// No rate off the scheduler's log lines sits here: each of those is a token count over the
// time since the previous line of its kind, idle time included (the v1.22.12 notes in
// CHANGELOG.md have the measurements).
// The lanes that serve text on vLLM, whose counters the collector reads too (engine_metrics.py):
// no canary runs on them, and they count no client that left. A list of them, which the lane-lists
// test holds to the lanes whose installer stands on vllm-lane.sh, by its name; their names are the
// cockpit's: a copy of them said "Nemotron" where every other view says "Nemotron Bolt" (found in
// review, 2026-10-20).
const VLLM_UNITS = [KOLIBRI_UNIT, NEMOTRON_UNIT, NEMOTRON_SUPER_UNIT, FLASH_LOCAL_UNIT, ORNITH_UNIT, LFM3_UNIT];
const VLLM_LANE_NAME = Object.fromEntries(VLLM_UNITS.map(u => [u, LANE_NAME[u]]));
on('metrics', d => {
if (!d.lane){
// The Kolibri lane serves on vLLM: "no text engine is serving" was said while it served
// (found in review, 2026-10-14)
const sv = (servingEngine() || [])[0];
// and the llama.cpp lanes (v1.48), which serve their counters with the key the cockpit sends
const vname = VLLM_LANE_NAME[sv] || (isLlamacpp(sv) ? LANE_NAME[sv] : ''), up = !!vname && textReady();
const eng = isLlamacpp(sv) ? 'llama.cpp' : 'vLLM';
// while it loads it serves nothing yet, next to a Requests line that says so (review, 2026-10-14)
cap('wm-cap', up ? `${vname}: ${eng}` : vname ? `${vname}: loading` : 'no text engine', ''); setText('wm-note', '');
setText('wm-verdict', up ? `The ${vname} lane serves on ${eng}: its counters come with the next read.`
: vname ? `The ${vname} lane is loading: it serves nothing yet.`
: 'No text engine is serving: there is nothing to count.');
facts($('wm-facts'), []); return;
}
// llama.cpp counts no request (engine_metrics.py): its window has none, and is read all the same
const llama = d.engine === 'llamacpp';
if (d.requests == null && !llama){
// nothing read yet for this engine: a read that failed is said apart from one on its way
cap('wm-cap', d.read === false ? 'no counters' : 'first read', ''); setText('wm-note', '');
setText('wm-verdict', d.read === false
? 'The engine has not answered /metrics, and a busy one answers a later read. An SGLang engine started without --enable-metrics has no counters to show: every SGLang lane here starts with it, and vLLM always serves them.'
: 'The first read of the engine’s counters is on its way.');
facts($('wm-facts'), []); return;
}
// the gate counts only finished work, not the peaks: the cockpit's own canary shows up in
// num_running_reqs while it runs, and a canary-only window must still read quiet, even
// though the Busiest moment row says one request ran
const w = d.watched_s || 0, any = d.requests > 0 || d.decode_tps != null || d.ttft_s != null || d.prefill_tps != null;
const vllm = d.lane in VLLM_LANE_NAME;
const peaks = [d.pool_max ? `${Math.round(100 * d.pool_max)} % of the pool` : null,
d.running_max ? `${fmtN(d.running_max)} request${d.running_max > 1 ? 's' : ''} at once` : null,
d.queued_max ? `${fmtN(d.queued_max)} waiting` : null].filter(Boolean);
setText('wm-note', w > 0 && w < 295 ? `watched ${fmtDur(w)}` : '');
// "quiet" through a prompt of 19 min that nothing finished in was the page's word for a hang (issue #61)
cap('wm-cap', d.approximate ? 'approximate' : any ? 'watching' : F.prompt ? 'computing a prompt' : 'quiet', d.approximate ? 'warn' : any || F.prompt ? 'ok' : '');
setText('wm-verdict', (d.read === false ? 'The last read of the engine’s counters failed: these numbers come from the one before. ' : '')
+ (d.approximate ? 'A canary ran beside a client request, so it is counted as one while it lies inside the window. ' : '')
+ (vllm ? 'From vLLM’s own counters: its tokens and latencies as it makes them, a request, its wait and its prefill once it finishes.'
: llama ? 'From llama.cpp’s own counters: a prompt’s tokens and an answer’s, and the time it spent on each, counted when each is done.'
: 'From the engine’s own counters: each request counted once, when it finishes, and the cockpit’s canary taken out.'));
facts($('wm-facts'), [
['Requests finished', d.requests == null ? 'not counted by llama.cpp' : fmtN(d.requests)],
// vLLM counts a prompt's tokens as it reads them, SGLang when its request finishes, llama.cpp when the prompt is done
['Prompt tokens from the cache', d.reuse == null ? (vllm ? 'no prompt read' : llama ? 'no prompt done' : 'no request finished')
: `${(100 * d.reuse).toFixed(1)} % of ${fmtN(d.prompt_tokens)}`],
// the queue is what the client waits before the engine starts on it; prefill counts the
// tokens the engine computed over its own prefill stopwatch, cache reads not in it
['Queued before starting', d.queue_s == null ? null : `${d.queue_s < 10 ? d.queue_s.toFixed(2) : d.queue_s.toFixed(1)} s on average`],
['Prefill speed', d.prefill_tps == null ? null : `${fmtN(Math.round(d.prefill_tps))} tok/s computed`],
['First token after', d.ttft_s == null ? null : `${d.ttft_s < 10 ? d.ttft_s.toFixed(2) : d.ttft_s.toFixed(1)} s on average`],
['Decode speed', d.decode_tps == null ? null : `${d.decode_tps.toFixed(1)} tok/s per request`],
// the drafter's yield over its own verification count: not the boot average the
// gauge holds, not the scheduler's log window
['Accepted per draft step', d.acc_len == null ? null : `${d.acc_len.toFixed(2)} tokens per verify step`],
['Generated, all clients', d.throughput_tps == null ? null : `${d.throughput_tps.toFixed(1)} tok/s, ${fmtN(d.generated_tokens)} tokens`],
// the levels are not counters: these are the cockpit's own peaks of its reads
['Busiest moment', peaks.length ? peaks.join(', ') : null],
['Idle in the window', d.idle_share == null ? null : `${Math.round(100 * d.idle_share)} % of the time`],
// vLLM counts no client that left (engine_metrics.py): not counted, which is not none
['Abandons the engine accepted', d.aborted == null ? (llama ? 'not counted by llama.cpp' : 'not counted by vLLM') : d.aborted > 0 ? fmtN(d.aborted) : 'none']]);
});
const feedTime = ts => {
if (!ts || ts.length < 19) return ts || '';
const n = new Date(), today = `${n.getFullYear()}-${String(n.getMonth() + 1).padStart(2, '0')}-${String(n.getDate()).padStart(2, '0')}`;
return ts.slice(0, 10) === today ? ts.slice(11, 19) : `${ts.slice(8, 10)}/${ts.slice(5, 7)} ${ts.slice(11, 16)}`;
};
// The engine is read every 1 s and the proxy's journal every 5 s, so a request relayed by the
// proxy is counted by the engine up to 5 s before its line reaches the table: meanwhile the gap
// between the two counts is NOT "direct" (review 2026-11-19, D1). The gap is remembered across
// engine reads, and "direct" is said only once a journal read landed with the gap already there
// and did not absorb it, over several engine reads, with the journal source fresh.
let gapReads = 0, gapOutlivedFeed = false;
// the engine's count of the requests in flight, minus the cockpit's own canary when one is in
// flight (the server says so, canary_inflight): a probe of the box is not a client of it
// (review 2026-11-19, D2)
const engineCount = () => !F.noEngine && F.load && F.load.num_reqs != null
? Math.max(0, runningReqs(F.load) + waitingReqs(F.load) - (F.canary ? 1 : 0)) : null;
on('engine_fast', () => {
const eng = engineCount();
const inflight = (F.feedRows || []).filter(r => r.outcome === 'in flight').length;
if (eng != null && eng > inflight) gapReads += 1;
else { gapReads = 0; gapOutlivedFeed = false; }
});
on('feed', d => {
if (gapReads > 0) gapOutlivedFeed = true; // the journal refreshed with the gap already there
const tb = $('feed').tBodies[0]; clear(tb);
const rows = (d.rows || []).slice().reverse();
F.feedRows = rows;
rows.forEach(r => {
const tr = tb.insertRow();
tr.insertCell().textContent = feedTime(r.ts);
// every client so far is this box talking to itself through the proxy: the port tells them apart
const c1 = tr.insertCell(); c1.className = 'num'; c1.textContent = r.peer.startsWith('127.0.0.1:') ? ':' + r.peer.split(':').pop() : r.peer; c1.title = r.peer;
const cp = tr.insertCell(); cp.textContent = r.path; cp.title = r.path;
const c2 = tr.insertCell(); c2.className = 'r num'; c2.textContent = r.bytes >= 1024 ? (r.bytes / 1024).toFixed(0) + ' KB' : r.bytes + ' B';
// a request in flight shows how long it has been so: its cell stayed empty through a prompt of 19 min
// that a user took for a hang (issue #61)
const c3 = tr.insertCell(); c3.className = 'r num'; c3.textContent = r.secs != null ? r.secs.toFixed(1) + ' s' : r.age != null ? fmtDur(r.age) : '';
// the kind comes from the server: an ok request wears no colour, nor does the cockpit's
// own probe; only a client who left (ember) and a failure (clay) light up
const kind = {ok: '', gone: 'warn', fail: 'err', live: 'gold', unknown: '', probe: ''}[r.kind] ?? 'err';
const c4 = tr.insertCell(); c4.append(el('span', 'tag ' + kind, r.outcome));
if (r.detail) c4.append(el('div', 'help', r.detail));
// the prompt the engine computes belongs to this row when it is the only one in flight
if (r.outcome === 'in flight' && F.prompt && rows.filter(x => x.outcome === 'in flight').length === 1)
c4.append(el('div', 'help', promptWords(F.prompt)));
});
renderTraffic();
});
afterApply(() => renderTraffic()); // an engine read between two feed reads moves the count
on('transcribe', d => { F.transcribe = d; renderTraffic(); });
// What is in flight, and where the count was read: the table is the proxy's journal alone, so a
// client that talks to the engine on :30000 directly (a bench, a script) is counted by the engine
// and never appears in the table, and the Transcribe lane's requests are read on its own port
// (collect_transcribe: counts and port only, the key stays server-side). The badge follows the
// engine's count and its title says where each part was read; an engine that has not answered
// counts nothing (review, 2026-11-19).
function renderTraffic(){
const rows = F.feedRows || [];
const inflight = rows.filter(r => r.outcome === 'in flight').length;
const eng = engineCount();
const tr = F.transcribe || {};
const trN = tr.serving && tr.read === true ? (tr.running || 0) + (tr.waiting || 0) : 0;
const shown = (eng == null ? inflight : Math.max(eng, inflight)) + trN;
badge('traffic', shown ? String(shown) : '', shown ? 'live' : '');
const b = $('bdg-traffic');
if (b) b.title = !shown ? '' : [eng != null ? `${eng} in flight, counted by the engine on :30000` : null,
inflight ? `${inflight} relayed by the proxy on :30001` : null,
trN ? `${trN} on the NVIDIA Nemotron Transcribe lane, on :${tr.port}` : null]
.filter(Boolean).join('; ');
// "direct" only when the gap outlived a journal read (gapOutlivedFeed), over several engine
// reads, with the journal source fresh (its tier is 5 s): never while it may just not have
// been read yet
const feedAge = lastAges.feed;
const direct = eng == null ? 0
: (gapOutlivedFeed && gapReads >= 2 && feedAge != null && feedAge <= 6 ? Math.max(0, eng - inflight) : 0);
let c = $('feed-empty');
if (!rows.length && !c){
const er = $('feed').tBodies[0].insertRow(); er.className = 'empty';
c = er.insertCell(); c.colSpan = 6; c.setAttribute('id', 'feed-empty');
}
if (c) c.textContent = direct > 0
? `${eng} request${eng > 1 ? 's are' : ' is'} running on the engine, sent to :30000 directly, not through the proxy: their details are not in this table.`
: 'No request has gone through the proxy yet. Agent clients use :30001.';
const note = $('feed-note'), parts = [];
if (rows.length && direct > 0)
parts.push(`${direct} of the ${eng} in flight on the engine were sent to :30000 directly, not through the proxy: their details are not in this table`);
if (trN > 0)
parts.push(`${[tr.running ? `${tr.running} running` : '', tr.waiting ? `${tr.waiting} waiting` : ''].filter(Boolean).join(', ')} on the NVIDIA Nemotron Transcribe lane, which answers on its own port :${tr.port}, not through the proxy`);
else if (tr.serving && tr.read === false)
parts.push(`the NVIDIA Nemotron Transcribe lane serves on :${tr.port}, but its counters did not answer${tr.why ? ` (${tr.why})` : ''}`);
setText(note, parts.join('. ') + (parts.length ? '.' : ''));
show(note, parts.length > 0);
}
on('reqguard', d => {
const g = d.guard || {}, z = d.zombies || {};
F.toolTargets = d.tool_targets || null; // the banner of renderBanners (proxy v6.48)
F.resent = d.resent || null; // and the one of a long prompt sent again (proxy v6.49)
cap('zg-cap', d.state === 'err' ? 'leaking' : d.state === 'warn' ? 'check' : 'holding', d.state === 'err' ? 'err' : d.state === 'warn' ? 'warn' : 'ok');
setText('zg-verdict', `${cap1(d.verdict || '')} (last ${d.window || '10m'}${d.lane ? ', ' + d.lane : ''}).`);
setText('zg-ver', g.version ? 'v' + g.version : 'no banner in the journal');
// an SGLang setting, which the guard reads on the SGLang lanes only
setText('zg-override', d.override === true ? 'yes' : d.override === false ? 'no' : d.lane ? 'unknown (docker did not answer)'
: (servingEngine() || [])[0] === KOLIBRI_UNIT ? 'not on the Kolibri-1 lane (an SGLang setting)'
: isVllmTable((servingEngine() || [])[0]) ? `not on ${b12xName((servingEngine() || [])[0])} (an SGLang setting)`
: isLlamacpp((servingEngine() || [])[0]) ? `not on ${llamacppName((servingEngine() || [])[0])} (an SGLang setting)` : 'no engine');
const acted = [];
if (g.aborted) acted.push(`${g.aborted} aborted`);
if (g.drained) acted.push(`${g.drained} drained${g.drain_max_s != null ? `, longest ${g.drain_max_s.toFixed(0)} s` : ''}`);
if (g.abort_failed) acted.push(`${g.abort_failed} aborts unanswered`);
if (g.ceiling) acted.push(`${g.ceiling} hit the drain ceiling`);
setText('zg-acted', acted.length ? acted.join(', ') : 'nothing to do');
setText('zg-flood', z.lines ? `${fmtN(z.lines)} from ${z.distinct}` : '0');
const note = g.predates_abort ? 'Below v6.14 a client that gives up during prefill leaves a generation the proxy cannot name.'
: d.override === false ? 'Without SGLANG_ENABLE_REQUEST_HEADER_OVERRIDES the engine keeps its own request id, so an abandoned answer is read to its end. The next engine restart picks the flag up.' : '';
show('zg-note', !!note); setText('zg-note', note);
const rows = z.requests || [], tb = $('zg-table').tBodies[0]; clear(tb); show('zg-table', rows.length > 0);
rows.forEach(r => { const tr = tb.insertRow(); const a = tr.insertCell(); a.className = 'num'; a.textContent = r.rid.slice(0, 12);
const b = tr.insertCell(); b.className = 'r num'; b.textContent = fmtN(r.lines); const c = tr.insertCell(); c.className = 'r num'; c.textContent = r.secs != null ? `${r.secs.toFixed(0)} s` : ''; });
});
// ── Machine ───────────────────────────────────────────────────────────────────
on('machine', d => {
const m = d.mem || {};
const bx = d.box || {};
setText('mm-box', !bx.cls ? 'unknown' : bx.cls === '64'
? `${boxName(bx)}: the lanes that fit it, the others say they need 128 GB` : boxName(bx));
if (m.MemTotal){
const used = m.MemTotal - m.MemAvailable;
// the colour follows headroom in gibibytes, not a percentage: a loaded lane sits past
// 90 % by design, and an alarm that rings while all is fine teaches people to ignore it
const kind = m.MemAvailable < 4 * GIB ? 'err' : m.MemAvailable < 9 * GIB ? 'warn' : 'ok';
cap('mm-cap', fmtGiB(m.MemAvailable) + ' available', kind);
setText('mm-used', fmtGiB(used) + ' of ' + fmtGiB(m.MemTotal)); setText('mm-avail', fmtGiB(m.MemAvailable));
setText('mm-cache', fmtGiB(m.Cached)); setText('mm-swap', fmtGiB((m.SwapTotal || 0) - (m.SwapFree || 0)));
push('mem', used / GIB); drawSpark($('mm-spark'), 'mem', cssVar('--brand'), m.MemTotal / GIB);
badge('machine', m.MemAvailable < 4 * GIB ? fmtGiB(m.MemAvailable, 0) : '', m.MemAvailable < 4 * GIB ? 'err' : '');
}
const cpu = d.cpu_pct || {};
cap('cpu-cap', (cpu.cpu ?? 0).toFixed(0) + ' %', (cpu.cpu || 0) > 85 ? 'warn' : 'ok');
push('cpu', cpu.cpu || 0); drawSpark($('cpu-spark'), 'cpu', cssVar('--mem'), 100);
const cores = Object.keys(cpu).filter(k => k !== 'cpu').sort((a, b) => Number(a.slice(3)) - Number(b.slice(3)));
setText('cpu-n', String(cores.length)); setText('cpu-load', (d.load || []).map(x => x.toFixed(2)).join(', '));
const box = $('cpu-cores');
if (box.children.length !== cores.length){ clear(box); cores.forEach(() => { const c = el('span'); c.style.cssText = 'height:26px; border-radius:5px; background:var(--ink-3); transition:background .6s'; box.append(c); }); }
cores.forEach((k, i) => { const v = Math.min(100, cpu[k] || 0); box.children[i].style.background = `color-mix(in srgb, var(--mem) ${Math.round(v)}%, var(--ink-3))`; box.children[i].title = `${k}: ${v.toFixed(0)} %`; });
const dk = d.disks || {};
setText('dk-home', dk.home ? fmtGiB(dk.home.free) + ' free of ' + fmtGiB(dk.home.total) : 'n/a');
setText('dk-docker', dk.docker ? fmtGiB(dk.docker.free) + ' free of ' + fmtGiB(dk.docker.total) : 'n/a');
});
// On the Kolibri lane the pool guard cannot act: vLLM has no route that flushes its cache, and it
// read "armed" there (review, 2026-10-14).
const kolibriHolds = () => (servingEngine() || [])[0] === KOLIBRI_UNIT;
// the Nemotron lanes, the Qwen3.8 Flash-Next FP4-Local lane, Ornith and the Liquid AI LFM3 lane run on vLLM too
const nemotronHolds = () => isVllmTable((servingEngine() || [])[0]);
// and the llama.cpp lanes, which stop a request whose connection closes, as vLLM does (proxy v6.55)
const llamacppHolds = () => isLlamacpp((servingEngine() || [])[0]);
// The floor stops generations through the proxy since v1.40.3, on every lane: vLLM has no route that
// aborts a generation, and the proxy closes its connection, which vLLM stops (it said "cannot act" there).
on('engine_fast', d => {
if (!d.mem_floor) return;
const f = d.mem_floor, how = kolibriHolds() || nemotronHolds() ? ' (on vLLM, by closing their connections)'
: llamacppHolds() ? ' (on llama.cpp, by closing their connections)' : '';
setText('mm-floor', `stops generations under ${f.gib} GiB through the proxy${how}`
+ (f.aborts ? `, fired ${f.aborts} time${f.aborts > 1 ? 's' : ''}` : ', never fired'));
});
on('lifecycle', d => {
const g = d.pool_guard; if (!g) return;
if (kolibriHolds()){ setText('mm-guard', 'not on the Kolibri-1 lane: vLLM has no cache flush route, and evicts its prefix cache by itself'); return; }
if (nemotronHolds()){ setText('mm-guard', `not on ${b12xName((servingEngine() || [])[0])}: vLLM has no cache flush route, and evicts its prefix cache by itself`); return; }
// llama.cpp's neither: the guard, which flushes SGLang's cache, said "armed" on its lane (found by its test, 2026-11-12)
if (llamacppHolds()){ setText('mm-guard', `not on ${llamacppName((servingEngine() || [])[0])}: llama.cpp has no cache flush route, and evicts its prompt cache by itself`); return; }
setText('mm-guard', !g.enabled ? 'off (COCKPIT_POOL_GUARD=0)' : g.fails ? `cannot flush since ${clockTime(g.last_fail)}: ${g.last_err}`
: g.flushes ? `${g.flushes} flush${g.flushes > 1 ? 'es' : ''}, last ${clockTime(g.last)}, above ${Math.round(g.threshold * 100)} % held` : `armed at ${Math.round(g.threshold * 100)} % held, never fired`);
});
// nvidia-smi silent: no reading, said as such. It read a green "…", a power line falling to
// 0 W and "No process on the GPU" (found by the monkey check, 2026-10-02)
on('gpu', d => {
const t = d.temp_c;
setText('gpu-pow', d.power_w != null ? d.power_w.toFixed(1) + ' W' : 'n/a');
setText('gpu-temp', t != null ? t.toFixed(0) + ' °C' : 'n/a');
cap('gpu-cap', t != null ? t.toFixed(0) + ' °C' : 'n/a', t == null ? '' : t > 85 ? 'err' : t > 75 ? 'warn' : 'ok');
if (d.power_w != null) push('pow', d.power_w);
drawSpark($('gpu-spark'), 'pow', cssVar('--warn'), undefined, {empty: d.power_w == null ? 'no reading' : 'collecting…'});
const tb = $('gpu-procs').tBodies[0]; clear(tb);
(d.procs || []).slice(0, 6).forEach(p => { const tr = tb.insertRow(); tr.insertCell().textContent = p.name || '?';
const a = tr.insertCell(); a.className = 'r num'; a.textContent = p.pid; const b = tr.insertCell(); b.className = 'r num'; b.textContent = p.mem; });
if (!tb.rows.length){ const tr = tb.insertRow(); tr.className = 'empty'; const c = tr.insertCell(); c.colSpan = 3;
c.textContent = Array.isArray(d.procs) ? 'No process on the GPU.' : 'No reading: nvidia-smi did not answer.'; }
labelCells($('gpu-procs'));
});
on('kernel', d => { const n = d.nvrm_oom_1h;
setText('dk-nvrm', n == null ? 'n/a (the kernel log did not answer)' : n ? `${n}, the last at ${(d.nvrm_last || '').slice(11, 19)}` : 'none'); });
// ── the GPU clock cap (decision of 2026-11-11) ─────────────────────────────────
// What each cap cost and gave on the reference box, 2026-11-11: the Qwen3.8 Flash-Next FP4-Local lane at 4 streams,
// the same work at each cap (48 answers of 1,200 tokens), no cap measured again at the end. docs/cockpit.md carries
// the same numbers, which a test holds to these.
const GPU_CAPS = [
{cap: 'none', mhz: 2502, tps4: 105.74, w: 46.6, hot: 92.6, tps1: 56.20, prefill: 2078},
{cap: '2400', mhz: 2387, tps4: 105.87, w: 35.9, hot: 90.2, tps1: 56.22, prefill: 2073},
{cap: '2200', mhz: 2190, tps4: 103.77, w: 28.1, hot: 86.6, tps1: 55.50, prefill: 2027},
{cap: '2000', mhz: 1989, tps4: 103.15, w: 22.8, hot: 84.4, tps1: 54.62, prefill: 2004}];
const GPU_CAP_AGAIN = {cap: 'none', mhz: 2494, tps4: 105.02, w: 47.7, hot: 93.2, tps1: 56.38, prefill: 2080};
const GPU_CAP_LIMITS = 'One lane measured, a text one, and one run per cap (None twice, first and last): the image, video and 27B lanes '
+ 'are not measured yet. The watts are the GPU’s alone, as nvidia-smi reads them, not the whole box’s.';
// the hottest zone is the box's, the hottest of all its thermal zones, not the GPU's (review of v1.47.0)
const gpuCapFigures = m => `${m.tps4.toFixed(2)} tok/s at 4 streams, the GPU at ${m.w.toFixed(1)} W, the box’s hottest zone at ${m.hot.toFixed(1)} °C`;
// a sentence ends once: nvidia-smi's own words often end with their period
const gpuCapEnd = s => /[.!?]$/.test(s) ? s : s + '.';
// a try that failed, in the server's own words: a cap set and not kept (keep) says it was set, and a call that did
// not answer (timeout) is not said to have failed, since it may still apply
const gpuCapFailed = (error, tried, said) => gpuCapEnd(error === 'keep' ? said
: `${tried === 'none' ? 'Lifting the GPU clock cap' : `Capping the GPU clock at ${gpuCapName(tried)}`}${error === 'timeout' ? '' : ' failed'}: ${said}`);
// the sheet's words for a cap (EXPLAIN.gpu_clock in base.js): what it does now and at a reboot, what it cost and
// gave, the limits of that measurement
function gpuCapExplain(cap){
const m = GPU_CAPS.find(x => x.cap === cap), none = GPU_CAPS[0];
if (!m) return '';
// no nvidia-smi here: None runs nothing, and forgets the cap the cockpit keeps (job_gpu_clock)
if (cap === 'none' && GC.has === false) return `This machine has no /usr/bin/nvidia-smi, so nothing is run: the cockpit forgets the cap it `
+ `keeps for its next start${GC.kept && GC.kept !== 'none' ? ` (${gpuCapName(GC.kept)})` : ''}, which it cannot set here.`;
if (cap === 'none') return 'nvidia-smi lifts the cap now: the GPU runs at its own clocks again, the factory setting, and the cockpit '
+ `forgets the cap it kept for its next start. On the reference box, with no cap: ${gpuCapFigures(none)}. ${GPU_CAP_LIMITS}`;
return `nvidia-smi caps the GPU’s clock at ${gpuCapName(cap)} now, a generation in flight included, until the next reboot; the `
+ 'cockpit keeps the cap and sets it again at its start, which is at boot. '
+ `On the reference box: ${gpuCapFigures(m)}, against ${none.tps4.toFixed(2)} tok/s, ${none.w.toFixed(1)} W and `
+ `${none.hot.toFixed(1)} °C with no cap. ${GPU_CAP_LIMITS}`;
}
// what the last state said: the reason the caps are off (blocked), whether None stays on for a kept cap (freeNone),
// whether this machine has nvidia-smi (has) and the cap kept (kept), which the sheet reads
const GC = {blocked: null, freeNone: false, has: null, kept: null};
function wireGpuCap(){
const opts = [...$('gc-pick').querySelectorAll('button')];
opts.forEach(b => {
const m = GPU_CAPS.find(x => x.cap === b.dataset.cap);
b.dataset.act = 'gpu_clock';
b.dataset.title = `${b.dataset.cap === 'none' ? 'No cap' : gpuCapName(b.dataset.cap)}: ${gpuCapFigures(m)} on the reference box`;
b.addEventListener('click', () => askAction('gpu_clock', {cap: b.dataset.cap}, []));
});
// the arrow keys move the focus over the caps, and Enter or Space asks for the one it is on: a cap is a
// privileged change that asks first, so the arrows never ask by themselves
$('gc-pick').addEventListener('keydown', ev => {
const step = {ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1}[ev.key];
if (!step || ev.altKey || ev.ctrlKey || ev.metaKey) return;
ev.preventDefault();
const live = opts.filter(b => !b.disabled); if (!live.length) return;
const i = live.indexOf(document.activeElement);
live[(Math.max(0, i) + step + live.length) % live.length].focus();
});
const tb = $('gc-table').tBodies[0]; clear(tb);
GPU_CAPS.concat([GPU_CAP_AGAIN]).forEach((m, i) => {
const tr = tb.insertRow();
tr.insertCell().textContent = m.cap === 'none' ? (i ? 'None, again at the end' : 'None') : gpuCapName(m.cap);
[`${fmtN(m.mhz)} MHz`, `${m.tps4.toFixed(2)} tok/s`, `${m.w.toFixed(1)} W`, `${m.hot.toFixed(1)} °C`].forEach(v => {
const c = tr.insertCell(); c.className = 'r num sz'; c.textContent = v; });
});
labelCells($('gc-table'));
const none = GPU_CAPS[0], low = GPU_CAPS[GPU_CAPS.length - 1];
setText('gc-note', 'The reference box, 2026-11-11: the Qwen3.8 Flash-Next FP4-Local lane at 4 streams, the same work at each cap '
+ `(48 answers of 1,200 tokens). One stream and the prefill moved little, ${none.tps1.toFixed(2)} to ${low.tps1.toFixed(2)} tok/s `
+ `and ${fmtN(none.prefill)} to ${fmtN(low.prefill)} tok/s from no cap to ${gpuCapName(low.cap)}. ${GPU_CAP_LIMITS}`);
}
// What the server says of the cap (cockpit.py, gpu_clock_state): the clock nvidia-smi reads, whether this machine has the
// nvidia-smi the sudoers lines name, the cap kept for the cockpit's next start, and what the cockpit last did with
// it. The cap lit is the one in effect as far as the cockpit knows: the one it set last, else the one it keeps while
// its start sets it again, and None once that try failed (the GPU at its own clocks: the kept cap stayed lit, the final
// review of v1.47.0) or on a machine without nvidia-smi, where no cap can be set. A call that did not answer (timeout)
// may still set or lift the cap, nvidia-smi running as root: the lit cap stays the one before it, and the state says
// not known.
on('gpu', d => {
const c = d.clock; if (!c) return;
const has = !!c.nvidia_smi, pending = c.set == null && c.kept !== 'none', unknown = c.error === 'timeout';
const failed = pending && !!c.error && !unknown;
const lit = !has || failed ? 'none' : c.set != null ? c.set : c.kept;
GC.has = has; GC.kept = c.kept;
setText('gc-mhz', c.mhz != null ? `${fmtN(c.mhz)} MHz` : 'n/a (nvidia-smi did not answer)');
cap('gc-cap', !has ? 'not on this machine'
: pending ? `${gpuCapName(c.kept)}, ${unknown ? 'not known' : c.error ? 'not set' : 'being set'}` : unknown ? 'not known' : gpuCapName(lit),
!has ? '' : unknown ? 'warn' : pending ? (c.error ? 'err' : 'warn') : c.error ? 'warn' : lit === 'none' ? '' : 'ok', pending && !c.error ? 'live' : true);
const when = c.at ? ` at ${clockTime(c.at)}` : '';
// none from the cockpit is all it knows: a cap set by hand outside it is not read back (nvidia-smi gives no cap)
setText('gc-state', !has ? 'none: no nvidia-smi here'
: pending ? `${gpuCapName(c.kept)}, kept for the cockpit’s start: ${unknown ? 'not known, its last try did not answer'
: c.error ? 'not set, its last try failed' : 'being set again'}`
: unknown ? `not known: ${c.tried === 'none' ? 'the try to lift it' : `the try to cap it at ${gpuCapName(c.tried)}`} did not answer, and may still apply`
: lit === 'none' ? (c.set === 'none' ? `none, lifted${when}: the GPU runs at its own clocks` : 'none set from the cockpit')
: `${gpuCapName(lit)}, set${c.origin === 'boot' ? ' again at the cockpit’s start' : ''}${when}`);
const m = GPU_CAPS.find(x => x.cap === lit);
setText('gc-line', m ? `${lit === 'none' ? 'No cap, the factory setting' : gpuCapName(lit)}: ${gpuCapFigures(m)} on the reference box.` : '');
// what failed last, and what to do: the server's own sentence (a refused sudo names the installer to run again)
const why = !has ? 'This machine has no /usr/bin/nvidia-smi, the one the cockpit’s sudoers lines name: the GPU clock cannot be capped from here.'
+ (c.kept !== 'none' ? ` The cockpit keeps ${gpuCapName(c.kept)} for its start, which it cannot set here: None forgets it.` : '')
: c.error ? gpuCapFailed(c.error, c.tried, c.said)
: c.kept_bad ? `The file the cockpit keeps its cap in (cockpit-gpu-clock.json) was not used: ${c.kept_bad}.` : '';
show('gc-why', !!why); setText('gc-why', why);
[...$('gc-pick').querySelectorAll('button')].forEach(b => { b.setAttribute('aria-checked', String(b.dataset.cap === lit)); b.tabIndex = b.dataset.cap === lit ? 0 : -1; });
// no nvidia-smi: every cap is off, with why, but None while a cap is kept, which it forgets (the server runs nothing
// then); applyBusy owns the disabled state of every action control
const blocked = has ? '' : why, freeNone = !has && c.kept !== 'none';
if (GC.blocked !== blocked || GC.freeNone !== freeNone){
GC.blocked = blocked; GC.freeNone = freeNone;
$('gc-pick').querySelectorAll('button').forEach(b => {
const own = freeNone && b.dataset.cap === 'none' ? '' : blocked;
if (own) b.dataset.blocked = own; else delete b.dataset.blocked; });
applyBusy();
}
});
// what a cap's job did, once it ends: the server's own sentence, and the panel above already reads the outcome
on('job_finished', j => {
if (j.action !== 'gpu_clock') return;
const r = j.result || {}, tried = (j.params || {}).cap;
if (r.dry_run) return toast(`${cap1(actionPhrase(j.action, j.params))}: dry run, nothing was run.`, 'ok');
if (j.status === 'done') return toast(gpuCapEnd(r.said || cap1(actionPhrase(j.action, j.params)) + ': done'), 'ok');
toast(gpuCapFailed(r.error, tried, r.said || 'open its log in Logs'), 'err', 9000);
});
// ── Library (on demand: each scan says what happened) ─────────────────────────
function tag(t, kind){ return el('span', 'tag' + (kind ? ' ' + kind : ''), t); }
function emptyRow(tb, n, txt){ const tr = tb.insertRow(); tr.className = 'empty'; const c = tr.insertCell(); c.colSpan = n; c.textContent = txt; }
function fmtServe(sv){
const parts = [];
if (sv.context_length) parts.push('ctx ' + fmtN(sv.context_length));
if (sv.mem_fraction != null) parts.push('mem ' + sv.mem_fraction);
if (sv.max_running_requests) parts.push('run ' + sv.max_running_requests);
if (sv.max_total_tokens) parts.push('pool ' + fmtN(sv.max_total_tokens));
if (sv.chunked_prefill) parts.push('chunk ' + sv.chunked_prefill);
const attn = sv.attention_backend || [sv.prefill_attention, sv.decode_attention].filter(Boolean).join('/');
if (attn) parts.push(attn);
return parts.join(', ');
}
function recipeRow(tb, row){
const r = row.recipe, tr = tb.insertRow(); const c0 = tr.insertCell();
if (r){ c0.append(tag(r.lane === 'flash' ? 'flash' : '27B', 'gold'), ' ', el('strong', null, r.id)); if (row.installed) c0.append(' ', tag('installed', 'cool')); if (!r.builtin) c0.append(' ', tag(row.file || 'custom')); }
else c0.append(tag(row.file || '?', 'err'));
if (row.errors && row.errors.length){ const td = tr.insertCell(); td.colSpan = 6; td.append(tag('invalid', 'err'), ' ', row.errors.join('; ')); return; }
// the engine and its version when the recipe runs the image its lane pins (decision 1178); an image of the
// operator's is named by itself, as before
const img = r.engine.image.replace(/@sha256:([0-9a-f]{12})[0-9a-f]+/, '@$1…');
const pinned = (F.engineTable || {})[r.lane === 'flash' ? UFLASH : U27];
const c1 = tr.insertCell(); c1.title = r.engine.image;
if (pinned && pinned.pin === r.engine.image) c1.append(pinned.label, ' ', el('span', 'faint num', img));
else { c1.className = 'num'; c1.textContent = img; }
const c2 = tr.insertCell(); c2.textContent = r.model.repo.split('/').pop() + ' '; c2.append(el('span', 'faint num', r.model.revision.slice(0, 10)));
const dr = r.drafter || {};
tr.insertCell().textContent = dr.algorithm === 'none' || !dr.algorithm ? 'none' : dr.algorithm + (dr.repo ? ' ' + dr.repo.split('/').pop() : ' (own head)') + (dr.draft_tokens ? ', ' + dr.draft_tokens + ' tokens' : '');
tr.insertCell().textContent = fmtServe(r.serve || {});
const p = row.presence || {}, cc = tr.insertCell();
[['image', p.image], ['model', p.model], ['drafter', p.drafter]].forEach(([k, v]) => cc.append(tag(v === true ? k : v === false ? k + ' missing' : k + ' n/a', v === false ? 'err' : ''), ' '));
if (p.downloading) cc.append(tag('downloading', 'warn'));
const cd = tr.insertCell();
if (row.drift == null) cd.append(tag('lane not installed'));
else if (!row.drift.length) cd.append(tag('matches', 'cool'));
else { const det = el('details'); const sum = el('summary'); sum.append(tag(row.drift.length + ' differ', row.installed ? 'warn' : '')); det.append(sum);
const ul = el('ul'); ul.style.cssText = 'margin:6px 0 0 16px; font-size:12px';
row.drift.forEach(x => ul.append(el('li', 'num', `${x.key}: recipe ${JSON.stringify(x.recipe)}, installed ${JSON.stringify(x.installed)}`))); det.append(ul); cd.append(det); }
}
const LOADED = {recipes: false, registry: false};
async function loadRecipes(){
const b = $('rcp-btn'); setText(b, 'Loading…'); b.disabled = true;
try{
const r = await fetch('/api/recipes?refresh=1'); if (r.status === 401) return login(); if (!r.ok) throw new Error('HTTP ' + r.status);
const d = await r.json(); LOADED.recipes = true;
const tb = $('rcp-table').tBodies[0]; clear(tb);
(d.builtin || []).forEach(row => recipeRow(tb, row)); (d.custom || []).forEach(row => recipeRow(tb, row));
if (!tb.rows.length) emptyRow(tb, 7, 'No recipe found.');
labelCells($('rcp-table'));
setText('rcp-dir', d.custom_dir ? `Custom recipes live in ${d.custom_dir}.` : '');
const inst = (d.builtin || []).concat(d.custom || []).filter(x => x.installed).map(x => x.recipe.id);
const drift = (d.builtin || []).filter(x => x.installed && x.drift && x.drift.length).length;
setText('rcp-line', (inst.length ? 'Installed: ' + inst.join(', ') + '.' : 'No installed lane has a recipe: the built-in ones cover the 27B and flash lanes.') + (drift ? ` ${drift} installed lane differs from its recipe (open the difference).` : ''));
setText('rcp-age', 'read ' + new Date().toLocaleTimeString([], {hour12: false}));
badge('library', drift ? `${drift} drift` : '', 'warn'); setText(b, 'Reload');
}catch(e){ setText('rcp-line', 'Could not load the recipes: ' + e.message); setText(b, 'Retry'); }
finally{ b.disabled = false; }
}
// Library's Delete of one repository: the server's plan first (what it frees on which disk, what it keeps and why,
// who reads it now, the Hub's verdict per revision), then the sheet. Read now by anything: said, and no sheet. Not
// served by the Hub as it is here: said in the sheet, whose button then reads "Delete it anyway" (lose=yes).
// what another project of the box keeps (~/.config/qwen38/library-keep): said, with no Delete
const keptTag = who => { const k = el('span', 'muted', `kept for ${who}`); k.title = 'listed in ~/.config/qwen38/library-keep'; return k; };
function deleteRepoButton(repo, cache){
const b = el('button', 'btn sm ghost', 'Delete'); b.type = 'button';
b.setAttribute('aria-label', `Delete ${repo} from the cache`);
b.addEventListener('click', () => askDeleteRepo(repo, cache, b));
return b;
}
async function askDeleteRepo(repo, cache, b){
const was = b.textContent; b.disabled = true; setText(b, 'Checking…');
try{
const r = await fetch('/api/registry/plan?repo=' + encodeURIComponent(repo) + '&cache=' + encodeURIComponent(cache)); if (r.status === 401) return login();
const d = await r.json();
if (d.refused) return toast(`${repo} stays: ${d.refused}.`, 'warn');
if (!r.ok) throw new Error(d.error || 'HTTP ' + r.status);
if ((d.readers || []).length) return toast(`${repo} is read now by ${d.readers.join('; ')}: stop that first.`, 'warn');
REG_DELETE.plan = d;
const what = {differs: 'served otherwise', absent: 'not served', unverified: 'too large to check by its content'};
const warns = (d.revisions || []).filter(rv => !rv.identical).map(rv => `Revision ${rv.rev.slice(0, 10)}: `
+ (rv.error || Object.keys(what).flatMap(k => (rv[k] || []).map(f => `${f} ${what[k]}`)).join(', '))
+ '. The Hub may not give it back as it is here: deleting it can lose it for good.');
if (!(d.revisions || []).length) warns.push('No revision of it to compare with the Hub: deleting it can lose it for good.');
if ((d.reloads || []).length) warns.push(`The next Load of ${d.reloads.map(t => TARGET_NAME[t] || t).join(', ')} downloads it again.`);
askAction('delete_repo', {repo, cache, lose: d.identical ? 'no' : 'yes'}, warns, {danger: true});
}catch(e){ toast('Could not plan the delete: ' + e.message, 'err'); }
finally{ b.disabled = false; setText(b, was); }
}
// Library's Delete of an engine image: the server's plan first (its names, the bytes only it holds, the containers
// and the serving lanes that keep it, whether its registry still serves it or its lane builds it), then the sheet
function deleteImageButton(id){
const b = el('button', 'btn sm ghost', 'Delete'); b.type = 'button';
b.setAttribute('aria-label', `Delete the engine image ${id}`);
b.addEventListener('click', () => askDeleteImage(id, b));
return b;
}
async function askDeleteImage(id, b){
const was = b.textContent; b.disabled = true; setText(b, 'Checking…');
try{
const r = await fetch('/api/registry/image-plan?id=' + encodeURIComponent(id)); if (r.status === 401) return login();
const d = await r.json();
if (d.refused) return toast(`The image ${id} stays: ${d.refused}.`, 'warn');
if (!r.ok) throw new Error(d.error || 'HTTP ' + r.status);
const users = (d.units || []).concat((d.containers || []).map(c => 'the container ' + c));
if (users.length) return toast(`The image ${id} is used by ${users.join('; ')}: stop that first.`, 'warn');
REG_DELETE.image = d;
const warns = [];
if (!d.obtainable) warns.push('No registry serves it now and no lane builds it: deleting it can lose it for good.');
if ((d.reloads || []).length) warns.push(`The next Load of ${d.reloads.map(u => LANE_NAME[u] || laneLabel(u)).join(', ')} pulls or builds it again.`);
askAction('delete_image', {image: id, lose: d.obtainable ? 'no' : 'yes'}, warns, {danger: true});
}catch(e){ toast('Could not plan the delete: ' + e.message, 'err'); }
finally{ b.disabled = false; setText(b, was); }
}
// fresh: Scan reads the cache again; opening the view shows the server's own read, which the
// recipes' load has just refreshed
async function scanRegistry(fresh = true){
const b = $('reg-btn'); setText(b, 'Scanning…'); b.disabled = true;
try{
const r = await fetch(fresh ? '/api/registry?refresh=1' : '/api/registry'); if (r.status === 401) return login(); if (!r.ok) throw new Error('HTTP ' + r.status);
const d = await r.json(); LOADED.registry = true;
// each disk: what is free, and what the models, Docker's images and the runtimes hold there
const dk = $('reg-disks'); clear(dk);
(d.disks || []).forEach(x => { const parts = [['models', 'models'], ['docker', "Docker's images (every project's)"], ['runtimes', 'runtimes and caches']].filter(([k]) => x[k]).map(([k, w]) => `${w} ${fmtGiB(x[k])}`);
dk.append(el('span', null, `${x.mount}: ${fmtGiB(x.free, 0)} free of ${fmtGiB(x.total, 0)}` + (parts.length ? ` (${parts.join(', ')})` : '')), el('br')); });
const tb = $('reg-models').tBodies[0]; clear(tb);
const offered = [];
(d.models || []).forEach(m => (m.revisions || []).forEach((rv, i) => {
const tr = tb.insertRow(); tr.insertCell().textContent = i ? '' : m.repo_id.split('/').pop();
const a = tr.insertCell(); a.className = 'num'; a.textContent = rv.rev.slice(0, 10);
const b2 = tr.insertCell(); b2.className = 'r num sz'; b2.textContent = fmtGiB(rv.bytes);
const c = tr.insertCell(); c.className = 'r num sz'; c.textContent = i ? '' : fmtGiB(m.disk_bytes);
const s = tr.insertCell(); s.append(tag(rv.status, rv.status === 'pinned' ? 'cool' : rv.status === 'stray' ? 'warn' : '')); if (rv.pin) s.append(' ', tag(rv.pin));
// a stray revision: what deleting it frees, or why it stays (the header's button deletes them)
const del = rv.delete;
if (del && del.bytes != null){ offered.push({repo: m.repo_id, rev: rv.rev, bytes: del.bytes}); s.append(' ', el('span', 'muted', `frees ${fmtGiB(del.bytes)}`)); }
else if (del && del.refused) s.append(' ', el('span', 'muted', `kept: ${del.refused}`));
// the whole repository, on its first row: Library's Delete (deleteRepoButton)
if (!i) s.append(' ', m.keep ? keptTag(m.keep) : deleteRepoButton(m.repo_id, m.cache));
}));
REG_STRAYS.list = offered; REG_STRAYS.bytes = offered.reduce((a, x) => a + x.bytes, 0);
const rd = $('reg-del'); rd.hidden = !offered.length;
setText(rd, `Delete ${offered.length} stray revision${offered.length === 1 ? '' : 's'}, frees ${fmtGiB(REG_STRAYS.bytes)}`);
if (!tb.rows.length) emptyRow(tb, 5, 'No managed model in the Hugging Face cache.');
labelCells($('reg-models'));
// each target a Load can switch to: its checkpoint here, begun or not, and Download where its lane is installed
const tt = $('reg-targets').tBodies[0]; clear(tt);
(d.targets || []).forEach(t => {
const tr = tt.insertRow(); tr.insertCell().textContent = TARGET_NAME[t.target] || t.target;
tr.insertCell().textContent = String(t.repo || '').split('/').pop();
const st = tr.insertCell();
// unknown: its pin was not read this time (a checkout rewriting its installer): nothing offered until the next scan
if (t.state === 'unknown'){ st.append(tag('not read', 'warn'), ' ', el('span', 'muted', 'what it needs was not read in its installer; nothing is offered until a scan reads it')); return; }
st.append(tag(t.state === 'complete' ? 'on disk' : t.state === 'incomplete' ? 'begun' : 'not downloaded', t.state === 'complete' ? 'cool' : 'warn'));
// a lane installed on demand and not prepared yet: the download runs in the image or the
// venv its first Load builds, so that Load is what downloads it
const lane = SIDE_LANE[TARGET_UNIT(t.target)], unbuilt = !!lane && (F.lanesReady || {})[lane] === false;
if (t.state !== 'complete' && !targetFits(t.target)) st.append(' ', el('span', 'muted', `it ${NEEDS_128}`));
else if (t.state !== 'complete' && t.installed && !unbuilt){
const b4 = el('button', 'btn sm ghost', t.state === 'incomplete' ? 'Finish the download' : 'Download'); b4.type = 'button';
b4.addEventListener('click', () => askAction('fetch', {target: t.target}));
st.append(' ', b4);
} else if (t.state !== 'complete') st.append(' ', el('span', 'muted', t.installed ? 'its first Load downloads it' : 'its lane is not installed'));
});
if (!tt.rows.length) emptyRow(tt, 3, 'No target.');
labelCells($('reg-targets'));
const ti = $('reg-images').tBodies[0]; clear(ti);
// an image named by its digest is one word of 70 characters: allowed to break anywhere, it no
// longer widens its column past the panel and pushes Size and ID out of view on a desk screen
// one Delete per image, on the first of its names: docker rmi of one name only takes that name away
const imgSeen = new Set();
(d.images || []).forEach(im => { const tr = ti.insertRow(); const n = tr.insertCell(); n.className = 'brk'; n.textContent = im.ref; const a = tr.insertCell(); a.className = 'r num sz'; a.textContent = im.size; const c = tr.insertCell(); c.className = 'r num'; c.textContent = im.id; const x = tr.insertCell(); if (!imgSeen.has(im.id)){ imgSeen.add(im.id); x.append(im.keep ? keptTag(im.keep) : deleteImageButton(im.id)); } });
if (!ti.rows.length) emptyRow(ti, 4, 'No engine image.');
labelCells($('reg-images'));
// the lanes' runtimes and the diffusion runtime's caches: what each holds, on which disk, and its Delete
const tr2 = $('reg-runtimes').tBodies[0]; clear(tr2);
(d.runtimes || []).forEach(rt => { const tr = tr2.insertRow(); const n = tr.insertCell(); n.textContent = RUNTIME_NAME[rt.item] || rt.item; n.append(' ', el('span', 'muted', `on ${rt.mount}`)); const s = tr.insertCell(); s.className = 'r num sz'; s.textContent = fmtGiB(rt.bytes); const x = tr.insertCell(); const b5 = el('button', 'btn sm ghost', 'Delete'); b5.type = 'button'; b5.setAttribute('aria-label', `Delete the ${RUNTIME_NAME[rt.item] || rt.item}`); b5.addEventListener('click', () => { REG_DELETE.runtime = rt; askAction('delete_runtime', {item: rt.item}, [], {danger: true}); }); x.append(b5); });
if (!tr2.rows.length) emptyRow(tr2, 3, 'None on this box.');
labelCells($('reg-runtimes'));
const to = $('reg-other').tBodies[0]; clear(to);
const others = (d.other_models || []).slice().sort((x, y) => y.disk_bytes - x.disk_bytes);
others.forEach(m => { const tr = to.insertRow(); const n = tr.insertCell(); n.textContent = m.repo_id; n.append(' ', m.keep ? keptTag(m.keep) : deleteRepoButton(m.repo_id, m.cache)); const c = tr.insertCell(); c.className = 'r num sz'; c.textContent = fmtGiB(m.disk_bytes); });
if (!others.length) emptyRow(to, 2, 'None.');
setText('reg-other-tag', others.length ? fmtGiB(others.reduce((a, m) => a + m.disk_bytes, 0)) + ' in ' + others.length : '');
const strays = (d.models || []).flatMap(m => m.revisions).filter(rv => rv.status === 'stray');
setText(b, strays.length ? `Rescan (${strays.length} stray)` : 'Rescan'); setText('reg-age', (d.partial || []).length ? 'scan incomplete, nothing deleted and nothing offered for what it missed: ' + d.partial.join(', ') : 'scanned ' + new Date().toLocaleTimeString([], {hour12: false}));
}catch(e){ setText(b, 'Retry'); setText('reg-age', 'scan failed: ' + e.message); }
finally{ b.disabled = false; }
}
async function checkUpstream(){
const b = $('up-btn'); setText(b, 'Checking…'); b.disabled = true;
try{
const r = await fetch('/api/upstream?refresh=1'); if (r.status === 401) return login(); if (!r.ok) throw new Error('HTTP ' + r.status);
const d = await r.json(), tb = $('up-table').tBodies[0]; clear(tb);
(d.models || []).forEach(m => { const tr = tb.insertRow(); tr.insertCell().textContent = m.model.split('/').pop();
const a = tr.insertCell(); a.className = 'num'; a.textContent = m.pin; const c = tr.insertCell(); c.className = 'num'; c.textContent = m.upstream || '?';
tr.insertCell().append(tag(m.status, m.status === 'same' ? 'cool' : m.status === 'moved' ? 'warn' : 'err')); });
labelCells($('up-table'));
const rel = d.release || {}, stale = rel.stale_code || [];
const relLine = rel.latest ? `Release: this box ${rel.local}, latest ${rel.latest}` + (rel.behind ? ', an update is out.'
: rel.ahead ? ', this box runs a version newer than the latest release.' : rel.latest === rel.local ? ', up to date.' : '.')
: 'The release check is offline (no network, or GitHub unreachable).';
setText('up-line', stale.length ? `This cockpit runs code older than the repo (${stale.join(', ')} changed on disk): restart it. ${relLine}` : relLine);
const moved = (d.models || []).filter(m => m.status === 'moved').length;
setText(b, moved ? `Recheck (${moved} moved)` : 'Recheck');
}catch(e){ setText(b, 'Retry'); setText('up-line', 'The check failed: ' + e.message); }
finally{ b.disabled = false; }
}
async function scanInventory(){
const b = $('inv-btn'); setText(b, 'Scanning…'); b.disabled = true;
try{
const r = await fetch('/api/inventory'); if (r.status === 401) return login(); if (!r.ok) throw new Error('HTTP ' + r.status);
const d = await r.json(), tb = $('inv-table').tBodies[0]; clear(tb);
(d.items || []).forEach(i => { const tr = tb.insertRow(); tr.insertCell().append(tag(i.kind)); tr.insertCell().textContent = i.what; });
if (!(d.items || []).length) emptyRow(tb, 2, 'Nothing found. Is the repo installed on this box?');
setText(b, 'Rescan'); setText('inv-line', `${(d.items || []).length} items, scanned ${new Date().toLocaleTimeString([], {hour12: false})}.`);
}catch(e){ setText(b, 'Retry'); setText('inv-line', 'The scan failed: ' + e.message); }
finally{ b.disabled = false; }
}
// A job that changes the lanes or the caches: Library reads them again, at once when it is open,
// else at its next opening. The checkpoints were read once per page, so a Load or a Download
// made elsewhere left Library saying what was there before (found in review, 2026-10-15).
on('job_finished', j => {
if (['switch', 'unit', 'prepare'].includes(j.action)) LOADED.recipes = false;
if (['switch', 'prepare', 'fetch', 'delete_strays', 'delete_repo', 'delete_image', 'delete_runtime'].includes(j.action)) LOADED.registry = false;
if (activeView === 'library'){ if (!LOADED.recipes) loadRecipes(); if (!LOADED.registry) scanRegistry(); }
});
// the registry with them: the checkpoints, what each lane can load (its Download), the images
// and the other models waited for a Scan, below recipes the same opening had read (2026-10-15)
onShow('library', async () => { if (!LOADED.recipes) await loadRecipes(); if (!LOADED.registry) scanRegistry(false); });
// ── Logs ──────────────────────────────────────────────────────────────────────
const LOGS_WANT = {src: null};
let followTimer = null, logTouched = false, logLines = [];
// What the box asks its own engine, dimmed so the engine's words stand out: the cockpit's
// load every second and its engine read every 30 s (current routes and the legacy ones),
// the health probes, the video poll. The load alone filled the whole view (2026-10-02). The
// Kolibri engine logs every request: its metrics read every few seconds, its version and its
// model list were the whole of its journal (2026-10-15). Dimmed when they were answered (an
// engine's 200, the proxy's "ok get") and not otherwise: the proxy's journal is its clients'
// requests too, and their refusals (a 401 without the key, a 503 with no engine) were dimmed
// among thousands of lines (found in review, 2026-10-15).
const POLLED = /GET \/(health|v1\/videos|v1\/loads|server_info|get_load|get_server_info|metrics|version|v1\/models)\b.*?(" 200 |\bok get\b)/;
function drawLog(){
const v = $('log-view'), q = $('log-filter').value.trim().toLowerCase();
clear(v);
const lines = q ? logLines.filter(l => l.toLowerCase().includes(q)) : logLines;
if (!lines.length){ v.textContent = logLines.length ? 'No line matches the filter.' : 'This source has no output yet.'; return; }
lines.forEach((ln, i) => {
const cls = /error|exception|traceback|failed|fatal/i.test(ln) ? 'l-err' : /warn/i.test(ln) ? 'l-warn' : /ready to roll|started|ready\b|succeeded/i.test(ln) ? 'l-ok'
: POLLED.test(ln) ? 'l-dim' : '';
const sp = el('span', cls || null, ln);
v.append(sp); if (i < lines.length - 1) v.append('\n');
});
v.scrollTop = v.scrollHeight;
}
async function tailLog(){
const src = $('log-src').value;
try{
const r = await fetch('/api/logs/' + src); if (r.status === 401) return login(); if (!r.ok) throw new Error('HTTP ' + r.status);
const d = await r.json(); logLines = d.lines || []; drawLog();
// the engines write their times in UTC; the server rewrote them in the box's own time
const n = d.local_stamps || 0;
show('log-note', n > 0);
setText('log-note', n ? `Times shown in this box's local time${d.tz ? ' (' + d.tz + ')' : ''}: the engine writes them in UTC.` : '');
}catch(e){ logLines = []; show('log-note', false); setText('log-view', `Could not read ${src}: ${e.message}`); }
}
// The Logs sources this box does not have are refused in the list itself, not offered to fail on
// read (review of v1.53.0, 2026-11-19): each option's unit is its own name with .service, and an
// absent lane's container and journal both go disabled, with the reason as the title. The agent's
// journal follows the agent collector, as before.
function refreshLogSources(){
const sel = $('log-src'); if (!sel) return;
[...sel.options].forEach(o => {
if (o.id === 'log-opt-agent') return;
// the speech lane is no lane of the units collector: its own collector says whether it is here (v1.58)
if (o.id === 'log-opt-speech'){
const has = !!(F.speech && F.speech.installed);
o.disabled = !has; if (has) o.removeAttribute('title'); else o.title = 'The speech lane is not installed on this box';
return;
}
const unit = o.value.endsWith('.service') ? o.value : o.value + '.service';
if (installed(unit)){ o.disabled = false; o.removeAttribute('title'); }
else { o.disabled = true; o.title = `${LANE_NAME[unit] || unit} is not installed on this box`; }
});
}
on('units', refreshLogSources);
on('speech', refreshLogSources);
function wireLogs(){
refreshLogSources();
$('log-btn').addEventListener('click', () => { setText('log-view', 'Reading…'); tailLog(); });
$('log-src').addEventListener('change', () => { logTouched = true; tailLog(); });
$('log-filter').addEventListener('input', drawLog);
wireCopyButton($('log-copy'), () => logLines.join('\n'), 'Copy the log');
$('log-follow').addEventListener('change', () => {
if (followTimer){ clearInterval(followTimer); followTimer = null; }
if ($('log-follow').checked){ tailLog(); followTimer = setInterval(() => { if (activeView === 'logs' && !document.hidden) tailLog(); }, 3000); }
});
}
// The source the page sends you to: the lane's journal when it has no container or failed.
function defaultLogSource(){
const s = servingEngine(); const u = LOGS_WANT.src || (s ? s[0] : enabledUnit());
const e = engines()[u] || {};
// the speech lane has a journal and no container (v1.58: its card's Journal button opened the 27B's container log)
if (isImageLane(u) || u === VIDEO_UNIT || u === PROXY_UNIT || u === SPEECH_UNIT || e.state === 'failed' || e.restarting) return u;
return u === UFLASH ? 'qwen38-flash' : u === KOLIBRI_UNIT ? 'qwen38-kolibri' : u === NEMOTRON_UNIT ? 'qwen38-nemotron'
: u === NEMOTRON_SUPER_UNIT ? 'qwen38-nemotron-super' : u === FLASH_LOCAL_UNIT ? 'qwen38-flash-local'
: u === ORNITH_UNIT ? 'qwen38-ornith-122b' : u === FLASH_UNSLOTH_UNIT ? 'qwen38-flash-unsloth'
: u === TRANSCRIBE_UNIT ? 'qwen38-transcribe'
: u === LFM25_UNIT ? 'qwen38-lfm25' : u === LFM3_UNIT ? 'qwen38-lfm3' : u === INKLING_UNIT ? 'qwen38-inkling' : 'qwen38-sglang';
}
onShow('logs', () => {
if (LOGS_WANT.src || !logTouched){ $('log-src').value = defaultLogSource(); LOGS_WANT.src = null; }
tailLog();
});
// jobs history: one row per job, kept by id and updated in place
const JOB_ROWS = new Map();
on('job', d => {
const hist = $('job-hist'); const all = (d.current ? [d.current] : []).concat(d.recent || []);
const ids = new Set(all.map(j => j.id));
JOB_ROWS.forEach((r, id) => { if (!ids.has(id)){ r.row.remove(); JOB_ROWS.delete(id); } });
const none = hist.querySelector('.none');
if (!all.length){ if (!none) hist.append(el('p', 'none faint', 'No job has run since the cockpit started.')); } else if (none) none.remove();
all.forEach((j, i) => {
let r = JOB_ROWS.get(j.id);
if (!r){
r = {row: el('div'), lamp: el('span', 'lamp'), what: el('span'), when: el('span', 'faint num'), btn: el('button', 'btn sm ghost', 'Log')};
r.row.style.cssText = 'display:grid; grid-template-columns:auto 1fr auto auto; gap:var(--s-3); align-items:center; padding:10px 0; border-top:1px solid var(--rule-1); font-size:var(--t-14)';
r.btn.type = 'button'; r.btn.addEventListener('click', () => showJobLog(j.id));
r.row.append(r.lamp, r.what, r.when, r.btn); JOB_ROWS.set(j.id, r);
}
r.lamp.className = 'lamp ' + (j.status === 'running' ? 'warn live' : j.status === 'done' ? 'ok' : 'err');
setText(r.what, describeJob(j)); setText(r.when, clockTime(j.started) + ', ' + fmtDur(j.elapsed));
if (hist.children[i] !== r.row) hist.insertBefore(r.row, hist.children[i] || null);
});
});
async function showJobLog(id){
const v = $('job-hist-log'); v.hidden = false; v.textContent = 'Loading…';
try{ const r = await fetch('/api/jobs/' + id); if (r.status === 401) return login();
if (r.status === 404){ v.textContent = 'This job is no longer in memory (the cockpit restarted); the audit log has its outcome.'; return; }
const j = await r.json(); v.textContent = `$ ${(j.argv || [j.action]).join(' ')}\n` + (j.lines || []).join('\n') + `\n[${j.status}${j.rc != null ? ', exit code ' + j.rc : ''}, ${fmtDur(j.elapsed)}]`; }
catch(e){ v.textContent = 'Could not load the job: ' + e.message; }
}
afterApply(() => { if (activeView === 'logs') renderEvents($('log-events'), 40); });
onShow('logs', () => renderEvents($('log-events'), 40));
on('agent', d => { const o = $('log-opt-agent'); if (o) o.hidden = !d.enabled; });
// ── Settings ──────────────────────────────────────────────────────────────────
on('opencode', d => {
const bad = d.real.error ? 'unknown: the config does not parse' : null;
const lim = l => bad || (l && l.context ? `${fmtN(l.context)} context, ${fmtN(l.output || 0)} out` : 'not declared');
setText('oc-lim27', lim((d.real.limits || {})['qwen38/qwen3.8-27b'])); setText('oc-limflash', lim((d.real.limits || {})['flashnext/qwen3.8-flash-next']));
// the default model's own limits as a first row, when they are not one of the two above: after a
// Load of Kolibri, LFM3 or another lane, the two rows named lanes that do not serve (review of
// v1.53.0, 2026-11-19)
const defKey = d.real.default || '';
const defLim = defKey ? (d.real.limits || {})[defKey] : null;
const showDef = !!defLim && defKey !== 'qwen38/qwen3.8-27b' && defKey !== 'flashnext/qwen3.8-flash-next';
show('oc-limdef-k', showDef); show('oc-limdef', showDef);
if (showDef){
setText('oc-limdef-k', `Limits, ${defKey.includes('/') ? defKey.split('/').slice(1).join('/') : defKey}`);
setText('oc-limdef', lim(defLim));
}
if (!d.enabled){
show('oc-limdef-k', false); show('oc-limdef', false);
cap('oc-cap', 'off', ''); setText('oc-state', 'off (installed with --no-opencode)' + (d.off_note ? `, ${d.off_note}` : ''));
setText('oc-default', d.real.present ? (bad || d.real.default || 'none') + ' (your own config, never touched)' : 'no opencode config on this box');
setText('oc-launcher', d.launcher.present ? (d.launcher.ours ? 'this repo’s oc is still there (stale)' : 'a foreign oc') : 'none');
show('oc-cmd', false); setText('oc-note', 'Switches leave your opencode default model alone. Turn the integration back on with ./install.sh --with-opencode');
badge('settings', '', ''); return;
}
const ok = d.follows;
cap('oc-cap', ok === true ? 'follows the lane' : ok === false ? 'differs' : 'on', ok === true ? 'ok' : ok === false ? 'warn' : '');
setText('oc-state', 'on, config ' + (d.real.error ? `present but unreadable (${d.real.error})` : d.real.present ? 'present' : 'missing (copy ~/.config/qwen38/opencode.json to ~/.config/opencode/)'));
setText('oc-default', (bad || d.real.default || 'none') + ': ' + d.why);
setText('oc-launcher', d.launcher.present ? (d.launcher.ours ? `oc, output cap ${d.launcher.cap ? fmtN(d.launcher.cap) : '?'}` : 'a foreign oc, launcher not installed') : 'missing (re-run ./install.sh)');
const f = d.fit;
setText('oc-fit', !f ? 'unknown until an engine serves' : f.ok ? `fits: prompt up to ${fmtN(f.context)} of ${fmtN(f.prompt_cap)}, with the answer ${fmtN(f.worst)} of ${fmtN(f.usable)}`
: `too large, ${f.why}: ${fmtN(f.asked)} asked, ${fmtN(f.limit)} servable`);
$('oc-fit').className = 'wrap' + (f && !f.ok ? ' warn-t' : '');
show('oc-cmd', true);
setText('oc-note', 'One command: the launcher lifts the output cap and auto-approves permissions. The default model follows every switch; running sessions keep the model they started with.');
badge('settings', ok === false ? '!' : '', 'warn');
});
// The fit button refuses before the click, with its reason under it, as the actions menu does
// (base.js openMenu): on a lane whose limits are its own (LFM3, Kolibri, the other vLLM and
// llama.cpp lanes) it learned the reason only from a toast after clicking (review of v1.53.0, 2026-11-19)
const OC_FIT = {blocked: null};
afterApply(() => {
const b = $('oc-fitbtn'); if (!b) return;
const own = cannotWhy('fit_opencode');
if (OC_FIT.blocked === own) return;
OC_FIT.blocked = own;
if (own) b.dataset.blocked = own; else delete b.dataset.blocked;
applyBusy();
});
on('repo', d => {
setText('rp-tag', d.tag || 'n/a'); setText('rp-branch', d.branch || 'n/a');
// the update channel this box follows (get.sh, decision 1529), beside the version and the
// update it names: the config payload names it, and the switch is the same one command
const ch = (F.config || {}).channel;
setText('rp-channel', ch === 'edge' ? 'edge (main)' : 'stable (the latest published release)');
setTitle('rp-channel', ch === 'edge' ? 'Back to the published releases: curl -fsSL https://get.alzeo.ai | bash -s -- --stable'
: 'Follow main instead: curl -fsSL https://get.alzeo.ai | bash -s -- --edge');
setText('rp-head', (d.head || '').split(' ')[0] || 'n/a'); setTitle('rp-head', d.head || '');
setText('rp-dirty', d.dirty == null ? 'unknown (git did not answer)' : d.dirty ? 'modified, uncommitted changes' : d.untracked ? `clean, ${d.untracked} untracked` : 'clean');
const pv = F.proxy && F.proxy.version, ps = F.proxy && F.proxy.same_as_repo;
setText('rp-proxy', (pv || 'version unknown') + (ps === false ? ', differs from the repo copy' : ps ? ', the repo copy' : ''));
});
// This box against what its clone recommends (v1.36.0): the list install.sh prints before its
// first step, one line per difference, what moves first.
const CF_GROUP = {moves: 'moves at the next update', yours: 'stays, your choice', site: 'stays, a setting of this site'};
const CF_WHY = {recorded: () => 'recorded as your choice', 'never-default': () => 'no release installed it by default',
'box-after': old => `this box was installed after ${old} moved the default`, 'box-unknown': () => 'the age of this box cannot be told',
env: () => 'set on a command line', site: () => 'updates never move it'};
function renderConformity(d){
const list = $('cf-list'); if (!list) return;
clear(list);
const c = d.conformity;
// the way to the recommended state, while a setting differs that is not the site's
const rec = $('cf-rec');
if (rec){ rec.hidden = !((c || {}).items || []).some(i => i.group !== 'site'); setText('cf-rec-cmd', recommendedCmd(F.config)); }
if (!c){ cap('cf-cap', 'unknown', ''); setText('cf-head', 'The cockpit could not compare this box with its release (its journal says why).'); return; }
const items = c.items || [], rel = c.release || 'this release';
if (!items.length){ cap('cf-cap', 'as recommended', 'ok'); setText('cf-head', `Every setting this box serves is what ${rel} recommends.`); return; }
// orange only for what the next update moves: a choice among the options is no alert (Hasan, 2026-10-17)
cap('cf-cap', items.length === 1 ? 'one differs' : `${items.length} differ`, items.some(i => i.group === 'moves') ? 'orange' : '');
setText('cf-head', `What this box serves, the ${c.lane === 'flash' ? 'flash' : '27B'} lane's units read, against what ${rel} recommends:`);
['moves', 'yours', 'site'].forEach(g => items.filter(i => i.group === g).forEach(i => {
const why = g === 'moves' ? `the default until ${i.old}` : (CF_WHY[i.why] || (() => i.why))(i.old);
const keep = g !== 'moves' ? '' : i.knob === 'DRAFT2' ? ' The update prints the variables that keep it.' : ` To keep it: ${i.knob}=${i.value} ./install.sh`;
const li = el('li', 'cf ' + g);
li.append(el('b', null, `${cfName(i)} ${i.value}`), el('span', null, `: ${CF_GROUP[g]}, ${why} (recommended: ${i.recommended}).${keep}`));
list.append(li);
}));
}
on('update', d => {
renderConformity(d);
whatsNew();
const parts = [];
if (d.installed) parts.push(d.installed);
const run = d.install_running;
if (run) parts.push(run.to ? `installing ${run.to}` : 'the installer is running');
else if (d.checked === false) parts.push('the update check is off');
else if (!d.latest) parts.push('latest release unknown (offline)');
else if (d.behind) parts.push(`${d.latest} is out: the command below updates this box`);
else parts.push('up to date');
setText('rp-upd', parts.join(', '));
});
// What the version this box runs changed, and the one place the cockpit says a star helps (Hasan, 2026-11-09):
// two links in the page, which the user opens or not. The page itself asks GitHub nothing, and nothing reminds or
// pops up. The release is published after its code, the reference box being updated in between: the link names
// this version's notes only once the latest release GitHub gave the cockpit's check is this version or a later
// one, compared number by number, and every release until then (the check off or offline, a box ahead of the
// releases). Not by the check's "behind", which compares with the last install this box recorded: a cockpit
// restarted in the middle of an update already runs the new version. Only what changed is written: the stream
// brings the whole state about once a second, and links rebuilt each time lost the keyboard's focus and a click
// that straddled a frame (both found in review, 2026-11-10).
function whatsNew(){
const a = $('rp-notes'); if (!a) return;
const nums = s => (/^v?(\d+)\.(\d+)\.(\d+)$/.exec(s || '') || []).slice(1).map(Number);
const cur = nums((F.config || {}).version), last = nums((F.update || {}).latest);
const older = i => i < 3 && (last[i] < cur[i] || (last[i] === cur[i] && older(i + 1)));
const out = cur.length === 3 && last.length === 3 && !older(0), v = 'v' + cur.join('.');
const href = 'https://github.com/hasso5703/alzeo/releases' + (out ? '/tag/' + v : '');
setText(a, out ? `The notes of ${v}` : 'The release notes');
if (a.getAttribute('href') !== href) a.setAttribute('href', href);
}
on('config', d => {
setText('ck-ver', d.version || '?');
whatsNew();
setText('ck-mode', d.dry_run ? 'dry run: logged and audited, nothing executed' : 'live: actions execute after your confirmation');
setText('ck-usable', Math.round((d.usable_frac || F.usable) * 100) + ' % of the KV pool for one prompt');
const per = d.periods || {}, pv = Object.values(per);
setText('ck-periods', pv.length ? `${pv.length} collectors, every ${Math.min(...pv)} to ${Math.max(...pv)} s` : '…');
setTitle('ck-periods', Object.entries(per).map(([k, v]) => `${k} ${v} s`).join(', '));
setText('st-update', updateCmd(d));
setText('cf-rec-cmd', recommendedCmd(d));
});
afterApply(() => { setText('ck-ceiling', !textReady() ? 'set when a text lane serves' : F.ceiling > 0 ? fmtN(F.ceiling) + ' tokens (proxy)' : 'none: the pool share only'); });
function wireOps(){
wireCopyButton($('st-copy'), () => $('st-update').textContent, 'Copy the update command');
wireCopyButton($('cf-rec-copy'), () => $('cf-rec-cmd').textContent, 'Copy the recommended command');
$('rcp-btn').addEventListener('click', loadRecipes);
$('reg-btn').addEventListener('click', () => scanRegistry(true));
$('reg-del').addEventListener('click', () => askAction('delete_strays', {}, [], {danger: true}));
$('up-btn').addEventListener('click', checkUpstream);
$('inv-btn').addEventListener('click', scanInventory);
$('oc-fitbtn').dataset.act = 'fit_opencode';
$('oc-fitbtn').addEventListener('click', () => askAction('fit_opencode', {}, []));
wireGpuCap();
const theme = $('theme-select');
if (theme && typeof themeName === 'function'){
theme.value = themeName();
theme.addEventListener('change', () => applyTheme(theme.value));
}
wireLogs();
}