browser4-cli 4.12.2 โ†’ 4.12.3

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
@@ -1,43 +1,163 @@
1
- # browser4-cli
1
+ # ๐Ÿค– Browser4
2
2
 
3
- Make websites accessible for AI agents. Automate tasks online with ease.
3
+ [![License: APACHE2](https://img.shields.io/badge/license-APACHE2-green?style=flat-square)](https://github.com/platonai/browser4/blob/main/LICENSE)
4
4
 
5
- ## What is browser4-cli?
5
+ ---
6
+
7
+ English | [็ฎ€ไฝ“ไธญๆ–‡](README.zh.md) | [ไธญๅ›ฝ้•œๅƒ](https://gitee.com/platonai_galaxyeye/Browser4)
8
+
9
+ <!-- TOC -->
10
+ **Table of Contents**
11
+ - [๐Ÿค– Browser4](#-browser4)
12
+ - [๐ŸŒŸ Introduction](#-introduction)
13
+ - [โœจ Key Capabilities](#-key-capabilities)
14
+ - [Quick Start](#quick-start)
15
+ - [๐Ÿงญ Tool Selection Guide](#-tool-selection-guide)
16
+ - [How to Interact with a Page](#how-to-interact-with-a-page)
17
+ - [How to Extract Data](#how-to-extract-data)
18
+ - [How to Process at Scale](#how-to-process-at-scale)
19
+ - [How to Turn HTML into Spreadsheets โ€” Zero Tokens](#how-to-turn-html-into-spreadsheets--zero-tokens)
20
+ - [๐Ÿ“ฆ Installation](#-installation)
21
+ - [๐Ÿ’ก CLI Guide for Humans](#-cli-guide-for-humans)
22
+ - [Quick start](#quick-start-1)
23
+ - [Mental model](#mental-model)
24
+ - [Global options](#global-options)
25
+ - [Key concepts before the command list](#key-concepts-before-the-command-list)
26
+ - [Complete command reference](#complete-command-reference)
27
+ - [Timeout environment variables](#timeout-environment-variables)
28
+ - [State persistence](#state-persistence)
29
+ - [๐Ÿš€ Build from Source](#-build-from-source)
30
+ - [Architecture](#architecture)
31
+ - [๐Ÿ“ฆ Modules Overview](#-modules-overview)
32
+ - [๐Ÿงช Test Fixture Server (MockSite)](#-test-fixture-server-mocksite)
33
+ - [๐Ÿค Support & Community](#-support--community)
34
+ - [๐Ÿ“œ Documentation](#-documentation)
35
+ - [๐Ÿ”ง Proxy Configuration](#-proxy-configuration---unblock-website-access)
36
+ - [License](#license)
37
+ <!-- /TOC -->
38
+
39
+ ## ๐ŸŒŸ Introduction
6
40
 
7
- `browser4-cli` is a command-line browser automation tool. It controls a real
8
- Chrome browser โ€” clicking, typing, scrolling, and extracting data โ€” through a
9
- local server that translates CLI commands into browser actions.
41
+ ๐Ÿ’– **Browser4: a fast, intelligent, scalable, multi-scenario agentic browser** ๐Ÿ’–
10
42
 
11
- **What you can do with it:**
43
+ ### โœจ Key Capabilities
12
44
 
13
- - Automate form filling, logins, and multistep web workflows
14
- - Capture accessibility snapshots (ARIA tree) for interaction and HTML snapshots (HTML) for data analysis
15
- - Extract structured data with AI, CSS selectors or X-SQL queries
16
- - Swarm mode: Scrape at scale with parallel browser contexts
17
- - Crawl websites recursively, following links to a configurable depth
18
- - Run autonomous AI agent tasks from natural-language instructions
19
- - Save screenshots, PDFs, and full HTML snapshots
45
+ * ๐Ÿค– **Agent Browser** โ€” Browser automation CLI for AI agents.
46
+ * โš™๏ธ **Machine Learning Agent** โ€” Turns complex pages into Excel/structured data without consuming tokens.
47
+ * โšก **Extreme Performance** โ€” Fully coroutine-safe; supports 100k ~ 200k complex page visits per machine per day.
48
+ * ๐Ÿงฌ **Data Extraction** โ€” Hybrid of LLM, ML, X-SQL and selectors for clean data across chaotic pages.
49
+ * ๐Ÿ“ฆ **And More** - Swarm scraping, crawl, batch, loop, stateful sessions, page storage, extension, plugins, and more.
20
50
 
21
- **What makes it different:**
51
+ ## Quick Start
22
52
 
23
- - **HTML snapshots** - static HTML analysis without losing information
24
- - **X-SQL** โ€” a SQL-like query language for extracting structured data from
25
- web pages in a single expression
26
- - **Session persistence** โ€” browser sessions survive across CLI invocations;
27
- come back to the same tabs and state days later
28
- - **Swarm scraping** โ€” coordinate multiple browser contexts in parallel for
29
- high-throughput data collection
53
+ Paste the following instruction to your favorite AI agent like claude, codex, workbuddy or openclaw and run it:
54
+
55
+ ```
56
+ Read https://browser4.io/SKILL.md and install browser4-cli (if not installed) for browser automation to perform the following task:
57
+
58
+ 1. go to amazon.com
59
+ 2. search for pens to draw on whiteboards
60
+ 3. compare the first 4 ones
61
+ 4. write the result to a markdown file
62
+ ```
30
63
 
31
- ## Installation
64
+ ## ๐Ÿงญ Tool Selection Guide
32
65
 
33
- ### npm (recommended)
66
+ Choosing the right tool for your task:
67
+
68
+ ### How to Interact with a Page
69
+
70
+ ```
71
+ Need to interact with a page?
72
+ โ”œโ”€ Need to open or recover a browser session? โ†’ open [url] or goto <url>
73
+ โ”œโ”€ Need to see what is clickable/typeable right now? โ†’ snapshot -i --boxes
74
+ โ”œโ”€ Need to click a button, link, checkbox, or menu item? โ†’ click <ref>
75
+ โ”œโ”€ Need to fill a form field and replace existing text? โ†’ fill <ref> "<text>"
76
+ โ”œโ”€ Need to type naturally into the current field or send Enter/Tab? โ†’ type / press
77
+ โ”œโ”€ Need to choose from a dropdown? โ†’ select <ref> <value>
78
+ โ”œโ”€ Need to hover, drag, scroll, or use the mouse directly? โ†’ hover / drag / scroll / mouse*
79
+ โ”œโ”€ Need to wait for the page to settle before the next step?
80
+ โ”‚ โ”œโ”€ Element appears? โ†’ wait <ref|selector>
81
+ โ”‚ โ”œโ”€ Text appears? โ†’ wait --text "..."
82
+ โ”‚ โ”œโ”€ URL changes? โ†’ wait --url "**/target"
83
+ โ”‚ โ””โ”€ Loading/network finishes? โ†’ wait --load networkidle
84
+ โ”œโ”€ Need to verify what changed after the action? โ†’ snapshot, get, or eval
85
+ โ””โ”€ Need to repeat many UI steps efficiently? โ†’ batch "goto ..." "click ..." "fill ..."
86
+ ```
87
+
88
+ Typical interactive flow:
34
89
 
35
90
  ```bash
91
+ browser4-cli goto https://example.com/login
92
+ browser4-cli snapshot -i --boxes
93
+ browser4-cli fill e3 "user@example.com"
94
+ browser4-cli fill e4 "secret" --submit
95
+ browser4-cli wait --load networkidle
96
+ browser4-cli snapshot -i
97
+ ```
98
+
99
+ ### How to Extract Data
100
+
101
+ ```
102
+ Need to extract data from a page?
103
+ โ”œโ”€ Interactive page (click, fill, scroll first)? โ†’ snapshot + refs, then extract
104
+ โ”œโ”€ Static page, one field? โ†’ htmlsnapshot get text "<selector>"
105
+ โ”œโ”€ Static page, all matches of one field? โ†’ htmlsnapshot get all text "<selector>"
106
+ โ”œโ”€ Static page, multiple correlated fields (title+price+url per item)?
107
+ โ”‚ โ†’ htmlsnapshot query --sql @query.sql
108
+ โ”œโ”€ Live JS / complex DOM logic? โ†’ eval --json
109
+ โ”œโ”€ Natural language ("find the product price")? โ†’ extract (needs LLM key)
110
+ โ””โ”€ High volume, many pages? โ†’ crawl or swarm with --sql
111
+ ```
112
+
113
+ ### How to Process at Scale
114
+
115
+ ```
116
+ Need to process multiple pages?
117
+ โ”œโ”€ Single list page (search results)? โ†’ htmlsnapshot query with DOM_LOAD_AND_SELECT
118
+ โ”œโ”€ List of known URLs (in a file)? โ†’ crawl --seed-file urls.txt --depth 0 --sql @query.sql
119
+ โ”œโ”€ Crawl from a start URL (follow links)? โ†’ crawl <url> --out-link-selector "..." --depth N
120
+ โ”œโ”€ Need parallel execution (high throughput)? โ†’ swarm create โ†’ swarm query --seed-file ...
121
+ โ”œโ”€ Repeated monitoring (check every hour)? โ†’ loop -- eval "..." -i 3600
122
+ โ””โ”€ Just a few URLs in a shell script?
123
+ โ†’ for url in ...; do browser4-cli goto "$url"; ... done
124
+ ```
125
+
126
+ ### How to Turn HTML into Spreadsheets โ€” Zero Tokens
127
+
128
+ [WebMiner](https://github.com/platonai/web-miner) runs ML clustering on downloaded HTML files to produce structured spreadsheets and interactive reports โ€” **no LLM tokens, everything runs locally.**
129
+
130
+ ```
131
+ Have HTML files and want structured data โ€” without tokens?
132
+ โ”œโ”€ < 20 pages? โ†’ browser4-cli crawl --seed-file urls.txt --depth 0 --sql @query.sql
133
+ โ”œโ”€ < 1,000 pages (small to medium)? โ†’ WebMiner Free (SMILE ML engine)
134
+ โ”‚ java -jar scent-miner.jar all ./pages/
135
+ โ”‚ โ†’ Interactive HTML report + Excel spreadsheets โ€” local, zero cost
136
+ โ”œโ”€ > 1,000 pages (production scale)? โ†’ WebMiner Commercial (Apache Spark ML)
137
+ โ”‚ Same encode โ†’ cluster โ†’ views pipeline, distributed across machines
138
+ โ””โ”€ Need to acquire pages first?
139
+ โ”œโ”€ Single pages: browser4-cli htmlsnapshot export
140
+ โ”œโ”€ Bulk download: browser4-cli crawl --seed-file urls.txt --depth 0
141
+ โ””โ”€ High throughput: browser4-cli swarm create โ†’ swarm query --seed-file ...
142
+ Then feed the HTML directory to WebMiner
143
+ ```
144
+
145
+ > **Pipeline:** `encode` (HTML โ†’ feature vectors โ†’ CSV) โ†’ `cluster` (KMeans, auto-detected K) โ†’ `views` (HTML report + Excel). Free tier uses the [SMILE](https://haifengl.github.io/) ML library for single-machine clustering (< 1,000 pages). Requires JDK 17+. See [web-miner](https://github.com/platonai/web-miner) for install instructions.
146
+
147
+ ---
148
+
149
+ ## ๐Ÿ“ฆ Installation
150
+
151
+ Manually installation is optional since your AI agent is smart enough to install it after reading the SKILL.
152
+
153
+ Install browser4-cli globally using npm (requires Node.js):
154
+
155
+ ```shell
36
156
  npm install -g browser4-cli
37
157
  browser4-cli install
38
158
  ```
39
159
 
40
- ### Standalone installers (no npm needed)
160
+ Or bootstrap the native binary directly with a single command:
41
161
 
42
162
  **Windows (PowerShell):**
43
163
  ```powershell
@@ -45,834 +165,576 @@ irm https://browser4.oss-cn-beijing.aliyuncs.com/scripts/install-browser4-cli.ps
45
165
  browser4-cli install
46
166
  ```
47
167
 
48
- **Linux / macOS:**
168
+ **Linux / macOS (bash):**
49
169
  ```bash
50
170
  curl -fsSL https://browser4.oss-cn-beijing.aliyuncs.com/scripts/install-browser4-cli.sh | bash
51
171
  browser4-cli install
52
172
  ```
53
173
 
54
- ## Quick start
174
+ ## ๐Ÿ’ก CLI Guide for Humans
175
+
176
+ `browser4-cli` is a human-usable browser automation shell, not just an agent backend. You can drive a real browser, inspect state, extract structured data, run X-SQL, orchestrate crawl/swarm jobs, manage server plugins and skills, and hand long-running work to built-in AI features.
177
+
178
+ If you want the embedded agent-facing instructions, see [skills/browser4-cli/SKILL.md](skills/browser4-cli/SKILL.md). This section is the human reference.
179
+
180
+ ### Quick start
55
181
 
56
182
  ```bash
57
183
  # Open a browser session
58
184
  browser4-cli open --headed https://browser4.io
59
185
 
60
- # Navigate to a page โ€” auto-opens a session if none is active
61
- browser4-cli goto https://browser4.io
62
-
63
- # Inspect the page โ€” note the eN labels on interactive nodes
186
+ # Inspect the page and get element refs
64
187
  browser4-cli snapshot --boxes
65
188
 
66
- # Interact using refs from the snapshot
189
+ # Interact using a ref from the snapshot
67
190
  browser4-cli click e15
68
- browser4-cli type e15 "Hello World"
69
- browser4-cli press e15 Enter
191
+ browser4-cli fill e16 "Browser4" --submit
70
192
 
71
- # Extract data with CSS selectors
72
- browser4-cli get text ".product-title"
73
- browser4-cli get attr ".product-image" data-src
193
+ # Extract data from the live page
194
+ browser4-cli get text "h1"
74
195
 
75
- # HTML snapshot with X-SQL
76
- browser4-cli htmlsnapshot capture
196
+ # Capture a static DOM snapshot for repeated extraction
77
197
  browser4-cli htmlsnapshot
78
198
  browser4-cli htmlsnapshot get text "#main-content"
79
199
  browser4-cli htmlsnapshot query --sql @query.sql
80
- browser4-cli htmlsnapshot grep -i "error"
81
200
 
82
- # AI-powered extraction and summarization (requires LLM key โ€” see LLM Configuration below)
83
- browser4-cli extract "product name, price, and rating as JSON"
84
- browser4-cli summarize "key points in 3 bullets"
201
+ # Save output
202
+ browser4-cli screenshot --full-page --filename page.png
203
+ browser4-cli pdf --filename page.pdf
204
+ ```
85
205
 
86
- # Autonomous agent task
87
- browser4-cli agent run "Search amazon for mechanical keyboards, compare the top 3, write a summary"
206
+ ### Mental model
88
207
 
89
- # Parallel scraping with swarm
90
- browser4-cli swarm create --max-open-tabs 12 --display-mode HEADLESS
91
- browser4-cli swarm submit --seed-file ./urls.txt --refresh
92
- browser4-cli swarm result scrape-task-1
208
+ 1. **Session-oriented**: commands work against the current browser session; use `-s <name>` for isolated named sessions.
209
+ 2. **Two page views**: `snapshot` is for interactive work with element refs like `e15`; `htmlsnapshot` is for DOM/X-SQL extraction with CSS selectors.
210
+ 3. **Interactive vs static extraction**: use `click`, `fill`, `type`, `press`, `wait` when the page must be manipulated first; use `htmlsnapshot query` when you need structured extraction from the DOM.
211
+ 4. **Synchronous vs async jobs**: `agent`, `swarm`, `crawl`, and async chat-style commands return task IDs you poll later.
93
212
 
94
- # Batch multiple commands
95
- browser4-cli batch "goto https://browser4.io" "snapshot" "screenshot"
213
+ ### Global options
96
214
 
97
- # Take a screenshot
98
- browser4-cli screenshot --full-page
215
+ These flags can appear before any command.
99
216
 
100
- # Manage cookies and storage
101
- browser4-cli cookie-list
102
- browser4-cli state-save session.json
217
+ | Flag | Meaning |
218
+ |---|---|
219
+ | `-h`, `--help [command\|category]` | Show top-level help, category help, or detailed command help |
220
+ | `--help-json` | Emit the machine-readable command reference |
221
+ | `-v`, `--version` | Print the CLI version |
222
+ | `-s`, `--session <name>` | Use a named session instead of the default session |
223
+ | `--server <url>` | Override the Browser4 server URL |
224
+ | `--timeout <seconds>` | Override the HTTP timeout for the current command |
225
+ | `--proxy <url>` | Proxy used for runtime downloads/install operations |
226
+ | `--json` | Emit machine-readable JSON only |
227
+ | `--pretty` | Pretty-print JSON output |
228
+ | `-q`, `--quiet` | Suppress normal human-readable output |
229
+ | `-tip`, `--show-tip` | Show a relevant tip on stderr after commands |
103
230
 
104
- # Close the session when done
105
- browser4-cli close
106
- ```
231
+ ### Key concepts before the command list
107
232
 
108
- ## Global options
233
+ #### Element refs vs CSS selectors
109
234
 
110
- | Flag | Description |
111
- |---|---|
112
- | `-h`, `--help [command]` | Print help (optionally for a command) |
113
- | `-v`, `--version` | Print version |
114
- | `-s <name>` | Named session (isolated state per name) |
115
- | `--server <url>` | Override Browser4 server URL |
116
- | `--proxy <url>` | HTTP proxy for runtime downloads only |
117
- | `--json` | Emit machine-parseable JSON to stdout |
118
- | `-q`, `--quiet` | Suppress normal output |
235
+ - `snapshot` returns accessibility-tree refs such as `e5`, `e12`, `e42`
236
+ - most interaction commands accept either a snapshot ref or a CSS selector
237
+ - `htmlsnapshot` commands use CSS selectors, not accessibility refs
119
238
 
120
- Sessions persist independently per name. Omit `-s` to use the default session
121
- (`~/.browser4/cli-state.json`). With `-s <name>`, state is stored under
122
- `~/.browser4/sessions/<name>.json`.
239
+ #### `snapshot` vs `htmlsnapshot`
123
240
 
124
- `--json` makes the CLI emit only the JSON envelope on stdout โ€” all human-readable
125
- text, tips, hints, and side information are suppressed (equivalent to `--quiet`
126
- but with structured output). Every successful command writes a single-line JSON
127
- envelope: `{"status":"ok","command":"<name>","output":{...}}`. Errors also
128
- produce a JSON envelope with `"status":"error"` and an `"error"` object.
241
+ | Tool | Best for | Input model | Output model |
242
+ |---|---|---|---|
243
+ | `snapshot` | clicking, typing, finding interactive elements | live accessibility tree | refs like `e15` |
244
+ | `htmlsnapshot` | DOM inspection, CSS extraction, X-SQL | stored HTML snapshot | CSS selectors and query results |
129
245
 
130
- ## Command reference
246
+ #### LLM configuration
131
247
 
132
- ### Session management
248
+ AI-powered commands such as `extract`, `summarize`, `chat`, `agent run`, and X-SQL `llm_*` functions require an LLM provider key.
249
+
250
+ | Provider | Environment variables |
251
+ |---|---|
252
+ | DeepSeek | `DEEPSEEK_API_KEY` |
253
+ | OpenRouter | `OPENROUTER_API_KEY`, `OPENROUTER_MODEL_NAME`, `OPENROUTER_BASE_URL` |
254
+ | Volcengine | `VOLCENGINE_API_KEY`, `VOLCENGINE_MODEL_NAME`, `VOLCENGINE_BASE_URL` |
255
+ | OpenAI-compatible | `OPENAI_API_KEY`, `OPENAI_MODEL_NAME`, `OPENAI_BASE_URL` |
256
+ | Aliyun Qwen | `OPENAI_API_KEY`, `OPENAI_MODEL_NAME`, `OPENAI_BASE_URL` |
257
+
258
+ ```bash
259
+ export DEEPSEEK_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
260
+ ```
261
+
262
+ ### Complete command reference
263
+
264
+ #### Session lifecycle and server administration
133
265
 
134
266
  | Command | Description |
135
267
  |---|---|
136
- | `open [url]` | Open or reuse a browser session. `--headed` / `--headless`, `--profile <path>`, `--profile-mode <mode>` (temporary / sequential / default), `--interact-level <level>` (FASTEST / FAST / DEFAULT). |
137
- | `attach` | Attach to an existing browser via CDP endpoint or channel name. `--cdp <url\|channel>` (e.g. `http://localhost:9222` or `chrome`), `--endpoint <url>` for remote Browser4 servers. |
138
- | `close` | Close the active session. |
139
- | `list` | List sessions with status (Active / Stale / Unknown). `--all` to list across workspaces. |
140
- | `close-all` | Close all sessions, keep the backend running. |
141
- | `kill-all` | Forcefully stop the backend and all browser processes. |
268
+ | `open [url]` | Open a browser session or reconnect to an existing one. Supports `--headed`, `--headless`, `--profile <path>`, `--profile-mode <DEFAULT\|SYSTEM_DEFAULT\|SEQUENTIAL\|TEMPORARY>`, `--interact-level <FASTEST\|FAST\|DEFAULT>`. |
269
+ | `attach` | Attach to an existing browser via CDP or the Browser4 extension. Supports `--cdp <url\|port\|channel>` and remote endpoint options. |
270
+ | `close` | Close the active browser session. |
271
+ | `list` | List browser sessions with their status and next-open behavior. Supports `--all`. |
272
+ | `session-default <name>` | Make a named session become the default unnamed session. |
273
+ | `close-all` | Close all sessions without stopping the backend. |
274
+ | `kill-all` | Force-stop the backend and Browser4-managed browser processes. |
142
275
  | `stop` | Gracefully stop the Browser4 server. |
143
- | `status` | Check whether the backend is reachable. `--server <url>` to check a specific server. |
144
- | `doctor` | Run system diagnostics. `--server <url>`, `--file <log-name>`, `--lines <n>`. |
276
+ | `status` | Show server version, port, and health. |
277
+ | `doctor` | Run diagnostics: build info, LLM status, stale daemon cleanup, optional repair. Supports `--verbose` and `--fix`. |
278
+ | `doctor log [name]` | List, view, tail, or grep backend log files. Supports `--tail`, grep-style flags, and `doctor log <name> grep <pattern>`. |
279
+ | `doctor metrics [filter]` | List, filter, or grep backend metrics. Supports `doctor metrics grep <pattern>`. |
280
+ | `delete-data` | Delete session data. |
281
+ | `install` | Install the Browser4 runtime bundle. Supports `--tag <version>` and `--force`. |
282
+ | `upgrade` | Upgrade the CLI/runtime bundle. Supports `--tag <version>` and `--force`. |
283
+ | `uninstall` | Remove global installs and runtime data. Supports `-y`, `--yes`, and `--dry-run`. |
145
284
 
146
285
  ```bash
147
286
  browser4-cli open --headed https://example.com
148
- browser4-cli open --profile-mode temporary https://example.com
149
287
  browser4-cli attach --cdp chrome
150
- browser4-cli list
151
- browser4-cli status
288
+ browser4-cli doctor --verbose
289
+ browser4-cli doctor log server.log --tail
290
+ browser4-cli doctor metrics grep request
152
291
  ```
153
292
 
154
- ### Navigation
293
+ #### Navigation
155
294
 
156
295
  | Command | Description |
157
296
  |---|---|
158
- | `goto <url>` | Navigate to a URL. Auto-opens a session if none is active. |
159
- | `go-back` | Go back to the previous page. |
160
- | `go-forward` | Go forward to the next page. |
297
+ | `goto <url>` | Navigate to a URL; auto-opens/reconnects a session if needed. |
298
+ | `go-back` | Go back in browser history. |
299
+ | `go-forward` | Go forward in browser history. |
161
300
  | `reload` | Reload the current page. |
162
301
 
163
- ```bash
164
- browser4-cli goto https://example.com
165
- browser4-cli -s mysession goto https://example.com
166
- ```
302
+ #### Core interaction
167
303
 
168
- ### Page interaction
304
+ All interaction commands accept a snapshot ref such as `e15` or a CSS selector unless noted otherwise. Most of them also support `--no-snapshot` to skip the automatic post-action accessibility snapshot.
169
305
 
170
306
  | Command | Description |
171
307
  |---|---|
172
- | `click <ref> [button]` | Click an element. `--modifiers` for modifier keys, `--follow` to detect and switch to new tabs opened by the click. |
173
- | `dblclick <ref> [button]` | Double-click an element. `--modifiers` for modifier keys, `--follow` to detect and switch to new tabs. |
308
+ | `click <ref> [button]` | Click an element. Supports `--modifiers`, `--follow`, `--auto-dismiss-dialogs`. |
309
+ | `dblclick <ref> [button]` | Double-click an element. Supports `--modifiers`, `--follow`, `--auto-dismiss-dialogs`. |
174
310
  | `hover <ref>` | Hover over an element. |
175
- | `drag <startRef> <endRef>` | Drag and drop between two elements. |
176
- | `fill <ref> <text>` | Fill text into an editable element. `--submit` to press Enter after. `--verify` to confirm. |
177
- | `type <text> [ref]` | Type text. `--submit`, `--verify`, `--focus` (click first to focus). |
178
- | `select <ref> <val>` | Select an option in a dropdown. `--verify` to confirm. |
179
- | `check <ref>` | Check a checkbox or radio. |
180
- | `uncheck <ref>` | Uncheck a checkbox or radio. |
311
+ | `fill <ref> <text>` | Clear and fill text into an editable field. Supports `--submit`, `--verify`. |
312
+ | `type <text> [ref]` | Type text into the focused element or a target element. Supports `--submit`, `--verify`, `--focus`, `--interactable-timeout`. |
313
+ | `press <key> [ref]` | Press a key on the focused element or a target element. Supports `--verify`, `--follow`. |
314
+ | `select <ref> <value>` | Select a dropdown value. Supports `--verify`. |
315
+ | `check <ref>` | Check a checkbox or radio button. |
316
+ | `uncheck <ref>` | Uncheck a checkbox or radio button. |
317
+ | `drag <startRef> <endRef>` | Drag and drop from one element to another. |
318
+ | `wait [target]` | Wait for a selector/ref, duration, text, URL pattern, page-load state, or JavaScript expression. Supports `--timeout`, `--text`, `--url`, `--load`, `--fn`. |
181
319
 
182
- All interaction commands accept element references from `snapshot` (e.g. `e15`)
183
- or CSS selectors (e.g. `#submit-btn`, `.menu-item`).
320
+ `wait --load` accepts `domcontentloaded`, `load`, and `networkidle`.
184
321
 
185
322
  ```bash
186
- browser4-cli click e15
187
- browser4-cli fill e7 "John Doe" --submit
188
- browser4-cli type "search term" e3
189
- browser4-cli select e12 "option-value"
323
+ browser4-cli click e8 --follow
324
+ browser4-cli fill e4 "john@example.com" --submit
325
+ browser4-cli type "Browser4" e7 --verify
326
+ browser4-cli wait --text "Success"
327
+ browser4-cli wait --load networkidle
190
328
  ```
191
329
 
192
- ### Keyboard & mouse
330
+ #### Keyboard and mouse
193
331
 
194
332
  | Command | Description |
195
333
  |---|---|
196
- | `press <key> [ref]` | Press a key (`a`, `Enter`, `ArrowLeft`, `Escape`). Supports `--verify`, `--follow` (detect new tabs). |
197
334
  | `keydown <key>` | Press and hold a key. |
198
- | `keyup <key>` | Release a key. |
199
- | `mousemove <x> <y>` | Move mouse to coordinates. |
200
- | `mousedown [button]` | Press mouse button (defaults to left). |
201
- | `mouseup [button]` | Release mouse button. |
202
- | `mousewheel <dx> <dy>` | Scroll the mouse wheel. |
203
- | `scroll <direction> <pixels>` | Scroll the page (`up` / `down` / `left` / `right`). |
335
+ | `keyup <key>` | Release a held key. |
336
+ | `mousemove <x> <y>` | Move the mouse to screen/page coordinates. |
337
+ | `mousedown [button]` | Press a mouse button. |
338
+ | `mouseup [button]` | Release a mouse button. |
339
+ | `mousewheel <dx> <dy>` | Scroll using a wheel delta. |
340
+ | `scroll <direction> <pixels>` | Scroll the page `up`, `down`, `left`, or `right`. |
204
341
 
205
- ```bash
206
- browser4-cli press Enter e7
207
- browser4-cli mousemove 200 400
208
- browser4-cli scroll down 300
209
- ```
210
-
211
- ### Waiting & dialogs
342
+ #### Page inspection and live extraction
212
343
 
213
344
  | Command | Description |
214
345
  |---|---|
215
- | `wait [target]` | Wait for a condition โ€” six modes available. |
216
- | `dialog-accept [prompt]` | Accept a browser dialog (alert, confirm, prompt). |
217
- | `dialog-dismiss` | Dismiss a browser dialog. |
346
+ | `snapshot` | Capture an accessibility-tree snapshot. Supports `--boxes`, `-i/--interactive`, `-u/--urls`, `-c/--compact`, `--no-compact`, `-d/--depth`, `-l/--limit`, `-s/--selector`, `--raw`, `--stdout`, `-vp/--viewport`, `--filename`. |
347
+ | `snapshot grep <pattern>` | Search saved/current snapshot YAML with grep-style flags such as `-i`, `-v`, `-c`, `-l`, `-F`, `-w`, `-A`, `-B`, `-C`, `--selector`, `--page`, `--page-size`, `--all`. |
348
+ | `snapshot list` | List saved snapshot files with timestamps and sizes. |
349
+ | `snapshot clean` | Remove old snapshot files. Supports `--dry-run`. |
350
+ | `get <mode> <selector> [name]` | Extract `text`, `html`, `box`, `styles`, `property`, or `attr` from a live page element. |
351
+ | `eval [expression] [ref]` | Evaluate JavaScript on the page or an element. Supports `--file`, `--stdin`, `--base64`, `--await`, `--wait-selector`, `--json`. |
352
+ | `console [min-level]` | List browser console messages. Supports `--clear`. |
353
+ | `cdp <method>` | Send an arbitrary Chrome DevTools Protocol command. Supports `--json <params>`. |
354
+ | `generate-locator <ref>` | Generate the best CSS selector for a snapshot ref or existing selector. |
355
+ | `resize <width> <height>` | Resize the browser window. |
356
+ | `dialog-accept [prompt]` | Accept an alert/confirm/prompt dialog, optionally filling the prompt. |
357
+ | `dialog-dismiss` | Dismiss an alert/confirm/prompt dialog. |
218
358
 
219
- `wait` supports six modes, selected by which option you provide:
359
+ `get` modes:
220
360
 
221
- | Mode | Syntax | Example |
361
+ | Mode | Meaning | Example |
222
362
  |---|---|---|
223
- | **selector** | `wait <ref\|selector>` | `browser4-cli wait e1` |
224
- | **time** | `wait <milliseconds>` | `browser4-cli wait 2000` |
225
- | **text** | `wait --text <text>` | `browser4-cli wait --text "Success"` |
226
- | **url** | `wait --url <glob>` | `browser4-cli wait --url "**/dashboard"` |
227
- | **load** | `wait --load <state>` | `browser4-cli wait --load networkidle` |
228
- | **fn** | `wait --fn <JS expr>` | `browser4-cli wait --fn "window.ready === true"` |
229
-
230
- All modes accept `--timeout <ms>` (default: 30000). Load states: `networkidle`,
231
- `domcontentloaded`, `load`.
232
-
233
- ### Screenshots & PDF
234
-
235
- | Command | Description |
236
- |---|---|
237
- | `screenshot [ref]` | Take a screenshot. `--filename <path>`, `--full-page`, `--viewport <n>`. Optionally of a specific element. |
238
- | `pdf` | Save page as PDF. `--filename <path>`. |
363
+ | `text` | visible inner text | `browser4-cli get text ".price"` |
364
+ | `html` | inner HTML | `browser4-cli get html "#main"` |
365
+ | `box` | bounding box | `browser4-cli get box "#hero"` |
366
+ | `styles` | computed styles | `browser4-cli get styles e9` |
367
+ | `property` | DOM property value | `browser4-cli get property "input" value` |
368
+ | `attr` | HTML attribute value | `browser4-cli get attr "a" href` |
239
369
 
240
370
  ```bash
241
- browser4-cli screenshot --full-page --filename page.png
242
- browser4-cli screenshot --viewport 0 --filename top.png
243
- browser4-cli pdf --filename page.pdf
371
+ browser4-cli snapshot -i --boxes
372
+ browser4-cli snapshot grep -C 2 "button"
373
+ browser4-cli eval "document.title"
374
+ browser4-cli eval --file script.js --await
375
+ browser4-cli console warn
376
+ browser4-cli cdp Runtime.evaluate --json '{"expression":"document.title"}'
244
377
  ```
245
378
 
246
- ### Tabs
379
+ #### HTML snapshot and X-SQL extraction
380
+
381
+ `htmlsnapshot` captures a stored raw DOM snapshot and is the center of Browser4's structured extraction workflow.
247
382
 
248
383
  | Command | Description |
249
384
  |---|---|
250
- | `tab-list` | List all tabs with their zero-based index and stable GUID. Use `--json` for full GUIDs. |
251
- | `tab-new [url]` | Open a new tab. |
252
- | `tab-close [index]` | Close a tab (current tab if no index). Use `--guid <guid>` for GUID-based close. |
253
- | `tab-select <index>` | Switch to a tab by index. Use `--guid <guid>` for GUID-based select. |
385
+ | `htmlsnapshot` | Short form of `htmlsnapshot capture`. |
386
+ | `htmlsnapshot capture` | Capture and store a static HTML snapshot with metadata about the page and interactive elements. |
387
+ | `htmlsnapshot get <field> [selector] [name]` | Extract the first matching `text`, `html`, or `attr` from the stored snapshot. |
388
+ | `htmlsnapshot get all <field> [selector] [name]` | Extract all matching values from the stored snapshot. Supports `--offset` and `--limit`. |
389
+ | `htmlsnapshot query [url]` | Run X-SQL. Supports `--sql <query\|@file>`, `--sql-stdin`, `--sql-base64`, result pagination, and extraction-focused output flags. |
390
+ | `htmlsnapshot export` | Export stored HTML to a file. Supports positional file path or `--file <path>` plus `--clean`. |
391
+ | `htmlsnapshot summary` | Generate a compressed Web Page Summary Index (WPSI). |
392
+ | `htmlsnapshot grep <pattern>` | Search stored HTML with grep-style flags. |
393
+ | `htmlsnapshot inspect [selector]` | Discover recurring DOM patterns and selector candidates. Supports `--max`, `--depth`, `--stdin`, `--selector-base64`. |
394
+
395
+ Important rules:
396
+
397
+ - use `snapshot` when you need refs and interaction
398
+ - use `htmlsnapshot` when you need repeated DOM extraction
399
+ - `htmlsnapshot query --sql @query.sql` is the recommended way to avoid shell quoting issues
400
+ - for correlated list extraction, prefer `htmlsnapshot query` over repeated `get all`
254
401
 
255
402
  ```bash
256
- browser4-cli tab-list
257
- browser4-cli tab-list --json # JSON output with full GUIDs
258
- browser4-cli tab-select 1
259
- browser4-cli tab-select --guid 1B46D74FB # select by stable GUID
260
- browser4-cli tab-new https://example.com
261
- browser4-cli tab-close 1
262
- browser4-cli tab-close --guid 1B46D74FB # close by stable GUID
403
+ browser4-cli htmlsnapshot
404
+ browser4-cli htmlsnapshot get text "#productTitle"
405
+ browser4-cli htmlsnapshot get all text ".result-title" --offset 10 --limit 5
406
+ browser4-cli htmlsnapshot inspect ".s-result-item" --depth 6 --max 20
407
+ browser4-cli htmlsnapshot export --file page.html --clean
408
+ browser4-cli htmlsnapshot query --sql @query.sql
263
409
  ```
264
410
 
265
- ### Element inspection
411
+ For deep X-SQL usage, see [skills/browser4-cli/references/htmlsnapshot.md](skills/browser4-cli/references/htmlsnapshot.md) and [skills/browser4-cli/references/x-sql-dom-load-select.md](skills/browser4-cli/references/x-sql-dom-load-select.md).
412
+
413
+ #### Screenshots and PDF
266
414
 
267
415
  | Command | Description |
268
416
  |---|---|
269
- | `snapshot` | Capture an accessibility snapshot. See [Snapshot](#snapshot) below. |
270
- | `get <mode> <selector> [name]` | Extract data from a page element in one of six modes (see below). |
271
- | `eval <expression> [ref]` | Evaluate JavaScript on the page or a target element. `--file <path>`, `--base64`, or `--stdin` to provide the expression. `--json` to wrap scalar results. |
272
- | `generate-locator <ref>` | Generate a stable CSS selector path for an element. |
273
- | `htmlsnapshot` | Short form of `htmlsnapshot capture`. Capture a static HTML snapshot. See [HTML Snapshot](#dom-snapshot) below. |
274
- | `htmlsnapshot capture` | Capture a static HTML snapshot. See [HTML Snapshot](#dom-snapshot) below. |
275
- | `extract <instruction>` | Extract structured data with AI. `--schema <json>` for typed output. `--filename <path>`, `--raw`. |
276
- | `summarize [instruction]` | Summarize page content with AI. `--selector <css>`, `--filename <path>`, `--raw`. |
417
+ | `screenshot [ref]` | Take a page or element screenshot. Supports `--filename`, `--full-page`, `--viewport`. |
418
+ | `pdf` | Save the current page as PDF. Supports `--filename`. |
277
419
 
278
- `get` modes:
420
+ #### Tabs
279
421
 
280
- | Mode | Returns | Example |
281
- |---|---|---|
282
- | `text` | Visible inner text | `browser4-cli get text ".price"` |
283
- | `html` | Inner HTML | `browser4-cli get html e3` |
284
- | `box` | Bounding box `{x,y,w,h}` | `browser4-cli get box "#header"` |
285
- | `styles` | Computed CSS styles | `browser4-cli get styles e9` |
286
- | `property` | DOM property value | `browser4-cli get property "input" value` |
287
- | `attr` | HTML attribute value | `browser4-cli get attr "a.link" href` |
288
-
289
- ```bash
290
- browser4-cli eval "document.title"
291
- browser4-cli eval "el => el.textContent" e15
292
- browser4-cli eval --file script.js
293
- browser4-cli eval --base64 ZG9jdW1lbnQudGl0bGU=
294
- browser4-cli generate-locator e5
295
- browser4-cli extract "product name, price, and rating"
296
- browser4-cli extract "contacts" --schema '{"type":"object","properties":{"name":{"type":"string"},"email":{"type":"string"}}}'
297
- browser4-cli summarize --selector "#reviews"
298
- ```
422
+ | Command | Description |
423
+ |---|---|
424
+ | `tab-list` | List open tabs with indexes, titles, and URLs; use `--json` for full GUIDs. |
425
+ | `tab-new [url]` | Open a new tab, optionally navigating to a URL. |
426
+ | `tab-close [index]` | Close a tab by index; supports `--guid <guid>`. |
427
+ | `tab-select <index>` | Switch to a tab by index; supports `--guid <guid>`. |
299
428
 
300
- ### Browser storage
429
+ #### Browser storage and local page data
301
430
 
302
431
  | Command | Description |
303
432
  |---|---|
304
- | `state-save [path]` | Save cookies & localStorage to a JSON file. |
305
- | `state-load <path>` | Restore cookies & localStorage from a saved state. |
306
- | `cookie-list` | List cookies. `--domain`, `--path` filters. |
433
+ | `state-save [filename]` | Save cookies and localStorage to a JSON file. |
434
+ | `state-load <filename>` | Restore cookies and localStorage from a JSON file. |
435
+ | `cookie-list` | List cookies. Supports `--domain`, `--path`. |
307
436
  | `cookie-get <name>` | Get a cookie by name. |
308
- | `cookie-set <name> <value>` | Set a cookie. `--domain`, `--path`, `--expires`, `--httpOnly`, `--secure`, `--sameSite` (Strict / Lax / None). |
309
- | `cookie-delete <name>` | Delete a cookie. `--domain`, `--path` overrides. |
437
+ | `cookie-set <name> <value>` | Set a cookie. Supports `--domain`, `--path`, `--expires`, `--httpOnly`, `--secure`, `--sameSite`. |
438
+ | `cookie-delete <name>` | Delete a cookie by name. Supports `--domain`, `--path`. |
310
439
  | `cookie-clear` | Clear all cookies. |
311
440
  | `localstorage-list` | List localStorage entries. |
312
- | `localstorage-get <key>` | Get a localStorage value. |
313
- | `localstorage-set <key> <value>` | Set a localStorage value. |
441
+ | `localstorage-get <key>` | Read a localStorage key. |
442
+ | `localstorage-set <key> <value>` | Set a localStorage key. |
314
443
  | `localstorage-delete <key>` | Delete a localStorage key. |
315
- | `localstorage-clear` | Clear all localStorage. |
444
+ | `localstorage-clear` | Clear localStorage. |
316
445
  | `sessionstorage-list` | List sessionStorage entries. |
317
- | `sessionstorage-get <key>` | Get a sessionStorage value. |
318
- | `sessionstorage-set <key> <value>` | Set a sessionStorage value. |
446
+ | `sessionstorage-get <key>` | Read a sessionStorage key. |
447
+ | `sessionstorage-set <key> <value>` | Set a sessionStorage key. |
319
448
  | `sessionstorage-delete <key>` | Delete a sessionStorage key. |
320
- | `sessionstorage-clear` | Clear all sessionStorage. |
449
+ | `sessionstorage-clear` | Clear sessionStorage. |
450
+ | `webdb export <dir>` | Export pages from the Browser4 web database to a local directory. |
451
+ | `webdb normalize <url>` | Normalize a URL into the web database key format. |
321
452
 
322
- ```bash
323
- browser4-cli state-save auth.json
324
- browser4-cli state-load auth.json
325
- browser4-cli cookie-set token abc123 --httpOnly --secure --sameSite Lax
326
- browser4-cli cookie-list --domain example.com
327
- ```
453
+ #### AI extraction, chat, and autonomous agent tasks
328
454
 
329
- ### Batch & loop
455
+ These commands require an LLM key.
330
456
 
331
457
  | Command | Description |
332
458
  |---|---|
333
- | `batch [command...]` | Execute multiple commands in one invocation. `--bail` to stop on first failure. `--json` to read commands from stdin JSON. |
334
- | `loop <task>` | Execute a task repeatedly on an interval. Supports plain text tasks, X-SQL, shell commands (`--shell`), and CLI subcommands (after `--`). |
335
-
336
- `batch` only supports DOM operations (navigation, keyboard, mouse, core
337
- interactions, screenshots, tabs). Session lifecycle commands (`open`, `close`)
338
- must run separately.
339
-
340
- ```bash
341
- # Batch form fill
342
- browser4-cli batch "fill e1 'John'" "fill e2 'john@example.com'" "click e3"
343
-
344
- # Stop on first failure
345
- browser4-cli batch --bail "goto https://example.com" "click e1" "screenshot"
346
-
347
- # Pipe commands as JSON
348
- echo '[
349
- ["goto", "https://example.com"],
350
- ["fill", "#name", "Bob"],
351
- ["click", "#submit"]
352
- ]' | browser4-cli batch --json
353
-
354
- # Loop: run every 5 minutes, 10 iterations
355
- browser4-cli loop "load https://example.com and extract the page title" -i 300 -n 10
356
-
357
- # Loop a shell command
358
- browser4-cli loop --shell "curl -s https://api.example.com/health" -i 60 -n 10
459
+ | `extract <instruction>` | Extract structured data from the current page. Supports `--schema <json\|@file>`, `--filename`, `--raw`, `--stdout`. |
460
+ | `summarize [instruction]` | Summarize the current page. Supports `--selector`, `--filename`, `--raw`, `--stdout`. |
461
+ | `chat <message>` | Send a plain AI chat request without auto-appended browser context. |
462
+ | `chat-result <id>` | Retrieve the result of an async chat task. |
463
+ | `agent run <task>` | Submit an autonomous browser task and immediately receive a task ID. |
464
+ | `agent status <id>` | Check a running task. |
465
+ | `agent result <id>` | Fetch a completed result. |
466
+ | `agent list` | List tracked agent tasks and their status. |
467
+
468
+ ```bash
469
+ browser4-cli extract "product name, price, rating"
470
+ browser4-cli extract "contacts" --schema @schema.json
471
+ browser4-cli summarize --selector "#reviews"
472
+ browser4-cli agent run "Go to amazon.com, compare the first 3 keyboards, write a summary"
473
+ browser4-cli agent status agent-task-1
359
474
  ```
360
475
 
361
- ### Server management
476
+ #### Batch and loop automation
362
477
 
363
478
  | Command | Description |
364
479
  |---|---|
365
- | `install` | Download the Browser4 runtime bundle. `--tag <version>`, `--force`. |
366
- | `upgrade` | Upgrade the runtime. `--tag <version>`, `--force`. |
367
- | `uninstall` | Remove browser4-cli and its runtime data. `-y` / `--yes` to skip confirmation, `--dry-run` to preview. |
480
+ | `batch [command...]` | Execute multiple commands in one invocation. Supports `--bail` and `--json` for stdin-driven command arrays. |
481
+ | `loop [task]` | Run a task repeatedly. Supports `--name`, `-i/--interval`, `-n/--count`, `-t/--timeout`, `--shell`, `--list`, `--pause`, `--resume`, `--pause-all`, `--resume-all`, `--stop`, `--stop-all`, `--status`, `--history`, `--keep-state`. |
482
+
483
+ Batch-compatible commands:
484
+
485
+ ```text
486
+ goto go-back go-forward reload press type keydown keyup
487
+ click dblclick hover fill select check uncheck drag
488
+ mousemove mousedown mouseup mousewheel scroll wait
489
+ get eval snapshot screenshot pdf dialog-accept dialog-dismiss
490
+ resize tab-list tab-new tab-close tab-select
491
+ ```
368
492
 
369
493
  ```bash
370
- browser4-cli install
371
- browser4-cli install --tag v4.11.0
372
- browser4-cli upgrade --force
373
- browser4-cli uninstall --dry-run
374
- browser4-cli uninstall -y
494
+ browser4-cli batch --bail "goto https://example.com" "snapshot" "screenshot"
495
+ browser4-cli loop "load https://example.com and extract the title" -i 300 -n 10
496
+ browser4-cli loop --shell "curl -s https://api.example.com/health" -i 60
497
+ browser4-cli loop --list
375
498
  ```
376
499
 
377
- ### Skills
500
+ #### Swarm and crawl for scale
378
501
 
379
- Manage bundled skill files embedded in the browser4-cli binary. Skill files are AI agent
380
- instructions that always match the installed CLI version.
502
+ The `co` prefix is accepted as an alias for `swarm`.
381
503
 
382
504
  | Command | Description |
383
505
  |---|---|
384
- | `skills` | List all bundled skill names. Same as `skills list`. |
385
- | `skills list` | List available bundled skills with file counts. |
386
- | `skills get <name>` | Output a skill's SKILL.md content. `--full` includes references and templates. `--all` outputs every skill. |
387
- | `skills path [name]` | Print the skills directory path. With a name, prints the path to that skill's subdirectory. |
388
- | `skills unpack [dest]` | Unpack bundled skill files to a directory (defaults to the skills directory). |
389
-
390
- Skill files are unpacked to the versioned installation directory during `browser4-cli install`.
391
- Use `skills unpack` to refresh or relocate skill files without reinstalling.
392
- Set `BROWSER4_SKILLS_DIR` to override the skills directory path.
506
+ | `swarm create` | Create a parallel scraping session. Supports `--profile-mode`, `--max-open-tabs`, `--max-browser-contexts`, `--display-mode`. |
507
+ | `swarm submit [url]` | Submit URLs or X-SQL payloads as jobs. Supports `--seed-file`, `--sql`, `--deadline`, `--expires`, `--refresh`, `--parse`. |
508
+ | `swarm query <url>` | Run an X-SQL extraction job against one or more loaded pages. Supports `--sql`, `--seed-file`, `--deadline`, `--expires`, `--refresh`. |
509
+ | `swarm status <id>` | Check a swarm task status. |
510
+ | `swarm result <id>` | Fetch a completed swarm result. |
511
+ | `swarm list` | List tracked swarm tasks. |
512
+ | `swarm close` | Close the swarm session and release browser resources. |
513
+ | `crawl [url]` | Crawl from a URL or seed file. Supports `--seed-file`, `--sql`, `--sql-stdin`, `--sql-base64`, `--format`, `--output`, `-d/--depth`, `-ol/--out-link-selector`, `-olp/--out-link-pattern`, `-tl/--top-links`, `-a/--args`, `--refresh`, `--parse`, `--expires`, `-p/--priority`, `--page-load-timeout`, `--ignore-url-query`, `--no-norm`, `--readonly`, `-bg/--background`. |
514
+ | `crawl status <id>` | Check crawl task status. |
515
+ | `crawl result <id>` | Fetch crawl results. |
516
+ | `crawl cancel <id>` | Cancel a running crawl. |
517
+ | `crawl clear` | Remove terminal-state crawl tasks; supports force-style cleanup options. |
518
+ | `crawl list` | List tracked crawl tasks. |
393
519
 
394
520
  ```bash
395
- browser4-cli skills # List bundled skills
396
- browser4-cli skills get browser4-cli # Get the CLI skill's main content
397
- browser4-cli skills get browser4-cli --full # Include references and templates
398
- browser4-cli skills get --all # Output every skill
399
- browser4-cli skills path # Print skills root directory
400
- browser4-cli skills path browser4-cli # Print path to a specific skill
401
- browser4-cli skills unpack # Unpack to default skills directory
402
- browser4-cli skills unpack /custom/path # Unpack to a custom directory
521
+ browser4-cli swarm create --max-open-tabs 12 --display-mode HEADLESS
522
+ browser4-cli swarm query --seed-file urls.txt --sql @query.sql --refresh
523
+ browser4-cli crawl "https://example.com" --depth 2 --out-link-selector "a[href]"
524
+ browser4-cli crawl list
403
525
  ```
404
526
 
405
- ### Other
406
-
407
- | Command | Description |
408
- |---|---|
409
- | `resize <w> <h>` | Resize the browser window. |
410
- | `delete-data` | Delete session data (cookies, storage, cache). |
411
- | `console [min-level]` | List console messages. `--clear` to clear. |
412
- | `upload <ref> <file>` | Upload files to a file input. |
413
-
414
- ---
415
-
416
- ## Commands with subcommands
417
-
418
- ### Snapshot
527
+ #### Bundled skill files vs installed runtime skills
419
528
 
420
- `snapshot` captures an accessibility tree of the current page. Every interactive
421
- element is labeled with a ref (`e15`, `e42`) that you can pass directly to
422
- `click`, `type`, `fill`, and other interaction commands.
423
-
424
- ```
425
- browser4-cli snapshot [options]
426
- browser4-cli snapshot grep [OPTIONS] <pattern>
427
- ```
529
+ Browser4 has two different "skill" surfaces:
428
530
 
429
- #### snapshot
531
+ 1. **`skills ...`** manages bundled, embedded skill documents that ship with the CLI.
532
+ 2. **`skill-*`** manages installed runtime skills exposed by the backend.
430
533
 
431
- Capture the accessibility snapshot.
534
+ ##### Bundled CLI skills
432
535
 
433
- | Option | Description |
536
+ | Command | Description |
434
537
  |---|---|
435
- | `--filename <path>` | Save snapshot to file instead of stdout |
436
- | `--boxes` | Include bounding boxes `[box=x,y,w,h]` per element |
437
- | `-i`, `--interactive` | Show only interactive elements |
438
- | `-u`, `--urls` | Include href URLs for link elements |
439
- | `-c`, `--compact` | Remove empty structural nodes (default) |
440
- | `--no-compact` | Include all structural nodes |
441
- | `-d`, `--depth <n>` | Limit tree depth |
442
- | `-l`, `--limit <n>` | Cap total rendered nodes |
443
- | `-s`, `--selector <css>` | Scope snapshot to a CSS selector |
444
- | `--raw`, `--stdout` | Print directly to stdout (for piping) |
445
- | `-vp`, `--viewport <spec>` | Capture specific viewports (e.g. `0,2,4` or `1-3`) |
446
-
447
- ```bash
448
- # Full snapshot with bounding boxes
449
- browser4-cli snapshot --boxes
450
-
451
- # Interactive elements only, depth-limited
452
- browser4-cli snapshot -i -c -d 5
453
-
454
- # Scope to a specific section, pipe to grep
455
- browser4-cli snapshot -s "#main-content" --raw | grep "button"
456
-
457
- # Capture specific viewports
458
- browser4-cli snapshot --viewport 0,2,4
459
- ```
538
+ | `skills` | List bundled skill names. |
539
+ | `skills list` | Same as `skills`. |
540
+ | `skills get <name>` | Print a skill's `SKILL.md`. Supports `--full` and `--all`. |
541
+ | `skills path [name]` | Print the bundled skill directory path. |
542
+ | `skills unpack [dest]` | Unpack bundled skill files to a directory. |
460
543
 
461
- #### snapshot grep
544
+ ##### Installed runtime skills
462
545
 
463
- Search the accessibility-tree YAML with regex patterns and grep-style output.
464
- Line numbers are shown by default.
465
-
466
- | Flag | Description |
546
+ | Command | Description |
467
547
  |---|---|
468
- | `-i` | Case-insensitive matching |
469
- | `-A N`, `-B N`, `-C N` | Context lines after / before / around each match |
470
- | `-v` | Invert match (non-matching lines) |
471
- | `-c` | Print only count of matching lines |
472
- | `-l` | Print only whether matches exist |
473
- | `-F` | Treat pattern as a literal string |
474
- | `-w` | Match whole words only |
475
- | `--no-line-number` | Suppress line numbers |
476
- | `--selector <css>` | Scope search to a CSS selector |
477
- | `--page N`, `--page-size N`, `--all` | Output pagination (2000 lines per page default) |
478
-
479
- ```bash
480
- browser4-cli snapshot grep -i error
481
- browser4-cli snapshot grep -C 2 "timeout"
482
- browser4-cli snapshot grep -F -w "Error" --selector main
483
- ```
484
-
485
- ---
548
+ | `skill-list` | List installed backend skills. |
549
+ | `skill-info <id>` | Show detailed skill metadata. |
550
+ | `skill-install <path>` | Install a skill from a directory containing `SKILL.md`. Supports `--overwrite`. |
551
+ | `skill-uninstall <id>` | Remove a skill by ID. |
552
+ | `skill-reload <id>` | Reload a skill from its source directory. |
486
553
 
487
- ### HTML Snapshot
554
+ #### Progressive experience memory
488
555
 
489
- `htmlsnapshot` captures a **static HTML snapshot** of the current page โ€” a full
490
- HTML capture stored in the backend that can be queried repeatedly without
491
- re-fetching. Unlike the accessibility `snapshot`, this works against the raw DOM.
556
+ These commands operate on Browser4's learned experience store.
492
557
 
493
- ```
494
- browser4-cli htmlsnapshot capture
495
- browser4-cli htmlsnapshot
496
- browser4-cli htmlsnapshot get <field> [selector] [name]
497
- browser4-cli htmlsnapshot get all <field> [selector] [name]
498
- browser4-cli htmlsnapshot query [url] --sql <query>
499
- browser4-cli htmlsnapshot export [--file <path>] [--clean]
500
- browser4-cli htmlsnapshot summary
501
- browser4-cli htmlsnapshot grep [OPTIONS] <pattern>
502
- browser4-cli htmlsnapshot inspect [selector] [--max N] [--depth D]
503
- ```
504
-
505
- #### htmlsnapshot / htmlsnapshot capture
506
-
507
- Capture the DOM and display metadata (URL, title, timestamps, image/link counts,
508
- interactive elements with tag, class, id, aria, and bounding boxes).
509
- `htmlsnapshot` is a short form of `htmlsnapshot capture`.
510
-
511
- ```bash
512
- browser4-cli htmlsnapshot capture
513
- browser4-cli htmlsnapshot
514
- ```
558
+ | Command | Description |
559
+ |---|---|
560
+ | `experience save <url> <trace>` | Save a task execution trace. Supports `--outcome`, `--intent`, `--task-type`. |
561
+ | `experience query <url>` | Query known selectors, blockers, and hints for a URL/domain. Supports `--intent`. |
562
+ | `experience list` | List stored experience entries. Supports `--filter`, `--intent-filter`, `--page`, `--page-size`. |
563
+ | `experience deep-learn <url> <intent>` | Run deeper analysis on stored traces. Supports `--force`. |
515
564
 
516
- #### htmlsnapshot get
565
+ #### Plugins
517
566
 
518
- Extract elements from the stored snapshot by CSS selector.
567
+ Plugins are server-side JARs that extend Browser4.
519
568
 
520
- | Field | Returns | Example |
521
- |---|---|---|
522
- | `text` | Inner text of the first match | `htmlsnapshot get text "#title"` |
523
- | `html` | Inner HTML of the first match | `htmlsnapshot get html "body"` |
524
- | `attr` | Attribute value (requires `name`) | `htmlsnapshot get attr "a" href` |
569
+ | Command | Description |
570
+ |---|---|
571
+ | `plugin list` | List installed plugins. |
572
+ | `plugin info <name>` | Show plugin details. |
573
+ | `plugin install <file>` | Install a plugin from a local JAR file. Supports `--replace`. |
574
+ | `plugin remove <name>` | Remove a plugin. Supports `-y`, `--yes`. |
525
575
 
526
- Selector defaults to `:root`. `get html` output is paginated (2000 lines per page);
527
- `get text` is not paginated by default. Use `--page N`, `--page-size N`, or `--all`.
576
+ #### Advanced and currently hidden commands
528
577
 
529
- ```bash
530
- browser4-cli htmlsnapshot get text "#productTitle"
531
- browser4-cli htmlsnapshot get html "#main-content"
532
- browser4-cli htmlsnapshot get attr "a.product-link" href
533
- browser4-cli htmlsnapshot get html "body" --page 2
534
- browser4-cli htmlsnapshot get html --all
535
- ```
578
+ These commands exist in the CLI but are intentionally kept out of the default public help.
536
579
 
537
- #### htmlsnapshot get all
580
+ | Command | Description |
581
+ |---|---|
582
+ | `upload <ref> <file>` | Upload one or multiple files to a file input. |
583
+ | `act <description>` | Experimental natural-language action translator that turns plain text into a browser command and runs it. |
538
584
 
539
- Like `get`, but extracts ALL matching elements (querySelectorAll semantics).
540
- Supports `--offset N` and `--limit N` for element-level pagination, plus
541
- `--page N`, `--page-size N`, `--all` for output pagination. `get all html` is
542
- paginated at 2000 lines by default; `get all text` is not paginated by default.
585
+ ### Timeout environment variables
543
586
 
544
- > **Note:** Each `get all` call scans the whole document independently. For
545
- > **correlated multi-field extraction** (title + price + URL per item), use
546
- > `htmlsnapshot query` with X-SQL's `DOM_LOAD_AND_SELECT` โ€” it scopes each row
547
- > to a parent container so fields stay aligned. See the
548
- > [list-page scraping pattern](skills/browser4-cli/references/x-sql-dom-load-select.md).
587
+ | Variable | Default | Used for |
588
+ |---|---:|---|
589
+ | `BROWSER4_CLI_HTTP_TIMEOUT_SECS` | `30` | most commands |
590
+ | `BROWSER4_CLI_INPUT_TIMEOUT_SECS` | `90` | `type`, `fill`, and other slower input workflows |
591
+ | `BROWSER4_CLI_NAVIGATION_TIMEOUT_SECS` | `120` | `goto`, `reload`, `go-back`, `go-forward` |
549
592
 
550
593
  ```bash
551
- browser4-cli htmlsnapshot get all text "h2 a"
552
- browser4-cli htmlsnapshot get all text ".result" --offset 10 --limit 5
553
- browser4-cli htmlsnapshot get all text "p" --page-size 500
594
+ export BROWSER4_CLI_INPUT_TIMEOUT_SECS=180
595
+ export BROWSER4_CLI_NAVIGATION_TIMEOUT_SECS=300
554
596
  ```
555
597
 
556
- #### htmlsnapshot query
598
+ ### State persistence
557
599
 
558
- Run an X-SQL query against the stored HTML snapshot. `--sql` is required. Use
559
- `@url` as a placeholder for the target page URL (unquoted โ€” the server handles
560
- escaping).
561
-
562
- **Recommended:** Write queries to a `.sql` file to avoid shell escaping issues.
563
- Prefix the `--sql` value with `@` to read from a file. Use `--sql-stdin` for
564
- piped/scripted workflows, or `--sql-base64` for transport-safe encoded queries.
565
-
566
- ```bash
567
- # From a file (recommended โ€” no shell escaping)
568
- cat > query.sql << 'SQLEOF'
569
- SELECT
570
- dom_base_uri(dom) AS url,
571
- dom_first_text(dom, 'h1') AS title
572
- FROM load_and_select(@url, ':root')
573
- SQLEOF
574
- browser4-cli htmlsnapshot query --sql @query.sql
600
+ CLI state lives under `~/.browser4` unless overridden.
575
601
 
576
- # From stdin
577
- cat query.sql | browser4-cli htmlsnapshot query --sql-stdin
602
+ - default session: `~/.browser4/cli-state.json`
603
+ - named sessions: `~/.browser4/sessions/<name>.json`
604
+ - loops: `~/.browser4/loops/<name>.json`
578
605
 
579
- # From base64 (transport-safe, no quoting issues)
580
- browser4-cli htmlsnapshot query --sql "$(base64 -w0 query.sql)" --sql-base64
606
+ The runtime bundle is stored separately in a platform-conventional application-data directory, so clearing session state does not force a re-download of Browser4 itself.
581
607
 
582
- # Inline (simple queries only โ€” quoted selectors require escaping on Windows)
583
- browser4-cli htmlsnapshot query --sql "
584
- SELECT dom_base_uri(dom) AS url, dom_first_text(dom, 'h1') AS title
585
- FROM load_and_select(@url, ':root')
586
- "
587
- ```
608
+ ---
588
609
 
589
- #### htmlsnapshot export
610
+ ## ๐Ÿš€ Build from Source
590
611
 
591
- Save the full snapshot HTML to a local file. Use `--clean` to strip `<script>`, `<style>`, comments, and non-standard attributes โ€” producing minimal HTML ideal for LLM consumption.
612
+ **Prerequisites:** Git, JDK 17+ (21+ recommended), Chrome/Chromium, and PowerShell 7 (Linux/macOS only). For the full prerequisites table, platform-specific tools, and Chrome auto-detection paths, see [Build from Source](docs/build-from-source.md).
592
613
 
593
- ```bash
594
- browser4-cli htmlsnapshot export --file snapshot.html
595
- browser4-cli htmlsnapshot export --file page.html --clean
596
- ```
597
-
598
- #### htmlsnapshot summary
614
+ 1. **Clone the repository**
615
+ ```shell
616
+ git clone https://github.com/platonai/Browser4.git
617
+ cd Browser4
618
+ ```
599
619
 
600
- Generate a compressed Web Page Summary Index (WPSI) โ€” page type, structure, key
601
- content nodes, repeated lists, tables, and stats โ€” typically <1% of the original
602
- HTML size.
620
+ 2. **Configure your LLM API key**
603
621
 
604
- ```bash
605
- browser4-cli htmlsnapshot summary
606
- ```
622
+ > Edit [application.properties](application.properties) and add your API key, or set environment variables. See [LLM Configuration](#llm-configuration) for supported providers and variable names.
607
623
 
608
- #### htmlsnapshot grep
624
+ 3. **Build the project**
625
+ ```shell
626
+ ./mvnw -DskipTests
627
+ ```
609
628
 
610
- Search the HTML snapshot HTML with regex patterns. Same grep flags as
611
- `snapshot grep`: `-i`, `-A N`, `-B N`, `-C N`, `-v`, `-c`, `-l`, `-F`, `-w`,
612
- `--no-line-number`, `--selector <css>`, `--page N`, `--page-size N`, `--all`.
629
+ 4. **Build and run the CLI (from source)**
630
+ ```shell
631
+ # Build the Rust CLI (requires Rust toolchain)
632
+ cd cli/browser4-cli && cargo build --release
613
633
 
614
- ```bash
615
- browser4-cli htmlsnapshot grep -i error
616
- browser4-cli htmlsnapshot grep -F -C 2 "404 Not Found"
617
- browser4-cli htmlsnapshot grep --selector main "Submit"
618
- browser4-cli htmlsnapshot grep --all "TODOs"
619
- ```
634
+ # Or run directly without installing:
635
+ cargo run --manifest-path cli/browser4-cli/Cargo.toml -- --help
620
636
 
621
- #### htmlsnapshot inspect
637
+ # Add --quiet to suppress Cargo build-status output:
638
+ cargo run --quiet --manifest-path cli/browser4-cli/Cargo.toml -- <command>
622
639
 
623
- Analyze DOM structure and discover CSS selectors for recurring patterns (product
624
- cards, prices, titles). Run without arguments to auto-discover the page's most
625
- prominent repeating content. When the selector matches multiple similar elements,
626
- it compares their child structures and ranks selectors by recurrence.
640
+ # Or install globally:
641
+ cd cli/browser4-cli && cargo install --path .
642
+ ```
643
+ > On Windows, prefix the command with `chcp 65001 >nul &&` for proper UTF-8 output.
644
+ > See [Build from Source](docs/build-from-source.md) for full platform-specific instructions.
627
645
 
628
- ```bash
629
- browser4-cli htmlsnapshot inspect # auto-discover repeating patterns
630
- browser4-cli htmlsnapshot inspect ".product_pod" # inspect a specific container
631
- browser4-cli htmlsnapshot inspect ".s-result-item" --depth 6 --max 20
632
- ```
646
+ **Dev-mode wrappers (no install needed):** The repo root provides shell wrappers
647
+ that auto-build from source. Use `./b4w.ps1 <command>` (PowerShell),
648
+ `./b4w.sh <command>` (Git Bash / Linux / macOS), or `./b4w.bat <command>`
649
+ (CMD) โ€” all accept the same arguments as the installed `browser4-cli` binary.
633
650
 
634
651
  ---
635
652
 
636
- ### LLM Configuration
653
+ ๐ŸŽฌ YouTube:
654
+ [![Watch the video](https://img.youtube.com/vi/_BcryqWzVMI/0.jpg)](https://www.youtube.com/watch?v=_BcryqWzVMI)
637
655
 
638
- AI-powered commands (`agent`, `extract`, `summarize`) and X-SQL `llm_*` functions
639
- require an LLM API key. Configure one provider via environment variables:
640
-
641
- | Provider | Environment Variables |
642
- |---|---|
643
- | DeepSeek | `DEEPSEEK_API_KEY` |
644
- | OpenRouter | `OPENROUTER_API_KEY`, `OPENROUTER_MODEL_NAME`, `OPENROUTER_BASE_URL` |
645
- | Volcengine (ByteDance) | `VOLCENGINE_API_KEY`, `VOLCENGINE_MODEL_NAME`, `VOLCENGINE_BASE_URL` |
646
- | OpenAI-compatible | `OPENAI_API_KEY`, `OPENAI_MODEL_NAME`, `OPENAI_BASE_URL` |
647
- | Aliyun Qwen (DashScope) | `OPENAI_API_KEY`, `OPENAI_MODEL_NAME`, `OPENAI_BASE_URL` |
648
-
649
- Example:
650
-
651
- ```bash
652
- export DEEPSEEK_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
653
- ```
654
-
655
- If no valid LLM key is configured, AI commands fail fast with a clear error at startup.
656
+ ๐Ÿ“บ Bilibili:
657
+ [https://www.bilibili.com/video/BV1kM2rYrEFC](https://www.bilibili.com/video/BV1kM2rYrEFC)
656
658
 
657
659
  ---
658
660
 
659
- ### Agent
661
+ ## Architecture
660
662
 
661
- The `agent` subcommands submit natural-language tasks that the Browser4 backend
662
- executes autonomously โ€” it plans, browses, and returns a result.
663
-
664
- ```
665
- browser4-cli agent run <task>
666
- browser4-cli agent status <id>
667
- browser4-cli agent result <id>
668
663
  ```
669
-
670
- #### agent run
671
-
672
- Submit an asynchronous natural-language task. Returns immediately with a task ID.
673
-
674
- ```bash
675
- browser4-cli agent run "Open browser4.io and summarize the hero section"
676
- # โ†’ Task submitted: agent-task-1
677
- # โ†’ Use 'browser4-cli agent status agent-task-1' to check progress.
664
+ browser4-cli (Rust) โ”€โ”€MCP over HTTPโ”€โ”€โ–ถ browser4-rest (Kotlin/Spring) โ”€โ”€โ–ถ PulsarWebDriver (Kotlin/CDP)
678
665
  ```
679
666
 
680
- #### agent status
681
-
682
- Poll the status of a running task.
683
-
684
- ```bash
685
- browser4-cli agent status agent-task-1
686
- ```
687
-
688
- #### agent result
689
-
690
- Fetch the completed task result.
667
+ - **CLI** (`cli/browser4-cli`) โ€” native Rust binary, talks to the backend via MCP tool calls
668
+ - **Backend** (`browser4-rest`) โ€” Spring Boot server, dispatches MCP tools to browser drivers
669
+ - **Browser driver** (`browser4-core/browser4-browser`) โ€” wraps Chrome DevTools Protocol
670
+ - **Agent tools** (`browser4-agentic`) โ€” maps MCP tool names to browser automation methods
691
671
 
692
- ```bash
693
- browser4-cli agent result agent-task-1
694
- ```
672
+ ## ๐Ÿ“ฆ Modules Overview
695
673
 
696
- Agent commands are task-ID based and do not require an active browser session.
697
- They are not supported inside `batch` mode.
674
+ | Module | Description |
675
+ |---|----------------------------------------------------------------------|
676
+ | `cli/browser4-cli` | Rust CLI โ€” fast, native binary for browser automation |
677
+ | `skills/browser4-cli` | AI agent skill definitions (SKILL.md) |
678
+ | `browser4-core` | Core engine: sessions, scheduling, DOM, browser control |
679
+ | `browser4-dependencies` | BOM and dependency version alignment |
680
+ | `browser4-tools` | Operational tools and launch helpers |
681
+ | `browser4-agentic` | AI agents, MCP integration, skill registration |
682
+ | `browser4-agent-tools` | High-level agent tools: scraping, crawling, stateful page interaction |
683
+ | `browser4-rest` | Spring Boot REST layer & command endpoints |
684
+ | `browser4-apps/browser4-standalone` | Product packaging โ€” unified launcher (`target/Browser4.jar`) |
685
+ | `examples/browser4-examples` | Runnable examples and demos |
686
+ | `browser4-tests` | E2E, integration, and scenario test suites |
687
+ | `cdp-protocol` | Chrome DevTools Protocol JSON definitions |
688
+ | `coworker/` | Builtin AI coworker |
698
689
 
699
690
  ---
700
691
 
701
- ### Swarm
702
-
703
- Swarm mode coordinates multiple browser contexts in parallel for high-throughput
704
- scraping and data extraction.
705
-
706
- ```
707
- browser4-cli swarm create [options]
708
- browser4-cli swarm submit [url] [options]
709
- browser4-cli swarm query <url> --sql <query>
710
- browser4-cli swarm status <id>
711
- browser4-cli swarm result <id>
712
- ```
692
+ ## ๐Ÿงช Test Fixture Server (MockSite)
713
693
 
714
- #### swarm create
694
+ Browser4 includes a lightweight **MockSite** server that serves static HTML pages for testing and demos. Start it from the repository root:
715
695
 
716
- Create a swarm scrape session.
696
+ **Windows:** `./bin/test.ps1 mock-site -Dmock.site.port=18080`
697
+ **Linux/macOS:** `./bin/test.sh mock-site -Dmock.site.port=18080`
717
698
 
718
- | Option | Default | Description |
719
- |---|---|---|
720
- | `--profile-mode` | `SEQUENTIAL` | Profile mode: `SEQUENTIAL` or `TEMPORARY` |
721
- | `--max-open-tabs` | `8` | Max open tabs per browser context |
722
- | `--max-browser-contexts` | `2` | Number of isolated browser environments |
723
- | `--display-mode` | โ€” | Display mode: `GUI`, `HEADLESS`, `SUPERVISED` |
724
-
725
- ```bash
726
- browser4-cli swarm create \
727
- --profile-mode TEMPORARY \
728
- --max-open-tabs 12 \
729
- --max-browser-contexts 3 \
730
- --display-mode HEADLESS
731
- ```
732
-
733
- #### swarm submit
734
-
735
- Submit URLs as scrape jobs. Accepts a direct URL, a `--seed-file` (one URL per
736
- line; `#` comments and blank lines ignored), or both.
737
-
738
- | Option | Description |
739
- |---|---|
740
- | `--seed-file <path>` | File of URLs to submit |
741
- | `--sql <query>` | X-SQL query (inline or `@file.sql`). Sends to query API instead of submit. |
742
- | `--deadline <ISO 8601>` | Task completion deadline |
743
- | `--expires <duration>` | Cache expiration (e.g. `1d`, `1h`) |
744
- | `--refresh` | Force fresh fetch, ignore cache |
745
- | `--parse` | Parse page immediately after fetching |
746
-
747
- ```bash
748
- # Submit URLs from a file
749
- browser4-cli swarm submit --seed-file ./urls.txt \
750
- --deadline 2026-03-30T00:00:00Z \
751
- --expires 1d --refresh
752
-
753
- # Submit with inline X-SQL
754
- browser4-cli swarm submit "https://www.amazon.com/dp/B08PP5MSVB" --sql "
755
- SELECT
756
- dom_base_uri(dom) AS url,
757
- dom_first_text(dom, '#productTitle') AS title
758
- FROM load_and_select(@url, 'body')
759
- "
760
-
761
- # Submit with X-SQL from a file
762
- browser4-cli swarm submit "https://www.amazon.com/dp/B08PP5MSVB" --sql @query.sql
763
- ```
764
-
765
- #### swarm query
766
-
767
- Run an X-SQL query against loaded webpages. `--sql` is required. Supports a
768
- direct URL, `--seed-file`, or both โ€” runs the same query against each. Also
769
- accepts `--deadline`, `--expires`, `--refresh`.
770
-
771
- ```bash
772
- # Inline X-SQL
773
- browser4-cli swarm query "https://www.amazon.com/dp/B08PP5MSVB" --sql "
774
- SELECT dom_first_text(dom, '#productTitle') AS title
775
- FROM load_and_select(@url, 'body')
776
- "
777
-
778
- # From a file, with seed URLs
779
- browser4-cli swarm query --sql @query.sql --seed-file ./urls.txt --refresh
780
- ```
781
-
782
- #### swarm status / swarm result
783
-
784
- Poll and fetch results โ€” same pattern as `agent status` / `agent result`.
785
-
786
- ```bash
787
- browser4-cli swarm status scrape-task-4
788
- browser4-cli swarm result scrape-task-4
789
- ```
699
+ Key demo pages are served at `http://localhost:18080/generated/`. For the full page listing, environment variables, Python fallback, and Maven-based launch, see [MockSite](docs/mocksite.md). For the test taxonomy and tagging system, see [Test Taxonomy](docs/TESTING.md).
790
700
 
791
701
  ---
792
702
 
793
- ### Crawl
703
+ ## ๐Ÿค Support & Community
794
704
 
795
- Recursive website crawling from a seed URL. Reuses the swarm infrastructure.
705
+ Join our community for support, feedback, and collaboration!
796
706
 
797
- ```
798
- browser4-cli crawl <url> [options]
799
- ```
707
+ - **GitHub Discussions**: Engage with developers and users.
708
+ - **Issue Tracker**: Report bugs or request features.
709
+ - **Social Media**: Follow us for updates and news.
800
710
 
801
- | Flag | Default | Description |
802
- |---|---|---|
803
- | `-d`, `--depth` | `1` | Maximum crawl depth |
804
- | `-ol`, `--out-link-selector` | โ€” | CSS selector to extract links from each page |
805
- | `-olp`, `--out-link-pattern` | `.+` | Regex filter for extracted links |
806
- | `-tl`, `--top-links` | `20` | Max links extracted per page |
807
- | `-a`, `--args` | โ€” | Additional LoadOptions passthrough (e.g. `-a "-nMaxRetry 5"`) |
808
- | `--refresh` | โ€” | Force fresh fetch |
809
- | `--parse` | โ€” | Parse pages immediately after fetching |
810
- | `--expires` | โ€” | Cache expiration (e.g. `1d`, `1h`, `30m`) |
811
- | `-p`, `--priority` | โ€” | Queue priority (lower = higher) |
812
- | `--ignore-url-query` | โ€” | Strip query params during URL normalization |
813
- | `--no-norm` | โ€” | Disable URL normalization |
814
- | `--readonly` | โ€” | Non-destructive mode |
815
- | `--page-load-timeout` | โ€” | Max wait for each page load |
816
- | `-bg`, `--background` | โ€” | Submit crawl and return immediately; use `crawl list` to track |
817
-
818
- ```bash
819
- # Depth 1: extract all links from homepage, load each linked page
820
- browser4-cli crawl "https://example.com" --out-link-selector "a[href]"
821
-
822
- # Depth 2: follow product links, filter by pattern
823
- browser4-cli crawl "https://shop.example.com" \
824
- --depth 2 \
825
- --out-link-selector "a.product-link" \
826
- --out-link-pattern "/product/" \
827
- --top-links 10
828
-
829
- # Deep crawl with refresh and content storage
830
- browser4-cli crawl "https://example.com" --depth 3 --refresh
831
-
832
- # Background crawl โ€” submit and return immediately
833
- browser4-cli crawl "https://example.com" -ol "a[href]" --background
834
- browser4-cli crawl list
835
- ```
711
+ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
836
712
 
837
713
  ---
838
714
 
839
- ## Element references
715
+ ## ๐Ÿ“œ Documentation
840
716
 
841
- The `snapshot` command returns an accessibility tree where every interactive
842
- element is labeled with a ref like `e15`. Pass this ref to any interaction
843
- command:
717
+ Comprehensive documentation is available in the `docs/` directory and on our [GitHub Pages site](https://platonai.github.io/browser4/).
844
718
 
845
- ```bash
846
- browser4-cli snapshot # see e15 is the search input
847
- browser4-cli click e15 # click it
848
- browser4-cli type "query" e15 # type into it
849
- ```
850
-
851
- You can also use CSS selectors (e.g. `#search`, `.btn-primary`,
852
- `input[name=email]`) anywhere a ref is accepted.
719
+ ---
853
720
 
854
- ## State persistence
721
+ ## ๐Ÿ”ง Proxy Configuration - Unblock Website Access
855
722
 
856
- CLI state is stored under `~/.browser4` (override with `BROWSER4_CLI_STATE_DIR`):
723
+ <details>
857
724
 
858
- - Default session: `~/.browser4/cli-state.json`
859
- - Named sessions (`-s <name>`): `~/.browser4/sessions/<name>.json`
725
+ Set the environment variable `PROXY_ROTATION_URL` to the rotation URL provided by your proxy service provider:
860
726
 
861
- Each state file stores the session ID, server URL, and cursor position โ€” so your
862
- next `open` or `goto` picks up right where you left off.
727
+ ```shell
728
+ export PROXY_ROTATION_URL=https://your-proxy-provider.com/rotation-endpoint
729
+ ```
863
730
 
864
- The Browser4 runtime bundle (~200 MB) is stored separately in a
865
- platform-conventional data directory so clearing CLI session state does not
866
- require re-downloading:
731
+ Each time you access this rotation URL, it should return a response containing one or more fresh proxy IPs.
732
+ If you need this type of URL, please contact your proxy service provider.
867
733
 
868
- | Platform | Path |
869
- |---|---|
870
- | Linux | `~/.local/share/browser4/runtime/<version>/` |
871
- | macOS | `~/Library/Application Support/browser4/runtime/<version>/` |
872
- | Windows | `%APPDATA%/browser4/runtime/<version>/` |
734
+ </details>
873
735
 
874
- Override the runtime data root with `BROWSER4_RUNTIME_DIR`.
736
+ ---
875
737
 
876
738
  ## License
877
739
 
878
- Apache-2.0
740
+ Apache 2.0 License. See [LICENSE](LICENSE) for details.