mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:48:26 +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
@@ -80,12 +80,7 @@ export async function executeJob(
|
||||
|
||||
let deleted = false;
|
||||
|
||||
const finish = async (
|
||||
status: "ok" | "error" | "skipped",
|
||||
err?: string,
|
||||
summary?: string,
|
||||
outputText?: string,
|
||||
) => {
|
||||
const finish = async (status: "ok" | "error" | "skipped", err?: string, summary?: string) => {
|
||||
const endedAt = state.deps.nowMs();
|
||||
job.state.runningAtMs = undefined;
|
||||
job.state.lastRunAtMs = startedAt;
|
||||
@@ -124,30 +119,6 @@ export async function executeJob(
|
||||
deleted = true;
|
||||
emit(state, { jobId: job.id, action: "removed" });
|
||||
}
|
||||
|
||||
if (job.sessionTarget === "isolated" && !job.delivery) {
|
||||
const prefix = job.isolation?.postToMainPrefix?.trim() || "Cron";
|
||||
const mode = job.isolation?.postToMainMode ?? "summary";
|
||||
|
||||
let body = (summary ?? err ?? status).trim();
|
||||
if (mode === "full") {
|
||||
// Prefer full agent output if available; fall back to summary.
|
||||
const maxCharsRaw = job.isolation?.postToMainMaxChars;
|
||||
const maxChars = Number.isFinite(maxCharsRaw) ? Math.max(0, maxCharsRaw as number) : 8000;
|
||||
const fullText = (outputText ?? "").trim();
|
||||
if (fullText) {
|
||||
body = fullText.length > maxChars ? `${fullText.slice(0, maxChars)}…` : fullText;
|
||||
}
|
||||
}
|
||||
|
||||
const statusPrefix = status === "ok" ? prefix : `${prefix} (${status})`;
|
||||
state.deps.enqueueSystemEvent(`${statusPrefix}: ${body}`, {
|
||||
agentId: job.agentId,
|
||||
});
|
||||
if (job.wakeMode === "now") {
|
||||
state.deps.requestHeartbeatNow({ reason: `cron:${job.id}:post` });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -214,11 +185,11 @@ export async function executeJob(
|
||||
message: job.payload.message,
|
||||
});
|
||||
if (res.status === "ok") {
|
||||
await finish("ok", undefined, res.summary, res.outputText);
|
||||
await finish("ok", undefined, res.summary);
|
||||
} else if (res.status === "skipped") {
|
||||
await finish("skipped", undefined, res.summary, res.outputText);
|
||||
await finish("skipped", undefined, res.summary);
|
||||
} else {
|
||||
await finish("error", res.error ?? "cron job failed", res.summary, res.outputText);
|
||||
await finish("error", res.error ?? "cron job failed", res.summary);
|
||||
}
|
||||
} catch (err) {
|
||||
await finish("error", String(err));
|
||||
|
||||
Reference in New Issue
Block a user