@tangle-network/agent-bench 2.0.0 → 4.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 +27 -0
- package/README.md +32 -2
- package/dist/adapters.d.ts +3 -3
- package/dist/adapters.js +3 -5
- package/dist/adapters.js.map +1 -1
- package/dist/benchmarks/_harness.d.ts +4 -4
- package/dist/benchmarks/_harness.js +5 -2
- package/dist/benchmarks/_harness.js.map +1 -1
- package/dist/benchmarks/aec-bench.d.ts +2 -2
- package/dist/benchmarks/aec-bench.js +49 -42
- package/dist/benchmarks/aec-bench.js.map +1 -1
- package/dist/benchmarks/agentbench.d.ts +2 -2
- package/dist/benchmarks/agentbench.js +41 -34
- package/dist/benchmarks/agentbench.js.map +1 -1
- package/dist/benchmarks/appworld.d.ts +4 -4
- package/dist/benchmarks/appworld.js +67 -53
- package/dist/benchmarks/appworld.js.map +1 -1
- package/dist/benchmarks/bfcl.d.ts +2 -2
- package/dist/benchmarks/bfcl.js +52 -44
- package/dist/benchmarks/bfcl.js.map +1 -1
- package/dist/benchmarks/cad-design.d.ts +2 -2
- package/dist/benchmarks/cad-design.js +53 -44
- package/dist/benchmarks/cad-design.js.map +1 -1
- package/dist/benchmarks/cadbench.d.ts +2 -2
- package/dist/benchmarks/cadbench.js +1 -1
- package/dist/benchmarks/cadgenbench.d.ts +2 -2
- package/dist/benchmarks/cadgenbench.js +1 -1
- package/dist/benchmarks/commit0.d.ts +2 -2
- package/dist/benchmarks/commit0.js +38 -31
- package/dist/benchmarks/commit0.js.map +1 -1
- package/dist/benchmarks/crag.d.ts +2 -2
- package/dist/benchmarks/crag.js +37 -32
- package/dist/benchmarks/crag.js.map +1 -1
- package/dist/benchmarks/dabstep.d.ts +2 -2
- package/dist/benchmarks/dabstep.js +41 -34
- package/dist/benchmarks/dabstep.js.map +1 -1
- package/dist/benchmarks/finresearchbench.d.ts +4 -4
- package/dist/benchmarks/finresearchbench.js +61 -48
- package/dist/benchmarks/finresearchbench.js.map +1 -1
- package/dist/benchmarks/finsearchcomp.d.ts +3 -3
- package/dist/benchmarks/finsearchcomp.js +54 -43
- package/dist/benchmarks/finsearchcomp.js.map +1 -1
- package/dist/benchmarks/frames.d.ts +2 -2
- package/dist/benchmarks/frames.js +66 -51
- package/dist/benchmarks/frames.js.map +1 -1
- package/dist/benchmarks/hotpotqa.d.ts +2 -2
- package/dist/benchmarks/hotpotqa.js +59 -47
- package/dist/benchmarks/hotpotqa.js.map +1 -1
- package/dist/benchmarks/humaneval.d.ts +3 -3
- package/dist/benchmarks/humaneval.js +39 -35
- package/dist/benchmarks/humaneval.js.map +1 -1
- package/dist/benchmarks/mcad-bench.d.ts +2 -2
- package/dist/benchmarks/mcad-bench.js +68 -56
- package/dist/benchmarks/mcad-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-bench.d.ts +2 -2
- package/dist/benchmarks/mcad-cq-bench.js +69 -57
- package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-golds.d.ts +1 -1
- package/dist/benchmarks/mcad-cq-golds.js +1 -1
- package/dist/benchmarks/mcad-cq-golds.js.map +1 -1
- package/dist/benchmarks/mcad-golds.d.ts +1 -1
- package/dist/benchmarks/mcad-golds.js.map +1 -1
- package/dist/benchmarks/mind2web.d.ts +3 -3
- package/dist/benchmarks/mind2web.js +62 -49
- package/dist/benchmarks/mind2web.js.map +1 -1
- package/dist/benchmarks/nomiracl.d.ts +2 -2
- package/dist/benchmarks/nomiracl.js +43 -36
- package/dist/benchmarks/nomiracl.js.map +1 -1
- package/dist/benchmarks/open-rag-bench.d.ts +2 -2
- package/dist/benchmarks/open-rag-bench.js +37 -32
- package/dist/benchmarks/open-rag-bench.js.map +1 -1
- package/dist/benchmarks/programbench.d.ts +2 -2
- package/dist/benchmarks/programbench.js +28 -23
- package/dist/benchmarks/programbench.js.map +1 -1
- package/dist/benchmarks/rag-shared.d.ts +2 -2
- package/dist/benchmarks/rag-shared.js +15 -13
- package/dist/benchmarks/rag-shared.js.map +1 -1
- package/dist/benchmarks/ragbench.d.ts +2 -2
- package/dist/benchmarks/ragbench.js +34 -29
- package/dist/benchmarks/ragbench.js.map +1 -1
- package/dist/benchmarks/simpleqa.d.ts +2 -2
- package/dist/benchmarks/simpleqa.js +62 -51
- package/dist/benchmarks/simpleqa.js.map +1 -1
- package/dist/benchmarks/swe-bench.d.ts +4 -4
- package/dist/benchmarks/swe-bench.js +47 -41
- package/dist/benchmarks/swe-bench.js.map +1 -1
- package/dist/benchmarks/t2-ragbench.d.ts +2 -2
- package/dist/benchmarks/t2-ragbench.js +37 -32
- package/dist/benchmarks/t2-ragbench.js.map +1 -1
- package/dist/benchmarks/tau-bench-shared.d.ts +2 -2
- package/dist/benchmarks/tau-bench-shared.js +43 -36
- package/dist/benchmarks/tau-bench-shared.js.map +1 -1
- package/dist/benchmarks/tau2-bench.d.ts +2 -2
- package/dist/benchmarks/tau2-bench.js.map +1 -1
- package/dist/benchmarks/tau3-banking.d.ts +2 -2
- package/dist/benchmarks/tau3-banking.js.map +1 -1
- package/dist/benchmarks/terminal-bench.d.ts +2 -2
- package/dist/benchmarks/terminal-bench.js +29 -23
- package/dist/benchmarks/terminal-bench.js.map +1 -1
- package/dist/benchmarks/toollm.d.ts +2 -2
- package/dist/benchmarks/toollm.js +40 -34
- package/dist/benchmarks/toollm.js.map +1 -1
- package/dist/benchmarks/trata-hedge.d.ts +2 -2
- package/dist/benchmarks/trata-hedge.js +46 -38
- package/dist/benchmarks/trata-hedge.js.map +1 -1
- package/dist/benchmarks/types.d.ts +33 -63
- package/dist/benchmarks/types.js +36 -1
- package/dist/benchmarks/types.js.map +1 -0
- package/dist/benchmarks/webarena-verified.d.ts +2 -2
- package/dist/benchmarks/webarena-verified.js +29 -24
- package/dist/benchmarks/webarena-verified.js.map +1 -1
- package/dist/{cadbench-Byr5gO1M.js → cadbench-htzAmMaI.js} +39 -32
- package/dist/cadbench-htzAmMaI.js.map +1 -0
- package/dist/{cadgenbench-Tvk16YKT.js → cadgenbench-BLvEtnxU.js} +28 -22
- package/dist/cadgenbench-BLvEtnxU.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +667 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +43 -22
- package/dist/index.js +297 -144
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
- package/pier_agents/candidate_contract.py +226 -74
- package/pier_agents/tangle_candidate.py +79 -1
- package/pier_agents/workspace_boundary.py +29 -1
- package/scripts/enterpriseops-gym-run.sh +82 -0
- package/scripts/grade-recorded-evidence.mjs +6 -6
- package/scripts/harvey-lab-judge.py +50 -0
- package/scripts/harvey-lab-run.sh +53 -0
- package/scripts/harvey-lab-sandbox.sh +21 -0
- package/scripts/healthbench-professional-run.sh +30 -0
- package/scripts/healthbench_professional_run.py +112 -0
- package/scripts/mlcr-run.sh +17 -0
- package/scripts/mlcr_run.py +133 -0
- package/scripts/prbench-run.sh +39 -0
- package/scripts/prbench_run.py +53 -0
- package/scripts/verify-packed-consumer.mjs +32 -27
- package/scripts/verify-pier-agent.mts +142 -25
- package/src/adapters.ts +5 -7
- package/src/benchmarks/_harness.test.mts +18 -1
- package/src/benchmarks/_harness.ts +12 -7
- package/src/benchmarks/aec-bench.test.mts +14 -14
- package/src/benchmarks/aec-bench.ts +62 -56
- package/src/benchmarks/agent-eval-contract.test.mts +38 -0
- package/src/benchmarks/agentbench.ts +44 -37
- package/src/benchmarks/appworld.test.mts +7 -7
- package/src/benchmarks/appworld.ts +88 -75
- package/src/benchmarks/bfcl.ts +60 -53
- package/src/benchmarks/cad-design.ts +34 -32
- package/src/benchmarks/cadbench.ts +34 -32
- package/src/benchmarks/cadgenbench.ts +30 -28
- package/src/benchmarks/commit0.test.mts +9 -9
- package/src/benchmarks/commit0.ts +50 -43
- package/src/benchmarks/crag.ts +45 -40
- package/src/benchmarks/dabstep-official.test.mts +8 -8
- package/src/benchmarks/dabstep.test.mts +11 -11
- package/src/benchmarks/dabstep.ts +47 -40
- package/src/benchmarks/external-adapters.test.mts +43 -44
- package/src/benchmarks/finresearchbench.ts +57 -47
- package/src/benchmarks/finsearchcomp.ts +72 -67
- package/src/benchmarks/frames.ts +76 -69
- package/src/benchmarks/hotpotqa.ts +69 -64
- package/src/benchmarks/humaneval.ts +37 -35
- package/src/benchmarks/mcad-bench.test.mts +30 -30
- package/src/benchmarks/mcad-bench.ts +66 -60
- package/src/benchmarks/mcad-cq-bench.ts +69 -63
- package/src/benchmarks/mcad-cq-golds.ts +1 -1
- package/src/benchmarks/mcad-cq.test.mts +40 -40
- package/src/benchmarks/mcad-golds.ts +1 -1
- package/src/benchmarks/mind2web.ts +66 -58
- package/src/benchmarks/nomiracl.ts +53 -46
- package/src/benchmarks/open-rag-bench.ts +47 -42
- package/src/benchmarks/programbench.test.mts +10 -10
- package/src/benchmarks/programbench.ts +38 -33
- package/src/benchmarks/rag-benchmarks.test.mts +31 -31
- package/src/benchmarks/rag-shared.ts +13 -16
- package/src/benchmarks/ragbench.ts +44 -39
- package/src/benchmarks/simpleqa.ts +78 -73
- package/src/benchmarks/swe-bench.test.mts +3 -3
- package/src/benchmarks/swe-bench.ts +66 -61
- package/src/benchmarks/t2-ragbench.ts +47 -42
- package/src/benchmarks/tau-bench-shared.ts +51 -44
- package/src/benchmarks/tau-pin.test.mts +1 -1
- package/src/benchmarks/tau2-bench.ts +2 -2
- package/src/benchmarks/tau3-banking.ts +2 -2
- package/src/benchmarks/terminal-bench.test.mts +3 -3
- package/src/benchmarks/terminal-bench.ts +41 -36
- package/src/benchmarks/toollm.ts +54 -47
- package/src/benchmarks/trata-hedge.ts +57 -52
- package/src/benchmarks/types.ts +70 -59
- package/src/benchmarks/webarena-verified.ts +49 -42
- package/src/cli.ts +74 -0
- package/src/corpus-replay.mts +9 -9
- package/src/examples/benchmark-matrix.mts +13 -10
- package/src/gate-cli.mts +5 -5
- package/src/gate.test.mts +14 -12
- package/src/gate.ts +23 -22
- package/src/index.ts +20 -11
- package/src/pier-agent.ts +108 -38
- package/src/pier-trial-controller.test.mts +48 -1
- package/src/pier-trial-controller.ts +121 -8
- package/src/published.test.mts +534 -0
- package/src/published.ts +524 -0
- package/src/run-benchmarks-cli.mts +2 -2
- package/src/run-benchmarks.test.mts +58 -48
- package/src/run-benchmarks.ts +64 -57
- package/src/swe-bench-env.ts +6 -6
- package/src/worker.ts +1 -1
- package/dist/benchmarks/enterpriseops-gym.d.ts +0 -6
- package/dist/benchmarks/enterpriseops-gym.js +0 -236
- package/dist/benchmarks/enterpriseops-gym.js.map +0 -1
- package/dist/cadbench-Byr5gO1M.js.map +0 -1
- package/dist/cadgenbench-Tvk16YKT.js.map +0 -1
- package/fixtures/enterpriseops-gym.json +0 -103
- package/scripts/enterpriseops_gym_judge.py +0 -281
- package/src/benchmarks/enterpriseops-gym.test.mts +0 -77
- package/src/benchmarks/enterpriseops-gym.ts +0 -343
- package/src/eops-skills/address-every-subtask.md +0 -5
- package/src/eops-skills/exact-tools-and-args.md +0 -5
- package/src/eops-skills/full-sequence-to-goal.md +0 -5
- package/src/eops-skills/ground-every-value.md +0 -5
- package/src/eops-skills/honor-the-policies.md +0 -5
package/src/benchmarks/bfcl.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { readFile, stat } from 'node:fs/promises'
|
|
|
13
13
|
import { join } from 'node:path'
|
|
14
14
|
import type { OutputAdapter } from '@tangle-network/agent-runtime/kernel'
|
|
15
15
|
import { benchRoot } from './_harness'
|
|
16
|
-
import
|
|
16
|
+
import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
|
|
17
17
|
|
|
18
18
|
const FIXTURES = join(benchRoot, 'fixtures', 'bfcl.json')
|
|
19
19
|
const DEFAULT_CATEGORY = 'BFCL_v4_simple_python'
|
|
@@ -141,15 +141,17 @@ function rowToTask(row: BfclRow, answer: BfclAnswerRow, category: string): Bench
|
|
|
141
141
|
}
|
|
142
142
|
return {
|
|
143
143
|
id: row.id,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
payload: {
|
|
145
|
+
subset: category,
|
|
146
|
+
prompt: [
|
|
147
|
+
'Solve this BFCL function-calling task.',
|
|
148
|
+
'Return only JSON: {"function_calls":[{"name":"...","arguments":{...}}]}.',
|
|
149
|
+
'',
|
|
150
|
+
questionText(row.question),
|
|
151
|
+
'',
|
|
152
|
+
`Available functions: ${JSON.stringify(row.function, null, 2)}`,
|
|
153
|
+
].join('\n'),
|
|
154
|
+
},
|
|
153
155
|
metadata: meta as unknown as Record<string, unknown>,
|
|
154
156
|
}
|
|
155
157
|
}
|
|
@@ -157,14 +159,14 @@ function rowToTask(row: BfclRow, answer: BfclAnswerRow, category: string): Bench
|
|
|
157
159
|
function readMeta(task: BenchTask): BfclMeta {
|
|
158
160
|
const md = task.metadata
|
|
159
161
|
if (!md || !Array.isArray(md.expected)) {
|
|
160
|
-
throw new Error(`BFCL task ${task.id} missing expected calls —
|
|
162
|
+
throw new Error(`BFCL task ${task.id} missing expected calls — loadAll did not populate metadata`)
|
|
161
163
|
}
|
|
162
164
|
return md as unknown as BfclMeta
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
function selectTasks(tasks: BenchTask[], opts: LoadOptions): BenchTask[] {
|
|
166
168
|
let out = tasks
|
|
167
|
-
if (opts.
|
|
169
|
+
if (opts.subset) out = out.filter((task) => task.payload.subset === opts.subset)
|
|
168
170
|
if (opts.ids) {
|
|
169
171
|
const want = new Set(opts.ids)
|
|
170
172
|
out = out.filter((task) => want.has(task.id))
|
|
@@ -271,7 +273,7 @@ function callMatches(expected: BfclAllowedCall, actual: BfclActualCall): boolean
|
|
|
271
273
|
return true
|
|
272
274
|
}
|
|
273
275
|
|
|
274
|
-
function scoreCalls(task: BenchTask, artifact: string):
|
|
276
|
+
function scoreCalls(task: BenchTask, artifact: string): BenchEvaluation {
|
|
275
277
|
const meta = readMeta(task)
|
|
276
278
|
const actual = extractActualCalls(artifact)
|
|
277
279
|
const used = new Set<number>()
|
|
@@ -286,61 +288,66 @@ function scoreCalls(task: BenchTask, artifact: string): BenchScore {
|
|
|
286
288
|
const recall = meta.expected.length === 0 ? 0 : matched / meta.expected.length
|
|
287
289
|
const precision = actual.length === 0 ? 0 : matched / actual.length
|
|
288
290
|
const score = recall
|
|
291
|
+
const raw = {
|
|
292
|
+
scoring: meta.scoring,
|
|
293
|
+
category: meta.category,
|
|
294
|
+
expected: meta.expected,
|
|
295
|
+
actual,
|
|
296
|
+
precision,
|
|
297
|
+
recall,
|
|
298
|
+
fullBfclLeaderboardScore: null,
|
|
299
|
+
}
|
|
289
300
|
return {
|
|
290
|
-
|
|
301
|
+
passed: recall === 1 && precision === 1,
|
|
291
302
|
score,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
category: meta.category,
|
|
295
|
-
expected: meta.expected,
|
|
296
|
-
actual,
|
|
297
|
-
precision,
|
|
298
|
-
recall,
|
|
299
|
-
fullBfclLeaderboardScore: null,
|
|
300
|
-
}),
|
|
303
|
+
notes: JSON.stringify(raw),
|
|
304
|
+
raw,
|
|
301
305
|
}
|
|
302
306
|
}
|
|
303
307
|
|
|
304
|
-
export function createBfclAdapter():
|
|
308
|
+
export function createBfclAdapter(): RuntimeBenchmark {
|
|
305
309
|
const fixturesMode = process.env.BFCL_FIXTURES === '1'
|
|
306
310
|
|
|
307
|
-
return {
|
|
308
|
-
|
|
309
|
-
output: bfclOutput,
|
|
311
|
+
return runtimeBenchmark({
|
|
312
|
+
id: 'bfcl',
|
|
310
313
|
|
|
311
|
-
async
|
|
312
|
-
if (fixturesMode) return
|
|
313
|
-
const dir = bfclDir()
|
|
314
|
-
if (!dir) {
|
|
315
|
-
throw new Error(
|
|
316
|
-
'BFCL_DIR is required. Fix: clone https://github.com/ShishirPatil/gorilla, set BFCL_DIR=/path/to/gorilla/berkeley-function-call-leaderboard, and optionally set BFCL_CATEGORY=BFCL_v4_simple_python.',
|
|
317
|
-
)
|
|
318
|
-
}
|
|
319
|
-
const category = bfclCategory()
|
|
320
|
-
await assertPath(taskFile(dir, category), 'BFCL task JSONL')
|
|
321
|
-
await assertPath(answerFile(dir, category), 'BFCL possible_answer JSONL')
|
|
322
|
-
await loadOfficialTasks(dir, { limit: 1 })
|
|
323
|
-
},
|
|
324
|
-
|
|
325
|
-
async loadTasks(opts: LoadOptions = {}) {
|
|
314
|
+
async loadAll(opts: LoadOptions = {}) {
|
|
326
315
|
if (fixturesMode) return loadFixtures(opts)
|
|
327
316
|
const dir = bfclDir()
|
|
328
317
|
if (!dir) throw new Error('BFCL_DIR is required to load official BFCL rows')
|
|
329
318
|
return loadOfficialTasks(dir, opts)
|
|
330
319
|
},
|
|
331
320
|
|
|
332
|
-
async
|
|
333
|
-
|
|
334
|
-
return JSON.stringify({
|
|
335
|
-
function_calls: meta.expected.map((call) => ({
|
|
336
|
-
name: call.name,
|
|
337
|
-
arguments: Object.fromEntries(Object.entries(call.arguments).map(([key, values]) => [key, values[0]])),
|
|
338
|
-
})),
|
|
339
|
-
}, null, 2)
|
|
321
|
+
async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
|
|
322
|
+
return scoreCalls(task, artifact)
|
|
340
323
|
},
|
|
341
324
|
|
|
342
|
-
|
|
343
|
-
|
|
325
|
+
runtime: {
|
|
326
|
+
output: bfclOutput,
|
|
327
|
+
|
|
328
|
+
async preflight() {
|
|
329
|
+
if (fixturesMode) return
|
|
330
|
+
const dir = bfclDir()
|
|
331
|
+
if (!dir) {
|
|
332
|
+
throw new Error(
|
|
333
|
+
'BFCL_DIR is required. Fix: clone https://github.com/ShishirPatil/gorilla, set BFCL_DIR=/path/to/gorilla/berkeley-function-call-leaderboard, and optionally set BFCL_CATEGORY=BFCL_v4_simple_python.',
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
const category = bfclCategory()
|
|
337
|
+
await assertPath(taskFile(dir, category), 'BFCL task JSONL')
|
|
338
|
+
await assertPath(answerFile(dir, category), 'BFCL possible_answer JSONL')
|
|
339
|
+
await loadOfficialTasks(dir, { limit: 1 })
|
|
340
|
+
},
|
|
341
|
+
|
|
342
|
+
async goldArtifact(task: BenchTask) {
|
|
343
|
+
const meta = readMeta(task)
|
|
344
|
+
return JSON.stringify({
|
|
345
|
+
function_calls: meta.expected.map((call) => ({
|
|
346
|
+
name: call.name,
|
|
347
|
+
arguments: Object.fromEntries(Object.entries(call.arguments).map(([key, values]) => [key, values[0]])),
|
|
348
|
+
})),
|
|
349
|
+
}, null, 2)
|
|
350
|
+
},
|
|
344
351
|
},
|
|
345
|
-
}
|
|
352
|
+
})
|
|
346
353
|
}
|
|
@@ -28,7 +28,7 @@ import { mkdtemp, readFile, writeFile } from 'node:fs/promises'
|
|
|
28
28
|
import { tmpdir } from 'node:os'
|
|
29
29
|
import { join } from 'node:path'
|
|
30
30
|
import { promisify } from 'node:util'
|
|
31
|
-
import
|
|
31
|
+
import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
|
|
32
32
|
|
|
33
33
|
const execFileAsync = promisify(execFile)
|
|
34
34
|
|
|
@@ -341,39 +341,21 @@ difference(){
|
|
|
341
341
|
},
|
|
342
342
|
]
|
|
343
343
|
|
|
344
|
-
export function createCadDesignAdapter():
|
|
345
|
-
return {
|
|
346
|
-
|
|
344
|
+
export function createCadDesignAdapter(): RuntimeBenchmark {
|
|
345
|
+
return runtimeBenchmark({
|
|
346
|
+
id: 'cad-design',
|
|
347
347
|
|
|
348
|
-
async
|
|
349
|
-
try {
|
|
350
|
-
await execFileAsync('xvfb-run', ['-a', 'openscad', '--version'], { timeout: 30_000 })
|
|
351
|
-
} catch (err) {
|
|
352
|
-
const msg = err instanceof Error ? err.message : String(err)
|
|
353
|
-
throw new Error(
|
|
354
|
-
`cad-design preflight failed: ${msg}\n` +
|
|
355
|
-
`Fix: install OpenSCAD + Xvfb (Debian/Ubuntu: sudo apt-get install -y openscad xvfb). ` +
|
|
356
|
-
`The judge runs \`xvfb-run -a openscad -o out.stl model.scad\` — both must be on PATH.`,
|
|
357
|
-
)
|
|
358
|
-
}
|
|
359
|
-
},
|
|
360
|
-
|
|
361
|
-
async loadTasks(opts: LoadOptions = {}) {
|
|
348
|
+
async loadAll(opts: LoadOptions = {}) {
|
|
362
349
|
let tasks = TASKS
|
|
363
350
|
if (opts.ids) tasks = tasks.filter((t) => opts.ids!.includes(t.id))
|
|
364
351
|
if (opts.limit != null) tasks = tasks.slice(0, opts.limit)
|
|
365
|
-
return tasks.map((t): BenchTask => ({ id: t.id, prompt: t.prompt, metadata: t.meta as unknown as Record<string, unknown> }))
|
|
366
|
-
},
|
|
367
|
-
|
|
368
|
-
async goldArtifact(task: BenchTask) {
|
|
369
|
-
const meta = task.metadata as unknown as CadTaskMeta | undefined
|
|
370
|
-
return meta?.gold
|
|
352
|
+
return tasks.map((t): BenchTask => ({ id: t.id, payload: { prompt: t.prompt }, metadata: t.meta as unknown as Record<string, unknown> }))
|
|
371
353
|
},
|
|
372
354
|
|
|
373
|
-
async
|
|
355
|
+
async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
|
|
374
356
|
const spec = (task.metadata as unknown as CadTaskMeta).spec
|
|
375
357
|
const src = artifact.trim()
|
|
376
|
-
if (!src) return {
|
|
358
|
+
if (!src) return { passed: false, score: 0, notes: 'empty artifact', raw: {} }
|
|
377
359
|
|
|
378
360
|
const dir = await mkdtemp(join(tmpdir(), 'cad-'))
|
|
379
361
|
const scad = join(dir, 'model.scad')
|
|
@@ -388,7 +370,7 @@ export function createCadDesignAdapter(): BenchmarkAdapter {
|
|
|
388
370
|
stderr = r.stderr
|
|
389
371
|
} catch (err) {
|
|
390
372
|
const msg = err instanceof Error ? err.message : String(err)
|
|
391
|
-
return {
|
|
373
|
+
return { passed: false, score: 0, notes: `compile failed: ${msg.slice(0, 300)}`, raw: {} }
|
|
392
374
|
}
|
|
393
375
|
|
|
394
376
|
// Render a PNG alongside (the artifact run-capsule animates). Non-fatal.
|
|
@@ -405,13 +387,13 @@ export function createCadDesignAdapter(): BenchmarkAdapter {
|
|
|
405
387
|
try {
|
|
406
388
|
stl = await readFile(stlPath, 'utf8')
|
|
407
389
|
} catch {
|
|
408
|
-
return {
|
|
390
|
+
return { passed: false, score: 0, notes: 'compiled but produced no STL (empty geometry)', raw: {} }
|
|
409
391
|
}
|
|
410
392
|
const volumes = Number(/Volumes:\s*(\d+)/.exec(stderr)?.[1] ?? '1')
|
|
411
393
|
const geo = measureStl(stl, volumes)
|
|
412
394
|
const { checks, score } = scoreGeometry(geo, spec)
|
|
413
395
|
const resolved = score === 1
|
|
414
|
-
const
|
|
396
|
+
const raw = {
|
|
415
397
|
checks,
|
|
416
398
|
geo: {
|
|
417
399
|
triangles: geo.triangles,
|
|
@@ -422,8 +404,28 @@ export function createCadDesignAdapter(): BenchmarkAdapter {
|
|
|
422
404
|
},
|
|
423
405
|
renderPath: pngPath,
|
|
424
406
|
stlPath,
|
|
425
|
-
}
|
|
426
|
-
return { resolved, score,
|
|
407
|
+
}
|
|
408
|
+
return { passed: resolved, score, notes: JSON.stringify(raw), raw }
|
|
427
409
|
},
|
|
428
|
-
|
|
410
|
+
|
|
411
|
+
runtime: {
|
|
412
|
+
async preflight() {
|
|
413
|
+
try {
|
|
414
|
+
await execFileAsync('xvfb-run', ['-a', 'openscad', '--version'], { timeout: 30_000 })
|
|
415
|
+
} catch (err) {
|
|
416
|
+
const msg = err instanceof Error ? err.message : String(err)
|
|
417
|
+
throw new Error(
|
|
418
|
+
`cad-design preflight failed: ${msg}\n` +
|
|
419
|
+
`Fix: install OpenSCAD + Xvfb (Debian/Ubuntu: sudo apt-get install -y openscad xvfb). ` +
|
|
420
|
+
`The judge runs \`xvfb-run -a openscad -o out.stl model.scad\` — both must be on PATH.`,
|
|
421
|
+
)
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
async goldArtifact(task: BenchTask) {
|
|
426
|
+
const meta = task.metadata as unknown as CadTaskMeta | undefined
|
|
427
|
+
return meta?.gold
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
})
|
|
429
431
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { readFile } from 'node:fs/promises'
|
|
15
|
-
import type
|
|
15
|
+
import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
|
|
16
16
|
import { renderBpy } from '../worker-blender'
|
|
17
17
|
import { runBenchRouterTurn } from '../router-turn'
|
|
18
18
|
|
|
@@ -81,7 +81,7 @@ async function judgeCriteria(
|
|
|
81
81
|
return { passed, note: `${passed.filter(Boolean).length}/${criteria.length} criteria` }
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
export function createCadBenchAdapter():
|
|
84
|
+
export function createCadBenchAdapter(): RuntimeBenchmark {
|
|
85
85
|
let cache: Array<{ id: string; instruction: string; meta: CadBenchMeta }> | null = null
|
|
86
86
|
|
|
87
87
|
async function load(): Promise<typeof cache & object> {
|
|
@@ -99,48 +99,50 @@ export function createCadBenchAdapter(): BenchmarkAdapter {
|
|
|
99
99
|
return cache
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
return {
|
|
103
|
-
|
|
102
|
+
return runtimeBenchmark({
|
|
103
|
+
id: 'cadbench',
|
|
104
104
|
|
|
105
|
-
async
|
|
106
|
-
const { execFile } = await import('node:child_process')
|
|
107
|
-
const { promisify } = await import('node:util')
|
|
108
|
-
const exec = promisify(execFile)
|
|
109
|
-
try {
|
|
110
|
-
await exec('xvfb-run', ['-a', 'blender', '--version'], { timeout: 30_000 })
|
|
111
|
-
} catch (err) {
|
|
112
|
-
throw new Error(
|
|
113
|
-
`cadbench preflight failed: ${(err instanceof Error ? err.message : String(err)).slice(0, 200)}\n` +
|
|
114
|
-
`Fix: install Blender + Xvfb (sudo apt-get install -y blender xvfb). The judge runs \`xvfb-run -a blender --background --python\`.`,
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
await load()
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
async loadTasks(opts: LoadOptions = {}) {
|
|
105
|
+
async loadAll(opts: LoadOptions = {}) {
|
|
121
106
|
let rows = await load()
|
|
122
107
|
if (opts.ids) rows = rows.filter((r) => opts.ids!.includes(r.id))
|
|
123
108
|
// TYPE filter (Simulative|Wild) via env, applied before limit.
|
|
124
109
|
const t = process.env.CADBENCH_TYPE
|
|
125
110
|
if (t) rows = rows.filter((r) => r.meta.type.toLowerCase() === t.toLowerCase())
|
|
126
111
|
if (opts.limit != null) rows = rows.slice(0, opts.limit)
|
|
127
|
-
return rows.map((r): BenchTask => ({ id: r.id, prompt: r.instruction, metadata: r.meta as unknown as Record<string, unknown> }))
|
|
112
|
+
return rows.map((r): BenchTask => ({ id: r.id, payload: { prompt: r.instruction }, metadata: r.meta as unknown as Record<string, unknown> }))
|
|
128
113
|
},
|
|
129
114
|
|
|
130
|
-
async
|
|
131
|
-
return undefined // no reference bpy script ships with the benchmark
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
|
|
115
|
+
async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
|
|
135
116
|
const meta = task.metadata as unknown as CadBenchMeta
|
|
136
117
|
const criteria = meta.criteria ?? []
|
|
137
|
-
if (!artifact.trim()) return {
|
|
138
|
-
if (criteria.length === 0) return {
|
|
118
|
+
if (!artifact.trim()) return { passed: false, score: 0, notes: 'empty artifact', raw: {} }
|
|
119
|
+
if (criteria.length === 0) return { passed: false, score: 0, notes: 'task has no criteria', raw: {} }
|
|
139
120
|
const r = await renderBpy(artifact, { views: 4 })
|
|
140
|
-
if (!r.built) return {
|
|
141
|
-
const { passed, note } = await judgeCriteria(task.prompt, artifact, criteria, r.renders)
|
|
121
|
+
if (!r.built) return { passed: false, score: 0, notes: `did not build/render: ${r.error ?? 'no mesh'}`, raw: {} }
|
|
122
|
+
const { passed, note } = await judgeCriteria(task.payload.prompt, artifact, criteria, r.renders)
|
|
142
123
|
const score = passed.filter(Boolean).length / criteria.length
|
|
143
|
-
return {
|
|
124
|
+
return { passed: score === 1, score, notes: note, raw: {} }
|
|
144
125
|
},
|
|
145
|
-
|
|
126
|
+
|
|
127
|
+
runtime: {
|
|
128
|
+
async preflight() {
|
|
129
|
+
const { execFile } = await import('node:child_process')
|
|
130
|
+
const { promisify } = await import('node:util')
|
|
131
|
+
const exec = promisify(execFile)
|
|
132
|
+
try {
|
|
133
|
+
await exec('xvfb-run', ['-a', 'blender', '--version'], { timeout: 30_000 })
|
|
134
|
+
} catch (err) {
|
|
135
|
+
throw new Error(
|
|
136
|
+
`cadbench preflight failed: ${(err instanceof Error ? err.message : String(err)).slice(0, 200)}\n` +
|
|
137
|
+
`Fix: install Blender + Xvfb (sudo apt-get install -y blender xvfb). The judge runs \`xvfb-run -a blender --background --python\`.`,
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
await load()
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
async goldArtifact() {
|
|
144
|
+
return undefined // no reference bpy script ships with the benchmark
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
})
|
|
146
148
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* The official task set (private GT, server-side graded) isn't released yet, so
|
|
9
9
|
* tasks here are seeded from the repo's dimension-named geometry fixtures (real
|
|
10
10
|
* GT STEPs scored by the real scorer). When CADGENBENCH_DATA_DIR is set, swap
|
|
11
|
-
*
|
|
11
|
+
* loadAll to read the published fixtures' description.yaml + ground_truth.step.
|
|
12
12
|
*
|
|
13
13
|
* Requires the CADGenBench venv (CADGENBENCH_VENV) + clone (CADGENBENCH_DIR) +
|
|
14
14
|
* xvfb (the scorer's alignment renders need a display).
|
|
@@ -19,7 +19,7 @@ import { mkdtemp, rm, writeFile } from 'node:fs/promises'
|
|
|
19
19
|
import { tmpdir } from 'node:os'
|
|
20
20
|
import { join } from 'node:path'
|
|
21
21
|
import { promisify } from 'node:util'
|
|
22
|
-
import type
|
|
22
|
+
import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
|
|
23
23
|
import { CGB_DIR, CGB_VENV_PY } from '../worker-build123d'
|
|
24
24
|
|
|
25
25
|
const execFileAsync = promisify(execFile)
|
|
@@ -60,23 +60,11 @@ function fixtureTasks(): Array<{ id: string; prompt: string; gtStep: string }> {
|
|
|
60
60
|
]
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
export function createCadGenBenchAdapter():
|
|
64
|
-
return {
|
|
65
|
-
|
|
63
|
+
export function createCadGenBenchAdapter(): RuntimeBenchmark {
|
|
64
|
+
return runtimeBenchmark({
|
|
65
|
+
id: 'cadgenbench',
|
|
66
66
|
|
|
67
|
-
async
|
|
68
|
-
const r = await execFileAsync(CGB_VENV_PY, ['-c', 'import cadgenbench.eval.evaluate, build123d, trimesh, manifold3d; print("ok")'], { timeout: 60_000 }).catch(
|
|
69
|
-
(e) => ({ stdout: '', stderr: e instanceof Error ? e.message : String(e) }),
|
|
70
|
-
)
|
|
71
|
-
if (!/ok/.test(r.stdout)) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`cadgenbench preflight failed (venv=${CGB_VENV_PY}): ${r.stderr.slice(0, 200)}\n` +
|
|
74
|
-
`Fix: git clone https://github.com/huggingface/cadgenbench ${CGB_DIR}; python3 -m venv $CADGENBENCH_VENV; $CADGENBENCH_VENV/bin/pip install -e ${CGB_DIR}`,
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
async loadTasks(opts: LoadOptions = {}) {
|
|
67
|
+
async loadAll(opts: LoadOptions = {}) {
|
|
80
68
|
// CGB_HARD_DIR (a dir with tasks.json = [{id,prompt,gtStep}]) overrides the
|
|
81
69
|
// trivial fixture primitives with hard multi-feature parts (real headroom).
|
|
82
70
|
let tasks = fixtureTasks()
|
|
@@ -88,16 +76,12 @@ export function createCadGenBenchAdapter(): BenchmarkAdapter {
|
|
|
88
76
|
if (opts.ids) tasks = tasks.filter((t) => opts.ids!.includes(t.id))
|
|
89
77
|
if (opts.limit != null) tasks = tasks.slice(0, opts.limit)
|
|
90
78
|
const meta = (gtStep: string): CgbMeta => ({ gtStep, resolveThreshold: Number(process.env.CGB_RESOLVE_THRESHOLD ?? 0.9) })
|
|
91
|
-
return tasks.map((t): BenchTask => ({ id: t.id, prompt: t.prompt, metadata: meta(t.gtStep) as unknown as Record<string, unknown> }))
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
async goldArtifact() {
|
|
95
|
-
return undefined // GT is a STEP file scored by the kernel, not a returnable artifact
|
|
79
|
+
return tasks.map((t): BenchTask => ({ id: t.id, payload: { prompt: t.prompt }, metadata: meta(t.gtStep) as unknown as Record<string, unknown> }))
|
|
96
80
|
},
|
|
97
81
|
|
|
98
|
-
async
|
|
82
|
+
async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
|
|
99
83
|
const { gtStep, resolveThreshold } = task.metadata as unknown as CgbMeta
|
|
100
|
-
if (!artifact.includes('ISO-10303-21')) return {
|
|
84
|
+
if (!artifact.includes('ISO-10303-21')) return { passed: false, score: 0, notes: 'artifact is not a STEP file', raw: {} }
|
|
101
85
|
const dir = await mkdtemp(join(tmpdir(), 'cgb-judge-'))
|
|
102
86
|
const cand = join(dir, 'candidate.step')
|
|
103
87
|
const scorer = join(dir, 'score.py')
|
|
@@ -109,13 +93,31 @@ export function createCadGenBenchAdapter(): BenchmarkAdapter {
|
|
|
109
93
|
(e) => ({ stdout: (e as { stdout?: string }).stdout ?? '', stderr: e instanceof Error ? e.message : String(e) }),
|
|
110
94
|
)
|
|
111
95
|
const m = /CGB_SCORE (\{.*\})/.exec(r.stdout)
|
|
112
|
-
if (!m) return {
|
|
96
|
+
if (!m) return { passed: false, score: 0, notes: `scorer produced no verdict: ${(r.stderr || r.stdout).slice(0, 160)}`, raw: {} }
|
|
113
97
|
const v = JSON.parse(m[1]) as { cad_score: number; status: string; error?: string }
|
|
114
98
|
const score = typeof v.cad_score === 'number' ? v.cad_score : 0
|
|
115
|
-
return {
|
|
99
|
+
return { passed: score >= resolveThreshold, score, notes: `cad_score=${score.toFixed(3)} status=${v.status}${v.error ? ` (${v.error})` : ''}`, raw: {} }
|
|
116
100
|
} finally {
|
|
117
101
|
await rm(dir, { recursive: true, force: true }).catch(() => {})
|
|
118
102
|
}
|
|
119
103
|
},
|
|
120
|
-
|
|
104
|
+
|
|
105
|
+
runtime: {
|
|
106
|
+
async preflight() {
|
|
107
|
+
const r = await execFileAsync(CGB_VENV_PY, ['-c', 'import cadgenbench.eval.evaluate, build123d, trimesh, manifold3d; print("ok")'], { timeout: 60_000 }).catch(
|
|
108
|
+
(e) => ({ stdout: '', stderr: e instanceof Error ? e.message : String(e) }),
|
|
109
|
+
)
|
|
110
|
+
if (!/ok/.test(r.stdout)) {
|
|
111
|
+
throw new Error(
|
|
112
|
+
`cadgenbench preflight failed (venv=${CGB_VENV_PY}): ${r.stderr.slice(0, 200)}\n` +
|
|
113
|
+
`Fix: git clone https://github.com/huggingface/cadgenbench ${CGB_DIR}; python3 -m venv $CADGENBENCH_VENV; $CADGENBENCH_VENV/bin/pip install -e ${CGB_DIR}`,
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
async goldArtifact() {
|
|
119
|
+
return undefined // GT is a STEP file scored by the kernel, not a returnable artifact
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
})
|
|
121
123
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Offline commit0 adapter test. The judge needs the official `commit0` harness +
|
|
3
3
|
* a Docker daemon, neither installed in CI, so this exercises the parts that run
|
|
4
|
-
* offline (fixtures
|
|
4
|
+
* offline (fixtures loadAll, the diff OutputAdapter, goldArtifact) and asserts
|
|
5
5
|
* the harness-backed path FAILS LOUD with the documented fix — never a fake score.
|
|
6
6
|
* Run: COMMIT0_FIXTURES=1 npx tsx --test src/benchmarks/commit0.test.mts
|
|
7
7
|
*/
|
|
@@ -14,22 +14,22 @@ process.env.COMMIT0_FIXTURES = '1'
|
|
|
14
14
|
type Events = Parameters<typeof commit0DiffOutput.parse>[0]
|
|
15
15
|
const stream = (text: string): Events => [{ data: { finalText: text } }] as unknown as Events
|
|
16
16
|
|
|
17
|
-
test('
|
|
17
|
+
test('loadAll (fixtures) yields stubbed-library tasks with diff-deliverable prompt + metadata', async () => {
|
|
18
18
|
const a = createCommit0Adapter()
|
|
19
|
-
const tasks = await a.
|
|
19
|
+
const tasks = await a.loadAll({ ids: ['commit-0/wcwidth'] })
|
|
20
20
|
assert.equal(tasks.length, 1)
|
|
21
21
|
const t = tasks[0]
|
|
22
22
|
assert.equal(t.id, 'commit-0/wcwidth')
|
|
23
|
-
assert.match(t.prompt, /```diff/)
|
|
23
|
+
assert.match(t.payload.prompt, /```diff/)
|
|
24
24
|
const md = t.metadata as Record<string, unknown>
|
|
25
25
|
assert.equal(md.instanceId, 'commit-0/wcwidth')
|
|
26
26
|
assert.equal(typeof md.referenceCommit, 'string')
|
|
27
27
|
assert.equal(md.srcDir, 'wcwidth/')
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
-
test('
|
|
30
|
+
test('loadAll limit slices the fixture set', async () => {
|
|
31
31
|
const a = createCommit0Adapter()
|
|
32
|
-
const tasks = await a.
|
|
32
|
+
const tasks = await a.loadAll({ limit: 2 })
|
|
33
33
|
assert.equal(tasks.length, 2)
|
|
34
34
|
})
|
|
35
35
|
|
|
@@ -47,8 +47,8 @@ test('diff OutputAdapter: last fenced ```diff wins; fence-less falls back to tri
|
|
|
47
47
|
|
|
48
48
|
test('goldArtifact is undefined — oracle is a git ref, documented, not a fabricated diff', async () => {
|
|
49
49
|
const a = createCommit0Adapter()
|
|
50
|
-
const [t] = await a.
|
|
51
|
-
assert.equal(await a.goldArtifact(t), undefined)
|
|
50
|
+
const [t] = await a.loadAll({ ids: ['commit-0/wcwidth'] })
|
|
51
|
+
assert.equal(await a.runtime.goldArtifact?.(t), undefined)
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
test('preflight FAILS LOUD with the install/Docker fix when the harness venv is absent', async () => {
|
|
@@ -59,7 +59,7 @@ test('preflight FAILS LOUD with the install/Docker fix when the harness venv is
|
|
|
59
59
|
process.env.COMMIT0_VENV = '.venv-commit0-does-not-exist'
|
|
60
60
|
try {
|
|
61
61
|
const a = createCommit0Adapter()
|
|
62
|
-
await assert.rejects(a.preflight(), (e: Error) => {
|
|
62
|
+
await assert.rejects(a.runtime.preflight!(), (e: Error) => {
|
|
63
63
|
assert.match(e.message, /pip install commit0/)
|
|
64
64
|
assert.match(e.message, /Docker daemon/)
|
|
65
65
|
return true
|