feat(scripts): add mustache render-template via Responses pages

Add HTML template kind to Responses with a seeded system email-default
template, render-template.js using Mustache, and html body support in
send-email. Templates are editable but system pages cannot be deleted.

Co-authored-by: Nasyarobby Putra <nasyarobby@gmail.com>
This commit is contained in:
Cursor Agent
2026-08-15 01:44:51 +00:00
co-authored by nsrb
parent 23ce72fec2
commit 46e2cbb83b
12 changed files with 426 additions and 50 deletions
+17 -7
View File
@@ -147,8 +147,11 @@ async function sendEmail(ctx) {
}
const text = ctx.data?.text ?? ctx.data?.body ?? ctx.data?.message;
if (typeof text !== "string" || text.length === 0) {
throw new Error("data.text is required (plain-text body)");
const html = ctx.data?.html;
const hasText = typeof text === "string" && text.length > 0;
const hasHtml = typeof html === "string" && html.length > 0;
if (!hasText && !hasHtml) {
throw new Error("data.text or data.html is required");
}
const cc = normalizeRecipients(ctx.data?.cc, "data.cc");
@@ -174,8 +177,9 @@ async function sendEmail(ctx) {
from,
to,
subject,
text,
};
if (hasText) mail.text = text;
if (hasHtml) mail.html = html;
if (cc) mail.cc = cc;
if (bcc) mail.bcc = bcc;
if (replyTo) mail.replyTo = replyTo;
@@ -203,9 +207,10 @@ async function sendEmail(ctx) {
cc: cc ?? null,
bcc: bcc ? "[redacted]" : null,
subjectLength: subject.length,
textLength: text.length,
textLength: hasText ? text.length : 0,
htmlLength: hasHtml ? html.length : 0,
},
"send-email: sending plain-text message",
"send-email: sending message",
);
const info = await transporter.sendMail(mail);
@@ -224,7 +229,7 @@ async function sendEmail(ctx) {
}
sendEmail.meta = {
description: "Send a plain-text email via SMTP (nodemailer)",
description: "Send an email via SMTP (nodemailer); plain text, HTML, or both",
config: {
service: {
type: "string",
@@ -387,9 +392,14 @@ sendEmail.meta = {
subject: { type: "string", required: true, description: "Email subject" },
text: {
type: "string",
required: true,
required: false,
description: "Plain-text body (aliases: body, message)",
},
html: {
type: "string",
required: false,
description: "HTML body (e.g. from render-template.js)",
},
priority: {
type: "string",
required: false,