mirror of
https://github.com/ValueCell-ai/ClawX.git
synced 2026-08-14 00:48:10 +00:00
Improve agent-browser download logs for CI pipeline visibility (#1084)
This commit is contained in:
@@ -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}/<platform-arch>/`));
|
||||
|
||||
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=<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!`);
|
||||
|
||||
Reference in New Issue
Block a user