cortico-world-hands 0.20.11 → 0.20.13
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/index.js +11 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2673,7 +2673,7 @@ ${text.slice(0, 2200)}`;
|
|
|
2673
2673
|
if (f) {
|
|
2674
2674
|
return {
|
|
2675
2675
|
text: `\u300C${hit.text}\u300D\u5B57\u592A\u5C0F\uFF08\u9AD8 ${h}px\uFF09\uFF0C\u6211\u628A\u8FD9\u5757\u653E\u5927\u4E86`,
|
|
2676
|
-
blobs: [{ bytes: f.bytes, mime: "image/jpeg", name: "zoom.jpg", fallbackText: "\uFF08\u8FD9\u4E00\u5757\u7684\u653E\u5927\u56FE\uFF09" }]
|
|
2676
|
+
blobs: this.looksLikeImage(f.bytes) ? [{ bytes: f.bytes, mime: "image/jpeg", name: "zoom.jpg", fallbackText: "\uFF08\u8FD9\u4E00\u5757\u7684\u653E\u5927\u56FE\uFF09" }] : []
|
|
2677
2677
|
};
|
|
2678
2678
|
}
|
|
2679
2679
|
}
|
|
@@ -2687,7 +2687,7 @@ ${text.slice(0, 2200)}`;
|
|
|
2687
2687
|
if (!f) return failed("\u8FD9\u4E00\u5757\u6CA1\u622A\u5230\uFF08\u5750\u6807\u53EF\u80FD\u8D85\u51FA\u5C4F\u5E55\uFF09");
|
|
2688
2688
|
return {
|
|
2689
2689
|
text: `\u653E\u5927\u770B @(${x},${y}) ${w}\xD7${h}`,
|
|
2690
|
-
blobs: [{ bytes: f.bytes, mime: "image/jpeg", name: "zoom.jpg", fallbackText: "\uFF08\u8FD9\u662F\u4ED6\u6307\u5B9A\u90A3\u4E00\u5757\u653E\u5927\u540E\u7684\u622A\u56FE\uFF09" }]
|
|
2690
|
+
blobs: this.looksLikeImage(f.bytes) ? [{ bytes: f.bytes, mime: "image/jpeg", name: "zoom.jpg", fallbackText: "\uFF08\u8FD9\u662F\u4ED6\u6307\u5B9A\u90A3\u4E00\u5757\u653E\u5927\u540E\u7684\u622A\u56FE\uFF09" }] : []
|
|
2691
2691
|
};
|
|
2692
2692
|
}
|
|
2693
2693
|
case "hand_see":
|
|
@@ -2880,10 +2880,17 @@ ${text.slice(0, 2200)}`;
|
|
|
2880
2880
|
async see() {
|
|
2881
2881
|
return await this.hands.look("text").then((r) => r.text);
|
|
2882
2882
|
}
|
|
2883
|
+
/** 只认真正的 JPEG/PNG,防止坏图进上下文把整轮 400 掉。 */
|
|
2884
|
+
looksLikeImage(bytes) {
|
|
2885
|
+
if (!bytes || bytes.length < 2e3) return false;
|
|
2886
|
+
const jpg = bytes[0] === 255 && bytes[1] === 216;
|
|
2887
|
+
const png = bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71;
|
|
2888
|
+
return jpg || png;
|
|
2889
|
+
}
|
|
2883
2890
|
async look(args) {
|
|
2884
2891
|
const detail = args.detail === "screen" || args.detail === "text" ? args.detail : "both";
|
|
2885
2892
|
const report = await this.hands.look(detail);
|
|
2886
|
-
const blobs = report.blob ? [report.blob] : [];
|
|
2893
|
+
const blobs = report.blob && this.looksLikeImage(report.blob.bytes) ? [report.blob] : [];
|
|
2887
2894
|
return { text: report.text, ...blobs.length ? { blobs } : {} };
|
|
2888
2895
|
}
|
|
2889
2896
|
/** 给文字就先在屏幕上找,找到唯一一处才点;给坐标就直接点。 */
|
|
@@ -3237,7 +3244,7 @@ ${lines || "\uFF08\u90FD\u5212\u6389\u4E86\uFF09"}`;
|
|
|
3237
3244
|
${list}`);
|
|
3238
3245
|
}
|
|
3239
3246
|
const only = hits2[0];
|
|
3240
|
-
const beforeUi = await this.hands.
|
|
3247
|
+
const beforeUi = await this.hands.uiSnapshot().catch(() => null);
|
|
3241
3248
|
const before = beforeUi && beforeUi.ok ? beforeUi.pkg : "";
|
|
3242
3249
|
const receipt3 = await this.hands.tap(only.center.x, only.center.y);
|
|
3243
3250
|
this.note(receipt3);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-hands",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.13",
|
|
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",
|