* Extract system prompt text from the `system` option.
(system?: string | TextBlockParam[])
| 116 | * Extract system prompt text from the `system` option. |
| 117 | */ |
| 118 | function extractSystemText(system?: string | TextBlockParam[]): string { |
| 119 | if (!system) return '' |
| 120 | if (typeof system === 'string') return system |
| 121 | return system |
| 122 | .filter((b): b is { type: 'text'; text: string } => 'text' in b && !!b.text) |
| 123 | .map(b => b.text) |
| 124 | .join('\n\n') |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Convert Anthropic MessageParam[] to a list of {role, content} objects |
no outgoing calls
no test coverage detected