cortico-world-hands 0.8.0 → 0.9.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 +54 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1063,6 +1063,22 @@ var Hands = class {
|
|
|
1063
1063
|
}
|
|
1064
1064
|
return { ok: res.status === 200 && body.ok !== false, detail: flat(body.detail || body.error || "", 80) };
|
|
1065
1065
|
}
|
|
1066
|
+
/** 唤醒屏幕(用 Shizuku 的 input keyevent 224)。 */
|
|
1067
|
+
async wakeScreen() {
|
|
1068
|
+
const cfg = this.cfg();
|
|
1069
|
+
const credential = this.readToken();
|
|
1070
|
+
const t = credential ? `t=${encodeURIComponent(credential)}` : "";
|
|
1071
|
+
const res = await post(this.port(cfg.handPort), `/hand/wake?${t}`, "", 15e3);
|
|
1072
|
+
return res.body.toString("utf8");
|
|
1073
|
+
}
|
|
1074
|
+
/** 息屏(可选,用来自己测唤醒)。 */
|
|
1075
|
+
async sleepScreen() {
|
|
1076
|
+
const cfg = this.cfg();
|
|
1077
|
+
const credential = this.readToken();
|
|
1078
|
+
const t = credential ? `t=${encodeURIComponent(credential)}` : "";
|
|
1079
|
+
const res = await post(this.port(cfg.handPort), `/hand/sleep?${t}`, "", 15e3);
|
|
1080
|
+
return res.body.toString("utf8");
|
|
1081
|
+
}
|
|
1066
1082
|
/** 画板:新开一张。 */
|
|
1067
1083
|
async canvasNew(w = 512, h = 512, bg = "transparent") {
|
|
1068
1084
|
const cfg = this.cfg();
|
|
@@ -1442,6 +1458,18 @@ var HANDS_TOOL_DECLS = [
|
|
|
1442
1458
|
description: "\u770B\u624B\u81EA\u5DF1\u7684\u72B6\u6001\uFF1A\u8D70\u54EA\u6761\u901A\u9053\u3001\u901A\u4E0D\u901A\u3001\u8FD9\u4E00\u5206\u949F\u52A8\u4E86\u51E0\u4E2A\u52A8\u4F5C\u3001\u521A\u624D\u90A3\u4E00\u4E0B\u6210\u4E86\u6CA1\u6709\u3002\u5BF9\u65B9\u95EE\u300C\u624B\u80FD\u7528\u5417\u300D\u300C\u4F60\u521A\u624D\u70B9\u4E86\u4EC0\u4E48\u300D\u65F6\u7528\u5B83\u3002",
|
|
1443
1459
|
parameters: { type: "object", properties: {}, required: [] }
|
|
1444
1460
|
},
|
|
1461
|
+
{
|
|
1462
|
+
name: "screen_wake",
|
|
1463
|
+
tags: ["act"],
|
|
1464
|
+
description: "\u70B9\u4EAE\u5C4F\u5E55\uFF1A\u5C4F\u5E55\u9ED1\u7740\u4E5F\u80FD\u5524\u9192\uFF08\u7528 Shizuku \u7684\u7CFB\u7EDF\u6309\u952E\uFF0Croot/Shizuku \u4EFB\u4E00\u901A\u9053\uFF09\u3002\u4E3B\u4EBA\u8BF4\u300C\u4EAE\u4E00\u4E0B\u5C4F\u300D\u300C\u5E2E\u6211\u628A\u5C4F\u5E55\u70B9\u4EAE\u300D\u65F6\u7528\u5B83\uFF1B\u5931\u8D25\u4F1A\u8FD4\u56DE\u539F\u56E0\u3002",
|
|
1465
|
+
parameters: { type: "object", properties: {} }
|
|
1466
|
+
},
|
|
1467
|
+
{
|
|
1468
|
+
name: "screen_sleep",
|
|
1469
|
+
tags: ["act"],
|
|
1470
|
+
description: "\u628A\u5C4F\u5E55\u5173\u6389\uFF08\u606F\u5C4F\uFF09\u3002\u4E3B\u4EBA\u8BF4\u8981\u5173\u5C4F\u3001\u6216\u8005\u4F60\u60F3\u81EA\u5DF1\u6D4B\u4E00\u4E0B\u5524\u9192\u662F\u5426\u7BA1\u7528\u65F6\u7528\u5B83\u3002",
|
|
1471
|
+
parameters: { type: "object", properties: {} }
|
|
1472
|
+
},
|
|
1445
1473
|
{
|
|
1446
1474
|
name: "canvas_new",
|
|
1447
1475
|
tags: ["act"],
|
|
@@ -1901,6 +1929,10 @@ ${lines.join("\n")}
|
|
|
1901
1929
|
return await this.diaryRead(args);
|
|
1902
1930
|
case "skin_install":
|
|
1903
1931
|
return await this.skinInstall(args);
|
|
1932
|
+
case "screen_wake":
|
|
1933
|
+
return await this.screenWake();
|
|
1934
|
+
case "screen_sleep":
|
|
1935
|
+
return await this.screenSleep();
|
|
1904
1936
|
case "canvas_new":
|
|
1905
1937
|
return await this.canvasNew(args);
|
|
1906
1938
|
case "canvas_stroke":
|
|
@@ -2025,6 +2057,28 @@ ${lines.join("\n")}
|
|
|
2025
2057
|
}
|
|
2026
2058
|
return `\u8BB0\u7262\u4E86\uFF1A\u300C${key}\u300D\u2192 ${value}${cloud}`;
|
|
2027
2059
|
}
|
|
2060
|
+
/** 点亮屏幕:成功说清楚,失败给原因。 */
|
|
2061
|
+
async screenWake() {
|
|
2062
|
+
const raw = await this.hands.wakeScreen();
|
|
2063
|
+
try {
|
|
2064
|
+
const r = JSON.parse(raw);
|
|
2065
|
+
if (r.ok) {
|
|
2066
|
+
return r.litBefore ? "\u5C4F\u5E55\u672C\u6765\u5C31\u662F\u4EAE\u7684\u3002" : "\u5C4F\u5E55\u70B9\u4EAE\u4E86\u3002";
|
|
2067
|
+
}
|
|
2068
|
+
return failed(r.error || "\u6CA1\u70B9\u4EAE\uFF0C\u539F\u56E0\u4E0D\u660E");
|
|
2069
|
+
} catch {
|
|
2070
|
+
return failed(raw.slice(0, 120));
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
async screenSleep() {
|
|
2074
|
+
const raw = await this.hands.sleepScreen();
|
|
2075
|
+
try {
|
|
2076
|
+
const r = JSON.parse(raw);
|
|
2077
|
+
return r.ok ? "\u5C4F\u5E55\u5173\u6389\u4E86\u3002" : failed(r.error || "\u6CA1\u5173\u6389\uFF0C\u539F\u56E0\u4E0D\u660E");
|
|
2078
|
+
} catch {
|
|
2079
|
+
return failed(raw.slice(0, 120));
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2028
2082
|
async canvasNew(args) {
|
|
2029
2083
|
const w = args.w === void 0 ? 512 : Math.max(64, Math.min(2048, Math.round(Number(args.w))));
|
|
2030
2084
|
const h = args.h === void 0 ? 512 : Math.max(64, Math.min(2048, Math.round(Number(args.h))));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-hands",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|