( taskId: string, fromOffset: number, maxBytes: number = DEFAULT_MAX_READ_BYTES, )
| 302 | * Reads only from the byte offset, up to maxBytes — never loads the full file. |
| 303 | */ |
| 304 | export async function getTaskOutputDelta( |
| 305 | taskId: string, |
| 306 | fromOffset: number, |
| 307 | maxBytes: number = DEFAULT_MAX_READ_BYTES, |
| 308 | ): Promise<{ content: string; newOffset: number }> { |
| 309 | try { |
| 310 | const result = await readFileRange( |
| 311 | getTaskOutputPath(taskId), |
| 312 | fromOffset, |
| 313 | maxBytes, |
| 314 | ) |
| 315 | if (!result) { |
| 316 | return { content: '', newOffset: fromOffset } |
| 317 | } |
| 318 | return { |
| 319 | content: result.content, |
| 320 | newOffset: fromOffset + result.bytesRead, |
| 321 | } |
| 322 | } catch (e) { |
| 323 | const code = getErrnoCode(e) |
| 324 | if (code === 'ENOENT') { |
| 325 | return { content: '', newOffset: fromOffset } |
| 326 | } |
| 327 | logError(e) |
| 328 | return { content: '', newOffset: fromOffset } |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * Get output for a task, reading the tail of the file. |
no test coverage detected