inspiration-agent 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +368 -0
- package/dist/.env.example +53 -0
- package/dist/README.md +368 -0
- package/dist/agent/ai.agent.js +712 -0
- package/dist/channel/feishu-connection.js +238 -0
- package/dist/channel/feishu.service.js +222 -0
- package/dist/cli.js +659 -0
- package/dist/config/system.prompt.txt +312 -0
- package/dist/index.js +176 -0
- package/dist/model/base-llm.service.js +320 -0
- package/dist/model/deepseek.service.js +18 -0
- package/dist/model/kimi.service.js +19 -0
- package/dist/model/minimax.service.js +35 -0
- package/dist/model/zhipu.service.js +26 -0
- package/dist/services/database.service.js +697 -0
- package/dist/services/memory.manager.js +486 -0
- package/dist/services/message.queue.js +157 -0
- package/dist/tools/browser.tools.js +814 -0
- package/dist/tools/command.tools.js +361 -0
- package/dist/tools/file.tools.js +222 -0
- package/dist/tools/memory.tools.js +393 -0
- package/dist/tools/scheduler.tools.js +559 -0
- package/dist/tools/search.tools.js +208 -0
- package/dist/utils/logger.js +52 -0
- package/dist/utils/markdown-renderer.js +207 -0
- package/package.json +51 -0
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
const cron = require("node-cron");
|
|
2
|
+
const logger = require("../utils/logger");
|
|
3
|
+
|
|
4
|
+
class SchedulerTools {
|
|
5
|
+
constructor(dbService, agentCallback, feishuService = null) {
|
|
6
|
+
this.dbService = dbService;
|
|
7
|
+
this.agentCallback = agentCallback;
|
|
8
|
+
this.feishuService = feishuService;
|
|
9
|
+
this.scheduledJobs = new Map();
|
|
10
|
+
this.defaultChatId = process.env.FEISHU_DEFAULT_CHAT_ID || null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
setFeishuService(feishuService) {
|
|
14
|
+
this.feishuService = feishuService;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
setDefaultChatId(chatId) {
|
|
18
|
+
this.defaultChatId = chatId;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async init() {
|
|
22
|
+
await this.loadAndStartAllTasks();
|
|
23
|
+
logger.info("定时任务调度器已初始化");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async loadAndStartAllTasks() {
|
|
27
|
+
try {
|
|
28
|
+
const tasks = await this.dbService.getEnabledScheduledTasks();
|
|
29
|
+
for (const task of tasks) {
|
|
30
|
+
this.startTask(task);
|
|
31
|
+
}
|
|
32
|
+
logger.info(`已加载 ${tasks.length} 个启用的定时任务`);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
logger.error(`加载定时任务失败: ${error.message}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
startTask(task) {
|
|
39
|
+
if (this.scheduledJobs.has(task.id)) {
|
|
40
|
+
this.stopTask(task.id);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!cron.validate(task.cronExpression)) {
|
|
44
|
+
logger.error(`无效的 cron 表达式: ${task.cronExpression}`);
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const job = cron.schedule(task.cronExpression, async () => {
|
|
49
|
+
await this.executeTask(task);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
this.scheduledJobs.set(task.id, job);
|
|
53
|
+
logger.info(`定时任务已启动: ${task.name} (ID: ${task.id}, Cron: ${task.cronExpression})`);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
stopTask(taskId) {
|
|
58
|
+
const job = this.scheduledJobs.get(taskId);
|
|
59
|
+
if (job) {
|
|
60
|
+
job.stop();
|
|
61
|
+
this.scheduledJobs.delete(taskId);
|
|
62
|
+
logger.info(`定时任务已停止: ID ${taskId}`);
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async executeTask(task) {
|
|
69
|
+
logger.info(`执行定时任务: ${task.name} (ID: ${task.id})`);
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
let result = null;
|
|
73
|
+
if (this.agentCallback) {
|
|
74
|
+
result = await this.agentCallback(task.prompt);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const now = new Date();
|
|
78
|
+
const nextRun = this.getNextRunTime(task.cronExpression);
|
|
79
|
+
await this.dbService.updateTaskRunInfo(task.id, now.toISOString(), nextRun);
|
|
80
|
+
|
|
81
|
+
if (result && this.feishuService && this.defaultChatId) {
|
|
82
|
+
const title = `⏰ 定时任务执行结果: ${task.name}`;
|
|
83
|
+
const content = `**执行时间:** ${now.toLocaleString("zh-CN")}\n\n**提示词:**\n${task.prompt}\n\n**执行结果:**\n${result}`;
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
await this.feishuService.sendRichTextMessage(this.defaultChatId, title, content);
|
|
87
|
+
logger.info(`定时任务结果已发送到飞书: ${task.name}`);
|
|
88
|
+
} catch (sendError) {
|
|
89
|
+
logger.error(`发送定时任务结果到飞书失败: ${sendError.message}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
logger.info(`定时任务执行完成: ${task.name}`);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
logger.error(`定时任务执行失败: ${task.name} - ${error.message}`);
|
|
96
|
+
|
|
97
|
+
if (this.feishuService && this.defaultChatId) {
|
|
98
|
+
try {
|
|
99
|
+
const errorTitle = `❌ 定时任务执行失败: ${task.name}`;
|
|
100
|
+
const errorContent = `**执行时间:** ${new Date().toLocaleString("zh-CN")}\n\n**错误信息:**\n${error.message}`;
|
|
101
|
+
await this.feishuService.sendRichTextMessage(
|
|
102
|
+
this.defaultChatId,
|
|
103
|
+
errorTitle,
|
|
104
|
+
errorContent
|
|
105
|
+
);
|
|
106
|
+
} catch (sendError) {
|
|
107
|
+
logger.error(`发送错误信息到飞书失败: ${sendError.message}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
getNextRunTime(cronExpression) {
|
|
114
|
+
try {
|
|
115
|
+
const interval = cron.parseExpression(cronExpression);
|
|
116
|
+
const next = interval.next();
|
|
117
|
+
return next.toISOString();
|
|
118
|
+
} catch (error) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async createScheduledTask(args) {
|
|
124
|
+
try {
|
|
125
|
+
const { name, description, cronExpression, prompt, enabled = true } = args;
|
|
126
|
+
|
|
127
|
+
if (!name || !cronExpression || !prompt) {
|
|
128
|
+
return {
|
|
129
|
+
success: false,
|
|
130
|
+
error: "缺少必要参数: name, cronExpression, prompt",
|
|
131
|
+
message: "创建定时任务失败: 缺少必要参数",
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!cron.validate(cronExpression)) {
|
|
136
|
+
return {
|
|
137
|
+
success: false,
|
|
138
|
+
error: `无效的 cron 表达式: ${cronExpression}`,
|
|
139
|
+
message: "创建定时任务失败: 无效的 cron 表达式",
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const nextRunAt = this.getNextRunTime(cronExpression);
|
|
144
|
+
|
|
145
|
+
const result = await this.dbService.saveScheduledTask({
|
|
146
|
+
name,
|
|
147
|
+
description: description || "",
|
|
148
|
+
cronExpression,
|
|
149
|
+
prompt,
|
|
150
|
+
enabled,
|
|
151
|
+
nextRunAt,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (enabled) {
|
|
155
|
+
const task = await this.dbService.getScheduledTaskById(result.id);
|
|
156
|
+
this.startTask(task);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
success: true,
|
|
161
|
+
id: result.id,
|
|
162
|
+
name,
|
|
163
|
+
cronExpression,
|
|
164
|
+
nextRunAt,
|
|
165
|
+
message: `成功创建定时任务: ${name} (ID: ${result.id}),下次执行时间: ${nextRunAt || "未知"}`,
|
|
166
|
+
};
|
|
167
|
+
} catch (error) {
|
|
168
|
+
return {
|
|
169
|
+
success: false,
|
|
170
|
+
error: error.message,
|
|
171
|
+
message: `创建定时任务失败: ${error.message}`,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async getAllScheduledTasks(args) {
|
|
177
|
+
try {
|
|
178
|
+
const tasks = await this.dbService.getAllScheduledTasks();
|
|
179
|
+
|
|
180
|
+
const taskList = tasks.map((task) => ({
|
|
181
|
+
id: task.id,
|
|
182
|
+
name: task.name,
|
|
183
|
+
description: task.description,
|
|
184
|
+
cronExpression: task.cronExpression,
|
|
185
|
+
prompt: task.prompt,
|
|
186
|
+
enabled: task.enabled,
|
|
187
|
+
lastRunAt: task.lastRunAt,
|
|
188
|
+
nextRunAt: task.nextRunAt,
|
|
189
|
+
runCount: task.runCount,
|
|
190
|
+
isRunning: this.scheduledJobs.has(task.id),
|
|
191
|
+
}));
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
success: true,
|
|
195
|
+
count: taskList.length,
|
|
196
|
+
tasks: taskList,
|
|
197
|
+
message: `成功获取 ${taskList.length} 个定时任务`,
|
|
198
|
+
};
|
|
199
|
+
} catch (error) {
|
|
200
|
+
return {
|
|
201
|
+
success: false,
|
|
202
|
+
error: error.message,
|
|
203
|
+
message: `获取定时任务列表失败: ${error.message}`,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async getScheduledTask(args) {
|
|
209
|
+
try {
|
|
210
|
+
const { id } = args;
|
|
211
|
+
|
|
212
|
+
if (!id) {
|
|
213
|
+
return {
|
|
214
|
+
success: false,
|
|
215
|
+
error: "缺少 id 参数",
|
|
216
|
+
message: "获取定时任务失败: 缺少 id 参数",
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const task = await this.dbService.getScheduledTaskById(id);
|
|
221
|
+
|
|
222
|
+
if (!task) {
|
|
223
|
+
return {
|
|
224
|
+
success: false,
|
|
225
|
+
error: "未找到指定的定时任务",
|
|
226
|
+
message: `获取定时任务失败: ID ${id} 的定时任务不存在`,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
success: true,
|
|
232
|
+
task: {
|
|
233
|
+
...task,
|
|
234
|
+
isRunning: this.scheduledJobs.has(task.id),
|
|
235
|
+
},
|
|
236
|
+
message: `成功获取定时任务: ${task.name} (ID: ${task.id})`,
|
|
237
|
+
};
|
|
238
|
+
} catch (error) {
|
|
239
|
+
return {
|
|
240
|
+
success: false,
|
|
241
|
+
error: error.message,
|
|
242
|
+
message: `获取定时任务失败: ${error.message}`,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async updateScheduledTask(args) {
|
|
248
|
+
try {
|
|
249
|
+
const { id, name, description, cronExpression, prompt, enabled } = args;
|
|
250
|
+
|
|
251
|
+
if (!id) {
|
|
252
|
+
return {
|
|
253
|
+
success: false,
|
|
254
|
+
error: "缺少 id 参数",
|
|
255
|
+
message: "更新定时任务失败: 缺少 id 参数",
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const existingTask = await this.dbService.getScheduledTaskById(id);
|
|
260
|
+
if (!existingTask) {
|
|
261
|
+
return {
|
|
262
|
+
success: false,
|
|
263
|
+
error: "未找到指定的定时任务",
|
|
264
|
+
message: `更新定时任务失败: ID ${id} 的定时任务不存在`,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (cronExpression && !cron.validate(cronExpression)) {
|
|
269
|
+
return {
|
|
270
|
+
success: false,
|
|
271
|
+
error: `无效的 cron 表达式: ${cronExpression}`,
|
|
272
|
+
message: "更新定时任务失败: 无效的 cron 表达式",
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const newCronExpression = cronExpression || existingTask.cronExpression;
|
|
277
|
+
const nextRunAt = this.getNextRunTime(newCronExpression);
|
|
278
|
+
|
|
279
|
+
const updateData = {};
|
|
280
|
+
if (name !== undefined) updateData.name = name;
|
|
281
|
+
if (description !== undefined) updateData.description = description;
|
|
282
|
+
if (cronExpression !== undefined) updateData.cronExpression = cronExpression;
|
|
283
|
+
if (prompt !== undefined) updateData.prompt = prompt;
|
|
284
|
+
if (enabled !== undefined) updateData.enabled = enabled;
|
|
285
|
+
updateData.nextRunAt = nextRunAt;
|
|
286
|
+
|
|
287
|
+
await this.dbService.updateScheduledTask(id, updateData);
|
|
288
|
+
|
|
289
|
+
this.stopTask(id);
|
|
290
|
+
|
|
291
|
+
const newEnabled = enabled !== undefined ? enabled : existingTask.enabled;
|
|
292
|
+
if (newEnabled) {
|
|
293
|
+
const updatedTask = await this.dbService.getScheduledTaskById(id);
|
|
294
|
+
this.startTask(updatedTask);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return {
|
|
298
|
+
success: true,
|
|
299
|
+
id,
|
|
300
|
+
name: name || existingTask.name,
|
|
301
|
+
message: `成功更新定时任务 (ID: ${id})`,
|
|
302
|
+
};
|
|
303
|
+
} catch (error) {
|
|
304
|
+
return {
|
|
305
|
+
success: false,
|
|
306
|
+
error: error.message,
|
|
307
|
+
message: `更新定时任务失败: ${error.message}`,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async deleteScheduledTask(args) {
|
|
313
|
+
try {
|
|
314
|
+
const { id } = args;
|
|
315
|
+
|
|
316
|
+
if (!id) {
|
|
317
|
+
return {
|
|
318
|
+
success: false,
|
|
319
|
+
error: "缺少 id 参数",
|
|
320
|
+
message: "删除定时任务失败: 缺少 id 参数",
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const task = await this.dbService.getScheduledTaskById(id);
|
|
325
|
+
if (!task) {
|
|
326
|
+
return {
|
|
327
|
+
success: false,
|
|
328
|
+
error: "未找到指定的定时任务",
|
|
329
|
+
message: `删除定时任务失败: ID ${id} 的定时任务不存在`,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
this.stopTask(id);
|
|
334
|
+
|
|
335
|
+
const result = await this.dbService.deleteScheduledTask(id);
|
|
336
|
+
|
|
337
|
+
if (!result.deleted) {
|
|
338
|
+
return {
|
|
339
|
+
success: false,
|
|
340
|
+
error: "删除失败",
|
|
341
|
+
message: `删除定时任务失败: ID ${id}`,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return {
|
|
346
|
+
success: true,
|
|
347
|
+
id,
|
|
348
|
+
name: task.name,
|
|
349
|
+
message: `成功删除定时任务: ${task.name} (ID: ${id})`,
|
|
350
|
+
};
|
|
351
|
+
} catch (error) {
|
|
352
|
+
return {
|
|
353
|
+
success: false,
|
|
354
|
+
error: error.message,
|
|
355
|
+
message: `删除定时任务失败: ${error.message}`,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
async toggleScheduledTask(args) {
|
|
361
|
+
try {
|
|
362
|
+
const { id, enabled } = args;
|
|
363
|
+
|
|
364
|
+
if (!id || enabled === undefined) {
|
|
365
|
+
return {
|
|
366
|
+
success: false,
|
|
367
|
+
error: "缺少必要参数: id 或 enabled",
|
|
368
|
+
message: "切换定时任务状态失败: 缺少必要参数",
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const task = await this.dbService.getScheduledTaskById(id);
|
|
373
|
+
if (!task) {
|
|
374
|
+
return {
|
|
375
|
+
success: false,
|
|
376
|
+
error: "未找到指定的定时任务",
|
|
377
|
+
message: `切换定时任务状态失败: ID ${id} 的定时任务不存在`,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const nextRunAt = enabled ? this.getNextRunTime(task.cronExpression) : null;
|
|
382
|
+
|
|
383
|
+
await this.dbService.updateScheduledTask(id, { enabled, nextRunAt });
|
|
384
|
+
|
|
385
|
+
if (enabled) {
|
|
386
|
+
this.startTask(task);
|
|
387
|
+
} else {
|
|
388
|
+
this.stopTask(id);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return {
|
|
392
|
+
success: true,
|
|
393
|
+
id,
|
|
394
|
+
name: task.name,
|
|
395
|
+
enabled,
|
|
396
|
+
message: `成功${enabled ? "启用" : "禁用"}定时任务: ${task.name} (ID: ${id})`,
|
|
397
|
+
};
|
|
398
|
+
} catch (error) {
|
|
399
|
+
return {
|
|
400
|
+
success: false,
|
|
401
|
+
error: error.message,
|
|
402
|
+
message: `切换定时任务状态失败: ${error.message}`,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
stopAllTasks() {
|
|
408
|
+
for (const [id, job] of this.scheduledJobs) {
|
|
409
|
+
job.stop();
|
|
410
|
+
}
|
|
411
|
+
this.scheduledJobs.clear();
|
|
412
|
+
logger.info("所有定时任务已停止");
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
getFunctionDefinitions() {
|
|
416
|
+
return [
|
|
417
|
+
{
|
|
418
|
+
type: "function",
|
|
419
|
+
function: {
|
|
420
|
+
name: "create_scheduled_task",
|
|
421
|
+
description:
|
|
422
|
+
"创建一个新的定时任务,定时发起 AI Agent 调用。cron 表达式格式: 秒 分 时 日 月 星期 (例如: '0 9 * * *' 表示每天早上9点执行)",
|
|
423
|
+
parameters: {
|
|
424
|
+
type: "object",
|
|
425
|
+
properties: {
|
|
426
|
+
name: {
|
|
427
|
+
type: "string",
|
|
428
|
+
description: "定时任务名称",
|
|
429
|
+
},
|
|
430
|
+
description: {
|
|
431
|
+
type: "string",
|
|
432
|
+
description: "定时任务描述",
|
|
433
|
+
},
|
|
434
|
+
cronExpression: {
|
|
435
|
+
type: "string",
|
|
436
|
+
description:
|
|
437
|
+
"Cron 表达式,格式: 秒 分 时 日 月 星期。例如: '0 9 * * *' 每天早上9点, '0 */30 * * * *' 每30分钟, '0 9 * * 1-5' 工作日早上9点",
|
|
438
|
+
},
|
|
439
|
+
prompt: {
|
|
440
|
+
type: "string",
|
|
441
|
+
description: "定时任务执行时发送给 AI Agent 的提示词/指令",
|
|
442
|
+
},
|
|
443
|
+
enabled: {
|
|
444
|
+
type: "boolean",
|
|
445
|
+
description: "是否启用该定时任务,默认为 true",
|
|
446
|
+
},
|
|
447
|
+
},
|
|
448
|
+
required: ["name", "cronExpression", "prompt"],
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
type: "function",
|
|
454
|
+
function: {
|
|
455
|
+
name: "get_all_scheduled_tasks",
|
|
456
|
+
description: "查询所有定时任务",
|
|
457
|
+
parameters: {
|
|
458
|
+
type: "object",
|
|
459
|
+
properties: {},
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
type: "function",
|
|
465
|
+
function: {
|
|
466
|
+
name: "get_scheduled_task",
|
|
467
|
+
description: "根据 ID 查询单个定时任务详情",
|
|
468
|
+
parameters: {
|
|
469
|
+
type: "object",
|
|
470
|
+
properties: {
|
|
471
|
+
id: {
|
|
472
|
+
type: "integer",
|
|
473
|
+
description: "定时任务 ID",
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
required: ["id"],
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
type: "function",
|
|
482
|
+
function: {
|
|
483
|
+
name: "update_scheduled_task",
|
|
484
|
+
description: "更新定时任务配置",
|
|
485
|
+
parameters: {
|
|
486
|
+
type: "object",
|
|
487
|
+
properties: {
|
|
488
|
+
id: {
|
|
489
|
+
type: "integer",
|
|
490
|
+
description: "定时任务 ID",
|
|
491
|
+
},
|
|
492
|
+
name: {
|
|
493
|
+
type: "string",
|
|
494
|
+
description: "新的任务名称",
|
|
495
|
+
},
|
|
496
|
+
description: {
|
|
497
|
+
type: "string",
|
|
498
|
+
description: "新的任务描述",
|
|
499
|
+
},
|
|
500
|
+
cronExpression: {
|
|
501
|
+
type: "string",
|
|
502
|
+
description: "新的 Cron 表达式",
|
|
503
|
+
},
|
|
504
|
+
prompt: {
|
|
505
|
+
type: "string",
|
|
506
|
+
description: "新的提示词/指令",
|
|
507
|
+
},
|
|
508
|
+
enabled: {
|
|
509
|
+
type: "boolean",
|
|
510
|
+
description: "是否启用",
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
required: ["id"],
|
|
514
|
+
},
|
|
515
|
+
},
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
type: "function",
|
|
519
|
+
function: {
|
|
520
|
+
name: "delete_scheduled_task",
|
|
521
|
+
description: "删除指定的定时任务",
|
|
522
|
+
parameters: {
|
|
523
|
+
type: "object",
|
|
524
|
+
properties: {
|
|
525
|
+
id: {
|
|
526
|
+
type: "integer",
|
|
527
|
+
description: "要删除的定时任务 ID",
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
required: ["id"],
|
|
531
|
+
},
|
|
532
|
+
},
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
type: "function",
|
|
536
|
+
function: {
|
|
537
|
+
name: "toggle_scheduled_task",
|
|
538
|
+
description: "启用或禁用定时任务",
|
|
539
|
+
parameters: {
|
|
540
|
+
type: "object",
|
|
541
|
+
properties: {
|
|
542
|
+
id: {
|
|
543
|
+
type: "integer",
|
|
544
|
+
description: "定时任务 ID",
|
|
545
|
+
},
|
|
546
|
+
enabled: {
|
|
547
|
+
type: "boolean",
|
|
548
|
+
description: "true 启用,false 禁用",
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
required: ["id", "enabled"],
|
|
552
|
+
},
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
];
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
module.exports = SchedulerTools;
|