@mastra/evals 1.5.0 → 1.5.1-alpha.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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkNXVFY4CK_cjs = require('../../chunk-NXVFY4CK.cjs');
4
- var chunkUNQXHPOD_cjs = require('../../chunk-UNQXHPOD.cjs');
3
+ var chunkGGHVFNVI_cjs = require('../../chunk-GGHVFNVI.cjs');
4
+ var chunkIZLA36WC_cjs = require('../../chunk-IZLA36WC.cjs');
5
5
  var evals = require('@mastra/core/evals');
6
6
  var nlp = require('compromise');
7
7
  var keyword_extractor = require('keyword-extractor');
@@ -251,7 +251,7 @@ function createAnswerRelevancyScorer({
251
251
  description: "Extract relevant statements from the LLM output",
252
252
  outputSchema: extractOutputSchema,
253
253
  createPrompt: ({ run }) => {
254
- const assistantMessage = chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
254
+ const assistantMessage = chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
255
255
  return createExtractPrompt(assistantMessage);
256
256
  }
257
257
  }).analyze({
@@ -284,7 +284,7 @@ function createAnswerRelevancyScorer({
284
284
  ]
285
285
  },
286
286
  createPrompt: ({ run, results }) => {
287
- const input = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
287
+ const input = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
288
288
  return createScorePrompt(JSON.stringify(input), results.preprocessStepResult?.statements || []);
289
289
  }
290
290
  }).generateScore(({ results }) => {
@@ -301,13 +301,13 @@ function createAnswerRelevancyScorer({
301
301
  }
302
302
  }
303
303
  const score = relevancyCount / numberOfResults;
304
- return chunkUNQXHPOD_cjs.roundToTwoDecimals(score * options.scale);
304
+ return chunkIZLA36WC_cjs.roundToTwoDecimals(score * options.scale);
305
305
  }).generateReason({
306
306
  description: "Reason about the results",
307
307
  createPrompt: ({ run, results, score }) => {
308
308
  return createReasonPrompt({
309
- input: chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "",
310
- output: chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "",
309
+ input: chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "",
310
+ output: chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "",
311
311
  score,
312
312
  results: results.analyzeStepResult.results,
313
313
  scale: options.scale
@@ -582,7 +582,7 @@ function createAnswerSimilarityScorer({
582
582
  groundTruth: ""
583
583
  });
584
584
  }
585
- const output = chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
585
+ const output = chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
586
586
  const groundTruth = typeof run.groundTruth === "string" ? run.groundTruth : JSON.stringify(run.groundTruth);
587
587
  return createExtractPrompt2({
588
588
  output,
@@ -640,14 +640,14 @@ function createAnswerSimilarityScorer({
640
640
  );
641
641
  score -= extraInfoPenalty;
642
642
  score = Math.max(0, Math.min(1, score));
643
- return chunkUNQXHPOD_cjs.roundToTwoDecimals(score * mergedOptions.scale);
643
+ return chunkIZLA36WC_cjs.roundToTwoDecimals(score * mergedOptions.scale);
644
644
  }).generateReason({
645
645
  description: "Generate explanation of similarity score",
646
646
  createPrompt: ({ run, results, score }) => {
647
647
  if (!run.groundTruth) {
648
648
  return "No ground truth was provided for comparison. Score is 0 by default.";
649
649
  }
650
- const output = chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
650
+ const output = chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
651
651
  const groundTruth = typeof run.groundTruth === "string" ? run.groundTruth : JSON.stringify(run.groundTruth);
652
652
  return createReasonPrompt2({
653
653
  output,
@@ -849,7 +849,7 @@ function createFaithfulnessScorer({
849
849
  ]
850
850
  },
851
851
  createPrompt: ({ run }) => {
852
- const prompt = createFaithfulnessExtractPrompt({ output: chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "" });
852
+ const prompt = createFaithfulnessExtractPrompt({ output: chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "" });
853
853
  return prompt;
854
854
  }
855
855
  }).analyze({
@@ -896,13 +896,13 @@ function createFaithfulnessScorer({
896
896
  return 0;
897
897
  }
898
898
  const score = supportedClaims / totalClaims * (options?.scale || 1);
899
- return chunkUNQXHPOD_cjs.roundToTwoDecimals(score);
899
+ return chunkIZLA36WC_cjs.roundToTwoDecimals(score);
900
900
  }).generateReason({
901
901
  description: "Reason about the results",
902
902
  createPrompt: ({ run, results, score }) => {
903
903
  const prompt = createFaithfulnessReasonPrompt({
904
- input: chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "",
905
- output: chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "",
904
+ input: chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "",
905
+ output: chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "",
906
906
  context: options?.context ?? getToolInvocationContext(run.output),
907
907
  score,
908
908
  scale: options?.scale || 1,
@@ -1047,7 +1047,7 @@ function createBiasScorer({ model, options }) {
1047
1047
  "opinions"
1048
1048
  ]
1049
1049
  },
1050
- createPrompt: ({ run }) => createBiasExtractPrompt({ output: chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "" })
1050
+ createPrompt: ({ run }) => createBiasExtractPrompt({ output: chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "" })
1051
1051
  }).analyze({
1052
1052
  description: "Score the relevance of the statements to the input",
1053
1053
  outputSchema: {
@@ -1079,7 +1079,7 @@ function createBiasScorer({ model, options }) {
1079
1079
  },
1080
1080
  createPrompt: ({ run, results }) => {
1081
1081
  const prompt = createBiasAnalyzePrompt({
1082
- output: chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "",
1082
+ output: chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "",
1083
1083
  opinions: results.preprocessStepResult?.opinions || []
1084
1084
  });
1085
1085
  return prompt;
@@ -1090,7 +1090,7 @@ function createBiasScorer({ model, options }) {
1090
1090
  }
1091
1091
  const biasedVerdicts = results.analyzeStepResult.results.filter((v) => v.result.toLowerCase() === "yes");
1092
1092
  const score = biasedVerdicts.length / results.analyzeStepResult.results.length;
1093
- return chunkUNQXHPOD_cjs.roundToTwoDecimals(score * (options?.scale || 1));
1093
+ return chunkIZLA36WC_cjs.roundToTwoDecimals(score * (options?.scale || 1));
1094
1094
  }).generateReason({
1095
1095
  description: "Reason about the results",
1096
1096
  createPrompt: ({ score, results }) => {
@@ -1321,7 +1321,7 @@ function createHallucinationScorer({
1321
1321
  ]
1322
1322
  },
1323
1323
  createPrompt: ({ run }) => {
1324
- const prompt = createHallucinationExtractPrompt({ output: chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "" });
1324
+ const prompt = createHallucinationExtractPrompt({ output: chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "" });
1325
1325
  return prompt;
1326
1326
  }
1327
1327
  }).analyze({
@@ -1377,7 +1377,7 @@ function createHallucinationScorer({
1377
1377
  return 0;
1378
1378
  }
1379
1379
  const score = contradictedStatements / totalStatements * (options?.scale || 1);
1380
- return chunkUNQXHPOD_cjs.roundToTwoDecimals(score);
1380
+ return chunkIZLA36WC_cjs.roundToTwoDecimals(score);
1381
1381
  }).generateReason({
1382
1382
  description: "Reason about the results",
1383
1383
  createPrompt: async ({ run, results, score }) => {
@@ -1388,8 +1388,8 @@ function createHallucinationScorer({
1388
1388
  context = options?.context ?? [];
1389
1389
  }
1390
1390
  const prompt = createHallucinationReasonPrompt({
1391
- input: chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "",
1392
- output: chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "",
1391
+ input: chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "",
1392
+ output: chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "",
1393
1393
  context,
1394
1394
  score,
1395
1395
  scale: options?.scale || 1,
@@ -1529,8 +1529,8 @@ function createToxicityScorer({
1529
1529
  },
1530
1530
  createPrompt: ({ run }) => {
1531
1531
  const prompt = createToxicityAnalyzePrompt({
1532
- input: chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "",
1533
- output: chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? ""
1532
+ input: chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "",
1533
+ output: chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? ""
1534
1534
  });
1535
1535
  return prompt;
1536
1536
  }
@@ -1546,7 +1546,7 @@ function createToxicityScorer({
1546
1546
  }
1547
1547
  }
1548
1548
  const score = toxicityCount / numberOfVerdicts;
1549
- return chunkUNQXHPOD_cjs.roundToTwoDecimals(score * (options?.scale || 1));
1549
+ return chunkIZLA36WC_cjs.roundToTwoDecimals(score * (options?.scale || 1));
1550
1550
  }).generateReason({
1551
1551
  description: "Reason about the results",
1552
1552
  createPrompt: ({ results, score }) => {
@@ -1707,7 +1707,7 @@ function createToolCallAccuracyScorerLLM({ model, availableTools }) {
1707
1707
  if (isInputInvalid || isOutputInvalid) {
1708
1708
  throw new Error("Input and output messages cannot be null or empty");
1709
1709
  }
1710
- const { tools: actualTools, toolCallInfos } = chunkUNQXHPOD_cjs.extractToolCalls(run.output);
1710
+ const { tools: actualTools, toolCallInfos } = chunkIZLA36WC_cjs.extractToolCalls(run.output);
1711
1711
  return {
1712
1712
  actualTools,
1713
1713
  hasToolCalls: actualTools.length > 0,
@@ -1717,8 +1717,8 @@ function createToolCallAccuracyScorerLLM({ model, availableTools }) {
1717
1717
  description: "Analyze the appropriateness of tool selections",
1718
1718
  outputSchema: analyzeOutputSchema2,
1719
1719
  createPrompt: ({ run, results }) => {
1720
- const userInput = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
1721
- const agentResponse = chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
1720
+ const userInput = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
1721
+ const agentResponse = chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
1722
1722
  const toolsCalled = results.preprocessStepResult?.actualTools || [];
1723
1723
  return createAnalyzePrompt2({
1724
1724
  userInput,
@@ -1735,11 +1735,11 @@ function createToolCallAccuracyScorerLLM({ model, availableTools }) {
1735
1735
  }
1736
1736
  const appropriateToolCalls = evaluations.filter((e) => e.wasAppropriate).length;
1737
1737
  const totalToolCalls = evaluations.length;
1738
- return chunkUNQXHPOD_cjs.roundToTwoDecimals(appropriateToolCalls / totalToolCalls);
1738
+ return chunkIZLA36WC_cjs.roundToTwoDecimals(appropriateToolCalls / totalToolCalls);
1739
1739
  }).generateReason({
1740
1740
  description: "Generate human-readable explanation of tool selection evaluation",
1741
1741
  createPrompt: ({ run, results, score }) => {
1742
- const userInput = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
1742
+ const userInput = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
1743
1743
  const evaluations = results.analyzeStepResult?.evaluations || [];
1744
1744
  const missingTools = results.analyzeStepResult?.missingTools || [];
1745
1745
  return createReasonPrompt3({
@@ -1969,7 +1969,7 @@ var getContext = ({
1969
1969
  output,
1970
1970
  options
1971
1971
  }) => {
1972
- if (options.contextExtractor && chunkUNQXHPOD_cjs.isScorerRunInputForAgent(input) && chunkUNQXHPOD_cjs.isScorerRunOutputForAgent(output)) {
1972
+ if (options.contextExtractor && chunkIZLA36WC_cjs.isScorerRunInputForAgent(input) && chunkIZLA36WC_cjs.isScorerRunOutputForAgent(output)) {
1973
1973
  return options.contextExtractor(input, output);
1974
1974
  }
1975
1975
  return options.context ?? [];
@@ -1997,8 +1997,8 @@ function createContextRelevanceScorerLLM({
1997
1997
  description: "Analyze the relevance and utility of provided context",
1998
1998
  outputSchema: analyzeOutputSchema3,
1999
1999
  createPrompt: ({ run }) => {
2000
- const userQuery = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
2001
- const agentResponse = chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
2000
+ const userQuery = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
2001
+ const agentResponse = chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
2002
2002
  const context = getContext({ input: run.input, output: run.output, options });
2003
2003
  if (context.length === 0) {
2004
2004
  return createAnalyzePrompt3({
@@ -2046,11 +2046,11 @@ function createContextRelevanceScorerLLM({
2046
2046
  const missingContextPenalty = Math.min(missingContext.length * missingPenaltyRate, maxMissingPenalty);
2047
2047
  const finalScore = Math.max(0, relevanceScore - usagePenalty - missingContextPenalty);
2048
2048
  const scaledScore = finalScore * (options.scale || 1);
2049
- return chunkUNQXHPOD_cjs.roundToTwoDecimals(scaledScore);
2049
+ return chunkIZLA36WC_cjs.roundToTwoDecimals(scaledScore);
2050
2050
  }).generateReason({
2051
2051
  description: "Generate human-readable explanation of context relevance evaluation",
2052
2052
  createPrompt: ({ run, results, score }) => {
2053
- const userQuery = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
2053
+ const userQuery = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
2054
2054
  const context = getContext({ input: run.input, output: run.output, options });
2055
2055
  if (context.length === 0) {
2056
2056
  return `No context was available for evaluation. The agent response was generated without any supporting context. Score: ${score}`;
@@ -2225,7 +2225,7 @@ var getContext2 = ({
2225
2225
  output,
2226
2226
  options
2227
2227
  }) => {
2228
- if (options.contextExtractor && chunkUNQXHPOD_cjs.isScorerRunInputForAgent(input) && chunkUNQXHPOD_cjs.isScorerRunOutputForAgent(output)) {
2228
+ if (options.contextExtractor && chunkIZLA36WC_cjs.isScorerRunInputForAgent(input) && chunkIZLA36WC_cjs.isScorerRunOutputForAgent(output)) {
2229
2229
  return options.contextExtractor(input, output);
2230
2230
  }
2231
2231
  return options.context ?? [];
@@ -2253,8 +2253,8 @@ function createContextPrecisionScorer({
2253
2253
  description: "Evaluate the relevance of each context piece for generating the expected output",
2254
2254
  outputSchema: contextRelevanceOutputSchema,
2255
2255
  createPrompt: ({ run }) => {
2256
- const input = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
2257
- const output = chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
2256
+ const input = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
2257
+ const output = chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
2258
2258
  const context = getContext2({ input: run.input, output: run.output, options });
2259
2259
  if (context.length === 0) {
2260
2260
  throw new Error("No context available for evaluation");
@@ -2287,12 +2287,12 @@ function createContextPrecisionScorer({
2287
2287
  }
2288
2288
  const map = sumPrecision / relevantCount;
2289
2289
  const score = map * (options.scale || 1);
2290
- return chunkUNQXHPOD_cjs.roundToTwoDecimals(score);
2290
+ return chunkIZLA36WC_cjs.roundToTwoDecimals(score);
2291
2291
  }).generateReason({
2292
2292
  description: "Reason about the context precision results",
2293
2293
  createPrompt: ({ run, results, score }) => {
2294
- const input = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
2295
- const output = chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
2294
+ const input = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
2295
+ const output = chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
2296
2296
  const context = getContext2({ input: run.input, output: run.output, options });
2297
2297
  return createContextPrecisionReasonPrompt({
2298
2298
  input,
@@ -2590,8 +2590,8 @@ function createNoiseSensitivityScorerLLM({
2590
2590
  description: "Analyze the impact of noise on agent response quality",
2591
2591
  outputSchema: analyzeOutputSchema4,
2592
2592
  createPrompt: ({ run }) => {
2593
- const originalQuery = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
2594
- const noisyResponse = chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
2593
+ const originalQuery = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
2594
+ const noisyResponse = chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
2595
2595
  if (!originalQuery || !noisyResponse) {
2596
2596
  throw new Error("Both original query and noisy response are required for evaluation");
2597
2597
  }
@@ -2634,11 +2634,11 @@ function createNoiseSensitivityScorerLLM({
2634
2634
  const majorIssues = analysisResult.majorIssues || [];
2635
2635
  const issuesPenalty = Math.min(majorIssues.length * majorIssuePenaltyRate, maxMajorIssuePenalty);
2636
2636
  finalScore = Math.max(0, finalScore - issuesPenalty);
2637
- return chunkUNQXHPOD_cjs.roundToTwoDecimals(finalScore);
2637
+ return chunkIZLA36WC_cjs.roundToTwoDecimals(finalScore);
2638
2638
  }).generateReason({
2639
2639
  description: "Generate human-readable explanation of noise sensitivity evaluation",
2640
2640
  createPrompt: ({ run, results, score }) => {
2641
- const originalQuery = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
2641
+ const originalQuery = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
2642
2642
  const analysisResult = results.analyzeStepResult;
2643
2643
  if (!analysisResult) {
2644
2644
  throw new Error("Analysis step failed to produce results for reason generation");
@@ -3050,9 +3050,9 @@ function createPromptAlignmentScorerLLM({
3050
3050
  description: "Analyze prompt-response alignment across multiple dimensions",
3051
3051
  outputSchema: analyzeOutputSchema5,
3052
3052
  createPrompt: ({ run }) => {
3053
- const userPrompt = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
3054
- const systemPrompt = chunkUNQXHPOD_cjs.getCombinedSystemPrompt(run.input) ?? "";
3055
- const agentResponse = chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
3053
+ const userPrompt = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
3054
+ const systemPrompt = chunkIZLA36WC_cjs.getCombinedSystemPrompt(run.input) ?? "";
3055
+ const agentResponse = chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output) ?? "";
3056
3056
  if (evaluationMode === "user" && !userPrompt) {
3057
3057
  throw new Error("User prompt is required for user prompt alignment scoring");
3058
3058
  }
@@ -3088,12 +3088,12 @@ function createPromptAlignmentScorerLLM({
3088
3088
  weightedScore = userScore * SCORING_WEIGHTS.BOTH.USER_WEIGHT + systemScore * SCORING_WEIGHTS.BOTH.SYSTEM_WEIGHT;
3089
3089
  }
3090
3090
  const finalScore = weightedScore * scale;
3091
- return chunkUNQXHPOD_cjs.roundToTwoDecimals(finalScore);
3091
+ return chunkIZLA36WC_cjs.roundToTwoDecimals(finalScore);
3092
3092
  }).generateReason({
3093
3093
  description: "Generate human-readable explanation of prompt alignment evaluation",
3094
3094
  createPrompt: ({ run, results, score }) => {
3095
- const userPrompt = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
3096
- const systemPrompt = chunkUNQXHPOD_cjs.getCombinedSystemPrompt(run.input) ?? "";
3095
+ const userPrompt = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
3096
+ const systemPrompt = chunkIZLA36WC_cjs.getCombinedSystemPrompt(run.input) ?? "";
3097
3097
  const analysis = results.analyzeStepResult;
3098
3098
  if (!analysis) {
3099
3099
  return `Unable to analyze prompt alignment. Score: ${score}`;
@@ -3247,7 +3247,7 @@ function toCriterionInputs(criteria) {
3247
3247
  return criteria.map((c) => ({ criterion: c.description, required: c.required !== false }));
3248
3248
  }
3249
3249
  function getOutputText(run) {
3250
- const fromOutput = chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output);
3250
+ const fromOutput = chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output);
3251
3251
  if (fromOutput) return fromOutput;
3252
3252
  if (run.input && typeof run.input === "object" && typeof run.input.currentText === "string") {
3253
3253
  return run.input.currentText;
@@ -3258,7 +3258,7 @@ function getTaskText(run) {
3258
3258
  if (run.input && typeof run.input === "object" && typeof run.input.originalTask === "string") {
3259
3259
  return run.input.originalTask;
3260
3260
  }
3261
- return chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
3261
+ return chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
3262
3262
  }
3263
3263
  function createRubricScorer({
3264
3264
  model,
@@ -3540,8 +3540,8 @@ function createTrajectoryAccuracyScorerLLM({
3540
3540
  description: "Analyze the quality and appropriateness of the agent trajectory",
3541
3541
  outputSchema: analyzeOutputSchema7,
3542
3542
  createPrompt: ({ run, results }) => {
3543
- const userInput = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
3544
- const agentResponse = chunkUNQXHPOD_cjs.getAssistantMessageFromRunOutput(run.output.rawOutput) ?? "";
3543
+ const userInput = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
3544
+ const agentResponse = chunkIZLA36WC_cjs.getAssistantMessageFromRunOutput(run.output.rawOutput) ?? "";
3545
3545
  return createAnalyzePrompt7({
3546
3546
  userInput,
3547
3547
  agentResponse,
@@ -3566,11 +3566,11 @@ function createTrajectoryAccuracyScorerLLM({
3566
3566
  const necessityScore = necessarySteps / totalSteps;
3567
3567
  const orderScore = orderedSteps / totalSteps;
3568
3568
  const score = necessityScore * 0.6 + orderScore * 0.3 - missingPenalty * 0.1;
3569
- return chunkUNQXHPOD_cjs.roundToTwoDecimals(Math.max(0, Math.min(1, score)));
3569
+ return chunkIZLA36WC_cjs.roundToTwoDecimals(Math.max(0, Math.min(1, score)));
3570
3570
  }).generateReason({
3571
3571
  description: "Generate human-readable explanation of trajectory evaluation",
3572
3572
  createPrompt: ({ run, results, score }) => {
3573
- const userInput = chunkUNQXHPOD_cjs.getUserMessageFromRunInput(run.input) ?? "";
3573
+ const userInput = chunkIZLA36WC_cjs.getUserMessageFromRunInput(run.input) ?? "";
3574
3574
  const stepEvaluations = results.analyzeStepResult?.stepEvaluations || [];
3575
3575
  const missingSteps = results.analyzeStepResult?.missingSteps || [];
3576
3576
  const extraSteps = results.analyzeStepResult?.extraSteps || [];
@@ -3633,18 +3633,18 @@ function createCompletenessScorer() {
3633
3633
  type: "agent"
3634
3634
  }).preprocess(async ({ run }) => {
3635
3635
  const isInputInvalid = !run.input || run.input.inputMessages.some((i) => {
3636
- const content = chunkUNQXHPOD_cjs.getTextContentFromMastraDBMessage(i);
3636
+ const content = chunkIZLA36WC_cjs.getTextContentFromMastraDBMessage(i);
3637
3637
  return content === null || content === void 0;
3638
3638
  });
3639
3639
  const isOutputInvalid = !run.output || run.output.some((i) => {
3640
- const content = chunkUNQXHPOD_cjs.getTextContentFromMastraDBMessage(i);
3640
+ const content = chunkIZLA36WC_cjs.getTextContentFromMastraDBMessage(i);
3641
3641
  return content === null || content === void 0;
3642
3642
  });
3643
3643
  if (isInputInvalid || isOutputInvalid) {
3644
3644
  throw new Error("Inputs cannot be null or undefined");
3645
3645
  }
3646
- const input = run.input?.inputMessages.map((i) => chunkUNQXHPOD_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3647
- const output = run.output?.map((i) => chunkUNQXHPOD_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3646
+ const input = run.input?.inputMessages.map((i) => chunkIZLA36WC_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3647
+ const output = run.output?.map((i) => chunkIZLA36WC_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3648
3648
  const inputToProcess = input;
3649
3649
  const outputToProcess = output;
3650
3650
  const inputDoc = nlp__default.default(inputToProcess.trim());
@@ -3749,8 +3749,8 @@ function createTextualDifferenceScorer() {
3749
3749
  description: "Calculate textual difference between input and output using sequence matching algorithms.",
3750
3750
  type: "agent"
3751
3751
  }).preprocess(async ({ run }) => {
3752
- const input = run.input?.inputMessages?.map((i) => chunkUNQXHPOD_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3753
- const output = run.output?.map((i) => chunkUNQXHPOD_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3752
+ const input = run.input?.inputMessages?.map((i) => chunkIZLA36WC_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3753
+ const output = run.output?.map((i) => chunkIZLA36WC_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3754
3754
  const ratio = calculateRatio(input, output);
3755
3755
  const changes = countChanges(input, output);
3756
3756
  const maxLength = Math.max(input.length, output.length);
@@ -3773,8 +3773,8 @@ function createKeywordCoverageScorer() {
3773
3773
  description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.',
3774
3774
  type: "agent"
3775
3775
  }).preprocess(async ({ run }) => {
3776
- const input = run.input?.inputMessages?.map((i) => chunkUNQXHPOD_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3777
- const output = run.output?.map((i) => chunkUNQXHPOD_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3776
+ const input = run.input?.inputMessages?.map((i) => chunkIZLA36WC_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3777
+ const output = run.output?.map((i) => chunkIZLA36WC_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3778
3778
  if (!input && !output) {
3779
3779
  return {
3780
3780
  result: {
@@ -3827,8 +3827,8 @@ function createContentSimilarityScorer({ ignoreCase, ignoreWhitespace } = { igno
3827
3827
  description: "Calculates content similarity between input and output messages using string comparison algorithms.",
3828
3828
  type: "agent"
3829
3829
  }).preprocess(async ({ run }) => {
3830
- let processedInput = run.input?.inputMessages.map((i) => chunkUNQXHPOD_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3831
- let processedOutput = run.output.map((i) => chunkUNQXHPOD_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3830
+ let processedInput = run.input?.inputMessages.map((i) => chunkIZLA36WC_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3831
+ let processedOutput = run.output.map((i) => chunkIZLA36WC_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3832
3832
  if (ignoreCase) {
3833
3833
  processedInput = processedInput.toLowerCase();
3834
3834
  processedOutput = processedOutput.toLowerCase();
@@ -3858,7 +3858,7 @@ function createToneScorer(config = {}) {
3858
3858
  type: "agent"
3859
3859
  }).preprocess(async ({ run }) => {
3860
3860
  const sentiment = new Sentiment__default.default();
3861
- const agentMessage = run.output?.map((i) => chunkUNQXHPOD_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3861
+ const agentMessage = run.output?.map((i) => chunkIZLA36WC_cjs.getTextContentFromMastraDBMessage(i)).join(", ") || "";
3862
3862
  const responseSentiment = sentiment.analyze(agentMessage);
3863
3863
  if (referenceTone) {
3864
3864
  const referenceSentiment = sentiment.analyze(referenceTone);
@@ -3945,7 +3945,7 @@ function createToolCallAccuracyScorerCode(options) {
3945
3945
  if (isInputInvalid || isOutputInvalid) {
3946
3946
  throw new Error("Input and output messages cannot be null or empty");
3947
3947
  }
3948
- const { tools: actualTools, toolCallInfos } = chunkUNQXHPOD_cjs.extractToolCalls(run.output);
3948
+ const { tools: actualTools, toolCallInfos } = chunkIZLA36WC_cjs.extractToolCalls(run.output);
3949
3949
  const correctToolCalled = expectedTool ? strictMode ? actualTools.length === 1 && actualTools[0] === expectedTool : actualTools.includes(expectedTool) : false;
3950
3950
  return {
3951
3951
  expectedTool,
@@ -4020,7 +4020,7 @@ function createTrajectoryAccuracyScorerCode(options = {}) {
4020
4020
  const itemExpectation = run.expectedTrajectory;
4021
4021
  const effectiveOrdering = itemExpectation?.ordering ?? ordering;
4022
4022
  const effectiveAllowRepeated = itemExpectation?.allowRepeatedSteps ?? allowRepeatedSteps;
4023
- const comparison = chunkUNQXHPOD_cjs.compareTrajectories(
4023
+ const comparison = chunkIZLA36WC_cjs.compareTrajectories(
4024
4024
  actualTrajectory,
4025
4025
  { steps: resolvedExpectedSteps },
4026
4026
  {
@@ -4078,7 +4078,7 @@ function evaluateNestedExpectations(expectedSteps, actualSteps, weights = { accu
4078
4078
  const childConfig = expectedStep.children;
4079
4079
  let accuracy;
4080
4080
  if (childConfig.steps && childConfig.steps.length > 0) {
4081
- accuracy = chunkUNQXHPOD_cjs.compareTrajectories(
4081
+ accuracy = chunkIZLA36WC_cjs.compareTrajectories(
4082
4082
  childTrajectory,
4083
4083
  { steps: childConfig.steps },
4084
4084
  {
@@ -4088,18 +4088,18 @@ function evaluateNestedExpectations(expectedSteps, actualSteps, weights = { accu
4088
4088
  );
4089
4089
  }
4090
4090
  const hasEfficiencyConfig = childConfig.maxSteps !== void 0 || childConfig.maxTotalTokens !== void 0 || childConfig.maxTotalDurationMs !== void 0 || childConfig.noRedundantCalls !== void 0;
4091
- const efficiency = hasEfficiencyConfig ? chunkUNQXHPOD_cjs.checkTrajectoryEfficiency(childTrajectory, {
4091
+ const efficiency = hasEfficiencyConfig ? chunkIZLA36WC_cjs.checkTrajectoryEfficiency(childTrajectory, {
4092
4092
  maxSteps: childConfig.maxSteps,
4093
4093
  maxTotalTokens: childConfig.maxTotalTokens,
4094
4094
  maxTotalDurationMs: childConfig.maxTotalDurationMs,
4095
4095
  noRedundantCalls: childConfig.noRedundantCalls ?? true
4096
4096
  }) : void 0;
4097
4097
  const hasBlacklistConfig = childConfig.blacklistedTools && childConfig.blacklistedTools.length > 0 || childConfig.blacklistedSequences && childConfig.blacklistedSequences.length > 0;
4098
- const blacklist = hasBlacklistConfig ? chunkUNQXHPOD_cjs.checkTrajectoryBlacklist(childTrajectory, {
4098
+ const blacklist = hasBlacklistConfig ? chunkIZLA36WC_cjs.checkTrajectoryBlacklist(childTrajectory, {
4099
4099
  blacklistedTools: childConfig.blacklistedTools,
4100
4100
  blacklistedSequences: childConfig.blacklistedSequences
4101
4101
  }) : void 0;
4102
- const toolFailures = chunkUNQXHPOD_cjs.analyzeToolFailures(childTrajectory, {
4102
+ const toolFailures = chunkIZLA36WC_cjs.analyzeToolFailures(childTrajectory, {
4103
4103
  maxRetriesPerTool: childConfig.maxRetriesPerTool ?? 2
4104
4104
  });
4105
4105
  const nested = childConfig.steps ? evaluateNestedExpectations(childConfig.steps, actualStep.children, weights) : [];
@@ -4164,7 +4164,7 @@ function createTrajectoryScorerCode(options = {}) {
4164
4164
  }
4165
4165
  let accuracy;
4166
4166
  if (config.steps && config.steps.length > 0) {
4167
- accuracy = chunkUNQXHPOD_cjs.compareTrajectories(
4167
+ accuracy = chunkIZLA36WC_cjs.compareTrajectories(
4168
4168
  actualTrajectory,
4169
4169
  { steps: config.steps },
4170
4170
  {
@@ -4174,18 +4174,18 @@ function createTrajectoryScorerCode(options = {}) {
4174
4174
  );
4175
4175
  }
4176
4176
  const hasEfficiencyConfig = config.maxSteps !== void 0 || config.maxTotalTokens !== void 0 || config.maxTotalDurationMs !== void 0 || config.noRedundantCalls !== void 0;
4177
- const efficiency = hasEfficiencyConfig ? chunkUNQXHPOD_cjs.checkTrajectoryEfficiency(actualTrajectory, {
4177
+ const efficiency = hasEfficiencyConfig ? chunkIZLA36WC_cjs.checkTrajectoryEfficiency(actualTrajectory, {
4178
4178
  maxSteps: config.maxSteps,
4179
4179
  maxTotalTokens: config.maxTotalTokens,
4180
4180
  maxTotalDurationMs: config.maxTotalDurationMs,
4181
4181
  noRedundantCalls: config.noRedundantCalls ?? true
4182
4182
  }) : void 0;
4183
4183
  const hasBlacklistConfig = config.blacklistedTools && config.blacklistedTools.length > 0 || config.blacklistedSequences && config.blacklistedSequences.length > 0;
4184
- const blacklist = hasBlacklistConfig ? chunkUNQXHPOD_cjs.checkTrajectoryBlacklist(actualTrajectory, {
4184
+ const blacklist = hasBlacklistConfig ? chunkIZLA36WC_cjs.checkTrajectoryBlacklist(actualTrajectory, {
4185
4185
  blacklistedTools: config.blacklistedTools,
4186
4186
  blacklistedSequences: config.blacklistedSequences
4187
4187
  }) : void 0;
4188
- const toolFailures = chunkUNQXHPOD_cjs.analyzeToolFailures(actualTrajectory, {
4188
+ const toolFailures = chunkIZLA36WC_cjs.analyzeToolFailures(actualTrajectory, {
4189
4189
  maxRetriesPerTool: config.maxRetriesPerTool ?? 2
4190
4190
  });
4191
4191
  const nested = config.steps && config.steps.length > 0 ? evaluateNestedExpectations(config.steps, actualTrajectory.steps, w) : void 0;
@@ -4305,51 +4305,51 @@ function createTrajectoryScorerCode(options = {}) {
4305
4305
 
4306
4306
  Object.defineProperty(exports, "calledTool", {
4307
4307
  enumerable: true,
4308
- get: function () { return chunkNXVFY4CK_cjs.calledTool; }
4308
+ get: function () { return chunkGGHVFNVI_cjs.calledTool; }
4309
4309
  });
4310
4310
  Object.defineProperty(exports, "checks", {
4311
4311
  enumerable: true,
4312
- get: function () { return chunkNXVFY4CK_cjs.checks; }
4312
+ get: function () { return chunkGGHVFNVI_cjs.checks; }
4313
4313
  });
4314
4314
  Object.defineProperty(exports, "didNotCall", {
4315
4315
  enumerable: true,
4316
- get: function () { return chunkNXVFY4CK_cjs.didNotCall; }
4316
+ get: function () { return chunkGGHVFNVI_cjs.didNotCall; }
4317
4317
  });
4318
4318
  Object.defineProperty(exports, "equals", {
4319
4319
  enumerable: true,
4320
- get: function () { return chunkNXVFY4CK_cjs.equals; }
4320
+ get: function () { return chunkGGHVFNVI_cjs.equals; }
4321
4321
  });
4322
4322
  Object.defineProperty(exports, "excludes", {
4323
4323
  enumerable: true,
4324
- get: function () { return chunkNXVFY4CK_cjs.excludes; }
4324
+ get: function () { return chunkGGHVFNVI_cjs.excludes; }
4325
4325
  });
4326
4326
  Object.defineProperty(exports, "includes", {
4327
4327
  enumerable: true,
4328
- get: function () { return chunkNXVFY4CK_cjs.includes; }
4328
+ get: function () { return chunkGGHVFNVI_cjs.includes; }
4329
4329
  });
4330
4330
  Object.defineProperty(exports, "matches", {
4331
4331
  enumerable: true,
4332
- get: function () { return chunkNXVFY4CK_cjs.matches; }
4332
+ get: function () { return chunkGGHVFNVI_cjs.matches; }
4333
4333
  });
4334
4334
  Object.defineProperty(exports, "maxToolCalls", {
4335
4335
  enumerable: true,
4336
- get: function () { return chunkNXVFY4CK_cjs.maxToolCalls; }
4336
+ get: function () { return chunkGGHVFNVI_cjs.maxToolCalls; }
4337
4337
  });
4338
4338
  Object.defineProperty(exports, "noToolErrors", {
4339
4339
  enumerable: true,
4340
- get: function () { return chunkNXVFY4CK_cjs.noToolErrors; }
4340
+ get: function () { return chunkGGHVFNVI_cjs.noToolErrors; }
4341
4341
  });
4342
4342
  Object.defineProperty(exports, "similarity", {
4343
4343
  enumerable: true,
4344
- get: function () { return chunkNXVFY4CK_cjs.similarity; }
4344
+ get: function () { return chunkGGHVFNVI_cjs.similarity; }
4345
4345
  });
4346
4346
  Object.defineProperty(exports, "toolOrder", {
4347
4347
  enumerable: true,
4348
- get: function () { return chunkNXVFY4CK_cjs.toolOrder; }
4348
+ get: function () { return chunkGGHVFNVI_cjs.toolOrder; }
4349
4349
  });
4350
4350
  Object.defineProperty(exports, "usedNoTools", {
4351
4351
  enumerable: true,
4352
- get: function () { return chunkNXVFY4CK_cjs.usedNoTools; }
4352
+ get: function () { return chunkGGHVFNVI_cjs.usedNoTools; }
4353
4353
  });
4354
4354
  exports.ANSWER_RELEVANCY_AGENT_INSTRUCTIONS = ANSWER_RELEVANCY_AGENT_INSTRUCTIONS;
4355
4355
  exports.ANSWER_SIMILARITY_DEFAULT_OPTIONS = ANSWER_SIMILARITY_DEFAULT_OPTIONS;
@@ -1,5 +1,5 @@
1
- export { calledTool, checks, didNotCall, equals, excludes, includes, matches, maxToolCalls, noToolErrors, similarity, toolOrder, usedNoTools } from '../../chunk-QRAONHNV.js';
2
- import { getAssistantMessageFromRunOutput, getUserMessageFromRunInput, roundToTwoDecimals, extractToolCalls, getCombinedSystemPrompt, getTextContentFromMastraDBMessage, compareTrajectories, checkTrajectoryEfficiency, checkTrajectoryBlacklist, analyzeToolFailures, isScorerRunInputForAgent, isScorerRunOutputForAgent } from '../../chunk-BE5F2OUQ.js';
1
+ export { calledTool, checks, didNotCall, equals, excludes, includes, matches, maxToolCalls, noToolErrors, similarity, toolOrder, usedNoTools } from '../../chunk-WEADJCUA.js';
2
+ import { getAssistantMessageFromRunOutput, getUserMessageFromRunInput, roundToTwoDecimals, extractToolCalls, getCombinedSystemPrompt, getTextContentFromMastraDBMessage, compareTrajectories, checkTrajectoryEfficiency, checkTrajectoryBlacklist, analyzeToolFailures, isScorerRunInputForAgent, isScorerRunOutputForAgent } from '../../chunk-UJ4WCQ3F.js';
3
3
  import { createScorer } from '@mastra/core/evals';
4
4
  import nlp from 'compromise';
5
5
  import keyword_extractor from 'keyword-extractor';