@postalsys/email-ai-tools 3.0.5 → 3.0.6

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.0.6](https://github.com/postalsys/email-ai-tools/compare/v3.0.5...v3.0.6) (2026-11-28)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * build the summary's view of a message with the HTML parser browsers follow ([32396e8](https://github.com/postalsys/email-ai-tools/commit/32396e8071939f1b8ecdd30e137dd455c2ed7861))
9
+ * close the seventeenth review's ways to leave visible text out of the summary ([22b302f](https://github.com/postalsys/email-ai-tools/commit/22b302f51a9c13364687bb6ae021af8efd3fedc8))
10
+ * count a style value as hiding only when it plainly is one ([78e42cf](https://github.com/postalsys/email-ai-tools/commit/78e42cfcf9428cbb3d4ccbeaf5b0448b560a0bc0))
11
+ * keep text a reader sees that 3.0.5 left out of the summary ([d6b5643](https://github.com/postalsys/email-ai-tools/commit/d6b56433e396484a939578aabf8054e83c871709))
12
+ * keep text a reader sees that 3.0.5 left out of the summary ([986eef8](https://github.com/postalsys/email-ai-tools/commit/986eef837b297721e5cc98416a387e41eb6a5b79))
13
+ * keep the text converter's tree the tree the summary's view was written from ([a8c57b1](https://github.com/postalsys/email-ai-tools/commit/a8c57b1b99a11f20688b1aef76c02b9d336bedd2))
14
+ * read a message's style sheets as strictly as a browser does ([e5272a3](https://github.com/postalsys/email-ai-tools/commit/e5272a3f3271b5d8bc26d5bdcc8fa2bb7535a150))
15
+ * read each style sheet on its own and match class names as browsers split them ([71ac479](https://github.com/postalsys/email-ai-tools/commit/71ac479f9a47737ee2c7bed6218f3d1bcdb154f4))
16
+ * read the font and all shorthands, and never read "none 'x'" as none ([aeca543](https://github.com/postalsys/email-ai-tools/commit/aeca543465d9704149c17fc3c76e3b1c9cd60052))
17
+ * write no element the text converter reads as raw text ([36a4646](https://github.com/postalsys/email-ai-tools/commit/36a4646a2715935bea2141028c0be6c3695eb492))
18
+ * write SVG and MathML elements out as spans for the text converter ([866471e](https://github.com/postalsys/email-ai-tools/commit/866471eed525fc5f03c6d259b0498298ede12d5d))
19
+ * write the summary's view of a message out with the parser's own serializer ([54066af](https://github.com/postalsys/email-ai-tools/commit/54066afcf9ab82efa0f93cdc6b72b093f5d9f35b))
20
+
3
21
  ## [3.0.5](https://github.com/postalsys/email-ai-tools/compare/v3.0.4...v3.0.5) (2026-11-28)
4
22
 
5
23
 
package/README.md CHANGED
@@ -86,9 +86,10 @@ A parameter the backend refuses with a 400 that names it (`response_format`, `re
86
86
  The email is untrusted input, and the library does not leave its verdict to the model alone:
87
87
 
88
88
  - **The model reads the part the recipient sees.** When a message has an HTML part, that is what is read, however long the plain text beside it: a sender writes both, and a plain part no mail client shows is where text meant only for the model would go. The plain text is read only when there is no HTML, or the HTML has no text at all.
89
- - **Hidden text is removed.** Elements a mail client does not render (`display:none`, `visibility:hidden`, a font size below a pixel, an opacity below a tenth, a far negative text indent, a block-level box of no height that clips its content, the `hidden` attribute, scripts, styles, comments) are dropped before the HTML is converted, and zero-width, soft-hyphen and bidirectional control characters are removed from the text. The model reads what the recipient sees. An element hidden only by an inherited property (visibility, font size, text indent) is kept when something inside it sets that property again, as email templates do with a `font-size:0` wrapper.
90
- - **Style sheets count only when they can be read faithfully.** The message's own `<style>` rules are weighed with the `style` attributes the way a mail client weighs them: by specificity, then by their place in the sheet, the attribute after the rules, and `!important` declarations after all of those. A leading `html` or `body` before a descendant combinator matches as if both were present. Removing text a reader sees would be worse than leaving in text they do not, so the sheets count for nothing, and only `style` attributes do, whenever a rule that could show an element again cannot be read: a pseudo-class or a sibling combinator, a media query that does not hold for every reader, another at-rule, an `@import` or a linked style sheet, a sheet in a conditional comment, an escaped property name, more than 100 such rules, or matching them all would cost more than a fixed budget. The same happens where the parser here and a browser could disagree about which style elements exist: inside SVG or MathML, inside an element a browser reads as text (`noframes`, `noembed`, `iframe`, `noscript`, after `plaintext`), or after a comment a browser ends earlier (`--!>`, a CDATA section), and when the document is cut short.
91
- - **Conditional comments are read as the clients read them.** Outlook-only content (`<!--[if mso]>...<![endif]-->`) is kept, and the downlevel-revealed form email builders write (`<!--[if !mso]><!-->...<!--<![endif]-->`) keeps the content between its two comments. Comments end where a browser ends them.
89
+ - **Hidden text is removed.** Elements a mail client does not render (`display:none`, `visibility:hidden`, a font size below a pixel, an opacity of zero, a block-level box of no height that clips its content, the `hidden` attribute, scripts, styles, comments) are dropped before the HTML is converted, and zero-width, soft-hyphen and bidirectional control characters are removed from the text. The model reads what the recipient sees. An element hidden only by an inherited property (visibility, font size) is kept when something inside it sets that property again, as email templates do with a `font-size:0` wrapper, and a table or a form control counts as setting the font size again, as browsers do. A box of no height counts only on a block-level element, never on the root, the body, a fieldset, a dialog or a form control, and is kept when something inside it is positioned `absolute` or `fixed` or the clipping is undone. A negative text indent is not treated as hiding: it moves the first line only. A value counts as hiding only when it plainly is one (`none`, an exact zero); any other value, one computed with `calc()` or `var()`, a keyword or one a browser rejects, keeps the text, and declarations are split where CSS splits them.
90
+ - **The document is built the way a browser builds it.** The HTML is parsed with parse5, the parser that follows the HTML standard browsers implement, so paragraphs close, tables get their `tbody`, stray content moves out of tables and raw text stays text exactly where a mail client does it. Nesting past 500 levels is left out.
91
+ - **Style sheets count only when they can be read faithfully.** The message's own `<style>` rules are weighed with the `style` attributes the way a mail client weighs them: by specificity, then by their place in the sheet, the attribute after the rules, and `!important` declarations after all of those. Removing text a reader sees would be worse than leaving in text they do not, so the sheets count for nothing, and only `style` attributes do, whenever a rule that could show an element again cannot be read: a pseudo-class or a sibling combinator, a selector on the root or body's children (a webmail shows the message inside a page of its own), a media query that does not hold for every reader, another at-rule, an `@import` or a linked style sheet, a sheet in a conditional comment or in `noscript`, an escaped property name, SVG or MathML, more than 100 such rules, or matching them all would cost more than a fixed budget. A document in quirks mode is shown in quirks mode by a client that renders it as its own page and in standards mode by a webmail, so there mixed-case class or id names and a paragraph around a table leave the sheets unread too, as does a document cut short. When the sheets are not read, a `style` attribute still hides only when nothing unread could override it (no `!`, no `@import`, no linked sheet), and the `hidden` attribute only when no sheet sets a display.
92
+ - **Conditional comments are read as the clients read them.** Outlook-only content (`<!--[if mso]>...<![endif]-->`) is kept, parsed on its own so nothing it leaves open reaches past it, unless it opens a comment of its own, and the downlevel-revealed form email builders write (`<!--[if !mso]><!-->...<!--<![endif]-->`) keeps the content between its two comments. Comments end where a browser ends them.
92
93
  - **The work is bounded.** At most 1 MB of HTML and 128 KB of style sheets is read, elements nested more than 500 deep are left out (as the text converter would leave them out), and the style sheet rules are applied only while the estimated cost of matching them stays under a fixed budget. A hostile message costs about as much as an ordinary large one.
93
94
  - **Signals are collected in code**, on the full message and before anything is removed, and the ones that carry a floor are passed to the model as `signals`: an executable or double-extension attachment (by extension or content type, after the name is normalised), an attachment a browser runs code from (HTML, SVG), a link whose text names a different host than its target (links read the way a browser does, hidden links included, image alt text counted as link text), a lookalike domain mixing scripts (a Cyrillic letter inside `paypal.com`, in unicode, punycode or percent encoding), a display name that reads as an address on another domain, a reply address on another domain, and a verified authentication failure. Each carries a quoted, cleaned detail.
94
95
  - **The risk score has a floor.** After the model answers, `riskAssessment.risk` is raised to the floor of the signals found (4 for an executable attachment or a lookalike domain, 3 for a link mismatch, a scriptable attachment, a display name address or a failed authentication, 2 for a reply address elsewhere), the assessment says what was found, and `riskAssessment.signals` lists the codes. That list is always what the code found, an empty one when nothing was, whatever the model wrote there. A model talked into "risk 1" by text inside the message still delivers a 4 when the attachment is an executable. When the model's answer cannot be parsed, or the prompt cannot be fitted into the token budget, the error carries the signals.