(content: unknown)
| 49 | ] |
| 50 | |
| 51 | function extractRawUserTextContent(content: unknown): string | null { |
| 52 | if (typeof content === 'string') { |
| 53 | return content |
| 54 | } |
| 55 | |
| 56 | if (!Array.isArray(content)) { |
| 57 | return null |
| 58 | } |
| 59 | |
| 60 | const parts = content |
| 61 | .map((block) => { |
| 62 | if (!block || typeof block !== 'object' || Array.isArray(block)) return null |
| 63 | const record = block as Record<string, unknown> |
| 64 | return record.type === 'text' && typeof record.text === 'string' |
| 65 | ? record.text |
| 66 | : null |
| 67 | }) |
| 68 | .filter((text): text is string => text !== null) |
| 69 | |
| 70 | return parts.length > 0 ? parts.join('\n') : null |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Returns true if a JSONL message should be classified as a user-role message |
no outgoing calls
no test coverage detected