fix: show active passthrough capacity and separate program source publication

This commit is contained in:
Agent Workbench Dev
2026-11-06 09:24:33 +08:00
parent 9d11760640
commit fda264e40a
16 changed files with 248 additions and 37 deletions
+22 -18
View File
@@ -6,13 +6,15 @@ import { planReaBundle, copyReaBundle } from './bundle-rea.mjs';
import { planBrowserBundle, copyBrowserBundle } from './bundle-browser.mjs';
import { planDesktopBundle, buildNativeLauncher, copyDesktopBundle } from './bundle-desktop.mjs';
import { buildWindowsInstaller } from './build-installer.mjs';
import { createDocumentationBundle } from './documentation-bundle.mjs';
import { createDocumentationBundle, createProgramGuides } from './documentation-bundle.mjs';
import { archiveWindowsDirectory } from './release-archive.mjs';
import { copyReleaseTree } from './release-copy.mjs';
const args = process.argv.slice(2);
if (args.some(value => !['--help', '--immutable'].includes(value))) throw new Error('Unsupported argument; use --help.');
if (args.includes('--help')) { console.log('node scripts/package.mjs [--immutable] - create new portable/source releases and archives; existing release folders are never refreshed.'); process.exit(0); }
if (args.some(value => !['--help', '--immutable', '--application-only', '--with-evidence'].includes(value))) throw new Error('Unsupported argument; use --help.');
if (args.includes('--help')) { console.log('node scripts/package.mjs [--immutable] [--with-evidence] - publish program/installer by default; explicitly add --with-evidence for legacy source/runtime/evidence archives. For source code only use npm run package:source. No installed user data is packaged.'); process.exit(0); }
if (args.includes('--application-only') && args.includes('--with-evidence')) throw new Error('Select program publication or legacy evidence export.');
const applicationOnly = !args.includes('--with-evidence');
const root = process.cwd();
if (execFileSync('git', ['status', '--porcelain', '--untracked-files=all'], { cwd: root, encoding: 'utf8', windowsHide: true }).trim()) throw new Error('Commit the reviewed release inputs before packaging; sourceCommit must identify the actual shipped sources.');
const meta = JSON.parse(fs.readFileSync('package.json', 'utf8'));
@@ -25,9 +27,9 @@ fs.mkdirSync(releases, { recursive: true });
const baseName = 'Agent-Workbench-' + meta.version;
const buildSuffix = args.includes('--immutable') || fs.existsSync(path.join(releases, baseName + '-win-x64')) ? '-' + new Date().toISOString().replace(/[-:TZ.]/g, '') : '';
const portableRoot = path.join(releases, baseName + '-win-x64' + buildSuffix);
const sourceRoot = path.join(releases, baseName + '-source' + buildSuffix);
const evidenceRoot = path.join(releases, baseName + '-evidence' + buildSuffix);
for (const target of [portableRoot, sourceRoot]) {
const sourceRoot = applicationOnly ? null : path.join(releases, baseName + '-source' + buildSuffix);
const evidenceRoot = applicationOnly ? null : path.join(releases, baseName + '-evidence' + buildSuffix);
for (const target of [portableRoot, sourceRoot].filter(Boolean)) {
if (!path.resolve(target).startsWith(releases + path.sep) || fs.existsSync(target)) throw new Error('Release output must be a new folder under releases.');
fs.mkdirSync(target, { recursive: true });
}
@@ -38,9 +40,9 @@ const copyTree = copyReleaseTree;
for (const name of portableFiles) copyTree(path.join(root, name), path.join(portableRoot, name));
fs.mkdirSync(path.join(portableRoot, 'scripts'), { recursive: true });
for (const name of ['Start-Workbench.ps1', 'Stop-Workbench.ps1', 'Start-Desktop.ps1', 'upgrade-running.mjs', 'python-check-runner.py']) fs.copyFileSync(path.join(root, 'scripts', name), path.join(portableRoot, 'scripts', name));
for (const name of sourceFiles) copyTree(path.join(root, name), path.join(sourceRoot, name));
if (sourceRoot) for (const name of sourceFiles) copyTree(path.join(root, name), path.join(sourceRoot, name));
const sourceCommit = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8', windowsHide: true }).trim();
const documentation = createDocumentationBundle({ root, portableRoot, evidenceRoot, archiveName: path.basename(evidenceRoot) + '.zip', sourceCommit });
const documentation = applicationOnly ? createProgramGuides({ root, portableRoot, sourceCommit }) : createDocumentationBundle({ root, portableRoot, evidenceRoot, archiveName: path.basename(evidenceRoot) + '.zip', sourceCommit });
const preferredNode = path.resolve(root, '..', 'tools', 'node-v24.22.1-win-x64', 'node.exe');
const nodeBinary = process.env.AGENT_WORKBENCH_NODE_PATH || (fs.existsSync(preferredNode) ? preferredNode : process.execPath);
@@ -56,18 +58,20 @@ 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'));
fs.copyFileSync(nodeLicense, path.join(portableRoot, 'runtime', 'LICENSE'));
fs.mkdirSync(path.join(sourceRoot, 'runtime'), { recursive: true });
fs.copyFileSync(nodeBinary, path.join(sourceRoot, 'runtime', 'node.exe'));
fs.copyFileSync(nodeLicense, path.join(sourceRoot, 'runtime', 'LICENSE'));
copyTree(npmRoot, path.join(sourceRoot, 'runtime', 'node_modules', 'npm'));
if (sourceRoot) {
fs.mkdirSync(path.join(sourceRoot, 'runtime'), { recursive: true });
fs.copyFileSync(nodeBinary, path.join(sourceRoot, 'runtime', 'node.exe'));
fs.copyFileSync(nodeLicense, path.join(sourceRoot, 'runtime', 'LICENSE'));
copyTree(npmRoot, path.join(sourceRoot, 'runtime', 'node_modules', 'npm'));
}
const launcherPath = path.join(root, '.qa', 'native-launcher', 'AgentWorkbench.exe');
const nativeLauncher = buildNativeLauncher(root, launcherPath);
const desktopRuntime = copyDesktopBundle(root, portableRoot, desktopPlan, { launcher: launcherPath });
copyDesktopBundle(root, sourceRoot, desktopPlan, { source: true });
if (sourceRoot) copyDesktopBundle(root, sourceRoot, desktopPlan, { source: true });
const reaRuntime = copyReaBundle(path.join(portableRoot, 'runtime'), reaPlan);
copyReaBundle(path.join(sourceRoot, 'runtime'), reaPlan);
if (sourceRoot) copyReaBundle(path.join(sourceRoot, 'runtime'), reaPlan);
const browserRuntime = copyBrowserBundle(path.join(portableRoot, 'runtime'), browserPlan);
copyBrowserBundle(path.join(sourceRoot, 'runtime'), browserPlan);
if (sourceRoot) copyBrowserBundle(path.join(sourceRoot, 'runtime'), browserPlan);
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.',
@@ -102,7 +106,7 @@ fs.writeFileSync(path.join(licenseRoot, 'Node-' + nodeVersion + '-LICENSE.txt'),
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]) {
for (const output of [portableRoot, sourceRoot].filter(Boolean)) {
fs.cpSync(licenseRoot, path.join(output, 'licenses'), { recursive: true });
fs.copyFileSync(path.join(root, 'THIRD_PARTY_NOTICES.txt'), path.join(output, 'THIRD_PARTY_NOTICES.txt'));
}
@@ -124,7 +128,7 @@ function manifest(directory, kind) {
return result;
}
const portableManifest = manifest(portableRoot, 'portable');
manifest(sourceRoot, 'source');
if (sourceRoot) manifest(sourceRoot, 'source');
const installer = buildWindowsInstaller({ root, portableRoot, outputRoot: releases });
function archive(directory) {
const destination = directory + '.zip';
@@ -132,7 +136,7 @@ function archive(directory) {
archiveWindowsDirectory(directory, destination);
return { path: destination, bytes: fs.statSync(destination).size, sha256: createHash('sha256').update(fs.readFileSync(destination)).digest('hex') };
}
const result = { portableRoot, sourceRoot, evidenceRoot, portable: archive(portableRoot), source: archive(sourceRoot), evidence: archive(evidenceRoot), documentation: { sourceCommit, originalFiles: documentation.originalFiles, originalBytes: documentation.originalBytes, shippedFiles: documentation.shipped.length, shippedBytes: documentation.shipped.reduce((sum, row) => sum + row.bytes, 0), evidenceManifestSha256: documentation.evidenceManifestSha256 }, installer, desktopRuntime, nativeLauncher, nodeVersion, reaRuntime, portableFiles: portableManifest.files.length, licenseTexts: licenseCount + 2 };
const result = { portableRoot, ...(sourceRoot ? { sourceRoot, source: archive(sourceRoot) } : {}), ...(evidenceRoot ? { evidenceRoot, evidence: archive(evidenceRoot) } : {}), portable: archive(portableRoot), documentation: { sourceCommit, scope: documentation.scope, originalFiles: documentation.originalFiles, originalBytes: documentation.originalBytes, shippedFiles: documentation.shipped.length, shippedBytes: documentation.shipped.reduce((sum, row) => sum + row.bytes, 0), evidenceManifestSha256: documentation.evidenceManifestSha256 }, installer, desktopRuntime, nativeLauncher, nodeVersion, reaRuntime, portableFiles: portableManifest.files.length, licenseTexts: licenseCount + 2 };
result.browserRuntime = { playwrightVersion: browserRuntime.playwrightVersion, packages: browserRuntime.packages.map(pkg => ({ name: pkg.name, version: pkg.version, files: pkg.files.length })) };
fs.writeFileSync(path.join(releases, 'latest.json'), JSON.stringify(result, null, 2));
console.log(JSON.stringify(result, null, 2));