@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/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import '@chronary/sdk';
6
6
  declare const TOOL_DEFINITIONS: ToolDefinition[];
7
7
 
8
8
  declare const ListCalendarsSchema: z.ZodObject<{
9
+ agent_id: z.ZodOptional<z.ZodString>;
9
10
  include: z.ZodOptional<z.ZodEnum<{
10
11
  all: "all";
11
12
  }>>;
@@ -38,15 +39,26 @@ declare const DeleteCalendarSchema: z.ZodObject<{
38
39
  calendar_id: z.ZodString;
39
40
  }, z.core.$strip>;
40
41
  declare const ListEventsSchema: z.ZodObject<{
41
- calendar_id: z.ZodString;
42
+ calendar_id: z.ZodOptional<z.ZodString>;
43
+ agent_id: z.ZodOptional<z.ZodString>;
42
44
  start_after: z.ZodOptional<z.ZodString>;
43
45
  start_before: z.ZodOptional<z.ZodString>;
46
+ status: z.ZodOptional<z.ZodEnum<{
47
+ confirmed: "confirmed";
48
+ tentative: "tentative";
49
+ cancelled: "cancelled";
50
+ hold: "hold";
51
+ }>>;
52
+ source: z.ZodOptional<z.ZodEnum<{
53
+ internal: "internal";
54
+ external_ical: "external_ical";
55
+ }>>;
44
56
  limit: z.ZodDefault<z.ZodNumber>;
45
57
  offset: z.ZodDefault<z.ZodNumber>;
46
58
  }, z.core.$strip>;
47
59
  declare const GetEventSchema: z.ZodObject<{
48
60
  event_id: z.ZodString;
49
- calendar_id: z.ZodString;
61
+ calendar_id: z.ZodOptional<z.ZodString>;
50
62
  }, z.core.$strip>;
51
63
  declare const CreateEventSchema: z.ZodObject<{
52
64
  calendar_id: z.ZodString;
@@ -66,7 +78,7 @@ declare const CreateEventSchema: z.ZodObject<{
66
78
  }, z.core.$strip>;
67
79
  declare const UpdateEventSchema: z.ZodObject<{
68
80
  event_id: z.ZodString;
69
- calendar_id: z.ZodString;
81
+ calendar_id: z.ZodOptional<z.ZodString>;
70
82
  title: z.ZodOptional<z.ZodString>;
71
83
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
84
  start_time: z.ZodOptional<z.ZodString>;
@@ -82,7 +94,7 @@ declare const UpdateEventSchema: z.ZodObject<{
82
94
  }, z.core.$strip>;
83
95
  declare const CancelEventSchema: z.ZodObject<{
84
96
  event_id: z.ZodString;
85
- calendar_id: z.ZodString;
97
+ calendar_id: z.ZodOptional<z.ZodString>;
86
98
  }, z.core.$strip>;
87
99
  declare const ConfirmEventSchema: z.ZodObject<{
88
100
  event_id: z.ZodString;
package/dist/index.js CHANGED
@@ -129,6 +129,7 @@ var WEBHOOK_EVENT_TYPES = [
129
129
  ];
130
130
  var WEBHOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed"];
131
131
  var ListCalendarsSchema = z.object({
132
+ 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."),
132
133
  include: z.enum(["all"]).optional().describe('Pass "all" to include calendars across all agents (org keys only)'),
133
134
  limit: z.number().int().min(1).max(200).default(50).describe("Max results to return"),
134
135
  offset: z.number().int().min(0).default(0).describe("Pagination offset")
@@ -154,15 +155,18 @@ var DeleteCalendarSchema = z.object({
154
155
  calendar_id: z.string().describe("Calendar ID to delete")
155
156
  });
156
157
  var ListEventsSchema = z.object({
157
- calendar_id: z.string().describe("Calendar ID to list events from"),
158
- start_after: z.string().datetime().optional().describe("Filter events starting after this time"),
159
- start_before: z.string().datetime().optional().describe("Filter events starting before this time"),
158
+ calendar_id: z.string().optional().describe("Calendar ID to list events from. Provide this or agent_id."),
159
+ agent_id: z.string().optional().describe("Agent ID to list events for across all of the agent's calendars. Provide this or calendar_id."),
160
+ start_after: z.string().datetime().optional().describe("Only events starting after this ISO 8601 time"),
161
+ start_before: z.string().datetime().optional().describe("Only events starting before this ISO 8601 time"),
162
+ status: z.enum(["confirmed", "tentative", "cancelled", "hold"]).optional().describe("Filter by event status"),
163
+ source: z.enum(["internal", "external_ical"]).optional().describe('Filter by source: "internal" (created via the API) or "external_ical" (synced from an iCal subscription)'),
160
164
  limit: z.number().int().min(1).max(200).default(50).describe("Max results to return"),
161
165
  offset: z.number().int().min(0).default(0).describe("Pagination offset")
162
166
  });
163
167
  var GetEventSchema = z.object({
164
168
  event_id: z.string().describe("Event ID to retrieve"),
165
- 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).")
169
+ calendar_id: z.string().optional().describe("Calendar ID that owns the event. Optional \u2014 if omitted the calendar is resolved from the event.")
166
170
  });
167
171
  var CreateEventSchema = z.object({
168
172
  calendar_id: z.string().describe("Calendar ID to add the event to"),
@@ -178,7 +182,7 @@ var CreateEventSchema = z.object({
178
182
  });
179
183
  var UpdateEventSchema = z.object({
180
184
  event_id: z.string().describe("Event ID to update"),
181
- 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)."),
185
+ calendar_id: z.string().optional().describe("Calendar ID that owns the event. Optional \u2014 if omitted the calendar is resolved from the event."),
182
186
  title: z.string().min(1).max(500).optional().describe("New event title"),
183
187
  description: z.string().nullable().optional().describe("New description, or null to clear it"),
184
188
  start_time: z.string().datetime().optional().describe("New start time (ISO 8601)"),
@@ -190,7 +194,7 @@ var UpdateEventSchema = z.object({
190
194
  });
191
195
  var CancelEventSchema = z.object({
192
196
  event_id: z.string().describe("Event ID to cancel"),
193
- 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).")
197
+ 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.")
194
198
  });
195
199
  var ConfirmEventSchema = z.object({
196
200
  event_id: z.string().describe("Event ID of the hold to confirm")
@@ -287,7 +291,7 @@ var timeOfDay = z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "must be HH:MM in
287
291
  var workingHoursDaySchema = z.object({
288
292
  start: timeOfDay,
289
293
  end: timeOfDay
290
- });
294
+ }).refine((v) => v.end > v.start, "end must be after start").describe("A single day's working hours window");
291
295
  var workingHoursSchema = z.object({
292
296
  mon: workingHoursDaySchema.optional(),
293
297
  tue: workingHoursDaySchema.optional(),
@@ -296,7 +300,7 @@ var workingHoursSchema = z.object({
296
300
  fri: workingHoursDaySchema.optional(),
297
301
  sat: workingHoursDaySchema.optional(),
298
302
  sun: workingHoursDaySchema.optional()
299
- }).nullable();
303
+ }).refine((v) => Object.keys(v).length > 0, "at least one day must be specified").nullable();
300
304
  var SetAvailabilityRulesSchema = z.object({
301
305
  calendar_id: z.string().describe("Calendar to configure"),
302
306
  buffer_before_minutes: z.number().int().min(0).max(120).default(0).describe("Minutes of buffer before each event (0\u2013120)"),
@@ -410,7 +414,7 @@ async function fetchPage(iterator, offset, limit) {
410
414
  }
411
415
  var listCalendars = safeFunc(async (ctx) => {
412
416
  const { client, params } = ctx;
413
- const iter = client.calendars.list({ include: params.include, limit: params.limit });
417
+ const iter = client.calendars.list({ agentId: params.agent_id, include: params.include, limit: params.limit });
414
418
  return fetchPage(iter, params.offset, params.limit);
415
419
  });
416
420
  var getCalendar = safeFunc(async (ctx) => {
@@ -437,16 +441,23 @@ var deleteCalendar = safeFunc(async (ctx) => {
437
441
  });
438
442
  var listEvents = safeFunc(async (ctx) => {
439
443
  const { client, params } = ctx;
444
+ if (!params.calendar_id && !params.agent_id) {
445
+ throw new Error("Provide calendar_id or agent_id");
446
+ }
440
447
  const iter = client.events.list({
441
448
  calendarId: params.calendar_id,
449
+ agentId: params.agent_id,
442
450
  start_after: params.start_after,
443
451
  start_before: params.start_before,
452
+ status: params.status,
453
+ source: params.source,
444
454
  limit: params.limit
445
455
  });
446
456
  return fetchPage(iter, params.offset, params.limit);
447
457
  });
448
458
  var getEvent = safeFunc(async (ctx) => {
449
- return ctx.client.events.get(ctx.params.calendar_id, ctx.params.event_id);
459
+ const { calendar_id, event_id } = ctx.params;
460
+ return calendar_id ? ctx.client.events.get(calendar_id, event_id) : ctx.client.events.getById(event_id);
450
461
  });
451
462
  var createEvent = safeFunc(async (ctx) => {
452
463
  const { client, params } = ctx;
@@ -456,10 +467,15 @@ var createEvent = safeFunc(async (ctx) => {
456
467
  var updateEvent = safeFunc(async (ctx) => {
457
468
  const { client, params } = ctx;
458
469
  const { calendar_id, event_id, ...updates } = params;
459
- return client.events.update(calendar_id, event_id, updates);
470
+ return calendar_id ? client.events.update(calendar_id, event_id, updates) : client.events.updateById(event_id, updates);
460
471
  });
461
472
  var cancelEvent = safeFunc(async (ctx) => {
462
- await ctx.client.events.delete(ctx.params.calendar_id, ctx.params.event_id);
473
+ const { calendar_id, event_id } = ctx.params;
474
+ if (calendar_id) {
475
+ await ctx.client.events.delete(calendar_id, event_id);
476
+ } else {
477
+ await ctx.client.events.deleteById(event_id);
478
+ }
463
479
  return void 0;
464
480
  });
465
481
  var confirmEvent = safeFunc(async (ctx) => {
@@ -727,7 +743,7 @@ var TOOL_DEFINITIONS = [
727
743
  // ── Events ─────────────────────────────────────────────────────
728
744
  {
729
745
  name: "list_events",
730
- 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.",
746
+ 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`.",
731
747
  schema: ListEventsSchema,
732
748
  annotations: { title: "List Events", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
733
749
  execute: createExecutor(listEvents)