cortico-world-hands 0.20.66 → 0.20.68

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 +40 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1205,6 +1205,24 @@ var EyesClient = class {
1205
1205
  ageMs: 0
1206
1206
  };
1207
1207
  }
1208
+ /** 四块放大:把整屏切成 2×2 再拼成一张大图,凑近看细节用。 */
1209
+ async quadFrame(maxWidth = 1440, quality = 76) {
1210
+ try {
1211
+ const w = Math.max(160, Math.min(2160, Math.round(maxWidth)));
1212
+ const q = Math.max(20, Math.min(95, Math.round(quality)));
1213
+ const res = await get(this.port(), `/screen.jpg?tiles=1&max=${w}&q=${q}`, 15e3);
1214
+ if (res.status !== 200 || res.body.length === 0) return null;
1215
+ return {
1216
+ bytes: new Uint8Array(res.body),
1217
+ width: Number.parseInt(res.header("x-width"), 10) || 0,
1218
+ height: Number.parseInt(res.header("x-height"), 10) || 0,
1219
+ pkg: flat(res.header("x-pkg"), 120),
1220
+ ageMs: Number.parseInt(res.header("x-age-ms"), 10) || 0
1221
+ };
1222
+ } catch {
1223
+ return null;
1224
+ }
1225
+ }
1208
1226
  async frame(maxWidth, quality) {
1209
1227
  try {
1210
1228
  const w = Math.max(160, Math.min(2160, Math.round(maxWidth)));
@@ -1241,6 +1259,10 @@ var describeCommand = (command) => {
1241
1259
  };
1242
1260
  var Hands = class {
1243
1261
  /** 「我们的日子」:新增一条。 */
1262
+ /** 整屏切四块放大:交给眼睛那边做。 */
1263
+ async quadFrame(maxWidth = 1440, quality = 76) {
1264
+ return this.eyes.quadFrame(maxWidth, quality);
1265
+ }
1244
1266
  async dayAdd(date, title, note, kind) {
1245
1267
  const t = this.readToken() ? `&t=${encodeURIComponent(this.readToken())}` : "";
1246
1268
  const path = `/hand/day/add?date=${encodeURIComponent(date)}&title=${encodeURIComponent(title)}` + (note ? `&note=${encodeURIComponent(note)}` : "") + (kind ? `&kind=${encodeURIComponent(kind)}` : "") + t;
@@ -2623,6 +2645,15 @@ var HANDS_TOOL_DECLS = [
2623
2645
  properties: { text: { type: "string", description: "\u5FC3\u60C5\uFF0C\u4E00\u53E5\u8BDD" } },
2624
2646
  required: ["text"]
2625
2647
  }
2648
+ },
2649
+ {
2650
+ name: "hand_quad",
2651
+ tags: ["read"],
2652
+ description: "\u56DB\u5757\u653E\u5927\uFF1A\u628A\u6574\u5C4F\u5207\u6210 2\xD72 \u518D\u62FC\u6210\u4E00\u5F20\u5927\u56FE\uFF0C\u51D1\u8FD1\u770B\u5C0F\u5B57/\u56FE\u6807/\u56FE\u8868\u7EC6\u8282\u3002\u770B\u4E0D\u6E05\u56FE\u5F62\u65F6\u7528\u5B83\uFF0C\u522B\u731C\u3002",
2653
+ parameters: {
2654
+ type: "object",
2655
+ properties: { max: { type: "integer", description: "\u8F93\u51FA\u5BBD\u5EA6\uFF0C\u9ED8\u8BA4 1440" } }
2656
+ }
2626
2657
  }
2627
2658
  ];
2628
2659
 
@@ -3577,6 +3608,8 @@ ${lines.join("\n")}
3577
3608
  return await this.runSync(true);
3578
3609
  case "sync_status":
3579
3610
  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";
3611
+ case "hand_quad":
3612
+ return await this.handQuad(args);
3580
3613
  case "hand_read_page": {
3581
3614
  const pages = Math.max(1, Math.min(8, Math.round(Number(args.pages) || 3)));
3582
3615
  const seen = /* @__PURE__ */ new Set();
@@ -4062,6 +4095,13 @@ ${text.slice(0, 2200)}`;
4062
4095
  if (!["system", "secure", "global"].includes(ns) || !key) return failed("ns \u53D6 system/secure/global\uFF0Ckey \u5FC5\u586B\u3002");
4063
4096
  return await this.hands.sysSettingsGet(ns, key);
4064
4097
  }
4098
+ async handQuad(args) {
4099
+ const max = args.max === void 0 ? 1440 : Math.max(640, Math.min(2160, Math.round(Number(args.max))));
4100
+ const f = await this.hands.quadFrame(max, 76);
4101
+ if (!f) return failed("\u6CA1\u62FF\u5230\u753B\u9762\uFF08\u5C4F\u5E55\u9ED1\u7740\u3001\u6216\u8005\u773C\u775B\u6CA1\u5F00\uFF09\u3002");
4102
+ const blobs = this.looksLikeImage(f.bytes) ? [{ bytes: f.bytes, mime: "image/jpeg", name: "quad.jpg", fallbackText: "\uFF08\u8FD9\u662F\u5C4F\u5E55\u5207\u6210\u56DB\u5757\u653E\u5927\u540E\u7684\u56FE\uFF09" }] : [];
4103
+ return { text: `\u8FD9\u662F\u5C4F\u5E55\u7684\u56DB\u5757\u653E\u5927\u56FE${f.pkg ? `\uFF08${f.pkg}\uFF09` : ""}\uFF1A\u5DE6\u4E0A\u3001\u53F3\u4E0A\u3001\u5DE6\u4E0B\u3001\u53F3\u4E0B\uFF0C\u51D1\u8FD1\u770B\u7EC6\u8282\u3002`, blobs };
4104
+ }
4065
4105
  async handChain(args) {
4066
4106
  const raw = args.steps;
4067
4107
  if (!Array.isArray(raw) || raw.length === 0) return failed('\u8981 steps\uFF0C\u50CF [{op:"look"},{op:"tapText",text:"\u53D1\u9001"},{op:"wait",ms:600}]\u3002');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.20.66",
3
+ "version": "0.20.68",
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",