@nickduy/agent-studio 0.1.5 → 0.1.7

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,278 +1,278 @@
1
- # Storage Management
2
-
3
- Manage cookies, localStorage, sessionStorage, and browser storage state.
4
-
5
- ## Storage State
6
-
7
- Save and restore complete browser state including cookies and storage.
8
-
9
- ### Save Storage State
10
-
11
- ```bash
12
- # Save to auto-generated filename (storage-state-{timestamp}.json)
13
- playwright-cli state-save
14
-
15
- # Save to specific filename
16
- playwright-cli state-save my-auth-state.json
17
- ```
18
-
19
- ### Restore Storage State
20
-
21
- ```bash
22
- # Load storage state from file
23
- playwright-cli state-load my-auth-state.json
24
-
25
- # Reload page to apply cookies
26
- playwright-cli open https://example.com
27
- ```
28
-
29
- ### Storage State File Format
30
-
31
- The saved file contains:
32
-
33
- ```json
34
- {
35
- "cookies": [
36
- {
37
- "name": "session_id",
38
- "value": "abc123",
39
- "domain": "example.com",
40
- "path": "/",
41
- "expires": 1893456000,
42
- "httpOnly": true,
43
- "secure": true,
44
- "sameSite": "Lax"
45
- }
46
- ],
47
- "origins": [
48
- {
49
- "origin": "https://example.com",
50
- "localStorage": [
51
- { "name": "theme", "value": "dark" },
52
- { "name": "user_id", "value": "12345" }
53
- ]
54
- }
55
- ]
56
- }
57
- ```
58
-
59
- ## Cookies
60
-
61
- ### List All Cookies
62
-
63
- ```bash
64
- playwright-cli cookie-list
65
- ```
66
-
67
- ### Filter Cookies by Domain
68
-
69
- ```bash
70
- playwright-cli cookie-list --domain=example.com
71
- ```
72
-
73
- ### Filter Cookies by Path
74
-
75
- ```bash
76
- playwright-cli cookie-list --path=/api
77
- ```
78
-
79
- ### Get Specific Cookie
80
-
81
- ```bash
82
- playwright-cli cookie-get session_id
83
- ```
84
-
85
- ### Set a Cookie
86
-
87
- ```bash
88
- # Basic cookie
89
- playwright-cli cookie-set session abc123
90
-
91
- # Cookie with options
92
- playwright-cli cookie-set session abc123 --domain=example.com --path=/ --httpOnly --secure --sameSite=Lax
93
-
94
- # Cookie with expiration (Unix timestamp)
95
- playwright-cli cookie-set remember_me token123 --expires=1893456000
96
- ```
97
-
98
- ### Delete a Cookie
99
-
100
- ```bash
101
- playwright-cli cookie-delete session_id
102
-
103
- # Only on one domain, other domains keep their session_id
104
- playwright-cli cookie-delete session_id --domain=example.com
105
- ```
106
-
107
- ### Clear All Cookies
108
-
109
- ```bash
110
- playwright-cli cookie-clear
111
- ```
112
-
113
- ### Advanced: Multiple Cookies or Custom Options
114
-
115
- For complex scenarios like adding multiple cookies at once, use `run-code`:
116
-
117
- ```bash
118
- playwright-cli run-code "async page => {
119
- await page.context().addCookies([
120
- { name: 'session_id', value: 'sess_abc123', domain: 'example.com', path: '/', httpOnly: true },
121
- { name: 'preferences', value: JSON.stringify({ theme: 'dark' }), domain: 'example.com', path: '/' }
122
- ]);
123
- }"
124
- ```
125
-
126
- ## Local Storage
127
-
128
- ### List All localStorage Items
129
-
130
- ```bash
131
- playwright-cli localstorage-list
132
- ```
133
-
134
- ### Get Single Value
135
-
136
- ```bash
137
- playwright-cli localstorage-get token
138
- ```
139
-
140
- ### Set Value
141
-
142
- ```bash
143
- playwright-cli localstorage-set theme dark
144
- ```
145
-
146
- ### Set JSON Value
147
-
148
- ```bash
149
- playwright-cli localstorage-set user_settings '{"theme":"dark","language":"en"}'
150
- ```
151
-
152
- ### Delete Single Item
153
-
154
- ```bash
155
- playwright-cli localstorage-delete token
156
- ```
157
-
158
- ### Clear All localStorage
159
-
160
- ```bash
161
- playwright-cli localstorage-clear
162
- ```
163
-
164
- ### Advanced: Multiple Operations
165
-
166
- For complex scenarios like setting multiple values at once, use `run-code`:
167
-
168
- ```bash
169
- playwright-cli run-code "async page => {
170
- await page.evaluate(() => {
171
- localStorage.setItem('token', 'jwt_abc123');
172
- localStorage.setItem('user_id', '12345');
173
- localStorage.setItem('expires_at', Date.now() + 3600000);
174
- });
175
- }"
176
- ```
177
-
178
- ## Session Storage
179
-
180
- ### List All sessionStorage Items
181
-
182
- ```bash
183
- playwright-cli sessionstorage-list
184
- ```
185
-
186
- ### Get Single Value
187
-
188
- ```bash
189
- playwright-cli sessionstorage-get form_data
190
- ```
191
-
192
- ### Set Value
193
-
194
- ```bash
195
- playwright-cli sessionstorage-set step 3
196
- ```
197
-
198
- ### Delete Single Item
199
-
200
- ```bash
201
- playwright-cli sessionstorage-delete step
202
- ```
203
-
204
- ### Clear sessionStorage
205
-
206
- ```bash
207
- playwright-cli sessionstorage-clear
208
- ```
209
-
210
- ## IndexedDB
211
-
212
- ### List Databases
213
-
214
- ```bash
215
- playwright-cli run-code "async page => {
216
- return await page.evaluate(async () => {
217
- const databases = await indexedDB.databases();
218
- return databases;
219
- });
220
- }"
221
- ```
222
-
223
- ### Delete Database
224
-
225
- ```bash
226
- playwright-cli run-code "async page => {
227
- await page.evaluate(() => {
228
- indexedDB.deleteDatabase('myDatabase');
229
- });
230
- }"
231
- ```
232
-
233
- ## Common Patterns
234
-
235
- ### Authentication State Reuse
236
-
237
- ```bash
238
- # Step 1: Login and save state
239
- playwright-cli open https://app.example.com/login
240
- playwright-cli snapshot
241
- playwright-cli fill e1 "user@example.com"
242
- playwright-cli fill e2 "password123"
243
- playwright-cli click e3
244
-
245
- # Save the authenticated state
246
- playwright-cli state-save auth.json
247
-
248
- # Step 2: Later, restore state and skip login
249
- playwright-cli state-load auth.json
250
- playwright-cli open https://app.example.com/dashboard
251
- # Already logged in!
252
- ```
253
-
254
- ### Save and Restore Roundtrip
255
-
256
- ```bash
257
- # Set up authentication state
258
- playwright-cli open https://example.com
259
- playwright-cli eval "() => { document.cookie = 'session=abc123'; localStorage.setItem('user', 'john'); }"
260
-
261
- # Save state to file
262
- playwright-cli state-save my-session.json
263
-
264
- # ... later, in a new session ...
265
-
266
- # Restore state
267
- playwright-cli state-load my-session.json
268
- playwright-cli open https://example.com
269
- # Cookies and localStorage are restored!
270
- ```
271
-
272
- ## Security Notes
273
-
274
- - Never commit storage state files containing auth tokens
275
- - Add `*.auth-state.json` to `.gitignore`
276
- - Delete state files after automation completes
277
- - Use environment variables for sensitive data
278
- - By default, sessions run in-memory mode which is safer for sensitive operations
1
+ # Storage Management
2
+
3
+ Manage cookies, localStorage, sessionStorage, and browser storage state.
4
+
5
+ ## Storage State
6
+
7
+ Save and restore complete browser state including cookies and storage.
8
+
9
+ ### Save Storage State
10
+
11
+ ```bash
12
+ # Save to auto-generated filename (storage-state-{timestamp}.json)
13
+ playwright-cli state-save
14
+
15
+ # Save to specific filename
16
+ playwright-cli state-save my-auth-state.json
17
+ ```
18
+
19
+ ### Restore Storage State
20
+
21
+ ```bash
22
+ # Load storage state from file
23
+ playwright-cli state-load my-auth-state.json
24
+
25
+ # Reload page to apply cookies
26
+ playwright-cli open https://example.com
27
+ ```
28
+
29
+ ### Storage State File Format
30
+
31
+ The saved file contains:
32
+
33
+ ```json
34
+ {
35
+ "cookies": [
36
+ {
37
+ "name": "session_id",
38
+ "value": "abc123",
39
+ "domain": "example.com",
40
+ "path": "/",
41
+ "expires": 1893456000,
42
+ "httpOnly": true,
43
+ "secure": true,
44
+ "sameSite": "Lax"
45
+ }
46
+ ],
47
+ "origins": [
48
+ {
49
+ "origin": "https://example.com",
50
+ "localStorage": [
51
+ { "name": "theme", "value": "dark" },
52
+ { "name": "user_id", "value": "12345" }
53
+ ]
54
+ }
55
+ ]
56
+ }
57
+ ```
58
+
59
+ ## Cookies
60
+
61
+ ### List All Cookies
62
+
63
+ ```bash
64
+ playwright-cli cookie-list
65
+ ```
66
+
67
+ ### Filter Cookies by Domain
68
+
69
+ ```bash
70
+ playwright-cli cookie-list --domain=example.com
71
+ ```
72
+
73
+ ### Filter Cookies by Path
74
+
75
+ ```bash
76
+ playwright-cli cookie-list --path=/api
77
+ ```
78
+
79
+ ### Get Specific Cookie
80
+
81
+ ```bash
82
+ playwright-cli cookie-get session_id
83
+ ```
84
+
85
+ ### Set a Cookie
86
+
87
+ ```bash
88
+ # Basic cookie
89
+ playwright-cli cookie-set session abc123
90
+
91
+ # Cookie with options
92
+ playwright-cli cookie-set session abc123 --domain=example.com --path=/ --httpOnly --secure --sameSite=Lax
93
+
94
+ # Cookie with expiration (Unix timestamp)
95
+ playwright-cli cookie-set remember_me token123 --expires=1893456000
96
+ ```
97
+
98
+ ### Delete a Cookie
99
+
100
+ ```bash
101
+ playwright-cli cookie-delete session_id
102
+
103
+ # Only on one domain, other domains keep their session_id
104
+ playwright-cli cookie-delete session_id --domain=example.com
105
+ ```
106
+
107
+ ### Clear All Cookies
108
+
109
+ ```bash
110
+ playwright-cli cookie-clear
111
+ ```
112
+
113
+ ### Advanced: Multiple Cookies or Custom Options
114
+
115
+ For complex scenarios like adding multiple cookies at once, use `run-code`:
116
+
117
+ ```bash
118
+ playwright-cli run-code "async page => {
119
+ await page.context().addCookies([
120
+ { name: 'session_id', value: 'sess_abc123', domain: 'example.com', path: '/', httpOnly: true },
121
+ { name: 'preferences', value: JSON.stringify({ theme: 'dark' }), domain: 'example.com', path: '/' }
122
+ ]);
123
+ }"
124
+ ```
125
+
126
+ ## Local Storage
127
+
128
+ ### List All localStorage Items
129
+
130
+ ```bash
131
+ playwright-cli localstorage-list
132
+ ```
133
+
134
+ ### Get Single Value
135
+
136
+ ```bash
137
+ playwright-cli localstorage-get token
138
+ ```
139
+
140
+ ### Set Value
141
+
142
+ ```bash
143
+ playwright-cli localstorage-set theme dark
144
+ ```
145
+
146
+ ### Set JSON Value
147
+
148
+ ```bash
149
+ playwright-cli localstorage-set user_settings '{"theme":"dark","language":"en"}'
150
+ ```
151
+
152
+ ### Delete Single Item
153
+
154
+ ```bash
155
+ playwright-cli localstorage-delete token
156
+ ```
157
+
158
+ ### Clear All localStorage
159
+
160
+ ```bash
161
+ playwright-cli localstorage-clear
162
+ ```
163
+
164
+ ### Advanced: Multiple Operations
165
+
166
+ For complex scenarios like setting multiple values at once, use `run-code`:
167
+
168
+ ```bash
169
+ playwright-cli run-code "async page => {
170
+ await page.evaluate(() => {
171
+ localStorage.setItem('token', 'jwt_abc123');
172
+ localStorage.setItem('user_id', '12345');
173
+ localStorage.setItem('expires_at', Date.now() + 3600000);
174
+ });
175
+ }"
176
+ ```
177
+
178
+ ## Session Storage
179
+
180
+ ### List All sessionStorage Items
181
+
182
+ ```bash
183
+ playwright-cli sessionstorage-list
184
+ ```
185
+
186
+ ### Get Single Value
187
+
188
+ ```bash
189
+ playwright-cli sessionstorage-get form_data
190
+ ```
191
+
192
+ ### Set Value
193
+
194
+ ```bash
195
+ playwright-cli sessionstorage-set step 3
196
+ ```
197
+
198
+ ### Delete Single Item
199
+
200
+ ```bash
201
+ playwright-cli sessionstorage-delete step
202
+ ```
203
+
204
+ ### Clear sessionStorage
205
+
206
+ ```bash
207
+ playwright-cli sessionstorage-clear
208
+ ```
209
+
210
+ ## IndexedDB
211
+
212
+ ### List Databases
213
+
214
+ ```bash
215
+ playwright-cli run-code "async page => {
216
+ return await page.evaluate(async () => {
217
+ const databases = await indexedDB.databases();
218
+ return databases;
219
+ });
220
+ }"
221
+ ```
222
+
223
+ ### Delete Database
224
+
225
+ ```bash
226
+ playwright-cli run-code "async page => {
227
+ await page.evaluate(() => {
228
+ indexedDB.deleteDatabase('myDatabase');
229
+ });
230
+ }"
231
+ ```
232
+
233
+ ## Common Patterns
234
+
235
+ ### Authentication State Reuse
236
+
237
+ ```bash
238
+ # Step 1: Login and save state
239
+ playwright-cli open https://app.example.com/login
240
+ playwright-cli snapshot
241
+ playwright-cli fill e1 "user@example.com"
242
+ playwright-cli fill e2 "password123"
243
+ playwright-cli click e3
244
+
245
+ # Save the authenticated state
246
+ playwright-cli state-save auth.json
247
+
248
+ # Step 2: Later, restore state and skip login
249
+ playwright-cli state-load auth.json
250
+ playwright-cli open https://app.example.com/dashboard
251
+ # Already logged in!
252
+ ```
253
+
254
+ ### Save and Restore Roundtrip
255
+
256
+ ```bash
257
+ # Set up authentication state
258
+ playwright-cli open https://example.com
259
+ playwright-cli eval "() => { document.cookie = 'session=abc123'; localStorage.setItem('user', 'john'); }"
260
+
261
+ # Save state to file
262
+ playwright-cli state-save my-session.json
263
+
264
+ # ... later, in a new session ...
265
+
266
+ # Restore state
267
+ playwright-cli state-load my-session.json
268
+ playwright-cli open https://example.com
269
+ # Cookies and localStorage are restored!
270
+ ```
271
+
272
+ ## Security Notes
273
+
274
+ - Never commit storage state files containing auth tokens
275
+ - Add `*.auth-state.json` to `.gitignore`
276
+ - Delete state files after automation completes
277
+ - Use environment variables for sensitive data
278
+ - By default, sessions run in-memory mode which is safer for sensitive operations