@wix/evalforge-evaluator 0.63.0 → 0.64.0
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/build/index.mjs
CHANGED
|
@@ -6438,6 +6438,7 @@ import { randomUUID } from "crypto";
|
|
|
6438
6438
|
|
|
6439
6439
|
// src/run-scenario/agents/claude-code/write-mcp.ts
|
|
6440
6440
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
6441
|
+
import { spawn } from "child_process";
|
|
6441
6442
|
import { join as join3 } from "path";
|
|
6442
6443
|
import { MCP_SERVERS_JSON_KEY } from "@wix/evalforge-types";
|
|
6443
6444
|
async function writeMcpToFilesystem(cwd, mcps) {
|
|
@@ -6463,6 +6464,73 @@ async function writeMcpToFilesystem(cwd, mcps) {
|
|
|
6463
6464
|
await writeFile2(filePath, content, "utf8");
|
|
6464
6465
|
console.log(`[MCP] Written to ${filePath}`);
|
|
6465
6466
|
}
|
|
6467
|
+
async function probeMcpServers(mcps, probeMs = 5e3) {
|
|
6468
|
+
const results = [];
|
|
6469
|
+
for (const mcp of mcps) {
|
|
6470
|
+
const config = mcp.config;
|
|
6471
|
+
for (const [name2, value] of Object.entries(config)) {
|
|
6472
|
+
if (typeof value !== "object" || value === null) continue;
|
|
6473
|
+
const cfg = value;
|
|
6474
|
+
const command = cfg.command;
|
|
6475
|
+
const args = cfg.args;
|
|
6476
|
+
if (typeof command !== "string" || !Array.isArray(args)) continue;
|
|
6477
|
+
const result = await probeOneServer(
|
|
6478
|
+
name2,
|
|
6479
|
+
command,
|
|
6480
|
+
args,
|
|
6481
|
+
probeMs
|
|
6482
|
+
);
|
|
6483
|
+
results.push(result);
|
|
6484
|
+
}
|
|
6485
|
+
}
|
|
6486
|
+
return results;
|
|
6487
|
+
}
|
|
6488
|
+
function probeOneServer(name2, command, args, probeMs) {
|
|
6489
|
+
return new Promise((resolve2) => {
|
|
6490
|
+
const startMs = Date.now();
|
|
6491
|
+
let stdout = "";
|
|
6492
|
+
let stderr = "";
|
|
6493
|
+
let settled = false;
|
|
6494
|
+
const finish = (exitCode, signal) => {
|
|
6495
|
+
if (settled) return;
|
|
6496
|
+
settled = true;
|
|
6497
|
+
resolve2({
|
|
6498
|
+
name: name2,
|
|
6499
|
+
command,
|
|
6500
|
+
args,
|
|
6501
|
+
exitCode,
|
|
6502
|
+
signal,
|
|
6503
|
+
stdout: stdout.slice(-2e3),
|
|
6504
|
+
stderr: stderr.slice(-2e3),
|
|
6505
|
+
durationMs: Date.now() - startMs
|
|
6506
|
+
});
|
|
6507
|
+
};
|
|
6508
|
+
const child = spawn(command, args, {
|
|
6509
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
6510
|
+
env: process.env
|
|
6511
|
+
});
|
|
6512
|
+
child.stdout.on("data", (chunk) => {
|
|
6513
|
+
stdout += chunk.toString();
|
|
6514
|
+
});
|
|
6515
|
+
child.stderr.on("data", (chunk) => {
|
|
6516
|
+
stderr += chunk.toString();
|
|
6517
|
+
});
|
|
6518
|
+
child.on("error", (err) => {
|
|
6519
|
+
stderr += `
|
|
6520
|
+
spawn error: ${err.message}`;
|
|
6521
|
+
finish(null, null);
|
|
6522
|
+
});
|
|
6523
|
+
child.on("close", (code2, sig) => {
|
|
6524
|
+
finish(code2, sig);
|
|
6525
|
+
});
|
|
6526
|
+
setTimeout(() => {
|
|
6527
|
+
if (!settled) {
|
|
6528
|
+
child.kill("SIGTERM");
|
|
6529
|
+
finish(null, "PROBE_TIMEOUT");
|
|
6530
|
+
}
|
|
6531
|
+
}, probeMs);
|
|
6532
|
+
});
|
|
6533
|
+
}
|
|
6466
6534
|
|
|
6467
6535
|
// src/run-scenario/agents/claude-code/write-sub-agents.ts
|
|
6468
6536
|
import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
|
|
@@ -6717,6 +6785,29 @@ async function executeWithClaudeCode(skills, scenario, options) {
|
|
|
6717
6785
|
const allMessages = [];
|
|
6718
6786
|
if (options.mcps && options.mcps.length > 0) {
|
|
6719
6787
|
await writeMcpToFilesystem(options.cwd, options.mcps);
|
|
6788
|
+
const probeResults = await probeMcpServers(options.mcps);
|
|
6789
|
+
if (options.traceContext) {
|
|
6790
|
+
emitTraceEvent(
|
|
6791
|
+
{
|
|
6792
|
+
evalRunId: options.traceContext.evalRunId,
|
|
6793
|
+
scenarioId: options.traceContext.scenarioId,
|
|
6794
|
+
scenarioName: options.traceContext.scenarioName,
|
|
6795
|
+
targetId: options.traceContext.targetId,
|
|
6796
|
+
targetName: options.traceContext.targetName,
|
|
6797
|
+
stepNumber: 0,
|
|
6798
|
+
type: LiveTraceEventType.DIAGNOSTIC,
|
|
6799
|
+
outputPreview: JSON.stringify({
|
|
6800
|
+
event: "mcp-probe",
|
|
6801
|
+
results: probeResults
|
|
6802
|
+
}).slice(0, 2e3),
|
|
6803
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6804
|
+
isComplete: false
|
|
6805
|
+
},
|
|
6806
|
+
options.traceContext.tracePushUrl,
|
|
6807
|
+
options.traceContext.routeHeader,
|
|
6808
|
+
options.traceContext.authToken
|
|
6809
|
+
);
|
|
6810
|
+
}
|
|
6720
6811
|
}
|
|
6721
6812
|
if (options.subAgents && options.subAgents.length > 0) {
|
|
6722
6813
|
await writeSubAgentsToFilesystem(options.cwd, options.subAgents);
|