browser4-cli 4.13.11 → 4.14.0-rc.2

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
@@ -38,6 +38,7 @@ English | [简体中文](README.zh.md) | [中国镜像](https://gitee.com/platon
38
38
  - [🚀 Build from Source](#-build-from-source)
39
39
  - [Architecture](#architecture)
40
40
  - [📦 Modules Overview](#-modules-overview)
41
+ - [🧩 Programming-Agent Kernel (browser4-coding)](#-programming-agent-kernel-browser4-coding)
41
42
  - [🧪 Test Fixture Server (MockSite)](#-test-fixture-server-mocksite)
42
43
  - [🤝 Support & Community](#-support--community)
43
44
  - [📜 Documentation](#-documentation)
@@ -51,11 +52,12 @@ English | [简体中文](README.zh.md) | [中国镜像](https://gitee.com/platon
51
52
 
52
53
  ### ✨ Key Capabilities
53
54
 
54
- * 🤖 **Agent Browser** — Enable AI agents to browse, interact, and automate real-world websites.
55
- * 🧠 **ML-Powered Extraction** — Learn page structures and extract structured data without LLM token costs.
56
- * ⚡ **High-Performance Runtime** — Coroutine-safe architecture supporting 100k–200k complex page visits per machine per day.
57
- * 🧬 **Hybrid Intelligence** — Combine LLM, ML, X-SQL, and selectors for robust extraction and experience reuse.
58
- * 📦 **Enterprise-Scale Automation** — Swarm crawling, CDP-native control, batch jobs, stateful sessions, plugins, extensions, and more.
55
+ * 🤖 **Agent Browser** — AI agents and humans drive real browsers via a Rust CLI, MCP, and an agentic backend: navigate, click, fill, snapshot, batch, and loop.
56
+ * 🧬 **Zero-Token Extraction** — X-SQL + CSS selectors for deterministic extraction from live pages or stored HTML snapshots; WebMiner ML clustering turns HTML corpora into spreadsheet and report views with no LLM tokens.
57
+ * 🧠 **Hybrid Intelligence** — Combine LLM extraction, ML clustering, X-SQL, and a progressive experience store that reuses learned selectors and blockers.
58
+ * ⚡ **High-Performance Runtime** — Coroutine-safe, CDP-native engine designed for 100k–200k complex page visits per machine per day via swarm/crawl scale-out.
59
+ * 📦 **Enterprise-Scale Automation** — Swarm crawling, batch/loop jobs, stateful sessions, plugins, runtime skills, browser extension, and MCP-over-HTTP.
60
+ * 🛠️ **Programming-Agent Kernel** — 50+ `coding.*` tools (sandboxed shell/fs, scaffolding, validation, self-development) for agents building Browser4 artifacts — or Browser4 itself.
59
61
 
60
62
  ## Quick Start
61
63
 
@@ -273,7 +275,7 @@ export DEEPSEEK_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
273
275
 
274
276
  | Command | Description |
275
277
  |---|---|
276
- | `open [url]` | Open a browser session or reconnect to an existing one. **Headless by default.** Supports `--headed` (visible window), `--headless`, `--profile <path>`, `--profile-mode <DEFAULT\|SYSTEM_DEFAULT\|SEQUENTIAL\|TEMPORARY>`, `--interact-level <FASTEST\|FAST\|DEFAULT>`. |
278
+ | `open [url]` | Open a browser session or reconnect to an existing one. **Headless by default.** Supports `--headed` (visible window), `--headless`, `--profile <path>`, `--profile-mode <DEFAULT\|SYSTEM_DEFAULT\|SEQUENTIAL\|TEMPORARY>`, `--interact-level <FASTEST\|FAST\|DEFAULT>`. **Note:** `SYSTEM_DEFAULT` is deprecated and unsupported on Chrome ≥ 143 — use `attach` + `state-save`/`state-load` to reuse system browser state (see [browser-state-import.md](skills/browser4-cli/references/browser-state-import.md)). |
277
279
  | `attach` | Attach to an existing browser via CDP or the Browser4 extension. Supports `--cdp <url\|port\|channel>` and remote endpoint options. |
278
280
  | `close` | Close the active browser session. |
279
281
  | `list` | List browser sessions with their status and next-open behavior. Supports `--all`. |
@@ -281,10 +283,11 @@ export DEEPSEEK_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
281
283
  | `close-all` | Close all sessions without stopping the backend. |
282
284
  | `kill-all` | Force-stop the backend and Browser4-managed browser processes. |
283
285
  | `stop` | Gracefully stop the Browser4 server. |
284
- | `status` | Show server version, port, and health. |
286
+ | `status` | Show server version, port, health, and the web status panel URL (`http://<server>:8182/status`). |
285
287
  | `doctor` | Run diagnostics: build info, LLM status, stale daemon cleanup, optional repair. Supports `--verbose` and `--fix`. |
286
288
  | `doctor log [name]` | List, view, tail, or grep backend log files. Supports `--tail`, grep-style flags, and `doctor log <name> grep <pattern>`. |
287
289
  | `doctor metrics [filter]` | List, filter, or grep backend metrics. Supports `doctor metrics grep <pattern>`. |
290
+ | `doctor status [--section <name>] [--verbose]` | Print the aggregated status panel report in the terminal: summary layer by default, full detail with `--verbose`, one report with `--section` (health, build, runtime, llm, sessions, pulsar-sessions, swarm, url-pool, browsers, drivers, privacy, plugins, skills, metrics, logs), machine-readable JSON with `--json`. |
288
291
  | `delete-data` | Delete session data. |
289
292
  | `install` | Install the Browser4 runtime bundle. Supports `--tag <version>` and `--force`. |
290
293
  | `upgrade` | Upgrade the CLI/runtime bundle. Supports `--tag <version>` and `--force`. |
@@ -296,8 +299,31 @@ browser4-cli attach --cdp chrome
296
299
  browser4-cli doctor --verbose
297
300
  browser4-cli doctor log server.log --tail
298
301
  browser4-cli doctor metrics grep request
302
+ browser4-cli doctor status --section skills --verbose
299
303
  ```
300
304
 
305
+ **Web status panel:** open `http://127.0.0.1:8182/status` in a browser for a live dashboard
306
+ (health, version, JVM/runtime, LLM config, sessions, **Pulsar sessions** — SDK identity,
307
+ context and main-loop state, **swarm** — swarm session plus task summary, **URL pool** —
308
+ queued/real-time/delay counts per priority cache, browsers & open tabs — per-session
309
+ browser/driver binding and tab counts, with on-demand live tab details via
310
+ `GET /api/system/tabs` — driver pools, plugins: load/enable state and SDK compatibility,
311
+ **skills**: registered skills with origin (classpath/filesystem/programmatic),
312
+ metrics, log files; auto-refreshes, set `?refresh=<ms>` to change the interval). The panel
313
+ is backed by the aggregated `GET /api/system/status` endpoint; the individual endpoints
314
+ (`/api/system/health`, `/api/system/build`, `/api/doctor/llm-status`, `/api/doctor/metrics`,
315
+ `/api/doctor/log-files`, `/api/plugins`, `/api/skills`) remain available. `browser4-cli plugin-list` also
316
+ reports load/enable state and SDK version for every installed plugin; the same reports can be
317
+ read from the terminal with `browser4-cli doctor status`.
318
+
319
+ **Page screenshots:** open `http://127.0.0.1:8182/pages.html` for a grid of every open page
320
+ across sessions. The active tab of each session is captured automatically (click a screenshot
321
+ to re-capture it); inactive tabs show a placeholder that captures on click. Swarm sessions only
322
+ show placeholders. Screenshots load **asynchronously** — the backend captures in the background
323
+ (`202 Accepted` with `Retry-After` while capturing, cached `image/png` when ready), so the panel
324
+ never blocks on a capture. Backed by `GET /api/pages` and
325
+ `GET /api/pages/{sessionId}/{guid}/screenshot.png` (`?refresh=1` forces a new capture).
326
+
301
327
  #### Navigation
302
328
 
303
329
  | Command | Description |
@@ -399,6 +425,7 @@ browser4-cli cdp Runtime.evaluate --json '{"expression":"document.title"}'
399
425
  | `htmlsnapshot summary` | Generate a compressed Web Page Summary Index (WPSI). |
400
426
  | `htmlsnapshot grep <pattern>` | Search stored HTML with grep-style flags. |
401
427
  | `htmlsnapshot inspect [selector]` | Discover recurring DOM patterns and selector candidates. Supports `--max`, `--depth`, `--stdin`, `--selector-base64`. |
428
+ | `htmlsnapshot readability [url]` | Extract the main article content with a Readability-style heuristic — no LLM, no tokens. Supports `--text-only` and pagination. |
402
429
 
403
430
  Important rules:
404
431
 
@@ -406,6 +433,7 @@ Important rules:
406
433
  - use `htmlsnapshot` when you need repeated DOM extraction
407
434
  - `htmlsnapshot query --sql @query.sql` is the recommended way to avoid shell quoting issues
408
435
  - for correlated list extraction, prefer `htmlsnapshot query` over repeated `get all`
436
+ - for one-step article extraction (no selectors needed), use `htmlsnapshot readability`
409
437
 
410
438
  ```bash
411
439
  browser4-cli htmlsnapshot
@@ -414,6 +442,7 @@ browser4-cli htmlsnapshot get all text ".result-title" --offset 10 --limit 5
414
442
  browser4-cli htmlsnapshot inspect ".s-result-item" --depth 6 --max 20
415
443
  browser4-cli htmlsnapshot export --file page.html --clean
416
444
  browser4-cli htmlsnapshot query --sql @query.sql
445
+ browser4-cli htmlsnapshot readability --text-only --all
417
446
  ```
418
447
 
419
448
  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).
@@ -468,7 +497,7 @@ These commands require an LLM key.
468
497
  | `summarize [instruction]` | Summarize the current page. Supports `--selector`, `--filename`, `--raw`, `--stdout`. |
469
498
  | `chat <message>` | Send a plain AI chat request without auto-appended browser context. |
470
499
  | `chat-result <id>` | Retrieve the result of an async chat task. |
471
- | `agent run <task>` | Submit an autonomous browser task and immediately receive a task ID. |
500
+ | `agent run <task>` | Submit an autonomous browser task and immediately receive a task ID. Supports `--wait` (block for the result) and `--wait-timeout <seconds>` (default 600). |
472
501
  | `agent status <id>` | Check a running task. |
473
502
  | `agent result <id>` | Fetch a completed result. |
474
503
  | `agent list` | List tracked agent tasks and their status. |
@@ -617,7 +646,7 @@ The runtime bundle is stored separately in a platform-conventional application-d
617
646
 
618
647
  ## 🚀 Build from Source
619
648
 
620
- **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).
649
+ **Prerequisites:** Git, JDK 25+ (Eclipse Temurin), 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).
621
650
 
622
651
  1. **Clone the repository**
623
652
  ```shell
@@ -676,6 +705,7 @@ browser4-cli (Rust) ──MCP over HTTP──▶ browser4-rest (Kotlin/Spring)
676
705
  - **Backend** (`browser4-rest`) — Spring Boot server, dispatches MCP tools to browser drivers
677
706
  - **Browser driver** (`browser4-core/browser4-browser`) — wraps Chrome DevTools Protocol
678
707
  - **Agent tools** (`browser4-agentic`) — maps MCP tool names to browser automation methods
708
+ - **Programming kernel** (`browser4-coding`) — dependency-light agent toolkit (sandboxed shell/filesystem, scaffolding, validation, self-development tools) — see [below](#-programming-agent-kernel-browser4-coding)
679
709
 
680
710
  ## 📦 Modules Overview
681
711
 
@@ -687,6 +717,7 @@ browser4-cli (Rust) ──MCP over HTTP──▶ browser4-rest (Kotlin/Spring)
687
717
  | `browser4-dependencies` | BOM and dependency version alignment |
688
718
  | `browser4-tools` | Operational tools and launch helpers |
689
719
  | `browser4-agentic` | AI agents, MCP integration, skill registration |
720
+ | `browser4-coding` | Programming-agent kernel — sandboxed shell/fs, artifact scaffolding & validation, self-development tools (47 `coding.*` tools) |
690
721
  | `browser4-agent-tools` | High-level agent tools: scraping, crawling, stateful page interaction |
691
722
  | `browser4-rest` | Spring Boot REST layer & command endpoints |
692
723
  | `browser4-apps/browser4-standalone` | Product packaging — unified launcher (`target/Browser4.jar`) |
@@ -697,6 +728,28 @@ browser4-cli (Rust) ──MCP over HTTP──▶ browser4-rest (Kotlin/Spring)
697
728
 
698
729
  ---
699
730
 
731
+ ## 🧩 Programming-Agent Kernel (browser4-coding)
732
+
733
+ `browser4-coding` is the dependency-light programming kernel that lets an AI agent create Browser4 artifacts **and** develop Browser4 itself. It is independent of `browser4-agentic` and `pulsar-common` (only SLF4J + Jackson + coroutines), so it can be reused by non-agent hosts. Heavy backends (LSP servers, kotlin-compiler-embeddable) are probed at runtime and never downloaded by default.
734
+
735
+ The `coding` domain exposes **47 tools** in four groups:
736
+
737
+ | Group | Count | Highlights |
738
+ |---|---|---|
739
+ | Shell & filesystem | 28 | sandboxed `coding.shell` (command whitelist), snapshot-based edit primitives with `revert`, `diff` (Myers/Patience), repo-governance protection (`coding.protect`) |
740
+ | Artifact creation & validation | 6 | `scaffold` (plugin/skill/js/script), `scaffoldFlow` (multi-file dev-flow), `scaffoldFromExample` (anti-staleness live templates, directory mode + stem-derived renames), `validate` (incl. `repo-consistency`) |
741
+ | Self-development | 7 | `mvnBuild` (structured diagnostics), `ktSymbols`/`ktReferences`/`ktInheritance` (zero-dep Kotlin analysis), `impact` + `moduleGraph` (live pom graph), `devTask` (AGENTS.md flow + execution), `trapCheck` (CDP pitfalls) |
742
+ | LSP | 4 | on-demand `diagnostics`/`symbols`/`references` for ts/js/py/rs (degrades gracefully when a server is missing) |
743
+
744
+ **Generic vs project-specific**: the kernel is layered by *mechanism vs data* — diff, sandbox, LSP client, Kotlin analysis, Maven passthrough and the pom-graph scanner are generic and portable; the scaffolds, validators, `ModuleMap`, `CdpTrapCheck` and the governance defaults encode Browser4 conventions and are the layer to rewrite when reusing the kernel elsewhere.
745
+
746
+ - Full tool reference & workflows: `skills/browser4-coding/SKILL.md`
747
+ - Developing Browser4 itself: `skills/browser4-dev/SKILL.md`
748
+ - Four-artifact comparison examples (real vs scaffold output): `docs-dev/copilot/examples/`
749
+ - Evaluation summary (P1–P7): `docs-dev/copilot/browser4-programming-support-eval.md`
750
+
751
+ ---
752
+
700
753
  ## 🧪 Test Fixture Server (MockSite)
701
754
 
702
755
  Browser4 includes a lightweight **MockSite** server that serves static HTML pages for testing and demos. Start it from the repository root:
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser4-cli",
3
- "version": "4.13.11",
3
+ "version": "4.14.0-rc.2",
4
4
  "description": "Browser automation CLI for AI agents",
5
5
  "type": "module",
6
6
  "files": [
@@ -9,8 +9,9 @@
9
9
  "skills"
10
10
  ],
11
11
  "bin": {
12
- "browser4-cli": "bin/browser4-cli.js",
13
- "browser4": "bin/browser4-cli.js"
12
+ "b4": "bin/browser4-cli.js",
13
+ "browser4": "bin/browser4-cli.js",
14
+ "browser4-cli": "bin/browser4-cli.js"
14
15
  },
15
16
  "scripts": {
16
17
  "sync:readme": "node scripts/sync-readme.mjs sync",
@@ -39,8 +39,20 @@ cleanup() {
39
39
  wait "$HTTP_PID" 2>/dev/null || true
40
40
  fi
41
41
  if [ -n "${TEMP_DIR:-}" ] && [ -d "$TEMP_DIR" ]; then
42
- rm -rf "$TEMP_DIR"
42
+ # On Windows the JVM/Chrome may hold jar and log handles open for a
43
+ # few seconds after kill-all ("Device or resource busy"). Retry
44
+ # briefly, and never let a cleanup failure override the script's
45
+ # PASS/FAIL exit status — the test result is what matters, and CI
46
+ # runners are ephemeral anyway.
47
+ local attempt
48
+ for attempt in 1 2 3 4 5; do
49
+ if rm -rf "$TEMP_DIR" 2>/dev/null; then
50
+ break
51
+ fi
52
+ sleep 2
53
+ done
43
54
  fi
55
+ return 0
44
56
  }
45
57
  trap cleanup EXIT
46
58
 
@@ -189,6 +201,13 @@ run_cli() {
189
201
  # BROWSER4_RUNTIME_DIR → where the installed runtime lives
190
202
  # BROWSER4_CLI_STATE_DIR → where CLI session state is persisted
191
203
  # BROWSER4_SERVER_LOG_DIR → where server startup logs go
204
+ # BROWSER4_CLI_FORCE_REMOTE_BUNDLE → skip the "build local bundle from
205
+ # the repo checkout" dev path. Without this, the CLI prefers a
206
+ # Maven rebuild of browser4-bundle when run inside a checkout
207
+ # (and hard-fails when Maven cannot run, e.g. no/mismatched JDK).
208
+ # The smoke test must exercise the *downloaded archive*, not a
209
+ # locally rebuilt bundle, so force the installed-runtime path.
210
+ BROWSER4_CLI_FORCE_REMOTE_BUNDLE=1 \
192
211
  BROWSER4_CLI_STATE_DIR="$STATE_DIR" \
193
212
  BROWSER4_RUNTIME_DIR="$RUNTIME_DIR" \
194
213
  BROWSER4_SERVER_LOG_DIR="$SERVER_LOG_DIR" \