nstbrowser-ai-agent 0.0.13 → 0.0.14

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 (38) hide show
  1. package/README.md +187 -415
  2. package/bin/nstbrowser-ai-agent-darwin-arm64 +0 -0
  3. package/bin/nstbrowser-ai-agent-darwin-x64 +0 -0
  4. package/bin/nstbrowser-ai-agent-linux-arm64 +0 -0
  5. package/bin/nstbrowser-ai-agent-linux-x64 +0 -0
  6. package/bin/nstbrowser-ai-agent-win32-x64.exe +0 -0
  7. package/dist/actions.js +14 -1
  8. package/dist/actions.js.map +1 -1
  9. package/dist/browser-profile-resolver.d.ts +9 -0
  10. package/dist/browser-profile-resolver.d.ts.map +1 -1
  11. package/dist/browser-profile-resolver.js +24 -3
  12. package/dist/browser-profile-resolver.js.map +1 -1
  13. package/dist/browser.d.ts +6 -0
  14. package/dist/browser.d.ts.map +1 -1
  15. package/dist/browser.js +25 -2
  16. package/dist/browser.js.map +1 -1
  17. package/dist/constants.d.ts +1 -0
  18. package/dist/constants.d.ts.map +1 -1
  19. package/dist/constants.js +1 -0
  20. package/dist/constants.js.map +1 -1
  21. package/dist/daemon.d.ts.map +1 -1
  22. package/dist/daemon.js +5 -2
  23. package/dist/daemon.js.map +1 -1
  24. package/dist/nstbrowser-actions.js +59 -34
  25. package/dist/nstbrowser-actions.js.map +1 -1
  26. package/dist/nstbrowser-client.d.ts.map +1 -1
  27. package/dist/nstbrowser-client.js +34 -11
  28. package/dist/nstbrowser-client.js.map +1 -1
  29. package/dist/nstbrowser-types.d.ts +1 -0
  30. package/dist/nstbrowser-types.d.ts.map +1 -1
  31. package/dist/protocol.d.ts.map +1 -1
  32. package/dist/protocol.js +31 -2
  33. package/dist/protocol.js.map +1 -1
  34. package/dist/version.d.ts +1 -1
  35. package/dist/version.js +1 -1
  36. package/package.json +1 -1
  37. package/skills/nstbrowser-ai-agent/SKILL.md +175 -335
  38. package/skills/nstbrowser-ai-agent/skill.json +1 -1
@@ -1,403 +1,243 @@
1
1
  ---
2
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, 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", "list profiles with pagination", or any task requiring Nstbrowser's anti-detection features.
3
+ description: Browser automation CLI for Nstbrowser profiles. Use when the user needs Nstbrowser profile management, temporary browsers, proxy-aware automation, or browser actions that must run through the Nstbrowser desktop client.
4
4
  allowed-tools: Bash(npx nstbrowser-ai-agent:*), Bash(nstbrowser-ai-agent:*)
5
5
  ---
6
6
 
7
- # nstbrowser-ai-agent - Quick Reference
7
+ # nstbrowser-ai-agent
8
8
 
9
- ## Prerequisites
9
+ This skill is for the **Nstbrowser** workflow.
10
10
 
11
- **Required**: Nstbrowser desktop client must be installed and running
12
- - Download: https://www.nstbrowser.io/
13
- - Start the desktop application
14
- - Obtain API key from dashboard
11
+ ## Default Operating Mode
15
12
 
16
- ## Quick Setup
13
+ Use a **known-good Nstbrowser profile** and repeat the same `--profile <name-or-id>` on every browser command.
17
14
 
18
- ```bash
19
- # 1. Configure API key (required)
20
- nstbrowser-ai-agent config set key YOUR_API_KEY
15
+ - This is the safest default for AI agents.
16
+ - Only introduce `--session` when the task truly needs an isolated multi-step workflow.
17
+ - In one daemon session, `--profile twitter1` must switch to `twitter1`; do not assume the previous profile remains active.
18
+ - Do not assume refs such as `@e1` will keep working after navigation or across a different session.
21
19
 
22
- # 2. Verify connection
23
- nstbrowser-ai-agent profile list
20
+ ## Prerequisites
24
21
 
25
- # 3. Ready to use!
26
- ```
22
+ - Nstbrowser desktop client is installed and running
23
+ - API key is configured with `nstbrowser-ai-agent config set key YOUR_API_KEY` or `NST_API_KEY`
24
+ - NST service is reachable at `http://127.0.0.1:8848` unless the user configured a different host/port
27
25
 
28
- ## Core Commands
26
+ ## First Checks
29
27
 
30
- ### Configuration
31
- ```bash
32
- nstbrowser-ai-agent config set key YOUR_KEY # Set API key
33
- nstbrowser-ai-agent config show # Show current config
34
- ```
28
+ Run these first when the environment may be unconfigured:
35
29
 
36
- ### Diagnostics & Troubleshooting
37
30
  ```bash
38
- nstbrowser-ai-agent diagnose # Run comprehensive environment check
39
- nstbrowser-ai-agent verify [--profile <name-or-id>] # Test browser functionality
40
- nstbrowser-ai-agent repair # Attempt automatic fixes
31
+ nstbrowser-ai-agent nst status
32
+ nstbrowser-ai-agent profile list
33
+ nstbrowser-ai-agent --version
41
34
  ```
42
35
 
43
- ### Profile Management (NST)
44
- ```bash
45
- nstbrowser-ai-agent profile list # List all profiles
46
- nstbrowser-ai-agent profile create <name> # Create new profile
47
- nstbrowser-ai-agent profile delete <id> # Delete profile
48
- nstbrowser-ai-agent profile proxy update <id> # Update proxy settings
49
- nstbrowser-ai-agent profile tags create <id> <tag> # Add tags to profile
50
- nstbrowser-ai-agent profile cache clear <id> # Clear profile cache
51
- ```
36
+ ## Fast Path
37
+
38
+ Use this path unless the user explicitly asks for something more specialized:
52
39
 
53
- ### Browser Control (NST)
54
40
  ```bash
55
- nstbrowser-ai-agent browser start-once # Start temporary browser
56
- nstbrowser-ai-agent browser list # List running browsers
57
- nstbrowser-ai-agent browser stop <id> # Stop browser
58
- nstbrowser-ai-agent browser start <profile-id> # Start browser for profile
59
- nstbrowser-ai-agent browser stop-all # Stop all browsers
41
+ nstbrowser-ai-agent nst status
42
+ nstbrowser-ai-agent profile list
43
+ nstbrowser-ai-agent verify --profile YOUR_PROFILE
44
+ nstbrowser-ai-agent --profile YOUR_PROFILE open https://example.com
45
+ nstbrowser-ai-agent --profile YOUR_PROFILE snapshot -i
46
+ nstbrowser-ai-agent --profile YOUR_PROFILE click @e1
47
+ nstbrowser-ai-agent --profile YOUR_PROFILE get url
48
+ nstbrowser-ai-agent --profile YOUR_PROFILE screenshot --annotate /tmp/page.png
60
49
  ```
61
50
 
62
- ### Page Interaction
63
- All browser action commands support `[--profile <name-or-id>]` to specify which profile to use.
51
+ Replace `YOUR_PROFILE` with a profile from `profile list`.
64
52
 
65
- ```bash
66
- nstbrowser-ai-agent open <url> [--profile <name-or-id>] # Navigate to URL
67
- nstbrowser-ai-agent snapshot -i [--profile <name-or-id>] # Get interactive elements with refs
68
- nstbrowser-ai-agent click @e1 [--profile <name-or-id>] # Click element by ref
69
- nstbrowser-ai-agent click @e1 --new-tab [--profile <name-or-id>] # Click and open in new tab
70
- nstbrowser-ai-agent fill @e2 "text" [--profile <name-or-id>] # Fill input field
71
- nstbrowser-ai-agent type @e2 "text" [--profile <name-or-id>] # Type into element
72
- nstbrowser-ai-agent hover @e3 [--profile <name-or-id>] # Hover over element
73
- nstbrowser-ai-agent focus @e4 [--profile <name-or-id>] # Focus element
74
- nstbrowser-ai-agent check @e5 [--profile <name-or-id>] # Check checkbox
75
- nstbrowser-ai-agent uncheck @e6 [--profile <name-or-id>] # Uncheck checkbox
76
- nstbrowser-ai-agent select @e7 "value" [--profile <name-or-id>] # Select dropdown option
77
- nstbrowser-ai-agent drag @e8 @e9 [--profile <name-or-id>] # Drag and drop
78
- nstbrowser-ai-agent upload @e10 ./file.pdf [--profile <name-or-id>] # Upload files
79
- nstbrowser-ai-agent download @e11 ./file.pdf [--profile <name-or-id>] # Download file
80
- ```
53
+ If you do not have a clean profile yet:
81
54
 
82
- ### Navigation & Waiting
83
55
  ```bash
84
- nstbrowser-ai-agent back [--profile <name-or-id>] # Go back
85
- nstbrowser-ai-agent forward [--profile <name-or-id>] # Go forward
86
- nstbrowser-ai-agent reload [--profile <name-or-id>] # Reload page
87
- nstbrowser-ai-agent wait @e1 [--profile <name-or-id>] # Wait for element
88
- nstbrowser-ai-agent wait 2000 [--profile <name-or-id>] # Wait milliseconds
89
- nstbrowser-ai-agent wait --load networkidle [--profile <name-or-id>] # Wait for load state
90
- nstbrowser-ai-agent wait --url "**/dashboard" [--profile <name-or-id>] # Wait for URL pattern
91
- nstbrowser-ai-agent wait --text "Welcome" [--profile <name-or-id>] # Wait for text
92
- nstbrowser-ai-agent wait --download ./file.pdf [--profile <name-or-id>] # Wait for download
56
+ nstbrowser-ai-agent profile create task-profile
57
+ nstbrowser-ai-agent --profile task-profile open https://example.com
93
58
  ```
94
59
 
95
- ### Keyboard & Mouse
96
- ```bash
97
- nstbrowser-ai-agent press Enter [--profile <name-or-id>] # Press key
98
- nstbrowser-ai-agent press Control+a [--profile <name-or-id>] # Key combination
99
- nstbrowser-ai-agent keyboard type "Hello" [--profile <name-or-id>] # Type without selector
100
- nstbrowser-ai-agent keyboard inserttext "text" [--profile <name-or-id>] # Insert text
101
- nstbrowser-ai-agent mouse move 100 200 [--profile <name-or-id>] # Move mouse
102
- nstbrowser-ai-agent mouse click [--profile <name-or-id>] # Mouse click
103
- nstbrowser-ai-agent scroll down 500 [--profile <name-or-id>] # Scroll page
104
- nstbrowser-ai-agent scrollintoview @e1 [--profile <name-or-id>] # Scroll element into view
105
- ```
60
+ ## Core NST Commands
106
61
 
107
- ### Data Extraction
108
- ```bash
109
- nstbrowser-ai-agent get title [--profile <name-or-id>] # Get page title
110
- nstbrowser-ai-agent get url [--profile <name-or-id>] # Get current URL
111
- nstbrowser-ai-agent get text @e1 [--profile <name-or-id>] # Get element text
112
- nstbrowser-ai-agent get html @e2 [--profile <name-or-id>] # Get element HTML
113
- nstbrowser-ai-agent get value @e3 [--profile <name-or-id>] # Get input value
114
- nstbrowser-ai-agent get attr @e4 href [--profile <name-or-id>] # Get attribute
115
- nstbrowser-ai-agent get count "li.item" [--profile <name-or-id>] # Count elements
116
- nstbrowser-ai-agent get box @e5 [--profile <name-or-id>] # Get bounding box
117
- nstbrowser-ai-agent get styles @e6 [--profile <name-or-id>] # Get computed styles
118
- nstbrowser-ai-agent eval "document.title" [--profile <name-or-id>] # Execute JavaScript
119
- ```
62
+ ### Configuration
120
63
 
121
- ### Element State Checking
122
64
  ```bash
123
- nstbrowser-ai-agent is visible @e1 [--profile <name-or-id>] # Check if visible
124
- nstbrowser-ai-agent is enabled @e2 [--profile <name-or-id>] # Check if enabled
125
- nstbrowser-ai-agent is checked @e3 [--profile <name-or-id>] # Check if checked
65
+ nstbrowser-ai-agent config set key YOUR_API_KEY
66
+ nstbrowser-ai-agent config show
67
+ nstbrowser-ai-agent config get key
126
68
  ```
127
69
 
128
- ### Semantic Element Finding
129
- ```bash
130
- nstbrowser-ai-agent find role button click --name Submit
131
- nstbrowser-ai-agent find text "Sign In" click
132
- nstbrowser-ai-agent find label "Email" fill "user@example.com"
133
- nstbrowser-ai-agent find placeholder "Search..." type "query"
134
- nstbrowser-ai-agent find testid "login-form" click
135
- nstbrowser-ai-agent find first "li.item" click
136
- nstbrowser-ai-agent find nth 2 ".card" hover
137
- ```
70
+ ### Diagnostics
71
+
72
+ Use only the forms below:
138
73
 
139
- ### Screenshots & Recording
140
74
  ```bash
141
- nstbrowser-ai-agent screenshot [path] # Take screenshot
142
- nstbrowser-ai-agent screenshot --full # Full page screenshot
143
- nstbrowser-ai-agent screenshot --annotate # Annotated with element refs
144
- nstbrowser-ai-agent pdf ./page.pdf # Save as PDF
145
- nstbrowser-ai-agent record start ./demo.webm # Start video recording
146
- nstbrowser-ai-agent record stop # Stop recording
75
+ nstbrowser-ai-agent nst status
76
+ nstbrowser-ai-agent profile list
77
+ nstbrowser-ai-agent verify YOUR_PROFILE
78
+ nstbrowser-ai-agent verify --profile YOUR_PROFILE
79
+ nstbrowser-ai-agent repair
147
80
  ```
148
81
 
149
- ## Quick Start Workflows
82
+ ### Profile Management
150
83
 
151
- ### Workflow 1: Temporary Browser (No Profile)
152
- ```bash
153
- # Start temporary browser and navigate
154
- nstbrowser-ai-agent browser start-once
155
- nstbrowser-ai-agent open https://example.com
156
- nstbrowser-ai-agent snapshot -i
157
- nstbrowser-ai-agent click @e1
158
- nstbrowser-ai-agent close
159
- ```
84
+ - `profile list`
85
+ Use when you need a fast human-readable list of candidate profiles.
86
+ Important parameter: `--verbose` returns the full NST profile object instead of the shorter summary.
160
87
 
161
- ### Workflow 2: Profile-based Session (Recommended)
162
- ```bash
163
- # All browser commands can use --profile parameter
164
- nstbrowser-ai-agent --profile my-profile open https://example.com
165
- nstbrowser-ai-agent --profile my-profile snapshot -i
166
- nstbrowser-ai-agent --profile my-profile fill @e1 "user@example.com"
167
- nstbrowser-ai-agent --profile my-profile fill @e2 "password"
168
- nstbrowser-ai-agent --profile my-profile click @e3
169
- nstbrowser-ai-agent --profile my-profile close
170
-
171
- # Or use UUID format (auto-detected)
172
- nstbrowser-ai-agent --profile "527e7b55-ca19-4422-89e4-88af4cf0f543" open https://example.com
173
- ```
88
+ - `profile list-cursor --page-size <size> [--cursor <token>] [--direction next|prev]`
89
+ Use when there are many profiles and you want deterministic paging.
90
+ `--page-size` limits one page.
91
+ `--cursor` continues from a previously returned cursor.
92
+ `--direction` tells NST whether that cursor is for the next page or previous page.
174
93
 
175
- ### Workflow 3: Data Extraction with Profile
176
- ```bash
177
- # Extract information from page using specific profile
178
- nstbrowser-ai-agent --profile data-scraper open https://example.com
179
- nstbrowser-ai-agent --profile data-scraper wait --load networkidle
180
- nstbrowser-ai-agent --profile data-scraper snapshot -i
181
- nstbrowser-ai-agent --profile data-scraper get text @e1
182
- nstbrowser-ai-agent --profile data-scraper eval "document.querySelectorAll('h2').length"
183
- nstbrowser-ai-agent --profile data-scraper screenshot --annotate page.png
184
- ```
94
+ - `profile show <name-or-id>`
95
+ Use when you need one profile's exact group, proxy, tags, platform, or last launch info.
185
96
 
186
- ### Workflow 4: Advanced Automation with State Management
187
- ```bash
188
- # Save authentication state for reuse
189
- nstbrowser-ai-agent --profile auth-profile open https://app.example.com/login
190
- nstbrowser-ai-agent --profile auth-profile fill @e1 "user@example.com"
191
- nstbrowser-ai-agent --profile auth-profile fill @e2 "password"
192
- nstbrowser-ai-agent --profile auth-profile click @e3
193
- nstbrowser-ai-agent --profile auth-profile wait --text "Dashboard"
194
- nstbrowser-ai-agent --profile auth-profile state save ./auth-state.json
195
-
196
- # Later, restore state and continue
197
- nstbrowser-ai-agent --profile auth-profile state load ./auth-state.json
198
- nstbrowser-ai-agent --profile auth-profile open https://app.example.com/dashboard
199
- nstbrowser-ai-agent --profile auth-profile snapshot -i
200
- ```
97
+ - `profile create <name> [--platform <Windows|macOS|Linux>] [--kernel <version>] [--group-id <id>]`
98
+ Use when you need a clean profile for a new task.
99
+ `--kernel` requests a preferred kernel milestone; NST may normalize it to a currently supported version.
100
+ Optional proxy parameters:
101
+ `--proxy-host <host>`, `--proxy-port <port>`, `--proxy-type <http|https|socks5>`, `--proxy-username <user>`, `--proxy-password <pass>`.
201
102
 
202
- ### Workflow 5: Multi-tab Operations
203
- ```bash
204
- # Work with multiple tabs using same profile
205
- nstbrowser-ai-agent --profile multi-tab open https://example.com
206
- nstbrowser-ai-agent --profile multi-tab tab new https://another-site.com
207
- nstbrowser-ai-agent --profile multi-tab tab 1 # Switch to second tab
208
- nstbrowser-ai-agent --profile multi-tab click @e1
209
- nstbrowser-ai-agent --profile multi-tab tab 0 # Switch back to first tab
210
- nstbrowser-ai-agent --profile multi-tab screenshot
211
- ```
103
+ - `profile proxy show <name-or-id>`
104
+ Use when proxy behavior looks suspicious and you want to inspect the saved proxy config and last proxy check result.
212
105
 
213
- ### Storage & Cookies Management
214
- ```bash
215
- nstbrowser-ai-agent cookies # Get all cookies
216
- nstbrowser-ai-agent cookies set name "value" # Set cookie
217
- nstbrowser-ai-agent cookies set auth "token" --domain example.com --httpOnly --secure
218
- nstbrowser-ai-agent cookies clear # Clear all cookies
219
- nstbrowser-ai-agent storage local # Get localStorage
220
- nstbrowser-ai-agent storage local set key "value" # Set localStorage
221
- nstbrowser-ai-agent storage session get key # Get sessionStorage
222
- nstbrowser-ai-agent storage local clear # Clear localStorage
223
- ```
106
+ - `profile proxy update <name-or-id> --host <host> --port <port> [--type <type>] [--username <user>] [--password <pass>]`
107
+ Use when a profile should keep the same cookies/history but change to a different proxy.
224
108
 
225
- ### Network & Debugging
226
- ```bash
227
- nstbrowser-ai-agent network route "**/api/*" --abort # Block API requests
228
- nstbrowser-ai-agent network route "**/data.json" --body '{"mock": true}'
229
- nstbrowser-ai-agent network requests # List captured requests
230
- nstbrowser-ai-agent network requests --clear # Clear request log
231
- nstbrowser-ai-agent console # View console logs
232
- nstbrowser-ai-agent errors # View page errors
233
- nstbrowser-ai-agent trace start # Start Playwright trace
234
- nstbrowser-ai-agent trace stop ./trace.zip # Stop and save trace
235
- nstbrowser-ai-agent profiler start # Start Chrome DevTools profiling
236
- nstbrowser-ai-agent profiler stop ./profile.json # Stop and save profile
237
- ```
109
+ - `profile proxy reset <name-or-id> [name-or-id...]`
110
+ Use when a profile should go back to local/default routing.
238
111
 
239
- ### Tab & Window Management
240
- ```bash
241
- nstbrowser-ai-agent tab # List all tabs
242
- nstbrowser-ai-agent tab new https://example.com # Open new tab
243
- nstbrowser-ai-agent tab 2 # Switch to tab 2
244
- nstbrowser-ai-agent tab close # Close current tab
245
- nstbrowser-ai-agent tab close 1 # Close tab 1
246
- nstbrowser-ai-agent window new # Open new window
247
- nstbrowser-ai-agent frame "#iframe" # Switch to iframe
248
- nstbrowser-ai-agent frame main # Switch back to main frame
249
- ```
112
+ - `profile tags list`, `profile tags create`, `profile tags update`, `profile tags clear`
113
+ Use when you need to organize profiles for repeated agent workflows.
114
+ `profile tags create` only needs a tag name; the CLI fills in a default tag color.
250
115
 
251
- ### Browser Settings & Emulation
252
- ```bash
253
- nstbrowser-ai-agent set viewport 1920 1080 # Set viewport size
254
- nstbrowser-ai-agent set device "iPhone 12" # Emulate device
255
- nstbrowser-ai-agent set geo 37.7749 -122.4194 # Set geolocation
256
- nstbrowser-ai-agent set offline on # Enable offline mode
257
- nstbrowser-ai-agent set headers '{"X-Custom": "value"}' # Set HTTP headers
258
- nstbrowser-ai-agent set credentials admin pass # Set HTTP auth
259
- nstbrowser-ai-agent set media dark # Set color scheme
260
- ```
116
+ - `profile groups list`, `profile groups change <group-id> <name-or-id> [name-or-id...]`
117
+ Use when you need to discover valid NST group IDs or move profiles into a specific group.
261
118
 
262
- ### State Management
263
- ```bash
264
- nstbrowser-ai-agent state save ./auth-state.json # Save browser state
265
- nstbrowser-ai-agent state load ./auth-state.json # Load browser state
266
- nstbrowser-ai-agent state list # List saved states
267
- nstbrowser-ai-agent state show filename.json # Show state summary
268
- nstbrowser-ai-agent state clear --all # Clear all states
269
- ```
119
+ ### Browser Management
270
120
 
271
- ### Comparison & Diffing
272
- ```bash
273
- nstbrowser-ai-agent diff snapshot # Compare current vs last snapshot
274
- nstbrowser-ai-agent diff snapshot --baseline before.txt # Compare vs saved snapshot
275
- nstbrowser-ai-agent diff screenshot --baseline before.png # Visual diff
276
- nstbrowser-ai-agent diff url https://v1.com https://v2.com # Compare two pages
277
- nstbrowser-ai-agent diff url https://staging.com https://prod.com --screenshot
278
- ```
121
+ - `browser list`
122
+ Use when you need to see which profile browsers or temporary browsers are already running.
279
123
 
280
- ### Dialog Handling
281
- ```bash
282
- nstbrowser-ai-agent dialog accept # Accept alert/confirm
283
- nstbrowser-ai-agent dialog accept "input text" # Accept prompt with text
284
- nstbrowser-ai-agent dialog dismiss # Dismiss/cancel dialog
285
- ```
124
+ - `browser start <name-or-id> [--headless] [--auto-close]`
125
+ Use when you want the browser running before the first `open`.
126
+ `--headless` requests headless launch.
127
+ `--auto-close` asks NST to close that browser when its owner exits.
286
128
 
287
- ## Global Options (Apply to ALL commands)
129
+ - `browser pages <name-or-id>`
130
+ Use when you need the current debuggable pages in one running browser.
288
131
 
289
- ### Profile Selection
290
- ```bash
291
- --profile <name-or-id> # Use specific NST profile (name or UUID)
292
- # Examples: --profile "my-profile" or --profile "527e7b55-ca19-4422-89e4-88af4cf0f543"
293
- ```
132
+ - `browser debugger <name-or-id>`
133
+ Use when you need the debugger port and browser-level WebSocket endpoint.
134
+
135
+ - `browser cdp-url <name-or-id>`
136
+ Use when you only need the browser-level CDP WebSocket URL.
137
+
138
+ - `browser connect <name-or-id>`
139
+ Use when you want NST to start the browser if needed and immediately return connection info.
140
+
141
+ - `browser start-once [--platform <platform>] [--kernel <kernel>] [--headless] [--auto-close]`
142
+ Use only for throwaway work that should not persist in a saved profile.
143
+
144
+ - `browser cdp-url-once`
145
+ Use when a temporary browser is enough and you only need its CDP URL.
146
+
147
+ - `browser connect-once [--platform <platform>] [--kernel <kernel>]`
148
+ Use when one command should both create a temporary browser and return CDP connection info.
149
+
150
+ - `browser stop <name-or-id>` and `browser stop-all`
151
+ Use for cleanup after the task or when stale browsers should be cleared.
152
+
153
+ ### When to Use Which NST Command
154
+
155
+ - Use `nst status` first when the environment itself may be broken.
156
+ - Use `profile list` when you only need a profile name to start work quickly.
157
+ - Use `profile list-cursor` when the workspace has too many profiles for one list.
158
+ - Use `profile show` when the question is about one specific profile's configuration.
159
+ - Use `verify` before real work when the profile may be stale or untrusted.
160
+ - Use `repair` after `verify` reports stale browser state or repeated attach failures.
161
+ - Use `browser start` when you want explicit control over browser launch.
162
+ - Use `--profile <name-or-id>` directly on browser actions when the goal is task execution, not management.
163
+
164
+ ## Browser Actions
165
+
166
+ All browser actions can use `--profile <name-or-id>`. The value may be a profile name or UUID.
167
+
168
+ ### Recommended Workflow
169
+
170
+ Prefer this workflow over temporary browsers:
294
171
 
295
- ### Session Management
296
172
  ```bash
297
- --session <name> # Use isolated session
298
- --session-name <name> # Auto-save/restore state across restarts
173
+ nstbrowser-ai-agent --profile YOUR_PROFILE open https://example.com
174
+ nstbrowser-ai-agent --profile YOUR_PROFILE snapshot -i
175
+ nstbrowser-ai-agent --profile YOUR_PROFILE click @e1
176
+ nstbrowser-ai-agent --profile YOUR_PROFILE get url
177
+ nstbrowser-ai-agent --profile YOUR_PROFILE screenshot --annotate /tmp/page.png
178
+ nstbrowser-ai-agent browser stop YOUR_PROFILE
299
179
  ```
300
180
 
301
- ### Output Control
181
+ ### Session Workflow
182
+
183
+ Use this only when the user explicitly needs isolation or a longer daemon-backed run. Keep the same `--session` and `--profile` on every related command.
184
+
185
+ If the task intentionally changes to a different Nstbrowser profile inside the same `--session`, repeat the new `--profile` explicitly on the switching command.
186
+
302
187
  ```bash
303
- --json # JSON output for all commands
304
- --content-boundaries # Wrap page content in boundary markers
305
- --max-output <chars> # Truncate output to N characters
188
+ nstbrowser-ai-agent --session task-run --profile YOUR_PROFILE open https://example.com
189
+ nstbrowser-ai-agent --session task-run --profile YOUR_PROFILE snapshot -i
190
+ nstbrowser-ai-agent --session task-run --profile YOUR_PROFILE click @e1
191
+ nstbrowser-ai-agent --session task-run --profile YOUR_PROFILE tab new https://iana.org
192
+ nstbrowser-ai-agent --session task-run --profile YOUR_PROFILE get url
306
193
  ```
307
194
 
308
- ### Browser Configuration
195
+ ### Temporary Browser Workflow
196
+
197
+ Use `browser start-once` only when the user wants a throwaway browser and does not need profile persistence:
198
+
309
199
  ```bash
310
- --headers <json> # HTTP headers (scoped to origin)
311
- --user-agent <ua> # Custom User-Agent
312
- --proxy <server> # Proxy server (http://user:pass@host:port)
313
- --proxy-bypass <hosts> # Bypass proxy for hosts
314
- --color-scheme <scheme> # dark, light, no-preference
315
- --download-path <path> # Default download directory
200
+ nstbrowser-ai-agent browser start-once
201
+ nstbrowser-ai-agent open https://example.com
202
+ nstbrowser-ai-agent snapshot -i
316
203
  ```
317
204
 
318
- ## Common Issues & Solutions
319
-
320
- | Problem | Solution |
321
- |---------|----------|
322
- | "HTTP 400: Bad Request" | Start Nstbrowser desktop client and verify API key |
323
- | "Profile not found" | Use `profile list` to see available profiles, or check profile name/ID |
324
- | "Element not found" | Run `snapshot -i` to refresh element refs after page changes |
325
- | "@e1 not working" | Element refs change after navigation - get fresh snapshot |
326
- | "Browser not running" | Use `browser start <profile-id>` or `browser start-once` |
327
- | "Command timeout" | Use appropriate wait strategies: `wait --load networkidle` |
328
- | "Stale element reference" | Re-run `snapshot -i` after DOM changes |
329
- | "Profile ID vs name confusion" | Both work - UUID format auto-detected as ID, others as name |
330
- | "Headers not working" | Headers are scoped to origin - use `--headers` with `open` command |
331
- | "Download not saving" | Specify full path: `download @e1 ./downloads/file.pdf` |
332
- | "Screenshot annotation missing" | Use `--annotate` flag: `screenshot --annotate` |
333
- | "State not persisting" | Use `--session-name` for auto-persistence or manual `state save/load` |
334
-
335
- ## Advanced Features
336
-
337
- - **Proxy Configuration**: `profile proxy update <id> --host proxy.com --port 8080`
338
- - **Batch Operations**: `profile delete id1 id2 id3`
339
- - **Tab Management**: `tab new <url>`, `tab 0`, `tab close`
340
- - **Wait Strategies**: `wait 3000`, `wait --load networkidle`
341
-
342
- ## Best Practices
343
-
344
- 1. **Always Use Profile Parameters**: Specify `--profile <name-or-id>` for all browser operations to ensure consistent fingerprinting and session management
345
- 2. **Profile ID vs Name**: Use profile IDs (UUID format) for reliability, names for readability - both are auto-detected
346
- 3. **Refresh Element References**: Run `snapshot -i` after tab switches, page changes, or navigation to get fresh @e references
347
- 4. **Use JSON Output for Integration**: Add `--json` to any command for machine-readable output in AI agent workflows
348
- 5. **Handle Async Operations**: Use appropriate wait strategies (`--load networkidle`, `wait --text`, `wait @element`) for dynamic content
349
- 6. **State Persistence**: Use `--session-name` for automatic state persistence across browser restarts
350
- 7. **Error Handling**: Check command output and retry with fresh snapshots if element references become stale
351
- 8. **Security**: Use `--content-boundaries` to safely parse page content and avoid injection attacks
352
- 9. **Performance**: Use `--max-output` to limit large page content, `snapshot --compact` to reduce noise
353
- 10. **Debugging**: Use `--annotate` screenshots for visual debugging, `trace start/stop` for detailed analysis
354
-
355
- ## Profile Parameter Usage
356
-
357
- **All browser action commands support the `--profile` parameter:**
205
+ ## Useful Global Options
358
206
 
359
207
  ```bash
360
- # Navigation commands
361
- nstbrowser-ai-agent --profile my-profile open <url>
362
- nstbrowser-ai-agent --profile my-profile back
363
- nstbrowser-ai-agent --profile my-profile forward
364
- nstbrowser-ai-agent --profile my-profile reload
365
-
366
- # Interaction commands
367
- nstbrowser-ai-agent --profile my-profile click @e1
368
- nstbrowser-ai-agent --profile my-profile fill @e2 "text"
369
- nstbrowser-ai-agent --profile my-profile type @e3 "text"
370
- nstbrowser-ai-agent --profile my-profile hover @e4
371
- nstbrowser-ai-agent --profile my-profile drag @e5 @e6
372
-
373
- # Data extraction commands
374
- nstbrowser-ai-agent --profile my-profile snapshot -i
375
- nstbrowser-ai-agent --profile my-profile get text @e1
376
- nstbrowser-ai-agent --profile my-profile screenshot
377
- nstbrowser-ai-agent --profile my-profile eval "code"
378
-
379
- # State and storage commands
380
- nstbrowser-ai-agent --profile my-profile cookies set name "value"
381
- nstbrowser-ai-agent --profile my-profile storage local set key "value"
382
- nstbrowser-ai-agent --profile my-profile state save ./state.json
383
-
384
- # All other browser commands...
208
+ --profile <name-or-id> Use a specific Nstbrowser profile
209
+ --session <name> Use an isolated daemon session
210
+ --session-name <name> Auto-save and restore browser state
211
+ --json Machine-readable output
212
+ --headers <json> Scoped HTTP headers for the opened origin
213
+ --proxy <server> Override proxy for the launched browser session
214
+ --proxy-bypass <hosts> Bypass proxy for specific hosts
215
+ --annotate Add numbered labels to screenshot output
216
+ --full Full-page screenshot
385
217
  ```
386
218
 
387
- **Profile Resolution Priority:**
388
- 1. Check running browsers (by ID or name, use earliest if multiple)
389
- 2. Start browser if profile exists but not running
390
- 3. Create new profile if name doesn't exist
391
- 4. Error if ID doesn't exist
392
- 5. Use temporary browser if no profile specified
219
+ ## Recommended Patterns
220
+
221
+ 1. Start with `nst status` and `profile list` if anything about the environment is unclear.
222
+ 2. Prefer `snapshot -i` before `click` or `fill` so refs are fresh.
223
+ 3. Repeat the same `--profile` on every browser command unless you are intentionally using a dedicated `--session`.
224
+ 4. Use `--session` only when you need an isolated workflow, and then keep both `--session` and `--profile` consistent across the whole run.
225
+ 5. Use `repair` before retrying if NST reports stale browser state or multiple stuck instances.
226
+ 6. Prefer a clean or newly created profile if an existing profile has broken proxy or network settings.
393
227
 
394
- ## Full Documentation
228
+ ## Common Failure Recovery
395
229
 
396
- Complete documentation: https://github.com/nstbrowser/nstbrowser-ai-agent#readme
230
+ - `Profile not found`: run `profile list` and use the exact profile name or UUID.
231
+ - `@e1 not working`: run `snapshot -i` again because refs change after navigation.
232
+ - Refs are order-dependent: generate them first, then use them later in the same session.
233
+ - `@e1` is treated like CSS: you probably changed profile or session context, or forgot to pass the same `--profile` again.
234
+ - `Browser not running`: run `browser start <name-or-id>` or re-run `open`.
235
+ - `NST agent not responding`: start the Nstbrowser desktop client, then run `nst status`.
236
+ - `Command appears stale`: use a new `--session` name or run `browser stop <name-or-id>` / `browser stop-all`.
237
+ - `open https://example.com` lands on a Chrome error page: switch to a clean profile or create a new one because the current profile may have a broken proxy.
397
238
 
398
239
  ## Notes
399
240
 
400
- - All browser operations use Nstbrowser profiles for advanced fingerprinting
401
- - Temporary browsers (`browser start-once`) don't save session state
402
- - Profile sessions persist cookies, localStorage, and login state
403
- - Element refs (@e1, @e2) are generated by `snapshot -i` command
241
+ - `browser start-once` creates a temporary Nstbrowser-managed browser.
242
+ - Profile-backed sessions persist cookies and site storage in the Nstbrowser profile itself.
243
+ - `--profile` is for Nstbrowser profile selection only.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nstbrowser-ai-agent",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Browser automation CLI with Nstbrowser integration for AI agents",
5
5
  "author": "NstbrowserIO",
6
6
  "license": "MIT-0",