Skip to content

fix(anthropic): accept stable and beta SDK events - #99

Merged
Kinfe123 merged 2 commits into
mainfrom
fix/anthropic-sdk-event-types
Oct 30, 2026
Merged

Kinfe123 merged 2 commits into
mainfrom
fix/anthropic-sdk-event-types

Conversation

@Kinfe123

Copy link
Copy Markdown
Collaborator

Problem

With streamfold 0.1.14 and @anthropic-ai/sdk 1.3.0, passing client.messages.create({ model, messages, max_tokens, stream: true }) to readStructured(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

  • A real SDK consumer fixture covers stable and beta message streams, readStructured, both manual push methods, and an unknown raw event literal.
  • pnpm typecheck fails before the declaration change with TS2322/TS2345 on both SDK stream surfaces and passes afterward.
  • pnpm release:check passes: 197 JavaScript tests, 11 Rust tests, type/syntax checks, WASM build, formatting, Clippy, and package checks.

Public surface

Widens AnthropicToolInputEvent without removing an existing shape. Updates API documentation and the unreleased changelog. The SDK is a development-only dependency for the consumer type check.

@Kinfe123 Kinfe123 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, stable and beta anthropic streams typecheck directly.

@Kinfe123
Kinfe123 merged commit cd5eac9 into main Oct 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant