@chronary/toolkit 1.1.0 → 1.2.1

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.
@@ -51,6 +51,7 @@ var WEBHOOK_EVENT_TYPES = [
51
51
  ];
52
52
  var WEBHOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed"];
53
53
  var ListCalendarsSchema = import_zod.z.object({
54
+ agent_id: import_zod.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."),
54
55
  include: import_zod.z.enum(["all"]).optional().describe('Pass "all" to include calendars across all agents (org keys only)'),
55
56
  limit: import_zod.z.number().int().min(1).max(200).default(50).describe("Max results to return"),
56
57
  offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset")
@@ -76,15 +77,18 @@ var DeleteCalendarSchema = import_zod.z.object({
76
77
  calendar_id: import_zod.z.string().describe("Calendar ID to delete")
77
78
  });
78
79
  var ListEventsSchema = import_zod.z.object({
79
- calendar_id: import_zod.z.string().describe("Calendar ID to list events from"),
80
- start_after: import_zod.z.string().datetime().optional().describe("Filter events starting after this time"),
81
- start_before: import_zod.z.string().datetime().optional().describe("Filter events starting before this time"),
80
+ calendar_id: import_zod.z.string().optional().describe("Calendar ID to list events from. Provide this or agent_id."),
81
+ agent_id: import_zod.z.string().optional().describe("Agent ID to list events for across all of the agent's calendars. Provide this or calendar_id."),
82
+ start_after: import_zod.z.string().datetime().optional().describe("Only events starting after this ISO 8601 time"),
83
+ start_before: import_zod.z.string().datetime().optional().describe("Only events starting before this ISO 8601 time"),
84
+ status: import_zod.z.enum(["confirmed", "tentative", "cancelled", "hold"]).optional().describe("Filter by event status"),
85
+ source: import_zod.z.enum(["internal", "external_ical"]).optional().describe('Filter by source: "internal" (created via the API) or "external_ical" (synced from an iCal subscription)'),
82
86
  limit: import_zod.z.number().int().min(1).max(200).default(50).describe("Max results to return"),
83
87
  offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset")
84
88
  });
85
89
  var GetEventSchema = import_zod.z.object({
86
90
  event_id: import_zod.z.string().describe("Event ID to retrieve"),
87
- calendar_id: import_zod.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).")
91
+ calendar_id: import_zod.z.string().optional().describe("Calendar ID that owns the event. Optional \u2014 if omitted the calendar is resolved from the event.")
88
92
  });
89
93
  var CreateEventSchema = import_zod.z.object({
90
94
  calendar_id: import_zod.z.string().describe("Calendar ID to add the event to"),
@@ -100,7 +104,7 @@ var CreateEventSchema = import_zod.z.object({
100
104
  });
101
105
  var UpdateEventSchema = import_zod.z.object({
102
106
  event_id: import_zod.z.string().describe("Event ID to update"),
103
- calendar_id: import_zod.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)."),
107
+ calendar_id: import_zod.z.string().optional().describe("Calendar ID that owns the event. Optional \u2014 if omitted the calendar is resolved from the event."),
104
108
  title: import_zod.z.string().min(1).max(500).optional().describe("New event title"),
105
109
  description: import_zod.z.string().nullable().optional().describe("New description, or null to clear it"),
106
110
  start_time: import_zod.z.string().datetime().optional().describe("New start time (ISO 8601)"),
@@ -112,7 +116,7 @@ var UpdateEventSchema = import_zod.z.object({
112
116
  });
113
117
  var CancelEventSchema = import_zod.z.object({
114
118
  event_id: import_zod.z.string().describe("Event ID to cancel"),
115
- calendar_id: import_zod.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).")
119
+ calendar_id: import_zod.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.")
116
120
  });
117
121
  var ConfirmEventSchema = import_zod.z.object({
118
122
  event_id: import_zod.z.string().describe("Event ID of the hold to confirm")
@@ -209,7 +213,7 @@ var timeOfDay = import_zod.z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "must b
209
213
  var workingHoursDaySchema = import_zod.z.object({
210
214
  start: timeOfDay,
211
215
  end: timeOfDay
212
- });
216
+ }).refine((v) => v.end > v.start, "end must be after start").describe("A single day's working hours window");
213
217
  var workingHoursSchema = import_zod.z.object({
214
218
  mon: workingHoursDaySchema.optional(),
215
219
  tue: workingHoursDaySchema.optional(),
@@ -218,7 +222,7 @@ var workingHoursSchema = import_zod.z.object({
218
222
  fri: workingHoursDaySchema.optional(),
219
223
  sat: workingHoursDaySchema.optional(),
220
224
  sun: workingHoursDaySchema.optional()
221
- }).nullable();
225
+ }).refine((v) => Object.keys(v).length > 0, "at least one day must be specified").nullable();
222
226
  var SetAvailabilityRulesSchema = import_zod.z.object({
223
227
  calendar_id: import_zod.z.string().describe("Calendar to configure"),
224
228
  buffer_before_minutes: import_zod.z.number().int().min(0).max(120).default(0).describe("Minutes of buffer before each event (0\u2013120)"),
@@ -332,7 +336,7 @@ async function fetchPage(iterator, offset, limit) {
332
336
  }
333
337
  var listCalendars = safeFunc(async (ctx) => {
334
338
  const { client, params } = ctx;
335
- const iter = client.calendars.list({ include: params.include, limit: params.limit });
339
+ const iter = client.calendars.list({ agentId: params.agent_id, include: params.include, limit: params.limit });
336
340
  return fetchPage(iter, params.offset, params.limit);
337
341
  });
338
342
  var getCalendar = safeFunc(async (ctx) => {
@@ -359,16 +363,23 @@ var deleteCalendar = safeFunc(async (ctx) => {
359
363
  });
360
364
  var listEvents = safeFunc(async (ctx) => {
361
365
  const { client, params } = ctx;
366
+ if (!params.calendar_id && !params.agent_id) {
367
+ throw new Error("Provide calendar_id or agent_id");
368
+ }
362
369
  const iter = client.events.list({
363
370
  calendarId: params.calendar_id,
371
+ agentId: params.agent_id,
364
372
  start_after: params.start_after,
365
373
  start_before: params.start_before,
374
+ status: params.status,
375
+ source: params.source,
366
376
  limit: params.limit
367
377
  });
368
378
  return fetchPage(iter, params.offset, params.limit);
369
379
  });
370
380
  var getEvent = safeFunc(async (ctx) => {
371
- return ctx.client.events.get(ctx.params.calendar_id, ctx.params.event_id);
381
+ const { calendar_id, event_id } = ctx.params;
382
+ return calendar_id ? ctx.client.events.get(calendar_id, event_id) : ctx.client.events.getById(event_id);
372
383
  });
373
384
  var createEvent = safeFunc(async (ctx) => {
374
385
  const { client, params } = ctx;
@@ -378,10 +389,15 @@ var createEvent = safeFunc(async (ctx) => {
378
389
  var updateEvent = safeFunc(async (ctx) => {
379
390
  const { client, params } = ctx;
380
391
  const { calendar_id, event_id, ...updates } = params;
381
- return client.events.update(calendar_id, event_id, updates);
392
+ return calendar_id ? client.events.update(calendar_id, event_id, updates) : client.events.updateById(event_id, updates);
382
393
  });
383
394
  var cancelEvent = safeFunc(async (ctx) => {
384
- await ctx.client.events.delete(ctx.params.calendar_id, ctx.params.event_id);
395
+ const { calendar_id, event_id } = ctx.params;
396
+ if (calendar_id) {
397
+ await ctx.client.events.delete(calendar_id, event_id);
398
+ } else {
399
+ await ctx.client.events.deleteById(event_id);
400
+ }
385
401
  return void 0;
386
402
  });
387
403
  var confirmEvent = safeFunc(async (ctx) => {
@@ -649,7 +665,7 @@ var TOOL_DEFINITIONS = [
649
665
  // ── Events ─────────────────────────────────────────────────────
650
666
  {
651
667
  name: "list_events",
652
- 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.",
668
+ 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`.",
653
669
  schema: ListEventsSchema,
654
670
  annotations: { title: "List Events", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
655
671
  execute: createExecutor(listEvents)
@@ -923,7 +939,7 @@ var TOOL_DEFINITIONS = [
923
939
  },
924
940
  {
925
941
  name: "revoke_scoped_key",
926
- description: "Revoke an agent-scoped API key by ID. The key stops authenticating immediately and cannot be un-revoked. Requires an org-level API key.",
942
+ description: "Revoke an agent-scoped API key by ID. Revocation is permanent (cannot be un-revoked); the key stops authenticating within about a minute. Requires an org-level API key.",
927
943
  schema: RevokeScopedKeySchema,
928
944
  annotations: { title: "Revoke Scoped Key", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
929
945
  execute: createExecutor(revokeScopedKey)