Turn protocol v1 parts into the old stream format, for widgets before 0.6
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
The 0.6 server streams typed parts (WirePart, in packages/core/src/protocol/v1.ts), but widgets on 0.5 and older read chunks like {"content":"Hi"} and {"done":true}. Those widgets will stay on sites and CDNs for months, so the server needs to translate. This issue is that translation, as one pure function.
What to do
Create packages/core/src/protocol/legacy.ts:
export interface LegacyChunk {
content?: string;
done?: boolean;
error?: string;
retryAfter?: number; // seconds
leadCaptured?: boolean;
leadData?: Record<string, unknown>;
suggestedActions?: string[];
}
/** The chunk an old widget expects for this part, or null for parts it has no use for. */
export function toLegacyChunk(part: WirePart): LegacyChunk | null;
| v1 part | Legacy chunk |
|---|---|
text-delta |
{ content: delta } |
lead-captured |
{ leadCaptured: true, leadData: lead } |
suggestions |
{ suggestedActions: items } |
error with rate_limited |
{ error: 'rate_limit', retryAfter }, with retryAfter = retryAfterMs rounded up to seconds, left out when there's none |
error with timeout |
{ error: 'timeout' } |
error with internal_error |
{ error: 'internal_error' } |
error with invalid_request |
{ error: 'Invalid request' } (what 0.5 servers send) |
error with any other code |
{ error: 'provider_error' } |
finish with reason error or aborted |
null (the error part already went out, or nobody is listening) |
finish with any other reason |
{ done: true } |
everything else (start, text-start, text-end, source, tool-call, tool-result, handoff, agent-message) |
null |
Those error strings are the ones the 0.5 widget understands (packages/widget/src/widget.ts, resolveErrorType, line 643).
Where to look
packages/core/src/protocol/v1.ts(the part types)packages/server/src/handler.ts, which writes the old chunks today (lines 51, 61, 71, 181, 209, 223, 250)
Acceptance criteria
- New
packages/core/src/protocol/legacy.ts, exported frompackages/core/src/protocol/index.tsand from@chatcops/core - One test per row of the table, plus
retryAfterMs: 1500becomingretryAfter: 2 - A test that runs a whole v1 stream through it and gets the exact chunks a 0.5 server sends for the same reply
- 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 于 6 天前认领。 未关闭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 于 1 天前认领。 未关闭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 于 1 天前认领。 未关闭documentation good first issue hacktoberfest website
codercops/chatcops#286 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Create @chatcops/store-cloudflare (D1, KV and a Durable Object counter)可能已有人在做 @bhushan4work 于 1 天前认领。 未关闭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 于 1 天前认领。 未关闭enhancement hacktoberfest help wanted server
难度 5/5 一周以上 新手友好度 35/100
codercops/chatcops#247 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 codercops/chatcops 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug
难度 1/5 1 小时以内 新手友好度 76/100
维护者通常 1 天内回复
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1 小时以内 新手友好度 76/100
lingdojo/kana-dojo#32964 · 1 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
Documentation status: needs triage
难度 2/5 1-3 小时 新手友好度 72/100
mastra-ai/mastra#28194 · 1 条评论 ·
维护者通常 1 天内回复
-
priority-low refactor-3
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 3 天内回复