@xbrowser/cli 1.6.2 → 1.7.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.
@@ -98,6 +98,9 @@ async function startDaemonProcess(port = 9224) {
98
98
  });
99
99
  });
100
100
  }
101
+ async function stopDaemonProcess() {
102
+ await xcliStopDaemon(getDaemonConfig());
103
+ }
101
104
  function getDaemonProcessStatus() {
102
105
  const config = getDaemonConfig();
103
106
  const running = isDaemonRunning(config);
@@ -113,8 +116,16 @@ function getDaemonProcessStatus() {
113
116
  };
114
117
  }
115
118
 
119
+ // src/version.ts
120
+ import { createRequire } from "module";
121
+ var require2 = createRequire(import.meta.url);
122
+ var pkg = require2("../package.json");
123
+ var version = pkg.version;
124
+
116
125
  export {
117
126
  getDaemonConfig,
118
127
  startDaemonProcess,
119
- getDaemonProcessStatus
128
+ stopDaemonProcess,
129
+ getDaemonProcessStatus,
130
+ version
120
131
  };
@@ -123,6 +123,12 @@ function getDaemonProcessStatus() {
123
123
  };
124
124
  }
125
125
 
126
+ // src/version.ts
127
+ import { createRequire } from "module";
128
+ var require2 = createRequire(import.meta.url);
129
+ var pkg = require2("../package.json");
130
+ var version = pkg.version;
131
+
126
132
  // src/client/daemon-client.ts
127
133
  var DAEMON_PORT = 9224;
128
134
  var DAEMON_BASE = `http://localhost:${DAEMON_PORT}`;
@@ -136,8 +142,22 @@ async function ensureDaemonRunning() {
136
142
  _ensurePromise = null;
137
143
  }
138
144
  for (let attempt = 0; attempt < 3; attempt++) {
139
- const healthOk = await fetch(`${DAEMON_BASE}/health`, { signal: AbortSignal.timeout(2e3) }).then((r) => r.ok ? r.json() : null).then((d) => d?.status === "ok").catch(() => false);
140
- if (healthOk) return;
145
+ const healthOk = await fetch(`${DAEMON_BASE}/health`, { signal: AbortSignal.timeout(2e3) }).then((r) => r.ok ? r.json() : null).then((d) => {
146
+ if (d?.status === "ok") {
147
+ if (d.version && d.version !== version) {
148
+ return { needsRestart: true };
149
+ }
150
+ return { needsRestart: false };
151
+ }
152
+ return null;
153
+ }).catch(() => null);
154
+ if (healthOk?.needsRestart === false) return;
155
+ if (healthOk?.needsRestart === true) {
156
+ console.error(`\u26A0\uFE0F Daemon version mismatch. Restarting...`);
157
+ await stopDaemonProcess().catch(() => {
158
+ });
159
+ break;
160
+ }
141
161
  if (attempt < 2) await new Promise((r) => setTimeout(r, 500));
142
162
  }
143
163
  console.error("\u{1F504} Starting daemon...");
@@ -308,6 +328,7 @@ async function forwardViewerCheckSelector(name, selector) {
308
328
  }
309
329
 
310
330
  export {
331
+ version,
311
332
  getDaemonConfig,
312
333
  startDaemonProcess,
313
334
  stopDaemonProcess,
package/dist/cli.js CHANGED
@@ -53,8 +53,9 @@ import {
53
53
  getDaemonProcessStatus,
54
54
  killAllDaemonProcesses,
55
55
  startDaemonProcess,
56
- stopDaemonProcess
57
- } from "./chunk-L35D5DAY.js";
56
+ stopDaemonProcess,
57
+ version
58
+ } from "./chunk-53LRNYPG.js";
58
59
  import {
59
60
  errMsg
60
61
  } from "./chunk-GDKLH7ZY.js";
@@ -178,12 +179,6 @@ function asZodSchema(value) {
178
179
  return value;
179
180
  }
180
181
 
181
- // src/version.ts
182
- import { createRequire } from "module";
183
- var require2 = createRequire(import.meta.url);
184
- var pkg = require2("../package.json");
185
- var version = pkg.version;
186
-
187
182
  // src/executor.ts
188
183
  import {
189
184
  ok as ok25,
@@ -950,10 +945,7 @@ var evaluateCommand = registerCommand({
950
945
  const result = await ctx.page.evaluate(p.expression);
951
946
  const response = ok7({ result });
952
947
  if (decision && decision.severity === "danger") {
953
- response.tips = normalizeTips2([
954
- `\u26A0\uFE0F CDP Firewall: ${decision.reason}`,
955
- `\u{1F4A1} Fix: ${decision.suggestion}`
956
- ]);
948
+ response.tips = normalizeTips2([`${decision.suggestion}`]);
957
949
  }
958
950
  return response;
959
951
  }
@@ -6122,14 +6114,14 @@ function ensurePluginDependencies(pluginsDir) {
6122
6114
  if (existsSync3(zodPath)) return;
6123
6115
  mkdirSync4(pluginsDir, { recursive: true });
6124
6116
  const pkgPath = join5(pluginsDir, "package.json");
6125
- let pkg2 = {};
6117
+ let pkg = {};
6126
6118
  if (existsSync3(pkgPath)) {
6127
6119
  try {
6128
- pkg2 = readJsonFile(pkgPath, {});
6120
+ pkg = readJsonFile(pkgPath, {});
6129
6121
  } catch {
6130
6122
  }
6131
6123
  }
6132
- const existingDeps = pkg2.dependencies || {};
6124
+ const existingDeps = pkg.dependencies || {};
6133
6125
  let needsInstall = false;
6134
6126
  for (const [dep, version2] of Object.entries(SHARED_PLUGIN_DEPENDENCIES)) {
6135
6127
  if (!existingDeps[dep]) {
@@ -6138,10 +6130,10 @@ function ensurePluginDependencies(pluginsDir) {
6138
6130
  }
6139
6131
  }
6140
6132
  if (!needsInstall && existsSync3(join5(pluginsDir, "node_modules"))) return;
6141
- pkg2.dependencies = existingDeps;
6142
- pkg2.private = true;
6143
- pkg2.description = pkg2.description || "xbrowser plugins \u2014 shared dependencies";
6144
- writeFileSync5(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
6133
+ pkg.dependencies = existingDeps;
6134
+ pkg.private = true;
6135
+ pkg.description = pkg.description || "xbrowser plugins \u2014 shared dependencies";
6136
+ writeFileSync5(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
6145
6137
  try {
6146
6138
  execSync("npm install --production --no-package-lock --no-fund --no-audit", {
6147
6139
  cwd: pluginsDir,
@@ -7189,7 +7181,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7189
7181
  params = result.data;
7190
7182
  }
7191
7183
  if (command.scope !== "cli" && !process.env.XBROWSER_DAEMON_WORKER) {
7192
- const { forwardExec } = await import("./daemon-client-S3EUTRC6.js");
7184
+ const { forwardExec } = await import("./daemon-client-TOUDMIY5.js");
7193
7185
  const result = await forwardExec(commandName, params, sessionName, extraOpts?.cdpEndpoint);
7194
7186
  if (result) return result;
7195
7187
  }
@@ -8033,10 +8025,10 @@ async function installFromNpm(packageName, name, targetDir) {
8033
8025
  cpSync2(extractDir, targetDir, { recursive: true, force: true });
8034
8026
  const pkgPath = resolve4(targetDir, "package.json");
8035
8027
  if (existsSync6(pkgPath)) {
8036
- const pkg2 = JSON.parse(readFileSync4(pkgPath, "utf-8"));
8037
- if (!pkg2._npmSource) {
8038
- pkg2._npmSource = { name: packageName, version: latestVersion };
8039
- writeFileSync6(pkgPath, JSON.stringify(pkg2, null, 2));
8028
+ const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
8029
+ if (!pkg._npmSource) {
8030
+ pkg._npmSource = { name: packageName, version: latestVersion };
8031
+ writeFileSync6(pkgPath, JSON.stringify(pkg, null, 2));
8040
8032
  }
8041
8033
  }
8042
8034
  } finally {
@@ -8075,10 +8067,10 @@ async function installFromGit(gitUrl, name, targetDir) {
8075
8067
  rmSync3(resolve5(targetDir, ".git"), { recursive: true, force: true });
8076
8068
  const pkgPath = resolve5(targetDir, "package.json");
8077
8069
  if (existsSync7(pkgPath)) {
8078
- const pkg2 = JSON.parse(readFileSync5(pkgPath, "utf-8"));
8079
- if (!pkg2._gitSource) {
8080
- pkg2._gitSource = { url: gitUrl };
8081
- writeFileSync7(pkgPath, JSON.stringify(pkg2, null, 2));
8070
+ const pkg = JSON.parse(readFileSync5(pkgPath, "utf-8"));
8071
+ if (!pkg._gitSource) {
8072
+ pkg._gitSource = { url: gitUrl };
8073
+ writeFileSync7(pkgPath, JSON.stringify(pkg, null, 2));
8082
8074
  }
8083
8075
  }
8084
8076
  } finally {
@@ -8127,10 +8119,10 @@ async function installFromUrl(url, name, targetDir) {
8127
8119
  cpSync4(extractDir, targetDir, { recursive: true, force: true });
8128
8120
  const pkgPath = resolve6(targetDir, "package.json");
8129
8121
  if (existsSync8(pkgPath)) {
8130
- const pkg2 = JSON.parse(readFileSync6(pkgPath, "utf-8"));
8131
- if (!pkg2._urlSource) {
8132
- pkg2._urlSource = { url };
8133
- writeFileSync8(pkgPath, JSON.stringify(pkg2, null, 2));
8122
+ const pkg = JSON.parse(readFileSync6(pkgPath, "utf-8"));
8123
+ if (!pkg._urlSource) {
8124
+ pkg._urlSource = { url };
8125
+ writeFileSync8(pkgPath, JSON.stringify(pkg, null, 2));
8134
8126
  }
8135
8127
  }
8136
8128
  } finally {
@@ -8540,11 +8532,11 @@ var PluginInstaller = class {
8540
8532
  if (!existsSync10(indexPath) && !existsSync10(indexJsPath)) continue;
8541
8533
  const metadata = PluginMetadataParser.parseFromPackageJson(pluginPath);
8542
8534
  let source = "local";
8543
- const pkg2 = readJsonFile(resolve8(pluginPath, "package.json"), {});
8544
- if (pkg2._marketplace) source = "marketplace";
8545
- else if (pkg2._npmSource) source = "npm";
8546
- else if (pkg2._gitSource) source = "git";
8547
- else if (pkg2._urlSource) source = "url";
8535
+ const pkg = readJsonFile(resolve8(pluginPath, "package.json"), {});
8536
+ if (pkg._marketplace) source = "marketplace";
8537
+ else if (pkg._npmSource) source = "npm";
8538
+ else if (pkg._gitSource) source = "git";
8539
+ else if (pkg._urlSource) source = "url";
8548
8540
  plugins.push({
8549
8541
  id: entry.name,
8550
8542
  name: entry.name,
@@ -8884,8 +8876,8 @@ var NPMSearcher = class {
8884
8876
  }
8885
8877
  return parts.join(" ");
8886
8878
  }
8887
- static parseNPMPackage(pkg2) {
8888
- const data = pkg2;
8879
+ static parseNPMPackage(pkg) {
8880
+ const data = pkg;
8889
8881
  const author = this.parseAuthor(data.author);
8890
8882
  const links = this.parseLinks(data);
8891
8883
  const time = data.time;
@@ -10445,19 +10437,19 @@ async function handlePluginInfo(args, options, mode) {
10445
10437
  const distTags = data["dist-tags"];
10446
10438
  const latest = distTags?.latest;
10447
10439
  const versions = data.versions;
10448
- const pkg2 = latest && versions?.[latest];
10449
- if (pkg2) {
10440
+ const pkg = latest && versions?.[latest];
10441
+ if (pkg) {
10450
10442
  if (mode === "json") {
10451
- outputResult({ source: "npm", name: pkg2.name, version: latest, description: pkg2.description }, mode);
10443
+ outputResult({ source: "npm", name: pkg.name, version: latest, description: pkg.description }, mode);
10452
10444
  return;
10453
10445
  }
10454
- console.log(`\u540D\u79F0: ${pkg2.name || ""}`);
10446
+ console.log(`\u540D\u79F0: ${pkg.name || ""}`);
10455
10447
  console.log(`\u7248\u672C: ${latest}`);
10456
- console.log(`\u63CF\u8FF0: ${pkg2.description || ""}`);
10457
- const author = pkg2.author;
10448
+ console.log(`\u63CF\u8FF0: ${pkg.description || ""}`);
10449
+ const author = pkg.author;
10458
10450
  console.log(`\u4F5C\u8005: ${typeof author === "string" ? author : author?.name || ""}`);
10459
- console.log(`\u5173\u952E\u8BCD: ${(pkg2.keywords || []).join(", ")}`);
10460
- console.log(`\u8BB8\u53EF\u8BC1: ${pkg2.license || ""}`);
10451
+ console.log(`\u5173\u952E\u8BCD: ${(pkg.keywords || []).join(", ")}`);
10452
+ console.log(`\u8BB8\u53EF\u8BC1: ${pkg.license || ""}`);
10461
10453
  return;
10462
10454
  }
10463
10455
  }
@@ -10544,7 +10536,7 @@ async function handlePlugin(args, options, mode) {
10544
10536
  } catch {
10545
10537
  }
10546
10538
  try {
10547
- const { daemonPing } = await import("./daemon-client-S3EUTRC6.js");
10539
+ const { daemonPing } = await import("./daemon-client-TOUDMIY5.js");
10548
10540
  if (await daemonPing()) {
10549
10541
  await fetch("http://localhost:9224/rpc", {
10550
10542
  method: "POST",
@@ -12951,7 +12943,7 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
12951
12943
  }
12952
12944
  const needsBrowser = cmdEntry.scope === "page" || cmdEntry.scope === "browser";
12953
12945
  if (needsBrowser && !process.env.XBROWSER_DAEMON_WORKER) {
12954
- const { forwardExec } = await import("./daemon-client-S3EUTRC6.js");
12946
+ const { forwardExec } = await import("./daemon-client-TOUDMIY5.js");
12955
12947
  const userTimeout = typeof params.timeout === "number" && params.timeout > 0 ? params.timeout * 1e3 + 3e4 : void 0;
12956
12948
  const result = await forwardExec(`${command}.${subCommand}`, params, sessionName, cdpEndpoint, userTimeout);
12957
12949
  const resultData = result && typeof result === "object" && "data" in result ? result.data : void 0;
@@ -1,6 +1,8 @@
1
1
  import {
2
- startDaemonProcess
3
- } from "./chunk-O3FLVCUU.js";
2
+ startDaemonProcess,
3
+ stopDaemonProcess,
4
+ version
5
+ } from "./chunk-24SY6PE5.js";
4
6
  import {
5
7
  errMsg
6
8
  } from "./chunk-GDKLH7ZY.js";
@@ -19,8 +21,22 @@ async function ensureDaemonRunning() {
19
21
  _ensurePromise = null;
20
22
  }
21
23
  for (let attempt = 0; attempt < 3; attempt++) {
22
- const healthOk = await fetch(`${DAEMON_BASE}/health`, { signal: AbortSignal.timeout(2e3) }).then((r) => r.ok ? r.json() : null).then((d) => d?.status === "ok").catch(() => false);
23
- if (healthOk) return;
24
+ const healthOk = await fetch(`${DAEMON_BASE}/health`, { signal: AbortSignal.timeout(2e3) }).then((r) => r.ok ? r.json() : null).then((d) => {
25
+ if (d?.status === "ok") {
26
+ if (d.version && d.version !== version) {
27
+ return { needsRestart: true };
28
+ }
29
+ return { needsRestart: false };
30
+ }
31
+ return null;
32
+ }).catch(() => null);
33
+ if (healthOk?.needsRestart === false) return;
34
+ if (healthOk?.needsRestart === true) {
35
+ console.error(`\u26A0\uFE0F Daemon version mismatch. Restarting...`);
36
+ await stopDaemonProcess().catch(() => {
37
+ });
38
+ break;
39
+ }
24
40
  if (attempt < 2) await new Promise((r) => setTimeout(r, 500));
25
41
  }
26
42
  console.error("\u{1F504} Starting daemon...");
@@ -29,7 +29,7 @@ import {
29
29
  forwardSessionList,
30
30
  forwardViewerCheckSelector,
31
31
  isDaemonRunning
32
- } from "./chunk-L35D5DAY.js";
32
+ } from "./chunk-53LRNYPG.js";
33
33
  import "./chunk-GDKLH7ZY.js";
34
34
  import "./chunk-KFQGP6VL.js";
35
35
  export {
@@ -29,8 +29,9 @@ import {
29
29
  } from "./chunk-2QQDTXDL.js";
30
30
  import {
31
31
  getDaemonConfig,
32
- getDaemonProcessStatus
33
- } from "./chunk-O3FLVCUU.js";
32
+ getDaemonProcessStatus,
33
+ version
34
+ } from "./chunk-24SY6PE5.js";
34
35
  import {
35
36
  errMsg
36
37
  } from "./chunk-GDKLH7ZY.js";
@@ -911,10 +912,7 @@ var evaluateCommand = registerCommand({
911
912
  const result = await ctx.page.evaluate(p.expression);
912
913
  const response = ok7({ result });
913
914
  if (decision && decision.severity === "danger") {
914
- response.tips = normalizeTips2([
915
- `\u26A0\uFE0F CDP Firewall: ${decision.reason}`,
916
- `\u{1F4A1} Fix: ${decision.suggestion}`
917
- ]);
915
+ response.tips = normalizeTips2([`${decision.suggestion}`]);
918
916
  }
919
917
  return response;
920
918
  }
@@ -6720,7 +6718,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
6720
6718
  params = result.data;
6721
6719
  }
6722
6720
  if (command.scope !== "cli" && !process.env.XBROWSER_DAEMON_WORKER) {
6723
- const { forwardExec } = await import("./daemon-client-WT7PTGYQ.js");
6721
+ const { forwardExec } = await import("./daemon-client-PZX2KOLQ.js");
6724
6722
  const result = await forwardExec(commandName, params, sessionName, extraOpts?.cdpEndpoint);
6725
6723
  if (result) return result;
6726
6724
  }
@@ -11211,7 +11209,7 @@ async function main() {
11211
11209
  pathname: "/health",
11212
11210
  handler: (_req, res) => {
11213
11211
  res.writeHead(200, { "Content-Type": "application/json" });
11214
- res.end(JSON.stringify({ status: "ok", pid: process.pid }));
11212
+ res.end(JSON.stringify({ status: "ok", pid: process.pid, version }));
11215
11213
  }
11216
11214
  }
11217
11215
  ]
package/dist/index.js CHANGED
@@ -24,8 +24,9 @@ import {
24
24
  getDaemonProcessStatus,
25
25
  killAllDaemonProcesses,
26
26
  startDaemonProcess,
27
- stopDaemonProcess
28
- } from "./chunk-L35D5DAY.js";
27
+ stopDaemonProcess,
28
+ version
29
+ } from "./chunk-53LRNYPG.js";
29
30
  import {
30
31
  CaptchaDetector,
31
32
  HumanInteractionManager,
@@ -105,12 +106,6 @@ import {
105
106
  __require
106
107
  } from "./chunk-KFQGP6VL.js";
107
108
 
108
- // src/version.ts
109
- import { createRequire } from "module";
110
- var require2 = createRequire(import.meta.url);
111
- var pkg = require2("../package.json");
112
- var version = pkg.version;
113
-
114
109
  // src/executor.ts
115
110
  import {
116
111
  ok as ok25,
@@ -990,10 +985,7 @@ var evaluateCommand = registerCommand({
990
985
  const result = await ctx.page.evaluate(p.expression);
991
986
  const response = ok7({ result });
992
987
  if (decision && decision.severity === "danger") {
993
- response.tips = normalizeTips2([
994
- `\u26A0\uFE0F CDP Firewall: ${decision.reason}`,
995
- `\u{1F4A1} Fix: ${decision.suggestion}`
996
- ]);
988
+ response.tips = normalizeTips2([`${decision.suggestion}`]);
997
989
  }
998
990
  return response;
999
991
  }
@@ -6439,14 +6431,14 @@ function ensurePluginDependencies(pluginsDir) {
6439
6431
  if (existsSync3(zodPath)) return;
6440
6432
  mkdirSync4(pluginsDir, { recursive: true });
6441
6433
  const pkgPath = join5(pluginsDir, "package.json");
6442
- let pkg2 = {};
6434
+ let pkg = {};
6443
6435
  if (existsSync3(pkgPath)) {
6444
6436
  try {
6445
- pkg2 = readJsonFile(pkgPath, {});
6437
+ pkg = readJsonFile(pkgPath, {});
6446
6438
  } catch {
6447
6439
  }
6448
6440
  }
6449
- const existingDeps = pkg2.dependencies || {};
6441
+ const existingDeps = pkg.dependencies || {};
6450
6442
  let needsInstall = false;
6451
6443
  for (const [dep, version2] of Object.entries(SHARED_PLUGIN_DEPENDENCIES)) {
6452
6444
  if (!existingDeps[dep]) {
@@ -6455,10 +6447,10 @@ function ensurePluginDependencies(pluginsDir) {
6455
6447
  }
6456
6448
  }
6457
6449
  if (!needsInstall && existsSync3(join5(pluginsDir, "node_modules"))) return;
6458
- pkg2.dependencies = existingDeps;
6459
- pkg2.private = true;
6460
- pkg2.description = pkg2.description || "xbrowser plugins \u2014 shared dependencies";
6461
- writeFileSync5(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
6450
+ pkg.dependencies = existingDeps;
6451
+ pkg.private = true;
6452
+ pkg.description = pkg.description || "xbrowser plugins \u2014 shared dependencies";
6453
+ writeFileSync5(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
6462
6454
  try {
6463
6455
  execSync("npm install --production --no-package-lock --no-fund --no-audit", {
6464
6456
  cwd: pluginsDir,
@@ -7509,7 +7501,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7509
7501
  params = result.data;
7510
7502
  }
7511
7503
  if (command.scope !== "cli" && !process.env.XBROWSER_DAEMON_WORKER) {
7512
- const { forwardExec } = await import("./daemon-client-S3EUTRC6.js");
7504
+ const { forwardExec } = await import("./daemon-client-TOUDMIY5.js");
7513
7505
  const result = await forwardExec(commandName, params, sessionName, extraOpts?.cdpEndpoint);
7514
7506
  if (result) return result;
7515
7507
  }
@@ -8351,10 +8343,10 @@ async function installFromNpm(packageName, name, targetDir) {
8351
8343
  cpSync2(extractDir, targetDir, { recursive: true, force: true });
8352
8344
  const pkgPath = resolve4(targetDir, "package.json");
8353
8345
  if (existsSync6(pkgPath)) {
8354
- const pkg2 = JSON.parse(readFileSync4(pkgPath, "utf-8"));
8355
- if (!pkg2._npmSource) {
8356
- pkg2._npmSource = { name: packageName, version: latestVersion };
8357
- writeFileSync6(pkgPath, JSON.stringify(pkg2, null, 2));
8346
+ const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
8347
+ if (!pkg._npmSource) {
8348
+ pkg._npmSource = { name: packageName, version: latestVersion };
8349
+ writeFileSync6(pkgPath, JSON.stringify(pkg, null, 2));
8358
8350
  }
8359
8351
  }
8360
8352
  } finally {
@@ -8393,10 +8385,10 @@ async function installFromGit(gitUrl, name, targetDir) {
8393
8385
  rmSync3(resolve5(targetDir, ".git"), { recursive: true, force: true });
8394
8386
  const pkgPath = resolve5(targetDir, "package.json");
8395
8387
  if (existsSync7(pkgPath)) {
8396
- const pkg2 = JSON.parse(readFileSync5(pkgPath, "utf-8"));
8397
- if (!pkg2._gitSource) {
8398
- pkg2._gitSource = { url: gitUrl };
8399
- writeFileSync7(pkgPath, JSON.stringify(pkg2, null, 2));
8388
+ const pkg = JSON.parse(readFileSync5(pkgPath, "utf-8"));
8389
+ if (!pkg._gitSource) {
8390
+ pkg._gitSource = { url: gitUrl };
8391
+ writeFileSync7(pkgPath, JSON.stringify(pkg, null, 2));
8400
8392
  }
8401
8393
  }
8402
8394
  } finally {
@@ -8445,10 +8437,10 @@ async function installFromUrl(url, name, targetDir) {
8445
8437
  cpSync4(extractDir, targetDir, { recursive: true, force: true });
8446
8438
  const pkgPath = resolve6(targetDir, "package.json");
8447
8439
  if (existsSync8(pkgPath)) {
8448
- const pkg2 = JSON.parse(readFileSync6(pkgPath, "utf-8"));
8449
- if (!pkg2._urlSource) {
8450
- pkg2._urlSource = { url };
8451
- writeFileSync8(pkgPath, JSON.stringify(pkg2, null, 2));
8440
+ const pkg = JSON.parse(readFileSync6(pkgPath, "utf-8"));
8441
+ if (!pkg._urlSource) {
8442
+ pkg._urlSource = { url };
8443
+ writeFileSync8(pkgPath, JSON.stringify(pkg, null, 2));
8452
8444
  }
8453
8445
  }
8454
8446
  } finally {
@@ -8858,11 +8850,11 @@ var PluginInstaller = class {
8858
8850
  if (!existsSync10(indexPath) && !existsSync10(indexJsPath)) continue;
8859
8851
  const metadata = PluginMetadataParser.parseFromPackageJson(pluginPath);
8860
8852
  let source = "local";
8861
- const pkg2 = readJsonFile(resolve8(pluginPath, "package.json"), {});
8862
- if (pkg2._marketplace) source = "marketplace";
8863
- else if (pkg2._npmSource) source = "npm";
8864
- else if (pkg2._gitSource) source = "git";
8865
- else if (pkg2._urlSource) source = "url";
8853
+ const pkg = readJsonFile(resolve8(pluginPath, "package.json"), {});
8854
+ if (pkg._marketplace) source = "marketplace";
8855
+ else if (pkg._npmSource) source = "npm";
8856
+ else if (pkg._gitSource) source = "git";
8857
+ else if (pkg._urlSource) source = "url";
8866
8858
  plugins.push({
8867
8859
  id: entry.name,
8868
8860
  name: entry.name,
@@ -9202,8 +9194,8 @@ var NPMSearcher = class {
9202
9194
  }
9203
9195
  return parts.join(" ");
9204
9196
  }
9205
- static parseNPMPackage(pkg2) {
9206
- const data = pkg2;
9197
+ static parseNPMPackage(pkg) {
9198
+ const data = pkg;
9207
9199
  const author = this.parseAuthor(data.author);
9208
9200
  const links = this.parseLinks(data);
9209
9201
  const time = data.time;
@@ -10768,19 +10760,19 @@ async function handlePluginInfo(args, options, mode) {
10768
10760
  const distTags = data["dist-tags"];
10769
10761
  const latest = distTags?.latest;
10770
10762
  const versions = data.versions;
10771
- const pkg2 = latest && versions?.[latest];
10772
- if (pkg2) {
10763
+ const pkg = latest && versions?.[latest];
10764
+ if (pkg) {
10773
10765
  if (mode === "json") {
10774
- outputResult({ source: "npm", name: pkg2.name, version: latest, description: pkg2.description }, mode);
10766
+ outputResult({ source: "npm", name: pkg.name, version: latest, description: pkg.description }, mode);
10775
10767
  return;
10776
10768
  }
10777
- console.log(`\u540D\u79F0: ${pkg2.name || ""}`);
10769
+ console.log(`\u540D\u79F0: ${pkg.name || ""}`);
10778
10770
  console.log(`\u7248\u672C: ${latest}`);
10779
- console.log(`\u63CF\u8FF0: ${pkg2.description || ""}`);
10780
- const author = pkg2.author;
10771
+ console.log(`\u63CF\u8FF0: ${pkg.description || ""}`);
10772
+ const author = pkg.author;
10781
10773
  console.log(`\u4F5C\u8005: ${typeof author === "string" ? author : author?.name || ""}`);
10782
- console.log(`\u5173\u952E\u8BCD: ${(pkg2.keywords || []).join(", ")}`);
10783
- console.log(`\u8BB8\u53EF\u8BC1: ${pkg2.license || ""}`);
10774
+ console.log(`\u5173\u952E\u8BCD: ${(pkg.keywords || []).join(", ")}`);
10775
+ console.log(`\u8BB8\u53EF\u8BC1: ${pkg.license || ""}`);
10784
10776
  return;
10785
10777
  }
10786
10778
  }
@@ -10867,7 +10859,7 @@ async function handlePlugin(args, options, mode) {
10867
10859
  } catch {
10868
10860
  }
10869
10861
  try {
10870
- const { daemonPing } = await import("./daemon-client-S3EUTRC6.js");
10862
+ const { daemonPing } = await import("./daemon-client-TOUDMIY5.js");
10871
10863
  if (await daemonPing()) {
10872
10864
  await fetch("http://localhost:9224/rpc", {
10873
10865
  method: "POST",
@@ -13274,7 +13266,7 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
13274
13266
  }
13275
13267
  const needsBrowser = cmdEntry.scope === "page" || cmdEntry.scope === "browser";
13276
13268
  if (needsBrowser && !process.env.XBROWSER_DAEMON_WORKER) {
13277
- const { forwardExec } = await import("./daemon-client-S3EUTRC6.js");
13269
+ const { forwardExec } = await import("./daemon-client-TOUDMIY5.js");
13278
13270
  const userTimeout = typeof params.timeout === "number" && params.timeout > 0 ? params.timeout * 1e3 + 3e4 : void 0;
13279
13271
  const result = await forwardExec(`${command}.${subCommand}`, params, sessionName, cdpEndpoint, userTimeout);
13280
13272
  const resultData = result && typeof result === "object" && "data" in result ? result.data : void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xbrowser/cli",
3
- "version": "1.6.2",
3
+ "version": "1.7.0",
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": {