MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / initTaskOutput

Function initTaskOutput

source code/utils/task/diskOutput.ts:402–423  ·  view source on GitHub ↗
(taskId: string)

Source from the content-addressed store, hash-verified

400 * Creates an empty file to ensure the path exists.
401 */
402export function initTaskOutput(taskId: string): Promise<string> {
403 return track(
404 (async () => {
405 await ensureOutputDir()
406 const outputPath = getTaskOutputPath(taskId)
407 // SECURITY: O_NOFOLLOW prevents symlink-following attacks from the sandbox.
408 // O_EXCL ensures we create a new file and fail if something already exists at this path.
409 // On Windows, use string flags — numeric O_EXCL can produce EINVAL through libuv.
410 const fh = await open(
411 outputPath,
412 process.platform === 'win32'
413 ? 'wx'
414 : fsConstants.O_WRONLY |
415 fsConstants.O_CREAT |
416 fsConstants.O_EXCL |
417 O_NOFOLLOW,
418 )
419 await fh.close()
420 return outputPath
421 })(),
422 )
423}
424
425/**
426 * Initialize output file as a symlink to another file (e.g., agent transcript).

Callers 3

initTaskOutputAsSymlinkFunction · 0.85
registerRemoteAgentTaskFunction · 0.85

Calls 5

trackFunction · 0.85
ensureOutputDirFunction · 0.85
getTaskOutputPathFunction · 0.85
openFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected