Skip to content

feat: SSE frame parser (core slice of #46) - #49

Merged
rwrife merged 1 commit into
mainfrom
feat/issue-46-sse-frame-parser
Jul 15, 2026
Merged

feat: SSE frame parser (core slice of #46)#49
rwrife merged 1 commit into
mainfrom
feat/issue-46-sse-frame-parser

Conversation

@rwrife

@rwrife rwrife commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Closes part of #46 — first shippable slice.

What

Pure Server-Sent Events frame parser at src/core/sse/, WHATWG-spec-compliant, no VS Code / undici deps.

Highlights

  • SseParser — stateful streaming API (push / end / drain); handles chunk-split CRLF, leading BOM, comments, unknown fields, multi-data: join, sticky lastEventId / retry, NUL-in-id: rejection, digits-only retry:.
  • SseEventSchema (zod) validating every dispatched event.
  • parseSse() one-shot helper.
  • 22 vitest cases (spec examples + edge cases: CRLF, bare CR, BOM, multi-data, chunk boundaries).

Not in this PR (still under #46)

  • Response viewer streaming mode
  • # @sse-until <expr> directive
  • undici wire-up + reconnect / Last-Event-ID header
  • .sse.jsonl transcript persistence
  • README section

Kept small and pure to land the foundation first; follow-ups will layer on it.

Checks

  • npm run lint
  • npm run typecheck
  • npm run test:unit ✅ (431 passed, 22 new)

First slice of #46: a streaming, spec-compliant Server-Sent Events
frame parser under src/core/sse/, fully unit-testable without VS Code
or network.

- SseParser: stateful, chunked; handles CR / LF / CRLF (incl. CRLF
  split across chunks), leading BOM, ':' comments, unknown fields,
  multi-'data:' join, NUL-in-'id:' rejection, digits-only 'retry:'.
- SseEventSchema: zod validation for dispatched events; sticky
  lastEventId / retry across events per spec.
- parseSse() one-shot convenience wrapper.
- 22 vitest cases covering the WHATWG examples plus edge cases.

Follow-up work (response viewer streaming mode, '@sse-until'
directive, reconnect + Last-Event-ID wiring, transcript persistence)
stays tracked under #46.
@rwrife
rwrife merged commit 473171e into main Jul 15, 2026
8 checks passed
@rwrife
rwrife deleted the feat/issue-46-sse-frame-parser branch July 15, 2026 17:00
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.

1 participant