cortico-world-hands 0.19.0 → 0.20.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 +45 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -221,6 +221,7 @@ var HANDS_LOOK_CONFIG_GROUP = {
221
221
  };
222
222
 
223
223
  // src/world.ts
224
+ import { writeFileSync } from "node:fs";
224
225
  import { fileURLToPath } from "node:url";
225
226
  import { join } from "node:path";
226
227
 
@@ -1895,6 +1896,25 @@ var HANDS_TOOL_DECLS = [
1895
1896
  tags: ["read"],
1896
1897
  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
1898
  parameters: { type: "object", properties: {} }
1899
+ },
1900
+ {
1901
+ name: "persona_get",
1902
+ tags: ["read"],
1903
+ description: "\u8BFB\u5979\u81EA\u5DF1\u7684\u4EBA\u683C\u539F\u6587\uFF08CONSTITUTION\uFF09\u3002",
1904
+ parameters: { type: "object", properties: {} }
1905
+ },
1906
+ {
1907
+ name: "persona_set",
1908
+ tags: ["act"],
1909
+ description: "\u6539\u5979\u81EA\u5DF1\u7684\u4EBA\u683C\u539F\u6587\u3002\u4F1A\u5148\u5907\u4EFD\u65E7\u7248\u5230\u5DE5\u4F5C\u533A CONSTITUTION.bak.<\u65F6\u95F4>\uFF0C\u518D\u5199\u5165\u3002\u6574\u6BB5\u66FF\u6362\uFF0C\u4E0D\u662F\u8FFD\u52A0\u3002",
1910
+ parameters: {
1911
+ type: "object",
1912
+ properties: {
1913
+ content: { type: "string", description: "\u65B0\u7684\u5B8C\u6574\u4EBA\u683C\u6587\u672C" },
1914
+ why: { type: "string", description: "\u4E3A\u4EC0\u4E48\u6539\uFF08\u8BB0\u4E00\u7B14\uFF09" }
1915
+ },
1916
+ required: ["content"]
1917
+ }
1898
1918
  }
1899
1919
  ];
1900
1920
 
@@ -2002,6 +2022,27 @@ var HandsWorld = class {
2002
2022
  this.mineTimer = null;
2003
2023
  }
2004
2024
  /** 每 30 秒看一次:日程到点投一条,早安/晚安/纪念日各一次。 */
2025
+ /** 读人格原文。 */
2026
+ async personaGet() {
2027
+ const dir = this.opts.botDir || this.opts.dataDir || ".";
2028
+ const text = readPersona(dir);
2029
+ return text ? text.slice(0, 6e3) : "\u5DE5\u4F5C\u533A\u91CC\u6CA1\u6709 CONSTITUTION.md";
2030
+ }
2031
+ /** 改人格原文:先备份,再整段替换。 */
2032
+ async personaSet(args) {
2033
+ const content = typeof args.content === "string" ? args.content.trim() : "";
2034
+ if (content.length < 200) return failed("\u4EBA\u683C\u592A\u77ED\u4E86\uFF08\u81F3\u5C11\u4E24\u767E\u5B57\uFF09\uFF0C\u628A\u6574\u6BB5\u5199\u5B8C\u6574\u518D\u7ED9\u6211\u3002");
2035
+ const dir = this.opts.botDir || this.opts.dataDir || ".";
2036
+ try {
2037
+ const old = readPersona(dir);
2038
+ const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
2039
+ if (old) writeFileSync(join(dir, `CONSTITUTION.bak.${stamp}.md`), old);
2040
+ writeFileSync(join(dir, "CONSTITUTION.md"), content);
2041
+ return `\u4EBA\u683C\u6362\u597D\u4E86\uFF08\u65E7\u7248\u5907\u4EFD\u6210 CONSTITUTION.bak.${stamp}.md\uFF09`;
2042
+ } catch (err) {
2043
+ return failed("\u5199\u4E0D\u8FDB\u53BB\uFF1A" + String(err).slice(0, 120));
2044
+ }
2045
+ }
2005
2046
  /** 懿心 ↔ Coopanin:记忆推成 记忆库.md,人格原文存进懿心。 */
2006
2047
  async runSync(manual) {
2007
2048
  const dir = this.opts.botDir || this.opts.dataDir || ".";
@@ -2274,6 +2315,10 @@ ${lines.join("\n")}
2274
2315
  return await this.matchImage(args, false);
2275
2316
  case "hand_tap_image":
2276
2317
  return await this.matchImage(args, true);
2318
+ case "persona_get":
2319
+ return await this.personaGet();
2320
+ case "persona_set":
2321
+ return await this.personaSet(args);
2277
2322
  case "sync_now":
2278
2323
  return await this.runSync(true);
2279
2324
  case "sync_status":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.19.0",
3
+ "version": "0.20.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",