(rawBlocks: RawBlock[], messageContent: string)
| 582 | } |
| 583 | |
| 584 | function normalizeBlocks(rawBlocks: RawBlock[], messageContent: string): PersistedContentBlock[] { |
| 585 | const blocks = rawBlocks.map(normalizeBlock) |
| 586 | const hasAssistantText = blocks.some( |
| 587 | (b) => |
| 588 | b.type === MothershipStreamV1EventType.text && |
| 589 | b.channel !== MothershipStreamV1TextChannel.thinking && |
| 590 | b.content?.trim() |
| 591 | ) |
| 592 | if (!hasAssistantText && messageContent.trim()) { |
| 593 | blocks.push({ |
| 594 | type: MothershipStreamV1EventType.text, |
| 595 | channel: MothershipStreamV1TextChannel.assistant, |
| 596 | content: messageContent, |
| 597 | }) |
| 598 | } |
| 599 | return blocks |
| 600 | } |
| 601 | |
| 602 | export function normalizeMessage(raw: Record<string, unknown>): PersistedMessage { |
| 603 | const msg: PersistedMessage = { |
no test coverage detected