@chronary/toolkit 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mastra.js CHANGED
@@ -25,6 +25,7 @@ var WEBHOOK_EVENT_TYPES = [
25
25
  ];
26
26
  var WEBHOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed"];
27
27
  var ListCalendarsSchema = z.object({
28
+ agent_id: z.string().optional().describe("Filter to calendars owned by this agent. Org keys only \u2014 agent-scoped keys are always limited to their own agent and ignore this."),
28
29
  include: z.enum(["all"]).optional().describe('Pass "all" to include calendars across all agents (org keys only)'),
29
30
  limit: z.number().int().min(1).max(200).default(50).describe("Max results to return"),
30
31
  offset: z.number().int().min(0).default(0).describe("Pagination offset")
@@ -50,15 +51,18 @@ var DeleteCalendarSchema = z.object({
50
51
  calendar_id: z.string().describe("Calendar ID to delete")
51
52
  });
52
53
  var ListEventsSchema = z.object({
53
- calendar_id: z.string().describe("Calendar ID to list events from"),
54
- start_after: z.string().datetime().optional().describe("Filter events starting after this time"),
55
- start_before: z.string().datetime().optional().describe("Filter events starting before this time"),
54
+ calendar_id: z.string().optional().describe("Calendar ID to list events from. Provide this or agent_id."),
55
+ agent_id: z.string().optional().describe("Agent ID to list events for across all of the agent's calendars. Provide this or calendar_id."),
56
+ start_after: z.string().datetime().optional().describe("Only events starting after this ISO 8601 time"),
57
+ start_before: z.string().datetime().optional().describe("Only events starting before this ISO 8601 time"),
58
+ status: z.enum(["confirmed", "tentative", "cancelled", "hold"]).optional().describe("Filter by event status"),
59
+ source: z.enum(["internal", "external_ical"]).optional().describe('Filter by source: "internal" (created via the API) or "external_ical" (synced from an iCal subscription)'),
56
60
  limit: z.number().int().min(1).max(200).default(50).describe("Max results to return"),
57
61
  offset: z.number().int().min(0).default(0).describe("Pagination offset")
58
62
  });
59
63
  var GetEventSchema = z.object({
60
64
  event_id: z.string().describe("Event ID to retrieve"),
61
- calendar_id: z.string().describe("Calendar ID that owns the event. Required \u2014 the SDK is calendar-scoped (unlike the hosted MCP, which can resolve the calendar from event_id).")
65
+ calendar_id: z.string().optional().describe("Calendar ID that owns the event. Optional \u2014 if omitted the calendar is resolved from the event.")
62
66
  });
63
67
  var CreateEventSchema = z.object({
64
68
  calendar_id: z.string().describe("Calendar ID to add the event to"),
@@ -74,7 +78,7 @@ var CreateEventSchema = z.object({
74
78
  });
75
79
  var UpdateEventSchema = z.object({
76
80
  event_id: z.string().describe("Event ID to update"),
77
- calendar_id: z.string().describe("Calendar ID that owns the event. Required \u2014 the SDK is calendar-scoped (unlike the hosted MCP, which can resolve the calendar from event_id)."),
81
+ calendar_id: z.string().optional().describe("Calendar ID that owns the event. Optional \u2014 if omitted the calendar is resolved from the event."),
78
82
  title: z.string().min(1).max(500).optional().describe("New event title"),
79
83
  description: z.string().nullable().optional().describe("New description, or null to clear it"),
80
84
  start_time: z.string().datetime().optional().describe("New start time (ISO 8601)"),
@@ -86,7 +90,7 @@ var UpdateEventSchema = z.object({
86
90
  });
87
91
  var CancelEventSchema = z.object({
88
92
  event_id: z.string().describe("Event ID to cancel"),
89
- calendar_id: z.string().describe("Calendar ID that owns the event. Required \u2014 the SDK is calendar-scoped (unlike the hosted MCP, which can resolve the calendar from event_id).")
93
+ calendar_id: z.string().optional().describe("Calendar ID that owns the event. Optional \u2014 if omitted the calendar is resolved from the event. Matches the asymmetry with confirm_event / release_event which never required this arg.")
90
94
  });
91
95
  var ConfirmEventSchema = z.object({
92
96
  event_id: z.string().describe("Event ID of the hold to confirm")
@@ -183,7 +187,7 @@ var timeOfDay = z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "must be HH:MM in
183
187
  var workingHoursDaySchema = z.object({
184
188
  start: timeOfDay,
185
189
  end: timeOfDay
186
- });
190
+ }).refine((v) => v.end > v.start, "end must be after start").describe("A single day's working hours window");
187
191
  var workingHoursSchema = z.object({
188
192
  mon: workingHoursDaySchema.optional(),
189
193
  tue: workingHoursDaySchema.optional(),
@@ -192,7 +196,7 @@ var workingHoursSchema = z.object({
192
196
  fri: workingHoursDaySchema.optional(),
193
197
  sat: workingHoursDaySchema.optional(),
194
198
  sun: workingHoursDaySchema.optional()
195
- }).nullable();
199
+ }).refine((v) => Object.keys(v).length > 0, "at least one day must be specified").nullable();
196
200
  var SetAvailabilityRulesSchema = z.object({
197
201
  calendar_id: z.string().describe("Calendar to configure"),
198
202
  buffer_before_minutes: z.number().int().min(0).max(120).default(0).describe("Minutes of buffer before each event (0\u2013120)"),
@@ -306,7 +310,7 @@ async function fetchPage(iterator, offset, limit) {
306
310
  }
307
311
  var listCalendars = safeFunc(async (ctx) => {
308
312
  const { client, params } = ctx;
309
- const iter = client.calendars.list({ include: params.include, limit: params.limit });
313
+ const iter = client.calendars.list({ agentId: params.agent_id, include: params.include, limit: params.limit });
310
314
  return fetchPage(iter, params.offset, params.limit);
311
315
  });
312
316
  var getCalendar = safeFunc(async (ctx) => {
@@ -333,16 +337,23 @@ var deleteCalendar = safeFunc(async (ctx) => {
333
337
  });
334
338
  var listEvents = safeFunc(async (ctx) => {
335
339
  const { client, params } = ctx;
340
+ if (!params.calendar_id && !params.agent_id) {
341
+ throw new Error("Provide calendar_id or agent_id");
342
+ }
336
343
  const iter = client.events.list({
337
344
  calendarId: params.calendar_id,
345
+ agentId: params.agent_id,
338
346
  start_after: params.start_after,
339
347
  start_before: params.start_before,
348
+ status: params.status,
349
+ source: params.source,
340
350
  limit: params.limit
341
351
  });
342
352
  return fetchPage(iter, params.offset, params.limit);
343
353
  });
344
354
  var getEvent = safeFunc(async (ctx) => {
345
- return ctx.client.events.get(ctx.params.calendar_id, ctx.params.event_id);
355
+ const { calendar_id, event_id } = ctx.params;
356
+ return calendar_id ? ctx.client.events.get(calendar_id, event_id) : ctx.client.events.getById(event_id);
346
357
  });
347
358
  var createEvent = safeFunc(async (ctx) => {
348
359
  const { client, params } = ctx;
@@ -352,10 +363,15 @@ var createEvent = safeFunc(async (ctx) => {
352
363
  var updateEvent = safeFunc(async (ctx) => {
353
364
  const { client, params } = ctx;
354
365
  const { calendar_id, event_id, ...updates } = params;
355
- return client.events.update(calendar_id, event_id, updates);
366
+ return calendar_id ? client.events.update(calendar_id, event_id, updates) : client.events.updateById(event_id, updates);
356
367
  });
357
368
  var cancelEvent = safeFunc(async (ctx) => {
358
- await ctx.client.events.delete(ctx.params.calendar_id, ctx.params.event_id);
369
+ const { calendar_id, event_id } = ctx.params;
370
+ if (calendar_id) {
371
+ await ctx.client.events.delete(calendar_id, event_id);
372
+ } else {
373
+ await ctx.client.events.deleteById(event_id);
374
+ }
359
375
  return void 0;
360
376
  });
361
377
  var confirmEvent = safeFunc(async (ctx) => {
@@ -623,7 +639,7 @@ var TOOL_DEFINITIONS = [
623
639
  // ── Events ─────────────────────────────────────────────────────
624
640
  {
625
641
  name: "list_events",
626
- description: "List all events on a calendar, including internally created events and externally synced events from iCal subscriptions (e.g. Google Calendar, Outlook). Use start_after and start_before to query a specific time window.",
642
+ description: "List events on a calendar or across an agent's calendars, including internally created events and externally synced events from iCal subscriptions (e.g. Google Calendar, Outlook). Provide `calendar_id` OR `agent_id`. Narrow with `start_after`/`start_before` (time window), `status`, and `source`.",
627
643
  schema: ListEventsSchema,
628
644
  annotations: { title: "List Events", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
629
645
  execute: createExecutor(listEvents)