cortico-world-hands 0.1.3 → 0.1.5

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 +34 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -671,10 +671,12 @@ var Hands = class {
671
671
  return this.perform({ kind: "drag", x1: a, y1: b, x2: c, y2: d, ms });
672
672
  }
673
673
  /** 留言板:写一条。 */
674
- async noteAdd(text) {
674
+ async noteAdd(text, kind) {
675
675
  const cfg = this.cfg();
676
- const token = cfg.handToken ? `&t=${encodeURIComponent(cfg.handToken)}` : "";
677
- const path = `/hand/note?text=${encodeURIComponent(text)}${token}`;
676
+ const credential = this.readToken();
677
+ const token = credential ? `&t=${encodeURIComponent(credential)}` : "";
678
+ const k = kind ? `&kind=${encodeURIComponent(kind)}` : "";
679
+ const path = `/hand/note?text=${encodeURIComponent(text)}${k}${token}`;
678
680
  const res = await get(this.port(cfg.handPort), path, ACTION_TIMEOUT_MS);
679
681
  let body = {};
680
682
  try {
@@ -686,7 +688,8 @@ var Hands = class {
686
688
  /** 留言板:全部留言。 */
687
689
  async noteList() {
688
690
  const cfg = this.cfg();
689
- const token = cfg.handToken ? `?t=${encodeURIComponent(cfg.handToken)}` : "";
691
+ const credential = this.readToken();
692
+ const token = credential ? `?t=${encodeURIComponent(credential)}` : "";
690
693
  const res = await get(this.port(cfg.handPort), `/hand/notes${token}`, ACTION_TIMEOUT_MS);
691
694
  try {
692
695
  const body = JSON.parse(res.body.toString("utf8"));
@@ -698,7 +701,8 @@ var Hands = class {
698
701
  /** 留言板:划掉一条。 */
699
702
  async noteDone(id) {
700
703
  const cfg = this.cfg();
701
- const token = cfg.handToken ? `&t=${encodeURIComponent(cfg.handToken)}` : "";
704
+ const credential = this.readToken();
705
+ const token = credential ? `&t=${encodeURIComponent(credential)}` : "";
702
706
  const res = await get(this.port(cfg.handPort), `/hand/note/done?id=${encodeURIComponent(id)}${token}`, ACTION_TIMEOUT_MS);
703
707
  return res.status === 200;
704
708
  }
@@ -707,7 +711,8 @@ var Hands = class {
707
711
  const cfg = this.cfg();
708
712
  const tries = Math.max(0, Math.min(12, Math.round(Number(opts.tries ?? 5))));
709
713
  const scroll = opts.scroll === false ? "0" : "1";
710
- const token = cfg.handToken ? `&t=${encodeURIComponent(cfg.handToken)}` : "";
714
+ const credential = this.readToken();
715
+ const token = credential ? `&t=${encodeURIComponent(credential)}` : "";
711
716
  const path = `/hand/find?text=${encodeURIComponent(text)}&tries=${tries}&scroll=${scroll}${token}`;
712
717
  const res = await get(this.port(cfg.handPort), path, ACTION_TIMEOUT_MS);
713
718
  let body = {};
@@ -954,7 +959,12 @@ var HANDS_TOOL_DECLS = [
954
959
  parameters: {
955
960
  type: "object",
956
961
  properties: {
957
- text: { type: "string", description: "\u8981\u5199\u4E0B\u7684\u5185\u5BB9\u3002" }
962
+ text: { type: "string", description: "\u8981\u5199\u4E0B\u7684\u5185\u5BB9\u3002" },
963
+ kind: {
964
+ type: "string",
965
+ enum: ["todo", "say", "think"],
966
+ description: "\u5206\u7C7B\uFF1Atodo=\u5F85\u529E\uFF08\u8981\u505A\u7684\u4E8B\uFF0C\u4F1A\u88AB\u6BCF\u5929\u63D0\u9192\uFF09\u3001say=\u60F3\u5BF9\u4E3B\u4EBA\u8BF4\u7684\u8BDD\u3001think=\u788E\u788E\u5FF5\u3002\u9ED8\u8BA4 todo\u3002"
967
+ }
958
968
  },
959
969
  required: ["text"]
960
970
  }
@@ -963,7 +973,13 @@ var HANDS_TOOL_DECLS = [
963
973
  name: "note_list",
964
974
  tags: ["read"],
965
975
  description: "\u770B\u7559\u8A00\u677F\uFF1A\u6709\u54EA\u4E9B\u6CA1\u5212\u6389\u7684\u3001\u90FD\u5199\u4E86\u4EC0\u4E48\u3002\u5BF9\u65B9\u95EE\u300C\u4F60\u8BB0\u4E86\u4EC0\u4E48\u300D\u300C\u7559\u8A00\u677F\u4E0A\u6709\u5565\u300D\u65F6\u7528\u5B83\u3002",
966
- parameters: { type: "object", properties: {}, required: [] }
976
+ parameters: {
977
+ type: "object",
978
+ properties: {
979
+ kind: { type: "string", enum: ["todo", "say", "think"], description: "\u53EA\u770B\u67D0\u4E00\u7C7B\uFF08\u53EF\u7701\u7565\uFF09\u3002" }
980
+ },
981
+ required: []
982
+ }
967
983
  },
968
984
  {
969
985
  name: "note_done",
@@ -1066,7 +1082,7 @@ var HandsWorld = class {
1066
1082
  case "note_add":
1067
1083
  return await this.noteAdd(args);
1068
1084
  case "note_list":
1069
- return await this.noteList();
1085
+ return await this.noteList(args);
1070
1086
  case "note_done":
1071
1087
  return await this.noteDone(args);
1072
1088
  case "hand_stop":
@@ -1102,15 +1118,19 @@ var HandsWorld = class {
1102
1118
  async noteAdd(args) {
1103
1119
  const text = typeof args.text === "string" ? args.text.trim() : "";
1104
1120
  if (!text) return failed("\u8981\u5199\u4EC0\u4E48\uFF1F\u7ED9 text\u3002");
1105
- const result = await this.hands.noteAdd(text);
1121
+ const kind = typeof args.kind === "string" ? args.kind : void 0;
1122
+ const result = await this.hands.noteAdd(text, kind);
1106
1123
  if (!result.ok) return failed(`\u6CA1\u5199\u8FDB\u7559\u8A00\u677F\uFF1A${result.detail || "\u624B\u6CA1\u54CD\u5E94"}`);
1107
1124
  return `\u5199\u5728\u7559\u8A00\u677F\u4E0A\u4E86\uFF1A\u300C${text}\u300D`;
1108
1125
  }
1109
- async noteList() {
1110
- const notes = await this.hands.noteList();
1111
- if (notes.length === 0) return "\u7559\u8A00\u677F\u662F\u7A7A\u7684\u3002";
1126
+ async noteList(args = {}) {
1127
+ const all = await this.hands.noteList();
1128
+ const kind = typeof args.kind === "string" ? args.kind : "";
1129
+ const notes = kind ? all.filter((n) => (n.kind || "todo") === kind) : all;
1130
+ if (notes.length === 0) return "\u7559\u8A00\u677F\u662F\u7A7A\u7684\uFF1B\u8981\u4E0D\u518D\u8BB0\u70B9\u4EC0\u4E48\u3002";
1112
1131
  const open = notes.filter((n) => !n.done);
1113
- const lines = open.map((n) => `- [${n.id}] ${n.ts} ${n.text}`).join("\n");
1132
+ const label = (k) => k === "say" ? "\u60F3\u8BF4\u7684" : k === "think" ? "\u788E\u788E\u5FF5" : "\u5F85\u529E";
1133
+ const lines = open.map((n) => `- [${n.id}] ${label(n.kind || "todo")} ${n.ts} ${n.text}`).join("\n");
1114
1134
  return `\u7559\u8A00\u677F\u4E0A\u6709 ${notes.length} \u6761\uFF0C\u672A\u5B8C ${open.length} \u6761\uFF1A
1115
1135
  ${lines || "\uFF08\u90FD\u5212\u6389\u4E86\uFF09"}`;
1116
1136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
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",