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]>
28 lines
983 B
TypeScript
28 lines
983 B
TypeScript
import { z } from "zod";
|
|
import grabCronJobs from "@/src/functions/backend/db/cron-jobs/grab-cron-jobs";
|
|
import describeCronJob from "@/src/utils/describe-cron-job";
|
|
import type { HarnessTool } from "../../types";
|
|
|
|
type Params = {
|
|
user_id: number | string;
|
|
bot_id: number | string;
|
|
};
|
|
|
|
/**
|
|
* Lets a bot see its own schedules, everywhere it works.
|
|
*/
|
|
export default function listSchedulesTool({ user_id, bot_id }: Params): HarnessTool<Record<string, never>> {
|
|
return {
|
|
name: "list_schedules",
|
|
description: `List your schedules (routines): id, cron expression (UTC), where each runs, whether it's paused, its next run and its last error.`,
|
|
schema: z.object({}),
|
|
run: async () => {
|
|
const cron_jobs = await grabCronJobs({ user_id, bot_id });
|
|
|
|
if (!cron_jobs.length) return `You have no schedules.`;
|
|
|
|
return cron_jobs.map((cron_job) => `- ${describeCronJob({ cron_job })}`).join("\n");
|
|
},
|
|
};
|
|
}
|