Conversation
- Move the ai devDependency to ^7.0.127 and keep the AI SDK 6 harness on an ai-v6 alias (npm:ai@^6.0.292). - Run the shieldLanguageModelMiddleware matrix on AI SDK 7 with MockLanguageModelV4, plus v7 cases for stream parts, raw chunks, UI message streams, tool results, tool call arguments, and wrapped transformParams. - shieldMiddleware().wrapParams/wrapParamsAsync now harden AI SDK 7's instructions option as well as the deprecated system option. - README support table and CHANGELOG Unreleased entry.
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.
Adds official support for Vercel AI SDK 7 (
ai@7.0.127, the current npmlatest).What changed
aidevDependency moves to^7.0.127, and the existing AI SDK 6 harness now imports from a newai-v6alias (npm:ai@^6.0.292, same version as before). The v4/v5/v6 tests are otherwise unchanged.MockLanguageModelV4fromai/test, since AI SDK 7 uses thev4model spec): the fullshieldLanguageModelMiddlewarematrix now runs on 7 (generateText,streamText, redaction,throwOnLeak, chunked mode, credentials, canaries,blockOnOutputFindings). There are also 7-specific cases for stream part ordering, provider metadata on deltas, raw chunk dropping, UI message stream errors, injections in all tool result output types,scanToolResults: false, tool call input redaction (generate and stream), and a wrappedtransformParams.shieldLanguageModelMiddlewareneeded no changes. AI SDK 7'swrapLanguageModelaccepts middleware of anyspecificationVersion, and the v4 call options, results, and stream parts have the shapes it already reads.systemand replaces it withinstructions.shieldMiddleware().wrapParams()/wrapParamsAsync()only hardenedsystem, so a prompt passed asinstructionsreached the model unhardened. They now harden both. (3 new tests cover this, and they fail without the fix.)[Unreleased]entry. The package version is unchanged.Test results (local, Node 20.19 / bun 1.4.2)
bun run typecheck: passbun run test: 40 files, 1233 passed, 2 skipped (base branch: 1193 passed, 2 skipped; +40 new tests)bun run build: passbun install --frozen-lockfileandnpm pack --dry-run: passdistwithai@7.0.127on Node 20: clean output passes, a leaked system prompt is redacted, and an injection throwsInjectionDetectedError.I didn't run the paid integration tests (
test:integration).Note:
ai@7declaresengines.node >=22. Shield's ownenginesis unchanged.