fix: carry the event type narrowing through the stream parser

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hugocasa
2026-09-17 10:07:22 +02:00
co-authored by Claude Opus 5
parent 3e2dac0cf9
commit 69db9d8b0b
+4 -2
View File
@@ -173,7 +173,7 @@ const STREAM_EVENT_TYPES = [
'tool_result'
]
function parseStreamEvent(line: string): Record<string, unknown> | undefined {
function parseStreamEvent(line: string): (Record<string, unknown> & { type: string }) | undefined {
let event: unknown
try {
event = JSON.parse(line)
@@ -183,7 +183,9 @@ function parseStreamEvent(line: string): Record<string, unknown> | undefined {
if (!isRecord(event) || typeof event.type !== 'string') {
return undefined
}
return STREAM_EVENT_TYPES.includes(event.type) ? event : undefined
return STREAM_EVENT_TYPES.includes(event.type)
? (event as Record<string, unknown> & { type: string })
: undefined
}
/**