@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
package/LICENSE ADDED
@@ -0,0 +1,44 @@
1
+ Elastic License 2.0 (ELv2)
2
+
3
+ **Acceptance**
4
+ By using the software, you agree to all of the terms and conditions below.
5
+
6
+ **Copyright License**
7
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
8
+
9
+ **Limitations**
10
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
11
+
12
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
13
+
14
+ You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
15
+
16
+ **Patents**
17
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
18
+
19
+ **Notices**
20
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
21
+
22
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
23
+
24
+ **No Other Rights**
25
+ These terms do not imply any licenses other than those expressly granted in these terms.
26
+
27
+ **Termination**
28
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
29
+
30
+ **No Liability**
31
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
32
+
33
+ **Definitions**
34
+ The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
35
+
36
+ _you_ refers to the individual or entity agreeing to these terms.
37
+
38
+ _your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
39
+
40
+ _your licenses_ are all the licenses granted to you for the software under these terms.
41
+
42
+ _use_ means anything you do with the software requiring one of your licenses.
43
+
44
+ _trademark_ means trademarks, service marks, and similar rights.
@@ -0,0 +1,44 @@
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 error_codes_exports = {};
20
+ __export(error_codes_exports, {
21
+ SchedulerErrorCode: () => SchedulerErrorCode
22
+ });
23
+ module.exports = __toCommonJS(error_codes_exports);
24
+ var SchedulerErrorCode = /* @__PURE__ */ ((SchedulerErrorCode2) => {
25
+ SchedulerErrorCode2["SCHEDULER_NOT_ENABLED"] = "SCHEDULER_NOT_ENABLED";
26
+ SchedulerErrorCode2["SCHEDULER_INVALID_CONFIG"] = "SCHEDULER_INVALID_CONFIG";
27
+ SchedulerErrorCode2["SCHEDULER_MISSING_STORAGE"] = "SCHEDULER_MISSING_STORAGE";
28
+ SchedulerErrorCode2["SCHEDULE_INVALID_CRON"] = "SCHEDULE_INVALID_CRON";
29
+ SchedulerErrorCode2["SCHEDULE_INVALID_INPUT"] = "SCHEDULE_INVALID_INPUT";
30
+ SchedulerErrorCode2["SCHEDULE_LIMIT_REACHED"] = "SCHEDULE_LIMIT_REACHED";
31
+ SchedulerErrorCode2["SCHEDULE_NOT_FOUND"] = "SCHEDULE_NOT_FOUND";
32
+ SchedulerErrorCode2["SCHEDULE_CREATE_FAILED"] = "SCHEDULE_CREATE_FAILED";
33
+ SchedulerErrorCode2["SCHEDULE_UPDATE_FAILED"] = "SCHEDULE_UPDATE_FAILED";
34
+ SchedulerErrorCode2["SCHEDULE_DELETE_FAILED"] = "SCHEDULE_DELETE_FAILED";
35
+ SchedulerErrorCode2["SCHEDULE_EXECUTION_FAILED"] = "SCHEDULE_EXECUTION_FAILED";
36
+ SchedulerErrorCode2["SCHEDULE_EXECUTION_TIMEOUT"] = "SCHEDULE_EXECUTION_TIMEOUT";
37
+ SchedulerErrorCode2["STORAGE_READ_FAILED"] = "STORAGE_READ_FAILED";
38
+ SchedulerErrorCode2["STORAGE_WRITE_FAILED"] = "STORAGE_WRITE_FAILED";
39
+ return SchedulerErrorCode2;
40
+ })(SchedulerErrorCode || {});
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ SchedulerErrorCode
44
+ });
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Error codes for scheduler operations
3
+ */
4
+ declare enum SchedulerErrorCode {
5
+ SCHEDULER_NOT_ENABLED = "SCHEDULER_NOT_ENABLED",
6
+ SCHEDULER_INVALID_CONFIG = "SCHEDULER_INVALID_CONFIG",
7
+ SCHEDULER_MISSING_STORAGE = "SCHEDULER_MISSING_STORAGE",
8
+ SCHEDULE_INVALID_CRON = "SCHEDULE_INVALID_CRON",
9
+ SCHEDULE_INVALID_INPUT = "SCHEDULE_INVALID_INPUT",
10
+ SCHEDULE_LIMIT_REACHED = "SCHEDULE_LIMIT_REACHED",
11
+ SCHEDULE_NOT_FOUND = "SCHEDULE_NOT_FOUND",
12
+ SCHEDULE_CREATE_FAILED = "SCHEDULE_CREATE_FAILED",
13
+ SCHEDULE_UPDATE_FAILED = "SCHEDULE_UPDATE_FAILED",
14
+ SCHEDULE_DELETE_FAILED = "SCHEDULE_DELETE_FAILED",
15
+ SCHEDULE_EXECUTION_FAILED = "SCHEDULE_EXECUTION_FAILED",
16
+ SCHEDULE_EXECUTION_TIMEOUT = "SCHEDULE_EXECUTION_TIMEOUT",
17
+ STORAGE_READ_FAILED = "STORAGE_READ_FAILED",
18
+ STORAGE_WRITE_FAILED = "STORAGE_WRITE_FAILED"
19
+ }
20
+
21
+ export { SchedulerErrorCode };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Error codes for scheduler operations
3
+ */
4
+ declare enum SchedulerErrorCode {
5
+ SCHEDULER_NOT_ENABLED = "SCHEDULER_NOT_ENABLED",
6
+ SCHEDULER_INVALID_CONFIG = "SCHEDULER_INVALID_CONFIG",
7
+ SCHEDULER_MISSING_STORAGE = "SCHEDULER_MISSING_STORAGE",
8
+ SCHEDULE_INVALID_CRON = "SCHEDULE_INVALID_CRON",
9
+ SCHEDULE_INVALID_INPUT = "SCHEDULE_INVALID_INPUT",
10
+ SCHEDULE_LIMIT_REACHED = "SCHEDULE_LIMIT_REACHED",
11
+ SCHEDULE_NOT_FOUND = "SCHEDULE_NOT_FOUND",
12
+ SCHEDULE_CREATE_FAILED = "SCHEDULE_CREATE_FAILED",
13
+ SCHEDULE_UPDATE_FAILED = "SCHEDULE_UPDATE_FAILED",
14
+ SCHEDULE_DELETE_FAILED = "SCHEDULE_DELETE_FAILED",
15
+ SCHEDULE_EXECUTION_FAILED = "SCHEDULE_EXECUTION_FAILED",
16
+ SCHEDULE_EXECUTION_TIMEOUT = "SCHEDULE_EXECUTION_TIMEOUT",
17
+ STORAGE_READ_FAILED = "STORAGE_READ_FAILED",
18
+ STORAGE_WRITE_FAILED = "STORAGE_WRITE_FAILED"
19
+ }
20
+
21
+ export { SchedulerErrorCode };
@@ -0,0 +1,20 @@
1
+ var SchedulerErrorCode = /* @__PURE__ */ ((SchedulerErrorCode2) => {
2
+ SchedulerErrorCode2["SCHEDULER_NOT_ENABLED"] = "SCHEDULER_NOT_ENABLED";
3
+ SchedulerErrorCode2["SCHEDULER_INVALID_CONFIG"] = "SCHEDULER_INVALID_CONFIG";
4
+ SchedulerErrorCode2["SCHEDULER_MISSING_STORAGE"] = "SCHEDULER_MISSING_STORAGE";
5
+ SchedulerErrorCode2["SCHEDULE_INVALID_CRON"] = "SCHEDULE_INVALID_CRON";
6
+ SchedulerErrorCode2["SCHEDULE_INVALID_INPUT"] = "SCHEDULE_INVALID_INPUT";
7
+ SchedulerErrorCode2["SCHEDULE_LIMIT_REACHED"] = "SCHEDULE_LIMIT_REACHED";
8
+ SchedulerErrorCode2["SCHEDULE_NOT_FOUND"] = "SCHEDULE_NOT_FOUND";
9
+ SchedulerErrorCode2["SCHEDULE_CREATE_FAILED"] = "SCHEDULE_CREATE_FAILED";
10
+ SchedulerErrorCode2["SCHEDULE_UPDATE_FAILED"] = "SCHEDULE_UPDATE_FAILED";
11
+ SchedulerErrorCode2["SCHEDULE_DELETE_FAILED"] = "SCHEDULE_DELETE_FAILED";
12
+ SchedulerErrorCode2["SCHEDULE_EXECUTION_FAILED"] = "SCHEDULE_EXECUTION_FAILED";
13
+ SchedulerErrorCode2["SCHEDULE_EXECUTION_TIMEOUT"] = "SCHEDULE_EXECUTION_TIMEOUT";
14
+ SchedulerErrorCode2["STORAGE_READ_FAILED"] = "STORAGE_READ_FAILED";
15
+ SchedulerErrorCode2["STORAGE_WRITE_FAILED"] = "STORAGE_WRITE_FAILED";
16
+ return SchedulerErrorCode2;
17
+ })(SchedulerErrorCode || {});
18
+ export {
19
+ SchedulerErrorCode
20
+ };
@@ -0,0 +1,163 @@
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 errors_exports = {};
20
+ __export(errors_exports, {
21
+ SCHEDULER_ERROR_SCOPE: () => SCHEDULER_ERROR_SCOPE,
22
+ SchedulerError: () => SchedulerError
23
+ });
24
+ module.exports = __toCommonJS(errors_exports);
25
+ var import_core = require("@dexto/core");
26
+ var import_error_codes = require("./error-codes.js");
27
+ const SCHEDULER_ERROR_SCOPE = "scheduler";
28
+ class SchedulerError {
29
+ static notEnabled() {
30
+ return new import_core.DextoRuntimeError(
31
+ import_error_codes.SchedulerErrorCode.SCHEDULER_NOT_ENABLED,
32
+ SCHEDULER_ERROR_SCOPE,
33
+ import_core.ErrorType.USER,
34
+ "Scheduler is not enabled in configuration",
35
+ void 0,
36
+ "Add scheduler-tools to customTools in your agent configuration"
37
+ );
38
+ }
39
+ static missingStorage() {
40
+ return new import_core.DextoRuntimeError(
41
+ import_error_codes.SchedulerErrorCode.SCHEDULER_MISSING_STORAGE,
42
+ SCHEDULER_ERROR_SCOPE,
43
+ import_core.ErrorType.SYSTEM,
44
+ "StorageManager is required but not available",
45
+ void 0,
46
+ "Ensure StorageManager is available in context.services"
47
+ );
48
+ }
49
+ static invalidConfig(details) {
50
+ return new import_core.DextoRuntimeError(
51
+ import_error_codes.SchedulerErrorCode.SCHEDULER_INVALID_CONFIG,
52
+ SCHEDULER_ERROR_SCOPE,
53
+ import_core.ErrorType.USER,
54
+ `Invalid scheduler configuration: ${details}`,
55
+ { details }
56
+ );
57
+ }
58
+ static invalidCron(expression, details) {
59
+ return new import_core.DextoRuntimeError(
60
+ import_error_codes.SchedulerErrorCode.SCHEDULE_INVALID_CRON,
61
+ SCHEDULER_ERROR_SCOPE,
62
+ import_core.ErrorType.USER,
63
+ `Invalid cron expression: ${expression}${details ? ` - ${details}` : ""}`,
64
+ { expression, details }
65
+ );
66
+ }
67
+ static invalidInput(details) {
68
+ return new import_core.DextoRuntimeError(
69
+ import_error_codes.SchedulerErrorCode.SCHEDULE_INVALID_INPUT,
70
+ SCHEDULER_ERROR_SCOPE,
71
+ import_core.ErrorType.USER,
72
+ `Invalid schedule input: ${details}`,
73
+ { details }
74
+ );
75
+ }
76
+ static limitReached(current, max) {
77
+ return new import_core.DextoRuntimeError(
78
+ import_error_codes.SchedulerErrorCode.SCHEDULE_LIMIT_REACHED,
79
+ SCHEDULER_ERROR_SCOPE,
80
+ import_core.ErrorType.USER,
81
+ `Schedule limit reached: ${current}/${max}`,
82
+ { current, max },
83
+ "Delete unused schedules or increase maxSchedules in configuration"
84
+ );
85
+ }
86
+ static notFound(scheduleId) {
87
+ return new import_core.DextoRuntimeError(
88
+ import_error_codes.SchedulerErrorCode.SCHEDULE_NOT_FOUND,
89
+ SCHEDULER_ERROR_SCOPE,
90
+ import_core.ErrorType.NOT_FOUND,
91
+ `Schedule not found: ${scheduleId}`,
92
+ { scheduleId }
93
+ );
94
+ }
95
+ static createFailed(details) {
96
+ return new import_core.DextoRuntimeError(
97
+ import_error_codes.SchedulerErrorCode.SCHEDULE_CREATE_FAILED,
98
+ SCHEDULER_ERROR_SCOPE,
99
+ import_core.ErrorType.SYSTEM,
100
+ `Failed to create schedule: ${details}`,
101
+ { details }
102
+ );
103
+ }
104
+ static updateFailed(scheduleId, details) {
105
+ return new import_core.DextoRuntimeError(
106
+ import_error_codes.SchedulerErrorCode.SCHEDULE_UPDATE_FAILED,
107
+ SCHEDULER_ERROR_SCOPE,
108
+ import_core.ErrorType.SYSTEM,
109
+ `Failed to update schedule ${scheduleId}: ${details}`,
110
+ { scheduleId, details }
111
+ );
112
+ }
113
+ static deleteFailed(scheduleId, details) {
114
+ return new import_core.DextoRuntimeError(
115
+ import_error_codes.SchedulerErrorCode.SCHEDULE_DELETE_FAILED,
116
+ SCHEDULER_ERROR_SCOPE,
117
+ import_core.ErrorType.SYSTEM,
118
+ `Failed to delete schedule ${scheduleId}: ${details}`,
119
+ { scheduleId, details }
120
+ );
121
+ }
122
+ static executionFailed(scheduleId, details) {
123
+ return new import_core.DextoRuntimeError(
124
+ import_error_codes.SchedulerErrorCode.SCHEDULE_EXECUTION_FAILED,
125
+ SCHEDULER_ERROR_SCOPE,
126
+ import_core.ErrorType.SYSTEM,
127
+ `Schedule execution failed for ${scheduleId}: ${details}`,
128
+ { scheduleId, details }
129
+ );
130
+ }
131
+ static executionTimeout(scheduleId, timeout) {
132
+ return new import_core.DextoRuntimeError(
133
+ import_error_codes.SchedulerErrorCode.SCHEDULE_EXECUTION_TIMEOUT,
134
+ SCHEDULER_ERROR_SCOPE,
135
+ import_core.ErrorType.TIMEOUT,
136
+ `Schedule execution timed out for ${scheduleId} after ${timeout}ms`,
137
+ { scheduleId, timeout }
138
+ );
139
+ }
140
+ static storageReadFailed(operation, details) {
141
+ return new import_core.DextoRuntimeError(
142
+ import_error_codes.SchedulerErrorCode.STORAGE_READ_FAILED,
143
+ SCHEDULER_ERROR_SCOPE,
144
+ import_core.ErrorType.SYSTEM,
145
+ `Storage read failed for ${operation}: ${details}`,
146
+ { operation, details }
147
+ );
148
+ }
149
+ static storageWriteFailed(operation, details) {
150
+ return new import_core.DextoRuntimeError(
151
+ import_error_codes.SchedulerErrorCode.STORAGE_WRITE_FAILED,
152
+ SCHEDULER_ERROR_SCOPE,
153
+ import_core.ErrorType.SYSTEM,
154
+ `Storage write failed for ${operation}: ${details}`,
155
+ { operation, details }
156
+ );
157
+ }
158
+ }
159
+ // Annotate the CommonJS export names for ESM import in node:
160
+ 0 && (module.exports = {
161
+ SCHEDULER_ERROR_SCOPE,
162
+ SchedulerError
163
+ });
@@ -0,0 +1,64 @@
1
+ import { DextoRuntimeError } from '@dexto/core';
2
+
3
+ /**
4
+ * Error classes for scheduler operations
5
+ */
6
+
7
+ /**
8
+ * Scheduler error scope (string literal since scheduler is external to core)
9
+ */
10
+ declare const SCHEDULER_ERROR_SCOPE: "scheduler";
11
+ /**
12
+ * Scheduler error factory methods
13
+ * Creates properly typed errors for scheduler operations
14
+ */
15
+ declare class SchedulerError {
16
+ static notEnabled(): DextoRuntimeError<undefined>;
17
+ static missingStorage(): DextoRuntimeError<undefined>;
18
+ static invalidConfig(details: string): DextoRuntimeError<{
19
+ details: string;
20
+ }>;
21
+ static invalidCron(expression: string, details?: string): DextoRuntimeError<{
22
+ expression: string;
23
+ details: string | undefined;
24
+ }>;
25
+ static invalidInput(details: string): DextoRuntimeError<{
26
+ details: string;
27
+ }>;
28
+ static limitReached(current: number, max: number): DextoRuntimeError<{
29
+ current: number;
30
+ max: number;
31
+ }>;
32
+ static notFound(scheduleId: string): DextoRuntimeError<{
33
+ scheduleId: string;
34
+ }>;
35
+ static createFailed(details: string): DextoRuntimeError<{
36
+ details: string;
37
+ }>;
38
+ static updateFailed(scheduleId: string, details: string): DextoRuntimeError<{
39
+ scheduleId: string;
40
+ details: string;
41
+ }>;
42
+ static deleteFailed(scheduleId: string, details: string): DextoRuntimeError<{
43
+ scheduleId: string;
44
+ details: string;
45
+ }>;
46
+ static executionFailed(scheduleId: string, details: string): DextoRuntimeError<{
47
+ scheduleId: string;
48
+ details: string;
49
+ }>;
50
+ static executionTimeout(scheduleId: string, timeout: number): DextoRuntimeError<{
51
+ scheduleId: string;
52
+ timeout: number;
53
+ }>;
54
+ static storageReadFailed(operation: string, details: string): DextoRuntimeError<{
55
+ operation: string;
56
+ details: string;
57
+ }>;
58
+ static storageWriteFailed(operation: string, details: string): DextoRuntimeError<{
59
+ operation: string;
60
+ details: string;
61
+ }>;
62
+ }
63
+
64
+ export { SCHEDULER_ERROR_SCOPE, SchedulerError };
@@ -0,0 +1,64 @@
1
+ import { DextoRuntimeError } from '@dexto/core';
2
+
3
+ /**
4
+ * Error classes for scheduler operations
5
+ */
6
+
7
+ /**
8
+ * Scheduler error scope (string literal since scheduler is external to core)
9
+ */
10
+ declare const SCHEDULER_ERROR_SCOPE: "scheduler";
11
+ /**
12
+ * Scheduler error factory methods
13
+ * Creates properly typed errors for scheduler operations
14
+ */
15
+ declare class SchedulerError {
16
+ static notEnabled(): DextoRuntimeError<undefined>;
17
+ static missingStorage(): DextoRuntimeError<undefined>;
18
+ static invalidConfig(details: string): DextoRuntimeError<{
19
+ details: string;
20
+ }>;
21
+ static invalidCron(expression: string, details?: string): DextoRuntimeError<{
22
+ expression: string;
23
+ details: string | undefined;
24
+ }>;
25
+ static invalidInput(details: string): DextoRuntimeError<{
26
+ details: string;
27
+ }>;
28
+ static limitReached(current: number, max: number): DextoRuntimeError<{
29
+ current: number;
30
+ max: number;
31
+ }>;
32
+ static notFound(scheduleId: string): DextoRuntimeError<{
33
+ scheduleId: string;
34
+ }>;
35
+ static createFailed(details: string): DextoRuntimeError<{
36
+ details: string;
37
+ }>;
38
+ static updateFailed(scheduleId: string, details: string): DextoRuntimeError<{
39
+ scheduleId: string;
40
+ details: string;
41
+ }>;
42
+ static deleteFailed(scheduleId: string, details: string): DextoRuntimeError<{
43
+ scheduleId: string;
44
+ details: string;
45
+ }>;
46
+ static executionFailed(scheduleId: string, details: string): DextoRuntimeError<{
47
+ scheduleId: string;
48
+ details: string;
49
+ }>;
50
+ static executionTimeout(scheduleId: string, timeout: number): DextoRuntimeError<{
51
+ scheduleId: string;
52
+ timeout: number;
53
+ }>;
54
+ static storageReadFailed(operation: string, details: string): DextoRuntimeError<{
55
+ operation: string;
56
+ details: string;
57
+ }>;
58
+ static storageWriteFailed(operation: string, details: string): DextoRuntimeError<{
59
+ operation: string;
60
+ details: string;
61
+ }>;
62
+ }
63
+
64
+ export { SCHEDULER_ERROR_SCOPE, SchedulerError };
package/dist/errors.js ADDED
@@ -0,0 +1,138 @@
1
+ import { DextoRuntimeError, ErrorType } from "@dexto/core";
2
+ import { SchedulerErrorCode } from "./error-codes.js";
3
+ const SCHEDULER_ERROR_SCOPE = "scheduler";
4
+ class SchedulerError {
5
+ static notEnabled() {
6
+ return new DextoRuntimeError(
7
+ SchedulerErrorCode.SCHEDULER_NOT_ENABLED,
8
+ SCHEDULER_ERROR_SCOPE,
9
+ ErrorType.USER,
10
+ "Scheduler is not enabled in configuration",
11
+ void 0,
12
+ "Add scheduler-tools to customTools in your agent configuration"
13
+ );
14
+ }
15
+ static missingStorage() {
16
+ return new DextoRuntimeError(
17
+ SchedulerErrorCode.SCHEDULER_MISSING_STORAGE,
18
+ SCHEDULER_ERROR_SCOPE,
19
+ ErrorType.SYSTEM,
20
+ "StorageManager is required but not available",
21
+ void 0,
22
+ "Ensure StorageManager is available in context.services"
23
+ );
24
+ }
25
+ static invalidConfig(details) {
26
+ return new DextoRuntimeError(
27
+ SchedulerErrorCode.SCHEDULER_INVALID_CONFIG,
28
+ SCHEDULER_ERROR_SCOPE,
29
+ ErrorType.USER,
30
+ `Invalid scheduler configuration: ${details}`,
31
+ { details }
32
+ );
33
+ }
34
+ static invalidCron(expression, details) {
35
+ return new DextoRuntimeError(
36
+ SchedulerErrorCode.SCHEDULE_INVALID_CRON,
37
+ SCHEDULER_ERROR_SCOPE,
38
+ ErrorType.USER,
39
+ `Invalid cron expression: ${expression}${details ? ` - ${details}` : ""}`,
40
+ { expression, details }
41
+ );
42
+ }
43
+ static invalidInput(details) {
44
+ return new DextoRuntimeError(
45
+ SchedulerErrorCode.SCHEDULE_INVALID_INPUT,
46
+ SCHEDULER_ERROR_SCOPE,
47
+ ErrorType.USER,
48
+ `Invalid schedule input: ${details}`,
49
+ { details }
50
+ );
51
+ }
52
+ static limitReached(current, max) {
53
+ return new DextoRuntimeError(
54
+ SchedulerErrorCode.SCHEDULE_LIMIT_REACHED,
55
+ SCHEDULER_ERROR_SCOPE,
56
+ ErrorType.USER,
57
+ `Schedule limit reached: ${current}/${max}`,
58
+ { current, max },
59
+ "Delete unused schedules or increase maxSchedules in configuration"
60
+ );
61
+ }
62
+ static notFound(scheduleId) {
63
+ return new DextoRuntimeError(
64
+ SchedulerErrorCode.SCHEDULE_NOT_FOUND,
65
+ SCHEDULER_ERROR_SCOPE,
66
+ ErrorType.NOT_FOUND,
67
+ `Schedule not found: ${scheduleId}`,
68
+ { scheduleId }
69
+ );
70
+ }
71
+ static createFailed(details) {
72
+ return new DextoRuntimeError(
73
+ SchedulerErrorCode.SCHEDULE_CREATE_FAILED,
74
+ SCHEDULER_ERROR_SCOPE,
75
+ ErrorType.SYSTEM,
76
+ `Failed to create schedule: ${details}`,
77
+ { details }
78
+ );
79
+ }
80
+ static updateFailed(scheduleId, details) {
81
+ return new DextoRuntimeError(
82
+ SchedulerErrorCode.SCHEDULE_UPDATE_FAILED,
83
+ SCHEDULER_ERROR_SCOPE,
84
+ ErrorType.SYSTEM,
85
+ `Failed to update schedule ${scheduleId}: ${details}`,
86
+ { scheduleId, details }
87
+ );
88
+ }
89
+ static deleteFailed(scheduleId, details) {
90
+ return new DextoRuntimeError(
91
+ SchedulerErrorCode.SCHEDULE_DELETE_FAILED,
92
+ SCHEDULER_ERROR_SCOPE,
93
+ ErrorType.SYSTEM,
94
+ `Failed to delete schedule ${scheduleId}: ${details}`,
95
+ { scheduleId, details }
96
+ );
97
+ }
98
+ static executionFailed(scheduleId, details) {
99
+ return new DextoRuntimeError(
100
+ SchedulerErrorCode.SCHEDULE_EXECUTION_FAILED,
101
+ SCHEDULER_ERROR_SCOPE,
102
+ ErrorType.SYSTEM,
103
+ `Schedule execution failed for ${scheduleId}: ${details}`,
104
+ { scheduleId, details }
105
+ );
106
+ }
107
+ static executionTimeout(scheduleId, timeout) {
108
+ return new DextoRuntimeError(
109
+ SchedulerErrorCode.SCHEDULE_EXECUTION_TIMEOUT,
110
+ SCHEDULER_ERROR_SCOPE,
111
+ ErrorType.TIMEOUT,
112
+ `Schedule execution timed out for ${scheduleId} after ${timeout}ms`,
113
+ { scheduleId, timeout }
114
+ );
115
+ }
116
+ static storageReadFailed(operation, details) {
117
+ return new DextoRuntimeError(
118
+ SchedulerErrorCode.STORAGE_READ_FAILED,
119
+ SCHEDULER_ERROR_SCOPE,
120
+ ErrorType.SYSTEM,
121
+ `Storage read failed for ${operation}: ${details}`,
122
+ { operation, details }
123
+ );
124
+ }
125
+ static storageWriteFailed(operation, details) {
126
+ return new DextoRuntimeError(
127
+ SchedulerErrorCode.STORAGE_WRITE_FAILED,
128
+ SCHEDULER_ERROR_SCOPE,
129
+ ErrorType.SYSTEM,
130
+ `Storage write failed for ${operation}: ${details}`,
131
+ { operation, details }
132
+ );
133
+ }
134
+ }
135
+ export {
136
+ SCHEDULER_ERROR_SCOPE,
137
+ SchedulerError
138
+ };