@chronary/toolkit 1.5.3 → 1.6.2

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 +23 -0
  2. package/README.md +2 -2
  3. package/dist/ai-sdk.cjs +292 -63
  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 +292 -63
  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 +337 -65
  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 +332 -64
  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 +291 -62
  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 +291 -62
  24. package/dist/langchain.js.map +1 -1
  25. package/dist/mastra.cjs +292 -63
  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 +292 -63
  30. package/dist/mastra.js.map +1 -1
  31. package/dist/mcp.cjs +314 -69
  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 +312 -68
  36. package/dist/mcp.js.map +1 -1
  37. package/dist/openai.cjs +291 -62
  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 +291 -62
  42. package/dist/openai.js.map +1 -1
  43. package/package.json +4 -4
@@ -47,12 +47,15 @@ var WEBHOOK_EVENT_TYPES = [
47
47
  "proposal.confirmed",
48
48
  "proposal.expired",
49
49
  "proposal.cancelled",
50
- "webhook.deactivated"
50
+ "webhook.deactivated",
51
+ "org.plan_changed",
52
+ "calendar_connection.reauthorization_required",
53
+ "usage.threshold_crossed"
51
54
  ];
52
- var WEBHOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed"];
55
+ var WEBHOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed", "dropped"];
53
56
  var ListCalendarsSchema = import_zod.z.object({
54
- 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
- include: import_zod.z.enum(["all"]).optional().describe('Pass "all" to include calendars across all agents (org keys only)'),
57
+ 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."),
58
+ include: import_zod.z.enum(["all"]).optional().describe('Pass "all" to include calendars across all agents (Organization keys only)'),
56
59
  limit: import_zod.z.number().int().min(1).max(200).default(50).describe("Max results to return"),
57
60
  offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset")
58
61
  });
@@ -62,13 +65,13 @@ var GetCalendarSchema = import_zod.z.object({
62
65
  var CreateCalendarSchema = import_zod.z.object({
63
66
  name: import_zod.z.string().min(1).max(255).describe("Calendar name"),
64
67
  agent_id: import_zod.z.string().optional().describe("Agent ID to own this calendar (omit for org-level)"),
65
- timezone: import_zod.z.string().min(1).describe("IANA timezone (e.g. America/New_York)"),
68
+ timezone: import_zod.z.string().min(1).max(64).describe("IANA timezone (e.g. America/New_York)"),
66
69
  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.")
67
70
  });
68
71
  var UpdateCalendarSchema = import_zod.z.object({
69
72
  calendar_id: import_zod.z.string().describe("Calendar ID to update"),
70
73
  name: import_zod.z.string().min(1).max(255).optional().describe("New calendar name"),
71
- timezone: import_zod.z.string().min(1).optional().describe("New IANA timezone (e.g. America/New_York)"),
74
+ timezone: import_zod.z.string().min(1).max(64).optional().describe("New IANA timezone (e.g. America/New_York)"),
72
75
  agent_status: import_zod.z.enum(["idle", "working", "waiting", "error"]).optional().describe("Owning agent's status"),
73
76
  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"),
74
77
  metadata: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional().describe("Arbitrary metadata (max 16KB)")
@@ -109,6 +112,18 @@ var ListEventsSchema = import_zod.z.object({
109
112
  offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset"),
110
113
  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.")
111
114
  });
115
+ var ListOrgEventsSchema = import_zod.z.object({
116
+ calendar_ids: import_zod.z.array(import_zod.z.string()).max(50).optional().describe("Only these calendar IDs (at most 50)"),
117
+ agent_id: import_zod.z.string().optional().describe("Only this agent's calendars"),
118
+ start_after: import_zod.z.string().datetime().optional().describe("Only events starting at or after this ISO 8601 time"),
119
+ start_before: import_zod.z.string().datetime().optional().describe("Only events starting at or before this ISO 8601 time"),
120
+ status: import_zod.z.enum(["confirmed", "tentative", "cancelled", "hold"]).optional().describe("Filter by event status"),
121
+ 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)'),
122
+ q: import_zod.z.string().optional().describe("Case-insensitive title search. Requires start_after and start_before at most 31 days apart"),
123
+ 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)."),
124
+ limit: import_zod.z.number().int().min(1).max(100).default(50).describe("Max results to return (1-100)"),
125
+ offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset")
126
+ });
112
127
  var GetEventSchema = import_zod.z.object({
113
128
  event_id: import_zod.z.string().describe("Event ID to retrieve"),
114
129
  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.")
@@ -118,19 +133,19 @@ var CreateEventSchema = import_zod.z.object({
118
133
  title: import_zod.z.string().min(1).max(500).describe("Event title"),
119
134
  start_time: import_zod.z.string().datetime().describe("Start time (ISO 8601)"),
120
135
  end_time: import_zod.z.string().datetime().describe("End time (ISO 8601)"),
121
- description: import_zod.z.string().optional().describe("Optional event description"),
136
+ description: import_zod.z.string().max(1e4).optional().describe("Optional event description"),
122
137
  all_day: import_zod.z.boolean().default(false).describe("Whether this is an all-day event"),
123
138
  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".'),
124
139
  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."),
125
140
  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.'),
126
141
  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.'),
127
- 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.')
142
+ 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: 1 recurring series, must end within 90 days.')
128
143
  });
129
144
  var UpdateEventSchema = import_zod.z.object({
130
145
  event_id: import_zod.z.string().describe("Event ID to update"),
131
146
  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."),
132
147
  title: import_zod.z.string().min(1).max(500).optional().describe("New event title"),
133
- description: import_zod.z.string().nullable().optional().describe("New description, or null to clear it"),
148
+ description: import_zod.z.string().max(1e4).nullable().optional().describe("New description, or null to clear it"),
134
149
  start_time: import_zod.z.string().datetime().optional().describe("New start time (ISO 8601)"),
135
150
  end_time: import_zod.z.string().datetime().optional().describe("New end time (ISO 8601)"),
136
151
  all_day: import_zod.z.boolean().optional().describe("Whether this is an all-day event"),
@@ -153,7 +168,7 @@ var ReleaseEventSchema = import_zod.z.object({
153
168
  var CreateAgentSchema = import_zod.z.object({
154
169
  name: import_zod.z.string().min(1).max(255).describe("Display name for the agent"),
155
170
  type: import_zod.z.enum(["ai", "human", "resource"]).describe("Agent type"),
156
- description: import_zod.z.string().optional().describe("Optional description")
171
+ description: import_zod.z.string().max(5e3).optional().describe("Optional description")
157
172
  });
158
173
  var ListAgentsSchema = import_zod.z.object({
159
174
  type: import_zod.z.enum(["ai", "human", "resource"]).optional().describe("Filter by agent type"),
@@ -167,7 +182,7 @@ var GetAgentSchema = import_zod.z.object({
167
182
  var UpdateAgentSchema = import_zod.z.object({
168
183
  agent_id: import_zod.z.string().describe("Agent ID to update"),
169
184
  name: import_zod.z.string().min(1).max(255).optional().describe("New display name"),
170
- description: import_zod.z.string().nullable().optional().describe("New description (null to clear)"),
185
+ description: import_zod.z.string().max(5e3).nullable().optional().describe("New description (null to clear)"),
171
186
  metadata: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional().describe("Arbitrary metadata (max 16KB)"),
172
187
  status: import_zod.z.enum(["active", "paused"]).optional().describe("Operational status")
173
188
  });
@@ -224,7 +239,7 @@ var CreateProposalSchema = import_zod.z.object({
224
239
  expires_at: import_zod.z.string().datetime().optional().describe("Auto-cancel cutoff if unresolved")
225
240
  });
226
241
  var ListProposalsSchema = import_zod.z.object({
227
- status: import_zod.z.enum(["pending", "confirmed", "expired", "cancelled"]).optional().describe("Filter by proposal status"),
242
+ status: import_zod.z.enum(["pending", "resolving", "confirmed", "expired", "cancelled"]).optional().describe("Filter by proposal status"),
228
243
  organizer_agent_id: import_zod.z.string().optional().describe("Filter by organizer agent"),
229
244
  limit: import_zod.z.number().int().min(1).max(200).optional().describe("Max results (default 50)"),
230
245
  offset: import_zod.z.number().int().min(0).optional().describe("Pagination offset (default 0)")
@@ -275,7 +290,8 @@ var ClearAvailabilityRulesSchema = import_zod.z.object({
275
290
  });
276
291
  var CreateScopedKeySchema = import_zod.z.object({
277
292
  agent_id: import_zod.z.string().regex(/^agt_/).describe("Agent ID this key is scoped to"),
278
- label: import_zod.z.string().min(1).max(100).optional().describe("Human-readable label for the key")
293
+ label: import_zod.z.string().min(1).max(100).optional().describe("Human-readable label for the key"),
294
+ 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.")
279
295
  });
280
296
  var ListScopedKeysSchema = import_zod.z.object({});
281
297
  var RevokeScopedKeySchema = import_zod.z.object({
@@ -284,8 +300,14 @@ var RevokeScopedKeySchema = import_zod.z.object({
284
300
  var GetAuditLogSchema = import_zod.z.object({
285
301
  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."),
286
302
  to: import_zod.z.string().datetime({ offset: true }).optional().describe("End of the window (ISO 8601)"),
287
- action: import_zod.z.string().min(1).max(64).optional().describe("Filter by action name (e.g. event.created)"),
303
+ 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."),
288
304
  actor_key_prefix: import_zod.z.string().min(1).max(32).optional().describe("Filter by the API key prefix that performed the action"),
305
+ 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"),
306
+ 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)"),
307
+ request_id: import_zod.z.string().min(1).max(64).optional().describe("Filter by request id (the X-Request-Id of the original call)"),
308
+ 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_)"),
309
+ status_class: import_zod.z.enum(["2xx", "3xx", "4xx", "5xx"]).optional().describe("Filter by response status class: 2xx, 3xx, 4xx or 5xx"),
310
+ 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)"),
289
311
  cursor: import_zod.z.string().min(1).max(256).optional().describe("Opaque pagination cursor from a previous response"),
290
312
  limit: import_zod.z.number().int().min(1).max(200).optional().describe("Max results to return (default 50)")
291
313
  });
@@ -300,12 +322,12 @@ var GetWebhookSchema = import_zod.z.object({
300
322
  webhook_id: import_zod.z.string().describe("Webhook subscription to fetch")
301
323
  });
302
324
  var CreateWebhookSchema = import_zod.z.object({
303
- url: import_zod.z.string().url().describe("HTTPS endpoint that will receive event deliveries"),
325
+ url: import_zod.z.string().url().max(2048).describe("HTTPS endpoint that will receive event deliveries"),
304
326
  events: import_zod.z.array(import_zod.z.enum(WEBHOOK_EVENT_TYPES)).min(1).describe("Event types to subscribe to")
305
327
  });
306
328
  var UpdateWebhookSchema = import_zod.z.object({
307
329
  webhook_id: import_zod.z.string().describe("Webhook subscription to update"),
308
- url: import_zod.z.string().url().optional().describe("New HTTPS delivery endpoint"),
330
+ url: import_zod.z.string().url().max(2048).optional().describe("New HTTPS delivery endpoint"),
309
331
  events: import_zod.z.array(import_zod.z.enum(WEBHOOK_EVENT_TYPES)).min(1).optional().describe("Replacement set of event types to subscribe to"),
310
332
  active: import_zod.z.boolean().optional().describe("Set false to pause deliveries, true to resume")
311
333
  });
@@ -315,9 +337,27 @@ var DeleteWebhookSchema = import_zod.z.object({
315
337
  var ListWebhookDeliveriesSchema = import_zod.z.object({
316
338
  webhook_id: import_zod.z.string().describe("Webhook subscription whose deliveries to list"),
317
339
  limit: import_zod.z.number().int().min(1).max(100).default(20).describe("Max results to return"),
318
- offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset"),
340
+ offset: import_zod.z.number().int().min(0).default(0).describe("Pagination offset. Cannot be combined with cursor"),
319
341
  status: import_zod.z.enum(WEBHOOK_DELIVERY_STATUSES).optional().describe("Filter to a single delivery status"),
320
- include_payload: import_zod.z.boolean().optional().describe("Include the full event payload sent on each delivery")
342
+ include_payload: import_zod.z.boolean().optional().describe("Include the full event payload sent on each delivery"),
343
+ 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"),
344
+ created_after: import_zod.z.string().datetime().optional().describe("Only deliveries created at or after this time (ISO 8601, UTC)"),
345
+ created_before: import_zod.z.string().datetime().optional().describe("Only deliveries created before this time (ISO 8601, UTC)"),
346
+ delivery_id: import_zod.z.string().max(100).regex(/^whd_[A-Za-z0-9_-]+$/).optional().describe("Only the delivery with this id"),
347
+ is_test: import_zod.z.boolean().optional().describe("true for test events only, false to leave them out"),
348
+ cursor: import_zod.z.string().min(1).max(1024).optional().describe("The next_cursor from the previous page")
349
+ });
350
+ var GetWebhookDeliverySchema = import_zod.z.object({
351
+ webhook_id: import_zod.z.string().describe("Webhook subscription the delivery belongs to"),
352
+ delivery_id: import_zod.z.string().describe("Delivery ID (whd_...) from list_webhook_deliveries")
353
+ });
354
+ var SendTestWebhookSchema = import_zod.z.object({
355
+ webhook_id: import_zod.z.string().describe("Webhook subscription to send the test event to"),
356
+ event_type: import_zod.z.enum(WEBHOOK_EVENT_TYPES).describe("Event type whose sample payload to send")
357
+ });
358
+ var ReplayWebhookDeliverySchema = import_zod.z.object({
359
+ webhook_id: import_zod.z.string().describe("Webhook subscription the delivery belongs to"),
360
+ delivery_id: import_zod.z.string().describe("Delivery to replay (whd_...)")
321
361
  });
322
362
  var ListICalSubscriptionsSchema = import_zod.z.object({
323
363
  agent_id: import_zod.z.string().describe("Agent ID whose iCal subscriptions to list"),
@@ -331,13 +371,13 @@ var GetICalSubscriptionSchema = import_zod.z.object({
331
371
  var SubscribeICalSchema = import_zod.z.object({
332
372
  agent_id: import_zod.z.string().describe("Agent ID that will own this subscription"),
333
373
  calendar_id: import_zod.z.string().describe("Calendar ID to sync external events into"),
334
- url: import_zod.z.string().url().describe("HTTPS URL of the iCal feed (.ics) to subscribe to"),
374
+ url: import_zod.z.string().url().max(2048).describe("HTTPS URL of the iCal feed (.ics) to subscribe to"),
335
375
  label: import_zod.z.string().optional().describe("Optional label for this subscription")
336
376
  });
337
377
  var UpdateICalSubscriptionSchema = import_zod.z.object({
338
378
  subscription_id: import_zod.z.string().describe("iCal subscription ID to update"),
339
379
  label: import_zod.z.string().min(1).max(255).optional().describe("New label for this subscription"),
340
- url: import_zod.z.string().url().refine((u) => u.startsWith("https://"), "URL must use HTTPS").optional().describe("New HTTPS URL of the iCal feed (.ics)")
380
+ 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)")
341
381
  });
342
382
  var DeleteICalSubscriptionSchema = import_zod.z.object({
343
383
  subscription_id: import_zod.z.string().describe("iCal subscription ID to delete")
@@ -345,23 +385,53 @@ var DeleteICalSubscriptionSchema = import_zod.z.object({
345
385
  var SyncICalSubscriptionSchema = import_zod.z.object({
346
386
  subscription_id: import_zod.z.string().describe("iCal subscription ID to sync")
347
387
  });
388
+ var PauseICalSubscriptionSchema = import_zod.z.object({
389
+ subscription_id: import_zod.z.string().describe("iCal subscription ID to pause")
390
+ });
391
+ var ResumeICalSubscriptionSchema = import_zod.z.object({
392
+ subscription_id: import_zod.z.string().describe("iCal subscription ID to resume")
393
+ });
348
394
  var GetUsageSchema = import_zod.z.object({});
395
+ var GetUsageHistorySchema = import_zod.z.object({
396
+ months: import_zod.z.number().int().min(1).max(12).optional().describe("Number of UTC calendar months to return, 1-12 (default 6)")
397
+ });
398
+ var GetBillingSchema = import_zod.z.object({});
399
+ var RequestUpgradeSchema = import_zod.z.object({
400
+ interval: import_zod.z.enum(["month", "year"]).optional().describe("Billing interval to request. Defaults to month."),
401
+ reason: import_zod.z.string().max(500).optional().describe("Why the upgrade is needed (max 500 chars). Shown to your human as plain text."),
402
+ feature: import_zod.z.string().optional().describe("Plan-gated feature that was blocked, e.g. scoped_keys (from a plan_required error)."),
403
+ metric: import_zod.z.string().optional().describe("Quota metric that was exhausted, e.g. api_calls (from a quota_exceeded error).")
404
+ });
405
+ var GetUpgradeRequestSchema = import_zod.z.object({
406
+ id: import_zod.z.string().describe("Upgrade request ID (upr_...)")
407
+ });
408
+ var CancelUpgradeRequestSchema = GetUpgradeRequestSchema;
349
409
 
350
410
  // src/safe.ts
351
411
  var import_sdk = require("@chronary/sdk");
412
+ function toErrorPayload(err) {
413
+ if (err instanceof import_sdk.ChronaryError) {
414
+ const payload = {
415
+ error: err.errorType ?? err.name,
416
+ message: err.message
417
+ };
418
+ if (err.upgradeUrl !== void 0) payload.upgrade_url = err.upgradeUrl;
419
+ if (err.docsUrl !== void 0) payload.docs_url = err.docsUrl;
420
+ if (err.requiredPlan !== void 0) payload.required_plan = err.requiredPlan;
421
+ if (err.feature !== void 0) payload.feature = err.feature;
422
+ if (err.metric !== void 0) payload.metric = err.metric;
423
+ if (err.limit !== void 0) payload.limit = err.limit;
424
+ return payload;
425
+ }
426
+ return { error: "error", message: err instanceof Error ? err.message : String(err) };
427
+ }
352
428
  function safeFunc(fn) {
353
429
  return async (params) => {
354
430
  try {
355
431
  const result = await fn(params);
356
432
  return { result: result ?? { success: true }, isError: false };
357
433
  } catch (err) {
358
- if (err instanceof import_sdk.ChronaryError) {
359
- return { result: `${err.name}: ${err.message}`, isError: true };
360
- }
361
- return {
362
- result: `Error: ${err instanceof Error ? err.message : String(err)}`,
363
- isError: true
364
- };
434
+ return { result: toErrorPayload(err), isError: true };
365
435
  }
366
436
  };
367
437
  }
@@ -442,6 +512,21 @@ var listEvents = safeFunc(async (ctx) => {
442
512
  });
443
513
  return fetchPage(iter, params.offset, params.limit);
444
514
  });
515
+ var listOrgEvents = safeFunc(async (ctx) => {
516
+ const { client, params } = ctx;
517
+ const iter = client.events.listAll({
518
+ calendar_id: params.calendar_ids,
519
+ agent_id: params.agent_id,
520
+ start_after: params.start_after,
521
+ start_before: params.start_before,
522
+ status: params.status,
523
+ source: params.source,
524
+ q: params.q,
525
+ expand: params.expand,
526
+ limit: params.limit
527
+ });
528
+ return fetchPage(iter, params.offset, params.limit);
529
+ });
445
530
  var getEvent = safeFunc(async (ctx) => {
446
531
  const { calendar_id, event_id } = ctx.params;
447
532
  return calendar_id ? ctx.client.events.get(calendar_id, event_id) : ctx.client.events.getById(event_id);
@@ -613,6 +698,15 @@ var listWebhookDeliveries = safeFunc(async (ctx) => {
613
698
  const { webhook_id, ...query } = params;
614
699
  return client.webhooks.listDeliveries(webhook_id, query);
615
700
  });
701
+ var getWebhookDelivery = safeFunc(async (ctx) => {
702
+ return ctx.client.webhooks.getDelivery(ctx.params.webhook_id, ctx.params.delivery_id);
703
+ });
704
+ var sendTestWebhook = safeFunc(async (ctx) => {
705
+ return ctx.client.webhooks.sendTest(ctx.params.webhook_id, { event_type: ctx.params.event_type });
706
+ });
707
+ var replayWebhookDelivery = safeFunc(async (ctx) => {
708
+ return ctx.client.webhooks.replayDelivery(ctx.params.webhook_id, ctx.params.delivery_id);
709
+ });
616
710
  var getAuditLog = safeFunc(async (ctx) => {
617
711
  return ctx.client.auditLog.list(ctx.params);
618
712
  });
@@ -648,13 +742,49 @@ var deleteICalSubscription = safeFunc(async (ctx) => {
648
742
  var syncICalSubscription = safeFunc(async (ctx) => {
649
743
  return ctx.client.icalSubscriptions.sync(ctx.params.subscription_id);
650
744
  });
745
+ var pauseICalSubscription = safeFunc(async (ctx) => {
746
+ return ctx.client.icalSubscriptions.pause(ctx.params.subscription_id);
747
+ });
748
+ var resumeICalSubscription = safeFunc(async (ctx) => {
749
+ return ctx.client.icalSubscriptions.resume(ctx.params.subscription_id);
750
+ });
651
751
  var getUsage = safeFunc(async (ctx) => {
652
752
  return ctx.client.usage.get();
653
753
  });
754
+ var getUsageHistory = safeFunc(async (ctx) => {
755
+ return ctx.client.usage.history({ months: ctx.params.months });
756
+ });
757
+ var getBilling = safeFunc(async (ctx) => {
758
+ return ctx.client.billing.get();
759
+ });
760
+ var requestUpgrade = safeFunc(async (ctx) => {
761
+ return ctx.client.billing.upgradeRequests.create(ctx.params);
762
+ });
763
+ var getUpgradeRequest = safeFunc(async (ctx) => {
764
+ return ctx.client.billing.upgradeRequests.get(ctx.params.id);
765
+ });
766
+ var cancelUpgradeRequest = safeFunc(async (ctx) => {
767
+ return ctx.client.billing.upgradeRequests.cancel(ctx.params.id);
768
+ });
654
769
  function createExecutor(fn) {
655
770
  return (client, params) => fn({ client, params });
656
771
  }
657
772
 
773
+ // src/untrusted.ts
774
+ var EVENT_UNTRUSTED_FIELDS = ["title", "description", "metadata"];
775
+ var WEBHOOK_DELIVERY_UNTRUSTED_FIELDS = ["payload", "response_body"];
776
+ function withUntrustedFields(result, fields) {
777
+ const body = result.result;
778
+ if (result.isError || typeof body !== "object" || body === null || Array.isArray(body)) return result;
779
+ return { ...result, result: { untrusted_fields: [...fields], ...body } };
780
+ }
781
+ function markUntrusted(def) {
782
+ const fields = def.untrustedFields;
783
+ if (!fields || fields.length === 0) return def;
784
+ const execute = def.execute;
785
+ return { ...def, execute: async (client, params) => withUntrustedFields(await execute(client, params), fields) };
786
+ }
787
+
658
788
  // src/definitions.ts
659
789
  var HOSTED_API_MCP_TOOL_NAMES = [
660
790
  "create_agent",
@@ -662,6 +792,7 @@ var HOSTED_API_MCP_TOOL_NAMES = [
662
792
  "create_calendar",
663
793
  "create_event",
664
794
  "list_events",
795
+ "list_org_events",
665
796
  "get_event",
666
797
  "update_event",
667
798
  "get_availability",
@@ -678,6 +809,8 @@ var HOSTED_API_MCP_TOOL_NAMES = [
678
809
  "update_ical_subscription",
679
810
  "delete_ical_subscription",
680
811
  "sync_ical_subscription",
812
+ "pause_ical_subscription",
813
+ "resume_ical_subscription",
681
814
  "get_calendar_context",
682
815
  "create_proposal",
683
816
  "list_proposals",
@@ -697,6 +830,9 @@ var HOSTED_API_MCP_TOOL_NAMES = [
697
830
  "update_webhook",
698
831
  "delete_webhook",
699
832
  "list_webhook_deliveries",
833
+ "get_webhook_delivery",
834
+ "send_test_webhook",
835
+ "replay_webhook_delivery",
700
836
  "get_agent",
701
837
  "update_agent",
702
838
  "delete_agent",
@@ -709,21 +845,26 @@ var HOSTED_API_MCP_TOOL_NAMES = [
709
845
  "get_booking_page",
710
846
  "delete_booking_page",
711
847
  "get_usage",
848
+ "get_usage_history",
712
849
  "get_audit_log",
713
- "accept_terms"
850
+ "accept_terms",
851
+ "get_billing",
852
+ "request_upgrade",
853
+ "get_upgrade_request",
854
+ "cancel_upgrade_request"
714
855
  ];
715
- var TOOL_DEFINITIONS = [
856
+ var RAW_TOOL_DEFINITIONS = [
716
857
  // ── Calendars ──────────────────────────────────────────────────
717
858
  {
718
859
  name: "list_calendars",
719
- 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.",
860
+ 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.",
720
861
  schema: ListCalendarsSchema,
721
862
  annotations: { title: "List Calendars", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
722
863
  execute: createExecutor(listCalendars)
723
864
  },
724
865
  {
725
866
  name: "get_calendar",
726
- 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.",
867
+ 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.",
727
868
  schema: GetCalendarSchema,
728
869
  annotations: { title: "Get Calendar", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
729
870
  execute: createExecutor(getCalendar)
@@ -737,14 +878,14 @@ var TOOL_DEFINITIONS = [
737
878
  },
738
879
  {
739
880
  name: "update_calendar",
740
- description: "Update a calendar's name, timezone, agent status, default reminders, or metadata. Agent-scoped keys may only update calendars owned by their agent.",
881
+ description: "Update a calendar's name, timezone, agent status, default reminders, or metadata. Agent keys may only update calendars owned by their agent.",
741
882
  schema: UpdateCalendarSchema,
742
883
  annotations: { title: "Update Calendar", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
743
884
  execute: createExecutor(updateCalendar)
744
885
  },
745
886
  {
746
887
  name: "delete_calendar",
747
- 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.",
888
+ 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.",
748
889
  schema: DeleteCalendarSchema,
749
890
  annotations: { title: "Delete Calendar", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
750
891
  execute: createExecutor(deleteCalendar)
@@ -759,7 +900,7 @@ var TOOL_DEFINITIONS = [
759
900
  },
760
901
  {
761
902
  name: "list_booking_pages",
762
- description: "List booking pages in the org. Agent-scoped keys see only pages on their own agent's calendars.",
903
+ description: "List booking pages in the org. Agent keys see only pages on their own agent's calendars.",
763
904
  schema: ListBookingPagesSchema,
764
905
  annotations: { title: "List Booking Pages", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
765
906
  execute: createExecutor(listBookingPages)
@@ -784,13 +925,23 @@ var TOOL_DEFINITIONS = [
784
925
  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`.",
785
926
  schema: ListEventsSchema,
786
927
  annotations: { title: "List Events", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
928
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
787
929
  execute: createExecutor(listEvents)
788
930
  },
931
+ {
932
+ name: "list_org_events",
933
+ 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.",
934
+ schema: ListOrgEventsSchema,
935
+ annotations: { title: "List Organization Events", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
936
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
937
+ execute: createExecutor(listOrgEvents)
938
+ },
789
939
  {
790
940
  name: "get_event",
791
941
  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.",
792
942
  schema: GetEventSchema,
793
943
  annotations: { title: "Get Event", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
944
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
794
945
  execute: createExecutor(getEvent)
795
946
  },
796
947
  {
@@ -805,6 +956,7 @@ var TOOL_DEFINITIONS = [
805
956
  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.",
806
957
  schema: UpdateEventSchema,
807
958
  annotations: { title: "Update Event", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
959
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
808
960
  execute: createExecutor(updateEvent)
809
961
  },
810
962
  {
@@ -812,6 +964,7 @@ var TOOL_DEFINITIONS = [
812
964
  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.",
813
965
  schema: CancelEventSchema,
814
966
  annotations: { title: "Cancel Event", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
967
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
815
968
  execute: createExecutor(cancelEvent)
816
969
  },
817
970
  {
@@ -819,6 +972,7 @@ var TOOL_DEFINITIONS = [
819
972
  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.',
820
973
  schema: ConfirmEventSchema,
821
974
  annotations: { title: "Confirm Event", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
975
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
822
976
  execute: createExecutor(confirmEvent)
823
977
  },
824
978
  {
@@ -845,21 +999,21 @@ var TOOL_DEFINITIONS = [
845
999
  },
846
1000
  {
847
1001
  name: "get_agent",
848
- 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.",
1002
+ 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.",
849
1003
  schema: GetAgentSchema,
850
1004
  annotations: { title: "Get Agent", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
851
1005
  execute: createExecutor(getAgent)
852
1006
  },
853
1007
  {
854
1008
  name: "update_agent",
855
- 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.",
1009
+ description: "Update an agent's name, description, metadata, or status (active/paused). Requires an Organization key \u2014 Agent keys cannot mutate agents.",
856
1010
  schema: UpdateAgentSchema,
857
1011
  annotations: { title: "Update Agent", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
858
1012
  execute: createExecutor(updateAgent)
859
1013
  },
860
1014
  {
861
1015
  name: "delete_agent",
862
- 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.",
1016
+ 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.",
863
1017
  schema: DeleteAgentSchema,
864
1018
  annotations: { title: "Delete Agent", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
865
1019
  execute: createExecutor(deleteAgent)
@@ -881,21 +1035,21 @@ var TOOL_DEFINITIONS = [
881
1035
  },
882
1036
  {
883
1037
  name: "create_connection_link",
884
- 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.",
1038
+ 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.",
885
1039
  schema: CreateConnectionLinkSchema,
886
1040
  annotations: { title: "Create Human Calendar Setup Link", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
887
1041
  execute: createExecutor(createConnectionLink)
888
1042
  },
889
1043
  {
890
1044
  name: "get_connection_link",
891
- 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.",
1045
+ 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.",
892
1046
  schema: GetConnectionLinkSchema,
893
1047
  annotations: { title: "Get Human Calendar Setup Status", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
894
1048
  execute: createExecutor(getConnectionLink)
895
1049
  },
896
1050
  {
897
1051
  name: "cancel_connection_link",
898
- description: "Cancel a pending human-calendar setup request. This invalidates the setup URL and does not disconnect an already completed Google or Microsoft connection.",
1052
+ 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.",
899
1053
  schema: CancelConnectionLinkSchema,
900
1054
  annotations: { title: "Cancel Human Calendar Setup Link", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
901
1055
  execute: createExecutor(cancelConnectionLink)
@@ -906,47 +1060,48 @@ var TOOL_DEFINITIONS = [
906
1060
  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.`,
907
1061
  schema: GetCalendarContextSchema,
908
1062
  annotations: { title: "Get Calendar Context", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1063
+ untrustedFields: EVENT_UNTRUSTED_FIELDS,
909
1064
  execute: createExecutor(getCalendarContext)
910
1065
  },
911
1066
  // ── Scheduling proposals ───────────────────────────────────────
912
1067
  {
913
1068
  name: "create_proposal",
914
- 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.",
1069
+ 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.",
915
1070
  schema: CreateProposalSchema,
916
1071
  annotations: { title: "Create Proposal", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
917
1072
  execute: createExecutor(createProposal)
918
1073
  },
919
1074
  {
920
1075
  name: "list_proposals",
921
- description: "List scheduling proposals for the org. Filter by status (pending|confirmed|expired|cancelled) or organizer_agent_id. Requires an org-level API key.",
1076
+ description: "List scheduling proposals for the org. Filter by status (pending|confirmed|expired|cancelled) or organizer_agent_id. Requires an Organization key.",
922
1077
  schema: ListProposalsSchema,
923
1078
  annotations: { title: "List Proposals", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
924
1079
  execute: createExecutor(listProposals)
925
1080
  },
926
1081
  {
927
1082
  name: "get_proposal",
928
- description: "Get a scheduling proposal by id, including its slots and per-participant responses. Requires an org-level API key.",
1083
+ description: "Get a scheduling proposal by id, including its slots and per-participant responses. Requires an Organization key.",
929
1084
  schema: GetProposalSchema,
930
1085
  annotations: { title: "Get Proposal", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
931
1086
  execute: createExecutor(getProposal)
932
1087
  },
933
1088
  {
934
1089
  name: "respond_to_proposal",
935
- 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.',
1090
+ 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.',
936
1091
  schema: RespondToProposalSchema,
937
1092
  annotations: { title: "Respond To Proposal", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
938
1093
  execute: createExecutor(respondToProposal)
939
1094
  },
940
1095
  {
941
1096
  name: "resolve_proposal",
942
- 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.',
1097
+ 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.',
943
1098
  schema: ResolveProposalSchema,
944
1099
  annotations: { title: "Resolve Proposal", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
945
1100
  execute: createExecutor(resolveProposal)
946
1101
  },
947
1102
  {
948
1103
  name: "cancel_proposal",
949
- description: 'Cancel an open proposal. Fires a proposal.cancelled webhook with reason="organizer_cancelled". Requires an org-level API key. Pro plan only.',
1104
+ description: 'Cancel an open proposal. Fires a proposal.cancelled webhook with reason="organizer_cancelled". Requires an Organization key. Pro plan only.',
950
1105
  schema: CancelProposalSchema,
951
1106
  annotations: { title: "Cancel Proposal", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
952
1107
  execute: createExecutor(cancelProposal)
@@ -976,46 +1131,69 @@ var TOOL_DEFINITIONS = [
976
1131
  // ── Webhooks ───────────────────────────────────────────────────
977
1132
  {
978
1133
  name: "list_webhooks",
979
- 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.",
1134
+ description: "List the org's webhook subscriptions with their subscribed event types and active state. Signing secrets are never returned. Requires an Organization key.",
980
1135
  schema: ListWebhooksSchema,
981
1136
  annotations: { title: "List Webhooks", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
982
1137
  execute: createExecutor(listWebhooks)
983
1138
  },
984
1139
  {
985
1140
  name: "get_webhook",
986
- 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.",
1141
+ 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.",
987
1142
  schema: GetWebhookSchema,
988
1143
  annotations: { title: "Get Webhook", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
989
1144
  execute: createExecutor(getWebhook)
990
1145
  },
991
1146
  {
992
1147
  name: "create_webhook",
993
- 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.",
1148
+ 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.",
994
1149
  schema: CreateWebhookSchema,
995
- annotations: { title: "Create Webhook", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
1150
+ annotations: { title: "Create Webhook", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
996
1151
  execute: createExecutor(createWebhook)
997
1152
  },
998
1153
  {
999
1154
  name: "update_webhook",
1000
- 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.",
1155
+ 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.",
1001
1156
  schema: UpdateWebhookSchema,
1002
- annotations: { title: "Update Webhook", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1157
+ annotations: { title: "Update Webhook", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true },
1003
1158
  execute: createExecutor(updateWebhook)
1004
1159
  },
1005
1160
  {
1006
1161
  name: "delete_webhook",
1007
- description: "Permanently delete a webhook subscription. This frees its endpoint slot against the per-plan cap. Requires an org-level API key.",
1162
+ description: "Permanently delete a webhook subscription. This frees its endpoint slot against the per-plan cap. Requires an Organization key.",
1008
1163
  schema: DeleteWebhookSchema,
1009
1164
  annotations: { title: "Delete Webhook", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
1010
1165
  execute: createExecutor(deleteWebhook)
1011
1166
  },
1012
1167
  {
1013
1168
  name: "list_webhook_deliveries",
1014
- 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.",
1169
+ 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.",
1015
1170
  schema: ListWebhookDeliveriesSchema,
1016
1171
  annotations: { title: "List Webhook Deliveries", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1172
+ untrustedFields: WEBHOOK_DELIVERY_UNTRUSTED_FIELDS,
1017
1173
  execute: createExecutor(listWebhookDeliveries)
1018
1174
  },
1175
+ {
1176
+ name: "get_webhook_delivery",
1177
+ 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.",
1178
+ schema: GetWebhookDeliverySchema,
1179
+ annotations: { title: "Get Webhook Delivery", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1180
+ untrustedFields: WEBHOOK_DELIVERY_UNTRUSTED_FIELDS,
1181
+ execute: createExecutor(getWebhookDelivery)
1182
+ },
1183
+ {
1184
+ name: "send_test_webhook",
1185
+ 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.",
1186
+ schema: SendTestWebhookSchema,
1187
+ annotations: { title: "Send Test Webhook", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
1188
+ execute: createExecutor(sendTestWebhook)
1189
+ },
1190
+ {
1191
+ name: "replay_webhook_delivery",
1192
+ 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.",
1193
+ schema: ReplayWebhookDeliverySchema,
1194
+ annotations: { title: "Replay Webhook Delivery", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
1195
+ execute: createExecutor(replayWebhookDelivery)
1196
+ },
1019
1197
  // ── iCal Subscriptions ─────────────────────────────────────────
1020
1198
  {
1021
1199
  name: "list_ical_subscriptions",
@@ -1042,7 +1220,7 @@ var TOOL_DEFINITIONS = [
1042
1220
  name: "update_ical_subscription",
1043
1221
  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.",
1044
1222
  schema: UpdateICalSubscriptionSchema,
1045
- annotations: { title: "Update iCal Subscription", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1223
+ annotations: { title: "Update iCal Subscription", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
1046
1224
  execute: createExecutor(updateICalSubscription)
1047
1225
  },
1048
1226
  {
@@ -1054,29 +1232,43 @@ var TOOL_DEFINITIONS = [
1054
1232
  },
1055
1233
  {
1056
1234
  name: "sync_ical_subscription",
1057
- 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.",
1235
+ 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.',
1058
1236
  schema: SyncICalSubscriptionSchema,
1059
1237
  annotations: { title: "Sync iCal Subscription", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
1060
1238
  execute: createExecutor(syncICalSubscription)
1061
1239
  },
1240
+ {
1241
+ name: "pause_ical_subscription",
1242
+ 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.",
1243
+ schema: PauseICalSubscriptionSchema,
1244
+ annotations: { title: "Pause iCal Subscription", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1245
+ execute: createExecutor(pauseICalSubscription)
1246
+ },
1247
+ {
1248
+ name: "resume_ical_subscription",
1249
+ 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.",
1250
+ schema: ResumeICalSubscriptionSchema,
1251
+ annotations: { title: "Resume iCal Subscription", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1252
+ execute: createExecutor(resumeICalSubscription)
1253
+ },
1062
1254
  // ── Scoped keys ────────────────────────────────────────────────
1063
1255
  {
1064
1256
  name: "create_scoped_key",
1065
- 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.",
1257
+ 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.",
1066
1258
  schema: CreateScopedKeySchema,
1067
1259
  annotations: { title: "Create Scoped Key", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
1068
1260
  execute: createExecutor(createScopedKey)
1069
1261
  },
1070
1262
  {
1071
1263
  name: "list_scoped_keys",
1072
- 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.",
1264
+ 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.",
1073
1265
  schema: ListScopedKeysSchema,
1074
1266
  annotations: { title: "List Scoped Keys", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1075
1267
  execute: createExecutor(listScopedKeys)
1076
1268
  },
1077
1269
  {
1078
1270
  name: "revoke_scoped_key",
1079
- 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.",
1271
+ 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.",
1080
1272
  schema: RevokeScopedKeySchema,
1081
1273
  annotations: { title: "Revoke Scoped Key", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
1082
1274
  execute: createExecutor(revokeScopedKey)
@@ -1084,7 +1276,7 @@ var TOOL_DEFINITIONS = [
1084
1276
  // ── Audit log ──────────────────────────────────────────────────
1085
1277
  {
1086
1278
  name: "get_audit_log",
1087
- 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.",
1279
+ 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.",
1088
1280
  schema: GetAuditLogSchema,
1089
1281
  annotations: { title: "Get Audit Log", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1090
1282
  execute: createExecutor(getAuditLog)
@@ -1092,7 +1284,7 @@ var TOOL_DEFINITIONS = [
1092
1284
  // ── Terms ──────────────────────────────────────────────────────
1093
1285
  {
1094
1286
  name: "accept_terms",
1095
- 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.",
1287
+ 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.",
1096
1288
  schema: AcceptTermsSchema,
1097
1289
  annotations: { title: "Accept Terms", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1098
1290
  execute: createExecutor(acceptTerms)
@@ -1100,12 +1292,49 @@ var TOOL_DEFINITIONS = [
1100
1292
  // ── Usage ──────────────────────────────────────────────────────
1101
1293
  {
1102
1294
  name: "get_usage",
1103
- 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.",
1295
+ 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.",
1104
1296
  schema: GetUsageSchema,
1105
1297
  annotations: { title: "Get Usage", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1106
1298
  execute: createExecutor(getUsage)
1299
+ },
1300
+ {
1301
+ name: "get_usage_history",
1302
+ 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.",
1303
+ schema: GetUsageHistorySchema,
1304
+ annotations: { title: "Get Usage History", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1305
+ execute: createExecutor(getUsageHistory)
1306
+ },
1307
+ // ── Billing ────────────────────────────────────────────────────
1308
+ {
1309
+ name: "get_billing",
1310
+ 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_*).",
1311
+ schema: GetBillingSchema,
1312
+ annotations: { title: "Get Billing", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1313
+ execute: createExecutor(getBilling)
1314
+ },
1315
+ {
1316
+ name: "request_upgrade",
1317
+ 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.",
1318
+ schema: RequestUpgradeSchema,
1319
+ annotations: { title: "Request Upgrade", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1320
+ execute: createExecutor(requestUpgrade)
1321
+ },
1322
+ {
1323
+ name: "get_upgrade_request",
1324
+ 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_*).",
1325
+ schema: GetUpgradeRequestSchema,
1326
+ annotations: { title: "Get Upgrade Request", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1327
+ execute: createExecutor(getUpgradeRequest)
1328
+ },
1329
+ {
1330
+ name: "cancel_upgrade_request",
1331
+ 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.",
1332
+ schema: CancelUpgradeRequestSchema,
1333
+ annotations: { title: "Cancel Upgrade Request", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1334
+ execute: createExecutor(cancelUpgradeRequest)
1107
1335
  }
1108
1336
  ];
1337
+ var TOOL_DEFINITIONS = RAW_TOOL_DEFINITIONS.map(markUntrusted);
1109
1338
  var toolkitToolNames = new Set(TOOL_DEFINITIONS.map((tool) => tool.name));
1110
1339
  var hostedToolNames = new Set(HOSTED_API_MCP_TOOL_NAMES);
1111
1340
  var TOOLKIT_MCP_PARITY = {