mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:41:23 +00:00
- Added support for new delivery modes in cron jobs: `announce`, `deliver`, and `none`. - Updated documentation to reflect changes in delivery options and usage examples. - Enhanced the cron job schema to include delivery configuration. - Refactored related CLI commands and UI components to accommodate the new delivery settings. - Improved handling of legacy delivery fields for backward compatibility. This update allows users to choose how output from isolated jobs is delivered, enhancing flexibility in job management.
108 lines
2.8 KiB
TypeScript
108 lines
2.8 KiB
TypeScript
import type { ChannelId } from "../channels/plugins/types.js";
|
|
|
|
export type CronSchedule =
|
|
| { kind: "at"; atMs: number }
|
|
| { kind: "every"; everyMs: number; anchorMs?: number }
|
|
| { kind: "cron"; expr: string; tz?: string };
|
|
|
|
export type CronSessionTarget = "main" | "isolated";
|
|
export type CronWakeMode = "next-heartbeat" | "now";
|
|
|
|
export type CronMessageChannel = ChannelId | "last";
|
|
|
|
export type CronDeliveryMode = "none" | "announce" | "deliver";
|
|
|
|
export type CronDelivery = {
|
|
mode: CronDeliveryMode;
|
|
channel?: CronMessageChannel;
|
|
to?: string;
|
|
bestEffort?: boolean;
|
|
};
|
|
|
|
export type CronDeliveryPatch = Partial<CronDelivery>;
|
|
|
|
export type CronPayload =
|
|
| { kind: "systemEvent"; text: string }
|
|
| {
|
|
kind: "agentTurn";
|
|
message: string;
|
|
/** Optional model override (provider/model or alias). */
|
|
model?: string;
|
|
thinking?: string;
|
|
timeoutSeconds?: number;
|
|
allowUnsafeExternalContent?: boolean;
|
|
deliver?: boolean;
|
|
channel?: CronMessageChannel;
|
|
to?: string;
|
|
bestEffortDeliver?: boolean;
|
|
};
|
|
|
|
export type CronPayloadPatch =
|
|
| { kind: "systemEvent"; text?: string }
|
|
| {
|
|
kind: "agentTurn";
|
|
message?: string;
|
|
model?: string;
|
|
thinking?: string;
|
|
timeoutSeconds?: number;
|
|
allowUnsafeExternalContent?: boolean;
|
|
deliver?: boolean;
|
|
channel?: CronMessageChannel;
|
|
to?: string;
|
|
bestEffortDeliver?: boolean;
|
|
};
|
|
|
|
export type CronIsolation = {
|
|
postToMainPrefix?: string;
|
|
/**
|
|
* What to post back into the main session after an isolated run.
|
|
* - summary: small status/summary line (default)
|
|
* - full: the agent's final text output (optionally truncated)
|
|
*/
|
|
postToMainMode?: "summary" | "full";
|
|
/** Max chars when postToMainMode="full". Default: 8000. */
|
|
postToMainMaxChars?: number;
|
|
};
|
|
|
|
export type CronJobState = {
|
|
nextRunAtMs?: number;
|
|
runningAtMs?: number;
|
|
lastRunAtMs?: number;
|
|
lastStatus?: "ok" | "error" | "skipped";
|
|
lastError?: string;
|
|
lastDurationMs?: number;
|
|
};
|
|
|
|
export type CronJob = {
|
|
id: string;
|
|
agentId?: string;
|
|
name: string;
|
|
description?: string;
|
|
enabled: boolean;
|
|
deleteAfterRun?: boolean;
|
|
createdAtMs: number;
|
|
updatedAtMs: number;
|
|
schedule: CronSchedule;
|
|
sessionTarget: CronSessionTarget;
|
|
wakeMode: CronWakeMode;
|
|
payload: CronPayload;
|
|
delivery?: CronDelivery;
|
|
isolation?: CronIsolation;
|
|
state: CronJobState;
|
|
};
|
|
|
|
export type CronStoreFile = {
|
|
version: 1;
|
|
jobs: CronJob[];
|
|
};
|
|
|
|
export type CronJobCreate = Omit<CronJob, "id" | "createdAtMs" | "updatedAtMs" | "state"> & {
|
|
state?: Partial<CronJobState>;
|
|
};
|
|
|
|
export type CronJobPatch = Partial<Omit<CronJob, "id" | "createdAtMs" | "state" | "payload">> & {
|
|
payload?: CronPayloadPatch;
|
|
delivery?: CronDeliveryPatch;
|
|
state?: Partial<CronJobState>;
|
|
};
|