Files
paseo/packages/protocol/src/schedule/cadence.ts
T
Mohamed BoudraandGitHub ffe76a7e57 Make workspace, agent, and schedule automation consistent (#2186)
* feat(workspaces): align agent and schedule automation

Make workspace identity the shared placement boundary for MCP and CLI, while caller identity determines parentage. Keep heartbeats minimal and cron-based without changing legacy rolling interval semantics.

* test(cli): expect canonical schedule cadence

* fix(automation): preserve workspace and schedule compatibility

* fix(automation): preserve compatibility edges

* fix(workspaces): align MCP lifecycle resolution

* fix(workspaces): preserve creation intent

* fix(workspaces): preserve branch and schedule identity
2026-07-18 14:04:48 +02:00

28 lines
702 B
TypeScript

/**
* Convert an exact rolling interval to an equivalent five-field cron cadence.
* Returns null when cron's calendar boundaries would change the interval.
*/
export function everyMsToFiveFieldCron(everyMs: number): string | null {
const minutes = everyMs / 60_000;
if (!Number.isInteger(minutes) || minutes <= 0) {
return null;
}
if (minutes < 60 && 60 % minutes === 0) {
return `*/${minutes} * * * *`;
}
if (minutes === 60) {
return "0 * * * *";
}
if (minutes % 60 !== 0) {
return null;
}
const hours = minutes / 60;
if (hours < 24 && 24 % hours === 0) {
return `0 */${hours} * * *`;
}
if (hours === 24) {
return "0 0 * * *";
}
return null;
}