@mastra/evals 1.4.0-alpha.0 → 1.5.0-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.
@@ -0,0 +1,214 @@
1
+ export interface IncludesOptions {
2
+ /** Case-insensitive match (default: true) */
3
+ ignoreCase?: boolean;
4
+ }
5
+ /**
6
+ * Scores 1 if the agent's output text contains the expected substring, 0 otherwise.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { checks } from '@mastra/evals';
11
+ * const scorer = checks.includes('sunny');
12
+ * ```
13
+ */
14
+ export declare function includes(expected: string, options?: IncludesOptions): import("@mastra/core/evals").MastraScorer<"check-includes", import("@mastra/core/evals").ScorerRunInputForAgent, import("@mastra/core/evals").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
15
+ output: string;
16
+ target: string;
17
+ found: boolean;
18
+ }> & Record<"generateScoreStepResult", number>>;
19
+ /**
20
+ * Scores 1 if the agent's output text does NOT contain the substring, 0 otherwise.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { checks } from '@mastra/evals';
25
+ * const scorer = checks.excludes('error');
26
+ * ```
27
+ */
28
+ export declare function excludes(unwanted: string, options?: IncludesOptions): import("@mastra/core/evals").MastraScorer<"check-excludes", import("@mastra/core/evals").ScorerRunInputForAgent, import("@mastra/core/evals").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
29
+ output: string;
30
+ target: string;
31
+ excluded: boolean;
32
+ }> & Record<"generateScoreStepResult", number>>;
33
+ /**
34
+ * Scores 1 if the output text exactly equals the expected string (after optional normalization).
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import { checks } from '@mastra/evals';
39
+ * const scorer = checks.equals('Hello, world!');
40
+ * ```
41
+ */
42
+ export declare function equals(expected: string, options?: IncludesOptions): import("@mastra/core/evals").MastraScorer<"check-equals", import("@mastra/core/evals").ScorerRunInputForAgent, import("@mastra/core/evals").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
43
+ output: string;
44
+ target: string;
45
+ isEqual: boolean;
46
+ }> & Record<"generateScoreStepResult", number>>;
47
+ export interface MatchesOptions {
48
+ /** If true, the output must match the pattern exactly (anchored). Default: false (substring match). */
49
+ exact?: boolean;
50
+ }
51
+ /**
52
+ * Scores 1 if the output matches the given regular expression, 0 otherwise.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * import { checks } from '@mastra/evals';
57
+ * const scorer = checks.matches(/\d{1,3}°[FC]/);
58
+ * ```
59
+ */
60
+ export declare function matches(pattern: RegExp, options?: MatchesOptions): import("@mastra/core/evals").MastraScorer<"check-matches", import("@mastra/core/evals").ScorerRunInputForAgent, import("@mastra/core/evals").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
61
+ output: string;
62
+ pattern: string;
63
+ matched: boolean;
64
+ }> & Record<"generateScoreStepResult", number>>;
65
+ export interface SimilarityOptions {
66
+ /** Minimum similarity threshold (0-1) to score 1. Default: 0.7 */
67
+ threshold?: number;
68
+ /** Case-insensitive comparison (default: true) */
69
+ ignoreCase?: boolean;
70
+ }
71
+ /**
72
+ * Returns the string similarity score (0-1) between the output and an expected string.
73
+ * Useful for fuzzy matching when exact equality is too strict.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * import { checks } from '@mastra/evals';
78
+ * const scorer = checks.similarity('Sunny, 72°F');
79
+ * ```
80
+ */
81
+ export declare function similarity(expected: string, options?: SimilarityOptions): import("@mastra/core/evals").MastraScorer<"check-similarity", import("@mastra/core/evals").ScorerRunInputForAgent, import("@mastra/core/evals").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
82
+ output: string;
83
+ target: string;
84
+ score: number;
85
+ threshold: number | undefined;
86
+ }> & Record<"generateScoreStepResult", number>>;
87
+ export interface CalledToolOptions {
88
+ /** Minimum number of times the tool must be called. Default: 1 */
89
+ times?: number;
90
+ }
91
+ /**
92
+ * Scores 1 if the agent called the specified tool (at least `times` times).
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { checks } from '@mastra/evals';
97
+ * const scorer = checks.calledTool('get_weather');
98
+ * const twice = checks.calledTool('search', { times: 2 });
99
+ * ```
100
+ */
101
+ export declare function calledTool(toolName: string, options?: CalledToolOptions): import("@mastra/core/evals").MastraScorer<"check-called-tool", import("@mastra/core/evals").ScorerRunInputForAgent, import("@mastra/core/evals").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
102
+ toolName: string;
103
+ expectedTimes: number;
104
+ actualCount: number;
105
+ passed: boolean;
106
+ }> & Record<"generateScoreStepResult", number>>;
107
+ /**
108
+ * Scores 1 if the agent did NOT call the specified tool.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * import { checks } from '@mastra/evals';
113
+ * const scorer = checks.didNotCall('delete_user');
114
+ * ```
115
+ */
116
+ export declare function didNotCall(toolName: string): import("@mastra/core/evals").MastraScorer<"check-did-not-call", import("@mastra/core/evals").ScorerRunInputForAgent, import("@mastra/core/evals").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
117
+ toolName: string;
118
+ count: number;
119
+ passed: boolean;
120
+ }> & Record<"generateScoreStepResult", number>>;
121
+ /**
122
+ * Scores 1 if the tools were called in the specified order (relaxed: allows other calls in between).
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * import { checks } from '@mastra/evals';
127
+ * const scorer = checks.toolOrder(['search', 'summarize', 'respond']);
128
+ * ```
129
+ */
130
+ export declare function toolOrder(expectedOrder: string[]): import("@mastra/core/evals").MastraScorer<"check-tool-order", import("@mastra/core/evals").ScorerRunInputForAgent, import("@mastra/core/evals").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
131
+ actualTools: string[];
132
+ expectedOrder: string[];
133
+ passed: boolean;
134
+ }> & Record<"generateScoreStepResult", number>>;
135
+ /**
136
+ * Scores 1 if the agent used no more than `max` tool calls.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * import { checks } from '@mastra/evals';
141
+ * const scorer = checks.maxToolCalls(5);
142
+ * ```
143
+ */
144
+ export declare function maxToolCalls(max: number): import("@mastra/core/evals").MastraScorer<"check-max-tool-calls", import("@mastra/core/evals").ScorerRunInputForAgent, import("@mastra/core/evals").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
145
+ count: number;
146
+ max: number;
147
+ passed: boolean;
148
+ }> & Record<"generateScoreStepResult", number>>;
149
+ /**
150
+ * Scores 1 if the agent made no tool calls at all.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * import { checks } from '@mastra/evals';
155
+ * const scorer = checks.usedNoTools();
156
+ * ```
157
+ */
158
+ export declare function usedNoTools(): import("@mastra/core/evals").MastraScorer<"check-used-no-tools", import("@mastra/core/evals").ScorerRunInputForAgent, import("@mastra/core/evals").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
159
+ count: number;
160
+ passed: boolean;
161
+ }> & Record<"generateScoreStepResult", number>>;
162
+ /**
163
+ * Scores 1 if none of the tool invocations resulted in an error state.
164
+ * Checks for tool invocations with state other than 'result' (i.e., missing results).
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * import { checks } from '@mastra/evals';
169
+ * const scorer = checks.noToolErrors();
170
+ * ```
171
+ */
172
+ export declare function noToolErrors(): import("@mastra/core/evals").MastraScorer<"check-no-tool-errors", import("@mastra/core/evals").ScorerRunInputForAgent, import("@mastra/core/evals").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
173
+ errorCount: number;
174
+ totalCalls: number;
175
+ passed: boolean;
176
+ }> & Record<"generateScoreStepResult", number>>;
177
+ /**
178
+ * Quick Checks — composable micro-scorers for common assertions.
179
+ *
180
+ * These are zero-LLM, zero-ceremony scorers that plug into the existing
181
+ * `scorers: [...]` array anywhere scorers are used. Internally they are
182
+ * standard `createScorer()` instances with the same observability, storage,
183
+ * and pipeline integration as any other scorer.
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * import { checks } from '@mastra/evals';
188
+ *
189
+ * await runEvals({
190
+ * data: [...],
191
+ * target: myAgent,
192
+ * scorers: [
193
+ * checks.includes('sunny'),
194
+ * checks.calledTool('get_weather'),
195
+ * checks.toolOrder(['search', 'summarize']),
196
+ * checks.noToolErrors(),
197
+ * ],
198
+ * });
199
+ * ```
200
+ */
201
+ export declare const checks: {
202
+ includes: typeof includes;
203
+ excludes: typeof excludes;
204
+ equals: typeof equals;
205
+ matches: typeof matches;
206
+ similarity: typeof similarity;
207
+ calledTool: typeof calledTool;
208
+ didNotCall: typeof didNotCall;
209
+ toolOrder: typeof toolOrder;
210
+ maxToolCalls: typeof maxToolCalls;
211
+ usedNoTools: typeof usedNoTools;
212
+ noToolErrors: typeof noToolErrors;
213
+ };
214
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/checks/index.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAC9B,6CAA6C;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;;;;gDAuBvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;;;;gDAuBvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;;;;gDAuBrE;AAED,MAAM,WAAW,cAAc;IAC7B,uGAAuG;IACvG,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;;;;gDAoBpE;AAED,MAAM,WAAW,iBAAiB;IAChC,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB;;;;;gDA0B3E;AAID,MAAM,WAAW,iBAAiB;IAChC,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB;;;;;gDAgB3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM;;;;gDAe1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE;;;;gDAsBhD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM;;;;gDAcvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW;;;gDAc1B;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY;;;;gDAe3B;AAsBD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;CAYlB,CAAC"}
@@ -5,4 +5,5 @@ export * from './content-similarity/index.js';
5
5
  export * from './tone/index.js';
6
6
  export * from './tool-call-accuracy/index.js';
7
7
  export * from './trajectory/index.js';
8
+ export * from './checks/index.js';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scorers/code/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scorers/code/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC"}
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var chunkNXVFY4CK_cjs = require('../../chunk-NXVFY4CK.cjs');
3
4
  var chunkUNQXHPOD_cjs = require('../../chunk-UNQXHPOD.cjs');
4
5
  var evals = require('@mastra/core/evals');
5
6
  var nlp = require('compromise');
@@ -3675,9 +3676,9 @@ function calculateRatio(input, output) {
3675
3676
  if (input.length === 0 || output.length === 0) {
3676
3677
  return 0;
3677
3678
  }
3678
- const matches = longestCommonSubsequence(input, output);
3679
+ const matches2 = longestCommonSubsequence(input, output);
3679
3680
  const total = input.length + output.length;
3680
- return total > 0 ? 2 * matches / total : 0;
3681
+ return total > 0 ? 2 * matches2 / total : 0;
3681
3682
  }
3682
3683
  function longestCommonSubsequence(str1, str2) {
3683
3684
  const m = str1.length;
@@ -3728,18 +3729,18 @@ function countChanges(input, output) {
3728
3729
  return changes;
3729
3730
  }
3730
3731
  function findCommonWords(arr1, arr2) {
3731
- let matches = 0;
3732
+ let matches2 = 0;
3732
3733
  const used = /* @__PURE__ */ new Set();
3733
3734
  for (let i = 0; i < arr1.length; i++) {
3734
3735
  for (let j = 0; j < arr2.length; j++) {
3735
3736
  if (!used.has(j) && arr1[i] === arr2[j]) {
3736
- matches++;
3737
+ matches2++;
3737
3738
  used.add(j);
3738
3739
  break;
3739
3740
  }
3740
3741
  }
3741
3742
  }
3742
- return matches;
3743
+ return matches2;
3743
3744
  }
3744
3745
  function createTextualDifferenceScorer() {
3745
3746
  return evals.createScorer({
@@ -3841,11 +3842,11 @@ function createContentSimilarityScorer({ ignoreCase, ignoreWhitespace } = { igno
3841
3842
  processedOutput
3842
3843
  };
3843
3844
  }).generateScore(({ results }) => {
3844
- const similarity = stringSimilarity__default.default.compareTwoStrings(
3845
+ const similarity2 = stringSimilarity__default.default.compareTwoStrings(
3845
3846
  results.preprocessStepResult?.processedInput,
3846
3847
  results.preprocessStepResult?.processedOutput
3847
3848
  );
3848
- return similarity;
3849
+ return similarity2;
3849
3850
  });
3850
3851
  }
3851
3852
  function createToneScorer(config = {}) {
@@ -4302,6 +4303,54 @@ function createTrajectoryScorerCode(options = {}) {
4302
4303
  });
4303
4304
  }
4304
4305
 
4306
+ Object.defineProperty(exports, "calledTool", {
4307
+ enumerable: true,
4308
+ get: function () { return chunkNXVFY4CK_cjs.calledTool; }
4309
+ });
4310
+ Object.defineProperty(exports, "checks", {
4311
+ enumerable: true,
4312
+ get: function () { return chunkNXVFY4CK_cjs.checks; }
4313
+ });
4314
+ Object.defineProperty(exports, "didNotCall", {
4315
+ enumerable: true,
4316
+ get: function () { return chunkNXVFY4CK_cjs.didNotCall; }
4317
+ });
4318
+ Object.defineProperty(exports, "equals", {
4319
+ enumerable: true,
4320
+ get: function () { return chunkNXVFY4CK_cjs.equals; }
4321
+ });
4322
+ Object.defineProperty(exports, "excludes", {
4323
+ enumerable: true,
4324
+ get: function () { return chunkNXVFY4CK_cjs.excludes; }
4325
+ });
4326
+ Object.defineProperty(exports, "includes", {
4327
+ enumerable: true,
4328
+ get: function () { return chunkNXVFY4CK_cjs.includes; }
4329
+ });
4330
+ Object.defineProperty(exports, "matches", {
4331
+ enumerable: true,
4332
+ get: function () { return chunkNXVFY4CK_cjs.matches; }
4333
+ });
4334
+ Object.defineProperty(exports, "maxToolCalls", {
4335
+ enumerable: true,
4336
+ get: function () { return chunkNXVFY4CK_cjs.maxToolCalls; }
4337
+ });
4338
+ Object.defineProperty(exports, "noToolErrors", {
4339
+ enumerable: true,
4340
+ get: function () { return chunkNXVFY4CK_cjs.noToolErrors; }
4341
+ });
4342
+ Object.defineProperty(exports, "similarity", {
4343
+ enumerable: true,
4344
+ get: function () { return chunkNXVFY4CK_cjs.similarity; }
4345
+ });
4346
+ Object.defineProperty(exports, "toolOrder", {
4347
+ enumerable: true,
4348
+ get: function () { return chunkNXVFY4CK_cjs.toolOrder; }
4349
+ });
4350
+ Object.defineProperty(exports, "usedNoTools", {
4351
+ enumerable: true,
4352
+ get: function () { return chunkNXVFY4CK_cjs.usedNoTools; }
4353
+ });
4305
4354
  exports.ANSWER_RELEVANCY_AGENT_INSTRUCTIONS = ANSWER_RELEVANCY_AGENT_INSTRUCTIONS;
4306
4355
  exports.ANSWER_SIMILARITY_DEFAULT_OPTIONS = ANSWER_SIMILARITY_DEFAULT_OPTIONS;
4307
4356
  exports.ANSWER_SIMILARITY_INSTRUCTIONS = ANSWER_SIMILARITY_INSTRUCTIONS;