mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
3acc168c4f
* fix(cron): persist explicit scheduled tool authority * test(cron): cover explicit scheduled authority * fix(cron): preserve legacy authority on routine edits * test(cron): add explicit authority e2e matrix * test(cron): harden explicit authority live proof
20 lines
688 B
TypeScript
20 lines
688 B
TypeScript
import type { CronJob } from "./types.js";
|
|
|
|
type CronToolRuntimeSpec = Pick<CronJob, "payload" | "trigger">;
|
|
|
|
/** Returns whether a cron job can construct or execute OpenClaw agent tools. */
|
|
export function cronJobUsesToolRuntime(job: CronToolRuntimeSpec): boolean {
|
|
return (
|
|
job.payload.kind === "agentTurn" ||
|
|
job.payload.kind === "script" ||
|
|
Boolean(job.trigger?.script.trim())
|
|
);
|
|
}
|
|
|
|
/** Stamps an explicit unrestricted cap without changing jobs that already carry one. */
|
|
export function applyDefaultCronToolsAllow(job: CronToolRuntimeSpec): void {
|
|
if (cronJobUsesToolRuntime(job) && job.payload.toolsAllow === undefined) {
|
|
job.payload.toolsAllow = ["*"];
|
|
}
|
|
}
|