agentmail-toolkit 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.
File without changes
@@ -0,0 +1,32 @@
1
+ from typing import Optional
2
+ from agentmail import AgentMail
3
+ from agents import FunctionTool, RunContextWrapper
4
+
5
+ from .toolkit import Toolkit
6
+ from .tools import Tool
7
+
8
+
9
+ class AgentMailToolkit(Toolkit[FunctionTool]):
10
+ def __init__(self, client: Optional[AgentMail] = None):
11
+ super().__init__(client)
12
+
13
+ def _build_tool(self, tool: Tool):
14
+ async def on_invoke_tool(ctx: RunContextWrapper, input_str: str):
15
+ try:
16
+ result = self.call_method(
17
+ tool.method_name,
18
+ tool.params_schema.model_validate_json(input_str),
19
+ )
20
+ return result.model_dump_json()
21
+ except Exception as e:
22
+ return str(e)
23
+
24
+ params_json_schema = tool.params_schema.model_json_schema()
25
+ params_json_schema["additionalProperties"] = False
26
+
27
+ return FunctionTool(
28
+ name=tool.name,
29
+ description=tool.description,
30
+ params_json_schema=params_json_schema,
31
+ on_invoke_tool=on_invoke_tool,
32
+ )
File without changes
@@ -0,0 +1,63 @@
1
+ from typing import Optional, List
2
+ from pydantic import BaseModel, Field
3
+
4
+
5
+ class ListItemsParams(BaseModel):
6
+ limit: Optional[int] = Field(description="The maximum number of items to return")
7
+ last_key: Optional[str] = Field(description="The last key to use for pagination")
8
+
9
+
10
+ class GetInboxParams(BaseModel):
11
+ inbox_id: str = Field(description="The ID of the inbox to get")
12
+
13
+
14
+ class CreateInboxParams(BaseModel):
15
+ username: str = Field(description="The username of the inbox to create")
16
+ display_name: str = Field(description="The display name of the inbox to create")
17
+
18
+
19
+ class ListThreadsParams(ListItemsParams):
20
+ inbox_id: str = Field(description="The ID of the inbox to list threads for")
21
+ received: bool = Field(description="Whether to filter by received threads")
22
+ sent: bool = Field(description="Whether to filter by sent threads")
23
+
24
+
25
+ class GetThreadParams(BaseModel):
26
+ inbox_id: str = Field(description="The ID of the inbox to get the thread for")
27
+ thread_id: str = Field(description="The ID of the thread to get")
28
+
29
+
30
+ class ListMessagesParams(ListItemsParams):
31
+ inbox_id: str = Field(description="The ID of the inbox to list messages for")
32
+
33
+
34
+ class GetMessageParams(BaseModel):
35
+ inbox_id: str = Field(description="The ID of the inbox to get the message for")
36
+ message_id: str = Field(description="The ID of the message to get")
37
+
38
+
39
+ class GetAttachmentParams(BaseModel):
40
+ inbox_id: str = Field(description="The ID of the inbox to get the attachment for")
41
+ message_id: str = Field(
42
+ description="The ID of the message to get the attachment for"
43
+ )
44
+ attachment_id: str = Field(description="The ID of the attachment to get")
45
+
46
+
47
+ class SendMessageParams(BaseModel):
48
+ inbox_id: str = Field(description="The ID of the inbox to send the message from")
49
+ to: List[str] = Field(description="The list of recipients")
50
+ cc: Optional[List[str]] = Field(description="The list of CC recipients")
51
+ bcc: Optional[List[str]] = Field(description="The list of BCC recipients")
52
+ subject: Optional[str] = Field(description="The subject of the message")
53
+ text: Optional[str] = Field(description="The plain text body of the message")
54
+ html: Optional[str] = Field(description="The HTML body of the message")
55
+
56
+
57
+ class ReplyToMessageParams(BaseModel):
58
+ inbox_id: str = Field(
59
+ description="The ID of the inbox to reply to the message from"
60
+ )
61
+ message_id: str = Field(description="The ID of the message to reply to")
62
+ text: Optional[str] = Field(description="The plain text body of the reply")
63
+ html: Optional[str] = Field(description="The HTML body of the reply")
@@ -0,0 +1,36 @@
1
+ from typing import TypeVar, Generic, List, Optional
2
+ from abc import ABC, abstractmethod
3
+ from pydantic import BaseModel
4
+ from agentmail import AgentMail
5
+
6
+ from .tools import Tool, tools
7
+
8
+
9
+ T = TypeVar("T")
10
+
11
+
12
+ class Toolkit(Generic[T], ABC):
13
+ _client: AgentMail = None
14
+ _tools: List[T] = None
15
+
16
+ def __init__(self, client: Optional[AgentMail] = None):
17
+ if client:
18
+ self._client = client
19
+ else:
20
+ self._client = AgentMail()
21
+
22
+ self._tools = [self._build_tool(tool) for tool in tools]
23
+
24
+ @abstractmethod
25
+ def _build_tool(self, tool: Tool) -> T:
26
+ pass
27
+
28
+ def call_method(self, method_name: str, args: BaseModel) -> BaseModel:
29
+ method = self._client
30
+ for part in method_name.split("."):
31
+ method = getattr(method, part)
32
+
33
+ return method(**args.model_dump())
34
+
35
+ def get_tools(self) -> List[T]:
36
+ return self._tools
@@ -0,0 +1,86 @@
1
+ from typing import List, Type
2
+ from pydantic import BaseModel
3
+
4
+ from .schemas import (
5
+ ListItemsParams,
6
+ GetInboxParams,
7
+ CreateInboxParams,
8
+ ListThreadsParams,
9
+ GetThreadParams,
10
+ ListMessagesParams,
11
+ GetMessageParams,
12
+ GetAttachmentParams,
13
+ SendMessageParams,
14
+ ReplyToMessageParams,
15
+ )
16
+
17
+
18
+ class Tool(BaseModel):
19
+ name: str
20
+ method_name: str
21
+ description: str
22
+ params_schema: Type[BaseModel]
23
+
24
+
25
+ tools: List[Tool] = [
26
+ Tool(
27
+ name="list_inboxes",
28
+ method_name="inboxes.list",
29
+ description="List all inboxes",
30
+ params_schema=ListItemsParams,
31
+ ),
32
+ Tool(
33
+ name="get_inbox",
34
+ method_name="inboxes.get",
35
+ description="Get inbox by ID",
36
+ params_schema=GetInboxParams,
37
+ ),
38
+ Tool(
39
+ name="create_inbox",
40
+ method_name="inboxes.create",
41
+ description="Create a new inbox",
42
+ params_schema=CreateInboxParams,
43
+ ),
44
+ Tool(
45
+ name="list_threads",
46
+ method_name="threads.list",
47
+ description="List threads by inbox ID",
48
+ params_schema=ListThreadsParams,
49
+ ),
50
+ Tool(
51
+ name="get_thread",
52
+ method_name="threads.get",
53
+ description="Get thread by ID",
54
+ params_schema=GetThreadParams,
55
+ ),
56
+ Tool(
57
+ name="list_messages",
58
+ method_name="messages.list",
59
+ description="List messages by thread ID",
60
+ params_schema=ListMessagesParams,
61
+ ),
62
+ Tool(
63
+ name="get_message",
64
+ method_name="messages.get",
65
+ description="Get message by ID",
66
+ params_schema=GetMessageParams,
67
+ ),
68
+ Tool(
69
+ name="get_attachment",
70
+ method_name="attachments.get",
71
+ description="Get attachment by ID",
72
+ params_schema=GetAttachmentParams,
73
+ ),
74
+ Tool(
75
+ name="send_message",
76
+ method_name="messages.send",
77
+ description="Send a message",
78
+ params_schema=SendMessageParams,
79
+ ),
80
+ Tool(
81
+ name="reply_to_message",
82
+ method_name="messages.reply",
83
+ description="Reply to a message",
84
+ params_schema=ReplyToMessageParams,
85
+ ),
86
+ ]
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentmail-toolkit
3
+ Version: 0.1.0
4
+ Summary: AgentMail Toolkit
5
+ Requires-Python: >=3.11
6
+ Requires-Dist: agentmail>=0.0.16
7
+ Requires-Dist: openai-agents>=0.0.3
8
+ Requires-Dist: pydantic>=2.10.6
9
+ Description-Content-Type: text/markdown
10
+
11
+ # AgentMail Toolkit
12
+
13
+ The AgentMail Toolkit integrates popular agent frameworks and protocols including OpenAI Agents SDK, Vercel AI SDK, and Model Context Protocol (MCP) with the AgentMail API.
@@ -0,0 +1,9 @@
1
+ agentmail_toolkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ agentmail_toolkit/openai.py,sha256=8SFyY80oT2XoJM_UG9ZuABl6E9aD-I4wXhTtNg4jd5M,1053
3
+ agentmail_toolkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ agentmail_toolkit/schemas.py,sha256=RDlkjnYDhQfSSoaluTAZFCQjBVCFWAglA64cc9jVjQQ,2634
5
+ agentmail_toolkit/toolkit.py,sha256=c9H7p8KnMLXouqPekks7aWZxCWFk_tIzwPpkFeJZLps,905
6
+ agentmail_toolkit/tools.py,sha256=ErqM_e15iuP9BBdZ2ZSSujz0MnNegFC-Y48wCIgDZWo,2117
7
+ agentmail_toolkit-0.1.0.dist-info/METADATA,sha256=k_dQ05zggFW5iS1Z9dc5Z8Gu9D_GmF8-NwHnWpNKsCs,448
8
+ agentmail_toolkit-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ agentmail_toolkit-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any