Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.
TypeScript agentic-aiaiai-agentsai-videocompilerdslffmpeggenerative-aillmmarkup-languagemonorepoplugin-systemprogramming-languagetext-to-videotypescriptvideovideo-automationvideo-clonevideo-editingvideo-generation
fix(reference-video-tools): one root for reference state, and still pairs compare as stills
rpone4b16264bea80
diff --git a/packages/reference-video-tools/README.md b/packages/reference-video-tools/README.mdindex 7eb6b0a3..cb0ec45a 100644--- a/packages/reference-video-tools/README.md+++ b/packages/reference-video-tools/README.md@@ -42,8 +42,9 @@ tags it registers. `inspect_svml_vocabulary` reads packages you can already nameis deliberately unable to scan a directory, so this is how a caller finds out what vocabulary existsinstead of working from memory.-`prepare_reference` requires a local video path and stores derived media under the project's-gitignored `.hypit/reference-video-tools/` directory. It produces four full-reference observations: `people_and_product`,+`prepare_reference` requires a local video path and stores derived media under the checkout's+gitignored `.hypit/reference-video-tools/` directory, which is where every other command reads it+from whichever directory it is run in. It produces four full-reference observations: `people_and_product`,`voices`, `persistent_systems` — the on-screen text and graphic systems that continue or recur acrossthe whole video, each one's lifetime, and whether its appearance ever changes — and `places`: howmany locations the video was shot in, which camera positions appear in each, which parts of the videodiff --git a/packages/reference-video-tools/src/authoring.ts b/packages/reference-video-tools/src/authoring.tsindex baefedc7..af4591ff 100644--- a/packages/reference-video-tools/src/authoring.ts+++ b/packages/reference-video-tools/src/authoring.ts@@ -1008,9 +1008,16 @@ export async function renderElement(input: RenderElementInput): Promise<Record<sconst placed = built.tracks.find((track) => String(track.outputRef ?? "").endsWith(`::output::${element}.track`)|| String(track.outputRef ?? "").includes(`::output::${element}.`));if (placed === undefined) {+ // An output is named `<id>.<output>`, and --element takes the id on its own. Listing the outputs+ // would hand the reader a name that fails the same way the one they passed did, so the last part+ // is dropped and one element placed twice is named once.+ const ids = [...new Set(built.tracks.map((track) => {+ const output = String(track.outputRef ?? "").split("::output::")[1];+ return output === undefined ? track.name : output.replace(/\.[^.]*$/u, "");+ }))];throw new Error([- `the Source places no element named ${element}. It places:`,- ...built.tracks.map((track) => ` ${String(track.outputRef ?? "").split("::output::")[1] ?? track.name}`),+ `the Source places no element named ${element}. --element takes the bare id, and these are placed:`,+ ...ids.map((id) => ` ${id}`),].join("\n"));}diff --git a/packages/reference-video-tools/src/checks.ts b/packages/reference-video-tools/src/checks.tsindex 62b97491..8a9395c3 100644--- a/packages/reference-video-tools/src/checks.ts+++ b/packages/reference-video-tools/src/checks.ts@@ -14,7 +14,7 @@ import { readStudioSession } from "@hypit/studio/src/session.js";import type { StudioSession } from "@hypit/studio/src/session.js";import { inspectStudioRun } from "@hypit/studio/src/studio-preflight.js";-import { invokedFrom, scriptBody } from "./authoring.js";+import { invokedFrom, referenceRoot, scriptBody } from "./authoring.js";import { assert } from "./media.js";export type PreviewCheckInput = {@@ -217,7 +217,7 @@ type CoverageReport = {*/export async function reconstructionCheck(input: ReconstructionCheckInput,- roots: { readonly workspaceRoot: string; readonly packageRoot: string },+ roots: { readonly packageRoot: string },): Promise<Record<string, unknown>> {const cwd = invokedFrom();const runPath = resolve(cwd, input.run);@@ -454,16 +454,16 @@ export async function reconstructionCheck(// The Source does not name the reference it reconstructs, so a single prepared reference is used// when there is exactly one and named explicitly when there is more than one.- const referenceRoot = join(roots.workspaceRoot, ".hypit", "reference-video-tools");- const prepared = (await readdir(referenceRoot, { withFileTypes: true }).catch(() => []))+ const preparedRoot = referenceRoot();+ const prepared = (await readdir(preparedRoot, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory()).map((entry) => entry.name);let reference = input.reference_id;if (reference === undefined) {- assert(prepared.length > 0, `no prepared reference under ${referenceRoot}; run prepare_reference first`);+ assert(prepared.length > 0, `no prepared reference under ${preparedRoot}; run prepare_reference first`);assert(prepared.length === 1, `${prepared.length} prepared references; pass --reference-id (${prepared.join(", ")})`);reference = prepared[0]!;}- assert(prepared.includes(reference), `reference ${reference} is not prepared under ${referenceRoot}`);+ assert(prepared.includes(reference), `reference ${reference} is not prepared under ${preparedRoot}`);type LoggedComparison = {readonly element?: string;@@ -479,7 +479,7 @@ export async function reconstructionCheck(?? (entry.range?.segment === undefined ? undefined : `segment ${entry.range.segment}`)?? (entry.range?.selection === undefined ? undefined : `selection ${entry.range.selection}`)?? "an unnamed stretch";- const logPath = join(referenceRoot, reference, "comparisons.jsonl");+ const logPath = join(preparedRoot, reference, "comparisons.jsonl");const log = (await readFile(logPath, "utf8").catch(() => "")).split("\n").filter((line) => line.trim().length > 0).flatMap((line) => { try { return [JSON.parse(line) as LoggedComparison]; } catch { return []; } })diff --git a/packages/reference-video-tools/src/cli.ts b/packages/reference-video-tools/src/cli.tsindex 403d5e30..f9943ff3 100644--- a/packages/reference-video-tools/src/cli.ts+++ b/packages/reference-video-tools/src/cli.ts@@ -79,6 +79,11 @@ function usage(): string {"both tiled against the compared stretch's own duration so the grids sample alike. Use --image only","when the reference's own visual observation states the element is completely still.","",+ "Both sides of a --video pair are measured once they are cut to the same stretch, and a pair that is",+ "completely still on both sides is compared as one frame from each: `compared` reads `still` and",+ "`both_sides_still` says why. Both sides have to be still, because a render's base is a flat",+ "placeholder and is therefore still whatever the reference does.",+ "","make-placeholder writes a correctly-sized placeholder for a media slot the Source declares as a","generation and a Build has not filled. It is deterministic and Provider-free: the comparison loop","uses its output to mock an empty slot, and the observer is told the slot is a placeholder so it is",diff --git a/packages/reference-video-tools/src/media.ts b/packages/reference-video-tools/src/media.tsindex 69d82ce1..c0237fd4 100644--- a/packages/reference-video-tools/src/media.ts+++ b/packages/reference-video-tools/src/media.ts@@ -51,6 +51,31 @@ export async function probe(path: string): Promise<{ duration: number; width: nu};}+/**+ * Whether a clip holds one picture for the whole of its length.+ *+ * `freezedetect` reports each stretch it saw no change across as a start, and as an end where the+ * picture changes again. One stretch that opens on the first frame and never closes is the whole+ * clip; a stretch that opens later, or one that closes before the clip does, means something moved.+ * The times are measured to a frame, so an end landing on the last frame is the clip ending.+ */+export async function completelyStill(path: string): Promise<boolean> {+ const { duration, frameRate } = await probe(path);+ // The filter announces a stretch only once it has run for `d`, and announces it at the second it+ // began rather than the second it was noticed, so `d` has only to be shorter than the clip.+ // `metadata=print` writes what it found to stdout, which is where the result is read from.+ const printed = await command("ffmpeg", [+ "-hide_banner", "-loglevel", "error", "-i", path, "-an",+ "-vf", "freezedetect=n=-60dB:d=0.1,metadata=mode=print:file=-", "-f", "null", "-",+ ], 300_000);+ const text = printed.toString("utf8");+ const times = (name: string): readonly number[] =>+ [...text.matchAll(new RegExp(String.raw`freezedetect\.freeze_${name}=([0-9.]+)`, "gu"))].map((match) => Number(match[1]));+ const tolerance = frameRate > 0 ? 1 / frameRate : 0.05;+ const starts = times("start");+ return starts.length === 1 && starts[0]! <= tolerance && times("end").every((at) => at >= duration - tolerance);+}+function distance(left: Uint8Array, right: Uint8Array): number {let total = 0;for (let index = 0; index < left.length; index += 1) total += Math.abs(left[index]! - right[index]!);diff --git a/packages/reference-video-tools/src/tools.ts b/packages/reference-video-tools/src/tools.tsindex c361b566..1e35a2dd 100644--- a/packages/reference-video-tools/src/tools.ts+++ b/packages/reference-video-tools/src/tools.ts@@ -10,13 +10,14 @@ import { markupSurfaceHostFacetAbi } from "@hypit/markup";import type { RegisteredSurface, SurfaceVocabulary } from "@hypit/markup";import { exactModelHostAbi } from "@hypit/model-kit";-import { authorSource, invokedFrom, referenceWords, renderElement, renderPreviews, spokenRange, standInSidecarPath } from "./authoring.js";+import { authorSource, invokedFrom, referenceRoot, referenceWords, renderElement, renderPreviews, spokenRange, standInSidecarPath } from "./authoring.js";import type { RenderElementInput, RenderPreviewsInput, SpokenRange, StandInFocus, StandInSidecar } from "./authoring.js";import { writePlaceholder } from "./placeholder.js";import { previewCheck, reconstructionCheck } from "./checks.js";import type { PreviewCheckInput, ReconstructionCheckInput } from "./checks.js";import {assert,+ completelyStill,cutClip,cutFrame,ensureDir,@@ -114,7 +115,6 @@ export type ReferenceVideoTools = {};type ToolOptions = {- readonly workspaceRoot?: string;readonly packageRoot?: string;readonly model?: string;readonly concurrency?: number;@@ -136,8 +136,15 @@ function positiveEnv(name: string): number | undefined {return value;}-function stateRoot(workspaceRoot: string, reference: string): string {- return join(workspaceRoot, ".hypit", "reference-video-tools", reference);+/**+ * Where one reference's prepared state lives.+ *+ * `referenceRoot` finds the Hypit tree from this module's own location, so the directory+ * `prepare_reference` writes to is the directory every other command reads from, whichever directory+ * the command was run in.+ */+function stateRoot(reference: string): string {+ return join(referenceRoot(), reference);}/**@@ -430,6 +437,9 @@ type RangeCut = {readonly rendered: string;readonly referenceTile: string;readonly renderedTile: string;+ /** Where each side's single frame goes, for a stretch that turns out to hold one picture. */+ readonly referenceStill: string;+ readonly renderedStill: string;/** How long the cut runs, which is the duration both frame grids are sampled against. */readonly seconds: number;readonly referenceSeconds: number;@@ -547,6 +557,8 @@ async function cutWordRange(rendered,referenceTile: join(dir, `${label}-reference-tile.jpg`),renderedTile: join(dir, `${label}-rendered-tile.jpg`),+ referenceStill: join(dir, `${label}-reference-still.jpg`),+ renderedStill: join(dir, `${label}-rendered-still.jpg`),seconds,referenceSeconds: round(referenceSeconds),renderedSeconds: round(renderedSeconds),@@ -580,8 +592,7 @@ function publicPrepare(state: ReferenceState): PrepareResult {}export function createReferenceVideoTools(options: ToolOptions = {}): ReferenceVideoTools {- const workspaceRoot = resolve(options.workspaceRoot ?? process.cwd());- const packageRoot = resolve(options.packageRoot ?? workspaceRoot);+ const packageRoot = resolve(options.packageRoot ?? process.cwd());const model = options.model ?? process.env.GEMINI_MODEL?.trim() ?? "gemini-3.1-pro-preview";// Pacing is deployment policy, not author intent: it depends on the quota behind the credentials,// which the calling agent has no way to know. It is settable here and through the environment, and@@ -596,9 +607,8 @@ export function createReferenceVideoTools(options: ToolOptions = {}): ReferenceVconst generator = async (): Promise<GenerateText> => generatorPromise ??= options.generate === undefined ? defaultGenerate(model) : Promise.resolve(options.generate);const loadState = async (reference: string): Promise<ReferenceState> => {- const path = join(stateRoot(workspaceRoot, reference), "state.json");- const state = await readJson<ReferenceState>(path);- assert(state !== undefined, `reference ${reference} was not prepared in ${workspaceRoot}`);+ const state = await readJson<ReferenceState>(join(stateRoot(reference), "state.json"));+ assert(state !== undefined, `reference ${reference} is not prepared under ${referenceRoot()}; run prepare_reference first`);return state;};@@ -683,7 +693,7 @@ export function createReferenceVideoTools(options: ToolOptions = {}): ReferenceVconst file = await stat(videoPath).catch(() => undefined);assert(file?.isFile(), `video_path is not a file: ${videoPath}`);const reference = await referenceId(videoPath);- const root = stateRoot(workspaceRoot, reference);+ const root = stateRoot(reference);const statePath = join(root, "state.json");let existing = await readJson<ReferenceState>(statePath);const redoMedia = input.redo === "media" || input.redo === "all";@@ -951,7 +961,7 @@ export function createReferenceVideoTools(options: ToolOptions = {}): ReferenceVasync compare_reconstruction(input): Promise<Record<string, unknown>> {const state = await loadState(input.reference_id);- const root = stateRoot(workspaceRoot, state.reference_id);+ const root = stateRoot(state.reference_id);const named = [input.shot_id, input.segment, input.selection].filter((value) => value !== undefined);assert(named.length === 1, "name exactly one of shot_id, segment and selection");const supplied = [input.image_path, input.video_path].filter((value) => value !== undefined);@@ -993,12 +1003,32 @@ export function createReferenceVideoTools(options: ToolOptions = {}): ReferenceVstretchSeconds = cut.seconds;}+ // A stretch that holds one picture on both sides has one picture to compare, and a clip or a+ // grid of the same frame repeated says nothing the frame alone does not.+ //+ // Both sides are measured, and both have to be still. The render's base is a flat placeholder+ // and is therefore still whatever it covers, so a render measured on its own would carry every+ // pair down to a frame — including the pairs whose reference moves, where the difference+ // between a mock base and a real one would be doing the deciding.+ let bothStill = false;+ if (clip) {+ bothStill = await completelyStill(referenceMedia) && await completelyStill(renderedMedia);+ if (bothStill) {+ referenceMedia = shot === undefined+ ? await cutFrame(cut!.reference, stretchSeconds / 2, cut!.referenceStill)+ : shot.representative_frame_ref;+ renderedMedia = await cutFrame(renderedMedia, stretchSeconds / 2,+ shot === undefined ? cut!.renderedStill : join(root, "shots", `${shot.shot_id}-reconstruction-still.jpg`));+ }+ }+ const asClip = clip && !bothStill;+// A clip comparison reads the whole stretch on both sides. The observer that reads video is// given the two clips; the observer that reads pictures is given two frame tiles, which is the// same degradation `prepare_reference` already applies to a shot. Tiling both against the same// duration makes `tileFrames` choose the same frame count and layout for each, so the two grids// are read side by side rather than as different samplings.- if (clip && observer === "agent") {+ if (asClip && observer === "agent") {if (shot !== undefined) {assert(shot.frames_tile_ref !== null,`shot ${shot.shot_id} has no frame tile; re-prepare the reference with --redo all --observer agent`);@@ -1012,16 +1042,16 @@ export function createReferenceVideoTools(options: ToolOptions = {}): ReferenceV}}- const unit = clip && observer !== "agent" ? "video clips" : "still images";+ const unit = asClip && observer !== "agent" ? "video clips" : "still images";// TILE_PREAMBLE already tells the agent observer how to read a grid, so this adds only what is// new about a pair of them: both are stretches, and they are compared as sequences.- const reading = clip && observer === "agent"+ const reading = asClip && observer === "agent"? "\n\nBoth are grids, so compare them as sequences rather than as single moments.": "";const differences = await ask("comparison", {media: [referenceMedia, renderedMedia],instruction: `You compare two supplied ${unit} and describe their visible differences in natural language only. You are not told how either was made. Do not write code, markup, SVML, component names, or production advice.`,- prompt: `Two ${unit} are supplied in order: one, then two.${reading}${cut?.incomplete ?? ""}${scope.length === 0 ? "" : `\n\nLimit the comparison to this: ${scope}`}\n\nDescribe every visible difference between them: layout and arrangement, the position and size of each element, cropping and margins, colour, typeface, weight, letter and line spacing, alignment, outline or stroke, shadow, glow, borders and corner treatment, and anything present in one and absent from the other.${clip ? " Also describe differences in what changes over the stretch: what appears, what leaves, in what order, and how anything moves." : ""} State plainly which differences are large enough to read as a different design and which are minor. If they are visually equivalent, say exactly that.\n\nDo not speculate about how either was produced, which one is a source, or which one is a copy. Return natural language only.`,+ prompt: `Two ${unit} are supplied in order: one, then two.${reading}${asClip ? cut?.incomplete ?? "" : ""}${scope.length === 0 ? "" : `\n\nLimit the comparison to this: ${scope}`}\n\nDescribe every visible difference between them: layout and arrangement, the position and size of each element, cropping and margins, colour, typeface, weight, letter and line spacing, alignment, outline or stroke, shadow, glow, borders and corner treatment, and anything present in one and absent from the other.${asClip ? " Also describe differences in what changes over the stretch: what appears, what leaves, in what order, and how anything moves." : ""} State plainly which differences are large enough to read as a different design and which are minor. If they are visually equivalent, say exactly that.\n\nDo not speculate about how either was produced, which one is a source, or which one is a copy. Return natural language only.`,});// The answer is deliberately not cached — every iteration is a fresh comparison. What is// recorded is that a comparison happened, so a gate can tell an element that was looked at@@ -1037,7 +1067,7 @@ export function createReferenceVideoTools(options: ToolOptions = {}): ReferenceVobserver,status: differences.status,scoped: scope.length > 0,- clip,+ clip: asClip,...(standIn === undefined ? {} : { stand_in: standIn }),});return {@@ -1047,9 +1077,10 @@ export function createReferenceVideoTools(options: ToolOptions = {}): ReferenceV...(cut === undefined ? {} : {range: cut.record,...(clip ? { reference_seconds: cut.referenceSeconds, rendered_seconds: cut.renderedSeconds } : {}),- ...(cut.incomplete.length === 0 ? {} : { incomplete_ends: cut.incomplete.trim() }),+ ...(asClip && cut.incomplete.length > 0 ? { incomplete_ends: cut.incomplete.trim() } : {}),}),- compared: clip ? "clip" : "still",+ compared: asClip ? "clip" : "still",+ ...(bothStill ? { both_sides_still: true } : {}),reference_ref: referenceMedia,rendered_ref: renderedMedia,...(standIn === undefined ? {} : { stand_in: standIn }),@@ -1069,7 +1100,7 @@ export function createReferenceVideoTools(options: ToolOptions = {}): ReferenceVassert(key.length > 0, "key is required");const text = input.text.trim();assert(text.length > 0, "text is required; an observation that saw nothing says so in words");- const root = stateRoot(workspaceRoot, input.reference_id);+ const root = stateRoot(input.reference_id);if (WHOLE_REFERENCE_KEYS.includes(key as typeof WHOLE_REFERENCE_KEYS[number])) {const field = key as typeof WHOLE_REFERENCE_KEYS[number];await writeJson(join(root, "state.json"), { ...state, [field]: observation("complete", text) });@@ -1112,7 +1143,7 @@ export function createReferenceVideoTools(options: ToolOptions = {}): ReferenceV},async reconstruction_check(input): Promise<Record<string, unknown>> {- return await reconstructionCheck(input, { workspaceRoot, packageRoot });+ return await reconstructionCheck(input, { packageRoot });},};}diff --git a/packages/reference-video-tools/test/tools.test.ts b/packages/reference-video-tools/test/tools.test.tsindex a120adbd..c64e28f5 100644--- a/packages/reference-video-tools/test/tools.test.ts+++ b/packages/reference-video-tools/test/tools.test.ts@@ -14,6 +14,9 @@ const REFERENCE = "ref-fixture";async function workspace(shotCount: number): Promise<{ readonly root: string; readonly stateRoot: string }> {const root = await mkdtemp(join(tmpdir(), "reference-video-tools-"));+ // Prepared state is read from the Hypit tree, which HYPIT_REPOSITORY names. A fixture puts the tree+ // in a directory of its own so the state it writes is the state the tools read.+ process.env["HYPIT_REPOSITORY"] = root;const stateRoot = join(root, ".hypit", "reference-video-tools", REFERENCE);const shots = join(stateRoot, "shots");await mkdir(shots, { recursive: true });@@ -70,8 +73,8 @@ function recorder(calls: Call[], answer = "observed"): GenerateText {};}-function tools(root: string, calls: Call[], answer?: string) {- return createReferenceVideoTools({ workspaceRoot: root, concurrency: 4, launchGapMs: 0, retryDelayMs: 0, generate: recorder(calls, answer) });+function tools(calls: Call[], answer?: string) {+ return createReferenceVideoTools({ concurrency: 4, launchGapMs: 0, retryDelayMs: 0, generate: recorder(calls, answer) });}test("installed packages can be listed, and one that will not load is reported rather than hidden", async () => {@@ -97,9 +100,9 @@ test("installed packages can be listed, and one that will not load is reported r});test("observation covers picture, drawn type and sound for every shot and caches every key", async () => {- const { root, stateRoot } = await workspace(2);+ const { stateRoot } = await workspace(2);const calls: Call[] = [];- const result = await tools(root, calls).observe_reference({ reference_id: REFERENCE });+ const result = await tools(calls).observe_reference({ reference_id: REFERENCE });const cache = JSON.parse(await readFile(join(stateRoot, "observations.json"), "utf8")) as Record<string, unknown>;assert.deepEqual(Object.keys(cache).sort(), [@@ -129,28 +132,28 @@ test("observation covers picture, drawn type and sound for every shot and caches});test("a second observation reuses the cache and only an explicit reobserve runs the model again", async () => {- const { root } = await workspace(2);+ await workspace(2);const first: Call[] = [];- await tools(root, first).observe_reference({ reference_id: REFERENCE });+ await tools(first).observe_reference({ reference_id: REFERENCE });assert.equal(first.length, 7, "two shots: picture, type and sound each, plus one shared boundary");const second: Call[] = [];- await tools(root, second).observe_reference({ reference_id: REFERENCE });+ await tools(second).observe_reference({ reference_id: REFERENCE });assert.deepEqual(second, []);const selected: Call[] = [];- await tools(root, selected).observe_reference({ reference_id: REFERENCE, shot_ids: ["shot-002"] });+ await tools(selected).observe_reference({ reference_id: REFERENCE, shot_ids: ["shot-002"] });assert.deepEqual(selected, [], "naming a shot must not silently re-run its cached observations");const forced: Call[] = [];- await tools(root, forced).observe_reference({ reference_id: REFERENCE, shot_ids: ["shot-002"], reobserve: true });+ await tools(forced).observe_reference({ reference_id: REFERENCE, shot_ids: ["shot-002"], reobserve: true });assert.equal(forced.length, 4, "reobserve reruns the selected shot's picture, type and sound plus its one boundary, and nothing else");});test("a narrow question costs one call, answers from the named shots and never re-runs observations", async () => {- const { root, stateRoot } = await workspace(4);+ const { stateRoot } = await workspace(4);const calls: Call[] = [];- const result = await tools(root, calls, "the caption sits above the lower edge")+ const result = await tools(calls, "the caption sits above the lower edge").observe_reference({ reference_id: REFERENCE, shot_ids: ["shot-003"], question: "How thick is the caption outline?" });assert.equal(calls.length, 1);@@ -161,10 +164,10 @@ test("a narrow question costs one call, answers from the named shots and never rassert.equal(await readFile(join(stateRoot, "observations.json"), "utf8"), "{}\n");await assert.rejects(- tools(root, []).observe_reference({ reference_id: REFERENCE, question: "which shot?" }),+ tools([]).observe_reference({ reference_id: REFERENCE, question: "which shot?" }),/question requires at least one shot id/u);await assert.rejects(- tools(root, []).observe_reference({ reference_id: REFERENCE, shot_ids: ["shot-001", "shot-002", "shot-003", "shot-004"], question: "which shot?" }),+ tools([]).observe_reference({ reference_id: REFERENCE, shot_ids: ["shot-001", "shot-002", "shot-003", "shot-004"], question: "which shot?" }),/at most three shots/u);});@@ -173,7 +176,7 @@ test("reconstruction comparison sends an unlabelled pair and accepts rendered PNconst rendered = join(root, "rendered.png");await writeFile(rendered, "rendered-bytes", "utf8");const calls: Call[] = [];- const result = await tools(root, calls, "the list starts lower in one image")+ const result = await tools(calls, "the list starts lower in one image").compare_reconstruction({ reference_id: REFERENCE, shot_id: "shot-001", image_path: rendered, question: "only the full-screen list area" });assert.equal(calls.length, 1);@@ -186,7 +189,7 @@ test("reconstruction comparison sends an unlabelled pair and accepts rendered PNassert.deepEqual(result["differences"], { status: "complete", text: "the list starts lower in one image" });await assert.rejects(- tools(root, []).compare_reconstruction({ reference_id: REFERENCE, shot_id: "shot-009", image_path: rendered }),+ tools([]).compare_reconstruction({ reference_id: REFERENCE, shot_id: "shot-009", image_path: rendered }),/shot shot-009 does not exist/u);});@@ -195,15 +198,14 @@ test("an unsupported media extension fails loudly instead of being sent as opaquconst rendered = join(root, "rendered.tiff");await writeFile(rendered, "rendered-bytes", "utf8");await assert.rejects(- tools(root, []).compare_reconstruction({ reference_id: REFERENCE, shot_id: "shot-001", image_path: rendered }),+ tools([]).compare_reconstruction({ reference_id: REFERENCE, shot_id: "shot-001", image_path: rendered }),/unsupported media extension/u);});test("a rejected request fails once instead of being retried until the loop gives up", async () => {- const { root } = await workspace(1);+ await workspace(1);let attempts = 0;const rejecting = createReferenceVideoTools({- workspaceRoot: root,concurrency: 4,launchGapMs: 0,retryDelayMs: 0,@@ -218,9 +220,8 @@ test("a rejected request fails once instead of being retried until the loop give});test("a failed observation is reported as unresolved instead of an empty list", async () => {- const { root } = await workspace(1);+ await workspace(1);const failing = createReferenceVideoTools({- workspaceRoot: root,concurrency: 4,launchGapMs: 0,retryDelayMs: 0,