Repository navigation
fix(anthropic): accept stable and beta SDK events - #99
Merged
Merged
Conversation
Kinfe123
commented
Oct 30, 2026
Kinfe123
left a comment
Collaborator
Author
There was a problem hiding this comment.
lgtm, stable and beta anthropic streams typecheck directly.
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.
Problem
With streamfold 0.1.14 and @anthropic-ai/sdk 1.3.0, passing
client.messages.create({ model, messages, max_tokens, stream: true })toreadStructured(events, { integration: anthropic })fails TypeScript compilation. The beta message stream and manual push methods fail the same way.Root cause
The adapter's fallback event shape requires a string index signature. Anthropic declares its events as interfaces without that signature, so non-tool block starts cannot satisfy the union even though the runtime ignores them.
Change
Accept a discriminator-only fallback alongside the existing event shapes. Preserve the existing index-signature branch for raw provider event literals with extra fields. No runtime behavior changes or SDK runtime dependencies are introduced.
Verification
readStructured, both manual push methods, and an unknown raw event literal.pnpm typecheckfails before the declaration change with TS2322/TS2345 on both SDK stream surfaces and passes afterward.pnpm release:checkpasses: 197 JavaScript tests, 11 Rust tests, type/syntax checks, WASM build, formatting, Clippy, and package checks.Public surface
Widens
AnthropicToolInputEventwithout removing an existing shape. Updates API documentation and the unreleased changelog. The SDK is a development-only dependency for the consumer type check.