* Truncate output if it exceeds the maximum length
(text: string)
| 4557 | * Truncate output if it exceeds the maximum length |
| 4558 | */ |
| 4559 | private truncateOutput(text: string): string { |
| 4560 | if (text.length <= MAX_OUTPUT_LENGTH) return text; |
| 4561 | const truncated = text.slice(0, MAX_OUTPUT_LENGTH); |
| 4562 | const lastNewline = truncated.lastIndexOf('\n'); |
| 4563 | const cutPoint = lastNewline > MAX_OUTPUT_LENGTH * 0.8 ? lastNewline : MAX_OUTPUT_LENGTH; |
| 4564 | return truncated.slice(0, cutPoint) + '\n\n... (output truncated)'; |
| 4565 | } |
| 4566 | |
| 4567 | // ========================================================================= |
| 4568 | // Formatting helpers (compact by default to reduce context usage) |
no outgoing calls
no test coverage detected