Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 472189f49e8e0e7361425176190c8833151e848e
parent 6d6cd79c21ac218176aa79b6f9938526e20e46d5
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 13 Oct 2026 21:30:26 -0400

report-draft: a per-job extractorModel — ops, the MCP's generate, umtool's sweep forms (r28 F2)

`report-draft {extractorModel}` names an API sweep's extractor (a Claude
model id the price table knows, isKnownApiModel; a sweep's only) in place of
settings.generation.models.extractor; on a local sweep it is unused, with a
warning. The MCP's generate takes and checks it; umtool shows an extractor
beside a sweep's Claude model (new article, copy with model, a research
run's continuation) and sends it when it is not the policy's. COMMANDS.md
regenerated.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
MCOMMANDS.md | 2+-
Mcommon/controller/reportDraft.ts | 26++++++++++++++++++++++++--
Meditor/app/api/ops/_reportDraft.test.ts | 29+++++++++++++++++++++++++++++
Meditor/app/api/ops/report-draft/route.ts | 9+++++----
Mmcp/src/generation.test.ts | 6++++++
Mmcp/src/generation.ts | 10+++++++++-
Mscripts/archilyzer-ops.mjs | 9++++++---
Mumtool/app/api/articles/generate/route.ts | 8+++++---
Aumtool/components/articles/ExtractorSelect.tsx | 40++++++++++++++++++++++++++++++++++++++++
Mumtool/components/articles/IterationsTab.tsx | 20+++++++++++++++++++-
Mumtool/components/articles/NewArticleForm.tsx | 6++++++
Mumtool/components/articles/ResearchSlot.tsx | 17++++++++++++++++-
Mumtool/e2e/article-new.spec.ts | 6++++++
Mumtool/lib/articles/generation.ts | 2+-
14 files changed, 173 insertions(+), 17 deletions(-)

diff --git a/COMMANDS.md b/COMMANDS.md @@ -143,7 +143,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run) | `archive-search` | archive-search searches archive.org (its advanced-search syntax) and answers the items: {"query", "limit"?: 50 (at most 500)} -&gt; {found, items: \[{identifier, title?}\]}, in identifier order. One request through the editor's archive.org client, paced and backed off as an import is. Read only; import-archive-org with "query" imports what a search finds. | `pnpm ops archive-search --json '{"query":"title:(kitchen) AND mediatype:movies","limit":20}'` | | `archive-item` | archive-item answers one archive.org item's files from its metadata: {"item"} -&gt; {item: {identifier, url, title?, date?, mediatype?, creator?, collections, restricted, mediaFiles, mediaBytes, files: \[{name, format?, source?, size?, seconds?, media, restricted, original?}\]}}. media marks the originals an import takes (one record each); restricted, what archive.org will not hand out. Read only; nothing is downloaded. | `pnpm ops archive-item --json '{"item":"example-item"}'` | | `import-post` | import-post imports ONE post by its URL into a posts channel of its platform: {"slug", "url"} — an X status (x.com/&lt;handle&gt;/status/&lt;id&gt;) or a Bluesky post (bsky.app/profile/&lt;handle&gt;/post/&lt;id&gt;, or its at:// URI). Read through the channel's own fetcher (gallery-dl for X, with the channel's login; the public AppView for Bluesky) as an import-post job on the platform's queue. Refused, before any job: a URL that is not a post, a channel that is not a posts channel of that platform or whose fetcher cannot read one post, a post the URL names as another account's, the platform held or cooling down. A post already archived is not read again; one the platform says is another account's is not written. The log ends with @@import-post {ok, slug, url, id, written, already?, post?, error?}. | `pnpm ops import-post --json '{"slug":"demo-x","url":"https://x.com/example/status/1700000000000000001"}' --wait` | -| `report-draft` | report-draft runs a generation over an article's iteration as a report-draft job: {"task": "sweep" \| "revise-report" \| "revise-video" \| "narrate" \| "research", "article", ...} -&gt; {jobId, iteration, warnings?}. A sweep takes "question" and "channels" (and "from"/"to"): a new iteration; a revision takes "iteration" (the one it revises) and "feedback": a new iteration; a narration takes "iteration" (a done one; "cards"?, "force"?) and is a step on it. "copyOf" N runs iteration N again on "model". "model" defaults to settings.generation's route for the task (one routed to code needs a model named). A Claude model runs on draft:api, capped at "maxUsd" (default by task, never above caps.max), and is refused when the day's API total has reached caps.daily; a local model runs on draft:local, through the GPU arbiter, and is unloaded when it ends. The corpus is "source" (a handle), "build" (a composed build), or the newest build holding the channels. `job cancel <id>` stops it. The log ends with @@report-draft {article, iteration, task, status, summary, usd, minutes}; --wait prints it. A research run takes "question" ("channels"? "from"/"to"?) and "autonomy" (propose \| limits \| auto; default settings.generation.research): it searches the corpus, the web and archive.org and proposes acquisitions (archive.org imports, videos, new channels — always on no site —, posts, transcription, persisting), each with its reason and evidence, enqueuing what its autonomy and the settings' caps allow through the editor's own actions; the rest waits in the iteration's proposals.json. A sweep with "iteration" N CONTINUES research run N: its question, over its channels and every channel a done acquisition wrote into, the sweep's parent N; refused while N still waits, unless "force" (what is done so far). | `pnpm ops report-draft --json '{"task":"sweep","article":"demo-article","question":"What does she say about the shop?","channels":["demo-channel"]}' --wait`<br>`pnpm ops report-draft --json '{"task":"revise-report","article":"demo-article","iteration":1,"feedback":"Drop the second finding."}'`<br>`pnpm ops report-draft --json '{"task":"research","article":"demo-article","question":"Where did the shop story start?","autonomy":"propose"}' --wait`<br>`pnpm ops report-draft --json '{"task":"sweep","article":"demo-article","iteration":1}'` | +| `report-draft` | report-draft runs a generation over an article's iteration as a report-draft job: {"task": "sweep" \| "revise-report" \| "revise-video" \| "narrate" \| "research", "article", ...} -&gt; {jobId, iteration, warnings?}. A sweep takes "question" and "channels" (and "from"/"to"): a new iteration; a revision takes "iteration" (the one it revises) and "feedback": a new iteration; a narration takes "iteration" (a done one; "cards"?, "force"?) and is a step on it. "copyOf" N runs iteration N again on "model". "extractorModel" is an API sweep's extractor (a Claude model id; default settings.generation.models.extractor). "model" defaults to settings.generation's route for the task (one routed to code needs a model named). A Claude model runs on draft:api, capped at "maxUsd" (default by task, never above caps.max), and is refused when the day's API total has reached caps.daily; a local model runs on draft:local, through the GPU arbiter, and is unloaded when it ends. The corpus is "source" (a handle), "build" (a composed build), or the newest build holding the channels. `job cancel <id>` stops it. The log ends with @@report-draft {article, iteration, task, status, summary, usd, minutes}; --wait prints it. A research run takes "question" ("channels"? "from"/"to"?) and "autonomy" (propose \| limits \| auto; default settings.generation.research): it searches the corpus, the web and archive.org and proposes acquisitions (archive.org imports, videos, new channels — always on no site —, posts, transcription, persisting), each with its reason and evidence, enqueuing what its autonomy and the settings' caps allow through the editor's own actions; the rest waits in the iteration's proposals.json. A sweep with "iteration" N CONTINUES research run N: its question, over its channels and every channel a done acquisition wrote into, the sweep's parent N; refused while N still waits, unless "force" (what is done so far). | `pnpm ops report-draft --json '{"task":"sweep","article":"demo-article","question":"What does she say about the shop?","channels":["demo-channel"]}' --wait`<br>`pnpm ops report-draft --json '{"task":"revise-report","article":"demo-article","iteration":1,"feedback":"Drop the second finding."}'`<br>`pnpm ops report-draft --json '{"task":"research","article":"demo-article","question":"Where did the shop story start?","autonomy":"propose"}' --wait`<br>`pnpm ops report-draft --json '{"task":"sweep","article":"demo-article","iteration":1}'` | | `research-approve` | research-approve settles a research run's acquisitions: {"article", "iteration", "ids"?: \["p01", …\], "approve"?: true \| false, "note"?} -&gt; {outcomes: \[{id, status?, jobId?, note?, error?}\], research: {phase, autonomy, limits, spent, proposals, waitingOn: {approval, jobs}, continuedBy}}. It first refreshes every enqueued acquisition from its jobs (all done: done; one failed: failed, naming it). approve: true runs each proposal through the editor's own action (past the run's autonomy and caps, never past a standing rule); false rejects it, note saying why. No ids: the run's state now. The phase is wait (approvals or jobs pending), ready (nothing pending: continue with report-draft {"task": "sweep", "iteration": N}) or continued. Refused while the run's job is going. | `pnpm ops research-approve --json '{"article":"demo-article","iteration":1,"ids":["p01","p03"],"approve":true}'` | ### Usage, flags and environment diff --git a/common/controller/reportDraft.ts b/common/controller/reportDraft.ts @@ -8,6 +8,9 @@ // sweep, the research run it CONTINUES (S11: its question, and its // channels widened by what it acquired, are the defaults); else none // model default: settings.generation.models[route] for the task's route +// extractorModel an API sweep's extractor (default: +// settings.generation.models.extractor): a Claude model id the +// price table knows (release 28 F2) // question / channels / from / to a sweep's // feedback a revision's // copyOf run iteration N again on another model (same kind and inputs) @@ -38,7 +41,7 @@ import type { Paths } from "../lib/paths"; import { getSettings } from "../lib/settings"; import { capFor, type GenerationSettings, type GenerationTask } from "../lib/generationSettings"; import { PROJECT_URL } from "../lib/project"; -import { providerOf, unloadOllama, type LlmConfig } from "../lib/llm"; +import { PRICES, providerOf, unloadOllama, type LlmConfig } from "../lib/llm"; import { webTools } from "../lib/web/tools"; import { copyIteration, @@ -72,6 +75,7 @@ export const REPORT_DRAFT_BODY_KEYS = [ "article", "iteration", "model", + "extractorModel", "feedback", "question", "channels", @@ -93,6 +97,7 @@ export type ReportDraftBody = { article: string; iteration?: number; model?: string; + extractorModel?: string; feedback?: string; question?: string; channels?: string[]; @@ -107,6 +112,12 @@ export type ReportDraftBody = { autonomy?: Autonomy; }; +// A Claude model the price table knows: one of its ids, or a dated id of one +// (`claude-haiku-4-5-20251001`). +export function isKnownApiModel(model: string): boolean { + return model.startsWith("claude-") && Object.keys(PRICES).some((p) => model === p || model.startsWith(`${p}-`)); +} + const TASKS: readonly GenerationTask[] = ["sweep", "revise-report", "revise-video", "narrate", "research"]; const ymd = /^\d{4}-\d{2}-\d{2}$/; @@ -146,6 +157,14 @@ export function parseReportDraftBody(b: Record<string, unknown>): ReportDraftBod set("iteration", int("iteration")); set("copyOf", int("copyOf")); set("model", text("model")); + const extractor = text("extractorModel"); + if (extractor !== undefined) { + if (!isKnownApiModel(extractor)) { + fail(`"extractorModel" is a Claude model id (${Object.keys(PRICES).filter((m) => m.startsWith("claude-")).join(", ")}): an API sweep's extractor runs on the API`); + } + if (task !== "sweep") fail('"extractorModel" is a sweep\'s (the extractor an API sweep reads batches with)'); + out.extractorModel = extractor; + } set("feedback", text("feedback")); set("question", text("question")); set("channels", list("channels")); @@ -334,6 +353,9 @@ export async function enqueueReportDraft(raw: Record<string, unknown>, deps: Rep } const model = modelFor(gen, body.task, body.model); const provider = providerOf(model); + if (body.extractorModel && provider === "local") { + warnings.push(`extractorModel ${body.extractorModel} is unused: a sweep on a local model runs the pipeline, which has no extractor`); + } let maxUsd: number | undefined; if (provider === "api") { maxUsd = capFor(gen.caps, CAP_OF[body.task], body.maxUsd); @@ -462,7 +484,7 @@ async function runReportDraft( const projectsRoot = projectsRootOf(gen); // A local run costs nothing: it has no dollar cap. const cap = provider === "api" ? o.maxUsd! : Number.POSITIVE_INFINITY; - const extractor = gen.models.extractor; + const extractor = body.extractorModel ?? gen.models.extractor; let input: TaskInput; switch (body.task) { case "sweep": diff --git a/editor/app/api/ops/_reportDraft.test.ts b/editor/app/api/ops/_reportDraft.test.ts @@ -81,6 +81,15 @@ test("the body: each task's needs, and the refusals in words", () => { assert.deepEqual(parseReportDraftBody({ task: "sweep", article: "a", question: " q ", channels: "x, y" }), { task: "sweep", article: "a", question: "q", channels: ["x", "y"] }); }); +test("extractorModel (release 28 F2): a sweep's, a Claude model the price table knows", () => { + const sweep = { task: "sweep", article: "a", question: "q", channels: ["x"] }; + assert.equal(parseReportDraftBody({ ...sweep, extractorModel: "claude-haiku-5-5" }).extractorModel, "claude-haiku-5-5"); + assert.equal(parseReportDraftBody({ ...sweep, extractorModel: "claude-haiku-4-5-20251001" }).extractorModel, "claude-haiku-4-5-20251001"); + assert.throws(() => parseReportDraftBody({ ...sweep, extractorModel: "qwen3:8b" }), /"extractorModel" is a Claude model id/); + assert.throws(() => parseReportDraftBody({ ...sweep, extractorModel: "claude-nonsense-9" }), /"extractorModel" is a Claude model id/); + assert.throws(() => parseReportDraftBody({ task: "revise-report", article: "a", iteration: 1, feedback: "f", extractorModel: "claude-haiku-5-5" }), /"extractorModel" is a sweep's/); +}); + test("refused before any iteration: a task routed to Claude Code with no model, a cap over max", async () => { const code = await enqueueReportDraft({ task: "sweep", article: "synth-refused", question: "q", channels: ["synth-kitchen"], source }, deps()); assert.equal(code.result.ok, false); @@ -117,6 +126,26 @@ test("an API sweep: a report-draft job on draft:api, the iteration done with its assert.equal(api.requestHeaders.at(-1)!["x-api-key"], FAKE_KEY, "the key file's key"); }); +test("an API sweep with its own extractorModel: the batches are read on it, its spend in the ledger", async () => { + const r = await run("sweep-agent"); + api.push(...r.turns); + const before = api.requests.length; + const out = await enqueueReportDraft( + { task: "sweep", article: "synth-extractor", model: r.model, extractorModel: "claude-haiku-5-5", question: r.question, channels: r.channels, source }, + deps(), + ); + assert.ok(out.result.ok && "iteration" in out, (out.result as { error?: string }).error); + void out.result.stream.cancel(); + const done = await out.result.done; + const job = getRegistry().get(out.result.jobId)!; + assert.equal(done.status, "done", await readFile(job.logPath, "utf8")); + const models = api.requests.slice(before).map((q: { model: string }) => q.model); + assert.ok(models.includes("claude-haiku-5-5"), models.join(",")); + assert.ok(!models.includes("claude-haiku-4-5"), "not the settings' extractor"); + const it = (await readIteration("synth-extractor", out.iteration, paths))!; + assert.ok(it.usage["claude-haiku-5-5"]!.calls === 1); +}); + test("the daily cap: a job that would start past the day's total is refused, naming it", async () => { const before = await readGenerationUsage(paths.generationUsageFile); const total = before.reduce((s, x) => s + x.usd, 0); diff --git a/editor/app/api/ops/report-draft/route.ts b/editor/app/api/ops/report-draft/route.ts @@ -7,9 +7,9 @@ import { researchEditor } from "../_researchEditor"; export const dynamic = "force-dynamic"; -// POST { task, article, iteration?, model?, feedback?, question?, channels?, -// from?, to?, copyOf?, maxUsd?, source?, build?, cards?, force?, -// autonomy? } +// POST { task, article, iteration?, model?, extractorModel?, feedback?, +// question?, channels?, from?, to?, copyOf?, maxUsd?, source?, build?, +// cards?, force?, autonomy? } // -> { ok: true, jobId, iteration, warnings? } // // A generation over an article's iteration (release 27 S6), as a @@ -28,7 +28,8 @@ export const dynamic = "force-dynamic"; // while N still waits, unless `force`); // - `copyOf` N: iteration N again on `model` (same kind and inputs). // `model` defaults to settings.generation's route for the task (a task routed -// to `code` needs one named). An API job's cap is `maxUsd`, else the task's +// to `code` needs one named). `extractorModel` is an API sweep's extractor +// (a Claude model id; default settings.generation.models.extractor). An API job's cap is `maxUsd`, else the task's // default (settings.generation.caps), never above `caps.max`; a job that would // start past the day's API total (`caps.daily`) is refused, naming it. The // corpus is `source` (a handle), `build` (a composed build's id), or the newest diff --git a/mcp/src/generation.test.ts b/mcp/src/generation.test.ts @@ -258,6 +258,10 @@ test("generate: the arguments are checked before any request; research is a task assert.ok(GENERATE_TASKS.includes("research")); const ok = validateGenerateArgs({ task: "research", article: "synth-a", question: "what was said?", channels: ["synth-kitchen"] }); assert.equal(ok.ok, true); + // A sweep's extractor, per job (release 28 F2), passed through as the editor's key. + const ex = validateGenerateArgs({ task: "sweep", article: "a", question: "q", channels: ["c"], extractorModel: " claude-haiku-5-5 " }); + assert.ok(ex.ok && ex.request.kind === "start"); + if (ex.ok && ex.request.kind === "start") assert.equal(ex.request.body.extractorModel, "claude-haiku-5-5"); for (const [args, re] of [ [{ task: "teaser", article: "a" }, /task is one of sweep, revise-report, revise-video, narrate, research/], [{ task: "sweep", article: "Not An Id" }, /article is an article id/], @@ -268,6 +272,8 @@ test("generate: the arguments are checked before any request; research is a task [{ task: "sweep", article: "a", via: "api", model: "x" }, /model or via, not both/], [{ task: "sweep", article: "a", wait_seconds: -2 }, /wait_seconds/], [{ job: "../etc" }, /is not a job id/], + [{ task: "revise-report", article: "a", iteration: 1, feedback: "f", extractorModel: "claude-haiku-4-5" }, /extractorModel is a sweep's/], + [{ task: "sweep", article: "a", extractorModel: "qwen3:8b" }, /extractorModel is a Claude model id/], ] as const) { const v = validateGenerateArgs(args as Record<string, unknown>); assert.equal(v.ok, false, JSON.stringify(args)); diff --git a/mcp/src/generation.ts b/mcp/src/generation.ts @@ -242,12 +242,16 @@ export function validateGenerateArgs(args: Record<string, unknown>): { ok: true; if (n === null) return bad(`${k} is an iteration number (1, 2, …)`); if (n !== undefined) body[k] = n; } - for (const k of ["model", "feedback", "question", "from", "to"] as const) { + for (const k of ["model", "extractorModel", "feedback", "question", "from", "to"] as const) { if (args[k] === undefined) continue; const v = trimmed(args[k]); if (!v) return bad(`${k} is text`); body[k] = v; } + if (body.extractorModel !== undefined) { + if (task !== "sweep") return bad("extractorModel is a sweep's (the extractor an API sweep reads batches with)"); + if (!String(body.extractorModel).startsWith("claude-")) return bad("extractorModel is a Claude model id: an API sweep's extractor runs on the API"); + } for (const k of ["channels", "cards"] as const) { if (args[k] === undefined) continue; const v = args[k]; @@ -620,6 +624,10 @@ export const GENERATION_TOOLS = [ feedback: { type: "string", description: "A revision's feedback: what to change, concretely." }, copyOf: { type: "integer", minimum: 1, description: "Run this iteration again (same kind and inputs) on model or via." }, model: { type: "string", description: "The model to run on (else the route's)." }, + extractorModel: { + type: "string", + description: "sweep on the API: the Claude model its extractor reads batches with (else the settings' extractor).", + }, via: { type: "string", enum: ["api", "local"], description: "Run on this route's model instead of the policy's route — only when the operator asks." }, maxUsd: { type: "number", description: "An API job's cap in USD (else the task's default; never above the settings' max)." }, cards: { type: "array", items: { type: "string" }, description: "narrate: only these card ids." }, diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs @@ -396,8 +396,9 @@ const ACTIONS = [ "import-post", // GENERATION (release 27 S6): a sweep, a report or video revision, or a // narration step over an article's iteration ({task, article, iteration?, - // model?, feedback?, question?, channels?, copyOf?, maxUsd?, …}), as a - // report-draft job on draft:api or draft:local. `job cancel` stops it. + // model?, extractorModel?, feedback?, question?, channels?, copyOf?, maxUsd?, + // …}), as a report-draft job on draft:api or draft:local. `job cancel` stops + // it. "report-draft", // RESEARCH RUNS (release 27 S11): a research run's acquisitions, after its // job — refreshed from their jobs, then approved (run through the editor) or @@ -1194,7 +1195,9 @@ export function usage() { ' and "channels" (and "from"/"to"): a new iteration; a revision takes', ' "iteration" (the one it revises) and "feedback": a new iteration; a', ' narration takes "iteration" (a done one; "cards"?, "force"?) and is a step', - ' on it. "copyOf" N runs iteration N again on "model". "model" defaults to', + ' on it. "copyOf" N runs iteration N again on "model". "extractorModel" is', + " an API sweep's extractor (a Claude model id; default", + ' settings.generation.models.extractor). "model" defaults to', " settings.generation's route for the task (one routed to code needs a model", ' named). A Claude model runs on draft:api, capped at "maxUsd" (default by', " task, never above caps.max), and is refused when the day's API total has", diff --git a/umtool/app/api/articles/generate/route.ts b/umtool/app/api/articles/generate/route.ts @@ -3,11 +3,13 @@ import { enqueueDraft, errorResponse } from "@/lib/articles/generation"; export const dynamic = "force-dynamic"; // START A GENERATION (release 27 S8): the body is `pnpm ops report-draft`'s — -// { task, article, iteration?, model?, feedback?, question?, channels?, from?, -// to?, copyOf?, maxUsd?, cards?, force?, autonomy? } — forwarded to the editor, which +// { task, article, iteration?, model?, extractorModel?, feedback?, question?, +// channels?, from?, to?, copyOf?, maxUsd?, cards?, force?, autonomy? } — +// forwarded to the editor, which // creates the iteration and runs the job. Answers { ok, jobId, iteration }. // -// a new article task sweep, question, channels (from, to) +// a new article task sweep, question, channels (from, to); on Claude, +// extractorModel (release 28 F2: else the settings') // a new iteration task revise-report | revise-video, iteration, feedback // copy with model the iteration's task, copyOf, model // narration task narrate, iteration, model (a step) diff --git a/umtool/components/articles/ExtractorSelect.tsx b/umtool/components/articles/ExtractorSelect.tsx @@ -0,0 +1,40 @@ +"use client"; + +// THE EXTRACTOR OF ONE SWEEP (release 28 F2): an API sweep reads its batches +// with a cheap Claude model, `settings.generation.models.extractor` unless a +// job names its own (`report-draft {extractorModel}`). Shown beside a sweep's +// model when that model is Claude's; a choice equal to the policy's sends +// nothing (the editor's default is the same model). + +const field = "rounded border border-[var(--color-line)] bg-[var(--color-ink)] px-1.5 py-0.5 text-[12px] text-[var(--color-text)]"; + +/** The body key for a sweep on `model`: `{extractorModel}` when it is not the policy's. */ +export function extractorBody(model: string, extractor: string, policyExtractor: string | undefined): { extractorModel?: string } { + return model.startsWith("claude-") && extractor && extractor !== policyExtractor ? { extractorModel: extractor } : {}; +} + +export default function ExtractorSelect({ + label, + value, + onChange, + models, +}: { + label: string; + value: string; + onChange: (v: string) => void; + /** Claude's models (an API sweep's extractor runs on the API). */ + models: string[]; +}) { + return ( + <label className="flex items-center gap-1"> + <span className="text-[var(--color-dim)]">extractor</span> + <select aria-label={label} className={`${field} font-mono`} value={value} onChange={(e) => onChange(e.target.value)}> + {[...new Set([value, ...models].filter((m) => m && m.startsWith("claude-")))].map((m) => ( + <option key={m} value={m}> + {m} + </option> + ))} + </select> + </label> + ); +} diff --git a/umtool/components/articles/IterationsTab.tsx b/umtool/components/articles/IterationsTab.tsx @@ -6,6 +6,7 @@ import { Button } from "@/components/ui/button"; import { badgeVariants } from "@/components/ui/badge"; import ChainPanel from "@/components/articles/ChainPanel"; import ResearchSlot from "@/components/articles/ResearchSlot"; +import ExtractorSelect, { extractorBody } from "@/components/articles/ExtractorSelect"; import DeletePlan from "@/components/DeletePlan"; import { usd, type Today } from "@/components/articles/PolicyPanel"; import type { ArticleIterations, DraftJobView, IterationRow, PolicyView } from "@/lib/articles/generation"; @@ -200,6 +201,7 @@ function IterationCard({ const g = ctx.policy?.generation; const [copyModel, setCopyModel] = useState(() => ctx.allModels.find((m) => m !== it.model) ?? it.model); const [narrateModel, setNarrateModel] = useState(g?.routes.narrate === "api" ? g.models.api : (g?.models.local ?? "")); + const [copyExtractor, setCopyExtractor] = useState(g?.models.extractor ?? ""); const done = it.status === "done"; const active = it.status === "queued" || it.status === "running"; const runningStep = it.steps.find((s) => s.status === "running" && s.jobId && !s.task.startsWith("chain:")); @@ -307,6 +309,8 @@ function IterationCard({ post={ctx.post} models={ctx.allModels} sweepModel={g?.routes.sweep === "local" ? g.models.local : (g?.models.api ?? "")} + apiModels={ctx.policy?.models.api ?? []} + extractor={g?.models.extractor} /> )} @@ -324,7 +328,21 @@ function IterationCard({ {task && !active && ( <span className="flex items-center gap-1"> <ModelSelect label={`copy ${it.label} on model`} value={copyModel} onChange={setCopyModel} models={ctx.allModels} /> - <Button size="sm" onClick={() => void ctx.post({ task, article: ctx.article, copyOf: it.n, model: copyModel })}> + {task === "sweep" && copyModel.startsWith("claude-") && ( + <ExtractorSelect label={`extractor for the copy of ${it.label}`} value={copyExtractor} onChange={setCopyExtractor} models={ctx.policy?.models.api ?? []} /> + )} + <Button + size="sm" + onClick={() => + void ctx.post({ + task, + article: ctx.article, + copyOf: it.n, + model: copyModel, + ...(task === "sweep" ? extractorBody(copyModel, copyExtractor, g?.models.extractor) : {}), + }) + } + > Copy with model </Button> </span> diff --git a/umtool/components/articles/NewArticleForm.tsx b/umtool/components/articles/NewArticleForm.tsx @@ -4,6 +4,7 @@ import { useCallback, useEffect, useMemo, useState } from "react"; import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; import PolicyPanel, { type Today } from "@/components/articles/PolicyPanel"; +import ExtractorSelect, { extractorBody } from "@/components/articles/ExtractorSelect"; import type { EditorChannel, PolicyView } from "@/lib/articles/generation"; // /articles/new (release 27 S8): a question over channels becomes an article's @@ -117,6 +118,7 @@ export default function NewArticleForm({ initialPolicy, today, taken }: { initia : (policy?.models.local ?? []); const routeModel = begin === "research" ? researchModel : task === "agent" ? policy?.generation.models.api : policy?.generation.models.local; const [model, setModel] = useState(routeModel ?? ""); + const [extractor, setExtractor] = useState(policy?.generation.models.extractor ?? ""); // A cap is a Claude run's: the agent, or research on a Claude model. const capped = begin === "research" ? model.startsWith("claude-") : task === "agent"; const capDefault = policy?.generation.caps.sweep ?? 5; @@ -153,6 +155,7 @@ export default function NewArticleForm({ initialPolicy, today, taken }: { initia question, ...(channels.length ? { channels } : {}), model, + ...(begin === "sweep" ? extractorBody(model, extractor, policy?.generation.models.extractor) : {}), ...(from ? { from } : {}), ...(to ? { to } : {}), ...(capped ? { maxUsd } : {}), @@ -264,6 +267,9 @@ export default function NewArticleForm({ initialPolicy, today, taken }: { initia ))} </select> </label> + {begin === "sweep" && model.startsWith("claude-") && ( + <ExtractorSelect label="extractor for this sweep" value={extractor} onChange={setExtractor} models={policy?.models.api ?? []} /> + )} {capped && ( <label className="flex flex-col gap-1"> <span className="micro">cap $</span> diff --git a/umtool/components/articles/ResearchSlot.tsx b/umtool/components/articles/ResearchSlot.tsx @@ -2,6 +2,7 @@ import { useCallback, useEffect, useState } from "react"; import { Button } from "@/components/ui/button"; +import ExtractorSelect, { extractorBody } from "@/components/articles/ExtractorSelect"; import { badgeVariants } from "@/components/ui/badge"; import type { IterationRow } from "@/lib/articles/generation"; import type { ResearchProposal, ResearchView } from "@/lib/articles/research"; @@ -176,6 +177,8 @@ export default function ResearchSlot({ post, models, sweepModel, + apiModels = [], + extractor, }: { article: string; iteration: IterationRow; @@ -184,12 +187,16 @@ export default function ResearchSlot({ models: string[]; /** The sweep route's model, the continuation's default. */ sweepModel: string; + /** Claude's models, and the policy's extractor: a continuation on Claude may name its own (release 28 F2). */ + apiModels?: string[]; + extractor?: string; }) { const n = iteration.n; const [view, setView] = useState<ResearchView | null>(null); const [error, setError] = useState(""); const [busy, setBusy] = useState(false); const [model, setModel] = useState(sweepModel); + const [extractorModel, setExtractorModel] = useState(extractor ?? ""); const active = iteration.status === "queued" || iteration.status === "running"; const load = useCallback(async () => { @@ -289,7 +296,15 @@ export default function ResearchSlot({ </option> ))} </select> - <Button size="sm" variant="primary" disabled={busy} onClick={() => void post({ task: "sweep", article, iteration: n, model })}> + {model.startsWith("claude-") && ( + <ExtractorSelect label={`continuation extractor for ${iteration.label}`} value={extractorModel} onChange={setExtractorModel} models={apiModels} /> + )} + <Button + size="sm" + variant="primary" + disabled={busy} + onClick={() => void post({ task: "sweep", article, iteration: n, model, ...extractorBody(model, extractorModel, extractor) })} + > Continue into a sweep </Button> </div> diff --git a/umtool/e2e/article-new.spec.ts b/umtool/e2e/article-new.spec.ts @@ -91,14 +91,20 @@ test("a new article: question, channels, the local pipeline — its first iterat await form.getByRole("button", { name: "Start" }).click(); await expect(form.getByRole("alert")).toContainText("at most the policy's $5"); + // The agent's extractor is the policy's unless this sweep names its own (release 28 F2). + await expect(form.getByRole("combobox", { name: "extractor for this sweep" })).toHaveValue("claude-haiku-4-5"); + await form.getByRole("combobox", { name: "extractor for this sweep" }).selectOption("claude-haiku-5-5"); + await form.getByRole("radio", { name: /pipeline/ }).check(); await expect(form.getByRole("combobox", { name: "model" })).toHaveValue("qwen3:8b"); + await expect(form.getByRole("combobox", { name: "extractor for this sweep" }), "the pipeline has no extractor").toHaveCount(0); await form.getByRole("button", { name: "Start" }).click(); await expect(page).toHaveURL(new RegExp(`/articles/${ARTICLE}\\?tab=iterations$`)); const asked = stubAsked("report-draft").at(-1)!; expect(asked).toMatchObject({ task: "sweep", article: ARTICLE, question: "What did the channel say about the vote?", channels: ["sitechan"], model: "qwen3:8b" }); expect(asked).not.toHaveProperty("maxUsd"); + expect(asked).not.toHaveProperty("extractorModel"); const first = page.locator("[data-iteration='1']"); await expect(first).toHaveAttribute("data-kind", "sweep"); diff --git a/umtool/lib/articles/generation.ts b/umtool/lib/articles/generation.ts @@ -216,7 +216,7 @@ export async function cancelDraftJob(id: string): Promise<void> { // The body umtool sends to `report-draft`: the action's own keys, nothing else // (the editor refuses an unknown key; this refuses it first, by name). -const DRAFT_KEYS = ["task", "article", "iteration", "model", "feedback", "question", "channels", "from", "to", "copyOf", "maxUsd", "cards", "force", "autonomy"]; +const DRAFT_KEYS = ["task", "article", "iteration", "model", "extractorModel", "feedback", "question", "channels", "from", "to", "copyOf", "maxUsd", "cards", "force", "autonomy"]; export async function enqueueDraft(body: Record<string, unknown>): Promise<{ jobId: string; iteration: number }> { const out: Record<string, unknown> = {};