@kbzowski/mcp-inbox 0.1.1 → 0.2.0

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.
@@ -39,6 +39,16 @@ export declare function countEmailsInFolder(db: CacheDb, folder: string): number
39
39
  * a FLAGS update.
40
40
  */
41
41
  export declare function setEmailFlags(db: CacheDb, folder: string, uid: number, flags: string[]): void;
42
+ /**
43
+ * Apply a flag-set mutation to each of the given UIDs. `mutate` receives
44
+ * the current flags and returns the new flags. Can't be a single SQL
45
+ * UPDATE because existing flags vary per row (we're adding/removing
46
+ * \Seen, not replacing). Wrapped in a transaction so either all rows
47
+ * update or none do.
48
+ *
49
+ * No-ops on empty UID list.
50
+ */
51
+ export declare function mutateEmailFlagsForUids(db: CacheDb, folder: string, uids: number[], mutate: (current: string[]) => string[]): void;
42
52
  /**
43
53
  * Wipe every cached message in a folder. Invoked when UIDVALIDITY changes
44
54
  * on the server - all our UIDs have been invalidated at once.
@@ -2,27 +2,41 @@ import type { SearchObject } from 'imapflow';
2
2
  /**
3
3
  * Typed IMAP search criteria, produced by our Zod-validated tool inputs.
4
4
  *
5
- * This type is the single source of truth for what every `imap_*_emails`
6
- * tool accepts. It stays deliberately narrow - ImapFlow's `SearchObject`
7
- * is much richer (flags, modseq, gmail extensions) but most of that
8
- * surface isn't exposed to tool callers.
5
+ * Recursive via `or` and `not`: tools can build `{subject, or: [{from}, {from}]}`
6
+ * which maps to `subject=X AND (from=a OR from=b)` at the IMAP layer.
7
+ *
8
+ * The type stays narrower than ImapFlow's full `SearchObject` - we don't
9
+ * expose modseq, Gmail extensions, or custom keywords yet.
9
10
  */
10
11
  export interface EmailSearchCriteria {
11
- subject?: string;
12
- from?: string;
13
- to?: string;
14
- body?: string;
12
+ subject?: string | undefined;
13
+ from?: string | undefined;
14
+ to?: string | undefined;
15
+ body?: string | undefined;
15
16
  /** If true, only messages without `\Seen`. If undefined/false, no filter. */
16
- unseen?: boolean;
17
- /** Only messages received on/after this date (Date or ISO string). */
18
- since?: Date;
17
+ unseen?: boolean | undefined;
18
+ /** Only messages received on/after this date. */
19
+ since?: Date | undefined;
19
20
  /** Only messages received before this date. */
20
- before?: Date;
21
+ before?: Date | undefined;
22
+ /** Only messages larger than this many bytes. */
23
+ larger_than_bytes?: number | undefined;
24
+ /** Only messages smaller than this many bytes. */
25
+ smaller_than_bytes?: number | undefined;
26
+ /**
27
+ * Array of sub-criteria (>=2); at least one must match. Maps to IMAP OR.
28
+ * IMAP OR is strictly binary on the wire but ImapFlow unrolls arrays
29
+ * for us, so `or: [a, b, c]` works as (a OR b OR c).
30
+ */
31
+ or?: EmailSearchCriteria[] | undefined;
32
+ /** Sub-criteria that must NOT match. Maps to IMAP NOT. */
33
+ not?: EmailSearchCriteria | undefined;
21
34
  }
22
35
  /**
23
36
  * Convert our typed criteria into ImapFlow's `SearchObject`.
24
37
  *
25
- * An empty criteria object yields `{ all: true }` - ImapFlow sends that
26
- * as a bare IMAP `ALL`, matching every message in the mailbox.
38
+ * Recurses into `or` and `not` so full boolean trees survive the
39
+ * translation. Empty criteria objects yield `{ all: true }`, matching
40
+ * every message - preserves the old behavior when no filters are set.
27
41
  */
28
42
  export declare function buildImapSearch(c: EmailSearchCriteria): SearchObject;