@wix/evalforge-evaluator 0.64.0 → 0.65.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.js CHANGED
@@ -6544,6 +6544,70 @@ spawn error: ${err.message}`;
6544
6544
  }, probeMs);
6545
6545
  });
6546
6546
  }
6547
+ async function probeNpmConfig(cwd) {
6548
+ const homedir = process.env.HOME ?? "~";
6549
+ const [cwdNpmrc, homeNpmrc, npmConfigList, npmConfigGetRegistry] = await Promise.all([
6550
+ (0, import_promises4.readFile)((0, import_path6.join)(cwd, ".npmrc"), "utf8").catch(
6551
+ (e) => `[not found: ${e.message}]`
6552
+ ),
6553
+ (0, import_promises4.readFile)((0, import_path6.join)(homedir, ".npmrc"), "utf8").catch(
6554
+ (e) => `[not found: ${e.message}]`
6555
+ ),
6556
+ runShellCapture("npm config list", cwd, 3e3),
6557
+ runShellCapture("npm config get registry", cwd, 3e3)
6558
+ ]);
6559
+ const npmEnvVars = {};
6560
+ for (const [key, value] of Object.entries(process.env)) {
6561
+ if (key.toLowerCase().startsWith("npm_config")) {
6562
+ npmEnvVars[key] = value;
6563
+ }
6564
+ }
6565
+ return {
6566
+ cwd,
6567
+ cwdNpmrc: cwdNpmrc.slice(0, 1e3),
6568
+ homeNpmrc: homeNpmrc.slice(0, 1e3),
6569
+ npmConfigList: npmConfigList.slice(0, 2e3),
6570
+ npmConfigGetRegistry: npmConfigGetRegistry.trim(),
6571
+ npmEnvVars,
6572
+ homedir
6573
+ };
6574
+ }
6575
+ function runShellCapture(cmd, cwd, timeoutMs) {
6576
+ return new Promise((resolve2) => {
6577
+ let output = "";
6578
+ let settled = false;
6579
+ const child = (0, import_child_process.spawn)("sh", ["-c", cmd], {
6580
+ stdio: ["pipe", "pipe", "pipe"],
6581
+ cwd,
6582
+ env: process.env
6583
+ });
6584
+ child.stdout.on("data", (chunk) => {
6585
+ output += chunk.toString();
6586
+ });
6587
+ child.stderr.on("data", (chunk) => {
6588
+ output += chunk.toString();
6589
+ });
6590
+ child.on("close", () => {
6591
+ if (!settled) {
6592
+ settled = true;
6593
+ resolve2(output);
6594
+ }
6595
+ });
6596
+ child.on("error", (err) => {
6597
+ if (!settled) {
6598
+ settled = true;
6599
+ resolve2(`[error: ${err.message}]`);
6600
+ }
6601
+ });
6602
+ setTimeout(() => {
6603
+ if (!settled) {
6604
+ settled = true;
6605
+ child.kill("SIGTERM");
6606
+ resolve2(output + "\n[timed out]");
6607
+ }
6608
+ }, timeoutMs);
6609
+ });
6610
+ }
6547
6611
 
6548
6612
  // src/run-scenario/agents/claude-code/write-sub-agents.ts
6549
6613
  var import_promises5 = require("fs/promises");
@@ -6821,6 +6885,33 @@ async function executeWithClaudeCode(skills, scenario, options) {
6821
6885
  options.traceContext.authToken
6822
6886
  );
6823
6887
  }
6888
+ const npmDiag = await probeNpmConfig(options.cwd);
6889
+ console.log(
6890
+ "[DEBUG-d744ca] npm-config-diagnostic",
6891
+ JSON.stringify(npmDiag)
6892
+ );
6893
+ if (options.traceContext) {
6894
+ emitTraceEvent(
6895
+ {
6896
+ evalRunId: options.traceContext.evalRunId,
6897
+ scenarioId: options.traceContext.scenarioId,
6898
+ scenarioName: options.traceContext.scenarioName,
6899
+ targetId: options.traceContext.targetId,
6900
+ targetName: options.traceContext.targetName,
6901
+ stepNumber: 0,
6902
+ type: import_evalforge_types3.LiveTraceEventType.DIAGNOSTIC,
6903
+ outputPreview: JSON.stringify({
6904
+ event: "npm-config-diagnostic",
6905
+ ...npmDiag
6906
+ }).slice(0, 4e3),
6907
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
6908
+ isComplete: false
6909
+ },
6910
+ options.traceContext.tracePushUrl,
6911
+ options.traceContext.routeHeader,
6912
+ options.traceContext.authToken
6913
+ );
6914
+ }
6824
6915
  }
6825
6916
  if (options.subAgents && options.subAgents.length > 0) {
6826
6917
  await writeSubAgentsToFilesystem(options.cwd, options.subAgents);