@agentmbox/plugin-agentmbox 1.0.0

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.
package/README.md ADDED
@@ -0,0 +1,189 @@
1
+ # @agentmbox/plugin-agentmbox
2
+
3
+ AgentMBox email integration plugin for ElizaOS - enables AI agents to send and receive emails via the AgentMBox API.
4
+
5
+ ## Features
6
+
7
+ - **Send Emails**: Agents can send emails to any recipient
8
+ - **Receive Emails**: Agents can retrieve and read emails from their mailbox
9
+ - **Email Provider**: Built-in provider gives agents awareness of their inbox status
10
+ - **Full API Access**: Complete access to AgentMBox mailbox, domain, and payment management
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ bun add @agentmbox/plugin-agentmbox
16
+ ```
17
+
18
+ ## Configuration
19
+
20
+ Add the plugin to your agent's configuration and set the required environment variables:
21
+
22
+ ### Environment Variables
23
+
24
+ | Variable | Required | Description |
25
+ |----------|----------|-------------|
26
+ | `AGENTMBOX_API_KEY` | Yes | Your AgentMBox API key (starts with `ai_`) |
27
+ | `AGENTMBOX_MAILBOX` | No | Default mailbox address (e.g., `my-agent@agentmbox.com`) |
28
+ | `AGENTMBOX_BASE_URL` | No | Custom API base URL (defaults to `https://agentmbox.com/api/v1`) |
29
+
30
+ ### Character Configuration
31
+
32
+ ```json
33
+ {
34
+ "plugins": [
35
+ "@agentmbox/plugin-agentmbox"
36
+ ]
37
+ }
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ### 1. Create an AgentMBox Account
43
+
44
+ Follow the [AgentMBox Quick Start Guide](https://www.agentmbox.com/docs) to:
45
+
46
+ 1. Create an account at https://agentmbox.com
47
+ 2. Create an API key
48
+ 3. Add payment (5 USDC per 30 days on Solana)
49
+ 4. Create a mailbox (e.g., `my-agent@agentmbox.com`)
50
+
51
+ ### 2. Configure Your Agent
52
+
53
+ Add the environment variables to your `.env` file:
54
+
55
+ ```env
56
+ AGENTMBOX_API_KEY=ai_your_api_key_here
57
+ AGENTMBOX_MAILBOX=my-agent@agentmbox.com
58
+ ```
59
+
60
+ ### 3. Use in Your Agent
61
+
62
+ The plugin provides two actions and one provider:
63
+
64
+ #### Send Email Action (`SEND_EMAIL`)
65
+
66
+ ```typescript
67
+ // The agent can send emails by specifying recipient, subject, and body
68
+ await runtime.execute({
69
+ action: "SEND_EMAIL",
70
+ parameters: {
71
+ to: "recipient@example.com",
72
+ subject: "Hello from your agent",
73
+ text: "This is the plain text body",
74
+ html: "<p>Or HTML body</p>"
75
+ }
76
+ });
77
+ ```
78
+
79
+ #### Get Emails Action (`GET_EMAILS`)
80
+
81
+ ```typescript
82
+ // Retrieve emails from the mailbox
83
+ await runtime.execute({
84
+ action: "GET_EMAILS",
85
+ parameters: {
86
+ limit: 10, // Number of emails to retrieve (default: 10)
87
+ offset: 0, // Pagination offset
88
+ unreadOnly: false // Filter to only unread emails
89
+ }
90
+ });
91
+
92
+ // Get a specific email by ID
93
+ await runtime.execute({
94
+ action: "GET_EMAILS",
95
+ parameters: {
96
+ emailId: "M1234"
97
+ }
98
+ });
99
+ ```
100
+
101
+ #### Email Provider
102
+
103
+ The email provider automatically provides context about the agent's inbox:
104
+
105
+ ```typescript
106
+ // Access via state in actions or handlers
107
+ const emailContext = state.email;
108
+ // Contains: available, unreadCount, totalEmails, recentEmails[]
109
+ ```
110
+
111
+ ## AgentMBox Setup Guide
112
+
113
+ ### Creating a Mailbox
114
+
115
+ ```bash
116
+ curl -X POST https://agentmbox.com/api/v1/mailboxes \
117
+ -H "Authorization: Bearer YOUR_API_KEY" \
118
+ -H "Content-Type: application/json" \
119
+ -d '{"localPart": "my-agent"}'
120
+ ```
121
+
122
+ ### Sending an Email
123
+
124
+ ```bash
125
+ curl -X POST https://agentmbox.com/api/v1/mail/send \
126
+ -H "Authorization: Bearer YOUR_API_KEY" \
127
+ -H "Content-Type: application/json" \
128
+ -d '{
129
+ "from": "my-agent@agentmbox.com",
130
+ "to": "recipient@example.com",
131
+ "subject": "Hello",
132
+ "text": "Email body"
133
+ }'
134
+ ```
135
+
136
+ ### Checking Emails
137
+
138
+ ```bash
139
+ curl "https://agentmbox.com/api/v1/mail?mailbox=my-agent@agentmbox.com&limit=10" \
140
+ -H "Authorization: Bearer YOUR_API_KEY"
141
+ ```
142
+
143
+ ## API Reference
144
+
145
+ ### Service Methods
146
+
147
+ ```typescript
148
+ const service = runtime.getService<AgentMBoxService>("agentmbox");
149
+
150
+ // Email operations
151
+ service.listEmails(limit, offset);
152
+ service.getEmail(emailId);
153
+ service.sendEmail({ from, to, subject, text, html });
154
+ service.deleteEmail(emailId);
155
+
156
+ // Mailbox operations
157
+ service.listMailboxes();
158
+ service.createMailbox({ localPart, displayName });
159
+ service.deleteMailbox(mailboxId);
160
+
161
+ // Payment operations
162
+ service.getPaymentStatus();
163
+ service.checkPayment();
164
+
165
+ // Domain operations
166
+ service.listDomains();
167
+ service.addDomain("example.com");
168
+ service.verifyDomain(domainId);
169
+ ```
170
+
171
+ ## Development
172
+
173
+ ```bash
174
+ # Install dependencies
175
+ bun install
176
+
177
+ # Build the plugin
178
+ bun run build
179
+
180
+ # Run tests
181
+ bun test
182
+
183
+ # Watch mode
184
+ bun run dev
185
+ ```
186
+
187
+ ## License
188
+
189
+ MIT