MCPcopy
hub / github.com/codeaashu/claude-code / initTaskOutput

Function initTaskOutput

src/utils/task/diskOutput.ts:400–421  ·  view source on GitHub ↗
(taskId: string)

Source from the content-addressed store, hash-verified

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