@postalsys/email-ai-tools 2.0.0 → 2.1.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.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +7 -0
- package/CLAUDE.md +2 -1
- package/README.md +3 -1
- package/index.js +14 -2
- package/lib/generate-summary.js +15 -4
- package/lib/token-estimate.js +1 -1
- package/package.json +1 -1
- package/test/index.test.js +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.1.0](https://github.com/postalsys/email-ai-tools/compare/v2.0.0...v2.1.0) (2026-10-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* export the header whitelist, the reasoning effort levels and the token budget default ([f52882a](https://github.com/postalsys/email-ai-tools/commit/f52882a04227dc55a00da238b9db6df3ea48ec1c))
|
|
9
|
+
|
|
3
10
|
## [2.0.0](https://github.com/postalsys/email-ai-tools/compare/v1.14.14...v2.0.0) (2026-10-01)
|
|
4
11
|
|
|
5
12
|
|
package/CLAUDE.md
CHANGED
|
@@ -38,7 +38,8 @@ which dependencies this library may use.
|
|
|
38
38
|
serves, newest family first (`chatOnly: false` keeps the rest).
|
|
39
39
|
- `lib/api-request.js` - shared HTTP request helper (size cap, JSON parsing, 429
|
|
40
40
|
retry with Retry-After, error shaping) used by every API call.
|
|
41
|
-
- `lib/token-estimate.js` - character-based token estimate
|
|
41
|
+
- `lib/token-estimate.js` - character-based token estimate and prompt fitting against
|
|
42
|
+
a budget that covers the fixed parts of the prompt too.
|
|
42
43
|
|
|
43
44
|
## Technology Stack
|
|
44
45
|
|
package/README.md
CHANGED
|
@@ -107,7 +107,9 @@ Models that are not chat models are left out unless `chatOnly: false` is set. On
|
|
|
107
107
|
|
|
108
108
|
## Other exports
|
|
109
109
|
|
|
110
|
-
`DEFAULT_MODEL`, `DEFAULT_REASONING_EFFORT`, `DEFAULT_SYSTEM_PROMPT` and `DEFAULT_INSTRUCTIONS`, for a UI that lets the operator edit the instructions or
|
|
110
|
+
- `DEFAULT_MODEL`, `DEFAULT_REASONING_EFFORT`, `DEFAULT_MAX_TOKENS`, `DEFAULT_SYSTEM_PROMPT` and `DEFAULT_INSTRUCTIONS`, for a UI that lets the operator edit the instructions, pick the model or set the budget
|
|
111
|
+
- `REASONING_EFFORTS`, the effort levels a UI can offer (`none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`), of which each model family supports a subset
|
|
112
|
+
- `ALLOWED_HEADERS`, the header whitelist, for a caller that decides which headers to fetch for the summary
|
|
111
113
|
|
|
112
114
|
## Upgrading from 1.x
|
|
113
115
|
|
package/index.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
generateSummary,
|
|
5
|
+
DEFAULT_MODEL,
|
|
6
|
+
DEFAULT_REASONING_EFFORT,
|
|
7
|
+
DEFAULT_MAX_TOKENS,
|
|
8
|
+
DEFAULT_SYSTEM_PROMPT,
|
|
9
|
+
DEFAULT_INSTRUCTIONS,
|
|
10
|
+
REASONING_EFFORTS,
|
|
11
|
+
ALLOWED_HEADERS
|
|
12
|
+
} = require('./lib/generate-summary');
|
|
4
13
|
const { listModels } = require('./lib/list-models');
|
|
5
14
|
|
|
6
15
|
module.exports = {
|
|
@@ -8,6 +17,9 @@ module.exports = {
|
|
|
8
17
|
listModels,
|
|
9
18
|
DEFAULT_MODEL,
|
|
10
19
|
DEFAULT_REASONING_EFFORT,
|
|
20
|
+
DEFAULT_MAX_TOKENS,
|
|
11
21
|
DEFAULT_SYSTEM_PROMPT,
|
|
12
|
-
DEFAULT_INSTRUCTIONS
|
|
22
|
+
DEFAULT_INSTRUCTIONS,
|
|
23
|
+
REASONING_EFFORTS,
|
|
24
|
+
ALLOWED_HEADERS
|
|
13
25
|
};
|
package/lib/generate-summary.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const libmime = require('libmime');
|
|
4
4
|
const { htmlToText } = require('@postalsys/email-text-tools');
|
|
5
5
|
const { apiRequest } = require('./api-request');
|
|
6
|
-
const { estimateTokens, fitPrompt } = require('./token-estimate');
|
|
6
|
+
const { estimateTokens, fitPrompt, DEFAULT_MAX_ALLOWED_TOKENS } = require('./token-estimate');
|
|
7
7
|
const { getApiUrl, OPENAI_API_BASE_URL } = require('./get-api-url');
|
|
8
8
|
|
|
9
9
|
const OPENAI_API_URL_CHAT = '/v1/chat/completions';
|
|
@@ -12,11 +12,18 @@ const OPENAI_API_URL_CHAT = '/v1/chat/completions';
|
|
|
12
12
|
// the model catalogue on 2026-10-01)
|
|
13
13
|
const DEFAULT_MODEL = 'gpt-6-luna';
|
|
14
14
|
|
|
15
|
+
// The reasoning effort levels OpenAI's models know, lowest first. Each family supports a subset:
|
|
16
|
+
// "minimal" exists only on the first GPT-5 models, "none" only from GPT-5.1 on, "xhigh" and
|
|
17
|
+
// "max" only on GPT-6. A level a model refuses is dropped and the model's own default applies
|
|
18
|
+
const REASONING_EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
19
|
+
|
|
15
20
|
// Sent to reasoning models when the caller sets no effort of its own. Every reasoning model
|
|
16
|
-
// OpenAI serves accepts "low"
|
|
17
|
-
// from GPT-5.1 on, so neither is a safe default
|
|
21
|
+
// OpenAI serves accepts "low", so it is the one safe default
|
|
18
22
|
const DEFAULT_REASONING_EFFORT = 'low';
|
|
19
23
|
|
|
24
|
+
// Default prompt budget, as an estimated token count covering the instructions and the email
|
|
25
|
+
const DEFAULT_MAX_TOKENS = DEFAULT_MAX_ALLOWED_TOKENS;
|
|
26
|
+
|
|
20
27
|
// Headers the model gets to see. Signature blobs (DKIM, ARC seals) are left out: they are large,
|
|
21
28
|
// and the model cannot verify them anyway. The authentication results are what carries their
|
|
22
29
|
// verdict
|
|
@@ -522,6 +529,10 @@ module.exports = {
|
|
|
522
529
|
resetParameterCache,
|
|
523
530
|
DEFAULT_MODEL,
|
|
524
531
|
DEFAULT_REASONING_EFFORT,
|
|
532
|
+
DEFAULT_MAX_TOKENS,
|
|
525
533
|
DEFAULT_SYSTEM_PROMPT,
|
|
526
|
-
DEFAULT_INSTRUCTIONS
|
|
534
|
+
DEFAULT_INSTRUCTIONS,
|
|
535
|
+
REASONING_EFFORTS,
|
|
536
|
+
// a copy: the headers the model gets to see, for a caller that decides what to fetch
|
|
537
|
+
ALLOWED_HEADERS: Object.freeze([...DEFAULT_ALLOWED_HEADERS])
|
|
527
538
|
};
|
package/lib/token-estimate.js
CHANGED
|
@@ -128,4 +128,4 @@ function fitPrompt({ text, maxLength, maxTokens, overhead }) {
|
|
|
128
128
|
return { text: fitted, charactersRemoved: text.length - fitted.length };
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
module.exports = { estimateTokens, fitLength, fitPrompt };
|
|
131
|
+
module.exports = { estimateTokens, fitLength, fitPrompt, DEFAULT_MAX_ALLOWED_TOKENS };
|
package/package.json
CHANGED
package/test/index.test.js
CHANGED
|
@@ -13,10 +13,18 @@ describe('index exports', () => {
|
|
|
13
13
|
assert.equal(typeof lib.listModels, 'function');
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
it('exports the default model and
|
|
16
|
+
it('exports the default model, reasoning effort and token budget', () => {
|
|
17
17
|
assert.equal(typeof lib.DEFAULT_MODEL, 'string');
|
|
18
18
|
assert.ok(lib.DEFAULT_MODEL.length > 0);
|
|
19
19
|
assert.equal(lib.DEFAULT_REASONING_EFFORT, 'low');
|
|
20
|
+
assert.ok(lib.REASONING_EFFORTS.includes(lib.DEFAULT_REASONING_EFFORT));
|
|
21
|
+
assert.equal(lib.DEFAULT_MAX_TOKENS, 30000);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('exports the header whitelist as a frozen list', () => {
|
|
25
|
+
assert.ok(Object.isFrozen(lib.ALLOWED_HEADERS));
|
|
26
|
+
assert.ok(lib.ALLOWED_HEADERS.includes('authentication-results'));
|
|
27
|
+
assert.ok(lib.ALLOWED_HEADERS.includes('subject'));
|
|
20
28
|
});
|
|
21
29
|
|
|
22
30
|
it('exports DEFAULT_SYSTEM_PROMPT as a non-empty string', () => {
|