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