@fre4x/benchmark 1.1.8 → 1.1.11
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/dist/index.js +171 -155
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6890,6 +6890,10 @@ var require_dist = __commonJS({
|
|
|
6890
6890
|
}
|
|
6891
6891
|
});
|
|
6892
6892
|
|
|
6893
|
+
// src/index.ts
|
|
6894
|
+
import { realpathSync } from "node:fs";
|
|
6895
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
6896
|
+
|
|
6893
6897
|
// ../packages/shared/dist/errors.js
|
|
6894
6898
|
function createValidationError(field, message) {
|
|
6895
6899
|
return {
|
|
@@ -6926,7 +6930,7 @@ function createInternalError(error48) {
|
|
|
6926
6930
|
type: "text",
|
|
6927
6931
|
text: `Internal Error: ${message}
|
|
6928
6932
|
|
|
6929
|
-
Suggestion:
|
|
6933
|
+
Suggestion: Use the error details above to correct tool arguments and retry the tool call.`
|
|
6930
6934
|
}
|
|
6931
6935
|
]
|
|
6932
6936
|
};
|
|
@@ -31327,159 +31331,7 @@ function evaluateTask(task, solution, execution) {
|
|
|
31327
31331
|
};
|
|
31328
31332
|
}
|
|
31329
31333
|
|
|
31330
|
-
// src/
|
|
31331
|
-
import { mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
|
|
31332
|
-
import path3 from "node:path";
|
|
31333
|
-
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
31334
|
-
function nowStamp() {
|
|
31335
|
-
return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
31336
|
-
}
|
|
31337
|
-
function createArtifact(kind, filePath, mimeType, description) {
|
|
31338
|
-
return {
|
|
31339
|
-
artifact_id: `${kind}_${randomUUID3()}`,
|
|
31340
|
-
kind,
|
|
31341
|
-
path: filePath,
|
|
31342
|
-
mime_type: mimeType,
|
|
31343
|
-
...description ? { description } : {}
|
|
31344
|
-
};
|
|
31345
|
-
}
|
|
31346
|
-
async function ensureTaskWorkspace(attemptId, taskId) {
|
|
31347
|
-
const workspaceDir = path3.join(getAttemptWorkspaceDir(attemptId), taskId);
|
|
31348
|
-
await mkdir3(workspaceDir, { recursive: true });
|
|
31349
|
-
return workspaceDir;
|
|
31350
|
-
}
|
|
31351
|
-
async function materializeAsset(workspaceDir, taskId, asset) {
|
|
31352
|
-
if (asset.materialization !== "workspace_file") {
|
|
31353
|
-
return null;
|
|
31354
|
-
}
|
|
31355
|
-
const assetDir = path3.join(workspaceDir, "assets");
|
|
31356
|
-
await mkdir3(assetDir, { recursive: true });
|
|
31357
|
-
const fileName = `${taskId}-${asset.name}`;
|
|
31358
|
-
const filePath = path3.join(assetDir, fileName);
|
|
31359
|
-
await writeFile3(filePath, asset.content, "utf8");
|
|
31360
|
-
return createArtifact(
|
|
31361
|
-
"materialized_asset",
|
|
31362
|
-
filePath,
|
|
31363
|
-
asset.mime_type,
|
|
31364
|
-
asset.description
|
|
31365
|
-
);
|
|
31366
|
-
}
|
|
31367
|
-
async function writeSubmissionArtifact(workspaceDir, task, solution) {
|
|
31368
|
-
const extension = task.response_format === "json" ? "json" : "txt";
|
|
31369
|
-
const filePath = path3.join(workspaceDir, `submission.${extension}`);
|
|
31370
|
-
await writeFile3(filePath, solution, "utf8");
|
|
31371
|
-
return createArtifact(
|
|
31372
|
-
"submission",
|
|
31373
|
-
filePath,
|
|
31374
|
-
task.response_format === "json" ? "application/json" : "text/plain",
|
|
31375
|
-
"Submitted solution payload."
|
|
31376
|
-
);
|
|
31377
|
-
}
|
|
31378
|
-
async function writeRunnerReport(workspaceDir, task, logs, facts) {
|
|
31379
|
-
const reportPath = path3.join(
|
|
31380
|
-
workspaceDir,
|
|
31381
|
-
`runner-report-${nowStamp()}.json`
|
|
31382
|
-
);
|
|
31383
|
-
await writeFile3(
|
|
31384
|
-
reportPath,
|
|
31385
|
-
JSON.stringify(
|
|
31386
|
-
{
|
|
31387
|
-
task_id: task.task_id,
|
|
31388
|
-
logs,
|
|
31389
|
-
facts
|
|
31390
|
-
},
|
|
31391
|
-
null,
|
|
31392
|
-
2
|
|
31393
|
-
),
|
|
31394
|
-
"utf8"
|
|
31395
|
-
);
|
|
31396
|
-
return createArtifact(
|
|
31397
|
-
"runner_report",
|
|
31398
|
-
reportPath,
|
|
31399
|
-
"application/json",
|
|
31400
|
-
"Execution report with runner facts and logs."
|
|
31401
|
-
);
|
|
31402
|
-
}
|
|
31403
|
-
function countWorkspaceAssets(task) {
|
|
31404
|
-
return task.assets.filter(
|
|
31405
|
-
(asset) => asset.materialization === "workspace_file"
|
|
31406
|
-
).length;
|
|
31407
|
-
}
|
|
31408
|
-
async function executeTaskRunner(attempt, task, solution) {
|
|
31409
|
-
const workspaceDir = await ensureTaskWorkspace(
|
|
31410
|
-
attempt.attempt_id,
|
|
31411
|
-
task.task_id
|
|
31412
|
-
);
|
|
31413
|
-
const artifacts = [];
|
|
31414
|
-
const logs = [
|
|
31415
|
-
`runner ${attempt.runner_kind} started for task ${task.task_id}`
|
|
31416
|
-
];
|
|
31417
|
-
const materializedAssets = await Promise.all(
|
|
31418
|
-
task.assets.map(async (asset) => {
|
|
31419
|
-
const artifact = await materializeAsset(
|
|
31420
|
-
workspaceDir,
|
|
31421
|
-
task.task_id,
|
|
31422
|
-
asset
|
|
31423
|
-
);
|
|
31424
|
-
return { artifact, asset };
|
|
31425
|
-
})
|
|
31426
|
-
);
|
|
31427
|
-
for (const { artifact, asset } of materializedAssets) {
|
|
31428
|
-
if (artifact) {
|
|
31429
|
-
artifacts.push(artifact);
|
|
31430
|
-
logs.push(
|
|
31431
|
-
`materialized asset ${asset.asset_id} to ${artifact.path}`
|
|
31432
|
-
);
|
|
31433
|
-
} else {
|
|
31434
|
-
logs.push(`kept asset ${asset.asset_id} inline`);
|
|
31435
|
-
}
|
|
31436
|
-
}
|
|
31437
|
-
const submissionArtifact = await writeSubmissionArtifact(
|
|
31438
|
-
workspaceDir,
|
|
31439
|
-
task,
|
|
31440
|
-
solution
|
|
31441
|
-
);
|
|
31442
|
-
artifacts.push(submissionArtifact);
|
|
31443
|
-
logs.push(`wrote submission artifact ${submissionArtifact.path}`);
|
|
31444
|
-
const facts = {
|
|
31445
|
-
materialized_asset_count: countWorkspaceAssets(task),
|
|
31446
|
-
total_asset_count: task.assets.length,
|
|
31447
|
-
response_format: task.response_format,
|
|
31448
|
-
family: attempt.family
|
|
31449
|
-
};
|
|
31450
|
-
if (attempt.runner_kind === "code_runner") {
|
|
31451
|
-
facts.domain = "code";
|
|
31452
|
-
logs.push("prepared code workspace inputs");
|
|
31453
|
-
} else if (attempt.runner_kind === "browser_runner") {
|
|
31454
|
-
facts.domain = "web";
|
|
31455
|
-
logs.push("prepared browser snapshot workspace");
|
|
31456
|
-
} else {
|
|
31457
|
-
facts.domain = "os";
|
|
31458
|
-
logs.push("prepared os workspace inventory");
|
|
31459
|
-
}
|
|
31460
|
-
const reportArtifact = await writeRunnerReport(
|
|
31461
|
-
workspaceDir,
|
|
31462
|
-
task,
|
|
31463
|
-
logs,
|
|
31464
|
-
facts
|
|
31465
|
-
);
|
|
31466
|
-
artifacts.push(reportArtifact);
|
|
31467
|
-
logs.push(`wrote runner report ${reportArtifact.path}`);
|
|
31468
|
-
return {
|
|
31469
|
-
runner_kind: attempt.runner_kind,
|
|
31470
|
-
workspace_dir: workspaceDir,
|
|
31471
|
-
logs,
|
|
31472
|
-
facts,
|
|
31473
|
-
artifacts
|
|
31474
|
-
};
|
|
31475
|
-
}
|
|
31476
|
-
|
|
31477
|
-
// src/index.ts
|
|
31478
|
-
var PACKAGE_VERSION = getPackageVersion(import.meta.url);
|
|
31479
|
-
var server = new McpServer({
|
|
31480
|
-
name: "@fre4x/benchmark",
|
|
31481
|
-
version: PACKAGE_VERSION
|
|
31482
|
-
});
|
|
31334
|
+
// src/format.ts
|
|
31483
31335
|
function buildTextResult(text, structuredContent) {
|
|
31484
31336
|
return {
|
|
31485
31337
|
content: [{ type: "text", text: truncateToLimit(text) }],
|
|
@@ -31669,6 +31521,155 @@ function formatCatalogStatus(status) {
|
|
|
31669
31521
|
])
|
|
31670
31522
|
].join("\n");
|
|
31671
31523
|
}
|
|
31524
|
+
|
|
31525
|
+
// src/runners.ts
|
|
31526
|
+
import { mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
|
|
31527
|
+
import path3 from "node:path";
|
|
31528
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
31529
|
+
function nowStamp() {
|
|
31530
|
+
return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
31531
|
+
}
|
|
31532
|
+
function createArtifact(kind, filePath, mimeType, description) {
|
|
31533
|
+
return {
|
|
31534
|
+
artifact_id: `${kind}_${randomUUID3()}`,
|
|
31535
|
+
kind,
|
|
31536
|
+
path: filePath,
|
|
31537
|
+
mime_type: mimeType,
|
|
31538
|
+
...description ? { description } : {}
|
|
31539
|
+
};
|
|
31540
|
+
}
|
|
31541
|
+
async function ensureTaskWorkspace(attemptId, taskId) {
|
|
31542
|
+
const workspaceDir = path3.join(getAttemptWorkspaceDir(attemptId), taskId);
|
|
31543
|
+
await mkdir3(workspaceDir, { recursive: true });
|
|
31544
|
+
return workspaceDir;
|
|
31545
|
+
}
|
|
31546
|
+
async function materializeAsset(workspaceDir, taskId, asset) {
|
|
31547
|
+
if (asset.materialization !== "workspace_file") {
|
|
31548
|
+
return null;
|
|
31549
|
+
}
|
|
31550
|
+
const assetDir = path3.join(workspaceDir, "assets");
|
|
31551
|
+
await mkdir3(assetDir, { recursive: true });
|
|
31552
|
+
const fileName = `${taskId}-${asset.name}`;
|
|
31553
|
+
const filePath = path3.join(assetDir, fileName);
|
|
31554
|
+
await writeFile3(filePath, asset.content, "utf8");
|
|
31555
|
+
return createArtifact(
|
|
31556
|
+
"materialized_asset",
|
|
31557
|
+
filePath,
|
|
31558
|
+
asset.mime_type,
|
|
31559
|
+
asset.description
|
|
31560
|
+
);
|
|
31561
|
+
}
|
|
31562
|
+
async function writeSubmissionArtifact(workspaceDir, task, solution) {
|
|
31563
|
+
const extension = task.response_format === "json" ? "json" : "txt";
|
|
31564
|
+
const filePath = path3.join(workspaceDir, `submission.${extension}`);
|
|
31565
|
+
await writeFile3(filePath, solution, "utf8");
|
|
31566
|
+
return createArtifact(
|
|
31567
|
+
"submission",
|
|
31568
|
+
filePath,
|
|
31569
|
+
task.response_format === "json" ? "application/json" : "text/plain",
|
|
31570
|
+
"Submitted solution payload."
|
|
31571
|
+
);
|
|
31572
|
+
}
|
|
31573
|
+
async function writeRunnerReport(workspaceDir, task, logs, facts) {
|
|
31574
|
+
const reportPath = path3.join(
|
|
31575
|
+
workspaceDir,
|
|
31576
|
+
`runner-report-${nowStamp()}.json`
|
|
31577
|
+
);
|
|
31578
|
+
await writeFile3(
|
|
31579
|
+
reportPath,
|
|
31580
|
+
JSON.stringify(
|
|
31581
|
+
{
|
|
31582
|
+
task_id: task.task_id,
|
|
31583
|
+
logs,
|
|
31584
|
+
facts
|
|
31585
|
+
},
|
|
31586
|
+
null,
|
|
31587
|
+
2
|
|
31588
|
+
),
|
|
31589
|
+
"utf8"
|
|
31590
|
+
);
|
|
31591
|
+
return createArtifact(
|
|
31592
|
+
"runner_report",
|
|
31593
|
+
reportPath,
|
|
31594
|
+
"application/json",
|
|
31595
|
+
"Execution report with runner facts and logs."
|
|
31596
|
+
);
|
|
31597
|
+
}
|
|
31598
|
+
function countWorkspaceAssets(task) {
|
|
31599
|
+
return task.assets.filter(
|
|
31600
|
+
(asset) => asset.materialization === "workspace_file"
|
|
31601
|
+
).length;
|
|
31602
|
+
}
|
|
31603
|
+
async function executeTaskRunner(attempt, task, solution) {
|
|
31604
|
+
const workspaceDir = await ensureTaskWorkspace(
|
|
31605
|
+
attempt.attempt_id,
|
|
31606
|
+
task.task_id
|
|
31607
|
+
);
|
|
31608
|
+
const artifacts = [];
|
|
31609
|
+
const logs = [
|
|
31610
|
+
`runner ${attempt.runner_kind} started for task ${task.task_id}`
|
|
31611
|
+
];
|
|
31612
|
+
const materializedAssets = await Promise.all(
|
|
31613
|
+
task.assets.map(async (asset) => {
|
|
31614
|
+
const artifact = await materializeAsset(
|
|
31615
|
+
workspaceDir,
|
|
31616
|
+
task.task_id,
|
|
31617
|
+
asset
|
|
31618
|
+
);
|
|
31619
|
+
return { artifact, asset };
|
|
31620
|
+
})
|
|
31621
|
+
);
|
|
31622
|
+
for (const { artifact, asset } of materializedAssets) {
|
|
31623
|
+
if (artifact) {
|
|
31624
|
+
artifacts.push(artifact);
|
|
31625
|
+
logs.push(
|
|
31626
|
+
`materialized asset ${asset.asset_id} to ${artifact.path}`
|
|
31627
|
+
);
|
|
31628
|
+
} else {
|
|
31629
|
+
logs.push(`kept asset ${asset.asset_id} inline`);
|
|
31630
|
+
}
|
|
31631
|
+
}
|
|
31632
|
+
const submissionArtifact = await writeSubmissionArtifact(
|
|
31633
|
+
workspaceDir,
|
|
31634
|
+
task,
|
|
31635
|
+
solution
|
|
31636
|
+
);
|
|
31637
|
+
artifacts.push(submissionArtifact);
|
|
31638
|
+
logs.push(`wrote submission artifact ${submissionArtifact.path}`);
|
|
31639
|
+
const facts = {
|
|
31640
|
+
materialized_asset_count: countWorkspaceAssets(task),
|
|
31641
|
+
total_asset_count: task.assets.length,
|
|
31642
|
+
response_format: task.response_format,
|
|
31643
|
+
family: attempt.family
|
|
31644
|
+
};
|
|
31645
|
+
if (attempt.runner_kind === "code_runner") {
|
|
31646
|
+
facts.domain = "code";
|
|
31647
|
+
logs.push("prepared code workspace inputs");
|
|
31648
|
+
} else if (attempt.runner_kind === "browser_runner") {
|
|
31649
|
+
facts.domain = "web";
|
|
31650
|
+
logs.push("prepared browser snapshot workspace");
|
|
31651
|
+
} else {
|
|
31652
|
+
facts.domain = "os";
|
|
31653
|
+
logs.push("prepared os workspace inventory");
|
|
31654
|
+
}
|
|
31655
|
+
const reportArtifact = await writeRunnerReport(
|
|
31656
|
+
workspaceDir,
|
|
31657
|
+
task,
|
|
31658
|
+
logs,
|
|
31659
|
+
facts
|
|
31660
|
+
);
|
|
31661
|
+
artifacts.push(reportArtifact);
|
|
31662
|
+
logs.push(`wrote runner report ${reportArtifact.path}`);
|
|
31663
|
+
return {
|
|
31664
|
+
runner_kind: attempt.runner_kind,
|
|
31665
|
+
workspace_dir: workspaceDir,
|
|
31666
|
+
logs,
|
|
31667
|
+
facts,
|
|
31668
|
+
artifacts
|
|
31669
|
+
};
|
|
31670
|
+
}
|
|
31671
|
+
|
|
31672
|
+
// src/handlers.ts
|
|
31672
31673
|
async function handleGetCatalogStatus() {
|
|
31673
31674
|
try {
|
|
31674
31675
|
const status = await getCatalogStatus();
|
|
@@ -32198,6 +32199,13 @@ async function handleCancelAttempt(params) {
|
|
|
32198
32199
|
return createInternalError(error48);
|
|
32199
32200
|
}
|
|
32200
32201
|
}
|
|
32202
|
+
|
|
32203
|
+
// src/index.ts
|
|
32204
|
+
var PACKAGE_VERSION = getPackageVersion(import.meta.url);
|
|
32205
|
+
var server = new McpServer({
|
|
32206
|
+
name: "@fre4x/benchmark",
|
|
32207
|
+
version: PACKAGE_VERSION
|
|
32208
|
+
});
|
|
32201
32209
|
server.registerTool(
|
|
32202
32210
|
"list_challenges",
|
|
32203
32211
|
{
|
|
@@ -32289,12 +32297,20 @@ server.registerTool(
|
|
|
32289
32297
|
},
|
|
32290
32298
|
handleCancelAttempt
|
|
32291
32299
|
);
|
|
32300
|
+
function isMainModule(url2) {
|
|
32301
|
+
if (!process.argv[1]) return false;
|
|
32302
|
+
try {
|
|
32303
|
+
return realpathSync(fileURLToPath2(url2)) === realpathSync(process.argv[1]);
|
|
32304
|
+
} catch {
|
|
32305
|
+
return false;
|
|
32306
|
+
}
|
|
32307
|
+
}
|
|
32292
32308
|
async function main() {
|
|
32293
32309
|
const transport = new StdioServerTransport();
|
|
32294
32310
|
await server.connect(transport);
|
|
32295
32311
|
console.error("[benchmark] MCP server running via stdio");
|
|
32296
32312
|
}
|
|
32297
|
-
if (
|
|
32313
|
+
if (isMainModule(import.meta.url)) {
|
|
32298
32314
|
main().catch((error48) => {
|
|
32299
32315
|
console.error("[benchmark] fatal error", error48);
|
|
32300
32316
|
process.exit(1);
|