F39: Vercel AI SDK integration#8
Merged
Merged
Conversation
…ageEvent) Adds onFinish callback factory and event helper for Vercel AI SDK. Users can track usage from generateText/streamText/generateObject with 2-3 lines of code. Privacy-safe: only reads usage metadata, never accesses text/toolCalls/toolResults. Fire-and-forget tracking. Includes 14 tests covering provider detection, privacy invariant (property trap enforcement), latency edge cases, and fire-and-forget. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
Sentinel Code Review — ✅ APPROVEDMandatory Scans
Implementation Completeness (4/4 critical steps)
Security Checklist
Quality
FindingsNo blocking findings. Clean implementation. NOTE: This is an SDK change — requires publish task for The King (npm release). Sandra should create this after QA. Merge blocked by B30 (Vercel ERROR on aispendguard-app). SDK PR itself is mergeable but per sequential gate, will merge after B30 resolution. |
Contributor
Author
Code Review — APPROVED (Sentinel)PR #8 — F39: Vercel AI SDK integration Mandatory Scans: CLEANSecurity: CLEAN
Non-blocking
Tests: 14 tests including privacy traps. PASS.Merge blocked by B30. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
createAISDKOnFinish()callback factory for automatic usage tracking from Vercel AI SDK'sgenerateText(),streamText(), andgenerateObject()createVercelAIUsageEvent()pure helper for manual event constructionresult.usageandresult.responsemetadata — never accessestext,toolCalls,toolResults,object, orrawResponseTask
Task file:
aispendguard-tasks/active/features/F39-vercel-ai-sdk-integration.mdChanges
src/types.tsVercelAIOnFinishResultandVercelAIConfigtypessrc/vercel-ai.tssrc/index.tstests/vercel-ai.test.mjsImplementation Coverage
src/types.ts—VercelAIOnFinishResult,VercelAIConfigsrc/vercel-ai.ts—createVercelAIUsageEvent(),createAISDKOnFinish(),detectProvider()src/index.ts— function and type exportstests/vercel-ai.test.mjs— 14 test casesTesting
npx tsc --noEmitpassesnpm run buildpassesDocumentation
aispendguard-app/app/(docs)/docs/page.tsx) and SDK docs (aispendguard-docs/sdk/) to be done post-merge per plan Step 5 (RECOMMENDED, not blocking)