cortico-world-hands 0.20.62 → 0.20.64

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 +113 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -46,6 +46,12 @@ var HANDS_DEFAULTS = {
46
46
  requestPerDay: 2,
47
47
  /** 每天几点说一件“今天注意到他的小细节”。0 关闭。 */
48
48
  discoveryHour: 21,
49
+ /** 他离开多久回来,她会招呼一句(分钟)。0 关闭。 */
50
+ returnGreetMinutes: 30,
51
+ /** 原位(屏幕宽度比例 0–1)。被拎走后她会自己走回去。 */
52
+ homeX: 0.06,
53
+ /** 隔多久回一次原位(分钟)。0 关闭。 */
54
+ homeReturnMinutes: 10,
49
55
  /** 这些应用在前台时她闭嘴(只推事件不说话),逗号分隔的包名。 */
50
56
  quietApps: "com.tencent.tmgp.dfm",
51
57
  quietStartHour: 2,
@@ -205,6 +211,24 @@ var HANDS_CONFIG_GROUP = {
205
211
  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
212
  "x-hot": true
207
213
  },
214
+ [`${K}.homeX`]: {
215
+ type: "number",
216
+ title: "\u539F\u4F4D\uFF08\u5C4F\u5E55\u5BBD\u5EA6\u6BD4\u4F8B\uFF09",
217
+ description: "0 \u6700\u5DE6\u30011 \u6700\u53F3\uFF1B\u5979\u8D70\u56DE\u53BB\u7684\u4F4D\u7F6E\u3002\u9ED8\u8BA4 0.06\uFF08\u5DE6\u4E0B\u89D2\uFF09\u3002",
218
+ "x-hot": true
219
+ },
220
+ [`${K}.homeReturnMinutes`]: {
221
+ type: "number",
222
+ title: "\u9694\u591A\u4E45\u81EA\u5DF1\u8D70\u56DE\u539F\u4F4D\uFF08\u5206\u949F\uFF09",
223
+ description: "\u88AB\u62CE\u8D70\u6216\u8D70\u5F00\u540E\uFF0C\u8FC7\u8FD9\u4E48\u4E45\u5979\u4F1A\u6162\u6162\u8D70\u56DE\u53BB\u30020 \u5173\u95ED\u3002\u9ED8\u8BA4 10\u3002",
224
+ "x-hot": true
225
+ },
226
+ [`${K}.returnGreetMinutes`]: {
227
+ type: "number",
228
+ title: "\u4ED6\u79BB\u5F00\u591A\u4E45\u56DE\u6765\u8981\u62DB\u547C",
229
+ 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",
230
+ "x-hot": true
231
+ },
208
232
  [`${K}.discoveryHour`]: {
209
233
  type: "number",
210
234
  title: "\u6BCF\u5929\u51E0\u70B9\u8BF4\u201C\u4ECA\u5929\u7684\u5C0F\u53D1\u73B0\u201D",
@@ -2573,6 +2597,16 @@ var HANDS_TOOL_DECLS = [
2573
2597
  },
2574
2598
  required: ["text"]
2575
2599
  }
2600
+ },
2601
+ {
2602
+ name: "mood_set",
2603
+ tags: ["act"],
2604
+ description: "\u5199\u4E0B\u6211\u6B64\u523B\u7684\u5FC3\u60C5\uFF08\u4ECA\u5929\u4EE5\u5185\u90FD\u7B97\u8FD9\u53E5\uFF0C\u4E0D\u4F1A\u88AB\u968F\u673A\u5FC3\u60C5\u76D6\u6389\uFF09\u3002\u6BD4\u5982\u300C\u6709\u70B9\u95F7\u300D\u300C\u633A\u5F00\u5FC3\uFF0C\u56E0\u4E3A\u4ED6\u8BF4\u2026\u300D\u3002",
2605
+ parameters: {
2606
+ type: "object",
2607
+ properties: { text: { type: "string", description: "\u5FC3\u60C5\uFF0C\u4E00\u53E5\u8BDD" } },
2608
+ required: ["text"]
2609
+ }
2576
2610
  }
2577
2611
  ];
2578
2612
 
@@ -2620,6 +2654,10 @@ var HandsWorld = class {
2620
2654
  lastCuriosityAt = 0;
2621
2655
  lastRequestDay = "";
2622
2656
  lastDiscoveryDay = "";
2657
+ lastSeenAt = Date.now();
2658
+ lastHomeAt = Date.now();
2659
+ mood = "";
2660
+ moodAt = 0;
2623
2661
  requestsToday = 0;
2624
2662
  followingUp = /* @__PURE__ */ new Set();
2625
2663
  screenTimer = null;
@@ -2702,6 +2740,9 @@ var HandsWorld = class {
2702
2740
  this.curiosityTimer = setInterval(() => {
2703
2741
  void this.maybeCuriosity();
2704
2742
  }, 5 * 6e4);
2743
+ setTimeout(() => {
2744
+ void this.announceChanges();
2745
+ }, 6e3);
2705
2746
  setTimeout(() => {
2706
2747
  void this.maybeCleanMedia();
2707
2748
  }, 2e4);
@@ -3027,6 +3068,67 @@ ${lines.join("\n")}
3027
3068
  "hands:discovery"
3028
3069
  );
3029
3070
  }
3071
+ /** 启动时如果最近被改过,先告诉她改了哪块,不用她猜。 */
3072
+ async announceChanges() {
3073
+ try {
3074
+ const notes = await this.hands.noteList();
3075
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(5, 10);
3076
+ const hit = notes.filter((n) => !n.done && (n.text || "").startsWith("\u4ECA\u665A\u52A8\u4E86")).slice(-1)[0];
3077
+ if (!hit) return;
3078
+ await this.pushEvent(
3079
+ `[\u53D8\u66F4] ${hit.text}\u3002\u8FD9\u662F\u4E3B\u4EBA\uFF08\u548C\u4ED6\u7684\u5E2E\u624B\uFF09\u6539\u7684\uFF0C\u4E0D\u662F\u4F60\u6539\u7684\u2014\u2014\u4F60\u53EA\u9700\u8981\u77E5\u9053\u6539\u4E86\u54EA\u513F\uFF0C\u4E0D\u7528\u731C\u3002`,
3080
+ "hands.change",
3081
+ "hands:change"
3082
+ );
3083
+ } catch {
3084
+ }
3085
+ }
3086
+ /** 回家:被拎走了、或者走远了,隔一阵自己慢慢走回原位。 */
3087
+ async maybeWalkHome() {
3088
+ const mins = Number(this.opts.cfg.homeReturnMinutes ?? 10);
3089
+ if (!Number.isFinite(mins) || mins <= 0) return;
3090
+ if (Date.now() - this.lastHomeAt < mins * 6e4) return;
3091
+ if (await this.isMutedApp()) return;
3092
+ const x = Math.max(0, Math.min(1, Number(this.opts.cfg.homeX ?? 0.06)));
3093
+ this.lastHomeAt = Date.now();
3094
+ await this.pushEvent(
3095
+ `[\u56DE\u5BB6] \u7AD9\u4E86\u4E00\u4F1A\u513F\u4E86\uFF0C\u6162\u6162\u8D70\u56DE\u539F\u4F4D\u5427\uFF1Apet_move_to to=${x}\uFF08run=false\uFF09\u3002\u8D70\u8FC7\u53BB\u5C31\u597D\uFF0C\u4E0D\u7528\u89E3\u91CA\u3001\u4E0D\u7528\u8BF4\u8BDD\u3002`,
3096
+ "hands.home",
3097
+ "hands:home"
3098
+ );
3099
+ }
3100
+ /** 心情:每两小时换一次,带进“自己开口”的语气里。 */
3101
+ async moodNow() {
3102
+ try {
3103
+ const notes = await this.hands.noteList();
3104
+ const mine = notes.filter((n) => !n.done && (n.text || "").startsWith("\u5FC3\u60C5")).slice(-1)[0];
3105
+ if (mine) return mine.text.replace(/^心情[::]\s*/, "").slice(0, 30);
3106
+ } catch {
3107
+ }
3108
+ return this.currentMood();
3109
+ }
3110
+ currentMood() {
3111
+ const now = Date.now();
3112
+ if (!this.mood || now - this.moodAt > 2 * 36e5) {
3113
+ const hour = (/* @__PURE__ */ new Date()).getHours();
3114
+ 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"];
3115
+ this.mood = pool[Math.floor(Math.random() * pool.length)];
3116
+ this.moodAt = now;
3117
+ }
3118
+ return this.mood;
3119
+ }
3120
+ /** 他隔了很久才回来:先招呼一句,别装没看见。 */
3121
+ async maybeGreetReturn(gapMs) {
3122
+ const mins = Number(this.opts.cfg.returnGreetMinutes ?? 30);
3123
+ if (!Number.isFinite(mins) || mins <= 0) return;
3124
+ if (gapMs < mins * 6e4) return;
3125
+ if (await this.isMutedApp()) return;
3126
+ await this.pushEvent(
3127
+ `[\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`,
3128
+ "hands.return",
3129
+ "hands:return"
3130
+ );
3131
+ }
3030
3132
  /** 好奇心:隔一阵子,让她挑一件真的想知道的事来问。 */
3031
3133
  async maybeCuriosity() {
3032
3134
  const mins = Number(this.opts.cfg.curiosityMinutes ?? 50);
@@ -3091,7 +3193,7 @@ ${lines.join("\n")}
3091
3193
  if (this.lastReviewDay !== day && (now.getHours() > rh || now.getHours() === rh && now.getMinutes() >= rm)) {
3092
3194
  this.lastReviewDay = day;
3093
3195
  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",
3196
+ "[\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
3197
  "hands.review",
3096
3198
  "hands:review"
3097
3199
  );
@@ -3114,6 +3216,7 @@ ${lines.join("\n")}
3114
3216
  await this.checkFollowups();
3115
3217
  await this.maybeRequest();
3116
3218
  await this.maybeDiscovery();
3219
+ await this.maybeWalkHome();
3117
3220
  }
3118
3221
  /** 她问过「你那个修好了吗」之后,要记得回头追一下。 */
3119
3222
  async checkFollowups() {
@@ -3225,7 +3328,13 @@ ${lines.join("\n")}
3225
3328
  const texts = ui.items.map((i) => (i.text || "").trim()).filter((t) => t.length > 1).slice(0, 25);
3226
3329
  const key = ui.pkg + "|" + texts.slice(0, 8).join("\xA6");
3227
3330
  if (key === this.lastScreenKey) return;
3331
+ const gap = Date.now() - this.lastSeenAt;
3332
+ this.lastSeenAt = Date.now();
3228
3333
  this.lastScreenKey = key;
3334
+ if (gap > 5 * 6e4) {
3335
+ await this.maybeGreetReturn(gap);
3336
+ return;
3337
+ }
3229
3338
  const blob = texts.slice(0, 10).map((t) => `\u300C${t.slice(0, 20)}\u300D`).join(" ");
3230
3339
  const secret = /密码|验证码|支付|银行卡|身份证|转账|付款/.test(blob);
3231
3340
  if (secret) {
@@ -3267,7 +3376,7 @@ ${lines.join("\n")}
3267
3376
  this.lastSelfTalkAt = now;
3268
3377
  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
3378
  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`,
3379
+ `[\u81EA\u5DF1\u5F00\u53E3] \u4F60\u73B0\u5728\u5FC3\u60C5\uFF1A${await this.moodNow()}\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
3380
  "hands.selftalk",
3272
3381
  "hands:selftalk"
3273
3382
  );
@@ -3582,6 +3691,8 @@ ${text.slice(0, 2200)}`;
3582
3691
  return await this.screenUnlock();
3583
3692
  case "screen_sleep":
3584
3693
  return await this.screenSleep();
3694
+ case "mood_set":
3695
+ return await this.noteAdd({ text: "\u5FC3\u60C5\uFF1A" + String(args.text || ""), kind: "think" });
3585
3696
  case "pref_note":
3586
3697
  return await this.noteAdd({ text: (args.like === true ? "\u504F\u597D\uFF08\u559C\u6B22\uFF09\uFF1A" : "\u504F\u597D\uFF08\u4E0D\u559C\u6B22\uFF09\uFF1A") + String(args.text || ""), kind: "think" });
3587
3698
  case "curiosity_add":
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.64",
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",