* Extracts searchable text content from a message.
(message: SerializedMessage)
| 57 | * Extracts searchable text content from a message. |
| 58 | */ |
| 59 | function extractMessageText(message: SerializedMessage): string { |
| 60 | if (message.type !== 'user' && message.type !== 'assistant') { |
| 61 | return '' |
| 62 | } |
| 63 | |
| 64 | const content = 'message' in message ? message.message?.content : undefined |
| 65 | if (!content) return '' |
| 66 | |
| 67 | if (typeof content === 'string') { |
| 68 | return content |
| 69 | } |
| 70 | |
| 71 | if (Array.isArray(content)) { |
| 72 | return content |
| 73 | .map(block => { |
| 74 | if (typeof block === 'string') return block |
| 75 | if ('text' in block && typeof block.text === 'string') return block.text |
| 76 | return '' |
| 77 | }) |
| 78 | .filter(Boolean) |
| 79 | .join(' ') |
| 80 | } |
| 81 | |
| 82 | return '' |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Extracts a truncated transcript from session messages. |
nothing calls this directly
no outgoing calls
no test coverage detected