-
Notifications
You must be signed in to change notification settings - Fork 3
fix!: resolve typecheck errors by upgrading to zod v4 and ai SDK 5.0.108 #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Upgrade zod from ^3.23.8 to ^4.1.13 for improved performance - Upgrade ai SDK from ^5.0.63 to ^5.0.108 for latest features - Upgrade @ai-sdk/openai from ^2.0.46 to ^2.0.80 - Upgrade @modelcontextprotocol/sdk from ^1.19.1 to ^1.24.3 - Add zod to examples devDependencies to ensure consistent type resolution across workspace packages This resolves TypeScript type errors where AISDKToolResult was not assignable to ToolSet due to different zod versions being resolved in root and examples packages.
- Import ToolSet from 'ai' package in types.ts - Update AISDKToolResult to extend ToolSet for full compatibility with generateText, streamText, and other AI SDK functions - Add 'ai' and '@ai-sdk/provider-utils' to tsdown dts.resolve to ensure AI SDK types are properly bundled in declarations This ensures AISDKToolResult is properly assignable to ToolSet when used with AI SDK functions like generateText().
- Replace 'zod' import with 'zod/mini' for smaller tree-shaken bundles - Use zod/mini wrapper functions instead of method chaining: - z.optional() instead of .optional() - z.nullable() instead of .nullish() - z.looseObject() instead of .passthrough() - Update z.record() calls to use two arguments (key, value) per zod v4 zod/mini provides a functional API that tree-shakes more effectively, resulting in smaller final bundles for consumers of this library.
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR upgrades the project's core dependencies to resolve TypeScript type errors, specifically upgrading to Zod v4 and AI SDK v5.0.108. The changes ensure better compatibility with the AI SDK's ToolSet type and leverage Zod v4's tree-shaking capabilities via the zod/mini import.
Key Changes:
- Upgraded zod from v3.23.8 to v4.1.13, ai SDK from v5.0.63 to v5.0.108, and MCP SDK from v1.19.1 to v1.24.3
- Modified
AISDKToolResulttype to extend AI SDK'sToolSettype for full compatibility with AI SDK functions - Migrated
rpc-client.tsvalidation schemas to usezod/miniwith wrapper function syntax for better tree-shaking
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tsdown.config.ts | Added 'ai' and '@ai-sdk/provider-utils' to dts.resolve for proper type bundling during build |
| src/types.ts | Modified AISDKToolResult to extend ToolSet from 'ai' package, ensuring compatibility with AI SDK v5 functions |
| src/rpc-client.ts | Migrated to zod/mini and updated all schema definitions to use zod v4 wrapper function syntax |
| pnpm-workspace.yaml | Updated catalog versions for @ai-sdk/openai, zod, ai, and @modelcontextprotocol/sdk dependencies |
| pnpm-lock.yaml | Lockfile updates reflecting all dependency version changes across the workspace |
| examples/package.json | Added explicit zod dev dependency to examples package for consistency |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }) | ||
| .passthrough(); | ||
| const rpcActionResponseSchema = z.looseObject({ | ||
| next: z.nullable(z.optional(z.string())), |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order of z.nullable(z.optional(...)) is semantically incorrect. In zod, the outer wrapper is applied first, meaning this accepts null | undefined, but when the value is undefined, it will be validated as optional (which is correct), but when it's null, it will try to validate null as optional which then validates null as a string (which will fail).
The correct pattern should be z.optional(z.nullable(z.string())) which means: the field can be undefined (optional), and when present, it can be null or a string.
| next: z.nullable(z.optional(z.string())), | |
| next: z.optional(z.nullable(z.string())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 6 files
Summary
AISDKToolResultwas not assignable toToolSetzod/minifor better tree-shakingChanges
Dependencies
Type Fixes
ToolSetfromaipackage and extend it inAISDKToolResultaiand@ai-sdk/provider-utilsto tsdown dts.resolve for proper type bundlingCode Changes
rpc-client.tsto usezod/miniwith wrapper function syntaxz.record()calls to use two arguments (key, value) per zod v4 APIBreaking Changes
AI SDK v4 is no longer supported - only AI SDK v5.x is supported.
Test Plan
pnpm run typecheckpassespnpm run testpasses (262 tests)pnpm run lintpassespnpm run buildsucceedsFixes #163
Fixes #160