feat: add hosted HTTP SSE transport#240
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 448600010d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const events = options.subscribe(signal); | ||
| setSseHeaders(options.response); | ||
| for await (const event of events) { |
There was a problem hiding this comment.
Delay SSE headers until subscription lookup can fail
When subscribe is implemented as an async generator or otherwise defers run lookup/authorization until iteration, this flushes the 200 SSE headers before that lookup can throw. In that context the host's route can no longer return its JSON 404/401 policy (the Express handler only does so before headers are sent), so clients see a successful SSE response that closes instead of the intended error.
Useful? React with 👍 / 👎.
| this.baseUrl = options.baseUrl.trim().replace(/\/+$/, ''); | ||
| if (!this.baseUrl) { | ||
| throw new ConversationRunHttpSseClientError('Conversation run baseUrl cannot be empty.'); |
There was a problem hiding this comment.
Preserve root-relative base URLs
For deployments that mount the conventional resource at the origin root (/runs), callers naturally pass baseUrl: '/'; this normalization strips it to an empty string and then throws, so the HTTP/SSE client cannot be used for that valid route layout. Reject only originally blank values or preserve / as the normalized base.
Useful? React with 👍 / 👎.
Summary
@roackb2/heddle/hosted/http-ssefor strict replay cursors, canonical SSE frames, backpressure, and subscriber-only disconnect cleanup on Node HTTP@roackb2/heddle-remote/http-ssefor browser-safe REST/fetch lifecycle, accepted/cancel validation, incremental SSE parsing, reader cleanup, and event identity checksAPI shape
The preset intentionally standardizes only the conventional
POST /runs,GET /runs/:runId/events, andPOST /runs/:runId/cancelresource. tRPC, WebSocket, IPC, and other transports continue to use the neutral base layer.Verification
yarn test:unit— 660 passedyarn test:integration— 291 passed, including the real HTTP hosted-stack flowyarn remote:buildyarn buildnpm pack ./packages/heddle-remote --dry-run—/http-ssedeclarations and runtime files includedPR #239 is merged; this branch is rebased onto the resulting
main.