fix: upgrade directly launched hosts and freeze package QA evidence

This commit is contained in:
Agent Workbench Dev
2026-10-30 14:45:50 +08:00
parent 96de94e722
commit eab5ac077a
7 changed files with 111 additions and 11 deletions
+14 -1
View File
@@ -106,8 +106,21 @@ export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRo
const probe = readUpgradeJson(origin + '/api/health', 15000, 'Observe owned request handler');
probe.catch(() => {});
const event = await within(pausedEvent, 10000, 'Workbench request observation');
const captureExpression = "(() => {"
+ " const currentServer = typeof server !== 'undefined' ? server : typeof server2 !== 'undefined' ? server2 : undefined;"
+ " const currentStore = typeof store !== 'undefined' ? store : typeof store2 !== 'undefined' ? store2 : undefined;"
+ " const currentProvider = typeof provider !== 'undefined' ? provider : typeof provider2 !== 'undefined' ? provider2 : undefined;"
+ " const currentRuntime = typeof runtime !== 'undefined' ? runtime : typeof runtime2 !== 'undefined' ? runtime2 : undefined;"
+ " const currentToken = typeof token !== 'undefined' ? token : typeof token2 !== 'undefined' ? token2 : undefined;"
+ " const currentClients = typeof clients !== 'undefined' ? clients : typeof clients2 !== 'undefined' ? clients2 : undefined;"
+ " const currentStarted = typeof started !== 'undefined' ? started : typeof started2 !== 'undefined' ? started2 : undefined;"
+ " const currentExampleProject = typeof exampleProject !== 'undefined' ? exampleProject : typeof exampleProject2 !== 'undefined' ? exampleProject2 : undefined;"
+ " const currentShutdown = typeof shutdown !== 'undefined' ? shutdown : typeof shutdown2 !== 'undefined' ? shutdown2 : undefined;"
+ " const servers = currentServer ? [currentServer] : process._getActiveHandles().filter(handle => handle?.listening && handle.address?.()?.address === '127.0.0.1' && handle.address?.()?.port === " + new URL(origin).port + ");"
+ " if (servers.length !== 1 || !currentStore || !currentProvider || !currentRuntime || !currentToken || !currentClients || !currentShutdown) throw new Error('The existing Workbench context is incomplete.');"
+ " globalThis.__awUpgradeContext = { server: servers[0], store: currentStore, provider: currentProvider, runtime: currentRuntime, token: currentToken, clients: currentClients, started: currentStarted, exampleProject: currentExampleProject, shutdown: currentShutdown }; return 'context-ready'; })()";
const captured = await protocol.send('Debugger.evaluateOnCallFrame', { callFrameId: event.callFrames[0].callFrameId,
expression: "(() => { const servers = typeof server !== 'undefined' ? [server] : process._getActiveHandles().filter(handle => handle?.listening && handle.address?.()?.address === '127.0.0.1' && handle.address?.()?.port === " + new URL(origin).port + "); if (servers.length !== 1) throw new Error('Owned local server not found uniquely'); globalThis.__awUpgradeContext = { server: servers[0], store, provider, runtime, token, clients, started, exampleProject, shutdown }; return 'context-ready'; })()", returnByValue: true });
expression: captureExpression, returnByValue: true });
if (captured.exceptionDetails || captured.result.value !== 'context-ready') throw new Error('Could not retain the existing runtime objects.');
for (const breakpointId of breakpoints.splice(0)) await protocol.send('Debugger.removeBreakpoint', { breakpointId });
await protocol.send('Debugger.resume'); paused = false; await probe;