@womp/spark-agent 17.7.3 → 17.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +41 -0
- package/dist/bench-camera.d.ts +36 -2
- package/dist/bench-camera.js +18 -3
- package/dist/camera-fit.d.ts +47 -0
- package/dist/camera-fit.js +70 -0
- package/dist/capabilities/scene.d.ts +99 -1
- package/dist/capabilities/scene.js +125 -15
- package/dist/capabilities.d.ts +2 -2
- package/dist/capabilities.js +1 -1
- package/dist/generated/scene-declarations.d.ts +1 -1
- package/dist/generated/scene-declarations.js +1 -1
- package/dist/kakapo-mux-cli.js +41 -0
- package/dist/kakapo-mux.d.ts +56 -0
- package/dist/kakapo-mux.js +264 -0
- package/dist/materials/inspection.d.ts +1 -1
- package/dist/materials/inspection.js +2 -2
- package/dist/public-capabilities.d.ts +1 -1
- package/dist/quality-bench-cli.d.ts +2 -0
- package/dist/quality-bench-cli.js +156 -0
- package/dist/quality-bench-sheet.d.ts +13 -0
- package/dist/quality-bench-sheet.js +120 -0
- package/dist/quality-bench.d.ts +293 -0
- package/dist/quality-bench.js +1120 -0
- package/dist/sdk-scene-screenshot.d.ts +5 -2
- package/dist/sdk-scene-screenshot.js +32 -10
- package/dist/server/sqlite-store.js +2 -1
- package/package.json +8 -4
- package/dist/simple-bench-cli.js +0 -64
- package/dist/simple-bench-prompts.d.ts +0 -5
- package/dist/simple-bench-prompts.js +0 -12
- package/dist/simple-bench.d.ts +0 -15
- package/dist/simple-bench.js +0 -163
- /package/dist/{simple-bench-cli.d.ts → kakapo-mux-cli.d.ts} +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, statSync } from "node:fs";
|
|
3
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
4
|
+
import { loadEnvFile } from "node:process";
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { SPARK_MODELS } from "./models.js";
|
|
8
|
+
import { compareQualityRuns, generateBenchSheet, listQualityCases, loadQualityCase, pairwiseReportMarkdown, reportMarkdown, runQualityBench, scoreExistingBenchRun } from "./quality-bench.js";
|
|
9
|
+
async function main() {
|
|
10
|
+
const { values } = parseArgs({ options: {
|
|
11
|
+
cases: { type: "string" }, only: { type: "string" }, split: { type: "string" },
|
|
12
|
+
repeat: { type: "string", default: "2" }, parallel: { type: "string", default: "32" },
|
|
13
|
+
model: { type: "string", default: "gpt-6.2-astra" }, reasoning: { type: "string", default: "xhigh" },
|
|
14
|
+
judge: { type: "boolean", default: false },
|
|
15
|
+
"kakapo-url": { type: "string" }, output: { type: "string" }, baseline: { type: "string" },
|
|
16
|
+
compare: { type: "string" }, ab: { type: "string" }, "score-only": { type: "string" }, sheet: { type: "string" },
|
|
17
|
+
focus: { type: "string" }, "view-filter": { type: "string" },
|
|
18
|
+
"timeout-minutes": { type: "string", default: "40" },
|
|
19
|
+
help: { type: "boolean" },
|
|
20
|
+
} });
|
|
21
|
+
const all = await listQualityCases();
|
|
22
|
+
if (values.help) {
|
|
23
|
+
console.log(`quality-bench [options]
|
|
24
|
+
|
|
25
|
+
Builds each case in parallel on one Kakapo through an in-process kakapo-mux, renders standardized same-camera views
|
|
26
|
+
(fixed 3/4, 4 sides, 5-view turntable, 2x2 grid, close-ups), counts deterministic SDF structure, and outputs one visual
|
|
27
|
+
comparison sheet per repeat (sheet-run-<n>.png) with per-phase timings and results.csv. AI judging is opt-in via --judge.
|
|
28
|
+
WARNING: makes paid Spark model calls (and AI judge calls when --judge or --ab is passed) and replaces the Kakapo scene.
|
|
29
|
+
|
|
30
|
+
--only <a,b> Run only these case IDs (alias for --cases); default: all (${all.join(", ")})
|
|
31
|
+
--cases <a,b> Same as --only
|
|
32
|
+
--split <tune|holdout> Filter cases by split in case.json (ignored if --only/--cases is set)
|
|
33
|
+
--repeat <n> Builds per case; default 2
|
|
34
|
+
--parallel <n> Builds at once; default 32
|
|
35
|
+
--model <id> Default: gpt-6.2-astra. Models: ${SPARK_MODELS.map((model) => model.id).join(", ")}
|
|
36
|
+
--reasoning <effort> Default: xhigh
|
|
37
|
+
--judge Enable AI vision judges (likeness + close-up checks); default: false
|
|
38
|
+
--kakapo-url <url> Default: KAKAPO_URL from .env, or ws://127.0.0.1:5502
|
|
39
|
+
--output <directory> New directory only; default: .spark/quality/<timestamp>
|
|
40
|
+
--baseline <dir|report> Baseline directory (for --ab) or report.json (for metric diffs)
|
|
41
|
+
--sheet <run-dir> Generate full-res sheet-run-<n>.png files for an existing run directory
|
|
42
|
+
--compare <report.json> Only rewrite report.md of --compare against --baseline; no builds
|
|
43
|
+
--ab <candidate-dir> Blinded order-swapped pairwise judge against --baseline directory; no builds
|
|
44
|
+
--score-only <run-dir> Re-render/score saved scene.json files in <run-dir> (recover after Kakapo crash)
|
|
45
|
+
--timeout-minutes <n> Per-build timeout; default 40`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (values.sheet) {
|
|
49
|
+
const sheets = await generateBenchSheet(path.resolve(values.sheet));
|
|
50
|
+
console.log(sheets.length ? sheets.map((s) => `Sheet: ${s}`).join("\n") : "Sheets: none");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (values["score-only"]) {
|
|
54
|
+
if (existsSync(".env"))
|
|
55
|
+
loadEnvFile();
|
|
56
|
+
for (const k of ["ANTHROPIC_API_KEY", "GEMINI_API_KEY"])
|
|
57
|
+
if (!process.env[k]?.trim())
|
|
58
|
+
throw new Error(`${k} is required in the environment or .env.`);
|
|
59
|
+
const baseline = values.baseline ? JSON.parse(await readFile(values.baseline, "utf8")) : undefined;
|
|
60
|
+
const outDir = path.resolve(values["score-only"]);
|
|
61
|
+
await scoreExistingBenchRun(outDir, {
|
|
62
|
+
kakapoUrl: values["kakapo-url"] ?? process.env.KAKAPO_URL ?? "ws://127.0.0.1:5502",
|
|
63
|
+
baseline,
|
|
64
|
+
});
|
|
65
|
+
console.log(await readFile(path.join(outDir, "report.md"), "utf8"));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (values.ab) {
|
|
69
|
+
if (!values.baseline)
|
|
70
|
+
throw new Error("--ab needs --baseline <baseline-dir>.");
|
|
71
|
+
if (existsSync(".env"))
|
|
72
|
+
loadEnvFile();
|
|
73
|
+
if (!process.env.GEMINI_API_KEY?.trim())
|
|
74
|
+
throw new Error("GEMINI_API_KEY is required in the environment or .env.");
|
|
75
|
+
const report = await compareQualityRuns(path.resolve(values.baseline), path.resolve(values.ab), {
|
|
76
|
+
focus: values.focus,
|
|
77
|
+
viewFilter: values["view-filter"],
|
|
78
|
+
});
|
|
79
|
+
const o = report.overall;
|
|
80
|
+
const decisive = o.candidateWins + o.baselineWins;
|
|
81
|
+
console.log(pairwiseReportMarkdown(report));
|
|
82
|
+
console.log(`[autoresearch-begin]
|
|
83
|
+
candidate_win_rate: ${decisive ? (o.candidateWins / decisive).toFixed(3) : "0.500"}
|
|
84
|
+
candidate_wins: ${o.candidateWins}
|
|
85
|
+
baseline_wins: ${o.baselineWins}
|
|
86
|
+
ties: ${o.ties}
|
|
87
|
+
pairs: ${o.pairs}
|
|
88
|
+
order_consistency: ${o.pairs ? (o.consistent / o.pairs).toFixed(3) : "0.000"}
|
|
89
|
+
[autoresearch-end]`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (values.compare) {
|
|
93
|
+
if (!values.baseline)
|
|
94
|
+
throw new Error("--compare needs --baseline.");
|
|
95
|
+
const report = JSON.parse(await readFile(values.compare, "utf8"));
|
|
96
|
+
const baseline = JSON.parse(await readFile(values.baseline, "utf8"));
|
|
97
|
+
const out = path.join(path.dirname(values.compare), "report.md");
|
|
98
|
+
await writeFile(out, reportMarkdown(report, baseline));
|
|
99
|
+
console.log(out);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const model = SPARK_MODELS.find((item) => item.id === values.model);
|
|
103
|
+
if (!model)
|
|
104
|
+
throw new Error("Select a supported model using --model. See --help.");
|
|
105
|
+
const reasoning = values.reasoning;
|
|
106
|
+
if (!model.reasoningEfforts.includes(reasoning))
|
|
107
|
+
throw new Error("Unsupported reasoning effort for this model.");
|
|
108
|
+
const requestedCases = values.only ?? values.cases;
|
|
109
|
+
let cases = requestedCases ? requestedCases.split(",").map((c) => c.trim()).filter(Boolean) : all;
|
|
110
|
+
if (!requestedCases && values.split && values.split !== "all") {
|
|
111
|
+
const loaded = await Promise.all(all.map(loadQualityCase));
|
|
112
|
+
cases = loaded.filter((c) => c.split === values.split).map((c) => c.id);
|
|
113
|
+
if (!cases.length)
|
|
114
|
+
throw new Error(`No cases in split "${values.split}".`);
|
|
115
|
+
}
|
|
116
|
+
for (const c of cases)
|
|
117
|
+
if (!all.includes(c))
|
|
118
|
+
throw new Error(`Unknown case ${c}; cases: ${all.join(", ")}.`);
|
|
119
|
+
const repeat = Number(values.repeat), parallel = Number(values.parallel);
|
|
120
|
+
if (!Number.isSafeInteger(repeat) || repeat < 1 || !Number.isSafeInteger(parallel) || parallel < 1)
|
|
121
|
+
throw new Error("--repeat and --parallel take positive integers.");
|
|
122
|
+
const timeoutMs = Number(values["timeout-minutes"]) * 60_000;
|
|
123
|
+
if (existsSync(".env"))
|
|
124
|
+
loadEnvFile();
|
|
125
|
+
const key = { openai: "OPENAI_API_KEY", anthropic: "ANTHROPIC_API_KEY", google: "GEMINI_API_KEY" }[model.provider];
|
|
126
|
+
const requiredKeys = new Set([key, ...(values.judge ? ["ANTHROPIC_API_KEY", "GEMINI_API_KEY"] : [])]);
|
|
127
|
+
for (const k of requiredKeys)
|
|
128
|
+
if (!process.env[k]?.trim())
|
|
129
|
+
throw new Error(`${k} is required in the environment or .env.`);
|
|
130
|
+
let baselineReport;
|
|
131
|
+
if (values.baseline) {
|
|
132
|
+
const resolvedBase = path.resolve(values.baseline);
|
|
133
|
+
const rp = existsSync(resolvedBase) && statSync(resolvedBase).isDirectory() ? path.join(resolvedBase, "report.json") : resolvedBase;
|
|
134
|
+
if (existsSync(rp))
|
|
135
|
+
baselineReport = JSON.parse(await readFile(rp, "utf8"));
|
|
136
|
+
}
|
|
137
|
+
const controller = new AbortController();
|
|
138
|
+
const stop = () => controller.abort(new Error("Benchmark interrupted."));
|
|
139
|
+
process.once("SIGINT", stop);
|
|
140
|
+
process.once("SIGTERM", stop);
|
|
141
|
+
const output = path.resolve(values.output ?? `.spark/quality/${new Date().toISOString().replaceAll(":", "-")}`);
|
|
142
|
+
console.log(`Results: ${output}`);
|
|
143
|
+
const report = await runQualityBench({
|
|
144
|
+
cases, repeat, parallel, judge: values.judge,
|
|
145
|
+
settings: { modelId: model.id, reasoningEffort: reasoning },
|
|
146
|
+
kakapoUrl: values["kakapo-url"] ?? process.env.KAKAPO_URL ?? "ws://127.0.0.1:5502",
|
|
147
|
+
output, timeoutMs, signal: controller.signal,
|
|
148
|
+
});
|
|
149
|
+
if (baselineReport)
|
|
150
|
+
await writeFile(path.join(output, "report.md"), reportMarkdown(report, baselineReport));
|
|
151
|
+
console.log(await readFile(path.join(output, "report.md"), "utf8"));
|
|
152
|
+
for (let i = 1; i <= repeat; i++)
|
|
153
|
+
console.log(`Visual sheet: ${path.join(output, `sheet-run-${i}.png`)}`);
|
|
154
|
+
process.exit(0);
|
|
155
|
+
}
|
|
156
|
+
main().catch((error) => { console.error(error instanceof Error ? error.message : String(error)); process.exitCode = 1; });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { QualityRunResult } from "./quality-bench.js";
|
|
2
|
+
export interface SheetRow {
|
|
3
|
+
caseId: string;
|
|
4
|
+
run: number;
|
|
5
|
+
runDir: string;
|
|
6
|
+
refFile: string;
|
|
7
|
+
result: QualityRunResult;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Generates one full-resolution lossless PNG sheet per repeat (`sheet-run-<n>.png`) with zero padding between tiles:
|
|
11
|
+
* [Reference | Fixed 3/4 | Front | Back | Top] per case row, plus a header bar with timings, cost, structure, and optional judge scores.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildMasterSheet(outputDir: string, rows: SheetRow[]): Promise<string[]>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// Full-resolution, zero-padding lossless PNG image sheets (`sheet-run-<n>.png`) for quality-bench runs.
|
|
2
|
+
// One sheet is exported per repeat/run; works with or without AI judging (--judge).
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
const esc = (s) => String(s ?? "")
|
|
6
|
+
.replaceAll("&", "&")
|
|
7
|
+
.replaceAll("<", "<")
|
|
8
|
+
.replaceAll(">", ">")
|
|
9
|
+
.replaceAll('"', """);
|
|
10
|
+
function fmtSec(ms) {
|
|
11
|
+
if (typeof ms !== "number" || !Number.isFinite(ms))
|
|
12
|
+
return "–";
|
|
13
|
+
return ms >= 10_000 ? `${Math.round(ms / 1000)}s` : `${(ms / 1000).toFixed(1)}s`;
|
|
14
|
+
}
|
|
15
|
+
function fmtNum(v, digits = 2) {
|
|
16
|
+
return typeof v === "number" && Number.isFinite(v) ? v.toFixed(digits) : "–";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generates one full-resolution lossless PNG sheet per repeat (`sheet-run-<n>.png`) with zero padding between tiles:
|
|
20
|
+
* [Reference | Fixed 3/4 | Front | Back | Top] per case row, plus a header bar with timings, cost, structure, and optional judge scores.
|
|
21
|
+
*/
|
|
22
|
+
export async function buildMasterSheet(outputDir, rows) {
|
|
23
|
+
if (!rows.length)
|
|
24
|
+
return [];
|
|
25
|
+
const byRun = new Map();
|
|
26
|
+
for (const row of rows) {
|
|
27
|
+
const list = byRun.get(row.run) ?? [];
|
|
28
|
+
list.push(row);
|
|
29
|
+
byRun.set(row.run, list);
|
|
30
|
+
}
|
|
31
|
+
const outFiles = [];
|
|
32
|
+
for (const run of [...byRun.keys()].sort((a, b) => a - b)) {
|
|
33
|
+
const runRows = byRun.get(run).slice().sort((a, b) => a.caseId.localeCompare(b.caseId));
|
|
34
|
+
const outFile = path.join(outputDir, `sheet-run-${run}.png`);
|
|
35
|
+
await renderSheetFile(outFile, runRows);
|
|
36
|
+
outFiles.push(outFile);
|
|
37
|
+
}
|
|
38
|
+
return outFiles;
|
|
39
|
+
}
|
|
40
|
+
async function renderSheetFile(outFile, rows) {
|
|
41
|
+
const { default: sharp } = await import("sharp");
|
|
42
|
+
let tileW = 1280, tileH = 720;
|
|
43
|
+
for (const row of rows) {
|
|
44
|
+
const probe = [
|
|
45
|
+
path.join(row.runDir, "fixed-3q.jpg"),
|
|
46
|
+
path.join(row.runDir, "turntable-front.jpg"),
|
|
47
|
+
path.join(row.runDir, "turntable-quarter-l.jpg"),
|
|
48
|
+
].find((p) => existsSync(p));
|
|
49
|
+
if (probe) {
|
|
50
|
+
const meta = await sharp(probe).metadata();
|
|
51
|
+
if (meta.width && meta.height) {
|
|
52
|
+
tileW = meta.width;
|
|
53
|
+
tileH = meta.height;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const cols = 5, headerH = 64;
|
|
59
|
+
const rowW = cols * tileW;
|
|
60
|
+
const rowH = headerH + tileH;
|
|
61
|
+
const totalH = rows.length * rowH;
|
|
62
|
+
const composites = [];
|
|
63
|
+
for (let rIdx = 0; rIdx < rows.length; rIdx++) {
|
|
64
|
+
const row = rows[rIdx];
|
|
65
|
+
const y0 = rIdx * rowH;
|
|
66
|
+
const r = row.result;
|
|
67
|
+
const t = r.timings;
|
|
68
|
+
const timingStr = t
|
|
69
|
+
? `build ${fmtSec(t.buildMs)} | render ${fmtSec(t.renderMs)}${t.judgeMs ? ` | judge ${fmtSec(t.judgeMs)}` : ""} | total ${fmtSec(r.durationMs)}`
|
|
70
|
+
: `total ${fmtSec(r.durationMs)}`;
|
|
71
|
+
const structStr = r.structure
|
|
72
|
+
? `areas ${r.structure.areas} | curves ${r.structure.curves} | cubes ${r.structure.cubes} | seams ${r.structure.seams} | rib ${r.structure.ribbingDepth} | clusters ${r.structure.floatingClusters}`
|
|
73
|
+
: "";
|
|
74
|
+
const judgeStr = [
|
|
75
|
+
r.likeness ? `likeness ${fmtNum(r.likeness.mean)}` : "",
|
|
76
|
+
...Object.entries(r.checks ?? {}).map(([k, v]) => `${k} ${fmtNum(v.mean)}`),
|
|
77
|
+
].filter(Boolean).join(" | ");
|
|
78
|
+
const costStr = r.costUsd != null ? `$${r.costUsd.toFixed(2)}` : "$–";
|
|
79
|
+
const statusColor = r.error ? "#ef4444" : "#22c55e";
|
|
80
|
+
const headerSvg = Buffer.from(`<svg width="${rowW}" height="${headerH}">
|
|
81
|
+
<rect x="0" y="0" width="${rowW}" height="${headerH}" fill="#181b22"/>
|
|
82
|
+
<circle cx="26" cy="32" r="8" fill="${statusColor}"/>
|
|
83
|
+
<text x="46" y="28" font-family="Arial,sans-serif" font-size="22" font-weight="bold" fill="#f8fafc">${esc(row.caseId)} / run-${row.run} (${esc(r.status)}, ${esc(costStr)}, ${r.steps} steps) · ${esc(timingStr)}${judgeStr ? ` · ${esc(judgeStr)}` : ""}</text>
|
|
84
|
+
<text x="46" y="52" font-family="Arial,sans-serif" font-size="18" fill="#94a3b8">${esc(r.error ? `Error: ${r.error.slice(0, 180)}` : structStr)}</text>
|
|
85
|
+
</svg>`);
|
|
86
|
+
composites.push({ input: headerSvg, left: 0, top: y0 });
|
|
87
|
+
const candidates = [
|
|
88
|
+
["REFERENCE", [row.refFile]],
|
|
89
|
+
["FIXED 3/4", [path.join(row.runDir, "fixed-3q.jpg"), path.join(row.runDir, "turntable-quarter-l.jpg")]],
|
|
90
|
+
["FRONT", [path.join(row.runDir, "fixed-front.jpg"), path.join(row.runDir, "turntable-front.jpg"), path.join(row.runDir, "side-nx.jpg")]],
|
|
91
|
+
["BACK", [path.join(row.runDir, "fixed-back.jpg"), path.join(row.runDir, "turntable-back.jpg"), path.join(row.runDir, "side-px.jpg")]],
|
|
92
|
+
["TOP / ISO", [path.join(row.runDir, "fixed-top.jpg"), path.join(row.runDir, "turntable-top.jpg"), path.join(row.runDir, "turntable-grid.jpg")]],
|
|
93
|
+
];
|
|
94
|
+
for (let cIdx = 0; cIdx < candidates.length; cIdx++) {
|
|
95
|
+
const [label, paths] = candidates[cIdx];
|
|
96
|
+
const file = paths.find((p) => existsSync(p));
|
|
97
|
+
const left = cIdx * tileW;
|
|
98
|
+
const top = y0 + headerH;
|
|
99
|
+
const badge = Buffer.from(`<svg width="${tileW}" height="${tileH}"><rect x="12" y="12" width="156" height="34" rx="5" fill="rgba(15,18,25,0.75)"/><text x="22" y="35" font-family="Arial,sans-serif" font-size="20" font-weight="bold" fill="#f8fafc">${esc(label)}</text></svg>`);
|
|
100
|
+
const tileBuf = file
|
|
101
|
+
? await sharp(file)
|
|
102
|
+
.resize(tileW, tileH, { fit: "contain", background: { r: 245, g: 247, b: 250, alpha: 1 } })
|
|
103
|
+
.composite([{ input: badge, top: 0, left: 0 }])
|
|
104
|
+
.png()
|
|
105
|
+
.toBuffer()
|
|
106
|
+
: await sharp({ create: { width: tileW, height: tileH, channels: 3, background: { r: 30, g: 34, b: 44 } } })
|
|
107
|
+
.composite([{ input: badge, top: 0, left: 0 }])
|
|
108
|
+
.png()
|
|
109
|
+
.toBuffer();
|
|
110
|
+
composites.push({ input: tileBuf, left, top });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
await sharp({
|
|
114
|
+
create: { width: rowW, height: totalH, channels: 3, background: { r: 12, g: 14, b: 19 } },
|
|
115
|
+
limitInputPixels: false,
|
|
116
|
+
})
|
|
117
|
+
.composite(composites)
|
|
118
|
+
.png({ compressionLevel: 6 })
|
|
119
|
+
.toFile(outFile);
|
|
120
|
+
}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { KakapoAPI } from "@womp/kakapo-sdk";
|
|
2
|
+
import { type BenchBounds } from "./bench-camera.js";
|
|
3
|
+
import type { SparkRunSettings } from "./server/types.js";
|
|
4
|
+
export declare const QUALITY_CASES_DIR: string;
|
|
5
|
+
/** Standardized multi-view turntable rendered around the matched front side (used by --ab pairwise judging on any object). */
|
|
6
|
+
export declare const TURNTABLE_VIEWS: QualityView[];
|
|
7
|
+
/** A close-up framed on part of the build, from the side it faces turned by `turn` degrees about +Y. */
|
|
8
|
+
export interface QualityView {
|
|
9
|
+
name: string;
|
|
10
|
+
/** What the close-up shows, for the judge (e.g. "shoulders, three-quarter view"); defaults to `name`. */
|
|
11
|
+
label?: string;
|
|
12
|
+
/** Frame the parts in this band of the build's height (0 = lowest point, 1 = highest)... */
|
|
13
|
+
band?: [number, number];
|
|
14
|
+
/** ...or the parts whose name matches this pattern (case-insensitive), minus `exclude`. */
|
|
15
|
+
match?: string;
|
|
16
|
+
exclude?: string;
|
|
17
|
+
/** With `match`: keep the parts on one side of the build (a = its right, b = its left), e.g. one hand. */
|
|
18
|
+
half?: "a" | "b";
|
|
19
|
+
turn: number;
|
|
20
|
+
/** Camera height: up component of the view direction. */
|
|
21
|
+
tilt?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A judged check: close-ups of the build, and the parts the judge compares with the reference picture. Each item maps
|
|
25
|
+
* a part key to the part's name as the judge should find it, e.g. "left shoulder (where the left-hand sleeve meets
|
|
26
|
+
* the jacket)". The judge rates each part 0-3 (matches / minor detail / visible join or wrong shape / wrong); the
|
|
27
|
+
* check's score is the share of parts that pass.
|
|
28
|
+
*/
|
|
29
|
+
export interface QualityCheck {
|
|
30
|
+
id: string;
|
|
31
|
+
views: QualityView[];
|
|
32
|
+
items: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
export interface QualityCase {
|
|
35
|
+
id: string;
|
|
36
|
+
/** Optional benchmark split ("tune" for prompt iteration, "holdout" for regression gating). */
|
|
37
|
+
split?: "tune" | "holdout";
|
|
38
|
+
prompt: string;
|
|
39
|
+
/** Attached to the prompt, relative to the case directory. */
|
|
40
|
+
images: string[];
|
|
41
|
+
/** Picture the judges compare against (usually the front view), relative to the case directory. */
|
|
42
|
+
reference: string;
|
|
43
|
+
/** Parts the likeness judge scores 0-10, front render against the reference. */
|
|
44
|
+
likeness: string[];
|
|
45
|
+
checks: QualityCheck[];
|
|
46
|
+
}
|
|
47
|
+
export interface QualityBenchOptions {
|
|
48
|
+
cases: string[];
|
|
49
|
+
repeat: number;
|
|
50
|
+
parallel: number;
|
|
51
|
+
kakapoUrl: string;
|
|
52
|
+
settings: SparkRunSettings;
|
|
53
|
+
output: string;
|
|
54
|
+
/** Run AI vision judges (likeness + close-up checks); defaults to false for fast visual sheet comparison. */
|
|
55
|
+
judge?: boolean;
|
|
56
|
+
timeoutMs: number;
|
|
57
|
+
signal: AbortSignal;
|
|
58
|
+
log?: (line: string) => void;
|
|
59
|
+
}
|
|
60
|
+
export declare function loadQualityCaseSpec(id: string): Promise<QualityCase & {
|
|
61
|
+
dir: string;
|
|
62
|
+
}>;
|
|
63
|
+
export declare function loadQualityCase(id: string): Promise<QualityCase & {
|
|
64
|
+
dir: string;
|
|
65
|
+
}>;
|
|
66
|
+
export declare function listQualityCases(): Promise<string[]>;
|
|
67
|
+
/**
|
|
68
|
+
* A new Womp project's scene properties: swan-frontend src/utils/scene/data.tsx `defaultSceneProperty`, lit by the
|
|
69
|
+
* leadenhall_market environment. Builds start from these so they are lit as in the editor. Kakapo's own default
|
|
70
|
+
* environment, `sunset_small` (code/Modeller/Scene.h), is in no data tree, so a scene taken from a freshly started
|
|
71
|
+
* engine has no environment light and renders nearly black.
|
|
72
|
+
*/
|
|
73
|
+
export declare const WOMP_SCENE_PROPERTIES: {
|
|
74
|
+
readonly backdrop_color1: {
|
|
75
|
+
readonly x: 1;
|
|
76
|
+
readonly y: 1;
|
|
77
|
+
readonly z: 1;
|
|
78
|
+
};
|
|
79
|
+
readonly backdrop_color2: {
|
|
80
|
+
readonly x: 1;
|
|
81
|
+
readonly y: 1;
|
|
82
|
+
readonly z: 1;
|
|
83
|
+
};
|
|
84
|
+
readonly backdrop_grad_offset: {
|
|
85
|
+
readonly x: 1;
|
|
86
|
+
readonly y: 1;
|
|
87
|
+
};
|
|
88
|
+
readonly backdrop_multiplier: 0.8489999771118164;
|
|
89
|
+
readonly backdrop_name: "dfsd_gaby";
|
|
90
|
+
readonly flags: 0;
|
|
91
|
+
readonly floor_blend_begin: 0;
|
|
92
|
+
readonly floor_blend_end: 1;
|
|
93
|
+
readonly floor_blending_factor: 0.5870000123977661;
|
|
94
|
+
readonly hdr_multiplier: 1.2999999523162842;
|
|
95
|
+
readonly hdr_name: "leadenhall_market";
|
|
96
|
+
readonly hdr_orientation: {
|
|
97
|
+
readonly x: 0;
|
|
98
|
+
readonly y: 0;
|
|
99
|
+
};
|
|
100
|
+
readonly render_flags: 59;
|
|
101
|
+
readonly dynamic_resolution: 1;
|
|
102
|
+
readonly outline: {
|
|
103
|
+
readonly x: 0;
|
|
104
|
+
readonly y: 0;
|
|
105
|
+
readonly z: 0;
|
|
106
|
+
readonly w: 2;
|
|
107
|
+
};
|
|
108
|
+
readonly outline_mode: 0;
|
|
109
|
+
readonly cel_shading_levels: 0;
|
|
110
|
+
readonly exposure: 1;
|
|
111
|
+
readonly tonemapper: 0;
|
|
112
|
+
readonly use_image_background: false;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* A saved scene with its environment made renderable: one still on Kakapo's missing default environment (builds made
|
|
116
|
+
* before the bench seeded WOMP_SCENE_PROPERTIES) gets the Womp default environment; any other scene is unchanged.
|
|
117
|
+
*/
|
|
118
|
+
export declare function withWompEnvironment(scene: any): any;
|
|
119
|
+
/**
|
|
120
|
+
* Ensures Kakapo has a valid minimal scene (with `nodes["0"]`) before connecting `KakapoAPI` (prevents
|
|
121
|
+
* `Cannot convert undefined or null to object` when Kakapo is open with no project loaded).
|
|
122
|
+
* When `reset` is true, always replaces the engine scene with a clean empty root scene with a new Womp project's
|
|
123
|
+
* properties, so `KakapoMux` templates inherit neither stale scenes nor the engine's unlit default environment.
|
|
124
|
+
*/
|
|
125
|
+
export declare function ensureKakapoScene(url: string, reset?: boolean): Promise<void>;
|
|
126
|
+
/** Runs every case `repeat` times, `parallel` builds at once, and writes report.json and report.md to `output`. */
|
|
127
|
+
export declare function runQualityBench(options: QualityBenchOptions): Promise<QualityReport>;
|
|
128
|
+
export interface QualityTimings {
|
|
129
|
+
buildMs: number;
|
|
130
|
+
renderMs: number;
|
|
131
|
+
judgeMs: number;
|
|
132
|
+
}
|
|
133
|
+
export interface QualityRunResult {
|
|
134
|
+
case: string;
|
|
135
|
+
run: number;
|
|
136
|
+
status: string;
|
|
137
|
+
error?: string;
|
|
138
|
+
costUsd: number | null;
|
|
139
|
+
durationMs: number;
|
|
140
|
+
timings?: QualityTimings;
|
|
141
|
+
steps: number;
|
|
142
|
+
likeness?: Judged & {
|
|
143
|
+
side: string;
|
|
144
|
+
};
|
|
145
|
+
/** The side render the judge named as the build's front (`DEFAULT_FRONT` without a judge); turntable views turn from it. */
|
|
146
|
+
front?: string;
|
|
147
|
+
checks: Record<string, Judged>;
|
|
148
|
+
structure?: SceneStructure;
|
|
149
|
+
}
|
|
150
|
+
interface Judged {
|
|
151
|
+
scores: Record<string, number>;
|
|
152
|
+
mean: number;
|
|
153
|
+
notes?: unknown;
|
|
154
|
+
}
|
|
155
|
+
/** Spark's public +Z is forward and maps to renderer -X, so a build that follows the convention faces the `nx` side. */
|
|
156
|
+
export declare const DEFAULT_FRONT = "nx";
|
|
157
|
+
/** Fixed Spark-space perspective shots (`benchCamera`), fitted to Kakapo's native world bounding box. */
|
|
158
|
+
export declare function renderFixedCameras(api: KakapoAPI, dir: string): Promise<string[]>;
|
|
159
|
+
/** The part of `box` inside `to`, or undefined when they do not overlap. */
|
|
160
|
+
export declare function clipBox(box: BenchBounds, to: BenchBounds): BenchBounds | undefined;
|
|
161
|
+
/** The side a front answer names; "none", an unknown label or a malformed answer keeps Spark's convention. */
|
|
162
|
+
export declare function frontFromAnswer(answer: unknown, keys: string[]): string;
|
|
163
|
+
export interface PairwiseResult {
|
|
164
|
+
winner: "A" | "B" | "tie";
|
|
165
|
+
consistent: boolean;
|
|
166
|
+
reason: string;
|
|
167
|
+
aFlaws: string;
|
|
168
|
+
bFlaws: string;
|
|
169
|
+
}
|
|
170
|
+
/** Resolves order-swapped forward (A, B) and reverse (B, A) pairwise judgements; disagreement becomes a tie. */
|
|
171
|
+
export declare function resolvePairwiseSwap(forward: {
|
|
172
|
+
winner: "A" | "B" | "tie";
|
|
173
|
+
reason?: string;
|
|
174
|
+
a_flaws?: string;
|
|
175
|
+
b_flaws?: string;
|
|
176
|
+
}, reverse: {
|
|
177
|
+
winner: "A" | "B" | "tie";
|
|
178
|
+
reason?: string;
|
|
179
|
+
a_flaws?: string;
|
|
180
|
+
b_flaws?: string;
|
|
181
|
+
}): PairwiseResult;
|
|
182
|
+
/**
|
|
183
|
+
* Blinded order-swapped pairwise judge (Gemini 4 Neon, low thinking): runs (A, B) and (B, A) in parallel so position
|
|
184
|
+
* bias cancels out into a tie. Works on any reference image or focused close-up view set.
|
|
185
|
+
*/
|
|
186
|
+
export declare function judgePairwise(referenceFile: string, shotsA: {
|
|
187
|
+
name: string;
|
|
188
|
+
label?: string;
|
|
189
|
+
file?: string;
|
|
190
|
+
}[], shotsB: {
|
|
191
|
+
name: string;
|
|
192
|
+
label?: string;
|
|
193
|
+
file?: string;
|
|
194
|
+
}[], focus?: string): Promise<PairwiseResult>;
|
|
195
|
+
/**
|
|
196
|
+
* Stitches 4 turntable renders (front, quarter-l, back, top) into a single labeled 1280x720 2x2 contact sheet JPEG so
|
|
197
|
+
* pairwise VLM calls see only 3 images total (Reference, Build A grid, Build B grid) without image-overload bias.
|
|
198
|
+
*/
|
|
199
|
+
export declare function buildContactSheet(shots: {
|
|
200
|
+
name: string;
|
|
201
|
+
file?: string;
|
|
202
|
+
}[], outFile: string): Promise<string | null>;
|
|
203
|
+
export interface PairwiseComparisonReport {
|
|
204
|
+
baselineDir: string;
|
|
205
|
+
candidateDir: string;
|
|
206
|
+
focus?: string;
|
|
207
|
+
finishedAt: string;
|
|
208
|
+
judge: string;
|
|
209
|
+
overall: {
|
|
210
|
+
pairs: number;
|
|
211
|
+
candidateWins: number;
|
|
212
|
+
baselineWins: number;
|
|
213
|
+
ties: number;
|
|
214
|
+
consistent: number;
|
|
215
|
+
};
|
|
216
|
+
cases: Record<string, {
|
|
217
|
+
pairs: number;
|
|
218
|
+
candidateWins: number;
|
|
219
|
+
baselineWins: number;
|
|
220
|
+
ties: number;
|
|
221
|
+
consistent: number;
|
|
222
|
+
skipped?: string[];
|
|
223
|
+
runs: (PairwiseResult & {
|
|
224
|
+
pair: string;
|
|
225
|
+
baselineRun: string;
|
|
226
|
+
candidateRun: string;
|
|
227
|
+
})[];
|
|
228
|
+
}>;
|
|
229
|
+
}
|
|
230
|
+
/** Blinded order-swapped all-vs-all pairwise comparison of two completed quality-bench output directories (A = baseline, B = candidate). */
|
|
231
|
+
export declare function compareQualityRuns(baselineDir: string, candidateDir: string, options?: {
|
|
232
|
+
focus?: string;
|
|
233
|
+
viewFilter?: string;
|
|
234
|
+
allPairs?: boolean;
|
|
235
|
+
}): Promise<PairwiseComparisonReport>;
|
|
236
|
+
export declare function pairwiseReportMarkdown(report: PairwiseComparisonReport): string;
|
|
237
|
+
/**
|
|
238
|
+
* Recovers and scores an existing bench output directory from its saved `scene.json` files (e.g. after a Kakapo crash),
|
|
239
|
+
* rendering any missing views/grids and reusing existing judge JSONs so completed Spark builds are never wasted.
|
|
240
|
+
*/
|
|
241
|
+
export declare function scoreExistingBenchRun(outputDir: string, options: {
|
|
242
|
+
kakapoUrl: string;
|
|
243
|
+
baseline?: QualityReport;
|
|
244
|
+
log?: (line: string) => void;
|
|
245
|
+
}): Promise<QualityReport>;
|
|
246
|
+
export interface SceneStructure {
|
|
247
|
+
/** Top-level Areas (outermost Area in each visible branch). */
|
|
248
|
+
areas: number;
|
|
249
|
+
curves: number;
|
|
250
|
+
points: number;
|
|
251
|
+
primitives: number;
|
|
252
|
+
/** Cube primitives that add material (informational: expected on CAD, unusual on organic builds). */
|
|
253
|
+
cubes: number;
|
|
254
|
+
/** Pairs of top-level Areas holding overlapping parts of the same material: Areas never blend, so these show seams. */
|
|
255
|
+
seams: number;
|
|
256
|
+
/** Largest estimated ridge depth (x1000 scene units) across visible V3 Bezier curves; higher means visible ribbing. */
|
|
257
|
+
ribbingDepth: number;
|
|
258
|
+
/** Count of visible V3 Bezier curves with noticeable spacing ribbing (ratio > 1.5 and depth > 0.002). */
|
|
259
|
+
ribbedCurves: number;
|
|
260
|
+
/** Disconnected additive geometry clusters (1 = single connected solid; >1 = detached/floating pieces). */
|
|
261
|
+
floatingClusters: number;
|
|
262
|
+
}
|
|
263
|
+
/** Estimates spacing ribbing on a V3 Bezier curve (mirrors Kakapo CurveBezier.cpp spacing logic). */
|
|
264
|
+
export declare function curveRibbing(node: any, scale?: number): {
|
|
265
|
+
ratio: number;
|
|
266
|
+
depth: number;
|
|
267
|
+
prims: number;
|
|
268
|
+
density: number;
|
|
269
|
+
} | null;
|
|
270
|
+
export declare function sceneStructure(scene: any): SceneStructure;
|
|
271
|
+
export interface QualityReport {
|
|
272
|
+
version: 1;
|
|
273
|
+
finishedAt: string;
|
|
274
|
+
settings: SparkRunSettings;
|
|
275
|
+
judge: string;
|
|
276
|
+
repeat: number;
|
|
277
|
+
cases: Record<string, {
|
|
278
|
+
runs: number;
|
|
279
|
+
failed: number;
|
|
280
|
+
metrics: Record<string, {
|
|
281
|
+
mean: number;
|
|
282
|
+
sd: number;
|
|
283
|
+
n: number;
|
|
284
|
+
}>;
|
|
285
|
+
costUsd: number;
|
|
286
|
+
durationS: number;
|
|
287
|
+
}>;
|
|
288
|
+
}
|
|
289
|
+
/** Generates or regenerates per-repeat `sheet-run-<n>.png` files for an existing bench output directory without running builds. */
|
|
290
|
+
export declare function generateBenchSheet(outputDir: string): Promise<string[]>;
|
|
291
|
+
/** Markdown table per case; with a baseline report, each metric's change and whether it is beyond noise. */
|
|
292
|
+
export declare function reportMarkdown(report: QualityReport, baseline?: QualityReport): string;
|
|
293
|
+
export {};
|