@tangle-network/agent-app 0.59.5 → 0.60.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.
@@ -5,7 +5,7 @@ import {
5
5
  } from "../chunk-WN3UK23P.js";
6
6
  import {
7
7
  noticeEmail
8
- } from "../chunk-TLVRBD2M.js";
8
+ } from "../chunk-5YSXPHGK.js";
9
9
  import "../chunk-D6UJEOZQ.js";
10
10
  import "../chunk-YNSPVKMS.js";
11
11
  import "../chunk-3NCPXNBZ.js";
@@ -101,6 +101,11 @@ function header(product) {
101
101
  "</table>"
102
102
  ].join("");
103
103
  }
104
+ function section(entry, product) {
105
+ if (entry.items.length === 0) return "";
106
+ const heading = entry.heading ? `<p class="t-ink" style="margin:20px 0 6px;font-family:${FONT};font-size:13px;line-height:18px;font-weight:600;color:${L.ink}">${escapeHtml(entry.heading)}</p>` : "";
107
+ return heading + items(entry.items, product);
108
+ }
104
109
  function items(list, product) {
105
110
  const rows = list.map((item, index) => {
106
111
  const rule = index === 0 ? "" : `border-top:1px solid ${L.hairline};`;
@@ -149,16 +154,22 @@ function small(html, margin, size = 13) {
149
154
  function footerLines(footer, product) {
150
155
  const where = footer.workspaceName ? `${footer.workspaceName} \xB7 ${product.name}` : product.name;
151
156
  const manage = footer.manageUrl ? resolveEmailUrl(footer.manageUrl, product) : null;
157
+ const unsubscribe = footer.unsubscribeUrl ? resolveEmailUrl(footer.unsubscribeUrl, product) : null;
158
+ const links = [
159
+ ...manage ? [link("Manage notifications", manage, "text-decoration:underline")] : [],
160
+ ...unsubscribe ? [link("Unsubscribe", unsubscribe, "text-decoration:underline")] : []
161
+ ];
152
162
  const html = [
153
163
  escapeHtml(where),
154
164
  escapeHtml(footer.reason),
155
- ...manage ? [link("Manage notifications", manage, "text-decoration:underline")] : [],
165
+ ...links.length > 0 ? [links.join(" &middot; ")] : [],
156
166
  ...footer.postalAddress ? [escapeHtml(footer.postalAddress)] : []
157
167
  ];
158
168
  const text = [
159
169
  where,
160
170
  footer.reason,
161
171
  ...manage ? [`Manage notifications: ${manage}`] : [],
172
+ ...unsubscribe ? [`Unsubscribe: ${unsubscribe}`] : [],
162
173
  ...footer.postalAddress ? [footer.postalAddress] : []
163
174
  ];
164
175
  return { html, text };
@@ -170,7 +181,7 @@ function renderHtml(content, product) {
170
181
  const body = [
171
182
  `<h1 class="t-ink" style="margin:0 0 12px;font-family:${FONT};font-size:22px;line-height:28px;font-weight:600;letter-spacing:-0.01em;color:${L.ink}">${escapeHtml(content.title)}</h1>`,
172
183
  ...content.paragraphs.map((text) => paragraph(text, "0 0 12px")),
173
- content.items && content.items.length > 0 ? items(content.items, product) : "",
184
+ ...(content.sections ?? []).map((entry) => section(entry, product)),
174
185
  buttons(content, product),
175
186
  content.showPrimaryLink && primaryHref ? small(`Or open this link: ${link(primaryHref, primaryHref, "word-break:break-all")}`, "20px 0 0") : "",
176
187
  content.note ? small(escapeHtml(content.note), content.showPrimaryLink ? "8px 0 0" : "20px 0 0") : ""
@@ -211,13 +222,16 @@ ${STYLE}
211
222
  }
212
223
  function renderText(content, product) {
213
224
  const blocks = [`Tangle ${productSuffix(product)}`, content.title, ...content.paragraphs];
214
- if (content.items && content.items.length > 0) {
215
- blocks.push(content.items.map((item) => {
225
+ for (const entry of content.sections ?? []) {
226
+ if (entry.items.length === 0) continue;
227
+ const list = entry.items.map((item) => {
216
228
  const lines = [`- ${item.title}`];
217
229
  if (item.detail) lines.push(` ${item.detail}`);
218
230
  if (item.url) lines.push(` ${resolveEmailUrl(item.url, product)}`);
219
231
  return lines.join("\n");
220
- }).join("\n"));
232
+ }).join("\n");
233
+ blocks.push(entry.heading ? `${entry.heading}
234
+ ${list}` : list);
221
235
  }
222
236
  const actions = [content.primary, content.secondary].filter((action) => Boolean(action)).map((action) => `${action.label}: ${resolveEmailUrl(action.url, product)}`);
223
237
  if (actions.length > 0) blocks.push(actions.join("\n"));
@@ -232,7 +246,11 @@ function renderEmail(product, content) {
232
246
  preheader: content.preheader,
233
247
  html: renderHtml(content, product),
234
248
  text: renderText(content, product),
235
- attachments: [MARK_ATTACHMENT]
249
+ attachments: [MARK_ATTACHMENT],
250
+ headers: content.footer.unsubscribeUrl ? {
251
+ "List-Unsubscribe": `<${resolveEmailUrl(content.footer.unsubscribeUrl, product)}>`,
252
+ "List-Unsubscribe-Post": "List-Unsubscribe=One-Click"
253
+ } : {}
236
254
  };
237
255
  }
238
256
  function emailPreviewHtml(message) {
@@ -253,9 +271,6 @@ function midSentence(text) {
253
271
  if ((first.match(/[A-Z]/g) ?? []).length > 1) return text;
254
272
  return text.charAt(0).toLowerCase() + text.slice(1);
255
273
  }
256
- function plural(count, one, many) {
257
- return count === 1 ? one : many;
258
- }
259
274
  function day(date) {
260
275
  return date.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric", timeZone: "UTC" });
261
276
  }
@@ -269,7 +284,7 @@ function approvalEmail(product, input) {
269
284
  preheader: `The agent paused${where} until you decide.`,
270
285
  title: rest.length === 0 ? "Approval needed" : `${input.actions.length} approvals needed`,
271
286
  paragraphs: [`The agent paused${where} until you decide. Nothing runs until you approve.`],
272
- items: input.actions.map((action) => ({ title: action.summary, ...action.detail ? { detail: action.detail } : {} })),
287
+ sections: [{ items: input.actions.map((action) => ({ title: action.summary, ...action.detail ? { detail: action.detail } : {} })) }],
273
288
  primary: { label: "Approve", url: input.approveUrl },
274
289
  secondary: { label: "Review", url: input.reviewUrl },
275
290
  footer: input.footer
@@ -293,15 +308,13 @@ function inviteEmail(product, input) {
293
308
  });
294
309
  }
295
310
  function digestEmail(product, input) {
296
- const count = input.items.length;
297
- const updates = `${count} ${plural(count, "update", "updates")}`;
298
311
  const date = input.date.toLocaleDateString("en-US", { weekday: "long", month: "long", day: "numeric", timeZone: "UTC" });
299
312
  return renderEmail(product, {
300
- subject: emailSubject(`${input.workspaceName}: ${updates}`, product),
301
- preheader: input.items[0]?.title ?? `Nothing new in ${input.workspaceName}.`,
302
- title: `What happened in ${input.workspaceName}`,
303
- paragraphs: [count === 0 ? `Nothing new on ${date}.` : `${updates} on ${date}.`],
304
- items: input.items,
313
+ subject: emailSubject(`${input.workspaceName}: ${input.headline}`, product),
314
+ preheader: `${input.headline}.`,
315
+ title: `Your day in ${input.workspaceName}`,
316
+ paragraphs: [`${date}: ${input.headline}.`],
317
+ sections: input.sections,
305
318
  primary: { label: `Open ${product.name}`, url: input.openUrl },
306
319
  footer: input.footer
307
320
  });
@@ -421,4 +434,4 @@ export {
421
434
  noticeEmail,
422
435
  lintEmailHtml
423
436
  };
424
- //# sourceMappingURL=chunk-TLVRBD2M.js.map
437
+ //# sourceMappingURL=chunk-5YSXPHGK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/email/mark.generated.ts","../src/email/palette.ts","../src/email/layout.ts","../src/email/templates.ts","../src/email/lint.ts"],"sourcesContent":["// GENERATED by scripts/email-mark.mjs from @tangle-network/brand TangleKnot; do not edit.\n/** The Tangle knot as a 84px transparent PNG (base64), shown at 28px in email headers. */\nexport const TANGLE_MARK_PNG_BASE64 =\n 'iVBORw0KGgoAAAANSUhEUgAAAFQAAABUCAYAAAAcaxDBAAAQAElEQVR4nOxcDZBV1X3//8+9971dVvkwEhR1GuvEatIY09hmOklTCU2bMQYnH3ZMTAmRZRdpqIAYgV3Iy35CgAUEBBGcBNskliSmTZqPjtox6dhJaGY61NFGpfEDSBRBgbjsvnfv+fd/P86959x73+5b9r26mdm/Luede+/5uP/zO//z/zjnCpikupKASaorTTK0zjTJ0DrTJEPrTJMMrTNNMrTOZMM4qWuxewsBXsVDcxEBzSQUBQAJ4VhxilHq/6sPHyY/SU+NIeYriFw6TMMnMC6Rfj5oFVVrOfWh+Wx0zUWiEyTwZeHRrzauL+yFcRDCOVDPYu8LHtICr4Dv8oAK/rsGr+q/PMkgDfPccWJ281sSpxCl4f2QScF1xSztepwnGV0PLxv1CAzrj8qF7afykG3PzMuofyE3+L5nS/FL8OChLb1OF4yRamZoaSlNtctyo2vTpz0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iQRaxv3MX9kCN1NtKs6wKfIr1jM8H+IqikSiS1TtAqrBOWx589u4H8FhePUtKdF7RqxxkpFyV/227uL4dvKRt21Jqeg5qpLtWDX9SeNZulpsXjvRtveEm75mtXcU/SJfHahX330aPWxX6IGjM1JwtcZ58D7aA15lJJ9hPeYQdVYPGVxnD7yeh5YnZwgtVr0SfJEjySY9Y0B9xHXhZ5fO0YW5zprTofdlIavY3m9QvMIOe8nEAYH7Fka8V/O9KscyeyRqQf/SxYHry0RQrTJUCDA63eO/ZuabpGaiVoT6tXyifFGV4Z74/ECDXX0o17KkfZS+8MTMC1QSg1j316Z3QuVHQKBpbtX9YZc89p64tB8sz5LX3fDH/SPmIDPWJQyGPWi4E6kgaSZSqhVI1Uua6OfJGXi+n1Z+eGWb7pCE9FdNKIZvy+q3nc/utI5OZ6dCRs0Vv7s5SFpladaOT/3VGa1hsZ6A05XmuQaCGWMUkiB0suUiBbFw/g/Aqcf0MEqMPuUANp030AF86rh+vEal9AFxelpvkAwNdThvgOL/OqMiPgjpI97PqNA+CyE5Sgz7CGdQayFSkIzV5OfNlR0ImpBCtkKlJ5QipCTKrRDejPiJkZ4Zv9HoFeXC4SAvvKRWfhBqoZoYq2tBKl/rKOGvc77MkzsogFvKRmS8j06tzFsEmwvJmxgjlRpCh2e+NJqdN2FX4mifov8qFyupt3VPGdIR8zAxNU1e7O5879vv88yLu5UzuVSGNIEVSX/2FoQWkngNDQ07LPMi7r2YCqG/hpWQ0pMph/HVGl03fE2DhbzygF8vkPLx9HKecx83QSTJpAp8C+d2kSYbWmSYZWmeaZGidaZKhdaZJhtaZJhlaZ/o/AAAA//8mfCa5AAAABklEQVQDAPyiOFzVbOpbAAAAAElFTkSuQmCC'\n","/**\n * The Brand roles the email layout paints with, as literal hex. Email clients\n * cannot read CSS variables, and importing `@tangle-network/brand` at runtime\n * would load React into a server-only renderer, so the values live here and\n * `tests/email/palette.test.ts` fails when they drift from Brand's `palettes`.\n */\nexport const EMAIL_PALETTE = {\n light: {\n canvas: '#eceef3',\n card: '#ffffff',\n well: '#f6f7fa',\n hairline: '#c7c6d6',\n ink: '#2d2d2d',\n inkSecondary: '#3f3f3f',\n inkMuted: '#4c4c4c',\n accent: '#4c3fc5',\n onAccent: '#ffffff',\n accentText: '#3c32e9',\n },\n dark: {\n canvas: '#0a0a14',\n card: '#191826',\n well: '#12111f',\n hairline: '#2a293d',\n ink: '#e6e6e6',\n inkSecondary: '#c7c7c7',\n inkMuted: '#b5b5b5',\n accent: '#4c3fc5',\n onAccent: '#ffffff',\n accentText: '#a5b4fc',\n },\n} as const\n\n/**\n * Brand's `--font-sans` stack with the system faces email clients actually\n * have. No client used for this mail loads web fonts reliably, so Inter shows\n * only where it is installed and the platform UI face carries the rest.\n */\nexport const EMAIL_FONT_STACK =\n \"Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif\"\n","import { TANGLE_MARK_PNG_BASE64 } from './mark.generated'\nimport { EMAIL_FONT_STACK, EMAIL_PALETTE } from './palette'\n\n/** The app an email comes from. */\nexport interface EmailProduct {\n /**\n * The product name, e.g. `GTM Agent`. The header reads `Tangle GTM Agent`;\n * subjects and the sender use the name alone. A name that already starts\n * with `Tangle` (`Tangle Sandbox`) is not doubled.\n */\n name: string\n /** The app's absolute origin; app-relative links resolve against it. */\n url: string\n}\n\n/** Why the recipient got the email and where they control it. */\nexport interface EmailFooter {\n /** The workspace the email concerns. */\n workspaceName?: string\n /** One sentence, e.g. `You own this workspace.` */\n reason: string\n /** Where the recipient changes which emails they get; absolute or app-relative. */\n manageUrl?: string\n /**\n * Turns this kind of email off in one request, without signing in; absolute\n * or app-relative. Adds an Unsubscribe link and the RFC 8058\n * `List-Unsubscribe` headers, so the endpoint must accept a POST.\n */\n unsubscribeUrl?: string\n /**\n * The sender's postal address, for marketing mail such as a digest. Leave it\n * unset on transactional mail (approvals, invites, sign-in), which does not\n * need one.\n */\n postalAddress?: string\n}\n\n/** A button. `url` is absolute or app-relative. */\nexport interface EmailAction {\n label: string\n url: string\n}\n\n/** One row in a list box: an approval request or a digest entry. */\nexport interface EmailItem {\n title: string\n detail?: string\n /** Makes the title a link; absolute or app-relative. */\n url?: string\n}\n\n/** An inline image the HTML references by `cid:`; the mail client must send it with the message. */\nexport interface EmailAttachment {\n filename: string\n /** Base64 file content, the form Resend and SES accept. */\n content: string\n contentType: string\n contentId: string\n}\n\n/** A rendered email, ready for any transport. */\nexport interface EmailMessage {\n subject: string\n /** The inbox preview line. */\n preheader: string\n html: string\n text: string\n /** Pass these through to the mail client; the header mark is one of them. */\n attachments: EmailAttachment[]\n /** Extra message headers, such as `List-Unsubscribe`; pass them through too. */\n headers: Record<string, string>\n}\n\n/** A titled list box; a template with one list leaves `heading` unset. */\nexport interface EmailSection {\n heading?: string\n items: readonly EmailItem[]\n}\n\n/** What a template places in the shared layout. */\ninterface EmailContent {\n subject: string\n preheader: string\n title: string\n paragraphs: readonly string[]\n sections?: readonly EmailSection[]\n primary?: EmailAction\n secondary?: EmailAction\n /** Print the primary link under the buttons for clients that strip them. */\n showPrimaryLink?: boolean\n /** A short line under the buttons, e.g. an expiry. */\n note?: string\n footer: EmailFooter\n}\n\nconst MARK_CONTENT_ID = 'tangle-mark'\nconst MARK_ATTACHMENT: EmailAttachment = {\n filename: 'tangle.png',\n content: TANGLE_MARK_PNG_BASE64,\n contentType: 'image/png',\n contentId: MARK_CONTENT_ID,\n}\n\nconst L = EMAIL_PALETTE.light\nconst D = EMAIL_PALETTE.dark\nconst FONT = EMAIL_FONT_STACK\n\n// Inline styles carry the light design; this block only adapts it for clients\n// that honor dark mode or narrow screens. A client that drops <style> still\n// renders the complete light email.\nconst STYLE = `\n@media (prefers-color-scheme: dark) {\n .t-bg { background-color: ${D.canvas} !important; }\n .t-card { background-color: ${D.card} !important; border-color: ${D.hairline} !important; }\n .t-well { background-color: ${D.well} !important; }\n .t-rule { border-color: ${D.hairline} !important; }\n .t-ink { color: ${D.ink} !important; }\n .t-ink2 { color: ${D.inkSecondary} !important; }\n .t-muted { color: ${D.inkMuted} !important; }\n .t-link { color: ${D.accentText} !important; }\n .t-btn2 { border-color: ${D.hairline} !important; }\n}\n@media (max-width: 600px) {\n .t-outer { padding: 20px 8px !important; }\n .t-card { padding: 28px 22px 24px !important; }\n}\n[data-ogsb] .t-bg { background-color: ${D.canvas} !important; }\n[data-ogsb] .t-card { background-color: ${D.card} !important; }\n[data-ogsb] .t-well { background-color: ${D.well} !important; }\n[data-ogsc] .t-ink { color: ${D.ink} !important; }\n[data-ogsc] .t-ink2 { color: ${D.inkSecondary} !important; }\n[data-ogsc] .t-muted { color: ${D.inkMuted} !important; }\n[data-ogsc] .t-link { color: ${D.accentText} !important; }\n`.trim()\n\n/** Escape text for HTML element content and quoted attribute values. */\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;')\n}\n\n/** An absolute http(s) URL; app-relative paths resolve against the product origin. */\nfunction resolveEmailUrl(url: string, product: EmailProduct): string {\n const resolved = new URL(url, product.url)\n if (resolved.protocol !== 'https:' && resolved.protocol !== 'http:') {\n throw new TypeError(`Email links must be http(s): ${resolved.protocol}`)\n }\n return resolved.toString()\n}\n\n/** `Title — Product`, the one subject shape every Tangle email uses. */\nexport function emailSubject(subject: string, product: EmailProduct): string {\n return `${subject} — ${product.name}`\n}\n\nfunction paragraph(text: string, margin: string): string {\n return `<p class=\"t-ink2\" style=\"margin:${margin};font-family:${FONT};font-size:15px;line-height:24px;color:${L.inkSecondary}\">${escapeHtml(text)}</p>`\n}\n\nfunction link(label: string, href: string, style: string): string {\n return `<a class=\"t-link\" href=\"${escapeHtml(href)}\" style=\"color:${L.accentText};text-decoration:none;${style}\">${escapeHtml(label)}</a>`\n}\n\n/** The product name after the `Tangle` logotype: `GTM Agent`, or `Sandbox` for `Tangle Sandbox`. */\nfunction productSuffix(product: EmailProduct): string {\n return product.name.replace(/^Tangle\\s+/i, '')\n}\n\n// Brand's lockup: the knot, `Tangle` in the logotype's bold, then the product\n// name at a lighter weight, as the product site headers set it.\nfunction header(product: EmailProduct): string {\n const type = `font-family:${FONT};font-size:17px;line-height:20px;letter-spacing:-0.01em;color:${L.ink}`\n return [\n '<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">',\n '<tr>',\n `<td style=\"padding:0 10px 0 0;vertical-align:middle\"><img src=\"cid:${MARK_CONTENT_ID}\" width=\"28\" height=\"28\" alt=\"\" style=\"display:block;width:28px;height:28px;border:0;outline:none;text-decoration:none\"></td>`,\n `<td class=\"t-ink\" style=\"vertical-align:middle;white-space:nowrap;${type}\">`,\n `<span class=\"t-ink\" style=\"${type};font-weight:700\">Tangle</span>`,\n `<span class=\"t-ink\" style=\"${type};font-weight:500\">&nbsp;${escapeHtml(productSuffix(product))}</span>`,\n '</td>',\n '</tr>',\n '</table>',\n ].join('')\n}\n\nfunction section(entry: EmailSection, product: EmailProduct): string {\n if (entry.items.length === 0) return ''\n const heading = entry.heading\n ? `<p class=\"t-ink\" style=\"margin:20px 0 6px;font-family:${FONT};font-size:13px;line-height:18px;font-weight:600;color:${L.ink}\">${escapeHtml(entry.heading)}</p>`\n : ''\n return heading + items(entry.items, product)\n}\n\nfunction items(list: readonly EmailItem[], product: EmailProduct): string {\n const rows = list.map((item, index) => {\n const rule = index === 0 ? '' : `border-top:1px solid ${L.hairline};`\n const title = item.url\n ? link(item.title, resolveEmailUrl(item.url, product), 'font-weight:600')\n : escapeHtml(item.title)\n const detail = item.detail\n ? `<p class=\"t-muted\" style=\"margin:2px 0 0;font-family:${FONT};font-size:13px;line-height:20px;color:${L.inkMuted}\">${escapeHtml(item.detail)}</p>`\n : ''\n return [\n `<tr><td class=\"t-rule\" style=\"padding:14px 16px;${rule}\">`,\n `<p class=\"t-ink\" style=\"margin:0;font-family:${FONT};font-size:15px;line-height:22px;font-weight:600;color:${L.ink}\">${title}</p>`,\n detail,\n '</td></tr>',\n ].join('')\n })\n return [\n `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"t-well\" bgcolor=\"${L.well}\" style=\"background-color:${L.well};border-radius:8px;margin:4px 0 8px\">`,\n ...rows,\n '</table>',\n ].join('')\n}\n\nfunction primaryButton(action: EmailAction, href: string): string {\n return [\n `<td bgcolor=\"${L.accent}\" style=\"border-radius:8px;background-color:${L.accent};mso-padding-alt:12px 22px\">`,\n `<a href=\"${escapeHtml(href)}\" style=\"display:inline-block;padding:12px 22px;font-family:${FONT};font-size:15px;line-height:20px;font-weight:600;color:${L.onAccent};text-decoration:none;border-radius:8px\">${escapeHtml(action.label)}</a>`,\n '</td>',\n ].join('')\n}\n\nfunction secondaryButton(action: EmailAction, href: string): string {\n return [\n `<td class=\"t-btn2\" style=\"border:1px solid ${L.hairline};border-radius:8px;mso-padding-alt:11px 21px\">`,\n `<a class=\"t-ink\" href=\"${escapeHtml(href)}\" style=\"display:inline-block;padding:11px 21px;font-family:${FONT};font-size:15px;line-height:20px;font-weight:600;color:${L.ink};text-decoration:none;border-radius:8px\">${escapeHtml(action.label)}</a>`,\n '</td>',\n ].join('')\n}\n\nfunction buttons(content: EmailContent, product: EmailProduct): string {\n const cells: string[] = []\n if (content.primary) cells.push(primaryButton(content.primary, resolveEmailUrl(content.primary.url, product)))\n if (content.secondary) {\n if (cells.length > 0) cells.push('<td style=\"width:10px;font-size:0;line-height:0\">&nbsp;</td>')\n cells.push(secondaryButton(content.secondary, resolveEmailUrl(content.secondary.url, product)))\n }\n if (cells.length === 0) return ''\n return `<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"margin:20px 0 0\"><tr>${cells.join('')}</tr></table>`\n}\n\nfunction small(html: string, margin: string, size = 13): string {\n return `<p class=\"t-muted\" style=\"margin:${margin};font-family:${FONT};font-size:${size}px;line-height:${size + 7}px;color:${L.inkMuted}\">${html}</p>`\n}\n\nfunction footerLines(footer: EmailFooter, product: EmailProduct): { html: string[]; text: string[] } {\n const where = footer.workspaceName ? `${footer.workspaceName} · ${product.name}` : product.name\n const manage = footer.manageUrl ? resolveEmailUrl(footer.manageUrl, product) : null\n const unsubscribe = footer.unsubscribeUrl ? resolveEmailUrl(footer.unsubscribeUrl, product) : null\n const links = [\n ...(manage ? [link('Manage notifications', manage, 'text-decoration:underline')] : []),\n ...(unsubscribe ? [link('Unsubscribe', unsubscribe, 'text-decoration:underline')] : []),\n ]\n const html = [\n escapeHtml(where),\n escapeHtml(footer.reason),\n ...(links.length > 0 ? [links.join(' &middot; ')] : []),\n ...(footer.postalAddress ? [escapeHtml(footer.postalAddress)] : []),\n ]\n const text = [\n where,\n footer.reason,\n ...(manage ? [`Manage notifications: ${manage}`] : []),\n ...(unsubscribe ? [`Unsubscribe: ${unsubscribe}`] : []),\n ...(footer.postalAddress ? [footer.postalAddress] : []),\n ]\n return { html, text }\n}\n\n// Keeps the body text that follows out of the inbox preview line.\nconst PREHEADER_SPACER = '&#847;&zwnj;&nbsp;'.repeat(40)\n\nfunction renderHtml(content: EmailContent, product: EmailProduct): string {\n const primaryHref = content.primary ? resolveEmailUrl(content.primary.url, product) : null\n const footer = footerLines(content.footer, product)\n const body = [\n `<h1 class=\"t-ink\" style=\"margin:0 0 12px;font-family:${FONT};font-size:22px;line-height:28px;font-weight:600;letter-spacing:-0.01em;color:${L.ink}\">${escapeHtml(content.title)}</h1>`,\n ...content.paragraphs.map((text) => paragraph(text, '0 0 12px')),\n ...(content.sections ?? []).map((entry) => section(entry, product)),\n buttons(content, product),\n content.showPrimaryLink && primaryHref\n ? small(`Or open this link: ${link(primaryHref, primaryHref, 'word-break:break-all')}`, '20px 0 0')\n : '',\n content.note ? small(escapeHtml(content.note), content.showPrimaryLink ? '8px 0 0' : '20px 0 0') : '',\n ].join('')\n\n return [\n '<!DOCTYPE html>',\n '<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\">',\n '<head>',\n '<meta charset=\"utf-8\">',\n '<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">',\n '<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">',\n '<meta name=\"x-apple-disable-message-reformatting\">',\n '<meta name=\"format-detection\" content=\"telephone=no, date=no, address=no, email=no, url=no\">',\n '<meta name=\"color-scheme\" content=\"light dark\">',\n '<meta name=\"supported-color-schemes\" content=\"light dark\">',\n `<title>${escapeHtml(content.subject)}</title>`,\n '<!--[if mso]><noscript><xml><o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml></noscript><![endif]-->',\n `<style>\\n${STYLE}\\n</style>`,\n '</head>',\n `<body class=\"t-bg\" style=\"margin:0;padding:0;width:100%;background-color:${L.canvas};-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%\">`,\n `<div style=\"display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden;mso-hide:all\">${escapeHtml(content.preheader)}${PREHEADER_SPACER}</div>`,\n `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"t-bg\" bgcolor=\"${L.canvas}\" style=\"background-color:${L.canvas}\">`,\n '<tr><td class=\"t-outer\" align=\"center\" style=\"padding:32px 12px\">',\n '<!--[if mso]><table role=\"presentation\" width=\"560\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\"><tr><td><![endif]-->',\n '<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"max-width:560px;margin:0 auto\">',\n `<tr><td style=\"padding:0 4px 20px\">${header(product)}</td></tr>`,\n `<tr><td class=\"t-card\" bgcolor=\"${L.card}\" style=\"background-color:${L.card};border:1px solid ${L.hairline};border-radius:12px;padding:36px 36px 32px\">${body}</td></tr>`,\n `<tr><td style=\"padding:24px 4px 0\">${footer.html.map((line, index) => small(line, index === 0 ? '0' : '4px 0 0', 12)).join('')}</td></tr>`,\n '</table>',\n '<!--[if mso]></td></tr></table><![endif]-->',\n '</td></tr>',\n '</table>',\n '</body>',\n '</html>',\n ].join('\\n')\n}\n\nfunction renderText(content: EmailContent, product: EmailProduct): string {\n const blocks: string[] = [`Tangle ${productSuffix(product)}`, content.title, ...content.paragraphs]\n for (const entry of content.sections ?? []) {\n if (entry.items.length === 0) continue\n const list = entry.items.map((item) => {\n const lines = [`- ${item.title}`]\n if (item.detail) lines.push(` ${item.detail}`)\n if (item.url) lines.push(` ${resolveEmailUrl(item.url, product)}`)\n return lines.join('\\n')\n }).join('\\n')\n blocks.push(entry.heading ? `${entry.heading}\\n${list}` : list)\n }\n const actions = [content.primary, content.secondary]\n .filter((action): action is EmailAction => Boolean(action))\n .map((action) => `${action.label}: ${resolveEmailUrl(action.url, product)}`)\n if (actions.length > 0) blocks.push(actions.join('\\n'))\n if (content.note) blocks.push(content.note)\n blocks.push(['--', ...footerLines(content.footer, product).text].join('\\n'))\n return `${blocks.join('\\n\\n')}\\n`\n}\n\n/** Place a template's content in the shared Tangle layout. */\nexport function renderEmail(product: EmailProduct, content: EmailContent): EmailMessage {\n return {\n subject: content.subject,\n preheader: content.preheader,\n html: renderHtml(content, product),\n text: renderText(content, product),\n attachments: [MARK_ATTACHMENT],\n headers: content.footer.unsubscribeUrl\n ? {\n 'List-Unsubscribe': `<${resolveEmailUrl(content.footer.unsubscribeUrl, product)}>`,\n 'List-Unsubscribe-Post': 'List-Unsubscribe=One-Click',\n }\n : {},\n }\n}\n\n/**\n * The HTML with inline images embedded as data URIs, for browser previews and\n * screenshots. Mail clients get `cid:` references and the attachments instead.\n */\nexport function emailPreviewHtml(message: Pick<EmailMessage, 'html' | 'attachments'>): string {\n return message.attachments.reduce(\n (html, attachment) => html.split(`cid:${attachment.contentId}`).join(`data:${attachment.contentType};base64,${attachment.content}`),\n message.html,\n )\n}\n\n/**\n * The From header for an app's mail: `GTM Agent · Tangle <noreply@tangle.tools>`.\n * The product leads because inbox sender columns truncate; `· Tangle` ties\n * every app to the company and the sending domain.\n */\nexport function emailSender(productName: string, address: string): string {\n if (!/^[^\\s<>@]+@[^\\s<>@]+\\.[^\\s<>@]+$/.test(address)) throw new TypeError(`Not an email address: ${address}`)\n const name = /\\bTangle\\b/i.test(productName) ? productName : `${productName} · Tangle`\n return `${name} <${address}>`\n}\n","import {\n emailSubject,\n renderEmail,\n type EmailAction,\n type EmailFooter,\n type EmailItem,\n type EmailMessage,\n type EmailProduct,\n type EmailSection,\n} from './layout'\n\n/** Sentence case to mid-sentence: `Create agent` → `create agent`; acronyms such as `API key` keep their case. */\nfunction midSentence(text: string): string {\n const first = text.split(/\\s/, 1)[0] ?? ''\n if ((first.match(/[A-Z]/g) ?? []).length > 1) return text\n return text.charAt(0).toLowerCase() + text.slice(1)\n}\n\nfunction day(date: Date): string {\n return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' })\n}\n\n/** One action an agent is waiting to run. */\nexport interface ApprovalEmailAction {\n /** What runs, in plain language and sentence case: `Create agent “Quinn”`. */\n summary: string\n /** Where it runs and until when, e.g. `ph0ny · open until Oct 9, 3:40 PM UTC`. */\n detail?: string\n}\n\n/** Input for {@link approvalEmail}. */\nexport interface ApprovalEmailInput {\n /** At least one action, in the order the agent asked. */\n actions: readonly ApprovalEmailAction[]\n /** The conversation the agent paused in. */\n conversation?: string\n /** Opens the decision, e.g. the chat with the approval card. */\n approveUrl: string\n /** Opens the context, e.g. every request waiting in the workspace. */\n reviewUrl: string\n footer: EmailFooter\n}\n\n/**\n * An agent paused until someone approves what it wants to do. Neither button\n * decides anything: link scanners open email links, so both lead to the app,\n * where the signed-in owner approves.\n */\nexport function approvalEmail(product: EmailProduct, input: ApprovalEmailInput): EmailMessage {\n const [first, ...rest] = input.actions\n if (!first) throw new TypeError('approvalEmail needs at least one action')\n const what = rest.length === 0\n ? midSentence(first.summary)\n : `${midSentence(first.summary)} and ${rest.length} more`\n const where = input.conversation ? ` in “${input.conversation}”` : ''\n return renderEmail(product, {\n subject: emailSubject(`Approve: ${what}`, product),\n preheader: `The agent paused${where} until you decide.`,\n title: rest.length === 0 ? 'Approval needed' : `${input.actions.length} approvals needed`,\n paragraphs: [`The agent paused${where} until you decide. Nothing runs until you approve.`],\n sections: [{ items: input.actions.map((action): EmailItem => ({ title: action.summary, ...(action.detail ? { detail: action.detail } : {}) })) }],\n primary: { label: 'Approve', url: input.approveUrl },\n secondary: { label: 'Review', url: input.reviewUrl },\n footer: input.footer,\n })\n}\n\n/** Input for {@link inviteEmail}. */\nexport interface InviteEmailInput {\n workspaceName: string\n /** Who sent the invitation: a name or an email address. */\n inviter: string\n /** The role the invitation grants, e.g. `editor`. */\n role: string\n acceptUrl: string\n expiresAt: Date\n}\n\n/** Someone invited the recipient to a workspace. */\nexport function inviteEmail(product: EmailProduct, input: InviteEmailInput): EmailMessage {\n const role = input.role.toLowerCase()\n const article = /^[aeiou]/.test(role) ? 'an' : 'a'\n return renderEmail(product, {\n subject: emailSubject(`Join ${input.workspaceName}`, product),\n preheader: `${input.inviter} invited you to ${input.workspaceName}.`,\n title: `Join ${input.workspaceName}`,\n paragraphs: [`${input.inviter} invited you to ${input.workspaceName} on ${product.name} as ${article} ${role}.`],\n primary: { label: 'Accept invitation', url: input.acceptUrl },\n showPrimaryLink: true,\n note: `This invitation expires on ${day(input.expiresAt)}.`,\n footer: {\n workspaceName: input.workspaceName,\n reason: `You received this because ${input.inviter} invited this address.`,\n },\n })\n}\n\n/** Input for {@link digestEmail}. */\nexport interface DigestEmailInput {\n workspaceName: string\n /** The day the digest covers, in the workspace's own date. */\n date: Date\n /** The most useful facts in a few words, for the subject and preview: `2 approvals waiting, 14 turns`. */\n headline: string\n /** What happened and what waits, most important first; empty sections are left out. */\n sections: readonly EmailSection[]\n /** Opens the workspace. */\n openUrl: string\n footer: EmailFooter\n}\n\n/** What happened in a workspace over a day, and what waits on the recipient. */\nexport function digestEmail(product: EmailProduct, input: DigestEmailInput): EmailMessage {\n const date = input.date.toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric', timeZone: 'UTC' })\n return renderEmail(product, {\n subject: emailSubject(`${input.workspaceName}: ${input.headline}`, product),\n preheader: `${input.headline}.`,\n title: `Your day in ${input.workspaceName}`,\n paragraphs: [`${date}: ${input.headline}.`],\n sections: input.sections,\n primary: { label: `Open ${product.name}`, url: input.openUrl },\n footer: input.footer,\n })\n}\n\n/** Input for {@link noticeEmail}. */\nexport interface NoticeEmailInput {\n /** Short; the product name is appended. */\n subject: string\n title: string\n /** One or two short paragraphs. */\n body: string | readonly string[]\n action?: EmailAction\n secondaryAction?: EmailAction\n /** Print the action's link too, for one-time links such as sign-in. */\n showLink?: boolean\n note?: string\n /** Inbox preview line. Defaults to the first paragraph. */\n preheader?: string\n footer: EmailFooter\n}\n\n/** Any other transactional message: one title, a short body and at most two buttons. */\nexport function noticeEmail(product: EmailProduct, input: NoticeEmailInput): EmailMessage {\n const paragraphs = typeof input.body === 'string' ? [input.body] : [...input.body]\n return renderEmail(product, {\n subject: emailSubject(input.subject, product),\n preheader: input.preheader ?? paragraphs[0] ?? input.title,\n title: input.title,\n paragraphs,\n ...(input.action ? { primary: input.action } : {}),\n ...(input.secondaryAction ? { secondary: input.secondaryAction } : {}),\n ...(input.showLink ? { showPrimaryLink: true } : {}),\n ...(input.note ? { note: input.note } : {}),\n footer: input.footer,\n })\n}\n","/** One way an email's HTML would break in Gmail or Outlook. */\nexport interface EmailLintIssue {\n rule:\n | 'document'\n | 'external-css'\n | 'style-block'\n | 'unsupported-element'\n | 'unsupported-css'\n | 'layout-table'\n | 'inline-style'\n | 'image'\n | 'link'\n | 'size'\n message: string\n}\n\n// Gmail clips a message body larger than about 102 KB behind \"View entire message\".\nconst GMAIL_CLIP_BYTES = 102_000\n\nconst tags = (html: string, name: string): string[] =>\n html.match(new RegExp(`<${name}\\\\b[^>]*>`, 'gi')) ?? []\n\nconst attribute = (tag: string, name: string): string | null => {\n const match = new RegExp(`\\\\s${name}=\"([^\"]*)\"`, 'i').exec(tag)\n return match ? match[1]! : null\n}\n\n/** Top-level rules of a stylesheet: their selector or at-rule preludes. */\nfunction preludes(css: string): string[] {\n const out: string[] = []\n let depth = 0\n let start = 0\n for (let i = 0; i < css.length; i++) {\n if (css[i] === '{') {\n if (depth === 0) out.push(css.slice(start, i).trim())\n depth++\n } else if (css[i] === '}') {\n depth--\n if (depth === 0) start = i + 1\n }\n }\n return out\n}\n\n/**\n * Check rendered email HTML against what Gmail and Outlook render: a complete\n * document, layout in presentation tables, styles inline (a `<style>` block may\n * only add dark-mode and narrow-screen overrides), images with alt text and\n * fixed size, absolute links, and a body small enough that Gmail does not clip.\n */\nexport function lintEmailHtml(html: string): EmailLintIssue[] {\n const issues: EmailLintIssue[] = []\n const issue = (rule: EmailLintIssue['rule'], message: string) => issues.push({ rule, message })\n const visible = html.replace(/<!--[\\s\\S]*?-->/g, '')\n\n if (!/^<!DOCTYPE html>/i.test(html)) issue('document', 'Missing <!DOCTYPE html>')\n if (!/<html\\b[^>]*\\slang=\"[^\"]+\"/i.test(html)) issue('document', 'Missing <html lang>')\n if (!/<meta charset=\"utf-8\">/i.test(html)) issue('document', 'Missing <meta charset=\"utf-8\">')\n if (!/<title>[^<]+<\\/title>/i.test(html)) issue('document', 'Missing <title>')\n\n if (/<link\\b[^>]*rel=\"?stylesheet/i.test(visible)) issue('external-css', 'Linked stylesheets are stripped')\n if (/@import\\b/i.test(visible)) issue('external-css', '@import is stripped')\n\n for (const block of visible.match(/<style\\b[^>]*>([\\s\\S]*?)<\\/style>/gi) ?? []) {\n const css = block.replace(/<\\/?style\\b[^>]*>/gi, '').replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n for (const prelude of preludes(css)) {\n if (!prelude.startsWith('@media') && !prelude.startsWith('[data-og')) {\n issue('style-block', `<style> may only hold overrides; \"${prelude}\" must be inline`)\n }\n }\n }\n\n for (const name of ['script', 'form', 'input', 'button', 'svg', 'iframe', 'video', 'audio', 'object', 'embed']) {\n if (tags(visible, name).length > 0) issue('unsupported-element', `<${name}> is stripped or unsupported`)\n }\n\n for (const pattern of [\n /display\\s*:\\s*(?:flex|grid|inline-flex)/i,\n /position\\s*:/i,\n /float\\s*:/i,\n /var\\(/i,\n /calc\\(/i,\n /rgba?\\(|hsla?\\(/i,\n /background-image\\s*:|url\\(/i,\n ]) {\n if (pattern.test(visible)) issue('unsupported-css', `Outlook does not render ${pattern.source}`)\n }\n\n for (const table of tags(visible, 'table')) {\n if (attribute(table, 'role') !== 'presentation') issue('layout-table', `Layout table without role=\"presentation\": ${table.slice(0, 80)}`)\n for (const name of ['cellpadding', 'cellspacing', 'border']) {\n if (attribute(table, name) !== '0') issue('layout-table', `Layout table without ${name}=\"0\": ${table.slice(0, 80)}`)\n }\n }\n for (const div of tags(visible, 'div')) {\n const style = attribute(div, 'style') ?? ''\n if (!/display\\s*:\\s*none/i.test(style) && /(?:^|;)\\s*(?:max-)?width\\s*:/i.test(style)) {\n issue('layout-table', 'Outlook ignores <div> widths; size with a table cell')\n }\n }\n\n for (const name of ['p', 'h1', 'h2', 'h3', 'a', 'span']) {\n for (const tag of tags(visible, name)) {\n const style = attribute(tag, 'style') ?? ''\n if (!/(?:^|;)\\s*color\\s*:/i.test(style) || !/font-(?:family|size)\\s*:/i.test(style) && name !== 'a') {\n issue('inline-style', `<${name}> without inline color and font: ${tag.slice(0, 80)}`)\n }\n }\n }\n\n for (const img of tags(visible, 'img')) {\n // alt=\"\" is valid for a decorative image, such as a mark beside its own wordmark.\n if (attribute(img, 'alt') === null) issue('image', `Image without alt text: ${img.slice(0, 80)}`)\n if (!attribute(img, 'width') || !attribute(img, 'height')) issue('image', `Image without width and height: ${img.slice(0, 80)}`)\n const src = attribute(img, 'src') ?? ''\n if (!/^(?:https:|cid:)/.test(src)) issue('image', `Image source must be https: or cid: (${src.slice(0, 40)})`)\n }\n\n for (const anchor of tags(visible, 'a')) {\n const href = attribute(anchor, 'href') ?? ''\n if (!/^(?:https:\\/\\/|mailto:|http:\\/\\/(?:localhost|127\\.0\\.0\\.1)[:/])/.test(href)) {\n issue('link', `Links must be absolute https: ${href.slice(0, 60)}`)\n }\n }\n\n const bytes = new TextEncoder().encode(html).length\n if (bytes > GMAIL_CLIP_BYTES) issue('size', `${bytes} bytes; Gmail clips above ${GMAIL_CLIP_BYTES}`)\n return issues\n}\n"],"mappings":";AAEO,IAAM,yBACX;;;ACGK,IAAM,gBAAgB;AAAA,EAC3B,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,IACV,KAAK;AAAA,IACL,cAAc;AAAA,IACd,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,YAAY;AAAA,EACd;AAAA,EACA,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,IACV,KAAK;AAAA,IACL,cAAc;AAAA,IACd,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,YAAY;AAAA,EACd;AACF;AAOO,IAAM,mBACX;;;ACwDF,IAAM,kBAAkB;AACxB,IAAM,kBAAmC;AAAA,EACvC,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AAAA,EACb,WAAW;AACb;AAEA,IAAM,IAAI,cAAc;AACxB,IAAM,IAAI,cAAc;AACxB,IAAM,OAAO;AAKb,IAAM,QAAQ;AAAA;AAAA,8BAEgB,EAAE,MAAM;AAAA,gCACN,EAAE,IAAI,8BAA8B,EAAE,QAAQ;AAAA,gCAC9C,EAAE,IAAI;AAAA,4BACV,EAAE,QAAQ;AAAA,oBAClB,EAAE,GAAG;AAAA,qBACJ,EAAE,YAAY;AAAA,sBACb,EAAE,QAAQ;AAAA,qBACX,EAAE,UAAU;AAAA,4BACL,EAAE,QAAQ;AAAA;A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,UAAU,KAAK,QAAQ,EAAG,OAAM,SAAS,mCAAmC,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE;AAC/H,UAAM,MAAM,UAAU,KAAK,KAAK,KAAK;AACrC,QAAI,CAAC,mBAAmB,KAAK,GAAG,EAAG,OAAM,SAAS,wCAAwC,IAAI,MAAM,GAAG,EAAE,CAAC,GAAG;AAAA,EAC/G;AAEA,aAAW,UAAU,KAAK,SAAS,GAAG,GAAG;AACvC,UAAM,OAAO,UAAU,QAAQ,MAAM,KAAK;AAC1C,QAAI,CAAC,kEAAkE,KAAK,IAAI,GAAG;AACjF,YAAM,QAAQ,iCAAiC,KAAK,MAAM,GAAG,EAAE,CAAC,EAAE;AAAA,IACpE;AAAA,EACF;AAEA,QAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,IAAI,EAAE;AAC7C,MAAI,QAAQ,iBAAkB,OAAM,QAAQ,GAAG,KAAK,6BAA6B,gBAAgB,EAAE;AACnG,SAAO;AACT;","names":[]}
@@ -20,9 +20,12 @@
20
20
  * })
21
21
  * await resend.emails.send({ from: emailSender('GTM Agent', 'noreply@tangle.tools'), to, ...message })
22
22
  *
23
+ * Every field the message carries goes to the mail client, `headers`
24
+ * included: a footer `unsubscribeUrl` adds the RFC 8058 one-click headers.
25
+ *
23
26
  * `lintEmailHtml` checks rendered HTML against Gmail and Outlook constraints;
24
27
  * `emailPreviewHtml` embeds the inline images for a browser preview.
25
28
  */
26
- export { emailPreviewHtml, emailSender, type EmailAction, type EmailAttachment, type EmailFooter, type EmailItem, type EmailMessage, type EmailProduct, } from './layout';
29
+ export { emailPreviewHtml, emailSender, type EmailAction, type EmailAttachment, type EmailFooter, type EmailItem, type EmailMessage, type EmailProduct, type EmailSection, } from './layout';
27
30
  export { approvalEmail, digestEmail, inviteEmail, noticeEmail, type ApprovalEmailAction, type ApprovalEmailInput, type DigestEmailInput, type InviteEmailInput, type NoticeEmailInput, } from './templates';
28
31
  export { lintEmailHtml, type EmailLintIssue } from './lint';
@@ -6,7 +6,7 @@ import {
6
6
  inviteEmail,
7
7
  lintEmailHtml,
8
8
  noticeEmail
9
- } from "../chunk-TLVRBD2M.js";
9
+ } from "../chunk-5YSXPHGK.js";
10
10
  export {
11
11
  approvalEmail,
12
12
  digestEmail,
@@ -17,6 +17,12 @@ export interface EmailFooter {
17
17
  reason: string;
18
18
  /** Where the recipient changes which emails they get; absolute or app-relative. */
19
19
  manageUrl?: string;
20
+ /**
21
+ * Turns this kind of email off in one request, without signing in; absolute
22
+ * or app-relative. Adds an Unsubscribe link and the RFC 8058
23
+ * `List-Unsubscribe` headers, so the endpoint must accept a POST.
24
+ */
25
+ unsubscribeUrl?: string;
20
26
  /**
21
27
  * The sender's postal address, for marketing mail such as a digest. Leave it
22
28
  * unset on transactional mail (approvals, invites, sign-in), which does not
@@ -29,7 +35,7 @@ export interface EmailAction {
29
35
  label: string;
30
36
  url: string;
31
37
  }
32
- /** One row in the email's list box: an approval request or a digest entry. */
38
+ /** One row in a list box: an approval request or a digest entry. */
33
39
  export interface EmailItem {
34
40
  title: string;
35
41
  detail?: string;
@@ -53,6 +59,13 @@ export interface EmailMessage {
53
59
  text: string;
54
60
  /** Pass these through to the mail client; the header mark is one of them. */
55
61
  attachments: EmailAttachment[];
62
+ /** Extra message headers, such as `List-Unsubscribe`; pass them through too. */
63
+ headers: Record<string, string>;
64
+ }
65
+ /** A titled list box; a template with one list leaves `heading` unset. */
66
+ export interface EmailSection {
67
+ heading?: string;
68
+ items: readonly EmailItem[];
56
69
  }
57
70
  /** What a template places in the shared layout. */
58
71
  interface EmailContent {
@@ -60,7 +73,7 @@ interface EmailContent {
60
73
  preheader: string;
61
74
  title: string;
62
75
  paragraphs: readonly string[];
63
- items?: readonly EmailItem[];
76
+ sections?: readonly EmailSection[];
64
77
  primary?: EmailAction;
65
78
  secondary?: EmailAction;
66
79
  /** Print the primary link under the buttons for clients that strip them. */
@@ -1,4 +1,4 @@
1
- import { type EmailAction, type EmailFooter, type EmailItem, type EmailMessage, type EmailProduct } from './layout';
1
+ import { type EmailAction, type EmailFooter, type EmailMessage, type EmailProduct, type EmailSection } from './layout';
2
2
  /** One action an agent is waiting to run. */
3
3
  export interface ApprovalEmailAction {
4
4
  /** What runs, in plain language and sentence case: `Create agent “Quinn”`. */
@@ -39,15 +39,17 @@ export declare function inviteEmail(product: EmailProduct, input: InviteEmailInp
39
39
  /** Input for {@link digestEmail}. */
40
40
  export interface DigestEmailInput {
41
41
  workspaceName: string;
42
- /** The day the digest covers. */
42
+ /** The day the digest covers, in the workspace's own date. */
43
43
  date: Date;
44
- /** What happened, most important first. */
45
- items: readonly EmailItem[];
44
+ /** The most useful facts in a few words, for the subject and preview: `2 approvals waiting, 14 turns`. */
45
+ headline: string;
46
+ /** What happened and what waits, most important first; empty sections are left out. */
47
+ sections: readonly EmailSection[];
46
48
  /** Opens the workspace. */
47
49
  openUrl: string;
48
50
  footer: EmailFooter;
49
51
  }
50
- /** What happened in a workspace that day. */
52
+ /** What happened in a workspace over a day, and what waits on the recipient. */
51
53
  export declare function digestEmail(product: EmailProduct, input: DigestEmailInput): EmailMessage;
52
54
  /** Input for {@link noticeEmail}. */
53
55
  export interface NoticeEmailInput {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.59.5",
3
+ "version": "0.60.0",
4
4
  "packageManager": "pnpm@11.24.0",
5
5
  "description": "Build agent applications with typed chat, tools, sandboxes, integrations, billing, and evaluation.",
6
6
  "keywords": [
@@ -617,7 +617,7 @@
617
617
  "@tangle-network/agent-docs": "0.2.1",
618
618
  "@tangle-network/agent-eval": "0.209.1",
619
619
  "@tangle-network/agent-gateway": "0.11.4",
620
- "@tangle-network/agent-integrations": "0.67.0",
620
+ "@tangle-network/agent-integrations": "0.68.0",
621
621
  "@tangle-network/agent-interface": "3.1.1",
622
622
  "@tangle-network/agent-knowledge": "20.0.0",
623
623
  "@tangle-network/agent-profile-materialize": "0.22.0",
@@ -688,7 +688,7 @@
688
688
  "@firecrawl/pdf-inspector-wasm": ">=0.1.3",
689
689
  "@huggingface/transformers": ">=3",
690
690
  "@tangle-network/agent-eval": ">=0.199.0 <0.205.0 || >=0.205.1 <0.206.0 || >=0.209.1 <0.210.0",
691
- "@tangle-network/agent-integrations": ">=0.54.2 <0.58.0 || >=0.59.0 <0.61.0 || >=0.66.0 <0.67.0 || >=0.67.0 <0.68.0",
691
+ "@tangle-network/agent-integrations": ">=0.54.2 <0.58.0 || >=0.59.0 <0.61.0 || >=0.66.0 <0.67.0 || >=0.67.0 <0.68.0 || >=0.68.0 <0.69.0",
692
692
  "@tangle-network/agent-interface": "^2.13.0 || ^3.0.0",
693
693
  "@tangle-network/agent-knowledge": "^17.1.2 || ^18.0.0 || ^19.0.1 || ^20.0.0",
694
694
  "@tangle-network/agent-profile-materialize": ">=0.20.1 <0.21.0 || >=0.21.0 <0.22.0 || >=0.22.0 <0.23.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/email/mark.generated.ts","../src/email/palette.ts","../src/email/layout.ts","../src/email/templates.ts","../src/email/lint.ts"],"sourcesContent":["// GENERATED by scripts/email-mark.mjs from @tangle-network/brand TangleKnot; do not edit.\n/** The Tangle knot as a 84px transparent PNG (base64), shown at 28px in email headers. */\nexport const TANGLE_MARK_PNG_BASE64 =\n 'iVBORw0KGgoAAAANSUhEUgAAAFQAAABUCAYAAAAcaxDBAAAQAElEQVR4nOxcDZBV1X3//8+9971dVvkwEhR1GuvEatIY09hmOklTCU2bMQYnH3ZMTAmRZRdpqIAYgV3Iy35CgAUEBBGcBNskliSmTZqPjtox6dhJaGY61NFGpfEDSBRBgbjsvnfv+fd/P86959x73+5b9r26mdm/Luede+/5uP/zO//z/zjnCpikupKASaorTTK0zjTJ0DrTJEPrTJMMrTNNMrTOZMM4qWuxewsBXsVDcxEBzSQUBQAJ4VhxilHq/6sPHyY/SU+NIeYriFw6TMMnMC6Rfj5oFVVrOfWh+Wx0zUWiEyTwZeHR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n * The Brand roles the email layout paints with, as literal hex. Email clients\n * cannot read CSS variables, and importing `@tangle-network/brand` at runtime\n * would load React into a server-only renderer, so the values live here and\n * `tests/email/palette.test.ts` fails when they drift from Brand's `palettes`.\n */\nexport const EMAIL_PALETTE = {\n light: {\n canvas: '#eceef3',\n card: '#ffffff',\n well: '#f6f7fa',\n hairline: '#c7c6d6',\n ink: '#2d2d2d',\n inkSecondary: '#3f3f3f',\n inkMuted: '#4c4c4c',\n accent: '#4c3fc5',\n onAccent: '#ffffff',\n accentText: '#3c32e9',\n },\n dark: {\n canvas: '#0a0a14',\n card: '#191826',\n well: '#12111f',\n hairline: '#2a293d',\n ink: '#e6e6e6',\n inkSecondary: '#c7c7c7',\n inkMuted: '#b5b5b5',\n accent: '#4c3fc5',\n onAccent: '#ffffff',\n accentText: '#a5b4fc',\n },\n} as const\n\n/**\n * Brand's `--font-sans` stack with the system faces email clients actually\n * have. No client used for this mail loads web fonts reliably, so Inter shows\n * only where it is installed and the platform UI face carries the rest.\n */\nexport const EMAIL_FONT_STACK =\n \"Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif\"\n","import { TANGLE_MARK_PNG_BASE64 } from './mark.generated'\nimport { EMAIL_FONT_STACK, EMAIL_PALETTE } from './palette'\n\n/** The app an email comes from. */\nexport interface EmailProduct {\n /**\n * The product name, e.g. `GTM Agent`. The header reads `Tangle GTM Agent`;\n * subjects and the sender use the name alone. A name that already starts\n * with `Tangle` (`Tangle Sandbox`) is not doubled.\n */\n name: string\n /** The app's absolute origin; app-relative links resolve against it. */\n url: string\n}\n\n/** Why the recipient got the email and where they control it. */\nexport interface EmailFooter {\n /** The workspace the email concerns. */\n workspaceName?: string\n /** One sentence, e.g. `You own this workspace.` */\n reason: string\n /** Where the recipient changes which emails they get; absolute or app-relative. */\n manageUrl?: string\n /**\n * The sender's postal address, for marketing mail such as a digest. Leave it\n * unset on transactional mail (approvals, invites, sign-in), which does not\n * need one.\n */\n postalAddress?: string\n}\n\n/** A button. `url` is absolute or app-relative. */\nexport interface EmailAction {\n label: string\n url: string\n}\n\n/** One row in the email's list box: an approval request or a digest entry. */\nexport interface EmailItem {\n title: string\n detail?: string\n /** Makes the title a link; absolute or app-relative. */\n url?: string\n}\n\n/** An inline image the HTML references by `cid:`; the mail client must send it with the message. */\nexport interface EmailAttachment {\n filename: string\n /** Base64 file content, the form Resend and SES accept. */\n content: string\n contentType: string\n contentId: string\n}\n\n/** A rendered email, ready for any transport. */\nexport interface EmailMessage {\n subject: string\n /** The inbox preview line. */\n preheader: string\n html: string\n text: string\n /** Pass these through to the mail client; the header mark is one of them. */\n attachments: EmailAttachment[]\n}\n\n/** What a template places in the shared layout. */\ninterface EmailContent {\n subject: string\n preheader: string\n title: string\n paragraphs: readonly string[]\n items?: readonly EmailItem[]\n primary?: EmailAction\n secondary?: EmailAction\n /** Print the primary link under the buttons for clients that strip them. */\n showPrimaryLink?: boolean\n /** A short line under the buttons, e.g. an expiry. */\n note?: string\n footer: EmailFooter\n}\n\nconst MARK_CONTENT_ID = 'tangle-mark'\nconst MARK_ATTACHMENT: EmailAttachment = {\n filename: 'tangle.png',\n content: TANGLE_MARK_PNG_BASE64,\n contentType: 'image/png',\n contentId: MARK_CONTENT_ID,\n}\n\nconst L = EMAIL_PALETTE.light\nconst D = EMAIL_PALETTE.dark\nconst FONT = EMAIL_FONT_STACK\n\n// Inline styles carry the light design; this block only adapts it for clients\n// that honor dark mode or narrow screens. A client that drops <style> still\n// renders the complete light email.\nconst STYLE = `\n@media (prefers-color-scheme: dark) {\n .t-bg { background-color: ${D.canvas} !important; }\n .t-card { background-color: ${D.card} !important; border-color: ${D.hairline} !important; }\n .t-well { background-color: ${D.well} !important; }\n .t-rule { border-color: ${D.hairline} !important; }\n .t-ink { color: ${D.ink} !important; }\n .t-ink2 { color: ${D.inkSecondary} !important; }\n .t-muted { color: ${D.inkMuted} !important; }\n .t-link { color: ${D.accentText} !important; }\n .t-btn2 { border-color: ${D.hairline} !important; }\n}\n@media (max-width: 600px) {\n .t-outer { padding: 20px 8px !important; }\n .t-card { padding: 28px 22px 24px !important; }\n}\n[data-ogsb] .t-bg { background-color: ${D.canvas} !important; }\n[data-ogsb] .t-card { background-color: ${D.card} !important; }\n[data-ogsb] .t-well { background-color: ${D.well} !important; }\n[data-ogsc] .t-ink { color: ${D.ink} !important; }\n[data-ogsc] .t-ink2 { color: ${D.inkSecondary} !important; }\n[data-ogsc] .t-muted { color: ${D.inkMuted} !important; }\n[data-ogsc] .t-link { color: ${D.accentText} !important; }\n`.trim()\n\n/** Escape text for HTML element content and quoted attribute values. */\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;')\n}\n\n/** An absolute http(s) URL; app-relative paths resolve against the product origin. */\nfunction resolveEmailUrl(url: string, product: EmailProduct): string {\n const resolved = new URL(url, product.url)\n if (resolved.protocol !== 'https:' && resolved.protocol !== 'http:') {\n throw new TypeError(`Email links must be http(s): ${resolved.protocol}`)\n }\n return resolved.toString()\n}\n\n/** `Title — Product`, the one subject shape every Tangle email uses. */\nexport function emailSubject(subject: string, product: EmailProduct): string {\n return `${subject} — ${product.name}`\n}\n\nfunction paragraph(text: string, margin: string): string {\n return `<p class=\"t-ink2\" style=\"margin:${margin};font-family:${FONT};font-size:15px;line-height:24px;color:${L.inkSecondary}\">${escapeHtml(text)}</p>`\n}\n\nfunction link(label: string, href: string, style: string): string {\n return `<a class=\"t-link\" href=\"${escapeHtml(href)}\" style=\"color:${L.accentText};text-decoration:none;${style}\">${escapeHtml(label)}</a>`\n}\n\n/** The product name after the `Tangle` logotype: `GTM Agent`, or `Sandbox` for `Tangle Sandbox`. */\nfunction productSuffix(product: EmailProduct): string {\n return product.name.replace(/^Tangle\\s+/i, '')\n}\n\n// Brand's lockup: the knot, `Tangle` in the logotype's bold, then the product\n// name at a lighter weight, as the product site headers set it.\nfunction header(product: EmailProduct): string {\n const type = `font-family:${FONT};font-size:17px;line-height:20px;letter-spacing:-0.01em;color:${L.ink}`\n return [\n '<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">',\n '<tr>',\n `<td style=\"padding:0 10px 0 0;vertical-align:middle\"><img src=\"cid:${MARK_CONTENT_ID}\" width=\"28\" height=\"28\" alt=\"\" style=\"display:block;width:28px;height:28px;border:0;outline:none;text-decoration:none\"></td>`,\n `<td class=\"t-ink\" style=\"vertical-align:middle;white-space:nowrap;${type}\">`,\n `<span class=\"t-ink\" style=\"${type};font-weight:700\">Tangle</span>`,\n `<span class=\"t-ink\" style=\"${type};font-weight:500\">&nbsp;${escapeHtml(productSuffix(product))}</span>`,\n '</td>',\n '</tr>',\n '</table>',\n ].join('')\n}\n\nfunction items(list: readonly EmailItem[], product: EmailProduct): string {\n const rows = list.map((item, index) => {\n const rule = index === 0 ? '' : `border-top:1px solid ${L.hairline};`\n const title = item.url\n ? link(item.title, resolveEmailUrl(item.url, product), 'font-weight:600')\n : escapeHtml(item.title)\n const detail = item.detail\n ? `<p class=\"t-muted\" style=\"margin:2px 0 0;font-family:${FONT};font-size:13px;line-height:20px;color:${L.inkMuted}\">${escapeHtml(item.detail)}</p>`\n : ''\n return [\n `<tr><td class=\"t-rule\" style=\"padding:14px 16px;${rule}\">`,\n `<p class=\"t-ink\" style=\"margin:0;font-family:${FONT};font-size:15px;line-height:22px;font-weight:600;color:${L.ink}\">${title}</p>`,\n detail,\n '</td></tr>',\n ].join('')\n })\n return [\n `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"t-well\" bgcolor=\"${L.well}\" style=\"background-color:${L.well};border-radius:8px;margin:4px 0 8px\">`,\n ...rows,\n '</table>',\n ].join('')\n}\n\nfunction primaryButton(action: EmailAction, href: string): string {\n return [\n `<td bgcolor=\"${L.accent}\" style=\"border-radius:8px;background-color:${L.accent};mso-padding-alt:12px 22px\">`,\n `<a href=\"${escapeHtml(href)}\" style=\"display:inline-block;padding:12px 22px;font-family:${FONT};font-size:15px;line-height:20px;font-weight:600;color:${L.onAccent};text-decoration:none;border-radius:8px\">${escapeHtml(action.label)}</a>`,\n '</td>',\n ].join('')\n}\n\nfunction secondaryButton(action: EmailAction, href: string): string {\n return [\n `<td class=\"t-btn2\" style=\"border:1px solid ${L.hairline};border-radius:8px;mso-padding-alt:11px 21px\">`,\n `<a class=\"t-ink\" href=\"${escapeHtml(href)}\" style=\"display:inline-block;padding:11px 21px;font-family:${FONT};font-size:15px;line-height:20px;font-weight:600;color:${L.ink};text-decoration:none;border-radius:8px\">${escapeHtml(action.label)}</a>`,\n '</td>',\n ].join('')\n}\n\nfunction buttons(content: EmailContent, product: EmailProduct): string {\n const cells: string[] = []\n if (content.primary) cells.push(primaryButton(content.primary, resolveEmailUrl(content.primary.url, product)))\n if (content.secondary) {\n if (cells.length > 0) cells.push('<td style=\"width:10px;font-size:0;line-height:0\">&nbsp;</td>')\n cells.push(secondaryButton(content.secondary, resolveEmailUrl(content.secondary.url, product)))\n }\n if (cells.length === 0) return ''\n return `<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"margin:20px 0 0\"><tr>${cells.join('')}</tr></table>`\n}\n\nfunction small(html: string, margin: string, size = 13): string {\n return `<p class=\"t-muted\" style=\"margin:${margin};font-family:${FONT};font-size:${size}px;line-height:${size + 7}px;color:${L.inkMuted}\">${html}</p>`\n}\n\nfunction footerLines(footer: EmailFooter, product: EmailProduct): { html: string[]; text: string[] } {\n const where = footer.workspaceName ? `${footer.workspaceName} · ${product.name}` : product.name\n const manage = footer.manageUrl ? resolveEmailUrl(footer.manageUrl, product) : null\n const html = [\n escapeHtml(where),\n escapeHtml(footer.reason),\n ...(manage ? [link('Manage notifications', manage, 'text-decoration:underline')] : []),\n ...(footer.postalAddress ? [escapeHtml(footer.postalAddress)] : []),\n ]\n const text = [\n where,\n footer.reason,\n ...(manage ? [`Manage notifications: ${manage}`] : []),\n ...(footer.postalAddress ? [footer.postalAddress] : []),\n ]\n return { html, text }\n}\n\n// Keeps the body text that follows out of the inbox preview line.\nconst PREHEADER_SPACER = '&#847;&zwnj;&nbsp;'.repeat(40)\n\nfunction renderHtml(content: EmailContent, product: EmailProduct): string {\n const primaryHref = content.primary ? resolveEmailUrl(content.primary.url, product) : null\n const footer = footerLines(content.footer, product)\n const body = [\n `<h1 class=\"t-ink\" style=\"margin:0 0 12px;font-family:${FONT};font-size:22px;line-height:28px;font-weight:600;letter-spacing:-0.01em;color:${L.ink}\">${escapeHtml(content.title)}</h1>`,\n ...content.paragraphs.map((text) => paragraph(text, '0 0 12px')),\n content.items && content.items.length > 0 ? items(content.items, product) : '',\n buttons(content, product),\n content.showPrimaryLink && primaryHref\n ? small(`Or open this link: ${link(primaryHref, primaryHref, 'word-break:break-all')}`, '20px 0 0')\n : '',\n content.note ? small(escapeHtml(content.note), content.showPrimaryLink ? '8px 0 0' : '20px 0 0') : '',\n ].join('')\n\n return [\n '<!DOCTYPE html>',\n '<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\">',\n '<head>',\n '<meta charset=\"utf-8\">',\n '<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">',\n '<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">',\n '<meta name=\"x-apple-disable-message-reformatting\">',\n '<meta name=\"format-detection\" content=\"telephone=no, date=no, address=no, email=no, url=no\">',\n '<meta name=\"color-scheme\" content=\"light dark\">',\n '<meta name=\"supported-color-schemes\" content=\"light dark\">',\n `<title>${escapeHtml(content.subject)}</title>`,\n '<!--[if mso]><noscript><xml><o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml></noscript><![endif]-->',\n `<style>\\n${STYLE}\\n</style>`,\n '</head>',\n `<body class=\"t-bg\" style=\"margin:0;padding:0;width:100%;background-color:${L.canvas};-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%\">`,\n `<div style=\"display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden;mso-hide:all\">${escapeHtml(content.preheader)}${PREHEADER_SPACER}</div>`,\n `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"t-bg\" bgcolor=\"${L.canvas}\" style=\"background-color:${L.canvas}\">`,\n '<tr><td class=\"t-outer\" align=\"center\" style=\"padding:32px 12px\">',\n '<!--[if mso]><table role=\"presentation\" width=\"560\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\"><tr><td><![endif]-->',\n '<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"max-width:560px;margin:0 auto\">',\n `<tr><td style=\"padding:0 4px 20px\">${header(product)}</td></tr>`,\n `<tr><td class=\"t-card\" bgcolor=\"${L.card}\" style=\"background-color:${L.card};border:1px solid ${L.hairline};border-radius:12px;padding:36px 36px 32px\">${body}</td></tr>`,\n `<tr><td style=\"padding:24px 4px 0\">${footer.html.map((line, index) => small(line, index === 0 ? '0' : '4px 0 0', 12)).join('')}</td></tr>`,\n '</table>',\n '<!--[if mso]></td></tr></table><![endif]-->',\n '</td></tr>',\n '</table>',\n '</body>',\n '</html>',\n ].join('\\n')\n}\n\nfunction renderText(content: EmailContent, product: EmailProduct): string {\n const blocks: string[] = [`Tangle ${productSuffix(product)}`, content.title, ...content.paragraphs]\n if (content.items && content.items.length > 0) {\n blocks.push(content.items.map((item) => {\n const lines = [`- ${item.title}`]\n if (item.detail) lines.push(` ${item.detail}`)\n if (item.url) lines.push(` ${resolveEmailUrl(item.url, product)}`)\n return lines.join('\\n')\n }).join('\\n'))\n }\n const actions = [content.primary, content.secondary]\n .filter((action): action is EmailAction => Boolean(action))\n .map((action) => `${action.label}: ${resolveEmailUrl(action.url, product)}`)\n if (actions.length > 0) blocks.push(actions.join('\\n'))\n if (content.note) blocks.push(content.note)\n blocks.push(['--', ...footerLines(content.footer, product).text].join('\\n'))\n return `${blocks.join('\\n\\n')}\\n`\n}\n\n/** Place a template's content in the shared Tangle layout. */\nexport function renderEmail(product: EmailProduct, content: EmailContent): EmailMessage {\n return {\n subject: content.subject,\n preheader: content.preheader,\n html: renderHtml(content, product),\n text: renderText(content, product),\n attachments: [MARK_ATTACHMENT],\n }\n}\n\n/**\n * The HTML with inline images embedded as data URIs, for browser previews and\n * screenshots. Mail clients get `cid:` references and the attachments instead.\n */\nexport function emailPreviewHtml(message: Pick<EmailMessage, 'html' | 'attachments'>): string {\n return message.attachments.reduce(\n (html, attachment) => html.split(`cid:${attachment.contentId}`).join(`data:${attachment.contentType};base64,${attachment.content}`),\n message.html,\n )\n}\n\n/**\n * The From header for an app's mail: `GTM Agent · Tangle <noreply@tangle.tools>`.\n * The product leads because inbox sender columns truncate; `· Tangle` ties\n * every app to the company and the sending domain.\n */\nexport function emailSender(productName: string, address: string): string {\n if (!/^[^\\s<>@]+@[^\\s<>@]+\\.[^\\s<>@]+$/.test(address)) throw new TypeError(`Not an email address: ${address}`)\n const name = /\\bTangle\\b/i.test(productName) ? productName : `${productName} · Tangle`\n return `${name} <${address}>`\n}\n","import {\n emailSubject,\n renderEmail,\n type EmailAction,\n type EmailFooter,\n type EmailItem,\n type EmailMessage,\n type EmailProduct,\n} from './layout'\n\n/** Sentence case to mid-sentence: `Create agent` → `create agent`; acronyms such as `API key` keep their case. */\nfunction midSentence(text: string): string {\n const first = text.split(/\\s/, 1)[0] ?? ''\n if ((first.match(/[A-Z]/g) ?? []).length > 1) return text\n return text.charAt(0).toLowerCase() + text.slice(1)\n}\n\nfunction plural(count: number, one: string, many: string): string {\n return count === 1 ? one : many\n}\n\nfunction day(date: Date): string {\n return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' })\n}\n\n/** One action an agent is waiting to run. */\nexport interface ApprovalEmailAction {\n /** What runs, in plain language and sentence case: `Create agent “Quinn”`. */\n summary: string\n /** Where it runs and until when, e.g. `ph0ny · open until Oct 9, 3:40 PM UTC`. */\n detail?: string\n}\n\n/** Input for {@link approvalEmail}. */\nexport interface ApprovalEmailInput {\n /** At least one action, in the order the agent asked. */\n actions: readonly ApprovalEmailAction[]\n /** The conversation the agent paused in. */\n conversation?: string\n /** Opens the decision, e.g. the chat with the approval card. */\n approveUrl: string\n /** Opens the context, e.g. every request waiting in the workspace. */\n reviewUrl: string\n footer: EmailFooter\n}\n\n/**\n * An agent paused until someone approves what it wants to do. Neither button\n * decides anything: link scanners open email links, so both lead to the app,\n * where the signed-in owner approves.\n */\nexport function approvalEmail(product: EmailProduct, input: ApprovalEmailInput): EmailMessage {\n const [first, ...rest] = input.actions\n if (!first) throw new TypeError('approvalEmail needs at least one action')\n const what = rest.length === 0\n ? midSentence(first.summary)\n : `${midSentence(first.summary)} and ${rest.length} more`\n const where = input.conversation ? ` in “${input.conversation}”` : ''\n return renderEmail(product, {\n subject: emailSubject(`Approve: ${what}`, product),\n preheader: `The agent paused${where} until you decide.`,\n title: rest.length === 0 ? 'Approval needed' : `${input.actions.length} approvals needed`,\n paragraphs: [`The agent paused${where} until you decide. Nothing runs until you approve.`],\n items: input.actions.map((action): EmailItem => ({ title: action.summary, ...(action.detail ? { detail: action.detail } : {}) })),\n primary: { label: 'Approve', url: input.approveUrl },\n secondary: { label: 'Review', url: input.reviewUrl },\n footer: input.footer,\n })\n}\n\n/** Input for {@link inviteEmail}. */\nexport interface InviteEmailInput {\n workspaceName: string\n /** Who sent the invitation: a name or an email address. */\n inviter: string\n /** The role the invitation grants, e.g. `editor`. */\n role: string\n acceptUrl: string\n expiresAt: Date\n}\n\n/** Someone invited the recipient to a workspace. */\nexport function inviteEmail(product: EmailProduct, input: InviteEmailInput): EmailMessage {\n const role = input.role.toLowerCase()\n const article = /^[aeiou]/.test(role) ? 'an' : 'a'\n return renderEmail(product, {\n subject: emailSubject(`Join ${input.workspaceName}`, product),\n preheader: `${input.inviter} invited you to ${input.workspaceName}.`,\n title: `Join ${input.workspaceName}`,\n paragraphs: [`${input.inviter} invited you to ${input.workspaceName} on ${product.name} as ${article} ${role}.`],\n primary: { label: 'Accept invitation', url: input.acceptUrl },\n showPrimaryLink: true,\n note: `This invitation expires on ${day(input.expiresAt)}.`,\n footer: {\n workspaceName: input.workspaceName,\n reason: `You received this because ${input.inviter} invited this address.`,\n },\n })\n}\n\n/** Input for {@link digestEmail}. */\nexport interface DigestEmailInput {\n workspaceName: string\n /** The day the digest covers. */\n date: Date\n /** What happened, most important first. */\n items: readonly EmailItem[]\n /** Opens the workspace. */\n openUrl: string\n footer: EmailFooter\n}\n\n/** What happened in a workspace that day. */\nexport function digestEmail(product: EmailProduct, input: DigestEmailInput): EmailMessage {\n const count = input.items.length\n const updates = `${count} ${plural(count, 'update', 'updates')}`\n const date = input.date.toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric', timeZone: 'UTC' })\n return renderEmail(product, {\n subject: emailSubject(`${input.workspaceName}: ${updates}`, product),\n preheader: input.items[0]?.title ?? `Nothing new in ${input.workspaceName}.`,\n title: `What happened in ${input.workspaceName}`,\n paragraphs: [count === 0 ? `Nothing new on ${date}.` : `${updates} on ${date}.`],\n items: input.items,\n primary: { label: `Open ${product.name}`, url: input.openUrl },\n footer: input.footer,\n })\n}\n\n/** Input for {@link noticeEmail}. */\nexport interface NoticeEmailInput {\n /** Short; the product name is appended. */\n subject: string\n title: string\n /** One or two short paragraphs. */\n body: string | readonly string[]\n action?: EmailAction\n secondaryAction?: EmailAction\n /** Print the action's link too, for one-time links such as sign-in. */\n showLink?: boolean\n note?: string\n /** Inbox preview line. Defaults to the first paragraph. */\n preheader?: string\n footer: EmailFooter\n}\n\n/** Any other transactional message: one title, a short body and at most two buttons. */\nexport function noticeEmail(product: EmailProduct, input: NoticeEmailInput): EmailMessage {\n const paragraphs = typeof input.body === 'string' ? [input.body] : [...input.body]\n return renderEmail(product, {\n subject: emailSubject(input.subject, product),\n preheader: input.preheader ?? paragraphs[0] ?? input.title,\n title: input.title,\n paragraphs,\n ...(input.action ? { primary: input.action } : {}),\n ...(input.secondaryAction ? { secondary: input.secondaryAction } : {}),\n ...(input.showLink ? { showPrimaryLink: true } : {}),\n ...(input.note ? { note: input.note } : {}),\n footer: input.footer,\n })\n}\n","/** One way an email's HTML would break in Gmail or Outlook. */\nexport interface EmailLintIssue {\n rule:\n | 'document'\n | 'external-css'\n | 'style-block'\n | 'unsupported-element'\n | 'unsupported-css'\n | 'layout-table'\n | 'inline-style'\n | 'image'\n | 'link'\n | 'size'\n message: string\n}\n\n// Gmail clips a message body larger than about 102 KB behind \"View entire message\".\nconst GMAIL_CLIP_BYTES = 102_000\n\nconst tags = (html: string, name: string): string[] =>\n html.match(new RegExp(`<${name}\\\\b[^>]*>`, 'gi')) ?? []\n\nconst attribute = (tag: string, name: string): string | null => {\n const match = new RegExp(`\\\\s${name}=\"([^\"]*)\"`, 'i').exec(tag)\n return match ? match[1]! : null\n}\n\n/** Top-level rules of a stylesheet: their selector or at-rule preludes. */\nfunction preludes(css: string): string[] {\n const out: string[] = []\n let depth = 0\n let start = 0\n for (let i = 0; i < css.length; i++) {\n if (css[i] === '{') {\n if (depth === 0) out.push(css.slice(start, i).trim())\n depth++\n } else if (css[i] === '}') {\n depth--\n if (depth === 0) start = i + 1\n }\n }\n return out\n}\n\n/**\n * Check rendered email HTML against what Gmail and Outlook render: a complete\n * document, layout in presentation tables, styles inline (a `<style>` block may\n * only add dark-mode and narrow-screen overrides), images with alt text and\n * fixed size, absolute links, and a body small enough that Gmail does not clip.\n */\nexport function lintEmailHtml(html: string): EmailLintIssue[] {\n const issues: EmailLintIssue[] = []\n const issue = (rule: EmailLintIssue['rule'], message: string) => issues.push({ rule, message })\n const visible = html.replace(/<!--[\\s\\S]*?-->/g, '')\n\n if (!/^<!DOCTYPE html>/i.test(html)) issue('document', 'Missing <!DOCTYPE html>')\n if (!/<html\\b[^>]*\\slang=\"[^\"]+\"/i.test(html)) issue('document', 'Missing <html lang>')\n if (!/<meta charset=\"utf-8\">/i.test(html)) issue('document', 'Missing <meta charset=\"utf-8\">')\n if (!/<title>[^<]+<\\/title>/i.test(html)) issue('document', 'Missing <title>')\n\n if (/<link\\b[^>]*rel=\"?stylesheet/i.test(visible)) issue('external-css', 'Linked stylesheets are stripped')\n if (/@import\\b/i.test(visible)) issue('external-css', '@import is stripped')\n\n for (const block of visible.match(/<style\\b[^>]*>([\\s\\S]*?)<\\/style>/gi) ?? []) {\n const css = block.replace(/<\\/?style\\b[^>]*>/gi, '').replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n for (const prelude of preludes(css)) {\n if (!prelude.startsWith('@media') && !prelude.startsWith('[data-og')) {\n issue('style-block', `<style> may only hold overrides; \"${prelude}\" must be inline`)\n }\n }\n }\n\n for (const name of ['script', 'form', 'input', 'button', 'svg', 'iframe', 'video', 'audio', 'object', 'embed']) {\n if (tags(visible, name).length > 0) issue('unsupported-element', `<${name}> is stripped or unsupported`)\n }\n\n for (const pattern of [\n /display\\s*:\\s*(?:flex|grid|inline-flex)/i,\n /position\\s*:/i,\n /float\\s*:/i,\n /var\\(/i,\n /calc\\(/i,\n /rgba?\\(|hsla?\\(/i,\n /background-image\\s*:|url\\(/i,\n ]) {\n if (pattern.test(visible)) issue('unsupported-css', `Outlook does not render ${pattern.source}`)\n }\n\n for (const table of tags(visible, 'table')) {\n if (attribute(table, 'role') !== 'presentation') issue('layout-table', `Layout table without role=\"presentation\": ${table.slice(0, 80)}`)\n for (const name of ['cellpadding', 'cellspacing', 'border']) {\n if (attribute(table, name) !== '0') issue('layout-table', `Layout table without ${name}=\"0\": ${table.slice(0, 80)}`)\n }\n }\n for (const div of tags(visible, 'div')) {\n const style = attribute(div, 'style') ?? ''\n if (!/display\\s*:\\s*none/i.test(style) && /(?:^|;)\\s*(?:max-)?width\\s*:/i.test(style)) {\n issue('layout-table', 'Outlook ignores <div> widths; size with a table cell')\n }\n }\n\n for (const name of ['p', 'h1', 'h2', 'h3', 'a', 'span']) {\n for (const tag of tags(visible, name)) {\n const style = attribute(tag, 'style') ?? ''\n if (!/(?:^|;)\\s*color\\s*:/i.test(style) || !/font-(?:family|size)\\s*:/i.test(style) && name !== 'a') {\n issue('inline-style', `<${name}> without inline color and font: ${tag.slice(0, 80)}`)\n }\n }\n }\n\n for (const img of tags(visible, 'img')) {\n // alt=\"\" is valid for a decorative image, such as a mark beside its own wordmark.\n if (attribute(img, 'alt') === null) issue('image', `Image without alt text: ${img.slice(0, 80)}`)\n if (!attribute(img, 'width') || !attribute(img, 'height')) issue('image', `Image without width and height: ${img.slice(0, 80)}`)\n const src = attribute(img, 'src') ?? ''\n if (!/^(?:https:|cid:)/.test(src)) issue('image', `Image source must be https: or cid: (${src.slice(0, 40)})`)\n }\n\n for (const anchor of tags(visible, 'a')) {\n const href = attribute(anchor, 'href') ?? ''\n if (!/^(?:https:\\/\\/|mailto:|http:\\/\\/(?:localhost|127\\.0\\.0\\.1)[:/])/.test(href)) {\n issue('link', `Links must be absolute https: ${href.slice(0, 60)}`)\n }\n }\n\n const bytes = new TextEncoder().encode(html).length\n if (bytes > GMAIL_CLIP_BYTES) issue('size', `${bytes} bytes; Gmail clips above ${GMAIL_CLIP_BYTES}`)\n return issues\n}\n"],"mappings":";AAEO,IAAM,yBACX;;;ACGK,IAAM,gBAAgB;AAAA,EAC3B,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,IACV,KAAK;AAAA,IACL,cAAc;AAAA,IACd,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,YAAY;AAAA,EACd;AAAA,EACA,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,IACV,KAAK;AAAA,IACL,cAAc;AAAA,IACd,UA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