feat(sdk): add AI SDK 7 support#3833
Conversation
🦋 Changeset detectedLatest commit: e55fa9f The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (11)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (9)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (31)
WalkthroughThis PR extends Trigger.dev SDK to support AI SDK v7 while maintaining backward compatibility with v5 and v6. The implementation adds parallel TypeScript type-checking against v7 definitions, creates ESM/CJS runtime shims to handle v7's ESM-only package structure, refactors type contracts to be version-agnostic using structural typing instead of concrete SDK types, and introduces automatic registration of the 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/plugins
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
The `ai` peer range now includes v7, and the chat surfaces work against the v7 ESM-only build. v5 and v6 are unchanged. On v7, model-call spans moved from `ai` core into `@ai-sdk/otel`: install it alongside `ai@7` and the SDK registers it at chat agent boot so `experimental_telemetry` keeps flowing into run traces. An already-registered integration is detected and skipped; set `TRIGGER_AI_SDK_OTEL_AUTOREGISTER=0` to disable auto-registration. `ai@7` is ESM-only, so runtime value imports from `ai` sit behind a paired ESM/CJS shim.
On v7 the tool execution context is passed as `context` (v6 used `experimental_context`). createTaskToolExecuteHandler only read `experimental_context`, so task-backed tools (`ai.toolExecute`) lost their context on v7. Read whichever is set and stamp both names into the subtask metadata.
5da48c3 to
e55fa9f
Compare
Summary
Adds support for Vercel AI SDK 7. The
aipeer range now includes v7, and thechat.agent/ chat surfaces work against v7's ESM-only build. v5 and v6 keep working unchanged, so this is additive.Telemetry on v7
On v7, model-call spans moved out of
aicore into the separate@ai-sdk/oteladapter, soexperimental_telemetryalone produces nothing until an integration is registered. Install@ai-sdk/otelalongsideai@7and the SDK registers it once per worker at chat agent boot, so spans keep flowing into run traces with no extra setup.If you (or a library you import) already register
@ai-sdk/otel, the SDK detects the existing integration and skips its own registration, so you won't get duplicate spans. SetTRIGGER_AI_SDK_OTEL_AUTOREGISTER=0to disable auto-registration entirely.Notes
ai@7is ESM-only, which tripped TS1479 in the SDK's CommonJS build. Runtime value imports fromaiare isolated behind a paired ESM/CJS shim so both module formats resolve the right form; type-only imports stay as directimport typeat their use sites.