Documentation
¶
Overview ¶
Package sdkstream presents a Protocol Stage EventStream as the SDK stream types the existing client writers consume, so the client-facing output of a Stage pipeline goes through exactly the code that writes it today.
Anthropic V1 is served here from Beta events: V1 is a subset of Beta on the wire, so a Beta event is re-read as its V1 form. Content V1 cannot express is refused explicitly (see AnthropicV1Downgrade) rather than dropped.
Index ¶
- func AnthropicBeta(ctx context.Context, events stage.EventStream, options ...Option) *anthropicstream.Stream[anthropic.BetaRawMessageStreamEventUnion]
- func AnthropicV1(ctx context.Context, events stage.EventStream, options ...Option) *anthropicstream.Stream[anthropic.MessageStreamEventUnion]
- func AnthropicV1Downgrade(message *anthropic.BetaMessage) (*anthropic.Message, error)
- func WireJSON(value any) ([]byte, error)
- type InBandError
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnthropicBeta ¶
func AnthropicBeta(ctx context.Context, events stage.EventStream, options ...Option) *anthropicstream.Stream[anthropic.BetaRawMessageStreamEventUnion]
AnthropicBeta returns events as an Anthropic Beta SDK stream. Closing the SDK stream closes events.
func AnthropicV1 ¶
func AnthropicV1(ctx context.Context, events stage.EventStream, options ...Option) *anthropicstream.Stream[anthropic.MessageStreamEventUnion]
AnthropicV1 returns Beta events as an Anthropic V1 SDK stream for a V1 client. A block V1 cannot express ends the stream with an error.
func AnthropicV1Downgrade ¶
func AnthropicV1Downgrade(message *anthropic.BetaMessage) (*anthropic.Message, error)
AnthropicV1Downgrade re-reads a Beta message as its V1 form for a V1 client, keeping its wire bytes. A block V1 cannot express is an error.
Types ¶
type InBandError ¶
InBandError is an error event carried inside a stream.
func (InBandError) Error ¶
func (e InBandError) Error() string
type Option ¶
type Option func(*anthropicDecoder)
Option configures a stream presentation.
func OnHeartbeat ¶
func OnHeartbeat(f func()) Option
OnHeartbeat calls f for every stage.Heartbeat, on the goroutine reading the stream (the one writing to the client), so f may write to the client. Without it heartbeats are dropped.