(entry: MakaPiToolEntry)
| 713 | } |
| 714 | |
| 715 | function toolInputSummary(entry: MakaPiToolEntry): string { |
| 716 | const input = entry.input; |
| 717 | const obj = |
| 718 | input !== null && typeof input === 'object' ? (input as Record<string, unknown>) : undefined; |
| 719 | switch (entry.toolName) { |
| 720 | case 'Bash': { |
| 721 | const command = obj?.command; |
| 722 | if (typeof command === 'string' && command.trim()) { |
| 723 | // Agents often lead with `#` comment lines; the row names what the |
| 724 | // command does, so show the first real command line when one exists. |
| 725 | const firstRealLine = command |
| 726 | .split('\n') |
| 727 | .map((line) => line.trim()) |
| 728 | .find((line) => line !== '' && !line.startsWith('#')); |
| 729 | return `$ ${firstRealLine ?? command.split('\n')[0]!.trim()}`; |
| 730 | } |
| 731 | break; |
| 732 | } |
| 733 | case 'Read': { |
| 734 | const path = obj?.path; |
| 735 | if (typeof path === 'string' && path.trim()) { |
| 736 | const parts = [path]; |
| 737 | if (typeof obj?.offset === 'number') parts.push(`offset ${obj.offset}`); |
| 738 | if (typeof obj?.limit === 'number') parts.push(`limit ${obj.limit}`); |
| 739 | return parts.join(' '); |
| 740 | } |
| 741 | break; |
| 742 | } |
| 743 | case 'WriteStdin': { |
| 744 | const parts: string[] = []; |
| 745 | const input = readWriteStdinInputPreview(obj); |
| 746 | if (input) parts.push(input.truncated ? `${input.text}… · ${input.bytes} bytes` : input.text); |
| 747 | if (obj?.size && typeof obj.size === 'object') { |
| 748 | const size = obj.size as { cols?: unknown; rows?: unknown }; |
| 749 | if (typeof size.cols === 'number' && typeof size.rows === 'number') { |
| 750 | parts.push(`${size.cols}x${size.rows}`); |
| 751 | } |
| 752 | } |
| 753 | if (parts.length > 0) return parts.join(' · '); |
| 754 | if (typeof obj?.ref === 'string') return obj.ref; |
| 755 | break; |
| 756 | } |
| 757 | case 'Write': |
| 758 | case 'Edit': { |
| 759 | const path = obj?.path; |
| 760 | if (typeof path === 'string' && path.trim()) return path; |
| 761 | break; |
| 762 | } |
| 763 | case 'Grep': { |
| 764 | const pattern = obj?.pattern; |
| 765 | if (typeof pattern === 'string' && pattern.trim()) { |
| 766 | const parts = [pattern]; |
| 767 | if (typeof obj?.path === 'string' && obj.path.trim()) parts.push(`in ${obj.path}`); |
| 768 | if (typeof obj?.glob === 'string' && obj.glob.trim()) parts.push(`glob ${obj.glob}`); |
| 769 | return parts.join(' '); |
| 770 | } |
| 771 | break; |
| 772 | } |
no test coverage detected