@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.
Files changed (70) hide show
  1. package/LICENSE +44 -0
  2. package/dist/error-codes.cjs +44 -0
  3. package/dist/error-codes.d.cts +21 -0
  4. package/dist/error-codes.d.ts +21 -0
  5. package/dist/error-codes.js +20 -0
  6. package/dist/errors.cjs +163 -0
  7. package/dist/errors.d.cts +64 -0
  8. package/dist/errors.d.ts +64 -0
  9. package/dist/errors.js +138 -0
  10. package/dist/executor.cjs +161 -0
  11. package/dist/executor.d.cts +46 -0
  12. package/dist/executor.d.ts +46 -0
  13. package/dist/executor.js +137 -0
  14. package/dist/index.cjs +89 -0
  15. package/dist/index.d.cts +19 -0
  16. package/dist/index.d.ts +19 -0
  17. package/dist/index.js +56 -0
  18. package/dist/manager.cjs +461 -0
  19. package/dist/manager.d.cts +113 -0
  20. package/dist/manager.d.ts +113 -0
  21. package/dist/manager.js +430 -0
  22. package/dist/schemas.cjs +138 -0
  23. package/dist/schemas.d.cts +263 -0
  24. package/dist/schemas.d.ts +263 -0
  25. package/dist/schemas.js +105 -0
  26. package/dist/storage.cjs +249 -0
  27. package/dist/storage.d.cts +62 -0
  28. package/dist/storage.d.ts +62 -0
  29. package/dist/storage.js +225 -0
  30. package/dist/tool-provider.cjs +239 -0
  31. package/dist/tool-provider.d.cts +34 -0
  32. package/dist/tool-provider.d.ts +34 -0
  33. package/dist/tool-provider.js +212 -0
  34. package/dist/tool-types.cjs +16 -0
  35. package/dist/tool-types.d.cts +9 -0
  36. package/dist/tool-types.d.ts +9 -0
  37. package/dist/tool-types.js +0 -0
  38. package/dist/tools/create-schedule.cjs +75 -0
  39. package/dist/tools/create-schedule.d.cts +14 -0
  40. package/dist/tools/create-schedule.d.ts +14 -0
  41. package/dist/tools/create-schedule.js +51 -0
  42. package/dist/tools/delete-schedule.cjs +45 -0
  43. package/dist/tools/delete-schedule.d.cts +14 -0
  44. package/dist/tools/delete-schedule.d.ts +14 -0
  45. package/dist/tools/delete-schedule.js +21 -0
  46. package/dist/tools/get-history.cjs +63 -0
  47. package/dist/tools/get-history.d.cts +14 -0
  48. package/dist/tools/get-history.d.ts +14 -0
  49. package/dist/tools/get-history.js +39 -0
  50. package/dist/tools/get-schedule.cjs +68 -0
  51. package/dist/tools/get-schedule.d.cts +14 -0
  52. package/dist/tools/get-schedule.d.ts +14 -0
  53. package/dist/tools/get-schedule.js +44 -0
  54. package/dist/tools/list-schedules.cjs +67 -0
  55. package/dist/tools/list-schedules.d.cts +14 -0
  56. package/dist/tools/list-schedules.d.ts +14 -0
  57. package/dist/tools/list-schedules.js +43 -0
  58. package/dist/tools/trigger-schedule.cjs +56 -0
  59. package/dist/tools/trigger-schedule.d.cts +14 -0
  60. package/dist/tools/trigger-schedule.d.ts +14 -0
  61. package/dist/tools/trigger-schedule.js +32 -0
  62. package/dist/tools/update-schedule.cjs +53 -0
  63. package/dist/tools/update-schedule.d.cts +14 -0
  64. package/dist/tools/update-schedule.d.ts +14 -0
  65. package/dist/tools/update-schedule.js +29 -0
  66. package/dist/types.cjs +16 -0
  67. package/dist/types.d.cts +72 -0
  68. package/dist/types.d.ts +72 -0
  69. package/dist/types.js +0 -0
  70. package/package.json +41 -0
@@ -0,0 +1,32 @@
1
+ import { TriggerScheduleInputSchema } from "../schemas.js";
2
+ function createTriggerScheduleTool(getManager) {
3
+ return {
4
+ id: "trigger_schedule_now",
5
+ description: "Manually trigger a schedule to execute immediately, outside of its normal schedule.",
6
+ inputSchema: TriggerScheduleInputSchema,
7
+ execute: async (input, context) => {
8
+ const { scheduleId } = input;
9
+ const manager = await getManager(context);
10
+ const log = await manager.triggerScheduleNow(scheduleId);
11
+ const durationLine = log.duration != null ? `Duration: ${log.duration}ms` : "Duration: (unknown)";
12
+ const errorLine = log.error ?? "Unknown error";
13
+ const message = log.status === "success" ? `Schedule executed successfully
14
+
15
+ Execution ID: ${log.id}
16
+ Status: ${log.status}
17
+ ${durationLine}
18
+
19
+ Result:
20
+ ${log.result || "(no result)"}` : `Schedule execution failed
21
+
22
+ Execution ID: ${log.id}
23
+ Status: ${log.status}
24
+ ${durationLine}
25
+ Error: ${errorLine}`;
26
+ return { message, execution: log };
27
+ }
28
+ };
29
+ }
30
+ export {
31
+ createTriggerScheduleTool
32
+ };
@@ -0,0 +1,53 @@
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 update_schedule_exports = {};
20
+ __export(update_schedule_exports, {
21
+ createUpdateScheduleTool: () => createUpdateScheduleTool
22
+ });
23
+ module.exports = __toCommonJS(update_schedule_exports);
24
+ var import_schemas = require("../schemas.js");
25
+ function createUpdateScheduleTool(getManager) {
26
+ return {
27
+ id: "update_schedule",
28
+ description: `Update an existing scheduled task. Can modify timing, instruction, or session mode.
29
+
30
+ When changing sessionMode to "inherit", the current conversation will be captured as the target session.`,
31
+ inputSchema: import_schemas.UpdateScheduleInputSchema,
32
+ execute: async (input, context) => {
33
+ const { scheduleId, ...updates } = input;
34
+ const manager = await getManager(context);
35
+ const schedule = await manager.updateSchedule(scheduleId, updates, context.sessionId);
36
+ const sessionInfo = schedule.sessionMode === "inherit" ? `Session: Inheriting conversation (${schedule.sessionId})` : schedule.sessionMode === "fixed" ? `Session: Fixed to ${schedule.sessionId}` : schedule.sessionMode === "dedicated" ? `Session: Dedicated thread` : `Session: Ephemeral (new each run)`;
37
+ const message = `Schedule updated successfully
38
+
39
+ ID: ${schedule.id}
40
+ Name: ${schedule.name}
41
+ Cron: ${schedule.cronExpression}
42
+ Mode: ${schedule.sessionMode}
43
+ ${sessionInfo}
44
+ Status: ${schedule.enabled ? "Enabled" : "Disabled"}
45
+ Next run: ${schedule.nextRunAt ? new Date(schedule.nextRunAt).toISOString() : "N/A"}`;
46
+ return { message, schedule };
47
+ }
48
+ };
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ createUpdateScheduleTool
53
+ });
@@ -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 updating schedules
10
+ */
11
+
12
+ declare function createUpdateScheduleTool(getManager: SchedulerManagerGetter): Tool;
13
+
14
+ export { createUpdateScheduleTool };
@@ -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 updating schedules
10
+ */
11
+
12
+ declare function createUpdateScheduleTool(getManager: SchedulerManagerGetter): Tool;
13
+
14
+ export { createUpdateScheduleTool };
@@ -0,0 +1,29 @@
1
+ import { UpdateScheduleInputSchema } from "../schemas.js";
2
+ function createUpdateScheduleTool(getManager) {
3
+ return {
4
+ id: "update_schedule",
5
+ description: `Update an existing scheduled task. Can modify timing, instruction, or session mode.
6
+
7
+ When changing sessionMode to "inherit", the current conversation will be captured as the target session.`,
8
+ inputSchema: UpdateScheduleInputSchema,
9
+ execute: async (input, context) => {
10
+ const { scheduleId, ...updates } = input;
11
+ const manager = await getManager(context);
12
+ const schedule = await manager.updateSchedule(scheduleId, updates, context.sessionId);
13
+ const sessionInfo = schedule.sessionMode === "inherit" ? `Session: Inheriting conversation (${schedule.sessionId})` : schedule.sessionMode === "fixed" ? `Session: Fixed to ${schedule.sessionId}` : schedule.sessionMode === "dedicated" ? `Session: Dedicated thread` : `Session: Ephemeral (new each run)`;
14
+ const message = `Schedule updated successfully
15
+
16
+ ID: ${schedule.id}
17
+ Name: ${schedule.name}
18
+ Cron: ${schedule.cronExpression}
19
+ Mode: ${schedule.sessionMode}
20
+ ${sessionInfo}
21
+ Status: ${schedule.enabled ? "Enabled" : "Disabled"}
22
+ Next run: ${schedule.nextRunAt ? new Date(schedule.nextRunAt).toISOString() : "N/A"}`;
23
+ return { message, schedule };
24
+ }
25
+ };
26
+ }
27
+ export {
28
+ createUpdateScheduleTool
29
+ };
package/dist/types.cjs ADDED
@@ -0,0 +1,16 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,72 @@
1
+ import { ScheduleSessionMode } from './schemas.cjs';
2
+ import 'zod';
3
+
4
+ /**
5
+ * Core types for scheduler tool provider
6
+ */
7
+
8
+ /**
9
+ * Schedule definition for automated task execution
10
+ */
11
+ interface Schedule {
12
+ id: string;
13
+ /** Human-readable name for the schedule (e.g., "Coffee Reminder") */
14
+ name: string;
15
+ cronExpression: string;
16
+ timezone: string;
17
+ enabled: boolean;
18
+ task: {
19
+ /** Instruction for the executing agent */
20
+ instruction: string;
21
+ metadata?: Record<string, unknown>;
22
+ };
23
+ /**
24
+ * How session context is managed for executions.
25
+ * @default 'ephemeral'
26
+ */
27
+ sessionMode: ScheduleSessionMode;
28
+ /**
29
+ * Session ID for 'fixed' mode, or captured session for 'inherit' mode.
30
+ * Not used for 'ephemeral' or 'dedicated' modes.
31
+ */
32
+ sessionId?: string;
33
+ /** Optional workspace path for executions */
34
+ workspacePath?: string;
35
+ createdAt: number;
36
+ updatedAt: number;
37
+ lastRunAt?: number;
38
+ nextRunAt?: number;
39
+ runCount: number;
40
+ successCount: number;
41
+ failureCount: number;
42
+ lastError?: string;
43
+ }
44
+ /**
45
+ * Execution log entry for schedule runs
46
+ */
47
+ interface ExecutionLog {
48
+ id: string;
49
+ scheduleId: string;
50
+ triggeredAt: number;
51
+ completedAt?: number;
52
+ status: 'pending' | 'success' | 'failed' | 'timeout';
53
+ duration?: number;
54
+ error?: string;
55
+ result?: string;
56
+ }
57
+ /**
58
+ * Schedule filters for listing
59
+ */
60
+ interface ScheduleFilters {
61
+ enabled?: boolean;
62
+ }
63
+ /**
64
+ * Executor function type - called to execute scheduled tasks
65
+ */
66
+ type ScheduleExecutorFn = (params: {
67
+ prompt: string;
68
+ sessionId: string;
69
+ schedule: Schedule;
70
+ }) => Promise<string>;
71
+
72
+ export type { ExecutionLog, Schedule, ScheduleExecutorFn, ScheduleFilters };
@@ -0,0 +1,72 @@
1
+ import { ScheduleSessionMode } from './schemas.js';
2
+ import 'zod';
3
+
4
+ /**
5
+ * Core types for scheduler tool provider
6
+ */
7
+
8
+ /**
9
+ * Schedule definition for automated task execution
10
+ */
11
+ interface Schedule {
12
+ id: string;
13
+ /** Human-readable name for the schedule (e.g., "Coffee Reminder") */
14
+ name: string;
15
+ cronExpression: string;
16
+ timezone: string;
17
+ enabled: boolean;
18
+ task: {
19
+ /** Instruction for the executing agent */
20
+ instruction: string;
21
+ metadata?: Record<string, unknown>;
22
+ };
23
+ /**
24
+ * How session context is managed for executions.
25
+ * @default 'ephemeral'
26
+ */
27
+ sessionMode: ScheduleSessionMode;
28
+ /**
29
+ * Session ID for 'fixed' mode, or captured session for 'inherit' mode.
30
+ * Not used for 'ephemeral' or 'dedicated' modes.
31
+ */
32
+ sessionId?: string;
33
+ /** Optional workspace path for executions */
34
+ workspacePath?: string;
35
+ createdAt: number;
36
+ updatedAt: number;
37
+ lastRunAt?: number;
38
+ nextRunAt?: number;
39
+ runCount: number;
40
+ successCount: number;
41
+ failureCount: number;
42
+ lastError?: string;
43
+ }
44
+ /**
45
+ * Execution log entry for schedule runs
46
+ */
47
+ interface ExecutionLog {
48
+ id: string;
49
+ scheduleId: string;
50
+ triggeredAt: number;
51
+ completedAt?: number;
52
+ status: 'pending' | 'success' | 'failed' | 'timeout';
53
+ duration?: number;
54
+ error?: string;
55
+ result?: string;
56
+ }
57
+ /**
58
+ * Schedule filters for listing
59
+ */
60
+ interface ScheduleFilters {
61
+ enabled?: boolean;
62
+ }
63
+ /**
64
+ * Executor function type - called to execute scheduled tasks
65
+ */
66
+ type ScheduleExecutorFn = (params: {
67
+ prompt: string;
68
+ sessionId: string;
69
+ schedule: Schedule;
70
+ }) => Promise<string>;
71
+
72
+ export type { ExecutionLog, Schedule, ScheduleExecutorFn, ScheduleFilters };
package/dist/types.js ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@dexto/tools-scheduler",
3
+ "version": "1.6.0",
4
+ "description": "Scheduler tools provider for Dexto agents - enables proactive task scheduling",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "keywords": [
15
+ "dexto",
16
+ "tools",
17
+ "scheduler",
18
+ "cron",
19
+ "automation"
20
+ ],
21
+ "dependencies": {
22
+ "cron-parser": "^4.9.0",
23
+ "node-cron": "^4.2.1",
24
+ "zod": "^3.25.0",
25
+ "@dexto/agent-config": "1.6.0",
26
+ "@dexto/core": "1.6.0"
27
+ },
28
+ "devDependencies": {
29
+ "tsup": "^8.0.0",
30
+ "typescript": "^5.3.3"
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "README.md"
35
+ ],
36
+ "scripts": {
37
+ "build": "tsup",
38
+ "typecheck": "tsc --noEmit",
39
+ "clean": "rm -rf dist"
40
+ }
41
+ }