Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): use randomUUID for Windows grok prompt temp files

[._.]/ Adam Eivy9bd4c87bfa16
diff --git a/server/lib/grok.js b/server/lib/grok.js
index de76f25f3e..4c5e65c7cd 100644
--- a/server/lib/grok.js
+++ b/server/lib/grok.js
@@ -24,6 +24,7 @@
import os from 'os';
import { writeFileSync, unlinkSync } from 'fs';
import { join } from 'path';
+import { randomUUID } from 'crypto';
import { hasModelFlag, commandBasename } from './providerModels.js';
const NOOP_CLEANUP = () => {};
@@ -145,7 +146,11 @@ export function prepareGrokPromptFile(args, prompt) {
if (process.platform !== 'win32') return { args, useStdin: true, cleanup: NOOP_CLEANUP };
const idx = args.indexOf(GROK_STDIN_PROMPT_PATH);
if (idx <= 0 || args[idx - 1] !== '--prompt-file') return { args, useStdin: true, cleanup: NOOP_CLEANUP };
- const file = join(os.tmpdir(), `grok-prompt-${process.pid}-${Date.now()}.txt`);
+ // A collision-resistant name — concurrent grok runs in the same process (e.g.
+ // parallel CoS agents / pipeline stages) can reach here in the same millisecond,
+ // so a pid+timestamp name would clobber each other's prompt or delete a file a
+ // sibling still needs. randomUUID is unique per call (server-side Node crypto).
+ const file = join(os.tmpdir(), `grok-prompt-${process.pid}-${randomUUID()}.txt`);
writeFileSync(file, typeof prompt === 'string' ? prompt : '', 'utf8');
const rewritten = [...args];
rewritten[idx] = file;