nstbrowser-ai-agent 0.0.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 (119) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1321 -0
  3. package/bin/nstbrowser-ai-agent-darwin-arm64 +0 -0
  4. package/bin/nstbrowser-ai-agent-darwin-x64 +0 -0
  5. package/bin/nstbrowser-ai-agent-linux-arm64 +0 -0
  6. package/bin/nstbrowser-ai-agent-linux-x64 +0 -0
  7. package/bin/nstbrowser-ai-agent-win32-x64.exe +0 -0
  8. package/bin/nstbrowser-ai-agent.js +109 -0
  9. package/dist/action-policy.d.ts +14 -0
  10. package/dist/action-policy.d.ts.map +1 -0
  11. package/dist/action-policy.js +253 -0
  12. package/dist/action-policy.js.map +1 -0
  13. package/dist/actions.d.ts +18 -0
  14. package/dist/actions.d.ts.map +1 -0
  15. package/dist/actions.js +2037 -0
  16. package/dist/actions.js.map +1 -0
  17. package/dist/auth-cli.d.ts +2 -0
  18. package/dist/auth-cli.d.ts.map +1 -0
  19. package/dist/auth-cli.js +97 -0
  20. package/dist/auth-cli.js.map +1 -0
  21. package/dist/auth-vault.d.ts +36 -0
  22. package/dist/auth-vault.d.ts.map +1 -0
  23. package/dist/auth-vault.js +125 -0
  24. package/dist/auth-vault.js.map +1 -0
  25. package/dist/browser.d.ts +573 -0
  26. package/dist/browser.d.ts.map +1 -0
  27. package/dist/browser.js +2036 -0
  28. package/dist/browser.js.map +1 -0
  29. package/dist/confirmation.d.ts +8 -0
  30. package/dist/confirmation.d.ts.map +1 -0
  31. package/dist/confirmation.js +30 -0
  32. package/dist/confirmation.js.map +1 -0
  33. package/dist/daemon.d.ts +65 -0
  34. package/dist/daemon.d.ts.map +1 -0
  35. package/dist/daemon.js +589 -0
  36. package/dist/daemon.js.map +1 -0
  37. package/dist/diff.d.ts +18 -0
  38. package/dist/diff.d.ts.map +1 -0
  39. package/dist/diff.js +271 -0
  40. package/dist/diff.js.map +1 -0
  41. package/dist/domain-filter.d.ts +28 -0
  42. package/dist/domain-filter.d.ts.map +1 -0
  43. package/dist/domain-filter.js +149 -0
  44. package/dist/domain-filter.js.map +1 -0
  45. package/dist/encryption.d.ts +73 -0
  46. package/dist/encryption.d.ts.map +1 -0
  47. package/dist/encryption.js +171 -0
  48. package/dist/encryption.js.map +1 -0
  49. package/dist/ios-actions.d.ts +11 -0
  50. package/dist/ios-actions.d.ts.map +1 -0
  51. package/dist/ios-actions.js +228 -0
  52. package/dist/ios-actions.js.map +1 -0
  53. package/dist/ios-manager.d.ts +266 -0
  54. package/dist/ios-manager.d.ts.map +1 -0
  55. package/dist/ios-manager.js +1073 -0
  56. package/dist/ios-manager.js.map +1 -0
  57. package/dist/nstbrowser-actions.d.ts +10 -0
  58. package/dist/nstbrowser-actions.d.ts.map +1 -0
  59. package/dist/nstbrowser-actions.js +277 -0
  60. package/dist/nstbrowser-actions.js.map +1 -0
  61. package/dist/nstbrowser-client.d.ts +197 -0
  62. package/dist/nstbrowser-client.d.ts.map +1 -0
  63. package/dist/nstbrowser-client.js +454 -0
  64. package/dist/nstbrowser-client.js.map +1 -0
  65. package/dist/nstbrowser-errors.d.ts +28 -0
  66. package/dist/nstbrowser-errors.d.ts.map +1 -0
  67. package/dist/nstbrowser-errors.js +59 -0
  68. package/dist/nstbrowser-errors.js.map +1 -0
  69. package/dist/nstbrowser-profile-resolver.d.ts +89 -0
  70. package/dist/nstbrowser-profile-resolver.d.ts.map +1 -0
  71. package/dist/nstbrowser-profile-resolver.js +227 -0
  72. package/dist/nstbrowser-profile-resolver.js.map +1 -0
  73. package/dist/nstbrowser-types.d.ts +151 -0
  74. package/dist/nstbrowser-types.d.ts.map +1 -0
  75. package/dist/nstbrowser-types.js +5 -0
  76. package/dist/nstbrowser-types.js.map +1 -0
  77. package/dist/nstbrowser-utils.d.ts +71 -0
  78. package/dist/nstbrowser-utils.d.ts.map +1 -0
  79. package/dist/nstbrowser-utils.js +174 -0
  80. package/dist/nstbrowser-utils.js.map +1 -0
  81. package/dist/protocol.d.ts +26 -0
  82. package/dist/protocol.d.ts.map +1 -0
  83. package/dist/protocol.js +1245 -0
  84. package/dist/protocol.js.map +1 -0
  85. package/dist/snapshot.d.ts +67 -0
  86. package/dist/snapshot.d.ts.map +1 -0
  87. package/dist/snapshot.js +514 -0
  88. package/dist/snapshot.js.map +1 -0
  89. package/dist/state-utils.d.ts +77 -0
  90. package/dist/state-utils.d.ts.map +1 -0
  91. package/dist/state-utils.js +178 -0
  92. package/dist/state-utils.js.map +1 -0
  93. package/dist/stream-server.d.ts +117 -0
  94. package/dist/stream-server.d.ts.map +1 -0
  95. package/dist/stream-server.js +309 -0
  96. package/dist/stream-server.js.map +1 -0
  97. package/dist/types.d.ts +1121 -0
  98. package/dist/types.d.ts.map +1 -0
  99. package/dist/types.js +2 -0
  100. package/dist/types.js.map +1 -0
  101. package/package.json +83 -0
  102. package/scripts/analyze-api-coverage.js +205 -0
  103. package/scripts/analyze-cli-coverage.js +239 -0
  104. package/scripts/build-all-platforms.sh +68 -0
  105. package/scripts/check-version-sync.js +39 -0
  106. package/scripts/copy-native.js +36 -0
  107. package/scripts/download-nstbrowser-docs.js +152 -0
  108. package/scripts/generate-skills.sh +218 -0
  109. package/scripts/postinstall.js +231 -0
  110. package/scripts/sync-version.js +69 -0
  111. package/skills/nstbrowser-ai-agent/SKILL.md +759 -0
  112. package/skills/nstbrowser-ai-agent/references/batch-operations.md +414 -0
  113. package/skills/nstbrowser-ai-agent/references/nst-api-reference.md +960 -0
  114. package/skills/nstbrowser-ai-agent/references/profile-management.md +672 -0
  115. package/skills/nstbrowser-ai-agent/references/proxy-configuration.md +460 -0
  116. package/skills/nstbrowser-ai-agent/references/troubleshooting.md +773 -0
  117. package/skills/nstbrowser-ai-agent/templates/automated-workflow.sh +248 -0
  118. package/skills/nstbrowser-ai-agent/templates/batch-proxy-update.sh +257 -0
  119. package/skills/nstbrowser-ai-agent/templates/profile-setup.sh +248 -0
@@ -0,0 +1,759 @@
1
+ ---
2
+ name: nstbrowser-ai-agent
3
+ description: Browser automation CLI with Nstbrowser integration for AI agents. Use when the user needs advanced browser fingerprinting, profile management, proxy configuration, batch operations on multiple browser profiles, CDP connections, or cursor-based pagination for large datasets. Triggers include requests to "use NST profile", "configure proxy for profile", "manage browser profiles", "batch update profiles", "start multiple browsers", "connect to CDP", "list profiles with pagination", or any task requiring Nstbrowser's anti-detection features.
4
+ allowed-tools: Bash(npx nstbrowser-ai-agent:*), Bash(nstbrowser-ai-agent:*)
5
+ ---
6
+
7
+ # Browser Automation with nstbrowser-ai-agent (Nstbrowser Integration)
8
+
9
+ ## Overview
10
+
11
+ This skill enables AI agents to control browsers using nstbrowser-ai-agent CLI with Nstbrowser integration. Nstbrowser provides advanced browser fingerprinting, profile management, and anti-detection capabilities for professional browser automation.
12
+
13
+ **Key Features:**
14
+ - Advanced browser fingerprinting and anti-detection
15
+ - Profile management with persistent sessions
16
+ - Proxy configuration per profile
17
+ - Batch operations on multiple profiles
18
+ - Tag and group organization
19
+ - Local and cloud browser support
20
+
21
+ ## Core Concepts
22
+
23
+ ### Providers
24
+
25
+ - **nst (default)**: Uses Nstbrowser with profiles and fingerprinting
26
+ - **local**: Uses local Chromium browser (for testing without Nstbrowser)
27
+
28
+ ### Profiles
29
+
30
+ Nstbrowser profiles store:
31
+ - Browser fingerprints (canvas, WebGL, fonts, etc.)
32
+ - Cookies and localStorage
33
+ - Login sessions
34
+ - Proxy settings
35
+ - Browser configuration
36
+
37
+ ### Profile Name vs ID
38
+
39
+ All profile commands support both profile NAME and profile ID:
40
+
41
+ **Resolution Priority:**
42
+ 1. Explicit `--profile-id` flag (highest priority)
43
+ 2. Explicit `--profile` flag (profile name)
44
+ 3. `NST_PROFILE_ID` environment variable
45
+ 4. `NST_PROFILE` environment variable
46
+ 5. Temporary browser (if no profile specified)
47
+
48
+ **When to use:**
49
+ - **Profile Name**: More user-friendly, easier to remember
50
+ - **Profile ID**: Guaranteed uniqueness, better for scripts
51
+
52
+ ### Sticky Sessions
53
+
54
+ Once you start a session with a profile, that session "locks" to that browser instance. Subsequent commands automatically reuse the same browser without repeating the `--profile` flag.
55
+
56
+ ```bash
57
+ # First command: link session to profile
58
+ nstbrowser-ai-agent --profile my-profile open https://example.com
59
+
60
+ # Subsequent commands: Stays in 'my-profile' automatically
61
+ nstbrowser-ai-agent snapshot -i
62
+ nstbrowser-ai-agent click @e1
63
+ ```
64
+
65
+ ### Refs
66
+
67
+ Elements are identified by refs (e.g., @e1, @e2) from snapshots, making automation more reliable than CSS selectors.
68
+
69
+ ## Environment Setup
70
+
71
+ ### Configuration (Recommended)
72
+
73
+ Configure NST API credentials once using config commands:
74
+
75
+ ```bash
76
+ # Set API key (required) - stored in ~/.nst-ai-agent/config.json
77
+ nstbrowser-ai-agent config set key <your-api-key>
78
+
79
+ # Optional: Set custom host (default: 127.0.0.1)
80
+ nstbrowser-ai-agent config set host api.example.com
81
+
82
+ # Optional: Set custom port (default: 8848)
83
+ nstbrowser-ai-agent config set port 9000
84
+
85
+ # View configuration
86
+ nstbrowser-ai-agent config show
87
+
88
+ # Get specific value
89
+ nstbrowser-ai-agent config get key
90
+ ```
91
+
92
+ Configuration persists across sessions and takes priority over environment variables.
93
+
94
+ ### Environment Variables (Alternative)
95
+
96
+ ```bash
97
+ # Nstbrowser API credentials (required if not using config)
98
+ export NST_API_KEY="your-api-key"
99
+
100
+ # Optional: Nstbrowser API endpoint
101
+ export NST_HOST="localhost" # Default: 127.0.0.1
102
+ export NST_PORT="8848" # Default: 8848
103
+
104
+ # Optional: Default profile
105
+ export NST_PROFILE="my-profile-name"
106
+ # Or use profile ID
107
+ export NST_PROFILE_ID="profile-uuid"
108
+ ```
109
+
110
+ **Priority:** Config file > Environment variables > Defaults
111
+
112
+ ### Local Mode (No Nstbrowser)
113
+
114
+ ```bash
115
+ # Use local browser instead of Nstbrowser
116
+ export NSTBROWSER_AI_AGENT_LOCAL=1
117
+ # Or use --local flag
118
+ nstbrowser-ai-agent --local open https://example.com
119
+ ```
120
+
121
+ ## Profile Management Commands
122
+
123
+ ### List Profiles
124
+
125
+ ```bash
126
+ # List all profiles
127
+ nstbrowser-ai-agent profile list
128
+
129
+ # List with JSON output
130
+ nstbrowser-ai-agent profile list --json
131
+ ```
132
+
133
+
134
+ ### List Profiles with Cursor Pagination
135
+
136
+ ```bash
137
+ # List profiles with cursor-based pagination (for large datasets)
138
+ nstbrowser-ai-agent profile list-cursor --page-size 50
139
+
140
+ # Navigate to next page using cursor from previous response
141
+ nstbrowser-ai-agent profile list-cursor --cursor "next-page-token" --page-size 50
142
+
143
+ # More efficient than 'profile list' for large datasets (1000+ profiles)
144
+ ```
145
+ ### Show Profile Details
146
+
147
+ ```bash
148
+ # Show by profile name (recommended)
149
+ nstbrowser-ai-agent profile show my-profile --json
150
+
151
+ # Show by profile ID
152
+ nstbrowser-ai-agent profile show 86581051-fb0d-4c4a-b1e3-ebc1abd17174 --json
153
+ ```
154
+
155
+ Returns complete profile information including fingerprint, proxy, tags, groups, and launch history.
156
+
157
+ ### Create Profile
158
+
159
+ ```bash
160
+ nstbrowser-ai-agent profile create <name> \
161
+ --proxy-host <host> \
162
+ --proxy-port <port> \
163
+ --proxy-type <http|https|socks5> \
164
+ --proxy-username <user> \
165
+ --proxy-password <pass> \
166
+ --platform <Windows|macOS|Linux> \
167
+ --kernel <version> \
168
+ --group-id <group-id>
169
+ ```
170
+
171
+ ### Delete Profile
172
+
173
+ ```bash
174
+ # Delete single profile
175
+ nstbrowser-ai-agent profile delete <profile-id>
176
+
177
+ # Delete multiple profiles (batch)
178
+ nstbrowser-ai-agent profile delete <id-1> <id-2> <id-3>
179
+ ```
180
+
181
+ ### Profile Groups
182
+
183
+ ```bash
184
+ # List all groups
185
+ nstbrowser-ai-agent profile groups list
186
+
187
+ # Move profile(s) to group
188
+ nstbrowser-ai-agent profile groups change <group-id> <profile-id> [profile-id...]
189
+
190
+ # Batch move profiles to group
191
+ nstbrowser-ai-agent profile groups batch-change <group-id> <id-1> <id-2> <id-3>
192
+ ```
193
+
194
+ ## Proxy Management Commands
195
+
196
+ ### Show Proxy Configuration
197
+
198
+ ```bash
199
+ # Show by profile name or ID
200
+ nstbrowser-ai-agent profile proxy show <name-or-id> --json
201
+ ```
202
+
203
+ Returns proxy configuration and check result (IP, location, timezone).
204
+
205
+ ### Update Proxy
206
+
207
+ ```bash
208
+ # Update proxy for single profile (supports name or ID)
209
+ nstbrowser-ai-agent profile proxy update <name-or-id> \
210
+ --host proxy.example.com \
211
+ --port 8080 \
212
+ --type http \
213
+ --username user \
214
+ --password pass
215
+ ```
216
+
217
+ ### Reset Proxy
218
+
219
+ ```bash
220
+ # Reset single profile
221
+ nstbrowser-ai-agent profile proxy reset <profile-id>
222
+
223
+ # Reset multiple profiles (batch)
224
+ nstbrowser-ai-agent profile proxy reset <id-1> <id-2> <id-3>
225
+ ```
226
+
227
+ ### Batch Proxy Operations
228
+
229
+ ```bash
230
+ # Batch update proxy for multiple profiles
231
+ nstbrowser-ai-agent profile proxy batch-update \
232
+ <id-1> <id-2> <id-3> \
233
+ --host proxy.example.com \
234
+ --port 8080 \
235
+ --type http \
236
+ --username user \
237
+ --password pass
238
+
239
+ # Batch reset proxy for multiple profiles
240
+ nstbrowser-ai-agent profile proxy batch-reset <id-1> <id-2> <id-3>
241
+ ```
242
+
243
+ ## Tag Management Commands
244
+
245
+ ### List Tags
246
+
247
+ ```bash
248
+ nstbrowser-ai-agent profile tags list
249
+ ```
250
+
251
+ ### Create Tags
252
+
253
+ ```bash
254
+ # Add single tag to profile
255
+ nstbrowser-ai-agent profile tags create <profile-id> <tag-name>
256
+ ```
257
+
258
+ ### Update Tags
259
+
260
+ ```bash
261
+ # Update tags with colors (replaces existing tags)
262
+ nstbrowser-ai-agent profile tags update <profile-id> \
263
+ production:blue testing:green staging:yellow
264
+
265
+ # Update tags without colors
266
+ nstbrowser-ai-agent profile tags update <profile-id> \
267
+ production testing staging
268
+ ```
269
+
270
+ Tag format: `tag-name:color` or just `tag-name`
271
+
272
+ ### Clear Tags
273
+
274
+ ```bash
275
+ # Clear single profile
276
+ nstbrowser-ai-agent profile tags clear <profile-id>
277
+
278
+ # Clear multiple profiles (batch)
279
+ nstbrowser-ai-agent profile tags clear <id-1> <id-2> <id-3>
280
+ ```
281
+
282
+ ### Batch Tag Operations
283
+
284
+ ```bash
285
+ # Batch create tags for multiple profiles
286
+ nstbrowser-ai-agent profile tags batch-create \
287
+ <id-1> <id-2> \
288
+ production:blue automated:green
289
+
290
+ # Batch update tags (replaces existing)
291
+ nstbrowser-ai-agent profile tags batch-update \
292
+ <id-1> <id-2> \
293
+ updated:red verified:green
294
+
295
+ # Batch clear tags
296
+ nstbrowser-ai-agent profile tags batch-clear <id-1> <id-2> <id-3>
297
+ ```
298
+
299
+ ## Browser Instance Management
300
+
301
+ ### List Running Browsers
302
+
303
+ ```bash
304
+ nstbrowser-ai-agent browser list
305
+ ```
306
+
307
+ ### Start Browser
308
+
309
+ Profiles can be referenced by name or ID. The system automatically detects UUID patterns:
310
+
311
+ ```bash
312
+ # Start by profile name
313
+ nstbrowser-ai-agent browser start my-profile
314
+ nstbrowser-ai-agent browser start proxy_ph
315
+
316
+ # Start by profile ID (UUID format auto-detected)
317
+ nstbrowser-ai-agent browser start 86581051-fb0d-4c4a-b1e3-ebc1abd17174
318
+ nstbrowser-ai-agent browser start ef2b083a-8f77-4a7f-8441-a8d56bbd832b
319
+
320
+ # Both work the same way - the --profile flag automatically detects the format
321
+ # No need to use --profile-id explicitly (though it still works for backward compatibility)
322
+
323
+ # Start with options
324
+ nstbrowser-ai-agent browser start <name-or-id> \
325
+ --headless \
326
+ --auto-close \
327
+ --disable-gpu
328
+ ```
329
+
330
+
331
+ ### Start Multiple Browsers (Batch)
332
+
333
+ ```bash
334
+ # Start multiple browsers simultaneously (by name or ID)
335
+ nstbrowser-ai-agent browser start-batch profile-1 profile-2 profile-3
336
+ nstbrowser-ai-agent browser start-batch proxy_ph ef2b083a-8f77-4a7f-8441-a8d56bbd832b
337
+
338
+ # Each browser runs independently with its own profile and fingerprint
339
+ # Useful for parallel scraping, testing, or automation tasks
340
+ ```
341
+
342
+ ### Start Temporary Browser
343
+
344
+ ```bash
345
+ # Start temporary browser without profile (for one-time use)
346
+ nstbrowser-ai-agent browser start-once
347
+
348
+ # Use for quick tests or disposable sessions
349
+ # Browser is automatically cleaned up after use
350
+ ```
351
+
352
+ ### Stop Browser
353
+
354
+ ```bash
355
+ # Stop by profile name or ID
356
+ nstbrowser-ai-agent browser stop <name-or-id>
357
+
358
+ # Stop all browsers
359
+ nstbrowser-ai-agent browser stop-all
360
+ ```
361
+
362
+ ### Get Browser Pages
363
+
364
+ ```bash
365
+ # Get list of pages/tabs in running browser
366
+ nstbrowser-ai-agent browser pages <name-or-id> --json
367
+ ```
368
+
369
+ Returns list of all pages/tabs with URLs and titles.
370
+
371
+ ### Get Debugger URL
372
+
373
+ ```bash
374
+ # Get Chrome DevTools debugger URL
375
+ nstbrowser-ai-agent browser debugger <name-or-id> --json
376
+ ```
377
+
378
+ Returns WebSocket URL for connecting Chrome DevTools.
379
+
380
+ ## Local Data Management
381
+
382
+ ### Clear Cache
383
+
384
+ ```bash
385
+ # Clear cache for single profile
386
+ nstbrowser-ai-agent profile cache clear <profile-id>
387
+
388
+ # Clear cache for multiple profiles (batch)
389
+ nstbrowser-ai-agent profile cache clear <id-1> <id-2> <id-3>
390
+ ```
391
+
392
+ ### Clear Cookies
393
+
394
+ ```bash
395
+ # Clear cookies for single profile
396
+ nstbrowser-ai-agent profile cookies clear <profile-id>
397
+
398
+ # Clear cookies for multiple profiles (batch)
399
+ nstbrowser-ai-agent profile cookies clear <id-1> <id-2> <id-3>
400
+ ```
401
+
402
+ ## Browser Automation Commands
403
+
404
+ ### Navigation
405
+
406
+ ```bash
407
+ # Open URL (auto-launches browser if not running)
408
+ nstbrowser-ai-agent open <url>
409
+
410
+ # Navigate back/forward
411
+ nstbrowser-ai-agent back
412
+ nstbrowser-ai-agent forward
413
+ nstbrowser-ai-agent reload
414
+ ```
415
+
416
+ ### Page Inspection
417
+
418
+ ```bash
419
+ # Get accessibility snapshot with refs (best for AI)
420
+ nstbrowser-ai-agent snapshot -i
421
+
422
+ # Get page title
423
+ nstbrowser-ai-agent get title
424
+
425
+ # Get current URL
426
+ nstbrowser-ai-agent get url
427
+
428
+ # Take screenshot
429
+ nstbrowser-ai-agent screenshot <path>
430
+
431
+ # Annotated screenshot with element labels
432
+ nstbrowser-ai-agent screenshot --annotate <path>
433
+ ```
434
+
435
+ ### Element Interaction
436
+
437
+ ```bash
438
+ # Click element by ref
439
+ nstbrowser-ai-agent click @e1
440
+
441
+ # Fill input by ref
442
+ nstbrowser-ai-agent fill @e2 "text"
443
+
444
+ # Type into element
445
+ nstbrowser-ai-agent type @e3 "text"
446
+
447
+ # Get element text
448
+ nstbrowser-ai-agent get text @e4
449
+
450
+ # Check if element is visible
451
+ nstbrowser-ai-agent is visible @e5
452
+ ```
453
+
454
+ ### JavaScript Execution
455
+
456
+ ```bash
457
+ # Execute JavaScript
458
+ nstbrowser-ai-agent eval "document.title"
459
+
460
+ # Execute with stdin
461
+ echo "document.querySelectorAll('a').length" | nstbrowser-ai-agent eval --stdin
462
+ ```
463
+
464
+ ### Wait Commands
465
+
466
+ ```bash
467
+ # Wait for element
468
+ nstbrowser-ai-agent wait <selector>
469
+
470
+ # Wait for time (milliseconds)
471
+ nstbrowser-ai-agent wait 3000
472
+
473
+ # Wait for page load
474
+ nstbrowser-ai-agent wait --load networkidle
475
+ ```
476
+
477
+ ### Close Browser
478
+
479
+ ```bash
480
+ nstbrowser-ai-agent close
481
+ ```
482
+
483
+ ## Workflow Patterns
484
+
485
+ ### Pattern 1: Profile-based Automation (Using Profile Name)
486
+
487
+ ```bash
488
+ # 1. Set API key
489
+ export NST_API_KEY="your-key"
490
+
491
+ # 2. List profiles to find target
492
+ nstbrowser-ai-agent profile list
493
+
494
+ # 3. Set profile by name (RECOMMENDED)
495
+ export NST_PROFILE="my-profile"
496
+
497
+ # 4. Open browser (auto-uses profile, auto-starts if not running)
498
+ nstbrowser-ai-agent open https://example.com
499
+
500
+ # 5. Get snapshot
501
+ nstbrowser-ai-agent snapshot -i
502
+
503
+ # 6. Interact with page
504
+ nstbrowser-ai-agent click @e1
505
+ nstbrowser-ai-agent fill @e2 "data"
506
+
507
+ # 7. Close (session saved to profile)
508
+ nstbrowser-ai-agent close
509
+ ```
510
+
511
+ ### Pattern 2: Batch Profile Management
512
+
513
+ ```bash
514
+ # Get multiple profile IDs
515
+ PROFILE_IDS=$(nstbrowser-ai-agent profile list --json | jq -r '.data.profiles[0:3] | map(.profileId) | join(" ")')
516
+
517
+ # Batch update proxy
518
+ nstbrowser-ai-agent profile proxy batch-update $PROFILE_IDS \
519
+ --host proxy.example.com \
520
+ --port 8080 \
521
+ --type http
522
+
523
+ # Batch add tags
524
+ nstbrowser-ai-agent profile tags batch-create $PROFILE_IDS \
525
+ automated:blue batch-updated:green
526
+
527
+ # Batch move to group
528
+ GROUP_ID=$(nstbrowser-ai-agent profile groups list --json | jq -r '.data.groups[0].groupId')
529
+ nstbrowser-ai-agent profile groups batch-change $GROUP_ID $PROFILE_IDS
530
+ ```
531
+
532
+ ### Pattern 3: Parallel Tasks (Isolation)
533
+
534
+ ```bash
535
+ # Task 1 in browser A
536
+ nstbrowser-ai-agent --session task-a --profile profile-1 open site1.com
537
+
538
+ # Task 2 in browser B (Parallel)
539
+ nstbrowser-ai-agent --session task-b --profile profile-2 open site2.com
540
+
541
+ # Interact with Task A without affecting Task B
542
+ nstbrowser-ai-agent --session task-a click @e1
543
+ ```
544
+
545
+ ### Pattern 4: Login and Scrape
546
+
547
+ ```bash
548
+ # 1. Open login page
549
+ nstbrowser-ai-agent open https://site.com/login
550
+
551
+ # 2. Wait for page to load
552
+ nstbrowser-ai-agent wait --load networkidle
553
+
554
+ # 3. Fill and submit using CSS selectors
555
+ nstbrowser-ai-agent fill 'input[placeholder="Email"]' "username"
556
+ nstbrowser-ai-agent fill 'input[type="password"]' "password"
557
+ nstbrowser-ai-agent click 'button[type="submit"]'
558
+
559
+ # 4. Wait for navigation
560
+ nstbrowser-ai-agent wait --load networkidle
561
+
562
+ # 5. Navigate to target page
563
+ nstbrowser-ai-agent open https://site.com/data
564
+
565
+ # 6. Extract data
566
+ nstbrowser-ai-agent snapshot -i > data.txt
567
+ nstbrowser-ai-agent eval "document.querySelector('.info')?.textContent"
568
+
569
+ # 7. Close (session saved to profile)
570
+ nstbrowser-ai-agent close
571
+ ```
572
+
573
+ ## Best Practices
574
+
575
+ 1. **Use Profile Names**: More readable than IDs for most use cases
576
+ 2. **Set Environment Variables**: Use `NST_PROFILE` for consistent profile usage
577
+ 3. **Leverage Sticky Sessions**: No need to repeat `--profile` flag
578
+ 4. **Use Batch Operations**: More efficient for multiple profiles
579
+ 5. **Organize with Groups and Tags**: Keep profiles organized
580
+ 6. **Prefer CSS Selectors for Modern Apps**: Refs may not work with Vue/React/Angular
581
+ 7. **Wait Appropriately**: Use `wait --load networkidle` after navigation
582
+ 8. **Close Cleanly**: Always close browser to save session state
583
+ 9. **Handle Errors**: Check command output and retry if needed
584
+ 10. **Use Proxies Per Profile**: Configure proxies for geo-targeting or privacy
585
+
586
+ ## JSON Output
587
+
588
+ All commands support `--json` flag for machine-readable output:
589
+
590
+ ```bash
591
+ nstbrowser-ai-agent profile list --json
592
+ nstbrowser-ai-agent snapshot -i --json
593
+ nstbrowser-ai-agent get text @e1 --json
594
+ ```
595
+
596
+ ## Error Handling
597
+
598
+ ### Common Issues
599
+
600
+ **"NST_API_KEY is required"**
601
+ - Solution: Set `export NST_API_KEY="your-key"`
602
+
603
+ **"Failed to connect to Nstbrowser"**
604
+ - Solution: Ensure Nstbrowser client is running
605
+ - Check: `curl http://localhost:8848/api/v2/profiles`
606
+
607
+ **"Profile not found"**
608
+ - Solution: List profiles with `nstbrowser-ai-agent profile list`
609
+ - Verify profile name/ID
610
+
611
+ **"Element not found" or "Action timed out"**
612
+ - Solution: Get fresh snapshot with `nstbrowser-ai-agent snapshot -i`
613
+ - Try using CSS selectors instead of refs
614
+
615
+ ### Ref System Limitations
616
+
617
+ The ref system (`@e1`, `@e2`, etc.) may not work reliably with modern web frameworks (Vue.js, React, Angular).
618
+
619
+ **Workaround - Use CSS Selectors:**
620
+
621
+ ```bash
622
+ # 1. Inspect page elements
623
+ nstbrowser-ai-agent eval "Array.from(document.querySelectorAll('input')).map(el => ({type: el.type, placeholder: el.placeholder}))"
624
+
625
+ # 2. Use CSS selectors directly
626
+ nstbrowser-ai-agent fill 'input[placeholder="Email"]' "user@example.com"
627
+ nstbrowser-ai-agent fill 'input[type="password"]' "password"
628
+ nstbrowser-ai-agent click 'button[type="submit"]'
629
+ ```
630
+
631
+ ## Command Reference
632
+
633
+ ### Profile Commands
634
+ - `profile list` - List all profiles
635
+ - `profile show <name-or-id>` - Show profile details
636
+ - `profile create <name>` - Create new profile
637
+ - `profile delete <id> [id...]` - Delete profile(s)
638
+ - `profile groups list` - List all groups
639
+ - `profile groups change <group-id> <profile-id> [profile-id...]` - Move profile(s) to group
640
+ - `profile groups batch-change <group-id> <id> [id...]` - Batch change group
641
+
642
+ ### Proxy Commands
643
+ - `profile proxy show <name-or-id>` - Show proxy configuration
644
+ - `profile proxy update <name-or-id>` - Update proxy settings
645
+ - `profile proxy reset <id> [id...]` - Reset proxy settings
646
+ - `profile proxy batch-update <id> [id...] --host --port` - Batch update proxy
647
+ - `profile proxy batch-reset <id> [id...]` - Batch reset proxy
648
+
649
+ ### Tag Commands
650
+ - `profile tags list` - List all tags
651
+ - `profile tags create <id> <tag>` - Add tag to profile
652
+ - `profile tags update <id> <tag:color> [tag:color...]` - Update profile tags
653
+ - `profile tags clear <id> [id...]` - Clear profile tags
654
+ - `profile tags batch-create <id> [id...] <tag:color>` - Batch create tags
655
+ - `profile tags batch-update <id> [id...] <tag:color>` - Batch update tags
656
+ - `profile tags batch-clear <id> [id...]` - Batch clear tags
657
+
658
+ ### Browser Commands
659
+ - `browser list` - List running browsers
660
+ - `browser start <name-or-id>` - Start browser
661
+ - `browser stop <name-or-id>` - Stop browser
662
+ - `browser stop-all` - Stop all browsers
663
+ - `browser pages <name-or-id>` - Get browser pages list
664
+ - `browser debugger <name-or-id>` - Get debugger URL
665
+
666
+ ### Local Data Commands
667
+ - `profile cache clear <id> [id...]` - Clear profile cache
668
+ - `profile cookies clear <id> [id...]` - Clear profile cookies
669
+
670
+ ### Navigation Commands
671
+ - `open <url>` - Navigate to URL
672
+ - `back` - Go back
673
+ - `forward` - Go forward
674
+ - `reload` - Reload page
675
+
676
+ ### Inspection Commands
677
+ - `snapshot [-i] [-c] [-d <depth>]` - Get page snapshot
678
+ - `get title` - Get page title
679
+ - `get url` - Get current URL
680
+ - `get text <sel>` - Get element text
681
+ - `screenshot [path]` - Take screenshot
682
+
683
+ ### Interaction Commands
684
+ - `click <sel>` - Click element
685
+ - `fill <sel> <text>` - Fill input
686
+ - `type <sel> <text>` - Type into element
687
+ - `press <key>` - Press key
688
+ - `wait <sel|ms>` - Wait for element or time
689
+
690
+ ### Utility Commands
691
+ - `eval <js>` - Execute JavaScript
692
+ - `close` - Close browser
693
+ - `session list` - List active sessions
694
+
695
+ ## Deep-Dive Documentation
696
+
697
+ | Reference | When to Use |
698
+ |-----------|-------------|
699
+ | [references/nst-api-reference.md](references/nst-api-reference.md) | Complete NST API reference with all commands |
700
+ | [references/profile-management.md](references/profile-management.md) | Profile creation, organization, and lifecycle |
701
+ | [references/proxy-configuration.md](references/proxy-configuration.md) | Proxy setup, testing, and troubleshooting |
702
+ | [references/batch-operations.md](references/batch-operations.md) | Efficient batch operations on multiple profiles |
703
+ | [references/troubleshooting.md](references/troubleshooting.md) | Common issues and diagnostic commands |
704
+
705
+ ## Ready-to-Use Templates
706
+
707
+ | Template | Description |
708
+ |----------|-------------|
709
+ | [templates/profile-setup.sh](templates/profile-setup.sh) | Profile initialization with proxy and tags |
710
+ | [templates/batch-proxy-update.sh](templates/batch-proxy-update.sh) | Batch proxy update for multiple profiles |
711
+ | [templates/automated-workflow.sh](templates/automated-workflow.sh) | Complete automation workflow example |
712
+
713
+ ```bash
714
+ ./templates/profile-setup.sh my-profile --proxy-host proxy.com --proxy-port 8080
715
+ ./templates/batch-proxy-update.sh "id1 id2 id3" --proxy-host proxy.com --proxy-port 8080
716
+ ./templates/automated-workflow.sh my-profile https://example.com
717
+ ```
718
+
719
+ ## Notes
720
+
721
+ - Nstbrowser is the **default provider** (no `-p nst` flag needed)
722
+ - **Profile name/ID support**: All commands accept both names and IDs
723
+ - **Auto-start**: Browser automatically starts when using profile name if not running
724
+ - **Name resolution**: Profile names are resolved to IDs automatically via API
725
+ - **Sticky sessions**: Profile persists across commands in the same session
726
+ - Profiles are managed by Nstbrowser client, not the CLI
727
+ - Daemon auto-starts on first command and persists between commands
728
+ - Use `--local` flag for local browser mode (no Nstbrowser required)
729
+ - Session state is automatically saved to profiles when browser closes
730
+
731
+ ### Get CDP WebSocket URL
732
+
733
+ ```bash
734
+ # Get CDP URL for existing browser instance
735
+ nstbrowser-ai-agent browser cdp-url <name-or-id>
736
+
737
+ # Get CDP URL for temporary browser
738
+ nstbrowser-ai-agent browser cdp-url-once
739
+ ```
740
+
741
+ Returns WebSocket URL that can be used to connect Chrome DevTools, Puppeteer, Playwright, or other CDP-compatible tools.
742
+
743
+ ### Connect to Browser and Get CDP URL
744
+
745
+ ```bash
746
+ # Connect to browser (starts if not running) and get CDP URL
747
+ nstbrowser-ai-agent browser connect <name-or-id>
748
+
749
+ # Connect to temporary browser and get CDP URL
750
+ nstbrowser-ai-agent browser connect-once
751
+ ```
752
+
753
+ These commands start the browser if it's not already running, then return the CDP WebSocket URL.
754
+
755
+ **Use cases:**
756
+ - Connect Puppeteer/Playwright to Nstbrowser-managed browsers
757
+ - Attach Chrome DevTools for debugging
758
+ - Integrate with custom CDP-based automation tools
759
+ - Monitor browser activity with external tools