fix(agentrun): bound events timeout to 60m

This commit is contained in:
Codex
2026-07-15 06:08:41 +02:00
parent 968ffa3ecf
commit 82b48a00fa
2 changed files with 25 additions and 5 deletions
+4 -4
View File
@@ -360,12 +360,12 @@ function parsePositiveInt(raw: string | null, flag: string): number {
export function parseDurationMs(raw: string | null, flag: string): number {
if (raw === null || raw.length === 0) throw new Error(`${flag} requires a duration`);
const match = /^(\d+)(ms|s|m|h)$/u.exec(raw.trim());
if (match === null) throw new Error(`${flag} must use an integer duration such as 500ms, 120s, 3m, or 1h`);
const match = /^(\d+)(ms|s|m)$/u.exec(raw.trim());
if (match === null) throw new Error(`${flag} must use a positive integer duration with ms, s, or m units, such as 500ms, 120s, or 3m`);
const amount = Number(match[1]);
const multiplier = match[2] === "ms" ? 1 : match[2] === "s" ? 1_000 : match[2] === "m" ? 60_000 : 3_600_000;
const multiplier = match[2] === "ms" ? 1 : match[2] === "s" ? 1_000 : 60_000;
const value = amount * multiplier;
if (!Number.isSafeInteger(value) || value < 1 || value > 86_400_000) throw new Error(`${flag} must be between 1ms and 24h`);
if (!Number.isSafeInteger(value) || value < 1 || value > 3_600_000) throw new Error(`${flag} must be between 1ms and 60m`);
return value;
}