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
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Parse duration string to milliseconds.
|
||||
* Supports formats like: 5m, 30s, 1h, 2h30m, 90, etc.
|
||||
* Supports formats like: 5m, 30s, 1h, 2h30m, 1d, 90, etc.
|
||||
* If no unit is specified, assumes seconds.
|
||||
*/
|
||||
export function parseDuration(input: string): number {
|
||||
@@ -11,14 +11,16 @@ export function parseDuration(input: string): number {
|
||||
return parseInt(trimmed, 10) * 1000;
|
||||
}
|
||||
|
||||
if (!/^(?:\d+[smhd])+$/.test(trimmed)) {
|
||||
throw new Error(`Invalid duration format: ${input}. Use formats like: 5m, 30s, 1h, 2h30m, 1d`);
|
||||
}
|
||||
|
||||
// Parse duration with units
|
||||
let totalMs = 0;
|
||||
const regex = /(\d+)([smh])/g;
|
||||
const regex = /(\d+)([smhd])/g;
|
||||
let match;
|
||||
let hasMatch = false;
|
||||
|
||||
while ((match = regex.exec(trimmed)) !== null) {
|
||||
hasMatch = true;
|
||||
const value = parseInt(match[1], 10);
|
||||
const unit = match[2];
|
||||
|
||||
@@ -32,12 +34,11 @@ export function parseDuration(input: string): number {
|
||||
case "h":
|
||||
totalMs += value * 60 * 60 * 1000;
|
||||
break;
|
||||
case "d":
|
||||
totalMs += value * 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasMatch) {
|
||||
throw new Error(`Invalid duration format: ${input}. Use formats like: 5m, 30s, 1h, 2h30m`);
|
||||
}
|
||||
|
||||
return totalMs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user