(text: string)
| 102 | } |
| 103 | |
| 104 | export function segmentAssistantStreamingText(text: string): AssistantStreamingSegments { |
| 105 | const { blocks, endsAtBoundary, hasOpenFence } = collectAssistantBlocks(text); |
| 106 | if (blocks.length === 0) { |
| 107 | return { |
| 108 | committed: [], |
| 109 | draft: null, |
| 110 | }; |
| 111 | } |
| 112 | if (hasOpenFence || !endsAtBoundary) { |
| 113 | if (blocks.length === 1) { |
| 114 | return { |
| 115 | committed: [], |
| 116 | draft: blocks[0], |
| 117 | }; |
| 118 | } |
| 119 | return { |
| 120 | committed: blocks.slice(0, -1), |
| 121 | draft: blocks[blocks.length - 1] ?? null, |
| 122 | }; |
| 123 | } |
| 124 | return { |
| 125 | committed: blocks, |
| 126 | draft: null, |
| 127 | }; |
| 128 | } |
nothing calls this directly
no test coverage detected