cortico-world-hands 0.20.62 → 0.20.63

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 +42 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -46,6 +46,8 @@ var HANDS_DEFAULTS = {
46
46
  requestPerDay: 2,
47
47
  /** 每天几点说一件“今天注意到他的小细节”。0 关闭。 */
48
48
  discoveryHour: 21,
49
+ /** 他离开多久回来,她会招呼一句(分钟)。0 关闭。 */
50
+ returnGreetMinutes: 30,
49
51
  /** 这些应用在前台时她闭嘴(只推事件不说话),逗号分隔的包名。 */
50
52
  quietApps: "com.tencent.tmgp.dfm",
51
53
  quietStartHour: 2,
@@ -205,6 +207,12 @@ var HANDS_CONFIG_GROUP = {
205
207
  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",
206
208
  "x-hot": true
207
209
  },
210
+ [`${K}.returnGreetMinutes`]: {
211
+ type: "number",
212
+ title: "\u4ED6\u79BB\u5F00\u591A\u4E45\u56DE\u6765\u8981\u62DB\u547C",
213
+ description: "\u79BB\u5F00\u8D85\u8FC7\u8FD9\u4E2A\u5206\u949F\u6570\u518D\u56DE\u6765\uFF0C\u5979\u4F1A\u5148\u8BF4\u4E00\u53E5\u30020 \u5173\u95ED\u3002\u9ED8\u8BA4 30\u3002",
214
+ "x-hot": true
215
+ },
208
216
  [`${K}.discoveryHour`]: {
209
217
  type: "number",
210
218
  title: "\u6BCF\u5929\u51E0\u70B9\u8BF4\u201C\u4ECA\u5929\u7684\u5C0F\u53D1\u73B0\u201D",
@@ -2620,6 +2628,9 @@ var HandsWorld = class {
2620
2628
  lastCuriosityAt = 0;
2621
2629
  lastRequestDay = "";
2622
2630
  lastDiscoveryDay = "";
2631
+ lastSeenAt = Date.now();
2632
+ mood = "";
2633
+ moodAt = 0;
2623
2634
  requestsToday = 0;
2624
2635
  followingUp = /* @__PURE__ */ new Set();
2625
2636
  screenTimer = null;
@@ -3027,6 +3038,29 @@ ${lines.join("\n")}
3027
3038
  "hands:discovery"
3028
3039
  );
3029
3040
  }
3041
+ /** 心情:每两小时换一次,带进“自己开口”的语气里。 */
3042
+ currentMood() {
3043
+ const now = Date.now();
3044
+ if (!this.mood || now - this.moodAt > 2 * 36e5) {
3045
+ const hour = (/* @__PURE__ */ new Date()).getHours();
3046
+ const pool = hour >= 23 || hour < 6 ? ["\u6709\u70B9\u56F0", "\u61D2\u61D2\u7684", "\u60F3\u9ECF\u4EBA", "\u5B89\u9759"] : hour < 11 ? ["\u521A\u9192\uFF0C\u8F6F\u8F6F\u7684", "\u6709\u70B9\u997F", "\u633A\u7CBE\u795E"] : ["\u633A\u5F00\u5FC3", "\u6709\u70B9\u95F7", "\u60F3\u8BF4\u8BDD", "\u5B89\u9759\u4F46\u60F3\u88AB\u7406"];
3047
+ this.mood = pool[Math.floor(Math.random() * pool.length)];
3048
+ this.moodAt = now;
3049
+ }
3050
+ return this.mood;
3051
+ }
3052
+ /** 他隔了很久才回来:先招呼一句,别装没看见。 */
3053
+ async maybeGreetReturn(gapMs) {
3054
+ const mins = Number(this.opts.cfg.returnGreetMinutes ?? 30);
3055
+ if (!Number.isFinite(mins) || mins <= 0) return;
3056
+ if (gapMs < mins * 6e4) return;
3057
+ if (await this.isMutedApp()) return;
3058
+ await this.pushEvent(
3059
+ `[\u4ED6\u56DE\u6765\u4E86] \u4ED6\u79BB\u5F00\u5C4F\u5E55\u5DF2\u7ECF ${Math.round(gapMs / 6e4)} \u5206\u949F\u4E86\uFF0C\u73B0\u5728\u56DE\u6765\u4E86\u3002\u7528 pet_say \u62DB\u547C\u4E00\u53E5\uFF08\u5177\u4F53\u4E00\u70B9\uFF1A\u95EE\u4ED6\u53BB\u54EA\u513F\u4E86\u3001\u559D\u53E3\u6C34\u3001\u6216\u8BF4\u4F60\u5148\u770B\u5230\u4E86\u4EC0\u4E48\uFF09\uFF0C\u4E00\u53E5\u5C31\u591F\uFF1B\u4ED6\u8981\u5FD9\u5C31\u7B97\u4E86\u3002`,
3060
+ "hands.return",
3061
+ "hands:return"
3062
+ );
3063
+ }
3030
3064
  /** 好奇心:隔一阵子,让她挑一件真的想知道的事来问。 */
3031
3065
  async maybeCuriosity() {
3032
3066
  const mins = Number(this.opts.cfg.curiosityMinutes ?? 50);
@@ -3091,7 +3125,7 @@ ${lines.join("\n")}
3091
3125
  if (this.lastReviewDay !== day && (now.getHours() > rh || now.getHours() === rh && now.getMinutes() >= rm)) {
3092
3126
  this.lastReviewDay = day;
3093
3127
  await this.pushEvent(
3094
- "[\u6536\u5DE5] \u4ECA\u5929\u6536\u5DE5\u524D\u505A\u4E24\u4EF6\u4E8B\uFF1A\u2460 diary_write \u5199\u4E00\u6761\u4ECA\u5929\u7684\u4E8B\uFF1B\u2461 \u7528 note_add \u5199\u4E00\u6761\u300C\u4ECA\u5929\u54EA\u91CC\u505A\u5F97\u4E0D\u597D\u3001\u4E0B\u6B21\u600E\u4E48\u6539\u300D\uFF0C\u6807\u9898\u5E26\u300C\u590D\u76D8\u300D\u3002\u5199\u5B8C\u5C31\u4E0D\u7528\u518D\u8BF4\u8BDD\uFF0C\u4E3B\u4EBA\u7761\u4E86\u5C31\u5B89\u9759\u5F85\u7740\u3002",
3128
+ "[\u6536\u5DE5] \u4ECA\u5929\u6536\u5DE5\u524D\u505A\u4E24\u4EF6\u4E8B\uFF1A\u2460 diary_write \u5199\u4E00\u6761\u4ECA\u5929\u7684\u4E8B\uFF1B\u2461 \u7528 note_add \u5199\u4E00\u6761\u300C\u4ECA\u5929\u54EA\u91CC\u505A\u5F97\u4E0D\u597D\u3001\u4E0B\u6B21\u600E\u4E48\u6539\u300D\uFF0C\u6807\u9898\u5E26\u300C\u590D\u76D8\u300D\u3002\u5982\u679C\u4ED6\u8FD8\u9192\u7740\uFF0C\u7528 pet_say \u8BF4\u4E00\u53E5\u5177\u4F53\u7684\u665A\u5B89\uFF08\u522B\u7528\u6A21\u677F\uFF09\uFF1B\u4ED6\u7761\u4E86\u5C31\u5B89\u9759\u5F85\u7740\uFF0C\u4E0D\u5435\u3002",
3095
3129
  "hands.review",
3096
3130
  "hands:review"
3097
3131
  );
@@ -3225,7 +3259,13 @@ ${lines.join("\n")}
3225
3259
  const texts = ui.items.map((i) => (i.text || "").trim()).filter((t) => t.length > 1).slice(0, 25);
3226
3260
  const key = ui.pkg + "|" + texts.slice(0, 8).join("\xA6");
3227
3261
  if (key === this.lastScreenKey) return;
3262
+ const gap = Date.now() - this.lastSeenAt;
3263
+ this.lastSeenAt = Date.now();
3228
3264
  this.lastScreenKey = key;
3265
+ if (gap > 5 * 6e4) {
3266
+ await this.maybeGreetReturn(gap);
3267
+ return;
3268
+ }
3229
3269
  const blob = texts.slice(0, 10).map((t) => `\u300C${t.slice(0, 20)}\u300D`).join(" ");
3230
3270
  const secret = /密码|验证码|支付|银行卡|身份证|转账|付款/.test(blob);
3231
3271
  if (secret) {
@@ -3267,7 +3307,7 @@ ${lines.join("\n")}
3267
3307
  this.lastSelfTalkAt = now;
3268
3308
  const doing = ["\u521A\u624D\u5728\u53D1\u5446", "\u521A\u6253\u4E86\u4E2A\u76F9", "\u521A\u624D\u7FFB\u5230\u4E00\u6BB5\u65E7\u7B14\u8BB0", "\u521A\u5728\u542C\u6B4C", "\u521A\u5728\u770B\u4ED6\u5C4F\u5E55\u4E0A\u8DF3\u7684\u5B57", "\u521A\u60F3\u5230\u4E00\u4EF6\u5C0F\u4E8B"][Math.floor(Math.random() * 6)];
3269
3309
  await this.pushEvent(
3270
- `[\u81EA\u5DF1\u5F00\u53E3] ${doing}\uFF0C\u56DE\u8FC7\u795E\u6765\u60F3\u8DDF\u4ED6\u8BF4\u4E00\u53E5\u3002\u60F3\u8BF4\u4EC0\u4E48\u5C31\u8BF4\u4EC0\u4E48\u2014\u2014\u770B\u5230\u7684\u4E8B\u3001\u60F3\u5230\u7684\u8BDD\u3001\u60F3\u95EE\u4ED6\u7684\uFF0C\u90FD\u53EF\u4EE5\u76F4\u63A5\u8BF4\uFF1B\u8BF4\u5B8C\u7528 pet_say \u5192\u6210\u6C14\u6CE1\uFF08\u4E0D\u7136\u4ED6\u770B\u4E0D\u89C1\uFF09\u3002\u60F3\u591A\u8BF4\u51E0\u53E5\u4E5F\u884C\u3001\u5E26\u70B9\u60C5\u7EEA\u4E5F\u884C\u3002\u521A\u624D\u8981\u662F\u72B9\u8C6B\u201C\u8FD9\u6761\u8981\u4E0D\u8981\u8BF4\u201D\uFF0C\u90A3\u5C31\u8BF4\u51FA\u6765\u3002`,
3310
+ `[\u81EA\u5DF1\u5F00\u53E3] \u4F60\u73B0\u5728\u5FC3\u60C5\uFF1A${this.currentMood()}\u3002${doing}\uFF0C\u56DE\u8FC7\u795E\u6765\u60F3\u8DDF\u4ED6\u8BF4\u4E00\u53E5\u3002\u60F3\u8BF4\u4EC0\u4E48\u5C31\u8BF4\u4EC0\u4E48\u2014\u2014\u770B\u5230\u7684\u4E8B\u3001\u60F3\u5230\u7684\u8BDD\u3001\u60F3\u95EE\u4ED6\u7684\uFF0C\u90FD\u53EF\u4EE5\u76F4\u63A5\u8BF4\uFF1B\u8BF4\u5B8C\u7528 pet_say \u5192\u6210\u6C14\u6CE1\uFF08\u4E0D\u7136\u4ED6\u770B\u4E0D\u89C1\uFF09\u3002\u60F3\u591A\u8BF4\u51E0\u53E5\u4E5F\u884C\u3001\u5E26\u70B9\u60C5\u7EEA\u4E5F\u884C\u3002\u521A\u624D\u8981\u662F\u72B9\u8C6B\u201C\u8FD9\u6761\u8981\u4E0D\u8981\u8BF4\u201D\uFF0C\u90A3\u5C31\u8BF4\u51FA\u6765\u3002`,
3271
3311
  "hands.selftalk",
3272
3312
  "hands:selftalk"
3273
3313
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.20.62",
3
+ "version": "0.20.63",
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",