cortico-world-hands 0.20.60 → 0.20.61

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 +102 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -40,6 +40,10 @@ var HANDS_DEFAULTS = {
40
40
  goalCheckHours: "12,20",
41
41
  /** 允许她自己决定动手(只读 + 小动作,边界写在她的规矩里)。 */
42
42
  autonomyAct: true,
43
+ /** 隔多久让她好奇一次(分钟)。 */
44
+ curiosityMinutes: 50,
45
+ /** 每天最多几次主动请求。 */
46
+ requestPerDay: 2,
43
47
  /** 这些应用在前台时她闭嘴(只推事件不说话),逗号分隔的包名。 */
44
48
  quietApps: "com.tencent.tmgp.dfm",
45
49
  quietStartHour: 2,
@@ -193,6 +197,18 @@ var HANDS_CONFIG_GROUP = {
193
197
  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
198
  "x-hot": true
195
199
  },
200
+ [`${K}.curiosityMinutes`]: {
201
+ type: "number",
202
+ title: "\u9694\u591A\u4E45\u597D\u5947\u4E00\u6B21\uFF08\u5206\u949F\uFF09",
203
+ 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
+ "x-hot": true
205
+ },
206
+ [`${K}.requestPerDay`]: {
207
+ type: "number",
208
+ title: "\u6BCF\u5929\u6700\u591A\u51E0\u6B21\u201C\u60F3\u8BF7\u4F60\u201D",
209
+ 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",
210
+ "x-hot": true
211
+ },
196
212
  [`${K}.quietApps`]: {
197
213
  type: "string",
198
214
  title: "\u8FD9\u4E9B App \u5728\u524D\u53F0\u65F6\u5979\u95ED\u5634",
@@ -2516,6 +2532,26 @@ var HANDS_TOOL_DECLS = [
2516
2532
  },
2517
2533
  required: ["steps"]
2518
2534
  }
2535
+ },
2536
+ {
2537
+ name: "curiosity_add",
2538
+ tags: ["act"],
2539
+ 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",
2540
+ parameters: {
2541
+ type: "object",
2542
+ properties: { text: { type: "string", description: "\u60F3\u77E5\u9053\u7684\uFF0C\u6BD4\u5982\u300C\u4ED6\u7684\u952E\u76D8\u7528\u4E86\u591A\u4E45\u4E86\u300D" } },
2543
+ required: ["text"]
2544
+ }
2545
+ },
2546
+ {
2547
+ name: "request_add",
2548
+ tags: ["act"],
2549
+ 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",
2550
+ parameters: {
2551
+ type: "object",
2552
+ properties: { text: { type: "string", description: "\u60F3\u8BF7\u4ED6\u505A\u7684\u4E8B" } },
2553
+ required: ["text"]
2554
+ }
2519
2555
  }
2520
2556
  ];
2521
2557
 
@@ -2559,6 +2595,10 @@ var HandsWorld = class {
2559
2595
  lastReviewDay = "";
2560
2596
  lastMorningDay = "";
2561
2597
  lastGoalSlot = "";
2598
+ curiosityTimer = null;
2599
+ lastCuriosityAt = 0;
2600
+ lastRequestDay = "";
2601
+ requestsToday = 0;
2562
2602
  followingUp = /* @__PURE__ */ new Set();
2563
2603
  screenTimer = null;
2564
2604
  lastScreenAt = 0;
@@ -2637,6 +2677,9 @@ var HandsWorld = class {
2637
2677
  this.routineTimer = setInterval(() => {
2638
2678
  void this.tickRoutine();
2639
2679
  }, 6e4);
2680
+ this.curiosityTimer = setInterval(() => {
2681
+ void this.maybeCuriosity();
2682
+ }, 5 * 6e4);
2640
2683
  setTimeout(() => {
2641
2684
  void this.maybeCleanMedia();
2642
2685
  }, 2e4);
@@ -2662,6 +2705,7 @@ var HandsWorld = class {
2662
2705
  if (this.screenTimer) clearInterval(this.screenTimer);
2663
2706
  if (this.keepNotesTimer) clearInterval(this.keepNotesTimer);
2664
2707
  if (this.routineTimer) clearInterval(this.routineTimer);
2708
+ if (this.curiosityTimer) clearInterval(this.curiosityTimer);
2665
2709
  this.pollTimer = null;
2666
2710
  this.mineTimer = null;
2667
2711
  }
@@ -2945,6 +2989,59 @@ ${lines.join("\n")}
2945
2989
  );
2946
2990
  }
2947
2991
  }
2992
+ /** 好奇心:隔一阵子,让她挑一件真的想知道的事来问。 */
2993
+ async maybeCuriosity() {
2994
+ const mins = Number(this.opts.cfg.curiosityMinutes ?? 50);
2995
+ if (!Number.isFinite(mins) || mins <= 0) return;
2996
+ if (await this.isMutedApp()) return;
2997
+ const hour = (/* @__PURE__ */ new Date()).getHours();
2998
+ const q0 = Number(this.opts.cfg.quietStartHour ?? 2);
2999
+ const q1 = Number(this.opts.cfg.quietEndHour ?? 7);
3000
+ if (hour >= q0 && hour < q1) return;
3001
+ const now = Date.now();
3002
+ if (now - this.lastCuriosityAt < mins * 6e4) return;
3003
+ this.lastCuriosityAt = now;
3004
+ let pending = 0;
3005
+ try {
3006
+ const notes = await this.hands.noteList();
3007
+ pending = notes.filter((n) => !n.done && n.text.startsWith("\u597D\u5947")).length;
3008
+ } catch {
3009
+ }
3010
+ await this.pushEvent(
3011
+ "[\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",
3012
+ "hands.curiosity",
3013
+ "hands:curiosity"
3014
+ );
3015
+ }
3016
+ /** 主动请求:一天最多几次,把「想请他做的小事」说出来。 */
3017
+ async maybeRequest() {
3018
+ const perDay = Number(this.opts.cfg.requestPerDay ?? 2);
3019
+ if (!Number.isFinite(perDay) || perDay <= 0) return;
3020
+ if (await this.isMutedApp()) return;
3021
+ const now = /* @__PURE__ */ new Date();
3022
+ const day = now.toISOString().slice(0, 10);
3023
+ if (this.lastRequestDay !== day) {
3024
+ this.lastRequestDay = day;
3025
+ this.requestsToday = 0;
3026
+ }
3027
+ if (this.requestsToday >= perDay) return;
3028
+ const hour = now.getHours();
3029
+ if (hour < 9 || hour > 23) return;
3030
+ if (Math.random() > 0.18) return;
3031
+ let pick = "";
3032
+ try {
3033
+ const notes = await this.hands.noteList();
3034
+ const reqs = notes.filter((n) => !n.done && n.text.startsWith("\u60F3\u8BF7\u4ED6"));
3035
+ if (reqs.length) pick = reqs[0].text.replace(/^想请他[::]?/, "").trim();
3036
+ } catch {
3037
+ }
3038
+ this.requestsToday += 1;
3039
+ await this.pushEvent(
3040
+ "[\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",
3041
+ "hands.request",
3042
+ "hands:request"
3043
+ );
3044
+ }
2948
3045
  /** 每天 23:30 收工复盘、早上先读复盘、隔一阵检查她自己定的目标。 */
2949
3046
  async tickRoutine() {
2950
3047
  if (await this.isMutedApp()) return;
@@ -2977,6 +3074,7 @@ ${lines.join("\n")}
2977
3074
  await this.checkOwnGoals();
2978
3075
  }
2979
3076
  await this.checkFollowups();
3077
+ await this.maybeRequest();
2980
3078
  }
2981
3079
  /** 她问过「你那个修好了吗」之后,要记得回头追一下。 */
2982
3080
  async checkFollowups() {
@@ -3445,6 +3543,10 @@ ${text.slice(0, 2200)}`;
3445
3543
  return await this.screenUnlock();
3446
3544
  case "screen_sleep":
3447
3545
  return await this.screenSleep();
3546
+ case "curiosity_add":
3547
+ return await this.noteAdd({ text: "\u597D\u5947\uFF1A" + String(args.text || ""), kind: "think" });
3548
+ case "request_add":
3549
+ return await this.noteAdd({ text: "\u60F3\u8BF7\u4ED6\uFF1A" + String(args.text || ""), kind: "say" });
3448
3550
  case "hand_chain":
3449
3551
  return await this.handChain(args);
3450
3552
  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.61",
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",