ai-remote 0.4.9 → 0.4.11

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.md CHANGED
@@ -92,6 +92,12 @@ npx ai-remote shot -o screen.png
92
92
  npx ai-remote click 640,400
93
93
  ```
94
94
 
95
+ When a Mac offers both account authentication and the legacy VNC-password
96
+ challenge, `-u NAME` selects the account exchange and attaches to that user's
97
+ desktop. Omit `-u` to use the legacy VNC password instead. Add `--save` after a
98
+ successful first connection to keep the password in the macOS login Keychain;
99
+ later connections can use `--no-prompt`.
100
+
95
101
  The client is this package's own: no noVNC, no browser and no gateway. It signs
96
102
  in either way a host may ask -- the classic VNC password, or the account and
97
103
  password macOS Screen Sharing wants -- and decodes Raw and CopyRect, which
package/dist/cli.mjs CHANGED
@@ -7649,6 +7649,8 @@ var ENCODING = {
7649
7649
  LAST_RECT: -224
7650
7650
  };
7651
7651
  var SECURITY = { NONE: 1, VNC: 2, APPLE_DH: 30 };
7652
+ var ACTIVE_UPDATE_INTERVAL_MS = 1e3 / 30;
7653
+ var IDLE_UPDATE_INTERVAL_MS = 100;
7652
7654
  var SECURITY_NAME = {
7653
7655
  0: "invalid",
7654
7656
  1: "none",
@@ -7800,13 +7802,16 @@ var RfbClient = class extends EventTarget {
7800
7802
  /**
7801
7803
  * Which way to sign in.
7802
7804
  *
7803
- * A password challenge is preferred where the host offers one: it is the same
7804
- * everywhere. Apple's exchange comes next, because on macOS it is usually the
7805
- * only thing offered -- Screen Sharing wants an account, not a VNC password,
7806
- * unless somebody has turned the legacy one on.
7805
+ * A named account means the caller wants Apple's account exchange when the
7806
+ * host offers it. macOS can advertise that beside the legacy VNC-password
7807
+ * challenge; choosing the challenge first ignores the account and attaches to
7808
+ * loginwindow instead of the named user's desktop. Without an account, keep
7809
+ * preferring the portable VNC-password challenge.
7807
7810
  */
7808
7811
  #chooseSecurity(offered) {
7812
+ const username = this.options.username ?? "";
7809
7813
  const password2 = this.options.password ?? "";
7814
+ if (username && password2 && offered.includes(SECURITY.APPLE_DH)) return SECURITY.APPLE_DH;
7810
7815
  if (password2 && offered.includes(SECURITY.VNC)) return SECURITY.VNC;
7811
7816
  if (password2 && offered.includes(SECURITY.APPLE_DH)) return SECURITY.APPLE_DH;
7812
7817
  if (offered.includes(SECURITY.NONE)) return SECURITY.NONE;
@@ -7886,7 +7891,12 @@ var RfbClient = class extends EventTarget {
7886
7891
  while (!this.#closed) {
7887
7892
  const [type] = await this.#read(1);
7888
7893
  if (type === SERVER.FRAMEBUFFER_UPDATE) {
7889
- await this.#framebufferUpdate();
7894
+ const started = Date.now();
7895
+ const changed = await this.#framebufferUpdate();
7896
+ const interval = changed ? ACTIVE_UPDATE_INTERVAL_MS : IDLE_UPDATE_INTERVAL_MS;
7897
+ const remaining = interval - (Date.now() - started);
7898
+ if (remaining > 0) await new Promise((resolve) => setTimeout(resolve, remaining));
7899
+ if (this.#closed) break;
7890
7900
  this.#requestUpdate(!this.#wantFull);
7891
7901
  continue;
7892
7902
  }
@@ -7951,6 +7961,7 @@ var RfbClient = class extends EventTarget {
7951
7961
  if (rects.length) {
7952
7962
  this.dispatchEvent(new CustomEvent("paint", { detail: { rects } }));
7953
7963
  }
7964
+ return resized || rects.length > 0;
7954
7965
  }
7955
7966
  // --- the byte stream -------------------------------------------------------------
7956
7967
  #feed(bytes) {
@@ -9781,9 +9792,10 @@ async function runWindow(argv) {
9781
9792
  macosTitlebarTransparent: true,
9782
9793
  macosFullsizeContentView: true,
9783
9794
  macosTitleHidden: true,
9784
- // The page handles clicks in the bar, so this is what leaves the window
9785
- // draggable by the parts of it that are not a button.
9786
- macosMovableByWindowBackground: true
9795
+ // Keep dragging scoped to the native titlebar. Enabling movable background
9796
+ // makes AppKit treat the remote desktop canvas (and the terminal) as a
9797
+ // window drag handle, stealing pointer drags meant for the remote machine.
9798
+ macosMovableByWindowBackground: false
9787
9799
  });
9788
9800
  try {
9789
9801
  const edge = 64;
@@ -9799,7 +9811,7 @@ async function runWindow(argv) {
9799
9811
  }
9800
9812
  }, 400);
9801
9813
  }
9802
- await application.whenReady();
9814
+ await application.whenReady({ interval: 100 });
9803
9815
  }
9804
9816
 
9805
9817
  // src/cli/generated/viewer-bundle.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-remote",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "description": "RDP, VNC and SSH protocol engines that run in Node, a Worker or a browser -- plus `npx ai-remote`, a CLI that drives a machine and shows you what it is doing",
5
5
  "type": "module",
6
6
  "bin": {