@aalis/plugin-scheduler 0.15.0 → 0.16.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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type ConfigOf } from '@aalis/schema-config';
2
+ import { type TextRef } from '@aalis/schema-i18n';
2
3
  interface SchedulerJobConfig {
3
4
  name: string;
4
5
  /** cron 表达式 (5 段: 分 时 日 月 周),支持快捷符 @hourly/@daily/@weekly/@monthly */
@@ -18,7 +19,8 @@ interface SchedulerJobConfig {
18
19
  * 代理身份的 platform(authority 查表用),与 `platform` 解耦。
19
20
  * 由创建路径 snapshot 真实调用者身份;触发时回填到 IncomingMessage.actor.platform。
20
21
  * - WebUI/CLI/AI 调用工具创建:来自调用者 callCtx,**调用者匿名则留空**
21
- * - 静态 yaml jobs 缺省:webui:console(owner 级,因为编辑配置文件本身就是 owner 行为)
22
+ * - 静态 yaml jobs:与 actorUserId 成对填写;都不写为 webui:console(owner 级,因为编辑配置文件本身就是 owner 行为);
23
+ * 只写一项是配置错误,这条任务不载入
22
24
  * - 老 dynamic jobs 缺省:**留空 = 匿名**(带启动 warning,便于审计)
23
25
  *
24
26
  * 留空即匿名(defaultAuthority)。触发路径不会为空值发明身份——owner 只能来自显式来源。
@@ -44,6 +46,7 @@ interface SchedulerConfig {
44
46
  /** 动态任务持久化文件路径 */
45
47
  persistPath: string;
46
48
  }
49
+ /** 任务触发时的消息声明 ownerApproved,内容里的指令照常执行:经 addJob、setJob 交来的内容要是 owner 过目过原文的 */
47
50
  export interface SchedulerService {
48
51
  getJobs(): Array<{
49
52
  name: string;
@@ -59,14 +62,18 @@ export interface SchedulerService {
59
62
  lastRun: number;
60
63
  nextRun: number;
61
64
  runCount: number;
62
- lastResult: string;
65
+ /** 最近执行结果,给人看:可以是文字对象(@aalis/schema-i18n),还没执行过时为空串 */
66
+ lastResult: string | TextRef;
63
67
  }>;
64
68
  pauseJob(name: string): boolean;
65
69
  resumeJob(name: string): boolean;
66
70
  triggerJob(name: string): Promise<boolean>;
67
- /** cron 无效时抛出原因,不收下 */
71
+ /** 名字是配置文件里写了的、cron 或固定间隔无效时抛出原因,不收下 */
68
72
  addJob(job: SchedulerJobConfig): void;
69
- /** upsert:已存在则先 remove 再 add;计划任务页的新建与编辑都经它。cron 无效时抛出原因,原任务不变 */
73
+ /**
74
+ * upsert:已存在则先 remove 再 add;计划任务页的新建与编辑都经它。名字是配置文件里写了的、cron 或固定间隔无效时抛出原因,
75
+ * 原任务不变
76
+ */
70
77
  setJob(job: SchedulerJobConfig): void;
71
78
  removeJob(name: string): boolean;
72
79
  }
@@ -75,69 +82,69 @@ export declare const configSchema: {
75
82
  readonly jobs: {
76
83
  readonly type: "array";
77
84
  readonly onInvalid: "error";
78
- readonly label: "计划任务列表";
79
- readonly description: "配置定时/周期性任务,让 AI 主动执行计划。";
85
+ readonly label: TextRef;
86
+ readonly description: TextRef;
80
87
  readonly items: {
81
88
  readonly name: {
82
89
  readonly type: "string";
83
- readonly label: "任务名称";
90
+ readonly label: TextRef;
84
91
  };
85
92
  readonly cron: {
86
93
  readonly type: "string";
87
- readonly label: "Cron 表达式";
88
- readonly description: "5 段格式: 分 时 日 月 周 (如 \"0 9 * * *\" = 每天 9:00)。与\"固定间隔\"二选一。";
94
+ readonly label: TextRef;
95
+ readonly description: TextRef;
89
96
  };
90
97
  readonly interval: {
91
98
  readonly type: "number";
92
- readonly label: "固定间隔(秒)";
93
- readonly description: "每隔 N 秒执行一次。与\"Cron 表达式\"二选一。";
99
+ readonly label: TextRef;
100
+ readonly description: TextRef;
94
101
  };
95
102
  readonly runAt: {
96
103
  readonly type: "string";
97
- readonly label: "一次性运行时间";
98
- readonly description: "ISO 字符串;执行一次后自动禁用。";
104
+ readonly label: TextRef;
105
+ readonly description: TextRef;
99
106
  };
100
107
  readonly sessionId: {
101
108
  readonly type: "string";
102
- readonly label: "目标会话 ID";
103
- readonly description: "任务消息发往的会话 ID。可以是真实群/用户会话,也可以自定义(如 scheduler::daily)。";
109
+ readonly label: TextRef;
110
+ readonly description: TextRef;
104
111
  };
105
112
  readonly platform: {
106
113
  readonly type: "string";
107
114
  readonly onInvalid: "error";
108
- readonly label: "目标平台";
115
+ readonly label: TextRef;
109
116
  readonly required: true;
110
- readonly description: "任务消息的平台标识(如 internal、webui、onebot)。仅用于消息路由。";
117
+ readonly description: TextRef;
111
118
  readonly default: "internal";
112
119
  };
113
120
  readonly actorPlatform: {
114
121
  readonly type: "string";
115
122
  readonly onInvalid: "error";
116
- readonly label: "执行身份-平台";
117
- readonly description: "代理身份的 platform(与目标平台解耦)。authority 按 (actorPlatform, actorUserId) 联合裁决能力。留空 = webui。";
123
+ readonly label: TextRef;
124
+ readonly description: TextRef;
118
125
  };
119
126
  readonly actorUserId: {
120
127
  readonly type: "string";
121
128
  readonly onInvalid: "error";
122
- readonly label: "执行身份-用户 ID";
123
- readonly description: "代理身份的 userId。留空 = console(与 actorPlatform=webui 组合即 owner,拥有一切能力)。";
129
+ readonly label: TextRef;
130
+ readonly description: TextRef;
124
131
  };
125
132
  readonly content: {
126
133
  readonly type: "string";
127
- readonly label: "消息内容";
134
+ readonly label: TextRef;
128
135
  readonly default: "";
129
- readonly description: "发送给 Agent 的指令/提示内容。";
136
+ readonly description: TextRef;
130
137
  };
131
138
  readonly enabled: {
132
139
  readonly type: "boolean";
133
- readonly label: "启用";
140
+ readonly label: TextRef;
134
141
  readonly default: true;
135
142
  readonly onInvalid: "error";
136
143
  };
137
144
  readonly timeZone: {
138
145
  readonly type: "string";
139
- readonly label: "时区 (IANA)";
140
- readonly description: "cron 求值所用时区,如 Asia/Shanghai、Europe/London。留空 = 进程本地时区。仅对 cron 类任务生效。";
146
+ readonly label: TextRef;
147
+ readonly description: TextRef;
141
148
  };
142
149
  };
143
150
  readonly default: [];
@@ -145,9 +152,9 @@ export declare const configSchema: {
145
152
  readonly persistPath: {
146
153
  readonly type: "string";
147
154
  readonly onInvalid: "error";
148
- readonly label: "动态任务存储路径";
155
+ readonly label: TextRef;
149
156
  readonly default: "data:/scheduler-jobs.json";
150
- readonly description: "通过 AI 或 WebUI 创建的任务会持久化到此 storage URI,重启后自动加载。";
157
+ readonly description: TextRef;
151
158
  };
152
159
  };
153
160
  declare const _default: import("@aalis/core").PluginDefinition<{
@@ -157,6 +164,8 @@ declare const _default: import("@aalis/core").PluginDefinition<{
157
164
  storage: import("@aalis/core").OptionalUse<import("@aalis/api-storage").StorageService, import("@aalis/api-storage").BoundStorage>;
158
165
  /** 计划任务页的登记口;无 WebUI 时调度照常运行 */
159
166
  webui: import("@aalis/core").OptionalUse<import("@aalis/api-webui").WebUIService, import("@aalis/api-webui").BoundWebui>;
167
+ /** 认调用所在的会话是不是子会话(在子会话里建任务要写明目标);没有会话管理就没有子会话 */
168
+ sessionManager: import("@aalis/core").OptionalUse<import("@aalis/api-session-manager").SessionManagerService, import("@aalis/api-session-manager").SessionManagerService>;
160
169
  events: import("@aalis/core").ServiceDescriptor<(identity: symbol) => import("@aalis/core").Events, import("@aalis/core").Events>;
161
170
  lifecycle: import("@aalis/core").ServiceDescriptor<(identity: symbol) => import("@aalis/core").LifecycleCap, import("@aalis/core").LifecycleCap>;
162
171
  logger: import("@aalis/core").ServiceDescriptor<(identity: symbol) => import("@aalis/core").Logger, import("@aalis/core").Logger>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,QAAQ,EAA0C,MAAM,sBAAsB,CAAC;AAc7F,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa;I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