@divebell/agent-browser 0.33.1-divebell.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1831 -0
  3. package/bin/agent-browser-darwin-arm64 +0 -0
  4. package/bin/agent-browser-darwin-x64 +0 -0
  5. package/bin/agent-browser-linux-arm64 +0 -0
  6. package/bin/agent-browser-linux-musl-arm64 +0 -0
  7. package/bin/agent-browser-linux-musl-x64 +0 -0
  8. package/bin/agent-browser-linux-x64 +0 -0
  9. package/bin/agent-browser-win32-x64.exe +0 -0
  10. package/bin/agent-browser.js +120 -0
  11. package/cli/src/native/a11y/LICENSE-axe-core-THIRD-PARTY.txt +66 -0
  12. package/cli/src/native/a11y/LICENSE-axe-core.txt +362 -0
  13. package/package.json +61 -0
  14. package/scripts/build-all-platforms.sh +85 -0
  15. package/scripts/check-version-sync.js +81 -0
  16. package/scripts/copy-native.js +36 -0
  17. package/scripts/postinstall.js +321 -0
  18. package/scripts/sync-version.js +125 -0
  19. package/scripts/windows-debug/provision.sh +220 -0
  20. package/scripts/windows-debug/run.sh +92 -0
  21. package/scripts/windows-debug/start.sh +43 -0
  22. package/scripts/windows-debug/stop.sh +28 -0
  23. package/scripts/windows-debug/sync.sh +27 -0
  24. package/skill-data/agentcore/SKILL.md +115 -0
  25. package/skill-data/core/SKILL.md +518 -0
  26. package/skill-data/core/references/authentication.md +380 -0
  27. package/skill-data/core/references/commands.md +511 -0
  28. package/skill-data/core/references/profiling.md +120 -0
  29. package/skill-data/core/references/proxy-support.md +194 -0
  30. package/skill-data/core/references/session-management.md +180 -0
  31. package/skill-data/core/references/snapshot-refs.md +219 -0
  32. package/skill-data/core/references/trust-boundaries.md +51 -0
  33. package/skill-data/core/references/video-recording.md +175 -0
  34. package/skill-data/core/references/webgpu.md +118 -0
  35. package/skill-data/core/templates/authenticated-session.sh +105 -0
  36. package/skill-data/core/templates/capture-workflow.sh +69 -0
  37. package/skill-data/core/templates/form-automation.sh +62 -0
  38. package/skill-data/derive-client/SKILL.md +86 -0
  39. package/skill-data/dogfood/SKILL.md +220 -0
  40. package/skill-data/dogfood/references/issue-taxonomy.md +109 -0
  41. package/skill-data/dogfood/templates/dogfood-report-template.md +53 -0
  42. package/skill-data/electron/SKILL.md +236 -0
  43. package/skill-data/slack/SKILL.md +285 -0
  44. package/skill-data/slack/references/slack-tasks.md +348 -0
  45. package/skill-data/slack/templates/slack-report-template.md +163 -0
  46. package/skill-data/vercel-sandbox/SKILL.md +213 -0
  47. package/skills/agent-browser/SKILL.md +51 -0
@@ -0,0 +1,85 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ # Build agent-browser for all platforms using Docker
5
+ # Usage: ./scripts/build-all-platforms.sh
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
9
+ OUTPUT_DIR="$PROJECT_ROOT/bin"
10
+
11
+ # Colors
12
+ RED='\033[0;31m'
13
+ GREEN='\033[0;32m'
14
+ YELLOW='\033[1;33m'
15
+ NC='\033[0m' # No Color
16
+
17
+ echo -e "${YELLOW}Building agent-browser for all platforms...${NC}"
18
+ echo ""
19
+
20
+ # Ensure output directory exists
21
+ mkdir -p "$OUTPUT_DIR"
22
+
23
+ # Build the Docker image if needed
24
+ echo -e "${YELLOW}Building Docker cross-compilation image...${NC}"
25
+ docker build --platform linux/amd64 -t agent-browser-builder -f "$PROJECT_ROOT/docker/Dockerfile.build" "$PROJECT_ROOT"
26
+
27
+ # Function to build for a target
28
+ build_target() {
29
+ local rust_target=$1
30
+ local build_target=$2
31
+ local output_name=$3
32
+
33
+ echo -e "${YELLOW}Building for ${build_target}...${NC}"
34
+
35
+ rm -f "$OUTPUT_DIR/$output_name"
36
+
37
+ docker run --rm \
38
+ --platform linux/amd64 \
39
+ -v "$PROJECT_ROOT/cli:/build" \
40
+ -v "$OUTPUT_DIR:/output" \
41
+ agent-browser-builder \
42
+ -c "set -euo pipefail
43
+ cargo zigbuild --release --target ${build_target}
44
+ source_path=/build/target/${rust_target}/release/agent-browser
45
+ if [ -f \"\$source_path.exe\" ]; then
46
+ source_path=\"\$source_path.exe\"
47
+ fi
48
+ cp \"\$source_path\" /output/${output_name}
49
+ chmod +x /output/${output_name} 2>/dev/null || true"
50
+
51
+ if [ -f "$OUTPUT_DIR/$output_name" ]; then
52
+ echo -e "${GREEN}✓ Built ${output_name}${NC}"
53
+ else
54
+ echo -e "${RED}✗ Failed to build ${output_name}${NC}"
55
+ return 1
56
+ fi
57
+ }
58
+
59
+ # Build for each platform
60
+ # Linux x64
61
+ build_target "x86_64-unknown-linux-gnu" "x86_64-unknown-linux-gnu.2.28" "agent-browser-linux-x64"
62
+
63
+ # Linux ARM64
64
+ build_target "aarch64-unknown-linux-gnu" "aarch64-unknown-linux-gnu.2.28" "agent-browser-linux-arm64"
65
+
66
+ # Windows x64
67
+ build_target "x86_64-pc-windows-gnu" "x86_64-pc-windows-gnu" "agent-browser-win32-x64.exe"
68
+
69
+ # macOS x64 (via zig for cross-compilation)
70
+ build_target "x86_64-apple-darwin" "x86_64-apple-darwin" "agent-browser-darwin-x64"
71
+
72
+ # macOS ARM64 (via zig for cross-compilation)
73
+ build_target "aarch64-apple-darwin" "aarch64-apple-darwin" "agent-browser-darwin-arm64"
74
+
75
+ # Linux musl x64 (Alpine)
76
+ build_target "x86_64-unknown-linux-musl" "x86_64-unknown-linux-musl" "agent-browser-linux-musl-x64"
77
+
78
+ # Linux musl ARM64 (Alpine)
79
+ build_target "aarch64-unknown-linux-musl" "aarch64-unknown-linux-musl" "agent-browser-linux-musl-arm64"
80
+
81
+ echo ""
82
+ echo -e "${GREEN}Build complete!${NC}"
83
+ echo ""
84
+ echo "Binaries are in: $OUTPUT_DIR"
85
+ ls -la "$OUTPUT_DIR"/agent-browser-*
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Verifies that package.json and cli/Cargo.toml have the same version.
5
+ * Used in CI to catch version drift.
6
+ */
7
+
8
+ import { readFileSync } from 'fs';
9
+ import { dirname, join } from 'path';
10
+ import { fileURLToPath } from 'url';
11
+
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
+ const rootDir = join(__dirname, '..');
14
+
15
+ // Read package.json version
16
+ const packageJson = JSON.parse(readFileSync(join(rootDir, 'package.json'), 'utf-8'));
17
+ const packageVersion = packageJson.version;
18
+
19
+ // Read Cargo.toml version
20
+ const cargoToml = readFileSync(join(rootDir, 'cli/Cargo.toml'), 'utf-8');
21
+ const cargoVersionMatch = cargoToml.match(/^version\s*=\s*"([^"]*)"/m);
22
+
23
+ if (!cargoVersionMatch) {
24
+ console.error('Could not find version in cli/Cargo.toml');
25
+ process.exit(1);
26
+ }
27
+
28
+ const cargoVersion = cargoVersionMatch[1];
29
+
30
+ // Read dashboard package.json version
31
+ const dashboardPkg = JSON.parse(readFileSync(join(rootDir, 'packages/dashboard/package.json'), 'utf-8'));
32
+ const dashboardVersion = dashboardPkg.version;
33
+
34
+ // Read sandbox package versions
35
+ const sandboxPkg = JSON.parse(readFileSync(join(rootDir, 'packages/@agent-browser/sandbox/package.json'), 'utf-8'));
36
+ const sandboxVersion = sandboxPkg.version;
37
+ const sandboxVersionSource = readFileSync(join(rootDir, 'packages/@agent-browser/sandbox/src/version.ts'), 'utf-8');
38
+ const sandboxVersionMatch = sandboxVersionSource.match(/AGENT_BROWSER_SANDBOX_VERSION\s*=\s*"([^"]*)"/);
39
+
40
+ if (!sandboxVersionMatch) {
41
+ console.error('Could not find AGENT_BROWSER_SANDBOX_VERSION in packages/@agent-browser/sandbox/src/version.ts');
42
+ process.exit(1);
43
+ }
44
+
45
+ const sandboxRuntimeVersion = sandboxVersionMatch[1];
46
+
47
+ // Read Eve package version
48
+ const evePkg = JSON.parse(readFileSync(join(rootDir, 'packages/@agent-browser/eve/package.json'), 'utf-8'));
49
+ const eveVersion = evePkg.version;
50
+ const eveSandboxDependency = evePkg.dependencies?.['@agent-browser/sandbox'];
51
+
52
+ const mismatches = [];
53
+ if (packageVersion !== cargoVersion) {
54
+ mismatches.push(` cli/Cargo.toml: ${cargoVersion}`);
55
+ }
56
+ if (packageVersion !== dashboardVersion) {
57
+ mismatches.push(` packages/dashboard: ${dashboardVersion}`);
58
+ }
59
+ if (packageVersion !== sandboxVersion) {
60
+ mismatches.push(` packages/@agent-browser/sandbox/package.json: ${sandboxVersion}`);
61
+ }
62
+ if (packageVersion !== sandboxRuntimeVersion) {
63
+ mismatches.push(` packages/@agent-browser/sandbox/src/version.ts: ${sandboxRuntimeVersion}`);
64
+ }
65
+ if (packageVersion !== eveVersion) {
66
+ mismatches.push(` packages/@agent-browser/eve/package.json: ${eveVersion}`);
67
+ }
68
+ if (eveSandboxDependency !== 'workspace:^') {
69
+ mismatches.push(` packages/@agent-browser/eve dependency @agent-browser/sandbox: ${eveSandboxDependency}`);
70
+ }
71
+
72
+ if (mismatches.length > 0) {
73
+ console.error('Version mismatch detected!');
74
+ console.error(` package.json: ${packageVersion}`);
75
+ for (const m of mismatches) console.error(m);
76
+ console.error('');
77
+ console.error("Run 'pnpm run version:sync' to fix this.");
78
+ process.exit(1);
79
+ }
80
+
81
+ console.log(`Versions are in sync: ${packageVersion}`);
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Copies the compiled Rust binary to bin/ with platform-specific naming
5
+ */
6
+
7
+ import { copyFileSync, existsSync, mkdirSync } from 'fs';
8
+ import { dirname, join } from 'path';
9
+ import { fileURLToPath } from 'url';
10
+ import { platform, arch } from 'os';
11
+
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
+ const projectRoot = join(__dirname, '..');
14
+
15
+ const sourceExt = platform() === 'win32' ? '.exe' : '';
16
+ const sourcePath = join(projectRoot, `cli/target/release/agent-browser${sourceExt}`);
17
+ const binDir = join(projectRoot, 'bin');
18
+
19
+ // Determine platform suffix
20
+ const platformKey = `${platform()}-${arch()}`;
21
+ const ext = platform() === 'win32' ? '.exe' : '';
22
+ const targetName = `agent-browser-${platformKey}${ext}`;
23
+ const targetPath = join(binDir, targetName);
24
+
25
+ if (!existsSync(sourcePath)) {
26
+ console.error(`Error: Native binary not found at ${sourcePath}`);
27
+ console.error('Run "cargo build --release --manifest-path cli/Cargo.toml" first');
28
+ process.exit(1);
29
+ }
30
+
31
+ if (!existsSync(binDir)) {
32
+ mkdirSync(binDir, { recursive: true });
33
+ }
34
+
35
+ copyFileSync(sourcePath, targetPath);
36
+ console.log(`✓ Copied native binary to ${targetPath}`);
@@ -0,0 +1,321 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Postinstall script for agent-browser
5
+ *
6
+ * Downloads the platform-specific native binary if not present.
7
+ * On global installs, patches npm's bin entry to use the native binary directly:
8
+ * - Windows: Overwrites .cmd/.ps1 shims
9
+ * - Mac/Linux: Replaces symlink to point to native binary
10
+ */
11
+
12
+ import { existsSync, mkdirSync, chmodSync, createWriteStream, unlinkSync, writeFileSync, symlinkSync, lstatSync } from 'fs';
13
+ import { dirname, join } from 'path';
14
+ import { fileURLToPath } from 'url';
15
+ import { platform, arch } from 'os';
16
+ import { get } from 'https';
17
+ import { execSync } from 'child_process';
18
+
19
+ const __dirname = dirname(fileURLToPath(import.meta.url));
20
+ const projectRoot = join(__dirname, '..');
21
+ const binDir = join(projectRoot, 'bin');
22
+
23
+ // Detect if the system uses musl libc (e.g. Alpine Linux)
24
+ function isMusl() {
25
+ if (platform() !== 'linux') return false;
26
+ try {
27
+ const result = execSync('ldd --version 2>&1 || true', { encoding: 'utf8' });
28
+ return result.toLowerCase().includes('musl');
29
+ } catch {
30
+ return existsSync('/lib/ld-musl-x86_64.so.1') || existsSync('/lib/ld-musl-aarch64.so.1');
31
+ }
32
+ }
33
+
34
+ // Platform detection
35
+ const osKey = platform() === 'linux' && isMusl() ? 'linux-musl' : platform();
36
+ // Windows ARM64 falls back to x64 binary (no native ARM64 build available).
37
+ // x64 binaries run via Windows' built-in emulation on ARM64.
38
+ const effectiveArch = platform() === 'win32' && arch() === 'arm64' ? 'x64' : arch();
39
+ const platformKey = `${osKey}-${effectiveArch}`;
40
+ const ext = platform() === 'win32' ? '.exe' : '';
41
+ const binaryName = `agent-browser-${platformKey}${ext}`;
42
+ const binaryPath = join(binDir, binaryName);
43
+
44
+ // Package info
45
+ const packageJson = JSON.parse(
46
+ (await import('fs')).readFileSync(join(projectRoot, 'package.json'), 'utf8')
47
+ );
48
+ const version = packageJson.version;
49
+
50
+ // GitHub release URL
51
+ const GITHUB_REPO = 'vercel-labs/agent-browser';
52
+ const DOWNLOAD_URL = `https://github.com/${GITHUB_REPO}/releases/download/v${version}/${binaryName}`;
53
+
54
+ async function downloadFile(url, dest) {
55
+ return new Promise((resolve, reject) => {
56
+ const file = createWriteStream(dest);
57
+
58
+ const request = (url) => {
59
+ get(url, (response) => {
60
+ // Handle redirects
61
+ if (response.statusCode === 301 || response.statusCode === 302) {
62
+ request(response.headers.location);
63
+ return;
64
+ }
65
+
66
+ if (response.statusCode !== 200) {
67
+ reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
68
+ return;
69
+ }
70
+
71
+ response.pipe(file);
72
+ file.on('finish', () => {
73
+ file.close();
74
+ resolve();
75
+ });
76
+ }).on('error', (err) => {
77
+ unlinkSync(dest);
78
+ reject(err);
79
+ });
80
+ };
81
+
82
+ request(url);
83
+ });
84
+ }
85
+
86
+ /**
87
+ * Detect which package manager ran this postinstall and write a marker file
88
+ * next to the binary so `agent-browser upgrade` can use the correct one
89
+ * without fragile path heuristics or slow subprocess probing.
90
+ *
91
+ * npm_config_user_agent is set by npm/pnpm/yarn/bun during lifecycle scripts,
92
+ * e.g. "pnpm/8.10.0 node/v20.10.0 linux x64"
93
+ */
94
+ function writeInstallMethod() {
95
+ const ua = process.env.npm_config_user_agent || '';
96
+ let method = '';
97
+ if (ua.startsWith('pnpm/')) method = 'pnpm';
98
+ else if (ua.startsWith('yarn/')) method = 'yarn';
99
+ else if (ua.startsWith('bun/')) method = 'bun';
100
+ else if (ua.startsWith('npm/')) method = 'npm';
101
+
102
+ if (method) {
103
+ try {
104
+ writeFileSync(join(binDir, '.install-method'), method);
105
+ } catch {
106
+ // Non-critical — upgrade will fall back to heuristics
107
+ }
108
+ }
109
+ }
110
+
111
+ async function main() {
112
+ // Check if binary already exists
113
+ if (existsSync(binaryPath)) {
114
+ // Ensure binary is executable (npm doesn't preserve execute bit)
115
+ if (platform() !== 'win32') {
116
+ chmodSync(binaryPath, 0o755);
117
+ }
118
+ console.log(`✓ Native binary ready: ${binaryName}`);
119
+
120
+ writeInstallMethod();
121
+
122
+ // On global installs, fix npm's bin entry to use native binary directly
123
+ await fixGlobalInstallBin();
124
+
125
+ showInstallReminder();
126
+ return;
127
+ }
128
+
129
+ // Ensure bin directory exists
130
+ if (!existsSync(binDir)) {
131
+ mkdirSync(binDir, { recursive: true });
132
+ }
133
+
134
+ console.log(`Downloading native binary for ${platformKey}...`);
135
+ if (platform() === 'win32' && arch() === 'arm64') {
136
+ console.log(` Note: Using x64 binary on ARM64 Windows (runs via emulation)`);
137
+ }
138
+ console.log(`URL: ${DOWNLOAD_URL}`);
139
+
140
+ try {
141
+ await downloadFile(DOWNLOAD_URL, binaryPath);
142
+
143
+ // Make executable on Unix
144
+ if (platform() !== 'win32') {
145
+ chmodSync(binaryPath, 0o755);
146
+ }
147
+
148
+ console.log(`✓ Downloaded native binary: ${binaryName}`);
149
+ } catch (err) {
150
+ console.log(`Could not download native binary: ${err.message}`);
151
+ console.log('');
152
+ console.log('To build the native binary locally:');
153
+ console.log(' 1. Install Rust: https://rustup.rs');
154
+ console.log(' 2. Run: npm run build:native');
155
+ }
156
+
157
+ writeInstallMethod();
158
+
159
+ // On global installs, fix npm's bin entry to use native binary directly
160
+ // This avoids the /bin/sh error on Windows and provides zero-overhead execution
161
+ await fixGlobalInstallBin();
162
+
163
+ showInstallReminder();
164
+ }
165
+
166
+ function findSystemChrome() {
167
+ const os = platform();
168
+ if (os === 'darwin') {
169
+ const candidates = [
170
+ '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
171
+ '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
172
+ '/Applications/Chromium.app/Contents/MacOS/Chromium',
173
+ ];
174
+ return candidates.find(p => existsSync(p)) || null;
175
+ }
176
+ if (os === 'linux') {
177
+ const names = ['google-chrome', 'google-chrome-stable', 'chromium-browser', 'chromium'];
178
+ for (const name of names) {
179
+ try {
180
+ const result = execSync(`which ${name} 2>/dev/null`, { encoding: 'utf8' }).trim();
181
+ if (result) return result;
182
+ } catch {}
183
+ }
184
+ return null;
185
+ }
186
+ if (os === 'win32') {
187
+ const candidates = [
188
+ `${process.env.LOCALAPPDATA}\\Google\\Chrome\\Application\\chrome.exe`,
189
+ 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
190
+ 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
191
+ ];
192
+ return candidates.find(p => p && existsSync(p)) || null;
193
+ }
194
+ return null;
195
+ }
196
+
197
+ function showInstallReminder() {
198
+ const systemChrome = findSystemChrome();
199
+ if (systemChrome) {
200
+ console.log('');
201
+ console.log(` ✓ System Chrome found: ${systemChrome}`);
202
+ console.log(' agent-browser will use it automatically.');
203
+ console.log('');
204
+ return;
205
+ }
206
+
207
+ console.log('');
208
+ console.log(' ⚠ No Chrome installation detected.');
209
+ console.log(' If you plan to use a local browser, run:');
210
+ console.log('');
211
+ console.log(' agent-browser install');
212
+ if (platform() === 'linux') {
213
+ console.log('');
214
+ console.log(' On Linux, include system dependencies with:');
215
+ console.log('');
216
+ console.log(' agent-browser install --with-deps');
217
+ }
218
+ console.log('');
219
+ console.log(' You can skip this if you use --cdp, --provider, --engine, or --executable-path.');
220
+ console.log('');
221
+ }
222
+
223
+ /**
224
+ * Fix npm's bin entry on global installs to use the native binary directly.
225
+ * This provides zero-overhead CLI execution for global installs.
226
+ */
227
+ async function fixGlobalInstallBin() {
228
+ if (platform() === 'win32') {
229
+ await fixWindowsShims();
230
+ } else {
231
+ await fixUnixSymlink();
232
+ }
233
+ }
234
+
235
+ /**
236
+ * Fix npm symlink on Mac/Linux global installs.
237
+ * Replace the symlink to the JS wrapper with a symlink to the native binary.
238
+ */
239
+ async function fixUnixSymlink() {
240
+ // Get npm's global bin directory (npm prefix -g + /bin)
241
+ let npmBinDir;
242
+ try {
243
+ const prefix = execSync('npm prefix -g', { encoding: 'utf8' }).trim();
244
+ npmBinDir = join(prefix, 'bin');
245
+ } catch {
246
+ return; // npm not available
247
+ }
248
+
249
+ const symlinkPath = join(npmBinDir, 'agent-browser');
250
+
251
+ // Check if symlink exists (indicates global install)
252
+ try {
253
+ const stat = lstatSync(symlinkPath);
254
+ if (!stat.isSymbolicLink()) {
255
+ return; // Not a symlink, don't touch it
256
+ }
257
+ } catch {
258
+ return; // Symlink doesn't exist, not a global install
259
+ }
260
+
261
+ // Replace symlink to point directly to native binary
262
+ try {
263
+ unlinkSync(symlinkPath);
264
+ symlinkSync(binaryPath, symlinkPath);
265
+ console.log('✓ Optimized: symlink points to native binary (zero overhead)');
266
+ } catch (err) {
267
+ // Permission error or other issue - not critical, JS wrapper still works
268
+ console.log(`⚠ Could not optimize symlink: ${err.message}`);
269
+ console.log(' CLI will work via Node.js wrapper (slightly slower startup)');
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Fix npm-generated shims on Windows global installs.
275
+ * npm generates shims that try to run /bin/sh, which doesn't exist on Windows.
276
+ * We overwrite them to invoke the native .exe directly.
277
+ */
278
+ async function fixWindowsShims() {
279
+ let npmBinDir;
280
+ try {
281
+ npmBinDir = execSync('npm prefix -g', { encoding: 'utf8' }).trim();
282
+ } catch {
283
+ return;
284
+ }
285
+
286
+ const cmdShim = join(npmBinDir, 'agent-browser.cmd');
287
+ const ps1Shim = join(npmBinDir, 'agent-browser.ps1');
288
+
289
+ // Shims may not exist yet during postinstall (npm creates them after
290
+ // lifecycle scripts). If missing, fall back: the JS wrapper at
291
+ // bin/agent-browser.js handles Windows correctly via child_process.spawn.
292
+ if (!existsSync(cmdShim)) {
293
+ return;
294
+ }
295
+
296
+ // Detect architecture so ARM64 Windows is handled correctly
297
+ // (falls back to x64 binary — see platform detection above)
298
+ const cpuArch = effectiveArch;
299
+ const relativeBinaryPath = `node_modules\\agent-browser\\bin\\agent-browser-win32-${cpuArch}.exe`;
300
+ const absoluteBinaryPath = join(npmBinDir, relativeBinaryPath);
301
+
302
+ // Only rewrite shims if the native binary actually exists
303
+ if (!existsSync(absoluteBinaryPath)) {
304
+ return;
305
+ }
306
+
307
+ try {
308
+ const cmdContent = `@ECHO off\r\n"%~dp0${relativeBinaryPath}" %*\r\n`;
309
+ writeFileSync(cmdShim, cmdContent);
310
+
311
+ const ps1Content = `#!/usr/bin/env pwsh\r\n$basedir = Split-Path $MyInvocation.MyCommand.Definition -Parent\r\n& "$basedir\\${relativeBinaryPath}" $args\r\nexit $LASTEXITCODE\r\n`;
312
+ writeFileSync(ps1Shim, ps1Content);
313
+
314
+ console.log('✓ Optimized: shims point to native binary (zero overhead)');
315
+ } catch (err) {
316
+ console.log(`⚠ Could not optimize shims: ${err.message}`);
317
+ console.log(' CLI will work via Node.js wrapper (slightly slower startup)');
318
+ }
319
+ }
320
+
321
+ main().catch(console.error);
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Syncs the version from package.json to all other config files.
5
+ * Run this script before building or releasing.
6
+ */
7
+
8
+ import { execSync } from "child_process";
9
+ import { readFileSync, writeFileSync } from "fs";
10
+ import { dirname, join } from "path";
11
+ import { fileURLToPath } from "url";
12
+
13
+ const __dirname = dirname(fileURLToPath(import.meta.url));
14
+ const rootDir = join(__dirname, "..");
15
+ const cliDir = join(rootDir, "cli");
16
+
17
+ // Read version from package.json (single source of truth)
18
+ const packageJson = JSON.parse(
19
+ readFileSync(join(rootDir, "package.json"), "utf-8")
20
+ );
21
+ const version = packageJson.version;
22
+
23
+ console.log(`Syncing version ${version} to all config files...`);
24
+
25
+ // Update Cargo.toml
26
+ const cargoTomlPath = join(cliDir, "Cargo.toml");
27
+ let cargoToml = readFileSync(cargoTomlPath, "utf-8");
28
+ const cargoVersionRegex = /^version\s*=\s*"[^"]*"/m;
29
+ const newCargoVersion = `version = "${version}"`;
30
+
31
+ let cargoTomlUpdated = false;
32
+ if (cargoVersionRegex.test(cargoToml)) {
33
+ const oldMatch = cargoToml.match(cargoVersionRegex)?.[0];
34
+ if (oldMatch !== newCargoVersion) {
35
+ cargoToml = cargoToml.replace(cargoVersionRegex, newCargoVersion);
36
+ writeFileSync(cargoTomlPath, cargoToml);
37
+ console.log(` Updated cli/Cargo.toml: ${oldMatch} -> ${newCargoVersion}`);
38
+ cargoTomlUpdated = true;
39
+ } else {
40
+ console.log(` cli/Cargo.toml already up to date`);
41
+ }
42
+ } else {
43
+ console.error(" Could not find version field in cli/Cargo.toml");
44
+ process.exit(1);
45
+ }
46
+
47
+ // Update packages/dashboard/package.json
48
+ const dashboardPkgPath = join(rootDir, "packages", "dashboard", "package.json");
49
+ const dashboardPkg = JSON.parse(readFileSync(dashboardPkgPath, "utf-8"));
50
+ if (dashboardPkg.version !== version) {
51
+ const oldVersion = dashboardPkg.version;
52
+ dashboardPkg.version = version;
53
+ writeFileSync(dashboardPkgPath, JSON.stringify(dashboardPkg, null, 2) + "\n");
54
+ console.log(` Updated packages/dashboard/package.json: ${oldVersion} -> ${version}`);
55
+ } else {
56
+ console.log(` packages/dashboard/package.json already up to date`);
57
+ }
58
+
59
+ // Update packages/@agent-browser/sandbox/package.json
60
+ const sandboxPkgPath = join(rootDir, "packages", "@agent-browser", "sandbox", "package.json");
61
+ const sandboxPkg = JSON.parse(readFileSync(sandboxPkgPath, "utf-8"));
62
+ if (sandboxPkg.version !== version) {
63
+ const oldVersion = sandboxPkg.version;
64
+ sandboxPkg.version = version;
65
+ writeFileSync(sandboxPkgPath, JSON.stringify(sandboxPkg, null, 2) + "\n");
66
+ console.log(` Updated packages/@agent-browser/sandbox/package.json: ${oldVersion} -> ${version}`);
67
+ } else {
68
+ console.log(` packages/@agent-browser/sandbox/package.json already up to date`);
69
+ }
70
+
71
+ // Update packages/@agent-browser/eve/package.json (version + workspace sandbox dependency)
72
+ const evePkgPath = join(rootDir, "packages", "@agent-browser", "eve", "package.json");
73
+ const evePkg = JSON.parse(readFileSync(evePkgPath, "utf-8"));
74
+ const eveSandboxDependency = "workspace:^";
75
+ if (evePkg.version !== version || evePkg.dependencies["@agent-browser/sandbox"] !== eveSandboxDependency) {
76
+ const oldVersion = evePkg.version;
77
+ evePkg.version = version;
78
+ evePkg.dependencies["@agent-browser/sandbox"] = eveSandboxDependency;
79
+ writeFileSync(evePkgPath, JSON.stringify(evePkg, null, 2) + "\n");
80
+ console.log(` Updated packages/@agent-browser/eve/package.json: ${oldVersion} -> ${version}`);
81
+ } else {
82
+ console.log(` packages/@agent-browser/eve/package.json already up to date`);
83
+ }
84
+
85
+ // Update package runtime version constant
86
+ const sandboxVersionPath = join(
87
+ rootDir,
88
+ "packages",
89
+ "@agent-browser",
90
+ "sandbox",
91
+ "src",
92
+ "version.ts",
93
+ );
94
+ const sandboxVersionSource = `export const AGENT_BROWSER_SANDBOX_VERSION = "${version}";\n`;
95
+ const currentSandboxVersionSource = readFileSync(sandboxVersionPath, "utf-8");
96
+ if (currentSandboxVersionSource !== sandboxVersionSource) {
97
+ writeFileSync(sandboxVersionPath, sandboxVersionSource);
98
+ console.log(` Updated packages/@agent-browser/sandbox/src/version.ts -> ${version}`);
99
+ } else {
100
+ console.log(` packages/@agent-browser/sandbox/src/version.ts already up to date`);
101
+ }
102
+
103
+ // Update Cargo.lock to match Cargo.toml
104
+ if (cargoTomlUpdated) {
105
+ try {
106
+ execSync("cargo update -p agent-browser --offline", {
107
+ cwd: cliDir,
108
+ stdio: "pipe",
109
+ });
110
+ console.log(` Updated cli/Cargo.lock`);
111
+ } catch {
112
+ // --offline may fail if package not in cache, try without it
113
+ try {
114
+ execSync("cargo update -p agent-browser", {
115
+ cwd: cliDir,
116
+ stdio: "pipe",
117
+ });
118
+ console.log(` Updated cli/Cargo.lock`);
119
+ } catch (e) {
120
+ console.error(` Warning: Could not update Cargo.lock: ${e.message}`);
121
+ }
122
+ }
123
+ }
124
+
125
+ console.log("Version sync complete.");