@midscene/computer 1.4.8-beta-20260227092357.0 → 1.4.8

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/dist/es/cli.mjs CHANGED
@@ -314,10 +314,33 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
314
314
  await sleep(50);
315
315
  const movedPos = libnut.getMousePos();
316
316
  console.log(`[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`);
317
+ const deltaX = Math.abs(movedPos.x - targetX);
318
+ const deltaY = Math.abs(movedPos.y - targetY);
319
+ if (deltaX > 5 || deltaY > 5) {
320
+ const msg = `[HealthCheck] WARNING: Mouse control may not be working. Expected (${targetX}, ${targetY}), got (${movedPos.x}, ${movedPos.y}), delta=(${deltaX}, ${deltaY})`;
321
+ console.warn(msg);
322
+ debugDevice(msg);
323
+ if ('win32' === process.platform && !this.isRunningAsAdmin()) {
324
+ const hint = "Midscene is NOT running as Administrator. Windows blocks mouse/keyboard input to elevated (admin) applications from non-admin processes (UIPI). Please run your terminal or Node.js as Administrator and try again.";
325
+ console.error(`\n[HealthCheck] ${hint}\n`);
326
+ debugDevice(hint);
327
+ }
328
+ }
317
329
  libnut.moveMouse(startPos.x, startPos.y);
318
330
  console.log(`[HealthCheck] Mouse restored to (${startPos.x}, ${startPos.y})`);
319
331
  console.log('[HealthCheck] Health check passed');
320
332
  }
333
+ isRunningAsAdmin() {
334
+ if ('win32' !== process.platform) return false;
335
+ try {
336
+ execSync('net session', {
337
+ stdio: 'pipe'
338
+ });
339
+ return true;
340
+ } catch {
341
+ return false;
342
+ }
343
+ }
321
344
  async screenshotBase64() {
322
345
  if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
323
346
  debugDevice('Taking screenshot', {
package/dist/es/index.mjs CHANGED
@@ -313,10 +313,33 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
313
313
  await sleep(50);
314
314
  const movedPos = device_libnut.getMousePos();
315
315
  console.log(`[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`);
316
+ const deltaX = Math.abs(movedPos.x - targetX);
317
+ const deltaY = Math.abs(movedPos.y - targetY);
318
+ if (deltaX > 5 || deltaY > 5) {
319
+ const msg = `[HealthCheck] WARNING: Mouse control may not be working. Expected (${targetX}, ${targetY}), got (${movedPos.x}, ${movedPos.y}), delta=(${deltaX}, ${deltaY})`;
320
+ console.warn(msg);
321
+ debugDevice(msg);
322
+ if ('win32' === process.platform && !this.isRunningAsAdmin()) {
323
+ const hint = "Midscene is NOT running as Administrator. Windows blocks mouse/keyboard input to elevated (admin) applications from non-admin processes (UIPI). Please run your terminal or Node.js as Administrator and try again.";
324
+ console.error(`\n[HealthCheck] ${hint}\n`);
325
+ debugDevice(hint);
326
+ }
327
+ }
316
328
  device_libnut.moveMouse(startPos.x, startPos.y);
317
329
  console.log(`[HealthCheck] Mouse restored to (${startPos.x}, ${startPos.y})`);
318
330
  console.log('[HealthCheck] Health check passed');
319
331
  }
332
+ isRunningAsAdmin() {
333
+ if ('win32' !== process.platform) return false;
334
+ try {
335
+ execSync('net session', {
336
+ stdio: 'pipe'
337
+ });
338
+ return true;
339
+ } catch {
340
+ return false;
341
+ }
342
+ }
320
343
  async screenshotBase64() {
321
344
  if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
322
345
  debugDevice('Taking screenshot', {
@@ -313,10 +313,33 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
313
313
  await sleep(50);
314
314
  const movedPos = libnut.getMousePos();
315
315
  console.log(`[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`);
316
+ const deltaX = Math.abs(movedPos.x - targetX);
317
+ const deltaY = Math.abs(movedPos.y - targetY);
318
+ if (deltaX > 5 || deltaY > 5) {
319
+ const msg = `[HealthCheck] WARNING: Mouse control may not be working. Expected (${targetX}, ${targetY}), got (${movedPos.x}, ${movedPos.y}), delta=(${deltaX}, ${deltaY})`;
320
+ console.warn(msg);
321
+ debugDevice(msg);
322
+ if ('win32' === process.platform && !this.isRunningAsAdmin()) {
323
+ const hint = "Midscene is NOT running as Administrator. Windows blocks mouse/keyboard input to elevated (admin) applications from non-admin processes (UIPI). Please run your terminal or Node.js as Administrator and try again.";
324
+ console.error(`\n[HealthCheck] ${hint}\n`);
325
+ debugDevice(hint);
326
+ }
327
+ }
316
328
  libnut.moveMouse(startPos.x, startPos.y);
317
329
  console.log(`[HealthCheck] Mouse restored to (${startPos.x}, ${startPos.y})`);
318
330
  console.log('[HealthCheck] Health check passed');
319
331
  }
332
+ isRunningAsAdmin() {
333
+ if ('win32' !== process.platform) return false;
334
+ try {
335
+ execSync('net session', {
336
+ stdio: 'pipe'
337
+ });
338
+ return true;
339
+ } catch {
340
+ return false;
341
+ }
342
+ }
320
343
  async screenshotBase64() {
321
344
  if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
322
345
  debugDevice('Taking screenshot', {
package/dist/lib/cli.js CHANGED
@@ -342,10 +342,33 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
342
342
  await (0, utils_namespaceObject.sleep)(50);
343
343
  const movedPos = libnut.getMousePos();
344
344
  console.log(`[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`);
345
+ const deltaX = Math.abs(movedPos.x - targetX);
346
+ const deltaY = Math.abs(movedPos.y - targetY);
347
+ if (deltaX > 5 || deltaY > 5) {
348
+ const msg = `[HealthCheck] WARNING: Mouse control may not be working. Expected (${targetX}, ${targetY}), got (${movedPos.x}, ${movedPos.y}), delta=(${deltaX}, ${deltaY})`;
349
+ console.warn(msg);
350
+ debugDevice(msg);
351
+ if ('win32' === process.platform && !this.isRunningAsAdmin()) {
352
+ const hint = "Midscene is NOT running as Administrator. Windows blocks mouse/keyboard input to elevated (admin) applications from non-admin processes (UIPI). Please run your terminal or Node.js as Administrator and try again.";
353
+ console.error(`\n[HealthCheck] ${hint}\n`);
354
+ debugDevice(hint);
355
+ }
356
+ }
345
357
  libnut.moveMouse(startPos.x, startPos.y);
346
358
  console.log(`[HealthCheck] Mouse restored to (${startPos.x}, ${startPos.y})`);
347
359
  console.log('[HealthCheck] Health check passed');
348
360
  }
361
+ isRunningAsAdmin() {
362
+ if ('win32' !== process.platform) return false;
363
+ try {
364
+ (0, external_node_child_process_namespaceObject.execSync)('net session', {
365
+ stdio: 'pipe'
366
+ });
367
+ return true;
368
+ } catch {
369
+ return false;
370
+ }
371
+ }
349
372
  async screenshotBase64() {
350
373
  if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
351
374
  debugDevice('Taking screenshot', {
package/dist/lib/index.js CHANGED
@@ -361,10 +361,33 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
361
361
  await (0, utils_namespaceObject.sleep)(50);
362
362
  const movedPos = device_libnut.getMousePos();
363
363
  console.log(`[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`);
364
+ const deltaX = Math.abs(movedPos.x - targetX);
365
+ const deltaY = Math.abs(movedPos.y - targetY);
366
+ if (deltaX > 5 || deltaY > 5) {
367
+ const msg = `[HealthCheck] WARNING: Mouse control may not be working. Expected (${targetX}, ${targetY}), got (${movedPos.x}, ${movedPos.y}), delta=(${deltaX}, ${deltaY})`;
368
+ console.warn(msg);
369
+ debugDevice(msg);
370
+ if ('win32' === process.platform && !this.isRunningAsAdmin()) {
371
+ const hint = "Midscene is NOT running as Administrator. Windows blocks mouse/keyboard input to elevated (admin) applications from non-admin processes (UIPI). Please run your terminal or Node.js as Administrator and try again.";
372
+ console.error(`\n[HealthCheck] ${hint}\n`);
373
+ debugDevice(hint);
374
+ }
375
+ }
364
376
  device_libnut.moveMouse(startPos.x, startPos.y);
365
377
  console.log(`[HealthCheck] Mouse restored to (${startPos.x}, ${startPos.y})`);
366
378
  console.log('[HealthCheck] Health check passed');
367
379
  }
380
+ isRunningAsAdmin() {
381
+ if ('win32' !== process.platform) return false;
382
+ try {
383
+ (0, external_node_child_process_namespaceObject.execSync)('net session', {
384
+ stdio: 'pipe'
385
+ });
386
+ return true;
387
+ } catch {
388
+ return false;
389
+ }
390
+ }
368
391
  async screenshotBase64() {
369
392
  if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
370
393
  debugDevice('Taking screenshot', {
@@ -357,10 +357,33 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
357
357
  await (0, utils_namespaceObject.sleep)(50);
358
358
  const movedPos = libnut.getMousePos();
359
359
  console.log(`[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`);
360
+ const deltaX = Math.abs(movedPos.x - targetX);
361
+ const deltaY = Math.abs(movedPos.y - targetY);
362
+ if (deltaX > 5 || deltaY > 5) {
363
+ const msg = `[HealthCheck] WARNING: Mouse control may not be working. Expected (${targetX}, ${targetY}), got (${movedPos.x}, ${movedPos.y}), delta=(${deltaX}, ${deltaY})`;
364
+ console.warn(msg);
365
+ debugDevice(msg);
366
+ if ('win32' === process.platform && !this.isRunningAsAdmin()) {
367
+ const hint = "Midscene is NOT running as Administrator. Windows blocks mouse/keyboard input to elevated (admin) applications from non-admin processes (UIPI). Please run your terminal or Node.js as Administrator and try again.";
368
+ console.error(`\n[HealthCheck] ${hint}\n`);
369
+ debugDevice(hint);
370
+ }
371
+ }
360
372
  libnut.moveMouse(startPos.x, startPos.y);
361
373
  console.log(`[HealthCheck] Mouse restored to (${startPos.x}, ${startPos.y})`);
362
374
  console.log('[HealthCheck] Health check passed');
363
375
  }
376
+ isRunningAsAdmin() {
377
+ if ('win32' !== process.platform) return false;
378
+ try {
379
+ (0, external_node_child_process_namespaceObject.execSync)('net session', {
380
+ stdio: 'pipe'
381
+ });
382
+ return true;
383
+ } catch {
384
+ return false;
385
+ }
386
+ }
364
387
  async screenshotBase64() {
365
388
  if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
366
389
  debugDevice('Taking screenshot', {
@@ -62,6 +62,11 @@ export declare class ComputerDevice implements AbstractInterface {
62
62
  static listDisplays(): Promise<DisplayInfo[]>;
63
63
  connect(): Promise<void>;
64
64
  private healthCheck;
65
+ /**
66
+ * Check if the current process is running with Administrator privileges.
67
+ * Uses "net session" which succeeds only when elevated.
68
+ */
69
+ private isRunningAsAdmin;
65
70
  screenshotBase64(): Promise<string>;
66
71
  size(): Promise<Size>;
67
72
  /**
@@ -35,6 +35,11 @@ declare class ComputerDevice implements AbstractInterface {
35
35
  static listDisplays(): Promise<DisplayInfo[]>;
36
36
  connect(): Promise<void>;
37
37
  private healthCheck;
38
+ /**
39
+ * Check if the current process is running with Administrator privileges.
40
+ * Uses "net session" which succeeds only when elevated.
41
+ */
42
+ private isRunningAsAdmin;
38
43
  screenshotBase64(): Promise<string>;
39
44
  size(): Promise<Size>;
40
45
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/computer",
3
- "version": "1.4.8-beta-20260227092357.0",
3
+ "version": "1.4.8",
4
4
  "description": "Midscene.js Computer Desktop Automation",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "@computer-use/libnut": "^4.2.0",
37
37
  "clipboardy": "^4.0.0",
38
38
  "screenshot-desktop": "^1.15.3",
39
- "@midscene/core": "1.4.8-beta-20260227092357.0",
40
- "@midscene/shared": "1.4.8-beta-20260227092357.0"
39
+ "@midscene/core": "1.4.8",
40
+ "@midscene/shared": "1.4.8"
41
41
  },
42
42
  "optionalDependencies": {
43
43
  "node-mac-permissions": "2.5.0"