@midscene/computer 1.12.7 → 1.12.8-beta-20260915081046.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/cli.mjs CHANGED
@@ -1120,6 +1120,17 @@ class ComputerDevice {
1120
1120
  moveDisplayPointer(point, context, smooth) {
1121
1121
  return this.moveGlobalPointer(this.toGlobalPoint(point), context, smooth);
1122
1122
  }
1123
+ async performPointerDrag(from, to, duration) {
1124
+ await this.moveDisplayPointer(from, 'Mouse did not reach the drag start target');
1125
+ await this.inputDriver.withMouseButton('left', async ()=>{
1126
+ await this.inputDriver.delay(100);
1127
+ await this.moveDisplayPointer(to, 'Mouse did not reach the drag end target', {
1128
+ smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
1129
+ smoothDelay: void 0 === duration ? SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / SMOOTH_MOVE_STEPS_DRAG))
1130
+ });
1131
+ await this.inputDriver.delay(100);
1132
+ });
1133
+ }
1123
1134
  async focusKeyboardTarget(element, delayMs) {
1124
1135
  const [x, y] = element.center;
1125
1136
  if ('darwin' === process.platform) await this.inputPrimitives.pointer.tap({
@@ -1212,7 +1223,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
1212
1223
  }
1213
1224
  async healthCheck(displays) {
1214
1225
  console.log('[HealthCheck] Starting health check...');
1215
- console.log("[HealthCheck] @midscene/computer v1.12.7");
1226
+ console.log("[HealthCheck] @midscene/computer v1.12.8-beta-20260915081046.0");
1216
1227
  console.log('[HealthCheck] Taking screenshot...');
1217
1228
  const screenshotTimeout = 15000;
1218
1229
  let timeoutId;
@@ -1560,7 +1571,9 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
1560
1571
  }
1561
1572
  actionSpace() {
1562
1573
  const defaultActions = [
1563
- ...defineActionsFromInputPrimitives(this.inputPrimitives)
1574
+ ...defineActionsFromInputPrimitives(this.inputPrimitives, {
1575
+ size: ()=>this.size()
1576
+ })
1564
1577
  ];
1565
1578
  const platformActions = Object.values(createPlatformActions());
1566
1579
  const customActions = this.options?.customActions || [];
@@ -1691,15 +1704,10 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
1691
1704
  await this.inputDriver.delay(MOUSE_MOVE_EFFECT_WAIT);
1692
1705
  },
1693
1706
  dragAndDrop: async (from, to)=>{
1694
- await this.moveDisplayPointer(from, 'Mouse did not reach the drag start target');
1695
- await this.inputDriver.withMouseButton('left', async ()=>{
1696
- await this.inputDriver.delay(100);
1697
- await this.moveDisplayPointer(to, 'Mouse did not reach the drag end target', {
1698
- smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
1699
- smoothDelay: SMOOTH_MOVE_DELAY_DRAG
1700
- });
1701
- await this.inputDriver.delay(100);
1702
- });
1707
+ await this.performPointerDrag(from, to);
1708
+ },
1709
+ swipe: async (from, to, opts)=>{
1710
+ await this.performPointerDrag(from, to, opts?.duration);
1703
1711
  }
1704
1712
  },
1705
1713
  keyboard: {
@@ -2200,7 +2208,9 @@ class RDPDevice {
2200
2208
  }
2201
2209
  actionSpace() {
2202
2210
  const defaultActions = [
2203
- ...defineActionsFromInputPrimitives(this.inputPrimitives),
2211
+ ...defineActionsFromInputPrimitives(this.inputPrimitives, {
2212
+ size: ()=>this.size()
2213
+ }),
2204
2214
  defineAction({
2205
2215
  name: 'ListDisplays',
2206
2216
  description: 'List all available displays/monitors',
@@ -2284,6 +2294,23 @@ class RDPDevice {
2284
2294
  }
2285
2295
  if (options?.settleDelayMs) await sleep(options.settleDelayMs);
2286
2296
  }
2297
+ async performPointerDrag(from, to, duration) {
2298
+ await this.movePointer(Math.round(from.x), Math.round(from.y), {
2299
+ steps: device_SMOOTH_MOVE_STEPS_TAP,
2300
+ stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
2301
+ });
2302
+ await this.backend.mouseButton('left', 'down');
2303
+ try {
2304
+ await sleep(DRAG_HOLD_DURATION);
2305
+ await this.movePointer(Math.round(to.x), Math.round(to.y), {
2306
+ steps: device_SMOOTH_MOVE_STEPS_DRAG,
2307
+ stepDelayMs: void 0 === duration ? device_SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / device_SMOOTH_MOVE_STEPS_DRAG))
2308
+ });
2309
+ await sleep(DRAG_HOLD_DURATION);
2310
+ } finally{
2311
+ await this.backend.mouseButton('left', 'up');
2312
+ }
2313
+ }
2287
2314
  async performWheel(direction, amount, x, y) {
2288
2315
  let remaining = Math.abs(amount);
2289
2316
  if (0 === remaining) remaining = DEFAULT_SCROLL_STEP_AMOUNT;
@@ -2337,18 +2364,10 @@ class RDPDevice {
2337
2364
  });
2338
2365
  },
2339
2366
  dragAndDrop: async (from, to)=>{
2340
- await this.movePointer(Math.round(from.x), Math.round(from.y), {
2341
- steps: device_SMOOTH_MOVE_STEPS_TAP,
2342
- stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
2343
- });
2344
- await this.backend.mouseButton('left', 'down');
2345
- await sleep(DRAG_HOLD_DURATION);
2346
- await this.movePointer(Math.round(to.x), Math.round(to.y), {
2347
- steps: device_SMOOTH_MOVE_STEPS_DRAG,
2348
- stepDelayMs: device_SMOOTH_MOVE_DELAY_DRAG
2349
- });
2350
- await sleep(DRAG_HOLD_DURATION);
2351
- await this.backend.mouseButton('left', 'up');
2367
+ await this.performPointerDrag(from, to);
2368
+ },
2369
+ swipe: async (from, to, opts)=>{
2370
+ await this.performPointerDrag(from, to, opts?.duration);
2352
2371
  }
2353
2372
  },
2354
2373
  keyboard: {
@@ -2688,7 +2707,7 @@ const tools = new ComputerMidsceneTools({
2688
2707
  });
2689
2708
  runToolsCLI(tools, 'midscene-computer', {
2690
2709
  stripPrefix: 'computer_',
2691
- version: "1.12.7",
2710
+ version: "1.12.8-beta-20260915081046.0",
2692
2711
  extraCommands: createReportCliCommands()
2693
2712
  }).catch((e)=>{
2694
2713
  process.exit(reportCLIError(e));
package/dist/es/index.mjs CHANGED
@@ -1120,6 +1120,17 @@ class ComputerDevice {
1120
1120
  moveDisplayPointer(point, context, smooth) {
1121
1121
  return this.moveGlobalPointer(this.toGlobalPoint(point), context, smooth);
1122
1122
  }
1123
+ async performPointerDrag(from, to, duration) {
1124
+ await this.moveDisplayPointer(from, 'Mouse did not reach the drag start target');
1125
+ await this.inputDriver.withMouseButton('left', async ()=>{
1126
+ await this.inputDriver.delay(100);
1127
+ await this.moveDisplayPointer(to, 'Mouse did not reach the drag end target', {
1128
+ smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
1129
+ smoothDelay: void 0 === duration ? SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / SMOOTH_MOVE_STEPS_DRAG))
1130
+ });
1131
+ await this.inputDriver.delay(100);
1132
+ });
1133
+ }
1123
1134
  async focusKeyboardTarget(element, delayMs) {
1124
1135
  const [x, y] = element.center;
1125
1136
  if ('darwin' === process.platform) await this.inputPrimitives.pointer.tap({
@@ -1212,7 +1223,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
1212
1223
  }
1213
1224
  async healthCheck(displays) {
1214
1225
  console.log('[HealthCheck] Starting health check...');
1215
- console.log("[HealthCheck] @midscene/computer v1.12.7");
1226
+ console.log("[HealthCheck] @midscene/computer v1.12.8-beta-20260915081046.0");
1216
1227
  console.log('[HealthCheck] Taking screenshot...');
1217
1228
  const screenshotTimeout = 15000;
1218
1229
  let timeoutId;
@@ -1560,7 +1571,9 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
1560
1571
  }
1561
1572
  actionSpace() {
1562
1573
  const defaultActions = [
1563
- ...defineActionsFromInputPrimitives(this.inputPrimitives)
1574
+ ...defineActionsFromInputPrimitives(this.inputPrimitives, {
1575
+ size: ()=>this.size()
1576
+ })
1564
1577
  ];
1565
1578
  const platformActions = Object.values(createPlatformActions());
1566
1579
  const customActions = this.options?.customActions || [];
@@ -1691,15 +1704,10 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
1691
1704
  await this.inputDriver.delay(MOUSE_MOVE_EFFECT_WAIT);
1692
1705
  },
1693
1706
  dragAndDrop: async (from, to)=>{
1694
- await this.moveDisplayPointer(from, 'Mouse did not reach the drag start target');
1695
- await this.inputDriver.withMouseButton('left', async ()=>{
1696
- await this.inputDriver.delay(100);
1697
- await this.moveDisplayPointer(to, 'Mouse did not reach the drag end target', {
1698
- smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
1699
- smoothDelay: SMOOTH_MOVE_DELAY_DRAG
1700
- });
1701
- await this.inputDriver.delay(100);
1702
- });
1707
+ await this.performPointerDrag(from, to);
1708
+ },
1709
+ swipe: async (from, to, opts)=>{
1710
+ await this.performPointerDrag(from, to, opts?.duration);
1703
1711
  }
1704
1712
  },
1705
1713
  keyboard: {
@@ -2243,7 +2251,9 @@ class RDPDevice {
2243
2251
  }
2244
2252
  actionSpace() {
2245
2253
  const defaultActions = [
2246
- ...defineActionsFromInputPrimitives(this.inputPrimitives),
2254
+ ...defineActionsFromInputPrimitives(this.inputPrimitives, {
2255
+ size: ()=>this.size()
2256
+ }),
2247
2257
  defineAction({
2248
2258
  name: 'ListDisplays',
2249
2259
  description: 'List all available displays/monitors',
@@ -2327,6 +2337,23 @@ class RDPDevice {
2327
2337
  }
2328
2338
  if (options?.settleDelayMs) await sleep(options.settleDelayMs);
2329
2339
  }
2340
+ async performPointerDrag(from, to, duration) {
2341
+ await this.movePointer(Math.round(from.x), Math.round(from.y), {
2342
+ steps: device_SMOOTH_MOVE_STEPS_TAP,
2343
+ stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
2344
+ });
2345
+ await this.backend.mouseButton('left', 'down');
2346
+ try {
2347
+ await sleep(DRAG_HOLD_DURATION);
2348
+ await this.movePointer(Math.round(to.x), Math.round(to.y), {
2349
+ steps: device_SMOOTH_MOVE_STEPS_DRAG,
2350
+ stepDelayMs: void 0 === duration ? device_SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / device_SMOOTH_MOVE_STEPS_DRAG))
2351
+ });
2352
+ await sleep(DRAG_HOLD_DURATION);
2353
+ } finally{
2354
+ await this.backend.mouseButton('left', 'up');
2355
+ }
2356
+ }
2330
2357
  async performWheel(direction, amount, x, y) {
2331
2358
  let remaining = Math.abs(amount);
2332
2359
  if (0 === remaining) remaining = DEFAULT_SCROLL_STEP_AMOUNT;
@@ -2380,18 +2407,10 @@ class RDPDevice {
2380
2407
  });
2381
2408
  },
2382
2409
  dragAndDrop: async (from, to)=>{
2383
- await this.movePointer(Math.round(from.x), Math.round(from.y), {
2384
- steps: device_SMOOTH_MOVE_STEPS_TAP,
2385
- stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
2386
- });
2387
- await this.backend.mouseButton('left', 'down');
2388
- await sleep(DRAG_HOLD_DURATION);
2389
- await this.movePointer(Math.round(to.x), Math.round(to.y), {
2390
- steps: device_SMOOTH_MOVE_STEPS_DRAG,
2391
- stepDelayMs: device_SMOOTH_MOVE_DELAY_DRAG
2392
- });
2393
- await sleep(DRAG_HOLD_DURATION);
2394
- await this.backend.mouseButton('left', 'up');
2410
+ await this.performPointerDrag(from, to);
2411
+ },
2412
+ swipe: async (from, to, opts)=>{
2413
+ await this.performPointerDrag(from, to, opts?.duration);
2395
2414
  }
2396
2415
  },
2397
2416
  keyboard: {
@@ -2727,7 +2746,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
2727
2746
  }
2728
2747
  }
2729
2748
  function version() {
2730
- const currentVersion = "1.12.7";
2749
+ const currentVersion = "1.12.8-beta-20260915081046.0";
2731
2750
  console.log(`@midscene/computer v${currentVersion}`);
2732
2751
  return currentVersion;
2733
2752
  }
package/dist/lib/cli.js CHANGED
@@ -1146,6 +1146,17 @@ class ComputerDevice {
1146
1146
  moveDisplayPointer(point, context, smooth) {
1147
1147
  return this.moveGlobalPointer(this.toGlobalPoint(point), context, smooth);
1148
1148
  }
1149
+ async performPointerDrag(from, to, duration) {
1150
+ await this.moveDisplayPointer(from, 'Mouse did not reach the drag start target');
1151
+ await this.inputDriver.withMouseButton('left', async ()=>{
1152
+ await this.inputDriver.delay(100);
1153
+ await this.moveDisplayPointer(to, 'Mouse did not reach the drag end target', {
1154
+ smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
1155
+ smoothDelay: void 0 === duration ? SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / SMOOTH_MOVE_STEPS_DRAG))
1156
+ });
1157
+ await this.inputDriver.delay(100);
1158
+ });
1159
+ }
1149
1160
  async focusKeyboardTarget(element, delayMs) {
1150
1161
  const [x, y] = element.center;
1151
1162
  if ('darwin' === process.platform) await this.inputPrimitives.pointer.tap({
@@ -1238,7 +1249,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
1238
1249
  }
1239
1250
  async healthCheck(displays) {
1240
1251
  console.log('[HealthCheck] Starting health check...');
1241
- console.log("[HealthCheck] @midscene/computer v1.12.7");
1252
+ console.log("[HealthCheck] @midscene/computer v1.12.8-beta-20260915081046.0");
1242
1253
  console.log('[HealthCheck] Taking screenshot...');
1243
1254
  const screenshotTimeout = 15000;
1244
1255
  let timeoutId;
@@ -1586,7 +1597,9 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
1586
1597
  }
1587
1598
  actionSpace() {
1588
1599
  const defaultActions = [
1589
- ...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives)
1600
+ ...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives, {
1601
+ size: ()=>this.size()
1602
+ })
1590
1603
  ];
1591
1604
  const platformActions = Object.values(createPlatformActions());
1592
1605
  const customActions = this.options?.customActions || [];
@@ -1717,15 +1730,10 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
1717
1730
  await this.inputDriver.delay(MOUSE_MOVE_EFFECT_WAIT);
1718
1731
  },
1719
1732
  dragAndDrop: async (from, to)=>{
1720
- await this.moveDisplayPointer(from, 'Mouse did not reach the drag start target');
1721
- await this.inputDriver.withMouseButton('left', async ()=>{
1722
- await this.inputDriver.delay(100);
1723
- await this.moveDisplayPointer(to, 'Mouse did not reach the drag end target', {
1724
- smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
1725
- smoothDelay: SMOOTH_MOVE_DELAY_DRAG
1726
- });
1727
- await this.inputDriver.delay(100);
1728
- });
1733
+ await this.performPointerDrag(from, to);
1734
+ },
1735
+ swipe: async (from, to, opts)=>{
1736
+ await this.performPointerDrag(from, to, opts?.duration);
1729
1737
  }
1730
1738
  },
1731
1739
  keyboard: {
@@ -2227,7 +2235,9 @@ class RDPDevice {
2227
2235
  }
2228
2236
  actionSpace() {
2229
2237
  const defaultActions = [
2230
- ...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives),
2238
+ ...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives, {
2239
+ size: ()=>this.size()
2240
+ }),
2231
2241
  (0, device_namespaceObject.defineAction)({
2232
2242
  name: 'ListDisplays',
2233
2243
  description: 'List all available displays/monitors',
@@ -2311,6 +2321,23 @@ class RDPDevice {
2311
2321
  }
2312
2322
  if (options?.settleDelayMs) await (0, utils_namespaceObject.sleep)(options.settleDelayMs);
2313
2323
  }
2324
+ async performPointerDrag(from, to, duration) {
2325
+ await this.movePointer(Math.round(from.x), Math.round(from.y), {
2326
+ steps: device_SMOOTH_MOVE_STEPS_TAP,
2327
+ stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
2328
+ });
2329
+ await this.backend.mouseButton('left', 'down');
2330
+ try {
2331
+ await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
2332
+ await this.movePointer(Math.round(to.x), Math.round(to.y), {
2333
+ steps: device_SMOOTH_MOVE_STEPS_DRAG,
2334
+ stepDelayMs: void 0 === duration ? device_SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / device_SMOOTH_MOVE_STEPS_DRAG))
2335
+ });
2336
+ await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
2337
+ } finally{
2338
+ await this.backend.mouseButton('left', 'up');
2339
+ }
2340
+ }
2314
2341
  async performWheel(direction, amount, x, y) {
2315
2342
  let remaining = Math.abs(amount);
2316
2343
  if (0 === remaining) remaining = DEFAULT_SCROLL_STEP_AMOUNT;
@@ -2364,18 +2391,10 @@ class RDPDevice {
2364
2391
  });
2365
2392
  },
2366
2393
  dragAndDrop: async (from, to)=>{
2367
- await this.movePointer(Math.round(from.x), Math.round(from.y), {
2368
- steps: device_SMOOTH_MOVE_STEPS_TAP,
2369
- stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
2370
- });
2371
- await this.backend.mouseButton('left', 'down');
2372
- await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
2373
- await this.movePointer(Math.round(to.x), Math.round(to.y), {
2374
- steps: device_SMOOTH_MOVE_STEPS_DRAG,
2375
- stepDelayMs: device_SMOOTH_MOVE_DELAY_DRAG
2376
- });
2377
- await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
2378
- await this.backend.mouseButton('left', 'up');
2394
+ await this.performPointerDrag(from, to);
2395
+ },
2396
+ swipe: async (from, to, opts)=>{
2397
+ await this.performPointerDrag(from, to, opts?.duration);
2379
2398
  }
2380
2399
  },
2381
2400
  keyboard: {
@@ -2715,7 +2734,7 @@ const tools = new ComputerMidsceneTools({
2715
2734
  });
2716
2735
  (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-computer', {
2717
2736
  stripPrefix: 'computer_',
2718
- version: "1.12.7",
2737
+ version: "1.12.8-beta-20260915081046.0",
2719
2738
  extraCommands: (0, core_namespaceObject.createReportCliCommands)()
2720
2739
  }).catch((e)=>{
2721
2740
  process.exit((0, cli_namespaceObject.reportCLIError)(e));
package/dist/lib/index.js CHANGED
@@ -1172,6 +1172,17 @@ class ComputerDevice {
1172
1172
  moveDisplayPointer(point, context, smooth) {
1173
1173
  return this.moveGlobalPointer(this.toGlobalPoint(point), context, smooth);
1174
1174
  }
1175
+ async performPointerDrag(from, to, duration) {
1176
+ await this.moveDisplayPointer(from, 'Mouse did not reach the drag start target');
1177
+ await this.inputDriver.withMouseButton('left', async ()=>{
1178
+ await this.inputDriver.delay(100);
1179
+ await this.moveDisplayPointer(to, 'Mouse did not reach the drag end target', {
1180
+ smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
1181
+ smoothDelay: void 0 === duration ? SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / SMOOTH_MOVE_STEPS_DRAG))
1182
+ });
1183
+ await this.inputDriver.delay(100);
1184
+ });
1185
+ }
1175
1186
  async focusKeyboardTarget(element, delayMs) {
1176
1187
  const [x, y] = element.center;
1177
1188
  if ('darwin' === process.platform) await this.inputPrimitives.pointer.tap({
@@ -1264,7 +1275,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
1264
1275
  }
1265
1276
  async healthCheck(displays) {
1266
1277
  console.log('[HealthCheck] Starting health check...');
1267
- console.log("[HealthCheck] @midscene/computer v1.12.7");
1278
+ console.log("[HealthCheck] @midscene/computer v1.12.8-beta-20260915081046.0");
1268
1279
  console.log('[HealthCheck] Taking screenshot...');
1269
1280
  const screenshotTimeout = 15000;
1270
1281
  let timeoutId;
@@ -1612,7 +1623,9 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
1612
1623
  }
1613
1624
  actionSpace() {
1614
1625
  const defaultActions = [
1615
- ...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives)
1626
+ ...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives, {
1627
+ size: ()=>this.size()
1628
+ })
1616
1629
  ];
1617
1630
  const platformActions = Object.values(createPlatformActions());
1618
1631
  const customActions = this.options?.customActions || [];
@@ -1743,15 +1756,10 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
1743
1756
  await this.inputDriver.delay(MOUSE_MOVE_EFFECT_WAIT);
1744
1757
  },
1745
1758
  dragAndDrop: async (from, to)=>{
1746
- await this.moveDisplayPointer(from, 'Mouse did not reach the drag start target');
1747
- await this.inputDriver.withMouseButton('left', async ()=>{
1748
- await this.inputDriver.delay(100);
1749
- await this.moveDisplayPointer(to, 'Mouse did not reach the drag end target', {
1750
- smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
1751
- smoothDelay: SMOOTH_MOVE_DELAY_DRAG
1752
- });
1753
- await this.inputDriver.delay(100);
1754
- });
1759
+ await this.performPointerDrag(from, to);
1760
+ },
1761
+ swipe: async (from, to, opts)=>{
1762
+ await this.performPointerDrag(from, to, opts?.duration);
1755
1763
  }
1756
1764
  },
1757
1765
  keyboard: {
@@ -2297,7 +2305,9 @@ class RDPDevice {
2297
2305
  }
2298
2306
  actionSpace() {
2299
2307
  const defaultActions = [
2300
- ...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives),
2308
+ ...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives, {
2309
+ size: ()=>this.size()
2310
+ }),
2301
2311
  (0, device_namespaceObject.defineAction)({
2302
2312
  name: 'ListDisplays',
2303
2313
  description: 'List all available displays/monitors',
@@ -2381,6 +2391,23 @@ class RDPDevice {
2381
2391
  }
2382
2392
  if (options?.settleDelayMs) await (0, utils_namespaceObject.sleep)(options.settleDelayMs);
2383
2393
  }
2394
+ async performPointerDrag(from, to, duration) {
2395
+ await this.movePointer(Math.round(from.x), Math.round(from.y), {
2396
+ steps: device_SMOOTH_MOVE_STEPS_TAP,
2397
+ stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
2398
+ });
2399
+ await this.backend.mouseButton('left', 'down');
2400
+ try {
2401
+ await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
2402
+ await this.movePointer(Math.round(to.x), Math.round(to.y), {
2403
+ steps: device_SMOOTH_MOVE_STEPS_DRAG,
2404
+ stepDelayMs: void 0 === duration ? device_SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / device_SMOOTH_MOVE_STEPS_DRAG))
2405
+ });
2406
+ await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
2407
+ } finally{
2408
+ await this.backend.mouseButton('left', 'up');
2409
+ }
2410
+ }
2384
2411
  async performWheel(direction, amount, x, y) {
2385
2412
  let remaining = Math.abs(amount);
2386
2413
  if (0 === remaining) remaining = DEFAULT_SCROLL_STEP_AMOUNT;
@@ -2434,18 +2461,10 @@ class RDPDevice {
2434
2461
  });
2435
2462
  },
2436
2463
  dragAndDrop: async (from, to)=>{
2437
- await this.movePointer(Math.round(from.x), Math.round(from.y), {
2438
- steps: device_SMOOTH_MOVE_STEPS_TAP,
2439
- stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
2440
- });
2441
- await this.backend.mouseButton('left', 'down');
2442
- await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
2443
- await this.movePointer(Math.round(to.x), Math.round(to.y), {
2444
- steps: device_SMOOTH_MOVE_STEPS_DRAG,
2445
- stepDelayMs: device_SMOOTH_MOVE_DELAY_DRAG
2446
- });
2447
- await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
2448
- await this.backend.mouseButton('left', 'up');
2464
+ await this.performPointerDrag(from, to);
2465
+ },
2466
+ swipe: async (from, to, opts)=>{
2467
+ await this.performPointerDrag(from, to, opts?.duration);
2449
2468
  }
2450
2469
  },
2451
2470
  keyboard: {
@@ -2785,7 +2804,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
2785
2804
  }
2786
2805
  const env_namespaceObject = require("@midscene/shared/env");
2787
2806
  function version() {
2788
- const currentVersion = "1.12.7";
2807
+ const currentVersion = "1.12.8-beta-20260915081046.0";
2789
2808
  console.log(`@midscene/computer v${currentVersion}`);
2790
2809
  return currentVersion;
2791
2810
  }
@@ -89,6 +89,7 @@ export declare class ComputerDevice implements AbstractInterface {
89
89
  constructor(options?: ComputerDeviceOpt);
90
90
  private moveGlobalPointer;
91
91
  private moveDisplayPointer;
92
+ private performPointerDrag;
92
93
  private focusKeyboardTarget;
93
94
  describe(): string;
94
95
  /**
@@ -388,6 +389,7 @@ export declare class RDPDevice implements AbstractInterface {
388
389
  private edgeScrollDirection;
389
390
  private defaultScrollDistance;
390
391
  private movePointer;
392
+ private performPointerDrag;
391
393
  private performWheel;
392
394
  }
393
395
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/computer",
3
- "version": "1.12.7",
3
+ "version": "1.12.8-beta-20260915081046.0",
4
4
  "description": "Midscene.js Computer Desktop Automation",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,8 +33,8 @@
33
33
  "@computer-use/libnut": "^4.2.0",
34
34
  "clipboardy": "^4.0.0",
35
35
  "screenshot-desktop": "^1.15.3",
36
- "@midscene/shared": "1.12.7",
37
- "@midscene/core": "1.12.7"
36
+ "@midscene/shared": "1.12.8-beta-20260915081046.0",
37
+ "@midscene/core": "1.12.8-beta-20260915081046.0"
38
38
  },
39
39
  "optionalDependencies": {
40
40
  "node-mac-permissions": "2.5.0"