@tangle-network/agent-eval 2.0.17 → 2.0.19
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 +19 -0
- package/dist/analyst/index.d.ts +25 -1
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +1 -1
- package/dist/{benchmark-command-CZbrh9bS.js → benchmark-command-DOQeozeM.js} +89 -2
- package/dist/benchmark-command-DOQeozeM.js.map +1 -0
- package/dist/benchmarks/index.d.ts +13 -0
- package/dist/benchmarks/index.d.ts.map +1 -1
- package/dist/benchmarks/index.js +100 -11
- package/dist/benchmarks/index.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/openapi.json +1 -1
- package/docs/skill-eval.md +3 -0
- package/package.json +1 -1
- package/dist/benchmark-command-CZbrh9bS.js.map +0 -1
|
@@ -23,6 +23,17 @@ interface BenchmarkMetricCalibrationResult {
|
|
|
23
23
|
reasons: string[];
|
|
24
24
|
}
|
|
25
25
|
export declare function calibrateBenchmarkMetric<TPayload = unknown, TArtifact = string>(options: BenchmarkMetricCalibrationOptions<TPayload, TArtifact>): Promise<BenchmarkMetricCalibrationResult>;
|
|
26
|
+
declare function harborTaskAssetIdentity(directory: string): Promise<{
|
|
27
|
+
version: 1;
|
|
28
|
+
digest: `sha256:${string}`;
|
|
29
|
+
components: {
|
|
30
|
+
configuration: string;
|
|
31
|
+
instruction: string;
|
|
32
|
+
environment: string | null;
|
|
33
|
+
tests: string | null;
|
|
34
|
+
verifier: string | null;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
26
37
|
/** One Harbor task, as its `task.toml` and `instruction.md` state it. */
|
|
27
38
|
interface HarborTaskPayload {
|
|
28
39
|
/** `[task].name`, such as `terminal-bench/interleaved-vigenere`; the directory name when absent. */
|
|
@@ -58,6 +69,8 @@ interface HarborTaskPayload {
|
|
|
58
69
|
config?: Record<string, unknown>;
|
|
59
70
|
/** Byte identity of the imported task.toml, independent of its declared upstream revision. */
|
|
60
71
|
configDigest?: string;
|
|
72
|
+
/** Commitments to this task's admitted configuration, instruction, environment and verifier assets. */
|
|
73
|
+
assetIdentity?: Awaited<ReturnType<typeof harborTaskAssetIdentity>>;
|
|
61
74
|
/** Native metadata, including domain/field/subfield/tags in science datasets. */
|
|
62
75
|
metadata?: Record<string, unknown>;
|
|
63
76
|
/** The environment starts more than one container (a docker-compose file). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/benchmarks/calibration.ts","../../src/benchmarks/harbor.ts","../../src/benchmarks/harbor-environment.ts","../../src/benchmarks/harbor-regrade.ts","../../src/benchmarks/native.ts","../../src/benchmarks/routing/dataset.ts","../../src/benchmarks/routing/index.ts","../../src/benchmarks/runner.ts","../../src/benchmarks/standard-formats.ts"],"mappings":";;;;;;UAEiB,kCAAkC,oBAAoB;EACrE,SAAS,iBAAiB,qBAAqB,WAAW,UAAU;EACpE,MAAM,qBAAqB;EAC3B,cAAc;EACd,gBAAgB;EAChB;EACA;EACA;;UAGe;EACf;EACA,MAAM;EACN,QAAQ;EACR;EACA;EACA;EACA;;wBAGoB,yBAAyB,oBAAoB,oBACjE,SAAS,kCAAkC,UAAU,aACpD,QAAQ;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/benchmarks/calibration.ts","../../src/benchmarks/harbor-assets.ts","../../src/benchmarks/harbor.ts","../../src/benchmarks/harbor-environment.ts","../../src/benchmarks/harbor-regrade.ts","../../src/benchmarks/native.ts","../../src/benchmarks/routing/dataset.ts","../../src/benchmarks/routing/index.ts","../../src/benchmarks/runner.ts","../../src/benchmarks/standard-formats.ts"],"mappings":";;;;;;UAEiB,kCAAkC,oBAAoB;EACrE,SAAS,iBAAiB,qBAAqB,WAAW,UAAU;EACpE,MAAM,qBAAqB;EAC3B,cAAc;EACd,gBAAgB;EAChB;EACA;EACA;;UAGe;EACf;EACA,MAAM;EACN,QAAQ;EACR;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ACf;EACA;EACA;EACA;EACA;EACA;;UAGe,mBAAmB,oBAAoB;EACtD,WAAW,MAAM,kBAAkB;EACnC,UAAU,eAAe,WAAW,kBAAkB;EACtD,QAAQ;EACR;EACA;;wBAGoB,oBAAoB,oBAAoB,oBAC5D,SAAS,oBAAoB,UAAU,aACtC,QAAQ,mBAAmB,UAAU;wBA0DlB,mBAAmB,UACvC,SAAS,iBAAiB,qBAAqB,WAAW,oBAC1D,kBAAiB,gBAChB,QAAQ,MAAM,kBAAkB;wBA6BnB,eAAe,UAAU,WACvC,SAAS,iBAAiB,qBAAqB,WAAW,UAAU,aACnE,YAAY,WAAW,kBAAkB;UC3L3B;EACf;EACA;EACA;EACA,WAAW;;UAGI;EACf;EACA;EACA,WAAW;;UAGI;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,gBAAgB;EAChB,SAAS,eAAe;EACxB,WAAW;;UAGI;EACf;EACA,QAAQ;EACR,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB;EACA,SAAS;EACT;EACA,WAAW,oBAAoB;;UAGhB,kCAAkC;EACjD,oBAAoB;EACpB;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;;KAGU,kEAGC;EAEP;EACA;EACA,mBAAmB;;UAGR;EACf,oBAAoB;EACpB;EACA;EACA;EACA;;wBA0Bc,WAAW,eAAe;wBAgB1B,qBAAqB,eAAe;wBAgBpC,sBAAsB,eAAe;wBAerC,4BACd,SAAS,qCACR,MAAM,qBAAqB;wBAuCd,kCACd,SAAS,4BACR,iBACD,qBAAqB,2BACrB,0BACA;wBAwBc,0BACd,SAAS,0BACT,UAAU,2BACV,UAAS"}
|
package/dist/benchmarks/index.js
CHANGED
|
@@ -10,10 +10,11 @@ import { r as VERIFICATION_STRATEGY_SOURCES } from "../verification-strategy-CYh
|
|
|
10
10
|
import "../campaign-CJRlis5N.js";
|
|
11
11
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
12
12
|
import { z } from "zod";
|
|
13
|
+
import { createReadStream } from "node:fs";
|
|
13
14
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
14
15
|
import { hostname, tmpdir } from "node:os";
|
|
15
16
|
import { execFile } from "node:child_process";
|
|
16
|
-
import { cp, mkdir, mkdtemp, readFile, readdir, realpath, rm, writeFile } from "node:fs/promises";
|
|
17
|
+
import { cp, lstat, mkdir, mkdtemp, readFile, readdir, readlink, realpath, rm, writeFile } from "node:fs/promises";
|
|
17
18
|
import { promisify, stripVTControlCharacters } from "node:util";
|
|
18
19
|
import { parse, stringify } from "smol-toml";
|
|
19
20
|
import { setTimeout } from "node:timers/promises";
|
|
@@ -97,6 +98,82 @@ function defineBenchmark(input) {
|
|
|
97
98
|
function benchmarkDefinitionDigest(input) {
|
|
98
99
|
return hashCanonical(defineBenchmark(input));
|
|
99
100
|
}
|
|
101
|
+
// src/benchmarks/harbor-assets.ts
|
|
102
|
+
const bytesDigest = (bytes) => `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
|
|
103
|
+
/** The same context identity serves Harbor import and image rebuilding; never follows links. */
|
|
104
|
+
async function harborDirectoryDigest(directory) {
|
|
105
|
+
const root = resolve(directory);
|
|
106
|
+
const status = await lstat(root).catch((error) => {
|
|
107
|
+
if (error.code === "ENOENT") return null;
|
|
108
|
+
throw error;
|
|
109
|
+
});
|
|
110
|
+
if (!status) return null;
|
|
111
|
+
if (!status.isDirectory()) throw new Error(`Harbor asset root must be a directory: ${root}`);
|
|
112
|
+
const names = (await readdir(root, {
|
|
113
|
+
recursive: true,
|
|
114
|
+
withFileTypes: true
|
|
115
|
+
})).map((entry) => relative(root, join(entry.parentPath, entry.name))).sort();
|
|
116
|
+
const entries = [];
|
|
117
|
+
for (const name of [".", ...names]) {
|
|
118
|
+
const path = join(root, name);
|
|
119
|
+
const before = await lstat(path);
|
|
120
|
+
const mode = before.mode & 511;
|
|
121
|
+
if (before.isDirectory()) entries.push({
|
|
122
|
+
path: name,
|
|
123
|
+
kind: "directory",
|
|
124
|
+
mode
|
|
125
|
+
});
|
|
126
|
+
else if (before.isSymbolicLink()) {
|
|
127
|
+
const target = relative(root, await realpath(path));
|
|
128
|
+
if (target === ".." || target.startsWith(`..${sep}`) || isAbsolute(target)) throw new Error(`Harbor asset link escapes its declared directory: ${name}`);
|
|
129
|
+
entries.push({
|
|
130
|
+
path: name,
|
|
131
|
+
kind: "symlink",
|
|
132
|
+
target: await readlink(path)
|
|
133
|
+
});
|
|
134
|
+
} else if (before.isFile()) {
|
|
135
|
+
const digest = createHash("sha256");
|
|
136
|
+
for await (const chunk of createReadStream(path)) digest.update(chunk);
|
|
137
|
+
const after = await lstat(path);
|
|
138
|
+
if ([
|
|
139
|
+
"dev",
|
|
140
|
+
"ino",
|
|
141
|
+
"size",
|
|
142
|
+
"mode",
|
|
143
|
+
"mtimeMs",
|
|
144
|
+
"ctimeMs"
|
|
145
|
+
].some((key) => before[key] !== after[key])) throw new Error(`Harbor asset changed while hashing: ${name}`);
|
|
146
|
+
entries.push({
|
|
147
|
+
path: name,
|
|
148
|
+
kind: "file",
|
|
149
|
+
mode,
|
|
150
|
+
size: before.size,
|
|
151
|
+
sha256: digest.digest("hex")
|
|
152
|
+
});
|
|
153
|
+
} else throw new Error(`Unsupported Harbor asset: ${name}`);
|
|
154
|
+
}
|
|
155
|
+
return hashCanonical(entries);
|
|
156
|
+
}
|
|
157
|
+
async function harborTaskAssetIdentity(directory) {
|
|
158
|
+
const components = {
|
|
159
|
+
configuration: bytesDigest(await readFile(join(directory, "task.toml"))),
|
|
160
|
+
instruction: bytesDigest(await readFile(join(directory, "instruction.md"))),
|
|
161
|
+
environment: await harborDirectoryDigest(join(directory, "environment")),
|
|
162
|
+
tests: await harborDirectoryDigest(join(directory, "tests")),
|
|
163
|
+
verifier: await harborDirectoryDigest(join(directory, "verifier"))
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
version: 1,
|
|
167
|
+
digest: hashCanonical({
|
|
168
|
+
version: 1,
|
|
169
|
+
components
|
|
170
|
+
}),
|
|
171
|
+
components
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
async function assertHarborTaskAssets(payload) {
|
|
175
|
+
if (payload.assetIdentity && (await harborTaskAssetIdentity(payload.taskDir)).digest !== payload.assetIdentity.digest) throw new Error("Harbor task assets changed since import; reload the task in a fresh campaign");
|
|
176
|
+
}
|
|
100
177
|
// src/benchmarks/harbor-environment.ts
|
|
101
178
|
/**
|
|
102
179
|
* The docker host lifecycle of a Harbor case: its environment image is built once, before its first
|
|
@@ -140,15 +217,11 @@ const alive = (pid) => {
|
|
|
140
217
|
};
|
|
141
218
|
/** `harbor-case/<task dir>` and the digest of every file under `environment/`. */
|
|
142
219
|
async function caseImage(item) {
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
for (const file of (await readdir(dir, {
|
|
146
|
-
recursive: true,
|
|
147
|
-
withFileTypes: true
|
|
148
|
-
})).filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name)).sort()) digest.update(`${file.slice(dir.length)}\0`).update(await readFile(file));
|
|
220
|
+
const digest = await harborDirectoryDigest(join(item.payload.taskDir, "environment"));
|
|
221
|
+
if (!digest) throw new Error("Harbor task has no environment directory");
|
|
149
222
|
return {
|
|
150
223
|
repository: `harbor-case/${item.payload.dir.toLowerCase()}`,
|
|
151
|
-
digest: digest.
|
|
224
|
+
digest: digest.slice(7, 23)
|
|
152
225
|
};
|
|
153
226
|
}
|
|
154
227
|
/**
|
|
@@ -220,6 +293,7 @@ async function build(item, options) {
|
|
|
220
293
|
}
|
|
221
294
|
/** Build the case's environment image once and return its tag; waits for a live slot first. */
|
|
222
295
|
async function prepareCaseEnvironment(item, options = {}) {
|
|
296
|
+
await assertHarborTaskAssets(item.payload);
|
|
223
297
|
const key = item.payload.taskDir;
|
|
224
298
|
while (!live.has(key) && live.size >= (options.maxLive ?? 2)) {
|
|
225
299
|
options.signal?.throwIfAborted();
|
|
@@ -229,10 +303,12 @@ async function prepareCaseEnvironment(item, options = {}) {
|
|
|
229
303
|
});
|
|
230
304
|
}
|
|
231
305
|
let entry = live.get(key);
|
|
306
|
+
if (entry && entry.environment !== item.payload.assetIdentity?.components.environment) throw new Error("Harbor environment changed while prepared; release it before preparing again");
|
|
232
307
|
if (!entry) {
|
|
233
308
|
entry = {
|
|
234
309
|
host: options.host,
|
|
235
|
-
image: build(item, options)
|
|
310
|
+
image: build(item, options),
|
|
311
|
+
environment: item.payload.assetIdentity?.components.environment
|
|
236
312
|
};
|
|
237
313
|
live.set(key, entry);
|
|
238
314
|
entry.image.catch(() => {
|
|
@@ -240,7 +316,9 @@ async function prepareCaseEnvironment(item, options = {}) {
|
|
|
240
316
|
wake();
|
|
241
317
|
});
|
|
242
318
|
}
|
|
243
|
-
|
|
319
|
+
const image = await entry.image;
|
|
320
|
+
await assertHarborTaskAssets(item.payload);
|
|
321
|
+
return image;
|
|
244
322
|
}
|
|
245
323
|
/**
|
|
246
324
|
* Remove the case's tag and its build cache: the records whose step is the Dockerfile's first
|
|
@@ -372,6 +450,9 @@ async function readHarborTask(taskDir, relativePath) {
|
|
|
372
450
|
});
|
|
373
451
|
const environmentFiles = await readdir(join(dir, "environment")).catch(() => []);
|
|
374
452
|
const name = dir.split("/").pop() ?? dir;
|
|
453
|
+
const configDigest = `sha256:${createHash("sha256").update(configText).digest("hex")}`;
|
|
454
|
+
const assetIdentity = await harborTaskAssetIdentity(dir);
|
|
455
|
+
if (assetIdentity.components.configuration !== configDigest || assetIdentity.components.instruction !== `sha256:${createHash("sha256").update(instruction).digest("hex")}`) throw new Error("Harbor task changed during import");
|
|
375
456
|
return {
|
|
376
457
|
name: textOrNull(task.name) ?? name,
|
|
377
458
|
dir: name,
|
|
@@ -390,7 +471,8 @@ async function readHarborTask(taskDir, relativePath) {
|
|
|
390
471
|
artifacts: artifactMappings.map((entry) => entry.source),
|
|
391
472
|
artifactMappings,
|
|
392
473
|
config,
|
|
393
|
-
configDigest
|
|
474
|
+
configDigest,
|
|
475
|
+
assetIdentity,
|
|
394
476
|
metadata,
|
|
395
477
|
multiContainer: environmentFiles.some((file) => /compose\.ya?ml$/u.test(file)),
|
|
396
478
|
category: textOrNull(metadata.category),
|
|
@@ -455,7 +537,9 @@ function createHarborBenchmarkAdapter(options) {
|
|
|
455
537
|
return selectBenchmarkItems((await loadAll()).filter((item) => item.split === tag), options);
|
|
456
538
|
},
|
|
457
539
|
async evaluate(item, artifact) {
|
|
540
|
+
await assertHarborTaskAssets(item.payload);
|
|
458
541
|
const outcome = await options.grade(item, artifact);
|
|
542
|
+
await assertHarborTaskAssets(item.payload);
|
|
459
543
|
if (!outcome.succeeded) throw new Error(`${options.id} ${item.id}: the verifier did not score this artifact: ${outcome.error}`);
|
|
460
544
|
const { reward, detail, raw } = outcome.value;
|
|
461
545
|
if (!(Number.isFinite(reward) && reward >= 0 && reward <= 1)) throw new Error(`${options.id} ${item.id}: the verifier returned reward ${reward}, outside [0, 1]`);
|
|
@@ -533,7 +617,12 @@ function gradeHarborPatch(options = {}) {
|
|
|
533
617
|
const work = await mkdtemp(join(tmpdir(), "harbor-grade-"));
|
|
534
618
|
try {
|
|
535
619
|
const task = join(work, item.payload.dir);
|
|
620
|
+
await assertHarborTaskAssets(item.payload);
|
|
536
621
|
await cp(item.payload.taskDir, task, { recursive: true });
|
|
622
|
+
await assertHarborTaskAssets({
|
|
623
|
+
...item.payload,
|
|
624
|
+
taskDir: task
|
|
625
|
+
});
|
|
537
626
|
await rm(join(task, "solution"), {
|
|
538
627
|
recursive: true,
|
|
539
628
|
force: true
|