(toolResult: unknown)
| 234 | } |
| 235 | |
| 236 | function extractToolResultText(toolResult: unknown): string | null { |
| 237 | if (!isRecord(toolResult)) return null |
| 238 | if (typeof toolResult.error === 'string') return toolResult.error |
| 239 | if (isRecord(toolResult.error) && typeof toolResult.error.message === 'string') return toolResult.error.message |
| 240 | if (Array.isArray(toolResult.content)) { |
| 241 | return toolResult.content |
| 242 | .map((part) => (isRecord(part) && part.type === 'text' && typeof part.text === 'string' ? part.text : '')) |
| 243 | .join('\n') |
| 244 | .trim() |
| 245 | } |
| 246 | return null |
| 247 | } |
| 248 | |
| 249 | export function toRenderOnlyToolErrorBlock( |
| 250 | toolName: string | undefined, |
no test coverage detected