Files
cobble/src/harness/tools/bot/delete-schedule-tool.ts
T
tbenandClaude Opus 5.5 c44048dbab Add bot schedules (routines), open Activity, add Help and a Desktop computer view
Bots create, list, update and delete schedules (cron_jobs, Bun.cron in UTC);
a per-minute cron queues due runs as tasks. Routines, Activity (super admins)
and Help get their own rail aside. Help covers familiar problems, starting
with signing in to Google through Cookie-Editor over the new Desktop (noVNC)
view.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 10:52:32 +01:00

31 lines
940 B
TypeScript

import { z } from "zod";
import deleteCronJob from "@/src/functions/backend/db/cron-jobs/delete-cron-job";
import type { HarnessTool } from "../../types";
type Params = {
user_id: number | string;
bot_id: number | string;
};
type Args = {
schedule_id: number;
};
/**
* Lets a bot delete one of its own schedules.
*/
export default function deleteScheduleTool({ user_id, bot_id }: Params): HarnessTool<Args> {
return {
name: "delete_schedule",
description: `Delete one of your schedules for good (ids from list_schedules). To stop it for a while, pause it with update_schedule instead.`,
schema: z.object({
schedule_id: z.number().int(),
}),
run: async ({ args }) => {
const cron_job = await deleteCronJob({ user_id, bot_id, cron_job_id: args.schedule_id });
return `Schedule #${cron_job.id} "${cron_job.title}" deleted.`;
},
};
}