the 2026-11-16 rounds, the whole day in one commit: model discovery (the two-step op act -- discover scrapes the provider metadata, refine runs the deterministic battery over every id and hands the adjudicated results to the best passing model for the curated registry; state/models.json is the truth of selectable models and gates all model use, a fresh deployment has none; the five named sampling knobs ride run.json params over server.json params, sent only when set; the curator call retries once on the host's network hiccups, its output strictly validated with the machine-list fallback, and the do-not-deliberate line keeps its thinking tokens down); the pick rule reworked on the GM's rulings -- the dv endpoint's 5.2/5.3-max flip was an alias (one model behind both ids), the rank keys on the reasoning bucket not the raw token count (within-bucket differences are sampling noise, the thresholds sit in the endpoint's observed gaps) and full ties settle sort-lex-pick-bottom, with the mock registry carrying a canned tie pair (mock/mock-tie) and the smoke asserting the lex-bottom pick; the play-protocol batch (OOC GM turns carry no cache blocks, memory.json is authored draft applied by the start gate's reapply over a fresh db, /story filters OOC whole, the per-turn raw control on the table); the tunables UX round (web/knobs.mjs: the definitions table with the GM's hint texts and the probed this-endpoint bounds, the per-knob explicit override toggle replacing implicit empty-means-unset diffing, the shared focus-driven hint bar; the run detail and /model responses carry paramDefaults, the deployment layer -- the only default anyone can honestly name); request recording (every provider call lands its resolved model + effective params on the msg event as via, a failed call lands a req event with the failure, both surface on the raw tab and the per-turn raw control on no model-facing surface, a req riding the slidwin tail passes the start lint as conversation machinery; the housekeeping pass log names its model via the clerk's --model flag); the mind verb (<mind> JSON in a player turn sets its sampling for its next turn -- one-shot, max_tokens excluded, a budget not a mind; bounds enforced in KNOB_BOUNDS with the range named in the conflict and the heal restatement the statement that counts; derive() makes a statement live until a player reply consumes it, honest across restarts, session boundaries and forks -- an unconsumed mind rides on); the full-block protocol (the GM rewrote system/invariants/reminder to eliminate the diff verbs: she emits whole <status>/<agenda> at her turn tail, a present block is a whole-list set, absent means unchanged never blank, over-cap agendas evict from the bottom silently -- ruled a feature, silent to her, the note shows the GM; renderView strips every copy and stamps the newest of each kind at the tail of her most recent prose turn, her own emission, so the context reads as the same sequence of events the game had; GM prose goes pure, old logs' composited rides strip, they were never GM words; <mind> is write-only, its tags strip from the view; every turn of hers carries its <model> block -- the params it rode, bare JSON from the via record, the current call included, suppressed when nothing is set, emitting one refused with a pointer at <mind>; the clerk's status-apply/agenda-apply delta verbs RETIRED with their dispatch and collectors, status-set/agenda-set are the player path now; the story strips her blocks, the table chips them; the smoke imports renderView and asserts the view policy directly -- the pattern for testing view-only policy no API exposes); and the opening event RETIRED (the start gate seeds the clerk from her last authored turn's blocks -- the GM moved la-caramba's initial status into her opening turn; old carryovers keep their events as inert history; the event's pre-existing double-landing in every started log, pre-bundle and in-carry, died with the branch); smoke ALL PASS + restart + reminder + repo checks green, browser passes over the knob UX and the new chips and notes with zero console errors, typecheck green on both programs; README and DICTIONARY carry the durable design, HANDOFF trimmed to the map
This commit is contained in:
@@ -43,6 +43,15 @@
|
||||
</div>
|
||||
<div id="invite-list"></div>
|
||||
<div id="user-list"></div>
|
||||
<div id="models-admin">
|
||||
<h3>models</h3>
|
||||
<div id="models-state" class="hint"></div>
|
||||
<div class="form-actions">
|
||||
<button id="models-discover">discover</button>
|
||||
<button id="models-refine">refine</button>
|
||||
</div>
|
||||
<div id="models-list"></div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
// web/knobs.mjs -- the sampling knobs: the definitions table and the
|
||||
// per-role knob row.
|
||||
//
|
||||
// The knobs are named, well-known, widely supported. The definitions
|
||||
// table is the single home of every knob text -- label, hint, bounds
|
||||
// -- red-pen the prose here, in place. Bounds are display knowledge
|
||||
// probed from this endpoint's own validation errors (the /model
|
||||
// route's validation stays generic: a finite number). The provider's
|
||||
// serving defaults are unknown and stay unstated; the only default
|
||||
// anyone can honestly name is the deployment layer (server.json
|
||||
// params), which rides the run detail as paramDefaults.
|
||||
//
|
||||
// Two defaults, never conflated: a knob unset means its value is NOT
|
||||
// sent to the provider; a value present is sent, and the row marks it
|
||||
// when it equals the deployment default. The explicit override toggle
|
||||
// carries the distinction: off (the visible default) disables the
|
||||
// input and saving sends nothing for the knob (null clears a
|
||||
// previously-set value); on demands a number.
|
||||
//
|
||||
// The hint bar is shared by both roles -- one explanation at a time,
|
||||
// driven by focus (a tap focuses), cleared when focus leaves the
|
||||
// knobs entirely.
|
||||
|
||||
/** @typedef {import('../server/shapes.mjs').RoleParams} RoleParams */
|
||||
|
||||
import { el } from './dom.mjs';
|
||||
|
||||
/** One knob's definition: the texts are the product, the shape is
|
||||
* schema-ready for later kinds (bools: what to expect on and off;
|
||||
* enums: explanation-only) -- nothing else ships today. All five
|
||||
* knobs are the GM's here; the mind verb (server/loop.mjs) sets
|
||||
* only the four that are hers -- max_tokens is excluded by ruling
|
||||
* (a budget, not a mind). */
|
||||
/** @typedef {{ key: keyof RoleParams, kind: 'number', label: string, hint: string, bounds: string }} KnobDef */
|
||||
|
||||
/** @type {KnobDef[]} */
|
||||
const DEFS = [
|
||||
{
|
||||
key: 'temperature',
|
||||
kind: 'number',
|
||||
label: 'temperature',
|
||||
hint: 'How adventurous the word choice is. Higher: more varied and surprising, occasionally unhinged. Lower: more predictable and conservative; at 0 the same prompt tends to get the same words.',
|
||||
bounds: 'This endpoint: 0 to 2.',
|
||||
},
|
||||
{
|
||||
key: 'top_p',
|
||||
kind: 'number',
|
||||
label: 'top_p',
|
||||
hint: 'Narrows the field to the most likely words that together cover this much probability. Higher: more words in play, more variety. Lower: fewer, safer choices; very low makes her repeat herself.',
|
||||
bounds: 'This endpoint: above 0 (0 is refused), up to 1.',
|
||||
},
|
||||
{
|
||||
key: 'top_k',
|
||||
kind: 'number',
|
||||
label: 'top_k',
|
||||
hint: 'Like top_p but by count -- only the k most likely words are considered each step. Higher: more variety. Lower: more locked-in; at 1 she picks the single most likely word every time. -1 and 0 turn the filter off.',
|
||||
bounds: 'No known bounds on this endpoint; -1 and 0 both mean the filter is off.',
|
||||
},
|
||||
{
|
||||
key: 'repetition_penalty',
|
||||
kind: 'number',
|
||||
label: 'repetition_penalty',
|
||||
hint: 'A direct nudge against repeating recent words and phrasings. 1 is no effect; raise it to make her evade repetition. Too high and she substitutes odd words to escape.',
|
||||
bounds: 'Must be above 0 on this endpoint, no known max.',
|
||||
},
|
||||
{
|
||||
key: 'max_tokens',
|
||||
kind: 'number',
|
||||
label: 'max_tokens',
|
||||
hint: 'The response\'s hard length budget. Higher: room for long turns. Lower: cheaper and shorter, but the turn can cut off mid-sentence -- and on reasoning models thinking counts against this budget first, so a low cap can be eaten entirely before she writes a word.',
|
||||
bounds: '1 or more on this endpoint; no enforced max (values above the model\'s output ceiling are accepted).',
|
||||
},
|
||||
];
|
||||
|
||||
/** The hint bar's text for one knob: label, the explanation, the
|
||||
* bounds, and the honest default statement for this role's
|
||||
* deployment layer. Never invents an unknown value. */
|
||||
/** @param {KnobDef} def @param {number|undefined|null} dep @returns {string} */
|
||||
function hintText(def, dep) {
|
||||
const defLine = dep !== undefined && dep !== null
|
||||
? `Unset = the deployment default (${dep}).`
|
||||
: 'Unset = not sent; the provider\'s own default applies (unknown).';
|
||||
return `${def.label.replace(/_/g, ' ')} -- ${def.hint} ${def.bounds} ${defLine}`;
|
||||
}
|
||||
|
||||
/** One role's knob row.
|
||||
* @param {string} role
|
||||
* @param {RoleParams|undefined} current the run's own knobs
|
||||
* @param {RoleParams|undefined|null} deployment the deployment layer (server.json params)
|
||||
* @param {HTMLElement} hintBar the shared hint bar
|
||||
* @returns {{ wrap: HTMLElement, read: () => Record<string, number|null> }}
|
||||
*/
|
||||
export function knobsBox(role, current, deployment, hintBar) {
|
||||
const wrap = el('div', 'knobs');
|
||||
wrap.appendChild(el('div', 'knobs-head', `${role} knobs`));
|
||||
/** @type {Record<string, { tog: HTMLInputElement, inp: HTMLInputElement }>} */
|
||||
const rows = {};
|
||||
for (const def of DEFS) {
|
||||
const row = el('div', 'knob');
|
||||
const tog = /** @type {HTMLInputElement} */ (el('input'));
|
||||
tog.type = 'checkbox';
|
||||
tog.title = 'override';
|
||||
const lab = el('label', null, `${def.label.replace(/_/g, ' ')} `);
|
||||
const inp = /** @type {HTMLInputElement} */ (el('input'));
|
||||
inp.type = 'number';
|
||||
inp.step = 'any';
|
||||
const mark = el('span', 'knob-default', ' \u00b7 deployment default');
|
||||
lab.appendChild(inp);
|
||||
lab.appendChild(mark);
|
||||
row.appendChild(tog);
|
||||
row.appendChild(lab);
|
||||
wrap.appendChild(row);
|
||||
|
||||
const set = current?.[def.key];
|
||||
tog.checked = set !== undefined;
|
||||
if (set !== undefined) inp.value = String(set);
|
||||
const dep = deployment?.[def.key];
|
||||
// the toggle owns the state: off disables the input (the value
|
||||
// stays for a change of mind), on demands a number; a value equal
|
||||
// to the deployment default is still sent, and the row marks it
|
||||
const sync = () => {
|
||||
inp.disabled = !tog.checked;
|
||||
mark.hidden = !(tog.checked && inp.value.trim() !== '' && Number(inp.value) === dep);
|
||||
};
|
||||
tog.addEventListener('change', sync);
|
||||
inp.addEventListener('input', sync);
|
||||
sync();
|
||||
inp.addEventListener('focus', () => { hintBar.textContent = hintText(def, dep); });
|
||||
rows[def.key] = { tog, inp };
|
||||
}
|
||||
// the bar keeps its text while focus moves inside the row, clears
|
||||
// when it leaves the knobs entirely
|
||||
wrap.addEventListener('focusout', (e) => {
|
||||
if (!wrap.contains(/** @type {?Node} */ (e.relatedTarget))) hintBar.textContent = '';
|
||||
});
|
||||
const read = () => {
|
||||
/** @type {Record<string, number|null>} */ const out = {};
|
||||
for (const def of DEFS) {
|
||||
const { tog, inp } = rows[def.key];
|
||||
if (tog.checked) {
|
||||
const v = inp.value.trim();
|
||||
if (v === '' || !Number.isFinite(Number(v))) {
|
||||
throw new Error(`${def.label}: a number is required -- or switch the override off`);
|
||||
}
|
||||
out[def.key] = Number(v);
|
||||
} else if (current?.[def.key] !== undefined) {
|
||||
out[def.key] = null; // clearing a previously-set knob
|
||||
}
|
||||
}
|
||||
return out;
|
||||
};
|
||||
return { wrap, read };
|
||||
}
|
||||
+9
-2
@@ -14,8 +14,15 @@ export {};
|
||||
/** @typedef {{ id: string, package: string, models: ?{ player?: ?string, housekeeper?: ?string }, owner: ?string, ownerName: ?string, created: ?string, forked: ?number, pc: ?string, display: string, sessions: number, phase: ?string, ready: ?boolean, initialized: boolean, fill?: { a: number, b: number, cold: number }, open: boolean, session: ?number, pendingAsk: ?string }} RunCard */
|
||||
|
||||
/** GET /runs/:id -- the run detail: identity, the phase bookkeeping,
|
||||
* her two blocks, the fill, the context meter's numbers. */
|
||||
/** @typedef {{ run: { id: string, package: ?string, created: ?string, forked: ?number, owner: ?string, ownerName: ?string, models: { player?: ?string, housekeeper?: ?string }, modelDefaults: { player?: ?string, housekeeper?: ?string } }, display: string, open: boolean, phase: ?string, session: ?number, sessions: number, draft: boolean, ready: ?boolean, status: string[], agenda: string[], records: number, fill: Record<string, number>, events: number, pendingAsk: ?string, usage: ?{ promptTokens: number, completionTokens: number }, context: ?{ used: number, contwin: ?boolean, pct: ?number } }} RunDetail */
|
||||
* her two blocks, the fill, the context meter's numbers.
|
||||
* paramDefaults is the knobs' deployment layer (server.json params)
|
||||
* -- the only default an unset knob honestly resolves to. */
|
||||
/** @typedef {{ run: { id: string, package: ?string, created: ?string, forked: ?number, owner: ?string, ownerName: ?string, models: { player?: ?string, housekeeper?: ?string }, params: { player?: ?import('../server/shapes.mjs').RoleParams, housekeeper?: ?import('../server/shapes.mjs').RoleParams }, modelDefaults: { player?: ?string, housekeeper?: ?string }, paramDefaults: { player?: ?import('../server/shapes.mjs').RoleParams, housekeeper?: ?import('../server/shapes.mjs').RoleParams } }, display: string, open: boolean, phase: ?string, session: ?number, sessions: number, draft: boolean, ready: ?boolean, status: string[], agenda: string[], records: number, fill: Record<string, number>, events: number, pendingAsk: ?string, usage: ?{ promptTokens: number, completionTokens: number }, context: ?{ used: number, contwin: ?boolean, pct: ?number } }} RunDetail */
|
||||
|
||||
/** GET /api/models -- the deployment's model registry and the
|
||||
* discovery job state riding along. phase 'none' is the fresh
|
||||
* deployment: nothing is selectable until the op discovers. */
|
||||
/** @typedef {{ phase: 'none'|'preliminary'|'refined', discovered: ?string, refined: ?string, curator: ?string, defaults: { player?: ?string, housekeeper?: ?string }, models: import('../server/shapes.mjs').RegistryModel[], job: ?import('../server/shapes.mjs').JobState }} ModelsRegistryResponse */
|
||||
|
||||
/** GET /runs/:id/table -- the live session's projection (thinking
|
||||
* never crosses the wire, variant turns carry only the picked one). */
|
||||
|
||||
+27
-1
@@ -269,9 +269,11 @@ h1 { font-size: 15px; letter-spacing: 0.1em; color: var(--dim); font-weight: nor
|
||||
.raw-block pre.raw-thinking { color: var(--dim); }
|
||||
|
||||
.turn { margin: 0 0 20px; max-width: 760px; }
|
||||
.turn .who { font-size: 11px; letter-spacing: 0.12em; color: var(--dim); margin-bottom: 3px; }
|
||||
.turn .who { display: flex; align-items: baseline; gap: 8px; font-size: 11px; letter-spacing: 0.12em; color: var(--dim); margin-bottom: 3px; }
|
||||
.turn .who .raw-toggle { margin-left: auto; font-size: 11px; padding: 0 8px; color: var(--dim); }
|
||||
.turn.gm .who { color: var(--accent); }
|
||||
.turn.player .who { color: var(--ok); }
|
||||
.raw-slot { margin: 10px 0 2px; }
|
||||
|
||||
.line { margin: 2px 0; white-space: pre-wrap; }
|
||||
.narration { color: var(--dim); font-style: italic; }
|
||||
@@ -287,6 +289,9 @@ h1 { font-size: 15px; letter-spacing: 0.1em; color: var(--dim); font-weight: nor
|
||||
.chip.gained { color: var(--ok); border-color: var(--ok); }
|
||||
.chip.drop { text-decoration: line-through; }
|
||||
.chip.add { color: var(--ok); border-color: var(--ok); }
|
||||
.chip.mind { color: var(--accent); border-color: var(--accent); }
|
||||
.chip.status { color: var(--text); }
|
||||
.chip.agenda { color: var(--accent); border-color: var(--accent); }
|
||||
|
||||
.machinery {
|
||||
margin: 6px 0; font-size: 12px; color: var(--dim);
|
||||
@@ -294,6 +299,27 @@ h1 { font-size: 15px; letter-spacing: 0.1em; color: var(--dim); font-weight: nor
|
||||
}
|
||||
.machinery .head { color: var(--text); }
|
||||
|
||||
/* the sampling knobs: per-knob override toggle + number input, one
|
||||
row per role; the shared hint bar sits under both rows */
|
||||
.knobs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; align-items: baseline; }
|
||||
.knobs-head { width: 100%; font-size: 11px; letter-spacing: 0.12em; color: var(--dim); }
|
||||
.knobs .knob { display: flex; align-items: baseline; gap: 5px; font-size: 11px; color: var(--dim); }
|
||||
.knobs .knob input[type='number'] { width: 72px; padding: 2px 6px; font-size: 12px; }
|
||||
.knobs .knob input[type='number']:disabled { opacity: 0.45; }
|
||||
.knobs .knob .knob-default { color: var(--accent); }
|
||||
.knob-hint {
|
||||
min-height: 3.1em; /* the bar holds its place -- focus walks never jump the layout */
|
||||
margin: 2px 0 8px;
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
color: var(--dim);
|
||||
}
|
||||
|
||||
/* the admin's models block: verdict rows */
|
||||
#models-admin h3 { margin: 14px 0 4px; }
|
||||
#models-list .admin-row { flex-wrap: wrap; gap: 4px 10px; }
|
||||
#models-list .hint { font-style: italic; }
|
||||
|
||||
/* the dormant bar: the review window's banner over the carryover
|
||||
preview, with the start button */
|
||||
.beat {
|
||||
|
||||
+85
-18
@@ -55,8 +55,15 @@ export function renderContent(target, text, { extract }) {
|
||||
if (am) { agenda = am[1]; body = body.replace(am[0], ''); }
|
||||
}
|
||||
const tags = [];
|
||||
for (const m of body.matchAll(/<(lost|gained|add|drop)>([\s\S]*?)<\/\1>/g)) {
|
||||
tags.push({ kind: m[1], items: m[2].split('\n').flatMap((l) => l.split(',')).map((x) => x.trim()).filter(Boolean) });
|
||||
for (const m of body.matchAll(/<(lost|gained|add|drop|mind|status|agenda)>([\s\S]*?)<\/\1>/g)) {
|
||||
// the mind block is JSON -- it rides whole (no comma-splitting);
|
||||
// the note line carries the human-readable form. Status and
|
||||
// agenda blocks are the full-block protocol: their items chip
|
||||
// like the deltas did (list markers stripped for display)
|
||||
const items = m[1] === 'mind'
|
||||
? [m[2].trim()]
|
||||
: m[2].split('\n').flatMap((l) => l.replace(/^\s*[-*]\s+\d*[.:)]?\s*/, '').split(',')).map((x) => x.trim()).filter(Boolean);
|
||||
tags.push({ kind: m[1], items });
|
||||
}
|
||||
for (const t of tags) body = body.replace(new RegExp(`<${t.kind}>[\\s\\S]*?</${t.kind}>`), '');
|
||||
|
||||
@@ -131,14 +138,34 @@ export function renderContent(target, text, { extract }) {
|
||||
return { status, conflict, agenda };
|
||||
}
|
||||
|
||||
// the request record's line: the resolved model and the effective
|
||||
// params as sent (the merged layer actually sent). Shared by the raw
|
||||
// walk and the per-turn raw control. fail is present when the call
|
||||
// failed -- no message resulted.
|
||||
/** @param {{ model: string, params?: Record<string, number> }} via @param {?string} [fail] @returns {string} */
|
||||
export function viaLine(via, fail = null) {
|
||||
const ks = Object.entries(via.params ?? {});
|
||||
const p = ks.length ? ` -- ${ks.map(([k, v]) => `${k}: ${v}`).join(', ')}` : ' (no knobs set)';
|
||||
return fail ? `[request failed] ${via.model}${p} -- ${fail}` : `[request] ${via.model}${p}`;
|
||||
}
|
||||
|
||||
// the note line, shared by both walks
|
||||
/** @param {NoteEvent} e @returns {?string} */
|
||||
function noteText(e) {
|
||||
if (e.kind === 'session') return `session ${e.n} opened`;
|
||||
if (e.kind === 'ask') return `ask_gm: ${e.question}`;
|
||||
if (e.kind === 'status') return `status: lost ${JSON.stringify(e.applied?.lost ?? [])}, gained ${JSON.stringify(e.applied?.gained ?? [])}`;
|
||||
if (e.kind === 'agenda') return `agenda: added ${JSON.stringify(e.applied?.added ?? [])}, dropped ${JSON.stringify(e.applied?.dropped ?? [])}`;
|
||||
if (e.kind === 'status') {
|
||||
return e.set
|
||||
? `status set: ${JSON.stringify(e.set)}`
|
||||
: `status: lost ${JSON.stringify(e.applied?.lost ?? [])}, gained ${JSON.stringify(e.applied?.gained ?? [])}`;
|
||||
}
|
||||
if (e.kind === 'agenda') {
|
||||
return e.set
|
||||
? `agenda set: ${JSON.stringify(e.set)}${e.evicted?.length ? ` -- evicted ${JSON.stringify(e.evicted)}` : ''}`
|
||||
: `agenda: added ${JSON.stringify(e.applied?.added ?? [])}, dropped ${JSON.stringify(e.applied?.dropped ?? [])}`;
|
||||
}
|
||||
if (e.kind === 'pick') return `variant literature: ${e.count} offered, #${e.chosen + 1} picked`;
|
||||
if (e.kind === 'mind') return `mind: ${Object.entries(e.params ?? {}).map(([k, v]) => `${k} ${v}`).join(', ')} -- rides her next turn`;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -172,6 +199,11 @@ export function renderRaw(entries) {
|
||||
t.appendChild(el('div', 'machinery', `her opening status: ${JSON.stringify(e.status)}`));
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'req') {
|
||||
// a failed provider request: the record of what was attempted
|
||||
t.appendChild(el('div', 'machinery', viaLine(e, e.fail)));
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'note') {
|
||||
const text = noteText(e);
|
||||
if (text) t.appendChild(el('div', 'machinery', text));
|
||||
@@ -200,6 +232,7 @@ export function renderRaw(entries) {
|
||||
if (e.t === 'msg' && e.m.role === 'assistant') {
|
||||
const d = block('player');
|
||||
if (e.m.reasoning_content) d.appendChild(el('pre', 'raw-thinking', e.m.reasoning_content));
|
||||
if (e.via) d.appendChild(el('div', 'machinery', viaLine(e.via)));
|
||||
d.appendChild(el('pre', null, String(e.m.content ?? '')));
|
||||
for (const c of e.m.tool_calls ?? []) {
|
||||
d.appendChild(el('div', 'machinery', `[tool call] ${c.function.name}`));
|
||||
@@ -212,11 +245,15 @@ export function renderRaw(entries) {
|
||||
}
|
||||
|
||||
// the entry walk. onConflict receives a conflict block found on a GM
|
||||
// turn -- the play view owns where it lands (the status pane). The
|
||||
// opening event (her opening status) renders as machinery, mirroring
|
||||
// turn -- the play view owns where it lands (the status pane).
|
||||
// onRaw, when given, puts a small control on every GM/player turn
|
||||
// that shows that one entry's wire form inline -- the play view owns
|
||||
// the fetch (the raw session is the audit surface; the walks are
|
||||
// index-aligned, so table entry i is session entry i). The opening
|
||||
// event (her opening status) renders as machinery, mirroring
|
||||
// the wire policy: it is set once, never re-sent.
|
||||
/** @param {LogEvent[]} entries @param {{ onConflict?: (text: string) => void }} [opts] */
|
||||
export function renderTranscript(entries, { onConflict } = {}) {
|
||||
/** @param {LogEvent[]} entries @param {{ onConflict?: (text: string) => void, onRaw?: (idx: number, slot: HTMLElement) => Promise<void> }} [opts] */
|
||||
export function renderTranscript(entries, { onConflict, onRaw } = {}) {
|
||||
const t = $('transcript');
|
||||
t.textContent = '';
|
||||
/** @type {BundleEvent[]} */ const bundleParts = [];
|
||||
@@ -234,7 +271,8 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
bundleParts.length = 0;
|
||||
};
|
||||
|
||||
for (const e of entries) {
|
||||
for (let idx = 0; idx < entries.length; idx++) {
|
||||
const e = entries[idx];
|
||||
if (e.t === 'bundle') {
|
||||
// every part is inspectable, read-only: system (guards +
|
||||
// substrate + craft), backdrop, character, the rings
|
||||
@@ -259,14 +297,15 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
t.appendChild(el('div', 'machinery', `her opening status: ${JSON.stringify(e.status)}`));
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'req') continue; // a failed request's record -- the raw surfaces carry it
|
||||
if (e.t === 'msg') {
|
||||
if (e.m.role === 'user' && e.conflictOnly) {
|
||||
// the self-heal message: error traffic on its own, never GM prose
|
||||
t.appendChild(el('div', 'machinery', `[conflict] ${String(e.m.content).replace(/<\/?conflict>/g, '').trim()}`));
|
||||
continue;
|
||||
}
|
||||
if (e.m.role === 'user') gmTurn(e.m.content, 'GM');
|
||||
else if (e.m.role === 'assistant') playerTurn(e);
|
||||
if (e.m.role === 'user') gmTurn(e, idx, 'GM');
|
||||
else if (e.m.role === 'assistant') playerTurn(e, idx);
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'tool') {
|
||||
@@ -278,26 +317,30 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
flushBundle();
|
||||
t.scrollTop = t.scrollHeight;
|
||||
|
||||
/** @param {?string} content @param {string} who */
|
||||
function gmTurn(content, who) {
|
||||
/** @param {MsgEvent} e @param {number} idx @param {string} who */
|
||||
function gmTurn(e, idx, who) {
|
||||
const d = el('div', 'turn gm');
|
||||
d.appendChild(el('div', 'who', who));
|
||||
const head = el('div', 'who', who);
|
||||
d.appendChild(head);
|
||||
const body = el('div');
|
||||
d.appendChild(body);
|
||||
const { conflict } = renderContent(body, content, { extract: true });
|
||||
const { conflict } = renderContent(body, e.m.content, { extract: true });
|
||||
if (conflict) onConflict?.(conflict);
|
||||
if (onRaw) addRawControl(head, d, idx);
|
||||
t.appendChild(d);
|
||||
}
|
||||
/** @param {MsgEvent} e */
|
||||
function playerTurn(e) {
|
||||
/** @param {MsgEvent} e @param {number} idx */
|
||||
function playerTurn(e, idx) {
|
||||
const d = el('div', 'turn player');
|
||||
d.appendChild(el('div', 'who', 'player'));
|
||||
const head = el('div', 'who', 'player');
|
||||
d.appendChild(head);
|
||||
const body = el('div');
|
||||
d.appendChild(body);
|
||||
renderContent(body, e.m.content, { extract: false });
|
||||
for (const c of e.m.tool_calls ?? []) {
|
||||
d.appendChild(el('div', 'machinery', `[tool call] ${c.function.name}`));
|
||||
}
|
||||
if (onRaw) addRawControl(head, d, idx);
|
||||
t.appendChild(d);
|
||||
}
|
||||
/** @param {NoteEvent} e */
|
||||
@@ -305,4 +348,28 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
const text = noteText(e);
|
||||
if (text) t.appendChild(el('div', 'machinery', text));
|
||||
}
|
||||
|
||||
// the per-turn raw control: the who row carries the button, the
|
||||
// card gains a slot under the body -- onRaw fills it on first open
|
||||
// (the caller owns the fetch and its errors), later clicks toggle
|
||||
/** @param {HTMLElement} head @param {HTMLElement} card @param {number} idx */
|
||||
function addRawControl(head, card, idx) {
|
||||
const btn = /** @type {HTMLButtonElement} */ (el('button', 'raw-toggle', 'raw'));
|
||||
head.appendChild(btn);
|
||||
btn.addEventListener('click', async () => {
|
||||
const slot = /** @type {?HTMLElement} */ (card.querySelector('.raw-slot'));
|
||||
if (slot && slot.childElementCount) {
|
||||
slot.hidden = !slot.hidden; // filled already -- just toggle
|
||||
return;
|
||||
}
|
||||
const fresh = slot ?? el('div', 'raw-slot');
|
||||
if (!slot) card.appendChild(fresh);
|
||||
btn.disabled = true;
|
||||
try {
|
||||
await onRaw?.(idx, fresh);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+83
-3
@@ -6,7 +6,7 @@ import { api } from './client.mjs';
|
||||
import { state } from './state.mjs';
|
||||
import { banner } from './chrome.mjs';
|
||||
import { navigate, render } from './router.mjs';
|
||||
import { armedButton } from './widgets.mjs';
|
||||
import { armedButton, fmtCeiling } from './widgets.mjs';
|
||||
|
||||
/** @typedef {import('./shapes.mjs').RunCard} RunCard */
|
||||
|
||||
@@ -69,8 +69,8 @@ async function renderAdmin(seq) {
|
||||
const box = $('admin');
|
||||
if (!state.me?.superuser) { box.hidden = true; return; }
|
||||
box.hidden = false;
|
||||
/** @type {[{ invites: { id: number, kind: string, created_at: string, state: string }[] }, { users: import('../server/shapes.mjs').User[] }]} */
|
||||
const [inv, us] = await Promise.all([api('/invites'), api('/users')]);
|
||||
/** @type {[{ invites: { id: number, kind: string, created_at: string, state: string }[] }, { users: import('../server/shapes.mjs').User[] }, import('./shapes.mjs').ModelsRegistryResponse]} */
|
||||
const [inv, us, reg] = await Promise.all([api('/invites'), api('/users'), api('/models')]);
|
||||
if (seq !== state.seq) return;
|
||||
const invList = $('invite-list');
|
||||
invList.textContent = '';
|
||||
@@ -107,8 +107,88 @@ async function renderAdmin(seq) {
|
||||
}
|
||||
userList.appendChild(row);
|
||||
}
|
||||
renderModelsAdmin(reg, seq);
|
||||
}
|
||||
|
||||
// --- models: the discovery surface --------------------------------------------
|
||||
//
|
||||
// Two op acts: discover (the metadata scrape, free) and refine (the
|
||||
// inference battery + the curator pass -- real traffic, may cost
|
||||
// real money, two-click armed with the warning). The registry state
|
||||
// line and the model list render from the saved registry.
|
||||
|
||||
/** @param {import('./shapes.mjs').ModelsRegistryResponse} reg @param {number} seq */
|
||||
function renderModelsAdmin(reg, seq) {
|
||||
const stateLine = $('models-state');
|
||||
const running = reg.job?.state === 'running';
|
||||
if (reg.phase === 'none') {
|
||||
stateLine.textContent = 'no models discovered -- model use is disabled until you discover';
|
||||
} else if (reg.phase === 'preliminary') {
|
||||
stateLine.textContent = `preliminary registry -- ${reg.models.length} scraped, unrefined (discovered ${fmtStamp(reg.discovered)})`;
|
||||
} else {
|
||||
stateLine.textContent = `refined registry -- ${reg.models.filter((m) => m.inference !== false).length}/${reg.models.length} usable \u00b7 defaults ${reg.defaults.player ?? 'none'} / ${reg.defaults.housekeeper ?? 'none'}${reg.curator && reg.curator !== 'curated' ? ` \u00b7 ${reg.curator}` : ''} (refined ${fmtStamp(reg.refined)})`;
|
||||
}
|
||||
if (running) stateLine.textContent = `refining -- ${reg.job?.phase ?? ''} started ${fmtStamp(reg.job?.started ?? null)}; this page follows the job`;
|
||||
/** @type {HTMLButtonElement} */ ($('models-discover')).disabled = running;
|
||||
/** @type {HTMLButtonElement} */ ($('models-refine')).disabled = running || reg.phase === 'none';
|
||||
|
||||
const list = $('models-list');
|
||||
list.textContent = '';
|
||||
for (const m of reg.models) {
|
||||
const row = el('div', 'admin-row');
|
||||
const facts = [
|
||||
m.id,
|
||||
m.label && m.label !== m.id ? m.label : null,
|
||||
m.family ? `(${m.family})` : null,
|
||||
fmtCeiling(m.input) ? `${fmtCeiling(m.input)} in` : null,
|
||||
m.output ? `${fmtCeiling(m.output)} out` : null,
|
||||
m.status === 'unrefined' ? 'unrefined' : null,
|
||||
m.inference === false ? 'FAILED the inference probe' : null,
|
||||
m.inference !== false && m.reasoning ? `reasoning ${m.reasoning}` : null,
|
||||
m.latency != null ? `${m.latency}ms` : null,
|
||||
].filter(Boolean).join(' \u00b7 ');
|
||||
row.appendChild(el('span', 'grow', facts));
|
||||
if (m.description) row.appendChild(el('span', 'hint', m.description));
|
||||
list.appendChild(row);
|
||||
}
|
||||
if (running && seq === state.seq) {
|
||||
// the job follows itself home: poll until it lands, then re-render
|
||||
setTimeout(async () => {
|
||||
const r = await api('/models').catch(() => null);
|
||||
if (!r || seq !== state.seq || state.view !== 'home') return;
|
||||
if (r.job?.state === 'running') renderModelsAdmin(r, seq);
|
||||
else render();
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {?string} iso @returns {string} */
|
||||
function fmtStamp(iso) {
|
||||
return iso ? `${iso.slice(0, 10)} ${iso.slice(11, 19)} UTC` : '?';
|
||||
}
|
||||
|
||||
// discover: the free scrape -- armed because it resets a refined
|
||||
// registry back to the preliminary list (the curation is re-earned
|
||||
// by refining again)
|
||||
armedButton($('models-discover'), {
|
||||
label: 'discover',
|
||||
confirm: 'resets the registry to a fresh scrape -- click again',
|
||||
fire: async () => {
|
||||
try { await api('/models/discover', { method: 'POST', body: {} }); } catch (e) { banner(e.message); return; }
|
||||
render();
|
||||
},
|
||||
});
|
||||
|
||||
// refine: the inference battery + the curator pass -- real traffic
|
||||
armedButton($('models-refine'), {
|
||||
label: 'refine',
|
||||
confirm: 'sends real traffic over every model -- may cost a buck. click again',
|
||||
fire: async () => {
|
||||
try { await api('/models/refine', { method: 'POST', body: {} }); } catch (e) { banner(e.message); return; }
|
||||
render();
|
||||
},
|
||||
});
|
||||
|
||||
$('new-run-btn').addEventListener('click', () => navigate('/new'));
|
||||
$('invite-mint').addEventListener('click', async () => {
|
||||
try {
|
||||
|
||||
+39
-3
@@ -17,7 +17,7 @@ import { banner, hideBanner, renderMeter, setBusy, setSessionInfo } from './chro
|
||||
import { navigate, render, runGone } from './router.mjs';
|
||||
import { logEvent } from './log.mjs';
|
||||
import { armedButton, modelList, modelsBox, paneEditor } from './widgets.mjs';
|
||||
import { renderRaw, renderTranscript } from './transcript.mjs';
|
||||
import { renderRaw, renderTranscript, viaLine } from './transcript.mjs';
|
||||
|
||||
// the table's two faces: the curated projection (the table) and the
|
||||
// raw audit log. Sticky across the re-renders a turn triggers;
|
||||
@@ -123,7 +123,7 @@ async function refreshPlay(id, seq) {
|
||||
} else {
|
||||
/** @type {TableResponse} */ const session = await api(`/runs/${id}/table`);
|
||||
if (seq !== state.seq) return;
|
||||
renderTranscript(session.entries, { onConflict: showConflict });
|
||||
renderTranscript(session.entries, { onConflict: showConflict, onRaw: showRawEntry });
|
||||
}
|
||||
} else if (detail.phase === 'dormant') {
|
||||
// the review window: the carryover is the preview of the next
|
||||
@@ -152,7 +152,7 @@ async function refreshPlay(id, seq) {
|
||||
$('models-pane').hidden = false;
|
||||
const mlist = await modelList();
|
||||
if (seq !== state.seq) return;
|
||||
models.fill(detail.run.models, detail.run.modelDefaults, mlist);
|
||||
models.fill(detail.run.models, detail.run.modelDefaults, detail.run.params, detail.run.paramDefaults, mlist);
|
||||
|
||||
// pending ask: the modal re-presents after a refresh -- the owner's
|
||||
// to answer
|
||||
@@ -195,6 +195,42 @@ function showConflict(text) {
|
||||
c.hidden = false;
|
||||
}
|
||||
|
||||
// one entry's wire form, inline on the table: the raw session is the
|
||||
// audit surface, fetched on demand -- the same data the raw tab
|
||||
// shows, one entry at a time (the walks are index-aligned: table
|
||||
// entry i is session entry i). Thinking, the whole variants block,
|
||||
// the rides as sent, tool arguments, the request record (resolved
|
||||
// model + effective params) -- everything the table curates away, in
|
||||
// place, no tab switch.
|
||||
/** @param {number} idx @param {HTMLElement} slot @returns {Promise<void>} */
|
||||
async function showRawEntry(idx, slot) {
|
||||
let entry;
|
||||
try {
|
||||
/** @type {TableResponse} */ const session = await api(`/runs/${state.runId}/session`);
|
||||
entry = session.entries[idx];
|
||||
} catch (e) {
|
||||
banner(e.message);
|
||||
return;
|
||||
}
|
||||
if (!entry || entry.t !== 'msg') {
|
||||
banner('the raw entry could not be found -- refresh and try again');
|
||||
return;
|
||||
}
|
||||
const block = el('div', 'raw-block');
|
||||
if (entry.m.role === 'assistant' && entry.m.reasoning_content) {
|
||||
block.appendChild(el('div', 'who', 'thinking'));
|
||||
block.appendChild(el('pre', 'raw-thinking', entry.m.reasoning_content));
|
||||
}
|
||||
if (entry.via) block.appendChild(el('div', 'machinery', viaLine(entry.via)));
|
||||
block.appendChild(el('div', 'who', entry.m.role === 'user' ? 'gm -- as sent' : 'player -- as sent'));
|
||||
block.appendChild(el('pre', null, String(entry.m.content ?? '')));
|
||||
for (const c of entry.m.tool_calls ?? []) {
|
||||
block.appendChild(el('div', 'machinery', `[tool call] ${c.function.name}`));
|
||||
if (c.function.arguments) block.appendChild(el('pre', null, String(c.function.arguments)));
|
||||
}
|
||||
slot.appendChild(block);
|
||||
}
|
||||
|
||||
// --- the GM's notepad: always on screen, auto-saved -------------------
|
||||
//
|
||||
// A debounced save (1s after the last keystroke, immediate on blur),
|
||||
|
||||
+4
-4
@@ -29,7 +29,7 @@ const EDIT_LIST = [
|
||||
{ name: 'handbook.md', mode: 'rw', source: 'run' },
|
||||
{ name: 'backdrop.md', mode: 'rw', source: 'run' },
|
||||
{ name: 'character.md', mode: 'rw', source: 'run' },
|
||||
{ name: 'memory.json', mode: 'ro', source: 'run' }, // the session-0 manifest, applied at creation -- provenance
|
||||
{ name: 'memory.json', mode: 'ro', source: 'run' }, // her starting memories -- authored while the run is a draft; the start gate applies them
|
||||
{ name: 'carryover.jsonl', mode: 'rw', source: 'run' }, // the opening log -- raw events, linted on save
|
||||
{ name: 'settings.json', mode: 'ro', source: 'run' },
|
||||
{ name: 'run.json', mode: 'ro', source: 'run' },
|
||||
@@ -102,10 +102,10 @@ export async function enter(id, seq) {
|
||||
varsList.appendChild(row);
|
||||
}
|
||||
|
||||
// models: per-run overrides, selected from the upstream listing
|
||||
// models: per-run overrides, selected from the registry
|
||||
const mlist = await modelList();
|
||||
if (seq !== state.seq) return;
|
||||
models.fill(detail.run.models, detail.run.modelDefaults, mlist);
|
||||
models.fill(detail.run.models, detail.run.modelDefaults, detail.run.params, detail.run.paramDefaults, mlist);
|
||||
|
||||
const nav = $('setup-files');
|
||||
nav.textContent = '';
|
||||
@@ -303,7 +303,7 @@ async function startRun() {
|
||||
if (r.autoSend) logEvent('nav', 'the carryover ended on a GM turn -- sent automatically as her cue');
|
||||
} catch (e) {
|
||||
if (e.status === 422 && e.detail?.errors) {
|
||||
banner(`the carryover did not pass the start lint:\n${e.detail.errors.join('\n')}`);
|
||||
banner(`the start refused:\n${e.detail.errors.join('\n')}`);
|
||||
} else {
|
||||
banner(e.message);
|
||||
}
|
||||
|
||||
+86
-22
@@ -6,13 +6,16 @@
|
||||
// - paneEditor: the status/agenda pattern -- a body line, an edit
|
||||
// button, an inline editor; the section shell stays in index.html
|
||||
// - modelsBox: the per-run player/housekeeper selects over the
|
||||
// upstream listing; setup and the play aside each carry one
|
||||
// registry plus the sampling knobs (knobs.mjs owns the knob row
|
||||
// and its definitions table); setup and the play aside each carry
|
||||
// one
|
||||
|
||||
import { $, el } from './dom.mjs';
|
||||
import { api } from './client.mjs';
|
||||
import { state } from './state.mjs';
|
||||
import { banner } from './chrome.mjs';
|
||||
import { render } from './router.mjs';
|
||||
import { knobsBox } from './knobs.mjs';
|
||||
|
||||
// two-click confirm -- the second click within 5s fires; anything
|
||||
// else disarms. Each button owns its own arm state.
|
||||
@@ -103,21 +106,33 @@ export function paneEditor({ section, body, empty, placeholder, rows, format, to
|
||||
};
|
||||
}
|
||||
|
||||
// the upstream model listing, fetched once per session -- a live
|
||||
// /models call every render would hammer the endpoint for a list
|
||||
// that rarely changes
|
||||
/** @type {?string[]} */ let cachedModels = null;
|
||||
/** @returns {Promise<string[]>} */
|
||||
// the model registry, fetched once per session -- the selectors read
|
||||
// the saved registry, never the live provider (discovery is the op's
|
||||
// manual act; a listing fetch every render would hammer the endpoint
|
||||
// for a list that rarely changes)
|
||||
/** @type {?import('./shapes.mjs').ModelsRegistryResponse} */ let cachedRegistry = null;
|
||||
/** @returns {Promise<import('./shapes.mjs').ModelsRegistryResponse>} */
|
||||
export async function modelList() {
|
||||
if (!cachedModels) cachedModels = /** @type {string[]} */ (await api('/models').catch(() => []));
|
||||
return cachedModels;
|
||||
if (!cachedRegistry) cachedRegistry = /** @type {import('./shapes.mjs').ModelsRegistryResponse} */ (await api('/models').catch(() => /** @type {import('./shapes.mjs').ModelsRegistryResponse} */ ({ phase: 'none', discovered: null, refined: null, curator: null, defaults: {}, models: [], job: null })));
|
||||
return cachedRegistry;
|
||||
}
|
||||
|
||||
// a context ceiling as the short human form: 1048576 -> "1M",
|
||||
// 524288 -> "512K". Null when the provider stated nothing.
|
||||
/** @param {?number} tokens @returns {?string} */
|
||||
export function fmtCeiling(tokens) {
|
||||
if (tokens == null || !Number.isFinite(tokens) || tokens <= 0) return null;
|
||||
return tokens >= 1048576 ? `${Math.round(tokens / 1048576)}M` : `${Math.round(tokens / 1024)}K`;
|
||||
}
|
||||
|
||||
// A select's "" value means "deployment default"; a current override
|
||||
// missing from the listing stays selectable, so a stale pick never
|
||||
// silently rewrites itself.
|
||||
/** @param {HTMLSelectElement} sel @param {?string} current @param {string[]} list @param {?string} [def] */
|
||||
function fillSelect(sel, current, list, def) {
|
||||
// missing from the registry stays selectable, so a stale pick never
|
||||
// silently rewrites itself. The registry's usable models group by
|
||||
// family; the label is the curator's (or the id before refinement),
|
||||
// and the input ceiling rides along -- the user picks against the
|
||||
// contwin, so the context limit belongs in the open.
|
||||
/** @param {HTMLSelectElement} sel @param {?string} current @param {import('./shapes.mjs').ModelsRegistryResponse} reg @param {?string} [def] */
|
||||
function fillSelect(sel, current, reg, def) {
|
||||
sel.textContent = '';
|
||||
/** @param {string} v @param {string} label */
|
||||
const mk = (v, label) => {
|
||||
@@ -126,14 +141,33 @@ function fillSelect(sel, current, list, def) {
|
||||
sel.appendChild(o);
|
||||
};
|
||||
mk('', `deployment default${def ? ` -- ${def}` : ' (unset)'}`);
|
||||
const opts = [...list];
|
||||
if (current && !opts.includes(current)) opts.push(current);
|
||||
for (const m of opts) mk(m, m);
|
||||
const usableModels = reg.models.filter((m) => m.inference !== false && (m.roles?.player ?? true));
|
||||
const extras = current && !usableModels.some((m) => m.id === current) ? [current] : [];
|
||||
/** @type {Record<string, import('../server/shapes.mjs').RegistryModel[]>} */ const byFamily = {};
|
||||
for (const m of usableModels) {
|
||||
const f = m.family ?? m.id;
|
||||
(byFamily[f] ??= []).push(m);
|
||||
}
|
||||
const families = Object.keys(byFamily).sort();
|
||||
for (const f of families) {
|
||||
const group = /** @type {HTMLOptGroupElement} */ (el('optgroup'));
|
||||
group.label = f;
|
||||
for (const m of byFamily[f]) {
|
||||
const label = m.label ?? m.id;
|
||||
const ceil = fmtCeiling(m.input);
|
||||
const o = /** @type {HTMLOptionElement} */ (el('option', null, ceil ? `${label} \u00b7 ${ceil}` : label));
|
||||
o.value = m.id;
|
||||
group.appendChild(o);
|
||||
}
|
||||
sel.appendChild(group);
|
||||
}
|
||||
for (const x of extras) mk(x, `${x} (not in the registry)`);
|
||||
sel.value = current ?? '';
|
||||
}
|
||||
|
||||
// the models box: player/housekeeper selects + save, posting the
|
||||
// per-run overrides. The mount keeps its id -- the CSS panels it.
|
||||
// the models box: player/housekeeper selects over the registry, the
|
||||
// sampling knobs per role (one shared hint bar under both rows), and
|
||||
// one save. The mount keeps its id -- the CSS panels it.
|
||||
/** @param {string|HTMLElement} mount @param {{ title: string }} opts */
|
||||
export function modelsBox(mount, { title }) {
|
||||
const root = typeof mount === 'string' ? $(mount) : mount;
|
||||
@@ -147,6 +181,16 @@ export function modelsBox(mount, { title }) {
|
||||
hField.appendChild(houseSel);
|
||||
root.appendChild(pField);
|
||||
root.appendChild(hField);
|
||||
const knobHint = el('div', 'knob-hint'); // one bar, both roles
|
||||
/** @type {{ wrap: HTMLElement, read: () => Record<string, number|null> }} */ let playerKnobs = knobsBox('player', undefined, undefined, knobHint);
|
||||
/** @type {{ wrap: HTMLElement, read: () => Record<string, number|null> }} */ let houseKnobs = knobsBox('housekeeper', undefined, undefined, knobHint);
|
||||
root.appendChild(playerKnobs.wrap);
|
||||
root.appendChild(houseKnobs.wrap);
|
||||
root.appendChild(knobHint);
|
||||
if (!root.querySelector('.registry-hint')) {
|
||||
const hint = el('div', 'hint registry-hint', '');
|
||||
root.appendChild(hint);
|
||||
}
|
||||
const saveBtn = el('button', null, 'save models');
|
||||
const saveState = el('span', 'save-state');
|
||||
const actions = el('div', 'form-actions');
|
||||
@@ -155,9 +199,15 @@ export function modelsBox(mount, { title }) {
|
||||
root.appendChild(actions);
|
||||
saveBtn.addEventListener('click', async () => {
|
||||
try {
|
||||
// the knob read throws on an empty override -- same banner, nothing sent
|
||||
const params = { player: playerKnobs.read(), housekeeper: houseKnobs.read() };
|
||||
await api(`/runs/${state.runId}/model`, {
|
||||
method: 'POST',
|
||||
body: { player: playerSel.value || null, housekeeper: houseSel.value || null },
|
||||
body: {
|
||||
player: playerSel.value || null,
|
||||
housekeeper: houseSel.value || null,
|
||||
params,
|
||||
},
|
||||
});
|
||||
saveState.textContent = 'saved';
|
||||
} catch (e) {
|
||||
@@ -166,10 +216,24 @@ export function modelsBox(mount, { title }) {
|
||||
}
|
||||
});
|
||||
return {
|
||||
/** @param {?{ player?: ?string, housekeeper?: ?string }} models @param {?{ player?: ?string, housekeeper?: ?string }} defaults @param {string[]} list */
|
||||
fill(models, defaults, list) {
|
||||
fillSelect(playerSel, models?.player ?? null, list, defaults?.player);
|
||||
fillSelect(houseSel, models?.housekeeper ?? null, list, defaults?.housekeeper);
|
||||
/** @param {?{ player?: ?string, housekeeper?: ?string }} models @param {?{ player?: ?string, housekeeper?: ?string }} defaults @param {?{ player?: ?import('../server/shapes.mjs').RoleParams, housekeeper?: ?import('../server/shapes.mjs').RoleParams }} params @param {?{ player?: ?import('../server/shapes.mjs').RoleParams, housekeeper?: ?import('../server/shapes.mjs').RoleParams }} paramDefaults @param {import('./shapes.mjs').ModelsRegistryResponse} reg */
|
||||
fill(models, defaults, params, paramDefaults, reg) {
|
||||
fillSelect(playerSel, models?.player ?? null, reg, defaults?.player);
|
||||
fillSelect(houseSel, models?.housekeeper ?? null, reg, defaults?.housekeeper);
|
||||
const pk = knobsBox('player', params?.player ?? undefined, paramDefaults?.player ?? undefined, knobHint);
|
||||
const hk = knobsBox('housekeeper', params?.housekeeper ?? undefined, paramDefaults?.housekeeper ?? undefined, knobHint);
|
||||
playerKnobs.wrap.replaceWith(pk.wrap);
|
||||
houseKnobs.wrap.replaceWith(hk.wrap);
|
||||
playerKnobs = pk;
|
||||
houseKnobs = hk;
|
||||
const hint = root.querySelector('.registry-hint');
|
||||
if (hint) {
|
||||
hint.textContent = reg.phase === 'none'
|
||||
? 'no models discovered -- the op runs discovery from the admin block on home'
|
||||
: reg.phase === 'preliminary'
|
||||
? 'preliminary registry -- unrefined: the op can run refine to verify and label the models'
|
||||
: '';
|
||||
}
|
||||
saveState.textContent = '';
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user