bb-browser-api 0.11.5 → 0.12.0

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.zh-CN.md CHANGED
@@ -205,7 +205,7 @@ curl -X POST http://localhost:18888/api/fetch \
205
205
  curl "http://localhost:18888/api/capture?url=https://example.com&pattern=api"
206
206
 
207
207
  # Storage API — 读取指定域名的 Cookie / localStorage / sessionStorage
208
- curl "http://localhost:18888/api/storage?domain=example.com"
208
+ curl "http://localhost:18888/api/storage?domain=baidu.com"
209
209
  ```
210
210
 
211
211
  **核心优势:** 在你的真实浏览器上下文中执行,自动携带 Cookie 和登录态。
package/dist/cli.js CHANGED
@@ -266,7 +266,7 @@ function getDaemonPath() {
266
266
  }
267
267
  return resolve(currentDir, "../../daemon/dist/index.js");
268
268
  }
269
- async function ensureDaemon() {
269
+ async function ensureDaemon(customCdpUrl) {
270
270
  if (daemonReady && cachedInfo) {
271
271
  try {
272
272
  const status = await httpJson("GET", "/status", cachedInfo, void 0, 2e3);
@@ -300,10 +300,27 @@ async function ensureDaemon() {
300
300
  }
301
301
  }
302
302
  }
303
- const cdpInfo = await discoverCdpPort();
303
+ let cdpInfo;
304
+ if (customCdpUrl) {
305
+ try {
306
+ const url = new URL(customCdpUrl);
307
+ cdpInfo = {
308
+ host: url.hostname,
309
+ port: parseInt(url.port) || 9222
310
+ };
311
+ } catch (error) {
312
+ throw new Error(
313
+ `bb-browser: Invalid CDP URL: ${customCdpUrl}
314
+
315
+ Expected format: http://localhost:9222 or http://127.0.0.1:9222`
316
+ );
317
+ }
318
+ } else {
319
+ cdpInfo = await discoverCdpPort();
320
+ }
304
321
  if (!cdpInfo) {
305
322
  throw new Error(
306
- "bb-browser: Cannot find a Chromium-based browser.\n\nPlease do one of the following:\n 1. Install Google Chrome, Edge, or Brave\n 2. Start Chrome with: google-chrome --remote-debugging-port=19825\n 3. Set BB_BROWSER_CDP_URL=http://host:port"
323
+ "bb-browser: Cannot find a Chromium-based browser.\n\nPlease do one of the following:\n 1. Install Google Chrome, Edge, or Brave\n 2. Start Chrome with: google-chrome --remote-debugging-port=19825\n 3. Set BB_BROWSER_CDP_URL=http://host:port\n 4. Use: bb-browser-api daemon start --cdp-url http://localhost:9222"
307
324
  );
308
325
  }
309
326
  const daemonPath = getDaemonPath();
@@ -2594,7 +2611,7 @@ Tabs (${tabs.length}):`);
2594
2611
  }
2595
2612
  }
2596
2613
  async function startCommand(options = {}) {
2597
- await ensureDaemon();
2614
+ await ensureDaemon(options.cdpUrl);
2598
2615
  const status = await getDaemonStatus();
2599
2616
  if (options.json) {
2600
2617
  console.log(JSON.stringify(status, null, 2));
@@ -2626,7 +2643,7 @@ function formatUptime(ms) {
2626
2643
  }
2627
2644
 
2628
2645
  // packages/cli/src/index.ts
2629
- var VERSION = "0.11.5";
2646
+ var VERSION = "0.12.0";
2630
2647
  var HELP_TEXT = `
2631
2648
  bb-browser - AI Agent \u6D4F\u89C8\u5668\u81EA\u52A8\u5316\u5DE5\u5177
2632
2649
 
@@ -2682,6 +2699,7 @@ bb-browser - AI Agent \u6D4F\u89C8\u5668\u81EA\u52A8\u5316\u5DE5\u5177
2682
2699
  trace start|stop|status \u5F55\u5236\u7528\u6237\u64CD\u4F5C
2683
2700
  history search|domains \u67E5\u770B\u6D4F\u89C8\u5386\u53F2
2684
2701
  daemon [start|status|stop] \u7BA1\u7406 daemon\uFF08start: \u540E\u53F0\u542F\u52A8\uFF09
2702
+ --cdp-url <url> \u6307\u5B9A CDP URL\uFF08\u4F8B\u5982\uFF1Ahttp://localhost:9222\uFF09
2685
2703
 
2686
2704
  \u9009\u9879\uFF1A
2687
2705
  --json \u4EE5 JSON \u683C\u5F0F\u8F93\u51FA
@@ -2967,7 +2985,9 @@ async function main() {
2967
2985
  break;
2968
2986
  }
2969
2987
  if (daemonSubcommand === "start") {
2970
- await startCommand({ json: parsed.flags.json });
2988
+ const cdpUrlIndex = process.argv.findIndex((a) => a === "--cdp-url");
2989
+ const cdpUrl = cdpUrlIndex >= 0 ? process.argv[cdpUrlIndex + 1] : void 0;
2990
+ await startCommand({ json: parsed.flags.json, cdpUrl });
2971
2991
  break;
2972
2992
  }
2973
2993
  const daemonPath = getDaemonPath();