@xbrowser/cli 1.35.0 → 1.36.1

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.
Files changed (35) hide show
  1. package/README.md +137 -80
  2. package/dist/{browser-MLKP72XP.js → browser-IEZOLTHA.js} +1 -1
  3. package/dist/{browser-KY7AIRAB.js → browser-NHQDQRXB.js} +1 -1
  4. package/dist/{browser-RZ7DPBI3.js → browser-XELRNYBL.js} +1 -1
  5. package/dist/{chunk-53VZHESL.js → chunk-3ZHERY5Z.js} +2 -2
  6. package/dist/{chunk-Y2GRCINH.js → chunk-5BD2RE4G.js} +78 -6
  7. package/dist/{chunk-VYTQLZAX.js → chunk-5UXRFNXG.js} +28 -2
  8. package/dist/{chunk-JYYKMSFH.js → chunk-7O73V4GO.js} +1 -1
  9. package/dist/{chunk-C5ZPXPD7.js → chunk-DGPPP5XB.js} +53 -16
  10. package/dist/{chunk-EGOWDZXP.js → chunk-DUC664TA.js} +2 -2
  11. package/dist/{chunk-BLCBCESM.js → chunk-ENTENDF5.js} +1 -1
  12. package/dist/{chunk-WGS3Y6ZV.js → chunk-HNIGRT6P.js} +1 -1
  13. package/dist/{chunk-GNLZWHSP.js → chunk-KSB4PMCY.js} +1 -1
  14. package/dist/{chunk-RMYKVZIZ.js → chunk-L6QJUB33.js} +28 -2
  15. package/dist/{chunk-QRFM4NOV.js → chunk-NE344XKO.js} +78 -6
  16. package/dist/{chunk-43U5VDLB.js → chunk-PGEZJ6V3.js} +1 -1
  17. package/dist/chunk-YW4BIJQL.js +489 -0
  18. package/dist/cli.js +69 -51
  19. package/dist/convert-JNOM6H6A.js +490 -0
  20. package/dist/{convert-R3XXYKC6.js → convert-K6TLQEPX.js} +5 -3
  21. package/dist/{daemon-client-Z3NKNZRL.js → daemon-client-D4JG74IW.js} +3 -1
  22. package/dist/{daemon-client-OXKRGLPQ.js → daemon-client-XKWIZI4N.js} +53 -16
  23. package/dist/daemon-main.js +101 -15
  24. package/dist/index.d.ts +26 -3
  25. package/dist/index.js +68 -50
  26. package/dist/{run-routes-TFNV5BBR.js → run-routes-BDNVNZOS.js} +4 -4
  27. package/dist/{run-routes-SJKVZ34L.js → run-routes-FBMZ3OUW.js} +4 -4
  28. package/dist/{server-HUSX7EFE.js → server-6OWQMWRG.js} +2 -2
  29. package/dist/{server-KSP5H4HD.js → server-TPM3X3XK.js} +2 -2
  30. package/dist/{session-recorder-RUNQOJ7T.js → session-recorder-CNTY5KXF.js} +1 -1
  31. package/dist/{session-recorder-N7VEKJVW.js → session-recorder-KMKSQWEP.js} +1 -1
  32. package/dist/{viewer-routes-YOS5GTCV.js → viewer-routes-7E7S2QBD.js} +2 -2
  33. package/package.json +3 -2
  34. package/dist/chunk-ETCO4SNK.js +0 -206
  35. package/dist/convert-LB3GJTLR.js +0 -207
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  buildId,
11
11
  version
12
- } from "./chunk-WGS3Y6ZV.js";
12
+ } from "./chunk-HNIGRT6P.js";
13
13
  import {
14
14
  buildViewerUrl
15
15
  } from "./chunk-TZPKFUBT.js";
@@ -26,7 +26,7 @@ import {
26
26
  } from "./chunk-VEDJ5XSQ.js";
27
27
  import {
28
28
  SessionRecorder
29
- } from "./chunk-VYTQLZAX.js";
29
+ } from "./chunk-5UXRFNXG.js";
30
30
  import {
31
31
  closeEphemeralContext,
32
32
  closeSessionByName,
@@ -45,7 +45,7 @@ import {
45
45
  saveSessionDiskMeta,
46
46
  sessions,
47
47
  setActivePage
48
- } from "./chunk-43U5VDLB.js";
48
+ } from "./chunk-PGEZJ6V3.js";
49
49
  import {
50
50
  createRuleEngine
51
51
  } from "./chunk-ZCZELQCS.js";
@@ -3375,6 +3375,19 @@ function stripHashAnchorQuery(url) {
3375
3375
  return url;
3376
3376
  }
3377
3377
  }
3378
+ function createPageBudget(limit, used) {
3379
+ let reserved = used;
3380
+ return {
3381
+ tryAcquire() {
3382
+ if (reserved >= limit) return false;
3383
+ reserved++;
3384
+ return true;
3385
+ },
3386
+ isExhausted() {
3387
+ return reserved >= limit;
3388
+ }
3389
+ };
3390
+ }
3378
3391
  async function extractLinks(page, origin) {
3379
3392
  return page.evaluate((evalOrigin) => {
3380
3393
  return Array.from(document.querySelectorAll("a[href]")).map((a) => {
@@ -3652,6 +3665,7 @@ var crawlCommand = registerCommand({
3652
3665
  await seedPage.close();
3653
3666
  const pagePool = [];
3654
3667
  const poolSize = Math.min(options.concurrency, options.limit);
3668
+ const budget = createPageBudget(options.limit, results.length);
3655
3669
  for (let i = 0; i < poolSize; i++) {
3656
3670
  const ctx2 = await browser.newContext();
3657
3671
  contexts.push(ctx2);
@@ -3669,7 +3683,7 @@ var crawlCommand = registerCommand({
3669
3683
  return null;
3670
3684
  };
3671
3685
  const crawlWorker = async (page) => {
3672
- while (results.length < options.limit) {
3686
+ while (budget.tryAcquire()) {
3673
3687
  const item = dequeueNext();
3674
3688
  if (!item) break;
3675
3689
  completedCount++;
@@ -3683,7 +3697,7 @@ var crawlCommand = registerCommand({
3683
3697
  const pageTitle = await page.title();
3684
3698
  const pageContent = options.format === "html" ? pageHtml : htmlToMarkdown(pageHtml, { onlyMainContent: options.onlyMainContent });
3685
3699
  results.push({ url: page.url(), title: pageTitle, content: pageContent });
3686
- if (results.length >= options.limit) break;
3700
+ if (budget.isExhausted()) break;
3687
3701
  const links = await extractLinks(page, startUrl.origin);
3688
3702
  for (const link of links) {
3689
3703
  try {
@@ -8728,6 +8742,41 @@ function getTipsManager() {
8728
8742
  return globalTipsManager;
8729
8743
  }
8730
8744
 
8745
+ // src/utils/zod-internal.ts
8746
+ function asZodSchema(value) {
8747
+ return value;
8748
+ }
8749
+
8750
+ // src/utils/kebab-params.ts
8751
+ function toCamelCase(key) {
8752
+ return key.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
8753
+ }
8754
+ function schemaParamNames(schema) {
8755
+ for (let node = schema, depth = 0; node != null && depth < 5; depth++) {
8756
+ const internal = asZodSchema(node);
8757
+ const shape = internal.shape ?? internal._def?.shape;
8758
+ if (shape) {
8759
+ return new Set(Object.keys(typeof shape === "function" ? shape() : shape));
8760
+ }
8761
+ node = internal._def?.innerType ?? internal._def?.schema;
8762
+ }
8763
+ return void 0;
8764
+ }
8765
+ function normalizeKebabParams(schema, params) {
8766
+ const names = schemaParamNames(schema);
8767
+ if (!names) return params;
8768
+ let renamed;
8769
+ for (const [key, value] of Object.entries(params)) {
8770
+ if (!key.includes("-")) continue;
8771
+ const camelKey = toCamelCase(key);
8772
+ if (camelKey === key || !names.has(camelKey) || names.has(key)) continue;
8773
+ renamed ??= { ...params };
8774
+ if (!(camelKey in params)) renamed[camelKey] = value;
8775
+ delete renamed[key];
8776
+ }
8777
+ return renamed ?? params;
8778
+ }
8779
+
8731
8780
  // src/hooks/loader.ts
8732
8781
  var FAIL_KEYWORDS = [
8733
8782
  "\u767B\u5F55",
@@ -9312,7 +9361,7 @@ async function executePluginChainStep(context) {
9312
9361
  }
9313
9362
  const needsBrowser = cmdEntry.scope === "page" || cmdEntry.scope === "browser";
9314
9363
  if (needsBrowser && !process.env.XBROWSER_DAEMON_WORKER) {
9315
- const { forwardPluginExec } = await import("./daemon-client-OXKRGLPQ.js");
9364
+ const { forwardPluginExec } = await import("./daemon-client-XKWIZI4N.js");
9316
9365
  const userTimeout = typeof pluginParams.timeout === "number" && pluginParams.timeout > 0 ? pluginParams.timeout * 1e3 + 3e4 : void 0;
9317
9366
  const startFwd = Date.now();
9318
9367
  const fwd = await forwardPluginExec(
@@ -9539,7 +9588,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
9539
9588
  }
9540
9589
  let targetPageOverride = null;
9541
9590
  if (_target && extraOpts?.cdpEndpoint) {
9542
- const { findTargetPage } = await import("./browser-MLKP72XP.js");
9591
+ const { findTargetPage } = await import("./browser-IEZOLTHA.js");
9543
9592
  targetPageOverride = await findTargetPage(extraOpts.cdpEndpoint, _target);
9544
9593
  if (!targetPageOverride) {
9545
9594
  return errorResult(`Target "${_target}" not found. Use 'xbrowser targets --cdp ${extraOpts.cdpEndpoint}' to list available pages.`);
@@ -9547,6 +9596,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
9547
9596
  params = { ...params, url: targetPageOverride.url };
9548
9597
  }
9549
9598
  if (command.parameters) {
9599
+ params = normalizeKebabParams(command.parameters, params);
9550
9600
  const result = command.parameters.safeParse(params);
9551
9601
  if (!result.success) {
9552
9602
  return errorResult(
@@ -9556,7 +9606,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
9556
9606
  params = result.data;
9557
9607
  }
9558
9608
  if (command.scope !== "cli" && !process.env.XBROWSER_DAEMON_WORKER) {
9559
- const { forwardExec } = await import("./daemon-client-OXKRGLPQ.js");
9609
+ const { forwardExec } = await import("./daemon-client-XKWIZI4N.js");
9560
9610
  const longRunning = /^(vision-task|task|crawl|scrape|record|replay)$/.test(commandName);
9561
9611
  const result = await forwardExec(
9562
9612
  commandName,
@@ -10911,15 +10961,21 @@ function createRPCHandler() {
10911
10961
  }
10912
10962
  } catch {
10913
10963
  }
10964
+ const releaseReservation = reserveCommandAction(sessionName, command, cmdParams, preElement);
10965
+ let recorded = false;
10914
10966
  try {
10915
10967
  const result = await executeCommand(command, cmdParams, sessionName, {
10916
10968
  cdpEndpoint: endpoint,
10917
10969
  bridge: params.bridge === true
10918
10970
  });
10919
10971
  registerSessionIfNew(sessionName);
10920
- await injectCommandToRecorder(sessionName, command, cmdParams, urlBeforeCommand, preElement);
10972
+ if (result.success) {
10973
+ await injectCommandToRecorder(sessionName, command, cmdParams, urlBeforeCommand, preElement);
10974
+ recorded = true;
10975
+ }
10921
10976
  return result;
10922
10977
  } finally {
10978
+ if (!recorded) releaseReservation();
10923
10979
  if (needsPause) await previewWS.resumeScreencast(sessionName).catch(() => {
10924
10980
  });
10925
10981
  }
@@ -11130,9 +11186,7 @@ function createRPCHandler() {
11130
11186
  const limit = params.limit || 50;
11131
11187
  return { session: sessionName, commands: commandLogStore.list(sessionName, { limit }) };
11132
11188
  }
11133
- async function injectCommandToRecorder(sessionName, command, params, urlBeforeCommand, preElement) {
11134
- const recorder = activeRecorders.get(sessionName);
11135
- if (!recorder) return;
11189
+ function describeCommandAction(command, params) {
11136
11190
  const COMMAND_ACTION_MAP = {
11137
11191
  goto: "goto",
11138
11192
  fill: "cdp-fill",
@@ -11141,8 +11195,8 @@ function createRPCHandler() {
11141
11195
  select: "change",
11142
11196
  scroll: "scroll"
11143
11197
  };
11144
- const actionType = COMMAND_ACTION_MAP[command];
11145
- if (!actionType) return;
11198
+ const type = COMMAND_ACTION_MAP[command];
11199
+ if (!type) return void 0;
11146
11200
  const selector = params.selector || params.css;
11147
11201
  let value = params.value || params.expression;
11148
11202
  if (value === void 0 || value === "") {
@@ -11153,6 +11207,26 @@ function createRPCHandler() {
11153
11207
  const dist = params.distance ?? 300;
11154
11208
  value = `${dir}:${dist}`;
11155
11209
  }
11210
+ return { type, selector, value };
11211
+ }
11212
+ function reserveCommandAction(sessionName, command, params, preElement) {
11213
+ const recorder = activeRecorders.get(sessionName);
11214
+ const action = describeCommandAction(command, params);
11215
+ if (!recorder || !action?.selector) return () => {
11216
+ };
11217
+ return recorder.reserveCommandAction({
11218
+ type: action.type,
11219
+ // Same converged selector as injectCommandToRecorder (rec-duel d04/d06).
11220
+ selector: preElement?.selector || action.selector,
11221
+ value: action.value
11222
+ });
11223
+ }
11224
+ async function injectCommandToRecorder(sessionName, command, params, urlBeforeCommand, preElement) {
11225
+ const recorder = activeRecorders.get(sessionName);
11226
+ if (!recorder) return;
11227
+ const action = describeCommandAction(command, params);
11228
+ if (!action) return;
11229
+ const { type: actionType, selector, value } = action;
11156
11230
  let currentUrl = params.url || urlBeforeCommand;
11157
11231
  if (command !== "goto" && urlBeforeCommand && urlBeforeCommand !== "about:blank") {
11158
11232
  currentUrl = urlBeforeCommand;
@@ -11471,6 +11545,18 @@ function createRPCHandler() {
11471
11545
  }
11472
11546
  }
11473
11547
 
11548
+ // src/daemon/health.ts
11549
+ function buildHealthPayload(identity, startedAt, pid) {
11550
+ return {
11551
+ status: "ok",
11552
+ pid,
11553
+ version: identity.version,
11554
+ buildId: identity.buildId,
11555
+ startedAt,
11556
+ activeSessions: sessions.size
11557
+ };
11558
+ }
11559
+
11474
11560
  // src/websocket-server.ts
11475
11561
  import { EventEmitter as EventEmitter2 } from "events";
11476
11562
 
@@ -15492,7 +15578,7 @@ async function main() {
15492
15578
  pathname: "/health",
15493
15579
  handler: (_req, res) => {
15494
15580
  res.writeHead(200, { "Content-Type": "application/json" });
15495
- res.end(JSON.stringify({ status: "ok", pid: process.pid, version, buildId, startedAt }));
15581
+ res.end(JSON.stringify(buildHealthPayload({ version, buildId }, startedAt, process.pid)));
15496
15582
  }
15497
15583
  }
15498
15584
  ]
package/dist/index.d.ts CHANGED
@@ -2475,6 +2475,22 @@ declare class SessionRecorder {
2475
2475
  url?: string;
2476
2476
  element?: UserAction['element'];
2477
2477
  }): Promise<void>;
2478
+ /**
2479
+ * Reserve the dedup entry for a command BEFORE it executes. Both sides used
2480
+ * to write their entry only after their awaited captures (element screenshot,
2481
+ * auto-snapshot, click context): a fast click's signal was flushed while the
2482
+ * command was still in flight, found no 'command' entry and recorded itself,
2483
+ * and the command then found no 'signal' entry and recorded again.
2484
+ * Returns an undo for commands that end up recording nothing (failed or
2485
+ * thrown) — a reservation left behind would swallow a later real action on
2486
+ * the same element. A live 'signal' entry is kept: the real action was
2487
+ * already recorded and must still suppress the duplicate command action.
2488
+ */
2489
+ reserveCommandAction(action: {
2490
+ type: string;
2491
+ selector?: string;
2492
+ value?: string;
2493
+ }): () => void;
2478
2494
  /** Generate dedup key for an action (normalized type + selector/tag + value). */
2479
2495
  private dedupKey;
2480
2496
  get networkCount(): number;
@@ -2998,10 +3014,16 @@ interface RecordingEvent {
2998
3014
  }
2999
3015
  /**
3000
3016
  * A browser recording session with a start URL and captured events.
3017
+ *
3018
+ * Two on-disk formats exist: the legacy `events` list (selector at the top
3019
+ * level, values under `data`) and the `actions` list written by the current
3020
+ * recorder (selector under `element`, value/key/coords at the top level).
3001
3021
  */
3002
3022
  interface Recording {
3003
3023
  startUrl: string;
3004
3024
  events?: RecordingEvent[];
3025
+ actions?: UserAction[];
3026
+ sessionName?: string;
3005
3027
  id?: string;
3006
3028
  name?: string;
3007
3029
  startTime?: string;
@@ -3012,7 +3034,7 @@ interface Recording {
3012
3034
  * Generate a Node.js replay script from a recording.
3013
3035
  *
3014
3036
  * @param recording - The recording session to convert.
3015
- * @returns A self-contained JavaScript script string.
3037
+ * @returns A self-contained Playwright script string.
3016
3038
  */
3017
3039
  declare function generateJSScript(recording: Recording): string;
3018
3040
  /**
@@ -3024,10 +3046,11 @@ declare function generateJSScript(recording: Recording): string;
3024
3046
  */
3025
3047
  declare function generatePythonScript(recording: Recording): string;
3026
3048
  /**
3027
- * Generate a Bash replay script from a recording using CDP HTTP endpoints.
3049
+ * Generate a Bash replay script from a recording.
3028
3050
  *
3029
3051
  * @param recording - The recording session to convert.
3030
- * @returns A self-contained Bash script string.
3052
+ * @returns A Bash script string that replays the steps through the xbrowser
3053
+ * CLI in a single session.
3031
3054
  */
3032
3055
  declare function generateBashScript(recording: Recording): string;
3033
3056
 
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  handleViewer
3
- } from "./chunk-JYYKMSFH.js";
3
+ } from "./chunk-7O73V4GO.js";
4
4
  import {
5
5
  generateBashScript,
6
6
  generateJSScript,
7
7
  generatePythonScript
8
- } from "./chunk-ETCO4SNK.js";
8
+ } from "./chunk-YW4BIJQL.js";
9
9
  import {
10
10
  extractAndSave,
11
11
  extractRecording,
@@ -19,7 +19,7 @@ import {
19
19
  handleRun,
20
20
  readCommandFile,
21
21
  readStdin
22
- } from "./chunk-53VZHESL.js";
22
+ } from "./chunk-3ZHERY5Z.js";
23
23
  import {
24
24
  outputEnvelope,
25
25
  outputError,
@@ -30,6 +30,7 @@ import {
30
30
  PluginMetadataParser,
31
31
  XBrowserPluginLoader,
32
32
  actOnPage,
33
+ asZodSchema,
33
34
  assertPageScope,
34
35
  attachDetectAntiBot,
35
36
  attachWaitForHuman,
@@ -53,6 +54,7 @@ import {
53
54
  getWSServerFromCache,
54
55
  isChainInput,
55
56
  loadHooks,
57
+ normalizeKebabParams,
56
58
  observePage,
57
59
  parseCommandArgs,
58
60
  parseCommandChain,
@@ -64,13 +66,14 @@ import {
64
66
  setWSServer,
65
67
  setWSServerCache,
66
68
  splitCommand,
69
+ splitOutsideQuotes,
67
70
  waitForAIResponse,
68
71
  waitForPage
69
- } from "./chunk-Y2GRCINH.js";
72
+ } from "./chunk-5BD2RE4G.js";
70
73
  import {
71
74
  SessionRecorder,
72
75
  readMarkdownSummary
73
- } from "./chunk-RMYKVZIZ.js";
76
+ } from "./chunk-L6QJUB33.js";
74
77
  import {
75
78
  closeAllSessions,
76
79
  closeSessionByName,
@@ -82,7 +85,7 @@ import {
82
85
  getBrowser,
83
86
  resetForTesting,
84
87
  saveSessionDiskMeta
85
- } from "./chunk-BLCBCESM.js";
88
+ } from "./chunk-ENTENDF5.js";
86
89
  import "./chunk-JKVUFP3G.js";
87
90
  import "./chunk-3SZTCI33.js";
88
91
  import {
@@ -109,7 +112,7 @@ import {
109
112
  forwardSessionClose,
110
113
  forwardSessionList,
111
114
  version
112
- } from "./chunk-C5ZPXPD7.js";
115
+ } from "./chunk-DGPPP5XB.js";
113
116
  import {
114
117
  buildViewerUrl
115
118
  } from "./chunk-3OD76SUE.js";
@@ -181,7 +184,7 @@ var BROWSER_SCOPE = {
181
184
  };
182
185
 
183
186
  // src/router.ts
184
- import { parseArgs } from "@dyyz1993/xcli-core";
187
+ import { parseArgs, splitCommand as splitCommand2, unquote } from "@dyyz1993/xcli-core";
185
188
 
186
189
  // src/utils/selector.ts
187
190
  var HTML_TAGS = /* @__PURE__ */ new Set([
@@ -269,11 +272,6 @@ function normalizeSelector(input) {
269
272
  return "#" + input;
270
273
  }
271
274
 
272
- // src/utils/zod-internal.ts
273
- function asZodSchema(value) {
274
- return value;
275
- }
276
-
277
275
  // src/cli/browser-routes.ts
278
276
  import { helpGenerator } from "@dyyz1993/xcli-core";
279
277
  function autoCompleteParams(cmdName, params, options) {
@@ -283,6 +281,7 @@ function autoCompleteParams(cmdName, params, options) {
283
281
  const schema = asZodSchema(cmd.parameters);
284
282
  const shape = schema?.shape ?? schema?._def?.shape;
285
283
  if (!shape) return params;
284
+ options = normalizeKebabParams(cmd.parameters, options);
286
285
  for (const key of Object.keys(shape)) {
287
286
  if (params[key] !== void 0) continue;
288
287
  const v = options[key];
@@ -2877,7 +2876,7 @@ async function handleSession(args, options, mode, _cdpEndpoint) {
2877
2876
  const sub = args[0];
2878
2877
  switch (sub) {
2879
2878
  case "handoff": {
2880
- const { handleViewer: handleViewer2 } = await import("./viewer-routes-YOS5GTCV.js");
2879
+ const { handleViewer: handleViewer2 } = await import("./viewer-routes-7E7S2QBD.js");
2881
2880
  await handleViewer2([], { ...options, session: args[1] ?? options.session }, mode, _cdpEndpoint);
2882
2881
  break;
2883
2882
  }
@@ -2885,7 +2884,7 @@ async function handleSession(args, options, mode, _cdpEndpoint) {
2885
2884
  case "restore": {
2886
2885
  const name = args[1] || options.session || process.env.XBROWSER_SESSION || "default";
2887
2886
  try {
2888
- const { forwardSessionState } = await import("./daemon-client-Z3NKNZRL.js");
2887
+ const { forwardSessionState } = await import("./daemon-client-D4JG74IW.js");
2889
2888
  const data = await forwardSessionState(sub, name);
2890
2889
  outputEnvelope({ success: true, data }, { command: `session ${sub}` }, mode);
2891
2890
  } catch (error) {
@@ -3415,7 +3414,7 @@ async function handlePlugin(args, options, mode) {
3415
3414
  } catch {
3416
3415
  }
3417
3416
  try {
3418
- const { daemonPing: daemonPing2 } = await import("./daemon-client-Z3NKNZRL.js");
3417
+ const { daemonPing: daemonPing2 } = await import("./daemon-client-D4JG74IW.js");
3419
3418
  if (await daemonPing2()) {
3420
3419
  await fetch("http://localhost:9224/rpc", {
3421
3420
  method: "POST",
@@ -3940,7 +3939,7 @@ async function handleConvert(args, _mode) {
3940
3939
  const fs5 = await import("fs");
3941
3940
  const path4 = await import("path");
3942
3941
  const { default: yaml3 } = await import("yaml");
3943
- const { generateJSScript: generateJSScript2, generatePythonScript: generatePythonScript2, generateBashScript: generateBashScript2 } = await import("./convert-R3XXYKC6.js");
3942
+ const { generateJSScript: generateJSScript2, generatePythonScript: generatePythonScript2, generateBashScript: generateBashScript2 } = await import("./convert-K6TLQEPX.js");
3944
3943
  let recording;
3945
3944
  try {
3946
3945
  const content = fs5.readFileSync(filePath, "utf-8");
@@ -3953,24 +3952,6 @@ async function handleConvert(args, _mode) {
3953
3952
  outputError(`Error: "${filePath}" does not contain a valid recording (expected a YAML/JSON object with events or actions).`);
3954
3953
  process.exit(1);
3955
3954
  }
3956
- const rawActions = recording.actions;
3957
- if (Array.isArray(rawActions) && !Array.isArray(recording.events)) {
3958
- recording.events = rawActions.map((a) => {
3959
- const action = a;
3960
- const element = action.element ?? {};
3961
- return {
3962
- type: action.type,
3963
- selector: element.selector ?? action.selector,
3964
- data: {
3965
- ...action.data,
3966
- value: action.value ?? action.data?.value,
3967
- key: action.key ?? action.data?.key,
3968
- x: action.scrollX ?? action.data?.x,
3969
- y: action.scrollY ?? action.data?.y
3970
- }
3971
- };
3972
- });
3973
- }
3974
3955
  const ext = path4.extname(outputPath).toLowerCase();
3975
3956
  const recordingTyped = recording;
3976
3957
  let script;
@@ -3983,12 +3964,13 @@ async function handleConvert(args, _mode) {
3983
3964
  }
3984
3965
  fs5.writeFileSync(outputPath, script);
3985
3966
  fs5.chmodSync(outputPath, 493);
3986
- const eventCount = (recordingTyped.events || []).length;
3967
+ const eventCount = [recordingTyped.events, recordingTyped.actions].find(Array.isArray)?.length ?? 0;
3968
+ const runner = ext === ".py" ? "python" : ext === ".sh" ? "bash" : "node";
3987
3969
  process.stdout.write(`Converted ${filePath} -> ${outputPath}
3988
3970
  `);
3989
3971
  process.stdout.write(` Events: ${eventCount}, Start URL: ${recordingTyped.startUrl}
3990
3972
  `);
3991
- process.stdout.write(` Run: ${ext === ".py" ? "python" : ext === ".sh" ? "./" : "node"} ${outputPath}
3973
+ process.stdout.write(` Run: ${runner} ${outputPath}
3992
3974
  `);
3993
3975
  }
3994
3976
  async function handleExtract(args, _mode) {
@@ -4035,7 +4017,7 @@ async function handleFilter(args, _mode, options) {
4035
4017
  }
4036
4018
  }
4037
4019
  async function handleGeneratePlugin(sessionName, pluginName, outputDir) {
4038
- const { SessionRecorder: SessionRecorder2 } = await import("./session-recorder-RUNQOJ7T.js");
4020
+ const { SessionRecorder: SessionRecorder2 } = await import("./session-recorder-CNTY5KXF.js");
4039
4021
  const { readSiteKnowledge: readSiteKnowledge2, toMarkdown } = await import("./site-knowledge-SYC6VCDB.js");
4040
4022
  const { mkdirSync: mkdirSync8, writeFileSync: writeFileSync8 } = await import("fs");
4041
4023
  const { join: join10 } = await import("path");
@@ -7274,6 +7256,10 @@ async function handleStdinMode(stdinCommands, argv) {
7274
7256
  async function handleEvalMode(argv) {
7275
7257
  const evalCommands = parseEvalFlags(argv);
7276
7258
  if (evalCommands.length === 0) return;
7259
+ if (evalCommands.includes("--help") || evalCommands.includes("-h")) {
7260
+ showMainHelp();
7261
+ return;
7262
+ }
7277
7263
  const knownCommands = new Set(getCommandNames());
7278
7264
  const chainParts = evalCommands.map((value) => {
7279
7265
  const firstWord = value.trim().split(/\s+/)[0] || "";
@@ -7547,6 +7533,7 @@ async function handleCommandHelp(command, positional, mode) {
7547
7533
  return true;
7548
7534
  }
7549
7535
  function showBuiltinHelp(builtinCmd, mode) {
7536
+ builtinCmd = hideInternalParams(builtinCmd);
7550
7537
  if (mode === "json") {
7551
7538
  const paramsList = [];
7552
7539
  const schema = asZodSchema(builtinCmd.parameters);
@@ -7581,6 +7568,22 @@ function showBuiltinHelp(builtinCmd, mode) {
7581
7568
  }
7582
7569
  console.log(helpGenerator3.generate(builtinCmd, { color: true, emoji: false }));
7583
7570
  }
7571
+ function hideInternalParams(builtinCmd) {
7572
+ const schema = builtinCmd.parameters;
7573
+ if (!schema || typeof schema.omit !== "function") return builtinCmd;
7574
+ const internal = asZodSchema(builtinCmd.parameters);
7575
+ const shapeOrFn = internal.shape ?? internal._def?.shape;
7576
+ const shape = typeof shapeOrFn === "function" ? shapeOrFn() : shapeOrFn;
7577
+ if (!shape) return builtinCmd;
7578
+ const mask = {};
7579
+ for (const [key, field] of Object.entries(shape)) {
7580
+ const fieldSchema = asZodSchema(field);
7581
+ const description = fieldSchema.description || fieldSchema._def?.description || "";
7582
+ if (description.startsWith("Internal:")) mask[key] = true;
7583
+ }
7584
+ if (Object.keys(mask).length === 0) return builtinCmd;
7585
+ return { ...builtinCmd, parameters: schema.omit(mask) };
7586
+ }
7584
7587
  var SUBCOMMAND_HELP = {
7585
7588
  session: "session open|close|kill|list [--session <name>] [--cdp <endpoint>]",
7586
7589
  plugin: "plugin install|uninstall|list|reload|schema|search|info <name>",
@@ -7593,7 +7596,7 @@ var SUBCOMMAND_HELP = {
7593
7596
  remote: "remote <url> [command] [--token <token>]",
7594
7597
  convert: "convert <file> [--to js|py|sh]",
7595
7598
  extract: "extract <file> [--format json|yaml]",
7596
- filter: "filter <file> [--include <type>] [--exclude <type>]",
7599
+ filter: "filter <in.yaml> <out.yaml> [--include <type>] [--exclude <type>]",
7597
7600
  test: "test <name> [--cdp <endpoint>]",
7598
7601
  viewer: "viewer [--session <name>]",
7599
7602
  "console-panel": "console-panel [--port <port>]",
@@ -8170,7 +8173,7 @@ async function handleRemote(args, options, mode) {
8170
8173
  }
8171
8174
  }
8172
8175
  async function startMcpServer() {
8173
- const { startMcpStdio } = await import("./server-HUSX7EFE.js");
8176
+ const { startMcpStdio } = await import("./server-6OWQMWRG.js");
8174
8177
  startMcpStdio();
8175
8178
  }
8176
8179
 
@@ -8220,7 +8223,7 @@ async function dispatchSubcommand(request) {
8220
8223
  if (cdpEndpoint || options.bridge) {
8221
8224
  outputError("Managed runs use a self-launched headless browser");
8222
8225
  } else {
8223
- const { handleManagedRunFile } = await import("./run-routes-SJKVZ34L.js");
8226
+ const { handleManagedRunFile } = await import("./run-routes-FBMZ3OUW.js");
8224
8227
  await handleManagedRunFile(cmdArgs[0], { sessionName, parallel: options.parallel, mode });
8225
8228
  }
8226
8229
  } else {
@@ -8295,6 +8298,16 @@ var KNOWN_GLOBAL_OPTIONS = /* @__PURE__ */ new Set([
8295
8298
  "headless",
8296
8299
  "tab"
8297
8300
  ]);
8301
+ var GLOBAL_VALUE_FLAGS = /* @__PURE__ */ new Set([
8302
+ "--session",
8303
+ "--cdp",
8304
+ "--output",
8305
+ "-o",
8306
+ "--timeout",
8307
+ "--frame",
8308
+ "--target",
8309
+ "--tab"
8310
+ ]);
8298
8311
  async function handlePluginOrChainRoute(request) {
8299
8312
  const { command, cmdArgs, argv, options, mode, cdpEndpoint, sessionName, chainTokenStart, chainTokenEnd } = request;
8300
8313
  const loader = await getPluginLoader();
@@ -8316,7 +8329,7 @@ async function handlePluginOrChainRoute(request) {
8316
8329
  continue;
8317
8330
  }
8318
8331
  if (globalFlagSet.has(argv[i])) continue;
8319
- if (i > 0 && globalFlagSet.has(argv[i - 1]) && !argv[i].startsWith("-")) continue;
8332
+ if (i > 0 && GLOBAL_VALUE_FLAGS.has(argv[i - 1]) && !argv[i].startsWith("-")) continue;
8320
8333
  if (argv[i].startsWith("--session=") || argv[i].startsWith("--cdp=")) continue;
8321
8334
  cleanParts.push(argv[i]);
8322
8335
  }
@@ -8461,7 +8474,7 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
8461
8474
  }
8462
8475
  const needsBrowser = cmdEntry.scope === "page" || cmdEntry.scope === "browser";
8463
8476
  if (needsBrowser && !process.env.XBROWSER_DAEMON_WORKER) {
8464
- const { forwardPluginExec } = await import("./daemon-client-Z3NKNZRL.js");
8477
+ const { forwardPluginExec } = await import("./daemon-client-D4JG74IW.js");
8465
8478
  const userTimeout = typeof params.timeout === "number" && params.timeout > 0 ? params.timeout * 1e3 + 3e4 : void 0;
8466
8479
  const result = await forwardPluginExec(`${command}.${subCommand}`, params, sessionName, cdpEndpoint, userTimeout);
8467
8480
  const resultData = result && typeof result === "object" && "data" in result ? result.data : void 0;
@@ -8507,7 +8520,7 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
8507
8520
  const targetPage = pages[cmdTabIndex];
8508
8521
  await targetPage.bringToFront().catch(() => {
8509
8522
  });
8510
- const { setActivePage } = await import("./browser-RZ7DPBI3.js");
8523
+ const { setActivePage } = await import("./browser-XELRNYBL.js");
8511
8524
  setActivePage(session, targetPage);
8512
8525
  }
8513
8526
  }
@@ -8634,8 +8647,10 @@ async function routeCommand(argvIn, stdinCommands) {
8634
8647
  return;
8635
8648
  }
8636
8649
  const evalStart = findEvalStart(argv);
8637
- if (evalStart >= 0 && argv.length > evalStart + 1) {
8638
- await handleEvalScript(argv.slice(evalStart + 1), argv);
8650
+ const evalParts = evalStart >= 0 ? argv.slice(evalStart + 1) : [];
8651
+ const evalHelpRequested = evalParts.includes("--help") || evalParts.includes("-h");
8652
+ if (evalStart >= 0 && evalParts.length > 0 && !evalHelpRequested) {
8653
+ await handleEvalScript(evalParts, argv);
8639
8654
  return;
8640
8655
  }
8641
8656
  if (parseEvalFlags(argv).length > 0) {
@@ -8654,12 +8669,12 @@ async function routeCommand(argvIn, stdinCommands) {
8654
8669
  if (argv[0] === "--json" || argv[0] === "--yaml") {
8655
8670
  argv = argv.slice(1);
8656
8671
  }
8657
- const globalFlags = /* @__PURE__ */ new Set(["--session", "--cdp", "--json", "--yaml", "--output", "--timeout", "--help", "-h", "--version", "--frame", "--target", "--tab", "--bridge"]);
8672
+ const globalFlags = /* @__PURE__ */ new Set([...GLOBAL_VALUE_FLAGS, "--json", "--yaml", "--help", "-h", "--version", "--bridge"]);
8658
8673
  let chainArgIdx = -1;
8659
8674
  let seenCommandWord = false;
8660
8675
  for (let i = 0; i < argv.length; i++) {
8661
8676
  if (globalFlags.has(argv[i])) continue;
8662
- if (globalFlags.has(argv[i]) || i > 0 && globalFlags.has(argv[i - 1]) && !argv[i].startsWith("-")) continue;
8677
+ if (globalFlags.has(argv[i]) || i > 0 && GLOBAL_VALUE_FLAGS.has(argv[i - 1]) && !argv[i].startsWith("-")) continue;
8663
8678
  if (!seenCommandWord) {
8664
8679
  if (argv[i].includes(" ") && /^[a-zA-Z]/.test(argv[i])) {
8665
8680
  chainArgIdx = i;
@@ -8670,12 +8685,15 @@ async function routeCommand(argvIn, stdinCommands) {
8670
8685
  }
8671
8686
  if (chainArgIdx >= 0) {
8672
8687
  const chainArg = argv[chainArgIdx];
8688
+ if (isChainInput(chainArg)) {
8689
+ await handleChainInput(chainArg, argvIn);
8690
+ return;
8691
+ }
8673
8692
  const spaceIdx = chainArg.indexOf(" ");
8674
8693
  const possibleCmd = chainArg.substring(0, spaceIdx);
8675
8694
  if (/^[a-zA-Z][\w-]*$/.test(possibleCmd)) {
8676
8695
  const remainder = chainArg.substring(spaceIdx + 1);
8677
- let remainderParts = remainder.split(/\s+/).filter(Boolean);
8678
- remainderParts = remainderParts.flatMap((part) => part.split(";").filter(Boolean));
8696
+ const remainderParts = splitOutsideQuotes(remainder, ";").flatMap((part) => splitCommand2(part)).map(unquote);
8679
8697
  chainTokenStart = chainArgIdx;
8680
8698
  chainTokenEnd = chainArgIdx + remainderParts.length;
8681
8699
  argv = [...argv.slice(0, chainArgIdx), possibleCmd, ...remainderParts, ...argv.slice(chainArgIdx + 1)];
@@ -2,15 +2,15 @@ import {
2
2
  handleManagedRunFile,
3
3
  handleRun,
4
4
  runNamedJobs
5
- } from "./chunk-EGOWDZXP.js";
6
- import "./chunk-QRFM4NOV.js";
7
- import "./chunk-GNLZWHSP.js";
5
+ } from "./chunk-DUC664TA.js";
6
+ import "./chunk-NE344XKO.js";
7
+ import "./chunk-KSB4PMCY.js";
8
8
  import "./chunk-JKVUFP3G.js";
9
9
  import "./chunk-3SZTCI33.js";
10
10
  import "./chunk-3OD76SUE.js";
11
11
  import "./chunk-ZTHE5RBZ.js";
12
12
  import "./chunk-RGL2YTWQ.js";
13
- import "./chunk-C5ZPXPD7.js";
13
+ import "./chunk-DGPPP5XB.js";
14
14
  import "./chunk-Q2DFJQGS.js";
15
15
  import "./chunk-GYGVHWG3.js";
16
16
  import "./chunk-SMYSNO4M.js";