@midscene/harmony 1.6.0 → 1.6.1-beta-20260327104111.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.
package/dist/es/bin.mjs CHANGED
@@ -261,11 +261,12 @@ const harmonyInputParamSchema = z.object({
261
261
  locate: getMidsceneLocationSchema().describe('The input field to be filled').optional()
262
262
  });
263
263
  const defaultScrollUntilTimes = 10;
264
- const defaultSwipeSpeed = 600;
265
264
  const defaultFastSwipeSpeed = 2000;
266
265
  const maxScrollDistance = 9999999;
267
266
  const scrollQuadrantDivisions = 4;
267
+ const screenEdgeMargin = 50;
268
268
  const debugDevice = getDebug('harmony:device');
269
+ let screenshotResizeScaleWarned = false;
269
270
  const harmonyKeyCodeMap = {
270
271
  Enter: '2054',
271
272
  Backspace: '2055',
@@ -484,12 +485,9 @@ class device_HarmonyDevice {
484
485
  }
485
486
  async size() {
486
487
  const screenInfo = await this.getScreenSize();
487
- const scale = this.options?.screenshotResizeScale ?? 1;
488
- const logicalWidth = Math.round(screenInfo.width * scale);
489
- const logicalHeight = Math.round(screenInfo.height * scale);
490
488
  return {
491
- width: logicalWidth,
492
- height: logicalHeight
489
+ width: screenInfo.width,
490
+ height: screenInfo.height
493
491
  };
494
492
  }
495
493
  async screenshotBase64() {
@@ -587,10 +585,10 @@ class device_HarmonyDevice {
587
585
  const maxNegativeDeltaY = height - startY;
588
586
  deltaX = Math.max(-maxNegativeDeltaX, Math.min(deltaX, maxPositiveDeltaX));
589
587
  deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
590
- const endX = Math.round(startX - deltaX);
591
- const endY = Math.round(startY - deltaY);
588
+ const endX = Math.round(Math.max(screenEdgeMargin, Math.min(width - screenEdgeMargin, startX - deltaX)));
589
+ const endY = Math.round(Math.max(screenEdgeMargin, Math.min(height - screenEdgeMargin, startY - deltaY)));
592
590
  const hdc = await this.getHdc();
593
- await hdc.swipe(startX, startY, endX, endY, speed ?? defaultSwipeSpeed);
591
+ await hdc.fling(startX, startY, endX, endY, speed ?? defaultFastSwipeSpeed);
594
592
  }
595
593
  async scrollInDirection(direction, distance, startPoint) {
596
594
  const { width, height } = await this.size();
@@ -603,23 +601,23 @@ class device_HarmonyDevice {
603
601
  const endPoints = {
604
602
  down: {
605
603
  x: sx,
606
- y: Math.max(0, sy - scrollDistance)
604
+ y: Math.max(screenEdgeMargin, sy - scrollDistance)
607
605
  },
608
606
  up: {
609
607
  x: sx,
610
- y: Math.min(height, sy + scrollDistance)
608
+ y: Math.min(height - screenEdgeMargin, sy + scrollDistance)
611
609
  },
612
610
  left: {
613
- x: Math.min(width, sx + scrollDistance),
611
+ x: Math.min(width - screenEdgeMargin, sx + scrollDistance),
614
612
  y: sy
615
613
  },
616
614
  right: {
617
- x: Math.max(0, sx - scrollDistance),
615
+ x: Math.max(screenEdgeMargin, sx - scrollDistance),
618
616
  y: sy
619
617
  }
620
618
  };
621
619
  const end = endPoints[direction];
622
- await hdc.swipe(sx, sy, end.x, end.y);
620
+ await hdc.fling(sx, sy, end.x, end.y, defaultFastSwipeSpeed);
623
621
  return;
624
622
  }
625
623
  const deltas = {
@@ -664,18 +662,18 @@ class device_HarmonyDevice {
664
662
  const flingTargets = {
665
663
  up: {
666
664
  x: sx,
667
- y: Math.round(height)
665
+ y: Math.round(height) - screenEdgeMargin
668
666
  },
669
667
  down: {
670
668
  x: sx,
671
- y: 0
669
+ y: screenEdgeMargin
672
670
  },
673
671
  left: {
674
- x: Math.round(width),
672
+ x: Math.round(width) - screenEdgeMargin,
675
673
  y: sy
676
674
  },
677
675
  right: {
678
- x: 0,
676
+ x: screenEdgeMargin,
679
677
  y: sy
680
678
  }
681
679
  };
@@ -773,6 +771,10 @@ class device_HarmonyDevice {
773
771
  this.deviceId = deviceId;
774
772
  this.options = options;
775
773
  this.customActions = options?.customActions;
774
+ if (options?.screenshotResizeScale !== void 0 && !screenshotResizeScaleWarned) {
775
+ screenshotResizeScaleWarned = true;
776
+ console.warn('[midscene] screenshotResizeScale is deprecated. Use screenshotShrinkFactor in AgentOpt instead.');
777
+ }
776
778
  }
777
779
  }
778
780
  const runHdcShellParamSchema = z.object({
package/dist/es/cli.mjs CHANGED
@@ -258,11 +258,12 @@ const harmonyInputParamSchema = z.object({
258
258
  locate: getMidsceneLocationSchema().describe('The input field to be filled').optional()
259
259
  });
260
260
  const defaultScrollUntilTimes = 10;
261
- const defaultSwipeSpeed = 600;
262
261
  const defaultFastSwipeSpeed = 2000;
263
262
  const maxScrollDistance = 9999999;
264
263
  const scrollQuadrantDivisions = 4;
264
+ const screenEdgeMargin = 50;
265
265
  const debugDevice = getDebug('harmony:device');
266
+ let screenshotResizeScaleWarned = false;
266
267
  const harmonyKeyCodeMap = {
267
268
  Enter: '2054',
268
269
  Backspace: '2055',
@@ -481,12 +482,9 @@ class HarmonyDevice {
481
482
  }
482
483
  async size() {
483
484
  const screenInfo = await this.getScreenSize();
484
- const scale = this.options?.screenshotResizeScale ?? 1;
485
- const logicalWidth = Math.round(screenInfo.width * scale);
486
- const logicalHeight = Math.round(screenInfo.height * scale);
487
485
  return {
488
- width: logicalWidth,
489
- height: logicalHeight
486
+ width: screenInfo.width,
487
+ height: screenInfo.height
490
488
  };
491
489
  }
492
490
  async screenshotBase64() {
@@ -584,10 +582,10 @@ class HarmonyDevice {
584
582
  const maxNegativeDeltaY = height - startY;
585
583
  deltaX = Math.max(-maxNegativeDeltaX, Math.min(deltaX, maxPositiveDeltaX));
586
584
  deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
587
- const endX = Math.round(startX - deltaX);
588
- const endY = Math.round(startY - deltaY);
585
+ const endX = Math.round(Math.max(screenEdgeMargin, Math.min(width - screenEdgeMargin, startX - deltaX)));
586
+ const endY = Math.round(Math.max(screenEdgeMargin, Math.min(height - screenEdgeMargin, startY - deltaY)));
589
587
  const hdc = await this.getHdc();
590
- await hdc.swipe(startX, startY, endX, endY, speed ?? defaultSwipeSpeed);
588
+ await hdc.fling(startX, startY, endX, endY, speed ?? defaultFastSwipeSpeed);
591
589
  }
592
590
  async scrollInDirection(direction, distance, startPoint) {
593
591
  const { width, height } = await this.size();
@@ -600,23 +598,23 @@ class HarmonyDevice {
600
598
  const endPoints = {
601
599
  down: {
602
600
  x: sx,
603
- y: Math.max(0, sy - scrollDistance)
601
+ y: Math.max(screenEdgeMargin, sy - scrollDistance)
604
602
  },
605
603
  up: {
606
604
  x: sx,
607
- y: Math.min(height, sy + scrollDistance)
605
+ y: Math.min(height - screenEdgeMargin, sy + scrollDistance)
608
606
  },
609
607
  left: {
610
- x: Math.min(width, sx + scrollDistance),
608
+ x: Math.min(width - screenEdgeMargin, sx + scrollDistance),
611
609
  y: sy
612
610
  },
613
611
  right: {
614
- x: Math.max(0, sx - scrollDistance),
612
+ x: Math.max(screenEdgeMargin, sx - scrollDistance),
615
613
  y: sy
616
614
  }
617
615
  };
618
616
  const end = endPoints[direction];
619
- await hdc.swipe(sx, sy, end.x, end.y);
617
+ await hdc.fling(sx, sy, end.x, end.y, defaultFastSwipeSpeed);
620
618
  return;
621
619
  }
622
620
  const deltas = {
@@ -661,18 +659,18 @@ class HarmonyDevice {
661
659
  const flingTargets = {
662
660
  up: {
663
661
  x: sx,
664
- y: Math.round(height)
662
+ y: Math.round(height) - screenEdgeMargin
665
663
  },
666
664
  down: {
667
665
  x: sx,
668
- y: 0
666
+ y: screenEdgeMargin
669
667
  },
670
668
  left: {
671
- x: Math.round(width),
669
+ x: Math.round(width) - screenEdgeMargin,
672
670
  y: sy
673
671
  },
674
672
  right: {
675
- x: 0,
673
+ x: screenEdgeMargin,
676
674
  y: sy
677
675
  }
678
676
  };
@@ -770,6 +768,10 @@ class HarmonyDevice {
770
768
  this.deviceId = deviceId;
771
769
  this.options = options;
772
770
  this.customActions = options?.customActions;
771
+ if (options?.screenshotResizeScale !== void 0 && !screenshotResizeScaleWarned) {
772
+ screenshotResizeScaleWarned = true;
773
+ console.warn('[midscene] screenshotResizeScale is deprecated. Use screenshotShrinkFactor in AgentOpt instead.');
774
+ }
773
775
  }
774
776
  }
775
777
  const runHdcShellParamSchema = z.object({
@@ -952,7 +954,7 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
952
954
  const tools = new HarmonyMidsceneTools();
953
955
  runToolsCLI(tools, 'midscene-harmony', {
954
956
  stripPrefix: 'harmony_',
955
- version: "1.6.0"
957
+ version: "1.6.1-beta-20260327104111.0"
956
958
  }).catch((e)=>{
957
959
  if (!(e instanceof CLIError)) console.error(e);
958
960
  process.exit(e instanceof CLIError ? e.exitCode : 1);
package/dist/es/index.mjs CHANGED
@@ -230,11 +230,12 @@ const harmonyInputParamSchema = z.object({
230
230
  locate: getMidsceneLocationSchema().describe('The input field to be filled').optional()
231
231
  });
232
232
  const defaultScrollUntilTimes = 10;
233
- const defaultSwipeSpeed = 600;
234
233
  const defaultFastSwipeSpeed = 2000;
235
234
  const maxScrollDistance = 9999999;
236
235
  const scrollQuadrantDivisions = 4;
236
+ const screenEdgeMargin = 50;
237
237
  const debugDevice = getDebug('harmony:device');
238
+ let screenshotResizeScaleWarned = false;
238
239
  const harmonyKeyCodeMap = {
239
240
  Enter: '2054',
240
241
  Backspace: '2055',
@@ -453,12 +454,9 @@ class HarmonyDevice {
453
454
  }
454
455
  async size() {
455
456
  const screenInfo = await this.getScreenSize();
456
- const scale = this.options?.screenshotResizeScale ?? 1;
457
- const logicalWidth = Math.round(screenInfo.width * scale);
458
- const logicalHeight = Math.round(screenInfo.height * scale);
459
457
  return {
460
- width: logicalWidth,
461
- height: logicalHeight
458
+ width: screenInfo.width,
459
+ height: screenInfo.height
462
460
  };
463
461
  }
464
462
  async screenshotBase64() {
@@ -556,10 +554,10 @@ class HarmonyDevice {
556
554
  const maxNegativeDeltaY = height - startY;
557
555
  deltaX = Math.max(-maxNegativeDeltaX, Math.min(deltaX, maxPositiveDeltaX));
558
556
  deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
559
- const endX = Math.round(startX - deltaX);
560
- const endY = Math.round(startY - deltaY);
557
+ const endX = Math.round(Math.max(screenEdgeMargin, Math.min(width - screenEdgeMargin, startX - deltaX)));
558
+ const endY = Math.round(Math.max(screenEdgeMargin, Math.min(height - screenEdgeMargin, startY - deltaY)));
561
559
  const hdc = await this.getHdc();
562
- await hdc.swipe(startX, startY, endX, endY, speed ?? defaultSwipeSpeed);
560
+ await hdc.fling(startX, startY, endX, endY, speed ?? defaultFastSwipeSpeed);
563
561
  }
564
562
  async scrollInDirection(direction, distance, startPoint) {
565
563
  const { width, height } = await this.size();
@@ -572,23 +570,23 @@ class HarmonyDevice {
572
570
  const endPoints = {
573
571
  down: {
574
572
  x: sx,
575
- y: Math.max(0, sy - scrollDistance)
573
+ y: Math.max(screenEdgeMargin, sy - scrollDistance)
576
574
  },
577
575
  up: {
578
576
  x: sx,
579
- y: Math.min(height, sy + scrollDistance)
577
+ y: Math.min(height - screenEdgeMargin, sy + scrollDistance)
580
578
  },
581
579
  left: {
582
- x: Math.min(width, sx + scrollDistance),
580
+ x: Math.min(width - screenEdgeMargin, sx + scrollDistance),
583
581
  y: sy
584
582
  },
585
583
  right: {
586
- x: Math.max(0, sx - scrollDistance),
584
+ x: Math.max(screenEdgeMargin, sx - scrollDistance),
587
585
  y: sy
588
586
  }
589
587
  };
590
588
  const end = endPoints[direction];
591
- await hdc.swipe(sx, sy, end.x, end.y);
589
+ await hdc.fling(sx, sy, end.x, end.y, defaultFastSwipeSpeed);
592
590
  return;
593
591
  }
594
592
  const deltas = {
@@ -633,18 +631,18 @@ class HarmonyDevice {
633
631
  const flingTargets = {
634
632
  up: {
635
633
  x: sx,
636
- y: Math.round(height)
634
+ y: Math.round(height) - screenEdgeMargin
637
635
  },
638
636
  down: {
639
637
  x: sx,
640
- y: 0
638
+ y: screenEdgeMargin
641
639
  },
642
640
  left: {
643
- x: Math.round(width),
641
+ x: Math.round(width) - screenEdgeMargin,
644
642
  y: sy
645
643
  },
646
644
  right: {
647
- x: 0,
645
+ x: screenEdgeMargin,
648
646
  y: sy
649
647
  }
650
648
  };
@@ -742,6 +740,10 @@ class HarmonyDevice {
742
740
  this.deviceId = deviceId;
743
741
  this.options = options;
744
742
  this.customActions = options?.customActions;
743
+ if (options?.screenshotResizeScale !== void 0 && !screenshotResizeScaleWarned) {
744
+ screenshotResizeScaleWarned = true;
745
+ console.warn('[midscene] screenshotResizeScale is deprecated. Use screenshotShrinkFactor in AgentOpt instead.');
746
+ }
745
747
  }
746
748
  }
747
749
  const runHdcShellParamSchema = z.object({
@@ -257,11 +257,12 @@ const harmonyInputParamSchema = z.object({
257
257
  locate: getMidsceneLocationSchema().describe('The input field to be filled').optional()
258
258
  });
259
259
  const defaultScrollUntilTimes = 10;
260
- const defaultSwipeSpeed = 600;
261
260
  const defaultFastSwipeSpeed = 2000;
262
261
  const maxScrollDistance = 9999999;
263
262
  const scrollQuadrantDivisions = 4;
263
+ const screenEdgeMargin = 50;
264
264
  const debugDevice = getDebug('harmony:device');
265
+ let screenshotResizeScaleWarned = false;
265
266
  const harmonyKeyCodeMap = {
266
267
  Enter: '2054',
267
268
  Backspace: '2055',
@@ -480,12 +481,9 @@ class HarmonyDevice {
480
481
  }
481
482
  async size() {
482
483
  const screenInfo = await this.getScreenSize();
483
- const scale = this.options?.screenshotResizeScale ?? 1;
484
- const logicalWidth = Math.round(screenInfo.width * scale);
485
- const logicalHeight = Math.round(screenInfo.height * scale);
486
484
  return {
487
- width: logicalWidth,
488
- height: logicalHeight
485
+ width: screenInfo.width,
486
+ height: screenInfo.height
489
487
  };
490
488
  }
491
489
  async screenshotBase64() {
@@ -583,10 +581,10 @@ class HarmonyDevice {
583
581
  const maxNegativeDeltaY = height - startY;
584
582
  deltaX = Math.max(-maxNegativeDeltaX, Math.min(deltaX, maxPositiveDeltaX));
585
583
  deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
586
- const endX = Math.round(startX - deltaX);
587
- const endY = Math.round(startY - deltaY);
584
+ const endX = Math.round(Math.max(screenEdgeMargin, Math.min(width - screenEdgeMargin, startX - deltaX)));
585
+ const endY = Math.round(Math.max(screenEdgeMargin, Math.min(height - screenEdgeMargin, startY - deltaY)));
588
586
  const hdc = await this.getHdc();
589
- await hdc.swipe(startX, startY, endX, endY, speed ?? defaultSwipeSpeed);
587
+ await hdc.fling(startX, startY, endX, endY, speed ?? defaultFastSwipeSpeed);
590
588
  }
591
589
  async scrollInDirection(direction, distance, startPoint) {
592
590
  const { width, height } = await this.size();
@@ -599,23 +597,23 @@ class HarmonyDevice {
599
597
  const endPoints = {
600
598
  down: {
601
599
  x: sx,
602
- y: Math.max(0, sy - scrollDistance)
600
+ y: Math.max(screenEdgeMargin, sy - scrollDistance)
603
601
  },
604
602
  up: {
605
603
  x: sx,
606
- y: Math.min(height, sy + scrollDistance)
604
+ y: Math.min(height - screenEdgeMargin, sy + scrollDistance)
607
605
  },
608
606
  left: {
609
- x: Math.min(width, sx + scrollDistance),
607
+ x: Math.min(width - screenEdgeMargin, sx + scrollDistance),
610
608
  y: sy
611
609
  },
612
610
  right: {
613
- x: Math.max(0, sx - scrollDistance),
611
+ x: Math.max(screenEdgeMargin, sx - scrollDistance),
614
612
  y: sy
615
613
  }
616
614
  };
617
615
  const end = endPoints[direction];
618
- await hdc.swipe(sx, sy, end.x, end.y);
616
+ await hdc.fling(sx, sy, end.x, end.y, defaultFastSwipeSpeed);
619
617
  return;
620
618
  }
621
619
  const deltas = {
@@ -660,18 +658,18 @@ class HarmonyDevice {
660
658
  const flingTargets = {
661
659
  up: {
662
660
  x: sx,
663
- y: Math.round(height)
661
+ y: Math.round(height) - screenEdgeMargin
664
662
  },
665
663
  down: {
666
664
  x: sx,
667
- y: 0
665
+ y: screenEdgeMargin
668
666
  },
669
667
  left: {
670
- x: Math.round(width),
668
+ x: Math.round(width) - screenEdgeMargin,
671
669
  y: sy
672
670
  },
673
671
  right: {
674
- x: 0,
672
+ x: screenEdgeMargin,
675
673
  y: sy
676
674
  }
677
675
  };
@@ -769,6 +767,10 @@ class HarmonyDevice {
769
767
  this.deviceId = deviceId;
770
768
  this.options = options;
771
769
  this.customActions = options?.customActions;
770
+ if (options?.screenshotResizeScale !== void 0 && !screenshotResizeScaleWarned) {
771
+ screenshotResizeScaleWarned = true;
772
+ console.warn('[midscene] screenshotResizeScale is deprecated. Use screenshotShrinkFactor in AgentOpt instead.');
773
+ }
772
774
  }
773
775
  }
774
776
  const runHdcShellParamSchema = z.object({
@@ -955,7 +957,7 @@ class HarmonyMCPServer extends BaseMCPServer {
955
957
  constructor(toolsManager){
956
958
  super({
957
959
  name: '@midscene/harmony-mcp',
958
- version: "1.6.0",
960
+ version: "1.6.1-beta-20260327104111.0",
959
961
  description: 'Control the HarmonyOS device using natural language commands'
960
962
  }, toolsManager);
961
963
  }
package/dist/lib/bin.js CHANGED
@@ -287,11 +287,12 @@ const harmonyInputParamSchema = core_namespaceObject.z.object({
287
287
  locate: (0, core_namespaceObject.getMidsceneLocationSchema)().describe('The input field to be filled').optional()
288
288
  });
289
289
  const defaultScrollUntilTimes = 10;
290
- const defaultSwipeSpeed = 600;
291
290
  const defaultFastSwipeSpeed = 2000;
292
291
  const maxScrollDistance = 9999999;
293
292
  const scrollQuadrantDivisions = 4;
293
+ const screenEdgeMargin = 50;
294
294
  const debugDevice = (0, logger_namespaceObject.getDebug)('harmony:device');
295
+ let screenshotResizeScaleWarned = false;
295
296
  const harmonyKeyCodeMap = {
296
297
  Enter: '2054',
297
298
  Backspace: '2055',
@@ -510,12 +511,9 @@ class device_HarmonyDevice {
510
511
  }
511
512
  async size() {
512
513
  const screenInfo = await this.getScreenSize();
513
- const scale = this.options?.screenshotResizeScale ?? 1;
514
- const logicalWidth = Math.round(screenInfo.width * scale);
515
- const logicalHeight = Math.round(screenInfo.height * scale);
516
514
  return {
517
- width: logicalWidth,
518
- height: logicalHeight
515
+ width: screenInfo.width,
516
+ height: screenInfo.height
519
517
  };
520
518
  }
521
519
  async screenshotBase64() {
@@ -613,10 +611,10 @@ class device_HarmonyDevice {
613
611
  const maxNegativeDeltaY = height - startY;
614
612
  deltaX = Math.max(-maxNegativeDeltaX, Math.min(deltaX, maxPositiveDeltaX));
615
613
  deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
616
- const endX = Math.round(startX - deltaX);
617
- const endY = Math.round(startY - deltaY);
614
+ const endX = Math.round(Math.max(screenEdgeMargin, Math.min(width - screenEdgeMargin, startX - deltaX)));
615
+ const endY = Math.round(Math.max(screenEdgeMargin, Math.min(height - screenEdgeMargin, startY - deltaY)));
618
616
  const hdc = await this.getHdc();
619
- await hdc.swipe(startX, startY, endX, endY, speed ?? defaultSwipeSpeed);
617
+ await hdc.fling(startX, startY, endX, endY, speed ?? defaultFastSwipeSpeed);
620
618
  }
621
619
  async scrollInDirection(direction, distance, startPoint) {
622
620
  const { width, height } = await this.size();
@@ -629,23 +627,23 @@ class device_HarmonyDevice {
629
627
  const endPoints = {
630
628
  down: {
631
629
  x: sx,
632
- y: Math.max(0, sy - scrollDistance)
630
+ y: Math.max(screenEdgeMargin, sy - scrollDistance)
633
631
  },
634
632
  up: {
635
633
  x: sx,
636
- y: Math.min(height, sy + scrollDistance)
634
+ y: Math.min(height - screenEdgeMargin, sy + scrollDistance)
637
635
  },
638
636
  left: {
639
- x: Math.min(width, sx + scrollDistance),
637
+ x: Math.min(width - screenEdgeMargin, sx + scrollDistance),
640
638
  y: sy
641
639
  },
642
640
  right: {
643
- x: Math.max(0, sx - scrollDistance),
641
+ x: Math.max(screenEdgeMargin, sx - scrollDistance),
644
642
  y: sy
645
643
  }
646
644
  };
647
645
  const end = endPoints[direction];
648
- await hdc.swipe(sx, sy, end.x, end.y);
646
+ await hdc.fling(sx, sy, end.x, end.y, defaultFastSwipeSpeed);
649
647
  return;
650
648
  }
651
649
  const deltas = {
@@ -690,18 +688,18 @@ class device_HarmonyDevice {
690
688
  const flingTargets = {
691
689
  up: {
692
690
  x: sx,
693
- y: Math.round(height)
691
+ y: Math.round(height) - screenEdgeMargin
694
692
  },
695
693
  down: {
696
694
  x: sx,
697
- y: 0
695
+ y: screenEdgeMargin
698
696
  },
699
697
  left: {
700
- x: Math.round(width),
698
+ x: Math.round(width) - screenEdgeMargin,
701
699
  y: sy
702
700
  },
703
701
  right: {
704
- x: 0,
702
+ x: screenEdgeMargin,
705
703
  y: sy
706
704
  }
707
705
  };
@@ -799,6 +797,10 @@ class device_HarmonyDevice {
799
797
  this.deviceId = deviceId;
800
798
  this.options = options;
801
799
  this.customActions = options?.customActions;
800
+ if (options?.screenshotResizeScale !== void 0 && !screenshotResizeScaleWarned) {
801
+ screenshotResizeScaleWarned = true;
802
+ console.warn('[midscene] screenshotResizeScale is deprecated. Use screenshotShrinkFactor in AgentOpt instead.');
803
+ }
802
804
  }
803
805
  }
804
806
  const runHdcShellParamSchema = core_namespaceObject.z.object({
package/dist/lib/cli.js CHANGED
@@ -283,11 +283,12 @@ const harmonyInputParamSchema = core_namespaceObject.z.object({
283
283
  locate: (0, core_namespaceObject.getMidsceneLocationSchema)().describe('The input field to be filled').optional()
284
284
  });
285
285
  const defaultScrollUntilTimes = 10;
286
- const defaultSwipeSpeed = 600;
287
286
  const defaultFastSwipeSpeed = 2000;
288
287
  const maxScrollDistance = 9999999;
289
288
  const scrollQuadrantDivisions = 4;
289
+ const screenEdgeMargin = 50;
290
290
  const debugDevice = (0, logger_namespaceObject.getDebug)('harmony:device');
291
+ let screenshotResizeScaleWarned = false;
291
292
  const harmonyKeyCodeMap = {
292
293
  Enter: '2054',
293
294
  Backspace: '2055',
@@ -506,12 +507,9 @@ class HarmonyDevice {
506
507
  }
507
508
  async size() {
508
509
  const screenInfo = await this.getScreenSize();
509
- const scale = this.options?.screenshotResizeScale ?? 1;
510
- const logicalWidth = Math.round(screenInfo.width * scale);
511
- const logicalHeight = Math.round(screenInfo.height * scale);
512
510
  return {
513
- width: logicalWidth,
514
- height: logicalHeight
511
+ width: screenInfo.width,
512
+ height: screenInfo.height
515
513
  };
516
514
  }
517
515
  async screenshotBase64() {
@@ -609,10 +607,10 @@ class HarmonyDevice {
609
607
  const maxNegativeDeltaY = height - startY;
610
608
  deltaX = Math.max(-maxNegativeDeltaX, Math.min(deltaX, maxPositiveDeltaX));
611
609
  deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
612
- const endX = Math.round(startX - deltaX);
613
- const endY = Math.round(startY - deltaY);
610
+ const endX = Math.round(Math.max(screenEdgeMargin, Math.min(width - screenEdgeMargin, startX - deltaX)));
611
+ const endY = Math.round(Math.max(screenEdgeMargin, Math.min(height - screenEdgeMargin, startY - deltaY)));
614
612
  const hdc = await this.getHdc();
615
- await hdc.swipe(startX, startY, endX, endY, speed ?? defaultSwipeSpeed);
613
+ await hdc.fling(startX, startY, endX, endY, speed ?? defaultFastSwipeSpeed);
616
614
  }
617
615
  async scrollInDirection(direction, distance, startPoint) {
618
616
  const { width, height } = await this.size();
@@ -625,23 +623,23 @@ class HarmonyDevice {
625
623
  const endPoints = {
626
624
  down: {
627
625
  x: sx,
628
- y: Math.max(0, sy - scrollDistance)
626
+ y: Math.max(screenEdgeMargin, sy - scrollDistance)
629
627
  },
630
628
  up: {
631
629
  x: sx,
632
- y: Math.min(height, sy + scrollDistance)
630
+ y: Math.min(height - screenEdgeMargin, sy + scrollDistance)
633
631
  },
634
632
  left: {
635
- x: Math.min(width, sx + scrollDistance),
633
+ x: Math.min(width - screenEdgeMargin, sx + scrollDistance),
636
634
  y: sy
637
635
  },
638
636
  right: {
639
- x: Math.max(0, sx - scrollDistance),
637
+ x: Math.max(screenEdgeMargin, sx - scrollDistance),
640
638
  y: sy
641
639
  }
642
640
  };
643
641
  const end = endPoints[direction];
644
- await hdc.swipe(sx, sy, end.x, end.y);
642
+ await hdc.fling(sx, sy, end.x, end.y, defaultFastSwipeSpeed);
645
643
  return;
646
644
  }
647
645
  const deltas = {
@@ -686,18 +684,18 @@ class HarmonyDevice {
686
684
  const flingTargets = {
687
685
  up: {
688
686
  x: sx,
689
- y: Math.round(height)
687
+ y: Math.round(height) - screenEdgeMargin
690
688
  },
691
689
  down: {
692
690
  x: sx,
693
- y: 0
691
+ y: screenEdgeMargin
694
692
  },
695
693
  left: {
696
- x: Math.round(width),
694
+ x: Math.round(width) - screenEdgeMargin,
697
695
  y: sy
698
696
  },
699
697
  right: {
700
- x: 0,
698
+ x: screenEdgeMargin,
701
699
  y: sy
702
700
  }
703
701
  };
@@ -795,6 +793,10 @@ class HarmonyDevice {
795
793
  this.deviceId = deviceId;
796
794
  this.options = options;
797
795
  this.customActions = options?.customActions;
796
+ if (options?.screenshotResizeScale !== void 0 && !screenshotResizeScaleWarned) {
797
+ screenshotResizeScaleWarned = true;
798
+ console.warn('[midscene] screenshotResizeScale is deprecated. Use screenshotShrinkFactor in AgentOpt instead.');
799
+ }
798
800
  }
799
801
  }
800
802
  const runHdcShellParamSchema = core_namespaceObject.z.object({
@@ -977,7 +979,7 @@ class HarmonyMidsceneTools extends mcp_namespaceObject.BaseMidsceneTools {
977
979
  const tools = new HarmonyMidsceneTools();
978
980
  (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-harmony', {
979
981
  stripPrefix: 'harmony_',
980
- version: "1.6.0"
982
+ version: "1.6.1-beta-20260327104111.0"
981
983
  }).catch((e)=>{
982
984
  if (!(e instanceof cli_namespaceObject.CLIError)) console.error(e);
983
985
  process.exit(e instanceof cli_namespaceObject.CLIError ? e.exitCode : 1);