@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.
package/dist/index.cjs CHANGED
@@ -155,6 +155,7 @@ var WEBHOOK_EVENT_TYPES = [
155
155
  ];
156
156
  var WEBHOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed"];
157
157
  var ListCalendarsSchema = import_zod.z.object({
158
+ 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."),
158
159
  include: import_zod.z.enum(["all"]).optional().describe('Pass "all" to include calendars across all agents (org keys only)'),
159
160
  limit: import_zod.z.number().int().min(1).max(200).default(50).describe("Max results to return"),
160
161
  offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset")
@@ -180,15 +181,18 @@ var DeleteCalendarSchema = import_zod.z.object({
180
181
  calendar_id: import_zod.z.string().describe("Calendar ID to delete")
181
182
  });
182
183
  var ListEventsSchema = import_zod.z.object({
183
- calendar_id: import_zod.z.string().describe("Calendar ID to list events from"),
184
- start_after: import_zod.z.string().datetime().optional().describe("Filter events starting after this time"),
185
- start_before: import_zod.z.string().datetime().optional().describe("Filter events starting before this time"),
184
+ calendar_id: import_zod.z.string().optional().describe("Calendar ID to list events from. Provide this or agent_id."),
185
+ 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."),
186
+ start_after: import_zod.z.string().datetime().optional().describe("Only events starting after this ISO 8601 time"),
187
+ start_before: import_zod.z.string().datetime().optional().describe("Only events starting before this ISO 8601 time"),
188
+ status: import_zod.z.enum(["confirmed", "tentative", "cancelled", "hold"]).optional().describe("Filter by event status"),
189
+ 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)'),
186
190
  limit: import_zod.z.number().int().min(1).max(200).default(50).describe("Max results to return"),
187
191
  offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset")
188
192
  });
189
193
  var GetEventSchema = import_zod.z.object({
190
194
  event_id: import_zod.z.string().describe("Event ID to retrieve"),
191
- 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).")
195
+ 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.")
192
196
  });
193
197
  var CreateEventSchema = import_zod.z.object({
194
198
  calendar_id: import_zod.z.string().describe("Calendar ID to add the event to"),
@@ -204,7 +208,7 @@ var CreateEventSchema = import_zod.z.object({
204
208
  });
205
209
  var UpdateEventSchema = import_zod.z.object({
206
210
  event_id: import_zod.z.string().describe("Event ID to update"),
207
- 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)."),
211
+ 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."),
208
212
  title: import_zod.z.string().min(1).max(500).optional().describe("New event title"),
209
213
  description: import_zod.z.string().nullable().optional().describe("New description, or null to clear it"),
210
214
  start_time: import_zod.z.string().datetime().optional().describe("New start time (ISO 8601)"),
@@ -216,7 +220,7 @@ var UpdateEventSchema = import_zod.z.object({
216
220
  });
217
221
  var CancelEventSchema = import_zod.z.object({
218
222
  event_id: import_zod.z.string().describe("Event ID to cancel"),
219
- 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).")
223
+ 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.")
220
224
  });
221
225
  var ConfirmEventSchema = import_zod.z.object({
222
226
  event_id: import_zod.z.string().describe("Event ID of the hold to confirm")
@@ -313,7 +317,7 @@ var timeOfDay = import_zod.z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "must b
313
317
  var workingHoursDaySchema = import_zod.z.object({
314
318
  start: timeOfDay,
315
319
  end: timeOfDay
316
- });
320
+ }).refine((v) => v.end > v.start, "end must be after start").describe("A single day's working hours window");
317
321
  var workingHoursSchema = import_zod.z.object({
318
322
  mon: workingHoursDaySchema.optional(),
319
323
  tue: workingHoursDaySchema.optional(),
@@ -322,7 +326,7 @@ var workingHoursSchema = import_zod.z.object({
322
326
  fri: workingHoursDaySchema.optional(),
323
327
  sat: workingHoursDaySchema.optional(),
324
328
  sun: workingHoursDaySchema.optional()
325
- }).nullable();
329
+ }).refine((v) => Object.keys(v).length > 0, "at least one day must be specified").nullable();
326
330
  var SetAvailabilityRulesSchema = import_zod.z.object({
327
331
  calendar_id: import_zod.z.string().describe("Calendar to configure"),
328
332
  buffer_before_minutes: import_zod.z.number().int().min(0).max(120).default(0).describe("Minutes of buffer before each event (0\u2013120)"),
@@ -436,7 +440,7 @@ async function fetchPage(iterator, offset, limit) {
436
440
  }
437
441
  var listCalendars = safeFunc(async (ctx) => {
438
442
  const { client, params } = ctx;
439
- const iter = client.calendars.list({ include: params.include, limit: params.limit });
443
+ const iter = client.calendars.list({ agentId: params.agent_id, include: params.include, limit: params.limit });
440
444
  return fetchPage(iter, params.offset, params.limit);
441
445
  });
442
446
  var getCalendar = safeFunc(async (ctx) => {
@@ -463,16 +467,23 @@ var deleteCalendar = safeFunc(async (ctx) => {
463
467
  });
464
468
  var listEvents = safeFunc(async (ctx) => {
465
469
  const { client, params } = ctx;
470
+ if (!params.calendar_id && !params.agent_id) {
471
+ throw new Error("Provide calendar_id or agent_id");
472
+ }
466
473
  const iter = client.events.list({
467
474
  calendarId: params.calendar_id,
475
+ agentId: params.agent_id,
468
476
  start_after: params.start_after,
469
477
  start_before: params.start_before,
478
+ status: params.status,
479
+ source: params.source,
470
480
  limit: params.limit
471
481
  });
472
482
  return fetchPage(iter, params.offset, params.limit);
473
483
  });
474
484
  var getEvent = safeFunc(async (ctx) => {
475
- return ctx.client.events.get(ctx.params.calendar_id, ctx.params.event_id);
485
+ const { calendar_id, event_id } = ctx.params;
486
+ return calendar_id ? ctx.client.events.get(calendar_id, event_id) : ctx.client.events.getById(event_id);
476
487
  });
477
488
  var createEvent = safeFunc(async (ctx) => {
478
489
  const { client, params } = ctx;
@@ -482,10 +493,15 @@ var createEvent = safeFunc(async (ctx) => {
482
493
  var updateEvent = safeFunc(async (ctx) => {
483
494
  const { client, params } = ctx;
484
495
  const { calendar_id, event_id, ...updates } = params;
485
- return client.events.update(calendar_id, event_id, updates);
496
+ return calendar_id ? client.events.update(calendar_id, event_id, updates) : client.events.updateById(event_id, updates);
486
497
  });
487
498
  var cancelEvent = safeFunc(async (ctx) => {
488
- await ctx.client.events.delete(ctx.params.calendar_id, ctx.params.event_id);
499
+ const { calendar_id, event_id } = ctx.params;
500
+ if (calendar_id) {
501
+ await ctx.client.events.delete(calendar_id, event_id);
502
+ } else {
503
+ await ctx.client.events.deleteById(event_id);
504
+ }
489
505
  return void 0;
490
506
  });
491
507
  var confirmEvent = safeFunc(async (ctx) => {
@@ -753,7 +769,7 @@ var TOOL_DEFINITIONS = [
753
769
  // ── Events ─────────────────────────────────────────────────────
754
770
  {
755
771
  name: "list_events",
756
- 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.",
772
+ 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`.",
757
773
  schema: ListEventsSchema,
758
774
  annotations: { title: "List Events", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
759
775
  execute: createExecutor(listEvents)
@@ -1027,7 +1043,7 @@ var TOOL_DEFINITIONS = [
1027
1043
  },
1028
1044
  {
1029
1045
  name: "revoke_scoped_key",
1030
- 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.",
1046
+ 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.",
1031
1047
  schema: RevokeScopedKeySchema,
1032
1048
  annotations: { title: "Revoke Scoped Key", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
1033
1049
  execute: createExecutor(revokeScopedKey)