SmolBox.Wire.SSE (SmolBox v0.1.0)

Copy Markdown View Source

Incremental parser for the pinned SmolVM exec SSE protocol.

stdout/stderr are plain lossy UTF-8 data; only exit/error payloads are JSON. Unknown additive events and keepalives are ignored. An exit is required for successful completion. Terminal duplicates and output after exit are errors. Frames and incoming chunks have explicit byte limits; no mailbox is involved.

Summary

Functions

Consume a bounded chunk; incomplete UTF-8 is retained until the frame is complete.

EOF is successful only after a complete exit event with no unfinished frame.

Types

event()

@type event() ::
  {:stdout, String.t()}
  | {:stderr, String.t()}
  | {:exit, integer()}
  | {:error, :remote}

t()

@type t() :: %SmolBox.Wire.SSE{
  buffer: binary(),
  data: [binary()],
  event: binary(),
  frame_bytes: non_neg_integer(),
  max_chunk_bytes: pos_integer(),
  max_frame_bytes: pos_integer(),
  terminal: :exit | :error | nil
}

Functions

feed(state, chunk)

@spec feed(t(), binary()) :: {:ok, t(), [event()]} | {:error, SmolBox.Error.t()}

Consume a bounded chunk; incomplete UTF-8 is retained until the frame is complete.

finish(sse)

@spec finish(t()) :: :ok | {:error, SmolBox.Error.t()}

EOF is successful only after a complete exit event with no unfinished frame.