emailengine-app 2.79.1 → 2.79.3
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/workflows/deploy.yml +92 -39
- package/.github/workflows/release.yaml +94 -34
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +85 -0
- package/bin/emailengine.js +8 -1
- package/config/default.toml +6 -0
- package/copy-static-files.sh +23 -2
- package/data/google-crawlers.json +1 -1
- package/lib/account.js +138 -18
- package/lib/api-routes/account-routes.js +13 -1
- package/lib/api-routes/index.js +12 -0
- package/lib/api-routes/mailbox-routes.js +6 -0
- package/lib/api-routes/mcp-oauth-routes.js +259 -0
- package/lib/api-routes/mcp-routes.js +172 -0
- package/lib/api-routes/message-routes.js +125 -4
- package/lib/api-routes/outbox-routes.js +7 -0
- package/lib/api-routes/permission-map.js +97 -1
- package/lib/api-routes/route-helpers.js +16 -4
- package/lib/api-routes/route-metadata.js +24 -4
- package/lib/api-routes/submit-routes.js +41 -0
- package/lib/api-routes/template-routes.js +7 -0
- package/lib/api-routes/token-routes.js +4 -2
- package/lib/consts.js +30 -1
- package/lib/email-client/base-client.js +235 -163
- package/lib/email-client/gmail-client.js +99 -22
- package/lib/email-client/imap/mailbox.js +140 -66
- package/lib/email-client/imap-client.js +74 -68
- package/lib/email-client/outlook-client.js +29 -14
- package/lib/enum-descriptions.js +2 -1
- package/lib/field-usage.js +17 -1
- package/lib/logger.js +43 -3
- package/lib/lua/s-list-accounts.lua +5 -2
- package/lib/mcp/index.js +29 -0
- package/lib/mcp/inject.js +70 -0
- package/lib/mcp/json-schema.js +120 -0
- package/lib/mcp/listen.js +171 -0
- package/lib/mcp/oauth.js +324 -0
- package/lib/mcp/protocol.js +489 -0
- package/lib/mcp/resources.js +139 -0
- package/lib/mcp/tools.js +655 -0
- package/lib/openapi/index.js +3 -1
- package/lib/response-stream.js +52 -21
- package/lib/routes-ui.js +4 -0
- package/lib/schemas.js +24 -3
- package/lib/token-permission-view.js +104 -8
- package/lib/tokens.js +34 -5
- package/lib/tools.js +96 -0
- package/lib/ui-routes/account-routes.js +43 -1
- package/lib/ui-routes/admin-config-routes.js +114 -1
- package/lib/ui-routes/admin-entities-routes.js +54 -5
- package/lib/ui-routes/auth-routes.js +13 -0
- package/lib/ui-routes/mcp-consent-routes.js +330 -0
- package/lib/ui-routes/route-helpers.js +116 -1
- package/lib/utils/network.js +9 -1
- package/lib/web-safe-html.js +61 -0
- package/lib/webhooks.js +3 -8
- package/package.json +15 -14
- package/sbom.json +1 -1
- package/scripts/README.md +25 -0
- package/scripts/build-icon.js +77 -0
- package/server.js +21 -9
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +98 -0
- package/static/emailengine.ico +0 -0
- package/static/js/ui.js +465 -1
- package/static/licenses.html +85 -135
- package/translations/messages.pot +103 -103
- package/views/config/mcp.hbs +361 -0
- package/views/config/oauth/index.hbs +7 -0
- package/views/layout/prompt.hbs +62 -0
- package/views/mcp/authorize.hbs +136 -0
- package/views/partials/head_assets.hbs +3 -3
- package/views/partials/mcp_access_levels.hbs +13 -0
- package/views/partials/mcp_account_limit.hbs +14 -0
- package/views/partials/mcp_tool_count.hbs +19 -0
- package/views/partials/side_menu.hbs +1 -0
- package/views/partials/ui/account-picker.hbs +59 -0
- package/views/partials/ui/code-block.hbs +26 -0
- package/views/partials/ui/menu-item.hbs +5 -0
- package/views/partials/ui/radio.hbs +41 -0
- package/views/partials/ui/tab.hbs +15 -10
- package/views/partials/ui/tabs.hbs +8 -5
- package/views/templates/template.hbs +4 -3
- package/views/tokens/index.hbs +8 -2
- package/views/tokens/new.hbs +514 -243
- package/winconf.js +148 -48
- package/workers/api.js +198 -48
package/scripts/README.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Scripts
|
|
2
2
|
|
|
3
|
+
## build-icon.js
|
|
4
|
+
|
|
5
|
+
Regenerates `static/emailengine.ico` from `static/logo.png`. The result is committed, so run
|
|
6
|
+
this only when the logo artwork changes - a normal build does not need ImageMagick.
|
|
7
|
+
|
|
8
|
+
### Usage
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
brew install imagemagick
|
|
12
|
+
npm run build:icon
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### What it does
|
|
16
|
+
|
|
17
|
+
Builds a 7-image icon (256, 128, 64, 48, 32, 24, 16), PNG-compressing the two largest members
|
|
18
|
+
and using uncompressed 32-bit DIBs for the rest.
|
|
19
|
+
|
|
20
|
+
### Notes
|
|
21
|
+
|
|
22
|
+
- Do not replace it with a plain `magick -define icon:auto-resize=...` call. ImageMagick writes
|
|
23
|
+
every member as an uncompressed BMP, and the resulting icon is large enough to break the
|
|
24
|
+
packaged Windows executable outright. The header comment in the script explains why.
|
|
25
|
+
- `winconf.js` prints the remaining `.rsrc` headroom on every build. That number is the budget
|
|
26
|
+
for any future icon or resource change.
|
|
27
|
+
|
|
3
28
|
## refresh-test-tokens.js
|
|
4
29
|
|
|
5
30
|
Helper script to refresh OAuth2 tokens for Gmail test accounts.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// Regenerates static/emailengine.ico, the icon winconf.js stamps into the Windows executable.
|
|
5
|
+
// Run it when the logo artwork changes; the result is committed, so a normal build needs
|
|
6
|
+
// neither this script nor ImageMagick.
|
|
7
|
+
//
|
|
8
|
+
// The members are assembled here rather than by a single `magick -define icon:auto-resize=...`
|
|
9
|
+
// call because ImageMagick writes every one of them as an uncompressed BMP, and a 256x256 BMP
|
|
10
|
+
// alone is 270KB. The resulting icon is large enough to break the packaged exe - see the comment
|
|
11
|
+
// on payloadOffset() in winconf.js - so the two biggest sizes are PNG-compressed instead, which
|
|
12
|
+
// keeps the whole file around 63KB.
|
|
13
|
+
|
|
14
|
+
const { load } = require('resedit/cjs');
|
|
15
|
+
const { execFileSync } = require('child_process');
|
|
16
|
+
const { mkdtempSync, readFileSync, writeFileSync, rmSync } = require('fs');
|
|
17
|
+
const { tmpdir } = require('os');
|
|
18
|
+
const { join, resolve } = require('path');
|
|
19
|
+
|
|
20
|
+
const SOURCE = resolve(__dirname, '../static/logo.png');
|
|
21
|
+
const TARGET = resolve(__dirname, '../static/emailengine.ico');
|
|
22
|
+
|
|
23
|
+
// Windows renders the icon at all of these: 16 in the Explorer list view and the title bar, 32
|
|
24
|
+
// and 48 in the larger views, 256 for the extra large one. PNG for the two biggest, an
|
|
25
|
+
// uncompressed 32-bit DIB for the rest, which is the convention Windows has read since Vista
|
|
26
|
+
const PNG_SIZES = [256, 128];
|
|
27
|
+
const BMP_SIZES = [64, 48, 32, 24, 16];
|
|
28
|
+
|
|
29
|
+
function magick(args) {
|
|
30
|
+
try {
|
|
31
|
+
execFileSync('magick', args, { stdio: ['ignore', 'ignore', 'pipe'] });
|
|
32
|
+
} catch (err) {
|
|
33
|
+
if (err.code === 'ENOENT') {
|
|
34
|
+
throw new Error('ImageMagick is required to rebuild the icon: brew install imagemagick', { cause: err });
|
|
35
|
+
}
|
|
36
|
+
throw new Error(`magick ${args.join(' ')} failed: ${String(err.stderr || err.message).trim()}`, { cause: err });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
load()
|
|
41
|
+
.then(ResEdit => {
|
|
42
|
+
const workDir = mkdtempSync(join(tmpdir(), 'ee-icon-'));
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const icons = [];
|
|
46
|
+
|
|
47
|
+
for (let size of PNG_SIZES) {
|
|
48
|
+
const file = join(workDir, `png-${size}.png`);
|
|
49
|
+
magick([SOURCE, '-background', 'none', '-resize', `${size}x${size}`, '-strip', '-define', 'png:compression-level=9', file]);
|
|
50
|
+
// The dimensions have to be passed in: RawIconItem does not read them out of the
|
|
51
|
+
// PNG header, and without them the directory entry is written as 0x0 at 0bpp
|
|
52
|
+
icons.push({ data: ResEdit.Data.RawIconItem.from(readFileSync(file), size, size, 32) });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ImageMagick's own DIB members are well formed, so the small sizes are taken from an
|
|
56
|
+
// ico it builds rather than encoded here
|
|
57
|
+
const smallIco = join(workDir, 'small.ico');
|
|
58
|
+
magick([SOURCE, '-background', 'none', '-define', `icon:auto-resize=${BMP_SIZES.join(',')}`, smallIco]);
|
|
59
|
+
icons.push(...ResEdit.Data.IconFile.from(readFileSync(smallIco)).icons);
|
|
60
|
+
|
|
61
|
+
const iconFile = new ResEdit.Data.IconFile();
|
|
62
|
+
iconFile.icons = icons;
|
|
63
|
+
|
|
64
|
+
const ico = Buffer.from(iconFile.generate());
|
|
65
|
+
writeFileSync(TARGET, ico);
|
|
66
|
+
|
|
67
|
+
console.log(`Wrote ${TARGET}`);
|
|
68
|
+
console.log(` ${icons.length} images: ${icons.map(icon => `${icon.data.width}x${icon.data.height}`).join(', ')}`);
|
|
69
|
+
console.log(` ${ico.length} bytes`);
|
|
70
|
+
} finally {
|
|
71
|
+
rmSync(workDir, { recursive: true, force: true });
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
.catch(err => {
|
|
75
|
+
console.error('Error building the icon:', err);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
});
|
package/server.js
CHANGED
|
@@ -1160,11 +1160,21 @@ let spawnWorker = async (type, opts) => {
|
|
|
1160
1160
|
onlineWorkers.delete(worker);
|
|
1161
1161
|
metrics.threadStops.inc();
|
|
1162
1162
|
|
|
1163
|
+
// One classification for the whole handler: a suspended worker type and a clean exit
|
|
1164
|
+
// code are both deliberate, anything else is a worker that died.
|
|
1165
|
+
const unexpectedExit = exitCode !== 0 && !suspendedWorkerTypes.has(type);
|
|
1166
|
+
|
|
1167
|
+
// What a worker death cost - dropped API calls and offline accounts - is only ever
|
|
1168
|
+
// stated by the lines below, and they fire on deliberate exits too. The unexpected
|
|
1169
|
+
// case is the one an operator has to see, and most deployments run above info, so
|
|
1170
|
+
// that case logs at warn while a clean or requested stop stays at info.
|
|
1171
|
+
const exitLevel = unexpectedExit && !isClosing ? 'warn' : 'info';
|
|
1172
|
+
|
|
1163
1173
|
// Fail any in-flight calls routed to this worker right away, so callers
|
|
1164
1174
|
// get a fast retryable error instead of hanging until their own timeout.
|
|
1165
1175
|
let rejectedCalls = rejectWorkerCalls(callQueue, worker, WORKER_DIED_RESP_ERR);
|
|
1166
1176
|
if (rejectedCalls) {
|
|
1167
|
-
logger
|
|
1177
|
+
logger[exitLevel]({ msg: 'Rejected in-flight calls for exited worker', type, threadId: worker.threadId, rejectedCalls });
|
|
1168
1178
|
}
|
|
1169
1179
|
|
|
1170
1180
|
workers.get(type).delete(worker);
|
|
@@ -1188,7 +1198,7 @@ let spawnWorker = async (type, opts) => {
|
|
|
1188
1198
|
unassigned.add(account);
|
|
1189
1199
|
}
|
|
1190
1200
|
|
|
1191
|
-
logger
|
|
1201
|
+
logger[exitLevel]({
|
|
1192
1202
|
msg: 'Worker exited, moving accounts to unassigned',
|
|
1193
1203
|
accounts: accountList.size,
|
|
1194
1204
|
exitCode
|
|
@@ -1204,7 +1214,9 @@ let spawnWorker = async (type, opts) => {
|
|
|
1204
1214
|
|
|
1205
1215
|
// Check if all workers have exited (Redis reconnection scenario)
|
|
1206
1216
|
if (availableIMAPWorkers.size === 0) {
|
|
1207
|
-
|
|
1217
|
+
// Account tracking was lost fleet-wide - the same class of event as the
|
|
1218
|
+
// warn above, and equally invisible to an operator running above info
|
|
1219
|
+
logger.warn({
|
|
1208
1220
|
msg: 'All IMAP workers exited, reloading accounts from Redis for reassignment'
|
|
1209
1221
|
});
|
|
1210
1222
|
|
|
@@ -1215,7 +1227,7 @@ let spawnWorker = async (type, opts) => {
|
|
|
1215
1227
|
assigned.clear();
|
|
1216
1228
|
workerAssigned = new WeakMap();
|
|
1217
1229
|
|
|
1218
|
-
logger.
|
|
1230
|
+
logger.warn({
|
|
1219
1231
|
msg: 'Reloaded accounts from Redis',
|
|
1220
1232
|
accountCount: accounts.length
|
|
1221
1233
|
});
|
|
@@ -1251,7 +1263,7 @@ let spawnWorker = async (type, opts) => {
|
|
|
1251
1263
|
}
|
|
1252
1264
|
}, 10000); // 10 second timeout
|
|
1253
1265
|
|
|
1254
|
-
logger
|
|
1266
|
+
logger[exitLevel]({
|
|
1255
1267
|
msg: 'Worker exited, waiting for restart before reassignment',
|
|
1256
1268
|
accounts: unassigned.size,
|
|
1257
1269
|
expectedWorkers: config.workers.imap,
|
|
@@ -1265,13 +1277,13 @@ let spawnWorker = async (type, opts) => {
|
|
|
1265
1277
|
}
|
|
1266
1278
|
|
|
1267
1279
|
// Log worker exit
|
|
1268
|
-
if (
|
|
1280
|
+
if (unexpectedExit) {
|
|
1281
|
+
logger.error({ msg: 'Worker unexpectedly exited', exitCode, type });
|
|
1282
|
+
} else if (suspendedWorkerTypes.has(type)) {
|
|
1269
1283
|
logger.info({ msg: 'Worker thread terminated', exitCode, type });
|
|
1270
|
-
} else
|
|
1284
|
+
} else {
|
|
1271
1285
|
// Clean exit, e.g. the deliberate exit-for-restart after a Redis reconnection
|
|
1272
1286
|
logger.info({ msg: 'Worker exited', exitCode, type });
|
|
1273
|
-
} else {
|
|
1274
|
-
logger.error({ msg: 'Worker unexpectedly exited', exitCode, type });
|
|
1275
1287
|
}
|
|
1276
1288
|
|
|
1277
1289
|
// Respawn worker after delay, preserving any spawn options (e.g. API worker index).
|