agent-browser 0.15.2 → 0.16.0

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.
package/README.md CHANGED
@@ -495,6 +495,7 @@ This is useful for multimodal AI models that can reason about visual layout, unl
495
495
  | `--action-policy <path>` | Path to action policy JSON file (or `AGENT_BROWSER_ACTION_POLICY` env) |
496
496
  | `--confirm-actions <list>` | Action categories requiring confirmation (or `AGENT_BROWSER_CONFIRM_ACTIONS` env) |
497
497
  | `--confirm-interactive` | Interactive confirmation prompts; auto-denies if stdin is not a TTY (or `AGENT_BROWSER_CONFIRM_INTERACTIVE` env) |
498
+ | `--native` | [Experimental] Use native Rust daemon instead of Node.js (or `AGENT_BROWSER_NATIVE` env) |
498
499
  | `--config <path>` | Use a custom config file (or `AGENT_BROWSER_CONFIG` env) |
499
500
  | `--debug` | Debug output |
500
501
 
@@ -910,12 +911,50 @@ await browser.stopScreencast();
910
911
  agent-browser uses a client-daemon architecture:
911
912
 
912
913
  1. **Rust CLI** (fast native binary) - Parses commands, communicates with daemon
913
- 2. **Node.js Daemon** - Manages Playwright browser instance
914
- 3. **Fallback** - If native binary unavailable, uses Node.js directly
914
+ 2. **Node.js Daemon** (default) - Manages Playwright browser instance
915
+ 3. **Native Daemon** (experimental, `--native`) - Pure Rust daemon using direct CDP, no Node.js required
916
+ 4. **Fallback** - If native binary unavailable, uses Node.js directly
915
917
 
916
918
  The daemon starts automatically on first command and persists between commands for fast subsequent operations.
917
919
 
918
- **Browser Engine:** Uses Chromium by default. The daemon also supports Firefox and WebKit via the Playwright protocol.
920
+ **Browser Engine:** Uses Chromium by default. The default Node.js daemon also supports Firefox and WebKit via Playwright. The experimental native daemon speaks Chrome DevTools Protocol (CDP) directly and supports Chromium-based browsers and Safari (via WebDriver).
921
+
922
+ ## Experimental: Native Mode
923
+
924
+ The native daemon is a pure Rust implementation that communicates with Chrome directly via CDP, eliminating the Node.js and Playwright dependencies. It is currently **experimental** and opt-in.
925
+
926
+ ### Enabling Native Mode
927
+
928
+ ```bash
929
+ # Via flag
930
+ agent-browser --native open example.com
931
+
932
+ # Via environment variable (recommended for persistent use)
933
+ export AGENT_BROWSER_NATIVE=1
934
+ agent-browser open example.com
935
+ ```
936
+
937
+ Or add to your config file (`agent-browser.json`):
938
+
939
+ ```json
940
+ {"native": true}
941
+ ```
942
+
943
+ ### What's Different
944
+
945
+ | | Default (Node.js) | Native (`--native`) |
946
+ |---|---|---|
947
+ | **Runtime** | Node.js + Playwright | Pure Rust binary |
948
+ | **Protocol** | Playwright protocol | Direct CDP / WebDriver |
949
+ | **Install size** | Larger (Node.js + npm deps) | Smaller (single binary) |
950
+ | **Browser support** | Chromium, Firefox, WebKit | Chromium, Safari (via WebDriver) |
951
+ | **Stability** | Stable | Experimental |
952
+
953
+ ### Known Limitations
954
+
955
+ - Firefox and WebKit are not yet supported (Chromium and Safari only)
956
+ - Some Playwright-specific features (tracing format, HAR export) are not available
957
+ - The native daemon and Node.js daemon share the same session socket, so you cannot run both simultaneously for the same session. Use `agent-browser close` before switching modes.
919
958
 
920
959
  ## Platforms
921
960
 
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-browser",
3
- "version": "0.15.2",
3
+ "version": "0.16.0",
4
4
  "description": "Headless browser automation CLI for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/daemon.js",
@@ -187,46 +187,42 @@ async function fixUnixSymlink() {
187
187
  * We overwrite them to invoke the native .exe directly.
188
188
  */
189
189
  async function fixWindowsShims() {
190
- // Check if this is a global install by looking for npm's global prefix
191
190
  let npmBinDir;
192
191
  try {
193
192
  npmBinDir = execSync('npm prefix -g', { encoding: 'utf8' }).trim();
194
193
  } catch {
195
- return; // Not a global install or npm not available
194
+ return;
196
195
  }
197
196
 
198
- // The shims are in the npm prefix directory (not prefix/bin on Windows)
199
197
  const cmdShim = join(npmBinDir, 'agent-browser.cmd');
200
198
  const ps1Shim = join(npmBinDir, 'agent-browser.ps1');
201
199
 
202
- // Only fix if shims exist (indicates global install)
200
+ // Shims may not exist yet during postinstall (npm creates them after
201
+ // lifecycle scripts). If missing, fall back: the JS wrapper at
202
+ // bin/agent-browser.js handles Windows correctly via child_process.spawn.
203
203
  if (!existsSync(cmdShim)) {
204
204
  return;
205
205
  }
206
206
 
207
- // Path to native binary relative to npm prefix
208
- const relativeBinaryPath = 'node_modules\\agent-browser\\bin\\agent-browser-win32-x64.exe';
207
+ // Detect architecture so ARM64 Windows is handled correctly
208
+ const cpuArch = arch() === 'arm64' ? 'arm64' : 'x64';
209
+ const relativeBinaryPath = `node_modules\\agent-browser\\bin\\agent-browser-win32-${cpuArch}.exe`;
210
+ const absoluteBinaryPath = join(npmBinDir, relativeBinaryPath);
211
+
212
+ // Only rewrite shims if the native binary actually exists
213
+ if (!existsSync(absoluteBinaryPath)) {
214
+ return;
215
+ }
209
216
 
210
217
  try {
211
- // Overwrite .cmd shim
212
218
  const cmdContent = `@ECHO off\r\n"%~dp0${relativeBinaryPath}" %*\r\n`;
213
219
  writeFileSync(cmdShim, cmdContent);
214
220
 
215
- // Overwrite .ps1 shim
216
- const ps1Content = `#!/usr/bin/env pwsh
217
- $basedir = Split-Path $MyInvocation.MyCommand.Definition -Parent
218
- $exe = ""
219
- if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
220
- $exe = ".exe"
221
- }
222
- & "$basedir/${relativeBinaryPath.replace(/\\/g, '/')}" $args
223
- exit $LASTEXITCODE
224
- `;
221
+ 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`;
225
222
  writeFileSync(ps1Shim, ps1Content);
226
223
 
227
224
  console.log('✓ Optimized: shims point to native binary (zero overhead)');
228
225
  } catch (err) {
229
- // Permission error or other issue - not critical, JS wrapper still works
230
226
  console.log(`⚠ Could not optimize shims: ${err.message}`);
231
227
  console.log(' CLI will work via Node.js wrapper (slightly slower startup)');
232
228
  }
@@ -485,6 +485,21 @@ Priority (lowest to highest): `~/.agent-browser/config.json` < `./agent-browser.
485
485
  | [references/profiling.md](references/profiling.md) | Chrome DevTools profiling for performance analysis |
486
486
  | [references/proxy-support.md](references/proxy-support.md) | Proxy configuration, geo-testing, rotating proxies |
487
487
 
488
+ ## Experimental: Native Mode
489
+
490
+ agent-browser has an experimental native Rust daemon that communicates with Chrome directly via CDP, bypassing Node.js and Playwright entirely. It is opt-in and not recommended for production use yet.
491
+
492
+ ```bash
493
+ # Enable via flag
494
+ agent-browser --native open example.com
495
+
496
+ # Enable via environment variable (avoids passing --native every time)
497
+ export AGENT_BROWSER_NATIVE=1
498
+ agent-browser open example.com
499
+ ```
500
+
501
+ The native daemon supports Chromium and Safari (via WebDriver). Firefox and WebKit are not yet supported. All core commands (navigate, snapshot, click, fill, screenshot, cookies, storage, tabs, eval, etc.) work identically in native mode. Use `agent-browser close` before switching between native and default mode within the same session.
502
+
488
503
  ## Ready-to-Use Templates
489
504
 
490
505
  | Template | Description |