release: validate portable Node npm host and preserve live connection in 1.1.0 upgrade

This commit is contained in:
Agent Workbench Dev
2026-10-29 15:20:28 +08:00
parent 6d3a4c6705
commit 04c93eafec
12 changed files with 465 additions and 12 deletions
+6 -2
View File
@@ -18,8 +18,8 @@ for (const target of [portableRoot, sourceRoot]) {
fs.mkdirSync(target, { recursive: true });
}
const portableFiles = ['dist-client', 'dist-server', 'docs', 'examples', 'README.md', 'CHANGELOG.md', 'DESIGN.md', 'Start-Workbench.cmd', 'Stop-Workbench.cmd'];
const sourceFiles = ['src', 'public', 'scripts', 'tests', 'docs', 'examples', 'package.json', 'package-lock.json', 'vite.config.ts', 'tsconfig.json', 'index.html', '.gitignore', 'README.md', 'CHANGELOG.md', 'DESIGN.md', 'task_plan.md', 'findings.md', 'progress.md', 'Start-Workbench.cmd', 'Stop-Workbench.cmd'];
const portableFiles = ['dist-client', 'dist-server', 'docs', 'examples', 'benchmarks', 'research', 'README.md', 'CHANGELOG.md', 'DESIGN.md', 'AGENTS.md', 'Start-Workbench.cmd', 'Stop-Workbench.cmd'];
const sourceFiles = ['src', 'public', 'scripts', 'tests', 'docs', 'examples', 'benchmarks', 'research', 'package.json', 'package-lock.json', 'vite.config.ts', 'tsconfig.json', 'index.html', '.gitignore', 'README.md', 'CHANGELOG.md', 'DESIGN.md', 'AGENTS.md', 'task_plan.md', 'findings.md', 'progress.md', 'Start-Workbench.cmd', 'Stop-Workbench.cmd'];
const copyTree = (source, destination) => fs.cpSync(source, destination, { recursive: true, filter: (from, to) => {
if (!fs.statSync(from).isFile() || !fs.existsSync(to)) return true;
return !fs.readFileSync(from).equals(fs.readFileSync(to));
@@ -39,6 +39,9 @@ fs.mkdirSync(path.join(portableRoot, 'runtime'), { recursive: true });
const runtimeDestination = path.join(portableRoot, 'runtime', 'node.exe');
const digest = file => createHash('sha256').update(fs.readFileSync(file)).digest('hex');
if (!fs.existsSync(runtimeDestination) || digest(runtimeDestination) !== digest(nodeBinary)) fs.copyFileSync(nodeBinary, runtimeDestination);
const npmRoot = path.join(path.dirname(nodeBinary), 'node_modules', 'npm');
if (!fs.existsSync(path.join(npmRoot, 'bin', 'npm-cli.js'))) throw new Error('The portable engineering runner requires the npm shipped with this Node distribution.');
copyTree(npmRoot, path.join(portableRoot, 'runtime', 'node_modules', 'npm'));
const notices = ['Agent Workbench third-party notices', '',
'Original product code is supplied for the project owner. Its redistribution terms are determined by the project owner.',
@@ -66,6 +69,7 @@ for (const [location, entry] of Object.entries(lock.packages).sort(([a], [b]) =>
const nodeLicenseText = fs.readFileSync(nodeLicense, 'utf8');
fs.writeFileSync(path.join(licenseRoot, 'Node-' + nodeVersion + '-LICENSE.txt'), nodeLicenseText);
notices.push('='.repeat(72), 'Node.js ' + nodeVersion, '', nodeLicenseText);
notices.push('='.repeat(72), 'npm bundled with Node.js', 'Complete package and dependency licenses are retained under runtime/node_modules/npm/.', '', fs.readFileSync(path.join(npmRoot, 'LICENSE'), 'utf8'));
fs.writeFileSync(path.join(root, 'THIRD_PARTY_NOTICES.txt'), notices.join('\n'));
for (const output of [portableRoot, sourceRoot]) {
fs.cpSync(licenseRoot, path.join(output, 'licenses'), { recursive: true });