Skip to content

Conversation

@D0rSeg4l
Copy link

@D0rSeg4l D0rSeg4l commented Dec 31, 2025

This PR adds two features to the sdk:

  1. WebSocket Message Events & Session Info

Exposes WebSocket message events and session information through the public API, enabling better observability and control over realtime sessions.

Changes:

  • Add WsMessageEvents type exposing promptAck, imageSet, and generationStarted events
  • Forward WebSocket events to the main event emitter so clients can subscribe to them
  • Add getSessionInfo() method to retrieve session connection details (sessionId, serverIp, serverPort)
  • Add GenerationStartedMessage and SessionIdMessage types
  • Register event listeners before connecting to ensure events during connection are captured
  1. Subscribe Client for Existing Sessions

Adds a new createRealTimeSubscribeClient that allows read-only subscription to existing realtime sessions, enabling use cases like spectating or monitoring.

Changes:

  • Add subscribe-client.ts with createRealTimeSubscribeClient factory
  • Support receive-only WebRTC mode (null localStream) in WebRTCConnection
  • Move SessionInfo type to types.ts for shared use
  • Export new types: RealTimeSubscribeClient, RealTimeSubscribeClientOptions, RealTimeSubscribeConnectOptions, SubscribeEvents
  • Add realtimeSubscribe client to main SDK export
  • Added usage example to sdk-core/README.md
  1. Add RTT and Stats Methods

Adds WebRTC connection diagnostics to the RealTimeClient:

  • getRtt() - Returns current round-trip time in milliseconds
  • getStats() - Returns raw RTCStatsReport for detailed connection metrics
  • getSessionInfo() - Returns session ID and server info

Note

Enables spectating/monitoring of existing realtime sessions and improves observability of active sessions.

  • Adds realtimeSubscribe via createRealTimeSubscribeClient with receive‑only WebRTC support (null localStream) and SubscribeEvents
  • Exposes WS message events (promptAck, imageSet, generationStarted) through RealTimeClient by forwarding from WebRTCConnection
  • Adds session identification flow: new SessionIdMessage, stored as SessionInfo, and getSessionInfo() on RealTimeClient
  • Updates WebRTCConnection to handle generation_started, session_id, recvonly transceivers, and exports SessionInfo
  • Exports new types from index.ts and documents usage with a concise example in examples/sdk-core/README.md

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

- Add createRealTimeSubscribeClient for read-only subscription to existing sessions
- Move SessionInfo type to types.ts for better organization
- Support receive-only WebRTC mode in webrtc-connection.ts
- Fix any type in webrtc-manager.ts getSessionInfo()
@D0rSeg4l D0rSeg4l requested review from YehoavR and Copilot December 31, 2025 15:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds WebSocket message event observability and subscribe-only client functionality to the realtime SDK, enabling monitoring of existing sessions and better visibility into session state.

  • Exposes WebSocket events (promptAck, imageSet, generationStarted) and session information through the public API
  • Adds read-only subscription client for spectating/monitoring existing realtime sessions
  • Supports receive-only WebRTC mode by allowing null local streams

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/sdk/src/realtime/webrtc-manager.ts Adds getSessionInfo() method to expose session connection details
packages/sdk/src/realtime/webrtc-connection.ts Implements session info tracking, generation started events, and receive-only WebRTC mode
packages/sdk/src/realtime/types.ts Defines new message types for generation started and session info
packages/sdk/src/realtime/subscribe-client.ts New subscribe-only client for read-only access to existing sessions
packages/sdk/src/realtime/client.ts Forwards WebSocket events to main emitter and adds getSessionInfo() to client API
packages/sdk/src/index.ts Exports subscribe client and related types
examples/sdk-core/README.md Documents usage of the new subscribe client feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@D0rSeg4l D0rSeg4l marked this pull request as draft December 31, 2025 16:01
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 31, 2025

Open in StackBlitz

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

commit: dd96377

@D0rSeg4l D0rSeg4l requested a review from Copilot December 31, 2025 16:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

packages/sdk/src/index.ts:1

  • The example doesn't show error handling for when getSessionInfo() returns null (e.g., if called before the session_id message is received). Add a null check in the example to demonstrate proper usage.
import { z } from "zod";

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@D0rSeg4l D0rSeg4l requested a review from Copilot January 1, 2026 10:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@D0rSeg4l D0rSeg4l changed the title Feature/add websocet events callback Feature/add websocket events callback Jan 1, 2026
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.

2 participants