loopzero-gateway-email 0.0.0-stage → 0.1.1

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 ADDED
@@ -0,0 +1,331 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 414ebff: A lost IMAP connection is reopened with growing delays (1 s doubling to 60 s) until it succeeds or `disconnect()` is called, and the mail that arrived meanwhile is dispatched from the kept cursor. Before, a reset or timeout ended inbound mail for the life of the process while `connect()` had answered true, and an `error` event on an open connection had no listener.
8
+
9
+ ## 0.6.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 8585427: README status lines say "0.x, pre-1.0" instead of a hard-coded version.
14
+
15
+ ## 0.6.0
16
+
17
+ ### Minor Changes
18
+
19
+ - bc799e9: Export `matrixChannel`, `mattermostChannel` and `emailChannel`: `ChannelDescriptor`s with `MATRIX_*`, `MATTERMOST_*` and `EMAIL_*` environment bindings for `createChannels` and `configFromEnv`. The peer range on `loopzero-gateway` is now `>=0.21.0`.
20
+
21
+ ### Patch Changes
22
+
23
+ - fc94485: The email, IRC, Matrix, Nextcloud Talk and Signal channel descriptors build their configuration fields with the shared `field` helper, and email and Matrix read their env-string numbers and booleans through one shared reader instead of two copies. The descriptors and the values they accept are unchanged.
24
+
25
+ ## 0.5.0
26
+
27
+ ### Minor Changes
28
+
29
+ - 5db4bf0: The first connect no longer dispatches the unread backlog. It records the mailbox's UIDNEXT (with its UIDVALIDITY) as a cursor and dispatches only mail that arrives after it; `connect()` resolves once the baseline is set. A new `cursorStore` option persists the cursor across restarts; a changed UIDVALIDITY resets it.
30
+
31
+ ## 0.4.0
32
+
33
+ ### Minor Changes
34
+
35
+ - 7aff50b: The `nodemailer` peer range is now `^10.0.6`. Every nodemailer up to 10.0.5 is inside an open advisory, and the tests already ran against 10.3.1, which the old `^9.0.1` range refused.
36
+
37
+ ## 0.3.2
38
+
39
+ ### Patch Changes
40
+
41
+ - 0c0328d: Tests now load against `nodemailer@9.1.1`: the vitest config inlines `mailparser`, whose ESM build imports `nodemailer/lib/addressparser` as a directory that Node's ESM resolver rejects when its nodemailer dependency is 9.x. The declared `nodemailer` range is unchanged. No runtime change.
42
+ - 3f1788d: Send an image from a gateway handler, and refuse it wherever a platform cannot show one.
43
+
44
+ `loopzero-gateway` exports `OutboundAttachment` (`kind: "image"`, `mediaType`, `data`, optional
45
+ `filename`). `OutboundMessage` gains an optional `attachments` list, `ctx.reply(text, { attachments })`
46
+ carries it to the adapter (an empty list is left out), and `BasePlatformAdapter` declares
47
+ `supportsAttachments`, `false` by default. `DeliveryRouter.send` takes the same `attachments`
48
+ field. The runner and the router refuse an outbound carrying attachments as
49
+ `attachments_unsupported`, with no `sendMessage` call, when the adapter does not declare
50
+ `supportsAttachments`.
51
+
52
+ `loopzero-gateway-telegram` reports `supportsAttachments: true` and sends each image through
53
+ `sendPhoto`, the text as the first photo's caption up to 1024 UTF-16 units and after the photos
54
+ when longer. A non-image kind is refused as `attachments_unsupported`; a missing image, more
55
+ than 10 images or an image over 10 MiB as `invalid_attachment`; all with no request.
56
+
57
+ Every other adapter, and every adapter's `editMessage`, refuses an outbound carrying attachments
58
+ with `attachments_unsupported` and makes no platform call, instead of sending the text and
59
+ dropping the image.
60
+
61
+ The runner's auto-reply to a blocking `pre_inbound` hook no longer discards a `sendMessage` that
62
+ throws: the error reaches the `on_error` hooks with the event and is written to stderr, redacted,
63
+ as a handler error is. Dispatch still does not throw.
64
+
65
+ ## 0.3.1
66
+
67
+ ### Patch Changes
68
+
69
+ - 1e215ab: The peer floor on `loopzero-gateway` is `>=0.9.0`, which is what these packages have needed since
70
+ they gained `deliver`.
71
+
72
+ `deliver` and `runHandler` arrived in the core at 0.9.0, and the previous release shipped these
73
+ adapters still declaring `>=0.6.0` — a floor `dep-check` had already proven false by building the
74
+ workspace against it: TS4113 on the override, TS2551 on `runHandler`, in all ten packages.
75
+
76
+ It could not be corrected in that release. `dep-check`'s install check packs an adapter and installs
77
+ it the way a consumer would, and until 0.9.0 was on npm no consumer could resolve a package asking
78
+ for it — the check was right about the world as it stood. The floor is raised here, against a
79
+ registry where the version it names exists.
80
+
81
+ Between the two releases a consumer installing against an older core got a build error rather than a
82
+ resolution error: the same failure, later and less clearly. That window is closed.
83
+
84
+ ## 0.3.0
85
+
86
+ ### Minor Changes
87
+
88
+ - b38172b: **The peer floor on `loopzero-gateway` rises with this release.** Every adapter now implements
89
+ `deliver` over `runHandler`, and neither exists in an older core — an adapter installed against one
90
+ does not build. `dep-check` caught that by building the whole workspace against the floor each
91
+ package claimed, which is the one thing a version range cannot tell you by reading it.
92
+
93
+ The floor is set in the version commit rather than here, because a range cannot name a version that
94
+ does not exist yet: raised in the workspace, the same gate then fails the other way round — every
95
+ adapter declaring a floor above the core installed beside it. That is the shape `fa70153` used when
96
+ these ranges were first written.
97
+
98
+ `deliver(event)` — every adapter can now be handed an event that arrived out of band (#83).
99
+
100
+ `onInbound` was the seam every adapter implemented and it had no public counterpart. Six platforms
101
+ self-deliver once connected — long polling, a gateway socket, Socket Mode, a sync loop, IMAP — so
102
+ the asymmetry stayed invisible: `GatewayRunner` worked for eight platforms and silently did nothing
103
+ for LINE and WhatsApp Cloud, whose payloads arrive on an HTTP route the application owns. Every app
104
+ wired those two by hand, beside the runner rather than through it.
105
+
106
+ ```ts
107
+ const outcome = await adapter.deliver(event); // "ok" | "no_handler" | "handler_threw"
108
+ ```
109
+
110
+ The three outcomes are distinguished because a caller acts on them differently: answering a webhook
111
+ 200 when nobody was subscribed tells the provider to stop retrying a message nothing received.
112
+
113
+ `BasePlatformAdapter.runHandler` holds the containment once, where ten copies of it used to live —
114
+ a handler is user code, its throw is named as the handler's failure rather than the platform's, and
115
+ delivery continues. Each adapter's `deliver` is one line over it.
116
+
117
+ Also: `gateway-sms`'s `createWebhookServer` now signs against the configured `publicUrl` (#90).
118
+ Twilio verifies against the URL it POSTed to, and behind a proxy that rewrites `host` — a tunnel, an
119
+ ingress, a load balancer terminating TLS — the reconstruction from headers yields the internal
120
+ address, so a correct signature fails on every delivery. `publicUrl` is required by all three
121
+ backend option shapes and documented as "used by signature verifier"; until now no source file read
122
+ it. The header reconstruction stays as the fallback for an app served directly.
123
+
124
+ ## 0.2.1
125
+
126
+ ### Patch Changes
127
+
128
+ - 72f5807: An email with no display name no longer carries an empty one.
129
+
130
+ `mailparser` reports `name: ""` for a bare `From: alice@example.com` — not `undefined` — and the
131
+ guard tested only for `undefined`. So every message without a display name arrived with
132
+ `email.fromName: ""` and `sender.displayName: ""` present rather than absent, which is a different
133
+ shape from the one the optional fields promise: a consumer testing `"displayName" in sender` saw a
134
+ name that was not there.
135
+
136
+ The convention two lines further down in the same function is already `addr.length > 0`.
137
+
138
+ Found by mutation testing: eight mutants of the two conditional spreads survived, because no test
139
+ read either field.
140
+
141
+ ## 0.2.0
142
+
143
+ ### Minor Changes
144
+
145
+ - aa2eced: The nodemailer peer range no longer admits only vulnerable versions.
146
+
147
+ `nodemailer ^8.0.0` was declared as a peer, and the whole of `^8` is inside the range an advisory
148
+ names vulnerable (`<=9.0.0`, "Message-level raw option bypasses disableFileAccess/disableUrlAccess").
149
+ A consumer following our range got a vulnerable nodemailer; one who wanted a safe one got a peer
150
+ conflict.
151
+
152
+ The peer is now `^9.0.1`. Nodemailer 9 keeps `createTransport`, `sendMail`, `verify` and `close` —
153
+ the entire surface this adapter uses — and its 95 tests pass against it.
154
+
155
+ The advisory's subject is a message-level `raw` option on send, which this adapter does not use; it
156
+ parses inbound mail. The range moved anyway: one that admits only vulnerable versions is a defect
157
+ whether or not the vulnerable path is reachable.
158
+
159
+ ## 0.1.5
160
+
161
+ ### Patch Changes
162
+
163
+ - Every credential field now says what the platform calls it and where it is issued.
164
+
165
+ Measured: a developer who wires one adapter and carries its field name to the next gets
166
+ `error TS2353: … 'token' does not exist in type 'SlackAdapterOptions'`. That names the wrong field
167
+ and the type, and never the right one — so the answer was always one file away.
168
+
169
+ These docblocks are on published option types, so an editor now shows the answer on hover and
170
+ completion. All 15 credential-bearing fields across the ten packages are covered, including the ones
171
+ beyond each adapter's primary token: Slack's `appToken`, LINE's `channelSecret`, Vonage's
172
+ `apiSecret` and `signatureSecret`, WhatsApp's `appSecret`.
173
+
174
+ **Nothing was renamed.** Six of the ten primary names are the platform's own key, pinned against the
175
+ SDK's own declaration — `channelAccessToken` in `@line/bot-sdk`, `clientSecret` in
176
+ `@microsoft/teams.apps`, `accessToken` in `matrix-js-sdk`, `token` in `grammy` and `discord.js`,
177
+ `authToken` in `twilio`. Where ours diverges, the docblock says so rather than implying otherwise:
178
+ `botToken` (deliberate — the adapter also takes an `appToken`), Mattermost's `accessToken` against
179
+ its client's `token`, and `password` against nodemailer's `pass`.
180
+
181
+ ## 0.1.4
182
+
183
+ ### Patch Changes
184
+
185
+ - Drop the unused `loopzero-sdk` peer dependency, so a LoopZero app can install an adapter.
186
+
187
+ Every adapter declared `peer loopzero-sdk@^2.18.0` and imported the SDK in **zero** source files.
188
+ The framework ships `loopzero-sdk@4.x`, so `npm install loopzero-gateway-line` into a LoopZero app
189
+ failed outright with `ERESOLVE`.
190
+
191
+ The core's range was widened in `loopzero-gateway@0.7.0`, which was not enough on its own: an
192
+ adapter's own manifest still carried the pin, so installing one still failed even against the fixed
193
+ core. Measured in a real app before and after.
194
+
195
+ ## 0.1.3
196
+
197
+ ### Patch Changes
198
+
199
+ - e682180: **A message whose handler throws no longer kills the bot.** On Teams and on WhatsApp's web backend it did — not degraded delivery, an exit code. `Error: ... / Node.js v22.22.2`, and the next message never arrived.
200
+
201
+ Both dispatched with `void handler(event)`. `void` reads as "I am not waiting for this"; what it tells the runtime is "I am not handling the error", and under Node 22's default an unhandled rejection ends the process. Measured against both adapters through their own injection seams before the fix, and again after: the throw is now contained, named, and delivery continues.
202
+
203
+ **Discord and Telegram contained it but blamed the wrong thing.** The rejection escaped into the platform library's error channel, so a bug in the consumer's own handler surfaced as `[discord] client error` / `[telegram] bot error`. Anyone debugging that went looking in discord.js and grammy for a fault that was in their own code. Both now report `handler threw` and return `"handler_threw"` from the internal dispatch seam.
204
+
205
+ **WhatsApp Cloud dropped the rest of the batch, and made the platform resend it.** Meta packs several messages and their delivery receipts into one webhook, and the dispatch loop awaited each handler with nothing around it. One throw skipped every remaining message in the payload, skipped the status receipts, and rejected `handleWebhookPayload` — so the caller's route answered 500 and Meta redelivered the whole batch, replaying the messages that had already been handled. That is a duplicate-reply bug reached through a different door than the one fixed in #11. The same method also now answers `false` on a signed body that is not JSON, instead of throwing out of a method whose contract is `true`/`false`.
206
+
207
+ **Email gained a net it did not strictly need.** Its drain is written never to reject, and it does not — but both launch sites discard the promise, so that property was the only thing between a future edit and the same fatal rejection, and nothing enforced it. The catch now lives at the site that would pay for it.
208
+
209
+ **The contract is written down, and held to.** `BasePlatformAdapter.onInbound` now states it: a handler may throw, and an adapter must contain that throw, report it as the handler's failure rather than the platform's, and keep delivering. Eight of ten adapters had converged on exactly that with nothing recording it. `tests/lint/adapter-contract.test.ts` gains two invariants — every adapter names a handler throw as the handler's, and no adapter launches a user callback with a bare `void` — and both were checked against a deliberately reverted adapter to confirm they fire rather than pass vacuously.
210
+
211
+ - 8cbf136: **Every published export now carries documentation.** Forty-seven public symbols shipped with no docblock at all, so a consumer hovering `DiscordAdapter`, `SlackAdapter`, `WhatsAppCloudBackend`, `ThreadStore` or any of the error classes got an empty tooltip. Coverage across the eleven packages went from 71.2% to 100% (163/163), measured over the published declarations rather than the source, because a docblock is not documentation until it survives the build.
212
+
213
+ The text says what each symbol is for and what constrains it, not what its name already says. `TelegramAdapter` records that a bot cannot enumerate its chats nor speak into one that has not spoken first. `DiscordAdapter` records that reading message content needs a privileged intent enabled in the developer portal, without which every `event.text` arrives empty and nothing says why. `WhatsAppWebBackend` records that it is unofficial and can get a number banned. `shouldDispatchSyncEvent` records that Matrix replays history on sync, which is why a freshly started bot would otherwise answer every message it can still see.
214
+
215
+ **`gateway-slack`'s README documented a type that does not exist.** Its usage example imported `GatewayMessageEvent` from `loopzero-gateway`. That name is an internal alias inside the Discord and Telegram adapters (`MessageEvent as GatewayMessageEvent`), never an export. A reader who copied the example got code that did not compile. It now imports `MessageEvent`, which is what `onInbound` actually hands the handler.
216
+
217
+ Two docblocks that attached to nothing were reattached: `acquirePidLock` in `gateway-whatsapp` had its documentation stranded thirty lines above, over a different function, and shipped undocumented as a result.
218
+
219
+ - b8ef098: **Every package now ships the licence it declares.** All twelve manifests in this repository declare `Apache-2.0`, and the repository had no `LICENSE` file at all — not at the root, and not in any package directory except `gateway-email`. So each published tarball asserted a licence while carrying none of its terms, and §4(a) of that licence requires a copy to travel with the distribution. Worse than a missing file: with no licence text anywhere, everything outside the manifests fell back to default copyright, which grants a recipient nothing.
220
+
221
+ The text is now at the repository root and inside every publishable package, byte-identical to the canonical Apache License 2.0 with the appendix filled in (`Copyright 2026 getloopscale.com`). The one pre-existing copy, in `gateway-email`, was replaced along with the rest: it carried the same truncated paragraph 4(d) found across the ecosystem, dropping "reasonable and customary use" from the NOTICE clause — a modified body under an unmodified SPDX identifier.
222
+
223
+ **The repository moved to the official `getloopscale` organization.** Existing clones and published URLs keep working through GitHub's permanent redirect; the root manifest now declares `Apache-2.0` explicitly rather than leaving the workspace root silent.
224
+
225
+ - 5bae032: Six defects that broke real conversations, found by testing the adapters against the live platforms instead of against fakes.
226
+
227
+ **LINE — no outbound message was ever delivered.** The adapter called the v9 SDK client with positional arguments while that client takes a single request object, so LINE received an empty request and rejected every send with a 400. Upgrade if you use this adapter at all: nothing it sent reached anyone.
228
+
229
+ **Telegram — the bot froze on long replies.** Any message over 4096 characters that began with an unclosed code span (a stray backtick) put the splitter into an infinite loop, hanging the process until it ran out of memory. Long agent answers now split correctly whatever markdown they contain.
230
+
231
+ **Mattermost — long messages silently vanished.** The adapter never split anything, so any reply over 16,383 characters was rejected by the server and the user simply saw nothing. Long replies are now split into parts Mattermost accepts.
232
+
233
+ **SMS — long messages were rejected from the hundredth part onward.** The `(i/N)` prefix outgrew the space reserved for it, pushing every later part past the provider's limit.
234
+
235
+ **Matrix and LINE — `connect()` reported success with an invalid token.** Both now verify the credential with the server before returning `true`, so a wrong token fails at startup instead of silently receiving nothing forever.
236
+
237
+ **Email and Teams — the bot could go permanently deaf.** Replacing an inbound handler and then disposing of the previous one removed the new handler as well, and the gateway stopped receiving messages with nothing logged.
238
+
239
+ Also: a `pre_inbound` hook that threw put its raw error text into the user's chat, which could expose internal details such as connection strings or tokens. Users now see only which hook failed; the detail goes to the server log, redacted.
240
+
241
+ WhatsApp additionally stops opening a second session when `connect()` is called twice, and its group mention filter no longer treats unrelated digits scattered through a message as a mention of the bot.
242
+
243
+ - 4e6ae26: **The published type declarations now compile.** Five of these packages shipped a `.d.ts` (and matching `.d.cts`) containing type references that resolve to nothing — nine names, replicated across both module formats. `skipLibCheck: true` is on by default in most consumer projects, so the packages installed, imported and looked correct; under type-aware lint, which resolves the real type graph and has no such escape, every type reached through a broken reference degrades to `error`, and ordinary correct calls into these adapters come back flagged `no-unsafe-*`.
244
+
245
+ The names, all now bound: `EmailMessageEvent` (email), `SendResult` and `SlackMessageEvent` (slack), `GatewayConfigurationError` and `GatewayConfigurationErrorOptions` (sms), `TeamsMessageEvent` (teams), `ChildProcess` and `WhatsAppSendResult` (whatsapp).
246
+
247
+ Nothing was wrong with the source — every package's own `tsc --noEmit` was green throughout, which is exactly why this survived. The defect is in how tsup's declaration rollup emits the bundle: it re-exports a name without binding it locally, drops a type-only import from an external module while inlining the declarations that use it, or renames a declaration to avoid a collision and misses one use site. The `sms` names are the newest instance — the shared `GatewayConfigurationError` base introduced in `loopzero-gateway` 0.5.0 turned a local type into an external one, which is the shape the rollup drops.
248
+
249
+ The public surface of every package is unchanged: the same names are exported, and the repair that rewrites a re-export verifies that before and after. What changed is where a name is bound inside the declaration file.
250
+
251
+ - 7ccb21b: Two defects that only a real server could show, both found by the live suites.
252
+
253
+ **Email — the bot re-answered its whole unread inbox after every restart.** Nothing ever flagged a message as read on the server, and the only record of what had already been handled lived in memory and was thrown away on disconnect. So each reconnect fetched the entire unread backlog again and delivered all of it a second time: on the test mailbox, 166 messages meant 166 duplicate replies to the people who had written in. It got worse over time, because the backlog only ever grew. Messages are now flagged on the server once handled, in a single command per batch, so a restart picks up where it left off.
254
+
255
+ **Matrix — `disconnect()` could kill your process.** Shutting the client down cancels the requests it has open, and one of those cancellations surfaced as an unhandled rejection, which Node treats as fatal. An application that reconnects — the well-behaved kind, with retry on connection loss — could be terminated by its own clean shutdown. Measured against a real homeserver before the fix: 7 occurrences in 8 connect/disconnect cycles. Cancellations during shutdown are now contained, while any cancellation you request yourself through `getClient()` still reaches you unchanged.
256
+
257
+ ## 0.1.2
258
+
259
+ ### Patch Changes
260
+
261
+ - b8ef098: **Every package now ships the licence it declares.** All twelve manifests in this repository declare `Apache-2.0`, and the repository had no `LICENSE` file at all — not at the root, and not in any package directory except `gateway-email`. So each published tarball asserted a licence while carrying none of its terms, and §4(a) of that licence requires a copy to travel with the distribution. Worse than a missing file: with no licence text anywhere, everything outside the manifests fell back to default copyright, which grants a recipient nothing.
262
+
263
+ The text is now at the repository root and inside every publishable package, byte-identical to the canonical Apache License 2.0 with the appendix filled in (`Copyright 2026 getloopscale.com`). The one pre-existing copy, in `gateway-email`, was replaced along with the rest: it carried the same truncated paragraph 4(d) found across the ecosystem, dropping "reasonable and customary use" from the NOTICE clause — a modified body under an unmodified SPDX identifier.
264
+
265
+ **The repository moved to the official `getloopscale` organization.** Existing clones and published URLs keep working through GitHub's permanent redirect; the root manifest now declares `Apache-2.0` explicitly rather than leaving the workspace root silent.
266
+
267
+ - 5bae032: Six defects that broke real conversations, found by testing the adapters against the live platforms instead of against fakes.
268
+
269
+ **LINE — no outbound message was ever delivered.** The adapter called the v9 SDK client with positional arguments while that client takes a single request object, so LINE received an empty request and rejected every send with a 400. Upgrade if you use this adapter at all: nothing it sent reached anyone.
270
+
271
+ **Telegram — the bot froze on long replies.** Any message over 4096 characters that began with an unclosed code span (a stray backtick) put the splitter into an infinite loop, hanging the process until it ran out of memory. Long agent answers now split correctly whatever markdown they contain.
272
+
273
+ **Mattermost — long messages silently vanished.** The adapter never split anything, so any reply over 16,383 characters was rejected by the server and the user simply saw nothing. Long replies are now split into parts Mattermost accepts.
274
+
275
+ **SMS — long messages were rejected from the hundredth part onward.** The `(i/N)` prefix outgrew the space reserved for it, pushing every later part past the provider's limit.
276
+
277
+ **Matrix and LINE — `connect()` reported success with an invalid token.** Both now verify the credential with the server before returning `true`, so a wrong token fails at startup instead of silently receiving nothing forever.
278
+
279
+ **Email and Teams — the bot could go permanently deaf.** Replacing an inbound handler and then disposing of the previous one removed the new handler as well, and the gateway stopped receiving messages with nothing logged.
280
+
281
+ Also: a `pre_inbound` hook that threw put its raw error text into the user's chat, which could expose internal details such as connection strings or tokens. Users now see only which hook failed; the detail goes to the server log, redacted.
282
+
283
+ WhatsApp additionally stops opening a second session when `connect()` is called twice, and its group mention filter no longer treats unrelated digits scattered through a message as a mention of the bot.
284
+
285
+ - 7ccb21b: Two defects that only a real server could show, both found by the live suites.
286
+
287
+ **Email — the bot re-answered its whole unread inbox after every restart.** Nothing ever flagged a message as read on the server, and the only record of what had already been handled lived in memory and was thrown away on disconnect. So each reconnect fetched the entire unread backlog again and delivered all of it a second time: on the test mailbox, 166 messages meant 166 duplicate replies to the people who had written in. It got worse over time, because the backlog only ever grew. Messages are now flagged on the server once handled, in a single command per batch, so a restart picks up where it left off.
288
+
289
+ **Matrix — `disconnect()` could kill your process.** Shutting the client down cancels the requests it has open, and one of those cancellations surfaced as an unhandled rejection, which Node treats as fatal. An application that reconnects — the well-behaved kind, with retry on connection loss — could be terminated by its own clean shutdown. Measured against a real homeserver before the fix: 7 occurrences in 8 connect/disconnect cycles. Cancellations during shutdown are now contained, while any cancellation you request yourself through `getClient()` still reaches you unchanged.
290
+
291
+ ## 0.1.1
292
+
293
+ ### Patch Changes
294
+
295
+ - e926cd9: Align the gateway cluster to the hardened `loopzero-sdk` 2.18.0 Harness (ecosystem M6). Bumped the `loopzero-sdk` peer + dev dependency from `^1.9.0` to `^2.18.0` across all 11 packages. The only consumed SDK surface is `Security.redact` (in the gateway core runner) — a stable public API (ADR D68) unchanged across 1.x→2.x — so the alignment is a pin bump, not a migration. Validated: all 11 packages typecheck + build + test green against 2.18.0 (543 tests passed). No dead/unwired surfaces (`no-stubs-no-mocks-no-wired` checklist clean).
296
+
297
+ ## 2.0.0
298
+
299
+ ### Patch Changes
300
+
301
+ - Updated dependencies
302
+ - loopzero-sdk@1.3.0
303
+ - loopzero-gateway@2.0.0
304
+
305
+ ## 1.0.0
306
+
307
+ ### Patch Changes
308
+
309
+ - Updated dependencies
310
+ - loopzero-sdk@1.2.0
311
+ - loopzero-gateway@1.0.0
312
+
313
+ ## [0.1.0] - 2026-05-24
314
+
315
+ ### Added
316
+
317
+ - Initial release. Email platform adapter for `loopzero-gateway` (Roadmap v1.4 #4).
318
+ - `EmailAdapter` extending `BasePlatformAdapter` (ADRs D327-D339).
319
+ - Community-standard stack: `nodemailer@^8` (SMTP) + `imapflow@^1` (IMAP IDLE) + `mailparser@^3` (RFC 5322).
320
+ - IMAP IDLE preferred, 15s polling fallback (D328).
321
+ - Threading via `Message-ID` / `In-Reply-To` / `References` chain — RFC 5322 §3.6.4 (D329).
322
+ - `splitForEmail`-style 50000-char body truncation (EC-2).
323
+ - Automated-sender filter ON by default (regex + RFC 3834 `Auto-Submitted` header) — D332.
324
+ - Allowed-sender allowlist with bracketed-entry normalization (D333 + EC-3).
325
+ - `mapEmailError` HTTP / plain-Error mapper.
326
+ - DM-only channel mapping (D336); group threads deferred to v0.2.
327
+ - Outbound threading reciprocity with References dedup (D337 + EC-6).
328
+ - Own-address loopback drop guard (EC-1 CRITICAL).
329
+ - Concurrent dispatch serialized via Promise queue (EC-4).
330
+ - Subject fallback `"(no subject)"` when missing (EC-5).
331
+ - Seen-UID Set with FIFO cap at 5000 (D331).
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 getloopscale.com
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,40 @@
1
- # Temporary Holding Version
1
+ # `loopzero-gateway-email`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Email platform adapter for `loopzero-gateway`. Built on the community-standard 2026 Node email stack: `nodemailer` (SMTP) + `imapflow` (IMAP IDLE) + `mailparser` (RFC 5322 parsing).
4
+
5
+ Status: **0.x, pre-1.0**. Pre-1.0 contract per ADR D338 — breaking changes allowed within 0.x.
6
+
7
+ ## How inbound arrives
8
+
9
+ **IMAP IDLE.** The adapter polls the mailbox over its own connection; messages reach `onInbound`
10
+ once `connect()` resolves. There is no webhook to host and nothing for an application to
11
+ authenticate.
12
+
13
+ ## Channel descriptor
14
+
15
+ `emailChannel` describes the channel as data for `createChannels` and `configFromEnv` from `loopzero-gateway`. Its transport is `socket`.
16
+
17
+ ```ts
18
+ import { configFromEnv, createChannels } from "loopzero-gateway";
19
+ import { emailChannel } from "loopzero-gateway-email";
20
+
21
+ const { config, missing, secrets } = configFromEnv(emailChannel, process.env, "APP_");
22
+ const { adapters, rejected } = createChannels([{ descriptor: emailChannel, config, envPrefix: "APP_" }]);
23
+ ```
24
+
25
+ | Config key | Env name | Required | Secret |
26
+ | --- | --- | --- | --- |
27
+ | `address` | `EMAIL_ADDRESS` | yes | no |
28
+ | `password` | `EMAIL_PASSWORD` | yes | yes |
29
+ | `imapHost` | `EMAIL_IMAP_HOST` | yes | no |
30
+ | `imapPort` | `EMAIL_IMAP_PORT` | no | no |
31
+ | `smtpHost` | `EMAIL_SMTP_HOST` | yes | no |
32
+ | `smtpPort` | `EMAIL_SMTP_PORT` | no | no |
33
+ | `fromName` | `EMAIL_FROM_NAME` | no | no |
34
+ | `allowedSenders` | `EMAIL_ALLOWED_SENDERS` | no | no |
35
+ | `allowAutomated` | `EMAIL_ALLOW_AUTOMATED` | no | no |
36
+ | `pollIntervalMs` | `EMAIL_POLL_INTERVAL_MS` | no | no |
37
+ | `maxBodyChars` | `EMAIL_MAX_BODY_CHARS` | no | no |
38
+ | `cursorStore` | none (object) | no | no |
39
+
40
+ The `APP_` prefix is the app's choice. A value of the wrong type throws `invalid_config` naming the key; a list may be an array or a comma-separated string, a boolean `true`/`false` or the same strings, a number a number or a digit string.