browser4-cli 0.1.21 → 0.1.23

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
@@ -25,19 +25,7 @@ npm install browser4-cli
25
25
 
26
26
  Then use via `package.json` scripts or by invoking `browser4-cli` directly.
27
27
 
28
- ### Homebrew (macOS)
29
-
30
- ```bash
31
- brew install browser4-cli
32
- ```
33
-
34
- ### Cargo (Rust)
35
-
36
- ```bash
37
- cargo install browser4-cli
38
- ```
39
-
40
- ### Standalone Installer Scripts (no npm / Rust / Homebrew needed)
28
+ ### Standalone Installer Scripts (no npm needed)
41
29
 
42
30
  Bootstrap the native binary directly with a single command:
43
31
 
@@ -155,7 +143,7 @@ The tables below mirror the commands surfaced by the global `browser4-cli help`
155
143
  | `check <ref>` | Check a checkbox or radio button |
156
144
  | `uncheck <ref>` | Uncheck a checkbox or radio button |
157
145
  | `drag <startRef> <endRef>` | Drag and drop between two elements |
158
- | `snapshot` | Capture accessibility snapshot. Supports `--filename=<path>` to save snapshot to file. |
146
+ | `snapshot` | Capture accessibility snapshot. Supports `--filename=<path>` to save to file, `--boxes` for bounding boxes, `-i`/`--interactive` for interactive-only, `-u`/`--urls` for link URLs, `-c`/`--compact` for compact output, `-d`/`--depth <n>` for depth limiting, `-s`/`--selector <sel>` for CSS scoping, and `--raw` for raw output without page info. |
159
147
  | `eval <expression> [ref]` | Evaluate JavaScript on the page or a target element. Use `--file=<path>` to read the expression from a file. |
160
148
  | `get <mode> <selector> [name]` | Extract data from a page element. Modes: `text`, `html`, `box`, `styles`, `property`, `attr`. `name` is required for `property` and `attr`. |
161
149
  | `scroll <direction> <pixels>` | Scroll the page. Direction: `up`, `down`, `left`, or `right`. |
@@ -246,7 +234,7 @@ Use `close-all` for session cleanup when you want to keep the current Browser4 s
246
234
  |---|---|
247
235
  | `install` | Download the Browser4 runtime bundle. Supports `--tag=<version>` to pin a release and `--force` to reinstall even when already present. |
248
236
  | `upgrade` | Upgrade the Browser4 runtime bundle to the latest version or a specified `--tag` |
249
- | `uninstall` | Remove globally installed browser4-cli (npm, cargo) and its runtime data. Supports `-y` / `--yes` (skip confirmation) and `--dry-run` (preview). |
237
+ | `uninstall` | Remove globally installed browser4-cli (npm) and its runtime data. Supports `-y` / `--yes` (skip confirmation) and `--dry-run` (preview). |
250
238
  | `stop` | Kill the Browser4 backend after closing all sessions |
251
239
  | `status` | Check whether the Browser4 backend is reachable and healthy |
252
240
 
@@ -262,8 +250,8 @@ When a local Browser4 checkout is detected with the `browser4-bundle` module pre
262
250
  `install` and `upgrade` auto-build the runtime bundle from source (via Maven) instead
263
251
  of downloading.
264
252
 
265
- `uninstall` attempts to remove browser4-cli from npm global packages and cargo
266
- installs, and deletes the Browser4 runtime data and cache directories. It prompts
253
+ `uninstall` attempts to remove browser4-cli from npm global packages
254
+ and deletes the Browser4 runtime data and cache directories. It prompts
267
255
  for confirmation unless `-y` / `--yes` is passed. Use `--dry-run` to preview what
268
256
  would be removed without making changes. Does not require a running server.
269
257
 
@@ -292,6 +280,7 @@ Query `browser4-cli help <command>` for the exact syntax when you need them.
292
280
  | `swarm query <url>` | Run an X-SQL query against a loaded webpage |
293
281
  | `swarm status <id>` | Check the status of a scrape or query job |
294
282
  | `swarm result <id>` | Get the result of a completed job |
283
+ | `crawl <url>` | Crawl a website from a seed URL, following links up to a configurable depth |
295
284
 
296
285
  ## Agent task workflow (`agent <subcommand>`)
297
286
 
@@ -393,6 +382,8 @@ coordinates multiple browser contexts in the Browser4 backend.
393
382
  | `swarm query <url>` | Run X-SQL queries against loaded pages | `POST /api/swarm/query` |
394
383
  | `swarm status <id>` | Poll job status | `GET /api/swarm/{id}/status` |
395
384
  | `swarm result <id>` | Fetch completed job result | `GET /api/swarm/{id}/result` |
385
+ | `crawl <url>` | Start a website crawl | `POST /api/crawl` |
386
+ | (poll) | Track crawl progress | `GET /api/crawl/{id}/result` |
396
387
 
397
388
  ### URL scraping with `swarm submit`
398
389
 
@@ -450,6 +441,57 @@ browser4-cli swarm query --sql @query.sql --seed-file=./urls.txt --refresh
450
441
  - Prefix the `--sql` value with `@` to read from a file (e.g. `--sql @query.sql`).
451
442
  - All commands return a task ID; use `swarm status` / `swarm result` to track progress.
452
443
 
444
+ ## Crawl (`crawl`)
445
+
446
+ Recursive website crawling from a seed URL.
447
+
448
+ ### Command overview
449
+
450
+ | Command | Purpose | Backend endpoint |
451
+ |---|---|---|
452
+ | `crawl <url>` | Crawl a website from a seed URL | `POST /api/crawl` |
453
+ | (poll) | Track crawl progress | `GET /api/crawl/{id}/result` |
454
+
455
+ ### Basic crawling
456
+
457
+ ```shell
458
+ # depth=1: extract all links from homepage, load each linked page
459
+ browser4-cli crawl "https://example.com" --out-link-selector "a[href]"
460
+
461
+ # depth=2: follow links two levels deep, filter by pattern
462
+ browser4-cli crawl "https://shop.example.com" \
463
+ --depth 2 \
464
+ --out-link-selector "a.product-link" \
465
+ --out-link-pattern "/product/" \
466
+ --top-links 10
467
+
468
+ # with LoadOptions passthrough
469
+ browser4-cli crawl "https://example.com" -ol "a[href]" -a "-refresh -nMaxRetry 5"
470
+ ```
471
+
472
+ ### Key flags
473
+
474
+ | Flag | Default | Description |
475
+ |---|---|---|
476
+ | `-d`, `--depth` | `1` | Maximum crawl depth |
477
+ | `-ol`, `--out-link-selector` | — | CSS selector to extract links from each page |
478
+ | `-olp`, `--out-link-pattern` | `.+` | Regex pattern to filter extracted links |
479
+ | `-tl`, `--top-links` | `20` | Maximum links to extract per page |
480
+ | `-a`, `--args` | — | Additional LoadOptions passthrough |
481
+ | `--refresh` | — | Force a fresh fetch, ignoring cache |
482
+ | `--parse` | — | Parse each page immediately after fetching |
483
+ | `--expires` | — | Cache expiration duration |
484
+ | `--store-content` | — | Persist page content to storage |
485
+ | `--page-load-timeout` | — | Maximum time to wait for page load |
486
+ | `--readonly` | — | Non-destructive mode |
487
+
488
+ ### Notes
489
+
490
+ - All LoadOptions flags available via `--args` passthrough (e.g. `-a "-nMaxRetry 5 -lazyFlush"`).
491
+ - Depth=1 reuses `PulsarSession.submitForOutPages`; depth>1 uses BFS continuous crawl with visited-URL dedup.
492
+ - CLI timeout: 600s default, configurable via `BROWSER4_CLI_CRAWL_TIMEOUT_SECS`.
493
+ - Duplicate URLs are skipped (normalized: lowercase, no trailing slash, no query string).
494
+
453
495
  ## DOM Snapshot commands (`domsnapshot <subcommand>`)
454
496
 
455
497
  The `domsnapshot` commands capture and query a **static DOM snapshot** of the
@@ -474,6 +516,37 @@ browser4-cli domsnapshot export --file=page.html
474
516
  | `domsnapshot get <field> [selector] [name]` | Extract elements from the static DOM snapshot |
475
517
  | `domsnapshot query [url] --sql=<query>` | Run X-SQL against the DOM snapshot via the scrape API |
476
518
  | `domsnapshot export [--file=<path>]` | Save full snapshot HTML content to a local file |
519
+ | `domsnapshot grep [OPTIONS] <pattern>` | Search snapshot HTML with regex and grep-style output |
520
+
521
+ ### `domsnapshot grep` flags
522
+
523
+ Line numbers are shown by default (unlike GNU grep). Use `--no-line-number` to suppress them.
524
+
525
+ | Flag | Description |
526
+ |---|---|
527
+ | `-i` | Case-insensitive matching |
528
+ | `-A N`, `-B N`, `-C N` | Context lines after / before / around each match |
529
+ | `-v` | Invert match (select non-matching lines) |
530
+ | `-c` | Print only count of matching lines |
531
+ | `-l` | Print only whether matches exist (prints "domsnapshot" if matches found; use with `\| grep -q domsnapshot` for CI pass/fail) |
532
+ | `-F` | Treat pattern as a literal string |
533
+ | `-w` | Match whole words only |
534
+ | `--no-line-number` | Suppress line numbers in output |
535
+ | `--selector <CSS>` | Scope search to a CSS selector |
536
+
537
+ ```shell
538
+ # Basic search
539
+ browser4-cli domsnapshot grep -i error
540
+
541
+ # With context and literal match
542
+ browser4-cli domsnapshot grep -F -C 2 "404 Not Found"
543
+
544
+ # Count matches
545
+ browser4-cli domsnapshot grep -c "div"
546
+
547
+ # Search within a specific element
548
+ browser4-cli domsnapshot grep --selector main "Submit"
549
+ ```
477
550
 
478
551
  ### `domsnapshot get` fields
479
552
 
@@ -612,6 +685,18 @@ browser4-cli goto https://browser4.io
612
685
  # Inspect the page — note the eN labels on interactive nodes
613
686
  browser4-cli snapshot
614
687
 
688
+ # Include element bounding boxes in the snapshot
689
+ browser4-cli snapshot --boxes
690
+
691
+ # Show only interactive elements with compact output, depth-limited
692
+ browser4-cli snapshot -i -c -d 5
693
+
694
+ # Scope snapshot to a specific CSS selector
695
+ browser4-cli snapshot -s "#main-content"
696
+
697
+ # Raw output — no page info, just the snapshot content (useful for piping)
698
+ browser4-cli snapshot --raw | grep "button"
699
+
615
700
  # Capture a static DOM snapshot and extract data
616
701
  browser4-cli domsnapshot
617
702
  browser4-cli domsnapshot get text "#productTitle"
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser4-cli",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "Browser automation CLI for AI agents",
5
5
  "type": "module",
6
6
  "files": [