@agentmbox/plugin-agentmbox 1.0.1 → 1.1.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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import { logger as logger4 } from "@elizaos/core";
2
+ import { logger as logger5 } from "@elizaos/core";
3
3
 
4
4
  // src/services/AgentMBoxService.ts
5
5
  import { Service, logger as logger2 } from "@elizaos/core";
@@ -702,6 +702,137 @@ ${preview}`,
702
702
  ]
703
703
  };
704
704
 
705
+ // src/actions/onboarding.ts
706
+ import {
707
+ logger as logger4
708
+ } from "@elizaos/core";
709
+ var onboardingAction = {
710
+ name: "AGENTMBOX_ONBOARDING",
711
+ description: "Set up AgentMBox email for the agent - creates an account, pays 5 USDC on Solana, and creates a mailbox. The agent needs a Solana wallet with USDC to pay for the subscription.",
712
+ handler: async (runtime, message, state, _options, callback) => {
713
+ const onboardingService = runtime.getService(
714
+ "agentmbox-onboarding"
715
+ );
716
+ if (!onboardingService) {
717
+ const errorMsg = "AgentMBox onboarding service not initialized";
718
+ logger4.error(errorMsg);
719
+ if (callback) {
720
+ await callback({
721
+ text: errorMsg,
722
+ values: { success: false, error: errorMsg }
723
+ });
724
+ }
725
+ return { success: false, error: errorMsg };
726
+ }
727
+ if (onboardingService.isOnboardingComplete()) {
728
+ const mailbox = onboardingService.getMailbox();
729
+ const msg = `Already onboarded! Mailbox: ${mailbox}`;
730
+ logger4.info(msg);
731
+ if (callback) {
732
+ await callback({
733
+ text: msg,
734
+ values: { success: true, mailbox }
735
+ });
736
+ }
737
+ return { success: true, mailbox };
738
+ }
739
+ try {
740
+ logger4.info("Starting AgentMBox onboarding...");
741
+ const status = await onboardingService.startOnboarding(runtime);
742
+ if (callback) {
743
+ await callback({
744
+ text: `Onboarding ${status.stage}: ${status.mailbox || status.paymentAddress || status.error || ""}`,
745
+ values: {
746
+ success: status.stage === "complete",
747
+ stage: status.stage,
748
+ mailbox: status.mailbox,
749
+ paymentAddress: status.paymentAddress,
750
+ error: status.error
751
+ }
752
+ });
753
+ }
754
+ if (status.stage === "complete" && status.mailbox) {
755
+ const apiKey = onboardingService.getApiKey();
756
+ const mailbox = onboardingService.getMailbox();
757
+ if (apiKey) {
758
+ runtime.setSetting("AGENTMBOX_API_KEY", apiKey, true);
759
+ }
760
+ if (mailbox) {
761
+ runtime.setSetting("AGENTMBOX_MAILBOX", mailbox);
762
+ }
763
+ logger4.info("Onboarding complete! Mailbox: " + status.mailbox);
764
+ return { success: true, mailbox: status.mailbox };
765
+ } else if (status.stage === "awaiting_payment" && status.paymentAddress) {
766
+ const msg = "Payment required! Please send 5 USDC to: " + status.paymentAddress;
767
+ logger4.warn(msg);
768
+ return {
769
+ success: false,
770
+ stage: status.stage,
771
+ paymentAddress: status.paymentAddress,
772
+ message: msg
773
+ };
774
+ } else if (status.stage === "error") {
775
+ const errorMsg = "Onboarding failed: " + status.error;
776
+ logger4.error(errorMsg);
777
+ return { success: false, error: status.error };
778
+ }
779
+ return { success: true, stage: status.stage };
780
+ } catch (error) {
781
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
782
+ logger4.error("Onboarding failed: " + errorMessage);
783
+ if (callback) {
784
+ await callback({
785
+ text: "Onboarding failed: " + errorMessage,
786
+ values: { success: false, error: errorMessage }
787
+ });
788
+ }
789
+ return { success: false, error: errorMessage };
790
+ }
791
+ },
792
+ validate: async (runtime) => {
793
+ try {
794
+ const service = runtime.getService(
795
+ "agentmbox-onboarding"
796
+ );
797
+ return !!service;
798
+ } catch {
799
+ return false;
800
+ }
801
+ },
802
+ examples: [
803
+ [
804
+ {
805
+ name: "user",
806
+ content: "Set up email for this agent"
807
+ },
808
+ {
809
+ name: "assistant",
810
+ content: "I'll set up AgentMBox email for you. This will create an account and pay 5 USDC from the agent's wallet."
811
+ }
812
+ ],
813
+ [
814
+ {
815
+ name: "user",
816
+ content: "I need to configure the email service"
817
+ },
818
+ {
819
+ name: "assistant",
820
+ content: "Starting the AgentMBox onboarding process now."
821
+ }
822
+ ],
823
+ [
824
+ {
825
+ name: "user",
826
+ content: "Can you set up a mailbox for receiving emails?"
827
+ },
828
+ {
829
+ name: "assistant",
830
+ content: "On it! I'll create the mailbox and handle the payment."
831
+ }
832
+ ]
833
+ ]
834
+ };
835
+
705
836
  // src/providers/emailProvider.ts
706
837
  var emailProvider = {
707
838
  name: "email",
@@ -759,15 +890,19 @@ ${recentEmailsText}` : "\n\nNo recent emails."}`,
759
890
  var agentMBoxPlugin = {
760
891
  name: "agentmbox",
761
892
  description: "AgentMBox email integration plugin for ElizaOS - enables AI agents to send/receive emails with autonomous onboarding",
762
- actions: [sendEmailAction, getEmailsAction],
893
+ priority: 0,
894
+ config: {
895
+ baseUrl: "https://agentmbox.com/api/v1"
896
+ },
897
+ actions: [sendEmailAction, getEmailsAction, onboardingAction],
763
898
  providers: [emailProvider],
764
899
  services: [AgentMBoxService, AgentMBoxOnboardingService],
765
900
  init: async (config, runtime) => {
766
- logger4.info("AgentMBox plugin initializing");
901
+ logger5.info("AgentMBox plugin initializing");
767
902
  const existingApiKey = runtime.getSetting("AGENTMBOX_API_KEY");
768
903
  const skipOnboarding = runtime.getSetting("AGENTMBOX_SKIP_ONBOARDING") === "true";
769
904
  if (!existingApiKey && !skipOnboarding) {
770
- logger4.info("Starting AgentMBox autonomous onboarding...");
905
+ logger5.info("Starting AgentMBox autonomous onboarding...");
771
906
  try {
772
907
  const onboardingService = runtime.getService(
773
908
  "agentmbox-onboarding"
@@ -783,22 +918,22 @@ var agentMBoxPlugin = {
783
918
  if (mailbox) {
784
919
  runtime.setSetting("AGENTMBOX_MAILBOX", mailbox);
785
920
  }
786
- logger4.info("Onboarding complete! Mailbox: " + status.mailbox);
921
+ logger5.info("Onboarding complete! Mailbox: " + status.mailbox);
787
922
  } else if (status.stage === "awaiting_payment" && status.paymentAddress) {
788
- logger4.warn(
923
+ logger5.warn(
789
924
  "Payment required. Please fund: " + status.paymentAddress
790
925
  );
791
- logger4.info("Required: 5 USDC on Solana + ~0.01 SOL for fees");
926
+ logger5.info("Required: 5 USDC on Solana + ~0.01 SOL for fees");
792
927
  }
793
928
  }
794
929
  } catch (error) {
795
930
  const errorMsg = error instanceof Error ? error.message : "Unknown error";
796
- logger4.error("Onboarding failed: " + errorMsg);
931
+ logger5.error("Onboarding failed: " + errorMsg);
797
932
  }
798
933
  } else if (existingApiKey) {
799
- logger4.info("Using existing AgentMBox configuration");
934
+ logger5.info("Using existing AgentMBox configuration");
800
935
  } else {
801
- logger4.info("Onboarding skipped per configuration");
936
+ logger5.info("Onboarding skipped per configuration");
802
937
  }
803
938
  const emailService = runtime.getService("agentmbox");
804
939
  if (emailService) {
@@ -806,7 +941,7 @@ var agentMBoxPlugin = {
806
941
  await emailService.initialize(runtime);
807
942
  } catch (error) {
808
943
  const errorMsg = error instanceof Error ? error.message : "Unknown error";
809
- logger4.error(
944
+ logger5.error(
810
945
  "Failed to initialize AgentMBox email service: " + errorMsg
811
946
  );
812
947
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/services/AgentMBoxService.ts","../src/types/index.ts","../src/services/AgentMBoxOnboardingService.ts","../src/actions/sendEmail.ts","../src/actions/getEmails.ts","../src/providers/emailProvider.ts"],"sourcesContent":["/**\n * AgentMBox Plugin for ElizaOS\n * Email integration plugin that enables AI agents to send and receive emails\n * Includes autonomous self-onboarding using the agent's Solana wallet\n */\n\nimport type { Plugin, IAgentRuntime } from \"@elizaos/core\";\nimport { logger } from \"@elizaos/core\";\nimport { AgentMBoxService } from \"./services/AgentMBoxService\";\nimport { AgentMBoxOnboardingService } from \"./services/AgentMBoxOnboardingService\";\nimport { sendEmailAction } from \"./actions/sendEmail\";\nimport { getEmailsAction } from \"./actions/getEmails\";\nimport { emailProvider } from \"./providers/emailProvider\";\n\nexport const agentMBoxPlugin: Plugin = {\n name: \"agentmbox\",\n description:\n \"AgentMBox email integration plugin for ElizaOS - enables AI agents to send/receive emails with autonomous onboarding\",\n actions: [sendEmailAction, getEmailsAction],\n providers: [emailProvider],\n services: [AgentMBoxService, AgentMBoxOnboardingService],\n init: async (config: Record<string, string>, runtime: IAgentRuntime) => {\n logger.info(\"AgentMBox plugin initializing\");\n\n // Check if onboarding is needed\n const existingApiKey = runtime.getSetting(\"AGENTMBOX_API_KEY\");\n const skipOnboarding =\n runtime.getSetting(\"AGENTMBOX_SKIP_ONBOARDING\") === \"true\";\n\n if (!existingApiKey && !skipOnboarding) {\n logger.info(\"Starting AgentMBox autonomous onboarding...\");\n\n try {\n const onboardingService =\n runtime.getService<AgentMBoxOnboardingService>(\n \"agentmbox-onboarding\",\n );\n if (onboardingService) {\n const status = await onboardingService.startOnboarding(runtime);\n\n if (status.stage === \"complete\" && status.mailbox) {\n // Save credentials to runtime settings for persistence\n const apiKey = onboardingService.getApiKey();\n const mailbox = onboardingService.getMailbox();\n if (apiKey) {\n runtime.setSetting(\"AGENTMBOX_API_KEY\", apiKey, true);\n }\n if (mailbox) {\n runtime.setSetting(\"AGENTMBOX_MAILBOX\", mailbox);\n }\n logger.info(\"Onboarding complete! Mailbox: \" + status.mailbox);\n } else if (\n status.stage === \"awaiting_payment\" &&\n status.paymentAddress\n ) {\n logger.warn(\n \"Payment required. Please fund: \" + status.paymentAddress,\n );\n logger.info(\"Required: 5 USDC on Solana + ~0.01 SOL for fees\");\n }\n }\n } catch (error) {\n const errorMsg =\n error instanceof Error ? error.message : \"Unknown error\";\n logger.error(\"Onboarding failed: \" + errorMsg);\n }\n } else if (existingApiKey) {\n logger.info(\"Using existing AgentMBox configuration\");\n } else {\n logger.info(\"Onboarding skipped per configuration\");\n }\n\n // Initialize main email service (after onboarding has potentially saved credentials)\n const emailService = runtime.getService<AgentMBoxService>(\"agentmbox\");\n if (emailService) {\n try {\n await emailService.initialize(runtime);\n } catch (error) {\n const errorMsg =\n error instanceof Error ? error.message : \"Unknown error\";\n logger.error(\n \"Failed to initialize AgentMBox email service: \" + errorMsg,\n );\n // Don't fail the whole plugin initialization - the service will be unavailable\n }\n }\n },\n};\n\nexport default agentMBoxPlugin;\n\n// Re-export for convenience\nexport { AgentMBoxService } from \"./services/AgentMBoxService\";\nexport { AgentMBoxOnboardingService } from \"./services/AgentMBoxOnboardingService\";\nexport * from \"./types\";\n","import { Service, type IAgentRuntime, logger } from \"@elizaos/core\";\nimport {\n type AgentMBoxConfig,\n type EmailListResponse,\n type EmailDetailResponse,\n type SendEmailRequest,\n type SendEmailResponse,\n type MailboxListResponse,\n type CreateMailboxRequest,\n type CreateMailboxResponse,\n type PaymentStatus,\n type PaymentCheckResponse,\n type DomainListResponse,\n type DomainResponse,\n type DomainVerifyResponse,\n type ApiKeyResponse,\n isAgentMBoxError,\n} from \"../types\";\n\nexport class AgentMBoxService extends Service {\n private apiKey: string = \"\";\n private mailbox: string | undefined;\n private baseUrl: string = \"https://agentmbox.com/api/v1\";\n\n static serviceName = \"agentmbox\" as const;\n\n constructor(runtime?: IAgentRuntime) {\n super(runtime!);\n }\n\n get serviceName(): string {\n return AgentMBoxService.serviceName;\n }\n\n get capabilityDescription(): string {\n return \"AgentMBox email service - allows sending and receiving emails\";\n }\n\n async initialize(runtime: IAgentRuntime): Promise<void> {\n const apiKey = String(runtime.getSetting(\"AGENTMBOX_API_KEY\") || \"\");\n const mailbox = String(runtime.getSetting(\"AGENTMBOX_MAILBOX\") || \"\");\n const baseUrl = String(runtime.getSetting(\"AGENTMBOX_BASE_URL\") || \"\");\n\n // API key will be set by onboarding if not provided\n // The service will work once onboarding completes\n if (apiKey && !apiKey.startsWith(\"ai_\")) {\n logger.warn(\"AgentMBox API key should start with 'ai_'\");\n }\n\n const agentName =\n runtime.character?.name?.toLowerCase().replace(/\\s+/g, \"-\") || \"agent\";\n const defaultMailbox = mailbox || `${agentName}@agentmbox.com`;\n\n this.apiKey = apiKey;\n this.mailbox = defaultMailbox;\n this.baseUrl = baseUrl || \"https://agentmbox.com/api/v1\";\n this.runtime = runtime;\n\n if (!this.apiKey.startsWith(\"ai_\")) {\n logger.warn(\"AgentMBox API key should start with 'ai_'\");\n }\n\n logger.info(\"AgentMBox service initialized for: \" + this.mailbox);\n }\n\n async stop(): Promise<void> {\n logger.info(\"AgentMBox service stopped\");\n }\n\n private async request<T>(\n endpoint: string,\n options: RequestInit = {},\n ): Promise<T> {\n if (!this.apiKey) {\n throw new Error(\n \"AgentMBox API key not configured. Ensure onboarding has completed or set AGENTMBOX_API_KEY.\",\n );\n }\n\n const url = `${this.baseUrl}${endpoint}`;\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n ...(options.headers as Record<string, string>),\n };\n\n const response = await fetch(url, { ...options, headers });\n const data = await response.json();\n\n if (!response.ok) {\n if (isAgentMBoxError(data)) {\n throw new Error(\n `AgentMBox API error (${response.status}): ${data.error}`,\n );\n }\n throw new Error(`AgentMBox API error: ${response.status}`);\n }\n\n return data as T;\n }\n\n private getMailboxParam(): string {\n if (!this.mailbox) {\n throw new Error(\"Mailbox not configured\");\n }\n return \"?mailbox=\" + encodeURIComponent(this.mailbox);\n }\n\n async listEmails(limit = 50, offset = 0): Promise<EmailListResponse> {\n const mailboxParam = this.getMailboxParam();\n return this.request<EmailListResponse>(\n \"/mail\" + mailboxParam + \"&limit=\" + limit + \"&offset=\" + offset,\n );\n }\n\n async getEmail(emailId: string): Promise<EmailDetailResponse> {\n const mailboxParam = this.getMailboxParam();\n return this.request<EmailDetailResponse>(\"/mail/\" + emailId + mailboxParam);\n }\n\n async sendEmail(request: SendEmailRequest): Promise<SendEmailResponse> {\n const from = request.from || this.mailbox;\n if (!from) {\n throw new Error(\"Sender address not specified\");\n }\n\n return this.request<SendEmailResponse>(\"/mail/send\", {\n method: \"POST\",\n body: JSON.stringify({ ...request, from }),\n });\n }\n\n async deleteEmail(emailId: string): Promise<{ success: boolean }> {\n const mailboxParam = this.getMailboxParam();\n return this.request<{ success: boolean }>(\n \"/mail/\" + emailId + mailboxParam,\n {\n method: \"DELETE\",\n },\n );\n }\n\n async listMailboxes(): Promise<MailboxListResponse> {\n return this.request<MailboxListResponse>(\"/mailboxes\");\n }\n\n async createMailbox(\n request: CreateMailboxRequest,\n ): Promise<CreateMailboxResponse> {\n return this.request<CreateMailboxResponse>(\"/mailboxes\", {\n method: \"POST\",\n body: JSON.stringify(request),\n });\n }\n\n async deleteMailbox(mailboxId: string): Promise<{ success: boolean }> {\n return this.request<{ success: boolean }>(\"/mailboxes/\" + mailboxId, {\n method: \"DELETE\",\n });\n }\n\n async getPaymentStatus(): Promise<PaymentStatus> {\n return this.request<PaymentStatus>(\"/payment\");\n }\n\n async checkPayment(): Promise<PaymentCheckResponse> {\n return this.request<PaymentCheckResponse>(\"/payment/check\", {\n method: \"POST\",\n });\n }\n\n async listDomains(): Promise<DomainListResponse> {\n return this.request<DomainListResponse>(\"/domains\");\n }\n\n async addDomain(domain: string): Promise<DomainResponse> {\n return this.request<DomainResponse>(\"/domains\", {\n method: \"POST\",\n body: JSON.stringify({ domain }),\n });\n }\n\n async verifyDomain(domainId: string): Promise<DomainVerifyResponse> {\n return this.request<DomainVerifyResponse>(\n \"/domains/\" + domainId + \"/verify\",\n {\n method: \"POST\",\n },\n );\n }\n\n async deleteDomain(domainId: string): Promise<{ success: boolean }> {\n return this.request<{ success: boolean }>(\"/domains/\" + domainId, {\n method: \"DELETE\",\n });\n }\n\n async createApiKey(name: string): Promise<ApiKeyResponse> {\n return this.request<ApiKeyResponse>(\"/keys\", {\n method: \"POST\",\n body: JSON.stringify({ name }),\n });\n }\n\n async getStatus(): Promise<{ paid: boolean; paidUntil: string | null }> {\n try {\n const status = await this.getPaymentStatus();\n return { paid: status.paid, paidUntil: status.paidUntil };\n } catch (error) {\n logger.error(\"Failed to get AgentMBox status\");\n return { paid: false, paidUntil: null };\n }\n }\n}\n\nexport default AgentMBoxService;\n","/**\n * AgentMBox Plugin Types\n * TypeScript interfaces for AgentMBox email integration\n */\n\nexport interface AgentMBoxConfig {\n /** API key for AgentMBox (starts with ai_) */\n apiKey: string;\n /** Mailbox address (e.g., my-agent@agentmbox.com) */\n mailbox?: string;\n /** Base URL for AgentMBox API (default: https://agentmbox.com/api/v1) */\n baseUrl?: string;\n}\n\nexport interface EmailAddress {\n name?: string;\n email: string;\n}\n\nexport interface Email {\n id: string;\n from: EmailAddress[];\n to: EmailAddress[];\n cc?: EmailAddress[] | null;\n subject: string;\n receivedAt: string;\n textBody?: string;\n htmlBody?: string;\n preview?: string;\n hasAttachment: boolean;\n isRead: boolean;\n}\n\nexport interface EmailListResponse {\n mailbox: string;\n emails: Email[];\n limit: number;\n offset: number;\n}\n\nexport interface EmailDetailResponse {\n email: Email;\n}\n\nexport interface SendEmailRequest {\n /** Sender address (must be a mailbox you own) */\n from: string;\n /** Recipient(s) - single email or array */\n to: string | string[];\n /** Email subject line */\n subject: string;\n /** Plain text body */\n text?: string;\n /** HTML body */\n html?: string;\n}\n\nexport interface SendEmailResponse {\n success: boolean;\n}\n\nexport interface Mailbox {\n id: string;\n address: string;\n localPart: string;\n domainName: string;\n displayName?: string | null;\n password?: string; // Only shown at creation\n createdAt: string;\n}\n\nexport interface MailboxListResponse {\n mailboxes: Mailbox[];\n}\n\nexport interface CreateMailboxRequest {\n localPart: string;\n domainId?: string;\n displayName?: string;\n}\n\nexport interface CreateMailboxResponse {\n mailbox: Mailbox;\n}\n\nexport interface PaymentStatus {\n paid: boolean;\n paidUntil: string | null;\n solanaAddress: string;\n usdcPerPeriod: number;\n periodDays: number;\n creditedUsdc: number;\n payments: unknown[];\n}\n\nexport interface PaymentCheckResponse {\n paid: boolean;\n paidUntil: string;\n newCredits: number;\n balanceUsdc: number;\n creditedUsdc: number;\n}\n\nexport interface Domain {\n id: string;\n domain: string;\n verified: boolean;\n}\n\nexport interface DomainDNSRecords {\n verification: { type: string; name: string; value: string };\n mx: { type: string; name: string; value: string; priority: number };\n spf: { type: string; name: string; value: string };\n dkim: { type: string; name: string; value: string };\n}\n\nexport interface DomainResponse {\n domain: Domain;\n dnsRecords: DomainDNSRecords;\n}\n\nexport interface DomainVerifyResponse {\n verified: boolean;\n txtVerified: boolean;\n mxVerified: boolean;\n spfVerified: boolean;\n dkimVerified: boolean;\n}\n\nexport interface DomainListResponse {\n domains: (Domain & { dnsRecords?: DomainDNSRecords })[];\n}\n\nexport interface ApiKey {\n id: string;\n name: string;\n key: string;\n keyPrefix: string;\n}\n\nexport interface ApiKeyResponse {\n id: string;\n name: string;\n key: string;\n keyPrefix: string;\n}\n\nexport interface ApiKeyListResponse {\n keys: ApiKey[];\n}\n\nexport interface AgentMBoxError {\n error: string;\n}\n\nexport type AgentMBoxErrorCode = 400 | 401 | 402 | 403 | 404 | 409 | 502;\n\nexport function isAgentMBoxError(\n response: unknown,\n): response is AgentMBoxError {\n return (\n typeof response === \"object\" &&\n response !== null &&\n \"error\" in response &&\n typeof (response as AgentMBoxError).error === \"string\"\n );\n}\n","/**\n * AgentMBox Onboarding Service\n * Handles autonomous account creation and setup for AgentMBox\n * The agent pays for its own subscription using its Solana wallet\n */\n\nimport { Service, type IAgentRuntime, logger } from \"@elizaos/core\";\nimport {\n type PaymentStatus,\n type PaymentCheckResponse,\n type ApiKeyResponse,\n type Mailbox,\n} from \"../types\";\n\nexport interface OnboardingStatus {\n stage:\n | \"pending\"\n | \"account_created\"\n | \"api_key_created\"\n | \"awaiting_payment\"\n | \"paid\"\n | \"mailbox_created\"\n | \"complete\"\n | \"error\";\n paymentAddress?: string;\n mailbox?: string;\n error?: string;\n}\n\nexport class AgentMBoxOnboardingService extends Service {\n private apiKey: string = \"\";\n private mailbox: string | undefined;\n private baseUrl: string = \"https://agentmbox.com/api/v1\";\n private cfg: {\n ownerEmail: string;\n password: string;\n mailboxLocalPart: string;\n } | null = null;\n private status: OnboardingStatus = { stage: \"pending\" };\n\n static serviceName = \"agentmbox-onboarding\" as const;\n\n constructor(runtime?: IAgentRuntime) {\n super(runtime!);\n }\n\n get serviceName(): string {\n return AgentMBoxOnboardingService.serviceName;\n }\n\n get capabilityDescription(): string {\n return \"AgentMBox autonomous onboarding - creates account, pays for subscription, sets up mailbox\";\n }\n\n getApiKey(): string {\n return this.apiKey;\n }\n\n getMailbox(): string | undefined {\n return this.mailbox;\n }\n\n private generatePassword(length: number = 32): string {\n const chars =\n \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*\";\n let password = \"\";\n const array = new Uint8Array(length);\n crypto.getRandomValues(array);\n for (let i = 0; i < length; i++) {\n password += chars[array[i] % chars.length];\n }\n return password;\n }\n\n private async getAgentWallet(): Promise<{\n publicKey: string;\n privateKey: Uint8Array;\n } | null> {\n if (!this.runtime) return null;\n\n try {\n const privateKeyBase58 = String(\n this.runtime.getSetting(\"SOLANA_PRIVATE_KEY\") || \"\",\n );\n if (privateKeyBase58) {\n const { default: bs58 } = await import(\"bs58\");\n const { Keypair } = await import(\"@solana/web3.js\");\n const privateKey = bs58.decode(privateKeyBase58);\n const keypair = Keypair.fromSecretKey(privateKey);\n return {\n publicKey: keypair.publicKey.toBase58(),\n privateKey,\n };\n }\n\n const walletService = await this.runtime.getService(\"wallet\");\n if (walletService) {\n const keypair = await (walletService as any).getKeypair?.();\n if (keypair) {\n return {\n publicKey: keypair.publicKey.toBase58(),\n privateKey: keypair.secretKey,\n };\n }\n }\n } catch (error) {\n logger.warn(\"Could not get agent wallet\");\n }\n\n return null;\n }\n\n private async request<T>(\n endpoint: string,\n options: RequestInit = {},\n ): Promise<T> {\n const url = `${this.baseUrl}${endpoint}`;\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...(options.headers as Record<string, string>),\n };\n\n const response = await fetch(url, { ...options, headers });\n const data = await response.json();\n\n if (!response.ok) {\n const error = (data as { error?: string }).error || `${response.status}`;\n throw new Error(error);\n }\n\n return data as T;\n }\n\n private async authenticatedRequest<T>(\n endpoint: string,\n options: RequestInit = {},\n ): Promise<T> {\n if (!this.apiKey) {\n throw new Error(\"API key not set\");\n }\n\n const url = `${this.baseUrl}${endpoint}`;\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n ...(options.headers as Record<string, string>),\n };\n\n const response = await fetch(url, { ...options, headers });\n const data = await response.json();\n\n if (!response.ok) {\n const error = (data as { error?: string }).error || `${response.status}`;\n throw new Error(error);\n }\n\n return data as T;\n }\n\n async startOnboarding(runtime: IAgentRuntime): Promise<OnboardingStatus> {\n this.runtime = runtime;\n\n const existingApiKey = String(\n runtime.getSetting(\"AGENTMBOX_API_KEY\") || \"\",\n );\n if (existingApiKey && existingApiKey.startsWith(\"ai_\")) {\n this.apiKey = existingApiKey;\n return await this.checkExistingSetup();\n }\n\n const agentName =\n runtime.character?.name?.toLowerCase().replace(/\\s+/g, \"-\") || \"agent\";\n const mailboxSetting = String(\n runtime.getSetting(\"AGENTMBOX_MAILBOX\") || \"\",\n );\n this.cfg = {\n ownerEmail:\n String(runtime.getSetting(\"AGENTMBOX_OWNER_EMAIL\")) ||\n `agent-${agentName}@owner.local`,\n password: this.generatePassword(32),\n mailboxLocalPart: mailboxSetting\n ? mailboxSetting.split(\"@\")[0]\n : agentName,\n };\n\n try {\n // Step 1: Create account\n await this.createAccount();\n this.status = { stage: \"account_created\" };\n logger.info(\"AgentMBox account created\");\n\n // Step 2: Create API key\n const apiKeyResponse = await this.createApiKey(agentName);\n this.apiKey = apiKeyResponse.key;\n this.status = { stage: \"api_key_created\" };\n logger.info(\"AgentMBox API key created\");\n\n // Step 3: Get payment address\n const payment = await this.getPaymentStatus();\n this.status = {\n stage: \"awaiting_payment\",\n paymentAddress: payment.solanaAddress,\n };\n logger.info(\"Payment address: \" + payment.solanaAddress);\n\n // Step 4: Pay for subscription\n await this.payForSubscription(payment.solanaAddress, runtime);\n this.status = { stage: \"paid\" };\n logger.info(\"Payment completed\");\n\n // Step 5: Create mailbox\n const mailbox = await this.createMailbox(this.cfg!.mailboxLocalPart);\n this.mailbox = mailbox.address;\n this.status = {\n stage: \"complete\",\n mailbox: mailbox.address,\n };\n logger.info(\"Mailbox created: \" + mailbox.address);\n\n return this.status;\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : \"Unknown error\";\n logger.error(\"AgentMBox onboarding failed: \" + errorMsg);\n this.status = { stage: \"error\", error: errorMsg };\n throw error;\n }\n }\n\n private async checkExistingSetup(): Promise<OnboardingStatus> {\n try {\n const payment = await this.getPaymentStatus();\n\n if (payment.paid) {\n const mailbox = await this.getOrCreateMailbox();\n this.status = mailbox\n ? { stage: \"complete\", mailbox: mailbox.address }\n : { stage: \"paid\" };\n } else {\n const wallet = await this.getAgentWallet();\n if (wallet && this.runtime) {\n await this.payForSubscription(payment.solanaAddress, this.runtime);\n this.status = { stage: \"paid\" };\n const mailbox = await this.getOrCreateMailbox();\n if (mailbox) {\n this.status = { stage: \"complete\", mailbox: mailbox.address };\n }\n } else {\n this.status = {\n stage: \"awaiting_payment\",\n paymentAddress: payment.solanaAddress,\n };\n }\n }\n } catch (error) {\n logger.warn(\"Could not check existing setup\");\n this.status = { stage: \"pending\" };\n }\n\n return this.status;\n }\n\n private async payForSubscription(\n paymentAddress: string,\n runtime: IAgentRuntime,\n ): Promise<void> {\n const wallet = await this.getAgentWallet();\n\n if (!wallet) {\n logger.warn(\"No agent wallet found, waiting for manual payment\");\n await this.waitForPayment();\n return;\n }\n\n logger.info(\"Using agent wallet to pay for subscription\");\n\n try {\n const { Connection, Keypair } = await import(\"@solana/web3.js\");\n const { transfer, getOrCreateAssociatedTokenAccount } =\n await import(\"@solana/spl-token\");\n\n const connection = new Connection(\"https://api.mainnet-beta.solana.com\");\n const signer = Keypair.fromSecretKey(wallet.privateKey);\n\n const usdcMintStr = \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGZwyTDt1v\";\n const { PublicKey } = await import(\"@solana/web3.js\");\n const usdcMint = new PublicKey(usdcMintStr);\n const toPublicKey = new PublicKey(paymentAddress);\n\n const fromTokenAccount = await getOrCreateAssociatedTokenAccount(\n connection,\n signer,\n usdcMint,\n signer.publicKey,\n );\n\n const toTokenAccount = await getOrCreateAssociatedTokenAccount(\n connection,\n signer,\n usdcMint,\n toPublicKey,\n );\n\n const amount = 5_000_000;\n\n await transfer(\n connection,\n signer,\n fromTokenAccount.address,\n toTokenAccount.address,\n signer.publicKey,\n amount,\n );\n\n logger.info(\"USDC transfer complete\");\n await this.waitForPayment();\n } catch (error) {\n logger.error(\"Failed to transfer USDC, waiting for manual payment\");\n await this.waitForPayment();\n }\n }\n\n async stop(): Promise<void> {\n logger.info(\"AgentMBox onboarding service stopped\");\n }\n\n private async createAccount(): Promise<void> {\n if (!this.cfg) throw new Error(\"Config not set\");\n\n const response = await this.request<{ id: string }>(\"/auth/signup\", {\n method: \"POST\",\n body: JSON.stringify({\n email: this.cfg.ownerEmail,\n password: this.cfg.password,\n }),\n });\n\n logger.info(\"Account created: \" + response.id);\n }\n\n private async createApiKey(name: string): Promise<ApiKeyResponse> {\n const response = await this.request<ApiKeyResponse>(\"/keys\", {\n method: \"POST\",\n body: JSON.stringify({ name }),\n });\n\n logger.info(\"API key created: \" + response.key.substring(0, 12) + \"...\");\n return response;\n }\n\n private async getPaymentStatus(): Promise<PaymentStatus> {\n return this.authenticatedRequest<PaymentStatus>(\"/payment\");\n }\n\n private async waitForPayment(\n maxAttempts: number = 60,\n intervalMs: number = 5000,\n ): Promise<PaymentCheckResponse> {\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n const result = await this.authenticatedRequest<PaymentCheckResponse>(\n \"/payment/check\",\n {\n method: \"POST\",\n },\n );\n\n if (result.paid) {\n return result;\n }\n\n logger.info(\n \"Waiting for payment... (\" + attempt + \"/\" + maxAttempts + \")\",\n );\n } catch (e) {\n logger.warn(\n \"Payment check failed: \" +\n (e instanceof Error ? e.message : \"unknown\"),\n );\n }\n\n if (attempt < maxAttempts) {\n await new Promise((resolve) => setTimeout(resolve, intervalMs));\n }\n }\n\n throw new Error(\"Payment not received after \" + maxAttempts + \" attempts\");\n }\n\n private async createMailbox(localPart: string): Promise<Mailbox> {\n const response = await this.authenticatedRequest<{ mailbox: Mailbox }>(\n \"/mailboxes\",\n {\n method: \"POST\",\n body: JSON.stringify({\n localPart,\n displayName: this.cfg?.mailboxLocalPart || \"Agent Mailbox\",\n }),\n },\n );\n\n return response.mailbox;\n }\n\n async getOrCreateMailbox(): Promise<Mailbox | null> {\n try {\n const response = await this.authenticatedRequest<{\n mailboxes: Mailbox[];\n }>(\"/mailboxes\");\n\n if (response.mailboxes.length > 0) {\n return response.mailboxes[0];\n }\n\n if (this.cfg?.mailboxLocalPart) {\n return await this.createMailbox(this.cfg.mailboxLocalPart);\n }\n\n return null;\n } catch (error) {\n logger.error(\"Failed to get/create mailbox\");\n return null;\n }\n }\n\n getStatus(): OnboardingStatus {\n return this.status;\n }\n\n async getPaymentAddress(): Promise<string | null> {\n if (this.status.paymentAddress) {\n return this.status.paymentAddress;\n }\n\n try {\n const payment = await this.getPaymentStatus();\n return payment.solanaAddress;\n } catch {\n return null;\n }\n }\n\n isOnboardingComplete(): boolean {\n return this.status.stage === \"complete\";\n }\n}\n\nexport default AgentMBoxOnboardingService;\n","/**\n * Send Email Action\n * Allows the agent to send emails via AgentMBox\n */\n\nimport {\n type Action,\n type HandlerCallback,\n type IAgentRuntime,\n type Memory,\n type State,\n type ActionExample,\n} from \"@elizaos/core\";\nimport { AgentMBoxService } from \"../services/AgentMBoxService\";\n\nexport const sendEmailAction: Action = {\n name: \"SEND_EMAIL\",\n description: \"Send an email to a recipient using AgentMBox email service\",\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n state: State,\n options: Record<string, unknown>,\n callback?: HandlerCallback\n ) => {\n const service = runtime.getService<AgentMBoxService>(\"agentmbox\");\n if (!service) {\n throw new Error(\"AgentMBox service not initialized\");\n }\n\n const { to, subject, text, html } = options;\n\n if (!to) {\n throw new Error(\"Missing required field: 'to' (recipient email)\");\n }\n\n if (!subject) {\n throw new Error(\"Missing required field: 'subject'\");\n }\n\n const from = options.from as string | undefined;\n\n try {\n const result = await service.sendEmail({\n from,\n to: Array.isArray(to) ? to : to,\n subject,\n text: text as string | undefined,\n html: html as string | undefined,\n });\n\n if (callback) {\n await callback({\n text: `Email sent successfully to ${to}`,\n values: {\n success: result.success,\n recipient: to,\n subject,\n },\n });\n }\n\n return {\n success: true,\n values: {\n sentTo: to,\n subject,\n },\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n logger.error(\"Failed to send email\", { error: errorMessage });\n\n if (callback) {\n await callback({\n text: `Failed to send email: ${errorMessage}`,\n values: {\n success: false,\n error: errorMessage,\n },\n });\n }\n\n return {\n success: false,\n error: errorMessage,\n };\n }\n },\n validate: async (runtime: IAgentRuntime) => {\n try {\n const service = runtime.getService<AgentMBoxService>(\"agentmbox\");\n return !!service;\n } catch {\n return false;\n }\n },\n examples: [\n [\n {\n name: \"user\",\n content: \"Send an email to john@example.com about the project update\",\n },\n {\n name: \"assistant\",\n content: \"I'll send that email for you.\",\n },\n ],\n [\n {\n name: \"user\",\n content: \"Email the team that the meeting is at 3pm\",\n },\n {\n name: \"assistant\",\n content: \"Sending that email now.\",\n },\n ],\n [\n {\n name: \"user\",\n content: \"Can you notify alice@example.com that the report is ready?\",\n },\n {\n name: \"assistant\",\n content: \"I'll send her an email right away.\",\n },\n ],\n ] as ActionExample[][],\n};\n\nexport default sendEmailAction;\n","/**\n * Get Emails Action\n * Allows the agent to retrieve emails from the mailbox via AgentMBox\n */\n\nimport {\n type Action,\n type HandlerCallback,\n type IAgentRuntime,\n type Memory,\n type State,\n type ActionExample,\n} from \"@elizaos/core\";\nimport { AgentMBoxService } from \"../services/AgentMBoxService\";\n\nexport const getEmailsAction: Action = {\n name: \"GET_EMAILS\",\n description: \"Retrieve emails from the AgentMBox mailbox. Can filter by read status and limit results.\",\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n state: State,\n options: Record<string, unknown>,\n callback?: HandlerCallback\n ) => {\n const service = runtime.getService<AgentMBoxService>(\"agentmbox\");\n if (!service) {\n throw new Error(\"AgentMBox service not initialized\");\n }\n\n const limit = (options.limit as number) || 10;\n const offset = (options.offset as number) || 0;\n const emailId = options.emailId as string | undefined;\n\n try {\n // If emailId is provided, get a specific email\n if (emailId) {\n const emailDetail = await service.getEmail(emailId);\n\n if (callback) {\n await callback({\n text: `Retrieved email: ${emailDetail.email.subject}`,\n values: {\n email: emailDetail.email,\n },\n });\n }\n\n return {\n success: true,\n values: {\n email: emailDetail.email,\n },\n };\n }\n\n // Otherwise, list emails\n const emailList = await service.listEmails(limit, offset);\n\n // Filter by read status if specified\n let emails = emailList.emails;\n const unreadOnly = options.unreadOnly as boolean;\n if (unreadOnly) {\n emails = emails.filter((email) => !email.isRead);\n }\n\n if (callback) {\n const preview = emails\n .slice(0, 5)\n .map((e) => `- ${e.subject} from ${e.from[0]?.email}`)\n .join(\"\\n\");\n await callback({\n text: `Found ${emails.length} emails:\\n${preview}`,\n values: {\n emails: emails,\n total: emailList.emails.length,\n unread: emailList.emails.filter((e) => !e.isRead).length,\n },\n });\n }\n\n return {\n success: true,\n values: {\n emails: emails,\n total: emailList.emails.length,\n limit: emailList.limit,\n offset: emailList.offset,\n },\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n logger.error(\"Failed to get emails\", { error: errorMessage });\n\n if (callback) {\n await callback({\n text: `Failed to get emails: ${errorMessage}`,\n values: {\n success: false,\n error: errorMessage,\n },\n });\n }\n\n return {\n success: false,\n error: errorMessage,\n };\n }\n },\n validate: async (runtime: IAgentRuntime) => {\n try {\n const service = runtime.getService<AgentMBoxService>(\"agentmbox\");\n return !!service;\n } catch {\n return false;\n }\n },\n examples: [\n [\n {\n name: \"user\",\n content: \"Check my inbox for any new emails\",\n },\n {\n name: \"assistant\",\n content: \"Let me check your inbox for new emails.\",\n },\n ],\n [\n {\n name: \"user\",\n content: \"Show me the last 5 emails I received\",\n },\n {\n name: \"assistant\",\n content: \"I'll retrieve your recent emails.\",\n },\n ],\n [\n {\n name: \"user\",\n content: \"Get the details of that email about the meeting\",\n },\n {\n name: \"assistant\",\n content: \"Let me fetch that email for you.\",\n },\n ],\n ] as ActionExample[][],\n};\n\nexport default getEmailsAction;\n","/**\n * Email Provider\n * Provides email context to the agent, including unread counts and recent emails\n */\n\nimport {\n type Provider,\n type IAgentRuntime,\n type Memory,\n type State,\n type ProviderResult,\n} from \"@elizaos/core\";\nimport { AgentMBoxService } from \"../services/AgentMBoxService\";\n\nexport const emailProvider: Provider = {\n name: \"email\",\n description: \"Provides email context from AgentMBox including unread counts and recent messages\",\n get: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state: State\n ): Promise<ProviderResult> => {\n try {\n const service = runtime.getService<AgentMBoxService>(\"agentmbox\");\n if (!service) {\n return {\n text: \"Email service not available\",\n values: {\n available: false,\n },\n };\n }\n\n // Get recent emails\n const emailList = await service.listEmails(10, 0);\n const unreadCount = emailList.emails.filter((e) => !e.isRead).length;\n const recentEmails = emailList.emails.slice(0, 5);\n\n // Format recent emails for context\n const recentEmailsText = recentEmails\n .map(\n (email) =>\n `- From: ${email.from[0]?.name || email.from[0]?.email || \"Unknown\"} | Subject: ${email.subject}${\n !email.isRead ? \" [UNREAD]\" : \"\"\n }`\n )\n .join(\"\\n\");\n\n return {\n text: `Email Status: ${unreadCount} unread of ${emailList.emails.length} total${\n recentEmails.length > 0\n ? `\\n\\nRecent Emails:\\n${recentEmailsText}`\n : \"\\n\\nNo recent emails.\"\n }`,\n values: {\n available: true,\n unreadCount,\n totalEmails: emailList.emails.length,\n recentEmails: recentEmails.map((e) => ({\n id: e.id,\n from: e.from[0],\n subject: e.subject,\n preview: e.preview,\n isRead: e.isRead,\n receivedAt: e.receivedAt,\n })),\n },\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n return {\n text: `Email service error: ${errorMessage}`,\n values: {\n available: false,\n error: errorMessage,\n },\n };\n }\n },\n};\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OAAO,UAAU,sBACjB,OAAO,gBACP;AACA,YAAAA,QAAO;AAAA,cACL,oCAAoC,OAAO;AAAA,YAC7C;AACA,YAAAA,QAAO,KAAK,iDAAiD;AAAA,UAC/D;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,cAAM,WACJ,iBAAiB,QAAQ,MAAM,UAAU;AAC3C,QAAAA,QAAO,MAAM,wBAAwB,QAAQ;AAAA,MAC/C;AAAA,IACF,WAAW,gBAAgB;AACzB,MAAAA,QAAO,KAAK,wCAAwC;AAAA,IACtD,OAAO;AACL,MAAAA,QAAO,KAAK,sCAAsC;AAAA,IACpD;AAGA,UAAM,eAAe,QAAQ,WAA6B,WAAW;AACrE,QAAI,cAAc;AAChB,UAAI;AACF,cAAM,aAAa,WAAW,OAAO;AAAA,MACvC,SAAS,OAAO;AACd,cAAM,WACJ,iBAAiB,QAAQ,MAAM,UAAU;AAC3C,QAAAA,QAAO;AAAA,UACL,mDAAmD;AAAA,QACrD;AAAA,MAEF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":["logger","logger","logger","Service","logger","logger"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/services/AgentMBoxService.ts","../src/types/index.ts","../src/services/AgentMBoxOnboardingService.ts","../src/actions/sendEmail.ts","../src/actions/getEmails.ts","../src/actions/onboarding.ts","../src/providers/emailProvider.ts"],"sourcesContent":["/**\n * AgentMBox Plugin for ElizaOS\n * Email integration plugin that enables AI agents to send and receive emails\n * Includes autonomous self-onboarding using the agent's Solana wallet\n */\n\nimport type { Plugin, IAgentRuntime } from \"@elizaos/core\";\nimport { logger } from \"@elizaos/core\";\nimport { AgentMBoxService } from \"./services/AgentMBoxService\";\nimport { AgentMBoxOnboardingService } from \"./services/AgentMBoxOnboardingService\";\nimport { sendEmailAction } from \"./actions/sendEmail\";\nimport { getEmailsAction } from \"./actions/getEmails\";\nimport { onboardingAction } from \"./actions/onboarding\";\nimport { emailProvider } from \"./providers/emailProvider\";\n\nexport const agentMBoxPlugin: Plugin = {\n name: \"agentmbox\",\n description:\n \"AgentMBox email integration plugin for ElizaOS - enables AI agents to send/receive emails with autonomous onboarding\",\n priority: 0,\n config: {\n baseUrl: \"https://agentmbox.com/api/v1\",\n },\n actions: [sendEmailAction, getEmailsAction, onboardingAction],\n providers: [emailProvider],\n services: [AgentMBoxService, AgentMBoxOnboardingService],\n init: async (config: Record<string, string>, runtime: IAgentRuntime) => {\n logger.info(\"AgentMBox plugin initializing\");\n\n // Check if onboarding is needed\n const existingApiKey = runtime.getSetting(\"AGENTMBOX_API_KEY\");\n const skipOnboarding =\n runtime.getSetting(\"AGENTMBOX_SKIP_ONBOARDING\") === \"true\";\n\n if (!existingApiKey && !skipOnboarding) {\n logger.info(\"Starting AgentMBox autonomous onboarding...\");\n\n try {\n const onboardingService =\n runtime.getService<AgentMBoxOnboardingService>(\n \"agentmbox-onboarding\",\n );\n if (onboardingService) {\n const status = await onboardingService.startOnboarding(runtime);\n\n if (status.stage === \"complete\" && status.mailbox) {\n // Save credentials to runtime settings for persistence\n const apiKey = onboardingService.getApiKey();\n const mailbox = onboardingService.getMailbox();\n if (apiKey) {\n runtime.setSetting(\"AGENTMBOX_API_KEY\", apiKey, true);\n }\n if (mailbox) {\n runtime.setSetting(\"AGENTMBOX_MAILBOX\", mailbox);\n }\n logger.info(\"Onboarding complete! Mailbox: \" + status.mailbox);\n } else if (\n status.stage === \"awaiting_payment\" &&\n status.paymentAddress\n ) {\n logger.warn(\n \"Payment required. Please fund: \" + status.paymentAddress,\n );\n logger.info(\"Required: 5 USDC on Solana + ~0.01 SOL for fees\");\n }\n }\n } catch (error) {\n const errorMsg =\n error instanceof Error ? error.message : \"Unknown error\";\n logger.error(\"Onboarding failed: \" + errorMsg);\n }\n } else if (existingApiKey) {\n logger.info(\"Using existing AgentMBox configuration\");\n } else {\n logger.info(\"Onboarding skipped per configuration\");\n }\n\n // Initialize main email service (after onboarding has potentially saved credentials)\n const emailService = runtime.getService<AgentMBoxService>(\"agentmbox\");\n if (emailService) {\n try {\n await emailService.initialize(runtime);\n } catch (error) {\n const errorMsg =\n error instanceof Error ? error.message : \"Unknown error\";\n logger.error(\n \"Failed to initialize AgentMBox email service: \" + errorMsg,\n );\n // Don't fail the whole plugin initialization - the service will be unavailable\n }\n }\n },\n};\n\nexport default agentMBoxPlugin;\n\n// Re-export for convenience\nexport { AgentMBoxService } from \"./services/AgentMBoxService\";\nexport { AgentMBoxOnboardingService } from \"./services/AgentMBoxOnboardingService\";\nexport * from \"./types\";\n","import { Service, type IAgentRuntime, logger } from \"@elizaos/core\";\nimport {\n type AgentMBoxConfig,\n type EmailListResponse,\n type EmailDetailResponse,\n type SendEmailRequest,\n type SendEmailResponse,\n type MailboxListResponse,\n type CreateMailboxRequest,\n type CreateMailboxResponse,\n type PaymentStatus,\n type PaymentCheckResponse,\n type DomainListResponse,\n type DomainResponse,\n type DomainVerifyResponse,\n type ApiKeyResponse,\n isAgentMBoxError,\n} from \"../types\";\n\nexport class AgentMBoxService extends Service {\n private apiKey: string = \"\";\n private mailbox: string | undefined;\n private baseUrl: string = \"https://agentmbox.com/api/v1\";\n\n static serviceName = \"agentmbox\" as const;\n\n constructor(runtime?: IAgentRuntime) {\n super(runtime!);\n }\n\n get serviceName(): string {\n return AgentMBoxService.serviceName;\n }\n\n get capabilityDescription(): string {\n return \"AgentMBox email service - allows sending and receiving emails\";\n }\n\n async initialize(runtime: IAgentRuntime): Promise<void> {\n const apiKey = String(runtime.getSetting(\"AGENTMBOX_API_KEY\") || \"\");\n const mailbox = String(runtime.getSetting(\"AGENTMBOX_MAILBOX\") || \"\");\n const baseUrl = String(runtime.getSetting(\"AGENTMBOX_BASE_URL\") || \"\");\n\n // API key will be set by onboarding if not provided\n // The service will work once onboarding completes\n if (apiKey && !apiKey.startsWith(\"ai_\")) {\n logger.warn(\"AgentMBox API key should start with 'ai_'\");\n }\n\n const agentName =\n runtime.character?.name?.toLowerCase().replace(/\\s+/g, \"-\") || \"agent\";\n const defaultMailbox = mailbox || `${agentName}@agentmbox.com`;\n\n this.apiKey = apiKey;\n this.mailbox = defaultMailbox;\n this.baseUrl = baseUrl || \"https://agentmbox.com/api/v1\";\n this.runtime = runtime;\n\n if (!this.apiKey.startsWith(\"ai_\")) {\n logger.warn(\"AgentMBox API key should start with 'ai_'\");\n }\n\n logger.info(\"AgentMBox service initialized for: \" + this.mailbox);\n }\n\n async stop(): Promise<void> {\n logger.info(\"AgentMBox service stopped\");\n }\n\n private async request<T>(\n endpoint: string,\n options: RequestInit = {},\n ): Promise<T> {\n if (!this.apiKey) {\n throw new Error(\n \"AgentMBox API key not configured. Ensure onboarding has completed or set AGENTMBOX_API_KEY.\",\n );\n }\n\n const url = `${this.baseUrl}${endpoint}`;\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n ...(options.headers as Record<string, string>),\n };\n\n const response = await fetch(url, { ...options, headers });\n const data = await response.json();\n\n if (!response.ok) {\n if (isAgentMBoxError(data)) {\n throw new Error(\n `AgentMBox API error (${response.status}): ${data.error}`,\n );\n }\n throw new Error(`AgentMBox API error: ${response.status}`);\n }\n\n return data as T;\n }\n\n private getMailboxParam(): string {\n if (!this.mailbox) {\n throw new Error(\"Mailbox not configured\");\n }\n return \"?mailbox=\" + encodeURIComponent(this.mailbox);\n }\n\n async listEmails(limit = 50, offset = 0): Promise<EmailListResponse> {\n const mailboxParam = this.getMailboxParam();\n return this.request<EmailListResponse>(\n \"/mail\" + mailboxParam + \"&limit=\" + limit + \"&offset=\" + offset,\n );\n }\n\n async getEmail(emailId: string): Promise<EmailDetailResponse> {\n const mailboxParam = this.getMailboxParam();\n return this.request<EmailDetailResponse>(\"/mail/\" + emailId + mailboxParam);\n }\n\n async sendEmail(request: SendEmailRequest): Promise<SendEmailResponse> {\n const from = request.from || this.mailbox;\n if (!from) {\n throw new Error(\"Sender address not specified\");\n }\n\n return this.request<SendEmailResponse>(\"/mail/send\", {\n method: \"POST\",\n body: JSON.stringify({ ...request, from }),\n });\n }\n\n async deleteEmail(emailId: string): Promise<{ success: boolean }> {\n const mailboxParam = this.getMailboxParam();\n return this.request<{ success: boolean }>(\n \"/mail/\" + emailId + mailboxParam,\n {\n method: \"DELETE\",\n },\n );\n }\n\n async listMailboxes(): Promise<MailboxListResponse> {\n return this.request<MailboxListResponse>(\"/mailboxes\");\n }\n\n async createMailbox(\n request: CreateMailboxRequest,\n ): Promise<CreateMailboxResponse> {\n return this.request<CreateMailboxResponse>(\"/mailboxes\", {\n method: \"POST\",\n body: JSON.stringify(request),\n });\n }\n\n async deleteMailbox(mailboxId: string): Promise<{ success: boolean }> {\n return this.request<{ success: boolean }>(\"/mailboxes/\" + mailboxId, {\n method: \"DELETE\",\n });\n }\n\n async getPaymentStatus(): Promise<PaymentStatus> {\n return this.request<PaymentStatus>(\"/payment\");\n }\n\n async checkPayment(): Promise<PaymentCheckResponse> {\n return this.request<PaymentCheckResponse>(\"/payment/check\", {\n method: \"POST\",\n });\n }\n\n async listDomains(): Promise<DomainListResponse> {\n return this.request<DomainListResponse>(\"/domains\");\n }\n\n async addDomain(domain: string): Promise<DomainResponse> {\n return this.request<DomainResponse>(\"/domains\", {\n method: \"POST\",\n body: JSON.stringify({ domain }),\n });\n }\n\n async verifyDomain(domainId: string): Promise<DomainVerifyResponse> {\n return this.request<DomainVerifyResponse>(\n \"/domains/\" + domainId + \"/verify\",\n {\n method: \"POST\",\n },\n );\n }\n\n async deleteDomain(domainId: string): Promise<{ success: boolean }> {\n return this.request<{ success: boolean }>(\"/domains/\" + domainId, {\n method: \"DELETE\",\n });\n }\n\n async createApiKey(name: string): Promise<ApiKeyResponse> {\n return this.request<ApiKeyResponse>(\"/keys\", {\n method: \"POST\",\n body: JSON.stringify({ name }),\n });\n }\n\n async getStatus(): Promise<{ paid: boolean; paidUntil: string | null }> {\n try {\n const status = await this.getPaymentStatus();\n return { paid: status.paid, paidUntil: status.paidUntil };\n } catch (error) {\n logger.error(\"Failed to get AgentMBox status\");\n return { paid: false, paidUntil: null };\n }\n }\n}\n\nexport default AgentMBoxService;\n","/**\n * AgentMBox Plugin Types\n * TypeScript interfaces for AgentMBox email integration\n */\n\nexport interface AgentMBoxConfig {\n /** API key for AgentMBox (starts with ai_) */\n apiKey: string;\n /** Mailbox address (e.g., my-agent@agentmbox.com) */\n mailbox?: string;\n /** Base URL for AgentMBox API (default: https://agentmbox.com/api/v1) */\n baseUrl?: string;\n}\n\nexport interface EmailAddress {\n name?: string;\n email: string;\n}\n\nexport interface Email {\n id: string;\n from: EmailAddress[];\n to: EmailAddress[];\n cc?: EmailAddress[] | null;\n subject: string;\n receivedAt: string;\n textBody?: string;\n htmlBody?: string;\n preview?: string;\n hasAttachment: boolean;\n isRead: boolean;\n}\n\nexport interface EmailListResponse {\n mailbox: string;\n emails: Email[];\n limit: number;\n offset: number;\n}\n\nexport interface EmailDetailResponse {\n email: Email;\n}\n\nexport interface SendEmailRequest {\n /** Sender address (must be a mailbox you own) */\n from: string;\n /** Recipient(s) - single email or array */\n to: string | string[];\n /** Email subject line */\n subject: string;\n /** Plain text body */\n text?: string;\n /** HTML body */\n html?: string;\n}\n\nexport interface SendEmailResponse {\n success: boolean;\n}\n\nexport interface Mailbox {\n id: string;\n address: string;\n localPart: string;\n domainName: string;\n displayName?: string | null;\n password?: string; // Only shown at creation\n createdAt: string;\n}\n\nexport interface MailboxListResponse {\n mailboxes: Mailbox[];\n}\n\nexport interface CreateMailboxRequest {\n localPart: string;\n domainId?: string;\n displayName?: string;\n}\n\nexport interface CreateMailboxResponse {\n mailbox: Mailbox;\n}\n\nexport interface PaymentStatus {\n paid: boolean;\n paidUntil: string | null;\n solanaAddress: string;\n usdcPerPeriod: number;\n periodDays: number;\n creditedUsdc: number;\n payments: unknown[];\n}\n\nexport interface PaymentCheckResponse {\n paid: boolean;\n paidUntil: string;\n newCredits: number;\n balanceUsdc: number;\n creditedUsdc: number;\n}\n\nexport interface Domain {\n id: string;\n domain: string;\n verified: boolean;\n}\n\nexport interface DomainDNSRecords {\n verification: { type: string; name: string; value: string };\n mx: { type: string; name: string; value: string; priority: number };\n spf: { type: string; name: string; value: string };\n dkim: { type: string; name: string; value: string };\n}\n\nexport interface DomainResponse {\n domain: Domain;\n dnsRecords: DomainDNSRecords;\n}\n\nexport interface DomainVerifyResponse {\n verified: boolean;\n txtVerified: boolean;\n mxVerified: boolean;\n spfVerified: boolean;\n dkimVerified: boolean;\n}\n\nexport interface DomainListResponse {\n domains: (Domain & { dnsRecords?: DomainDNSRecords })[];\n}\n\nexport interface ApiKey {\n id: string;\n name: string;\n key: string;\n keyPrefix: string;\n}\n\nexport interface ApiKeyResponse {\n id: string;\n name: string;\n key: string;\n keyPrefix: string;\n}\n\nexport interface ApiKeyListResponse {\n keys: ApiKey[];\n}\n\nexport interface AgentMBoxError {\n error: string;\n}\n\nexport type AgentMBoxErrorCode = 400 | 401 | 402 | 403 | 404 | 409 | 502;\n\nexport function isAgentMBoxError(\n response: unknown,\n): response is AgentMBoxError {\n return (\n typeof response === \"object\" &&\n response !== null &&\n \"error\" in response &&\n typeof (response as AgentMBoxError).error === \"string\"\n );\n}\n","/**\n * AgentMBox Onboarding Service\n * Handles autonomous account creation and setup for AgentMBox\n * The agent pays for its own subscription using its Solana wallet\n */\n\nimport { Service, type IAgentRuntime, logger } from \"@elizaos/core\";\nimport {\n type PaymentStatus,\n type PaymentCheckResponse,\n type ApiKeyResponse,\n type Mailbox,\n} from \"../types\";\n\nexport interface OnboardingStatus {\n stage:\n | \"pending\"\n | \"account_created\"\n | \"api_key_created\"\n | \"awaiting_payment\"\n | \"paid\"\n | \"mailbox_created\"\n | \"complete\"\n | \"error\";\n paymentAddress?: string;\n mailbox?: string;\n error?: string;\n}\n\nexport class AgentMBoxOnboardingService extends Service {\n private apiKey: string = \"\";\n private mailbox: string | undefined;\n private baseUrl: string = \"https://agentmbox.com/api/v1\";\n private cfg: {\n ownerEmail: string;\n password: string;\n mailboxLocalPart: string;\n } | null = null;\n private status: OnboardingStatus = { stage: \"pending\" };\n\n static serviceName = \"agentmbox-onboarding\" as const;\n\n constructor(runtime?: IAgentRuntime) {\n super(runtime!);\n }\n\n get serviceName(): string {\n return AgentMBoxOnboardingService.serviceName;\n }\n\n get capabilityDescription(): string {\n return \"AgentMBox autonomous onboarding - creates account, pays for subscription, sets up mailbox\";\n }\n\n getApiKey(): string {\n return this.apiKey;\n }\n\n getMailbox(): string | undefined {\n return this.mailbox;\n }\n\n private generatePassword(length: number = 32): string {\n const chars =\n \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*\";\n let password = \"\";\n const array = new Uint8Array(length);\n crypto.getRandomValues(array);\n for (let i = 0; i < length; i++) {\n password += chars[array[i] % chars.length];\n }\n return password;\n }\n\n private async getAgentWallet(): Promise<{\n publicKey: string;\n privateKey: Uint8Array;\n } | null> {\n if (!this.runtime) return null;\n\n try {\n const privateKeyBase58 = String(\n this.runtime.getSetting(\"SOLANA_PRIVATE_KEY\") || \"\",\n );\n if (privateKeyBase58) {\n const { default: bs58 } = await import(\"bs58\");\n const { Keypair } = await import(\"@solana/web3.js\");\n const privateKey = bs58.decode(privateKeyBase58);\n const keypair = Keypair.fromSecretKey(privateKey);\n return {\n publicKey: keypair.publicKey.toBase58(),\n privateKey,\n };\n }\n\n const walletService = await this.runtime.getService(\"wallet\");\n if (walletService) {\n const keypair = await (walletService as any).getKeypair?.();\n if (keypair) {\n return {\n publicKey: keypair.publicKey.toBase58(),\n privateKey: keypair.secretKey,\n };\n }\n }\n } catch (error) {\n logger.warn(\"Could not get agent wallet\");\n }\n\n return null;\n }\n\n private async request<T>(\n endpoint: string,\n options: RequestInit = {},\n ): Promise<T> {\n const url = `${this.baseUrl}${endpoint}`;\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...(options.headers as Record<string, string>),\n };\n\n const response = await fetch(url, { ...options, headers });\n const data = await response.json();\n\n if (!response.ok) {\n const error = (data as { error?: string }).error || `${response.status}`;\n throw new Error(error);\n }\n\n return data as T;\n }\n\n private async authenticatedRequest<T>(\n endpoint: string,\n options: RequestInit = {},\n ): Promise<T> {\n if (!this.apiKey) {\n throw new Error(\"API key not set\");\n }\n\n const url = `${this.baseUrl}${endpoint}`;\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n ...(options.headers as Record<string, string>),\n };\n\n const response = await fetch(url, { ...options, headers });\n const data = await response.json();\n\n if (!response.ok) {\n const error = (data as { error?: string }).error || `${response.status}`;\n throw new Error(error);\n }\n\n return data as T;\n }\n\n async startOnboarding(runtime: IAgentRuntime): Promise<OnboardingStatus> {\n this.runtime = runtime;\n\n const existingApiKey = String(\n runtime.getSetting(\"AGENTMBOX_API_KEY\") || \"\",\n );\n if (existingApiKey && existingApiKey.startsWith(\"ai_\")) {\n this.apiKey = existingApiKey;\n return await this.checkExistingSetup();\n }\n\n const agentName =\n runtime.character?.name?.toLowerCase().replace(/\\s+/g, \"-\") || \"agent\";\n const mailboxSetting = String(\n runtime.getSetting(\"AGENTMBOX_MAILBOX\") || \"\",\n );\n this.cfg = {\n ownerEmail:\n String(runtime.getSetting(\"AGENTMBOX_OWNER_EMAIL\")) ||\n `agent-${agentName}@owner.local`,\n password: this.generatePassword(32),\n mailboxLocalPart: mailboxSetting\n ? mailboxSetting.split(\"@\")[0]\n : agentName,\n };\n\n try {\n // Step 1: Create account\n await this.createAccount();\n this.status = { stage: \"account_created\" };\n logger.info(\"AgentMBox account created\");\n\n // Step 2: Create API key\n const apiKeyResponse = await this.createApiKey(agentName);\n this.apiKey = apiKeyResponse.key;\n this.status = { stage: \"api_key_created\" };\n logger.info(\"AgentMBox API key created\");\n\n // Step 3: Get payment address\n const payment = await this.getPaymentStatus();\n this.status = {\n stage: \"awaiting_payment\",\n paymentAddress: payment.solanaAddress,\n };\n logger.info(\"Payment address: \" + payment.solanaAddress);\n\n // Step 4: Pay for subscription\n await this.payForSubscription(payment.solanaAddress, runtime);\n this.status = { stage: \"paid\" };\n logger.info(\"Payment completed\");\n\n // Step 5: Create mailbox\n const mailbox = await this.createMailbox(this.cfg!.mailboxLocalPart);\n this.mailbox = mailbox.address;\n this.status = {\n stage: \"complete\",\n mailbox: mailbox.address,\n };\n logger.info(\"Mailbox created: \" + mailbox.address);\n\n return this.status;\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : \"Unknown error\";\n logger.error(\"AgentMBox onboarding failed: \" + errorMsg);\n this.status = { stage: \"error\", error: errorMsg };\n throw error;\n }\n }\n\n private async checkExistingSetup(): Promise<OnboardingStatus> {\n try {\n const payment = await this.getPaymentStatus();\n\n if (payment.paid) {\n const mailbox = await this.getOrCreateMailbox();\n this.status = mailbox\n ? { stage: \"complete\", mailbox: mailbox.address }\n : { stage: \"paid\" };\n } else {\n const wallet = await this.getAgentWallet();\n if (wallet && this.runtime) {\n await this.payForSubscription(payment.solanaAddress, this.runtime);\n this.status = { stage: \"paid\" };\n const mailbox = await this.getOrCreateMailbox();\n if (mailbox) {\n this.status = { stage: \"complete\", mailbox: mailbox.address };\n }\n } else {\n this.status = {\n stage: \"awaiting_payment\",\n paymentAddress: payment.solanaAddress,\n };\n }\n }\n } catch (error) {\n logger.warn(\"Could not check existing setup\");\n this.status = { stage: \"pending\" };\n }\n\n return this.status;\n }\n\n private async payForSubscription(\n paymentAddress: string,\n runtime: IAgentRuntime,\n ): Promise<void> {\n const wallet = await this.getAgentWallet();\n\n if (!wallet) {\n logger.warn(\"No agent wallet found, waiting for manual payment\");\n await this.waitForPayment();\n return;\n }\n\n logger.info(\"Using agent wallet to pay for subscription\");\n\n try {\n const { Connection, Keypair } = await import(\"@solana/web3.js\");\n const { transfer, getOrCreateAssociatedTokenAccount } =\n await import(\"@solana/spl-token\");\n\n const connection = new Connection(\"https://api.mainnet-beta.solana.com\");\n const signer = Keypair.fromSecretKey(wallet.privateKey);\n\n const usdcMintStr = \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGZwyTDt1v\";\n const { PublicKey } = await import(\"@solana/web3.js\");\n const usdcMint = new PublicKey(usdcMintStr);\n const toPublicKey = new PublicKey(paymentAddress);\n\n const fromTokenAccount = await getOrCreateAssociatedTokenAccount(\n connection,\n signer,\n usdcMint,\n signer.publicKey,\n );\n\n const toTokenAccount = await getOrCreateAssociatedTokenAccount(\n connection,\n signer,\n usdcMint,\n toPublicKey,\n );\n\n const amount = 5_000_000;\n\n await transfer(\n connection,\n signer,\n fromTokenAccount.address,\n toTokenAccount.address,\n signer.publicKey,\n amount,\n );\n\n logger.info(\"USDC transfer complete\");\n await this.waitForPayment();\n } catch (error) {\n logger.error(\"Failed to transfer USDC, waiting for manual payment\");\n await this.waitForPayment();\n }\n }\n\n async stop(): Promise<void> {\n logger.info(\"AgentMBox onboarding service stopped\");\n }\n\n private async createAccount(): Promise<void> {\n if (!this.cfg) throw new Error(\"Config not set\");\n\n const response = await this.request<{ id: string }>(\"/auth/signup\", {\n method: \"POST\",\n body: JSON.stringify({\n email: this.cfg.ownerEmail,\n password: this.cfg.password,\n }),\n });\n\n logger.info(\"Account created: \" + response.id);\n }\n\n private async createApiKey(name: string): Promise<ApiKeyResponse> {\n const response = await this.request<ApiKeyResponse>(\"/keys\", {\n method: \"POST\",\n body: JSON.stringify({ name }),\n });\n\n logger.info(\"API key created: \" + response.key.substring(0, 12) + \"...\");\n return response;\n }\n\n private async getPaymentStatus(): Promise<PaymentStatus> {\n return this.authenticatedRequest<PaymentStatus>(\"/payment\");\n }\n\n private async waitForPayment(\n maxAttempts: number = 60,\n intervalMs: number = 5000,\n ): Promise<PaymentCheckResponse> {\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n const result = await this.authenticatedRequest<PaymentCheckResponse>(\n \"/payment/check\",\n {\n method: \"POST\",\n },\n );\n\n if (result.paid) {\n return result;\n }\n\n logger.info(\n \"Waiting for payment... (\" + attempt + \"/\" + maxAttempts + \")\",\n );\n } catch (e) {\n logger.warn(\n \"Payment check failed: \" +\n (e instanceof Error ? e.message : \"unknown\"),\n );\n }\n\n if (attempt < maxAttempts) {\n await new Promise((resolve) => setTimeout(resolve, intervalMs));\n }\n }\n\n throw new Error(\"Payment not received after \" + maxAttempts + \" attempts\");\n }\n\n private async createMailbox(localPart: string): Promise<Mailbox> {\n const response = await this.authenticatedRequest<{ mailbox: Mailbox }>(\n \"/mailboxes\",\n {\n method: \"POST\",\n body: JSON.stringify({\n localPart,\n displayName: this.cfg?.mailboxLocalPart || \"Agent Mailbox\",\n }),\n },\n );\n\n return response.mailbox;\n }\n\n async getOrCreateMailbox(): Promise<Mailbox | null> {\n try {\n const response = await this.authenticatedRequest<{\n mailboxes: Mailbox[];\n }>(\"/mailboxes\");\n\n if (response.mailboxes.length > 0) {\n return response.mailboxes[0];\n }\n\n if (this.cfg?.mailboxLocalPart) {\n return await this.createMailbox(this.cfg.mailboxLocalPart);\n }\n\n return null;\n } catch (error) {\n logger.error(\"Failed to get/create mailbox\");\n return null;\n }\n }\n\n getStatus(): OnboardingStatus {\n return this.status;\n }\n\n async getPaymentAddress(): Promise<string | null> {\n if (this.status.paymentAddress) {\n return this.status.paymentAddress;\n }\n\n try {\n const payment = await this.getPaymentStatus();\n return payment.solanaAddress;\n } catch {\n return null;\n }\n }\n\n isOnboardingComplete(): boolean {\n return this.status.stage === \"complete\";\n }\n}\n\nexport default AgentMBoxOnboardingService;\n","/**\n * Send Email Action\n * Allows the agent to send emails via AgentMBox\n */\n\nimport {\n type Action,\n type HandlerCallback,\n type IAgentRuntime,\n type Memory,\n type State,\n type ActionExample,\n} from \"@elizaos/core\";\nimport { AgentMBoxService } from \"../services/AgentMBoxService\";\n\nexport const sendEmailAction: Action = {\n name: \"SEND_EMAIL\",\n description: \"Send an email to a recipient using AgentMBox email service\",\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n state: State,\n options: Record<string, unknown>,\n callback?: HandlerCallback\n ) => {\n const service = runtime.getService<AgentMBoxService>(\"agentmbox\");\n if (!service) {\n throw new Error(\"AgentMBox service not initialized\");\n }\n\n const { to, subject, text, html } = options;\n\n if (!to) {\n throw new Error(\"Missing required field: 'to' (recipient email)\");\n }\n\n if (!subject) {\n throw new Error(\"Missing required field: 'subject'\");\n }\n\n const from = options.from as string | undefined;\n\n try {\n const result = await service.sendEmail({\n from,\n to: Array.isArray(to) ? to : to,\n subject,\n text: text as string | undefined,\n html: html as string | undefined,\n });\n\n if (callback) {\n await callback({\n text: `Email sent successfully to ${to}`,\n values: {\n success: result.success,\n recipient: to,\n subject,\n },\n });\n }\n\n return {\n success: true,\n values: {\n sentTo: to,\n subject,\n },\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n logger.error(\"Failed to send email\", { error: errorMessage });\n\n if (callback) {\n await callback({\n text: `Failed to send email: ${errorMessage}`,\n values: {\n success: false,\n error: errorMessage,\n },\n });\n }\n\n return {\n success: false,\n error: errorMessage,\n };\n }\n },\n validate: async (runtime: IAgentRuntime) => {\n try {\n const service = runtime.getService<AgentMBoxService>(\"agentmbox\");\n return !!service;\n } catch {\n return false;\n }\n },\n examples: [\n [\n {\n name: \"user\",\n content: \"Send an email to john@example.com about the project update\",\n },\n {\n name: \"assistant\",\n content: \"I'll send that email for you.\",\n },\n ],\n [\n {\n name: \"user\",\n content: \"Email the team that the meeting is at 3pm\",\n },\n {\n name: \"assistant\",\n content: \"Sending that email now.\",\n },\n ],\n [\n {\n name: \"user\",\n content: \"Can you notify alice@example.com that the report is ready?\",\n },\n {\n name: \"assistant\",\n content: \"I'll send her an email right away.\",\n },\n ],\n ] as ActionExample[][],\n};\n\nexport default sendEmailAction;\n","/**\n * Get Emails Action\n * Allows the agent to retrieve emails from the mailbox via AgentMBox\n */\n\nimport {\n type Action,\n type HandlerCallback,\n type IAgentRuntime,\n type Memory,\n type State,\n type ActionExample,\n} from \"@elizaos/core\";\nimport { AgentMBoxService } from \"../services/AgentMBoxService\";\n\nexport const getEmailsAction: Action = {\n name: \"GET_EMAILS\",\n description: \"Retrieve emails from the AgentMBox mailbox. Can filter by read status and limit results.\",\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n state: State,\n options: Record<string, unknown>,\n callback?: HandlerCallback\n ) => {\n const service = runtime.getService<AgentMBoxService>(\"agentmbox\");\n if (!service) {\n throw new Error(\"AgentMBox service not initialized\");\n }\n\n const limit = (options.limit as number) || 10;\n const offset = (options.offset as number) || 0;\n const emailId = options.emailId as string | undefined;\n\n try {\n // If emailId is provided, get a specific email\n if (emailId) {\n const emailDetail = await service.getEmail(emailId);\n\n if (callback) {\n await callback({\n text: `Retrieved email: ${emailDetail.email.subject}`,\n values: {\n email: emailDetail.email,\n },\n });\n }\n\n return {\n success: true,\n values: {\n email: emailDetail.email,\n },\n };\n }\n\n // Otherwise, list emails\n const emailList = await service.listEmails(limit, offset);\n\n // Filter by read status if specified\n let emails = emailList.emails;\n const unreadOnly = options.unreadOnly as boolean;\n if (unreadOnly) {\n emails = emails.filter((email) => !email.isRead);\n }\n\n if (callback) {\n const preview = emails\n .slice(0, 5)\n .map((e) => `- ${e.subject} from ${e.from[0]?.email}`)\n .join(\"\\n\");\n await callback({\n text: `Found ${emails.length} emails:\\n${preview}`,\n values: {\n emails: emails,\n total: emailList.emails.length,\n unread: emailList.emails.filter((e) => !e.isRead).length,\n },\n });\n }\n\n return {\n success: true,\n values: {\n emails: emails,\n total: emailList.emails.length,\n limit: emailList.limit,\n offset: emailList.offset,\n },\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n logger.error(\"Failed to get emails\", { error: errorMessage });\n\n if (callback) {\n await callback({\n text: `Failed to get emails: ${errorMessage}`,\n values: {\n success: false,\n error: errorMessage,\n },\n });\n }\n\n return {\n success: false,\n error: errorMessage,\n };\n }\n },\n validate: async (runtime: IAgentRuntime) => {\n try {\n const service = runtime.getService<AgentMBoxService>(\"agentmbox\");\n return !!service;\n } catch {\n return false;\n }\n },\n examples: [\n [\n {\n name: \"user\",\n content: \"Check my inbox for any new emails\",\n },\n {\n name: \"assistant\",\n content: \"Let me check your inbox for new emails.\",\n },\n ],\n [\n {\n name: \"user\",\n content: \"Show me the last 5 emails I received\",\n },\n {\n name: \"assistant\",\n content: \"I'll retrieve your recent emails.\",\n },\n ],\n [\n {\n name: \"user\",\n content: \"Get the details of that email about the meeting\",\n },\n {\n name: \"assistant\",\n content: \"Let me fetch that email for you.\",\n },\n ],\n ] as ActionExample[][],\n};\n\nexport default getEmailsAction;\n","/**\n * Onboarding Action\n * Allows the agent to self-onboard with AgentMBox - creates account, pays for subscription, sets up mailbox\n */\n\nimport {\n type Action,\n type HandlerCallback,\n type IAgentRuntime,\n type Memory,\n type State,\n type ActionExample,\n logger,\n} from \"@elizaos/core\";\nimport { AgentMBoxOnboardingService } from \"../services/AgentMBoxOnboardingService\";\n\nexport const onboardingAction: Action = {\n name: \"AGENTMBOX_ONBOARDING\",\n description:\n \"Set up AgentMBox email for the agent - creates an account, pays 5 USDC on Solana, and creates a mailbox. The agent needs a Solana wallet with USDC to pay for the subscription.\",\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n state: State,\n _options: Record<string, unknown>,\n callback?: HandlerCallback,\n ) => {\n const onboardingService = runtime.getService<AgentMBoxOnboardingService>(\n \"agentmbox-onboarding\",\n );\n\n if (!onboardingService) {\n const errorMsg = \"AgentMBox onboarding service not initialized\";\n logger.error(errorMsg);\n if (callback) {\n await callback({\n text: errorMsg,\n values: { success: false, error: errorMsg },\n });\n }\n return { success: false, error: errorMsg };\n }\n\n // Check if already onboarded\n if (onboardingService.isOnboardingComplete()) {\n const mailbox = onboardingService.getMailbox();\n const msg = `Already onboarded! Mailbox: ${mailbox}`;\n logger.info(msg);\n if (callback) {\n await callback({\n text: msg,\n values: { success: true, mailbox },\n });\n }\n return { success: true, mailbox };\n }\n\n try {\n logger.info(\"Starting AgentMBox onboarding...\");\n const status = await onboardingService.startOnboarding(runtime);\n\n if (callback) {\n await callback({\n text: `Onboarding ${status.stage}: ${\n status.mailbox || status.paymentAddress || status.error || \"\"\n }`,\n values: {\n success: status.stage === \"complete\",\n stage: status.stage,\n mailbox: status.mailbox,\n paymentAddress: status.paymentAddress,\n error: status.error,\n },\n });\n }\n\n if (status.stage === \"complete\" && status.mailbox) {\n // Save credentials to runtime settings\n const apiKey = onboardingService.getApiKey();\n const mailbox = onboardingService.getMailbox();\n if (apiKey) {\n runtime.setSetting(\"AGENTMBOX_API_KEY\", apiKey, true);\n }\n if (mailbox) {\n runtime.setSetting(\"AGENTMBOX_MAILBOX\", mailbox);\n }\n logger.info(\"Onboarding complete! Mailbox: \" + status.mailbox);\n return { success: true, mailbox: status.mailbox };\n } else if (status.stage === \"awaiting_payment\" && status.paymentAddress) {\n const msg =\n \"Payment required! Please send 5 USDC to: \" + status.paymentAddress;\n logger.warn(msg);\n return {\n success: false,\n stage: status.stage,\n paymentAddress: status.paymentAddress,\n message: msg,\n };\n } else if (status.stage === \"error\") {\n const errorMsg = \"Onboarding failed: \" + status.error;\n logger.error(errorMsg);\n return { success: false, error: status.error };\n }\n\n return { success: true, stage: status.stage };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n logger.error(\"Onboarding failed: \" + errorMessage);\n\n if (callback) {\n await callback({\n text: \"Onboarding failed: \" + errorMessage,\n values: { success: false, error: errorMessage },\n });\n }\n\n return { success: false, error: errorMessage };\n }\n },\n validate: async (runtime: IAgentRuntime) => {\n try {\n const service = runtime.getService<AgentMBoxOnboardingService>(\n \"agentmbox-onboarding\",\n );\n return !!service;\n } catch {\n return false;\n }\n },\n examples: [\n [\n {\n name: \"user\",\n content: \"Set up email for this agent\",\n },\n {\n name: \"assistant\",\n content:\n \"I'll set up AgentMBox email for you. This will create an account and pay 5 USDC from the agent's wallet.\",\n },\n ],\n [\n {\n name: \"user\",\n content: \"I need to configure the email service\",\n },\n {\n name: \"assistant\",\n content: \"Starting the AgentMBox onboarding process now.\",\n },\n ],\n [\n {\n name: \"user\",\n content: \"Can you set up a mailbox for receiving emails?\",\n },\n {\n name: \"assistant\",\n content: \"On it! I'll create the mailbox and handle the payment.\",\n },\n ],\n ] as ActionExample[][],\n};\n\nexport default onboardingAction;\n","/**\n * Email Provider\n * Provides email context to the agent, including unread counts and recent emails\n */\n\nimport {\n type Provider,\n type IAgentRuntime,\n type Memory,\n type State,\n type ProviderResult,\n} from \"@elizaos/core\";\nimport { AgentMBoxService } from \"../services/AgentMBoxService\";\n\nexport const emailProvider: Provider = {\n name: \"email\",\n description: \"Provides email context from AgentMBox including unread counts and recent messages\",\n get: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state: State\n ): Promise<ProviderResult> => {\n try {\n const service = runtime.getService<AgentMBoxService>(\"agentmbox\");\n if (!service) {\n return {\n text: \"Email service not available\",\n values: {\n available: false,\n },\n };\n }\n\n // Get recent emails\n const emailList = await service.listEmails(10, 0);\n const unreadCount = emailList.emails.filter((e) => !e.isRead).length;\n const recentEmails = emailList.emails.slice(0, 5);\n\n // Format recent emails for context\n const recentEmailsText = recentEmails\n .map(\n (email) =>\n `- From: ${email.from[0]?.name || email.from[0]?.email || \"Unknown\"} | Subject: ${email.subject}${\n !email.isRead ? \" [UNREAD]\" : \"\"\n }`\n )\n .join(\"\\n\");\n\n return {\n text: `Email Status: ${unreadCount} unread of ${emailList.emails.length} total${\n recentEmails.length > 0\n ? `\\n\\nRecent Emails:\\n${recentEmailsText}`\n : \"\\n\\nNo recent emails.\"\n }`,\n values: {\n available: true,\n unreadCount,\n totalEmails: emailList.emails.length,\n recentEmails: recentEmails.map((e) => ({\n id: e.id,\n from: e.from[0],\n subject: e.subject,\n preview: e.preview,\n isRead: e.isRead,\n receivedAt: e.receivedAt,\n })),\n },\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n return {\n text: `Email service error: ${errorMessage}`,\n values: {\n available: false,\n error: errorMessage,\n },\n };\n }\n },\n};\n\nexport default emailProvider;\n"],"mappings":";AAOA,SAAS,UAAAA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Q;AAAA,UACN;AAAA,QACF;AACF,YAAI,mBAAmB;AACrB,gBAAM,SAAS,MAAM,kBAAkB,gBAAgB,OAAO;AAE9D,cAAI,OAAO,UAAU,cAAc,OAAO,SAAS;AAEjD,kBAAM,SAAS,kBAAkB,UAAU;AAC3C,kBAAM,UAAU,kBAAkB,WAAW;AAC7C,gBAAI,QAAQ;AACV,sBAAQ,WAAW,qBAAqB,QAAQ,IAAI;AAAA,YACtD;AACA,gBAAI,SAAS;AACX,sBAAQ,WAAW,qBAAqB,OAAO;AAAA,YACjD;AACA,YAAAA,QAAO,KAAK,mCAAmC,OAAO,OAAO;AAAA,UAC/D,WACE,OAAO,UAAU,sBACjB,OAAO,gBACP;AACA,YAAAA,QAAO;AAAA,cACL,oCAAoC,OAAO;AAAA,YAC7C;AACA,YAAAA,QAAO,KAAK,iDAAiD;AAAA,UAC/D;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,cAAM,WACJ,iBAAiB,QAAQ,MAAM,UAAU;AAC3C,QAAAA,QAAO,MAAM,wBAAwB,QAAQ;AAAA,MAC/C;AAAA,IACF,WAAW,gBAAgB;AACzB,MAAAA,QAAO,KAAK,wCAAwC;AAAA,IACtD,OAAO;AACL,MAAAA,QAAO,KAAK,sCAAsC;AAAA,IACpD;AAGA,UAAM,eAAe,QAAQ,WAA6B,WAAW;AACrE,QAAI,cAAc;AAChB,UAAI;AACF,cAAM,aAAa,WAAW,OAAO;AAAA,MACvC,SAAS,OAAO;AACd,cAAM,WACJ,iBAAiB,QAAQ,MAAM,UAAU;AAC3C,QAAAA,QAAO;AAAA,UACL,mDAAmD;AAAA,QACrD;AAAA,MAEF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":["logger","logger","logger","Service","logger","logger","logger"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentmbox/plugin-agentmbox",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "AgentMBox email integration plugin for ElizaOS - enables AI agents to send and receive emails",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",