From 73e68f769d1f85118d80eb84f21c0e6d5552f723 Mon Sep 17 00:00:00 2001 From: paisley <8197966+su8su@users.noreply.github.com> Date: Tue, 2 Jun 2026 12:47:53 +0800 Subject: [PATCH] Improve agent-browser download logs for CI pipeline visibility (#1084) --- scripts/download-bundled-agent-browser.mjs | 56 ++++++++++++++++++---- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/scripts/download-bundled-agent-browser.mjs b/scripts/download-bundled-agent-browser.mjs index 13a6d8c7..3acdd088 100644 --- a/scripts/download-bundled-agent-browser.mjs +++ b/scripts/download-bundled-agent-browser.mjs @@ -44,18 +44,29 @@ const PLATFORM_GROUPS = { linux: ['linux-x64', 'linux-arm64'], }; +// Collected per-target results so we can print an install summary at the end, +// which is the part that should clearly show up in CI / pipeline logs. +const installed = []; + +function formatBytes(bytes) { + return `${(bytes / (1024 * 1024)).toFixed(2)} MiB (${bytes} bytes)`; +} + async function setupTarget(id) { const target = TARGETS[id]; if (!target) { - echo(chalk.yellow`āš ļø Target ${id} is not supported by this script.`); + echo(chalk.yellow(`āš ļø Target ${id} is not supported by this script.`)); return; } const targetDir = path.join(OUTPUT_BASE, id); const destBin = path.join(targetDir, target.binName); const downloadUrl = `${BASE_URL}/${target.asset}`; + const reusesX64 = id === 'win32-arm64'; - echo(chalk.blue`\nšŸ“¦ Setting up agent-browser for ${id}...`); + echo(chalk.blue(`\nšŸ“¦ [agent-browser ${AGENT_BROWSER_VERSION}] Installing for ${id}...`)); + echo(` asset: ${target.asset}${reusesX64 ? ' (no native arm64 asset; reusing win32-x64)' : ''}`); + echo(` dest: ${destBin}`); // Only remove our own binary, not the entire directory, to avoid deleting // uv / node binaries placed by other download scripts. @@ -65,9 +76,12 @@ async function setupTarget(id) { await fs.ensureDir(targetDir); // Download (bare binary — no extraction needed) - echo`ā¬‡ļø Downloading: ${downloadUrl}`; + const startedAt = Date.now(); + echo(` ā¬‡ļø Downloading: ${downloadUrl}`); const response = await fetch(downloadUrl); - if (!response.ok) throw new Error(`Failed to download: ${response.statusText}`); + if (!response.ok) { + throw new Error(`Failed to download ${target.asset}: ${response.status} ${response.statusText}`); + } const buffer = await response.arrayBuffer(); await fs.writeFile(destBin, Buffer.from(buffer)); @@ -76,13 +90,35 @@ async function setupTarget(id) { await fs.chmod(destBin, 0o755); } - echo(chalk.green`āœ… Success: ${destBin}`); + const { size } = await fs.stat(destBin); + const elapsedMs = Date.now() - startedAt; + echo(chalk.green(` āœ… Installed ${id}: ${formatBytes(size)} in ${(elapsedMs / 1000).toFixed(1)}s`)); + + installed.push({ id, asset: target.asset, dest: destBin, size }); +} + +function printSummary() { + echo(chalk.cyan(`\n──────── agent-browser install summary ────────`)); + echo(chalk.cyan(`version: ${AGENT_BROWSER_VERSION}`)); + if (installed.length === 0) { + echo(chalk.yellow(`no binaries were installed.`)); + } else { + for (const item of installed) { + echo(` • ${item.id.padEnd(13)} ${formatBytes(item.size).padEnd(28)} ${item.dest}`); + } + echo(chalk.cyan(`total: ${installed.length} binary(ies) installed.`)); + } + echo(chalk.cyan(`───────────────────────────────────────────────`)); } // Main logic const downloadAll = argv.all; const platform = argv.platform; +echo(chalk.cyan(`šŸ”§ agent-browser bundler — version ${AGENT_BROWSER_VERSION}`)); +echo(chalk.cyan(` source: ${BASE_URL}`)); +echo(chalk.cyan(` output: ${OUTPUT_BASE}//`)); + if (downloadAll) { echo(chalk.cyan`🌐 Downloading agent-browser binaries for ALL supported platforms...`); for (const id of Object.keys(TARGETS)) { @@ -91,24 +127,24 @@ if (downloadAll) { } else if (platform) { const targets = PLATFORM_GROUPS[platform]; if (!targets) { - echo(chalk.red`āŒ Unknown platform: ${platform}`); + echo(chalk.red(`āŒ Unknown platform: ${platform}`)); echo(`Available platforms: ${Object.keys(PLATFORM_GROUPS).join(', ')}`); process.exit(1); } - echo(chalk.cyan`šŸŽÆ Downloading agent-browser binaries for platform: ${platform}`); + echo(chalk.cyan(`šŸŽÆ Downloading agent-browser binaries for platform: ${platform}`)); echo(` Architectures: ${targets.join(', ')}`); for (const id of targets) { await setupTarget(id); } } else { const currentId = `${os.platform()}-${os.arch()}`; - echo(chalk.cyan`šŸ’» Detected system: ${currentId}`); + echo(chalk.cyan(`šŸ’» Detected system: ${currentId}`)); if (TARGETS[currentId]) { await setupTarget(currentId); } else { - echo(chalk.red`āŒ Current system ${currentId} is not in the supported download list.`); + echo(chalk.red(`āŒ Current system ${currentId} is not in the supported download list.`)); echo(`Supported targets: ${Object.keys(TARGETS).join(', ')}`); echo(`\nTip: Use --platform= to download for a specific platform`); echo(` Use --all to download for all platforms`); @@ -116,4 +152,6 @@ if (downloadAll) { } } +printSummary(); + echo(chalk.green`\nšŸŽ‰ Done!`);