@bobfrankston/rmfmail 1.2.329 → 1.2.333

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.
@@ -8835,6 +8835,8 @@ function parseStatusResponse(text) {
8835
8835
  data.uidValidity = val;
8836
8836
  else if (key === "UNSEEN")
8837
8837
  data.unseen = val;
8838
+ else if (key === "SIZE")
8839
+ data.size = val;
8838
8840
  }
8839
8841
  return data;
8840
8842
  }
@@ -8858,6 +8860,8 @@ function parseStatusResponseFull(text) {
8858
8860
  data.uidValidity = val;
8859
8861
  else if (key === "UNSEEN")
8860
8862
  data.unseen = val;
8863
+ else if (key === "SIZE")
8864
+ data.size = val;
8861
8865
  }
8862
8866
  return { mailbox, data };
8863
8867
  }
@@ -9477,9 +9481,11 @@ var NativeImapClient = class {
9477
9481
  console.error(` [imap] ${unparsed} LIST responses could not be parsed (${responses.length} total responses)`);
9478
9482
  return folders;
9479
9483
  }
9480
- async getStatus(mailbox) {
9484
+ // 2026-09-16 — Claude Code (Fable 5.1), at Bob's direction: `items` parameter added so a
9485
+ // caller can ask for RFC 8438 SIZE. Default unchanged, so existing callers see no difference.
9486
+ async getStatus(mailbox, items = ["MESSAGES", "UIDNEXT", "UNSEEN"]) {
9481
9487
  const tag = nextTag();
9482
- const responses = await this.sendCommand(tag, statusCommand(tag, mailbox, ["MESSAGES", "UIDNEXT", "UNSEEN"]));
9488
+ const responses = await this.sendCommand(tag, statusCommand(tag, mailbox, items));
9483
9489
  for (const r of responses) {
9484
9490
  if (r.tag === "*" && r.type === "STATUS") {
9485
9491
  const data = parseStatusResponse(r.text);
@@ -9489,6 +9495,44 @@ var NativeImapClient = class {
9489
9495
  }
9490
9496
  return {};
9491
9497
  }
9498
+ /**
9499
+ * Total size of a mailbox in octets plus its message count (for imail -sizes; added
9500
+ * 2026-09-16 by Claude Code, Fable 5.1, at Bob's direction).
9501
+ *
9502
+ * Fast path: RFC 8438 `STATUS (MESSAGES SIZE)` — one round trip, no message traffic —
9503
+ * when the server advertises STATUS=SIZE (Dovecot, Gmail do).
9504
+ * Fallback: EXAMINE (read-only) + `UID FETCH 1:* (UID RFC822.SIZE)` summed here. That
9505
+ * is one FETCH line per message but no envelopes or headers, so it stays cheap even
9506
+ * on a folder of tens of thousands of messages.
9507
+ *
9508
+ * `method` says which path produced the number so a log can show it.
9509
+ */
9510
+ async getFolderSize(mailbox) {
9511
+ if (this.capabilities.has("STATUS=SIZE")) {
9512
+ const st = await this.getStatus(mailbox, ["MESSAGES", "SIZE"]);
9513
+ if (typeof st.size === "number")
9514
+ return { messages: st.messages || 0, bytes: st.size, method: "status" };
9515
+ }
9516
+ const info = await this.examine(mailbox);
9517
+ try {
9518
+ if (!info.exists)
9519
+ return { messages: 0, bytes: 0, method: "fetch" };
9520
+ let messages = 0, bytes = 0;
9521
+ const tag = nextTag();
9522
+ await this.sendCommand(tag, fetchCommand(tag, "1:*", ["UID", "RFC822.SIZE"]), (r) => {
9523
+ if (r.tag !== "*" || r.type !== "FETCH")
9524
+ return;
9525
+ const m = r.text.match(/RFC822\.SIZE\s+(\d+)/);
9526
+ if (!m)
9527
+ return;
9528
+ messages++;
9529
+ bytes += parseInt(m[1]);
9530
+ });
9531
+ return { messages, bytes, method: "fetch" };
9532
+ } finally {
9533
+ await this.closeMailbox();
9534
+ }
9535
+ }
9492
9536
  async createMailbox(mailbox) {
9493
9537
  const tag = nextTag();
9494
9538
  const responses = await this.sendCommand(tag, createCommand(tag, mailbox));
@@ -10632,6 +10676,12 @@ var CompatImapClient = class {
10632
10676
  await this.ensureConnected();
10633
10677
  return this.native.getMessageCount(mailbox);
10634
10678
  }
10679
+ /** Mailbox size in octets + message count. STATUS=SIZE when the server has it, else a
10680
+ * size-only UID FETCH. See NativeImapClient.getFolderSize. (2026-09-16, Claude Code) */
10681
+ async getFolderSize(mailbox) {
10682
+ await this.ensureConnected();
10683
+ return this.native.getFolderSize(mailbox);
10684
+ }
10635
10685
  /** Get all UIDs in a mailbox */
10636
10686
  async getUids(mailbox) {
10637
10687
  await this.ensureConnected();