@tangle-network/agent-bench 0.14.4 → 1.0.2
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 +46 -0
- package/README.md +2 -3
- package/dist/adapters.d.ts +2 -5
- package/dist/adapters.js +3 -4
- package/dist/benchmarks/_harness.d.ts +17 -20
- package/dist/benchmarks/_harness.js +4 -4
- package/dist/benchmarks/_harness.js.map +1 -1
- package/dist/benchmarks/aec-bench.d.ts +1 -4
- package/dist/benchmarks/aec-bench.js +1 -2
- package/dist/benchmarks/agentbench.d.ts +2 -5
- package/dist/benchmarks/agentbench.js +1 -2
- package/dist/benchmarks/appworld.d.ts +8 -10
- package/dist/benchmarks/appworld.js +23 -23
- package/dist/benchmarks/appworld.js.map +1 -1
- package/dist/benchmarks/bfcl.d.ts +2 -5
- package/dist/benchmarks/bfcl.js +1 -2
- package/dist/benchmarks/cad-design.d.ts +2 -5
- package/dist/benchmarks/cad-design.js +2 -3
- package/dist/benchmarks/cad-design.js.map +1 -1
- package/dist/benchmarks/cadbench.d.ts +1 -4
- package/dist/benchmarks/cadbench.js +1 -2
- package/dist/benchmarks/cadgenbench.d.ts +1 -4
- package/dist/benchmarks/cadgenbench.js +1 -2
- package/dist/benchmarks/commit0.d.ts +2 -5
- package/dist/benchmarks/commit0.js +1 -2
- package/dist/benchmarks/crag.d.ts +1 -4
- package/dist/benchmarks/crag.js +3 -3
- package/dist/benchmarks/crag.js.map +1 -1
- package/dist/benchmarks/dabstep.d.ts +2 -5
- package/dist/benchmarks/dabstep.js +2 -3
- package/dist/benchmarks/dabstep.js.map +1 -1
- package/dist/benchmarks/enterpriseops-gym.d.ts +2 -5
- package/dist/benchmarks/enterpriseops-gym.js +1 -2
- package/dist/benchmarks/finresearchbench.d.ts +2 -5
- package/dist/benchmarks/finresearchbench.js +2 -3
- package/dist/benchmarks/finsearchcomp.d.ts +2 -5
- package/dist/benchmarks/finsearchcomp.js +4 -4
- package/dist/benchmarks/finsearchcomp.js.map +1 -1
- package/dist/benchmarks/frames.d.ts +3 -19
- package/dist/benchmarks/frames.js +13 -39
- package/dist/benchmarks/frames.js.map +1 -1
- package/dist/benchmarks/hotpotqa.d.ts +4 -14
- package/dist/benchmarks/hotpotqa.js +12 -32
- package/dist/benchmarks/hotpotqa.js.map +1 -1
- package/dist/benchmarks/humaneval.d.ts +9 -12
- package/dist/benchmarks/humaneval.js +2 -3
- package/dist/benchmarks/humaneval.js.map +1 -1
- package/dist/benchmarks/mcad-bench.d.ts +13 -16
- package/dist/benchmarks/mcad-bench.js +2 -3
- package/dist/benchmarks/mcad-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-bench.d.ts +17 -20
- package/dist/benchmarks/mcad-cq-bench.js +2 -3
- package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-golds.d.ts +2 -5
- package/dist/benchmarks/mcad-cq-golds.js +1 -2
- package/dist/benchmarks/mcad-golds.d.ts +1 -4
- package/dist/benchmarks/mcad-golds.js +0 -1
- package/dist/benchmarks/mcad-tasks.d.ts +5 -8
- package/dist/benchmarks/mcad-tasks.js +7 -8
- package/dist/benchmarks/mcad-tasks.js.map +1 -1
- package/dist/benchmarks/mind2web.d.ts +3 -5
- package/dist/benchmarks/mind2web.js +2 -3
- package/dist/benchmarks/mind2web.js.map +1 -1
- package/dist/benchmarks/nomiracl.d.ts +1 -4
- package/dist/benchmarks/nomiracl.js +1 -2
- package/dist/benchmarks/open-rag-bench.d.ts +1 -4
- package/dist/benchmarks/open-rag-bench.js +3 -3
- package/dist/benchmarks/open-rag-bench.js.map +1 -1
- package/dist/benchmarks/programbench.d.ts +2 -5
- package/dist/benchmarks/programbench.js +1 -2
- package/dist/benchmarks/rag-shared.d.ts +30 -22
- package/dist/benchmarks/rag-shared.js +8 -2
- package/dist/benchmarks/rag-shared.js.map +1 -1
- package/dist/benchmarks/ragbench.d.ts +1 -4
- package/dist/benchmarks/ragbench.js +3 -3
- package/dist/benchmarks/ragbench.js.map +1 -1
- package/dist/benchmarks/simpleqa.d.ts +2 -18
- package/dist/benchmarks/simpleqa.js +5 -31
- package/dist/benchmarks/simpleqa.js.map +1 -1
- package/dist/benchmarks/swe-bench.d.ts +7 -10
- package/dist/benchmarks/swe-bench.js +4 -4
- package/dist/benchmarks/swe-bench.js.map +1 -1
- package/dist/benchmarks/t2-ragbench.d.ts +1 -4
- package/dist/benchmarks/t2-ragbench.js +3 -3
- package/dist/benchmarks/t2-ragbench.js.map +1 -1
- package/dist/benchmarks/tau-bench-shared.d.ts +5 -8
- package/dist/benchmarks/tau-bench-shared.js +4 -4
- package/dist/benchmarks/tau-bench-shared.js.map +1 -1
- package/dist/benchmarks/tau2-bench.d.ts +2 -5
- package/dist/benchmarks/tau2-bench.js +1 -2
- package/dist/benchmarks/tau3-banking.d.ts +1 -4
- package/dist/benchmarks/tau3-banking.js +1 -2
- package/dist/benchmarks/terminal-bench.d.ts +1 -4
- package/dist/benchmarks/terminal-bench.js +4 -4
- package/dist/benchmarks/terminal-bench.js.map +1 -1
- package/dist/benchmarks/toollm.d.ts +2 -5
- package/dist/benchmarks/toollm.js +1 -2
- package/dist/benchmarks/trata-hedge.d.ts +1 -4
- package/dist/benchmarks/trata-hedge.js +2 -3
- package/dist/benchmarks/types.d.ts +6 -9
- package/dist/benchmarks/webarena-verified.d.ts +2 -5
- package/dist/benchmarks/webarena-verified.js +1 -2
- package/dist/{cadbench-BRF-59Mt.js → cadbench-DhAndllg.js} +4 -6
- package/dist/cadbench-DhAndllg.js.map +1 -0
- package/dist/{cadgenbench-DXtGkuW3.js → cadgenbench-Tvk16YKT.js} +15 -5
- package/dist/cadgenbench-Tvk16YKT.js.map +1 -0
- package/dist/index.d.ts +8 -18
- package/dist/index.js +16 -24
- package/dist/index.js.map +1 -1
- package/dist/{router-turn-uTYO6KQ1.js → router-turn-DNbQ_GjQ.js} +2 -3
- package/dist/router-turn-DNbQ_GjQ.js.map +1 -0
- package/fixtures/pier-agent/no-model-task/pre_artifacts.sh +0 -0
- package/fixtures/pier-agent/no-model-task/tests/test.sh +0 -0
- package/package.json +10 -10
- package/pier_agents/tangle_candidate.py +15 -23
- package/scripts/run-package-tests.mjs +8 -15
- package/src/atom-mcp-e2e.mts +2 -2
- package/src/benchmarks/frames.ts +10 -44
- package/src/benchmarks/hotpotqa.ts +9 -29
- package/src/benchmarks/rag-shared.ts +12 -0
- package/src/benchmarks/simpleqa.ts +2 -36
- package/src/commit0-prereqs.sh +0 -0
- package/src/corpus-replay.mts +8 -8
- package/src/corpus-report.mts +21 -21
- package/src/corpus.test.mts +5 -5
- package/src/corpus.ts +16 -16
- package/src/directives.ts +0 -38
- package/src/examples/lean-verify.ts +1 -1
- package/src/gate.ts +7 -7
- package/src/generate-eval/certify.ts +2 -2
- package/src/index.ts +1 -0
- package/src/refine-loop.ts +5 -5
- package/src/resolve-client.ts +1 -1
- package/src/router-turn.ts +3 -11
- package/src/run-pool.ts +1 -1
- package/src/runtime-hook-recorder.ts +2 -2
- package/src/search-bench/tasks.ts +1 -1
- package/src/selector.test.mts +13 -13
- package/src/selector.ts +19 -19
- package/src/swe-bench-env.ts +4 -12
- package/src/swe-jail.ts +5 -156
- package/src/swe-structural-judge-policy.ts +3 -3
- package/src/swe-structural-policy.ts +3 -3
- package/src/swe-structural-provenance.ts +4 -4
- package/src/terminal-compare.ts +10 -10
- package/src/worker-blender.ts +2 -106
- package/src/worker-build123d.ts +2 -81
- package/tb_agents/opencode_router_agent.py +1 -1
- package/dist/cadbench-BRF-59Mt.js.map +0 -1
- package/dist/cadgenbench-DXtGkuW3.js.map +0 -1
- package/dist/router-turn-uTYO6KQ1.js.map +0 -1
- package/scripts/cadbench_prepare.py +0 -22
- package/scripts/cadgenbench_hard_parts.py +0 -48
- package/scripts/clbench_codebase_judge.py +0 -73
- package/scripts/render-gate-chart.mjs +0 -176
- package/scripts/trata-hedge/README.md +0 -57
- package/scripts/trata-hedge/run.sh +0 -64
- package/src/cloud-loop.mts +0 -156
- package/src/coordination-mcp-container-reach.mts +0 -182
- package/src/fleet.mts +0 -143
- package/src/hev-structural.mts +0 -697
- package/src/humaneval-gate.mts +0 -220
- package/src/mbpp-structural.mts +0 -676
- package/src/mcp-mount-probe.mts +0 -141
- package/src/profiles.ts +0 -128
- package/src/research-gate.mts +0 -132
- package/src/research-shot.ts +0 -144
- package/src/router-executor.ts +0 -51
- package/src/sandbox-run.ts +0 -108
- package/src/search-bench/bridge.ts +0 -182
- package/src/search-bench/export.mts +0 -0
- package/src/search-bench/parametric-check.mts +0 -78
- package/src/search-bench/profiles.ts +0 -113
- package/src/search-bench/run.mts +0 -286
- package/src/search-bench/tasks-fresh.ts +0 -688
- package/src/smoke-structural-rollout.mts +0 -415
- package/src/stats.mts +0 -90
- package/src/swe-code-improve.mts +0 -306
- package/src/swe-improve.mts +0 -284
- package/src/swe-structural.mts +0 -707
- package/src/tb-container-executor.mts +0 -266
- package/src/tb-container-executor.test.mts +0 -134
- package/src/tb-supervisor-sidecar.mts +0 -208
- package/src/trata-gepa.mts +0 -381
- package/src/trata-hedge-solve.mts +0 -81
- package/tb_agents/opencode_refine_agent.py +0 -117
- package/tb_agents/opencode_supervisor_agent.py +0 -239
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
Follows `@tangle-network/agent-runtime` 8.0.1 (`^8.0.1`). No code change.
|
|
6
|
+
|
|
7
|
+
## 1.0.1
|
|
8
|
+
|
|
9
|
+
Tagged, never published: its manifest asked for `@tangle-network/agent-runtime` `^8.0.1` before 8.0.1 existed on npm, and its changelog wrongly said 1.0.0 had not been published. 1.0.0 was published on 2026-11-07 (22:51Z) from the tag at b035d49d.
|
|
10
|
+
|
|
11
|
+
## 1.0.0
|
|
12
|
+
|
|
13
|
+
First stable release, graduating from 0.14.4, the last version on npm; 0.14.5 to 0.14.10 were never published.
|
|
14
|
+
Named break since 0.14.4: the `./benchmarks/frames` entry no longer exports `ResearchAnswer`, `ResearchTask`, `normalizeAnswer` or `parseCitations`, and other exports were removed or narrowed; `api-surface.json` is the full record and `node scripts/check-version-bump.mjs --archive` lists them against 0.14.4.
|
|
15
|
+
Later compatible changes ship as patch releases.
|
|
16
|
+
|
|
17
|
+
Benchmark execution and grading are unchanged. Dependencies are the Runtime 1.0 cohort from 0.14.10, one caret per first-party package: agent-eval `^1.0.0`, Sandbox `^1.0.1`, agent-knowledge `^23.0.0` and agent-interface `^5.9.0`.
|
|
18
|
+
|
|
19
|
+
## 0.14.10
|
|
20
|
+
|
|
21
|
+
Use the Runtime 1.0 cohort, one caret per first-party package: agent-eval `^1.0.0`, Sandbox `^1.0.1`, agent-knowledge `^23.0.0` and agent-interface `^5.9.0`.
|
|
22
|
+
Benchmark execution and grading are unchanged.
|
|
23
|
+
|
|
24
|
+
## 0.14.9
|
|
25
|
+
|
|
26
|
+
Use the Runtime cohort with Sandbox `>=0.62.15 <0.62.16`; 0.62.15 carries the profile-file mount errors.
|
|
27
|
+
Benchmark execution and grading are unchanged.
|
|
28
|
+
|
|
29
|
+
## 0.14.8
|
|
30
|
+
|
|
31
|
+
Use the Runtime cohort with Sandbox `>=0.62.14 <0.62.15`; 0.62.14 carries native-copy content omission.
|
|
32
|
+
Benchmark execution and grading are unchanged.
|
|
33
|
+
|
|
34
|
+
## 0.14.7
|
|
35
|
+
|
|
36
|
+
Use the Runtime cohort with Sandbox `>=0.61.1 <0.61.2 || >=0.62.2 <0.62.3`; 0.62.2 sends a trace id on `exec`.
|
|
37
|
+
Benchmark execution and grading are unchanged.
|
|
38
|
+
|
|
39
|
+
## 0.14.6
|
|
40
|
+
|
|
41
|
+
Use the Runtime cohort with Sandbox `>=0.61.1 <0.61.2`, the first Sandbox whose `onTiming` declaration type-checks under `exactOptionalPropertyTypes`.
|
|
42
|
+
Benchmark execution and grading are unchanged.
|
|
43
|
+
|
|
44
|
+
## 0.14.5
|
|
45
|
+
|
|
46
|
+
Use the Runtime 0.326 cohort: Sandbox `>=0.60.92 <0.60.93`, which `@tangle-network/agent-provider-tangle` 4.4.1 requires.
|
|
47
|
+
Benchmark execution and grading are unchanged.
|
|
48
|
+
|
|
3
49
|
## 0.14.4
|
|
4
50
|
|
|
5
51
|
Use the Runtime 0.321 cohort: Eval `>=0.214.0 <0.215.0` and Knowledge `^22.0.2`, whose Eval peer admits Eval 0.214.
|
package/README.md
CHANGED
|
@@ -9,9 +9,8 @@ Published as `@tangle-network/agent-bench`, with independent CI and release chec
|
|
|
9
9
|
This package publishes from its own tag. A root `v*` tag publishes `@tangle-network/agent-runtime` only.
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
# after bench/package.json holds the new version on the
|
|
13
|
-
|
|
14
|
-
git push origin agent-bench-v<version>
|
|
12
|
+
# after bench/package.json holds the new version on main; also admits the tag's qualifier to its runner group
|
|
13
|
+
pnpm release:tag agent-bench@<version> --commit <merged-sha>
|
|
15
14
|
```
|
|
16
15
|
|
|
17
16
|
Bump `bench/package.json` and cut the tag in the same release. The manifest resolves the first-party cohort through the workspace catalog, so a catalog move changes what this package publishes. `publish.yml` skips a version the registry already holds, so a bump without a tag leaves the registry serving the previous cohort to every consumer.
|
package/dist/adapters.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { BenchmarkAdapter } from "./benchmarks/types.js";
|
|
2
|
-
|
|
3
|
-
declare const ADAPTERS: Record<string, () => BenchmarkAdapter>;
|
|
2
|
+
export declare const ADAPTERS: Record<string, () => BenchmarkAdapter>;
|
|
4
3
|
/** Resolve a benchmark key to its adapter, failing loud with the known keys. */
|
|
5
|
-
declare function resolveAdapter(key: string): BenchmarkAdapter;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { ADAPTERS, resolveAdapter };
|
|
4
|
+
export declare function resolveAdapter(key: string): BenchmarkAdapter;
|
|
8
5
|
//# sourceMappingURL=adapters.d.ts.map
|
package/dist/adapters.js
CHANGED
|
@@ -2,9 +2,9 @@ import { createAecBenchAdapter } from "./benchmarks/aec-bench.js";
|
|
|
2
2
|
import { createAgentBenchAdapter } from "./benchmarks/agentbench.js";
|
|
3
3
|
import { createAppWorldAdapter, createAppWorldReactAdapter } from "./benchmarks/appworld.js";
|
|
4
4
|
import { createBfclAdapter } from "./benchmarks/bfcl.js";
|
|
5
|
-
import { t as createCadBenchAdapter } from "./cadbench-
|
|
5
|
+
import { t as createCadBenchAdapter } from "./cadbench-DhAndllg.js";
|
|
6
6
|
import { createCadDesignAdapter } from "./benchmarks/cad-design.js";
|
|
7
|
-
import { t as createCadGenBenchAdapter } from "./cadgenbench-
|
|
7
|
+
import { t as createCadGenBenchAdapter } from "./cadgenbench-Tvk16YKT.js";
|
|
8
8
|
import { createCommit0Adapter } from "./benchmarks/commit0.js";
|
|
9
9
|
import { createCragAdapter } from "./benchmarks/crag.js";
|
|
10
10
|
import { createDabstepAdapter } from "./benchmarks/dabstep.js";
|
|
@@ -30,7 +30,7 @@ import { createTerminalBenchAdapter } from "./benchmarks/terminal-bench.js";
|
|
|
30
30
|
import { createToolLlmAdapter } from "./benchmarks/toollm.js";
|
|
31
31
|
import { createTrataHedgeAdapter } from "./benchmarks/trata-hedge.js";
|
|
32
32
|
import { createWebArenaVerifiedAdapter } from "./benchmarks/webarena-verified.js";
|
|
33
|
-
|
|
33
|
+
// src/adapters.ts
|
|
34
34
|
/**
|
|
35
35
|
* The benchmark registry — the single source of truth for every wired benchmark.
|
|
36
36
|
* One key per benchmark; the value is its `BenchmarkAdapter` factory. `runBenchmarks`
|
|
@@ -78,7 +78,6 @@ function resolveAdapter(key) {
|
|
|
78
78
|
if (!make) throw new Error(`unknown benchmark ${JSON.stringify(key)} (have: ${Object.keys(ADAPTERS).join(", ")})`);
|
|
79
79
|
return make();
|
|
80
80
|
}
|
|
81
|
-
//#endregion
|
|
82
81
|
export { ADAPTERS, resolveAdapter };
|
|
83
82
|
|
|
84
83
|
//# sourceMappingURL=adapters.js.map
|
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
import { BenchScore, JudgeArtifactReceipt } from "./types.js";
|
|
2
|
-
//#region src/benchmarks/_harness.d.ts
|
|
3
2
|
/** Package root for agent-bench, so `.venv`, scripts, and fixtures resolve. */
|
|
4
|
-
declare const benchRoot: string;
|
|
3
|
+
export declare const benchRoot: string;
|
|
5
4
|
/** Resolve the shared interpreter without requiring an installed package to contain a venv. */
|
|
6
|
-
declare function resolveBenchPython(env?: Readonly<{
|
|
5
|
+
export declare function resolveBenchPython(env?: Readonly<{
|
|
7
6
|
AGENT_BENCH_PYTHON?: string;
|
|
8
7
|
}>, root?: string): string;
|
|
9
8
|
/** The shared interpreter every Python-backed evaluator runs through. */
|
|
10
|
-
declare const venvPython: string;
|
|
9
|
+
export declare const venvPython: string;
|
|
11
10
|
/** Interpreter for a NAMED isolated venv (e.g. `.venv-commit0`). Benches whose pip
|
|
12
11
|
* deps conflict with the shared `.venv` (commit0 downgrades pydantic/sqlalchemy)
|
|
13
12
|
* get their own venv and pass its python explicitly — keeping the shared one clean. */
|
|
14
|
-
declare const venvPythonAt: (venvDir: string) => string;
|
|
13
|
+
export declare const venvPythonAt: (venvDir: string) => string;
|
|
15
14
|
/** Resolve an executable in an isolated venv. Relative venv paths are package-owned;
|
|
16
15
|
* absolute paths allow installed consumers to keep large environments elsewhere. */
|
|
17
|
-
declare function venvBinAt(venvDir: string, name: string): string;
|
|
16
|
+
export declare function venvBinAt(venvDir: string, name: string): string;
|
|
18
17
|
/** Report/transcript reads are large; 256 MiB matches the SWE harness budget. */
|
|
19
|
-
declare const bigBuffer: number;
|
|
18
|
+
export declare const bigBuffer: number;
|
|
20
19
|
/** Path to a named executable inside the bench venv (e.g. `venvBin('tb')`). */
|
|
21
|
-
declare function venvBin(name: string): string;
|
|
20
|
+
export declare function venvBin(name: string): string;
|
|
22
21
|
/**
|
|
23
22
|
* Run the bench venv python with an inline script (`-c`); return stdout. Throws
|
|
24
23
|
* (with stderr) on a nonzero exit — the loaders rely on this to fail loud rather
|
|
25
24
|
* than parse a partial dump.
|
|
26
25
|
*/
|
|
27
|
-
declare function runVenvPython(script: string, args?: string[], timeoutMs?: number, python?: string): Promise<string>;
|
|
26
|
+
export declare function runVenvPython(script: string, args?: string[], timeoutMs?: number, python?: string): Promise<string>;
|
|
28
27
|
/**
|
|
29
28
|
* Preflight a python-backed harness: import the module(s) and (optionally) ping
|
|
30
29
|
* Docker, all inside the bench venv. On failure THROWS the captured error joined
|
|
31
30
|
* to the adapter's `fix` guidance — the contract every code-bench preflight wants.
|
|
32
31
|
*/
|
|
33
|
-
declare function preflightVenvImports(opts: {
|
|
32
|
+
export declare function preflightVenvImports(opts: {
|
|
34
33
|
/** Module names to `import` (e.g. ['swebench']); '' entries are ignored. */
|
|
35
34
|
modules: string[];
|
|
36
35
|
/** Also `docker.from_env().ping()` — true for Docker-backed evaluators. */
|
|
@@ -50,12 +49,12 @@ declare function preflightVenvImports(opts: {
|
|
|
50
49
|
* is left open and a driver that does `sys.stdin.read()` blocks forever. The
|
|
51
50
|
* artifact-piping judges (commit0, appworld) MUST go through this.
|
|
52
51
|
*/
|
|
53
|
-
declare function runVenvScriptStdin(scriptPath: string, args: string[], input: string, opts?: {
|
|
52
|
+
export declare function runVenvScriptStdin(scriptPath: string, args: string[], input: string, opts?: {
|
|
54
53
|
cwd?: string;
|
|
55
54
|
timeoutMs?: number;
|
|
56
55
|
python?: string;
|
|
57
56
|
}): Promise<string>;
|
|
58
|
-
interface StagedRunSpec {
|
|
57
|
+
export interface StagedRunSpec {
|
|
59
58
|
/** mkdtemp prefix, e.g. 'swebench-' / 'commit0-'. */
|
|
60
59
|
tmpPrefix: string;
|
|
61
60
|
/**
|
|
@@ -84,12 +83,12 @@ interface StagedRunSpec {
|
|
|
84
83
|
/** Keep the temp dir on disk (debugging). Default false → always cleaned up. */
|
|
85
84
|
keepTmp?: boolean;
|
|
86
85
|
}
|
|
87
|
-
interface StagedRunCaptureSpec {
|
|
86
|
+
export interface StagedRunCaptureSpec {
|
|
88
87
|
/** Destination for `evaluator/`, `process/`, and the hashed `receipt.json`. */
|
|
89
88
|
destination: string;
|
|
90
89
|
}
|
|
91
90
|
/** A staged run failed after any requested evidence was durably retained. */
|
|
92
|
-
declare class StagedJudgeError extends Error {
|
|
91
|
+
export declare class StagedJudgeError extends Error {
|
|
93
92
|
readonly judgeArtifacts?: JudgeArtifactReceipt;
|
|
94
93
|
constructor(message: string, judgeArtifacts?: JudgeArtifactReceipt, options?: ErrorOptions);
|
|
95
94
|
}
|
|
@@ -98,13 +97,11 @@ declare class StagedJudgeError extends Error {
|
|
|
98
97
|
* cleanup. The evaluator's stdout/stderr is surfaced on failure; the temp dir is
|
|
99
98
|
* always removed in `finally` unless `keepTmp`.
|
|
100
99
|
*/
|
|
101
|
-
declare function runStagedJudge(spec: StagedRunSpec): Promise<BenchScore>;
|
|
100
|
+
export declare function runStagedJudge(spec: StagedRunSpec): Promise<BenchScore>;
|
|
102
101
|
/** Read + JSON.parse a report file from a staged run; throws with the path on failure. */
|
|
103
|
-
declare function readJsonReport<T>(path: string): Promise<T>;
|
|
102
|
+
export declare function readJsonReport<T>(path: string): Promise<T>;
|
|
104
103
|
/** Write a UTF-8 file into a staged dir (artifact / preds.json / attempt.sh / …). */
|
|
105
|
-
declare function stageFile(path: string, content: string): Promise<void>;
|
|
104
|
+
export declare function stageFile(path: string, content: string): Promise<void>;
|
|
106
105
|
/** Sanitize an instance id into a filesystem/run-id-safe token. */
|
|
107
|
-
declare function safeRunId(prefix: string, id: string): string;
|
|
108
|
-
//#endregion
|
|
109
|
-
export { StagedJudgeError, StagedRunCaptureSpec, StagedRunSpec, benchRoot, bigBuffer, preflightVenvImports, readJsonReport, resolveBenchPython, runStagedJudge, runVenvPython, runVenvScriptStdin, safeRunId, stageFile, venvBin, venvBinAt, venvPython, venvPythonAt };
|
|
106
|
+
export declare function safeRunId(prefix: string, id: string): string;
|
|
110
107
|
//# sourceMappingURL=_harness.d.ts.map
|
|
@@ -6,7 +6,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { promisify } from "node:util";
|
|
9
|
-
|
|
9
|
+
// src/benchmarks/_harness.ts
|
|
10
10
|
/**
|
|
11
11
|
* Shared code-bench harness. The "stage the artifact → run the benchmark's own
|
|
12
12
|
* evaluator in an external process (mkdtemp / execFile / .venv python / Docker)
|
|
@@ -59,7 +59,7 @@ function venvBinAt(venvDir, name) {
|
|
|
59
59
|
return join(resolve(benchRoot, venvDir), "bin", name);
|
|
60
60
|
}
|
|
61
61
|
/** Report/transcript reads are large; 256 MiB matches the SWE harness budget. */
|
|
62
|
-
const bigBuffer =
|
|
62
|
+
const bigBuffer = 268435456;
|
|
63
63
|
/** Path to a named executable inside the bench venv (e.g. `venvBin('tb')`). */
|
|
64
64
|
function venvBin(name) {
|
|
65
65
|
return venvBinAt(".venv", name);
|
|
@@ -149,7 +149,8 @@ function compareText(left, right) {
|
|
|
149
149
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
150
150
|
}
|
|
151
151
|
async function collectArtifactFiles(root, current) {
|
|
152
|
-
const
|
|
152
|
+
const absolute = join(root, current);
|
|
153
|
+
const entries = await readdir(absolute, { withFileTypes: true });
|
|
153
154
|
const files = [];
|
|
154
155
|
for (const entry of entries.sort((left, right) => compareText(left.name, right.name))) {
|
|
155
156
|
const relativePath = join(current, entry.name);
|
|
@@ -325,7 +326,6 @@ async function stageFile(path, content) {
|
|
|
325
326
|
function safeRunId(prefix, id) {
|
|
326
327
|
return `${prefix}-${id}`.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
327
328
|
}
|
|
328
|
-
//#endregion
|
|
329
329
|
export { StagedJudgeError, benchRoot, bigBuffer, preflightVenvImports, readJsonReport, resolveBenchPython, runStagedJudge, runVenvPython, runVenvScriptStdin, safeRunId, stageFile, venvBin, venvBinAt, venvPython, venvPythonAt };
|
|
330
330
|
|
|
331
331
|
//# sourceMappingURL=_harness.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_harness.js","names":[],"sources":["../../src/benchmarks/_harness.ts"],"sourcesContent":["/**\n * Shared code-bench harness. The \"stage the artifact → run the benchmark's own\n * evaluator in an external process (mkdtemp / execFile / .venv python / Docker)\n * → read its JSON report → { resolved, score }\" spine that swe-bench,\n * terminal-bench, commit0, programbench and aec-bench all need. Factored out so\n * the Docker/venv/report-reading logic lives in ONE place instead of being\n * copy-pasted per adapter.\n *\n * It owns NO benchmark policy: each adapter passes the argv for its evaluator\n * and a `parseReport` that maps that evaluator's report JSON → a BenchScore. The\n * harness owns process spawning, temp-dir lifecycle, large-buffer/timeout config\n * and fail-loud diagnostics.\n *\n * Fail-loud: an absent .venv / harness / Docker daemon THROWS from `preflight`\n * (the adapter passes the import line + the exact fix). A staged run that exits\n * nonzero throws with the captured stderr — never a fabricated score.\n */\n\nimport { execFile, spawn } from 'node:child_process'\nimport { createHash } from 'node:crypto'\nimport { existsSync, readFileSync } from 'node:fs'\nimport {\n cp,\n lstat,\n mkdir,\n mkdtemp,\n readFile,\n readlink,\n readdir,\n rename,\n rm,\n writeFile,\n} from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { promisify } from 'node:util'\nimport type {\n BenchScore,\n JudgeArtifactFileReceipt,\n JudgeArtifactReceipt,\n} from './types'\n\nconst execFileAsync = promisify(execFile)\n\n/** Locate the package by identity because source files and compiled chunks have different depths. */\nfunction resolveBenchRoot(moduleUrl: string): string {\n let current = dirname(fileURLToPath(moduleUrl))\n while (true) {\n const manifestPath = join(current, 'package.json')\n if (existsSync(manifestPath)) {\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { name?: unknown }\n if (manifest.name === '@tangle-network/agent-bench') return current\n }\n const parent = dirname(current)\n if (parent === current) {\n throw new Error(`Unable to locate @tangle-network/agent-bench from ${moduleUrl}`)\n }\n current = parent\n }\n}\n\n/** Package root for agent-bench, so `.venv`, scripts, and fixtures resolve. */\nexport const benchRoot = resolveBenchRoot(import.meta.url)\n\n/** Resolve the shared interpreter without requiring an installed package to contain a venv. */\nexport function resolveBenchPython(\n env: Readonly<{ AGENT_BENCH_PYTHON?: string }> = process.env,\n root: string = benchRoot,\n): string {\n const configured = env.AGENT_BENCH_PYTHON\n if (configured === undefined) return join(root, '.venv', 'bin', 'python')\n if (!isAbsolute(configured)) {\n throw new Error('AGENT_BENCH_PYTHON must be an absolute path')\n }\n return configured\n}\n\n/** The shared interpreter every Python-backed evaluator runs through. */\nexport const venvPython = resolveBenchPython()\n\n/** Interpreter for a NAMED isolated venv (e.g. `.venv-commit0`). Benches whose pip\n * deps conflict with the shared `.venv` (commit0 downgrades pydantic/sqlalchemy)\n * get their own venv and pass its python explicitly — keeping the shared one clean. */\nexport const venvPythonAt = (venvDir: string): string => venvBinAt(venvDir, 'python')\n\n/** Resolve an executable in an isolated venv. Relative venv paths are package-owned;\n * absolute paths allow installed consumers to keep large environments elsewhere. */\nexport function venvBinAt(venvDir: string, name: string): string {\n return join(resolve(benchRoot, venvDir), 'bin', name)\n}\n\n/** Report/transcript reads are large; 256 MiB matches the SWE harness budget. */\nexport const bigBuffer = 1024 * 1024 * 256\n\n/** Path to a named executable inside the bench venv (e.g. `venvBin('tb')`). */\nexport function venvBin(name: string): string {\n return venvBinAt('.venv', name)\n}\n\n/**\n * Run the bench venv python with an inline script (`-c`); return stdout. Throws\n * (with stderr) on a nonzero exit — the loaders rely on this to fail loud rather\n * than parse a partial dump.\n */\nexport async function runVenvPython(\n script: string,\n args: string[] = [],\n timeoutMs = 0,\n python: string = venvPython,\n): Promise<string> {\n const { stdout } = await execFileAsync(python, ['-c', script, ...args], {\n maxBuffer: bigBuffer,\n timeout: timeoutMs,\n })\n return stdout\n}\n\n/**\n * Preflight a python-backed harness: import the module(s) and (optionally) ping\n * Docker, all inside the bench venv. On failure THROWS the captured error joined\n * to the adapter's `fix` guidance — the contract every code-bench preflight wants.\n */\nexport async function preflightVenvImports(opts: {\n /** Module names to `import` (e.g. ['swebench']); '' entries are ignored. */\n modules: string[]\n /** Also `docker.from_env().ping()` — true for Docker-backed evaluators. */\n requireDocker?: boolean\n /** Actionable remediation appended to the thrown message. */\n fix: string\n /** Override the interpreter (e.g. an isolated `.venv-commit0`). Default: shared `.venv`. */\n python?: string\n}): Promise<void> {\n const imports = opts.modules.filter((m) => m.length > 0)\n const lines = [...imports.map((m) => `import ${m}`)]\n if (opts.requireDocker) lines.push('import docker', 'docker.from_env().ping()')\n lines.push(\"print('ok')\")\n try {\n await runVenvPython(lines.join('\\n'), [], 0, opts.python ?? venvPython)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n throw new Error(`${msg}\\n${opts.fix}`)\n }\n}\n\n/**\n * Run a bench-local python driver script (in the bench venv) while piping\n * `input` to its stdin, returning stdout. The driver's verdict JSON is its LAST\n * stdout line; callers parse that and inspect an `error` field (fail loud).\n *\n * Uses spawn + an explicit `stdin.end(input)` rather than promisify(execFile)'s\n * `input` option, because that option is NOT honored by async execFile — stdin\n * is left open and a driver that does `sys.stdin.read()` blocks forever. The\n * artifact-piping judges (commit0, appworld) MUST go through this.\n */\nexport function runVenvScriptStdin(\n scriptPath: string,\n args: string[],\n input: string,\n opts: { cwd?: string; timeoutMs?: number; python?: string } = {},\n): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n const child = spawn(opts.python ?? venvPython, [scriptPath, ...args], {\n cwd: opts.cwd ?? benchRoot,\n ...(opts.timeoutMs ? { timeout: opts.timeoutMs } : {}),\n })\n let stdout = ''\n let stderr = ''\n let bytes = 0\n child.stdout.on('data', (c: Buffer) => {\n bytes += c.length\n if (bytes <= bigBuffer) stdout += c.toString('utf8')\n })\n child.stderr.on('data', (c: Buffer) => {\n stderr += c.toString('utf8')\n })\n child.on('error', (err) => reject(err))\n child.on('close', (code) => {\n if (code === 0) resolve(stdout)\n else reject(new Error((stderr || stdout || `exit ${code}`).slice(0, 1500)))\n })\n child.stdin.end(input)\n })\n}\n\nexport interface StagedRunSpec {\n /** mkdtemp prefix, e.g. 'swebench-' / 'commit0-'. */\n tmpPrefix: string\n /**\n * Write the artifact + any harness inputs into the temp dir. Returns nothing;\n * `argv`/`cwd` consume `dir` to point the evaluator at what was written.\n */\n stage(dir: string): Promise<void>\n /** The external evaluator to spawn. `bin` defaults to the bench venv python. */\n bin?: string\n /** argv for the evaluator, computed from the temp `dir`. */\n argv(dir: string): string[]\n /** Working directory for the evaluator. Defaults to the temp `dir`. */\n cwd?(dir: string): string\n /** Hard timeout for the evaluator (ms); 0 = none. */\n timeoutMs?: number\n /**\n * Read the evaluator's report(s) out of `dir` and map to a BenchScore. Throws\n * if the expected report is absent/malformed (fail loud — no default score).\n */\n parseReport(dir: string): Promise<BenchScore>\n /**\n * Copy the complete evaluator directory plus raw process stdout/stderr to this\n * caller-owned directory before cleanup. The destination must not exist.\n */\n capture?: StagedRunCaptureSpec\n /** Keep the temp dir on disk (debugging). Default false → always cleaned up. */\n keepTmp?: boolean\n}\n\nexport interface StagedRunCaptureSpec {\n /** Destination for `evaluator/`, `process/`, and the hashed `receipt.json`. */\n destination: string\n}\n\n/** A staged run failed after any requested evidence was durably retained. */\nexport class StagedJudgeError extends Error {\n readonly judgeArtifacts?: JudgeArtifactReceipt\n\n constructor(message: string, judgeArtifacts?: JudgeArtifactReceipt, options?: ErrorOptions) {\n super(message, options)\n this.name = 'StagedJudgeError'\n this.judgeArtifacts = judgeArtifacts\n }\n}\n\nfunction sha256(bytes: Uint8Array): `sha256:${string}` {\n return `sha256:${createHash('sha256').update(bytes).digest('hex')}`\n}\n\nfunction portablePath(path: string): string {\n return path.split(sep).join('/')\n}\n\nfunction compareText(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0\n}\n\nasync function collectArtifactFiles(\n root: string,\n current: string,\n): Promise<JudgeArtifactFileReceipt[]> {\n const absolute = join(root, current)\n const entries = await readdir(absolute, { withFileTypes: true })\n const files: JudgeArtifactFileReceipt[] = []\n for (const entry of entries.sort((left, right) => compareText(left.name, right.name))) {\n const relativePath = join(current, entry.name)\n const path = join(root, relativePath)\n if (entry.isDirectory()) {\n files.push(...await collectArtifactFiles(root, relativePath))\n continue\n }\n if (entry.isFile()) {\n const bytes = await readFile(path)\n files.push({\n path: portablePath(relativePath),\n byteLength: bytes.byteLength,\n sha256: sha256(bytes),\n kind: 'file',\n })\n continue\n }\n if (entry.isSymbolicLink()) {\n const targetBytes = await readlink(path, { encoding: 'buffer' })\n files.push({\n path: portablePath(relativePath),\n byteLength: targetBytes.byteLength,\n sha256: sha256(targetBytes),\n kind: 'symlink',\n })\n continue\n }\n throw new Error(`staged judge capture does not support ${relativePath}`)\n }\n return files\n}\n\nfunction isWithin(parent: string, candidate: string): boolean {\n const path = relative(parent, candidate)\n return path === '' || (!path.startsWith(`..${sep}`) && path !== '..' && !isAbsolute(path))\n}\n\nasync function assertDestinationAbsent(destination: string): Promise<void> {\n try {\n await lstat(destination)\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return\n throw error\n }\n throw new Error(`staged judge capture destination already exists: ${destination}`)\n}\n\nasync function captureStagedRun(\n sourceDirectory: string,\n spec: StagedRunCaptureSpec,\n processOutput: Readonly<{ stdout: Buffer; stderr: Buffer }>,\n evaluatorSucceeded: boolean,\n): Promise<JudgeArtifactReceipt> {\n const source = resolve(sourceDirectory)\n const destination = resolve(spec.destination)\n if (isWithin(source, destination)) {\n throw new Error('staged judge capture destination must be outside the evaluator directory')\n }\n await mkdir(dirname(destination), { recursive: true })\n await assertDestinationAbsent(destination)\n const staging = await mkdtemp(join(dirname(destination), `.${basename(destination)}-capture-`))\n try {\n await cp(source, join(staging, 'evaluator'), {\n recursive: true,\n errorOnExist: true,\n force: false,\n preserveTimestamps: true,\n verbatimSymlinks: true,\n })\n await mkdir(join(staging, 'process'))\n await writeFile(join(staging, 'process', 'stdout.bin'), processOutput.stdout)\n await writeFile(join(staging, 'process', 'stderr.bin'), processOutput.stderr)\n\n const files = [\n ...await collectArtifactFiles(staging, 'evaluator'),\n ...await collectArtifactFiles(staging, 'process'),\n ].sort((left, right) => compareText(left.path, right.path))\n const byteLength = files.reduce((total, file) => total + file.byteLength, 0)\n const treeBytes = Buffer.from(\n files\n .map((file) => `${file.path}\\0${file.kind}\\0${file.byteLength}\\0${file.sha256}\\n`)\n .join(''),\n 'utf8',\n )\n const receipt: JudgeArtifactReceipt = {\n schema: 'agent-bench/judge-artifacts/v1',\n directory: destination,\n evaluatorDirectory: join(destination, 'evaluator'),\n manifestPath: join(destination, 'receipt.json'),\n evaluatorSucceeded,\n files,\n fileCount: files.length,\n byteLength,\n treeSha256: sha256(treeBytes),\n }\n await writeFile(join(staging, 'receipt.json'), `${JSON.stringify(receipt, null, 2)}\\n`)\n await rename(staging, destination)\n return receipt\n } catch (error) {\n await rm(staging, { recursive: true, force: true }).catch(() => {})\n throw error\n }\n}\n\nfunction processBytes(value: unknown): Buffer {\n if (Buffer.isBuffer(value)) return value\n if (value === undefined || value === null) return Buffer.alloc(0)\n return Buffer.from(String(value), 'utf8')\n}\n\n/**\n * The shared judge body: mkdtemp → stage → spawn evaluator → parseReport →\n * cleanup. The evaluator's stdout/stderr is surfaced on failure; the temp dir is\n * always removed in `finally` unless `keepTmp`.\n */\nexport async function runStagedJudge(spec: StagedRunSpec): Promise<BenchScore> {\n const dir = await mkdtemp(join(tmpdir(), spec.tmpPrefix))\n let stdout: Buffer<ArrayBufferLike> = Buffer.alloc(0)\n let stderr: Buffer<ArrayBufferLike> = Buffer.alloc(0)\n let evaluatorSucceeded = false\n let score: BenchScore | undefined\n let failure: unknown\n try {\n try {\n await spec.stage(dir)\n const bin = spec.bin ?? venvPython\n const argv = spec.argv(dir)\n try {\n const output = await execFileAsync(bin, argv, {\n cwd: spec.cwd ? spec.cwd(dir) : dir,\n encoding: 'buffer',\n maxBuffer: bigBuffer,\n ...(spec.timeoutMs ? { timeout: spec.timeoutMs } : {}),\n })\n stdout = processBytes(output.stdout)\n stderr = processBytes(output.stderr)\n evaluatorSucceeded = true\n } catch (err) {\n const e = err as { stderr?: unknown; stdout?: unknown; message?: string }\n stdout = processBytes(e.stdout)\n stderr = processBytes(e.stderr)\n const detail = processBytes(e.stderr ?? e.stdout ?? e.message ?? String(err))\n .toString('utf8')\n .slice(0, 2000)\n throw new Error(`${spec.tmpPrefix.replace(/-$/, '')} evaluator failed (${bin} ${argv.join(' ')}):\\n${detail}`)\n }\n score = await spec.parseReport(dir)\n } catch (err) {\n failure = err\n }\n } finally {\n let judgeArtifacts: JudgeArtifactReceipt | undefined\n if (spec.capture) {\n try {\n judgeArtifacts = await captureStagedRun(\n dir,\n spec.capture,\n { stdout, stderr },\n evaluatorSucceeded,\n )\n } catch (captureError) {\n failure = new Error(\n `staged judge failed to capture evaluator artifacts: ${captureError instanceof Error ? captureError.message : captureError}`,\n { cause: failure ?? captureError },\n )\n }\n }\n if (!spec.keepTmp) await rm(dir, { recursive: true, force: true }).catch(() => {})\n if (failure) {\n throw new StagedJudgeError(\n failure instanceof Error ? failure.message : String(failure),\n judgeArtifacts,\n { cause: failure },\n )\n }\n if (!score) throw new StagedJudgeError('staged judge completed without a score', judgeArtifacts)\n return judgeArtifacts ? { ...score, judgeArtifacts } : score\n }\n}\n\n/** Read + JSON.parse a report file from a staged run; throws with the path on failure. */\nexport async function readJsonReport<T>(path: string): Promise<T> {\n let raw: string\n try {\n raw = await readFile(path, 'utf8')\n } catch (err) {\n throw new Error(`expected report not written: ${path} (${err instanceof Error ? err.message : err})`)\n }\n try {\n return JSON.parse(raw) as T\n } catch (err) {\n throw new Error(`report not valid JSON at ${path}: ${err instanceof Error ? err.message : err}`)\n }\n}\n\n/** Write a UTF-8 file into a staged dir (artifact / preds.json / attempt.sh / …). */\nexport async function stageFile(path: string, content: string): Promise<void> {\n await writeFile(path, content)\n}\n\n/** Sanitize an instance id into a filesystem/run-id-safe token. */\nexport function safeRunId(prefix: string, id: string): string {\n return `${prefix}-${id}`.replace(/[^a-zA-Z0-9_.-]/g, '_')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,gBAAgB,UAAU,QAAQ;;AAGxC,SAAS,iBAAiB,WAA2B;CACnD,IAAI,UAAU,QAAQ,cAAc,SAAS,CAAC;CAC9C,OAAO,MAAM;EACX,MAAM,eAAe,KAAK,SAAS,cAAc;EACjD,IAAI,WAAW,YAAY,GACR;OAAA,KAAK,MAAM,aAAa,cAAc,MAAM,CAClD,CAAC,CAAC,SAAS,+BAA+B,OAAO;EAAA;EAE9D,MAAM,SAAS,QAAQ,OAAO;EAC9B,IAAI,WAAW,SACb,MAAM,IAAI,MAAM,qDAAqD,WAAW;EAElF,UAAU;CACZ;AACF;;AAGA,MAAa,YAAY,iBAAiB,OAAO,KAAK,GAAG;;AAGzD,SAAgB,mBACd,MAAiD,QAAQ,KACzD,OAAe,WACP;CACR,MAAM,aAAa,IAAI;CACvB,IAAI,eAAe,KAAA,GAAW,OAAO,KAAK,MAAM,SAAS,OAAO,QAAQ;CACxE,IAAI,CAAC,WAAW,UAAU,GACxB,MAAM,IAAI,MAAM,6CAA6C;CAE/D,OAAO;AACT;;AAGA,MAAa,aAAa,mBAAmB;;;;AAK7C,MAAa,gBAAgB,YAA4B,UAAU,SAAS,QAAQ;;;AAIpF,SAAgB,UAAU,SAAiB,MAAsB;CAC/D,OAAO,KAAK,QAAQ,WAAW,OAAO,GAAG,OAAO,IAAI;AACtD;;AAGA,MAAa,YAAY,OAAO,OAAO;;AAGvC,SAAgB,QAAQ,MAAsB;CAC5C,OAAO,UAAU,SAAS,IAAI;AAChC;;;;;;AAOA,eAAsB,cACpB,QACA,OAAiB,CAAC,GAClB,YAAY,GACZ,SAAiB,YACA;CACjB,MAAM,EAAE,WAAW,MAAM,cAAc,QAAQ;EAAC;EAAM;EAAQ,GA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IAAI,iBAAiB,0CAA0C,cAAc;EAC/F,OAAO,iBAAiB;GAAE,GAAG;GAAO;EAAe,IAAI;CACzD;AACF;;AAGA,eAAsB,eAAkB,MAA0B;CAChE,IAAI;CACJ,IAAI;EACF,MAAM,MAAM,SAAS,MAAM,MAAM;CACnC,SAAS,KAAK;EACZ,MAAM,IAAI,MAAM,gCAAgC,KAAK,IAAI,eAAe,QAAQ,IAAI,UAAU,IAAI,EAAE;CACtG;CACA,IAAI;EACF,OAAO,KAAK,MAAM,GAAG;CACvB,SAAS,KAAK;EACZ,MAAM,IAAI,MAAM,4BAA4B,KAAK,IAAI,eAAe,QAAQ,IAAI,UAAU,KAAK;CACjG;AACF;;AAGA,eAAsB,UAAU,MAAc,SAAgC;CAC5E,MAAM,UAAU,MAAM,OAAO;AAC/B;;AAGA,SAAgB,UAAU,QAAgB,IAAoB;CAC5D,OAAO,GAAG,OAAO,GAAG,KAAK,QAAQ,oBAAoB,GAAG;AAC1D"}
|
|
1
|
+
{"version":3,"file":"_harness.js","names":[],"sources":["../../src/benchmarks/_harness.ts"],"sourcesContent":["/**\n * Shared code-bench harness. The \"stage the artifact → run the benchmark's own\n * evaluator in an external process (mkdtemp / execFile / .venv python / Docker)\n * → read its JSON report → { resolved, score }\" spine that swe-bench,\n * terminal-bench, commit0, programbench and aec-bench all need. Factored out so\n * the Docker/venv/report-reading logic lives in ONE place instead of being\n * copy-pasted per adapter.\n *\n * It owns NO benchmark policy: each adapter passes the argv for its evaluator\n * and a `parseReport` that maps that evaluator's report JSON → a BenchScore. The\n * harness owns process spawning, temp-dir lifecycle, large-buffer/timeout config\n * and fail-loud diagnostics.\n *\n * Fail-loud: an absent .venv / harness / Docker daemon THROWS from `preflight`\n * (the adapter passes the import line + the exact fix). A staged run that exits\n * nonzero throws with the captured stderr — never a fabricated score.\n */\n\nimport { execFile, spawn } from 'node:child_process'\nimport { createHash } from 'node:crypto'\nimport { existsSync, readFileSync } from 'node:fs'\nimport {\n cp,\n lstat,\n mkdir,\n mkdtemp,\n readFile,\n readlink,\n readdir,\n rename,\n rm,\n writeFile,\n} from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { promisify } from 'node:util'\nimport type {\n BenchScore,\n JudgeArtifactFileReceipt,\n JudgeArtifactReceipt,\n} from './types'\n\nconst execFileAsync = promisify(execFile)\n\n/** Locate the package by identity because source files and compiled chunks have different depths. */\nfunction resolveBenchRoot(moduleUrl: string): string {\n let current = dirname(fileURLToPath(moduleUrl))\n while (true) {\n const manifestPath = join(current, 'package.json')\n if (existsSync(manifestPath)) {\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { name?: unknown }\n if (manifest.name === '@tangle-network/agent-bench') return current\n }\n const parent = dirname(current)\n if (parent === current) {\n throw new Error(`Unable to locate @tangle-network/agent-bench from ${moduleUrl}`)\n }\n current = parent\n }\n}\n\n/** Package root for agent-bench, so `.venv`, scripts, and fixtures resolve. */\nexport const benchRoot = resolveBenchRoot(import.meta.url)\n\n/** Resolve the shared interpreter without requiring an installed package to contain a venv. */\nexport function resolveBenchPython(\n env: Readonly<{ AGENT_BENCH_PYTHON?: string }> = process.env,\n root: string = benchRoot,\n): string {\n const configured = env.AGENT_BENCH_PYTHON\n if (configured === undefined) return join(root, '.venv', 'bin', 'python')\n if (!isAbsolute(configured)) {\n throw new Error('AGENT_BENCH_PYTHON must be an absolute path')\n }\n return configured\n}\n\n/** The shared interpreter every Python-backed evaluator runs through. */\nexport const venvPython = resolveBenchPython()\n\n/** Interpreter for a NAMED isolated venv (e.g. `.venv-commit0`). Benches whose pip\n * deps conflict with the shared `.venv` (commit0 downgrades pydantic/sqlalchemy)\n * get their own venv and pass its python explicitly — keeping the shared one clean. */\nexport const venvPythonAt = (venvDir: string): string => venvBinAt(venvDir, 'python')\n\n/** Resolve an executable in an isolated venv. Relative venv paths are package-owned;\n * absolute paths allow installed consumers to keep large environments elsewhere. */\nexport function venvBinAt(venvDir: string, name: string): string {\n return join(resolve(benchRoot, venvDir), 'bin', name)\n}\n\n/** Report/transcript reads are large; 256 MiB matches the SWE harness budget. */\nexport const bigBuffer = 1024 * 1024 * 256\n\n/** Path to a named executable inside the bench venv (e.g. `venvBin('tb')`). */\nexport function venvBin(name: string): string {\n return venvBinAt('.venv', name)\n}\n\n/**\n * Run the bench venv python with an inline script (`-c`); return stdout. Throws\n * (with stderr) on a nonzero exit — the loaders rely on this to fail loud rather\n * than parse a partial dump.\n */\nexport async function runVenvPython(\n script: string,\n args: string[] = [],\n timeoutMs = 0,\n python: string = venvPython,\n): Promise<string> {\n const { stdout } = await execFileAsync(python, ['-c', script, ...args], {\n maxBuffer: bigBuffer,\n timeout: timeoutMs,\n })\n return stdout\n}\n\n/**\n * Preflight a python-backed harness: import the module(s) and (optionally) ping\n * Docker, all inside the bench venv. On failure THROWS the captured error joined\n * to the adapter's `fix` guidance — the contract every code-bench preflight wants.\n */\nexport async function preflightVenvImports(opts: {\n /** Module names to `import` (e.g. ['swebench']); '' entries are ignored. */\n modules: string[]\n /** Also `docker.from_env().ping()` — true for Docker-backed evaluators. */\n requireDocker?: boolean\n /** Actionable remediation appended to the thrown message. */\n fix: string\n /** Override the interpreter (e.g. an isolated `.venv-commit0`). Default: shared `.venv`. */\n python?: string\n}): Promise<void> {\n const imports = opts.modules.filter((m) => m.length > 0)\n const lines = [...imports.map((m) => `import ${m}`)]\n if (opts.requireDocker) lines.push('import docker', 'docker.from_env().ping()')\n lines.push(\"print('ok')\")\n try {\n await runVenvPython(lines.join('\\n'), [], 0, opts.python ?? venvPython)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n throw new Error(`${msg}\\n${opts.fix}`)\n }\n}\n\n/**\n * Run a bench-local python driver script (in the bench venv) while piping\n * `input` to its stdin, returning stdout. The driver's verdict JSON is its LAST\n * stdout line; callers parse that and inspect an `error` field (fail loud).\n *\n * Uses spawn + an explicit `stdin.end(input)` rather than promisify(execFile)'s\n * `input` option, because that option is NOT honored by async execFile — stdin\n * is left open and a driver that does `sys.stdin.read()` blocks forever. The\n * artifact-piping judges (commit0, appworld) MUST go through this.\n */\nexport function runVenvScriptStdin(\n scriptPath: string,\n args: string[],\n input: string,\n opts: { cwd?: string; timeoutMs?: number; python?: string } = {},\n): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n const child = spawn(opts.python ?? venvPython, [scriptPath, ...args], {\n cwd: opts.cwd ?? benchRoot,\n ...(opts.timeoutMs ? { timeout: opts.timeoutMs } : {}),\n })\n let stdout = ''\n let stderr = ''\n let bytes = 0\n child.stdout.on('data', (c: Buffer) => {\n bytes += c.length\n if (bytes <= bigBuffer) stdout += c.toString('utf8')\n })\n child.stderr.on('data', (c: Buffer) => {\n stderr += c.toString('utf8')\n })\n child.on('error', (err) => reject(err))\n child.on('close', (code) => {\n if (code === 0) resolve(stdout)\n else reject(new Error((stderr || stdout || `exit ${code}`).slice(0, 1500)))\n })\n child.stdin.end(input)\n })\n}\n\nexport interface StagedRunSpec {\n /** mkdtemp prefix, e.g. 'swebench-' / 'commit0-'. */\n tmpPrefix: string\n /**\n * Write the artifact + any harness inputs into the temp dir. Returns nothing;\n * `argv`/`cwd` consume `dir` to point the evaluator at what was written.\n */\n stage(dir: string): Promise<void>\n /** The external evaluator to spawn. `bin` defaults to the bench venv python. */\n bin?: string\n /** argv for the evaluator, computed from the temp `dir`. */\n argv(dir: string): string[]\n /** Working directory for the evaluator. Defaults to the temp `dir`. */\n cwd?(dir: string): string\n /** Hard timeout for the evaluator (ms); 0 = none. */\n timeoutMs?: number\n /**\n * Read the evaluator's report(s) out of `dir` and map to a BenchScore. Throws\n * if the expected report is absent/malformed (fail loud — no default score).\n */\n parseReport(dir: string): Promise<BenchScore>\n /**\n * Copy the complete evaluator directory plus raw process stdout/stderr to this\n * caller-owned directory before cleanup. The destination must not exist.\n */\n capture?: StagedRunCaptureSpec\n /** Keep the temp dir on disk (debugging). Default false → always cleaned up. */\n keepTmp?: boolean\n}\n\nexport interface StagedRunCaptureSpec {\n /** Destination for `evaluator/`, `process/`, and the hashed `receipt.json`. */\n destination: string\n}\n\n/** A staged run failed after any requested evidence was durably retained. */\nexport class StagedJudgeError extends Error {\n readonly judgeArtifacts?: JudgeArtifactReceipt\n\n constructor(message: string, judgeArtifacts?: JudgeArtifactReceipt, options?: ErrorOptions) {\n super(message, options)\n this.name = 'StagedJudgeError'\n this.judgeArtifacts = judgeArtifacts\n }\n}\n\nfunction sha256(bytes: Uint8Array): `sha256:${string}` {\n return `sha256:${createHash('sha256').update(bytes).digest('hex')}`\n}\n\nfunction portablePath(path: string): string {\n return path.split(sep).join('/')\n}\n\nfunction compareText(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0\n}\n\nasync function collectArtifactFiles(\n root: string,\n current: string,\n): Promise<JudgeArtifactFileReceipt[]> {\n const absolute = join(root, current)\n const entries = await readdir(absolute, { withFileTypes: true })\n const files: JudgeArtifactFileReceipt[] = []\n for (const entry of entries.sort((left, right) => compareText(left.name, right.name))) {\n const relativePath = join(current, entry.name)\n const path = join(root, relativePath)\n if (entry.isDirectory()) {\n files.push(...await collectArtifactFiles(root, relativePath))\n continue\n }\n if (entry.isFile()) {\n const bytes = await readFile(path)\n files.push({\n path: portablePath(relativePath),\n byteLength: bytes.byteLength,\n sha256: sha256(bytes),\n kind: 'file',\n })\n continue\n }\n if (entry.isSymbolicLink()) {\n const targetBytes = await readlink(path, { encoding: 'buffer' })\n files.push({\n path: portablePath(relativePath),\n byteLength: targetBytes.byteLength,\n sha256: sha256(targetBytes),\n kind: 'symlink',\n })\n continue\n }\n throw new Error(`staged judge capture does not support ${relativePath}`)\n }\n return files\n}\n\nfunction isWithin(parent: string, candidate: string): boolean {\n const path = relative(parent, candidate)\n return path === '' || (!path.startsWith(`..${sep}`) && path !== '..' && !isAbsolute(path))\n}\n\nasync function assertDestinationAbsent(destination: string): Promise<void> {\n try {\n await lstat(destination)\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return\n throw error\n }\n throw new Error(`staged judge capture destination already exists: ${destination}`)\n}\n\nasync function captureStagedRun(\n sourceDirectory: string,\n spec: StagedRunCaptureSpec,\n processOutput: Readonly<{ stdout: Buffer; stderr: Buffer }>,\n evaluatorSucceeded: boolean,\n): Promise<JudgeArtifactReceipt> {\n const source = resolve(sourceDirectory)\n const destination = resolve(spec.destination)\n if (isWithin(source, destination)) {\n throw new Error('staged judge capture destination must be outside the evaluator directory')\n }\n await mkdir(dirname(destination), { recursive: true })\n await assertDestinationAbsent(destination)\n const staging = await mkdtemp(join(dirname(destination), `.${basename(destination)}-capture-`))\n try {\n await cp(source, join(staging, 'evaluator'), {\n recursive: true,\n errorOnExist: true,\n force: false,\n preserveTimestamps: true,\n verbatimSymlinks: true,\n })\n await mkdir(join(staging, 'process'))\n await writeFile(join(staging, 'process', 'stdout.bin'), processOutput.stdout)\n await writeFile(join(staging, 'process', 'stderr.bin'), processOutput.stderr)\n\n const files = [\n ...await collectArtifactFiles(staging, 'evaluator'),\n ...await collectArtifactFiles(staging, 'process'),\n ].sort((left, right) => compareText(left.path, right.path))\n const byteLength = files.reduce((total, file) => total + file.byteLength, 0)\n const treeBytes = Buffer.from(\n files\n .map((file) => `${file.path}\\0${file.kind}\\0${file.byteLength}\\0${file.sha256}\\n`)\n .join(''),\n 'utf8',\n )\n const receipt: JudgeArtifactReceipt = {\n schema: 'agent-bench/judge-artifacts/v1',\n directory: destination,\n evaluatorDirectory: join(destination, 'evaluator'),\n manifestPath: join(destination, 'receipt.json'),\n evaluatorSucceeded,\n files,\n fileCount: files.length,\n byteLength,\n treeSha256: sha256(treeBytes),\n }\n await writeFile(join(staging, 'receipt.json'), `${JSON.stringify(receipt, null, 2)}\\n`)\n await rename(staging, destination)\n return receipt\n } catch (error) {\n await rm(staging, { recursive: true, force: true }).catch(() => {})\n throw error\n }\n}\n\nfunction processBytes(value: unknown): Buffer {\n if (Buffer.isBuffer(value)) return value\n if (value === undefined || value === null) return Buffer.alloc(0)\n return Buffer.from(String(value), 'utf8')\n}\n\n/**\n * The shared judge body: mkdtemp → stage → spawn evaluator → parseReport →\n * cleanup. The evaluator's stdout/stderr is surfaced on failure; the temp dir is\n * always removed in `finally` unless `keepTmp`.\n */\nexport async function runStagedJudge(spec: StagedRunSpec): Promise<BenchScore> {\n const dir = await mkdtemp(join(tmpdir(), spec.tmpPrefix))\n let stdout: Buffer<ArrayBufferLike> = Buffer.alloc(0)\n let stderr: Buffer<ArrayBufferLike> = Buffer.alloc(0)\n let evaluatorSucceeded = false\n let score: BenchScore | undefined\n let failure: unknown\n try {\n try {\n await spec.stage(dir)\n const bin = spec.bin ?? venvPython\n const argv = spec.argv(dir)\n try {\n const output = await execFileAsync(bin, argv, {\n cwd: spec.cwd ? spec.cwd(dir) : dir,\n encoding: 'buffer',\n maxBuffer: bigBuffer,\n ...(spec.timeoutMs ? { timeout: spec.timeoutMs } : {}),\n })\n stdout = processBytes(output.stdout)\n stderr = processBytes(output.stderr)\n evaluatorSucceeded = true\n } catch (err) {\n const e = err as { stderr?: unknown; stdout?: unknown; message?: string }\n stdout = processBytes(e.stdout)\n stderr = processBytes(e.stderr)\n const detail = processBytes(e.stderr ?? e.stdout ?? e.message ?? String(err))\n .toString('utf8')\n .slice(0, 2000)\n throw new Error(`${spec.tmpPrefix.replace(/-$/, '')} evaluator failed (${bin} ${argv.join(' ')}):\\n${detail}`)\n }\n score = await spec.parseReport(dir)\n } catch (err) {\n failure = err\n }\n } finally {\n let judgeArtifacts: JudgeArtifactReceipt | undefined\n if (spec.capture) {\n try {\n judgeArtifacts = await captureStagedRun(\n dir,\n spec.capture,\n { stdout, stderr },\n evaluatorSucceeded,\n )\n } catch (captureError) {\n failure = new Error(\n `staged judge failed to capture evaluator artifacts: ${captureError instanceof Error ? captureError.message : captureError}`,\n { cause: failure ?? captureError },\n )\n }\n }\n if (!spec.keepTmp) await rm(dir, { recursive: true, force: true }).catch(() => {})\n if (failure) {\n throw new StagedJudgeError(\n failure instanceof Error ? failure.message : String(failure),\n judgeArtifacts,\n { cause: failure },\n )\n }\n if (!score) throw new StagedJudgeError('staged judge completed without a score', judgeArtifacts)\n return judgeArtifacts ? { ...score, judgeArtifacts } : score\n }\n}\n\n/** Read + JSON.parse a report file from a staged run; throws with the path on failure. */\nexport async function readJsonReport<T>(path: string): Promise<T> {\n let raw: string\n try {\n raw = await readFile(path, 'utf8')\n } catch (err) {\n throw new Error(`expected report not written: ${path} (${err instanceof Error ? err.message : err})`)\n }\n try {\n return JSON.parse(raw) as T\n } catch (err) {\n throw new Error(`report not valid JSON at ${path}: ${err instanceof Error ? err.message : err}`)\n }\n}\n\n/** Write a UTF-8 file into a staged dir (artifact / preds.json / attempt.sh / …). */\nexport async function stageFile(path: string, content: string): Promise<void> {\n await writeFile(path, content)\n}\n\n/** Sanitize an instance id into a filesystem/run-id-safe token. */\nexport function safeRunId(prefix: string, id: string): string {\n return `${prefix}-${id}`.replace(/[^a-zA-Z0-9_.-]/g, '_')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,gBAAgB,UAAU,QAAQ;;AAGxC,SAAS,iBAAiB,WAA2B;CACnD,IAAI,UAAU,QAAQ,cAAc,SAAS,CAAC;CAC9C,OAAO,MAAM;EACX,MAAM,eAAe,KAAK,SAAS,cAAc;EACjD,IAAI,WAAW,YAAY,GACR;OAAA,KAAK,MAAM,aAAa,cAAc,MAAM,CAClD,CAAC,CAAC,SAAS,+BAA+B,OAAO;EAAA;EAE9D,MAAM,SAAS,QAAQ,OAAO;EAC9B,IAAI,WAAW,SACb,MAAM,IAAI,MAAM,qDAAqD,WAAW;EAElF,UAAU;CACZ;AACF;;AAGA,MAAa,YAAY,iBAAiB,YAAY,GAAG;;AAGzD,SAAgB,mBACd,MAAiD,QAAQ,KACzD,OAAe,WACP;CACR,MAAM,aAAa,IAAI;CACvB,IAAI,eAAe,KAAA,GAAW,OAAO,KAAK,MA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chAdapter(): BenchmarkAdapter;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { createAecBenchAdapter };
|
|
2
|
+
export declare function createAecBenchAdapter(): BenchmarkAdapter;
|
|
6
3
|
//# sourceMappingURL=aec-bench.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { benchRoot, preflightVenvImports, readJsonReport, runStagedJudge, stageFile, venvPython } from "./_harness.js";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
|
|
4
|
+
// src/benchmarks/aec-bench.ts
|
|
5
5
|
/**
|
|
6
6
|
* AEC-Bench adapter (TheodoreGalanos/aec-bench, MIT) — closed-form
|
|
7
7
|
* Architecture/Engineering/Construction calculation tasks. Worker artifact = a
|
|
@@ -237,7 +237,6 @@ function createAecBenchAdapter() {
|
|
|
237
237
|
}
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
|
-
//#endregion
|
|
241
240
|
export { createAecBenchAdapter };
|
|
242
241
|
|
|
243
242
|
//# sourceMappingURL=aec-bench.js.map
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { BenchmarkAdapter } from "./types.js";
|
|
2
2
|
import { OutputAdapter } from "@tangle-network/agent-runtime/kernel";
|
|
3
|
-
|
|
4
|
-
declare
|
|
5
|
-
declare function createAgentBenchAdapter(): BenchmarkAdapter;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { agentbenchAnswerOutput, createAgentBenchAdapter };
|
|
3
|
+
export declare const agentbenchAnswerOutput: OutputAdapter<string>;
|
|
4
|
+
export declare function createAgentBenchAdapter(): BenchmarkAdapter;
|
|
8
5
|
//# sourceMappingURL=agentbench.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { benchRoot } from "./_harness.js";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
|
|
4
|
+
// src/benchmarks/agentbench.ts
|
|
5
5
|
/**
|
|
6
6
|
* AgentBench deterministic subset adapter.
|
|
7
7
|
*
|
|
@@ -109,7 +109,6 @@ function createAgentBenchAdapter() {
|
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
-
//#endregion
|
|
113
112
|
export { agentbenchAnswerOutput, createAgentBenchAdapter };
|
|
114
113
|
|
|
115
114
|
//# sourceMappingURL=agentbench.js.map
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { BenchmarkAdapter } from "./types.js";
|
|
2
2
|
import { OutputAdapter } from "@tangle-network/agent-runtime/kernel";
|
|
3
|
-
//#region src/benchmarks/appworld.d.ts
|
|
4
3
|
/** Worker solution code = the last fenced ```python block, else the raw text. */
|
|
5
|
-
declare const appworldSolutionOutput: OutputAdapter<string>;
|
|
6
|
-
declare function createAppWorldAdapter(): BenchmarkAdapter;
|
|
4
|
+
export declare const appworldSolutionOutput: OutputAdapter<string>;
|
|
5
|
+
export declare function createAppWorldAdapter(): BenchmarkAdapter;
|
|
7
6
|
/**
|
|
8
7
|
* AppWorld in its NATIVE protocol, run by OUR runtime: the worker is
|
|
9
8
|
* Runtime's profile-bound `router-tools` executor with one tool —
|
|
@@ -24,7 +23,7 @@ declare function createAppWorldAdapter(): BenchmarkAdapter;
|
|
|
24
23
|
* worker without modification. The artifact is the episode evaluation JSON
|
|
25
24
|
* (AppWorld's evaluator ran in-world); judge() parses it, never re-executes.
|
|
26
25
|
*/
|
|
27
|
-
interface ReactResult {
|
|
26
|
+
export interface ReactResult {
|
|
28
27
|
success?: boolean;
|
|
29
28
|
passes?: number;
|
|
30
29
|
fails?: number;
|
|
@@ -46,9 +45,9 @@ interface ReactRuntimeUsage {
|
|
|
46
45
|
/** Preserve a completed scientific/task result even when one accounting dimension is incomplete.
|
|
47
46
|
* Unknown usage fields stay absent; later comparison/reporting can refuse a cost claim without
|
|
48
47
|
* discarding the episode's task evidence. */
|
|
49
|
-
declare function appworldReactResultWithUsage(verdict: ReactResult, usage: ReactRuntimeUsage, turns: number | undefined, transcript: string): ReactResult;
|
|
48
|
+
export declare function appworldReactResultWithUsage(verdict: ReactResult, usage: ReactRuntimeUsage, turns: number | undefined, transcript: string): ReactResult;
|
|
50
49
|
/** Emit only usage the Runtime actually knows. Catalog estimates never become observed dollars. */
|
|
51
|
-
declare function appworldReactUsageEvent(result: ReactResult, model: string): {
|
|
50
|
+
export declare function appworldReactUsageEvent(result: ReactResult, model: string): {
|
|
52
51
|
type: 'llm_call';
|
|
53
52
|
data: Record<string, unknown>;
|
|
54
53
|
} | undefined;
|
|
@@ -60,7 +59,7 @@ type AppWorldComplete = (body: Record<string, unknown>, request?: {
|
|
|
60
59
|
readonly signal?: AbortSignal;
|
|
61
60
|
}) => Promise<unknown>;
|
|
62
61
|
/** SandboxClient whose leaf is Runtime's profile-bound Router executor driving a world session. */
|
|
63
|
-
declare function appworldToolLoopClient(cfg: {
|
|
62
|
+
export declare function appworldToolLoopClient(cfg: {
|
|
64
63
|
model: string;
|
|
65
64
|
routerBaseUrl: string;
|
|
66
65
|
routerKey: string;
|
|
@@ -70,7 +69,6 @@ declare function appworldToolLoopClient(cfg: {
|
|
|
70
69
|
/** Offline-test seam; production uses Runtime's Router HTTP transport. */
|
|
71
70
|
complete?: AppWorldComplete;
|
|
72
71
|
}): unknown;
|
|
73
|
-
declare function createAppWorldReactAdapter(): BenchmarkAdapter;
|
|
74
|
-
|
|
75
|
-
export { ReactResult, appworldReactResultWithUsage, appworldReactUsageEvent, appworldSolutionOutput, appworldToolLoopClient, createAppWorldAdapter, createAppWorldReactAdapter };
|
|
72
|
+
export declare function createAppWorldReactAdapter(): BenchmarkAdapter;
|
|
73
|
+
export {};
|
|
76
74
|
//# sourceMappingURL=appworld.d.ts.map
|
|
@@ -3,7 +3,7 @@ import { join } from "node:path";
|
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { createInterface } from "node:readline";
|
|
5
5
|
import { collectAgentTurn, createExecutor, streamAgentTurn } from "@tangle-network/agent-runtime/kernel";
|
|
6
|
-
|
|
6
|
+
// src/benchmarks/appworld.ts
|
|
7
7
|
/**
|
|
8
8
|
* AppWorld adapter (StonyBrookNLP/appworld). Worker artifact = the agent's
|
|
9
9
|
* Python solution that calls the simulated apps' APIs (the same `apis.<app>.<fn>`
|
|
@@ -286,29 +286,30 @@ function appworldToolLoopClient(cfg) {
|
|
|
286
286
|
prompt: { systemPrompt: system },
|
|
287
287
|
tools: { execute_python: true }
|
|
288
288
|
};
|
|
289
|
+
const factory = createExecutor({
|
|
290
|
+
backend: "router-tools",
|
|
291
|
+
routerBaseUrl: cfg.routerBaseUrl,
|
|
292
|
+
routerKey: cfg.routerKey,
|
|
293
|
+
...cfg.complete ? { complete: cfg.complete } : {},
|
|
294
|
+
tools: [EXECUTE_TOOL],
|
|
295
|
+
executeToolCall: async (name, args) => {
|
|
296
|
+
if (name !== "execute_python") return `error: unknown tool ${name}`;
|
|
297
|
+
const res = await call({
|
|
298
|
+
op: "execute",
|
|
299
|
+
code: String(args.code ?? "")
|
|
300
|
+
});
|
|
301
|
+
const done = res.task_completed === true;
|
|
302
|
+
const result = `${String(res.output ?? "")}${done ? "\n\n[TASK MARKED COMPLETE — reply with a final summary and do not call the tool again]" : ""}`;
|
|
303
|
+
transcriptSteps.push({
|
|
304
|
+
args: JSON.stringify(args),
|
|
305
|
+
result
|
|
306
|
+
});
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
309
|
+
});
|
|
289
310
|
const loop = await collectAgentTurn(streamAgentTurn({
|
|
290
311
|
kind: "executor",
|
|
291
|
-
factory
|
|
292
|
-
backend: "router-tools",
|
|
293
|
-
routerBaseUrl: cfg.routerBaseUrl,
|
|
294
|
-
routerKey: cfg.routerKey,
|
|
295
|
-
...cfg.complete ? { complete: cfg.complete } : {},
|
|
296
|
-
tools: [EXECUTE_TOOL],
|
|
297
|
-
executeToolCall: async (name, args) => {
|
|
298
|
-
if (name !== "execute_python") return `error: unknown tool ${name}`;
|
|
299
|
-
const res = await call({
|
|
300
|
-
op: "execute",
|
|
301
|
-
code: String(args.code ?? "")
|
|
302
|
-
});
|
|
303
|
-
const done = res.task_completed === true;
|
|
304
|
-
const result = `${String(res.output ?? "")}${done ? "\n\n[TASK MARKED COMPLETE — reply with a final summary and do not call the tool again]" : ""}`;
|
|
305
|
-
transcriptSteps.push({
|
|
306
|
-
args: JSON.stringify(args),
|
|
307
|
-
result
|
|
308
|
-
});
|
|
309
|
-
return result;
|
|
310
|
-
}
|
|
311
|
-
}),
|
|
312
|
+
factory,
|
|
312
313
|
profile
|
|
313
314
|
}, { prompt: `Task: ${instruction}` }, { signal }));
|
|
314
315
|
if (loop.status !== "completed") throw new Error(loop.error?.message ?? `AppWorld turn ended with ${loop.status}`);
|
|
@@ -384,7 +385,6 @@ function createAppWorldReactAdapter() {
|
|
|
384
385
|
leafClient: (c) => appworldToolLoopClient(c)
|
|
385
386
|
};
|
|
386
387
|
}
|
|
387
|
-
//#endregion
|
|
388
388
|
export { appworldReactResultWithUsage, appworldReactUsageEvent, appworldSolutionOutput, appworldToolLoopClient, createAppWorldAdapter, createAppWorldReactAdapter };
|
|
389
389
|
|
|
390
390
|
//# sourceMappingURL=appworld.js.map
|