@chronary/toolkit 1.2.4 → 1.3.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/mcp.cjs CHANGED
@@ -85,7 +85,8 @@ var ListEventsSchema = import_zod.z.object({
85
85
  status: import_zod.z.enum(["confirmed", "tentative", "cancelled", "hold"]).optional().describe("Filter by event status"),
86
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)'),
87
87
  limit: import_zod.z.number().int().min(1).max(200).default(50).describe("Max results to return"),
88
- offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset")
88
+ offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset"),
89
+ expand: import_zod.z.boolean().default(false).describe("Expand recurring series into individual occurrence instances within the window. Requires both start_after and start_before (max 366 days apart). Instances carry recurringEventId + originalStartTime.")
89
90
  });
90
91
  var GetEventSchema = import_zod.z.object({
91
92
  event_id: import_zod.z.string().describe("Event ID to retrieve"),
@@ -101,7 +102,8 @@ var CreateEventSchema = import_zod.z.object({
101
102
  status: import_zod.z.enum(["confirmed", "tentative", "hold"]).optional().describe('Event status. "hold" creates a tentative reservation that auto-expires at hold_expires_at. Defaults to "confirmed".'),
102
103
  reminders: import_zod.z.array(import_zod.z.number().int().min(1).max(40320)).max(5).nullable().optional().describe("Reminder offsets in minutes before start_time (e.g. [10, 1440]). Each fires an event.reminder webhook and shows as an alarm in the iCal feed. Omit or null to inherit the calendar default (then the system default of 10 min); [] for no reminders."),
103
104
  hold_expires_at: import_zod.z.string().datetime().optional().describe('Required when status="hold". ISO 8601 timestamp 30s-15min in the future. Auto-releases the hold when reached.'),
104
- hold_priority: import_zod.z.number().int().min(0).max(100).optional().describe('Only valid with status="hold". Higher-priority overlapping holds pre-empt lower-priority ones. Defaults to 0.')
105
+ hold_priority: import_zod.z.number().int().min(0).max(100).optional().describe('Only valid with status="hold". Higher-priority overlapping holds pre-empt lower-priority ones. Defaults to 0.'),
106
+ recurrence_rule: import_zod.z.string().max(256).optional().describe('Make this a recurring series (RFC 5545 RRULE subset, no "RRULE:" prefix), e.g. "FREQ=WEEKLY;BYDAY=MO,WE;COUNT=12". Supports FREQ=DAILY/WEEKLY/MONTHLY/YEARLY, INTERVAL, COUNT (max 730) or UNTIL, BYDAY (weekly list or monthly ordinal like 2TU/-1FR), BYMONTHDAY (1-28 or -1). start_time must match the rule pattern; expansion is UTC-only. Not allowed with status="hold". Free plan: max 5 recurring events, series must end within 90 days.')
105
107
  });
106
108
  var UpdateEventSchema = import_zod.z.object({
107
109
  event_id: import_zod.z.string().describe("Event ID to update"),
@@ -113,11 +115,13 @@ var UpdateEventSchema = import_zod.z.object({
113
115
  all_day: import_zod.z.boolean().optional().describe("Whether this is an all-day event"),
114
116
  status: import_zod.z.enum(["confirmed", "tentative", "cancelled"]).optional().describe("New event status"),
115
117
  metadata: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional().describe("Replacement metadata object"),
116
- reminders: import_zod.z.array(import_zod.z.number().int().min(1).max(40320)).max(5).nullable().optional().describe("Reminder offsets in minutes before start_time. Omit to leave unchanged, null to inherit the calendar default, [] for no reminders.")
118
+ reminders: import_zod.z.array(import_zod.z.number().int().min(1).max(40320)).max(5).nullable().optional().describe("Reminder offsets in minutes before start_time. Omit to leave unchanged, null to inherit the calendar default, [] for no reminders."),
119
+ recurrence_rule: import_zod.z.string().max(256).nullable().optional().describe("Set/change the recurring series rule (RFC 5545 RRULE subset, full-series semantics), or null to make the event a one-off. Changing the rule or start_time resets cancelled occurrences.")
117
120
  });
118
121
  var CancelEventSchema = import_zod.z.object({
119
122
  event_id: import_zod.z.string().describe("Event ID to cancel"),
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.")
123
+ 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."),
124
+ occurrence_start: import_zod.z.string().datetime().optional().describe("For recurring events only: ISO 8601 start of the single occurrence to cancel. The rest of the series is unaffected.")
121
125
  });
122
126
  var ConfirmEventSchema = import_zod.z.object({
123
127
  event_id: import_zod.z.string().describe("Event ID of the hold to confirm")
@@ -376,6 +380,7 @@ var listEvents = safeFunc(async (ctx) => {
376
380
  start_before: params.start_before,
377
381
  status: params.status,
378
382
  source: params.source,
383
+ expand: params.expand,
379
384
  limit: params.limit
380
385
  });
381
386
  return fetchPage(iter, params.offset, params.limit);
@@ -395,7 +400,11 @@ var updateEvent = safeFunc(async (ctx) => {
395
400
  return calendar_id ? client.events.update(calendar_id, event_id, updates) : client.events.updateById(event_id, updates);
396
401
  });
397
402
  var cancelEvent = safeFunc(async (ctx) => {
398
- const { calendar_id, event_id } = ctx.params;
403
+ const { calendar_id, event_id, occurrence_start } = ctx.params;
404
+ if (occurrence_start) {
405
+ const event = calendar_id ? await ctx.client.events.delete(calendar_id, event_id, { occurrence_start }) : await ctx.client.events.deleteById(event_id, { occurrence_start });
406
+ return { occurrence_cancelled: true, id: event_id, occurrence_start, event };
407
+ }
399
408
  if (calendar_id) {
400
409
  await ctx.client.events.delete(calendar_id, event_id);
401
410
  } else {
@@ -698,7 +707,7 @@ var TOOL_DEFINITIONS = [
698
707
  },
699
708
  {
700
709
  name: "cancel_event",
701
- description: "Delete or cancel an event from a calendar. Use this to remove, cancel, or delete any scheduled event or appointment. The event is marked cancelled and excluded from future availability calculations. `calendar_id` is optional \u2014 if omitted the calendar is looked up from the event. Provide `calendar_id` to fail fast on cross-calendar typos.",
710
+ description: "Delete or cancel an event from a calendar. Use this to remove, cancel, or delete any scheduled event or appointment. The event is marked cancelled and excluded from future availability calculations. For a recurring series, pass `occurrence_start` to cancel just that one occurrence (the series continues); omit it to cancel the whole series. `calendar_id` is optional \u2014 if omitted the calendar is looked up from the event. Provide `calendar_id` to fail fast on cross-calendar typos.",
702
711
  schema: CancelEventSchema,
703
712
  annotations: { title: "Cancel Event", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
704
713
  execute: createExecutor(cancelEvent)
@@ -1003,6 +1012,23 @@ var ListToolkit = class extends BaseToolkit {
1003
1012
  };
1004
1013
 
1005
1014
  // src/adapters/mcp.ts
1015
+ var ABOUT_MARKDOWN = `# Chronary
1016
+
1017
+ Calendar-as-a-service for AI agents. Give an agent its own calendars and
1018
+ events, coordinate availability across agents, run multi-party scheduling
1019
+ proposals, place auto-expiring holds, manage availability rules, sync external
1020
+ iCal feeds, and receive webhooks.
1021
+
1022
+ ## Getting started
1023
+ 1. \`create_agent\` \u2014 register an agent (skip if you already have one).
1024
+ 2. \`create_calendar\` \u2014 give the agent a calendar.
1025
+ 3. \`create_event\` / \`get_availability\` / \`find_meeting_time\` \u2014 schedule and coordinate.
1026
+
1027
+ ## Keys & plans
1028
+ Org keys (\`chr_sk_\`) can use every tool; agent-scoped keys (\`chr_ak_\`) are
1029
+ limited to their own agent and cannot use org-only tools such as
1030
+ \`create_agent\` or \`find_meeting_time\`. Temporal holds, cross-agent
1031
+ availability, and scheduling proposals require a Pro plan.`;
1006
1032
  var ChronaryToolkit = class extends ListToolkit {
1007
1033
  constructor(config) {
1008
1034
  super(config);
@@ -1039,6 +1065,126 @@ var ChronaryToolkit = class extends ListToolkit {
1039
1065
  );
1040
1066
  }
1041
1067
  }
1068
+ /**
1069
+ * Register the reusable prompt templates (MCP `prompts` capability) on an
1070
+ * McpServer. Mirrors the hosted server's four prompts so stdio and hosted
1071
+ * expose the same `prompts/list`. No-op if the server can't register prompts.
1072
+ */
1073
+ registerPrompts(server) {
1074
+ if (!server.registerPrompt) return;
1075
+ server.registerPrompt(
1076
+ "schedule_event",
1077
+ {
1078
+ title: "Schedule an event",
1079
+ description: "Create a calendar event on an agent's calendar at a specific time.",
1080
+ argsSchema: {
1081
+ calendar_id: import_zod2.z.string().describe("Target calendar ID (cal_...). Run list_calendars first if unknown."),
1082
+ title: import_zod2.z.string().describe("Event title"),
1083
+ start_time: import_zod2.z.string().describe("Start time, ISO 8601 (e.g. 2026-07-10T15:00:00Z)"),
1084
+ end_time: import_zod2.z.string().describe("End time, ISO 8601")
1085
+ }
1086
+ },
1087
+ ({ calendar_id, title, start_time, end_time }) => ({
1088
+ messages: [
1089
+ {
1090
+ role: "user",
1091
+ content: {
1092
+ type: "text",
1093
+ text: `Create an event on calendar ${calendar_id} titled "${title}" from ${start_time} to ${end_time}. Call the create_event tool with those arguments (calendar_id, title, start_time, end_time). If the calendar ID is unknown, call list_calendars first. Report the created event ID when done.`
1094
+ }
1095
+ }
1096
+ ]
1097
+ })
1098
+ );
1099
+ server.registerPrompt(
1100
+ "find_meeting_time",
1101
+ {
1102
+ title: "Find a meeting time",
1103
+ description: "Find a slot that works across several agents, then optionally book it.",
1104
+ argsSchema: {
1105
+ agent_ids: import_zod2.z.string().describe("Comma-separated agent IDs to coordinate (agt_...)."),
1106
+ duration: import_zod2.z.string().describe('Meeting length, e.g. "30m" or "1h".'),
1107
+ window: import_zod2.z.string().optional().describe('Optional ISO 8601 range to search, e.g. "2026-07-10T09:00:00Z/2026-07-10T18:00:00Z".')
1108
+ }
1109
+ },
1110
+ ({ agent_ids, duration, window }) => ({
1111
+ messages: [
1112
+ {
1113
+ role: "user",
1114
+ content: {
1115
+ type: "text",
1116
+ text: `Find a ${duration} slot that works for all of these agents: ${agent_ids}${window ? ` within ${window}` : ""}. Call the find_meeting_time tool (agents, duration, and start/end if a window is given). Present the top few candidate slots and ask which to book before calling create_event. (find_meeting_time requires a Pro plan.)`
1117
+ }
1118
+ }
1119
+ ]
1120
+ })
1121
+ );
1122
+ server.registerPrompt(
1123
+ "daily_agenda",
1124
+ {
1125
+ title: "Summarize an agent's day",
1126
+ description: "Get an agent's current status and upcoming schedule at a glance.",
1127
+ argsSchema: {
1128
+ agent_id: import_zod2.z.string().describe("Agent whose day to summarize (agt_...)."),
1129
+ date: import_zod2.z.string().optional().describe("Optional ISO 8601 date to focus on (defaults to today).")
1130
+ }
1131
+ },
1132
+ ({ agent_id, date }) => ({
1133
+ messages: [
1134
+ {
1135
+ role: "user",
1136
+ content: {
1137
+ type: "text",
1138
+ text: `Summarize agent ${agent_id}'s schedule${date ? ` for ${date}` : " for today"}. Use list_calendars to find the agent's calendar(s), then get_calendar_context for the current/next/upcoming events and status. Present a concise agenda.`
1139
+ }
1140
+ }
1141
+ ]
1142
+ })
1143
+ );
1144
+ server.registerPrompt(
1145
+ "new_scheduling_proposal",
1146
+ {
1147
+ title: "Propose a multi-party meeting",
1148
+ description: "Create a scheduling proposal offering several time slots to participants.",
1149
+ argsSchema: {
1150
+ title: import_zod2.z.string().describe("Proposal / meeting title"),
1151
+ organizer_agent_id: import_zod2.z.string().describe("Organizer agent ID (agt_...)."),
1152
+ participant_agent_ids: import_zod2.z.string().describe("Comma-separated participant agent IDs (agt_...).")
1153
+ }
1154
+ },
1155
+ ({ title, organizer_agent_id, participant_agent_ids }) => ({
1156
+ messages: [
1157
+ {
1158
+ role: "user",
1159
+ content: {
1160
+ type: "text",
1161
+ text: `Create a scheduling proposal "${title}" organized by ${organizer_agent_id} for participants ${participant_agent_ids}. First use get_availability / find_meeting_time to pick 2-3 candidate slots, then call create_proposal with those slots. Report the proposal ID. (Scheduling proposals require a Pro plan and an org-level key.)`
1162
+ }
1163
+ }
1164
+ ]
1165
+ })
1166
+ );
1167
+ }
1168
+ /**
1169
+ * Register the static `chronary://about` resource (MCP `resources` capability)
1170
+ * so stdio and hosted expose the same `resources/list`. No-op if the server
1171
+ * can't register resources.
1172
+ */
1173
+ registerResources(server) {
1174
+ if (!server.registerResource) return;
1175
+ server.registerResource(
1176
+ "about",
1177
+ "chronary://about",
1178
+ {
1179
+ title: "About Chronary",
1180
+ description: "What Chronary is and how to use its MCP tools.",
1181
+ mimeType: "text/markdown"
1182
+ },
1183
+ () => ({
1184
+ contents: [{ uri: "chronary://about", mimeType: "text/markdown", text: ABOUT_MARKDOWN }]
1185
+ })
1186
+ );
1187
+ }
1042
1188
  };
1043
1189
  // Annotate the CommonJS export names for ESM import in node:
1044
1190
  0 && (module.exports = {