@agimon-ai/browse-tool 0.2.5 → 0.2.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.
package/README.md CHANGED
@@ -64,6 +64,7 @@ Options:
64
64
  --port <port> Port for streamable HTTP transport (default: "3201")
65
65
  -p, --profile <name> Default profile name for browser sessions
66
66
  --custom-tools <path> Expose tools from a folder containing tools.yaml
67
+ --snippets-dir <path> Directory used by browser_run_code to save and load reusable snippets
67
68
  ```
68
69
 
69
70
  ### Streamable HTTP Transport
@@ -200,6 +201,13 @@ browse-tool exec-custom-tool \
200
201
  | `browser_resize_page` | Resize the browser viewport |
201
202
  | `browser_emulate` | Emulate device, geolocation, or network conditions |
202
203
 
204
+ ### Code Tools (2)
205
+
206
+ | Tool | Description |
207
+ |------|-------------|
208
+ | `browser_run_code` | Execute inline code against `{ page, context, browser }`, optionally save it as a reusable snippet |
209
+ | `browser_list_snippets` | List saved snippets by name, description, and snippetPath |
210
+
203
211
  ### Testing/Tracing Tools (3)
204
212
 
205
213
  | Tool | Description |
@@ -217,63 +225,47 @@ browse-tool exec-custom-tool \
217
225
  | `browser_delete_profile` | Delete a profile |
218
226
  | `browser_save_profile_state` | Save current browser state to profile |
219
227
 
220
- ### Automation Tools (3)
221
-
222
- | Tool | Description |
223
- |------|-------------|
224
- | `run_automation` | Run an automation script with optional pause |
225
- | `resume_automation` | Resume a paused automation |
226
- | `get_automation_status` | Get automation session status |
227
-
228
- ## Automation Script Format
229
-
230
- Automation scripts are TypeScript/JavaScript modules that export a `run` function:
231
-
232
- ```typescript
233
- import type { AutomationFixtures } from 'browse-tool';
234
-
235
- export async function run({ page, context, browser, pauseCheck }: AutomationFixtures) {
236
- // Navigate to a page
237
- await page.goto('https://example.com');
238
-
239
- // Create a pause checkpoint for LLM intervention
240
- await pauseCheck('after-navigation', 'Page loaded, ready for inspection');
228
+ ## Saved Snippets
241
229
 
242
- // Continue with automation
243
- await page.click('#login-button');
230
+ If you start `mcp-serve` or `http-serve` with `--snippets-dir <path>`, `browser_run_code` can persist inline snippets and later execute them again by `snippetPath`.
244
231
 
245
- // Another pause point
246
- await pauseCheck('after-login-click', 'Login button clicked');
232
+ Save an inline snippet:
247
233
 
248
- // Fill form
249
- await page.fill('#username', 'testuser');
250
- await page.fill('#password', 'password123');
234
+ ```json
235
+ {
236
+ "tool": "browser_run_code",
237
+ "arguments": {
238
+ "pageId": "page-1",
239
+ "code": "return await page.title();",
240
+ "saveAs": {
241
+ "name": "Get Page Title",
242
+ "description": "Return the current page title"
243
+ }
244
+ }
251
245
  }
252
246
  ```
253
247
 
254
- ### Fixtures Available
248
+ List saved snippets:
255
249
 
256
- | Fixture | Type | Description |
257
- |---------|------|-------------|
258
- | `page` | `Page` | Playwright Page instance |
259
- | `context` | `BrowserContext` | Playwright BrowserContext |
260
- | `browser` | `Browser` | Playwright Browser instance |
261
- | `pauseCheck` | `Function` | Create pause checkpoints for LLM control |
262
-
263
- ### Using pauseCheck
250
+ ```json
251
+ {
252
+ "tool": "browser_list_snippets",
253
+ "arguments": {}
254
+ }
255
+ ```
264
256
 
265
- The `pauseCheck` function allows the automation to pause at specific points, giving the LLM control to inspect the page, interact manually, and then resume:
257
+ Run a saved snippet:
266
258
 
267
- ```typescript
268
- await pauseCheck(stepName: string, reason?: string): Promise<void>
259
+ ```json
260
+ {
261
+ "tool": "browser_run_code",
262
+ "arguments": {
263
+ "pageId": "page-1",
264
+ "snippetPath": "get-page-title.ts"
265
+ }
266
+ }
269
267
  ```
270
268
 
271
- When paused:
272
- 1. The automation waits for `resume_automation` to be called
273
- 2. All browser tools remain available for LLM interaction
274
- 3. The LLM can inspect page state, take screenshots, etc.
275
- 4. Once resumed, automation continues from where it paused
276
-
277
269
  ## Profile Management
278
270
 
279
271
  Profiles allow you to persist browser state (cookies, localStorage, etc.) across sessions.
@@ -291,20 +283,6 @@ Profiles allow you to persist browser state (cookies, localStorage, etc.) across
291
283
  }
292
284
  ```
293
285
 
294
- ### Use a Profile with Automation
295
-
296
- ```json
297
- {
298
- "tool": "run_automation",
299
- "arguments": {
300
- "scriptPath": "/path/to/script.ts",
301
- "browserOptions": {
302
- "profile": "my-profile"
303
- }
304
- }
305
- }
306
- ```
307
-
308
286
  ### Save Profile State
309
287
 
310
288
  ```json
@@ -317,47 +295,6 @@ Profiles allow you to persist browser state (cookies, localStorage, etc.) across
317
295
  }
318
296
  ```
319
297
 
320
- ## LLM-Controlled Automation Flow
321
-
322
- The unique feature of browse-tool is the ability to run automation scripts with LLM intervention points:
323
-
324
- 1. **Start Automation with Pause**
325
- ```json
326
- {
327
- "tool": "run_automation",
328
- "arguments": {
329
- "scriptPath": "/path/to/script.ts",
330
- "pauseAtStart": true
331
- }
332
- }
333
- ```
334
-
335
- 2. **Automation Pauses** - Returns `automationId` and `pageIds`
336
-
337
- 3. **LLM Interacts** - Use browser tools (`browser_click`, `browser_fill`, etc.) on the paused pages
338
-
339
- 4. **Resume Automation**
340
- ```json
341
- {
342
- "tool": "resume_automation",
343
- "arguments": {
344
- "automationId": "automation-1"
345
- }
346
- }
347
- ```
348
-
349
- 5. **Script Continues** - Until next `pauseCheck` or completion
350
-
351
- 6. **Check Status**
352
- ```json
353
- {
354
- "tool": "get_automation_status",
355
- "arguments": {
356
- "automationId": "automation-1"
357
- }
358
- }
359
- ```
360
-
361
298
  ## Configuration
362
299
 
363
300
  ### Environment Variables