| 757 | } |
| 758 | |
| 759 | function taskResult(output: string): string | undefined { |
| 760 | if (!output.trim()) { |
| 761 | return undefined |
| 762 | } |
| 763 | |
| 764 | const match = output.match(/<task_result>\s*([\s\S]*?)\s*<\/task_result>/) |
| 765 | if (match) { |
| 766 | return match[1].trim() || undefined |
| 767 | } |
| 768 | |
| 769 | const next = output |
| 770 | .split("\n") |
| 771 | .filter((line) => !line.startsWith("task_id:")) |
| 772 | .join("\n") |
| 773 | .trim() |
| 774 | return next || undefined |
| 775 | } |
| 776 | |
| 777 | function scrollTaskFinal(p: ToolProps<typeof TaskTool>): string { |
| 778 | if (p.frame.status === "error") { |