chore: harden rpc assistant streaming types

This commit is contained in:
Peter Steinberger
2025-12-09 01:31:58 +01:00
parent 6b10f4241d
commit 27a545f79d
2 changed files with 1754 additions and 1750 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -535,11 +535,12 @@ export async function runCommandReply(
let lastStreamedAssistant: string | undefined;
const streamAssistantFinal = (msg?: {
role?: string;
content?: unknown;
content?: unknown | unknown[];
}) => {
if (!onPartialReply || msg?.role !== "assistant") return;
const textBlocks = Array.isArray(msg.content)
? (msg.content as Array<{ type?: string; text?: string }>)
const content = msg.content;
const textBlocks = Array.isArray(content)
? (content as Array<{ type?: string; text?: string }>)
.filter((c) => c?.type === "text" && typeof c.text === "string")
.map((c) => (c.text ?? "").trim())
.filter(Boolean)