|
| 1 | +/** |
| 2 | + * Calendar and Event Tools |
| 3 | + * |
| 4 | + * Tools for managing calendar events, scheduling meetings, and checking availability. |
| 5 | + * Demonstrates temporal data and scheduling operations. |
| 6 | + */ |
| 7 | + |
| 8 | +import { tool } from "../../src/schema"; |
| 9 | +import { z } from "zod"; |
| 10 | + |
| 11 | +export const createEventTool = tool({ |
| 12 | + name: "create_calendar_event", |
| 13 | + description: "Create a new calendar event", |
| 14 | + parameters: z.object({ |
| 15 | + title: z.string().describe("Event title"), |
| 16 | + start_time: z.string().describe("Event start time (ISO datetime)"), |
| 17 | + end_time: z.string().describe("Event end time (ISO datetime)"), |
| 18 | + description: z.string().optional().describe("Event description"), |
| 19 | + location: z.string().optional().describe("Event location"), |
| 20 | + attendees: z |
| 21 | + .array(z.string().email()) |
| 22 | + .optional() |
| 23 | + .describe("Email addresses of attendees"), |
| 24 | + reminder_minutes: z |
| 25 | + .number() |
| 26 | + .int() |
| 27 | + .optional() |
| 28 | + .describe("Minutes before event to send reminder"), |
| 29 | + recurrence: z |
| 30 | + .enum(["none", "daily", "weekly", "monthly"]) |
| 31 | + .default("none") |
| 32 | + .optional(), |
| 33 | + }), |
| 34 | + output: z.object({ |
| 35 | + event_id: z.string().describe("Unique event identifier"), |
| 36 | + created_at: z.string(), |
| 37 | + calendar_link: z.string().url().optional(), |
| 38 | + status: z.enum(["created", "error"]), |
| 39 | + }), |
| 40 | +}); |
| 41 | + |
| 42 | +export const checkAvailabilityTool = tool({ |
| 43 | + name: "check_availability", |
| 44 | + description: "Check calendar availability for specific time slots", |
| 45 | + parameters: z.object({ |
| 46 | + start_date: z.string().describe("Start date to check (YYYY-MM-DD)"), |
| 47 | + end_date: z.string().describe("End date to check (YYYY-MM-DD)"), |
| 48 | + attendees: z |
| 49 | + .array(z.string().email()) |
| 50 | + .optional() |
| 51 | + .describe("Check availability for these attendees"), |
| 52 | + duration_minutes: z |
| 53 | + .number() |
| 54 | + .int() |
| 55 | + .min(15) |
| 56 | + .optional() |
| 57 | + .describe("Desired meeting duration"), |
| 58 | + }), |
| 59 | + output: z.object({ |
| 60 | + available_slots: z.array( |
| 61 | + z.object({ |
| 62 | + start_time: z.string(), |
| 63 | + end_time: z.string(), |
| 64 | + all_attendees_free: z.boolean().optional(), |
| 65 | + }) |
| 66 | + ), |
| 67 | + busy_slots: z |
| 68 | + .array( |
| 69 | + z.object({ |
| 70 | + start_time: z.string(), |
| 71 | + end_time: z.string(), |
| 72 | + reason: z.string().optional(), |
| 73 | + }) |
| 74 | + ) |
| 75 | + .optional(), |
| 76 | + }), |
| 77 | +}); |
| 78 | + |
| 79 | +export const listEventsTool = tool({ |
| 80 | + name: "list_calendar_events", |
| 81 | + description: "List calendar events within a date range", |
| 82 | + parameters: z.object({ |
| 83 | + start_date: z.string().describe("Start date (YYYY-MM-DD)"), |
| 84 | + end_date: z.string().describe("End date (YYYY-MM-DD)"), |
| 85 | + calendar_id: z |
| 86 | + .string() |
| 87 | + .optional() |
| 88 | + .describe("Specific calendar ID to query"), |
| 89 | + search: z.string().optional().describe("Search term to filter events"), |
| 90 | + }), |
| 91 | + output: z.object({ |
| 92 | + events: z.array( |
| 93 | + z.object({ |
| 94 | + event_id: z.string(), |
| 95 | + title: z.string(), |
| 96 | + start_time: z.string(), |
| 97 | + end_time: z.string(), |
| 98 | + location: z.string().optional(), |
| 99 | + attendees_count: z.number().int().optional(), |
| 100 | + status: z.enum(["confirmed", "tentative", "cancelled"]).optional(), |
| 101 | + }) |
| 102 | + ), |
| 103 | + total_count: z.number().int(), |
| 104 | + }), |
| 105 | +}); |
| 106 | + |
| 107 | +export const updateEventTool = tool({ |
| 108 | + name: "update_calendar_event", |
| 109 | + description: "Update an existing calendar event", |
| 110 | + parameters: z.object({ |
| 111 | + event_id: z.string().describe("Event ID to update"), |
| 112 | + title: z.string().optional().describe("New event title"), |
| 113 | + start_time: z.string().optional().describe("New start time"), |
| 114 | + end_time: z.string().optional().describe("New end time"), |
| 115 | + description: z.string().optional(), |
| 116 | + location: z.string().optional(), |
| 117 | + status: z.enum(["confirmed", "tentative", "cancelled"]).optional(), |
| 118 | + }), |
| 119 | + output: z.object({ |
| 120 | + event_id: z.string(), |
| 121 | + updated_at: z.string(), |
| 122 | + status: z.enum(["updated", "not_found", "error"]), |
| 123 | + notification_sent: z.boolean().optional(), |
| 124 | + }), |
| 125 | +}); |
| 126 | + |
| 127 | +export const deleteEventTool = tool({ |
| 128 | + name: "delete_calendar_event", |
| 129 | + description: "Delete a calendar event", |
| 130 | + parameters: z.object({ |
| 131 | + event_id: z.string().describe("Event ID to delete"), |
| 132 | + notify_attendees: z |
| 133 | + .boolean() |
| 134 | + .default(true) |
| 135 | + .optional() |
| 136 | + .describe("Send cancellation notice to attendees"), |
| 137 | + cancellation_message: z |
| 138 | + .string() |
| 139 | + .optional() |
| 140 | + .describe("Optional message to include in cancellation notice"), |
| 141 | + }), |
| 142 | + output: z.object({ |
| 143 | + event_id: z.string(), |
| 144 | + status: z.enum(["deleted", "not_found", "error"]), |
| 145 | + attendees_notified: z.number().int().optional(), |
| 146 | + }), |
| 147 | +}); |
| 148 | + |
0 commit comments