Files
openclaw/src/cron/tools-allow.ts
T
Josh Avant 3acc168c4f fix(cron): persist explicit scheduled tool authority (#112483)
* 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
2026-07-22 02:28:49 -05:00

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 = ["*"];
}
}