mailagent-agent 0.1.0__tar.gz
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.
- mailagent_agent-0.1.0/PKG-INFO +42 -0
- mailagent_agent-0.1.0/README.md +27 -0
- mailagent_agent-0.1.0/mailagent/__init__.py +5 -0
- mailagent_agent-0.1.0/mailagent/client.py +120 -0
- mailagent_agent-0.1.0/mailagent_agent.egg-info/PKG-INFO +42 -0
- mailagent_agent-0.1.0/mailagent_agent.egg-info/SOURCES.txt +8 -0
- mailagent_agent-0.1.0/mailagent_agent.egg-info/dependency_links.txt +1 -0
- mailagent_agent-0.1.0/mailagent_agent.egg-info/top_level.txt +1 -0
- mailagent_agent-0.1.0/pyproject.toml +26 -0
- mailagent_agent-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mailagent-agent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for MailAgent agent verify API
|
|
5
|
+
Author: MailAgent
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://webmailagent.com/docs/agents.html
|
|
8
|
+
Project-URL: Repository, https://github.com/Alex0nder/MailAgent
|
|
9
|
+
Keywords: mailagent,agents,email,verification,otp
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# mailagent-agent (Python)
|
|
17
|
+
|
|
18
|
+
Minimal Python SDK for [MailAgent](https://webmailagent.com) agent verify flows — parity with `@mailagent/agent` core methods.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install mailagent-agent
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from mailagent import MailAgent
|
|
26
|
+
|
|
27
|
+
client = MailAgent("https://api.webmailagent.com", "ma_…")
|
|
28
|
+
result = client.verify_signup(service="github", timeout_seconds=90, delete_after=True)
|
|
29
|
+
print(result.get("agent", {}).get("primaryAction"))
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Methods
|
|
33
|
+
|
|
34
|
+
- `verify_signup(**options)` — `POST /v1/agent/verify`
|
|
35
|
+
- `get_profile()` — `GET /v1/me`
|
|
36
|
+
- `create_inbox(**options)` / `delete_inbox(id)`
|
|
37
|
+
- `list_messages(inbox_id, subject_contains=…)`
|
|
38
|
+
- `simulate_message(inbox_id, scenario="otp", …)`
|
|
39
|
+
- `diagnose_inbox(inbox_id, …)`
|
|
40
|
+
- `list_runs(run_id=…, label=…)`
|
|
41
|
+
|
|
42
|
+
Source: `packages/mailagent-agent-py` in [MailAgent](https://github.com/Alex0nder/MailAgent).
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# mailagent-agent (Python)
|
|
2
|
+
|
|
3
|
+
Minimal Python SDK for [MailAgent](https://webmailagent.com) agent verify flows — parity with `@mailagent/agent` core methods.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install mailagent-agent
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from mailagent import MailAgent
|
|
11
|
+
|
|
12
|
+
client = MailAgent("https://api.webmailagent.com", "ma_…")
|
|
13
|
+
result = client.verify_signup(service="github", timeout_seconds=90, delete_after=True)
|
|
14
|
+
print(result.get("agent", {}).get("primaryAction"))
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Methods
|
|
18
|
+
|
|
19
|
+
- `verify_signup(**options)` — `POST /v1/agent/verify`
|
|
20
|
+
- `get_profile()` — `GET /v1/me`
|
|
21
|
+
- `create_inbox(**options)` / `delete_inbox(id)`
|
|
22
|
+
- `list_messages(inbox_id, subject_contains=…)`
|
|
23
|
+
- `simulate_message(inbox_id, scenario="otp", …)`
|
|
24
|
+
- `diagnose_inbox(inbox_id, …)`
|
|
25
|
+
- `list_runs(run_id=…, label=…)`
|
|
26
|
+
|
|
27
|
+
Source: `packages/mailagent-agent-py` in [MailAgent](https://github.com/Alex0nder/MailAgent).
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""HTTP client for MailAgent REST API (parity with @mailagent/agent core flows)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import urllib.error
|
|
7
|
+
import urllib.parse
|
|
8
|
+
import urllib.request
|
|
9
|
+
from typing import Any, Mapping, MutableMapping, Optional
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class MailAgentError(RuntimeError):
|
|
13
|
+
def __init__(self, status: int, body: Any):
|
|
14
|
+
super().__init__(f"MailAgent {status}: {json.dumps(body)}")
|
|
15
|
+
self.status = status
|
|
16
|
+
self.body = body
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class MailAgent:
|
|
20
|
+
def __init__(self, base_url: str, api_key: str):
|
|
21
|
+
self.base = base_url.rstrip("/")
|
|
22
|
+
self.api_key = api_key
|
|
23
|
+
|
|
24
|
+
def _request(
|
|
25
|
+
self,
|
|
26
|
+
method: str,
|
|
27
|
+
path: str,
|
|
28
|
+
body: Optional[Mapping[str, Any]] = None,
|
|
29
|
+
*,
|
|
30
|
+
accept: str = "application/json",
|
|
31
|
+
) -> Any:
|
|
32
|
+
data = None
|
|
33
|
+
headers = {
|
|
34
|
+
"Authorization": f"Bearer {self.api_key}",
|
|
35
|
+
"Accept": accept,
|
|
36
|
+
}
|
|
37
|
+
if body is not None:
|
|
38
|
+
data = json.dumps(body).encode("utf-8")
|
|
39
|
+
headers["Content-Type"] = "application/json"
|
|
40
|
+
|
|
41
|
+
req = urllib.request.Request(
|
|
42
|
+
f"{self.base}{path}",
|
|
43
|
+
data=data,
|
|
44
|
+
headers=headers,
|
|
45
|
+
method=method,
|
|
46
|
+
)
|
|
47
|
+
try:
|
|
48
|
+
with urllib.request.urlopen(req, timeout=120) as res:
|
|
49
|
+
text = res.read().decode("utf-8")
|
|
50
|
+
return json.loads(text) if text else {}
|
|
51
|
+
except urllib.error.HTTPError as e:
|
|
52
|
+
raw = e.read().decode("utf-8")
|
|
53
|
+
try:
|
|
54
|
+
parsed = json.loads(raw) if raw else {}
|
|
55
|
+
except json.JSONDecodeError:
|
|
56
|
+
parsed = {"raw": raw}
|
|
57
|
+
raise MailAgentError(e.code, parsed) from e
|
|
58
|
+
|
|
59
|
+
def verify_signup(self, **options: Any) -> MutableMapping[str, Any]:
|
|
60
|
+
"""POST /v1/agent/verify"""
|
|
61
|
+
return self._request("POST", "/v1/agent/verify", options)
|
|
62
|
+
|
|
63
|
+
def get_profile(self) -> MutableMapping[str, Any]:
|
|
64
|
+
"""GET /v1/me"""
|
|
65
|
+
return self._request("GET", "/v1/me")
|
|
66
|
+
|
|
67
|
+
def get_agent_hub(self) -> MutableMapping[str, Any]:
|
|
68
|
+
"""GET /v1/agent"""
|
|
69
|
+
return self._request("GET", "/v1/agent")
|
|
70
|
+
|
|
71
|
+
def create_inbox(self, **options: Any) -> MutableMapping[str, Any]:
|
|
72
|
+
"""POST /v1/inboxes"""
|
|
73
|
+
return self._request("POST", "/v1/inboxes", options)
|
|
74
|
+
|
|
75
|
+
def delete_inbox(self, inbox_id: str) -> MutableMapping[str, Any]:
|
|
76
|
+
"""DELETE /v1/inboxes/:id"""
|
|
77
|
+
return self._request("DELETE", f"/v1/inboxes/{inbox_id}")
|
|
78
|
+
|
|
79
|
+
def list_messages(
|
|
80
|
+
self, inbox_id: str, *, subject_contains: Optional[str] = None
|
|
81
|
+
) -> MutableMapping[str, Any]:
|
|
82
|
+
q = ""
|
|
83
|
+
if subject_contains:
|
|
84
|
+
q = f"?subjectContains={urllib.parse.quote(subject_contains)}"
|
|
85
|
+
return self._request("GET", f"/v1/inboxes/{inbox_id}/messages{q}")
|
|
86
|
+
|
|
87
|
+
def simulate_message(
|
|
88
|
+
self, inbox_id: str, **options: Any
|
|
89
|
+
) -> MutableMapping[str, Any]:
|
|
90
|
+
"""POST /v1/inboxes/:id/simulate"""
|
|
91
|
+
return self._request(
|
|
92
|
+
"POST", f"/v1/inboxes/{inbox_id}/simulate", options
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
def diagnose_inbox(
|
|
96
|
+
self,
|
|
97
|
+
inbox_id: str,
|
|
98
|
+
*,
|
|
99
|
+
subject_contains: Optional[str] = None,
|
|
100
|
+
message_index: Optional[int] = None,
|
|
101
|
+
) -> MutableMapping[str, Any]:
|
|
102
|
+
params: list[str] = []
|
|
103
|
+
if subject_contains:
|
|
104
|
+
params.append(
|
|
105
|
+
"subjectContains=" + urllib.parse.quote(subject_contains)
|
|
106
|
+
)
|
|
107
|
+
if message_index is not None:
|
|
108
|
+
params.append(f"messageIndex={message_index}")
|
|
109
|
+
q = f"?{'&'.join(params)}" if params else ""
|
|
110
|
+
return self._request("GET", f"/v1/inboxes/{inbox_id}/diagnose{q}")
|
|
111
|
+
|
|
112
|
+
def list_runs(
|
|
113
|
+
self, *, run_id: Optional[str] = None, label: Optional[str] = None, limit: int = 30
|
|
114
|
+
) -> MutableMapping[str, Any]:
|
|
115
|
+
params: list[str] = [f"limit={limit}"]
|
|
116
|
+
if run_id:
|
|
117
|
+
params.append(f"runId={urllib.parse.quote(run_id)}")
|
|
118
|
+
if label:
|
|
119
|
+
params.append(f"label={urllib.parse.quote(label)}")
|
|
120
|
+
return self._request("GET", f"/v1/agent/runs?{'&'.join(params)}")
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mailagent-agent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for MailAgent agent verify API
|
|
5
|
+
Author: MailAgent
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://webmailagent.com/docs/agents.html
|
|
8
|
+
Project-URL: Repository, https://github.com/Alex0nder/MailAgent
|
|
9
|
+
Keywords: mailagent,agents,email,verification,otp
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# mailagent-agent (Python)
|
|
17
|
+
|
|
18
|
+
Minimal Python SDK for [MailAgent](https://webmailagent.com) agent verify flows — parity with `@mailagent/agent` core methods.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install mailagent-agent
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from mailagent import MailAgent
|
|
26
|
+
|
|
27
|
+
client = MailAgent("https://api.webmailagent.com", "ma_…")
|
|
28
|
+
result = client.verify_signup(service="github", timeout_seconds=90, delete_after=True)
|
|
29
|
+
print(result.get("agent", {}).get("primaryAction"))
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Methods
|
|
33
|
+
|
|
34
|
+
- `verify_signup(**options)` — `POST /v1/agent/verify`
|
|
35
|
+
- `get_profile()` — `GET /v1/me`
|
|
36
|
+
- `create_inbox(**options)` / `delete_inbox(id)`
|
|
37
|
+
- `list_messages(inbox_id, subject_contains=…)`
|
|
38
|
+
- `simulate_message(inbox_id, scenario="otp", …)`
|
|
39
|
+
- `diagnose_inbox(inbox_id, …)`
|
|
40
|
+
- `list_runs(run_id=…, label=…)`
|
|
41
|
+
|
|
42
|
+
Source: `packages/mailagent-agent-py` in [MailAgent](https://github.com/Alex0nder/MailAgent).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mailagent
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mailagent-agent"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python SDK for MailAgent agent verify API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
keywords = ["mailagent", "agents", "email", "verification", "otp"]
|
|
13
|
+
authors = [{ name = "MailAgent" }]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://webmailagent.com/docs/agents.html"
|
|
22
|
+
Repository = "https://github.com/Alex0nder/MailAgent"
|
|
23
|
+
|
|
24
|
+
[tool.setuptools.packages.find]
|
|
25
|
+
where = ["."]
|
|
26
|
+
include = ["mailagent*"]
|