Skip to content

Commit d9bad64

Browse files
Merge branch 'master' into issue-3352
2 parents f45163f + 77b48c7 commit d9bad64

File tree

5 files changed

+237
-159
lines changed

5 files changed

+237
-159
lines changed

.github/workflows/scorecard.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This workflow uses actions that are not certified by GitHub. They are provided
2+
# by a third-party and are governed by separate terms of service, privacy
3+
# policy, and support documentation.
4+
5+
name: Scorecard supply-chain security
6+
on:
7+
# For Branch-Protection check. Only the default branch is supported. See
8+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
9+
branch_protection_rule:
10+
# To guarantee Maintained check is occasionally updated. See
11+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
12+
schedule:
13+
- cron: '15 7 * * 4'
14+
push:
15+
branches: [ "master" ]
16+
17+
# Declare default permissions as read only.
18+
permissions: read-all
19+
20+
jobs:
21+
analysis:
22+
name: Scorecard analysis
23+
runs-on: ubuntu-latest
24+
# `publish_results: true` only works when run from the default branch. conditional can be removed if disabled.
25+
if: github.event.repository.default_branch == github.ref_name || github.event_name == 'pull_request'
26+
permissions:
27+
# Needed to upload the results to code-scanning dashboard.
28+
security-events: write
29+
# Needed to publish results and get a badge (see publish_results below).
30+
id-token: write
31+
# Uncomment the permissions below if installing in a private repository.
32+
# contents: read
33+
# actions: read
34+
35+
steps:
36+
- name: "Checkout code"
37+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
38+
with:
39+
persist-credentials: false
40+
41+
- name: "Run analysis"
42+
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
43+
with:
44+
results_file: results.sarif
45+
results_format: sarif
46+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
47+
# - you want to enable the Branch-Protection check on a *public* repository, or
48+
# - you are installing Scorecard on a *private* repository
49+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
50+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
51+
52+
# Public repositories:
53+
# - Publish results to OpenSSF REST API for easy access by consumers
54+
# - Allows the repository to include the Scorecard badge.
55+
# - See https://github.com/ossf/scorecard-action#publishing-results.
56+
# For private repositories:
57+
# - `publish_results` will always be set to `false`, regardless
58+
# of the value entered here.
59+
publish_results: true
60+
61+
# (Optional) Uncomment file_mode if you have a .gitattributes with files marked export-ignore
62+
# file_mode: git
63+
64+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
65+
# format to the repository Actions tab.
66+
- name: "Upload artifact"
67+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
68+
with:
69+
name: SARIF file
70+
path: results.sarif
71+
retention-days: 5
72+
73+
# Upload the results to GitHub's code scanning dashboard (optional).
74+
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
75+
- name: "Upload to code-scanning"
76+
uses: github/codeql-action/upload-sarif@v3
77+
with:
78+
sarif_file: results.sarif

camel/toolkits/gmail_toolkit.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def people_service(self, service: Any) -> None:
7373
r"""Allow overriding/injecting the People service (e.g., in tests)."""
7474
self._people_service = service
7575

76-
def send_email(
76+
def gmail_send_email(
7777
self,
7878
to: Union[str, List[str]],
7979
subject: str,
@@ -138,7 +138,7 @@ def send_email(
138138
logger.error("Failed to send email: %s", e)
139139
return {"error": f"Failed to send email: {e!s}"}
140140

141-
def reply_to_email(
141+
def gmail_reply_to_email(
142142
self,
143143
message_id: str,
144144
reply_body: str,
@@ -225,7 +225,7 @@ def reply_to_email(
225225

226226
# Get current user's email and remove it from recipients
227227
try:
228-
profile_result = self.get_profile()
228+
profile_result = self.gmail_get_profile()
229229
if profile_result.get('success'):
230230
current_user_email = profile_result['profile'][
231231
'email_address'
@@ -280,7 +280,7 @@ def reply_to_email(
280280
logger.error("Failed to reply to email: %s", e)
281281
return {"error": f"Failed to reply to email: {e!s}"}
282282

283-
def forward_email(
283+
def gmail_forward_email(
284284
self,
285285
message_id: str,
286286
to: Union[str, List[str]],
@@ -385,7 +385,7 @@ def forward_email(
385385
temp_files.append(temp_file.name)
386386

387387
# Download attachment
388-
result = self.get_attachment(
388+
result = self.gmail_get_attachment(
389389
message_id=message_id,
390390
attachment_id=att['attachment_id'],
391391
save_path=temp_file.name,
@@ -440,7 +440,7 @@ def forward_email(
440440
logger.error("Failed to forward email: %s", e)
441441
return {"error": f"Failed to forward email: {e!s}"}
442442

443-
def create_email_draft(
443+
def gmail_create_draft(
444444
self,
445445
to: Union[str, List[str]],
446446
subject: str,
@@ -505,7 +505,7 @@ def create_email_draft(
505505
logger.error("Failed to create draft: %s", e)
506506
return {"error": f"Failed to create draft: {e!s}"}
507507

508-
def send_draft(self, draft_id: str) -> Dict[str, Any]:
508+
def gmail_send_draft(self, draft_id: str) -> Dict[str, Any]:
509509
r"""Send a draft email.
510510
511511
Args:
@@ -537,7 +537,7 @@ def send_draft(self, draft_id: str) -> Dict[str, Any]:
537537
logger.error("Failed to send draft: %s", e)
538538
return {"error": f"Failed to send draft: {e!s}"}
539539

540-
def fetch_emails(
540+
def gmail_fetch_emails(
541541
self,
542542
query: str = "",
543543
max_results: int = 10,
@@ -616,7 +616,7 @@ def fetch_emails(
616616
logger.error("Failed to fetch emails: %s", e)
617617
return {"error": f"Failed to fetch emails: {e!s}"}
618618

619-
def fetch_thread_by_id(self, thread_id: str) -> Dict[str, Any]:
619+
def gmail_fetch_thread_by_id(self, thread_id: str) -> Dict[str, Any]:
620620
r"""Fetch a thread by ID.
621621
622622
Args:
@@ -653,7 +653,7 @@ def fetch_thread_by_id(self, thread_id: str) -> Dict[str, Any]:
653653
logger.error("Failed to fetch thread: %s", e)
654654
return {"error": f"Failed to fetch thread: {e!s}"}
655655

656-
def modify_email_labels(
656+
def gmail_modify_email_labels(
657657
self,
658658
message_id: str,
659659
add_labels: Optional[List[str]] = None,
@@ -710,7 +710,7 @@ def modify_email_labels(
710710
logger.error("Failed to modify labels: %s", e)
711711
return {"error": f"Failed to modify labels: {e!s}"}
712712

713-
def move_to_trash(self, message_id: str) -> Dict[str, Any]:
713+
def gmail_move_to_trash(self, message_id: str) -> Dict[str, Any]:
714714
r"""Move a message to trash.
715715
716716
Args:
@@ -742,7 +742,7 @@ def move_to_trash(self, message_id: str) -> Dict[str, Any]:
742742
logger.error("Failed to move message to trash: %s", e)
743743
return {"error": f"Failed to move message to trash: {e!s}"}
744744

745-
def get_attachment(
745+
def gmail_get_attachment(
746746
self,
747747
message_id: str,
748748
attachment_id: str,
@@ -802,7 +802,7 @@ def get_attachment(
802802
logger.error("Failed to get attachment: %s", e)
803803
return {"error": f"Failed to get attachment: {e!s}"}
804804

805-
def list_threads(
805+
def gmail_list_threads(
806806
self,
807807
query: str = "",
808808
max_results: int = 10,
@@ -884,7 +884,7 @@ def list_threads(
884884
logger.error("Failed to list threads: %s", e)
885885
return {"error": f"Failed to list threads: {e!s}"}
886886

887-
def list_drafts(
887+
def gmail_list_drafts(
888888
self, max_results: int = 10, page_token: Optional[str] = None
889889
) -> Dict[str, Any]:
890890
r"""List email drafts.
@@ -932,7 +932,7 @@ def list_drafts(
932932
logger.error("Failed to list drafts: %s", e)
933933
return {"error": f"Failed to list drafts: {e!s}"}
934934

935-
def list_gmail_labels(self) -> Dict[str, Any]:
935+
def gmail_list_labels(self) -> Dict[str, Any]:
936936
r"""List all Gmail labels.
937937
938938
Returns:
@@ -968,7 +968,7 @@ def list_gmail_labels(self) -> Dict[str, Any]:
968968
logger.error("Failed to list labels: %s", e)
969969
return {"error": f"Failed to list labels: {e!s}"}
970970

971-
def create_label(
971+
def gmail_create_label(
972972
self,
973973
name: str,
974974
label_list_visibility: Literal["labelShow", "labelHide"] = "labelShow",
@@ -1015,7 +1015,7 @@ def create_label(
10151015
logger.error("Failed to create label: %s", e)
10161016
return {"error": f"Failed to create label: {e!s}"}
10171017

1018-
def delete_label(self, label_id: str) -> Dict[str, Any]:
1018+
def gmail_delete_label(self, label_id: str) -> Dict[str, Any]:
10191019
r"""Delete a Gmail label.
10201020
10211021
Args:
@@ -1044,7 +1044,7 @@ def delete_label(self, label_id: str) -> Dict[str, Any]:
10441044
logger.error("Failed to delete label: %s", e)
10451045
return {"error": f"Failed to delete label: {e!s}"}
10461046

1047-
def modify_thread_labels(
1047+
def gmail_modify_thread_labels(
10481048
self,
10491049
thread_id: str,
10501050
add_labels: Optional[List[str]] = None,
@@ -1102,7 +1102,7 @@ def modify_thread_labels(
11021102
logger.error("Failed to modify thread labels: %s", e)
11031103
return {"error": f"Failed to modify thread labels: {e!s}"}
11041104

1105-
def get_profile(self) -> Dict[str, Any]:
1105+
def gmail_get_profile(self) -> Dict[str, Any]:
11061106
r"""Get Gmail profile information.
11071107
11081108
Returns:
@@ -1127,7 +1127,7 @@ def get_profile(self) -> Dict[str, Any]:
11271127
logger.error("Failed to get profile: %s", e)
11281128
return {"error": f"Failed to get profile: {e!s}"}
11291129

1130-
def get_contacts(
1130+
def gmail_get_contacts(
11311131
self,
11321132
max_results: int = 100,
11331133
page_token: Optional[str] = None,
@@ -1187,7 +1187,7 @@ def get_contacts(
11871187
logger.error("Failed to get contacts: %s", e)
11881188
return {"error": f"Failed to get contacts: {e!s}"}
11891189

1190-
def search_people(
1190+
def gmail_search_people(
11911191
self,
11921192
query: str,
11931193
max_results: int = 10,
@@ -1817,23 +1817,23 @@ def get_tools(self) -> List[FunctionTool]:
18171817
representing the functions in the toolkit.
18181818
"""
18191819
return [
1820-
FunctionTool(self.send_email),
1821-
FunctionTool(self.reply_to_email),
1822-
FunctionTool(self.forward_email),
1823-
FunctionTool(self.create_email_draft),
1824-
FunctionTool(self.send_draft),
1825-
FunctionTool(self.fetch_emails),
1826-
FunctionTool(self.fetch_thread_by_id),
1827-
FunctionTool(self.modify_email_labels),
1828-
FunctionTool(self.move_to_trash),
1829-
FunctionTool(self.get_attachment),
1830-
FunctionTool(self.list_threads),
1831-
FunctionTool(self.list_drafts),
1832-
FunctionTool(self.list_gmail_labels),
1833-
FunctionTool(self.create_label),
1834-
FunctionTool(self.delete_label),
1835-
FunctionTool(self.modify_thread_labels),
1836-
FunctionTool(self.get_profile),
1837-
FunctionTool(self.get_contacts),
1838-
FunctionTool(self.search_people),
1820+
FunctionTool(self.gmail_send_email),
1821+
FunctionTool(self.gmail_reply_to_email),
1822+
FunctionTool(self.gmail_forward_email),
1823+
FunctionTool(self.gmail_create_draft),
1824+
FunctionTool(self.gmail_send_draft),
1825+
FunctionTool(self.gmail_fetch_emails),
1826+
FunctionTool(self.gmail_fetch_thread_by_id),
1827+
FunctionTool(self.gmail_modify_email_labels),
1828+
FunctionTool(self.gmail_move_to_trash),
1829+
FunctionTool(self.gmail_get_attachment),
1830+
FunctionTool(self.gmail_list_threads),
1831+
FunctionTool(self.gmail_list_drafts),
1832+
FunctionTool(self.gmail_list_labels),
1833+
FunctionTool(self.gmail_create_label),
1834+
FunctionTool(self.gmail_delete_label),
1835+
FunctionTool(self.gmail_modify_thread_labels),
1836+
FunctionTool(self.gmail_get_profile),
1837+
FunctionTool(self.gmail_get_contacts),
1838+
FunctionTool(self.gmail_search_people),
18391839
]

0 commit comments

Comments
 (0)