@composio/mastra 0.10.9-canary.4 → 0.11.0-canary.6

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.
Files changed (2) hide show
  1. package/dist/index.mjs +36 -13
  2. package/package.json +6 -5
package/dist/index.mjs CHANGED
@@ -1,4 +1,6 @@
1
- import { BaseAgenticProvider, dereferenceJsonSchema, logger, normalizeToolArguments, omitNullToolArguments, telemetry, toStrictJsonSchema } from "@composio/core";
1
+ import { prepareJsonSchemaObjectPolicy } from "@composio/json-schema-to-zod/schema-policy";
2
+ import { jsonSchemaToZod } from "@composio/json-schema-to-zod";
3
+ import { BaseAgenticProvider, deduplicateJsonSchemaRequiredArrays, dereferenceJsonSchema, logger, normalizeToolArguments, omitNullToolArguments, telemetry, toStrictJsonSchema } from "@composio/core";
2
4
  import { applyCompatLayer } from "@mastra/schema-compat";
3
5
  import { createTool } from "@mastra/core/tools";
4
6
 
@@ -94,6 +96,25 @@ function relaxOutputSchema(schema) {
94
96
  * @packageDocumentation
95
97
  * @module providers/mastra
96
98
  */
99
+ /** Use Mastra's public Standard Schema boundary to retain the complete declaration. */
100
+ const inputContract = (schema) => {
101
+ const validator = jsonSchemaToZod(schema);
102
+ return { "~standard": {
103
+ version: 1,
104
+ vendor: "composio",
105
+ validate: (value) => {
106
+ const result = validator.safeParse(value);
107
+ return result.success ? { value: result.data } : { issues: result.error.issues.map(({ message, path }) => ({
108
+ message,
109
+ path
110
+ })) };
111
+ },
112
+ jsonSchema: {
113
+ input: () => structuredClone(schema),
114
+ output: () => structuredClone(schema)
115
+ }
116
+ } };
117
+ };
97
118
  var MastraProvider = class extends BaseAgenticProvider {
98
119
  name = "mastra";
99
120
  strict;
@@ -138,11 +159,11 @@ var MastraProvider = class extends BaseAgenticProvider {
138
159
  }, {});
139
160
  }
140
161
  wrapTool(tool, executeTool) {
141
- const inputParams = tool.inputParameters;
162
+ const inputParams = tool.inputParameters ? prepareJsonSchemaObjectPolicy(tool.inputParameters) : void 0;
142
163
  let parameters = inputParams;
143
164
  let strictSource;
144
165
  if (this.strict && inputParams) {
145
- const strict = toStrictJsonSchema(inputParams);
166
+ const strict = toStrictJsonSchema(tool.inputParameters);
146
167
  if (strict.unsupported.length > 0) {
147
168
  const reasons = strict.unsupported.map((entry) => `${entry.path || "<root>"}: ${entry.keyword} (${entry.detail})`).join("; ");
148
169
  logger.warn(`[composio/mastra] Tool ${JSON.stringify(tool.slug)} keeps its non-strict schema because it cannot be expressed as strict structured outputs: ${reasons}`);
@@ -152,14 +173,9 @@ var MastraProvider = class extends BaseAgenticProvider {
152
173
  }
153
174
  }
154
175
  const onReplace = (ref, reason) => this.warnDanglingRefOnce(tool, ref, reason);
155
- const inputSchema = applyCompatLayer({
156
- schema: dereferenceJsonSchema(parameters ?? {}, {
157
- onUnresolved: "sentinel",
158
- onReplace
159
- }),
160
- compatLayers: [],
161
- mode: "jsonSchema"
162
- });
176
+ const declaration = deduplicateJsonSchemaRequiredArrays(parameters ?? {});
177
+ const inputSchema = inputContract(declaration);
178
+ const sourceValidator = jsonSchemaToZod(inputParams ?? {});
163
179
  const outputSchema = applyCompatLayer({
164
180
  schema: relaxOutputSchema(dereferenceJsonSchema(tool.outputParameters ?? {}, {
165
181
  onUnresolved: "sentinel",
@@ -168,16 +184,23 @@ var MastraProvider = class extends BaseAgenticProvider {
168
184
  compatLayers: [],
169
185
  mode: "jsonSchema"
170
186
  });
171
- return createTool({
187
+ const mastraTool = createTool({
172
188
  id: tool.slug,
173
189
  description: tool.description ?? "",
174
190
  inputSchema,
175
191
  outputSchema,
176
192
  execute: async (inputData, _context) => {
177
193
  const normalized = normalizeToolArguments(inputData, tool.slug);
178
- return await executeTool(tool.slug, strictSource ? omitNullToolArguments(normalized, strictSource) : normalized);
194
+ return await executeTool(tool.slug, await sourceValidator.parseAsync(strictSource ? omitNullToolArguments(normalized, strictSource) : normalized));
179
195
  }
180
196
  });
197
+ const invoke = mastraTool.execute;
198
+ mastraTool.execute = async (input, context) => {
199
+ const normalized = normalizeToolArguments(input, tool.slug);
200
+ await sourceValidator.parseAsync(strictSource ? omitNullToolArguments(normalized, strictSource) : normalized);
201
+ return invoke(input, context);
202
+ };
203
+ return mastraTool;
181
204
  }
182
205
  wrapTools(tools, executeTool) {
183
206
  return tools.reduce((acc, tool) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composio/mastra",
3
- "version": "0.10.9-canary.4",
3
+ "version": "0.11.0-canary.6",
4
4
  "description": "Agentic Provider for mastra in Composio SDK",
5
5
  "main": "dist/index.mjs",
6
6
  "type": "module",
@@ -37,9 +37,9 @@
37
37
  "author": "",
38
38
  "license": "ISC",
39
39
  "peerDependencies": {
40
- "@composio/core": "0.33.1-canary.4",
41
40
  "@mastra/core": "^1.46.0",
42
- "zod": "^3.25 || ^4"
41
+ "zod": ">=4.1.13 <5",
42
+ "@composio/core": "^1.0.0-canary.6"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@mastra/core": "1.53.0",
@@ -48,10 +48,11 @@
48
48
  "typescript": "^7.0.2",
49
49
  "vitest": "^5.1.0",
50
50
  "zod": "^4.6.7",
51
- "@composio/core": "0.33.1-canary.4"
51
+ "@composio/core": "1.0.0-canary.6"
52
52
  },
53
53
  "dependencies": {
54
- "@mastra/schema-compat": "^1.4.1"
54
+ "@mastra/schema-compat": "^1.4.1",
55
+ "@composio/json-schema-to-zod": "1.0.0-canary.6"
55
56
  },
56
57
  "scripts": {
57
58
  "clean": "git clean -xdf node_modules",