修复 Codex App MCP 重载与线程库存恢复

This commit is contained in:
shiyue
2026-09-15 13:58:38 +08:00
parent a1e66c08f1
commit c38c937c05
4 changed files with 211 additions and 24 deletions

View File

@@ -1170,6 +1170,9 @@ function handleRequest(message) {
}
if (method === 'mcpServerStatus/list') {
const thread = ensureThread(params.threadId, params);
const projectMcpConfigured = Boolean(thread.config?.['mcp_servers.reg-app-project'])
|| thread.staleProjectMcpInventoryWarmup === true;
if (thread.staleProjectMcpInventoryWarmup === true) thread.staleProjectMcpInventoryWarmup = false;
send({
id,
result: {
@@ -1188,7 +1191,7 @@ function handleRequest(message) {
},
},
},
{
...(projectMcpConfigured ? [{
name: 'reg-app-project',
authStatus: 'unsupported',
resources: [],
@@ -1201,7 +1204,7 @@ function handleRequest(message) {
inputSchema: { type: 'object' },
},
},
},
}] : []),
{
name: 'reg-runtime-only',
authStatus: 'unsupported',
@@ -1218,13 +1221,19 @@ function handleRequest(message) {
},
],
nextCursor: null,
threadId: thread.id,
},
});
return;
}
if (method === 'thread/start') {
const thread = ensureThread(null, params);
if (process.env.MOCK_CODEX_APP_STALE_PROJECT_MCP === '1'
&& String(params.cwd || '').includes('codexapp-stale-mcp')
&& params.config?.['mcp_servers.reg-app-project']) {
thread.staleProjectMcpConfig = params.config['mcp_servers.reg-app-project'];
thread.staleProjectMcpInventoryWarmup = true;
delete thread.config['mcp_servers.reg-app-project'];
}
thread.lastThreadConfigMethod = 'thread/start';
send({ id, result: { thread: threadPayload(thread), model: params.model || 'gpt-5.5', cwd: thread.cwd, modelProvider: 'mock', approvalPolicy: params.approvalPolicy || 'never', approvalsReviewer: 'user', sandbox: params.sandbox || 'danger-full-access' } });
return;