mirror of
https://github.com/ValueCell-ai/ClawX.git
synced 2026-08-14 08:53:09 +00:00
Bundle agent-browser binary like uv and expose it on OpenClaw PATH (#1082)
This commit is contained in:
@@ -54,6 +54,9 @@ jobs:
|
||||
- name: Download uv binaries for Windows
|
||||
run: pnpm run uv:download:win
|
||||
|
||||
- name: Download agent-browser binaries for Windows
|
||||
run: pnpm run agent-browser:download:win
|
||||
|
||||
- name: Build Windows package (no publish)
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -77,6 +77,18 @@ jobs:
|
||||
if: matrix.platform == 'linux'
|
||||
run: pnpm run uv:download:linux
|
||||
|
||||
- name: Download agent-browser binaries for macOS
|
||||
if: matrix.platform == 'mac'
|
||||
run: pnpm run agent-browser:download:mac
|
||||
|
||||
- name: Download agent-browser binaries for Windows
|
||||
if: matrix.platform == 'win'
|
||||
run: pnpm run agent-browser:download:win
|
||||
|
||||
- name: Download agent-browser binaries for Linux
|
||||
if: matrix.platform == 'linux'
|
||||
run: pnpm run agent-browser:download:linux
|
||||
|
||||
|
||||
# macOS specific steps
|
||||
- name: Free disk space (macOS)
|
||||
|
||||
@@ -42,6 +42,9 @@ jobs:
|
||||
- name: Download uv binaries for Windows
|
||||
run: pnpm run uv:download:win
|
||||
|
||||
- name: Download agent-browser binaries for Windows
|
||||
run: pnpm run agent-browser:download:win
|
||||
|
||||
- name: Build Windows
|
||||
run: pnpm run package:win
|
||||
|
||||
|
||||
+1
-1
@@ -345,7 +345,7 @@ AI を開発ワークフローに統合できます。エージェントを使
|
||||
|
||||
```bash
|
||||
# 開発
|
||||
pnpm run init # 依存関係のインストール + uvのダウンロード
|
||||
pnpm run init # 依存関係のインストール + バンドルバイナリ(uv、agent-browser)のダウンロード
|
||||
pnpm dev # ホットリロードで起動(不足時は同梱スキルを自動準備)
|
||||
|
||||
# コード品質
|
||||
|
||||
@@ -349,7 +349,7 @@ Chain multiple skills together to create sophisticated automation pipelines. Pro
|
||||
|
||||
```bash
|
||||
# Development
|
||||
pnpm run init # Install dependencies + download uv
|
||||
pnpm run init # Install dependencies + download bundled binaries (uv, agent-browser)
|
||||
pnpm dev # Start with hot reload (auto-prepares bundled skills if missing)
|
||||
|
||||
# Quality
|
||||
|
||||
+1
-1
@@ -349,7 +349,7 @@ ClawX 采用 **双进程 + Host API 统一接入架构**。渲染进程只调用
|
||||
|
||||
```bash
|
||||
# 开发
|
||||
pnpm run init # 安装依赖并下载 uv
|
||||
pnpm run init # 安装依赖并下载捆绑二进制(uv、agent-browser)
|
||||
pnpm dev # 以热重载模式启动(若缺失会自动准备预装技能包)
|
||||
|
||||
# 代码质量
|
||||
|
||||
+8
-3
@@ -32,7 +32,7 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"postinstall": "node scripts/patch-browser-hint.mjs && node scripts/patch-openclaw-image-b64-json.mjs",
|
||||
"init": "pnpm install && pnpm run uv:download",
|
||||
"init": "pnpm install && pnpm run uv:download && pnpm run agent-browser:download",
|
||||
"predev": "node scripts/generate-ext-bridge.mjs && zx scripts/prepare-preinstalled-skills-dev.mjs",
|
||||
"dev": "vite",
|
||||
"ext:bridge": "node scripts/generate-ext-bridge.mjs",
|
||||
@@ -56,15 +56,20 @@
|
||||
"uv:download:win": "zx scripts/download-bundled-uv.mjs --platform=win",
|
||||
"uv:download:linux": "zx scripts/download-bundled-uv.mjs --platform=linux",
|
||||
"uv:download:all": "zx scripts/download-bundled-uv.mjs --all",
|
||||
"agent-browser:download": "zx scripts/download-bundled-agent-browser.mjs",
|
||||
"agent-browser:download:mac": "zx scripts/download-bundled-agent-browser.mjs --platform=mac",
|
||||
"agent-browser:download:win": "zx scripts/download-bundled-agent-browser.mjs --platform=win",
|
||||
"agent-browser:download:linux": "zx scripts/download-bundled-agent-browser.mjs --platform=linux",
|
||||
"agent-browser:download:all": "zx scripts/download-bundled-agent-browser.mjs --all",
|
||||
"node:download:win": "zx scripts/download-bundled-node.mjs --platform=win",
|
||||
"prep:win-binaries": "pnpm run uv:download:win && pnpm run node:download:win",
|
||||
"prep:win-binaries": "pnpm run uv:download:win && pnpm run agent-browser:download:win && pnpm run node:download:win",
|
||||
"icons": "zx scripts/generate-icons.mjs",
|
||||
"package": "node scripts/generate-ext-bridge.mjs && pnpm run build:vite && zx scripts/bundle-openclaw.mjs && zx scripts/bundle-openclaw-plugins.mjs && zx scripts/bundle-preinstalled-skills.mjs",
|
||||
"package:mac": "pnpm run package && node scripts/run-electron-builder.mjs --mac --publish never",
|
||||
"package:mac:local": "SKIP_PREINSTALLED_SKILLS=1 pnpm run package && node scripts/run-electron-builder.mjs --mac --publish never",
|
||||
"package:win": "pnpm run prep:win-binaries && pnpm run package && node scripts/patch-nsis-win.mjs && node scripts/run-electron-builder.mjs --win --publish never",
|
||||
"package:linux": "pnpm run package && node scripts/run-electron-builder.mjs --linux --publish never",
|
||||
"release": "pnpm run uv:download && pnpm run package && node scripts/run-electron-builder.mjs --publish always",
|
||||
"release": "pnpm run uv:download && pnpm run agent-browser:download && pnpm run package && node scripts/run-electron-builder.mjs --publish always",
|
||||
"preversion": "node scripts/pre-version-fetch-tags.mjs",
|
||||
"version": "node scripts/assert-release-version.mjs",
|
||||
"version:patch": "pnpm version patch",
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env zx
|
||||
|
||||
import 'zx/globals';
|
||||
|
||||
const ROOT_DIR = path.resolve(__dirname, '..');
|
||||
const AGENT_BROWSER_VERSION = 'v0.27.0';
|
||||
const BASE_URL = `https://github.com/vercel-labs/agent-browser/releases/download/${AGENT_BROWSER_VERSION}`;
|
||||
const OUTPUT_BASE = path.join(ROOT_DIR, 'resources', 'bin');
|
||||
|
||||
// Mapping Node platforms/archs to agent-browser release asset naming.
|
||||
// Assets are bare binaries (no archive). win32-arm64 has no native asset, so
|
||||
// it reuses the win32-x64 binary (runs via Windows-on-ARM x64 emulation).
|
||||
const TARGETS = {
|
||||
'darwin-arm64': {
|
||||
asset: 'agent-browser-darwin-arm64',
|
||||
binName: 'agent-browser',
|
||||
},
|
||||
'darwin-x64': {
|
||||
asset: 'agent-browser-darwin-x64',
|
||||
binName: 'agent-browser',
|
||||
},
|
||||
'win32-x64': {
|
||||
asset: 'agent-browser-win32-x64.exe',
|
||||
binName: 'agent-browser.exe',
|
||||
},
|
||||
'win32-arm64': {
|
||||
asset: 'agent-browser-win32-x64.exe',
|
||||
binName: 'agent-browser.exe',
|
||||
},
|
||||
'linux-arm64': {
|
||||
asset: 'agent-browser-linux-arm64',
|
||||
binName: 'agent-browser',
|
||||
},
|
||||
'linux-x64': {
|
||||
asset: 'agent-browser-linux-x64',
|
||||
binName: 'agent-browser',
|
||||
},
|
||||
};
|
||||
|
||||
// Platform groups for building multi-arch packages
|
||||
const PLATFORM_GROUPS = {
|
||||
mac: ['darwin-x64', 'darwin-arm64'],
|
||||
win: ['win32-x64', 'win32-arm64'],
|
||||
linux: ['linux-x64', 'linux-arm64'],
|
||||
};
|
||||
|
||||
async function setupTarget(id) {
|
||||
const target = TARGETS[id];
|
||||
if (!target) {
|
||||
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}`;
|
||||
|
||||
echo(chalk.blue`\n📦 Setting up agent-browser for ${id}...`);
|
||||
|
||||
// Only remove our own binary, not the entire directory, to avoid deleting
|
||||
// uv / node binaries placed by other download scripts.
|
||||
if (await fs.pathExists(destBin)) {
|
||||
await fs.remove(destBin);
|
||||
}
|
||||
await fs.ensureDir(targetDir);
|
||||
|
||||
// Download (bare binary — no extraction needed)
|
||||
echo`⬇️ Downloading: ${downloadUrl}`;
|
||||
const response = await fetch(downloadUrl);
|
||||
if (!response.ok) throw new Error(`Failed to download: ${response.statusText}`);
|
||||
const buffer = await response.arrayBuffer();
|
||||
await fs.writeFile(destBin, Buffer.from(buffer));
|
||||
|
||||
// Permission fix
|
||||
if (os.platform() !== 'win32') {
|
||||
await fs.chmod(destBin, 0o755);
|
||||
}
|
||||
|
||||
echo(chalk.green`✅ Success: ${destBin}`);
|
||||
}
|
||||
|
||||
// Main logic
|
||||
const downloadAll = argv.all;
|
||||
const platform = argv.platform;
|
||||
|
||||
if (downloadAll) {
|
||||
echo(chalk.cyan`🌐 Downloading agent-browser binaries for ALL supported platforms...`);
|
||||
for (const id of Object.keys(TARGETS)) {
|
||||
await setupTarget(id);
|
||||
}
|
||||
} else if (platform) {
|
||||
const targets = PLATFORM_GROUPS[platform];
|
||||
if (!targets) {
|
||||
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(` Architectures: ${targets.join(', ')}`);
|
||||
for (const id of targets) {
|
||||
await setupTarget(id);
|
||||
}
|
||||
} else {
|
||||
const currentId = `${os.platform()}-${os.arch()}`;
|
||||
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(`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`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
echo(chalk.green`\n🎉 Done!`);
|
||||
Reference in New Issue
Block a user