@celljs/ta-recall 4.13.0 → 4.14.0

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/README.en.md CHANGED
@@ -17,7 +17,7 @@ Settings → Recall: the daily brief, its time, one written now, and the offers
17
17
 
18
18
  Sessions a package opened for a role of its own (an agent of a channel, a run of a schedule) are offered nothing to keep.
19
19
 
20
- Offering to keep something is a kind of Initiative (`@celljs/ta-initiative`), `recall.keep`: declined twice in a row it goes down to In the brief and is no longer offered in conversations; what you keep, have made or decline is told to it. The brief tells too what waits in Suggestions and what Ta did on its own.
20
+ Offering to keep something is a kind of Initiative (`@celljs/ta-initiative`), `recall.keep`: declined twice in a row it goes down to In the brief and is no longer offered in conversations; what you keep, have made or decline is told to it. The brief tells too what waits in Suggestions and what Ta did on its own. The notices, the runs of scheduled tasks and the suggestions are read by the methods of those packages' hosts (`notices` of ta-notify, `list` / `runs` of ta-cron, `proposals` of ta-initiative), never by their data; a package that is off leaves its part out.
21
21
 
22
22
  ## Data and calls
23
23
 
package/README.md CHANGED
@@ -17,7 +17,7 @@ Ta 自带的 pi 包(默认开启,可在 Web 客户端的 设置 → 扩展
17
17
 
18
18
  由别的包打开、承担固定角色的会话(频道里的智能体、定时任务的运行)不建议存下来。
19
19
 
20
- 建议存下来是"主动"(`@celljs/ta-initiative`)的一类事 `recall.keep`:你连续拒绝两次后它降到"只进简报",就不再在对话里建议;存下、做成扩展或拒绝都会回报给它。简报也写上"Ta 的建议"里等你决定的事和 Ta 自己做了的事。
20
+ 建议存下来是"主动"(`@celljs/ta-initiative`)的一类事 `recall.keep`:你连续拒绝两次后它降到"只进简报",就不再在对话里建议;存下、做成扩展或拒绝都会回报给它。简报也写上"Ta 的建议"里等你决定的事和 Ta 自己做了的事。提醒、定时任务的运行和建议都经各包宿主的方法读(`ta-notify` 的 `notices`、`ta-cron` 的 `list` / `runs`、`ta-initiative` 的 `proposals`),不读它们的包数据;包关着时简报就没有那一段。
21
21
 
22
22
  ## 数据与调用
23
23
 
@@ -30,6 +30,27 @@ var TaHostUtil;
30
30
  });
31
31
  }
32
32
  TaHostUtil2.reach = reach;
33
+ function marked(systemPrompt, mark) {
34
+ return role(systemPrompt).includes(mark);
35
+ }
36
+ TaHostUtil2.marked = marked;
37
+ function role(systemPrompt) {
38
+ if (!systemPrompt) {
39
+ return "";
40
+ }
41
+ const open = `<addendum>
42
+ `;
43
+ const start = systemPrompt.indexOf(open);
44
+ const context = systemPrompt.indexOf(`<project_context>
45
+ `);
46
+ if (start < 0 || context >= 0 && context < start) {
47
+ return "";
48
+ }
49
+ const end = systemPrompt.indexOf(`
50
+ </addendum>`, start);
51
+ return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
52
+ }
53
+ TaHostUtil2.role = role;
33
54
  })(TaHostUtil || (TaHostUtil = {}));
34
55
  var TA_WITH_OTHERS_MARK = "[ta:speaks-with-others]";
35
56
  var TA_KEEP_MARK = "[ta:keep]";
@@ -677,7 +698,7 @@ function activate(pi) {
677
698
  asked = undefined;
678
699
  draft = undefined;
679
700
  briefing = false;
680
- if (event.messageType === "custom" || typeof event.prompt !== "string" || ctx.getSystemPrompt?.().includes(TA_WITH_OTHERS_MARK)) {
701
+ if (event.messageType === "custom" || typeof event.prompt !== "string" || TaHostUtil.marked(ctx.getSystemPrompt?.(), TA_WITH_OTHERS_MARK)) {
681
702
  return;
682
703
  }
683
704
  if (event.prompt.includes(BRIEF_MARK)) {
package/host/index.mjs CHANGED
@@ -32,6 +32,27 @@ var TaHostUtil;
32
32
  });
33
33
  }
34
34
  TaHostUtil2.reach = reach;
35
+ function marked(systemPrompt, mark) {
36
+ return role(systemPrompt).includes(mark);
37
+ }
38
+ TaHostUtil2.marked = marked;
39
+ function role(systemPrompt) {
40
+ if (!systemPrompt) {
41
+ return "";
42
+ }
43
+ const open = `<addendum>
44
+ `;
45
+ const start = systemPrompt.indexOf(open);
46
+ const context = systemPrompt.indexOf(`<project_context>
47
+ `);
48
+ if (start < 0 || context >= 0 && context < start) {
49
+ return "";
50
+ }
51
+ const end = systemPrompt.indexOf(`
52
+ </addendum>`, start);
53
+ return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
54
+ }
55
+ TaHostUtil2.role = role;
35
56
  })(TaHostUtil || (TaHostUtil = {}));
36
57
  var TA_BRIEF_SOURCE = "brief";
37
58
  var TA_ASK_ENTRY = "ta-ask";
@@ -1075,23 +1096,17 @@ class RecallHost {
1075
1096
  return sources.filter((source) => !!source);
1076
1097
  }
1077
1098
  async notices() {
1078
- const value = await this.host.getExtensionData(NOTIFY, "notices").catch(() => {
1079
- return;
1080
- });
1099
+ const value = await this.fromPackage(NOTIFY, "notices");
1081
1100
  return Array.isArray(value) ? value.filter((notice) => !!notice && typeof notice.at === "number" && typeof notice.text === "string") : [];
1082
1101
  }
1083
1102
  async runs(since) {
1084
- const tasks = await this.host.getExtensionData(CRON2, "tasks").catch(() => {
1085
- return;
1086
- });
1103
+ const tasks = await this.fromPackage(CRON2, "list");
1087
1104
  if (!Array.isArray(tasks)) {
1088
1105
  return [];
1089
1106
  }
1090
1107
  const ran = tasks.filter((task) => task && typeof task.id === "string" && Date.parse(task.lastRunAt ?? "") >= since);
1091
1108
  return Promise.all(ran.map(async (task) => {
1092
- const runs = await this.host.getExtensionData(CRON2, `runs/${task.id}`).catch(() => {
1093
- return;
1094
- });
1109
+ const runs = await this.fromPackage(CRON2, "runs", task.id, 1);
1095
1110
  const run = Array.isArray(runs) ? runs[0] : undefined;
1096
1111
  return {
1097
1112
  name: String(task.name ?? task.id),
@@ -1102,9 +1117,7 @@ class RecallHost {
1102
1117
  }));
1103
1118
  }
1104
1119
  async suggestions() {
1105
- const value = await this.host.getExtensionData(INITIATIVE, "proposals").catch(() => {
1106
- return;
1107
- });
1120
+ const value = await this.fromPackage(INITIATIVE, "proposals");
1108
1121
  return Array.isArray(value) ? value.filter((one) => !!one && typeof one.title === "string" && typeof one.state === "string" && typeof one.at === "number") : [];
1109
1122
  }
1110
1123
  async initiative(method, ...params) {
@@ -1132,6 +1145,11 @@ class RecallHost {
1132
1145
  return;
1133
1146
  });
1134
1147
  }
1148
+ fromPackage(name, method, ...params) {
1149
+ return this.host.callPackageHost(name, method, params).catch(() => {
1150
+ return;
1151
+ });
1152
+ }
1135
1153
  serial(work) {
1136
1154
  const next = this.queue.then(work, work);
1137
1155
  this.queue = next.catch(() => {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@celljs/ta-recall",
3
- "version": "4.13.0",
3
+ "version": "4.14.0",
4
4
  "description": "A pi package for Ta: asks earlier conversations what was done, offers to keep a request asked again as an extension (steps, a card, a page), and writes a daily brief of what got done and what waits for the user",
5
5
  "keywords": [
6
6
  "pi-package"
7
7
  ],
8
- "homepage": "https://github.com/cellbang/cell",
8
+ "homepage": "https://github.com/cellbang/ta",
9
9
  "bugs": {
10
- "url": "https://github.com/cellbang/cell/issues"
10
+ "url": "https://github.com/cellbang/ta/issues"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
@@ -27,8 +27,8 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.13.0",
31
- "@celljs/ta-web": "4.13.0",
30
+ "@celljs/ta-protocol": "4.14.0",
31
+ "@celljs/ta-web": "4.14.0",
32
32
  "@types/react": "^19.3.0"
33
33
  },
34
34
  "publishConfig": {
package/web/index.js CHANGED
@@ -702,6 +702,27 @@ var TaHostUtil;
702
702
  });
703
703
  }
704
704
  TaHostUtil2.reach = reach;
705
+ function marked(systemPrompt, mark) {
706
+ return role(systemPrompt).includes(mark);
707
+ }
708
+ TaHostUtil2.marked = marked;
709
+ function role(systemPrompt) {
710
+ if (!systemPrompt) {
711
+ return "";
712
+ }
713
+ const open = `<addendum>
714
+ `;
715
+ const start = systemPrompt.indexOf(open);
716
+ const context = systemPrompt.indexOf(`<project_context>
717
+ `);
718
+ if (start < 0 || context >= 0 && context < start) {
719
+ return "";
720
+ }
721
+ const end = systemPrompt.indexOf(`
722
+ </addendum>`, start);
723
+ return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
724
+ }
725
+ TaHostUtil2.role = role;
705
726
  })(TaHostUtil || (TaHostUtil = {}));
706
727
  var TA_KEEP_MARK = "[ta:keep]";
707
728
  var TA_ASK_ENTRY = "ta-ask";