crewly 1.4.63 → 1.4.64

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 (24) hide show
  1. package/dist/backend/backend/src/controllers/scheduler/unified-scheduler.controller.d.ts +91 -0
  2. package/dist/backend/backend/src/controllers/scheduler/unified-scheduler.controller.d.ts.map +1 -0
  3. package/dist/backend/backend/src/controllers/scheduler/unified-scheduler.controller.js +290 -0
  4. package/dist/backend/backend/src/controllers/scheduler/unified-scheduler.controller.js.map +1 -0
  5. package/dist/backend/backend/src/routes/api.routes.d.ts.map +1 -1
  6. package/dist/backend/backend/src/routes/api.routes.js +3 -0
  7. package/dist/backend/backend/src/routes/api.routes.js.map +1 -1
  8. package/dist/backend/backend/src/routes/modules/unified-scheduler.routes.d.ts +27 -0
  9. package/dist/backend/backend/src/routes/modules/unified-scheduler.routes.d.ts.map +1 -0
  10. package/dist/backend/backend/src/routes/modules/unified-scheduler.routes.js +40 -0
  11. package/dist/backend/backend/src/routes/modules/unified-scheduler.routes.js.map +1 -0
  12. package/dist/backend/backend/src/services/index.d.ts +1 -0
  13. package/dist/backend/backend/src/services/index.d.ts.map +1 -1
  14. package/dist/backend/backend/src/services/index.js +1 -0
  15. package/dist/backend/backend/src/services/index.js.map +1 -1
  16. package/dist/backend/backend/src/services/workflow/unified-scheduler.service.d.ts +234 -0
  17. package/dist/backend/backend/src/services/workflow/unified-scheduler.service.d.ts.map +1 -0
  18. package/dist/backend/backend/src/services/workflow/unified-scheduler.service.js +636 -0
  19. package/dist/backend/backend/src/services/workflow/unified-scheduler.service.js.map +1 -0
  20. package/dist/backend/backend/src/services/workflow/unified-scheduler.types.d.ts +156 -0
  21. package/dist/backend/backend/src/services/workflow/unified-scheduler.types.d.ts.map +1 -0
  22. package/dist/backend/backend/src/services/workflow/unified-scheduler.types.js +81 -0
  23. package/dist/backend/backend/src/services/workflow/unified-scheduler.types.js.map +1 -0
  24. package/package.json +1 -1
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Type definitions for the Unified Scheduler Service.
3
+ *
4
+ * The Unified Scheduler consolidates cron, interval, and idle-based
5
+ * scheduling into a single interface with persistent storage and
6
+ * agent auto-start capabilities.
7
+ *
8
+ * @module services/workflow/unified-scheduler.types
9
+ */
10
+ /** Supported schedule trigger types. */
11
+ export type ScheduleType = 'cron' | 'interval' | 'idle';
12
+ /** Runtime status of a schedule. */
13
+ export type ScheduleStatus = 'active' | 'paused' | 'completed' | 'error';
14
+ /**
15
+ * A unified schedule definition.
16
+ *
17
+ * Combines cron expressions, fixed intervals, and idle detection
18
+ * into a single structure. Only the fields relevant to the `type`
19
+ * are used at runtime:
20
+ * - type=cron: uses `cron`
21
+ * - type=interval: uses `intervalMinutes`
22
+ * - type=idle: uses `idleTimeoutMinutes`
23
+ */
24
+ export interface UnifiedSchedule {
25
+ /** Unique schedule identifier (UUID) */
26
+ id: string;
27
+ /** Target agent session name */
28
+ target: string;
29
+ /** Schedule type determines which timing field is used */
30
+ type: ScheduleType;
31
+ /** Cron expression (5-field, e.g., "0 8,14,20 * * *") — required when type=cron */
32
+ cron?: string;
33
+ /** Interval in minutes between triggers — required when type=interval */
34
+ intervalMinutes?: number;
35
+ /** Minutes of idle time before triggering — required when type=idle */
36
+ idleTimeoutMinutes?: number;
37
+ /** Message to send to the target agent when triggered */
38
+ message: string;
39
+ /** Whether the schedule is actively running */
40
+ enabled: boolean;
41
+ /** Auto-start the target agent if it's offline when triggered */
42
+ autoStart: boolean;
43
+ /** Maximum consecutive triggers before auto-pausing (default: 10) */
44
+ maxConsecutiveTriggers: number;
45
+ /** ISO timestamp of creation */
46
+ createdAt: string;
47
+ /** ISO timestamp of last modification */
48
+ updatedAt: string;
49
+ /** ISO timestamp of last trigger, or null if never triggered */
50
+ lastTriggeredAt: string | null;
51
+ /** Total number of times this schedule has triggered */
52
+ triggerCount: number;
53
+ /** Consecutive triggers since last agent activity/response */
54
+ consecutiveTriggers: number;
55
+ /** Current runtime status */
56
+ status: ScheduleStatus;
57
+ /** Error message if status is 'error' */
58
+ error?: string;
59
+ }
60
+ /** Request body for creating a new schedule. */
61
+ export interface CreateScheduleRequest {
62
+ /** Target agent session name */
63
+ target: string;
64
+ /** Schedule type */
65
+ type: ScheduleType;
66
+ /** Cron expression (required when type=cron) */
67
+ cron?: string;
68
+ /** Interval in minutes (required when type=interval) */
69
+ intervalMinutes?: number;
70
+ /** Idle timeout in minutes (required when type=idle) */
71
+ idleTimeoutMinutes?: number;
72
+ /** Message to send to the agent */
73
+ message: string;
74
+ /** Whether to activate immediately (default: true) */
75
+ enabled?: boolean;
76
+ /** Auto-start agent if offline (default: true) */
77
+ autoStart?: boolean;
78
+ /** Max consecutive triggers before auto-pause (default: 10) */
79
+ maxConsecutiveTriggers?: number;
80
+ }
81
+ /** Request body for updating an existing schedule. */
82
+ export interface UpdateScheduleRequest {
83
+ /** Updated cron expression */
84
+ cron?: string;
85
+ /** Updated interval */
86
+ intervalMinutes?: number;
87
+ /** Updated idle timeout */
88
+ idleTimeoutMinutes?: number;
89
+ /** Updated message */
90
+ message?: string;
91
+ /** Enable/disable */
92
+ enabled?: boolean;
93
+ /** Auto-start toggle */
94
+ autoStart?: boolean;
95
+ /** Updated max consecutive triggers */
96
+ maxConsecutiveTriggers?: number;
97
+ }
98
+ /** Persistent storage format for ~/.crewly/unified-schedules.json */
99
+ export interface UnifiedScheduleStore {
100
+ /** Schema version for future migrations */
101
+ version: string;
102
+ /** Last persistence timestamp */
103
+ updatedAt: string;
104
+ /** All schedule definitions */
105
+ schedules: UnifiedSchedule[];
106
+ }
107
+ /** Scheduler health/stats response. */
108
+ export interface SchedulerHealth {
109
+ /** Whether the scheduler loop is running */
110
+ running: boolean;
111
+ /** Number of active schedules */
112
+ activeCount: number;
113
+ /** Number of paused schedules */
114
+ pausedCount: number;
115
+ /** Total schedules (all statuses) */
116
+ totalCount: number;
117
+ /** Total triggers executed since service start */
118
+ totalTriggers: number;
119
+ /** Timestamp of last evaluation cycle */
120
+ lastEvaluatedAt: string | null;
121
+ /** Schedules grouped by type */
122
+ byType: Record<ScheduleType, number>;
123
+ }
124
+ /** Default values for the unified scheduler. */
125
+ export declare const UNIFIED_SCHEDULER_CONSTANTS: {
126
+ /** Evaluation loop interval (60 seconds — matches cron granularity) */
127
+ readonly EVAL_INTERVAL_MS: 60000;
128
+ /** Storage file path (relative to ~/.crewly/) */
129
+ readonly STORAGE_FILE: "unified-schedules.json";
130
+ /** Default max consecutive triggers before auto-pause */
131
+ readonly DEFAULT_MAX_CONSECUTIVE: 10;
132
+ /** Storage schema version */
133
+ readonly SCHEMA_VERSION: "1.0.0";
134
+ /** Default idle timeout if not specified (30 minutes) */
135
+ readonly DEFAULT_IDLE_TIMEOUT_MINUTES: 30;
136
+ };
137
+ /** Valid schedule types for request validation. */
138
+ export declare const VALID_SCHEDULE_TYPES: ReadonlySet<string>;
139
+ /**
140
+ * Validate a cron expression (basic 5-field format).
141
+ *
142
+ * Checks that the expression has exactly 5 space-separated fields
143
+ * and each field contains only valid cron characters.
144
+ *
145
+ * @param expr - Cron expression to validate
146
+ * @returns True if valid
147
+ */
148
+ export declare function isValidCronExpression(expr: string): boolean;
149
+ /**
150
+ * Validate a CreateScheduleRequest.
151
+ *
152
+ * @param req - Request to validate
153
+ * @returns Error message or null if valid
154
+ */
155
+ export declare function validateCreateRequest(req: CreateScheduleRequest): string | null;
156
+ //# sourceMappingURL=unified-scheduler.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unified-scheduler.types.d.ts","sourceRoot":"","sources":["../../../../../../backend/src/services/workflow/unified-scheduler.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,wCAAwC;AACxC,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC;AAExD,oCAAoC;AACpC,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;AAEzE;;;;;;;;;GASG;A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,mDAAmD;AACnD,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAyC,CAAC;AAE/F;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAK3D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,qBAAqB,GAAG,MAAM,GAAG,IAAI,CAyB/E"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Type definitions for the Unified Scheduler Service.
3
+ *
4
+ * The Unified Scheduler consolidates cron, interval, and idle-based
5
+ * scheduling into a single interface with persistent storage and
6
+ * agent auto-start capabilities.
7
+ *
8
+ * @module services/workflow/unified-scheduler.types
9
+ */
10
+ // =============================================================================
11
+ // Constants
12
+ // =============================================================================
13
+ /** Default values for the unified scheduler. */
14
+ export const UNIFIED_SCHEDULER_CONSTANTS = {
15
+ /** Evaluation loop interval (60 seconds — matches cron granularity) */
16
+ EVAL_INTERVAL_MS: 60_000,
17
+ /** Storage file path (relative to ~/.crewly/) */
18
+ STORAGE_FILE: 'unified-schedules.json',
19
+ /** Default max consecutive triggers before auto-pause */
20
+ DEFAULT_MAX_CONSECUTIVE: 10,
21
+ /** Storage schema version */
22
+ SCHEMA_VERSION: '1.0.0',
23
+ /** Default idle timeout if not specified (30 minutes) */
24
+ DEFAULT_IDLE_TIMEOUT_MINUTES: 30,
25
+ };
26
+ // =============================================================================
27
+ // Validation
28
+ // =============================================================================
29
+ /** Valid schedule types for request validation. */
30
+ export const VALID_SCHEDULE_TYPES = new Set(['cron', 'interval', 'idle']);
31
+ /**
32
+ * Validate a cron expression (basic 5-field format).
33
+ *
34
+ * Checks that the expression has exactly 5 space-separated fields
35
+ * and each field contains only valid cron characters.
36
+ *
37
+ * @param expr - Cron expression to validate
38
+ * @returns True if valid
39
+ */
40
+ export function isValidCronExpression(expr) {
41
+ const fields = expr.trim().split(/\s+/);
42
+ if (fields.length !== 5)
43
+ return false;
44
+ const validChars = /^[\d,\-\*\/]+$/;
45
+ return fields.every(f => validChars.test(f));
46
+ }
47
+ /**
48
+ * Validate a CreateScheduleRequest.
49
+ *
50
+ * @param req - Request to validate
51
+ * @returns Error message or null if valid
52
+ */
53
+ export function validateCreateRequest(req) {
54
+ if (!req.target || typeof req.target !== 'string')
55
+ return 'target is required';
56
+ if (!req.message || typeof req.message !== 'string')
57
+ return 'message is required';
58
+ if (!req.type || !VALID_SCHEDULE_TYPES.has(req.type)) {
59
+ return `type must be one of: ${[...VALID_SCHEDULE_TYPES].join(', ')}`;
60
+ }
61
+ switch (req.type) {
62
+ case 'cron':
63
+ if (!req.cron)
64
+ return 'cron expression is required when type=cron';
65
+ if (!isValidCronExpression(req.cron))
66
+ return `Invalid cron expression: ${req.cron}`;
67
+ break;
68
+ case 'interval':
69
+ if (!req.intervalMinutes || req.intervalMinutes <= 0) {
70
+ return 'intervalMinutes must be a positive number when type=interval';
71
+ }
72
+ break;
73
+ case 'idle':
74
+ if (!req.idleTimeoutMinutes || req.idleTimeoutMinutes <= 0) {
75
+ return 'idleTimeoutMinutes must be a positive number when type=idle';
76
+ }
77
+ break;
78
+ }
79
+ return null;
80
+ }
81
+ //# sourceMappingURL=unified-scheduler.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unified-scheduler.types.js","sourceRoot":"","sources":["../../../../../../backend/src/services/workflow/unified-scheduler.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA2IH,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,gDAAgD;AAChD,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,uEAAuE;IACvE,gBAAgB,EAAE,MAAM;IACxB,iDAAiD;IACjD,YAAY,EAAE,wBAAwB;IACtC,yDAAyD;IACzD,uBAAuB,EAAE,EAAE;IAC3B,6BAA6B;IAC7B,cAAc,EAAE,OAAO;IACvB,yDAAyD;IACzD,4BAA4B,EAAE,EAAE;CACxB,CAAC;AAEX,gFAAgF;AAChF,aAAa;A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QACR,KAAK,UAAU;YACb,IAAI,CAAC,GAAG,CAAC,eAAe,IAAI,GAAG,CAAC,eAAe,IAAI,CAAC,EAAE,CAAC;gBACrD,OAAO,8DAA8D,CAAC;YACxE,CAAC;YACD,MAAM;QACR,KAAK,MAAM;YACT,IAAI,CAAC,GAAG,CAAC,kBAAkB,IAAI,GAAG,CAAC,kBAAkB,IAAI,CAAC,EAAE,CAAC;gBAC3D,OAAO,6DAA6D,CAAC;YACvE,CAAC;YACD,MAAM;IACV,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crewly",
3
- "version": "1.4.63",
3
+ "version": "1.4.64",
4
4
  "type": "module",
5
5
  "description": "Multi-agent orchestration platform for AI coding teams — coordinates Claude Code, Gemini CLI, and Codex agents with a real-time web dashboard",
6
6
  "main": "dist/cli/cli/src/index.js",