Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions electron/services/providers/ClaudeProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'node:fs'
import path from 'node:path'
import os from 'node:os'
import { randomUUID } from 'node:crypto'
import { spawn, execSync } from 'node:child_process'
import { getDb } from '../../db/db'
import * as SecureKey from '../SecureKeyService'
Expand Down Expand Up @@ -221,8 +222,8 @@ export const ClaudeProvider: ProviderInterface = {
sections.push('</daemon-context>')

const contextContent = sections.filter(Boolean).join('\n')
const contextFilePath = path.join(os.tmpdir(), `daemon_agent_${agent.id}_${Date.now()}.txt`)
fs.writeFileSync(contextFilePath, contextContent, 'utf8')
const contextFilePath = path.join(os.tmpdir(), `daemon_agent_${agent.id}_${randomUUID()}.txt`)
fs.writeFileSync(contextFilePath, contextContent, { encoding: 'utf8', mode: 0o600 })

bootstrapAgentMcps(project.path, agent.mcps)

Expand Down Expand Up @@ -359,8 +360,8 @@ async function runPromptViaCli(

let systemPromptFile: string | null = null
if (systemPrompt) {
systemPromptFile = path.join(os.tmpdir(), `daemon_prompt_${Date.now()}.txt`)
fs.writeFileSync(systemPromptFile, systemPrompt, 'utf8')
systemPromptFile = path.join(os.tmpdir(), `daemon_prompt_${randomUUID()}.txt`)
fs.writeFileSync(systemPromptFile, systemPrompt, { encoding: 'utf8', mode: 0o600 })
args.push('--append-system-prompt-file', systemPromptFile)
}

Expand Down
11 changes: 6 additions & 5 deletions electron/services/providers/CodexProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'node:fs'
import path from 'node:path'
import os from 'node:os'
import { randomUUID } from 'node:crypto'
import { spawn, execSync } from 'node:child_process'
import { getDb } from '../../db/db'
import * as SecureKey from '../SecureKeyService'
Expand Down Expand Up @@ -191,8 +192,8 @@ export const CodexProvider: ProviderInterface = {
sections.push('</daemon-context>')

const contextContent = sections.filter(Boolean).join('\n')
const contextFilePath = path.join(os.tmpdir(), `daemon_codex_${agent.id}_${Date.now()}.txt`)
fs.writeFileSync(contextFilePath, contextContent, 'utf8')
const contextFilePath = path.join(os.tmpdir(), `daemon_codex_${agent.id}_${randomUUID()}.txt`)
fs.writeFileSync(contextFilePath, contextContent, { encoding: 'utf8', mode: 0o600 })

// Resolve model — map Claude models to Codex equivalents
const model = resolveCodexModel(agent.model)
Expand Down Expand Up @@ -232,7 +233,7 @@ export const CodexProvider: ProviderInterface = {
const codexPath = this.resolvePath()
const resolvedModel = resolveCodexModel(model)

const outputFile = path.join(os.tmpdir(), `daemon_codex_out_${Date.now()}.txt`)
const outputFile = path.join(os.tmpdir(), `daemon_codex_out_${randomUUID()}.txt`)

const args: string[] = [
'exec',
Expand All @@ -245,8 +246,8 @@ export const CodexProvider: ProviderInterface = {
// Write system prompt to temp file and pass via -c instructions_file
let contextFile: string | null = null
if (systemPrompt) {
contextFile = path.join(os.tmpdir(), `daemon_codex_prompt_${Date.now()}.txt`)
fs.writeFileSync(contextFile, systemPrompt, 'utf8')
contextFile = path.join(os.tmpdir(), `daemon_codex_prompt_${randomUUID()}.txt`)
fs.writeFileSync(contextFile, systemPrompt, { encoding: 'utf8', mode: 0o600 })
args.push('-c', `instructions_file=${contextFile}`)
}

Expand Down