# `H.HTTP.SSE`
[🔗](https://github.com/parlant/harness/blob/v0.3.0/lib/h/http/sse.ex#L1)

Chunked Server-Sent Events (`text/event-stream`) transport loop.

Handles:
  * Optional `Last-Event-ID` header / `last_event_id` query parameter parsing.
  * Initial atomic `snapshot` or missed `commit` ring replay.
  * Zero-copy `ProcBin` `{:commit_frame, seq, bin}` and ID-less `{:ephemeral_frame, bin}` streaming.
  * Bounded slow-client backpressure via mailbox drain and fresh `snapshot` replacement.
  * Periodic `: keepalive` comments and clean exit on socket write error or `{:close_sse, reason}`.

# `stream`

```elixir
@spec stream(Plug.Conn.t(), String.t(), String.t(), keyword()) :: Plug.Conn.t()
```

Subscribes the current request process to `(sid, cid)` via `daemon` and streams
SSE frames until the client disconnects or `{:close_sse, reason}` is received.

# `stream_sessions`

```elixir
@spec stream_sessions(Plug.Conn.t(), keyword()) :: Plug.Conn.t()
```

Subscribes the current request process to catalog session events via `daemon`
and streams initial `snapshot` + live `catalog` SSE frames until the client
disconnects or `{:close_sse, reason}` is received.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
