crewly 1.4.43 → 1.4.45
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/config/constants.ts +4 -0
- package/config/skills/agent/core/schedule-check/execute.sh +43 -4
- package/config/skills/orchestrator/cancel-cron/execute.sh +13 -0
- package/config/skills/orchestrator/create-cron/execute.sh +26 -0
- package/config/skills/orchestrator/list-cron/execute.sh +17 -0
- package/config/skills/orchestrator/schedule-check/execute.sh +46 -7
- package/config/skills/orchestrator/update-cron/execute.sh +16 -0
- package/dist/backend/backend/src/constants.d.ts +2 -0
- package/dist/backend/backend/src/constants.d.ts.map +1 -1
- package/dist/backend/backend/src/controllers/system/cron-task.controller.d.ts +25 -0
- package/dist/backend/backend/src/controllers/system/cron-task.controller.d.ts.map +1 -0
- package/dist/backend/backend/src/controllers/system/cron-task.controller.js +99 -0
- package/dist/backend/backend/src/controllers/system/cron-task.controller.js.map +1 -0
- package/dist/backend/backend/src/routes/api.routes.d.ts.map +1 -1
- package/dist/backend/backend/src/routes/api.routes.js +2 -0
- package/dist/backend/backend/src/routes/api.routes.js.map +1 -1
- package/dist/backend/backend/src/routes/modules/cron-task.routes.d.ts +3 -0
- package/dist/backend/backend/src/routes/modules/cron-task.routes.d.ts.map +1 -0
- package/dist/backend/backend/src/routes/modules/cron-task.routes.js +8 -0
- package/dist/backend/backend/src/routes/modules/cron-task.routes.js.map +1 -0
- package/dist/backend/backend/src/services/agent/agent-registration.service.d.ts +1 -0
- package/dist/backend/backend/src/services/agent/agent-registration.service.d.ts.map +1 -1
- package/dist/backend/backend/src/services/agent/agent-registration.service.js +15 -5
- package/dist/backend/backend/src/services/agent/agent-registration.service.js.map +1 -1
- package/dist/backend/backend/src/services/agent/idle-detection.service.d.ts +8 -0
- package/dist/backend/backend/src/services/agent/idle-detection.service.d.ts.map +1 -1
- package/dist/backend/backend/src/services/agent/idle-detection.service.js +43 -13
- package/dist/backend/backend/src/services/agent/idle-detection.service.js.map +1 -1
- package/dist/backend/backend/src/services/workflow/cron-task.service.d.ts +114 -0
- package/dist/backend/backend/src/services/workflow/cron-task.service.d.ts.map +1 -0
- package/dist/backend/backend/src/services/workflow/cron-task.service.js +303 -0
- package/dist/backend/backend/src/services/workflow/cron-task.service.js.map +1 -0
- package/dist/backend/backend/src/types/cron-task.types.d.ts +63 -0
- package/dist/backend/backend/src/types/cron-task.types.d.ts.map +1 -0
- package/dist/backend/backend/src/types/cron-task.types.js +10 -0
- package/dist/backend/backend/src/types/cron-task.types.js.map +1 -0
- package/dist/backend/config/constants.d.ts +4 -0
- package/dist/backend/config/constants.d.ts.map +1 -1
- package/dist/backend/config/constants.js +4 -0
- package/dist/backend/config/constants.js.map +1 -1
- package/dist/cli/backend/src/constants.d.ts +2 -0
- package/dist/cli/backend/src/constants.d.ts.map +1 -1
- package/dist/cli/config/constants.d.ts +4 -0
- package/dist/cli/config/constants.d.ts.map +1 -1
- package/dist/cli/config/constants.js +4 -0
- package/dist/cli/config/constants.js.map +1 -1
- package/package.json +1 -1
|
@@ -27,9 +27,18 @@ export class IdleDetectionService {
|
|
|
27
27
|
static instance = null;
|
|
28
28
|
logger;
|
|
29
29
|
timer = null;
|
|
30
|
+
agentRegistrationService = null;
|
|
30
31
|
constructor() {
|
|
31
32
|
this.logger = LoggerService.getInstance().createComponentLogger('IdleDetection');
|
|
32
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Inject AgentRegistrationService for auto-stop capability.
|
|
36
|
+
*
|
|
37
|
+
* @param service - AgentRegistrationService instance
|
|
38
|
+
*/
|
|
39
|
+
setAgentRegistrationService(service) {
|
|
40
|
+
this.agentRegistrationService = service;
|
|
41
|
+
}
|
|
33
42
|
/**
|
|
34
43
|
* Get the singleton instance.
|
|
35
44
|
*
|
|
@@ -128,8 +137,8 @@ export class IdleDetectionService {
|
|
|
128
137
|
if (!isActive && !isStarted) {
|
|
129
138
|
continue;
|
|
130
139
|
}
|
|
131
|
-
// Skip
|
|
132
|
-
if (AGENT_SUSPEND_CONSTANTS.
|
|
140
|
+
// Skip always-on roles (orchestrator, auditor)
|
|
141
|
+
if (AGENT_SUSPEND_CONSTANTS.ALWAYS_ON_ROLES.includes(member.role)) {
|
|
133
142
|
continue;
|
|
134
143
|
}
|
|
135
144
|
// Skip agents already being suspended or rehydrated
|
|
@@ -187,20 +196,41 @@ export class IdleDetectionService {
|
|
|
187
196
|
}
|
|
188
197
|
}
|
|
189
198
|
else {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
199
|
+
// Auto-stop: terminate idle agents to free resources
|
|
200
|
+
if (this.agentRegistrationService) {
|
|
201
|
+
this.logger.info('Agent idle timeout reached, stopping', {
|
|
202
|
+
sessionName: member.sessionName,
|
|
203
|
+
role: member.role,
|
|
204
|
+
idleMinutes: effectiveTimeoutMs / 60000,
|
|
205
|
+
agentStatus: member.agentStatus,
|
|
206
|
+
});
|
|
207
|
+
try {
|
|
208
|
+
await this.agentRegistrationService.terminateAgentSession(member.sessionName, member.role);
|
|
209
|
+
await StorageService.getInstance().updateAgentStatus(member.sessionName, CREWLY_CONSTANTS.AGENT_STATUSES.INACTIVE, 'idle_exit');
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
this.logger.error('Failed to stop idle agent', {
|
|
213
|
+
sessionName: member.sessionName,
|
|
214
|
+
error: err instanceof Error ? err.message : String(err),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
198
217
|
}
|
|
199
|
-
|
|
200
|
-
|
|
218
|
+
else {
|
|
219
|
+
// Fallback: suspend if registration service not available
|
|
220
|
+
this.logger.info('Agent idle timeout reached, suspending (no registration service)', {
|
|
201
221
|
sessionName: member.sessionName,
|
|
202
|
-
|
|
222
|
+
role: member.role,
|
|
223
|
+
idleMinutes: effectiveTimeoutMs / 60000,
|
|
203
224
|
});
|
|
225
|
+
try {
|
|
226
|
+
await suspendService.suspendAgent(member.sessionName, team.id, member.id, member.role);
|
|
227
|
+
}
|
|
228
|
+
catch (err) {
|
|
229
|
+
this.logger.error('Failed to suspend idle agent', {
|
|
230
|
+
sessionName: member.sessionName,
|
|
231
|
+
error: err instanceof Error ? err.message : String(err),
|
|
232
|
+
});
|
|
233
|
+
}
|
|
204
234
|
}
|
|
205
235
|
}
|
|
206
236
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idle-detection.service.js","sourceRoot":"","sources":["../../../../../../backend/src/services/agent/idle-detection.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAmB,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"idle-detection.service.js","sourceRoot":"","sources":["../../../../../../backend/src/services/agent/idle-detection.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAmB,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EA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G,CAAC;iCACvD,CAAC,CAAC;4BACJ,CAAC;wBACF,CAAC;6BAAM,CAAC;4BACP,0DAA0D;4BAC1D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kEAAkE,EAAE;gCACpF,WAAW,EAAE,MAAM,CAAC,WAAW;gCAC/B,IAAI,EAAE,MAAM,CAAC,IAAI;gCACjB,WAAW,EAAE,kBAAkB,GAAG,KAAK;6BACvC,CAAC,CAAC;4BAEH,IAAI,CAAC;gCACJ,MAAM,cAAc,CAAC,YAAY,CAChC,MAAM,CAAC,WAAW,EAClB,IAAI,CAAC,EAAE,EACP,MAAM,CAAC,EAAE,EACT,MAAM,CAAC,IAAI,CACX,CAAC;4BACH,CAAC;4BAAC,OAAO,GAAG,EAAE,CAAC;gCACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE;oCACjD,WAAW,EAAE,MAAM,CAAC,WAAW;oCAC/B,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;iCACvD,CAAC,CAAC;4BACJ,CAAC;wBACF,CAAC;oBACF,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cron Task Service
|
|
3
|
+
*
|
|
4
|
+
* Manages user-defined recurring tasks that run on cron schedules.
|
|
5
|
+
* Unlike scheduled messages (agent-created/cancellable), cron tasks
|
|
6
|
+
* can only be cancelled by user or orchestrator.
|
|
7
|
+
*
|
|
8
|
+
* Storage: ~/.crewly/cron-tasks.json
|
|
9
|
+
*
|
|
10
|
+
* @module services/workflow/cron-task.service
|
|
11
|
+
*/
|
|
12
|
+
import type { CronTask, CreateCronTaskRequest, UpdateCronTaskRequest } from '../../types/cron-task.types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Parse a cron expression and calculate the next run time.
|
|
15
|
+
* Supports standard 5-field cron: minute hour day-of-month month day-of-week.
|
|
16
|
+
*
|
|
17
|
+
* @param cronExpression - Standard 5-field cron expression
|
|
18
|
+
* @param timezone - IANA timezone
|
|
19
|
+
* @param after - Calculate next run after this date (defaults to now)
|
|
20
|
+
* @returns ISO string of next run time
|
|
21
|
+
*/
|
|
22
|
+
export declare function getNextRunTime(cronExpression: string, timezone: string, after?: Date): string;
|
|
23
|
+
/**
|
|
24
|
+
* Service for managing cron tasks.
|
|
25
|
+
*/
|
|
26
|
+
export declare class CronTaskService {
|
|
27
|
+
private static instance;
|
|
28
|
+
private logger;
|
|
29
|
+
private storeFile;
|
|
30
|
+
private timer;
|
|
31
|
+
private executionCallback;
|
|
32
|
+
constructor(crewlyHome?: string);
|
|
33
|
+
/**
|
|
34
|
+
* Get singleton instance.
|
|
35
|
+
*/
|
|
36
|
+
static getInstance(): CronTaskService;
|
|
37
|
+
/**
|
|
38
|
+
* Reset singleton (for testing).
|
|
39
|
+
*/
|
|
40
|
+
static resetInstance(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Set the callback invoked when a cron task is due for execution.
|
|
43
|
+
* The callback receives the task and should delegate it to the target agent.
|
|
44
|
+
*
|
|
45
|
+
* @param callback - Async function that executes a cron task
|
|
46
|
+
*/
|
|
47
|
+
setExecutionCallback(callback: (task: CronTask) => Promise<void>): void;
|
|
48
|
+
/**
|
|
49
|
+
* Start the cron task evaluation loop.
|
|
50
|
+
* Checks every minute for tasks whose nextRunAt has passed.
|
|
51
|
+
*/
|
|
52
|
+
start(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Stop the cron task evaluation loop.
|
|
55
|
+
*/
|
|
56
|
+
stop(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the service is running.
|
|
59
|
+
*/
|
|
60
|
+
isRunning(): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Create a new cron task.
|
|
63
|
+
*
|
|
64
|
+
* @param request - Cron task creation parameters
|
|
65
|
+
* @returns The created cron task
|
|
66
|
+
*/
|
|
67
|
+
create(request: CreateCronTaskRequest): Promise<CronTask>;
|
|
68
|
+
/**
|
|
69
|
+
* List all cron tasks, optionally filtered.
|
|
70
|
+
*
|
|
71
|
+
* @param filter - Optional filter criteria
|
|
72
|
+
* @returns Array of matching cron tasks
|
|
73
|
+
*/
|
|
74
|
+
list(filter?: {
|
|
75
|
+
targetAgent?: string;
|
|
76
|
+
enabled?: boolean;
|
|
77
|
+
}): Promise<CronTask[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Get a single cron task by ID.
|
|
80
|
+
*
|
|
81
|
+
* @param id - Cron task ID
|
|
82
|
+
* @returns The cron task or null
|
|
83
|
+
*/
|
|
84
|
+
get(id: string): Promise<CronTask | null>;
|
|
85
|
+
/**
|
|
86
|
+
* Update a cron task. Agents can update description/expression/enabled
|
|
87
|
+
* but cannot delete.
|
|
88
|
+
*
|
|
89
|
+
* @param id - Cron task ID
|
|
90
|
+
* @param updates - Fields to update
|
|
91
|
+
* @returns Updated task or null if not found
|
|
92
|
+
*/
|
|
93
|
+
update(id: string, updates: UpdateCronTaskRequest): Promise<CronTask | null>;
|
|
94
|
+
/**
|
|
95
|
+
* Delete a cron task. Only user/orchestrator should call this.
|
|
96
|
+
*
|
|
97
|
+
* @param id - Cron task ID
|
|
98
|
+
* @returns true if deleted, false if not found
|
|
99
|
+
*/
|
|
100
|
+
delete(id: string): Promise<boolean>;
|
|
101
|
+
/**
|
|
102
|
+
* Evaluate all enabled tasks and execute those whose nextRunAt has passed.
|
|
103
|
+
*/
|
|
104
|
+
evaluateTasks(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Load the cron task store from disk.
|
|
107
|
+
*/
|
|
108
|
+
private loadStore;
|
|
109
|
+
/**
|
|
110
|
+
* Save the cron task store to disk.
|
|
111
|
+
*/
|
|
112
|
+
private saveStore;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=cron-task.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron-task.service.d.ts","sourceRoot":"","sources":["../../../../../../backend/src/services/workflow/cron-task.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,KAAK,EACX,QAAQ,EAER,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,gCAAgC,CAAC;AAOxC;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CA0C7F;AAED;;GAEG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAgC;IACvD,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAA+C;IAC5D,OAAO,CAAC,iBAAiB,CAAoD;gBAEjE,UAAU,CAAC,EAAE,MAAM;IAM/B;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,eAAe;IAOrC;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI,IAAI;IAO5B;;;;;OAKG;IACH,oBAAoB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAIvE;;;OAGG;IACH,KAAK,IAAI,IAAI;IAgBb;;OAEG;IACH,IAAI,IAAI,IAAI;IAQZ;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IA0B/D;;;;;OAKG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAcrF;;;;;OAKG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAK/C;;;;;;;OAOG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAyBlF;;;;;OAKG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAW1C;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAwCpC;;OAEG;YACW,SAAS;IASvB;;OAEG;YACW,SAAS;CAKvB"}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cron Task Service
|
|
3
|
+
*
|
|
4
|
+
* Manages user-defined recurring tasks that run on cron schedules.
|
|
5
|
+
* Unlike scheduled messages (agent-created/cancellable), cron tasks
|
|
6
|
+
* can only be cancelled by user or orchestrator.
|
|
7
|
+
*
|
|
8
|
+
* Storage: ~/.crewly/cron-tasks.json
|
|
9
|
+
*
|
|
10
|
+
* @module services/workflow/cron-task.service
|
|
11
|
+
*/
|
|
12
|
+
import * as os from 'os';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import { readFile, writeFile, mkdir } from 'fs/promises';
|
|
15
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
16
|
+
import { LoggerService } from '../core/logger.service.js';
|
|
17
|
+
/**
|
|
18
|
+
* Check interval for cron task evaluation (60 seconds).
|
|
19
|
+
*/
|
|
20
|
+
const CRON_CHECK_INTERVAL_MS = 60_000;
|
|
21
|
+
/**
|
|
22
|
+
* Parse a cron expression and calculate the next run time.
|
|
23
|
+
* Supports standard 5-field cron: minute hour day-of-month month day-of-week.
|
|
24
|
+
*
|
|
25
|
+
* @param cronExpression - Standard 5-field cron expression
|
|
26
|
+
* @param timezone - IANA timezone
|
|
27
|
+
* @param after - Calculate next run after this date (defaults to now)
|
|
28
|
+
* @returns ISO string of next run time
|
|
29
|
+
*/
|
|
30
|
+
export function getNextRunTime(cronExpression, timezone, after) {
|
|
31
|
+
const now = after || new Date();
|
|
32
|
+
const parts = cronExpression.trim().split(/\s+/);
|
|
33
|
+
if (parts.length !== 5) {
|
|
34
|
+
throw new Error(`Invalid cron expression: expected 5 fields, got ${parts.length}`);
|
|
35
|
+
}
|
|
36
|
+
const [minuteSpec, hourSpec] = parts;
|
|
37
|
+
// Simple implementation: parse minute and hour for common daily/hourly crons
|
|
38
|
+
// For complex expressions, iterate minute-by-minute up to 48 hours
|
|
39
|
+
const minute = minuteSpec === '*' ? -1 : parseInt(minuteSpec, 10);
|
|
40
|
+
const hour = hourSpec === '*' ? -1 : parseInt(hourSpec, 10);
|
|
41
|
+
const candidate = new Date(now.getTime());
|
|
42
|
+
// Advance by 1 minute minimum to avoid re-triggering
|
|
43
|
+
candidate.setSeconds(0, 0);
|
|
44
|
+
candidate.setMinutes(candidate.getMinutes() + 1);
|
|
45
|
+
// Try up to 48 hours of minutes
|
|
46
|
+
for (let i = 0; i < 48 * 60; i++) {
|
|
47
|
+
const m = candidate.getMinutes();
|
|
48
|
+
const h = candidate.getHours();
|
|
49
|
+
const dayOfWeek = candidate.getDay(); // 0=Sun
|
|
50
|
+
const dayOfMonth = candidate.getDate();
|
|
51
|
+
const month = candidate.getMonth() + 1;
|
|
52
|
+
const minuteMatch = minute === -1 || m === minute;
|
|
53
|
+
const hourMatch = hour === -1 || h === hour;
|
|
54
|
+
const domMatch = parts[2] === '*' || parseInt(parts[2], 10) === dayOfMonth;
|
|
55
|
+
const monthMatch = parts[3] === '*' || parseInt(parts[3], 10) === month;
|
|
56
|
+
const dowMatch = parts[4] === '*' || parseInt(parts[4], 10) === dayOfWeek;
|
|
57
|
+
if (minuteMatch && hourMatch && domMatch && monthMatch && dowMatch) {
|
|
58
|
+
return candidate.toISOString();
|
|
59
|
+
}
|
|
60
|
+
candidate.setMinutes(candidate.getMinutes() + 1);
|
|
61
|
+
}
|
|
62
|
+
// Fallback: 24 hours from now
|
|
63
|
+
return new Date(now.getTime() + 24 * 60 * 60 * 1000).toISOString();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Service for managing cron tasks.
|
|
67
|
+
*/
|
|
68
|
+
export class CronTaskService {
|
|
69
|
+
static instance = null;
|
|
70
|
+
logger;
|
|
71
|
+
storeFile;
|
|
72
|
+
timer = null;
|
|
73
|
+
executionCallback = null;
|
|
74
|
+
constructor(crewlyHome) {
|
|
75
|
+
this.logger = LoggerService.getInstance().createComponentLogger('CronTaskService');
|
|
76
|
+
const home = crewlyHome || path.join(os.homedir(), '.crewly');
|
|
77
|
+
this.storeFile = path.join(home, 'cron-tasks.json');
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get singleton instance.
|
|
81
|
+
*/
|
|
82
|
+
static getInstance() {
|
|
83
|
+
if (!CronTaskService.instance) {
|
|
84
|
+
CronTaskService.instance = new CronTaskService();
|
|
85
|
+
}
|
|
86
|
+
return CronTaskService.instance;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Reset singleton (for testing).
|
|
90
|
+
*/
|
|
91
|
+
static resetInstance() {
|
|
92
|
+
if (CronTaskService.instance) {
|
|
93
|
+
CronTaskService.instance.stop();
|
|
94
|
+
}
|
|
95
|
+
CronTaskService.instance = null;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Set the callback invoked when a cron task is due for execution.
|
|
99
|
+
* The callback receives the task and should delegate it to the target agent.
|
|
100
|
+
*
|
|
101
|
+
* @param callback - Async function that executes a cron task
|
|
102
|
+
*/
|
|
103
|
+
setExecutionCallback(callback) {
|
|
104
|
+
this.executionCallback = callback;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Start the cron task evaluation loop.
|
|
108
|
+
* Checks every minute for tasks whose nextRunAt has passed.
|
|
109
|
+
*/
|
|
110
|
+
start() {
|
|
111
|
+
if (this.timer)
|
|
112
|
+
return;
|
|
113
|
+
this.logger.info('Starting cron task service', { intervalMs: CRON_CHECK_INTERVAL_MS });
|
|
114
|
+
this.timer = setInterval(async () => {
|
|
115
|
+
try {
|
|
116
|
+
await this.evaluateTasks();
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
this.logger.error('Cron task evaluation error', {
|
|
120
|
+
error: error instanceof Error ? error.message : String(error),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}, CRON_CHECK_INTERVAL_MS);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Stop the cron task evaluation loop.
|
|
127
|
+
*/
|
|
128
|
+
stop() {
|
|
129
|
+
if (this.timer) {
|
|
130
|
+
clearInterval(this.timer);
|
|
131
|
+
this.timer = null;
|
|
132
|
+
this.logger.info('Stopped cron task service');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Whether the service is running.
|
|
137
|
+
*/
|
|
138
|
+
isRunning() {
|
|
139
|
+
return this.timer !== null;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create a new cron task.
|
|
143
|
+
*
|
|
144
|
+
* @param request - Cron task creation parameters
|
|
145
|
+
* @returns The created cron task
|
|
146
|
+
*/
|
|
147
|
+
async create(request) {
|
|
148
|
+
const timezone = request.timezone || 'UTC';
|
|
149
|
+
const nextRunAt = getNextRunTime(request.cronExpression, timezone);
|
|
150
|
+
const task = {
|
|
151
|
+
id: `cron-${uuidv4().slice(0, 8)}`,
|
|
152
|
+
cronExpression: request.cronExpression,
|
|
153
|
+
timezone,
|
|
154
|
+
targetAgent: request.targetAgent,
|
|
155
|
+
targetTeamId: request.targetTeamId,
|
|
156
|
+
taskDescription: request.taskDescription,
|
|
157
|
+
createdBy: request.createdBy || 'user',
|
|
158
|
+
createdAt: new Date().toISOString(),
|
|
159
|
+
enabled: true,
|
|
160
|
+
lastRunAt: null,
|
|
161
|
+
nextRunAt,
|
|
162
|
+
};
|
|
163
|
+
const store = await this.loadStore();
|
|
164
|
+
store.tasks.push(task);
|
|
165
|
+
await this.saveStore(store);
|
|
166
|
+
this.logger.info('Cron task created', { id: task.id, cron: task.cronExpression, target: task.targetAgent });
|
|
167
|
+
return task;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* List all cron tasks, optionally filtered.
|
|
171
|
+
*
|
|
172
|
+
* @param filter - Optional filter criteria
|
|
173
|
+
* @returns Array of matching cron tasks
|
|
174
|
+
*/
|
|
175
|
+
async list(filter) {
|
|
176
|
+
const store = await this.loadStore();
|
|
177
|
+
let tasks = store.tasks;
|
|
178
|
+
if (filter?.targetAgent) {
|
|
179
|
+
tasks = tasks.filter(t => t.targetAgent === filter.targetAgent);
|
|
180
|
+
}
|
|
181
|
+
if (filter?.enabled !== undefined) {
|
|
182
|
+
tasks = tasks.filter(t => t.enabled === filter.enabled);
|
|
183
|
+
}
|
|
184
|
+
return tasks;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get a single cron task by ID.
|
|
188
|
+
*
|
|
189
|
+
* @param id - Cron task ID
|
|
190
|
+
* @returns The cron task or null
|
|
191
|
+
*/
|
|
192
|
+
async get(id) {
|
|
193
|
+
const store = await this.loadStore();
|
|
194
|
+
return store.tasks.find(t => t.id === id) || null;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Update a cron task. Agents can update description/expression/enabled
|
|
198
|
+
* but cannot delete.
|
|
199
|
+
*
|
|
200
|
+
* @param id - Cron task ID
|
|
201
|
+
* @param updates - Fields to update
|
|
202
|
+
* @returns Updated task or null if not found
|
|
203
|
+
*/
|
|
204
|
+
async update(id, updates) {
|
|
205
|
+
const store = await this.loadStore();
|
|
206
|
+
const task = store.tasks.find(t => t.id === id);
|
|
207
|
+
if (!task)
|
|
208
|
+
return null;
|
|
209
|
+
if (updates.cronExpression !== undefined) {
|
|
210
|
+
task.cronExpression = updates.cronExpression;
|
|
211
|
+
task.nextRunAt = getNextRunTime(updates.cronExpression, task.timezone);
|
|
212
|
+
}
|
|
213
|
+
if (updates.timezone !== undefined) {
|
|
214
|
+
task.timezone = updates.timezone;
|
|
215
|
+
task.nextRunAt = getNextRunTime(task.cronExpression, task.timezone);
|
|
216
|
+
}
|
|
217
|
+
if (updates.taskDescription !== undefined) {
|
|
218
|
+
task.taskDescription = updates.taskDescription;
|
|
219
|
+
}
|
|
220
|
+
if (updates.enabled !== undefined) {
|
|
221
|
+
task.enabled = updates.enabled;
|
|
222
|
+
}
|
|
223
|
+
await this.saveStore(store);
|
|
224
|
+
this.logger.info('Cron task updated', { id, updates: Object.keys(updates) });
|
|
225
|
+
return task;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Delete a cron task. Only user/orchestrator should call this.
|
|
229
|
+
*
|
|
230
|
+
* @param id - Cron task ID
|
|
231
|
+
* @returns true if deleted, false if not found
|
|
232
|
+
*/
|
|
233
|
+
async delete(id) {
|
|
234
|
+
const store = await this.loadStore();
|
|
235
|
+
const index = store.tasks.findIndex(t => t.id === id);
|
|
236
|
+
if (index === -1)
|
|
237
|
+
return false;
|
|
238
|
+
store.tasks.splice(index, 1);
|
|
239
|
+
await this.saveStore(store);
|
|
240
|
+
this.logger.info('Cron task deleted', { id });
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Evaluate all enabled tasks and execute those whose nextRunAt has passed.
|
|
245
|
+
*/
|
|
246
|
+
async evaluateTasks() {
|
|
247
|
+
const store = await this.loadStore();
|
|
248
|
+
const now = new Date();
|
|
249
|
+
let updated = false;
|
|
250
|
+
for (const task of store.tasks) {
|
|
251
|
+
if (!task.enabled || !task.nextRunAt)
|
|
252
|
+
continue;
|
|
253
|
+
const nextRun = new Date(task.nextRunAt);
|
|
254
|
+
if (nextRun > now)
|
|
255
|
+
continue;
|
|
256
|
+
// Task is due — execute it
|
|
257
|
+
this.logger.info('Cron task due, executing', {
|
|
258
|
+
id: task.id,
|
|
259
|
+
target: task.targetAgent,
|
|
260
|
+
nextRunAt: task.nextRunAt,
|
|
261
|
+
});
|
|
262
|
+
try {
|
|
263
|
+
if (this.executionCallback) {
|
|
264
|
+
await this.executionCallback(task);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
this.logger.error('Cron task execution failed', {
|
|
269
|
+
id: task.id,
|
|
270
|
+
error: error instanceof Error ? error.message : String(error),
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
// Update run times regardless of execution success
|
|
274
|
+
task.lastRunAt = now.toISOString();
|
|
275
|
+
task.nextRunAt = getNextRunTime(task.cronExpression, task.timezone, now);
|
|
276
|
+
updated = true;
|
|
277
|
+
}
|
|
278
|
+
if (updated) {
|
|
279
|
+
await this.saveStore(store);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Load the cron task store from disk.
|
|
284
|
+
*/
|
|
285
|
+
async loadStore() {
|
|
286
|
+
try {
|
|
287
|
+
const data = await readFile(this.storeFile, 'utf-8');
|
|
288
|
+
return JSON.parse(data);
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
return { tasks: [] };
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Save the cron task store to disk.
|
|
296
|
+
*/
|
|
297
|
+
async saveStore(store) {
|
|
298
|
+
const dir = path.dirname(this.storeFile);
|
|
299
|
+
await mkdir(dir, { recursive: true });
|
|
300
|
+
await writeFile(this.storeFile, JSON.stringify(store, null, 2), 'utf-8');
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=cron-task.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron-task.service.js","sourceRoot":"","sources":["../../../../../../backend/src/services/workflow/cron-task.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,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C,IAAI,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtC,MAAM,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC1E,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cron Task types — user-defined recurring tasks that agents cannot cancel.
|
|
3
|
+
*
|
|
4
|
+
* Part of the three-layer scheduling model:
|
|
5
|
+
* 1. Scheduled Messages — agent-created, agent-cancellable
|
|
6
|
+
* 2. Cron Tasks — user-created, only user/orchestrator can cancel
|
|
7
|
+
* 3. Heartbeat — reserved for always-on roles (orchestrator/auditor)
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* A cron task definition stored in ~/.crewly/cron-tasks.json.
|
|
11
|
+
*/
|
|
12
|
+
export interface CronTask {
|
|
13
|
+
/** Unique identifier (cron-xxxx) */
|
|
14
|
+
id: string;
|
|
15
|
+
/** Standard cron expression (e.g. "0 9 * * *" = daily at 9am) */
|
|
16
|
+
cronExpression: string;
|
|
17
|
+
/** IANA timezone for cron evaluation (e.g. "Asia/Shanghai") */
|
|
18
|
+
timezone: string;
|
|
19
|
+
/** Target agent session name to receive the task */
|
|
20
|
+
targetAgent: string;
|
|
21
|
+
/** Team ID the target agent belongs to */
|
|
22
|
+
targetTeamId: string;
|
|
23
|
+
/** Task description to send to the agent */
|
|
24
|
+
taskDescription: string;
|
|
25
|
+
/** Who created this cron task */
|
|
26
|
+
createdBy: 'user' | 'orchestrator';
|
|
27
|
+
/** ISO timestamp when created */
|
|
28
|
+
createdAt: string;
|
|
29
|
+
/** Whether this cron task is active */
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
/** ISO timestamp of last execution (null if never run) */
|
|
32
|
+
lastRunAt: string | null;
|
|
33
|
+
/** ISO timestamp of next scheduled run */
|
|
34
|
+
nextRunAt: string | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Storage format for cron-tasks.json.
|
|
38
|
+
*/
|
|
39
|
+
export interface CronTaskStore {
|
|
40
|
+
tasks: CronTask[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Request body for creating a cron task.
|
|
44
|
+
*/
|
|
45
|
+
export interface CreateCronTaskRequest {
|
|
46
|
+
cronExpression: string;
|
|
47
|
+
timezone?: string;
|
|
48
|
+
targetAgent: string;
|
|
49
|
+
targetTeamId: string;
|
|
50
|
+
taskDescription: string;
|
|
51
|
+
createdBy?: 'user' | 'orchestrator';
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Request body for updating a cron task.
|
|
55
|
+
* Agents can update taskDescription and cronExpression but not delete.
|
|
56
|
+
*/
|
|
57
|
+
export interface UpdateCronTaskRequest {
|
|
58
|
+
cronExpression?: string;
|
|
59
|
+
timezone?: string;
|
|
60
|
+
taskDescription?: string;
|
|
61
|
+
enabled?: boolean;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=cron-task.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron-task.types.d.ts","sourceRoot":"","sources":["../../../../../backend/src/types/cron-task.types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,iEAAiE;IACjE,cAAc,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,iCAAiC;IACjC,SAAS,EAAE,MAAM,GAAG,cAAc,CAAC;IACnC,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,0DAA0D;IAC1D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,QAAQ,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACrC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cron Task types — user-defined recurring tasks that agents cannot cancel.
|
|
3
|
+
*
|
|
4
|
+
* Part of the three-layer scheduling model:
|
|
5
|
+
* 1. Scheduled Messages — agent-created, agent-cancellable
|
|
6
|
+
* 2. Cron Tasks — user-created, only user/orchestrator can cancel
|
|
7
|
+
* 3. Heartbeat — reserved for always-on roles (orchestrator/auditor)
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=cron-task.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron-task.types.js","sourceRoot":"","sources":["../../../../../backend/src/types/cron-task.types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -765,6 +765,10 @@ export declare const AGENT_SUSPEND_CONSTANTS: {
|
|
|
765
765
|
readonly EXEMPT_ROLES: readonly ["orchestrator"];
|
|
766
766
|
/** Idle timeout for agents stuck in 'started' status (minutes) */
|
|
767
767
|
readonly STARTED_AGENT_IDLE_TIMEOUT_MINUTES: 15;
|
|
768
|
+
/** Roles that should never be auto-stopped (always-on) */
|
|
769
|
+
readonly ALWAYS_ON_ROLES: readonly ["orchestrator", "auditor"];
|
|
770
|
+
/** Idle timeout in ms before a worker agent is stopped (default 10 min) */
|
|
771
|
+
readonly AGENT_IDLE_STOP_TIMEOUT_MS: 600000;
|
|
768
772
|
};
|
|
769
773
|
/**
|
|
770
774
|
* Server process configuration for Node.js heap sizing and resource management.
|