@tangle-network/agent-bench 4.0.0 → 4.0.3
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 +21 -0
- package/HARNESS.md +2 -0
- package/dist/benchmarks/terminal-bench.js +15 -5
- package/dist/benchmarks/terminal-bench.js.map +1 -1
- package/dist/cli.js +44 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/pier-trial-supervisor.mjs +352 -0
- package/package.json +3 -3
- package/scripts/verify-packed-consumer.mjs +2 -1
- package/scripts/verify-pier-agent.mts +34 -100
- package/src/benchmarks/terminal-bench.ts +39 -6
- package/src/pier-agent.ts +19 -1
- package/src/published.test.mts +29 -6
- package/src/published.ts +53 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.0.3
|
|
4
|
+
|
|
5
|
+
Terminal-Bench leaves interrupted verifiers unscored. Set
|
|
6
|
+
`TERMINAL_BENCH_EVIDENCE_DIR` to an absolute directory to retain the verifier
|
|
7
|
+
files, including output from interrupted runs. Completed verifiers still
|
|
8
|
+
supply the official pass or fail result.
|
|
9
|
+
|
|
10
|
+
## 4.0.2
|
|
11
|
+
|
|
12
|
+
The installed package includes the trial supervisor beside the code that
|
|
13
|
+
launches it, so an installed Factory CLI can start and settle a Pier trial.
|
|
14
|
+
|
|
15
|
+
## 4.0.1
|
|
16
|
+
|
|
17
|
+
The shared Pier executor now records the protected terminal trace required
|
|
18
|
+
for Runtime grading. The receipt keeps the actual trial interval, and
|
|
19
|
+
Runtime retains ownership of model accounting.
|
|
20
|
+
|
|
21
|
+
Published benchmark run records retain the publisher's reported usage when
|
|
22
|
+
the execution supplies it.
|
|
23
|
+
|
|
3
24
|
## 4.0.0
|
|
4
25
|
|
|
5
26
|
Bench's public candidate-execution types move to Runtime 11. Consumers that
|
package/HARNESS.md
CHANGED
|
@@ -61,6 +61,8 @@ pnpm run run-benchmarks
|
|
|
61
61
|
|
|
62
62
|
`src/run-benchmarks-cli.mts` runs a selected subset of registered adapters across explicit agent cells. Each adapter owns task loading, output extraction, preflight, and judging. A missing dependency or failed gold self-check makes the benchmark unavailable; it never becomes a zero score.
|
|
63
63
|
|
|
64
|
+
Set `TERMINAL_BENCH_EVIDENCE_DIR` to an absolute directory to retain each Terminal-Bench verifier run and process output, including runs that stopped without a verdict.
|
|
65
|
+
|
|
64
66
|
Use `LOOP_ATTEMPTS=N` only when the benchmark's own visible feedback is allowed to enter later attempts. Hidden or gold material must remain outside the agent context.
|
|
65
67
|
|
|
66
68
|
`runBenchmarks()` returns each judged artifact, worker events, and observed usage in `perTask`.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { benchRoot, preflightVenvImports, readJsonReport, runStagedJudge, runVenvPython, safeRunId, stageFile, venvBinAt, venvPythonAt } from "./_harness.js";
|
|
2
2
|
import { runtimeBenchmark } from "./types.js";
|
|
3
|
-
import { join } from "node:path";
|
|
3
|
+
import { isAbsolute, join } from "node:path";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
4
5
|
// src/benchmarks/terminal-bench.ts
|
|
5
6
|
/**
|
|
6
7
|
* Terminal-Bench adapter. Each task = a Docker environment + an English
|
|
@@ -86,11 +87,14 @@ function createTerminalBenchAdapter() {
|
|
|
86
87
|
}));
|
|
87
88
|
},
|
|
88
89
|
async evaluate(task, artifact) {
|
|
89
|
-
const runId = safeRunId("bench", `${task.id}-${
|
|
90
|
+
const runId = safeRunId("bench", `${task.id}-${randomUUID()}`);
|
|
91
|
+
const evidenceRoot = process.env.TERMINAL_BENCH_EVIDENCE_DIR;
|
|
92
|
+
if (evidenceRoot && !isAbsolute(evidenceRoot)) throw new Error("TERMINAL_BENCH_EVIDENCE_DIR must be an absolute path");
|
|
90
93
|
return runStagedJudge({
|
|
91
94
|
tmpPrefix: "tbench-",
|
|
92
95
|
bin: terminalBenchBin(),
|
|
93
96
|
cwd: () => benchRoot,
|
|
97
|
+
...evidenceRoot && { capture: { destination: join(evidenceRoot, runId) } },
|
|
94
98
|
async stage(dir) {
|
|
95
99
|
await stageFile(join(dir, "attempt.sh"), artifact);
|
|
96
100
|
},
|
|
@@ -115,12 +119,18 @@ function createTerminalBenchAdapter() {
|
|
|
115
119
|
],
|
|
116
120
|
async parseReport(dir) {
|
|
117
121
|
const report = await readJsonReport(join(dir, "runs", runId, "results.json"));
|
|
118
|
-
const
|
|
119
|
-
const trial =
|
|
122
|
+
const trials = report?.results;
|
|
123
|
+
const trial = trials?.[0];
|
|
124
|
+
if (!Array.isArray(trials) || trials.length !== 1 || trial?.task_id !== task.id) throw new Error(`terminal-bench: report has no unique trial for ${task.id}`);
|
|
125
|
+
const checks = trial.parser_results;
|
|
126
|
+
if (typeof trial.is_resolved !== "boolean" || !checks || Array.isArray(checks) || typeof checks !== "object" || Object.keys(checks).length === 0) throw new Error(`terminal-bench: no verifier verdict for ${task.id} (${trial.failure_mode ?? "unknown"})`);
|
|
127
|
+
const resolved = trial.is_resolved;
|
|
128
|
+
const statuses = Object.values(checks);
|
|
129
|
+
if (statuses.some((status) => status !== "passed" && status !== "failed") || statuses.every((status) => status === "passed") !== resolved || !Array.isArray(report.resolved_ids) || report.resolved_ids.length !== Number(resolved) || report.resolved_ids.includes(task.id) !== resolved) throw new Error(`terminal-bench: report outcome disagrees with trial ${task.id}`);
|
|
120
130
|
return {
|
|
121
131
|
passed: resolved,
|
|
122
132
|
score: resolved ? 1 : 0,
|
|
123
|
-
notes: JSON.stringify(
|
|
133
|
+
notes: JSON.stringify(checks),
|
|
124
134
|
raw: {}
|
|
125
135
|
};
|
|
126
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-bench.js","names":[],"sources":["../../src/benchmarks/terminal-bench.ts"],"sourcesContent":["/**\n * Terminal-Bench adapter. Each task = a Docker environment + an English\n * instruction + a per-task verifier (run-tests.sh + pytest). The worker artifact\n * is the shell script the agent ran to attempt the task; the judge REPLAYS that\n * script in a fresh task container via the Terminal-Bench harness (`tb run` with\n * our ScriptAgent), then the task's own verifier scores the resulting state.\n * Fully deterministic — no LLM judge, no self-authored score.\n *\n * Requires: an isolated bench `.venv-terminal-bench` with `terminal-bench`\n * installed + a running Docker daemon (per-task images are built on first run).\n * Override with TERMINAL_BENCH_VENV. loadAll caches the dataset from the\n * Terminal-Bench registry on first run.\n *\n * Process/Docker/report plumbing is shared via ./_harness; this file owns the\n * Terminal-Bench-specific pieces: the Dataset enumeration, the ScriptAgent replay\n * argv, and the results.json shape.\n */\n\nimport { join } from 'node:path'\nimport {\n benchRoot,\n preflightVenvImports,\n readJsonReport,\n runStagedJudge,\n runVenvPython,\n safeRunId,\n stageFile,\n venvBinAt,\n venvPythonAt,\n} from './_harness'\nimport { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'\n\n// Terminal-Bench imports LiteLLM/Pydantic-2 APIs, while AppWorld pins Pydantic 1.\n// Keep it out of the shared bench .venv. Resolved at call-time so tests/runs can\n// override the env without reloading this module.\nconst terminalBenchVenvDir = (): string => process.env.TERMINAL_BENCH_VENV ?? '.venv-terminal-bench'\nconst terminalBenchPython = (): string => venvPythonAt(terminalBenchVenvDir())\nconst terminalBenchBin = (): string => venvBinAt(terminalBenchVenvDir(), 'tb')\n\n// Pinned dataset: the 0.1.1 core set is patched for terminal-bench >=0.2.4 (the\n// installed CLI) and is the published launch task set. name==version is what `tb\n// run -d` and `tb datasets download -d` both accept.\nconst DATASET = 'terminal-bench-core'\nconst DATASET_VERSION = '0.1.1'\nconst DATASET_REF = `${DATASET}==${DATASET_VERSION}`\n\n// Bundled fixture: when no ids/limit are given, load these. hello-world is the\n// fastest deterministic task (prebuilt python image, file-write verifier) so the\n// adapter is runnable without a large pull.\nconst FIXTURE_IDS = ['hello-world']\n\n// Import path the harness uses to load our replay agent (cwd = benchRoot).\nconst SCRIPT_AGENT = 'tb_agents.script_agent:ScriptAgent'\n\ninterface TbTaskRow {\n id: string\n instruction: string\n task_dir: string\n solution: string | null\n}\n\ninterface TbReport {\n resolved_ids?: string[]\n results?: Array<{ task_id: string; is_resolved: boolean | null; parser_results?: unknown }>\n}\n\n/** Enumerate dataset tasks via tb's Dataset loader (caches from the registry on\n * first run). Reads instruction from each task.yaml and the gold solution. */\nasync function loadRows(opts: LoadOptions): Promise<TbTaskRow[]> {\n const ids = opts.ids ?? (opts.limit ? null : FIXTURE_IDS)\n const limit = opts.limit ?? null\n const script = `\nimport json, sys\nfrom pathlib import Path\nfrom terminal_bench.dataset.dataset import Dataset\nfrom terminal_bench.handlers.trial_handler import TaskPaths\n\nreq_ids = json.loads(sys.argv[1]) if sys.argv[1] else None\nlimit = json.loads(sys.argv[2]) if sys.argv[2] else None\n\nds = Dataset(name=${JSON.stringify(DATASET)}, version=${JSON.stringify(DATASET_VERSION)}, task_ids=req_ids, n_tasks=limit)\n\nimport yaml\nout = []\nfor task_dir in ds:\n tp = TaskPaths(task_dir)\n cfg = yaml.safe_load(tp.task_config_path.read_text())\n try:\n sol = tp.solution_path.read_text()\n except FileNotFoundError:\n sol = None\n out.append({\n \"id\": task_dir.name,\n \"instruction\": cfg[\"instruction\"],\n \"task_dir\": str(task_dir),\n \"solution\": sol if (tp.solution_path.suffix == \".sh\" if sol is not None else False) else None,\n })\nprint(json.dumps(out))\n`\n const stdout = await runVenvPython(\n script,\n [ids ? JSON.stringify(ids) : '', limit !== null ? String(limit) : ''],\n 0,\n terminalBenchPython(),\n )\n return JSON.parse(stdout) as TbTaskRow[]\n}\n\nexport function createTerminalBenchAdapter(): RuntimeBenchmark {\n return runtimeBenchmark({\n id: 'terminal-bench',\n\n async loadAll(opts: LoadOptions = {}) {\n const rows = await loadRows(opts)\n if (rows.length === 0) {\n throw new Error(\n `terminal-bench loadAll returned no tasks for ${JSON.stringify(opts)} ` +\n `(dataset ${DATASET_REF}). Check the requested ids exist in the dataset.`,\n )\n }\n return rows.map(\n (r): BenchTask => ({\n id: r.id,\n payload: {\n subset: DATASET_VERSION,\n prompt: r.instruction,\n },\n metadata: {\n dataset: DATASET,\n datasetVersion: DATASET_VERSION,\n datasetRef: DATASET_REF,\n taskDir: r.task_dir,\n solution: r.solution,\n instruction: r.instruction,\n },\n }),\n )\n },\n\n async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {\n const runId = safeRunId('bench', `${task.id}-${Date.now()}`)\n return runStagedJudge({\n tmpPrefix: 'tbench-',\n bin: terminalBenchBin(),\n cwd: () => benchRoot,\n async stage(dir) {\n await stageFile(join(dir, 'attempt.sh'), artifact)\n },\n // The harness builds a fresh task container, runs ScriptAgent (which replays\n // the artifact script), then runs the task's verifier. --no-livestream keeps\n // stdout sane; --cleanup removes the per-run images.\n argv: (dir) => [\n 'run',\n '-d', DATASET_REF,\n '-t', task.id,\n '--agent-import-path', SCRIPT_AGENT,\n '--agent-kwarg', `script_path=${join(dir, 'attempt.sh')}`,\n '--output-path', join(dir, 'runs'),\n '--run-id', runId,\n '--n-concurrent', '1',\n '--no-livestream',\n '--cleanup',\n ],\n async parseReport(dir) {\n const report = await readJsonReport<TbReport>(join(dir, 'runs', runId, 'results.json'))\n const resolved = (report.resolved_ids ?? []).includes(task.id)\n const trial = report.results?.find((r) => r.task_id === task.id)\n return {\n passed: resolved,\n score: resolved ? 1 : 0,\n notes: JSON.stringify(trial?.parser_results ?? report.resolved_ids ?? {}),\n raw: {},\n }\n },\n })\n },\n\n runtime: {\n async preflight() {\n await preflightVenvImports({\n modules: ['terminal_bench'],\n requireDocker: true,\n python: terminalBenchPython(),\n fix:\n `Fix: (1) python3 -m venv bench/${terminalBenchVenvDir()} && ` +\n `bench/${terminalBenchVenvDir()}/bin/pip install terminal-bench ` +\n `(an ISOLATED venv — Terminal-Bench/LiteLLM require Pydantic 2 while AppWorld pins Pydantic 1; ` +\n `override the dir with TERMINAL_BENCH_VENV) ; ` +\n `(2) ensure the Docker daemon is running (the judge builds per-task images on first run). ` +\n `The ${DATASET_REF} dataset is cached from the Terminal-Bench registry on first loadAll.`,\n })\n },\n\n async goldArtifact(task: BenchTask) {\n // Gold = the task's solution.sh (the oracle script). solution.yaml tasks have\n // no shell-script artifact form here, so they return undefined (cannot be\n // verify-judged via the script-replay seam — use a .sh-solution task).\n const sol = task.metadata?.solution\n return typeof sol === 'string' ? sol : undefined\n },\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,6BAAqC,QAAQ,IAAI,uBAAuB;AAC9E,MAAM,4BAAoC,aAAa,qBAAqB,CAAC;AAC7E,MAAM,yBAAiC,UAAU,qBAAqB,GAAG,IAAI;AAK7E,MAAM,UAAU;AAChB,MAAM,kBAAkB;AACxB,MAAM,cAAc,GAAG,QAAQ,IAAI;AAKnC,MAAM,cAAc,CAAC,aAAa;AAGlC,MAAM,eAAe;;;AAgBrB,eAAe,SAAS,MAAyC;CAC/D,MAAM,MAAM,KAAK,QAAQ,KAAK,QAAQ,OAAO;CAC7C,MAAM,QAAQ,KAAK,SAAS;CAC5B,MAAM,SAAS;;;;;;;;;oBASG,KAAK,UAAU,OAAO,EAAE,YAAY,KAAK,UAAU,eAAe,EAAE;;;;;;;;;;;;;;;;;;;CAmBtF,MAAM,SAAS,MAAM,cACnB,QACA,CAAC,MAAM,KAAK,UAAU,GAAG,IAAI,IAAI,UAAU,OAAO,OAAO,KAAK,IAAI,EAAE,GACpE,GACA,oBAAoB,CACtB;CACA,OAAO,KAAK,MAAM,MAAM;AAC1B;AAEA,SAAgB,6BAA+C;CAC7D,OAAO,iBAAiB;EACtB,IAAI;EAEJ,MAAM,QAAQ,OAAoB,CAAC,GAAG;GACpC,MAAM,OAAO,MAAM,SAAS,IAAI;GAChC,IAAI,KAAK,WAAW,GAClB,MAAM,IAAI,MACR,gDAAgD,KAAK,UAAU,IAAI,EAAE,YACvD,YAAY,iDAC5B;GAEF,OAAO,KAAK,KACT,OAAkB;IACjB,I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AU;IAC3B,OAAO,OAAO,QAAQ,WAAW,MAAM,KAAA;GACzC;EACF;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"terminal-bench.js","names":[],"sources":["../../src/benchmarks/terminal-bench.ts"],"sourcesContent":["/**\n * Terminal-Bench adapter. Each task = a Docker environment + an English\n * instruction + a per-task verifier (run-tests.sh + pytest). The worker artifact\n * is the shell script the agent ran to attempt the task; the judge REPLAYS that\n * script in a fresh task container via the Terminal-Bench harness (`tb run` with\n * our ScriptAgent), then the task's own verifier scores the resulting state.\n * Fully deterministic — no LLM judge, no self-authored score.\n *\n * Requires: an isolated bench `.venv-terminal-bench` with `terminal-bench`\n * installed + a running Docker daemon (per-task images are built on first run).\n * Override with TERMINAL_BENCH_VENV. loadAll caches the dataset from the\n * Terminal-Bench registry on first run.\n *\n * Process/Docker/report plumbing is shared via ./_harness; this file owns the\n * Terminal-Bench-specific pieces: the Dataset enumeration, the ScriptAgent replay\n * argv, and the results.json shape.\n */\n\nimport { randomUUID } from 'node:crypto'\nimport { isAbsolute, join } from 'node:path'\nimport {\n benchRoot,\n preflightVenvImports,\n readJsonReport,\n runStagedJudge,\n runVenvPython,\n safeRunId,\n stageFile,\n venvBinAt,\n venvPythonAt,\n} from './_harness'\nimport { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'\n\n// Terminal-Bench imports LiteLLM/Pydantic-2 APIs, while AppWorld pins Pydantic 1.\n// Keep it out of the shared bench .venv. Resolved at call-time so tests/runs can\n// override the env without reloading this module.\nconst terminalBenchVenvDir = (): string => process.env.TERMINAL_BENCH_VENV ?? '.venv-terminal-bench'\nconst terminalBenchPython = (): string => venvPythonAt(terminalBenchVenvDir())\nconst terminalBenchBin = (): string => venvBinAt(terminalBenchVenvDir(), 'tb')\n\n// Pinned dataset: the 0.1.1 core set is patched for terminal-bench >=0.2.4 (the\n// installed CLI) and is the published launch task set. name==version is what `tb\n// run -d` and `tb datasets download -d` both accept.\nconst DATASET = 'terminal-bench-core'\nconst DATASET_VERSION = '0.1.1'\nconst DATASET_REF = `${DATASET}==${DATASET_VERSION}`\n\n// Bundled fixture: when no ids/limit are given, load these. hello-world is the\n// fastest deterministic task (prebuilt python image, file-write verifier) so the\n// adapter is runnable without a large pull.\nconst FIXTURE_IDS = ['hello-world']\n\n// Import path the harness uses to load our replay agent (cwd = benchRoot).\nconst SCRIPT_AGENT = 'tb_agents.script_agent:ScriptAgent'\n\ninterface TbTaskRow {\n id: string\n instruction: string\n task_dir: string\n solution: string | null\n}\n\ninterface TbReport {\n resolved_ids?: string[]\n results?: Array<{\n task_id: string\n is_resolved: boolean | null\n failure_mode?: string\n parser_results?: Record<string, string> | null\n }>\n}\n\n/** Enumerate dataset tasks via tb's Dataset loader (caches from the registry on\n * first run). Reads instruction from each task.yaml and the gold solution. */\nasync function loadRows(opts: LoadOptions): Promise<TbTaskRow[]> {\n const ids = opts.ids ?? (opts.limit ? null : FIXTURE_IDS)\n const limit = opts.limit ?? null\n const script = `\nimport json, sys\nfrom pathlib import Path\nfrom terminal_bench.dataset.dataset import Dataset\nfrom terminal_bench.handlers.trial_handler import TaskPaths\n\nreq_ids = json.loads(sys.argv[1]) if sys.argv[1] else None\nlimit = json.loads(sys.argv[2]) if sys.argv[2] else None\n\nds = Dataset(name=${JSON.stringify(DATASET)}, version=${JSON.stringify(DATASET_VERSION)}, task_ids=req_ids, n_tasks=limit)\n\nimport yaml\nout = []\nfor task_dir in ds:\n tp = TaskPaths(task_dir)\n cfg = yaml.safe_load(tp.task_config_path.read_text())\n try:\n sol = tp.solution_path.read_text()\n except FileNotFoundError:\n sol = None\n out.append({\n \"id\": task_dir.name,\n \"instruction\": cfg[\"instruction\"],\n \"task_dir\": str(task_dir),\n \"solution\": sol if (tp.solution_path.suffix == \".sh\" if sol is not None else False) else None,\n })\nprint(json.dumps(out))\n`\n const stdout = await runVenvPython(\n script,\n [ids ? JSON.stringify(ids) : '', limit !== null ? String(limit) : ''],\n 0,\n terminalBenchPython(),\n )\n return JSON.parse(stdout) as TbTaskRow[]\n}\n\nexport function createTerminalBenchAdapter(): RuntimeBenchmark {\n return runtimeBenchmark({\n id: 'terminal-bench',\n\n async loadAll(opts: LoadOptions = {}) {\n const rows = await loadRows(opts)\n if (rows.length === 0) {\n throw new Error(\n `terminal-bench loadAll returned no tasks for ${JSON.stringify(opts)} ` +\n `(dataset ${DATASET_REF}). Check the requested ids exist in the dataset.`,\n )\n }\n return rows.map(\n (r): BenchTask => ({\n id: r.id,\n payload: {\n subset: DATASET_VERSION,\n prompt: r.instruction,\n },\n metadata: {\n dataset: DATASET,\n datasetVersion: DATASET_VERSION,\n datasetRef: DATASET_REF,\n taskDir: r.task_dir,\n solution: r.solution,\n instruction: r.instruction,\n },\n }),\n )\n },\n\n async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {\n const runId = safeRunId('bench', `${task.id}-${randomUUID()}`)\n const evidenceRoot = process.env.TERMINAL_BENCH_EVIDENCE_DIR\n if (evidenceRoot && !isAbsolute(evidenceRoot)) {\n throw new Error('TERMINAL_BENCH_EVIDENCE_DIR must be an absolute path')\n }\n return runStagedJudge({\n tmpPrefix: 'tbench-',\n bin: terminalBenchBin(),\n cwd: () => benchRoot,\n ...(evidenceRoot && { capture: { destination: join(evidenceRoot, runId) } }),\n async stage(dir) {\n await stageFile(join(dir, 'attempt.sh'), artifact)\n },\n // The harness builds a fresh task container, runs ScriptAgent (which replays\n // the artifact script), then runs the task's verifier. --no-livestream keeps\n // stdout sane; --cleanup removes the per-run images.\n argv: (dir) => [\n 'run',\n '-d', DATASET_REF,\n '-t', task.id,\n '--agent-import-path', SCRIPT_AGENT,\n '--agent-kwarg', `script_path=${join(dir, 'attempt.sh')}`,\n '--output-path', join(dir, 'runs'),\n '--run-id', runId,\n '--n-concurrent', '1',\n '--no-livestream',\n '--cleanup',\n ],\n async parseReport(dir) {\n const report = await readJsonReport<TbReport>(join(dir, 'runs', runId, 'results.json'))\n const trials = report?.results\n const trial = trials?.[0]\n if (!Array.isArray(trials) || trials.length !== 1 || trial?.task_id !== task.id) {\n throw new Error(`terminal-bench: report has no unique trial for ${task.id}`)\n }\n const checks = trial.parser_results\n if (\n typeof trial.is_resolved !== 'boolean' ||\n !checks || Array.isArray(checks) || typeof checks !== 'object' ||\n Object.keys(checks).length === 0\n ) {\n throw new Error(`terminal-bench: no verifier verdict for ${task.id} (${trial.failure_mode ?? 'unknown'})`)\n }\n const resolved = trial.is_resolved\n const statuses = Object.values(checks)\n if (\n statuses.some((status) => status !== 'passed' && status !== 'failed') ||\n statuses.every((status) => status === 'passed') !== resolved ||\n !Array.isArray(report.resolved_ids) ||\n report.resolved_ids.length !== Number(resolved) ||\n report.resolved_ids.includes(task.id) !== resolved\n ) {\n throw new Error(`terminal-bench: report outcome disagrees with trial ${task.id}`)\n }\n return {\n passed: resolved,\n score: resolved ? 1 : 0,\n notes: JSON.stringify(checks),\n raw: {},\n }\n },\n })\n },\n\n runtime: {\n async preflight() {\n await preflightVenvImports({\n modules: ['terminal_bench'],\n requireDocker: true,\n python: terminalBenchPython(),\n fix:\n `Fix: (1) python3 -m venv bench/${terminalBenchVenvDir()} && ` +\n `bench/${terminalBenchVenvDir()}/bin/pip install terminal-bench ` +\n `(an ISOLATED venv — Terminal-Bench/LiteLLM require Pydantic 2 while AppWorld pins Pydantic 1; ` +\n `override the dir with TERMINAL_BENCH_VENV) ; ` +\n `(2) ensure the Docker daemon is running (the judge builds per-task images on first run). ` +\n `The ${DATASET_REF} dataset is cached from the Terminal-Bench registry on first loadAll.`,\n })\n },\n\n async goldArtifact(task: BenchTask) {\n // Gold = the task's solution.sh (the oracle script). solution.yaml tasks have\n // no shell-script artifact form here, so they return undefined (cannot be\n // verify-judged via the script-replay seam — use a .sh-solution task).\n const sol = task.metadata?.solution\n return typeof sol === 'string' ? sol : undefined\n },\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,6BAAqC,QAAQ,IAAI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,MAAM,uDAAuD,KAAK,IAAI;KAElF,OAAO;MACL,QAAQ;MACR,OAAO,WAAW,IAAI;MACtB,OAAO,KAAK,UAAU,MAAM;MAC5B,KAAK,CAAC;KACR;IACF;GACF,CAAC;EACH;EAEA,SAAS;GACP,MAAM,YAAY;IAChB,MAAM,qBAAqB;KACzB,SAAS,CAAC,gBAAgB;KAC1B,eAAe;KACf,QAAQ,oBAAoB;KAC5B,KACE,kCAAkC,qBAAqB,EAAE,YAChD,qBAAqB,EAAE,0QAIzB,YAAY;IACvB,CAAC;GACH;GAEA,MAAM,aAAa,MAAiB;IAIlC,MAAM,MAAM,KAAK,UAAU;IAC3B,OAAO,OAAO,QAAQ,WAAW,MAAM,KAAA;GACzC;EACF;CACF,CAAC;AACH"}
|
package/dist/cli.js
CHANGED
|
@@ -46,6 +46,12 @@ function agentApps(env) {
|
|
|
46
46
|
...Object.fromEntries(Object.entries(extra).map(([name, profileUrl]) => [name, { profileUrl }]))
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
+
function nonnegativeCounter(value) {
|
|
50
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
|
|
51
|
+
}
|
|
52
|
+
function nonnegativeMeasurement(value) {
|
|
53
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
54
|
+
}
|
|
49
55
|
const PUBLISHED_BENCHMARKS = {
|
|
50
56
|
automationbench: {
|
|
51
57
|
name: "automationbench",
|
|
@@ -84,10 +90,25 @@ const PUBLISHED_BENCHMARKS = {
|
|
|
84
90
|
if (!Array.isArray(tasks)) throw new Error("AutomationBench result has no tasks array");
|
|
85
91
|
return tasks.map((task) => {
|
|
86
92
|
if (typeof task.name !== "string" || typeof task.score !== "number" || typeof task.passed !== "boolean") throw new Error(`AutomationBench task result is malformed: ${JSON.stringify(task).slice(0, 200)}`);
|
|
93
|
+
const raw = {};
|
|
94
|
+
const counters = {
|
|
95
|
+
publisherInputTokens: task.input_tokens,
|
|
96
|
+
publisherOutputTokens: task.output_tokens,
|
|
97
|
+
publisherCachedInputTokens: task.cached_input_tokens,
|
|
98
|
+
publisherReasoningTokens: task.reasoning_tokens,
|
|
99
|
+
publisherModelCalls: task.num_model_calls
|
|
100
|
+
};
|
|
101
|
+
for (const [key, counter] of Object.entries(counters)) {
|
|
102
|
+
const value = nonnegativeCounter(counter);
|
|
103
|
+
if (value !== void 0) raw[key] = value;
|
|
104
|
+
}
|
|
105
|
+
const estimate = nonnegativeMeasurement(task.cost);
|
|
106
|
+
if (estimate !== void 0) raw.publisherEstimatedCostUsd = estimate;
|
|
87
107
|
return {
|
|
88
108
|
id: task.name,
|
|
89
109
|
passed: task.passed,
|
|
90
|
-
score: task.score
|
|
110
|
+
score: task.score,
|
|
111
|
+
...Object.keys(raw).length && { raw }
|
|
91
112
|
};
|
|
92
113
|
});
|
|
93
114
|
}
|
|
@@ -182,12 +203,26 @@ const PUBLISHED_BENCHMARKS = {
|
|
|
182
203
|
const runs = (await readFile(path.join(resultPath, "tasks.tsv"), "utf8")).trim().split("\n").map((line) => line.split(" "));
|
|
183
204
|
return Promise.all(runs.map(async ([run, task]) => {
|
|
184
205
|
const read = (file) => readFile(path.join(resultPath, run, file), "utf8").then((text) => JSON.parse(text), () => null);
|
|
206
|
+
const metrics = await read("metrics.json");
|
|
207
|
+
const input = nonnegativeCounter(metrics?.input_tokens);
|
|
208
|
+
const output = nonnegativeCounter(metrics?.output_tokens);
|
|
209
|
+
const agentSeconds = nonnegativeMeasurement(metrics?.wall_clock_seconds);
|
|
210
|
+
const raw = agentSeconds === void 0 ? void 0 : { publisherAgentWallMs: agentSeconds * 1e3 };
|
|
211
|
+
const telemetry = {
|
|
212
|
+
...raw && { raw },
|
|
213
|
+
...input !== void 0 && output !== void 0 && { tokenUsage: {
|
|
214
|
+
input,
|
|
215
|
+
output,
|
|
216
|
+
tokensKnown: false
|
|
217
|
+
} }
|
|
218
|
+
};
|
|
185
219
|
const dual = await read("scores_dual.json");
|
|
186
220
|
if (dual) return {
|
|
187
221
|
id: task,
|
|
188
222
|
passed: dual.all_pass === true,
|
|
189
223
|
score: Number(dual.dual_all_pass_rate),
|
|
190
|
-
notes: `dual-judge criterion pass ${String(dual.dual_criterion_pass)}
|
|
224
|
+
notes: `dual-judge criterion pass ${String(dual.dual_criterion_pass)}`,
|
|
225
|
+
...telemetry
|
|
191
226
|
};
|
|
192
227
|
const single = await read("scores.json");
|
|
193
228
|
if (single) {
|
|
@@ -197,7 +232,9 @@ const PUBLISHED_BENCHMARKS = {
|
|
|
197
232
|
passed: single.all_pass === true,
|
|
198
233
|
score: single.all_pass === true ? 1 : 0,
|
|
199
234
|
notes: `${String(single.n_passed)} of ${String(single.n_criteria)} criteria passed${single.n_grading_errors ? `; ${String(single.n_grading_errors)} grading errors` : ""}`,
|
|
235
|
+
...telemetry,
|
|
200
236
|
raw: {
|
|
237
|
+
...raw,
|
|
201
238
|
criteria_passed: Number(single.n_passed) || 0,
|
|
202
239
|
criteria_total: Number(single.n_criteria) || 0,
|
|
203
240
|
...Object.fromEntries(criteria.filter((c) => typeof c.id === "string").map((c) => [`crit.${String(c.id)}`, c.verdict === "pass" ? 1 : 0]))
|
|
@@ -208,7 +245,8 @@ const PUBLISHED_BENCHMARKS = {
|
|
|
208
245
|
id: task,
|
|
209
246
|
passed: false,
|
|
210
247
|
score: 0,
|
|
211
|
-
notes: "no scores: the harness or the grader failed (see the runner log)"
|
|
248
|
+
notes: "no scores: the harness or the grader failed (see the runner log)",
|
|
249
|
+
...telemetry
|
|
212
250
|
};
|
|
213
251
|
}));
|
|
214
252
|
}
|
|
@@ -501,8 +539,8 @@ async function runPublished(name, target, options) {
|
|
|
501
539
|
return run;
|
|
502
540
|
}
|
|
503
541
|
/**
|
|
504
|
-
* One agent-eval RunRecord per task, validated by agent-eval's own validator.
|
|
505
|
-
*
|
|
542
|
+
* One agent-eval RunRecord per task, validated by agent-eval's own validator. Preserve an observed publisher subtotal
|
|
543
|
+
* and leave missing provider bills unknown. A RunRecord's model must name a served snapshot; a subscription harness
|
|
506
544
|
* reports none, and a snapshot invented from the date would be false, so such rows record `unknown` with terminal outcome
|
|
507
545
|
* `unknown` and keep the requested model in `candidateId`. A pinned model id (a Router snapshot) is recorded as served.
|
|
508
546
|
*/
|
|
@@ -532,7 +570,7 @@ function runRecords(run, options) {
|
|
|
532
570
|
kind: "uncaptured",
|
|
533
571
|
usd: null
|
|
534
572
|
},
|
|
535
|
-
tokenUsage: {
|
|
573
|
+
tokenUsage: task.tokenUsage ?? {
|
|
536
574
|
input: 0,
|
|
537
575
|
output: 0,
|
|
538
576
|
tokensKnown: false
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/published.ts","../src/cli.ts"],"sourcesContent":["/**\n * Published benchmarks, run by their publishers' own runners, unmodified, at a pinned commit.\n *\n * One registry entry per benchmark: the publisher's repository and commit, its install and run commands, a parser from the\n * publisher's result file to per-task scores (agent-eval's verdict names: `passed`, `score`, `notes`), the license, the data terms, and the judge the publisher names. Nothing here loads\n * tasks, drives an agent loop, or grades: the publisher's runner does all three. A target becomes the OpenAI-compatible\n * endpoint that runner calls:\n *\n * model:<router model> the Tangle Router with `TANGLE_API_KEY`; the target is a model driving the benchmark's tools.\n * profile:<harness/model> a CLI Bridge (`AGENT_BENCH_BRIDGE_URL`, default http://127.0.0.1:3344/v1) running that harness with\n * its own loop and tools; the benchmark's tools reach it as caller-executed MCP tools (cli-bridge#397).\n * app:<agent app>@<harness/model>\n * the AgentProfile the app serves in production (prompt, skills, subagents, resources), run by\n * that subscription harness through the same CLI Bridge at `/profiles/<id>/v1` (cli-bridge#408).\n * The app's production model and its own MCP servers are not part of it; the run record names both.\n *\n * Every run says what it measured: `model-shaped` (the target as a model calling the benchmark's tools, which the\n * benchmark executes) or `own-loop` (the agent with its own loop and tools). The two are never compared as one.\n */\nimport { spawn } from 'node:child_process'\nimport { createHash, randomUUID } from 'node:crypto'\nimport { existsSync } from 'node:fs'\nimport { mkdir, readdir, readFile, writeFile } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { canonicalJson, RunRecordValidationError, UNKNOWN_MODEL, validateRunRecord, type RunRecord } from '@tangle-network/agent-eval'\n\nexport type Measured = 'model-shaped' | 'own-loop'\n\n/** The OpenAI-compatible endpoint a publisher's runner calls for one target. */\nexport interface Endpoint {\n target: string\n baseUrl: string\n model: string\n /** The environment variable that holds the endpoint's key; the runner reads it, nothing here prints it. */\n apiKeyVar: string\n /** What a run through this endpoint measures. */\n measured: Measured\n /** For an app target: which served profile ran, and what of the app it leaves out. */\n app?: AppProfile\n}\n\n/** An agent app's served AgentProfile as an app target runs it. */\nexport interface AppProfile {\n app: string\n profileUrl: string\n profileName: string | null\n profileVersion: string | null\n /** sha256 of the profile as run (served profile without `model` and `mcp`). */\n profileDigest: string\n /** The model the app runs in production, replaced by the target's harness model. */\n productionModel: unknown\n /** The app's own MCP servers, which need the app's deployment and are not mounted. */\n omittedMcp: string[]\n}\n\n/**\n * Agent apps a benchmark can target, each by the executable AgentProfile it serves in production: the projection its own\n * sandbox sends a harness (gtm-agent toExecutableAgentProfile, legal-agent slimSandboxProfile). `AGENT_BENCH_APPS`, a JSON\n * object of app name to profile URL or absolute file path, adds an app or points one at another source: a staging deployment,\n * a profile exported from a checkout, or a candidate profile an optimizer is scoring.\n */\nexport const AGENT_APPS: Readonly<Record<string, { profileUrl: string }>> = {\n 'gtm-agent': { profileUrl: 'https://gtm.tangle.tools/api/tools/profile?definition=executable' },\n 'legal-agent': { profileUrl: 'https://legal.tangle.tools/api/tools/profile?definition=executable' },\n}\n\nfunction agentApps(env: NodeJS.ProcessEnv): Record<string, { profileUrl: string }> {\n if (!env.AGENT_BENCH_APPS) return { ...AGENT_APPS }\n const extra = JSON.parse(env.AGENT_BENCH_APPS) as unknown\n if (!extra || typeof extra !== 'object' || Array.isArray(extra) || !Object.values(extra).every((url) => typeof url === 'string')) {\n throw new Error('AGENT_BENCH_APPS must be a JSON object of app name to profile URL or absolute file path')\n }\n return { ...AGENT_APPS, ...Object.fromEntries(Object.entries(extra as Record<string, string>).map(([name, profileUrl]) => [name, { profileUrl }])) }\n}\n\nexport interface PublishedRunOptions {\n /** Run this many tasks in the publisher's order (a sample, never a full official run unless asked). */\n tasks?: number\n /** Run exactly these publisher task ids. */\n taskIds?: string[]\n /** Extra arguments passed to the publisher's runner unchanged, after the ones this registry sets. */\n args?: string[]\n /** Where the publisher's result file and this run's record are written. */\n out: string\n env?: NodeJS.ProcessEnv\n /** Where publisher checkouts are cached; defaults to ~/.cache/agent-bench/published. */\n cacheDir?: string\n /**\n * Replace the publisher's judge with `bridge/<harness/model>`, a model on a subscription seat behind a CLI Bridge\n * (AGENT_BENCH_JUDGE_URL, default the profile Bridge). The run is then not official, and its record says so.\n */\n judge?: string\n /** The agent-eval RunRecord identity each task row carries; defaults: experiment `<benchmark>@<ref>`, candidate the target, split holdout. */\n record?: { experimentId?: string; candidateId?: string; splitTag?: 'search' | 'dev' | 'holdout' }\n}\n\n/** One task's score; `raw` carries the publisher's numeric per-task detail (Harvey LAB: `crit.<id>` 1|0, criteria counts). */\nexport interface PublishedTaskScore {\n id: string\n passed: boolean\n score: number\n notes?: string\n raw?: Record<string, number>\n}\n\nexport interface PublishedBenchmark {\n name: string\n repository: string\n /** The exact publisher commit; a moved tag cannot change a recorded number. */\n ref: string\n version: string\n license: string\n terms: string\n /** The judge model the publisher names, or null when the publisher's grader is deterministic. */\n judge: string | null\n /** The benchmark's runner accepts a substituted judge (`--judge`). */\n judgeSubstitutable?: boolean\n /** Why no run of this entry is official, when the publisher reports from an implementation it does not release. */\n unofficial?: string\n measured: Measured\n /** The runner writes a folder of results rather than one file. */\n resultIsFolder?: boolean\n install: string[][]\n run(endpoint: Endpoint, options: PublishedRunOptions, resultPath: string): string[]\n /** Read the publisher's result (a file or a folder) into one score per task, as the publisher's grader reported it. */\n parse(resultPath: string): Promise<PublishedTaskScore[]>\n}\n\nexport interface PublishedRun {\n benchmark: string\n version: string\n ref: string\n target: string\n model: string\n measured: Measured\n judge: string | null\n /** The judge the publisher names, kept beside a substituted one. */\n publisherJudge: string | null\n /** True when the score comes from the publisher's own grader and judge; false whenever a judge was substituted. */\n official: boolean\n /** Why the entry is never official (`PublishedBenchmark.unofficial`). */\n unofficial?: string\n app?: AppProfile\n tasks: number\n passed: number\n /** Mean task score, 0..1, as the publisher's grader reports it. */\n score: number\n taskScores: PublishedTaskScore[]\n resultPath: string\n /** One agent-eval RunRecord per task (JSON lines), for the ledgers, dashboards and promotion gates every other run feeds. */\n runRecords: string\n license: string\n terms: string\n startedAt: string\n finishedAt: string\n}\n\nexport const PUBLISHED_BENCHMARKS: Readonly<Record<string, PublishedBenchmark>> = {\n automationbench: {\n name: 'automationbench',\n repository: 'https://github.com/zapier/AutomationBench.git',\n ref: '4a8e1061254004d9dac807054eed33fad7d1ff14',\n version: '1.0.6',\n license: 'MIT (Zapier, Inc.); third-party API schemas excluded',\n terms: 'MIT: tasks and code may be redistributed with attribution',\n judge: null,\n measured: 'model-shaped',\n install: [['uv', 'sync', '--frozen']],\n run: (endpoint, options, resultPath) => [\n 'uv', 'run', 'auto-bench',\n '--model', endpoint.model, '--base-url', endpoint.baseUrl, '--api-key-var', endpoint.apiKeyVar,\n ...(options.taskIds?.length ? ['--tasks', options.taskIds.join(',')] : []),\n ...(options.tasks === undefined ? [] : ['--num-examples', String(options.tasks)]),\n '--max-concurrent', String(Math.max(1, Math.min(options.tasks ?? options.taskIds?.length ?? 4, 4))),\n '--export-json', resultPath,\n ...(options.args ?? []),\n ],\n parse: async (resultPath) => {\n const tasks = (JSON.parse(await readFile(resultPath, 'utf8')) as { tasks?: Array<{ name?: unknown; score?: unknown; passed?: unknown }> }).tasks\n if (!Array.isArray(tasks)) throw new Error('AutomationBench result has no tasks array')\n return tasks.map((task) => {\n if (typeof task.name !== 'string' || typeof task.score !== 'number' || typeof task.passed !== 'boolean') {\n throw new Error(`AutomationBench task result is malformed: ${JSON.stringify(task).slice(0, 200)}`)\n }\n return { id: task.name, passed: task.passed, score: task.score }\n })\n },\n },\n 'enterpriseops-gym': {\n name: 'enterpriseops-gym',\n repository: 'https://github.com/ServiceNow/EnterpriseOps-Gym.git',\n ref: '271f2c357f763376997dfd16807fcde2474ae41b',\n version: '271f2c3 (no release tag)',\n license: 'Apache-2.0 (ServiceNow; code and the ServiceNow-AI/EnterpriseOps-Gym dataset)',\n terms: 'Apache-2.0: tasks may be redistributed with attribution',\n judge: null,\n measured: 'model-shaped',\n resultIsFolder: true,\n install: [['uv', 'sync', '--extra', 'openai'], ['python3', '-c', \"import zipfile; zipfile.ZipFile('gym_dbs.zip').extractall('.')\"]],\n // A sample runs `--task` ids or the first --tasks of the domain (default teams, mode oracle; pass `-- --domain d --mode m`).\n run: (endpoint, options, resultPath) => [\n 'sh', fileURLToPath(new URL('../scripts/enterpriseops-gym-run.sh', import.meta.url)),\n resultPath, endpoint.baseUrl, endpoint.model, endpoint.apiKeyVar,\n options.tasks === undefined ? 'all' : String(options.tasks), (options.taskIds ?? []).join(','),\n ...(options.args ?? []),\n ],\n parse: async (resultPath) => {\n const folder = path.join(resultPath, 'run_1')\n const files = (await readdir(folder)).filter((file) => file.startsWith('results_') && file.endsWith('.json')).sort()\n if (!files.length) throw new Error(`EnterpriseOps-Gym wrote no task results under ${folder}`)\n return Promise.all(files.map(async (file) => {\n const result = JSON.parse(await readFile(path.join(folder, file), 'utf8')) as {\n statistics?: { overall_success_rate?: unknown; verifier_level_pass_rate?: unknown }; runs?: Array<{ error?: unknown }>\n }\n const success = result.statistics?.overall_success_rate\n const verifiers = result.statistics?.verifier_level_pass_rate\n if (typeof success !== 'number') throw new Error(`EnterpriseOps-Gym result ${file} has no statistics.overall_success_rate`)\n const error = result.runs?.find((run) => run.error)?.error\n return {\n id: file.slice('results_'.length, -'.json'.length).split('__').pop()!, passed: success === 1, score: success,\n notes: `verifier pass rate ${typeof verifiers === 'number' ? verifiers : 'unknown'}${error ? `; runner error: ${String(error).slice(0, 200)}` : ''}`,\n }\n }))\n },\n },\n 'harvey-lab': {\n name: 'harvey-lab',\n repository: 'https://github.com/harveyai/harvey-labs.git',\n // v1.3.0, the latest tag: v1.0 has no OpenAI-compatible chat adapter; v1.3.0 ships baseten/ (chat completions with tools).\n ref: '81d6a31b22d7c9f661cda4770cffcc12a5735dc2',\n version: 'v1.3.0',\n license: 'MIT (Harvey AI)',\n terms: 'MIT: tasks and their synthetic documents ship in the repository; no training or redistribution restriction stated',\n judge: 'claude-sonnet-4-6 + gpt-5.5 (LAB standard dual judge, all-pass per criterion)',\n judgeSubstitutable: true,\n measured: 'model-shaped',\n resultIsFolder: true,\n install: [\n ['uv', 'sync', '--all-extras'],\n // The publisher's own pinned pandoc, which its grader needs for .docx deliverables, into the checkout.\n ['sh', 'lab_core/sandbox/install_pandoc.sh', '.agent-bench'],\n ['sh', fileURLToPath(new URL('../scripts/harvey-lab-sandbox.sh', import.meta.url))],\n ],\n // A sample runs --task ids or the first --tasks in sorted task-id order (pass `-- --area <practice area>` to stay in one).\n run: (endpoint, options, resultPath) => [\n 'sh', fileURLToPath(new URL('../scripts/harvey-lab-run.sh', import.meta.url)),\n resultPath, endpoint.baseUrl, endpoint.model, endpoint.apiKeyVar,\n options.tasks === undefined ? 'all' : String(options.tasks), (options.taskIds ?? []).join(','), options.judge ?? 'publisher',\n ...(options.args ?? []),\n ],\n parse: async (resultPath) => {\n const runs = (await readFile(path.join(resultPath, 'tasks.tsv'), 'utf8')).trim().split('\\n').map((line) => line.split('\\t') as [string, string])\n return Promise.all(runs.map(async ([run, task]) => {\n const read = (file: string) => readFile(path.join(resultPath, run, file), 'utf8').then((text) => JSON.parse(text) as Record<string, unknown>, () => null)\n const dual = await read('scores_dual.json')\n if (dual) return { id: task, passed: dual.all_pass === true, score: Number(dual.dual_all_pass_rate), notes: `dual-judge criterion pass ${String(dual.dual_criterion_pass)}` }\n const single = await read('scores.json')\n if (single) {\n const criteria = Array.isArray(single.criteria_results) ? single.criteria_results as Array<{ id?: unknown; verdict?: unknown }> : []\n return { id: task, passed: single.all_pass === true, score: single.all_pass === true ? 1 : 0,\n notes: `${String(single.n_passed)} of ${String(single.n_criteria)} criteria passed${single.n_grading_errors ? `; ${String(single.n_grading_errors)} grading errors` : ''}`,\n raw: { criteria_passed: Number(single.n_passed) || 0, criteria_total: Number(single.n_criteria) || 0,\n ...Object.fromEntries(criteria.filter((c) => typeof c.id === 'string').map((c) => [`crit.${String(c.id)}`, c.verdict === 'pass' ? 1 : 0])) } }\n }\n return { id: task, passed: false, score: 0, notes: 'no scores: the harness or the grader failed (see the runner log)' }\n }))\n },\n },\n prbench: {\n name: 'prbench',\n repository: 'https://github.com/scaleapi/PRBench.git',\n ref: '7b2df0a28bf99ec51263c41b90dd510a740a7711',\n version: '7b2df0a (no release tag)',\n license: 'MIT (Scale AI); dataset ScaleAI/PRBench CC-BY-4.0',\n terms: 'CC-BY-4.0 dataset, not gated, loaded from Hugging Face at run time; attribution required, no training restriction stated',\n judge: 'openai/o4-mini (reasoning effort high), one call per rubric criterion',\n judgeSubstitutable: true,\n measured: 'model-shaped',\n resultIsFolder: true,\n // The publisher pins no dependency versions (requirements.txt), so a fresh install resolves them anew.\n install: [['uv', 'venv', '--quiet', '--python', '3.12'], ['uv', 'pip', 'install', '--quiet', '-r', 'requirements.txt']],\n // A sample runs --task ids or the first --tasks rows of the split (default legal; pass `-- --split finance`).\n run: (endpoint, options, resultPath) => [\n 'sh', fileURLToPath(new URL('../scripts/prbench-run.sh', import.meta.url)),\n resultPath, endpoint.baseUrl, endpoint.model, endpoint.apiKeyVar,\n options.tasks === undefined ? 'all' : String(options.tasks), (options.taskIds ?? []).join(','), options.judge ?? 'publisher',\n ...(options.args ?? []),\n ],\n // Per task, the publisher's clipped score: rubric points over the positive weights (negative criteria can take it below\n // zero; clamped to 0..1 here). The publisher's aggregate, mean_clipped, is max(0, mean of the unclamped scores).\n parse: async (resultPath) => {\n const folder = path.join(resultPath, 'results')\n const files = (await readdir(folder)).filter((file) => file.endsWith('.json'))\n if (files.length !== 1) throw new Error(`PRBench wrote ${files.length} result files under ${folder}, expected one`)\n const result = JSON.parse(await readFile(path.join(folder, files[0]!), 'utf8')) as { outputs?: Record<string, Record<string, { points?: unknown; weights?: unknown }>> }\n const tasks = Object.values(result.outputs ?? {})[0]\n if (!tasks) throw new Error(`PRBench result ${files[0]} has no outputs`)\n return Object.entries(tasks).map(([id, task]) => {\n const weights = Array.isArray(task.weights) ? task.weights.filter((weight): weight is number => typeof weight === 'number') : []\n const best = weights.filter((weight) => weight > 0).reduce((sum, weight) => sum + weight, 0)\n const points = typeof task.points === 'number' ? task.points : Number.NaN\n if (!best || Number.isNaN(points)) throw new Error(`PRBench task ${id} has no points or weights`)\n return { id, passed: points >= best, score: Math.min(1, Math.max(0, points / best)), notes: `${points} of ${best} rubric points` }\n })\n },\n },\n 'healthbench-professional': {\n name: 'healthbench-professional',\n repository: 'https://github.com/openai/simple-evals.git',\n ref: '652c89d0ca9df547706735883097e9537d40dc47',\n version: '652c89d (no release tag), data openai/healthbench-professional@349962fd',\n license: 'MIT (OpenAI simple-evals); dataset openai/healthbench-professional MIT',\n terms: 'MIT dataset, not gated, fetched from Hugging Face at the pinned revision at run time and never committed: the authors ask that examples not be revealed in plain text or images online. No training restriction stated.',\n judge: 'gpt-5.4-2026-03-05 (reasoning effort low), one call per rubric item; length-adjusted (center 2000 characters, 1.47 points per 500)',\n judgeSubstitutable: true,\n unofficial: 'OpenAI reports HealthBench Professional from an internal implementation it does not release; simple-evals with its Professional settings is the reference implementation',\n measured: 'model-shaped',\n resultIsFolder: true,\n // The publisher pins no dependency versions and ships no requirements file; these are the imports HealthBenchEval needs.\n install: [['uv', 'venv', '--quiet', '--python', '3.12'], ['uv', 'pip', 'install', '--quiet', 'openai', 'blobfile', 'numpy', 'pandas', 'jinja2', 'requests', 'tqdm']],\n // A sample runs the publisher's seeded sample of --tasks examples, or the --task ids.\n run: (endpoint, options, resultPath) => [\n 'sh', fileURLToPath(new URL('../scripts/healthbench-professional-run.sh', import.meta.url)),\n resultPath, endpoint.baseUrl, endpoint.model, endpoint.apiKeyVar,\n options.tasks === undefined ? 'all' : String(options.tasks), (options.taskIds ?? []).join(','), options.judge ?? 'publisher',\n ...(options.args ?? []),\n ],\n // Per task, the publisher's length-adjusted rubric score, clamped to 0..1 (the publisher clips the mean, not each task).\n // Passed: every positive criterion met and no negative one.\n parse: async (resultPath) => {\n const result = JSON.parse(await readFile(path.join(resultPath, 'result.json'), 'utf8')) as {\n examples?: Array<{ prompt_id: string; overall_score: number; length_adjusted: number; response_chars: number; positive_met: number; positive_total: number; negative_met: number }>\n }\n if (!result.examples?.length) throw new Error(`HealthBench Professional wrote no examples under ${resultPath}`)\n return result.examples.map((example) => ({\n id: example.prompt_id,\n passed: example.positive_met === example.positive_total && example.negative_met === 0,\n score: Math.min(1, Math.max(0, example.length_adjusted)),\n notes: `${example.positive_met} of ${example.positive_total} positive criteria met, ${example.negative_met} negative met; rubric score ${example.overall_score.toFixed(3)}, length-adjusted for ${example.response_chars} characters`,\n raw: {\n overall_score: example.overall_score, length_adjusted: example.length_adjusted, response_chars: example.response_chars,\n positive_met: example.positive_met, positive_total: example.positive_total, negative_met: example.negative_met,\n },\n }))\n },\n },\n mlcr: {\n name: 'mlcr',\n repository: 'https://github.com/Wisedocs-AI/medical-long-context-reasoning.git',\n ref: 'ca822de2d274184bb0cd5bf280ff917922f3716f',\n version: 'v1.1 (ca822de, the release commit; no tag), data Wisedocs/mlcr-dataset@1198206e',\n license: 'none: neither the code nor the Wisedocs/mlcr-dataset release carries a license (the dataset card says \"other\")',\n terms: 'No license: run locally for evaluation only, never committed, redistributed, or used for training or prompt optimization. The dataset is not gated and is fetched from Hugging Face at the pinned revision at run time.',\n // A substituted judge sits all three jury seats, each sampling independently, so the publisher's two-of-three rule applies.\n judge: \"jury of gemini-3.1-pro-preview, claude-opus-4-8-gcp and gpt-5.5 (majority vote, medium thinking) on the publisher's Vertex, Anthropic-on-GCP and Azure OpenAI providers, after a conciseness gate\",\n judgeSubstitutable: true,\n measured: 'model-shaped',\n resultIsFolder: true,\n install: [['uv', 'venv', '--quiet', '--python', '3.12'], ['uv', 'pip', 'install', '--quiet', '-e', '.[all]']],\n // A sample is the runner's first --tasks rows of the publisher's smoke experiment; MLCR names rows by matrix cell, not id.\n run: (endpoint, options, resultPath) => [\n 'sh', fileURLToPath(new URL('../scripts/mlcr-run.sh', import.meta.url)),\n resultPath, endpoint.baseUrl, endpoint.model, endpoint.apiKeyVar,\n options.tasks === undefined ? 'all' : String(options.tasks), (options.taskIds ?? []).join(','), options.judge ?? 'publisher',\n ...(options.args ?? []),\n ],\n // Per row, the jury's verdict: correct (complete and accurate by majority) after the conciseness gate.\n parse: async (resultPath) => {\n const result = JSON.parse(await readFile(path.join(resultPath, 'result.json'), 'utf8')) as {\n examples?: Array<{ id: string; concise: string; complete: string; accurate: string; correct: string; judge_error: boolean; response_chars: number }>\n }\n if (!result.examples?.length) throw new Error(`MLCR wrote no scored rows under ${resultPath}`)\n const verdict = (value: string) => (value === '' ? undefined : Number(value))\n return result.examples.map((example) => {\n if (example.correct === '') throw new Error(`MLCR row ${example.id} has no jury verdict${example.judge_error ? ' (the judge failed)' : ''}`)\n const raw = Object.fromEntries(Object.entries({ concise: verdict(example.concise), complete: verdict(example.complete), accurate: verdict(example.accurate), correct: verdict(example.correct) })\n .filter((entry): entry is [string, number] => entry[1] !== undefined))\n return {\n id: example.id, passed: example.correct === '1', score: example.correct === '1' ? 1 : 0,\n notes: `concise ${example.concise || '-'}, complete ${example.complete || '-'}, accurate ${example.accurate || '-'}; ${example.response_chars} characters`,\n raw: { ...raw, response_chars: example.response_chars },\n }\n })\n },\n },\n}\n\n/** Resolve a `model:`, `app:` or `profile:` target to the endpoint a publisher's runner calls. */\nexport async function resolveEndpoint(target: string, benchmark: PublishedBenchmark, env: NodeJS.ProcessEnv = process.env): Promise<Endpoint> {\n const match = /^(model|app|profile):(.+)$/.exec(target)\n if (!match) throw new Error(`target must be model:<router model>, app:<agent app>@<harness/model> or profile:<harness/model>, not '${target}'`)\n const [, kind, id] = match as unknown as [string, 'model' | 'app' | 'profile', string]\n if (kind === 'model') {\n return { target, model: id, baseUrl: env.AGENT_BENCH_ROUTER_URL ?? 'https://router.tangle.tools/v1', apiKeyVar: 'TANGLE_API_KEY', measured: benchmark.measured }\n }\n // A loopback Bridge without a bearer accepts any key; the runner still needs one to send.\n const bridge = env.AGENT_BENCH_BRIDGE_URL ?? 'http://127.0.0.1:3344/v1'\n if (kind === 'profile') return { target, model: id, baseUrl: bridge, apiKeyVar: 'AGENT_BENCH_BRIDGE_KEY', measured: 'own-loop' }\n const at = id.indexOf('@')\n const [name, harness] = at === -1 ? [id, ''] : [id.slice(0, at), id.slice(at + 1)]\n const apps = agentApps(env)\n const app = apps[name]\n if (!app) throw new Error(`no agent app '${name}'; registered: ${Object.keys(apps).join(', ')} (add one with AGENT_BENCH_APPS)`)\n if (!harness) throw new Error(`app:${name} needs @<harness/model>, the subscription harness that runs the app's profile, e.g. app:${name}@opencode/zai-coding-plan/glm-5.3`)\n const catalog = env.AGENT_BENCH_BRIDGE_PROFILES_DIR\n if (!catalog) throw new Error(`AGENT_BENCH_BRIDGE_PROFILES_DIR is not set: point it at the CLI Bridge's SANDBOX_PROFILES_DIR, where app:${name} writes its profile`)\n const { mcp, model, ...profile } = await readAppProfile(name, app.profileUrl)\n const text = JSON.stringify(profile)\n const digest = createHash('sha256').update(text).digest('hex')\n // Content-addressed: the Bridge rereads its catalog only for an id it does not know.\n const profileId = `${name}-${digest.slice(0, 12)}`\n await mkdir(catalog, { recursive: true })\n await writeFile(path.join(catalog, `${profileId}.json`), text)\n return {\n target, model: harness, baseUrl: `${bridge.replace(/\\/v1\\/?$/, '')}/profiles/${profileId}/v1`, apiKeyVar: 'AGENT_BENCH_BRIDGE_KEY', measured: 'own-loop',\n app: {\n app: name, profileUrl: app.profileUrl, profileDigest: `sha256:${digest}`, productionModel: model ?? null,\n profileName: typeof profile.name === 'string' ? profile.name : null, profileVersion: typeof profile.version === 'string' ? profile.version : null,\n omittedMcp: mcp && typeof mcp === 'object' ? Object.keys(mcp) : [],\n },\n }\n}\n\n/** An app's profile from its URL, or from an absolute file path. */\nasync function readAppProfile(name: string, source: string): Promise<Record<string, unknown>> {\n if (path.isAbsolute(source)) return JSON.parse(await readFile(source, 'utf8')) as Record<string, unknown>\n const response = await fetch(source)\n if (!response.ok) throw new Error(`${source} answered ${response.status}; app:${name} needs the profile the app serves`)\n return await response.json() as Record<string, unknown>\n}\n\n/** Run one published benchmark against one target with the publisher's runner and grader, and record the result. */\nexport async function runPublished(name: string, target: string, options: PublishedRunOptions): Promise<PublishedRun> {\n const benchmark = PUBLISHED_BENCHMARKS[name]\n if (!benchmark) throw new Error(`no published benchmark '${name}'; registered: ${Object.keys(PUBLISHED_BENCHMARKS).join(', ')}`)\n const env = { ...process.env, ...options.env }\n if (options.judge !== undefined && !benchmark.judgeSubstitutable) {\n throw new Error(`${benchmark.name} grades ${benchmark.judge === null ? 'deterministically' : `with ${benchmark.judge}`}; this registry cannot substitute its judge`)\n }\n if (options.judge !== undefined && !options.judge.startsWith('bridge/')) throw new Error(`--judge must be bridge/<harness/model>, not '${options.judge}'`)\n env.AGENT_BENCH_JUDGE_URL ??= env.AGENT_BENCH_BRIDGE_URL ?? 'http://127.0.0.1:3344/v1'\n const endpoint = await resolveEndpoint(target, benchmark, env)\n if (!env[endpoint.apiKeyVar]) throw new Error(`${endpoint.apiKeyVar} is not set; the ${target} endpoint needs it`)\n const checkout = await publisherCheckout(benchmark, options.cacheDir, env)\n await mkdir(options.out, { recursive: true })\n const resultPath = path.resolve(options.out, `${benchmark.name}-result${benchmark.resultIsFolder ? '' : '.json'}`)\n const startedAt = new Date().toISOString()\n const [command, ...args] = benchmark.run(endpoint, options, resultPath)\n await execute(command!, args, checkout, env)\n const taskScores = await benchmark.parse(resultPath)\n const run: PublishedRun = {\n benchmark: benchmark.name, version: benchmark.version, ref: benchmark.ref, target, model: endpoint.model,\n measured: endpoint.measured, judge: options.judge ?? benchmark.judge, publisherJudge: benchmark.judge,\n official: options.judge === undefined && benchmark.unofficial === undefined,\n ...(benchmark.unofficial ? { unofficial: benchmark.unofficial } : {}),\n ...(endpoint.app ? { app: endpoint.app } : {}),\n tasks: taskScores.length, passed: taskScores.filter((task) => task.passed).length,\n score: taskScores.length ? taskScores.reduce((sum, task) => sum + task.score, 0) / taskScores.length : 0,\n taskScores, resultPath, runRecords: path.resolve(options.out, `${benchmark.name}-runrecords.jsonl`),\n license: benchmark.license, terms: benchmark.terms, startedAt, finishedAt: new Date().toISOString(),\n }\n await writeFile(run.runRecords, runRecords(run, options).map((record) => JSON.stringify(record)).join('\\n') + '\\n')\n await writeFile(path.resolve(options.out, `${benchmark.name}-run.json`), `${JSON.stringify(run, null, 2)}\\n`)\n return run\n}\n\n/**\n * One agent-eval RunRecord per task, validated by agent-eval's own validator. The publisher's runner makes the model calls,\n * so cost and tokens are uncaptured, never zero. A RunRecord's model must name a served snapshot; a subscription harness\n * reports none, and a snapshot invented from the date would be false, so such rows record `unknown` with terminal outcome\n * `unknown` and keep the requested model in `candidateId`. A pinned model id (a Router snapshot) is recorded as served.\n */\nfunction runRecords(run: PublishedRun, options: PublishedRunOptions): RunRecord[] {\n const split = options.record?.splitTag ?? 'holdout'\n const sha = (value: string) => `sha256:${createHash('sha256').update(value).digest('hex')}`\n const configHash = sha(canonicalJson({ benchmark: run.benchmark, ref: run.ref, target: run.target, judge: run.judge, args: options.args ?? [] }))\n return run.taskScores.map((task) => {\n const row = {\n runId: randomUUID(), experimentId: options.record?.experimentId ?? `${run.benchmark}@${run.ref}`,\n candidateId: options.record?.candidateId ?? run.target, seed: 0, model: run.model,\n // The publisher owns the prompt; an app run's prompt is its profile.\n promptHash: run.app?.profileDigest ?? sha(run.target), configHash, commitSha: run.ref,\n wallMs: Math.max(0, Date.parse(run.finishedAt) - Date.parse(run.startedAt)),\n costUsd: null, costProvenance: { kind: 'uncaptured', usd: null }, tokenUsage: { input: 0, output: 0, tokensKnown: false },\n terminalOutcome: 'succeeded',\n outcome: { [split === 'holdout' ? 'holdoutScore' : 'searchScore']: task.score, raw: { passed: task.passed ? 1 : 0, ...task.raw } },\n splitTag: split, scenarioId: `${run.benchmark}:${task.id}`,\n }\n try {\n return validateRunRecord(row)\n } catch (error) {\n if (!(error instanceof RunRecordValidationError) || error.path !== 'model') throw error\n return validateRunRecord({ ...row, model: UNKNOWN_MODEL, terminalOutcome: 'unknown' })\n }\n })\n}\n\n/** The publisher's repository at the pinned commit, installed once per cache. */\nasync function publisherCheckout(benchmark: PublishedBenchmark, cacheDir: string | undefined, env: NodeJS.ProcessEnv): Promise<string> {\n const root = cacheDir ?? path.join(homedir(), '.cache', 'agent-bench', 'published')\n const dir = path.join(root, `${benchmark.name}@${benchmark.ref}`)\n const installed = path.join(dir, '.agent-bench-installed')\n if (existsSync(installed)) return dir\n if (!existsSync(path.join(dir, '.git'))) {\n await mkdir(root, { recursive: true })\n await execute('git', ['clone', '--quiet', '--filter=blob:none', '--no-checkout', benchmark.repository, dir], root, env)\n }\n await execute('git', ['checkout', '--quiet', '--detach', benchmark.ref], dir, env)\n for (const [command, ...args] of benchmark.install) await execute(command!, args, dir, env)\n await writeFile(installed, `${benchmark.ref}\\n`)\n return dir\n}\n\nfunction execute(command: string, args: string[], cwd: string, env: NodeJS.ProcessEnv): Promise<void> {\n return new Promise((resolve, reject) => {\n const child = spawn(command, args, { cwd, env, stdio: 'inherit' })\n child.once('error', (error) => reject(new Error(`${command} could not start in ${cwd}: ${error.message}`)))\n child.once('exit', (code, signal) => code === 0\n ? resolve()\n : reject(new Error(`${command} ${args.slice(0, 3).join(' ')} exited ${signal ?? code} in ${cwd}`)))\n })\n}\n","#!/usr/bin/env node\n/**\n * agent-bench run <benchmark> --target <model:|app:|profile:> [--tasks N] [--task <publisher task id>]... [--out <dir>] [-- <runner args>]\n * agent-bench list\n *\n * Runs a published benchmark with its publisher's own runner and grader (src/published.ts), prints the score with what it\n * measured, and writes the run record to --out (default ./agent-bench-runs/<benchmark>-<time>).\n */\nimport path from 'node:path'\nimport { PUBLISHED_BENCHMARKS, runPublished } from './published'\n\nconst usage = 'usage: agent-bench run <benchmark> --target <model:<router model>|app:<agent app>@<harness/model>|profile:<harness/model>> [--tasks N] [--task <id>]... [--judge bridge/<harness/model>] [--experiment <id>] [--candidate <id>] [--split search|dev|holdout] [--out <dir>] [-- <runner args>]\\n agent-bench list'\n\nasync function main(argv: string[]): Promise<number> {\n const [command, ...rest] = argv\n if (command === 'list') {\n for (const benchmark of Object.values(PUBLISHED_BENCHMARKS)) {\n console.log(`${benchmark.name} ${benchmark.version} ${benchmark.repository}@${benchmark.ref.slice(0, 12)} ${benchmark.measured} judge=${benchmark.judge ?? 'deterministic'} license=${benchmark.license}`)\n }\n return 0\n }\n if (command !== 'run' || !rest[0] || rest[0].startsWith('-')) {\n console.error(usage)\n return 2\n }\n const name = rest[0]\n const separator = rest.indexOf('--')\n const own = separator === -1 ? rest.slice(1) : rest.slice(1, separator)\n const runnerArgs = separator === -1 ? [] : rest.slice(separator + 1)\n let target: string | undefined\n let tasks: number | undefined\n const taskIds: string[] = []\n let out: string | undefined\n let judge: string | undefined\n const record: { experimentId?: string; candidateId?: string; splitTag?: 'search' | 'dev' | 'holdout' } = {}\n for (let i = 0; i < own.length; i++) {\n const flag = own[i]\n const value = own[i + 1]\n if (value === undefined) throw new Error(`${flag} needs a value\\n${usage}`)\n if (flag === '--target') target = value\n else if (flag === '--tasks') tasks = Number.parseInt(value, 10)\n else if (flag === '--task') taskIds.push(value)\n else if (flag === '--out') out = value\n else if (flag === '--judge') judge = value\n else if (flag === '--experiment') record.experimentId = value\n else if (flag === '--candidate') record.candidateId = value\n else if (flag === '--split') record.splitTag = value as 'search' | 'dev' | 'holdout'\n else throw new Error(`unknown option ${flag}\\n${usage}`)\n i++\n }\n if (!target) throw new Error(`--target is required\\n${usage}`)\n if (tasks !== undefined && !(Number.isSafeInteger(tasks) && tasks > 0)) throw new Error('--tasks must be a positive integer')\n const run = await runPublished(name, target, {\n ...(tasks === undefined ? {} : { tasks }),\n ...(taskIds.length ? { taskIds } : {}),\n ...(judge === undefined ? {} : { judge }),\n ...(Object.keys(record).length ? { record } : {}),\n args: runnerArgs,\n out: path.resolve(out ?? path.join('agent-bench-runs', `${name}-${new Date().toISOString().replace(/[:.]/g, '-')}`)),\n })\n console.log(`${run.benchmark} ${run.version} on ${run.target}: ${run.passed} of ${run.tasks} passed, score ${run.score.toFixed(3)}, measured ${run.measured}, judge ${run.judge === null ? 'deterministic' : run.judge} (${run.official ? 'official' : `${[run.judge !== run.publisherJudge ? `substituted for ${run.publisherJudge}` : undefined, run.unofficial].filter(Boolean).join('; ')}, not official`})`)\n if (run.app) {\n console.log(`app: ${run.app.app} profile ${run.app.profileName ?? '?'} ${run.app.profileVersion ?? ''} ${run.app.profileDigest.slice(0, 19)} from ${run.app.profileUrl}; ` +\n `its production model ${JSON.stringify(run.app.productionModel)} replaced by ${run.model}; its MCP servers not mounted: ${run.app.omittedMcp.join(', ') || 'none'}`)\n }\n console.log(`record: ${path.join(path.dirname(run.resultPath), `${run.benchmark}-run.json`)}`)\n console.log(`run records: ${run.runRecords}`)\n return 0\n}\n\nmain(process.argv.slice(2)).then((code) => process.exit(code), (error: unknown) => {\n console.error(error instanceof Error ? error.message : String(error))\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,MAAa,aAA+D;CAC1E,aAAa,EAAE,YAAY,mEAAmE;CAC9F,eAAe,EAAE,YAAY,qEAAqE;AACpG;AAEA,SAAS,UAAU,KAAgE;CACjF,IAAI,CAAC,IAAI,kBAAkB,OAAO,EAAE,GAAG,WAAW;CAClD,MAAM,QAAQ,KAAK,MAAM,IAAI,gBAAgB;CAC7C,IAAI,CAAC,S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pinned commit.\n *\n * One registry entry per benchmark: the publisher's repository and commit, its install and run commands, a parser from the\n * publisher's result file to per-task scores (agent-eval's verdict names: `passed`, `score`, `notes`), the license, the data terms, and the judge the publisher names. Nothing here loads\n * tasks, drives an agent loop, or grades: the publisher's runner does all three. A target becomes the OpenAI-compatible\n * endpoint that runner calls:\n *\n * model:<router model> the Tangle Router with `TANGLE_API_KEY`; the target is a model driving the benchmark's tools.\n * profile:<harness/model> a CLI Bridge (`AGENT_BENCH_BRIDGE_URL`, default http://127.0.0.1:3344/v1) running that harness with\n * its own loop and tools; the benchmark's tools reach it as caller-executed MCP tools (cli-bridge#397).\n * app:<agent app>@<harness/model>\n * the AgentProfile the app serves in production (prompt, skills, subagents, resources), run by\n * that subscription harness through the same CLI Bridge at `/profiles/<id>/v1` (cli-bridge#408).\n * The app's production model and its own MCP servers are not part of it; the run record names both.\n *\n * Every run says what it measured: `model-shaped` (the target as a model calling the benchmark's tools, which the\n * benchmark executes) or `own-loop` (the agent with its own loop and tools). The two are never compared as one.\n */\nimport { spawn } from 'node:child_process'\nimport { createHash, randomUUID } from 'node:crypto'\nimport { existsSync } from 'node:fs'\nimport { mkdir, readdir, readFile, writeFile } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { canonicalJson, RunRecordValidationError, UNKNOWN_MODEL, validateRunRecord, type RunRecord } from '@tangle-network/agent-eval'\n\nexport type Measured = 'model-shaped' | 'own-loop'\n\n/** The OpenAI-compatible endpoint a publisher's runner calls for one target. */\nexport interface Endpoint {\n target: string\n baseUrl: string\n model: string\n /** The environment variable that holds the endpoint's key; the runner reads it, nothing here prints it. */\n apiKeyVar: string\n /** What a run through this endpoint measures. */\n measured: Measured\n /** For an app target: which served profile ran, and what of the app it leaves out. */\n app?: AppProfile\n}\n\n/** An agent app's served AgentProfile as an app target runs it. */\nexport interface AppProfile {\n app: string\n profileUrl: string\n profileName: string | null\n profileVersion: string | null\n /** sha256 of the profile as run (served profile without `model` and `mcp`). */\n profileDigest: string\n /** The model the app runs in production, replaced by the target's harness model. */\n productionModel: unknown\n /** The app's own MCP servers, which need the app's deployment and are not mounted. */\n omittedMcp: string[]\n}\n\n/**\n * Agent apps a benchmark can target, each by the executable AgentProfile it serves in production: the projection its own\n * sandbox sends a harness (gtm-agent toExecutableAgentProfile, legal-agent slimSandboxProfile). `AGENT_BENCH_APPS`, a JSON\n * object of app name to profile URL or absolute file path, adds an app or points one at another source: a staging deployment,\n * a profile exported from a checkout, or a candidate profile an optimizer is scoring.\n */\nexport const AGENT_APPS: Readonly<Record<string, { profileUrl: string }>> = {\n 'gtm-agent': { profileUrl: 'https://gtm.tangle.tools/api/tools/profile?definition=executable' },\n 'legal-agent': { profileUrl: 'https://legal.tangle.tools/api/tools/profile?definition=executable' },\n}\n\nfunction agentApps(env: NodeJS.ProcessEnv): Record<string, { profileUrl: string }> {\n if (!env.AGENT_BENCH_APPS) return { ...AGENT_APPS }\n const extra = JSON.parse(env.AGENT_BENCH_APPS) as unknown\n if (!extra || typeof extra !== 'object' || Array.isArray(extra) || !Object.values(extra).every((url) => typeof url === 'string')) {\n throw new Error('AGENT_BENCH_APPS must be a JSON object of app name to profile URL or absolute file path')\n }\n return { ...AGENT_APPS, ...Object.fromEntries(Object.entries(extra as Record<string, string>).map(([name, profileUrl]) => [name, { profileUrl }])) }\n}\n\nexport interface PublishedRunOptions {\n /** Run this many tasks in the publisher's order (a sample, never a full official run unless asked). */\n tasks?: number\n /** Run exactly these publisher task ids. */\n taskIds?: string[]\n /** Extra arguments passed to the publisher's runner unchanged, after the ones this registry sets. */\n args?: string[]\n /** Where the publisher's result file and this run's record are written. */\n out: string\n env?: NodeJS.ProcessEnv\n /** Where publisher checkouts are cached; defaults to ~/.cache/agent-bench/published. */\n cacheDir?: string\n /**\n * Replace the publisher's judge with `bridge/<harness/model>`, a model on a subscription seat behind a CLI Bridge\n * (AGENT_BENCH_JUDGE_URL, default the profile Bridge). The run is then not official, and its record says so.\n */\n judge?: string\n /** The agent-eval RunRecord identity each task row carries; defaults: experiment `<benchmark>@<ref>`, candidate the target, split holdout. */\n record?: { experimentId?: string; candidateId?: string; splitTag?: 'search' | 'dev' | 'holdout' }\n}\n\n/** One task's score; `raw` carries the publisher's numeric per-task detail (Harvey LAB: `crit.<id>` 1|0, criteria counts). */\nexport interface PublishedTaskScore {\n id: string\n passed: boolean\n score: number\n notes?: string\n raw?: Record<string, number>\n /** Observed provider counters retained by the publisher. A subtotal keeps tokensKnown false. */\n tokenUsage?: RunRecord['tokenUsage']\n}\n\nfunction nonnegativeCounter(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0\n ? value\n : undefined\n}\n\nfunction nonnegativeMeasurement(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined\n}\n\nexport interface PublishedBenchmark {\n name: string\n repository: string\n /** The exact publisher commit; a moved tag cannot change a recorded number. */\n ref: string\n version: string\n license: string\n terms: string\n /** The judge model the publisher names, or null when the publisher's grader is deterministic. */\n judge: string | null\n /** The benchmark's runner accepts a substituted judge (`--judge`). */\n judgeSubstitutable?: boolean\n /** Why no run of this entry is official, when the publisher reports from an implementation it does not release. */\n unofficial?: string\n measured: Measured\n /** The runner writes a folder of results rather than one file. */\n resultIsFolder?: boolean\n install: string[][]\n run(endpoint: Endpoint, options: PublishedRunOptions, resultPath: string): string[]\n /** Read the publisher's result (a file or a folder) into one score per task, as the publisher's grader reported it. */\n parse(resultPath: string): Promise<PublishedTaskScore[]>\n}\n\nexport interface PublishedRun {\n benchmark: string\n version: string\n ref: string\n target: string\n model: string\n measured: Measured\n judge: string | null\n /** The judge the publisher names, kept beside a substituted one. */\n publisherJudge: string | null\n /** True when the score comes from the publisher's own grader and judge; false whenever a judge was substituted. */\n official: boolean\n /** Why the entry is never official (`PublishedBenchmark.unofficial`). */\n unofficial?: string\n app?: AppProfile\n tasks: number\n passed: number\n /** Mean task score, 0..1, as the publisher's grader reports it. */\n score: number\n taskScores: PublishedTaskScore[]\n resultPath: string\n /** One agent-eval RunRecord per task (JSON lines), for the ledgers, dashboards and promotion gates every other run feeds. */\n runRecords: string\n license: string\n terms: string\n startedAt: string\n finishedAt: string\n}\n\nexport const PUBLISHED_BENCHMARKS: Readonly<Record<string, PublishedBenchmark>> = {\n automationbench: {\n name: 'automationbench',\n repository: 'https://github.com/zapier/AutomationBench.git',\n ref: '4a8e1061254004d9dac807054eed33fad7d1ff14',\n version: '1.0.6',\n license: 'MIT (Zapier, Inc.); third-party API schemas excluded',\n terms: 'MIT: tasks and code may be redistributed with attribution',\n judge: null,\n measured: 'model-shaped',\n install: [['uv', 'sync', '--frozen']],\n run: (endpoint, options, resultPath) => [\n 'uv', 'run', 'auto-bench',\n '--model', endpoint.model, '--base-url', endpoint.baseUrl, '--api-key-var', endpoint.apiKeyVar,\n ...(options.taskIds?.length ? ['--tasks', options.taskIds.join(',')] : []),\n ...(options.tasks === undefined ? [] : ['--num-examples', String(options.tasks)]),\n '--max-concurrent', String(Math.max(1, Math.min(options.tasks ?? options.taskIds?.length ?? 4, 4))),\n '--export-json', resultPath,\n ...(options.args ?? []),\n ],\n parse: async (resultPath) => {\n const tasks = (JSON.parse(await readFile(resultPath, 'utf8')) as { tasks?: Array<Record<string, unknown>> }).tasks\n if (!Array.isArray(tasks)) throw new Error('AutomationBench result has no tasks array')\n return tasks.map((task) => {\n if (typeof task.name !== 'string' || typeof task.score !== 'number' || typeof task.passed !== 'boolean') {\n throw new Error(`AutomationBench task result is malformed: ${JSON.stringify(task).slice(0, 200)}`)\n }\n // This export can fall back to counting text characters. Its pricing is also calculated by\n // the publisher. Keep these fields with the score without attesting provider usage or billing.\n const raw: Record<string, number> = {}\n const counters = {\n publisherInputTokens: task.input_tokens,\n publisherOutputTokens: task.output_tokens,\n publisherCachedInputTokens: task.cached_input_tokens,\n publisherReasoningTokens: task.reasoning_tokens,\n publisherModelCalls: task.num_model_calls,\n }\n for (const [key, counter] of Object.entries(counters)) {\n const value = nonnegativeCounter(counter)\n if (value !== undefined) raw[key] = value\n }\n const estimate = nonnegativeMeasurement(task.cost)\n if (estimate !== undefined) raw.publisherEstimatedCostUsd = estimate\n return {\n id: task.name, passed: task.passed, score: task.score,\n ...(Object.keys(raw).length && { raw }),\n }\n })\n },\n },\n 'enterpriseops-gym': {\n name: 'enterpriseops-gym',\n repository: 'https://github.com/ServiceNow/EnterpriseOps-Gym.git',\n ref: '271f2c357f763376997dfd16807fcde2474ae41b',\n version: '271f2c3 (no release tag)',\n license: 'Apache-2.0 (ServiceNow; code and the ServiceNow-AI/EnterpriseOps-Gym dataset)',\n terms: 'Apache-2.0: tasks may be redistributed with attribution',\n judge: null,\n measured: 'model-shaped',\n resultIsFolder: true,\n install: [['uv', 'sync', '--extra', 'openai'], ['python3', '-c', \"import zipfile; zipfile.ZipFile('gym_dbs.zip').extractall('.')\"]],\n // A sample runs `--task` ids or the first --tasks of the domain (default teams, mode oracle; pass `-- --domain d --mode m`).\n run: (endpoint, options, resultPath) => [\n 'sh', fileURLToPath(new URL('../scripts/enterpriseops-gym-run.sh', import.meta.url)),\n resultPath, endpoint.baseUrl, endpoint.model, endpoint.apiKeyVar,\n options.tasks === undefined ? 'all' : String(options.tasks), (options.taskIds ?? []).join(','),\n ...(options.args ?? []),\n ],\n parse: async (resultPath) => {\n const folder = path.join(resultPath, 'run_1')\n const files = (await readdir(folder)).filter((file) => file.startsWith('results_') && file.endsWith('.json')).sort()\n if (!files.length) throw new Error(`EnterpriseOps-Gym wrote no task results under ${folder}`)\n return Promise.all(files.map(async (file) => {\n const result = JSON.parse(await readFile(path.join(folder, file), 'utf8')) as {\n statistics?: { overall_success_rate?: unknown; verifier_level_pass_rate?: unknown }; runs?: Array<{ error?: unknown }>\n }\n const success = result.statistics?.overall_success_rate\n const verifiers = result.statistics?.verifier_level_pass_rate\n if (typeof success !== 'number') throw new Error(`EnterpriseOps-Gym result ${file} has no statistics.overall_success_rate`)\n const error = result.runs?.find((run) => run.error)?.error\n return {\n id: file.slice('results_'.length, -'.json'.length).split('__').pop()!, passed: success === 1, score: success,\n notes: `verifier pass rate ${typeof verifiers === 'number' ? verifiers : 'unknown'}${error ? `; runner error: ${String(error).slice(0, 200)}` : ''}`,\n }\n }))\n },\n },\n 'harvey-lab': {\n name: 'harvey-lab',\n repository: 'https://github.com/harveyai/harvey-labs.git',\n // v1.3.0, the latest tag: v1.0 has no OpenAI-compatible chat adapter; v1.3.0 ships baseten/ (chat completions with tools).\n ref: '81d6a31b22d7c9f661cda4770cffcc12a5735dc2',\n version: 'v1.3.0',\n license: 'MIT (Harvey AI)',\n terms: 'MIT: tasks and their synthetic documents ship in the repository; no training or redistribution restriction stated',\n judge: 'claude-sonnet-4-6 + gpt-5.5 (LAB standard dual judge, all-pass per criterion)',\n judgeSubstitutable: true,\n measured: 'model-shaped',\n resultIsFolder: true,\n install: [\n ['uv', 'sync', '--all-extras'],\n // The publisher's own pinned pandoc, which its grader needs for .docx deliverables, into the checkout.\n ['sh', 'lab_core/sandbox/install_pandoc.sh', '.agent-bench'],\n ['sh', fileURLToPath(new URL('../scripts/harvey-lab-sandbox.sh', import.meta.url))],\n ],\n // A sample runs --task ids or the first --tasks in sorted task-id order (pass `-- --area <practice area>` to stay in one).\n run: (endpoint, options, resultPath) => [\n 'sh', fileURLToPath(new URL('../scripts/harvey-lab-run.sh', import.meta.url)),\n resultPath, endpoint.baseUrl, endpoint.model, endpoint.apiKeyVar,\n options.tasks === undefined ? 'all' : String(options.tasks), (options.taskIds ?? []).join(','), options.judge ?? 'publisher',\n ...(options.args ?? []),\n ],\n parse: async (resultPath) => {\n const runs = (await readFile(path.join(resultPath, 'tasks.tsv'), 'utf8')).trim().split('\\n').map((line) => line.split('\\t') as [string, string])\n return Promise.all(runs.map(async ([run, task]) => {\n const read = (file: string) => readFile(path.join(resultPath, run, file), 'utf8').then((text) => JSON.parse(text) as Record<string, unknown>, () => null)\n const metrics = await read('metrics.json')\n const input = nonnegativeCounter(metrics?.input_tokens)\n const output = nonnegativeCounter(metrics?.output_tokens)\n const agentSeconds = nonnegativeMeasurement(metrics?.wall_clock_seconds)\n const raw = agentSeconds === undefined ? undefined : { publisherAgentWallMs: agentSeconds * 1_000 }\n // The publisher retains supported response counters, without a per-call completeness flag.\n const telemetry: Pick<PublishedTaskScore, 'tokenUsage' | 'raw'> = {\n ...(raw && { raw }),\n ...(input !== undefined && output !== undefined && {\n tokenUsage: { input, output, tokensKnown: false },\n }),\n }\n const dual = await read('scores_dual.json')\n if (dual) return { id: task, passed: dual.all_pass === true, score: Number(dual.dual_all_pass_rate), notes: `dual-judge criterion pass ${String(dual.dual_criterion_pass)}`, ...telemetry }\n const single = await read('scores.json')\n if (single) {\n const criteria = Array.isArray(single.criteria_results) ? single.criteria_results as Array<{ id?: unknown; verdict?: unknown }> : []\n return { id: task, passed: single.all_pass === true, score: single.all_pass === true ? 1 : 0,\n notes: `${String(single.n_passed)} of ${String(single.n_criteria)} criteria passed${single.n_grading_errors ? `; ${String(single.n_grading_errors)} grading errors` : ''}`,\n ...telemetry,\n raw: { ...raw, criteria_passed: Number(single.n_passed) || 0, criteria_total: Number(single.n_criteria) || 0,\n ...Object.fromEntries(criteria.filter((c) => typeof c.id === 'string').map((c) => [`crit.${String(c.id)}`, c.verdict === 'pass' ? 1 : 0])) } }\n }\n return { id: task, passed: false, score: 0, notes: 'no scores: the harness or the grader failed (see the runner log)', ...telemetry }\n }))\n },\n },\n prbench: {\n name: 'prbench',\n repository: 'https://github.com/scaleapi/PRBench.git',\n ref: '7b2df0a28bf99ec51263c41b90dd510a740a7711',\n version: '7b2df0a (no release tag)',\n license: 'MIT (Scale AI); dataset ScaleAI/PRBench CC-BY-4.0',\n terms: 'CC-BY-4.0 dataset, not gated, loaded from Hugging Face at run time; attribution required, no training restriction stated',\n judge: 'openai/o4-mini (reasoning effort high), one call per rubric criterion',\n judgeSubstitutable: true,\n measured: 'model-shaped',\n resultIsFolder: true,\n // The publisher pins no dependency versions (requirements.txt), so a fresh install resolves them anew.\n install: [['uv', 'venv', '--quiet', '--python', '3.12'], ['uv', 'pip', 'install', '--quiet', '-r', 'requirements.txt']],\n // A sample runs --task ids or the first --tasks rows of the split (default legal; pass `-- --split finance`).\n run: (endpoint, options, resultPath) => [\n 'sh', fileURLToPath(new URL('../scripts/prbench-run.sh', import.meta.url)),\n resultPath, endpoint.baseUrl, endpoint.model, endpoint.apiKeyVar,\n options.tasks === undefined ? 'all' : String(options.tasks), (options.taskIds ?? []).join(','), options.judge ?? 'publisher',\n ...(options.args ?? []),\n ],\n // Per task, the publisher's clipped score: rubric points over the positive weights (negative criteria can take it below\n // zero; clamped to 0..1 here). The publisher's aggregate, mean_clipped, is max(0, mean of the unclamped scores).\n parse: async (resultPath) => {\n const folder = path.join(resultPath, 'results')\n const files = (await readdir(folder)).filter((file) => file.endsWith('.json'))\n if (files.length !== 1) throw new Error(`PRBench wrote ${files.length} result files under ${folder}, expected one`)\n const result = JSON.parse(await readFile(path.join(folder, files[0]!), 'utf8')) as { outputs?: Record<string, Record<string, { points?: unknown; weights?: unknown }>> }\n const tasks = Object.values(result.outputs ?? {})[0]\n if (!tasks) throw new Error(`PRBench result ${files[0]} has no outputs`)\n return Object.entries(tasks).map(([id, task]) => {\n const weights = Array.isArray(task.weights) ? task.weights.filter((weight): weight is number => typeof weight === 'number') : []\n const best = weights.filter((weight) => weight > 0).reduce((sum, weight) => sum + weight, 0)\n const points = typeof task.points === 'number' ? task.points : Number.NaN\n if (!best || Number.isNaN(points)) throw new Error(`PRBench task ${id} has no points or weights`)\n return { id, passed: points >= best, score: Math.min(1, Math.max(0, points / best)), notes: `${points} of ${best} rubric points` }\n })\n },\n },\n 'healthbench-professional': {\n name: 'healthbench-professional',\n repository: 'https://github.com/openai/simple-evals.git',\n ref: '652c89d0ca9df547706735883097e9537d40dc47',\n version: '652c89d (no release tag), data openai/healthbench-professional@349962fd',\n license: 'MIT (OpenAI simple-evals); dataset openai/healthbench-professional MIT',\n terms: 'MIT dataset, not gated, fetched from Hugging Face at the pinned revision at run time and never committed: the authors ask that examples not be revealed in plain text or images online. No training restriction stated.',\n judge: 'gpt-5.4-2026-03-05 (reasoning effort low), one call per rubric item; length-adjusted (center 2000 characters, 1.47 points per 500)',\n judgeSubstitutable: true,\n unofficial: 'OpenAI reports HealthBench Professional from an internal implementation it does not release; simple-evals with its Professional settings is the reference implementation',\n measured: 'model-shaped',\n resultIsFolder: true,\n // The publisher pins no dependency versions and ships no requirements file; these are the imports HealthBenchEval needs.\n install: [['uv', 'venv', '--quiet', '--python', '3.12'], ['uv', 'pip', 'install', '--quiet', 'openai', 'blobfile', 'numpy', 'pandas', 'jinja2', 'requests', 'tqdm']],\n // A sample runs the publisher's seeded sample of --tasks examples, or the --task ids.\n run: (endpoint, options, resultPath) => [\n 'sh', fileURLToPath(new URL('../scripts/healthbench-professional-run.sh', import.meta.url)),\n resultPath, endpoint.baseUrl, endpoint.model, endpoint.apiKeyVar,\n options.tasks === undefined ? 'all' : String(options.tasks), (options.taskIds ?? []).join(','), options.judge ?? 'publisher',\n ...(options.args ?? []),\n ],\n // Per task, the publisher's length-adjusted rubric score, clamped to 0..1 (the publisher clips the mean, not each task).\n // Passed: every positive criterion met and no negative one.\n parse: async (resultPath) => {\n const result = JSON.parse(await readFile(path.join(resultPath, 'result.json'), 'utf8')) as {\n examples?: Array<{ prompt_id: string; overall_score: number; length_adjusted: number; response_chars: number; positive_met: number; positive_total: number; negative_met: number }>\n }\n if (!result.examples?.length) throw new Error(`HealthBench Professional wrote no examples under ${resultPath}`)\n return result.examples.map((example) => ({\n id: example.prompt_id,\n passed: example.positive_met === example.positive_total && example.negative_met === 0,\n score: Math.min(1, Math.max(0, example.length_adjusted)),\n notes: `${example.positive_met} of ${example.positive_total} positive criteria met, ${example.negative_met} negative met; rubric score ${example.overall_score.toFixed(3)}, length-adjusted for ${example.response_chars} characters`,\n raw: {\n overall_score: example.overall_score, length_adjusted: example.length_adjusted, response_chars: example.response_chars,\n positive_met: example.positive_met, positive_total: example.positive_total, negative_met: example.negative_met,\n },\n }))\n },\n },\n mlcr: {\n name: 'mlcr',\n repository: 'https://github.com/Wisedocs-AI/medical-long-context-reasoning.git',\n ref: 'ca822de2d274184bb0cd5bf280ff917922f3716f',\n version: 'v1.1 (ca822de, the release commit; no tag), data Wisedocs/mlcr-dataset@1198206e',\n license: 'none: neither the code nor the Wisedocs/mlcr-dataset release carries a license (the dataset card says \"other\")',\n terms: 'No license: run locally for evaluation only, never committed, redistributed, or used for training or prompt optimization. The dataset is not gated and is fetched from Hugging Face at the pinned revision at run time.',\n // A substituted judge sits all three jury seats, each sampling independently, so the publisher's two-of-three rule applies.\n judge: \"jury of gemini-3.1-pro-preview, claude-opus-4-8-gcp and gpt-5.5 (majority vote, medium thinking) on the publisher's Vertex, Anthropic-on-GCP and Azure OpenAI providers, after a conciseness gate\",\n judgeSubstitutable: true,\n measured: 'model-shaped',\n resultIsFolder: true,\n install: [['uv', 'venv', '--quiet', '--python', '3.12'], ['uv', 'pip', 'install', '--quiet', '-e', '.[all]']],\n // A sample is the runner's first --tasks rows of the publisher's smoke experiment; MLCR names rows by matrix cell, not id.\n run: (endpoint, options, resultPath) => [\n 'sh', fileURLToPath(new URL('../scripts/mlcr-run.sh', import.meta.url)),\n resultPath, endpoint.baseUrl, endpoint.model, endpoint.apiKeyVar,\n options.tasks === undefined ? 'all' : String(options.tasks), (options.taskIds ?? []).join(','), options.judge ?? 'publisher',\n ...(options.args ?? []),\n ],\n // Per row, the jury's verdict: correct (complete and accurate by majority) after the conciseness gate.\n parse: async (resultPath) => {\n const result = JSON.parse(await readFile(path.join(resultPath, 'result.json'), 'utf8')) as {\n examples?: Array<{ id: string; concise: string; complete: string; accurate: string; correct: string; judge_error: boolean; response_chars: number }>\n }\n if (!result.examples?.length) throw new Error(`MLCR wrote no scored rows under ${resultPath}`)\n const verdict = (value: string) => (value === '' ? undefined : Number(value))\n return result.examples.map((example) => {\n if (example.correct === '') throw new Error(`MLCR row ${example.id} has no jury verdict${example.judge_error ? ' (the judge failed)' : ''}`)\n const raw = Object.fromEntries(Object.entries({ concise: verdict(example.concise), complete: verdict(example.complete), accurate: verdict(example.accurate), correct: verdict(example.correct) })\n .filter((entry): entry is [string, number] => entry[1] !== undefined))\n return {\n id: example.id, passed: example.correct === '1', score: example.correct === '1' ? 1 : 0,\n notes: `concise ${example.concise || '-'}, complete ${example.complete || '-'}, accurate ${example.accurate || '-'}; ${example.response_chars} characters`,\n raw: { ...raw, response_chars: example.response_chars },\n }\n })\n },\n },\n}\n\n/** Resolve a `model:`, `app:` or `profile:` target to the endpoint a publisher's runner calls. */\nexport async function resolveEndpoint(target: string, benchmark: PublishedBenchmark, env: NodeJS.ProcessEnv = process.env): Promise<Endpoint> {\n const match = /^(model|app|profile):(.+)$/.exec(target)\n if (!match) throw new Error(`target must be model:<router model>, app:<agent app>@<harness/model> or profile:<harness/model>, not '${target}'`)\n const [, kind, id] = match as unknown as [string, 'model' | 'app' | 'profile', string]\n if (kind === 'model') {\n return { target, model: id, baseUrl: env.AGENT_BENCH_ROUTER_URL ?? 'https://router.tangle.tools/v1', apiKeyVar: 'TANGLE_API_KEY', measured: benchmark.measured }\n }\n // A loopback Bridge without a bearer accepts any key; the runner still needs one to send.\n const bridge = env.AGENT_BENCH_BRIDGE_URL ?? 'http://127.0.0.1:3344/v1'\n if (kind === 'profile') return { target, model: id, baseUrl: bridge, apiKeyVar: 'AGENT_BENCH_BRIDGE_KEY', measured: 'own-loop' }\n const at = id.indexOf('@')\n const [name, harness] = at === -1 ? [id, ''] : [id.slice(0, at), id.slice(at + 1)]\n const apps = agentApps(env)\n const app = apps[name]\n if (!app) throw new Error(`no agent app '${name}'; registered: ${Object.keys(apps).join(', ')} (add one with AGENT_BENCH_APPS)`)\n if (!harness) throw new Error(`app:${name} needs @<harness/model>, the subscription harness that runs the app's profile, e.g. app:${name}@opencode/zai-coding-plan/glm-5.3`)\n const catalog = env.AGENT_BENCH_BRIDGE_PROFILES_DIR\n if (!catalog) throw new Error(`AGENT_BENCH_BRIDGE_PROFILES_DIR is not set: point it at the CLI Bridge's SANDBOX_PROFILES_DIR, where app:${name} writes its profile`)\n const { mcp, model, ...profile } = await readAppProfile(name, app.profileUrl)\n const text = JSON.stringify(profile)\n const digest = createHash('sha256').update(text).digest('hex')\n // Content-addressed: the Bridge rereads its catalog only for an id it does not know.\n const profileId = `${name}-${digest.slice(0, 12)}`\n await mkdir(catalog, { recursive: true })\n await writeFile(path.join(catalog, `${profileId}.json`), text)\n return {\n target, model: harness, baseUrl: `${bridge.replace(/\\/v1\\/?$/, '')}/profiles/${profileId}/v1`, apiKeyVar: 'AGENT_BENCH_BRIDGE_KEY', measured: 'own-loop',\n app: {\n app: name, profileUrl: app.profileUrl, profileDigest: `sha256:${digest}`, productionModel: model ?? null,\n profileName: typeof profile.name === 'string' ? profile.name : null, profileVersion: typeof profile.version === 'string' ? profile.version : null,\n omittedMcp: mcp && typeof mcp === 'object' ? Object.keys(mcp) : [],\n },\n }\n}\n\n/** An app's profile from its URL, or from an absolute file path. */\nasync function readAppProfile(name: string, source: string): Promise<Record<string, unknown>> {\n if (path.isAbsolute(source)) return JSON.parse(await readFile(source, 'utf8')) as Record<string, unknown>\n const response = await fetch(source)\n if (!response.ok) throw new Error(`${source} answered ${response.status}; app:${name} needs the profile the app serves`)\n return await response.json() as Record<string, unknown>\n}\n\n/** Run one published benchmark against one target with the publisher's runner and grader, and record the result. */\nexport async function runPublished(name: string, target: string, options: PublishedRunOptions): Promise<PublishedRun> {\n const benchmark = PUBLISHED_BENCHMARKS[name]\n if (!benchmark) throw new Error(`no published benchmark '${name}'; registered: ${Object.keys(PUBLISHED_BENCHMARKS).join(', ')}`)\n const env = { ...process.env, ...options.env }\n if (options.judge !== undefined && !benchmark.judgeSubstitutable) {\n throw new Error(`${benchmark.name} grades ${benchmark.judge === null ? 'deterministically' : `with ${benchmark.judge}`}; this registry cannot substitute its judge`)\n }\n if (options.judge !== undefined && !options.judge.startsWith('bridge/')) throw new Error(`--judge must be bridge/<harness/model>, not '${options.judge}'`)\n env.AGENT_BENCH_JUDGE_URL ??= env.AGENT_BENCH_BRIDGE_URL ?? 'http://127.0.0.1:3344/v1'\n const endpoint = await resolveEndpoint(target, benchmark, env)\n if (!env[endpoint.apiKeyVar]) throw new Error(`${endpoint.apiKeyVar} is not set; the ${target} endpoint needs it`)\n const checkout = await publisherCheckout(benchmark, options.cacheDir, env)\n await mkdir(options.out, { recursive: true })\n const resultPath = path.resolve(options.out, `${benchmark.name}-result${benchmark.resultIsFolder ? '' : '.json'}`)\n const startedAt = new Date().toISOString()\n const [command, ...args] = benchmark.run(endpoint, options, resultPath)\n await execute(command!, args, checkout, env)\n const taskScores = await benchmark.parse(resultPath)\n const run: PublishedRun = {\n benchmark: benchmark.name, version: benchmark.version, ref: benchmark.ref, target, model: endpoint.model,\n measured: endpoint.measured, judge: options.judge ?? benchmark.judge, publisherJudge: benchmark.judge,\n official: options.judge === undefined && benchmark.unofficial === undefined,\n ...(benchmark.unofficial ? { unofficial: benchmark.unofficial } : {}),\n ...(endpoint.app ? { app: endpoint.app } : {}),\n tasks: taskScores.length, passed: taskScores.filter((task) => task.passed).length,\n score: taskScores.length ? taskScores.reduce((sum, task) => sum + task.score, 0) / taskScores.length : 0,\n taskScores, resultPath, runRecords: path.resolve(options.out, `${benchmark.name}-runrecords.jsonl`),\n license: benchmark.license, terms: benchmark.terms, startedAt, finishedAt: new Date().toISOString(),\n }\n await writeFile(run.runRecords, runRecords(run, options).map((record) => JSON.stringify(record)).join('\\n') + '\\n')\n await writeFile(path.resolve(options.out, `${benchmark.name}-run.json`), `${JSON.stringify(run, null, 2)}\\n`)\n return run\n}\n\n/**\n * One agent-eval RunRecord per task, validated by agent-eval's own validator. Preserve an observed publisher subtotal\n * and leave missing provider bills unknown. A RunRecord's model must name a served snapshot; a subscription harness\n * reports none, and a snapshot invented from the date would be false, so such rows record `unknown` with terminal outcome\n * `unknown` and keep the requested model in `candidateId`. A pinned model id (a Router snapshot) is recorded as served.\n */\nfunction runRecords(run: PublishedRun, options: PublishedRunOptions): RunRecord[] {\n const split = options.record?.splitTag ?? 'holdout'\n const sha = (value: string) => `sha256:${createHash('sha256').update(value).digest('hex')}`\n const configHash = sha(canonicalJson({ benchmark: run.benchmark, ref: run.ref, target: run.target, judge: run.judge, args: options.args ?? [] }))\n return run.taskScores.map((task) => {\n const row = {\n runId: randomUUID(), experimentId: options.record?.experimentId ?? `${run.benchmark}@${run.ref}`,\n candidateId: options.record?.candidateId ?? run.target, seed: 0, model: run.model,\n // The publisher owns the prompt; an app run's prompt is its profile.\n promptHash: run.app?.profileDigest ?? sha(run.target), configHash, commitSha: run.ref,\n wallMs: Math.max(0, Date.parse(run.finishedAt) - Date.parse(run.startedAt)),\n costUsd: null, costProvenance: { kind: 'uncaptured', usd: null },\n tokenUsage: task.tokenUsage ?? { input: 0, output: 0, tokensKnown: false },\n terminalOutcome: 'succeeded',\n outcome: { [split === 'holdout' ? 'holdoutScore' : 'searchScore']: task.score, raw: { passed: task.passed ? 1 : 0, ...task.raw } },\n splitTag: split, scenarioId: `${run.benchmark}:${task.id}`,\n }\n try {\n return validateRunRecord(row)\n } catch (error) {\n if (!(error instanceof RunRecordValidationError) || error.path !== 'model') throw error\n return validateRunRecord({ ...row, model: UNKNOWN_MODEL, terminalOutcome: 'unknown' })\n }\n })\n}\n\n/** The publisher's repository at the pinned commit, installed once per cache. */\nasync function publisherCheckout(benchmark: PublishedBenchmark, cacheDir: string | undefined, env: NodeJS.ProcessEnv): Promise<string> {\n const root = cacheDir ?? path.join(homedir(), '.cache', 'agent-bench', 'published')\n const dir = path.join(root, `${benchmark.name}@${benchmark.ref}`)\n const installed = path.join(dir, '.agent-bench-installed')\n if (existsSync(installed)) return dir\n if (!existsSync(path.join(dir, '.git'))) {\n await mkdir(root, { recursive: true })\n await execute('git', ['clone', '--quiet', '--filter=blob:none', '--no-checkout', benchmark.repository, dir], root, env)\n }\n await execute('git', ['checkout', '--quiet', '--detach', benchmark.ref], dir, env)\n for (const [command, ...args] of benchmark.install) await execute(command!, args, dir, env)\n await writeFile(installed, `${benchmark.ref}\\n`)\n return dir\n}\n\nfunction execute(command: string, args: string[], cwd: string, env: NodeJS.ProcessEnv): Promise<void> {\n return new Promise((resolve, reject) => {\n const child = spawn(command, args, { cwd, env, stdio: 'inherit' })\n child.once('error', (error) => reject(new Error(`${command} could not start in ${cwd}: ${error.message}`)))\n child.once('exit', (code, signal) => code === 0\n ? resolve()\n : reject(new Error(`${command} ${args.slice(0, 3).join(' ')} exited ${signal ?? code} in ${cwd}`)))\n })\n}\n","#!/usr/bin/env node\n/**\n * agent-bench run <benchmark> --target <model:|app:|profile:> [--tasks N] [--task <publisher task id>]... [--out <dir>] [-- <runner args>]\n * agent-bench list\n *\n * Runs a published benchmark with its publisher's own runner and grader (src/published.ts), prints the score with what it\n * measured, and writes the run record to --out (default ./agent-bench-runs/<benchmark>-<time>).\n */\nimport path from 'node:path'\nimport { PUBLISHED_BENCHMARKS, runPublished } from './published'\n\nconst usage = 'usage: agent-bench run <benchmark> --target <model:<router model>|app:<agent app>@<harness/model>|profile:<harness/model>> [--tasks N] [--task <id>]... [--judge bridge/<harness/model>] [--experiment <id>] [--candidate <id>] [--split search|dev|holdout] [--out <dir>] [-- <runner args>]\\n agent-bench list'\n\nasync function main(argv: string[]): Promise<number> {\n const [command, ...rest] = argv\n if (command === 'list') {\n for (const benchmark of Object.values(PUBLISHED_BENCHMARKS)) {\n console.log(`${benchmark.name} ${benchmark.version} ${benchmark.repository}@${benchmark.ref.slice(0, 12)} ${benchmark.measured} judge=${benchmark.judge ?? 'deterministic'} license=${benchmark.license}`)\n }\n return 0\n }\n if (command !== 'run' || !rest[0] || rest[0].startsWith('-')) {\n console.error(usage)\n return 2\n }\n const name = rest[0]\n const separator = rest.indexOf('--')\n const own = separator === -1 ? rest.slice(1) : rest.slice(1, separator)\n const runnerArgs = separator === -1 ? [] : rest.slice(separator + 1)\n let target: string | undefined\n let tasks: number | undefined\n const taskIds: string[] = []\n let out: string | undefined\n let judge: string | undefined\n const record: { experimentId?: string; candidateId?: string; splitTag?: 'search' | 'dev' | 'holdout' } = {}\n for (let i = 0; i < own.length; i++) {\n const flag = own[i]\n const value = own[i + 1]\n if (value === undefined) throw new Error(`${flag} needs a value\\n${usage}`)\n if (flag === '--target') target = value\n else if (flag === '--tasks') tasks = Number.parseInt(value, 10)\n else if (flag === '--task') taskIds.push(value)\n else if (flag === '--out') out = value\n else if (flag === '--judge') judge = value\n else if (flag === '--experiment') record.experimentId = value\n else if (flag === '--candidate') record.candidateId = value\n else if (flag === '--split') record.splitTag = value as 'search' | 'dev' | 'holdout'\n else throw new Error(`unknown option ${flag}\\n${usage}`)\n i++\n }\n if (!target) throw new Error(`--target is required\\n${usage}`)\n if (tasks !== undefined && !(Number.isSafeInteger(tasks) && tasks > 0)) throw new Error('--tasks must be a positive integer')\n const run = await runPublished(name, target, {\n ...(tasks === undefined ? {} : { tasks }),\n ...(taskIds.length ? { taskIds } : {}),\n ...(judge === undefined ? {} : { judge }),\n ...(Object.keys(record).length ? { record } : {}),\n args: runnerArgs,\n out: path.resolve(out ?? path.join('agent-bench-runs', `${name}-${new Date().toISOString().replace(/[:.]/g, '-')}`)),\n })\n console.log(`${run.benchmark} ${run.version} on ${run.target}: ${run.passed} of ${run.tasks} passed, score ${run.score.toFixed(3)}, measured ${run.measured}, judge ${run.judge === null ? 'deterministic' : run.judge} (${run.official ? 'official' : `${[run.judge !== run.publisherJudge ? `substituted for ${run.publisherJudge}` : undefined, run.unofficial].filter(Boolean).join('; ')}, not official`})`)\n if (run.app) {\n console.log(`app: ${run.app.app} profile ${run.app.profileName ?? '?'} ${run.app.profileVersion ?? ''} ${run.app.profileDigest.slice(0, 19)} from ${run.app.profileUrl}; ` +\n `its production model ${JSON.stringify(run.app.productionModel)} replaced by ${run.model}; its MCP servers not mounted: ${run.app.omittedMcp.join(', ') || 'none'}`)\n }\n console.log(`record: ${path.join(path.dirname(run.resultPath), `${run.benchmark}-run.json`)}`)\n console.log(`run records: ${run.runRecords}`)\n return 0\n}\n\nmain(process.argv.slice(2)).then((code) => process.exit(code), (error: unknown) => {\n console.error(error instanceof Error ? error.message : String(error))\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,MAAa,aAA+D;CAC1E,aAAa,EAAE,YAAY,mEAAmE;CAC9F,eAAe,EAAE,YAAY,qEAAqE;AACpG;AAEA,SAAS,UAAU,KAAgE;CACjF,IAAI,CAAC,IAAI,kBAAkB,OAAO,EAAE,GAAG,WAAW;CAClD,MAAM,QAAQ,KAAK,MAAM,IAAI,gBAAgB;CAC7C,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,KAAK,CAAC,OAAO,OAAO,KAAK,CAAC,CAAC,OAAO,QAAQ,OAAO,QAAQ,QAAQ,GAC7H,MAAM,IAAI,MAAM,yFAAyF;CAE3G,OAAO;EAAE,GAAG;EAAY,GAAG,OAAO,YAAY,OAAO,QAAQ,KAA+B,CAAC,CAAC,KAAK,CAAC,MAAM,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;CAAE;AACrJ;AAkCA,SAAS,mBAAmB,OAAoC;CAC9D,OAAO,OAAO,UAAU,YAAY,OAAO,cAAc,KAAK,KAAK,SAAS,IACxE,QACA,KAAA;AACN;AAEA,SAAS,uBAAuB,OAAoC;CAClE,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,SAAS,IAAI,QAAQ,KAAA;AACrF;AAsDA,MAAa,uBAAqE;CAChF,iBAAiB;EACf,MAAM;EACN,YAAY;EACZ,KAAK;EACL,SAAS;EACT,SAAS;EACT,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS,CAAC;GAAC;GAAM;GAAQ;EAAU,CAAC;EACpC,MAAM,UAAU,SAAS,eAAe;GACtC;GAAM;GAAO;GACb;GAAW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AY;CAC5C,OAAO;AACT;AAEA,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,SAAS,QAAQ,KAAK,IAAI,IAAI,UAAmB;CACjF,QAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CACpE,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1408,6 +1408,7 @@ function createPierCandidateExecutionOptions(options) {
|
|
|
1408
1408
|
context.signal.throwIfAborted();
|
|
1409
1409
|
const identity = trialIdentity(request.executionId, request.executionPlan.value.digest);
|
|
1410
1410
|
if (trials.has(identity)) throw new Error("Pier trial identity is already active");
|
|
1411
|
+
const startedAt = Date.now();
|
|
1411
1412
|
const trial = options.controller.start(staged, {
|
|
1412
1413
|
request,
|
|
1413
1414
|
traceStore: context.traceStore,
|
|
@@ -1421,9 +1422,19 @@ function createPierCandidateExecutionOptions(options) {
|
|
|
1421
1422
|
const active = { handle: trial };
|
|
1422
1423
|
trials.set(identity, active);
|
|
1423
1424
|
const result = sealPierTrialResult(await awaitAbortableTrial(trial, context.signal));
|
|
1425
|
+
const endedAt = Math.max(startedAt, Date.now());
|
|
1424
1426
|
active.result = result;
|
|
1425
1427
|
officialResults.set(request.executionId, result);
|
|
1426
|
-
|
|
1428
|
+
const capture = protectedCaptureFromPierResult(request, result.value);
|
|
1429
|
+
if (!await context.traceStore.getRun(request.trace.runId)) await context.traceStore.appendRun({
|
|
1430
|
+
runId: request.trace.runId,
|
|
1431
|
+
scenarioId: request.benchmark.task.scenario.id,
|
|
1432
|
+
startedAt,
|
|
1433
|
+
endedAt,
|
|
1434
|
+
status: capture.termination.kind === "exit" && capture.termination.exitCode === 0 ? "completed" : "failed",
|
|
1435
|
+
tags: request.trace.tags
|
|
1436
|
+
});
|
|
1437
|
+
return capture;
|
|
1427
1438
|
},
|
|
1428
1439
|
stop: async (request) => {
|
|
1429
1440
|
assertTerminationAcknowledged(await options.controller.terminateAndWait({
|