( blocks: readonly T[], delta: string )
| 47 | } |
| 48 | |
| 49 | export function appendPlanDraftDelta<T extends BlockWithType>( |
| 50 | blocks: readonly T[], |
| 51 | delta: string |
| 52 | ): Array<T | PlanDraftContentBlock> { |
| 53 | const nextBlocks = blocks.map(cloneBlock) as Array<T | PlanDraftContentBlock> |
| 54 | const lastBlock = nextBlocks[nextBlocks.length - 1] |
| 55 | if (isPlanDraftBlock(lastBlock)) { |
| 56 | lastBlock.text += delta |
| 57 | } else { |
| 58 | nextBlocks.push({ type: 'plan_draft', version: 1, status: 'streaming', text: delta }) |
| 59 | } |
| 60 | return nextBlocks |
| 61 | } |
| 62 | |
| 63 | export function replacePlanDraftWithPlan<T extends BlockWithType>( |
| 64 | blocks: readonly T[], |
no test coverage detected