cortico-world-hands 0.20.39 → 0.20.40

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.
Files changed (2) hide show
  1. package/dist/index.js +15 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1654,7 +1654,18 @@ var Hands = class {
1654
1654
  throw new HandError(`\u773C\u775B\u6CA1\u5F00\uFF1A${health?.error ?? "\u65E0\u969C\u788D\u670D\u52A1\u6CA1\u5728\u8DD1\uFF08\u7CFB\u7EDF\u8BBE\u7F6E \u2192 \u65E0\u969C\u788D\uFF09"}\u3002`);
1655
1655
  }
1656
1656
  const state = await this.eyes.state(this.port(cfg.sensePort));
1657
- const where = state?.appLabel && state.appPkg ? `${state.appLabel}\uFF08${state.appPkg}\uFF09` : state?.appPkg || "\u672A\u77E5\u5E94\u7528";
1657
+ let uiPkg = "";
1658
+ let uiItems = [];
1659
+ try {
1660
+ const u = await this.eyes.ui();
1661
+ if (u && u.ok) {
1662
+ uiPkg = (u.pkg || "").trim();
1663
+ uiItems = u.items || [];
1664
+ }
1665
+ } catch {
1666
+ }
1667
+ const pkgNow = (state?.appPkg || "").trim() || uiPkg;
1668
+ const where = state?.appLabel && state.appPkg ? `${state.appLabel}\uFF08${state.appPkg}\uFF09` : pkgNow || "\u8FD9\u4E2A\u754C\u9762\uFF08\u8BFB\u4E0D\u5230\u5E94\u7528\u540D\uFF09";
1658
1669
  const parts = [`\u73B0\u5728\u524D\u53F0\u662F ${where}\u3002`];
1659
1670
  if (state) {
1660
1671
  parts.push(`${state.screenOn ? "\u5C4F\u5E55\u4EAE\u7740" : "\u5C4F\u5E55\u9ED1\u7740"}\u3001${state.locked ? "\u9501\u7740" : "\u6CA1\u9501"}${typeof state.battery === "number" ? `\u3001\u7535\u91CF ${state.battery}%` : ""}\u3002`);
@@ -1674,9 +1685,9 @@ var Hands = class {
1674
1685
  }
1675
1686
  }
1676
1687
  if (detail !== "screen") {
1677
- const ui = await this.eyes.ui();
1678
- if (ui.ok && ui.items.length) {
1679
- const lines = ui.items.slice(0, 40).map((item) => {
1688
+ const items = uiItems;
1689
+ if (items.length) {
1690
+ const lines = items.slice(0, 40).map((item) => {
1680
1691
  const spot = item.center ? `@(${item.center.x},${item.center.y})` : "";
1681
1692
  return `- \u300C${item.text}\u300D${spot}`;
1682
1693
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.20.39",
3
+ "version": "0.20.40",
4
4
  "type": "module",
5
5
  "description": "Cortico World: hands for the desktop pet — looks at the phone screen, then taps, swipes, pinches, drags, types and presses keys through whatever actuator the device actually has",
6
6
  "license": "MIT",