chore: sync local workspace changes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { createServer } from 'node:http';
|
||||
import { execFile, spawn } from 'node:child_process';
|
||||
import { access, cp, mkdir, mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises';
|
||||
import { access, chmod, cp, mkdir, mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
@@ -50,8 +50,29 @@ const CODEX_HOME_RUNTIME_PATHS = [
|
||||
'models_cache.json',
|
||||
'version.json',
|
||||
];
|
||||
const CHAT_SESSION_RESOURCE_DIR_MODE = 0o777;
|
||||
const activeCodexExecutions = new Map();
|
||||
|
||||
async function ensureWorldWritableDirectory(absolutePath) {
|
||||
await mkdir(absolutePath, { recursive: true, mode: CHAT_SESSION_RESOURCE_DIR_MODE });
|
||||
await chmod(absolutePath, CHAT_SESSION_RESOURCE_DIR_MODE).catch(() => {});
|
||||
}
|
||||
|
||||
async function ensureWritableChatSessionDirectories(repoPath, sessionId) {
|
||||
const sessionRoot = path.join(repoPath, 'public', '.codex_chat', sessionId);
|
||||
const resourceRoot = path.join(sessionRoot, 'resource');
|
||||
const uploadRoot = path.join(resourceRoot, 'uploads');
|
||||
|
||||
await ensureWorldWritableDirectory(sessionRoot);
|
||||
await ensureWorldWritableDirectory(resourceRoot);
|
||||
await ensureWorldWritableDirectory(uploadRoot);
|
||||
|
||||
return {
|
||||
resourceRoot,
|
||||
uploadRoot,
|
||||
};
|
||||
}
|
||||
|
||||
const commandDefinitions = {
|
||||
test: {
|
||||
label: 'TEST',
|
||||
@@ -539,8 +560,7 @@ async function runCodexLiveExecution(payload, response) {
|
||||
}
|
||||
|
||||
await validateCodexExecutionRuntime(repoPath, codexBin);
|
||||
await mkdir(resourceDir, { recursive: true });
|
||||
await mkdir(uploadDir, { recursive: true });
|
||||
await ensureWritableChatSessionDirectories(repoPath, sessionId);
|
||||
|
||||
const tempDir = await mkdtemp(path.join(tmpdir(), 'command-runner-codex-'));
|
||||
const writableCodexHome = await prepareWritableCodexHome(tempDir);
|
||||
|
||||
Reference in New Issue
Block a user