@tangle-network/agent-bench 0.4.1 → 0.4.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 +9 -0
- package/dist/adapters.d.ts +4 -11
- package/dist/adapters.js +78 -41
- package/dist/adapters.js.map +1 -1
- package/dist/benchmarks/_harness.d.ts +48 -66
- package/dist/benchmarks/_harness.js +329 -33
- package/dist/benchmarks/_harness.js.map +1 -1
- package/dist/benchmarks/aec-bench.d.ts +4 -25
- package/dist/benchmarks/aec-bench.js +242 -7
- package/dist/benchmarks/aec-bench.js.map +1 -1
- package/dist/benchmarks/agentbench.d.ts +5 -13
- package/dist/benchmarks/agentbench.js +114 -9
- package/dist/benchmarks/agentbench.js.map +1 -1
- package/dist/benchmarks/appworld.d.ts +9 -29
- package/dist/benchmarks/appworld.js +317 -12
- package/dist/benchmarks/appworld.js.map +1 -1
- package/dist/benchmarks/bfcl.d.ts +5 -15
- package/dist/benchmarks/bfcl.js +264 -9
- package/dist/benchmarks/bfcl.js.map +1 -1
- package/dist/benchmarks/cad-design.d.ts +16 -41
- package/dist/benchmarks/cad-design.js +512 -6
- package/dist/benchmarks/cad-design.js.map +1 -1
- package/dist/benchmarks/cadbench.d.ts +4 -17
- package/dist/benchmarks/cadbench.js +2 -8
- package/dist/benchmarks/cadgenbench.d.ts +4 -20
- package/dist/benchmarks/cadgenbench.js +2 -8
- package/dist/benchmarks/commit0.d.ts +5 -27
- package/dist/benchmarks/commit0.js +187 -9
- package/dist/benchmarks/commit0.js.map +1 -1
- package/dist/benchmarks/crag.d.ts +4 -12
- package/dist/benchmarks/crag.js +110 -8
- package/dist/benchmarks/crag.js.map +1 -1
- package/dist/benchmarks/dabstep.d.ts +5 -15
- package/dist/benchmarks/dabstep.js +177 -9
- package/dist/benchmarks/dabstep.js.map +1 -1
- package/dist/benchmarks/enterpriseops-gym.d.ts +5 -34
- package/dist/benchmarks/enterpriseops-gym.js +236 -9
- package/dist/benchmarks/enterpriseops-gym.js.map +1 -1
- package/dist/benchmarks/finresearchbench.d.ts +4 -13
- package/dist/benchmarks/finresearchbench.js +218 -7
- package/dist/benchmarks/finresearchbench.js.map +1 -1
- package/dist/benchmarks/finsearchcomp.d.ts +8 -39
- package/dist/benchmarks/finsearchcomp.js +267 -6
- package/dist/benchmarks/finsearchcomp.js.map +1 -1
- package/dist/benchmarks/frames.d.ts +15 -37
- package/dist/benchmarks/frames.js +408 -11
- package/dist/benchmarks/frames.js.map +1 -1
- package/dist/benchmarks/hotpotqa.d.ts +4 -24
- package/dist/benchmarks/hotpotqa.js +250 -14
- package/dist/benchmarks/hotpotqa.js.map +1 -1
- package/dist/benchmarks/humaneval.d.ts +19 -37
- package/dist/benchmarks/humaneval.js +279 -16
- package/dist/benchmarks/humaneval.js.map +1 -1
- package/dist/benchmarks/mind2web.d.ts +7 -34
- package/dist/benchmarks/mind2web.js +257 -8
- package/dist/benchmarks/mind2web.js.map +1 -1
- package/dist/benchmarks/nomiracl.d.ts +4 -13
- package/dist/benchmarks/nomiracl.js +146 -8
- package/dist/benchmarks/nomiracl.js.map +1 -1
- package/dist/benchmarks/open-rag-bench.d.ts +4 -12
- package/dist/benchmarks/open-rag-bench.js +110 -8
- package/dist/benchmarks/open-rag-bench.js.map +1 -1
- package/dist/benchmarks/programbench.d.ts +5 -29
- package/dist/benchmarks/programbench.js +161 -9
- package/dist/benchmarks/programbench.js.map +1 -1
- package/dist/benchmarks/rag-shared.d.ts +21 -20
- package/dist/benchmarks/rag-shared.js +245 -38
- package/dist/benchmarks/rag-shared.js.map +1 -1
- package/dist/benchmarks/ragbench.d.ts +4 -14
- package/dist/benchmarks/ragbench.js +127 -8
- package/dist/benchmarks/ragbench.js.map +1 -1
- package/dist/benchmarks/simpleqa.d.ts +17 -44
- package/dist/benchmarks/simpleqa.js +293 -10
- package/dist/benchmarks/simpleqa.js.map +1 -1
- package/dist/benchmarks/swe-bench.d.ts +23 -36
- package/dist/benchmarks/swe-bench.js +234 -13
- package/dist/benchmarks/swe-bench.js.map +1 -1
- package/dist/benchmarks/t2-ragbench.d.ts +4 -12
- package/dist/benchmarks/t2-ragbench.js +118 -8
- package/dist/benchmarks/t2-ragbench.js.map +1 -1
- package/dist/benchmarks/tau-bench-shared.d.ts +14 -22
- package/dist/benchmarks/tau-bench-shared.js +169 -9
- package/dist/benchmarks/tau-bench-shared.js.map +1 -1
- package/dist/benchmarks/tau2-bench.d.ts +5 -5
- package/dist/benchmarks/tau2-bench.js +28 -10
- package/dist/benchmarks/tau2-bench.js.map +1 -1
- package/dist/benchmarks/tau3-banking.d.ts +4 -13
- package/dist/benchmarks/tau3-banking.js +28 -8
- package/dist/benchmarks/tau3-banking.js.map +1 -1
- package/dist/benchmarks/terminal-bench.d.ts +4 -22
- package/dist/benchmarks/terminal-bench.js +140 -7
- package/dist/benchmarks/terminal-bench.js.map +1 -1
- package/dist/benchmarks/toollm.d.ts +5 -13
- package/dist/benchmarks/toollm.js +184 -9
- package/dist/benchmarks/toollm.js.map +1 -1
- package/dist/benchmarks/trata-hedge.d.ts +4 -30
- package/dist/benchmarks/trata-hedge.js +336 -6
- package/dist/benchmarks/trata-hedge.js.map +1 -1
- package/dist/benchmarks/types.d.ts +85 -94
- package/dist/benchmarks/types.js +1 -1
- package/dist/benchmarks/webarena-verified.d.ts +5 -13
- package/dist/benchmarks/webarena-verified.js +152 -9
- package/dist/benchmarks/webarena-verified.js.map +1 -1
- package/dist/cadbench-DpQWZHp4.js +285 -0
- package/dist/cadbench-DpQWZHp4.js.map +1 -0
- package/dist/cadgenbench-DRhczfsG.js +151 -0
- package/dist/cadgenbench-DRhczfsG.js.map +1 -0
- package/dist/index.d.ts +245 -293
- package/dist/index.js +1669 -1791
- package/dist/index.js.map +1 -1
- package/package.json +17 -14
- package/scripts/verify-packed-consumer.mjs +20 -17
- package/src/corpus.test.mts +13 -0
- package/src/corpus.ts +4 -0
- package/src/profile-coordinates.ts +2 -2
- package/src/rollout-ledger/backfill-swe-arena.mts +5 -1
- package/src/rollout-ledger/settle-capture.mts +7 -1
- package/src/search-bench/profiles.ts +1 -1
- package/src/skill-sandbox-smoke.mts +2 -1
- package/src/swe-arena/gepa-seat.mts +1 -1
- package/src/swe-arena/ledger-orphans.test.mts +36 -34
- package/dist/benchmarks/cadbench.js.map +0 -1
- package/dist/benchmarks/cadgenbench.js.map +0 -1
- package/dist/benchmarks/types.js.map +0 -1
- package/dist/chunk-53UPUNBZ.js +0 -325
- package/dist/chunk-53UPUNBZ.js.map +0 -1
- package/dist/chunk-5FEQDSCT.js +0 -211
- package/dist/chunk-5FEQDSCT.js.map +0 -1
- package/dist/chunk-5H5XV76F.js +0 -240
- package/dist/chunk-5H5XV76F.js.map +0 -1
- package/dist/chunk-67ACKDCX.js +0 -118
- package/dist/chunk-67ACKDCX.js.map +0 -1
- package/dist/chunk-7FKBWOQT.js +0 -147
- package/dist/chunk-7FKBWOQT.js.map +0 -1
- package/dist/chunk-BEN6IF2X.js +0 -221
- package/dist/chunk-BEN6IF2X.js.map +0 -1
- package/dist/chunk-BZY5QARD.js +0 -120
- package/dist/chunk-BZY5QARD.js.map +0 -1
- package/dist/chunk-C7T7WEK2.js +0 -103
- package/dist/chunk-C7T7WEK2.js.map +0 -1
- package/dist/chunk-CLIKAXKH.js +0 -276
- package/dist/chunk-CLIKAXKH.js.map +0 -1
- package/dist/chunk-CWIOBFSP.js +0 -197
- package/dist/chunk-CWIOBFSP.js.map +0 -1
- package/dist/chunk-CXDUTWQE.js +0 -318
- package/dist/chunk-CXDUTWQE.js.map +0 -1
- package/dist/chunk-DWALFME7.js +0 -182
- package/dist/chunk-DWALFME7.js.map +0 -1
- package/dist/chunk-EEOC6QPJ.js +0 -144
- package/dist/chunk-EEOC6QPJ.js.map +0 -1
- package/dist/chunk-EIETHPD5.js +0 -321
- package/dist/chunk-EIETHPD5.js.map +0 -1
- package/dist/chunk-GC2EPS6L.js +0 -130
- package/dist/chunk-GC2EPS6L.js.map +0 -1
- package/dist/chunk-GCHL6XPM.js +0 -169
- package/dist/chunk-GCHL6XPM.js.map +0 -1
- package/dist/chunk-HQ5HCCKF.js +0 -142
- package/dist/chunk-HQ5HCCKF.js.map +0 -1
- package/dist/chunk-HVW25KSX.js +0 -208
- package/dist/chunk-HVW25KSX.js.map +0 -1
- package/dist/chunk-INNOYXCP.js +0 -387
- package/dist/chunk-INNOYXCP.js.map +0 -1
- package/dist/chunk-J6BU3NTM.js +0 -251
- package/dist/chunk-J6BU3NTM.js.map +0 -1
- package/dist/chunk-JSQOUKXS.js +0 -149
- package/dist/chunk-JSQOUKXS.js.map +0 -1
- package/dist/chunk-JTHWEDEW.js +0 -32
- package/dist/chunk-JTHWEDEW.js.map +0 -1
- package/dist/chunk-NRMGT25X.js +0 -116
- package/dist/chunk-NRMGT25X.js.map +0 -1
- package/dist/chunk-PA2ZKHJC.js +0 -230
- package/dist/chunk-PA2ZKHJC.js.map +0 -1
- package/dist/chunk-PUIRNYI7.js +0 -189
- package/dist/chunk-PUIRNYI7.js.map +0 -1
- package/dist/chunk-QZZEAHWJ.js +0 -136
- package/dist/chunk-QZZEAHWJ.js.map +0 -1
- package/dist/chunk-SEVJPLZC.js +0 -260
- package/dist/chunk-SEVJPLZC.js.map +0 -1
- package/dist/chunk-TBKU5XQI.js +0 -228
- package/dist/chunk-TBKU5XQI.js.map +0 -1
- package/dist/chunk-UPAMRDX4.js +0 -233
- package/dist/chunk-UPAMRDX4.js.map +0 -1
- package/dist/chunk-VQRS7VUC.js +0 -342
- package/dist/chunk-VQRS7VUC.js.map +0 -1
- package/dist/chunk-WG7TM7UV.js +0 -30
- package/dist/chunk-WG7TM7UV.js.map +0 -1
- package/dist/chunk-X3BTXCJ4.js +0 -262
- package/dist/chunk-X3BTXCJ4.js.map +0 -1
- package/dist/chunk-XXFF3RRD.js +0 -162
- package/dist/chunk-XXFF3RRD.js.map +0 -1
- package/dist/chunk-ZFNOM7WR.js +0 -27
- package/dist/chunk-ZFNOM7WR.js.map +0 -1
- package/dist/chunk-ZNCCYTFG.js +0 -170
- package/dist/chunk-ZNCCYTFG.js.map +0 -1
package/dist/chunk-J6BU3NTM.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
preflightVenvImports,
|
|
3
|
-
readJsonReport,
|
|
4
|
-
runStagedJudge,
|
|
5
|
-
runVenvPython,
|
|
6
|
-
safeRunId,
|
|
7
|
-
stageFile
|
|
8
|
-
} from "./chunk-EIETHPD5.js";
|
|
9
|
-
|
|
10
|
-
// src/benchmarks/swe-bench.ts
|
|
11
|
-
import { join } from "path";
|
|
12
|
-
var SWE_REPO_DIR = "/work";
|
|
13
|
-
var swePatchOutput = {
|
|
14
|
-
parse(events) {
|
|
15
|
-
let text = "";
|
|
16
|
-
for (const ev of events) {
|
|
17
|
-
const d = ev?.data;
|
|
18
|
-
const t = d?.finalText ?? d?.text ?? d?.result;
|
|
19
|
-
if (typeof t === "string" && t.length > 0) text = t;
|
|
20
|
-
}
|
|
21
|
-
const fences = [...text.matchAll(/```(?:diff|patch)?\s*\n([\s\S]*?)```/g)];
|
|
22
|
-
const last = fences.at(-1)?.[1];
|
|
23
|
-
return (last ?? text).trim();
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var DATASET = "princeton-nlp/SWE-bench_Verified";
|
|
27
|
-
var SWE_CACHE_LEVELS = /* @__PURE__ */ new Set(["none", "base", "env", "instance"]);
|
|
28
|
-
function scorerNamespace() {
|
|
29
|
-
const namespace = process.env.SWEBENCH_NAMESPACE ?? "swebench";
|
|
30
|
-
if (namespace !== "swebench" && namespace !== "none") {
|
|
31
|
-
throw new Error(`SWEBENCH_NAMESPACE must be swebench|none, got "${namespace}"`);
|
|
32
|
-
}
|
|
33
|
-
return namespace;
|
|
34
|
-
}
|
|
35
|
-
var TEST_FILE_EXCLUDES = [
|
|
36
|
-
"':(exclude,glob)**/tests/**'",
|
|
37
|
-
"':(exclude,glob)**/test/**'",
|
|
38
|
-
"':(exclude,glob)test_*.py'",
|
|
39
|
-
"':(exclude,glob)**/test_*.py'",
|
|
40
|
-
"':(exclude,glob)*_test.py'",
|
|
41
|
-
"':(exclude,glob)**/*_test.py'",
|
|
42
|
-
"':(exclude,glob)conftest.py'",
|
|
43
|
-
"':(exclude,glob)**/conftest.py'"
|
|
44
|
-
].join(" ");
|
|
45
|
-
function stringIds(report, key) {
|
|
46
|
-
const value = report[key];
|
|
47
|
-
if (value === void 0) return [];
|
|
48
|
-
if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string")) {
|
|
49
|
-
throw new Error(`swe-bench: malformed ${key}`);
|
|
50
|
-
}
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
function scoreSweReport(taskId, value) {
|
|
54
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
55
|
-
throw new Error("swe-bench: report must be an object");
|
|
56
|
-
}
|
|
57
|
-
const report = value;
|
|
58
|
-
const statusIds = {
|
|
59
|
-
resolved: stringIds(report, "resolved_ids"),
|
|
60
|
-
unresolved: stringIds(report, "unresolved_ids"),
|
|
61
|
-
emptyPatch: stringIds(report, "empty_patch_ids"),
|
|
62
|
-
completed: stringIds(report, "completed_ids"),
|
|
63
|
-
incomplete: stringIds(report, "incomplete_ids"),
|
|
64
|
-
error: stringIds(report, "error_ids")
|
|
65
|
-
};
|
|
66
|
-
const submitted = stringIds(report, "submitted_ids");
|
|
67
|
-
const mentioned = Object.values(statusIds).flat();
|
|
68
|
-
if (mentioned.some((id) => id !== taskId) || submitted.length > 0 && (submitted.length !== 1 || submitted[0] !== taskId)) {
|
|
69
|
-
throw new Error(`swe-bench: report identity mismatch for ${taskId}`);
|
|
70
|
-
}
|
|
71
|
-
if (statusIds.error.includes(taskId) || statusIds.incomplete.includes(taskId)) {
|
|
72
|
-
throw new Error(`swe-bench: evaluator failed for ${taskId}`);
|
|
73
|
-
}
|
|
74
|
-
const outcomes = [
|
|
75
|
-
statusIds.resolved.includes(taskId),
|
|
76
|
-
statusIds.unresolved.includes(taskId),
|
|
77
|
-
statusIds.emptyPatch.includes(taskId)
|
|
78
|
-
];
|
|
79
|
-
if (outcomes.filter(Boolean).length !== 1) {
|
|
80
|
-
throw new Error(`swe-bench: report has no unique outcome for ${taskId}`);
|
|
81
|
-
}
|
|
82
|
-
if ((outcomes[0] || outcomes[1]) && !statusIds.completed.includes(taskId)) {
|
|
83
|
-
throw new Error(`swe-bench: report lacks a completed evaluation for ${taskId}`);
|
|
84
|
-
}
|
|
85
|
-
const resolved = outcomes[0];
|
|
86
|
-
return { resolved, score: resolved ? 1 : 0, detail: JSON.stringify(report) };
|
|
87
|
-
}
|
|
88
|
-
function sweEvaluationArgv(args) {
|
|
89
|
-
return [
|
|
90
|
-
"-m",
|
|
91
|
-
"swebench.harness.run_evaluation",
|
|
92
|
-
"--dataset_name",
|
|
93
|
-
DATASET,
|
|
94
|
-
"--predictions_path",
|
|
95
|
-
args.predictionsPath,
|
|
96
|
-
"--run_id",
|
|
97
|
-
args.runId,
|
|
98
|
-
"--instance_ids",
|
|
99
|
-
args.instanceId,
|
|
100
|
-
"--max_workers",
|
|
101
|
-
"1",
|
|
102
|
-
"--namespace",
|
|
103
|
-
args.namespace ?? scorerNamespace(),
|
|
104
|
-
"--cache_level",
|
|
105
|
-
args.cacheLevel
|
|
106
|
-
];
|
|
107
|
-
}
|
|
108
|
-
function shellQuote(value) {
|
|
109
|
-
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
110
|
-
}
|
|
111
|
-
function sweMetadata(task) {
|
|
112
|
-
const repo = String(task.metadata?.repo ?? "");
|
|
113
|
-
const base = String(task.metadata?.base_commit ?? "");
|
|
114
|
-
if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo)) {
|
|
115
|
-
throw new Error(`swe-bench: invalid repo metadata for ${task.id}: ${repo}`);
|
|
116
|
-
}
|
|
117
|
-
if (!/^[0-9a-f]{7,40}$/i.test(base)) {
|
|
118
|
-
throw new Error(`swe-bench: invalid base_commit metadata for ${task.id}: ${base}`);
|
|
119
|
-
}
|
|
120
|
-
return { repo, base };
|
|
121
|
-
}
|
|
122
|
-
function createSweBenchAdapter(options = {}) {
|
|
123
|
-
if (options.timeoutMs !== void 0 && (!Number.isSafeInteger(options.timeoutMs) || options.timeoutMs <= 0)) throw new Error("swe-bench: timeoutMs must be a positive integer");
|
|
124
|
-
const cacheLevel = options.cacheLevel ?? "env";
|
|
125
|
-
if (!SWE_CACHE_LEVELS.has(cacheLevel)) throw new Error("swe-bench: invalid cacheLevel");
|
|
126
|
-
if (options.captureEvaluatorArtifacts !== void 0 && typeof options.captureEvaluatorArtifacts !== "function") throw new Error("swe-bench: captureEvaluatorArtifacts must be a function");
|
|
127
|
-
let attemptSequence = 0;
|
|
128
|
-
return {
|
|
129
|
-
name: "swe-bench-verified",
|
|
130
|
-
output: swePatchOutput,
|
|
131
|
-
// Extract the patch from repo STATE, not printed text: stage every edit the
|
|
132
|
-
// agent made in the cloned repo and diff it against the checked-out
|
|
133
|
-
// base_commit (`HEAD`). Test files are excluded — the judge applies the gold
|
|
134
|
-
// `test_patch` itself, so an agent edit to a test would collide on apply. The
|
|
135
|
-
// paths come out `a/<repo-relative>` (cwd = repo root), matching the gold
|
|
136
|
-
// patch format the swebench judge's `git apply` expects.
|
|
137
|
-
// Pre-stage: clone the instance repo at base_commit into SWE_REPO_DIR so the
|
|
138
|
-
// agent only edits (the harness owns the checkout — a stochastic model can't be
|
|
139
|
-
// trusted to clone to an exact path). `--quiet` keeps the exec output small.
|
|
140
|
-
boxSetup(task) {
|
|
141
|
-
const { repo, base } = sweMetadata(task);
|
|
142
|
-
return {
|
|
143
|
-
command: `rm -rf ${shellQuote(SWE_REPO_DIR)} && git clone --quiet ${shellQuote(`https://github.com/${repo}`)} ${shellQuote(SWE_REPO_DIR)} && git -C ${shellQuote(SWE_REPO_DIR)} checkout --quiet ${shellQuote(base)}`
|
|
144
|
-
};
|
|
145
|
-
},
|
|
146
|
-
boxExtract() {
|
|
147
|
-
return {
|
|
148
|
-
command: `git -C ${shellQuote(SWE_REPO_DIR)} add -A && git -C ${shellQuote(SWE_REPO_DIR)} diff --cached -- . ${TEST_FILE_EXCLUDES}`
|
|
149
|
-
};
|
|
150
|
-
},
|
|
151
|
-
async preflight() {
|
|
152
|
-
await preflightVenvImports({
|
|
153
|
-
modules: ["swebench"],
|
|
154
|
-
requireDocker: true,
|
|
155
|
-
fix: `Fix: (1) python3 -m venv bench/.venv && bench/.venv/bin/pip install swebench ; (2) ensure the Docker daemon is running (the judge builds per-instance images).`
|
|
156
|
-
});
|
|
157
|
-
},
|
|
158
|
-
async loadTasks(opts = {}) {
|
|
159
|
-
const limit = opts.limit ?? 10;
|
|
160
|
-
const split = opts.split ?? "test";
|
|
161
|
-
const script = `
|
|
162
|
-
import json, sys
|
|
163
|
-
from datasets import load_dataset
|
|
164
|
-
ds = load_dataset(${JSON.stringify(DATASET)}, split=${JSON.stringify(split)})
|
|
165
|
-
ids = set(json.loads(sys.argv[1])) if len(sys.argv) > 1 and sys.argv[1] else None
|
|
166
|
-
out = []
|
|
167
|
-
for r in ds:
|
|
168
|
-
if ids is not None and r["instance_id"] not in ids:
|
|
169
|
-
continue
|
|
170
|
-
out.append({
|
|
171
|
-
"instance_id": r["instance_id"], "repo": r["repo"], "base_commit": r["base_commit"],
|
|
172
|
-
"problem_statement": r["problem_statement"], "patch": r["patch"], "test_patch": r["test_patch"],
|
|
173
|
-
"FAIL_TO_PASS": r["FAIL_TO_PASS"], "PASS_TO_PASS": r["PASS_TO_PASS"],
|
|
174
|
-
"version": r.get("version"), "environment_setup_commit": r.get("environment_setup_commit"),
|
|
175
|
-
})
|
|
176
|
-
if ids is None and len(out) >= ${limit}:
|
|
177
|
-
break
|
|
178
|
-
print(json.dumps(out))
|
|
179
|
-
`;
|
|
180
|
-
const stdout = await runVenvPython(script, [opts.ids ? JSON.stringify(opts.ids) : ""]);
|
|
181
|
-
const rows = JSON.parse(stdout);
|
|
182
|
-
return rows.map(
|
|
183
|
-
(r) => ({
|
|
184
|
-
id: String(r.instance_id),
|
|
185
|
-
split,
|
|
186
|
-
prompt: [
|
|
187
|
-
`Repository: ${r.repo} @ ${r.base_commit}`,
|
|
188
|
-
"",
|
|
189
|
-
`The repository is ALREADY cloned at ${SWE_REPO_DIR}, checked out at commit ${r.base_commit}. Work there directly (\`cd ${SWE_REPO_DIR}\`); do not re-clone.`,
|
|
190
|
-
"",
|
|
191
|
-
"Resolve this issue by editing the repository SOURCE so the failing tests pass without breaking the passing ones. Do NOT edit test files \u2014 the evaluation runs hidden tests on a fresh checkout, so editing tests does not count. Keep the change minimal and confined to the cloned repo.",
|
|
192
|
-
"Work iteratively: reproduce the issue, implement the fix in the source, and re-run the relevant tests until they pass. You do NOT need to print the diff \u2014 the harness reads your committed edits directly from the repo.",
|
|
193
|
-
"",
|
|
194
|
-
"--- Issue ---",
|
|
195
|
-
String(r.problem_statement ?? "")
|
|
196
|
-
].join("\n"),
|
|
197
|
-
metadata: r
|
|
198
|
-
})
|
|
199
|
-
);
|
|
200
|
-
},
|
|
201
|
-
async goldArtifact(task) {
|
|
202
|
-
const gold = task.metadata?.patch;
|
|
203
|
-
return typeof gold === "string" ? gold : void 0;
|
|
204
|
-
},
|
|
205
|
-
async judge(task, artifact) {
|
|
206
|
-
const runId = safeRunId("bench", task.id);
|
|
207
|
-
const capture = options.captureEvaluatorArtifacts?.({
|
|
208
|
-
taskId: task.id,
|
|
209
|
-
runId,
|
|
210
|
-
attemptSequence: ++attemptSequence
|
|
211
|
-
});
|
|
212
|
-
return runStagedJudge({
|
|
213
|
-
tmpPrefix: "swebench-",
|
|
214
|
-
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
|
|
215
|
-
...capture === void 0 ? {} : { capture },
|
|
216
|
-
// Debug: retain the staged dir (holds swebench's per-instance apply/run
|
|
217
|
-
// logs) for post-mortem when SWEBENCH_KEEP_TMP is set. Off by default.
|
|
218
|
-
...process.env.SWEBENCH_KEEP_TMP ? { keepTmp: true } : {},
|
|
219
|
-
async stage(dir) {
|
|
220
|
-
await stageFile(
|
|
221
|
-
join(dir, "preds.json"),
|
|
222
|
-
JSON.stringify([
|
|
223
|
-
{ instance_id: task.id, model_name_or_path: "agent-runtime-bench", model_patch: artifact }
|
|
224
|
-
])
|
|
225
|
-
);
|
|
226
|
-
},
|
|
227
|
-
// The official evaluation harness. Pulls/builds the instance image, applies
|
|
228
|
-
// the patch, runs the test spec, writes a per-run report JSON in cwd.
|
|
229
|
-
argv: (dir) => sweEvaluationArgv({
|
|
230
|
-
predictionsPath: join(dir, "preds.json"),
|
|
231
|
-
runId,
|
|
232
|
-
instanceId: task.id,
|
|
233
|
-
cacheLevel,
|
|
234
|
-
namespace: scorerNamespace()
|
|
235
|
-
}),
|
|
236
|
-
async parseReport(dir) {
|
|
237
|
-
const report = await readJsonReport(join(dir, `agent-runtime-bench.${runId}.json`));
|
|
238
|
-
return scoreSweReport(task.id, report);
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
export {
|
|
246
|
-
swePatchOutput,
|
|
247
|
-
scoreSweReport,
|
|
248
|
-
sweEvaluationArgv,
|
|
249
|
-
createSweBenchAdapter
|
|
250
|
-
};
|
|
251
|
-
//# sourceMappingURL=chunk-J6BU3NTM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/benchmarks/swe-bench.ts"],"sourcesContent":["/**\n * SWE-bench Verified adapter. Worker artifact = a unified-diff patch. Judge =\n * the official `swebench` harness: apply the patch in the instance's Docker\n * image, run FAIL_TO_PASS + PASS_TO_PASS, report `resolved`. Fully deterministic\n * — no LLM judge.\n *\n * Requires: the bench `.venv` with `swebench` installed + a running Docker\n * daemon (per-instance images are pulled/built on first run).\n *\n * Process/Docker/report plumbing is shared via ./_harness; this file owns the\n * SWE-specific pieces: the patch OutputAdapter, the dataset dump, and the\n * predictions-file → run_evaluation argv → report-shape mapping.\n */\n\nimport { join } from 'node:path'\nimport type { OutputAdapter } from '@tangle-network/agent-runtime/loops'\nimport {\n preflightVenvImports,\n readJsonReport,\n runStagedJudge,\n runVenvPython,\n safeRunId,\n stageFile,\n type StagedRunCaptureSpec,\n} from './_harness'\nimport type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'\n\n/**\n * Fixed in-box path the agent clones the instance repo into. It is the SINGLE\n * source of truth shared by the prompt template (which tells the agent to clone\n * here) and `boxExtract` (which runs `git diff` here after the shot) — so the\n * harness always knows exactly where the agent's edits live, for any instance.\n */\nconst SWE_REPO_DIR = '/work'\n\n/**\n * The SWE deliverable's FALLBACK parser, from the agent's event STREAM.\n *\n * The PRIMARY deliverable is `boxExtract` below: a `git diff` of the agent's\n * actual edits, read from the cloned repo's STATE inside the box (standard\n * SWE-bench practice). This event-stream parse only runs when that diff is empty\n * — a model that edited the source correctly but never printed a fenced diff (the\n * exact failure this replaces) still scores off its real changes, not its prose.\n */\nexport const swePatchOutput: OutputAdapter<string> = {\n parse(events) {\n let text = ''\n for (const ev of events) {\n const d = (ev as { data?: Record<string, unknown> })?.data\n const t = d?.finalText ?? d?.text ?? d?.result\n if (typeof t === 'string' && t.length > 0) text = t\n }\n // Last ```diff/```patch fenced block (the contract the prompt asks for);\n // fall back to the raw text so a fence-less but valid diff still reaches the judge.\n const fences = [...text.matchAll(/```(?:diff|patch)?\\s*\\n([\\s\\S]*?)```/g)]\n const last = fences.at(-1)?.[1]\n return (last ?? text).trim()\n },\n}\n\nconst DATASET = 'princeton-nlp/SWE-bench_Verified'\nexport type SweBenchCacheLevel = 'none' | 'base' | 'env' | 'instance'\n\nexport interface SweBenchArtifactCaptureContext {\n readonly taskId: string\n readonly runId: string\n /** One-based sequence unique within this adapter instance. */\n readonly attemptSequence: number\n}\n\nexport interface SweBenchAdapterOptions {\n readonly timeoutMs?: number\n readonly cacheLevel?: SweBenchCacheLevel\n /**\n * Return a unique destination for any attempt whose complete official\n * evaluator directory and process logs should be retained.\n */\n readonly captureEvaluatorArtifacts?: (\n context: SweBenchArtifactCaptureContext,\n ) => StagedRunCaptureSpec | undefined\n}\n\nconst SWE_CACHE_LEVELS = new Set<SweBenchCacheLevel>(['none', 'base', 'env', 'instance'])\n\nfunction scorerNamespace(): 'swebench' | 'none' {\n const namespace = process.env.SWEBENCH_NAMESPACE ?? 'swebench'\n if (namespace !== 'swebench' && namespace !== 'none') {\n throw new Error(`SWEBENCH_NAMESPACE must be swebench|none, got \"${namespace}\"`)\n }\n return namespace\n}\nconst TEST_FILE_EXCLUDES = [\n \"':(exclude,glob)**/tests/**'\",\n \"':(exclude,glob)**/test/**'\",\n \"':(exclude,glob)test_*.py'\",\n \"':(exclude,glob)**/test_*.py'\",\n \"':(exclude,glob)*_test.py'\",\n \"':(exclude,glob)**/*_test.py'\",\n \"':(exclude,glob)conftest.py'\",\n \"':(exclude,glob)**/conftest.py'\",\n].join(' ')\n\ninterface SweReport {\n resolved_instances?: number\n resolved_ids?: string[]\n unresolved_ids?: string[]\n empty_patch_ids?: string[]\n completed_ids?: string[]\n incomplete_ids?: string[]\n error_ids?: string[]\n submitted_ids?: string[]\n}\n\nfunction stringIds(report: Record<string, unknown>, key: keyof SweReport): string[] {\n const value = report[key]\n if (value === undefined) return []\n if (!Array.isArray(value) || value.some((entry) => typeof entry !== 'string')) {\n throw new Error(`swe-bench: malformed ${key}`)\n }\n return value\n}\n\n/** Convert one official report into a score without turning evaluator failures into agent failures. */\nexport function scoreSweReport(taskId: string, value: unknown): BenchScore {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n throw new Error('swe-bench: report must be an object')\n }\n const report = value as Record<string, unknown>\n const statusIds = {\n resolved: stringIds(report, 'resolved_ids'),\n unresolved: stringIds(report, 'unresolved_ids'),\n emptyPatch: stringIds(report, 'empty_patch_ids'),\n completed: stringIds(report, 'completed_ids'),\n incomplete: stringIds(report, 'incomplete_ids'),\n error: stringIds(report, 'error_ids'),\n }\n const submitted = stringIds(report, 'submitted_ids')\n const mentioned = Object.values(statusIds).flat()\n if (\n mentioned.some((id) => id !== taskId)\n || (submitted.length > 0 && (submitted.length !== 1 || submitted[0] !== taskId))\n ) {\n throw new Error(`swe-bench: report identity mismatch for ${taskId}`)\n }\n if (statusIds.error.includes(taskId) || statusIds.incomplete.includes(taskId)) {\n throw new Error(`swe-bench: evaluator failed for ${taskId}`)\n }\n const outcomes = [\n statusIds.resolved.includes(taskId),\n statusIds.unresolved.includes(taskId),\n statusIds.emptyPatch.includes(taskId),\n ]\n if (outcomes.filter(Boolean).length !== 1) {\n throw new Error(`swe-bench: report has no unique outcome for ${taskId}`)\n }\n if ((outcomes[0] || outcomes[1]) && !statusIds.completed.includes(taskId)) {\n throw new Error(`swe-bench: report lacks a completed evaluation for ${taskId}`)\n }\n const resolved = outcomes[0]\n return { resolved, score: resolved ? 1 : 0, detail: JSON.stringify(report) }\n}\n\nexport function sweEvaluationArgv(args: {\n readonly predictionsPath: string\n readonly runId: string\n readonly instanceId: string\n readonly cacheLevel: SweBenchCacheLevel\n readonly namespace?: 'swebench' | 'none'\n}): string[] {\n return [\n '-m', 'swebench.harness.run_evaluation',\n '--dataset_name', DATASET,\n '--predictions_path', args.predictionsPath,\n '--run_id', args.runId,\n '--instance_ids', args.instanceId,\n '--max_workers', '1',\n '--namespace', args.namespace ?? scorerNamespace(),\n '--cache_level', args.cacheLevel,\n ]\n}\n\nfunction shellQuote(value: string): string {\n return `'${value.replace(/'/g, `'\\\\''`)}'`\n}\n\nfunction sweMetadata(task: BenchTask): { repo: string; base: string } {\n const repo = String(task.metadata?.repo ?? '')\n const base = String(task.metadata?.base_commit ?? '')\n if (!/^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/.test(repo)) {\n throw new Error(`swe-bench: invalid repo metadata for ${task.id}: ${repo}`)\n }\n if (!/^[0-9a-f]{7,40}$/i.test(base)) {\n throw new Error(`swe-bench: invalid base_commit metadata for ${task.id}: ${base}`)\n }\n return { repo, base }\n}\n\nexport function createSweBenchAdapter(options: SweBenchAdapterOptions = {}): BenchmarkAdapter {\n if (\n options.timeoutMs !== undefined\n && (!Number.isSafeInteger(options.timeoutMs) || options.timeoutMs <= 0)\n ) throw new Error('swe-bench: timeoutMs must be a positive integer')\n const cacheLevel = options.cacheLevel ?? 'env'\n if (!SWE_CACHE_LEVELS.has(cacheLevel)) throw new Error('swe-bench: invalid cacheLevel')\n if (\n options.captureEvaluatorArtifacts !== undefined\n && typeof options.captureEvaluatorArtifacts !== 'function'\n ) throw new Error('swe-bench: captureEvaluatorArtifacts must be a function')\n let attemptSequence = 0\n return {\n name: 'swe-bench-verified',\n output: swePatchOutput,\n\n // Extract the patch from repo STATE, not printed text: stage every edit the\n // agent made in the cloned repo and diff it against the checked-out\n // base_commit (`HEAD`). Test files are excluded — the judge applies the gold\n // `test_patch` itself, so an agent edit to a test would collide on apply. The\n // paths come out `a/<repo-relative>` (cwd = repo root), matching the gold\n // patch format the swebench judge's `git apply` expects.\n // Pre-stage: clone the instance repo at base_commit into SWE_REPO_DIR so the\n // agent only edits (the harness owns the checkout — a stochastic model can't be\n // trusted to clone to an exact path). `--quiet` keeps the exec output small.\n boxSetup(task) {\n const { repo, base } = sweMetadata(task)\n return {\n command: `rm -rf ${shellQuote(SWE_REPO_DIR)} && git clone --quiet ${shellQuote(`https://github.com/${repo}`)} ${shellQuote(SWE_REPO_DIR)} && git -C ${shellQuote(SWE_REPO_DIR)} checkout --quiet ${shellQuote(base)}`,\n }\n },\n boxExtract() {\n return {\n command: `git -C ${shellQuote(SWE_REPO_DIR)} add -A && git -C ${shellQuote(SWE_REPO_DIR)} diff --cached -- . ${TEST_FILE_EXCLUDES}`,\n }\n },\n\n async preflight() {\n await preflightVenvImports({\n modules: ['swebench'],\n requireDocker: true,\n fix:\n `Fix: (1) python3 -m venv bench/.venv && bench/.venv/bin/pip install swebench ; ` +\n `(2) ensure the Docker daemon is running (the judge builds per-instance images).`,\n })\n },\n\n async loadTasks(opts: LoadOptions = {}) {\n const limit = opts.limit ?? 10\n const split = opts.split ?? 'test'\n // Dump instances as JSON via the datasets loader (HF download on first run).\n const script = `\nimport json, sys\nfrom datasets import load_dataset\nds = load_dataset(${JSON.stringify(DATASET)}, split=${JSON.stringify(split)})\nids = set(json.loads(sys.argv[1])) if len(sys.argv) > 1 and sys.argv[1] else None\nout = []\nfor r in ds:\n if ids is not None and r[\"instance_id\"] not in ids:\n continue\n out.append({\n \"instance_id\": r[\"instance_id\"], \"repo\": r[\"repo\"], \"base_commit\": r[\"base_commit\"],\n \"problem_statement\": r[\"problem_statement\"], \"patch\": r[\"patch\"], \"test_patch\": r[\"test_patch\"],\n \"FAIL_TO_PASS\": r[\"FAIL_TO_PASS\"], \"PASS_TO_PASS\": r[\"PASS_TO_PASS\"],\n \"version\": r.get(\"version\"), \"environment_setup_commit\": r.get(\"environment_setup_commit\"),\n })\n if ids is None and len(out) >= ${limit}:\n break\nprint(json.dumps(out))\n`\n const stdout = await runVenvPython(script, [opts.ids ? JSON.stringify(opts.ids) : ''])\n const rows = JSON.parse(stdout) as Array<Record<string, unknown>>\n return rows.map(\n (r): BenchTask => ({\n id: String(r.instance_id),\n split,\n prompt: [\n `Repository: ${r.repo} @ ${r.base_commit}`,\n '',\n `The repository is ALREADY cloned at ${SWE_REPO_DIR}, checked out at commit ${r.base_commit}. Work there directly (\\`cd ${SWE_REPO_DIR}\\`); do not re-clone.`,\n '',\n 'Resolve this issue by editing the repository SOURCE so the failing tests pass without breaking the passing ones. Do NOT edit test files — the evaluation runs hidden tests on a fresh checkout, so editing tests does not count. Keep the change minimal and confined to the cloned repo.',\n 'Work iteratively: reproduce the issue, implement the fix in the source, and re-run the relevant tests until they pass. You do NOT need to print the diff — the harness reads your committed edits directly from the repo.',\n '',\n '--- Issue ---',\n String(r.problem_statement ?? ''),\n ].join('\\n'),\n metadata: r,\n }),\n )\n },\n\n async goldArtifact(task: BenchTask) {\n const gold = task.metadata?.patch\n return typeof gold === 'string' ? gold : undefined\n },\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const runId = safeRunId('bench', task.id)\n const capture = options.captureEvaluatorArtifacts?.({\n taskId: task.id,\n runId,\n attemptSequence: ++attemptSequence,\n })\n return runStagedJudge({\n tmpPrefix: 'swebench-',\n ...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),\n ...(capture === undefined ? {} : { capture }),\n // Debug: retain the staged dir (holds swebench's per-instance apply/run\n // logs) for post-mortem when SWEBENCH_KEEP_TMP is set. Off by default.\n ...(process.env.SWEBENCH_KEEP_TMP ? { keepTmp: true } : {}),\n async stage(dir) {\n await stageFile(\n join(dir, 'preds.json'),\n JSON.stringify([\n { instance_id: task.id, model_name_or_path: 'agent-runtime-bench', model_patch: artifact },\n ]),\n )\n },\n // The official evaluation harness. Pulls/builds the instance image, applies\n // the patch, runs the test spec, writes a per-run report JSON in cwd.\n argv: (dir) => sweEvaluationArgv({\n predictionsPath: join(dir, 'preds.json'),\n runId,\n instanceId: task.id,\n cacheLevel,\n namespace: scorerNamespace(),\n }),\n async parseReport(dir) {\n // Report file: agent-runtime-bench.<run_id>.json\n const report = await readJsonReport<SweReport>(join(dir, `agent-runtime-bench.${runId}.json`))\n return scoreSweReport(task.id, report)\n },\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;AAcA,SAAS,YAAY;AAmBrB,IAAM,eAAe;AAWd,IAAM,iBAAwC;AAAA,EACnD,MAAM,QAAQ;AACZ,QAAI,OAAO;AACX,eAAW,MAAM,QAAQ;AACvB,YAAM,IAAK,IAA2C;AACtD,YAAM,IAAI,GAAG,aAAa,GAAG,QAAQ,GAAG;AACxC,UAAI,OAAO,MAAM,YAAY,EAAE,SAAS,EAAG,QAAO;AAAA,IACpD;AAGA,UAAM,SAAS,CAAC,GAAG,KAAK,SAAS,uCAAuC,CAAC;AACzE,UAAM,OAAO,OAAO,GAAG,EAAE,IAAI,CAAC;AAC9B,YAAQ,QAAQ,MAAM,KA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AO,eAAe;AAAA,QACpB,WAAW;AAAA,QACX,GAAI,QAAQ,cAAc,SAAY,CAAC,IAAI,EAAE,WAAW,QAAQ,UAAU;AAAA,QAC1E,GAAI,YAAY,SAAY,CAAC,IAAI,EAAE,QAAQ;AAAA;AAAA;AAAA,QAG3C,GAAI,QAAQ,IAAI,oBAAoB,EAAE,SAAS,KAAK,IAAI,CAAC;AAAA,QACzD,MAAM,MAAM,KAAK;AACf,gBAAM;AAAA,YACJ,KAAK,KAAK,YAAY;AAAA,YACtB,KAAK,UAAU;AAAA,cACb,EAAE,aAAa,KAAK,IAAI,oBAAoB,uBAAuB,aAAa,SAAS;AAAA,YAC3F,CAAC;AAAA,UACH;AAAA,QACF;AAAA;AAAA;AAAA,QAGA,MAAM,CAAC,QAAQ,kBAAkB;AAAA,UAC/B,iBAAiB,KAAK,KAAK,YAAY;AAAA,UACvC;AAAA,UACA,YAAY,KAAK;AAAA,UACjB;AAAA,UACA,WAAW,gBAAgB;AAAA,QAC7B,CAAC;AAAA,QACD,MAAM,YAAY,KAAK;AAErB,gBAAM,SAAS,MAAM,eAA0B,KAAK,KAAK,uBAAuB,KAAK,OAAO,CAAC;AAC7F,iBAAO,eAAe,KAAK,IAAI,MAAM;AAAA,QACvC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
|
package/dist/chunk-JSQOUKXS.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
benchRoot,
|
|
3
|
-
preflightVenvImports,
|
|
4
|
-
readJsonReport,
|
|
5
|
-
runStagedJudge,
|
|
6
|
-
runVenvPython,
|
|
7
|
-
safeRunId,
|
|
8
|
-
stageFile,
|
|
9
|
-
venvBinAt,
|
|
10
|
-
venvPythonAt
|
|
11
|
-
} from "./chunk-EIETHPD5.js";
|
|
12
|
-
|
|
13
|
-
// src/benchmarks/terminal-bench.ts
|
|
14
|
-
import { join } from "path";
|
|
15
|
-
var terminalBenchVenvDir = () => process.env.TERMINAL_BENCH_VENV ?? ".venv-terminal-bench";
|
|
16
|
-
var terminalBenchPython = () => venvPythonAt(terminalBenchVenvDir());
|
|
17
|
-
var terminalBenchBin = () => venvBinAt(terminalBenchVenvDir(), "tb");
|
|
18
|
-
var DATASET = "terminal-bench-core";
|
|
19
|
-
var DATASET_VERSION = "0.1.1";
|
|
20
|
-
var DATASET_REF = `${DATASET}==${DATASET_VERSION}`;
|
|
21
|
-
var FIXTURE_IDS = ["hello-world"];
|
|
22
|
-
var SCRIPT_AGENT = "tb_agents.script_agent:ScriptAgent";
|
|
23
|
-
async function loadRows(opts) {
|
|
24
|
-
const ids = opts.ids ?? (opts.limit ? null : FIXTURE_IDS);
|
|
25
|
-
const limit = opts.limit ?? null;
|
|
26
|
-
const script = `
|
|
27
|
-
import json, sys
|
|
28
|
-
from pathlib import Path
|
|
29
|
-
from terminal_bench.dataset.dataset import Dataset
|
|
30
|
-
from terminal_bench.handlers.trial_handler import TaskPaths
|
|
31
|
-
|
|
32
|
-
req_ids = json.loads(sys.argv[1]) if sys.argv[1] else None
|
|
33
|
-
limit = json.loads(sys.argv[2]) if sys.argv[2] else None
|
|
34
|
-
|
|
35
|
-
ds = Dataset(name=${JSON.stringify(DATASET)}, version=${JSON.stringify(DATASET_VERSION)}, task_ids=req_ids, n_tasks=limit)
|
|
36
|
-
|
|
37
|
-
import yaml
|
|
38
|
-
out = []
|
|
39
|
-
for task_dir in ds:
|
|
40
|
-
tp = TaskPaths(task_dir)
|
|
41
|
-
cfg = yaml.safe_load(tp.task_config_path.read_text())
|
|
42
|
-
try:
|
|
43
|
-
sol = tp.solution_path.read_text()
|
|
44
|
-
except FileNotFoundError:
|
|
45
|
-
sol = None
|
|
46
|
-
out.append({
|
|
47
|
-
"id": task_dir.name,
|
|
48
|
-
"instruction": cfg["instruction"],
|
|
49
|
-
"task_dir": str(task_dir),
|
|
50
|
-
"solution": sol if (tp.solution_path.suffix == ".sh" if sol is not None else False) else None,
|
|
51
|
-
})
|
|
52
|
-
print(json.dumps(out))
|
|
53
|
-
`;
|
|
54
|
-
const stdout = await runVenvPython(
|
|
55
|
-
script,
|
|
56
|
-
[ids ? JSON.stringify(ids) : "", limit !== null ? String(limit) : ""],
|
|
57
|
-
0,
|
|
58
|
-
terminalBenchPython()
|
|
59
|
-
);
|
|
60
|
-
return JSON.parse(stdout);
|
|
61
|
-
}
|
|
62
|
-
function createTerminalBenchAdapter() {
|
|
63
|
-
return {
|
|
64
|
-
name: "terminal-bench",
|
|
65
|
-
async preflight() {
|
|
66
|
-
await preflightVenvImports({
|
|
67
|
-
modules: ["terminal_bench"],
|
|
68
|
-
requireDocker: true,
|
|
69
|
-
python: terminalBenchPython(),
|
|
70
|
-
fix: `Fix: (1) python3 -m venv bench/${terminalBenchVenvDir()} && bench/${terminalBenchVenvDir()}/bin/pip install terminal-bench (an ISOLATED venv \u2014 Terminal-Bench/LiteLLM require Pydantic 2 while AppWorld pins Pydantic 1; override the dir with TERMINAL_BENCH_VENV) ; (2) ensure the Docker daemon is running (the judge builds per-task images on first run). The ${DATASET_REF} dataset is cached from the Terminal-Bench registry on first loadTasks.`
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
async loadTasks(opts = {}) {
|
|
74
|
-
const rows = await loadRows(opts);
|
|
75
|
-
if (rows.length === 0) {
|
|
76
|
-
throw new Error(
|
|
77
|
-
`terminal-bench loadTasks returned no tasks for ${JSON.stringify(opts)} (dataset ${DATASET_REF}). Check the requested ids exist in the dataset.`
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
return rows.map(
|
|
81
|
-
(r) => ({
|
|
82
|
-
id: r.id,
|
|
83
|
-
split: DATASET_VERSION,
|
|
84
|
-
prompt: r.instruction,
|
|
85
|
-
metadata: {
|
|
86
|
-
dataset: DATASET,
|
|
87
|
-
datasetVersion: DATASET_VERSION,
|
|
88
|
-
datasetRef: DATASET_REF,
|
|
89
|
-
taskDir: r.task_dir,
|
|
90
|
-
solution: r.solution,
|
|
91
|
-
instruction: r.instruction
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
);
|
|
95
|
-
},
|
|
96
|
-
async goldArtifact(task) {
|
|
97
|
-
const sol = task.metadata?.solution;
|
|
98
|
-
return typeof sol === "string" ? sol : void 0;
|
|
99
|
-
},
|
|
100
|
-
async judge(task, artifact) {
|
|
101
|
-
const runId = safeRunId("bench", `${task.id}-${Date.now()}`);
|
|
102
|
-
return runStagedJudge({
|
|
103
|
-
tmpPrefix: "tbench-",
|
|
104
|
-
bin: terminalBenchBin(),
|
|
105
|
-
cwd: () => benchRoot,
|
|
106
|
-
async stage(dir) {
|
|
107
|
-
await stageFile(join(dir, "attempt.sh"), artifact);
|
|
108
|
-
},
|
|
109
|
-
// The harness builds a fresh task container, runs ScriptAgent (which replays
|
|
110
|
-
// the artifact script), then runs the task's verifier. --no-livestream keeps
|
|
111
|
-
// stdout sane; --cleanup removes the per-run images.
|
|
112
|
-
argv: (dir) => [
|
|
113
|
-
"run",
|
|
114
|
-
"-d",
|
|
115
|
-
DATASET_REF,
|
|
116
|
-
"-t",
|
|
117
|
-
task.id,
|
|
118
|
-
"--agent-import-path",
|
|
119
|
-
SCRIPT_AGENT,
|
|
120
|
-
"--agent-kwarg",
|
|
121
|
-
`script_path=${join(dir, "attempt.sh")}`,
|
|
122
|
-
"--output-path",
|
|
123
|
-
join(dir, "runs"),
|
|
124
|
-
"--run-id",
|
|
125
|
-
runId,
|
|
126
|
-
"--n-concurrent",
|
|
127
|
-
"1",
|
|
128
|
-
"--no-livestream",
|
|
129
|
-
"--cleanup"
|
|
130
|
-
],
|
|
131
|
-
async parseReport(dir) {
|
|
132
|
-
const report = await readJsonReport(join(dir, "runs", runId, "results.json"));
|
|
133
|
-
const resolved = (report.resolved_ids ?? []).includes(task.id);
|
|
134
|
-
const trial = report.results?.find((r) => r.task_id === task.id);
|
|
135
|
-
return {
|
|
136
|
-
resolved,
|
|
137
|
-
score: resolved ? 1 : 0,
|
|
138
|
-
detail: JSON.stringify(trial?.parser_results ?? report.resolved_ids ?? {})
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export {
|
|
147
|
-
createTerminalBenchAdapter
|
|
148
|
-
};
|
|
149
|
-
//# sourceMappingURL=chunk-JSQOUKXS.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"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. loadTasks 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 { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } 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(): BenchmarkAdapter {\n return {\n name: 'terminal-bench',\n\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 loadTasks.`,\n })\n },\n\n async loadTasks(opts: LoadOptions = {}) {\n const rows = await loadRows(opts)\n if (rows.length === 0) {\n throw new Error(\n `terminal-bench loadTasks 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 split: DATASET_VERSION,\n prompt: r.instruction,\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 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 async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\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 resolved,\n score: resolved ? 1 : 0,\n detail: JSON.stringify(trial?.parser_results ?? report.resolved_ids ?? {}),\n }\n },\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAS,YAAY;AAiBrB,IAAM,uBAAuB,MAAc,QAAQ,IAAI,uBAAuB;AAC9E,IAAM,sBAAsB,MAAc,aAAa,qBAAqB,CAAC;AAC7E,IAAM,mBAAmB,MAAc,UAAU,qBAAqB,GAAG,IAAI;AAK7E,IAAM,UAAU;AAChB,IAAM,kBAAkB;AACxB,IAAM,cAAc,GAAG,OAAO,KAAK,eAAe;AAKlD,IAAM,cAAc,CAAC,aAAa;AAGlC,IAAM,eAAe;AAgBrB,eAAe,SAAS,MAAyC;AAC/D,QAAM,MAAM,KAAK,QAAQ,KAAK,QAAQ,OAAO;AAC7C,QAAM,QAAQ,KAAK,SAAS;AAC5B,QAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBASG,KAAK,UAAU,OAAO,CAAC,aAAa,KAAK,UAAU,eAAe,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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IAAI,CAAC,EAAE;AAC3D,aAAO,eAAe;AAAA,QACpB,WAAW;AAAA,QACX,KAAK,iBAAiB;AAAA,QACtB,KAAK,MAAM;AAAA,QACX,MAAM,MAAM,KAAK;AACf,gBAAM,UAAU,KAAK,KAAK,YAAY,GAAG,QAAQ;AAAA,QACnD;AAAA;AAAA;AAAA;AAAA,QAIA,MAAM,CAAC,QAAQ;AAAA,UACb;AAAA,UACA;AAAA,UAAM;AAAA,UACN;AAAA,UAAM,KAAK;AAAA,UACX;AAAA,UAAuB;AAAA,UACvB;AAAA,UAAiB,eAAe,KAAK,KAAK,YAAY,CAAC;AAAA,UACvD;AAAA,UAAiB,KAAK,KAAK,MAAM;AAAA,UACjC;AAAA,UAAY;AAAA,UACZ;AAAA,UAAkB;AAAA,UAClB;AAAA,UACA;AAAA,QACF;AAAA,QACA,MAAM,YAAY,KAAK;AACrB,gBAAM,SAAS,MAAM,eAAyB,KAAK,KAAK,QAAQ,OAAO,cAAc,CAAC;AACtF,gBAAM,YAAY,OAAO,gBAAgB,CAAC,GAAG,SAAS,KAAK,EAAE;AAC7D,gBAAM,QAAQ,OAAO,SAAS,KAAK,CAAC,MAAM,EAAE,YAAY,KAAK,EAAE;AAC/D,iBAAO;AAAA,YACL;AAAA,YACA,OAAO,WAAW,IAAI;AAAA,YACtB,QAAQ,KAAK,UAAU,OAAO,kBAAkB,OAAO,gBAAgB,CAAC,CAAC;AAAA,UAC3E;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
|
package/dist/chunk-JTHWEDEW.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// src/refine-loop.ts
|
|
2
|
-
var defaultDecide = (history) => history[history.length - 1]?.verdict?.valid === true;
|
|
3
|
-
async function runRefineLoop(spec) {
|
|
4
|
-
const rounds = Math.max(1, spec.rounds);
|
|
5
|
-
const decide = spec.decide ?? defaultDecide;
|
|
6
|
-
let ctxSet = false;
|
|
7
|
-
let ctx = void 0;
|
|
8
|
-
try {
|
|
9
|
-
if (spec.setup) {
|
|
10
|
-
ctx = await spec.setup();
|
|
11
|
-
ctxSet = true;
|
|
12
|
-
}
|
|
13
|
-
const history = [];
|
|
14
|
-
for (let r = 1; r <= rounds; r += 1) {
|
|
15
|
-
const prompt = spec.prompt(r, history, ctx);
|
|
16
|
-
const { artifact, note } = await spec.runShot(prompt, r, ctx);
|
|
17
|
-
const verdict = spec.judge ? await spec.judge(artifact, r) : void 0;
|
|
18
|
-
history.push({ round: r, prompt, artifact, verdict, note });
|
|
19
|
-
if (decide(history)) break;
|
|
20
|
-
}
|
|
21
|
-
const blind = history[0];
|
|
22
|
-
const final = history[history.length - 1];
|
|
23
|
-
return { rounds: history, blind, final, resolved: history.some((h) => h.verdict?.valid === true) };
|
|
24
|
-
} finally {
|
|
25
|
-
if (ctxSet && spec.teardown) await spec.teardown(ctx);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export {
|
|
30
|
-
runRefineLoop
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=chunk-JTHWEDEW.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/refine-loop.ts"],"sourcesContent":["/**\n * runRefineLoop — the ONE shared k-shot loop (see docs/architecture.md §1, §12).\n *\n * It replaces the seven hand-rolled `for (round 1..k) { shot → judge → decide →\n * carry-forward }` copies across the workers (~700 LOC of duplicated skeleton).\n * The worker is an OPAQUE `runShot`; this loop owns iteration, carry-forward\n * steering, optional per-round judging + early stop, and round bookkeeping.\n *\n * Two carry-forward channels, both first-class (the extraction found both in the\n * wild and they must stay pluggable):\n * - EXECUTION CONTEXT (`Ctx`): created once by `setup`, threaded to every shot,\n * torn down by `teardown`. This is how filesystem/session state carries — a\n * cloned repo whose edits persist (SWE refine), a shared sandbox box whose\n * session persists (sandbox research), or a scratch dir.\n * - PROMPT (`prompt(round, history, ctx)`): how textual state carries — round 1\n * is the blind prompt; rounds 2+ fold prior rounds' artifacts + a directive.\n *\n * Judging is OPTIONAL: workers that run all k rounds and let the orchestrator\n * judge omit `judge`/`decide` (the loop runs to budget); a loop that should stop\n * on the first valid answer wires `judge` (default `decide` = stop-on-valid).\n *\n * This is the inference-timescale instance of the spine's atom: `runShot` is the\n * worker Agent's `act→Output`; `prompt` is the driver Agent's `act→steer`. It is\n * deliberately corpus-agnostic — callers map `RefineLoopResult` to a RunRecord.\n */\n\n/** Minimal per-round verdict — `valid` gates early-stop, `score` is informational. */\nexport interface RoundVerdict {\n valid: boolean\n score?: number\n}\n\nexport interface RoundRecord<Artifact> {\n /** 1-based round index. */\n round: number\n prompt: string\n artifact: Artifact\n /** Present only when a `judge` is wired. */\n verdict?: RoundVerdict\n /** Non-fatal note (e.g. a liveness backstop fired this round). */\n note?: string\n}\n\nexport interface RefineLoopSpec<Artifact, Ctx = void> {\n /** Max shots. Always ≥ 1. */\n rounds: number\n /** Build the per-task execution context once (clone repo / create box / mkdtemp). */\n setup?: () => Promise<Ctx>\n /** Round `r`'s prompt. `r === 1` is the blind prompt; `r > 1` carries `history`. */\n prompt: (round: number, history: ReadonlyArray<RoundRecord<Artifact>>, ctx: Ctx) => string\n /** Run ONE shot — the opaque worker (local spawn / sandbox stream / router chat). */\n runShot: (\n prompt: string,\n round: number,\n ctx: Ctx,\n ) => Promise<{ artifact: Artifact; note?: string }>\n /** Optional per-round judge. Omit to run all `rounds` (orchestrator judges later). */\n judge?: (artifact: Artifact, round: number) => Promise<RoundVerdict>\n /** Stop after this round? Default: stop once a round's verdict is valid (else run to budget). */\n decide?: (history: ReadonlyArray<RoundRecord<Artifact>>) => boolean\n /** Always runs (even on throw) when `setup` ran. */\n teardown?: (ctx: Ctx) => Promise<void>\n}\n\nexport interface RefineLoopResult<Artifact> {\n /** Every executed round in order. */\n rounds: RoundRecord<Artifact>[]\n /** Round 1 — the blind artifact. */\n blind: RoundRecord<Artifact>\n /** The last executed round. */\n final: RoundRecord<Artifact>\n /** True iff any round was judged valid (only meaningful when `judge` is wired). */\n resolved: boolean\n}\n\nconst defaultDecide = <Artifact>(history: ReadonlyArray<RoundRecord<Artifact>>): boolean =>\n history[history.length - 1]?.verdict?.valid === true\n\nexport async function runRefineLoop<Artifact, Ctx = void>(\n spec: RefineLoopSpec<Artifact, Ctx>,\n): Promise<RefineLoopResult<Artifact>> {\n const rounds = Math.max(1, spec.rounds)\n const decide = spec.decide ?? defaultDecide\n let ctxSet = false\n let ctx = undefined as Ctx\n try {\n if (spec.setup) {\n ctx = await spec.setup()\n ctxSet = true\n }\n const history: RoundRecord<Artifact>[] = []\n for (let r = 1; r <= rounds; r += 1) {\n const prompt = spec.prompt(r, history, ctx)\n const { artifact, note } = await spec.runShot(prompt, r, ctx)\n const verdict = spec.judge ? await spec.judge(artifact, r) : undefined\n history.push({ round: r, prompt, artifact, verdict, note })\n if (decide(history)) break\n }\n // The loop runs ≥ 1 round, so history is non-empty.\n const blind = history[0] as RoundRecord<Artifact>\n const final = history[history.length - 1] as RoundRecord<Artifact>\n return { rounds: history, blind, final, resolved: history.some((h) => h.verdict?.valid === true) }\n } finally {\n if (ctxSet && spec.teardown) await spec.teardown(ctx)\n }\n}\n"],"mappings":";AA2EA,IAAM,gBAAgB,CAAW,YAC/B,QAAQ,QAAQ,SAAS,CAAC,GAAG,SAAS,UAAU;AAElD,eAAsB,cACpB,MACqC;AACrC,QAAM,SAAS,KAAK,IAAI,GAAG,KAAK,MAAM;AACtC,QAAM,SAAS,KAAK,UAAU;AAC9B,MAAI,SAAS;AACb,MAAI,MAAM;AACV,MAAI;AACF,QAAI,KAAK,OAAO;AACd,YAAM,MAAM,KAAK,MAAM;AACvB,eAAS;AAAA,IACX;AACA,UAAM,UAAmC,CAAC;AAC1C,aAAS,IAAI,GAAG,KAAK,QAAQ,KAAK,GAAG;AACnC,YAAM,SAAS,KAAK,OAAO,GAAG,SAAS,GAAG;AAC1C,YAAM,EAAE,UAAU,KAAK,IAAI,MAAM,KAAK,QAAQ,QAAQ,GAAG,GAAG;AAC5D,YAAM,UAAU,KAAK,QAAQ,MAAM,KAAK,MAAM,UAAU,CAAC,IAAI;AAC7D,cAAQ,KAAK,EAAE,OAAO,GAAG,QAAQ,UAAU,SAAS,KAAK,CAAC;AAC1D,UAAI,OAAO,OAAO,EAAG;AAAA,IACvB;AAEA,UAAM,QAAQ,QAAQ,CAAC;AACvB,UAAM,QAAQ,QAAQ,QAAQ,SAAS,CAAC;AACxC,WAAO,EAAE,QAAQ,SAAS,OAAO,OAAO,UAAU,QAAQ,KAAK,CAAC,MAAM,EAAE,SAAS,UAAU,IAAI,EAAE;AAAA,EACnG,UAAE;AACA,QAAI,UAAU,KAAK,SAAU,OAAM,KAAK,SAAS,GAAG;AAAA,EACtD;AACF;","names":[]}
|
package/dist/chunk-NRMGT25X.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FINAL_ANSWER_SENTINEL,
|
|
3
|
-
allStrings,
|
|
4
|
-
answerScoreToBenchScore,
|
|
5
|
-
firstString,
|
|
6
|
-
isObject,
|
|
7
|
-
ragAnswerOutput,
|
|
8
|
-
readJsonRows,
|
|
9
|
-
scoreAnswerArtifact,
|
|
10
|
-
selectTasks,
|
|
11
|
-
stringFrom
|
|
12
|
-
} from "./chunk-X3BTXCJ4.js";
|
|
13
|
-
import {
|
|
14
|
-
benchRoot
|
|
15
|
-
} from "./chunk-EIETHPD5.js";
|
|
16
|
-
|
|
17
|
-
// src/benchmarks/crag.ts
|
|
18
|
-
import { readFile } from "fs/promises";
|
|
19
|
-
import { join } from "path";
|
|
20
|
-
var FIXTURES = join(benchRoot, "fixtures", "crag.json");
|
|
21
|
-
var dataFile = () => process.env.CRAG_DATA_FILE;
|
|
22
|
-
function rowToTask(raw, index) {
|
|
23
|
-
if (!isObject(raw)) throw new Error(`CRAG row ${index} must be an object`);
|
|
24
|
-
const query = firstString(raw, ["query", "question", "prompt"]);
|
|
25
|
-
const goldAnswers = allStrings(raw, ["answer", "answers", "gold", "gold_answer", "expected_answer"]);
|
|
26
|
-
if (!query) throw new Error(`CRAG row ${index} missing query`);
|
|
27
|
-
if (goldAnswers.length === 0) throw new Error(`CRAG row ${index} missing gold answer`);
|
|
28
|
-
const domain = stringFrom(raw.domain) ?? "unknown";
|
|
29
|
-
const questionType = stringFrom(raw.question_type) ?? stringFrom(raw.questionType) ?? "unknown";
|
|
30
|
-
const dynamism = stringFrom(raw.static_or_dynamic) ?? stringFrom(raw.dynamism) ?? "unknown";
|
|
31
|
-
const id = stringFrom(raw.id) ?? stringFrom(raw.query_id) ?? `crag-${index}`;
|
|
32
|
-
const meta = {
|
|
33
|
-
benchmark: "crag",
|
|
34
|
-
query,
|
|
35
|
-
goldAnswers,
|
|
36
|
-
domain,
|
|
37
|
-
questionType,
|
|
38
|
-
dynamism
|
|
39
|
-
};
|
|
40
|
-
return {
|
|
41
|
-
id,
|
|
42
|
-
split: stringFrom(raw.split) ?? domain,
|
|
43
|
-
prompt: [
|
|
44
|
-
"Answer this CRAG factual question.",
|
|
45
|
-
"Return a concise answer and do not guess when the evidence is insufficient.",
|
|
46
|
-
"End with a single final line: `FINAL ANSWER: <answer>`.",
|
|
47
|
-
"",
|
|
48
|
-
`Question: ${query}`,
|
|
49
|
-
`Domain: ${domain}`,
|
|
50
|
-
`Question type: ${questionType}`,
|
|
51
|
-
`Dynamism: ${dynamism}`
|
|
52
|
-
].join("\n"),
|
|
53
|
-
metadata: meta
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function readMeta(task) {
|
|
57
|
-
const md = task.metadata;
|
|
58
|
-
if (!md || !Array.isArray(md.goldAnswers)) {
|
|
59
|
-
throw new Error(`CRAG task ${task.id} missing metadata \u2014 loadTasks did not populate it`);
|
|
60
|
-
}
|
|
61
|
-
return md;
|
|
62
|
-
}
|
|
63
|
-
async function loadRows(path) {
|
|
64
|
-
const rows = await readJsonRows(path);
|
|
65
|
-
if (rows.length === 0) throw new Error(`CRAG: no rows in ${path}`);
|
|
66
|
-
return rows;
|
|
67
|
-
}
|
|
68
|
-
async function loadFixtures(opts) {
|
|
69
|
-
const rows = JSON.parse(await readFile(FIXTURES, "utf8"));
|
|
70
|
-
console.warn(`[crag] CRAG_FIXTURES=1 \u2014 loading ${rows.length} adapter fixtures`);
|
|
71
|
-
return selectTasks(rows.map(rowToTask), opts, "CRAG");
|
|
72
|
-
}
|
|
73
|
-
function createCragAdapter() {
|
|
74
|
-
const fixturesMode = process.env.CRAG_FIXTURES === "1";
|
|
75
|
-
return {
|
|
76
|
-
name: "crag",
|
|
77
|
-
output: ragAnswerOutput,
|
|
78
|
-
async preflight() {
|
|
79
|
-
if (fixturesMode) {
|
|
80
|
-
await readFile(FIXTURES, "utf8");
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const path = dataFile();
|
|
84
|
-
if (!path) {
|
|
85
|
-
throw new Error(
|
|
86
|
-
"CRAG_DATA_FILE is required. Fix: export facebookresearch/CRAG rows to JSONL and set CRAG_DATA_FILE=/path/to/crag.jsonl, or set CRAG_FIXTURES=1 for adapter plumbing."
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
await loadRows(path);
|
|
90
|
-
},
|
|
91
|
-
async loadTasks(opts = {}) {
|
|
92
|
-
if (fixturesMode) return loadFixtures(opts);
|
|
93
|
-
const path = dataFile();
|
|
94
|
-
if (!path) throw new Error("CRAG_DATA_FILE is required to load CRAG tasks");
|
|
95
|
-
return selectTasks((await loadRows(path)).map(rowToTask), opts, "CRAG");
|
|
96
|
-
},
|
|
97
|
-
async goldArtifact(task) {
|
|
98
|
-
return `${FINAL_ANSWER_SENTINEL} ${readMeta(task).goldAnswers[0] ?? ""}`;
|
|
99
|
-
},
|
|
100
|
-
async judge(task, artifact) {
|
|
101
|
-
const meta = readMeta(task);
|
|
102
|
-
const score = scoreAnswerArtifact(artifact, meta.goldAnswers);
|
|
103
|
-
return answerScoreToBenchScore(score, {
|
|
104
|
-
benchmark: meta.benchmark,
|
|
105
|
-
domain: meta.domain,
|
|
106
|
-
questionType: meta.questionType,
|
|
107
|
-
dynamism: meta.dynamism
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export {
|
|
114
|
-
createCragAdapter
|
|
115
|
-
};
|
|
116
|
-
//# sourceMappingURL=chunk-NRMGT25X.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/benchmarks/crag.ts"],"sourcesContent":["/**\n * CRAG adapter (Comprehensive RAG Benchmark).\n *\n * Live mode expects an official or compatible CRAG JSON/JSONL export. The\n * adapter preserves CRAG domain/type/dynamism tags in metadata and scores final\n * answers deterministically against the provided gold answer list.\n */\n\nimport { readFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { benchRoot } from './_harness'\nimport type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'\nimport {\n FINAL_ANSWER_SENTINEL,\n allStrings,\n answerScoreToBenchScore,\n firstString,\n isObject,\n ragAnswerOutput,\n readJsonRows,\n scoreAnswerArtifact,\n selectTasks,\n stringFrom,\n} from './rag-shared'\n\nconst FIXTURES = join(benchRoot, 'fixtures', 'crag.json')\n\ninterface CragMeta {\n benchmark: 'crag'\n query: string\n goldAnswers: string[]\n domain: string\n questionType: string\n dynamism: string\n}\n\nconst dataFile = (): string | undefined => process.env.CRAG_DATA_FILE\n\nfunction rowToTask(raw: unknown, index: number): BenchTask {\n if (!isObject(raw)) throw new Error(`CRAG row ${index} must be an object`)\n const query = firstString(raw, ['query', 'question', 'prompt'])\n const goldAnswers = allStrings(raw, ['answer', 'answers', 'gold', 'gold_answer', 'expected_answer'])\n if (!query) throw new Error(`CRAG row ${index} missing query`)\n if (goldAnswers.length === 0) throw new Error(`CRAG row ${index} missing gold answer`)\n const domain = stringFrom(raw.domain) ?? 'unknown'\n const questionType = stringFrom(raw.question_type) ?? stringFrom(raw.questionType) ?? 'unknown'\n const dynamism = stringFrom(raw.static_or_dynamic) ?? stringFrom(raw.dynamism) ?? 'unknown'\n const id = stringFrom(raw.id) ?? stringFrom(raw.query_id) ?? `crag-${index}`\n const meta: CragMeta = {\n benchmark: 'crag',\n query,\n goldAnswers,\n domain,\n questionType,\n dynamism,\n }\n return {\n id,\n split: stringFrom(raw.split) ?? domain,\n prompt: [\n 'Answer this CRAG factual question.',\n 'Return a concise answer and do not guess when the evidence is insufficient.',\n 'End with a single final line: `FINAL ANSWER: <answer>`.',\n '',\n `Question: ${query}`,\n `Domain: ${domain}`,\n `Question type: ${questionType}`,\n `Dynamism: ${dynamism}`,\n ].join('\\n'),\n metadata: meta as unknown as Record<string, unknown>,\n }\n}\n\nfunction readMeta(task: BenchTask): CragMeta {\n const md = task.metadata\n if (!md || !Array.isArray(md.goldAnswers)) {\n throw new Error(`CRAG task ${task.id} missing metadata — loadTasks did not populate it`)\n }\n return md as unknown as CragMeta\n}\n\nasync function loadRows(path: string): Promise<unknown[]> {\n const rows = await readJsonRows(path)\n if (rows.length === 0) throw new Error(`CRAG: no rows in ${path}`)\n return rows\n}\n\nasync function loadFixtures(opts: LoadOptions): Promise<BenchTask[]> {\n const rows = JSON.parse(await readFile(FIXTURES, 'utf8')) as unknown[]\n console.warn(`[crag] CRAG_FIXTURES=1 — loading ${rows.length} adapter fixtures`)\n return selectTasks(rows.map(rowToTask), opts, 'CRAG')\n}\n\nexport function createCragAdapter(): BenchmarkAdapter {\n const fixturesMode = process.env.CRAG_FIXTURES === '1'\n\n return {\n name: 'crag',\n output: ragAnswerOutput,\n\n async preflight() {\n if (fixturesMode) {\n await readFile(FIXTURES, 'utf8')\n return\n }\n const path = dataFile()\n if (!path) {\n throw new Error(\n 'CRAG_DATA_FILE is required. Fix: export facebookresearch/CRAG rows to JSONL and set CRAG_DATA_FILE=/path/to/crag.jsonl, or set CRAG_FIXTURES=1 for adapter plumbing.',\n )\n }\n await loadRows(path)\n },\n\n async loadTasks(opts: LoadOptions = {}) {\n if (fixturesMode) return loadFixtures(opts)\n const path = dataFile()\n if (!path) throw new Error('CRAG_DATA_FILE is required to load CRAG tasks')\n return selectTasks((await loadRows(path)).map(rowToTask), opts, 'CRAG')\n },\n\n async goldArtifact(task: BenchTask) {\n return `${FINAL_ANSWER_SENTINEL} ${readMeta(task).goldAnswers[0] ?? ''}`\n },\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const meta = readMeta(task)\n const score = scoreAnswerArtifact(artifact, meta.goldAnswers)\n return answerScoreToBenchScore(score, {\n benchmark: meta.benchmark,\n domain: meta.domain,\n questionType: meta.questionType,\n dynamism: meta.dynamism,\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAQA,SAAS,gBAAgB;AACzB,SAAS,YAAY;AAgBrB,IAAM,WAAW,KAAK,WAAW,YAAY,WAAW;AAWxD,IAAM,WAAW,MAA0B,QAAQ,IAAI;AAEvD,SAAS,UAAU,KAAc,OAA0B;AACzD,MAAI,CAAC,SAAS,GAAG,EAAG,OAAM,IAAI,MAAM,YAAY,KAAK,oBAAoB;AACzE,QAAM,QAAQ,YAAY,KAAK,CAAC,SAAS,YAAY,QAAQ,CAAC;AAC9D,QAAM,cAAc,WAAW,KAAK,CAAC,UAAU,WAAW,QAAQ,eAAe,iBAAiB,CAAC;AACnG,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,YAAY,KAAK,gBAAgB;AAC7D,MAAI,YAAY,WAAW,EAAG,OAAM,IAAI,MAAM,YAAY,KAAK,sBAAsB;AACrF,QAAM,SAAS,WAAW,IAAI,MAAM,KAAK;AACzC,QAAM,eAAe,WAAW,IAAI,aAAa,KAAK,WAAW,IAAI,YAAY,KAAK;AACtF,QAAM,WAAW,WAAW,IAAI,iBAAiB,KAAK,WAAW,IAAI,QAAQ,KAAK;AAClF,QAAM,KAAK,WAAW,IAAI,EAAE,KAAK,WAAW,IAAI,QAAQ,KAAK,QAAQ,KAAK;AAC1E,QAAM,OAAiB;AAAA,IACrB,WAAW;AAAA,IACX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