@mastra/schema-compat 0.10.2 → 0.10.3-alpha.1

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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/schema-compat@0.10.2-alpha.3 build /home/runner/work/mastra/mastra/packages/schema-compat
2
+ > @mastra/schema-compat@0.10.3-alpha.1 build /home/runner/work/mastra/mastra/packages/schema-compat
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.5.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 2143ms
9
+ TSC ⚡️ Build success in 2208ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/packages/schema-compat/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/packages/schema-compat/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 1931ms
16
+ DTS ⚡️ Build success in 1941ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 21.03 KB
21
- ESM ⚡️ Build success in 162ms
22
- CJS dist/index.cjs 21.65 KB
23
- CJS ⚡️ Build success in 163ms
20
+ CJS dist/index.cjs 21.59 KB
21
+ CJS ⚡️ Build success in 164ms
22
+ ESM dist/index.js 20.96 KB
23
+ ESM ⚡️ Build success in 164ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mastra/schema-compat
2
2
 
3
+ ## 0.10.3-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - a853c43: Allow for object.passthrough in schema compat (aka MCP tool support).
8
+
9
+ ## 0.10.3-alpha.0
10
+
11
+ ### Patch Changes
12
+
13
+ - 98bbe5a: Claude cannot handle tuple schemas now.
14
+
3
15
  ## 0.10.2
4
16
 
5
17
  ### Patch Changes
@@ -339,7 +339,9 @@ declare abstract class SchemaCompatLayer {
339
339
  * @param value - The Zod object to process
340
340
  * @returns The processed Zod object
341
341
  */
342
- defaultZodObjectHandler(value: ZodObject<any, any, any>): ZodObject<any, any, any>;
342
+ defaultZodObjectHandler(value: ZodObject<any, any, any>, options?: {
343
+ passthrough?: boolean;
344
+ }): ZodObject<any, any, any>;
343
345
  /**
344
346
  * Merges validation constraints into a parameter description.
345
347
  *
@@ -339,7 +339,9 @@ declare abstract class SchemaCompatLayer {
339
339
  * @param value - The Zod object to process
340
340
  * @returns The processed Zod object
341
341
  */
342
- defaultZodObjectHandler(value: ZodObject<any, any, any>): ZodObject<any, any, any>;
342
+ defaultZodObjectHandler(value: ZodObject<any, any, any>, options?: {
343
+ passthrough?: boolean;
344
+ }): ZodObject<any, any, any>;
343
345
  /**
344
346
  * Merges validation constraints into a parameter description.
345
347
  *
package/dist/index.cjs CHANGED
@@ -115,7 +115,7 @@ var SchemaCompatLayer = class {
115
115
  * @param value - The Zod object to process
116
116
  * @returns The processed Zod object
117
117
  */
118
- defaultZodObjectHandler(value) {
118
+ defaultZodObjectHandler(value, options = { passthrough: true }) {
119
119
  const processedShape = Object.entries(value.shape).reduce((acc, [key, propValue]) => {
120
120
  acc[key] = this.processZodType(propValue);
121
121
  return acc;
@@ -130,6 +130,9 @@ var SchemaCompatLayer = class {
130
130
  if (value.description) {
131
131
  result = result.describe(value.description);
132
132
  }
133
+ if (options.passthrough && value._def.unknownKeys === "passthrough") {
134
+ result = result.passthrough();
135
+ }
133
136
  return result;
134
137
  }
135
138
  /**
@@ -425,9 +428,8 @@ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
425
428
  }
426
429
  processZodType(value) {
427
430
  if (isOptional(value)) {
428
- const handleTypes = ["ZodObject", "ZodArray", "ZodUnion", "ZodNever", "ZodUndefined"];
431
+ const handleTypes = ["ZodObject", "ZodArray", "ZodUnion", "ZodNever", "ZodUndefined", "ZodTuple"];
429
432
  if (this.getModel().modelId.includes("claude-3.5-haiku")) handleTypes.push("ZodString");
430
- if (this.getModel().modelId.includes("claude-3.7")) handleTypes.push("ZodTuple");
431
433
  return this.defaultZodOptionalHandler(value, handleTypes);
432
434
  } else if (isObj(value)) {
433
435
  return this.defaultZodObjectHandler(value);
@@ -442,11 +444,7 @@ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
442
444
  return value;
443
445
  }
444
446
  }
445
- if (this.getModel().modelId.includes("claude-3.7")) {
446
- return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodTuple", "ZodUndefined"]);
447
- } else {
448
- return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodUndefined"]);
449
- }
447
+ return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodTuple", "ZodUndefined"]);
450
448
  }
451
449
  };
452
450
 
@@ -605,7 +603,7 @@ var OpenAIReasoningSchemaCompatLayer = class extends SchemaCompatLayer {
605
603
  const innerZodType = this.processZodType(value._def.innerType);
606
604
  return innerZodType.nullable();
607
605
  } else if (isObj(value)) {
608
- return this.defaultZodObjectHandler(value);
606
+ return this.defaultZodObjectHandler(value, { passthrough: false });
609
607
  } else if (isArr(value)) {
610
608
  return this.defaultZodArrayHandler(value);
611
609
  } else if (isUnion(value)) {
package/dist/index.js CHANGED
@@ -113,7 +113,7 @@ var SchemaCompatLayer = class {
113
113
  * @param value - The Zod object to process
114
114
  * @returns The processed Zod object
115
115
  */
116
- defaultZodObjectHandler(value) {
116
+ defaultZodObjectHandler(value, options = { passthrough: true }) {
117
117
  const processedShape = Object.entries(value.shape).reduce((acc, [key, propValue]) => {
118
118
  acc[key] = this.processZodType(propValue);
119
119
  return acc;
@@ -128,6 +128,9 @@ var SchemaCompatLayer = class {
128
128
  if (value.description) {
129
129
  result = result.describe(value.description);
130
130
  }
131
+ if (options.passthrough && value._def.unknownKeys === "passthrough") {
132
+ result = result.passthrough();
133
+ }
131
134
  return result;
132
135
  }
133
136
  /**
@@ -423,9 +426,8 @@ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
423
426
  }
424
427
  processZodType(value) {
425
428
  if (isOptional(value)) {
426
- const handleTypes = ["ZodObject", "ZodArray", "ZodUnion", "ZodNever", "ZodUndefined"];
429
+ const handleTypes = ["ZodObject", "ZodArray", "ZodUnion", "ZodNever", "ZodUndefined", "ZodTuple"];
427
430
  if (this.getModel().modelId.includes("claude-3.5-haiku")) handleTypes.push("ZodString");
428
- if (this.getModel().modelId.includes("claude-3.7")) handleTypes.push("ZodTuple");
429
431
  return this.defaultZodOptionalHandler(value, handleTypes);
430
432
  } else if (isObj(value)) {
431
433
  return this.defaultZodObjectHandler(value);
@@ -440,11 +442,7 @@ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
440
442
  return value;
441
443
  }
442
444
  }
443
- if (this.getModel().modelId.includes("claude-3.7")) {
444
- return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodTuple", "ZodUndefined"]);
445
- } else {
446
- return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodUndefined"]);
447
- }
445
+ return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodTuple", "ZodUndefined"]);
448
446
  }
449
447
  };
450
448
 
@@ -603,7 +601,7 @@ var OpenAIReasoningSchemaCompatLayer = class extends SchemaCompatLayer {
603
601
  const innerZodType = this.processZodType(value._def.innerType);
604
602
  return innerZodType.nullable();
605
603
  } else if (isObj(value)) {
606
- return this.defaultZodObjectHandler(value);
604
+ return this.defaultZodObjectHandler(value, { passthrough: false });
607
605
  } else if (isArr(value)) {
608
606
  return this.defaultZodArrayHandler(value);
609
607
  } else if (isUnion(value)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/schema-compat",
3
- "version": "0.10.2",
3
+ "version": "0.10.3-alpha.1",
4
4
  "description": "Tool schema compatibility layer for Mastra.ai",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,24 +28,24 @@
28
28
  "author": "",
29
29
  "license": "Elastic-2.0",
30
30
  "dependencies": {
31
+ "json-schema": "^0.4.0",
31
32
  "zod-from-json-schema": "^0.0.5",
32
- "zod-to-json-schema": "^3.24.5",
33
- "json-schema": "^0.4.0"
33
+ "zod-to-json-schema": "^3.24.5"
34
34
  },
35
35
  "peerDependencies": {
36
- "zod": "^3.0.0",
37
- "ai": "^4.0.0"
36
+ "ai": "^4.0.0",
37
+ "zod": "^3.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@types/node": "^20.17.57",
41
40
  "@types/json-schema": "^7.0.15",
42
- "eslint": "^9.28.0",
43
- "tsup": "^8.5.0",
44
- "typescript": "^5.8.2",
45
- "vitest": "^3.2.2",
46
- "zod": "^3.25.56",
41
+ "@types/node": "^20.19.0",
47
42
  "ai": "4.3.16",
48
- "@internal/lint": "0.0.11"
43
+ "eslint": "^9.29.0",
44
+ "tsup": "^8.5.0",
45
+ "typescript": "^5.8.3",
46
+ "vitest": "^3.2.3",
47
+ "zod": "^3.25.67",
48
+ "@internal/lint": "0.0.13"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
@@ -19,9 +19,8 @@ export class AnthropicSchemaCompatLayer extends SchemaCompatLayer {
19
19
 
20
20
  processZodType(value: ZodTypeAny): ZodTypeAny {
21
21
  if (isOptional(value)) {
22
- const handleTypes: AllZodType[] = ['ZodObject', 'ZodArray', 'ZodUnion', 'ZodNever', 'ZodUndefined'];
22
+ const handleTypes: AllZodType[] = ['ZodObject', 'ZodArray', 'ZodUnion', 'ZodNever', 'ZodUndefined', 'ZodTuple'];
23
23
  if (this.getModel().modelId.includes('claude-3.5-haiku')) handleTypes.push('ZodString');
24
- if (this.getModel().modelId.includes('claude-3.7')) handleTypes.push('ZodTuple');
25
24
  return this.defaultZodOptionalHandler(value, handleTypes);
26
25
  } else if (isObj(value)) {
27
26
  return this.defaultZodObjectHandler(value);
@@ -40,10 +39,6 @@ export class AnthropicSchemaCompatLayer extends SchemaCompatLayer {
40
39
  }
41
40
  }
42
41
 
43
- if (this.getModel().modelId.includes('claude-3.7')) {
44
- return this.defaultUnsupportedZodTypeHandler(value, ['ZodNever', 'ZodTuple', 'ZodUndefined']);
45
- } else {
46
- return this.defaultUnsupportedZodTypeHandler(value, ['ZodNever', 'ZodUndefined']);
47
- }
42
+ return this.defaultUnsupportedZodTypeHandler(value, ['ZodNever', 'ZodTuple', 'ZodUndefined']);
48
43
  }
49
44
  }
@@ -45,7 +45,7 @@ export class OpenAIReasoningSchemaCompatLayer extends SchemaCompatLayer {
45
45
  const innerZodType = this.processZodType(value._def.innerType);
46
46
  return innerZodType.nullable();
47
47
  } else if (isObj(value)) {
48
- return this.defaultZodObjectHandler(value);
48
+ return this.defaultZodObjectHandler(value, { passthrough: false });
49
49
  } else if (isArr(value)) {
50
50
  return this.defaultZodArrayHandler(value);
51
51
  } else if (isUnion(value)) {
@@ -232,7 +232,10 @@ export abstract class SchemaCompatLayer {
232
232
  * @param value - The Zod object to process
233
233
  * @returns The processed Zod object
234
234
  */
235
- public defaultZodObjectHandler(value: ZodObject<any, any, any>): ZodObject<any, any, any> {
235
+ public defaultZodObjectHandler(
236
+ value: ZodObject<any, any, any>,
237
+ options: { passthrough?: boolean } = { passthrough: true },
238
+ ): ZodObject<any, any, any> {
236
239
  const processedShape = Object.entries(value.shape).reduce<Record<string, ZodTypeAny>>((acc, [key, propValue]) => {
237
240
  acc[key] = this.processZodType(propValue as ZodTypeAny);
238
241
  return acc;
@@ -250,6 +253,11 @@ export abstract class SchemaCompatLayer {
250
253
  if (value.description) {
251
254
  result = result.describe(value.description);
252
255
  }
256
+
257
+ if (options.passthrough && value._def.unknownKeys === 'passthrough') {
258
+ result = result.passthrough();
259
+ }
260
+
253
261
  return result;
254
262
  }
255
263