@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 +189 -0
- package/bun.lock +659 -0
- package/dist/index.d.ts +246 -0
- package/dist/index.js +811 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
- package/src/actions/getEmails.ts +153 -0
- package/src/actions/sendEmail.ts +132 -0
- package/src/index.ts +95 -0
- package/src/providers/emailProvider.ts +82 -0
- package/src/services/AgentMBoxOnboardingService.ts +447 -0
- package/src/services/AgentMBoxService.ts +194 -0
- package/src/types/index.ts +167 -0
- package/tsconfig.json +20 -0
- package/tsup.config.ts +11 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { Service, IAgentRuntime, Plugin } from '@elizaos/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AgentMBox Plugin Types
|
|
5
|
+
* TypeScript interfaces for AgentMBox email integration
|
|
6
|
+
*/
|
|
7
|
+
interface AgentMBoxConfig {
|
|
8
|
+
/** API key for AgentMBox (starts with ai_) */
|
|
9
|
+
apiKey: string;
|
|
10
|
+
/** Mailbox address (e.g., my-agent@agentmbox.com) */
|
|
11
|
+
mailbox?: string;
|
|
12
|
+
/** Base URL for AgentMBox API (default: https://agentmbox.com/api/v1) */
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
interface EmailAddress {
|
|
16
|
+
name?: string;
|
|
17
|
+
email: string;
|
|
18
|
+
}
|
|
19
|
+
interface Email {
|
|
20
|
+
id: string;
|
|
21
|
+
from: EmailAddress[];
|
|
22
|
+
to: EmailAddress[];
|
|
23
|
+
cc?: EmailAddress[] | null;
|
|
24
|
+
subject: string;
|
|
25
|
+
receivedAt: string;
|
|
26
|
+
textBody?: string;
|
|
27
|
+
htmlBody?: string;
|
|
28
|
+
preview?: string;
|
|
29
|
+
hasAttachment: boolean;
|
|
30
|
+
isRead: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface EmailListResponse {
|
|
33
|
+
mailbox: string;
|
|
34
|
+
emails: Email[];
|
|
35
|
+
limit: number;
|
|
36
|
+
offset: number;
|
|
37
|
+
}
|
|
38
|
+
interface EmailDetailResponse {
|
|
39
|
+
email: Email;
|
|
40
|
+
}
|
|
41
|
+
interface SendEmailRequest {
|
|
42
|
+
/** Sender address (must be a mailbox you own) */
|
|
43
|
+
from: string;
|
|
44
|
+
/** Recipient(s) - single email or array */
|
|
45
|
+
to: string | string[];
|
|
46
|
+
/** Email subject line */
|
|
47
|
+
subject: string;
|
|
48
|
+
/** Plain text body */
|
|
49
|
+
text?: string;
|
|
50
|
+
/** HTML body */
|
|
51
|
+
html?: string;
|
|
52
|
+
}
|
|
53
|
+
interface SendEmailResponse {
|
|
54
|
+
success: boolean;
|
|
55
|
+
}
|
|
56
|
+
interface Mailbox {
|
|
57
|
+
id: string;
|
|
58
|
+
address: string;
|
|
59
|
+
localPart: string;
|
|
60
|
+
domainName: string;
|
|
61
|
+
displayName?: string | null;
|
|
62
|
+
password?: string;
|
|
63
|
+
createdAt: string;
|
|
64
|
+
}
|
|
65
|
+
interface MailboxListResponse {
|
|
66
|
+
mailboxes: Mailbox[];
|
|
67
|
+
}
|
|
68
|
+
interface CreateMailboxRequest {
|
|
69
|
+
localPart: string;
|
|
70
|
+
domainId?: string;
|
|
71
|
+
displayName?: string;
|
|
72
|
+
}
|
|
73
|
+
interface CreateMailboxResponse {
|
|
74
|
+
mailbox: Mailbox;
|
|
75
|
+
}
|
|
76
|
+
interface PaymentStatus {
|
|
77
|
+
paid: boolean;
|
|
78
|
+
paidUntil: string | null;
|
|
79
|
+
solanaAddress: string;
|
|
80
|
+
usdcPerPeriod: number;
|
|
81
|
+
periodDays: number;
|
|
82
|
+
creditedUsdc: number;
|
|
83
|
+
payments: unknown[];
|
|
84
|
+
}
|
|
85
|
+
interface PaymentCheckResponse {
|
|
86
|
+
paid: boolean;
|
|
87
|
+
paidUntil: string;
|
|
88
|
+
newCredits: number;
|
|
89
|
+
balanceUsdc: number;
|
|
90
|
+
creditedUsdc: number;
|
|
91
|
+
}
|
|
92
|
+
interface Domain {
|
|
93
|
+
id: string;
|
|
94
|
+
domain: string;
|
|
95
|
+
verified: boolean;
|
|
96
|
+
}
|
|
97
|
+
interface DomainDNSRecords {
|
|
98
|
+
verification: {
|
|
99
|
+
type: string;
|
|
100
|
+
name: string;
|
|
101
|
+
value: string;
|
|
102
|
+
};
|
|
103
|
+
mx: {
|
|
104
|
+
type: string;
|
|
105
|
+
name: string;
|
|
106
|
+
value: string;
|
|
107
|
+
priority: number;
|
|
108
|
+
};
|
|
109
|
+
spf: {
|
|
110
|
+
type: string;
|
|
111
|
+
name: string;
|
|
112
|
+
value: string;
|
|
113
|
+
};
|
|
114
|
+
dkim: {
|
|
115
|
+
type: string;
|
|
116
|
+
name: string;
|
|
117
|
+
value: string;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
interface DomainResponse {
|
|
121
|
+
domain: Domain;
|
|
122
|
+
dnsRecords: DomainDNSRecords;
|
|
123
|
+
}
|
|
124
|
+
interface DomainVerifyResponse {
|
|
125
|
+
verified: boolean;
|
|
126
|
+
txtVerified: boolean;
|
|
127
|
+
mxVerified: boolean;
|
|
128
|
+
spfVerified: boolean;
|
|
129
|
+
dkimVerified: boolean;
|
|
130
|
+
}
|
|
131
|
+
interface DomainListResponse {
|
|
132
|
+
domains: (Domain & {
|
|
133
|
+
dnsRecords?: DomainDNSRecords;
|
|
134
|
+
})[];
|
|
135
|
+
}
|
|
136
|
+
interface ApiKey {
|
|
137
|
+
id: string;
|
|
138
|
+
name: string;
|
|
139
|
+
key: string;
|
|
140
|
+
keyPrefix: string;
|
|
141
|
+
}
|
|
142
|
+
interface ApiKeyResponse {
|
|
143
|
+
id: string;
|
|
144
|
+
name: string;
|
|
145
|
+
key: string;
|
|
146
|
+
keyPrefix: string;
|
|
147
|
+
}
|
|
148
|
+
interface ApiKeyListResponse {
|
|
149
|
+
keys: ApiKey[];
|
|
150
|
+
}
|
|
151
|
+
interface AgentMBoxError {
|
|
152
|
+
error: string;
|
|
153
|
+
}
|
|
154
|
+
type AgentMBoxErrorCode = 400 | 401 | 402 | 403 | 404 | 409 | 502;
|
|
155
|
+
declare function isAgentMBoxError(response: unknown): response is AgentMBoxError;
|
|
156
|
+
|
|
157
|
+
declare class AgentMBoxService extends Service {
|
|
158
|
+
private apiKey;
|
|
159
|
+
private mailbox;
|
|
160
|
+
private baseUrl;
|
|
161
|
+
static serviceName: "agentmbox";
|
|
162
|
+
constructor(runtime?: IAgentRuntime);
|
|
163
|
+
get serviceName(): string;
|
|
164
|
+
get capabilityDescription(): string;
|
|
165
|
+
initialize(runtime: IAgentRuntime): Promise<void>;
|
|
166
|
+
stop(): Promise<void>;
|
|
167
|
+
private request;
|
|
168
|
+
private getMailboxParam;
|
|
169
|
+
listEmails(limit?: number, offset?: number): Promise<EmailListResponse>;
|
|
170
|
+
getEmail(emailId: string): Promise<EmailDetailResponse>;
|
|
171
|
+
sendEmail(request: SendEmailRequest): Promise<SendEmailResponse>;
|
|
172
|
+
deleteEmail(emailId: string): Promise<{
|
|
173
|
+
success: boolean;
|
|
174
|
+
}>;
|
|
175
|
+
listMailboxes(): Promise<MailboxListResponse>;
|
|
176
|
+
createMailbox(request: CreateMailboxRequest): Promise<CreateMailboxResponse>;
|
|
177
|
+
deleteMailbox(mailboxId: string): Promise<{
|
|
178
|
+
success: boolean;
|
|
179
|
+
}>;
|
|
180
|
+
getPaymentStatus(): Promise<PaymentStatus>;
|
|
181
|
+
checkPayment(): Promise<PaymentCheckResponse>;
|
|
182
|
+
listDomains(): Promise<DomainListResponse>;
|
|
183
|
+
addDomain(domain: string): Promise<DomainResponse>;
|
|
184
|
+
verifyDomain(domainId: string): Promise<DomainVerifyResponse>;
|
|
185
|
+
deleteDomain(domainId: string): Promise<{
|
|
186
|
+
success: boolean;
|
|
187
|
+
}>;
|
|
188
|
+
createApiKey(name: string): Promise<ApiKeyResponse>;
|
|
189
|
+
getStatus(): Promise<{
|
|
190
|
+
paid: boolean;
|
|
191
|
+
paidUntil: string | null;
|
|
192
|
+
}>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* AgentMBox Onboarding Service
|
|
197
|
+
* Handles autonomous account creation and setup for AgentMBox
|
|
198
|
+
* The agent pays for its own subscription using its Solana wallet
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
interface OnboardingStatus {
|
|
202
|
+
stage: "pending" | "account_created" | "api_key_created" | "awaiting_payment" | "paid" | "mailbox_created" | "complete" | "error";
|
|
203
|
+
paymentAddress?: string;
|
|
204
|
+
mailbox?: string;
|
|
205
|
+
error?: string;
|
|
206
|
+
}
|
|
207
|
+
declare class AgentMBoxOnboardingService extends Service {
|
|
208
|
+
private apiKey;
|
|
209
|
+
private mailbox;
|
|
210
|
+
private baseUrl;
|
|
211
|
+
private cfg;
|
|
212
|
+
private status;
|
|
213
|
+
static serviceName: "agentmbox-onboarding";
|
|
214
|
+
constructor(runtime?: IAgentRuntime);
|
|
215
|
+
get serviceName(): string;
|
|
216
|
+
get capabilityDescription(): string;
|
|
217
|
+
getApiKey(): string;
|
|
218
|
+
getMailbox(): string | undefined;
|
|
219
|
+
private generatePassword;
|
|
220
|
+
private getAgentWallet;
|
|
221
|
+
private request;
|
|
222
|
+
private authenticatedRequest;
|
|
223
|
+
startOnboarding(runtime: IAgentRuntime): Promise<OnboardingStatus>;
|
|
224
|
+
private checkExistingSetup;
|
|
225
|
+
private payForSubscription;
|
|
226
|
+
stop(): Promise<void>;
|
|
227
|
+
private createAccount;
|
|
228
|
+
private createApiKey;
|
|
229
|
+
private getPaymentStatus;
|
|
230
|
+
private waitForPayment;
|
|
231
|
+
private createMailbox;
|
|
232
|
+
getOrCreateMailbox(): Promise<Mailbox | null>;
|
|
233
|
+
getStatus(): OnboardingStatus;
|
|
234
|
+
getPaymentAddress(): Promise<string | null>;
|
|
235
|
+
isOnboardingComplete(): boolean;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* AgentMBox Plugin for ElizaOS
|
|
240
|
+
* Email integration plugin that enables AI agents to send and receive emails
|
|
241
|
+
* Includes autonomous self-onboarding using the agent's Solana wallet
|
|
242
|
+
*/
|
|
243
|
+
|
|
244
|
+
declare const agentMBoxPlugin: Plugin;
|
|
245
|
+
|
|
246
|
+
export { type AgentMBoxConfig, type AgentMBoxError, type AgentMBoxErrorCode, AgentMBoxOnboardingService, AgentMBoxService, type ApiKey, type ApiKeyListResponse, type ApiKeyResponse, type CreateMailboxRequest, type CreateMailboxResponse, type Domain, type DomainDNSRecords, type DomainListResponse, type DomainResponse, type DomainVerifyResponse, type Email, type EmailAddress, type EmailDetailResponse, type EmailListResponse, type Mailbox, type MailboxListResponse, type PaymentCheckResponse, type PaymentStatus, type SendEmailRequest, type SendEmailResponse, agentMBoxPlugin, agentMBoxPlugin as default, isAgentMBoxError };
|