agent-browser-loop 0.2.2 → 0.3.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.
@@ -1,5 +1,7 @@
1
1
  # Agent Browser Loop - CLI Reference
2
2
 
3
+ <!-- TIP: Check package.json for dev server scripts to find the port to test (e.g. dev:basic, dev:next) -->
4
+
3
5
  Complete CLI reference for `agent-browser`.
4
6
 
5
7
  ## Commands
@@ -18,12 +20,19 @@ agent-browser open <url> [options]
18
20
  | `--headed` | Show browser window (default: headless) |
19
21
  | `--new, -n` | Create new session with auto-generated ID |
20
22
  | `--session, -s <id>` | Target session (from `--new`) |
23
+ | `--profile, -p <name>` | Load profile and save back on close |
24
+ | `--no-save` | Don't save profile changes on close (read-only) |
25
+ | `--width, -W <pixels>` | Viewport width (default: 1280) |
26
+ | `--height, -H <pixels>` | Viewport height (default: 720) |
21
27
  | `--json` | Output as JSON |
22
28
 
23
29
  **Examples:**
24
30
  ```bash
25
31
  agent-browser open http://localhost:3000
26
32
  agent-browser open http://localhost:3000 --headed
33
+ agent-browser open http://localhost:3000 --width 1920 --height 1080
34
+ agent-browser open http://localhost:3000 --profile admin # Loads and auto-saves on close
35
+ agent-browser open http://localhost:3000 --profile admin --no-save # Read-only
27
36
  agent-browser open --new http://localhost:3000 # Output: Session: swift-fox
28
37
  ```
29
38
 
@@ -54,6 +63,7 @@ agent-browser act <actions...> [options]
54
63
  | Type | `type:<ref>:<text>` | `type:input_0:hello` |
55
64
  | Press key | `press:<key>` | `press:Enter` |
56
65
  | Scroll | `scroll:<direction>[:<amount>]` | `scroll:down:500` |
66
+ | Resize | `resize:<width>:<height>` | `resize:1920:1080` |
57
67
  | Select | `select:<ref>:<value>` | `select:select_0:option1` |
58
68
  | Check | `check:<ref>` | `check:checkbox_0` |
59
69
  | Uncheck | `uncheck:<ref>` | `uncheck:checkbox_0` |
@@ -213,6 +223,127 @@ agent-browser screenshot
213
223
 
214
224
  ---
215
225
 
226
+ ### `resize <width> <height>`
227
+
228
+ Resize the browser viewport mid-session.
229
+
230
+ ```bash
231
+ agent-browser resize <width> <height> [options]
232
+ ```
233
+
234
+ **Options:**
235
+ | Flag | Description |
236
+ |------|-------------|
237
+ | `--session, -s <id>` | Target session |
238
+ | `--json` | Output as JSON |
239
+
240
+ **Examples:**
241
+ ```bash
242
+ agent-browser resize 1920 1080
243
+ agent-browser resize 375 667 # Mobile viewport
244
+ agent-browser act "resize:1920:1080" # Via act command
245
+ ```
246
+
247
+ ---
248
+
249
+ ### `profile <subcommand>`
250
+
251
+ Manage session storage profiles (cookies + localStorage). The `<name>` in all commands is an arbitrary identifier you choose (e.g., `admin`, `testuser`, `staging`).
252
+
253
+ #### `profile list`
254
+
255
+ List all available profiles.
256
+
257
+ ```bash
258
+ agent-browser profile list [--json]
259
+ ```
260
+
261
+ #### `profile show <name>`
262
+
263
+ Show profile contents.
264
+
265
+ ```bash
266
+ agent-browser profile show <name> [--json]
267
+ ```
268
+
269
+ #### `profile save <name>`
270
+
271
+ Save current session storage to a profile.
272
+
273
+ ```bash
274
+ agent-browser profile save <name> [options]
275
+ ```
276
+
277
+ **Options:**
278
+ | Flag | Description |
279
+ |------|-------------|
280
+ | `--session, -s <id>` | Source session |
281
+ | `--global` | Save to global profiles (`~/.config/agent-browser/profiles/`) |
282
+ | `--private` | Save to private profiles (gitignored) |
283
+ | `--description, -d <text>` | Profile description |
284
+
285
+ #### `profile delete <name>`
286
+
287
+ Delete a profile.
288
+
289
+ ```bash
290
+ agent-browser profile delete <name>
291
+ ```
292
+
293
+ #### `profile import <name> <path>`
294
+
295
+ Import profile from a Playwright storage state JSON file.
296
+
297
+ ```bash
298
+ agent-browser profile import <name> <path> [--global] [--private]
299
+ ```
300
+
301
+ #### `profile capture <name>`
302
+
303
+ Opens a headed browser, lets you interact manually (log in, etc.), then saves the session when you press Enter in the terminal.
304
+
305
+ ```bash
306
+ agent-browser profile capture <name> --url <url> [options]
307
+ ```
308
+
309
+ **Options:**
310
+ | Flag | Description |
311
+ |------|-------------|
312
+ | `--url <url>` | URL to navigate to (required) |
313
+ | `--global` | Save to global profiles |
314
+ | `--private` | Save to private profiles |
315
+ | `--description, -d <text>` | Profile description |
316
+
317
+ **Examples:**
318
+ ```bash
319
+ # Capture a session (opens browser, you log in, press Enter to save)
320
+ agent-browser profile capture admin --url http://localhost:3000/login
321
+ agent-browser profile capture testuser --url http://localhost:3000/login
322
+
323
+ # Save from an already-open session instead
324
+ agent-browser open http://localhost:3000/login --headed
325
+ # ... log in manually ...
326
+ agent-browser profile save admin --description "Admin account"
327
+
328
+ # Use profile (loads saved cookies/localStorage)
329
+ agent-browser open http://localhost:3000/dashboard --profile admin
330
+
331
+ # List profiles
332
+ agent-browser profile list
333
+
334
+ # Import existing Playwright storage state file
335
+ agent-browser profile import staging ./storage-state.json --global
336
+ ```
337
+
338
+ **Profile Storage Locations:**
339
+ - Local: `.agent-browser/profiles/<name>.json` (project-scoped, shareable via git)
340
+ - Private: `.agent-browser/profiles/.private/<name>.json` (gitignored)
341
+ - Global: `~/.config/agent-browser/profiles/<name>.json` (user-level)
342
+
343
+ Resolution order: private -> local -> global
344
+
345
+ ---
346
+
216
347
  ### `close`
217
348
 
218
349
  Close browser session or stop daemon.
@@ -3,12 +3,15 @@ name: agent-browser-loop
3
3
  description: Use when an agent must drive a live browser session in a back-and-forth loop (state -> explicit actions -> state) for UI validation, reproducible QA, or debugging UI behavior. Prefer this over one-shot CLI usage when an agent needs inspectable, stepwise control.
4
4
  ---
5
5
 
6
+
6
7
  # Agent Browser Loop
7
8
 
8
9
  Control a browser via CLI. Execute actions, read state, and verify UI changes in a stepwise loop.
9
10
 
10
11
  ## Quick Start
11
12
 
13
+ > **TIP**: Check package.json for dev server scripts to find the port to test
14
+
12
15
  ```bash
13
16
  # Open a URL (starts browser daemon automatically)
14
17
  agent-browser open http://localhost:3000
@@ -165,13 +168,42 @@ agent-browser close
165
168
  # Headed mode (visible browser)
166
169
  agent-browser open http://localhost:3000 --headed
167
170
 
168
- # JSON output
169
- agent-browser state --json
171
+ # Custom viewport size
172
+ agent-browser open http://localhost:3000 --width 1920 --height 1080
173
+
174
+ # Resize mid-session
175
+ agent-browser resize 1920 1080
176
+ ```
177
+
178
+ ## Profiles (Session Storage)
179
+
180
+ Save and reuse cookies/localStorage across sessions. The profile name (e.g., `admin`, `testuser`) is an arbitrary identifier you choose.
170
181
 
171
- # Skip state in response
172
- agent-browser act click:button_0 --no-state
182
+ ```bash
183
+ # Capture: opens browser, you interact, press Enter in terminal to save
184
+ agent-browser profile capture admin --url http://localhost:3000/login
185
+
186
+ # Or save from an already-open session
187
+ agent-browser open http://localhost:3000/login --headed
188
+ # ... log in manually ...
189
+ agent-browser profile save admin
190
+
191
+ # Use saved profile - auto-saves updated tokens on close
192
+ agent-browser open http://localhost:3000/dashboard --profile admin
193
+ # ... use the app (tokens may refresh) ...
194
+ agent-browser close # Updated tokens saved back to profile
195
+
196
+ # Use --no-save for read-only (don't save changes back)
197
+ agent-browser open http://localhost:3000 --profile admin --no-save
198
+
199
+ # List/manage profiles
200
+ agent-browser profile list
201
+ agent-browser profile show admin
202
+ agent-browser profile delete admin
173
203
  ```
174
204
 
205
+ Profiles are stored locally (`.agent-browser/profiles/`) or globally (`~/.config/agent-browser/profiles/`).
206
+
175
207
  ## Multi-Session
176
208
 
177
209
  Run multiple browsers in parallel with `--new`:
package/README.md CHANGED
@@ -57,6 +57,45 @@ agent-browser state
57
57
 
58
58
  Every command returns the current page state - interactive elements, form values, scroll position, console errors, network failures. The agent sees exactly what it needs to verify the code works or debug why it doesn't.
59
59
 
60
+ ## Profiles (Session Storage)
61
+
62
+ Save and reuse login sessions across runs:
63
+
64
+ ```bash
65
+ # Save current session to a profile
66
+ agent-browser profile save admin
67
+
68
+ # Use profile (auto-saves updated tokens on close)
69
+ agent-browser open http://localhost:3000 --profile admin
70
+
71
+ # Use --no-save for read-only access
72
+ agent-browser open http://localhost:3000 --profile admin --no-save
73
+
74
+ # Other commands
75
+ agent-browser profile list
76
+ agent-browser profile capture admin --url http://localhost:3000/login
77
+ agent-browser profile delete admin
78
+ ```
79
+
80
+ Profiles store cookies and localStorage. Use `--global` for user-level profiles, `--private` for gitignored project profiles.
81
+
82
+ ## Multi-Session
83
+
84
+ Run multiple browser sessions in parallel:
85
+
86
+ ```bash
87
+ # Create sessions with auto-generated IDs
88
+ agent-browser open --new http://localhost:3000 # Output: Session: swift-fox
89
+ agent-browser open --new http://localhost:3000 # Output: Session: calm-river
90
+
91
+ # Target specific sessions
92
+ agent-browser act -s swift-fox click:button_0
93
+ agent-browser state -s calm-river
94
+
95
+ # List all sessions
96
+ agent-browser sessions
97
+ ```
98
+
60
99
  ## CLI Reference
61
100
 
62
101
  | Command | Description |
@@ -102,23 +141,6 @@ agent-browser wait --timeout 60000 # Custom timeout
102
141
  --no-state # Skip state in response
103
142
  ```
104
143
 
105
- ## Multi-Session
106
-
107
- Run multiple browser sessions in parallel:
108
-
109
- ```bash
110
- # Create sessions with auto-generated IDs
111
- agent-browser open --new http://localhost:3000 # Output: Session: swift-fox
112
- agent-browser open --new http://localhost:3000 # Output: Session: calm-river
113
-
114
- # Target specific sessions
115
- agent-browser act -s swift-fox click:button_0
116
- agent-browser state -s calm-river
117
-
118
- # List all sessions
119
- agent-browser sessions
120
- ```
121
-
122
144
  ## State Output
123
145
 
124
146
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-browser-loop",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "description": "Let your AI coding agent drive a browser to verify its own work",
5
5
  "license": "MIT",
6
6
  "author": "Jason Silberman",
package/src/browser.ts CHANGED
@@ -482,6 +482,28 @@ export class AgentBrowser {
482
482
  return actions.screenshot(this.getPage(), options);
483
483
  }
484
484
 
485
+ /**
486
+ * Resize the viewport
487
+ */
488
+ async resize(width: number, height: number): Promise<void> {
489
+ await this.getPage().setViewportSize({ width, height });
490
+ this.config.viewportWidth = width;
491
+ this.config.viewportHeight = height;
492
+ }
493
+
494
+ /**
495
+ * Get current viewport size
496
+ */
497
+ getViewportSize(): { width: number; height: number } {
498
+ const size = this.getPage().viewportSize();
499
+ return (
500
+ size ?? {
501
+ width: this.config.viewportWidth!,
502
+ height: this.config.viewportHeight!,
503
+ }
504
+ );
505
+ }
506
+
485
507
  /**
486
508
  * Get captured console logs
487
509
  */