@mastra/core 1.0.0-beta.16 → 1.0.0-beta.18
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/CHANGELOG.md +23 -0
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-UT6MASE5.cjs → chunk-2OOMJRXZ.cjs} +3 -3
- package/dist/{chunk-UT6MASE5.cjs.map → chunk-2OOMJRXZ.cjs.map} +1 -1
- package/dist/{chunk-F7PAZAGE.js → chunk-2XX35XRX.js} +8 -9
- package/dist/chunk-2XX35XRX.js.map +1 -0
- package/dist/{chunk-QD776HMB.js → chunk-5YYAQUEF.js} +3 -3
- package/dist/{chunk-QD776HMB.js.map → chunk-5YYAQUEF.js.map} +1 -1
- package/dist/{chunk-UTMBASR5.js → chunk-6R4744NH.js} +4 -4
- package/dist/{chunk-UTMBASR5.js.map → chunk-6R4744NH.js.map} +1 -1
- package/dist/{chunk-CSCTVLD5.js → chunk-6RFJWX4V.js} +3 -3
- package/dist/{chunk-CSCTVLD5.js.map → chunk-6RFJWX4V.js.map} +1 -1
- package/dist/{chunk-KKYAYRIO.js → chunk-ABMWK6JU.js} +4 -4
- package/dist/{chunk-KKYAYRIO.js.map → chunk-ABMWK6JU.js.map} +1 -1
- package/dist/{chunk-37YWZMBX.js → chunk-AIJLACR2.js} +9 -5
- package/dist/chunk-AIJLACR2.js.map +1 -0
- package/dist/{chunk-WDXYPI3P.js → chunk-AR5CF3IN.js} +3 -3
- package/dist/{chunk-WDXYPI3P.js.map → chunk-AR5CF3IN.js.map} +1 -1
- package/dist/{chunk-4UH5LAF5.cjs → chunk-BWZ6UOBF.cjs} +15 -15
- package/dist/{chunk-4UH5LAF5.cjs.map → chunk-BWZ6UOBF.cjs.map} +1 -1
- package/dist/{chunk-DT5RMENY.js → chunk-CHVWQDMP.js} +39 -5
- package/dist/chunk-CHVWQDMP.js.map +1 -0
- package/dist/{chunk-OXV6QFSV.cjs → chunk-G6YCU7HJ.cjs} +8 -8
- package/dist/{chunk-OXV6QFSV.cjs.map → chunk-G6YCU7HJ.cjs.map} +1 -1
- package/dist/{chunk-5DL6Y7PJ.cjs → chunk-GFALVOBW.cjs} +35 -36
- package/dist/chunk-GFALVOBW.cjs.map +1 -0
- package/dist/{chunk-NNFF3URD.js → chunk-IHPCE24V.js} +8 -8
- package/dist/{chunk-NNFF3URD.js.map → chunk-IHPCE24V.js.map} +1 -1
- package/dist/{chunk-33VDGXRH.cjs → chunk-IY5QWADY.cjs} +16 -16
- package/dist/{chunk-33VDGXRH.cjs.map → chunk-IY5QWADY.cjs.map} +1 -1
- package/dist/{chunk-FB5QMTJJ.js → chunk-JBEKXEX6.js} +4 -4
- package/dist/{chunk-FB5QMTJJ.js.map → chunk-JBEKXEX6.js.map} +1 -1
- package/dist/{chunk-4KVIXN7K.cjs → chunk-NGRUGDFP.cjs} +14 -14
- package/dist/{chunk-4KVIXN7K.cjs.map → chunk-NGRUGDFP.cjs.map} +1 -1
- package/dist/{chunk-6YUHA5UH.cjs → chunk-O4YSWWLB.cjs} +5 -5
- package/dist/{chunk-6YUHA5UH.cjs.map → chunk-O4YSWWLB.cjs.map} +1 -1
- package/dist/{chunk-A6JNGJIU.cjs → chunk-P3XQ3TNY.cjs} +30 -30
- package/dist/{chunk-A6JNGJIU.cjs.map → chunk-P3XQ3TNY.cjs.map} +1 -1
- package/dist/{chunk-4N6WB4EZ.js → chunk-POSO2X6D.js} +6 -6
- package/dist/{chunk-4N6WB4EZ.js.map → chunk-POSO2X6D.js.map} +1 -1
- package/dist/{chunk-GNUITL2N.js → chunk-RC7RN5MY.js} +3 -3
- package/dist/{chunk-GNUITL2N.js.map → chunk-RC7RN5MY.js.map} +1 -1
- package/dist/{chunk-AQ22JIR7.cjs → chunk-SDR22R4D.cjs} +16 -16
- package/dist/{chunk-AQ22JIR7.cjs.map → chunk-SDR22R4D.cjs.map} +1 -1
- package/dist/{chunk-7KL2YFFK.cjs → chunk-SGRMJZMJ.cjs} +15 -15
- package/dist/{chunk-7KL2YFFK.cjs.map → chunk-SGRMJZMJ.cjs.map} +1 -1
- package/dist/{chunk-K4XAKG7L.js → chunk-TI6D7CAN.js} +4 -4
- package/dist/{chunk-K4XAKG7L.js.map → chunk-TI6D7CAN.js.map} +1 -1
- package/dist/{chunk-H2NHG7QL.cjs → chunk-VW7YQWDW.cjs} +9 -5
- package/dist/chunk-VW7YQWDW.cjs.map +1 -0
- package/dist/{chunk-NCAMNQC3.cjs → chunk-XIYLL4DN.cjs} +40 -6
- package/dist/chunk-XIYLL4DN.cjs.map +1 -0
- package/dist/{chunk-NK4UN2LF.cjs → chunk-XR7RX2PS.cjs} +5 -5
- package/dist/{chunk-NK4UN2LF.cjs.map → chunk-XR7RX2PS.cjs.map} +1 -1
- package/dist/{chunk-J4SXS7KN.js → chunk-Y52PV3W4.js} +4 -4
- package/dist/{chunk-J4SXS7KN.js.map → chunk-Y52PV3W4.js.map} +1 -1
- package/dist/{chunk-3ZRMVPQA.cjs → chunk-ZSQ7L6AW.cjs} +7 -7
- package/dist/{chunk-3ZRMVPQA.cjs.map → chunk-ZSQ7L6AW.cjs.map} +1 -1
- package/dist/evals/index.cjs +19 -19
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +11 -11
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/provider-types.generated.d.ts +14 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +11 -11
- package/dist/memory/index.js +1 -1
- package/dist/netlify-CUYK2MZ2.cjs +12 -0
- package/dist/{netlify-5Y33S7WL.cjs.map → netlify-CUYK2MZ2.cjs.map} +1 -1
- package/dist/netlify-J4QPOROO.js +3 -0
- package/dist/{netlify-3MHHJG2E.js.map → netlify-J4QPOROO.js.map} +1 -1
- package/dist/processors/index.cjs +37 -37
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-IGILEKIM.js +3 -0
- package/dist/{provider-registry-LXSWMVEC.js.map → provider-registry-IGILEKIM.js.map} +1 -1
- package/dist/provider-registry-XNQEGR56.cjs +40 -0
- package/dist/{provider-registry-YJ2P5YY5.cjs.map → provider-registry-XNQEGR56.cjs.map} +1 -1
- package/dist/provider-registry.json +36 -2
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/constants.cjs +14 -14
- package/dist/storage/constants.js +1 -1
- package/dist/storage/index.cjs +92 -92
- package/dist/storage/index.js +2 -2
- package/dist/stream/index.cjs +9 -9
- package/dist/stream/index.js +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/utils/zod-utils.d.ts +7 -1
- package/dist/utils/zod-utils.d.ts.map +1 -1
- package/dist/utils.cjs +27 -27
- package/dist/utils.js +2 -2
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +23 -23
- package/dist/workflows/index.js +1 -1
- package/package.json +5 -5
- package/src/llm/model/provider-types.generated.d.ts +14 -1
- package/dist/chunk-37YWZMBX.js.map +0 -1
- package/dist/chunk-5DL6Y7PJ.cjs.map +0 -1
- package/dist/chunk-DT5RMENY.js.map +0 -1
- package/dist/chunk-F7PAZAGE.js.map +0 -1
- package/dist/chunk-H2NHG7QL.cjs.map +0 -1
- package/dist/chunk-NCAMNQC3.cjs.map +0 -1
- package/dist/netlify-3MHHJG2E.js +0 -3
- package/dist/netlify-5Y33S7WL.cjs +0 -12
- package/dist/provider-registry-LXSWMVEC.js +0 -3
- package/dist/provider-registry-YJ2P5YY5.cjs +0 -40
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVW7YQWDW_cjs = require('./chunk-VW7YQWDW.cjs');
|
|
4
4
|
var chunkUVHSM2GU_cjs = require('./chunk-UVHSM2GU.cjs');
|
|
5
5
|
|
|
6
6
|
// src/tools/validation.ts
|
|
@@ -38,10 +38,10 @@ function normalizeNullishInput(schema, input) {
|
|
|
38
38
|
if (input !== void 0 && input !== null) {
|
|
39
39
|
return input;
|
|
40
40
|
}
|
|
41
|
-
if (
|
|
41
|
+
if (chunkVW7YQWDW_cjs.isZodArray(schema)) {
|
|
42
42
|
return [];
|
|
43
43
|
}
|
|
44
|
-
if (
|
|
44
|
+
if (chunkVW7YQWDW_cjs.isZodObject(schema)) {
|
|
45
45
|
return {};
|
|
46
46
|
}
|
|
47
47
|
return input;
|
|
@@ -272,5 +272,5 @@ exports.isVercelTool = isVercelTool;
|
|
|
272
272
|
exports.validateToolInput = validateToolInput;
|
|
273
273
|
exports.validateToolOutput = validateToolOutput;
|
|
274
274
|
exports.validateToolSuspendData = validateToolSuspendData;
|
|
275
|
-
//# sourceMappingURL=chunk-
|
|
276
|
-
//# sourceMappingURL=chunk-
|
|
275
|
+
//# sourceMappingURL=chunk-O4YSWWLB.cjs.map
|
|
276
|
+
//# sourceMappingURL=chunk-O4YSWWLB.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tools/validation.ts","../src/tools/tool.ts","../src/tools/toolchecks.ts"],"names":["isZodArray","isZodObject","RequestContext","resumeData"],"mappings":";;;;;;AAgBA,SAAS,kBAAA,CAAmB,IAAA,EAAe,SAAA,GAAoB,GAAA,EAAa;AAC1E,EAAA,IAAI;AACF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AAa,IAAA,IAAQ,OAAO,IAAA,CAAK,OAAA,KAAY,cAAc,aAAA,IAAiB,IAAA,CAAA,CAAA;AAE1G","file":"chunk-6YUHA5UH.cjs","sourcesContent":["import type { z } from 'zod';\nimport type { ZodLikeSchema } from '../types/zod-compat';\nimport { isZodArray, isZodObject } from '../utils/zod-utils';\n\nexport interface ValidationError<T = any> {\n error: true;\n message: string;\n validationErrors: z.ZodFormattedError<T>;\n}\n\n/**\n * Safely truncates data for error messages to avoid exposing sensitive information.\n * @param data The data to truncate\n * @param maxLength Maximum length of the truncated string (default: 200)\n * @returns Truncated string representation\n */\nfunction truncateForLogging(data: unknown, maxLength: number = 200): string {\n try {\n const stringified = JSON.stringify(data, null, 2);\n if (stringified.length <= maxLength) {\n return stringified;\n }\n return stringified.slice(0, maxLength) + '... (truncated)';\n } catch {\n return '[Unable to serialize data]';\n }\n}\n\n/**\n * Validates raw suspend data against a Zod schema.\n *\n * @param schema The Zod schema to validate against\n * @param suspendData The raw suspend data to validate\n * @param toolId Optional tool ID for better error messages\n * @returns The validated data or a validation error\n */\nexport function validateToolSuspendData<T = any>(\n schema: ZodLikeSchema | undefined,\n suspendData: unknown,\n toolId?: string,\n): { data: T | unknown; error?: ValidationError<T> } {\n // If no schema, return suspend data as-is\n if (!schema || !('safeParse' in schema)) {\n return { data: suspendData };\n }\n\n // Validate the input directly - no unwrapping needed in v1.0\n const validation = schema.safeParse(suspendData);\n\n if (validation.success) {\n return { data: validation.data };\n }\n\n // Validation failed, return error\n const errorMessages = validation.error.issues\n .map((e: z.ZodIssue) => `- ${e.path?.join('.') || 'root'}: ${e.message}`)\n .join('\\n');\n\n const error: ValidationError<T> = {\n error: true,\n message: `Tool suspension data validation failed${toolId ? ` for ${toolId}` : ''}. Please fix the following errors and try again:\\n${errorMessages}\\n\\nProvided arguments: ${truncateForLogging(suspendData)}`,\n validationErrors: validation.error.format() as z.ZodFormattedError<T>,\n };\n\n return { data: suspendData, error };\n}\n\n/**\n * Normalizes undefined/null input to an appropriate default value based on schema type.\n * This handles LLMs (Claude Sonnet 4.5, Gemini 2.4, etc.) that send undefined/null\n * instead of {} or [] when all parameters are optional.\n *\n * @param schema The Zod schema to check\n * @param input The input to normalize\n * @returns The normalized input (original value, {}, or [])\n */\nfunction normalizeNullishInput(schema: ZodLikeSchema, input: unknown): unknown {\n if (input !== undefined && input !== null) {\n return input;\n }\n\n // Check if schema is an array type (using typeName to avoid dual-package hazard)\n if (isZodArray(schema as z.ZodTypeAny)) {\n return [];\n }\n\n // Check if schema is an object type (using typeName to avoid dual-package hazard)\n if (isZodObject(schema as z.ZodTypeAny)) {\n return {};\n }\n\n // For other schema types, return the original input and let Zod validate\n return input;\n}\n\n/**\n * Validates raw input data against a Zod schema.\n *\n * @param schema The Zod schema to validate against\n * @param input The raw input data to validate\n * @param toolId Optional tool ID for better error messages\n * @returns The validated data or a validation error\n */\nexport function validateToolInput<T = any>(\n schema: ZodLikeSchema | undefined,\n input: unknown,\n toolId?: string,\n): { data: T | unknown; error?: ValidationError<T> } {\n // If no schema, return input as-is\n if (!schema || !('safeParse' in schema)) {\n return { data: input };\n }\n\n // Normalize undefined/null input to appropriate default for the schema type\n // This handles LLMs that send undefined instead of {} or [] for optional parameters\n const normalizedInput = normalizeNullishInput(schema, input);\n\n // Validate the normalized input\n const validation = schema.safeParse(normalizedInput);\n\n if (validation.success) {\n return { data: validation.data };\n }\n\n // Validation failed, return error\n const errorMessages = validation.error.issues\n .map((e: z.ZodIssue) => `- ${e.path?.join('.') || 'root'}: ${e.message}`)\n .join('\\n');\n\n const error: ValidationError<T> = {\n error: true,\n message: `Tool input validation failed${toolId ? ` for ${toolId}` : ''}. Please fix the following errors and try again:\\n${errorMessages}\\n\\nProvided arguments: ${truncateForLogging(input)}`,\n validationErrors: validation.error.format() as z.ZodFormattedError<T>,\n };\n\n return { data: input, error };\n}\n\n/**\n * Validates tool output data against a Zod schema.\n *\n * @param schema The Zod schema to validate against\n * @param output The output data to validate\n * @param toolId Optional tool ID for better error messages\n * @returns The validated data or a validation error\n */\nexport function validateToolOutput<T = any>(\n schema: ZodLikeSchema | undefined,\n output: unknown,\n toolId?: string,\n suspendCalled?: boolean,\n): { data: T | unknown; error?: ValidationError<T> } {\n // If no schema, return output as-is\n if (!schema || !('safeParse' in schema) || suspendCalled) {\n return { data: output };\n }\n\n // Validate the output\n const validation = schema.safeParse(output);\n\n if (validation.success) {\n return { data: validation.data };\n }\n\n // Validation failed, return error\n const errorMessages = validation.error.issues\n .map((e: z.ZodIssue) => `- ${e.path?.join('.') || 'root'}: ${e.message}`)\n .join('\\n');\n\n const error: ValidationError<T> = {\n error: true,\n message: `Tool output validation failed${toolId ? ` for ${toolId}` : ''}. The tool returned invalid output:\\n${errorMessages}\\n\\nReturned output: ${truncateForLogging(output)}`,\n validationErrors: validation.error.format() as z.ZodFormattedError<T>,\n };\n\n return { data: output, error };\n}\n","import type { Mastra } from '../mastra';\nimport { RequestContext } from '../request-context';\nimport type { ZodLikeSchema, InferZodLikeSchema, InferZodLikeSchemaInput } from '../types/zod-compat';\nimport type { SuspendOptions } from '../workflows';\nimport type { ToolAction, ToolExecutionContext } from './types';\nimport { validateToolInput, validateToolOutput, validateToolSuspendData } from './validation';\n\n/**\n * A type-safe tool that agents and workflows can call to perform specific actions.\n *\n * @template TSchemaIn - Input schema type\n * @template TSchemaOut - Output schema type\n * @template TSuspendSchema - Suspend operation schema type\n * @template TResumeSchema - Resume operation schema type\n * @template TContext - Execution context type\n *\n * @example Basic tool with validation\n * ```typescript\n * const weatherTool = createTool({\n * id: 'get-weather',\n * description: 'Get weather for a location',\n * inputSchema: z.object({\n * location: z.string(),\n * units: z.enum(['celsius', 'fahrenheit']).optional()\n * }),\n * execute: async (inputData) => {\n * return await fetchWeather(inputData.location, inputData.units);\n * }\n * });\n * ```\n *\n * @example Tool requiring approval\n * ```typescript\n * const deleteFileTool = createTool({\n * id: 'delete-file',\n * description: 'Delete a file',\n * requireApproval: true,\n * inputSchema: z.object({ filepath: z.string() }),\n * execute: async (inputData) => {\n * await fs.unlink(inputData.filepath);\n * return { deleted: true };\n * }\n * });\n * ```\n *\n * @example Tool with Mastra integration\n * ```typescript\n * const saveTool = createTool({\n * id: 'save-data',\n * description: 'Save data to storage',\n * inputSchema: z.object({ key: z.string(), value: z.any() }),\n * execute: async (inputData, context) => {\n * const storage = context?.mastra?.getStorage();\n * await storage?.set(inputData.key, inputData.value);\n * return { saved: true };\n * }\n * });\n * ```\n */\nexport class Tool<\n TSchemaIn extends ZodLikeSchema | undefined = undefined,\n TSchemaOut extends ZodLikeSchema | undefined = undefined,\n TSuspendSchema extends ZodLikeSchema = any,\n TResumeSchema extends ZodLikeSchema = any,\n TContext extends ToolExecutionContext<TSuspendSchema, TResumeSchema> = ToolExecutionContext<\n TSuspendSchema,\n TResumeSchema\n >,\n TId extends string = string,\n> implements ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId>\n{\n /** Unique identifier for the tool */\n id: TId;\n\n /** Description of what the tool does */\n description: string;\n\n /** Schema for validating input parameters */\n inputSchema?: TSchemaIn;\n\n /** Schema for validating output structure */\n outputSchema?: TSchemaOut;\n\n /** Schema for suspend operation data */\n suspendSchema?: TSuspendSchema;\n\n /** Schema for resume operation data */\n resumeSchema?: TResumeSchema;\n\n /**\n * Tool execution function\n * @param inputData - The raw, validated input data\n * @param context - Optional execution context with metadata\n * @returns Promise resolving to tool output or a ValidationError if input validation fails\n */\n execute?: ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext>['execute'];\n\n /** Parent Mastra instance for accessing shared resources */\n mastra?: Mastra;\n\n /**\n * Whether the tool requires explicit user approval before execution\n * @example\n * ```typescript\n * // For destructive operations\n * requireApproval: true\n * ```\n */\n requireApproval?: boolean;\n\n /**\n * Provider-specific options passed to the model when this tool is used.\n * Keys are provider names (e.g., 'anthropic', 'openai'), values are provider-specific configs.\n * @example\n * ```typescript\n * providerOptions: {\n * anthropic: {\n * cacheControl: { type: 'ephemeral' }\n * }\n * }\n * ```\n */\n providerOptions?: Record<string, Record<string, unknown>>;\n\n /**\n * Creates a new Tool instance with input validation wrapper.\n *\n * @param opts - Tool configuration and execute function\n * @example\n * ```typescript\n * const tool = new Tool({\n * id: 'my-tool',\n * description: 'Does something useful',\n * inputSchema: z.object({ name: z.string() }),\n * execute: async (inputData) => ({ greeting: `Hello ${inputData.name}` })\n * });\n * ```\n */\n constructor(opts: ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId>) {\n this.id = opts.id;\n this.description = opts.description;\n this.inputSchema = opts.inputSchema;\n this.outputSchema = opts.outputSchema;\n this.suspendSchema = opts.suspendSchema;\n this.resumeSchema = opts.resumeSchema;\n this.mastra = opts.mastra;\n this.requireApproval = opts.requireApproval || false;\n this.providerOptions = opts.providerOptions;\n\n // Tools receive two parameters:\n // 1. input - The raw, validated input data\n // 2. context - Execution metadata (mastra, suspend, etc.)\n if (opts.execute) {\n const originalExecute = opts.execute;\n this.execute = async (inputData: unknown, context?: any) => {\n // Validate input if schema exists\n const { data, error } = validateToolInput(this.inputSchema, inputData, this.id);\n if (error) {\n return error as any;\n }\n\n let suspendData = null;\n\n const baseContext = context\n ? {\n ...context,\n ...(context.suspend\n ? {\n suspend: (args: any, suspendOptions?: SuspendOptions) => {\n suspendData = args;\n return context.suspend?.(args, suspendOptions);\n },\n }\n : {}),\n }\n : {};\n\n // Organize context based on execution source\n let organizedContext = baseContext;\n if (!context) {\n // No context provided - create a minimal context with requestContext\n organizedContext = {\n requestContext: new RequestContext(),\n mastra: undefined,\n };\n } else {\n // Check if this is agent execution (has toolCallId and messages)\n const isAgentExecution = baseContext.toolCallId && baseContext.messages;\n\n // Check if this is workflow execution (has workflow properties)\n // Agent execution takes precedence - don't treat as workflow if it's an agent call\n const isWorkflowExecution = !isAgentExecution && (baseContext.workflow || baseContext.workflowId);\n\n if (isAgentExecution && !baseContext.agent) {\n // Reorganize agent context - nest agent-specific properties under 'agent' key\n const { toolCallId, messages, suspend, resumeData, threadId, resourceId, writableStream, ...rest } =\n baseContext;\n organizedContext = {\n ...rest,\n agent: {\n toolCallId,\n messages,\n suspend,\n resumeData,\n threadId,\n resourceId,\n writableStream,\n },\n // Ensure requestContext is always present\n requestContext: rest.requestContext || new RequestContext(),\n };\n } else if (isWorkflowExecution && !baseContext.workflow) {\n // Reorganize workflow context - nest workflow-specific properties under 'workflow' key\n const { workflowId, runId, state, setState, suspend, resumeData, ...rest } = baseContext;\n organizedContext = {\n ...rest,\n workflow: {\n workflowId,\n runId,\n state,\n setState,\n suspend,\n resumeData,\n },\n // Ensure requestContext is always present\n requestContext: rest.requestContext || new RequestContext(),\n };\n } else {\n // Ensure requestContext is always present even for direct execution\n organizedContext = {\n ...baseContext,\n agent: baseContext.agent\n ? {\n ...baseContext.agent,\n suspend: (args: any, suspendOptions?: SuspendOptions) => {\n suspendData = args;\n return baseContext.agent?.suspend?.(args, suspendOptions);\n },\n }\n : baseContext.agent,\n workflow: baseContext.workflow\n ? {\n ...baseContext.workflow,\n suspend: (args: any, suspendOptions?: SuspendOptions) => {\n suspendData = args;\n return baseContext.workflow?.suspend?.(args, suspendOptions);\n },\n }\n : baseContext.workflow,\n requestContext: baseContext.requestContext || new RequestContext(),\n };\n }\n }\n\n const resumeData =\n organizedContext.agent?.resumeData ?? organizedContext.workflow?.resumeData ?? organizedContext?.resumeData;\n\n if (resumeData) {\n const resumeValidation = validateToolInput(this.resumeSchema, resumeData, this.id);\n if (resumeValidation.error) {\n return resumeValidation.error as any;\n }\n }\n\n // Call the original execute with validated input and organized context\n const output = await originalExecute(data as any, organizedContext);\n\n if (suspendData) {\n const suspendValidation = validateToolSuspendData(this.suspendSchema, suspendData, this.id);\n if (suspendValidation.error) {\n return suspendValidation.error as any;\n }\n }\n\n const skiptOutputValidation = !!(typeof output === 'undefined' && suspendData);\n\n // Validate output if schema exists\n const outputValidation = validateToolOutput(this.outputSchema, output, this.id, skiptOutputValidation);\n if (outputValidation.error) {\n return outputValidation.error as any;\n }\n\n return outputValidation.data;\n };\n }\n }\n}\n\n/**\n * Creates a type-safe tool with automatic input validation.\n *\n * @template TSchemaIn - Input schema type\n * @template TSchemaOut - Output schema type\n * @template TSuspendSchema - Suspend operation schema type\n * @template TResumeSchema - Resume operation schema type\n * @template TContext - Execution context type\n * @template TExecute - Execute function type\n *\n * @param opts - Tool configuration including schemas and execute function\n * @returns Type-safe Tool instance with conditional typing based on schemas\n *\n * @example Simple tool\n * ```typescript\n * const greetTool = createTool({\n * id: 'greet',\n * description: 'Say hello',\n * execute: async () => ({ message: 'Hello!' })\n * });\n * ```\n *\n * @example Tool with input validation\n * ```typescript\n * const calculateTool = createTool({\n * id: 'calculate',\n * description: 'Perform calculations',\n * inputSchema: z.object({\n * operation: z.enum(['add', 'subtract']),\n * a: z.number(),\n * b: z.number()\n * }),\n * execute: async (inputData) => {\n * const result = inputData.operation === 'add'\n * ? inputData.a + inputData.b\n * : inputData.a - inputData.b;\n * return { result };\n * }\n * });\n * ```\n *\n * @example Tool with output schema\n * ```typescript\n * const userTool = createTool({\n * id: 'get-user',\n * description: 'Get user data',\n * inputSchema: z.object({ userId: z.string() }),\n * outputSchema: z.object({\n * id: z.string(),\n * name: z.string(),\n * email: z.string()\n * }),\n * execute: async (inputData) => {\n * return await fetchUser(inputData.userId);\n * }\n * });\n * ```\n *\n * @example Tool with external API\n * ```typescript\n * const weatherTool = createTool({\n * id: 'weather',\n * description: 'Get weather data',\n * inputSchema: z.object({\n * city: z.string(),\n * units: z.enum(['metric', 'imperial']).default('metric')\n * }),\n * execute: async (inputData) => {\n * const response = await fetch(\n * `https://api.weather.com/v1/weather?q=${inputData.city}&units=${inputData.units}`\n * );\n * return response.json();\n * }\n * });\n * ```\n */\nexport function createTool<\n TId extends string = string,\n TSchemaIn extends ZodLikeSchema | undefined = undefined,\n TSchemaOut extends ZodLikeSchema | undefined = undefined,\n TSuspendSchema extends ZodLikeSchema = any,\n TResumeSchema extends ZodLikeSchema = any,\n TContext extends ToolExecutionContext<TSuspendSchema, TResumeSchema> = ToolExecutionContext<\n TSuspendSchema,\n TResumeSchema\n >,\n>(\n opts: ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId>,\n): [TSchemaIn, TSchemaOut] extends [ZodLikeSchema, ZodLikeSchema]\n ? Tool<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId> & {\n inputSchema: TSchemaIn;\n outputSchema: TSchemaOut;\n execute: (\n inputData: InferZodLikeSchema<TSchemaIn>,\n context?: TContext,\n ) => Promise<InferZodLikeSchemaInput<TSchemaOut> & { error?: never }>;\n }\n : Tool<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId> {\n return new Tool(opts) as any;\n}\n","import { Tool } from './tool';\nimport type { ToolToConvert } from './tool-builder/builder';\nimport type { VercelTool } from './types';\n\n/**\n * Checks if a tool is a Vercel Tool (AI SDK tool)\n * @param tool - The tool to check\n * @returns True if the tool is a Vercel Tool, false otherwise\n */\nexport function isVercelTool(tool?: ToolToConvert): tool is VercelTool {\n // Checks if this tool is not an instance of Mastra's Tool class\n // AI SDK tools must have an execute function and either:\n // - 'parameters' (v4) or 'inputSchema' (v5/v6)\n // This prevents plain objects with inputSchema (like client tools) from being treated as VercelTools\n return !!(\n tool &&\n !(tool instanceof Tool) &&\n ('parameters' in tool || ('execute' in tool && typeof tool.execute === 'function' && 'inputSchema' in tool))\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/tools/validation.ts","../src/tools/tool.ts","../src/tools/toolchecks.ts"],"names":["isZodArray","isZodObject","RequestContext","resumeData"],"mappings":";;;;;;AAgBA,SAAS,kBAAA,CAAmB,IAAA,EAAe,SAAA,GAAoB,GAAA,EAAa;AAC1E,EAAA,IAAI;AACF,IAAA,MAAM,WAAA,GAAc,IAAA,CAAK,SAAA,CAAU,IAAA,EAAM,MAAM,CAAC,CAAA;AAChD,IAAA,IAAI,WAAA,CAA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WLB.cjs","sourcesContent":["import type { z } from 'zod';\nimport type { ZodLikeSchema } from '../types/zod-compat';\nimport { isZodArray, isZodObject } from '../utils/zod-utils';\n\nexport interface ValidationError<T = any> {\n error: true;\n message: string;\n validationErrors: z.ZodFormattedError<T>;\n}\n\n/**\n * Safely truncates data for error messages to avoid exposing sensitive information.\n * @param data The data to truncate\n * @param maxLength Maximum length of the truncated string (default: 200)\n * @returns Truncated string representation\n */\nfunction truncateForLogging(data: unknown, maxLength: number = 200): string {\n try {\n const stringified = JSON.stringify(data, null, 2);\n if (stringified.length <= maxLength) {\n return stringified;\n }\n return stringified.slice(0, maxLength) + '... (truncated)';\n } catch {\n return '[Unable to serialize data]';\n }\n}\n\n/**\n * Validates raw suspend data against a Zod schema.\n *\n * @param schema The Zod schema to validate against\n * @param suspendData The raw suspend data to validate\n * @param toolId Optional tool ID for better error messages\n * @returns The validated data or a validation error\n */\nexport function validateToolSuspendData<T = any>(\n schema: ZodLikeSchema | undefined,\n suspendData: unknown,\n toolId?: string,\n): { data: T | unknown; error?: ValidationError<T> } {\n // If no schema, return suspend data as-is\n if (!schema || !('safeParse' in schema)) {\n return { data: suspendData };\n }\n\n // Validate the input directly - no unwrapping needed in v1.0\n const validation = schema.safeParse(suspendData);\n\n if (validation.success) {\n return { data: validation.data };\n }\n\n // Validation failed, return error\n const errorMessages = validation.error.issues\n .map((e: z.ZodIssue) => `- ${e.path?.join('.') || 'root'}: ${e.message}`)\n .join('\\n');\n\n const error: ValidationError<T> = {\n error: true,\n message: `Tool suspension data validation failed${toolId ? ` for ${toolId}` : ''}. Please fix the following errors and try again:\\n${errorMessages}\\n\\nProvided arguments: ${truncateForLogging(suspendData)}`,\n validationErrors: validation.error.format() as z.ZodFormattedError<T>,\n };\n\n return { data: suspendData, error };\n}\n\n/**\n * Normalizes undefined/null input to an appropriate default value based on schema type.\n * This handles LLMs (Claude Sonnet 4.5, Gemini 2.4, etc.) that send undefined/null\n * instead of {} or [] when all parameters are optional.\n *\n * @param schema The Zod schema to check\n * @param input The input to normalize\n * @returns The normalized input (original value, {}, or [])\n */\nfunction normalizeNullishInput(schema: ZodLikeSchema, input: unknown): unknown {\n if (input !== undefined && input !== null) {\n return input;\n }\n\n // Check if schema is an array type (using typeName to avoid dual-package hazard)\n if (isZodArray(schema as z.ZodTypeAny)) {\n return [];\n }\n\n // Check if schema is an object type (using typeName to avoid dual-package hazard)\n if (isZodObject(schema as z.ZodTypeAny)) {\n return {};\n }\n\n // For other schema types, return the original input and let Zod validate\n return input;\n}\n\n/**\n * Validates raw input data against a Zod schema.\n *\n * @param schema The Zod schema to validate against\n * @param input The raw input data to validate\n * @param toolId Optional tool ID for better error messages\n * @returns The validated data or a validation error\n */\nexport function validateToolInput<T = any>(\n schema: ZodLikeSchema | undefined,\n input: unknown,\n toolId?: string,\n): { data: T | unknown; error?: ValidationError<T> } {\n // If no schema, return input as-is\n if (!schema || !('safeParse' in schema)) {\n return { data: input };\n }\n\n // Normalize undefined/null input to appropriate default for the schema type\n // This handles LLMs that send undefined instead of {} or [] for optional parameters\n const normalizedInput = normalizeNullishInput(schema, input);\n\n // Validate the normalized input\n const validation = schema.safeParse(normalizedInput);\n\n if (validation.success) {\n return { data: validation.data };\n }\n\n // Validation failed, return error\n const errorMessages = validation.error.issues\n .map((e: z.ZodIssue) => `- ${e.path?.join('.') || 'root'}: ${e.message}`)\n .join('\\n');\n\n const error: ValidationError<T> = {\n error: true,\n message: `Tool input validation failed${toolId ? ` for ${toolId}` : ''}. Please fix the following errors and try again:\\n${errorMessages}\\n\\nProvided arguments: ${truncateForLogging(input)}`,\n validationErrors: validation.error.format() as z.ZodFormattedError<T>,\n };\n\n return { data: input, error };\n}\n\n/**\n * Validates tool output data against a Zod schema.\n *\n * @param schema The Zod schema to validate against\n * @param output The output data to validate\n * @param toolId Optional tool ID for better error messages\n * @returns The validated data or a validation error\n */\nexport function validateToolOutput<T = any>(\n schema: ZodLikeSchema | undefined,\n output: unknown,\n toolId?: string,\n suspendCalled?: boolean,\n): { data: T | unknown; error?: ValidationError<T> } {\n // If no schema, return output as-is\n if (!schema || !('safeParse' in schema) || suspendCalled) {\n return { data: output };\n }\n\n // Validate the output\n const validation = schema.safeParse(output);\n\n if (validation.success) {\n return { data: validation.data };\n }\n\n // Validation failed, return error\n const errorMessages = validation.error.issues\n .map((e: z.ZodIssue) => `- ${e.path?.join('.') || 'root'}: ${e.message}`)\n .join('\\n');\n\n const error: ValidationError<T> = {\n error: true,\n message: `Tool output validation failed${toolId ? ` for ${toolId}` : ''}. The tool returned invalid output:\\n${errorMessages}\\n\\nReturned output: ${truncateForLogging(output)}`,\n validationErrors: validation.error.format() as z.ZodFormattedError<T>,\n };\n\n return { data: output, error };\n}\n","import type { Mastra } from '../mastra';\nimport { RequestContext } from '../request-context';\nimport type { ZodLikeSchema, InferZodLikeSchema, InferZodLikeSchemaInput } from '../types/zod-compat';\nimport type { SuspendOptions } from '../workflows';\nimport type { ToolAction, ToolExecutionContext } from './types';\nimport { validateToolInput, validateToolOutput, validateToolSuspendData } from './validation';\n\n/**\n * A type-safe tool that agents and workflows can call to perform specific actions.\n *\n * @template TSchemaIn - Input schema type\n * @template TSchemaOut - Output schema type\n * @template TSuspendSchema - Suspend operation schema type\n * @template TResumeSchema - Resume operation schema type\n * @template TContext - Execution context type\n *\n * @example Basic tool with validation\n * ```typescript\n * const weatherTool = createTool({\n * id: 'get-weather',\n * description: 'Get weather for a location',\n * inputSchema: z.object({\n * location: z.string(),\n * units: z.enum(['celsius', 'fahrenheit']).optional()\n * }),\n * execute: async (inputData) => {\n * return await fetchWeather(inputData.location, inputData.units);\n * }\n * });\n * ```\n *\n * @example Tool requiring approval\n * ```typescript\n * const deleteFileTool = createTool({\n * id: 'delete-file',\n * description: 'Delete a file',\n * requireApproval: true,\n * inputSchema: z.object({ filepath: z.string() }),\n * execute: async (inputData) => {\n * await fs.unlink(inputData.filepath);\n * return { deleted: true };\n * }\n * });\n * ```\n *\n * @example Tool with Mastra integration\n * ```typescript\n * const saveTool = createTool({\n * id: 'save-data',\n * description: 'Save data to storage',\n * inputSchema: z.object({ key: z.string(), value: z.any() }),\n * execute: async (inputData, context) => {\n * const storage = context?.mastra?.getStorage();\n * await storage?.set(inputData.key, inputData.value);\n * return { saved: true };\n * }\n * });\n * ```\n */\nexport class Tool<\n TSchemaIn extends ZodLikeSchema | undefined = undefined,\n TSchemaOut extends ZodLikeSchema | undefined = undefined,\n TSuspendSchema extends ZodLikeSchema = any,\n TResumeSchema extends ZodLikeSchema = any,\n TContext extends ToolExecutionContext<TSuspendSchema, TResumeSchema> = ToolExecutionContext<\n TSuspendSchema,\n TResumeSchema\n >,\n TId extends string = string,\n> implements ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId>\n{\n /** Unique identifier for the tool */\n id: TId;\n\n /** Description of what the tool does */\n description: string;\n\n /** Schema for validating input parameters */\n inputSchema?: TSchemaIn;\n\n /** Schema for validating output structure */\n outputSchema?: TSchemaOut;\n\n /** Schema for suspend operation data */\n suspendSchema?: TSuspendSchema;\n\n /** Schema for resume operation data */\n resumeSchema?: TResumeSchema;\n\n /**\n * Tool execution function\n * @param inputData - The raw, validated input data\n * @param context - Optional execution context with metadata\n * @returns Promise resolving to tool output or a ValidationError if input validation fails\n */\n execute?: ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext>['execute'];\n\n /** Parent Mastra instance for accessing shared resources */\n mastra?: Mastra;\n\n /**\n * Whether the tool requires explicit user approval before execution\n * @example\n * ```typescript\n * // For destructive operations\n * requireApproval: true\n * ```\n */\n requireApproval?: boolean;\n\n /**\n * Provider-specific options passed to the model when this tool is used.\n * Keys are provider names (e.g., 'anthropic', 'openai'), values are provider-specific configs.\n * @example\n * ```typescript\n * providerOptions: {\n * anthropic: {\n * cacheControl: { type: 'ephemeral' }\n * }\n * }\n * ```\n */\n providerOptions?: Record<string, Record<string, unknown>>;\n\n /**\n * Creates a new Tool instance with input validation wrapper.\n *\n * @param opts - Tool configuration and execute function\n * @example\n * ```typescript\n * const tool = new Tool({\n * id: 'my-tool',\n * description: 'Does something useful',\n * inputSchema: z.object({ name: z.string() }),\n * execute: async (inputData) => ({ greeting: `Hello ${inputData.name}` })\n * });\n * ```\n */\n constructor(opts: ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId>) {\n this.id = opts.id;\n this.description = opts.description;\n this.inputSchema = opts.inputSchema;\n this.outputSchema = opts.outputSchema;\n this.suspendSchema = opts.suspendSchema;\n this.resumeSchema = opts.resumeSchema;\n this.mastra = opts.mastra;\n this.requireApproval = opts.requireApproval || false;\n this.providerOptions = opts.providerOptions;\n\n // Tools receive two parameters:\n // 1. input - The raw, validated input data\n // 2. context - Execution metadata (mastra, suspend, etc.)\n if (opts.execute) {\n const originalExecute = opts.execute;\n this.execute = async (inputData: unknown, context?: any) => {\n // Validate input if schema exists\n const { data, error } = validateToolInput(this.inputSchema, inputData, this.id);\n if (error) {\n return error as any;\n }\n\n let suspendData = null;\n\n const baseContext = context\n ? {\n ...context,\n ...(context.suspend\n ? {\n suspend: (args: any, suspendOptions?: SuspendOptions) => {\n suspendData = args;\n return context.suspend?.(args, suspendOptions);\n },\n }\n : {}),\n }\n : {};\n\n // Organize context based on execution source\n let organizedContext = baseContext;\n if (!context) {\n // No context provided - create a minimal context with requestContext\n organizedContext = {\n requestContext: new RequestContext(),\n mastra: undefined,\n };\n } else {\n // Check if this is agent execution (has toolCallId and messages)\n const isAgentExecution = baseContext.toolCallId && baseContext.messages;\n\n // Check if this is workflow execution (has workflow properties)\n // Agent execution takes precedence - don't treat as workflow if it's an agent call\n const isWorkflowExecution = !isAgentExecution && (baseContext.workflow || baseContext.workflowId);\n\n if (isAgentExecution && !baseContext.agent) {\n // Reorganize agent context - nest agent-specific properties under 'agent' key\n const { toolCallId, messages, suspend, resumeData, threadId, resourceId, writableStream, ...rest } =\n baseContext;\n organizedContext = {\n ...rest,\n agent: {\n toolCallId,\n messages,\n suspend,\n resumeData,\n threadId,\n resourceId,\n writableStream,\n },\n // Ensure requestContext is always present\n requestContext: rest.requestContext || new RequestContext(),\n };\n } else if (isWorkflowExecution && !baseContext.workflow) {\n // Reorganize workflow context - nest workflow-specific properties under 'workflow' key\n const { workflowId, runId, state, setState, suspend, resumeData, ...rest } = baseContext;\n organizedContext = {\n ...rest,\n workflow: {\n workflowId,\n runId,\n state,\n setState,\n suspend,\n resumeData,\n },\n // Ensure requestContext is always present\n requestContext: rest.requestContext || new RequestContext(),\n };\n } else {\n // Ensure requestContext is always present even for direct execution\n organizedContext = {\n ...baseContext,\n agent: baseContext.agent\n ? {\n ...baseContext.agent,\n suspend: (args: any, suspendOptions?: SuspendOptions) => {\n suspendData = args;\n return baseContext.agent?.suspend?.(args, suspendOptions);\n },\n }\n : baseContext.agent,\n workflow: baseContext.workflow\n ? {\n ...baseContext.workflow,\n suspend: (args: any, suspendOptions?: SuspendOptions) => {\n suspendData = args;\n return baseContext.workflow?.suspend?.(args, suspendOptions);\n },\n }\n : baseContext.workflow,\n requestContext: baseContext.requestContext || new RequestContext(),\n };\n }\n }\n\n const resumeData =\n organizedContext.agent?.resumeData ?? organizedContext.workflow?.resumeData ?? organizedContext?.resumeData;\n\n if (resumeData) {\n const resumeValidation = validateToolInput(this.resumeSchema, resumeData, this.id);\n if (resumeValidation.error) {\n return resumeValidation.error as any;\n }\n }\n\n // Call the original execute with validated input and organized context\n const output = await originalExecute(data as any, organizedContext);\n\n if (suspendData) {\n const suspendValidation = validateToolSuspendData(this.suspendSchema, suspendData, this.id);\n if (suspendValidation.error) {\n return suspendValidation.error as any;\n }\n }\n\n const skiptOutputValidation = !!(typeof output === 'undefined' && suspendData);\n\n // Validate output if schema exists\n const outputValidation = validateToolOutput(this.outputSchema, output, this.id, skiptOutputValidation);\n if (outputValidation.error) {\n return outputValidation.error as any;\n }\n\n return outputValidation.data;\n };\n }\n }\n}\n\n/**\n * Creates a type-safe tool with automatic input validation.\n *\n * @template TSchemaIn - Input schema type\n * @template TSchemaOut - Output schema type\n * @template TSuspendSchema - Suspend operation schema type\n * @template TResumeSchema - Resume operation schema type\n * @template TContext - Execution context type\n * @template TExecute - Execute function type\n *\n * @param opts - Tool configuration including schemas and execute function\n * @returns Type-safe Tool instance with conditional typing based on schemas\n *\n * @example Simple tool\n * ```typescript\n * const greetTool = createTool({\n * id: 'greet',\n * description: 'Say hello',\n * execute: async () => ({ message: 'Hello!' })\n * });\n * ```\n *\n * @example Tool with input validation\n * ```typescript\n * const calculateTool = createTool({\n * id: 'calculate',\n * description: 'Perform calculations',\n * inputSchema: z.object({\n * operation: z.enum(['add', 'subtract']),\n * a: z.number(),\n * b: z.number()\n * }),\n * execute: async (inputData) => {\n * const result = inputData.operation === 'add'\n * ? inputData.a + inputData.b\n * : inputData.a - inputData.b;\n * return { result };\n * }\n * });\n * ```\n *\n * @example Tool with output schema\n * ```typescript\n * const userTool = createTool({\n * id: 'get-user',\n * description: 'Get user data',\n * inputSchema: z.object({ userId: z.string() }),\n * outputSchema: z.object({\n * id: z.string(),\n * name: z.string(),\n * email: z.string()\n * }),\n * execute: async (inputData) => {\n * return await fetchUser(inputData.userId);\n * }\n * });\n * ```\n *\n * @example Tool with external API\n * ```typescript\n * const weatherTool = createTool({\n * id: 'weather',\n * description: 'Get weather data',\n * inputSchema: z.object({\n * city: z.string(),\n * units: z.enum(['metric', 'imperial']).default('metric')\n * }),\n * execute: async (inputData) => {\n * const response = await fetch(\n * `https://api.weather.com/v1/weather?q=${inputData.city}&units=${inputData.units}`\n * );\n * return response.json();\n * }\n * });\n * ```\n */\nexport function createTool<\n TId extends string = string,\n TSchemaIn extends ZodLikeSchema | undefined = undefined,\n TSchemaOut extends ZodLikeSchema | undefined = undefined,\n TSuspendSchema extends ZodLikeSchema = any,\n TResumeSchema extends ZodLikeSchema = any,\n TContext extends ToolExecutionContext<TSuspendSchema, TResumeSchema> = ToolExecutionContext<\n TSuspendSchema,\n TResumeSchema\n >,\n>(\n opts: ToolAction<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId>,\n): [TSchemaIn, TSchemaOut] extends [ZodLikeSchema, ZodLikeSchema]\n ? Tool<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId> & {\n inputSchema: TSchemaIn;\n outputSchema: TSchemaOut;\n execute: (\n inputData: InferZodLikeSchema<TSchemaIn>,\n context?: TContext,\n ) => Promise<InferZodLikeSchemaInput<TSchemaOut> & { error?: never }>;\n }\n : Tool<TSchemaIn, TSchemaOut, TSuspendSchema, TResumeSchema, TContext, TId> {\n return new Tool(opts) as any;\n}\n","import { Tool } from './tool';\nimport type { ToolToConvert } from './tool-builder/builder';\nimport type { VercelTool } from './types';\n\n/**\n * Checks if a tool is a Vercel Tool (AI SDK tool)\n * @param tool - The tool to check\n * @returns True if the tool is a Vercel Tool, false otherwise\n */\nexport function isVercelTool(tool?: ToolToConvert): tool is VercelTool {\n // Checks if this tool is not an instance of Mastra's Tool class\n // AI SDK tools must have an execute function and either:\n // - 'parameters' (v4) or 'inputSchema' (v5/v6)\n // This prevents plain objects with inputSchema (like client tools) from being treated as VercelTools\n return !!(\n tool &&\n !(tool instanceof Tool) &&\n ('parameters' in tool || ('execute' in tool && typeof tool.execute === 'function' && 'inputSchema' in tool))\n );\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkGFALVOBW_cjs = require('./chunk-GFALVOBW.cjs');
|
|
4
4
|
var chunkL3NKIMF5_cjs = require('./chunk-L3NKIMF5.cjs');
|
|
5
5
|
var chunk4U7ZLI36_cjs = require('./chunk-4U7ZLI36.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkO4YSWWLB_cjs = require('./chunk-O4YSWWLB.cjs');
|
|
7
7
|
var chunkUVHSM2GU_cjs = require('./chunk-UVHSM2GU.cjs');
|
|
8
8
|
var chunkDGV2FWB4_cjs = require('./chunk-DGV2FWB4.cjs');
|
|
9
9
|
var chunkAF74UXR5_cjs = require('./chunk-AF74UXR5.cjs');
|
|
@@ -31,7 +31,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
31
31
|
let suspended;
|
|
32
32
|
let bailed;
|
|
33
33
|
const startedAt = Date.now();
|
|
34
|
-
const { inputData, validationError } = await
|
|
34
|
+
const { inputData, validationError } = await chunkGFALVOBW_cjs.validateStepInput({
|
|
35
35
|
prevOutput: typeof params.foreachIdx === "number" ? params.input?.[params.foreachIdx] : params.input,
|
|
36
36
|
step,
|
|
37
37
|
validateInputs: params.validateInputs ?? true
|
|
@@ -56,7 +56,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
56
56
|
throw validationError;
|
|
57
57
|
}
|
|
58
58
|
const stepOutput = await step.execute(
|
|
59
|
-
|
|
59
|
+
chunkGFALVOBW_cjs.createDeprecationProxy(
|
|
60
60
|
{
|
|
61
61
|
workflowId: params.workflowId,
|
|
62
62
|
runId,
|
|
@@ -71,9 +71,9 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
71
71
|
resumeData: params.resumeData,
|
|
72
72
|
suspendData: suspendDataToUse,
|
|
73
73
|
getInitData: () => stepResults?.input,
|
|
74
|
-
getStepResult:
|
|
74
|
+
getStepResult: chunkGFALVOBW_cjs.getStepResult.bind(this, stepResults),
|
|
75
75
|
suspend: async (suspendPayload) => {
|
|
76
|
-
const { suspendData, validationError: validationError2 } = await
|
|
76
|
+
const { suspendData, validationError: validationError2 } = await chunkGFALVOBW_cjs.validateStepSuspendData({
|
|
77
77
|
suspendData: suspendPayload,
|
|
78
78
|
step,
|
|
79
79
|
validateInputs: params.validateInputs ?? true
|
|
@@ -91,7 +91,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
91
91
|
abort: () => {
|
|
92
92
|
abortController?.abort();
|
|
93
93
|
},
|
|
94
|
-
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new
|
|
94
|
+
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new chunkGFALVOBW_cjs.EventEmitterPubSub(params.emitter),
|
|
95
95
|
[chunkL3NKIMF5_cjs.STREAM_FORMAT_SYMBOL]: void 0,
|
|
96
96
|
// TODO
|
|
97
97
|
engine: {},
|
|
@@ -101,7 +101,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
103
|
paramName: "runCount",
|
|
104
|
-
deprecationMessage:
|
|
104
|
+
deprecationMessage: chunkGFALVOBW_cjs.runCountDeprecationMessage,
|
|
105
105
|
logger: this.logger
|
|
106
106
|
}
|
|
107
107
|
)
|
|
@@ -206,7 +206,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
206
206
|
iterationCount
|
|
207
207
|
}) {
|
|
208
208
|
return condition(
|
|
209
|
-
|
|
209
|
+
chunkGFALVOBW_cjs.createDeprecationProxy(
|
|
210
210
|
{
|
|
211
211
|
workflowId,
|
|
212
212
|
runId,
|
|
@@ -217,7 +217,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
217
217
|
retryCount,
|
|
218
218
|
resumeData,
|
|
219
219
|
getInitData: () => stepResults?.input,
|
|
220
|
-
getStepResult:
|
|
220
|
+
getStepResult: chunkGFALVOBW_cjs.getStepResult.bind(this, stepResults),
|
|
221
221
|
bail: (_result) => {
|
|
222
222
|
throw new Error("Not implemented");
|
|
223
223
|
},
|
|
@@ -226,7 +226,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
226
226
|
abort: () => {
|
|
227
227
|
abortController?.abort();
|
|
228
228
|
},
|
|
229
|
-
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new
|
|
229
|
+
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new chunkGFALVOBW_cjs.EventEmitterPubSub(emitter),
|
|
230
230
|
[chunkL3NKIMF5_cjs.STREAM_FORMAT_SYMBOL]: void 0,
|
|
231
231
|
// TODO
|
|
232
232
|
engine: {},
|
|
@@ -237,7 +237,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
237
237
|
},
|
|
238
238
|
{
|
|
239
239
|
paramName: "runCount",
|
|
240
|
-
deprecationMessage:
|
|
240
|
+
deprecationMessage: chunkGFALVOBW_cjs.runCountDeprecationMessage,
|
|
241
241
|
logger: this.logger
|
|
242
242
|
}
|
|
243
243
|
)
|
|
@@ -255,7 +255,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
255
255
|
}
|
|
256
256
|
try {
|
|
257
257
|
return await step.fn(
|
|
258
|
-
|
|
258
|
+
chunkGFALVOBW_cjs.createDeprecationProxy(
|
|
259
259
|
{
|
|
260
260
|
workflowId: params.workflowId,
|
|
261
261
|
runId,
|
|
@@ -269,7 +269,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
269
269
|
retryCount,
|
|
270
270
|
resumeData: params.resumeData,
|
|
271
271
|
getInitData: () => stepResults?.input,
|
|
272
|
-
getStepResult:
|
|
272
|
+
getStepResult: chunkGFALVOBW_cjs.getStepResult.bind(this, stepResults),
|
|
273
273
|
suspend: async (_suspendPayload) => {
|
|
274
274
|
throw new Error("Not implemented");
|
|
275
275
|
},
|
|
@@ -281,7 +281,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
281
281
|
},
|
|
282
282
|
// TODO
|
|
283
283
|
writer: void 0,
|
|
284
|
-
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new
|
|
284
|
+
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new chunkGFALVOBW_cjs.EventEmitterPubSub(ee),
|
|
285
285
|
[chunkL3NKIMF5_cjs.STREAM_FORMAT_SYMBOL]: void 0,
|
|
286
286
|
// TODO
|
|
287
287
|
engine: {},
|
|
@@ -291,7 +291,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
291
291
|
},
|
|
292
292
|
{
|
|
293
293
|
paramName: "runCount",
|
|
294
|
-
deprecationMessage:
|
|
294
|
+
deprecationMessage: chunkGFALVOBW_cjs.runCountDeprecationMessage,
|
|
295
295
|
logger: this.logger
|
|
296
296
|
}
|
|
297
297
|
)
|
|
@@ -313,7 +313,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
313
313
|
}
|
|
314
314
|
try {
|
|
315
315
|
const result = await step.fn(
|
|
316
|
-
|
|
316
|
+
chunkGFALVOBW_cjs.createDeprecationProxy(
|
|
317
317
|
{
|
|
318
318
|
workflowId: params.workflowId,
|
|
319
319
|
runId,
|
|
@@ -327,7 +327,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
327
327
|
retryCount,
|
|
328
328
|
resumeData: params.resumeData,
|
|
329
329
|
getInitData: () => stepResults?.input,
|
|
330
|
-
getStepResult:
|
|
330
|
+
getStepResult: chunkGFALVOBW_cjs.getStepResult.bind(this, stepResults),
|
|
331
331
|
suspend: async (_suspendPayload) => {
|
|
332
332
|
throw new Error("Not implemented");
|
|
333
333
|
},
|
|
@@ -339,7 +339,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
339
339
|
},
|
|
340
340
|
// TODO
|
|
341
341
|
writer: void 0,
|
|
342
|
-
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new
|
|
342
|
+
[chunkL3NKIMF5_cjs.PUBSUB_SYMBOL]: this.mastra?.pubsub ?? new chunkGFALVOBW_cjs.EventEmitterPubSub(ee),
|
|
343
343
|
[chunkL3NKIMF5_cjs.STREAM_FORMAT_SYMBOL]: void 0,
|
|
344
344
|
// TODO
|
|
345
345
|
engine: {},
|
|
@@ -349,7 +349,7 @@ var StepExecutor = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
349
349
|
},
|
|
350
350
|
{
|
|
351
351
|
paramName: "runCount",
|
|
352
|
-
deprecationMessage:
|
|
352
|
+
deprecationMessage: chunkGFALVOBW_cjs.runCountDeprecationMessage,
|
|
353
353
|
logger: this.logger
|
|
354
354
|
}
|
|
355
355
|
)
|
|
@@ -1574,7 +1574,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1574
1574
|
workflowName: step.step.id,
|
|
1575
1575
|
runId
|
|
1576
1576
|
}) ?? { context: {} };
|
|
1577
|
-
const timeTravelParams =
|
|
1577
|
+
const timeTravelParams = chunkGFALVOBW_cjs.createTimeTravelExecutionParams({
|
|
1578
1578
|
steps: timeTravel.steps.slice(1),
|
|
1579
1579
|
inputData: timeTravel.inputData,
|
|
1580
1580
|
resumeData: timeTravel.resumeData,
|
|
@@ -1668,7 +1668,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
1668
1668
|
for (const [key, value] of Object.entries(requestContext)) {
|
|
1669
1669
|
rc.set(key, value);
|
|
1670
1670
|
}
|
|
1671
|
-
const { resumeData: timeTravelResumeData, validationError: timeTravelResumeValidationError } = await
|
|
1671
|
+
const { resumeData: timeTravelResumeData, validationError: timeTravelResumeValidationError } = await chunkGFALVOBW_cjs.validateStepResumeData({
|
|
1672
1672
|
resumeData: timeTravel?.stepResults[step.step.id]?.status === "suspended" ? timeTravel?.resumeData : void 0,
|
|
1673
1673
|
step: step.step
|
|
1674
1674
|
});
|
|
@@ -2224,7 +2224,7 @@ var WorkflowEventProcessor = class extends EventProcessor {
|
|
|
2224
2224
|
|
|
2225
2225
|
// src/workflows/evented/workflow.ts
|
|
2226
2226
|
function cloneWorkflow(workflow, opts) {
|
|
2227
|
-
const wf = new
|
|
2227
|
+
const wf = new chunkGFALVOBW_cjs.Workflow({
|
|
2228
2228
|
id: opts.id,
|
|
2229
2229
|
inputSchema: workflow.inputSchema,
|
|
2230
2230
|
outputSchema: workflow.outputSchema,
|
|
@@ -2255,7 +2255,7 @@ function isAgent(params) {
|
|
|
2255
2255
|
return params?.component === "AGENT";
|
|
2256
2256
|
}
|
|
2257
2257
|
function isTool(params) {
|
|
2258
|
-
return params instanceof
|
|
2258
|
+
return params instanceof chunkO4YSWWLB_cjs.Tool;
|
|
2259
2259
|
}
|
|
2260
2260
|
function createStep(params) {
|
|
2261
2261
|
if (isAgent(params)) {
|
|
@@ -2392,7 +2392,7 @@ function createWorkflow(params) {
|
|
|
2392
2392
|
executionEngine
|
|
2393
2393
|
});
|
|
2394
2394
|
}
|
|
2395
|
-
var EventedWorkflow = class extends
|
|
2395
|
+
var EventedWorkflow = class extends chunkGFALVOBW_cjs.Workflow {
|
|
2396
2396
|
constructor(params) {
|
|
2397
2397
|
super(params);
|
|
2398
2398
|
this.engineType = "evented";
|
|
@@ -2452,7 +2452,7 @@ var EventedWorkflow = class extends chunk5DL6Y7PJ_cjs.Workflow {
|
|
|
2452
2452
|
return run;
|
|
2453
2453
|
}
|
|
2454
2454
|
};
|
|
2455
|
-
var EventedRun = class extends
|
|
2455
|
+
var EventedRun = class extends chunkGFALVOBW_cjs.Run {
|
|
2456
2456
|
constructor(params) {
|
|
2457
2457
|
super(params);
|
|
2458
2458
|
this.serializedStepGraph = params.serializedStepGraph;
|
|
@@ -2757,7 +2757,7 @@ function isExecutableStep(step) {
|
|
|
2757
2757
|
}
|
|
2758
2758
|
|
|
2759
2759
|
// src/workflows/evented/execution-engine.ts
|
|
2760
|
-
var EventedExecutionEngine = class extends
|
|
2760
|
+
var EventedExecutionEngine = class extends chunkGFALVOBW_cjs.ExecutionEngine {
|
|
2761
2761
|
eventProcessor;
|
|
2762
2762
|
constructor({
|
|
2763
2763
|
mastra,
|
|
@@ -2843,7 +2843,7 @@ var EventedExecutionEngine = class extends chunk5DL6Y7PJ_cjs.ExecutionEngine {
|
|
|
2843
2843
|
await ack?.();
|
|
2844
2844
|
await pubsub.unsubscribe("workflows-finish", finishCb);
|
|
2845
2845
|
if (event.type === "workflow.fail" && event.data.stepResults) {
|
|
2846
|
-
event.data.stepResults =
|
|
2846
|
+
event.data.stepResults = chunkGFALVOBW_cjs.hydrateSerializedStepErrors(event.data.stepResults);
|
|
2847
2847
|
}
|
|
2848
2848
|
resolve(event.data);
|
|
2849
2849
|
return;
|
|
@@ -2910,5 +2910,5 @@ exports.cloneStep = cloneStep;
|
|
|
2910
2910
|
exports.cloneWorkflow = cloneWorkflow;
|
|
2911
2911
|
exports.createStep = createStep;
|
|
2912
2912
|
exports.createWorkflow = createWorkflow;
|
|
2913
|
-
//# sourceMappingURL=chunk-
|
|
2914
|
-
//# sourceMappingURL=chunk-
|
|
2913
|
+
//# sourceMappingURL=chunk-P3XQ3TNY.cjs.map
|
|
2914
|
+
//# sourceMappingURL=chunk-P3XQ3TNY.cjs.map
|