* Extract text from first user message for fingerprint computation.
(messages: MessageParam[])
| 67 | * Extract text from first user message for fingerprint computation. |
| 68 | */ |
| 69 | function extractFirstUserMessageText(messages: MessageParam[]): string { |
| 70 | const firstUserMessage = messages.find(m => m.role === 'user') |
| 71 | if (!firstUserMessage) return '' |
| 72 | |
| 73 | const content = firstUserMessage.content |
| 74 | if (typeof content === 'string') return content |
| 75 | |
| 76 | // Array of content blocks - find first text block |
| 77 | const textBlock = content.find(block => block.type === 'text') |
| 78 | return textBlock?.type === 'text' ? textBlock.text : '' |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Lightweight API wrapper for "side queries" outside the main conversation loop. |