dsh-x-core 0.1.21 → 0.1.23

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 (50) hide show
  1. package/assets/dsh-preview.png +0 -0
  2. package/assets/dsh.ico +0 -0
  3. package/assets/icon.ico +0 -0
  4. package/assets/tray.ico +0 -0
  5. package/assets/tray.png +0 -0
  6. package/core-npm.js +201 -183
  7. package/desktop-plugins.js +86 -0
  8. package/desktop.js +200 -0
  9. package/filemanager-base.js +7 -8
  10. package/filemanager-linux.js +124 -0
  11. package/filemanager.js +4 -7
  12. package/native-notify.js +74 -0
  13. package/node/node +2 -1
  14. package/package.json +1 -1
  15. package/packs/dsh-x-workbench/README.md +61 -0
  16. package/packs/dsh-x-workbench/dspack.json +4 -0
  17. package/packs/dsh-x-workbench/home/skills/agent-browser/LICENSE-APACHE-2.0.txt +202 -0
  18. package/packs/dsh-x-workbench/home/skills/agent-browser/NOTICE.md +6 -0
  19. package/packs/dsh-x-workbench/home/skills/agent-browser/SKILL.md +697 -0
  20. package/packs/dsh-x-workbench/home/skills/agent-browser/references/authentication.md +313 -0
  21. package/packs/dsh-x-workbench/home/skills/agent-browser/references/commands.md +300 -0
  22. package/packs/dsh-x-workbench/home/skills/agent-browser/references/profiling.md +120 -0
  23. package/packs/dsh-x-workbench/home/skills/agent-browser/references/proxy-support.md +194 -0
  24. package/packs/dsh-x-workbench/home/skills/agent-browser/references/session-management.md +201 -0
  25. package/packs/dsh-x-workbench/home/skills/agent-browser/references/snapshot-refs.md +229 -0
  26. package/packs/dsh-x-workbench/home/skills/agent-browser/references/video-recording.md +173 -0
  27. package/packs/dsh-x-workbench/home/skills/agent-browser/templates/authenticated-session.sh +105 -0
  28. package/packs/dsh-x-workbench/home/skills/agent-browser/templates/capture-workflow.sh +69 -0
  29. package/packs/dsh-x-workbench/home/skills/agent-browser/templates/form-automation.sh +62 -0
  30. package/packs/dsh-x-workbench/home/skills/electron/LICENSE-APACHE-2.0.txt +202 -0
  31. package/packs/dsh-x-workbench/home/skills/electron/NOTICE.md +6 -0
  32. package/packs/dsh-x-workbench/home/skills/electron/SKILL.md +243 -0
  33. package/packs/dsh-x-workbench/manifest.json +35 -0
  34. package/perf/patch-hooks.mjs +14 -1
  35. package/perf/plugin-profile.mjs +204 -0
  36. package/perf/register.mjs +4 -0
  37. package/platform.js +2 -1
  38. package/public/booting.html +475 -0
  39. package/public/favicon.ico +0 -0
  40. package/public/favicon.png +0 -0
  41. package/public/icon.png +0 -0
  42. package/public/index.html +9277 -8173
  43. package/public/internal-tabs.js +45 -41
  44. package/public/launcher.css +285 -98
  45. package/public/mascot.js +1 -1
  46. package/public/theme.css +33 -6
  47. package/public/water.js +1 -1
  48. package/registry.js +38 -3
  49. package/server.js +1060 -119
  50. package/settings.js +78 -1
@@ -0,0 +1,313 @@
1
+ <!--
2
+ Derived from vercel-labs/agent-browser (skills/agent-browser/references/authentication.md).
3
+ Copyright 2025 Vercel Inc. Licensed under Apache-2.0.
4
+ Modified by ZCode: local integration, formatting and adaptations.
5
+ See THIRD-PARTY-NOTICES.md in the repository root for license and provenance.
6
+ -->
7
+
8
+ # Authentication Patterns
9
+
10
+ Login flows, session persistence, OAuth, 2FA, and authenticated browsing.
11
+
12
+ **Related**: [session-management.md](session-management.md) for state persistence details, [SKILL.md](../SKILL.md) for quick start.
13
+
14
+ ## Contents
15
+
16
+ - [Import Auth from Your Browser](#import-auth-from-your-browser)
17
+ - [Persistent Profiles](#persistent-profiles)
18
+ - [Session Persistence](#session-persistence)
19
+ - [Basic Login Flow](#basic-login-flow)
20
+ - [Saving Authentication State](#saving-authentication-state)
21
+ - [Restoring Authentication](#restoring-authentication)
22
+ - [OAuth / SSO Flows](#oauth--sso-flows)
23
+ - [Two-Factor Authentication](#two-factor-authentication)
24
+ - [HTTP Basic Auth](#http-basic-auth)
25
+ - [Cookie-Based Auth](#cookie-based-auth)
26
+ - [Token Refresh Handling](#token-refresh-handling)
27
+ - [Security Best Practices](#security-best-practices)
28
+
29
+ ## Import Auth from Your Browser
30
+
31
+ The fastest way to authenticate is to reuse cookies from a Chrome session you are already logged into.
32
+
33
+ **Step 1: Start Chrome with remote debugging**
34
+
35
+ ```bash
36
+ # macOS
37
+ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --remote-debugging-port=9222
38
+
39
+ # Linux
40
+ google-chrome --remote-debugging-port=9222
41
+
42
+ # Windows
43
+ "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
44
+ ```
45
+
46
+ Log in to your target site(s) in this Chrome window as you normally would.
47
+
48
+ > **Security note:** `--remote-debugging-port` exposes full browser control on localhost. Any local process can connect and read cookies, execute JS, etc. Only use on trusted machines and close Chrome when done.
49
+
50
+ **Step 2: Grab the auth state**
51
+
52
+ ```bash
53
+ # Auto-discover the running Chrome and save its cookies + localStorage
54
+ agent-browser --auto-connect state save ./my-auth.json
55
+ ```
56
+
57
+ **Step 3: Reuse in automation**
58
+
59
+ ```bash
60
+ # Load auth at launch
61
+ agent-browser --state ./my-auth.json open https://app.example.com/dashboard
62
+
63
+ # Or load into an existing session
64
+ agent-browser state load ./my-auth.json
65
+ agent-browser open https://app.example.com/dashboard
66
+ ```
67
+
68
+ This works for any site, including those with complex OAuth flows, SSO, or 2FA -- as long as Chrome already has valid session cookies.
69
+
70
+ > **Security note:** State files contain session tokens in plaintext. Add them to `.gitignore`, delete when no longer needed, and set `AGENT_BROWSER_ENCRYPTION_KEY` for encryption at rest. See [Security Best Practices](#security-best-practices).
71
+
72
+ **Tip:** Combine with `--session-name` so the imported auth auto-persists across restarts:
73
+
74
+ ```bash
75
+ agent-browser --session-name myapp state load ./my-auth.json
76
+ # From now on, state is auto-saved/restored for "myapp"
77
+ ```
78
+
79
+ ## Persistent Profiles
80
+
81
+ Use `--profile` to point agent-browser at a Chrome user data directory. This persists everything (cookies, IndexedDB, service workers, cache) across browser restarts without explicit save/load:
82
+
83
+ ```bash
84
+ # First run: login once
85
+ agent-browser --profile ~/.myapp-profile open https://app.example.com/login
86
+ # ... complete login flow ...
87
+
88
+ # All subsequent runs: already authenticated
89
+ agent-browser --profile ~/.myapp-profile open https://app.example.com/dashboard
90
+ ```
91
+
92
+ Use different paths for different projects or test users:
93
+
94
+ ```bash
95
+ agent-browser --profile ~/.profiles/admin open https://app.example.com
96
+ agent-browser --profile ~/.profiles/viewer open https://app.example.com
97
+ ```
98
+
99
+ Or set via environment variable:
100
+
101
+ ```bash
102
+ export AGENT_BROWSER_PROFILE=~/.myapp-profile
103
+ agent-browser open https://app.example.com/dashboard
104
+ ```
105
+
106
+ ## Session Persistence
107
+
108
+ Use `--session-name` to auto-save and restore cookies + localStorage by name, without managing files:
109
+
110
+ ```bash
111
+ # Auto-saves state on close, auto-restores on next launch
112
+ agent-browser --session-name twitter open https://twitter.com
113
+ # ... login flow ...
114
+ agent-browser close # state saved to ~/.agent-browser/sessions/
115
+
116
+ # Next time: state is automatically restored
117
+ agent-browser --session-name twitter open https://twitter.com
118
+ ```
119
+
120
+ Encrypt state at rest:
121
+
122
+ ```bash
123
+ export AGENT_BROWSER_ENCRYPTION_KEY=$(openssl rand -hex 32)
124
+ agent-browser --session-name secure open https://app.example.com
125
+ ```
126
+
127
+ ## Basic Login Flow
128
+
129
+ ```bash
130
+ # Navigate to login page
131
+ agent-browser open https://app.example.com/login
132
+ agent-browser wait --load networkidle
133
+
134
+ # Get form elements
135
+ agent-browser snapshot -i
136
+ # Output: @e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Sign In"
137
+
138
+ # Fill credentials
139
+ agent-browser fill @e1 "user@example.com"
140
+ agent-browser fill @e2 "password123"
141
+
142
+ # Submit
143
+ agent-browser click @e3
144
+ agent-browser wait --load networkidle
145
+
146
+ # Verify login succeeded
147
+ agent-browser get url # Should be dashboard, not login
148
+ ```
149
+
150
+ ## Saving Authentication State
151
+
152
+ After logging in, save state for reuse:
153
+
154
+ ```bash
155
+ # Login first (see above)
156
+ agent-browser open https://app.example.com/login
157
+ agent-browser snapshot -i
158
+ agent-browser fill @e1 "user@example.com"
159
+ agent-browser fill @e2 "password123"
160
+ agent-browser click @e3
161
+ agent-browser wait --url "**/dashboard"
162
+
163
+ # Save authenticated state
164
+ agent-browser state save ./auth-state.json
165
+ ```
166
+
167
+ ## Restoring Authentication
168
+
169
+ Skip login by loading saved state:
170
+
171
+ ```bash
172
+ # Load saved auth state
173
+ agent-browser state load ./auth-state.json
174
+
175
+ # Navigate directly to protected page
176
+ agent-browser open https://app.example.com/dashboard
177
+
178
+ # Verify authenticated
179
+ agent-browser snapshot -i
180
+ ```
181
+
182
+ ## OAuth / SSO Flows
183
+
184
+ For OAuth redirects:
185
+
186
+ ```bash
187
+ # Start OAuth flow
188
+ agent-browser open https://app.example.com/auth/google
189
+
190
+ # Handle redirects automatically
191
+ agent-browser wait --url "**/accounts.google.com**"
192
+ agent-browser snapshot -i
193
+
194
+ # Fill Google credentials
195
+ agent-browser fill @e1 "user@gmail.com"
196
+ agent-browser click @e2 # Next button
197
+ agent-browser wait 2000
198
+ agent-browser snapshot -i
199
+ agent-browser fill @e3 "password"
200
+ agent-browser click @e4 # Sign in
201
+
202
+ # Wait for redirect back
203
+ agent-browser wait --url "**/app.example.com**"
204
+ agent-browser state save ./oauth-state.json
205
+ ```
206
+
207
+ ## Two-Factor Authentication
208
+
209
+ Handle 2FA with manual intervention:
210
+
211
+ ```bash
212
+ # Login with credentials
213
+ agent-browser open https://app.example.com/login --headed # Show browser
214
+ agent-browser snapshot -i
215
+ agent-browser fill @e1 "user@example.com"
216
+ agent-browser fill @e2 "password123"
217
+ agent-browser click @e3
218
+
219
+ # Wait for user to complete 2FA manually
220
+ echo "Complete 2FA in the browser window..."
221
+ agent-browser wait --url "**/dashboard" --timeout 120000
222
+
223
+ # Save state after 2FA
224
+ agent-browser state save ./2fa-state.json
225
+ ```
226
+
227
+ ## HTTP Basic Auth
228
+
229
+ For sites using HTTP Basic Authentication:
230
+
231
+ ```bash
232
+ # Set credentials before navigation
233
+ agent-browser set credentials username password
234
+
235
+ # Navigate to protected resource
236
+ agent-browser open https://protected.example.com/api
237
+ ```
238
+
239
+ ## Cookie-Based Auth
240
+
241
+ Manually set authentication cookies:
242
+
243
+ ```bash
244
+ # Set auth cookie
245
+ agent-browser cookies set session_token "abc123xyz"
246
+
247
+ # Navigate to protected page
248
+ agent-browser open https://app.example.com/dashboard
249
+ ```
250
+
251
+ ## Token Refresh Handling
252
+
253
+ For sessions with expiring tokens:
254
+
255
+ ```bash
256
+ #!/bin/bash
257
+ # Wrapper that handles token refresh
258
+
259
+ STATE_FILE="./auth-state.json"
260
+
261
+ # Try loading existing state
262
+ if [[ -f "$STATE_FILE" ]]; then
263
+ agent-browser state load "$STATE_FILE"
264
+ agent-browser open https://app.example.com/dashboard
265
+
266
+ # Check if session is still valid
267
+ URL=$(agent-browser get url)
268
+ if [[ "$URL" == *"/login"* ]]; then
269
+ echo "Session expired, re-authenticating..."
270
+ # Perform fresh login
271
+ agent-browser snapshot -i
272
+ agent-browser fill @e1 "$USERNAME"
273
+ agent-browser fill @e2 "$PASSWORD"
274
+ agent-browser click @e3
275
+ agent-browser wait --url "**/dashboard"
276
+ agent-browser state save "$STATE_FILE"
277
+ fi
278
+ else
279
+ # First-time login
280
+ agent-browser open https://app.example.com/login
281
+ # ... login flow ...
282
+ fi
283
+ ```
284
+
285
+ ## Security Best Practices
286
+
287
+ 1. **Never commit state files** - They contain session tokens
288
+
289
+ ```bash
290
+ echo "*.auth-state.json" >> .gitignore
291
+ ```
292
+
293
+ 2. **Use environment variables for credentials**
294
+
295
+ ```bash
296
+ agent-browser fill @e1 "$APP_USERNAME"
297
+ agent-browser fill @e2 "$APP_PASSWORD"
298
+ ```
299
+
300
+ 3. **Clean up after automation**
301
+
302
+ ```bash
303
+ agent-browser cookies clear
304
+ rm -f ./auth-state.json
305
+ ```
306
+
307
+ 4. **Use short-lived sessions for CI/CD**
308
+ ```bash
309
+ # Don't persist state in CI
310
+ agent-browser open https://app.example.com/login
311
+ # ... login and perform actions ...
312
+ agent-browser close # Session ends, nothing persisted
313
+ ```
@@ -0,0 +1,300 @@
1
+ <!--
2
+ Derived from vercel-labs/agent-browser (skills/agent-browser/references/commands.md).
3
+ Copyright 2025 Vercel Inc. Licensed under Apache-2.0.
4
+ Modified by ZCode: local integration, formatting and adaptations.
5
+ See THIRD-PARTY-NOTICES.md in the repository root for license and provenance.
6
+ -->
7
+
8
+ # Command Reference
9
+
10
+ Complete reference for all agent-browser commands. For quick start and common patterns, see SKILL.md.
11
+
12
+ ## Navigation
13
+
14
+ ```bash
15
+ agent-browser open <url> # Navigate to URL (aliases: goto, navigate)
16
+ # Supports: https://, http://, file://, about:, data://
17
+ # Auto-prepends https:// if no protocol given
18
+ agent-browser back # Go back
19
+ agent-browser forward # Go forward
20
+ agent-browser reload # Reload page
21
+ agent-browser close # Close browser (aliases: quit, exit)
22
+ agent-browser connect 9222 # Connect to browser via CDP port
23
+ ```
24
+
25
+ ## Snapshot (page analysis)
26
+
27
+ ```bash
28
+ agent-browser snapshot # Full accessibility tree
29
+ agent-browser snapshot -i # Interactive elements only (recommended)
30
+ agent-browser snapshot -c # Compact output
31
+ agent-browser snapshot -d 3 # Limit depth to 3
32
+ agent-browser snapshot -s "#main" # Scope to CSS selector
33
+ ```
34
+
35
+ ## Interactions (use @refs from snapshot)
36
+
37
+ ```bash
38
+ agent-browser click @e1 # Click
39
+ agent-browser click @e1 --new-tab # Click and open in new tab
40
+ agent-browser dblclick @e1 # Double-click
41
+ agent-browser focus @e1 # Focus element
42
+ agent-browser fill @e2 "text" # Clear and type
43
+ agent-browser type @e2 "text" # Type without clearing
44
+ agent-browser press Enter # Press key (alias: key)
45
+ agent-browser press Control+a # Key combination
46
+ agent-browser keydown Shift # Hold key down
47
+ agent-browser keyup Shift # Release key
48
+ agent-browser hover @e1 # Hover
49
+ agent-browser check @e1 # Check checkbox
50
+ agent-browser uncheck @e1 # Uncheck checkbox
51
+ agent-browser select @e1 "value" # Select dropdown option
52
+ agent-browser select @e1 "a" "b" # Select multiple options
53
+ agent-browser scroll down 500 # Scroll page (default: down 300px)
54
+ agent-browser scrollintoview @e1 # Scroll element into view (alias: scrollinto)
55
+ agent-browser drag @e1 @e2 # Drag and drop
56
+ agent-browser upload @e1 file.pdf # Upload files
57
+ ```
58
+
59
+ ## Get Information
60
+
61
+ ```bash
62
+ agent-browser get text @e1 # Get element text
63
+ agent-browser get html @e1 # Get innerHTML
64
+ agent-browser get value @e1 # Get input value
65
+ agent-browser get attr @e1 href # Get attribute
66
+ agent-browser get title # Get page title
67
+ agent-browser get url # Get current URL
68
+ agent-browser get cdp-url # Get CDP WebSocket URL
69
+ agent-browser get count ".item" # Count matching elements
70
+ agent-browser get box @e1 # Get bounding box
71
+ agent-browser get styles @e1 # Get computed styles (font, color, bg, etc.)
72
+ ```
73
+
74
+ ## Check State
75
+
76
+ ```bash
77
+ agent-browser is visible @e1 # Check if visible
78
+ agent-browser is enabled @e1 # Check if enabled
79
+ agent-browser is checked @e1 # Check if checked
80
+ ```
81
+
82
+ ## Screenshots and PDF
83
+
84
+ ```bash
85
+ agent-browser screenshot # Save to temporary directory
86
+ agent-browser screenshot path.png # Save to specific path
87
+ agent-browser screenshot --full # Full page
88
+ agent-browser pdf output.pdf # Save as PDF
89
+ ```
90
+
91
+ ## Video Recording
92
+
93
+ ```bash
94
+ agent-browser record start ./demo.webm # Start recording
95
+ agent-browser click @e1 # Perform actions
96
+ agent-browser record stop # Stop and save video
97
+ agent-browser record restart ./take2.webm # Stop current + start new
98
+ ```
99
+
100
+ ## Wait
101
+
102
+ ```bash
103
+ agent-browser wait @e1 # Wait for element
104
+ agent-browser wait 2000 # Wait milliseconds
105
+ agent-browser wait --text "Success" # Wait for text (or -t)
106
+ agent-browser wait --url "**/dashboard" # Wait for URL pattern (or -u)
107
+ agent-browser wait --load networkidle # Wait for network idle (or -l)
108
+ agent-browser wait --fn "window.ready" # Wait for JS condition (or -f)
109
+ ```
110
+
111
+ ## Mouse Control
112
+
113
+ ```bash
114
+ agent-browser mouse move 100 200 # Move mouse
115
+ agent-browser mouse down left # Press button
116
+ agent-browser mouse up left # Release button
117
+ agent-browser mouse wheel 100 # Scroll wheel
118
+ ```
119
+
120
+ ## Semantic Locators (alternative to refs)
121
+
122
+ ```bash
123
+ agent-browser find role button click --name "Submit"
124
+ agent-browser find text "Sign In" click
125
+ agent-browser find text "Sign In" click --exact # Exact match only
126
+ agent-browser find label "Email" fill "user@test.com"
127
+ agent-browser find placeholder "Search" type "query"
128
+ agent-browser find alt "Logo" click
129
+ agent-browser find title "Close" click
130
+ agent-browser find testid "submit-btn" click
131
+ agent-browser find first ".item" click
132
+ agent-browser find last ".item" click
133
+ agent-browser find nth 2 "a" hover
134
+ ```
135
+
136
+ ## Browser Settings
137
+
138
+ ```bash
139
+ agent-browser set viewport 1920 1080 # Set viewport size
140
+ agent-browser set viewport 1920 1080 2 # 2x retina (same CSS size, higher res screenshots)
141
+ agent-browser set device "iPhone 14" # Emulate device
142
+ agent-browser set geo 37.7749 -122.4194 # Set geolocation (alias: geolocation)
143
+ agent-browser set offline on # Toggle offline mode
144
+ agent-browser set headers '{"X-Key":"v"}' # Extra HTTP headers
145
+ agent-browser set credentials user pass # HTTP basic auth (alias: auth)
146
+ agent-browser set media dark # Emulate color scheme
147
+ agent-browser set media light reduced-motion # Light mode + reduced motion
148
+ ```
149
+
150
+ ## Cookies and Storage
151
+
152
+ ```bash
153
+ agent-browser cookies # Get all cookies
154
+ agent-browser cookies set name value # Set cookie
155
+ agent-browser cookies clear # Clear cookies
156
+ agent-browser storage local # Get all localStorage
157
+ agent-browser storage local key # Get specific key
158
+ agent-browser storage local set k v # Set value
159
+ agent-browser storage local clear # Clear all
160
+ ```
161
+
162
+ ## Network
163
+
164
+ ```bash
165
+ agent-browser network route <url> # Intercept requests
166
+ agent-browser network route <url> --abort # Block requests
167
+ agent-browser network route <url> --body '{}' # Mock response
168
+ agent-browser network unroute [url] # Remove routes
169
+ agent-browser network requests # View tracked requests
170
+ agent-browser network requests --filter api # Filter requests
171
+ ```
172
+
173
+ ## Tabs and Windows
174
+
175
+ ```bash
176
+ agent-browser tab # List tabs
177
+ agent-browser tab new [url] # New tab
178
+ agent-browser tab 2 # Switch to tab by index
179
+ agent-browser tab close # Close current tab
180
+ agent-browser tab close 2 # Close tab by index
181
+ agent-browser window new # New window
182
+ ```
183
+
184
+ ## Frames
185
+
186
+ ```bash
187
+ agent-browser frame "#iframe" # Switch to iframe by CSS selector
188
+ agent-browser frame @e3 # Switch to iframe by element ref
189
+ agent-browser frame main # Back to main frame
190
+ ```
191
+
192
+ ### Iframe support
193
+
194
+ Iframes are detected automatically during snapshots. When the main-frame snapshot runs, `Iframe` nodes are resolved and their content is inlined beneath the iframe element in the output (one level of nesting; iframes within iframes are not expanded).
195
+
196
+ ```bash
197
+ agent-browser snapshot -i
198
+ # @e3 [Iframe] "payment-frame"
199
+ # @e4 [input] "Card number"
200
+ # @e5 [button] "Pay"
201
+
202
+ # Interact directly — refs inside iframes already work
203
+ agent-browser fill @e4 "4111111111111111"
204
+ agent-browser click @e5
205
+
206
+ # Or switch frame context for scoped snapshots
207
+ agent-browser frame @e3 # Switch using element ref
208
+ agent-browser snapshot -i # Snapshot scoped to that iframe
209
+ agent-browser frame main # Return to main frame
210
+ ```
211
+
212
+ The `frame` command accepts:
213
+
214
+ - **Element refs** — `frame @e3` resolves the ref to an iframe element
215
+ - **CSS selectors** — `frame "#payment-iframe"` finds the iframe by selector
216
+ - **Frame name/URL** — matches against the browser's frame tree
217
+
218
+ ## Dialogs
219
+
220
+ ```bash
221
+ agent-browser dialog accept [text] # Accept dialog
222
+ agent-browser dialog dismiss # Dismiss dialog
223
+ ```
224
+
225
+ ## JavaScript
226
+
227
+ ```bash
228
+ agent-browser eval "document.title" # Simple expressions only
229
+ agent-browser eval -b "<base64>" # Any JavaScript (base64 encoded)
230
+ agent-browser eval --stdin # Read script from stdin
231
+ ```
232
+
233
+ Use `-b`/`--base64` or `--stdin` for reliable execution. Shell escaping with nested quotes and special characters is error-prone.
234
+
235
+ ```bash
236
+ # Base64 encode your script, then:
237
+ agent-browser eval -b "ZG9jdW1lbnQucXVlcnlTZWxlY3RvcignW3NyYyo9Il9uZXh0Il0nKQ=="
238
+
239
+ # Or use stdin with heredoc for multiline scripts:
240
+ cat <<'EOF' | agent-browser eval --stdin
241
+ const links = document.querySelectorAll('a');
242
+ Array.from(links).map(a => a.href);
243
+ EOF
244
+ ```
245
+
246
+ ## State Management
247
+
248
+ ```bash
249
+ agent-browser state save auth.json # Save cookies, storage, auth state
250
+ agent-browser state load auth.json # Restore saved state
251
+ ```
252
+
253
+ ## Global Options
254
+
255
+ ```bash
256
+ agent-browser --session <name> ... # Isolated browser session
257
+ agent-browser --json ... # JSON output for parsing
258
+ agent-browser --headed ... # Show browser window (not headless)
259
+ agent-browser --full ... # Full page screenshot (-f)
260
+ agent-browser --cdp <port> ... # Connect via Chrome DevTools Protocol
261
+ agent-browser -p <provider> ... # Cloud browser provider (--provider)
262
+ agent-browser --proxy <url> ... # Use proxy server
263
+ agent-browser --proxy-bypass <hosts> # Hosts to bypass proxy
264
+ agent-browser --headers <json> ... # HTTP headers scoped to URL's origin
265
+ agent-browser --executable-path <p> # Custom browser executable
266
+ agent-browser --extension <path> ... # Load browser extension (repeatable)
267
+ agent-browser --ignore-https-errors # Ignore SSL certificate errors
268
+ agent-browser --help # Show help (-h)
269
+ agent-browser --version # Show version (-V)
270
+ agent-browser <command> --help # Show detailed help for a command
271
+ ```
272
+
273
+ ## Debugging
274
+
275
+ ```bash
276
+ agent-browser --headed open example.com # Show browser window
277
+ agent-browser --cdp 9222 snapshot # Connect via CDP port
278
+ agent-browser connect 9222 # Alternative: connect command
279
+ agent-browser console # View console messages
280
+ agent-browser console --clear # Clear console
281
+ agent-browser errors # View page errors
282
+ agent-browser errors --clear # Clear errors
283
+ agent-browser highlight @e1 # Highlight element
284
+ agent-browser inspect # Open Chrome DevTools for this session
285
+ agent-browser trace start # Start recording trace
286
+ agent-browser trace stop trace.zip # Stop and save trace
287
+ agent-browser profiler start # Start Chrome DevTools profiling
288
+ agent-browser profiler stop trace.json # Stop and save profile
289
+ ```
290
+
291
+ ## Environment Variables
292
+
293
+ ```bash
294
+ AGENT_BROWSER_SESSION="mysession" # Default session name
295
+ AGENT_BROWSER_EXECUTABLE_PATH="/path/chrome" # Custom browser path
296
+ AGENT_BROWSER_EXTENSIONS="/ext1,/ext2" # Comma-separated extension paths
297
+ AGENT_BROWSER_PROVIDER="browserbase" # Cloud browser provider
298
+ AGENT_BROWSER_STREAM_PORT="9223" # WebSocket streaming port
299
+ AGENT_BROWSER_HOME="/path/to/agent-browser" # Custom install location
300
+ ```