feat(ai): add AI SDK v7 compatibility for evlog/ai#404
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Thank you for following the naming conventions! 🙏 |
📝 WalkthroughWalkthroughThis PR adds AI SDK v7 compatibility to evlog’s telemetry integration, keeps v6 hook support, renames telemetry config usage from ChangesAI SDK v7 compatibility
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant AI SDK
participant createEvlogIntegration
participant EvlogTelemetryIntegration
participant Telemetry State
participant Wide Event
AI SDK->>createEvlogIntegration: build integration
createEvlogIntegration->>EvlogTelemetryIntegration: return v6/v7-compatible hooks
AI SDK->>EvlogTelemetryIntegration: onToolCallFinish / onToolExecutionEnd
EvlogTelemetryIntegration->>Telemetry State: record tool execution
AI SDK->>EvlogTelemetryIntegration: onFinish / onEnd
EvlogTelemetryIntegration->>Telemetry State: record generation duration
AI SDK->>EvlogTelemetryIntegration: onEmbedEnd / onAbort / onError
EvlogTelemetryIntegration->>Telemetry State: record embedding, abort, error
Telemetry State->>Wide Event: flush accumulated telemetry
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/nuxthub-playground/package.json`:
- Around line 13-15: The dependency declaration for `@ai-sdk/vue` in package.json
is still on the older major line, so update the `@ai-sdk/vue` entry in the same
dependencies block where ai is set to ^7.0.0. Replace the current version with
the v7-compatible release (^4.0.7) and keep the package list consistent with the
AI SDK version bump.
In `@packages/evlog/package.json`:
- Line 395: The ai peer dependency range needs an upper bound to match the
version-specific adapters used in the AI integration. Update the
peerDependencies entry for ai in the package manifest to cap support before the
next major, and ensure it aligns with the existing adaptV6ToolEvent and
adaptV7ToolEvent logic in packages/evlog/src/ai/index.ts so future majors do not
pass through without a compatibility check. Keep devDependencies.ai on the
current major, but constrain the peer range to the supported v6/v7 window.
In `@packages/evlog/src/ai/index.ts`:
- Around line 931-933: The duration calculation in the state update logic uses a
truthy check on generationStartTime, which fails when fake timers make
Date.now() return 0. Update the guard in the code around
state.generationStartTime so it explicitly checks for undefined/null before
computing state.totalDurationMs, preserving valid zero timestamps while keeping
the same duration assignment behavior.
In `@packages/evlog/test/ai/ai.test.ts`:
- Around line 1774-1784: The `computes totalDurationMs from onStart to onEnd`
test is timing-dependent because it uses a real `setTimeout(20)`. Update the
test in `ai.test.ts` to use the repository fake-timer helper from
`test/helpers/` instead of real time, then advance the clock deterministically
before calling `callIntegrationOnEnd`. Keep the assertions around
`getLastAiData`/`totalDurationMs`, but change them to assert the exact expected
duration rather than a minimum range.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: dff1f1b1-4fab-4c35-93fe-3f9170729dac
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (18)
.changeset/ai-sdk-v7-compat.mdapps/docs/app/components/features/FeatureAiSdk.vueapps/docs/content/4.use-cases/2.ai-sdk/01.overview.mdapps/docs/content/4.use-cases/2.ai-sdk/04.metadata.mdapps/docs/content/4.use-cases/2.ai-sdk/05.telemetry.mdapps/docs/skills/review-logging-patterns/SKILL.mdapps/nuxthub-playground/.nuxtrcapps/nuxthub-playground/package.jsonapps/nuxthub-playground/server/api/chat.post.tsapps/nuxthub-playground/server/api/test/ai-wrap.get.tsexamples/eve/package.jsonpackage.jsonpackages/evlog/README.mdpackages/evlog/package.jsonpackages/evlog/src/ai/index.tspackages/evlog/test/ai/ai.test.tspackages/nuxthub/.nuxtrcpnpm-workspace.yaml
Guard generationStartTime with an explicit undefined check, use fake timers in duration tests, cap the ai peer range, and bump @ai-sdk/vue to v4.
🔗 Linked issue
📚 Description
📝 Checklist
Summary by CodeRabbit
EvlogTelemetrytype for integration usage.telemetryvsexperimental_telemetry).