@wix/evalforge-evaluator 0.64.0 → 0.66.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
@@ -6437,7 +6437,7 @@ async function writeSkillFiles(skillDir, files) {
6437
6437
  import { randomUUID } from "crypto";
6438
6438
 
6439
6439
  // src/run-scenario/agents/claude-code/write-mcp.ts
6440
- import { writeFile as writeFile2 } from "fs/promises";
6440
+ import { writeFile as writeFile2, readFile } from "fs/promises";
6441
6441
  import { spawn } from "child_process";
6442
6442
  import { join as join3 } from "path";
6443
6443
  import { MCP_SERVERS_JSON_KEY } from "@wix/evalforge-types";
@@ -6531,6 +6531,96 @@ spawn error: ${err.message}`;
6531
6531
  }, probeMs);
6532
6532
  });
6533
6533
  }
6534
+ async function probeNpmConfig(cwd) {
6535
+ const homedir = process.env.HOME ?? "~";
6536
+ const [
6537
+ cwdNpmrc,
6538
+ homeNpmrc,
6539
+ projectRootNpmrc,
6540
+ globalNpmrc,
6541
+ npmConfigListFull,
6542
+ npmConfigGetRegistry,
6543
+ npmViewWixMcp
6544
+ ] = await Promise.all([
6545
+ readFile(join3(cwd, ".npmrc"), "utf8").catch(
6546
+ (e) => `[not found: ${e.message}]`
6547
+ ),
6548
+ readFile(join3(homedir, ".npmrc"), "utf8").catch(
6549
+ (e) => `[not found: ${e.message}]`
6550
+ ),
6551
+ readFile("/user-code/.npmrc", "utf8").catch(
6552
+ (e) => `[not found: ${e.message}]`
6553
+ ),
6554
+ runShellCapture(
6555
+ 'echo "=== globalconfig ===" && npm config get globalconfig && cat "$(npm config get globalconfig)" 2>/dev/null || echo "[no global npmrc]" && echo "=== userconfig ===" && npm config get userconfig && cat "$(npm config get userconfig)" 2>/dev/null || echo "[no user npmrc]" && echo "=== prefix ===" && npm config get prefix && cat "$(npm config get prefix)/etc/npmrc" 2>/dev/null || echo "[no prefix npmrc]"',
6556
+ cwd,
6557
+ 5e3
6558
+ ),
6559
+ runShellCapture("npm config list -l 2>&1 | head -60", cwd, 5e3),
6560
+ runShellCapture("npm config get registry", cwd, 3e3),
6561
+ runShellCapture(
6562
+ "npm view @wix/mcp version --registry https://registry.npmjs.org 2>&1",
6563
+ cwd,
6564
+ 1e4
6565
+ )
6566
+ ]);
6567
+ const npmEnvVars = {};
6568
+ for (const [key, value] of Object.entries(process.env)) {
6569
+ const lk = key.toLowerCase();
6570
+ if (lk.startsWith("npm_config") || lk.includes("token") || lk.includes("auth") || lk.includes("registry")) {
6571
+ npmEnvVars[key] = lk.includes("token") || lk.includes("auth") || lk.includes("secret") ? `[REDACTED, length=${(value ?? "").length}]` : value;
6572
+ }
6573
+ }
6574
+ return {
6575
+ cwd,
6576
+ processCwd: process.cwd(),
6577
+ cwdNpmrc: cwdNpmrc.slice(0, 1e3),
6578
+ homeNpmrc: homeNpmrc.slice(0, 1e3),
6579
+ projectRootNpmrc: projectRootNpmrc.slice(0, 1e3),
6580
+ globalNpmrc: globalNpmrc.slice(0, 2e3),
6581
+ npmConfigListFull: npmConfigListFull.slice(0, 3e3),
6582
+ npmConfigGetRegistry: npmConfigGetRegistry.trim(),
6583
+ npmViewWixMcp: npmViewWixMcp.trim().slice(0, 500),
6584
+ npmEnvVars,
6585
+ homedir
6586
+ };
6587
+ }
6588
+ function runShellCapture(cmd, cwd, timeoutMs) {
6589
+ return new Promise((resolve2) => {
6590
+ let output = "";
6591
+ let settled = false;
6592
+ const child = spawn("sh", ["-c", cmd], {
6593
+ stdio: ["pipe", "pipe", "pipe"],
6594
+ cwd,
6595
+ env: process.env
6596
+ });
6597
+ child.stdout.on("data", (chunk) => {
6598
+ output += chunk.toString();
6599
+ });
6600
+ child.stderr.on("data", (chunk) => {
6601
+ output += chunk.toString();
6602
+ });
6603
+ child.on("close", () => {
6604
+ if (!settled) {
6605
+ settled = true;
6606
+ resolve2(output);
6607
+ }
6608
+ });
6609
+ child.on("error", (err) => {
6610
+ if (!settled) {
6611
+ settled = true;
6612
+ resolve2(`[error: ${err.message}]`);
6613
+ }
6614
+ });
6615
+ setTimeout(() => {
6616
+ if (!settled) {
6617
+ settled = true;
6618
+ child.kill("SIGTERM");
6619
+ resolve2(output + "\n[timed out]");
6620
+ }
6621
+ }, timeoutMs);
6622
+ });
6623
+ }
6534
6624
 
6535
6625
  // src/run-scenario/agents/claude-code/write-sub-agents.ts
6536
6626
  import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
@@ -6808,6 +6898,33 @@ async function executeWithClaudeCode(skills, scenario, options) {
6808
6898
  options.traceContext.authToken
6809
6899
  );
6810
6900
  }
6901
+ const npmDiag = await probeNpmConfig(options.cwd);
6902
+ console.log(
6903
+ "[DEBUG-d744ca] npm-config-diagnostic",
6904
+ JSON.stringify(npmDiag)
6905
+ );
6906
+ if (options.traceContext) {
6907
+ emitTraceEvent(
6908
+ {
6909
+ evalRunId: options.traceContext.evalRunId,
6910
+ scenarioId: options.traceContext.scenarioId,
6911
+ scenarioName: options.traceContext.scenarioName,
6912
+ targetId: options.traceContext.targetId,
6913
+ targetName: options.traceContext.targetName,
6914
+ stepNumber: 0,
6915
+ type: LiveTraceEventType.DIAGNOSTIC,
6916
+ outputPreview: JSON.stringify({
6917
+ event: "npm-config-diagnostic",
6918
+ ...npmDiag
6919
+ }).slice(0, 8e3),
6920
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
6921
+ isComplete: false
6922
+ },
6923
+ options.traceContext.tracePushUrl,
6924
+ options.traceContext.routeHeader,
6925
+ options.traceContext.authToken
6926
+ );
6927
+ }
6811
6928
  }
6812
6929
  if (options.subAgents && options.subAgents.length > 0) {
6813
6930
  await writeSubAgentsToFilesystem(options.cwd, options.subAgents);