UNPKG

@mastra/core

Version:
38 lines (37 loc) 1.31 kB
// src/evals/collect-tool-mocks.ts function isSubAgentDelegation(toolName) { return toolName.startsWith("agent-"); } function extractToolName(label) { const match = label.match(/^(?:mcp_)?tool:\s*'(.*?)'/); return match?.[1] ?? label; } function collectToolMocks(steps) { return collectToolMocksInto(steps, []); } function collectToolMocksInto(steps, acc) { if (!steps) return acc; for (const step of steps) { const isToolCall = step.stepType === "tool_call" || step.stepType === "mcp_tool_call"; if (isToolCall && step.name) { const toolName = extractToolName(step.name); const toolArgs = "toolArgs" in step ? step.toolArgs : void 0; const toolResult = "toolResult" in step ? step.toolResult : void 0; acc.push({ toolName, args: toolArgs ?? {}, output: toolResult, // Sub-agent delegation args are LLM-authored + runtime-injected; default // to ignore-args matching so the saved mock matches on replay. ...isSubAgentDelegation(toolName) ? { matchArgs: "ignore" } : {} }); } if (!isToolCall && step.children?.length) { collectToolMocksInto(step.children, acc); } } return acc; } export { collectToolMocks }; //# sourceMappingURL=chunk-T24H2ARG.js.map //# sourceMappingURL=chunk-T24H2ARG.js.map