( output: string, taskId: string, )
| 20 | * the last N characters that fit within the limit. |
| 21 | */ |
| 22 | export function formatTaskOutput( |
| 23 | output: string, |
| 24 | taskId: string, |
| 25 | ): { content: string; wasTruncated: boolean } { |
| 26 | const maxLen = getMaxTaskOutputLength() |
| 27 | |
| 28 | if (output.length <= maxLen) { |
| 29 | return { content: output, wasTruncated: false } |
| 30 | } |
| 31 | |
| 32 | const filePath = getTaskOutputPath(taskId) |
| 33 | const header = `[Truncated. Full output: ${filePath}]\n\n` |
| 34 | const availableSpace = maxLen - header.length |
| 35 | const truncated = output.slice(-availableSpace) |
| 36 | |
| 37 | return { content: header + truncated, wasTruncated: true } |
| 38 | } |
| 39 |
no test coverage detected