import { ToolPlugin, ToolResult, ToolContext } from "./types.js"; import { CRON_DELETE_TOOL_NAME } from "../constants/tools.js"; const CRON_DELETE_DESCRIPTION = "Cancel a scheduled cron job by ID"; const CRON_DELETE_PROMPT = `Cancel a cron job previously scheduled with CronCreate. Removes it from both the in-memory session store and durable file storage (if applicable).`; export const cronDeleteTool: ToolPlugin = { name: CRON_DELETE_TOOL_NAME, config: { type: "function", function: { name: CRON_DELETE_TOOL_NAME, description: CRON_DELETE_DESCRIPTION, parameters: { type: "object", properties: { id: { type: "string", description: "Job ID returned by CronCreate", }, }, required: ["id"], }, }, }, prompt: () => CRON_DELETE_PROMPT, execute: async ( args: Record, context: ToolContext, ): Promise => { const { id } = args as { id: string }; if (!context.cronManager) { return { success: false, content: "", error: "CronManager not available", }; } const success = context.cronManager.deleteJob(id); return { success, content: JSON.stringify({ success }, null, 2), shortResult: success ? `Deleted job ${id}` : `Job ${id} not found`, error: success ? undefined : `Job ${id} not found`, }; }, };