browser4-cli 0.1.7 → 0.1.9
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 +255 -51
- package/bin/.install-method +0 -0
- package/bin/browser4-cli-linux-arm64 +0 -0
- package/bin/browser4-cli-linux-x64 +0 -0
- package/bin/browser4-cli-win32-x64.exe +0 -0
- package/bin/browser4-cli.js +0 -0
- package/package.json +3 -3
- package/scripts/build-all-platforms.ps1 +0 -0
- package/scripts/build-all-platforms.sh +0 -0
- package/scripts/check-npm-publish-needed.js +0 -0
- package/scripts/check-version-sync.js +0 -0
- package/scripts/copy-native.js +0 -0
- package/scripts/npm-publish-check.js +0 -0
- package/scripts/postinstall.js +0 -0
- package/scripts/publish-if-needed.js +0 -0
- package/scripts/sync-version.js +6 -6
- package/bin/browser4-cli-darwin-arm64 +0 -0
- package/bin/browser4-cli-darwin-x64 +0 -0
- package/bin/browser4-cli-linux-musl-arm64 +0 -0
- package/bin/browser4-cli-linux-musl-x64 +0 -0
package/README.md
CHANGED
|
@@ -68,6 +68,16 @@ browser4-cli -s=<session> <command> [args] [options]
|
|
|
68
68
|
| `--version` | Print version |
|
|
69
69
|
| `-s=<name>` | Named session label |
|
|
70
70
|
| `--server=<url>` | Override Browser4 server URL |
|
|
71
|
+
| `--json` | Emit machine-parseable JSON to stdout |
|
|
72
|
+
| `-q`, `--quiet` | Suppress normal output, only show errors |
|
|
73
|
+
|
|
74
|
+
`--json` switches every command's stdout from human-readable text to a
|
|
75
|
+
single-line JSON envelope (`{"status":"ok","command":"<name>","output":{...}}`).
|
|
76
|
+
Omit `--json` for the default human-readable output.
|
|
77
|
+
|
|
78
|
+
`-q` / `--quiet` suppresses all normal stdout output. Errors and
|
|
79
|
+
progress messages still go to stderr. Combine with `--json` for
|
|
80
|
+
silent-on-success scripting: `browser4-cli --json -q open`.
|
|
71
81
|
|
|
72
82
|
Sessions are persisted independently per name. Omitting `-s` uses the
|
|
73
83
|
default session (`~/.browser4/cli-state.json`). With `-s=<name>`, a
|
|
@@ -83,9 +93,9 @@ The tables below mirror the commands surfaced by the global `browser4-cli help`
|
|
|
83
93
|
|
|
84
94
|
| Command | Description |
|
|
85
95
|
|---|---|
|
|
86
|
-
| `open [url]` | Open or switch to a browser session (
|
|
96
|
+
| `open [url]` | Open or switch to a browser session. Supports `--headed` (force visible window) and `--headless` (force headless). |
|
|
87
97
|
| `close` | Close the active session |
|
|
88
|
-
| `goto <url>` | Navigate to a URL
|
|
98
|
+
| `goto <url>` | Navigate to a URL, auto-opening or refreshing the session if needed |
|
|
89
99
|
| `click <ref> [button]` | Click an element |
|
|
90
100
|
| `dblclick <ref> [button]` | Double-click an element |
|
|
91
101
|
| `type <text> [ref]` | Type text into the focused element or an optional target element |
|
|
@@ -128,12 +138,11 @@ The tables below mirror the commands surfaced by the global `browser4-cli help`
|
|
|
128
138
|
| `mouseup [button]` | Release mouse button |
|
|
129
139
|
| `mousewheel <dx> <dy>` | Scroll the mouse wheel |
|
|
130
140
|
|
|
131
|
-
####
|
|
141
|
+
#### Screenshots
|
|
132
142
|
|
|
133
143
|
| Command | Description |
|
|
134
144
|
|---|---|
|
|
135
|
-
| `screenshot [ref]` | Take a screenshot |
|
|
136
|
-
| `pdf` | Save page as PDF |
|
|
145
|
+
| `screenshot [ref]` | Take a screenshot (optionally of a specific element) |
|
|
137
146
|
|
|
138
147
|
#### Tabs
|
|
139
148
|
|
|
@@ -146,6 +155,28 @@ The tables below mirror the commands surfaced by the global `browser4-cli help`
|
|
|
146
155
|
|
|
147
156
|
Use `tab-list` first to find the zero-based tab index you want to select or close.
|
|
148
157
|
|
|
158
|
+
#### Browser storage
|
|
159
|
+
|
|
160
|
+
| Command | Description |
|
|
161
|
+
|---|---|
|
|
162
|
+
| `state-save <path>` | Save cookies and localStorage to a JSON file |
|
|
163
|
+
| `state-load <path>` | Restore cookies and localStorage from a saved state file |
|
|
164
|
+
| `cookie-list` | List all cookies (optionally filtered by `--domain` / `--path`) |
|
|
165
|
+
| `cookie-get <name>` | Get a cookie by name |
|
|
166
|
+
| `cookie-set <name> <value>` | Set a cookie (optional `--path`, `--domain`) |
|
|
167
|
+
| `cookie-delete <name>` | Delete a cookie by name |
|
|
168
|
+
| `cookie-clear` | Clear all cookies for the current page |
|
|
169
|
+
| `localstorage-list` | List all localStorage entries |
|
|
170
|
+
| `localstorage-get <key>` | Get a localStorage value by key |
|
|
171
|
+
| `localstorage-set <key> <value>` | Set a localStorage key-value pair |
|
|
172
|
+
| `localstorage-delete <key>` | Delete a localStorage key |
|
|
173
|
+
| `localstorage-clear` | Clear all localStorage entries |
|
|
174
|
+
| `sessionstorage-list` | List all sessionStorage entries |
|
|
175
|
+
| `sessionstorage-get <key>` | Get a sessionStorage value by key |
|
|
176
|
+
| `sessionstorage-set <key> <value>` | Set a sessionStorage key-value pair |
|
|
177
|
+
| `sessionstorage-delete <key>` | Delete a sessionStorage key |
|
|
178
|
+
| `sessionstorage-clear` | Clear all sessionStorage entries |
|
|
179
|
+
|
|
149
180
|
#### Browser sessions
|
|
150
181
|
|
|
151
182
|
| Command | Description |
|
|
@@ -156,6 +187,26 @@ Use `tab-list` first to find the zero-based tab index you want to select or clos
|
|
|
156
187
|
|
|
157
188
|
Use `close-all` for session cleanup when you want to keep the current Browser4 service running. Use `kill-all` only when you explicitly want to stop the backend and clean up tracked Browser4 processes.
|
|
158
189
|
|
|
190
|
+
#### Server management
|
|
191
|
+
|
|
192
|
+
| Command | Description |
|
|
193
|
+
|---|---|
|
|
194
|
+
| `install` | Download the Browser4 runtime bundle. Supports `--tag=<version>` to pin a release and `--force` to reinstall even when already present. |
|
|
195
|
+
| `upgrade` | Upgrade the Browser4 runtime bundle to the latest version or a specified `--tag` |
|
|
196
|
+
| `stop` | Kill the Browser4 backend after closing all sessions |
|
|
197
|
+
| `status` | Check whether the Browser4 backend is reachable and healthy |
|
|
198
|
+
|
|
199
|
+
`install` and `upgrade` both manage the Browser4 runtime bundle — a self-contained
|
|
200
|
+
distribution that includes all dependency jars, a minimal `jlink`-built JRE, and
|
|
201
|
+
platform launcher scripts. Neither requires `cargo` or a Rust toolchain; the runtime
|
|
202
|
+
is a Java application downloaded from GitHub Releases.
|
|
203
|
+
|
|
204
|
+
Use `--tag=<version>` to pin a specific release (e.g. `--tag=v4.9.3`). Use `--force`
|
|
205
|
+
to reinstall even when the same version is already present.
|
|
206
|
+
|
|
207
|
+
When a local Browser4 checkout is detected with the `browser4-bundle` module present,
|
|
208
|
+
`install` and `upgrade` auto-build the runtime bundle from source (via Maven) instead
|
|
209
|
+
of downloading.
|
|
159
210
|
|
|
160
211
|
### Advanced commands
|
|
161
212
|
|
|
@@ -164,28 +215,182 @@ Query `browser4-cli help <command>` for the exact syntax when you need them.
|
|
|
164
215
|
|
|
165
216
|
| Command | Description |
|
|
166
217
|
|---|---|
|
|
167
|
-
| `batch [command...]` | Execute multiple commands in one invocation. Only DOM operations are supported (Core, Navigation, Keyboard, Mouse, Export, Tabs categories). Commands like `open`, `close`, `list`, `agent
|
|
218
|
+
| `batch [command...]` | Execute multiple commands in one invocation. Only DOM operations are supported (Core, Navigation, Keyboard, Mouse, Export, Tabs categories). Commands like `open`, `close`, `list`, `agent run`, etc. are not allowed in batch mode. |
|
|
168
219
|
| `console [min-level]` | List console messages |
|
|
169
220
|
| `extract <instruction>` | Extract structured data from the current page |
|
|
170
221
|
| `summarize [instruction]` | Summarize page content using AI |
|
|
171
|
-
| `agent
|
|
172
|
-
| `agent
|
|
173
|
-
| `agent
|
|
174
|
-
| `
|
|
175
|
-
| `
|
|
176
|
-
| `
|
|
177
|
-
| `
|
|
178
|
-
| `
|
|
222
|
+
| `agent run <task>` | Run an autonomous agent task |
|
|
223
|
+
| `agent status <id>` | Check the status of a running agent task |
|
|
224
|
+
| `agent result <id>` | Get the result of a completed agent task |
|
|
225
|
+
| `swarm create` | Create a swarm scrape session with parallel browser contexts |
|
|
226
|
+
| `swarm submit [url]` | Submit URL(s) or raw X-SQL payloads as scrape jobs |
|
|
227
|
+
| `swarm query <url>` | Run an X-SQL query against a loaded webpage |
|
|
228
|
+
| `swarm status <id>` | Check the status of a scrape or query job |
|
|
229
|
+
| `swarm result <id>` | Get the result of a completed job |
|
|
230
|
+
|
|
231
|
+
## Agent task workflow (`agent <subcommand>`)
|
|
232
|
+
|
|
233
|
+
The `agent-*` commands wrap the backend command agent's asynchronous task API.
|
|
234
|
+
They are useful when you want Browser4 to plan and execute a natural-language
|
|
235
|
+
task in the background instead of issuing one low-level browser action at a
|
|
236
|
+
time.
|
|
237
|
+
|
|
238
|
+
Like other advanced commands, they are intentionally omitted from the global
|
|
239
|
+
`browser4-cli help` overview. Query `browser4-cli help agent run` (or
|
|
240
|
+
`agent status` / `agent result`) when you need the exact syntax.
|
|
241
|
+
|
|
242
|
+
Use the spaced `agent <subcommand>` form:
|
|
243
|
+
|
|
244
|
+
```shell
|
|
245
|
+
browser4-cli agent run "Open example.com and summarize the hero section"
|
|
246
|
+
browser4-cli agent status agent-task-1
|
|
247
|
+
browser4-cli agent result agent-task-1
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Command lifecycle
|
|
251
|
+
|
|
252
|
+
| Step | Command | What it does |
|
|
253
|
+
|---|---|---|
|
|
254
|
+
| 1 | `agent run <task>` | Submits an asynchronous natural-language task through `command_run` and prints the returned task ID |
|
|
255
|
+
| 2 | `agent status <id>` | Fetches the latest task status payload through `command_status` |
|
|
256
|
+
| 3 | `agent result <id>` | Fetches the completed task result payload through `command_result` |
|
|
257
|
+
|
|
258
|
+
### Notes
|
|
259
|
+
|
|
260
|
+
- `agent run` is asynchronous: it returns immediately after the backend accepts
|
|
261
|
+
the task and prints a follow-up `agent status` command with the generated task
|
|
262
|
+
ID.
|
|
263
|
+
- `agent status` prints the backend status payload as-is. In practice this is a
|
|
264
|
+
JSON object that commonly includes fields such as `id`, `status`,
|
|
265
|
+
`statusCode`, `processState`, `message`, `agentState`, `agentHistory`, and
|
|
266
|
+
`commandResult`.
|
|
267
|
+
- `agent result` prints the backend result payload as-is. Depending on the task,
|
|
268
|
+
it may be plain text or structured JSON.
|
|
269
|
+
- These commands are task-ID based and do not require an active CLI browser
|
|
270
|
+
session slot. The global `-s=<name>` option is therefore usually not relevant
|
|
271
|
+
for `agent-*` follow-up calls.
|
|
272
|
+
- `agent` subcommands are not supported inside `batch` mode.
|
|
273
|
+
- `agent run` performs a short post-submit status probe so obvious missing-LLM
|
|
274
|
+
configuration failures can be surfaced immediately instead of leaving you with
|
|
275
|
+
a task ID that will never succeed.
|
|
276
|
+
|
|
277
|
+
### Use cases
|
|
278
|
+
|
|
279
|
+
#### 1. Submit an autonomous agent task
|
|
280
|
+
|
|
281
|
+
```shell
|
|
282
|
+
browser4-cli agent run "Open browser4.io and summarize the hero section"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Typical output:
|
|
286
|
+
|
|
287
|
+
```text
|
|
288
|
+
Task submitted: agent-task-1
|
|
289
|
+
Use 'browser4-cli agent status agent-task-1' to check progress.
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
#### 2. Poll task progress
|
|
293
|
+
|
|
294
|
+
```shell
|
|
295
|
+
browser4-cli agent status agent-task-1
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Example status payload:
|
|
299
|
+
|
|
300
|
+
```json
|
|
301
|
+
{"id":"agent-task-1","status":"RUNNING"}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
On a real Browser4 backend the payload can be richer and may include lifecycle
|
|
305
|
+
details such as `processState`, agent history snapshots, or an embedded partial
|
|
306
|
+
`commandResult`.
|
|
307
|
+
|
|
308
|
+
#### 3. Read the final result
|
|
309
|
+
|
|
310
|
+
```shell
|
|
311
|
+
browser4-cli agent result agent-task-1
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
If the backend returns a structured `CommandResult`, expect fields such as
|
|
315
|
+
`summary`, `pageSummary`, `fields`, `links`, or `xsqlResultSet`.
|
|
316
|
+
|
|
317
|
+
## Swarm scrape workflow (`swarm <subcommand>`)
|
|
318
|
+
|
|
319
|
+
The `swarm` subcommands support a swarm scrape workflow where one CLI session
|
|
320
|
+
coordinates multiple browser contexts in the Browser4 backend.
|
|
321
|
+
|
|
322
|
+
### Command overview
|
|
323
|
+
|
|
324
|
+
| Command | Purpose | Backend endpoint |
|
|
325
|
+
|---|---|---|
|
|
326
|
+
| `swarm create` | Create a swarm scrape session | `POST /api/swarm` |
|
|
327
|
+
| `swarm submit <url>` | Scrape URLs or submit raw X-SQL | `POST /api/swarm/submit` |
|
|
328
|
+
| `swarm query <url>` | Run X-SQL queries against loaded pages | `POST /api/swarm/query` |
|
|
329
|
+
| `swarm status <id>` | Poll job status | `GET /api/swarm/{id}/status` |
|
|
330
|
+
| `swarm result <id>` | Fetch completed job result | `GET /api/swarm/{id}/result` |
|
|
331
|
+
|
|
332
|
+
### URL scraping with `swarm submit`
|
|
333
|
+
|
|
334
|
+
```shell
|
|
335
|
+
# create a session
|
|
336
|
+
browser4-cli swarm create \
|
|
337
|
+
--profile-mode=TEMPORARY \
|
|
338
|
+
--max-open-tabs=12 \
|
|
339
|
+
--max-browser-contexts=3 \
|
|
340
|
+
--display-mode=HEADLESS
|
|
341
|
+
|
|
342
|
+
# submit URLs as scrape jobs
|
|
343
|
+
browser4-cli swarm submit https://example.com/direct \
|
|
344
|
+
--seed-file=./swarm-seeds.txt \
|
|
345
|
+
--deadline=2026-03-30T00:00:00Z \
|
|
346
|
+
--expires=1d \
|
|
347
|
+
--refresh --parse --store-content
|
|
348
|
+
|
|
349
|
+
# poll and fetch the result
|
|
350
|
+
browser4-cli swarm status scrape-task-4
|
|
351
|
+
browser4-cli swarm result scrape-task-4
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### X-SQL queries with `swarm query`
|
|
355
|
+
|
|
356
|
+
Run structured X-SQL queries against loaded webpages to extract data.
|
|
357
|
+
|
|
358
|
+
```shell
|
|
359
|
+
# Inline query:
|
|
360
|
+
browser4-cli swarm query "https://www.amazon.com/dp/B08PP5MSVB" --sql "
|
|
361
|
+
SELECT
|
|
362
|
+
dom_base_uri(dom) AS url,
|
|
363
|
+
dom_first_text(dom, '#productTitle') AS title,
|
|
364
|
+
dom_first_slim_html(dom, 'img:expr(width > 400)') AS img
|
|
365
|
+
FROM load_and_select(@url, 'body');
|
|
366
|
+
"
|
|
367
|
+
|
|
368
|
+
# From a file:
|
|
369
|
+
browser4-cli swarm query "https://www.amazon.com/dp/B08PP5MSVB" --sql @query.sql
|
|
370
|
+
|
|
371
|
+
# With seed file and load options:
|
|
372
|
+
browser4-cli swarm query --sql @query.sql --seed-file=./urls.txt --refresh --parse
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Notes
|
|
376
|
+
|
|
377
|
+
- `swarm create` accepts backend capability hints: `--profile-mode`, `--max-open-tabs`,
|
|
378
|
+
`--max-browser-contexts`, `--display-mode`.
|
|
379
|
+
- `swarm submit` and `swarm query` both accept a positional URL, `--seed-file`, or both.
|
|
380
|
+
Seed files use one URL per line; `#` comments and blank lines are ignored.
|
|
381
|
+
- Both commands support load-option flags: `--deadline`, `--expires`, `--refresh`,
|
|
382
|
+
`--parse`, `--store-content`.
|
|
383
|
+
- `swarm query --sql` is **required**; `swarm submit --sql` also works as a convenience.
|
|
384
|
+
Use `@url` in the X-SQL template; it is replaced with the target URL server-side.
|
|
385
|
+
- Prefix the `--sql` value with `@` to read from a file (e.g. `--sql @query.sql`).
|
|
386
|
+
- All commands return a task ID; use `swarm status` / `swarm result` to track progress.
|
|
179
387
|
|
|
180
388
|
## Element References
|
|
181
389
|
|
|
182
390
|
The `snapshot` command returns an accessibility tree where every interactive
|
|
183
391
|
node is labeled with a short identifier such as `e15`. Pass this identifier
|
|
184
|
-
directly to commands like `click`, `type`, or `press
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
You can also pass plain CSS selectors (e.g. `.my-button`, `#search-input`) or
|
|
188
|
-
fully-qualified `backend:<N>` refs directly.
|
|
392
|
+
directly to commands like `click`, `type`, or `press`. You can also use plain
|
|
393
|
+
CSS selectors (e.g. `.my-button`, `#search-input`).
|
|
189
394
|
|
|
190
395
|
## State Persistence
|
|
191
396
|
|
|
@@ -206,41 +411,23 @@ fields such as:
|
|
|
206
411
|
|
|
207
412
|
### Session state transitions
|
|
208
413
|
|
|
209
|
-
|
|
210
|
-
|
|
414
|
+
| Command | Behavior |
|
|
415
|
+
|---|---|
|
|
416
|
+
| `open` | Creates a new session, or reuses an existing active one. Stale sessions are automatically refreshed. |
|
|
417
|
+
| `open -s=<name>` | Same as `open` but scoped to a named session slot. |
|
|
418
|
+
| `goto <url>` | Reuses the current session if active; otherwise opens a fresh one before navigating. |
|
|
419
|
+
| `close` | Closes the current session (no-op if none active). |
|
|
420
|
+
| `close-all` / `kill-all` / `stop` | Clears all persisted session state. |
|
|
211
421
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
| No persisted session | No state change | `require_session()` fails with `No active session. Run "browser4-cli open" first.` |
|
|
215
|
-
| `open` succeeds (no existing session) | `create_session()` writes a fresh state file with new `sessionId`, current `baseUrl`, and clears `activeSelector` / `lastMousePosition` | A new active session becomes the current CLI session |
|
|
216
|
-
| `open` when a saved session exists and the backend still reports it `active` | No state change — keeps the existing `sessionId` | The existing session is reused; subsequent commands target the same session |
|
|
217
|
-
| `open` when a saved session exists but is missing or no longer `active` in the backend | `invalidate_session()` clears the stale saved `sessionId`, `activeSelector`, and `lastMousePosition`, then `create_session()` writes a fresh session | The stale session is refreshed automatically by opening a new one |
|
|
218
|
-
| `open -s=<name>` | Reads/writes the named session state file | Opens, reuses, or refreshes the named session for that slot; subsequent `-s=<name>` commands use the same slot |
|
|
219
|
-
| Command succeeds through `with_session()` | `sessionId` stays unchanged | The command uses the persisted session normally |
|
|
220
|
-
| Command fails because the server reports a stale / expired session and `recover_stale = false` | `invalidate_session()` clears `sessionId`, `activeSelector`, and `lastMousePosition`, while keeping `baseUrl` | The command fails with `Saved session expired. Run "browser4-cli open" first.` |
|
|
221
|
-
| `goto` is invoked but the saved session is missing or no longer `active` in the backend | `invalidate_session()` clears the saved `sessionId`, `activeSelector`, and `lastMousePosition` | The command fails with `No active session for "goto". Run "browser4-cli open" to create or refresh the session first.` |
|
|
222
|
-
| `close` with an active session | `clear_state()` removes only the current session state file after best-effort remote close | The selected default or named session is fully cleared |
|
|
223
|
-
| `close` with no persisted `sessionId` | `clear_state()` best-effort removes the current session slot | Prints `No active session. Run "browser4-cli open" first.` and exits successfully as a no-op |
|
|
224
|
-
| `close-all` / `kill-all` | `clear_all_state()` removes the default state file and all named session files | All persisted CLI session files are cleared |
|
|
225
|
-
|
|
226
|
-
Notes:
|
|
227
|
-
|
|
228
|
-
- `goto` reuses only the current backend-`active` session. It does not create a
|
|
229
|
-
new session automatically; run `browser4-cli open` first if the saved session
|
|
230
|
-
is missing or stale.
|
|
231
|
-
- `open` first checks whether the saved session for the current slot is still
|
|
232
|
-
backend-`active`. It reuses active sessions and refreshes stale ones by
|
|
233
|
-
creating a new session for the same slot.
|
|
234
|
-
- `list` reads persisted session files and compares them with live backend
|
|
235
|
-
sessions to show both the current status (`Active`, `Stale`, or `Unknown`)
|
|
236
|
-
and whether the next `open` will `Reuse` or `Refresh` that slot.
|
|
422
|
+
The `list` command shows each session's status: **Active** (backend confirms),
|
|
423
|
+
**Stale** (backend has stopped it), or **Unknown** (backend unreachable).
|
|
237
424
|
|
|
238
425
|
## Runtime Temp Files
|
|
239
426
|
|
|
240
427
|
`browser4-cli` keeps ephemeral runtime artifacts under the system temp directory:
|
|
241
428
|
|
|
242
|
-
- Windows: `%TEMP
|
|
243
|
-
- Linux/macOS: `${TMPDIR:-/tmp}
|
|
429
|
+
- Windows: `%TEMP%\browser4\browser4-cli`
|
|
430
|
+
- Linux/macOS: `${TMPDIR:-/tmp}/browser4/browser4-cli`
|
|
244
431
|
|
|
245
432
|
This temp subtree contains items such as:
|
|
246
433
|
|
|
@@ -248,7 +435,20 @@ This temp subtree contains items such as:
|
|
|
248
435
|
- staged Maven wrapper launchers
|
|
249
436
|
- Rust test scratch directories used by `browser4-cli` tests
|
|
250
437
|
|
|
251
|
-
Persistent CLI state
|
|
438
|
+
Persistent CLI state remains under `~/.browser4` by default. The Browser4 runtime
|
|
439
|
+
bundle (JRE, JARs, launchers) is stored separately in a platform-conventional
|
|
440
|
+
data directory so that clearing CLI session state does not require re-downloading
|
|
441
|
+
the ~200 MB runtime:
|
|
442
|
+
|
|
443
|
+
- Linux: `~/.local/share/browser4/runtime/<version>/`
|
|
444
|
+
- macOS: `~/Library/Application Support/browser4/runtime/<version>/`
|
|
445
|
+
- Windows: `%APPDATA%/browser4/runtime/<version>/`
|
|
446
|
+
|
|
447
|
+
The `current.tag` file in the `runtime/` directory records the active version.
|
|
448
|
+
Override the runtime data root with the `BROWSER4_RUNTIME_DIR` environment variable.
|
|
449
|
+
Downloaded archives are cached under the platform cache directory
|
|
450
|
+
(`~/.cache/browser4/downloads/` on Linux, `~/Library/Caches/browser4/downloads/`
|
|
451
|
+
on macOS, `%LOCALAPPDATA%/browser4/downloads/` on Windows).
|
|
252
452
|
|
|
253
453
|
## Snapshots
|
|
254
454
|
|
|
@@ -262,10 +462,14 @@ After each command that modifies browser state, the CLI automatically:
|
|
|
262
462
|
## Examples
|
|
263
463
|
|
|
264
464
|
```shell
|
|
265
|
-
# Open a new browser window
|
|
465
|
+
# Open a new browser window (defaults to headed)
|
|
266
466
|
browser4-cli open
|
|
267
467
|
|
|
268
|
-
#
|
|
468
|
+
# Open in headed or headless mode
|
|
469
|
+
browser4-cli open --headed https://browser4.io
|
|
470
|
+
browser4-cli open --headless https://browser4.io
|
|
471
|
+
|
|
472
|
+
# Navigate to a page — auto-opens a session if none is active
|
|
269
473
|
browser4-cli goto https://playwright.dev
|
|
270
474
|
|
|
271
475
|
# Inspect the page — note the eN labels on interactive nodes
|
package/bin/.install-method
CHANGED
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bin/browser4-cli.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser4-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Browser automation CLI for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"version:sync": "node scripts/sync-version.js",
|
|
18
|
-
"version": "npm run version:sync && git add browser4-cli/Cargo.toml",
|
|
18
|
+
"version": "npm run version:sync && git add browser4-cli/Cargo.toml browser4-cli/Cargo.lock",
|
|
19
19
|
"build:native": "npm run version:sync && cargo build --release --manifest-path browser4-cli/Cargo.toml && node scripts/copy-native.js",
|
|
20
20
|
"build:linux": "npm run version:sync && docker compose -f docker/docker-compose.yml run --rm build-linux",
|
|
21
21
|
"build:macos": "npm run version:sync && (cargo build --release --manifest-path browser4-cli/Cargo.toml --target aarch64-apple-darwin & cargo build --release --manifest-path browser4-cli/Cargo.toml --target x86_64-apple-darwin & wait) && cp cli/target/aarch64-apple-darwin/release/browser4 bin/browser4-darwin-arm64 && cp cli/target/x86_64-apple-darwin/release/browser4 bin/browser4-darwin-x64",
|
|
22
22
|
"build:windows": "npm run version:sync && docker compose -f docker/docker-compose.yml run --rm build-windows",
|
|
23
|
-
"build:all-platforms": "npm run version:sync && (npm run build:linux & npm run build:windows & wait)",
|
|
23
|
+
"build:all-platforms": "npm run version:sync && (npm run build:linux & npm run build:windows & npm run build:macos & wait)",
|
|
24
24
|
"build:docker": "docker build -t browser4-builder -f docker/Dockerfile.build .",
|
|
25
25
|
"publish:if-needed": "node scripts/publish-if-needed.js",
|
|
26
26
|
"release": "npm run publish:if-needed",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/scripts/copy-native.js
CHANGED
|
File without changes
|
|
File without changes
|
package/scripts/postinstall.js
CHANGED
|
File without changes
|
|
File without changes
|
package/scripts/sync-version.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* Run this script before building or releasing.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import {execSync} from "child_process";
|
|
9
|
+
import {readFileSync, writeFileSync} from "fs";
|
|
10
|
+
import {dirname, join} from "path";
|
|
11
|
+
import {fileURLToPath} from "url";
|
|
12
12
|
|
|
13
13
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
14
|
const rootDir = join(__dirname, "..");
|
|
@@ -47,7 +47,7 @@ if (cargoVersionRegex.test(cargoToml)) {
|
|
|
47
47
|
// Update Cargo.lock to match Cargo.toml
|
|
48
48
|
if (cargoTomlUpdated) {
|
|
49
49
|
try {
|
|
50
|
-
execSync("cargo update -p browser4 --offline", {
|
|
50
|
+
execSync("cargo update -p browser4-cli --offline", {
|
|
51
51
|
cwd: cliDir,
|
|
52
52
|
stdio: "pipe",
|
|
53
53
|
});
|
|
@@ -55,7 +55,7 @@ if (cargoTomlUpdated) {
|
|
|
55
55
|
} catch {
|
|
56
56
|
// --offline may fail if package not in cache, try without it
|
|
57
57
|
try {
|
|
58
|
-
execSync("cargo update -p browser4", {
|
|
58
|
+
execSync("cargo update -p browser4-cli", {
|
|
59
59
|
cwd: cliDir,
|
|
60
60
|
stdio: "pipe",
|
|
61
61
|
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|