@midscene/computer 1.4.3 → 1.4.4

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
@@ -205,6 +205,39 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
205
205
  debugDevice(`Failed to connect: ${error}`);
206
206
  throw new Error(`Unable to connect to computer device: ${error}`);
207
207
  }
208
+ await this.healthCheck();
209
+ }
210
+ async healthCheck() {
211
+ console.log('[HealthCheck] Starting health check...');
212
+ console.log('[HealthCheck] Taking screenshot...');
213
+ try {
214
+ const base64 = await this.screenshotBase64();
215
+ console.log(`[HealthCheck] Screenshot succeeded (length=${base64.length})`);
216
+ } catch (error) {
217
+ console.error(`[HealthCheck] Screenshot failed: ${error}`);
218
+ process.exit(1);
219
+ }
220
+ console.log('[HealthCheck] Moving mouse...');
221
+ try {
222
+ node_assert(libnut, 'libnut not initialized');
223
+ const startPos = libnut.getMousePos();
224
+ console.log(`[HealthCheck] Current mouse position: (${startPos.x}, ${startPos.y})`);
225
+ const offsetX = Math.floor(40 * Math.random()) + 10;
226
+ const offsetY = Math.floor(40 * Math.random()) + 10;
227
+ const targetX = startPos.x + offsetX;
228
+ const targetY = startPos.y + offsetY;
229
+ console.log(`[HealthCheck] Moving mouse to (${targetX}, ${targetY})...`);
230
+ libnut.moveMouse(targetX, targetY);
231
+ await sleep(50);
232
+ const movedPos = libnut.getMousePos();
233
+ console.log(`[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`);
234
+ libnut.moveMouse(startPos.x, startPos.y);
235
+ console.log(`[HealthCheck] Mouse restored to (${startPos.x}, ${startPos.y})`);
236
+ } catch (error) {
237
+ console.error(`[HealthCheck] Mouse move failed: ${error}`);
238
+ process.exit(1);
239
+ }
240
+ console.log('[HealthCheck] Health check passed');
208
241
  }
209
242
  async screenshotBase64() {
210
243
  debugDevice('Taking screenshot', {
package/dist/es/index.mjs CHANGED
@@ -204,6 +204,39 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
204
204
  debugDevice(`Failed to connect: ${error}`);
205
205
  throw new Error(`Unable to connect to computer device: ${error}`);
206
206
  }
207
+ await this.healthCheck();
208
+ }
209
+ async healthCheck() {
210
+ console.log('[HealthCheck] Starting health check...');
211
+ console.log('[HealthCheck] Taking screenshot...');
212
+ try {
213
+ const base64 = await this.screenshotBase64();
214
+ console.log(`[HealthCheck] Screenshot succeeded (length=${base64.length})`);
215
+ } catch (error) {
216
+ console.error(`[HealthCheck] Screenshot failed: ${error}`);
217
+ process.exit(1);
218
+ }
219
+ console.log('[HealthCheck] Moving mouse...');
220
+ try {
221
+ node_assert(device_libnut, 'libnut not initialized');
222
+ const startPos = device_libnut.getMousePos();
223
+ console.log(`[HealthCheck] Current mouse position: (${startPos.x}, ${startPos.y})`);
224
+ const offsetX = Math.floor(40 * Math.random()) + 10;
225
+ const offsetY = Math.floor(40 * Math.random()) + 10;
226
+ const targetX = startPos.x + offsetX;
227
+ const targetY = startPos.y + offsetY;
228
+ console.log(`[HealthCheck] Moving mouse to (${targetX}, ${targetY})...`);
229
+ device_libnut.moveMouse(targetX, targetY);
230
+ await sleep(50);
231
+ const movedPos = device_libnut.getMousePos();
232
+ console.log(`[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`);
233
+ device_libnut.moveMouse(startPos.x, startPos.y);
234
+ console.log(`[HealthCheck] Mouse restored to (${startPos.x}, ${startPos.y})`);
235
+ } catch (error) {
236
+ console.error(`[HealthCheck] Mouse move failed: ${error}`);
237
+ process.exit(1);
238
+ }
239
+ console.log('[HealthCheck] Health check passed');
207
240
  }
208
241
  async screenshotBase64() {
209
242
  debugDevice('Taking screenshot', {
@@ -204,6 +204,39 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
204
204
  debugDevice(`Failed to connect: ${error}`);
205
205
  throw new Error(`Unable to connect to computer device: ${error}`);
206
206
  }
207
+ await this.healthCheck();
208
+ }
209
+ async healthCheck() {
210
+ console.log('[HealthCheck] Starting health check...');
211
+ console.log('[HealthCheck] Taking screenshot...');
212
+ try {
213
+ const base64 = await this.screenshotBase64();
214
+ console.log(`[HealthCheck] Screenshot succeeded (length=${base64.length})`);
215
+ } catch (error) {
216
+ console.error(`[HealthCheck] Screenshot failed: ${error}`);
217
+ process.exit(1);
218
+ }
219
+ console.log('[HealthCheck] Moving mouse...');
220
+ try {
221
+ node_assert(libnut, 'libnut not initialized');
222
+ const startPos = libnut.getMousePos();
223
+ console.log(`[HealthCheck] Current mouse position: (${startPos.x}, ${startPos.y})`);
224
+ const offsetX = Math.floor(40 * Math.random()) + 10;
225
+ const offsetY = Math.floor(40 * Math.random()) + 10;
226
+ const targetX = startPos.x + offsetX;
227
+ const targetY = startPos.y + offsetY;
228
+ console.log(`[HealthCheck] Moving mouse to (${targetX}, ${targetY})...`);
229
+ libnut.moveMouse(targetX, targetY);
230
+ await sleep(50);
231
+ const movedPos = libnut.getMousePos();
232
+ console.log(`[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`);
233
+ libnut.moveMouse(startPos.x, startPos.y);
234
+ console.log(`[HealthCheck] Mouse restored to (${startPos.x}, ${startPos.y})`);
235
+ } catch (error) {
236
+ console.error(`[HealthCheck] Mouse move failed: ${error}`);
237
+ process.exit(1);
238
+ }
239
+ console.log('[HealthCheck] Health check passed');
207
240
  }
208
241
  async screenshotBase64() {
209
242
  debugDevice('Taking screenshot', {
package/dist/lib/cli.js CHANGED
@@ -233,6 +233,39 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
233
233
  debugDevice(`Failed to connect: ${error}`);
234
234
  throw new Error(`Unable to connect to computer device: ${error}`);
235
235
  }
236
+ await this.healthCheck();
237
+ }
238
+ async healthCheck() {
239
+ console.log('[HealthCheck] Starting health check...');
240
+ console.log('[HealthCheck] Taking screenshot...');
241
+ try {
242
+ const base64 = await this.screenshotBase64();
243
+ console.log(`[HealthCheck] Screenshot succeeded (length=${base64.length})`);
244
+ } catch (error) {
245
+ console.error(`[HealthCheck] Screenshot failed: ${error}`);
246
+ process.exit(1);
247
+ }
248
+ console.log('[HealthCheck] Moving mouse...');
249
+ try {
250
+ external_node_assert_default()(libnut, 'libnut not initialized');
251
+ const startPos = libnut.getMousePos();
252
+ console.log(`[HealthCheck] Current mouse position: (${startPos.x}, ${startPos.y})`);
253
+ const offsetX = Math.floor(40 * Math.random()) + 10;
254
+ const offsetY = Math.floor(40 * Math.random()) + 10;
255
+ const targetX = startPos.x + offsetX;
256
+ const targetY = startPos.y + offsetY;
257
+ console.log(`[HealthCheck] Moving mouse to (${targetX}, ${targetY})...`);
258
+ libnut.moveMouse(targetX, targetY);
259
+ await (0, utils_namespaceObject.sleep)(50);
260
+ const movedPos = libnut.getMousePos();
261
+ console.log(`[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`);
262
+ libnut.moveMouse(startPos.x, startPos.y);
263
+ console.log(`[HealthCheck] Mouse restored to (${startPos.x}, ${startPos.y})`);
264
+ } catch (error) {
265
+ console.error(`[HealthCheck] Mouse move failed: ${error}`);
266
+ process.exit(1);
267
+ }
268
+ console.log('[HealthCheck] Health check passed');
236
269
  }
237
270
  async screenshotBase64() {
238
271
  debugDevice('Taking screenshot', {
package/dist/lib/index.js CHANGED
@@ -250,6 +250,39 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
250
250
  debugDevice(`Failed to connect: ${error}`);
251
251
  throw new Error(`Unable to connect to computer device: ${error}`);
252
252
  }
253
+ await this.healthCheck();
254
+ }
255
+ async healthCheck() {
256
+ console.log('[HealthCheck] Starting health check...');
257
+ console.log('[HealthCheck] Taking screenshot...');
258
+ try {
259
+ const base64 = await this.screenshotBase64();
260
+ console.log(`[HealthCheck] Screenshot succeeded (length=${base64.length})`);
261
+ } catch (error) {
262
+ console.error(`[HealthCheck] Screenshot failed: ${error}`);
263
+ process.exit(1);
264
+ }
265
+ console.log('[HealthCheck] Moving mouse...');
266
+ try {
267
+ external_node_assert_default()(device_libnut, 'libnut not initialized');
268
+ const startPos = device_libnut.getMousePos();
269
+ console.log(`[HealthCheck] Current mouse position: (${startPos.x}, ${startPos.y})`);
270
+ const offsetX = Math.floor(40 * Math.random()) + 10;
271
+ const offsetY = Math.floor(40 * Math.random()) + 10;
272
+ const targetX = startPos.x + offsetX;
273
+ const targetY = startPos.y + offsetY;
274
+ console.log(`[HealthCheck] Moving mouse to (${targetX}, ${targetY})...`);
275
+ device_libnut.moveMouse(targetX, targetY);
276
+ await (0, utils_namespaceObject.sleep)(50);
277
+ const movedPos = device_libnut.getMousePos();
278
+ console.log(`[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`);
279
+ device_libnut.moveMouse(startPos.x, startPos.y);
280
+ console.log(`[HealthCheck] Mouse restored to (${startPos.x}, ${startPos.y})`);
281
+ } catch (error) {
282
+ console.error(`[HealthCheck] Mouse move failed: ${error}`);
283
+ process.exit(1);
284
+ }
285
+ console.log('[HealthCheck] Health check passed');
253
286
  }
254
287
  async screenshotBase64() {
255
288
  debugDevice('Taking screenshot', {
@@ -248,6 +248,39 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
248
248
  debugDevice(`Failed to connect: ${error}`);
249
249
  throw new Error(`Unable to connect to computer device: ${error}`);
250
250
  }
251
+ await this.healthCheck();
252
+ }
253
+ async healthCheck() {
254
+ console.log('[HealthCheck] Starting health check...');
255
+ console.log('[HealthCheck] Taking screenshot...');
256
+ try {
257
+ const base64 = await this.screenshotBase64();
258
+ console.log(`[HealthCheck] Screenshot succeeded (length=${base64.length})`);
259
+ } catch (error) {
260
+ console.error(`[HealthCheck] Screenshot failed: ${error}`);
261
+ process.exit(1);
262
+ }
263
+ console.log('[HealthCheck] Moving mouse...');
264
+ try {
265
+ external_node_assert_default()(libnut, 'libnut not initialized');
266
+ const startPos = libnut.getMousePos();
267
+ console.log(`[HealthCheck] Current mouse position: (${startPos.x}, ${startPos.y})`);
268
+ const offsetX = Math.floor(40 * Math.random()) + 10;
269
+ const offsetY = Math.floor(40 * Math.random()) + 10;
270
+ const targetX = startPos.x + offsetX;
271
+ const targetY = startPos.y + offsetY;
272
+ console.log(`[HealthCheck] Moving mouse to (${targetX}, ${targetY})...`);
273
+ libnut.moveMouse(targetX, targetY);
274
+ await (0, utils_namespaceObject.sleep)(50);
275
+ const movedPos = libnut.getMousePos();
276
+ console.log(`[HealthCheck] Mouse position after move: (${movedPos.x}, ${movedPos.y})`);
277
+ libnut.moveMouse(startPos.x, startPos.y);
278
+ console.log(`[HealthCheck] Mouse restored to (${startPos.x}, ${startPos.y})`);
279
+ } catch (error) {
280
+ console.error(`[HealthCheck] Mouse move failed: ${error}`);
281
+ process.exit(1);
282
+ }
283
+ console.log('[HealthCheck] Health check passed');
251
284
  }
252
285
  async screenshotBase64() {
253
286
  debugDevice('Taking screenshot', {
@@ -54,6 +54,7 @@ export declare class ComputerDevice implements AbstractInterface {
54
54
  */
55
55
  static listDisplays(): Promise<DisplayInfo[]>;
56
56
  connect(): Promise<void>;
57
+ private healthCheck;
57
58
  screenshotBase64(): Promise<string>;
58
59
  size(): Promise<Size>;
59
60
  /**
@@ -32,6 +32,7 @@ declare class ComputerDevice implements AbstractInterface {
32
32
  */
33
33
  static listDisplays(): Promise<DisplayInfo[]>;
34
34
  connect(): Promise<void>;
35
+ private healthCheck;
35
36
  screenshotBase64(): Promise<string>;
36
37
  size(): Promise<Size>;
37
38
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/computer",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
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.3",
40
- "@midscene/shared": "1.4.3"
39
+ "@midscene/core": "1.4.4",
40
+ "@midscene/shared": "1.4.4"
41
41
  },
42
42
  "optionalDependencies": {
43
43
  "node-mac-permissions": "2.5.0"