(controller)
| 658 | |
| 659 | const trackedStream = new ReadableStream<LanguageModelV3StreamPart>({ |
| 660 | async pull(controller): Promise<void> { |
| 661 | try { |
| 662 | for (;;) { |
| 663 | const { done, value } = await reader.read(); |
| 664 | if (done) { |
| 665 | await finalizeStep({ |
| 666 | output: buildOutput(), |
| 667 | usage, |
| 668 | error: streamError, |
| 669 | rawRequest, |
| 670 | requestHeaders: capturedRequestHeaders, |
| 671 | responseHeaders, |
| 672 | rawResponse: fullStreamChunks, |
| 673 | rawChunks, |
| 674 | }); |
| 675 | controller.close(); |
| 676 | return; |
| 677 | } |
| 678 | |
| 679 | assert(value, "DevTools middleware expected stream value when done=false"); |
| 680 | |
| 681 | if (!collectChunk(value)) { |
| 682 | continue; |
| 683 | } |
| 684 | |
| 685 | controller.enqueue(value); |
| 686 | return; |
| 687 | } |
| 688 | } catch (error) { |
| 689 | await finalizeStep({ |
| 690 | output: buildOutput(), |
| 691 | usage, |
| 692 | error: getErrorMessage(error), |
| 693 | rawRequest, |
| 694 | requestHeaders: capturedRequestHeaders, |
| 695 | responseHeaders, |
| 696 | rawResponse: fullStreamChunks, |
| 697 | rawChunks, |
| 698 | }); |
| 699 | controller.error(error); |
| 700 | } |
| 701 | }, |
| 702 | |
| 703 | async cancel(reason): Promise<void> { |
| 704 | try { |
nothing calls this directly
no test coverage detected