Skip to content

feat: support AI SDK v7 (ai@7) as a peer dependency#691

Merged
bensabic merged 2 commits into
vercel:mainfrom
chentsulin:feat/ai-sdk-v7-peer
Jul 13, 2026
Merged

feat: support AI SDK v7 (ai@7) as a peer dependency#691
bensabic merged 2 commits into
vercel:mainfrom
chentsulin:feat/ai-sdk-v7-peer

Conversation

@chentsulin

Copy link
Copy Markdown
Contributor

Closes #690

What

Widens the AI SDK peer dependency ranges so the Chat SDK installs cleanly next to ai@7:

  • chat: ai@^6.0.182 || ^7.0.0
  • @chat-adapter/web: ai@^6 || ^7, @ai-sdk/react@^3 || ^4, @ai-sdk/svelte@^4 || ^5, @ai-sdk/vue@^3 || ^4

This also unbreaks create-chat-sdk scaffolds, which install ai@latest (now v7) next to chat and currently hit a peer conflict out of the box.

The one real v6 → v7 break

In v7, tool() with an execute function returns ExecutableTool<Tool<...>> — an internal type from @ai-sdk/provider-utils that ai does not re-export. The chat/ai tool factories relied on inference, so declaration emit failed with TS2742 (17 errors). The factories now declare explicit Tool<Input, Output> return types, which is exactly the shape the previously published .d.ts already had — the public type surface is unchanged, and the emitted declarations only reference types from ai (portable for consumers on either major).

Everything else checked out compatible:

  • v7 stream parts keep text-delta / finish-step shapes, so fromFullStream duck-typing works unchanged; fullStream remains as a deprecated alias
  • tool-level needsApproval is deprecated in v7 but still typed and honored
  • createUIMessageStream, createUIMessageStreamResponse, isTextUIPart, UIMessage, UIMessageStreamWriter, ChatInit, DefaultChatTransport all still exported — @chat-adapter/web needed zero source changes

Other changes

  • devDependencies move to v7 so the workspace develops/tests against the latest major
  • examples/nextjs-chat and examples/nuxt-chat move to ai@^7 (required — mixing majors across the workspace fails typecheck, since chat's d.ts resolves ai types from its own devDependency)
  • Test-only: the ToolExecutionOptions stub type is now derived from Tool["execute"] because v7 made the generic parameter required
  • Changeset included (minor for chat and @chat-adapter/web)

Verification

The same source was verified against both majors (ai@6.0.182 and ai@7.0.17): tsc --noEmit and the full test suites (chat: 1035 tests, @chat-adapter/web: 21 tests) pass on each. pnpm validate (knip + check + typecheck + test + build, including both examples) is green on v7.

Note for adopters: ai@7 itself requires Node.js ≥ 22 and is ESM-only; chat keeps engines.node >= 20 since ai is an optional peer.

🤖 Generated with Claude Code

@chentsulin chentsulin requested a review from a team as a code owner July 10, 2026 09:58
@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

@chentsulin is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

chentsulin and others added 2 commits July 13, 2026 09:17
Widen peer ranges so the Chat SDK installs cleanly next to ai@7:

- chat: ai ^6.0.182 || ^7.0.0
- @chat-adapter/web: ai ^6 || ^7, @ai-sdk/react ^3 || ^4,
  @ai-sdk/svelte ^4 || ^5, @ai-sdk/vue ^3 || ^4

The only real v6 -> v7 break for this repo is that tool() with an
execute function now returns ExecutableTool<Tool<...>>, an internal
type that ai does not re-export, so the inferred return types of the
chat/ai tool factories fail declaration emit (TS2742). The factories
now declare explicit Tool<Input, Output> return types — the same
shape the published d.ts already had — so the public type surface is
unchanged and works against both majors.

Workspaces develop against v7 (devDependencies), and the examples
move to ai@7 to keep a single major across the monorepo. Source was
verified against both ai@6.0.182 and ai@7.0.17: typecheck and the
full test suites pass on each.

Closes vercel#690

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: chentsulin <chentsulin@gmail.com>
@dancer dancer force-pushed the feat/ai-sdk-v7-peer branch from 5b7998c to 0628bc5 Compare July 13, 2026 08:19
@bensabic bensabic merged commit 6714efc into vercel:main Jul 13, 2026
11 of 13 checks passed
dancer added a commit that referenced this pull request Jul 13, 2026
## summary

#691 widened the `ai` peer to `^6 || ^7`, but the workspace
devDependency pins ai@7 so CI only exercised v7. this adds an
`ai-sdk-v6-compat` job that forces the v6 constellation (ai@6 + matching
`@ai-sdk/react`/`svelte`/`vue` majors via `pnpm.overrides`) and builds,
typechecks, and tests `chat` and `@chat-adapter/web` against it. it's
wired into the required `build-and-test` summary so a v6 regression
can't land unnoticed

## test plan

- ran the job's steps locally against ai@6: `chat` (1044 tests) and
`@chat-adapter/web` (21 tests) build, typecheck, and pass
- YAML validated

Signed-off-by: dancer <josh@afterima.ge>
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.

Support AI SDK v7 (ai@7) as a peer dependency

3 participants