You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: use zod instead of zod/v4 for tool type compatibility (#130)
## Summary
- Fixes type incompatibility when users define tools with plain `zod`
imports
- The SDK was importing types from `zod/v4`, but users typically import
from `zod`, causing TypeScript errors due to internal type metadata
differences
## Changes
- Import `ZodType`, `ZodObject`, `ZodRawShape` from `zod` instead of
`zod/v4` in `tool-types.ts`, `tool.ts`, and `tool-executor.ts`
- Keep runtime imports (`toJSONSchema`, `ZodError`) from `zod/v4` as
they're only available there
- Use type assertion in `convertZodToJsonSchema` to bridge the type gap
between `zod` and `zod/v4`
- Update `toJSONSchema` target from `openapi-3.0` to `draft-7` (former
isn't supported in current Zod version)
- Update tests to use `draft-7` target
## Error Before Fix
```
No overload matches this call.
Type ZodObject<{ channel: ZodString; timestamp: ZodString; name: ZodString; }, strip> is not assignable to type ZodObject<Readonly<{ [k: string]: ZodType<unknown, unknown, ZodTypeInternals<unknown, unknown>>; }>, strip>.
The types of '_zod.version.minor' are incompatible between these types.
Type 1 is not assignable to type 0.
```
## Test plan
- [x] Build passes (`pnpm run build`)
- [x] All tests pass (`npx vitest --run`)
- [x] Verified tool definition works with plain `zod` imports
Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "@openrouter/sdk",
3
-
"version": "0.3.10",
3
+
"version": "0.3.11",
4
4
"author": "OpenRouter",
5
5
"description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 300+ language models through a unified API.",
0 commit comments