@mastra/agent-builder 1.0.0-beta.7 → 1.0.0-beta.8

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,5 +1,37 @@
1
1
  # @mastra/agent-builder
2
2
 
3
+ ## 1.0.0-beta.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed inline type narrowing for `tool.execute()` return type when using `outputSchema`. ([#11420](https://github.com/mastra-ai/mastra/pull/11420))
8
+
9
+ **Problem:** When calling `tool.execute()`, TypeScript couldn't narrow the `ValidationError | OutputType` union after checking `'error' in result && result.error`, causing type errors when accessing output properties.
10
+
11
+ **Solution:**
12
+ - Added `{ error?: never }` to the success type, enabling proper discriminated union narrowing
13
+ - Simplified `createTool` generics so `inputData` is correctly typed based on `inputSchema`
14
+
15
+ **Note:** Tool output schemas should not use `error` as a field name since it's reserved for ValidationError discrimination. Use `errorMessage` or similar instead.
16
+
17
+ **Usage:**
18
+
19
+ ```typescript
20
+ const result = await myTool.execute({ firstName: 'Hans' });
21
+
22
+ if ('error' in result && result.error) {
23
+ console.error('Validation failed:', result.message);
24
+ return;
25
+ }
26
+
27
+ // ✅ TypeScript now correctly narrows result
28
+ return { fullName: result.fullName };
29
+ ```
30
+
31
+ - Updated dependencies [[`3d93a15`](https://github.com/mastra-ai/mastra/commit/3d93a15796b158c617461c8b98bede476ebb43e2), [`efe406a`](https://github.com/mastra-ai/mastra/commit/efe406a1353c24993280ebc2ed61dd9f65b84b26), [`119e5c6`](https://github.com/mastra-ai/mastra/commit/119e5c65008f3e5cfca954eefc2eb85e3bf40da4), [`74e504a`](https://github.com/mastra-ai/mastra/commit/74e504a3b584eafd2f198001c6a113bbec589fd3), [`e33fdbd`](https://github.com/mastra-ai/mastra/commit/e33fdbd07b33920d81e823122331b0c0bee0bb59), [`929f69c`](https://github.com/mastra-ai/mastra/commit/929f69c3436fa20dd0f0e2f7ebe8270bd82a1529), [`8a73529`](https://github.com/mastra-ai/mastra/commit/8a73529ca01187f604b1f3019d0a725ac63ae55f)]:
32
+ - @mastra/core@1.0.0-beta.16
33
+ - @mastra/memory@1.0.0-beta.8
34
+
3
35
  ## 1.0.0-beta.7
4
36
 
5
37
  ### Patch Changes