@midscene/android 1.7.7 → 1.7.10-beta-20260507030203.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
@@ -1618,17 +1618,19 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
1618
1618
  this.connectingAdb = null;
1619
1619
  this.yadbPushed = false;
1620
1620
  }
1621
- async getTimestamp() {
1621
+ async getDeviceLocalTimeString(format = 'YYYY-MM-DD HH:mm:ss') {
1622
1622
  const adb = await this.getAdb();
1623
1623
  try {
1624
- const stdout = await adb.shell('date +%s%3N');
1625
- const timestamp = Number.parseInt(stdout.trim(), 10);
1626
- if (Number.isNaN(timestamp)) throw new Error(`Invalid timestamp format: ${stdout}`);
1627
- debugDevice(`Got device time: ${timestamp}`);
1628
- return timestamp;
1624
+ const stdout = await adb.shell('date +%Y-%m-%dT%H:%M:%S');
1625
+ const match = stdout.trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/);
1626
+ if (!match) throw new Error(`Invalid device time format: ${stdout}`);
1627
+ const [, year, month, day, hours, minutes, seconds] = match;
1628
+ const timeString = format.replace('YYYY', year).replace('MM', month).replace('DD', day).replace('HH', hours).replace('mm', minutes).replace('ss', seconds);
1629
+ debugDevice(`Got device local time: ${timeString}`);
1630
+ return `${timeString} (${format})`;
1629
1631
  } catch (error) {
1630
- debugDevice(`Failed to get device time: ${error}`);
1631
- throw new Error(`Failed to get device time: ${error}`);
1632
+ debugDevice(`Failed to get device local time: ${error}`);
1633
+ throw new Error(`Failed to get device local time: ${error}`);
1632
1634
  }
1633
1635
  }
1634
1636
  async back() {
@@ -2016,7 +2018,7 @@ class AndroidMidsceneTools extends BaseMidsceneTools {
2016
2018
  const tools = new AndroidMidsceneTools();
2017
2019
  runToolsCLI(tools, 'midscene-android', {
2018
2020
  stripPrefix: 'android_',
2019
- version: "1.7.7",
2021
+ version: "1.7.10-beta-20260507030203.0",
2020
2022
  extraCommands: createReportCliCommands()
2021
2023
  }).catch((e)=>{
2022
2024
  process.exit(reportCLIError(e));
package/dist/es/index.mjs CHANGED
@@ -1521,17 +1521,19 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
1521
1521
  this.connectingAdb = null;
1522
1522
  this.yadbPushed = false;
1523
1523
  }
1524
- async getTimestamp() {
1524
+ async getDeviceLocalTimeString(format = 'YYYY-MM-DD HH:mm:ss') {
1525
1525
  const adb = await this.getAdb();
1526
1526
  try {
1527
- const stdout = await adb.shell('date +%s%3N');
1528
- const timestamp = Number.parseInt(stdout.trim(), 10);
1529
- if (Number.isNaN(timestamp)) throw new Error(`Invalid timestamp format: ${stdout}`);
1530
- debugDevice(`Got device time: ${timestamp}`);
1531
- return timestamp;
1527
+ const stdout = await adb.shell('date +%Y-%m-%dT%H:%M:%S');
1528
+ const match = stdout.trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/);
1529
+ if (!match) throw new Error(`Invalid device time format: ${stdout}`);
1530
+ const [, year, month, day, hours, minutes, seconds] = match;
1531
+ const timeString = format.replace('YYYY', year).replace('MM', month).replace('DD', day).replace('HH', hours).replace('mm', minutes).replace('ss', seconds);
1532
+ debugDevice(`Got device local time: ${timeString}`);
1533
+ return `${timeString} (${format})`;
1532
1534
  } catch (error) {
1533
- debugDevice(`Failed to get device time: ${error}`);
1534
- throw new Error(`Failed to get device time: ${error}`);
1535
+ debugDevice(`Failed to get device local time: ${error}`);
1536
+ throw new Error(`Failed to get device local time: ${error}`);
1535
1537
  }
1536
1538
  }
1537
1539
  async back() {
@@ -1618,17 +1618,19 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
1618
1618
  this.connectingAdb = null;
1619
1619
  this.yadbPushed = false;
1620
1620
  }
1621
- async getTimestamp() {
1621
+ async getDeviceLocalTimeString(format = 'YYYY-MM-DD HH:mm:ss') {
1622
1622
  const adb = await this.getAdb();
1623
1623
  try {
1624
- const stdout = await adb.shell('date +%s%3N');
1625
- const timestamp = Number.parseInt(stdout.trim(), 10);
1626
- if (Number.isNaN(timestamp)) throw new Error(`Invalid timestamp format: ${stdout}`);
1627
- debugDevice(`Got device time: ${timestamp}`);
1628
- return timestamp;
1624
+ const stdout = await adb.shell('date +%Y-%m-%dT%H:%M:%S');
1625
+ const match = stdout.trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/);
1626
+ if (!match) throw new Error(`Invalid device time format: ${stdout}`);
1627
+ const [, year, month, day, hours, minutes, seconds] = match;
1628
+ const timeString = format.replace('YYYY', year).replace('MM', month).replace('DD', day).replace('HH', hours).replace('mm', minutes).replace('ss', seconds);
1629
+ debugDevice(`Got device local time: ${timeString}`);
1630
+ return `${timeString} (${format})`;
1629
1631
  } catch (error) {
1630
- debugDevice(`Failed to get device time: ${error}`);
1631
- throw new Error(`Failed to get device time: ${error}`);
1632
+ debugDevice(`Failed to get device local time: ${error}`);
1633
+ throw new Error(`Failed to get device local time: ${error}`);
1632
1634
  }
1633
1635
  }
1634
1636
  async back() {
@@ -2020,7 +2022,7 @@ class AndroidMCPServer extends BaseMCPServer {
2020
2022
  constructor(toolsManager){
2021
2023
  super({
2022
2024
  name: '@midscene/android-mcp',
2023
- version: "1.7.7",
2025
+ version: "1.7.10-beta-20260507030203.0",
2024
2026
  description: 'Control the Android device using natural language commands'
2025
2027
  }, toolsManager);
2026
2028
  }
package/dist/lib/cli.js CHANGED
@@ -1633,17 +1633,19 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
1633
1633
  this.connectingAdb = null;
1634
1634
  this.yadbPushed = false;
1635
1635
  }
1636
- async getTimestamp() {
1636
+ async getDeviceLocalTimeString(format = 'YYYY-MM-DD HH:mm:ss') {
1637
1637
  const adb = await this.getAdb();
1638
1638
  try {
1639
- const stdout = await adb.shell('date +%s%3N');
1640
- const timestamp = Number.parseInt(stdout.trim(), 10);
1641
- if (Number.isNaN(timestamp)) throw new Error(`Invalid timestamp format: ${stdout}`);
1642
- debugDevice(`Got device time: ${timestamp}`);
1643
- return timestamp;
1639
+ const stdout = await adb.shell('date +%Y-%m-%dT%H:%M:%S');
1640
+ const match = stdout.trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/);
1641
+ if (!match) throw new Error(`Invalid device time format: ${stdout}`);
1642
+ const [, year, month, day, hours, minutes, seconds] = match;
1643
+ const timeString = format.replace('YYYY', year).replace('MM', month).replace('DD', day).replace('HH', hours).replace('mm', minutes).replace('ss', seconds);
1644
+ debugDevice(`Got device local time: ${timeString}`);
1645
+ return `${timeString} (${format})`;
1644
1646
  } catch (error) {
1645
- debugDevice(`Failed to get device time: ${error}`);
1646
- throw new Error(`Failed to get device time: ${error}`);
1647
+ debugDevice(`Failed to get device local time: ${error}`);
1648
+ throw new Error(`Failed to get device local time: ${error}`);
1647
1649
  }
1648
1650
  }
1649
1651
  async back() {
@@ -2031,7 +2033,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2031
2033
  const tools = new AndroidMidsceneTools();
2032
2034
  (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-android', {
2033
2035
  stripPrefix: 'android_',
2034
- version: "1.7.7",
2036
+ version: "1.7.10-beta-20260507030203.0",
2035
2037
  extraCommands: (0, core_namespaceObject.createReportCliCommands)()
2036
2038
  }).catch((e)=>{
2037
2039
  process.exit((0, cli_namespaceObject.reportCLIError)(e));
package/dist/lib/index.js CHANGED
@@ -1555,17 +1555,19 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
1555
1555
  this.connectingAdb = null;
1556
1556
  this.yadbPushed = false;
1557
1557
  }
1558
- async getTimestamp() {
1558
+ async getDeviceLocalTimeString(format = 'YYYY-MM-DD HH:mm:ss') {
1559
1559
  const adb = await this.getAdb();
1560
1560
  try {
1561
- const stdout = await adb.shell('date +%s%3N');
1562
- const timestamp = Number.parseInt(stdout.trim(), 10);
1563
- if (Number.isNaN(timestamp)) throw new Error(`Invalid timestamp format: ${stdout}`);
1564
- debugDevice(`Got device time: ${timestamp}`);
1565
- return timestamp;
1561
+ const stdout = await adb.shell('date +%Y-%m-%dT%H:%M:%S');
1562
+ const match = stdout.trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/);
1563
+ if (!match) throw new Error(`Invalid device time format: ${stdout}`);
1564
+ const [, year, month, day, hours, minutes, seconds] = match;
1565
+ const timeString = format.replace('YYYY', year).replace('MM', month).replace('DD', day).replace('HH', hours).replace('mm', minutes).replace('ss', seconds);
1566
+ debugDevice(`Got device local time: ${timeString}`);
1567
+ return `${timeString} (${format})`;
1566
1568
  } catch (error) {
1567
- debugDevice(`Failed to get device time: ${error}`);
1568
- throw new Error(`Failed to get device time: ${error}`);
1569
+ debugDevice(`Failed to get device local time: ${error}`);
1570
+ throw new Error(`Failed to get device local time: ${error}`);
1569
1571
  }
1570
1572
  }
1571
1573
  async back() {
@@ -1648,17 +1648,19 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
1648
1648
  this.connectingAdb = null;
1649
1649
  this.yadbPushed = false;
1650
1650
  }
1651
- async getTimestamp() {
1651
+ async getDeviceLocalTimeString(format = 'YYYY-MM-DD HH:mm:ss') {
1652
1652
  const adb = await this.getAdb();
1653
1653
  try {
1654
- const stdout = await adb.shell('date +%s%3N');
1655
- const timestamp = Number.parseInt(stdout.trim(), 10);
1656
- if (Number.isNaN(timestamp)) throw new Error(`Invalid timestamp format: ${stdout}`);
1657
- debugDevice(`Got device time: ${timestamp}`);
1658
- return timestamp;
1654
+ const stdout = await adb.shell('date +%Y-%m-%dT%H:%M:%S');
1655
+ const match = stdout.trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/);
1656
+ if (!match) throw new Error(`Invalid device time format: ${stdout}`);
1657
+ const [, year, month, day, hours, minutes, seconds] = match;
1658
+ const timeString = format.replace('YYYY', year).replace('MM', month).replace('DD', day).replace('HH', hours).replace('mm', minutes).replace('ss', seconds);
1659
+ debugDevice(`Got device local time: ${timeString}`);
1660
+ return `${timeString} (${format})`;
1659
1661
  } catch (error) {
1660
- debugDevice(`Failed to get device time: ${error}`);
1661
- throw new Error(`Failed to get device time: ${error}`);
1662
+ debugDevice(`Failed to get device local time: ${error}`);
1663
+ throw new Error(`Failed to get device local time: ${error}`);
1662
1664
  }
1663
1665
  }
1664
1666
  async back() {
@@ -2051,7 +2053,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2051
2053
  constructor(toolsManager){
2052
2054
  super({
2053
2055
  name: '@midscene/android-mcp',
2054
- version: "1.7.7",
2056
+ version: "1.7.10-beta-20260507030203.0",
2055
2057
  description: 'Control the Android device using natural language commands'
2056
2058
  }, toolsManager);
2057
2059
  }
@@ -211,11 +211,11 @@ export declare class AndroidDevice implements AbstractInterface {
211
211
  scroll(deltaX: number, deltaY: number, duration?: number, warnOnClamp?: boolean, direction?: ScrollDirection): Promise<void>;
212
212
  destroy(): Promise<void>;
213
213
  /**
214
- * Get the current time from the Android device.
215
- * Returns the device's current timestamp in milliseconds.
216
- * This is useful when the system time and device time are not synchronized.
214
+ * Get the current device-local time as a formatted string.
215
+ * This avoids formatting an Android epoch timestamp in the host machine's
216
+ * timezone, which can disagree with the device status bar.
217
217
  */
218
- getTimestamp(): Promise<number>;
218
+ getDeviceLocalTimeString(format?: string): Promise<string>;
219
219
  back(): Promise<void>;
220
220
  home(): Promise<void>;
221
221
  recentApps(): Promise<void>;
@@ -203,11 +203,11 @@ declare class AndroidDevice implements AbstractInterface {
203
203
  scroll(deltaX: number, deltaY: number, duration?: number, warnOnClamp?: boolean, direction?: ScrollDirection): Promise<void>;
204
204
  destroy(): Promise<void>;
205
205
  /**
206
- * Get the current time from the Android device.
207
- * Returns the device's current timestamp in milliseconds.
208
- * This is useful when the system time and device time are not synchronized.
206
+ * Get the current device-local time as a formatted string.
207
+ * This avoids formatting an Android epoch timestamp in the host machine's
208
+ * timezone, which can disagree with the device status bar.
209
209
  */
210
- getTimestamp(): Promise<number>;
210
+ getDeviceLocalTimeString(format?: string): Promise<string>;
211
211
  back(): Promise<void>;
212
212
  home(): Promise<void>;
213
213
  recentApps(): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/android",
3
- "version": "1.7.7",
3
+ "version": "1.7.10-beta-20260507030203.0",
4
4
  "description": "Android automation library for Midscene",
5
5
  "keywords": [
6
6
  "Android UI automation",
@@ -41,8 +41,8 @@
41
41
  "@yume-chan/stream-extra": "2.1.0",
42
42
  "appium-adb": "12.12.1",
43
43
  "sharp": "^0.34.3",
44
- "@midscene/shared": "1.7.7",
45
- "@midscene/core": "1.7.7"
44
+ "@midscene/core": "1.7.10-beta-20260507030203.0",
45
+ "@midscene/shared": "1.7.10-beta-20260507030203.0"
46
46
  },
47
47
  "optionalDependencies": {
48
48
  "@ffmpeg-installer/ffmpeg": "^1.1.0"
@@ -56,7 +56,7 @@
56
56
  "undici": "^6.0.0",
57
57
  "vitest": "3.0.5",
58
58
  "zod": "^3.25.1",
59
- "@midscene/playground": "1.7.7"
59
+ "@midscene/playground": "1.7.10-beta-20260507030203.0"
60
60
  },
61
61
  "license": "MIT",
62
62
  "scripts": {