Add one shared encoder for the server's event stream lines
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
Each server adapter builds its own SSE lines and writes its own data: [DONE] (packages/server/src/adapters/express.ts, lines 59 and 61, vercel.ts, lines 55 and 57, cloudflare.ts, lines 72 and 74), and their headers differ slightly. For protocol v1, one module will own the format so the adapters only move bytes. This issue is that module.
What to do
Create packages/core/src/protocol/sse.ts:
/** One event: `data: <json>` and a blank line. */
export function encodeSSE(part: WirePart | Record<string, unknown>): string;
/** A comment line that keeps the connection busy while nothing else is sent. */
export const SSE_PING: string; // ': ping\n\n'
/** Ends the stream. */
export const SSE_DONE: string; // 'data: [DONE]\n\n'
export const SSE_HEADERS: Readonly<Record<string, string>>;
SSE_HEADERS:Content-Type: text/event-stream; charset=utf-8,Cache-Control: no-cache, no-transform(stops proxies from compressing and buffering),X-Accel-Buffering: no(nginx). Leave outConnection. HTTP/2 doesn't allow it, and the runtimes handle it themselves.encodeSSEmust never produce a raw line break inside the data line.JSON.stringifyalready escapes\nand\r, so test that a part with line breaks in its text stays on one line. Also test that U+2028 and U+2029 survive.
Where to look
packages/core/src/protocol/v1.ts- The SSE format on MDN
Acceptance criteria
- New
packages/core/src/protocol/sse.ts, exported frompackages/core/src/protocol/index.tsand from@chatcops/core - Tests for the line format, line breaks in text, U+2028/U+2029, and the exact header values
- The adapters aren't changed in this PR (I switch them over in the protocol PR)
- Changeset for
@chatcops/core(minor) -
pnpm test:coverageandpnpm lintpass
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #<this issue number>. Setup notes (pnpm, build before test) are in CONTRIBUTING.md.
- 主要语言
- TypeScript
- 星标
- 13
- 派生
- 7
- 平均合并
- 3 小时 41 分钟
- 30 天内合并 PR
- 155
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
codercops/chatcops 的其他 Issue
-
Document the pre-chat form可能已有人在做 @masyarakatai 于 5 天前认领。 未关闭documentation good first issue hacktoberfest widget
难度 2/5 1-3 小时 新手友好度 88/100
codercops/chatcops#70 · 5 条评论 ·
维护者通常 1 天内回复
-
docs: update the providers page for openai-compatible, registerProvider and provider imports可能已有人在做 @prakashNalla 今天认领。 未关闭documentation good first issue hacktoberfest website
难度 3/5 1-2 天 新手友好度 76/100
codercops/chatcops#291 · 1 条评论 ·
维护者通常 1 天内回复
-
docs: add a protocol reference page for custom clients可能已有人在做 @kachamsiddarth 今天认领。 未关闭documentation good first issue hacktoberfest website
codercops/chatcops#286 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Create @chatcops/store-cloudflare (D1, KV and a Durable Object counter)可能已有人在做 @bhushan4work 今天认领。 未关闭enhancement hacktoberfest help wanted server
难度 5/5 一周以上 新手友好度 25/100
codercops/chatcops#249 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Create @chatcops/store-sqlite, a store for single-server setups可能已有人在做 @srikar-naidu 今天认领。 未关闭enhancement hacktoberfest help wanted server
难度 5/5 一周以上 新手友好度 35/100
codercops/chatcops#247 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 codercops/chatcops 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
phivk/rubiks-lab#33 ·
维护者通常 1 天内回复
-
BUG:Edit Album strips spaces from the password so albums with a leading/trailing space in the password can't be edited可能已有人在做 @ManyaJain111 今天认领。 未关闭bug enhancement possible-duplicate
难度 2/5 1-3 小时 新手友好度 77/100
AOSSIE-Org/PictoPy#1637 · 4 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
chaitin/MonkeyCode#1437 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
area:cards enhancement migration ready-for-agent
难度 2/5 1-3 小时 新手友好度 70/100
fil-donadoni/tolaria#6309 ·
维护者通常 1 天内回复