@xbrowser/cli 1.28.0 → 1.29.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.
Files changed (37) hide show
  1. package/dist/{browser-NYYCR4O7.js → browser-2K3XYAKM.js} +5 -3
  2. package/dist/{browser-ZD53IMUJ.js → browser-OTEMG5NL.js} +6 -4
  3. package/dist/{browser-4IYIHZ6R.js → browser-XD3IOU5I.js} +8 -6
  4. package/dist/{cdp-driver-EFEW4ZEN.js → cdp-driver-AAS55KT2.js} +4 -4
  5. package/dist/{cdp-driver-4X6Q62WI.js → cdp-driver-O5I7SJ24.js} +3 -3
  6. package/dist/{cdp-driver-HB744QB4.js → cdp-driver-XTPY7EXP.js} +1296 -852
  7. package/dist/{chunk-SEEWE5SJ.js → chunk-2KPI5GKP.js} +3 -0
  8. package/dist/{chunk-75DNUI6M.js → chunk-6UJU2FJK.js} +146 -0
  9. package/dist/{chunk-3PUOISKE.js → chunk-CO2ZVOVT.js} +496 -452
  10. package/dist/{chunk-V6KGBU5J.js → chunk-FCPVQFTQ.js} +1011 -1038
  11. package/dist/{chunk-WK3INZLA.js → chunk-GDKKVT2P.js} +750 -651
  12. package/dist/{chunk-HSYRAV3H.js → chunk-LFSLNHW5.js} +1846 -1358
  13. package/dist/{chunk-OSZNJT4U.js → chunk-LM32MNBB.js} +79 -8
  14. package/dist/{chunk-J3HXZVSN.js → chunk-N5XTLNKS.js} +1166 -868
  15. package/dist/{chunk-T2AI24A5.js → chunk-NAIHOVDZ.js} +3 -0
  16. package/dist/{chunk-WYETQ5C7.js → chunk-NEE6EMYA.js} +14 -1
  17. package/dist/{chunk-ME5FO5YV.js → chunk-NQPXZ74W.js} +1296 -852
  18. package/dist/{chunk-KECYFWJO.js → chunk-P33R7F2D.js} +413 -384
  19. package/dist/{chunk-OEC7ZSFW.js → chunk-SCYBNSOG.js} +1560 -1461
  20. package/dist/{chunk-R3F4K2SB.js → chunk-SMYSNO4M.js} +10 -0
  21. package/dist/{chunk-IR6C24P7.js → chunk-UZ6XPUBD.js} +1030 -1048
  22. package/dist/cli.js +3398 -3357
  23. package/dist/daemon-main.js +737 -707
  24. package/dist/index.d.ts +362 -474
  25. package/dist/index.js +5730 -5689
  26. package/dist/{launcher-SJ44X25U.js → launcher-TOLF23ET.js} +1 -1
  27. package/dist/{launcher-XHKIC4GP.js → launcher-ZYB32LSZ.js} +1 -1
  28. package/dist/{plugin-singleton-GGSBI3EG.js → plugin-singleton-A6RNITJW.js} +1 -1
  29. package/dist/{proxy-NKCYE76M.js → proxy-H3RIUOCN.js} +2 -2
  30. package/dist/{server-JXF3JOAM.js → server-LNZTDAKT.js} +4 -4
  31. package/dist/{server-26SE6YZR.js → server-ZTI2K5YJ.js} +7 -7
  32. package/dist/{session-recorder-GEZVQBKW.js → session-recorder-DF2YGH2E.js} +1 -1
  33. package/dist/{session-recorder-563ISSJK.js → session-recorder-R3GDGXLJ.js} +1 -1
  34. package/dist/{session-replayer-TXTNTG33.js → session-replayer-CLTZ2URU.js} +1 -1
  35. package/dist/{stealth-QNSMIHQK.js → stealth-FMPZO2OB.js} +1 -1
  36. package/dist/{stealth-MHJNBJY7.js → stealth-MCKFKPZ6.js} +1 -1
  37. package/package.json +6 -3
@@ -32,6 +32,9 @@ var DEFAULT_ARGS = [
32
32
  "--no-first-run",
33
33
  "--no-default-browser-check",
34
34
  "--no-sandbox",
35
+ // CI runner 的 /dev/shm 仅 64MB,Chrome shm 不足时启动显著变慢(CDP 端口
36
+ // 30s 绑不上,伴生 dbus 噪音)——e2e m5-human-gate 间歇挂的根因(09-24)。
37
+ "--disable-dev-shm-usage",
35
38
  "--disable-background-networking",
36
39
  "--disable-background-timer-throttling",
37
40
  "--disable-backgrounding-occluded-windows",
@@ -897,6 +897,149 @@ var pageLifecycleRule = {
897
897
  }
898
898
  };
899
899
 
900
+ // src/cdp-interceptor/rules/humanize-transform.ts
901
+ var CURSOR_KEY = "humanize-cursor";
902
+ var KEYS_KEY = "humanize-keys";
903
+ var MOUSE_STEP_DELAYS = [16, 19, 23, 28];
904
+ var TYPE_DELAYS = [42, 58, 74, 96, 118, 155, 210];
905
+ function rand(min, max) {
906
+ return min + Math.random() * (max - min);
907
+ }
908
+ function roundCoordinate(value) {
909
+ return Math.round(value * 100) / 100;
910
+ }
911
+ function humanMousePath(fromX, fromY, toX, toY) {
912
+ const dist = Math.hypot(toX - fromX, toY - fromY);
913
+ const n = Math.max(8, Math.min(28, Math.round(dist / 15)));
914
+ const shortMove = dist < 120;
915
+ const curvature = shortMove ? rand(2, 6) : Math.max(dist * rand(0.12, 0.22), rand(18, 35));
916
+ const dir = Math.random() < 0.5 ? 1 : -1;
917
+ const dx = toX - fromX;
918
+ const dy = toY - fromY;
919
+ const d = dist || 1;
920
+ const c1x = fromX + dx * 0.3 - dy / d * curvature * 0.5 * dir;
921
+ const c1y = fromY + dy * 0.3 + dx / d * curvature * 0.5 * dir;
922
+ const c2x = fromX + dx * 0.7 - dy / d * curvature * 0.8 * dir;
923
+ const c2y = fromY + dy * 0.7 + dx / d * curvature * 0.8 * dir;
924
+ const amp = shortMove ? Math.min(2, 3.2) : 3.2;
925
+ const points = [];
926
+ for (let i = 1; i <= n; i++) {
927
+ const t = i / n;
928
+ const eased = t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2;
929
+ const mt = 1 - eased;
930
+ const px = mt ** 3 * fromX + 3 * mt ** 2 * eased * c1x + 3 * mt * eased ** 2 * c2x + eased ** 3 * toX;
931
+ const py = mt ** 3 * fromY + 3 * mt ** 2 * eased * c1y + 3 * mt * eased ** 2 * c2y + eased ** 3 * toY;
932
+ points.push({
933
+ x: roundCoordinate(px + rand(-amp, amp)),
934
+ y: roundCoordinate(py + rand(-amp, amp)),
935
+ delay: MOUSE_STEP_DELAYS[Math.floor(Math.random() * MOUSE_STEP_DELAYS.length)]
936
+ });
937
+ }
938
+ if (!shortMove) {
939
+ const over = rand(6, 14);
940
+ points.push({
941
+ x: roundCoordinate(toX + dx / d * over + rand(-2, 2)),
942
+ y: roundCoordinate(toY + dy / d * over + rand(-2, 2)),
943
+ delay: Math.round(rand(14, 30))
944
+ });
945
+ points.push({
946
+ x: roundCoordinate(toX + dx / d * over * 0.4),
947
+ y: roundCoordinate(toY + dy / d * over * 0.4),
948
+ delay: Math.round(rand(14, 30))
949
+ });
950
+ }
951
+ points.push({
952
+ x: roundCoordinate(toX + rand(-1, 1)),
953
+ y: roundCoordinate(toY + rand(-1, 1)),
954
+ delay: Math.round(rand(14, 30))
955
+ });
956
+ return points;
957
+ }
958
+ function characterKeyEvents(text) {
959
+ const events = [];
960
+ for (const char of text) {
961
+ if (char === "\n") {
962
+ events.push(
963
+ { type: "rawKeyDown", key: "Enter", code: "Enter", windowsVirtualKeyCode: 13 },
964
+ { type: "char", text: "\r" },
965
+ { type: "keyUp", key: "Enter", code: "Enter", windowsVirtualKeyCode: 13 }
966
+ );
967
+ continue;
968
+ }
969
+ events.push(
970
+ { type: "rawKeyDown", key: char, text: char, unmodifiedText: char },
971
+ { type: "char", text: char },
972
+ { type: "keyUp", key: char }
973
+ );
974
+ }
975
+ return events;
976
+ }
977
+ function isMouseEvent(method) {
978
+ return method === "Input.dispatchMouseEvent";
979
+ }
980
+ var humanizeTransformRule = {
981
+ id: "humanize-transform",
982
+ name: "Humanize Trusted Input Transform",
983
+ priority: 45,
984
+ canHandle(ctx) {
985
+ return isMouseEvent(ctx.method) || ctx.method === "Input.insertText";
986
+ },
987
+ evaluate(ctx) {
988
+ if (ctx.method === "Input.insertText") return this.transformInsertText(ctx);
989
+ return this.transformMouseEvent(ctx);
990
+ },
991
+ transformMouseEvent(ctx) {
992
+ const params = ctx.params;
993
+ if (params.type !== "mouseMoved" || typeof params.x !== "number" || typeof params.y !== "number") {
994
+ const x = params.x;
995
+ const y = params.y;
996
+ if (typeof x === "number" && typeof y === "number") {
997
+ ctx.sessionState.set(CURSOR_KEY, { x, y });
998
+ }
999
+ return null;
1000
+ }
1001
+ const cursor = ctx.sessionState.get(CURSOR_KEY) ?? { x: 0, y: 0 };
1002
+ const jump = Math.hypot(params.x - cursor.x, params.y - cursor.y);
1003
+ ctx.sessionState.set(CURSOR_KEY, { x: params.x, y: params.y });
1004
+ if (jump < 32) return null;
1005
+ const path = humanMousePath(cursor.x, cursor.y, params.x, params.y);
1006
+ return {
1007
+ ruleId: this.id,
1008
+ action: "transform",
1009
+ severity: "info",
1010
+ reason: `Expanded instant mouse jump of ${jump.toFixed(0)}px into ${path.length} trusted bezier moves.`,
1011
+ suggestion: "Use page.mouse.move with steps for explicit control; this transform preserves isTrusted=true.",
1012
+ transformedParams: { __sequence: path.map((point) => ({
1013
+ method: "Input.dispatchMouseEvent",
1014
+ params: { type: "mouseMoved", x: point.x, y: point.y, button: params.button ?? "none" },
1015
+ delayMs: point.delay
1016
+ })) }
1017
+ };
1018
+ },
1019
+ transformInsertText(ctx) {
1020
+ const params = ctx.params;
1021
+ const text = params.text ?? "";
1022
+ if (!text) return null;
1023
+ const timing = ctx.sessionState.get(KEYS_KEY) ?? { lastDelay: TYPE_DELAYS[1] };
1024
+ const bucket = TYPE_DELAYS[Math.floor(Math.random() * TYPE_DELAYS.length)];
1025
+ const events = characterKeyEvents(text).map((event, index) => ({
1026
+ method: "Input.dispatchKeyEvent",
1027
+ params: event,
1028
+ delayMs: index === 0 ? 0 : Math.max(24, Math.round(bucket + rand(-bucket * 0.45, bucket * 0.55)))
1029
+ }));
1030
+ timing.lastDelay = bucket;
1031
+ ctx.sessionState.set(KEYS_KEY, timing);
1032
+ return {
1033
+ ruleId: this.id,
1034
+ action: "transform",
1035
+ severity: "info",
1036
+ reason: `Expanded Input.insertText (${text.length} chars) into ${events.length} trusted key events with variable rhythm.`,
1037
+ suggestion: "Use page.type for explicit control; this transform preserves the native keyboard command stream.",
1038
+ transformedParams: { __sequence: events }
1039
+ };
1040
+ }
1041
+ };
1042
+
900
1043
  // src/cdp-interceptor/rules-engine.ts
901
1044
  var BUILTIN_RULES = [
902
1045
  domMutationRule,
@@ -905,6 +1048,7 @@ var BUILTIN_RULES = [
905
1048
  eventSimulationRule,
906
1049
  mouseTrajectoryRule,
907
1050
  inputKeystrokeRule,
1051
+ humanizeTransformRule,
908
1052
  emulationOverrideRule,
909
1053
  networkAnomalyRule,
910
1054
  pageLifecycleRule
@@ -937,8 +1081,10 @@ function createRuleEngine(customRules) {
937
1081
  if (isProbeMarked(code)) return null;
938
1082
  } catch {
939
1083
  }
1084
+ const humanizeEnabled = process.env.XBROWSER_HUMANIZE_CDP === "on";
940
1085
  for (const rule of rules) {
941
1086
  if (rule.canHandle && !rule.canHandle(fullCtx)) continue;
1087
+ if (rule.id === "humanize-transform" && !humanizeEnabled) continue;
942
1088
  const decision = rule.evaluate(fullCtx);
943
1089
  if (!decision) continue;
944
1090
  if (decision.action !== "pass") return decision;