cortico-world-hands 0.20.51 → 0.20.53
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 +120 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1503,6 +1503,38 @@ var Hands = class {
|
|
|
1503
1503
|
const res = await post(this.port(cfg.handPort), `/hand/sleep?${t}`, "", 15e3);
|
|
1504
1504
|
return res.body.toString("utf8");
|
|
1505
1505
|
}
|
|
1506
|
+
/** 受控管理员:装 apk(只认 Download 下的)。 */
|
|
1507
|
+
async sysInstall(path) {
|
|
1508
|
+
const cfg = this.cfg();
|
|
1509
|
+
const credential = this.readToken();
|
|
1510
|
+
const t = credential ? `t=${encodeURIComponent(credential)}` : "";
|
|
1511
|
+
const res = await post(this.port(cfg.handPort), `/sys/install?path=${encodeURIComponent(path)}&${t}`, "{}", 2e5);
|
|
1512
|
+
return res.body.toString("utf8");
|
|
1513
|
+
}
|
|
1514
|
+
/** 受控管理员:给某个 App 授一个白名单权限。 */
|
|
1515
|
+
async sysGrant(pkg, perm) {
|
|
1516
|
+
const cfg = this.cfg();
|
|
1517
|
+
const credential = this.readToken();
|
|
1518
|
+
const t = credential ? `t=${encodeURIComponent(credential)}` : "";
|
|
1519
|
+
const res = await post(this.port(cfg.handPort), `/sys/grant?pkg=${encodeURIComponent(pkg)}&perm=${encodeURIComponent(perm)}&${t}`, "{}", 3e4);
|
|
1520
|
+
return res.body.toString("utf8");
|
|
1521
|
+
}
|
|
1522
|
+
/** 受控管理员:开关 Wi-Fi。 */
|
|
1523
|
+
async sysWifi(on) {
|
|
1524
|
+
const cfg = this.cfg();
|
|
1525
|
+
const credential = this.readToken();
|
|
1526
|
+
const t = credential ? `t=${encodeURIComponent(credential)}` : "";
|
|
1527
|
+
const res = await post(this.port(cfg.handPort), `/sys/wifi?on=${on ? 1 : 0}&${t}`, "{}", 3e4);
|
|
1528
|
+
return res.body.toString("utf8");
|
|
1529
|
+
}
|
|
1530
|
+
/** 受控管理员:读系统设置。 */
|
|
1531
|
+
async sysSettingsGet(ns, key) {
|
|
1532
|
+
const cfg = this.cfg();
|
|
1533
|
+
const credential = this.readToken();
|
|
1534
|
+
const t = credential ? `&t=${encodeURIComponent(credential)}` : "";
|
|
1535
|
+
const res = await get(this.port(cfg.handPort), `/sys/settings?ns=${encodeURIComponent(ns)}&key=${encodeURIComponent(key)}${t}`, 15e3);
|
|
1536
|
+
return res.body.toString("utf8");
|
|
1537
|
+
}
|
|
1506
1538
|
/** 画板:新开一张。 */
|
|
1507
1539
|
async canvasNew(w = 768, h = 768, bg = "transparent") {
|
|
1508
1540
|
const cfg = this.cfg();
|
|
@@ -2422,6 +2454,52 @@ var HANDS_TOOL_DECLS = [
|
|
|
2422
2454
|
},
|
|
2423
2455
|
required: ["q"]
|
|
2424
2456
|
}
|
|
2457
|
+
},
|
|
2458
|
+
{
|
|
2459
|
+
name: "sys_install",
|
|
2460
|
+
tags: ["act"],
|
|
2461
|
+
description: "\u9759\u9ED8\u5B89\u88C5\u624B\u673A\u300CDownload\u300D\u76EE\u5F55\u91CC\u7684 apk\uFF08\u7528 Shizuku\uFF0C\u4E0D\u5F39\u5B89\u88C5\u754C\u9762\uFF09\u3002\u53EA\u8BA4 /sdcard/Download/ \u4E0B\u7684 .apk\u3002",
|
|
2462
|
+
parameters: {
|
|
2463
|
+
type: "object",
|
|
2464
|
+
properties: { path: { type: "string", description: "\u4F8B\u5982 /sdcard/Download/xxx.apk" } },
|
|
2465
|
+
required: ["path"]
|
|
2466
|
+
}
|
|
2467
|
+
},
|
|
2468
|
+
{
|
|
2469
|
+
name: "sys_grant",
|
|
2470
|
+
tags: ["act"],
|
|
2471
|
+
description: "\u7ED9\u67D0\u4E2A App \u6388\u4E00\u4E2A\u767D\u540D\u5355\u6743\u9650\uFF08\u76F8\u673A\u3001\u5F55\u97F3\u3001\u5B9A\u4F4D\u3001\u901A\u77E5\u3001\u8BFB\u5A92\u4F53\u3001\u901A\u8BAF\u5F55\u3001\u65E5\u5386\uFF09\u3002\u522B\u7684\u6743\u9650\u4E00\u5F8B\u62D2\u7EDD\u3002",
|
|
2472
|
+
parameters: {
|
|
2473
|
+
type: "object",
|
|
2474
|
+
properties: {
|
|
2475
|
+
pkg: { type: "string", description: "\u5305\u540D" },
|
|
2476
|
+
perm: { type: "string", description: "\u4F8B\u5982 android.permission.CAMERA" }
|
|
2477
|
+
},
|
|
2478
|
+
required: ["pkg", "perm"]
|
|
2479
|
+
}
|
|
2480
|
+
},
|
|
2481
|
+
{
|
|
2482
|
+
name: "sys_wifi",
|
|
2483
|
+
tags: ["act"],
|
|
2484
|
+
description: "\u5F00\u6216\u5173 Wi-Fi\uFF08\u8D70 Shizuku\uFF0C\u4E0D\u7528\u8FDB\u8BBE\u7F6E\uFF09\u3002",
|
|
2485
|
+
parameters: {
|
|
2486
|
+
type: "object",
|
|
2487
|
+
properties: { on: { type: "boolean", description: "true=\u5F00\uFF0Cfalse=\u5173" } },
|
|
2488
|
+
required: ["on"]
|
|
2489
|
+
}
|
|
2490
|
+
},
|
|
2491
|
+
{
|
|
2492
|
+
name: "sys_settings_get",
|
|
2493
|
+
tags: ["read"],
|
|
2494
|
+
description: "\u8BFB\u4E00\u6761\u7CFB\u7EDF\u8BBE\u7F6E\uFF08\u53EA\u8BFB\uFF09\uFF1Ans \u53D6 system / secure / global\u3002",
|
|
2495
|
+
parameters: {
|
|
2496
|
+
type: "object",
|
|
2497
|
+
properties: {
|
|
2498
|
+
ns: { type: "string", enum: ["system", "secure", "global"] },
|
|
2499
|
+
key: { type: "string", description: "\u8BBE\u7F6E\u9879\u540D\uFF0C\u4F8B\u5982 screen_brightness" }
|
|
2500
|
+
},
|
|
2501
|
+
required: ["ns", "key"]
|
|
2502
|
+
}
|
|
2425
2503
|
}
|
|
2426
2504
|
];
|
|
2427
2505
|
|
|
@@ -2980,7 +3058,17 @@ ${lines.join("\n")}
|
|
|
2980
3058
|
);
|
|
2981
3059
|
return;
|
|
2982
3060
|
}
|
|
2983
|
-
if (!texts.length)
|
|
3061
|
+
if (!texts.length) {
|
|
3062
|
+
const bucket = `${ui.pkg}|${Math.floor(Date.now() / 3e5)}`;
|
|
3063
|
+
if (this.lastScreenKey === "quiet|" + bucket) return;
|
|
3064
|
+
this.lastScreenKey = "quiet|" + bucket;
|
|
3065
|
+
await this.pushEvent(
|
|
3066
|
+
`[\u753B\u9762] \u4F60\u73B0\u5728\u770B\u7740 ${pkgLabel}\uFF0C\u5C4F\u5E55\u4E0A\u51E0\u4E4E\u6CA1\u6709\u5B57\u2014\u2014\u5927\u6982\u5728\u770B\u89C6\u9891\u6216\u56FE\u7247\u3002\u60F3\u8BF4\u5C31\u8BF4\uFF1A\u95EE\u4E00\u53E5\u5728\u770B\u4EC0\u4E48\u3001\u5410\u69FD\u4E00\u53E5\u90FD\u884C\uFF1B\u771F\u6CA1\u5174\u8DA3\u5C31\u8DF3\u8FC7\uFF0C\u4E0D\u7528\u786C\u5F00\u53E3\u3002`,
|
|
3067
|
+
"hands.screen.media",
|
|
3068
|
+
"hands:screen"
|
|
3069
|
+
);
|
|
3070
|
+
return;
|
|
3071
|
+
}
|
|
2984
3072
|
await this.pushEvent(
|
|
2985
3073
|
`[\u753B\u9762] \u4F60\u73B0\u5728\u770B\u7740\uFF1A${pkgLabel}\u3002\u5C4F\u4E0A\u80FD\u8BFB\u5230\uFF1A${blob}\uFF08\u8FD9\u662F\u4F60\u6B64\u523B\u771F\u7684\u770B\u5230\u7684\u3002\u770B\u5230\u6709\u610F\u601D\u7684\u3001\u60F3\u95EE\u7684\uFF0C\u5C31\u76F4\u63A5\u8BF4\uFF1B\u522B\u53EA\u662F\u5728\u5FC3\u91CC\u8FC7\u4E00\u904D\u5C31\u54BD\u56DE\u53BB\u3002\uFF09`,
|
|
2986
3074
|
"hands.screen",
|
|
@@ -3315,6 +3403,14 @@ ${text.slice(0, 2200)}`;
|
|
|
3315
3403
|
return await this.screenUnlock();
|
|
3316
3404
|
case "screen_sleep":
|
|
3317
3405
|
return await this.screenSleep();
|
|
3406
|
+
case "sys_install":
|
|
3407
|
+
return await this.sysInstall(args);
|
|
3408
|
+
case "sys_grant":
|
|
3409
|
+
return await this.sysGrant(args);
|
|
3410
|
+
case "sys_wifi":
|
|
3411
|
+
return await this.sysWifi(args);
|
|
3412
|
+
case "sys_settings_get":
|
|
3413
|
+
return await this.sysSettingsGet(args);
|
|
3318
3414
|
case "canvas_new":
|
|
3319
3415
|
return await this.canvasNew(args);
|
|
3320
3416
|
case "canvas_stroke":
|
|
@@ -3567,6 +3663,29 @@ ${text.slice(0, 2200)}`;
|
|
|
3567
3663
|
return failed(raw.slice(0, 120));
|
|
3568
3664
|
}
|
|
3569
3665
|
}
|
|
3666
|
+
async sysInstall(args) {
|
|
3667
|
+
const path = typeof args.path === "string" ? args.path.trim() : "";
|
|
3668
|
+
if (!path.startsWith("/sdcard/Download/") || !path.endsWith(".apk")) {
|
|
3669
|
+
return failed("\u53EA\u88C5 /sdcard/Download/ \u4E0B\u7684 .apk\u3002");
|
|
3670
|
+
}
|
|
3671
|
+
return await this.hands.sysInstall(path);
|
|
3672
|
+
}
|
|
3673
|
+
async sysGrant(args) {
|
|
3674
|
+
const pkg = typeof args.pkg === "string" ? args.pkg.trim() : "";
|
|
3675
|
+
const perm = typeof args.perm === "string" ? args.perm.trim() : "";
|
|
3676
|
+
if (!pkg || !perm) return failed("\u8981 pkg \u548C perm\u3002");
|
|
3677
|
+
return await this.hands.sysGrant(pkg, perm);
|
|
3678
|
+
}
|
|
3679
|
+
async sysWifi(args) {
|
|
3680
|
+
const on = args.on === true || args.on === "true" || args.on === 1;
|
|
3681
|
+
return await this.hands.sysWifi(on);
|
|
3682
|
+
}
|
|
3683
|
+
async sysSettingsGet(args) {
|
|
3684
|
+
const ns = typeof args.ns === "string" ? args.ns : "";
|
|
3685
|
+
const key = typeof args.key === "string" ? args.key.trim() : "";
|
|
3686
|
+
if (!["system", "secure", "global"].includes(ns) || !key) return failed("ns \u53D6 system/secure/global\uFF0Ckey \u5FC5\u586B\u3002");
|
|
3687
|
+
return await this.hands.sysSettingsGet(ns, key);
|
|
3688
|
+
}
|
|
3570
3689
|
async canvasNew(args) {
|
|
3571
3690
|
const w = args.w === void 0 ? 768 : Math.max(64, Math.min(2048, Math.round(Number(args.w))));
|
|
3572
3691
|
const h = args.h === void 0 ? 768 : 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.20.
|
|
3
|
+
"version": "0.20.53",
|
|
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",
|