Zod dependency configuration does not follow official best practices for library authors
Summary
The current Zod usage in AG-UI TypeScript SDK does not follow the official Zod best practices for library authors. This may cause version conflicts for users and lacks Zod 4 compatibility.
Current State
1. Dependency Configuration Issues
Zod is currently in dependencies instead of peerDependencies:
| Package |
Current Config |
Issue |
@ag-ui/core |
dependencies: "zod": "^3.22.4" |
❌ Should be peerDependencies |
@ag-ui/client |
dependencies: "zod": "^3.22.4" |
❌ Should be peerDependencies |
@ag-ui/vercel-ai-sdk |
dependencies: "zod": "^3.22.4" |
❌ Should be peerDependencies |
According to official docs:
Any library built on top of Zod should include "zod" in "peerDependencies". This lets your users "bring their own Zod".
2. Outdated Version Range
Current version ^3.22.4 is outdated and doesn't support Zod 4.
Recommended version range:
{
"peerDependencies": {
"zod": "^3.25.0 || ^4.0.0"
}
}
3. Import Path Not Using Permalinks
All files currently import Zod like this:
import { z } from "zod"; // ❌ Not recommended
Official recommendation:
Import from these subpaths only. Think of them like "permalinks" to their respective Zod versions.
"zod/v3" for Zod 3 ✅
"zod/v4/core" for the Zod 4 Core package ✅
import * as z3 from "zod/v3"; // ✅ Recommended
References
Zod dependency configuration does not follow official best practices for library authors
Summary
The current Zod usage in AG-UI TypeScript SDK does not follow the official Zod best practices for library authors. This may cause version conflicts for users and lacks Zod 4 compatibility.
Current State
1. Dependency Configuration Issues
Zod is currently in
dependenciesinstead ofpeerDependencies:@ag-ui/coredependencies: "zod": "^3.22.4"peerDependencies@ag-ui/clientdependencies: "zod": "^3.22.4"peerDependencies@ag-ui/vercel-ai-sdkdependencies: "zod": "^3.22.4"peerDependenciesAccording to official docs:
2. Outdated Version Range
Current version
^3.22.4is outdated and doesn't support Zod 4.Recommended version range:
{ "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" } }3. Import Path Not Using Permalinks
All files currently import Zod like this:
Official recommendation:
References