Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions apps/sim/lib/mothership/inbox/response.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
import { createLogger } from '@sim/logger'
import { marked } from 'marked'
import { toHtml } from 'hast-util-to-html'
import remarkBreaks from 'remark-breaks'
import remarkGfm from 'remark-gfm'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import { unified } from 'unified'
import { getBaseUrl } from '@/lib/core/utils/urls'
import * as agentmail from '@/lib/mothership/inbox/agentmail-client'
import { replaceUntilStable } from '@/lib/mothership/inbox/format'
Expand DownExpand Up@@ -37,7 +42,7 @@ export async function sendInboxResponse(
: `I wasn't able to complete this task.\n\nError: ${result.error || 'Unknown error'}\n\n[View details](${chatUrl})\n\nBest,\nMothership`

const html = result.success
? renderEmailHtml(result.content, chatUrl)
? await renderEmailHtml(result.content, chatUrl)
: renderErrorHtml(result.error || 'Unknown error', chatUrl)

try {
Expand DownExpand Up@@ -93,8 +98,20 @@ function stripUnsafeUrls(html: string): string {
return html.replace(/href\s*=\s*"(javascript|vbscript|data):[^"]*"/gi, 'href="#"')
}

function renderEmailHtml(markdown: string, chatUrl: string): string {
const bodyHtml = stripUnsafeUrls(marked.parse(stripRawHtml(markdown), { async: false }) as string)
const markdownProcessor = unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkBreaks)
.use(remarkRehype)

async function markdownToHtml(markdown: string): Promise<string> {
const mdast = markdownProcessor.parse(markdown)
const hast = await markdownProcessor.run(mdast)
return toHtml(hast)
}

async function renderEmailHtml(markdown: string, chatUrl: string): Promise<string> {
const bodyHtml = stripUnsafeUrls(await markdownToHtml(stripRawHtml(markdown)))

return `<!DOCTYPE html><html><head><meta charset="utf-8"><style>${EMAIL_STYLES}</style></head>
<body>
Expand Down
3 changes: 0 additions & 3 deletions apps/sim/next.config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,9 +81,6 @@ const nextConfig: NextConfig = {
'unpdf',
'ffmpeg-static',
'fluent-ffmpeg',
'pino',
'pino-pretty',
'thread-stream',
'ws',
'isolated-vm',
],
Expand Down
61 changes: 25 additions & 36 deletions apps/sim/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,24 +33,24 @@
"@1password/sdk": "0.3.1",
"@a2a-js/sdk": "0.3.7",
"@anthropic-ai/sdk": "0.71.2",
"@aws-sdk/client-athena": "3.1024.0",
"@aws-sdk/client-bedrock-runtime": "3.940.0",
"@aws-sdk/client-cloudformation": "3.1019.0",
"@aws-sdk/client-cloudwatch": "3.940.0",
"@aws-sdk/client-cloudwatch-logs": "3.940.0",
"@aws-sdk/client-dynamodb": "3.940.0",
"@aws-sdk/client-iam": "3.1029.0",
"@aws-sdk/client-athena": "3.1032.0",
"@aws-sdk/client-bedrock-runtime": "3.1032.0",
"@aws-sdk/client-cloudformation": "3.1032.0",
"@aws-sdk/client-cloudwatch": "3.1032.0",
"@aws-sdk/client-cloudwatch-logs": "3.1032.0",
"@aws-sdk/client-dynamodb": "3.1032.0",
"@aws-sdk/client-iam": "3.1032.0",
"@aws-sdk/client-identitystore": "3.1032.0",
"@aws-sdk/client-organizations": "3.1032.0",
"@aws-sdk/client-rds-data": "3.940.0",
"@aws-sdk/client-s3": "^3.779.0",
"@aws-sdk/client-secrets-manager": "3.940.0",
"@aws-sdk/client-sesv2": "3.940.0",
"@aws-sdk/client-sqs": "3.947.0",
"@aws-sdk/client-rds-data": "3.1032.0",
"@aws-sdk/client-s3": "3.1032.0",
"@aws-sdk/client-secrets-manager": "3.1032.0",
"@aws-sdk/client-sesv2": "3.1032.0",
"@aws-sdk/client-sqs": "3.1032.0",
"@aws-sdk/client-sso-admin": "3.1032.0",
"@aws-sdk/client-sts": "3.1029.0",
"@aws-sdk/lib-dynamodb": "3.940.0",
"@aws-sdk/s3-request-presigner": "^3.779.0",
"@aws-sdk/client-sts": "3.1032.0",
"@aws-sdk/lib-dynamodb": "3.1032.0",
"@aws-sdk/s3-request-presigner": "3.1032.0",
"@azure/communication-email": "1.0.0",
"@azure/storage-blob": "12.27.0",
"@better-auth/sso": "1.3.12",
Expand All@@ -65,7 +65,6 @@
"@modelcontextprotocol/sdk": "1.29.0",
"@monaco-editor/react": "4.7.0",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/exporter-jaeger": "2.1.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.200.0",
"@opentelemetry/resources": "^2.0.0",
"@opentelemetry/sdk-node": "^0.200.0",
Expand All@@ -92,8 +91,8 @@
"@radix-ui/react-toggle": "^1.1.2",
"@radix-ui/react-tooltip": "1.2.8",
"@radix-ui/react-visually-hidden": "1.2.4",
"@react-email/components": "^0.0.34",
"@react-email/render": "2.0.0",
"@react-email/components": "0.5.7",
"@react-email/render": "2.0.8",
"@sim/audit": "workspace:*",
"@sim/logger": "workspace:*",
"@sim/realtime-protocol": "workspace:*",
Expand All@@ -106,15 +105,11 @@
"@tanstack/react-query": "5.90.8",
"@tanstack/react-query-devtools": "5.90.2",
"@trigger.dev/sdk": "4.4.3",
"@types/react-window": "2.0.0",
"@types/three": "0.177.0",
"ajv": "8.18.0",
"better-auth": "1.3.12",
"better-auth-harmony": "1.3.1",
"binary-extensions": "^2.0.0",
"browser-image-compression": "^2.0.2",
"chalk": "5.6.2",
"chart.js": "4.5.1",
"cheerio": "1.1.2",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
Expand All@@ -127,8 +122,6 @@
"docx": "^9.6.1",
"docx-preview": "^0.3.7",
"drizzle-orm": "^0.45.2",
"encoding": "0.1.13",
"entities": "6.0.1",
"es-toolkit": "1.45.1",
"ffmpeg-static": "5.3.0",
"fluent-ffmpeg": "2.1.3",
Expand All@@ -137,6 +130,7 @@
"google-auth-library": "10.5.0",
"gray-matter": "^4.0.3",
"groq-sdk": "^0.15.0",
"hast-util-to-html": "9.0.5",
"html-to-image": "1.11.13",
"html-to-text": "^9.0.5",
"idb-keyval": "6.2.2",
Expand All@@ -153,7 +147,6 @@
"jwt-decode": "^4.0.0",
"lucide-react": "^0.479.0",
"mammoth": "^1.9.0",
"marked": "17.0.4",
"mermaid": "11.14.0",
"micromatch": "4.0.8",
"monaco-editor": "0.55.1",
Expand DownExpand Up@@ -184,31 +177,30 @@
"react-simple-code-editor": "^0.14.1",
"react-window": "2.2.3",
"reactflow": "^11.11.4",
"redis": "5.10.0",
"rehype-autolink-headings": "^7.1.0",
"rehype-slug": "^6.0.0",
"remark-breaks": "^4.0.0",
"remark-gfm": "4.0.1",
"remark-parse": "11.0.0",
"remark-rehype": "11.1.2",
"resend": "^4.1.2",
"rss-parser": "3.13.0",
"safe-regex2": "5.1.0",
"sharp": "0.34.3",
"soap": "1.8.0",
"socket.io-client": "4.8.1",
"ssh2": "^1.17.0",
"streamdown": "2.5.0",
"stripe": "18.5.0",
"svix": "1.88.0",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"thread-stream": "4.0.0",
"three": "0.177.0",
"twilio": "5.9.0",
"unified": "11.0.5",
"unpdf": "1.4.0",
"uuid": "^11.1.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"zod": "4.3.6",
"zustand": "^4.5.7"
"zustand": "^5.0.13"
},
"devDependencies": {
"@sim/testing": "workspace:*",
Expand All@@ -227,16 +219,15 @@
"@types/prismjs": "^1.26.5",
"@types/react": "^19",
"@types/react-dom": "^19",
"@types/react-window": "2.0.0",
"@types/ssh2": "^1.15.5",
"@types/three": "0.177.0",
"@vitejs/plugin-react": "^4.3.4",
"@vitest/coverage-v8": "^3.0.8",
"autoprefixer": "10.4.21",
"concurrently": "^9.1.0",
"critters": "0.0.25",
"dotenv": "^16.4.7",
"jsdom": "^26.0.0",
"postcss": "^8",
"react-email": "^4.0.13",
"react-email": "4.3.2",
"tailwindcss": "^3.4.1",
"typescript": "^5.7.3",
"vite-tsconfig-paths": "^5.1.4",
Expand All@@ -252,8 +243,6 @@
"overrides": {
"next": "16.2.4",
"@next/env": "16.2.4",
"drizzle-orm": "^0.45.2",
"postgres": "^3.4.5",
"react-floater": {
"react": "$react",
"react-dom": "$react-dom"
Expand Down
3 changes: 1 addition & 2 deletions apps/sim/tools/workday/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import { listWorkersTool } from '@/tools/workday/list_workers'
import { terminateWorkerTool } from '@/tools/workday/terminate_worker'
import { updateWorkerTool } from '@/tools/workday/update_worker'

export * from './types'
export {
assignOnboardingTool as workdayAssignOnboardingTool,
changeJobTool as workdayChangeJobTool,
Expand All@@ -21,5 +22,3 @@ export {
terminateWorkerTool as workdayTerminateWorkerTool,
updateWorkerTool as workdayUpdateWorkerTool,
}

export * from './types'
Loading
Loading