@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 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as _tangle_network_agent_runtime_loops from '@tangle-network/agent-runtime/loops';
|
|
2
|
+
import { BenchmarkAdapter } from './types.js';
|
|
3
|
+
|
|
4
|
+
declare const tau2ResultsOutput: _tangle_network_agent_runtime_loops.OutputAdapter<string>;
|
|
5
|
+
declare function createTau2BenchAdapter(): BenchmarkAdapter;
|
|
6
|
+
|
|
7
|
+
export { createTau2BenchAdapter, tau2ResultsOutput };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BenchmarkAdapter } from './types.js';
|
|
2
|
+
import '@tangle-network/agent-runtime/loops';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* tau3-banking adapter.
|
|
6
|
+
*
|
|
7
|
+
* The current upstream tau3 release is the `sierra-research/tau2-bench` repo with
|
|
8
|
+
* package namespace `tau2` and a new `banking_knowledge` domain. This adapter
|
|
9
|
+
* reuses the shared tau reward recomputation path and only changes the default
|
|
10
|
+
* domain/env names.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare function createTau3BankingAdapter(): BenchmarkAdapter;
|
|
14
|
+
|
|
15
|
+
export { createTau3BankingAdapter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BenchmarkAdapter } from './types.js';
|
|
2
|
+
import '@tangle-network/agent-runtime/loops';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Terminal-Bench adapter. Each task = a Docker environment + an English
|
|
6
|
+
* instruction + a per-task verifier (run-tests.sh + pytest). The worker artifact
|
|
7
|
+
* is the shell script the agent ran to attempt the task; the judge REPLAYS that
|
|
8
|
+
* script in a fresh task container via the Terminal-Bench harness (`tb run` with
|
|
9
|
+
* our ScriptAgent), then the task's own verifier scores the resulting state.
|
|
10
|
+
* Fully deterministic — no LLM judge, no self-authored score.
|
|
11
|
+
*
|
|
12
|
+
* Requires: an isolated bench `.venv-terminal-bench` with `terminal-bench`
|
|
13
|
+
* installed + a running Docker daemon (per-task images are built on first run).
|
|
14
|
+
* Override with TERMINAL_BENCH_VENV. loadTasks caches the dataset from the
|
|
15
|
+
* Terminal-Bench registry on first run.
|
|
16
|
+
*
|
|
17
|
+
* Process/Docker/report plumbing is shared via ./_harness; this file owns the
|
|
18
|
+
* Terminal-Bench-specific pieces: the Dataset enumeration, the ScriptAgent replay
|
|
19
|
+
* argv, and the results.json shape.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
declare function createTerminalBenchAdapter(): BenchmarkAdapter;
|
|
23
|
+
|
|
24
|
+
export { createTerminalBenchAdapter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OutputAdapter } from '@tangle-network/agent-runtime/loops';
|
|
2
|
+
import { BenchmarkAdapter } from './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ToolLLM/ToolBench adapter.
|
|
6
|
+
*
|
|
7
|
+
* ToolBench task loading is useful for breadth, but the official ToolEval pass
|
|
8
|
+
* rate evaluator is LLM-based and stochastic. This adapter therefore scores
|
|
9
|
+
* only ToolBench's deterministic API-selection labels (`relevant APIs`). It
|
|
10
|
+
* never records a full ToolEval pass-rate score.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare const toollmOutput: OutputAdapter<string>;
|
|
14
|
+
declare function createToolLlmAdapter(): BenchmarkAdapter;
|
|
15
|
+
|
|
16
|
+
export { createToolLlmAdapter, toollmOutput };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BenchmarkAdapter } from './types.js';
|
|
2
|
+
import '@tangle-network/agent-runtime/loops';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Trata Hedge-Bench adapter (Trata-Inc/trata-hedge-bench). 102 financial
|
|
6
|
+
* analysis tasks across 6 domains (private equity, managed care, industrials,
|
|
7
|
+
* vertical SaaS, REITs, insurance). Each task bundles real earnings-call
|
|
8
|
+
* transcripts, financial statements, press releases, and SEC filings under
|
|
9
|
+
* `environment/data/`; the agent must produce a grounded analysis citing those
|
|
10
|
+
* files.
|
|
11
|
+
*
|
|
12
|
+
* Harbor architecture: the original benchmark runs each task in a Docker
|
|
13
|
+
* container with file-read tools. This adapter skips Harbor and embeds the data
|
|
14
|
+
* files directly in the worker prompt so any router backend can score it. Large
|
|
15
|
+
* files (> 30 KB) are truncated to fit within model context limits. The judge
|
|
16
|
+
* reads the actual files from disk for citation verification.
|
|
17
|
+
*
|
|
18
|
+
* Judge: a 3-stage LLM cascade faithful to grade.py —
|
|
19
|
+
* Task 1: hallucination check (cited-file context + agent answer)
|
|
20
|
+
* Task 2: per-move coverage check (ground truth + agent answer + flagged claims)
|
|
21
|
+
* Task 3: synthesis check (ground truth + agent answer)
|
|
22
|
+
* Score 0–4: themes_covered == num_themes && synthesis → 4, all themes → 3,
|
|
23
|
+
* ≥2 themes → 2, ≥1 theme → 1, else → 0. Normalized to 0..1 for BenchScore;
|
|
24
|
+
* resolved = score 4 (sparse reward).
|
|
25
|
+
*
|
|
26
|
+
* Requires TANGLE_API_KEY and TRATA_BENCH_ROOT=/tmp/trata-hedge-bench.
|
|
27
|
+
* Clone: git clone --depth 1 https://github.com/Trata-Inc/trata-hedge-bench /tmp/trata-hedge-bench
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
declare function createTrataHedgeAdapter(): BenchmarkAdapter;
|
|
31
|
+
|
|
32
|
+
export { createTrataHedgeAdapter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { OutputAdapter } from '@tangle-network/agent-runtime/loops';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* BenchmarkAdapter — the seam every external benchmark implements so the
|
|
5
|
+
* agent-runtime loop can be A/B'd (blind vs steering vs steering+memory) against
|
|
6
|
+
* a REAL, DETERMINISTIC judge. The worker produces an `artifact` (a patch, a
|
|
7
|
+
* command transcript, a final state); the benchmark's own harness scores it.
|
|
8
|
+
*
|
|
9
|
+
* The point: no self-authored judge, no invented score noise. The number comes
|
|
10
|
+
* from the benchmark's published evaluation harness.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface BenchTask {
|
|
14
|
+
/** Stable benchmark instance id. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** The task statement handed to the worker agent. */
|
|
17
|
+
prompt: string;
|
|
18
|
+
split?: string;
|
|
19
|
+
/** Benchmark-specific fields the worker/judge need (repo, base_commit, gold, …). */
|
|
20
|
+
metadata?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
interface JudgeArtifactFileReceipt {
|
|
23
|
+
/** POSIX path relative to the capture directory. */
|
|
24
|
+
path: string;
|
|
25
|
+
/** Exact byte length of the retained file or symbolic-link target. */
|
|
26
|
+
byteLength: number;
|
|
27
|
+
/** SHA-256 over the retained file bytes or UTF-8 symbolic-link target. */
|
|
28
|
+
sha256: `sha256:${string}`;
|
|
29
|
+
kind: 'file' | 'symlink';
|
|
30
|
+
}
|
|
31
|
+
/** Durable evidence written before a staged evaluator's temporary directory is removed. */
|
|
32
|
+
interface JudgeArtifactReceipt {
|
|
33
|
+
schema: 'agent-bench/judge-artifacts/v1';
|
|
34
|
+
/** Absolute directory containing `evaluator/`, `process/`, and `receipt.json`. */
|
|
35
|
+
directory: string;
|
|
36
|
+
/** Exact copy of the evaluator working directory. */
|
|
37
|
+
evaluatorDirectory: string;
|
|
38
|
+
manifestPath: string;
|
|
39
|
+
evaluatorSucceeded: boolean;
|
|
40
|
+
files: JudgeArtifactFileReceipt[];
|
|
41
|
+
fileCount: number;
|
|
42
|
+
byteLength: number;
|
|
43
|
+
/** SHA-256 over every sorted path, kind, byte length, and content hash. */
|
|
44
|
+
treeSha256: `sha256:${string}`;
|
|
45
|
+
}
|
|
46
|
+
interface BenchScore {
|
|
47
|
+
/** Did the deterministic judge pass (tests resolved / state correct)? */
|
|
48
|
+
resolved: boolean;
|
|
49
|
+
/** 0..1 — 1 = fully resolved; partial credit where the harness supports it. */
|
|
50
|
+
score: number;
|
|
51
|
+
detail?: string;
|
|
52
|
+
/** Present only when the caller explicitly requested durable judge evidence. */
|
|
53
|
+
judgeArtifacts?: JudgeArtifactReceipt;
|
|
54
|
+
}
|
|
55
|
+
interface LoadOptions {
|
|
56
|
+
limit?: number;
|
|
57
|
+
split?: string;
|
|
58
|
+
ids?: string[];
|
|
59
|
+
}
|
|
60
|
+
interface BenchmarkAdapter {
|
|
61
|
+
readonly name: string;
|
|
62
|
+
/** Throw with actionable guidance when the harness/judge isn't installed/runnable. */
|
|
63
|
+
preflight(): Promise<void>;
|
|
64
|
+
loadTasks(opts?: LoadOptions): Promise<BenchTask[]>;
|
|
65
|
+
/** DETERMINISTIC judge: score the worker's produced artifact for a task. */
|
|
66
|
+
judge(task: BenchTask, artifact: string): Promise<BenchScore>;
|
|
67
|
+
/** Gold/oracle artifact — lets us self-verify the judge before spending model tokens. */
|
|
68
|
+
goldArtifact(task: BenchTask): Promise<string | undefined>;
|
|
69
|
+
/** How to extract the judged artifact from a run's event stream. Optional —
|
|
70
|
+
* defaults to the agent's final answer text (the research/QA case). SWE sets
|
|
71
|
+
* it to a patch parser. This is `benchmark = adapter` owning its deliverable,
|
|
72
|
+
* so the gate runner (`runGate` / `runBenchmark`) needs no
|
|
73
|
+
* per-benchmark branching. */
|
|
74
|
+
output?: OutputAdapter<string>;
|
|
75
|
+
/** Post-shot deliverable extraction from the box FILESYSTEM, not the event stream.
|
|
76
|
+
* When set, the shot runner execs `command` in the STILL-ALIVE box after the agent
|
|
77
|
+
* turn drains and uses its stdout as the judged artifact — the durable way to capture
|
|
78
|
+
* a git diff of the agent's in-box edits (standard SWE-bench practice: SWE-agent /
|
|
79
|
+
* OpenHands read the diff from repo STATE), instead of hoping the model printed a
|
|
80
|
+
* fenced diff in its reply. Empty stdout ⇒ the runner falls back to `output` (the
|
|
81
|
+
* event-stream parse). `cwd` defaults to the box root. */
|
|
82
|
+
boxExtract?(task: BenchTask): {
|
|
83
|
+
command: string;
|
|
84
|
+
cwd?: string;
|
|
85
|
+
};
|
|
86
|
+
/** Optional workspace pre-stage run in the box BEFORE the agent shot (same
|
|
87
|
+
* session as `boxExtract`). For repo-state benchmarks (SWE-bench) this clones
|
|
88
|
+
* the instance repo at `base_commit` into a fixed path so the agent only edits
|
|
89
|
+
* — the harness owns the checkout, not the (stochastic) model. A non-zero exit
|
|
90
|
+
* fails the shot loud rather than letting the agent run against an empty box. */
|
|
91
|
+
boxSetup?(task: BenchTask): {
|
|
92
|
+
command: string;
|
|
93
|
+
cwd?: string;
|
|
94
|
+
};
|
|
95
|
+
/** Benchmark-owned worker leaf. Set when the benchmark's native protocol IS the
|
|
96
|
+
* worker (e.g. AppWorld's interactive ReAct episode runs inside the engine,
|
|
97
|
+
* not as a chat completion) — the experiment uses this instead of the
|
|
98
|
+
* BACKEND-selected client; the steer still flows through the per-round prompt.
|
|
99
|
+
* Typed loosely to avoid a runtime import cycle; the harness casts it. */
|
|
100
|
+
leafClient?: (cfg: {
|
|
101
|
+
model: string;
|
|
102
|
+
routerBaseUrl: string;
|
|
103
|
+
routerKey: string;
|
|
104
|
+
}) => unknown;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type { BenchScore, BenchTask, BenchmarkAdapter, JudgeArtifactFileReceipt, JudgeArtifactReceipt, LoadOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OutputAdapter } from '@tangle-network/agent-runtime/loops';
|
|
2
|
+
import { BenchmarkAdapter } from './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* WebArena-Verified adapter (ServiceNow/webarena-verified).
|
|
6
|
+
*
|
|
7
|
+
* Worker artifact = a WebArena-Verified run output directory, not final chat text.
|
|
8
|
+
* Judge = the official `webarena_verified eval-tasks` evaluator over that output
|
|
9
|
+
* directory. The adapter refuses to score a plain answer so we do not turn a DOM
|
|
10
|
+
* benchmark into a fake text benchmark.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare const webarenaOutputDirOutput: OutputAdapter<string>;
|
|
14
|
+
declare function createWebArenaVerifiedAdapter(): BenchmarkAdapter;
|
|
15
|
+
|
|
16
|
+
export { createWebArenaVerifiedAdapter, webarenaOutputDirOutput };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import {
|
|
2
|
+
benchRoot
|
|
3
|
+
} from "./chunk-LRRD7NAG.js";
|
|
4
|
+
|
|
5
|
+
// src/benchmarks/toollm.ts
|
|
6
|
+
import { readFile } from "fs/promises";
|
|
7
|
+
import { join } from "path";
|
|
8
|
+
var FIXTURES = join(benchRoot, "fixtures", "toollm.json");
|
|
9
|
+
var DEFAULT_QUERY_REL = join("data_example", "instruction", "G1_query.json");
|
|
10
|
+
var toolbenchDir = () => process.env.TOOLBENCH_DIR;
|
|
11
|
+
var queryFile = (dir) => process.env.TOOLLM_QUERY_FILE ?? join(dir, DEFAULT_QUERY_REL);
|
|
12
|
+
var toollmOutput = {
|
|
13
|
+
parse(events) {
|
|
14
|
+
let text = "";
|
|
15
|
+
for (const ev of events) {
|
|
16
|
+
const d = ev?.data;
|
|
17
|
+
const t = d?.finalText ?? d?.text ?? d?.result;
|
|
18
|
+
if (typeof t === "string" && t.length > 0) text = t;
|
|
19
|
+
}
|
|
20
|
+
return text.trim();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
function rowToTask(row) {
|
|
24
|
+
const relevantApis = normalizeApiPairs(row["relevant APIs"] ?? []);
|
|
25
|
+
const meta = {
|
|
26
|
+
queryId: String(row.query_id),
|
|
27
|
+
apiList: row.api_list ?? [],
|
|
28
|
+
relevantApis,
|
|
29
|
+
deterministicJudge: "api-selection"
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
id: String(row.query_id),
|
|
33
|
+
prompt: [
|
|
34
|
+
"Solve this ToolLLM/ToolBench API-use task.",
|
|
35
|
+
"Use only the listed APIs/tools and return the completed tool-use trace plus final answer.",
|
|
36
|
+
"",
|
|
37
|
+
`Query: ${row.query}`,
|
|
38
|
+
"",
|
|
39
|
+
`Available APIs: ${JSON.stringify(row.api_list ?? [], null, 2)}`,
|
|
40
|
+
"",
|
|
41
|
+
'Return the APIs you used as JSON: {"api_calls":[{"tool_name":"...","api_name":"..."}]}.'
|
|
42
|
+
].join("\n"),
|
|
43
|
+
metadata: meta
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function normalizeApiPart(value) {
|
|
47
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
48
|
+
}
|
|
49
|
+
function apiKey(pair) {
|
|
50
|
+
return `${normalizeApiPart(pair[0])}.${normalizeApiPart(pair[1])}`;
|
|
51
|
+
}
|
|
52
|
+
function normalizeApiPairs(value) {
|
|
53
|
+
if (!Array.isArray(value)) return [];
|
|
54
|
+
const out = [];
|
|
55
|
+
for (const item of value) {
|
|
56
|
+
if (Array.isArray(item) && typeof item[0] === "string" && typeof item[1] === "string") {
|
|
57
|
+
out.push([item[0], item[1]]);
|
|
58
|
+
} else if (item && typeof item === "object" && typeof item.tool_name === "string" && typeof item.api_name === "string") {
|
|
59
|
+
out.push([item.tool_name, item.api_name]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
function readMeta(task) {
|
|
65
|
+
const md = task.metadata;
|
|
66
|
+
if (!md || !Array.isArray(md.relevantApis)) {
|
|
67
|
+
throw new Error(`ToolLLM task ${task.id} missing metadata \u2014 loadTasks did not populate deterministic API-selection labels`);
|
|
68
|
+
}
|
|
69
|
+
return md;
|
|
70
|
+
}
|
|
71
|
+
function selectRows(rows, opts) {
|
|
72
|
+
let tasks = rows.map(rowToTask);
|
|
73
|
+
if (opts.ids) {
|
|
74
|
+
const want = new Set(opts.ids);
|
|
75
|
+
tasks = tasks.filter((task) => want.has(task.id));
|
|
76
|
+
} else if (opts.limit !== void 0) {
|
|
77
|
+
tasks = tasks.slice(0, opts.limit);
|
|
78
|
+
}
|
|
79
|
+
if (tasks.length === 0) throw new Error(`ToolLLM: no tasks matched ${JSON.stringify(opts)}`);
|
|
80
|
+
return tasks;
|
|
81
|
+
}
|
|
82
|
+
function assertDeterministicSubset(tasks, source) {
|
|
83
|
+
const missing = tasks.filter((task) => readMeta(task).relevantApis.length === 0).map((task) => task.id);
|
|
84
|
+
if (missing.length > 0) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`ToolLLM deterministic API-selection labels missing for ${missing.length}/${tasks.length} task(s) from ${source}: ${missing.slice(0, 5).join(", ")}. Use a ToolBench query file that includes "relevant APIs" labels, or do not score ToolLLM in agent-bench.`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function loadFixtures(opts) {
|
|
91
|
+
const rows = JSON.parse(await readFile(FIXTURES, "utf8"));
|
|
92
|
+
console.warn(`[toollm] TOOLLM_FIXTURES=1 \u2014 loading ${rows.length} adapter fixtures`);
|
|
93
|
+
const tasks = selectRows(rows, opts);
|
|
94
|
+
assertDeterministicSubset(tasks, FIXTURES);
|
|
95
|
+
return tasks;
|
|
96
|
+
}
|
|
97
|
+
async function loadOfficialTasks(dir, opts) {
|
|
98
|
+
const source = queryFile(dir);
|
|
99
|
+
const tasks = selectRows(JSON.parse(await readFile(source, "utf8")), opts);
|
|
100
|
+
assertDeterministicSubset(tasks, source);
|
|
101
|
+
return tasks;
|
|
102
|
+
}
|
|
103
|
+
function extractJsonBlock(text) {
|
|
104
|
+
const fences = [...text.matchAll(/```(?:json)?\s*\n([\s\S]*?)```/g)];
|
|
105
|
+
const raw = (fences.at(-1)?.[1] ?? text).trim();
|
|
106
|
+
try {
|
|
107
|
+
return JSON.parse(raw);
|
|
108
|
+
} catch {
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function extractCalledApis(text, expected) {
|
|
113
|
+
const parsed = extractJsonBlock(text);
|
|
114
|
+
if (parsed && typeof parsed === "object") {
|
|
115
|
+
const raw = parsed;
|
|
116
|
+
const fromApiCalls = normalizeApiPairs(raw.api_calls);
|
|
117
|
+
if (fromApiCalls.length > 0) return { pairs: fromApiCalls, source: "structured-json" };
|
|
118
|
+
const fromCalls = normalizeApiPairs(raw.calls);
|
|
119
|
+
if (fromCalls.length > 0) return { pairs: fromCalls, source: "structured-json" };
|
|
120
|
+
}
|
|
121
|
+
const lower = text.toLowerCase();
|
|
122
|
+
return {
|
|
123
|
+
pairs: expected.filter(([tool, api]) => {
|
|
124
|
+
const toolNeedle = normalizeApiPart(tool);
|
|
125
|
+
const apiNeedle = normalizeApiPart(api);
|
|
126
|
+
const compactText = lower.replace(/[^a-z0-9]+/g, "");
|
|
127
|
+
return compactText.includes(`${toolNeedle}${apiNeedle}`) || lower.includes(tool.toLowerCase()) && lower.includes(api.toLowerCase());
|
|
128
|
+
}),
|
|
129
|
+
source: "text-mention"
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function scoreApiSelection(task, artifact) {
|
|
133
|
+
const meta = readMeta(task);
|
|
134
|
+
if (meta.relevantApis.length === 0) {
|
|
135
|
+
throw new Error(`ToolLLM task ${task.id} has no deterministic API-selection labels; refusing to score`);
|
|
136
|
+
}
|
|
137
|
+
const expected = new Set(meta.relevantApis.map(apiKey));
|
|
138
|
+
const extracted = extractCalledApis(artifact, meta.relevantApis);
|
|
139
|
+
const calledPairs = extracted.pairs;
|
|
140
|
+
const called = new Set(calledPairs.map(apiKey));
|
|
141
|
+
const truePositives = [...called].filter((key) => expected.has(key)).length;
|
|
142
|
+
const precision = called.size === 0 ? 0 : truePositives / called.size;
|
|
143
|
+
const recall = truePositives / expected.size;
|
|
144
|
+
const score = expected.size === 0 ? 0 : recall;
|
|
145
|
+
const resolved = extracted.source === "structured-json" && recall === 1 && precision === 1;
|
|
146
|
+
return {
|
|
147
|
+
resolved,
|
|
148
|
+
score,
|
|
149
|
+
detail: JSON.stringify({
|
|
150
|
+
scoring: "api-selection-only",
|
|
151
|
+
extractionSource: extracted.source,
|
|
152
|
+
queryId: meta.queryId,
|
|
153
|
+
expected: meta.relevantApis,
|
|
154
|
+
called: calledPairs,
|
|
155
|
+
precision,
|
|
156
|
+
recall,
|
|
157
|
+
fullToolEvalScore: null
|
|
158
|
+
})
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function createToolLlmAdapter() {
|
|
162
|
+
const fixturesMode = process.env.TOOLLM_FIXTURES === "1";
|
|
163
|
+
return {
|
|
164
|
+
name: "toollm",
|
|
165
|
+
output: toollmOutput,
|
|
166
|
+
async preflight() {
|
|
167
|
+
if (fixturesMode) return;
|
|
168
|
+
const dir = toolbenchDir();
|
|
169
|
+
if (!dir) {
|
|
170
|
+
throw new Error("TOOLBENCH_DIR is required. Fix: clone https://github.com/OpenBMB/ToolBench and set TOOLBENCH_DIR=/path/to/ToolBench.");
|
|
171
|
+
}
|
|
172
|
+
await loadOfficialTasks(dir, { limit: 1 });
|
|
173
|
+
},
|
|
174
|
+
async loadTasks(opts = {}) {
|
|
175
|
+
if (fixturesMode) return loadFixtures(opts);
|
|
176
|
+
const dir = toolbenchDir();
|
|
177
|
+
if (!dir) throw new Error("TOOLBENCH_DIR is required to load ToolLLM tasks");
|
|
178
|
+
return loadOfficialTasks(dir, opts);
|
|
179
|
+
},
|
|
180
|
+
async goldArtifact(task) {
|
|
181
|
+
const meta = readMeta(task);
|
|
182
|
+
if (meta.relevantApis.length === 0) return void 0;
|
|
183
|
+
return JSON.stringify({
|
|
184
|
+
api_calls: meta.relevantApis.map(([tool_name, api_name]) => ({ tool_name, api_name }))
|
|
185
|
+
}, null, 2);
|
|
186
|
+
},
|
|
187
|
+
async judge(task, artifact) {
|
|
188
|
+
return scoreApiSelection(task, artifact);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export {
|
|
194
|
+
toollmOutput,
|
|
195
|
+
createToolLlmAdapter
|
|
196
|
+
};
|
|
197
|
+
//# sourceMappingURL=chunk-2PVVP7GN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/benchmarks/toollm.ts"],"sourcesContent":["/**\n * ToolLLM/ToolBench adapter.\n *\n * ToolBench task loading is useful for breadth, but the official ToolEval pass\n * rate evaluator is LLM-based and stochastic. This adapter therefore scores\n * only ToolBench's deterministic API-selection labels (`relevant APIs`). It\n * never records a full ToolEval pass-rate score.\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', 'toollm.json')\nconst DEFAULT_QUERY_REL = join('data_example', 'instruction', 'G1_query.json')\n\ninterface ToolApi {\n category_name?: string\n tool_name: string\n api_name: string\n api_description?: string\n required_parameters?: unknown[]\n optional_parameters?: unknown[]\n method?: string\n}\n\ninterface ToolBenchRow {\n query_id: number | string\n query: string\n api_list?: ToolApi[]\n 'relevant APIs'?: Array<[string, string]>\n}\n\ninterface ToolBenchMeta {\n queryId: string\n apiList: ToolApi[]\n relevantApis: Array<[string, string]>\n deterministicJudge: 'api-selection'\n}\n\nconst toolbenchDir = (): string | undefined => process.env.TOOLBENCH_DIR\nconst queryFile = (dir: string): string => process.env.TOOLLM_QUERY_FILE ?? join(dir, DEFAULT_QUERY_REL)\n\nexport const toollmOutput: 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 return text.trim()\n },\n}\n\nfunction rowToTask(row: ToolBenchRow): BenchTask {\n const relevantApis = normalizeApiPairs(row['relevant APIs'] ?? [])\n const meta: ToolBenchMeta = {\n queryId: String(row.query_id),\n apiList: row.api_list ?? [],\n relevantApis,\n deterministicJudge: 'api-selection',\n }\n return {\n id: String(row.query_id),\n prompt: [\n 'Solve this ToolLLM/ToolBench API-use task.',\n 'Use only the listed APIs/tools and return the completed tool-use trace plus final answer.',\n '',\n `Query: ${row.query}`,\n '',\n `Available APIs: ${JSON.stringify(row.api_list ?? [], null, 2)}`,\n '',\n 'Return the APIs you used as JSON: {\"api_calls\":[{\"tool_name\":\"...\",\"api_name\":\"...\"}]}.',\n ].join('\\n'),\n metadata: meta as unknown as Record<string, unknown>,\n }\n}\n\nfunction normalizeApiPart(value: string): string {\n return value.toLowerCase().replace(/[^a-z0-9]+/g, '')\n}\n\nfunction apiKey(pair: readonly [string, string]): string {\n return `${normalizeApiPart(pair[0])}.${normalizeApiPart(pair[1])}`\n}\n\nfunction normalizeApiPairs(value: unknown): Array<[string, string]> {\n if (!Array.isArray(value)) return []\n const out: Array<[string, string]> = []\n for (const item of value) {\n if (Array.isArray(item) && typeof item[0] === 'string' && typeof item[1] === 'string') {\n out.push([item[0], item[1]])\n } else if (\n item && typeof item === 'object'\n && typeof (item as { tool_name?: unknown }).tool_name === 'string'\n && typeof (item as { api_name?: unknown }).api_name === 'string'\n ) {\n out.push([(item as { tool_name: string }).tool_name, (item as { api_name: string }).api_name])\n }\n }\n return out\n}\n\nfunction readMeta(task: BenchTask): ToolBenchMeta {\n const md = task.metadata\n if (!md || !Array.isArray(md.relevantApis)) {\n throw new Error(`ToolLLM task ${task.id} missing metadata — loadTasks did not populate deterministic API-selection labels`)\n }\n return md as unknown as ToolBenchMeta\n}\n\nfunction selectRows(rows: ToolBenchRow[], opts: LoadOptions): BenchTask[] {\n let tasks = rows.map(rowToTask)\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(`ToolLLM: no tasks matched ${JSON.stringify(opts)}`)\n return tasks\n}\n\nfunction assertDeterministicSubset(tasks: readonly BenchTask[], source: string): void {\n const missing = tasks.filter((task) => readMeta(task).relevantApis.length === 0).map((task) => task.id)\n if (missing.length > 0) {\n throw new Error(\n `ToolLLM deterministic API-selection labels missing for ${missing.length}/${tasks.length} task(s) from ${source}: ${missing.slice(0, 5).join(', ')}. ` +\n 'Use a ToolBench query file that includes \"relevant APIs\" labels, or do not score ToolLLM in agent-bench.',\n )\n }\n}\n\nasync function loadFixtures(opts: LoadOptions): Promise<BenchTask[]> {\n const rows = JSON.parse(await readFile(FIXTURES, 'utf8')) as ToolBenchRow[]\n console.warn(`[toollm] TOOLLM_FIXTURES=1 — loading ${rows.length} adapter fixtures`)\n const tasks = selectRows(rows, opts)\n assertDeterministicSubset(tasks, FIXTURES)\n return tasks\n}\n\nasync function loadOfficialTasks(dir: string, opts: LoadOptions): Promise<BenchTask[]> {\n const source = queryFile(dir)\n const tasks = selectRows(JSON.parse(await readFile(source, 'utf8')) as ToolBenchRow[], opts)\n assertDeterministicSubset(tasks, source)\n return tasks\n}\n\nfunction extractJsonBlock(text: string): unknown {\n const fences = [...text.matchAll(/```(?:json)?\\s*\\n([\\s\\S]*?)```/g)]\n const raw = (fences.at(-1)?.[1] ?? text).trim()\n try {\n return JSON.parse(raw)\n } catch {\n return undefined\n }\n}\n\ninterface ExtractedApis {\n pairs: Array<[string, string]>\n source: 'structured-json' | 'text-mention'\n}\n\nfunction extractCalledApis(text: string, expected: readonly [string, string][]): ExtractedApis {\n const parsed = extractJsonBlock(text)\n if (parsed && typeof parsed === 'object') {\n const raw = parsed as Record<string, unknown>\n const fromApiCalls = normalizeApiPairs(raw.api_calls)\n if (fromApiCalls.length > 0) return { pairs: fromApiCalls, source: 'structured-json' }\n const fromCalls = normalizeApiPairs(raw.calls)\n if (fromCalls.length > 0) return { pairs: fromCalls, source: 'structured-json' }\n }\n\n const lower = text.toLowerCase()\n return {\n pairs: expected.filter(([tool, api]) => {\n const toolNeedle = normalizeApiPart(tool)\n const apiNeedle = normalizeApiPart(api)\n const compactText = lower.replace(/[^a-z0-9]+/g, '')\n return compactText.includes(`${toolNeedle}${apiNeedle}`) || (lower.includes(tool.toLowerCase()) && lower.includes(api.toLowerCase()))\n }),\n source: 'text-mention',\n }\n}\n\nfunction scoreApiSelection(task: BenchTask, artifact: string): BenchScore {\n const meta = readMeta(task)\n if (meta.relevantApis.length === 0) {\n throw new Error(`ToolLLM task ${task.id} has no deterministic API-selection labels; refusing to score`)\n }\n const expected = new Set(meta.relevantApis.map(apiKey))\n const extracted = extractCalledApis(artifact, meta.relevantApis)\n const calledPairs = extracted.pairs\n const called = new Set(calledPairs.map(apiKey))\n const truePositives = [...called].filter((key) => expected.has(key)).length\n const precision = called.size === 0 ? 0 : truePositives / called.size\n const recall = truePositives / expected.size\n const score = expected.size === 0 ? 0 : recall\n const resolved = extracted.source === 'structured-json' && recall === 1 && precision === 1\n return {\n resolved,\n score,\n detail: JSON.stringify({\n scoring: 'api-selection-only',\n extractionSource: extracted.source,\n queryId: meta.queryId,\n expected: meta.relevantApis,\n called: calledPairs,\n precision,\n recall,\n fullToolEvalScore: null,\n }),\n }\n}\n\nexport function createToolLlmAdapter(): BenchmarkAdapter {\n const fixturesMode = process.env.TOOLLM_FIXTURES === '1'\n\n return {\n name: 'toollm',\n output: toollmOutput,\n\n async preflight() {\n if (fixturesMode) return\n const dir = toolbenchDir()\n if (!dir) {\n throw new Error('TOOLBENCH_DIR is required. Fix: clone https://github.com/OpenBMB/ToolBench and set TOOLBENCH_DIR=/path/to/ToolBench.')\n }\n await loadOfficialTasks(dir, { limit: 1 })\n },\n\n async loadTasks(opts: LoadOptions = {}) {\n if (fixturesMode) return loadFixtures(opts)\n const dir = toolbenchDir()\n if (!dir) throw new Error('TOOLBENCH_DIR is required to load ToolLLM tasks')\n return loadOfficialTasks(dir, opts)\n },\n\n async goldArtifact(task: BenchTask) {\n const meta = readMeta(task)\n if (meta.relevantApis.length === 0) return undefined\n return JSON.stringify({\n api_calls: meta.relevantApis.map(([tool_name, api_name]) => ({ tool_name, api_name })),\n }, null, 2)\n },\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n return scoreApiSelection(task, artifact)\n },\n }\n}\n"],"mappings":";;;;;AASA,SAAS,gBAAgB;AACzB,SAAS,YAAY;AAKrB,IAAM,WAAW,KAAK,WAAW,YAAY,aAAa;AAC1D,IAAM,oBAAoB,KAAK,gBAAgB,eAAe,eAAe;AA0B7E,IAAM,eAAe,MAA0B,QAAQ,IAAI;AAC3D,IAAM,YAAY,CAAC,QAAwB,QAAQ,IAAI,qBAAqB,KAAK,KAAK,iBAAiB;AAEhG,IAAM,eAAsC;AAAA,EACjD,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,EAAE,SAAS,EAAG,QAAO;AAAA,IACpD;AACA,WAAO,KAAK,KAAK;AAAA,EACnB;AACF;AAEA,SAAS,UAAU,KAA8B;AAC/C,QAAM,eAAe,kBAAkB,IAAI,eAAe,KAAK,CAAC,CAAC;AACjE,QAAM,OAAsB;AAAA,IAC1B,SAAS,OAAO,IAAI,QAAQ;AAAA,IAC5B,SAAS,IAAI,YAAY,CAAC;AAAA,IAC1B;AAAA,IACA,oBAAoB;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