@mastra/schema-compat 0.10.3-alpha.1 → 0.10.4-alpha.0
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +13 -0
- package/dist/_tsup-dts-rollup.d.cts +3 -0
- package/dist/_tsup-dts-rollup.d.ts +3 -0
- package/dist/index.cjs +3 -2
- package/dist/index.js +4 -3
- package/package.json +3 -3
- package/src/provider-compats/google.ts +8 -0
- package/src/schema-compatibility.ts +2 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/schema-compat@0.10.
|
|
2
|
+
> @mastra/schema-compat@0.10.4-alpha.0 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
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 2187ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/schema-compat/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/schema-compat/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1840ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m21.14 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 111ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m21.76 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 138ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @mastra/schema-compat
|
|
2
2
|
|
|
3
|
+
## 0.10.4-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0c85311: Fix Google models ZodNull tool schema handling
|
|
8
|
+
|
|
9
|
+
## 0.10.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 98bbe5a: Claude cannot handle tuple schemas now.
|
|
14
|
+
- a853c43: Allow for object.passthrough in schema compat (aka MCP tool support).
|
|
15
|
+
|
|
3
16
|
## 0.10.3-alpha.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -6,6 +6,7 @@ import { z } from 'zod';
|
|
|
6
6
|
import { ZodArray } from 'zod';
|
|
7
7
|
import { ZodDate } from 'zod';
|
|
8
8
|
import { ZodDefault } from 'zod';
|
|
9
|
+
import { ZodNull } from 'zod';
|
|
9
10
|
import { ZodNumber } from 'zod';
|
|
10
11
|
import { ZodObject } from 'zod';
|
|
11
12
|
import { ZodOptional } from 'zod';
|
|
@@ -195,6 +196,8 @@ export declare const isDate: (v: ZodTypeAny) => v is ZodDate;
|
|
|
195
196
|
|
|
196
197
|
export declare const isDefault: (v: ZodTypeAny) => v is ZodDefault<any>;
|
|
197
198
|
|
|
199
|
+
export declare const isNull: (v: ZodTypeAny) => v is ZodNull;
|
|
200
|
+
|
|
198
201
|
declare const isNumber: (v: ZodTypeAny) => v is ZodNumber;
|
|
199
202
|
export { isNumber }
|
|
200
203
|
export { isNumber as isNumber_alias_1 }
|
|
@@ -6,6 +6,7 @@ import { z } from 'zod';
|
|
|
6
6
|
import { ZodArray } from 'zod';
|
|
7
7
|
import { ZodDate } from 'zod';
|
|
8
8
|
import { ZodDefault } from 'zod';
|
|
9
|
+
import { ZodNull } from 'zod';
|
|
9
10
|
import { ZodNumber } from 'zod';
|
|
10
11
|
import { ZodObject } from 'zod';
|
|
11
12
|
import { ZodOptional } from 'zod';
|
|
@@ -195,6 +196,8 @@ export declare const isDate: (v: ZodTypeAny) => v is ZodDate;
|
|
|
195
196
|
|
|
196
197
|
export declare const isDefault: (v: ZodTypeAny) => v is ZodDefault<any>;
|
|
197
198
|
|
|
199
|
+
export declare const isNull: (v: ZodTypeAny) => v is ZodNull;
|
|
200
|
+
|
|
198
201
|
declare const isNumber: (v: ZodTypeAny) => v is ZodNumber;
|
|
199
202
|
export { isNumber }
|
|
200
203
|
export { isNumber as isNumber_alias_1 }
|
package/dist/index.cjs
CHANGED
|
@@ -73,6 +73,7 @@ var ALL_NUMBER_CHECKS = [
|
|
|
73
73
|
var ALL_ARRAY_CHECKS = ["min", "max", "length"];
|
|
74
74
|
var isOptional = (v) => v instanceof zod.ZodOptional;
|
|
75
75
|
var isObj = (v) => v instanceof zod.ZodObject;
|
|
76
|
+
var isNull = (v) => v instanceof zod.ZodNull;
|
|
76
77
|
var isArr = (v) => v instanceof zod.ZodArray;
|
|
77
78
|
var isUnion = (v) => v instanceof zod.ZodUnion;
|
|
78
79
|
var isString = (v) => v instanceof zod.ZodString;
|
|
@@ -474,8 +475,6 @@ var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
474
475
|
return value;
|
|
475
476
|
}
|
|
476
477
|
};
|
|
477
|
-
|
|
478
|
-
// src/provider-compats/google.ts
|
|
479
478
|
var GoogleSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
480
479
|
constructor(model) {
|
|
481
480
|
super(model);
|
|
@@ -496,6 +495,8 @@ var GoogleSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
496
495
|
"ZodNumber",
|
|
497
496
|
...UNSUPPORTED_ZOD_TYPES
|
|
498
497
|
]);
|
|
498
|
+
} else if (isNull(value)) {
|
|
499
|
+
return zod.z.any().refine((v) => v === null, { message: "must be null" }).describe(value._def.description || "must be null");
|
|
499
500
|
} else if (isObj(value)) {
|
|
500
501
|
return this.defaultZodObjectHandler(value);
|
|
501
502
|
} else if (isArr(value)) {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, z, ZodDefault, ZodDate } from 'zod';
|
|
1
|
+
import { ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, z, ZodNull, ZodDefault, ZodDate } from 'zod';
|
|
2
2
|
import { jsonSchema } from 'ai';
|
|
3
3
|
import { convertJsonSchemaToZod } from 'zod-from-json-schema';
|
|
4
4
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
@@ -71,6 +71,7 @@ var ALL_NUMBER_CHECKS = [
|
|
|
71
71
|
var ALL_ARRAY_CHECKS = ["min", "max", "length"];
|
|
72
72
|
var isOptional = (v) => v instanceof ZodOptional;
|
|
73
73
|
var isObj = (v) => v instanceof ZodObject;
|
|
74
|
+
var isNull = (v) => v instanceof ZodNull;
|
|
74
75
|
var isArr = (v) => v instanceof ZodArray;
|
|
75
76
|
var isUnion = (v) => v instanceof ZodUnion;
|
|
76
77
|
var isString = (v) => v instanceof ZodString;
|
|
@@ -472,8 +473,6 @@ var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
472
473
|
return value;
|
|
473
474
|
}
|
|
474
475
|
};
|
|
475
|
-
|
|
476
|
-
// src/provider-compats/google.ts
|
|
477
476
|
var GoogleSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
478
477
|
constructor(model) {
|
|
479
478
|
super(model);
|
|
@@ -494,6 +493,8 @@ var GoogleSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
494
493
|
"ZodNumber",
|
|
495
494
|
...UNSUPPORTED_ZOD_TYPES
|
|
496
495
|
]);
|
|
496
|
+
} else if (isNull(value)) {
|
|
497
|
+
return z.any().refine((v) => v === null, { message: "must be null" }).describe(value._def.description || "must be null");
|
|
497
498
|
} else if (isObj(value)) {
|
|
498
499
|
return this.defaultZodObjectHandler(value);
|
|
499
500
|
} else if (isArr(value)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/schema-compat",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4-alpha.0",
|
|
4
4
|
"description": "Tool schema compatibility layer for Mastra.ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"eslint": "^9.29.0",
|
|
44
44
|
"tsup": "^8.5.0",
|
|
45
45
|
"typescript": "^5.8.3",
|
|
46
|
-
"vitest": "^3.2.
|
|
46
|
+
"vitest": "^3.2.4",
|
|
47
47
|
"zod": "^3.25.67",
|
|
48
|
-
"@internal/lint": "0.0.
|
|
48
|
+
"@internal/lint": "0.0.17"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { LanguageModelV1 } from 'ai';
|
|
2
2
|
import type { ZodTypeAny } from 'zod';
|
|
3
|
+
import { z } from 'zod';
|
|
3
4
|
import type { Targets } from 'zod-to-json-schema';
|
|
4
5
|
import {
|
|
5
6
|
SchemaCompatLayer,
|
|
6
7
|
UNSUPPORTED_ZOD_TYPES,
|
|
7
8
|
isArr,
|
|
9
|
+
isNull,
|
|
8
10
|
isNumber,
|
|
9
11
|
isObj,
|
|
10
12
|
isOptional,
|
|
@@ -35,6 +37,12 @@ export class GoogleSchemaCompatLayer extends SchemaCompatLayer {
|
|
|
35
37
|
'ZodNumber',
|
|
36
38
|
...UNSUPPORTED_ZOD_TYPES,
|
|
37
39
|
]);
|
|
40
|
+
} else if (isNull(value)) {
|
|
41
|
+
// Google models don't support null, so we need to convert it to any and then refine it to null
|
|
42
|
+
return z
|
|
43
|
+
.any()
|
|
44
|
+
.refine(v => v === null, { message: 'must be null' })
|
|
45
|
+
.describe(value._def.description || 'must be null');
|
|
38
46
|
} else if (isObj(value)) {
|
|
39
47
|
return this.defaultZodObjectHandler(value);
|
|
40
48
|
} else if (isArr(value)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Schema, LanguageModelV1 } from 'ai';
|
|
2
2
|
import type { JSONSchema7 } from 'json-schema';
|
|
3
|
-
import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodDate, ZodDefault } from 'zod';
|
|
3
|
+
import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodDate, ZodDefault, ZodNull } from 'zod';
|
|
4
4
|
import type { ZodTypeAny } from 'zod';
|
|
5
5
|
import type { Targets } from 'zod-to-json-schema';
|
|
6
6
|
import { convertZodSchemaToAISDKSchema } from './utils';
|
|
@@ -29,6 +29,7 @@ export const ALL_ARRAY_CHECKS = ['min', 'max', 'length'] as const;
|
|
|
29
29
|
|
|
30
30
|
export const isOptional = (v: ZodTypeAny): v is ZodOptional<any> => v instanceof ZodOptional;
|
|
31
31
|
export const isObj = (v: ZodTypeAny): v is ZodObject<any, any, any> => v instanceof ZodObject;
|
|
32
|
+
export const isNull = (v: ZodTypeAny): v is ZodNull => v instanceof ZodNull;
|
|
32
33
|
export const isArr = (v: ZodTypeAny): v is ZodArray<any, any> => v instanceof ZodArray;
|
|
33
34
|
export const isUnion = (v: ZodTypeAny): v is ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]> => v instanceof ZodUnion;
|
|
34
35
|
export const isString = (v: ZodTypeAny): v is ZodString => v instanceof ZodString;
|