Skip to content

Stream Events code improvements#49

Merged
x2d7 merged 11 commits intorelease/v0.3.1from
refactor/event-system-v0.3.1
Mar 9, 2026
Merged

Stream Events code improvements#49
x2d7 merged 11 commits intorelease/v0.3.1from
refactor/event-system-v0.3.1

Conversation

@x2d7
Copy link
Owner

@x2d7 x2d7 commented Mar 9, 2026

Summary

Refactor event types for consistency and add JSON serialization support.

Refactor: rename events and unexport GetType (#39, #40)

Event types renamed for idiomatic Go style — EventNewTokenEventToken, EventNewToolCallEventToolCall etc. New was redundant in type names. Deprecated aliases added for all renamed types, to be removed in v0.4.0.

StreamEvent.GetType is now unexported — the interface is sealed, external implementation was never intended.

eventType switched from uint/iota to string constants, making the type readable and serialization-friendly.

Feat: JSON serialization for events (#39)

Added MarshalEvent and UnmarshalEvent to serial.go. Each event is wrapped in an envelope with a type discriminator:

{"type": "token", "payload": {"text": "hello"}}

serial.go is intended as the home for all future serialization utilities — Messages, Client, Chat and others.

Closes #39
Closes #40

@x2d7 x2d7 added this to the v0.3.1 — Events Improvements milestone Mar 9, 2026
@x2d7 x2d7 merged commit e56f3b9 into release/v0.3.1 Mar 9, 2026
1 check passed
@x2d7 x2d7 deleted the refactor/event-system-v0.3.1 branch March 9, 2026 17:07
@x2d7 x2d7 mentioned this pull request Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant