(result: BatchItemResult | undefined)
| 220 | * Returns null if the result is missing, failed, or has no text blocks. |
| 221 | */ |
| 222 | export function extractText(result: BatchItemResult | undefined): string | null { |
| 223 | if (!result || result.status !== 'succeeded' || !result.message) { |
| 224 | return null; |
| 225 | } |
| 226 | |
| 227 | const text = result.message.content |
| 228 | .filter((block): block is Anthropic.TextBlock => block.type === 'text') |
| 229 | .map((block) => block.text) |
| 230 | .join('\n'); |
| 231 | |
| 232 | return text || null; |
| 233 | } |
| 234 | |
| 235 | function sleep(ms: number): Promise<void> { |
| 236 | return new Promise((resolve) => setTimeout(resolve, ms)); |
no outgoing calls
no test coverage detected