Turn protocol v1 parts into the old stream format, for widgets before 0.6
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
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.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 13
- Forks
- 7
- Ø Merge
- 3 Std. 33 Min.
- Gemergte PRs (30 T.)
- 176
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus codercops/chatcops
-
Add startup checks that catch weak or leaked security settingsEvtl. vergeben @varun-pahuja hat das vor 2 Tagen übernommen. Offenenhancement good first issue hacktoberfest server
codercops/chatcops#231 · 3 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Type-check the TypeScript samples in the docsEvtl. vergeben @An16og hat das vor 2 Tagen übernommen. Offendocumentation hacktoberfest help wanted testing
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 70/100
codercops/chatcops#201 · 7 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
hacktoberfest
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 1 Tag
-
Add built-in translations to the widgetEvtl. vergeben @piyusshhjangid hat das vor 1 Tag übernommen. Offenhelp wanted widget
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
codercops/chatcops#55 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in codercops/chatcops
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
db-ux-design-system/core-web#8613 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
foxglove/mcap#1907 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug internal-plugin pr-welcome upstream
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
dsh-tauri-desk/deepseek-harness-desktop#1225 · 1 Kommentar ·
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
unjs/unhead#1027 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag