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