@ghostpaw/email 0.5.0 → 0.5.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/README.md CHANGED
@@ -222,7 +222,17 @@ download on macOS, remove quarantine with
222
222
  Linux binaries require glibc 2.28+; use npx on Alpine.
223
223
  See the [binary build workflow](.github/workflows/release-binaries.yml).
224
224
 
225
- <!-- sizes -->
225
+ Sizes for 0.5.0 (Node 26.12.1 inside each binary):
226
+
227
+ | Target | Archive | Binary |
228
+ |---|---|---|
229
+ | linux-x64 | 41.7 MB tar.gz | 117.7 MB |
230
+ | linux-arm64 | 41.2 MB tar.gz | 115.4 MB |
231
+ | darwin-arm64 | 44.9 MB tar.gz | 146.9 MB |
232
+ | darwin-x64 | 46.4 MB tar.gz | 149.8 MB |
233
+ | windows-x64 | 38.5 MB zip | 105.8 MB |
234
+
235
+ The npm package is 1711 KB unpacked and needs Node 24+.
226
236
 
227
237
  Release installation is checked on ubuntu-24.04, macos-15 and windows-2025.
228
238
 
package/dist/cli.js CHANGED
@@ -784,7 +784,7 @@ ${e.cyan(d)}
784
784
  var emailVersion;
785
785
  var init_version = __esm({
786
786
  "src/version.ts"() {
787
- emailVersion = "0.5.0";
787
+ emailVersion = "0.5.1";
788
788
  }
789
789
  });
790
790
  function getConfigDir() {
@@ -5639,6 +5639,15 @@ function createNetworkSurface(db, options) {
5639
5639
  }
5640
5640
  return session;
5641
5641
  }
5642
+ async function pullFolders(s4) {
5643
+ const result = [];
5644
+ for (const f3 of await s4.listFolders()) {
5645
+ result.push(
5646
+ upsertFolder(db, { accountId, path: f3.path, delimiter: f3.delimiter, role: f3.role })
5647
+ );
5648
+ }
5649
+ return result;
5650
+ }
5642
5651
  return {
5643
5652
  connect: async () => {
5644
5653
  await requireSession().connect();
@@ -5670,7 +5679,8 @@ function createNetworkSurface(db, options) {
5670
5679
  },
5671
5680
  sync: async (syncOptions) => {
5672
5681
  const s4 = requireSession();
5673
- const folders = listFolders2(db, accountId);
5682
+ let folders = listFolders2(db, accountId);
5683
+ if (!folders.length) folders = await pullFolders(s4);
5674
5684
  const results = [];
5675
5685
  let totalNew = 0;
5676
5686
  let totalExpunged = 0;
@@ -5709,21 +5719,7 @@ function createNetworkSurface(db, options) {
5709
5719
  }
5710
5720
  }
5711
5721
  },
5712
- refreshFolders: async () => {
5713
- const s4 = requireSession();
5714
- const imapFolders = await s4.listFolders();
5715
- const result = [];
5716
- for (const f3 of imapFolders) {
5717
- const upserted = upsertFolder(db, {
5718
- accountId,
5719
- path: f3.path,
5720
- delimiter: f3.delimiter,
5721
- role: f3.role
5722
- });
5723
- result.push(upserted);
5724
- }
5725
- return result;
5726
- },
5722
+ refreshFolders: async () => pullFolders(requireSession()),
5727
5723
  searchRemote: async (folder, query) => {
5728
5724
  const s4 = requireSession();
5729
5725
  if (s4.selectedFolder !== folder) {
@@ -6682,7 +6678,8 @@ function createWriteSurface(db, options) {
6682
6678
  async function sendComposed(composed) {
6683
6679
  const raw2 = composed.toString("utf8");
6684
6680
  const fromMatch = raw2.match(/^From:\s*(.+?)$/m);
6685
- const fromAddr = fromMatch?.[1]?.match(/<(.+?)>|(\S+@\S+)/)?.[1] ?? "";
6681
+ const fromParts = fromMatch?.[1]?.match(/<(.+?)>|(\S+@\S+)/);
6682
+ const fromAddr = fromParts?.[1] ?? fromParts?.[2] ?? "";
6686
6683
  const toMatch = [...raw2.matchAll(/^(?:To|Cc|Bcc):\s*(.+?)$/gm)];
6687
6684
  const toAddrs = toMatch.flatMap(
6688
6685
  (m2) => (m2[1] ?? "").split(",").map((a2) => (a2.match(/<(.+?)>|(\S+@\S+)/)?.[1] ?? a2).trim())
package/dist/index.cjs CHANGED
@@ -3514,6 +3514,15 @@ function createNetworkSurface(db, options) {
3514
3514
  }
3515
3515
  return session;
3516
3516
  }
3517
+ async function pullFolders(s3) {
3518
+ const result = [];
3519
+ for (const f of await s3.listFolders()) {
3520
+ result.push(
3521
+ upsertFolder(db, { accountId, path: f.path, delimiter: f.delimiter, role: f.role })
3522
+ );
3523
+ }
3524
+ return result;
3525
+ }
3517
3526
  return {
3518
3527
  connect: async () => {
3519
3528
  await requireSession().connect();
@@ -3545,7 +3554,8 @@ function createNetworkSurface(db, options) {
3545
3554
  },
3546
3555
  sync: async (syncOptions) => {
3547
3556
  const s3 = requireSession();
3548
- const folders = listFolders2(db, accountId);
3557
+ let folders = listFolders2(db, accountId);
3558
+ if (!folders.length) folders = await pullFolders(s3);
3549
3559
  const results = [];
3550
3560
  let totalNew = 0;
3551
3561
  let totalExpunged = 0;
@@ -3584,21 +3594,7 @@ function createNetworkSurface(db, options) {
3584
3594
  }
3585
3595
  }
3586
3596
  },
3587
- refreshFolders: async () => {
3588
- const s3 = requireSession();
3589
- const imapFolders = await s3.listFolders();
3590
- const result = [];
3591
- for (const f of imapFolders) {
3592
- const upserted = upsertFolder(db, {
3593
- accountId,
3594
- path: f.path,
3595
- delimiter: f.delimiter,
3596
- role: f.role
3597
- });
3598
- result.push(upserted);
3599
- }
3600
- return result;
3601
- },
3597
+ refreshFolders: async () => pullFolders(requireSession()),
3602
3598
  searchRemote: async (folder, query) => {
3603
3599
  const s3 = requireSession();
3604
3600
  if (s3.selectedFolder !== folder) {
@@ -4474,7 +4470,8 @@ function createWriteSurface(db, options) {
4474
4470
  async function sendComposed(composed) {
4475
4471
  const raw2 = composed.toString("utf8");
4476
4472
  const fromMatch = raw2.match(/^From:\s*(.+?)$/m);
4477
- const fromAddr = fromMatch?.[1]?.match(/<(.+?)>|(\S+@\S+)/)?.[1] ?? "";
4473
+ const fromParts = fromMatch?.[1]?.match(/<(.+?)>|(\S+@\S+)/);
4474
+ const fromAddr = fromParts?.[1] ?? fromParts?.[2] ?? "";
4478
4475
  const toMatch = [...raw2.matchAll(/^(?:To|Cc|Bcc):\s*(.+?)$/gm)];
4479
4476
  const toAddrs = toMatch.flatMap(
4480
4477
  (m) => (m[1] ?? "").split(",").map((a) => (a.match(/<(.+?)>|(\S+@\S+)/)?.[1] ?? a).trim())
package/dist/index.js CHANGED
@@ -3490,6 +3490,15 @@ function createNetworkSurface(db, options) {
3490
3490
  }
3491
3491
  return session;
3492
3492
  }
3493
+ async function pullFolders(s3) {
3494
+ const result = [];
3495
+ for (const f of await s3.listFolders()) {
3496
+ result.push(
3497
+ upsertFolder(db, { accountId, path: f.path, delimiter: f.delimiter, role: f.role })
3498
+ );
3499
+ }
3500
+ return result;
3501
+ }
3493
3502
  return {
3494
3503
  connect: async () => {
3495
3504
  await requireSession().connect();
@@ -3521,7 +3530,8 @@ function createNetworkSurface(db, options) {
3521
3530
  },
3522
3531
  sync: async (syncOptions) => {
3523
3532
  const s3 = requireSession();
3524
- const folders = listFolders2(db, accountId);
3533
+ let folders = listFolders2(db, accountId);
3534
+ if (!folders.length) folders = await pullFolders(s3);
3525
3535
  const results = [];
3526
3536
  let totalNew = 0;
3527
3537
  let totalExpunged = 0;
@@ -3560,21 +3570,7 @@ function createNetworkSurface(db, options) {
3560
3570
  }
3561
3571
  }
3562
3572
  },
3563
- refreshFolders: async () => {
3564
- const s3 = requireSession();
3565
- const imapFolders = await s3.listFolders();
3566
- const result = [];
3567
- for (const f of imapFolders) {
3568
- const upserted = upsertFolder(db, {
3569
- accountId,
3570
- path: f.path,
3571
- delimiter: f.delimiter,
3572
- role: f.role
3573
- });
3574
- result.push(upserted);
3575
- }
3576
- return result;
3577
- },
3573
+ refreshFolders: async () => pullFolders(requireSession()),
3578
3574
  searchRemote: async (folder, query) => {
3579
3575
  const s3 = requireSession();
3580
3576
  if (s3.selectedFolder !== folder) {
@@ -4450,7 +4446,8 @@ function createWriteSurface(db, options) {
4450
4446
  async function sendComposed(composed) {
4451
4447
  const raw2 = composed.toString("utf8");
4452
4448
  const fromMatch = raw2.match(/^From:\s*(.+?)$/m);
4453
- const fromAddr = fromMatch?.[1]?.match(/<(.+?)>|(\S+@\S+)/)?.[1] ?? "";
4449
+ const fromParts = fromMatch?.[1]?.match(/<(.+?)>|(\S+@\S+)/);
4450
+ const fromAddr = fromParts?.[1] ?? fromParts?.[2] ?? "";
4454
4451
  const toMatch = [...raw2.matchAll(/^(?:To|Cc|Bcc):\s*(.+?)$/gm)];
4455
4452
  const toAddrs = toMatch.flatMap(
4456
4453
  (m) => (m[1] ?? "").split(",").map((a) => (a.match(/<(.+?)>|(\S+@\S+)/)?.[1] ?? a).trim())
@@ -256,7 +256,7 @@ var init_mcp_stdio = __esm({
256
256
  var emailVersion;
257
257
  var init_version = __esm({
258
258
  "src/version.ts"() {
259
- emailVersion = "0.5.0";
259
+ emailVersion = "0.5.1";
260
260
  }
261
261
  });
262
262
 
@@ -4616,7 +4616,8 @@ function createWriteSurface(db, options) {
4616
4616
  async function sendComposed(composed) {
4617
4617
  const raw2 = composed.toString("utf8");
4618
4618
  const fromMatch = raw2.match(/^From:\s*(.+?)$/m);
4619
- const fromAddr = fromMatch?.[1]?.match(/<(.+?)>|(\S+@\S+)/)?.[1] ?? "";
4619
+ const fromParts = fromMatch?.[1]?.match(/<(.+?)>|(\S+@\S+)/);
4620
+ const fromAddr = fromParts?.[1] ?? fromParts?.[2] ?? "";
4620
4621
  const toMatch = [...raw2.matchAll(/^(?:To|Cc|Bcc):\s*(.+?)$/gm)];
4621
4622
  const toAddrs = toMatch.flatMap(
4622
4623
  (m) => (m[1] ?? "").split(",").map((a) => (a.match(/<(.+?)>|(\S+@\S+)/)?.[1] ?? a).trim())
@@ -5942,6 +5943,15 @@ function createNetworkSurface(db, options) {
5942
5943
  }
5943
5944
  return session;
5944
5945
  }
5946
+ async function pullFolders(s3) {
5947
+ const result = [];
5948
+ for (const f of await s3.listFolders()) {
5949
+ result.push(
5950
+ upsertFolder(db, { accountId, path: f.path, delimiter: f.delimiter, role: f.role })
5951
+ );
5952
+ }
5953
+ return result;
5954
+ }
5945
5955
  return {
5946
5956
  connect: async () => {
5947
5957
  await requireSession().connect();
@@ -5973,7 +5983,8 @@ function createNetworkSurface(db, options) {
5973
5983
  },
5974
5984
  sync: async (syncOptions) => {
5975
5985
  const s3 = requireSession();
5976
- const folders = listFolders(db, accountId);
5986
+ let folders = listFolders(db, accountId);
5987
+ if (!folders.length) folders = await pullFolders(s3);
5977
5988
  const results = [];
5978
5989
  let totalNew = 0;
5979
5990
  let totalExpunged = 0;
@@ -6012,21 +6023,7 @@ function createNetworkSurface(db, options) {
6012
6023
  }
6013
6024
  }
6014
6025
  },
6015
- refreshFolders: async () => {
6016
- const s3 = requireSession();
6017
- const imapFolders = await s3.listFolders();
6018
- const result = [];
6019
- for (const f of imapFolders) {
6020
- const upserted = upsertFolder(db, {
6021
- accountId,
6022
- path: f.path,
6023
- delimiter: f.delimiter,
6024
- role: f.role
6025
- });
6026
- result.push(upserted);
6027
- }
6028
- return result;
6029
- },
6026
+ refreshFolders: async () => pullFolders(requireSession()),
6030
6027
  searchRemote: async (folder, query) => {
6031
6028
  const s3 = requireSession();
6032
6029
  if (s3.selectedFolder !== folder) {
package/dist/mcp.cjs CHANGED
@@ -3541,7 +3541,8 @@ function createWriteSurface(db, options) {
3541
3541
  async function sendComposed(composed) {
3542
3542
  const raw2 = composed.toString("utf8");
3543
3543
  const fromMatch = raw2.match(/^From:\s*(.+?)$/m);
3544
- const fromAddr = fromMatch?.[1]?.match(/<(.+?)>|(\S+@\S+)/)?.[1] ?? "";
3544
+ const fromParts = fromMatch?.[1]?.match(/<(.+?)>|(\S+@\S+)/);
3545
+ const fromAddr = fromParts?.[1] ?? fromParts?.[2] ?? "";
3545
3546
  const toMatch = [...raw2.matchAll(/^(?:To|Cc|Bcc):\s*(.+?)$/gm)];
3546
3547
  const toAddrs = toMatch.flatMap(
3547
3548
  (m) => (m[1] ?? "").split(",").map((a) => (a.match(/<(.+?)>|(\S+@\S+)/)?.[1] ?? a).trim())
@@ -4867,6 +4868,15 @@ function createNetworkSurface(db, options) {
4867
4868
  }
4868
4869
  return session;
4869
4870
  }
4871
+ async function pullFolders(s3) {
4872
+ const result = [];
4873
+ for (const f of await s3.listFolders()) {
4874
+ result.push(
4875
+ upsertFolder(db, { accountId, path: f.path, delimiter: f.delimiter, role: f.role })
4876
+ );
4877
+ }
4878
+ return result;
4879
+ }
4870
4880
  return {
4871
4881
  connect: async () => {
4872
4882
  await requireSession().connect();
@@ -4898,7 +4908,8 @@ function createNetworkSurface(db, options) {
4898
4908
  },
4899
4909
  sync: async (syncOptions) => {
4900
4910
  const s3 = requireSession();
4901
- const folders = listFolders(db, accountId);
4911
+ let folders = listFolders(db, accountId);
4912
+ if (!folders.length) folders = await pullFolders(s3);
4902
4913
  const results = [];
4903
4914
  let totalNew = 0;
4904
4915
  let totalExpunged = 0;
@@ -4937,21 +4948,7 @@ function createNetworkSurface(db, options) {
4937
4948
  }
4938
4949
  }
4939
4950
  },
4940
- refreshFolders: async () => {
4941
- const s3 = requireSession();
4942
- const imapFolders = await s3.listFolders();
4943
- const result = [];
4944
- for (const f of imapFolders) {
4945
- const upserted = upsertFolder(db, {
4946
- accountId,
4947
- path: f.path,
4948
- delimiter: f.delimiter,
4949
- role: f.role
4950
- });
4951
- result.push(upserted);
4952
- }
4953
- return result;
4954
- },
4951
+ refreshFolders: async () => pullFolders(requireSession()),
4955
4952
  searchRemote: async (folder, query) => {
4956
4953
  const s3 = requireSession();
4957
4954
  if (s3.selectedFolder !== folder) {
@@ -5010,7 +5007,7 @@ var init_network = __esm({
5010
5007
  });
5011
5008
 
5012
5009
  // src/version.ts
5013
- var emailVersion = "0.5.0";
5010
+ var emailVersion = "0.5.1";
5014
5011
 
5015
5012
  // src/surface/email_mcp_instructions.ts
5016
5013
  var emailMcpInstructions = "Read and search cached email offline. Configure live accounts with email account add before network operations. Inspect messages before replying or changing folders. Confirm recipients and content before sending; trash and folder deletion can remove mail. Credentials use the existing email CLI account configuration or EMAIL_* environment variables.";
package/dist/mcp.js CHANGED
@@ -3517,7 +3517,8 @@ function createWriteSurface(db, options) {
3517
3517
  async function sendComposed(composed) {
3518
3518
  const raw2 = composed.toString("utf8");
3519
3519
  const fromMatch = raw2.match(/^From:\s*(.+?)$/m);
3520
- const fromAddr = fromMatch?.[1]?.match(/<(.+?)>|(\S+@\S+)/)?.[1] ?? "";
3520
+ const fromParts = fromMatch?.[1]?.match(/<(.+?)>|(\S+@\S+)/);
3521
+ const fromAddr = fromParts?.[1] ?? fromParts?.[2] ?? "";
3521
3522
  const toMatch = [...raw2.matchAll(/^(?:To|Cc|Bcc):\s*(.+?)$/gm)];
3522
3523
  const toAddrs = toMatch.flatMap(
3523
3524
  (m) => (m[1] ?? "").split(",").map((a) => (a.match(/<(.+?)>|(\S+@\S+)/)?.[1] ?? a).trim())
@@ -4843,6 +4844,15 @@ function createNetworkSurface(db, options) {
4843
4844
  }
4844
4845
  return session;
4845
4846
  }
4847
+ async function pullFolders(s3) {
4848
+ const result = [];
4849
+ for (const f of await s3.listFolders()) {
4850
+ result.push(
4851
+ upsertFolder(db, { accountId, path: f.path, delimiter: f.delimiter, role: f.role })
4852
+ );
4853
+ }
4854
+ return result;
4855
+ }
4846
4856
  return {
4847
4857
  connect: async () => {
4848
4858
  await requireSession().connect();
@@ -4874,7 +4884,8 @@ function createNetworkSurface(db, options) {
4874
4884
  },
4875
4885
  sync: async (syncOptions) => {
4876
4886
  const s3 = requireSession();
4877
- const folders = listFolders(db, accountId);
4887
+ let folders = listFolders(db, accountId);
4888
+ if (!folders.length) folders = await pullFolders(s3);
4878
4889
  const results = [];
4879
4890
  let totalNew = 0;
4880
4891
  let totalExpunged = 0;
@@ -4913,21 +4924,7 @@ function createNetworkSurface(db, options) {
4913
4924
  }
4914
4925
  }
4915
4926
  },
4916
- refreshFolders: async () => {
4917
- const s3 = requireSession();
4918
- const imapFolders = await s3.listFolders();
4919
- const result = [];
4920
- for (const f of imapFolders) {
4921
- const upserted = upsertFolder(db, {
4922
- accountId,
4923
- path: f.path,
4924
- delimiter: f.delimiter,
4925
- role: f.role
4926
- });
4927
- result.push(upserted);
4928
- }
4929
- return result;
4930
- },
4927
+ refreshFolders: async () => pullFolders(requireSession()),
4931
4928
  searchRemote: async (folder, query) => {
4932
4929
  const s3 = requireSession();
4933
4930
  if (s3.selectedFolder !== folder) {
@@ -4986,7 +4983,7 @@ var init_network = __esm({
4986
4983
  });
4987
4984
 
4988
4985
  // src/version.ts
4989
- var emailVersion = "0.5.0";
4986
+ var emailVersion = "0.5.1";
4990
4987
 
4991
4988
  // src/surface/email_mcp_instructions.ts
4992
4989
  var emailMcpInstructions = "Read and search cached email offline. Configure live accounts with email account add before network operations. Inspect messages before replying or changing folders. Confirm recipients and content before sending; trash and folder deletion can remove mail. Credentials use the existing email CLI account configuration or EMAIL_* environment variables.";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghostpaw/email",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Standalone IMAP/SMTP email engine for Node.js — SQLite local cache, threading, sync, zero dependencies, with a built-in LLM tool facade",
5
5
  "type": "module",
6
6
  "exports": {