Stream Chunk Protocol
The stream protocol is defined in @kortyx/stream as StreamChunk.
Core chunk types
sessionstatustext-starttext-deltatext-endmessagestructured-datainterrupttransitiondoneerror
Typical client loop
TS
import { readStream, type StreamChunk } from "kortyx";
const chunks: StreamChunk[] = [];
for await (const chunk of readStream(response.body)) {
chunks.push(chunk);
if (chunk.type === "text-delta") {
// append to in-flight assistant text
}
if (chunk.type === "interrupt") {
// render selection UI and resume with token/requestId
}
if (chunk.type === "done") {
break;
}
}Notes
doneis terminal for a stream runerrormay be followed bydonesessionhelps clients persist conversation identity