(
blockId: string,
content: string,
options: { selectedOutputKey?: string; selectedOutputBytes?: number } = {}
)
| 372 | } |
| 373 | |
| 374 | const sendChunk = ( |
| 375 | blockId: string, |
| 376 | content: string, |
| 377 | options: { selectedOutputKey?: string; selectedOutputBytes?: number } = {} |
| 378 | ) => { |
| 379 | const separator = state.processedOutputs.size > 0 ? '\n\n' : '' |
| 380 | const chunk = separator + content |
| 381 | if (options.selectedOutputKey) { |
| 382 | const selectedOutputBytes = |
| 383 | options.selectedOutputBytes ?? Buffer.byteLength(chunk, 'utf8') |
| 384 | const nextSelectedOutputBytes = state.selectedOutputBytes + selectedOutputBytes |
| 385 | assertInlineMaterializationSize(nextSelectedOutputBytes, MAX_INLINE_MATERIALIZATION_BYTES) |
| 386 | state.selectedOutputBytes = nextSelectedOutputBytes |
| 387 | state.streamedSelectedOutputKeys.add(options.selectedOutputKey) |
| 388 | } |
| 389 | controller.enqueue(encodeSSE({ blockId, chunk })) |
| 390 | state.processedOutputs.add(blockId) |
| 391 | } |
| 392 | |
| 393 | /** |
| 394 | * Callback for handling streaming execution events. |
no test coverage detected