mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-05 12:24:28 +01:00
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>
1685 lines
143 KiB
JavaScript
1685 lines
143 KiB
JavaScript
"use strict";
|
||
/* Alzeo cockpit, the base every view stands on.
|
||
|
||
One state payload (a server-sent event stream, with polling behind it) drives every
|
||
view through renderers that write text nodes only, never HTML built from data. Each
|
||
renderer is registered against the collector it reads (on()), runs isolated (one that
|
||
throws marks its own panels and nothing else), and every panel says how fresh its
|
||
sources are. Every action goes through one sheet that shows its exact command, one
|
||
server-side job lock, and one dock visible from every view and every browser.
|
||
|
||
The files load in order: base, the views, then boot.js starts the transport. */
|
||
|
||
// ── small tools ─────────────────────────────────────────────────────────────────
|
||
const $ = id => document.getElementById(id);
|
||
const GIB = 1024 ** 3;
|
||
const gib = b => b == null || isNaN(b) ? null : b / GIB;
|
||
// gibibytes, said as such: 1024 cubed is a GiB, not a GB
|
||
const fmtGiB = (b, d = 1) => b == null || isNaN(b) ? '…' : (b / GIB).toFixed(d) + ' GiB';
|
||
const fmtN = n => n == null || isNaN(n) ? '…' : Number(n).toLocaleString('en');
|
||
const fmtK = n => n == null ? '?' : n >= 1e6 ? (n / 1e6).toFixed(2).replace(/\.?0+$/, '') + 'M' : Math.round(n / 1000) + 'K';
|
||
// rounded once, before it is split: minutes floored and seconds rounded read "8 min 60"
|
||
const fmtDur = s => {
|
||
if (s == null || isNaN(s)) return '?';
|
||
const r = Math.max(0, Math.round(s));
|
||
return r < 90 ? r + ' s' : r < 3600 ? Math.floor(r / 60) + ' min ' + String(r % 60).padStart(2, '0')
|
||
: Math.floor(r / 3600) + ' h ' + String(Math.floor((r % 3600) / 60)).padStart(2, '0');
|
||
};
|
||
// minutes for a plan, not a stopwatch: "about 13 min". The minutes are rounded before the hours
|
||
// are split off: rounded after, 7,170 s read "1 h 60" and 3,599 s "60 min" (found in review,
|
||
// 2026-10-21)
|
||
const fmtMin = s => {
|
||
if (s == null) return '?';
|
||
if (s < 90) return Math.round(s) + ' s';
|
||
const m = Math.round(s / 60);
|
||
return m < 60 ? m + ' min' : Math.floor(m / 60) + ' h ' + String(m % 60).padStart(2, '0');
|
||
};
|
||
// a time of day is ambiguous once the page reloads events written on another day
|
||
const clockTime = ts => {
|
||
const d = new Date(ts * 1000), now = new Date();
|
||
const hm = d.toLocaleTimeString([], {hour12: false, hour: '2-digit', minute: '2-digit'});
|
||
if (d.toDateString() === now.toDateString()) return hm;
|
||
return d.toLocaleDateString([], {day: '2-digit', month: '2-digit'}) + ' ' + hm;
|
||
};
|
||
const el = (tag, cls, txt) => { const n = document.createElement(tag); if (cls) n.className = cls; if (txt != null) n.textContent = txt; return n; };
|
||
const clear = n => { if (n) while (n.firstChild) n.removeChild(n.firstChild); };
|
||
const setText = (id, txt) => { const e = typeof id === 'string' ? $(id) : id; if (e && e.textContent !== String(txt)) e.textContent = txt; };
|
||
const setTitle = (id, txt) => { const e = typeof id === 'string' ? $(id) : id; if (e) e.title = txt || ''; };
|
||
const show = (id, on) => { const e = typeof id === 'string' ? $(id) : id; if (e) e.hidden = !on; };
|
||
const cssVar = v => getComputedStyle(document.documentElement).getPropertyValue(v).trim();
|
||
// quoted for a shell: an apostrophe in a prompt must not end the string halfway
|
||
const shq = s => "'" + String(s).replace(/'/g, `'\\''`) + "'";
|
||
function cap(id, text, kind, lamp){
|
||
const e = typeof id === 'string' ? $(id) : id; if (!e) return;
|
||
clear(e); e.className = 'cap' + (kind ? ' ' + kind : '');
|
||
if (lamp !== false){ const l = el('span', 'lamp' + (kind === 'ok' ? ' ok' : kind === 'warn' ? ' warn' : kind === 'err' ? ' err' : kind === 'cool' ? ' cool' : kind === 'orange' ? ' orange' : '') + (lamp === 'live' ? ' live' : '')); e.append(l); }
|
||
e.append(document.createTextNode(text));
|
||
}
|
||
// Each cell carries its column's name: on a phone a wide table stacks into cards, and a
|
||
// line without its header is a number nobody can read. A cell spanning columns has none.
|
||
function labelCells(t){
|
||
const heads = t.tHead ? [...t.tHead.rows[0].cells].map(c => c.textContent.trim()) : [];
|
||
[...t.tBodies[0].rows].forEach(tr => {
|
||
let i = 0;
|
||
[...tr.cells].forEach(td => { const n = td.colSpan || 1; if (n === 1 && heads[i]) td.dataset.label = heads[i]; i += n; });
|
||
});
|
||
}
|
||
function facts(dl, rows){
|
||
clear(dl);
|
||
rows.forEach(([k, v, cls]) => { if (v == null) return; dl.append(el('dt', null, k)); const dd = el('dd', cls || null, v); dl.append(dd); });
|
||
}
|
||
|
||
// ── vocabulary: one word per engine state, everywhere ─────────────────────────
|
||
const STATE_LABEL = {
|
||
stopped: 'stopped', failed: 'failed', starting: 'starting', 'loading-weights': 'loading weights',
|
||
'loading-draft': 'loading the draft head', 'allocating-kv': 'allocating the KV pool',
|
||
'capturing-graphs': 'capturing CUDA graphs', 'warming-up': 'warming up', ready: 'ready',
|
||
degraded: 'ready but not answering', stopping: 'stopping', wedged: 'wedged: no generation',
|
||
orphan: 'running outside systemd'};
|
||
// the word for a lane, with what the start guard or a lost scheduler adds to its state: a lane
|
||
// held by the guard read "starting", one it refused "failed" (engine-preflight.sh, issue #26),
|
||
// a flash lane on a GPU outside its ATS mode is no matter of memory (issue #54), and neither is the
|
||
// Qwen3.8 Flash-Next FP4-Local lane missing a file it reads (its unit's guard)
|
||
const stateLabel = e => !e ? '' : e.held ? 'waiting for GPU memory' : e.refused ? 'not starting: GPU memory held'
|
||
: e.cannot ? 'cannot start on this GPU' : e.lacks ? 'cannot start: a file is missing' : e.zombie ? 'lost its scheduler' : e.state === 'failed' && e.crashed_serving ? 'restarting after a crash'
|
||
: (STATE_LABEL[e.state] || e.state);
|
||
const sentence = s => s ? s.charAt(0).toUpperCase() + s.slice(1) : '';
|
||
const STATE_KIND = {ready: 'ok', degraded: 'warn', failed: 'err', stopped: '', stopping: 'warn', wedged: 'err', orphan: 'err'};
|
||
const TRANSITIONAL = new Set(['starting', 'loading-weights', 'loading-draft', 'allocating-kv', 'capturing-graphs', 'warming-up']);
|
||
// a unit that is not running, whatever its container does: its button offers Start
|
||
const UNIT_DOWN = new Set(['stopped', 'failed', 'orphan']);
|
||
const stateKind = st => STATE_KIND[st] ?? 'warn';
|
||
const stateLive = st => st === 'stopping' || TRANSITIONAL.has(st) ? 'live' : true;
|
||
const STAGE_LABEL = {'init': 'init', 'loading-weights': 'weights', 'loading-draft': 'draft', 'allocating-kv': 'KV pool',
|
||
'capturing-graphs': 'graphs', 'warming-up': 'warmup'};
|
||
const ALL_STAGES = Object.keys(STAGE_LABEL);
|
||
|
||
const U27 = 'qwen38-sglang.service', UFLASH = 'qwen38-flash.service', IMAGE_UNIT = 'qwen38-image.service',
|
||
VIDEO_UNIT = 'qwen38-video.service', KOLIBRI_UNIT = 'qwen38-kolibri.service', NEMOTRON_UNIT = 'qwen38-nemotron.service',
|
||
NEMOTRON_SUPER_UNIT = 'qwen38-nemotron-super.service', FLASH_LOCAL_UNIT = 'qwen38-flash-local.service',
|
||
ORNITH_UNIT = 'qwen38-ornith-122b.service', FLASH_UNSLOTH_UNIT = 'qwen38-flash-unsloth.service',
|
||
IMAGE_H3_UNIT = 'qwen38-image-h3.service', TRANSCRIBE_UNIT = 'qwen38-transcribe.service',
|
||
LFM25_UNIT = 'qwen38-lfm25.service', LFM3_UNIT = 'qwen38-lfm3.service', INKLING_UNIT = 'qwen38-inkling.service',
|
||
PROXY_UNIT = 'qwen38-keepalive.service', AGENT_UNIT = 'opencode-web.service',
|
||
// the speech lane, on the CPU beside whichever lane serves: none of LANE_UNITS, which take the GPU in turn (v1.58)
|
||
SPEECH_UNIT = 'qwen38-speech.service';
|
||
// the order of the Now view's rack and the Lanes view's cards: Ornith before Kolibri and the Nemotron lanes (Hasan, 2026-10-22);
|
||
// the flash model's builds side by side, Unsloth's GGUF after NVIDIA's FP4-Local (v1.48); the speech recognizer after the
|
||
// video lane (v1.51); Liquid AI's LFM2.5 and LFM3 after the other text lanes, and Inkling 2 Mini after them (v1.59)
|
||
const LANE_UNITS = [U27, UFLASH, FLASH_LOCAL_UNIT, FLASH_UNSLOTH_UNIT, ORNITH_UNIT, KOLIBRI_UNIT, NEMOTRON_UNIT, NEMOTRON_SUPER_UNIT, LFM25_UNIT, LFM3_UNIT, INKLING_UNIT, IMAGE_UNIT, IMAGE_H3_UNIT, VIDEO_UNIT, TRANSCRIBE_UNIT];
|
||
// the image lanes, Qwen-Image 2.1 and MiniMax-H3-Image: one Image view addresses the one that serves (image.js, imgUnit)
|
||
const isImageLane = u => u === IMAGE_UNIT || u === IMAGE_H3_UNIT;
|
||
// the two Nemotron lanes, Bolt and Super VL: one vLLM image, the same routes and the same limits
|
||
const isNemotron = u => u === NEMOTRON_UNIT || u === NEMOTRON_SUPER_UNIT;
|
||
// the vLLM lanes on b12x, the two Nemotron lanes, the Qwen3.8 Flash-Next FP4-Local lane and the Ornith lane: the
|
||
// same routes, the same counters, the same belts that cannot act; each says its own name
|
||
const isB12x = u => isNemotron(u) || u === FLASH_LOCAL_UNIT || u === ORNITH_UNIT;
|
||
const b12xName = u => `the ${LANE_NAME[u]} lane`;
|
||
// the vLLM lanes the server reads from one table (cockpit.py TABLE_LANES): the b12x family's, and the Liquid AI LFM3
|
||
// lane's, on vLLM's own nightly without b12x or a drafter: the same routes, counters and belts that cannot act
|
||
const isVllmTable = u => isB12x(u) || u === LFM3_UNIT;
|
||
// the llama.cpp lanes (the Unsloth GGUF lane, v1.48): none of SGLang's routes either, its own counters, its own name
|
||
const isLlamacpp = u => u === FLASH_UNSLOTH_UNIT;
|
||
const llamacppName = u => `the ${LANE_NAME[u]} lane`;
|
||
// The lanes' names in sentences, each its family's official name (decision 1180 of Hasan, 2026-11-07: no name of
|
||
// our own, neither for a lane nor for its default version)
|
||
const LANE_NAME = {[U27]: 'Qwen3.8 27B', [UFLASH]: 'Qwen3.8 Flash-Next', [FLASH_LOCAL_UNIT]: 'Qwen3.8 Flash-Next FP4-Local',
|
||
[KOLIBRI_UNIT]: 'Kolibri-1', [NEMOTRON_UNIT]: 'Nemotron 3.5 Bolt', [NEMOTRON_SUPER_UNIT]: 'Nemotron 3.5 Super VL',
|
||
[ORNITH_UNIT]: 'Ornith 1.5 122B', [FLASH_UNSLOTH_UNIT]: 'Qwen3.8 Flash-Next Unsloth GGUF',
|
||
[IMAGE_UNIT]: 'Qwen-Image 2.1', [IMAGE_H3_UNIT]: 'MiniMax-H3-Image', [VIDEO_UNIT]: 'MiniMax-H3',
|
||
[TRANSCRIBE_UNIT]: 'NVIDIA Nemotron Transcribe', [LFM25_UNIT]: 'Liquid AI LFM2.5 24B-A2B',
|
||
[LFM3_UNIT]: 'Liquid AI LFM3', [INKLING_UNIT]: 'Inkling 2 Mini'};
|
||
// What each lane is, for people: the kind of work it does and the one line that says so.
|
||
// `lane` names the lane's hue in the stylesheet (--lane-<lane>); `maker` its mark in img/logos.
|
||
const LANE_META = {
|
||
[U27]: {title: 'Qwen3.8 27B', kind: 'Text, up to 1M tokens of context', desc: 'Dense 27B in NVFP4 with a DFlash2 draft. The long-context lane.', view: 'agent', lane: '27b', maker: 'qwen'},
|
||
[UFLASH]: {title: 'Qwen3.8 Flash-Next', kind: 'Text, 262K tokens of context', desc: 'Mixture of experts, 176B in NVFP4 with its own draft head. The fast lane for agents.', view: 'agent', lane: 'flash', maker: 'qwen'},
|
||
[FLASH_LOCAL_UNIT]: {title: 'Qwen3.8 Flash-Next FP4-Local', kind: 'Text and images, 262K tokens of context', desc: 'The same 176B model in NVIDIA’s own FP4 build, distilled from its full precision, served by vLLM with b12x as NVIDIA’s model card says. Reasoning, tool calls and vision.', view: 'agent', lane: 'flash-local', maker: 'nvidia'},
|
||
[KOLIBRI_UNIT]: {title: 'Kolibri-1', kind: 'Text, 262K tokens, German and English', desc: 'Aleph Alpha’s mixture of experts, 78B with 3.5B active, served by vLLM. Reasoning and tool calls.', view: 'agent', lane: 'kolibri', maker: 'alephalpha'},
|
||
[NEMOTRON_UNIT]: {title: 'Nemotron 3.5 Bolt', kind: 'Text, images and video, 262K tokens', desc: 'NVIDIA’s mixture of experts, 74B with 9B active in 2 bits, served by vLLM with its drafter. Reasoning, tool calls and vision.', view: 'agent', lane: 'nemotron', maker: 'nvidia'},
|
||
[NEMOTRON_SUPER_UNIT]: {title: 'Nemotron 3.5 Super VL', kind: 'Text, images and video, 1M tokens', desc: 'NVIDIA’s mixture of experts, 120B with 12B active in NVFP4, served by vLLM with its drafter. Reasoning, tool calls and vision over a 1M window.', view: 'agent', lane: 'nemotron-super', maker: 'nvidia'},
|
||
[ORNITH_UNIT]: {title: 'Ornith 1.5 122B', kind: 'Text, images and video, 1M tokens', desc: 'Ornith AI’s mixture of experts, 122B with 8 of its 256 experts active, in its authors’ NVFP4 build, served by vLLM with b12x and its MTP head. Reasoning, tool calls and vision.', view: 'agent', lane: 'ornith-122b', maker: 'ornith'},
|
||
[FLASH_UNSLOTH_UNIT]: {title: 'Qwen3.8 Flash-Next Unsloth GGUF', kind: 'Text, 262K tokens of context', desc: 'The same 176B model in Unsloth’s dynamic GGUF (UD-IQ3_XXS or UD-Q4_K_XL), served by llama.cpp with an n-gram lookup and a DFlash2 draft, its n-gram (PLE) table read from the disk. Reasoning and tool calls.', view: 'agent', lane: 'flash-unsloth', maker: 'unsloth'},
|
||
[LFM25_UNIT]: {title: 'Liquid AI LFM2.5 24B-A2B', kind: 'Text, 131K tokens of context', desc: 'Liquid AI’s hybrid mixture of experts, 24B with 2B active, in its official FP8 build with its DSpark draft, served by SGLang. It reasons before every answer, and calls tools.', view: 'agent', lane: 'lfm25', maker: 'liquid'},
|
||
[INKLING_UNIT]: {title: 'Inkling 2 Mini', kind: 'Text and images, 1M tokens of context', desc: 'Thinking Machines’ looped mixture of experts, 26.4B with 3.4B active, its middle layers run three times per token, served by SGLang with the DSpark draft head of its checkpoint. The light text lane: about 60 % of the 27B’s memory, reasoning at the effort asked, tool calls and vision.', view: 'agent', lane: 'inkling', maker: 'thinkingmachines'},
|
||
[LFM3_UNIT]: {title: 'Liquid AI LFM3', kind: 'Text, 262K tokens of context', desc: 'Liquid AI’s small hybrid model, 1.7B, in its official NVFP4 build, served by vLLM. Post-trained for agents: reasoning (on or off) and tool calls, many requests at once.', view: 'agent', lane: 'lfm3', maker: 'liquid'},
|
||
[IMAGE_UNIT]: {title: 'Qwen-Image 2.1', kind: 'Images', desc: 'Create, edit with up to ten references, cut out with a real alpha channel.', view: 'image', lane: 'image', maker: 'qwen'},
|
||
[IMAGE_H3_UNIT]: {title: 'MiniMax-H3-Image', kind: 'Images, up to 16.9 megapixels', desc: 'MiniMax’s image model in six steps: create, or edit with up to ten references, at 2K in about 16 s and 4K in about 82 s. Its licence is not granted in the EU, the UK, South Korea or the US.', view: 'image', lane: 'image-h3', maker: 'minimax'},
|
||
[VIDEO_UNIT]: {title: 'MiniMax-H3', kind: 'Video with sound', desc: 'Video and audio made together, from a prompt or from keyframes.', view: 'video', lane: 'video', maker: 'minimax'},
|
||
// its own view since v1.54: the Transcription tab drives it through the cockpit's relay; programs still ask it on its port with the box's key
|
||
[TRANSCRIBE_UNIT]: {title: 'NVIDIA Nemotron Transcribe', kind: 'Speech to text, on its own port', desc: 'NVIDIA’s speech recognizer, 30B with 4B active, in GGUF Q8_0, served by llama.cpp on port 30036 with the box’s key: /v1/audio/transcriptions and /v1/realtime. Measured on this box: French WER 2.76 %, English 0.40 %, about ten times faster than real time.', view: 'transcribe', lane: 'transcribe', maker: 'nvidia'}};
|
||
// a lane's maker's mark, as an image the stylesheet sizes (the marks belong to their owners, img/logos/NOTICE.md)
|
||
function makerMark(unit, cls = 'mark'){
|
||
const box = el('span', cls); box.setAttribute('aria-hidden', 'true');
|
||
const img = el('img'); img.src = `/static/img/logos/${LANE_META[unit].maker}.svg`; img.alt = ''; img.decoding = 'async';
|
||
box.append(img); return box;
|
||
}
|
||
// How long each lane takes to answer after a start, before the box has seen one of its
|
||
// boots (measured on the reference box). Once a lane booted in front of the cockpit, the
|
||
// median of its own boots replaces these.
|
||
const READY_DEFAULT = {[U27]: 540, [UFLASH]: 780, [FLASH_LOCAL_UNIT]: 1020, [KOLIBRI_UNIT]: 600, [NEMOTRON_UNIT]: 450, [NEMOTRON_SUPER_UNIT]: 660, [ORNITH_UNIT]: 420, [FLASH_UNSLOTH_UNIT]: 420, [IMAGE_UNIT]: 70, [IMAGE_H3_UNIT]: 451, [VIDEO_UNIT]: 720, [TRANSCRIBE_UNIT]: 15, [LFM25_UNIT]: 290, [LFM3_UNIT]: 160, [INKLING_UNIT]: 230};
|
||
const TARGET_UNIT = t => t === 'image' || t === 'image-turbo' ? IMAGE_UNIT : t === 'image-h3' ? IMAGE_H3_UNIT : t === 'video' ? VIDEO_UNIT
|
||
: t === 'transcribe' ? TRANSCRIBE_UNIT : t === 'lfm25' ? LFM25_UNIT : t === 'lfm3' ? LFM3_UNIT : t === 'inkling' ? INKLING_UNIT
|
||
: String(t).startsWith('kolibri') ? KOLIBRI_UNIT : t === 'nemotron-super' ? NEMOTRON_SUPER_UNIT : String(t).startsWith('nemotron') ? NEMOTRON_UNIT
|
||
: t === 'flash-local' ? FLASH_LOCAL_UNIT : t === 'ornith-122b' ? ORNITH_UNIT : String(t).startsWith('flash-unsloth') ? FLASH_UNSLOTH_UNIT
|
||
: String(t).startsWith('flash') ? UFLASH : U27;
|
||
const LANE_TARGETS = {[U27]: ['stock', 'uncensored', 'fp8', 'uncensored-fp8', 'arete', 'daisyrose'], [UFLASH]: ['flash', 'flash-uncensored', 'flash-nvda'],
|
||
[FLASH_LOCAL_UNIT]: ['flash-local'],
|
||
[KOLIBRI_UNIT]: ['kolibri', 'kolibri-nvfp4'], [NEMOTRON_UNIT]: ['nemotron'], [NEMOTRON_SUPER_UNIT]: ['nemotron-super'],
|
||
[ORNITH_UNIT]: ['ornith-122b'], [FLASH_UNSLOTH_UNIT]: ['flash-unsloth-iq3', 'flash-unsloth'], [IMAGE_UNIT]: ['image', 'image-turbo'],
|
||
[IMAGE_H3_UNIT]: ['image-h3'], [VIDEO_UNIT]: ['video'], [TRANSCRIBE_UNIT]: ['transcribe'], [LFM25_UNIT]: ['lfm25'],
|
||
[LFM3_UNIT]: ['lfm3'], [INKLING_UNIT]: ['inkling']};
|
||
// Each version's official name: the model, its precision, and who publishes it, read off the repository its
|
||
// installer pins (decisions 1180 and 1185: "abliterated", the word of those builds' own makers, never "uncensored"
|
||
// nor "stock"; the targets' ids, in commands, do not change). dashboard/tests/test_target_names.py reads each
|
||
// repository back from the installers.
|
||
const TARGET_NAME = {stock: 'Qwen3.8 27B NVFP4 · RadixArk', uncensored: 'Qwen3.8 27B abliterated NVFP4 · edp1096',
|
||
fp8: 'Qwen3.8 27B FP8 · Qwen', 'uncensored-fp8': 'Qwen3.8 27B abliterated FP8 · edp1096',
|
||
arete: 'Arete 27B NVFP4 · atakans',
|
||
daisyrose: 'DaisyRose 27B NVFP4 · RadixArk',
|
||
flash: 'Qwen3.8 Flash-Next NVFP4 · RadixArk', 'flash-uncensored': 'Qwen3.8 Flash-Next abliterated NVFP4 · dealignai',
|
||
'flash-nvda': 'Qwen3.8 Flash-Next NVFP4 · NVIDIA', 'flash-local': 'Qwen3.8 Flash-Next FP4-Local · NVIDIA',
|
||
image: 'Qwen-Image 2.1 · Qwen', 'image-turbo': 'Qwen-Image 2.1 Turbo · Qwen', video: 'MiniMax-H3 · MiniMax',
|
||
kolibri: 'Kolibri-1 FP8 · Aleph Alpha', 'kolibri-nvfp4': 'Kolibri-1 NVFP4 · Quantinine',
|
||
nemotron: 'Nemotron 3.5 Bolt 24GB · NVIDIA', 'nemotron-super': 'Nemotron 3.5 Super VL NVFP4 · NVIDIA',
|
||
'ornith-122b': 'Ornith 1.5 122B NVFP4 · Ornith AI', 'flash-unsloth': 'Qwen3.8 Flash-Next UD-Q4_K_XL GGUF · Unsloth',
|
||
'flash-unsloth-iq3': 'Qwen3.8 Flash-Next UD-IQ3_XXS GGUF · Unsloth',
|
||
'image-h3': 'MiniMax-H3-Image · MiniMax',
|
||
transcribe: 'NVIDIA Nemotron 3.5 Transcribe 30B-A4B Q8_0 GGUF · mradermacher',
|
||
lfm25: 'LFM2.5 24B-A2B FP8 · Liquid AI', lfm3: 'LFM3 1.7B NVFP4 · Liquid AI',
|
||
inkling: 'Inkling 2 Mini · Thinking Machines'};
|
||
// A version's name on its button in Lanes, and the line that tells it apart once chosen. A
|
||
// target is declared in the tables of this block: a page test fails when one lacks a name or a line.
|
||
const TARGET_SHORT_NAME = {stock: 'NVFP4 · RadixArk', uncensored: 'Abliterated NVFP4 · edp1096', fp8: 'FP8 · Qwen',
|
||
'uncensored-fp8': 'Abliterated FP8 · edp1096', arete: 'Arete NVFP4 · atakans', daisyrose: 'DaisyRose NVFP4 · RadixArk', flash: 'NVFP4 · RadixArk', 'flash-uncensored': 'Abliterated NVFP4 · dealignai',
|
||
'flash-nvda': 'NVFP4 · NVIDIA', image: 'Base', 'image-turbo': 'Turbo', video: 'H3', kolibri: 'FP8 · Aleph Alpha',
|
||
'kolibri-nvfp4': 'NVFP4 · Quantinine', nemotron: 'Bolt', 'nemotron-super': 'Super VL', 'flash-local': 'FP4-Local',
|
||
'ornith-122b': '122B', 'flash-unsloth': 'UD-Q4_K_XL · Unsloth', 'flash-unsloth-iq3': 'UD-IQ3_XXS · Unsloth',
|
||
'image-h3': 'H3-Image', transcribe: 'Q8_0', lfm25: 'FP8 · Liquid AI', lfm3: 'NVFP4 · Liquid AI',
|
||
inkling: 'NVFP4 and MXFP8 · Thinking Machines'};
|
||
const TARGET_LINE = {
|
||
stock: 'The default: smallest and fastest', uncensored: 'Refusals removed, same size and speed',
|
||
fp8: "Qwen's own weights: the most faithful, and heavier", 'uncensored-fp8': 'Refusals removed, and heavier',
|
||
arete: 'Nous Research’s fine-tune, the same size and serving path',
|
||
daisyrose: 'RadixArk’s RL-only fine-tune, the same size and serving path',
|
||
flash: 'The default', 'flash-uncensored': 'Refusals removed', 'flash-nvda': "NVIDIA's own export",
|
||
image: '40 steps, the most detail', 'image-turbo': '8 steps, about 4.5 times faster', video: 'The one version',
|
||
kolibri: "Aleph Alpha's own weights: the reference", 'kolibri-nvfp4': '4-bit experts: faster under load, French a little weaker',
|
||
nemotron: 'The one version: 2-bit experts and their drafter',
|
||
'nemotron-super': 'The one version: NVFP4 and its drafter, a 1M window',
|
||
'flash-local': 'The one version: NVIDIA’s FP4 build and its MTP head',
|
||
'ornith-122b': 'The one version: its authors’ NVFP4 build and its MTP head',
|
||
'flash-unsloth': 'Unsloth’s dynamic 4-bit GGUF, with an n-gram lookup and a DFlash2 draft: two requests at once',
|
||
'flash-unsloth-iq3': 'The default: its experts in 3-bit, faster, four requests at once',
|
||
'image-h3': 'The one version: six steps, up to 16.9 megapixels',
|
||
transcribe: 'The one version: Q8_0 and its F16 projector',
|
||
lfm25: 'The one version: its official FP8 and its DSpark draft',
|
||
lfm3: 'The one version: its official NVFP4',
|
||
inkling: 'The one version: its NVFP4 and MXFP8 experts and its DSpark draft head'};
|
||
const TARGET_NOTE = {
|
||
stock: 'The NVFP4 quantization this repo pins by default: smallest and fastest of the 27B targets.',
|
||
uncensored: 'The abliterated NVFP4 checkpoint: same size and speed as RadixArk’s NVFP4, refusals removed.',
|
||
fp8: 'Qwen’s own FP8 release: the most faithful weights of this lane, and the heaviest. 30.9 GB against 21.9 GB for NVFP4, taken out of the KV pool: 771,139 tokens against 863,398 on the same 1M unit, and a slower decode. The first switch downloads about 31 GB.',
|
||
'uncensored-fp8': 'The abliterated weights in Qwen’s FP8 format: the same 30.9 GB and the same cost in pool and speed as FP8. The first switch downloads about 31 GB.',
|
||
arete: 'Arete 27B, Nous Research’s fine-tune of Qwen3.8 27B (Apache-2.0), in atakans’s NVFP4 build of 21.1 GB: the serving path of RadixArk’s NVFP4 with its DFlash2 draft, and the same fp8 KV cache, which its switch declares in the checkpoint’s config. Measured on this box on 2026-11-14: GSM8K 99.2 %, MMLU 88.0 %, HumanEval 96.3 %, 69 to 72 tokens/s alone, the needle found at 120,000 and 300,000 tokens. The first switch downloads about 21 GB.',
|
||
daisyrose: 'DaisyRose 27B, RadixArk’s reinforcement-learning-only fine-tune of Qwen3.8 27B (Apache-2.0, no SFT, no distillation), in RadixArk’s NVFP4 build of 21.95 GB: the serving path of RadixArk’s NVFP4 with its DFlash2 draft, and the same fp8 KV cache, which its switch declares in the checkpoint’s config (it declares none, like Arete’s). Nothing measured on this box yet; RadixArk publishes Terminal-Bench 2.1 at 75.5 against 73.0 for Qwen3.8-27B (xhigh reasoning). The first switch downloads about 22 GB.',
|
||
flash: 'The Qwen3.8 Flash-Next lane: its own unit, its own image, and a 47.7 GiB N-gram table on the NVMe that the server rewrites at every boot.',
|
||
'flash-uncensored': 'The abliterated build of the same 176B tree, byte-identical in layout, so every serving flag is the same. The first switch downloads about 136 GB.',
|
||
'flash-nvda': 'NVIDIA’s own mixed-precision export of the same model, served with a pinned MoE runner. The first switch downloads about 133 GB.',
|
||
image: 'Text to image, editing with up to ten references, native RGBA. 31 GiB of weights that do not fit beside a text lane.',
|
||
'image-turbo': 'Qwen’s eight-step distillation of the same model, for the same three uses: a 1024 × 1024 image in 7.5 s against 34 s, at the same memory, the eight steps fixed by the checkpoint. The first switch downloads about 33 GB.',
|
||
video: 'Text to video with joint audio, plus first and last frame conditioning. The checkpoint does not fit beside a text lane.',
|
||
kolibri: 'Aleph Alpha’s official FP8 release, served as their model card says: vLLM 0.29 with their plugin, 262,144 tokens of context, temperature 1.0, top_p 0.97, top_k 128, reasoning on (effort low, medium, high or none per request). German and English are its languages. Measured on this box: 48 tokens/s alone, 166 at 8 requests.',
|
||
'kolibri-nvfp4': 'The same model with its routed experts in 4-bit NVFP4 (Quantinine), attention and everything else the official FP8 bit for bit: 53 tokens/s alone and 248 at 8 requests, in 42.8 GiB instead of 73.6. English and German text score level with the FP8; French measurably lower (about 4 % of perplexity). The first switch downloads about 46 GB.',
|
||
nemotron: 'NVIDIA’s Nemotron 3.5 Bolt, its experts in 2 bits, served as its model card says: vLLM nightly with b12x, its LiLiCorr drafter, 262,144 tokens of context, temperature 1.0, top_p 0.95, reasoning on (off, efficient or full per request). It reads images and video. Measured on this box: 140 tokens/s alone on code, 50 on prose, 201 in all at 16 requests, 24 requests at the full window. The first switch downloads about 26 GB.',
|
||
'nemotron-super': 'NVIDIA’s Nemotron 3.5 Super VL in NVFP4, served as its model card says for a DGX Spark: its LiLiCorr drafter, a window of 1,048,576 tokens, the Mamba state in float16 with stochastic rounding, temperature 1.0, top_p 0.95, reasoning on (off, efficient or full per request), in the Nemotron 3.5 Bolt lane’s vLLM image. It reads images and video. Measured on this box: 70 tokens/s alone on code, 31 on prose, its whole window 1.1 to 1.3 times over in its cache. The first switch downloads about 77 GB.',
|
||
'flash-local': 'NVIDIA’s own FP4 build of the flash model, served as its model card says for a DGX Spark: vLLM with b12x, its experts and its n-gram table in NVFP4 after a quantization-aware distillation from the full precision (GPQA Diamond 91.5 % against 92.2 % on NVIDIA’s card), an MTP head drafting 4 tokens, 262,144 tokens of context and a KV cache of about 920,000 tokens, reasoning on at lean as on the other Qwen lanes unless a request asks for another level (xhigh by default with FLASH_LOCAL_EFFORT=xhigh). Its table is read at every token: with the HF cache on another disk, its first Load copies the table’s files (32 GB) beside your home directory. The first boot tunes b12x’s kernels for this GPU, about 17 min; the next ones take about 6. The first switch downloads about 102 GB.',
|
||
'ornith-122b': 'Ornith AI’s Ornith 1.5 122B (MIT) in its authors’ NVFP4 build, served by vLLM with b12x in the Qwen3.8 Flash-Next FP4-Local lane’s image: its experts and output head in NVFP4, its projections in FP8, an MTP head drafting 2 tokens, 1,048,576 tokens of context (its own 262,144 stretched four times with YaRN), temperature 0.6, top_p 0.95, top_k 20, reasoning on (off with effort none or minimal). It reads images and video. The first switch downloads about 78 GB.',
|
||
'flash-unsloth': 'Unsloth’s dynamic GGUF of the flash model (UD-Q4_K_XL, 76.9 GiB of weights), served by llama.cpp’s own server with its n-gram lookup and ggml-org’s DFlash2 draft (Q8_0), its weights copied into the GPU’s memory and its n-gram (PLE) table (26.8 GiB) read from the disk as the tokens need it: 262,144 tokens of context for each of two requests at once (1,048,576 for one request at a time with FLASH_UNSLOTH_CONTEXT=1m given to its installer), the model card’s sampling (temperature 1.0, top_p 0.95, top_k 20), reasoning on at lean as on the other Qwen lanes unless a request asks for another level. Measured on this box at that sampling, one request, on its image (llama.cpp b12316, 2026-11-12, each text’s first pass): 51.8 tokens/s on code, 56.9 in reasoning, 31.5 on prose and 123.7 on a rewrite of code (27.9, 27.7, 27.3 and 27.4 without the lookup and the draft, on the image before it); two requests at once, 63.2 tokens/s in all. The first switch downloads about 112 GB.',
|
||
'flash-unsloth-iq3': 'Unsloth’s UD-IQ3_XXS GGUF of the same model, served the same way (llama.cpp’s own server, its n-gram lookup and ggml-org’s DFlash2 draft, the same chat template and sampling): its experts in 3-bit, 51.1 GiB of weights where UD-Q4_K_XL has 76.9, and the same n-gram (PLE) table, read from the disk. The room it leaves goes to more requests at once: 262,144 tokens of context for each of four, the KV cache in q8_0 (1,048,576 for one request at a time with FLASH_UNSLOTH_CONTEXT=1m given to its installer). Measured on this box, one request at temperature 0 on its image (llama.cpp b12316, 2026-11-14, each text’s first pass, two windows of 262,144 for both quantizations, the GPU capped at 2,400 MHz): 69.4 tokens/s on code, 76.4 in reasoning, 37.7 on prose and 171.7 on a rewrite of code, where UD-Q4_K_XL gave 55.6, 60.5, 32.0 and 129.8; with its four windows, 66.2 tokens/s for one request and 71.5 in all with four (the GPU capped at 2,000 MHz). At the medium effort and temperature 0, four requests at once (llama.cpp b12291 built on this box, 2026-11-14): GSM8K 98.8 % (250 questions; 98.4 % for UD-Q4_K_XL on the same bench) and HumanEval 98.2 % (164 problems; 99.4 %), the box keeping 28.7 GiB available at the lowest. The lane’s default since v1.49.0. The first switch downloads about 85 GB, 55 when UD-Q4_K_XL is there (the n-gram table is one file for the two).',
|
||
'image-h3': 'MiniMax’s MiniMax-H3-Image, served by SGLang Diffusion from its main branch: text to image and editing with up to ten references, six steps fixed by the checkpoint with no guidance, from 2048 × 2048 to 16.9 megapixels (4736 × 3552, 6272 × 2688), one image per call. Measured on the reference box at this lane’s SGLang commit: 2048 × 2048 in 15.6 s, 4736 × 3552 in 81 s, an edit at 2048 × 2048 with a 1024-pixel reference in 24 s, the engine at 92.3 GB at its peak: it fits beside no other lane. Its text encoder is MiniMax-H3’s, the video lane’s, fetched with it when the video lane has not. Its licence, the MiniMax-H3-Image Community License, is not granted in the European Union, the United Kingdom, South Korea or the United States; elsewhere commercial use above USD 1 million of annual revenue, or as a service hosted for others, needs MiniMax’s written authorization. The first switch downloads about 69 GB, and 67 more without the video lane.',
|
||
transcribe: 'NVIDIA’s Nemotron-3.5-Transcribe-30B-A4B in mradermacher’s GGUF Q8_0 with its F16 projector (36.5 GB), served by llama.cpp’s own server in the Qwen3.8 Flash-Next Unsloth GGUF lane’s image, on a port of its own (30036) with the box’s key: /v1/audio/transcriptions and the /v1/realtime websocket, reasoning off, a window of 65,536 tokens, as the reference box measured it (French WER 2.76 % over 20 excerpts, English 0.40 %, ready in 15 s once its files are on disk). The proxy on :30001 and opencode are text clients and do not reach it. It fits beside no text lane. The first switch downloads about 37 GB.',
|
||
lfm25: 'Liquid AI’s LFM2.5 24B-A2B in its official FP8 build (its linear weights in FP8 by blocks of 128 × 128), with its official DSpark draft, served by SGLang in the Qwen3.8 27B lane’s image as Liquid AI’s card gives the command: 131,072 tokens of context, the draft proposing blocks of 9 tokens, its own chat template and sampling (temperature 0.1, top_k 50, repetition_penalty 1.05). Its template opens a reasoning block at every answer, whatever a request asks: no effort or switch turns it off, and System One does not run on it. Tool calls in its own format, which the engine turns into OpenAI tool calls. Measured on the reference box on 2026-11-14: ready in 286 s, GSM8K 91.2 % (250 questions, 8 requests at once), 362 tokens/s in all at the median under those 8, the draft accepting 5.28 tokens at the median, a KV cache of 1,667,049 tokens, the box keeping 24 GiB available at the lowest. Its licence, the LFM Open License v1.0, does not grant commercial use to a company with an annual revenue of 10 million US dollars or more. The first switch downloads about 26 GB.',
|
||
lfm3: 'Liquid AI’s LFM3 1.7B in its official NVFP4 build (ModelOpt, weights and activations by groups of 16), served by vLLM’s own nightly image (LFM3 is in no vLLM release yet) with the model’s whole window, 262,144 tokens, its own chat template and sampling (temperature 0.1, top_k 50, repetition_penalty 1.1), a memory share of 0.75 that keeps the box room (vLLM’s KV cache otherwise grows into all the memory left). It reasons by default and can be asked not to (the none variant, pi’s off): its template reads that switch and no level. Tool calls in Qwen3-Coder’s form, which the engine turns into OpenAI tool calls. Measured on the reference box on 2026-11-16, before its share was set: ready in about 2 min 40 s, GSM8K 89.6 % (250 questions), 87.7 tokens/s alone and 3,912 in all at 128 requests, a prompt of 131,072 tokens computed in 10.2 s, an agent’s next turn served 99 to 100 % from the prefix cache. Its licence, the LFM Open License v1.0, does not grant commercial use to a company with an annual revenue of 10 million US dollars or more. The first switch downloads about 2 GB.',
|
||
inkling: 'Thinking Machines’ Inkling 2 Mini (Apache-2.0, with Thinking Machines’ Model Acceptable Use Policy), a looped mixture of experts: 26.4B parameters with 3.4B active, its middle twelve layers run three times per token (5.4B effective), its experts in NVFP4 and MXFP8. Served by SGLang from the image its cookbook gives the model (it is in no SGLang release yet) with the cookbook’s DGX Spark recipe: the DSpark draft head of its checkpoint verifying 8 tokens a step, a static memory share of 0.45, the model’s window of 1,048,576 tokens, its own chat template and sampling (temperature 1.0). It reasons at the effort a request asks, from none to xhigh, high by default; its card says the lowest effort does not turn the reasoning off, and System One does not run on it. It reads images. Measured on the reference box on 2026-11-22: ready in 222 s (379 s at its first start, which compiles its kernels), 53.1 GiB of GPU memory against 89 for the Qwen3.8 27B, a KV cache of 490,496 tokens, 64.7 tokens/s at bench.sh’s greedy median against 72.3, 30.3 tokens/s alone and 89.2 in all at 8 requests against 34.0 and 119.0, a prompt of 32,015 tokens computed in 10.0 s, three tool calls of three, GSM8K 96.4 % (250 questions, its default effort). The first switch downloads about 21 GB.'};
|
||
// What installs a lane this box does not have. Since v1.20 a plain ./install.sh installs
|
||
// every lane, so one missing here was left out (a --no-<lane> on the last run) or did not fit:
|
||
// --with-<lane> installs it beside the lane that serves, which keeps serving. A text lane comes with
|
||
// its default target; the others download when they are loaded.
|
||
const LANE_INSTALL = {[U27]: './install.sh --with-27b', [UFLASH]: './install.sh --with-flash', [IMAGE_UNIT]: './install.sh --with-image',
|
||
[VIDEO_UNIT]: './install.sh --with-video', [KOLIBRI_UNIT]: './install.sh --with-kolibri',
|
||
[NEMOTRON_UNIT]: './install.sh --with-nemotron', [NEMOTRON_SUPER_UNIT]: './install.sh --with-nemotron-super',
|
||
[FLASH_LOCAL_UNIT]: './install.sh --with-flash-local', [ORNITH_UNIT]: './install.sh --with-ornith-122b',
|
||
[FLASH_UNSLOTH_UNIT]: './install.sh --with-flash-unsloth', [IMAGE_H3_UNIT]: './install.sh --with-image-h3',
|
||
[TRANSCRIBE_UNIT]: './install.sh --with-transcribe', [LFM25_UNIT]: './install.sh --with-lfm25',
|
||
[LFM3_UNIT]: './install.sh --with-lfm3', [INKLING_UNIT]: './install.sh --with-inkling'};
|
||
// A lane a 64 GB DGX Spark cannot hold (boxmem.py, which the machine panel carries): where another
|
||
// lane names the command that installs it, it says it needs a 128 GB box. Unknown is no refusal.
|
||
const laneFits = unit => {
|
||
const box = (F.machine || {}).box || {};
|
||
return box.cls !== '64' || !Array.isArray(box.fits) || box.fits.includes(unit);
|
||
};
|
||
// A switch target the same way: the 27B's FP8 ones are not a 64 GB box's (boxmem.py's targets)
|
||
const targetFits = target => {
|
||
const box = (F.machine || {}).box || {};
|
||
return box.cls !== '64' || !Array.isArray(box.targets) || box.targets.includes(target);
|
||
};
|
||
const NEEDS_128 = 'needs a 128 GB DGX Spark';
|
||
const installHint = unit => laneFits(unit) ? `Install it on the box: ${LANE_INSTALL[unit]}`
|
||
: `It ${NEEDS_128}, and this box is a 64 GB one.`;
|
||
// What the box is, from the same panel: the name its maker sells it under and its memory class
|
||
// ("ASUS Ascent GX10, 128 GB"), or null while unknown.
|
||
const boxName = (box = (F.machine || {}).box || {}) => box.cls ? `${box.name || 'GB10 box'}, ${box.cls} GB` : null;
|
||
|
||
// ── the facts every view shares (each guarded against missing data) ──────────
|
||
const F = {life: null, units: {}, config: {}, job: null, load: {}, pool: null, window: 262144, ceiling: 0, usable: 0.92,
|
||
maxRun: null, target: null, containers: {}, proxy: null, agent: null, update: null, memFloor: null, toolTargets: null, resent: null, machine: null,
|
||
gpu: null, ocfit: null, transcribe: null, feedRows: null};
|
||
const engines = () => (F.life && F.life.engines) || {};
|
||
function servingEngine(){ return Object.entries(engines()).find(([, e]) => !UNIT_DOWN.has(e.state) || e.restarting) || null; }
|
||
// The lane enabled at boot, or null when none is (or systemctl did not say). enabledUnit()
|
||
// falls back on the 27B, a default to show logs of; said as a fact, it read "27B starts at
|
||
// boot" on a box that boots nothing (found 2026-10-02).
|
||
function bootUnit(){
|
||
const e = Object.entries(F.units || {}).find(([n, u]) => LANE_UNITS.includes(n) && u.enabled === 'enabled');
|
||
return e ? e[0] : null;
|
||
}
|
||
function enabledUnit(){ return bootUnit() || U27; }
|
||
// systemctl answered for every lane (a unit not installed answers too, with no file state)
|
||
const bootKnown = () => LANE_UNITS.every(n => F.units && F.units[n] && F.units[n].enabled !== '?' && F.units[n].enabled !== undefined);
|
||
function servingReady(){ const s = servingEngine(); return !!(s && ['ready', 'degraded', 'wedged'].includes(s[1].state)); }
|
||
// A TEXT engine is up: the pool, the context window, flush, abort and smoke all talk to
|
||
// the text engine on :30000, and with a lane that serves none of it (the image and video
|
||
// lanes, the transcribe lane on its own port) that port is closed.
|
||
function textReady(){ const s = servingEngine(); return servingReady() && !!s && !isImageLane(s[0]) && s[0] !== VIDEO_UNIT && s[0] !== TRANSCRIBE_UNIT; }
|
||
const imageServing = () => { const s = servingEngine(); return !!s && isImageLane(s[0]); };
|
||
const videoServing = () => { const s = servingEngine(); return !!s && s[0] === VIDEO_UNIT; };
|
||
const transcribeServing = () => { const s = servingEngine(); return !!s && s[0] === TRANSCRIBE_UNIT; };
|
||
// answering on its own port: only at ready or degraded, like the capsule of the Now view, so a copied
|
||
// test is not offered while the lane boots and its curl would fail (review of v1.53.0, 2026-11-19)
|
||
const transcribeReady = () => { const s = servingEngine(); return !!s && s[0] === TRANSCRIBE_UNIT && (s[1].state === 'ready' || s[1].state === 'degraded'); };
|
||
function bootSeconds(unit){
|
||
const b = ((engines()[unit] || {}).boots || []).slice().sort((a, c) => a - c), n = b.length;
|
||
// the median: the middle boot, or the mean of the two middle ones for an even count
|
||
return n ? (n % 2 ? b[(n - 1) / 2] : Math.round((b[n / 2 - 1] + b[n / 2]) / 2)) : (READY_DEFAULT[unit] || 540);
|
||
}
|
||
const readyIn = unit => 'about ' + fmtDur(bootSeconds(unit));
|
||
// the text engine's served target, when it is one of this unit's
|
||
const ownTarget = unit => F.target && TARGET_UNIT(F.target) === unit ? F.target : null;
|
||
// What the serving engine itself says it serves, only from a read taken after this engine
|
||
// started: the read comes every 30 s and is kept through a restart, so for up to 30 s after
|
||
// one it still names the previous engine's checkpoint. The image engine's answer is read by
|
||
// the cockpit once per life of its unit, so it is never the previous one's. null when there
|
||
// is no such read.
|
||
function servedTarget(unit){
|
||
const s = servingEngine(), age = lastAges.engine_info;
|
||
if (!s || s[0] !== unit || unit === VIDEO_UNIT) return null;
|
||
if (isImageLane(unit)) return s[1].served_target || null;
|
||
return s[1].elapsed != null && age != null && age < s[1].elapsed ? ownTarget(unit) : null;
|
||
}
|
||
function laneTarget(unit){
|
||
// A target of another lane is the previous engine's, read before this one answered.
|
||
return servedTarget(unit) || (engines()[unit] || {}).target || null;
|
||
}
|
||
function laneLabel(unit){
|
||
if (unit === AGENT_UNIT) return 'the opencode web server';
|
||
if (unit === PROXY_UNIT) return 'the keepalive proxy';
|
||
if (unit === SPEECH_UNIT) return 'the speech lane';
|
||
const t = laneTarget(unit);
|
||
return (t && TARGET_NAME[t]) || LANE_NAME[unit] || unit.replace('.service', '');
|
||
}
|
||
// A lane's name in two parts, the family (LANE_NAME) and what follows it (its precision and who publishes it), for
|
||
// the places too narrow for the whole: a phone's capsule says the family alone (the version's full name pushed
|
||
// its state, "ready", out of it, 2026-11-08), and a bay's title breaks between the two, never after the " · ".
|
||
function nameParts(full, unit){
|
||
const fam = LANE_NAME[unit] || '';
|
||
return fam && full.startsWith(fam + ' ') ? [fam, full.slice(fam.length + 1)] : [full, ''];
|
||
}
|
||
// The engine a lane runs and its version, the one way the page says them (decision 1178): dashboard/engines.py's
|
||
// table, which its tests check against the installers' pins. 'SGLang 0.5.22'; '' for a unit with none. The lane that
|
||
// serves says the version its engine reports (engine_info): when that is not the one the pinned image reports (an
|
||
// image of the operator's), the engine's own word is said, never the pin's.
|
||
// a lane's kind with the window it runs, where that is the 1M one its installer offers (FLASH_LOCAL_CONTEXT=1m,
|
||
// discussion #63, and FLASH_UNSLOTH_CONTEXT=1m): the words of LANE_META say the native window, and said "262K" of a
|
||
// lane serving 1,048,576. The lane that serves says its engine's window (engine_info), the others the one their unit
|
||
// starts with: a unit staged again while its lane serves names a window its engine does not run yet (code review of
|
||
// v1.45.2)
|
||
const laneKind = unit => {
|
||
const k = LANE_META[unit].kind, live = F.liveEngine && F.liveEngine.unit === unit ? F.liveEngine.window : 0;
|
||
const w = live > 0 ? live : ((F.engineTable || {})[unit] || {}).window;
|
||
return w >= 1000000 && /262K tokens/.test(k) ? k.replace('262K tokens', '1M tokens') : k;
|
||
};
|
||
function engineLabel(unit){
|
||
// the table the cockpit reads every 30 s (engine_table)
|
||
const e = ((F.engineTable || {})[unit]);
|
||
if (!e) return '';
|
||
// the engine's own word, for the lane that serves (F.liveEngine, cleared once that lane no longer serves)
|
||
const live = F.liveEngine && F.liveEngine.unit === unit ? String(F.liveEngine.version || '').replace(/^vLLM /, '') : '';
|
||
if (live) return e.reports && live !== e.reports ? `${e.engine} ${live}` : e.label;
|
||
// a lane its installer set on an image of the operator's: not the pin's version (pinned, read in its unit)
|
||
return e.pinned === false ? `${e.engine}, another image` : e.label;
|
||
}
|
||
// When systemctl did not say ('?'), the lifecycle's list decides: it leaves out a diffusion lane
|
||
// with no unit file. Read as installed, '?' showed the image and video lanes of a box whose
|
||
// systemctl did not answer as installed, their checkpoint "…" for good (a CI runner, 2026-10-02).
|
||
const installed = unit => { const u = F.units[unit]; return u && u.enabled !== '?' ? u.enabled !== '' : !!engines()[unit]; };
|
||
const blockedFor = key => ((F.life || {}).blocked || {})[key] || null;
|
||
|
||
// ── the bus: renderers per collector, isolated ────────────────────────────────
|
||
const HANDLERS = {}; // collector -> [fn]
|
||
const AFTER = []; // hooks after every payload
|
||
function on(src, fn){ (HANDLERS[src] = HANDLERS[src] || []).push(fn); }
|
||
function afterApply(fn){ AFTER.push(fn); }
|
||
let lastMsgAt = 0, lastState = null, lastAges = {}, lastErrors = {}, offline = false;
|
||
const lastGood = {}, renderErr = {}, warned = {};
|
||
function warnOnce(name, msg){ if (warned[name] === msg) return; warned[name] = msg; console.warn(name, msg); }
|
||
// order matters a little: config, units and engine info feed the others
|
||
const ORDER = ['config', 'units', 'repo', 'engine_info', 'engine_fast', 'lifecycle', 'machine', 'gpu'];
|
||
function apply(state){
|
||
lastState = state; lastMsgAt = Date.now();
|
||
const serverNow = Math.max(0, ...Object.values(state).map(w => w && w.ts ? w.ts : 0));
|
||
const errors = {}, ages = {};
|
||
for (const [name, wrap] of Object.entries(state)){
|
||
const bad = !!(wrap && wrap.data && wrap.data.error);
|
||
if (bad) errors[name] = wrap.data.error;
|
||
// a collector that keeps failing must not look fresh just because it keeps trying
|
||
if (wrap && wrap.ts && !bad) lastGood[name] = wrap.ts;
|
||
ages[name] = lastGood[name] != null ? Math.max(0, serverNow - lastGood[name]) : null;
|
||
}
|
||
const names = ORDER.filter(n => n in state).concat(Object.keys(state).filter(n => !ORDER.includes(n)));
|
||
for (const name of names){
|
||
const fns = HANDLERS[name]; if (!fns) continue;
|
||
const wrap = state[name] || {};
|
||
for (const fn of fns){
|
||
try{
|
||
if (errors[name]) throw new Error(errors[name]);
|
||
fn(wrap.data || {});
|
||
delete renderErr[name]; delete warned[name];
|
||
}catch(e){
|
||
if (!errors[name]) renderErr[name] = e.message; // a bug here, not a dead source
|
||
warnOnce(name, e.message);
|
||
if (name === 'engine_info') try { (HANDLERS.engine_info_down || []).forEach(f => f()); } catch { /* keep going */ }
|
||
}
|
||
}
|
||
}
|
||
lastAges = ages; lastErrors = errors;
|
||
freshness();
|
||
AFTER.forEach(fn => { try { fn(state, errors); } catch(e){ warnOnce('after', e.message); } });
|
||
}
|
||
function freshness(){
|
||
// age = how old the server said the sample was, PLUS how long we have had no payload
|
||
const drift = lastMsgAt ? Math.max(0, (Date.now() - lastMsgAt) / 1000) : 0;
|
||
const periods = (F.config && F.config.periods) || {};
|
||
document.querySelectorAll('[data-src]').forEach(sec => {
|
||
const srcs = sec.dataset.src.split(',');
|
||
let worst = 0, stale = false, err = null;
|
||
srcs.forEach(s => {
|
||
const a = lastAges[s], p = periods[s] || 5;
|
||
if (a != null){ const t = a + drift; worst = Math.max(worst, t); if (t > 3 * p + 3) stale = true; }
|
||
if (renderErr[s]) err = err || `${s} render error: ${renderErr[s]}`;
|
||
else if (lastErrors[s] && s !== 'engine_info') err = err || `${s}: ${lastErrors[s]}`;
|
||
});
|
||
const head = [...sec.children].find(c => c.localName === 'header');
|
||
const age = head && head.querySelector('.age');
|
||
if (age){ setText(age, err ? 'no data: ' + err.slice(0, 60) : stale ? `stale, ${fmtDur(worst)} old` : worst > 4 ? `${Math.round(worst)} s ago` : 'live'); }
|
||
sec.classList.toggle('stale', stale || !!err);
|
||
});
|
||
}
|
||
|
||
// ── the transport: SSE, polling behind it, an offline watch ───────────────────
|
||
let es = null, pollTimer = null, sseUp = false, lastSseTry = 0;
|
||
function login(){ leavingForLogin = true; location.href = '/login'; }
|
||
function setConn(onl, label){
|
||
const l = $('conn-lamp'); if (l) l.className = 'lamp' + (onl ? ' ok live' : offline ? ' err' : ' warn');
|
||
setText('conn-lbl', label);
|
||
}
|
||
function startPolling(){
|
||
if (pollTimer) return;
|
||
pollTimer = setInterval(async () => {
|
||
try{
|
||
const r = await fetch('/api/state'); if (r.status === 401) return login();
|
||
apply(await r.json()); setConn(true, 'polling');
|
||
if (!sseUp && Date.now() - lastSseTry > 15000) connect(); // climb back to the live stream
|
||
}catch{ setConn(false, 'offline'); }
|
||
}, 2000);
|
||
}
|
||
function connect(){
|
||
lastSseTry = Date.now();
|
||
if (es){ try { es.close(); } catch { /* already gone */ } } // never two streams at once
|
||
// handlers hold their OWN stream: a late event from a replaced one must not flip the state
|
||
const src = new EventSource('/api/stream');
|
||
es = src;
|
||
src.onopen = () => { if (es !== src) return; sseUp = true; setConn(true, 'live'); if (pollTimer){ clearInterval(pollTimer); pollTimer = null; } };
|
||
src.onmessage = ev => { if (es !== src) return; try { apply(JSON.parse(ev.data)); setConn(true, 'live'); } catch(e){ console.warn('bad frame', e.message); } };
|
||
src.onerror = () => {
|
||
if (es !== src){ try { src.close(); } catch { /* gone */ } return; }
|
||
sseUp = false; setConn(false, 'reconnecting'); src.close(); startPolling(); setTimeout(connect, 3000);
|
||
};
|
||
}
|
||
function startTransport(){
|
||
fetch('/api/state').then(r => { if (r.status === 401){ login(); return null; } return r.json(); })
|
||
.then(s => { if (s){ apply(s); connect(); } })
|
||
.catch(() => { setConn(false, 'offline'); startPolling(); });
|
||
// offline watch, on the client's clock
|
||
setInterval(() => {
|
||
const was = offline; offline = !!lastMsgAt && Date.now() - lastMsgAt > 6000;
|
||
if (offline) setConn(false, 'no data for ' + fmtDur((Date.now() - lastMsgAt) / 1000));
|
||
if (lastState) freshness();
|
||
if (was !== offline){ if (lastState) renderBanners(lastState, lastErrors); applyBusy(); }
|
||
}, 1000);
|
||
}
|
||
async function csrf(){
|
||
const t = await fetch('/api/csrf', {method: 'POST'});
|
||
if (t.status === 401){ login(); throw new Error('signed out'); }
|
||
return (await t.json()).token;
|
||
}
|
||
async function postJSON(path, body){
|
||
const tok = await csrf();
|
||
const r = await fetch(path, {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({...body, csrf: tok})});
|
||
if (r.status === 401){ login(); throw new Error('signed out'); }
|
||
let out = {};
|
||
try { out = await r.json(); } catch { /* an empty answer */ }
|
||
return {status: r.status, ok: r.ok, out};
|
||
}
|
||
|
||
// ── router: views, the rail, the phone menu ───────────────────────────────────
|
||
const VIEWS = ['now', 'lanes', 'traffic', 'machine', 'agent', 'decide', 'image', 'video', 'transcribe', 'library', 'logs', 'settings'];
|
||
// the old tab names still land: links in the docs and bookmarks say #agent, #engines
|
||
const ALIAS = {overview: 'now', engines: 'lanes', requests: 'traffic', systemone: 'decide', models: 'library', setup: 'settings'};
|
||
const ON_SHOW = {};
|
||
let activeView = 'now';
|
||
function onShow(view, fn){ (ON_SHOW[view] = ON_SHOW[view] || []).push(fn); }
|
||
function showView(name, push = true){
|
||
name = ALIAS[name] || name;
|
||
if (!VIEWS.includes(name)) name = 'now';
|
||
const was = activeView; activeView = name; document.body.dataset.view = name;
|
||
VIEWS.forEach(v => { const s = $('view-' + v); if (s) s.classList.toggle('active', v === name); });
|
||
document.querySelectorAll('.rail .nav').forEach(b => {
|
||
if (b.dataset.view === name) b.setAttribute('aria-current', 'page'); else b.removeAttribute('aria-current');
|
||
});
|
||
if (push && location.hash !== '#' + name) history.replaceState(null, '', '#' + name);
|
||
setRailOpen(false);
|
||
if (was !== name) window.scrollTo({top: 0});
|
||
(ON_SHOW[name] || []).forEach(fn => { try { fn(); } catch(e){ warnOnce('show ' + name, e.message); } });
|
||
}
|
||
function setRailOpen(open){
|
||
document.body.classList.toggle('railopen', open);
|
||
const b = $('menubtn'); if (b) b.setAttribute('aria-expanded', String(open));
|
||
}
|
||
function setRailMin(min){
|
||
document.body.classList.toggle('railmin', min);
|
||
const b = $('railbtn');
|
||
if (b){ b.setAttribute('aria-expanded', String(!min)); setText(b.querySelector('span'), min ? 'Expand' : 'Collapse');
|
||
if (min) b.title = 'Expand'; else b.removeAttribute('title'); }
|
||
try { localStorage.setItem('cockpit.rail', min ? 'min' : 'open'); } catch { /* storage may be unavailable */ }
|
||
}
|
||
function badge(view, txt, kind){ const b = $('bdg-' + view); if (b){ setText(b, txt || ''); b.className = 'bdg' + (kind ? ' ' + kind : ''); } }
|
||
|
||
// ── toasts ────────────────────────────────────────────────────────────────────
|
||
function toast(text, kind, ms = 4200){
|
||
const box = $('toasts'); if (!box) return;
|
||
const t = el('div', 'toast' + (kind ? ' ' + kind : ''), text);
|
||
box.append(t);
|
||
while (box.children.length > 3) box.firstChild.remove();
|
||
setTimeout(() => t.remove(), ms);
|
||
}
|
||
// The update: the README's one command in its long form, get.sh from GitHub itself (v1.41.0),
|
||
// run from this checkout so that get.sh updates this clone. The server sends it; a page newer
|
||
// than the process that serves it builds it.
|
||
function updateCmd(cfg){
|
||
const c = cfg || {};
|
||
return (c.terminal_only || {}).update
|
||
|| `cd ${c.repo_dir || '~/dgx-spark-qwen38'} && curl -fsSL https://raw.githubusercontent.com/hasso5703/alzeo/main/get.sh | bash`;
|
||
}
|
||
// The installer of this very clone, for one get.sh refuses to update: off its channel's branch
|
||
// (main or stable), or with commits of its own past origin/main (a worktree a developer installs
|
||
// from; cockpit.py, release_state's clone_local)
|
||
function localInstallCmd(cfg){
|
||
const c = cfg || {};
|
||
return (c.terminal_only || {}).update_stack || `cd ${c.repo_dir || '~/dgx-spark-qwen38'} && ./install.sh`;
|
||
}
|
||
// ./install.sh --recommended through the same one command (get.sh hands install.sh what follows -s --)
|
||
function recommendedCmd(cfg){
|
||
const c = cfg || {};
|
||
return (c.terminal_only || {}).recommended
|
||
|| `cd ${c.repo_dir || '~/dgx-spark-qwen38'} && curl -fsSL https://raw.githubusercontent.com/hasso5703/alzeo/main/get.sh | bash -s -- --recommended`;
|
||
}
|
||
// The clipboard API exists in a secure context only: on the box's LAN or Tailscale address, plain
|
||
// HTTP, every copy control said the browser refused (found 2026-10-21, a GX10's cockpit opened by its
|
||
// Tailscale address). A selected textarea and execCommand('copy'), still inside the click, copy there.
|
||
async function copyText(txt){
|
||
if (navigator.clipboard && window.isSecureContext){
|
||
try { await navigator.clipboard.writeText(txt); toast('Copied.', 'ok', 1800); return true; } catch { /* the textarea below */ }
|
||
}
|
||
// 16 px: under it, iOS Safari zooms the whole page on the field's focus and never zooms back
|
||
// (cockpit.css); and the focus goes back where it was, on the button for a keyboard
|
||
const back = document.activeElement;
|
||
const ta = el('textarea'); ta.value = txt; ta.readOnly = true; ta.dataset.copy = '';
|
||
ta.style.cssText = 'position:fixed; top:-1000px; left:0; opacity:0; font-size:16px';
|
||
document.body.append(ta); ta.select(); ta.setSelectionRange(0, txt.length);
|
||
let done = false;
|
||
try { done = document.execCommand('copy'); } catch { done = false; }
|
||
ta.remove();
|
||
if (back && back !== document.body && back.focus) back.focus({ preventScroll: true });
|
||
if (done) toast('Copied.', 'ok', 1800); else toast('The browser refused the clipboard; select the text instead.', 'warn');
|
||
return done;
|
||
}
|
||
// A copy icon carries its field: the same button, drawn as a copy mark at rest and a green
|
||
// check for a moment after a successful copy. The text may be a function for a command that
|
||
// is rebuilt while the view is open.
|
||
function copyGlyph(){
|
||
const NS = 'http://www.w3.org/2000/svg', s = document.createElementNS(NS, 'svg');
|
||
s.setAttribute('viewBox', '0 0 24 24'); s.setAttribute('aria-hidden', 'true');
|
||
const rect = document.createElementNS(NS, 'rect');
|
||
rect.setAttribute('class', 'g-copy'); rect.setAttribute('x', '8.5'); rect.setAttribute('y', '8.5');
|
||
rect.setAttribute('width', '12.5'); rect.setAttribute('height', '12.5'); rect.setAttribute('rx', '2.5');
|
||
const back = document.createElementNS(NS, 'path');
|
||
back.setAttribute('class', 'g-copy');
|
||
back.setAttribute('d', 'M15.5 8.5V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v8.5a2 2 0 0 0 2 2h3.5');
|
||
const check = document.createElementNS(NS, 'path');
|
||
check.setAttribute('class', 'g-check'); check.setAttribute('d', 'M4.5 12.5 9.5 17.5 19.5 7');
|
||
s.append(rect, back, check);
|
||
return s;
|
||
}
|
||
function wireCopyButton(btn, text, label = 'Copy'){
|
||
if (!btn) return btn;
|
||
if (!btn.querySelector('svg')) btn.append(copyGlyph());
|
||
const get = () => typeof text === 'function' ? text() : text;
|
||
const reset = () => { btn.classList.remove('copied'); btn.setAttribute('aria-label', label); btn.title = label; };
|
||
btn.setAttribute('aria-label', label); btn.title = label;
|
||
btn.addEventListener('click', async () => {
|
||
if (!await copyText(String(get() || ''))) return;
|
||
btn.classList.add('copied'); btn.setAttribute('aria-label', 'Copied'); btn.title = 'Copied';
|
||
clearTimeout(btn.copyTimer); btn.copyTimer = setTimeout(reset, 1600);
|
||
});
|
||
return btn;
|
||
}
|
||
function copyIconButton(text, label){
|
||
const b = el('button', 'icon-btn copy-icon copy-inline'); b.type = 'button';
|
||
b.append(copyGlyph());
|
||
return wireCopyButton(b, text, label);
|
||
}
|
||
|
||
// ── actions: one sheet, the exact command, the warnings, one job at a time ─────
|
||
// a GPU clock cap as the page says it: "2,400 MHz", or "no cap" (the Machine view, ops.js)
|
||
const gpuCapName = cap => cap === 'none' ? 'no cap' : `${fmtN(Number(cap))} MHz`;
|
||
// Same vocabulary as the server's event feed: an action reads as a sentence.
|
||
const ACTION_PHRASE = {
|
||
speech_boot: p => p.verb === 'enable' ? 'start the speech lane with the box' : 'no longer start the speech lane with the box',
|
||
unit: p => `${p.verb || 'act on'} ${laneLabel(String(p.unit || ''))}`,
|
||
switch: p => `point the boot at ${TARGET_NAME[p.target] || p.target || 'a target'}`,
|
||
flush_cache: () => 'flush the engine cache', abort_all: () => 'abort every generation in flight',
|
||
smoke: () => 'run a smoke generation', diag_bundle: () => 'write a diagnostics bundle',
|
||
fit_opencode: () => 'fit the opencode limits to this engine',
|
||
delete_strays: () => 'delete the stray revisions from the model caches',
|
||
delete_repo: p => `delete ${p.repo || 'a repository'} from the model cache`,
|
||
delete_image: p => `delete the engine image ${p.image || ''}`,
|
||
delete_runtime: p => `delete the ${RUNTIME_NAME[p.item] || p.item || 'runtime'}`,
|
||
apply_pending: p => `put in place the update ${LANE_NAME[p.unit] || p.unit || 'a lane'} waited for`,
|
||
fetch: p => `download the checkpoint of ${TARGET_NAME[p.target] || p.target || 'a target'}`,
|
||
clients: p => `set the clients for the window of ${TARGET_NAME[p.target] || p.target || 'a lane'}`,
|
||
prepare: p => `build the runtime of the ${laneOfTarget(p.target) || ''} lane`,
|
||
gpu_clock: p => p.cap === 'none' ? 'lift the GPU clock cap' : `cap the GPU clock at ${gpuCapName(p.cap)}`};
|
||
function actionPhrase(action, params){
|
||
const f = ACTION_PHRASE[action]; if (f) return f(params || {});
|
||
const p = params || {}; return action + (Object.keys(p).length ? ' ' + Object.entries(p).map(([k, v]) => `${k} ${v}`).join(', ') : '');
|
||
}
|
||
const cap1 = s => String(s).charAt(0).toUpperCase() + String(s).slice(1);
|
||
// these three talk to the text engine: without one they can only fail
|
||
const NEEDS_ENGINE = new Set(['flush_cache', 'abort_all', 'smoke']);
|
||
// what the Kolibri lane's vLLM has no route for: offered there, these could only fail (found in
|
||
// review, 2026-10-14). The fit reads SGLang's /server_info, and Kolibri's limits are its own.
|
||
const KOLIBRI_CANNOT = {
|
||
flush_cache: 'The Kolibri-1 lane has no cache flush route: vLLM evicts its prefix cache by itself.',
|
||
abort_all: 'The Kolibri-1 lane has no route that aborts its generations: stopping the lane stops them.',
|
||
fit_opencode: 'The Kolibri-1 lane\'s opencode limits are its own, set when it is loaded: there is nothing to fit to its pool.'};
|
||
// the Nemotron lanes run on vLLM too: the same three
|
||
const NEMOTRON_CANNOT = {
|
||
flush_cache: 'The Nemotron 3.5 Bolt lane has no cache flush route: vLLM evicts its prefix cache by itself.',
|
||
abort_all: 'The Nemotron 3.5 Bolt lane has no route that aborts its generations: stopping the lane stops them.',
|
||
fit_opencode: 'The Nemotron 3.5 Bolt lane\'s opencode limits are its own, set when it is loaded: there is nothing to fit to its pool.'};
|
||
// and the Nemotron 3.5 Super VL lane, in its own name (cockpit.py NEMOTRON_SUPER_CANNOT)
|
||
const NEMOTRON_SUPER_CANNOT = {
|
||
flush_cache: 'The Nemotron 3.5 Super VL lane has no cache flush route: vLLM evicts its prefix cache by itself.',
|
||
abort_all: 'The Nemotron 3.5 Super VL lane has no route that aborts its generations: stopping the lane stops them.',
|
||
fit_opencode: 'The Nemotron 3.5 Super VL lane\'s opencode limits are its own, set when it is loaded: there is nothing to fit to its pool.'};
|
||
// and the Qwen3.8 Flash-Next FP4-Local lane, in its own name, as the server says it (cockpit.py FLASH_LOCAL_CANNOT)
|
||
const FLASH_LOCAL_CANNOT = {
|
||
flush_cache: 'The Qwen3.8 Flash-Next FP4-Local lane has no cache flush route: vLLM evicts its prefix cache by itself.',
|
||
abort_all: 'The Qwen3.8 Flash-Next FP4-Local lane has no route that aborts its generations: stopping the lane stops them.',
|
||
fit_opencode: 'The Qwen3.8 Flash-Next FP4-Local lane\'s opencode limits are its own, set when it is loaded: its window decides them, not its pool.'};
|
||
// and the Ornith lane, in its own name (cockpit.py ORNITH_CANNOT)
|
||
const ORNITH_CANNOT = {
|
||
flush_cache: 'The Ornith 1.5 122B lane has no cache flush route: vLLM evicts its prefix cache by itself.',
|
||
abort_all: 'The Ornith 1.5 122B lane has no route that aborts its generations: stopping the lane stops them.',
|
||
fit_opencode: 'The Ornith 1.5 122B lane\'s opencode limits are its own, set when it is loaded: its window decides them, not its pool.'};
|
||
// and the Liquid AI LFM3 lane, in its own name (cockpit.py LFM3_CANNOT)
|
||
const LFM3_CANNOT = {
|
||
flush_cache: 'The Liquid AI LFM3 lane has no cache flush route: vLLM evicts its prefix cache by itself.',
|
||
abort_all: 'The Liquid AI LFM3 lane has no route that aborts its generations: stopping the lane stops them.',
|
||
fit_opencode: 'The Liquid AI LFM3 lane\'s opencode limits are its own, set when it is loaded: its window decides them, not its pool.'};
|
||
// and the Unsloth GGUF lane, llama.cpp's, in its own name (cockpit.py FLASH_UNSLOTH_CANNOT)
|
||
const FLASH_UNSLOTH_CANNOT = {
|
||
flush_cache: 'The Qwen3.8 Flash-Next Unsloth GGUF lane has no cache flush route: llama.cpp keeps and evicts its prompt cache by itself.',
|
||
abort_all: 'The Qwen3.8 Flash-Next Unsloth GGUF lane has no route that aborts its generations: stopping the lane stops them.',
|
||
fit_opencode: 'The Qwen3.8 Flash-Next Unsloth GGUF lane\'s opencode limits are its own, set when it is loaded: its window decides them, not its pool.'};
|
||
function cannotWhy(name){
|
||
const s = servingEngine();
|
||
return !s ? '' : s[0] === KOLIBRI_UNIT ? (KOLIBRI_CANNOT[name] || '') : s[0] === FLASH_LOCAL_UNIT ? (FLASH_LOCAL_CANNOT[name] || '')
|
||
: s[0] === FLASH_UNSLOTH_UNIT ? (FLASH_UNSLOTH_CANNOT[name] || '') : s[0] === LFM3_UNIT ? (LFM3_CANNOT[name] || '')
|
||
: s[0] === ORNITH_UNIT ? (ORNITH_CANNOT[name] || '') : s[0] === NEMOTRON_SUPER_UNIT ? (NEMOTRON_SUPER_CANNOT[name] || '')
|
||
: isNemotron(s[0]) ? (NEMOTRON_CANNOT[name] || '') : '';
|
||
}
|
||
function noEngineWhy(){
|
||
if (textReady()) return '';
|
||
if (imageServing()) return 'The image lane is serving: this talks to the text engine, which is not running.';
|
||
if (videoServing()) return 'The video lane is serving: this talks to the text engine, which is not running.';
|
||
if (transcribeServing()) return 'The NVIDIA Nemotron Transcribe lane is serving: this talks to the text engine, which is not running.';
|
||
const u = bootUnit();
|
||
return 'No text engine is serving. Start one first' + (u && !isImageLane(u) && u !== VIDEO_UNIT && u !== TRANSCRIBE_UNIT ? ` (it answers in ${readyIn(u)}).` : ' from Lanes.');
|
||
}
|
||
function busyWhy(){
|
||
if (offline) return 'The cockpit is unreachable: actions wait until the connection is back.';
|
||
if (loadRunning()) return `A load is running (${TARGET_NAME[SHEET.target]}). Wait for it to finish, or bring its window back with the job button.`;
|
||
if (F.job && F.job.current) return `Another action is running (${actionPhrase(F.job.current.action, F.job.current.params)}). Wait for it to finish.`;
|
||
return '';
|
||
}
|
||
// switch-model.sh restarts opencode-web when the config it reads changed, as fit_opencode says of its own rewrite
|
||
const AGENT_RESTART = 'If the Agent server runs and its config changed, it restarts to read it: a reply it is writing then is cut short.';
|
||
const EXPLAIN = {
|
||
speech_boot: p => p.verb === 'enable' ? 'systemd enables the speech lane: from the next boot it starts with the box and holds its host memory (2.5 GB with the 0.6B recognizer, 4.2 with the 1.7B) beside whichever lane serves. It does not start it now.'
|
||
: 'systemd disables the speech lane at boot: it stays as it is now, and after the next boot it is started by hand, here or with systemctl.',
|
||
unit: p => {
|
||
const lane = laneLabel(p.unit);
|
||
if (p.unit === AGENT_UNIT) return {stop: 'systemd stops opencode serve: the Agent view goes dark until the server is started again.',
|
||
start: 'systemd starts opencode serve on loopback; the Agent view is back within seconds.',
|
||
restart: 'systemd restarts opencode serve, which picks up an upgraded binary; the Agent view reconnects by itself.'}[p.verb] || '';
|
||
if (p.unit === SPEECH_UNIT) return {stop: 'systemd stops the speech lane: its audio routes answer nothing until it is started again, and the host memory it holds comes back. The lane that serves is not touched.',
|
||
start: 'systemd starts the speech lane on the CPU, beside the lane that serves: it takes no GPU memory, holds host memory instead (2.5 GB with the 0.6B recognizer, 4.2 with the 1.7B), and answers within seconds.',
|
||
restart: 'systemd restarts the speech lane: a transcription or a sentence being made right now is lost, and it answers again within seconds.'}[p.verb] || '';
|
||
if (p.unit === PROXY_UNIT) return p.verb === 'stop' ? 'systemd stops the keepalive proxy. The engine keeps running, but agent clients on :30001 lose their door until it is back.' : 'systemd starts the keepalive proxy on :30001.';
|
||
if (p.verb === 'stop') return `systemd stops ${lane}. Its memory comes back at once; no other lane starts by itself.`;
|
||
if (p.verb === 'restart') return `systemd restarts ${lane}; it answers again in ${readyIn(p.unit)}.`;
|
||
return `systemd starts ${lane}: it loads its weights and answers in ${readyIn(p.unit)}. Follow the boot in the dock and on the Now view.`;
|
||
},
|
||
switch: p => (TARGET_NOTE[p.target] ? TARGET_NOTE[p.target] + '\n\n' : '') +
|
||
`switch-model.sh verifies the checkpoint, makes this lane the one enabled at boot and ${TARGET_UNIT(p.target) === VIDEO_UNIT || TARGET_UNIT(p.target) === IMAGE_H3_UNIT ? 'changes nothing else'
|
||
: TARGET_UNIT(p.target) === TRANSCRIBE_UNIT ? 'fetches what its GGUF files lack and puts in its unit for them: the proxy and opencode, text clients, stay as they are'
|
||
: TARGET_UNIT(p.target) === IMAGE_UNIT ? 'points its unit at this checkpoint'
|
||
: TARGET_UNIT(p.target) === KOLIBRI_UNIT ? `points its unit at this checkpoint and its memory share, and makes ${LANE_NAME[KOLIBRI_UNIT]} opencode's default model, with its compaction`
|
||
: TARGET_UNIT(p.target) === FLASH_LOCAL_UNIT ? `puts in its unit for this checkpoint, with its chat template and, when the HF cache is on another disk, the copies of its n-gram table, and makes ${LANE_NAME[FLASH_LOCAL_UNIT]} opencode's default model, with its compaction`
|
||
: TARGET_UNIT(p.target) === ORNITH_UNIT ? `puts in its unit for this checkpoint, and makes ${LANE_NAME[ORNITH_UNIT]} opencode's default model, with its compaction`
|
||
: TARGET_UNIT(p.target) === FLASH_UNSLOTH_UNIT ? `fetches what its GGUF files and its draft lack, puts in its unit for them with its chat template, and makes ${LANE_NAME[FLASH_UNSLOTH_UNIT]} opencode's default model, with its compaction`
|
||
: TARGET_UNIT(p.target) === LFM25_UNIT ? `fetches what its checkpoint and its draft lack, puts in its unit for them, and makes ${LANE_NAME[LFM25_UNIT]} opencode's default model, with its compaction`
|
||
: TARGET_UNIT(p.target) === LFM3_UNIT ? `puts in its unit for this checkpoint, and makes ${LANE_NAME[LFM3_UNIT]} opencode's default model, with its compaction`
|
||
: TARGET_UNIT(p.target) === INKLING_UNIT ? `fetches what its checkpoint lacks, puts in its unit for it, and makes ${LANE_NAME[INKLING_UNIT]} opencode's default model, with its compaction`
|
||
: isNemotron(TARGET_UNIT(p.target)) ? `points its unit at this checkpoint and its memory share, and makes ${LANE_NAME[TARGET_UNIT(p.target)]} opencode's default model, with its compaction`
|
||
: 'rewrites its unit, the proxy ceiling and the opencode default model'}. It never restarts anything.`,
|
||
flush_cache: () => 'Empties the radix cache. Harmless; the engine refuses it while requests run.',
|
||
abort_all: () => 'Every running or queued generation stops now, and each client is cut: an agent retries its request (end its turn in the agent).',
|
||
smoke: () => 'One real 200-token generation through the proxy, the way a client uses it.',
|
||
diag_bundle: () => 'Collects logs, state and versions into a tarball in your home; the API key is masked everywhere.',
|
||
fit_opencode: () => 'Reads the KV pool of the engine serving now and rewrites only opencode’s context and output limits, so a conversation can never outgrow it. A dated backup is written first. If the Agent server runs, it restarts to read them: a reply it is writing then is cut short.',
|
||
clients: p => `switch-model.sh ${p.target} --clients sets the limits of opencode, pi and claude-local for the window ${LANE_NAME[TARGET_UNIT(p.target)]}’s unit starts with, `
|
||
+ 'with the lane’s name in opencode. opencode’s default model and its compaction stay with the lane the boot names, and nothing else changes: '
|
||
+ 'no fetch, no unit, no boot, no engine. ' + AGENT_RESTART,
|
||
// what the cap cost and gave on the reference box, and its limits (ops.js, the Machine view)
|
||
gpu_clock: p => gpuCapExplain(p.cap)};
|
||
// the stray revisions the last scan of the checkpoints offered to delete (Library, scanRegistry)
|
||
const REG_STRAYS = {list: [], bytes: 0};
|
||
// Library's Delete of one repository: the plan the server made for it (GET /api/registry/plan), which the sheet shows
|
||
const REG_DELETE = {plan: null, image: null, runtime: null};
|
||
// Library's runtimes and caches, by the server's item names (cockpit.py, RUNTIME_ITEMS)
|
||
const RUNTIME_NAME = {image: 'Qwen-Image 2.1 runtime', 'image-h3': 'MiniMax-H3-Image runtime', video: 'MiniMax-H3 video runtime',
|
||
'diffusion-caches': 'Diffusion caches of the first start'};
|
||
// the lane a Load's target belongs to, by prepare-lane.sh's names (the cockpit's target_lane)
|
||
const laneOfTarget = t => SIDE_LANE[TARGET_UNIT(t)];
|
||
EXPLAIN.prepare = p => {
|
||
const lane = laneOfTarget(p.target), text = lane === 'flash' || lane === '27b';
|
||
return (text ? `prepare-lane.sh ${lane} ${p.target} builds what the lane runs, and fetches the checkpoint of ${TARGET_NAME[p.target] || p.target}: `
|
||
: `prepare-lane.sh runs install-${lane}.sh --prepare, which builds the lane's runtime: `)
|
||
+ `${LANE_RUNTIME[lane] || 'its runtime'}, as the user, with no sudo. It changes nothing else: no unit, no boot, no engine.`;
|
||
};
|
||
EXPLAIN.fetch = p => `switch-model.sh fetches the checkpoint of ${TARGET_NAME[p.target] || p.target} into the cache as a switch to it does: `
|
||
+ 'the cache first, resumable, its room checked before. It changes nothing else: no unit, no boot, no engine. The dock shows the bytes as they come.';
|
||
EXPLAIN.delete_strays = () => {
|
||
const s = REG_STRAYS;
|
||
return `Removes from the Hugging Face cache ${s.list.map(x => `${x.repo.split('/').pop()} ${x.rev.slice(0, 10)} (${fmtGiB(x.bytes)})`).join(', ')}`
|
||
+ `, ${fmtGiB(s.bytes)} in all: each one's snapshot and the blobs only it links to. No pin, no installed unit and no ref names them, `
|
||
+ 'so no lane reads them, and a blob another revision shares stays. The cockpit scans again when you confirm, and deletes only what is still stray.';
|
||
};
|
||
EXPLAIN.delete_repo = p => {
|
||
const d = REG_DELETE.plan || {}, kept = (d.kept_why || []).length;
|
||
return `Removes ${p.repo} from ${d.cache || 'its cache'}: ${fmtGiB(d.bytes)} freed on ${d.mount || 'its disk'}`
|
||
+ (kept ? `, keeping ${fmtGiB(d.kept_bytes)} of it (${d.kept_why.join('; ')})` : '') + '. '
|
||
+ (d.identical ? `The Hub still serves ${(d.revisions || []).length === 1 ? 'this revision' : 'each of its revisions'} exactly as it is here: a download gets it back. ` : '')
|
||
+ 'No lane, container or process reads it now, and a blob another repository shares stays. '
|
||
+ 'The cockpit plans it again when you confirm, asks the Hub again, and deletes only then.';
|
||
};
|
||
EXPLAIN.delete_image = p => {
|
||
const d = REG_DELETE.image || {};
|
||
return `Removes the image ${p.image} and each of its names (${(d.names || []).join(', ')}) with docker rmi: `
|
||
+ `${d.bytes == null ? 'the bytes only it holds' : fmtGiB(d.bytes)} freed on ${d.mount || 'its disk'}, the layers no other image has. `
|
||
+ (d.obtainable ? ((d.registry || [])[0] || {}).how ? 'Its lane builds it again here. ' : 'Its registry still serves it by its digest: a pull gets it back. ' : '')
|
||
+ 'No container starts from it and no lane that runs it serves. The cockpit plans it again when you confirm.';
|
||
};
|
||
EXPLAIN.delete_runtime = p => {
|
||
const d = REG_DELETE.runtime || {};
|
||
return `Removes ${(d.paths || []).join(', ')}: ${fmtGiB(d.bytes)} freed on ${d.mount || 'its disk'}. `
|
||
+ (p.item === 'diffusion-caches' ? 'The diffusion runtime writes them again at the next start of an image or video lane, which then takes longer. '
|
||
: `The lane's next Load builds it again, as the user (prepare-lane.sh). What the lane made, in its outputs folder, stays. `)
|
||
+ 'Refused while a lane that runs it serves or starts.';
|
||
};
|
||
const TITLE = {unit: p => `${cap1(p.verb)} ${laneLabel(p.unit)}`,
|
||
speech_boot: p => p.verb === 'enable' ? 'Start the speech lane with the box' : 'No longer start the speech lane with the box', switch: p => `Point the boot at ${TARGET_NAME[p.target] || p.target}`,
|
||
flush_cache: () => 'Flush the engine cache', abort_all: () => 'Abort every generation in flight', smoke: () => 'Run a smoke generation',
|
||
diag_bundle: () => 'Write a diagnostics bundle', fit_opencode: () => 'Fit the opencode limits',
|
||
delete_strays: () => 'Delete the stray revisions',
|
||
delete_repo: p => `Delete ${String(p.repo || '').split('/').pop()}`,
|
||
delete_image: p => `Delete the image ${p.image}`,
|
||
delete_runtime: p => `Delete the ${RUNTIME_NAME[p.item] || p.item}`,
|
||
fetch: p => `Download ${TARGET_NAME[p.target] || p.target}`,
|
||
clients: p => `Set the clients for the window of ${TARGET_NAME[p.target] || p.target}`,
|
||
prepare: p => `Build the ${laneOfTarget(p.target)} lane's runtime`,
|
||
gpu_clock: p => p.cap === 'none' ? 'Lift the GPU clock cap' : `Cap the GPU clock at ${gpuCapName(p.cap)}`};
|
||
const VERB = {unit: p => cap1(p.verb) + ' ' + (LANE_NAME[p.unit] || laneLabel(p.unit)),
|
||
speech_boot: p => p.verb === 'enable' ? 'Start it with the box' : 'Stop starting it with the box', switch: () => 'Point the boot', flush_cache: () => 'Flush',
|
||
abort_all: () => 'Abort all', smoke: () => 'Run the probe', diag_bundle: () => 'Write the bundle', fit_opencode: () => 'Fit the limits',
|
||
delete_strays: () => 'Delete them', delete_repo: p => p.lose === 'yes' ? 'Delete it anyway' : 'Delete it',
|
||
delete_image: p => p.lose === 'yes' ? 'Delete it anyway' : 'Delete it', delete_runtime: () => 'Delete it', fetch: () => 'Download', clients: () => 'Set the clients', prepare: () => 'Build it',
|
||
gpu_clock: p => p.cap === 'none' ? 'Lift the cap' : `Cap at ${gpuCapName(p.cap)}`};
|
||
// the GPU clock cap runs as a python job on the server, which hands the page each cap's exact command (its
|
||
// config); the sheet shows that command, not the job's name, unless this machine has no nvidia-smi (ops.js, GC),
|
||
// where None runs nothing and only forgets the cap kept
|
||
const argvFor = (name, p) => name === 'unit' ? ['sudo', '-n', '/usr/bin/systemctl', p.verb, p.unit]
|
||
: name === 'speech_boot' ? ['sudo', '-n', '/usr/bin/systemctl', p.verb, SPEECH_UNIT]
|
||
: name === 'switch' ? ['bash', 'switch-model.sh', p.target] : name === 'fetch' ? ['bash', 'switch-model.sh', p.target, '--fetch']
|
||
: name === 'clients' ? ['bash', 'switch-model.sh', p.target, '--clients']
|
||
: name === 'prepare' ? ['bash', 'prepare-lane.sh', laneOfTarget(p.target)].concat(['flash', '27b'].includes(laneOfTarget(p.target)) ? [p.target] : [])
|
||
: name === 'gpu_clock' && GC.has !== false && ((F.config || {}).gpu_clock_argv || {})[p.cap] ? F.config.gpu_clock_argv[p.cap]
|
||
: ['cockpit', name];
|
||
|
||
let SHEET = null; // {mode: 'one'|'journey', ...}
|
||
// A dialog hands the focus back to what opened it: closing one left it on the body, so a
|
||
// keyboard had to start again from the top of the page.
|
||
const OPENER = {sheet: null, menu: null, viewer: null};
|
||
const giveBack = k => { const e = OPENER[k]; OPENER[k] = null; if (e && e.isConnected && typeof e.focus === 'function') e.focus(); };
|
||
function openSheet(focusId = 'sh-go'){
|
||
const a = document.activeElement; OPENER.sheet = a && !a.closest('#scrim') ? a : OPENER.sheet;
|
||
$('scrim').hidden = false; setTimeout(() => $(focusId).focus(), 0);
|
||
}
|
||
// A result's screen takes the shape of what it shows: its own proportions, as wide as the
|
||
// column allows and no taller than most of the window (78vh, through a max-width derived
|
||
// from the ratio), centred. Both result screens went back to their 16:9 box when the result
|
||
// arrived, so a portrait sat small in the middle of it and a gallery of images was cut at
|
||
// its bottom (Hasan, 2026-10-10). A size of 0 lets the box follow what it holds (a gallery);
|
||
// no size at all gives the screen its default back.
|
||
function fitScreen(sc, w, h){
|
||
if (w > 0 && h > 0){ sc.style.aspectRatio = `${w} / ${h}`; sc.style.maxWidth = `calc(78vh * ${(w / h).toFixed(4)})`; sc.classList.add('fit'); return; }
|
||
sc.style.aspectRatio = w === 0 ? 'auto' : ''; sc.style.maxWidth = ''; sc.classList.remove('fit');
|
||
}
|
||
// The image viewer: a result over the whole window, fitted to it or drawn at its own pixels
|
||
// (one image pixel to one screen pixel, whatever the display's density), closed by Escape,
|
||
// its Close button or a click beside the picture; the focus goes back where it was.
|
||
function openViewer(src, w, h, name){
|
||
const a = document.activeElement; OPENER.viewer = a && !a.closest('#viewer') ? a : OPENER.viewer;
|
||
const v = $('viewer-img'); v.src = src; v.alt = `The image at full size, ${w} by ${h}`; v.style.width = '';
|
||
$('viewer-pane').classList.remove('actual'); $('viewer-actual').setAttribute('aria-pressed', 'false');
|
||
setText('viewer-size', `${w} × ${h}`); $('viewer-dl').href = src; $('viewer-dl').setAttribute('download', name);
|
||
$('viewer').hidden = false; setTimeout(() => { if (!$('viewer').hidden) $('viewer-close').focus(); }, 0);
|
||
}
|
||
function viewerActual(){
|
||
const pane = $('viewer-pane'), v = $('viewer-img'), on = !pane.classList.contains('actual');
|
||
pane.classList.toggle('actual', on); $('viewer-actual').setAttribute('aria-pressed', String(on));
|
||
v.style.width = on && v.naturalWidth ? `${Math.round(v.naturalWidth / (window.devicePixelRatio || 1))}px` : '';
|
||
}
|
||
function closeViewer(){ $('viewer').hidden = true; giveBack('viewer'); }
|
||
// A load whose steps are running is put away, not closed: its steps go on, the dock follows the step that
|
||
// runs, and the job button brings the window back. The window held the whole page through a 20-minute
|
||
// download, and reloading the page to get it back stopped the chain (Hasan, 2026-10-12).
|
||
// Nothing else starts while a load runs, its window shown or put away: its next step could stop the lane
|
||
// that work would run on (one engine at a time), and two chains would race on the same lanes. A window is
|
||
// put away only while its steps run: a step that fails always brings it back.
|
||
const loadRunning = () => !!(SHEET && SHEET.running && SHEET.mode === 'journey');
|
||
const loadAway = () => loadRunning() && !!SHEET.hidden;
|
||
const LOAD_RUNNING = 'A load is still running: the job button brings its window back.';
|
||
// A window a failure brought back keeps its first second: the Escape or the click the person aimed at what
|
||
// it covered (the viewer, the page) must not dismiss why the load failed. Its Cancel closes it at once.
|
||
const BACK_GUARD_MS = 1000;
|
||
const justBack = () => !!(SHEET && SHEET.backAt && Date.now() - SHEET.backAt < BACK_GUARD_MS);
|
||
// The reason a lane's own work (an image, a video, a decision) waits, shown under its button.
|
||
const laneWorkWaits = () => loadRunning() ? `A load is running (${TARGET_NAME[SHEET.target]}): its steps stop and start lanes. Wait for it to finish.` : '';
|
||
function closeSheet(){
|
||
if (loadRunning()) SHEET.hidden = true; // put away: its steps go on
|
||
else if (SHEET && SHEET.running) return; // one action closes its window once the job is accepted
|
||
else { const s = SHEET; SHEET = null; if (s && s.onClose) s.onClose(); }
|
||
$('scrim').hidden = true; giveBack('sheet'); journeyChanged();
|
||
}
|
||
// Brought back by the job button while the steps run: the focus goes to Hide (Go is disabled then).
|
||
function reopenJourney(){
|
||
if (!loadAway()) return false;
|
||
SHEET.hidden = false; openSheet('sh-cancel'); journeyChanged(); return true;
|
||
}
|
||
// The job button: the job that runs, or a load put away while it waits between two steps (a stopped lane
|
||
// reading down can take 90 s), so the window always has a way back. It shows on a narrow screen too
|
||
// (.away), where the head has no room for the plain job button.
|
||
function renderPip(){
|
||
const pip = $('jobpip'); if (!pip) return;
|
||
const cur = (F.job || {}).current, away = loadAway();
|
||
pip.hidden = !(cur || away); pip.classList.toggle('away', away);
|
||
const what = cur ? describeJob(cur) : away ? `Load ${TARGET_NAME[SHEET.target]}: between steps` : '';
|
||
setText('jobpip-what', what || '…'); pip.title = what; // cut short on a phone: the whole of it on hover
|
||
}
|
||
function journeyChanged(){ renderPip(); applyBusy(); }
|
||
// fn runs when a load starts or ends, not at every tick of a job: the views whose own work waits for a
|
||
// load (image, video, decide) say so under their button then.
|
||
function onLoadChange(fn){ let seen = false; on('busy', () => { const k = loadRunning(); if (k !== seen){ seen = k; fn(); } }); }
|
||
// A page closed or reloaded stops the chain after the step that runs; with the window put away nothing on
|
||
// screen says so, so the browser asks first. Not in a dry run, whose loads are a walk-through, and not
|
||
// when the page itself goes to the login (a session that ended cannot run the chain anyway).
|
||
let leavingForLogin = false;
|
||
const leaveWarning = () => loadAway() && !F.config.dry_run && !leavingForLogin;
|
||
function askAction(name, params, warns, opts = {}){
|
||
if (offline) return toast('The cockpit is unreachable right now: nothing can be started.', 'err');
|
||
if (loadRunning()) return toast(LOAD_RUNNING, 'warn');
|
||
if (NEEDS_ENGINE.has(name) && !textReady()) return toast(noEngineWhy(), 'warn');
|
||
if (cannotWhy(name)) return toast(cannotWhy(name), 'warn');
|
||
if (F.job && F.job.current) return toast(busyWhy(), 'warn');
|
||
if (!$('scrim').hidden) return;
|
||
const p = params || {};
|
||
setText('sh-title', (TITLE[name] ? TITLE[name](p) : name));
|
||
setText('sh-lede', (EXPLAIN[name] ? EXPLAIN[name](p) : '') + (F.config.dry_run ? '\n\nDry run: nothing will really be executed.' : ''));
|
||
const w = $('sh-warns'); clear(w); (warns || []).forEach(x => w.append(el('p', null, x))); w.hidden = !(warns && warns.length);
|
||
$('sh-journey').hidden = true; show('sh-cmd-lbl', true); show('sh-cmd', true);
|
||
setText('sh-cmd', argvFor(name, p).join(' '));
|
||
setText('sh-status', ''); $('sh-status').className = 'status';
|
||
const go = $('sh-go'); go.disabled = false; setText(go, VERB[name] ? VERB[name](p) : 'Run it');
|
||
go.className = 'btn ' + (opts.danger || (name === 'unit' && p.verb !== 'start') || name === 'abort_all' ? 'danger solid' : 'primary');
|
||
SHEET = {mode: 'one', name, params: p, onClose: opts.onClose};
|
||
openSheet();
|
||
}
|
||
// Run one action; resolves {ok, status, out}. The sheet shows refusals where they happened.
|
||
async function runAction(name, params){
|
||
const {status, out} = await postJSON('/api/action', {name, params});
|
||
return {ok: status === 202, status, out};
|
||
}
|
||
async function sheetGo(){
|
||
if (!SHEET || SHEET.running) return;
|
||
if (SHEET.mode === 'journey') return runJourney();
|
||
SHEET.running = true; const go = $('sh-go'); go.disabled = true; $('sh-cancel').disabled = true; setText('sh-status', 'sending…');
|
||
const {name, params} = SHEET;
|
||
try{
|
||
const r = await runAction(name, params);
|
||
if (r.ok){
|
||
if (name === 'unit' && isImageLane(params.unit) && params.verb !== 'start') IMG_INTERRUPTED_AT.t = Date.now();
|
||
if (name === 'unit' && params.unit === VIDEO_UNIT && params.verb !== 'start') VID_INTERRUPTED_AT.t = Date.now();
|
||
SHEET.running = false; closeSheet(!0);
|
||
toast(`${cap1(actionPhrase(name, params))}: running${r.out.dry_run ? ' (dry run)' : ''}. The dock follows it.`, 'ok');
|
||
dockPinned = false; return;
|
||
}
|
||
if (r.status === 409 && r.out.reasons){ $('sh-status').className = 'status err'; setText('sh-status', 'Blocked: ' + r.out.reasons.join('; ')); }
|
||
else if (r.status === 409){ SHEET.running = false; closeSheet(); toast(r.out.message || 'Another action is already running.', 'warn'); return; }
|
||
else { $('sh-status').className = 'status err'; setText('sh-status', `Refused (${r.status}): ` + (r.out.error || JSON.stringify(r.out))); }
|
||
}catch(e){ $('sh-status').className = 'status err'; setText('sh-status', 'The request failed: ' + e.message); }
|
||
finally{ if (SHEET){ SHEET.running = false; } go.disabled = false; $('sh-cancel').disabled = false; }
|
||
}
|
||
const IMG_INTERRUPTED_AT = {t: 0}, VID_INTERRUPTED_AT = {t: 0};
|
||
|
||
// ── the lane journey: loading a lane is one path, each step its own job ───────
|
||
// The server knows three moves (switch, stop, start) and refuses them out of order; the
|
||
// page chains them, one job after the other, and says each command before it runs.
|
||
// what a side lane's first Load builds before its switch fetches the checkpoint
|
||
const LANE_RUNTIME = {flash: 'its SGLang image (about 16 GB to download), its checkpoint (about 136 GB) and its reduced draft vocabulary',
|
||
'27b': 'its SGLang image (about 15 GB to download), its DFlash2 draft (about 2 GB) and its checkpoint (22 to 31 GB)',
|
||
image: 'a venv and SGLang Diffusion, about 12 GB, about 10 minutes',
|
||
'image-h3': 'a venv and SGLang Diffusion from its main branch, with FlashInfer’s kernels, about 15 GB, about 10 minutes',
|
||
video: 'a venv and SGLang Diffusion, about 12 GB, about 10 minutes, and the Turbo adapter',
|
||
kolibri: 'its vLLM image, about 10 GB to download (23 GB on disk), pulled and built here',
|
||
nemotron: 'its vLLM image, about 11 GB to download (25 GB on disk), pulled and built here',
|
||
'nemotron-super': 'the Nemotron 3.5 Bolt lane’s vLLM image, about 11 GB to download (25 GB on disk), pulled and built here once for both lanes',
|
||
'flash-local': 'its vLLM image with b12x, about 10 GB to download (18 GB on disk), pulled as its model card names it',
|
||
'ornith-122b': 'the Qwen3.8 Flash-Next FP4-Local lane’s vLLM image with b12x, about 10 GB to download (18 GB on disk), pulled once for the two',
|
||
'flash-unsloth': 'llama.cpp’s own server image for arm64 with CUDA, about 2.7 GB to download (4.5 GB on disk), pulled as its project publishes it',
|
||
transcribe: 'the Qwen3.8 Flash-Next Unsloth GGUF lane’s llama.cpp server image, about 2.7 GB to download (4.5 GB on disk), pulled once for the two',
|
||
lfm25: 'the Qwen3.8 27B lane’s SGLang image (about 15 GB to download), pulled once for the two',
|
||
lfm3: 'vLLM’s own nightly image, about 11.5 GB to download (28 GB on disk), pulled as published',
|
||
inkling: 'SGLang’s own image for it, about 16.4 GB to download (38.6 GB on disk), pulled as its cookbook names it'};
|
||
const SIDE_LANE = {[IMAGE_UNIT]: 'image', [VIDEO_UNIT]: 'video', [KOLIBRI_UNIT]: 'kolibri', [NEMOTRON_UNIT]: 'nemotron',
|
||
[NEMOTRON_SUPER_UNIT]: 'nemotron-super', [FLASH_LOCAL_UNIT]: 'flash-local', [ORNITH_UNIT]: 'ornith-122b',
|
||
[FLASH_UNSLOTH_UNIT]: 'flash-unsloth', [IMAGE_H3_UNIT]: 'image-h3', [TRANSCRIBE_UNIT]: 'transcribe',
|
||
[LFM25_UNIT]: 'lfm25', [LFM3_UNIT]: 'lfm3', [INKLING_UNIT]: 'inkling', [UFLASH]: 'flash', [U27]: '27b'};
|
||
// The lanes whose clients follow the window their unit starts with (FLASH_LOCAL_CONTEXT=1m, FLASH_UNSLOTH_CONTEXT=1m):
|
||
// switch-model.sh sets opencode, pi and claude-local for that window, and nothing else does. The Load of such a lane as
|
||
// the boot lane started or restarted its unit alone, so a window chosen with --units-only reached the engine and not
|
||
// the clients: back from 1M they kept a context of 830,000 tokens where the proxy refuses a prompt past 250,000, and
|
||
// on the way to 1M they kept 205,000 (code review of v1.48.0, 2026-11-12; the FP4-Local lane's since v1.45.2). Its Load
|
||
// now sets them first, with the step that sets them at every other Load, and a Load that starts nothing adds nothing.
|
||
const WINDOW_CLIENTS = new Set([FLASH_LOCAL_UNIT, FLASH_UNSLOTH_UNIT]);
|
||
const clientsStep = (unit, target) => ({name: 'switch', params: {target}, title: `Set the clients for ${LANE_NAME[unit]}’s window`,
|
||
desc: 'Verifies its files and sets opencode, pi and claude-local for the window its unit starts with. The lane does not restart. ' + AGENT_RESTART});
|
||
// The same clients for a lane that serves without being the boot lane, whose switch would point the boot at it: the
|
||
// clients alone (switch-model.sh --clients). The Load of an update to it set none, and a window chosen with
|
||
// --units-only reached the engine at its restart and not the clients (review of v1.48.0, 2026-11-13).
|
||
const clientsOnlyStep = (unit, target) => ({name: 'clients', params: {target}, title: `Set the clients for ${LANE_NAME[unit]}’s window`,
|
||
desc: 'Sets the limits of opencode, pi and claude-local, and the lane’s name in opencode, for the window its unit starts with; the boot and '
|
||
+ 'opencode’s default model stay where they are, and the lane does not restart. ' + AGENT_RESTART});
|
||
function laneJourneySteps(target){
|
||
const unit = TARGET_UNIT(target);
|
||
const steps = [];
|
||
// installed on demand: a lane whose runtime is not built yet builds it first, as the user
|
||
const lane = SIDE_LANE[unit];
|
||
// an update that waits for this Load (decision 1408): its preparation fetches what the new unit lacks, the step after
|
||
// puts the unit in place; the restart below applies it
|
||
const pendAll = (F.pending || {})[unit];
|
||
// a wait the unit in place changed since (a switch) is marked stale by the cockpit: said before the Load, which
|
||
// would download what it lacks and then drop it, so no step is proposed for it (review of v1.52.0, 2026-11-19)
|
||
const stale = !!pendAll && pendAll.length > 0 && String(pendAll[0]).startsWith('stale:');
|
||
const pend = stale ? null : pendAll;
|
||
// the 27B's and the flash lane's waiting unit or launcher goes in place by apply_pending (their switch rewrites only
|
||
// the target); a lane beside them takes its new unit from its switch, which renders it and fetches its checkpoint
|
||
// A wait serving ANOTHER target than the one asked is neither prepared nor posed: the switch renders the unit
|
||
// in place for the asked target and clears the wait (c59e015), and downloads nothing for the wait's target
|
||
// (third review of v1.52.0, 2026-11-19, GLM 5.3: the journey prepared the wait's checkpoint, 45 GB, then the
|
||
// switch overwrote it)
|
||
const pendTarget = (F.pendingTargets || {})[unit] || null;
|
||
const pendAsked = !pend || !pendTarget || pendTarget === target;
|
||
const applies = !!pend && pendAsked && (unit === U27 || unit === UFLASH);
|
||
if (lane && ((F.lanesReady || {})[lane] === false || (pend && pendAsked)))
|
||
steps.push({name: 'prepare', params: {target},
|
||
title: pend && pendAsked ? `Download what the update of ${LANE_NAME[unit]} needs` : `Build the runtime of ${LANE_NAME[unit]}`,
|
||
desc: pend && pendAsked ? `What its new unit reads and this box lacks${pend.length ? ': ' + pend.join('; ') : ''}, with no sudo. It serves meanwhile.`
|
||
: `Its first Load: ${LANE_RUNTIME[lane]}, with no sudo.` + (lane === 'flash' || lane === '27b' ? '' : ' The next step fetches its checkpoint.')});
|
||
if (applies)
|
||
steps.push({name: 'apply_pending', params: {unit}, title: `Put in place the update ${LANE_NAME[unit]} waited for`,
|
||
desc: `Its new unit replaces the one it served with${pend.length ? ', now that the box has what it lacked: ' + pend.join('; ') : ''}. Nothing restarts yet.`});
|
||
// The Load of the lane that serves this very target, with an update owed to it, is the
|
||
// restart that applies the update and nothing else: the steps below would point the boot at
|
||
// it (a lane started as installed is not the boot lane) or switch it back, which no update
|
||
// asked for (found in review, 2026-10-17). The lane's card asks the same of it (lanes.js).
|
||
const sv0 = servingEngine();
|
||
if (sv0 && sv0[0] === unit && laneTarget(unit) === target && (updateOwed(unit) || applies))
|
||
return steps.concat(!WINDOW_CLIENTS.has(unit) ? [] : bootUnit() === unit ? [clientsStep(unit, target)] : [clientsOnlyStep(unit, target)],
|
||
[{name: 'unit', params: {verb: 'restart', unit}, title: `Restart ${LANE_NAME[unit]} on what the update installed`,
|
||
desc: `It answers again in ${readyIn(unit)}.` + (isImageLane(unit) || unit === VIDEO_UNIT ? ' A generation in flight is lost.' : '')}]);
|
||
const serving = servingEngine();
|
||
// none enabled: the switch step makes this one the boot lane, as it does from any other
|
||
const enabled = bootUnit();
|
||
const curTarget = (engines()[unit] || {}).target;
|
||
// a lane that cannot start as installed (its checkpoint or a copy of its table missing) gets the
|
||
// switch, which fetches and copies them, even as the boot lane already: its Load started it
|
||
// alone and it failed again on the same missing file (found in review, 2026-10-20)
|
||
const whole = !lane || (F.lanesStartable || {})[lane] !== false;
|
||
const switchAt = steps.length;
|
||
if (enabled !== unit || (curTarget && curTarget !== target) || (!curTarget && LANE_TARGETS[unit].length > 1 && target !== LANE_TARGETS[unit][0])
|
||
|| !whole || (pend && pendAsked && !applies))
|
||
// for a boot lane that lacks a file, the step fetches or copies it: up to 102 GB, not a check
|
||
steps.push({name: 'switch', params: {target},
|
||
title: pend && pendAsked && !applies ? `Put the update of ${LANE_NAME[unit]} in place`
|
||
: whole || enabled !== unit ? `Point the boot at ${TARGET_NAME[target]}` : `Bring back what ${LANE_NAME[unit]} lacks`,
|
||
desc: pend && pendAsked && !applies ? 'Fetches the checkpoint its new unit reads, puts that unit in place and makes this lane the one enabled at boot. Nothing restarts.'
|
||
: whole ? 'Verifies the checkpoint and makes this lane the one enabled at boot. Nothing restarts.'
|
||
: 'Fetches what its checkpoint lacks' + (unit === FLASH_LOCAL_UNIT ? ' and copies its n-gram table again (up to 102 GB to fetch, 32 GB to copy)' : '')
|
||
+ ', and makes this lane the one enabled at boot. Nothing restarts.'});
|
||
const pointed = steps.length > switchAt;
|
||
if (serving && serving[0] !== unit)
|
||
steps.push({name: 'unit', params: {verb: 'stop', unit: serving[0]}, title: `Stop ${laneLabel(serving[0])}`,
|
||
desc: isImageLane(serving[0]) || serving[0] === VIDEO_UNIT ? 'A generation in flight is lost.' : 'Clients on :30001 see the engine unavailable until the next one answers.'});
|
||
// The engine serves what it loaded when it started; a switch since then (a journey that
|
||
// stopped after its first step, switch-model.sh from a terminal) changed only what the
|
||
// next start loads, and the restart is still owed. Read against the unit's file alone, the
|
||
// journey had no step left and said "already serving" of a checkpoint that was not
|
||
// (found 2026-10-05: flash served while its unit pointed at flash-uncensored).
|
||
const served = servedTarget(unit), owed = !!(served && served !== target);
|
||
// The image engine says what it serves (cockpit.py, once per life of its unit): a switch
|
||
// that only points the unit at the checkpoint it already serves owes no restart, which
|
||
// would end a generation for nothing.
|
||
const switched = isImageLane(unit) && served ? owed : steps.length || owed;
|
||
// An update that changed what this engine starts with, while it served, owes a restart
|
||
// too: what it brought applies at the next start (cockpit.py, stale_engines).
|
||
const updated = !!updateOwed(unit);
|
||
if (serving && serving[0] === unit && (switched || updated))
|
||
steps.push({name: 'unit', params: {verb: 'restart', unit},
|
||
title: switched ? `Restart ${LANE_NAME[unit]} on the new checkpoint` : `Restart ${LANE_NAME[unit]} on what the update installed`,
|
||
desc: `It answers again in ${readyIn(unit)}.` + (isImageLane(unit) || unit === VIDEO_UNIT ? ' A generation in flight is lost.' : '')});
|
||
else if (!serving || serving[0] !== unit)
|
||
steps.push({name: 'unit', params: {verb: 'start', unit}, title: `Start ${LANE_NAME[unit]}`, desc: `It loads and answers in ${readyIn(unit)}.`});
|
||
// a boot lane whose clients follow its window, started or restarted: they are set first, where its switch would be
|
||
if (WINDOW_CLIENTS.has(unit) && !pointed && steps.length && steps[steps.length - 1].params.unit === unit)
|
||
steps.splice(switchAt, 0, clientsStep(unit, target));
|
||
return steps;
|
||
}
|
||
// What an update owes the engine of this unit, in words, or null (cockpit.py, stale_engines).
|
||
// Only for an engine that serves: one that boots starts on what is installed, and the tier's
|
||
// answer from before its restart offered that restart again, which would throw the boot away.
|
||
// And not while a switch waits for its restart: the switch rewrote the same files, the "next
|
||
// start loads" banner says so, and its Load applies both; the restart offered here undid the
|
||
// switch (both found in review, 2026-10-17).
|
||
function updateOwed(unit){
|
||
const why = unit && ((F.update || {}).stale_engines || {})[unit];
|
||
if (!why) return null;
|
||
const e = engines()[unit] || {};
|
||
if (e.state !== 'ready' && e.state !== 'degraded') return null;
|
||
const served = servedTarget(unit);
|
||
if (served && e.target && served !== e.target) return null;
|
||
return why;
|
||
}
|
||
function askJourney(target, opts = {}){
|
||
if (offline) return toast('The cockpit is unreachable right now: nothing can be started.', 'err');
|
||
if (loadRunning()) return toast(LOAD_RUNNING, 'warn');
|
||
if (F.job && F.job.current) return toast(busyWhy(), 'warn');
|
||
if (!$('scrim').hidden) return;
|
||
const unit = TARGET_UNIT(target);
|
||
if (!installed(unit)) return toast(`${LANE_NAME[unit]} is not installed on this box. ${installHint(unit)}`, 'warn', 7000);
|
||
const steps = laneJourneySteps(target);
|
||
if (!steps.length) return toast(`${TARGET_NAME[target]} is already serving.`, 'ok');
|
||
setText('sh-title', `Load ${TARGET_NAME[target]}`);
|
||
setText('sh-lede', (TARGET_NOTE[target] || '') + `\n\nThe page runs these steps one after the other, each as its own job, and stops at the first that fails. Hide puts this window away while they run; closing the page stops the chain after the step that is running.` + (F.config.dry_run ? '\n\nDry run: nothing will really be executed, the state on the box never moves, and a gate can refuse a later step of the walk-through because it still reads the box as it was.' : ''));
|
||
const w = $('sh-warns'); clear(w);
|
||
const serving = servingEngine();
|
||
const warns = [];
|
||
if (serving && serving[0] === UFLASH && TRANSITIONAL.has(serving[1].state)) warns.push('Flash is booting: stopping now throws that boot away, and the next start takes a whole boot again.');
|
||
if (serving && serving[0] !== unit && (serving[0] === U27 || serving[0] === UFLASH || serving[0] === LFM25_UNIT || serving[0] === INKLING_UNIT || serving[0] === KOLIBRI_UNIT || isVllmTable(serving[0]) || isLlamacpp(serving[0]))) warns.push('Agent clients on :30001 lose their engine until a text lane answers again.');
|
||
// stopped for another lane, or restarted on its other checkpoint: either ends a generation
|
||
if (serving && (isImageLane(serving[0]) || serving[0] === VIDEO_UNIT) && steps.some(s => s.name === 'unit' && s.params.unit === serving[0]))
|
||
warns.push('A generation in flight on ' + laneLabel(serving[0]) + ' is lost.');
|
||
warns.forEach(x => w.append(el('p', null, x))); w.hidden = !warns.length;
|
||
const j = $('sh-journey'); clear(j); j.hidden = false;
|
||
steps.forEach((s, i) => {
|
||
const li = el('li'); li.dataset.i = i;
|
||
const n = el('span', 'n', String(i + 1));
|
||
const body = el('div'); body.append(el('div', 't', s.title), el('div', 'd', s.desc));
|
||
const c = el('pre', 'cmd', argvFor(s.name, s.params).join(' ')); body.append(c);
|
||
li.append(n, body); j.append(li);
|
||
});
|
||
show('sh-cmd-lbl', false); show('sh-cmd', false);
|
||
// a first Load downloads before it boots, and the page can time the boot, not the downloads
|
||
const boot = fmtMin(bootSeconds(unit) + 15);
|
||
setText('sh-status', steps.some(s => s.name === 'prepare')
|
||
? `${steps.length} steps: its first Load downloads first (the line under each step says how far it is), then it answers in about ${boot}`
|
||
: `${steps.length} step${steps.length > 1 ? 's' : ''}, about ${boot} in all`);
|
||
$('sh-status').className = 'status';
|
||
const go = $('sh-go'); go.disabled = false; go.className = 'btn primary'; setText(go, `Load ${LANE_NAME[unit]}`);
|
||
SHEET = {mode: 'journey', target, steps, idx: 0, onClose: opts.onClose};
|
||
openSheet();
|
||
}
|
||
function jStep(i, cls){ const li = $('sh-journey').children[i]; if (li) li.className = cls; }
|
||
// What the step running now is doing, under it: its time so far and its job's last output
|
||
// line. The window said only "Step 1 of 2" through a 22-minute download, and it read as
|
||
// frozen (2026-10-05); the dock had the line, under the sheet.
|
||
function jLive(i, text){
|
||
const li = $('sh-journey').children[i]; if (!li) return;
|
||
let p = li.querySelector('.live');
|
||
if (!p){ if (text == null) return; p = el('div', 'd live'); li.lastChild.append(p); }
|
||
if (text == null) p.remove(); else setText(p, text);
|
||
}
|
||
const jobLast = cur => String((cur.lines || []).slice(-1)[0] || '').replace(/\x1b\[[0-9;]*[A-Za-z]/g, '').trim();
|
||
async function runJourney(){
|
||
const S = SHEET; S.running = true;
|
||
$('sh-go').disabled = true; setText($('sh-cancel'), 'Hide'); journeyChanged();
|
||
// A step that fails stops the chain, said in one place: the window comes back over whatever was open
|
||
// (the menu, the image viewer), with the focus on its status line, never on a button, and deaf to Escape
|
||
// and to a click outside it for a second (justBack): a key or a click the person aimed elsewhere can
|
||
// neither run the step again nor dismiss why it failed.
|
||
let fail = null;
|
||
try {
|
||
for (let i = S.idx; i < S.steps.length; i++){
|
||
S.at = i;
|
||
const st = S.steps[i]; jStep(i, 'run');
|
||
setText('sh-status', `Step ${i + 1} of ${S.steps.length}: ${st.title}…`);
|
||
let r;
|
||
try { r = await runAction(st.name, st.params); } catch(e){ r = {ok: false, status: 0, out: {error: e.message}}; }
|
||
if (!r.ok){
|
||
const why = r.out.reasons ? r.out.reasons.join('; ') : r.out.error || r.out.message || 'HTTP ' + r.status;
|
||
fail = {i, text: `Step ${i + 1} refused: ` + why + (F.config.dry_run && r.out.reasons ? ' (dry run: the steps above changed nothing on the box, so the gate still reads the state as it was)' : '')};
|
||
break;
|
||
}
|
||
const id = r.out.job || r.out.id; S.jobId = id;
|
||
const res = await waitJob(id, cur => { const last = jobLast(cur); jLive(i, fmtDur(cur.elapsed) + ' so far' + (last ? ': ' + last : '')); });
|
||
S.jobId = null;
|
||
if (!res.ok){
|
||
fail = {i, text: `Step ${i + 1} ${res.why}. ` + (res.lost ? 'The Now view and Logs say where the lane is before anything is retried.' : 'Its log is in the dock.')};
|
||
break;
|
||
}
|
||
jLive(i, null);
|
||
jStep(i, 'done');
|
||
if (st.name === 'unit' && st.params.verb !== 'start'){
|
||
if (isImageLane(st.params.unit)) IMG_INTERRUPTED_AT.t = Date.now();
|
||
if (st.params.unit === VIDEO_UNIT) VID_INTERRUPTED_AT.t = Date.now();
|
||
// the next start is refused until the stopped lane reads down: wait for it.
|
||
// A dry run never moves the engine state, so the wait would burn its whole
|
||
// budget on every stop step and read as a stuck journey.
|
||
if (!F.config.dry_run) await waitFor(() => { const e = engines()[st.params.unit]; return !e || UNIT_DOWN.has(e.state); }, 90000);
|
||
}
|
||
}
|
||
} catch (e) { // an error in the page itself: the chain stops where it was, said like a failed step
|
||
fail = {i: S.at || 0, text: `Step ${(S.at || 0) + 1} stopped on an error in the page (${e && e.message ? e.message : e}). The Now view and Logs say where the lane is before anything is retried.`};
|
||
}
|
||
if (fail){
|
||
jStep(fail.i, 'fail'); S.running = false; S.idx = fail.i; S.jobId = null;
|
||
$('sh-status').className = 'status err'; setText('sh-status', fail.text);
|
||
$('sh-go').disabled = false; setText($('sh-cancel'), 'Cancel'); setText($('sh-go'), 'Retry from here');
|
||
if (S.hidden && SHEET === S){
|
||
closeMenu(); if (!$('viewer').hidden) closeViewer();
|
||
S.hidden = false; S.backAt = Date.now(); openSheet('sh-status');
|
||
}
|
||
journeyChanged(); return;
|
||
}
|
||
// nothing is left to cancel: the button only closes the window, which closes itself below
|
||
S.running = false; setText($('sh-cancel'), 'Close');
|
||
setText('sh-status', 'Done. The lane is booting: the Now view and the dock follow it.');
|
||
if (S.hidden){ // put away: the page stays where the person went, a toast says it ended
|
||
if (SHEET === S) closeSheet(); else journeyChanged();
|
||
toast(`Load ${TARGET_NAME[S.target]}: every step done. The lane is booting; the Now view and the dock follow it.`, 'ok', 7000);
|
||
return;
|
||
}
|
||
setTimeout(() => { if (SHEET === S) closeSheet(); showView('now'); }, 900);
|
||
}
|
||
// A job is done when the job collector shows it finished. Resolves {ok, why} ({lost} too, for
|
||
// a job the cockpit no longer knows). It follows the job for as long as the job runs: the
|
||
// server bounds every action itself (a switch has 7,200 s, for a download), and a fixed
|
||
// 20 min here gave up 2 minutes before a healthy 22-minute switch to flash-uncensored (a
|
||
// 135 GB checkpoint) ended, so the restart after it never ran (found 2026-10-05).
|
||
// onTick(job) sees the running job at every tick.
|
||
const JOB_LOST_MS = 60 * 1000;
|
||
function waitJob(id, onTick){
|
||
let gone = null;
|
||
return new Promise(resolve => {
|
||
const tick = () => {
|
||
const j = F.job || {};
|
||
const cur = j.current, found = (j.recent || []).find(x => x.id === id);
|
||
if (found && (!cur || cur.id !== id)){
|
||
return resolve(found.status === 'done' ? {ok: true} : {ok: false, why: `failed${found.rc != null ? ' with exit code ' + found.rc : ''}`});
|
||
}
|
||
if (cur && cur.id === id){
|
||
gone = null;
|
||
if (onTick) try { onTick(cur); } catch { /* the live line is a courtesy, never the wait */ }
|
||
} else if (gone === null) gone = Date.now();
|
||
// neither running nor finished: a cockpit restarted under it keeps no job history
|
||
else if (Date.now() - gone > JOB_LOST_MS) return resolve({ok: false, lost: true, why: 'is no longer known to the cockpit (restarted?), so how it ended is unknown'});
|
||
setTimeout(tick, 500);
|
||
};
|
||
tick();
|
||
});
|
||
}
|
||
function waitFor(pred, timeoutMs){
|
||
const t0 = Date.now();
|
||
// a predicate that throws (state not read yet after a reconnect) counts as not yet: a throw inside the
|
||
// timer would leave the promise pending for good, and a load waiting on it running forever
|
||
const holds = () => { try { return !!pred(); } catch { return false; } };
|
||
return new Promise(resolve => { const tick = () => { if (holds() || Date.now() - t0 > timeoutMs) return resolve(); setTimeout(tick, 500); }; tick(); });
|
||
}
|
||
|
||
// ── the dock: the job running now, from every view and every browser ─────────
|
||
let dockPinned = false, dockHidden = null, lastFinished;
|
||
const JOBLINES = {id: null, lines: [], final: null, read: null};
|
||
// A job that prints nothing, like systemctl, said "starting…" under "Stop 27B" while it stopped the lane, and its log
|
||
// "(no output yet)" after it had ended (issue #64): it says what it does in its own verb, and its log the command first
|
||
const UNIT_DOING = {start: 'starting', stop: 'stopping', restart: 'restarting'};
|
||
const jobDoing = j => `${(j.action === 'unit' && UNIT_DOING[(j.params || {}).verb]) || 'running'}, nothing printed yet`;
|
||
// "(it printed nothing)" only once its last lines were read: a page opened after the job had ended said it of a job
|
||
// that printed hundreds of lines until the fetch answered, and for good when it failed (review of v1.45.0). And no
|
||
// "$" line in a dry run, where nothing runs: the server's own line says what would have (review of v1.45.0)
|
||
function jobLog(j, lines, ended){
|
||
const head = j && j.argv && !j.dry_run ? ['$ ' + j.argv.join(' ')] : [];
|
||
const none = !ended ? '(nothing printed yet)' : j && JOBLINES.read === j.id ? '(it printed nothing)' : '(reading its log…)';
|
||
return head.concat(lines.length ? lines : [none]).join('\n');
|
||
}
|
||
function describeJob(j){ return cap1(actionPhrase(j.action, j.params)) + (j.origin === 'autoheal' ? ', by the autoheal belt' : '')
|
||
+ (j.origin === 'boot' ? ', again at the cockpit’s start' : '') + (j.dry_run ? ' (dry run)' : ''); }
|
||
function renderJob(d){
|
||
F.job = d;
|
||
const dock = $('dock'), cur = d.current, recent = (d.recent || [])[0];
|
||
const now = Date.now() / 1000;
|
||
let showIt = false, shown = null;
|
||
if (cur){
|
||
shown = cur;
|
||
showIt = dockHidden !== cur.id;
|
||
dock.className = 'dock'; $('dock-lamp').className = 'lamp warn live';
|
||
setText('dock-what', describeJob(cur)); setText('dock-time', fmtDur(cur.elapsed));
|
||
show('dock-bar', true);
|
||
if (JOBLINES.id !== cur.id){ JOBLINES.id = cur.id; JOBLINES.lines = []; }
|
||
if (cur.lines && cur.lines.length) JOBLINES.lines = cur.lines;
|
||
setText('dock-last', JOBLINES.lines.length ? JOBLINES.lines[JOBLINES.lines.length - 1] : jobDoing(cur));
|
||
} else {
|
||
if (recent && (now - (recent.ended || recent.started) < 60 || dockPinned) && dockHidden !== recent.id){
|
||
showIt = true; shown = recent;
|
||
const ok = recent.status === 'done';
|
||
dock.className = 'dock ' + (ok ? 'done' : 'failed'); $('dock-lamp').className = 'lamp ' + (ok ? 'ok' : 'err');
|
||
setText('dock-what', describeJob(recent)); setText('dock-time', fmtDur(recent.elapsed)); show('dock-bar', false);
|
||
const r = recent.result || {};
|
||
setText('dock-last', r.reply ? `reply: ${r.reply}` : r.path ? `written: ${r.path}` : r.reason === 'busy' ? 'the engine refused: requests still running'
|
||
: ok ? (recent.argv ? `finished, exit code ${recent.rc}` : 'finished') : `failed${recent.rc != null ? ` (exit code ${recent.rc})` : ''}: open the log`);
|
||
if (JOBLINES.id !== recent.id){ JOBLINES.id = recent.id; JOBLINES.lines = []; }
|
||
// its last lines are fetched once it ended: the running snapshot stops short of the end
|
||
if (JOBLINES.final !== recent.id){ JOBLINES.final = recent.id; fetchJobLines(recent.id); }
|
||
}
|
||
if (recent){
|
||
if (lastFinished === undefined) lastFinished = recent.id; // first sight: adopt, do not act
|
||
else if (lastFinished !== recent.id){ lastFinished = recent.id; (HANDLERS.job_finished || []).forEach(f => { try { f(recent); } catch { /* isolated */ } }); }
|
||
}
|
||
}
|
||
dock.hidden = !showIt;
|
||
renderPip();
|
||
setText('dock-pre', jobLog(shown, JOBLINES.lines, !cur));
|
||
const pre = $('dock-pre'); if (!pre.hidden) pre.scrollTop = pre.scrollHeight;
|
||
const say = cur ? `${describeJob(cur)}: running` : recent ? `${describeJob(recent)}: ${recent.status}` : '';
|
||
say && sayOnce('job', say);
|
||
applyBusy();
|
||
}
|
||
async function fetchJobLines(id){
|
||
try{ const r = await fetch('/api/jobs/' + id); if (r.status === 401) return login(); if (!r.ok) return;
|
||
const j = await r.json(); if (JOBLINES.id === id){ JOBLINES.lines = j.lines || []; JOBLINES.read = id; setText('dock-pre', jobLog(Object.assign({id}, j), JOBLINES.lines, true)); } }
|
||
catch { /* the dock keeps what it has */ }
|
||
}
|
||
// what a screen reader hears when a lane or a job changes state, once per change
|
||
const SAID = {};
|
||
function sayOnce(key, txt){ if (SAID[key] === txt) return; SAID[key] = txt; setText('sayer', txt); }
|
||
|
||
// Every control that runs an action is disabled, with its reason, while it cannot.
|
||
// [data-busy] is the same disabling for a control that does not open the action sheet
|
||
// (the sign-out button signs out at once): data-act means "opens the sheet", nothing else.
|
||
function applyBusy(){
|
||
const why = busyWhy(), eng = noEngineWhy();
|
||
document.querySelectorAll('[data-act], [data-busy]').forEach(b => {
|
||
const need = NEEDS_ENGINE.has(b.dataset.act) ? eng : '';
|
||
const own = b.dataset.blocked || '';
|
||
b.disabled = !!(why || need || own);
|
||
b.title = why || need || own || b.dataset.title || '';
|
||
});
|
||
(HANDLERS.busy || []).forEach(f => { try { f(why); } catch { /* isolated */ } });
|
||
}
|
||
|
||
// ── banners: what you did not go looking for ──────────────────────────────────
|
||
// The settings conformity.py compares that are no variable of their own, as the page names them
|
||
// (v1.36.0): the same names install.sh's list gives them.
|
||
const CF_NAME = {'target.27b': '27B target', 'target.flash': 'flash target', DRAFT2: '27B drafter',
|
||
KOLIBRI_VARIANT: 'Kolibri-1 checkpoint', IMAGE_MODEL: 'image model', VIDEO_VARIANT: 'video variant',
|
||
FLASH_UNSLOTH_TARGET: 'Unsloth GGUF target'};
|
||
const cfName = i => CF_NAME[i.knob] || i.knob;
|
||
function wedgeNext(){
|
||
const c = F.config || {};
|
||
if (c.autoheal) return 'The autoheal belt restarts it' + (c.autoheal_grace_s ? ` after its ${fmtDur(c.autoheal_grace_s)} grace period` : '');
|
||
return 'Nothing restarts it by itself (the autoheal belt is off; COCKPIT_AUTOHEAL=1 arms it): stop it and start it again from Lanes';
|
||
}
|
||
function renderBanners(state, errors){
|
||
const box = $('banners'); if (!box) return;
|
||
const want = [];
|
||
// cmd: a command the banner asks to run, shown apart with its copy icon (Hasan, 2026-10-21:
|
||
// selecting it by hand out of a sentence was the only way)
|
||
// list: lines a banner shows one under the other, between its title and its sentence (the commits of the clone)
|
||
const add = (kind, strong, text, cmd, list) => want.push([kind, strong, text, cmd, list]);
|
||
const otherUp = n => Object.entries(engines()).some(([m, x]) => m !== n && (!UNIT_DOWN.has(x.state) || x.restarting));
|
||
if (offline) add('err', 'Connection lost.', `No data from the cockpit for ${fmtDur((Date.now() - lastMsgAt) / 1000)}: what is on screen is frozen and actions wait.`);
|
||
if (F.config && F.config.dry_run) add('info', 'Dry run.', 'Every action is confirmed, logged and audited as usual, but nothing is executed. This instance exists for tests.');
|
||
Object.entries(engines()).forEach(([n, e]) => {
|
||
const name = LANE_NAME[n] || n;
|
||
if (e.state === 'wedged') add('err', `${name} is wedged.`, `It answers health checks but generates nothing. ${wedgeNext()}. The Logs view has the scheduler forensics.`);
|
||
// the start guard holds a start while the last engine's GPU memory is not back, and refuses
|
||
// it if it stays held: that is no crash, and saying "keeps crashing" sent people after one
|
||
if (e.held) add('warn', `${name} waits for GPU memory.`, `${sentence(e.held)}. It starts by itself once that memory is back: starting on memory the driver kept is how sglang#40948 froze a DGX Spark until a power cycle.`);
|
||
// the GPU itself: no wait, memory or reboot changes it, and systemd does not start it again.
|
||
// Said while no other lane is up, whose Load is the way out it names: a unit that exited 78
|
||
// stays failed until a reboot, and the banner stayed red over the lane that serves.
|
||
if (e.state === 'failed' && e.cannot) { if (!otherUp(n)) add('err', `${name} cannot start on this box.`, `${sentence(e.cannot)}. Load another lane from Lanes.`); }
|
||
// a file the engine reads is missing (its checkpoint, a copy of its table): the unit exited 78
|
||
// and stays failed, and its Load fetches the file again (its switch step, laneJourneySteps)
|
||
else if (e.state === 'failed' && e.lacks) { if (!otherUp(n)) add('err', `${name} cannot start: a file it reads is missing.`, `${sentence(e.lacks)}.`); }
|
||
else if (e.state === 'failed' && e.refused) add('err', `${name} is not starting.`, `${sentence(e.refused)}. ` + (e.restarting ? 'systemd checks again every 15 s and starts it once that memory is back; if nothing holds it, a reboot frees it.' : 'Start it again from Lanes once that memory is back; if nothing holds it, a reboot frees it.'));
|
||
else if (e.state === 'failed' && e.restarting && e.crashed_serving) add('warn', `${name} stopped while it was serving and is starting again.`, 'systemd starts it again 15 s after it stops, and the lane comes back by itself. Its journal in Logs says why it stopped.');
|
||
else if (e.state === 'failed' && e.restarting) add('err', `${name} keeps crashing.`, `It dies during startup and systemd relaunches it every 15 s${e.restarts ? ` (${e.restarts} so far)` : ''}. Stop it from Lanes to end the loop; its journal is in Logs.`);
|
||
else if (e.state === 'failed' && e.result === 'timeout') add('warn', `${name} was killed while stopping.`, 'It did not exit within its stop timeout. Nothing broke while it served: start it again when you need it.');
|
||
else if (e.state === 'failed') add('err', `${name} failed.`, 'systemd reports the unit failed. Read its journal in Logs, then start it again from Lanes.');
|
||
// a server alive without its scheduler answers nothing, and systemd sees nothing wrong
|
||
if (e.zombie) add('err', `${name} lost its scheduler.`, 'Its server process lives on and answers nothing, and systemd sees nothing wrong, so it would never come back by itself. '
|
||
+ ((F.config || {}).zombie_restart ? (e.zombie_in > 0 ? `The cockpit restarts it in ${fmtDur(e.zombie_in)}.` : 'The cockpit restarts it now.') : 'Restart it from Lanes (COCKPIT_ZOMBIE_RESTART=0 keeps the cockpit from doing it).'));
|
||
else if (e.state === 'degraded') add('warn', `${name} stopped answering.`, 'It was serving; health probes retry every 2 s. If it stays here, Logs says why.');
|
||
});
|
||
// A switch that is not restarted yet: the unit loads one checkpoint at its next start while
|
||
// the engine serves another, and nothing else on the page said so.
|
||
const sv = servingEngine();
|
||
// degraded too: it still serves what it loaded, and the update banner below keeps quiet then
|
||
if (sv && (sv[0] === U27 || sv[0] === UFLASH || sv[0] === KOLIBRI_UNIT || isB12x(sv[0]) || isLlamacpp(sv[0]) || isImageLane(sv[0])) && (sv[1].state === 'ready' || sv[1].state === 'degraded')){
|
||
const served = servedTarget(sv[0]), next = sv[1].target;
|
||
if (served && next && served !== next)
|
||
add('info', `${TARGET_NAME[served]} is serving, and the lane's next start loads ${TARGET_NAME[next]}.`,
|
||
`The switch to ${TARGET_NAME[next]} is written but its restart has not run, so clients still get ${TARGET_NAME[served]}. Load ${TARGET_NAME[next]} in Lanes restarts it (${readyIn(sv[0])}).`);
|
||
}
|
||
// An update rewrote what the serving engine starts with (its unit, a file it reads at its
|
||
// start, its image) and left it serving, as an update does: only the installer's output
|
||
// said a restart was owed (found 2026-10-16: Bolt's prefix cache settings, v1.35.0).
|
||
const upd0 = sv && updateOwed(sv[0]);
|
||
if (upd0) add('warn', `${laneLabel(sv[0])} runs what it started with, not what the update installed.`,
|
||
`${upd0}. It applies at its next start: Restart ${LANE_NAME[sv[0]]} to apply the update, on its card in Lanes (it answers again in ${readyIn(sv[0])}).`);
|
||
// since v1.40.3 the stop goes through the proxy, which cuts each client instead of letting its
|
||
// stream end as if the answer were whole, and holds new generations back while memory is short.
|
||
// What it did is the cockpit's to say (mem_floor.said): it claimed every generation stopped and
|
||
// new requests held where the proxy had cut none (code review, 2026-10-26)
|
||
if (F.memFloor && F.memFloor.aborts && F.memFloor.last_abort && Date.now() / 1000 - F.memFloor.last_abort < 600){
|
||
const ago = fmtDur(Date.now() / 1000 - F.memFloor.last_abort);
|
||
add('warn', 'The memory floor fired.', F.memFloor.via === 'proxy' && F.memFloor.said
|
||
? `Memory fell under ${F.memFloor.gib} GiB with requests running, ${ago} ago. To keep the box out of a livelock: ${F.memFloor.said}.`
|
||
: `Memory fell under ${F.memFloor.gib} GiB with requests running: every generation was aborted ${ago} ago to keep the box out of a livelock.`);
|
||
}
|
||
// Cohere's report (2026-10-26): the proxy writes down a tool call whose arguments name an Alibaba
|
||
// Cloud host or a cloud metadata address, whatever the client, and relays it as it came (v6.48)
|
||
const tt = F.toolTargets;
|
||
if (tt && tt.count && tt.last)
|
||
add('err', `A model asked a tool to reach ${tt.last.hosts}.`,
|
||
`${tt.count === 1 ? 'One tool call' : `${tt.count} tool calls`} in the last 24 h named an Alibaba Cloud host or a cloud metadata address (Cohere's report on Qwen3.8-Flash-Next), the last ${fmtDur(Math.max(0, Date.now() / 1000 - tt.last.at))} ago in a ${tt.last.tool} call on ${tt.last.path}. The proxy only reports it: whether the call ran depends on the client and its rules (docs/agents-and-network.md).`);
|
||
// A long prompt sent again after its client left it without an answer (proxy v6.49, issue #61): on
|
||
// the Ornith lane Claude Code left a prompt of 500,161 tokens after 620 s, twice, then 300 s, twice,
|
||
// and the engine kept what it had computed only every other time, so its answer came after 35 min
|
||
const rs = F.resent;
|
||
if (rs && rs.count && rs.last)
|
||
add('warn', 'A client gave up on a long prompt and sent it again.',
|
||
`${rs.count === 1 ? 'Once' : `${rs.count} times`} in the last 24 h, the last ${fmtDur(Math.max(0, Date.now() / 1000 - rs.last.at))} ago: `
|
||
+ `${rs.last.who} left it without an answer after ${fmtDur(rs.last.secs)} (${rs.last.n} time${rs.last.n > 1 ? 's' : ''} in a row), `
|
||
+ `and the engine computed it again, from what its prefix cache had kept of it, if anything. ${rs.last.advice}.`);
|
||
const upd = F.update || {};
|
||
// An update that runs now (install.sh keeps a file while it lasts, the cockpit checks its process):
|
||
// the banners that ask for one wait, since one runs (an ASUS Ascent GX10, 2026-10-21: an update of
|
||
// 1 h 45, a checkpoint of 144 GB, under the orange banner that asked for it), and so does the one
|
||
// that asks to restart this cockpit, which the update restarts
|
||
const run = upd.install_running;
|
||
if (run) add('info', run.to ? `Installing ${run.to}.` : 'The installer is running.',
|
||
`It started ${fmtMin(Math.max(0, Date.now() / 1000 - run.started))} ago. There is nothing to run meanwhile: this page says what is left to do once it ends.`);
|
||
if (upd.behind && !run) add('info', `Version ${upd.latest} is out; this box runs ${upd.installed}.`, 'The update keeps your choices, and moves a default an older release left to today\'s: it lists both before its first step. Update with:', updateCmd(F.config));
|
||
// The services behind their own clone (v1.36.0): installed.json names the release and the
|
||
// commit the last run that ended well installed. A git pull with no ./install.sh moves the
|
||
// clone and not the services, and a run stopped at --no-start updated neither the side lanes,
|
||
// nor the proxy, nor the cockpit; a box no run of v1.36.0 or later recorded is said once.
|
||
if (upd.behind_clone && !run){
|
||
const why = upd.behind_clone_why;
|
||
// the same release on both sides names the commits (Hasan's capture, 2026-10-29: "the services run
|
||
// v1.40.4, the clone is v1.40.4" said nothing of what moved); "past it" only with the commits the server found
|
||
// past the recorded one, which it looks for only in a clone that descends from it (review, 2026-10-30). The
|
||
// server names the two commits only for the same release on both sides: it alone decides that case here.
|
||
const same = !!upd.installed_commit, n = upd.commits_count, cs = upd.commits || [];
|
||
const past = n ? `${n === 1 ? 'one commit' : n + ' commits'} past it, at` : 'at';
|
||
// a clone get.sh refuses to update (off its channel's branch, or with commits of its own) gets its own installer: get.sh, which the
|
||
// banner gave it, refused (review of v1.48.0, 2026-11-13)
|
||
const cmd = upd.clone_local ? localInstallCmd(F.config) : updateCmd(F.config);
|
||
if (why === 'commit') add('orange', same
|
||
? `The clone moved on since the last install: the services run ${upd.installed} at ${upd.installed_commit}, the clone is ${past} ${upd.clone_commit}.`
|
||
: `The clone moved on since the last install: the services run ${upd.installed}, the clone is ${upd.clone || 'newer'}.`,
|
||
upd.clone_local ? 'This clone is off its channel\'s branch (main or stable) or holds commits of its own, which the one-line update refuses to install. Run its installer so the services follow it:'
|
||
: 'A git pull changes the files, not what runs. Run the installer so the services follow it:', cmd,
|
||
// one commit a line: joined by commas, subjects that hold commas themselves ran into each other (review)
|
||
same && cs.length ? cs.concat(n > cs.length ? [`and ${n - cs.length} more`] : []) : null);
|
||
else if (why === 'no-start') add('orange', 'The last install stopped at --no-start.',
|
||
'The side lanes, the proxy and the cockpit were not updated with it. Run it again without --no-start:', cmd);
|
||
else add('orange', `No install of v1.36.0 or later recorded what this box runs.`,
|
||
'The services run a release before it, or one an install that did not end well left. Run the installer once:', cmd);
|
||
}
|
||
// This box against what its clone recommends (v1.36.0, 2026-10-17): an orange banner when the
|
||
// next update moves something, so that nobody runs behind in silence. The operator's own
|
||
// choices make none (Hasan, 2026-10-17: a choice is not a delay, and a box that keeps one wore
|
||
// the banner for good); Settings lists each difference.
|
||
const cf = (upd.conformity || {}).items || [];
|
||
const moves = cf.filter(i => i.group === 'moves');
|
||
if (moves.length && !run){
|
||
const rel = upd.conformity.release || 'this release', kept = cf.length - moves.length;
|
||
add('orange', `This box runs ${moves.length === 1 ? 'a default' : moves.length + ' defaults'} of an older release.`,
|
||
`${moves.map(i => `${cfName(i)} ${i.value}`).join(', ')}: the next update moves ${moves.length === 1 ? 'it' : 'them'} to what ${rel} recommends`
|
||
+ (kept ? `, and keeps ${kept === 1 ? 'one setting' : kept + ' settings'} of yours` : '') + '. Settings lists each difference, and the variable that keeps it.');
|
||
}
|
||
if ((upd.stale_code || []).length && !run) add('warn', 'This cockpit runs older code than the files on disk.', `${upd.stale_code.join(', ')} changed under it. Restart it:`, 'sudo systemctl restart qwen38-dashboard.service');
|
||
// An update staged a new unit that waits for its lane's Load (decision 1408): until then the lane
|
||
// serves the release it served, and the only trace on the main screen was the Lanes tab's small
|
||
// badge, invisible on a phone with the rail closed (review of v1.53.0, 2026-11-19). A wait marked
|
||
// stale is dropped by its Load, not applied, so it gets no banner.
|
||
if (!run) Object.entries(F.pending || {}).forEach(([unit, lacks]) => {
|
||
if ((lacks[0] || '').startsWith('stale:')) return;
|
||
add('orange', `An update waits for the ${LANE_NAME[unit] || unit} lane's Load.`,
|
||
`Until its Load the lane serves the release it served. Load it from its card in Lanes${lacks.length ? `, which downloads ${lacks.join('; ')} first` : ''}.`);
|
||
});
|
||
const ocf = F.ocfit;
|
||
// A Load writes the lane's nominal pair before its engine has a pool, and the cockpit lowers
|
||
// it once the engine is ready: while its own fit runs, or waits for the engine to finish
|
||
// warming up, that is a note, not a warning (it warned for ~9 s after every Load of the 27B,
|
||
// then for up to 30 s while the engine warmed up, second GX10, 2026-10-22)
|
||
const ocWaits = ocf && ocf.autofit === 'waiting for the engine';
|
||
if (ocf && !ocf.ok && (ocf.autofit === 'started' || ocf.autofit === 'fitting' || ocWaits))
|
||
add('info', 'The cockpit is fitting opencode to this engine.', `opencode's limits were written before ${ocf.served} booted, ${fmtN(ocf.asked)} tokens, and this boot serves ${fmtN(ocf.limit)}: the cockpit lowers them to fit${ocWaits ? ' as soon as the engine is ready' : ''}, and the Agent view's server restarts to read them. Nothing to do.`);
|
||
else if (ocf && !ocf.ok) add('warn', 'opencode asks for more than this engine can hold.', `${ocf.why}: opencode declares ${fmtN(ocf.asked)} tokens, and ${ocf.served} can serve ${fmtN(ocf.limit)}. A session would break when the proxy refuses the prompt. Settings has "Fit the limits to this engine".`);
|
||
// A box that chose ./install.sh --opencode 1 stays on OpenCode 1 at every update while every other box
|
||
// serves OpenCode 2, the default since v1.56.0: nobody stays behind without knowing it (decision 1564)
|
||
if ((F.agent || {}).major_choice === '1')
|
||
add('orange', 'opencode 1 on this box: behind.',
|
||
'This box chose ./install.sh --opencode 1, so every update keeps it on OpenCode 1 while the others serve OpenCode 2, '
|
||
+ 'the default since v1.56.0. To move to it (./install.sh --opencode 1 stays the way back), on the box:', './install.sh --opencode 2');
|
||
((F.life || {}).orphans || []).forEach(o => add('warn', `${LANE_NAME[o.unit] || o.unit} is running outside systemd.`,
|
||
`The container ${o.container} serves, but its unit is not running, so no other engine may start and a reboot will not bring it back. Start it from Lanes to replace it, or remove it:`, `docker rm -f ${o.container}`));
|
||
if (errors.lifecycle) add('warn', 'Engine state unknown.', 'The lifecycle collector failed: ' + String(errors.lifecycle).slice(0, 120));
|
||
// drawn only when it changed: a live region re-read twice a second is noise
|
||
const sig = JSON.stringify(want.map(w => [w[0], w[1], !!w[3], w[4] || null]));
|
||
if (box.dataset.sig === sig){
|
||
[...box.children].forEach((b, i) => {
|
||
const t = b.querySelector('.t'); if (t) setText(t, want[i][2]);
|
||
const c = b.querySelector('.bcmd .cmd'); if (c) setText(c, want[i][3]);
|
||
});
|
||
return;
|
||
}
|
||
box.dataset.sig = sig; clear(box);
|
||
want.forEach(([kind, strong, text, cmd, list]) => {
|
||
const b = el('div', 'banner ' + kind);
|
||
b.append(el('span', 'lamp ' + (kind === 'err' ? 'err' : kind === 'warn' ? 'warn' : kind === 'orange' ? 'orange' : '')));
|
||
const p = el('div'); p.append(el('b', null, strong + ' '));
|
||
if (list && list.length){ const ul = el('ul', 'blist'); list.forEach(x => ul.append(el('li', null, x))); p.append(ul); }
|
||
p.append(el('span', 't', text));
|
||
if (cmd){
|
||
const pre = el('pre', 'cmd', cmd), btn = el('button', 'icon-btn copy-icon'), c = el('div', 'copy-field bcmd');
|
||
btn.type = 'button'; wireCopyButton(btn, () => pre.textContent, 'Copy the command');
|
||
c.append(pre, btn); p.append(c);
|
||
}
|
||
b.append(p); box.append(b);
|
||
});
|
||
}
|
||
afterApply(renderBanners);
|
||
|
||
// ── sparklines: canvas, bounded series, device resolution ─────────────────────
|
||
const SERIES = {};
|
||
function push(name, v, max = 180){ (SERIES[name] = SERIES[name] || []).push(v); if (SERIES[name].length > max) SERIES[name].shift(); }
|
||
function drawSpark(canvas, name, color, yMax, opts = {}){
|
||
if (!canvas || !canvas.getContext) return;
|
||
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
||
const w = canvas.clientWidth || 600, h = canvas.clientHeight || 64;
|
||
if (canvas.width !== Math.round(w * dpr) || canvas.height !== Math.round(h * dpr)){ canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr); }
|
||
const c = canvas.getContext('2d'); if (!c) return;
|
||
c.setTransform(dpr, 0, 0, dpr, 0, 0); c.clearRect(0, 0, w, h);
|
||
const data = SERIES[name] || [];
|
||
c.strokeStyle = cssVar('--spark-grid') || 'rgba(255,255,255,.06)'; c.lineWidth = 1;
|
||
[0.25, 0.5, 0.75].forEach(f => { c.beginPath(); c.moveTo(0, Math.round(h * f) + .5); c.lineTo(w, Math.round(h * f) + .5); c.stroke(); });
|
||
if (data.length < 2){ c.fillStyle = cssVar('--fg-3'); c.font = '12px Geist, system-ui'; c.textAlign = 'center'; c.fillText(opts.empty || 'collecting…', w / 2, h / 2 + 4); return; }
|
||
const m = yMax || Math.max(...data, 1e-9);
|
||
const at = (v, i) => [i * (w / (data.length - 1)), h - Math.min(v / m, 1) * (h - 8) - 4];
|
||
const g = c.createLinearGradient(0, 0, 0, h); g.addColorStop(0, color); g.addColorStop(1, 'rgba(0,0,0,0)');
|
||
c.beginPath(); data.forEach((v, i) => { const [x, y] = at(v, i); i ? c.lineTo(x, y) : c.moveTo(x, y); });
|
||
c.lineTo(w, h); c.lineTo(0, h); c.closePath(); c.globalAlpha = .25; c.fillStyle = g; c.fill(); c.globalAlpha = 1;
|
||
c.beginPath(); data.forEach((v, i) => { const [x, y] = at(v, i); i ? c.lineTo(x, y) : c.moveTo(x, y); });
|
||
c.strokeStyle = color; c.lineWidth = 2; c.lineJoin = 'round'; c.stroke();
|
||
const [lx, ly] = at(data[data.length - 1], data.length - 1);
|
||
c.fillStyle = color; c.beginPath(); c.arc(lx - 2, ly, 3, 0, 6.284); c.fill();
|
||
}
|
||
|
||
// ── collectors every view shares ───────────────────────────────────────────────
|
||
on('config', d => {
|
||
F.config = d; F.usable = d.usable_frac || F.usable;
|
||
setText('ver', 'v' + (d.version || '?') + (d.dry_run ? ', dry run' : ''));
|
||
show('drytag', !!d.dry_run);
|
||
});
|
||
on('units', d => { F.units = d.units || {}; });
|
||
on('lifecycle', d => { F.life = d; });
|
||
on('repo', d => { F.proxy = d.proxy || null; });
|
||
on('update', d => { F.update = d || {}; });
|
||
// which side lanes are prepared, their runtime built (installed on demand: units at install,
|
||
// runtime at the first Load): true, false, or null for a lane not installed
|
||
on('lanes_ready', d => { F.lanesReady = d || {}; });
|
||
on('lanes_startable', d => { F.lanesStartable = d || {}; });
|
||
// an update that waits for a lane's Load (decision 1408): {unit: [what its new unit lacks]} (cockpit.py, pending_units)
|
||
on('pending', d => { F.pending = d || {}; });
|
||
// the target each waiting unit serves (cockpit.py, pending_target): a Load toward another target neither
|
||
// prepares nor poses the wait, the switch renders the unit in place for the asked target and clears it
|
||
on('pending_targets', d => { F.pendingTargets = d || {}; });
|
||
on('agent', d => { F.agent = d; });
|
||
on('containers', d => { F.containers = d.containers || {}; });
|
||
on('job', renderJob);
|
||
on('engine_info', d => {
|
||
if (d.prompt_ceiling_tokens != null) F.ceiling = d.prompt_ceiling_tokens;
|
||
F.target = d.served_target || null;
|
||
const i = d.info || {};
|
||
F.model = i.model_path || null;
|
||
if (i.max_total_num_tokens) F.pool = i.max_total_num_tokens;
|
||
if (i.context_length) F.window = i.context_length;
|
||
if (i.max_running_requests) F.maxRun = i.max_running_requests;
|
||
});
|
||
on('engine_fast', d => { F.load = (d.load || [])[0] || {}; F.noEngine = !d.load; F.memFloor = d.mem_floor || F.memFloor; F.prompt = d.prompt || null; F.canary = !!d.canary_inflight; });
|
||
on('machine', d => { F.machine = d; });
|
||
on('gpu', d => { F.gpu = d; });
|
||
on('opencode', d => { F.ocfit = d.fit || null; });
|
||
// The pool a lane's facts show. The history holds the boots this cockpit watched, so a
|
||
// cockpit restarted after the serving lane booted read the boot before as "this boot"
|
||
// (400,384 tokens beside a live 491,136 on 2026-09-30): the serving text lane shows
|
||
// what its engine reports now, every other lane its last recorded boot.
|
||
const livePool = (unit, e) => {
|
||
const s = servingEngine();
|
||
// the engine read is refreshed every 30 s: right after a switch it can still be the
|
||
// previous lane's, which says so by its target
|
||
return !!(s && s[0] === unit && textReady() && F.pool && (!F.target || !e || !e.target || F.target === e.target));
|
||
};
|
||
function lanePool(unit, e){ return livePool(unit, e) ? F.pool : (e && e.pools && e.pools.last) || null; }
|
||
// The engine's own window caps it too: on Kolibri, a 2.2M-token pool and no proxy ceiling read
|
||
// "about 1.8M tokens" while vLLM refuses a prompt past 262,144 (found in review, 2026-10-14).
|
||
const singleLimit = () => F.pool ? Math.min(Math.round(F.pool * F.usable), F.ceiling > 0 ? F.ceiling : Infinity,
|
||
F.window > 0 ? F.window : Infinity) : null;
|
||
// physical pool occupancy: the engine dedupes shared prefixes, so the requests' summed
|
||
// lengths ("logical") can read past the pool while the pool never overflows
|
||
const physTokens = l => (l.num_used_tokens != null ? l.num_used_tokens : l.num_tokens) || 0;
|
||
// the load counts a queued request in num_reqs too (running plus waiting, the /get_load shape):
|
||
// what runs is the difference (01/10: "5 Running, 3 Waiting" for two running and three queued)
|
||
const runningReqs = l => Math.max(0, (l.num_reqs || 0) - (l.num_waiting_reqs || 0));
|
||
const waitingReqs = l => l.num_waiting_reqs || 0;
|
||
const loadWords = l => [runningReqs(l) ? `${runningReqs(l)} running` : '', waitingReqs(l) ? `${waitingReqs(l)} waiting` : ''].filter(Boolean).join(', ');
|
||
// The one running request's prompt, while vLLM computes it (lc.prompt_progress): a prompt the cache
|
||
// cannot serve takes minutes, 19 for 494,089 tokens on the Ornith lane, and the page said only
|
||
// "1 running" and "quiet" through all of it (issue #61, 2026-10-30). The time left is a floor.
|
||
// a floor stays a floor once written: rounded down, where fmtMin rounds to the nearest minute and said
|
||
// "at least 3 min" of 150 s (code review, 2026-10-31)
|
||
const fmtAtLeast = s => {
|
||
if (s < 90) return Math.floor(s) + ' s';
|
||
const m = Math.floor(s / 60);
|
||
return m < 60 ? m + ' min' : Math.floor(m / 60) + ' h ' + String(m % 60).padStart(2, '0');
|
||
};
|
||
// how far a prompt the cache could not serve has got (issue #61): the Activity panel of Now, and the feed's row
|
||
const promptProgress = p => !p ? '' : `${Math.round(100 * p.share)} % of ${fmtN(p.tokens)} tokens after ${fmtDur(p.elapsed)}`
|
||
+ (p.left_min_s != null ? `, at least ${fmtAtLeast(p.left_min_s)} left` : p.share >= 0.99 ? ', almost done' : '');
|
||
const promptWords = p => !p ? '' : `computing its prompt: ${promptProgress(p)}`;
|
||
|
||
// ── wiring the shell ──────────────────────────────────────────────────────────
|
||
function wireShell(){
|
||
document.querySelectorAll('.rail .nav').forEach(b => b.addEventListener('click', () => showView(b.dataset.view)));
|
||
window.addEventListener('hashchange', () => showView(location.hash.slice(1) || 'now', false));
|
||
$('menubtn').addEventListener('click', () => {
|
||
const open = !document.body.classList.contains('railopen'); setRailOpen(open);
|
||
if (open) setTimeout(() => { const b = document.querySelector('.rail .nav[aria-current="page"]') || document.querySelector('.rail .nav'); if (b) b.focus(); }, 0);
|
||
});
|
||
document.addEventListener('click', e => { if (document.body.classList.contains('railopen') && !e.target.closest('.rail') && !e.target.closest('#menubtn')) setRailOpen(false); });
|
||
try { setRailMin(localStorage.getItem('cockpit.rail') === 'min'); } catch { setRailMin(false); }
|
||
$('railbtn').addEventListener('click', () => setRailMin(!document.body.classList.contains('railmin')));
|
||
$('serving').addEventListener('click', () => showView('lanes'));
|
||
$('jobpip').addEventListener('click', () => {
|
||
const cur = (F.job || {}).current;
|
||
if (loadAway() && (!cur || cur.id === SHEET.jobId) && reopenJourney()) return;
|
||
dockHidden = null; dockPinned = true; $('dock').hidden = false;
|
||
});
|
||
window.addEventListener('beforeunload', e => { if (leaveWarning()){ e.preventDefault(); e.returnValue = ''; } });
|
||
// the sheet
|
||
$('sh-cancel').addEventListener('click', () => closeSheet());
|
||
$('sh-go').addEventListener('click', sheetGo);
|
||
$('scrim').addEventListener('click', e => { if (e.target === $('scrim') && !justBack()) closeSheet(); });
|
||
$('viewer-close').addEventListener('click', closeViewer);
|
||
$('viewer-actual').addEventListener('click', viewerActual);
|
||
// the picture says its own size once decoded: the label, and the 100 % width, follow it
|
||
$('viewer-img').addEventListener('load', () => { const v = $('viewer-img'); if (!v.naturalWidth) return;
|
||
setText('viewer-size', `${v.naturalWidth} × ${v.naturalHeight}`);
|
||
if ($('viewer-pane').classList.contains('actual')) v.style.width = `${Math.round(v.naturalWidth / (window.devicePixelRatio || 1))}px`; });
|
||
$('viewer').addEventListener('click', e => { if (e.target === $('viewer') || e.target === $('viewer-pane')) closeViewer(); });
|
||
document.addEventListener('keydown', e => {
|
||
if (!$('viewer').hidden){
|
||
if (e.key === 'Escape') closeViewer();
|
||
if (e.key === 'Tab'){ // focus stays on the viewer's own controls
|
||
const f = [...$('viewer').querySelectorAll('button, a[href]')];
|
||
const i = f.indexOf(document.activeElement);
|
||
e.preventDefault(); f[(i + (e.shiftKey ? -1 : 1) + f.length) % f.length].focus();
|
||
}
|
||
return;
|
||
}
|
||
if (!$('scrim').hidden){
|
||
if (e.key === 'Escape' && !justBack()) closeSheet();
|
||
if (e.key === 'Tab'){ // focus stays inside the sheet
|
||
const f = [...$('sheet').querySelectorAll('button')].filter(b => !b.disabled);
|
||
if (!f.length) return;
|
||
const i = f.indexOf(document.activeElement);
|
||
e.preventDefault(); f[(i + (e.shiftKey ? -1 : 1) + f.length) % f.length].focus();
|
||
}
|
||
return;
|
||
}
|
||
if (!$('menu').hidden){
|
||
if (e.key === 'Escape') closeMenu();
|
||
if (e.key === 'Tab'){ // focus stays inside the menu, as in the sheet
|
||
const f = [...$('menu').querySelectorAll('button')].filter(b => !b.disabled);
|
||
if (!f.length) return;
|
||
const i = f.indexOf(document.activeElement);
|
||
e.preventDefault(); f[(i + (e.shiftKey ? -1 : 1) + f.length) % f.length].focus();
|
||
}
|
||
return;
|
||
}
|
||
if (e.key === 'Escape' && document.body.classList.contains('railopen')){ setRailOpen(false); $('menubtn').focus(); }
|
||
});
|
||
// the dock
|
||
$('dock-log').addEventListener('click', () => {
|
||
const pre = $('dock-pre'), open = pre.hidden; pre.hidden = !open; dockPinned = open;
|
||
$('dock-log').setAttribute('aria-expanded', String(open)); setText($('dock-log'), open ? 'Hide log' : 'Log');
|
||
if (open && JOBLINES.id) fetchJobLines(JOBLINES.id);
|
||
});
|
||
$('dock-close').addEventListener('click', () => {
|
||
const j = F.job || {}; dockHidden = (j.current || (j.recent || [])[0] || {}).id || null; dockPinned = false; $('dock').hidden = true;
|
||
});
|
||
// the actions menu
|
||
$('actbtn').addEventListener('click', openMenu);
|
||
$('logoutbtn').addEventListener('click', async () => {
|
||
try {
|
||
const r = await postJSON('/api/logout', {});
|
||
if (!r.ok) return toast('Could not sign out (' + r.status + '): the session is still open.', 'err');
|
||
} catch (e) {
|
||
if (e.message !== 'signed out') return toast('Could not sign out: ' + e.message, 'err');
|
||
}
|
||
leavingForLogin = true;
|
||
location.href = '/';
|
||
});
|
||
$('menu-close').addEventListener('click', closeMenu);
|
||
$('menu').addEventListener('click', e => { if (e.target === $('menu')) closeMenu(); });
|
||
}
|
||
const MENU_ITEMS = [
|
||
['smoke', 'Run a smoke generation', 'One real generation through the proxy, the way a client uses it.'],
|
||
['flush_cache', 'Flush the engine cache', 'Empties the radix cache; harmless, refused while requests run.'],
|
||
['abort_all', 'Abort every generation', 'Every running or queued generation ends now.'],
|
||
['diag_bundle', 'Write a diagnostics bundle', 'Logs, state and versions in a tarball in your home, key masked.'],
|
||
['fit_opencode', 'Fit the opencode limits', 'Match opencode to the pool this boot got.']];
|
||
function openMenu(){
|
||
const box = $('menu-list'); clear(box);
|
||
MENU_ITEMS.forEach(([act, t, d]) => {
|
||
const b = el('button', 'btn block act');
|
||
const no = cannotWhy(act);
|
||
b.dataset.act = act; b.dataset.title = no || d;
|
||
if (no) b.setAttribute('aria-disabled', 'true');
|
||
b.append(el('span', null, t), el('span', 'faint', no || d));
|
||
b.addEventListener('click', () => { closeMenu(); askAction(act, {}, []); });
|
||
box.append(b);
|
||
});
|
||
const a = document.activeElement; OPENER.menu = a && !a.closest('#menu') ? a : OPENER.menu;
|
||
$('menu').hidden = false; applyBusy();
|
||
setTimeout(() => { const f = [...$('menu-list').querySelectorAll('button')].find(b => !b.disabled) || $('menu-close'); if (f) f.focus(); }, 0);
|
||
}
|
||
function closeMenu(){ if ($('menu').hidden) return; $('menu').hidden = true; giveBack('menu'); }
|