cortico-world-hands 0.14.0 → 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.
Files changed (2) hide show
  1. package/dist/index.js +31 -9
  2. 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);
@@ -2227,14 +2251,9 @@ ${lines.join("\n")}
2227
2251
  } catch {
2228
2252
  first = raw.slice(0, 120);
2229
2253
  }
2230
- const second = await this.hands.qqOpenReply(text, to || void 0);
2231
- try {
2232
- const r2 = JSON.parse(second);
2233
- if (r2.ok) return `\u6253\u5F00 QQ \u56DE\u4E86${to ? "\u7ED9\u300C" + to + "\u300D" : ""}\uFF1A${text}\uFF08\u5FEB\u901F\u56DE\u590D\u4E0D\u53EF\u7528\uFF0C\u5DF2\u5207\u56DE\u6765\uFF09`;
2234
- return failed(`\u5FEB\u901F\u56DE\u590D\u4E0D\u884C\uFF08${first}\uFF09\uFF0C\u6253\u5F00 QQ \u4E5F\u6CA1\u6210\uFF08${r2.error || "\u539F\u56E0\u4E0D\u660E"}\uFF09`);
2235
- } catch {
2236
- return failed(`\u5FEB\u901F\u56DE\u590D\u4E0D\u884C\uFF08${first}\uFF09\uFF0C\u6253\u5F00 QQ \u4E5F\u6CA1\u6210`);
2237
- }
2254
+ return failed(
2255
+ `\u901A\u77E5\u91CC\u6CA1\u6709\u5FEB\u901F\u56DE\u590D\u5165\u53E3\uFF08${first}\uFF09\u3002\u8FD9\u6761\u522B\u7528\u811A\u672C\u56DE\uFF0C\u7528\u4F60\u81EA\u5DF1\u7684\u624B\uFF1Apet_open_app \u6253\u5F00 QQ \u2192 hand_look \u770B\u4E00\u773C \u2192 hand_tap \u70B9\u5BF9\u8BDD \u2192 hand_type \u6253\u5B57 \u2192 hand_tap \u70B9\u300C\u53D1\u9001\u300D\u2192 \u5207\u56DE\u4E3B\u4EBA\u539F\u6765\u7684\u5E94\u7528\u3002\u4E00\u6B21\u53EA\u56DE\u4E00\u6761\uFF0C\u56DE\u5B8C\u5C31\u9000\u51FA\u6765\u3002`
2256
+ );
2238
2257
  }
2239
2258
  /** 解锁:成功/没锁/失败都给人话。 */
2240
2259
  async screenUnlock() {
@@ -2461,9 +2480,12 @@ ${lines || "\uFF08\u90FD\u5212\u6389\u4E86\uFF09"}`;
2461
2480
  ${list}`);
2462
2481
  }
2463
2482
  const only = hits2[0];
2483
+ const beforeUi = await this.hands.ui().catch(() => null);
2484
+ const before = beforeUi && beforeUi.ok ? beforeUi.pkg : "";
2464
2485
  const receipt3 = await this.hands.tap(only.center.x, only.center.y);
2465
2486
  this.note(receipt3);
2466
- return `${receipt3.text}\uFF08\u70B9\u7684\u662F\u300C${only.text}\u300D\uFF09`;
2487
+ const after = await this.verifyChange(before);
2488
+ return `${receipt3.text}\uFF08\u70B9\u7684\u662F\u300C${only.text}\u300D\uFF09${after}`;
2467
2489
  }
2468
2490
  const hit = hits2[nth];
2469
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.14.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",