From ebc1ce0f7aec9f0e66bd52184edeb1ef571cb783 Mon Sep 17 00:00:00 2001 From: huijiro Date: Thu, 16 Oct 2025 16:40:57 -0300 Subject: [PATCH 1/2] Revert "Inbound Stuff + Email send (#196)" This reverts commit af2468e2727ad074781e7796dc0f121786aac3ed. --- src/apis/email.ts | 52 ------------------------- src/io/email.ts | 91 ------------------------------------------- src/types.ts | 10 ----- test/io/email.test.ts | 4 +- 4 files changed, 2 insertions(+), 155 deletions(-) diff --git a/src/apis/email.ts b/src/apis/email.ts index f43c8408..208329be 100644 --- a/src/apis/email.ts +++ b/src/apis/email.ts @@ -4,58 +4,6 @@ import type { EmailService } from '../types'; import { POST } from './api'; export default class EmailApi implements EmailService { - /** - * send an email - */ - async send( - agentId: string, - email: string, - authToken: string, - messageId: string - ): Promise { - const tracer = getTracer(); - const currentContext = context.active(); - - // Create a child span using the current context - const span = tracer.startSpan('agentuity.email.send', {}, currentContext); - - try { - // Create a new context with the child span - const spanContext = trace.setSpan(currentContext, span); - - // Execute the operation within the new context - return await context.with(spanContext, async () => { - span.setAttribute('@agentuity/agentId', agentId); - span.setAttribute('@agentuity/emailMessageId', messageId); - - const resp = await POST( - '/email/send', - email, - { - 'Content-Type': 'message/rfc822', - 'X-Agentuity-Message-Id': messageId, - }, - undefined, - authToken - ); - if (resp.status === 200) { - span.setStatus({ code: SpanStatusCode.OK }); - return; - } - const body = await resp.response.text(); - span.setStatus({ code: SpanStatusCode.ERROR, message: body }); - throw new Error( - `error sending email: ${resp.response.statusText} (${resp.response.status})${body}` - ); - }); - } catch (ex) { - recordException(span, ex); - throw ex; - } finally { - span.end(); - } - } - /** * send an email reply to an incoming email */ diff --git a/src/io/email.ts b/src/io/email.ts index 52c0015a..ad68ddeb 100644 --- a/src/io/email.ts +++ b/src/io/email.ts @@ -459,97 +459,6 @@ export class Email { return ''; } - /** - * Send a new email to the specified recipients. - * - * @param req - The agent request containing metadata with email-auth-token - * @param context - The agent context - * @param to - Array of recipient email addresses - * @param email - The email content (subject, text, html, attachments) - * @param from - Optional sender information (defaults to the recipient of the incoming email) - * @returns Promise resolving to the message ID of the sent email - * @throws Error if email-auth-token is missing, recipients list is empty, or from address is invalid - */ - async send( - req: AgentRequest, - context: AgentContext, - to: string[], - email: EmailReply, - from?: { - name?: string; - email?: string; - } - ): Promise { - const authToken = req.metadata?.['email-auth-token'] as string; - if (!authToken) { - throw new Error( - 'email authorization token is required but not found in metadata' - ); - } - - return (async () => { - let attachments: Attachment[] = []; - if (email.attachments) { - attachments = await Promise.all( - email.attachments.map(async (attachment) => { - const resp = await fromDataType(attachment.data); - return { - filename: attachment.filename, - content: await resp.data.buffer(), - contentType: resp.data.contentType, - contentDisposition: - attachment.contentDisposition ?? ('attachment' as const), - }; - }) - ); - } - - const normalizedTo = to.map((addr) => addr.trim()).filter(Boolean); - if (normalizedTo.length === 0) { - throw new Error('at least one recipient email is required'); - } - - const fromAddress = from?.email ?? this.toEmail(); - if (!fromAddress) { - throw new Error('a valid from email address is required'); - } - - const mail = new MailComposer({ - date: new Date(), - from: { - name: from?.name ?? context.agent.name, - address: fromAddress, - }, - to: normalizedTo.join(', '), - subject: email.subject ?? '', - text: email.text, - html: email.html, - attachments, - }); - const newemail = mail.compile(); - - return new Promise((resolve, reject) => { - newemail.build(async (err, message) => { - if (err) { - reject(err); - } else { - try { - await context.email.send( - context.agent.id, - message.toString(), - authToken, - newemail.messageId() - ); - resolve(newemail.messageId()); - } catch (ex) { - reject(ex); - } - } - }); - }); - })(); - } - /** * send a reply to the email */ diff --git a/src/types.ts b/src/types.ts index 1c27d09a..b147eda1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -669,16 +669,6 @@ export interface VectorStorage { * EmailService provides a way to send email replies to incoming emails */ export interface EmailService { - /** - * Send a new email to the specified recipients. - */ - send( - agentId: string, - email: string, - authToken: string, - messageId: string - ): Promise; - /** * send an email reply to an incoming email * diff --git a/test/io/email.test.ts b/test/io/email.test.ts index d74f28d0..7fbb2191 100644 --- a/test/io/email.test.ts +++ b/test/io/email.test.ts @@ -56,7 +56,7 @@ Test attachment content const email = await parseEmail(Buffer.from(emailContent)); - expect(email.attachments).toBeDefined(); + expect(() => email.attachments()).not.toThrow(); const attachments = email.attachments(); expect(attachments).toHaveLength(0); }); @@ -82,7 +82,7 @@ Test attachment content const email = await parseEmail(Buffer.from(emailContent)); - expect(email.attachments).toBeDefined(); + expect(() => email.attachments()).not.toThrow(); const attachments = email.attachments(); expect(attachments).toHaveLength(0); }); From adc4c2d1b4847c5c807cf763f72f7c6f059cb2fb Mon Sep 17 00:00:00 2001 From: huijiro Date: Thu, 16 Oct 2025 16:44:02 -0300 Subject: [PATCH 2/2] Changelog --- CHANGELOG.md | 6 ++++++ package-lock.json | 5 +++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c08ec028..89c64f04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # @agentuity/sdk Changelog +## 0.0.157 + +### Patch Changes + +- Removed send from email (unavailable at the moment) + ## [0.0.156] - 2025-10-15 ### Added diff --git a/package-lock.json b/package-lock.json index 812e80a0..cc09753f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@agentuity/sdk", - "version": "0.0.156", + "version": "0.0.157", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@agentuity/sdk", - "version": "0.0.156", + "version": "0.0.157", "license": "Apache-2.0", "dependencies": { "@opentelemetry/api": "^1.9.0", @@ -6824,6 +6824,7 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, diff --git a/package.json b/package.json index bb17c23d..d3962a35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@agentuity/sdk", - "version": "0.0.156", + "version": "0.0.157", "description": "The Agentuity SDK for NodeJS and Bun", "license": "Apache-2.0", "public": true,