cortico-world-hands 0.14.1 → 0.15.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/index.js +28 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1369,6 +1369,12 @@ ${lines.join("\n")}`);
|
|
|
1369
1369
|
|
|
1370
1370
|
// src/tools.ts
|
|
1371
1371
|
var HANDS_TOOL_DECLS = [
|
|
1372
|
+
{
|
|
1373
|
+
name: "hand_see",
|
|
1374
|
+
tags: ["read"],
|
|
1375
|
+
description: "\u53EA\u770B\u6587\u5B57\uFF1A\u5F53\u524D\u524D\u53F0\u662F\u8C01\u3001\u5C4F\u5E55\u4E0A\u6709\u54EA\u4E9B\u80FD\u70B9\u7684\u5B57\u3001\u5404\u81EA\u7684\u771F\u5B9E\u5750\u6807\u3002\u6BD4 hand_look \u5FEB\uFF08\u4E0D\u622A\u56FE\uFF09\uFF0C\u60F3\u5FEB\u901F\u770B\u6E05\u5C4F\u5E55\u65F6\u7528\u5B83\u3002",
|
|
1376
|
+
parameters: { type: "object", properties: {} }
|
|
1377
|
+
},
|
|
1372
1378
|
{
|
|
1373
1379
|
name: "hand_look",
|
|
1374
1380
|
tags: ["read", "snapshot"],
|
|
@@ -2034,6 +2040,8 @@ ${lines.join("\n")}
|
|
|
2034
2040
|
await this.guard();
|
|
2035
2041
|
ctx.signal?.throwIfAborted();
|
|
2036
2042
|
switch (name) {
|
|
2043
|
+
case "hand_see":
|
|
2044
|
+
return await this.see();
|
|
2037
2045
|
case "hand_look":
|
|
2038
2046
|
return await this.look(args);
|
|
2039
2047
|
case "hand_tap":
|
|
@@ -2123,6 +2131,22 @@ ${lines.join("\n")}
|
|
|
2123
2131
|
this.recent.unshift(`${stamp} ${receipt.text}`);
|
|
2124
2132
|
if (this.recent.length > 6) this.recent.length = 6;
|
|
2125
2133
|
}
|
|
2134
|
+
/** 点完等半秒,看前台有没有变;变了说一声,没变提醒她可能点歪了。 */
|
|
2135
|
+
async verifyChange(beforePkg) {
|
|
2136
|
+
try {
|
|
2137
|
+
await new Promise((r) => setTimeout(r, 450));
|
|
2138
|
+
const ui = await this.hands.ui();
|
|
2139
|
+
const now = ui.ok ? ui.pkg : "";
|
|
2140
|
+
if (beforePkg && now && beforePkg !== now) return `\uFF0C\u754C\u9762\u5DF2\u7ECF\u5207\u5230 ${now}`;
|
|
2141
|
+
return "\uFF08\u5C4F\u5E55\u770B\u8D77\u6765\u6CA1\u53D8\uFF1B\u5982\u679C\u8BE5\u6709\u53CD\u5E94\uFF0C\u5148 hand_see \u770B\u4E00\u773C\u518D\u70B9\uFF09";
|
|
2142
|
+
} catch {
|
|
2143
|
+
return "";
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
/** 纯文字版看屏:快,不带图。 */
|
|
2147
|
+
async see() {
|
|
2148
|
+
return await this.hands.look("text").then((r) => r.text);
|
|
2149
|
+
}
|
|
2126
2150
|
async look(args) {
|
|
2127
2151
|
const detail = args.detail === "screen" || args.detail === "text" ? args.detail : "both";
|
|
2128
2152
|
const report = await this.hands.look(detail);
|
|
@@ -2456,9 +2480,12 @@ ${lines || "\uFF08\u90FD\u5212\u6389\u4E86\uFF09"}`;
|
|
|
2456
2480
|
${list}`);
|
|
2457
2481
|
}
|
|
2458
2482
|
const only = hits2[0];
|
|
2483
|
+
const beforeUi = await this.hands.ui().catch(() => null);
|
|
2484
|
+
const before = beforeUi && beforeUi.ok ? beforeUi.pkg : "";
|
|
2459
2485
|
const receipt3 = await this.hands.tap(only.center.x, only.center.y);
|
|
2460
2486
|
this.note(receipt3);
|
|
2461
|
-
|
|
2487
|
+
const after = await this.verifyChange(before);
|
|
2488
|
+
return `${receipt3.text}\uFF08\u70B9\u7684\u662F\u300C${only.text}\u300D\uFF09${after}`;
|
|
2462
2489
|
}
|
|
2463
2490
|
const hit = hits2[nth];
|
|
2464
2491
|
if (!hit) return failed(`\u300C${text}\u300D\u53EA\u6709 ${hits2.length} \u5904\uFF0C\u6CA1\u6709\u7B2C ${nth} \u4E2A\u3002`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-hands",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
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",
|