Skip to content

WebSocket and SSE client effects #228

@aallan

Description

@aallan

Add WebSocket and Server-Sent Events (SSE) client effects.

Motivation

Streaming LLM responses (OpenAI, Anthropic, and other inference APIs) use SSE. Real-time applications need WebSocket connections. These are distinct from the request/response model of the Http effect.

Proposed effects

-- SSE: server-sent event stream
fn stream_completion(@String -> @Unit)
  effects(<SSE, IO>)
{
  SSE.connect(@String.0, fn(@String -> @Unit) effects(<IO>) {
    IO.print(@String.0)
  })
}
  • SSE.connect(url, handler) — open an SSE connection, call handler for each event
  • WebSocket.connect(url) — open a WebSocket connection
  • WebSocket.send(message) / WebSocket.receive() — bidirectional messaging

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    C9C9 — Language designenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions