cortico-world-hands 0.1.5 → 0.1.6
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 +28 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -698,6 +698,15 @@ var Hands = class {
|
|
|
698
698
|
return [];
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
|
+
/** 留言板:未完成的待办条数(状态灯里显示)。 */
|
|
702
|
+
async notePending() {
|
|
703
|
+
try {
|
|
704
|
+
const notes = await this.noteList();
|
|
705
|
+
return notes.filter((n) => !n.done).length;
|
|
706
|
+
} catch {
|
|
707
|
+
return 0;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
701
710
|
/** 留言板:划掉一条。 */
|
|
702
711
|
async noteDone(id) {
|
|
703
712
|
const cfg = this.cfg();
|
|
@@ -741,6 +750,7 @@ var Hands = class {
|
|
|
741
750
|
if (!state.ok) throw new HandError(`\u624B\u73B0\u5728\u52A8\u4E0D\u4E86\uFF1A${state.detail}`);
|
|
742
751
|
const where = await this.screenGuard();
|
|
743
752
|
await this.throttle();
|
|
753
|
+
this.lookCache = null;
|
|
744
754
|
const described = describeCommand(command);
|
|
745
755
|
const cfg = this.cfg();
|
|
746
756
|
if (cfg.dryRun) {
|
|
@@ -764,7 +774,18 @@ var Hands = class {
|
|
|
764
774
|
}
|
|
765
775
|
}
|
|
766
776
|
/** 看一眼屏幕。detail: both(画面加文字,默认)、screen(只要画面)、text(只要文字)。 */
|
|
777
|
+
lookCache = null;
|
|
767
778
|
async look(detail = "both") {
|
|
779
|
+
const now = Date.now();
|
|
780
|
+
if (this.lookCache && this.lookCache.detail === detail && now - this.lookCache.at < 1200) {
|
|
781
|
+
this.looks += 1;
|
|
782
|
+
return this.lookCache.report;
|
|
783
|
+
}
|
|
784
|
+
const report = await this.lookFresh(detail);
|
|
785
|
+
this.lookCache = { at: Date.now(), detail, report };
|
|
786
|
+
return report;
|
|
787
|
+
}
|
|
788
|
+
async lookFresh(detail = "both") {
|
|
768
789
|
const cfg = this.cfg();
|
|
769
790
|
const health = await this.eyes.health();
|
|
770
791
|
if (!health?.ok) {
|
|
@@ -1078,7 +1099,7 @@ var HandsWorld = class {
|
|
|
1078
1099
|
case "hand_key":
|
|
1079
1100
|
return await this.key(args);
|
|
1080
1101
|
case "hand_status":
|
|
1081
|
-
return this.statusText();
|
|
1102
|
+
return await this.statusText();
|
|
1082
1103
|
case "note_add":
|
|
1083
1104
|
return await this.noteAdd(args);
|
|
1084
1105
|
case "note_list":
|
|
@@ -1230,7 +1251,7 @@ ${list}`);
|
|
|
1230
1251
|
this.note(receipt);
|
|
1231
1252
|
return receipt.text;
|
|
1232
1253
|
}
|
|
1233
|
-
statusText() {
|
|
1254
|
+
async statusText() {
|
|
1234
1255
|
const cfg = this.opts.cfg;
|
|
1235
1256
|
const state = this.hands.state();
|
|
1236
1257
|
const stats = this.hands.stats();
|
|
@@ -1241,6 +1262,11 @@ ${list}`);
|
|
|
1241
1262
|
`\u8FD9\u4E00\u5206\u949F\uFF1A${stats.inWindow}\uFF0F${Math.max(1, Math.round(cfg.maxActionsPerMinute) || 30)} \u4E0B\uFF1B\u7D2F\u8BA1\u52A8\u8FC7 ${stats.acts} \u6B21\u3001\u770B\u8FC7 ${stats.looks} \u6B21`
|
|
1242
1263
|
];
|
|
1243
1264
|
if (this.pausedUntil > Date.now()) lines.push(`\u53EB\u505C\u4E2D\uFF1A\u8FD8\u6709 ${Math.ceil((this.pausedUntil - Date.now()) / 1e3)} \u79D2`);
|
|
1265
|
+
try {
|
|
1266
|
+
const pending = await this.hands.notePending();
|
|
1267
|
+
if (pending > 0) lines.push(`\u7559\u8A00\u677F\uFF1A\u8FD8\u6709 ${pending} \u6761\u6CA1\u5212\u6389`);
|
|
1268
|
+
} catch {
|
|
1269
|
+
}
|
|
1244
1270
|
if (this.recent.length) lines.push(`\u6700\u8FD1\uFF1A
|
|
1245
1271
|
${this.recent.map((r) => `- ${r}`).join("\n")}`);
|
|
1246
1272
|
return lines.join("\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-hands",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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",
|