cortexflow-google-calendar 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,7 @@
1
+ """cortexflow-google-calendar — example CortexFlow plugin: Calendar events."""
2
+
3
+ from cortexflow_google_calendar.plugin import GoogleCalendarPlugin
4
+ from cortexflow_google_calendar.tool import GoogleCalendarEventsTool
5
+
6
+ __all__ = ["GoogleCalendarEventsTool", "GoogleCalendarPlugin"]
7
+ __version__ = "0.1.0"
@@ -0,0 +1,34 @@
1
+ """GoogleCalendarPlugin — registers GoogleCalendarEventsTool with the gateway."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+
7
+ from cortexflow_sdk import Plugin, PluginMetadata
8
+
9
+ from cortexflow_google_calendar.tool import GoogleCalendarEventsTool
10
+
11
+
12
+ class GoogleCalendarPlugin(Plugin):
13
+ """Adds a calendar_list_events tool.
14
+
15
+ Reads GOOGLE_CALENDAR_ACCESS_TOKEN from the environment — a short-lived
16
+ OAuth2 access token, not a long-lived API key. Refreshing that token is
17
+ left to the operator (e.g. a cron job calling Google's OAuth2 token
18
+ endpoint with a stored refresh token).
19
+ """
20
+
21
+ metadata = PluginMetadata(
22
+ name="cortexflow-google-calendar",
23
+ version="0.1.0",
24
+ plugin_type="tool",
25
+ description="List upcoming Google Calendar events.",
26
+ permissions=["network"],
27
+ homepage="https://github.com/TheAmitChandra/CortexFlow",
28
+ )
29
+
30
+ def __init__(self) -> None:
31
+ self._access_token = os.getenv("GOOGLE_CALENDAR_ACCESS_TOKEN")
32
+
33
+ def get_tools(self):
34
+ return [GoogleCalendarEventsTool(access_token=self._access_token)]
@@ -0,0 +1,79 @@
1
+ """GoogleCalendarEventsTool — lists upcoming events from a Google Calendar."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import datetime
6
+
7
+ from cortexflow_sdk import Tool, ToolResult
8
+
9
+ _EVENTS_URL = "https://www.googleapis.com/calendar/v3/calendars/{calendar_id}/events"
10
+
11
+
12
+ def _now_iso() -> str:
13
+ return datetime.datetime.now(datetime.timezone.utc).isoformat()
14
+
15
+
16
+ class GoogleCalendarEventsTool(Tool):
17
+ """Lists upcoming events from a Google Calendar via the Calendar API v3.
18
+
19
+ Requires an OAuth2 access token with the
20
+ ``https://www.googleapis.com/auth/calendar.readonly`` scope — obtaining
21
+ that token (the OAuth consent flow) is out of scope for this tool.
22
+ """
23
+
24
+ name = "calendar_list_events"
25
+ description = "List upcoming events from a Google Calendar."
26
+ parameters = {
27
+ "calendar_id": {
28
+ "type": "str",
29
+ "description": "Calendar ID, or 'primary' for the user's main calendar",
30
+ "required": False,
31
+ },
32
+ "limit": {"type": "int", "description": "Max events to return (default 10)", "required": False},
33
+ }
34
+ permissions = ["network"]
35
+
36
+ def __init__(self, access_token: str | None = None) -> None:
37
+ self._access_token = access_token
38
+
39
+ async def execute(self, calendar_id: str = "primary", limit: int = 10, **_) -> ToolResult:
40
+ if not self._access_token:
41
+ return ToolResult(
42
+ tool=self.name, output=None, error="GOOGLE_CALENDAR_ACCESS_TOKEN not set",
43
+ )
44
+
45
+ try:
46
+ import httpx
47
+ except ImportError:
48
+ return ToolResult(tool=self.name, output=None, error="pip install httpx")
49
+
50
+ url = _EVENTS_URL.format(calendar_id=calendar_id)
51
+ headers = {"Authorization": f"Bearer {self._access_token}"}
52
+ params = {
53
+ "timeMin": _now_iso(),
54
+ "maxResults": min(limit, 100),
55
+ "singleEvents": "true",
56
+ "orderBy": "startTime",
57
+ }
58
+
59
+ try:
60
+ async with httpx.AsyncClient() as client:
61
+ resp = await client.get(url, headers=headers, params=params, timeout=10.0)
62
+ resp.raise_for_status()
63
+ data = resp.json()
64
+ except Exception as exc:
65
+ return ToolResult(tool=self.name, output=None, error=str(exc))
66
+
67
+ events = [
68
+ {
69
+ "summary": e.get("summary", "(no title)"),
70
+ "start": (e.get("start") or {}).get("dateTime") or (e.get("start") or {}).get("date", ""),
71
+ "link": e.get("htmlLink", ""),
72
+ }
73
+ for e in data.get("items", [])[:limit]
74
+ ]
75
+ return ToolResult(
76
+ tool=self.name,
77
+ output=events,
78
+ metadata={"calendar_id": calendar_id, "count": len(events)},
79
+ )
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.4
2
+ Name: cortexflow-google-calendar
3
+ Version: 0.1.0
4
+ Summary: CortexFlow plugin — list upcoming Google Calendar events.
5
+ Author-email: Amit Chandra <amit.vervebot@gmail.com>
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: cortexflow-sdk>=0.1.0
11
+ Requires-Dist: httpx>=0.27.0
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=8.2.0; extra == "dev"
14
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
15
+ Dynamic: license-file
16
+
17
+ # cortexflow-google-calendar
18
+
19
+ Example CortexFlow plugin: a `calendar_list_events` tool that lists upcoming
20
+ events from a Google Calendar via Calendar API v3.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install -e ./cortexflow-sdk # not yet on PyPI
26
+ pip install -e examples/plugins/cortexflow-google-calendar
27
+ ```
28
+
29
+ ## Setup
30
+
31
+ This tool expects an OAuth2 **access token** with the
32
+ `https://www.googleapis.com/auth/calendar.readonly` scope, set as
33
+ `GOOGLE_CALENDAR_ACCESS_TOKEN`. Obtaining and refreshing that token (the
34
+ OAuth consent flow against Google's identity service) is outside this
35
+ plugin's scope — wire it up via your own token-refresh job or a library like
36
+ `google-auth-oauthlib`.
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+ from cortexflow_google_calendar import GoogleCalendarEventsTool
42
+
43
+ tool = GoogleCalendarEventsTool(access_token="ya29....")
44
+ result = await tool.execute(calendar_id="primary", limit=5)
45
+ print(result.output)
46
+ ```
47
+
48
+ Once installed alongside the CortexFlow gateway, `PluginRegistry.discover()`
49
+ finds it via the `cortexflow.plugins` entry point declared in
50
+ `pyproject.toml`.
@@ -0,0 +1,9 @@
1
+ cortexflow_google_calendar/__init__.py,sha256=7g-JI3-cPsZO1wzrFHdqybCrhRwgD1og2pPn2gw-odo,304
2
+ cortexflow_google_calendar/plugin.py,sha256=dKzmSlhYJjzTPhUXgZo1cZUAeE3rVomQlzBZpUrMXCQ,1107
3
+ cortexflow_google_calendar/tool.py,sha256=FwhnERXOzoQ_9LEv3iqY1abj3cV1vEqQuUJ7sldcsKM,2781
4
+ cortexflow_google_calendar-0.1.0.dist-info/licenses/LICENSE,sha256=7Dz5G7L1S2nxC1KQDChyyWKVx4NDmJJDf-KNruUtrHk,1069
5
+ cortexflow_google_calendar-0.1.0.dist-info/METADATA,sha256=NZRAdpNC4fCoNJnVw_XTq4UaVg8cXoxKjhaP4b51t_c,1561
6
+ cortexflow_google_calendar-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
7
+ cortexflow_google_calendar-0.1.0.dist-info/entry_points.txt,sha256=GNbYnWsDyoKmR9HnAiglAq-tIR9qEDRXuTTSwpBmGXE,105
8
+ cortexflow_google_calendar-0.1.0.dist-info/top_level.txt,sha256=70TUltWNZDVK0ex9gf0RULpZUjIcXE9D7voP8Y54ND8,27
9
+ cortexflow_google_calendar-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [cortexflow.plugins]
2
+ cortexflow-google-calendar = cortexflow_google_calendar.plugin:GoogleCalendarPlugin
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Amit Chandra
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ cortexflow_google_calendar