@tangle-network/agent-bench 0.14.4 → 1.0.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 +38 -0
- package/README.md +2 -3
- package/dist/adapters.d.ts +2 -5
- package/dist/adapters.js +3 -4
- package/dist/benchmarks/_harness.d.ts +17 -20
- package/dist/benchmarks/_harness.js +4 -4
- package/dist/benchmarks/_harness.js.map +1 -1
- package/dist/benchmarks/aec-bench.d.ts +1 -4
- package/dist/benchmarks/aec-bench.js +1 -2
- package/dist/benchmarks/agentbench.d.ts +2 -5
- package/dist/benchmarks/agentbench.js +1 -2
- package/dist/benchmarks/appworld.d.ts +8 -10
- package/dist/benchmarks/appworld.js +23 -23
- package/dist/benchmarks/appworld.js.map +1 -1
- package/dist/benchmarks/bfcl.d.ts +2 -5
- package/dist/benchmarks/bfcl.js +1 -2
- package/dist/benchmarks/cad-design.d.ts +2 -5
- package/dist/benchmarks/cad-design.js +2 -3
- package/dist/benchmarks/cad-design.js.map +1 -1
- package/dist/benchmarks/cadbench.d.ts +1 -4
- package/dist/benchmarks/cadbench.js +1 -2
- package/dist/benchmarks/cadgenbench.d.ts +1 -4
- package/dist/benchmarks/cadgenbench.js +1 -2
- package/dist/benchmarks/commit0.d.ts +2 -5
- package/dist/benchmarks/commit0.js +1 -2
- package/dist/benchmarks/crag.d.ts +1 -4
- package/dist/benchmarks/crag.js +3 -3
- package/dist/benchmarks/crag.js.map +1 -1
- package/dist/benchmarks/dabstep.d.ts +2 -5
- package/dist/benchmarks/dabstep.js +2 -3
- package/dist/benchmarks/dabstep.js.map +1 -1
- package/dist/benchmarks/enterpriseops-gym.d.ts +2 -5
- package/dist/benchmarks/enterpriseops-gym.js +1 -2
- package/dist/benchmarks/finresearchbench.d.ts +2 -5
- package/dist/benchmarks/finresearchbench.js +2 -3
- package/dist/benchmarks/finsearchcomp.d.ts +2 -5
- package/dist/benchmarks/finsearchcomp.js +4 -4
- package/dist/benchmarks/finsearchcomp.js.map +1 -1
- package/dist/benchmarks/frames.d.ts +3 -19
- package/dist/benchmarks/frames.js +13 -39
- package/dist/benchmarks/frames.js.map +1 -1
- package/dist/benchmarks/hotpotqa.d.ts +4 -14
- package/dist/benchmarks/hotpotqa.js +12 -32
- package/dist/benchmarks/hotpotqa.js.map +1 -1
- package/dist/benchmarks/humaneval.d.ts +9 -12
- package/dist/benchmarks/humaneval.js +2 -3
- package/dist/benchmarks/humaneval.js.map +1 -1
- package/dist/benchmarks/mcad-bench.d.ts +13 -16
- package/dist/benchmarks/mcad-bench.js +2 -3
- package/dist/benchmarks/mcad-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-bench.d.ts +17 -20
- package/dist/benchmarks/mcad-cq-bench.js +2 -3
- package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-golds.d.ts +2 -5
- package/dist/benchmarks/mcad-cq-golds.js +1 -2
- package/dist/benchmarks/mcad-golds.d.ts +1 -4
- package/dist/benchmarks/mcad-golds.js +0 -1
- package/dist/benchmarks/mcad-tasks.d.ts +5 -8
- package/dist/benchmarks/mcad-tasks.js +7 -8
- package/dist/benchmarks/mcad-tasks.js.map +1 -1
- package/dist/benchmarks/mind2web.d.ts +3 -5
- package/dist/benchmarks/mind2web.js +2 -3
- package/dist/benchmarks/mind2web.js.map +1 -1
- package/dist/benchmarks/nomiracl.d.ts +1 -4
- package/dist/benchmarks/nomiracl.js +1 -2
- package/dist/benchmarks/open-rag-bench.d.ts +1 -4
- package/dist/benchmarks/open-rag-bench.js +3 -3
- package/dist/benchmarks/open-rag-bench.js.map +1 -1
- package/dist/benchmarks/programbench.d.ts +2 -5
- package/dist/benchmarks/programbench.js +1 -2
- package/dist/benchmarks/rag-shared.d.ts +30 -22
- package/dist/benchmarks/rag-shared.js +8 -2
- package/dist/benchmarks/rag-shared.js.map +1 -1
- package/dist/benchmarks/ragbench.d.ts +1 -4
- package/dist/benchmarks/ragbench.js +3 -3
- package/dist/benchmarks/ragbench.js.map +1 -1
- package/dist/benchmarks/simpleqa.d.ts +2 -18
- package/dist/benchmarks/simpleqa.js +5 -31
- package/dist/benchmarks/simpleqa.js.map +1 -1
- package/dist/benchmarks/swe-bench.d.ts +7 -10
- package/dist/benchmarks/swe-bench.js +4 -4
- package/dist/benchmarks/swe-bench.js.map +1 -1
- package/dist/benchmarks/t2-ragbench.d.ts +1 -4
- package/dist/benchmarks/t2-ragbench.js +3 -3
- package/dist/benchmarks/t2-ragbench.js.map +1 -1
- package/dist/benchmarks/tau-bench-shared.d.ts +5 -8
- package/dist/benchmarks/tau-bench-shared.js +4 -4
- package/dist/benchmarks/tau-bench-shared.js.map +1 -1
- package/dist/benchmarks/tau2-bench.d.ts +2 -5
- package/dist/benchmarks/tau2-bench.js +1 -2
- package/dist/benchmarks/tau3-banking.d.ts +1 -4
- package/dist/benchmarks/tau3-banking.js +1 -2
- package/dist/benchmarks/terminal-bench.d.ts +1 -4
- package/dist/benchmarks/terminal-bench.js +4 -4
- package/dist/benchmarks/terminal-bench.js.map +1 -1
- package/dist/benchmarks/toollm.d.ts +2 -5
- package/dist/benchmarks/toollm.js +1 -2
- package/dist/benchmarks/trata-hedge.d.ts +1 -4
- package/dist/benchmarks/trata-hedge.js +2 -3
- package/dist/benchmarks/types.d.ts +6 -9
- package/dist/benchmarks/webarena-verified.d.ts +2 -5
- package/dist/benchmarks/webarena-verified.js +1 -2
- package/dist/{cadbench-BRF-59Mt.js → cadbench-DhAndllg.js} +4 -6
- package/dist/cadbench-DhAndllg.js.map +1 -0
- package/dist/{cadgenbench-DXtGkuW3.js → cadgenbench-Tvk16YKT.js} +15 -5
- package/dist/cadgenbench-Tvk16YKT.js.map +1 -0
- package/dist/index.d.ts +8 -18
- package/dist/index.js +16 -24
- package/dist/index.js.map +1 -1
- package/dist/{router-turn-uTYO6KQ1.js → router-turn-DNbQ_GjQ.js} +2 -3
- package/dist/router-turn-DNbQ_GjQ.js.map +1 -0
- package/fixtures/pier-agent/no-model-task/pre_artifacts.sh +0 -0
- package/fixtures/pier-agent/no-model-task/tests/test.sh +0 -0
- package/package.json +10 -10
- package/pier_agents/tangle_candidate.py +15 -23
- package/scripts/run-package-tests.mjs +8 -15
- package/src/atom-mcp-e2e.mts +2 -2
- package/src/benchmarks/frames.ts +10 -44
- package/src/benchmarks/hotpotqa.ts +9 -29
- package/src/benchmarks/rag-shared.ts +12 -0
- package/src/benchmarks/simpleqa.ts +2 -36
- package/src/commit0-prereqs.sh +0 -0
- package/src/corpus-replay.mts +8 -8
- package/src/corpus-report.mts +21 -21
- package/src/corpus.test.mts +5 -5
- package/src/corpus.ts +16 -16
- package/src/directives.ts +0 -38
- package/src/examples/lean-verify.ts +1 -1
- package/src/gate.ts +7 -7
- package/src/generate-eval/certify.ts +2 -2
- package/src/index.ts +1 -0
- package/src/refine-loop.ts +5 -5
- package/src/resolve-client.ts +1 -1
- package/src/router-turn.ts +3 -11
- package/src/run-pool.ts +1 -1
- package/src/runtime-hook-recorder.ts +2 -2
- package/src/search-bench/tasks.ts +1 -1
- package/src/selector.test.mts +13 -13
- package/src/selector.ts +19 -19
- package/src/swe-bench-env.ts +4 -12
- package/src/swe-jail.ts +5 -156
- package/src/swe-structural-judge-policy.ts +3 -3
- package/src/swe-structural-policy.ts +3 -3
- package/src/swe-structural-provenance.ts +4 -4
- package/src/terminal-compare.ts +10 -10
- package/src/worker-blender.ts +2 -106
- package/src/worker-build123d.ts +2 -81
- package/tb_agents/opencode_router_agent.py +1 -1
- package/dist/cadbench-BRF-59Mt.js.map +0 -1
- package/dist/cadgenbench-DXtGkuW3.js.map +0 -1
- package/dist/router-turn-uTYO6KQ1.js.map +0 -1
- package/scripts/cadbench_prepare.py +0 -22
- package/scripts/cadgenbench_hard_parts.py +0 -48
- package/scripts/clbench_codebase_judge.py +0 -73
- package/scripts/render-gate-chart.mjs +0 -176
- package/scripts/trata-hedge/README.md +0 -57
- package/scripts/trata-hedge/run.sh +0 -64
- package/src/cloud-loop.mts +0 -156
- package/src/coordination-mcp-container-reach.mts +0 -182
- package/src/fleet.mts +0 -143
- package/src/hev-structural.mts +0 -697
- package/src/humaneval-gate.mts +0 -220
- package/src/mbpp-structural.mts +0 -676
- package/src/mcp-mount-probe.mts +0 -141
- package/src/profiles.ts +0 -128
- package/src/research-gate.mts +0 -132
- package/src/research-shot.ts +0 -144
- package/src/router-executor.ts +0 -51
- package/src/sandbox-run.ts +0 -108
- package/src/search-bench/bridge.ts +0 -182
- package/src/search-bench/export.mts +0 -0
- package/src/search-bench/parametric-check.mts +0 -78
- package/src/search-bench/profiles.ts +0 -113
- package/src/search-bench/run.mts +0 -286
- package/src/search-bench/tasks-fresh.ts +0 -688
- package/src/smoke-structural-rollout.mts +0 -415
- package/src/stats.mts +0 -90
- package/src/swe-code-improve.mts +0 -306
- package/src/swe-improve.mts +0 -284
- package/src/swe-structural.mts +0 -707
- package/src/tb-container-executor.mts +0 -266
- package/src/tb-container-executor.test.mts +0 -134
- package/src/tb-supervisor-sidecar.mts +0 -208
- package/src/trata-gepa.mts +0 -381
- package/src/trata-hedge-solve.mts +0 -81
- package/tb_agents/opencode_refine_agent.py +0 -117
- package/tb_agents/opencode_supervisor_agent.py +0 -239
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcad-tasks.js","names":[],"sources":["../../src/benchmarks/mcad-tasks.ts"],"sourcesContent":["/**\n * MCAD task specs — 10 dimensioned mechanical parts adopted from the MIT-licensed\n * text-to-cad benchmark set (github.com/earthtojake/text-to-cad, `benchmarks/`).\n *\n * Upstream ships each part as a prompt plus a human checklist (\"four through-holes,\n * 8 mm each; no floating gussets\") with NO grader. This file is the machine-checkable\n * form: every assertion below is derivable in closed form from the upstream prompt,\n * and every derivation is shown in a comment beside its number. An assertion that\n * cannot be derived in closed form is OMITTED, never guessed — the judge only\n * asserts what the prompt actually pins.\n *\n * FORMAT DEVIATION, stated once: upstream asks for STEP export. The v1 judge\n * compiles OpenSCAD and grades the STL mesh (same judge deps as `cad-design`);\n * OpenSCAD cannot emit STEP. The geometric content of every check is preserved;\n * the \"STEP imports\" row is replaced by \"compiles + watertight\". Tasks keep the\n * upstream dimensional text verbatim inside an OpenSCAD-deliverable wrapper.\n *\n * Probes are the hole/pocket checks: a point the finished solid must NOT contain\n * (inside a hole bore) or MUST contain (in the surrounding material). Locations\n * come from the prompt's own dimensions, with clearance chosen so a hole that is\n * missing, misplaced by more than ~1 mm, or wrong in diameter by more than ~1 mm\n * flips at least one probe.\n */\n\nexport interface McadSpec {\n /** Overall axis-aligned extents in mm, [min, max] per axis. */\n bbox?: { x?: [number, number]; y?: [number, number]; z?: [number, number] }\n /** Enclosed mesh volume band in mm^3 — closed-form only, derivation in a comment. */\n volume?: [number, number]\n /** Disconnected-solid count band (fused parts must read as ONE solid). */\n solids?: [number, number]\n /** Triangle floor — rejects degenerate single-box answers where relevant. */\n minTriangles?: number\n /** Points (mm) that must test INSIDE the solid (material present). */\n probesInsideSolid?: Array<[number, number, number]>\n /** Points (mm) that must test OUTSIDE the solid (hole/pocket/clearance present). */\n probesOutsideSolid?: Array<[number, number, number]>\n}\n\nexport interface McadTask {\n id: string\n /** Upstream dimensional brief, verbatim, wrapped for the OpenSCAD deliverable. */\n prompt: string\n spec: McadSpec\n /** Upstream file this was adopted from. */\n source: string\n /** False when the spec has no verified gold yet — the judge still runs, but the\n * accept direction is uncalibrated and the loader surfaces that in metadata. */\n calibrated: boolean\n}\n\n/** Exported so a sibling adapter can SWAP this preamble for its own deliverable\n * (see `mcad-cq-bench.ts`) by prefix, instead of re-authoring ten prompts and\n * letting the two copies drift. The upstream dimensional text stays the tail. */\nexport const MCAD_DELIVERABLE =\n 'Author OpenSCAD source (units: mm) that builds exactly this part as one fused solid. ' +\n 'Reply with ONLY the OpenSCAD code. Use $fn=96 or finer for round features.'\n\nconst DELIVERABLE = MCAD_DELIVERABLE\n\n/** Task 10 is an ASSEMBLY, not a part: its own text says \"use separate solid bodies\"\n * and its checklist pins nine of them, which the single-solid boilerplate above\n * flatly contradicts. A worker cannot satisfy both, so that task gets this\n * preamble instead; everything else about the deliverable is unchanged. */\nexport const MCAD_DELIVERABLE_MULTIBODY =\n 'Author OpenSCAD source (units: mm) that builds exactly this assembly as the separate ' +\n 'solid bodies listed below. The bodies must stay disjoint — no two of them may touch or ' +\n 'intersect. Reply with ONLY the OpenSCAD code. Use $fn=96 or finer for round features.'\n\nconst DELIVERABLE_MULTIBODY = MCAD_DELIVERABLE_MULTIBODY\n\nexport const MCAD_TASKS: McadTask[] = [\n {\n id: 'calibration-block',\n source: 'benchmarks/01-rectangular-calibration-block.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The part is a rectangular block, 100 mm long in X, 60 mm wide in Y, and 20 mm tall in Z. ' +\n 'Center the block on the XY origin, with the bottom face at Z = 0. ' +\n 'Add four vertical through-holes, each 8 mm in diameter, located at X = +/-35 mm and Y = +/-20 mm. ' +\n 'Add a 2 mm chamfer to the top perimeter edges only. Do not chamfer the holes.',\n spec: {\n bbox: { x: [99, 101], y: [59, 61], z: [19, 21] },\n // block 100*60*20 = 120000; holes 4 * pi * 4^2 * 20 = 4021.2;\n // top-perimeter 2 mm chamfer ~ (2*2/2) * perimeter(320) - corners ~ 620..640.\n // exact-ish 115340; band allows +-1% modelling slack but excludes\n // no-chamfer (115979) ONLY via the upper edge staying below it? No -\n // 115979 is within 1%; the chamfer is NOT volume-separable at this size,\n // so the band checks holes+block and the chamfer stays unasserted.\n volume: [113_000, 117_000],\n solids: [1, 1],\n probesInsideSolid: [\n [0, 0, 10], // core material between the holes\n [48, 28, 10], // corner material\n [35, 20 + 5.5, 10], // 5.5 mm off a hole center: outside an 8 mm bore, inside the block\n ],\n probesOutsideSolid: [\n [35, 20, 10], // each 8 mm bore, probed at mid-depth\n [-35, 20, 10],\n [35, -20, 10],\n [-35, -20, 10],\n [35, 20 + 3.0, 10], // 3.0 mm off center: still inside a 4 mm-radius bore\n ],\n },\n },\n {\n id: 'circular-flange',\n source: 'benchmarks/02-circular-flange.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The flange is a cylinder with an outside diameter of 80 mm and a thickness of 10 mm. ' +\n 'Its axis is vertical along Z, with the bottom face at Z = 0 and the center at X = 0, Y = 0. ' +\n 'Add a central vertical through-bore with diameter 30 mm. ' +\n 'Add six equally spaced vertical through-holes, each 6 mm in diameter, on a 60 mm bolt-circle diameter. ' +\n 'Add a 1.5 mm fillet to the top and bottom outside circular edges.',\n spec: {\n // OD 80 -> radius 40; thickness 10.\n bbox: { x: [79, 81], y: [79, 81], z: [9, 11] },\n // cylinder pi*40^2*10 = 50265.48; central bore pi*15^2*10 = 7068.58;\n // 6 bolt holes 6*pi*3^2*10 = 1696.46; net 41500.44.\n // top+bottom 1.5 mm fillet on the OD removes ~2*(1-pi/4)*1.5^2*(pi*80)\n // = ~242.7 (0.6%), well inside a +-3% band, so it stays unasserted here.\n volume: [40_250, 42_750],\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [22, 0, 5], // core material between the 30 mm bore and the 60 mm bolt circle\n [15 + 1.5, 0, 5], // 1.5 mm past the 15 mm bore radius: inside material\n ],\n probesOutsideSolid: [\n [0, 0, 5], // central bore, dead center, mid-thickness\n [15 - 1, 0, 5], // 1 mm inside the 15 mm bore radius: still inside the bore\n ],\n // The 6 bolt holes have a pinned radius (30 mm) and count (6) but no stated\n // starting angle, so their exact XY centers are not derivable; any global\n // rotation of the pattern is a valid answer. Omitted rather than guessed.\n },\n },\n {\n id: 'l-bracket',\n source: 'benchmarks/03-l-bracket.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The bracket has a horizontal base plate 80 mm long in X, 50 mm wide in Y, and 8 mm thick in Z. Center the base plate on the XY origin, with its bottom at Z = 0. ' +\n 'Add a vertical back plate along the rear long edge of the base. The back plate is 80 mm long in X, 8 mm thick in Y, and 50 mm tall in Z, rising from the top of the base plate. The back plate should sit along the rear edge at positive Y. ' +\n 'Add two vertical through-holes in the base plate, each 6 mm in diameter, located at X = +/-25 mm and Y = -10 mm. ' +\n 'Add two horizontal through-holes in the vertical plate, each 6 mm in diameter, located at X = +/-25 mm and Z = 30 mm, passing through the 8 mm thickness of the vertical plate. ' +\n 'Add two triangular gussets, each 8 mm thick in X, located at X = +/-20 mm. Each gusset should connect the base plate to the back plate with a right-triangle side profile 30 mm tall and 30 mm deep. ' +\n 'Add 2 mm fillets to the outside corner where the base and back plate meet.',\n spec: {\n // X: both plates are 80 mm long, gussets sit within +/-24 -> base governs.\n // Y: base is 50 mm wide (-25..25); back plate (8 mm thick) hugs the rear\n // edge, occupying Y=17..25 (flush at Y=25), inside the base's Y range.\n // Z: base bottom 0, base top 8; back plate rises 50 mm from there -> top 58.\n bbox: { x: [79, 81], y: [49, 51], z: [57, 59] },\n // base 80*50*8=32000 - 2 holes(pi*3^2*8=452.39) = 31547.61\n // back 80*8*50=32000 - 2 holes(452.39) = 31547.61\n // 2 gussets: right triangle 30x30 * 8 mm thick = 0.5*30*30*8=3600 each -> 7200\n // sum 70295.22; the two plates occupy disjoint Z ranges (0-8 vs 8-58), no\n // volume overlap. A 2 mm fillet on the one outside X-running corner edge\n // (length 80) removes ~(1-pi/4)*2^2*80=68.7 (0.1%), folded into the band.\n volume: [68_200, 72_400],\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [0, 0, 4], // base plate core, away from both base holes (X=+/-25, Y=-10)\n [0, 21, 30], // back plate core (mid-Y-thickness 17..25), away from both back holes\n [25, -10 + 4.5, 4], // 4.5 mm past the base hole's 3 mm radius (r+1.5): inside material\n [25, 21, 30 + 4.5], // 4.5 mm past the back hole's 3 mm radius (r+1.5), offset in Z: inside material\n ],\n probesOutsideSolid: [\n [25, -10, 4], // base hole (X=25, Y=-10), dead center, mid-thickness\n [-25, -10, 4], // base hole (X=-25, Y=-10), dead center\n [25, -10 + 2, 4], // 1 mm inside the base hole's 3 mm radius (r-1)\n [25, 21, 30], // back hole (X=25, Z=30), dead center, mid-Y-thickness\n [-25, 21, 30], // back hole (X=-25, Z=30), dead center\n [25, 21, 30 + 2], // 1 mm inside the back hole's 3 mm radius (r-1), offset in Z\n ],\n },\n },\n {\n id: 'stepped-shaft-keyway',\n source: 'benchmarks/04-stepped-shaft-keyway.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The shaft axis runs along X. The total length is 120 mm. The left end center is at X = 0, Y = 0, Z = 0. ' +\n 'From X = 0 to X = 30, the shaft diameter is 20 mm. From X = 30 to X = 90, the shaft diameter is 30 mm. From X = 90 to X = 120, the shaft diameter is 20 mm. ' +\n 'Add a 1 mm chamfer to both end edges. ' +\n 'Add a rectangular keyway slot on the top of the 30 mm diameter middle section. The keyway is 6 mm wide in Y, 3 mm deep in Z, and runs from X = 40 to X = 80.',\n spec: {\n // length 0..120; widest section is the 30 mm-diameter middle (radius 15).\n bbox: { x: [119, 121], y: [29, 31], z: [29, 31] },\n // 3 segments on-axis (Y=0,Z=0): pi*10^2*30 + pi*15^2*60 + pi*10^2*30 = 61261.06\n // minus keyway 6*3*40=720 -> net 60541.06. End chamfers (1 mm, r=10 circles)\n // remove ~2*0.5*1^2*(2*pi*10)=62.8 (0.1%), folded into the band.\n // TIGHTENED band: a model that omits the keyway entirely would measure\n // 61261.06, only 1.19% above net -- inside a naive +-3% band. Upper bound\n // is pulled below 61261 to force that failure to read as a miss; probes\n // below also independently catch a keyway that is missing or too shallow.\n volume: [59_700, 61_050],\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [15, 0, 0], // on-axis material, left 20 mm-diameter section\n [60, 0, 0], // on-axis material, middle section, far from the keyway (which is at Z=12..15)\n [105, 0, 0], // on-axis material, right 20 mm-diameter section\n [60, 3 + 1.5, 15 - 1.5], // 1.5 mm past the keyway's 3 mm half-width (assumed centered on Y=0): inside the 30 mm section\n [60, 0, 15 - 3 - 2], // 2 mm below the keyway floor (Z = 15-3 = 12): shaft material intact beneath the slot\n ],\n probesOutsideSolid: [\n [60, 0, 15 - 1.5], // keyway void, X-midpoint of the 40..80 run, mid-depth between floor (Z=12) and top (Z=15)\n [60, 3 - 1, 15 - 1.5], // 1 mm inside the keyway's 3 mm half-width: still within the 6 mm-wide slot\n ],\n },\n },\n {\n id: 'open-top-electronics-enclosure',\n source: 'benchmarks/05-open-top-electronics-enclosure.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The outer shape is a rectangular box 100 mm long in X, 70 mm wide in Y, and 30 mm tall in Z. Center it on the XY origin, with the bottom face at Z = 0. ' +\n 'The enclosure is open at the top. The wall thickness is 3 mm and the bottom floor thickness is 3 mm. ' +\n 'Add four internal cylindrical standoffs rising from the inside floor. Each standoff has an outside diameter of 10 mm and a height of 12 mm above the inside floor. Place the standoffs at X = +/-35 mm and Y = +/-25 mm. ' +\n 'Add a centered blind hole in each standoff, 3 mm in diameter and 8 mm deep from the top of the standoff. ' +\n 'Add 2 mm radius fillets to the four outside vertical corners of the enclosure.',\n spec: {\n bbox: { x: [99, 101], y: [69, 71], z: [29, 31] },\n // outer box 100*70*30=210000; interior cavity (94 x 64 footprint, open\n // top, floor top at Z=3) is 94*64*27=162432; shell = 47568.\n // 4 standoffs (OD10 r5, h12 above floor): 4*pi*5^2*12=3769.91.\n // 4 blind holes (d3 r1.5, 8 mm deep from standoff top): 4*pi*1.5^2*8=226.19.\n // net 47568 + 3769.91 - 226.19 = 51111.72. 4 corner fillets (r2, full\n // 30 mm height) remove ~4*(1-pi/4)*2^2*30=103.0 (0.2%), folded into band.\n volume: [49_600, 52_650],\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [0, 0, 3 / 2], // floor slab, mid-thickness (Z=0..3), away from all standoffs\n [50 - 3 / 2, 0, 15], // +X wall material, mid-wall-thickness (47..50), mid-height\n [35 + 1.5 + 1.5, 25, 15 - 8 / 2], // 1.5 mm past the (35,25) standoff's 1.5 mm blind-hole radius (r+1.5): inside the standoff (OD10, r5)\n [35, 25, 3 + 0.5], // 0.5 mm above the floor top (Z=3), within the (35,25) standoff's footprint: confirms the standoff is fused to the floor, not floating\n ],\n probesOutsideSolid: [\n [0, 0, 15], // open interior cavity, away from standoffs: confirms the box is hollow, not solid\n [35, 25, 15 - 8 / 2], // blind hole at the (35,25) standoff: top at Z=3+12=15, 8 mm deep -> mid-depth Z=11\n [-35, 25, 15 - 8 / 2], // blind hole at the (-35,25) standoff, dead center\n [35, -25, 15 - 8 / 2], // blind hole at the (35,-25) standoff, dead center\n [-35, -25, 15 - 8 / 2], // blind hole at the (-35,-25) standoff, dead center\n [35 + 0.5, 25, 15 - 8 / 2], // 1 mm inside the (35,25) hole's 1.5 mm radius\n ],\n },\n },\n {\n id: 'clevis-bracket-lightening-cutouts',\n source: 'benchmarks/06-clevis-bracket-lightening-cutouts.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The part is symmetric about the XZ plane. ' +\n 'Start with a base plate 120 mm long in X, 60 mm wide in Y, and 10 mm thick in Z, centered on the XY origin, with bottom face at Z = 0. ' +\n 'Add two vertical clevis lugs rising from the top of the base near the center. Each lug is 18 mm thick in Y, 42 mm tall above the base, and extends 36 mm along X. The two lugs are separated by a 16 mm central gap in Y. The top of each lug has a semicircular rounded profile with radius 18 mm when viewed from the side. ' +\n 'Add a horizontal through-hole of diameter 14 mm through both lugs along the Y direction, centered at X = 0 and Z = 34 mm. ' +\n 'Add four base mounting holes, diameter 7 mm, through the base plate, located at X = +/-45 mm and Y = +/-20 mm. ' +\n 'Add two triangular lightening cutouts through the base web, one on each side of the clevis, each with rounded corners of radius 3 mm. ' +\n 'Add two diagonal reinforcing ribs from the base to the outer faces of the lugs, one on each side, thickness 6 mm. ' +\n 'Add 3 mm fillets to the base perimeter and 2 mm fillets at lug-to-base transitions.',\n spec: {\n // X: base 120 mm governs (lugs +/-18, ribs bounded by the lugs, both well inside).\n // Y: base 60 mm governs (lugs span 8..26 / -26..-8, inside the base's +/-30).\n // Z: base top at 10; lug is 42 mm tall total (36 mm X-width -> the stated\n // 18 mm cap radius = half that width, so the 42 mm figure already includes\n // the rounded top) -> lug top at 10+42=52.\n bbox: { x: [119, 121], y: [59, 61], z: [51, 53] },\n // Volume OMITTED: the two triangular lightening cutouts have no stated\n // size (only \"rounded corners radius 3 mm\" and \"one on each side\"), and\n // the two reinforcing ribs give only a thickness (6 mm), not a length or\n // height. Both features materially remove/add volume by an unbounded\n // amount, so no closed-form band is honest here.\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n // 8.5 mm past the clevis hole's 7 mm radius (r+1.5), offset in Z, inside\n // the lug's rounded cap (Z=34 is the semicircle's flat base at the lug's\n // straight-to-round transition; 34+8.5=42.5 is within the cap, |X|<~15.9 there).\n [0, 17, 34 + 8.5],\n [45, 20 + 3.5 + 1.5, 5], // 5 mm past the (45,20) mounting hole's 3.5 mm radius (r+1.5): inside the base plate\n ],\n probesOutsideSolid: [\n [0, 17, 34], // clevis hole, dead center (positive-Y lug, mid-thickness Y=17 of the 8..26 lug)\n [0, -17, 34], // clevis hole, dead center (negative-Y lug, mid-thickness Y=-17)\n [0, 17, 34 + 6], // 1 mm inside the clevis hole's 7 mm radius (r-1), offset in Z\n [45, 20, 5], // (45,20) mounting hole, dead center, mid-thickness\n [-45, 20, 5], // (-45,20) mounting hole, dead center\n [45, -20, 5], // (45,-20) mounting hole, dead center\n [-45, -20, 5], // (-45,-20) mounting hole, dead center\n [45, 20 + 3.5 - 1, 5], // 1 mm inside the (45,20) hole's 3.5 mm radius (r-1)\n ],\n // Lightening-cutout and rib probes omitted: neither feature has a stated\n // position or size beyond \"one on each side\" / a single thickness, so no\n // point can be placed with confidence it lands inside or outside either.\n },\n },\n {\n id: 'radial-engine-cylinder',\n source: 'benchmarks/07-radial-engine-cylinder.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The main cylinder axis is vertical along Z and centered at the origin. ' +\n 'Create a central barrel with diameter 36 mm and height 70 mm, bottom at Z = 0. ' +\n 'Around the barrel, add 12 horizontal circular cooling fins. Each fin is 2 mm thick in Z, has outside diameter 62 mm, and is spaced every 5 mm from Z = 10 mm to Z = 65 mm. ' +\n 'Add a thicker base flange at the bottom, outside diameter 70 mm and thickness 8 mm, with six vertical mounting holes of diameter 5 mm on a 56 mm bolt circle. ' +\n 'Add a top cap cylinder, diameter 44 mm and height 8 mm, from Z = 70 mm to Z = 78 mm. ' +\n 'Add an angled spark-plug boss protruding from the side of the top cap. The boss is a cylinder of diameter 12 mm and length 24 mm, angled upward at 35 degrees from horizontal, with its axis pointing outward in the positive X direction. ' +\n 'Add a 5 mm diameter hole through the boss along its own axis. ' +\n 'Add small 1 mm fillets to the outer fin edges and base flange edges.',\n spec: {\n // Y is unaffected by the boss (boss points only in +X): widest rotational\n // feature is the base flange, OD 70 mm.\n // X and Z OMITTED: the boss (12 mm dia, 24 mm long, 35 deg up, +X) has no\n // stated root position along the top cap (only \"protruding from the side\"),\n // so how far it extends past the cap's OD=44 (X) and how high its tip\n // rises past the cap top at Z=78 (Z) both depend on an unstated embedding\n // depth -- not closed-form derivable.\n bbox: { y: [69, 71] },\n // Volume OMITTED: same boss-root ambiguity makes the boss's net\n // contribution (external protrusion minus embedded overlap minus its own\n // 5 mm bore, intersected at an angle with the cap's curved surface) not\n // closed-form. The rotational-body-only components (barrel 71251.32 +\n // 12 fins 48028.67 + flange-net 21702.12 + cap 12164.25 = 153146.36) are\n // well defined but omitting the boss would silently mis-grade any correct\n // model, so the whole field is left unset rather than partially asserted.\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [0, 0, 35], // barrel core, on-axis, mid-height (0..70) -- barrel has no bore\n [22, 0, 4], // flange material at r=22 (between barrel r=18 and the 56 mm bolt-circle band r=25.5..30.5), mid-thickness (0..8)\n [33, 0, 4], // flange material at r=33 (between the bolt-circle band and OD 35), mid-thickness\n [0, 0, 74], // top cap core, on-axis, mid-height (70..78) -- away from the boss, which emerges from the cap's side, not its axis\n [18 - 1, 0, 12 + 1.5], // 1 mm inside the barrel's 18 mm radius, at Z=13.5 -- the gap between fin 1 (Z=10..12) and fin 2 (Z=15..17), where only the barrel itself can be present\n ],\n probesOutsideSolid: [\n [18 + 1, 0, 12 + 1.5], // 1 mm beyond the barrel's 18 mm radius, same fin-gap Z=13.5: confirms the barrel does not bulge past its stated 36 mm diameter (fins only exist in their own 2 mm Z-slices, not this gap)\n ],\n // No further probesOutsideSolid: the 6 base-flange mounting holes have a\n // pinned radius (28 mm) and count (6) but no stated starting angle (same\n // ambiguity as task 02's bolt circle), and the boss's own 5 mm bore sits\n // at an unstated root position on the cap. Neither has a fully pinned\n // XYZ location to probe.\n },\n },\n {\n id: 'centrifugal-impeller',\n source: 'benchmarks/08-centrifugal-impeller.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The impeller axis is vertical along Z and centered at the origin. ' +\n 'Add a circular backplate disk with outside diameter 90 mm and thickness 6 mm, with its bottom face at Z = 0. ' +\n 'Add a central hub cylinder on top of the backplate, diameter 26 mm and height 22 mm above the backplate. ' +\n 'Add a vertical through-bore of diameter 8 mm through the entire part. ' +\n 'Add 12 identical backward-curved blades on top of the backplate, equally spaced around the hub. Each blade begins at radius 18 mm and ends at radius 43 mm. Each blade is 3 mm thick, 16 mm tall above the backplate, and curves backward by approximately 45 degrees from root to tip. The blade tips should lean opposite the direction of rotation when viewed from above. ' +\n 'Add 1 mm fillets at the blade roots where they meet the backplate and hub. Add a 1.5 mm fillet to the top and bottom outer circular edges of the backplate.',\n spec: {\n // X/Y: backplate OD 90 mm is the widest feature (blade tips reach only\n // r=43 -> diameter 86). Z: backplate top at 6, hub top at 6+22=28, which\n // exceeds the blades' top at 6+16=22 -> hub governs the overall height.\n bbox: { x: [89, 91], y: [89, 91], z: [27, 29] },\n // Volume OMITTED (named directly in the task rules as an omit example):\n // the 12 blades are specified only by start/end radius, thickness, and an\n // \"approximately 45 degrees\" backward curve -- no exact swept-path or\n // cross-section profile is given, so their volume is not closed-form.\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [4 + 1.5, 0, 14], // 1.5 mm past the 4 mm through-bore radius (r+1.5), inside the hub\n [10, 0, 15], // hub material (r=10, within the hub's 13 mm radius), away from the bore and the blade root region (blades begin at r=18)\n [30, 0, 3], // backplate material, mid-thickness (Z=0..6), r=30 -- below blade start height (Z=6), safe regardless of blade shape\n ],\n probesOutsideSolid: [\n [0, 0, 14], // through-bore, dead center, mid-height (bore runs the full 0..28 part height)\n [4 - 1, 0, 14], // 1 mm inside the bore's 4 mm radius (r-1)\n ],\n // Blade probes omitted: the curved sweep path between the stated start\n // (r18) and end (r43) radii is only qualitatively described (\"approximately\n // 45 degrees\"), so no exact in/out point on a blade is derivable.\n },\n },\n {\n id: 'spiral-staircase',\n source: 'benchmarks/09-spiral-staircase.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The staircase is centered on the origin and rises along Z. ' +\n 'Add a central vertical column, diameter 14 mm and height 140 mm, with its bottom at Z = 0. ' +\n 'Add 20 identical wedge-shaped stair treads arranged helically around the column. Each tread is 4 mm thick, has an inner radius of 10 mm, an outer radius of 62 mm, and subtends 24 degrees in plan view. The first tread is at Z = 4 mm, and each subsequent tread rises by 6 mm and rotates by 18 degrees around Z. ' +\n 'Add a helical outer handrail tube of diameter 5 mm following radius 66 mm, starting at Z = 14 mm and ending at Z = 130 mm, making one full revolution around the staircase. ' +\n 'Add 20 vertical balusters, each diameter 3 mm, connecting the outer end of each tread to the handrail. ' +\n 'Add a circular base disk, diameter 90 mm and thickness 5 mm.',\n spec: {\n // Widest reach is the handrail TUBE's outer surface: centerline radius 66\n // + tube radius 2.5 = 68.5 -> diameter 137. (Base disk OD 90 and tread OD\n // 124 are both smaller.)\n // Z OMITTED: the base disk (diameter 90, thickness 5) has no stated Z\n // position -- unlike every other feature in this part, its placement\n // relative to the column's Z=0 bottom is never given. Column-top-only\n // height is 140; if the disk sits fully below Z=0 the total is 145 --\n // a 5 mm (3.6%) swing with no textual basis to pick one, so left unset.\n bbox: { x: [136, 138], y: [136, 138] },\n // Volume OMITTED (named directly in the task rules as an omit example):\n // helical wedge treads, a helical handrail sweep, and angled balusters\n // have no closed-form solid-of-revolution/extrusion formula from radii\n // and angles alone.\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [0, 0, 70], // central column, on-axis, mid-height (0..140) -- unambiguous regardless of tread/handrail/baluster placement\n [7 - 1, 0, 70], // 1 mm inside the column's 7 mm radius: confirms the column reaches its stated 14 mm diameter\n ],\n probesOutsideSolid: [\n // 1 mm beyond the column's 7 mm radius, same height: treads never reach\n // this radius (their stated inner radius is 10 mm, a fixed 3 mm gap from\n // the column regardless of Z), so this is safely open air at any Z.\n [7 + 1, 0, 70],\n ],\n // No hole/bore/pocket is stated for this part otherwise -- it is purely\n // additive (column, treads, handrail, balusters, base disk).\n },\n },\n {\n id: 'planetary-gear-stage',\n source: 'benchmarks/10-planetary-gear-stage.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE_MULTIBODY}\\n\\n` +\n 'The assembly lies flat in the XY plane with gear axes along Z. Use separate solid bodies for the sun gear, three planet gears, ring gear, carrier plate, and three planet pins. ' +\n 'All gears are 8 mm thick. Use simplified straight-sided trapezoidal teeth rather than true involute teeth. ' +\n 'The sun gear has 24 external teeth, pitch diameter 48 mm, root diameter 42 mm, and outside diameter 54 mm. ' +\n 'The three planet gears each have 18 external teeth, pitch diameter 36 mm, root diameter 31 mm, and outside diameter 41 mm. Place the planet gear centers on a 42 mm radius circle, equally spaced every 120 degrees. ' +\n 'The ring gear is concentric with the sun gear, has 60 internal teeth, internal pitch diameter 120 mm, internal root diameter 126 mm, internal tooth-tip diameter 114 mm, and outside diameter 140 mm. ' +\n 'Add a thin circular carrier plate below the gears, diameter 105 mm and thickness 4 mm, located from Z = -5 mm to Z = -1 mm. ' +\n 'Add three vertical planet pins, each diameter 6 mm and height 14 mm, centered under the planet gears. ' +\n 'Add a central sun bore of diameter 10 mm.',\n spec: {\n // This task uses DELIVERABLE_MULTIBODY, not the single-solid boilerplate:\n // the two are contradictory here (the part's own text says \"Use separate\n // solid bodies for...\"), and solids below is the upstream checklist's\n // explicit nine-body requirement, which no fused answer can satisfy.\n //\n // X/Y: ring gear OD 140 mm is the widest feature (planet reach = 42\n // (center radius) + 20.5 (planet outside radius) = 62.5 -> dia 125, smaller).\n bbox: { x: [139, 141], y: [139, 141] },\n // Z OMITTED: only the carrier plate has an explicit Z range (-5..-1).\n // The pin height (14 mm) strongly suggests pins bridge carrier-top to\n // gear-bottom (-1 -> 13, gears then spanning 13..21), since spacing the\n // gears above the carrier is the pin's whole mechanical purpose -- but\n // the prompt never states pins rest flush on the carrier or that gears\n // rest flush on the pins, so this is inference, not a pinned value.\n //\n // Volume OMITTED (gear teeth named directly in the task rules as an omit\n // example): trapezoidal tooth width/profile is not given beyond pitch/\n // root/outside diameters and tooth count, and the Z-stacking ambiguity\n // above compounds it for 8 of the 9 bodies.\n solids: [9, 9], // sun(1) + 3 planets + ring(1) + carrier(1) + 3 pins = 9, per the checklist's explicit body count\n minTriangles: 100,\n probesInsideSolid: [\n [40, 0, -3], // carrier plate material, mid-thickness (Z=-5..-1), r=40 (within its 52.5 mm radius) -- the only body with a fully pinned Z range\n [105 / 2 - 1, 0, -3], // 1 mm inside the carrier's 52.5 mm radius (105 mm OD): confirms the carrier reaches its stated diameter\n ],\n probesOutsideSolid: [\n // 1 mm beyond the carrier's 52.5 mm radius, same mid-thickness Z: the\n // prompt states the carrier plate is \"below the gears,\" so nothing\n // else in the assembly can occupy Z=-3 at any radius.\n [105 / 2 + 1, 0, -3],\n ],\n // No further probesOutsideSolid: the sun bore and every other gear-body\n // feature sit at a Z height that depends on the carrier/pin stacking\n // inference above, which the prompt does not state numerically. Planet\n // gear centers ARE derivable in XY (radius 42, 120 deg spacing ->\n // (42,0), (42*cos120, 42*sin120)=(-21, 36.37), (-21,-36.37))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IAAG;GAAE,CACrB;GACA,oBAAoB,CAIlB;IAAC;IAAa;IAAG;GAAE,CACrB;EAOF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"mcad-tasks.js","names":["DELIVERABLE_MULTIBODY"],"sources":["../../src/benchmarks/mcad-tasks.ts"],"sourcesContent":["/**\n * MCAD task specs — 10 dimensioned mechanical parts adopted from the MIT-licensed\n * text-to-cad benchmark set (github.com/earthtojake/text-to-cad, `benchmarks/`).\n *\n * Upstream ships each part as a prompt plus a human checklist (\"four through-holes,\n * 8 mm each; no floating gussets\") with NO grader. This file is the machine-checkable\n * form: every assertion below is derivable in closed form from the upstream prompt,\n * and every derivation is shown in a comment beside its number. An assertion that\n * cannot be derived in closed form is OMITTED, never guessed — the judge only\n * asserts what the prompt actually pins.\n *\n * FORMAT DEVIATION, stated once: upstream asks for STEP export. The v1 judge\n * compiles OpenSCAD and grades the STL mesh (same judge deps as `cad-design`);\n * OpenSCAD cannot emit STEP. The geometric content of every check is preserved;\n * the \"STEP imports\" row is replaced by \"compiles + watertight\". Tasks keep the\n * upstream dimensional text verbatim inside an OpenSCAD-deliverable wrapper.\n *\n * Probes are the hole/pocket checks: a point the finished solid must NOT contain\n * (inside a hole bore) or MUST contain (in the surrounding material). Locations\n * come from the prompt's own dimensions, with clearance chosen so a hole that is\n * missing, misplaced by more than ~1 mm, or wrong in diameter by more than ~1 mm\n * flips at least one probe.\n */\n\nexport interface McadSpec {\n /** Overall axis-aligned extents in mm, [min, max] per axis. */\n bbox?: { x?: [number, number]; y?: [number, number]; z?: [number, number] }\n /** Enclosed mesh volume band in mm^3 — closed-form only, derivation in a comment. */\n volume?: [number, number]\n /** Disconnected-solid count band (fused parts must read as ONE solid). */\n solids?: [number, number]\n /** Triangle floor — rejects degenerate single-box answers where relevant. */\n minTriangles?: number\n /** Points (mm) that must test INSIDE the solid (material present). */\n probesInsideSolid?: Array<[number, number, number]>\n /** Points (mm) that must test OUTSIDE the solid (hole/pocket/clearance present). */\n probesOutsideSolid?: Array<[number, number, number]>\n}\n\nexport interface McadTask {\n id: string\n /** Upstream dimensional brief, verbatim, wrapped for the OpenSCAD deliverable. */\n prompt: string\n spec: McadSpec\n /** Upstream file this was adopted from. */\n source: string\n /** False when the spec has no verified gold yet — the judge still runs, but the\n * accept direction is uncalibrated and the loader surfaces that in metadata. */\n calibrated: boolean\n}\n\n/** Exported so a sibling adapter can SWAP this preamble for its own deliverable\n * (see `mcad-cq-bench.ts`) by prefix, instead of re-authoring ten prompts and\n * letting the two copies drift. The upstream dimensional text stays the tail. */\nexport const MCAD_DELIVERABLE =\n 'Author OpenSCAD source (units: mm) that builds exactly this part as one fused solid. ' +\n 'Reply with ONLY the OpenSCAD code. Use $fn=96 or finer for round features.'\n\nconst DELIVERABLE = MCAD_DELIVERABLE\n\n/** Task 10 is an ASSEMBLY, not a part: its own text says \"use separate solid bodies\"\n * and its checklist pins nine of them, which the single-solid boilerplate above\n * flatly contradicts. A worker cannot satisfy both, so that task gets this\n * preamble instead; everything else about the deliverable is unchanged. */\nexport const MCAD_DELIVERABLE_MULTIBODY =\n 'Author OpenSCAD source (units: mm) that builds exactly this assembly as the separate ' +\n 'solid bodies listed below. The bodies must stay disjoint — no two of them may touch or ' +\n 'intersect. Reply with ONLY the OpenSCAD code. Use $fn=96 or finer for round features.'\n\nconst DELIVERABLE_MULTIBODY = MCAD_DELIVERABLE_MULTIBODY\n\nexport const MCAD_TASKS: McadTask[] = [\n {\n id: 'calibration-block',\n source: 'benchmarks/01-rectangular-calibration-block.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The part is a rectangular block, 100 mm long in X, 60 mm wide in Y, and 20 mm tall in Z. ' +\n 'Center the block on the XY origin, with the bottom face at Z = 0. ' +\n 'Add four vertical through-holes, each 8 mm in diameter, located at X = +/-35 mm and Y = +/-20 mm. ' +\n 'Add a 2 mm chamfer to the top perimeter edges only. Do not chamfer the holes.',\n spec: {\n bbox: { x: [99, 101], y: [59, 61], z: [19, 21] },\n // block 100*60*20 = 120000; holes 4 * pi * 4^2 * 20 = 4021.2;\n // top-perimeter 2 mm chamfer ~ (2*2/2) * perimeter(320) - corners ~ 620..640.\n // exact-ish 115340; band allows +-1% modelling slack but excludes\n // no-chamfer (115979) ONLY via the upper edge staying below it? No -\n // 115979 is within 1%; the chamfer is NOT volume-separable at this size,\n // so the band checks holes+block and the chamfer stays unasserted.\n volume: [113_000, 117_000],\n solids: [1, 1],\n probesInsideSolid: [\n [0, 0, 10], // core material between the holes\n [48, 28, 10], // corner material\n [35, 20 + 5.5, 10], // 5.5 mm off a hole center: outside an 8 mm bore, inside the block\n ],\n probesOutsideSolid: [\n [35, 20, 10], // each 8 mm bore, probed at mid-depth\n [-35, 20, 10],\n [35, -20, 10],\n [-35, -20, 10],\n [35, 20 + 3.0, 10], // 3.0 mm off center: still inside a 4 mm-radius bore\n ],\n },\n },\n {\n id: 'circular-flange',\n source: 'benchmarks/02-circular-flange.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The flange is a cylinder with an outside diameter of 80 mm and a thickness of 10 mm. ' +\n 'Its axis is vertical along Z, with the bottom face at Z = 0 and the center at X = 0, Y = 0. ' +\n 'Add a central vertical through-bore with diameter 30 mm. ' +\n 'Add six equally spaced vertical through-holes, each 6 mm in diameter, on a 60 mm bolt-circle diameter. ' +\n 'Add a 1.5 mm fillet to the top and bottom outside circular edges.',\n spec: {\n // OD 80 -> radius 40; thickness 10.\n bbox: { x: [79, 81], y: [79, 81], z: [9, 11] },\n // cylinder pi*40^2*10 = 50265.48; central bore pi*15^2*10 = 7068.58;\n // 6 bolt holes 6*pi*3^2*10 = 1696.46; net 41500.44.\n // top+bottom 1.5 mm fillet on the OD removes ~2*(1-pi/4)*1.5^2*(pi*80)\n // = ~242.7 (0.6%), well inside a +-3% band, so it stays unasserted here.\n volume: [40_250, 42_750],\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [22, 0, 5], // core material between the 30 mm bore and the 60 mm bolt circle\n [15 + 1.5, 0, 5], // 1.5 mm past the 15 mm bore radius: inside material\n ],\n probesOutsideSolid: [\n [0, 0, 5], // central bore, dead center, mid-thickness\n [15 - 1, 0, 5], // 1 mm inside the 15 mm bore radius: still inside the bore\n ],\n // The 6 bolt holes have a pinned radius (30 mm) and count (6) but no stated\n // starting angle, so their exact XY centers are not derivable; any global\n // rotation of the pattern is a valid answer. Omitted rather than guessed.\n },\n },\n {\n id: 'l-bracket',\n source: 'benchmarks/03-l-bracket.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The bracket has a horizontal base plate 80 mm long in X, 50 mm wide in Y, and 8 mm thick in Z. Center the base plate on the XY origin, with its bottom at Z = 0. ' +\n 'Add a vertical back plate along the rear long edge of the base. The back plate is 80 mm long in X, 8 mm thick in Y, and 50 mm tall in Z, rising from the top of the base plate. The back plate should sit along the rear edge at positive Y. ' +\n 'Add two vertical through-holes in the base plate, each 6 mm in diameter, located at X = +/-25 mm and Y = -10 mm. ' +\n 'Add two horizontal through-holes in the vertical plate, each 6 mm in diameter, located at X = +/-25 mm and Z = 30 mm, passing through the 8 mm thickness of the vertical plate. ' +\n 'Add two triangular gussets, each 8 mm thick in X, located at X = +/-20 mm. Each gusset should connect the base plate to the back plate with a right-triangle side profile 30 mm tall and 30 mm deep. ' +\n 'Add 2 mm fillets to the outside corner where the base and back plate meet.',\n spec: {\n // X: both plates are 80 mm long, gussets sit within +/-24 -> base governs.\n // Y: base is 50 mm wide (-25..25); back plate (8 mm thick) hugs the rear\n // edge, occupying Y=17..25 (flush at Y=25), inside the base's Y range.\n // Z: base bottom 0, base top 8; back plate rises 50 mm from there -> top 58.\n bbox: { x: [79, 81], y: [49, 51], z: [57, 59] },\n // base 80*50*8=32000 - 2 holes(pi*3^2*8=452.39) = 31547.61\n // back 80*8*50=32000 - 2 holes(452.39) = 31547.61\n // 2 gussets: right triangle 30x30 * 8 mm thick = 0.5*30*30*8=3600 each -> 7200\n // sum 70295.22; the two plates occupy disjoint Z ranges (0-8 vs 8-58), no\n // volume overlap. A 2 mm fillet on the one outside X-running corner edge\n // (length 80) removes ~(1-pi/4)*2^2*80=68.7 (0.1%), folded into the band.\n volume: [68_200, 72_400],\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [0, 0, 4], // base plate core, away from both base holes (X=+/-25, Y=-10)\n [0, 21, 30], // back plate core (mid-Y-thickness 17..25), away from both back holes\n [25, -10 + 4.5, 4], // 4.5 mm past the base hole's 3 mm radius (r+1.5): inside material\n [25, 21, 30 + 4.5], // 4.5 mm past the back hole's 3 mm radius (r+1.5), offset in Z: inside material\n ],\n probesOutsideSolid: [\n [25, -10, 4], // base hole (X=25, Y=-10), dead center, mid-thickness\n [-25, -10, 4], // base hole (X=-25, Y=-10), dead center\n [25, -10 + 2, 4], // 1 mm inside the base hole's 3 mm radius (r-1)\n [25, 21, 30], // back hole (X=25, Z=30), dead center, mid-Y-thickness\n [-25, 21, 30], // back hole (X=-25, Z=30), dead center\n [25, 21, 30 + 2], // 1 mm inside the back hole's 3 mm radius (r-1), offset in Z\n ],\n },\n },\n {\n id: 'stepped-shaft-keyway',\n source: 'benchmarks/04-stepped-shaft-keyway.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The shaft axis runs along X. The total length is 120 mm. The left end center is at X = 0, Y = 0, Z = 0. ' +\n 'From X = 0 to X = 30, the shaft diameter is 20 mm. From X = 30 to X = 90, the shaft diameter is 30 mm. From X = 90 to X = 120, the shaft diameter is 20 mm. ' +\n 'Add a 1 mm chamfer to both end edges. ' +\n 'Add a rectangular keyway slot on the top of the 30 mm diameter middle section. The keyway is 6 mm wide in Y, 3 mm deep in Z, and runs from X = 40 to X = 80.',\n spec: {\n // length 0..120; widest section is the 30 mm-diameter middle (radius 15).\n bbox: { x: [119, 121], y: [29, 31], z: [29, 31] },\n // 3 segments on-axis (Y=0,Z=0): pi*10^2*30 + pi*15^2*60 + pi*10^2*30 = 61261.06\n // minus keyway 6*3*40=720 -> net 60541.06. End chamfers (1 mm, r=10 circles)\n // remove ~2*0.5*1^2*(2*pi*10)=62.8 (0.1%), folded into the band.\n // TIGHTENED band: a model that omits the keyway entirely would measure\n // 61261.06, only 1.19% above net -- inside a naive +-3% band. Upper bound\n // is pulled below 61261 to force that failure to read as a miss; probes\n // below also independently catch a keyway that is missing or too shallow.\n volume: [59_700, 61_050],\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [15, 0, 0], // on-axis material, left 20 mm-diameter section\n [60, 0, 0], // on-axis material, middle section, far from the keyway (which is at Z=12..15)\n [105, 0, 0], // on-axis material, right 20 mm-diameter section\n [60, 3 + 1.5, 15 - 1.5], // 1.5 mm past the keyway's 3 mm half-width (assumed centered on Y=0): inside the 30 mm section\n [60, 0, 15 - 3 - 2], // 2 mm below the keyway floor (Z = 15-3 = 12): shaft material intact beneath the slot\n ],\n probesOutsideSolid: [\n [60, 0, 15 - 1.5], // keyway void, X-midpoint of the 40..80 run, mid-depth between floor (Z=12) and top (Z=15)\n [60, 3 - 1, 15 - 1.5], // 1 mm inside the keyway's 3 mm half-width: still within the 6 mm-wide slot\n ],\n },\n },\n {\n id: 'open-top-electronics-enclosure',\n source: 'benchmarks/05-open-top-electronics-enclosure.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The outer shape is a rectangular box 100 mm long in X, 70 mm wide in Y, and 30 mm tall in Z. Center it on the XY origin, with the bottom face at Z = 0. ' +\n 'The enclosure is open at the top. The wall thickness is 3 mm and the bottom floor thickness is 3 mm. ' +\n 'Add four internal cylindrical standoffs rising from the inside floor. Each standoff has an outside diameter of 10 mm and a height of 12 mm above the inside floor. Place the standoffs at X = +/-35 mm and Y = +/-25 mm. ' +\n 'Add a centered blind hole in each standoff, 3 mm in diameter and 8 mm deep from the top of the standoff. ' +\n 'Add 2 mm radius fillets to the four outside vertical corners of the enclosure.',\n spec: {\n bbox: { x: [99, 101], y: [69, 71], z: [29, 31] },\n // outer box 100*70*30=210000; interior cavity (94 x 64 footprint, open\n // top, floor top at Z=3) is 94*64*27=162432; shell = 47568.\n // 4 standoffs (OD10 r5, h12 above floor): 4*pi*5^2*12=3769.91.\n // 4 blind holes (d3 r1.5, 8 mm deep from standoff top): 4*pi*1.5^2*8=226.19.\n // net 47568 + 3769.91 - 226.19 = 51111.72. 4 corner fillets (r2, full\n // 30 mm height) remove ~4*(1-pi/4)*2^2*30=103.0 (0.2%), folded into band.\n volume: [49_600, 52_650],\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [0, 0, 3 / 2], // floor slab, mid-thickness (Z=0..3), away from all standoffs\n [50 - 3 / 2, 0, 15], // +X wall material, mid-wall-thickness (47..50), mid-height\n [35 + 1.5 + 1.5, 25, 15 - 8 / 2], // 1.5 mm past the (35,25) standoff's 1.5 mm blind-hole radius (r+1.5): inside the standoff (OD10, r5)\n [35, 25, 3 + 0.5], // 0.5 mm above the floor top (Z=3), within the (35,25) standoff's footprint: confirms the standoff is fused to the floor, not floating\n ],\n probesOutsideSolid: [\n [0, 0, 15], // open interior cavity, away from standoffs: confirms the box is hollow, not solid\n [35, 25, 15 - 8 / 2], // blind hole at the (35,25) standoff: top at Z=3+12=15, 8 mm deep -> mid-depth Z=11\n [-35, 25, 15 - 8 / 2], // blind hole at the (-35,25) standoff, dead center\n [35, -25, 15 - 8 / 2], // blind hole at the (35,-25) standoff, dead center\n [-35, -25, 15 - 8 / 2], // blind hole at the (-35,-25) standoff, dead center\n [35 + 0.5, 25, 15 - 8 / 2], // 1 mm inside the (35,25) hole's 1.5 mm radius\n ],\n },\n },\n {\n id: 'clevis-bracket-lightening-cutouts',\n source: 'benchmarks/06-clevis-bracket-lightening-cutouts.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The part is symmetric about the XZ plane. ' +\n 'Start with a base plate 120 mm long in X, 60 mm wide in Y, and 10 mm thick in Z, centered on the XY origin, with bottom face at Z = 0. ' +\n 'Add two vertical clevis lugs rising from the top of the base near the center. Each lug is 18 mm thick in Y, 42 mm tall above the base, and extends 36 mm along X. The two lugs are separated by a 16 mm central gap in Y. The top of each lug has a semicircular rounded profile with radius 18 mm when viewed from the side. ' +\n 'Add a horizontal through-hole of diameter 14 mm through both lugs along the Y direction, centered at X = 0 and Z = 34 mm. ' +\n 'Add four base mounting holes, diameter 7 mm, through the base plate, located at X = +/-45 mm and Y = +/-20 mm. ' +\n 'Add two triangular lightening cutouts through the base web, one on each side of the clevis, each with rounded corners of radius 3 mm. ' +\n 'Add two diagonal reinforcing ribs from the base to the outer faces of the lugs, one on each side, thickness 6 mm. ' +\n 'Add 3 mm fillets to the base perimeter and 2 mm fillets at lug-to-base transitions.',\n spec: {\n // X: base 120 mm governs (lugs +/-18, ribs bounded by the lugs, both well inside).\n // Y: base 60 mm governs (lugs span 8..26 / -26..-8, inside the base's +/-30).\n // Z: base top at 10; lug is 42 mm tall total (36 mm X-width -> the stated\n // 18 mm cap radius = half that width, so the 42 mm figure already includes\n // the rounded top) -> lug top at 10+42=52.\n bbox: { x: [119, 121], y: [59, 61], z: [51, 53] },\n // Volume OMITTED: the two triangular lightening cutouts have no stated\n // size (only \"rounded corners radius 3 mm\" and \"one on each side\"), and\n // the two reinforcing ribs give only a thickness (6 mm), not a length or\n // height. Both features materially remove/add volume by an unbounded\n // amount, so no closed-form band is honest here.\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n // 8.5 mm past the clevis hole's 7 mm radius (r+1.5), offset in Z, inside\n // the lug's rounded cap (Z=34 is the semicircle's flat base at the lug's\n // straight-to-round transition; 34+8.5=42.5 is within the cap, |X|<~15.9 there).\n [0, 17, 34 + 8.5],\n [45, 20 + 3.5 + 1.5, 5], // 5 mm past the (45,20) mounting hole's 3.5 mm radius (r+1.5): inside the base plate\n ],\n probesOutsideSolid: [\n [0, 17, 34], // clevis hole, dead center (positive-Y lug, mid-thickness Y=17 of the 8..26 lug)\n [0, -17, 34], // clevis hole, dead center (negative-Y lug, mid-thickness Y=-17)\n [0, 17, 34 + 6], // 1 mm inside the clevis hole's 7 mm radius (r-1), offset in Z\n [45, 20, 5], // (45,20) mounting hole, dead center, mid-thickness\n [-45, 20, 5], // (-45,20) mounting hole, dead center\n [45, -20, 5], // (45,-20) mounting hole, dead center\n [-45, -20, 5], // (-45,-20) mounting hole, dead center\n [45, 20 + 3.5 - 1, 5], // 1 mm inside the (45,20) hole's 3.5 mm radius (r-1)\n ],\n // Lightening-cutout and rib probes omitted: neither feature has a stated\n // position or size beyond \"one on each side\" / a single thickness, so no\n // point can be placed with confidence it lands inside or outside either.\n },\n },\n {\n id: 'radial-engine-cylinder',\n source: 'benchmarks/07-radial-engine-cylinder.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The main cylinder axis is vertical along Z and centered at the origin. ' +\n 'Create a central barrel with diameter 36 mm and height 70 mm, bottom at Z = 0. ' +\n 'Around the barrel, add 12 horizontal circular cooling fins. Each fin is 2 mm thick in Z, has outside diameter 62 mm, and is spaced every 5 mm from Z = 10 mm to Z = 65 mm. ' +\n 'Add a thicker base flange at the bottom, outside diameter 70 mm and thickness 8 mm, with six vertical mounting holes of diameter 5 mm on a 56 mm bolt circle. ' +\n 'Add a top cap cylinder, diameter 44 mm and height 8 mm, from Z = 70 mm to Z = 78 mm. ' +\n 'Add an angled spark-plug boss protruding from the side of the top cap. The boss is a cylinder of diameter 12 mm and length 24 mm, angled upward at 35 degrees from horizontal, with its axis pointing outward in the positive X direction. ' +\n 'Add a 5 mm diameter hole through the boss along its own axis. ' +\n 'Add small 1 mm fillets to the outer fin edges and base flange edges.',\n spec: {\n // Y is unaffected by the boss (boss points only in +X): widest rotational\n // feature is the base flange, OD 70 mm.\n // X and Z OMITTED: the boss (12 mm dia, 24 mm long, 35 deg up, +X) has no\n // stated root position along the top cap (only \"protruding from the side\"),\n // so how far it extends past the cap's OD=44 (X) and how high its tip\n // rises past the cap top at Z=78 (Z) both depend on an unstated embedding\n // depth -- not closed-form derivable.\n bbox: { y: [69, 71] },\n // Volume OMITTED: same boss-root ambiguity makes the boss's net\n // contribution (external protrusion minus embedded overlap minus its own\n // 5 mm bore, intersected at an angle with the cap's curved surface) not\n // closed-form. The rotational-body-only components (barrel 71251.32 +\n // 12 fins 48028.67 + flange-net 21702.12 + cap 12164.25 = 153146.36) are\n // well defined but omitting the boss would silently mis-grade any correct\n // model, so the whole field is left unset rather than partially asserted.\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [0, 0, 35], // barrel core, on-axis, mid-height (0..70) -- barrel has no bore\n [22, 0, 4], // flange material at r=22 (between barrel r=18 and the 56 mm bolt-circle band r=25.5..30.5), mid-thickness (0..8)\n [33, 0, 4], // flange material at r=33 (between the bolt-circle band and OD 35), mid-thickness\n [0, 0, 74], // top cap core, on-axis, mid-height (70..78) -- away from the boss, which emerges from the cap's side, not its axis\n [18 - 1, 0, 12 + 1.5], // 1 mm inside the barrel's 18 mm radius, at Z=13.5 -- the gap between fin 1 (Z=10..12) and fin 2 (Z=15..17), where only the barrel itself can be present\n ],\n probesOutsideSolid: [\n [18 + 1, 0, 12 + 1.5], // 1 mm beyond the barrel's 18 mm radius, same fin-gap Z=13.5: confirms the barrel does not bulge past its stated 36 mm diameter (fins only exist in their own 2 mm Z-slices, not this gap)\n ],\n // No further probesOutsideSolid: the 6 base-flange mounting holes have a\n // pinned radius (28 mm) and count (6) but no stated starting angle (same\n // ambiguity as task 02's bolt circle), and the boss's own 5 mm bore sits\n // at an unstated root position on the cap. Neither has a fully pinned\n // XYZ location to probe.\n },\n },\n {\n id: 'centrifugal-impeller',\n source: 'benchmarks/08-centrifugal-impeller.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The impeller axis is vertical along Z and centered at the origin. ' +\n 'Add a circular backplate disk with outside diameter 90 mm and thickness 6 mm, with its bottom face at Z = 0. ' +\n 'Add a central hub cylinder on top of the backplate, diameter 26 mm and height 22 mm above the backplate. ' +\n 'Add a vertical through-bore of diameter 8 mm through the entire part. ' +\n 'Add 12 identical backward-curved blades on top of the backplate, equally spaced around the hub. Each blade begins at radius 18 mm and ends at radius 43 mm. Each blade is 3 mm thick, 16 mm tall above the backplate, and curves backward by approximately 45 degrees from root to tip. The blade tips should lean opposite the direction of rotation when viewed from above. ' +\n 'Add 1 mm fillets at the blade roots where they meet the backplate and hub. Add a 1.5 mm fillet to the top and bottom outer circular edges of the backplate.',\n spec: {\n // X/Y: backplate OD 90 mm is the widest feature (blade tips reach only\n // r=43 -> diameter 86). Z: backplate top at 6, hub top at 6+22=28, which\n // exceeds the blades' top at 6+16=22 -> hub governs the overall height.\n bbox: { x: [89, 91], y: [89, 91], z: [27, 29] },\n // Volume OMITTED (named directly in the task rules as an omit example):\n // the 12 blades are specified only by start/end radius, thickness, and an\n // \"approximately 45 degrees\" backward curve -- no exact swept-path or\n // cross-section profile is given, so their volume is not closed-form.\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [4 + 1.5, 0, 14], // 1.5 mm past the 4 mm through-bore radius (r+1.5), inside the hub\n [10, 0, 15], // hub material (r=10, within the hub's 13 mm radius), away from the bore and the blade root region (blades begin at r=18)\n [30, 0, 3], // backplate material, mid-thickness (Z=0..6), r=30 -- below blade start height (Z=6), safe regardless of blade shape\n ],\n probesOutsideSolid: [\n [0, 0, 14], // through-bore, dead center, mid-height (bore runs the full 0..28 part height)\n [4 - 1, 0, 14], // 1 mm inside the bore's 4 mm radius (r-1)\n ],\n // Blade probes omitted: the curved sweep path between the stated start\n // (r18) and end (r43) radii is only qualitatively described (\"approximately\n // 45 degrees\"), so no exact in/out point on a blade is derivable.\n },\n },\n {\n id: 'spiral-staircase',\n source: 'benchmarks/09-spiral-staircase.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE}\\n\\n` +\n 'The staircase is centered on the origin and rises along Z. ' +\n 'Add a central vertical column, diameter 14 mm and height 140 mm, with its bottom at Z = 0. ' +\n 'Add 20 identical wedge-shaped stair treads arranged helically around the column. Each tread is 4 mm thick, has an inner radius of 10 mm, an outer radius of 62 mm, and subtends 24 degrees in plan view. The first tread is at Z = 4 mm, and each subsequent tread rises by 6 mm and rotates by 18 degrees around Z. ' +\n 'Add a helical outer handrail tube of diameter 5 mm following radius 66 mm, starting at Z = 14 mm and ending at Z = 130 mm, making one full revolution around the staircase. ' +\n 'Add 20 vertical balusters, each diameter 3 mm, connecting the outer end of each tread to the handrail. ' +\n 'Add a circular base disk, diameter 90 mm and thickness 5 mm.',\n spec: {\n // Widest reach is the handrail TUBE's outer surface: centerline radius 66\n // + tube radius 2.5 = 68.5 -> diameter 137. (Base disk OD 90 and tread OD\n // 124 are both smaller.)\n // Z OMITTED: the base disk (diameter 90, thickness 5) has no stated Z\n // position -- unlike every other feature in this part, its placement\n // relative to the column's Z=0 bottom is never given. Column-top-only\n // height is 140; if the disk sits fully below Z=0 the total is 145 --\n // a 5 mm (3.6%) swing with no textual basis to pick one, so left unset.\n bbox: { x: [136, 138], y: [136, 138] },\n // Volume OMITTED (named directly in the task rules as an omit example):\n // helical wedge treads, a helical handrail sweep, and angled balusters\n // have no closed-form solid-of-revolution/extrusion formula from radii\n // and angles alone.\n solids: [1, 1],\n minTriangles: 100,\n probesInsideSolid: [\n [0, 0, 70], // central column, on-axis, mid-height (0..140) -- unambiguous regardless of tread/handrail/baluster placement\n [7 - 1, 0, 70], // 1 mm inside the column's 7 mm radius: confirms the column reaches its stated 14 mm diameter\n ],\n probesOutsideSolid: [\n // 1 mm beyond the column's 7 mm radius, same height: treads never reach\n // this radius (their stated inner radius is 10 mm, a fixed 3 mm gap from\n // the column regardless of Z), so this is safely open air at any Z.\n [7 + 1, 0, 70],\n ],\n // No hole/bore/pocket is stated for this part otherwise -- it is purely\n // additive (column, treads, handrail, balusters, base disk).\n },\n },\n {\n id: 'planetary-gear-stage',\n source: 'benchmarks/10-planetary-gear-stage.md',\n calibrated: true,\n prompt:\n `${DELIVERABLE_MULTIBODY}\\n\\n` +\n 'The assembly lies flat in the XY plane with gear axes along Z. Use separate solid bodies for the sun gear, three planet gears, ring gear, carrier plate, and three planet pins. ' +\n 'All gears are 8 mm thick. Use simplified straight-sided trapezoidal teeth rather than true involute teeth. ' +\n 'The sun gear has 24 external teeth, pitch diameter 48 mm, root diameter 42 mm, and outside diameter 54 mm. ' +\n 'The three planet gears each have 18 external teeth, pitch diameter 36 mm, root diameter 31 mm, and outside diameter 41 mm. Place the planet gear centers on a 42 mm radius circle, equally spaced every 120 degrees. ' +\n 'The ring gear is concentric with the sun gear, has 60 internal teeth, internal pitch diameter 120 mm, internal root diameter 126 mm, internal tooth-tip diameter 114 mm, and outside diameter 140 mm. ' +\n 'Add a thin circular carrier plate below the gears, diameter 105 mm and thickness 4 mm, located from Z = -5 mm to Z = -1 mm. ' +\n 'Add three vertical planet pins, each diameter 6 mm and height 14 mm, centered under the planet gears. ' +\n 'Add a central sun bore of diameter 10 mm.',\n spec: {\n // This task uses DELIVERABLE_MULTIBODY, not the single-solid boilerplate:\n // the two are contradictory here (the part's own text says \"Use separate\n // solid bodies for...\"), and solids below is the upstream checklist's\n // explicit nine-body requirement, which no fused answer can satisfy.\n //\n // X/Y: ring gear OD 140 mm is the widest feature (planet reach = 42\n // (center radius) + 20.5 (planet outside radius) = 62.5 -> dia 125, smaller).\n bbox: { x: [139, 141], y: [139, 141] },\n // Z OMITTED: only the carrier plate has an explicit Z range (-5..-1).\n // The pin height (14 mm) strongly suggests pins bridge carrier-top to\n // gear-bottom (-1 -> 13, gears then spanning 13..21), since spacing the\n // gears above the carrier is the pin's whole mechanical purpose -- but\n // the prompt never states pins rest flush on the carrier or that gears\n // rest flush on the pins, so this is inference, not a pinned value.\n //\n // Volume OMITTED (gear teeth named directly in the task rules as an omit\n // example): trapezoidal tooth width/profile is not given beyond pitch/\n // root/outside diameters and tooth count, and the Z-stacking ambiguity\n // above compounds it for 8 of the 9 bodies.\n solids: [9, 9], // sun(1) + 3 planets + ring(1) + carrier(1) + 3 pins = 9, per the checklist's explicit body count\n minTriangles: 100,\n probesInsideSolid: [\n [40, 0, -3], // carrier plate material, mid-thickness (Z=-5..-1), r=40 (within its 52.5 mm radius) -- the only body with a fully pinned Z range\n [105 / 2 - 1, 0, -3], // 1 mm inside the carrier's 52.5 mm radius (105 mm OD): confirms the carrier reaches its stated diameter\n ],\n probesOutsideSolid: [\n // 1 mm beyond the carrier's 52.5 mm radius, same mid-thickness Z: the\n // prompt states the carrier plate is \"below the gears,\" so nothing\n // else in the assembly can occupy Z=-3 at any radius.\n [105 / 2 + 1, 0, -3],\n ],\n // No further probesOutsideSolid: the sun bore and every other gear-body\n // feature sit at a Z height that depends on the carrier/pin stacking\n // inference above, which the prompt does not state numerically. Planet\n // gear centers ARE derivable in XY (radius 42, 120 deg spacing ->\n // (42,0), (42*cos120, 42*sin120)=(-21, 36.37), (-21,-36.37)) but without\n // a pinned Z no 3D probe point can be placed with confidence.\n },\n },\n]\n"],"mappings":";;;;AAsDA,MAAa,mBACX;AAGF,MAAM,cAAc;;;;;AAMpB,MAAa,6BACX;AAMF,MAAa,aAAyB;CACpC;EACE,IAAI;EACJ,QAAQ;EACR,YAAY;EACZ,QACE,GAAG,YAAY;EAKjB,MAAM;GACJ,MAAM;IAAE,GAAG,CAAC,IAAI,GAAG;IAAG,GAAG,CAAC,IAAI,EAAE;IAAG,GAAG,CAAC,IAAI,EAAE;GAAE;GAO/C,QAAQ,CAAC,OAAS,KAAO;GACzB,QAAQ,CAAC,GAAG,CAAC;GACb,mBAAmB;IACjB;KAAC;KAAG;KAAG;IAAE;IACT;KAAC;KAAI;KAAI;IAAE;IACX;KAAC;KAAI;KAAU;IAAE;GACnB;GACA,oBAAoB;IAClB;KAAC;KAAI;KAAI;IAAE;IACX;KAAC;KAAK;KAAI;IAAE;IACZ;KAAC;KAAI;KAAK;IAAE;IACZ;KAAC;KAAK;KAAK;IAAE;IACb;KAAC;KAAI;KAAU;IAAE;GACnB;EACF;CACF;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AG,GAAG,CAAC,KAAK,GAAG;GAAE;GAKrC,QAAQ,CAAC,GAAG,CAAC;GACb,cAAc;GACd,mBAAmB,CACjB;IAAC;IAAG;IAAG;GAAE,GACT;IAAC;IAAO;IAAG;GAAE,CACf;GACA,oBAAoB,CAIlB;IAAC;IAAO;IAAG;GAAE,CACf;EAGF;CACF;CACA;EACE,IAAI;EACJ,QAAQ;EACR,YAAY;EACZ,QACE,GAAGA,2BAAsB;EAS3B,MAAM;GAQJ,MAAM;IAAE,GAAG,CAAC,KAAK,GAAG;IAAG,GAAG,CAAC,KAAK,GAAG;GAAE;GAYrC,QAAQ,CAAC,GAAG,CAAC;GACb,cAAc;GACd,mBAAmB,CACjB;IAAC;IAAI;IAAG;GAAE,GACV;IAAC,MAAM,IAAI;IAAG;IAAG;GAAE,CACrB;GACA,oBAAoB,CAIlB;IAAC;IAAa;IAAG;GAAE,CACrB;EAOF;CACF;AACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BenchmarkAdapter } from "./types.js";
|
|
2
|
-
//#region src/benchmarks/mind2web.d.ts
|
|
3
2
|
interface ParsedAction {
|
|
4
3
|
elementId: string;
|
|
5
4
|
op: string;
|
|
@@ -7,8 +6,7 @@ interface ParsedAction {
|
|
|
7
6
|
}
|
|
8
7
|
/** Parse the worker artifact's ELEMENT / ACTION / VALUE sentinel lines.
|
|
9
8
|
* Fail-closed: a missing ELEMENT or ACTION returns null (judge → resolved=false). */
|
|
10
|
-
declare function parseAction(artifact: string): ParsedAction | null;
|
|
11
|
-
declare function createMind2WebAdapter(): BenchmarkAdapter;
|
|
12
|
-
|
|
13
|
-
export { createMind2WebAdapter, parseAction };
|
|
9
|
+
export declare function parseAction(artifact: string): ParsedAction | null;
|
|
10
|
+
export declare function createMind2WebAdapter(): BenchmarkAdapter;
|
|
11
|
+
export {};
|
|
14
12
|
//# sourceMappingURL=mind2web.d.ts.map
|
|
@@ -4,7 +4,7 @@ import { execFile } from "node:child_process";
|
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { promisify } from "node:util";
|
|
7
|
-
|
|
7
|
+
// src/benchmarks/mind2web.ts
|
|
8
8
|
/**
|
|
9
9
|
* Mind2Web adapter (osunlp/Multimodal-Mind2Web, split 'test_domain' by default).
|
|
10
10
|
* Web-agent ACTION PREDICTION: each task is one step of a real web task — given
|
|
@@ -53,7 +53,7 @@ async function py(script, args = []) {
|
|
|
53
53
|
"-c",
|
|
54
54
|
script,
|
|
55
55
|
...args
|
|
56
|
-
], { maxBuffer:
|
|
56
|
+
], { maxBuffer: 268435456 });
|
|
57
57
|
return stdout;
|
|
58
58
|
}
|
|
59
59
|
/** The loader: stream the split, skip steps with no positive candidate (fail-loud,
|
|
@@ -252,7 +252,6 @@ print('ok'); sys.stdout.flush(); os._exit(0)`);
|
|
|
252
252
|
}
|
|
253
253
|
};
|
|
254
254
|
}
|
|
255
|
-
//#endregion
|
|
256
255
|
export { createMind2WebAdapter, parseAction };
|
|
257
256
|
|
|
258
257
|
//# sourceMappingURL=mind2web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mind2web.js","names":[],"sources":["../../src/benchmarks/mind2web.ts"],"sourcesContent":["/**\n * Mind2Web adapter (osunlp/Multimodal-Mind2Web, split 'test_domain' by default).\n * Web-agent ACTION PREDICTION: each task is one step of a real web task — given\n * the natural-language goal and the page's candidate elements, the worker picks\n * the SINGLE element to act on and the action (CLICK / TYPE / SELECT [+ value]).\n *\n * Judge is the published Mind2Web step metric, FULLY DETERMINISTIC — no LLM:\n * element correct ⇔ predicted backend_node_id ∈ pos_candidates ids\n * operation correct ⇔ op-type matches AND (TYPE/SELECT) the value matches\n * resolved (Step-SR) ⇔ element correct AND operation correct\n * score = 0.6·element + 0.4·operation (a gradient for the optimizer; the right\n * element is most of the credit, mirroring Element-Acc ≫ Op as the lever)\n * This is the low-noise reward a certifiable directive-lift needs: the number is a\n * programmatic match against human-verified ground truth, not a judge's opinion.\n *\n * The worker artifact is three sentinel lines (ELEMENT / ACTION / VALUE) so the\n * judge extracts deterministically; the prompt presents the candidate set as a\n * choice over backend_node_id ordered by id (position uncorrelated with the answer).\n *\n * Each step carries the dataset's OWN page screenshot (written to a temp file by\n * the loader); the worker drops it into a browser.<op> span so run-capsule's screen\n * capsule turns the run into a film — the real page, not a re-rendered DOM.\n *\n * Requires for a live run: a python with `datasets` + `pillow` and network to\n * Hugging Face. Point M2W_PYTHON at it (defaults to bench/.venv/bin/python).\n */\n\nimport { execFile } from 'node:child_process'\nimport { mkdir } from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { promisify } from 'node:util'\nimport type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'\n\nconst execFileAsync = promisify(execFile)\nconst BENCH_ROOT = fileURLToPath(new URL('../..', import.meta.url))\nconst PY = process.env.M2W_PYTHON ?? join(BENCH_ROOT, '.venv', 'bin', 'python')\n\nconst DATASET = 'osunlp/Multimodal-Mind2Web'\nconst DEFAULT_SPLIT = process.env.M2W_SPLIT ?? 'test_domain'\nconst SHOTS_DIR = process.env.M2W_SHOTS ?? join(tmpdir(), 'm2w-shots')\n/** Candidate-set cap presented to the worker (always keeps all pos candidates). */\nconst CANDIDATE_CAP = Number(process.env.M2W_CANDIDATE_CAP ?? 30)\n\n/** The worker contract appended to every task prompt; the judge keys off these. */\nconst WORKER_CONTRACT = [\n '',\n 'Pick the SINGLE next element to act on, then end your response with EXACTLY these three lines:',\n 'ELEMENT: <the [id] number of the chosen element>',\n 'ACTION: <CLICK | TYPE | SELECT>',\n 'VALUE: <text to type or option to select; leave empty for CLICK>',\n].join('\\n')\n\ninterface RawCandidate {\n id: string\n label: string\n}\ninterface Mind2WebRow {\n id: string\n task: string\n website: string\n domain: string\n subdomain: string\n op: string\n value: string\n goldIds: string[]\n candidates: RawCandidate[]\n screenshotPath: string\n targetRepr: string\n}\ninterface Mind2WebMeta {\n task: string\n website: string\n domain: string\n op: string\n value: string\n goldIds: string[]\n candidateIds: string[]\n screenshotPath: string\n targetRepr: string\n}\n\n/** Run the bench python with a script on stdin; return stdout (throws on nonzero). */\nasync function py(script: string, args: string[] = []): Promise<string> {\n const { stdout } = await execFileAsync(PY, ['-c', script, ...args], { maxBuffer: 1024 * 1024 * 256 })\n return stdout\n}\n\n/** The loader: stream the split, skip steps with no positive candidate (fail-loud,\n * never a silent score-0), cap the candidate set, save each screenshot to a file. */\nconst LOADER = `\nimport json, sys, os\nfrom datasets import load_dataset\ncfg = json.loads(sys.argv[1])\nsplit = cfg[\"split\"]; limit = cfg.get(\"limit\"); cap = cfg.get(\"cap\", 30)\nshots = cfg[\"shotsDir\"]; ids = set(cfg[\"ids\"]) if cfg.get(\"ids\") else None\nos.makedirs(shots, exist_ok=True)\nKEEP = (\"aria_label\",\"aria-label\",\"role\",\"type\",\"name\",\"placeholder\",\"title\",\"alt\",\"value\",\"text\",\"id\",\"class\",\"href\")\ndef label(tag, attr):\n try:\n a = json.loads(attr) if isinstance(attr, str) else (attr or {})\n except Exception:\n a = {}\n parts = []\n for k in KEEP:\n v = a.get(k)\n if v:\n sv = str(v).replace(\"\\\\n\", \" \").strip()\n if k == \"class\": sv = sv[:40]\n if k == \"href\": sv = sv[:50]\n if sv: parts.append(k + \"=\" + sv[:60])\n return \"<\" + str(tag) + \"> \" + \" \".join(parts[:6])\ndef cands(raw):\n out = []\n for c in raw or []:\n try:\n d = json.loads(c) if isinstance(c, str) else c\n except Exception:\n continue\n bid = str(d.get(\"backend_node_id\", \"\"))\n if not bid: continue\n out.append({\"id\": bid, \"label\": label(d.get(\"tag\", \"?\"), d.get(\"attributes\"))})\n return out\nds = load_dataset(${JSON.stringify(DATASET)}, split=split, streaming=True)\nemitted = []; skipped = 0; scanned = 0\nfor r in ds:\n scanned += 1\n if ids is not None and r[\"action_uid\"] not in ids:\n if scanned > 8000: break\n continue\n pos = cands(r.get(\"pos_candidates\"))\n if not pos:\n skipped += 1\n continue\n neg = cands(r.get(\"neg_candidates\"))\n seen = set(p[\"id\"] for p in pos); merged = list(pos)\n for n in neg:\n if len(merged) >= cap: break\n if n[\"id\"] in seen: continue\n seen.add(n[\"id\"]); merged.append(n)\n merged.sort(key=lambda x: int(x[\"id\"]) if x[\"id\"].isdigit() else 0)\n try:\n op = json.loads(r[\"operation\"]) if isinstance(r[\"operation\"], str) else r[\"operation\"]\n except Exception:\n op = {}\n sp = os.path.join(shots, str(r[\"action_uid\"]) + \".jpg\")\n try:\n r[\"screenshot\"].convert(\"RGB\").save(sp, \"JPEG\", quality=70)\n except Exception:\n sp = \"\"\n emitted.append({\n \"id\": r[\"action_uid\"], \"task\": r.get(\"confirmed_task\", \"\"),\n \"website\": r.get(\"website\", \"\"), \"domain\": r.get(\"domain\", \"\"), \"subdomain\": r.get(\"subdomain\", \"\"),\n \"op\": str(op.get(\"op\", \"\")).upper(), \"value\": str(op.get(\"value\", \"\")),\n \"goldIds\": [p[\"id\"] for p in pos], \"candidates\": merged,\n \"screenshotPath\": sp, \"targetRepr\": r.get(\"target_action_reprs\", \"\"),\n })\n if ids is None and limit is not None and len(emitted) >= limit: break\n if ids is not None and len(emitted) >= len(ids): break\nsys.stderr.write(\"[mind2web] emitted=%d skipped_empty_pos=%d scanned=%d\\\\n\" % (len(emitted), skipped, scanned)); sys.stderr.flush()\nprint(json.dumps(emitted)); sys.stdout.flush()\nos._exit(0)\n`\n\nfunction buildPrompt(row: Mind2WebRow): string {\n const choices = row.candidates.map((c) => ` [${c.id}] ${c.label}`).join('\\n')\n return [\n `Web task: ${row.task}`,\n '',\n 'You are taking the NEXT single action on the current web page. Choose the one element',\n 'to act on from the candidates below (each line is \"[id] <tag> attributes\"):',\n choices,\n WORKER_CONTRACT,\n ].join('\\n')\n}\n\nfunction rowToTask(row: Mind2WebRow): BenchTask {\n const meta: Mind2WebMeta = {\n task: row.task,\n website: row.website,\n domain: row.domain,\n op: row.op,\n value: row.value,\n goldIds: row.goldIds,\n candidateIds: row.candidates.map((c) => c.id),\n screenshotPath: row.screenshotPath,\n targetRepr: row.targetRepr,\n }\n return {\n id: `mind2web-${row.id}`,\n split: DEFAULT_SPLIT,\n prompt: buildPrompt(row),\n metadata: meta as unknown as Record<string, unknown>,\n }\n}\n\nfunction readMeta(task: BenchTask): Mind2WebMeta {\n const md = task.metadata\n if (!md || !Array.isArray((md as { goldIds?: unknown }).goldIds)) {\n throw new Error(`mind2web task ${task.id} missing metadata.goldIds — loadTasks did not populate it`)\n }\n return md as unknown as Mind2WebMeta\n}\n\n/** Normalize a TYPE/SELECT value for comparison: lowercase, collapse whitespace. */\nfunction normValue(s: string): string {\n return s.toLowerCase().replace(/\\s+/g, ' ').trim()\n}\n\ninterface ParsedAction {\n elementId: string\n op: string\n value: string\n}\n\n/** Parse the worker artifact's ELEMENT / ACTION / VALUE sentinel lines.\n * Fail-closed: a missing ELEMENT or ACTION returns null (judge → resolved=false). */\nexport function parseAction(artifact: string): ParsedAction | null {\n const elem = /ELEMENT:\\s*\\[?(\\d+)\\]?/i.exec(artifact)\n const op = /ACTION:\\s*(CLICK|TYPE|SELECT)/i.exec(artifact)\n if (!elem?.[1] || !op?.[1]) return null\n const val = /VALUE:\\s*(.*)/i.exec(artifact)\n return { elementId: elem[1], op: op[1].toUpperCase(), value: (val?.[1] ?? '').trim() }\n}\n\nexport function createMind2WebAdapter(): BenchmarkAdapter {\n const split = DEFAULT_SPLIT\n\n return {\n name: 'mind2web',\n\n async preflight() {\n try {\n await py(\n `import os, sys\nfrom datasets import load_dataset\nimport PIL\nds = load_dataset(${JSON.stringify(DATASET)}, split=${JSON.stringify(split)}, streaming=True)\nnext(iter(ds))\nprint('ok'); sys.stdout.flush(); os._exit(0)`,\n )\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n throw new Error(\n `mind2web preflight failed: ${msg}\\n` +\n `Fix: (1) a python with datasets + pillow (python3 -m venv bench/.venv && bench/.venv/bin/pip install datasets pillow) ; ` +\n `(2) network access to Hugging Face for ${DATASET} (split ${split}) ; ` +\n `point M2W_PYTHON at the python if not bench/.venv.`,\n )\n }\n },\n\n async loadTasks(opts: LoadOptions = {}) {\n const cfg = {\n split: opts.split ?? split,\n limit: opts.ids ? undefined : (opts.limit ?? 10),\n cap: CANDIDATE_CAP,\n shotsDir: SHOTS_DIR,\n ids: opts.ids ? opts.ids.map((id) => id.replace(/^mind2web-/, '')) : undefined,\n }\n await mkdir(SHOTS_DIR, { recursive: true })\n const stdout = await py(LOADER, [JSON.stringify(cfg)])\n const rows = JSON.parse(stdout) as Mind2WebRow[]\n return rows.map(rowToTask)\n },\n\n async goldArtifact(task: BenchTask) {\n // Gold = the worker-contract serialization of the ground-truth action, so\n // verify-judge proves gold→resolved through the SAME parse path the real\n // artifact takes. The first accepted positive id is the canonical target.\n const meta = readMeta(task)\n const id = meta.goldIds[0]\n if (!id) return undefined\n return `ELEMENT: ${id}\\nACTION: ${meta.op}\\nVALUE: ${meta.value}`\n },\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const meta = readMeta(task)\n const parsed = parseAction(artifact)\n if (!parsed) {\n return {\n resolved: false,\n score: 0,\n detail: JSON.stringify({ reason: 'no parseable ELEMENT/ACTION', goldOp: meta.op, goldIds: meta.goldIds }),\n }\n }\n const elementCorrect = meta.goldIds.includes(parsed.elementId)\n const opMatch = parsed.op === meta.op\n const valueMatch = meta.op === 'CLICK' ? true : normValue(parsed.value) === normValue(meta.value)\n const operationCorrect = opMatch && valueMatch\n const resolved = elementCorrect && operationCorrect\n const score = 0.6 * (elementCorrect ? 1 : 0) + 0.4 * (operationCorrect ? 1 : 0)\n return {\n resolved,\n score,\n detail: JSON.stringify({\n elementCorrect,\n opMatch,\n valueMatch,\n predicted: parsed,\n goldOp: meta.op,\n goldValue: meta.value,\n goldIds: meta.goldIds,\n website: meta.website,\n domain: meta.domain,\n }),\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;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imodal-Mind2Web, split 'test_domain' by default).\n * Web-agent ACTION PREDICTION: each task is one step of a real web task — given\n * the natural-language goal and the page's candidate elements, the worker picks\n * the SINGLE element to act on and the action (CLICK / TYPE / SELECT [+ value]).\n *\n * Judge is the published Mind2Web step metric, FULLY DETERMINISTIC — no LLM:\n * element correct ⇔ predicted backend_node_id ∈ pos_candidates ids\n * operation correct ⇔ op-type matches AND (TYPE/SELECT) the value matches\n * resolved (Step-SR) ⇔ element correct AND operation correct\n * score = 0.6·element + 0.4·operation (a gradient for the optimizer; the right\n * element is most of the credit, mirroring Element-Acc ≫ Op as the lever)\n * This is the low-noise reward a certifiable directive-lift needs: the number is a\n * programmatic match against human-verified ground truth, not a judge's opinion.\n *\n * The worker artifact is three sentinel lines (ELEMENT / ACTION / VALUE) so the\n * judge extracts deterministically; the prompt presents the candidate set as a\n * choice over backend_node_id ordered by id (position uncorrelated with the answer).\n *\n * Each step carries the dataset's OWN page screenshot (written to a temp file by\n * the loader); the worker drops it into a browser.<op> span so run-capsule's screen\n * capsule turns the run into a film — the real page, not a re-rendered DOM.\n *\n * Requires for a live run: a python with `datasets` + `pillow` and network to\n * Hugging Face. Point M2W_PYTHON at it (defaults to bench/.venv/bin/python).\n */\n\nimport { execFile } from 'node:child_process'\nimport { mkdir } from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { promisify } from 'node:util'\nimport type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'\n\nconst execFileAsync = promisify(execFile)\nconst BENCH_ROOT = fileURLToPath(new URL('../..', import.meta.url))\nconst PY = process.env.M2W_PYTHON ?? join(BENCH_ROOT, '.venv', 'bin', 'python')\n\nconst DATASET = 'osunlp/Multimodal-Mind2Web'\nconst DEFAULT_SPLIT = process.env.M2W_SPLIT ?? 'test_domain'\nconst SHOTS_DIR = process.env.M2W_SHOTS ?? join(tmpdir(), 'm2w-shots')\n/** Candidate-set cap presented to the worker (always keeps all pos candidates). */\nconst CANDIDATE_CAP = Number(process.env.M2W_CANDIDATE_CAP ?? 30)\n\n/** The worker contract appended to every task prompt; the judge keys off these. */\nconst WORKER_CONTRACT = [\n '',\n 'Pick the SINGLE next element to act on, then end your response with EXACTLY these three lines:',\n 'ELEMENT: <the [id] number of the chosen element>',\n 'ACTION: <CLICK | TYPE | SELECT>',\n 'VALUE: <text to type or option to select; leave empty for CLICK>',\n].join('\\n')\n\ninterface RawCandidate {\n id: string\n label: string\n}\ninterface Mind2WebRow {\n id: string\n task: string\n website: string\n domain: string\n subdomain: string\n op: string\n value: string\n goldIds: string[]\n candidates: RawCandidate[]\n screenshotPath: string\n targetRepr: string\n}\ninterface Mind2WebMeta {\n task: string\n website: string\n domain: string\n op: string\n value: string\n goldIds: string[]\n candidateIds: string[]\n screenshotPath: string\n targetRepr: string\n}\n\n/** Run the bench python with a script on stdin; return stdout (throws on nonzero). */\nasync function py(script: string, args: string[] = []): Promise<string> {\n const { stdout } = await execFileAsync(PY, ['-c', script, ...args], { maxBuffer: 1024 * 1024 * 256 })\n return stdout\n}\n\n/** The loader: stream the split, skip steps with no positive candidate (fail-loud,\n * never a silent score-0), cap the candidate set, save each screenshot to a file. */\nconst LOADER = `\nimport json, sys, os\nfrom datasets import load_dataset\ncfg = json.loads(sys.argv[1])\nsplit = cfg[\"split\"]; limit = cfg.get(\"limit\"); cap = cfg.get(\"cap\", 30)\nshots = cfg[\"shotsDir\"]; ids = set(cfg[\"ids\"]) if cfg.get(\"ids\") else None\nos.makedirs(shots, exist_ok=True)\nKEEP = (\"aria_label\",\"aria-label\",\"role\",\"type\",\"name\",\"placeholder\",\"title\",\"alt\",\"value\",\"text\",\"id\",\"class\",\"href\")\ndef label(tag, attr):\n try:\n a = json.loads(attr) if isinstance(attr, str) else (attr or {})\n except Exception:\n a = {}\n parts = []\n for k in KEEP:\n v = a.get(k)\n if v:\n sv = str(v).replace(\"\\\\n\", \" \").strip()\n if k == \"class\": sv = sv[:40]\n if k == \"href\": sv = sv[:50]\n if sv: parts.append(k + \"=\" + sv[:60])\n return \"<\" + str(tag) + \"> \" + \" \".join(parts[:6])\ndef cands(raw):\n out = []\n for c in raw or []:\n try:\n d = json.loads(c) if isinstance(c, str) else c\n except Exception:\n continue\n bid = str(d.get(\"backend_node_id\", \"\"))\n if not bid: continue\n out.append({\"id\": bid, \"label\": label(d.get(\"tag\", \"?\"), d.get(\"attributes\"))})\n return out\nds = load_dataset(${JSON.stringify(DATASET)}, split=split, streaming=True)\nemitted = []; skipped = 0; scanned = 0\nfor r in ds:\n scanned += 1\n if ids is not None and r[\"action_uid\"] not in ids:\n if scanned > 8000: break\n continue\n pos = cands(r.get(\"pos_candidates\"))\n if not pos:\n skipped += 1\n continue\n neg = cands(r.get(\"neg_candidates\"))\n seen = set(p[\"id\"] for p in pos); merged = list(pos)\n for n in neg:\n if len(merged) >= cap: break\n if n[\"id\"] in seen: continue\n seen.add(n[\"id\"]); merged.append(n)\n merged.sort(key=lambda x: int(x[\"id\"]) if x[\"id\"].isdigit() else 0)\n try:\n op = json.loads(r[\"operation\"]) if isinstance(r[\"operation\"], str) else r[\"operation\"]\n except Exception:\n op = {}\n sp = os.path.join(shots, str(r[\"action_uid\"]) + \".jpg\")\n try:\n r[\"screenshot\"].convert(\"RGB\").save(sp, \"JPEG\", quality=70)\n except Exception:\n sp = \"\"\n emitted.append({\n \"id\": r[\"action_uid\"], \"task\": r.get(\"confirmed_task\", \"\"),\n \"website\": r.get(\"website\", \"\"), \"domain\": r.get(\"domain\", \"\"), \"subdomain\": r.get(\"subdomain\", \"\"),\n \"op\": str(op.get(\"op\", \"\")).upper(), \"value\": str(op.get(\"value\", \"\")),\n \"goldIds\": [p[\"id\"] for p in pos], \"candidates\": merged,\n \"screenshotPath\": sp, \"targetRepr\": r.get(\"target_action_reprs\", \"\"),\n })\n if ids is None and limit is not None and len(emitted) >= limit: break\n if ids is not None and len(emitted) >= len(ids): break\nsys.stderr.write(\"[mind2web] emitted=%d skipped_empty_pos=%d scanned=%d\\\\n\" % (len(emitted), skipped, scanned)); sys.stderr.flush()\nprint(json.dumps(emitted)); sys.stdout.flush()\nos._exit(0)\n`\n\nfunction buildPrompt(row: Mind2WebRow): string {\n const choices = row.candidates.map((c) => ` [${c.id}] ${c.label}`).join('\\n')\n return [\n `Web task: ${row.task}`,\n '',\n 'You are taking the NEXT single action on the current web page. Choose the one element',\n 'to act on from the candidates below (each line is \"[id] <tag> attributes\"):',\n choices,\n WORKER_CONTRACT,\n ].join('\\n')\n}\n\nfunction rowToTask(row: Mind2WebRow): BenchTask {\n const meta: Mind2WebMeta = {\n task: row.task,\n website: row.website,\n domain: row.domain,\n op: row.op,\n value: row.value,\n goldIds: row.goldIds,\n candidateIds: row.candidates.map((c) => c.id),\n screenshotPath: row.screenshotPath,\n targetRepr: row.targetRepr,\n }\n return {\n id: `mind2web-${row.id}`,\n split: DEFAULT_SPLIT,\n prompt: buildPrompt(row),\n metadata: meta as unknown as Record<string, unknown>,\n }\n}\n\nfunction readMeta(task: BenchTask): Mind2WebMeta {\n const md = task.metadata\n if (!md || !Array.isArray((md as { goldIds?: unknown }).goldIds)) {\n throw new Error(`mind2web task ${task.id} missing metadata.goldIds — loadTasks did not populate it`)\n }\n return md as unknown as Mind2WebMeta\n}\n\n/** Normalize a TYPE/SELECT value for comparison: lowercase, collapse whitespace. */\nfunction normValue(s: string): string {\n return s.toLowerCase().replace(/\\s+/g, ' ').trim()\n}\n\ninterface ParsedAction {\n elementId: string\n op: string\n value: string\n}\n\n/** Parse the worker artifact's ELEMENT / ACTION / VALUE sentinel lines.\n * Fail-closed: a missing ELEMENT or ACTION returns null (judge → resolved=false). */\nexport function parseAction(artifact: string): ParsedAction | null {\n const elem = /ELEMENT:\\s*\\[?(\\d+)\\]?/i.exec(artifact)\n const op = /ACTION:\\s*(CLICK|TYPE|SELECT)/i.exec(artifact)\n if (!elem?.[1] || !op?.[1]) return null\n const val = /VALUE:\\s*(.*)/i.exec(artifact)\n return { elementId: elem[1], op: op[1].toUpperCase(), value: (val?.[1] ?? '').trim() }\n}\n\nexport function createMind2WebAdapter(): BenchmarkAdapter {\n const split = DEFAULT_SPLIT\n\n return {\n name: 'mind2web',\n\n async preflight() {\n try {\n await py(\n `import os, sys\nfrom datasets import load_dataset\nimport PIL\nds = load_dataset(${JSON.stringify(DATASET)}, split=${JSON.stringify(split)}, streaming=True)\nnext(iter(ds))\nprint('ok'); sys.stdout.flush(); os._exit(0)`,\n )\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n throw new Error(\n `mind2web preflight failed: ${msg}\\n` +\n `Fix: (1) a python with datasets + pillow (python3 -m venv bench/.venv && bench/.venv/bin/pip install datasets pillow) ; ` +\n `(2) network access to Hugging Face for ${DATASET} (split ${split}) ; ` +\n `point M2W_PYTHON at the python if not bench/.venv.`,\n )\n }\n },\n\n async loadTasks(opts: LoadOptions = {}) {\n const cfg = {\n split: opts.split ?? split,\n limit: opts.ids ? undefined : (opts.limit ?? 10),\n cap: CANDIDATE_CAP,\n shotsDir: SHOTS_DIR,\n ids: opts.ids ? opts.ids.map((id) => id.replace(/^mind2web-/, '')) : undefined,\n }\n await mkdir(SHOTS_DIR, { recursive: true })\n const stdout = await py(LOADER, [JSON.stringify(cfg)])\n const rows = JSON.parse(stdout) as Mind2WebRow[]\n return rows.map(rowToTask)\n },\n\n async goldArtifact(task: BenchTask) {\n // Gold = the worker-contract serialization of the ground-truth action, so\n // verify-judge proves gold→resolved through the SAME parse path the real\n // artifact takes. The first accepted positive id is the canonical target.\n const meta = readMeta(task)\n const id = meta.goldIds[0]\n if (!id) return undefined\n return `ELEMENT: ${id}\\nACTION: ${meta.op}\\nVALUE: ${meta.value}`\n },\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const meta = readMeta(task)\n const parsed = parseAction(artifact)\n if (!parsed) {\n return {\n resolved: false,\n score: 0,\n detail: JSON.stringify({ reason: 'no parseable ELEMENT/ACTION', goldOp: meta.op, goldIds: meta.goldIds }),\n }\n }\n const elementCorrect = meta.goldIds.includes(parsed.elementId)\n const opMatch = parsed.op === meta.op\n const valueMatch = meta.op === 'CLICK' ? true : normValue(parsed.value) === normValue(meta.value)\n const operationCorrect = opMatch && valueMatch\n const resolved = elementCorrect && operationCorrect\n const score = 0.6 * (elementCorrect ? 1 : 0) + 0.4 * (operationCorrect ? 1 : 0)\n return {\n resolved,\n score,\n detail: JSON.stringify({\n elementCorrect,\n opMatch,\n valueMatch,\n predicted: parsed,\n goldOp: meta.op,\n goldValue: meta.value,\n goldIds: meta.goldIds,\n website: meta.website,\n domain: meta.domain,\n }),\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,gBAAgB,UAAU,QAAQ;AACxC,MAAM,aAAa,cAAc,IAAI,IAAI,SAAS,YAAY,GAAG,CAAC;AAClE,MAAM,KAAK,QAAQ,IAAI,cAAc,KAAK,YAAY,SAAS,OAAO,QAAQ;AAE9E,MAAM,UAAU;AAChB,MAAM,gBAAgB,QAAQ,IAAI,aAAa;AAC/C,MAAM,YAAY,QAAQ,IAAI,aAAa,KAAK,OAAO,GAAG,WAAW;;AAErE,MAAM,gBAAgB,OAAO,QAAQ,IAAI,qBAAqB,EAAE;;AAGhE,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;;AAgCX,eAAe,GAAG,QAAgB,OAAiB,CAAC,GAAoB;CACtE,MAAM,EAAE,WAAW,MAAM,cAAc,IAAI;EAAC;EAAM;EAAQ,GAAG;CAAI,GAAG,EAAE,WAAW,UAAkB,CAAC;CACpG,OAAO;AACT;;;AAIA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAiCK,KAAK,UAAU,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyC5C,SAAS,YAAY,KAA0B;CAC7C,MAAM,UAAU,IAAI,WAAW,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AK,KAAK;GAChG,MAAM,mBAAmB,WAAW;GAGpC,OAAO;IACL,UAHe,kBAAkB;IAIjC,OAHY,MAAO,iBAAiB,IAAI,KAAK,MAAO,mBAAmB,IAAI;IAI3E,QAAQ,KAAK,UAAU;KACrB;KACA;KACA;KACA,WAAW;KACX,QAAQ,KAAK;KACb,WAAW,KAAK;KAChB,SAAS,KAAK;KACd,SAAS,KAAK;KACd,QAAQ,KAAK;IACf,CAAC;GACH;EACF;CACF;AACF"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { BenchmarkAdapter } from "./types.js";
|
|
2
|
-
|
|
3
|
-
declare function createNoMiraclAdapter(): BenchmarkAdapter;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { createNoMiraclAdapter };
|
|
2
|
+
export declare function createNoMiraclAdapter(): BenchmarkAdapter;
|
|
6
3
|
//# sourceMappingURL=nomiracl.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { benchRoot } from "./_harness.js";
|
|
|
2
2
|
import { contextBlock, contextsFrom, firstString, isObject, ragAnswerOutput, readJsonRows, selectTasks, stringFrom } from "./rag-shared.js";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
-
|
|
5
|
+
// src/benchmarks/nomiracl.ts
|
|
6
6
|
/**
|
|
7
7
|
* NoMIRACL adapter.
|
|
8
8
|
*
|
|
@@ -141,7 +141,6 @@ function createNoMiraclAdapter() {
|
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
//#endregion
|
|
145
144
|
export { createNoMiraclAdapter };
|
|
146
145
|
|
|
147
146
|
//# sourceMappingURL=nomiracl.js.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { BenchmarkAdapter } from "./types.js";
|
|
2
|
-
|
|
3
|
-
declare function createOpenRagBenchAdapter(): BenchmarkAdapter;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { createOpenRagBenchAdapter };
|
|
2
|
+
export declare function createOpenRagBenchAdapter(): BenchmarkAdapter;
|
|
6
3
|
//# sourceMappingURL=open-rag-bench.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { benchRoot } from "./_harness.js";
|
|
|
2
2
|
import { FINAL_ANSWER_SENTINEL, allStrings, answerScoreToBenchScore, contextBlock, contextsFrom, firstString, isObject, ragAnswerOutput, readJsonRows, scoreAnswerArtifact, selectTasks, stringFrom } from "./rag-shared.js";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
-
|
|
5
|
+
// src/benchmarks/open-rag-bench.ts
|
|
6
6
|
/**
|
|
7
7
|
* Open RAG Bench adapter.
|
|
8
8
|
*
|
|
@@ -96,7 +96,8 @@ function createOpenRagBenchAdapter() {
|
|
|
96
96
|
},
|
|
97
97
|
async judge(task, artifact) {
|
|
98
98
|
const meta = readMeta(task);
|
|
99
|
-
|
|
99
|
+
const score = scoreAnswerArtifact(artifact, meta.goldAnswers);
|
|
100
|
+
return answerScoreToBenchScore(score, {
|
|
100
101
|
benchmark: meta.benchmark,
|
|
101
102
|
documentId: meta.documentId,
|
|
102
103
|
modality: meta.modality,
|
|
@@ -105,7 +106,6 @@ function createOpenRagBenchAdapter() {
|
|
|
105
106
|
}
|
|
106
107
|
};
|
|
107
108
|
}
|
|
108
|
-
//#endregion
|
|
109
109
|
export { createOpenRagBenchAdapter };
|
|
110
110
|
|
|
111
111
|
//# sourceMappingURL=open-rag-bench.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-rag-bench.js","names":[],"sources":["../../src/benchmarks/open-rag-bench.ts"],"sourcesContent":["/**\n * Open RAG Bench adapter.\n *\n * This targets Vectara-style Open RAG Bench exports over PDF-derived text,\n * table, and image contexts. The deterministic judge scores final-answer\n * agreement and surfaces modality/document metadata for diagnostics.\n */\n\nimport { readFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { benchRoot } from './_harness'\nimport type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'\nimport {\n FINAL_ANSWER_SENTINEL,\n allStrings,\n answerScoreToBenchScore,\n contextBlock,\n contextsFrom,\n firstString,\n isObject,\n ragAnswerOutput,\n readJsonRows,\n scoreAnswerArtifact,\n selectTasks,\n stringFrom,\n type RagContext,\n} from './rag-shared'\n\nconst FIXTURES = join(benchRoot, 'fixtures', 'open-rag-bench.json')\n\ninterface OpenRagBenchMeta {\n benchmark: 'open-rag-bench'\n query: string\n goldAnswers: string[]\n contexts: RagContext[]\n documentId: string\n modality: string\n}\n\nconst dataFile = (): string | undefined => process.env.OPEN_RAG_BENCH_DATA_FILE\n\nfunction rowToTask(raw: unknown, index: number): BenchTask {\n if (!isObject(raw)) throw new Error(`Open RAG Bench row ${index} must be an object`)\n const query = firstString(raw, ['question', 'query', 'prompt'])\n const goldAnswers = allStrings(raw, ['answer', 'answers', 'reference', 'reference_answer', 'gold'])\n if (!query) throw new Error(`Open RAG Bench row ${index} missing question/query`)\n if (goldAnswers.length === 0) throw new Error(`Open RAG Bench row ${index} missing answer`)\n const contexts =\n contextsFrom(raw.contexts).length > 0\n ? contextsFrom(raw.contexts)\n : contextsFrom(raw.chunks).length > 0\n ? contextsFrom(raw.chunks)\n : contextsFrom(raw.pages)\n const documentId =\n stringFrom(raw.document_id) ??\n stringFrom(raw.doc_id) ??\n stringFrom(raw.pdf_id) ??\n stringFrom(raw.file_name) ??\n stringFrom(raw.filename) ??\n 'unknown'\n const modality = stringFrom(raw.modality) ?? stringFrom(raw.answer_modality) ?? 'unknown'\n const id = stringFrom(raw.id) ?? stringFrom(raw.query_id) ?? `open-rag-bench-${index}`\n const meta: OpenRagBenchMeta = {\n benchmark: 'open-rag-bench',\n query,\n goldAnswers,\n contexts,\n documentId,\n modality,\n }\n return {\n id,\n split: stringFrom(raw.split) ?? modality,\n prompt: [\n 'Answer this Open RAG Bench PDF question using the supplied document context.',\n 'Use tables, text, and image-derived notes when present.',\n 'End with a single final line: `FINAL ANSWER: <answer>`.',\n '',\n `Question: ${query}`,\n `Document: ${documentId}`,\n `Modality: ${modality}`,\n contexts.length > 0 ? `\\nDocument context:\\n${contextBlock(contexts)}` : undefined,\n ]\n .filter(Boolean)\n .join('\\n'),\n metadata: meta as unknown as Record<string, unknown>,\n }\n}\n\nfunction readMeta(task: BenchTask): OpenRagBenchMeta {\n const md = task.metadata\n if (!md || !Array.isArray(md.goldAnswers)) {\n throw new Error(`Open RAG Bench task ${task.id} missing metadata — loadTasks did not populate it`)\n }\n return md as unknown as OpenRagBenchMeta\n}\n\nasync function loadRows(path: string): Promise<unknown[]> {\n const rows = await readJsonRows(path)\n if (rows.length === 0) throw new Error(`Open RAG Bench: no rows in ${path}`)\n return rows\n}\n\nasync function loadFixtures(opts: LoadOptions): Promise<BenchTask[]> {\n const rows = JSON.parse(await readFile(FIXTURES, 'utf8')) as unknown[]\n console.warn(`[open-rag-bench] OPEN_RAG_BENCH_FIXTURES=1 — loading ${rows.length} adapter fixtures`)\n return selectTasks(rows.map(rowToTask), opts, 'Open RAG Bench')\n}\n\nexport function createOpenRagBenchAdapter(): BenchmarkAdapter {\n const fixturesMode = process.env.OPEN_RAG_BENCH_FIXTURES === '1'\n\n return {\n name: 'open-rag-bench',\n output: ragAnswerOutput,\n\n async preflight() {\n if (fixturesMode) {\n await readFile(FIXTURES, 'utf8')\n return\n }\n const path = dataFile()\n if (!path) {\n throw new Error(\n 'OPEN_RAG_BENCH_DATA_FILE is required. Fix: export vectara/open-rag-bench rows to JSONL and set OPEN_RAG_BENCH_DATA_FILE=/path/to/open-rag-bench.jsonl, or set OPEN_RAG_BENCH_FIXTURES=1 for adapter plumbing.',\n )\n }\n await loadRows(path)\n },\n\n async loadTasks(opts: LoadOptions = {}) {\n if (fixturesMode) return loadFixtures(opts)\n const path = dataFile()\n if (!path) throw new Error('OPEN_RAG_BENCH_DATA_FILE is required to load Open RAG Bench tasks')\n return selectTasks((await loadRows(path)).map(rowToTask), opts, 'Open RAG Bench')\n },\n\n async goldArtifact(task: BenchTask) {\n return `${FINAL_ANSWER_SENTINEL} ${readMeta(task).goldAnswers[0] ?? ''}`\n },\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const meta = readMeta(task)\n const score = scoreAnswerArtifact(artifact, meta.goldAnswers)\n return answerScoreToBenchScore(score, {\n benchmark: meta.benchmark,\n documentId: meta.documentId,\n modality: meta.modality,\n contextCount: meta.contexts.length,\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;AA4BA,MAAM,WAAW,KAAK,WAAW,YAAY,qBAAqB;AAWlE,MAAM,iBAAqC,QAAQ,IAAI;AAEvD,SAAS,UAAU,KAAc,OAA0B;CACzD,IAAI,CAAC,SAAS,GAAG,GAAG,MAAM,IAAI,MAAM,sBAAsB,MAAM,mBAAmB;CACnF,MAAM,QAAQ,YAAY,KAAK;EAAC;EAAY;EAAS;CAAQ,CAAC;CAC9D,MAAM,cAAc,WAAW,KAAK;EAAC;EAAU;EAAW;EAAa;EAAoB;CAAM,CAAC;CAClG,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,sBAAsB,MAAM,wBAAwB;CAChF,IAAI,YAAY,WAAW,GAAG,MAAM,IAAI,MAAM,sBAAsB,MAAM,gBAAgB;CAC1F,MAAM,WACJ,aAAa,IAAI,QAAQ,CAAC,CAAC,SAAS,IAChC,aAAa,IAAI,QAAQ,IACzB,aAAa,IAAI,MAAM,CAAC,CAAC,SAAS,IAChC,aAAa,IAAI,MAAM,IACvB,aAAa,IAAI,KAAK;CAC9B,MAAM,aACJ,WAAW,IAAI,WAAW,KAC1B,WAAW,IAAI,MAAM,KACrB,WAAW,IAAI,MAAM,KACrB,WAAW,IAAI,SAAS,KACxB,WAAW,IAAI,QAAQ,KACvB;CACF,MAAM,WAAW,WAAW,IAAI,QAAQ,KAAK,WAAW,IAAI,eAAe,KAAK;CAChF,MAAM,KAAK,WAAW,IAAI,EAAE,KAAK,WAAW,IAAI,QAAQ,KAAK,kBAAkB;CAC/E,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mEAAmE;GAC9F,OAAO,aAAa,MAAM,SAAS,IAAI,EAAA,CAAG,IAAI,SAAS,GAAG,MAAM,gBAAgB;EAClF;EAEA,MAAM,aAAa,MAAiB;GAClC,OAAO,GAAG,sBAAsB,GAAG,SAAS,IAAI,CAAC,CAAC,YAAY,MAAM;EACtE;EAEA,MAAM,MAAM,MAAiB,UAAuC;GAClE,MAAM,OAAO,SAAS,IAAI;
|
|
1
|
+
{"version":3,"file":"open-rag-bench.js","names":[],"sources":["../../src/benchmarks/open-rag-bench.ts"],"sourcesContent":["/**\n * Open RAG Bench adapter.\n *\n * This targets Vectara-style Open RAG Bench exports over PDF-derived text,\n * table, and image contexts. The deterministic judge scores final-answer\n * agreement and surfaces modality/document metadata for diagnostics.\n */\n\nimport { readFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { benchRoot } from './_harness'\nimport type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'\nimport {\n FINAL_ANSWER_SENTINEL,\n allStrings,\n answerScoreToBenchScore,\n contextBlock,\n contextsFrom,\n firstString,\n isObject,\n ragAnswerOutput,\n readJsonRows,\n scoreAnswerArtifact,\n selectTasks,\n stringFrom,\n type RagContext,\n} from './rag-shared'\n\nconst FIXTURES = join(benchRoot, 'fixtures', 'open-rag-bench.json')\n\ninterface OpenRagBenchMeta {\n benchmark: 'open-rag-bench'\n query: string\n goldAnswers: string[]\n contexts: RagContext[]\n documentId: string\n modality: string\n}\n\nconst dataFile = (): string | undefined => process.env.OPEN_RAG_BENCH_DATA_FILE\n\nfunction rowToTask(raw: unknown, index: number): BenchTask {\n if (!isObject(raw)) throw new Error(`Open RAG Bench row ${index} must be an object`)\n const query = firstString(raw, ['question', 'query', 'prompt'])\n const goldAnswers = allStrings(raw, ['answer', 'answers', 'reference', 'reference_answer', 'gold'])\n if (!query) throw new Error(`Open RAG Bench row ${index} missing question/query`)\n if (goldAnswers.length === 0) throw new Error(`Open RAG Bench row ${index} missing answer`)\n const contexts =\n contextsFrom(raw.contexts).length > 0\n ? contextsFrom(raw.contexts)\n : contextsFrom(raw.chunks).length > 0\n ? contextsFrom(raw.chunks)\n : contextsFrom(raw.pages)\n const documentId =\n stringFrom(raw.document_id) ??\n stringFrom(raw.doc_id) ??\n stringFrom(raw.pdf_id) ??\n stringFrom(raw.file_name) ??\n stringFrom(raw.filename) ??\n 'unknown'\n const modality = stringFrom(raw.modality) ?? stringFrom(raw.answer_modality) ?? 'unknown'\n const id = stringFrom(raw.id) ?? stringFrom(raw.query_id) ?? `open-rag-bench-${index}`\n const meta: OpenRagBenchMeta = {\n benchmark: 'open-rag-bench',\n query,\n goldAnswers,\n contexts,\n documentId,\n modality,\n }\n return {\n id,\n split: stringFrom(raw.split) ?? modality,\n prompt: [\n 'Answer this Open RAG Bench PDF question using the supplied document context.',\n 'Use tables, text, and image-derived notes when present.',\n 'End with a single final line: `FINAL ANSWER: <answer>`.',\n '',\n `Question: ${query}`,\n `Document: ${documentId}`,\n `Modality: ${modality}`,\n contexts.length > 0 ? `\\nDocument context:\\n${contextBlock(contexts)}` : undefined,\n ]\n .filter(Boolean)\n .join('\\n'),\n metadata: meta as unknown as Record<string, unknown>,\n }\n}\n\nfunction readMeta(task: BenchTask): OpenRagBenchMeta {\n const md = task.metadata\n if (!md || !Array.isArray(md.goldAnswers)) {\n throw new Error(`Open RAG Bench task ${task.id} missing metadata — loadTasks did not populate it`)\n }\n return md as unknown as OpenRagBenchMeta\n}\n\nasync function loadRows(path: string): Promise<unknown[]> {\n const rows = await readJsonRows(path)\n if (rows.length === 0) throw new Error(`Open RAG Bench: no rows in ${path}`)\n return rows\n}\n\nasync function loadFixtures(opts: LoadOptions): Promise<BenchTask[]> {\n const rows = JSON.parse(await readFile(FIXTURES, 'utf8')) as unknown[]\n console.warn(`[open-rag-bench] OPEN_RAG_BENCH_FIXTURES=1 — loading ${rows.length} adapter fixtures`)\n return selectTasks(rows.map(rowToTask), opts, 'Open RAG Bench')\n}\n\nexport function createOpenRagBenchAdapter(): BenchmarkAdapter {\n const fixturesMode = process.env.OPEN_RAG_BENCH_FIXTURES === '1'\n\n return {\n name: 'open-rag-bench',\n output: ragAnswerOutput,\n\n async preflight() {\n if (fixturesMode) {\n await readFile(FIXTURES, 'utf8')\n return\n }\n const path = dataFile()\n if (!path) {\n throw new Error(\n 'OPEN_RAG_BENCH_DATA_FILE is required. Fix: export vectara/open-rag-bench rows to JSONL and set OPEN_RAG_BENCH_DATA_FILE=/path/to/open-rag-bench.jsonl, or set OPEN_RAG_BENCH_FIXTURES=1 for adapter plumbing.',\n )\n }\n await loadRows(path)\n },\n\n async loadTasks(opts: LoadOptions = {}) {\n if (fixturesMode) return loadFixtures(opts)\n const path = dataFile()\n if (!path) throw new Error('OPEN_RAG_BENCH_DATA_FILE is required to load Open RAG Bench tasks')\n return selectTasks((await loadRows(path)).map(rowToTask), opts, 'Open RAG Bench')\n },\n\n async goldArtifact(task: BenchTask) {\n return `${FINAL_ANSWER_SENTINEL} ${readMeta(task).goldAnswers[0] ?? ''}`\n },\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const meta = readMeta(task)\n const score = scoreAnswerArtifact(artifact, meta.goldAnswers)\n return answerScoreToBenchScore(score, {\n benchmark: meta.benchmark,\n documentId: meta.documentId,\n modality: meta.modality,\n contextCount: meta.contexts.length,\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;AA4BA,MAAM,WAAW,KAAK,WAAW,YAAY,qBAAqB;AAWlE,MAAM,iBAAqC,QAAQ,IAAI;AAEvD,SAAS,UAAU,KAAc,OAA0B;CACzD,IAAI,CAAC,SAAS,GAAG,GAAG,MAAM,IAAI,MAAM,sBAAsB,MAAM,mBAAmB;CACnF,MAAM,QAAQ,YAAY,KAAK;EAAC;EAAY;EAAS;CAAQ,CAAC;CAC9D,MAAM,cAAc,WAAW,KAAK;EAAC;EAAU;EAAW;EAAa;EAAoB;CAAM,CAAC;CAClG,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,sBAAsB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SAAS,UAAU,MAAM,CAAC;CACxD,QAAQ,KAAK,wDAAwD,KAAK,OAAO,kBAAkB;CACnG,OAAO,YAAY,KAAK,IAAI,SAAS,GAAG,MAAM,gBAAgB;AAChE;AAEA,SAAgB,4BAA8C;CAC5D,MAAM,eAAe,QAAQ,IAAI,4BAA4B;CAE7D,OAAO;EACL,MAAM;EACN,QAAQ;EAER,MAAM,YAAY;GAChB,IAAI,cAAc;IAChB,MAAM,SAAS,UAAU,MAAM;IAC/B;GACF;GACA,MAAM,OAAO,SAAS;GACtB,IAAI,CAAC,MACH,MAAM,IAAI,MACR,+MACF;GAEF,MAAM,SAAS,IAAI;EACrB;EAEA,MAAM,UAAU,OAAoB,CAAC,GAAG;GACtC,IAAI,cAAc,OAAO,aAAa,IAAI;GAC1C,MAAM,OAAO,SAAS;GACtB,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,mEAAmE;GAC9F,OAAO,aAAa,MAAM,SAAS,IAAI,EAAA,CAAG,IAAI,SAAS,GAAG,MAAM,gBAAgB;EAClF;EAEA,MAAM,aAAa,MAAiB;GAClC,OAAO,GAAG,sBAAsB,GAAG,SAAS,IAAI,CAAC,CAAC,YAAY,MAAM;EACtE;EAEA,MAAM,MAAM,MAAiB,UAAuC;GAClE,MAAM,OAAO,SAAS,IAAI;GAC1B,MAAM,QAAQ,oBAAoB,UAAU,KAAK,WAAW;GAC5D,OAAO,wBAAwB,OAAO;IACpC,WAAW,KAAK;IAChB,YAAY,KAAK;IACjB,UAAU,KAAK;IACf,cAAc,KAAK,SAAS;GAC9B,CAAC;EACH;CACF;AACF"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { BenchmarkAdapter } from "./types.js";
|
|
2
2
|
import { OutputAdapter } from "@tangle-network/agent-runtime/kernel";
|
|
3
|
-
//#region src/benchmarks/programbench.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Parse the worker stream into the submission text the driver materializes: the
|
|
6
5
|
* concatenation of every ```path:<p>``` fenced block. Passed through verbatim to
|
|
7
6
|
* the python driver, which tars it. Empty when the worker emitted no file block
|
|
8
7
|
* (fail-closed → the harness scores a missing compile.sh as 0).
|
|
9
8
|
*/
|
|
10
|
-
declare const programbenchSubmissionOutput: OutputAdapter<string>;
|
|
11
|
-
declare function createProgrambenchAdapter(): BenchmarkAdapter;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { createProgrambenchAdapter, programbenchSubmissionOutput };
|
|
9
|
+
export declare const programbenchSubmissionOutput: OutputAdapter<string>;
|
|
10
|
+
export declare function createProgrambenchAdapter(): BenchmarkAdapter;
|
|
14
11
|
//# sourceMappingURL=programbench.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { benchRoot, preflightVenvImports, runVenvScriptStdin } from "./_harness.js";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
|
|
4
|
+
// src/benchmarks/programbench.ts
|
|
5
5
|
/**
|
|
6
6
|
* ProgramBench adapter (facebookresearch/ProgramBench) — cleanroom
|
|
7
7
|
* reverse-engineering: rebuild a black-box executable's behavior from scratch.
|
|
@@ -156,7 +156,6 @@ function createProgrambenchAdapter() {
|
|
|
156
156
|
}
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
-
//#endregion
|
|
160
159
|
export { createProgrambenchAdapter, programbenchSubmissionOutput };
|
|
161
160
|
|
|
162
161
|
//# sourceMappingURL=programbench.js.map
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { BenchScore, BenchTask, LoadOptions } from "./types.js";
|
|
2
2
|
import { OutputAdapter } from "@tangle-network/agent-runtime/kernel";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export declare const FINAL_ANSWER_SENTINEL = "FINAL ANSWER:";
|
|
4
|
+
export interface ResearchAnswer {
|
|
5
|
+
finalAnswer: string;
|
|
6
|
+
citations: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface RagContext {
|
|
6
9
|
id: string;
|
|
7
10
|
text: string;
|
|
8
11
|
title?: string;
|
|
9
12
|
source?: string;
|
|
10
13
|
relevant?: boolean;
|
|
11
14
|
}
|
|
12
|
-
interface RagAnswerScore {
|
|
15
|
+
export interface RagAnswerScore {
|
|
13
16
|
resolved: boolean;
|
|
14
17
|
score: number;
|
|
15
18
|
finalAnswer: string;
|
|
@@ -19,25 +22,30 @@ interface RagAnswerScore {
|
|
|
19
22
|
f1: number;
|
|
20
23
|
threshold: number;
|
|
21
24
|
}
|
|
22
|
-
declare const ragAnswerOutput: OutputAdapter<string>;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
export declare const ragAnswerOutput: OutputAdapter<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Parse the worker artifact into the final answer string.
|
|
28
|
+
* Order: the `FINAL ANSWER:` sentinel first (deterministic-extraction discipline);
|
|
29
|
+
* fall back to the last non-empty line. Returns '' when nothing is parseable
|
|
30
|
+
* (fail-closed — never guess), which judge() counts as resolved=false.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseFinalAnswer(artifact: string): string;
|
|
33
|
+
/** Extract cited URLs from a `CITATIONS:` block and any bare URLs in the artifact. */
|
|
34
|
+
export declare function parseCitations(artifact: string): string[];
|
|
35
|
+
export declare function normalizeAnswer(input: string): string;
|
|
36
|
+
export declare function tokenF1(candidate: string, gold: string): number;
|
|
37
|
+
export declare function scoreAnswerArtifact(artifact: string, golds: readonly string[], options?: {
|
|
28
38
|
threshold?: number;
|
|
29
39
|
numericTolerance?: number;
|
|
30
40
|
}): RagAnswerScore;
|
|
31
|
-
declare function answerScoreToBenchScore(score: RagAnswerScore, detail: Record<string, unknown>): BenchScore;
|
|
32
|
-
declare function readJsonRows(path: string): Promise<unknown[]>;
|
|
33
|
-
declare function selectTasks(tasks: BenchTask[], opts: LoadOptions, label: string): BenchTask[];
|
|
34
|
-
declare function stringFrom(value: unknown): string | undefined;
|
|
35
|
-
declare function stringArrayFrom(value: unknown): string[];
|
|
36
|
-
declare function firstString(row: Record<string, unknown>, keys: readonly string[]): string;
|
|
37
|
-
declare function allStrings(row: Record<string, unknown>, keys: readonly string[]): string[];
|
|
38
|
-
declare function contextsFrom(value: unknown): RagContext[];
|
|
39
|
-
declare function contextBlock(contexts: readonly RagContext[]): string;
|
|
40
|
-
declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
41
|
-
//#endregion
|
|
42
|
-
export { FINAL_ANSWER_SENTINEL, RagAnswerScore, RagContext, allStrings, answerScoreToBenchScore, contextBlock, contextsFrom, firstString, isObject, normalizeAnswer, parseCitations, parseFinalAnswer, ragAnswerOutput, readJsonRows, scoreAnswerArtifact, selectTasks, stringArrayFrom, stringFrom, tokenF1 };
|
|
41
|
+
export declare function answerScoreToBenchScore(score: RagAnswerScore, detail: Record<string, unknown>): BenchScore;
|
|
42
|
+
export declare function readJsonRows(path: string): Promise<unknown[]>;
|
|
43
|
+
export declare function selectTasks(tasks: BenchTask[], opts: LoadOptions, label: string): BenchTask[];
|
|
44
|
+
export declare function stringFrom(value: unknown): string | undefined;
|
|
45
|
+
export declare function stringArrayFrom(value: unknown): string[];
|
|
46
|
+
export declare function firstString(row: Record<string, unknown>, keys: readonly string[]): string;
|
|
47
|
+
export declare function allStrings(row: Record<string, unknown>, keys: readonly string[]): string[];
|
|
48
|
+
export declare function contextsFrom(value: unknown): RagContext[];
|
|
49
|
+
export declare function contextBlock(contexts: readonly RagContext[]): string;
|
|
50
|
+
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
43
51
|
//# sourceMappingURL=rag-shared.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
|
|
2
|
+
// src/benchmarks/rag-shared.ts
|
|
3
3
|
const FINAL_ANSWER_SENTINEL = "FINAL ANSWER:";
|
|
4
4
|
const ragAnswerOutput = { parse(events) {
|
|
5
5
|
let text = "";
|
|
@@ -10,6 +10,12 @@ const ragAnswerOutput = { parse(events) {
|
|
|
10
10
|
}
|
|
11
11
|
return text.trim();
|
|
12
12
|
} };
|
|
13
|
+
/**
|
|
14
|
+
* Parse the worker artifact into the final answer string.
|
|
15
|
+
* Order: the `FINAL ANSWER:` sentinel first (deterministic-extraction discipline);
|
|
16
|
+
* fall back to the last non-empty line. Returns '' when nothing is parseable
|
|
17
|
+
* (fail-closed — never guess), which judge() counts as resolved=false.
|
|
18
|
+
*/
|
|
13
19
|
function parseFinalAnswer(artifact) {
|
|
14
20
|
const lines = artifact.split(/\r?\n/);
|
|
15
21
|
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
@@ -23,6 +29,7 @@ function parseFinalAnswer(artifact) {
|
|
|
23
29
|
}
|
|
24
30
|
return "";
|
|
25
31
|
}
|
|
32
|
+
/** Extract cited URLs from a `CITATIONS:` block and any bare URLs in the artifact. */
|
|
26
33
|
function parseCitations(artifact) {
|
|
27
34
|
const urls = /* @__PURE__ */ new Set();
|
|
28
35
|
for (const match of artifact.matchAll(/https?:\/\/[^\s)<>"']+/g)) urls.add(match[0].replace(/[.,;]+$/, ""));
|
|
@@ -240,7 +247,6 @@ function contextBlock(contexts) {
|
|
|
240
247
|
function isObject(value) {
|
|
241
248
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
242
249
|
}
|
|
243
|
-
//#endregion
|
|
244
250
|
export { FINAL_ANSWER_SENTINEL, allStrings, answerScoreToBenchScore, contextBlock, contextsFrom, firstString, isObject, normalizeAnswer, parseCitations, parseFinalAnswer, ragAnswerOutput, readJsonRows, scoreAnswerArtifact, selectTasks, stringArrayFrom, stringFrom, tokenF1 };
|
|
245
251
|
|
|
246
252
|
//# sourceMappingURL=rag-shared.js.map
|