Use unique temp file names for Claude pipe
This commit is contained in:
parent
9c078ab2a4
commit
8eabd31442
|
|
@ -334,12 +334,13 @@ export async function exec(workdir: string, command: string): Promise<{ exitCode
|
|||
|
||||
/** Pipe input text to Claude in the container with a prompt, returning the output. */
|
||||
export async function claudePipe(input: string, prompt: string): Promise<{ exitCode: number; stdout: string; stderr: string }> {
|
||||
const tmpPath = join(homedir(), '.sandlot', '.claude-pipe-tmp')
|
||||
const tmpName = `.claude-pipe-${crypto.randomUUID()}`
|
||||
const tmpPath = join(homedir(), '.sandlot', tmpName)
|
||||
try {
|
||||
await Bun.write(tmpPath, input)
|
||||
return await exec(
|
||||
join(homedir(), '.sandlot'),
|
||||
`cat /sandlot/.claude-pipe-tmp | claude -p "${prompt.replace(/"/g, '\\"')}"`,
|
||||
`cat /sandlot/${tmpName} | claude -p "${prompt.replace(/"/g, '\\"')}"`,
|
||||
)
|
||||
} finally {
|
||||
await Bun.file(tmpPath).unlink().catch(() => {})
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user