@agenticmail/core 0.5.51 → 0.5.55

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/dist/index.cjs CHANGED
@@ -1107,9 +1107,11 @@ var import_mailparser = require("mailparser");
1107
1107
  async function parseEmail(raw) {
1108
1108
  const parsed = await (0, import_mailparser.simpleParser)(raw);
1109
1109
  const xOriginalFrom = parsed.headers?.get("x-original-from");
1110
+ const xAgenticMailRelay = parsed.headers?.get("x-agenticmail-relay");
1110
1111
  const originalFromAddr = typeof xOriginalFrom === "string" ? xOriginalFrom.trim() : void 0;
1112
+ const isAgenticMailInboundRelay = xAgenticMailRelay === "inbound";
1111
1113
  let fromAddrs = parsed.from?.value ?? [];
1112
- if (originalFromAddr && fromAddrs.length > 0 && fromAddrs[0].address?.endsWith("@localhost")) {
1114
+ if (originalFromAddr && fromAddrs.length > 0 && (isAgenticMailInboundRelay || fromAddrs[0].address?.endsWith("@localhost"))) {
1113
1115
  fromAddrs = [{ name: fromAddrs[0].name || "", address: originalFromAddr }];
1114
1116
  }
1115
1117
  const toAddrs = parsed.to ? Array.isArray(parsed.to) ? parsed.to.flatMap((t) => t.value) : parsed.to.value : [];
@@ -1616,8 +1618,28 @@ var StalwartAdmin = class {
1616
1618
  }
1617
1619
  async healthCheck() {
1618
1620
  try {
1619
- const response = await fetch(`${this.baseUrl}/health`, { signal: AbortSignal.timeout(5e3) });
1620
- return response.ok;
1621
+ const response = await fetch(`${this.baseUrl}/health`, { signal: AbortSignal.timeout(3e3) });
1622
+ if (response.ok) return true;
1623
+ } catch {
1624
+ }
1625
+ try {
1626
+ const net = await import("net");
1627
+ return await new Promise((resolve) => {
1628
+ const smtpPort = parseInt(process.env.SMTP_PORT || "25", 10);
1629
+ const smtpHost = process.env.SMTP_HOST || "localhost";
1630
+ const socket = net.createConnection({ host: smtpHost, port: smtpPort, timeout: 3e3 }, () => {
1631
+ socket.destroy();
1632
+ resolve(true);
1633
+ });
1634
+ socket.on("error", () => {
1635
+ socket.destroy();
1636
+ resolve(false);
1637
+ });
1638
+ socket.on("timeout", () => {
1639
+ socket.destroy();
1640
+ resolve(false);
1641
+ });
1642
+ });
1621
1643
  } catch {
1622
1644
  return false;
1623
1645
  }
@@ -5724,6 +5746,8 @@ var GatewayManager = class {
5724
5746
  const mailOpts = {
5725
5747
  from,
5726
5748
  to: recipients.join(", "),
5749
+ cc: mail.cc ? Array.isArray(mail.cc) ? mail.cc.join(", ") : mail.cc : void 0,
5750
+ bcc: mail.bcc ? Array.isArray(mail.bcc) ? mail.bcc.join(", ") : mail.bcc : void 0,
5727
5751
  subject: mail.subject,
5728
5752
  text: mail.text || void 0,
5729
5753
  html: mail.html || void 0,
@@ -7391,7 +7415,14 @@ IMAP_PORT=143
7391
7415
  const composePath = (0, import_node_path8.join)(dataDir, "docker-compose.yml");
7392
7416
  (0, import_node_fs7.writeFileSync)(composePath, `services:
7393
7417
  stalwart:
7394
- image: stalwartlabs/stalwart:latest
7418
+ # Pinned to v0.15.5 \u2014 Stalwart 0.16+ moved its config to JSON
7419
+ # at /etc/stalwart/config.json (hardcoded into the container
7420
+ # CMD), runs as UID 2000, and silently ignores our pre-0.10
7421
+ # TOML mount. On those builds Stalwart enters bootstrap mode
7422
+ # and the setup wizard 404s on the admin API. Pinning until
7423
+ # the templates are migrated to the 0.16+ JSON layout.
7424
+ # Tracking: https://github.com/agenticmail/agenticmail/issues/10
7425
+ image: stalwartlabs/stalwart:v0.15.5
7395
7426
  container_name: agenticmail-stalwart
7396
7427
  ports:
7397
7428
  - "127.0.0.1:8080:8080" # HTTP Admin + JMAP (localhost only)
package/dist/index.js CHANGED
@@ -354,9 +354,11 @@ import { simpleParser } from "mailparser";
354
354
  async function parseEmail(raw) {
355
355
  const parsed = await simpleParser(raw);
356
356
  const xOriginalFrom = parsed.headers?.get("x-original-from");
357
+ const xAgenticMailRelay = parsed.headers?.get("x-agenticmail-relay");
357
358
  const originalFromAddr = typeof xOriginalFrom === "string" ? xOriginalFrom.trim() : void 0;
359
+ const isAgenticMailInboundRelay = xAgenticMailRelay === "inbound";
358
360
  let fromAddrs = parsed.from?.value ?? [];
359
- if (originalFromAddr && fromAddrs.length > 0 && fromAddrs[0].address?.endsWith("@localhost")) {
361
+ if (originalFromAddr && fromAddrs.length > 0 && (isAgenticMailInboundRelay || fromAddrs[0].address?.endsWith("@localhost"))) {
360
362
  fromAddrs = [{ name: fromAddrs[0].name || "", address: originalFromAddr }];
361
363
  }
362
364
  const toAddrs = parsed.to ? Array.isArray(parsed.to) ? parsed.to.flatMap((t) => t.value) : parsed.to.value : [];
@@ -863,8 +865,28 @@ var StalwartAdmin = class {
863
865
  }
864
866
  async healthCheck() {
865
867
  try {
866
- const response = await fetch(`${this.baseUrl}/health`, { signal: AbortSignal.timeout(5e3) });
867
- return response.ok;
868
+ const response = await fetch(`${this.baseUrl}/health`, { signal: AbortSignal.timeout(3e3) });
869
+ if (response.ok) return true;
870
+ } catch {
871
+ }
872
+ try {
873
+ const net = await import("net");
874
+ return await new Promise((resolve) => {
875
+ const smtpPort = parseInt(process.env.SMTP_PORT || "25", 10);
876
+ const smtpHost = process.env.SMTP_HOST || "localhost";
877
+ const socket = net.createConnection({ host: smtpHost, port: smtpPort, timeout: 3e3 }, () => {
878
+ socket.destroy();
879
+ resolve(true);
880
+ });
881
+ socket.on("error", () => {
882
+ socket.destroy();
883
+ resolve(false);
884
+ });
885
+ socket.on("timeout", () => {
886
+ socket.destroy();
887
+ resolve(false);
888
+ });
889
+ });
868
890
  } catch {
869
891
  return false;
870
892
  }
@@ -4967,6 +4989,8 @@ var GatewayManager = class {
4967
4989
  const mailOpts = {
4968
4990
  from,
4969
4991
  to: recipients.join(", "),
4992
+ cc: mail.cc ? Array.isArray(mail.cc) ? mail.cc.join(", ") : mail.cc : void 0,
4993
+ bcc: mail.bcc ? Array.isArray(mail.bcc) ? mail.bcc.join(", ") : mail.bcc : void 0,
4970
4994
  subject: mail.subject,
4971
4995
  text: mail.text || void 0,
4972
4996
  html: mail.html || void 0,
@@ -6634,7 +6658,14 @@ IMAP_PORT=143
6634
6658
  const composePath = join9(dataDir, "docker-compose.yml");
6635
6659
  writeFileSync5(composePath, `services:
6636
6660
  stalwart:
6637
- image: stalwartlabs/stalwart:latest
6661
+ # Pinned to v0.15.5 \u2014 Stalwart 0.16+ moved its config to JSON
6662
+ # at /etc/stalwart/config.json (hardcoded into the container
6663
+ # CMD), runs as UID 2000, and silently ignores our pre-0.10
6664
+ # TOML mount. On those builds Stalwart enters bootstrap mode
6665
+ # and the setup wizard 404s on the admin API. Pinning until
6666
+ # the templates are migrated to the 0.16+ JSON layout.
6667
+ # Tracking: https://github.com/agenticmail/agenticmail/issues/10
6668
+ image: stalwartlabs/stalwart:v0.15.5
6638
6669
  container_name: agenticmail-stalwart
6639
6670
  ports:
6640
6671
  - "127.0.0.1:8080:8080" # HTTP Admin + JMAP (localhost only)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/core",
3
- "version": "0.5.51",
3
+ "version": "0.5.55",
4
4
  "description": "Core SDK for AgenticMail — email, SMS, and phone number access for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",