@postalsys/email-ai-tools 1.13.5 → 1.13.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/.github/codeql/codeql-config.yml +11 -0
- package/.github/workflows/codeql.yml +48 -0
- package/.github/workflows/release.yaml +2 -2
- package/.github/workflows/test.yaml +15 -6
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +7 -0
- package/CLAUDE.md +125 -0
- package/SECURITY.md +79 -0
- package/package.json +5 -5
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
name: "email-ai-tools CodeQL config"
|
|
2
|
+
|
|
3
|
+
# Exclude code that is not part of the published library runtime from analysis.
|
|
4
|
+
# These paths generate only false-positive noise:
|
|
5
|
+
# - tests and their mock server intentionally use fixed local URLs and
|
|
6
|
+
# simplified handlers that are not production code
|
|
7
|
+
# - examples are standalone usage snippets, not part of the package
|
|
8
|
+
paths-ignore:
|
|
9
|
+
- test
|
|
10
|
+
- '**/test/**'
|
|
11
|
+
- examples
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: "CodeQL Advanced"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "master" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "master" ]
|
|
8
|
+
schedule:
|
|
9
|
+
- cron: '40 17 * * 6'
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
analyze:
|
|
13
|
+
name: Analyze (${{ matrix.language }})
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
permissions:
|
|
16
|
+
# required for all workflows
|
|
17
|
+
security-events: write
|
|
18
|
+
|
|
19
|
+
# required to fetch internal or private CodeQL packs
|
|
20
|
+
packages: read
|
|
21
|
+
|
|
22
|
+
# only required for workflows in private repositories
|
|
23
|
+
actions: read
|
|
24
|
+
contents: read
|
|
25
|
+
|
|
26
|
+
strategy:
|
|
27
|
+
fail-fast: false
|
|
28
|
+
matrix:
|
|
29
|
+
include:
|
|
30
|
+
- language: actions
|
|
31
|
+
build-mode: none
|
|
32
|
+
- language: javascript-typescript
|
|
33
|
+
build-mode: none
|
|
34
|
+
steps:
|
|
35
|
+
- name: Checkout repository
|
|
36
|
+
uses: actions/checkout@v4
|
|
37
|
+
|
|
38
|
+
- name: Initialize CodeQL
|
|
39
|
+
uses: github/codeql-action/init@v4
|
|
40
|
+
with:
|
|
41
|
+
languages: ${{ matrix.language }}
|
|
42
|
+
build-mode: ${{ matrix.build-mode }}
|
|
43
|
+
config-file: ./.github/codeql/codeql-config.yml
|
|
44
|
+
|
|
45
|
+
- name: Perform CodeQL Analysis
|
|
46
|
+
uses: github/codeql-action/analyze@v4
|
|
47
|
+
with:
|
|
48
|
+
category: "/language:${{matrix.language}}"
|
|
@@ -6,15 +6,23 @@ on:
|
|
|
6
6
|
pull_request:
|
|
7
7
|
branches: [master]
|
|
8
8
|
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
concurrency:
|
|
13
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
14
|
+
cancel-in-progress: true
|
|
15
|
+
|
|
9
16
|
jobs:
|
|
10
17
|
test:
|
|
11
|
-
runs-on: ubuntu-
|
|
18
|
+
runs-on: ubuntu-24.04
|
|
19
|
+
timeout-minutes: 10
|
|
12
20
|
strategy:
|
|
13
21
|
matrix:
|
|
14
22
|
node-version: [22, 24]
|
|
15
23
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
17
|
-
- uses: actions/setup-node@
|
|
24
|
+
- uses: actions/checkout@v6
|
|
25
|
+
- uses: actions/setup-node@v6
|
|
18
26
|
with:
|
|
19
27
|
node-version: ${{ matrix.node-version }}
|
|
20
28
|
cache: 'npm'
|
|
@@ -22,10 +30,11 @@ jobs:
|
|
|
22
30
|
- run: npm test
|
|
23
31
|
|
|
24
32
|
lint:
|
|
25
|
-
runs-on: ubuntu-
|
|
33
|
+
runs-on: ubuntu-24.04
|
|
34
|
+
timeout-minutes: 10
|
|
26
35
|
steps:
|
|
27
|
-
- uses: actions/checkout@
|
|
28
|
-
- uses: actions/setup-node@
|
|
36
|
+
- uses: actions/checkout@v6
|
|
37
|
+
- uses: actions/setup-node@v6
|
|
29
38
|
with:
|
|
30
39
|
node-version: 24
|
|
31
40
|
cache: 'npm'
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.13.6](https://github.com/postalsys/email-ai-tools/compare/v1.13.5...v1.13.6) (2026-06-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* refresh dependencies and add project tooling ([2e3955e](https://github.com/postalsys/email-ai-tools/commit/2e3955e071dd96afa3a44413db7978302704048c))
|
|
9
|
+
|
|
3
10
|
## [1.13.5](https://github.com/postalsys/email-ai-tools/compare/v1.13.4...v1.13.5) (2026-05-29)
|
|
4
11
|
|
|
5
12
|
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Claude Development Guidelines
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
`@postalsys/email-ai-tools` is a Node.js library that adds AI/LLM features on top
|
|
6
|
+
of parsed email data. It talks to OpenAI-compatible HTTP APIs (chat completions,
|
|
7
|
+
text completions, embeddings, model listing) to summarize messages, score them
|
|
8
|
+
for risk, generate vector embeddings, and answer questions over stored email.
|
|
9
|
+
|
|
10
|
+
It is published to npm and consumed by other Postal Systems projects - most
|
|
11
|
+
notably EmailEngine (`../emailengine`), where it ships inside a standalone binary
|
|
12
|
+
built with `@yao-pkg/pkg`. See **Packaging Compatibility** below; it constrains
|
|
13
|
+
which dependencies this library may use.
|
|
14
|
+
|
|
15
|
+
## Project Structure
|
|
16
|
+
|
|
17
|
+
- `index.js` - Public entry point; re-exports the functions listed below
|
|
18
|
+
- `/lib` - Implementation modules (one feature per file)
|
|
19
|
+
- `/test` - Tests using the Node.js native test runner (`*.test.js`)
|
|
20
|
+
- `/test/helpers/mock-server.js` - Local mock of the OpenAI-compatible API used by tests
|
|
21
|
+
- `/examples` - Standalone usage examples (excluded from lint and CodeQL)
|
|
22
|
+
|
|
23
|
+
### Library Modules
|
|
24
|
+
|
|
25
|
+
- `lib/generate-summary.js` - `generateSummary()` plus `DEFAULT_SYSTEM_PROMPT` /
|
|
26
|
+
`DEFAULT_USER_PROMPT`; produces a natural-language summary of a message.
|
|
27
|
+
- `lib/risk-analysis.js` - `riskAnalysis()`; flags suspicious/risky email content.
|
|
28
|
+
- `lib/generate-embeddings.js` - `generateEmbeddings()` / `getChunkEmbeddings()`;
|
|
29
|
+
splits message text into chunks and returns vector embeddings.
|
|
30
|
+
- `lib/embeddings-query.js` - `embeddingsQuery()` / `questionQuery()`; answers
|
|
31
|
+
questions over a set of emails using embeddings and chat completions.
|
|
32
|
+
- `lib/list-models.js` - `listModels()`; lists models exposed by the API endpoint.
|
|
33
|
+
|
|
34
|
+
## Technology Stack
|
|
35
|
+
|
|
36
|
+
- **Runtime**: Node.js (CI tests on 22 and 24). No build step - plain CommonJS.
|
|
37
|
+
- **Module system**: CommonJS (`'use strict';`, `require`/`module.exports`).
|
|
38
|
+
- **HTTP**: `undici` (`fetch` + `Agent`) for all outbound API calls.
|
|
39
|
+
- **Tokenizing**: `gpt3-tokenizer` for token-count budgeting.
|
|
40
|
+
- **Email/text helpers**: `@postalsys/email-text-tools`, `libmime`,
|
|
41
|
+
`nodemailer/lib/addressparser`, `linkify-it`, `tlds`, `punycode.js`.
|
|
42
|
+
|
|
43
|
+
## Development Commands
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
npm test # Run the test suite (node --test test/*.test.js)
|
|
47
|
+
npm run lint # Lint with ESLint
|
|
48
|
+
npm run format # Format code with Prettier
|
|
49
|
+
npm run update # Refresh deps: remove node_modules + lockfile, ncu -u, npm install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Testing
|
|
53
|
+
|
|
54
|
+
- Uses the Node.js native test runner with the native `assert` module.
|
|
55
|
+
- Tests live in `/test` and must be named `*.test.js` - the runner glob only
|
|
56
|
+
matches that pattern, so helpers (e.g. `test/helpers/mock-server.js`) are never
|
|
57
|
+
picked up as test files.
|
|
58
|
+
- Tests are hermetic: they run against the in-process mock server in
|
|
59
|
+
`test/helpers/mock-server.js` rather than calling real OpenAI endpoints. Do not
|
|
60
|
+
add tests that require live API credentials or network access.
|
|
61
|
+
- Run `npm test` before committing and make sure it passes.
|
|
62
|
+
|
|
63
|
+
## Packaging Compatibility (important)
|
|
64
|
+
|
|
65
|
+
EmailEngine bundles this library into a single executable with `@yao-pkg/pkg`.
|
|
66
|
+
`pkg` snapshots the CommonJS `require` graph at build time, so **every dependency
|
|
67
|
+
must be CommonJS-compatible**. Do not introduce pure-ESM-only packages or
|
|
68
|
+
ESM-only versions of existing packages.
|
|
69
|
+
|
|
70
|
+
- New ESM-only majors are blocked in `.ncurc.js` via the `reject` list (e.g.
|
|
71
|
+
`nanoid` moved to ESM and is pinned).
|
|
72
|
+
- `undici` is pinned to the 7.x line; 8.x requires Node >= 22.19.
|
|
73
|
+
- When `npm run update` proposes an upgrade, confirm the new version still
|
|
74
|
+
publishes a CommonJS build and still loads under `require()` before accepting
|
|
75
|
+
it. If a package goes ESM-only, add it to the `reject` list in `.ncurc.js` with
|
|
76
|
+
a one-line comment explaining why.
|
|
77
|
+
|
|
78
|
+
## Dependency Management
|
|
79
|
+
|
|
80
|
+
- Use `npm run update` to bump dependencies (it runs `ncu -u` then a clean
|
|
81
|
+
install). Respect the `reject` list in `.ncurc.js`.
|
|
82
|
+
- After updating, run `npm test`, `npm run lint`, and
|
|
83
|
+
`npx prettier --check "**/*.{js,json,md}"` to confirm nothing broke.
|
|
84
|
+
- Keep `package.json` versions exact (no `^`/`~` ranges) to match the existing
|
|
85
|
+
convention and keep `pkg` builds reproducible.
|
|
86
|
+
|
|
87
|
+
## Versioning & Releases
|
|
88
|
+
|
|
89
|
+
- Releases are automated with **release-please** (`.github/workflows/release.yaml`).
|
|
90
|
+
Merging Conventional Commit messages to `master` opens/updates a release PR;
|
|
91
|
+
merging that PR tags the version, updates `CHANGELOG.md`, and publishes to npm
|
|
92
|
+
with provenance.
|
|
93
|
+
- Commit prefixes drive the version bump: `fix:` -> patch, `feat:` -> minor,
|
|
94
|
+
`feat!:` / `BREAKING CHANGE:` -> major.
|
|
95
|
+
|
|
96
|
+
## Code Style Rules
|
|
97
|
+
|
|
98
|
+
- CommonJS only - every module starts with `'use strict';` and uses
|
|
99
|
+
`require`/`module.exports`. No `import`/`export`.
|
|
100
|
+
- Never use emojis in code or documentation; printable ASCII characters only.
|
|
101
|
+
- Use a single hyphen-minus (`-`) as a dash in user-facing strings and docs.
|
|
102
|
+
Never use double hyphens (`--`), em dashes, or en dashes.
|
|
103
|
+
- Formatting is owned by Prettier and linting by ESLint - run both before
|
|
104
|
+
committing; do not hand-format against them.
|
|
105
|
+
- **Git commit messages: do not list Claude (or any AI) as a co-author or
|
|
106
|
+
contributor.** Write commit messages in the project's own voice.
|
|
107
|
+
- Use Conventional Commit prefixes so release-please works (`fix:`, `feat:`,
|
|
108
|
+
`chore:`, `docs:`, `test:`, `ci:`, `refactor:`).
|
|
109
|
+
- For commits that do not change runtime behavior (docs, comments, CI/workflow
|
|
110
|
+
tweaks, formatting), append `[skip ci]` to the commit message to avoid
|
|
111
|
+
triggering the GitHub Actions workflows. Exception: do not add `[skip ci]` to
|
|
112
|
+
commits using a `fix:` or `feat:` prefix - those must run so the release action
|
|
113
|
+
is triggered.
|
|
114
|
+
|
|
115
|
+
## Workflow After Making Changes
|
|
116
|
+
|
|
117
|
+
1. Run `npm run format` and `npm run lint`.
|
|
118
|
+
2. Run `npm test` and confirm it passes.
|
|
119
|
+
3. Review changed code for reuse, quality, and efficiency (`/simplify`), and run
|
|
120
|
+
`/security-review` for anything touching parsing, prompts, or outbound HTTP.
|
|
121
|
+
4. After pushing, check the GitHub Actions runs (e.g. `gh run list --branch master`)
|
|
122
|
+
and report their status, including the CodeQL ("code quality") results. If a
|
|
123
|
+
run fails for an unrelated infrastructure reason (checkout reporting "account
|
|
124
|
+
suspended", HTTP 403, other auth errors), check https://www.githubstatus.com/
|
|
125
|
+
for an active GitHub incident before assuming the code is at fault.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
`@postalsys/email-ai-tools` is a Node.js library that processes email content and
|
|
4
|
+
forwards it to OpenAI-compatible AI APIs to generate summaries, risk assessments,
|
|
5
|
+
embeddings, and question answers. Because it parses untrusted email data and
|
|
6
|
+
handles API credentials passed in by the caller, we take security reports
|
|
7
|
+
seriously and aim to respond quickly.
|
|
8
|
+
|
|
9
|
+
## Supported Versions
|
|
10
|
+
|
|
11
|
+
Security fixes are released only against the latest version. We do not backport
|
|
12
|
+
patches to older releases - upgrading to the current release line is the
|
|
13
|
+
supported way to receive security updates.
|
|
14
|
+
|
|
15
|
+
| Version | Supported |
|
|
16
|
+
| ------- | ------------------ |
|
|
17
|
+
| 1.x | :white_check_mark: |
|
|
18
|
+
| < 1.0 | :x: |
|
|
19
|
+
|
|
20
|
+
If you are on an older version, please upgrade. See the release notes at
|
|
21
|
+
<https://github.com/postalsys/email-ai-tools/releases> before updating.
|
|
22
|
+
|
|
23
|
+
## Reporting a Vulnerability
|
|
24
|
+
|
|
25
|
+
**Please do not report security vulnerabilities through public GitHub issues,
|
|
26
|
+
pull requests, or discussions.**
|
|
27
|
+
|
|
28
|
+
Report privately through one of the following channels:
|
|
29
|
+
|
|
30
|
+
1. **GitHub Security Advisories (preferred).** Open a private report at
|
|
31
|
+
<https://github.com/postalsys/email-ai-tools/security/advisories/new>. This
|
|
32
|
+
keeps the discussion private until a fix is published and lets us credit you.
|
|
33
|
+
2. **Email.** Send details to **andris@postalsys.com**. Encrypt sensitive details
|
|
34
|
+
if possible.
|
|
35
|
+
|
|
36
|
+
When reporting, please include as much of the following as you can:
|
|
37
|
+
|
|
38
|
+
- The affected version(s) and environment (library version, Node.js version, OS).
|
|
39
|
+
- The function involved (e.g. `generateSummary`, `riskAnalysis`,
|
|
40
|
+
`generateEmbeddings`, `embeddingsQuery`, `questionQuery`, `listModels`).
|
|
41
|
+
- A clear description of the issue and its impact (e.g. prompt injection that
|
|
42
|
+
escalates privileges in a consuming application, credential or API-token
|
|
43
|
+
disclosure, SSRF via a configurable API base URL, injection, information
|
|
44
|
+
disclosure, denial of service through unbounded input).
|
|
45
|
+
- A minimal proof of concept or reproduction steps.
|
|
46
|
+
- Any suggested remediation, if you have one.
|
|
47
|
+
|
|
48
|
+
We are a small team, so there is no guaranteed response time - sometimes reports
|
|
49
|
+
are handled within hours, sometimes they take longer. Accepted issues are fixed
|
|
50
|
+
in a new release and coordinated through a GitHub Security Advisory, and reporters
|
|
51
|
+
who wish to be named are credited.
|
|
52
|
+
|
|
53
|
+
## CVEs
|
|
54
|
+
|
|
55
|
+
We track and disclose vulnerabilities through GitHub Security Advisories. We do
|
|
56
|
+
not request or manage CVE identifiers ourselves. If you need a CVE assigned for a
|
|
57
|
+
reported issue, please request one yourself - for example, through GitHub's own
|
|
58
|
+
CVE request flow on the published advisory, or another CNA.
|
|
59
|
+
|
|
60
|
+
## Scope
|
|
61
|
+
|
|
62
|
+
In scope: the library source in this repository - email parsing and text
|
|
63
|
+
extraction, prompt construction, token budgeting, and the outbound HTTP calls to
|
|
64
|
+
OpenAI-compatible endpoints (including handling of the caller-supplied API token
|
|
65
|
+
and the configurable API base URL).
|
|
66
|
+
|
|
67
|
+
Out of scope:
|
|
68
|
+
|
|
69
|
+
- Vulnerabilities in your own application code that integrates with this library.
|
|
70
|
+
- The behavior, content, or safety of the AI models and API providers this
|
|
71
|
+
library connects to (OpenAI or any OpenAI-compatible endpoint you configure).
|
|
72
|
+
- Model "hallucinations" or undesirable AI output that does not stem from a code
|
|
73
|
+
defect in this library.
|
|
74
|
+
- Misuse such as passing untrusted endpoints as the API base URL, leaking your
|
|
75
|
+
own API tokens, or exposing the library's output to untrusted parties.
|
|
76
|
+
- Social-engineering reports and theoretical issues without a demonstrated,
|
|
77
|
+
concrete impact.
|
|
78
|
+
|
|
79
|
+
Thank you for helping keep email-ai-tools and its users safe.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postalsys/email-ai-tools",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.6",
|
|
4
4
|
"description": "Email AI tools",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@eslint/eslintrc": "3.3.5",
|
|
25
25
|
"@eslint/js": "10.0.1",
|
|
26
|
-
"eslint": "10.
|
|
26
|
+
"eslint": "10.5.0",
|
|
27
27
|
"eslint-config-nodemailer": "1.2.0",
|
|
28
28
|
"eslint-config-prettier": "10.1.8",
|
|
29
29
|
"mailparser": "3.9.9",
|
|
30
|
-
"prettier": "3.8.
|
|
30
|
+
"prettier": "3.8.4"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@postalsys/email-text-tools": "2.4.
|
|
33
|
+
"@postalsys/email-text-tools": "2.4.7",
|
|
34
34
|
"gpt3-tokenizer": "1.1.5",
|
|
35
35
|
"libmime": "5.3.8",
|
|
36
36
|
"linkify-it": "5.0.1",
|
|
37
|
-
"nodemailer": "
|
|
37
|
+
"nodemailer": "9.0.0",
|
|
38
38
|
"punycode.js": "2.3.1",
|
|
39
39
|
"tlds": "1.261.0",
|
|
40
40
|
"undici": "7.25.0"
|