@dexto/tools-scheduler 1.6.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/LICENSE +44 -0
- package/dist/error-codes.cjs +44 -0
- package/dist/error-codes.d.cts +21 -0
- package/dist/error-codes.d.ts +21 -0
- package/dist/error-codes.js +20 -0
- package/dist/errors.cjs +163 -0
- package/dist/errors.d.cts +64 -0
- package/dist/errors.d.ts +64 -0
- package/dist/errors.js +138 -0
- package/dist/executor.cjs +161 -0
- package/dist/executor.d.cts +46 -0
- package/dist/executor.d.ts +46 -0
- package/dist/executor.js +137 -0
- package/dist/index.cjs +89 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +56 -0
- package/dist/manager.cjs +461 -0
- package/dist/manager.d.cts +113 -0
- package/dist/manager.d.ts +113 -0
- package/dist/manager.js +430 -0
- package/dist/schemas.cjs +138 -0
- package/dist/schemas.d.cts +263 -0
- package/dist/schemas.d.ts +263 -0
- package/dist/schemas.js +105 -0
- package/dist/storage.cjs +249 -0
- package/dist/storage.d.cts +62 -0
- package/dist/storage.d.ts +62 -0
- package/dist/storage.js +225 -0
- package/dist/tool-provider.cjs +239 -0
- package/dist/tool-provider.d.cts +34 -0
- package/dist/tool-provider.d.ts +34 -0
- package/dist/tool-provider.js +212 -0
- package/dist/tool-types.cjs +16 -0
- package/dist/tool-types.d.cts +9 -0
- package/dist/tool-types.d.ts +9 -0
- package/dist/tool-types.js +0 -0
- package/dist/tools/create-schedule.cjs +75 -0
- package/dist/tools/create-schedule.d.cts +14 -0
- package/dist/tools/create-schedule.d.ts +14 -0
- package/dist/tools/create-schedule.js +51 -0
- package/dist/tools/delete-schedule.cjs +45 -0
- package/dist/tools/delete-schedule.d.cts +14 -0
- package/dist/tools/delete-schedule.d.ts +14 -0
- package/dist/tools/delete-schedule.js +21 -0
- package/dist/tools/get-history.cjs +63 -0
- package/dist/tools/get-history.d.cts +14 -0
- package/dist/tools/get-history.d.ts +14 -0
- package/dist/tools/get-history.js +39 -0
- package/dist/tools/get-schedule.cjs +68 -0
- package/dist/tools/get-schedule.d.cts +14 -0
- package/dist/tools/get-schedule.d.ts +14 -0
- package/dist/tools/get-schedule.js +44 -0
- package/dist/tools/list-schedules.cjs +67 -0
- package/dist/tools/list-schedules.d.cts +14 -0
- package/dist/tools/list-schedules.d.ts +14 -0
- package/dist/tools/list-schedules.js +43 -0
- package/dist/tools/trigger-schedule.cjs +56 -0
- package/dist/tools/trigger-schedule.d.cts +14 -0
- package/dist/tools/trigger-schedule.d.ts +14 -0
- package/dist/tools/trigger-schedule.js +32 -0
- package/dist/tools/update-schedule.cjs +53 -0
- package/dist/tools/update-schedule.d.cts +14 -0
- package/dist/tools/update-schedule.d.ts +14 -0
- package/dist/tools/update-schedule.js +29 -0
- package/dist/types.cjs +16 -0
- package/dist/types.d.cts +72 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.js +0 -0
- package/package.json +41 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CreateScheduleInputSchema } from "../schemas.js";
|
|
2
|
+
function createCreateScheduleTool(getManager) {
|
|
3
|
+
return {
|
|
4
|
+
id: "create_schedule",
|
|
5
|
+
description: `Create a scheduled task that executes automatically at specified times.
|
|
6
|
+
|
|
7
|
+
Session Modes (sessionMode parameter):
|
|
8
|
+
\u2022 "ephemeral" (default) - Fresh isolated session each run. Use for: daily reports, monitoring, standalone tasks
|
|
9
|
+
\u2022 "dedicated" - Persistent session for this schedule. Use for: tracking progress over time, building context across runs
|
|
10
|
+
\u2022 "inherit" - Continue in THIS conversation. Use for: "remind me in 1 hour", "check back on this later"
|
|
11
|
+
\u2022 "fixed" - Use specific sessionId. Use for: posting to a known thread, cross-session orchestration
|
|
12
|
+
|
|
13
|
+
Agent Targeting (targetAgentId parameter):
|
|
14
|
+
\u2022 Specifies which agent should execute the scheduled task
|
|
15
|
+
\u2022 Examples: "notes" for notes agent, "filesystem" for file operations, "coding" for code tasks
|
|
16
|
+
\u2022 If not specified, executes in the orchestrator's context
|
|
17
|
+
\u2022 Use this to delegate specialized tasks to the appropriate app agent
|
|
18
|
+
|
|
19
|
+
Examples:
|
|
20
|
+
- Daily standup reminder: sessionMode="ephemeral", cronExpression="0 9 * * 1-5"
|
|
21
|
+
- Track project daily: sessionMode="dedicated", cronExpression="0 18 * * *"
|
|
22
|
+
- Remind me in 2 hours: sessionMode="inherit", cronExpression="0 14 * * *" (one-time)
|
|
23
|
+
- Notes backup at midnight: targetAgentId="notes", cronExpression="0 0 * * *"
|
|
24
|
+
- Daily code review: targetAgentId="coding", cronExpression="0 17 * * 1-5"`,
|
|
25
|
+
inputSchema: CreateScheduleInputSchema,
|
|
26
|
+
execute: async (input, context) => {
|
|
27
|
+
const typedInput = input;
|
|
28
|
+
const manager = await getManager(context);
|
|
29
|
+
const schedule = await manager.createSchedule(typedInput, context.sessionId);
|
|
30
|
+
const sessionInfo = schedule.sessionMode === "inherit" ? `Session: Inheriting current conversation (${schedule.sessionId})` : schedule.sessionMode === "fixed" ? `Session: Fixed to ${schedule.sessionId}` : schedule.sessionMode === "dedicated" ? `Session: Dedicated thread for this schedule` : `Session: New isolated session each run`;
|
|
31
|
+
const targetAgent = schedule.task.metadata?.__os_targetAgentId;
|
|
32
|
+
const targetInfo = targetAgent ? `Target Agent: ${targetAgent}` : `Target Agent: orchestrator (default)`;
|
|
33
|
+
const message = `Schedule created successfully
|
|
34
|
+
|
|
35
|
+
ID: ${schedule.id}
|
|
36
|
+
Name: ${schedule.name}
|
|
37
|
+
Cron: ${schedule.cronExpression}
|
|
38
|
+
Timezone: ${schedule.timezone}
|
|
39
|
+
Mode: ${schedule.sessionMode}
|
|
40
|
+
${sessionInfo}
|
|
41
|
+
${targetInfo}
|
|
42
|
+
Next run: ${schedule.nextRunAt ? new Date(schedule.nextRunAt).toISOString() : "calculating..."}
|
|
43
|
+
|
|
44
|
+
The schedule is now active and will execute automatically.`;
|
|
45
|
+
return { message, schedule };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
createCreateScheduleTool
|
|
51
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var delete_schedule_exports = {};
|
|
20
|
+
__export(delete_schedule_exports, {
|
|
21
|
+
createDeleteScheduleTool: () => createDeleteScheduleTool
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(delete_schedule_exports);
|
|
24
|
+
var import_schemas = require("../schemas.js");
|
|
25
|
+
function createDeleteScheduleTool(getManager) {
|
|
26
|
+
return {
|
|
27
|
+
id: "delete_schedule",
|
|
28
|
+
description: "Delete a schedule permanently. This will stop all future executions of the schedule.",
|
|
29
|
+
inputSchema: import_schemas.DeleteScheduleInputSchema,
|
|
30
|
+
execute: async (input, context) => {
|
|
31
|
+
const { scheduleId } = input;
|
|
32
|
+
const manager = await getManager(context);
|
|
33
|
+
await manager.deleteSchedule(scheduleId);
|
|
34
|
+
return {
|
|
35
|
+
message: `Schedule deleted successfully: ${scheduleId}`,
|
|
36
|
+
deleted: true,
|
|
37
|
+
scheduleId
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
createDeleteScheduleTool
|
|
45
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tool } from '@dexto/core';
|
|
2
|
+
import { SchedulerManagerGetter } from '../tool-types.cjs';
|
|
3
|
+
import '../manager.cjs';
|
|
4
|
+
import '../schemas.cjs';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../types.cjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool for deleting schedules
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function createDeleteScheduleTool(getManager: SchedulerManagerGetter): Tool;
|
|
13
|
+
|
|
14
|
+
export { createDeleteScheduleTool };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tool } from '@dexto/core';
|
|
2
|
+
import { SchedulerManagerGetter } from '../tool-types.js';
|
|
3
|
+
import '../manager.js';
|
|
4
|
+
import '../schemas.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool for deleting schedules
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function createDeleteScheduleTool(getManager: SchedulerManagerGetter): Tool;
|
|
13
|
+
|
|
14
|
+
export { createDeleteScheduleTool };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DeleteScheduleInputSchema } from "../schemas.js";
|
|
2
|
+
function createDeleteScheduleTool(getManager) {
|
|
3
|
+
return {
|
|
4
|
+
id: "delete_schedule",
|
|
5
|
+
description: "Delete a schedule permanently. This will stop all future executions of the schedule.",
|
|
6
|
+
inputSchema: DeleteScheduleInputSchema,
|
|
7
|
+
execute: async (input, context) => {
|
|
8
|
+
const { scheduleId } = input;
|
|
9
|
+
const manager = await getManager(context);
|
|
10
|
+
await manager.deleteSchedule(scheduleId);
|
|
11
|
+
return {
|
|
12
|
+
message: `Schedule deleted successfully: ${scheduleId}`,
|
|
13
|
+
deleted: true,
|
|
14
|
+
scheduleId
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
createDeleteScheduleTool
|
|
21
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var get_history_exports = {};
|
|
20
|
+
__export(get_history_exports, {
|
|
21
|
+
createGetScheduleHistoryTool: () => createGetScheduleHistoryTool
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(get_history_exports);
|
|
24
|
+
var import_schemas = require("../schemas.js");
|
|
25
|
+
function createGetScheduleHistoryTool(getManager) {
|
|
26
|
+
return {
|
|
27
|
+
id: "get_schedule_history",
|
|
28
|
+
description: "Get the execution history for a schedule, showing past runs and their results.",
|
|
29
|
+
inputSchema: import_schemas.GetScheduleHistoryInputSchema,
|
|
30
|
+
execute: async (input, context) => {
|
|
31
|
+
const { scheduleId, limit = 10 } = input;
|
|
32
|
+
const manager = await getManager(context);
|
|
33
|
+
const logs = await manager.getExecutionHistory(scheduleId, limit);
|
|
34
|
+
if (logs.length === 0) {
|
|
35
|
+
return {
|
|
36
|
+
message: `No execution history found for schedule: ${scheduleId}`,
|
|
37
|
+
history: []
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const historyList = logs.map((log) => {
|
|
41
|
+
const statusIcon = log.status === "success" ? "[SUCCESS]" : log.status === "failed" ? "[FAILED]" : log.status === "timeout" ? "[TIMEOUT]" : "[PENDING]";
|
|
42
|
+
return `
|
|
43
|
+
${statusIcon} Execution ID: ${log.id}
|
|
44
|
+
Status: ${log.status}
|
|
45
|
+
Triggered: ${new Date(log.triggeredAt).toISOString()}
|
|
46
|
+
${log.completedAt ? `Completed: ${new Date(log.completedAt).toISOString()}` : ""}
|
|
47
|
+
${log.duration ? `Duration: ${log.duration}ms` : ""}
|
|
48
|
+
${log.error ? `Error: ${log.error}` : ""}
|
|
49
|
+
${log.result ? `Result: ${log.result.substring(0, 200)}${log.result.length > 200 ? "..." : ""}` : ""}
|
|
50
|
+
---`;
|
|
51
|
+
}).join("\n");
|
|
52
|
+
return {
|
|
53
|
+
message: `Execution history for schedule ${scheduleId} (showing ${logs.length} most recent):
|
|
54
|
+
${historyList}`,
|
|
55
|
+
history: logs
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
createGetScheduleHistoryTool
|
|
63
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tool } from '@dexto/core';
|
|
2
|
+
import { SchedulerManagerGetter } from '../tool-types.cjs';
|
|
3
|
+
import '../manager.cjs';
|
|
4
|
+
import '../schemas.cjs';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../types.cjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool for getting schedule execution history
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function createGetScheduleHistoryTool(getManager: SchedulerManagerGetter): Tool;
|
|
13
|
+
|
|
14
|
+
export { createGetScheduleHistoryTool };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tool } from '@dexto/core';
|
|
2
|
+
import { SchedulerManagerGetter } from '../tool-types.js';
|
|
3
|
+
import '../manager.js';
|
|
4
|
+
import '../schemas.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool for getting schedule execution history
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function createGetScheduleHistoryTool(getManager: SchedulerManagerGetter): Tool;
|
|
13
|
+
|
|
14
|
+
export { createGetScheduleHistoryTool };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { GetScheduleHistoryInputSchema } from "../schemas.js";
|
|
2
|
+
function createGetScheduleHistoryTool(getManager) {
|
|
3
|
+
return {
|
|
4
|
+
id: "get_schedule_history",
|
|
5
|
+
description: "Get the execution history for a schedule, showing past runs and their results.",
|
|
6
|
+
inputSchema: GetScheduleHistoryInputSchema,
|
|
7
|
+
execute: async (input, context) => {
|
|
8
|
+
const { scheduleId, limit = 10 } = input;
|
|
9
|
+
const manager = await getManager(context);
|
|
10
|
+
const logs = await manager.getExecutionHistory(scheduleId, limit);
|
|
11
|
+
if (logs.length === 0) {
|
|
12
|
+
return {
|
|
13
|
+
message: `No execution history found for schedule: ${scheduleId}`,
|
|
14
|
+
history: []
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const historyList = logs.map((log) => {
|
|
18
|
+
const statusIcon = log.status === "success" ? "[SUCCESS]" : log.status === "failed" ? "[FAILED]" : log.status === "timeout" ? "[TIMEOUT]" : "[PENDING]";
|
|
19
|
+
return `
|
|
20
|
+
${statusIcon} Execution ID: ${log.id}
|
|
21
|
+
Status: ${log.status}
|
|
22
|
+
Triggered: ${new Date(log.triggeredAt).toISOString()}
|
|
23
|
+
${log.completedAt ? `Completed: ${new Date(log.completedAt).toISOString()}` : ""}
|
|
24
|
+
${log.duration ? `Duration: ${log.duration}ms` : ""}
|
|
25
|
+
${log.error ? `Error: ${log.error}` : ""}
|
|
26
|
+
${log.result ? `Result: ${log.result.substring(0, 200)}${log.result.length > 200 ? "..." : ""}` : ""}
|
|
27
|
+
---`;
|
|
28
|
+
}).join("\n");
|
|
29
|
+
return {
|
|
30
|
+
message: `Execution history for schedule ${scheduleId} (showing ${logs.length} most recent):
|
|
31
|
+
${historyList}`,
|
|
32
|
+
history: logs
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
createGetScheduleHistoryTool
|
|
39
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var get_schedule_exports = {};
|
|
20
|
+
__export(get_schedule_exports, {
|
|
21
|
+
createGetScheduleTool: () => createGetScheduleTool
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(get_schedule_exports);
|
|
24
|
+
var import_schemas = require("../schemas.js");
|
|
25
|
+
function createGetScheduleTool(getManager) {
|
|
26
|
+
return {
|
|
27
|
+
id: "get_schedule",
|
|
28
|
+
description: "Get detailed information about a specific schedule by ID.",
|
|
29
|
+
inputSchema: import_schemas.GetScheduleInputSchema,
|
|
30
|
+
execute: async (input, context) => {
|
|
31
|
+
const { scheduleId } = input;
|
|
32
|
+
const manager = await getManager(context);
|
|
33
|
+
const schedule = await manager.getSchedule(scheduleId);
|
|
34
|
+
if (!schedule) {
|
|
35
|
+
throw new Error(`Schedule not found: ${scheduleId}`);
|
|
36
|
+
}
|
|
37
|
+
const message = `
|
|
38
|
+
Schedule Details:
|
|
39
|
+
|
|
40
|
+
ID: ${schedule.id}
|
|
41
|
+
Name: ${schedule.name}
|
|
42
|
+
Status: ${schedule.enabled ? "Enabled" : "Disabled"}
|
|
43
|
+
Cron Expression: ${schedule.cronExpression}
|
|
44
|
+
Timezone: ${schedule.timezone}
|
|
45
|
+
|
|
46
|
+
Task:
|
|
47
|
+
Instruction: ${schedule.task.instruction}
|
|
48
|
+
Metadata: ${JSON.stringify(schedule.task.metadata || {}, null, 2)}
|
|
49
|
+
|
|
50
|
+
Statistics:
|
|
51
|
+
Total runs: ${schedule.runCount}
|
|
52
|
+
Successful: ${schedule.successCount}
|
|
53
|
+
Failed: ${schedule.failureCount}
|
|
54
|
+
Last run: ${schedule.lastRunAt ? new Date(schedule.lastRunAt).toISOString() : "Never"}
|
|
55
|
+
Next run: ${schedule.nextRunAt ? new Date(schedule.nextRunAt).toISOString() : "N/A"}
|
|
56
|
+
${schedule.lastError ? `Last error: ${schedule.lastError}` : ""}
|
|
57
|
+
|
|
58
|
+
Created: ${new Date(schedule.createdAt).toISOString()}
|
|
59
|
+
Updated: ${new Date(schedule.updatedAt).toISOString()}
|
|
60
|
+
`;
|
|
61
|
+
return { message, schedule };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
67
|
+
createGetScheduleTool
|
|
68
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tool } from '@dexto/core';
|
|
2
|
+
import { SchedulerManagerGetter } from '../tool-types.cjs';
|
|
3
|
+
import '../manager.cjs';
|
|
4
|
+
import '../schemas.cjs';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../types.cjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool for getting schedule details
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function createGetScheduleTool(getManager: SchedulerManagerGetter): Tool;
|
|
13
|
+
|
|
14
|
+
export { createGetScheduleTool };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tool } from '@dexto/core';
|
|
2
|
+
import { SchedulerManagerGetter } from '../tool-types.js';
|
|
3
|
+
import '../manager.js';
|
|
4
|
+
import '../schemas.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool for getting schedule details
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function createGetScheduleTool(getManager: SchedulerManagerGetter): Tool;
|
|
13
|
+
|
|
14
|
+
export { createGetScheduleTool };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { GetScheduleInputSchema } from "../schemas.js";
|
|
2
|
+
function createGetScheduleTool(getManager) {
|
|
3
|
+
return {
|
|
4
|
+
id: "get_schedule",
|
|
5
|
+
description: "Get detailed information about a specific schedule by ID.",
|
|
6
|
+
inputSchema: GetScheduleInputSchema,
|
|
7
|
+
execute: async (input, context) => {
|
|
8
|
+
const { scheduleId } = input;
|
|
9
|
+
const manager = await getManager(context);
|
|
10
|
+
const schedule = await manager.getSchedule(scheduleId);
|
|
11
|
+
if (!schedule) {
|
|
12
|
+
throw new Error(`Schedule not found: ${scheduleId}`);
|
|
13
|
+
}
|
|
14
|
+
const message = `
|
|
15
|
+
Schedule Details:
|
|
16
|
+
|
|
17
|
+
ID: ${schedule.id}
|
|
18
|
+
Name: ${schedule.name}
|
|
19
|
+
Status: ${schedule.enabled ? "Enabled" : "Disabled"}
|
|
20
|
+
Cron Expression: ${schedule.cronExpression}
|
|
21
|
+
Timezone: ${schedule.timezone}
|
|
22
|
+
|
|
23
|
+
Task:
|
|
24
|
+
Instruction: ${schedule.task.instruction}
|
|
25
|
+
Metadata: ${JSON.stringify(schedule.task.metadata || {}, null, 2)}
|
|
26
|
+
|
|
27
|
+
Statistics:
|
|
28
|
+
Total runs: ${schedule.runCount}
|
|
29
|
+
Successful: ${schedule.successCount}
|
|
30
|
+
Failed: ${schedule.failureCount}
|
|
31
|
+
Last run: ${schedule.lastRunAt ? new Date(schedule.lastRunAt).toISOString() : "Never"}
|
|
32
|
+
Next run: ${schedule.nextRunAt ? new Date(schedule.nextRunAt).toISOString() : "N/A"}
|
|
33
|
+
${schedule.lastError ? `Last error: ${schedule.lastError}` : ""}
|
|
34
|
+
|
|
35
|
+
Created: ${new Date(schedule.createdAt).toISOString()}
|
|
36
|
+
Updated: ${new Date(schedule.updatedAt).toISOString()}
|
|
37
|
+
`;
|
|
38
|
+
return { message, schedule };
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
createGetScheduleTool
|
|
44
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var list_schedules_exports = {};
|
|
20
|
+
__export(list_schedules_exports, {
|
|
21
|
+
createListSchedulesTool: () => createListSchedulesTool
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(list_schedules_exports);
|
|
24
|
+
var import_schemas = require("../schemas.js");
|
|
25
|
+
function createListSchedulesTool(getManager) {
|
|
26
|
+
return {
|
|
27
|
+
id: "list_schedules",
|
|
28
|
+
description: "List all scheduled tasks. Optionally filter by enabled status.",
|
|
29
|
+
inputSchema: import_schemas.ListSchedulesInputSchema,
|
|
30
|
+
execute: async (input, context) => {
|
|
31
|
+
const manager = await getManager(context);
|
|
32
|
+
const { enabled } = input;
|
|
33
|
+
const schedules = await manager.listSchedules(enabled !== void 0 ? { enabled } : {});
|
|
34
|
+
if (schedules.length === 0) {
|
|
35
|
+
return {
|
|
36
|
+
message: "No schedules found.",
|
|
37
|
+
schedules: []
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const scheduleList = schedules.map((s) => {
|
|
41
|
+
const status = s.enabled ? "Enabled" : "Disabled";
|
|
42
|
+
const nextRun = s.nextRunAt ? new Date(s.nextRunAt).toISOString() : "N/A";
|
|
43
|
+
const lastRun = s.lastRunAt ? new Date(s.lastRunAt).toISOString() : "Never";
|
|
44
|
+
return `
|
|
45
|
+
ID: ${s.id}
|
|
46
|
+
Name: ${s.name}
|
|
47
|
+
Status: ${status}
|
|
48
|
+
Cron: ${s.cronExpression}
|
|
49
|
+
Timezone: ${s.timezone}
|
|
50
|
+
Runs: ${s.runCount} (${s.successCount} success, ${s.failureCount} failed)
|
|
51
|
+
Last run: ${lastRun}
|
|
52
|
+
Next run: ${nextRun}
|
|
53
|
+
${s.lastError ? `Last error: ${s.lastError}` : ""}
|
|
54
|
+
---`;
|
|
55
|
+
}).join("\n");
|
|
56
|
+
return {
|
|
57
|
+
message: `Found ${schedules.length} schedule(s):
|
|
58
|
+
${scheduleList}`,
|
|
59
|
+
schedules
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
createListSchedulesTool
|
|
67
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tool } from '@dexto/core';
|
|
2
|
+
import { SchedulerManagerGetter } from '../tool-types.cjs';
|
|
3
|
+
import '../manager.cjs';
|
|
4
|
+
import '../schemas.cjs';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../types.cjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool for listing schedules
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function createListSchedulesTool(getManager: SchedulerManagerGetter): Tool;
|
|
13
|
+
|
|
14
|
+
export { createListSchedulesTool };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tool } from '@dexto/core';
|
|
2
|
+
import { SchedulerManagerGetter } from '../tool-types.js';
|
|
3
|
+
import '../manager.js';
|
|
4
|
+
import '../schemas.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool for listing schedules
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function createListSchedulesTool(getManager: SchedulerManagerGetter): Tool;
|
|
13
|
+
|
|
14
|
+
export { createListSchedulesTool };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ListSchedulesInputSchema } from "../schemas.js";
|
|
2
|
+
function createListSchedulesTool(getManager) {
|
|
3
|
+
return {
|
|
4
|
+
id: "list_schedules",
|
|
5
|
+
description: "List all scheduled tasks. Optionally filter by enabled status.",
|
|
6
|
+
inputSchema: ListSchedulesInputSchema,
|
|
7
|
+
execute: async (input, context) => {
|
|
8
|
+
const manager = await getManager(context);
|
|
9
|
+
const { enabled } = input;
|
|
10
|
+
const schedules = await manager.listSchedules(enabled !== void 0 ? { enabled } : {});
|
|
11
|
+
if (schedules.length === 0) {
|
|
12
|
+
return {
|
|
13
|
+
message: "No schedules found.",
|
|
14
|
+
schedules: []
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const scheduleList = schedules.map((s) => {
|
|
18
|
+
const status = s.enabled ? "Enabled" : "Disabled";
|
|
19
|
+
const nextRun = s.nextRunAt ? new Date(s.nextRunAt).toISOString() : "N/A";
|
|
20
|
+
const lastRun = s.lastRunAt ? new Date(s.lastRunAt).toISOString() : "Never";
|
|
21
|
+
return `
|
|
22
|
+
ID: ${s.id}
|
|
23
|
+
Name: ${s.name}
|
|
24
|
+
Status: ${status}
|
|
25
|
+
Cron: ${s.cronExpression}
|
|
26
|
+
Timezone: ${s.timezone}
|
|
27
|
+
Runs: ${s.runCount} (${s.successCount} success, ${s.failureCount} failed)
|
|
28
|
+
Last run: ${lastRun}
|
|
29
|
+
Next run: ${nextRun}
|
|
30
|
+
${s.lastError ? `Last error: ${s.lastError}` : ""}
|
|
31
|
+
---`;
|
|
32
|
+
}).join("\n");
|
|
33
|
+
return {
|
|
34
|
+
message: `Found ${schedules.length} schedule(s):
|
|
35
|
+
${scheduleList}`,
|
|
36
|
+
schedules
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
createListSchedulesTool
|
|
43
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var trigger_schedule_exports = {};
|
|
20
|
+
__export(trigger_schedule_exports, {
|
|
21
|
+
createTriggerScheduleTool: () => createTriggerScheduleTool
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(trigger_schedule_exports);
|
|
24
|
+
var import_schemas = require("../schemas.js");
|
|
25
|
+
function createTriggerScheduleTool(getManager) {
|
|
26
|
+
return {
|
|
27
|
+
id: "trigger_schedule_now",
|
|
28
|
+
description: "Manually trigger a schedule to execute immediately, outside of its normal schedule.",
|
|
29
|
+
inputSchema: import_schemas.TriggerScheduleInputSchema,
|
|
30
|
+
execute: async (input, context) => {
|
|
31
|
+
const { scheduleId } = input;
|
|
32
|
+
const manager = await getManager(context);
|
|
33
|
+
const log = await manager.triggerScheduleNow(scheduleId);
|
|
34
|
+
const durationLine = log.duration != null ? `Duration: ${log.duration}ms` : "Duration: (unknown)";
|
|
35
|
+
const errorLine = log.error ?? "Unknown error";
|
|
36
|
+
const message = log.status === "success" ? `Schedule executed successfully
|
|
37
|
+
|
|
38
|
+
Execution ID: ${log.id}
|
|
39
|
+
Status: ${log.status}
|
|
40
|
+
${durationLine}
|
|
41
|
+
|
|
42
|
+
Result:
|
|
43
|
+
${log.result || "(no result)"}` : `Schedule execution failed
|
|
44
|
+
|
|
45
|
+
Execution ID: ${log.id}
|
|
46
|
+
Status: ${log.status}
|
|
47
|
+
${durationLine}
|
|
48
|
+
Error: ${errorLine}`;
|
|
49
|
+
return { message, execution: log };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
createTriggerScheduleTool
|
|
56
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tool } from '@dexto/core';
|
|
2
|
+
import { SchedulerManagerGetter } from '../tool-types.cjs';
|
|
3
|
+
import '../manager.cjs';
|
|
4
|
+
import '../schemas.cjs';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../types.cjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool for manually triggering schedules
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function createTriggerScheduleTool(getManager: SchedulerManagerGetter): Tool;
|
|
13
|
+
|
|
14
|
+
export { createTriggerScheduleTool };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tool } from '@dexto/core';
|
|
2
|
+
import { SchedulerManagerGetter } from '../tool-types.js';
|
|
3
|
+
import '../manager.js';
|
|
4
|
+
import '../schemas.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool for manually triggering schedules
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function createTriggerScheduleTool(getManager: SchedulerManagerGetter): Tool;
|
|
13
|
+
|
|
14
|
+
export { createTriggerScheduleTool };
|