chore: sync local workspace changes

This commit is contained in:
2026-05-07 11:03:47 +09:00
parent 2df0ba30cb
commit 82c0d8a197
217 changed files with 44873 additions and 1678 deletions

View File

@@ -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);

View File

@@ -23,6 +23,20 @@ const mimeTypes = {
'.woff2': 'font/woff2',
};
function resolveCacheControl(resolvedPath, extension) {
const normalizedPath = resolvedPath.replace(/\\/g, '/');
if (extension === '.html') {
return 'no-cache';
}
if (normalizedPath.endsWith('/sw.js') || extension === '.webmanifest') {
return 'no-store, no-cache, max-age=0, must-revalidate';
}
return 'public, max-age=31536000, immutable';
}
function looksLikeStaticAsset(requestedPath) {
const normalizedPath = requestedPath.split('?')[0] ?? requestedPath;
const extension = extname(normalizedPath);
@@ -135,7 +149,7 @@ const server = createServer(async (request, response) => {
response.writeHead(200, {
'Content-Type': contentType,
'Cache-Control': extension === '.html' ? 'no-cache' : 'public, max-age=31536000, immutable',
'Cache-Control': resolveCacheControl(resolvedPath, extension),
});
createReadStream(resolvedPath).pipe(response);