diff --git a/agent_suite_sdk/__init__.py b/agent_suite_sdk/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/agent_suite_sdk/client.py b/agent_suite_sdk/client.py new file mode 100644 index 0000000..7558016 --- /dev/null +++ b/agent_suite_sdk/client.py @@ -0,0 +1,47 @@ +import httpx +from typing import List, Optional +from .schemas import InboxResponse, InboxPublic, MessageCreate, MessageList + +class AgentSuiteClient: + def __init__(self, api_key: Optional[str] = None, base_url: str = "http://localhost:8000"): + self.base_url = base_url + self.headers = {"Authorization": f"Bearer {api_key}"} if api_key else {} + self.client = httpx.AsyncClient(base_url=self.base_url, headers=self.headers) + + async def create_inbox(self) -> InboxResponse: + """Creates a new inbox and returns the API Key.""" + response = await self.client.post("/v1/inboxes") + response.raise_for_status() + data = response.json() + # Update headers if we just created the account + self.client.headers.update({"Authorization": f"Bearer {data['api_key']}"}) + return InboxResponse(**data) + + async def get_my_inbox(self) -> InboxPublic: + """Gets current inbox details.""" + response = await self.client.get("/v1/inboxes/me") + response.raise_for_status() + return InboxPublic(**response.json()) + + async def send_email(self, to: str, subject: str, body: str, html_body: Optional[str] = None): + """Sends an email.""" + payload = { + "to": to, + "subject": subject, + "body": body, + "html_body": html_body + } + response = await self.client.post("/v1/inboxes/me/send", json=payload) + response.raise_for_status() + return response.json() + + async def list_messages(self, skip: int = 0, limit: int = 50, unread_only: bool = False) -> MessageList: + """Lists received messages.""" + params = {"skip": skip, "limit": limit, "unread_only": unread_only} + response = await self.client.get("/v1/inboxes/me/messages", params=params) + response.raise_for_status() + return MessageList(**response.json()) + + async def close(self): + """Closes the client connection.""" + await self.client.aclose() diff --git a/agent_suite_sdk/schemas.py b/agent_suite_sdk/schemas.py new file mode 100644 index 0000000..d2b6e18 --- /dev/null +++ b/agent_suite_sdk/schemas.py @@ -0,0 +1,34 @@ +from pydantic import BaseModel, EmailStr +from uuid import UUID +from datetime import datetime +from typing import List, Optional + +class InboxResponse(BaseModel): + id: UUID + email_address: str + api_key: str + created_at: datetime + +class InboxPublic(BaseModel): + id: UUID + email_address: str + created_at: datetime + +class MessageCreate(BaseModel): + to: EmailStr + subject: str + body: str + html_body: Optional[str] = None + +class MessageResponse(BaseModel): + id: UUID + sender: str + recipient: str + subject: Optional[str] + body_text: Optional[str] + received_at: datetime + is_read: bool + +class MessageList(BaseModel): + total: int + messages: List[MessageResponse] diff --git a/openapi.yaml b/openapi.yaml new file mode 100644 index 0000000..7b9eeb8 --- /dev/null +++ b/openapi.yaml @@ -0,0 +1,34 @@ +openapi: 3.0.0 +info: + title: Agent Suite API + version: 0.1.0 + description: Infrastructure API for AI agents (Email without OAuth) +servers: + - url: http://localhost:8000 +paths: + /v1/inboxes: + post: + summary: Create new inbox + responses: + '201': + description: Created + /v1/inboxes/me/send: + post: + summary: Send Email + security: + - bearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + to: {type: string} + subject: {type: string} + body: {type: string} +components: + securitySchemes: + bearerAuth: + type: http + scheme: bearer