MCPcopy
hub / github.com/claude-code-best/claude-code / writeCapabilityFile

Function writeCapabilityFile

src/utils/udsMessaging.ts:243–266  ·  view source on GitHub ↗
(
  socket: string,
  token: string,
)

Source from the content-addressed store, hash-verified

241}
242
243async function writeCapabilityFile(
244 socket: string,
245 token: string,
246): Promise<void> {
247 const dir = getCapabilityDir()
248 await assertPrivateCapabilityDir(dir)
249 const target = getCapabilityPath(socket)
250 const temp = `${target}.${process.pid}.${randomBytes(8).toString('hex')}.tmp`
251 try {
252 await writePrivateFileExclusive(
253 temp,
254 jsonStringify({ socketPath: socket, authToken: token }),
255 )
256 await rename(temp, target)
257 } catch (error) {
258 try {
259 await unlink(temp)
260 } catch {
261 // Temp file may not exist if exclusive creation failed.
262 }
263 throw error
264 }
265 capabilityFilePath = target
266}
267
268export async function readUdsCapabilityToken(
269 socket: string,

Callers 1

startUdsMessagingFunction · 0.85

Calls 8

getCapabilityDirFunction · 0.85
getCapabilityPathFunction · 0.85
jsonStringifyFunction · 0.85
renameFunction · 0.85
unlinkFunction · 0.85
toStringMethod · 0.65

Tested by

no test coverage detected