@mastra/evals 0.13.1 → 0.13.3-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.
- package/dist/{chunk-5CVZXIFW.js → chunk-4LRZVFXR.js} +32 -3
- package/dist/chunk-4LRZVFXR.js.map +1 -0
- package/dist/{chunk-QVZBKGOE.cjs → chunk-EKSPLMYP.cjs} +32 -2
- package/dist/chunk-EKSPLMYP.cjs.map +1 -0
- package/dist/{dist-JVIEAZJ6.js → dist-CI72CYZJ.js} +10 -10
- package/dist/{dist-JVIEAZJ6.js.map → dist-CI72CYZJ.js.map} +1 -1
- package/dist/{dist-JQCAD3AD.cjs → dist-IKJJ2AX4.cjs} +10 -10
- package/dist/{dist-JQCAD3AD.cjs.map → dist-IKJJ2AX4.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{magic-string.es-NBXOXRCK.cjs → magic-string.es-VZN2EYER.cjs} +3 -3
- package/dist/{magic-string.es-NBXOXRCK.cjs.map → magic-string.es-VZN2EYER.cjs.map} +1 -1
- package/dist/{magic-string.es-6JSI7KY4.js → magic-string.es-WQRLTQPQ.js} +3 -3
- package/dist/{magic-string.es-6JSI7KY4.js.map → magic-string.es-WQRLTQPQ.js.map} +1 -1
- package/dist/scorers/code/index.cjs +2 -2
- package/dist/scorers/code/index.js +1 -1
- package/dist/scorers/llm/context-precision/index.d.ts +18 -0
- package/dist/scorers/llm/context-precision/index.d.ts.map +1 -0
- package/dist/scorers/llm/context-precision/prompts.d.ts +19 -0
- package/dist/scorers/llm/context-precision/prompts.d.ts.map +1 -0
- package/dist/scorers/llm/context-relevance/index.d.ts +27 -0
- package/dist/scorers/llm/context-relevance/index.d.ts.map +1 -0
- package/dist/scorers/llm/context-relevance/prompts.d.ts +20 -0
- package/dist/scorers/llm/context-relevance/prompts.d.ts.map +1 -0
- package/dist/scorers/llm/index.cjs +1163 -25
- package/dist/scorers/llm/index.cjs.map +1 -1
- package/dist/scorers/llm/index.d.ts +4 -0
- package/dist/scorers/llm/index.d.ts.map +1 -1
- package/dist/scorers/llm/index.js +1137 -3
- package/dist/scorers/llm/index.js.map +1 -1
- package/dist/scorers/llm/noise-sensitivity/index.d.ts +36 -0
- package/dist/scorers/llm/noise-sensitivity/index.d.ts.map +1 -0
- package/dist/scorers/llm/noise-sensitivity/prompts.d.ts +21 -0
- package/dist/scorers/llm/noise-sensitivity/prompts.d.ts.map +1 -0
- package/dist/scorers/llm/prompt-alignment/index.d.ts +38 -0
- package/dist/scorers/llm/prompt-alignment/index.d.ts.map +1 -0
- package/dist/scorers/llm/prompt-alignment/prompts.d.ts +44 -0
- package/dist/scorers/llm/prompt-alignment/prompts.d.ts.map +1 -0
- package/dist/scorers/llm/tool-call-accuracy/index.d.ts +2 -4
- package/dist/scorers/llm/tool-call-accuracy/index.d.ts.map +1 -1
- package/dist/scorers/utils.d.ts +2 -0
- package/dist/scorers/utils.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/chunk-5CVZXIFW.js.map +0 -1
- package/dist/chunk-QVZBKGOE.cjs.map +0 -1
|
@@ -5,6 +5,35 @@ var roundToTwoDecimals = (num) => {
|
|
|
5
5
|
var getUserMessageFromRunInput = (input) => {
|
|
6
6
|
return input?.inputMessages.find(({ role }) => role === "user")?.content;
|
|
7
7
|
};
|
|
8
|
+
var getSystemMessagesFromRunInput = (input) => {
|
|
9
|
+
const systemMessages = [];
|
|
10
|
+
if (input?.systemMessages) {
|
|
11
|
+
systemMessages.push(
|
|
12
|
+
...input.systemMessages.map((msg) => {
|
|
13
|
+
if (typeof msg.content === "string") {
|
|
14
|
+
return msg.content;
|
|
15
|
+
} else if (Array.isArray(msg.content)) {
|
|
16
|
+
return msg.content.filter((part) => part.type === "text").map((part) => part.text || "").join(" ");
|
|
17
|
+
}
|
|
18
|
+
return "";
|
|
19
|
+
}).filter((content) => content)
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
if (input?.taggedSystemMessages) {
|
|
23
|
+
Object.values(input.taggedSystemMessages).forEach((messages) => {
|
|
24
|
+
messages.forEach((msg) => {
|
|
25
|
+
if (typeof msg.content === "string") {
|
|
26
|
+
systemMessages.push(msg.content);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return systemMessages;
|
|
32
|
+
};
|
|
33
|
+
var getCombinedSystemPrompt = (input) => {
|
|
34
|
+
const systemMessages = getSystemMessagesFromRunInput(input);
|
|
35
|
+
return systemMessages.join("\n\n");
|
|
36
|
+
};
|
|
8
37
|
var getAssistantMessageFromRunOutput = (output) => {
|
|
9
38
|
return output?.find(({ role }) => role === "assistant")?.content;
|
|
10
39
|
};
|
|
@@ -31,6 +60,6 @@ function extractToolCalls(output) {
|
|
|
31
60
|
return { tools: toolCalls, toolCallInfos };
|
|
32
61
|
}
|
|
33
62
|
|
|
34
|
-
export { extractToolCalls, getAssistantMessageFromRunOutput, getUserMessageFromRunInput, roundToTwoDecimals };
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
36
|
-
//# sourceMappingURL=chunk-
|
|
63
|
+
export { extractToolCalls, getAssistantMessageFromRunOutput, getCombinedSystemPrompt, getUserMessageFromRunInput, roundToTwoDecimals };
|
|
64
|
+
//# sourceMappingURL=chunk-4LRZVFXR.js.map
|
|
65
|
+
//# sourceMappingURL=chunk-4LRZVFXR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/scorers/utils.ts"],"names":[],"mappings":";AAIO,IAAM,kBAAA,GAAqB,CAAC,GAAA,KAAgB;AACjD,EAAA,OAAO,KAAK,KAAA,CAAA,CAAO,GAAA,GAAM,MAAA,CAAO,OAAA,IAAW,GAAG,CAAA,GAAI,GAAA;AACpD;AA4BO,IAAM,0BAAA,GAA6B,CAAC,KAAA,KAAmC;AAC5E,EAAA,OAAO,KAAA,EAAO,cAAc,IAAA,CAAK,CAAC,EAAE,IAAA,EAAK,KAAM,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context';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent, ScoringInput } from '@mastra/core/scores';\nimport type { ToolInvocation, UIMessage } from 'ai';\n\nexport const roundToTwoDecimals = (num: number) => {\n return Math.round((num + Number.EPSILON) * 100) / 100;\n};\n\nexport function isCloserTo(value: number, target1: number, target2: number): boolean {\n return Math.abs(value - target1) < Math.abs(value - target2);\n}\n\nexport type TestCase = {\n input: string;\n output: string;\n expectedResult: {\n score: number;\n reason?: string;\n };\n};\n\nexport type TestCaseWithContext = TestCase & {\n context: string[];\n};\n\nexport const createTestRun = (input: string, output: string, context?: string[]): ScoringInput => {\n return {\n input: [{ role: 'user', content: input }],\n output: { role: 'assistant', text: output },\n additionalContext: { context },\n runtimeContext: {},\n };\n};\n\nexport const getUserMessageFromRunInput = (input?: ScorerRunInputForAgent) => {\n return input?.inputMessages.find(({ role }) => role === 'user')?.content;\n};\n\nexport const getSystemMessagesFromRunInput = (input?: ScorerRunInputForAgent): string[] => {\n const systemMessages: string[] = [];\n\n // Add standard system messages\n if (input?.systemMessages) {\n systemMessages.push(\n ...input.systemMessages\n .map(msg => {\n // Handle different content types - extract text if it's an array of parts\n if (typeof msg.content === 'string') {\n return msg.content;\n } else if (Array.isArray(msg.content)) {\n // Extract text from parts array\n return msg.content\n .filter(part => part.type === 'text')\n .map(part => part.text || '')\n .join(' ');\n }\n return '';\n })\n .filter(content => content),\n );\n }\n\n // Add tagged system messages (these are specialized system prompts)\n if (input?.taggedSystemMessages) {\n Object.values(input.taggedSystemMessages).forEach(messages => {\n messages.forEach(msg => {\n if (typeof msg.content === 'string') {\n systemMessages.push(msg.content);\n }\n });\n });\n }\n\n return systemMessages;\n};\n\nexport const getCombinedSystemPrompt = (input?: ScorerRunInputForAgent): string => {\n const systemMessages = getSystemMessagesFromRunInput(input);\n return systemMessages.join('\\n\\n');\n};\n\nexport const getAssistantMessageFromRunOutput = (output?: ScorerRunOutputForAgent) => {\n return output?.find(({ role }) => role === 'assistant')?.content;\n};\n\nexport const createToolInvocation = ({\n toolCallId,\n toolName,\n args,\n result,\n state = 'result',\n}: {\n toolCallId: string;\n toolName: string;\n args: Record<string, any>;\n result: Record<string, any>;\n state?: ToolInvocation['state'];\n}): { toolCallId: string; toolName: string; args: Record<string, any>; result: Record<string, any>; state: string } => {\n return {\n toolCallId,\n toolName,\n args,\n result,\n state,\n };\n};\n\nexport const createUIMessage = ({\n content,\n role,\n id = 'test-message',\n toolInvocations = [],\n}: {\n id: string;\n role: 'user' | 'assistant' | 'system';\n content: string;\n toolInvocations?: Array<{\n toolCallId: string;\n toolName: string;\n args: Record<string, any>;\n result: Record<string, any>;\n state: any;\n }>;\n}): UIMessage => {\n return {\n id,\n role,\n content,\n parts: [{ type: 'text', text: content }],\n toolInvocations,\n };\n};\n\nexport const createAgentTestRun = ({\n inputMessages = [],\n output,\n rememberedMessages = [],\n systemMessages = [],\n taggedSystemMessages = {},\n runtimeContext = new RuntimeContext(),\n runId = crypto.randomUUID(),\n}: {\n inputMessages?: ScorerRunInputForAgent['inputMessages'];\n output: ScorerRunOutputForAgent;\n rememberedMessages?: ScorerRunInputForAgent['rememberedMessages'];\n systemMessages?: ScorerRunInputForAgent['systemMessages'];\n taggedSystemMessages?: ScorerRunInputForAgent['taggedSystemMessages'];\n runtimeContext?: RuntimeContext;\n runId?: string;\n}): {\n input: ScorerRunInputForAgent;\n output: ScorerRunOutputForAgent;\n runtimeContext: RuntimeContext;\n runId: string;\n} => {\n return {\n input: {\n inputMessages,\n rememberedMessages,\n systemMessages,\n taggedSystemMessages,\n },\n output,\n runtimeContext,\n runId,\n };\n};\n\nexport type ToolCallInfo = {\n toolName: string;\n toolCallId: string;\n messageIndex: number;\n invocationIndex: number;\n};\n\nexport function extractToolCalls(output: ScorerRunOutputForAgent): { tools: string[]; toolCallInfos: ToolCallInfo[] } {\n const toolCalls: string[] = [];\n const toolCallInfos: ToolCallInfo[] = [];\n\n for (let messageIndex = 0; messageIndex < output.length; messageIndex++) {\n const message = output[messageIndex];\n if (message?.toolInvocations) {\n for (let invocationIndex = 0; invocationIndex < message.toolInvocations.length; invocationIndex++) {\n const invocation = message.toolInvocations[invocationIndex];\n if (invocation && invocation.toolName && (invocation.state === 'result' || invocation.state === 'call')) {\n toolCalls.push(invocation.toolName);\n toolCallInfos.push({\n toolName: invocation.toolName,\n toolCallId: invocation.toolCallId || `${messageIndex}-${invocationIndex}`,\n messageIndex,\n invocationIndex,\n });\n }\n }\n }\n }\n\n return { tools: toolCalls, toolCallInfos };\n}\n\nexport const extractInputMessages = (runInput: ScorerRunInputForAgent | undefined): string[] => {\n return runInput?.inputMessages?.map(msg => msg.content) || [];\n};\n\nexport const extractAgentResponseMessages = (runOutput: ScorerRunOutputForAgent): string[] => {\n return runOutput.filter(msg => msg.role === 'assistant').map(msg => msg.content);\n};\n"]}
|
|
@@ -7,6 +7,35 @@ var roundToTwoDecimals = (num) => {
|
|
|
7
7
|
var getUserMessageFromRunInput = (input) => {
|
|
8
8
|
return input?.inputMessages.find(({ role }) => role === "user")?.content;
|
|
9
9
|
};
|
|
10
|
+
var getSystemMessagesFromRunInput = (input) => {
|
|
11
|
+
const systemMessages = [];
|
|
12
|
+
if (input?.systemMessages) {
|
|
13
|
+
systemMessages.push(
|
|
14
|
+
...input.systemMessages.map((msg) => {
|
|
15
|
+
if (typeof msg.content === "string") {
|
|
16
|
+
return msg.content;
|
|
17
|
+
} else if (Array.isArray(msg.content)) {
|
|
18
|
+
return msg.content.filter((part) => part.type === "text").map((part) => part.text || "").join(" ");
|
|
19
|
+
}
|
|
20
|
+
return "";
|
|
21
|
+
}).filter((content) => content)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (input?.taggedSystemMessages) {
|
|
25
|
+
Object.values(input.taggedSystemMessages).forEach((messages) => {
|
|
26
|
+
messages.forEach((msg) => {
|
|
27
|
+
if (typeof msg.content === "string") {
|
|
28
|
+
systemMessages.push(msg.content);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return systemMessages;
|
|
34
|
+
};
|
|
35
|
+
var getCombinedSystemPrompt = (input) => {
|
|
36
|
+
const systemMessages = getSystemMessagesFromRunInput(input);
|
|
37
|
+
return systemMessages.join("\n\n");
|
|
38
|
+
};
|
|
10
39
|
var getAssistantMessageFromRunOutput = (output) => {
|
|
11
40
|
return output?.find(({ role }) => role === "assistant")?.content;
|
|
12
41
|
};
|
|
@@ -35,7 +64,8 @@ function extractToolCalls(output) {
|
|
|
35
64
|
|
|
36
65
|
exports.extractToolCalls = extractToolCalls;
|
|
37
66
|
exports.getAssistantMessageFromRunOutput = getAssistantMessageFromRunOutput;
|
|
67
|
+
exports.getCombinedSystemPrompt = getCombinedSystemPrompt;
|
|
38
68
|
exports.getUserMessageFromRunInput = getUserMessageFromRunInput;
|
|
39
69
|
exports.roundToTwoDecimals = roundToTwoDecimals;
|
|
40
|
-
//# sourceMappingURL=chunk-
|
|
41
|
-
//# sourceMappingURL=chunk-
|
|
70
|
+
//# sourceMappingURL=chunk-EKSPLMYP.cjs.map
|
|
71
|
+
//# sourceMappingURL=chunk-EKSPLMYP.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/scorers/utils.ts"],"names":[],"mappings":";;;AAIO,IAAM,kBAAA,GAAqB,CAAC,GAAA,KAAgB;AACjD,EAAA,OAAO,KAAK,KAAA,CAAA,CAAO,GAAA,GAAM,MAAA,CAAO,OAAA,IAAW,GAAG,CAAA,GAAI,GAAA;AACpD;AA4BO,IAAM,0BAAA,GAA6B,CAAC,KAAA,KAAmC;AAC5E,EAAA,OAAO,KAAA,EAAO,cAAc,IAAA,CAAK,CAAC,EAAE,IAAA,EAAK,KAAM,IAAA,KAAS,MAAM,CAAA,EAAG,OAAA;AACnE;AAEO,IAAM,6BAAA,GAAgC,CAAC,KAAA,KAA6C;AACzF,EAAA,MAAM,iBAA2B,EAAC;AAGlC,EAAA,IAAI,OAAO,cAAA,EAAgB;A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C,EAAE,MAAK,KAAM,IAAA,KAAS,WAAW,CAAA,EAAG,OAAA;AAC3D;AA4FO,SAAS,iBAAiB,MAAA,EAAqF;AACpH,EAAA,MAAM,YAAsB,EAAC;AAC7B,EAAA,MAAM,gBAAgC,EAAC;AAEvC,EAAA,KAAA,IAAS,YAAA,GAAe,CAAA,EAAG,YAAA,GAAe,MAAA,CAAO,QAAQ,YAAA,EAAA,EAAgB;AACvE,IAAA,MAAM,OAAA,GAAU,OAAO,YAAY,CAAA;AACnC,IAAA,IAAI,SAAS,eAAA,EAAiB;AAC5B,MAAA,KAAA,IAAS,kBAAkB,CAAA,EAAG,eAAA,GAAkB,OAAA,CAAQ,eAAA,CAAgB,QAAQ,eAAA,EAAA,EAAmB;AACjG,QAAA,MAAM,UAAA,GAAa,OAAA,CAAQ,eAAA,CAAgB,eAAe,CAAA;AAC1D,QAAA,IAAI,UAAA,IAAc,WAAW,QAAA,KAAa,UAAA,CAAW,UAAU,QAAA,IAAY,UAAA,CAAW,UAAU,MAAA,CAAA,EAAS;AACvG,UAAA,SAAA,CAAU,IAAA,CAAK,WAAW,QAAQ,CAAA;AAClC,UAAA,aAAA,CAAc,IAAA,CAAK;AAAA,YACjB,UAAU,UAAA,CAAW,QAAA;AAAA,YACrB,YAAY,UAAA,CAAW,UAAA,IAAc,CAAA,EAAG,YAAY,IAAI,eAAe,CAAA,CAAA;AAAA,YACvE,YAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,aAAA,EAAc;AAC3C","file":"chunk-EKSPLMYP.cjs","sourcesContent":["import { RuntimeContext } from '@mastra/core/runtime-context';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent, ScoringInput } from '@mastra/core/scores';\nimport type { ToolInvocation, UIMessage } from 'ai';\n\nexport const roundToTwoDecimals = (num: number) => {\n return Math.round((num + Number.EPSILON) * 100) / 100;\n};\n\nexport function isCloserTo(value: number, target1: number, target2: number): boolean {\n return Math.abs(value - target1) < Math.abs(value - target2);\n}\n\nexport type TestCase = {\n input: string;\n output: string;\n expectedResult: {\n score: number;\n reason?: string;\n };\n};\n\nexport type TestCaseWithContext = TestCase & {\n context: string[];\n};\n\nexport const createTestRun = (input: string, output: string, context?: string[]): ScoringInput => {\n return {\n input: [{ role: 'user', content: input }],\n output: { role: 'assistant', text: output },\n additionalContext: { context },\n runtimeContext: {},\n };\n};\n\nexport const getUserMessageFromRunInput = (input?: ScorerRunInputForAgent) => {\n return input?.inputMessages.find(({ role }) => role === 'user')?.content;\n};\n\nexport const getSystemMessagesFromRunInput = (input?: ScorerRunInputForAgent): string[] => {\n const systemMessages: string[] = [];\n\n // Add standard system messages\n if (input?.systemMessages) {\n systemMessages.push(\n ...input.systemMessages\n .map(msg => {\n // Handle different content types - extract text if it's an array of parts\n if (typeof msg.content === 'string') {\n return msg.content;\n } else if (Array.isArray(msg.content)) {\n // Extract text from parts array\n return msg.content\n .filter(part => part.type === 'text')\n .map(part => part.text || '')\n .join(' ');\n }\n return '';\n })\n .filter(content => content),\n );\n }\n\n // Add tagged system messages (these are specialized system prompts)\n if (input?.taggedSystemMessages) {\n Object.values(input.taggedSystemMessages).forEach(messages => {\n messages.forEach(msg => {\n if (typeof msg.content === 'string') {\n systemMessages.push(msg.content);\n }\n });\n });\n }\n\n return systemMessages;\n};\n\nexport const getCombinedSystemPrompt = (input?: ScorerRunInputForAgent): string => {\n const systemMessages = getSystemMessagesFromRunInput(input);\n return systemMessages.join('\\n\\n');\n};\n\nexport const getAssistantMessageFromRunOutput = (output?: ScorerRunOutputForAgent) => {\n return output?.find(({ role }) => role === 'assistant')?.content;\n};\n\nexport const createToolInvocation = ({\n toolCallId,\n toolName,\n args,\n result,\n state = 'result',\n}: {\n toolCallId: string;\n toolName: string;\n args: Record<string, any>;\n result: Record<string, any>;\n state?: ToolInvocation['state'];\n}): { toolCallId: string; toolName: string; args: Record<string, any>; result: Record<string, any>; state: string } => {\n return {\n toolCallId,\n toolName,\n args,\n result,\n state,\n };\n};\n\nexport const createUIMessage = ({\n content,\n role,\n id = 'test-message',\n toolInvocations = [],\n}: {\n id: string;\n role: 'user' | 'assistant' | 'system';\n content: string;\n toolInvocations?: Array<{\n toolCallId: string;\n toolName: string;\n args: Record<string, any>;\n result: Record<string, any>;\n state: any;\n }>;\n}): UIMessage => {\n return {\n id,\n role,\n content,\n parts: [{ type: 'text', text: content }],\n toolInvocations,\n };\n};\n\nexport const createAgentTestRun = ({\n inputMessages = [],\n output,\n rememberedMessages = [],\n systemMessages = [],\n taggedSystemMessages = {},\n runtimeContext = new RuntimeContext(),\n runId = crypto.randomUUID(),\n}: {\n inputMessages?: ScorerRunInputForAgent['inputMessages'];\n output: ScorerRunOutputForAgent;\n rememberedMessages?: ScorerRunInputForAgent['rememberedMessages'];\n systemMessages?: ScorerRunInputForAgent['systemMessages'];\n taggedSystemMessages?: ScorerRunInputForAgent['taggedSystemMessages'];\n runtimeContext?: RuntimeContext;\n runId?: string;\n}): {\n input: ScorerRunInputForAgent;\n output: ScorerRunOutputForAgent;\n runtimeContext: RuntimeContext;\n runId: string;\n} => {\n return {\n input: {\n inputMessages,\n rememberedMessages,\n systemMessages,\n taggedSystemMessages,\n },\n output,\n runtimeContext,\n runId,\n };\n};\n\nexport type ToolCallInfo = {\n toolName: string;\n toolCallId: string;\n messageIndex: number;\n invocationIndex: number;\n};\n\nexport function extractToolCalls(output: ScorerRunOutputForAgent): { tools: string[]; toolCallInfos: ToolCallInfo[] } {\n const toolCalls: string[] = [];\n const toolCallInfos: ToolCallInfo[] = [];\n\n for (let messageIndex = 0; messageIndex < output.length; messageIndex++) {\n const message = output[messageIndex];\n if (message?.toolInvocations) {\n for (let invocationIndex = 0; invocationIndex < message.toolInvocations.length; invocationIndex++) {\n const invocation = message.toolInvocations[invocationIndex];\n if (invocation && invocation.toolName && (invocation.state === 'result' || invocation.state === 'call')) {\n toolCalls.push(invocation.toolName);\n toolCallInfos.push({\n toolName: invocation.toolName,\n toolCallId: invocation.toolCallId || `${messageIndex}-${invocationIndex}`,\n messageIndex,\n invocationIndex,\n });\n }\n }\n }\n }\n\n return { tools: toolCalls, toolCallInfos };\n}\n\nexport const extractInputMessages = (runInput: ScorerRunInputForAgent | undefined): string[] => {\n return runInput?.inputMessages?.map(msg => msg.content) || [];\n};\n\nexport const extractAgentResponseMessages = (runOutput: ScorerRunOutputForAgent): string[] => {\n return runOutput.filter(msg => msg.role === 'assistant').map(msg => msg.content);\n};\n"]}
|
|
@@ -11986,7 +11986,7 @@ function createTestHook(name, handler) {
|
|
|
11986
11986
|
};
|
|
11987
11987
|
}
|
|
11988
11988
|
|
|
11989
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.
|
|
11989
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.11_@vitest+ui@3.2.3_jiti@2.4.2_jsdom_70e728ef477f1e37b982af437efd45b2/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js
|
|
11990
11990
|
var NAME_WORKER_STATE = "__vitest_worker__";
|
|
11991
11991
|
function getWorkerState() {
|
|
11992
11992
|
const workerState = globalThis[NAME_WORKER_STATE];
|
|
@@ -12034,7 +12034,7 @@ async function waitForImportsToResolve() {
|
|
|
12034
12034
|
await waitForImportsToResolve();
|
|
12035
12035
|
}
|
|
12036
12036
|
|
|
12037
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.
|
|
12037
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.11_@vitest+ui@3.2.3_jiti@2.4.2_jsdom_70e728ef477f1e37b982af437efd45b2/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
|
|
12038
12038
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
12039
12039
|
function getDefaultExportFromCjs3(x) {
|
|
12040
12040
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -12887,7 +12887,7 @@ function offsetToLineNumber(source, offset) {
|
|
|
12887
12887
|
return line + 1;
|
|
12888
12888
|
}
|
|
12889
12889
|
async function saveInlineSnapshots(environment, snapshots) {
|
|
12890
|
-
const MagicString = (await import('./magic-string.es-
|
|
12890
|
+
const MagicString = (await import('./magic-string.es-WQRLTQPQ.js')).default;
|
|
12891
12891
|
const files = new Set(snapshots.map((i) => i.file));
|
|
12892
12892
|
await Promise.all(Array.from(files).map(async (file) => {
|
|
12893
12893
|
const snaps = snapshots.filter((i) => i.file === file);
|
|
@@ -13664,7 +13664,7 @@ var SnapshotClient = class {
|
|
|
13664
13664
|
}
|
|
13665
13665
|
};
|
|
13666
13666
|
|
|
13667
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.
|
|
13667
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.11_@vitest+ui@3.2.3_jiti@2.4.2_jsdom_70e728ef477f1e37b982af437efd45b2/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js
|
|
13668
13668
|
var RealDate = Date;
|
|
13669
13669
|
var now2 = null;
|
|
13670
13670
|
var MockDate = class _MockDate extends RealDate {
|
|
@@ -13712,7 +13712,7 @@ function resetDate() {
|
|
|
13712
13712
|
globalThis.Date = RealDate;
|
|
13713
13713
|
}
|
|
13714
13714
|
|
|
13715
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.
|
|
13715
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.11_@vitest+ui@3.2.3_jiti@2.4.2_jsdom_70e728ef477f1e37b982af437efd45b2/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
|
|
13716
13716
|
var unsupported = [
|
|
13717
13717
|
"matchSnapshot",
|
|
13718
13718
|
"toMatchSnapshot",
|
|
@@ -16398,7 +16398,7 @@ function getImporter(name) {
|
|
|
16398
16398
|
return stack?.file || "";
|
|
16399
16399
|
}
|
|
16400
16400
|
|
|
16401
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.
|
|
16401
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.11_@vitest+ui@3.2.3_jiti@2.4.2_jsdom_70e728ef477f1e37b982af437efd45b2/node_modules/vitest/dist/chunks/benchmark.CYdenmiT.js
|
|
16402
16402
|
var benchFns = /* @__PURE__ */ new WeakMap();
|
|
16403
16403
|
var benchOptsMap = /* @__PURE__ */ new WeakMap();
|
|
16404
16404
|
var bench = createBenchmark(function(name, fn2 = noop, options = {}) {
|
|
@@ -16424,12 +16424,12 @@ function formatName2(name) {
|
|
|
16424
16424
|
return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
|
|
16425
16425
|
}
|
|
16426
16426
|
|
|
16427
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.
|
|
16427
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.11_@vitest+ui@3.2.3_jiti@2.4.2_jsdom_70e728ef477f1e37b982af437efd45b2/node_modules/vitest/dist/chunks/index.CdQS2e2Q.js
|
|
16428
16428
|
__toESM(require_dist(), 1);
|
|
16429
16429
|
var assertType = function assertType2() {
|
|
16430
16430
|
};
|
|
16431
16431
|
|
|
16432
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.
|
|
16432
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.11_@vitest+ui@3.2.3_jiti@2.4.2_jsdom_70e728ef477f1e37b982af437efd45b2/node_modules/vitest/dist/index.js
|
|
16433
16433
|
var import_expect_type2 = __toESM(require_dist(), 1);
|
|
16434
16434
|
var export_expectTypeOf = import_expect_type2.expectTypeOf;
|
|
16435
16435
|
/*! Bundled license information:
|
|
@@ -16725,5 +16725,5 @@ chai/chai.js:
|
|
|
16725
16725
|
*/
|
|
16726
16726
|
|
|
16727
16727
|
export { afterAll, afterEach, assert2 as assert, assertType, beforeAll, beforeEach, bench, chai_exports as chai, createExpect, describe, globalExpect as expect, export_expectTypeOf as expectTypeOf, inject, it, onTestFailed, onTestFinished, should, suite, test3 as test, vi, vitest };
|
|
16728
|
-
//# sourceMappingURL=dist-
|
|
16729
|
-
//# sourceMappingURL=dist-
|
|
16728
|
+
//# sourceMappingURL=dist-CI72CYZJ.js.map
|
|
16729
|
+
//# sourceMappingURL=dist-CI72CYZJ.js.map
|