Skip to content

Commit 6492f57

Browse files
authored
refactor(deps): move zod to peerDependencies with v4-mini (#278)
- Move zod from dependencies to peerDependencies (>=3.25.0 <5) - Use zod/v4-mini subpath for smaller bundle size in schema/headers - Use zod/v4 subpath in feedback.ts (requires .transform/.refine) - Add zod to devDependencies and examples for development/testing This allows users to bring their own zod version (3.25+ or 4.x) while ensuring compatibility with AI SDK's zod peer dependency. The v4-mini variant reduces bundle size for simple schemas.
1 parent 043d3b8 commit 6492f57

File tree

8 files changed

+27
-19
lines changed

8 files changed

+27
-19
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ The StackOne AI SDK provides the `StackOneToolSet` class, which fetches tools dy
1414

1515
```bash
1616
# Using npm
17-
npm install @stackone/ai
17+
npm install @stackone/ai zod
1818

1919
# Using yarn
20-
yarn add @stackone/ai
20+
yarn add @stackone/ai zod
2121

2222
# Using pnpm
23-
pnpm add @stackone/ai
23+
pnpm add @stackone/ai zod
2424

2525
# Using bun
26-
bun add @stackone/ai
26+
bun add @stackone/ai zod
2727
```
2828

29+
> **Note:** `zod` is a peer dependency required for AI SDK integrations and internal schema validation. Version `>=3.25.0 <5` is supported.
30+
2931
## Usage
3032

3133
```typescript

examples/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"@tanstack/ai": "catalog:examples",
1313
"@tanstack/ai-openai": "catalog:examples",
1414
"ai": "catalog:peer",
15-
"openai": "catalog:peer"
15+
"openai": "catalog:peer",
16+
"zod": "catalog:dev"
1617
},
1718
"devDependencies": {
1819
"@types/node": "catalog:dev",

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@
5353
"dependencies": {
5454
"@modelcontextprotocol/sdk": "catalog:prod",
5555
"@orama/orama": "catalog:prod",
56-
"defu": "catalog:prod",
57-
"zod": "catalog:prod"
56+
"defu": "catalog:prod"
5857
},
5958
"devDependencies": {
6059
"@fast-check/vitest": "catalog:dev",
@@ -76,12 +75,14 @@
7675
"type-fest": "catalog:dev",
7776
"typescript": "catalog:dev",
7877
"unplugin-unused": "catalog:dev",
79-
"vitest": "catalog:dev"
78+
"vitest": "catalog:dev",
79+
"zod": "catalog:dev"
8080
},
8181
"peerDependencies": {
8282
"@anthropic-ai/sdk": "catalog:peer",
8383
"ai": "catalog:peer",
84-
"openai": "catalog:peer"
84+
"openai": "catalog:peer",
85+
"zod": "catalog:peer"
8586
},
8687
"peerDependenciesMeta": {
8788
"@anthropic-ai/sdk": {

pnpm-lock.yaml

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ catalogs:
2727
typescript: ^5.8.3
2828
unplugin-unused: ^0.5.4
2929
vitest: ^4.0.15
30+
zod: ^4.1.13
3031
examples:
3132
'@anthropic-ai/claude-agent-sdk': ^0.1.67
3233
'@tanstack/ai': ^0.0.3
@@ -35,11 +36,11 @@ catalogs:
3536
'@anthropic-ai/sdk': ^0.52.0
3637
ai: '>=5.0.108 <7.0.0'
3738
openai: ^6.2.0
39+
zod: '>=3.25.0 <5'
3840
prod:
3941
'@modelcontextprotocol/sdk': ^1.24.3
4042
'@orama/orama': ^3.1.11
4143
defu: ^6.1.4
42-
zod: ^4.1.13
4344

4445
enablePrePostScripts: true
4546

src/feedback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { z } from 'zod';
1+
import { z } from 'zod/v4';
22
import { DEFAULT_BASE_URL } from './consts';
33
import { BaseTool } from './tool';
44
import type { ExecuteConfig, ExecuteOptions, JsonObject, JsonValue, ToolParameters } from './types';

src/headers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { z } from 'zod/mini';
1+
import { z } from 'zod/v4-mini';
22
import type { JsonObject } from './types';
33

44
/**

src/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { z } from 'zod/mini';
1+
import { z } from 'zod/v4-mini';
22
import { stackOneHeadersSchema } from './headers';
33

44
/**

0 commit comments

Comments
 (0)