@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,380 @@
1
+ # Authentication Patterns
2
+
3
+ Login flows, session persistence, OAuth, 2FA, and authenticated browsing.
4
+
5
+ **Related**: [session-management.md](session-management.md) for state persistence details, [SKILL.md](../SKILL.md) for quick start.
6
+
7
+ ## Contents
8
+
9
+ - [Import Auth from Your Browser](#import-auth-from-your-browser)
10
+ - [Persistent Profiles](#persistent-profiles)
11
+ - [Session Persistence](#session-persistence)
12
+ - [Basic Login Flow](#basic-login-flow)
13
+ - [Plugins](#plugins)
14
+ - [Saving Authentication State](#saving-authentication-state)
15
+ - [Restoring Authentication](#restoring-authentication)
16
+ - [OAuth / SSO Flows](#oauth--sso-flows)
17
+ - [Two-Factor Authentication](#two-factor-authentication)
18
+ - [HTTP Basic Auth](#http-basic-auth)
19
+ - [Cookie-Based Auth](#cookie-based-auth)
20
+ - [Token Refresh Handling](#token-refresh-handling)
21
+ - [Security Best Practices](#security-best-practices)
22
+
23
+ ## Import Auth from Your Browser
24
+
25
+ The fastest way to authenticate is to reuse cookies from a Chrome session you are already logged into.
26
+
27
+ **Step 1: Start Chrome with remote debugging**
28
+
29
+ ```bash
30
+ # macOS
31
+ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --remote-debugging-port=9222
32
+
33
+ # Linux
34
+ google-chrome --remote-debugging-port=9222
35
+
36
+ # Windows
37
+ "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
38
+ ```
39
+
40
+ Log in to your target site(s) in this Chrome window as you normally would.
41
+
42
+ > **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.
43
+
44
+ **Step 2: Grab the auth state**
45
+
46
+ ```bash
47
+ # Auto-discover the running Chrome and save its cookies + localStorage
48
+ agent-browser --auto-connect state save ./my-auth.json
49
+ ```
50
+
51
+ **Step 3: Reuse in automation**
52
+
53
+ ```bash
54
+ # Load auth at launch
55
+ agent-browser --state ./my-auth.json open https://app.example.com/dashboard
56
+
57
+ # Or load into an already-launched session
58
+ agent-browser open about:blank
59
+ agent-browser state load ./my-auth.json
60
+ agent-browser open https://app.example.com/dashboard
61
+ ```
62
+
63
+ This works for any site, including those with complex OAuth flows, SSO, or 2FA, as long as Chrome already has valid session cookies.
64
+
65
+ > **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).
66
+
67
+ **Tip:** Combine with `--session <id> --restore` so the imported auth auto-persists across restarts:
68
+
69
+ ```bash
70
+ SESSION="$(agent-browser session id --scope worktree --prefix myapp)"
71
+ agent-browser --session "$SESSION" --restore --state ./my-auth.json open https://app.example.com/dashboard
72
+ # From now on, state is auto-saved/restored for this session
73
+ ```
74
+
75
+ ## Persistent Profiles
76
+
77
+ 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:
78
+
79
+ ```bash
80
+ # First run: login once
81
+ agent-browser --profile ~/.myapp-profile open https://app.example.com/login
82
+ # ... complete login flow ...
83
+
84
+ # All subsequent runs: already authenticated
85
+ agent-browser --profile ~/.myapp-profile open https://app.example.com/dashboard
86
+ ```
87
+
88
+ Use different paths for different projects or test users:
89
+
90
+ ```bash
91
+ agent-browser --profile ~/.profiles/admin open https://app.example.com
92
+ agent-browser --profile ~/.profiles/viewer open https://app.example.com
93
+ ```
94
+
95
+ Or set via environment variable:
96
+
97
+ ```bash
98
+ export AGENT_BROWSER_PROFILE=~/.myapp-profile
99
+ agent-browser open https://app.example.com/dashboard
100
+ ```
101
+
102
+ ## Session Persistence
103
+
104
+ Use `--restore` with a stable `--session` to auto-save and restore cookies + localStorage without managing files:
105
+
106
+ ```bash
107
+ # Auto-saves state on close, auto-restores on next launch
108
+ SESSION="$(agent-browser session id --scope worktree --prefix twitter)"
109
+ agent-browser --session "$SESSION" --restore open https://twitter.com
110
+ # ... login flow ...
111
+ agent-browser --session "$SESSION" --restore close # state saved to ~/.agent-browser/sessions/
112
+
113
+ # Next time: state is automatically restored
114
+ agent-browser --session "$SESSION" --restore open https://twitter.com
115
+ ```
116
+
117
+ Encrypt state at rest:
118
+
119
+ ```bash
120
+ export AGENT_BROWSER_ENCRYPTION_KEY=$(openssl rand -hex 32)
121
+ agent-browser --session secure --restore open https://app.example.com
122
+ ```
123
+
124
+ ## Basic Login Flow
125
+
126
+ ```bash
127
+ # Navigate to login page
128
+ agent-browser open https://app.example.com/login
129
+ agent-browser wait --load networkidle
130
+
131
+ # Get form elements
132
+ agent-browser snapshot -i
133
+ # Output: @e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Sign In"
134
+
135
+ # Fill credentials
136
+ agent-browser fill @e1 "user@example.com"
137
+ agent-browser fill @e2 "password123"
138
+
139
+ # Submit
140
+ agent-browser click @e3
141
+ agent-browser wait --load networkidle
142
+
143
+ # Verify login succeeded
144
+ agent-browser get url # Should be dashboard, not login
145
+ ```
146
+
147
+ ## Plugins
148
+
149
+ Use credential provider plugins when credentials live in external vault software. Plugins are configured in `agent-browser.json` and run as external executables over the `agent-browser.plugin.v1` stdio JSON protocol.
150
+
151
+ Add a plugin with `plugin add`. A plain `name` or `@scope/name` resolves from npm; `owner/repo` resolves from GitHub:
152
+
153
+ ```bash
154
+ agent-browser plugin add agent-browser-plugin-vault --name vault
155
+ agent-browser plugin add @company/agent-browser-plugin-vault --name vault
156
+ agent-browser plugin add org/agent-browser-plugin-cloud-browser
157
+ ```
158
+
159
+ ```json
160
+ {
161
+ "plugins": [
162
+ {
163
+ "name": "vault",
164
+ "command": "agent-browser-plugin-vault",
165
+ "capabilities": ["credential.read"]
166
+ },
167
+ {
168
+ "name": "cloud-browser",
169
+ "command": "agent-browser-plugin-cloud-browser",
170
+ "capabilities": ["browser.provider"]
171
+ },
172
+ {
173
+ "name": "stealth",
174
+ "command": "agent-browser-plugin-stealth",
175
+ "capabilities": ["launch.mutate"]
176
+ },
177
+ {
178
+ "name": "captcha",
179
+ "command": "agent-browser-plugin-captcha",
180
+ "capabilities": ["command.run", "captcha.solve"]
181
+ }
182
+ ]
183
+ }
184
+ ```
185
+
186
+ Inspect configured plugins before use:
187
+
188
+ ```bash
189
+ agent-browser plugin list
190
+ agent-browser plugin show vault
191
+ ```
192
+
193
+ Resolve credentials just-in-time for one login:
194
+
195
+ ```bash
196
+ agent-browser auth login my-app --credential-provider vault --item "My App"
197
+ ```
198
+
199
+ Use a plugin as a browser provider or a generic domain command:
200
+
201
+ ```bash
202
+ agent-browser --provider cloud-browser open https://example.com
203
+ agent-browser plugin run captcha captcha.solve --payload '{"siteKey":"...","url":"https://example.com"}'
204
+ ```
205
+
206
+ `plugin run` is for `command.run` and custom capabilities. Core capabilities and protocol request types use their dedicated command paths.
207
+
208
+ Use `--url`, `--username-selector`, `--password-selector`, and `--submit-selector` on `auth login` to override plugin-provided metadata for the current login only.
209
+
210
+ Gate plugin secret access separately from normal login automation:
211
+
212
+ ```bash
213
+ agent-browser --confirm-actions plugin:vault:credential.read auth login my-app --credential-provider vault --item "My App"
214
+ agent-browser --confirm-actions plugin:cloud-browser:browser.provider --provider cloud-browser open https://example.com
215
+ agent-browser --confirm-actions plugin:stealth:launch.mutate open https://example.com
216
+ ```
217
+
218
+ Do not put vault tokens or passwords in plugin command args. Use the vault vendor's own login/session mechanism or environment outside agent-browser config.
219
+
220
+ ## Saving Authentication State
221
+
222
+ After logging in, save state for reuse:
223
+
224
+ ```bash
225
+ # Login first (see above)
226
+ agent-browser open https://app.example.com/login
227
+ agent-browser snapshot -i
228
+ agent-browser fill @e1 "user@example.com"
229
+ agent-browser fill @e2 "password123"
230
+ agent-browser click @e3
231
+ agent-browser wait --url "**/dashboard"
232
+
233
+ # Save authenticated state
234
+ agent-browser state save ./auth-state.json
235
+ ```
236
+
237
+ ## Restoring Authentication
238
+
239
+ Skip login by loading saved state:
240
+
241
+ ```bash
242
+ # Load saved auth state
243
+ agent-browser state load ./auth-state.json
244
+
245
+ # Navigate directly to protected page
246
+ agent-browser open https://app.example.com/dashboard
247
+
248
+ # Verify authenticated
249
+ agent-browser snapshot -i
250
+ ```
251
+
252
+ ## OAuth / SSO Flows
253
+
254
+ For OAuth redirects:
255
+
256
+ ```bash
257
+ # Start OAuth flow
258
+ agent-browser open https://app.example.com/auth/google
259
+
260
+ # Handle redirects automatically
261
+ agent-browser wait --url "**/accounts.google.com**"
262
+ agent-browser snapshot -i
263
+
264
+ # Fill Google credentials
265
+ agent-browser fill @e1 "user@gmail.com"
266
+ agent-browser click @e2 # Next button
267
+ agent-browser wait 2000
268
+ agent-browser snapshot -i
269
+ agent-browser fill @e3 "password"
270
+ agent-browser click @e4 # Sign in
271
+
272
+ # Wait for redirect back
273
+ agent-browser wait --url "**/app.example.com**"
274
+ agent-browser state save ./oauth-state.json
275
+ ```
276
+
277
+ ## Two-Factor Authentication
278
+
279
+ Handle 2FA with manual intervention:
280
+
281
+ ```bash
282
+ # Login with credentials
283
+ agent-browser open https://app.example.com/login --headed # Show browser
284
+ agent-browser snapshot -i
285
+ agent-browser fill @e1 "user@example.com"
286
+ agent-browser fill @e2 "password123"
287
+ agent-browser click @e3
288
+
289
+ # Wait for user to complete 2FA manually
290
+ echo "Complete 2FA in the browser window..."
291
+ agent-browser wait --url "**/dashboard" --timeout 120000
292
+
293
+ # Save state after 2FA
294
+ agent-browser state save ./2fa-state.json
295
+ ```
296
+
297
+ ## HTTP Basic Auth
298
+
299
+ For sites using HTTP Basic Authentication:
300
+
301
+ ```bash
302
+ # Set credentials before navigation
303
+ agent-browser set credentials username password
304
+
305
+ # Navigate to protected resource
306
+ agent-browser open https://protected.example.com/api
307
+ ```
308
+
309
+ ## Cookie-Based Auth
310
+
311
+ Manually set authentication cookies:
312
+
313
+ ```bash
314
+ # Set auth cookie
315
+ agent-browser cookies set session_token "abc123xyz"
316
+
317
+ # Navigate to protected page
318
+ agent-browser open https://app.example.com/dashboard
319
+ ```
320
+
321
+ ## Token Refresh Handling
322
+
323
+ For sessions with expiring tokens:
324
+
325
+ ```bash
326
+ #!/bin/bash
327
+ # Wrapper that handles token refresh
328
+
329
+ STATE_FILE="./auth-state.json"
330
+
331
+ # Try loading existing state
332
+ if [[ -f "$STATE_FILE" ]]; then
333
+ agent-browser state load "$STATE_FILE"
334
+ agent-browser open https://app.example.com/dashboard
335
+
336
+ # Check if session is still valid
337
+ URL=$(agent-browser get url)
338
+ if [[ "$URL" == *"/login"* ]]; then
339
+ echo "Session expired, re-authenticating..."
340
+ # Perform fresh login
341
+ agent-browser snapshot -i
342
+ agent-browser fill @e1 "$USERNAME"
343
+ agent-browser fill @e2 "$PASSWORD"
344
+ agent-browser click @e3
345
+ agent-browser wait --url "**/dashboard"
346
+ agent-browser state save "$STATE_FILE"
347
+ fi
348
+ else
349
+ # First-time login
350
+ agent-browser open https://app.example.com/login
351
+ # ... login flow ...
352
+ fi
353
+ ```
354
+
355
+ ## Security Best Practices
356
+
357
+ 1. **Never commit state files** - They contain session tokens
358
+ ```bash
359
+ echo "*.auth-state.json" >> .gitignore
360
+ ```
361
+
362
+ 2. **Use environment variables for credentials**
363
+ ```bash
364
+ agent-browser fill @e1 "$APP_USERNAME"
365
+ agent-browser fill @e2 "$APP_PASSWORD"
366
+ ```
367
+
368
+ 3. **Clean up after automation**
369
+ ```bash
370
+ agent-browser cookies clear
371
+ rm -f ./auth-state.json
372
+ ```
373
+
374
+ 4. **Use short-lived sessions for CI/CD**
375
+ ```bash
376
+ # Don't persist state in CI
377
+ agent-browser open https://app.example.com/login
378
+ # ... login and perform actions ...
379
+ agent-browser close # Session ends, nothing persisted
380
+ ```