cortico-world-hands 0.20.3 → 0.20.4
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.
- package/dist/index.js +40 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1016,6 +1016,20 @@ var EyesClient = class {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
return { ok: body.ok !== false, pkg: flat(body.pkg, 120), items };
|
|
1018
1018
|
}
|
|
1019
|
+
/** 只截一块并放大:x,y,w,h 是真实像素。 */
|
|
1020
|
+
async zoom(x, y, w, h, maxWidth = 1080, quality = 80) {
|
|
1021
|
+
const cfg = this.cfg();
|
|
1022
|
+
const path = `/screen.jpg?x=${Math.max(0, Math.round(x))}&y=${Math.max(0, Math.round(y))}&w=${Math.max(8, Math.round(w))}&h=${Math.max(8, Math.round(h))}&max=${Math.round(maxWidth)}&q=${Math.round(quality)}`;
|
|
1023
|
+
const res = await get(this.handPort(), path, 12e3);
|
|
1024
|
+
if (res.status !== 200 || res.body.length === 0) return null;
|
|
1025
|
+
return {
|
|
1026
|
+
bytes: new Uint8Array(res.body),
|
|
1027
|
+
width: Number.parseInt(res.header("x-width"), 10) || 0,
|
|
1028
|
+
height: Number.parseInt(res.header("x-height"), 10) || 0,
|
|
1029
|
+
pkg: "",
|
|
1030
|
+
ageMs: 0
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1019
1033
|
async frame(maxWidth, quality) {
|
|
1020
1034
|
try {
|
|
1021
1035
|
const w = Math.max(160, Math.min(2160, Math.round(maxWidth)));
|
|
@@ -2122,6 +2136,21 @@ var HANDS_TOOL_DECLS = [
|
|
|
2122
2136
|
},
|
|
2123
2137
|
required: ["content"]
|
|
2124
2138
|
}
|
|
2139
|
+
},
|
|
2140
|
+
{
|
|
2141
|
+
name: "hand_zoom",
|
|
2142
|
+
tags: ["read"],
|
|
2143
|
+
description: "\u53EA\u622A\u5C4F\u5E55\u7684\u4E00\u5C0F\u5757\u5E76\u653E\u5927\u2014\u2014\u5C0F\u5B57\u3001\u5C0F\u6309\u94AE\u770B\u4E0D\u6E05\u65F6\u7528\u5B83\u3002\u5148 hand_see \u62FF\u5230\u5750\u6807\uFF0C\u518D\u628A\u8FD9\u5757\u7684 x/y/\u5BBD/\u9AD8 \u4EA4\u7ED9\u5B83\u3002",
|
|
2144
|
+
parameters: {
|
|
2145
|
+
type: "object",
|
|
2146
|
+
properties: {
|
|
2147
|
+
x: { type: "integer", description: "\u5DE6\u4E0A\u89D2\u6A2A\u5750\u6807\uFF08\u771F\u5B9E\u50CF\u7D20\uFF09" },
|
|
2148
|
+
y: { type: "integer", description: "\u5DE6\u4E0A\u89D2\u7EB5\u5750\u6807" },
|
|
2149
|
+
w: { type: "integer", description: "\u5BBD" },
|
|
2150
|
+
h: { type: "integer", description: "\u9AD8" }
|
|
2151
|
+
},
|
|
2152
|
+
required: ["x", "y", "w", "h"]
|
|
2153
|
+
}
|
|
2125
2154
|
}
|
|
2126
2155
|
];
|
|
2127
2156
|
|
|
@@ -2530,6 +2559,17 @@ ${lines.join("\n")}
|
|
|
2530
2559
|
return await this.runSync(true);
|
|
2531
2560
|
case "sync_status":
|
|
2532
2561
|
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";
|
|
2562
|
+
case "hand_zoom": {
|
|
2563
|
+
const n = (v) => Math.round(Number(v));
|
|
2564
|
+
const x = n(args.x), y = n(args.y), w = n(args.w), h = n(args.h);
|
|
2565
|
+
if (![x, y, w, h].every(Number.isFinite) || w <= 0 || h <= 0) return failed("\u8981\u7ED9 x/y/w/h\uFF08\u771F\u5B9E\u50CF\u7D20\uFF09");
|
|
2566
|
+
const f = await this.hands.zoom(x, y, w, h);
|
|
2567
|
+
if (!f) return failed("\u8FD9\u4E00\u5757\u6CA1\u622A\u5230\uFF08\u5750\u6807\u53EF\u80FD\u8D85\u51FA\u5C4F\u5E55\uFF09");
|
|
2568
|
+
return {
|
|
2569
|
+
text: `\u653E\u5927\u770B @(${x},${y}) ${w}\xD7${h}`,
|
|
2570
|
+
blobs: [{ bytes: f.bytes, mime: "image/jpeg", name: "zoom.jpg", fallbackText: "\uFF08\u8FD9\u662F\u4ED6\u6307\u5B9A\u90A3\u4E00\u5757\u653E\u5927\u540E\u7684\u622A\u56FE\uFF09" }]
|
|
2571
|
+
};
|
|
2572
|
+
}
|
|
2533
2573
|
case "hand_see":
|
|
2534
2574
|
return await this.see();
|
|
2535
2575
|
case "hand_look":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-hands",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.4",
|
|
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",
|