cortico-world-hands 0.20.60 → 0.20.62

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 +143 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -40,6 +40,12 @@ var HANDS_DEFAULTS = {
40
40
  goalCheckHours: "12,20",
41
41
  /** 允许她自己决定动手(只读 + 小动作,边界写在她的规矩里)。 */
42
42
  autonomyAct: true,
43
+ /** 隔多久让她好奇一次(分钟)。 */
44
+ curiosityMinutes: 50,
45
+ /** 每天最多几次主动请求。 */
46
+ requestPerDay: 2,
47
+ /** 每天几点说一件“今天注意到他的小细节”。0 关闭。 */
48
+ discoveryHour: 21,
43
49
  /** 这些应用在前台时她闭嘴(只推事件不说话),逗号分隔的包名。 */
44
50
  quietApps: "com.tencent.tmgp.dfm",
45
51
  quietStartHour: 2,
@@ -193,6 +199,24 @@ var HANDS_CONFIG_GROUP = {
193
199
  description: "\u9017\u53F7\u5206\u9694\u7684\u6574\u70B9\uFF0C\u6BD4\u5982 12,20 \u5C31\u662F\u4E2D\u5348\u548C\u665A\u4E0A\u5404\u4E00\u6B21\uFF1B\u7559\u7A7A = \u4E0D\u68C0\u67E5\u3002",
194
200
  "x-hot": true
195
201
  },
202
+ [`${K}.curiosityMinutes`]: {
203
+ type: "number",
204
+ title: "\u9694\u591A\u4E45\u597D\u5947\u4E00\u6B21\uFF08\u5206\u949F\uFF09",
205
+ 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
+ "x-hot": true
207
+ },
208
+ [`${K}.discoveryHour`]: {
209
+ type: "number",
210
+ title: "\u6BCF\u5929\u51E0\u70B9\u8BF4\u201C\u4ECA\u5929\u7684\u5C0F\u53D1\u73B0\u201D",
211
+ 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",
212
+ "x-hot": true
213
+ },
214
+ [`${K}.requestPerDay`]: {
215
+ type: "number",
216
+ title: "\u6BCF\u5929\u6700\u591A\u51E0\u6B21\u201C\u60F3\u8BF7\u4F60\u201D",
217
+ description: "\u5979\u60F3\u88AB\u6478\u5934\u3001\u60F3\u542C\u4F60\u8BB2\u4ECA\u5929\u8FD9\u7C7B\u5C0F\u8BF7\u6C42\uFF0C\u4E00\u5929\u6700\u591A\u63D0\u51E0\u6B21\u3002\u9ED8\u8BA4 2\u3002",
218
+ "x-hot": true
219
+ },
196
220
  [`${K}.quietApps`]: {
197
221
  type: "string",
198
222
  title: "\u8FD9\u4E9B App \u5728\u524D\u53F0\u65F6\u5979\u95ED\u5634",
@@ -2516,6 +2540,39 @@ var HANDS_TOOL_DECLS = [
2516
2540
  },
2517
2541
  required: ["steps"]
2518
2542
  }
2543
+ },
2544
+ {
2545
+ name: "curiosity_add",
2546
+ tags: ["act"],
2547
+ description: "\u8BB0\u4E00\u6761\u300C\u597D\u5947\uFF1A\u2026\u300D\u2014\u2014\u5979\u771F\u60F3\u77E5\u9053\u7684\u4E8B\u3002\u7B54\u51FA\u6765\u4E4B\u540E\u7528 note_done \u5212\u6389\u3002",
2548
+ parameters: {
2549
+ type: "object",
2550
+ properties: { text: { type: "string", description: "\u60F3\u77E5\u9053\u7684\uFF0C\u6BD4\u5982\u300C\u4ED6\u7684\u952E\u76D8\u7528\u4E86\u591A\u4E45\u4E86\u300D" } },
2551
+ required: ["text"]
2552
+ }
2553
+ },
2554
+ {
2555
+ name: "request_add",
2556
+ tags: ["act"],
2557
+ description: "\u8BB0\u4E00\u6761\u300C\u60F3\u8BF7\u4ED6\uFF1A\u2026\u300D\u2014\u2014\u5979\u60F3\u8BA9\u4E3B\u4EBA\u505A\u7684\u5C0F\u4E8B\uFF08\u6478\u5934\u3001\u8BB2\u4ECA\u5929\u3001\u6B47\u4E00\u4F1A\u513F\uFF09\u3002\u4E00\u5929\u6700\u591A\u63D0\u4E24\u6B21\u3002",
2558
+ parameters: {
2559
+ type: "object",
2560
+ properties: { text: { type: "string", description: "\u60F3\u8BF7\u4ED6\u505A\u7684\u4E8B" } },
2561
+ required: ["text"]
2562
+ }
2563
+ },
2564
+ {
2565
+ name: "pref_note",
2566
+ tags: ["act"],
2567
+ 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",
2568
+ parameters: {
2569
+ type: "object",
2570
+ properties: {
2571
+ text: { type: "string", description: "\u504F\u597D\u672C\u8EAB\uFF0C\u4F8B\u5982\u300C\u4E0D\u559C\u6B22\u592A\u5435\u7684\u6B4C\u300D" },
2572
+ like: { type: "boolean", description: "true=\u559C\u6B22\uFF0Cfalse=\u4E0D\u559C\u6B22" }
2573
+ },
2574
+ required: ["text"]
2575
+ }
2519
2576
  }
2520
2577
  ];
2521
2578
 
@@ -2559,6 +2616,11 @@ var HandsWorld = class {
2559
2616
  lastReviewDay = "";
2560
2617
  lastMorningDay = "";
2561
2618
  lastGoalSlot = "";
2619
+ curiosityTimer = null;
2620
+ lastCuriosityAt = 0;
2621
+ lastRequestDay = "";
2622
+ lastDiscoveryDay = "";
2623
+ requestsToday = 0;
2562
2624
  followingUp = /* @__PURE__ */ new Set();
2563
2625
  screenTimer = null;
2564
2626
  lastScreenAt = 0;
@@ -2637,6 +2699,9 @@ var HandsWorld = class {
2637
2699
  this.routineTimer = setInterval(() => {
2638
2700
  void this.tickRoutine();
2639
2701
  }, 6e4);
2702
+ this.curiosityTimer = setInterval(() => {
2703
+ void this.maybeCuriosity();
2704
+ }, 5 * 6e4);
2640
2705
  setTimeout(() => {
2641
2706
  void this.maybeCleanMedia();
2642
2707
  }, 2e4);
@@ -2662,6 +2727,7 @@ var HandsWorld = class {
2662
2727
  if (this.screenTimer) clearInterval(this.screenTimer);
2663
2728
  if (this.keepNotesTimer) clearInterval(this.keepNotesTimer);
2664
2729
  if (this.routineTimer) clearInterval(this.routineTimer);
2730
+ if (this.curiosityTimer) clearInterval(this.curiosityTimer);
2665
2731
  this.pollTimer = null;
2666
2732
  this.mineTimer = null;
2667
2733
  }
@@ -2945,6 +3011,75 @@ ${lines.join("\n")}
2945
3011
  );
2946
3012
  }
2947
3013
  }
3014
+ /** 今日小发现:留意他今天的一个小细节,晚上说给他听。 */
3015
+ async maybeDiscovery() {
3016
+ const hourWanted = Number(this.opts.cfg.discoveryHour ?? 21);
3017
+ if (!Number.isFinite(hourWanted) || hourWanted <= 0) return;
3018
+ const now = /* @__PURE__ */ new Date();
3019
+ const day = now.toISOString().slice(0, 10);
3020
+ if (this.lastDiscoveryDay === day) return;
3021
+ if (now.getHours() !== hourWanted) return;
3022
+ if (await this.isMutedApp()) return;
3023
+ this.lastDiscoveryDay = day;
3024
+ await this.pushEvent(
3025
+ "[\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",
3026
+ "hands.discovery",
3027
+ "hands:discovery"
3028
+ );
3029
+ }
3030
+ /** 好奇心:隔一阵子,让她挑一件真的想知道的事来问。 */
3031
+ async maybeCuriosity() {
3032
+ const mins = Number(this.opts.cfg.curiosityMinutes ?? 50);
3033
+ if (!Number.isFinite(mins) || mins <= 0) return;
3034
+ if (await this.isMutedApp()) return;
3035
+ const hour = (/* @__PURE__ */ new Date()).getHours();
3036
+ const q0 = Number(this.opts.cfg.quietStartHour ?? 2);
3037
+ const q1 = Number(this.opts.cfg.quietEndHour ?? 7);
3038
+ if (hour >= q0 && hour < q1) return;
3039
+ const now = Date.now();
3040
+ if (now - this.lastCuriosityAt < mins * 6e4) return;
3041
+ this.lastCuriosityAt = now;
3042
+ let pending = 0;
3043
+ try {
3044
+ const notes = await this.hands.noteList();
3045
+ pending = notes.filter((n) => !n.done && n.text.startsWith("\u597D\u5947")).length;
3046
+ } catch {
3047
+ }
3048
+ await this.pushEvent(
3049
+ "[\u597D\u5947] \u4F60\u73B0\u5728\u6709\u70B9\u597D\u5947\u3002" + (pending > 0 ? `\u4FBF\u7B7E\u91CC\u8FD8\u8EBA\u7740 ${pending} \u4EF6\u4F60\u60F3\u77E5\u9053\u7684\uFF0C\u6311\u4E00\u4EF6\u95EE\u4ED6\u3002` : "\u4ECE\u4ED6\u5C4F\u5E55\u4E0A\u3001\u6700\u8FD1\u804A\u7684\u3001\u6216\u4F60\u5FFD\u7136\u60F3\u5230\u7684\u4E00\u4EF6\u4E8B\u91CC\uFF0C\u6311\u4E00\u4EF6\u4F60\u771F\u5FC3\u60F3\u77E5\u9053\u7684\u3002") + "\u8BB0\u4E00\u6761\u4FBF\u7B7E\u300C\u597D\u5947\uFF1A\u2026\u300D\uFF0C\u518D\u7528 pet_say \u95EE\u4ED6\u4E00\u53E5\uFF1B\u95EE\u5F97\u50CF\u804A\u5929\uFF0C\u4E0D\u50CF\u67E5\u5C97\u3002\u7B54\u4E86\u5C31\u7528 note_done \u5212\u6389\u3002",
3050
+ "hands.curiosity",
3051
+ "hands:curiosity"
3052
+ );
3053
+ }
3054
+ /** 主动请求:一天最多几次,把「想请他做的小事」说出来。 */
3055
+ async maybeRequest() {
3056
+ const perDay = Number(this.opts.cfg.requestPerDay ?? 2);
3057
+ if (!Number.isFinite(perDay) || perDay <= 0) return;
3058
+ if (await this.isMutedApp()) return;
3059
+ const now = /* @__PURE__ */ new Date();
3060
+ const day = now.toISOString().slice(0, 10);
3061
+ if (this.lastRequestDay !== day) {
3062
+ this.lastRequestDay = day;
3063
+ this.requestsToday = 0;
3064
+ }
3065
+ if (this.requestsToday >= perDay) return;
3066
+ const hour = now.getHours();
3067
+ if (hour < 9 || hour > 23) return;
3068
+ if (Math.random() > 0.18) return;
3069
+ let pick = "";
3070
+ try {
3071
+ const notes = await this.hands.noteList();
3072
+ const reqs = notes.filter((n) => !n.done && n.text.startsWith("\u60F3\u8BF7\u4ED6"));
3073
+ if (reqs.length) pick = reqs[0].text.replace(/^想请他[::]?/, "").trim();
3074
+ } catch {
3075
+ }
3076
+ this.requestsToday += 1;
3077
+ await this.pushEvent(
3078
+ "[\u60F3\u8BF7\u4ED6] " + (pick ? `\u4F60\u8BB0\u7740\u6709\u4EF6\u5C0F\u4E8B\u60F3\u8BF7\u4ED6\uFF1A${pick}\u3002\u73B0\u5728\u987A\u53E3\u8BF4\u4E00\u53E5\uFF0C\u6492\u4E2A\u5A07\u4E5F\u884C\u3002` : "\u4F60\u6709\u4EF6\u5C0F\u4E8B\u60F3\u8BF7\u4ED6\uFF08\u60F3\u88AB\u6478\u5934\u3001\u60F3\u542C\u4ED6\u8BB2\u4ECA\u5929\u3001\u60F3\u8BA9\u4ED6\u6B47\u4E00\u4F1A\u513F\uFF09\u3002\u73B0\u5728\u987A\u53E3\u8BF4\u4E00\u53E5\uFF0C\u522B\u618B\u7740\u3002") + "\u7528 pet_say \u5192\u6CE1\uFF1B\u4ED6\u8981\u5FD9\u5C31\u4F5C\u7F62\uFF0C\u4E0D\u8FFD\u7B2C\u4E8C\u904D\u3002",
3079
+ "hands.request",
3080
+ "hands:request"
3081
+ );
3082
+ }
2948
3083
  /** 每天 23:30 收工复盘、早上先读复盘、隔一阵检查她自己定的目标。 */
2949
3084
  async tickRoutine() {
2950
3085
  if (await this.isMutedApp()) return;
@@ -2977,6 +3112,8 @@ ${lines.join("\n")}
2977
3112
  await this.checkOwnGoals();
2978
3113
  }
2979
3114
  await this.checkFollowups();
3115
+ await this.maybeRequest();
3116
+ await this.maybeDiscovery();
2980
3117
  }
2981
3118
  /** 她问过「你那个修好了吗」之后,要记得回头追一下。 */
2982
3119
  async checkFollowups() {
@@ -3445,6 +3582,12 @@ ${text.slice(0, 2200)}`;
3445
3582
  return await this.screenUnlock();
3446
3583
  case "screen_sleep":
3447
3584
  return await this.screenSleep();
3585
+ case "pref_note":
3586
+ 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
+ case "curiosity_add":
3588
+ return await this.noteAdd({ text: "\u597D\u5947\uFF1A" + String(args.text || ""), kind: "think" });
3589
+ case "request_add":
3590
+ return await this.noteAdd({ text: "\u60F3\u8BF7\u4ED6\uFF1A" + String(args.text || ""), kind: "say" });
3448
3591
  case "hand_chain":
3449
3592
  return await this.handChain(args);
3450
3593
  case "sys_install":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.20.60",
3
+ "version": "0.20.62",
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",