@mastra/core 1.0.0-beta.17 → 1.0.0-beta.19
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 +83 -0
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +11 -11
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +3 -3
- package/dist/agent/message-list/index.d.ts +8 -0
- package/dist/agent/message-list/index.d.ts.map +1 -1
- package/dist/agent/message-list/index.js +1 -1
- package/dist/{chunk-3AISNGWY.cjs → chunk-3LVC2TGA.cjs} +7 -7
- package/dist/{chunk-3AISNGWY.cjs.map → chunk-3LVC2TGA.cjs.map} +1 -1
- package/dist/{chunk-JBEKXEX6.js → chunk-43VR5ZNS.js} +3 -3
- package/dist/{chunk-JBEKXEX6.js.map → chunk-43VR5ZNS.js.map} +1 -1
- package/dist/{chunk-G6YCU7HJ.cjs → chunk-4BYMMTK6.cjs} +5 -5
- package/dist/{chunk-G6YCU7HJ.cjs.map → chunk-4BYMMTK6.cjs.map} +1 -1
- package/dist/{chunk-SRQTDHF5.js → chunk-5ABMEQEN.js} +101 -25
- package/dist/chunk-5ABMEQEN.js.map +1 -0
- package/dist/{chunk-RGX4NX5L.cjs → chunk-5ISEMRYZ.cjs} +102 -26
- package/dist/chunk-5ISEMRYZ.cjs.map +1 -0
- package/dist/{chunk-7CDELQD6.js → chunk-6CJM5Y6Z.js} +4 -4
- package/dist/{chunk-7CDELQD6.js.map → chunk-6CJM5Y6Z.js.map} +1 -1
- package/dist/{chunk-O4YSWWLB.cjs → chunk-ABHX6L4P.cjs} +20 -3
- package/dist/chunk-ABHX6L4P.cjs.map +1 -0
- package/dist/{chunk-OHQ4PC6P.cjs → chunk-DE4ZHUSC.cjs} +13 -13
- package/dist/{chunk-OHQ4PC6P.cjs.map → chunk-DE4ZHUSC.cjs.map} +1 -1
- package/dist/{chunk-SDR22R4D.cjs → chunk-E77HNO5E.cjs} +14 -14
- package/dist/{chunk-SDR22R4D.cjs.map → chunk-E77HNO5E.cjs.map} +1 -1
- package/dist/{chunk-QXL3F3T2.js → chunk-HUHM6BXV.js} +50 -6
- package/dist/chunk-HUHM6BXV.js.map +1 -0
- package/dist/{chunk-N6HPK6I3.cjs → chunk-I7HSIQRP.cjs} +15 -15
- package/dist/{chunk-N6HPK6I3.cjs.map → chunk-I7HSIQRP.cjs.map} +1 -1
- package/dist/{chunk-RC7RN5MY.js → chunk-IIGB2Z6S.js} +3 -3
- package/dist/{chunk-RC7RN5MY.js.map → chunk-IIGB2Z6S.js.map} +1 -1
- package/dist/{chunk-4DFWV4IR.js → chunk-ILOI5OB3.js} +3 -3
- package/dist/chunk-ILOI5OB3.js.map +1 -0
- package/dist/{chunk-AAX7ZOM7.cjs → chunk-IMMRWP4F.cjs} +3 -3
- package/dist/chunk-IMMRWP4F.cjs.map +1 -0
- package/dist/{chunk-5YYAQUEF.js → chunk-M55RALU2.js} +20 -3
- package/dist/chunk-M55RALU2.js.map +1 -0
- package/dist/{chunk-4QYTF4ZB.cjs → chunk-MV7R7B6Z.cjs} +30 -30
- package/dist/{chunk-4QYTF4ZB.cjs.map → chunk-MV7R7B6Z.cjs.map} +1 -1
- package/dist/{chunk-EMLEZXTQ.cjs → chunk-MVLOJX6I.cjs} +50 -6
- package/dist/chunk-MVLOJX6I.cjs.map +1 -0
- package/dist/{chunk-SGRMJZMJ.cjs → chunk-N55KRGVI.cjs} +6 -6
- package/dist/{chunk-SGRMJZMJ.cjs.map → chunk-N55KRGVI.cjs.map} +1 -1
- package/dist/{chunk-YORDI4E7.js → chunk-O3DUSIUY.js} +37 -23
- package/dist/chunk-O3DUSIUY.js.map +1 -0
- package/dist/{chunk-SJ3MF5G2.js → chunk-OSXQXATR.js} +4 -4
- package/dist/{chunk-SJ3MF5G2.js.map → chunk-OSXQXATR.js.map} +1 -1
- package/dist/{chunk-6ZKYNY3H.cjs → chunk-S6HUG6SH.cjs} +84 -70
- package/dist/chunk-S6HUG6SH.cjs.map +1 -0
- package/dist/{chunk-4M75INXO.cjs → chunk-TRSSKBDY.cjs} +16 -16
- package/dist/{chunk-4M75INXO.cjs.map → chunk-TRSSKBDY.cjs.map} +1 -1
- package/dist/{chunk-GPC7WOLN.js → chunk-XUQY6EIK.js} +4 -4
- package/dist/{chunk-GPC7WOLN.js.map → chunk-XUQY6EIK.js.map} +1 -1
- package/dist/{chunk-HGWVTZWK.js → chunk-Y3PUB5GS.js} +6 -6
- package/dist/{chunk-HGWVTZWK.js.map → chunk-Y3PUB5GS.js.map} +1 -1
- package/dist/{chunk-ABMWK6JU.js → chunk-Z2JFMLEA.js} +3 -3
- package/dist/{chunk-ABMWK6JU.js.map → chunk-Z2JFMLEA.js.map} +1 -1
- package/dist/{chunk-I55X7FYN.js → chunk-ZKE2ZPHB.js} +5 -5
- package/dist/{chunk-I55X7FYN.js.map → chunk-ZKE2ZPHB.js.map} +1 -1
- package/dist/evals/index.cjs +4 -4
- package/dist/evals/index.js +1 -1
- package/dist/evals/scoreTraces/index.cjs +3 -3
- package/dist/evals/scoreTraces/index.js +1 -1
- 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/gateways/models-dev.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +41 -11
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +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/memory/memory.d.ts +1 -1
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/memory/types.d.ts +19 -1
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/models-dev-FHJWQQO5.cjs +12 -0
- package/dist/{models-dev-26XLUKVK.cjs.map → models-dev-FHJWQQO5.cjs.map} +1 -1
- package/dist/models-dev-JMCO6M5W.js +3 -0
- package/dist/{models-dev-HUFLQFPB.js.map → models-dev-JMCO6M5W.js.map} +1 -1
- package/dist/processors/index.cjs +37 -37
- package/dist/processors/index.js +1 -1
- package/dist/processors/memory/semantic-recall.d.ts +19 -1
- package/dist/processors/memory/semantic-recall.d.ts.map +1 -1
- package/dist/provider-registry-IZPSWLPV.js +3 -0
- package/dist/{provider-registry-LUBC7RIO.js.map → provider-registry-IZPSWLPV.js.map} +1 -1
- package/dist/provider-registry-OZWLA7RR.cjs +40 -0
- package/dist/{provider-registry-AUJKATCF.cjs.map → provider-registry-OZWLA7RR.cjs.map} +1 -1
- package/dist/provider-registry.json +98 -22
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/index.cjs +30 -30
- package/dist/storage/index.js +1 -1
- package/dist/stream/base/output-format-handlers.d.ts.map +1 -1
- package/dist/stream/base/schema.d.ts.map +1 -1
- package/dist/stream/index.cjs +12 -12
- package/dist/stream/index.js +2 -2
- 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/tools/validation.d.ts.map +1 -1
- package/dist/utils.cjs +22 -22
- package/dist/utils.js +1 -1
- 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 +41 -11
- package/dist/chunk-4DFWV4IR.js.map +0 -1
- package/dist/chunk-5YYAQUEF.js.map +0 -1
- package/dist/chunk-6ZKYNY3H.cjs.map +0 -1
- package/dist/chunk-AAX7ZOM7.cjs.map +0 -1
- package/dist/chunk-EMLEZXTQ.cjs.map +0 -1
- package/dist/chunk-O4YSWWLB.cjs.map +0 -1
- package/dist/chunk-QXL3F3T2.js.map +0 -1
- package/dist/chunk-RGX4NX5L.cjs.map +0 -1
- package/dist/chunk-SRQTDHF5.js.map +0 -1
- package/dist/chunk-YORDI4E7.js.map +0 -1
- package/dist/models-dev-26XLUKVK.cjs +0 -12
- package/dist/models-dev-HUFLQFPB.js +0 -3
- package/dist/provider-registry-AUJKATCF.cjs +0 -40
- package/dist/provider-registry-LUBC7RIO.js +0 -3
|
@@ -46,11 +46,28 @@ function normalizeNullishInput(schema, input) {
|
|
|
46
46
|
}
|
|
47
47
|
return input;
|
|
48
48
|
}
|
|
49
|
+
function convertUndefinedToNull(input) {
|
|
50
|
+
if (input === void 0) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (input === null || typeof input !== "object") {
|
|
54
|
+
return input;
|
|
55
|
+
}
|
|
56
|
+
if (Array.isArray(input)) {
|
|
57
|
+
return input.map(convertUndefinedToNull);
|
|
58
|
+
}
|
|
59
|
+
const result = {};
|
|
60
|
+
for (const [key, value] of Object.entries(input)) {
|
|
61
|
+
result[key] = convertUndefinedToNull(value);
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
49
65
|
function validateToolInput(schema, input, toolId) {
|
|
50
66
|
if (!schema || !("safeParse" in schema)) {
|
|
51
67
|
return { data: input };
|
|
52
68
|
}
|
|
53
|
-
|
|
69
|
+
let normalizedInput = normalizeNullishInput(schema, input);
|
|
70
|
+
normalizedInput = convertUndefinedToNull(normalizedInput);
|
|
54
71
|
const validation = schema.safeParse(normalizedInput);
|
|
55
72
|
if (validation.success) {
|
|
56
73
|
return { data: validation.data };
|
|
@@ -272,5 +289,5 @@ exports.isVercelTool = isVercelTool;
|
|
|
272
289
|
exports.validateToolInput = validateToolInput;
|
|
273
290
|
exports.validateToolOutput = validateToolOutput;
|
|
274
291
|
exports.validateToolSuspendData = validateToolSuspendData;
|
|
275
|
-
//# sourceMappingURL=chunk-
|
|
276
|
-
//# sourceMappingURL=chunk-
|
|
292
|
+
//# sourceMappingURL=chunk-ABHX6L4P.cjs.map
|
|
293
|
+
//# sourceMappingURL=chunk-ABHX6L4P.cjs.map
|
|
@@ -0,0 +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,IAAA,MAAM,WAAA,GAAc,IAAA,CAAK,SAAA,CAAU,IAAA,EAAM,MAAM,CAAC,CAAA;AAChD,IAAA,IAAI,WAAA,CAAY,UAAU,SAAA,EAAW;AACnC,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,OAAO,WAAA,CAAY,KAAA,CAAM,CAAA,EAAG,SAAS,CAAA,GAAI,iBAAA;AAAA,EAC3C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,4BAAA;AAAA,EACT;AACF;AAUO,SAAS,uBAAA,CACd,MAAA,EACA,WAAA,EACA,MAAA,EACmD;AAEnD,EAAA,IAAI,CAAC,MAAA,IAAU,EAAE,WAAA,IAAe,MAAA,CAAA,EAAS;AACvC,IAAA,OAAO,EAAE,MAAM,WAAA,EAAY;AAAA,EAC7B;AAGA,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,SAAA,CAAU,WAAW,CAAA;AAE/C,EAAA,IAAI,WAAW,OAAA,EAAS;AACtB,IAAA,OAAO,EAAE,IAAA,EAAM,UAAA,CAAW,IAAA,EAAK;AAAA,EACjC;AAGA,EAAA,MAAM,aAAA,GAAgB,WAAW,KAAA,CAAM,MAAA,CACpC,IAAI,CAAC,CAAA,KAAkB,KAAK,CAAA,CAAE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eSchema } 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 * Recursively converts undefined values to null in an object.\n * This is needed for OpenAI compat layers which convert .optional() to .nullable()\n * for strict mode compliance. When fields are omitted (undefined), we convert them\n * to null so the schema validation passes, and the transform then converts null back\n * to undefined. (GitHub #11457)\n *\n * @param input The input to process\n * @returns The processed input with undefined values converted to null\n */\nfunction convertUndefinedToNull(input: unknown): unknown {\n if (input === undefined) {\n return null;\n }\n\n if (input === null || typeof input !== 'object') {\n return input;\n }\n\n if (Array.isArray(input)) {\n return input.map(convertUndefinedToNull);\n }\n\n // It's an object - recursively process all properties\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(input as Record<string, unknown>)) {\n result[key] = convertUndefinedToNull(value);\n }\n return result;\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 let normalizedInput = normalizeNullishInput(schema, input);\n\n // Convert undefined values to null recursively (GitHub #11457)\n // This is needed because OpenAI compat layers convert .optional() to .nullable()\n // for strict mode compliance. When fields are omitted (undefined), we convert them\n // to null so the schema validation passes. The schema's transform will then convert\n // null back to undefined to match the original .optional() semantics.\n normalizedInput = convertUndefinedToNull(normalizedInput);\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,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkMV7R7B6Z_cjs = require('./chunk-MV7R7B6Z.cjs');
|
|
4
|
+
var chunk3LVC2TGA_cjs = require('./chunk-3LVC2TGA.cjs');
|
|
5
|
+
var chunkS6HUG6SH_cjs = require('./chunk-S6HUG6SH.cjs');
|
|
6
6
|
var chunkXR7RX2PS_cjs = require('./chunk-XR7RX2PS.cjs');
|
|
7
7
|
var chunk6BJ7XHRH_cjs = require('./chunk-6BJ7XHRH.cjs');
|
|
8
8
|
var chunkMR7ZWBL6_cjs = require('./chunk-MR7ZWBL6.cjs');
|
|
@@ -286,7 +286,7 @@ var Mastra = class {
|
|
|
286
286
|
if (config?.pubsub) {
|
|
287
287
|
this.#pubsub = config.pubsub;
|
|
288
288
|
} else {
|
|
289
|
-
this.#pubsub = new
|
|
289
|
+
this.#pubsub = new chunkS6HUG6SH_cjs.EventEmitterPubSub();
|
|
290
290
|
}
|
|
291
291
|
this.#events = {};
|
|
292
292
|
for (const topic in config?.events ?? {}) {
|
|
@@ -296,7 +296,7 @@ var Mastra = class {
|
|
|
296
296
|
this.#events[topic] = config?.events?.[topic] ?? [];
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
const workflowEventProcessor = new
|
|
299
|
+
const workflowEventProcessor = new chunkMV7R7B6Z_cjs.WorkflowEventProcessor({ mastra: this });
|
|
300
300
|
const workflowEventCb = async (event, cb) => {
|
|
301
301
|
try {
|
|
302
302
|
await workflowEventProcessor.process(event, cb);
|
|
@@ -324,7 +324,7 @@ var Mastra = class {
|
|
|
324
324
|
this.#idGenerator = config?.idGenerator;
|
|
325
325
|
let storage = config?.storage;
|
|
326
326
|
if (storage) {
|
|
327
|
-
storage =
|
|
327
|
+
storage = chunkS6HUG6SH_cjs.augmentWithInit(storage);
|
|
328
328
|
}
|
|
329
329
|
if (config?.observability) {
|
|
330
330
|
if (typeof config.observability.getDefaultInstance === "function") {
|
|
@@ -638,7 +638,7 @@ var Mastra = class {
|
|
|
638
638
|
const agents = this.#resolveStoredAgents(storedAgent.agents);
|
|
639
639
|
const memory = this.#resolveStoredMemory(storedAgent.memory);
|
|
640
640
|
const scorers = this.#resolveStoredScorers(storedAgent.scorers);
|
|
641
|
-
const agent = new
|
|
641
|
+
const agent = new chunkS6HUG6SH_cjs.Agent({
|
|
642
642
|
id: storedAgent.id,
|
|
643
643
|
name: storedAgent.name,
|
|
644
644
|
description: storedAgent.description,
|
|
@@ -804,8 +804,8 @@ var Mastra = class {
|
|
|
804
804
|
throw createUndefinedPrimitiveError("agent", agent, key);
|
|
805
805
|
}
|
|
806
806
|
let mastraAgent;
|
|
807
|
-
if (
|
|
808
|
-
mastraAgent =
|
|
807
|
+
if (chunk3LVC2TGA_cjs.isToolLoopAgentLike(agent)) {
|
|
808
|
+
mastraAgent = chunk3LVC2TGA_cjs.toolLoopAgentToMastraAgent(agent, { fallbackName: key });
|
|
809
809
|
} else {
|
|
810
810
|
mastraAgent = agent;
|
|
811
811
|
}
|
|
@@ -1839,7 +1839,7 @@ var Mastra = class {
|
|
|
1839
1839
|
* ```
|
|
1840
1840
|
*/
|
|
1841
1841
|
setStorage(storage) {
|
|
1842
|
-
this.#storage =
|
|
1842
|
+
this.#storage = chunkS6HUG6SH_cjs.augmentWithInit(storage);
|
|
1843
1843
|
}
|
|
1844
1844
|
setLogger({ logger }) {
|
|
1845
1845
|
this.#logger = logger;
|
|
@@ -2501,7 +2501,7 @@ var Mastra = class {
|
|
|
2501
2501
|
if (process.env.MASTRA_DEV !== "true" && process.env.MASTRA_DEV !== "1") {
|
|
2502
2502
|
return;
|
|
2503
2503
|
}
|
|
2504
|
-
import('./provider-registry-
|
|
2504
|
+
import('./provider-registry-OZWLA7RR.cjs').then(async ({ GatewayRegistry }) => {
|
|
2505
2505
|
const registry = GatewayRegistry.getInstance();
|
|
2506
2506
|
const customGateways = Object.values(this.#gateways || {});
|
|
2507
2507
|
registry.registerCustomGateways(customGateways);
|
|
@@ -2555,5 +2555,5 @@ var Mastra = class {
|
|
|
2555
2555
|
};
|
|
2556
2556
|
|
|
2557
2557
|
exports.Mastra = Mastra;
|
|
2558
|
-
//# sourceMappingURL=chunk-
|
|
2559
|
-
//# sourceMappingURL=chunk-
|
|
2558
|
+
//# sourceMappingURL=chunk-DE4ZHUSC.cjs.map
|
|
2559
|
+
//# sourceMappingURL=chunk-DE4ZHUSC.cjs.map
|