agent-browser 0.6.0 → 0.7.2

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 (42) hide show
  1. package/README.md +90 -9
  2. package/bin/agent-browser-darwin-arm64 +0 -0
  3. package/bin/agent-browser-darwin-x64 +0 -0
  4. package/bin/agent-browser-linux-arm64 +0 -0
  5. package/bin/agent-browser-linux-x64 +0 -0
  6. package/bin/agent-browser-win32-x64.exe +0 -0
  7. package/dist/actions.js +17 -11
  8. package/dist/actions.js.map +1 -1
  9. package/dist/browser.d.ts +24 -1
  10. package/dist/browser.d.ts.map +1 -1
  11. package/dist/browser.js +241 -21
  12. package/dist/browser.js.map +1 -1
  13. package/dist/daemon.d.ts +5 -0
  14. package/dist/daemon.d.ts.map +1 -1
  15. package/dist/daemon.js +51 -5
  16. package/dist/daemon.js.map +1 -1
  17. package/dist/protocol.d.ts.map +1 -1
  18. package/dist/protocol.js +11 -0
  19. package/dist/protocol.js.map +1 -1
  20. package/dist/types.d.ts +5 -0
  21. package/dist/types.d.ts.map +1 -1
  22. package/package.json +26 -23
  23. package/scripts/build-all-platforms.sh +0 -0
  24. package/scripts/copy-native.js +2 -1
  25. package/scripts/postinstall.js +1 -1
  26. package/skills/agent-browser/SKILL.md +132 -35
  27. package/skills/agent-browser/references/authentication.md +188 -0
  28. package/skills/agent-browser/references/proxy-support.md +175 -0
  29. package/skills/agent-browser/references/session-management.md +181 -0
  30. package/skills/agent-browser/references/snapshot-refs.md +186 -0
  31. package/skills/agent-browser/references/video-recording.md +162 -0
  32. package/skills/agent-browser/templates/authenticated-session.sh +91 -0
  33. package/skills/agent-browser/templates/capture-workflow.sh +68 -0
  34. package/skills/agent-browser/templates/form-automation.sh +64 -0
  35. package/dist/browser.test.d.ts +0 -2
  36. package/dist/browser.test.d.ts.map +0 -1
  37. package/dist/browser.test.js +0 -136
  38. package/dist/browser.test.js.map +0 -1
  39. package/dist/protocol.test.d.ts +0 -2
  40. package/dist/protocol.test.d.ts.map +0 -1
  41. package/dist/protocol.test.js +0 -176
  42. package/dist/protocol.test.js.map +0 -1
@@ -26,15 +26,20 @@ agent-browser close # Close browser
26
26
  ## Commands
27
27
 
28
28
  ### Navigation
29
+
29
30
  ```bash
30
- agent-browser open <url> # Navigate to URL
31
+ agent-browser open <url> # Navigate to URL (aliases: goto, navigate)
32
+ # Supports: https://, http://, file://, about:, data://
33
+ # Auto-prepends https:// if no protocol given
31
34
  agent-browser back # Go back
32
35
  agent-browser forward # Go forward
33
36
  agent-browser reload # Reload page
34
- agent-browser close # Close browser
37
+ agent-browser close # Close browser (aliases: quit, exit)
38
+ agent-browser connect 9222 # Connect to browser via CDP port
35
39
  ```
36
40
 
37
41
  ### Snapshot (page analysis)
42
+
38
43
  ```bash
39
44
  agent-browser snapshot # Full accessibility tree
40
45
  agent-browser snapshot -i # Interactive elements only (recommended)
@@ -44,27 +49,30 @@ agent-browser snapshot -s "#main" # Scope to CSS selector
44
49
  ```
45
50
 
46
51
  ### Interactions (use @refs from snapshot)
52
+
47
53
  ```bash
48
54
  agent-browser click @e1 # Click
49
55
  agent-browser dblclick @e1 # Double-click
50
56
  agent-browser focus @e1 # Focus element
51
57
  agent-browser fill @e2 "text" # Clear and type
52
58
  agent-browser type @e2 "text" # Type without clearing
53
- agent-browser press Enter # Press key
59
+ agent-browser press Enter # Press key (alias: key)
54
60
  agent-browser press Control+a # Key combination
55
61
  agent-browser keydown Shift # Hold key down
56
62
  agent-browser keyup Shift # Release key
57
63
  agent-browser hover @e1 # Hover
58
64
  agent-browser check @e1 # Check checkbox
59
65
  agent-browser uncheck @e1 # Uncheck checkbox
60
- agent-browser select @e1 "value" # Select dropdown
61
- agent-browser scroll down 500 # Scroll page
62
- agent-browser scrollintoview @e1 # Scroll element into view
66
+ agent-browser select @e1 "value" # Select dropdown option
67
+ agent-browser select @e1 "a" "b" # Select multiple options
68
+ agent-browser scroll down 500 # Scroll page (default: down 300px)
69
+ agent-browser scrollintoview @e1 # Scroll element into view (alias: scrollinto)
63
70
  agent-browser drag @e1 @e2 # Drag and drop
64
71
  agent-browser upload @e1 file.pdf # Upload files
65
72
  ```
66
73
 
67
74
  ### Get information
75
+
68
76
  ```bash
69
77
  agent-browser get text @e1 # Get element text
70
78
  agent-browser get html @e1 # Get innerHTML
@@ -74,9 +82,11 @@ agent-browser get title # Get page title
74
82
  agent-browser get url # Get current URL
75
83
  agent-browser get count ".item" # Count matching elements
76
84
  agent-browser get box @e1 # Get bounding box
85
+ agent-browser get styles @e1 # Get computed styles (font, color, bg, etc.)
77
86
  ```
78
87
 
79
88
  ### Check state
89
+
80
90
  ```bash
81
91
  agent-browser is visible @e1 # Check if visible
82
92
  agent-browser is enabled @e1 # Check if enabled
@@ -84,6 +94,7 @@ agent-browser is checked @e1 # Check if checked
84
94
  ```
85
95
 
86
96
  ### Screenshots & PDF
97
+
87
98
  ```bash
88
99
  agent-browser screenshot # Screenshot to stdout
89
100
  agent-browser screenshot path.png # Save to file
@@ -92,25 +103,30 @@ agent-browser pdf output.pdf # Save as PDF
92
103
  ```
93
104
 
94
105
  ### Video recording
106
+
95
107
  ```bash
96
108
  agent-browser record start ./demo.webm # Start recording (uses current URL + state)
97
109
  agent-browser click @e1 # Perform actions
98
110
  agent-browser record stop # Stop and save video
99
111
  agent-browser record restart ./take2.webm # Stop current + start new recording
100
112
  ```
101
- Recording creates a fresh context but preserves cookies/storage from your session. If no URL is provided, it automatically returns to your current page. For smooth demos, explore first, then start recording.
113
+
114
+ Recording creates a fresh context but preserves cookies/storage from your session. If no URL is provided, it
115
+ automatically returns to your current page. For smooth demos, explore first, then start recording.
102
116
 
103
117
  ### Wait
118
+
104
119
  ```bash
105
120
  agent-browser wait @e1 # Wait for element
106
121
  agent-browser wait 2000 # Wait milliseconds
107
- agent-browser wait --text "Success" # Wait for text
108
- agent-browser wait --url "**/dashboard" # Wait for URL pattern
109
- agent-browser wait --load networkidle # Wait for network idle
110
- agent-browser wait --fn "window.ready" # Wait for JS condition
122
+ agent-browser wait --text "Success" # Wait for text (or -t)
123
+ agent-browser wait --url "**/dashboard" # Wait for URL pattern (or -u)
124
+ agent-browser wait --load networkidle # Wait for network idle (or -l)
125
+ agent-browser wait --fn "window.ready" # Wait for JS condition (or -f)
111
126
  ```
112
127
 
113
128
  ### Mouse control
129
+
114
130
  ```bash
115
131
  agent-browser mouse move 100 200 # Move mouse
116
132
  agent-browser mouse down left # Press button
@@ -119,26 +135,36 @@ agent-browser mouse wheel 100 # Scroll wheel
119
135
  ```
120
136
 
121
137
  ### Semantic locators (alternative to refs)
138
+
122
139
  ```bash
123
140
  agent-browser find role button click --name "Submit"
124
141
  agent-browser find text "Sign In" click
142
+ agent-browser find text "Sign In" click --exact # Exact match only
125
143
  agent-browser find label "Email" fill "user@test.com"
144
+ agent-browser find placeholder "Search" type "query"
145
+ agent-browser find alt "Logo" click
146
+ agent-browser find title "Close" click
147
+ agent-browser find testid "submit-btn" click
126
148
  agent-browser find first ".item" click
127
- agent-browser find nth 2 "a" text
149
+ agent-browser find last ".item" click
150
+ agent-browser find nth 2 "a" hover
128
151
  ```
129
152
 
130
153
  ### Browser settings
154
+
131
155
  ```bash
132
- agent-browser set viewport 1920 1080 # Set viewport size
133
- agent-browser set device "iPhone 14" # Emulate device
134
- agent-browser set geo 37.7749 -122.4194 # Set geolocation
135
- agent-browser set offline on # Toggle offline mode
136
- agent-browser set headers '{"X-Key":"v"}' # Extra HTTP headers
137
- agent-browser set credentials user pass # HTTP basic auth
138
- agent-browser set media dark # Emulate color scheme
156
+ agent-browser set viewport 1920 1080 # Set viewport size
157
+ agent-browser set device "iPhone 14" # Emulate device
158
+ agent-browser set geo 37.7749 -122.4194 # Set geolocation (alias: geolocation)
159
+ agent-browser set offline on # Toggle offline mode
160
+ agent-browser set headers '{"X-Key":"v"}' # Extra HTTP headers
161
+ agent-browser set credentials user pass # HTTP basic auth (alias: auth)
162
+ agent-browser set media dark # Emulate color scheme
163
+ agent-browser set media light reduced-motion # Light mode + reduced motion
139
164
  ```
140
165
 
141
166
  ### Cookies & Storage
167
+
142
168
  ```bash
143
169
  agent-browser cookies # Get all cookies
144
170
  agent-browser cookies set name value # Set cookie
@@ -150,6 +176,7 @@ agent-browser storage local clear # Clear all
150
176
  ```
151
177
 
152
178
  ### Network
179
+
153
180
  ```bash
154
181
  agent-browser network route <url> # Intercept requests
155
182
  agent-browser network route <url> --abort # Block requests
@@ -160,31 +187,73 @@ agent-browser network requests --filter api # Filter requests
160
187
  ```
161
188
 
162
189
  ### Tabs & Windows
190
+
163
191
  ```bash
164
192
  agent-browser tab # List tabs
165
193
  agent-browser tab new [url] # New tab
166
- agent-browser tab 2 # Switch to tab
167
- agent-browser tab close # Close tab
194
+ agent-browser tab 2 # Switch to tab by index
195
+ agent-browser tab close # Close current tab
196
+ agent-browser tab close 2 # Close tab by index
168
197
  agent-browser window new # New window
169
198
  ```
170
199
 
171
200
  ### Frames
201
+
172
202
  ```bash
173
203
  agent-browser frame "#iframe" # Switch to iframe
174
204
  agent-browser frame main # Back to main frame
175
205
  ```
176
206
 
177
207
  ### Dialogs
208
+
178
209
  ```bash
179
210
  agent-browser dialog accept [text] # Accept dialog
180
211
  agent-browser dialog dismiss # Dismiss dialog
181
212
  ```
182
213
 
183
214
  ### JavaScript
215
+
184
216
  ```bash
185
217
  agent-browser eval "document.title" # Run JavaScript
186
218
  ```
187
219
 
220
+ ## Global options
221
+
222
+ ```bash
223
+ agent-browser --session <name> ... # Isolated browser session
224
+ agent-browser --json ... # JSON output for parsing
225
+ agent-browser --headed ... # Show browser window (not headless)
226
+ agent-browser --full ... # Full page screenshot (-f)
227
+ agent-browser --cdp <port> ... # Connect via Chrome DevTools Protocol
228
+ agent-browser -p <provider> ... # Cloud browser provider (--provider)
229
+ agent-browser --proxy <url> ... # Use proxy server
230
+ agent-browser --headers <json> ... # HTTP headers scoped to URL's origin
231
+ agent-browser --executable-path <p> # Custom browser executable
232
+ agent-browser --extension <path> ... # Load browser extension (repeatable)
233
+ agent-browser --help # Show help (-h)
234
+ agent-browser --version # Show version (-V)
235
+ agent-browser <command> --help # Show detailed help for a command
236
+ ```
237
+
238
+ ### Proxy support
239
+
240
+ ```bash
241
+ agent-browser --proxy http://proxy.com:8080 open example.com
242
+ agent-browser --proxy http://user:pass@proxy.com:8080 open example.com
243
+ agent-browser --proxy socks5://proxy.com:1080 open example.com
244
+ ```
245
+
246
+ ## Environment variables
247
+
248
+ ```bash
249
+ AGENT_BROWSER_SESSION="mysession" # Default session name
250
+ AGENT_BROWSER_EXECUTABLE_PATH="/path/chrome" # Custom browser path
251
+ AGENT_BROWSER_EXTENSIONS="/ext1,/ext2" # Comma-separated extension paths
252
+ AGENT_BROWSER_PROVIDER="browserbase" # Cloud browser provider
253
+ AGENT_BROWSER_STREAM_PORT="9223" # WebSocket streaming port
254
+ AGENT_BROWSER_HOME="/path/to/agent-browser" # Custom install location (for daemon.js)
255
+ ```
256
+
188
257
  ## Example: Form submission
189
258
 
190
259
  ```bash
@@ -227,6 +296,7 @@ agent-browser session list
227
296
  ## JSON output (for parsing)
228
297
 
229
298
  Add `--json` for machine-readable output:
299
+
230
300
  ```bash
231
301
  agent-browser snapshot -i --json
232
302
  agent-browser get text @e1 --json
@@ -235,18 +305,45 @@ agent-browser get text @e1 --json
235
305
  ## Debugging
236
306
 
237
307
  ```bash
238
- agent-browser open example.com --headed # Show browser window
239
- agent-browser console # View console messages
240
- agent-browser errors # View page errors
241
- agent-browser record start ./debug.webm # Record from current page
242
- agent-browser record stop # Save recording
243
- agent-browser open example.com --headed # Show browser window
244
- agent-browser --cdp 9222 snapshot # Connect via CDP
245
- agent-browser console # View console messages
246
- agent-browser console --clear # Clear console
247
- agent-browser errors # View page errors
248
- agent-browser errors --clear # Clear errors
249
- agent-browser highlight @e1 # Highlight element
250
- agent-browser trace start # Start recording trace
251
- agent-browser trace stop trace.zip # Stop and save trace
308
+ agent-browser --headed open example.com # Show browser window
309
+ agent-browser --cdp 9222 snapshot # Connect via CDP port
310
+ agent-browser connect 9222 # Alternative: connect command
311
+ agent-browser console # View console messages
312
+ agent-browser console --clear # Clear console
313
+ agent-browser errors # View page errors
314
+ agent-browser errors --clear # Clear errors
315
+ agent-browser highlight @e1 # Highlight element
316
+ agent-browser trace start # Start recording trace
317
+ agent-browser trace stop trace.zip # Stop and save trace
318
+ agent-browser record start ./debug.webm # Record video from current page
319
+ agent-browser record stop # Save recording
320
+ ```
321
+
322
+ ## Deep-dive documentation
323
+
324
+ For detailed patterns and best practices, see:
325
+
326
+ | Reference | Description |
327
+ |-----------|-------------|
328
+ | [references/snapshot-refs.md](references/snapshot-refs.md) | Ref lifecycle, invalidation rules, troubleshooting |
329
+ | [references/session-management.md](references/session-management.md) | Parallel sessions, state persistence, concurrent scraping |
330
+ | [references/authentication.md](references/authentication.md) | Login flows, OAuth, 2FA handling, state reuse |
331
+ | [references/video-recording.md](references/video-recording.md) | Recording workflows for debugging and documentation |
332
+ | [references/proxy-support.md](references/proxy-support.md) | Proxy configuration, geo-testing, rotating proxies |
333
+
334
+ ## Ready-to-use templates
335
+
336
+ Executable workflow scripts for common patterns:
337
+
338
+ | Template | Description |
339
+ |----------|-------------|
340
+ | [templates/form-automation.sh](templates/form-automation.sh) | Form filling with validation |
341
+ | [templates/authenticated-session.sh](templates/authenticated-session.sh) | Login once, reuse state |
342
+ | [templates/capture-workflow.sh](templates/capture-workflow.sh) | Content extraction with screenshots |
343
+
344
+ Usage:
345
+ ```bash
346
+ ./templates/form-automation.sh https://example.com/form
347
+ ./templates/authenticated-session.sh https://app.example.com/login
348
+ ./templates/capture-workflow.sh https://example.com ./output
252
349
  ```
@@ -0,0 +1,188 @@
1
+ # Authentication Patterns
2
+
3
+ Patterns for handling login flows, session persistence, and authenticated browsing.
4
+
5
+ ## Basic Login Flow
6
+
7
+ ```bash
8
+ # Navigate to login page
9
+ agent-browser open https://app.example.com/login
10
+ agent-browser wait --load networkidle
11
+
12
+ # Get form elements
13
+ agent-browser snapshot -i
14
+ # Output: @e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Sign In"
15
+
16
+ # Fill credentials
17
+ agent-browser fill @e1 "user@example.com"
18
+ agent-browser fill @e2 "password123"
19
+
20
+ # Submit
21
+ agent-browser click @e3
22
+ agent-browser wait --load networkidle
23
+
24
+ # Verify login succeeded
25
+ agent-browser get url # Should be dashboard, not login
26
+ ```
27
+
28
+ ## Saving Authentication State
29
+
30
+ After logging in, save state for reuse:
31
+
32
+ ```bash
33
+ # Login first (see above)
34
+ agent-browser open https://app.example.com/login
35
+ agent-browser snapshot -i
36
+ agent-browser fill @e1 "user@example.com"
37
+ agent-browser fill @e2 "password123"
38
+ agent-browser click @e3
39
+ agent-browser wait --url "**/dashboard"
40
+
41
+ # Save authenticated state
42
+ agent-browser state save ./auth-state.json
43
+ ```
44
+
45
+ ## Restoring Authentication
46
+
47
+ Skip login by loading saved state:
48
+
49
+ ```bash
50
+ # Load saved auth state
51
+ agent-browser state load ./auth-state.json
52
+
53
+ # Navigate directly to protected page
54
+ agent-browser open https://app.example.com/dashboard
55
+
56
+ # Verify authenticated
57
+ agent-browser snapshot -i
58
+ ```
59
+
60
+ ## OAuth / SSO Flows
61
+
62
+ For OAuth redirects:
63
+
64
+ ```bash
65
+ # Start OAuth flow
66
+ agent-browser open https://app.example.com/auth/google
67
+
68
+ # Handle redirects automatically
69
+ agent-browser wait --url "**/accounts.google.com**"
70
+ agent-browser snapshot -i
71
+
72
+ # Fill Google credentials
73
+ agent-browser fill @e1 "user@gmail.com"
74
+ agent-browser click @e2 # Next button
75
+ agent-browser wait 2000
76
+ agent-browser snapshot -i
77
+ agent-browser fill @e3 "password"
78
+ agent-browser click @e4 # Sign in
79
+
80
+ # Wait for redirect back
81
+ agent-browser wait --url "**/app.example.com**"
82
+ agent-browser state save ./oauth-state.json
83
+ ```
84
+
85
+ ## Two-Factor Authentication
86
+
87
+ Handle 2FA with manual intervention:
88
+
89
+ ```bash
90
+ # Login with credentials
91
+ agent-browser open https://app.example.com/login --headed # Show browser
92
+ agent-browser snapshot -i
93
+ agent-browser fill @e1 "user@example.com"
94
+ agent-browser fill @e2 "password123"
95
+ agent-browser click @e3
96
+
97
+ # Wait for user to complete 2FA manually
98
+ echo "Complete 2FA in the browser window..."
99
+ agent-browser wait --url "**/dashboard" --timeout 120000
100
+
101
+ # Save state after 2FA
102
+ agent-browser state save ./2fa-state.json
103
+ ```
104
+
105
+ ## HTTP Basic Auth
106
+
107
+ For sites using HTTP Basic Authentication:
108
+
109
+ ```bash
110
+ # Set credentials before navigation
111
+ agent-browser set credentials username password
112
+
113
+ # Navigate to protected resource
114
+ agent-browser open https://protected.example.com/api
115
+ ```
116
+
117
+ ## Cookie-Based Auth
118
+
119
+ Manually set authentication cookies:
120
+
121
+ ```bash
122
+ # Set auth cookie
123
+ agent-browser cookies set session_token "abc123xyz"
124
+
125
+ # Navigate to protected page
126
+ agent-browser open https://app.example.com/dashboard
127
+ ```
128
+
129
+ ## Token Refresh Handling
130
+
131
+ For sessions with expiring tokens:
132
+
133
+ ```bash
134
+ #!/bin/bash
135
+ # Wrapper that handles token refresh
136
+
137
+ STATE_FILE="./auth-state.json"
138
+
139
+ # Try loading existing state
140
+ if [[ -f "$STATE_FILE" ]]; then
141
+ agent-browser state load "$STATE_FILE"
142
+ agent-browser open https://app.example.com/dashboard
143
+
144
+ # Check if session is still valid
145
+ URL=$(agent-browser get url)
146
+ if [[ "$URL" == *"/login"* ]]; then
147
+ echo "Session expired, re-authenticating..."
148
+ # Perform fresh login
149
+ agent-browser snapshot -i
150
+ agent-browser fill @e1 "$USERNAME"
151
+ agent-browser fill @e2 "$PASSWORD"
152
+ agent-browser click @e3
153
+ agent-browser wait --url "**/dashboard"
154
+ agent-browser state save "$STATE_FILE"
155
+ fi
156
+ else
157
+ # First-time login
158
+ agent-browser open https://app.example.com/login
159
+ # ... login flow ...
160
+ fi
161
+ ```
162
+
163
+ ## Security Best Practices
164
+
165
+ 1. **Never commit state files** - They contain session tokens
166
+ ```bash
167
+ echo "*.auth-state.json" >> .gitignore
168
+ ```
169
+
170
+ 2. **Use environment variables for credentials**
171
+ ```bash
172
+ agent-browser fill @e1 "$APP_USERNAME"
173
+ agent-browser fill @e2 "$APP_PASSWORD"
174
+ ```
175
+
176
+ 3. **Clean up after automation**
177
+ ```bash
178
+ agent-browser cookies clear
179
+ rm -f ./auth-state.json
180
+ ```
181
+
182
+ 4. **Use short-lived sessions for CI/CD**
183
+ ```bash
184
+ # Don't persist state in CI
185
+ agent-browser open https://app.example.com/login
186
+ # ... login and perform actions ...
187
+ agent-browser close # Session ends, nothing persisted
188
+ ```
@@ -0,0 +1,175 @@
1
+ # Proxy Support
2
+
3
+ Configure proxy servers for browser automation, useful for geo-testing, rate limiting avoidance, and corporate environments.
4
+
5
+ ## Basic Proxy Configuration
6
+
7
+ Set proxy via environment variable before starting:
8
+
9
+ ```bash
10
+ # HTTP proxy
11
+ export HTTP_PROXY="http://proxy.example.com:8080"
12
+ agent-browser open https://example.com
13
+
14
+ # HTTPS proxy
15
+ export HTTPS_PROXY="https://proxy.example.com:8080"
16
+ agent-browser open https://example.com
17
+
18
+ # Both
19
+ export HTTP_PROXY="http://proxy.example.com:8080"
20
+ export HTTPS_PROXY="http://proxy.example.com:8080"
21
+ agent-browser open https://example.com
22
+ ```
23
+
24
+ ## Authenticated Proxy
25
+
26
+ For proxies requiring authentication:
27
+
28
+ ```bash
29
+ # Include credentials in URL
30
+ export HTTP_PROXY="http://username:password@proxy.example.com:8080"
31
+ agent-browser open https://example.com
32
+ ```
33
+
34
+ ## SOCKS Proxy
35
+
36
+ ```bash
37
+ # SOCKS5 proxy
38
+ export ALL_PROXY="socks5://proxy.example.com:1080"
39
+ agent-browser open https://example.com
40
+
41
+ # SOCKS5 with auth
42
+ export ALL_PROXY="socks5://user:pass@proxy.example.com:1080"
43
+ agent-browser open https://example.com
44
+ ```
45
+
46
+ ## Proxy Bypass
47
+
48
+ Skip proxy for specific domains:
49
+
50
+ ```bash
51
+ # Bypass proxy for local addresses
52
+ export NO_PROXY="localhost,127.0.0.1,.internal.company.com"
53
+ agent-browser open https://internal.company.com # Direct connection
54
+ agent-browser open https://external.com # Via proxy
55
+ ```
56
+
57
+ ## Common Use Cases
58
+
59
+ ### Geo-Location Testing
60
+
61
+ ```bash
62
+ #!/bin/bash
63
+ # Test site from different regions using geo-located proxies
64
+
65
+ PROXIES=(
66
+ "http://us-proxy.example.com:8080"
67
+ "http://eu-proxy.example.com:8080"
68
+ "http://asia-proxy.example.com:8080"
69
+ )
70
+
71
+ for proxy in "${PROXIES[@]}"; do
72
+ export HTTP_PROXY="$proxy"
73
+ export HTTPS_PROXY="$proxy"
74
+
75
+ region=$(echo "$proxy" | grep -oP '^\w+-\w+')
76
+ echo "Testing from: $region"
77
+
78
+ agent-browser --session "$region" open https://example.com
79
+ agent-browser --session "$region" screenshot "./screenshots/$region.png"
80
+ agent-browser --session "$region" close
81
+ done
82
+ ```
83
+
84
+ ### Rotating Proxies for Scraping
85
+
86
+ ```bash
87
+ #!/bin/bash
88
+ # Rotate through proxy list to avoid rate limiting
89
+
90
+ PROXY_LIST=(
91
+ "http://proxy1.example.com:8080"
92
+ "http://proxy2.example.com:8080"
93
+ "http://proxy3.example.com:8080"
94
+ )
95
+
96
+ URLS=(
97
+ "https://site.com/page1"
98
+ "https://site.com/page2"
99
+ "https://site.com/page3"
100
+ )
101
+
102
+ for i in "${!URLS[@]}"; do
103
+ proxy_index=$((i % ${#PROXY_LIST[@]}))
104
+ export HTTP_PROXY="${PROXY_LIST[$proxy_index]}"
105
+ export HTTPS_PROXY="${PROXY_LIST[$proxy_index]}"
106
+
107
+ agent-browser open "${URLS[$i]}"
108
+ agent-browser get text body > "output-$i.txt"
109
+ agent-browser close
110
+
111
+ sleep 1 # Polite delay
112
+ done
113
+ ```
114
+
115
+ ### Corporate Network Access
116
+
117
+ ```bash
118
+ #!/bin/bash
119
+ # Access internal sites via corporate proxy
120
+
121
+ export HTTP_PROXY="http://corpproxy.company.com:8080"
122
+ export HTTPS_PROXY="http://corpproxy.company.com:8080"
123
+ export NO_PROXY="localhost,127.0.0.1,.company.com"
124
+
125
+ # External sites go through proxy
126
+ agent-browser open https://external-vendor.com
127
+
128
+ # Internal sites bypass proxy
129
+ agent-browser open https://intranet.company.com
130
+ ```
131
+
132
+ ## Verifying Proxy Connection
133
+
134
+ ```bash
135
+ # Check your apparent IP
136
+ agent-browser open https://httpbin.org/ip
137
+ agent-browser get text body
138
+ # Should show proxy's IP, not your real IP
139
+ ```
140
+
141
+ ## Troubleshooting
142
+
143
+ ### Proxy Connection Failed
144
+
145
+ ```bash
146
+ # Test proxy connectivity first
147
+ curl -x http://proxy.example.com:8080 https://httpbin.org/ip
148
+
149
+ # Check if proxy requires auth
150
+ export HTTP_PROXY="http://user:pass@proxy.example.com:8080"
151
+ ```
152
+
153
+ ### SSL/TLS Errors Through Proxy
154
+
155
+ Some proxies perform SSL inspection. If you encounter certificate errors:
156
+
157
+ ```bash
158
+ # For testing only - not recommended for production
159
+ agent-browser open https://example.com --ignore-https-errors
160
+ ```
161
+
162
+ ### Slow Performance
163
+
164
+ ```bash
165
+ # Use proxy only when necessary
166
+ export NO_PROXY="*.cdn.com,*.static.com" # Direct CDN access
167
+ ```
168
+
169
+ ## Best Practices
170
+
171
+ 1. **Use environment variables** - Don't hardcode proxy credentials
172
+ 2. **Set NO_PROXY appropriately** - Avoid routing local traffic through proxy
173
+ 3. **Test proxy before automation** - Verify connectivity with simple requests
174
+ 4. **Handle proxy failures gracefully** - Implement retry logic for unstable proxies
175
+ 5. **Rotate proxies for large scraping jobs** - Distribute load and avoid bans