mirror of
https://github.com/hanzoai/dataroom.git
synced 2026-10-30 18:41:07 +00:00
hanzo-build-linux-amd64 is the only ARC runner pool installed on hanzo-k8s today (arm64 pool is paused until DigitalOcean ships arm64 droplets, per ~/work/hanzo/.github/RUNNERS.md). The arm64 job was waiting on spark-hanzoai-arm64 — not provisioned in this cluster — so every build sat in queue forever and the amd64 leg got cancelled. Set platforms: linux/amd64 on the reusable build call to skip arm64 entirely. Re-add arm64 if/when DO ships arm64 droplets and the spark runner pool comes back online.
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
/**
|
|
* Parser for AI SDK's toTextStreamResponse() format
|
|
* Handles plain text stream (no SSE, no JSON structure)
|
|
*/
|
|
|
|
export interface TextStreamCallbacks {
|
|
onTextDelta?: (delta: string, accumulated: string) => void;
|
|
onTextEnd?: (content: string) => void;
|
|
onError?: (error: Error) => void;
|
|
}
|
|
|
|
export interface TextStreamResult {
|
|
content: string;
|
|
}
|
|
|
|
/**
|
|
* Parse the text stream from toTextStreamResponse()
|
|
* This is a simple text-only stream with no structured events
|
|
*/
|
|
export async function parseTextStream(
|
|
reader: ReadableStreamDefaultReader<Uint8Array>,
|
|
callbacks: TextStreamCallbacks,
|
|
): Promise<TextStreamResult> {
|
|
const decoder = new TextDecoder();
|
|
let content = "";
|
|
|
|
try {
|
|
while (true) {
|
|
const { done, value } = await reader.read();
|
|
if (done) break;
|
|
|
|
const chunk = decoder.decode(value, { stream: true });
|
|
content += chunk;
|
|
callbacks.onTextDelta?.(chunk, content);
|
|
}
|
|
|
|
// Flush decoder
|
|
const remaining = decoder.decode();
|
|
if (remaining) {
|
|
content += remaining;
|
|
callbacks.onTextDelta?.(remaining, content);
|
|
}
|
|
} catch (error) {
|
|
callbacks.onError?.(error as Error);
|
|
throw error;
|
|
}
|
|
|
|
callbacks.onTextEnd?.(content);
|
|
|
|
return { content };
|
|
}
|
|
|