browserpilot-cdp 1.2.3 → 1.2.5

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
@@ -3,8 +3,13 @@
3
3
  > **Zero-click, pure-CDP Chrome Extension, MCP Server & CLI for AI Agents.**
4
4
  > Control, inspect, and debug your real logged-in Chrome browser — no Playwright/Puppeteer runtime bloat, no per-tab icon clicking, and no repetitive Chrome `--autoConnect` "Allow" confirmation popups.
5
5
 
6
+ [![npm version](https://img.shields.io/npm/v/browserpilot-cdp?color=0ea5e9)](https://www.npmjs.com/package/browserpilot-cdp)
7
+ [![CI](https://github.com/xy-tuoren/browserpilot/actions/workflows/ci.yml/badge.svg)](https://github.com/xy-tuoren/browserpilot/actions/workflows/ci.yml)
8
+ [![Node.js >= 22](https://img.shields.io/badge/node-%3E%3D22-brightgreen.svg)](https://nodejs.org/)
6
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
7
10
 
11
+ **English** | [简体中文](./README.zh-CN.md)
12
+
8
13
  ---
9
14
 
10
15
  ## Why BrowserPilot?
@@ -50,28 +55,47 @@ AI Coding Agents (Claude Code / Cursor / Codex / Antigravity / Custom SDK)
50
55
 
51
56
  ## Quick Start (1 Minute)
52
57
 
53
- ### Option 1: Install from npm (Recommended)
58
+ ### Step 1: Install CLI & Initialize
54
59
 
55
60
  ```bash
56
61
  npm install -g browserpilot-cdp
57
62
  browserpilot setup
58
63
  ```
59
64
 
60
- 1. `browserpilot setup` automatically syncs the bundled extension to a stable upgrade-proof folder (`~/.browserpilot/extension`), computes its deterministic Chrome Extension ID, and registers the **Chrome Native Messaging Host** (`com.browserpilot.bridge`) — **no copying Extension IDs or manual auth tokens required**.
61
- 2. Open `chrome://extensions` in Chrome, enable **Developer mode**, click **Load unpacked**, and select `~/.browserpilot/extension`. It connects automatically on the first millisecond!
62
- 3. Add `browserpilot` to your AI coding agent MCP config (Claude Code / Cursor / Codex / Antigravity):
63
- ```json
64
- {
65
- "mcpServers": {
66
- "browserpilot": {
67
- "command": "browserpilot",
68
- "args": ["mcp"]
69
- }
70
- }
71
- }
72
- ```
73
-
74
- ### Option 2: Build from Source
65
+ > **Prerequisites:** Node.js >= 22 (`ffmpeg` is optional, only required for video recording).
66
+ > **Non-invasive by design:** `browserpilot setup` only syncs the bundled Chrome extension to `~/.browserpilot/extension`, computes its deterministic Chrome Extension ID, and registers the **Chrome Native Messaging Host** (`com.browserpilot.bridge`). It **never** modifies your AI agents' settings or skill folders.
67
+
68
+ ### Step 2: Load the Chrome Extension (1-Time)
69
+
70
+ 1. Open `chrome://extensions` in Chrome and enable **Developer mode**.
71
+ 2. Click **Load unpacked** and select `~/.browserpilot/extension`.
72
+ 3. It connects automatically via Native Messaging on the first millisecond — **no copying Extension IDs or manual auth tokens required**, and future upgrades keep the same path & ID.
73
+
74
+ *(Skip Step 2 if you only want to drive a separate `--remote-debugging-port` Chromium instance via `browserpilot browser start` or `--cdp`.)*
75
+
76
+ ### Step 3: Connect Only the AI Agent(s) You Want (Choose Option A or B)
77
+
78
+ - **Option A — Agent Skill + CLI (Lightweight, lowest context token usage):**
79
+ Install [`skills/browserpilot/SKILL.md`](./skills/browserpilot/SKILL.md) only into the specific agent or project where you want it — for example:
80
+ ```bash
81
+ npx skills add xy-tuoren/browserpilot
82
+ ```
83
+ Or copy `skills/browserpilot/SKILL.md` (or the output of `browserpilot skill`) into a single project's `.claude/skills/browserpilot/`, `.agents/skills/browserpilot/`, etc. No MCP configuration required.
84
+
85
+ - **Option B — MCP Server (43 native `browser_*` tools + direct multimodal screenshot blocks):**
86
+ Add this snippet to the MCP config of whichever agent you want (Claude Code, Cursor, Codex, Antigravity):
87
+ ```json
88
+ {
89
+ "mcpServers": {
90
+ "browserpilot": {
91
+ "command": "browserpilot",
92
+ "args": ["mcp"]
93
+ }
94
+ }
95
+ }
96
+ ```
97
+
98
+ ### Alternative: Build from Source / Direct CDP (No Extension)
75
99
 
76
100
  ```bash
77
101
  git clone https://github.com/xy-tuoren/browserpilot.git
@@ -81,7 +105,7 @@ pnpm build
81
105
  node packages/server/dist/cli.js setup
82
106
  ```
83
107
 
84
- Or connect directly to a `--remote-debugging-port` Chrome without an extension:
108
+ Or connect MCP directly to a `--remote-debugging-port` Chrome without loading the extension:
85
109
 
86
110
  ```json
87
111
  {
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ import path7 from "node:path";
8
8
  import { fileURLToPath as fileURLToPath3 } from "node:url";
9
9
 
10
10
  // ../protocol/dist/constants.js
11
- var BROWSERPILOT_VERSION = "1.2.3";
11
+ var BROWSERPILOT_VERSION = "1.2.5";
12
12
  var DEFAULT_DAEMON_HOST = "127.0.0.1";
13
13
  var DEFAULT_DAEMON_PORT = 19888;
14
14
  var NATIVE_HOST_NAME = "com.browserpilot.bridge";
@@ -859,7 +859,13 @@ var IGNORED_ANALYTICS_PATTERNS = [
859
859
  /posthog\.com/i,
860
860
  /datadoghq\.com/i,
861
861
  /hm\.baidu\.com/i,
862
- /\/collect\b|\/analytics\b|\/telemetry\b|\/beacon\b/i
862
+ /\/collect\b|\/analytics\b|\/telemetry\b|\/beacon\b/i,
863
+ // Long-polling & real-time push endpoints (Discourse message-bus, Socket.IO, SignalR, SSE)
864
+ /\/message-bus\//i,
865
+ /\/(long-?poll|polling|heartbeat|keepalive)\b/i,
866
+ /socket\.io/i,
867
+ /[?&]EIO=\d/i,
868
+ /\/signalr\//i
863
869
  ];
864
870
  function isIgnoredAnalyticsUrl(url) {
865
871
  return IGNORED_ANALYTICS_PATTERNS.some((re) => re.test(url));
@@ -879,7 +885,7 @@ async function waitForPageLoad(session, options = {}) {
879
885
  return;
880
886
  if (isIgnoredAnalyticsUrl(url))
881
887
  return;
882
- inflight.set(id, url);
888
+ inflight.set(id, { url, startedAt: Date.now() });
883
889
  });
884
890
  const offFin = session.on("Network.loadingFinished", (params) => {
885
891
  inflight.delete(String(params.requestId ?? ""));
@@ -887,6 +893,16 @@ async function waitForPageLoad(session, options = {}) {
887
893
  const offFail = session.on("Network.loadingFailed", (params) => {
888
894
  inflight.delete(String(params.requestId ?? ""));
889
895
  });
896
+ const countActiveInflight = (now, docComplete) => {
897
+ if (!docComplete)
898
+ return inflight.size;
899
+ let active = 0;
900
+ for (const item of inflight.values()) {
901
+ if (now - item.startedAt < 2500)
902
+ active++;
903
+ }
904
+ return active;
905
+ };
890
906
  let readyState = "loading";
891
907
  let idleSince = null;
892
908
  try {
@@ -905,17 +921,19 @@ async function waitForPageLoad(session, options = {}) {
905
921
  } catch {
906
922
  readyState = "loading";
907
923
  }
924
+ const now = Date.now();
908
925
  const stillOnBlank = Boolean(options.ignoreAboutBlank) && (!href || href === "about:blank");
909
- if (!stillOnBlank && (readyState === "complete" || readyState === "interactive") && inflight.size === 0) {
926
+ const activePending = countActiveInflight(now, readyState === "complete");
927
+ if (!stillOnBlank && (readyState === "complete" || readyState === "interactive") && activePending === 0) {
910
928
  if (idleSince === null)
911
- idleSince = Date.now();
912
- if (Date.now() - idleSince >= idleMs || readyState === "complete") {
913
- if (Date.now() - idleSince >= Math.min(idleMs, 150)) {
929
+ idleSince = now;
930
+ if (now - idleSince >= idleMs || readyState === "complete") {
931
+ if (now - idleSince >= Math.min(idleMs, 150)) {
914
932
  return {
915
933
  success: true,
916
934
  readyState,
917
935
  pendingRequests: 0,
918
- waitTimeMs: Date.now() - start,
936
+ waitTimeMs: now - start,
919
937
  timedOut: false
920
938
  };
921
939
  }
@@ -1058,14 +1076,35 @@ var LANDMARK_AND_STRUCTURE_ROLES = /* @__PURE__ */ new Set([
1058
1076
  "iframe"
1059
1077
  ]);
1060
1078
  var SKIPPED_ROLES = /* @__PURE__ */ new Set(["InlineTextBox", "LineBreak", "LayoutTable", "LayoutTableRow", "LayoutTableCell"]);
1079
+ var LEAF_LABELED_ROLES = /* @__PURE__ */ new Set([
1080
+ "link",
1081
+ "button",
1082
+ "heading",
1083
+ "tab",
1084
+ "menuitem",
1085
+ "menuitemcheckbox",
1086
+ "menuitemradio",
1087
+ "option",
1088
+ "checkbox",
1089
+ "radio",
1090
+ "switch",
1091
+ "textbox",
1092
+ "searchbox",
1093
+ "combobox"
1094
+ ]);
1061
1095
  function getProp(node, name) {
1062
1096
  const prop = node.properties?.find((p) => p.name === name);
1063
1097
  return prop?.value?.value;
1064
1098
  }
1065
- function cleanText(raw, maxLen = 140) {
1099
+ function normalizeWs(raw) {
1066
1100
  if (raw === void 0 || raw === null)
1067
1101
  return "";
1068
- const s = String(raw).replace(/\s+/g, " ").trim();
1102
+ return String(raw).replace(/\s+/g, " ").trim();
1103
+ }
1104
+ function cleanText(raw, maxLen = 140) {
1105
+ const s = normalizeWs(raw);
1106
+ if (!s)
1107
+ return "";
1069
1108
  if (s.length <= maxLen)
1070
1109
  return s;
1071
1110
  return `${s.slice(0, maxLen - 1)}\u2026`;
@@ -1091,7 +1130,7 @@ function formatAXTree(nodes, options = {}) {
1091
1130
  }
1092
1131
  }
1093
1132
  const visited = /* @__PURE__ */ new Set();
1094
- function renderNode(node, depth, parentName) {
1133
+ function renderNode(node, depth, parentName, parentLeafText) {
1095
1134
  if (depth > maxDepth || visited.has(node.nodeId))
1096
1135
  return;
1097
1136
  visited.add(node.nodeId);
@@ -1101,27 +1140,30 @@ function formatAXTree(nodes, options = {}) {
1101
1140
  const children = (node.childIds ?? []).map((id) => nodeMap.get(id)).filter((c) => Boolean(c));
1102
1141
  if (node.ignored) {
1103
1142
  for (const child of children)
1104
- renderNode(child, depth, parentName);
1143
+ renderNode(child, depth, parentName, parentLeafText);
1105
1144
  return;
1106
1145
  }
1107
- const name = cleanText(node.name?.value);
1146
+ const fullRawName = normalizeWs(node.name?.value);
1147
+ const name = cleanText(fullRawName);
1108
1148
  const value = cleanText(node.value?.value, 100);
1109
1149
  const isInteractive = INTERACTIVE_ROLES.has(role) || getProp(node, "focusable") === true;
1110
1150
  if (role === "RootWebArea" || role === "WebArea") {
1111
1151
  for (const child of children)
1112
- renderNode(child, depth, name);
1152
+ renderNode(child, depth, name, "");
1113
1153
  return;
1114
1154
  }
1115
1155
  if (role === "StaticText") {
1116
- if (includeText && name && name !== parentName) {
1117
- lines.push(`${" ".repeat(depth)}- text: "${name}"`);
1118
- }
1156
+ if (!includeText || !name || name === parentName)
1157
+ return;
1158
+ if (parentLeafText && parentLeafText.includes(fullRawName))
1159
+ return;
1160
+ lines.push(`${" ".repeat(depth)}- text: "${name}"`);
1119
1161
  return;
1120
1162
  }
1121
1163
  const isMeaningful = isInteractive || LANDMARK_AND_STRUCTURE_ROLES.has(role);
1122
1164
  if (!isMeaningful) {
1123
1165
  for (const child of children)
1124
- renderNode(child, depth, parentName);
1166
+ renderNode(child, depth, parentName, parentLeafText);
1125
1167
  return;
1126
1168
  }
1127
1169
  const lineStartIndex = lines.length;
@@ -1171,17 +1213,18 @@ function formatAXTree(nodes, options = {}) {
1171
1213
  const namePart = name ? ` "${name}"` : "";
1172
1214
  const attrPart = attrs.length > 0 ? ` (${attrs.join(", ")})` : "";
1173
1215
  lines.push(`${indent}- ${refPrefix}${role}${namePart}${attrPart}`);
1216
+ const nextLeafText = fullRawName && LEAF_LABELED_ROLES.has(role) ? fullRawName : parentLeafText;
1174
1217
  for (const child of children) {
1175
- renderNode(child, depth + 1, name || parentName);
1218
+ renderNode(child, depth + 1, name || parentName, nextLeafText);
1176
1219
  }
1177
1220
  if (!isInteractive && !name && attrs.length === 0 && lines.length === lineStartIndex + 1) {
1178
1221
  lines.pop();
1179
1222
  }
1180
1223
  }
1181
- renderNode(rootNode, 0, "");
1224
+ renderNode(rootNode, 0, "", "");
1182
1225
  return { lines, refs, nextRefIndex: refCounter };
1183
1226
  }
1184
- function filterSnapshotLines(fullText, search, maxMatches = 25) {
1227
+ function filterSnapshotLines(fullText, search, maxMatches = 40) {
1185
1228
  const allLines = fullText.split("\n");
1186
1229
  const header = allLines[0]?.startsWith("URL:") ? allLines[0] : "";
1187
1230
  const body = header ? allLines.slice(1) : allLines;
@@ -2766,7 +2809,16 @@ var ConsoleCollector = class {
2766
2809
  }
2767
2810
  }
2768
2811
  if (options.search !== void 0) {
2769
- const regex = options.search instanceof RegExp ? options.search : new RegExp(options.search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "i");
2812
+ let regex;
2813
+ if (options.search instanceof RegExp) {
2814
+ regex = options.search;
2815
+ } else {
2816
+ try {
2817
+ regex = new RegExp(options.search, "i");
2818
+ } catch {
2819
+ regex = new RegExp(options.search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "i");
2820
+ }
2821
+ }
2770
2822
  list = list.filter((e) => regex.test(e.text) || e.url && regex.test(e.url) || e.stackTrace && regex.test(e.stackTrace));
2771
2823
  }
2772
2824
  this.cursors.set(cursorKey, this.getLatestId());
@@ -2957,7 +3009,16 @@ var NetworkInspector = class {
2957
3009
  list = list.filter((e) => e.resourceType?.toLowerCase() === rt);
2958
3010
  }
2959
3011
  if (options.search !== void 0) {
2960
- const regex = options.search instanceof RegExp ? options.search : new RegExp(options.search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "i");
3012
+ let regex;
3013
+ if (options.search instanceof RegExp) {
3014
+ regex = options.search;
3015
+ } else {
3016
+ try {
3017
+ regex = new RegExp(options.search, "i");
3018
+ } catch {
3019
+ regex = new RegExp(options.search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "i");
3020
+ }
3021
+ }
2961
3022
  list = list.filter((e) => regex.test(e.url) || e.errorText && regex.test(e.errorText));
2962
3023
  }
2963
3024
  const latestTs = this.entries[this.entries.length - 1]?.timestamp ?? Date.now();
@@ -3186,7 +3247,8 @@ function formatStylesAsText(styles) {
3186
3247
  if (styles.inlineStyles.length) {
3187
3248
  lines.push(" element.style {");
3188
3249
  for (const d of styles.inlineStyles) {
3189
- lines.push(` ${d.name}: ${d.value}${d.important ? " !important" : ""};`);
3250
+ const imp = d.important && !/!important\s*$/i.test(d.value) ? " !important" : "";
3251
+ lines.push(` ${d.name}: ${d.value}${imp};`);
3190
3252
  }
3191
3253
  lines.push(" }");
3192
3254
  }
@@ -3195,7 +3257,8 @@ function formatStylesAsText(styles) {
3195
3257
  lines.push(` ${r.selector} {${loc}`);
3196
3258
  for (const d of r.declarations) {
3197
3259
  const strike = d.overridden ? " /* overridden */" : "";
3198
- lines.push(` ${d.name}: ${d.value}${d.important ? " !important" : ""};${strike}`);
3260
+ const imp = d.important && !/!important\s*$/i.test(d.value) ? " !important" : "";
3261
+ lines.push(` ${d.name}: ${d.value}${imp};${strike}`);
3199
3262
  }
3200
3263
  lines.push(" }");
3201
3264
  }
@@ -7146,42 +7209,56 @@ exec ${JSON.stringify(process.execPath)} ${JSON.stringify(nativeHostJs)} "$@"
7146
7209
  }
7147
7210
 
7148
7211
  // src/skill-doc.ts
7149
- var BROWSERPILOT_SKILL_DOC = `# BrowserPilot \u2014 Zero-Click Pure-CDP Browser Control & DevTools Guide
7212
+ var BROWSERPILOT_SKILL_DOC = `# BrowserPilot \u2014 Real Chrome Automation & DevTools Guide
7150
7213
 
7151
- BrowserPilot controls your real logged-in Chrome browser (existing cookies, logins, extensions) via pure CDP with **zero manual confirmation clicks**.
7214
+ BrowserPilot controls the user's running Chrome browser (existing logins, cookies, tabs) or a Direct CDP Chromium instance via pure CDP with zero per-tab confirmation clicks.
7152
7215
 
7153
- ## Core Workflow (Fast & Token-Efficient)
7216
+ ## 1. Choose Mode (MCP vs CLI)
7217
+ - If \`browser_*\` MCP tools are available in this session, prefer calling them directly (screenshots return inline image blocks automatically).
7218
+ - Otherwise use the \`browserpilot\` CLI in the shell.
7219
+ - If a command reports no browser connected, run \`browserpilot doctor\` to diagnose and report clearly.
7154
7220
 
7155
- 1. **Discover tabs**: \`browser_tabs\` (or \`browserpilot tabs\`) \u2014 lists all tabs with \`tabId\`, URL, and title.
7156
- 2. **Navigate or pick existing tab**: \`browser_open_tab\` / \`browser_select_tab\` / \`browser_navigate\`. BrowserPilot auto-attaches \`chrome.debugger\` on demand with zero clicks.
7157
- 3. **Perceive the page**:
7158
- - Prefer \`browser_snapshot\` (compact AXTree with \`e1\`, \`e2\`... refs + automatic incremental diffs).
7159
- - Use \`scope\` (CSS selector/ref) or \`search\` on large pages to save tokens.
7160
- - Use \`browser_labeled_screenshot\` (Set-of-Mark overlays) when visual layout matters.
7161
- 4. **Interact with trusted CDP input**:
7162
- - \`browser_click\`, \`browser_fill\`, \`browser_type\`, \`browser_press_key\`, \`browser_select_option\`, \`browser_drag\`, \`browser_upload_file\`.
7163
- - Every action automatically reports newly thrown Console errors and failed Network requests.
7164
- 5. **Debug like Chrome DevTools**:
7165
- - \`browser_console\` (\`sinceLastCall: true\`) \u2014 logs, warnings, uncaught exceptions with stacks.
7166
- - \`browser_network\` (\`failedOnly: true\`, or pass \`requestId\` for headers, timing, JS initiator stack, and response body).
7167
- - \`browser_network_intercept\` \u2014 mock/block API responses via CDP \`Fetch\`.
7168
- - \`browser_styles\` \u2014 matched/inherited CSS rules with \`file:line\` + forced \`:hover\`/\`:focus\`.
7169
- - \`browser_react_info\` \u2014 React Fiber component name, dev source \`file:line\`, hierarchy, props.
7170
- - \`browser_debugger\` \u2014 breakpoints, pause/step, local scope variables, evaluate in call frame.
7171
- - \`browser_live_edit\` \u2014 grep loaded scripts and live-patch JS/CSS in memory.
7172
- - \`browser_performance\` \u2014 Core Web Vitals (LCP/CLS/FCP/TTFB), heap summary, CPU profiler, Tracing insights.
7173
- - \`browser_emulate\` \u2014 viewport, mobile, dark mode, CPU throttling, Slow 3G / offline.
7174
- - \`browser_downloads\` \u2014 configure download folder, list downloads, or wait for a file download to complete with its local path.
7175
- - \`browser_action_recorder\` \u2014 record user clicks/fills/selects/navigations into reusable batch steps, exec JS script, and Agent Skill Markdown.
7176
- - \`browser_record\` \u2014 record MP4/WebM screencast video via \`ffmpeg\` (optional \`audio: true\`) and create smart idle-sped-up demo videos.
7177
- 6. **Multi-step Stateful Sandbox (Playwriter replacement)**:
7178
- - \`browserpilot session new --tab-group docs\` -> returns session ID (e.g. \`1\`)
7179
- - \`browserpilot exec -s 1 -e 'const t = await tabs.open("https://example.com"); console.log(await snapshot({ tab: t }))'\`
7180
- - Available sandbox globals: \`state\`, \`tabs\`, \`snapshot\`, \`screenshot\`, \`screenshotWithLabels\`, \`cleanHTML\`, \`markdown\`, \`inspect\`, \`getLatestLogs\`, \`getNetwork\`, \`getStyles\`, \`getReactInfo\`, \`waitForPageLoad\`, \`waitForSelector\`, \`waitForText\`, \`cdp\`, \`createDemoVideo\`.
7221
+ ## 2. Core Workflow
7222
+ 1. **Tabs**: \`browser_tabs\` / \`browserpilot tabs\`, or \`browser_open_tab\` / \`browserpilot open <url> --tab-group <name>\`. Always pass \`--tab <id>\` (\`tabId\`) when multiple tabs are open.
7223
+ 2. **Perceive**:
7224
+ - \`browser_snapshot\` / \`browserpilot snapshot --tab <id> [--search "<regex>"] [--scope "<css>"] [--full]\`
7225
+ - First call returns full AXTree with \`e1\`, \`e2\`... refs + viewport/scroll info; subsequent calls return diffs (pass \`--full\` / \`showDiffSinceLastCall: false\` for full output).
7226
+ - Use \`browser_labeled_screenshot\` / \`browserpilot labeled-screenshot <path>\` when spatial layout or icon-only buttons matter.
7227
+ 3. **Act (trusted CDP input)**:
7228
+ - \`click\`, \`fill\`, \`type\`, \`press_key\`, \`hover\`, \`scroll\`, \`drag\`, \`select_option\`, \`upload_file\`, \`batch\`.
7229
+ - Targets accept refs (\`e5\`), CSS selectors (\`#submit\`), \`role=button[name="Save"]\`, \`label=...\`, \`placeholder=...\`, \`text=...\`, \`>> nth=N\`, or \`pinned\`.
7230
+ 4. **DevTools Debugging**:
7231
+ - \`browser_console\` / \`browserpilot console --level error --since-last\`
7232
+ - \`browser_network\` / \`browserpilot network --failed\` (pass \`requestId\` for headers, timing, initiator stack, body)
7233
+ - \`browser_network_intercept\` \u2014 mock/block API responses via CDP \`Fetch\`
7234
+ - \`browser_styles\` / \`browserpilot styles <target>\` \u2014 clean author CSS rules with \`file:line\` + forced \`:hover\`/\`:focus\`
7235
+ - \`browser_react_info\` / \`browserpilot react <target>\` \u2014 React Fiber component, source \`file:line\`, props
7236
+ - \`browser_debugger\` / \`browser_live_edit\` \u2014 breakpoints, call frames, live JS/CSS patching
7237
+ - \`browser_performance\` / \`browserpilot perf metrics\` \u2014 Web Vitals (LCP/CLS/FCP/TTFB), heap, CPU/trace
7238
+ - \`browser_downloads\`, \`browser_action_recorder\`, \`browser_record\` (MP4/WebM + smart idle speedup)
7181
7239
 
7182
- ## Safety Rules
7183
- - Never wipe profile-wide cookies/cache (BrowserPilot blocks \`Network.clearBrowserCookies\` / \`Network.clearBrowserCache\` automatically; use page-scoped \`browser_cookies\`).
7184
- - Confirm with the user before irreversible actions (payments, deletions, account/security changes, sending public posts).
7240
+ ## 3. Stateful JS Sandbox (\`browserpilot exec\`)
7241
+ > Important: BrowserPilot is **pure CDP, NOT Playwright** \u2014 do NOT call \`page.locator(...)\`. Use \`t.page.*\` and built-in helpers.
7242
+
7243
+ \`\`\`bash
7244
+ SID=$(browserpilot session new --tab-group work)
7245
+ browserpilot exec -s "$SID" -e '
7246
+ const t = await tabs.open("http://localhost:3000");
7247
+ state.tab = t;
7248
+ await waitForSelector("#email", { tab: t });
7249
+ await t.page.fill("#email", "alice@example.com");
7250
+ await t.page.click("role=button[name=\\"Sign in\\"]");
7251
+ console.log(await snapshot({ tab: t }));
7252
+ '
7253
+ \`\`\`
7254
+
7255
+ Globals: \`state\`, \`tabs\` (\`list\`, \`open\`, \`use\`, \`current\`, \`close\`), \`snapshot\`, \`screenshot\`, \`screenshotWithLabels\`, \`cleanHTML\`, \`markdown\`, \`inspect\`, \`getLatestLogs\`, \`getNetwork\`, \`getStyles\`, \`getReactInfo\`, \`waitForPageLoad\`, \`waitForSelector\`, \`waitForText\`, \`downloads\`, \`actionRecorder\`, \`cdp\`, \`sleep\`, \`createDemoVideo\`.
7256
+
7257
+ ## 4. Safety & Pitfalls
7258
+ - Confirm with the user before irreversible actions (payments, deletions, account/security changes, public posts).
7259
+ - Never bypass CAPTCHAs, Cloudflare Turnstile, or 2FA/Passkey prompts \u2014 stop and let the user complete them in Chrome.
7260
+ - If \`Another debugger is already attached\` appears, ask the user to close DevTools / detach the other extension on that tab, or open a new tab with \`browserpilot open\`.
7261
+ - Never wipe profile-wide cookies/cache (blocked automatically; use page-scoped \`browser_cookies\`).
7185
7262
  `;
7186
7263
 
7187
7264
  // src/cli.ts
@@ -7318,9 +7395,15 @@ Direct Quick Commands:
7318
7395
  browserpilot open <url> [--tab-group <name>]
7319
7396
  browserpilot close <tabId>
7320
7397
  browserpilot navigate <url> [--tab <id>]
7398
+ browserpilot back | forward | reload [--ignore-cache] [--tab <id>]
7321
7399
  browserpilot snapshot [--tab <id>] [--search <regex>] [--scope <css>] [--full]
7400
+ browserpilot markdown [--search <regex>] [--full] [--tab <id>]
7401
+ browserpilot html [--selector <css>] [--search <regex>] [--full] [--tab <id>]
7322
7402
  browserpilot click <ref|selector> [--tab <id>]
7323
7403
  browserpilot fill <ref|selector> <value> [--tab <id>]
7404
+ browserpilot hover <ref|selector> [--tab <id>]
7405
+ browserpilot scroll [down|up|left|right] [--amount <px>] [--target <ref|sel>] [--tab <id>]
7406
+ browserpilot wait [--selector <css>] [--text <str>] [--ms <N>] [--timeout <ms>] [--tab <id>]
7324
7407
  browserpilot screenshot [outputPath] [--full-page] [--tab <id>]
7325
7408
  browserpilot labeled-screenshot [outputPath] [--tab <id>]
7326
7409
  browserpilot console [--level error] [--search <str>] [--since-last] [--tab <id>]
@@ -7502,7 +7585,13 @@ BrowserPilot Setup (v${BROWSERPILOT_VERSION})`);
7502
7585
  }
7503
7586
  const cliBin = path7.resolve(__dirname3, "cli.js");
7504
7587
  console.log(`
7505
- 4. MCP Server Config (Claude Code / Cursor / Codex / Antigravity):`);
7588
+ 4. Connect Your AI Agent (Choose Option A or B \u2014 setup never modifies your agent configs):`);
7589
+ console.log(`
7590
+ Option A \u2014 Agent Skill + CLI (install only where you want):`);
7591
+ console.log(` npx skills add xy-tuoren/browserpilot`);
7592
+ console.log(` (or print skill instructions with: browserpilot skill)`);
7593
+ console.log(`
7594
+ Option B \u2014 MCP Server (43 native tools + direct screenshot images):`);
7506
7595
  console.log(
7507
7596
  JSON.stringify(
7508
7597
  {
@@ -7695,6 +7784,22 @@ BrowserPilot Setup (v${BROWSERPILOT_VERSION})`);
7695
7784
  case "goto":
7696
7785
  printToolOutput(await client.callTool("browser_navigate", { url: positional[1], tabId, sessionId }));
7697
7786
  return;
7787
+ case "back":
7788
+ printToolOutput(await client.callTool("browser_history", { action: "back", tabId, sessionId }));
7789
+ return;
7790
+ case "forward":
7791
+ printToolOutput(await client.callTool("browser_history", { action: "forward", tabId, sessionId }));
7792
+ return;
7793
+ case "reload":
7794
+ printToolOutput(
7795
+ await client.callTool("browser_history", {
7796
+ action: "reload",
7797
+ ignoreCache: Boolean(flags["ignore-cache"]),
7798
+ tabId,
7799
+ sessionId
7800
+ })
7801
+ );
7802
+ return;
7698
7803
  case "snapshot":
7699
7804
  printToolOutput(
7700
7805
  await client.callTool("browser_snapshot", {
@@ -7706,9 +7811,60 @@ BrowserPilot Setup (v${BROWSERPILOT_VERSION})`);
7706
7811
  })
7707
7812
  );
7708
7813
  return;
7814
+ case "markdown":
7815
+ printToolOutput(
7816
+ await client.callTool("browser_markdown", {
7817
+ tabId,
7818
+ sessionId,
7819
+ search: typeof flags.search === "string" ? flags.search : void 0,
7820
+ showDiffSinceLastCall: flags.full ? false : void 0
7821
+ })
7822
+ );
7823
+ return;
7824
+ case "html":
7825
+ printToolOutput(
7826
+ await client.callTool("browser_clean_html", {
7827
+ tabId,
7828
+ sessionId,
7829
+ selector: typeof flags.selector === "string" ? flags.selector : void 0,
7830
+ search: typeof flags.search === "string" ? flags.search : void 0,
7831
+ showDiffSinceLastCall: flags.full ? false : void 0,
7832
+ includeStyles: Boolean(flags["include-styles"])
7833
+ })
7834
+ );
7835
+ return;
7709
7836
  case "click":
7710
7837
  printToolOutput(await client.callTool("browser_click", { target: positional[1], tabId, sessionId }));
7711
7838
  return;
7839
+ case "hover":
7840
+ printToolOutput(await client.callTool("browser_hover", { target: positional[1], tabId, sessionId }));
7841
+ return;
7842
+ case "scroll": {
7843
+ const dir = positional[1];
7844
+ const direction = dir === "up" || dir === "down" || dir === "left" || dir === "right" ? dir : "down";
7845
+ printToolOutput(
7846
+ await client.callTool("browser_scroll", {
7847
+ direction,
7848
+ amount: typeof flags.amount === "string" ? Number(flags.amount) : void 0,
7849
+ target: typeof flags.target === "string" ? flags.target : void 0,
7850
+ tabId,
7851
+ sessionId
7852
+ })
7853
+ );
7854
+ return;
7855
+ }
7856
+ case "wait":
7857
+ printToolOutput(
7858
+ await client.callTool("browser_wait", {
7859
+ selector: typeof flags.selector === "string" ? flags.selector : void 0,
7860
+ text: typeof flags.text === "string" ? flags.text : void 0,
7861
+ ms: typeof flags.ms === "string" ? Number(flags.ms) : void 0,
7862
+ timeoutMs: typeof flags.timeout === "string" ? Number(flags.timeout) : void 0,
7863
+ tabId,
7864
+ sessionId
7865
+ })
7866
+ );
7867
+ return;
7712
7868
  case "fill":
7713
7869
  printToolOutput(await client.callTool("browser_fill", { target: positional[1], value: positional[2] ?? "", tabId, sessionId }));
7714
7870
  return;