@zhin.js/plugin-reminder 1.0.5 → 1.0.7
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.md +8 -2
- package/commands/remind/after/index.js +6 -5
- package/commands/remind/after/index.ts +6 -5
- package/commands/remind/at/index.js +8 -7
- package/commands/remind/at/index.ts +6 -5
- package/commands/remind/cancel/index.js +5 -4
- package/commands/remind/cancel/index.ts +5 -4
- package/commands/remind/create/index.js +3 -3
- package/commands/remind/create/index.ts +3 -3
- package/commands/remind/every/index.js +6 -5
- package/commands/remind/every/index.ts +6 -5
- package/commands/remind/list/index.js +5 -4
- package/commands/remind/list/index.ts +5 -4
- package/lib/admin-i18n.d.ts +155 -0
- package/lib/admin-i18n.d.ts.map +1 -0
- package/lib/admin-i18n.js +152 -0
- package/lib/admin-i18n.js.map +1 -0
- package/lib/admin-tasks.d.ts +35 -5
- package/lib/admin-tasks.d.ts.map +1 -1
- package/lib/admin-tasks.js +77 -57
- package/lib/admin-tasks.js.map +1 -1
- package/lib/caller.d.ts +2 -1
- package/lib/caller.d.ts.map +1 -1
- package/lib/caller.js +5 -3
- package/lib/caller.js.map +1 -1
- package/lib/config.js +6 -6
- package/lib/config.js.map +1 -1
- package/lib/create-reminder.d.ts.map +1 -1
- package/lib/create-reminder.js +31 -25
- package/lib/create-reminder.js.map +1 -1
- package/lib/duration.d.ts +2 -1
- package/lib/duration.d.ts.map +1 -1
- package/lib/duration.js +4 -3
- package/lib/duration.js.map +1 -1
- package/lib/i18n.d.ts +2 -0
- package/lib/i18n.d.ts.map +1 -0
- package/lib/i18n.js +336 -0
- package/lib/i18n.js.map +1 -0
- package/lib/natural-time.d.ts +5 -1
- package/lib/natural-time.d.ts.map +1 -1
- package/lib/natural-time.js +71 -57
- package/lib/natural-time.js.map +1 -1
- package/lib/service.d.ts +8 -2
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +47 -36
- package/lib/service.js.map +1 -1
- package/lib/storage.d.ts.map +1 -1
- package/lib/storage.js +7 -5
- package/lib/storage.js.map +1 -1
- package/lib/timing.d.ts +2 -1
- package/lib/timing.d.ts.map +1 -1
- package/lib/timing.js +5 -4
- package/lib/timing.js.map +1 -1
- package/lib/tool-actor.d.ts +2 -0
- package/lib/tool-actor.d.ts.map +1 -1
- package/lib/tool-actor.js +14 -4
- package/lib/tool-actor.js.map +1 -1
- package/package.json +9 -9
- package/plugin.js +8 -3
- package/schema.json +30 -0
- package/skills/reminder/tools/reminder_cancel/index.js +3 -2
- package/skills/reminder/tools/reminder_cancel/index.ts +3 -2
- package/skills/reminder/tools/reminder_create/index.js +7 -6
- package/skills/reminder/tools/reminder_create/index.ts +7 -6
- package/skills/reminder/tools/reminder_list/index.js +3 -2
- package/skills/reminder/tools/reminder_list/index.ts +3 -2
- package/src/admin-i18n.ts +154 -0
- package/src/admin-tasks.ts +79 -53
- package/src/caller.ts +5 -3
- package/src/config.ts +6 -6
- package/src/create-reminder.ts +33 -25
- package/src/duration.ts +5 -3
- package/src/i18n.ts +336 -0
- package/src/natural-time.ts +40 -30
- package/src/service.ts +51 -38
- package/src/storage.ts +7 -5
- package/src/timing.ts +6 -4
- package/src/tool-actor.ts +15 -4
package/lib/storage.js
CHANGED
|
@@ -4,10 +4,11 @@ import { ADMIN_REMINDER_STATE_KEY } from './admin-tasks.js';
|
|
|
4
4
|
const taskColumns = {
|
|
5
5
|
id: { type: 'text', length: 36, primary: true }, position: { type: 'integer', nullable: false },
|
|
6
6
|
...TASK_TARGET_COLUMNS, sender_id: { type: 'text', nullable: true }, creation: { type: 'text', nullable: true },
|
|
7
|
+
locale: { type: 'text', length: 16, nullable: true },
|
|
7
8
|
content: { type: 'text', nullable: false }, state: { type: 'text', length: 24, nullable: false },
|
|
8
9
|
created_at: { type: 'bigint', nullable: false }, next_run_at: { type: 'bigint', nullable: false },
|
|
9
10
|
interval_ms: { type: 'bigint', nullable: true }, claim_id: { type: 'text', nullable: true },
|
|
10
|
-
last_run_at: { type: 'bigint', nullable: true }, detail: { type: 'text', nullable: false },
|
|
11
|
+
last_run_at: { type: 'bigint', nullable: true }, detail: { type: 'text', nullable: false }, detail_key: { type: 'text', length: 40, nullable: true }, failure_code: { type: 'text', length: 64, nullable: true },
|
|
11
12
|
};
|
|
12
13
|
function codec(admin) {
|
|
13
14
|
const table = admin ? 'admin_reminder_tasks' : 'reminder_tasks';
|
|
@@ -17,6 +18,7 @@ function codec(admin) {
|
|
|
17
18
|
header: { table: `${table}_book`, definition: {
|
|
18
19
|
version: { type: 'integer', nullable: true }, revision: { type: 'text', nullable: true },
|
|
19
20
|
} },
|
|
21
|
+
addColumns: { [table]: ['locale', 'detail_key', 'failure_code'] },
|
|
20
22
|
tables: { [table]: taskColumns, ...(admin ? { [receipts]: TASK_RECEIPT_COLUMNS } : {}) },
|
|
21
23
|
encode(value) {
|
|
22
24
|
const book = value;
|
|
@@ -25,17 +27,17 @@ function codec(admin) {
|
|
|
25
27
|
return { header: { version: book.version, revision: 'revision' in book ? book.revision : null }, rows: {
|
|
26
28
|
[table]: book.tasks.map((task, position) => ({ id: task.id, position, ...encodeTaskTarget(task.target),
|
|
27
29
|
sender_id: 'senderId' in task ? encodeStorageIdentity(task.senderId) : null,
|
|
28
|
-
creation: 'creation' in task ? task.creation : null, content: encodeStorageIdentity(task.text),
|
|
30
|
+
locale: task.locale ?? 'zh-CN', creation: 'creation' in task ? task.creation : null, content: encodeStorageIdentity(task.text),
|
|
29
31
|
state: 'status' in task ? task.status : task.state, created_at: task.createdAt, next_run_at: task.nextRunAt,
|
|
30
|
-
interval_ms: task.intervalMs, claim_id: task.claimId, last_run_at: task.lastRunAt, detail: encodeStorageIdentity(task.detail) })),
|
|
32
|
+
interval_ms: task.intervalMs, claim_id: task.claimId, last_run_at: task.lastRunAt, detail: encodeStorageIdentity(task.detail), detail_key: task.detailKey ?? null, failure_code: 'failureCode' in task ? task.failureCode ?? null : null })),
|
|
31
33
|
...(admin ? { [receipts]: encodeTaskReceipts(book.receipts) } : {}),
|
|
32
34
|
} };
|
|
33
35
|
},
|
|
34
36
|
decode(header, rows) {
|
|
35
37
|
return { version: Number(header.version), ...(admin ? { revision: String(header.revision) } : {}),
|
|
36
|
-
tasks: rows[table].map(row => ({ id: String(row.id), target: decodeTaskTarget(row), text: decodeStorageIdentity(row.content),
|
|
38
|
+
tasks: rows[table].map(row => ({ id: String(row.id), target: decodeTaskTarget(row), text: decodeStorageIdentity(row.content), locale: row.locale == null ? 'zh-CN' : String(row.locale),
|
|
37
39
|
createdAt: Number(row.created_at), nextRunAt: Number(row.next_run_at), intervalMs: row.interval_ms == null ? null : Number(row.interval_ms),
|
|
38
|
-
claimId: row.claim_id == null ? null : String(row.claim_id), lastRunAt: row.last_run_at == null ? null : Number(row.last_run_at), detail: decodeStorageIdentity(row.detail),
|
|
40
|
+
claimId: row.claim_id == null ? null : String(row.claim_id), lastRunAt: row.last_run_at == null ? null : Number(row.last_run_at), detail: decodeStorageIdentity(row.detail), ...(row.detail_key == null ? {} : { detailKey: String(row.detail_key) }), ...(row.failure_code == null ? {} : { failureCode: String(row.failure_code) }),
|
|
39
41
|
...(admin ? { creation: String(row.creation), state: String(row.state) } : { senderId: decodeStorageIdentity(row.sender_id), status: String(row.state) }),
|
|
40
42
|
})), ...(admin ? { receipts: decodeTaskReceipts(rows[receipts]) } : {}),
|
|
41
43
|
};
|
package/lib/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,gBAAgB,EAChH,kBAAkB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,qBAAqB,EAChC,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAqB,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAA0B,MAAM,kBAAkB,CAAC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BAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;oBACrU,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;iBAC1J,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACzE,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,mBAAmB,CAAC,QAA4B;IAC9D,OAAO,0BAA0B,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC3E,CAAC"}
|
package/lib/timing.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
1
2
|
export declare const MAX_DELAY_SECONDS: number;
|
|
2
|
-
export declare function parseReminderInstant(value: string): number;
|
|
3
|
+
export declare function parseReminderInstant(value: string, locale?: Locale): number;
|
|
3
4
|
export declare function nextPeriodicTime(from: number, interval: number, now: number): number;
|
|
4
5
|
//# sourceMappingURL=timing.d.ts.map
|
package/lib/timing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../src/timing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,QAAqB,CAAC;AAEpD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../src/timing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,eAAO,MAAM,iBAAiB,QAAqB,CAAC;AAEpD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAU3E;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpF"}
|
package/lib/timing.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { reminderMessages as t } from './i18n.js';
|
|
1
2
|
export const MAX_DELAY_SECONDS = 365 * 24 * 60 * 60;
|
|
2
|
-
export function parseReminderInstant(value) {
|
|
3
|
+
export function parseReminderInstant(value, locale) {
|
|
3
4
|
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?(?:Z|[+-]\d{2}:\d{2})$/u.test(value))
|
|
4
|
-
throw new TypeError(
|
|
5
|
+
throw new TypeError(t(locale, 'absoluteFormat'));
|
|
5
6
|
const [year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0] = value.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?/u).slice(1).map(item => Number(item ?? 0));
|
|
6
7
|
const calendar = new Date(0);
|
|
7
8
|
calendar.setUTCFullYear(year, month, 0);
|
|
8
9
|
const daysInMonth = calendar.getUTCDate();
|
|
9
10
|
if (month < 1 || month > 12 || day < 1 || day > daysInMonth || hour > 23 || minute > 59 || second > 59)
|
|
10
|
-
throw new TypeError('
|
|
11
|
+
throw new TypeError(t(locale, 'instantInvalid'));
|
|
11
12
|
const time = Date.parse(value);
|
|
12
13
|
if (!Number.isSafeInteger(time))
|
|
13
|
-
throw new TypeError('
|
|
14
|
+
throw new TypeError(t(locale, 'instantInvalid'));
|
|
14
15
|
return time;
|
|
15
16
|
}
|
|
16
17
|
export function nextPeriodicTime(from, interval, now) {
|
package/lib/timing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../src/timing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../src/timing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,IAAI,CAAC,EAAE,MAAM,WAAW,CAAC;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAEpD,MAAM,UAAU,oBAAoB,CAAC,KAAa,EAAE,MAAe;IACjE,IAAI,CAAC,gFAAgF,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IACpJ,MAAM,CAAC,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,wDAAwD,CAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;IACxL,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7B,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC;IAC1C,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,WAAW,IAAI,IAAI,GAAG,EAAE,IAAI,MAAM,GAAG,EAAE,IAAI,MAAM,GAAG,EAAE;QAAE,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IACzJ,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAClF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,QAAgB,EAAE,GAAW;IAC1E,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;AACrE,CAAC"}
|
package/lib/tool-actor.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Locale } from 'zhin.js/i18n';
|
|
1
2
|
/**
|
|
2
3
|
* Resolve a ReminderActor from an Agent Tool invocation (IM origin only).
|
|
3
4
|
*/
|
|
@@ -7,6 +8,7 @@ import type { ToolInvocationOrigin } from "@zhin.js/tool";
|
|
|
7
8
|
import { type ReminderActor } from "./service.js";
|
|
8
9
|
export interface ToolActorContext {
|
|
9
10
|
readonly origin: ToolInvocationOrigin;
|
|
11
|
+
readonly locale?: Locale;
|
|
10
12
|
readonly principal: Readonly<{
|
|
11
13
|
subjectId: string;
|
|
12
14
|
roles: readonly string[];
|
package/lib/tool-actor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-actor.d.ts","sourceRoot":"","sources":["../src/tool-actor.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAqB,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAC9E,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,gBAAgB,GAAG,CAAC,CAAC;CACjD;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"tool-actor.d.ts","sourceRoot":"","sources":["../src/tool-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE1D;;GAEG;AACH,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAqB,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAC9E,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,gBAAgB,GAAG,CAAC,CAAC;CACjD;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAmC5E;AAED,6EAA6E;AAC7E,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,GACxB,aAAa,CAIf"}
|
package/lib/tool-actor.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolveLocale } from 'zhin.js/i18n';
|
|
2
|
+
import { reminderMessages as t } from './i18n.js';
|
|
1
3
|
/**
|
|
2
4
|
* Resolve a ReminderActor from an Agent Tool invocation (IM origin only).
|
|
3
5
|
*/
|
|
@@ -8,7 +10,7 @@ import { ReminderInputError } from "./service.js";
|
|
|
8
10
|
export function toolDeliveryTarget(context) {
|
|
9
11
|
const origin = context.origin;
|
|
10
12
|
if (origin.kind !== "im") {
|
|
11
|
-
throw new ReminderInputError(
|
|
13
|
+
throw new ReminderInputError(t(context.locale, 'toolOrigin'));
|
|
12
14
|
}
|
|
13
15
|
const index = context.project(adapterFeatureId);
|
|
14
16
|
const matches = index
|
|
@@ -17,7 +19,15 @@ export function toolDeliveryTarget(context) {
|
|
|
17
19
|
endpoint.name === origin.endpoint) &&
|
|
18
20
|
index.clientAdapter(endpoint.id) === origin.platform);
|
|
19
21
|
if (matches.length !== 1) {
|
|
20
|
-
throw new ReminderInputError(
|
|
22
|
+
throw new ReminderInputError(t(context.locale, 'toolEndpoint'));
|
|
23
|
+
}
|
|
24
|
+
if (origin.conversation) {
|
|
25
|
+
const canonical = createDeliveryTarget({ conversation: origin.conversation });
|
|
26
|
+
if (canonical.endpoint.id !== String(matches[0].id) || canonical.endpoint.adapter !== origin.platform
|
|
27
|
+
|| canonical.kind !== origin.scope || canonical.id !== origin.sceneId || canonical.threadId !== origin.threadId) {
|
|
28
|
+
throw new ReminderInputError(t(context.locale, 'toolEndpoint'));
|
|
29
|
+
}
|
|
30
|
+
return canonical;
|
|
21
31
|
}
|
|
22
32
|
return createDeliveryTarget({
|
|
23
33
|
conversation: {
|
|
@@ -32,7 +42,7 @@ export function toolDeliveryTarget(context) {
|
|
|
32
42
|
export function reminderActorFromTool(context) {
|
|
33
43
|
const senderId = context.principal.subjectId?.trim();
|
|
34
44
|
if (!senderId)
|
|
35
|
-
throw new ReminderInputError(
|
|
36
|
-
return { senderId, target: toolDeliveryTarget(context) };
|
|
45
|
+
throw new ReminderInputError(t(context.locale, 'toolSender'));
|
|
46
|
+
return { senderId, target: toolDeliveryTarget(context), locale: resolveLocale(context.locale) };
|
|
37
47
|
}
|
|
38
48
|
//# sourceMappingURL=tool-actor.js.map
|
package/lib/tool-actor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-actor.js","sourceRoot":"","sources":["../src/tool-actor.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAuB,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAqB,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EAAE,kBAAkB,EAAsB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-actor.js","sourceRoot":"","sources":["../src/tool-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,gBAAgB,IAAI,CAAC,EAAE,MAAM,WAAW,CAAC;AAClD;;GAEG;AACH,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hin.js/plugin-reminder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Persistent personal reminders for Zhin Plugin Runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"schema.json"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@zhin.js/im-contract": "1.1.
|
|
26
|
-
"@zhin.js/skill": "1.1.
|
|
27
|
-
"@zhin.js/tool": "1.1.
|
|
25
|
+
"@zhin.js/im-contract": "1.1.8",
|
|
26
|
+
"@zhin.js/skill": "1.1.10",
|
|
27
|
+
"@zhin.js/tool": "1.1.11"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"zod": "^4.0.0",
|
|
31
|
-
"zhin.js": "^1.1.
|
|
32
|
-
"@zhin.js/command": "^1.1.
|
|
33
|
-
"@zhin.js/schedule-feature": "^1.1.
|
|
31
|
+
"zhin.js": "^1.1.17",
|
|
32
|
+
"@zhin.js/command": "^1.1.11",
|
|
33
|
+
"@zhin.js/schedule-feature": "^1.1.9"
|
|
34
34
|
},
|
|
35
35
|
"peerDependenciesMeta": {
|
|
36
36
|
"@zhin.js/command": {
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"typescript": "^6.0.3",
|
|
48
48
|
"vitest": "^4.1.10",
|
|
49
49
|
"zod": "^4.4.3",
|
|
50
|
-
"zhin.js": "1.1.
|
|
51
|
-
"@zhin.js/schedule-feature": "1.1.
|
|
50
|
+
"zhin.js": "1.1.17",
|
|
51
|
+
"@zhin.js/schedule-feature": "1.1.9"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=22.19.0"
|
package/plugin.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { projectLocaleToken } from 'zhin.js/i18n';
|
|
2
3
|
import { databaseHostToken, definePlugin, outboundHostToken } from 'zhin.js';
|
|
3
4
|
import { pluginVerificationToken, pluginTaskProviderToken } from 'zhin.js/plugin-runtime';
|
|
4
5
|
import { randomUUID } from 'node:crypto';
|
|
@@ -19,11 +20,13 @@ export default definePlugin({
|
|
|
19
20
|
const outbound = context.resources.use(outboundHostToken);
|
|
20
21
|
if (!outbound.sendTarget)
|
|
21
22
|
throw new Error('提醒需要支持精确 DeliveryTarget 的 Outbound Host');
|
|
22
|
-
const service = new ReminderService(taskState, outbound, config);
|
|
23
|
+
const service = new ReminderService(taskState, outbound, config, context.resources.use(projectLocaleToken));
|
|
23
24
|
context.resources.provide(reminderServiceToken, service);
|
|
24
25
|
context.resources.provide(pluginTaskProviderToken, service.administratorTasks);
|
|
25
26
|
context.resources.provide(pluginVerificationToken, {
|
|
26
|
-
checks: () => [{ id: 'local-state', title: '持久状态读写检查',
|
|
27
|
+
checks: () => [{ id: 'local-state', title: '持久状态读写检查', titleI18n: { en: 'Persistent state read/write check' }, scope: 'local',
|
|
28
|
+
effects: ['写入、读取并删除一个独立探针键;不创建提醒、不发送消息'],
|
|
29
|
+
effectsI18n: { en: ['Write, read and delete an isolated probe key; no reminders are created and no messages are sent'] } }],
|
|
27
30
|
async run(checkId) {
|
|
28
31
|
if (checkId !== 'local-state')
|
|
29
32
|
throw new Error('Unknown reminder verification check');
|
|
@@ -33,7 +36,9 @@ export default definePlugin({
|
|
|
33
36
|
const value = await state.get(key);
|
|
34
37
|
if (value?.probe !== true)
|
|
35
38
|
throw new Error('持久状态读写结果不一致');
|
|
36
|
-
return { status: 'passed', summary: '本地持久状态读写通过',
|
|
39
|
+
return { status: 'passed', summary: '本地持久状态读写通过', summaryI18n: { en: 'Local persistent state read/write check passed' },
|
|
40
|
+
evidence: ['独立探针写入并成功读回;清理后删除', '仅验证当前 owner 的数据库状态;不证明调度或平台投递健康'],
|
|
41
|
+
evidenceI18n: { en: ['An isolated probe was written, read back and deleted during cleanup', 'Checks only this owner’s database state; does not verify scheduling or platform delivery'] } };
|
|
37
42
|
}
|
|
38
43
|
finally {
|
|
39
44
|
await state.delete(key);
|
package/schema.json
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
"timezone": {
|
|
6
6
|
"type": "string",
|
|
7
7
|
"description": "解释 create 自然时间并显示提醒的 IANA 时区;ISO 绝对时间仍须显式 offset",
|
|
8
|
+
"x-i18n": {
|
|
9
|
+
"en": {
|
|
10
|
+
"description": "IANA timezone for natural reminder times and display. Absolute ISO times still require an explicit offset."
|
|
11
|
+
}
|
|
12
|
+
},
|
|
8
13
|
"default": "UTC",
|
|
9
14
|
"x-zhin-config": {
|
|
10
15
|
"effect": "reload"
|
|
@@ -13,6 +18,11 @@
|
|
|
13
18
|
"maxTasks": {
|
|
14
19
|
"type": "number",
|
|
15
20
|
"description": "每实例聊天个人提醒池的活跃任务上限;与管理员池独立,降低上限不删除既有任务",
|
|
21
|
+
"x-i18n": {
|
|
22
|
+
"en": {
|
|
23
|
+
"description": "Maximum active personal chat reminders per instance, separate from administrator tasks. Lowering the limit does not delete existing tasks."
|
|
24
|
+
}
|
|
25
|
+
},
|
|
16
26
|
"default": 20,
|
|
17
27
|
"minimum": 1,
|
|
18
28
|
"maximum": 32,
|
|
@@ -24,6 +34,11 @@
|
|
|
24
34
|
"adminMaxTasks": {
|
|
25
35
|
"type": "number",
|
|
26
36
|
"description": "每实例管理员提醒池的活跃任务上限(待执行、暂停或未确认);与聊天池独立,两池总量可达上限之和",
|
|
37
|
+
"x-i18n": {
|
|
38
|
+
"en": {
|
|
39
|
+
"description": "Maximum active administrator reminders (scheduled, paused or unconfirmed) per instance. Separate from chat tasks; the two quotas are additive."
|
|
40
|
+
}
|
|
41
|
+
},
|
|
27
42
|
"default": 20,
|
|
28
43
|
"minimum": 1,
|
|
29
44
|
"maximum": 32,
|
|
@@ -35,6 +50,11 @@
|
|
|
35
50
|
"maxTasksPerSender": {
|
|
36
51
|
"type": "number",
|
|
37
52
|
"description": "同一发送者在同一会话的任务上限",
|
|
53
|
+
"x-i18n": {
|
|
54
|
+
"en": {
|
|
55
|
+
"description": "Maximum tasks per sender in the same conversation."
|
|
56
|
+
}
|
|
57
|
+
},
|
|
38
58
|
"default": 10,
|
|
39
59
|
"minimum": 1,
|
|
40
60
|
"maximum": 10,
|
|
@@ -46,6 +66,11 @@
|
|
|
46
66
|
"batchSize": {
|
|
47
67
|
"type": "number",
|
|
48
68
|
"description": "每次扫描最多投递的任务数",
|
|
69
|
+
"x-i18n": {
|
|
70
|
+
"en": {
|
|
71
|
+
"description": "Maximum tasks delivered in each scan."
|
|
72
|
+
}
|
|
73
|
+
},
|
|
49
74
|
"default": 5,
|
|
50
75
|
"minimum": 1,
|
|
51
76
|
"maximum": 5,
|
|
@@ -57,6 +82,11 @@
|
|
|
57
82
|
"missedGraceSeconds": {
|
|
58
83
|
"type": "number",
|
|
59
84
|
"description": "周期轮次超过此延迟后跳过;停机期间不补历史轮次",
|
|
85
|
+
"x-i18n": {
|
|
86
|
+
"en": {
|
|
87
|
+
"description": "Skip recurring runs delayed beyond this many seconds. Missed runs during downtime are not backfilled."
|
|
88
|
+
}
|
|
89
|
+
},
|
|
60
90
|
"default": 15,
|
|
61
91
|
"minimum": 5,
|
|
62
92
|
"maximum": 60,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { reminderMessages as t } from "../../../../lib/i18n.js";
|
|
2
3
|
import { defineAgentTool } from "@zhin.js/tool";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
import { replyReminder } from "../../../../lib/caller.js";
|
|
@@ -17,8 +18,8 @@ export default defineAgentTool({
|
|
|
17
18
|
const service = context.use(reminderServiceToken);
|
|
18
19
|
const ok = await service.cancel(reminderActorFromTool(context), id);
|
|
19
20
|
return ok
|
|
20
|
-
?
|
|
21
|
-
:
|
|
21
|
+
? t(context.locale, 'toolCancelled', { id })
|
|
22
|
+
: t(context.locale, 'toolNotFound', { id });
|
|
22
23
|
});
|
|
23
24
|
},
|
|
24
25
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { reminderMessages as t } from '../../../../src/i18n.js';
|
|
1
2
|
import { defineAgentTool } from "@zhin.js/tool";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import { replyReminder } from "../../../../src/caller.js";
|
|
@@ -18,8 +19,8 @@ export default defineAgentTool({
|
|
|
18
19
|
const service = context.use(reminderServiceToken);
|
|
19
20
|
const ok = await service.cancel(reminderActorFromTool(context), id);
|
|
20
21
|
return ok
|
|
21
|
-
?
|
|
22
|
-
:
|
|
22
|
+
? t(context.locale, 'toolCancelled', { id })
|
|
23
|
+
: t(context.locale, 'toolNotFound', { id });
|
|
23
24
|
});
|
|
24
25
|
},
|
|
25
26
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { reminderMessages as t } from "../../../../lib/i18n.js";
|
|
2
3
|
import { defineAgentTool } from "@zhin.js/tool";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
import { replyReminder } from "../../../../lib/caller.js";
|
|
@@ -36,22 +37,22 @@ export default defineAgentTool({
|
|
|
36
37
|
every_seconds !== undefined ? "every" : undefined,
|
|
37
38
|
].filter(Boolean);
|
|
38
39
|
if (modes.length !== 1) {
|
|
39
|
-
throw new ReminderInputError(
|
|
40
|
+
throw new ReminderInputError(t(context.locale, 'toolMode'));
|
|
40
41
|
}
|
|
41
42
|
const service = context.use(reminderServiceToken);
|
|
42
43
|
const actor = reminderActorFromTool(context);
|
|
43
44
|
if (every_seconds !== undefined) {
|
|
44
45
|
const intervalMs = every_seconds * 1000;
|
|
45
46
|
const task = await service.add(actor, text, Date.now() + intervalMs, intervalMs);
|
|
46
|
-
return
|
|
47
|
+
return `${t(context.locale, 'createdPeriodic')}\n${service.describe(task, context.locale)}`;
|
|
47
48
|
}
|
|
48
49
|
if (after) {
|
|
49
|
-
const delayMs = parseRelativeDelayMs(after);
|
|
50
|
+
const delayMs = parseRelativeDelayMs(after, context.locale);
|
|
50
51
|
const task = await service.add(actor, text, Date.now() + delayMs, null);
|
|
51
|
-
return
|
|
52
|
+
return `${t(context.locale, 'created')}\n${service.describe(task, context.locale)}`;
|
|
52
53
|
}
|
|
53
|
-
const task = await service.add(actor, text, parseReminderInstant(at), null);
|
|
54
|
-
return
|
|
54
|
+
const task = await service.add(actor, text, parseReminderInstant(at, context.locale), null);
|
|
55
|
+
return `${t(context.locale, 'created')}\n${service.describe(task, context.locale)}`;
|
|
55
56
|
});
|
|
56
57
|
},
|
|
57
58
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { reminderMessages as t } from '../../../../src/i18n.js';
|
|
1
2
|
import { defineAgentTool } from "@zhin.js/tool";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import { replyReminder } from "../../../../src/caller.js";
|
|
@@ -45,7 +46,7 @@ export default defineAgentTool({
|
|
|
45
46
|
].filter(Boolean);
|
|
46
47
|
if (modes.length !== 1) {
|
|
47
48
|
throw new ReminderInputError(
|
|
48
|
-
|
|
49
|
+
t(context.locale, 'toolMode')
|
|
49
50
|
);
|
|
50
51
|
}
|
|
51
52
|
const service = context.use(reminderServiceToken);
|
|
@@ -58,20 +59,20 @@ export default defineAgentTool({
|
|
|
58
59
|
Date.now() + intervalMs,
|
|
59
60
|
intervalMs
|
|
60
61
|
);
|
|
61
|
-
return
|
|
62
|
+
return `${t(context.locale, 'createdPeriodic')}\n${service.describe(task, context.locale)}`;
|
|
62
63
|
}
|
|
63
64
|
if (after) {
|
|
64
|
-
const delayMs = parseRelativeDelayMs(after);
|
|
65
|
+
const delayMs = parseRelativeDelayMs(after, context.locale);
|
|
65
66
|
const task = await service.add(actor, text, Date.now() + delayMs, null);
|
|
66
|
-
return
|
|
67
|
+
return `${t(context.locale, 'created')}\n${service.describe(task, context.locale)}`;
|
|
67
68
|
}
|
|
68
69
|
const task = await service.add(
|
|
69
70
|
actor,
|
|
70
71
|
text,
|
|
71
|
-
parseReminderInstant(at
|
|
72
|
+
parseReminderInstant(at!, context.locale),
|
|
72
73
|
null
|
|
73
74
|
);
|
|
74
|
-
return
|
|
75
|
+
return `${t(context.locale, 'created')}\n${service.describe(task, context.locale)}`;
|
|
75
76
|
});
|
|
76
77
|
},
|
|
77
78
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { reminderMessages as t } from "../../../../lib/i18n.js";
|
|
2
3
|
import { defineAgentTool } from "@zhin.js/tool";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
import { replyReminder } from "../../../../lib/caller.js";
|
|
@@ -15,8 +16,8 @@ export default defineAgentTool({
|
|
|
15
16
|
const service = context.use(reminderServiceToken);
|
|
16
17
|
const tasks = await service.list(reminderActorFromTool(context));
|
|
17
18
|
if (tasks.length === 0)
|
|
18
|
-
return
|
|
19
|
-
return tasks.map((task) => service.describe(task)).join("\n---\n");
|
|
19
|
+
return t(context.locale, 'toolEmpty');
|
|
20
|
+
return tasks.map((task) => service.describe(task, context.locale)).join("\n---\n");
|
|
20
21
|
});
|
|
21
22
|
},
|
|
22
23
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { reminderMessages as t } from '../../../../src/i18n.js';
|
|
1
2
|
import { defineAgentTool } from "@zhin.js/tool";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import { replyReminder } from "../../../../src/caller.js";
|
|
@@ -15,8 +16,8 @@ export default defineAgentTool({
|
|
|
15
16
|
return replyReminder(async () => {
|
|
16
17
|
const service = context.use(reminderServiceToken);
|
|
17
18
|
const tasks = await service.list(reminderActorFromTool(context));
|
|
18
|
-
if (tasks.length === 0) return
|
|
19
|
-
return tasks.map((task) => service.describe(task)).join("\n---\n");
|
|
19
|
+
if (tasks.length === 0) return t(context.locale, 'toolEmpty');
|
|
20
|
+
return tasks.map((task) => service.describe(task, context.locale)).join("\n---\n");
|
|
20
21
|
});
|
|
21
22
|
},
|
|
22
23
|
});
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { createMessages, type Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { PluginTaskError } from 'zhin.js/plugin-runtime';
|
|
3
|
+
|
|
4
|
+
const catalog = {
|
|
5
|
+
"invalidTarget": {
|
|
6
|
+
"zh-CN": "请提供完整有效的目标账号、会话、父容器和线程",
|
|
7
|
+
"en": "Provide a complete valid account, conversation, parent container and thread."
|
|
8
|
+
},
|
|
9
|
+
"requestReused": {
|
|
10
|
+
"zh-CN": "同一请求 ID 已用于其他内容",
|
|
11
|
+
"en": "This request ID was already used for different content."
|
|
12
|
+
},
|
|
13
|
+
"invalidAction": {
|
|
14
|
+
"zh-CN": "任务 ID 或操作无效",
|
|
15
|
+
"en": "Invalid task ID or action."
|
|
16
|
+
},
|
|
17
|
+
"updateParameters": {
|
|
18
|
+
"zh-CN": "仅编辑操作接受参数",
|
|
19
|
+
"en": "Only the update action accepts parameters."
|
|
20
|
+
},
|
|
21
|
+
"finished": {
|
|
22
|
+
"zh-CN": "任务已结束,不能再次取消",
|
|
23
|
+
"en": "This task has ended and cannot be cancelled again."
|
|
24
|
+
},
|
|
25
|
+
"invalidMutation": {
|
|
26
|
+
"zh-CN": "操作须包含 UUID requestId 和读取到的 expectedRevision",
|
|
27
|
+
"en": "The operation requires a UUID requestId and the expectedRevision read from the task list."
|
|
28
|
+
},
|
|
29
|
+
"replayConflict": {
|
|
30
|
+
"zh-CN": "同一操作请求 ID 已用于其他内容,禁止重放",
|
|
31
|
+
"en": "This operation request ID was used for different content and cannot be replayed."
|
|
32
|
+
},
|
|
33
|
+
"delivering": {
|
|
34
|
+
"zh-CN": "投递中或未确认;不会自动重试",
|
|
35
|
+
"en": "Delivery is in progress or unconfirmed; no automatic retry."
|
|
36
|
+
},
|
|
37
|
+
"quota": {
|
|
38
|
+
"zh-CN": "管理员提醒池已达上限,请先取消任务;聊天个人提醒使用独立配额",
|
|
39
|
+
"en": "The administrator reminder quota is full. Cancel a task first; chat reminders have a separate quota."
|
|
40
|
+
},
|
|
41
|
+
"notFound": {
|
|
42
|
+
"zh-CN": "未找到当前实例的管理员任务;聊天任务不在此入口管理",
|
|
43
|
+
"en": "No administrator task was found in this instance. Chat tasks are managed separately."
|
|
44
|
+
},
|
|
45
|
+
"pauseState": {
|
|
46
|
+
"zh-CN": "仅待执行任务可以暂停;未确认投递不能暂停或恢复",
|
|
47
|
+
"en": "Only scheduled tasks can be paused. Unconfirmed deliveries cannot be paused or resumed."
|
|
48
|
+
},
|
|
49
|
+
"resumeState": {
|
|
50
|
+
"zh-CN": "仅已暂停任务可以恢复;未确认投递不能恢复或重试",
|
|
51
|
+
"en": "Only paused tasks can be resumed. Unconfirmed deliveries cannot be resumed or retried."
|
|
52
|
+
},
|
|
53
|
+
"expired": {
|
|
54
|
+
"zh-CN": "一次性任务时间已过,请先编辑为未来时间再恢复",
|
|
55
|
+
"en": "This one-time reminder is past due. Set a future time before resuming."
|
|
56
|
+
},
|
|
57
|
+
"updateState": {
|
|
58
|
+
"zh-CN": "编辑前请先暂停任务;未确认投递不能编辑",
|
|
59
|
+
"en": "Pause the task before editing. Unconfirmed deliveries cannot be edited."
|
|
60
|
+
},
|
|
61
|
+
"stopped": {
|
|
62
|
+
"zh-CN": "管理员提醒服务属于已停止的插件实例",
|
|
63
|
+
"en": "This administrator reminder service belongs to a stopped plugin instance."
|
|
64
|
+
},
|
|
65
|
+
"retired": {
|
|
66
|
+
"zh-CN": "管理员提醒服务属于未发布或已退役的 generation",
|
|
67
|
+
"en": "This administrator reminder service belongs to an unpublished or retired generation."
|
|
68
|
+
},
|
|
69
|
+
"invalidParameters": {
|
|
70
|
+
"zh-CN": "参数须包含 1–500 字提醒内容、带 offset 的 ISO 时间及可选的 60 秒至一年整数周期",
|
|
71
|
+
"en": "Provide 1–500 characters of reminder text, an ISO time with an explicit offset, and optionally an integer interval from 60 seconds to one year."
|
|
72
|
+
},
|
|
73
|
+
"invalidInstant": {
|
|
74
|
+
"zh-CN": "提醒时间须为有效且带 Z 或 ±hh:mm 的 ISO 时间",
|
|
75
|
+
"en": "Use a valid ISO reminder time with Z or an explicit ±hh:mm offset."
|
|
76
|
+
},
|
|
77
|
+
"future": {
|
|
78
|
+
"zh-CN": "提醒时间须在未来一年内",
|
|
79
|
+
"en": "The reminder must be scheduled within the next year."
|
|
80
|
+
},
|
|
81
|
+
"revision": {
|
|
82
|
+
"zh-CN": "任务列表已变化,请刷新后重新确认操作",
|
|
83
|
+
"en": "The task list changed. Refresh it and confirm the operation again."
|
|
84
|
+
},
|
|
85
|
+
"capacity": {
|
|
86
|
+
"zh-CN": "管理员提醒池状态达到 32 条或 60 KiB 上限,请先取消并整理任务",
|
|
87
|
+
"en": "Administrator reminders reached the 32-task or 60 KiB limit. Cancel and clean up tasks first."
|
|
88
|
+
},
|
|
89
|
+
"corrupt": {
|
|
90
|
+
"zh-CN": "管理员提醒持久状态格式无效,已停止投递",
|
|
91
|
+
"en": "Administrator reminder storage is invalid. Delivery has stopped."
|
|
92
|
+
},
|
|
93
|
+
"waiting": {
|
|
94
|
+
"zh-CN": "等待执行",
|
|
95
|
+
"en": "Waiting to run"
|
|
96
|
+
},
|
|
97
|
+
"paused": {
|
|
98
|
+
"zh-CN": "管理员暂停",
|
|
99
|
+
"en": "Paused by an administrator"
|
|
100
|
+
},
|
|
101
|
+
"resumedSkipping": {
|
|
102
|
+
"zh-CN": "已恢复,并跳过错过的周期轮次",
|
|
103
|
+
"en": "Resumed; missed intervals were skipped"
|
|
104
|
+
},
|
|
105
|
+
"resumed": {
|
|
106
|
+
"zh-CN": "管理员恢复",
|
|
107
|
+
"en": "Resumed by an administrator"
|
|
108
|
+
},
|
|
109
|
+
"edited": {
|
|
110
|
+
"zh-CN": "已编辑,保持暂停;请确认后恢复",
|
|
111
|
+
"en": "Updated and still paused. Confirm before resuming."
|
|
112
|
+
},
|
|
113
|
+
"cancelled": {
|
|
114
|
+
"zh-CN": "管理员取消;已经开始的投递无法撤回",
|
|
115
|
+
"en": "Cancelled by an administrator. A delivery already in progress cannot be recalled."
|
|
116
|
+
},
|
|
117
|
+
"skipped": {
|
|
118
|
+
"zh-CN": "已跳过错过的周期轮次",
|
|
119
|
+
"en": "Missed intervals were skipped"
|
|
120
|
+
},
|
|
121
|
+
"unknown": {
|
|
122
|
+
"zh-CN": "平台未确认投递,请核实目标会话后取消并另建任务;不会自动重试",
|
|
123
|
+
"en": "The platform did not confirm delivery. Check the target conversation, then cancel and create another task; no automatic retry."
|
|
124
|
+
},
|
|
125
|
+
"delivered": {
|
|
126
|
+
"zh-CN": "已确认投递",
|
|
127
|
+
"en": "Delivery confirmed"
|
|
128
|
+
},
|
|
129
|
+
"rejected": {
|
|
130
|
+
"zh-CN": "平台明确未投递或拒绝;任务已停止",
|
|
131
|
+
"en": "The platform confirmed no delivery or rejected it. The task has stopped."
|
|
132
|
+
},
|
|
133
|
+
"stateNote": {
|
|
134
|
+
"zh-CN": "{detail};状态仅表示调度事实,不代表平台连接或投递健康",
|
|
135
|
+
"en": "{detail}; state records scheduling facts, not platform connection or delivery health."
|
|
136
|
+
}
|
|
137
|
+
} as const;
|
|
138
|
+
export const adminText = createMessages(catalog);
|
|
139
|
+
export type AdminTextKey = keyof typeof catalog;
|
|
140
|
+
export function isAdminTextKey(value: unknown): value is AdminTextKey { return typeof value === 'string' && Object.hasOwn(catalog, value); }
|
|
141
|
+
|
|
142
|
+
/** Persist a stable presentation key; preserve legacy text for older readers. */
|
|
143
|
+
export function taskDetail(detailKey: AdminTextKey) { return { detailKey, detail: adminText('zh-CN', detailKey) }; }
|
|
144
|
+
export function formatTaskDetail(task: { detail: string; detailKey?: AdminTextKey }, locale?: Locale): string {
|
|
145
|
+
return task.detailKey ? adminText(locale, task.detailKey) : task.detail;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export class LocalizedTaskError extends PluginTaskError {
|
|
149
|
+
readonly messageKey: AdminTextKey;
|
|
150
|
+
constructor(code: ConstructorParameters<typeof PluginTaskError>[0], messageKey: AdminTextKey) {
|
|
151
|
+
super(code, adminText('zh-CN', messageKey)); this.messageKey = messageKey;
|
|
152
|
+
}
|
|
153
|
+
localize(locale?: Locale): PluginTaskError { return new PluginTaskError(this.code, adminText(locale, this.messageKey)); }
|
|
154
|
+
}
|