@zhin.js/plugin-reminder 1.0.4 → 1.0.6
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 +12 -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 +4 -0
- package/lib/storage.d.ts.map +1 -0
- package/lib/storage.js +51 -0
- package/lib/storage.js.map +1 -0
- 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 +12 -4
- 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 +54 -0
- package/src/timing.ts +6 -4
- package/src/tool-actor.ts +15 -4
package/lib/storage.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createRelationalStateStore, TASK_TARGET_COLUMNS, TASK_RECEIPT_COLUMNS, encodeTaskTarget, decodeTaskTarget, encodeTaskReceipts, decodeTaskReceipts, encodeStorageIdentity, decodeStorageIdentity } from 'zhin.js/plugin-runtime';
|
|
2
|
+
import { REMINDER_STATE_KEY } from './service.js';
|
|
3
|
+
import { ADMIN_REMINDER_STATE_KEY } from './admin-tasks.js';
|
|
4
|
+
const taskColumns = {
|
|
5
|
+
id: { type: 'text', length: 36, primary: true }, position: { type: 'integer', nullable: false },
|
|
6
|
+
...TASK_TARGET_COLUMNS, sender_id: { type: 'text', nullable: true }, creation: { type: 'text', nullable: true },
|
|
7
|
+
locale: { type: 'text', length: 16, nullable: true },
|
|
8
|
+
content: { type: 'text', nullable: false }, state: { type: 'text', length: 24, nullable: false },
|
|
9
|
+
created_at: { type: 'bigint', nullable: false }, next_run_at: { type: 'bigint', nullable: false },
|
|
10
|
+
interval_ms: { type: 'bigint', nullable: true }, claim_id: { type: 'text', nullable: true },
|
|
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 },
|
|
12
|
+
};
|
|
13
|
+
function codec(admin) {
|
|
14
|
+
const table = admin ? 'admin_reminder_tasks' : 'reminder_tasks';
|
|
15
|
+
const receipts = 'admin_reminder_receipts';
|
|
16
|
+
return {
|
|
17
|
+
key: admin ? ADMIN_REMINDER_STATE_KEY : REMINDER_STATE_KEY,
|
|
18
|
+
header: { table: `${table}_book`, definition: {
|
|
19
|
+
version: { type: 'integer', nullable: true }, revision: { type: 'text', nullable: true },
|
|
20
|
+
} },
|
|
21
|
+
addColumns: { [table]: ['locale', 'detail_key', 'failure_code'] },
|
|
22
|
+
tables: { [table]: taskColumns, ...(admin ? { [receipts]: TASK_RECEIPT_COLUMNS } : {}) },
|
|
23
|
+
encode(value) {
|
|
24
|
+
const book = value;
|
|
25
|
+
if (book.version !== 1 || !Array.isArray(book.tasks))
|
|
26
|
+
throw new Error('Unsupported reminder book; original state was preserved');
|
|
27
|
+
return { header: { version: book.version, revision: 'revision' in book ? book.revision : null }, rows: {
|
|
28
|
+
[table]: book.tasks.map((task, position) => ({ id: task.id, position, ...encodeTaskTarget(task.target),
|
|
29
|
+
sender_id: 'senderId' in task ? encodeStorageIdentity(task.senderId) : null,
|
|
30
|
+
locale: task.locale ?? 'zh-CN', creation: 'creation' in task ? task.creation : null, content: encodeStorageIdentity(task.text),
|
|
31
|
+
state: 'status' in task ? task.status : task.state, created_at: task.createdAt, next_run_at: task.nextRunAt,
|
|
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 })),
|
|
33
|
+
...(admin ? { [receipts]: encodeTaskReceipts(book.receipts) } : {}),
|
|
34
|
+
} };
|
|
35
|
+
},
|
|
36
|
+
decode(header, rows) {
|
|
37
|
+
return { version: Number(header.version), ...(admin ? { revision: String(header.revision) } : {}),
|
|
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),
|
|
39
|
+
createdAt: Number(row.created_at), nextRunAt: Number(row.next_run_at), intervalMs: row.interval_ms == null ? null : Number(row.interval_ms),
|
|
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) }),
|
|
41
|
+
...(admin ? { creation: String(row.creation), state: String(row.state) } : { senderId: decodeStorageIdentity(row.sender_id), status: String(row.state) }),
|
|
42
|
+
})), ...(admin ? { receipts: decodeTaskReceipts(rows[receipts]) } : {}),
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Both pools keep their existing CAS API but persist independent rows atomically. */
|
|
48
|
+
export function createReminderState(database) {
|
|
49
|
+
return createRelationalStateStore(database, [codec(false), codec(true)]);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +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,kBA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ONDS: 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,CA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igin } 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,EAA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CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/plugin-reminder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
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/
|
|
26
|
-
"@zhin.js/
|
|
27
|
-
"@zhin.js/
|
|
25
|
+
"@zhin.js/skill": "1.1.10",
|
|
26
|
+
"@zhin.js/tool": "1.1.10",
|
|
27
|
+
"@zhin.js/im-contract": "1.1.7"
|
|
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.16",
|
|
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.16",
|
|
51
|
+
"@zhin.js/schedule-feature": "1.1.9"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=22.19.0"
|
package/plugin.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
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';
|
|
5
6
|
import { assertReminderTimezone } from "./lib/config.js";
|
|
7
|
+
import { createReminderState } from "./lib/storage.js";
|
|
6
8
|
import { ReminderService } from "./lib/service.js";
|
|
7
9
|
import { reminderServiceToken } from "./lib/runtime.js";
|
|
8
10
|
export default definePlugin({
|
|
@@ -12,15 +14,19 @@ export default definePlugin({
|
|
|
12
14
|
setup(context) {
|
|
13
15
|
const config = context.config.get();
|
|
14
16
|
assertReminderTimezone(config.timezone);
|
|
15
|
-
const
|
|
17
|
+
const database = context.resources.use(databaseHostToken);
|
|
18
|
+
const state = database.state;
|
|
19
|
+
const taskState = createReminderState(database);
|
|
16
20
|
const outbound = context.resources.use(outboundHostToken);
|
|
17
21
|
if (!outbound.sendTarget)
|
|
18
22
|
throw new Error('提醒需要支持精确 DeliveryTarget 的 Outbound Host');
|
|
19
|
-
const service = new ReminderService(
|
|
23
|
+
const service = new ReminderService(taskState, outbound, config, context.resources.use(projectLocaleToken));
|
|
20
24
|
context.resources.provide(reminderServiceToken, service);
|
|
21
25
|
context.resources.provide(pluginTaskProviderToken, service.administratorTasks);
|
|
22
26
|
context.resources.provide(pluginVerificationToken, {
|
|
23
|
-
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'] } }],
|
|
24
30
|
async run(checkId) {
|
|
25
31
|
if (checkId !== 'local-state')
|
|
26
32
|
throw new Error('Unknown reminder verification check');
|
|
@@ -30,7 +36,9 @@ export default definePlugin({
|
|
|
30
36
|
const value = await state.get(key);
|
|
31
37
|
if (value?.probe !== true)
|
|
32
38
|
throw new Error('持久状态读写结果不一致');
|
|
33
|
-
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'] } };
|
|
34
42
|
}
|
|
35
43
|
finally {
|
|
36
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
|
});
|