cortico-world-hands 0.20.64 → 0.20.65

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 +19 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2656,6 +2656,8 @@ var HandsWorld = class {
2656
2656
  lastDiscoveryDay = "";
2657
2657
  lastSeenAt = Date.now();
2658
2658
  lastHomeAt = Date.now();
2659
+ lastProactiveAt = 0;
2660
+ proactiveGapMs = 10 * 6e4;
2659
2661
  mood = "";
2660
2662
  moodAt = 0;
2661
2663
  requestsToday = 0;
@@ -3054,6 +3056,7 @@ ${lines.join("\n")}
3054
3056
  }
3055
3057
  /** 今日小发现:留意他今天的一个小细节,晚上说给他听。 */
3056
3058
  async maybeDiscovery() {
3059
+ if (!this.canProactive()) return;
3057
3060
  const hourWanted = Number(this.opts.cfg.discoveryHour ?? 21);
3058
3061
  if (!Number.isFinite(hourWanted) || hourWanted <= 0) return;
3059
3062
  const now = /* @__PURE__ */ new Date();
@@ -3062,12 +3065,20 @@ ${lines.join("\n")}
3062
3065
  if (now.getHours() !== hourWanted) return;
3063
3066
  if (await this.isMutedApp()) return;
3064
3067
  this.lastDiscoveryDay = day;
3068
+ this.markProactive();
3065
3069
  await this.pushEvent(
3066
3070
  "[\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",
3067
3071
  "hands.discovery",
3068
3072
  "hands:discovery"
3069
3073
  );
3070
3074
  }
3075
+ /** 主动事件之间至少隔 10 分钟:别好奇、请求、小发现连着砸过来。 */
3076
+ canProactive() {
3077
+ return Date.now() - this.lastProactiveAt > this.proactiveGapMs;
3078
+ }
3079
+ markProactive() {
3080
+ this.lastProactiveAt = Date.now();
3081
+ }
3071
3082
  /** 启动时如果最近被改过,先告诉她改了哪块,不用她猜。 */
3072
3083
  async announceChanges() {
3073
3084
  try {
@@ -3085,12 +3096,14 @@ ${lines.join("\n")}
3085
3096
  }
3086
3097
  /** 回家:被拎走了、或者走远了,隔一阵自己慢慢走回原位。 */
3087
3098
  async maybeWalkHome() {
3099
+ if (!this.canProactive()) return;
3088
3100
  const mins = Number(this.opts.cfg.homeReturnMinutes ?? 10);
3089
3101
  if (!Number.isFinite(mins) || mins <= 0) return;
3090
3102
  if (Date.now() - this.lastHomeAt < mins * 6e4) return;
3091
3103
  if (await this.isMutedApp()) return;
3092
3104
  const x = Math.max(0, Math.min(1, Number(this.opts.cfg.homeX ?? 0.06)));
3093
3105
  this.lastHomeAt = Date.now();
3106
+ this.markProactive();
3094
3107
  await this.pushEvent(
3095
3108
  `[\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
3109
  "hands.home",
@@ -3131,6 +3144,7 @@ ${lines.join("\n")}
3131
3144
  }
3132
3145
  /** 好奇心:隔一阵子,让她挑一件真的想知道的事来问。 */
3133
3146
  async maybeCuriosity() {
3147
+ if (!this.canProactive()) return;
3134
3148
  const mins = Number(this.opts.cfg.curiosityMinutes ?? 50);
3135
3149
  if (!Number.isFinite(mins) || mins <= 0) return;
3136
3150
  if (await this.isMutedApp()) return;
@@ -3147,6 +3161,7 @@ ${lines.join("\n")}
3147
3161
  pending = notes.filter((n) => !n.done && n.text.startsWith("\u597D\u5947")).length;
3148
3162
  } catch {
3149
3163
  }
3164
+ this.markProactive();
3150
3165
  await this.pushEvent(
3151
3166
  "[\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",
3152
3167
  "hands.curiosity",
@@ -3155,6 +3170,7 @@ ${lines.join("\n")}
3155
3170
  }
3156
3171
  /** 主动请求:一天最多几次,把「想请他做的小事」说出来。 */
3157
3172
  async maybeRequest() {
3173
+ if (!this.canProactive()) return;
3158
3174
  const perDay = Number(this.opts.cfg.requestPerDay ?? 2);
3159
3175
  if (!Number.isFinite(perDay) || perDay <= 0) return;
3160
3176
  if (await this.isMutedApp()) return;
@@ -3176,6 +3192,7 @@ ${lines.join("\n")}
3176
3192
  } catch {
3177
3193
  }
3178
3194
  this.requestsToday += 1;
3195
+ this.markProactive();
3179
3196
  await this.pushEvent(
3180
3197
  "[\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",
3181
3198
  "hands.request",
@@ -3364,6 +3381,7 @@ ${lines.join("\n")}
3364
3381
  }
3365
3382
  /** 隔一阵子允许她自己开口一次(尊重"没人找就别开口":只在白天、且真的隔了很久)。 */
3366
3383
  async maybeSelfTalk() {
3384
+ if (!this.canProactive()) return;
3367
3385
  const minutes = Number(this.opts.cfg.selfTalkMinutes ?? 0);
3368
3386
  if (!Number.isFinite(minutes) || minutes <= 0) return;
3369
3387
  const now = Date.now();
@@ -3375,6 +3393,7 @@ ${lines.join("\n")}
3375
3393
  if (await this.isMutedApp()) return;
3376
3394
  this.lastSelfTalkAt = now;
3377
3395
  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)];
3396
+ this.markProactive();
3378
3397
  await this.pushEvent(
3379
3398
  `[\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`,
3380
3399
  "hands.selftalk",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.20.64",
3
+ "version": "0.20.65",
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",