chore: rebuild CentOS7 release package
This commit is contained in:
134
server.js
134
server.js
@@ -6309,7 +6309,7 @@ wss.on('connection', (ws, req) => {
|
||||
handleComposerSuggestions(ws, msg);
|
||||
break;
|
||||
case 'abort':
|
||||
handleAbort(ws);
|
||||
handleAbort(ws, msg);
|
||||
break;
|
||||
case 'new_session':
|
||||
handleNewSession(ws, msg);
|
||||
@@ -7831,9 +7831,26 @@ function handleDetachView(ws) {
|
||||
wsSessionMap.delete(ws);
|
||||
}
|
||||
|
||||
function handleAbort(ws) {
|
||||
const sessionId = wsSessionMap.get(ws);
|
||||
function bindAbortSessionToWs(sessionId, ws) {
|
||||
if (!sessionId || !ws) return;
|
||||
const entries = [
|
||||
activeProcesses.get(sessionId),
|
||||
activeCodexAppTurns.get(sessionId),
|
||||
activeCodexAppGoalCommands.get(sessionId),
|
||||
].filter(Boolean);
|
||||
if (entries.length > 0) detachWsFromActiveRuntimes(ws);
|
||||
wsSessionMap.set(ws, sessionId);
|
||||
for (const entry of entries) {
|
||||
entry.ws = ws;
|
||||
entry.wsDisconnectTime = null;
|
||||
}
|
||||
}
|
||||
|
||||
function handleAbort(ws, msg = {}) {
|
||||
const requestedSessionId = sanitizeId(msg?.sessionId || '');
|
||||
const sessionId = requestedSessionId || wsSessionMap.get(ws);
|
||||
if (!sessionId) return;
|
||||
bindAbortSessionToWs(sessionId, ws);
|
||||
if (handleCodexAppAbortSession(sessionId, ws)) return;
|
||||
if (cancelCodexAppGoalCommand(sessionId, ws)) return;
|
||||
const entry = activeProcesses.get(sessionId);
|
||||
@@ -8300,9 +8317,17 @@ function detachWsFromActiveRuntimes(ws, options = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
function codexAppRuntimeThreadId(params = {}) {
|
||||
return params.threadId || params.thread?.id || params.item?.threadId || null;
|
||||
}
|
||||
|
||||
function codexAppRuntimeTurnId(params = {}) {
|
||||
return params.turnId || params.turn?.id || params.item?.turnId || null;
|
||||
}
|
||||
|
||||
function findCodexAppEntryByRuntime(params = {}) {
|
||||
const threadId = params.threadId || params.thread?.id || null;
|
||||
const turnId = params.turnId || params.turn?.id || null;
|
||||
const threadId = codexAppRuntimeThreadId(params);
|
||||
const turnId = codexAppRuntimeTurnId(params);
|
||||
if (threadId) {
|
||||
for (const [sessionId, entry] of activeCodexAppTurns) {
|
||||
if (entry.threadId === threadId) return { sessionId, entry };
|
||||
@@ -8316,6 +8341,95 @@ function findCodexAppEntryByRuntime(params = {}) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function findCodexAppSessionByThreadId(threadId) {
|
||||
const targetThreadId = String(threadId || '').trim();
|
||||
if (!targetThreadId) return null;
|
||||
try {
|
||||
for (const file of fs.readdirSync(SESSIONS_DIR)) {
|
||||
if (!file.endsWith('.json')) continue;
|
||||
const sessionId = sanitizeId(file.slice(0, -5));
|
||||
if (!sessionId) continue;
|
||||
const session = loadSession(sessionId);
|
||||
if (!session || !isCodexAppSession(session)) continue;
|
||||
if (getRuntimeSessionId(session) === targetThreadId) return { sessionId: session.id, session };
|
||||
}
|
||||
} catch (err) {
|
||||
plog('WARN', 'codex_app_thread_session_lookup_failed', {
|
||||
threadId: targetThreadId,
|
||||
error: err?.message || String(err || ''),
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function isCodexAppAdoptableRuntimeMethod(method) {
|
||||
return method === 'turn/started'
|
||||
|| method === 'item/started'
|
||||
|| method === 'item/agentMessage/delta'
|
||||
|| method === 'item/commandExecution/outputDelta'
|
||||
|| method === 'item/fileChange/patchUpdated'
|
||||
|| method === 'item/mcpToolCall/progress'
|
||||
|| method === 'plan/updated'
|
||||
|| method === 'turn/plan/updated'
|
||||
|| method === 'item/plan/updated'
|
||||
|| method === 'item/todoList/updated'
|
||||
|| method === 'item/reasoning/summaryTextDelta'
|
||||
|| method === 'item/reasoning/textDelta'
|
||||
|| method === 'item/completed'
|
||||
|| method === 'item/commandExecution/requestApproval'
|
||||
|| method === 'item/fileChange/requestApproval'
|
||||
|| method === 'item/permissions/requestApproval'
|
||||
|| method === 'item/tool/requestApproval'
|
||||
|| method === 'item/tool/requestUserInput'
|
||||
|| method === 'item/tool/call';
|
||||
}
|
||||
|
||||
function adoptCodexAppUnroutedTurn(params = {}, method = '') {
|
||||
if (!isCodexAppAdoptableRuntimeMethod(method)) return null;
|
||||
const threadId = codexAppRuntimeThreadId(params);
|
||||
const turnId = codexAppRuntimeTurnId(params);
|
||||
if (!threadId || !turnId) return null;
|
||||
|
||||
const matched = findCodexAppSessionByThreadId(threadId);
|
||||
if (!matched?.session) return null;
|
||||
const existing = activeCodexAppTurns.get(matched.sessionId);
|
||||
if (existing) return { sessionId: matched.sessionId, entry: existing };
|
||||
|
||||
const entry = {
|
||||
ws: findViewingSessionWs(matched.sessionId),
|
||||
agent: 'codexapp',
|
||||
cwd: matched.session.cwd || getDefaultSessionCwd(),
|
||||
threadId,
|
||||
expectedThreadId: threadId,
|
||||
turnId,
|
||||
fullText: '',
|
||||
toolCalls: [],
|
||||
toolOutputDeltas: new Map(),
|
||||
agentMessageItems: new Map(),
|
||||
mcpContext: {},
|
||||
codexRetry: null,
|
||||
lastUsage: null,
|
||||
lastError: null,
|
||||
errorSent: false,
|
||||
crossConversationReplyRequestId: null,
|
||||
retryRequest: null,
|
||||
clientUserMessageId: crypto.randomUUID(),
|
||||
startedAt: new Date().toISOString(),
|
||||
recoveredFromNotification: true,
|
||||
};
|
||||
activeCodexAppTurns.set(matched.sessionId, entry);
|
||||
persistCodexAppTurnState(matched.sessionId, entry, { immediate: true });
|
||||
broadcastSessionList();
|
||||
plog('INFO', 'codex_app_unrouted_turn_adopted', {
|
||||
sessionId: matched.sessionId.slice(0, 8),
|
||||
threadId,
|
||||
turnId,
|
||||
method,
|
||||
hasViewer: !!entry.ws,
|
||||
});
|
||||
return { sessionId: matched.sessionId, entry };
|
||||
}
|
||||
|
||||
function parseMaybeJsonObject(value) {
|
||||
if (value && typeof value === 'object' && !Array.isArray(value)) return value;
|
||||
if (typeof value !== 'string') return null;
|
||||
@@ -8638,10 +8752,12 @@ function processCcwebMcpChildNotification(child, notification) {
|
||||
return { changed: false, done: false };
|
||||
}
|
||||
|
||||
function findCodexAppRouteByRuntime(params = {}) {
|
||||
function findCodexAppRouteByRuntime(params = {}, method = '') {
|
||||
const parent = findCodexAppEntryByRuntime(params);
|
||||
if (parent) return { ...parent, role: 'parent' };
|
||||
const threadId = params.threadId || params.thread?.id || null;
|
||||
const recoveredParent = adoptCodexAppUnroutedTurn(params, method);
|
||||
if (recoveredParent) return { ...recoveredParent, role: 'parent' };
|
||||
const threadId = codexAppRuntimeThreadId(params);
|
||||
if (threadId && ccwebMcpChildThreads.has(threadId)) {
|
||||
const child = ccwebMcpChildThreads.get(threadId);
|
||||
return {
|
||||
@@ -8655,7 +8771,7 @@ function findCodexAppRouteByRuntime(params = {}) {
|
||||
}
|
||||
|
||||
function handleCodexAppNotification(notification) {
|
||||
const routed = findCodexAppRouteByRuntime(notification?.params || {});
|
||||
const routed = findCodexAppRouteByRuntime(notification?.params || {}, notification?.method || '');
|
||||
if (handleCodexAppMcpStartupStatusNotification(notification, routed)) return;
|
||||
if (!routed) {
|
||||
plog('INFO', 'codex_app_notification_unrouted', {
|
||||
@@ -9250,7 +9366,7 @@ function resolvePendingCodexAppApprovalsForSession(sessionId) {
|
||||
function handleCodexAppServerRequest(request) {
|
||||
const method = request?.method || '';
|
||||
const params = request?.params || {};
|
||||
const routed = findCodexAppEntryByRuntime(params);
|
||||
const routed = findCodexAppRouteByRuntime(params, method);
|
||||
const dynamicToolResponse = method === 'item/tool/call'
|
||||
? handleCodexAppDynamicToolCall(routed, params)
|
||||
: null;
|
||||
|
||||
Reference in New Issue
Block a user