arcade-google-sheets 4.0.0__py3-none-any.whl → 4.2.1__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.
@@ -1,6 +1,7 @@
1
1
  from arcade_google_sheets.tools.file_picker import generate_google_file_picker_url
2
2
  from arcade_google_sheets.tools.read import get_spreadsheet, get_spreadsheet_metadata
3
3
  from arcade_google_sheets.tools.search import search_spreadsheets
4
+ from arcade_google_sheets.tools.system_context import who_am_i
4
5
  from arcade_google_sheets.tools.write import (
5
6
  add_note_to_cell,
6
7
  create_spreadsheet,
@@ -17,4 +18,5 @@ __all__ = [
17
18
  "add_note_to_cell",
18
19
  "write_to_cell",
19
20
  "generate_google_file_picker_url",
21
+ "who_am_i",
20
22
  ]
@@ -0,0 +1,37 @@
1
+ from typing import Annotated, Any
2
+
3
+ from arcade_tdk import ToolContext, tool
4
+ from arcade_tdk.auth import Google
5
+
6
+ from arcade_google_sheets.utils import build_sheets_service
7
+ from arcade_google_sheets.who_am_i_util import build_who_am_i_response
8
+
9
+
10
+ @tool(
11
+ requires_auth=Google(
12
+ scopes=[
13
+ "https://www.googleapis.com/auth/drive.file",
14
+ "https://www.googleapis.com/auth/userinfo.profile",
15
+ "https://www.googleapis.com/auth/userinfo.email",
16
+ ]
17
+ )
18
+ )
19
+ async def who_am_i(
20
+ context: ToolContext,
21
+ ) -> Annotated[
22
+ dict[str, Any],
23
+ "Get comprehensive user profile and Google Sheets environment information.",
24
+ ]:
25
+ """
26
+ Get comprehensive user profile and Google Sheets environment information.
27
+
28
+ This tool provides detailed information about the authenticated user including
29
+ their name, email, profile picture, Google Sheets access permissions, and other
30
+ important profile details from Google services.
31
+ """
32
+
33
+ auth_token = context.get_auth_token_or_empty()
34
+ sheets_service = build_sheets_service(auth_token)
35
+ user_info = build_who_am_i_response(context, sheets_service)
36
+
37
+ return dict(user_info)
@@ -0,0 +1,81 @@
1
+ from typing import Any, TypedDict, cast
2
+
3
+ from google.oauth2.credentials import Credentials
4
+ from googleapiclient.discovery import build
5
+
6
+
7
+ class WhoAmIResponse(TypedDict, total=False):
8
+ my_email_address: str
9
+ display_name: str
10
+ given_name: str
11
+ family_name: str
12
+ formatted_name: str
13
+ profile_picture_url: str
14
+ google_sheets_access: bool
15
+
16
+
17
+ def build_who_am_i_response(context: Any, sheets_service: Any) -> WhoAmIResponse:
18
+ """Build complete who_am_i response from Google Sheets and People APIs."""
19
+ credentials = Credentials(
20
+ context.authorization.token if context.authorization and context.authorization.token else ""
21
+ )
22
+ people_service = _build_people_service(credentials)
23
+ person = _get_people_api_data(people_service)
24
+
25
+ user_info = _extract_profile_data(person)
26
+ user_info.update(_extract_google_sheets_info(sheets_service))
27
+
28
+ return cast(WhoAmIResponse, user_info)
29
+
30
+
31
+ def _extract_profile_data(person: dict[str, Any]) -> dict[str, Any]:
32
+ """Extract user profile data from People API response."""
33
+ profile_data = {}
34
+
35
+ names = person.get("names", [])
36
+ if names:
37
+ primary_name = names[0]
38
+ profile_data.update({
39
+ "display_name": primary_name.get("displayName"),
40
+ "given_name": primary_name.get("givenName"),
41
+ "family_name": primary_name.get("familyName"),
42
+ "formatted_name": primary_name.get("displayNameLastFirst"),
43
+ })
44
+
45
+ photos = person.get("photos", [])
46
+ if photos:
47
+ profile_data["profile_picture_url"] = photos[0].get("url")
48
+
49
+ email_addresses = person.get("emailAddresses", [])
50
+ if email_addresses:
51
+ primary_emails = [
52
+ email for email in email_addresses if email.get("metadata", {}).get("primary")
53
+ ]
54
+ if primary_emails:
55
+ profile_data["my_email_address"] = primary_emails[0].get("value")
56
+
57
+ return profile_data
58
+
59
+
60
+ def _extract_google_sheets_info(sheets_service: Any) -> dict[str, Any]:
61
+ """Extract minimal Google Sheets access information."""
62
+ sheets_info: dict[str, Any] = {}
63
+ try:
64
+ sheets_info["google_sheets_access"] = True
65
+ except Exception:
66
+ sheets_info["google_sheets_access"] = False
67
+ return sheets_info
68
+
69
+
70
+ def _build_people_service(credentials: Credentials) -> Any:
71
+ """Build and return the People API service client."""
72
+ return build("people", "v1", credentials=credentials)
73
+
74
+
75
+ def _get_people_api_data(people_service: Any) -> dict[str, Any]:
76
+ """Get user profile information from People API."""
77
+ person_fields = "names,emailAddresses,photos"
78
+ return cast(
79
+ dict[str, Any],
80
+ people_service.people().get(resourceName="people/me", personFields=person_fields).execute(),
81
+ )
@@ -1,20 +1,20 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arcade_google_sheets
3
- Version: 4.0.0
3
+ Version: 4.2.1
4
4
  Summary: Arcade.dev LLM tools for Google Sheets
5
5
  Author-email: Arcade <dev@arcade.dev>
6
6
  License: Proprietary - Arcade Software License Agreement v1.0
7
7
  License-File: LICENSE
8
8
  Requires-Python: >=3.10
9
- Requires-Dist: arcade-tdk<3.0.0,>=2.0.0
9
+ Requires-Dist: arcade-tdk<3.0.0,>=2.3.1
10
10
  Requires-Dist: google-api-core<3.0.0,>=2.19.1
11
11
  Requires-Dist: google-api-python-client<3.0.0,>=2.137.0
12
12
  Requires-Dist: google-auth-httplib2<1.0.0,>=0.2.0
13
13
  Requires-Dist: google-auth<3.0.0,>=2.32.0
14
14
  Requires-Dist: googleapis-common-protos<2.0.0,>=1.63.2
15
15
  Provides-Extra: dev
16
- Requires-Dist: arcade-ai[evals]<3.0.0,>=2.0.0; extra == 'dev'
17
- Requires-Dist: arcade-serve<3.0.0,>=2.0.0; extra == 'dev'
16
+ Requires-Dist: arcade-ai[evals]<3.0.0,>=2.2.1; extra == 'dev'
17
+ Requires-Dist: arcade-serve<3.0.0,>=2.1.0; extra == 'dev'
18
18
  Requires-Dist: mypy<1.6.0,>=1.5.1; extra == 'dev'
19
19
  Requires-Dist: pre-commit<3.5.0,>=3.4.0; extra == 'dev'
20
20
  Requires-Dist: pytest-asyncio<0.25.0,>=0.24.0; extra == 'dev'
@@ -6,12 +6,14 @@ arcade_google_sheets/models.py,sha256=xwPdwUis0OHTDbSLy85qWl7zIh2lDTi5HZMNKwdZjz
6
6
  arcade_google_sheets/templates.py,sha256=hSvjiErERLPe6RqWY6QNmivOy7Ofdg_zABcLWCI-ByU,189
7
7
  arcade_google_sheets/types.py,sha256=R-rCRcyFqDZx3jgl_kWeCliqC8fHuZ8ub_LQ2KoU2AE,37
8
8
  arcade_google_sheets/utils.py,sha256=VmDZOzAOEtfSPOra-ieVl_U16RLonQUOnZ4RW4Gf-oA,34895
9
- arcade_google_sheets/tools/__init__.py,sha256=ZUhznD9qcK0cdaFM05I2eA2SCpY2nD4ou2_zUR8rHek,594
9
+ arcade_google_sheets/who_am_i_util.py,sha256=MfDKsAOMUkH0DZNjMzcmDiuvxMEUJMT9o_a7uixCJF4,2734
10
+ arcade_google_sheets/tools/__init__.py,sha256=GBe1Op-o6QzCy9nA3qS53Ij2Uex5IXdFPUnGQo_TPkg,673
10
11
  arcade_google_sheets/tools/file_picker.py,sha256=Dqn-hfMoTsWyHM8QCakVgHr5TKrzL_1Lj-vYHVGtOW4,2342
11
12
  arcade_google_sheets/tools/read.py,sha256=qQX_TdcbPbkuaHPuhx7CzWsWJ_a97FSCDJqOlGHF_TM,4003
12
13
  arcade_google_sheets/tools/search.py,sha256=olCaUwDqW26yaYqMT5lPmQDFL6M9g7qON7JG3mcgYJM,4841
14
+ arcade_google_sheets/tools/system_context.py,sha256=rVpYeyFsL8mj0Lt6VWOhnfGaSy3ezOHL74EFJHjE9Ww,1176
13
15
  arcade_google_sheets/tools/write.py,sha256=4kNx941PQt6VUGTogbepnbfUdcsVze6u5c8QvlNnWCI,7782
14
- arcade_google_sheets-4.0.0.dist-info/METADATA,sha256=qDIQQqgbsYxUsqvmpNS7Om8xx9yC3HO_LfLA4uAbcYs,1123
15
- arcade_google_sheets-4.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- arcade_google_sheets-4.0.0.dist-info/licenses/LICENSE,sha256=ixeE7aL9b2B-_ZYHTY1vQcJB4NufKeo-LWwKNObGDN0,1960
17
- arcade_google_sheets-4.0.0.dist-info/RECORD,,
16
+ arcade_google_sheets-4.2.1.dist-info/METADATA,sha256=xM1z7j9tHzv6ncsWfQ2fU0dKY7BkNZ_lBgufskoz68w,1123
17
+ arcade_google_sheets-4.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ arcade_google_sheets-4.2.1.dist-info/licenses/LICENSE,sha256=ixeE7aL9b2B-_ZYHTY1vQcJB4NufKeo-LWwKNObGDN0,1960
19
+ arcade_google_sheets-4.2.1.dist-info/RECORD,,