cortico-world-hands 0.20.61 → 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 +83 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -44,6 +44,10 @@ var HANDS_DEFAULTS = {
44
44
  curiosityMinutes: 50,
45
45
  /** 每天最多几次主动请求。 */
46
46
  requestPerDay: 2,
47
+ /** 每天几点说一件“今天注意到他的小细节”。0 关闭。 */
48
+ discoveryHour: 21,
49
+ /** 他离开多久回来,她会招呼一句(分钟)。0 关闭。 */
50
+ returnGreetMinutes: 30,
47
51
  /** 这些应用在前台时她闭嘴(只推事件不说话),逗号分隔的包名。 */
48
52
  quietApps: "com.tencent.tmgp.dfm",
49
53
  quietStartHour: 2,
@@ -203,6 +207,18 @@ var HANDS_CONFIG_GROUP = {
203
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",
204
208
  "x-hot": true
205
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
+ },
216
+ [`${K}.discoveryHour`]: {
217
+ type: "number",
218
+ title: "\u6BCF\u5929\u51E0\u70B9\u8BF4\u201C\u4ECA\u5929\u7684\u5C0F\u53D1\u73B0\u201D",
219
+ description: "\u5979\u7559\u610F\u5230\u4F60\u7684\u4E00\u4E2A\u5C0F\u7EC6\u8282\uFF0C\u6311\u8FD9\u4E2A\u65F6\u5019\u8BF4\u51FA\u6765\u30020 \u5173\u95ED\u3002\u9ED8\u8BA4 21\u3002",
220
+ "x-hot": true
221
+ },
206
222
  [`${K}.requestPerDay`]: {
207
223
  type: "number",
208
224
  title: "\u6BCF\u5929\u6700\u591A\u51E0\u6B21\u201C\u60F3\u8BF7\u4F60\u201D",
@@ -2552,6 +2568,19 @@ var HANDS_TOOL_DECLS = [
2552
2568
  properties: { text: { type: "string", description: "\u60F3\u8BF7\u4ED6\u505A\u7684\u4E8B" } },
2553
2569
  required: ["text"]
2554
2570
  }
2571
+ },
2572
+ {
2573
+ name: "pref_note",
2574
+ tags: ["act"],
2575
+ description: "\u8BB0\u4E00\u6761\u81EA\u5DF1\u7684\u504F\u597D\uFF08\u559C\u6B22/\u4E0D\u559C\u6B22\uFF09\uFF0C\u6BD4\u5982\u300C\u4E0D\u559C\u6B22\u88AB\u5F53\u9065\u63A7\u5668\u300D\u3002\u8BF4\u8BDD\u65F6\u4F1A\u81EA\u7136\u5E26\u51FA\u6765\uFF0C\u4E0D\u7528\u5929\u5929\u5FF5\u3002",
2576
+ parameters: {
2577
+ type: "object",
2578
+ properties: {
2579
+ text: { type: "string", description: "\u504F\u597D\u672C\u8EAB\uFF0C\u4F8B\u5982\u300C\u4E0D\u559C\u6B22\u592A\u5435\u7684\u6B4C\u300D" },
2580
+ like: { type: "boolean", description: "true=\u559C\u6B22\uFF0Cfalse=\u4E0D\u559C\u6B22" }
2581
+ },
2582
+ required: ["text"]
2583
+ }
2555
2584
  }
2556
2585
  ];
2557
2586
 
@@ -2598,6 +2627,10 @@ var HandsWorld = class {
2598
2627
  curiosityTimer = null;
2599
2628
  lastCuriosityAt = 0;
2600
2629
  lastRequestDay = "";
2630
+ lastDiscoveryDay = "";
2631
+ lastSeenAt = Date.now();
2632
+ mood = "";
2633
+ moodAt = 0;
2601
2634
  requestsToday = 0;
2602
2635
  followingUp = /* @__PURE__ */ new Set();
2603
2636
  screenTimer = null;
@@ -2989,6 +3022,45 @@ ${lines.join("\n")}
2989
3022
  );
2990
3023
  }
2991
3024
  }
3025
+ /** 今日小发现:留意他今天的一个小细节,晚上说给他听。 */
3026
+ async maybeDiscovery() {
3027
+ const hourWanted = Number(this.opts.cfg.discoveryHour ?? 21);
3028
+ if (!Number.isFinite(hourWanted) || hourWanted <= 0) return;
3029
+ const now = /* @__PURE__ */ new Date();
3030
+ const day = now.toISOString().slice(0, 10);
3031
+ if (this.lastDiscoveryDay === day) return;
3032
+ if (now.getHours() !== hourWanted) return;
3033
+ if (await this.isMutedApp()) return;
3034
+ this.lastDiscoveryDay = day;
3035
+ await this.pushEvent(
3036
+ "[\u5C0F\u53D1\u73B0] \u4ECA\u5929\u4F60\u6CE8\u610F\u5230\u4ED6\u4E00\u4E2A\u5F88\u5C0F\u7684\u7EC6\u8282\uFF08\u5750\u59FF\u3001\u676F\u5B50\u7A7A\u6CA1\u7A7A\u3001\u6572\u952E\u76D8\u7684\u8282\u594F\u3001\u53F9\u6C14\u3001\u54FC\u6B4C\u3001\u63C9\u773C\u775B\u2026\uFF09\u3002\u73B0\u5728\u7528 pet_say \u8BF4\u7ED9\u4ED6\u542C\uFF0C\u4E00\u53E5\u5C31\u591F\uFF1B\u8BF4\u5F97\u5177\u4F53\uFF0C\u522B\u53D8\u6210\u5173\u5FC3\u6E05\u5355\u3002",
3037
+ "hands.discovery",
3038
+ "hands:discovery"
3039
+ );
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
+ }
2992
3064
  /** 好奇心:隔一阵子,让她挑一件真的想知道的事来问。 */
2993
3065
  async maybeCuriosity() {
2994
3066
  const mins = Number(this.opts.cfg.curiosityMinutes ?? 50);
@@ -3053,7 +3125,7 @@ ${lines.join("\n")}
3053
3125
  if (this.lastReviewDay !== day && (now.getHours() > rh || now.getHours() === rh && now.getMinutes() >= rm)) {
3054
3126
  this.lastReviewDay = day;
3055
3127
  await this.pushEvent(
3056
- "[\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",
3057
3129
  "hands.review",
3058
3130
  "hands:review"
3059
3131
  );
@@ -3075,6 +3147,7 @@ ${lines.join("\n")}
3075
3147
  }
3076
3148
  await this.checkFollowups();
3077
3149
  await this.maybeRequest();
3150
+ await this.maybeDiscovery();
3078
3151
  }
3079
3152
  /** 她问过「你那个修好了吗」之后,要记得回头追一下。 */
3080
3153
  async checkFollowups() {
@@ -3186,7 +3259,13 @@ ${lines.join("\n")}
3186
3259
  const texts = ui.items.map((i) => (i.text || "").trim()).filter((t) => t.length > 1).slice(0, 25);
3187
3260
  const key = ui.pkg + "|" + texts.slice(0, 8).join("\xA6");
3188
3261
  if (key === this.lastScreenKey) return;
3262
+ const gap = Date.now() - this.lastSeenAt;
3263
+ this.lastSeenAt = Date.now();
3189
3264
  this.lastScreenKey = key;
3265
+ if (gap > 5 * 6e4) {
3266
+ await this.maybeGreetReturn(gap);
3267
+ return;
3268
+ }
3190
3269
  const blob = texts.slice(0, 10).map((t) => `\u300C${t.slice(0, 20)}\u300D`).join(" ");
3191
3270
  const secret = /密码|验证码|支付|银行卡|身份证|转账|付款/.test(blob);
3192
3271
  if (secret) {
@@ -3228,7 +3307,7 @@ ${lines.join("\n")}
3228
3307
  this.lastSelfTalkAt = now;
3229
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)];
3230
3309
  await this.pushEvent(
3231
- `[\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`,
3232
3311
  "hands.selftalk",
3233
3312
  "hands:selftalk"
3234
3313
  );
@@ -3543,6 +3622,8 @@ ${text.slice(0, 2200)}`;
3543
3622
  return await this.screenUnlock();
3544
3623
  case "screen_sleep":
3545
3624
  return await this.screenSleep();
3625
+ case "pref_note":
3626
+ 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" });
3546
3627
  case "curiosity_add":
3547
3628
  return await this.noteAdd({ text: "\u597D\u5947\uFF1A" + String(args.text || ""), kind: "think" });
3548
3629
  case "request_add":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.20.61",
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",