@celljs/ta-cron 4.13.1 → 4.15.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
@@ -33,7 +33,7 @@ Times are local to the machine of the Ta service. A command may end with `--name
33
33
  ## How it runs
34
34
 
35
35
  - Three parts, none of which changes Ta's core:
36
- - **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.
36
+ - **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. Other packages read the tasks and runs with `callPackageHost('@celljs/ta-cron', …)`: `list()`, `runs(id, limit?)` (newest first), not by the data of this package (the brief of ta-recall does so).
37
37
  - **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.
38
38
  - **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.
39
39
  - **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.
package/README.md CHANGED
@@ -33,7 +33,7 @@ Ta 自带的 pi 包(默认开启,可在 Web 客户端的 设置 → 扩展
33
33
  ## 怎么运行
34
34
 
35
35
  - 由三部分组成,都不改 Ta 的核心:
36
- - **服务端**(`pi.host`,`web-src/host.ts`):调度器。Ta 服务启动时运行,只有一个计时器,睡到最近一个任务的时间(最长一分钟后再看一次,以便跟上系统时间的变化和休眠)。任务和运行记录存在包数据里(agent 目录的 `extension-data/@celljs/ta-cron.json`),每个任务保留最近 20 次运行。
36
+ - **服务端**(`pi.host`,`web-src/host.ts`):调度器。Ta 服务启动时运行,只有一个计时器,睡到最近一个任务的时间(最长一分钟后再看一次,以便跟上系统时间的变化和休眠)。任务和运行记录存在包数据里(agent 目录的 `extension-data/@celljs/ta-cron.json`),每个任务保留最近 20 次运行。别的包经 `callPackageHost('@celljs/ta-cron', …)` 读任务和运行:`list()`、`runs(id, limit?)`(新的在前),不读本包的数据(ta-recall 的简报就这样读)。
37
37
  - **pi 扩展**(`pi.extensions`,`web-src/extension.ts`):`/loop`、`/remind`、`/schedule` 和工具 `schedule_task`。命令的回答是对话里的一张卡片,不进入模型的上下文。
38
38
  - **Web 扩展**(`pi.web`,`web-src/index.tsx`):"定时任务"页、命令回答的卡片、运行结束时的通知,以及小组件面板(首页往右划,电脑上是导轨的按钮)里的"接下来"卡片:正在运行和最近要运行的三个任务。
39
39
  - **一次运行,一个对话**:每次运行打开一个新会话(归在 `ta-cron` 分组下),工作目录是任务的目录(默认是创建它的对话的目录,可以是 `ssh://` 远程目录),可单独指定模型和思考级别。追加的系统提示告诉 Ta 没人在看、不要提问、最后写一段总结;最后一条回答就是这次运行的总结。运行结束后会话关闭(有人正在看时等看完再关),对话文件保留。
@@ -118,6 +118,45 @@ var Limits;
118
118
  Limits.PARALLEL_RUNS = 3;
119
119
  })(Limits ||= {});
120
120
 
121
+ // ../ta-protocol/esm/common/language.js
122
+ var TaLanguageUtil;
123
+ (function(TaLanguageUtil2) {
124
+ TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
125
+ TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
126
+ function of(tag) {
127
+ const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
128
+ if (/^zh(\b|-)/.test(said)) {
129
+ return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
130
+ }
131
+ return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
132
+ }
133
+ TaLanguageUtil2.of = of;
134
+ function server(env = typeof process === "undefined" ? {} : process.env) {
135
+ return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
136
+ }
137
+ TaLanguageUtil2.server = server;
138
+ function pick(language, words) {
139
+ return words[of(language)];
140
+ }
141
+ TaLanguageUtil2.pick = pick;
142
+ function say(words) {
143
+ return words[server()];
144
+ }
145
+ TaLanguageUtil2.say = say;
146
+ function chinese(language) {
147
+ return of(language).startsWith("zh");
148
+ }
149
+ TaLanguageUtil2.chinese = chinese;
150
+ function cjk(language) {
151
+ return of(language) !== "en-US";
152
+ }
153
+ TaLanguageUtil2.cjk = cjk;
154
+ function list(language, items) {
155
+ return items.join(cjk(language) ? "、" : ", ");
156
+ }
157
+ TaLanguageUtil2.list = list;
158
+ })(TaLanguageUtil || (TaLanguageUtil = {}));
159
+
121
160
  // web-src/cron-expression.ts
122
161
  var FIELDS = [
123
162
  { name: "minute", min: 0, max: 59 },
@@ -299,8 +338,10 @@ var Duration;
299
338
  })(Duration ||= {});
300
339
  var EN_DAYS = ["Sundays", "Mondays", "Tuesdays", "Wednesdays", "Thursdays", "Fridays", "Saturdays"];
301
340
  var ZH_DAYS = ["日", "一", "二", "三", "四", "五", "六"];
341
+ var ZH_TW_DAYS = ["日", "一", "二", "三", "四", "五", "六"];
342
+ var JA_DAYS = ["日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"];
302
343
  var WORDS = {
303
- en: {
344
+ "en-US": {
304
345
  once: (time) => `Once, ${time}`,
305
346
  every: (amount, unit) => amount === 1 ? `Every ${unit}` : `Every ${amount} ${unit}s`,
306
347
  everyRaw: (duration) => `Every ${duration}`,
@@ -311,7 +352,7 @@ var WORDS = {
311
352
  hourly: (minute) => minute === 0 ? "Hourly" : `Hourly at :${pad(minute)}`,
312
353
  cron: (expression) => `Cron ${expression}`
313
354
  },
314
- zh: {
355
+ "zh-CN": {
315
356
  once: (time) => `${time} 运行一次`,
316
357
  every: (amount, unit) => `每 ${amount === 1 ? "" : `${amount} `}${{ minute: "分钟", hour: "小时", day: "天" }[unit]}`.replace("每 天", "每天"),
317
358
  everyRaw: (duration) => `每 ${duration}`,
@@ -321,6 +362,28 @@ var WORDS = {
321
362
  monthly: (day, time) => `每月 ${day} 日 ${time}`,
322
363
  hourly: (minute) => minute === 0 ? "每小时" : `每小时第 ${minute} 分`,
323
364
  cron: (expression) => `cron ${expression}`
365
+ },
366
+ "zh-TW": {
367
+ once: (time) => `${time} 執行一次`,
368
+ every: (amount, unit) => `每 ${amount === 1 ? "" : `${amount} `}${{ minute: "分鐘", hour: "小時", day: "天" }[unit]}`.replace("每 天", "每天"),
369
+ everyRaw: (duration) => `每 ${duration}`,
370
+ daily: (time) => `每天 ${time}`,
371
+ weekdays: (time) => `工作日 ${time}`,
372
+ weekly: (day, time) => `每週${ZH_TW_DAYS[day]} ${time}`,
373
+ monthly: (day, time) => `每月 ${day} 日 ${time}`,
374
+ hourly: (minute) => minute === 0 ? "每小時" : `每小時第 ${minute} 分`,
375
+ cron: (expression) => `cron ${expression}`
376
+ },
377
+ "ja-JP": {
378
+ once: (time) => `${time}に1回実行`,
379
+ every: (amount, unit) => amount === 1 ? `毎${{ minute: "分", hour: "時間", day: "日" }[unit]}` : `毎${amount}${{ minute: "分", hour: "時間", day: "日" }[unit]}`,
380
+ everyRaw: (duration) => `毎 ${duration}`,
381
+ daily: (time) => `毎日 ${time}`,
382
+ weekdays: (time) => `平日 ${time}`,
383
+ weekly: (day, time) => `${JA_DAYS[day]} ${time}`,
384
+ monthly: (day, time) => `毎月${day}日 ${time}`,
385
+ hourly: (minute) => minute === 0 ? "毎時間" : `毎時間 :${pad(minute)}`,
386
+ cron: (expression) => `Cron ${expression}`
324
387
  }
325
388
  };
326
389
  function pad(value) {
@@ -390,7 +453,8 @@ var ScheduleUtil;
390
453
  }
391
454
  ScheduleUtil.clock = clock;
392
455
  function describe(schedule, language, now = new Date) {
393
- const words = WORDS[language.startsWith("zh") ? "zh" : "en"];
456
+ const lang = TaLanguageUtil.of(language);
457
+ const words = WORDS[lang];
394
458
  switch (schedule.kind) {
395
459
  case "once":
396
460
  return words.once(clock(new Date(schedule.at), now));
@@ -693,16 +757,26 @@ ${reply2.runs.length ? reply2.runs.map((item) => run(item)).join(`
693
757
  // web-src/server-texts.ts
694
758
  var CronServerTexts;
695
759
  ((CronServerTexts) => {
696
- function zh(env = process.env) {
697
- return /^zh/i.test(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG || "");
760
+ function language(env = process.env) {
761
+ return TaLanguageUtil.of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG || "");
698
762
  }
699
- CronServerTexts.zh = zh;
763
+ CronServerTexts.language = language;
700
764
  function removeTask(name) {
701
- return zh() ? ["删除这个任务?", `${name} 和它的运行记录会被删除,运行产生的对话会保留。`] : ["Delete the scheduled task?", `${name} and its runs go; their conversations stay.`];
765
+ return TaLanguageUtil.say({
766
+ "zh-CN": ["删除这个任务?", `${name} 和它的运行记录会被删除,运行产生的对话会保留。`],
767
+ "zh-TW": ["刪除這個任務?", `${name} 和它的執行記錄會被刪除,執行產生的對話會保留。`],
768
+ "en-US": ["Delete the scheduled task?", `${name} and its runs go; their conversations stay.`],
769
+ "ja-JP": ["スケジュールされたタスクを削除しますか?", `${name}とその実行記録が削除されます。会話は保持されます。`]
770
+ });
702
771
  }
703
772
  CronServerTexts.removeTask = removeTask;
704
773
  function removeTasks(count) {
705
- return zh() ? ["删除这个目录的所有定时任务?", `${count} 个任务和它们的运行记录会被删除。`] : ["Delete the scheduled tasks of this directory?", `${count} tasks and their runs go.`];
774
+ return TaLanguageUtil.say({
775
+ "zh-CN": ["删除这个目录的所有定时任务?", `${count} 个任务和它们的运行记录会被删除。`],
776
+ "zh-TW": ["刪除這個目錄的所有定時任務?", `${count} 個任務和它們的執行記錄會被刪除。`],
777
+ "en-US": ["Delete the scheduled tasks of this directory?", `${count} tasks and their runs go.`],
778
+ "ja-JP": ["このディレクトリのすべてのスケジュールされたタスクを削除しますか?", `${count}個のタスクとその実行記録が削除されます。`]
779
+ });
706
780
  }
707
781
  CronServerTexts.removeTasks = removeTasks;
708
782
  })(CronServerTexts ||= {});
package/host/index.mjs CHANGED
@@ -22,6 +22,45 @@ var Limits;
22
22
  Limits.PARALLEL_RUNS = 3;
23
23
  })(Limits ||= {});
24
24
 
25
+ // ../ta-protocol/esm/common/language.js
26
+ var TaLanguageUtil;
27
+ (function(TaLanguageUtil2) {
28
+ TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
29
+ TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
30
+ function of(tag) {
31
+ const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
32
+ if (/^zh(\b|-)/.test(said)) {
33
+ return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
34
+ }
35
+ return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
36
+ }
37
+ TaLanguageUtil2.of = of;
38
+ function server(env = typeof process === "undefined" ? {} : process.env) {
39
+ return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
40
+ }
41
+ TaLanguageUtil2.server = server;
42
+ function pick(language, words) {
43
+ return words[of(language)];
44
+ }
45
+ TaLanguageUtil2.pick = pick;
46
+ function say(words) {
47
+ return words[server()];
48
+ }
49
+ TaLanguageUtil2.say = say;
50
+ function chinese(language) {
51
+ return of(language).startsWith("zh");
52
+ }
53
+ TaLanguageUtil2.chinese = chinese;
54
+ function cjk(language) {
55
+ return of(language) !== "en-US";
56
+ }
57
+ TaLanguageUtil2.cjk = cjk;
58
+ function list(language, items) {
59
+ return items.join(cjk(language) ? "、" : ", ");
60
+ }
61
+ TaLanguageUtil2.list = list;
62
+ })(TaLanguageUtil || (TaLanguageUtil = {}));
63
+
25
64
  // web-src/cron-expression.ts
26
65
  var FIELDS = [
27
66
  { name: "minute", min: 0, max: 59 },
@@ -203,8 +242,10 @@ var Duration;
203
242
  })(Duration ||= {});
204
243
  var EN_DAYS = ["Sundays", "Mondays", "Tuesdays", "Wednesdays", "Thursdays", "Fridays", "Saturdays"];
205
244
  var ZH_DAYS = ["日", "一", "二", "三", "四", "五", "六"];
245
+ var ZH_TW_DAYS = ["日", "一", "二", "三", "四", "五", "六"];
246
+ var JA_DAYS = ["日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"];
206
247
  var WORDS = {
207
- en: {
248
+ "en-US": {
208
249
  once: (time) => `Once, ${time}`,
209
250
  every: (amount, unit) => amount === 1 ? `Every ${unit}` : `Every ${amount} ${unit}s`,
210
251
  everyRaw: (duration) => `Every ${duration}`,
@@ -215,7 +256,7 @@ var WORDS = {
215
256
  hourly: (minute) => minute === 0 ? "Hourly" : `Hourly at :${pad(minute)}`,
216
257
  cron: (expression) => `Cron ${expression}`
217
258
  },
218
- zh: {
259
+ "zh-CN": {
219
260
  once: (time) => `${time} 运行一次`,
220
261
  every: (amount, unit) => `每 ${amount === 1 ? "" : `${amount} `}${{ minute: "分钟", hour: "小时", day: "天" }[unit]}`.replace("每 天", "每天"),
221
262
  everyRaw: (duration) => `每 ${duration}`,
@@ -225,6 +266,28 @@ var WORDS = {
225
266
  monthly: (day, time) => `每月 ${day} 日 ${time}`,
226
267
  hourly: (minute) => minute === 0 ? "每小时" : `每小时第 ${minute} 分`,
227
268
  cron: (expression) => `cron ${expression}`
269
+ },
270
+ "zh-TW": {
271
+ once: (time) => `${time} 執行一次`,
272
+ every: (amount, unit) => `每 ${amount === 1 ? "" : `${amount} `}${{ minute: "分鐘", hour: "小時", day: "天" }[unit]}`.replace("每 天", "每天"),
273
+ everyRaw: (duration) => `每 ${duration}`,
274
+ daily: (time) => `每天 ${time}`,
275
+ weekdays: (time) => `工作日 ${time}`,
276
+ weekly: (day, time) => `每週${ZH_TW_DAYS[day]} ${time}`,
277
+ monthly: (day, time) => `每月 ${day} 日 ${time}`,
278
+ hourly: (minute) => minute === 0 ? "每小時" : `每小時第 ${minute} 分`,
279
+ cron: (expression) => `cron ${expression}`
280
+ },
281
+ "ja-JP": {
282
+ once: (time) => `${time}に1回実行`,
283
+ every: (amount, unit) => amount === 1 ? `毎${{ minute: "分", hour: "時間", day: "日" }[unit]}` : `毎${amount}${{ minute: "分", hour: "時間", day: "日" }[unit]}`,
284
+ everyRaw: (duration) => `毎 ${duration}`,
285
+ daily: (time) => `毎日 ${time}`,
286
+ weekdays: (time) => `平日 ${time}`,
287
+ weekly: (day, time) => `${JA_DAYS[day]} ${time}`,
288
+ monthly: (day, time) => `毎月${day}日 ${time}`,
289
+ hourly: (minute) => minute === 0 ? "毎時間" : `毎時間 :${pad(minute)}`,
290
+ cron: (expression) => `Cron ${expression}`
228
291
  }
229
292
  };
230
293
  function pad(value) {
@@ -294,7 +357,8 @@ var ScheduleUtil;
294
357
  }
295
358
  ScheduleUtil.clock = clock;
296
359
  function describe(schedule, language, now = new Date) {
297
- const words = WORDS[language.startsWith("zh") ? "zh" : "en"];
360
+ const lang = TaLanguageUtil.of(language);
361
+ const words = WORDS[lang];
298
362
  switch (schedule.kind) {
299
363
  case "once":
300
364
  return words.once(clock(new Date(schedule.at), now));
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@celljs/ta-cron",
3
- "version": "4.13.1",
3
+ "version": "4.15.0",
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"
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.1",
31
- "@celljs/ta-web": "4.13.1",
30
+ "@celljs/ta-protocol": "4.15.0",
31
+ "@celljs/ta-web": "4.15.0",
32
32
  "@types/react": "^19.3.0"
33
33
  },
34
34
  "publishConfig": {
@@ -37,11 +37,15 @@
37
37
  "pi": {
38
38
  "title": {
39
39
  "en": "Scheduled tasks",
40
- "zh-CN": "定时任务"
40
+ "zh-CN": "定时任务",
41
+ "zh-TW": "定時任務",
42
+ "ja-JP": "スケジュールタスク"
41
43
  },
42
44
  "summary": {
43
45
  "en": "Has Ta do things on time: reminders, regular checks, a daily summary (/loop, /remind).",
44
- "zh-CN": "让 Ta 按时做事:到点提醒、定期检查、每天汇总(/loop、/remind)。"
46
+ "zh-CN": "让 Ta 按时做事:到点提醒、定期检查、每天汇总(/loop、/remind)。",
47
+ "zh-TW": "讓 Ta 按時做事:到點提醒、定期檢查、每天彙總(/loop、/remind)。",
48
+ "ja-JP": "Ta に決まった時間に作業させます:リマインダー、定期チェック、毎日のまとめ(/loop、/remind)。"
45
49
  },
46
50
  "descriptions": {
47
51
  "loop": {
package/web/index.js CHANGED
@@ -24,6 +24,45 @@ var Limits;
24
24
  Limits.PARALLEL_RUNS = 3;
25
25
  })(Limits ||= {});
26
26
 
27
+ // ../ta-protocol/esm/common/language.js
28
+ var TaLanguageUtil;
29
+ (function(TaLanguageUtil2) {
30
+ TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
31
+ TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
32
+ function of(tag) {
33
+ const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
34
+ if (/^zh(\b|-)/.test(said)) {
35
+ return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
36
+ }
37
+ return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
38
+ }
39
+ TaLanguageUtil2.of = of;
40
+ function server(env = typeof process === "undefined" ? {} : process.env) {
41
+ return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
42
+ }
43
+ TaLanguageUtil2.server = server;
44
+ function pick(language, words) {
45
+ return words[of(language)];
46
+ }
47
+ TaLanguageUtil2.pick = pick;
48
+ function say(words) {
49
+ return words[server()];
50
+ }
51
+ TaLanguageUtil2.say = say;
52
+ function chinese(language) {
53
+ return of(language).startsWith("zh");
54
+ }
55
+ TaLanguageUtil2.chinese = chinese;
56
+ function cjk(language) {
57
+ return of(language) !== "en-US";
58
+ }
59
+ TaLanguageUtil2.cjk = cjk;
60
+ function list(language, items) {
61
+ return items.join(cjk(language) ? "、" : ", ");
62
+ }
63
+ TaLanguageUtil2.list = list;
64
+ })(TaLanguageUtil || (TaLanguageUtil = {}));
65
+
27
66
  // web-src/i18n.ts
28
67
  var EN = {
29
68
  title: "Scheduled",
@@ -237,10 +276,223 @@ var ZH = {
237
276
  toolClear: "清空定时任务",
238
277
  toolOther: "定时任务"
239
278
  };
279
+ var ZH_TW = {
280
+ title: "定時任務",
281
+ cardTitle: "接下來",
282
+ cardEmpty: "沒有排著的任務",
283
+ newTask: "新建任務",
284
+ editTask: "編輯任務",
285
+ count: "{count} 個任務",
286
+ runningCount: "{count} 個執行中",
287
+ offGroup: "已停用",
288
+ emptyTitle: "讓 Ta 按時幹活",
289
+ emptyHint: "每次執行都是一個新對話,結束後給你看總結。",
290
+ example1: "彙總昨天的提交",
291
+ example2: "檢查 CI 是否通過",
292
+ example3: "寫今天的日報",
293
+ next: "{time}後",
294
+ nextAt: "下次 {time}",
295
+ running: "執行中…",
296
+ paused: "已暫停",
297
+ done: "已完成",
298
+ runNow: "立即執行",
299
+ edit: "編輯",
300
+ delete: "刪除",
301
+ confirmDelete: "刪除「{name}」?",
302
+ confirmDeleteMessage: "它的執行記錄一起刪除;對話保留。",
303
+ enable: "啟用",
304
+ prompt: "要 Ta 做什麼?",
305
+ promptPlaceholder: "例如:檢查 main 分支的 CI 是否通過,沒通過就查明原因",
306
+ name: "名字",
307
+ namePlaceholder: "可不填",
308
+ when: "時間",
309
+ once: "一次",
310
+ every: "每隔",
311
+ daily: "每天",
312
+ weekdays: "工作日",
313
+ weekly: "每週",
314
+ custom: "Cron",
315
+ minutes: "分鐘",
316
+ hours: "小時",
317
+ days: "天",
318
+ directory: "目錄",
319
+ notify: "通知我",
320
+ notifyDefault: "預設",
321
+ notifyAlways: "每次執行",
322
+ notifyError: "失敗時",
323
+ notifyNever: "不通知",
324
+ model: "模型",
325
+ thinking: "思考級別",
326
+ more: "更多",
327
+ cancel: "取消",
328
+ save: "儲存",
329
+ create: "建立",
330
+ preview: "下次執行 {time}",
331
+ noNext: "沒有下次執行",
332
+ runs: "執行記錄",
333
+ noRuns: "還沒有執行過",
334
+ byHand: "手動",
335
+ openChat: "開啟對話",
336
+ noChat: "這次執行沒有對話。",
337
+ success: "完成",
338
+ error: "失敗",
339
+ missed: "錯過",
340
+ interrupted: "Ta 服務在執行中途停止了。",
341
+ timeout: "執行時間太長,已停止。",
342
+ missedText: "到點時 Ta 服務沒有執行。",
343
+ started: "已開始執行「{name}」",
344
+ finished: "「{name}」已完成",
345
+ failed: "「{name}」執行失敗",
346
+ created: "已建立定時任務",
347
+ updated: "已更新",
348
+ enabled: "已啟用",
349
+ disabled: "已暫停",
350
+ removed: "已刪除 {names}",
351
+ removedNone: "沒有刪除任何任務",
352
+ noTasks: "還沒有定時任務。試試 /loop 30m <要做的事>。",
353
+ show: "檢視",
354
+ failedAction: "操作失敗:{message}",
355
+ help: "定時任務",
356
+ serviceNeeded: "定時任務在 Ta 服務裡執行。",
357
+ makeExtension: "做成擴充功能",
358
+ makeExtensionHint: "讓 Ta 為這個任務的結果做一個專屬頁面",
359
+ extensionAsk: "把定時任務「{name}」做成擴充功能,用專屬頁面呈現它的執行結果",
360
+ change: "讓 Ta 改",
361
+ changeTitle: "讓 Ta 修改「{name}」",
362
+ changePlaceholder: "想怎麼改?比如:只在工作日早上 9 點執行",
363
+ changeAsk: "修改定時任務「{name}」:{text}",
364
+ promptLabel: "Ta 要做的事",
365
+ showAll: "展開全文",
366
+ showLess: "收起",
367
+ stats: "已執行 {runs} 次",
368
+ statsFailed: "已執行 {runs} 次 · 失敗 {fails} 次",
369
+ lastRun: "上次 {time}",
370
+ moreOptions: "更多選項",
371
+ shortcut: "{key} + 回車{action}",
372
+ modelFailed: "做擴充功能的模型({model})現在用不了,已改用預設模型:{message}",
373
+ toolAdd: "新建定時任務",
374
+ toolUpdate: "修改定時任務",
375
+ toolList: "檢視定時任務",
376
+ toolShow: "檢視定時任務",
377
+ toolEnable: "開啟定時任務",
378
+ toolDisable: "暫停定時任務",
379
+ toolDelete: "刪除定時任務",
380
+ toolRun: "立即執行定時任務",
381
+ toolRuns: "檢視執行記錄",
382
+ toolClear: "清空定時任務",
383
+ toolOther: "定時任務"
384
+ };
385
+ var JA = {
386
+ title: "スケジュール",
387
+ cardTitle: "次のこと",
388
+ cardEmpty: "スケジュールされたタスクがありません",
389
+ newTask: "新しいタスク",
390
+ editTask: "タスクを編集",
391
+ count: "{count} 個のタスク",
392
+ runningCount: "{count} 個実行中",
393
+ offGroup: "オフ",
394
+ emptyTitle: "Ta にスケジュールに従って作業させる",
395
+ emptyHint: "各実行は新しい会話です。実行終了後にサマリーを表示します。",
396
+ example1: "yesterday のコミットをまとめる",
397
+ example2: "CI が通っているか確認",
398
+ example3: "今日の日報を書く",
399
+ next: "{time} 以内",
400
+ nextAt: "次回 {time}",
401
+ running: "実行中…",
402
+ paused: "一時停止中",
403
+ done: "完了",
404
+ runNow: "今すぐ実行",
405
+ edit: "編集",
406
+ delete: "削除",
407
+ confirmDelete: "{name} を削除しますか?",
408
+ confirmDeleteMessage: "その実行も削除されます。会話は残ります。",
409
+ enable: "オン",
410
+ prompt: "Ta に何をさせますか?",
411
+ promptPlaceholder: "例:main ブランチの CI が通っているか確認してください。通っていない場合は理由を調査してください",
412
+ name: "名前",
413
+ namePlaceholder: "オプション",
414
+ when: "いつ",
415
+ once: "1 回",
416
+ every: "ごと",
417
+ daily: "毎日",
418
+ weekdays: "平日",
419
+ weekly: "毎週",
420
+ custom: "Cron",
421
+ minutes: "分",
422
+ hours: "時間",
423
+ days: "日",
424
+ directory: "ディレクトリ",
425
+ notify: "通知",
426
+ notifyDefault: "デフォルト",
427
+ notifyAlways: "毎回実行",
428
+ notifyError: "失敗時",
429
+ notifyNever: "なし",
430
+ model: "モデル",
431
+ thinking: "思考レベル",
432
+ more: "さらに",
433
+ cancel: "キャンセル",
434
+ save: "保存",
435
+ create: "作成",
436
+ preview: "次回実行 {time}",
437
+ noNext: "次回実行なし",
438
+ runs: "実行",
439
+ noRuns: "まだ実行がありません",
440
+ byHand: "手動",
441
+ openChat: "会話を開く",
442
+ noChat: "この実行には会話がありません。",
443
+ success: "完了",
444
+ error: "失敗",
445
+ missed: "逃した",
446
+ interrupted: "Ta サービスが実行中に停止しました。",
447
+ timeout: "実行に時間がかかりすぎて停止しました。",
448
+ missedText: "指定時刻に Ta サービスが実行されていませんでした。",
449
+ started: "{name} の実行を開始しました",
450
+ finished: "{name} が完了しました",
451
+ failed: "{name} が失敗しました",
452
+ created: "スケジュールされたタスクが作成されました",
453
+ updated: "更新されました",
454
+ enabled: "オンになりました",
455
+ disabled: "一時停止しました",
456
+ removed: "{names} を削除しました",
457
+ removedNone: "タスクが削除されませんでした",
458
+ noTasks: "スケジュールされたタスクがまだありません。/loop 30m <すること> を試してください。",
459
+ show: "表示",
460
+ failedAction: "できませんでした:{message}",
461
+ help: "スケジュールされたタスク",
462
+ serviceNeeded: "スケジュールされたタスクは Ta サービスで実行します。",
463
+ makeExtension: "拡張機能を作成",
464
+ makeExtensionHint: "このタスクの結果用に Ta が独自のページを作成します",
465
+ extensionAsk: "スケジュールされたタスク「{name}」を拡張機能にして、その結果を表示するページを作成します",
466
+ change: "Ta に変更させる",
467
+ changeTitle: "「{name}」を Ta に変更させる",
468
+ changePlaceholder: "どのように変更しますか?例えば、平日の朝 9 時のみ実行する",
469
+ changeAsk: "スケジュールされたタスク「{name}」を変更:{text}",
470
+ promptLabel: "Ta が行うこと",
471
+ showAll: "すべて表示",
472
+ showLess: "より少ない表示",
473
+ stats: "{runs} 回実行しました",
474
+ statsFailed: "{runs} 回実行 · {fails} 回失敗",
475
+ lastRun: "前回 {time}",
476
+ moreOptions: "その他のオプション",
477
+ shortcut: "{key} + Enter で {action}",
478
+ modelFailed: "拡張機能を作成するモデル({model})は現在使用できません。デフォルトモデルに変更しました:{message}",
479
+ toolAdd: "スケジュール",
480
+ toolUpdate: "スケジュールされたタスクを変更",
481
+ toolList: "スケジュールされたタスクを一覧表示",
482
+ toolShow: "スケジュールされたタスクを表示",
483
+ toolEnable: "スケジュールされたタスクをオンにする",
484
+ toolDisable: "スケジュールされたタスクを一時停止",
485
+ toolDelete: "スケジュールされたタスクを削除",
486
+ toolRun: "スケジュールされたタスクを今すぐ実行",
487
+ toolRuns: "の実行を表示",
488
+ toolClear: "スケジュールされたタスクをクリア",
489
+ toolOther: "スケジュールされたタスク"
490
+ };
491
+ var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
240
492
  var CronWords;
241
493
  ((CronWords) => {
242
494
  function of(language) {
243
- return language === "zh-CN" ? ZH : EN;
495
+ return TaLanguageUtil.pick(language, WORDS);
244
496
  }
245
497
  CronWords.of = of;
246
498
  function format(text, values) {
@@ -430,8 +682,10 @@ var Duration;
430
682
  })(Duration ||= {});
431
683
  var EN_DAYS = ["Sundays", "Mondays", "Tuesdays", "Wednesdays", "Thursdays", "Fridays", "Saturdays"];
432
684
  var ZH_DAYS = ["日", "一", "二", "三", "四", "五", "六"];
433
- var WORDS = {
434
- en: {
685
+ var ZH_TW_DAYS = ["日", "一", "二", "三", "四", "五", "六"];
686
+ var JA_DAYS = ["日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"];
687
+ var WORDS2 = {
688
+ "en-US": {
435
689
  once: (time) => `Once, ${time}`,
436
690
  every: (amount, unit) => amount === 1 ? `Every ${unit}` : `Every ${amount} ${unit}s`,
437
691
  everyRaw: (duration) => `Every ${duration}`,
@@ -442,7 +696,7 @@ var WORDS = {
442
696
  hourly: (minute) => minute === 0 ? "Hourly" : `Hourly at :${pad(minute)}`,
443
697
  cron: (expression) => `Cron ${expression}`
444
698
  },
445
- zh: {
699
+ "zh-CN": {
446
700
  once: (time) => `${time} 运行一次`,
447
701
  every: (amount, unit) => `每 ${amount === 1 ? "" : `${amount} `}${{ minute: "分钟", hour: "小时", day: "天" }[unit]}`.replace("每 天", "每天"),
448
702
  everyRaw: (duration) => `每 ${duration}`,
@@ -452,6 +706,28 @@ var WORDS = {
452
706
  monthly: (day, time) => `每月 ${day} 日 ${time}`,
453
707
  hourly: (minute) => minute === 0 ? "每小时" : `每小时第 ${minute} 分`,
454
708
  cron: (expression) => `cron ${expression}`
709
+ },
710
+ "zh-TW": {
711
+ once: (time) => `${time} 執行一次`,
712
+ every: (amount, unit) => `每 ${amount === 1 ? "" : `${amount} `}${{ minute: "分鐘", hour: "小時", day: "天" }[unit]}`.replace("每 天", "每天"),
713
+ everyRaw: (duration) => `每 ${duration}`,
714
+ daily: (time) => `每天 ${time}`,
715
+ weekdays: (time) => `工作日 ${time}`,
716
+ weekly: (day, time) => `每週${ZH_TW_DAYS[day]} ${time}`,
717
+ monthly: (day, time) => `每月 ${day} 日 ${time}`,
718
+ hourly: (minute) => minute === 0 ? "每小時" : `每小時第 ${minute} 分`,
719
+ cron: (expression) => `cron ${expression}`
720
+ },
721
+ "ja-JP": {
722
+ once: (time) => `${time}に1回実行`,
723
+ every: (amount, unit) => amount === 1 ? `毎${{ minute: "分", hour: "時間", day: "日" }[unit]}` : `毎${amount}${{ minute: "分", hour: "時間", day: "日" }[unit]}`,
724
+ everyRaw: (duration) => `毎 ${duration}`,
725
+ daily: (time) => `毎日 ${time}`,
726
+ weekdays: (time) => `平日 ${time}`,
727
+ weekly: (day, time) => `${JA_DAYS[day]} ${time}`,
728
+ monthly: (day, time) => `毎月${day}日 ${time}`,
729
+ hourly: (minute) => minute === 0 ? "毎時間" : `毎時間 :${pad(minute)}`,
730
+ cron: (expression) => `Cron ${expression}`
455
731
  }
456
732
  };
457
733
  function pad(value) {
@@ -521,7 +797,8 @@ var ScheduleUtil;
521
797
  }
522
798
  ScheduleUtil.clock = clock;
523
799
  function describe(schedule, language, now = new Date) {
524
- const words = WORDS[language.startsWith("zh") ? "zh" : "en"];
800
+ const lang = TaLanguageUtil.of(language);
801
+ const words = WORDS2[lang];
525
802
  switch (schedule.kind) {
526
803
  case "once":
527
804
  return words.once(clock(new Date(schedule.at), now));
@@ -685,12 +962,19 @@ function message(error) {
685
962
  }
686
963
  function until(time, now = Date.now()) {
687
964
  const minutes = Math.max(1, Math.round((time - now) / 60000));
688
- const zh = pi.ui.language === "zh-CN";
965
+ const language = pi.ui.language;
689
966
  const [amount, unit] = minutes < 60 ? [minutes, "minute"] : minutes < 48 * 60 ? [Math.round(minutes / 60), "hour"] : [Math.round(minutes / 1440), "day"];
690
- if (zh) {
691
- return `${amount} ${{ minute: "分钟", hour: "小时", day: "天" }[unit]}`;
967
+ const unitMap = {
968
+ "zh-CN": { minute: "分钟", hour: "小时", day: "天" },
969
+ "zh-TW": { minute: "分鐘", hour: "小時", day: "天" },
970
+ "en-US": { minute: "minute", hour: "hour", day: "day" },
971
+ "ja-JP": { minute: "分", hour: "時間", day: "日" }
972
+ };
973
+ const unitKey = unitMap[language]?.[unit] ?? unitMap["en-US"][unit];
974
+ if (TaLanguageUtil.cjk(language)) {
975
+ return `${amount} ${unitKey}`;
692
976
  }
693
- return `${amount} ${unit}${amount === 1 ? "" : "s"}`;
977
+ return `${amount} ${unitKey}${amount === 1 ? "" : "s"}`;
694
978
  }
695
979
  function basename(path) {
696
980
  return path.replace(/[\\/]+$/, "").split(/[\\/]/).pop() || path;
@@ -711,16 +995,21 @@ class CronClient {
711
995
  start() {
712
996
  this.stop = this.api.storage.onChange((keys) => {
713
997
  if (keys.includes(Keys.TASKS)) {
714
- this.load();
998
+ this.quietly(this.load());
715
999
  }
716
1000
  for (const key of keys) {
717
1001
  const id = key.startsWith("runs/") ? key.slice(5) : undefined;
718
1002
  if (id && this.state.runs[id]) {
719
- this.loadRuns(id);
1003
+ this.quietly(this.loadRuns(id));
720
1004
  }
721
1005
  }
722
1006
  });
723
- this.load();
1007
+ this.quietly(this.load());
1008
+ }
1009
+ quietly(reading) {
1010
+ reading.catch(() => {
1011
+ return;
1012
+ });
724
1013
  }
725
1014
  dispose() {
726
1015
  this.stop?.();
@@ -754,7 +1043,7 @@ class CronClient {
754
1043
  this.reading = undefined;
755
1044
  if (this.again) {
756
1045
  this.again = false;
757
- this.load();
1046
+ this.quietly(this.load());
758
1047
  }
759
1048
  }
760
1049
  }
@@ -1660,7 +1949,7 @@ function weekdayNames() {
1660
1949
  const language = pi.ui.language;
1661
1950
  let names = DAY_NAMES.get(language);
1662
1951
  if (!names) {
1663
- const format = new Intl.DateTimeFormat(language === "zh-CN" ? "zh-CN" : "en", { weekday: "short" });
1952
+ const format = new Intl.DateTimeFormat(language, { weekday: "short" });
1664
1953
  names = Array.from({ length: 7 }, (_, day) => format.format(new Date(2023, 0, 1 + day)));
1665
1954
  DAY_NAMES.set(language, names);
1666
1955
  }