@mgcrea/mcp-apple-calendar 1.38.0 → 1.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { A as BUILD_INFO, C as CALENDAR_SURFACE, a as loadConfig, r as createServer } from "./server-BpF3gYz7.js";
2
+ import { A as BUILD_INFO, C as CALENDAR_SURFACE, a as loadConfig, r as createServer } from "./server-DkPjff2I.js";
3
3
  import { runStdioServer } from "@mgcrea/mcp-apple-core";
4
4
  //#region src/cli.ts
5
5
  const LOG_PREFIX = "apple-calendar-mcp";
package/dist/index.d.ts CHANGED
@@ -364,6 +364,19 @@ type EventPage = {
364
364
  * indistinguishable from a free afternoon.
365
365
  */
366
366
  hasMore: boolean;
367
+ /**
368
+ * Where the next page of a list starts. Pass it back as `from` with the same
369
+ * `to`. Events that overlap it and were already listed come back again; none
370
+ * are skipped.
371
+ *
372
+ * Absent while `hasMore` is true when no later `from` would move: paging is by
373
+ * start time, and a full page whose events all start at or before `from` (a
374
+ * crowd sharing one start) has no later one to give. Narrow the window or the
375
+ * calendars instead.
376
+ */
377
+ nextFrom?: string;
378
+ /** The same for search, which runs newest first: pass it back as `to`. */
379
+ nextTo?: string;
367
380
  expansion: ExpansionState;
368
381
  expansionReason?: string;
369
382
  /** The window actually queried, echoed so a clamp is visible. */
@@ -603,6 +616,7 @@ declare class AppleCalendarClient {
603
616
  */
604
617
  deleteEvents(refs: readonly string[]): Promise<{
605
618
  results: unknown[];
619
+ unknown?: number;
606
620
  scope: string;
607
621
  }>;
608
622
  lanes(): LaneStatus;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/build-info.ts","../src/client/store.ts","../src/config.ts","../src/client/availability.ts","../src/client/dates.ts","../src/client/locate.ts","../src/client/recurrence.ts","../src/client/calendar.ts","../src/client/errors.ts","../src/client/ref.ts","../src/server.ts","../src/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AqB;EA2OlE,SAAS,cAAc;EAkCvB,aAlCuB;EAsCvB,YAAY;EA+JN,YAAY,QAAQ,oBAAoB,QAAQ;EAuBhD,YAAY,QAAQ,oBAAoB,QAAQ;;;;;;;;;;;EA4EhD,aAAa,0BAA0B;IAAU;IAAoB;;EAkC3E,SAAS;;;;;;;;;;;cC5qCE,kBAAkB;;cAMlB;;cA0BA,2BAA2B;WACpB;EAElB,YAAY;;;cAUD,8BAA8B;WACvB;EAElB,YAAY,cAAc;;;;;;;;;;cAmBf,iCAAiC;WAC1B;EAElB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cC3CD;KAWD;;EAEV;;EAEA;;EAEA,iBAAiB;;EAEjB;;cA4BW,YAAS,qBACD,kBACH,kBACE;cAQP,YAAS,gBAAkB;;cA2D3B,cAAW,KAAS;;cAGpB,SAAM;;;cClJN;cACA;KAED;EACV,QAAQ;EACR,SAAS;;EAET,YAAY;;EAEZ,YAAY;;KAGF;EACV,QAAQ;EACR,QAAQ;;;;;;;;cASG,eAAY,MAAU,wBAAsB;;;KC9B7C;;;;;EAKV;;;;;;;;;;;;;;;;cAiBW,gBAAa,QAChB,WAAS,QACT,qBAAmB,KACtB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/build-info.ts","../src/client/store.ts","../src/config.ts","../src/client/availability.ts","../src/client/dates.ts","../src/client/locate.ts","../src/client/recurrence.ts","../src/client/calendar.ts","../src/client/errors.ts","../src/client/ref.ts","../src/server.ts","../src/tools/index.ts"],"mappings":";;;;;cAkBa,YAAY;;;KCiDb;EACV;;EAEA,aAAa;EACb,iBAAiB;EACjB,mBAAmB;EACnB,mBAAmB;EACnB,cAAc;;;;;;;;;EASd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;KAIU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;;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,YAAY;;;cAUD,8BAA8B;WACvB;EAElB,YAAY,cAAc;;;;;;;;;;cAmBf,iCAAiC;WAC1B;EAElB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cC3CD;KAWD;;EAEV;;EAEA;;EAEA,iBAAiB;;EAEjB;;cA4BW,YAAS,qBACD,kBACH,kBACE;cAQP,YAAS,gBAAkB;;cA2D3B,cAAW,KAAS;;cAGpB,SAAM;;;cClJN;cACA;KAED;EACV,QAAQ;EACR,SAAS;;EAET,YAAY;;EAEZ,YAAY;;KAGF;EACV,QAAQ;EACR,QAAQ;;;;;;;;cASG,eAAY,MAAU,wBAAsB;;;KC9B7C;;;;;EAKV;;;;;;;;;;;;;;;;cAiBW,gBAAa,QAChB,WAAS,QACT,qBAAmB,KACtB"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { A as BUILD_INFO, C as CALENDAR_SURFACE, D as CalendarNotWritableError, E as CalendarNotRunningError, O as EventNotFoundError, S as CALENDAR_BUNDLE_ID, T as CalendarNotFoundError, _ as STORE_FILENAME, a as loadConfig, b as locateStore, c as introspect, d as decodeRef, f as encodeRef, g as GROUP_CONTAINER, h as EXTRAS_FILENAME, i as registerTools, k as InvalidDateError, l as openStore, m as uuidOf, n as SERVER_VERSION, o as AppleCalendarClient, p as seriesRefOf, r as createServer, s as CalendarStore, t as SERVER_NAME, u as REF_VERSION, v as defaultContainerPath, w as CalendarBusyError, x as AppleCalendarError, y as defaultStorePath } from "./server-BpF3gYz7.js";
1
+ import { A as BUILD_INFO, C as CALENDAR_SURFACE, D as CalendarNotWritableError, E as CalendarNotRunningError, O as EventNotFoundError, S as CALENDAR_BUNDLE_ID, T as CalendarNotFoundError, _ as STORE_FILENAME, a as loadConfig, b as locateStore, c as introspect, d as decodeRef, f as encodeRef, g as GROUP_CONTAINER, h as EXTRAS_FILENAME, i as registerTools, k as InvalidDateError, l as openStore, m as uuidOf, n as SERVER_VERSION, o as AppleCalendarClient, p as seriesRefOf, r as createServer, s as CalendarStore, t as SERVER_NAME, u as REF_VERSION, v as defaultContainerPath, w as CalendarBusyError, x as AppleCalendarError, y as defaultStorePath } from "./server-DkPjff2I.js";
2
2
  export { AppleCalendarClient, AppleCalendarError, BUILD_INFO, CALENDAR_BUNDLE_ID, CALENDAR_SURFACE, CalendarBusyError, CalendarNotFoundError, CalendarNotRunningError, CalendarNotWritableError, CalendarStore, EXTRAS_FILENAME, EventNotFoundError, GROUP_CONTAINER, InvalidDateError, REF_VERSION, SERVER_NAME, SERVER_VERSION, STORE_FILENAME, createServer, decodeRef, defaultContainerPath, defaultStorePath, encodeRef, introspect, loadConfig, locateStore, openStore, registerTools, seriesRefOf, uuidOf };
@@ -1,4 +1,4 @@
1
- import { AppBusyError as CalendarBusyError, AppNotRunningError as CalendarNotRunningError, AppleAutomationError, AppleAutomationError as AppleCalendarError, BaseConfigSchema, CORE_DATA_EPOCH_OFFSET, IndexUnavailableError, InvalidDateError, PreconditionError, SchemaDriftError, addLocalDays, buildBaseDiagnostics, columnsOf, confirmArg, createOsascriptRunner, describeStore, escapeLike, fingerprintSchema, limitArg, ok, openReadOnly, parseBool, parseBound, parseBound as parseBound$1, parseConfig, parseDate, parseIntOpt, parseList, promptArg, readPackageIdentity, registerSurfaceResources, registerWorkflowPrompt, requiredPromptArg, resolveLimit, startOfLocalDay, toLocalIso, toLocalIso as toLocalIso$1, trimmed, withBusyRetry, withLazyTools, wrap } from "@mgcrea/mcp-apple-core";
1
+ import { AppBusyError as CalendarBusyError, AppNotRunningError as CalendarNotRunningError, AppleAutomationError, AppleAutomationError as AppleCalendarError, BaseConfigSchema, CORE_DATA_EPOCH_OFFSET, IndexUnavailableError, InvalidDateError, PreconditionError, SchemaDriftError, addLocalDays, buildBaseDiagnostics, columnsOf, confirmArg, createOsascriptRunner, describeStore, fingerprintSchema, likeContains, limitArg, ok, openReadOnly, parseBool, parseBound, parseBound as parseBound$1, parseConfig, parseDate, parseIntOpt, parseList, promptArg, readPackageIdentity, registerSurfaceResources, registerWorkflowPrompt, requiredPromptArg, resolveLimit, settleGroups, startOfLocalDay, toLocalIso, toLocalIso as toLocalIso$1, trimmed, withBusyRetry, withLazyTools, wrap } from "@mgcrea/mcp-apple-core";
2
2
  import { readdirSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
4
  import { join } from "node:path";
@@ -12,8 +12,8 @@ const pkg = readPackageIdentity(new URL("../package.json", import.meta.url), {
12
12
  const BUILD_INFO = {
13
13
  name: pkg.name,
14
14
  version: pkg.version,
15
- gitCommit: "45c3a7e",
16
- gitCommitDate: "2026-11-10T15:30:40+01:00"
15
+ gitCommit: "1e3dc3e",
16
+ gitCommitDate: "2026-11-16T14:52:33+01:00"
17
17
  };
18
18
  //#endregion
19
19
  //#region src/client/errors.ts
@@ -1359,13 +1359,13 @@ var CalendarStore = class {
1359
1359
  searchItems(q) {
1360
1360
  const c = this.caps.itemColumns;
1361
1361
  const cal = this.#calendarFilter(q.calendarUuids);
1362
- const needle = `%${escapeLike(q.text)}%`;
1363
1362
  const fields = ["summary"];
1364
1363
  if (q.scope === "full") {
1365
1364
  if (c.has("description")) fields.push("description");
1366
1365
  if (this.caps.hasLocation) fields.push("__location");
1367
1366
  }
1368
- const match = fields.map((f) => f === "__location" ? `loc."title" LIKE ? ESCAPE '\\'` : `ci."${f}" LIKE ? ESCAPE '\\'`).join(" OR ");
1367
+ const likes = fields.map((f) => likeContains(f === "__location" ? `loc."title"` : `ci."${f}"`, q.text));
1368
+ const match = likes.map((l) => l.sql).join(" OR ");
1369
1369
  const sql = `
1370
1370
  SELECT ci."start_date" AS startApple,
1371
1371
  ${c.has("end_date") ? `ci."end_date"` : `NULL`} AS endApple,
@@ -1380,7 +1380,7 @@ var CalendarStore = class {
1380
1380
  ORDER BY ci."start_date" DESC
1381
1381
  LIMIT ?`;
1382
1382
  const params = [
1383
- ...fields.map(() => needle),
1383
+ ...likes.map((l) => l.param),
1384
1384
  q.toApple,
1385
1385
  q.fromApple,
1386
1386
  ...cal.params,
@@ -1540,6 +1540,24 @@ const AVAILABILITY_FREE = 1;
1540
1540
  * and a runaway one is caught rather than answered.
1541
1541
  */
1542
1542
  const BUSY_SCAN_BOUND = 5e3;
1543
+ /**
1544
+ * Where a set of capped, ordered legs stops being complete.
1545
+ *
1546
+ * A leg that came back holding `limit` rows may have more past its last one,
1547
+ * and the status filters run after the LIMIT, so nothing at or beyond that
1548
+ * row's start is the whole picture. With several legs the cut is the one met
1549
+ * first in the order. `null` when no leg filled its limit.
1550
+ */
1551
+ const legCutoff = (legs, limit, order) => {
1552
+ let cut = null;
1553
+ for (const leg of legs) {
1554
+ if (leg.length < limit) continue;
1555
+ const last = leg.at(-1)?.startApple;
1556
+ if (last === null || last === void 0) continue;
1557
+ if (cut === null || (order === "asc" ? last < cut : last > cut)) cut = last;
1558
+ }
1559
+ return cut;
1560
+ };
1543
1561
  var AppleCalendarClient = class {
1544
1562
  config;
1545
1563
  runner;
@@ -1696,9 +1714,11 @@ var AppleCalendarClient = class {
1696
1714
  limit: legLimit,
1697
1715
  ...calendarUuids ? { calendarUuids } : {}
1698
1716
  };
1717
+ const items = store.rangeItems(q);
1718
+ const occurrences = store.rangeOccurrences(q);
1699
1719
  const merged = mergeRange({
1700
- items: store.rangeItems(q),
1701
- occurrences: store.rangeOccurrences(q),
1720
+ items,
1721
+ occurrences,
1702
1722
  coverage: store.coverage(),
1703
1723
  hasOccurrenceCache: store.caps.hasOccurrenceCache,
1704
1724
  fromApple,
@@ -1706,15 +1726,26 @@ var AppleCalendarClient = class {
1706
1726
  limit: legLimit,
1707
1727
  epochOffset: store.caps.epochOffset
1708
1728
  });
1729
+ const cutoff = legCutoff([
1730
+ items,
1731
+ occurrences,
1732
+ merged.rows
1733
+ ], legLimit, "asc");
1734
+ const cutAt = cutoff !== null && cutoff > fromApple ? cutoff : null;
1735
+ const complete = cutAt === null ? merged.rows : merged.rows.filter((r) => (r.startApple ?? 0) < cutAt);
1709
1736
  const declined = filters.includeDeclined ?? this.config.includeDeclined;
1710
1737
  const cancelled = filters.includeCancelled ?? this.config.includeCancelled;
1711
- const visible = merged.rows.filter((r) => this.#visible(r, {
1738
+ const visible = complete.filter((r) => this.#visible(r, {
1712
1739
  declined,
1713
1740
  cancelled
1714
1741
  }));
1742
+ const events = visible.slice(0, filters.limit).map((r) => this.#summarise(r, store));
1743
+ const hasMore = visible.length > filters.limit || cutoff !== null;
1744
+ const resumeAt = visible[filters.limit]?.startApple ?? cutAt;
1715
1745
  return {
1716
- events: visible.slice(0, filters.limit).map((r) => this.#summarise(r, store)),
1717
- hasMore: visible.length > filters.limit,
1746
+ events,
1747
+ hasMore,
1748
+ ...hasMore && resumeAt !== null && resumeAt > fromApple ? { nextFrom: this.#fromApple(resumeAt, store) } : {},
1718
1749
  expansion: merged.expansion,
1719
1750
  ...merged.expansionReason ? { expansionReason: merged.expansionReason } : {},
1720
1751
  window: {
@@ -1759,23 +1790,31 @@ var AppleCalendarClient = class {
1759
1790
  maxRangeDays: 1
1760
1791
  }, now).to, store) : Number.MAX_SAFE_INTEGER;
1761
1792
  const calendarUuids = this.#calendarUuids(store, args.calendar);
1793
+ const legLimit = Math.min(args.limit * 4 + 50, 5e3);
1762
1794
  const rows = store.searchItems({
1763
1795
  fromApple,
1764
1796
  toApple,
1765
- limit: Math.min(args.limit * 4 + 50, 5e3),
1797
+ limit: legLimit,
1766
1798
  text: args.query,
1767
1799
  scope: args.scope ?? "summary",
1768
1800
  ...calendarUuids ? { calendarUuids } : {}
1769
1801
  });
1802
+ const cutoff = legCutoff([rows], legLimit, "desc");
1803
+ const cutAt = cutoff !== null && cutoff + 1 < toApple ? cutoff : null;
1804
+ const complete = cutAt === null ? rows : rows.filter((r) => r.startApple !== null && r.startApple > cutAt);
1770
1805
  const declined = args.includeDeclined ?? this.config.includeDeclined;
1771
1806
  const cancelled = args.includeCancelled ?? this.config.includeCancelled;
1772
- const visible = rows.filter((r) => this.#visible(r, {
1807
+ const visible = complete.filter((r) => this.#visible(r, {
1773
1808
  declined,
1774
1809
  cancelled
1775
1810
  }));
1811
+ const hasMore = visible.length > args.limit || cutoff !== null;
1812
+ const resumeAt = visible[args.limit]?.startApple ?? cutAt;
1813
+ const advances = resumeAt !== null && resumeAt + 1 < toApple;
1776
1814
  return {
1777
1815
  events: visible.slice(0, args.limit).map((r) => this.#summarise(r, store)),
1778
- hasMore: visible.length > args.limit,
1816
+ hasMore,
1817
+ ...hasMore && advances ? { nextTo: this.#fromApple(resumeAt + 1, store) } : {},
1779
1818
  expansion: "unavailable",
1780
1819
  expansionReason: "search matches each event once, at its series start; use apple_calendar_list_events with a date range to see individual occurrences",
1781
1820
  window: {
@@ -2235,23 +2274,36 @@ var AppleCalendarClient = class {
2235
2274
  seriesRef: seriesRefOf(occurrence.parsed)
2236
2275
  });
2237
2276
  const byCalendar = /* @__PURE__ */ new Map();
2238
- for (const { parsed } of decoded) {
2277
+ for (const { ref, parsed } of decoded) {
2239
2278
  const key = parsed.calendarUid || "";
2240
- byCalendar.set(key, [...byCalendar.get(key) ?? [], parsed.eventUid]);
2279
+ byCalendar.set(key, [...byCalendar.get(key) ?? [], {
2280
+ ref,
2281
+ uid: parsed.eventUid
2282
+ }]);
2241
2283
  }
2242
- const results = [];
2243
- for (const [calendar, uids] of byCalendar) {
2244
- const data = await this.#run(DELETE_EVENTS, {
2245
- calendar: this.#nameForRefCalendar(calendar) ?? null,
2246
- uids
2284
+ try {
2285
+ const { rows, unknown } = await settleGroups(byCalendar, ([, events]) => events.map((e) => e.ref), async ([calendar, events]) => {
2286
+ const data = await this.#run(DELETE_EVENTS, {
2287
+ calendar: this.#nameForRefCalendar(calendar) ?? null,
2288
+ uids: events.map((e) => e.uid)
2289
+ });
2290
+ const refOf = new Map(events.map((e) => [e.uid, e.ref]));
2291
+ return (data.results ?? []).map((r) => ({
2292
+ ref: refOf.get(String(r.uid)) ?? null,
2293
+ ...r
2294
+ }));
2247
2295
  });
2248
- results.push(...data.results ?? []);
2296
+ return {
2297
+ results: rows.map((r) => "ok" in r ? {
2298
+ ...r,
2299
+ deleted: r.ok
2300
+ } : r),
2301
+ ...unknown ? { unknown } : {},
2302
+ scope: "series"
2303
+ };
2304
+ } finally {
2305
+ this.invalidate();
2249
2306
  }
2250
- this.invalidate();
2251
- return {
2252
- results,
2253
- scope: "series"
2254
- };
2255
2307
  }
2256
2308
  lanes() {
2257
2309
  const located = this.locate();
@@ -2747,7 +2799,7 @@ const filterSchema = {
2747
2799
  };
2748
2800
  const registerEventTools = (server, client) => {
2749
2801
  server.registerTool("apple_calendar_list_events", {
2750
- description: "List events in a date range, earliest first. Occurrences of repeating events are expanded, so a weekly standup appears once per week rather than once. The result carries a `coverage` block naming the window the expansion is known to cover; if your range runs past it, `truncated` is set and says what is missing rather than returning a short list silently. `hasMore` is the other reason a list can be partial: more events matched than `limit` allowed. Returns a `ref` per event for get_event.",
2802
+ description: "List events in a date range, earliest first. Occurrences of repeating events are expanded, so a weekly standup appears once per week rather than once. The result carries a `coverage` block naming the window the expansion is known to cover; if your range runs past it, `truncated` is set and says what is missing rather than returning a short list silently. `hasMore` is the other reason a list can be partial: more events matched than `limit` allowed; pass the returned `nextFrom` as `from` (same `to`) for the rest. Without `nextFrom`, the page cannot be advanced by start time (its events share one start): narrow the window or the calendars. Returns a `ref` per event for get_event.",
2751
2803
  inputSchema: z.object({
2752
2804
  from: fromArg,
2753
2805
  to: toArg,
@@ -2759,7 +2811,7 @@ const registerEventTools = (server, client) => {
2759
2811
  limit: resolveLimit(args.limit, client.config.maxResults, 50)
2760
2812
  })));
2761
2813
  server.registerTool("apple_calendar_search_events", {
2762
- description: "Search events by text, most recent first. Unbounded in time unless you give `from` or `to`. Matches each event ONCE at its series start — it does not expand occurrences, so use list_events with a range to see individual instances of a repeating event.",
2814
+ description: "Search events by text, most recent first. Unbounded in time unless you give `from` or `to`. Matches each event ONCE at its series start — it does not expand occurrences, so use list_events with a range to see individual instances of a repeating event. When `hasMore` is set, pass the returned `nextTo` as `to` for older matches; without `nextTo`, narrow the window instead.",
2763
2815
  inputSchema: z.object({
2764
2816
  query: z.string().min(1).describe("Text to look for. Matched case-insensitively."),
2765
2817
  scope: z.enum(["summary", "full"]).optional().describe("\"summary\" (default) searches titles; \"full\" adds notes and location."),
@@ -2854,4 +2906,4 @@ const createServer = (opts) => {
2854
2906
  //#endregion
2855
2907
  export { BUILD_INFO as A, CALENDAR_SURFACE as C, CalendarNotWritableError as D, CalendarNotRunningError as E, EventNotFoundError as O, CALENDAR_BUNDLE_ID as S, CalendarNotFoundError as T, STORE_FILENAME as _, loadConfig as a, locateStore as b, introspect as c, decodeRef as d, encodeRef as f, GROUP_CONTAINER as g, EXTRAS_FILENAME as h, registerTools as i, InvalidDateError as k, openStore as l, uuidOf as m, SERVER_VERSION as n, AppleCalendarClient as o, seriesRefOf as p, createServer as r, CalendarStore as s, SERVER_NAME as t, REF_VERSION as u, defaultContainerPath as v, CalendarBusyError as w, AppleCalendarError as x, defaultStorePath as y };
2856
2908
 
2857
- //# sourceMappingURL=server-BpF3gYz7.js.map
2909
+ //# sourceMappingURL=server-DkPjff2I.js.map