@mastra/schema-compat 0.0.0-refactor-agent-information-for-recomposable-ui-20251112151814 → 0.0.0-safe-stringify-telemetry-20251205024938

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 CHANGED
@@ -1,40 +1,124 @@
1
1
  # @mastra/schema-compat
2
2
 
3
- ## 0.0.0-refactor-agent-information-for-recomposable-ui-20251112151814
3
+ ## 0.0.0-safe-stringify-telemetry-20251205024938
4
4
 
5
- ### Major Changes
5
+ ### Patch Changes
6
6
 
7
- - Bump minimum required Node.js version to 22.13.0 ([#9706](https://github.com/mastra-ai/mastra/pull/9706))
7
+ - Fix discriminatedUnion schema information lost when json schema is converted to zod ([#10764](https://github.com/mastra-ai/mastra/pull/10764))
8
8
 
9
- - Mark as stable ([`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc))
9
+ ## 0.11.8
10
10
 
11
11
  ### Patch Changes
12
12
 
13
- - Fix Zod v4 toJSONSchema bug with z.record() single-argument form ([#9265](https://github.com/mastra-ai/mastra/pull/9265))
13
+ - Fixed OpenAI schema compatibility when using `agent.generate()` or `agent.stream()` with `structuredOutput`. ([#10454](https://github.com/mastra-ai/mastra/pull/10454))
14
14
 
15
- Zod v4 has a bug in the single-argument form of `z.record(valueSchema)` where it incorrectly assigns the value schema to `keyType` instead of `valueType`, leaving `valueType` undefined. This causes `toJSONSchema()` to throw "Cannot read properties of undefined (reading '\_zod')" when processing schemas containing `z.record()` fields.
15
+ ## Changes
16
+ - **Automatic transformation**: Zod schemas are now automatically transformed for OpenAI strict mode compatibility when using OpenAI models (including reasoning models like o1, o3, o4)
17
+ - **Optional field handling**: `.optional()` fields are converted to `.nullable()` with a transform that converts `null` → `undefined`, preserving optional semantics while satisfying OpenAI's strict mode requirements
18
+ - **Preserves nullable fields**: Intentionally `.nullable()` fields remain unchanged
19
+ - **Deep transformation**: Handles `.optional()` fields at any nesting level (objects, arrays, unions, etc.)
20
+ - **JSON Schema objects**: Not transformed, only Zod schemas
16
21
 
17
- This fix patches affected schemas before conversion by detecting records with missing `valueType` and correctly assigning the schema to `valueType` while setting `keyType` to `z.string()` (the default). The patch recursively handles nested schemas including those wrapped in `.optional()`, `.nullable()`, arrays, unions, and objects.
22
+ ## Example
23
+
24
+ ```typescript
25
+ const agent = new Agent({
26
+ name: 'data-extractor',
27
+ model: { provider: 'openai', modelId: 'gpt-4o' },
28
+ instructions: 'Extract user information',
29
+ });
30
+
31
+ const schema = z.object({
32
+ name: z.string(),
33
+ age: z.number().optional(),
34
+ deletedAt: z.date().nullable(),
35
+ });
36
+
37
+ // Schema is automatically transformed for OpenAI compatibility
38
+ const result = await agent.generate('Extract: John, deleted yesterday', {
39
+ structuredOutput: { schema },
40
+ });
41
+
42
+ // Result: { name: 'John', age: undefined, deletedAt: null }
43
+ ```
44
+
45
+ ## 0.11.8-alpha.0
46
+
47
+ ### Patch Changes
48
+
49
+ - Fixed OpenAI schema compatibility when using `agent.generate()` or `agent.stream()` with `structuredOutput`. ([#10454](https://github.com/mastra-ai/mastra/pull/10454))
50
+
51
+ ## Changes
52
+ - **Automatic transformation**: Zod schemas are now automatically transformed for OpenAI strict mode compatibility when using OpenAI models (including reasoning models like o1, o3, o4)
53
+ - **Optional field handling**: `.optional()` fields are converted to `.nullable()` with a transform that converts `null` → `undefined`, preserving optional semantics while satisfying OpenAI's strict mode requirements
54
+ - **Preserves nullable fields**: Intentionally `.nullable()` fields remain unchanged
55
+ - **Deep transformation**: Handles `.optional()` fields at any nesting level (objects, arrays, unions, etc.)
56
+ - **JSON Schema objects**: Not transformed, only Zod schemas
57
+
58
+ ## Example
59
+
60
+ ```typescript
61
+ const agent = new Agent({
62
+ name: 'data-extractor',
63
+ model: { provider: 'openai', modelId: 'gpt-4o' },
64
+ instructions: 'Extract user information',
65
+ });
66
+
67
+ const schema = z.object({
68
+ name: z.string(),
69
+ age: z.number().optional(),
70
+ deletedAt: z.date().nullable(),
71
+ });
72
+
73
+ // Schema is automatically transformed for OpenAI compatibility
74
+ const result = await agent.generate('Extract: John, deleted yesterday', {
75
+ structuredOutput: { schema },
76
+ });
77
+
78
+ // Result: { name: 'John', age: undefined, deletedAt: null }
79
+ ```
18
80
 
19
- - Improved reliability of string field types in tool schema compatibility ([#9266](https://github.com/mastra-ai/mastra/pull/9266))
81
+ ## 0.11.7
20
82
 
21
- ## 1.0.0-beta.0
83
+ ### Patch Changes
84
+
85
+ - update peerdeps ([`5ca1cca`](https://github.com/mastra-ai/mastra/commit/5ca1ccac61ffa7141e6d9fa8f22d3ad4d03bf5dc))
22
86
 
23
- ### Major Changes
87
+ ## 0.11.7-alpha.0
24
88
 
25
- - Bump minimum required Node.js version to 22.13.0 ([#9706](https://github.com/mastra-ai/mastra/pull/9706))
89
+ ### Patch Changes
26
90
 
27
- - Mark as stable ([`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc))
91
+ - update peerdeps ([`5ca1cca`](https://github.com/mastra-ai/mastra/commit/5ca1ccac61ffa7141e6d9fa8f22d3ad4d03bf5dc))
92
+
93
+ ## 0.11.6
28
94
 
29
95
  ### Patch Changes
30
96
 
31
- - Fix Zod v4 toJSONSchema bug with z.record() single-argument form ([#9265](https://github.com/mastra-ai/mastra/pull/9265))
97
+ - Fix Zod v4 toJSONSchema bug with z.record() single-argument form ([#9355](https://github.com/mastra-ai/mastra/pull/9355))
32
98
 
33
99
  Zod v4 has a bug in the single-argument form of `z.record(valueSchema)` where it incorrectly assigns the value schema to `keyType` instead of `valueType`, leaving `valueType` undefined. This causes `toJSONSchema()` to throw "Cannot read properties of undefined (reading '\_zod')" when processing schemas containing `z.record()` fields.
34
100
 
35
101
  This fix patches affected schemas before conversion by detecting records with missing `valueType` and correctly assigning the schema to `valueType` while setting `keyType` to `z.string()` (the default). The patch recursively handles nested schemas including those wrapped in `.optional()`, `.nullable()`, arrays, unions, and objects.
36
102
 
37
- - Improved reliability of string field types in tool schema compatibility ([#9266](https://github.com/mastra-ai/mastra/pull/9266))
103
+ - Improved reliability of string field types in tool schema compatibility ([#9362](https://github.com/mastra-ai/mastra/pull/9362))
104
+
105
+ ## 0.11.6-alpha.0
106
+
107
+ ### Patch Changes
108
+
109
+ - Fix Zod v4 toJSONSchema bug with z.record() single-argument form ([#9355](https://github.com/mastra-ai/mastra/pull/9355))
110
+
111
+ Zod v4 has a bug in the single-argument form of `z.record(valueSchema)` where it incorrectly assigns the value schema to `keyType` instead of `valueType`, leaving `valueType` undefined. This causes `toJSONSchema()` to throw "Cannot read properties of undefined (reading '\_zod')" when processing schemas containing `z.record()` fields.
112
+
113
+ This fix patches affected schemas before conversion by detecting records with missing `valueType` and correctly assigning the schema to `valueType` while setting `keyType` to `z.string()` (the default). The patch recursively handles nested schemas including those wrapped in `.optional()`, `.nullable()`, arrays, unions, and objects.
114
+
115
+ - Improved reliability of string field types in tool schema compatibility ([#9362](https://github.com/mastra-ai/mastra/pull/9362))
116
+
117
+ ## 0.11.5
118
+
119
+ ### Patch Changes
120
+
121
+ - Fix peerdependencies ([`eb7c1c8`](https://github.com/mastra-ai/mastra/commit/eb7c1c8c592d8fb16dfd250e337d9cdc73c8d5de))
38
122
 
39
123
  ## 0.11.4
40
124