feat: refine codex live chat flow

This commit is contained in:
2026-04-24 21:02:01 +09:00
parent d53532508b
commit 63e5d263a7
18 changed files with 1747 additions and 297 deletions

View File

@@ -505,6 +505,7 @@ async function runCodexLiveExecution(payload, response) {
const resourceDir = path.join(repoPath, 'public', '.codex_chat', sessionId, 'resource');
const uploadDir = path.join(resourceDir, 'uploads');
const codexBin = process.env.SERVER_COMMAND_RUNNER_CODEX_BIN?.trim() || process.env.PLAN_CODEX_BIN?.trim() || 'codex';
const configuredMaxExecutionMs = resolveCodexLiveMaxExecutionMs(payload?.maxExecutionSeconds);
if (!requestId || !sessionId || !prompt.trim()) {
sendJson(response, 400, {
@@ -619,9 +620,9 @@ async function runCodexLiveExecution(payload, response) {
executionTimer = setTimeout(() => {
requestTermination(
`Codex Live 실행이 ${Math.round(CODEX_LIVE_MAX_EXECUTION_MS / 1000)}초를 넘어 중단되었습니다.`,
`Codex Live 실행이 ${Math.round(configuredMaxExecutionMs / 1000)}초를 넘어 중단되었습니다.`,
);
}, CODEX_LIVE_MAX_EXECUTION_MS);
}, configuredMaxExecutionMs);
executionTimer.unref?.();
refreshIdleTimer();
@@ -758,6 +759,14 @@ async function runCodexLiveExecution(payload, response) {
child.stdin?.end(prompt);
}
function resolveCodexLiveMaxExecutionMs(value) {
if (typeof value !== 'number' || !Number.isFinite(value)) {
return CODEX_LIVE_MAX_EXECUTION_MS;
}
return Math.max(CODEX_LIVE_IDLE_TIMEOUT_MS, Math.min(7_200_000, Math.max(60_000, Math.round(value * 1000))));
}
function isAuthorized(request) {
const token = String(request.headers['x-access-token'] ?? '').trim();
return token.length > 0 && token === accessToken;