cortico-world-hands 0.20.48 → 0.20.49

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 +29 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -40,6 +40,8 @@ var HANDS_DEFAULTS = {
40
40
  goalCheckHours: "12,20",
41
41
  /** 允许她自己决定动手(只读 + 小动作,边界写在她的规矩里)。 */
42
42
  autonomyAct: true,
43
+ /** 这些应用在前台时她闭嘴(只推事件不说话),逗号分隔的包名。 */
44
+ quietApps: "com.tencent.tmgp.dfm",
43
45
  quietStartHour: 2,
44
46
  quietEndHour: 7,
45
47
  qqSelf: "\u665A\u6C50",
@@ -191,6 +193,12 @@ var HANDS_CONFIG_GROUP = {
191
193
  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",
192
194
  "x-hot": true
193
195
  },
196
+ [`${K}.quietApps`]: {
197
+ type: "string",
198
+ title: "\u8FD9\u4E9B App \u5728\u524D\u53F0\u65F6\u5979\u95ED\u5634",
199
+ description: "\u9017\u53F7\u5206\u9694\u7684\u5305\u540D\uFF1B\u9ED8\u8BA4\u4E09\u89D2\u6D32\u884C\u52A8 com.tencent.tmgp.dfm\u3002\u7559\u7A7A = \u4E0D\u9650\u5236\u3002",
200
+ "x-hot": true
201
+ },
194
202
  [`${K}.autonomyAct`]: {
195
203
  type: "boolean",
196
204
  title: "\u5141\u8BB8\u5979\u81EA\u5DF1\u52A8\u624B",
@@ -2458,6 +2466,7 @@ var HandsWorld = class {
2458
2466
  lastScreenAt = 0;
2459
2467
  lastScreenKey = "";
2460
2468
  handDown = null;
2469
+ fgCache = { pkg: "", at: 0 };
2461
2470
  lastMediaDay = "";
2462
2471
  cursor = 0;
2463
2472
  lastHitKey = "";
@@ -2840,6 +2849,7 @@ ${lines.join("\n")}
2840
2849
  }
2841
2850
  /** 每天 23:30 收工复盘、早上先读复盘、隔一阵检查她自己定的目标。 */
2842
2851
  async tickRoutine() {
2852
+ if (await this.isMutedApp()) return;
2843
2853
  const cfg = this.opts.cfg;
2844
2854
  const now = /* @__PURE__ */ new Date();
2845
2855
  const day = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
@@ -2890,10 +2900,27 @@ ${lines.join("\n")}
2890
2900
  "hands:goal"
2891
2901
  );
2892
2902
  }
2903
+ /** 现在前台是不是"该闭嘴"的 App(比如他在打三角洲)。 */
2904
+ async isMutedApp() {
2905
+ const list = String(this.opts.cfg.quietApps ?? "").split(",").map((x) => x.trim().toLowerCase()).filter(Boolean);
2906
+ if (!list.length) return false;
2907
+ const now = Date.now();
2908
+ if (now - this.fgCache.at > 1e4) {
2909
+ try {
2910
+ const ui = await this.hands.uiSnapshot();
2911
+ this.fgCache = { pkg: (ui.pkg || "").toLowerCase(), at: now };
2912
+ } catch {
2913
+ this.fgCache = { pkg: "", at: now };
2914
+ }
2915
+ }
2916
+ if (!this.fgCache.pkg) return false;
2917
+ return list.some((p) => this.fgCache.pkg.includes(p));
2918
+ }
2893
2919
  /** 隔一阵子提醒她把这段值得留的写进便签,防止交接后忘掉。 */
2894
2920
  async maybeKeepNotes() {
2895
2921
  const mins = Number(this.opts.cfg.keepNotesMinutes ?? 20);
2896
2922
  if (!Number.isFinite(mins) || mins <= 0) return;
2923
+ if (await this.isMutedApp()) return;
2897
2924
  const now = Date.now();
2898
2925
  if (now - this.lastKeepNotesAt < mins * 6e4) return;
2899
2926
  const hour = new Date(now).getHours();
@@ -2909,6 +2936,7 @@ ${lines.join("\n")}
2909
2936
  }
2910
2937
  /** 隔一会儿看一眼屏幕:看到变化就跟主人聊,隐私画面就明说"我不看"。 */
2911
2938
  async watchScreen() {
2939
+ if (await this.isMutedApp()) return;
2912
2940
  const secs = Number(this.opts.cfg.screenWatchSeconds ?? 40);
2913
2941
  if (!Number.isFinite(secs) || secs <= 0) return;
2914
2942
  const now = Date.now();
@@ -2966,6 +2994,7 @@ ${lines.join("\n")}
2966
2994
  const q0 = Number(this.opts.cfg.quietStartHour ?? 2);
2967
2995
  const q1 = Number(this.opts.cfg.quietEndHour ?? 7);
2968
2996
  if (hour >= q0 && hour < q1) return;
2997
+ if (await this.isMutedApp()) return;
2969
2998
  this.lastSelfTalkAt = now;
2970
2999
  await this.pushEvent(
2971
3000
  "[\u81EA\u5DF1\u5F00\u53E3] \u5B89\u9759\u4E00\u9635\u4E86\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\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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.20.48",
3
+ "version": "0.20.49",
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",