Skip to content

feat(realtime): add generationTick event for billing updates#81

Merged
AdirAmsalem merged 1 commit intomainfrom
feat/realtime-generation-tick
Feb 12, 2026
Merged

feat(realtime): add generationTick event for billing updates#81
AdirAmsalem merged 1 commit intomainfrom
feat/realtime-generation-tick

Conversation

@AdirAmsalem
Copy link
Contributor

@AdirAmsalem AdirAmsalem commented Feb 12, 2026

Summary

  • Surfaces the generation_tick WebSocket message as a public generationTick event on the realtime client, letting consumers track billed seconds in real-time during authenticated sessions
  • Parses generation_ended internally but intentionally does not expose it — devs should use connectionChange for disconnect and error for insufficient credits

Usage

client.on("generationTick", ({ seconds }) => {
  console.log(`Billed so far: ${seconds}s`);
  updateBillingUI(seconds);
});

Changes

File Change
types.ts Add GenerationTickMessage, GenerationEndedMessage types + IncomingWebRTCMessage union
webrtc-connection.ts Parse both events in handleSignalingMessage, emit generationTick via mitt
client.ts Add generationTick to Events type, wire listener to buffered event emitter

Design Decisions

  • generation_ended not exposed: It's unreliable (won't arrive on client-initiated disconnect or network drop) and overlaps with connectionChange: "disconnected". The insufficient_credits case is already covered by the error event.
  • camelCase naming (generationTick): Matches existing SDK conventions (connectionChange, promptAck, sessionId). Wire format stays snake_case.
  • No breaking changes: Adds to the existing Events type — on/off just gains a new event key.

Note

Low Risk
Additive event/type wiring only; no changes to core connection/retry logic or outbound protocol behavior.

Overview
Surfaces server-side generation_tick updates as a new public realtime client event generationTick, allowing consumers to track billed generation seconds during a session.

Adds new websocket message types GenerationTickMessage and GenerationEndedMessage to the signaling type union; the connection layer emits generationTick via its internal emitter and explicitly parses-but-does-not-expose generation_ended.

Written by Cursor Bugbot for commit f95fa8f. This will update automatically on new commits. Configure here.

Surface the generation_tick WebSocket message from bouncer as a public
generationTick event on the realtime client. This lets consumers track
billed seconds in real-time during authenticated sessions.

generation_ended is parsed but intentionally not exposed — devs should
use connectionChange for disconnect and error for insufficient credits.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 12, 2026

Open in StackBlitz

npm i https://pkg.pr.new/DecartAI/sdk/@decartai/sdk@81

commit: f95fa8f

@AdirAmsalem AdirAmsalem merged commit a47ee04 into main Feb 12, 2026
5 checks passed
@AdirAmsalem AdirAmsalem deleted the feat/realtime-generation-tick branch February 12, 2026 12:07
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