@celljs/ta-cron 4.8.0 → 4.9.1
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 +3 -3
- package/README.md +3 -3
- package/host/index.mjs +19 -12
- package/package.json +13 -4
- package/web/index.js +249 -281
- package/web-src/commands.spec.ts +0 -55
- package/web-src/commands.ts +0 -259
- package/web-src/cron-expression.spec.ts +0 -41
- package/web-src/cron-expression.ts +0 -150
- package/web-src/cron-protocol.ts +0 -151
- package/web-src/editor.tsx +0 -249
- package/web-src/extension.ts +0 -187
- package/web-src/form-util.spec.ts +0 -33
- package/web-src/form-util.ts +0 -141
- package/web-src/host.ts +0 -12
- package/web-src/i18n.ts +0 -175
- package/web-src/index.tsx +0 -35
- package/web-src/model-picker.spec.ts +0 -32
- package/web-src/model-picker.tsx +0 -227
- package/web-src/notifier.ts +0 -47
- package/web-src/page.ts +0 -126
- package/web-src/react.ts +0 -11
- package/web-src/reply.tsx +0 -80
- package/web-src/schedule-util.spec.ts +0 -48
- package/web-src/schedule-util.ts +0 -233
- package/web-src/scheduler.spec.ts +0 -254
- package/web-src/scheduler.ts +0 -380
- package/web-src/server-texts.spec.ts +0 -10
- package/web-src/server-texts.ts +0 -18
- package/web-src/style.ts +0 -133
- package/web-src/task-store.ts +0 -67
- package/web-src/task-util.ts +0 -174
- package/web-src/tasks-view.tsx +0 -279
- package/web-src/tool.ts +0 -135
package/README.en.md
CHANGED
|
@@ -18,7 +18,7 @@ A pi package that comes with Ta (on by default; turn it off in Settings → Exte
|
|
|
18
18
|
/schedule help
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
Or just say "sum up yesterday's commits every day at 9": Ta makes the task with the tool `schedule_task`. The Scheduled page
|
|
21
|
+
Or just say "sum up yesterday's commits every day at 9": Ta makes the task with the tool `schedule_task`. The Scheduled page of the web client (under Discover by default; pin it there or under Settings > Navigation) lists every task with its rule, its next run and a switch; opened, its prompt and the summary of each run, and "Open conversation" goes to the conversation of that run. Tasks are made, edited, run and deleted there too; the dialog picks a task's model from a list with a search box (type part of its name, id or provider; arrows and Enter pick; the models with credentials in the settings of its directory, pi packages' such as other agents included) and its thinking level, or leaves the defaults of the settings.
|
|
22
22
|
|
|
23
23
|
## Time rules
|
|
24
24
|
|
|
@@ -33,7 +33,7 @@ Times are local to the machine of the Ta service. A command may end with `--name
|
|
|
33
33
|
- Three parts, none of which changes Ta's core:
|
|
34
34
|
- **Server side** (`pi.host`, `web-src/host.ts`): the scheduler. It runs in the Ta service with one timer, asleep until the next task is due (it looks again within a minute at the latest, to follow a changed clock or a machine that slept). Tasks and runs are kept in the data of the package (`extension-data/@celljs/ta-cron.json` of the agent directory), the last 20 runs of each task.
|
|
35
35
|
- **pi extension** (`pi.extensions`, `web-src/extension.ts`): `/loop`, `/remind`, `/schedule` and the tool `schedule_task`. A command answers with a card in the conversation, which the model does not read.
|
|
36
|
-
- **Web extension** (`pi.web`, `web-src/index.tsx`): the Scheduled page, the cards of the commands,
|
|
36
|
+
- **Web extension** (`pi.web`, `web-src/index.tsx`): the Scheduled page, the cards of the commands, a notice when a run ends, and the Next up card of the board (a swipe to the right over the first tab of a phone, a button of the rail elsewhere): the three tasks running or due first.
|
|
37
37
|
- **One run, one conversation**: each run opens a new session (in the `ta-cron` group) in the task's directory (by default that of the conversation that made it; an `ssh://` directory works too), with the task's model and thinking level if it has them. The system prompt it adds tells Ta that nobody watches, not to ask anything, and to end with a summary; the last answer is the summary of the run. Once the run ends its session closes (after whoever is looking at it leaves), and its file stays.
|
|
38
38
|
- **No scheduling from a run**: a run has no `schedule_task` and the commands refuse, so tasks do not breed tasks.
|
|
39
39
|
- **No overlap**: a task whose last run has not ended when its time comes again lets that time go. At most 3 runs at once; the others wait.
|
|
@@ -45,4 +45,4 @@ Times are local to the machine of the Ta service. A command may end with `--name
|
|
|
45
45
|
|
|
46
46
|
- Tasks run only while the Ta service runs (`ta serve`; Ta Desktop starts it); in `ta` in a terminal the commands and the tool say they need it.
|
|
47
47
|
- A run's tools cannot be limited: it is a conversation like any other, with your settings and the project's extensions and skills.
|
|
48
|
-
- No outside channels such as email or webhooks, and no export or import.
|
|
48
|
+
- No outside channels such as email or webhooks, and no export or import.
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Ta 自带的 pi 包(默认开启,可在 Web 客户端的 设置 → 扩展
|
|
|
18
18
|
/schedule help
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
也可以直接说"每天 9 点帮我汇总昨天的提交":Ta 用工具 `schedule_task` 建任务。Web
|
|
21
|
+
也可以直接说"每天 9 点帮我汇总昨天的提交":Ta 用工具 `schedule_task` 建任务。Web 客户端的"定时任务"页(默认收在"发现"里,可以在那里或 设置 → 导航 固定到导航栏)列出所有任务:时间规则、下次运行、开关,展开看提示词和每次运行的总结,点"打开对话"进入那次运行的对话;也能在这里新建、编辑、立即运行和删除;新建和编辑时从可搜索的列表里选这个任务用的模型(输入名字、模型 id 或提供方即可筛选,方向键和回车选择;任务所在目录的设置里有凭据的模型,包括 pi 包提供的,如外部 Agent)和思考级别,不选就用设置里的默认值。
|
|
22
22
|
|
|
23
23
|
## 时间规则
|
|
24
24
|
|
|
@@ -33,7 +33,7 @@ Ta 自带的 pi 包(默认开启,可在 Web 客户端的 设置 → 扩展
|
|
|
33
33
|
- 由三部分组成,都不改 Ta 的核心:
|
|
34
34
|
- **服务端**(`pi.host`,`web-src/host.ts`):调度器。Ta 服务启动时运行,只有一个计时器,睡到最近一个任务的时间(最长一分钟后再看一次,以便跟上系统时间的变化和休眠)。任务和运行记录存在包数据里(agent 目录的 `extension-data/@celljs/ta-cron.json`),每个任务保留最近 20 次运行。
|
|
35
35
|
- **pi 扩展**(`pi.extensions`,`web-src/extension.ts`):`/loop`、`/remind`、`/schedule` 和工具 `schedule_task`。命令的回答是对话里的一张卡片,不进入模型的上下文。
|
|
36
|
-
- **Web 扩展**(`pi.web`,`web-src/index.tsx`):"定时任务"
|
|
36
|
+
- **Web 扩展**(`pi.web`,`web-src/index.tsx`):"定时任务"页、命令回答的卡片、运行结束时的通知,以及小组件面板(首页往右划,电脑上是导轨的按钮)里的"接下来"卡片:正在运行和最近要运行的三个任务。
|
|
37
37
|
- **一次运行,一个对话**:每次运行打开一个新会话(归在 `ta-cron` 分组下),工作目录是任务的目录(默认是创建它的对话的目录,可以是 `ssh://` 远程目录),可单独指定模型和思考级别。追加的系统提示告诉 Ta 没人在看、不要提问、最后写一段总结;最后一条回答就是这次运行的总结。运行结束后会话关闭(有人正在看时等看完再关),对话文件保留。
|
|
38
38
|
- **运行里不能再建定时任务**:运行的对话里没有 `schedule_task` 工具,命令也会拒绝,避免任务自我繁殖。
|
|
39
39
|
- **不重叠**:到点时上次运行还没结束,就跳过这次,等下一个时间。最多同时运行 3 个任务,其余排队。
|
|
@@ -45,4 +45,4 @@ Ta 自带的 pi 包(默认开启,可在 Web 客户端的 设置 → 扩展
|
|
|
45
45
|
|
|
46
46
|
- 只在 Ta 服务(`ta serve`,Ta 桌面版会自动启动它)运行时调度;单独运行 `ta`(终端)时命令和工具会提示需要 Ta 服务。
|
|
47
47
|
- 不能限定一次运行可用的工具:运行和普通对话一样,用你的设置和项目里的扩展、技能。
|
|
48
|
-
- 没有邮件、Webhook 之类的外部通知渠道,也没有导入导出。
|
|
48
|
+
- 没有邮件、Webhook 之类的外部通知渠道,也没有导入导出。
|
package/host/index.mjs
CHANGED
|
@@ -573,6 +573,7 @@ class CronScheduler {
|
|
|
573
573
|
working = 0;
|
|
574
574
|
lingering = new Set;
|
|
575
575
|
timer;
|
|
576
|
+
ticking = false;
|
|
576
577
|
disposed = false;
|
|
577
578
|
constructor(host, options = {}) {
|
|
578
579
|
this.host = host;
|
|
@@ -647,7 +648,7 @@ class CronScheduler {
|
|
|
647
648
|
}
|
|
648
649
|
arm() {
|
|
649
650
|
clearTimeout(this.timer);
|
|
650
|
-
if (this.disposed) {
|
|
651
|
+
if (this.disposed || this.ticking) {
|
|
651
652
|
return;
|
|
652
653
|
}
|
|
653
654
|
const now = this.options.now().getTime();
|
|
@@ -664,19 +665,25 @@ class CronScheduler {
|
|
|
664
665
|
if (this.disposed) {
|
|
665
666
|
return;
|
|
666
667
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
668
|
+
this.ticking = true;
|
|
669
|
+
try {
|
|
670
|
+
const now = this.options.now();
|
|
671
|
+
for (const { id } of [...this.tasks]) {
|
|
672
|
+
const task = this.tasks.find((other) => other.id === id);
|
|
673
|
+
if (!task?.enabled || !task.nextRunAt || new Date(task.nextRunAt).getTime() > now.getTime()) {
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
if (this.active.has(task.id)) {
|
|
677
|
+
await this.replace(this.advance(task, now));
|
|
678
|
+
} else {
|
|
679
|
+
await this.begin(task, "schedule", now);
|
|
680
|
+
}
|
|
676
681
|
}
|
|
682
|
+
await this.sweep();
|
|
683
|
+
} finally {
|
|
684
|
+
this.ticking = false;
|
|
685
|
+
this.arm();
|
|
677
686
|
}
|
|
678
|
-
await this.sweep();
|
|
679
|
-
this.arm();
|
|
680
687
|
}
|
|
681
688
|
advance(task, now) {
|
|
682
689
|
if (!ScheduleUtil.repeats(task.schedule)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-cron",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.1",
|
|
4
4
|
"description": "A pi package for Ta: prompts that run on a schedule, once, every so often or by a cron expression, each run in a conversation of its own in the Ta service",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"web",
|
|
19
19
|
"host",
|
|
20
20
|
"extension",
|
|
21
|
-
"
|
|
21
|
+
"!**/*.map"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "tsc -b && bun build web-src/index.tsx --format esm --target browser --outfile web/index.js && bun build web-src/host.ts --format esm --target node --outfile host/index.mjs && bun build web-src/extension.ts --format esm --target node --outfile extension/index.mjs",
|
|
@@ -27,14 +27,23 @@
|
|
|
27
27
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@celljs/ta-protocol": "4.
|
|
31
|
-
"@celljs/ta-web": "4.
|
|
30
|
+
"@celljs/ta-protocol": "4.9.1",
|
|
31
|
+
"@celljs/ta-web": "4.9.1",
|
|
32
32
|
"@types/react": "^19.3.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"pi": {
|
|
38
|
+
"title": {
|
|
39
|
+
"en": "Scheduled tasks",
|
|
40
|
+
"zh-CN": "定时任务"
|
|
41
|
+
},
|
|
42
|
+
"summary": {
|
|
43
|
+
"en": "Has Ta do things on time: reminders, regular checks, a daily summary (/loop, /remind).",
|
|
44
|
+
"zh-CN": "让 Ta 按时做事:到点提醒、定期检查、每天汇总(/loop、/remind)。"
|
|
45
|
+
},
|
|
46
|
+
"icon": "AlarmClock",
|
|
38
47
|
"web": [
|
|
39
48
|
"./web/index.js"
|
|
40
49
|
],
|