| 716 | } |
| 717 | |
| 718 | function toolStatusLabel(stage: ToolUiStage, update: any): string { |
| 719 | if (stage === 'start') return 'started'; |
| 720 | |
| 721 | const statusRaw = `${update?.status ?? update?.state ?? update?.outcome ?? ''}` |
| 722 | .toLowerCase() |
| 723 | .trim(); |
| 724 | |
| 725 | if (stage === 'complete') { |
| 726 | if ( |
| 727 | statusRaw.includes('fail') || |
| 728 | statusRaw.includes('error') || |
| 729 | update?.error |
| 730 | ) { |
| 731 | return 'failed'; |
| 732 | } |
| 733 | if (statusRaw.includes('cancel')) return 'cancelled'; |
| 734 | return 'completed'; |
| 735 | } |
| 736 | |
| 737 | return statusRaw || 'running'; |
| 738 | } |
| 739 | |
| 740 | function extractToolCallId(update: any): string | null { |
| 741 | const candidates = [ |