mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-21 08:02:38 +00:00
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:
co-authored by
Claude Opus 5
parent
701e8decce
commit
b4c0622f3f
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user