@chronary/toolkit 1.5.2 → 1.6.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +2 -2
  3. package/dist/ai-sdk.cjs +291 -62
  4. package/dist/ai-sdk.cjs.map +1 -1
  5. package/dist/ai-sdk.d.cts +1 -1
  6. package/dist/ai-sdk.d.ts +1 -1
  7. package/dist/ai-sdk.js +291 -62
  8. package/dist/ai-sdk.js.map +1 -1
  9. package/dist/{base-DuHHyh4Q.d.cts → base-BL0efzXv.d.cts} +11 -3
  10. package/dist/{base-DuHHyh4Q.d.ts → base-BL0efzXv.d.ts} +11 -3
  11. package/dist/index.cjs +336 -64
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +230 -6
  14. package/dist/index.d.ts +230 -6
  15. package/dist/index.js +331 -63
  16. package/dist/index.js.map +1 -1
  17. package/dist/instructions-CQAfBjV3.d.cts +10 -0
  18. package/dist/instructions-CQAfBjV3.d.ts +10 -0
  19. package/dist/langchain.cjs +290 -61
  20. package/dist/langchain.cjs.map +1 -1
  21. package/dist/langchain.d.cts +3 -2
  22. package/dist/langchain.d.ts +3 -2
  23. package/dist/langchain.js +290 -61
  24. package/dist/langchain.js.map +1 -1
  25. package/dist/mastra.cjs +291 -62
  26. package/dist/mastra.cjs.map +1 -1
  27. package/dist/mastra.d.cts +3 -2
  28. package/dist/mastra.d.ts +3 -2
  29. package/dist/mastra.js +291 -62
  30. package/dist/mastra.js.map +1 -1
  31. package/dist/mcp.cjs +313 -68
  32. package/dist/mcp.cjs.map +1 -1
  33. package/dist/mcp.d.cts +4 -2
  34. package/dist/mcp.d.ts +4 -2
  35. package/dist/mcp.js +311 -67
  36. package/dist/mcp.js.map +1 -1
  37. package/dist/openai.cjs +290 -61
  38. package/dist/openai.cjs.map +1 -1
  39. package/dist/openai.d.cts +3 -2
  40. package/dist/openai.d.ts +3 -2
  41. package/dist/openai.js +290 -61
  42. package/dist/openai.js.map +1 -1
  43. package/package.json +5 -5
package/dist/openai.cjs CHANGED
@@ -48,12 +48,15 @@ var WEBHOOK_EVENT_TYPES = [
48
48
  "proposal.confirmed",
49
49
  "proposal.expired",
50
50
  "proposal.cancelled",
51
- "webhook.deactivated"
51
+ "webhook.deactivated",
52
+ "org.plan_changed",
53
+ "calendar_connection.reauthorization_required",
54
+ "usage.threshold_crossed"
52
55
  ];
53
- var WEBHOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed"];
56
+ var WEBHOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed", "dropped"];
54
57
  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."),
56
- include: import_zod.z.enum(["all"]).optional().describe('Pass "all" to include calendars across all agents (org keys only)'),
58
+ agent_id: import_zod.z.string().optional().describe("Filter to calendars owned by this agent. Organization keys only \u2014 Agent keys are always limited to their own agent and ignore this."),
59
+ include: import_zod.z.enum(["all"]).optional().describe('Pass "all" to include calendars across all agents (Organization keys only)'),
57
60
  limit: import_zod.z.number().int().min(1).max(200).default(50).describe("Max results to return"),
58
61
  offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset")
59
62
  });
@@ -63,13 +66,13 @@ var GetCalendarSchema = import_zod.z.object({
63
66
  var CreateCalendarSchema = import_zod.z.object({
64
67
  name: import_zod.z.string().min(1).max(255).describe("Calendar name"),
65
68
  agent_id: import_zod.z.string().optional().describe("Agent ID to own this calendar (omit for org-level)"),
66
- timezone: import_zod.z.string().min(1).describe("IANA timezone (e.g. America/New_York)"),
69
+ timezone: import_zod.z.string().min(1).max(64).describe("IANA timezone (e.g. America/New_York)"),
67
70
  default_reminders: import_zod.z.array(import_zod.z.number().int().min(1).max(40320)).max(5).nullable().optional().describe("Default reminder offsets in minutes before start, inherited by events on this calendar that don't set their own. Omit or null to use the system default (10 min); [] for no reminders.")
68
71
  });
69
72
  var UpdateCalendarSchema = import_zod.z.object({
70
73
  calendar_id: import_zod.z.string().describe("Calendar ID to update"),
71
74
  name: import_zod.z.string().min(1).max(255).optional().describe("New calendar name"),
72
- timezone: import_zod.z.string().min(1).optional().describe("New IANA timezone (e.g. America/New_York)"),
75
+ timezone: import_zod.z.string().min(1).max(64).optional().describe("New IANA timezone (e.g. America/New_York)"),
73
76
  agent_status: import_zod.z.enum(["idle", "working", "waiting", "error"]).optional().describe("Owning agent's status"),
74
77
  default_reminders: import_zod.z.array(import_zod.z.number().int().min(1).max(40320)).max(5).nullable().optional().describe("Default reminder offsets in minutes; null for system default, [] for none"),
75
78
  metadata: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional().describe("Arbitrary metadata (max 16KB)")
@@ -110,6 +113,18 @@ var ListEventsSchema = import_zod.z.object({
110
113
  offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset"),
111
114
  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.")
112
115
  });
116
+ var ListOrgEventsSchema = import_zod.z.object({
117
+ calendar_ids: import_zod.z.array(import_zod.z.string()).max(50).optional().describe("Only these calendar IDs (at most 50)"),
118
+ agent_id: import_zod.z.string().optional().describe("Only this agent's calendars"),
119
+ start_after: import_zod.z.string().datetime().optional().describe("Only events starting at or after this ISO 8601 time"),
120
+ start_before: import_zod.z.string().datetime().optional().describe("Only events starting at or before this ISO 8601 time"),
121
+ status: import_zod.z.enum(["confirmed", "tentative", "cancelled", "hold"]).optional().describe("Filter by event status"),
122
+ 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)'),
123
+ q: import_zod.z.string().optional().describe("Case-insensitive title search. Requires start_after and start_before at most 31 days apart"),
124
+ expand: import_zod.z.boolean().default(false).describe("Expand recurring series into individual occurrences within the window. Requires both start_after and start_before (max 366 days apart)."),
125
+ limit: import_zod.z.number().int().min(1).max(100).default(50).describe("Max results to return (1-100)"),
126
+ offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset")
127
+ });
113
128
  var GetEventSchema = import_zod.z.object({
114
129
  event_id: import_zod.z.string().describe("Event ID to retrieve"),
115
130
  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.")
@@ -119,7 +134,7 @@ var CreateEventSchema = import_zod.z.object({
119
134
  title: import_zod.z.string().min(1).max(500).describe("Event title"),
120
135
  start_time: import_zod.z.string().datetime().describe("Start time (ISO 8601)"),
121
136
  end_time: import_zod.z.string().datetime().describe("End time (ISO 8601)"),
122
- description: import_zod.z.string().optional().describe("Optional event description"),
137
+ description: import_zod.z.string().max(1e4).optional().describe("Optional event description"),
123
138
  all_day: import_zod.z.boolean().default(false).describe("Whether this is an all-day event"),
124
139
  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".'),
125
140
  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."),
@@ -131,7 +146,7 @@ var UpdateEventSchema = import_zod.z.object({
131
146
  event_id: import_zod.z.string().describe("Event ID to update"),
132
147
  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."),
133
148
  title: import_zod.z.string().min(1).max(500).optional().describe("New event title"),
134
- description: import_zod.z.string().nullable().optional().describe("New description, or null to clear it"),
149
+ description: import_zod.z.string().max(1e4).nullable().optional().describe("New description, or null to clear it"),
135
150
  start_time: import_zod.z.string().datetime().optional().describe("New start time (ISO 8601)"),
136
151
  end_time: import_zod.z.string().datetime().optional().describe("New end time (ISO 8601)"),
137
152
  all_day: import_zod.z.boolean().optional().describe("Whether this is an all-day event"),
@@ -154,7 +169,7 @@ var ReleaseEventSchema = import_zod.z.object({
154
169
  var CreateAgentSchema = import_zod.z.object({
155
170
  name: import_zod.z.string().min(1).max(255).describe("Display name for the agent"),
156
171
  type: import_zod.z.enum(["ai", "human", "resource"]).describe("Agent type"),
157
- description: import_zod.z.string().optional().describe("Optional description")
172
+ description: import_zod.z.string().max(5e3).optional().describe("Optional description")
158
173
  });
159
174
  var ListAgentsSchema = import_zod.z.object({
160
175
  type: import_zod.z.enum(["ai", "human", "resource"]).optional().describe("Filter by agent type"),
@@ -168,7 +183,7 @@ var GetAgentSchema = import_zod.z.object({
168
183
  var UpdateAgentSchema = import_zod.z.object({
169
184
  agent_id: import_zod.z.string().describe("Agent ID to update"),
170
185
  name: import_zod.z.string().min(1).max(255).optional().describe("New display name"),
171
- description: import_zod.z.string().nullable().optional().describe("New description (null to clear)"),
186
+ description: import_zod.z.string().max(5e3).nullable().optional().describe("New description (null to clear)"),
172
187
  metadata: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional().describe("Arbitrary metadata (max 16KB)"),
173
188
  status: import_zod.z.enum(["active", "paused"]).optional().describe("Operational status")
174
189
  });
@@ -225,7 +240,7 @@ var CreateProposalSchema = import_zod.z.object({
225
240
  expires_at: import_zod.z.string().datetime().optional().describe("Auto-cancel cutoff if unresolved")
226
241
  });
227
242
  var ListProposalsSchema = import_zod.z.object({
228
- status: import_zod.z.enum(["pending", "confirmed", "expired", "cancelled"]).optional().describe("Filter by proposal status"),
243
+ status: import_zod.z.enum(["pending", "resolving", "confirmed", "expired", "cancelled"]).optional().describe("Filter by proposal status"),
229
244
  organizer_agent_id: import_zod.z.string().optional().describe("Filter by organizer agent"),
230
245
  limit: import_zod.z.number().int().min(1).max(200).optional().describe("Max results (default 50)"),
231
246
  offset: import_zod.z.number().int().min(0).optional().describe("Pagination offset (default 0)")
@@ -276,7 +291,8 @@ var ClearAvailabilityRulesSchema = import_zod.z.object({
276
291
  });
277
292
  var CreateScopedKeySchema = import_zod.z.object({
278
293
  agent_id: import_zod.z.string().regex(/^agt_/).describe("Agent ID this key is scoped to"),
279
- label: import_zod.z.string().min(1).max(100).optional().describe("Human-readable label for the key")
294
+ label: import_zod.z.string().min(1).max(100).optional().describe("Human-readable label for the key"),
295
+ expires_in: import_zod.z.enum(["30d", "60d", "90d", "180d", "365d"]).optional().describe("When the key stops working, from now. Omit for a key that never expires. After it expires, requests fail with 401 key_expired.")
280
296
  });
281
297
  var ListScopedKeysSchema = import_zod.z.object({});
282
298
  var RevokeScopedKeySchema = import_zod.z.object({
@@ -285,8 +301,14 @@ var RevokeScopedKeySchema = import_zod.z.object({
285
301
  var GetAuditLogSchema = import_zod.z.object({
286
302
  from: import_zod.z.string().datetime({ offset: true }).optional().describe("Start of the window (ISO 8601). Silently clamped to the plan retention window if older."),
287
303
  to: import_zod.z.string().datetime({ offset: true }).optional().describe("End of the window (ISO 8601)"),
288
- action: import_zod.z.string().min(1).max(64).optional().describe("Filter by action name (e.g. event.created)"),
304
+ action: import_zod.z.string().min(1).max(64).optional().describe("Filter by action name (e.g. event.create, agent_key.revoke). Legacy names are matched by their current names."),
289
305
  actor_key_prefix: import_zod.z.string().min(1).max(32).optional().describe("Filter by the API key prefix that performed the action"),
306
+ actor_type: import_zod.z.enum(["session", "org_key", "agent_key", "system"]).optional().describe("Filter by who acted: session (console), org_key, agent_key or system"),
307
+ actor_id: import_zod.z.string().min(1).max(64).optional().describe("Filter by actor id (an API key id, or the org id for console sessions)"),
308
+ request_id: import_zod.z.string().min(1).max(64).optional().describe("Filter by request id (the X-Request-Id of the original call)"),
309
+ resource: import_zod.z.string().max(64).regex(/^[a-z]{2,5}_[A-Za-z0-9_-]*$/).optional().describe("Filter by an entity id or id prefix the request touched (e.g. cal_abc123 or cal_)"),
310
+ status_class: import_zod.z.enum(["2xx", "3xx", "4xx", "5xx"]).optional().describe("Filter by response status class: 2xx, 3xx, 4xx or 5xx"),
311
+ category: import_zod.z.enum(["account", "keys", "agents", "calendars", "events", "scheduling", "webhooks", "human_calendars", "billing", "security"]).optional().describe("Filter by action category (e.g. keys, calendars, billing, security)"),
290
312
  cursor: import_zod.z.string().min(1).max(256).optional().describe("Opaque pagination cursor from a previous response"),
291
313
  limit: import_zod.z.number().int().min(1).max(200).optional().describe("Max results to return (default 50)")
292
314
  });
@@ -301,12 +323,12 @@ var GetWebhookSchema = import_zod.z.object({
301
323
  webhook_id: import_zod.z.string().describe("Webhook subscription to fetch")
302
324
  });
303
325
  var CreateWebhookSchema = import_zod.z.object({
304
- url: import_zod.z.string().url().describe("HTTPS endpoint that will receive event deliveries"),
326
+ url: import_zod.z.string().url().max(2048).describe("HTTPS endpoint that will receive event deliveries"),
305
327
  events: import_zod.z.array(import_zod.z.enum(WEBHOOK_EVENT_TYPES)).min(1).describe("Event types to subscribe to")
306
328
  });
307
329
  var UpdateWebhookSchema = import_zod.z.object({
308
330
  webhook_id: import_zod.z.string().describe("Webhook subscription to update"),
309
- url: import_zod.z.string().url().optional().describe("New HTTPS delivery endpoint"),
331
+ url: import_zod.z.string().url().max(2048).optional().describe("New HTTPS delivery endpoint"),
310
332
  events: import_zod.z.array(import_zod.z.enum(WEBHOOK_EVENT_TYPES)).min(1).optional().describe("Replacement set of event types to subscribe to"),
311
333
  active: import_zod.z.boolean().optional().describe("Set false to pause deliveries, true to resume")
312
334
  });
@@ -316,9 +338,27 @@ var DeleteWebhookSchema = import_zod.z.object({
316
338
  var ListWebhookDeliveriesSchema = import_zod.z.object({
317
339
  webhook_id: import_zod.z.string().describe("Webhook subscription whose deliveries to list"),
318
340
  limit: import_zod.z.number().int().min(1).max(100).default(20).describe("Max results to return"),
319
- offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset"),
341
+ offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset. Cannot be combined with cursor"),
320
342
  status: import_zod.z.enum(WEBHOOK_DELIVERY_STATUSES).optional().describe("Filter to a single delivery status"),
321
- include_payload: import_zod.z.boolean().optional().describe("Include the full event payload sent on each delivery")
343
+ include_payload: import_zod.z.boolean().optional().describe("Include the full event payload sent on each delivery"),
344
+ event_type: import_zod.z.string().max(100).regex(/^[a-z_]+\.(?:[a-z_]+)?$/).optional().describe("An exact event type (event.created), or a prefix ending in a dot (event.) for a whole group"),
345
+ created_after: import_zod.z.string().datetime().optional().describe("Only deliveries created at or after this time (ISO 8601, UTC)"),
346
+ created_before: import_zod.z.string().datetime().optional().describe("Only deliveries created before this time (ISO 8601, UTC)"),
347
+ delivery_id: import_zod.z.string().max(100).regex(/^whd_[A-Za-z0-9_-]+$/).optional().describe("Only the delivery with this id"),
348
+ is_test: import_zod.z.boolean().optional().describe("true for test events only, false to leave them out"),
349
+ cursor: import_zod.z.string().min(1).max(1024).optional().describe("The next_cursor from the previous page")
350
+ });
351
+ var GetWebhookDeliverySchema = import_zod.z.object({
352
+ webhook_id: import_zod.z.string().describe("Webhook subscription the delivery belongs to"),
353
+ delivery_id: import_zod.z.string().describe("Delivery ID (whd_...) from list_webhook_deliveries")
354
+ });
355
+ var SendTestWebhookSchema = import_zod.z.object({
356
+ webhook_id: import_zod.z.string().describe("Webhook subscription to send the test event to"),
357
+ event_type: import_zod.z.enum(WEBHOOK_EVENT_TYPES).describe("Event type whose sample payload to send")
358
+ });
359
+ var ReplayWebhookDeliverySchema = import_zod.z.object({
360
+ webhook_id: import_zod.z.string().describe("Webhook subscription the delivery belongs to"),
361
+ delivery_id: import_zod.z.string().describe("Delivery to replay (whd_...)")
322
362
  });
323
363
  var ListICalSubscriptionsSchema = import_zod.z.object({
324
364
  agent_id: import_zod.z.string().describe("Agent ID whose iCal subscriptions to list"),
@@ -332,13 +372,13 @@ var GetICalSubscriptionSchema = import_zod.z.object({
332
372
  var SubscribeICalSchema = import_zod.z.object({
333
373
  agent_id: import_zod.z.string().describe("Agent ID that will own this subscription"),
334
374
  calendar_id: import_zod.z.string().describe("Calendar ID to sync external events into"),
335
- url: import_zod.z.string().url().describe("HTTPS URL of the iCal feed (.ics) to subscribe to"),
375
+ url: import_zod.z.string().url().max(2048).describe("HTTPS URL of the iCal feed (.ics) to subscribe to"),
336
376
  label: import_zod.z.string().optional().describe("Optional label for this subscription")
337
377
  });
338
378
  var UpdateICalSubscriptionSchema = import_zod.z.object({
339
379
  subscription_id: import_zod.z.string().describe("iCal subscription ID to update"),
340
380
  label: import_zod.z.string().min(1).max(255).optional().describe("New label for this subscription"),
341
- url: import_zod.z.string().url().startsWith("https://", "URL must use HTTPS").optional().describe("New HTTPS URL of the iCal feed (.ics)")
381
+ url: import_zod.z.string().url().max(2048).refine((u) => u.startsWith("https://"), "URL must use HTTPS").optional().describe("New HTTPS URL of the iCal feed (.ics)")
342
382
  });
343
383
  var DeleteICalSubscriptionSchema = import_zod.z.object({
344
384
  subscription_id: import_zod.z.string().describe("iCal subscription ID to delete")
@@ -346,23 +386,53 @@ var DeleteICalSubscriptionSchema = import_zod.z.object({
346
386
  var SyncICalSubscriptionSchema = import_zod.z.object({
347
387
  subscription_id: import_zod.z.string().describe("iCal subscription ID to sync")
348
388
  });
389
+ var PauseICalSubscriptionSchema = import_zod.z.object({
390
+ subscription_id: import_zod.z.string().describe("iCal subscription ID to pause")
391
+ });
392
+ var ResumeICalSubscriptionSchema = import_zod.z.object({
393
+ subscription_id: import_zod.z.string().describe("iCal subscription ID to resume")
394
+ });
349
395
  var GetUsageSchema = import_zod.z.object({});
396
+ var GetUsageHistorySchema = import_zod.z.object({
397
+ months: import_zod.z.number().int().min(1).max(12).optional().describe("Number of UTC calendar months to return, 1-12 (default 6)")
398
+ });
399
+ var GetBillingSchema = import_zod.z.object({});
400
+ var RequestUpgradeSchema = import_zod.z.object({
401
+ interval: import_zod.z.enum(["month", "year"]).optional().describe("Billing interval to request. Defaults to month."),
402
+ reason: import_zod.z.string().max(500).optional().describe("Why the upgrade is needed (max 500 chars). Shown to your human as plain text."),
403
+ feature: import_zod.z.string().optional().describe("Plan-gated feature that was blocked, e.g. scoped_keys (from a plan_required error)."),
404
+ metric: import_zod.z.string().optional().describe("Quota metric that was exhausted, e.g. api_calls (from a quota_exceeded error).")
405
+ });
406
+ var GetUpgradeRequestSchema = import_zod.z.object({
407
+ id: import_zod.z.string().describe("Upgrade request ID (upr_...)")
408
+ });
409
+ var CancelUpgradeRequestSchema = GetUpgradeRequestSchema;
350
410
 
351
411
  // src/safe.ts
352
412
  var import_sdk = require("@chronary/sdk");
413
+ function toErrorPayload(err) {
414
+ if (err instanceof import_sdk.ChronaryError) {
415
+ const payload = {
416
+ error: err.errorType ?? err.name,
417
+ message: err.message
418
+ };
419
+ if (err.upgradeUrl !== void 0) payload.upgrade_url = err.upgradeUrl;
420
+ if (err.docsUrl !== void 0) payload.docs_url = err.docsUrl;
421
+ if (err.requiredPlan !== void 0) payload.required_plan = err.requiredPlan;
422
+ if (err.feature !== void 0) payload.feature = err.feature;
423
+ if (err.metric !== void 0) payload.metric = err.metric;
424
+ if (err.limit !== void 0) payload.limit = err.limit;
425
+ return payload;
426
+ }
427
+ return { error: "error", message: err instanceof Error ? err.message : String(err) };
428
+ }
353
429
  function safeFunc(fn) {
354
430
  return async (params) => {
355
431
  try {
356
432
  const result = await fn(params);
357
433
  return { result: result ?? { success: true }, isError: false };
358
434
  } catch (err) {
359
- if (err instanceof import_sdk.ChronaryError) {
360
- return { result: `${err.name}: ${err.message}`, isError: true };
361
- }
362
- return {
363
- result: `Error: ${err instanceof Error ? err.message : String(err)}`,
364
- isError: true
365
- };
435
+ return { result: toErrorPayload(err), isError: true };
366
436
  }
367
437
  };
368
438
  }
@@ -443,6 +513,21 @@ var listEvents = safeFunc(async (ctx) => {
443
513
  });
444
514
  return fetchPage(iter, params.offset, params.limit);
445
515
  });
516
+ var listOrgEvents = safeFunc(async (ctx) => {
517
+ const { client, params } = ctx;
518
+ const iter = client.events.listAll({
519
+ calendar_id: params.calendar_ids,
520
+ agent_id: params.agent_id,
521
+ start_after: params.start_after,
522
+ start_before: params.start_before,
523
+ status: params.status,
524
+ source: params.source,
525
+ q: params.q,
526
+ expand: params.expand,
527
+ limit: params.limit
528
+ });
529
+ return fetchPage(iter, params.offset, params.limit);
530
+ });
446
531
  var getEvent = safeFunc(async (ctx) => {
447
532
  const { calendar_id, event_id } = ctx.params;
448
533
  return calendar_id ? ctx.client.events.get(calendar_id, event_id) : ctx.client.events.getById(event_id);
@@ -614,6 +699,15 @@ var listWebhookDeliveries = safeFunc(async (ctx) => {
614
699
  const { webhook_id, ...query } = params;
615
700
  return client.webhooks.listDeliveries(webhook_id, query);
616
701
  });
702
+ var getWebhookDelivery = safeFunc(async (ctx) => {
703
+ return ctx.client.webhooks.getDelivery(ctx.params.webhook_id, ctx.params.delivery_id);
704
+ });
705
+ var sendTestWebhook = safeFunc(async (ctx) => {
706
+ return ctx.client.webhooks.sendTest(ctx.params.webhook_id, { event_type: ctx.params.event_type });
707
+ });
708
+ var replayWebhookDelivery = safeFunc(async (ctx) => {
709
+ return ctx.client.webhooks.replayDelivery(ctx.params.webhook_id, ctx.params.delivery_id);
710
+ });
617
711
  var getAuditLog = safeFunc(async (ctx) => {
618
712
  return ctx.client.auditLog.list(ctx.params);
619
713
  });
@@ -649,13 +743,49 @@ var deleteICalSubscription = safeFunc(async (ctx) => {
649
743
  var syncICalSubscription = safeFunc(async (ctx) => {
650
744
  return ctx.client.icalSubscriptions.sync(ctx.params.subscription_id);
651
745
  });
746
+ var pauseICalSubscription = safeFunc(async (ctx) => {
747
+ return ctx.client.icalSubscriptions.pause(ctx.params.subscription_id);
748
+ });
749
+ var resumeICalSubscription = safeFunc(async (ctx) => {
750
+ return ctx.client.icalSubscriptions.resume(ctx.params.subscription_id);
751
+ });
652
752
  var getUsage = safeFunc(async (ctx) => {
653
753
  return ctx.client.usage.get();
654
754
  });
755
+ var getUsageHistory = safeFunc(async (ctx) => {
756
+ return ctx.client.usage.history({ months: ctx.params.months });
757
+ });
758
+ var getBilling = safeFunc(async (ctx) => {
759
+ return ctx.client.billing.get();
760
+ });
761
+ var requestUpgrade = safeFunc(async (ctx) => {
762
+ return ctx.client.billing.upgradeRequests.create(ctx.params);
763
+ });
764
+ var getUpgradeRequest = safeFunc(async (ctx) => {
765
+ return ctx.client.billing.upgradeRequests.get(ctx.params.id);
766
+ });
767
+ var cancelUpgradeRequest = safeFunc(async (ctx) => {
768
+ return ctx.client.billing.upgradeRequests.cancel(ctx.params.id);
769
+ });
655
770
  function createExecutor(fn) {
656
771
  return (client, params) => fn({ client, params });
657
772
  }
658
773
 
774
+ // src/untrusted.ts
775
+ var EVENT_UNTRUSTED_FIELDS = ["title", "description", "metadata"];
776
+ var WEBHOOK_DELIVERY_UNTRUSTED_FIELDS = ["payload", "response_body"];
777
+ function withUntrustedFields(result, fields) {
778
+ const body = result.result;
779
+ if (result.isError || typeof body !== "object" || body === null || Array.isArray(body)) return result;
780
+ return { ...result, result: { untrusted_fields: [...fields], ...body } };
781
+ }
782
+ function markUntrusted(def) {
783
+ const fields = def.untrustedFields;
784
+ if (!fields || fields.length === 0) return def;
785
+ const execute = def.execute;
786
+ return { ...def, execute: async (client, params) => withUntrustedFields(await execute(client, params), fields) };
787
+ }
788
+
659
789
  // src/definitions.ts
660
790
  var HOSTED_API_MCP_TOOL_NAMES = [
661
791
  "create_agent",
@@ -663,6 +793,7 @@ var HOSTED_API_MCP_TOOL_NAMES = [
663
793
  "create_calendar",
664
794
  "create_event",
665
795
  "list_events",
796
+ "list_org_events",
666
797
  "get_event",
667
798
  "update_event",
668
799
  "get_availability",
@@ -679,6 +810,8 @@ var HOSTED_API_MCP_TOOL_NAMES = [
679
810
  "update_ical_subscription",
680
811
  "delete_ical_subscription",
681
812
  "sync_ical_subscription",
813
+ "pause_ical_subscription",
814
+ "resume_ical_subscription",
682
815
  "get_calendar_context",
683
816
  "create_proposal",
684
817
  "list_proposals",
@@ -698,6 +831,9 @@ var HOSTED_API_MCP_TOOL_NAMES = [
698
831
  "update_webhook",
699
832
  "delete_webhook",
700
833
  "list_webhook_deliveries",
834
+ "get_webhook_delivery",
835
+ "send_test_webhook",
836
+ "replay_webhook_delivery",
701
837
  "get_agent",
702
838
  "update_agent",
703
839
  "delete_agent",
@@ -710,21 +846,26 @@ var HOSTED_API_MCP_TOOL_NAMES = [
710
846
  "get_booking_page",
711
847
  "delete_booking_page",
712
848
  "get_usage",
849
+ "get_usage_history",
713
850
  "get_audit_log",
714
- "accept_terms"
851
+ "accept_terms",
852
+ "get_billing",
853
+ "request_upgrade",
854
+ "get_upgrade_request",
855
+ "cancel_upgrade_request"
715
856
  ];
716
- var TOOL_DEFINITIONS = [
857
+ var RAW_TOOL_DEFINITIONS = [
717
858
  // ── Calendars ──────────────────────────────────────────────────
718
859
  {
719
860
  name: "list_calendars",
720
- description: "List calendars in the org. Org-level API keys see every calendar (agent-owned and shared); agent-scoped keys see only their own agent's calendars. Use this to discover calendar IDs before creating or listing events.",
861
+ description: "List calendars in the org. Organization keys see every calendar (agent-owned and shared); Agent keys see only their own agent's calendars. Use this to discover calendar IDs before creating or listing events.",
721
862
  schema: ListCalendarsSchema,
722
863
  annotations: { title: "List Calendars", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
723
864
  execute: createExecutor(listCalendars)
724
865
  },
725
866
  {
726
867
  name: "get_calendar",
727
- description: "Fetch a single calendar by ID, including its name, timezone, agent status, and default reminders. Agent-scoped keys may only read calendars owned by their agent.",
868
+ description: "Fetch a single calendar by ID, including its name, timezone, agent status, and default reminders. Agent keys may only read calendars owned by their agent.",
728
869
  schema: GetCalendarSchema,
729
870
  annotations: { title: "Get Calendar", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
730
871
  execute: createExecutor(getCalendar)
@@ -738,14 +879,14 @@ var TOOL_DEFINITIONS = [
738
879
  },
739
880
  {
740
881
  name: "update_calendar",
741
- description: "Update a calendar's name, timezone, agent status, default reminders, or metadata. Agent-scoped keys may only update calendars owned by their agent.",
882
+ description: "Update a calendar's name, timezone, agent status, default reminders, or metadata. Agent keys may only update calendars owned by their agent.",
742
883
  schema: UpdateCalendarSchema,
743
884
  annotations: { title: "Update Calendar", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
744
885
  execute: createExecutor(updateCalendar)
745
886
  },
746
887
  {
747
888
  name: "delete_calendar",
748
- description: "Delete a calendar (soft delete). Its events are no longer returned and it stops contributing to availability. Agent-scoped keys may only delete calendars owned by their agent.",
889
+ description: "Delete a calendar (soft delete). Its events are no longer returned and it stops contributing to availability. Agent keys may only delete calendars owned by their agent.",
749
890
  schema: DeleteCalendarSchema,
750
891
  annotations: { title: "Delete Calendar", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
751
892
  execute: createExecutor(deleteCalendar)
@@ -760,7 +901,7 @@ var TOOL_DEFINITIONS = [
760
901
  },
761
902
  {
762
903
  name: "list_booking_pages",
763
- description: "List booking pages in the org. Agent-scoped keys see only pages on their own agent's calendars.",
904
+ description: "List booking pages in the org. Agent keys see only pages on their own agent's calendars.",
764
905
  schema: ListBookingPagesSchema,
765
906
  annotations: { title: "List Booking Pages", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
766
907
  execute: createExecutor(listBookingPages)
@@ -785,13 +926,23 @@ var TOOL_DEFINITIONS = [
785
926
  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`.",
786
927
  schema: ListEventsSchema,
787
928
  annotations: { title: "List Events", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
929
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
788
930
  execute: createExecutor(listEvents)
789
931
  },
932
+ {
933
+ name: "list_org_events",
934
+ description: "List events across all of the organization's calendars in one call, ordered by start time (an Agent key sees only its agent's calendars). Narrow with `calendar_ids`, `agent_id`, a `start_after`/`start_before` window, `status` and `source`. `q` searches titles (case-insensitive) and needs both window bounds at most 31 days apart. Use list_events for one calendar.",
935
+ schema: ListOrgEventsSchema,
936
+ annotations: { title: "List Organization Events", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
937
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
938
+ execute: createExecutor(listOrgEvents)
939
+ },
790
940
  {
791
941
  name: "get_event",
792
942
  description: "Retrieve a single event by ID, including its title, times, status, location, reminders, and metadata. Works for both internally created events and externally synced iCal events. `calendar_id` is optional \u2014 if omitted the calendar is resolved from the event. Provide `calendar_id` to fail fast on cross-calendar typos.",
793
943
  schema: GetEventSchema,
794
944
  annotations: { title: "Get Event", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
945
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
795
946
  execute: createExecutor(getEvent)
796
947
  },
797
948
  {
@@ -806,6 +957,7 @@ var TOOL_DEFINITIONS = [
806
957
  description: "Reschedule or edit an event \u2014 change its title, description, start/end times, location, status, reminders, or metadata. Use this to move an appointment to a new time or update its details. Provide only the fields you want to change. Holds cannot be edited via this tool (use confirm_event / release_event). External iCal events are read-only. `calendar_id` is optional \u2014 if omitted it is resolved from the event.",
807
958
  schema: UpdateEventSchema,
808
959
  annotations: { title: "Update Event", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
960
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
809
961
  execute: createExecutor(updateEvent)
810
962
  },
811
963
  {
@@ -813,6 +965,7 @@ var TOOL_DEFINITIONS = [
813
965
  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.",
814
966
  schema: CancelEventSchema,
815
967
  annotations: { title: "Cancel Event", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
968
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
816
969
  execute: createExecutor(cancelEvent)
817
970
  },
818
971
  {
@@ -820,6 +973,7 @@ var TOOL_DEFINITIONS = [
820
973
  description: 'Promote a held event to a confirmed booking. The event must currently have status="hold" and its hold_expires_at must not have passed. After confirmation, event.started and event.ended lifecycle webhooks fire at the scheduled times.',
821
974
  schema: ConfirmEventSchema,
822
975
  annotations: { title: "Confirm Event", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
976
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
823
977
  execute: createExecutor(confirmEvent)
824
978
  },
825
979
  {
@@ -846,21 +1000,21 @@ var TOOL_DEFINITIONS = [
846
1000
  },
847
1001
  {
848
1002
  name: "get_agent",
849
- description: "Fetch a single agent by ID. An agent represents an AI assistant, human, or shared resource (e.g. a meeting room). Agent-scoped API keys may only read their own agent.",
1003
+ description: "Fetch a single agent by ID. An agent represents an AI assistant, human, or shared resource (e.g. a meeting room). Agent keys may only read their own agent.",
850
1004
  schema: GetAgentSchema,
851
1005
  annotations: { title: "Get Agent", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
852
1006
  execute: createExecutor(getAgent)
853
1007
  },
854
1008
  {
855
1009
  name: "update_agent",
856
- description: "Update an agent's name, description, metadata, or status (active/paused). Requires an org-level API key \u2014 agent-scoped keys cannot mutate agents.",
1010
+ description: "Update an agent's name, description, metadata, or status (active/paused). Requires an Organization key \u2014 Agent keys cannot mutate agents.",
857
1011
  schema: UpdateAgentSchema,
858
1012
  annotations: { title: "Update Agent", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
859
1013
  execute: createExecutor(updateAgent)
860
1014
  },
861
1015
  {
862
1016
  name: "delete_agent",
863
- description: "Decommission an agent. This marks the agent as decommissioned and revokes all of its scoped API keys. Requires an org-level API key \u2014 agent-scoped keys cannot delete agents.",
1017
+ description: "Decommission an agent. This marks the agent as decommissioned and revokes all of its Agent keys. Requires an Organization key \u2014 Agent keys cannot delete agents.",
864
1018
  schema: DeleteAgentSchema,
865
1019
  annotations: { title: "Delete Agent", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
866
1020
  execute: createExecutor(deleteAgent)
@@ -882,21 +1036,21 @@ var TOOL_DEFINITIONS = [
882
1036
  },
883
1037
  {
884
1038
  name: "create_connection_link",
885
- description: "Request human setup of Google Calendar or Microsoft Outlook for a Chronary calendar. Give setup_url to a human; the agent never receives OAuth credentials, provider calendar names, or event data. The secret URL is returned only on first creation. If reused=true and setup_url is null, retain the original URL or cancel this link and create a replacement.",
1039
+ description: "Request human setup of Google Calendar or Microsoft Outlook for a Chronary calendar. Give setup_url to a human; the agent never receives OAuth credentials, provider calendar names, or event data. When the human finishes, the linked account becomes a Connection, listed under Human calendars in the Chronary console. The secret URL is returned only on first creation. If reused=true and setup_url is null, retain the original URL or cancel this link and create a replacement.",
886
1040
  schema: CreateConnectionLinkSchema,
887
1041
  annotations: { title: "Create Human Calendar Setup Link", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
888
1042
  execute: createExecutor(createConnectionLink)
889
1043
  },
890
1044
  {
891
1045
  name: "get_connection_link",
892
- description: "Poll a human-calendar setup request. Returns provider-neutral status and resulting connection ID when complete, but never replays the bearer setup URL or exposes human calendar data.",
1046
+ description: "Poll a human-calendar setup request. Returns provider-neutral status and, when complete, the ID of the resulting Connection (the human sees it under Human calendars in the Chronary console), but never replays the bearer setup URL or exposes human calendar data.",
893
1047
  schema: GetConnectionLinkSchema,
894
1048
  annotations: { title: "Get Human Calendar Setup Status", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
895
1049
  execute: createExecutor(getConnectionLink)
896
1050
  },
897
1051
  {
898
1052
  name: "cancel_connection_link",
899
- description: "Cancel a pending human-calendar setup request. This invalidates the setup URL and does not disconnect an already completed Google or Microsoft connection.",
1053
+ description: "Cancel a pending human-calendar setup request. This invalidates the setup URL and does not disconnect a Connection that was already completed; the human manages Connections under Human calendars in the Chronary console.",
900
1054
  schema: CancelConnectionLinkSchema,
901
1055
  annotations: { title: "Cancel Human Calendar Setup Link", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
902
1056
  execute: createExecutor(cancelConnectionLink)
@@ -907,47 +1061,48 @@ var TOOL_DEFINITIONS = [
907
1061
  description: `Get a calendar's temporal context in a single call: the current event (if one is happening now), the next upcoming event, recent past events, a short upcoming window, and the owning agent's status (idle/working/waiting/error). Use this to answer "what is this agent doing right now?" without issuing multiple list_events queries.`,
908
1062
  schema: GetCalendarContextSchema,
909
1063
  annotations: { title: "Get Calendar Context", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1064
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
910
1065
  execute: createExecutor(getCalendarContext)
911
1066
  },
912
1067
  // ── Scheduling proposals ───────────────────────────────────────
913
1068
  {
914
1069
  name: "create_proposal",
915
- description: "Create a scheduling proposal \u2014 send a set of candidate time slots to one or more participant agents so they can accept, decline, or counter-propose. The organizer agent owns the proposal; once every participant responds, the system auto-resolves to the highest-scoring slot (or cancels if all decline). Requires an org-level API key. Pro plan only.",
1070
+ description: "Create a scheduling proposal \u2014 send a set of candidate time slots to one or more participant agents so they can accept, decline, or counter-propose. The organizer agent owns the proposal; once every participant responds, the system auto-resolves to the highest-scoring slot (or cancels if all decline). Requires an Organization key. Pro plan only.",
916
1071
  schema: CreateProposalSchema,
917
1072
  annotations: { title: "Create Proposal", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
918
1073
  execute: createExecutor(createProposal)
919
1074
  },
920
1075
  {
921
1076
  name: "list_proposals",
922
- description: "List scheduling proposals for the org. Filter by status (pending|confirmed|expired|cancelled) or organizer_agent_id. Requires an org-level API key.",
1077
+ description: "List scheduling proposals for the org. Filter by status (pending|confirmed|expired|cancelled) or organizer_agent_id. Requires an Organization key.",
923
1078
  schema: ListProposalsSchema,
924
1079
  annotations: { title: "List Proposals", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
925
1080
  execute: createExecutor(listProposals)
926
1081
  },
927
1082
  {
928
1083
  name: "get_proposal",
929
- description: "Get a scheduling proposal by id, including its slots and per-participant responses. Requires an org-level API key.",
1084
+ description: "Get a scheduling proposal by id, including its slots and per-participant responses. Requires an Organization key.",
930
1085
  schema: GetProposalSchema,
931
1086
  annotations: { title: "Get Proposal", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
932
1087
  execute: createExecutor(getProposal)
933
1088
  },
934
1089
  {
935
1090
  name: "respond_to_proposal",
936
- description: 'Submit a response (accept / decline / counter) on behalf of one participant agent to an open proposal. An "accept" requires the slot id from the proposal; a "counter" can suggest alternative slots. When all participants have responded the proposal auto-resolves \u2014 no separate resolve call needed in the normal flow. Requires an org-level API key. Pro plan only.',
1091
+ description: 'Submit a response (accept / decline / counter) on behalf of one participant agent to an open proposal. An "accept" requires the slot id from the proposal; a "counter" can suggest alternative slots. When all participants have responded the proposal auto-resolves \u2014 no separate resolve call needed in the normal flow. Requires an Organization key. Pro plan only.',
937
1092
  schema: RespondToProposalSchema,
938
1093
  annotations: { title: "Respond To Proposal", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
939
1094
  execute: createExecutor(respondToProposal)
940
1095
  },
941
1096
  {
942
1097
  name: "resolve_proposal",
943
- description: 'Force-resolve an open proposal using responses collected so far. Picks the highest-scoring slot among those accepted by the most participants and creates a confirmed calendar event. If every response was "decline", the proposal is cancelled instead. Use when you want to close out a proposal without waiting for every participant. Requires an org-level API key. Pro plan only.',
1098
+ description: 'Force-resolve an open proposal using responses collected so far. Picks the highest-scoring slot among those accepted by the most participants and creates a confirmed calendar event. If every response was "decline", the proposal is cancelled instead. Use when you want to close out a proposal without waiting for every participant. Requires an Organization key. Pro plan only.',
944
1099
  schema: ResolveProposalSchema,
945
1100
  annotations: { title: "Resolve Proposal", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
946
1101
  execute: createExecutor(resolveProposal)
947
1102
  },
948
1103
  {
949
1104
  name: "cancel_proposal",
950
- description: 'Cancel an open proposal. Fires a proposal.cancelled webhook with reason="organizer_cancelled". Requires an org-level API key. Pro plan only.',
1105
+ description: 'Cancel an open proposal. Fires a proposal.cancelled webhook with reason="organizer_cancelled". Requires an Organization key. Pro plan only.',
951
1106
  schema: CancelProposalSchema,
952
1107
  annotations: { title: "Cancel Proposal", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
953
1108
  execute: createExecutor(cancelProposal)
@@ -977,46 +1132,69 @@ var TOOL_DEFINITIONS = [
977
1132
  // ── Webhooks ───────────────────────────────────────────────────
978
1133
  {
979
1134
  name: "list_webhooks",
980
- description: "List the org's webhook subscriptions with their subscribed event types and active state. Signing secrets are never returned. Requires an org-level API key.",
1135
+ description: "List the org's webhook subscriptions with their subscribed event types and active state. Signing secrets are never returned. Requires an Organization key.",
981
1136
  schema: ListWebhooksSchema,
982
1137
  annotations: { title: "List Webhooks", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
983
1138
  execute: createExecutor(listWebhooks)
984
1139
  },
985
1140
  {
986
1141
  name: "get_webhook",
987
- description: "Get a single webhook subscription by id, including its subscribed event types and active state. The signing secret is never returned. Requires an org-level API key.",
1142
+ description: "Get a single webhook subscription by id, including its subscribed event types and active state. The signing secret is never returned. Requires an Organization key.",
988
1143
  schema: GetWebhookSchema,
989
1144
  annotations: { title: "Get Webhook", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
990
1145
  execute: createExecutor(getWebhook)
991
1146
  },
992
1147
  {
993
1148
  name: "create_webhook",
994
- description: "Create a webhook subscription so the org receives HTTP POST notifications when events occur (e.g. event.created, proposal.confirmed). The signing secret is returned ONCE in this response \u2014 store it to verify the HMAC-SHA256 signature on delivered payloads. Requires an org-level API key.",
1149
+ description: "Create a webhook subscription so the org receives HTTP POST notifications when events occur (e.g. event.created, proposal.confirmed). The signing secret is returned ONCE in this response \u2014 store it to verify the HMAC-SHA256 signature on delivered payloads. Requires an Organization key.",
995
1150
  schema: CreateWebhookSchema,
996
- annotations: { title: "Create Webhook", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
1151
+ annotations: { title: "Create Webhook", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
997
1152
  execute: createExecutor(createWebhook)
998
1153
  },
999
1154
  {
1000
1155
  name: "update_webhook",
1001
- description: "Update a webhook subscription \u2014 change its delivery URL, the set of subscribed event types, or pause/resume it via active. At least one field must be supplied. Requires an org-level API key.",
1156
+ description: "Update a webhook subscription \u2014 change its delivery URL, the set of subscribed event types, or pause/resume it via active. At least one field must be supplied. Requires an Organization key.",
1002
1157
  schema: UpdateWebhookSchema,
1003
- annotations: { title: "Update Webhook", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1158
+ annotations: { title: "Update Webhook", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true },
1004
1159
  execute: createExecutor(updateWebhook)
1005
1160
  },
1006
1161
  {
1007
1162
  name: "delete_webhook",
1008
- description: "Permanently delete a webhook subscription. This frees its endpoint slot against the per-plan cap. Requires an org-level API key.",
1163
+ description: "Permanently delete a webhook subscription. This frees its endpoint slot against the per-plan cap. Requires an Organization key.",
1009
1164
  schema: DeleteWebhookSchema,
1010
1165
  annotations: { title: "Delete Webhook", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
1011
1166
  execute: createExecutor(deleteWebhook)
1012
1167
  },
1013
1168
  {
1014
1169
  name: "list_webhook_deliveries",
1015
- description: "List delivery attempts for a webhook subscription, with per-status counts (pending/delivered/failed). Use this to debug failing deliveries. Requires an org-level API key.",
1170
+ description: "List delivery attempts for a webhook subscription, newest first, with per-status counts (pending/delivered/failed/dropped). Filter by status, event type, creation time, delivery id or test flag, and page with next_cursor. `dropped` deliveries were stopped by the Free plan monthly limit. Use this to debug failing deliveries. Requires an Organization key.",
1016
1171
  schema: ListWebhookDeliveriesSchema,
1017
1172
  annotations: { title: "List Webhook Deliveries", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1173
+ untrustedFields: WEBHOOK_DELIVERY_UNTRUSTED_FIELDS,
1018
1174
  execute: createExecutor(listWebhookDeliveries)
1019
1175
  },
1176
+ {
1177
+ name: "get_webhook_delivery",
1178
+ description: "Get one webhook delivery with its payload and every attempt, oldest first: HTTP status, duration, the first 2 KB of the response body and an error code (timeout, connection_error, tls_error, redirect_not_followed, unsafe_destination_url, non_2xx). Use this to find out why a delivery failed. Requires an Organization key.",
1179
+ schema: GetWebhookDeliverySchema,
1180
+ annotations: { title: "Get Webhook Delivery", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1181
+ untrustedFields: WEBHOOK_DELIVERY_UNTRUSTED_FIELDS,
1182
+ execute: createExecutor(getWebhookDelivery)
1183
+ },
1184
+ {
1185
+ name: "send_test_webhook",
1186
+ description: "Send a signed sample payload of one event type to a webhook endpoint, to check that it receives and verifies deliveries. The delivery is marked is_test, carries the X-Chronary-Test: 1 header, makes one attempt, does not count toward the monthly delivery quota and is sent even when the endpoint is paused or disabled. The endpoint must subscribe to the event type. Poll get_webhook_delivery with the returned delivery_id for the result. Limited to 10 per minute. Requires an Organization key.",
1187
+ schema: SendTestWebhookSchema,
1188
+ annotations: { title: "Send Test Webhook", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
1189
+ execute: createExecutor(sendTestWebhook)
1190
+ },
1191
+ {
1192
+ name: "replay_webhook_delivery",
1193
+ description: "Send a failed or dropped webhook delivery again, as a new delivery with a new delivery_id. The stored payload goes out unchanged (same event id), signed with the endpoint's current secret, with an X-Chronary-Replay-Of header naming the original delivery. Only failed or dropped deliveries that are not test events can be replayed, the endpoint must be active, and the payload must still be stored (30 days). The replay follows the normal retry schedule and counts toward the monthly delivery quota. Poll get_webhook_delivery with the returned delivery_id for the result. Limited to 30 per minute. Requires a Developer or Pro plan and an Organization key.",
1194
+ schema: ReplayWebhookDeliverySchema,
1195
+ annotations: { title: "Replay Webhook Delivery", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
1196
+ execute: createExecutor(replayWebhookDelivery)
1197
+ },
1020
1198
  // ── iCal Subscriptions ─────────────────────────────────────────
1021
1199
  {
1022
1200
  name: "list_ical_subscriptions",
@@ -1043,7 +1221,7 @@ var TOOL_DEFINITIONS = [
1043
1221
  name: "update_ical_subscription",
1044
1222
  description: "Update an external iCal feed subscription \u2014 change its label or its feed URL. Changing the URL forces a full re-sync on the next poll.",
1045
1223
  schema: UpdateICalSubscriptionSchema,
1046
- annotations: { title: "Update iCal Subscription", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1224
+ annotations: { title: "Update iCal Subscription", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
1047
1225
  execute: createExecutor(updateICalSubscription)
1048
1226
  },
1049
1227
  {
@@ -1055,29 +1233,43 @@ var TOOL_DEFINITIONS = [
1055
1233
  },
1056
1234
  {
1057
1235
  name: "sync_ical_subscription",
1058
- description: "Trigger an immediate sync of an external iCal feed subscription instead of waiting for the next scheduled poll. Returns once the sync has been queued.",
1236
+ description: 'Start an immediate fetch of an external iCal feed instead of waiting for the next scheduled poll. Returns {"status":"syncing"} as soon as the fetch has started; call get_ical_subscription a few seconds later to read last_synced_at and last_error. A paused feed must be resumed first; one manual sync per feed per minute.',
1059
1237
  schema: SyncICalSubscriptionSchema,
1060
1238
  annotations: { title: "Sync iCal Subscription", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
1061
1239
  execute: createExecutor(syncICalSubscription)
1062
1240
  },
1241
+ {
1242
+ name: "pause_ical_subscription",
1243
+ description: "Pause an external iCal feed subscription: scheduled polls skip it and manual syncs are refused until it is resumed. Busy blocks already imported stay. Pausing a paused feed changes nothing. Returns the subscription.",
1244
+ schema: PauseICalSubscriptionSchema,
1245
+ annotations: { title: "Pause iCal Subscription", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1246
+ execute: createExecutor(pauseICalSubscription)
1247
+ },
1248
+ {
1249
+ name: "resume_ical_subscription",
1250
+ description: "Resume a paused or failing external iCal feed subscription: it returns to scheduled polling and its last_error is cleared. Resuming an active feed changes nothing. Returns the subscription.",
1251
+ schema: ResumeICalSubscriptionSchema,
1252
+ annotations: { title: "Resume iCal Subscription", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1253
+ execute: createExecutor(resumeICalSubscription)
1254
+ },
1063
1255
  // ── Scoped keys ────────────────────────────────────────────────
1064
1256
  {
1065
1257
  name: "create_scoped_key",
1066
- description: "Create an agent-scoped API key (chr_ak_*) that can only act on behalf of a single agent. Use this to self-provision or rotate per-agent credentials. The plaintext key is returned exactly once in the response \u2014 store it immediately, it cannot be retrieved later. Requires an org-level API key.",
1258
+ description: "Create an Agent key (chr_ak_*) that can only act on behalf of a single agent. Use this to self-provision or rotate per-agent credentials. The plaintext key is returned exactly once in the response \u2014 store it immediately, it cannot be retrieved later. Requires an Organization key.",
1067
1259
  schema: CreateScopedKeySchema,
1068
1260
  annotations: { title: "Create Scoped Key", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
1069
1261
  execute: createExecutor(createScopedKey)
1070
1262
  },
1071
1263
  {
1072
1264
  name: "list_scoped_keys",
1073
- description: "List all live (non-revoked) agent-scoped API keys for this org. Returns key metadata only (id, prefix, agent_id, label, created_at) \u2014 never the plaintext secret. Requires an org-level API key.",
1265
+ description: "List all live (non-revoked) Agent keys for this org. Returns key metadata only (id, prefix, agent_id, label, created_at) \u2014 never the plaintext secret. Requires an Organization key.",
1074
1266
  schema: ListScopedKeysSchema,
1075
1267
  annotations: { title: "List Scoped Keys", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1076
1268
  execute: createExecutor(listScopedKeys)
1077
1269
  },
1078
1270
  {
1079
1271
  name: "revoke_scoped_key",
1080
- 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.",
1272
+ description: "Revoke an Agent key by ID. Revocation is permanent (cannot be un-revoked); the key stops authenticating within about a minute. Requires an Organization key.",
1081
1273
  schema: RevokeScopedKeySchema,
1082
1274
  annotations: { title: "Revoke Scoped Key", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
1083
1275
  execute: createExecutor(revokeScopedKey)
@@ -1085,7 +1277,7 @@ var TOOL_DEFINITIONS = [
1085
1277
  // ── Audit log ──────────────────────────────────────────────────
1086
1278
  {
1087
1279
  name: "get_audit_log",
1088
- description: "List audit-log entries for the calling org \u2014 mutating operations and auth-lifecycle events, newest first. Results are clamped to the plan's retention window. Requires an org-level API key (chr_sk_*); agent-scoped keys cannot read the org-wide audit log.",
1280
+ description: "List audit-log entries for the calling org \u2014 mutating operations and auth-lifecycle events, newest first. Results are clamped to the plan's retention window. Requires an Organization key (chr_sk_*); Agent keys cannot read the org-wide audit log.",
1089
1281
  schema: GetAuditLogSchema,
1090
1282
  annotations: { title: "Get Audit Log", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1091
1283
  execute: createExecutor(getAuditLog)
@@ -1093,7 +1285,7 @@ var TOOL_DEFINITIONS = [
1093
1285
  // ── Terms ──────────────────────────────────────────────────────
1094
1286
  {
1095
1287
  name: "accept_terms",
1096
- description: "Re-accept the current Chronary terms of service on behalf of the calling org. Use this when responses carry the Chronary-Terms-Upgrade-Required header \u2014 a material ToS bump otherwise leaves MCP-only agents stuck without a console session. Pass the current tos_version (read it from GET /v1/auth/terms/current). Requires an org-level API key (chr_sk_*); agent-scoped keys cannot accept org-wide terms.",
1288
+ description: "Re-accept the current Chronary terms of service on behalf of the calling org. Use this when responses carry the Chronary-Terms-Upgrade-Required header \u2014 a material ToS bump otherwise leaves MCP-only agents stuck without a console session. Pass the current tos_version (read it from GET /v1/auth/terms/current). Requires an Organization key (chr_sk_*); Agent keys cannot accept org-wide terms.",
1097
1289
  schema: AcceptTermsSchema,
1098
1290
  annotations: { title: "Accept Terms", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1099
1291
  execute: createExecutor(acceptTerms)
@@ -1101,12 +1293,49 @@ var TOOL_DEFINITIONS = [
1101
1293
  // ── Usage ──────────────────────────────────────────────────────
1102
1294
  {
1103
1295
  name: "get_usage",
1104
- description: "Get the calling org's current-period usage and plan limits (agents, calendars, events, API calls, webhooks, availability queries, iCal subscriptions, proposals, scoped keys, holds, cross-calendar queries). Requires an org-level API key (chr_sk_*); agent-scoped keys cannot read org-wide usage.",
1296
+ description: "Get the calling org's current-period usage and plan limits (agents, calendars, events, API calls, webhook deliveries, webhook endpoints, availability queries, iCal subscriptions, proposals, recurring events, booking pages, scoped keys, holds, cross-calendar queries) and when the monthly counters reset (resets_at, 00:00 UTC on the 1st). Requires an Organization key (chr_sk_*); Agent keys cannot read org-wide usage.",
1105
1297
  schema: GetUsageSchema,
1106
1298
  annotations: { title: "Get Usage", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1107
1299
  execute: createExecutor(getUsage)
1300
+ },
1301
+ {
1302
+ name: "get_usage_history",
1303
+ description: "Get the calling org's monthly usage totals for the last 1-12 UTC calendar months (default 6), oldest first, ending with the current partial month. Each month lists every monthly counter (api_calls, events, webhook_deliveries, availability_queries, proposals, holds_created, holds_confirmed, holds_expired, cross_calendar_queries); limits are the current plan's (null = unlimited). Requires an Organization key (chr_sk_*); Agent keys cannot read org-wide usage.",
1304
+ schema: GetUsageHistorySchema,
1305
+ annotations: { title: "Get Usage History", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1306
+ execute: createExecutor(getUsageHistory)
1307
+ },
1308
+ // ── Billing ────────────────────────────────────────────────────
1309
+ {
1310
+ name: "get_billing",
1311
+ description: "Get the org's plan and billing status: plan, subscription status, renewal/cancellation dates, upgrade options, and any pending upgrade request. Read-only \u2014 agents cannot pay, cancel, or change payment methods. Requires an Organization key (chr_sk_*).",
1312
+ schema: GetBillingSchema,
1313
+ annotations: { title: "Get Billing", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1314
+ execute: createExecutor(getBilling)
1315
+ },
1316
+ {
1317
+ name: "request_upgrade",
1318
+ description: "Ask your human to upgrade this Chronary account to Pro. Returns approval_url \u2014 give it to your human; only a human can pay. If reused=true a request is already pending \u2014 do not call again; poll get_upgrade_request at most once a minute. The link opens the Billing page in the Chronary console.",
1319
+ schema: RequestUpgradeSchema,
1320
+ annotations: { title: "Request Upgrade", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1321
+ execute: createExecutor(requestUpgrade)
1322
+ },
1323
+ {
1324
+ name: "get_upgrade_request",
1325
+ description: "Poll an upgrade request by ID. status is pending, completed, declined, canceled, or expired. Poll at most once a minute; after completed, retry the blocked call about 15 seconds later. Requires an Organization key (chr_sk_*).",
1326
+ schema: GetUpgradeRequestSchema,
1327
+ annotations: { title: "Get Upgrade Request", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1328
+ execute: createExecutor(getUpgradeRequest)
1329
+ },
1330
+ {
1331
+ name: "cancel_upgrade_request",
1332
+ description: "Withdraw a pending upgrade request (for example, the blocker went away). The approval URL stops working. Fails with upgrade_request_not_pending if the request is already completed, declined, canceled, or expired.",
1333
+ schema: CancelUpgradeRequestSchema,
1334
+ annotations: { title: "Cancel Upgrade Request", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1335
+ execute: createExecutor(cancelUpgradeRequest)
1108
1336
  }
1109
1337
  ];
1338
+ var TOOL_DEFINITIONS = RAW_TOOL_DEFINITIONS.map(markUntrusted);
1110
1339
  var toolkitToolNames = new Set(TOOL_DEFINITIONS.map((tool) => tool.name));
1111
1340
  var hostedToolNames = new Set(HOSTED_API_MCP_TOOL_NAMES);
1112
1341
  var TOOLKIT_MCP_PARITY = {