@nickduy/agent-studio 0.1.4 → 0.1.6

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,227 +1,227 @@
1
- # Browser Session Management
2
-
3
- Run multiple isolated browser sessions concurrently with state persistence.
4
-
5
- ## Named Browser Sessions
6
-
7
- Use `-s` flag to isolate browser contexts:
8
-
9
- ```bash
10
- # Browser 1: Authentication flow
11
- playwright-cli -s=auth open https://app.example.com/login
12
-
13
- # Browser 2: Public browsing (separate cookies, storage)
14
- playwright-cli -s=public open https://example.com
15
-
16
- # Commands are isolated by browser session
17
- playwright-cli -s=auth fill e1 "user@example.com"
18
- playwright-cli -s=public snapshot
19
- ```
20
-
21
- ## Browser Session Isolation Properties
22
-
23
- Each browser session has independent:
24
- - Cookies
25
- - LocalStorage / SessionStorage
26
- - IndexedDB
27
- - Cache
28
- - Browsing history
29
- - Open tabs
30
-
31
- ## Browser Session Commands
32
-
33
- ```bash
34
- # List all browser sessions
35
- playwright-cli list
36
-
37
- # Stop a browser session (close the browser)
38
- playwright-cli close # stop the default browser
39
- playwright-cli -s=mysession close # stop a named browser
40
-
41
- # Stop all browser sessions
42
- playwright-cli close-all
43
-
44
- # Forcefully kill all daemon processes (for stale/zombie processes)
45
- playwright-cli kill-all
46
-
47
- # Delete browser session user data (profile directory)
48
- playwright-cli delete-data # delete default browser data
49
- playwright-cli -s=mysession delete-data # delete named browser data
50
- ```
51
-
52
- A headless session shuts down on its own after an hour without commands; the next command then reports that the browser is not open, so run `open` again. Headed browsers stay open. Use `open --idle-timeout=<ms>` to change the timeout, or `0` to disable it.
53
-
54
- ## Environment Variable
55
-
56
- Set a default browser session name via environment variable:
57
-
58
- ```bash
59
- export PLAYWRIGHT_CLI_SESSION="mysession"
60
- playwright-cli open example.com # Uses "mysession" automatically
61
- ```
62
-
63
- ## Common Patterns
64
-
65
- ### Concurrent Scraping
66
-
67
- ```bash
68
- #!/bin/bash
69
- # Scrape multiple sites concurrently
70
-
71
- # Start all browsers
72
- playwright-cli -s=site1 open https://site1.com &
73
- playwright-cli -s=site2 open https://site2.com &
74
- playwright-cli -s=site3 open https://site3.com &
75
- wait
76
-
77
- # Take snapshots from each
78
- playwright-cli -s=site1 snapshot
79
- playwright-cli -s=site2 snapshot
80
- playwright-cli -s=site3 snapshot
81
-
82
- # Cleanup
83
- playwright-cli close-all
84
- ```
85
-
86
- ### A/B Testing Sessions
87
-
88
- ```bash
89
- # Test different user experiences
90
- playwright-cli -s=variant-a open "https://app.com?variant=a"
91
- playwright-cli -s=variant-b open "https://app.com?variant=b"
92
-
93
- # Compare
94
- playwright-cli -s=variant-a screenshot
95
- playwright-cli -s=variant-b screenshot
96
- ```
97
-
98
- ### Persistent Profile
99
-
100
- By default, browser profile is kept in memory only. Use `--persistent` flag on `open` to persist the browser profile to disk:
101
-
102
- ```bash
103
- # Use persistent profile (auto-generated location)
104
- playwright-cli open https://example.com --persistent
105
-
106
- # Use persistent profile with custom directory
107
- playwright-cli open https://example.com --profile=/path/to/profile
108
- ```
109
-
110
- ## Attaching to a Running Browser
111
-
112
- Use `attach` to connect to a browser that is already running, instead of launching a new one.
113
-
114
- ### Attach by channel name
115
-
116
- Connect to a running Chrome or Edge instance by its channel name. The browser must have remote debugging enabled — navigate to `chrome://inspect/#remote-debugging` in the target browser and check "Allow remote debugging for this browser instance".
117
-
118
- ```bash
119
- # Attach to Chrome
120
- playwright-cli attach --cdp=chrome
121
-
122
- # Attach to Chrome Canary
123
- playwright-cli attach --cdp=chrome-canary
124
-
125
- # Attach to Microsoft Edge
126
- playwright-cli attach --cdp=msedge
127
-
128
- # Attach to Edge Dev
129
- playwright-cli attach --cdp=msedge-dev
130
- ```
131
-
132
- Supported channels: `chrome`, `chrome-beta`, `chrome-dev`, `chrome-canary`, `msedge`, `msedge-beta`, `msedge-dev`, `msedge-canary`.
133
-
134
- When `--session` is not provided, the session is named after the channel (e.g. `--cdp=msedge` creates a session called `msedge`), so parallel attaches to Chrome and Edge don't collide on `default`. Pass `--session=<name>` to override.
135
-
136
- ### Attach via CDP endpoint
137
-
138
- Connect to a browser that exposes a Chrome DevTools Protocol endpoint:
139
-
140
- ```bash
141
- playwright-cli attach --cdp=http://localhost:9222
142
- ```
143
-
144
- ### Attach via browser extension
145
-
146
- Connect to a browser with the Playwright extension installed:
147
-
148
- ```bash
149
- playwright-cli attach --extension
150
- ```
151
-
152
- ### Detach
153
-
154
- Tear down an attached session without affecting the external browser:
155
-
156
- ```bash
157
- # Detach the default attached session
158
- playwright-cli detach
159
-
160
- # Detach a specific attached session
161
- playwright-cli -s=msedge detach
162
- ```
163
-
164
- `detach` only works on sessions created via `attach`. For sessions created via `open`, use `close`.
165
-
166
- ## Default Browser Session
167
-
168
- When `-s` is omitted, commands use the default browser session:
169
-
170
- ```bash
171
- # These use the same default browser session
172
- playwright-cli open https://example.com
173
- playwright-cli snapshot
174
- playwright-cli close # Stops default browser
175
- ```
176
-
177
- ## Browser Session Configuration
178
-
179
- Configure a browser session with specific settings when opening:
180
-
181
- ```bash
182
- # Open with config file
183
- playwright-cli open https://example.com --config=.playwright/my-cli.json
184
-
185
- # Open with specific browser
186
- playwright-cli open https://example.com --browser=firefox
187
-
188
- # Open in headed mode
189
- playwright-cli open https://example.com --headed
190
-
191
- # Open with persistent profile
192
- playwright-cli open https://example.com --persistent
193
- ```
194
-
195
- ## Best Practices
196
-
197
- ### 1. Name Browser Sessions Semantically
198
-
199
- ```bash
200
- # GOOD: Clear purpose
201
- playwright-cli -s=github-auth open https://github.com
202
- playwright-cli -s=docs-scrape open https://docs.example.com
203
-
204
- # AVOID: Generic names
205
- playwright-cli -s=s1 open https://github.com
206
- ```
207
-
208
- ### 2. Always Clean Up
209
-
210
- ```bash
211
- # Stop browsers when done
212
- playwright-cli -s=auth close
213
- playwright-cli -s=scrape close
214
-
215
- # Or stop all at once
216
- playwright-cli close-all
217
-
218
- # If browsers become unresponsive or zombie processes remain
219
- playwright-cli kill-all
220
- ```
221
-
222
- ### 3. Delete Stale Browser Data
223
-
224
- ```bash
225
- # Remove old browser data to free disk space
226
- playwright-cli -s=oldsession delete-data
227
- ```
1
+ # Browser Session Management
2
+
3
+ Run multiple isolated browser sessions concurrently with state persistence.
4
+
5
+ ## Named Browser Sessions
6
+
7
+ Use `-s` flag to isolate browser contexts:
8
+
9
+ ```bash
10
+ # Browser 1: Authentication flow
11
+ playwright-cli -s=auth open https://app.example.com/login
12
+
13
+ # Browser 2: Public browsing (separate cookies, storage)
14
+ playwright-cli -s=public open https://example.com
15
+
16
+ # Commands are isolated by browser session
17
+ playwright-cli -s=auth fill e1 "user@example.com"
18
+ playwright-cli -s=public snapshot
19
+ ```
20
+
21
+ ## Browser Session Isolation Properties
22
+
23
+ Each browser session has independent:
24
+ - Cookies
25
+ - LocalStorage / SessionStorage
26
+ - IndexedDB
27
+ - Cache
28
+ - Browsing history
29
+ - Open tabs
30
+
31
+ ## Browser Session Commands
32
+
33
+ ```bash
34
+ # List all browser sessions
35
+ playwright-cli list
36
+
37
+ # Stop a browser session (close the browser)
38
+ playwright-cli close # stop the default browser
39
+ playwright-cli -s=mysession close # stop a named browser
40
+
41
+ # Stop all browser sessions
42
+ playwright-cli close-all
43
+
44
+ # Forcefully kill all daemon processes (for stale/zombie processes)
45
+ playwright-cli kill-all
46
+
47
+ # Delete browser session user data (profile directory)
48
+ playwright-cli delete-data # delete default browser data
49
+ playwright-cli -s=mysession delete-data # delete named browser data
50
+ ```
51
+
52
+ A headless session shuts down on its own after an hour without commands; the next command then reports that the browser is not open, so run `open` again. Headed browsers stay open. Use `open --idle-timeout=<ms>` to change the timeout, or `0` to disable it.
53
+
54
+ ## Environment Variable
55
+
56
+ Set a default browser session name via environment variable:
57
+
58
+ ```bash
59
+ export PLAYWRIGHT_CLI_SESSION="mysession"
60
+ playwright-cli open example.com # Uses "mysession" automatically
61
+ ```
62
+
63
+ ## Common Patterns
64
+
65
+ ### Concurrent Scraping
66
+
67
+ ```bash
68
+ #!/bin/bash
69
+ # Scrape multiple sites concurrently
70
+
71
+ # Start all browsers
72
+ playwright-cli -s=site1 open https://site1.com &
73
+ playwright-cli -s=site2 open https://site2.com &
74
+ playwright-cli -s=site3 open https://site3.com &
75
+ wait
76
+
77
+ # Take snapshots from each
78
+ playwright-cli -s=site1 snapshot
79
+ playwright-cli -s=site2 snapshot
80
+ playwright-cli -s=site3 snapshot
81
+
82
+ # Cleanup
83
+ playwright-cli close-all
84
+ ```
85
+
86
+ ### A/B Testing Sessions
87
+
88
+ ```bash
89
+ # Test different user experiences
90
+ playwright-cli -s=variant-a open "https://app.com?variant=a"
91
+ playwright-cli -s=variant-b open "https://app.com?variant=b"
92
+
93
+ # Compare
94
+ playwright-cli -s=variant-a screenshot
95
+ playwright-cli -s=variant-b screenshot
96
+ ```
97
+
98
+ ### Persistent Profile
99
+
100
+ By default, browser profile is kept in memory only. Use `--persistent` flag on `open` to persist the browser profile to disk:
101
+
102
+ ```bash
103
+ # Use persistent profile (auto-generated location)
104
+ playwright-cli open https://example.com --persistent
105
+
106
+ # Use persistent profile with custom directory
107
+ playwright-cli open https://example.com --profile=/path/to/profile
108
+ ```
109
+
110
+ ## Attaching to a Running Browser
111
+
112
+ Use `attach` to connect to a browser that is already running, instead of launching a new one.
113
+
114
+ ### Attach by channel name
115
+
116
+ Connect to a running Chrome or Edge instance by its channel name. The browser must have remote debugging enabled — navigate to `chrome://inspect/#remote-debugging` in the target browser and check "Allow remote debugging for this browser instance".
117
+
118
+ ```bash
119
+ # Attach to Chrome
120
+ playwright-cli attach --cdp=chrome
121
+
122
+ # Attach to Chrome Canary
123
+ playwright-cli attach --cdp=chrome-canary
124
+
125
+ # Attach to Microsoft Edge
126
+ playwright-cli attach --cdp=msedge
127
+
128
+ # Attach to Edge Dev
129
+ playwright-cli attach --cdp=msedge-dev
130
+ ```
131
+
132
+ Supported channels: `chrome`, `chrome-beta`, `chrome-dev`, `chrome-canary`, `msedge`, `msedge-beta`, `msedge-dev`, `msedge-canary`.
133
+
134
+ When `--session` is not provided, the session is named after the channel (e.g. `--cdp=msedge` creates a session called `msedge`), so parallel attaches to Chrome and Edge don't collide on `default`. Pass `--session=<name>` to override.
135
+
136
+ ### Attach via CDP endpoint
137
+
138
+ Connect to a browser that exposes a Chrome DevTools Protocol endpoint:
139
+
140
+ ```bash
141
+ playwright-cli attach --cdp=http://localhost:9222
142
+ ```
143
+
144
+ ### Attach via browser extension
145
+
146
+ Connect to a browser with the Playwright extension installed:
147
+
148
+ ```bash
149
+ playwright-cli attach --extension
150
+ ```
151
+
152
+ ### Detach
153
+
154
+ Tear down an attached session without affecting the external browser:
155
+
156
+ ```bash
157
+ # Detach the default attached session
158
+ playwright-cli detach
159
+
160
+ # Detach a specific attached session
161
+ playwright-cli -s=msedge detach
162
+ ```
163
+
164
+ `detach` only works on sessions created via `attach`. For sessions created via `open`, use `close`.
165
+
166
+ ## Default Browser Session
167
+
168
+ When `-s` is omitted, commands use the default browser session:
169
+
170
+ ```bash
171
+ # These use the same default browser session
172
+ playwright-cli open https://example.com
173
+ playwright-cli snapshot
174
+ playwright-cli close # Stops default browser
175
+ ```
176
+
177
+ ## Browser Session Configuration
178
+
179
+ Configure a browser session with specific settings when opening:
180
+
181
+ ```bash
182
+ # Open with config file
183
+ playwright-cli open https://example.com --config=.playwright/my-cli.json
184
+
185
+ # Open with specific browser
186
+ playwright-cli open https://example.com --browser=firefox
187
+
188
+ # Open in headed mode
189
+ playwright-cli open https://example.com --headed
190
+
191
+ # Open with persistent profile
192
+ playwright-cli open https://example.com --persistent
193
+ ```
194
+
195
+ ## Best Practices
196
+
197
+ ### 1. Name Browser Sessions Semantically
198
+
199
+ ```bash
200
+ # GOOD: Clear purpose
201
+ playwright-cli -s=github-auth open https://github.com
202
+ playwright-cli -s=docs-scrape open https://docs.example.com
203
+
204
+ # AVOID: Generic names
205
+ playwright-cli -s=s1 open https://github.com
206
+ ```
207
+
208
+ ### 2. Always Clean Up
209
+
210
+ ```bash
211
+ # Stop browsers when done
212
+ playwright-cli -s=auth close
213
+ playwright-cli -s=scrape close
214
+
215
+ # Or stop all at once
216
+ playwright-cli close-all
217
+
218
+ # If browsers become unresponsive or zombie processes remain
219
+ playwright-cli kill-all
220
+ ```
221
+
222
+ ### 3. Delete Stale Browser Data
223
+
224
+ ```bash
225
+ # Remove old browser data to free disk space
226
+ playwright-cli -s=oldsession delete-data
227
+ ```