cortico-world-hands 0.20.52 → 0.20.54
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 +123 -13
- 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
|
|
|
@@ -3325,6 +3403,14 @@ ${text.slice(0, 2200)}`;
|
|
|
3325
3403
|
return await this.screenUnlock();
|
|
3326
3404
|
case "screen_sleep":
|
|
3327
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);
|
|
3328
3414
|
case "canvas_new":
|
|
3329
3415
|
return await this.canvasNew(args);
|
|
3330
3416
|
case "canvas_stroke":
|
|
@@ -3524,6 +3610,17 @@ ${text.slice(0, 2200)}`;
|
|
|
3524
3610
|
if (!text) return failed("\u8981\u56DE\u4EC0\u4E48\uFF1F");
|
|
3525
3611
|
const to = typeof args.to === "string" ? args.to.trim() : "";
|
|
3526
3612
|
let why = "";
|
|
3613
|
+
try {
|
|
3614
|
+
const raw = await this.hands.qqReply(text, to || void 0);
|
|
3615
|
+
const r = JSON.parse(raw);
|
|
3616
|
+
if (r.ok) {
|
|
3617
|
+
this.clearQqDue();
|
|
3618
|
+
return `\u56DE\u4E86${r.to ? "\u7ED9\u300C" + r.to + "\u300D" : ""}\uFF1A${text}`;
|
|
3619
|
+
}
|
|
3620
|
+
why = `\u5FEB\u901F\u56DE\u590D\u6CA1\u6210\uFF08${r.error || "\u6CA1\u6709\u53EF\u56DE\u590D\u7684\u901A\u77E5"}\uFF09`;
|
|
3621
|
+
} catch (err) {
|
|
3622
|
+
why = `\u5FEB\u901F\u56DE\u590D\u62A5\u9519\uFF08${String(err).slice(0, 60)}\uFF09`;
|
|
3623
|
+
}
|
|
3527
3624
|
try {
|
|
3528
3625
|
await this.hands.wakeScreen();
|
|
3529
3626
|
await new Promise((r) => setTimeout(r, 700));
|
|
@@ -3540,21 +3637,11 @@ ${text.slice(0, 2200)}`;
|
|
|
3540
3637
|
this.clearQqDue();
|
|
3541
3638
|
return `\u6211\u5524\u5C4F\u3001\u89E3\u9501\u3001\u5F00 QQ \u56DE\u7684${to ? "\uFF08" + to + "\uFF09" : ""}\uFF1A${text}`;
|
|
3542
3639
|
}
|
|
3543
|
-
why
|
|
3640
|
+
why += `\uFF1B\u5F00\u804A\u56DE\u590D\u4E5F\u4E0D\u884C\uFF08${r2.error || "\u6CA1\u56DE\u6210"}\uFF09`;
|
|
3544
3641
|
} catch (err) {
|
|
3545
|
-
why
|
|
3546
|
-
}
|
|
3547
|
-
try {
|
|
3548
|
-
const raw = await this.hands.qqReply(text, to || void 0);
|
|
3549
|
-
const r = JSON.parse(raw);
|
|
3550
|
-
if (r.ok) {
|
|
3551
|
-
this.clearQqDue();
|
|
3552
|
-
return `\u56DE\u4E86${r.to ? "\u7ED9\u300C" + r.to + "\u300D" : ""}\uFF1A${text}`;
|
|
3553
|
-
}
|
|
3554
|
-
why += `\uFF1B\u5FEB\u901F\u56DE\u590D\u4E5F\u4E0D\u884C\uFF08${r.error || "\u6CA1\u56DE\u51FA\u53BB"}\uFF09`;
|
|
3555
|
-
} catch {
|
|
3642
|
+
why += `\uFF1B\u5F00\u804A\u56DE\u590D\u62A5\u9519\uFF08${String(err).slice(0, 60)}\uFF09`;
|
|
3556
3643
|
}
|
|
3557
|
-
return failed(`\u4E24\u6761\u8DEF\u90FD\u6CA1\u56DE\u6210\uFF08${why}\uFF09\u3002\
|
|
3644
|
+
return failed(`\u4E24\u6761\u81EA\u52A8\u8DEF\u90FD\u6CA1\u56DE\u6210\uFF08${why}\uFF09\u3002**\u5148\u522B\u81EA\u5DF1\u70B9 QQ \u754C\u9762**\u2014\u2014\u90A3\u662F\u4E71\u70B9\u7684\u6765\u7531\uFF1B\u628A\u539F\u56E0\u544A\u8BC9\u4E3B\u4EBA\uFF0C\u8BA9\u4ED6\u6253\u5F00\u65E0\u969C\u788D\uFF08\u8BBE\u7F6E \u2192 \u65E0\u969C\u788D \u2192 \u7D2B\u6708\u6708\uFF09\uFF0C\u518D\u56DE\u3002`);
|
|
3558
3645
|
}
|
|
3559
3646
|
/** 解锁:成功/没锁/失败都给人话。 */
|
|
3560
3647
|
async screenUnlock() {
|
|
@@ -3577,6 +3664,29 @@ ${text.slice(0, 2200)}`;
|
|
|
3577
3664
|
return failed(raw.slice(0, 120));
|
|
3578
3665
|
}
|
|
3579
3666
|
}
|
|
3667
|
+
async sysInstall(args) {
|
|
3668
|
+
const path = typeof args.path === "string" ? args.path.trim() : "";
|
|
3669
|
+
if (!path.startsWith("/sdcard/Download/") || !path.endsWith(".apk")) {
|
|
3670
|
+
return failed("\u53EA\u88C5 /sdcard/Download/ \u4E0B\u7684 .apk\u3002");
|
|
3671
|
+
}
|
|
3672
|
+
return await this.hands.sysInstall(path);
|
|
3673
|
+
}
|
|
3674
|
+
async sysGrant(args) {
|
|
3675
|
+
const pkg = typeof args.pkg === "string" ? args.pkg.trim() : "";
|
|
3676
|
+
const perm = typeof args.perm === "string" ? args.perm.trim() : "";
|
|
3677
|
+
if (!pkg || !perm) return failed("\u8981 pkg \u548C perm\u3002");
|
|
3678
|
+
return await this.hands.sysGrant(pkg, perm);
|
|
3679
|
+
}
|
|
3680
|
+
async sysWifi(args) {
|
|
3681
|
+
const on = args.on === true || args.on === "true" || args.on === 1;
|
|
3682
|
+
return await this.hands.sysWifi(on);
|
|
3683
|
+
}
|
|
3684
|
+
async sysSettingsGet(args) {
|
|
3685
|
+
const ns = typeof args.ns === "string" ? args.ns : "";
|
|
3686
|
+
const key = typeof args.key === "string" ? args.key.trim() : "";
|
|
3687
|
+
if (!["system", "secure", "global"].includes(ns) || !key) return failed("ns \u53D6 system/secure/global\uFF0Ckey \u5FC5\u586B\u3002");
|
|
3688
|
+
return await this.hands.sysSettingsGet(ns, key);
|
|
3689
|
+
}
|
|
3580
3690
|
async canvasNew(args) {
|
|
3581
3691
|
const w = args.w === void 0 ? 768 : Math.max(64, Math.min(2048, Math.round(Number(args.w))));
|
|
3582
3692
|
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.54",
|
|
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",
|