Switch the extract and summarise stages on the page, over config.yaml

A stored `stage:extract` / `stage:summarise` in the state table overrides
extract.enabled / summarise.enabled; with none, the file applies. One
function, stages.stage_on, decides, and both tasks' finders ask it.
GET/PUT /api/stages and `app stages` show and set it with who would answer;
Runs has a "What the model reads" block, and a search agent's card says when
a stage is off and links to the switch.

Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Sonnet committed 2026-09-29 15:54:53 +02:00
1 parent a629eda8de
commit 471ace703c
15 files changed
+593 -23

No files matched your search

+30 -2
View File
@@ -28,6 +28,10 @@
/** @type {object[]} every agent, as the server lists them */
let agents = [];
/** @type {Object<string, boolean>} whether extract and summarise run, from
* `/api/stages`; empty when that did not answer, and then a card says
* nothing about them */
let stageOn = {};
/** @type {number | "new" | null} the card in edit mode: an agent's id, NEW
* for the blank one on top, null for none */
let editing = null;
@@ -112,9 +116,27 @@
return `fit ${w.fit} · newness ${w.recency} · companies ${w.affinity} · liked ${w.taste}${gates}`;
}
// What the model reads after a pull, one clause per stage. A stage that is
// off says so, with a link to its switch under Runs: the numbers are only
// what it would read once it is on.
function limitsLine(row) {
const l = Object.assign({}, DEFAULT_LIMITS, row.limits);
return `reads ${l.extract_top} at ${l.extract_min} · summarises ${l.summarise_top} at ${l.summarise_min}`;
const p = el("p", "agent-limits");
const clauses = [
["extract", `reads ${l.extract_top} at ${l.extract_min}`, `${l.extract_top} at ${l.extract_min}`],
["summarise", `summarises ${l.summarise_top} at ${l.summarise_min}`, `${l.summarise_top} at ${l.summarise_min}`],
];
clauses.forEach(([name, on, would], i) => {
if (i) p.append(" · ");
if (stageOn[name] === false) {
const off = link("/settings/sources#stages", `${name} is off`);
off.title = "Switch it on under Runs, What the model reads.";
p.append(off, ` (${would})`);
} else {
p.append(on);
}
});
return p;
}
function card(row, fallback) {
@@ -136,7 +158,7 @@
? el("p", "agent-intent", intent)
: el("p", "agent-intent empty", "Nothing described yet, so fit has nothing to measure against. Edit says what this agent looks for."));
div.appendChild(el("p", "agent-weights", weightsLine(row)));
div.appendChild(el("p", "agent-limits", limitsLine(row)));
div.appendChild(limitsLine(row));
const actions = el("div", "agent-card-actions");
const edit = el("button", "secondary", "Edit");
@@ -330,6 +352,12 @@
async function load() {
agents = await api("/api/agents");
// A card is only worded by it, so a failure leaves the cards as they were.
try {
stageOn = Object.fromEntries((await api("/api/stages")).map((s) => [s.name, s.on]));
} catch (err) {
stageOn = {};
}
}
document.addEventListener("DOMContentLoaded", async () => {