@mastra/evals 1.10.8-alpha.1 → 1.10.8-alpha.2

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.
@@ -3,7 +3,7 @@ name: mastra-evals
3
3
  description: Documentation for @mastra/evals. Use when working with @mastra/evals APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/evals"
6
- version: "1.10.8-alpha.1"
6
+ version: "1.10.8-alpha.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.10.8-alpha.1",
2
+ "version": "1.10.8-alpha.2",
3
3
  "package": "@mastra/evals",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/tool-call-accuracy/index.ts"],"names":[],"mappings":"AAEA,UAAU,uBAAuB;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAyDD,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,uBAAuB;;;;;;;;;gDA2DhF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/tool-call-accuracy/index.ts"],"names":[],"mappings":"AAEA,UAAU,uBAAuB;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAiDD,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,uBAAuB;;;;;;;;;gDA2DhF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/trajectory/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,2BAA2B,EAC3B,qBAA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B,CAAC;IACtC,yCAAyC;IACzC,UAAU,CAAC,EAAE,0BAA0B,CAAC;IACxC,wCAAwC;IACxC,SAAS,CAAC,EAAE,yBAAyB,CAAC;IACtC,2CAA2C;IAC3C,YAAY,CAAC,EAAE,yBAAyB,CAAC;IACzC,gDAAgD;IAChD,MAAM,CAAC,EAAE,sBAAsB,EAAE,CAAC;CACnC,CAAC;AA2KF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,kGAAkG;IAClG,KAAK,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,QAAQ,CAAC,EAAE,0BAA0B,CAAC;IACtC,mDAAmD;IACnD,UAAU,CAAC,EAAE,0BAA0B,CAAC;IACxC,uDAAuD;IACvD,SAAS,CAAC,EAAE,yBAAyB,CAAC;IACtC,6BAA6B;IAC7B,YAAY,CAAC,EAAE,yBAAyB,CAAC;IACzC,wDAAwD;IACxD,MAAM,CAAC,EAAE,sBAAsB,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACrC,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,sBAAsB,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,2BAAgC;;;;;;;6FA0NnF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/llm/trajectory/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAyC,MAAM,oBAAoB,CAAC;AAE1G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAK1D,MAAM,WAAW,4BAA4B;IAC3C,oCAAoC;IACpC,KAAK,EAAE,iBAAiB,CAAC;IACzB,sDAAsD;IACtD,kBAAkB,CAAC,EAAE,UAAU,GAAG,YAAY,EAAE,CAAC;CAClD;AAkED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,iCAAiC,CAAC,EAChD,KAAK,EACL,kBAAkB,EAAE,wBAAwB,GAC7C,EAAE,4BAA4B;;;;;;;;;;;;;;;6FAuG9B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/llm/trajectory/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAyC,MAAM,oBAAoB,CAAC;AAE1G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAU1D,MAAM,WAAW,4BAA4B;IAC3C,oCAAoC;IACpC,KAAK,EAAE,iBAAiB,CAAC;IACzB,sDAAsD;IACtD,kBAAkB,CAAC,EAAE,UAAU,GAAG,YAAY,EAAE,CAAC;CAClD;AAkED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,iCAAiC,CAAC,EAChD,KAAK,EACL,kBAAkB,EAAE,wBAAwB,GAC7C,EAAE,4BAA4B;;;;;;;;;;;;;;;6FAuG9B"}
@@ -3814,14 +3814,13 @@ function formatStepDetails(step) {
3814
3814
  if (step.toolResult !== void 0) parts.push(`result: ${JSON.stringify(step.toolResult)}`);
3815
3815
  return parts.length > 0 ? ` (${parts.join(", ")})` : "";
3816
3816
  }
3817
- case "model_generation": return step.modelId ? ` (model: ${step.modelId})` : "";
3818
3817
  case "workflow_step": return step.output !== void 0 ? ` (output: ${JSON.stringify(step.output)})` : "";
3819
3818
  default: return "";
3820
3819
  }
3821
3820
  }
3822
3821
  function formatTrajectory(trajectory, indent = 0) {
3823
3822
  const prefix = " ".repeat(indent);
3824
- return trajectory.steps.map((step, i) => {
3823
+ return require_scorers_utils.toToolLevelSteps(trajectory.steps).map((step, i) => {
3825
3824
  let line = `${prefix}${i + 1}. [${step.stepType}] ${step.name}${formatStepDetails(step)}`;
3826
3825
  if (step.children && step.children.length > 0) line += `\n${formatTrajectory({ steps: step.children }, indent + 1)}`;
3827
3826
  return line;
@@ -4223,16 +4222,11 @@ function createToneScorer(config = {}) {
4223
4222
  //#region src/scorers/code/tool-call-accuracy/index.ts
4224
4223
  function checkToolOrder(actualTools, expectedOrder, strictMode = false) {
4225
4224
  if (strictMode) return JSON.stringify(actualTools) === JSON.stringify(expectedOrder);
4226
- const expectedIndices = [];
4225
+ let searchFrom = 0;
4227
4226
  for (const expectedTool of expectedOrder) {
4228
- const index = actualTools.indexOf(expectedTool);
4227
+ const index = actualTools.indexOf(expectedTool, searchFrom);
4229
4228
  if (index === -1) return false;
4230
- expectedIndices.push(index);
4231
- }
4232
- for (let i = 1; i < expectedIndices.length; i++) {
4233
- const currentIndex = expectedIndices[i];
4234
- const prevIndex = expectedIndices[i - 1];
4235
- if (currentIndex !== void 0 && prevIndex !== void 0 && currentIndex <= prevIndex) return false;
4229
+ searchFrom = index + 1;
4236
4230
  }
4237
4231
  return true;
4238
4232
  }
@@ -4356,7 +4350,7 @@ function createTrajectoryAccuracyScorerCode(options = {}) {
4356
4350
  actualTrajectory,
4357
4351
  expectedTrajectory: void 0,
4358
4352
  comparison: void 0,
4359
- actualStepNames: actualTrajectory.steps.map((s) => s.name),
4353
+ actualStepNames: require_scorers_utils.toToolLevelSteps(actualTrajectory.steps).map((s) => s.name),
4360
4354
  expectedStepNames: [],
4361
4355
  error: "No expected trajectory provided (pass via options or dataset item expectedTrajectory)"
4362
4356
  };
@@ -4371,7 +4365,7 @@ function createTrajectoryAccuracyScorerCode(options = {}) {
4371
4365
  actualTrajectory,
4372
4366
  expectedTrajectory: { steps: resolvedExpectedSteps },
4373
4367
  comparison,
4374
- actualStepNames: actualTrajectory.steps.map((s) => s.name),
4368
+ actualStepNames: require_scorers_utils.toToolLevelSteps(actualTrajectory.steps).map((s) => s.name),
4375
4369
  expectedStepNames: resolvedExpectedSteps.map((s) => s.name)
4376
4370
  };
4377
4371
  }).generateScore(({ results }) => {
@@ -4394,12 +4388,13 @@ function evaluateNestedExpectations(expectedSteps, actualSteps, weights = {
4394
4388
  blacklist: .1
4395
4389
  }) {
4396
4390
  const results = [];
4397
- const matchedIndices = /* @__PURE__ */ new Set();
4391
+ const matchedSteps = /* @__PURE__ */ new Set();
4392
+ const toolLevelSteps = require_scorers_utils.toToolLevelSteps(actualSteps);
4393
+ const containerNames = new Set(actualSteps.filter((s) => s.stepType === "model_generation" || s.stepType === "processor_run").map((s) => s.name));
4398
4394
  for (const expectedStep of expectedSteps) {
4399
4395
  if (!expectedStep.children) continue;
4400
- const matchIndex = actualSteps.findIndex((s, i) => !matchedIndices.has(i) && s.name === expectedStep.name && (!expectedStep.stepType || s.stepType === expectedStep.stepType));
4401
- const actualStep = matchIndex >= 0 ? actualSteps[matchIndex] : void 0;
4402
- if (matchIndex >= 0) matchedIndices.add(matchIndex);
4396
+ const actualStep = (expectedStep.stepType === "model_generation" || expectedStep.stepType === "processor_run" || !expectedStep.stepType && containerNames.has(expectedStep.name) ? actualSteps : toolLevelSteps).find((s) => !matchedSteps.has(s) && s.name === expectedStep.name && (!expectedStep.stepType || s.stepType === expectedStep.stepType));
4397
+ if (actualStep) matchedSteps.add(actualStep);
4403
4398
  if (!actualStep) {
4404
4399
  const expectedStepCount = expectedStep.children.steps?.length ?? 0;
4405
4400
  results.push({