ai-remote 0.4.9 → 0.4.10

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) {
@@ -9799,7 +9810,7 @@ async function runWindow(argv) {
9799
9810
  }
9800
9811
  }, 400);
9801
9812
  }
9802
- await application.whenReady();
9813
+ await application.whenReady({ interval: 100 });
9803
9814
  }
9804
9815
 
9805
9816
  // 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.10",
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": {