/**
 * Formatted scheduler operations shared between Agent's public API
 * (TUI/Telegram) and the LLM tool dispatch. Each function returns the
 * user-visible string for one operation so both surfaces produce
 * identical messages.
 */
export function formatTaskList(scheduler) {
    return scheduler.formatTaskList();
}
export function formatAddTask(scheduler, name, cron, prompt, timezone) {
    try {
        const task = scheduler.addTask(name, cron, prompt, timezone);
        const tz = task.timezone ? ` ${task.timezone}` : "";
        return `✓ Task added: [${task.id}] ${task.name} (${task.cron}${tz})`;
    }
    catch (err) {
        return `Error: ${err instanceof Error ? err.message : String(err)}`;
    }
}
export function formatRemoveTask(scheduler, id) {
    return scheduler.removeTask(id)
        ? `✓ Task ${id} removed.`
        : `Task ${id} not found.`;
}
export function formatToggleTask(scheduler, id, enabled) {
    try {
        const task = scheduler.toggleTask(id, enabled);
        return task
            ? `✓ Task ${id} ${enabled ? "enabled" : "disabled"}.`
            : `Task ${id} not found.`;
    }
    catch (err) {
        return `Error: ${err instanceof Error ? err.message : String(err)}`;
    }
}
export function formatUpdateTask(scheduler, id, patch) {
    try {
        const task = scheduler.updateTask(id, patch);
        if (!task)
            return `Task ${id} not found.`;
        const changed = Object.entries(patch)
            .filter(([, v]) => v !== undefined)
            .map(([k]) => k)
            .join(", ") || "(nothing)";
        const tz = task.timezone ? ` ${task.timezone}` : "";
        return `✓ Task ${id} updated (${changed}): ${task.name} | ${task.cron}${tz}`;
    }
    catch (err) {
        return `Error: ${err instanceof Error ? err.message : String(err)}`;
    }
}
export function executeSchedulerAction(scheduler, action, args) {
    switch (action) {
        case "list":
            return formatTaskList(scheduler);
        case "add":
            return formatAddTask(scheduler, args.name, args.cron, args.prompt, args.timezone);
        case "update":
            return formatUpdateTask(scheduler, args.id, {
                name: args.name,
                cron: args.cron,
                prompt: args.prompt,
                timezone: args.timezone,
                enabled: args.enabled,
                storagePolicyMode: args.storagePolicyMode,
            });
        case "remove":
            return formatRemoveTask(scheduler, args.id);
        case "toggle":
            return formatToggleTask(scheduler, args.id, args.enabled);
        default:
            return `Unknown scheduler action: ${action}`;
    }
}
//# sourceMappingURL=scheduler-executor.js.map