diff --git a/lib/emails/inbound/generateEmailResponse.ts b/lib/emails/inbound/generateEmailResponse.ts index 75501412..9cfd0113 100644 --- a/lib/emails/inbound/generateEmailResponse.ts +++ b/lib/emails/inbound/generateEmailResponse.ts @@ -1,3 +1,4 @@ +import { marked } from "marked"; import { ChatRequestBody } from "@/lib/chat/validateChatRequest"; import getGeneralAgent from "@/lib/agents/generalAgent/getGeneralAgent"; import { getEmailRoomMessages } from "@/lib/emails/inbound/getEmailRoomMessages"; @@ -27,6 +28,8 @@ export async function generateEmailResponse( const chatResponse = await agent.generate({ messages }); const text = chatResponse.text; + const bodyHtml = marked(text); + const footerHtml = `
@@ -40,7 +43,7 @@ export async function generateEmailResponse(
`.trim(); - const html = `${text}\n\n${footerHtml}`; + const html = `${bodyHtml}\n\n${footerHtml}`; return { text, html }; } diff --git a/lib/emails/inbound/respondToInboundEmail.ts b/lib/emails/inbound/respondToInboundEmail.ts index 1502b9d4..d0219644 100644 --- a/lib/emails/inbound/respondToInboundEmail.ts +++ b/lib/emails/inbound/respondToInboundEmail.ts @@ -26,6 +26,7 @@ export async function respondToInboundEmail( const to = original.from; const toArray = [to]; const from = getFromWithName(original.to, original.cc); + const cc = original.cc?.length ? original.cc : undefined; // Validate new memory and get chat request body (or early return if duplicate) const validationResult = await validateNewEmailMemory(event); @@ -48,6 +49,7 @@ export async function respondToInboundEmail( const payload = { from, to: toArray, + ...(cc && { cc }), subject, html, headers: { diff --git a/package.json b/package.json index 9834cb65..ca86291d 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "bullmq": "^5.65.1", "googleapis": "^168.0.0", "ioredis": "^5.8.2", + "marked": "^15.0.12", "mcp-handler": "^1.0.4", "multiformats": "^13.4.1", "next": "^16.0.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 63bae2a3..cfd67bed 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -53,6 +53,9 @@ importers: ioredis: specifier: ^5.8.2 version: 5.8.2 + marked: + specifier: ^15.0.12 + version: 15.0.12 mcp-handler: specifier: ^1.0.4 version: 1.0.4(@modelcontextprotocol/sdk@1.24.3(zod@4.1.13))(next@16.0.7(@opentelemetry/api@1.9.0)(react-dom@19.2.1(react@19.2.1))(react@19.2.1)) @@ -3934,6 +3937,11 @@ packages: magic-string@0.30.21: resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} + marked@15.0.12: + resolution: {integrity: sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA==} + engines: {node: '>= 18'} + hasBin: true + math-intrinsics@1.1.0: resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} engines: {node: '>= 0.4'} @@ -10890,6 +10898,8 @@ snapshots: dependencies: '@jridgewell/sourcemap-codec': 1.5.5 + marked@15.0.12: {} + math-intrinsics@1.1.0: {} mcp-handler@1.0.4(@modelcontextprotocol/sdk@1.24.3(zod@4.1.13))(next@16.0.7(@opentelemetry/api@1.9.0)(react-dom@19.2.1(react@19.2.1))(react@19.2.1)):