@wix/evalforge-evaluator 0.222.0 → 0.223.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
@@ -7417,7 +7417,6 @@ async function writeFilesToDirectory(targetDir, files) {
7417
7417
 
7418
7418
  // src/run-scenario/install-dependencies.ts
7419
7419
  var import_fs = require("fs");
7420
- var import_crypto = require("crypto");
7421
7420
  var import_path2 = __toESM(require("path"));
7422
7421
  var import_child_process = require("child_process");
7423
7422
  var INSTALL_TIMEOUT_MS = 18e4;
@@ -7516,18 +7515,16 @@ function detectPackageManager(workDir) {
7516
7515
  if ((0, import_fs.existsSync)(import_path2.default.join(workDir, "pnpm-lock.yaml"))) {
7517
7516
  return {
7518
7517
  cmd: "pnpm",
7519
- args: ["install", "--frozen-lockfile"],
7520
- cacheSourceFile: "pnpm-lock.yaml"
7518
+ args: ["install", "--frozen-lockfile"]
7521
7519
  };
7522
7520
  }
7523
7521
  if ((0, import_fs.existsSync)(import_path2.default.join(workDir, "package-lock.json"))) {
7524
- return { cmd: "npm", args: ["ci"], cacheSourceFile: "package-lock.json" };
7522
+ return { cmd: "npm", args: ["ci"] };
7525
7523
  }
7526
7524
  if ((0, import_fs.existsSync)(import_path2.default.join(workDir, "yarn.lock"))) {
7527
7525
  return {
7528
7526
  cmd: "yarn",
7529
- args: ["install", "--frozen-lockfile"],
7530
- cacheSourceFile: "yarn.lock"
7527
+ args: ["install", "--frozen-lockfile"]
7531
7528
  };
7532
7529
  }
7533
7530
  return {
@@ -7538,17 +7535,9 @@ function detectPackageManager(workDir) {
7538
7535
  "--prefer-offline",
7539
7536
  "--no-fund",
7540
7537
  "--no-audit"
7541
- ],
7542
- cacheSourceFile: "package.json"
7538
+ ]
7543
7539
  };
7544
7540
  }
7545
- function cloneDirectory(src, dest) {
7546
- if (process.platform === "darwin") {
7547
- (0, import_child_process.execFileSync)("cp", ["-rc", src, dest]);
7548
- } else {
7549
- (0, import_fs.cpSync)(src, dest, { recursive: true });
7550
- }
7551
- }
7552
7541
  async function runInstall(exec, pm, workDir, onProgress) {
7553
7542
  reportRegistry(workDir, onProgress);
7554
7543
  onProgress(`[diag] npm install starting: ${pm.cmd} ${pm.args.join(" ")}`);
@@ -7579,64 +7568,13 @@ async function runInstall(exec, pm, workDir, onProgress) {
7579
7568
  clearInterval(heartbeat);
7580
7569
  }
7581
7570
  }
7582
- async function installWithCache(workDir, exec, cacheBase, pm, onProgress) {
7583
- const sourceContent = (0, import_fs.readFileSync)(
7584
- import_path2.default.join(workDir, pm.cacheSourceFile),
7585
- "utf-8"
7586
- );
7587
- const cacheKey = (0, import_crypto.createHash)("sha256").update(sourceContent).digest("hex").slice(0, 16);
7588
- const cachedNodeModules = import_path2.default.join(cacheBase, cacheKey, "node_modules");
7589
- const targetNodeModules = import_path2.default.join(workDir, "node_modules");
7590
- const cacheDir = import_path2.default.dirname(cachedNodeModules);
7591
- const cachedYarnLock = import_path2.default.join(cacheDir, "yarn.lock");
7592
- if ((0, import_fs.existsSync)(cachedNodeModules)) {
7593
- console.log(
7594
- `[environment] Restoring node_modules from cache (key: ${cacheKey})`
7595
- );
7596
- onProgress(`[diag] node_modules cache HIT (key: ${cacheKey}) \u2014 restoring`);
7597
- if (!(0, import_fs.existsSync)(targetNodeModules)) {
7598
- cloneDirectory(cachedNodeModules, targetNodeModules);
7599
- }
7600
- if ((0, import_fs.existsSync)(cachedYarnLock)) {
7601
- (0, import_fs.copyFileSync)(cachedYarnLock, import_path2.default.join(workDir, "yarn.lock"));
7602
- }
7603
- onProgress("[diag] node_modules cache restore complete");
7604
- return;
7605
- }
7606
- onProgress(`[diag] node_modules cache MISS (key: ${cacheKey})`);
7607
- const ok = await runInstall(exec, pm, workDir, onProgress);
7608
- if (!ok) {
7609
- return;
7610
- }
7611
- console.log(
7612
- "[environment] Dependency installation complete \u2014 saving to cache"
7613
- );
7614
- try {
7615
- (0, import_fs.mkdirSync)(cacheDir, { recursive: true });
7616
- const yarnLockPath = import_path2.default.join(workDir, "yarn.lock");
7617
- if ((0, import_fs.existsSync)(yarnLockPath)) {
7618
- (0, import_fs.copyFileSync)(yarnLockPath, cachedYarnLock);
7619
- }
7620
- cloneDirectory(targetNodeModules, cachedNodeModules);
7621
- } catch (err) {
7622
- console.error(
7623
- "[environment] Failed to save to cache (installation still succeeded):",
7624
- err instanceof Error ? err.message : String(err)
7625
- );
7626
- }
7627
- }
7628
7571
  async function installDependencies(workDir, onProgress, options = {}) {
7629
7572
  if (!(0, import_fs.existsSync)(import_path2.default.join(workDir, "package.json"))) {
7630
7573
  return;
7631
7574
  }
7632
7575
  const exec = options.exec ?? defaultExec;
7633
- const cacheBase = options.cacheBase;
7634
7576
  onProgress("Installing dependencies...");
7635
7577
  const pm = detectPackageManager(workDir);
7636
- if (cacheBase) {
7637
- await installWithCache(workDir, exec, cacheBase, pm, onProgress);
7638
- return;
7639
- }
7640
7578
  await runInstall(exec, pm, workDir, onProgress);
7641
7579
  }
7642
7580
 
@@ -7781,7 +7719,6 @@ function writeWixEnvFile(workDir) {
7781
7719
  async function prepareWorkingDirectory(config, evalRunId2, targetId, scenarioId, onProgress, options = {}) {
7782
7720
  const template = options.template;
7783
7721
  const baseDir = config.evaluationsDir ?? import_path3.default.join((0, import_os.tmpdir)(), "evalforge-evaluations");
7784
- const nodeModulesCacheDir = import_path3.default.join(baseDir, "_node_modules_cache");
7785
7722
  if (template) {
7786
7723
  if (!config.evaluationsDir) {
7787
7724
  console.warn(
@@ -7800,7 +7737,6 @@ async function prepareWorkingDirectory(config, evalRunId2, targetId, scenarioId,
7800
7737
  writeWixEnvFile(workDir2);
7801
7738
  onProgress("[diag] entering installDependencies");
7802
7739
  await installDependencies(workDir2, onProgress, {
7803
- cacheBase: nodeModulesCacheDir,
7804
7740
  exec: createLoggingInstallExec(onProgress)
7805
7741
  });
7806
7742
  onProgress("[diag] installDependencies returned");
@@ -7824,7 +7760,7 @@ function emitTraceEvent(event, pushEvent) {
7824
7760
  }
7825
7761
 
7826
7762
  // src/run-scenario/run-agent-with-context.ts
7827
- var import_crypto5 = require("crypto");
7763
+ var import_crypto4 = require("crypto");
7828
7764
 
7829
7765
  // src/run-scenario/agents/registry.ts
7830
7766
  var AgentAdapterRegistry = class {
@@ -7982,7 +7918,7 @@ function resolveTimeoutMs(maxTurns, maxDurationMs) {
7982
7918
  }
7983
7919
 
7984
7920
  // src/run-scenario/agents/claude-code/execute.ts
7985
- var import_crypto2 = require("crypto");
7921
+ var import_crypto = require("crypto");
7986
7922
 
7987
7923
  // src/run-scenario/agents/claude-code/write-mcp.ts
7988
7924
  var import_promises5 = require("fs/promises");
@@ -9179,7 +9115,7 @@ function buildLLMTraceFromSteps(steps, totalDurationMs, usage, model) {
9179
9115
  const totalSubSteps = thinkingSubSteps + toolSubSteps + textSubSteps || 1;
9180
9116
  if (hasThinking && (hasText || toolCallCount > 0)) {
9181
9117
  subSteps.push({
9182
- id: (0, import_crypto2.randomUUID)(),
9118
+ id: (0, import_crypto.randomUUID)(),
9183
9119
  stepNumber: 0,
9184
9120
  // renumbered below
9185
9121
  turnIndex,
@@ -9211,7 +9147,7 @@ function buildLLMTraceFromSteps(steps, totalDurationMs, usage, model) {
9211
9147
  const toolSuccess = !tc.isError;
9212
9148
  const toolError = tc.isError ? tc.errorContent ?? "Tool call failed" : void 0;
9213
9149
  subSteps.push({
9214
- id: (0, import_crypto2.randomUUID)(),
9150
+ id: (0, import_crypto.randomUUID)(),
9215
9151
  stepNumber: 0,
9216
9152
  turnIndex,
9217
9153
  type: import_evalforge_types4.LLMStepType.TOOL_USE,
@@ -9241,7 +9177,7 @@ function buildLLMTraceFromSteps(steps, totalDurationMs, usage, model) {
9241
9177
  }
9242
9178
  if (hasText && toolCallCount > 0) {
9243
9179
  subSteps.push({
9244
- id: (0, import_crypto2.randomUUID)(),
9180
+ id: (0, import_crypto.randomUUID)(),
9245
9181
  stepNumber: 0,
9246
9182
  turnIndex,
9247
9183
  type: import_evalforge_types4.LLMStepType.COMPLETION,
@@ -9263,7 +9199,7 @@ function buildLLMTraceFromSteps(steps, totalDurationMs, usage, model) {
9263
9199
  if (subSteps.length === 0) {
9264
9200
  const stepType = hasThinking && !hasText ? import_evalforge_types4.LLMStepType.THINKING : import_evalforge_types4.LLMStepType.COMPLETION;
9265
9201
  subSteps.push({
9266
- id: (0, import_crypto2.randomUUID)(),
9202
+ id: (0, import_crypto.randomUUID)(),
9267
9203
  stepNumber: 0,
9268
9204
  turnIndex,
9269
9205
  type: stepType,
@@ -9321,7 +9257,7 @@ function buildLLMTraceFromSteps(steps, totalDurationMs, usage, model) {
9321
9257
  stepTypeBreakdown
9322
9258
  };
9323
9259
  return {
9324
- id: (0, import_crypto2.randomUUID)(),
9260
+ id: (0, import_crypto.randomUUID)(),
9325
9261
  steps: traceSteps,
9326
9262
  summary
9327
9263
  };
@@ -9688,7 +9624,7 @@ async function buildOpenCodeEnv(options) {
9688
9624
 
9689
9625
  // src/run-scenario/agents/opencode/build-trace.ts
9690
9626
  var import_evalforge_types7 = require("@wix/evalforge-types");
9691
- var import_crypto3 = require("crypto");
9627
+ var import_crypto2 = require("crypto");
9692
9628
  function toCanonicalModelId(modelId) {
9693
9629
  const slashIndex = modelId.indexOf("/");
9694
9630
  return slashIndex > 0 ? modelId.slice(slashIndex + 1) : modelId;
@@ -9800,7 +9736,7 @@ function buildTurnSteps(turn, turnIndex, ctx) {
9800
9736
  const totalSubSteps = thinkingSubSteps + toolSubSteps + textSubSteps || 1;
9801
9737
  if (hasThinking && (hasText || toolCallCount > 0)) {
9802
9738
  subSteps.push({
9803
- id: (0, import_crypto3.randomUUID)(),
9739
+ id: (0, import_crypto2.randomUUID)(),
9804
9740
  stepNumber: 0,
9805
9741
  turnIndex,
9806
9742
  type: import_evalforge_types7.LLMStepType.THINKING,
@@ -9827,7 +9763,7 @@ function buildTurnSteps(turn, turnIndex, ctx) {
9827
9763
  const toolFraction = toolBudgetSteps > 0 ? 1 / toolBudgetSteps : 1;
9828
9764
  const remainingFraction = (totalSubSteps - thinkingSubSteps) / totalSubSteps;
9829
9765
  subSteps.push({
9830
- id: (0, import_crypto3.randomUUID)(),
9766
+ id: (0, import_crypto2.randomUUID)(),
9831
9767
  stepNumber: 0,
9832
9768
  turnIndex,
9833
9769
  type: import_evalforge_types7.LLMStepType.TOOL_USE,
@@ -9857,7 +9793,7 @@ function buildTurnSteps(turn, turnIndex, ctx) {
9857
9793
  }
9858
9794
  if (hasText && toolCallCount > 0) {
9859
9795
  subSteps.push({
9860
- id: (0, import_crypto3.randomUUID)(),
9796
+ id: (0, import_crypto2.randomUUID)(),
9861
9797
  stepNumber: 0,
9862
9798
  turnIndex,
9863
9799
  type: import_evalforge_types7.LLMStepType.COMPLETION,
@@ -9879,7 +9815,7 @@ function buildTurnSteps(turn, turnIndex, ctx) {
9879
9815
  if (subSteps.length === 0) {
9880
9816
  const stepType = hasThinking && !hasText ? import_evalforge_types7.LLMStepType.THINKING : import_evalforge_types7.LLMStepType.COMPLETION;
9881
9817
  subSteps.push({
9882
- id: (0, import_crypto3.randomUUID)(),
9818
+ id: (0, import_crypto2.randomUUID)(),
9883
9819
  stepNumber: 0,
9884
9820
  turnIndex,
9885
9821
  type: stepType,
@@ -9969,7 +9905,7 @@ function buildLLMTrace(timestampedEvents, totalDurationMs, model, provider, exec
9969
9905
  totalDurationMs,
9970
9906
  canonicalModel
9971
9907
  );
9972
- return { id: (0, import_crypto3.randomUUID)(), steps: allSteps, summary };
9908
+ return { id: (0, import_crypto2.randomUUID)(), steps: allSteps, summary };
9973
9909
  }
9974
9910
 
9975
9911
  // src/run-scenario/agents/opencode/gateway-cost-interceptor.ts
@@ -10838,7 +10774,7 @@ var import_anthropic = require("@ai-sdk/anthropic");
10838
10774
  var import_google = require("@ai-sdk/google");
10839
10775
  var import_openai = require("@ai-sdk/openai");
10840
10776
  var import_evalforge_types11 = require("@wix/evalforge-types");
10841
- var import_crypto4 = require("crypto");
10777
+ var import_crypto3 = require("crypto");
10842
10778
 
10843
10779
  // src/run-scenario/agents/simple-agent/mcp-tools.ts
10844
10780
  var import_mcp = require("@ai-sdk/mcp");
@@ -11475,7 +11411,7 @@ function buildLLMTrace2(steps, totalDurationMs, modelId, provider, executionStar
11475
11411
  const costUsd = calculateStepCost(step, modelId, provider, tokenUsage);
11476
11412
  const toolResultError = findToolResultError(step);
11477
11413
  return {
11478
- id: (0, import_crypto4.randomUUID)(),
11414
+ id: (0, import_crypto3.randomUUID)(),
11479
11415
  stepNumber: i + 1,
11480
11416
  turnIndex: i,
11481
11417
  type: step.toolCalls.length > 0 ? import_evalforge_types11.LLMStepType.TOOL_USE : import_evalforge_types11.LLMStepType.COMPLETION,
@@ -11502,7 +11438,7 @@ function buildLLMTrace2(steps, totalDurationMs, modelId, provider, executionStar
11502
11438
  { prompt: 0, completion: 0, total: 0 }
11503
11439
  );
11504
11440
  return {
11505
- id: (0, import_crypto4.randomUUID)(),
11441
+ id: (0, import_crypto3.randomUUID)(),
11506
11442
  steps: traceSteps,
11507
11443
  summary: {
11508
11444
  totalSteps: traceSteps.length,
@@ -12385,7 +12321,7 @@ async function runAgentWithContext(config, evalRunId2, scenario, evalData, workD
12385
12321
  }
12386
12322
  } : agent?.modelConfig ?? (llmTrace?.summary.modelsUsed?.[0] ? { model: llmTrace.summary.modelsUsed[0] } : void 0);
12387
12323
  return {
12388
- id: (0, import_crypto5.randomUUID)(),
12324
+ id: (0, import_crypto4.randomUUID)(),
12389
12325
  targetId,
12390
12326
  targetName,
12391
12327
  scenarioId: scenario.id,
@@ -12531,7 +12467,7 @@ Site ID: ${provisionedSite.id}` : void 0;
12531
12467
  }
12532
12468
 
12533
12469
  // src/evaluation-loop.ts
12534
- var import_crypto6 = require("crypto");
12470
+ var import_crypto5 = require("crypto");
12535
12471
  async function runEvaluationLoop(scenarioItems, evalData, callbacks) {
12536
12472
  const runsPerScenario = evalData.evalRun.runsPerScenario ?? 1;
12537
12473
  let completedExecutions = 0;
@@ -12557,7 +12493,7 @@ async function runEvaluationLoop(scenarioItems, evalData, callbacks) {
12557
12493
  `[Evaluator] Scenario iteration failed, recording as error result: "${scenario.name}"${iterLabel} \u2014 ${errorMsg}`
12558
12494
  );
12559
12495
  const errorResult = {
12560
- id: (0, import_crypto6.randomUUID)(),
12496
+ id: (0, import_crypto5.randomUUID)(),
12561
12497
  targetId,
12562
12498
  targetName,
12563
12499
  scenarioId: scenario.id,