Turn protocol v1 parts into the old stream format, for widgets before 0.6
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 13
- Fork
- 7
- Merge trung bình
- 4 giờ 11 phút
- Pull request đã merge (30 ngày)
- 122
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của codercops/chatcops
-
enhancement hacktoberfest help wanted server
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Document the pre-chat formCó thể đã có người làm @masyarakatai đã nhận 4 ngày trước. Đang mởdocumentation good first issue hacktoberfest widget
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
codercops/chatcops#70 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement hacktoberfest help wanted server
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Create @chatcops/store-redis for Upstash and other Redis clientsCó thể đã có người làm @bhushan4work đã nhận hôm nay. Đang mởenhancement hacktoberfest help wanted server
codercops/chatcops#248 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement hacktoberfest help wanted server
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của codercops/chatcops
Issue tương tự
-
Area/Cloud Needs Triage Type/Bug
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
wso2/product-integrator#2847 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
bluesky-social/social-app#12118 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
heygen-com/hyperframes#6021 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Edit: Tele Posadas HDĐang mởcheck:passed streams:edit
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày