@xbrowser/cli 1.30.1 → 1.30.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/dist/index.js CHANGED
@@ -48,7 +48,7 @@ import {
48
48
  splitCommand,
49
49
  waitForAIResponse,
50
50
  waitForPage
51
- } from "./chunk-KPTD3SNJ.js";
51
+ } from "./chunk-Z6NMBZK3.js";
52
52
  import {
53
53
  SessionRecorder,
54
54
  readMarkdownSummary
@@ -64,10 +64,11 @@ import {
64
64
  getBrowser,
65
65
  resetForTesting,
66
66
  saveSessionDiskMeta
67
- } from "./chunk-BOZTIIBT.js";
67
+ } from "./chunk-BM6DDHA2.js";
68
68
  import "./chunk-JKVUFP3G.js";
69
69
  import {
70
70
  forwardCommandLog,
71
+ forwardExec,
71
72
  forwardNetworkAnalyze,
72
73
  forwardNetworkAround,
73
74
  forwardNetworkClear,
@@ -121,7 +122,7 @@ import {
121
122
  generateJSScript,
122
123
  generatePythonScript
123
124
  } from "./chunk-ETCO4SNK.js";
124
- import "./chunk-SPNWUUHA.js";
125
+ import "./chunk-VYGK4X33.js";
125
126
  import "./chunk-SMYSNO4M.js";
126
127
  import "./chunk-2KPI5GKP.js";
127
128
  import {
@@ -509,7 +510,8 @@ async function handleBrowserCommand(command, args, options, sessionName, mode, c
509
510
  type: options.type,
510
511
  selector: options.selector || options.s,
511
512
  base64: !!options.base64,
512
- output: options.output || options.o || args[0]
513
+ // --path 与 --output 等价(docs 曾写 --path 被静默忽略——fresh-agent 冒烟摩擦点 1)
514
+ output: options.output || options.o || options.path || args[0]
513
515
  };
514
516
  break;
515
517
  case "ua": {
@@ -5056,13 +5058,16 @@ async function handleEvalScript(parts, argv) {
5056
5058
  const cdpEndpoint = extractCdpFromArgv(argv);
5057
5059
  const sessionName = extractSessionNameFromArgv(argv);
5058
5060
  const mode = argv.some((a) => a === "--json" || a.startsWith("--json=") || a === "-j") ? "json" : argv.some((a) => a === "--yaml" || a.startsWith("--yaml=")) ? "yaml" : "text";
5059
- if (parts[0] === "--script-b64" && parts[1]) {
5060
- const chainResult2 = await executeChain(`eval --script-b64 ${parts[1]}`, { cdpEndpoint, sessionName, frame: extractFrameFromArgv(argv) });
5061
+ const emit = (result, duration) => {
5061
5062
  if (mode === "json" || mode === "yaml") {
5062
- outputEnvelope({ success: chainResult2.success, data: chainResult2.steps[chainResult2.steps.length - 1]?.data ?? null, duration: chainResult2.totalDuration }, { command: "eval" }, mode);
5063
+ outputEnvelope({ success: result.success, data: result.data, message: result.message, duration }, { command: "eval" }, mode);
5063
5064
  } else {
5064
- printChainResult(chainResult2);
5065
+ printChainResult({ success: result.success, steps: [{ command: "eval", raw: "eval", success: result.success, data: result.data, message: result.message, duration }], totalDuration: duration });
5065
5066
  }
5067
+ };
5068
+ if (parts[0] === "--script-b64" && parts[1]) {
5069
+ const chainResult2 = await executeChain(`eval --script-b64 ${parts[1]}`, { cdpEndpoint, sessionName, frame: extractFrameFromArgv(argv) });
5070
+ emit({ success: chainResult2.success, data: chainResult2.steps[chainResult2.steps.length - 1]?.data ?? null, message: chainResult2.steps[chainResult2.steps.length - 1]?.message }, chainResult2.totalDuration);
5066
5071
  if (!chainResult2.success) throw new Error("Command failed");
5067
5072
  return;
5068
5073
  }
@@ -5088,13 +5093,18 @@ async function handleEvalScript(parts, argv) {
5088
5093
  throw new Error("Command failed");
5089
5094
  }
5090
5095
  const b64 = Buffer.from(script, "utf8").toString("base64url");
5096
+ const forwarded = await forwardExec("eval", {
5097
+ ...frame ? { frame } : {},
5098
+ "script-b64": b64
5099
+ }, sessionName, cdpEndpoint).catch(() => null);
5100
+ if (forwarded) {
5101
+ emit({ success: forwarded.success, data: forwarded.data, message: forwarded.message }, 0);
5102
+ if (!forwarded.success) throw new Error("Command failed");
5103
+ return;
5104
+ }
5091
5105
  const chain = frame ? `eval --frame ${frame} --script-b64 ${b64}` : `eval --script-b64 ${b64}`;
5092
5106
  const chainResult = await executeChain(chain, { cdpEndpoint, sessionName });
5093
- if (mode === "json" || mode === "yaml") {
5094
- outputEnvelope({ success: chainResult.success, data: chainResult.steps[chainResult.steps.length - 1]?.data ?? null, duration: chainResult.totalDuration }, { command: "eval" }, mode);
5095
- } else {
5096
- printChainResult(chainResult);
5097
- }
5107
+ emit({ success: chainResult.success, data: chainResult.steps[chainResult.steps.length - 1]?.data ?? null, message: chainResult.steps[chainResult.steps.length - 1]?.message }, chainResult.totalDuration);
5098
5108
  if (!chainResult.success) throw new Error("Command failed");
5099
5109
  }
5100
5110
  async function handleChainInput(input, argv) {
@@ -5908,7 +5918,7 @@ async function handleRemote(args, options, mode) {
5908
5918
  }
5909
5919
  }
5910
5920
  async function startMcpServer() {
5911
- const { startMcpStdio } = await import("./server-TG47W7MV.js");
5921
+ const { startMcpStdio } = await import("./server-OZZ7NTCX.js");
5912
5922
  startMcpStdio();
5913
5923
  }
5914
5924
 
@@ -6223,7 +6233,7 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
6223
6233
  const targetPage = pages[cmdTabIndex];
6224
6234
  await targetPage.bringToFront().catch(() => {
6225
6235
  });
6226
- const { setActivePage } = await import("./browser-6PFTHZI3.js");
6236
+ const { setActivePage } = await import("./browser-JPTQ5JA2.js");
6227
6237
  setActivePage(session, targetPage);
6228
6238
  }
6229
6239
  }
@@ -9497,7 +9507,7 @@ var DataCollector = class {
9497
9507
  return results;
9498
9508
  }
9499
9509
  async createBrowserContext() {
9500
- const { launch } = await import("./cdp-driver-3ETNFQA4.js");
9510
+ const { launch } = await import("./cdp-driver-NGTMK5ID.js");
9501
9511
  const { browser } = await launch({
9502
9512
  headless: true,
9503
9513
  args: ["--no-sandbox", "--disable-setuid-sandbox"]
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getPluginLoader,
3
3
  resetPluginLoader
4
- } from "./chunk-LM32MNBB.js";
4
+ } from "./chunk-3DC3Y5OE.js";
5
5
  import "./chunk-KFQGP6VL.js";
6
6
  export {
7
7
  getPluginLoader,
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  executeChain,
3
3
  executeCommand
4
- } from "./chunk-KPTD3SNJ.js";
5
- import "./chunk-BOZTIIBT.js";
4
+ } from "./chunk-Z6NMBZK3.js";
5
+ import "./chunk-BM6DDHA2.js";
6
6
  import "./chunk-JKVUFP3G.js";
7
7
  import "./chunk-3OD76SUE.js";
8
8
  import "./chunk-ZTHE5RBZ.js";
9
9
  import "./chunk-Q2DFJQGS.js";
10
- import "./chunk-SPNWUUHA.js";
10
+ import "./chunk-VYGK4X33.js";
11
11
  import "./chunk-SMYSNO4M.js";
12
12
  import "./chunk-2KPI5GKP.js";
13
13
  import "./chunk-GDKLH7ZY.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  executeChain,
3
3
  executeCommand
4
- } from "./chunk-3K57RYVC.js";
4
+ } from "./chunk-G47VJ5OR.js";
5
5
  import "./chunk-JKVUFP3G.js";
6
6
  import "./chunk-3OD76SUE.js";
7
7
  import "./chunk-ZTHE5RBZ.js";
8
8
  import "./chunk-Q2DFJQGS.js";
9
- import "./chunk-OSIDUT4H.js";
9
+ import "./chunk-NBW3GGZB.js";
10
10
  import "./chunk-SMYSNO4M.js";
11
11
  import "./chunk-2KPI5GKP.js";
12
12
  import "./chunk-GDKLH7ZY.js";
@@ -142,7 +142,7 @@ var SessionReplayer = class {
142
142
  if (this.opts.page) {
143
143
  this.page = this.opts.page;
144
144
  } else if (this.opts.cdpUrl) {
145
- const { launch } = await import("./cdp-driver-WBFJNOLD.js");
145
+ const { launch } = await import("./cdp-driver-OA67L3ON.js");
146
146
  const { browser } = await launch({ cdpEndpoint: this.opts.cdpUrl });
147
147
  let contexts = browser.contexts();
148
148
  for (let i = 0; i < 10 && contexts.length === 0; i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xbrowser/cli",
3
- "version": "1.30.1",
3
+ "version": "1.30.3",
4
4
  "description": "Browser automation CLI for web scraping, headless browsing, SEO analysis, and AI agent workflows. A command-line alternative to Playwright, Puppeteer, and Selenium.",
5
5
  "type": "module",
6
6
  "bin": {