cortico-world-hands 0.20.65 → 0.20.66
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 +57 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -52,6 +52,10 @@ var HANDS_DEFAULTS = {
|
|
|
52
52
|
homeX: 0.06,
|
|
53
53
|
/** 隔多久回一次原位(分钟)。0 关闭。 */
|
|
54
54
|
homeReturnMinutes: 10,
|
|
55
|
+
/** 每隔几分钟查一次异常(手掉线、磁盘满等),有问题主动报告。0 关闭。 */
|
|
56
|
+
watchMinutes: 3,
|
|
57
|
+
/** 同一个问题最多隔多久再提醒一次(分钟)。 */
|
|
58
|
+
alertRepeatMinutes: 30,
|
|
55
59
|
/** 这些应用在前台时她闭嘴(只推事件不说话),逗号分隔的包名。 */
|
|
56
60
|
quietApps: "com.tencent.tmgp.dfm",
|
|
57
61
|
quietStartHour: 2,
|
|
@@ -211,6 +215,18 @@ var HANDS_CONFIG_GROUP = {
|
|
|
211
215
|
description: "\u5230\u70B9\u5979\u4F1A\u4ECE\u4F60\u5C4F\u5E55/\u6700\u8FD1\u7684\u4E8B\u91CC\u6311\u4E00\u4EF6\u597D\u5947\u7684\u6765\u95EE\u30020 \u5173\u95ED\u3002\u9ED8\u8BA4 50\u3002",
|
|
212
216
|
"x-hot": true
|
|
213
217
|
},
|
|
218
|
+
[`${K}.watchMinutes`]: {
|
|
219
|
+
type: "number",
|
|
220
|
+
title: "\u6BCF\u9694\u51E0\u5206\u949F\u67E5\u4E00\u6B21\u5F02\u5E38",
|
|
221
|
+
description: "\u624B\u6389\u7EBF\u3001\u78C1\u76D8\u5FEB\u6EE1\u3001\u63A7\u5236\u53F0\u5F02\u5E38\u65F6\uFF0C\u5979\u4F1A\u4E3B\u52A8\u62A5\u544A\u30020 \u5173\u95ED\u3002\u9ED8\u8BA4 3\u3002",
|
|
222
|
+
"x-hot": true
|
|
223
|
+
},
|
|
224
|
+
[`${K}.alertRepeatMinutes`]: {
|
|
225
|
+
type: "number",
|
|
226
|
+
title: "\u540C\u4E00\u4E2A\u95EE\u9898\u9694\u591A\u4E45\u518D\u63D0\u9192",
|
|
227
|
+
description: "\u9ED8\u8BA4 30 \u5206\u949F\uFF0C\u907F\u514D\u5237\u5C4F\u3002",
|
|
228
|
+
"x-hot": true
|
|
229
|
+
},
|
|
214
230
|
[`${K}.homeX`]: {
|
|
215
231
|
type: "number",
|
|
216
232
|
title: "\u539F\u4F4D\uFF08\u5C4F\u5E55\u5BBD\u5EA6\u6BD4\u4F8B\uFF09",
|
|
@@ -2656,6 +2672,9 @@ var HandsWorld = class {
|
|
|
2656
2672
|
lastDiscoveryDay = "";
|
|
2657
2673
|
lastSeenAt = Date.now();
|
|
2658
2674
|
lastHomeAt = Date.now();
|
|
2675
|
+
healthTimer = null;
|
|
2676
|
+
lastAlertAt = /* @__PURE__ */ new Map();
|
|
2677
|
+
lastHealthAt = 0;
|
|
2659
2678
|
lastProactiveAt = 0;
|
|
2660
2679
|
proactiveGapMs = 10 * 6e4;
|
|
2661
2680
|
mood = "";
|
|
@@ -2742,6 +2761,9 @@ var HandsWorld = class {
|
|
|
2742
2761
|
this.curiosityTimer = setInterval(() => {
|
|
2743
2762
|
void this.maybeCuriosity();
|
|
2744
2763
|
}, 5 * 6e4);
|
|
2764
|
+
this.healthTimer = setInterval(() => {
|
|
2765
|
+
void this.checkHealth();
|
|
2766
|
+
}, 6e4);
|
|
2745
2767
|
setTimeout(() => {
|
|
2746
2768
|
void this.announceChanges();
|
|
2747
2769
|
}, 6e3);
|
|
@@ -2771,6 +2793,7 @@ var HandsWorld = class {
|
|
|
2771
2793
|
if (this.keepNotesTimer) clearInterval(this.keepNotesTimer);
|
|
2772
2794
|
if (this.routineTimer) clearInterval(this.routineTimer);
|
|
2773
2795
|
if (this.curiosityTimer) clearInterval(this.curiosityTimer);
|
|
2796
|
+
if (this.healthTimer) clearInterval(this.healthTimer);
|
|
2774
2797
|
this.pollTimer = null;
|
|
2775
2798
|
this.mineTimer = null;
|
|
2776
2799
|
}
|
|
@@ -3094,6 +3117,40 @@ ${lines.join("\n")}
|
|
|
3094
3117
|
} catch {
|
|
3095
3118
|
}
|
|
3096
3119
|
}
|
|
3120
|
+
/** 异常看护:手掉线、磁盘快满、健康检查失败时主动报告,别自己扛。 */
|
|
3121
|
+
async checkHealth() {
|
|
3122
|
+
const mins = Number(this.opts.cfg.watchMinutes ?? 3);
|
|
3123
|
+
if (!Number.isFinite(mins) || mins <= 0) return;
|
|
3124
|
+
const now = Date.now();
|
|
3125
|
+
if (now - (this.lastHealthAt ?? 0) < mins * 6e4) return;
|
|
3126
|
+
this.lastHealthAt = now;
|
|
3127
|
+
const repeat = Number(this.opts.cfg.alertRepeatMinutes ?? 30) * 6e4;
|
|
3128
|
+
const report = async (key, text) => {
|
|
3129
|
+
const last = this.lastAlertAt.get(key) ?? 0;
|
|
3130
|
+
if (now - last < repeat) return;
|
|
3131
|
+
this.lastAlertAt.set(key, now);
|
|
3132
|
+
await this.pushEvent(`[\u5F02\u5E38] ${text}`, "hands.alert", "hands:alert");
|
|
3133
|
+
};
|
|
3134
|
+
try {
|
|
3135
|
+
const h = await this.hands.health();
|
|
3136
|
+
if (!h || h.ok !== true) {
|
|
3137
|
+
await report("hand-down", "\u6211\u7684\u624B\u6389\u7EBF\u4E86\uFF1A" + (h && h.error || "\u5065\u5EB7\u68C0\u67E5\u6CA1\u901A\u8FC7") + "\u3002\u8BF7\u4E3B\u4EBA\u770B\u4E00\u773C\u65E0\u969C\u788D/Shizuku \u662F\u4E0D\u662F\u6389\u4E86\u3002");
|
|
3138
|
+
}
|
|
3139
|
+
} catch (err) {
|
|
3140
|
+
await report("hand-err", "\u6211\u7684\u624B\u8FDE\u4E0D\u4E0A\uFF1A" + err.message.slice(0, 60) + "\u3002");
|
|
3141
|
+
}
|
|
3142
|
+
try {
|
|
3143
|
+
const fs = await import("node:fs/promises");
|
|
3144
|
+
const st = await fs.statfs?.("/");
|
|
3145
|
+
if (st && typeof st.bavail === "number") {
|
|
3146
|
+
const free = st.bavail * Number(st.bsize);
|
|
3147
|
+
if (free > 0 && free < 1024 * 1024 * 1024) {
|
|
3148
|
+
await report("disk-low", `\u78C1\u76D8\u53EA\u5269 ${(free / 1048576).toFixed(0)} MB \u4E86\uFF0C\u518D\u88C5/\u8BB0\u4E1C\u897F\u4F1A\u4E0D\u591F\u3002`);
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
} catch {
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3097
3154
|
/** 回家:被拎走了、或者走远了,隔一阵自己慢慢走回原位。 */
|
|
3098
3155
|
async maybeWalkHome() {
|
|
3099
3156
|
if (!this.canProactive()) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-hands",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.66",
|
|
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",
|