@kbzowski/mcp-inbox 0.4.0 → 0.5.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.
- package/README.md +25 -214
- package/dist/app.js +774 -398
- package/dist/cache/queries.d.ts +25 -3
- package/dist/cache/schema.d.ts +24 -2
- package/dist/cache/sync.d.ts +16 -6
- package/dist/config/env.d.ts +15 -27
- package/dist/imap/client.d.ts +9 -1
- package/dist/imap/mime-builder.d.ts +12 -0
- package/dist/imap/search.d.ts +6 -0
- package/dist/index.js +0 -1
- package/dist/migrations/20260804112339_fantastic_miss_america/migration.sql +1 -0
- package/dist/migrations/20260804112339_fantastic_miss_america/snapshot.json +310 -0
- package/dist/tools/compose-schema.d.ts +14 -0
- package/dist/tools/drafts/create-draft.d.ts +5 -0
- package/dist/tools/drafts/get-draft.d.ts +1 -1
- package/dist/tools/drafts/list-drafts.d.ts +1 -1
- package/dist/tools/drafts/update-draft.d.ts +5 -0
- package/dist/tools/emails/flags.d.ts +15 -0
- package/dist/tools/emails/get-email.d.ts +1 -1
- package/dist/tools/emails/list-emails.d.ts +1 -1
- package/dist/tools/emails/search-emails.d.ts +3 -1
- package/dist/tools/emails/set-flags.d.ts +13 -0
- package/dist/tools/emails/shared.d.ts +25 -27
- package/dist/tools/send/forward.d.ts +7 -1
- package/dist/tools/send/reply.d.ts +14 -1
- package/dist/tools/send/send-email.d.ts +5 -0
- package/package.json +12 -13
- package/dist/app.js.map +0 -7
- package/dist/index.js.map +0 -7
package/dist/cache/queries.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CacheDb } from './db';
|
|
2
|
-
import { type Folder, type FolderInsert, type Email, type EmailInsert } from './schema';
|
|
2
|
+
import { type AttachmentInfo, type Folder, type FolderInsert, type Email, type EmailInsert } from './schema';
|
|
3
3
|
/**
|
|
4
4
|
* Insert or update a folder row (matched on the primary-key `name`).
|
|
5
5
|
* Used after every SELECT to record the current UIDVALIDITY / UIDNEXT /
|
|
@@ -12,8 +12,20 @@ export declare function listFolders(db: CacheDb): Folder[];
|
|
|
12
12
|
* Insert or update an email envelope. Matched on (folder, uid) - IMAP UIDs
|
|
13
13
|
* are folder-scoped, never global.
|
|
14
14
|
*/
|
|
15
|
-
export declare function upsertEmail(db: CacheDb, row: EmailInsert): void;
|
|
15
|
+
export declare function upsertEmail(db: Pick<CacheDb, 'insert'>, row: EmailInsert): void;
|
|
16
|
+
/**
|
|
17
|
+
* Upsert many envelopes in one transaction. Outside a transaction every
|
|
18
|
+
* insert commits on its own, which on a cold sync of a large folder costs
|
|
19
|
+
* far more than the inserts themselves.
|
|
20
|
+
*/
|
|
21
|
+
export declare function upsertEmails(db: CacheDb, rows: readonly EmailInsert[]): void;
|
|
16
22
|
export declare function getEmail(db: CacheDb, folder: string, uid: number): Email | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Fetch many envelopes by UID, keyed for lookup. Batched, so a UID list
|
|
25
|
+
* over SQLite's parameter cap is safe. UIDs with no cached row are absent
|
|
26
|
+
* from the map rather than present as undefined.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getEmailsByUids(db: CacheDb, folder: string, uids: readonly number[]): Map<number, Email>;
|
|
17
29
|
export interface ListEmailsOptions {
|
|
18
30
|
/** Max rows to return. */
|
|
19
31
|
limit?: number;
|
|
@@ -46,6 +58,8 @@ export declare function listCachedUidsForFolder(db: CacheDb, folder: string): nu
|
|
|
46
58
|
* a FLAGS update.
|
|
47
59
|
*/
|
|
48
60
|
export declare function setEmailFlags(db: CacheDb, folder: string, uid: number, flags: string[]): void;
|
|
61
|
+
/** UIDs with no cached row are silently ignored. */
|
|
62
|
+
export declare function setFlagsForUids(db: CacheDb, folder: string, next: Map<number, string[]>): void;
|
|
49
63
|
/**
|
|
50
64
|
* Apply a flag-set mutation to each of the given UIDs. `mutate` receives
|
|
51
65
|
* the current flags and returns the new flags. Can't be a single SQL
|
|
@@ -71,13 +85,21 @@ export declare function deleteEmail(db: CacheDb, folder: string, uid: number): v
|
|
|
71
85
|
* EXPUNGE-detection path of the UID-diff sync fallback.
|
|
72
86
|
*/
|
|
73
87
|
export declare function deleteEmailsByUids(db: CacheDb, folder: string, uids: number[]): void;
|
|
88
|
+
/**
|
|
89
|
+
* Drop cached bodies last read before `cutoffMs`, keeping the envelope row.
|
|
90
|
+
* Envelopes are small and drive list/search; bodies are the unbounded part.
|
|
91
|
+
* Returns the number of rows cleared.
|
|
92
|
+
*/
|
|
93
|
+
export declare function pruneBodiesBefore(db: CacheDb, cutoffMs: number): number;
|
|
74
94
|
export interface CachedBody {
|
|
75
95
|
bodyText: string | null;
|
|
76
96
|
bodyHtml: string | null;
|
|
97
|
+
attachments: AttachmentInfo[] | null;
|
|
77
98
|
bodyCachedAt: number | null;
|
|
78
99
|
}
|
|
79
100
|
export declare function getEmailBody(db: CacheDb, folder: string, uid: number): CachedBody | undefined;
|
|
80
101
|
export declare function setEmailBody(db: CacheDb, folder: string, uid: number, body: {
|
|
81
102
|
text: string | null;
|
|
82
103
|
html: string | null;
|
|
83
|
-
|
|
104
|
+
attachments?: AttachmentInfo[];
|
|
105
|
+
}, nowMs: number): boolean;
|
package/dist/cache/schema.d.ts
CHANGED
|
@@ -131,8 +131,14 @@ export declare const folders: import("drizzle-orm/sqlite-core").SQLiteTableWithC
|
|
|
131
131
|
generated: undefined;
|
|
132
132
|
}, {}>;
|
|
133
133
|
};
|
|
134
|
-
dialect:
|
|
134
|
+
dialect: 'sqlite';
|
|
135
135
|
}>;
|
|
136
|
+
/** Metadata only - attachment bytes are never persisted. */
|
|
137
|
+
export interface AttachmentInfo {
|
|
138
|
+
filename: string | null;
|
|
139
|
+
content_type: string;
|
|
140
|
+
size_bytes: number;
|
|
141
|
+
}
|
|
136
142
|
/**
|
|
137
143
|
* Cached envelope + optional body for each message, keyed by folder + UID.
|
|
138
144
|
* IMAP UIDs are folder-scoped (and reset when UIDVALIDITY changes), so the
|
|
@@ -350,6 +356,22 @@ export declare const emails: import("drizzle-orm/sqlite-core").SQLiteTableWithCo
|
|
|
350
356
|
identity: undefined;
|
|
351
357
|
generated: undefined;
|
|
352
358
|
}, {}>;
|
|
359
|
+
attachmentsJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
360
|
+
name: string;
|
|
361
|
+
tableName: "emails";
|
|
362
|
+
dataType: "object json";
|
|
363
|
+
data: AttachmentInfo[];
|
|
364
|
+
driverParam: string;
|
|
365
|
+
notNull: false;
|
|
366
|
+
hasDefault: false;
|
|
367
|
+
isPrimaryKey: false;
|
|
368
|
+
isAutoincrement: false;
|
|
369
|
+
hasRuntimeDefault: false;
|
|
370
|
+
enumValues: undefined;
|
|
371
|
+
baseColumn: never;
|
|
372
|
+
identity: undefined;
|
|
373
|
+
generated: undefined;
|
|
374
|
+
}, {}>;
|
|
353
375
|
modseq: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
354
376
|
name: string;
|
|
355
377
|
tableName: "emails";
|
|
@@ -399,7 +421,7 @@ export declare const emails: import("drizzle-orm/sqlite-core").SQLiteTableWithCo
|
|
|
399
421
|
generated: undefined;
|
|
400
422
|
}, {}>;
|
|
401
423
|
};
|
|
402
|
-
dialect:
|
|
424
|
+
dialect: 'sqlite';
|
|
403
425
|
}>;
|
|
404
426
|
export type Folder = typeof folders.$inferSelect;
|
|
405
427
|
export type FolderInsert = typeof folders.$inferInsert;
|
package/dist/cache/sync.d.ts
CHANGED
|
@@ -18,15 +18,25 @@ export interface SyncResult {
|
|
|
18
18
|
*
|
|
19
19
|
* Algorithm:
|
|
20
20
|
* 1. SELECT the mailbox; read UIDVALIDITY, UIDNEXT, HIGHESTMODSEQ.
|
|
21
|
-
* 2. If cached UIDVALIDITY differs from server's → wipe folder cache
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* 4.
|
|
26
|
-
* UID-diff fallback for CONDSTORE-less servers).
|
|
21
|
+
* 2. If cached UIDVALIDITY differs from server's → wipe folder cache.
|
|
22
|
+
* 3. SEARCH ALL for the server's UID set, and diff it against the cache:
|
|
23
|
+
* evict what the server no longer has, fetch envelopes for what we
|
|
24
|
+
* don't have yet.
|
|
25
|
+
* 4. Refresh flags over the rest, narrowed by CONDSTORE when available.
|
|
27
26
|
* 5. Persist the new folder sync state.
|
|
28
27
|
*/
|
|
29
28
|
export declare function syncFolder(ctx: SyncContext, folderPath: string): Promise<SyncResult>;
|
|
29
|
+
export declare function diffUids(cached: readonly number[], server: readonly number[]): {
|
|
30
|
+
missing: number[];
|
|
31
|
+
ghosts: number[];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* CHANGEDSINCE is a CONDSTORE-only FETCH modifier. Sending it to a server that
|
|
35
|
+
* does not advertise CONDSTORE earns a BAD response and fails the whole sync,
|
|
36
|
+
* so gate it on what the server reports now - not on a modseq we cached back
|
|
37
|
+
* when it still supported the extension.
|
|
38
|
+
*/
|
|
39
|
+
export declare function changedSinceFor(serverModseq: number | null, cachedModseq: number | null | undefined): number | null;
|
|
30
40
|
/**
|
|
31
41
|
* Map an ImapFlow message into the EmailInsert shape. Exported so tools
|
|
32
42
|
* that fetch envelopes outside the main sync path (e.g. search auto-fill)
|
package/dist/config/env.d.ts
CHANGED
|
@@ -5,37 +5,29 @@ declare const EnvSchema: z.ZodPipe<z.ZodObject<{
|
|
|
5
5
|
IMAP_HOST: z.ZodString;
|
|
6
6
|
IMAP_PORT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
7
7
|
IMAP_TLS: z.ZodDefault<z.ZodPipe<z.ZodEnum<{
|
|
8
|
-
true: "true";
|
|
9
8
|
false: "false";
|
|
10
|
-
}>, z.ZodTransform<boolean, "true" | "false">>>;
|
|
11
|
-
IMAP_TLS_REJECT_UNAUTHORIZED: z.ZodDefault<z.ZodPipe<z.ZodEnum<{
|
|
12
9
|
true: "true";
|
|
10
|
+
}>, z.ZodTransform<boolean, "false" | "true">>>;
|
|
11
|
+
IMAP_TLS_REJECT_UNAUTHORIZED: z.ZodDefault<z.ZodPipe<z.ZodEnum<{
|
|
13
12
|
false: "false";
|
|
14
|
-
|
|
13
|
+
true: "true";
|
|
14
|
+
}>, z.ZodTransform<boolean, "false" | "true">>>;
|
|
15
15
|
IMAP_AUTH_TIMEOUT_MS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
16
16
|
SMTP_HOST: z.ZodOptional<z.ZodString>;
|
|
17
17
|
SMTP_PORT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
18
18
|
SMTP_SECURE: z.ZodDefault<z.ZodPipe<z.ZodEnum<{
|
|
19
|
-
true: "true";
|
|
20
19
|
false: "false";
|
|
21
|
-
|
|
20
|
+
true: "true";
|
|
21
|
+
}>, z.ZodTransform<boolean, "false" | "true">>>;
|
|
22
22
|
SMTP_USER: z.ZodOptional<z.ZodString>;
|
|
23
23
|
SMTP_PASSWORD: z.ZodOptional<z.ZodString>;
|
|
24
|
-
IMAP_CACHE_ENABLED: z.ZodDefault<z.ZodPipe<z.ZodEnum<{
|
|
25
|
-
true: "true";
|
|
26
|
-
false: "false";
|
|
27
|
-
}>, z.ZodTransform<boolean, "true" | "false">>>;
|
|
28
24
|
IMAP_CACHE_DIR: z.ZodOptional<z.ZodString>;
|
|
29
|
-
IMAP_CACHE_BODY_INLINE: z.ZodDefault<z.ZodPipe<z.ZodEnum<{
|
|
30
|
-
true: "true";
|
|
31
|
-
false: "false";
|
|
32
|
-
}>, z.ZodTransform<boolean, "true" | "false">>>;
|
|
33
25
|
IMAP_CACHE_DEFAULT_STALENESS_SEC: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
34
|
-
|
|
26
|
+
IMAP_CACHE_BODY_RETAIN_DAYS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
35
27
|
IMAP_IDLE_ENABLED: z.ZodDefault<z.ZodPipe<z.ZodEnum<{
|
|
36
|
-
true: "true";
|
|
37
28
|
false: "false";
|
|
38
|
-
|
|
29
|
+
true: "true";
|
|
30
|
+
}>, z.ZodTransform<boolean, "false" | "true">>>;
|
|
39
31
|
IMAP_IDLE_FOLDERS: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
|
|
40
32
|
DEBUG: z.ZodOptional<z.ZodString>;
|
|
41
33
|
}, z.core.$strip>, z.ZodTransform<{
|
|
@@ -56,11 +48,9 @@ declare const EnvSchema: z.ZodPipe<z.ZodObject<{
|
|
|
56
48
|
password: string;
|
|
57
49
|
};
|
|
58
50
|
cache: {
|
|
59
|
-
enabled: boolean;
|
|
60
51
|
dir: string;
|
|
61
|
-
eagerBodyCache: boolean;
|
|
62
52
|
defaultStalenessSec: number;
|
|
63
|
-
|
|
53
|
+
bodyRetainDays: number;
|
|
64
54
|
};
|
|
65
55
|
idle: {
|
|
66
56
|
enabled: boolean;
|
|
@@ -75,18 +65,16 @@ declare const EnvSchema: z.ZodPipe<z.ZodObject<{
|
|
|
75
65
|
IMAP_TLS: boolean;
|
|
76
66
|
IMAP_TLS_REJECT_UNAUTHORIZED: boolean;
|
|
77
67
|
IMAP_AUTH_TIMEOUT_MS: number;
|
|
68
|
+
SMTP_HOST?: string | undefined;
|
|
78
69
|
SMTP_PORT: number;
|
|
79
70
|
SMTP_SECURE: boolean;
|
|
80
|
-
IMAP_CACHE_ENABLED: boolean;
|
|
81
|
-
IMAP_CACHE_BODY_INLINE: boolean;
|
|
82
|
-
IMAP_CACHE_DEFAULT_STALENESS_SEC: number;
|
|
83
|
-
IMAP_CACHE_RETAIN_DAYS: number;
|
|
84
|
-
IMAP_IDLE_ENABLED: boolean;
|
|
85
|
-
IMAP_IDLE_FOLDERS: string[];
|
|
86
|
-
SMTP_HOST?: string | undefined;
|
|
87
71
|
SMTP_USER?: string | undefined;
|
|
88
72
|
SMTP_PASSWORD?: string | undefined;
|
|
89
73
|
IMAP_CACHE_DIR?: string | undefined;
|
|
74
|
+
IMAP_CACHE_DEFAULT_STALENESS_SEC: number;
|
|
75
|
+
IMAP_CACHE_BODY_RETAIN_DAYS: number;
|
|
76
|
+
IMAP_IDLE_ENABLED: boolean;
|
|
77
|
+
IMAP_IDLE_FOLDERS: string[];
|
|
90
78
|
DEBUG?: string | undefined;
|
|
91
79
|
}>>;
|
|
92
80
|
export type AppConfig = z.infer<typeof EnvSchema>;
|
package/dist/imap/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ImapFlow } from 'imapflow';
|
|
1
|
+
import { ImapFlow, type ListResponse } from 'imapflow';
|
|
2
2
|
import type { AppConfig } from '../config/env';
|
|
3
3
|
/**
|
|
4
4
|
* Build and connect an ImapFlow instance from the env-level IMAP config.
|
|
@@ -30,6 +30,14 @@ export declare class ImapClient {
|
|
|
30
30
|
* Multiple concurrent callers share the same in-flight connection attempt.
|
|
31
31
|
*/
|
|
32
32
|
connection(): Promise<ImapFlow>;
|
|
33
|
+
/**
|
|
34
|
+
* The mailbox list, cached for `maxAgeMs`. Resolving \Drafts / \Sent /
|
|
35
|
+
* \Trash needs it on every send, draft and delete, and a LIST is a network
|
|
36
|
+
* round-trip whose answer almost never changes. A newly created folder
|
|
37
|
+
* shows up within the window; `imap_list_folders` bypasses this entirely,
|
|
38
|
+
* so an explicit "what folders do I have" is always current.
|
|
39
|
+
*/
|
|
40
|
+
folderList(maxAgeMs?: number): Promise<ListResponse[]>;
|
|
33
41
|
/**
|
|
34
42
|
* Cleanly close the connection. Safe to call multiple times.
|
|
35
43
|
*/
|
|
@@ -6,6 +6,17 @@
|
|
|
6
6
|
* RFC 2047 encoded-word for non-ASCII headers, RFC 5322 line folding,
|
|
7
7
|
* multipart boundaries, and Message-ID generation automatically.
|
|
8
8
|
*/
|
|
9
|
+
export interface MessageAttachment {
|
|
10
|
+
filename: string;
|
|
11
|
+
content: Buffer;
|
|
12
|
+
/** Omit to let nodemailer sniff the type from `filename`. */
|
|
13
|
+
contentType?: string;
|
|
14
|
+
/**
|
|
15
|
+
* nodemailer defaults `message/*` parts to `inline`, which makes clients
|
|
16
|
+
* expand a forwarded message instead of offering it as a saveable file.
|
|
17
|
+
*/
|
|
18
|
+
contentDisposition?: 'attachment' | 'inline';
|
|
19
|
+
}
|
|
9
20
|
export interface BuildMessageInput {
|
|
10
21
|
from: string;
|
|
11
22
|
to: string | string[];
|
|
@@ -19,6 +30,7 @@ export interface BuildMessageInput {
|
|
|
19
30
|
references?: string | string[];
|
|
20
31
|
/** Optional extra headers (e.g. X-Mailer). */
|
|
21
32
|
headers?: Record<string, string>;
|
|
33
|
+
attachments?: MessageAttachment[];
|
|
22
34
|
}
|
|
23
35
|
/**
|
|
24
36
|
* Build a raw RFC 2822 message buffer, suitable for `IMAP APPEND` to the
|
package/dist/imap/search.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ export interface EmailSearchCriteria {
|
|
|
15
15
|
body?: string | undefined;
|
|
16
16
|
/** If true, only messages without `\Seen`. If undefined/false, no filter. */
|
|
17
17
|
unseen?: boolean | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Unlike `unseen`, these are three-state: true matches flagged/answered,
|
|
20
|
+
* false matches explicitly unflagged/unanswered, undefined does not filter.
|
|
21
|
+
*/
|
|
22
|
+
flagged?: boolean | undefined;
|
|
23
|
+
answered?: boolean | undefined;
|
|
18
24
|
/** Only messages received on/after this date. */
|
|
19
25
|
since?: Date | undefined;
|
|
20
26
|
/** Only messages received before this date. */
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `emails` ADD `attachments_json` text;
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "7",
|
|
3
|
+
"dialect": "sqlite",
|
|
4
|
+
"id": "a62d5cf7-0616-477c-818a-4896f264206d",
|
|
5
|
+
"prevIds": [
|
|
6
|
+
"5dc14bb7-bda9-4cba-88e2-489364cbb8fb"
|
|
7
|
+
],
|
|
8
|
+
"ddl": [
|
|
9
|
+
{
|
|
10
|
+
"name": "emails",
|
|
11
|
+
"entityType": "tables"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "folders",
|
|
15
|
+
"entityType": "tables"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"type": "text",
|
|
19
|
+
"notNull": true,
|
|
20
|
+
"autoincrement": false,
|
|
21
|
+
"default": null,
|
|
22
|
+
"generated": null,
|
|
23
|
+
"name": "folder",
|
|
24
|
+
"entityType": "columns",
|
|
25
|
+
"table": "emails"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "integer",
|
|
29
|
+
"notNull": true,
|
|
30
|
+
"autoincrement": false,
|
|
31
|
+
"default": null,
|
|
32
|
+
"generated": null,
|
|
33
|
+
"name": "uid",
|
|
34
|
+
"entityType": "columns",
|
|
35
|
+
"table": "emails"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"type": "text",
|
|
39
|
+
"notNull": false,
|
|
40
|
+
"autoincrement": false,
|
|
41
|
+
"default": null,
|
|
42
|
+
"generated": null,
|
|
43
|
+
"name": "message_id",
|
|
44
|
+
"entityType": "columns",
|
|
45
|
+
"table": "emails"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"type": "text",
|
|
49
|
+
"notNull": false,
|
|
50
|
+
"autoincrement": false,
|
|
51
|
+
"default": null,
|
|
52
|
+
"generated": null,
|
|
53
|
+
"name": "subject",
|
|
54
|
+
"entityType": "columns",
|
|
55
|
+
"table": "emails"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "text",
|
|
59
|
+
"notNull": false,
|
|
60
|
+
"autoincrement": false,
|
|
61
|
+
"default": null,
|
|
62
|
+
"generated": null,
|
|
63
|
+
"name": "from_addr",
|
|
64
|
+
"entityType": "columns",
|
|
65
|
+
"table": "emails"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"type": "text",
|
|
69
|
+
"notNull": false,
|
|
70
|
+
"autoincrement": false,
|
|
71
|
+
"default": null,
|
|
72
|
+
"generated": null,
|
|
73
|
+
"name": "to_addrs",
|
|
74
|
+
"entityType": "columns",
|
|
75
|
+
"table": "emails"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"type": "text",
|
|
79
|
+
"notNull": false,
|
|
80
|
+
"autoincrement": false,
|
|
81
|
+
"default": null,
|
|
82
|
+
"generated": null,
|
|
83
|
+
"name": "cc_addrs",
|
|
84
|
+
"entityType": "columns",
|
|
85
|
+
"table": "emails"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"type": "integer",
|
|
89
|
+
"notNull": false,
|
|
90
|
+
"autoincrement": false,
|
|
91
|
+
"default": null,
|
|
92
|
+
"generated": null,
|
|
93
|
+
"name": "date",
|
|
94
|
+
"entityType": "columns",
|
|
95
|
+
"table": "emails"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"type": "text",
|
|
99
|
+
"notNull": true,
|
|
100
|
+
"autoincrement": false,
|
|
101
|
+
"default": null,
|
|
102
|
+
"generated": null,
|
|
103
|
+
"name": "flags",
|
|
104
|
+
"entityType": "columns",
|
|
105
|
+
"table": "emails"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"type": "integer",
|
|
109
|
+
"notNull": true,
|
|
110
|
+
"autoincrement": false,
|
|
111
|
+
"default": "false",
|
|
112
|
+
"generated": null,
|
|
113
|
+
"name": "has_attachments",
|
|
114
|
+
"entityType": "columns",
|
|
115
|
+
"table": "emails"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"type": "text",
|
|
119
|
+
"notNull": true,
|
|
120
|
+
"autoincrement": false,
|
|
121
|
+
"default": null,
|
|
122
|
+
"generated": null,
|
|
123
|
+
"name": "envelope_json",
|
|
124
|
+
"entityType": "columns",
|
|
125
|
+
"table": "emails"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"type": "text",
|
|
129
|
+
"notNull": false,
|
|
130
|
+
"autoincrement": false,
|
|
131
|
+
"default": null,
|
|
132
|
+
"generated": null,
|
|
133
|
+
"name": "body_text",
|
|
134
|
+
"entityType": "columns",
|
|
135
|
+
"table": "emails"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"type": "text",
|
|
139
|
+
"notNull": false,
|
|
140
|
+
"autoincrement": false,
|
|
141
|
+
"default": null,
|
|
142
|
+
"generated": null,
|
|
143
|
+
"name": "body_html",
|
|
144
|
+
"entityType": "columns",
|
|
145
|
+
"table": "emails"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"type": "text",
|
|
149
|
+
"notNull": false,
|
|
150
|
+
"autoincrement": false,
|
|
151
|
+
"default": null,
|
|
152
|
+
"generated": null,
|
|
153
|
+
"name": "attachments_json",
|
|
154
|
+
"entityType": "columns",
|
|
155
|
+
"table": "emails"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"type": "integer",
|
|
159
|
+
"notNull": false,
|
|
160
|
+
"autoincrement": false,
|
|
161
|
+
"default": null,
|
|
162
|
+
"generated": null,
|
|
163
|
+
"name": "modseq",
|
|
164
|
+
"entityType": "columns",
|
|
165
|
+
"table": "emails"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"type": "integer",
|
|
169
|
+
"notNull": true,
|
|
170
|
+
"autoincrement": false,
|
|
171
|
+
"default": null,
|
|
172
|
+
"generated": null,
|
|
173
|
+
"name": "cached_at",
|
|
174
|
+
"entityType": "columns",
|
|
175
|
+
"table": "emails"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"type": "integer",
|
|
179
|
+
"notNull": false,
|
|
180
|
+
"autoincrement": false,
|
|
181
|
+
"default": null,
|
|
182
|
+
"generated": null,
|
|
183
|
+
"name": "body_cached_at",
|
|
184
|
+
"entityType": "columns",
|
|
185
|
+
"table": "emails"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"type": "text",
|
|
189
|
+
"notNull": false,
|
|
190
|
+
"autoincrement": false,
|
|
191
|
+
"default": null,
|
|
192
|
+
"generated": null,
|
|
193
|
+
"name": "name",
|
|
194
|
+
"entityType": "columns",
|
|
195
|
+
"table": "folders"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"type": "text",
|
|
199
|
+
"notNull": true,
|
|
200
|
+
"autoincrement": false,
|
|
201
|
+
"default": null,
|
|
202
|
+
"generated": null,
|
|
203
|
+
"name": "delimiter",
|
|
204
|
+
"entityType": "columns",
|
|
205
|
+
"table": "folders"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"type": "text",
|
|
209
|
+
"notNull": false,
|
|
210
|
+
"autoincrement": false,
|
|
211
|
+
"default": null,
|
|
212
|
+
"generated": null,
|
|
213
|
+
"name": "special_use",
|
|
214
|
+
"entityType": "columns",
|
|
215
|
+
"table": "folders"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"type": "integer",
|
|
219
|
+
"notNull": true,
|
|
220
|
+
"autoincrement": false,
|
|
221
|
+
"default": null,
|
|
222
|
+
"generated": null,
|
|
223
|
+
"name": "uid_validity",
|
|
224
|
+
"entityType": "columns",
|
|
225
|
+
"table": "folders"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"type": "integer",
|
|
229
|
+
"notNull": false,
|
|
230
|
+
"autoincrement": false,
|
|
231
|
+
"default": null,
|
|
232
|
+
"generated": null,
|
|
233
|
+
"name": "uid_next",
|
|
234
|
+
"entityType": "columns",
|
|
235
|
+
"table": "folders"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"type": "integer",
|
|
239
|
+
"notNull": false,
|
|
240
|
+
"autoincrement": false,
|
|
241
|
+
"default": null,
|
|
242
|
+
"generated": null,
|
|
243
|
+
"name": "highest_modseq",
|
|
244
|
+
"entityType": "columns",
|
|
245
|
+
"table": "folders"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"type": "integer",
|
|
249
|
+
"notNull": true,
|
|
250
|
+
"autoincrement": false,
|
|
251
|
+
"default": null,
|
|
252
|
+
"generated": null,
|
|
253
|
+
"name": "last_synced_at",
|
|
254
|
+
"entityType": "columns",
|
|
255
|
+
"table": "folders"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"columns": [
|
|
259
|
+
"folder",
|
|
260
|
+
"uid"
|
|
261
|
+
],
|
|
262
|
+
"nameExplicit": false,
|
|
263
|
+
"name": "emails_pk",
|
|
264
|
+
"entityType": "pks",
|
|
265
|
+
"table": "emails"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"columns": [
|
|
269
|
+
"name"
|
|
270
|
+
],
|
|
271
|
+
"nameExplicit": false,
|
|
272
|
+
"name": "folders_pk",
|
|
273
|
+
"table": "folders",
|
|
274
|
+
"entityType": "pks"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"columns": [
|
|
278
|
+
{
|
|
279
|
+
"value": "folder",
|
|
280
|
+
"isExpression": false
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"value": "date",
|
|
284
|
+
"isExpression": false
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
"isUnique": false,
|
|
288
|
+
"where": null,
|
|
289
|
+
"origin": "manual",
|
|
290
|
+
"name": "idx_emails_date",
|
|
291
|
+
"entityType": "indexes",
|
|
292
|
+
"table": "emails"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"columns": [
|
|
296
|
+
{
|
|
297
|
+
"value": "message_id",
|
|
298
|
+
"isExpression": false
|
|
299
|
+
}
|
|
300
|
+
],
|
|
301
|
+
"isUnique": false,
|
|
302
|
+
"where": null,
|
|
303
|
+
"origin": "manual",
|
|
304
|
+
"name": "idx_emails_message_id",
|
|
305
|
+
"entityType": "indexes",
|
|
306
|
+
"table": "emails"
|
|
307
|
+
}
|
|
308
|
+
],
|
|
309
|
+
"renames": []
|
|
310
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { MessageAttachment } from '../imap/mime-builder';
|
|
3
|
+
export declare const AddressList: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
4
|
+
export declare const AttachmentInput: z.ZodObject<{
|
|
5
|
+
filename: z.ZodString;
|
|
6
|
+
content_base64: z.ZodBase64;
|
|
7
|
+
content_type: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare const AttachmentList: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
10
|
+
filename: z.ZodString;
|
|
11
|
+
content_base64: z.ZodBase64;
|
|
12
|
+
content_type: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>>>;
|
|
14
|
+
export declare function toMessageAttachments(input: z.infer<typeof AttachmentInput>[] | undefined): MessageAttachment[] | undefined;
|
|
@@ -8,4 +8,9 @@ export declare const createDraftTool: import("../define-tool").ToolDefinition<z.
|
|
|
8
8
|
bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
9
9
|
from: z.ZodOptional<z.ZodString>;
|
|
10
10
|
folder: z.ZodOptional<z.ZodString>;
|
|
11
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
12
|
+
filename: z.ZodString;
|
|
13
|
+
content_base64: z.ZodBase64;
|
|
14
|
+
content_type: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strip>>>;
|
|
11
16
|
}, z.core.$strip>>;
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
export declare const getDraftTool: import("../define-tool").ToolDefinition<z.ZodObject<{
|
|
3
3
|
uid: z.ZodNumber;
|
|
4
4
|
folder: z.ZodOptional<z.ZodString>;
|
|
5
|
-
max_staleness_seconds: z.
|
|
5
|
+
max_staleness_seconds: z.ZodOptional<z.ZodNumber>;
|
|
6
6
|
response_format: z.ZodDefault<z.ZodEnum<{
|
|
7
7
|
json: "json";
|
|
8
8
|
markdown: "markdown";
|
|
@@ -3,7 +3,7 @@ export declare const listDraftsTool: import("../define-tool").ToolDefinition<z.Z
|
|
|
3
3
|
folder: z.ZodOptional<z.ZodString>;
|
|
4
4
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
offset: z.ZodDefault<z.ZodNumber>;
|
|
6
|
-
max_staleness_seconds: z.
|
|
6
|
+
max_staleness_seconds: z.ZodOptional<z.ZodNumber>;
|
|
7
7
|
response_format: z.ZodDefault<z.ZodEnum<{
|
|
8
8
|
json: "json";
|
|
9
9
|
markdown: "markdown";
|
|
@@ -9,4 +9,9 @@ export declare const updateDraftTool: import("../define-tool").ToolDefinition<z.
|
|
|
9
9
|
bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
10
10
|
from: z.ZodOptional<z.ZodString>;
|
|
11
11
|
folder: z.ZodOptional<z.ZodString>;
|
|
12
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
13
|
+
filename: z.ZodString;
|
|
14
|
+
content_base64: z.ZodBase64;
|
|
15
|
+
content_type: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, z.core.$strip>>>;
|
|
12
17
|
}, z.core.$strip>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ToolContext } from '../define-tool';
|
|
2
|
+
export interface FlagChange {
|
|
3
|
+
add?: string[];
|
|
4
|
+
remove?: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Add and/or remove IMAP flags on a set of UIDs, then write through to the
|
|
8
|
+
* cache. Returns false when the server accepted the command but reported no
|
|
9
|
+
* change (UID gone, mailbox opened read-only) - the cache is left alone in
|
|
10
|
+
* that case so it never claims a flag the server does not hold.
|
|
11
|
+
*
|
|
12
|
+
* Callers must not hold a mailbox lock: ImapFlow serialises locks per
|
|
13
|
+
* connection and this takes its own, so nesting deadlocks.
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyFlags(ctx: ToolContext, folder: string, uids: number[], change: FlagChange): Promise<boolean>;
|