(streamingExecution: unknown)
| 406 | } |
| 407 | |
| 408 | const onStream = async (streamingExecution: unknown) => { |
| 409 | const streamingExec = streamingExecution as { stream: ReadableStream; execution: any } |
| 410 | const blockId = streamingExec.execution?.blockId |
| 411 | const reader = streamingExec.stream.getReader() |
| 412 | const decoder = new TextDecoder() |
| 413 | |
| 414 | try { |
| 415 | while (true) { |
| 416 | const { done, value } = await reader.read() |
| 417 | if (done) break |
| 418 | const chunk = decoder.decode(value, { stream: true }) |
| 419 | await sendBufferedEvent({ |
| 420 | type: 'stream:chunk', |
| 421 | timestamp: new Date().toISOString(), |
| 422 | executionId, |
| 423 | workflowId, |
| 424 | data: { blockId, chunk }, |
| 425 | }) |
| 426 | } |
| 427 | await sendBufferedEvent({ |
| 428 | type: 'stream:done', |
| 429 | timestamp: new Date().toISOString(), |
| 430 | executionId, |
| 431 | workflowId, |
| 432 | data: { blockId }, |
| 433 | }) |
| 434 | } finally { |
| 435 | try { |
| 436 | reader.releaseLock() |
| 437 | } catch {} |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | const onChildWorkflowInstanceReady = async ( |
| 442 | blockId: string, |
nothing calls this directly
no test coverage detected