cortico-world-hands 0.20.0 → 0.20.2

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 +57 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -125,6 +125,18 @@ var HANDS_CONFIG_GROUP = {
125
125
  description: '\u4F8B\u5982 rish -c "{cmd}" \u6216 adb -s 127.0.0.1:5555 shell "{cmd}"\u3002{cmd} \u4F1A\u6362\u6210\u4E00\u6761\u5DF2\u7ECF\u6821\u9A8C\u8FC7\u7684 input \u547D\u4EE4\u3002',
126
126
  "x-hot": false
127
127
  },
128
+ [`${K}.skinPackUrl`]: {
129
+ type: "string",
130
+ title: "\u670D\u88C5\u5305\u5730\u5740",
131
+ description: "\u586B\u4E86\u5C31\u5728\u4E16\u754C\u542F\u52A8\u65F6\u81EA\u52A8\u88C5\uFF08\u672C\u5730 HTTP \u4E5F\u884C\uFF0C\u6BD4\u5982 http://127.0.0.1:18080\uFF09\u3002",
132
+ "x-hot": true
133
+ },
134
+ [`${K}.qqOwner`]: {
135
+ type: "string",
136
+ title: "\u4E3B\u4EBA\u7684 QQ \u540D\u5B57",
137
+ description: "\u7528\u6765\u533A\u5206\u300C\u4E3B\u4EBA\u7684\u6307\u4EE4\u300D\u548C\u300C\u522B\u4EBA\u7684\u6D88\u606F\u300D\u3002",
138
+ "x-hot": true
139
+ },
128
140
  [`${K}.token`]: {
129
141
  type: "string",
130
142
  title: "\u624B\u52BF\u4EE4\u724C",
@@ -221,9 +233,9 @@ var HANDS_LOOK_CONFIG_GROUP = {
221
233
  };
222
234
 
223
235
  // src/world.ts
224
- import { writeFileSync } from "node:fs";
236
+ import { writeFileSync as writeFileSync2 } from "node:fs";
225
237
  import { fileURLToPath } from "node:url";
226
- import { join } from "node:path";
238
+ import { join as join2 } from "node:path";
227
239
 
228
240
  // src/policy.ts
229
241
  var PASS_RULES = [
@@ -501,9 +513,46 @@ var Honcho = class {
501
513
  }
502
514
  };
503
515
 
516
+ // src/stores.ts
517
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
518
+ import { join } from "node:path";
519
+ var JsonStore = class {
520
+ file;
521
+ fallback;
522
+ cached = null;
523
+ constructor(dir, name, fallback) {
524
+ this.fallback = fallback;
525
+ try {
526
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
527
+ } catch {
528
+ }
529
+ this.file = join(dir, name);
530
+ }
531
+ read() {
532
+ if (this.cached) return this.cached;
533
+ try {
534
+ if (existsSync(this.file)) {
535
+ const raw = JSON.parse(readFileSync(this.file, "utf8"));
536
+ this.cached = raw ?? this.fallback;
537
+ return this.cached;
538
+ }
539
+ } catch {
540
+ }
541
+ this.cached = this.fallback;
542
+ return this.cached;
543
+ }
544
+ write(value) {
545
+ this.cached = value;
546
+ try {
547
+ writeFileSync(this.file, JSON.stringify(value, null, 2));
548
+ } catch {
549
+ }
550
+ }
551
+ };
552
+
504
553
  // src/hands.ts
505
554
  import { execFile } from "node:child_process";
506
- import { readFileSync } from "node:fs";
555
+ import { readFileSync as readFileSync2 } from "node:fs";
507
556
  import { get as httpGet, request as httpRequest } from "node:http";
508
557
  var ACTION_TIMEOUT_MS = 6e3;
509
558
  var PROBE_TTL_MS = 2e4;
@@ -904,7 +953,7 @@ var Hands = class {
904
953
  if (Date.now() - this.tokenCache.at < 3e4) return this.tokenCache.value;
905
954
  let value = "";
906
955
  try {
907
- const text = readFileSync(file, "utf8").trim();
956
+ const text = readFileSync2(file, "utf8").trim();
908
957
  if (text && text.length <= 200) value = text;
909
958
  } catch {
910
959
  value = "";
@@ -2036,8 +2085,8 @@ var HandsWorld = class {
2036
2085
  try {
2037
2086
  const old = readPersona(dir);
2038
2087
  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);
2088
+ if (old) writeFileSync2(join2(dir, `CONSTITUTION.bak.${stamp}.md`), old);
2089
+ writeFileSync2(join2(dir, "CONSTITUTION.md"), content);
2041
2090
  return `\u4EBA\u683C\u6362\u597D\u4E86\uFF08\u65E7\u7248\u5907\u4EFD\u6210 CONSTITUTION.bak.${stamp}.md\uFF09`;
2042
2091
  } catch (err) {
2043
2092
  return failed("\u5199\u4E0D\u8FDB\u53BB\uFF1A" + String(err).slice(0, 120));
@@ -2052,7 +2101,7 @@ var HandsWorld = class {
2052
2101
  try {
2053
2102
  const rows = await this.hands.memorySearch();
2054
2103
  lines = rows.length;
2055
- const target = join(dir, "\u8BB0\u5FC6\u5E93.md");
2104
+ const target = join2(dir, "\u8BB0\u5FC6\u5E93.md");
2056
2105
  const r = mergeMemorySection(target, rows);
2057
2106
  if (r.wrote) wrote.push("\u8BB0\u5FC6\u5E93.md");
2058
2107
  const persona = readPersona(dir);
@@ -2223,7 +2272,7 @@ ${lines.join("\n")}
2223
2272
  mediaDir() {
2224
2273
  const base = this.opts.dataDir;
2225
2274
  if (!base) return null;
2226
- const dir = base.endsWith("/data") ? join(base, "media") : join(base, "data", "media");
2275
+ const dir = base.endsWith("/data") ? join2(base, "media") : join2(base, "data", "media");
2227
2276
  return dir;
2228
2277
  }
2229
2278
  /** 钩子 5:QQ 在后台收到的消息,原样递给她;谁来的一眼能看清。 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.20.0",
3
+ "version": "0.20.2",
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",