arcade-google-docs 4.1.0__py3-none-any.whl → 4.2.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.
@@ -12,6 +12,7 @@ from arcade_google_docs.tools.search import (
12
12
  search_and_retrieve_documents,
13
13
  search_documents,
14
14
  )
15
+ from arcade_google_docs.tools.system_context import who_am_i
15
16
  from arcade_google_docs.tools.update import insert_text_at_end_of_document
16
17
 
17
18
  __all__ = [
@@ -24,4 +25,5 @@ __all__ = [
24
25
  "search_and_retrieve_documents",
25
26
  "search_documents",
26
27
  "generate_google_file_picker_url",
28
+ "who_am_i",
27
29
  ]
@@ -0,0 +1,36 @@
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_docs.utils import build_docs_service
7
+ from arcade_google_docs.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 Docs environment information.",
24
+ ]:
25
+ """
26
+ Get comprehensive user profile and Google Docs environment information.
27
+
28
+ This tool provides detailed information about the authenticated user including
29
+ their name, email, profile picture, Google Docs access permissions, and other
30
+ important profile details from Google services.
31
+ """
32
+
33
+ docs_service = build_docs_service(context.get_auth_token_or_empty())
34
+ user_info = build_who_am_i_response(context, docs_service)
35
+
36
+ return dict(user_info)
@@ -0,0 +1,86 @@
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_docs_access: bool
15
+
16
+
17
+ def build_who_am_i_response(context: Any, docs_service: Any) -> WhoAmIResponse:
18
+ """Build complete who_am_i response from Google Docs 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_docs_info(docs_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_docs_info(docs_service: Any) -> dict[str, Any]:
61
+ """Extract Google Docs specific information."""
62
+ docs_info = {}
63
+
64
+ try:
65
+ # Test Google Docs access by checking if we can access the service
66
+ # Since there's no direct way to test docs access, we'll assume it's available
67
+ # if we have the service (the scope validation happens at auth time)
68
+ docs_info["google_docs_access"] = True
69
+ except Exception:
70
+ docs_info["google_docs_access"] = False
71
+
72
+ return docs_info
73
+
74
+
75
+ def _build_people_service(credentials: Credentials) -> Any:
76
+ """Build and return the People API service client."""
77
+ return build("people", "v1", credentials=credentials)
78
+
79
+
80
+ def _get_people_api_data(people_service: Any) -> dict[str, Any]:
81
+ """Get user profile information from People API."""
82
+ person_fields = "names,emailAddresses,photos"
83
+ return cast(
84
+ dict[str, Any],
85
+ people_service.people().get(resourceName="people/me", personFields=person_fields).execute(),
86
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arcade_google_docs
3
- Version: 4.1.0
3
+ Version: 4.2.0
4
4
  Summary: Arcade.dev LLM tools for Google Docs
5
5
  Author-email: Arcade <dev@arcade.dev>
6
6
  License: Proprietary - Arcade Software License Agreement v1.0
@@ -5,15 +5,17 @@ arcade_google_docs/docmd.py,sha256=rgxUt0k2Nes0GWLlPR49qU0nnM8e6HCiqd61Z7zNfTk,2
5
5
  arcade_google_docs/enum.py,sha256=kuXlsHcMYbN28Qg-Dwp4viz-CZ8z85_WVjQVZj2EsEY,3441
6
6
  arcade_google_docs/templates.py,sha256=pxbdMj57eV3-ImW3CixDWscpVKS94Z8nTNyTxDhUfGY,283
7
7
  arcade_google_docs/utils.py,sha256=XMgKcWPWKy8SbH3y2eCil01hssHhUgYxVrwXyvHEU4A,3748
8
+ arcade_google_docs/who_am_i_util.py,sha256=NGQpQ0CuE2N86mGpkIdujXBRjcPBJ5SJ9BYzlb3mGFI,2925
8
9
  arcade_google_docs/models/document.py,sha256=0RvZ2_dfpz6ZoF1aUucYWOkRYWy_K_hiChSzoQtwhTc,30419
9
10
  arcade_google_docs/models/document_writables.py,sha256=DMBT5A05y7o7_PYlBB6O3KThma6-pm6hd5nxKGydT5Q,27575
10
11
  arcade_google_docs/models/requests.py,sha256=8Cga7QECmQWNFhM2QiGudvnQcgA_THi7ThNsUb7uavg,52176
11
- arcade_google_docs/tools/__init__.py,sha256=s0FS3z-uXE4lQH06YhnUKgIOT-Kq-v6rQMqXUGdPDnw,827
12
+ arcade_google_docs/tools/__init__.py,sha256=kQChYFQ6y1LJg7q6fngzCOPtaDH1-CeWUOzqxfR_oGY,904
12
13
  arcade_google_docs/tools/comment.py,sha256=Qm5NHdNHONs3j4gqbZ7Fw9NrTVBb_mZ-th1X-z2IoLM,2836
13
14
  arcade_google_docs/tools/create.py,sha256=AuYy8yMGscrxAdLJQX0WiisGHCTufSlaRu_QGMMKQmM,2764
14
15
  arcade_google_docs/tools/file_picker.py,sha256=Dqn-hfMoTsWyHM8QCakVgHr5TKrzL_1Lj-vYHVGtOW4,2342
15
16
  arcade_google_docs/tools/get.py,sha256=Aby3iI1EzjfZTovGH4OdwpIhuazfV4SQinpXDOl87cg,2076
16
17
  arcade_google_docs/tools/search.py,sha256=1k1cI-fKOo4SZU4ufCwZ4DysK3l9MhPScZggPfNCC5Y,8261
18
+ arcade_google_docs/tools/system_context.py,sha256=19HPSpNkLsb-MDWc-9CFgK_ha-rRzwaJr7hV6Us_1LI,1130
17
19
  arcade_google_docs/tools/update.py,sha256=_dReYit0s7ykn2bYQEUwohl3D_63U5leF87egO4eEiQ,1836
18
20
  arcade_google_docs/tools/edit_agent/edit_agent.py,sha256=1LIgKrQ70pDWzWNoaoy1st659perqa-ZW_ALmbVRbW0,2439
19
21
  arcade_google_docs/tools/edit_agent/executor.py,sha256=YbJqNXF0fw4N-u59gTbLpOBwKfoL7N6KZIOzV0pTllc,3718
@@ -23,6 +25,6 @@ arcade_google_docs/tools/edit_agent/prompts.py,sha256=M_f-HsPJppd3FQPhRAw7pKpaAr
23
25
  arcade_google_docs/tools/edit_agent/request_generator.py,sha256=eVDmzJDsOmJ-S8yANmJATt_G51rgCcCga6ArX4DTShM,5399
24
26
  arcade_google_docs/tools/edit_agent/utils.py,sha256=6lYmdQfX4CHfemP5PfxcXKSYpbdqFyEad997-gzCD48,639
25
27
  arcade_google_docs/tools/edit_agent/models/planning.py,sha256=RWQFB_KHl3Pq-snv1rHzoRxVvTnHVLZEGRpdohSX7wc,2962
26
- arcade_google_docs-4.1.0.dist-info/METADATA,sha256=ufO055P83TTGSEMN81EVwVhp6KusftVC20JpJwu0BRE,1127
27
- arcade_google_docs-4.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
- arcade_google_docs-4.1.0.dist-info/RECORD,,
28
+ arcade_google_docs-4.2.0.dist-info/METADATA,sha256=nLo_FmuOXT86wVAbVVFk-fnxFqI04jI_pJI0B2spx3g,1127
29
+ arcade_google_docs-4.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
30
+ arcade_google_docs-4.2.0.dist-info/RECORD,,