Skip to content

Conversation

@ryoppippi
Copy link
Member

@ryoppippi ryoppippi commented Dec 9, 2025

Summary

  • Upgrade dependencies to latest versions (zod v4, ai SDK 5.0.108, MCP SDK 1.24.3)
  • Fix TypeScript type errors where AISDKToolResult was not assignable to ToolSet
  • Migrate internal validation to zod/mini for better tree-shaking

Changes

Dependencies

  • zod: ^3.23.8 → ^4.1.13
  • ai: ^5.0.63 → ^5.0.108
  • @ai-sdk/openai: ^2.0.46 → ^2.0.80
  • @modelcontextprotocol/sdk: ^1.19.1 → ^1.24.3

Type Fixes

  • Import ToolSet from ai package and extend it in AISDKToolResult
  • Add ai and @ai-sdk/provider-utils to tsdown dts.resolve for proper type bundling

Code Changes

  • Migrate rpc-client.ts to use zod/mini with wrapper function syntax
  • Update z.record() calls to use two arguments (key, value) per zod v4 API

Breaking Changes

AI SDK v4 is no longer supported - only AI SDK v5.x is supported.

Test Plan

  • pnpm run typecheck passes
  • pnpm run test passes (262 tests)
  • pnpm run lint passes
  • pnpm run build succeeds

Fixes #163
Fixes #160

- 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.
Copilot AI review requested due to automatic review settings December 9, 2025 14:14
@ryoppippi ryoppippi requested a review from a team as a code owner December 9, 2025 14:14
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 9, 2025

Open in StackBlitz

npm i https://pkg.pr.new/StackOneHQ/stackone-ai-node/@stackone/ai@183

commit: 67565c6

@ryoppippi ryoppippi changed the title fix(types): resolve typecheck errors by upgrading to zod v4 and ai SDK 5.0.108 fix!: resolve typecheck errors by upgrading to zod v4 and ai SDK 5.0.108 Dec 9, 2025
Copy link

Copilot AI left a 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 AISDKToolResult type to extend AI SDK's ToolSet type for full compatibility with AI SDK functions
  • Migrated rpc-client.ts validation schemas to use zod/mini with 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())),
Copy link

Copilot AI Dec 9, 2025

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.

Suggested change
next: z.nullable(z.optional(z.string())),
next: z.optional(z.nullable(z.string())),

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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

@ryoppippi ryoppippi merged commit a2a4aaa into main Dec 9, 2025
7 checks passed
@ryoppippi ryoppippi deleted the fix/typecheck-zod-v4-ai-sdk branch December 9, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update mcp and zod packages deprecate vercel ai v4

3 participants