@sentry/junior-agent-browser 0.4.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.
@@ -0,0 +1,263 @@
1
+ # Command Reference
2
+
3
+ Complete reference for all agent-browser commands. For quick start and common patterns, see SKILL.md.
4
+
5
+ ## Navigation
6
+
7
+ ```bash
8
+ agent-browser open <url> # Navigate to URL (aliases: goto, navigate)
9
+ # Supports: https://, http://, file://, about:, data://
10
+ # Auto-prepends https:// if no protocol given
11
+ agent-browser back # Go back
12
+ agent-browser forward # Go forward
13
+ agent-browser reload # Reload page
14
+ agent-browser close # Close browser (aliases: quit, exit)
15
+ agent-browser connect 9222 # Connect to browser via CDP port
16
+ ```
17
+
18
+ ## Snapshot (page analysis)
19
+
20
+ ```bash
21
+ agent-browser snapshot # Full accessibility tree
22
+ agent-browser snapshot -i # Interactive elements only (recommended)
23
+ agent-browser snapshot -c # Compact output
24
+ agent-browser snapshot -d 3 # Limit depth to 3
25
+ agent-browser snapshot -s "#main" # Scope to CSS selector
26
+ ```
27
+
28
+ ## Interactions (use @refs from snapshot)
29
+
30
+ ```bash
31
+ agent-browser click @e1 # Click
32
+ agent-browser click @e1 --new-tab # Click and open in new tab
33
+ agent-browser dblclick @e1 # Double-click
34
+ agent-browser focus @e1 # Focus element
35
+ agent-browser fill @e2 "text" # Clear and type
36
+ agent-browser type @e2 "text" # Type without clearing
37
+ agent-browser press Enter # Press key (alias: key)
38
+ agent-browser press Control+a # Key combination
39
+ agent-browser keydown Shift # Hold key down
40
+ agent-browser keyup Shift # Release key
41
+ agent-browser hover @e1 # Hover
42
+ agent-browser check @e1 # Check checkbox
43
+ agent-browser uncheck @e1 # Uncheck checkbox
44
+ agent-browser select @e1 "value" # Select dropdown option
45
+ agent-browser select @e1 "a" "b" # Select multiple options
46
+ agent-browser scroll down 500 # Scroll page (default: down 300px)
47
+ agent-browser scrollintoview @e1 # Scroll element into view (alias: scrollinto)
48
+ agent-browser drag @e1 @e2 # Drag and drop
49
+ agent-browser upload @e1 file.pdf # Upload files
50
+ ```
51
+
52
+ ## Get Information
53
+
54
+ ```bash
55
+ agent-browser get text @e1 # Get element text
56
+ agent-browser get html @e1 # Get innerHTML
57
+ agent-browser get value @e1 # Get input value
58
+ agent-browser get attr @e1 href # Get attribute
59
+ agent-browser get title # Get page title
60
+ agent-browser get url # Get current URL
61
+ agent-browser get count ".item" # Count matching elements
62
+ agent-browser get box @e1 # Get bounding box
63
+ agent-browser get styles @e1 # Get computed styles (font, color, bg, etc.)
64
+ ```
65
+
66
+ ## Check State
67
+
68
+ ```bash
69
+ agent-browser is visible @e1 # Check if visible
70
+ agent-browser is enabled @e1 # Check if enabled
71
+ agent-browser is checked @e1 # Check if checked
72
+ ```
73
+
74
+ ## Screenshots and PDF
75
+
76
+ ```bash
77
+ agent-browser screenshot # Save to temporary directory
78
+ agent-browser screenshot path.png # Save to specific path
79
+ agent-browser screenshot --full # Full page
80
+ agent-browser pdf output.pdf # Save as PDF
81
+ ```
82
+
83
+ ## Video Recording
84
+
85
+ ```bash
86
+ agent-browser record start ./demo.webm # Start recording
87
+ agent-browser click @e1 # Perform actions
88
+ agent-browser record stop # Stop and save video
89
+ agent-browser record restart ./take2.webm # Stop current + start new
90
+ ```
91
+
92
+ ## Wait
93
+
94
+ ```bash
95
+ agent-browser wait @e1 # Wait for element
96
+ agent-browser wait 2000 # Wait milliseconds
97
+ agent-browser wait --text "Success" # Wait for text (or -t)
98
+ agent-browser wait --url "**/dashboard" # Wait for URL pattern (or -u)
99
+ agent-browser wait --load networkidle # Wait for network idle (or -l)
100
+ agent-browser wait --fn "window.ready" # Wait for JS condition (or -f)
101
+ ```
102
+
103
+ ## Mouse Control
104
+
105
+ ```bash
106
+ agent-browser mouse move 100 200 # Move mouse
107
+ agent-browser mouse down left # Press button
108
+ agent-browser mouse up left # Release button
109
+ agent-browser mouse wheel 100 # Scroll wheel
110
+ ```
111
+
112
+ ## Semantic Locators (alternative to refs)
113
+
114
+ ```bash
115
+ agent-browser find role button click --name "Submit"
116
+ agent-browser find text "Sign In" click
117
+ agent-browser find text "Sign In" click --exact # Exact match only
118
+ agent-browser find label "Email" fill "user@test.com"
119
+ agent-browser find placeholder "Search" type "query"
120
+ agent-browser find alt "Logo" click
121
+ agent-browser find title "Close" click
122
+ agent-browser find testid "submit-btn" click
123
+ agent-browser find first ".item" click
124
+ agent-browser find last ".item" click
125
+ agent-browser find nth 2 "a" hover
126
+ ```
127
+
128
+ ## Browser Settings
129
+
130
+ ```bash
131
+ agent-browser set viewport 1920 1080 # Set viewport size
132
+ agent-browser set device "iPhone 14" # Emulate device
133
+ agent-browser set geo 37.7749 -122.4194 # Set geolocation (alias: geolocation)
134
+ agent-browser set offline on # Toggle offline mode
135
+ agent-browser set headers '{"X-Key":"v"}' # Extra HTTP headers
136
+ agent-browser set credentials user pass # HTTP basic auth (alias: auth)
137
+ agent-browser set media dark # Emulate color scheme
138
+ agent-browser set media light reduced-motion # Light mode + reduced motion
139
+ ```
140
+
141
+ ## Cookies and Storage
142
+
143
+ ```bash
144
+ agent-browser cookies # Get all cookies
145
+ agent-browser cookies set name value # Set cookie
146
+ agent-browser cookies clear # Clear cookies
147
+ agent-browser storage local # Get all localStorage
148
+ agent-browser storage local key # Get specific key
149
+ agent-browser storage local set k v # Set value
150
+ agent-browser storage local clear # Clear all
151
+ ```
152
+
153
+ ## Network
154
+
155
+ ```bash
156
+ agent-browser network route <url> # Intercept requests
157
+ agent-browser network route <url> --abort # Block requests
158
+ agent-browser network route <url> --body '{}' # Mock response
159
+ agent-browser network unroute [url] # Remove routes
160
+ agent-browser network requests # View tracked requests
161
+ agent-browser network requests --filter api # Filter requests
162
+ ```
163
+
164
+ ## Tabs and Windows
165
+
166
+ ```bash
167
+ agent-browser tab # List tabs
168
+ agent-browser tab new [url] # New tab
169
+ agent-browser tab 2 # Switch to tab by index
170
+ agent-browser tab close # Close current tab
171
+ agent-browser tab close 2 # Close tab by index
172
+ agent-browser window new # New window
173
+ ```
174
+
175
+ ## Frames
176
+
177
+ ```bash
178
+ agent-browser frame "#iframe" # Switch to iframe
179
+ agent-browser frame main # Back to main frame
180
+ ```
181
+
182
+ ## Dialogs
183
+
184
+ ```bash
185
+ agent-browser dialog accept [text] # Accept dialog
186
+ agent-browser dialog dismiss # Dismiss dialog
187
+ ```
188
+
189
+ ## JavaScript
190
+
191
+ ```bash
192
+ agent-browser eval "document.title" # Simple expressions only
193
+ agent-browser eval -b "<base64>" # Any JavaScript (base64 encoded)
194
+ agent-browser eval --stdin # Read script from stdin
195
+ ```
196
+
197
+ Use `-b`/`--base64` or `--stdin` for reliable execution. Shell escaping with nested quotes and special characters is error-prone.
198
+
199
+ ```bash
200
+ # Base64 encode your script, then:
201
+ agent-browser eval -b "ZG9jdW1lbnQucXVlcnlTZWxlY3RvcignW3NyYyo9Il9uZXh0Il0nKQ=="
202
+
203
+ # Or use stdin with heredoc for multiline scripts:
204
+ cat <<'EOF' | agent-browser eval --stdin
205
+ const links = document.querySelectorAll('a');
206
+ Array.from(links).map(a => a.href);
207
+ EOF
208
+ ```
209
+
210
+ ## State Management
211
+
212
+ ```bash
213
+ agent-browser state save auth.json # Save cookies, storage, auth state
214
+ agent-browser state load auth.json # Restore saved state
215
+ ```
216
+
217
+ ## Global Options
218
+
219
+ ```bash
220
+ agent-browser --session <name> ... # Isolated browser session
221
+ agent-browser --json ... # JSON output for parsing
222
+ agent-browser --headed ... # Show browser window (not headless)
223
+ agent-browser --full ... # Full page screenshot (-f)
224
+ agent-browser --cdp <port> ... # Connect via Chrome DevTools Protocol
225
+ agent-browser -p <provider> ... # Cloud browser provider (--provider)
226
+ agent-browser --proxy <url> ... # Use proxy server
227
+ agent-browser --proxy-bypass <hosts> # Hosts to bypass proxy
228
+ agent-browser --headers <json> ... # HTTP headers scoped to URL's origin
229
+ agent-browser --executable-path <p> # Custom browser executable
230
+ agent-browser --extension <path> ... # Load browser extension (repeatable)
231
+ agent-browser --ignore-https-errors # Ignore SSL certificate errors
232
+ agent-browser --help # Show help (-h)
233
+ agent-browser --version # Show version (-V)
234
+ agent-browser <command> --help # Show detailed help for a command
235
+ ```
236
+
237
+ ## Debugging
238
+
239
+ ```bash
240
+ agent-browser --headed open example.com # Show browser window
241
+ agent-browser --cdp 9222 snapshot # Connect via CDP port
242
+ agent-browser connect 9222 # Alternative: connect command
243
+ agent-browser console # View console messages
244
+ agent-browser console --clear # Clear console
245
+ agent-browser errors # View page errors
246
+ agent-browser errors --clear # Clear errors
247
+ agent-browser highlight @e1 # Highlight element
248
+ agent-browser trace start # Start recording trace
249
+ agent-browser trace stop trace.zip # Stop and save trace
250
+ agent-browser profiler start # Start Chrome DevTools profiling
251
+ agent-browser profiler stop trace.json # Stop and save profile
252
+ ```
253
+
254
+ ## Environment Variables
255
+
256
+ ```bash
257
+ AGENT_BROWSER_SESSION="mysession" # Default session name
258
+ AGENT_BROWSER_EXECUTABLE_PATH="/path/chrome" # Custom browser path
259
+ AGENT_BROWSER_EXTENSIONS="/ext1,/ext2" # Comma-separated extension paths
260
+ AGENT_BROWSER_PROVIDER="browserbase" # Cloud browser provider
261
+ AGENT_BROWSER_STREAM_PORT="9223" # WebSocket streaming port
262
+ AGENT_BROWSER_HOME="/path/to/agent-browser" # Custom install location
263
+ ```
@@ -0,0 +1,120 @@
1
+ # Profiling
2
+
3
+ Capture Chrome DevTools performance profiles during browser automation for performance analysis.
4
+
5
+ **Related**: [commands.md](commands.md) for full command reference, [SKILL.md](../SKILL.md) for quick start.
6
+
7
+ ## Contents
8
+
9
+ - [Basic Profiling](#basic-profiling)
10
+ - [Profiler Commands](#profiler-commands)
11
+ - [Categories](#categories)
12
+ - [Use Cases](#use-cases)
13
+ - [Output Format](#output-format)
14
+ - [Viewing Profiles](#viewing-profiles)
15
+ - [Limitations](#limitations)
16
+
17
+ ## Basic Profiling
18
+
19
+ ```bash
20
+ # Start profiling
21
+ agent-browser profiler start
22
+
23
+ # Perform actions
24
+ agent-browser navigate https://example.com
25
+ agent-browser click "#button"
26
+ agent-browser wait 1000
27
+
28
+ # Stop and save
29
+ agent-browser profiler stop ./trace.json
30
+ ```
31
+
32
+ ## Profiler Commands
33
+
34
+ ```bash
35
+ # Start profiling with default categories
36
+ agent-browser profiler start
37
+
38
+ # Start with custom trace categories
39
+ agent-browser profiler start --categories "devtools.timeline,v8.execute,blink.user_timing"
40
+
41
+ # Stop profiling and save to file
42
+ agent-browser profiler stop ./trace.json
43
+ ```
44
+
45
+ ## Categories
46
+
47
+ The `--categories` flag accepts a comma-separated list of Chrome trace categories. Default categories include:
48
+
49
+ - `devtools.timeline` -- standard DevTools performance traces
50
+ - `v8.execute` -- time spent running JavaScript
51
+ - `blink` -- renderer events
52
+ - `blink.user_timing` -- `performance.mark()` / `performance.measure()` calls
53
+ - `latencyInfo` -- input-to-latency tracking
54
+ - `renderer.scheduler` -- task scheduling and execution
55
+ - `toplevel` -- broad-spectrum basic events
56
+
57
+ Several `disabled-by-default-*` categories are also included for detailed timeline, call stack, and V8 CPU profiling data.
58
+
59
+ ## Use Cases
60
+
61
+ ### Diagnosing Slow Page Loads
62
+
63
+ ```bash
64
+ agent-browser profiler start
65
+ agent-browser navigate https://app.example.com
66
+ agent-browser wait --load networkidle
67
+ agent-browser profiler stop ./page-load-profile.json
68
+ ```
69
+
70
+ ### Profiling User Interactions
71
+
72
+ ```bash
73
+ agent-browser navigate https://app.example.com
74
+ agent-browser profiler start
75
+ agent-browser click "#submit"
76
+ agent-browser wait 2000
77
+ agent-browser profiler stop ./interaction-profile.json
78
+ ```
79
+
80
+ ### CI Performance Regression Checks
81
+
82
+ ```bash
83
+ #!/bin/bash
84
+ agent-browser profiler start
85
+ agent-browser navigate https://app.example.com
86
+ agent-browser wait --load networkidle
87
+ agent-browser profiler stop "./profiles/build-${BUILD_ID}.json"
88
+ ```
89
+
90
+ ## Output Format
91
+
92
+ The output is a JSON file in Chrome Trace Event format:
93
+
94
+ ```json
95
+ {
96
+ "traceEvents": [
97
+ { "cat": "devtools.timeline", "name": "RunTask", "ph": "X", "ts": 12345, "dur": 100, ... },
98
+ ...
99
+ ],
100
+ "metadata": {
101
+ "clock-domain": "LINUX_CLOCK_MONOTONIC"
102
+ }
103
+ }
104
+ ```
105
+
106
+ The `metadata.clock-domain` field is set based on the host platform (Linux or macOS). On Windows it is omitted.
107
+
108
+ ## Viewing Profiles
109
+
110
+ Load the output JSON file in any of these tools:
111
+
112
+ - **Chrome DevTools**: Performance panel > Load profile (Ctrl+Shift+I > Performance)
113
+ - **Perfetto UI**: https://ui.perfetto.dev/ -- drag and drop the JSON file
114
+ - **Trace Viewer**: `chrome://tracing` in any Chromium browser
115
+
116
+ ## Limitations
117
+
118
+ - Only works with Chromium-based browsers (Chrome, Edge). Not supported on Firefox or WebKit.
119
+ - Trace data accumulates in memory while profiling is active (capped at 5 million events). Stop profiling promptly after the area of interest.
120
+ - Data collection on stop has a 30-second timeout. If the browser is unresponsive, the stop command may fail.
@@ -0,0 +1,194 @@
1
+ # Proxy Support
2
+
3
+ Proxy configuration for geo-testing, rate limiting avoidance, and corporate environments.
4
+
5
+ **Related**: [commands.md](commands.md) for global options, [SKILL.md](../SKILL.md) for quick start.
6
+
7
+ ## Contents
8
+
9
+ - [Basic Proxy Configuration](#basic-proxy-configuration)
10
+ - [Authenticated Proxy](#authenticated-proxy)
11
+ - [SOCKS Proxy](#socks-proxy)
12
+ - [Proxy Bypass](#proxy-bypass)
13
+ - [Common Use Cases](#common-use-cases)
14
+ - [Verifying Proxy Connection](#verifying-proxy-connection)
15
+ - [Troubleshooting](#troubleshooting)
16
+ - [Best Practices](#best-practices)
17
+
18
+ ## Basic Proxy Configuration
19
+
20
+ Use the `--proxy` flag or set proxy via environment variable:
21
+
22
+ ```bash
23
+ # Via CLI flag
24
+ agent-browser --proxy "http://proxy.example.com:8080" open https://example.com
25
+
26
+ # Via environment variable
27
+ export HTTP_PROXY="http://proxy.example.com:8080"
28
+ agent-browser open https://example.com
29
+
30
+ # HTTPS proxy
31
+ export HTTPS_PROXY="https://proxy.example.com:8080"
32
+ agent-browser open https://example.com
33
+
34
+ # Both
35
+ export HTTP_PROXY="http://proxy.example.com:8080"
36
+ export HTTPS_PROXY="http://proxy.example.com:8080"
37
+ agent-browser open https://example.com
38
+ ```
39
+
40
+ ## Authenticated Proxy
41
+
42
+ For proxies requiring authentication:
43
+
44
+ ```bash
45
+ # Include credentials in URL
46
+ export HTTP_PROXY="http://username:password@proxy.example.com:8080"
47
+ agent-browser open https://example.com
48
+ ```
49
+
50
+ ## SOCKS Proxy
51
+
52
+ ```bash
53
+ # SOCKS5 proxy
54
+ export ALL_PROXY="socks5://proxy.example.com:1080"
55
+ agent-browser open https://example.com
56
+
57
+ # SOCKS5 with auth
58
+ export ALL_PROXY="socks5://user:pass@proxy.example.com:1080"
59
+ agent-browser open https://example.com
60
+ ```
61
+
62
+ ## Proxy Bypass
63
+
64
+ Skip proxy for specific domains using `--proxy-bypass` or `NO_PROXY`:
65
+
66
+ ```bash
67
+ # Via CLI flag
68
+ agent-browser --proxy "http://proxy.example.com:8080" --proxy-bypass "localhost,*.internal.com" open https://example.com
69
+
70
+ # Via environment variable
71
+ export NO_PROXY="localhost,127.0.0.1,.internal.company.com"
72
+ agent-browser open https://internal.company.com # Direct connection
73
+ agent-browser open https://external.com # Via proxy
74
+ ```
75
+
76
+ ## Common Use Cases
77
+
78
+ ### Geo-Location Testing
79
+
80
+ ```bash
81
+ #!/bin/bash
82
+ # Test site from different regions using geo-located proxies
83
+
84
+ PROXIES=(
85
+ "http://us-proxy.example.com:8080"
86
+ "http://eu-proxy.example.com:8080"
87
+ "http://asia-proxy.example.com:8080"
88
+ )
89
+
90
+ for proxy in "${PROXIES[@]}"; do
91
+ export HTTP_PROXY="$proxy"
92
+ export HTTPS_PROXY="$proxy"
93
+
94
+ region=$(echo "$proxy" | grep -oP '^\w+-\w+')
95
+ echo "Testing from: $region"
96
+
97
+ agent-browser --session "$region" open https://example.com
98
+ agent-browser --session "$region" screenshot "./screenshots/$region.png"
99
+ agent-browser --session "$region" close
100
+ done
101
+ ```
102
+
103
+ ### Rotating Proxies for Scraping
104
+
105
+ ```bash
106
+ #!/bin/bash
107
+ # Rotate through proxy list to avoid rate limiting
108
+
109
+ PROXY_LIST=(
110
+ "http://proxy1.example.com:8080"
111
+ "http://proxy2.example.com:8080"
112
+ "http://proxy3.example.com:8080"
113
+ )
114
+
115
+ URLS=(
116
+ "https://site.com/page1"
117
+ "https://site.com/page2"
118
+ "https://site.com/page3"
119
+ )
120
+
121
+ for i in "${!URLS[@]}"; do
122
+ proxy_index=$((i % ${#PROXY_LIST[@]}))
123
+ export HTTP_PROXY="${PROXY_LIST[$proxy_index]}"
124
+ export HTTPS_PROXY="${PROXY_LIST[$proxy_index]}"
125
+
126
+ agent-browser open "${URLS[$i]}"
127
+ agent-browser get text body > "output-$i.txt"
128
+ agent-browser close
129
+
130
+ sleep 1 # Polite delay
131
+ done
132
+ ```
133
+
134
+ ### Corporate Network Access
135
+
136
+ ```bash
137
+ #!/bin/bash
138
+ # Access internal sites via corporate proxy
139
+
140
+ export HTTP_PROXY="http://corpproxy.company.com:8080"
141
+ export HTTPS_PROXY="http://corpproxy.company.com:8080"
142
+ export NO_PROXY="localhost,127.0.0.1,.company.com"
143
+
144
+ # External sites go through proxy
145
+ agent-browser open https://external-vendor.com
146
+
147
+ # Internal sites bypass proxy
148
+ agent-browser open https://intranet.company.com
149
+ ```
150
+
151
+ ## Verifying Proxy Connection
152
+
153
+ ```bash
154
+ # Check your apparent IP
155
+ agent-browser open https://httpbin.org/ip
156
+ agent-browser get text body
157
+ # Should show proxy's IP, not your real IP
158
+ ```
159
+
160
+ ## Troubleshooting
161
+
162
+ ### Proxy Connection Failed
163
+
164
+ ```bash
165
+ # Test proxy connectivity first
166
+ curl -x http://proxy.example.com:8080 https://httpbin.org/ip
167
+
168
+ # Check if proxy requires auth
169
+ export HTTP_PROXY="http://user:pass@proxy.example.com:8080"
170
+ ```
171
+
172
+ ### SSL/TLS Errors Through Proxy
173
+
174
+ Some proxies perform SSL inspection. If you encounter certificate errors:
175
+
176
+ ```bash
177
+ # For testing only - not recommended for production
178
+ agent-browser open https://example.com --ignore-https-errors
179
+ ```
180
+
181
+ ### Slow Performance
182
+
183
+ ```bash
184
+ # Use proxy only when necessary
185
+ export NO_PROXY="*.cdn.com,*.static.com" # Direct CDN access
186
+ ```
187
+
188
+ ## Best Practices
189
+
190
+ 1. **Use environment variables** - Don't hardcode proxy credentials
191
+ 2. **Set NO_PROXY appropriately** - Avoid routing local traffic through proxy
192
+ 3. **Test proxy before automation** - Verify connectivity with simple requests
193
+ 4. **Handle proxy failures gracefully** - Implement retry logic for unstable proxies
194
+ 5. **Rotate proxies for large scraping jobs** - Distribute load and avoid bans