@tangle-network/agent-bench 0.1.0 → 0.3.6
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 +23 -0
- package/HARNESS.md +302 -0
- package/README.md +39 -2
- package/dist/adapters.d.ts +15 -0
- package/dist/adapters.js +43 -0
- package/dist/adapters.js.map +1 -0
- package/dist/benchmarks/_harness.d.ts +125 -0
- package/dist/benchmarks/_harness.js +33 -0
- package/dist/benchmarks/_harness.js.map +1 -0
- package/dist/benchmarks/aec-bench.d.ts +27 -0
- package/dist/benchmarks/aec-bench.js +8 -0
- package/dist/benchmarks/aec-bench.js.map +1 -0
- package/dist/benchmarks/agentbench.d.ts +16 -0
- package/dist/benchmarks/agentbench.js +10 -0
- package/dist/benchmarks/agentbench.js.map +1 -0
- package/dist/benchmarks/appworld.d.ts +37 -0
- package/dist/benchmarks/appworld.js +14 -0
- package/dist/benchmarks/appworld.js.map +1 -0
- package/dist/benchmarks/bfcl.d.ts +18 -0
- package/dist/benchmarks/bfcl.js +10 -0
- package/dist/benchmarks/bfcl.js.map +1 -0
- package/dist/benchmarks/cad-design.d.ts +45 -0
- package/dist/benchmarks/cad-design.js +7 -0
- package/dist/benchmarks/cad-design.js.map +1 -0
- package/dist/benchmarks/cadbench.d.ts +19 -0
- package/dist/benchmarks/cadbench.js +8 -0
- package/dist/benchmarks/cadbench.js.map +1 -0
- package/dist/benchmarks/cadgenbench.d.ts +22 -0
- package/dist/benchmarks/cadgenbench.js +8 -0
- package/dist/benchmarks/cadgenbench.js.map +1 -0
- package/dist/benchmarks/commit0.d.ts +31 -0
- package/dist/benchmarks/commit0.js +10 -0
- package/dist/benchmarks/commit0.js.map +1 -0
- package/dist/benchmarks/crag.d.ts +14 -0
- package/dist/benchmarks/crag.js +9 -0
- package/dist/benchmarks/crag.js.map +1 -0
- package/dist/benchmarks/dabstep.d.ts +18 -0
- package/dist/benchmarks/dabstep.js +10 -0
- package/dist/benchmarks/dabstep.js.map +1 -0
- package/dist/benchmarks/enterpriseops-gym.d.ts +38 -0
- package/dist/benchmarks/enterpriseops-gym.js +10 -0
- package/dist/benchmarks/enterpriseops-gym.js.map +1 -0
- package/dist/benchmarks/finresearchbench.d.ts +15 -0
- package/dist/benchmarks/finresearchbench.js +8 -0
- package/dist/benchmarks/finresearchbench.js.map +1 -0
- package/dist/benchmarks/finsearchcomp.d.ts +49 -0
- package/dist/benchmarks/finsearchcomp.js +7 -0
- package/dist/benchmarks/finsearchcomp.js.map +1 -0
- package/dist/benchmarks/frames.d.ts +59 -0
- package/dist/benchmarks/frames.js +13 -0
- package/dist/benchmarks/frames.js.map +1 -0
- package/dist/benchmarks/hotpotqa.d.ts +48 -0
- package/dist/benchmarks/hotpotqa.js +15 -0
- package/dist/benchmarks/hotpotqa.js.map +1 -0
- package/dist/benchmarks/humaneval.d.ts +53 -0
- package/dist/benchmarks/humaneval.js +15 -0
- package/dist/benchmarks/humaneval.js.map +1 -0
- package/dist/benchmarks/mind2web.d.ts +41 -0
- package/dist/benchmarks/mind2web.js +9 -0
- package/dist/benchmarks/mind2web.js.map +1 -0
- package/dist/benchmarks/nomiracl.d.ts +15 -0
- package/dist/benchmarks/nomiracl.js +9 -0
- package/dist/benchmarks/nomiracl.js.map +1 -0
- package/dist/benchmarks/open-rag-bench.d.ts +14 -0
- package/dist/benchmarks/open-rag-bench.js +9 -0
- package/dist/benchmarks/open-rag-bench.js.map +1 -0
- package/dist/benchmarks/programbench.d.ts +38 -0
- package/dist/benchmarks/programbench.js +10 -0
- package/dist/benchmarks/programbench.js.map +1 -0
- package/dist/benchmarks/rag-shared.d.ts +42 -0
- package/dist/benchmarks/rag-shared.js +39 -0
- package/dist/benchmarks/rag-shared.js.map +1 -0
- package/dist/benchmarks/ragbench.d.ts +16 -0
- package/dist/benchmarks/ragbench.js +9 -0
- package/dist/benchmarks/ragbench.js.map +1 -0
- package/dist/benchmarks/simpleqa.d.ts +64 -0
- package/dist/benchmarks/simpleqa.js +11 -0
- package/dist/benchmarks/simpleqa.js.map +1 -0
- package/dist/benchmarks/swe-bench.d.ts +56 -0
- package/dist/benchmarks/swe-bench.js +14 -0
- package/dist/benchmarks/swe-bench.js.map +1 -0
- package/dist/benchmarks/t2-ragbench.d.ts +14 -0
- package/dist/benchmarks/t2-ragbench.js +9 -0
- package/dist/benchmarks/t2-ragbench.js.map +1 -0
- package/dist/benchmarks/tau-bench-shared.d.ts +26 -0
- package/dist/benchmarks/tau-bench-shared.js +10 -0
- package/dist/benchmarks/tau-bench-shared.js.map +1 -0
- package/dist/benchmarks/tau2-bench.d.ts +7 -0
- package/dist/benchmarks/tau2-bench.js +11 -0
- package/dist/benchmarks/tau2-bench.js.map +1 -0
- package/dist/benchmarks/tau3-banking.d.ts +15 -0
- package/dist/benchmarks/tau3-banking.js +9 -0
- package/dist/benchmarks/tau3-banking.js.map +1 -0
- package/dist/benchmarks/terminal-bench.d.ts +24 -0
- package/dist/benchmarks/terminal-bench.js +8 -0
- package/dist/benchmarks/terminal-bench.js.map +1 -0
- package/dist/benchmarks/toollm.d.ts +16 -0
- package/dist/benchmarks/toollm.js +10 -0
- package/dist/benchmarks/toollm.js.map +1 -0
- package/dist/benchmarks/trata-hedge.d.ts +32 -0
- package/dist/benchmarks/trata-hedge.js +7 -0
- package/dist/benchmarks/trata-hedge.js.map +1 -0
- package/dist/benchmarks/types.d.ts +107 -0
- package/dist/benchmarks/types.js +1 -0
- package/dist/benchmarks/types.js.map +1 -0
- package/dist/benchmarks/webarena-verified.d.ts +16 -0
- package/dist/benchmarks/webarena-verified.js +10 -0
- package/dist/benchmarks/webarena-verified.js.map +1 -0
- package/dist/chunk-2PVVP7GN.js +197 -0
- package/dist/chunk-2PVVP7GN.js.map +1 -0
- package/dist/chunk-2XU6OGEN.js +170 -0
- package/dist/chunk-2XU6OGEN.js.map +1 -0
- package/dist/chunk-53UPUNBZ.js +325 -0
- package/dist/chunk-53UPUNBZ.js.map +1 -0
- package/dist/chunk-5SBJCB6W.js +144 -0
- package/dist/chunk-5SBJCB6W.js.map +1 -0
- package/dist/chunk-7WSD27QQ.js +118 -0
- package/dist/chunk-7WSD27QQ.js.map +1 -0
- package/dist/chunk-C7T7WEK2.js +103 -0
- package/dist/chunk-C7T7WEK2.js.map +1 -0
- package/dist/chunk-CKUVRZ2T.js +251 -0
- package/dist/chunk-CKUVRZ2T.js.map +1 -0
- package/dist/chunk-HBSWHQNJ.js +30 -0
- package/dist/chunk-HBSWHQNJ.js.map +1 -0
- package/dist/chunk-HHXFIHXC.js +116 -0
- package/dist/chunk-HHXFIHXC.js.map +1 -0
- package/dist/chunk-IFAV6KEM.js +276 -0
- package/dist/chunk-IFAV6KEM.js.map +1 -0
- package/dist/chunk-INNOYXCP.js +387 -0
- package/dist/chunk-INNOYXCP.js.map +1 -0
- package/dist/chunk-J3KDJNX2.js +182 -0
- package/dist/chunk-J3KDJNX2.js.map +1 -0
- package/dist/chunk-JRWWGMK7.js +148 -0
- package/dist/chunk-JRWWGMK7.js.map +1 -0
- package/dist/chunk-JTHWEDEW.js +32 -0
- package/dist/chunk-JTHWEDEW.js.map +1 -0
- package/dist/chunk-KDIKRJGB.js +120 -0
- package/dist/chunk-KDIKRJGB.js.map +1 -0
- package/dist/chunk-LRRD7NAG.js +301 -0
- package/dist/chunk-LRRD7NAG.js.map +1 -0
- package/dist/chunk-ODT47UAY.js +221 -0
- package/dist/chunk-ODT47UAY.js.map +1 -0
- package/dist/chunk-PA2ZKHJC.js +230 -0
- package/dist/chunk-PA2ZKHJC.js.map +1 -0
- package/dist/chunk-PPYSEKFM.js +182 -0
- package/dist/chunk-PPYSEKFM.js.map +1 -0
- package/dist/chunk-PUIRNYI7.js +189 -0
- package/dist/chunk-PUIRNYI7.js.map +1 -0
- package/dist/chunk-R36V2VP7.js +169 -0
- package/dist/chunk-R36V2VP7.js.map +1 -0
- package/dist/chunk-R67DFVLO.js +142 -0
- package/dist/chunk-R67DFVLO.js.map +1 -0
- package/dist/chunk-SEVJPLZC.js +260 -0
- package/dist/chunk-SEVJPLZC.js.map +1 -0
- package/dist/chunk-SYDW647C.js +318 -0
- package/dist/chunk-SYDW647C.js.map +1 -0
- package/dist/chunk-TBKU5XQI.js +228 -0
- package/dist/chunk-TBKU5XQI.js.map +1 -0
- package/dist/chunk-TSWPNOYM.js +147 -0
- package/dist/chunk-TSWPNOYM.js.map +1 -0
- package/dist/chunk-UAIOHCUK.js +27 -0
- package/dist/chunk-UAIOHCUK.js.map +1 -0
- package/dist/chunk-UPAMRDX4.js +233 -0
- package/dist/chunk-UPAMRDX4.js.map +1 -0
- package/dist/chunk-VQRS7VUC.js +342 -0
- package/dist/chunk-VQRS7VUC.js.map +1 -0
- package/dist/chunk-X3BTXCJ4.js +262 -0
- package/dist/chunk-X3BTXCJ4.js.map +1 -0
- package/dist/chunk-X5YKXC6V.js +211 -0
- package/dist/chunk-X5YKXC6V.js.map +1 -0
- package/dist/chunk-Y6O2OCUO.js +130 -0
- package/dist/chunk-Y6O2OCUO.js.map +1 -0
- package/dist/chunk-YCGY7UIZ.js +208 -0
- package/dist/chunk-YCGY7UIZ.js.map +1 -0
- package/dist/chunk-Z7ML6L77.js +162 -0
- package/dist/chunk-Z7ML6L77.js.map +1 -0
- package/dist/chunk-ZEWMTR5M.js +136 -0
- package/dist/chunk-ZEWMTR5M.js.map +1 -0
- package/dist/index.d.ts +355 -0
- package/dist/index.js +1908 -0
- package/dist/index.js.map +1 -0
- package/fixtures/aec-bench.json +18 -0
- package/fixtures/agentbench-dbbench.json +22 -0
- package/fixtures/bfcl.json +45 -0
- package/fixtures/commit0.json +72 -0
- package/fixtures/crag.json +10 -0
- package/fixtures/dabstep.json +22 -0
- package/fixtures/enterpriseops-gym.json +103 -0
- package/fixtures/finresearchbench.json +21 -0
- package/fixtures/finsearchcomp.json +66 -0
- package/fixtures/frames.json +26 -0
- package/fixtures/hotpotqa.json +182 -0
- package/fixtures/nomiracl.json +26 -0
- package/fixtures/open-rag-bench.json +16 -0
- package/fixtures/pier-agent/no-model-task/environment/Dockerfile +16 -0
- package/fixtures/pier-agent/no-model-task/environment/seed/src/status.txt +1 -0
- package/fixtures/pier-agent/no-model-task/instruction.md +6 -0
- package/fixtures/pier-agent/no-model-task/pre_artifacts.sh +6 -0
- package/fixtures/pier-agent/no-model-task/task.toml +35 -0
- package/fixtures/pier-agent/no-model-task/tests/Dockerfile +17 -0
- package/fixtures/pier-agent/no-model-task/tests/seed/src/status.txt +1 -0
- package/fixtures/pier-agent/no-model-task/tests/test.sh +19 -0
- package/fixtures/programbench.json +17 -0
- package/fixtures/ragbench.json +21 -0
- package/fixtures/simpleqa.json +121 -0
- package/fixtures/t2-ragbench.json +13 -0
- package/fixtures/tau2-bench.json +16 -0
- package/fixtures/tau3-banking.json +16 -0
- package/fixtures/toollm.json +28 -0
- package/fixtures/webarena-verified.json +20 -0
- package/package.json +60 -20
- package/pier_agents/__init__.py +18 -0
- package/pier_agents/candidate_contract.py +755 -0
- package/pier_agents/process_boundary.py +321 -0
- package/pier_agents/tangle_candidate.py +907 -0
- package/pier_agents/workspace_boundary.py +368 -0
- package/scripts/appworld_driver.py +359 -0
- package/scripts/cadbench_prepare.py +22 -0
- package/scripts/cadgenbench_hard_parts.py +48 -0
- package/scripts/clbench_codebase_judge.py +73 -0
- package/scripts/commit0_judge.py +170 -0
- package/scripts/dabstep_judge.py +42 -0
- package/scripts/enterpriseops_gym_judge.py +281 -0
- package/scripts/programbench_judge.py +120 -0
- package/scripts/render-gate-chart.mjs +176 -0
- package/scripts/run-package-tests.mjs +56 -0
- package/scripts/terminate-pier-trial.mts +66 -0
- package/scripts/trata-hedge/README.md +56 -0
- package/scripts/trata-hedge/run.sh +60 -0
- package/scripts/trata-hedge/solve.py +83 -0
- package/scripts/verify-packed-consumer.mjs +235 -0
- package/scripts/verify-pier-agent.mts +715 -0
- package/scripts/verify-pier-pair.mts +74 -0
- package/scripts/verify-pier-recovery.mts +139 -0
- package/src/adapters.ts +26 -0
- package/src/benchmarks/_harness.test.mts +178 -0
- package/src/benchmarks/_harness.ts +239 -16
- package/src/benchmarks/agentbench.ts +163 -0
- package/src/benchmarks/appworld.test.mts +15 -9
- package/src/benchmarks/bfcl.ts +346 -0
- package/src/benchmarks/crag.ts +137 -0
- package/src/benchmarks/dabstep.test.mts +70 -0
- package/src/benchmarks/dabstep.ts +212 -0
- package/src/benchmarks/external-adapters.test.mts +150 -0
- package/src/benchmarks/finresearchbench.ts +269 -0
- package/src/benchmarks/humaneval.ts +20 -8
- package/src/benchmarks/nomiracl.ts +180 -0
- package/src/benchmarks/open-rag-bench.ts +153 -0
- package/src/benchmarks/rag-benchmarks.test.mts +138 -0
- package/src/benchmarks/rag-shared.ts +327 -0
- package/src/benchmarks/ragbench.ts +171 -0
- package/src/benchmarks/swe-bench.test.mts +61 -0
- package/src/benchmarks/swe-bench.ts +201 -19
- package/src/benchmarks/t2-ragbench.ts +166 -0
- package/src/benchmarks/tau-bench-shared.ts +214 -0
- package/src/benchmarks/tau2-bench.ts +30 -0
- package/src/benchmarks/tau3-banking.ts +29 -0
- package/src/benchmarks/terminal-bench.test.mts +33 -0
- package/src/benchmarks/terminal-bench.ts +23 -8
- package/src/benchmarks/toollm.ts +254 -0
- package/src/benchmarks/types.ts +42 -0
- package/src/benchmarks/webarena-verified.ts +200 -0
- package/src/commit0-prereqs.sh +0 -0
- package/src/coordination-mcp-container-reach.mts +181 -0
- package/src/decoder-live.mts +1 -1
- package/src/examples/README.md +103 -39
- package/src/examples/benchmark-matrix.mts +101 -0
- package/src/examples/lean-proof-gate.README.md +77 -0
- package/src/examples/lean-proof-gate.mts +162 -0
- package/src/examples/lean-verify.ts +95 -0
- package/src/examples/lean.Dockerfile +12 -0
- package/src/examples/math-demo.mts +9 -7
- package/src/examples/strategy-demo.mts +10 -12
- package/src/gate.ts +3 -2
- package/src/hev-eval.mts +69 -0
- package/src/hev-improve.mts +169 -0
- package/src/hev-structural.mts +688 -0
- package/src/index.ts +73 -0
- package/src/mbpp-structural.mts +662 -0
- package/src/pier-agent.test-fixtures.mts +19 -0
- package/src/pier-agent.test.mts +363 -0
- package/src/pier-agent.ts +657 -0
- package/src/pier-result-grader.mjs +30 -0
- package/src/pier-result-grader.test.mts +62 -0
- package/src/pier-result-grader.ts +108 -0
- package/src/pier-task-outcome.test.mts +117 -0
- package/src/pier-task-outcome.ts +240 -0
- package/src/pier-trial-controller.test.mts +412 -0
- package/src/pier-trial-controller.ts +858 -0
- package/src/pier-trial-supervisor.mjs +352 -0
- package/src/resolve-client.ts +25 -2
- package/src/run-benchmarks-cli.mts +72 -0
- package/src/run-benchmarks-report.ts +66 -0
- package/src/run-benchmarks.test.mts +231 -0
- package/src/run-benchmarks.ts +589 -0
- package/src/smoke-structural-rollout.mts +393 -0
- package/src/swe-bench-env.test.ts +207 -0
- package/src/swe-bench-env.ts +554 -0
- package/src/swe-jail.ts +293 -0
- package/src/swe-self-improve.mts +84 -0
- package/src/swe-structural-judge-policy.test.ts +117 -0
- package/src/swe-structural-judge-policy.ts +133 -0
- package/src/swe-structural-policy.test.ts +124 -0
- package/src/swe-structural-policy.ts +132 -0
- package/src/swe-structural-provenance.test.ts +93 -0
- package/src/swe-structural-provenance.ts +138 -0
- package/src/swe-structural.mts +1260 -0
- package/src/swe-temp.ts +14 -0
- package/src/tb-container-executor.mts +234 -0
- package/src/tb-container-executor.test.mts +99 -0
- package/src/tb-supervisor-sidecar.mts +222 -0
- package/src/trata-gepa.mts +1 -1
- package/steerers/eops-itsm-population.json +1 -0
- package/tb_agents/opencode_refine_agent.py +117 -0
- package/tb_agents/opencode_router_agent.py +406 -0
- package/tb_agents/opencode_supervisor_agent.py +239 -0
- package/tb_agents/script_agent.py +66 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createToolLlmAdapter
|
|
3
|
+
} from "./chunk-2PVVP7GN.js";
|
|
4
|
+
import {
|
|
5
|
+
createTrataHedgeAdapter
|
|
6
|
+
} from "./chunk-VQRS7VUC.js";
|
|
7
|
+
import {
|
|
8
|
+
createWebArenaVerifiedAdapter
|
|
9
|
+
} from "./chunk-Z7ML6L77.js";
|
|
10
|
+
import {
|
|
11
|
+
createRagBenchAdapter
|
|
12
|
+
} from "./chunk-R67DFVLO.js";
|
|
13
|
+
import {
|
|
14
|
+
createSimpleQaAdapter
|
|
15
|
+
} from "./chunk-SEVJPLZC.js";
|
|
16
|
+
import {
|
|
17
|
+
createSweBenchAdapter
|
|
18
|
+
} from "./chunk-CKUVRZ2T.js";
|
|
19
|
+
import {
|
|
20
|
+
createT2RagBenchAdapter
|
|
21
|
+
} from "./chunk-Y6O2OCUO.js";
|
|
22
|
+
import {
|
|
23
|
+
createTau2BenchAdapter
|
|
24
|
+
} from "./chunk-HBSWHQNJ.js";
|
|
25
|
+
import {
|
|
26
|
+
createTau3BankingAdapter
|
|
27
|
+
} from "./chunk-UAIOHCUK.js";
|
|
28
|
+
import {
|
|
29
|
+
createTerminalBenchAdapter
|
|
30
|
+
} from "./chunk-JRWWGMK7.js";
|
|
31
|
+
import {
|
|
32
|
+
createFramesAdapter
|
|
33
|
+
} from "./chunk-INNOYXCP.js";
|
|
34
|
+
import {
|
|
35
|
+
createHotpotqaAdapter
|
|
36
|
+
} from "./chunk-PA2ZKHJC.js";
|
|
37
|
+
import {
|
|
38
|
+
createHumanEvalAdapter
|
|
39
|
+
} from "./chunk-PPYSEKFM.js";
|
|
40
|
+
import {
|
|
41
|
+
createMind2WebAdapter
|
|
42
|
+
} from "./chunk-TBKU5XQI.js";
|
|
43
|
+
import {
|
|
44
|
+
createNoMiraclAdapter
|
|
45
|
+
} from "./chunk-TSWPNOYM.js";
|
|
46
|
+
import {
|
|
47
|
+
createOpenRagBenchAdapter
|
|
48
|
+
} from "./chunk-KDIKRJGB.js";
|
|
49
|
+
import {
|
|
50
|
+
createProgrambenchAdapter
|
|
51
|
+
} from "./chunk-ZEWMTR5M.js";
|
|
52
|
+
import {
|
|
53
|
+
createCadBenchAdapter
|
|
54
|
+
} from "./chunk-PUIRNYI7.js";
|
|
55
|
+
import {
|
|
56
|
+
createCadGenBenchAdapter
|
|
57
|
+
} from "./chunk-C7T7WEK2.js";
|
|
58
|
+
import {
|
|
59
|
+
createCommit0Adapter
|
|
60
|
+
} from "./chunk-2XU6OGEN.js";
|
|
61
|
+
import {
|
|
62
|
+
createCragAdapter
|
|
63
|
+
} from "./chunk-HHXFIHXC.js";
|
|
64
|
+
import {
|
|
65
|
+
createDabstepAdapter
|
|
66
|
+
} from "./chunk-J3KDJNX2.js";
|
|
67
|
+
import {
|
|
68
|
+
createEnterpriseOpsGymAdapter
|
|
69
|
+
} from "./chunk-X5YKXC6V.js";
|
|
70
|
+
import {
|
|
71
|
+
createFinResearchBenchAdapter
|
|
72
|
+
} from "./chunk-YCGY7UIZ.js";
|
|
73
|
+
import {
|
|
74
|
+
createFinsearchcompAdapter
|
|
75
|
+
} from "./chunk-UPAMRDX4.js";
|
|
76
|
+
import {
|
|
77
|
+
createAecBenchAdapter
|
|
78
|
+
} from "./chunk-ODT47UAY.js";
|
|
79
|
+
import {
|
|
80
|
+
createAgentBenchAdapter
|
|
81
|
+
} from "./chunk-7WSD27QQ.js";
|
|
82
|
+
import {
|
|
83
|
+
createAppWorldAdapter,
|
|
84
|
+
createAppWorldReactAdapter
|
|
85
|
+
} from "./chunk-SYDW647C.js";
|
|
86
|
+
import {
|
|
87
|
+
createBfclAdapter
|
|
88
|
+
} from "./chunk-IFAV6KEM.js";
|
|
89
|
+
import {
|
|
90
|
+
createCadDesignAdapter
|
|
91
|
+
} from "./chunk-53UPUNBZ.js";
|
|
92
|
+
|
|
93
|
+
// src/adapters.ts
|
|
94
|
+
var ADAPTERS = {
|
|
95
|
+
"swe-bench": createSweBenchAdapter,
|
|
96
|
+
"terminal-bench": createTerminalBenchAdapter,
|
|
97
|
+
// Code-benches sharing ./benchmarks/_harness (stage → external evaluator → report).
|
|
98
|
+
// loadTasks fetches the REAL dataset (committed fixtures fallback offline); judge
|
|
99
|
+
// delegates to the benchmark's own harness and fails loud when it/Docker is absent.
|
|
100
|
+
"aec-bench": createAecBenchAdapter,
|
|
101
|
+
commit0: createCommit0Adapter,
|
|
102
|
+
dabstep: createDabstepAdapter,
|
|
103
|
+
programbench: createProgrambenchAdapter,
|
|
104
|
+
"webarena-verified": createWebArenaVerifiedAdapter,
|
|
105
|
+
"tau2-bench": createTau2BenchAdapter,
|
|
106
|
+
"tau3-banking": createTau3BankingAdapter,
|
|
107
|
+
agentbench: createAgentBenchAdapter,
|
|
108
|
+
bfcl: createBfclAdapter,
|
|
109
|
+
toollm: createToolLlmAdapter,
|
|
110
|
+
appworld: createAppWorldAdapter,
|
|
111
|
+
// AppWorld's native interactive protocol — the worker is the in-engine ReAct
|
|
112
|
+
// episode (execution feedback every turn), the mode published baselines use.
|
|
113
|
+
"appworld-react": createAppWorldReactAdapter,
|
|
114
|
+
"enterpriseops-gym": createEnterpriseOpsGymAdapter,
|
|
115
|
+
"cad-design": createCadDesignAdapter,
|
|
116
|
+
cadbench: createCadBenchAdapter,
|
|
117
|
+
cadgenbench: createCadGenBenchAdapter,
|
|
118
|
+
frames: createFramesAdapter,
|
|
119
|
+
ragbench: createRagBenchAdapter,
|
|
120
|
+
crag: createCragAdapter,
|
|
121
|
+
nomiracl: createNoMiraclAdapter,
|
|
122
|
+
"open-rag-bench": createOpenRagBenchAdapter,
|
|
123
|
+
"t2-ragbench": createT2RagBenchAdapter,
|
|
124
|
+
finresearchbench: createFinResearchBenchAdapter,
|
|
125
|
+
finsearchcomp: createFinsearchcompAdapter,
|
|
126
|
+
simpleqa: createSimpleQaAdapter,
|
|
127
|
+
hotpotqa: createHotpotqaAdapter,
|
|
128
|
+
// Deployable-checker code domain: worker = router completion, judge = Docker test
|
|
129
|
+
// run (--network=none). The steering A/B counterpart to humaneval-gate.mts (selection).
|
|
130
|
+
humaneval: createHumanEvalAdapter,
|
|
131
|
+
mind2web: createMind2WebAdapter,
|
|
132
|
+
"trata-hedge": createTrataHedgeAdapter
|
|
133
|
+
};
|
|
134
|
+
function resolveAdapter(key) {
|
|
135
|
+
const make = ADAPTERS[key];
|
|
136
|
+
if (!make) throw new Error(`unknown benchmark ${JSON.stringify(key)} (have: ${Object.keys(ADAPTERS).join(", ")})`);
|
|
137
|
+
return make();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export {
|
|
141
|
+
ADAPTERS,
|
|
142
|
+
resolveAdapter
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=chunk-5SBJCB6W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters.ts"],"sourcesContent":["/**\n * The benchmark registry — the single source of truth for every wired benchmark.\n * One key per benchmark; the value is its `BenchmarkAdapter` factory. `runBenchmarks`\n * (the unifier) maps over this; `run.ts`, `rsi.ts`, and `corpus-replay.mts` all read it\n * here rather than each keeping their own copy.\n */\n\nimport { createAecBenchAdapter } from './benchmarks/aec-bench'\nimport { createAgentBenchAdapter } from './benchmarks/agentbench'\nimport { createAppWorldAdapter, createAppWorldReactAdapter } from './benchmarks/appworld'\nimport { createBfclAdapter } from './benchmarks/bfcl'\nimport { createCadBenchAdapter } from './benchmarks/cadbench'\nimport { createCadDesignAdapter } from './benchmarks/cad-design'\nimport { createCadGenBenchAdapter } from './benchmarks/cadgenbench'\nimport { createCommit0Adapter } from './benchmarks/commit0'\nimport { createCragAdapter } from './benchmarks/crag'\nimport { createDabstepAdapter } from './benchmarks/dabstep'\nimport { createEnterpriseOpsGymAdapter } from './benchmarks/enterpriseops-gym'\nimport { createFinResearchBenchAdapter } from './benchmarks/finresearchbench'\nimport { createFinsearchcompAdapter } from './benchmarks/finsearchcomp'\nimport { createFramesAdapter } from './benchmarks/frames'\nimport { createHotpotqaAdapter } from './benchmarks/hotpotqa'\nimport { createHumanEvalAdapter } from './benchmarks/humaneval'\nimport { createMind2WebAdapter } from './benchmarks/mind2web'\nimport { createNoMiraclAdapter } from './benchmarks/nomiracl'\nimport { createOpenRagBenchAdapter } from './benchmarks/open-rag-bench'\nimport { createProgrambenchAdapter } from './benchmarks/programbench'\nimport { createRagBenchAdapter } from './benchmarks/ragbench'\nimport { createSimpleQaAdapter } from './benchmarks/simpleqa'\nimport { createSweBenchAdapter } from './benchmarks/swe-bench'\nimport { createT2RagBenchAdapter } from './benchmarks/t2-ragbench'\nimport { createTau2BenchAdapter } from './benchmarks/tau2-bench'\nimport { createTau3BankingAdapter } from './benchmarks/tau3-banking'\nimport { createTerminalBenchAdapter } from './benchmarks/terminal-bench'\nimport { createToolLlmAdapter } from './benchmarks/toollm'\nimport { createTrataHedgeAdapter } from './benchmarks/trata-hedge'\nimport { createWebArenaVerifiedAdapter } from './benchmarks/webarena-verified'\nimport type { BenchmarkAdapter } from './benchmarks/types'\n\nexport const ADAPTERS: Record<string, () => BenchmarkAdapter> = {\n 'swe-bench': createSweBenchAdapter,\n 'terminal-bench': createTerminalBenchAdapter,\n // Code-benches sharing ./benchmarks/_harness (stage → external evaluator → report).\n // loadTasks fetches the REAL dataset (committed fixtures fallback offline); judge\n // delegates to the benchmark's own harness and fails loud when it/Docker is absent.\n 'aec-bench': createAecBenchAdapter,\n commit0: createCommit0Adapter,\n dabstep: createDabstepAdapter,\n programbench: createProgrambenchAdapter,\n 'webarena-verified': createWebArenaVerifiedAdapter,\n 'tau2-bench': createTau2BenchAdapter,\n 'tau3-banking': createTau3BankingAdapter,\n agentbench: createAgentBenchAdapter,\n bfcl: createBfclAdapter,\n toollm: createToolLlmAdapter,\n appworld: createAppWorldAdapter,\n // AppWorld's native interactive protocol — the worker is the in-engine ReAct\n // episode (execution feedback every turn), the mode published baselines use.\n 'appworld-react': createAppWorldReactAdapter,\n 'enterpriseops-gym': createEnterpriseOpsGymAdapter,\n 'cad-design': createCadDesignAdapter,\n cadbench: createCadBenchAdapter,\n cadgenbench: createCadGenBenchAdapter,\n frames: createFramesAdapter,\n ragbench: createRagBenchAdapter,\n crag: createCragAdapter,\n nomiracl: createNoMiraclAdapter,\n 'open-rag-bench': createOpenRagBenchAdapter,\n 't2-ragbench': createT2RagBenchAdapter,\n finresearchbench: createFinResearchBenchAdapter,\n finsearchcomp: createFinsearchcompAdapter,\n simpleqa: createSimpleQaAdapter,\n hotpotqa: createHotpotqaAdapter,\n // Deployable-checker code domain: worker = router completion, judge = Docker test\n // run (--network=none). The steering A/B counterpart to humaneval-gate.mts (selection).\n humaneval: createHumanEvalAdapter,\n mind2web: createMind2WebAdapter,\n 'trata-hedge': createTrataHedgeAdapter,\n}\n\n/** Resolve a benchmark key to its adapter, failing loud with the known keys. */\nexport function resolveAdapter(key: string): BenchmarkAdapter {\n const make = ADAPTERS[key]\n if (!make) throw new Error(`unknown benchmark ${JSON.stringify(key)} (have: ${Object.keys(ADAPTERS).join(', ')})`)\n return make()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCO,IAAM,WAAmD;AAAA,EAC9D,aAAa;AAAA,EACb,kBAAkB;AAAA;AAAA;AAAA;AAAA,EAIlB,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AAAA,EACT,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,UAAU;AAAA;AAAA;AAAA,EAGV,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,cAAc;AAAA,EACd,UAAU;AAAA,EACV,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,EACN,UAAU;AAAA,EACV,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,UAAU;AAAA,EACV,UAAU;AAAA;AAAA;AAAA,EAGV,WAAW;AAAA,EACX,UAAU;AAAA,EACV,eAAe;AACjB;AAGO,SAAS,eAAe,KAA+B;AAC5D,QAAM,OAAO,SAAS,GAAG;AACzB,MAAI,CAAC,KAAM,OAAM,IAAI,MAAM,qBAAqB,KAAK,UAAU,GAAG,CAAC,WAAW,OAAO,KAAK,QAAQ,EAAE,KAAK,IAAI,CAAC,GAAG;AACjH,SAAO,KAAK;AACd;","names":[]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
benchRoot
|
|
3
|
+
} from "./chunk-LRRD7NAG.js";
|
|
4
|
+
|
|
5
|
+
// src/benchmarks/agentbench.ts
|
|
6
|
+
import { readFile } from "fs/promises";
|
|
7
|
+
import { join } from "path";
|
|
8
|
+
var FIXTURES = join(benchRoot, "fixtures", "agentbench-dbbench.json");
|
|
9
|
+
var DEFAULT_SPLIT = "dev";
|
|
10
|
+
var agentbenchDir = () => process.env.AGENTBENCH_DIR;
|
|
11
|
+
var agentbenchAnswerOutput = {
|
|
12
|
+
parse(events) {
|
|
13
|
+
let text = "";
|
|
14
|
+
for (const ev of events) {
|
|
15
|
+
const d = ev?.data;
|
|
16
|
+
const t = d?.finalText ?? d?.text ?? d?.result;
|
|
17
|
+
if (typeof t === "string" && t.length > 0) text = t;
|
|
18
|
+
}
|
|
19
|
+
const fences = [...text.matchAll(/```(?:text|answer)?\s*\n([\s\S]*?)```/g)];
|
|
20
|
+
return (fences.at(-1)?.[1] ?? text).trim();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
function normalizeAnswer(value) {
|
|
24
|
+
return value.toLowerCase().replace(/\s+/g, " ").replace(/^["'`]+|["'`]+$/g, "").trim();
|
|
25
|
+
}
|
|
26
|
+
function rowToTask(row, index, split) {
|
|
27
|
+
const columns = row.table?.table_info?.columns?.map((c) => `${c.name}${c.type ? ` (${c.type})` : ""}`).join(", ");
|
|
28
|
+
const sampleRows = row.table?.table_info?.rows?.slice(0, 40);
|
|
29
|
+
const meta = {
|
|
30
|
+
labels: row.label,
|
|
31
|
+
split,
|
|
32
|
+
subset: "dbbench",
|
|
33
|
+
table: row.table
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
id: `dbbench-${split}-${index}`,
|
|
37
|
+
split,
|
|
38
|
+
prompt: [
|
|
39
|
+
"Answer this AgentBench DBBench question using the table below.",
|
|
40
|
+
"Return only the answer value.",
|
|
41
|
+
"",
|
|
42
|
+
`Question: ${row.description}`,
|
|
43
|
+
row.table?.table_name ? `Table: ${row.table.table_name}` : void 0,
|
|
44
|
+
columns ? `Columns: ${columns}` : void 0,
|
|
45
|
+
sampleRows ? `Rows JSON: ${JSON.stringify(sampleRows)}` : void 0
|
|
46
|
+
].filter(Boolean).join("\n"),
|
|
47
|
+
metadata: meta
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function readMeta(task) {
|
|
51
|
+
const md = task.metadata;
|
|
52
|
+
if (!md || !Array.isArray(md.labels)) {
|
|
53
|
+
throw new Error(`agentbench task ${task.id} missing metadata \u2014 loadTasks did not populate it`);
|
|
54
|
+
}
|
|
55
|
+
return md;
|
|
56
|
+
}
|
|
57
|
+
function selectRows(rows, opts, split) {
|
|
58
|
+
let tasks = rows.map((row, index) => rowToTask(row, index, split));
|
|
59
|
+
if (opts.ids) {
|
|
60
|
+
const want = new Set(opts.ids);
|
|
61
|
+
tasks = tasks.filter((task) => want.has(task.id));
|
|
62
|
+
} else if (opts.limit !== void 0) {
|
|
63
|
+
tasks = tasks.slice(0, opts.limit);
|
|
64
|
+
}
|
|
65
|
+
if (tasks.length === 0) throw new Error(`AgentBench DBBench: no tasks matched ${JSON.stringify(opts)}`);
|
|
66
|
+
return tasks;
|
|
67
|
+
}
|
|
68
|
+
async function loadJsonl(path) {
|
|
69
|
+
const raw = await readFile(path, "utf8");
|
|
70
|
+
return raw.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => JSON.parse(line));
|
|
71
|
+
}
|
|
72
|
+
async function loadFixtures(opts, split) {
|
|
73
|
+
const rows = JSON.parse(await readFile(FIXTURES, "utf8"));
|
|
74
|
+
console.warn(`[agentbench] AGENTBENCH_FIXTURES=1 \u2014 loading ${rows.length} DBBench adapter fixtures`);
|
|
75
|
+
return selectRows(rows, opts, split);
|
|
76
|
+
}
|
|
77
|
+
function createAgentBenchAdapter() {
|
|
78
|
+
const fixturesMode = process.env.AGENTBENCH_FIXTURES === "1";
|
|
79
|
+
return {
|
|
80
|
+
name: "agentbench",
|
|
81
|
+
output: agentbenchAnswerOutput,
|
|
82
|
+
async preflight() {
|
|
83
|
+
if (fixturesMode) return;
|
|
84
|
+
const dir = agentbenchDir();
|
|
85
|
+
if (!dir) {
|
|
86
|
+
throw new Error("AGENTBENCH_DIR is required. Fix: clone https://github.com/THUDM/AgentBench and set AGENTBENCH_DIR=/path/to/AgentBench.");
|
|
87
|
+
}
|
|
88
|
+
await loadJsonl(join(dir, "data", "dbbench", `${DEFAULT_SPLIT}.jsonl`));
|
|
89
|
+
},
|
|
90
|
+
async loadTasks(opts = {}) {
|
|
91
|
+
const split = opts.split ?? DEFAULT_SPLIT;
|
|
92
|
+
if (fixturesMode) return loadFixtures(opts, split);
|
|
93
|
+
const dir = agentbenchDir();
|
|
94
|
+
if (!dir) throw new Error("AGENTBENCH_DIR is required to load AgentBench DBBench tasks");
|
|
95
|
+
return selectRows(await loadJsonl(join(dir, "data", "dbbench", `${split}.jsonl`)), opts, split);
|
|
96
|
+
},
|
|
97
|
+
async goldArtifact(task) {
|
|
98
|
+
return readMeta(task).labels[0];
|
|
99
|
+
},
|
|
100
|
+
async judge(task, artifact) {
|
|
101
|
+
const meta = readMeta(task);
|
|
102
|
+
const got = normalizeAnswer(artifact);
|
|
103
|
+
const expected = meta.labels.map(normalizeAnswer);
|
|
104
|
+
const resolved = expected.includes(got);
|
|
105
|
+
return {
|
|
106
|
+
resolved,
|
|
107
|
+
score: resolved ? 1 : 0,
|
|
108
|
+
detail: JSON.stringify({ subset: meta.subset, split: meta.split, expected: meta.labels, got: artifact })
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
agentbenchAnswerOutput,
|
|
116
|
+
createAgentBenchAdapter
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=chunk-7WSD27QQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/benchmarks/agentbench.ts"],"sourcesContent":["/**\n * AgentBench deterministic subset adapter.\n *\n * This targets AgentBench DBBench rows only: question + table + published label.\n * It does not wrap AgentBench's controller protocol or the non-deterministic game\n * environments. Worker artifact = final answer text. Judge = exact match against\n * the official DBBench label list after light whitespace/case normalization.\n */\n\nimport { readFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport type { OutputAdapter } from '@tangle-network/agent-runtime/loops'\nimport { benchRoot } from './_harness'\nimport type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'\n\nconst FIXTURES = join(benchRoot, 'fixtures', 'agentbench-dbbench.json')\nconst DEFAULT_SPLIT = 'dev'\n\ninterface AgentBenchDbRow {\n description: string\n label: string[]\n table?: {\n table_name?: string\n table_info?: {\n columns?: Array<{ name: string; type?: string }>\n rows?: unknown[][]\n }\n }\n}\n\ninterface AgentBenchMeta {\n labels: string[]\n split: string\n subset: 'dbbench'\n table?: AgentBenchDbRow['table']\n}\n\nconst agentbenchDir = (): string | undefined => process.env.AGENTBENCH_DIR\n\nexport const agentbenchAnswerOutput: OutputAdapter<string> = {\n parse(events) {\n let text = ''\n for (const ev of events) {\n const d = (ev as { data?: Record<string, unknown> })?.data\n const t = d?.finalText ?? d?.text ?? d?.result\n if (typeof t === 'string' && t.length > 0) text = t\n }\n const fences = [...text.matchAll(/```(?:text|answer)?\\s*\\n([\\s\\S]*?)```/g)]\n return (fences.at(-1)?.[1] ?? text).trim()\n },\n}\n\nfunction normalizeAnswer(value: string): string {\n return value\n .toLowerCase()\n .replace(/\\s+/g, ' ')\n .replace(/^[\"'`]+|[\"'`]+$/g, '')\n .trim()\n}\n\nfunction rowToTask(row: AgentBenchDbRow, index: number, split: string): BenchTask {\n const columns = row.table?.table_info?.columns?.map((c) => `${c.name}${c.type ? ` (${c.type})` : ''}`).join(', ')\n const sampleRows = row.table?.table_info?.rows?.slice(0, 40)\n const meta: AgentBenchMeta = {\n labels: row.label,\n split,\n subset: 'dbbench',\n table: row.table,\n }\n return {\n id: `dbbench-${split}-${index}`,\n split,\n prompt: [\n 'Answer this AgentBench DBBench question using the table below.',\n 'Return only the answer value.',\n '',\n `Question: ${row.description}`,\n row.table?.table_name ? `Table: ${row.table.table_name}` : undefined,\n columns ? `Columns: ${columns}` : undefined,\n sampleRows ? `Rows JSON: ${JSON.stringify(sampleRows)}` : undefined,\n ]\n .filter(Boolean)\n .join('\\n'),\n metadata: meta as unknown as Record<string, unknown>,\n }\n}\n\nfunction readMeta(task: BenchTask): AgentBenchMeta {\n const md = task.metadata\n if (!md || !Array.isArray(md.labels)) {\n throw new Error(`agentbench task ${task.id} missing metadata — loadTasks did not populate it`)\n }\n return md as unknown as AgentBenchMeta\n}\n\nfunction selectRows(rows: AgentBenchDbRow[], opts: LoadOptions, split: string): BenchTask[] {\n let tasks = rows.map((row, index) => rowToTask(row, index, split))\n if (opts.ids) {\n const want = new Set(opts.ids)\n tasks = tasks.filter((task) => want.has(task.id))\n } else if (opts.limit !== undefined) {\n tasks = tasks.slice(0, opts.limit)\n }\n if (tasks.length === 0) throw new Error(`AgentBench DBBench: no tasks matched ${JSON.stringify(opts)}`)\n return tasks\n}\n\nasync function loadJsonl(path: string): Promise<AgentBenchDbRow[]> {\n const raw = await readFile(path, 'utf8')\n return raw\n .split('\\n')\n .map((line) => line.trim())\n .filter(Boolean)\n .map((line) => JSON.parse(line) as AgentBenchDbRow)\n}\n\nasync function loadFixtures(opts: LoadOptions, split: string): Promise<BenchTask[]> {\n const rows = JSON.parse(await readFile(FIXTURES, 'utf8')) as AgentBenchDbRow[]\n console.warn(`[agentbench] AGENTBENCH_FIXTURES=1 — loading ${rows.length} DBBench adapter fixtures`)\n return selectRows(rows, opts, split)\n}\n\nexport function createAgentBenchAdapter(): BenchmarkAdapter {\n const fixturesMode = process.env.AGENTBENCH_FIXTURES === '1'\n\n return {\n name: 'agentbench',\n output: agentbenchAnswerOutput,\n\n async preflight() {\n if (fixturesMode) return\n const dir = agentbenchDir()\n if (!dir) {\n throw new Error('AGENTBENCH_DIR is required. Fix: clone https://github.com/THUDM/AgentBench and set AGENTBENCH_DIR=/path/to/AgentBench.')\n }\n await loadJsonl(join(dir, 'data', 'dbbench', `${DEFAULT_SPLIT}.jsonl`))\n },\n\n async loadTasks(opts: LoadOptions = {}) {\n const split = opts.split ?? DEFAULT_SPLIT\n if (fixturesMode) return loadFixtures(opts, split)\n const dir = agentbenchDir()\n if (!dir) throw new Error('AGENTBENCH_DIR is required to load AgentBench DBBench tasks')\n return selectRows(await loadJsonl(join(dir, 'data', 'dbbench', `${split}.jsonl`)), opts, split)\n },\n\n async goldArtifact(task: BenchTask) {\n return readMeta(task).labels[0]\n },\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const meta = readMeta(task)\n const got = normalizeAnswer(artifact)\n const expected = meta.labels.map(normalizeAnswer)\n const resolved = expected.includes(got)\n return {\n resolved,\n score: resolved ? 1 : 0,\n detail: JSON.stringify({ subset: meta.subset, split: meta.split, expected: meta.labels, got: artifact }),\n }\n },\n }\n}\n"],"mappings":";;;;;AASA,SAAS,gBAAgB;AACzB,SAAS,YAAY;AAKrB,IAAM,WAAW,KAAK,WAAW,YAAY,yBAAyB;AACtE,IAAM,gBAAgB;AAqBtB,IAAM,gBAAgB,MAA0B,QAAQ,IAAI;AAErD,IAAM,yBAAgD;AAAA,EAC3D,MAAM,QAAQ;AACZ,QAAI,OAAO;AACX,eAAW,MAAM,QAAQ;AACvB,YAAM,IAAK,IAA2C;AACtD,YAAM,IAAI,GAAG,aAAa,GAAG,QAAQ,GAAG;AACxC,UAAI,OAAO,MAAM,YAAY,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AAS;AAC5B,UAAI,aAAc,QAAO,aAAa,MAAM,KAAK;AACjD,YAAM,MAAM,cAAc;AAC1B,UAAI,CAAC,IAAK,OAAM,IAAI,MAAM,6DAA6D;AACvF,aAAO,WAAW,MAAM,UAAU,KAAK,KAAK,QAAQ,WAAW,GAAG,KAAK,QAAQ,CAAC,GAAG,MAAM,KAAK;AAAA,IAChG;AAAA,IAEA,MAAM,aAAa,MAAiB;AAClC,aAAO,SAAS,IAAI,EAAE,OAAO,CAAC;AAAA,IAChC;AAAA,IAEA,MAAM,MAAM,MAAiB,UAAuC;AAClE,YAAM,OAAO,SAAS,IAAI;AAC1B,YAAM,MAAM,gBAAgB,QAAQ;AACpC,YAAM,WAAW,KAAK,OAAO,IAAI,eAAe;AAChD,YAAM,WAAW,SAAS,SAAS,GAAG;AACtC,aAAO;AAAA,QACL;AAAA,QACA,OAAO,WAAW,IAAI;AAAA,QACtB,QAAQ,KAAK,UAAU,EAAE,QAAQ,KAAK,QAAQ,OAAO,KAAK,OAAO,UAAU,KAAK,QAAQ,KAAK,SAAS,CAAC;AAAA,MACzG;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// src/benchmarks/cadgenbench.ts
|
|
2
|
+
import { execFile as execFile2 } from "child_process";
|
|
3
|
+
import { mkdtemp as mkdtemp2, rm as rm2, writeFile as writeFile2 } from "fs/promises";
|
|
4
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
5
|
+
import { join as join2 } from "path";
|
|
6
|
+
import { promisify as promisify2 } from "util";
|
|
7
|
+
|
|
8
|
+
// src/worker-build123d.ts
|
|
9
|
+
import { execFile } from "child_process";
|
|
10
|
+
import { existsSync, readFileSync } from "fs";
|
|
11
|
+
import { mkdtemp, readFile, rm, writeFile } from "fs/promises";
|
|
12
|
+
import { tmpdir } from "os";
|
|
13
|
+
import { join } from "path";
|
|
14
|
+
import { promisify } from "util";
|
|
15
|
+
import { routerChatWithUsage } from "@tangle-network/agent-runtime/loops";
|
|
16
|
+
var execFileAsync = promisify(execFile);
|
|
17
|
+
var CGB_VENV_PY = process.env.CADGENBENCH_VENV ?? "/tmp/cgb-venv/bin/python";
|
|
18
|
+
var CGB_DIR = process.env.CADGENBENCH_DIR ?? "/tmp/cadgenbench";
|
|
19
|
+
|
|
20
|
+
// src/benchmarks/cadgenbench.ts
|
|
21
|
+
var execFileAsync2 = promisify2(execFile2);
|
|
22
|
+
var SCORE_PY = `
|
|
23
|
+
import sys, json, tempfile, shutil
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
from cadgenbench.eval.evaluate import evaluate_result
|
|
26
|
+
cand, gt = Path(sys.argv[1]), Path(sys.argv[2])
|
|
27
|
+
with tempfile.TemporaryDirectory() as rd, tempfile.TemporaryDirectory() as gd:
|
|
28
|
+
rd, gd = Path(rd), Path(gd)
|
|
29
|
+
(rd / 'result.json').write_text('{}')
|
|
30
|
+
shutil.copy(gt, gd / 'ground_truth.step')
|
|
31
|
+
try:
|
|
32
|
+
evaluate_result(rd, gd, candidate_step=cand)
|
|
33
|
+
d = json.loads((rd / 'result.json').read_text())
|
|
34
|
+
print('CGB_SCORE ' + json.dumps({'cad_score': d.get('cad_score', 0.0), 'status': d.get('status', 'unknown')}))
|
|
35
|
+
except Exception as e:
|
|
36
|
+
print('CGB_SCORE ' + json.dumps({'cad_score': 0.0, 'status': 'error', 'error': str(e)[:200]}))
|
|
37
|
+
`.trim();
|
|
38
|
+
function fixtureTasks() {
|
|
39
|
+
const g = join2(CGB_DIR, "tests/fixtures/geometry");
|
|
40
|
+
return [
|
|
41
|
+
{ id: "box-10x20x30", prompt: "A rectangular solid box, 10 units wide (X), 20 units deep (Y), and 30 units tall (Z).", gtStep: join2(g, "box_10_20_30.step") },
|
|
42
|
+
{ id: "cube-10", prompt: "A cube, 10 units on every side.", gtStep: join2(g, "box_10_10_10.step") },
|
|
43
|
+
{ id: "sphere-10", prompt: "A sphere of radius 10 units, centered at the origin.", gtStep: join2(g, "sphere_10.step") }
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
function createCadGenBenchAdapter() {
|
|
47
|
+
return {
|
|
48
|
+
name: "cadgenbench",
|
|
49
|
+
async preflight() {
|
|
50
|
+
const r = await execFileAsync2(CGB_VENV_PY, ["-c", 'import cadgenbench.eval.evaluate, build123d, trimesh, manifold3d; print("ok")'], { timeout: 6e4 }).catch(
|
|
51
|
+
(e) => ({ stdout: "", stderr: e instanceof Error ? e.message : String(e) })
|
|
52
|
+
);
|
|
53
|
+
if (!/ok/.test(r.stdout)) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`cadgenbench preflight failed (venv=${CGB_VENV_PY}): ${r.stderr.slice(0, 200)}
|
|
56
|
+
Fix: git clone https://github.com/huggingface/cadgenbench ${CGB_DIR}; python3 -m venv $CADGENBENCH_VENV; $CADGENBENCH_VENV/bin/pip install -e ${CGB_DIR}`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
async loadTasks(opts = {}) {
|
|
61
|
+
let tasks = fixtureTasks();
|
|
62
|
+
const hard = process.env.CGB_HARD_DIR;
|
|
63
|
+
if (hard) {
|
|
64
|
+
const { readFile: readFile2 } = await import("fs/promises");
|
|
65
|
+
tasks = JSON.parse(await readFile2(join2(hard, "tasks.json"), "utf8"));
|
|
66
|
+
}
|
|
67
|
+
if (opts.ids) tasks = tasks.filter((t) => opts.ids.includes(t.id));
|
|
68
|
+
if (opts.limit != null) tasks = tasks.slice(0, opts.limit);
|
|
69
|
+
const meta = (gtStep) => ({ gtStep, resolveThreshold: Number(process.env.CGB_RESOLVE_THRESHOLD ?? 0.9) });
|
|
70
|
+
return tasks.map((t) => ({ id: t.id, prompt: t.prompt, metadata: meta(t.gtStep) }));
|
|
71
|
+
},
|
|
72
|
+
async goldArtifact() {
|
|
73
|
+
return void 0;
|
|
74
|
+
},
|
|
75
|
+
async judge(task, artifact) {
|
|
76
|
+
const { gtStep, resolveThreshold } = task.metadata;
|
|
77
|
+
if (!artifact.includes("ISO-10303-21")) return { resolved: false, score: 0, detail: "artifact is not a STEP file" };
|
|
78
|
+
const dir = await mkdtemp2(join2(tmpdir2(), "cgb-judge-"));
|
|
79
|
+
const cand = join2(dir, "candidate.step");
|
|
80
|
+
const scorer = join2(dir, "score.py");
|
|
81
|
+
try {
|
|
82
|
+
await writeFile2(cand, artifact);
|
|
83
|
+
await writeFile2(scorer, SCORE_PY);
|
|
84
|
+
const r = await execFileAsync2("xvfb-run", ["-a", CGB_VENV_PY, scorer, cand, gtStep], { maxBuffer: 1 << 26, timeout: 18e4 }).catch(
|
|
85
|
+
(e) => ({ stdout: e.stdout ?? "", stderr: e instanceof Error ? e.message : String(e) })
|
|
86
|
+
);
|
|
87
|
+
const m = /CGB_SCORE (\{.*\})/.exec(r.stdout);
|
|
88
|
+
if (!m) return { resolved: false, score: 0, detail: `scorer produced no verdict: ${(r.stderr || r.stdout).slice(0, 160)}` };
|
|
89
|
+
const v = JSON.parse(m[1]);
|
|
90
|
+
const score = typeof v.cad_score === "number" ? v.cad_score : 0;
|
|
91
|
+
return { resolved: score >= resolveThreshold, score, detail: `cad_score=${score.toFixed(3)} status=${v.status}${v.error ? ` (${v.error})` : ""}` };
|
|
92
|
+
} finally {
|
|
93
|
+
await rm2(dir, { recursive: true, force: true }).catch(() => {
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export {
|
|
101
|
+
createCadGenBenchAdapter
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=chunk-C7T7WEK2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/benchmarks/cadgenbench.ts","../src/worker-build123d.ts"],"sourcesContent":["/**\n * CADGenBench adapter (huggingface/cadgenbench, Apache-2.0). Task = a part\n * description → a STEP B-rep solid (output.step). Score = the benchmark's OWN\n * deterministic geometric metric (cad_score): validity gate → PCA/ICP align to\n * the ground truth → point-cloud F1 + volume IoU + edge F1 + topology match.\n * NOT an LLM judge, NOT self-defined checks — the published CAD kernel decides.\n *\n * The official task set (private GT, server-side graded) isn't released yet, so\n * tasks here are seeded from the repo's dimension-named geometry fixtures (real\n * GT STEPs scored by the real scorer). When CADGENBENCH_DATA_DIR is set, swap\n * loadTasks to read the published fixtures' description.yaml + ground_truth.step.\n *\n * Requires the CADGenBench venv (CADGENBENCH_VENV) + clone (CADGENBENCH_DIR) +\n * xvfb (the scorer's alignment renders need a display).\n */\n\nimport { execFile } from 'node:child_process'\nimport { mkdtemp, rm, writeFile } from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { promisify } from 'node:util'\nimport type { BenchScore, BenchTask, BenchmarkAdapter, LoadOptions } from './types'\nimport { CGB_DIR, CGB_VENV_PY } from '../worker-build123d'\n\nconst execFileAsync = promisify(execFile)\n\n/** Self-contained scorer wrapper (written to a temp file, run in the venv).\n * Scores a candidate STEP against a ground-truth STEP via the benchmark's own\n * evaluate_result, printing the cad_score line. */\nconst SCORE_PY = `\nimport sys, json, tempfile, shutil\nfrom pathlib import Path\nfrom cadgenbench.eval.evaluate import evaluate_result\ncand, gt = Path(sys.argv[1]), Path(sys.argv[2])\nwith tempfile.TemporaryDirectory() as rd, tempfile.TemporaryDirectory() as gd:\n rd, gd = Path(rd), Path(gd)\n (rd / 'result.json').write_text('{}')\n shutil.copy(gt, gd / 'ground_truth.step')\n try:\n evaluate_result(rd, gd, candidate_step=cand)\n d = json.loads((rd / 'result.json').read_text())\n print('CGB_SCORE ' + json.dumps({'cad_score': d.get('cad_score', 0.0), 'status': d.get('status', 'unknown')}))\n except Exception as e:\n print('CGB_SCORE ' + json.dumps({'cad_score': 0.0, 'status': 'error', 'error': str(e)[:200]}))\n`.trim()\n\ninterface CgbMeta {\n gtStep: string\n resolveThreshold: number\n}\n\n/** Fixture-seeded tasks (real GT STEPs from the repo, dim-named so the spec is\n * exact). Replaced by the published dataset when CADGENBENCH_DATA_DIR is set. */\nfunction fixtureTasks(): Array<{ id: string; prompt: string; gtStep: string }> {\n const g = join(CGB_DIR, 'tests/fixtures/geometry')\n return [\n { id: 'box-10x20x30', prompt: 'A rectangular solid box, 10 units wide (X), 20 units deep (Y), and 30 units tall (Z).', gtStep: join(g, 'box_10_20_30.step') },\n { id: 'cube-10', prompt: 'A cube, 10 units on every side.', gtStep: join(g, 'box_10_10_10.step') },\n { id: 'sphere-10', prompt: 'A sphere of radius 10 units, centered at the origin.', gtStep: join(g, 'sphere_10.step') },\n ]\n}\n\nexport function createCadGenBenchAdapter(): BenchmarkAdapter {\n return {\n name: 'cadgenbench',\n\n async preflight() {\n const r = await execFileAsync(CGB_VENV_PY, ['-c', 'import cadgenbench.eval.evaluate, build123d, trimesh, manifold3d; print(\"ok\")'], { timeout: 60_000 }).catch(\n (e) => ({ stdout: '', stderr: e instanceof Error ? e.message : String(e) }),\n )\n if (!/ok/.test(r.stdout)) {\n throw new Error(\n `cadgenbench preflight failed (venv=${CGB_VENV_PY}): ${r.stderr.slice(0, 200)}\\n` +\n `Fix: git clone https://github.com/huggingface/cadgenbench ${CGB_DIR}; python3 -m venv $CADGENBENCH_VENV; $CADGENBENCH_VENV/bin/pip install -e ${CGB_DIR}`,\n )\n }\n },\n\n async loadTasks(opts: LoadOptions = {}) {\n // CGB_HARD_DIR (a dir with tasks.json = [{id,prompt,gtStep}]) overrides the\n // trivial fixture primitives with hard multi-feature parts (real headroom).\n let tasks = fixtureTasks()\n const hard = process.env.CGB_HARD_DIR\n if (hard) {\n const { readFile } = await import('node:fs/promises')\n tasks = JSON.parse(await readFile(join(hard, 'tasks.json'), 'utf8')) as Array<{ id: string; prompt: string; gtStep: string }>\n }\n if (opts.ids) tasks = tasks.filter((t) => opts.ids!.includes(t.id))\n if (opts.limit != null) tasks = tasks.slice(0, opts.limit)\n const meta = (gtStep: string): CgbMeta => ({ gtStep, resolveThreshold: Number(process.env.CGB_RESOLVE_THRESHOLD ?? 0.9) })\n return tasks.map((t): BenchTask => ({ id: t.id, prompt: t.prompt, metadata: meta(t.gtStep) as unknown as Record<string, unknown> }))\n },\n\n async goldArtifact() {\n return undefined // GT is a STEP file scored by the kernel, not a returnable artifact\n },\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const { gtStep, resolveThreshold } = task.metadata as unknown as CgbMeta\n if (!artifact.includes('ISO-10303-21')) return { resolved: false, score: 0, detail: 'artifact is not a STEP file' }\n const dir = await mkdtemp(join(tmpdir(), 'cgb-judge-'))\n const cand = join(dir, 'candidate.step')\n const scorer = join(dir, 'score.py')\n try {\n await writeFile(cand, artifact)\n await writeFile(scorer, SCORE_PY)\n // xvfb: the scorer's alignment step renders; needs a display.\n const r = await execFileAsync('xvfb-run', ['-a', CGB_VENV_PY, scorer, cand, gtStep], { maxBuffer: 1 << 26, timeout: 180_000 }).catch(\n (e) => ({ stdout: (e as { stdout?: string }).stdout ?? '', stderr: e instanceof Error ? e.message : String(e) }),\n )\n const m = /CGB_SCORE (\\{.*\\})/.exec(r.stdout)\n if (!m) return { resolved: false, score: 0, detail: `scorer produced no verdict: ${(r.stderr || r.stdout).slice(0, 160)}` }\n const v = JSON.parse(m[1]) as { cad_score: number; status: string; error?: string }\n const score = typeof v.cad_score === 'number' ? v.cad_score : 0\n return { resolved: score >= resolveThreshold, score, detail: `cad_score=${score.toFixed(3)} status=${v.status}${v.error ? ` (${v.error})` : ''}` }\n } finally {\n await rm(dir, { recursive: true, force: true }).catch(() => {})\n }\n },\n }\n}\n","/**\n * CADGenBench worker. The deliverable is a STEP B-rep solid (output.step). We\n * author a build123d (Python on the OpenCascade kernel) script via the router,\n * execute it in the CADGenBench venv, and read back the produced output.step —\n * exactly the reference baseline's contract. The artifact returned IS the STEP\n * text, which the CADGenBench geometric scorer grades against the ground truth.\n *\n * The build123d authoring directive is the GEPA-optimizable surface; the\n * build123d API cheat sheet (shipped in the cadgenbench package) is appended as\n * fixed reference context. Requires the CADGenBench venv (CADGENBENCH_VENV) +\n * its clone (CADGENBENCH_DIR for the cheat sheet).\n */\n\nimport { execFile } from 'node:child_process'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { promisify } from 'node:util'\nimport type { Span } from '@tangle-network/agent-eval'\nimport type { BenchTask } from './benchmarks/types'\nimport { DEFAULT_BUILD123D_DIRECTIVE } from './directives'\nimport { runRefineLoop } from './refine-loop'\nimport { routerChatWithUsage } from '@tangle-network/agent-runtime/loops'\n\nexport { DEFAULT_BUILD123D_DIRECTIVE } from './directives'\n\nconst execFileAsync = promisify(execFile)\n\nexport const CGB_VENV_PY = process.env.CADGENBENCH_VENV ?? '/tmp/cgb-venv/bin/python'\nexport const CGB_DIR = process.env.CADGENBENCH_DIR ?? '/tmp/cadgenbench'\n\nasync function runLocal(cmd: string, args: string[], cwd: string, timeoutMs = 120_000): Promise<{ code: number; stdout: string; stderr: string }> {\n try {\n const { stdout, stderr } = await execFileAsync(cmd, args, { cwd, maxBuffer: 1 << 26, timeout: timeoutMs })\n return { code: 0, stdout, stderr }\n } catch (err) {\n const e = err as { code?: number; stdout?: string; stderr?: string; message?: string }\n return { code: typeof e.code === 'number' ? e.code : 1, stdout: e.stdout ?? '', stderr: e.stderr ?? e.message ?? String(err) }\n }\n}\n\nfunction extractPy(text: string): string {\n const fence = /```(?:python|py)?\\s*\\n([\\s\\S]*?)```/i.exec(text)\n return (fence ? fence[1] : text).trim()\n}\n\nlet _cheat: string | null = null\nfunction cheatSheet(): string {\n if (_cheat != null) return _cheat\n const p = join(CGB_DIR, 'src/cadgenbench/baseline/build123d_cheat_sheet.md')\n _cheat = existsSync(p) ? readFileSync(p, 'utf8').slice(0, 12000) : ''\n return _cheat\n}\n\nexport interface Build123dConfig {\n routerBaseUrl: string\n routerKey: string\n model: string\n rounds?: number\n /** The build123d authoring directive — the GEPA-optimizable surface. */\n directive?: string\n}\n\nexport interface Build123dShot {\n /** The produced STEP text (the artifact the CADGenBench scorer grades). */\n artifact: string\n /** The Python source the agent wrote. */\n source: string\n trace: Span[]\n usage: { input: number; output: number }\n ok: boolean\n built: boolean\n detail?: string\n}\n\n/** Author a build123d script via the router, execute it in the CADGenBench venv,\n * read back output.step. Refine on execution error / missing STEP. */\nexport async function solveBuild123dLocal(task: BenchTask, cfg: Build123dConfig): Promise<Build123dShot> {\n const rounds = Math.max(1, cfg.rounds ?? 2)\n const directive = cfg.directive ?? DEFAULT_BUILD123D_DIRECTIVE\n const sys = `${directive}\\n\\nbuild123d API reference:\\n${cheatSheet()}`\n const trace: Span[] = []\n const runId = `cadgenbench-${task.id}`\n let ts = Date.now()\n const tick = () => (ts += 1)\n const usage = { input: 0, output: 0 }\n // Carried across rounds in closures (the round Artifact is the Python source; the\n // STEP text + built flag + lastErr persist outside the loop). usage is REAL.\n let step = ''\n let built = false\n let lastErr = ''\n\n trace.push({ spanId: 's-brief', runId, kind: 'llm', name: 'brief', model: cfg.model, messages: [{ role: 'user', content: task.prompt }], startedAt: tick(), endedAt: tick(), status: 'ok' } as Span)\n\n // Migrated onto runRefineLoop: the mkdtemp scratch dir is the Ctx; built (STEP\n // produced) is the early-stop, modeled as a judge so default-decide stops the\n // loop. The round-2+ steer carries lastErr + the prior source verbatim.\n const res = await runRefineLoop<string, string>({\n rounds,\n setup: () => mkdtemp(join(tmpdir(), 'b123d-')),\n prompt: (round, history) =>\n round === 1\n ? task.prompt\n : `Your previous build123d script failed:\\n${lastErr}\\n\\nPrevious script:\\n${history[history.length - 1]?.artifact ?? ''}\\n\\nFix it so it runs in python and writes a valid output.step. Brief:\\n${task.prompt}`,\n runShot: async (user, round, dir) => {\n const scriptPath = join(dir, 'build.py')\n const stepPath = join(dir, 'output.step')\n const { content, usage: u } = await routerChatWithUsage(cfg, [\n { role: 'system', content: sys },\n { role: 'user', content: user },\n ])\n if (u) {\n usage.input += u.input\n usage.output += u.output\n }\n const source = extractPy(content)\n trace.push({ spanId: `s-author-${round}`, runId, kind: 'llm', name: `author r${round}`, model: cfg.model, messages: [{ role: 'user', content: round === 1 ? task.prompt : 'refine' }], output: content.slice(0, 600), startedAt: tick(), endedAt: tick(), status: 'ok' } as Span)\n trace.push({ spanId: `s-write-${round}`, runId, kind: 'tool', name: 'write_file', toolName: 'create_file', args: { path: 'build.py', content: source }, startedAt: tick(), endedAt: tick(), status: 'ok' } as Span)\n\n await writeFile(scriptPath, source)\n const run = await runLocal(CGB_VENV_PY, [scriptPath], dir)\n const got = existsSync(stepPath) ? await readFile(stepPath, 'utf8').catch(() => '') : ''\n built = got.includes('ISO-10303-21') && got.length > 200\n lastErr = built ? '' : `${run.stdout}\\n${run.stderr}`.trim().slice(-800) || 'no output.step written'\n if (built) step = got\n trace.push({ spanId: `s-exec-${round}`, runId, kind: 'tool', name: `build123d r${round}`, toolName: 'shell.exec', args: 'python build.py', result: (built ? 'wrote output.step' : lastErr).slice(0, 1500), startedAt: tick(), endedAt: tick(), status: built ? 'ok' : 'error', error: built ? undefined : `exit ${run.code}` } as Span)\n return { artifact: source }\n },\n judge: async () => ({ valid: built }),\n teardown: (dir) => rm(dir, { recursive: true, force: true }).then(() => {}, () => {}),\n })\n\n return {\n artifact: step,\n source: res.final.artifact,\n trace,\n usage,\n ok: res.final.artifact.trim().length > 0,\n built,\n detail: built ? 'exported output.step' : `did not produce a STEP in ${rounds} rounds${lastErr ? `; last: ${lastErr.slice(0, 140)}` : ''}`,\n }\n}\n"],"mappings":";AAgBA,SAAS,YAAAA,iBAAgB;AACzB,SAAS,WAAAC,UAAS,MAAAC,KAAI,aAAAC,kBAAiB;AACvC,SAAS,UAAAC,eAAc;AACvB,SAAS,QAAAC,aAAY;AACrB,SAAS,aAAAC,kBAAiB;;;ACP1B,SAAS,gBAAgB;AACzB,SAAS,YAAY,oBAAoB;AACzC,SAAS,SAAS,UAAU,IAAI,iBAAiB;AACjD,SAAS,cAAc;AACvB,SAAS,YAAY;AAC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