Skip to content

Personal AI, On Personal Devices

Python

feat(connectors): Apple Calendar connector for macOS (#619)

Pete Parise276322982277
diff --git a/src/openjarvis/connectors/__init__.py b/src/openjarvis/connectors/__init__.py
index 6aa3ad2c..74497b3e 100644
--- a/src/openjarvis/connectors/__init__.py
+++ b/src/openjarvis/connectors/__init__.py
@@ -63,6 +63,11 @@ try:
except ImportError:
pass
+try:
+ import openjarvis.connectors.apple_calendar # noqa: F401
+except ImportError:
+ pass
+
try:
import openjarvis.connectors.slack_connector # noqa: F401
except ImportError:
diff --git a/src/openjarvis/connectors/apple_calendar.py b/src/openjarvis/connectors/apple_calendar.py
new file mode 100644
index 00000000..218b72c5
--- /dev/null
+++ b/src/openjarvis/connectors/apple_calendar.py
@@ -0,0 +1,441 @@
+"""Apple Calendar connector — reads directly from the macOS Calendar SQLite database.
+
+No API calls, no OAuth, no app-specific password. Opens
+``~/Library/Group Containers/group.com.apple.calendar/Calendar.sqlitedb``
+in read-only mode and yields one :class:`Document` per upcoming event.
+
+Requires **Full Disk Access** granted to the terminal / app in
+System Settings → Privacy & Security → Full Disk Access.
+
+Timestamp notes
+---------------
+The Calendar database stores timestamps as seconds since the Apple epoch
+of 2001-01-01 00:00:00 UTC (same convention as Apple Contacts).
+"""
+
+from __future__ import annotations
+
+import sqlite3
+from datetime import datetime, timedelta, timezone
+from pathlib import Path
+from typing import Any, Dict, Iterator, List, Optional
+from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
+
+from openjarvis.connectors._stubs import BaseConnector, Document, SyncStatus
+from openjarvis.core.registry import ConnectorRegistry
+from openjarvis.tools._stubs import ToolSpec
+
+# ---------------------------------------------------------------------------
+# Constants
+# ---------------------------------------------------------------------------
+
+_CAL_DB = (
+ Path.home()
+ / "Library"
+ / "Group Containers"
+ / "group.com.apple.calendar"
+ / "Calendar.sqlitedb"
+)
+
+# Apple epoch: 2001-01-01 00:00:00 UTC
+_APPLE_EPOCH = datetime(2001, 1, 1, tzinfo=timezone.utc)
+
+# Default lookahead window for digest
+_DEFAULT_DAYS_AHEAD = 7
+_DEFAULT_DAYS_BEHIND = 1
+
+
+# ---------------------------------------------------------------------------
+# Helpers
+# ---------------------------------------------------------------------------
+
+
+def _apple_ts(seconds: float) -> datetime:
+ return _APPLE_EPOCH + timedelta(seconds=seconds)
+
+
+def _to_apple_ts(dt: datetime) -> float:
+ if dt.tzinfo is None:
+ dt = dt.replace(tzinfo=timezone.utc)
+ return (dt - _APPLE_EPOCH).total_seconds()
+
+
+def _open_db(path: Path) -> sqlite3.Connection | None:
+ try:
+ return sqlite3.connect(f"file:{path}?mode=ro", uri=True)
+ except sqlite3.OperationalError:
+ return None
+
+
+# ---------------------------------------------------------------------------
+# SQL
+# ---------------------------------------------------------------------------
+
+_EVENT_COLUMNS = """\
+SELECT
+ ci.ROWID,
+ ci.summary,
+ ci.description,
+ ci.start_date,
+ ci.end_date,
+ ci.all_day,
+ ci.start_tz,
+ ci.location_id,
+ ci.has_attendees,
+ ci.last_modified,
+ ci.UUID,
+ c.title AS calendar_title,
+ c.color AS calendar_color,
+ 0 AS is_occurrence
+"""
+
+_EVENTS_QUERY = (
+ _EVENT_COLUMNS
+ + """\
+FROM CalendarItem ci
+JOIN Calendar c ON ci.calendar_id = c.ROWID
+WHERE ci.start_date BETWEEN ? AND ?
+ AND ci.summary IS NOT NULL
+ AND ci.hidden = 0
+ORDER BY ci.start_date ASC
+"""
+)
+
+_EVENTS_WITH_OCCURRENCES_QUERY = (
+ _EVENT_COLUMNS
+ + """\
+FROM CalendarItem ci
+JOIN Calendar c ON ci.calendar_id = c.ROWID
+WHERE ci.start_date BETWEEN ? AND ?
+ AND ci.summary IS NOT NULL
+ AND ci.hidden = 0
+ AND NOT EXISTS (
+ SELECT 1
+ FROM OccurrenceCache master_oc
+ WHERE master_oc.event_id = ci.ROWID
+ AND master_oc.occurrence_start_date = ci.start_date
+ )
+UNION
+SELECT
+ ci.ROWID,
+ ci.summary,
+ ci.description,
+ oc.occurrence_start_date AS start_date,
+ oc.occurrence_end_date AS end_date,
+ ci.all_day,
+ ci.start_tz,
+ ci.location_id,
+ ci.has_attendees,
+ ci.last_modified,
+ ci.UUID,
+ c.title AS calendar_title,
+ c.color AS calendar_color,
+ 1 AS is_occurrence
+FROM OccurrenceCache oc
+JOIN CalendarItem ci ON oc.event_id = ci.ROWID
+JOIN Calendar c ON oc.calendar_id = c.ROWID
+WHERE oc.occurrence_end_date >= ?
+ AND oc.occurrence_start_date <= ?
+ AND ci.summary IS NOT NULL
+ AND ci.hidden = 0
+ORDER BY start_date ASC
+"""
+)
+
+_LOCATION_QUERY = """\
+SELECT title, address FROM Location WHERE ROWID = ?
+"""
+
+_SEARCH_QUERY = """\
+SELECT
+ ci.ROWID,
+ ci.summary,
+ ci.description,
+ ci.start_date,
+ ci.end_date,
+ ci.all_day,
+ ci.start_tz,
+ ci.UUID,
+ c.title AS calendar_title
+FROM CalendarItem ci
+JOIN Calendar c ON ci.calendar_id = c.ROWID
+WHERE ci.summary LIKE ?
+ AND ci.hidden = 0
+ORDER BY ci.start_date DESC
+LIMIT ?
+"""
+
+
+# ---------------------------------------------------------------------------
+# AppleCalendarConnector
+# ---------------------------------------------------------------------------
+
+
[email protected]("apple_calendar")
+class AppleCalendarConnector(BaseConnector):
+ """Connector that reads events from the macOS Calendar SQLite database.
+
+ Parameters
+ ----------
+ db_path:
+ Path to ``Calendar.sqlitedb``. Defaults to the system location.
+ days_ahead:
+ How many days into the future to fetch (default: 7).
+ days_behind:
+ How many days into the past to fetch (default: 1).
+ """
+
+ connector_id = "apple_calendar"
+ display_name = "Apple Calendar"
+ auth_type = "local"
+
+ def __init__(
+ self,
+ db_path: str = "",
+ days_ahead: int = _DEFAULT_DAYS_AHEAD,
+ days_behind: int = _DEFAULT_DAYS_BEHIND,
+ ) -> None:
+ self._db_path = Path(db_path) if db_path else _CAL_DB
+ self._days_ahead = days_ahead
+ self._days_behind = days_behind
+ self._items_synced = 0
+ self._items_total = 0
+ self._last_sync: Optional[datetime] = None
+
+ def is_connected(self) -> bool:
+ return self._db_path.exists()
+
+ def disconnect(self) -> None:
+ pass
+
+ def _fetch_location(self, conn: sqlite3.Connection, loc_id: int | None) -> str:
+ if not loc_id:
+ return ""
+ row = conn.execute(_LOCATION_QUERY, (loc_id,)).fetchone()
+ if not row:
+ return ""
+ parts = [p for p in (row[0], row[1]) if p]
+ return ", ".join(parts)
+
+ def _build_content(self, row: tuple, location: str) -> str:
+ (
+ _rowid,
+ summary,
+ description,
+ start_ts,
+ end_ts,
+ all_day,
+ start_tz,
+ _loc_id,
+ has_attendees,
+ _last_mod,
+ _uuid,
+ cal_title,
+ _color,
+ _is_occurrence,
+ ) = row
+
+ start_dt, end_dt = self._display_datetimes(
+ start_ts, end_ts, start_tz, bool(all_day)
+ )
+
+ if all_day:
+ date_str = start_dt.strftime("%A, %B %-d %Y (all day)")
+ else:
+ date_str = start_dt.strftime("%A, %B %-d %Y at %-I:%M %p")
+ if end_dt:
+ date_str += end_dt.strftime(" – %-I:%M %p")
+ if start_tz and start_tz != "_float":
+ date_str += f" ({start_tz})"
+
+ lines = [summary, f"Date: {date_str}", f"Calendar: {cal_title}"]
+ if location:
+ lines.append(f"Location: {location}")
+ if description and description.strip():
+ lines.append(f"Notes: {description.strip()}")
+ if has_attendees:
+ lines.append("Attendees: yes")
+
+ return "\n".join(lines)
+
+ @staticmethod
+ def _display_datetimes(
+ start_ts: float,
+ end_ts: float | None,
+ start_tz: str | None,
+ all_day: bool,
+ ) -> tuple[datetime, datetime | None]:
+ """Preserve Apple Calendar wall-clock semantics for event timestamps."""
+ start_dt = _apple_ts(start_ts)
+ end_dt = _apple_ts(end_ts) if end_ts else None
+ if all_day:
+ # All-day values encode calendar dates, not instants. Converting
+ # them through the machine timezone can move the displayed date.
+ return start_dt.replace(tzinfo=None), (
+ end_dt.replace(tzinfo=None) if end_dt else None
+ )
+ if not start_tz or start_tz == "_float":
+ # Floating events likewise carry a wall time with no timezone.
+ return start_dt.replace(tzinfo=None), (
+ end_dt.replace(tzinfo=None) if end_dt else None
+ )
+ try:
+ zone = ZoneInfo(start_tz)
+ except ZoneInfoNotFoundError:
+ return start_dt, end_dt
+ return start_dt.astimezone(zone), end_dt.astimezone(zone) if end_dt else None
+
+ @staticmethod
+ def _events_query(conn: sqlite3.Connection) -> tuple[str, tuple[int, ...]]:
+ """Select a query shape supported by the current Calendar schema."""
+ occurrence_columns = {
+ row[1] for row in conn.execute("PRAGMA table_info(OccurrenceCache)")
+ }
+ required = {
+ "event_id",
+ "calendar_id",
+ "occurrence_start_date",
+ "occurrence_end_date",
+ }
+ if required <= occurrence_columns:
+ return _EVENTS_WITH_OCCURRENCES_QUERY, (0, 1, 0, 1)
+ return _EVENTS_QUERY, (0, 1)
+
+ def sync(
+ self,
+ *,
+ since: Optional[datetime] = None,
+ cursor: Optional[str] = None,
+ ) -> Iterator[Document]:
+ conn = _open_db(self._db_path)
+ if conn is None:
+ return
+
+ now = datetime.now(tz=timezone.utc)
+ window_start = now - timedelta(days=self._days_behind)
+ window_end = now + timedelta(days=self._days_ahead)
+
+ start_ts = _to_apple_ts(window_start)
+ end_ts = _to_apple_ts(window_end)
+
+ try:
+ query, parameter_order = self._events_query(conn)
+ bounds = (start_ts, end_ts)
+ parameters = tuple(bounds[index] for index in parameter_order)
+ rows = conn.execute(query, parameters).fetchall()
+ self._items_total = len(rows)
+ synced = 0
+
+ for row in rows:
+ (
+ rowid,
+ summary,
+ description,
+ start_date,
+ end_date,
+ all_day,
+ start_tz,
+ loc_id,
+ has_attendees,
+ last_mod,
+ uuid,
+ cal_title,
+ color,
+ is_occurrence,
+ ) = row
+
+ timestamp = _apple_ts(last_mod) if last_mod else _apple_ts(start_date)
+ if since is not None:
+ since_utc = (
+ since if since.tzinfo else since.replace(tzinfo=timezone.utc)
+ )
+ if timestamp < since_utc:
+ continue
+
+ location = self._fetch_location(conn, loc_id)
+ content = self._build_content(row, location)
+ start_dt, _ = self._display_datetimes(
+ start_date, end_date, start_tz, bool(all_day)
+ )
+
+ meta: Dict[str, Any] = {
+ "summary": summary,
+ "calendar": cal_title,
+ "start": start_dt.isoformat(),
+ "all_day": bool(all_day),
+ "location": location,
+ "has_attendees": bool(has_attendees),
+ }
+
+ yield Document(
+ doc_id=(
+ f"apple_calendar:{uuid or rowid}:{int(start_date)}"
+ if is_occurrence
+ else f"apple_calendar:{uuid or rowid}"
+ ),
+ source="apple_calendar",
+ doc_type="calendar_event",
+ content=content,
+ title=summary,
+ author=cal_title,
+ timestamp=timestamp,
+ metadata=meta,
+ )
+ synced += 1
+
+ self._items_synced = synced
+
+ finally:
+ conn.close()
+
+ self._last_sync = datetime.now(tz=timezone.utc)
+
+ def sync_status(self) -> SyncStatus:
+ return SyncStatus(
+ state="idle",
+ items_synced=self._items_synced,
+ items_total=self._items_total,
+ last_sync=self._last_sync,
+ )
+
+ def mcp_tools(self) -> List[ToolSpec]:
+ return [
+ ToolSpec(
+ name="calendar_upcoming",
+ description=(
+ "Return upcoming Apple Calendar events. "
+ "Reads directly from the local macOS Calendar database."
+ ),
+ parameters={
+ "type": "object",
+ "properties": {
+ "days_ahead": {
+ "type": "integer",
+ "description": "Number of days ahead to look (default: 7)",
+ "default": 7,
+ },
+ },
+ },
+ category="knowledge",
+ ),
+ ToolSpec(
+ name="calendar_search",
+ description="Search Apple Calendar events by title keyword.",
+ parameters={
+ "type": "object",
+ "properties": {
+ "query": {
+ "type": "string",
+ "description": "Keyword to search in event titles",
+ },
+ "max_results": {
+ "type": "integer",
+ "description": "Maximum results to return",
+ "default": 20,
+ },
+ },
+ "required": ["query"],
+ },
+ category="knowledge",
+ ),
+ ]
diff --git a/src/openjarvis/security/data_boundary_audit.py b/src/openjarvis/security/data_boundary_audit.py
index f96aefe5..025966c6 100644
--- a/src/openjarvis/security/data_boundary_audit.py
+++ b/src/openjarvis/security/data_boundary_audit.py
@@ -225,6 +225,8 @@ CLOUD_API_SURFACES = CLOUD_MEDIA_TOOLS | WEB_SEARCH_TOOLS
OUTBOUND_TOOL_SURFACES = EXTERNAL_TOOL_SURFACES
LOCAL_ACCESS_TOOLS = {
"apply_patch",
+ "calendar_search",
+ "calendar_upcoming",
"channel_list",
"channel_status",
"code_interpreter",
diff --git a/src/openjarvis/tools/__init__.py b/src/openjarvis/tools/__init__.py
index 41d8e1b4..cc9f06bc 100644
--- a/src/openjarvis/tools/__init__.py
+++ b/src/openjarvis/tools/__init__.py
@@ -152,4 +152,9 @@ try:
except ImportError:
pass
+try:
+ import openjarvis.tools.apple_calendar # noqa: F401
+except ImportError:
+ pass
+
__all__ = ["BaseTool", "ToolExecutor", "ToolSpec"]
diff --git a/src/openjarvis/tools/apple_calendar.py b/src/openjarvis/tools/apple_calendar.py
new file mode 100644
index 00000000..7799b99b
--- /dev/null
+++ b/src/openjarvis/tools/apple_calendar.py
@@ -0,0 +1,99 @@
+"""Executable tools for the local Apple Calendar connector."""
+
+from __future__ import annotations
+
+import sqlite3
+from typing import Any
+
+from openjarvis.core.registry import ToolRegistry
+from openjarvis.core.types import ToolResult
+from openjarvis.tools._stubs import BaseTool, ToolSpec
+
+
[email protected]("calendar_upcoming")
+class CalendarUpcomingTool(BaseTool):
+ """Return upcoming events from the local Apple Calendar database."""
+
+ tool_id = "calendar_upcoming"
+
+ @property
+ def spec(self) -> ToolSpec:
+ # Keep connector imports lazy. Connectors use ``ToolSpec`` from the
+ # tools package, so importing the connector here at module load time
+ # creates a connector -> tools -> connector cycle and can skip these
+ # registry decorators depending on import order.
+ from openjarvis.connectors.apple_calendar import AppleCalendarConnector
+
+ return AppleCalendarConnector().mcp_tools()[0]
+
+ def execute(self, **params: Any) -> ToolResult:
+ from openjarvis.connectors.apple_calendar import AppleCalendarConnector
+
+ days_ahead = max(0, int(params.get("days_ahead", 7)))
+ connector = AppleCalendarConnector(days_ahead=days_ahead, days_behind=0)
+ documents = list(connector.sync())
+ return ToolResult(
+ tool_name=self.tool_id,
+ content="\n\n".join(document.content for document in documents)
+ or "No upcoming Apple Calendar events found.",
+ success=True,
+ metadata={"count": len(documents)},
+ )
+
+
[email protected]("calendar_search")
+class CalendarSearchTool(BaseTool):
+ """Search event titles in the local Apple Calendar database."""
+
+ tool_id = "calendar_search"
+
+ @property
+ def spec(self) -> ToolSpec:
+ from openjarvis.connectors.apple_calendar import AppleCalendarConnector
+
+ return AppleCalendarConnector().mcp_tools()[1]
+
+ def execute(self, **params: Any) -> ToolResult:
+ from openjarvis.connectors.apple_calendar import (
+ _SEARCH_QUERY,
+ AppleCalendarConnector,
+ _open_db,
+ )
+
+ query = str(params.get("query", "")).strip()
+ if not query:
+ return ToolResult(
+ tool_name=self.tool_id,
+ content="A non-empty query is required.",
+ success=False,
+ )
+ limit = max(1, min(int(params.get("max_results", 20)), 100))
+ connector = AppleCalendarConnector()
+ conn = _open_db(connector._db_path)
+ if conn is None:
+ return ToolResult(
+ tool_name=self.tool_id,
+ content="Apple Calendar database is unavailable.",
+ success=False,
+ )
+ try:
+ rows = conn.execute(_SEARCH_QUERY, (f"%{query}%", limit)).fetchall()
+ except sqlite3.Error as exc:
+ return ToolResult(
+ tool_name=self.tool_id,
+ content=f"Apple Calendar search failed: {exc}",
+ success=False,
+ )
+ finally:
+ conn.close()
+ lines = [
+ f"{row[1]} — "
+ f"{connector._display_datetimes(row[3], row[4], row[6], bool(row[5]))[0]}"
+ for row in rows
+ ]
+ return ToolResult(
+ tool_name=self.tool_id,
+ content="\n".join(lines) or f"No Apple Calendar events matched '{query}'.",
+ success=True,
+ metadata={"count": len(rows)},
+ )
diff --git a/tests/connectors/test_apple_calendar.py b/tests/connectors/test_apple_calendar.py
new file mode 100644
index 00000000..4e0ee10e
--- /dev/null
+++ b/tests/connectors/test_apple_calendar.py
@@ -0,0 +1,169 @@
+"""Integration tests for the read-only Apple Calendar connector and tools."""
+
+from __future__ import annotations
+
+import sqlite3
+from datetime import datetime, timedelta, timezone
+from zoneinfo import ZoneInfo
+
+from openjarvis.connectors.apple_calendar import (
+ AppleCalendarConnector,
+ _to_apple_ts,
+)
+from openjarvis.core.registry import ToolRegistry
+
+
+def _make_calendar_db(path):
+ conn = sqlite3.connect(path)
+ conn.executescript(
+ """
+ CREATE TABLE Calendar (ROWID INTEGER PRIMARY KEY, title TEXT, color TEXT);
+ CREATE TABLE CalendarItem (
+ ROWID INTEGER PRIMARY KEY, summary TEXT, description TEXT,
+ start_date REAL, end_date REAL, all_day INTEGER, start_tz TEXT,
+ location_id INTEGER, has_attendees INTEGER, last_modified REAL,
+ UUID TEXT, calendar_id INTEGER, hidden INTEGER
+ );
+ CREATE TABLE Location (ROWID INTEGER PRIMARY KEY, title TEXT, address TEXT);
+ CREATE TABLE OccurrenceCache (
+ event_id INTEGER, calendar_id INTEGER,
+ occurrence_start_date REAL, occurrence_end_date REAL
+ );
+ INSERT INTO Calendar VALUES (1, 'Work', '#123456');
+ """
+ )
+ return conn
+
+
+def _insert_event(conn, *, rowid, summary, start, end, tz="UTC", uuid=None):
+ conn.execute(
+ """INSERT INTO CalendarItem VALUES
+ (?, ?, '', ?, ?, 0, ?, NULL, 0, ?, ?, 1, 0)""",
+ (
+ rowid,
+ summary,
+ _to_apple_ts(start),
+ _to_apple_ts(end),
+ tz,
+ _to_apple_ts(start),
+ uuid or f"event-{rowid}",
+ ),
+ )
+
+
+def test_missing_database_is_an_empty_sync(tmp_path):
+ connector = AppleCalendarConnector(db_path=str(tmp_path / "missing.sqlite"))
+ assert list(connector.sync()) == []
+
+
+def test_timezone_is_converted_before_display(tmp_path):
+ db = tmp_path / "calendar.sqlite"
+ conn = _make_calendar_db(db)
+ now = datetime.now(timezone.utc)
+ start = (now + timedelta(hours=1)).replace(minute=0, second=0, microsecond=0)
+ _insert_event(
+ conn,
+ rowid=1,
+ summary="Pacific meeting",
+ start=start,
+ end=start + timedelta(hours=1),
+ tz="America/Los_Angeles",
+ )
+ conn.commit()
+ conn.close()
+
+ document = list(AppleCalendarConnector(db_path=str(db)).sync())[0]
+ local_start = start.astimezone(ZoneInfo("America/Los_Angeles"))
+ assert local_start.strftime("%-I:%M %p") in document.content
+ assert document.metadata["start"] == local_start.isoformat()
+
+
+def test_recurring_master_outside_window_yields_distinct_occurrences(tmp_path):
+ db = tmp_path / "calendar.sqlite"
+ conn = _make_calendar_db(db)
+ now = datetime.now(timezone.utc)
+ master = now - timedelta(days=90)
+ _insert_event(
+ conn,
+ rowid=1,
+ summary="Weekly standup",
+ start=master,
+ end=master + timedelta(hours=1),
+ uuid="weekly",
+ )
+ for offset in (1, 3):
+ start = now + timedelta(days=offset)
+ conn.execute(
+ "INSERT INTO OccurrenceCache VALUES (1, 1, ?, ?)",
+ (_to_apple_ts(start), _to_apple_ts(start + timedelta(hours=1))),
+ )
+ conn.commit()
+ conn.close()
+
+ documents = list(AppleCalendarConnector(db_path=str(db)).sync())
+ assert [document.title for document in documents] == [
+ "Weekly standup",
+ "Weekly standup",
+ ]
+ assert len({document.doc_id for document in documents}) == 2
+
+
+def test_recurring_master_is_not_duplicated_by_same_start_occurrence(tmp_path):
+ db = tmp_path / "calendar.sqlite"
+ conn = _make_calendar_db(db)
+ now = datetime.now(timezone.utc)
+ start = now + timedelta(hours=1)
+ _insert_event(
+ conn,
+ rowid=1,
+ summary="Weekly standup",
+ start=start,
+ end=start + timedelta(hours=1),
+ uuid="weekly",
+ )
+ conn.execute(
+ "INSERT INTO OccurrenceCache VALUES (1, 1, ?, ?)",
+ (_to_apple_ts(start), _to_apple_ts(start + timedelta(hours=1))),
+ )
+ conn.commit()
+ conn.close()
+
+ documents = list(AppleCalendarConnector(db_path=str(db)).sync())
+
+ assert [document.title for document in documents] == ["Weekly standup"]
+ assert documents[0].doc_id.startswith("apple_calendar:weekly:")
+
+
+def test_calendar_tools_are_registered_and_executable(tmp_path, monkeypatch):
+ import openjarvis.connectors.apple_calendar as calendar_module
+ from openjarvis.tools.apple_calendar import (
+ CalendarSearchTool,
+ CalendarUpcomingTool,
+ )
+
+ # The suite's autouse fixture intentionally clears registries after test
+ # modules are collected, so restore the two classes explicitly here. The
+ # fresh-process import-order behavior is covered in test_tool_registration.
+ if not ToolRegistry.contains("calendar_upcoming"):
+ ToolRegistry.register_value("calendar_upcoming", CalendarUpcomingTool)
+ if not ToolRegistry.contains("calendar_search"):
+ ToolRegistry.register_value("calendar_search", CalendarSearchTool)
+
+ db = tmp_path / "calendar.sqlite"
+ conn = _make_calendar_db(db)
+ now = datetime.now(timezone.utc)
+ _insert_event(
+ conn,
+ rowid=1,
+ summary="Planning session",
+ start=now + timedelta(hours=1),
+ end=now + timedelta(hours=2),
+ )
+ conn.commit()
+ conn.close()
+ monkeypatch.setattr(calendar_module, "_CAL_DB", db)
+
+ upcoming = ToolRegistry.get("calendar_upcoming")().execute(days_ahead=1)
+ search = ToolRegistry.get("calendar_search")().execute(query="Planning")
+ assert upcoming.success and "Planning session" in upcoming.content
+ assert search.success and "Planning session" in search.content
diff --git a/tests/security/test_data_boundary_audit.py b/tests/security/test_data_boundary_audit.py
index 5d61c3bc..886345c3 100644
--- a/tests/security/test_data_boundary_audit.py
+++ b/tests/security/test_data_boundary_audit.py
@@ -44,6 +44,8 @@ EXPECTED_KNOWLEDGE_ENGINE_TOOLS = {"scan_chunks"}
EXPECTED_LOCAL_ACCESS_TOOLS = {
"file_write",
"apply_patch",
+ "calendar_search",
+ "calendar_upcoming",
"docker_shell_exec",
"db_query",
"knowledge_sql",
diff --git a/tests/tools/test_tool_registration.py b/tests/tools/test_tool_registration.py
index d17f0ece..4746e9c5 100644
--- a/tests/tools/test_tool_registration.py
+++ b/tests/tools/test_tool_registration.py
@@ -75,6 +75,9 @@ EXPECTED_TOOLS = {
"knowledge_sql",
# scan_chunks.py
"scan_chunks",
+ # apple_calendar.py
+ "calendar_upcoming",
+ "calendar_search",
}
@@ -129,3 +132,25 @@ def test_package_import_registers_deep_research_tools():
)
assert result.returncode == 0, result.stderr
+
+
+def test_calendar_tools_register_when_connector_is_imported_first():
+ """Connector imports must not suppress calendar tool registration."""
+ result = subprocess.run(
+ [
+ sys.executable,
+ "-c",
+ (
+ "import openjarvis.connectors.apple_calendar; "
+ "from openjarvis.core.registry import ToolRegistry; "
+ "expected = {'calendar_upcoming', 'calendar_search'}; "
+ "missing = expected - set(ToolRegistry.keys()); "
+ "assert not missing, f'Missing tools: {sorted(missing)}'"
+ ),
+ ],
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+
+ assert result.returncode == 0, result.stderr