vibe.sse

Server-Sent Events (SSE) utilities.

This module provides the canonical implementation for SSE event formatting used throughout the VIBE assistant streaming infrastructure.

SSEEvent

Represents a Server-Sent Event.

SSE events are used for real-time streaming updates from the assistant to the browser client.

format

format() -> str

Format the event as an SSE string.

Returns:
  • str

    Formatted SSE event string ready for streaming to client.

  • str

    Multi-line data is split into separate data: lines per SSE spec.

format_sse_event

format_sse_event(event_type: str, data: str) -> str

Format a Server-Sent Events (SSE) event string.

This is the canonical SSE formatting function used throughout VIBE for streaming assistant responses to the browser.

Parameters:
  • event_type (str) –

    The SSE event type (e.g., 'chunk', 'form_command', 'error')

  • data (str) –

    The event data payload

Returns:
  • str

    Formatted SSE event string ready for streaming to client