feat(memory): release Mnemo project bridge and schema2 recovery
Official contracts and Windows source CI / windows-source (push) Has been cancelled

This commit is contained in:
Agent Workbench Dev
2026-11-11 03:03:43 +08:00
parent f7705d9634
commit e306f40cae
76 changed files with 10475 additions and 127 deletions
+7 -2
View File
@@ -76,7 +76,8 @@ function sameTarget(target, file) {
return target.title === displayName && target.url === 'file://' + displayName;
}
export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRoot }) {
export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRoot, rollbackInitialization = false }) {
if (typeof rollbackInitialization !== 'boolean' || rollbackInitialization && !handlerRoot) throw new Error('Initialization rollback requires the source-bound current handler root.');
const origin = localUrl(url), original = fs.realpathSync.native(currentRoot), next = fs.realpathSync.native(newRoot);
const originalScript = path.join(original, 'dist-server', 'server.mjs');
const upgradeScript = path.join(next, 'dist-server', 'hot-upgrade.mjs');
@@ -145,7 +146,11 @@ export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRo
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;
const expression = '(() => { try { const module = process.getBuiltinModule("module").createRequire(' + JSON.stringify(upgradeScript) + ')(' + JSON.stringify(upgradeScript) + '); return module.installUpgrade(globalThis.__awUpgradeContext, { appDirectory: ' + JSON.stringify(next) + ' }); } finally { delete globalThis.__awUpgradeContext; } })()';
const restoreScript = rollbackInitialization ? path.join(fs.realpathSync.native(handlerRoot), 'dist-server/hot-upgrade.mjs') : null;
const restore = restoreScript ? ' const restoreModule = process.getBuiltinModule("module").createRequire(' + JSON.stringify(restoreScript) + ')(' + JSON.stringify(restoreScript) + ');'
+ ' restoreModule.rollbackUnchangedUpgrade(globalThis.__awUpgradeContext, { appDirectory: ' + JSON.stringify(fs.realpathSync.native(handlerRoot)) + ' });' : '';
const expression = '(() => { try { const module = process.getBuiltinModule("module").createRequire(' + JSON.stringify(upgradeScript) + ')(' + JSON.stringify(upgradeScript) + ');' + restore
+ ' return module.installUpgrade(globalThis.__awUpgradeContext, { appDirectory: ' + JSON.stringify(next) + ' }); } finally { delete globalThis.__awUpgradeContext; } })()';
const upgraded = await protocol.send('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true });
if (upgraded.exceptionDetails) throw new Error('Runtime upgrade failed: ' + (upgraded.exceptionDetails.exception?.description ?? upgraded.exceptionDetails.text));
const result = upgraded.result.value;