cortico-world-hands 0.18.0 → 0.19.0

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 +50 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -222,6 +222,7 @@ var HANDS_LOOK_CONFIG_GROUP = {
222
222
 
223
223
  // src/world.ts
224
224
  import { fileURLToPath } from "node:url";
225
+ import { join } from "node:path";
225
226
 
226
227
  // src/policy.ts
227
228
  var PASS_RULES = [
@@ -1882,6 +1883,18 @@ var HANDS_TOOL_DECLS = [
1882
1883
  tags: ["read"],
1883
1884
  description: "\u5217\u51FA\u5DF2\u8BB0\u7684\u7EAA\u5FF5\u65E5\u3002",
1884
1885
  parameters: { type: "object", properties: {} }
1886
+ },
1887
+ {
1888
+ name: "sync_now",
1889
+ tags: ["act"],
1890
+ description: "\u628A\u61FF\u5FC3\u90A3\u8FB9\u5B58\u7684\u8BB0\u5FC6\u540C\u6B65\u5230\u5DE5\u4F5C\u533A\u300C\u8BB0\u5FC6\u5E93.md\u300D\uFF0C\u5E76\u628A\u4EBA\u683C\u539F\u6587\u5907\u4EFD\u8FDB\u61FF\u5FC3\u3002\u60F3\u624B\u52A8\u5BF9\u4E00\u6B21\u65F6\u7528\u3002",
1891
+ parameters: { type: "object", properties: {} }
1892
+ },
1893
+ {
1894
+ name: "sync_status",
1895
+ tags: ["read"],
1896
+ description: "\u770B\u4E0A\u4E00\u6B21\u540C\u6B65\u662F\u4EC0\u4E48\u65F6\u5019\u3001\u540C\u6B65\u4E86\u591A\u5C11\u6761\u3001\u4EBA\u683C\u539F\u6587\u591A\u5C11\u5B57\u3002",
1897
+ parameters: { type: "object", properties: {} }
1885
1898
  }
1886
1899
  ];
1887
1900
 
@@ -1904,6 +1917,8 @@ var HandsWorld = class {
1904
1917
  recent = [];
1905
1918
  honchoClient = null;
1906
1919
  agendaTimer = null;
1920
+ syncTimer = null;
1921
+ lastSync = null;
1907
1922
  agenda;
1908
1923
  affinity;
1909
1924
  ritual;
@@ -1955,6 +1970,12 @@ var HandsWorld = class {
1955
1970
  this.agendaTimer = setInterval(() => {
1956
1971
  void this.checkAgenda();
1957
1972
  }, 3e4);
1973
+ this.syncTimer = setInterval(() => {
1974
+ void this.runSync(false);
1975
+ }, 10 * 60 * 1e3);
1976
+ setTimeout(() => {
1977
+ void this.runSync(false);
1978
+ }, 45e3);
1958
1979
  this.pollTimer = setInterval(() => {
1959
1980
  void this.pollUserSpeech();
1960
1981
  }, 5e3);
@@ -1981,6 +2002,30 @@ var HandsWorld = class {
1981
2002
  this.mineTimer = null;
1982
2003
  }
1983
2004
  /** 每 30 秒看一次:日程到点投一条,早安/晚安/纪念日各一次。 */
2005
+ /** 懿心 ↔ Coopanin:记忆推成 记忆库.md,人格原文存进懿心。 */
2006
+ async runSync(manual) {
2007
+ const dir = this.opts.botDir || this.opts.dataDir || ".";
2008
+ const wrote = [];
2009
+ let lines = 0;
2010
+ let personaChars = 0;
2011
+ try {
2012
+ const rows = await this.hands.memorySearch();
2013
+ lines = rows.length;
2014
+ const target = join(dir, "\u8BB0\u5FC6\u5E93.md");
2015
+ const r = mergeMemorySection(target, rows);
2016
+ if (r.wrote) wrote.push("\u8BB0\u5FC6\u5E93.md");
2017
+ const persona = readPersona(dir);
2018
+ personaChars = persona.length;
2019
+ if (persona) {
2020
+ await this.hands.memorySave("\u4EBA\u683C\u539F\u6587", persona.slice(0, 12e3), "\u4EBA\u683C,\u540C\u6B65");
2021
+ wrote.push("\u4EBA\u683C\u539F\u6587\u2192\u61FF\u5FC3");
2022
+ }
2023
+ this.lastSync = { at: (/* @__PURE__ */ new Date()).toISOString(), lines, persona: personaChars };
2024
+ return `${manual ? "" : ""}\u540C\u6B65\u5B8C\u6210\uFF1A\u8BB0\u5FC6 ${lines} \u6761\uFF0C\u4EBA\u683C\u539F\u6587 ${personaChars} \u5B57${wrote.length ? "\uFF0C\u66F4\u65B0\u4E86 " + wrote.join("\u3001") : "\uFF0C\u6CA1\u6709\u53D8\u5316"}`;
2025
+ } catch (err) {
2026
+ return "\u540C\u6B65\u5931\u8D25\uFF1A" + String(err).slice(0, 120);
2027
+ }
2028
+ }
1984
2029
  async checkAgenda() {
1985
2030
  const now = /* @__PURE__ */ new Date();
1986
2031
  const iso = now.toISOString();
@@ -2229,6 +2274,10 @@ ${lines.join("\n")}
2229
2274
  return await this.matchImage(args, false);
2230
2275
  case "hand_tap_image":
2231
2276
  return await this.matchImage(args, true);
2277
+ case "sync_now":
2278
+ return await this.runSync(true);
2279
+ case "sync_status":
2280
+ return this.lastSync ? `\u4E0A\u6B21\u540C\u6B65 ${this.lastSync.at.slice(0, 19)}\uFF0C\u8BB0\u5FC6 ${this.lastSync.lines} \u6761\uFF0C\u4EBA\u683C ${this.lastSync.persona} \u5B57` : "\u8FD8\u6CA1\u540C\u6B65\u8FC7";
2232
2281
  case "hand_see":
2233
2282
  return await this.see();
2234
2283
  case "hand_look":
@@ -2912,7 +2961,7 @@ function handsDefinition() {
2912
2961
  id: HANDS_ID,
2913
2962
  label: "\u624B",
2914
2963
  defaults: () => structuredClone(HANDS_DEFAULTS),
2915
- create: (ctx) => new HandsWorld({ cfg: ctx.cfg, timezone: ctx.timezone, roots: [ctx.botDir, ctx.dataDir, ctx.repoRoot, ctx.packageDir], dataDir: ctx.dataDir })
2964
+ create: (ctx) => new HandsWorld({ cfg: ctx.cfg, timezone: ctx.timezone, roots: [ctx.botDir, ctx.dataDir, ctx.repoRoot, ctx.packageDir], botDir: ctx.botDir, dataDir: ctx.dataDir })
2916
2965
  };
2917
2966
  }
2918
2967
  var HANDS = handsDefinition();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
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",