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