mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:18:25 +00:00
feat(cron): enhance delivery modes and job configuration
- Updated isolated cron jobs to support new delivery modes: `announce` and `none`, improving output management. - Refactored job configuration to remove legacy fields and streamline delivery settings. - Enhanced the `CronJobEditor` UI to reflect changes in delivery options, including a new segmented control for delivery mode selection. - Updated documentation to clarify the new delivery configurations and their implications for job execution. - Improved tests to validate the new delivery behavior and ensure backward compatibility with legacy settings. This update provides users with greater flexibility in managing how isolated jobs deliver their outputs, enhancing overall usability and clarity in job configurations.
This commit is contained in:
committed by
Peter Steinberger
parent
ab9f06f4ff
commit
3f82daefd8
@@ -1,4 +1,5 @@
|
||||
import type { CronSchedule } from "./types.js";
|
||||
import { parseAbsoluteTimeMs } from "./parse.js";
|
||||
|
||||
const ONE_MINUTE_MS = 60 * 1000;
|
||||
const TEN_YEARS_MS = 10 * 365.25 * 24 * 60 * 60 * 1000;
|
||||
@@ -15,7 +16,7 @@ export type TimestampValidationSuccess = {
|
||||
export type TimestampValidationResult = TimestampValidationSuccess | TimestampValidationError;
|
||||
|
||||
/**
|
||||
* Validates atMs timestamps in cron schedules.
|
||||
* Validates at timestamps in cron schedules.
|
||||
* Rejects timestamps that are:
|
||||
* - More than 1 minute in the past
|
||||
* - More than 10 years in the future
|
||||
@@ -28,12 +29,13 @@ export function validateScheduleTimestamp(
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
const atMs = schedule.atMs;
|
||||
const atRaw = typeof schedule.at === "string" ? schedule.at.trim() : "";
|
||||
const atMs = atRaw ? parseAbsoluteTimeMs(atRaw) : null;
|
||||
|
||||
if (typeof atMs !== "number" || !Number.isFinite(atMs)) {
|
||||
if (atMs === null || !Number.isFinite(atMs)) {
|
||||
return {
|
||||
ok: false,
|
||||
message: `Invalid atMs: must be a finite number (got ${String(atMs)})`,
|
||||
message: `Invalid schedule.at: expected ISO-8601 timestamp (got ${String(schedule.at)})`,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,7 +48,7 @@ export function validateScheduleTimestamp(
|
||||
const minutesAgo = Math.floor(-diffMs / ONE_MINUTE_MS);
|
||||
return {
|
||||
ok: false,
|
||||
message: `atMs is in the past: ${atDate} (${minutesAgo} minutes ago). Current time: ${nowDate}`,
|
||||
message: `schedule.at is in the past: ${atDate} (${minutesAgo} minutes ago). Current time: ${nowDate}`,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -56,7 +58,7 @@ export function validateScheduleTimestamp(
|
||||
const yearsAhead = Math.floor(diffMs / (365.25 * 24 * 60 * 60 * 1000));
|
||||
return {
|
||||
ok: false,
|
||||
message: `atMs is too far in the future: ${atDate} (${yearsAhead} years ahead). Maximum allowed: 10 years`,
|
||||
message: `schedule.at is too far in the future: ${atDate} (${yearsAhead} years ahead). Maximum allowed: 10 years`,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user