@ghostpaw/email 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.
- package/LICENSE +21 -0
- package/README.md +242 -0
- package/dist/index.cjs +5933 -0
- package/dist/index.d.cts +2442 -0
- package/dist/index.d.ts +2442 -0
- package/dist/index.js +5879 -0
- package/package.json +97 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2442 @@
|
|
|
1
|
+
import { Writable, Duplex } from 'node:stream';
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
4
|
+
|
|
5
|
+
interface EmailRunResult {
|
|
6
|
+
lastInsertRowid: number | bigint;
|
|
7
|
+
changes?: number | bigint | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface EmailStatement {
|
|
10
|
+
run(...params: unknown[]): EmailRunResult;
|
|
11
|
+
get<TRecord>(...params: unknown[]): TRecord | undefined;
|
|
12
|
+
all<TRecord>(...params: unknown[]): TRecord[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* SQLite dependency injected into every email operation.
|
|
16
|
+
* Node.js `DatabaseSync` satisfies this interface directly.
|
|
17
|
+
*/
|
|
18
|
+
type EmailDb = {
|
|
19
|
+
exec(sql: string): void;
|
|
20
|
+
prepare(sql: string): EmailStatement;
|
|
21
|
+
close(): void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type EmailErrorCode = 'invariant' | 'not_found' | 'state' | 'validation' | 'auth' | 'connection' | 'protocol' | 'timeout' | 'unsupported' | 'envelope_rejected' | 'quota';
|
|
25
|
+
declare class EmailError extends Error {
|
|
26
|
+
readonly code: EmailErrorCode;
|
|
27
|
+
constructor(code: EmailErrorCode, message: string);
|
|
28
|
+
}
|
|
29
|
+
declare class EmailInvariantError extends EmailError {
|
|
30
|
+
constructor(message: string);
|
|
31
|
+
}
|
|
32
|
+
declare class EmailNotFoundError extends EmailError {
|
|
33
|
+
constructor(message: string);
|
|
34
|
+
}
|
|
35
|
+
declare class EmailStateError extends EmailError {
|
|
36
|
+
constructor(message: string);
|
|
37
|
+
}
|
|
38
|
+
declare class EmailValidationError extends EmailError {
|
|
39
|
+
constructor(message: string);
|
|
40
|
+
}
|
|
41
|
+
declare class EmailAuthError extends EmailError {
|
|
42
|
+
readonly mechanism: string | undefined;
|
|
43
|
+
constructor(message: string, mechanism?: string);
|
|
44
|
+
}
|
|
45
|
+
declare class EmailConnectionError extends EmailError {
|
|
46
|
+
constructor(message: string);
|
|
47
|
+
}
|
|
48
|
+
declare class EmailProtocolError extends EmailError {
|
|
49
|
+
readonly rawResponse: string | undefined;
|
|
50
|
+
readonly tag: string | undefined;
|
|
51
|
+
readonly smtpCode: number | undefined;
|
|
52
|
+
constructor(message: string, options?: {
|
|
53
|
+
rawResponse?: string;
|
|
54
|
+
tag?: string;
|
|
55
|
+
smtpCode?: number;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
declare class EmailTimeoutError extends EmailError {
|
|
59
|
+
constructor(message: string);
|
|
60
|
+
}
|
|
61
|
+
declare class EmailUnsupportedError extends EmailError {
|
|
62
|
+
readonly feature: string;
|
|
63
|
+
constructor(feature: string, message?: string);
|
|
64
|
+
}
|
|
65
|
+
declare class EmailEnvelopeRejectedError extends EmailError {
|
|
66
|
+
readonly smtpCode: number;
|
|
67
|
+
constructor(message: string, smtpCode: number);
|
|
68
|
+
}
|
|
69
|
+
declare class EmailQuotaError extends EmailError {
|
|
70
|
+
readonly used: number | undefined;
|
|
71
|
+
readonly limit: number | undefined;
|
|
72
|
+
constructor(message: string, used?: number, limit?: number);
|
|
73
|
+
}
|
|
74
|
+
declare function isEmailError(value: unknown): value is EmailError;
|
|
75
|
+
declare function isRetriable(error: unknown): boolean;
|
|
76
|
+
|
|
77
|
+
type errors_EmailAuthError = EmailAuthError;
|
|
78
|
+
declare const errors_EmailAuthError: typeof EmailAuthError;
|
|
79
|
+
type errors_EmailConnectionError = EmailConnectionError;
|
|
80
|
+
declare const errors_EmailConnectionError: typeof EmailConnectionError;
|
|
81
|
+
type errors_EmailEnvelopeRejectedError = EmailEnvelopeRejectedError;
|
|
82
|
+
declare const errors_EmailEnvelopeRejectedError: typeof EmailEnvelopeRejectedError;
|
|
83
|
+
type errors_EmailError = EmailError;
|
|
84
|
+
declare const errors_EmailError: typeof EmailError;
|
|
85
|
+
type errors_EmailErrorCode = EmailErrorCode;
|
|
86
|
+
type errors_EmailInvariantError = EmailInvariantError;
|
|
87
|
+
declare const errors_EmailInvariantError: typeof EmailInvariantError;
|
|
88
|
+
type errors_EmailNotFoundError = EmailNotFoundError;
|
|
89
|
+
declare const errors_EmailNotFoundError: typeof EmailNotFoundError;
|
|
90
|
+
type errors_EmailProtocolError = EmailProtocolError;
|
|
91
|
+
declare const errors_EmailProtocolError: typeof EmailProtocolError;
|
|
92
|
+
type errors_EmailQuotaError = EmailQuotaError;
|
|
93
|
+
declare const errors_EmailQuotaError: typeof EmailQuotaError;
|
|
94
|
+
type errors_EmailStateError = EmailStateError;
|
|
95
|
+
declare const errors_EmailStateError: typeof EmailStateError;
|
|
96
|
+
type errors_EmailTimeoutError = EmailTimeoutError;
|
|
97
|
+
declare const errors_EmailTimeoutError: typeof EmailTimeoutError;
|
|
98
|
+
type errors_EmailUnsupportedError = EmailUnsupportedError;
|
|
99
|
+
declare const errors_EmailUnsupportedError: typeof EmailUnsupportedError;
|
|
100
|
+
type errors_EmailValidationError = EmailValidationError;
|
|
101
|
+
declare const errors_EmailValidationError: typeof EmailValidationError;
|
|
102
|
+
declare const errors_isEmailError: typeof isEmailError;
|
|
103
|
+
declare const errors_isRetriable: typeof isRetriable;
|
|
104
|
+
declare namespace errors {
|
|
105
|
+
export { errors_EmailAuthError as EmailAuthError, errors_EmailConnectionError as EmailConnectionError, errors_EmailEnvelopeRejectedError as EmailEnvelopeRejectedError, errors_EmailError as EmailError, type errors_EmailErrorCode as EmailErrorCode, errors_EmailInvariantError as EmailInvariantError, errors_EmailNotFoundError as EmailNotFoundError, errors_EmailProtocolError as EmailProtocolError, errors_EmailQuotaError as EmailQuotaError, errors_EmailStateError as EmailStateError, errors_EmailTimeoutError as EmailTimeoutError, errors_EmailUnsupportedError as EmailUnsupportedError, errors_EmailValidationError as EmailValidationError, errors_isEmailError as isEmailError, errors_isRetriable as isRetriable };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
type Address = {
|
|
109
|
+
name?: string;
|
|
110
|
+
address: string;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
type AuthConfig = {
|
|
114
|
+
user: string;
|
|
115
|
+
pass: string;
|
|
116
|
+
} | {
|
|
117
|
+
user: string;
|
|
118
|
+
accessToken: string;
|
|
119
|
+
refreshToken?: string;
|
|
120
|
+
refreshFn?: () => Promise<string>;
|
|
121
|
+
} | {
|
|
122
|
+
mechanism: string;
|
|
123
|
+
credentials: Record<string, string>;
|
|
124
|
+
};
|
|
125
|
+
type EmailConfig = {
|
|
126
|
+
imap: {
|
|
127
|
+
host: string;
|
|
128
|
+
port: number;
|
|
129
|
+
tls?: boolean;
|
|
130
|
+
};
|
|
131
|
+
smtp: {
|
|
132
|
+
host: string;
|
|
133
|
+
port: number;
|
|
134
|
+
tls?: boolean;
|
|
135
|
+
};
|
|
136
|
+
auth: AuthConfig;
|
|
137
|
+
identities?: Address[];
|
|
138
|
+
storage?: string;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
type BodyPart = {
|
|
142
|
+
type: string;
|
|
143
|
+
subtype: string;
|
|
144
|
+
params: Record<string, string>;
|
|
145
|
+
id: string | null;
|
|
146
|
+
description: string | null;
|
|
147
|
+
encoding: string;
|
|
148
|
+
size: number;
|
|
149
|
+
lines?: number;
|
|
150
|
+
disposition?: {
|
|
151
|
+
type: string;
|
|
152
|
+
params: Record<string, string>;
|
|
153
|
+
} | null;
|
|
154
|
+
children?: BodyPart[];
|
|
155
|
+
partPath: string;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
type TokenType = 'atom' | 'quoted' | 'literal' | 'number' | 'nil' | 'lparen' | 'rparen' | 'lbracket' | 'rbracket' | 'crlf' | 'plus' | 'star';
|
|
159
|
+
type ImapToken = {
|
|
160
|
+
type: TokenType;
|
|
161
|
+
value: string | number | null | Buffer;
|
|
162
|
+
};
|
|
163
|
+
type ResponseCode = {
|
|
164
|
+
code: string;
|
|
165
|
+
value: string | number | string[] | null;
|
|
166
|
+
};
|
|
167
|
+
type TaggedResponse = {
|
|
168
|
+
kind: 'tagged';
|
|
169
|
+
tag: string;
|
|
170
|
+
status: 'OK' | 'NO' | 'BAD';
|
|
171
|
+
code: ResponseCode | null;
|
|
172
|
+
text: string;
|
|
173
|
+
};
|
|
174
|
+
type UntaggedResponse = {
|
|
175
|
+
kind: 'untagged';
|
|
176
|
+
type: string;
|
|
177
|
+
number: number | null;
|
|
178
|
+
data: unknown;
|
|
179
|
+
code: ResponseCode | null;
|
|
180
|
+
};
|
|
181
|
+
type ContinuationResponse = {
|
|
182
|
+
kind: 'continuation';
|
|
183
|
+
text: string;
|
|
184
|
+
};
|
|
185
|
+
type ImapResponse = TaggedResponse | UntaggedResponse | ContinuationResponse;
|
|
186
|
+
type ParsedEnvelope = {
|
|
187
|
+
date: string | null;
|
|
188
|
+
subject: string | null;
|
|
189
|
+
from: Address[];
|
|
190
|
+
sender: Address[];
|
|
191
|
+
replyTo: Address[];
|
|
192
|
+
to: Address[];
|
|
193
|
+
cc: Address[];
|
|
194
|
+
bcc: Address[];
|
|
195
|
+
inReplyTo: string | null;
|
|
196
|
+
messageId: string | null;
|
|
197
|
+
};
|
|
198
|
+
type FetchResult = {
|
|
199
|
+
uid: number;
|
|
200
|
+
flags: string[];
|
|
201
|
+
internalDate: string | null;
|
|
202
|
+
size: number | null;
|
|
203
|
+
envelope: ParsedEnvelope | null;
|
|
204
|
+
bodyStructure: BodyPart | null;
|
|
205
|
+
modSeq: number | null;
|
|
206
|
+
bodySections: Map<string, Buffer>;
|
|
207
|
+
gmailExtensions?: {
|
|
208
|
+
msgId?: string;
|
|
209
|
+
threadId?: string;
|
|
210
|
+
labels?: string[];
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* A raw IMAP argument that bypasses encodeArg quoting.
|
|
216
|
+
* Use for sequence sets (1:*), parenthesised lists ((FLAGS BODY)),
|
|
217
|
+
* flag lists (\Seen), SEARCH queries, and other pre-formatted IMAP syntax.
|
|
218
|
+
*/
|
|
219
|
+
type RawArg = {
|
|
220
|
+
readonly __raw: string;
|
|
221
|
+
};
|
|
222
|
+
declare function buildCommand(tag: string, name: string, args?: (string | RawArg)[]): string;
|
|
223
|
+
|
|
224
|
+
declare class ImapTokenizer {
|
|
225
|
+
#private;
|
|
226
|
+
feed(chunk: Buffer): void;
|
|
227
|
+
read(): ImapToken | null;
|
|
228
|
+
readAll(): ImapToken[];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
declare class ImapDispatcher {
|
|
232
|
+
#private;
|
|
233
|
+
constructor(socket: Writable, tokenizer: ImapTokenizer, tagGen: () => string);
|
|
234
|
+
/** Call this whenever new data arrives from the socket. */
|
|
235
|
+
receive(chunk: Buffer): void;
|
|
236
|
+
execute(name: string, args?: (string | RawArg)[]): Promise<{
|
|
237
|
+
tagged: TaggedResponse;
|
|
238
|
+
untagged: UntaggedResponse[];
|
|
239
|
+
}>;
|
|
240
|
+
/**
|
|
241
|
+
* Execute a command that ends with a synchronizing literal (`{N}\r\n`).
|
|
242
|
+
*
|
|
243
|
+
* Protocol flow (RFC 3501 §7.5):
|
|
244
|
+
* C: A001 APPEND "Sent" (\Seen) {1234}\r\n
|
|
245
|
+
* S: + go ahead\r\n
|
|
246
|
+
* C: <1234 bytes of message>\r\n
|
|
247
|
+
* S: A001 OK [APPENDUID …] Append completed
|
|
248
|
+
*
|
|
249
|
+
* @param name - Command name (e.g. "APPEND").
|
|
250
|
+
* @param args - Arguments before the literal (folder, flags, datetime, …).
|
|
251
|
+
* @param literal - The raw bytes to upload as the literal.
|
|
252
|
+
*/
|
|
253
|
+
executeWithLiteral(name: string, args: (string | RawArg)[], literal: Buffer): Promise<{
|
|
254
|
+
tagged: TaggedResponse;
|
|
255
|
+
untagged: UntaggedResponse[];
|
|
256
|
+
}>;
|
|
257
|
+
onUnsolicited(handler: (resp: UntaggedResponse) => void): void;
|
|
258
|
+
/** Write raw bytes directly to the socket (used for IDLE DONE). */
|
|
259
|
+
sendRaw(data: string): void;
|
|
260
|
+
destroy(): void;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
declare function authenticate(dispatcher: ImapDispatcher, capabilities: Set<string>, config: AuthConfig): Promise<void>;
|
|
264
|
+
|
|
265
|
+
type SelectedFolder = {
|
|
266
|
+
exists: number;
|
|
267
|
+
recent: number;
|
|
268
|
+
flags: string[];
|
|
269
|
+
permanentFlags: string[];
|
|
270
|
+
uidValidity: number;
|
|
271
|
+
uidNext: number;
|
|
272
|
+
highestModSeq: number | null;
|
|
273
|
+
};
|
|
274
|
+
type NegotiatedExtensions = {
|
|
275
|
+
condstore: boolean;
|
|
276
|
+
qresync: boolean;
|
|
277
|
+
move: boolean;
|
|
278
|
+
uidplus: boolean;
|
|
279
|
+
compress: boolean;
|
|
280
|
+
idle: boolean;
|
|
281
|
+
sort: boolean;
|
|
282
|
+
thread: boolean;
|
|
283
|
+
specialUse: boolean;
|
|
284
|
+
namespace: boolean;
|
|
285
|
+
id: boolean;
|
|
286
|
+
quota: boolean;
|
|
287
|
+
literalPlus: boolean;
|
|
288
|
+
esearch: boolean;
|
|
289
|
+
listStatus: boolean;
|
|
290
|
+
binary: boolean;
|
|
291
|
+
unselect: boolean;
|
|
292
|
+
appendLimit: number | null;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
declare function parseCapabilities(response: string): Set<string>;
|
|
296
|
+
declare function negotiateExtensions(capabilities: Set<string>): NegotiatedExtensions;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Send COMPRESS DEFLATE to the server.
|
|
300
|
+
* Returns true if the server accepted compression.
|
|
301
|
+
*
|
|
302
|
+
* The caller is responsible for calling ImapConnection.wrapCompression()
|
|
303
|
+
* immediately after this returns true — before any further data is sent or
|
|
304
|
+
* received — so the socket I/O is wrapped with zlib inflate/deflate streams.
|
|
305
|
+
*/
|
|
306
|
+
declare function enableCompression(dispatcher: ImapDispatcher): Promise<boolean>;
|
|
307
|
+
|
|
308
|
+
interface ImapConnectionConfig {
|
|
309
|
+
host: string;
|
|
310
|
+
port: number;
|
|
311
|
+
tls?: boolean;
|
|
312
|
+
timeout?: number;
|
|
313
|
+
keepaliveInterval?: number;
|
|
314
|
+
}
|
|
315
|
+
declare class ImapConnection extends EventEmitter {
|
|
316
|
+
#private;
|
|
317
|
+
constructor(config: ImapConnectionConfig);
|
|
318
|
+
get socket(): Duplex;
|
|
319
|
+
get isConnected(): boolean;
|
|
320
|
+
connect(): Promise<void>;
|
|
321
|
+
disconnect(): Promise<void>;
|
|
322
|
+
upgrade(): Promise<void>;
|
|
323
|
+
/**
|
|
324
|
+
* Negotiate COMPRESS=DEFLATE: wrap the socket read/write paths with
|
|
325
|
+
* zlib inflate/deflate streams. Must be called immediately after the
|
|
326
|
+
* server sends the COMPRESS OK response — before the server starts sending
|
|
327
|
+
* compressed bytes.
|
|
328
|
+
*/
|
|
329
|
+
wrapCompression(): void;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
type FolderRole = 'inbox' | 'sent' | 'drafts' | 'trash' | 'junk' | 'archive' | 'all' | 'flagged' | null;
|
|
333
|
+
type Folder = {
|
|
334
|
+
id: number;
|
|
335
|
+
accountId: number;
|
|
336
|
+
path: string;
|
|
337
|
+
delimiter: string;
|
|
338
|
+
role: FolderRole;
|
|
339
|
+
uidValidity: number | null;
|
|
340
|
+
uidNext: number | null;
|
|
341
|
+
highestModSeq: number | null;
|
|
342
|
+
messageCount: number | null;
|
|
343
|
+
unseenCount: number | null;
|
|
344
|
+
lastSyncedAt: string | null;
|
|
345
|
+
};
|
|
346
|
+
type FolderStatus = {
|
|
347
|
+
messages: number;
|
|
348
|
+
unseen: number;
|
|
349
|
+
uidNext: number;
|
|
350
|
+
uidValidity: number;
|
|
351
|
+
highestModSeq: number | null;
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
declare function listFolders$1(dispatcher: ImapDispatcher): Promise<Folder[]>;
|
|
355
|
+
declare function selectFolder(dispatcher: ImapDispatcher, path: string, qresync?: {
|
|
356
|
+
uidValidity: number;
|
|
357
|
+
highestModSeq: number;
|
|
358
|
+
knownUids: string;
|
|
359
|
+
}): Promise<SelectedFolder>;
|
|
360
|
+
declare function examineFolder(dispatcher: ImapDispatcher, path: string): Promise<SelectedFolder>;
|
|
361
|
+
declare function createImapFolder(dispatcher: ImapDispatcher, path: string): Promise<void>;
|
|
362
|
+
declare function deleteImapFolder(dispatcher: ImapDispatcher, path: string): Promise<void>;
|
|
363
|
+
declare function renameImapFolder(dispatcher: ImapDispatcher, oldPath: string, newPath: string): Promise<void>;
|
|
364
|
+
declare function subscribeImapFolder(dispatcher: ImapDispatcher, path: string): Promise<void>;
|
|
365
|
+
declare function unsubscribeImapFolder(dispatcher: ImapDispatcher, path: string): Promise<void>;
|
|
366
|
+
declare function statusFolder(dispatcher: ImapDispatcher, path: string): Promise<FolderStatus>;
|
|
367
|
+
|
|
368
|
+
declare function detectFolderRole(flags: string[], name: string): FolderRole;
|
|
369
|
+
|
|
370
|
+
type IdleEvent = {
|
|
371
|
+
type: 'exists';
|
|
372
|
+
count: number;
|
|
373
|
+
} | {
|
|
374
|
+
type: 'expunge';
|
|
375
|
+
seqno: number;
|
|
376
|
+
} | {
|
|
377
|
+
type: 'fetch';
|
|
378
|
+
seqno: number;
|
|
379
|
+
flags: string[];
|
|
380
|
+
};
|
|
381
|
+
declare function idle(dispatcher: ImapDispatcher, options?: {
|
|
382
|
+
signal?: AbortSignal;
|
|
383
|
+
timeout?: number;
|
|
384
|
+
}): AsyncGenerator<IdleEvent>;
|
|
385
|
+
|
|
386
|
+
declare function fetchMessages(dispatcher: ImapDispatcher, range: string, items: string[]): Promise<FetchResult[]>;
|
|
387
|
+
declare function searchMessages$1(dispatcher: ImapDispatcher, query: string): Promise<number[]>;
|
|
388
|
+
declare function storeFlags(dispatcher: ImapDispatcher, uids: number[], action: '+FLAGS.SILENT' | '-FLAGS.SILENT' | 'FLAGS.SILENT', flags: string[]): Promise<void>;
|
|
389
|
+
declare function copyMessages(dispatcher: ImapDispatcher, uids: number[], dest: string): Promise<{
|
|
390
|
+
uidMapping?: Record<number, number>;
|
|
391
|
+
}>;
|
|
392
|
+
declare function moveMessages(dispatcher: ImapDispatcher, uids: number[], dest: string, hasMove: boolean): Promise<void>;
|
|
393
|
+
declare function expungeAll(dispatcher: ImapDispatcher): Promise<void>;
|
|
394
|
+
declare function uidExpunge(dispatcher: ImapDispatcher, uids: number[]): Promise<void>;
|
|
395
|
+
declare function appendMessage(dispatcher: ImapDispatcher, folder: string, message: Buffer, flags?: string[], internalDate?: string): Promise<{
|
|
396
|
+
uid?: number;
|
|
397
|
+
}>;
|
|
398
|
+
|
|
399
|
+
declare function parseResponse(tokens: ImapToken[]): ImapResponse;
|
|
400
|
+
|
|
401
|
+
type SearchQuery = {
|
|
402
|
+
all?: boolean;
|
|
403
|
+
unseen?: boolean;
|
|
404
|
+
seen?: boolean;
|
|
405
|
+
flagged?: boolean;
|
|
406
|
+
answered?: boolean;
|
|
407
|
+
deleted?: boolean;
|
|
408
|
+
draft?: boolean;
|
|
409
|
+
since?: Date;
|
|
410
|
+
before?: Date;
|
|
411
|
+
on?: Date;
|
|
412
|
+
from?: string;
|
|
413
|
+
to?: string;
|
|
414
|
+
cc?: string;
|
|
415
|
+
subject?: string;
|
|
416
|
+
body?: string;
|
|
417
|
+
text?: string;
|
|
418
|
+
header?: {
|
|
419
|
+
name: string;
|
|
420
|
+
value: string;
|
|
421
|
+
};
|
|
422
|
+
larger?: number;
|
|
423
|
+
smaller?: number;
|
|
424
|
+
uid?: string;
|
|
425
|
+
modseq?: number;
|
|
426
|
+
gmailRaw?: string;
|
|
427
|
+
or?: [SearchQuery, SearchQuery];
|
|
428
|
+
not?: SearchQuery;
|
|
429
|
+
};
|
|
430
|
+
type LocalSearchOptions = {
|
|
431
|
+
folder?: string;
|
|
432
|
+
since?: Date;
|
|
433
|
+
before?: Date;
|
|
434
|
+
hasAttachments?: boolean;
|
|
435
|
+
unreadOnly?: boolean;
|
|
436
|
+
limit?: number;
|
|
437
|
+
};
|
|
438
|
+
type MessageListOptions = {
|
|
439
|
+
limit?: number;
|
|
440
|
+
offset?: number;
|
|
441
|
+
sort?: 'date' | 'from' | 'subject' | 'size';
|
|
442
|
+
order?: 'asc' | 'desc';
|
|
443
|
+
};
|
|
444
|
+
type ThreadListOptions = {
|
|
445
|
+
limit?: number;
|
|
446
|
+
offset?: number;
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
declare function compileSearchQuery(query: SearchQuery, capabilities?: Set<string>): string;
|
|
450
|
+
|
|
451
|
+
declare class ImapSession {
|
|
452
|
+
#private;
|
|
453
|
+
constructor(config: EmailConfig);
|
|
454
|
+
get capabilities(): Set<string>;
|
|
455
|
+
get extensions(): NegotiatedExtensions;
|
|
456
|
+
get selectedFolder(): string | null;
|
|
457
|
+
get dispatcher(): ImapDispatcher;
|
|
458
|
+
connect(): Promise<void>;
|
|
459
|
+
disconnect(): Promise<void>;
|
|
460
|
+
listFolders(): Promise<Folder[]>;
|
|
461
|
+
selectFolder(path: string): Promise<SelectedFolder>;
|
|
462
|
+
examineFolder(path: string): Promise<SelectedFolder>;
|
|
463
|
+
createFolder(path: string): Promise<void>;
|
|
464
|
+
deleteFolder(path: string): Promise<void>;
|
|
465
|
+
renameFolder(oldPath: string, newPath: string): Promise<void>;
|
|
466
|
+
subscribeFolder(path: string): Promise<void>;
|
|
467
|
+
unsubscribeFolder(path: string): Promise<void>;
|
|
468
|
+
statusFolder(path: string): Promise<FolderStatus>;
|
|
469
|
+
fetchMessages(range: string, items: string[]): Promise<FetchResult[]>;
|
|
470
|
+
searchMessages(query: string): Promise<number[]>;
|
|
471
|
+
storeFlags(uids: number[], action: '+FLAGS.SILENT' | '-FLAGS.SILENT' | 'FLAGS.SILENT', flags: string[]): Promise<void>;
|
|
472
|
+
copyMessages(uids: number[], dest: string): Promise<{
|
|
473
|
+
uidMapping?: Record<number, number>;
|
|
474
|
+
}>;
|
|
475
|
+
moveMessages(uids: number[], dest: string): Promise<void>;
|
|
476
|
+
expunge(): Promise<void>;
|
|
477
|
+
uidExpunge(uids: number[]): Promise<void>;
|
|
478
|
+
appendMessage(folder: string, message: Buffer, flags?: string[], internalDate?: string): Promise<{
|
|
479
|
+
uid?: number;
|
|
480
|
+
}>;
|
|
481
|
+
idle(options?: {
|
|
482
|
+
signal?: AbortSignal;
|
|
483
|
+
}): AsyncGenerator<IdleEvent>;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
declare function createTagGenerator(prefix?: string): () => string;
|
|
487
|
+
|
|
488
|
+
type index$8_IdleEvent = IdleEvent;
|
|
489
|
+
type index$8_ImapConnection = ImapConnection;
|
|
490
|
+
declare const index$8_ImapConnection: typeof ImapConnection;
|
|
491
|
+
type index$8_ImapDispatcher = ImapDispatcher;
|
|
492
|
+
declare const index$8_ImapDispatcher: typeof ImapDispatcher;
|
|
493
|
+
type index$8_ImapSession = ImapSession;
|
|
494
|
+
declare const index$8_ImapSession: typeof ImapSession;
|
|
495
|
+
type index$8_ImapTokenizer = ImapTokenizer;
|
|
496
|
+
declare const index$8_ImapTokenizer: typeof ImapTokenizer;
|
|
497
|
+
declare const index$8_appendMessage: typeof appendMessage;
|
|
498
|
+
declare const index$8_authenticate: typeof authenticate;
|
|
499
|
+
declare const index$8_buildCommand: typeof buildCommand;
|
|
500
|
+
declare const index$8_compileSearchQuery: typeof compileSearchQuery;
|
|
501
|
+
declare const index$8_copyMessages: typeof copyMessages;
|
|
502
|
+
declare const index$8_createImapFolder: typeof createImapFolder;
|
|
503
|
+
declare const index$8_createTagGenerator: typeof createTagGenerator;
|
|
504
|
+
declare const index$8_deleteImapFolder: typeof deleteImapFolder;
|
|
505
|
+
declare const index$8_detectFolderRole: typeof detectFolderRole;
|
|
506
|
+
declare const index$8_enableCompression: typeof enableCompression;
|
|
507
|
+
declare const index$8_examineFolder: typeof examineFolder;
|
|
508
|
+
declare const index$8_expungeAll: typeof expungeAll;
|
|
509
|
+
declare const index$8_fetchMessages: typeof fetchMessages;
|
|
510
|
+
declare const index$8_idle: typeof idle;
|
|
511
|
+
declare const index$8_moveMessages: typeof moveMessages;
|
|
512
|
+
declare const index$8_negotiateExtensions: typeof negotiateExtensions;
|
|
513
|
+
declare const index$8_parseCapabilities: typeof parseCapabilities;
|
|
514
|
+
declare const index$8_parseResponse: typeof parseResponse;
|
|
515
|
+
declare const index$8_renameImapFolder: typeof renameImapFolder;
|
|
516
|
+
declare const index$8_selectFolder: typeof selectFolder;
|
|
517
|
+
declare const index$8_statusFolder: typeof statusFolder;
|
|
518
|
+
declare const index$8_storeFlags: typeof storeFlags;
|
|
519
|
+
declare const index$8_subscribeImapFolder: typeof subscribeImapFolder;
|
|
520
|
+
declare const index$8_uidExpunge: typeof uidExpunge;
|
|
521
|
+
declare const index$8_unsubscribeImapFolder: typeof unsubscribeImapFolder;
|
|
522
|
+
declare namespace index$8 {
|
|
523
|
+
export { type index$8_IdleEvent as IdleEvent, index$8_ImapConnection as ImapConnection, index$8_ImapDispatcher as ImapDispatcher, index$8_ImapSession as ImapSession, index$8_ImapTokenizer as ImapTokenizer, index$8_appendMessage as appendMessage, index$8_authenticate as authenticate, index$8_buildCommand as buildCommand, index$8_compileSearchQuery as compileSearchQuery, index$8_copyMessages as copyMessages, index$8_createImapFolder as createImapFolder, index$8_createTagGenerator as createTagGenerator, index$8_deleteImapFolder as deleteImapFolder, index$8_detectFolderRole as detectFolderRole, index$8_enableCompression as enableCompression, index$8_examineFolder as examineFolder, index$8_expungeAll as expungeAll, index$8_fetchMessages as fetchMessages, index$8_idle as idle, listFolders$1 as listFolders, index$8_moveMessages as moveMessages, index$8_negotiateExtensions as negotiateExtensions, index$8_parseCapabilities as parseCapabilities, index$8_parseResponse as parseResponse, index$8_renameImapFolder as renameImapFolder, searchMessages$1 as searchMessages, index$8_selectFolder as selectFolder, index$8_statusFolder as statusFolder, index$8_storeFlags as storeFlags, index$8_subscribeImapFolder as subscribeImapFolder, index$8_uidExpunge as uidExpunge, index$8_unsubscribeImapFolder as unsubscribeImapFolder };
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
type AttachmentMeta = {
|
|
527
|
+
id: number;
|
|
528
|
+
messageId: number;
|
|
529
|
+
filename: string | null;
|
|
530
|
+
mimeType: string | null;
|
|
531
|
+
size: number | null;
|
|
532
|
+
contentId: string | null;
|
|
533
|
+
partPath: string;
|
|
534
|
+
inline: boolean;
|
|
535
|
+
};
|
|
536
|
+
type Attachment = AttachmentMeta & {
|
|
537
|
+
data: Buffer;
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
type ComposeAttachment = {
|
|
541
|
+
filename: string;
|
|
542
|
+
content: Buffer;
|
|
543
|
+
mimeType?: string;
|
|
544
|
+
inline?: boolean;
|
|
545
|
+
contentId?: string;
|
|
546
|
+
};
|
|
547
|
+
type ComposeInput = {
|
|
548
|
+
from?: Address;
|
|
549
|
+
to: Address[];
|
|
550
|
+
cc?: Address[];
|
|
551
|
+
bcc?: Address[];
|
|
552
|
+
sender?: Address;
|
|
553
|
+
envelopeFrom?: Address;
|
|
554
|
+
replyTo?: Address;
|
|
555
|
+
subject: string;
|
|
556
|
+
text?: string;
|
|
557
|
+
html?: string;
|
|
558
|
+
attachments?: ComposeAttachment[];
|
|
559
|
+
inReplyTo?: string;
|
|
560
|
+
references?: string[];
|
|
561
|
+
headers?: Record<string, string>;
|
|
562
|
+
};
|
|
563
|
+
type ReplyInput = {
|
|
564
|
+
to?: Address[];
|
|
565
|
+
cc?: Address[];
|
|
566
|
+
bcc?: Address[];
|
|
567
|
+
text?: string;
|
|
568
|
+
html?: string;
|
|
569
|
+
attachments?: ComposeAttachment[];
|
|
570
|
+
replyAll?: boolean;
|
|
571
|
+
};
|
|
572
|
+
type ForwardInput = {
|
|
573
|
+
to: Address[];
|
|
574
|
+
cc?: Address[];
|
|
575
|
+
bcc?: Address[];
|
|
576
|
+
text?: string;
|
|
577
|
+
html?: string;
|
|
578
|
+
attachments?: ComposeAttachment[];
|
|
579
|
+
mode?: 'inline' | 'attachment';
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
type Message = {
|
|
583
|
+
id: number;
|
|
584
|
+
folderId: number;
|
|
585
|
+
uid: number;
|
|
586
|
+
messageId: string | null;
|
|
587
|
+
inReplyTo: string | null;
|
|
588
|
+
references: string[];
|
|
589
|
+
threadId: string | null;
|
|
590
|
+
from: Address | null;
|
|
591
|
+
to: Address[];
|
|
592
|
+
cc: Address[];
|
|
593
|
+
bcc: Address[];
|
|
594
|
+
replyTo: Address | null;
|
|
595
|
+
subject: string | null;
|
|
596
|
+
date: string | null;
|
|
597
|
+
receivedAt: string;
|
|
598
|
+
envelopeFrom: Address | null;
|
|
599
|
+
envelopeTo: Address[];
|
|
600
|
+
flags: string[];
|
|
601
|
+
labels: string[];
|
|
602
|
+
size: number | null;
|
|
603
|
+
bodyStructure: BodyPart | null;
|
|
604
|
+
hasAttachments: boolean;
|
|
605
|
+
modSeq: number | null;
|
|
606
|
+
};
|
|
607
|
+
type MessageBody = {
|
|
608
|
+
textPlain: string | null;
|
|
609
|
+
textHtml: string | null;
|
|
610
|
+
raw?: Buffer;
|
|
611
|
+
};
|
|
612
|
+
type MessageDetail = Message & {
|
|
613
|
+
textPlain: string | null;
|
|
614
|
+
textHtml: string | null;
|
|
615
|
+
attachments: AttachmentMeta[];
|
|
616
|
+
};
|
|
617
|
+
type InsertMessageInput = Omit<Message, 'id'>;
|
|
618
|
+
|
|
619
|
+
type AccountStats = {
|
|
620
|
+
folders: {
|
|
621
|
+
path: string;
|
|
622
|
+
role: string | null;
|
|
623
|
+
total: number;
|
|
624
|
+
unread: number;
|
|
625
|
+
}[];
|
|
626
|
+
totalMessages: number;
|
|
627
|
+
totalUnread: number;
|
|
628
|
+
lastSyncedAt: string | null;
|
|
629
|
+
storageUsed: number;
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
type SyncOptions = {
|
|
633
|
+
folders?: string[];
|
|
634
|
+
fullSync?: boolean;
|
|
635
|
+
bodies?: 'none' | 'missing' | 'all';
|
|
636
|
+
};
|
|
637
|
+
type SyncFolderResult = {
|
|
638
|
+
path: string;
|
|
639
|
+
newMessages: number;
|
|
640
|
+
updatedFlags: number;
|
|
641
|
+
expunged: number;
|
|
642
|
+
duration: number;
|
|
643
|
+
};
|
|
644
|
+
type SyncResult = {
|
|
645
|
+
folders: SyncFolderResult[];
|
|
646
|
+
totalNew: number;
|
|
647
|
+
totalExpunged: number;
|
|
648
|
+
};
|
|
649
|
+
type WatchOptions = {
|
|
650
|
+
folders?: string[];
|
|
651
|
+
signal?: AbortSignal;
|
|
652
|
+
};
|
|
653
|
+
type WatchEvent = {
|
|
654
|
+
type: 'new';
|
|
655
|
+
folder: string;
|
|
656
|
+
messages: Message[];
|
|
657
|
+
} | {
|
|
658
|
+
type: 'flags';
|
|
659
|
+
folder: string;
|
|
660
|
+
uid: number;
|
|
661
|
+
flags: string[];
|
|
662
|
+
} | {
|
|
663
|
+
type: 'expunge';
|
|
664
|
+
folder: string;
|
|
665
|
+
uid: number;
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
type Thread = {
|
|
669
|
+
threadId: string;
|
|
670
|
+
subject: string | null;
|
|
671
|
+
participants: Address[];
|
|
672
|
+
messageCount: number;
|
|
673
|
+
unreadCount: number;
|
|
674
|
+
lastDate: string;
|
|
675
|
+
messages: ThreadMessage[];
|
|
676
|
+
};
|
|
677
|
+
type ThreadMessage = Message & {
|
|
678
|
+
depth: number;
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
type EmailReadSurface = {
|
|
682
|
+
folders(): Folder[];
|
|
683
|
+
folderStatus(path: string): FolderStatus;
|
|
684
|
+
messages(folder: string, options?: MessageListOptions): Message[];
|
|
685
|
+
threads(folder: string, options?: ThreadListOptions): Thread[];
|
|
686
|
+
getThread(threadId: string): Thread;
|
|
687
|
+
getMessage(folder: string, uid: number): Promise<MessageDetail>;
|
|
688
|
+
listAttachments(folder: string, uid: number): AttachmentMeta[];
|
|
689
|
+
getAttachment(folder: string, uid: number, partPath: string): Promise<Attachment>;
|
|
690
|
+
search(query: string, options?: LocalSearchOptions): Message[];
|
|
691
|
+
stats(): AccountStats;
|
|
692
|
+
getDatabase(): DatabaseSync;
|
|
693
|
+
};
|
|
694
|
+
type EmailWriteSurface = {
|
|
695
|
+
markRead(folder: string, uids: number[]): Promise<void>;
|
|
696
|
+
markUnread(folder: string, uids: number[]): Promise<void>;
|
|
697
|
+
star(folder: string, uids: number[]): Promise<void>;
|
|
698
|
+
unstar(folder: string, uids: number[]): Promise<void>;
|
|
699
|
+
markAnswered(folder: string, uids: number[]): Promise<void>;
|
|
700
|
+
copyTo(folder: string, uids: number[], destination: string): Promise<void>;
|
|
701
|
+
moveTo(folder: string, uids: number[], destination: string): Promise<void>;
|
|
702
|
+
archive(folder: string, uids: number[]): Promise<void>;
|
|
703
|
+
trash(folder: string, uids: number[]): Promise<void>;
|
|
704
|
+
moveToJunk(folder: string, uids: number[]): Promise<void>;
|
|
705
|
+
markNotJunk(folder: string, uids: number[], destination?: string): Promise<void>;
|
|
706
|
+
delete(folder: string, uids: number[]): Promise<void>;
|
|
707
|
+
addLabels(folder: string, uids: number[], labels: string[]): Promise<void>;
|
|
708
|
+
removeLabels(folder: string, uids: number[], labels: string[]): Promise<void>;
|
|
709
|
+
setLabels(folder: string, uids: number[], labels: string[]): Promise<void>;
|
|
710
|
+
send(input: ComposeInput): Promise<{
|
|
711
|
+
messageId: string;
|
|
712
|
+
}>;
|
|
713
|
+
reply(folder: string, uid: number, input: ReplyInput): Promise<{
|
|
714
|
+
messageId: string;
|
|
715
|
+
}>;
|
|
716
|
+
forward(folder: string, uid: number, input: ForwardInput): Promise<{
|
|
717
|
+
messageId: string;
|
|
718
|
+
}>;
|
|
719
|
+
saveDraft(input: ComposeInput): Promise<{
|
|
720
|
+
uid: number;
|
|
721
|
+
}>;
|
|
722
|
+
updateDraft(uid: number, input: ComposeInput): Promise<{
|
|
723
|
+
uid: number;
|
|
724
|
+
}>;
|
|
725
|
+
sendDraft(uid: number): Promise<{
|
|
726
|
+
messageId: string;
|
|
727
|
+
}>;
|
|
728
|
+
createFolder(path: string): Promise<void>;
|
|
729
|
+
renameFolder(oldPath: string, newPath: string): Promise<void>;
|
|
730
|
+
deleteFolder(path: string): Promise<void>;
|
|
731
|
+
subscribeFolder(path: string): Promise<void>;
|
|
732
|
+
unsubscribeFolder(path: string): Promise<void>;
|
|
733
|
+
exportEml(folder: string, uid: number): Promise<Buffer>;
|
|
734
|
+
importEml(folder: string, eml: Buffer, flags?: string[]): Promise<{
|
|
735
|
+
uid?: number;
|
|
736
|
+
}>;
|
|
737
|
+
};
|
|
738
|
+
type EmailNetworkSurface = {
|
|
739
|
+
connect(): Promise<void>;
|
|
740
|
+
disconnect(): Promise<void>;
|
|
741
|
+
reconnect(): Promise<void>;
|
|
742
|
+
sync(options?: SyncOptions): Promise<SyncResult>;
|
|
743
|
+
watch(options?: WatchOptions): AsyncIterable<WatchEvent>;
|
|
744
|
+
refreshFolders(): Promise<Folder[]>;
|
|
745
|
+
searchRemote(folder: string, query: SearchQuery): Promise<number[]>;
|
|
746
|
+
fetchBody(folder: string, uid: number): Promise<MessageBody>;
|
|
747
|
+
fetchAttachment(folder: string, uid: number, partPath: string): Promise<Attachment>;
|
|
748
|
+
};
|
|
749
|
+
type EmailRuntimeSurface = {
|
|
750
|
+
init(config: EmailConfig): Promise<void> | void;
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
declare class Mailbox {
|
|
754
|
+
#private;
|
|
755
|
+
constructor(config: EmailConfig);
|
|
756
|
+
connect(): Promise<void>;
|
|
757
|
+
disconnect(): Promise<void>;
|
|
758
|
+
isConnected(): boolean;
|
|
759
|
+
get read(): EmailReadSurface;
|
|
760
|
+
get write(): EmailWriteSurface;
|
|
761
|
+
get network(): EmailNetworkSurface;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
declare function composeForward(original: Message & MessageBody, input: ForwardInput): ComposeInput;
|
|
765
|
+
|
|
766
|
+
declare function composeMessage(input: ComposeInput): Buffer;
|
|
767
|
+
|
|
768
|
+
declare function composeReply(original: Message & MessageBody, input: ReplyInput, identities: Address[]): ComposeInput;
|
|
769
|
+
|
|
770
|
+
/** Parse a single RFC 5322 address or group. */
|
|
771
|
+
declare function decodeAddress(raw: string): Address | null;
|
|
772
|
+
declare function decodeAddressList(raw: string): Address[];
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Decode a BODYSTRUCTURE from grouped item data.
|
|
776
|
+
* The input is the data array returned by collectItems for the BODYSTRUCTURE value —
|
|
777
|
+
* parens have been converted to nested arrays, NIL to null, numbers to numbers.
|
|
778
|
+
*/
|
|
779
|
+
declare function decodeBodyStructure(data: unknown[], maxDepth?: number): BodyPart;
|
|
780
|
+
|
|
781
|
+
/** Parse Content-Disposition header. */
|
|
782
|
+
declare function decodeContentDisposition(raw: string): {
|
|
783
|
+
type: string;
|
|
784
|
+
params: Record<string, string>;
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
/** Parse Content-Type / MIME type line. */
|
|
788
|
+
declare function decodeContentType(raw: string): {
|
|
789
|
+
type: string;
|
|
790
|
+
subtype: string;
|
|
791
|
+
params: Record<string, string>;
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
/** Parse common RFC 5322 Date header values to ISO 8601 (UTC). */
|
|
795
|
+
declare function decodeDate(raw: string): string;
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* RFC 2047 encoded-word decoding.
|
|
799
|
+
*/
|
|
800
|
+
declare function decodeEncodedWords(raw: string): string;
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Decode an IMAP ENVELOPE response into a ParsedEnvelope.
|
|
804
|
+
*
|
|
805
|
+
* ENVELOPE data layout (RFC 3501 §7.4.2):
|
|
806
|
+
* [date, subject, from, sender, reply-to, to, cc, bcc, in-reply-to, message-id]
|
|
807
|
+
*/
|
|
808
|
+
declare function decodeEnvelope(data: unknown[]): ParsedEnvelope;
|
|
809
|
+
|
|
810
|
+
declare function decodeTransferEncoding(data: Buffer | string, encoding: string): Buffer;
|
|
811
|
+
|
|
812
|
+
declare function encodeAddress(addr: Address): string;
|
|
813
|
+
declare function encodeAddressList(addrs: Address[] | undefined | null): string;
|
|
814
|
+
|
|
815
|
+
declare function encodeAttachment(att: ComposeAttachment): string;
|
|
816
|
+
|
|
817
|
+
declare function encodeDate(date?: Date): string;
|
|
818
|
+
|
|
819
|
+
/** Encode header line with RFC 2047 B-encoding for non-ASCII. */
|
|
820
|
+
declare function encodeHeader(name: string, value: string): string;
|
|
821
|
+
|
|
822
|
+
type MimePart = {
|
|
823
|
+
headers: Map<string, string[]>;
|
|
824
|
+
body: Buffer;
|
|
825
|
+
children?: MimePart[];
|
|
826
|
+
};
|
|
827
|
+
declare function parseMultipart(body: Buffer, boundary: string, depth?: number, maxDepth?: number): MimePart[];
|
|
828
|
+
|
|
829
|
+
declare function extractAttachments(parts: MimePart[], basePath?: string): AttachmentMeta[];
|
|
830
|
+
|
|
831
|
+
declare function extractTextParts(parts: MimePart[]): {
|
|
832
|
+
textPlain: string | null;
|
|
833
|
+
textHtml: string | null;
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
/** Split header block into name -> values (lowercase names). */
|
|
837
|
+
declare function parseHeaders(raw: string): Map<string, string[]>;
|
|
838
|
+
|
|
839
|
+
type StructuredHeaders = {
|
|
840
|
+
from: Address | null;
|
|
841
|
+
to: Address[];
|
|
842
|
+
cc: Address[];
|
|
843
|
+
bcc: Address[];
|
|
844
|
+
replyTo: Address | null;
|
|
845
|
+
subject: string | null;
|
|
846
|
+
date: string | null;
|
|
847
|
+
messageId: string | null;
|
|
848
|
+
inReplyTo: string | null;
|
|
849
|
+
references: string[];
|
|
850
|
+
contentType: ReturnType<typeof decodeContentType> | null;
|
|
851
|
+
contentDisposition: ReturnType<typeof decodeContentDisposition> | null;
|
|
852
|
+
contentTransferEncoding: string | null;
|
|
853
|
+
};
|
|
854
|
+
declare function parseStructuredHeaders(headers: Map<string, string[]>): StructuredHeaders;
|
|
855
|
+
|
|
856
|
+
type ParsedMessage = {
|
|
857
|
+
headers: StructuredHeaders;
|
|
858
|
+
rawHeaders: Map<string, string[]>;
|
|
859
|
+
textPlain: string | null;
|
|
860
|
+
textHtml: string | null;
|
|
861
|
+
attachments: AttachmentMeta[];
|
|
862
|
+
bodyStructure: BodyPart;
|
|
863
|
+
};
|
|
864
|
+
declare function parseMessage(raw: Buffer): ParsedMessage;
|
|
865
|
+
|
|
866
|
+
/** RFC 5322 header unfolding: CRLF + WSP continues previous line. */
|
|
867
|
+
declare function unfoldHeaders(raw: string): string;
|
|
868
|
+
|
|
869
|
+
type index$7_MimePart = MimePart;
|
|
870
|
+
type index$7_ParsedMessage = ParsedMessage;
|
|
871
|
+
type index$7_StructuredHeaders = StructuredHeaders;
|
|
872
|
+
declare const index$7_composeForward: typeof composeForward;
|
|
873
|
+
declare const index$7_composeMessage: typeof composeMessage;
|
|
874
|
+
declare const index$7_composeReply: typeof composeReply;
|
|
875
|
+
declare const index$7_decodeAddress: typeof decodeAddress;
|
|
876
|
+
declare const index$7_decodeAddressList: typeof decodeAddressList;
|
|
877
|
+
declare const index$7_decodeBodyStructure: typeof decodeBodyStructure;
|
|
878
|
+
declare const index$7_decodeContentDisposition: typeof decodeContentDisposition;
|
|
879
|
+
declare const index$7_decodeContentType: typeof decodeContentType;
|
|
880
|
+
declare const index$7_decodeDate: typeof decodeDate;
|
|
881
|
+
declare const index$7_decodeEncodedWords: typeof decodeEncodedWords;
|
|
882
|
+
declare const index$7_decodeEnvelope: typeof decodeEnvelope;
|
|
883
|
+
declare const index$7_decodeTransferEncoding: typeof decodeTransferEncoding;
|
|
884
|
+
declare const index$7_encodeAddress: typeof encodeAddress;
|
|
885
|
+
declare const index$7_encodeAddressList: typeof encodeAddressList;
|
|
886
|
+
declare const index$7_encodeAttachment: typeof encodeAttachment;
|
|
887
|
+
declare const index$7_encodeDate: typeof encodeDate;
|
|
888
|
+
declare const index$7_encodeHeader: typeof encodeHeader;
|
|
889
|
+
declare const index$7_extractAttachments: typeof extractAttachments;
|
|
890
|
+
declare const index$7_extractTextParts: typeof extractTextParts;
|
|
891
|
+
declare const index$7_parseHeaders: typeof parseHeaders;
|
|
892
|
+
declare const index$7_parseMessage: typeof parseMessage;
|
|
893
|
+
declare const index$7_parseMultipart: typeof parseMultipart;
|
|
894
|
+
declare const index$7_parseStructuredHeaders: typeof parseStructuredHeaders;
|
|
895
|
+
declare const index$7_unfoldHeaders: typeof unfoldHeaders;
|
|
896
|
+
declare namespace index$7 {
|
|
897
|
+
export { type index$7_MimePart as MimePart, type index$7_ParsedMessage as ParsedMessage, type index$7_StructuredHeaders as StructuredHeaders, index$7_composeForward as composeForward, index$7_composeMessage as composeMessage, index$7_composeReply as composeReply, index$7_decodeAddress as decodeAddress, index$7_decodeAddressList as decodeAddressList, index$7_decodeBodyStructure as decodeBodyStructure, index$7_decodeContentDisposition as decodeContentDisposition, index$7_decodeContentType as decodeContentType, index$7_decodeDate as decodeDate, index$7_decodeEncodedWords as decodeEncodedWords, index$7_decodeEnvelope as decodeEnvelope, index$7_decodeTransferEncoding as decodeTransferEncoding, index$7_encodeAddress as encodeAddress, index$7_encodeAddressList as encodeAddressList, index$7_encodeAttachment as encodeAttachment, index$7_encodeDate as encodeDate, index$7_encodeHeader as encodeHeader, index$7_extractAttachments as extractAttachments, index$7_extractTextParts as extractTextParts, index$7_parseHeaders as parseHeaders, index$7_parseMessage as parseMessage, index$7_parseMultipart as parseMultipart, index$7_parseStructuredHeaders as parseStructuredHeaders, index$7_unfoldHeaders as unfoldHeaders };
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
type CreateNetworkSurfaceOptions = {
|
|
901
|
+
accountId: number;
|
|
902
|
+
session?: ImapSession | null;
|
|
903
|
+
};
|
|
904
|
+
declare function createNetworkSurface(db: EmailDb, options: CreateNetworkSurfaceOptions): EmailNetworkSurface;
|
|
905
|
+
|
|
906
|
+
type network_CreateNetworkSurfaceOptions = CreateNetworkSurfaceOptions;
|
|
907
|
+
declare const network_createNetworkSurface: typeof createNetworkSurface;
|
|
908
|
+
declare namespace network {
|
|
909
|
+
export { type network_CreateNetworkSurfaceOptions as CreateNetworkSurfaceOptions, network_createNetworkSurface as createNetworkSurface };
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
type CreateReadSurfaceOptions = {
|
|
913
|
+
/** When set, enables on-demand body / attachment fetch from IMAP. */
|
|
914
|
+
session?: unknown;
|
|
915
|
+
};
|
|
916
|
+
declare function createReadSurface(db: EmailDb, accountId: number, _options?: CreateReadSurfaceOptions): EmailReadSurface;
|
|
917
|
+
|
|
918
|
+
type read_CreateReadSurfaceOptions = CreateReadSurfaceOptions;
|
|
919
|
+
declare const read_createReadSurface: typeof createReadSurface;
|
|
920
|
+
declare namespace read {
|
|
921
|
+
export { type read_CreateReadSurfaceOptions as CreateReadSurfaceOptions, read_createReadSurface as createReadSurface };
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
declare function init(config: EmailConfig): {
|
|
925
|
+
db: EmailDb;
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
declare const runtime_init: typeof init;
|
|
929
|
+
declare namespace runtime {
|
|
930
|
+
export { runtime_init as init };
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
declare function createFts(db: EmailDb): void;
|
|
934
|
+
|
|
935
|
+
declare function createIndexes(db: EmailDb): void;
|
|
936
|
+
|
|
937
|
+
declare function createTables(db: EmailDb): void;
|
|
938
|
+
|
|
939
|
+
declare function initSchema(db: EmailDb): void;
|
|
940
|
+
|
|
941
|
+
declare const index$6_createFts: typeof createFts;
|
|
942
|
+
declare const index$6_createIndexes: typeof createIndexes;
|
|
943
|
+
declare const index$6_createTables: typeof createTables;
|
|
944
|
+
declare const index$6_initSchema: typeof initSchema;
|
|
945
|
+
declare namespace index$6 {
|
|
946
|
+
export { index$6_createFts as createFts, index$6_createIndexes as createIndexes, index$6_createTables as createTables, index$6_initSchema as initSchema };
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
declare const attachmentWorkflowSkill: {
|
|
950
|
+
name: string;
|
|
951
|
+
description: string;
|
|
952
|
+
content: string;
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
declare const composeAndSendSkill: {
|
|
956
|
+
name: string;
|
|
957
|
+
description: string;
|
|
958
|
+
content: string;
|
|
959
|
+
};
|
|
960
|
+
|
|
961
|
+
declare const connectAndSyncSkill: {
|
|
962
|
+
name: string;
|
|
963
|
+
description: string;
|
|
964
|
+
content: string;
|
|
965
|
+
};
|
|
966
|
+
|
|
967
|
+
declare const emailSkills: {
|
|
968
|
+
name: string;
|
|
969
|
+
description: string;
|
|
970
|
+
content: string;
|
|
971
|
+
}[];
|
|
972
|
+
declare function getEmailSkillByName(name: string): (typeof emailSkills)[number] | null;
|
|
973
|
+
|
|
974
|
+
declare const organizeBulkSkill: {
|
|
975
|
+
name: string;
|
|
976
|
+
description: string;
|
|
977
|
+
content: string;
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
declare const readAndReplySkill: {
|
|
981
|
+
name: string;
|
|
982
|
+
description: string;
|
|
983
|
+
content: string;
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
declare const recoverFromDisruptionSkill: {
|
|
987
|
+
name: string;
|
|
988
|
+
description: string;
|
|
989
|
+
content: string;
|
|
990
|
+
};
|
|
991
|
+
|
|
992
|
+
declare const searchAndActSkill: {
|
|
993
|
+
name: string;
|
|
994
|
+
description: string;
|
|
995
|
+
content: string;
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
interface EmailSkill {
|
|
999
|
+
name: string;
|
|
1000
|
+
description: string;
|
|
1001
|
+
content: string;
|
|
1002
|
+
}
|
|
1003
|
+
type EmailSkillRegistry = readonly EmailSkill[];
|
|
1004
|
+
declare function defineEmailSkill<TSkill extends EmailSkill>(skill: TSkill): TSkill;
|
|
1005
|
+
|
|
1006
|
+
declare const triageInboxSkill: {
|
|
1007
|
+
name: string;
|
|
1008
|
+
description: string;
|
|
1009
|
+
content: string;
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
type index$5_EmailSkill = EmailSkill;
|
|
1013
|
+
type index$5_EmailSkillRegistry = EmailSkillRegistry;
|
|
1014
|
+
declare const index$5_attachmentWorkflowSkill: typeof attachmentWorkflowSkill;
|
|
1015
|
+
declare const index$5_composeAndSendSkill: typeof composeAndSendSkill;
|
|
1016
|
+
declare const index$5_connectAndSyncSkill: typeof connectAndSyncSkill;
|
|
1017
|
+
declare const index$5_defineEmailSkill: typeof defineEmailSkill;
|
|
1018
|
+
declare const index$5_emailSkills: typeof emailSkills;
|
|
1019
|
+
declare const index$5_getEmailSkillByName: typeof getEmailSkillByName;
|
|
1020
|
+
declare const index$5_organizeBulkSkill: typeof organizeBulkSkill;
|
|
1021
|
+
declare const index$5_readAndReplySkill: typeof readAndReplySkill;
|
|
1022
|
+
declare const index$5_recoverFromDisruptionSkill: typeof recoverFromDisruptionSkill;
|
|
1023
|
+
declare const index$5_searchAndActSkill: typeof searchAndActSkill;
|
|
1024
|
+
declare const index$5_triageInboxSkill: typeof triageInboxSkill;
|
|
1025
|
+
declare namespace index$5 {
|
|
1026
|
+
export { type index$5_EmailSkill as EmailSkill, type index$5_EmailSkillRegistry as EmailSkillRegistry, index$5_attachmentWorkflowSkill as attachmentWorkflowSkill, index$5_composeAndSendSkill as composeAndSendSkill, index$5_connectAndSyncSkill as connectAndSyncSkill, index$5_defineEmailSkill as defineEmailSkill, index$5_emailSkills as emailSkills, index$5_getEmailSkillByName as getEmailSkillByName, index$5_organizeBulkSkill as organizeBulkSkill, index$5_readAndReplySkill as readAndReplySkill, index$5_recoverFromDisruptionSkill as recoverFromDisruptionSkill, index$5_searchAndActSkill as searchAndActSkill, index$5_triageInboxSkill as triageInboxSkill };
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
type SmtpResponse = {
|
|
1030
|
+
code: number;
|
|
1031
|
+
enhanced: string | null;
|
|
1032
|
+
message: string;
|
|
1033
|
+
isMultiline: boolean;
|
|
1034
|
+
};
|
|
1035
|
+
type SmtpErrorCategory = 'success' | 'temporary' | 'permanent';
|
|
1036
|
+
|
|
1037
|
+
declare class SmtpConnection {
|
|
1038
|
+
#private;
|
|
1039
|
+
constructor(options: {
|
|
1040
|
+
host: string;
|
|
1041
|
+
port: number;
|
|
1042
|
+
tls?: boolean;
|
|
1043
|
+
allowInsecure?: boolean;
|
|
1044
|
+
});
|
|
1045
|
+
get capabilities(): Map<string, string>;
|
|
1046
|
+
get maxSize(): number | null;
|
|
1047
|
+
connect(): Promise<void>;
|
|
1048
|
+
disconnect(): Promise<void>;
|
|
1049
|
+
sendCommand(cmd: string): Promise<SmtpResponse>;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
declare function smtpAuthenticate(conn: SmtpConnection, config: AuthConfig): Promise<void>;
|
|
1053
|
+
|
|
1054
|
+
declare function dotStuff(data: string): string;
|
|
1055
|
+
declare function dotUnstuff(data: string): string;
|
|
1056
|
+
|
|
1057
|
+
declare function parseSmtpResponse(lines: string[]): SmtpResponse;
|
|
1058
|
+
declare function categorizeSmtpError(code: number): SmtpErrorCategory;
|
|
1059
|
+
|
|
1060
|
+
type SmtpEnvelope = {
|
|
1061
|
+
from: string;
|
|
1062
|
+
to: string[];
|
|
1063
|
+
};
|
|
1064
|
+
declare function sendSmtpMessage(conn: SmtpConnection, envelope: SmtpEnvelope, message: Buffer): Promise<void>;
|
|
1065
|
+
|
|
1066
|
+
declare function smtpSend(config: EmailConfig, composed: Buffer, envelope: SmtpEnvelope): Promise<void>;
|
|
1067
|
+
|
|
1068
|
+
type index$4_SmtpConnection = SmtpConnection;
|
|
1069
|
+
declare const index$4_SmtpConnection: typeof SmtpConnection;
|
|
1070
|
+
type index$4_SmtpEnvelope = SmtpEnvelope;
|
|
1071
|
+
declare const index$4_categorizeSmtpError: typeof categorizeSmtpError;
|
|
1072
|
+
declare const index$4_dotStuff: typeof dotStuff;
|
|
1073
|
+
declare const index$4_dotUnstuff: typeof dotUnstuff;
|
|
1074
|
+
declare const index$4_parseSmtpResponse: typeof parseSmtpResponse;
|
|
1075
|
+
declare const index$4_sendSmtpMessage: typeof sendSmtpMessage;
|
|
1076
|
+
declare const index$4_smtpAuthenticate: typeof smtpAuthenticate;
|
|
1077
|
+
declare const index$4_smtpSend: typeof smtpSend;
|
|
1078
|
+
declare namespace index$4 {
|
|
1079
|
+
export { index$4_SmtpConnection as SmtpConnection, type index$4_SmtpEnvelope as SmtpEnvelope, index$4_categorizeSmtpError as categorizeSmtpError, index$4_dotStuff as dotStuff, index$4_dotUnstuff as dotUnstuff, index$4_parseSmtpResponse as parseSmtpResponse, index$4_sendSmtpMessage as sendSmtpMessage, index$4_smtpAuthenticate as smtpAuthenticate, index$4_smtpSend as smtpSend };
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
interface EmailSoulTrait {
|
|
1083
|
+
principle: string;
|
|
1084
|
+
provenance: string;
|
|
1085
|
+
}
|
|
1086
|
+
interface EmailSoul {
|
|
1087
|
+
slug: string;
|
|
1088
|
+
name: string;
|
|
1089
|
+
description: string;
|
|
1090
|
+
essence: string;
|
|
1091
|
+
traits: readonly EmailSoulTrait[];
|
|
1092
|
+
}
|
|
1093
|
+
declare const emailSoulEssence = "You think like the postmaster of a distributed letter room. Your mail comes from servers that change state without notifying you, goes out through queues that don't confirm delivery, and lives locally in a cache that is always a snapshot \u2014 never the truth.\n\nYour first responsibility is knowing which state you are in. When you read from the local database you are reading a picture taken during the last sync. When you trigger a fetch you are asking the server for a more recent picture. When you compose a reply you are creating something new that has not been confirmed anywhere yet. These are three different epistemic positions, and conflating them is where most mail-handling mistakes begin.\n\nYour second responsibility is thread coherence. A message in isolation is rarely enough to act on. Mail lives in conversations \u2014 threads where the oldest message set the context, the middle messages changed it, and the most recent message is what actually needs attention. Before you compose, read the thread. Before you archive, check whether the thread is complete. Before you mark answered, confirm the reply actually landed.\n\nYour third responsibility is proportionality between action and certainty. Reading is always safe. Marking flags is reversible. Archiving is recoverable. Trashing is mostly recoverable. Sending is permanent. Deleting is permanent. These exist on a gradient of consequence, and you move down it only as far as the situation genuinely requires. An action one step more destructive than necessary always costs something.\n\nYour fourth responsibility is classifying failures before reacting. A network timeout and an authentication rejection look similar but require opposite responses. Retrying a transient error is sensible. Retrying a bad-credentials error triggers lockouts. An SMTP failure mid-send may mean a duplicate is already in the recipient's inbox. You stop before you retry, and you identify what actually failed.\n\nYou do not invent protocol guarantees. You do not treat a locally-staged draft as a sent message. You do not treat a sync result as proof that the server will not have changed by the time you act on it. Precision here is not caution \u2014 it is how you stay useful across the full lifecycle of a mailbox.";
|
|
1094
|
+
declare const emailSoulTraits: {
|
|
1095
|
+
principle: string;
|
|
1096
|
+
provenance: string;
|
|
1097
|
+
}[];
|
|
1098
|
+
declare const emailSoul: EmailSoul;
|
|
1099
|
+
declare function renderEmailSoulPromptFoundation(soul?: EmailSoul): string;
|
|
1100
|
+
|
|
1101
|
+
type soul_EmailSoul = EmailSoul;
|
|
1102
|
+
type soul_EmailSoulTrait = EmailSoulTrait;
|
|
1103
|
+
declare const soul_emailSoul: typeof emailSoul;
|
|
1104
|
+
declare const soul_emailSoulEssence: typeof emailSoulEssence;
|
|
1105
|
+
declare const soul_emailSoulTraits: typeof emailSoulTraits;
|
|
1106
|
+
declare const soul_renderEmailSoulPromptFoundation: typeof renderEmailSoulPromptFoundation;
|
|
1107
|
+
declare namespace soul {
|
|
1108
|
+
export { type soul_EmailSoul as EmailSoul, type soul_EmailSoulTrait as EmailSoulTrait, soul_emailSoul as emailSoul, soul_emailSoulEssence as emailSoulEssence, soul_emailSoulTraits as emailSoulTraits, soul_renderEmailSoulPromptFoundation as renderEmailSoulPromptFoundation };
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* Assigns `thread_id` per message: first References entry, else In-Reply-To, else Message-ID.
|
|
1113
|
+
*/
|
|
1114
|
+
declare function computeThreads(db: EmailDb, folderId: number): void;
|
|
1115
|
+
|
|
1116
|
+
declare function deleteAccount(db: EmailDb, id: number): void;
|
|
1117
|
+
|
|
1118
|
+
declare function deleteFolder(db: EmailDb, folderId: number): void;
|
|
1119
|
+
|
|
1120
|
+
declare function deleteFolderMessages(db: EmailDb, folderId: number): void;
|
|
1121
|
+
|
|
1122
|
+
declare function deleteMessages(db: EmailDb, folderId: number, uids: readonly number[]): void;
|
|
1123
|
+
|
|
1124
|
+
type Account = {
|
|
1125
|
+
id: number;
|
|
1126
|
+
host: string;
|
|
1127
|
+
port: number;
|
|
1128
|
+
username: string;
|
|
1129
|
+
label: string | null;
|
|
1130
|
+
createdAt: string;
|
|
1131
|
+
};
|
|
1132
|
+
|
|
1133
|
+
declare function getAccount(db: EmailDb, id: number): Account | undefined;
|
|
1134
|
+
|
|
1135
|
+
declare function getAttachmentData(db: EmailDb, attachmentId: number): Attachment | undefined;
|
|
1136
|
+
|
|
1137
|
+
declare function getBody(db: EmailDb, messageId: number): MessageBody | undefined;
|
|
1138
|
+
|
|
1139
|
+
declare function getFolder(db: EmailDb, accountId: number, path: string): Folder | undefined;
|
|
1140
|
+
|
|
1141
|
+
declare function getFolderById(db: EmailDb, folderId: number): Folder | undefined;
|
|
1142
|
+
|
|
1143
|
+
declare function getMessage(db: EmailDb, folderId: number, uid: number): Message | undefined;
|
|
1144
|
+
|
|
1145
|
+
declare function getMessageById(db: EmailDb, id: number): Message | undefined;
|
|
1146
|
+
|
|
1147
|
+
declare function getStats(db: EmailDb, accountId: number): AccountStats;
|
|
1148
|
+
|
|
1149
|
+
declare function getThread(db: EmailDb, threadId: string): Thread;
|
|
1150
|
+
|
|
1151
|
+
type InsertAttachmentInput = {
|
|
1152
|
+
messageId: number;
|
|
1153
|
+
filename?: string | null;
|
|
1154
|
+
mimeType?: string | null;
|
|
1155
|
+
size?: number | null;
|
|
1156
|
+
contentId?: string | null;
|
|
1157
|
+
partPath: string;
|
|
1158
|
+
inline: boolean;
|
|
1159
|
+
data?: Buffer | null;
|
|
1160
|
+
};
|
|
1161
|
+
declare function insertAttachment(db: EmailDb, input: InsertAttachmentInput): AttachmentMeta;
|
|
1162
|
+
|
|
1163
|
+
declare function insertMessage(db: EmailDb, input: InsertMessageInput): Message;
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Batch-insert messages using INSERT OR IGNORE so that duplicates
|
|
1167
|
+
* (same folder_id + uid) are silently skipped. This makes sync
|
|
1168
|
+
* idempotent: running initialSync twice on the same folder won't crash.
|
|
1169
|
+
*/
|
|
1170
|
+
declare function insertMessagesBatch(db: EmailDb, inputs: InsertMessageInput[]): void;
|
|
1171
|
+
|
|
1172
|
+
declare function insertSyncLog(db: EmailDb, folderId: number, action: string, uid: number, details?: string): void;
|
|
1173
|
+
|
|
1174
|
+
declare function listAccounts(db: EmailDb): Account[];
|
|
1175
|
+
|
|
1176
|
+
declare function listAttachments(db: EmailDb, messageId: number): AttachmentMeta[];
|
|
1177
|
+
|
|
1178
|
+
declare function listFolders(db: EmailDb, accountId: number): Folder[];
|
|
1179
|
+
|
|
1180
|
+
declare function listMessages(db: EmailDb, folderId: number, options?: MessageListOptions): Message[];
|
|
1181
|
+
|
|
1182
|
+
type SyncLogEntry = {
|
|
1183
|
+
id: number;
|
|
1184
|
+
folderId: number;
|
|
1185
|
+
action: string;
|
|
1186
|
+
uid: number;
|
|
1187
|
+
details: string | null;
|
|
1188
|
+
syncedAt: string;
|
|
1189
|
+
};
|
|
1190
|
+
declare function listSyncLog(db: EmailDb, folderId: number, options?: {
|
|
1191
|
+
limit?: number;
|
|
1192
|
+
}): SyncLogEntry[];
|
|
1193
|
+
|
|
1194
|
+
declare function listThreads(db: EmailDb, folderId: number, options?: ThreadListOptions): Thread[];
|
|
1195
|
+
|
|
1196
|
+
declare function searchMessages(db: EmailDb, query: string, options?: LocalSearchOptions): Message[];
|
|
1197
|
+
|
|
1198
|
+
declare function updateAttachmentData(db: EmailDb, attachmentId: number, data: Buffer): void;
|
|
1199
|
+
|
|
1200
|
+
type FolderSyncMeta = {
|
|
1201
|
+
uidValidity?: number | null;
|
|
1202
|
+
uidNext?: number | null;
|
|
1203
|
+
highestModSeq?: number | null;
|
|
1204
|
+
messageCount?: number | null;
|
|
1205
|
+
unseenCount?: number | null;
|
|
1206
|
+
lastSyncedAt?: string | null;
|
|
1207
|
+
};
|
|
1208
|
+
declare function updateFolderSync(db: EmailDb, folderId: number, meta: FolderSyncMeta): void;
|
|
1209
|
+
|
|
1210
|
+
declare function updateMessageFlags(db: EmailDb, folderId: number, uid: number, flags: string[]): void;
|
|
1211
|
+
|
|
1212
|
+
declare function updateMessageThread(db: EmailDb, messageId: number, threadId: string): void;
|
|
1213
|
+
|
|
1214
|
+
type UpsertAccountInput = {
|
|
1215
|
+
id?: number;
|
|
1216
|
+
host: string;
|
|
1217
|
+
port: number;
|
|
1218
|
+
username: string;
|
|
1219
|
+
label?: string | null;
|
|
1220
|
+
};
|
|
1221
|
+
declare function upsertAccount(db: EmailDb, input: UpsertAccountInput): Account;
|
|
1222
|
+
|
|
1223
|
+
declare function upsertBody(db: EmailDb, messageId: number, textPlain: string | null, textHtml: string | null, raw?: Buffer): void;
|
|
1224
|
+
|
|
1225
|
+
type UpsertFolderInput = {
|
|
1226
|
+
accountId: number;
|
|
1227
|
+
path: string;
|
|
1228
|
+
delimiter?: string;
|
|
1229
|
+
role?: FolderRole;
|
|
1230
|
+
uidValidity?: number | null;
|
|
1231
|
+
uidNext?: number | null;
|
|
1232
|
+
highestModSeq?: number | null;
|
|
1233
|
+
messageCount?: number | null;
|
|
1234
|
+
unseenCount?: number | null;
|
|
1235
|
+
lastSyncedAt?: string | null;
|
|
1236
|
+
};
|
|
1237
|
+
declare function upsertFolder(db: EmailDb, input: UpsertFolderInput): Folder;
|
|
1238
|
+
|
|
1239
|
+
type index$3_FolderSyncMeta = FolderSyncMeta;
|
|
1240
|
+
type index$3_InsertAttachmentInput = InsertAttachmentInput;
|
|
1241
|
+
type index$3_SyncLogEntry = SyncLogEntry;
|
|
1242
|
+
type index$3_UpsertAccountInput = UpsertAccountInput;
|
|
1243
|
+
type index$3_UpsertFolderInput = UpsertFolderInput;
|
|
1244
|
+
declare const index$3_computeThreads: typeof computeThreads;
|
|
1245
|
+
declare const index$3_deleteAccount: typeof deleteAccount;
|
|
1246
|
+
declare const index$3_deleteFolder: typeof deleteFolder;
|
|
1247
|
+
declare const index$3_deleteFolderMessages: typeof deleteFolderMessages;
|
|
1248
|
+
declare const index$3_deleteMessages: typeof deleteMessages;
|
|
1249
|
+
declare const index$3_getAccount: typeof getAccount;
|
|
1250
|
+
declare const index$3_getAttachmentData: typeof getAttachmentData;
|
|
1251
|
+
declare const index$3_getBody: typeof getBody;
|
|
1252
|
+
declare const index$3_getFolder: typeof getFolder;
|
|
1253
|
+
declare const index$3_getFolderById: typeof getFolderById;
|
|
1254
|
+
declare const index$3_getMessage: typeof getMessage;
|
|
1255
|
+
declare const index$3_getMessageById: typeof getMessageById;
|
|
1256
|
+
declare const index$3_getStats: typeof getStats;
|
|
1257
|
+
declare const index$3_getThread: typeof getThread;
|
|
1258
|
+
declare const index$3_insertAttachment: typeof insertAttachment;
|
|
1259
|
+
declare const index$3_insertMessage: typeof insertMessage;
|
|
1260
|
+
declare const index$3_insertMessagesBatch: typeof insertMessagesBatch;
|
|
1261
|
+
declare const index$3_insertSyncLog: typeof insertSyncLog;
|
|
1262
|
+
declare const index$3_listAccounts: typeof listAccounts;
|
|
1263
|
+
declare const index$3_listAttachments: typeof listAttachments;
|
|
1264
|
+
declare const index$3_listFolders: typeof listFolders;
|
|
1265
|
+
declare const index$3_listMessages: typeof listMessages;
|
|
1266
|
+
declare const index$3_listSyncLog: typeof listSyncLog;
|
|
1267
|
+
declare const index$3_listThreads: typeof listThreads;
|
|
1268
|
+
declare const index$3_searchMessages: typeof searchMessages;
|
|
1269
|
+
declare const index$3_updateAttachmentData: typeof updateAttachmentData;
|
|
1270
|
+
declare const index$3_updateFolderSync: typeof updateFolderSync;
|
|
1271
|
+
declare const index$3_updateMessageFlags: typeof updateMessageFlags;
|
|
1272
|
+
declare const index$3_updateMessageThread: typeof updateMessageThread;
|
|
1273
|
+
declare const index$3_upsertAccount: typeof upsertAccount;
|
|
1274
|
+
declare const index$3_upsertBody: typeof upsertBody;
|
|
1275
|
+
declare const index$3_upsertFolder: typeof upsertFolder;
|
|
1276
|
+
declare namespace index$3 {
|
|
1277
|
+
export { type index$3_FolderSyncMeta as FolderSyncMeta, type index$3_InsertAttachmentInput as InsertAttachmentInput, type index$3_SyncLogEntry as SyncLogEntry, type index$3_UpsertAccountInput as UpsertAccountInput, type index$3_UpsertFolderInput as UpsertFolderInput, index$3_computeThreads as computeThreads, index$3_deleteAccount as deleteAccount, index$3_deleteFolder as deleteFolder, index$3_deleteFolderMessages as deleteFolderMessages, index$3_deleteMessages as deleteMessages, index$3_getAccount as getAccount, index$3_getAttachmentData as getAttachmentData, index$3_getBody as getBody, index$3_getFolder as getFolder, index$3_getFolderById as getFolderById, index$3_getMessage as getMessage, index$3_getMessageById as getMessageById, index$3_getStats as getStats, index$3_getThread as getThread, index$3_insertAttachment as insertAttachment, index$3_insertMessage as insertMessage, index$3_insertMessagesBatch as insertMessagesBatch, index$3_insertSyncLog as insertSyncLog, index$3_listAccounts as listAccounts, index$3_listAttachments as listAttachments, index$3_listFolders as listFolders, index$3_listMessages as listMessages, index$3_listSyncLog as listSyncLog, index$3_listThreads as listThreads, index$3_searchMessages as searchMessages, index$3_updateAttachmentData as updateAttachmentData, index$3_updateFolderSync as updateFolderSync, index$3_updateMessageFlags as updateMessageFlags, index$3_updateMessageThread as updateMessageThread, index$3_upsertAccount as upsertAccount, index$3_upsertBody as upsertBody, index$3_upsertFolder as upsertFolder };
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
declare function fetchAttachment(session: ImapSession, db: EmailDb, accountId: number, folderPath: string, uid: number, partPath: string): Promise<Buffer>;
|
|
1281
|
+
|
|
1282
|
+
declare function fetchBody(session: ImapSession, db: EmailDb, accountId: number, folderPath: string, uid: number): Promise<void>;
|
|
1283
|
+
|
|
1284
|
+
declare function populateFts(db: EmailDb, messageId: number, textPlain: string | null, textHtml: string | null): void;
|
|
1285
|
+
|
|
1286
|
+
declare const UIDVALIDITY_CHANGED: "uidvalidity_changed";
|
|
1287
|
+
declare function incrementalSyncFallback(session: ImapSession, db: EmailDb, folder: Folder): Promise<SyncFolderResult | typeof UIDVALIDITY_CHANGED>;
|
|
1288
|
+
|
|
1289
|
+
declare function incrementalSyncQresync(session: ImapSession, db: EmailDb, folder: Folder): Promise<SyncFolderResult>;
|
|
1290
|
+
|
|
1291
|
+
declare function initialSync(session: ImapSession, db: EmailDb, folderId: number, folderPath: string): Promise<SyncFolderResult>;
|
|
1292
|
+
|
|
1293
|
+
declare function syncFolder(session: ImapSession, db: EmailDb, folder: Folder, _options?: SyncOptions): Promise<SyncFolderResult>;
|
|
1294
|
+
|
|
1295
|
+
declare function handleUidValidityChange(db: EmailDb, folder: Folder): void;
|
|
1296
|
+
|
|
1297
|
+
declare const index$2_UIDVALIDITY_CHANGED: typeof UIDVALIDITY_CHANGED;
|
|
1298
|
+
declare const index$2_fetchAttachment: typeof fetchAttachment;
|
|
1299
|
+
declare const index$2_fetchBody: typeof fetchBody;
|
|
1300
|
+
declare const index$2_handleUidValidityChange: typeof handleUidValidityChange;
|
|
1301
|
+
declare const index$2_incrementalSyncFallback: typeof incrementalSyncFallback;
|
|
1302
|
+
declare const index$2_incrementalSyncQresync: typeof incrementalSyncQresync;
|
|
1303
|
+
declare const index$2_initialSync: typeof initialSync;
|
|
1304
|
+
declare const index$2_populateFts: typeof populateFts;
|
|
1305
|
+
declare const index$2_syncFolder: typeof syncFolder;
|
|
1306
|
+
declare namespace index$2 {
|
|
1307
|
+
export { index$2_UIDVALIDITY_CHANGED as UIDVALIDITY_CHANGED, index$2_fetchAttachment as fetchAttachment, index$2_fetchBody as fetchBody, index$2_handleUidValidityChange as handleUidValidityChange, index$2_incrementalSyncFallback as incrementalSyncFallback, index$2_incrementalSyncQresync as incrementalSyncQresync, index$2_initialSync as initialSync, index$2_populateFts as populateFts, index$2_syncFolder as syncFolder };
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
type ToolEntityKind = 'account' | 'attachment' | 'mailbox' | 'message' | 'sync_job' | 'thread' | 'transport';
|
|
1311
|
+
type ToolOutcomeKind = 'error' | 'needs_clarification' | 'no_op' | 'success';
|
|
1312
|
+
interface ToolEntityRef {
|
|
1313
|
+
kind: ToolEntityKind;
|
|
1314
|
+
id: string;
|
|
1315
|
+
title: string;
|
|
1316
|
+
}
|
|
1317
|
+
interface EmailToolResult {
|
|
1318
|
+
outcome: ToolOutcomeKind;
|
|
1319
|
+
summary: string;
|
|
1320
|
+
entities: readonly ToolEntityRef[];
|
|
1321
|
+
nextSteps: readonly string[];
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
type JsonSchemaType = 'array' | 'boolean' | 'integer' | 'number' | 'object' | 'string';
|
|
1325
|
+
interface JsonSchema {
|
|
1326
|
+
type?: JsonSchemaType | readonly JsonSchemaType[] | undefined;
|
|
1327
|
+
description?: string | undefined;
|
|
1328
|
+
properties?: Record<string, JsonSchema> | undefined;
|
|
1329
|
+
required?: readonly string[] | undefined;
|
|
1330
|
+
items?: JsonSchema | undefined;
|
|
1331
|
+
enum?: readonly unknown[] | undefined;
|
|
1332
|
+
}
|
|
1333
|
+
type ToolSideEffects = 'external' | 'none' | 'read' | 'write';
|
|
1334
|
+
/**
|
|
1335
|
+
* Context passed to every tool handler, containing the three live surfaces.
|
|
1336
|
+
* Consumers build this from a connected Mailbox instance.
|
|
1337
|
+
*/
|
|
1338
|
+
interface EmailToolContext {
|
|
1339
|
+
read: EmailReadSurface;
|
|
1340
|
+
write: EmailWriteSurface;
|
|
1341
|
+
network: EmailNetworkSurface;
|
|
1342
|
+
}
|
|
1343
|
+
interface EmailToolDefinition<TInput = unknown> {
|
|
1344
|
+
name: string;
|
|
1345
|
+
description: string;
|
|
1346
|
+
sideEffects: ToolSideEffects;
|
|
1347
|
+
inputSchema: JsonSchema;
|
|
1348
|
+
handler(ctx: EmailToolContext, input: TInput): Promise<EmailToolResult>;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
type MailReadInput = {
|
|
1352
|
+
view: 'folders';
|
|
1353
|
+
refresh?: boolean;
|
|
1354
|
+
} | {
|
|
1355
|
+
view: 'queue';
|
|
1356
|
+
folder?: string;
|
|
1357
|
+
unreadOnly?: boolean;
|
|
1358
|
+
limit?: number;
|
|
1359
|
+
refresh?: boolean;
|
|
1360
|
+
} | {
|
|
1361
|
+
view: 'thread';
|
|
1362
|
+
threadId: string;
|
|
1363
|
+
} | {
|
|
1364
|
+
view: 'message';
|
|
1365
|
+
folder: string;
|
|
1366
|
+
uid: number;
|
|
1367
|
+
} | {
|
|
1368
|
+
view: 'attachment';
|
|
1369
|
+
folder: string;
|
|
1370
|
+
uid: number;
|
|
1371
|
+
partPath?: string;
|
|
1372
|
+
} | {
|
|
1373
|
+
view: 'eml';
|
|
1374
|
+
folder: string;
|
|
1375
|
+
uid: number;
|
|
1376
|
+
};
|
|
1377
|
+
type MailSearchInput = {
|
|
1378
|
+
query: string;
|
|
1379
|
+
folder?: string;
|
|
1380
|
+
mode?: 'local' | 'remote';
|
|
1381
|
+
since?: string;
|
|
1382
|
+
before?: string;
|
|
1383
|
+
hasAttachments?: boolean;
|
|
1384
|
+
unreadOnly?: boolean;
|
|
1385
|
+
limit?: number;
|
|
1386
|
+
};
|
|
1387
|
+
type MailComposeInput = {
|
|
1388
|
+
action: 'send';
|
|
1389
|
+
input: ComposeInput;
|
|
1390
|
+
} | {
|
|
1391
|
+
action: 'reply';
|
|
1392
|
+
folder: string;
|
|
1393
|
+
uid: number;
|
|
1394
|
+
input: ReplyInput;
|
|
1395
|
+
} | {
|
|
1396
|
+
action: 'forward';
|
|
1397
|
+
folder: string;
|
|
1398
|
+
uid: number;
|
|
1399
|
+
input: ForwardInput;
|
|
1400
|
+
} | {
|
|
1401
|
+
action: 'save_draft';
|
|
1402
|
+
input: ComposeInput;
|
|
1403
|
+
} | {
|
|
1404
|
+
action: 'update_draft';
|
|
1405
|
+
uid: number;
|
|
1406
|
+
input: ComposeInput;
|
|
1407
|
+
} | {
|
|
1408
|
+
action: 'send_draft';
|
|
1409
|
+
uid: number;
|
|
1410
|
+
};
|
|
1411
|
+
type MailOrganizeInput = {
|
|
1412
|
+
action: 'mark_read' | 'mark_unread' | 'star' | 'unstar' | 'mark_answered';
|
|
1413
|
+
folder: string;
|
|
1414
|
+
uids: number[];
|
|
1415
|
+
} | {
|
|
1416
|
+
action: 'copy' | 'move';
|
|
1417
|
+
folder: string;
|
|
1418
|
+
uids: number[];
|
|
1419
|
+
destination: string;
|
|
1420
|
+
} | {
|
|
1421
|
+
action: 'archive' | 'trash' | 'junk';
|
|
1422
|
+
folder: string;
|
|
1423
|
+
uids: number[];
|
|
1424
|
+
} | {
|
|
1425
|
+
action: 'not_junk';
|
|
1426
|
+
folder: string;
|
|
1427
|
+
uids: number[];
|
|
1428
|
+
destination?: string;
|
|
1429
|
+
} | {
|
|
1430
|
+
action: 'set_labels' | 'add_labels' | 'remove_labels';
|
|
1431
|
+
folder: string;
|
|
1432
|
+
uids: number[];
|
|
1433
|
+
labels: string[];
|
|
1434
|
+
} | {
|
|
1435
|
+
action: 'create_folder';
|
|
1436
|
+
path: string;
|
|
1437
|
+
} | {
|
|
1438
|
+
action: 'rename_folder';
|
|
1439
|
+
oldPath: string;
|
|
1440
|
+
newPath: string;
|
|
1441
|
+
} | {
|
|
1442
|
+
action: 'delete_folder' | 'subscribe_folder' | 'unsubscribe_folder';
|
|
1443
|
+
path: string;
|
|
1444
|
+
};
|
|
1445
|
+
type MailSyncInput = {
|
|
1446
|
+
action: 'connect' | 'disconnect' | 'reconnect';
|
|
1447
|
+
} | {
|
|
1448
|
+
action: 'sync';
|
|
1449
|
+
folders?: string[];
|
|
1450
|
+
bodies?: 'none' | 'missing' | 'all';
|
|
1451
|
+
} | {
|
|
1452
|
+
action: 'refresh_folders';
|
|
1453
|
+
} | {
|
|
1454
|
+
action: 'watch';
|
|
1455
|
+
folders?: string[];
|
|
1456
|
+
};
|
|
1457
|
+
declare const emailTools: ({
|
|
1458
|
+
name: string;
|
|
1459
|
+
description: string;
|
|
1460
|
+
sideEffects: "read";
|
|
1461
|
+
inputSchema: {
|
|
1462
|
+
type: "object";
|
|
1463
|
+
required: string[];
|
|
1464
|
+
properties: {
|
|
1465
|
+
view: {
|
|
1466
|
+
type: "string";
|
|
1467
|
+
enum: string[];
|
|
1468
|
+
description: string;
|
|
1469
|
+
};
|
|
1470
|
+
folder: {
|
|
1471
|
+
type: "string";
|
|
1472
|
+
description: string;
|
|
1473
|
+
};
|
|
1474
|
+
uid: {
|
|
1475
|
+
type: "integer";
|
|
1476
|
+
description: string;
|
|
1477
|
+
};
|
|
1478
|
+
threadId: {
|
|
1479
|
+
type: "string";
|
|
1480
|
+
description: string;
|
|
1481
|
+
};
|
|
1482
|
+
partPath: {
|
|
1483
|
+
type: "string";
|
|
1484
|
+
description: string;
|
|
1485
|
+
};
|
|
1486
|
+
limit: {
|
|
1487
|
+
type: "integer";
|
|
1488
|
+
description: string;
|
|
1489
|
+
};
|
|
1490
|
+
unreadOnly: {
|
|
1491
|
+
type: "boolean";
|
|
1492
|
+
description: string;
|
|
1493
|
+
};
|
|
1494
|
+
refresh: {
|
|
1495
|
+
type: "boolean";
|
|
1496
|
+
description: string;
|
|
1497
|
+
};
|
|
1498
|
+
query?: never;
|
|
1499
|
+
mode?: never;
|
|
1500
|
+
since?: never;
|
|
1501
|
+
before?: never;
|
|
1502
|
+
hasAttachments?: never;
|
|
1503
|
+
action?: never;
|
|
1504
|
+
input?: never;
|
|
1505
|
+
uids?: never;
|
|
1506
|
+
destination?: never;
|
|
1507
|
+
labels?: never;
|
|
1508
|
+
path?: never;
|
|
1509
|
+
oldPath?: never;
|
|
1510
|
+
newPath?: never;
|
|
1511
|
+
folders?: never;
|
|
1512
|
+
bodies?: never;
|
|
1513
|
+
};
|
|
1514
|
+
};
|
|
1515
|
+
handler(ctx: EmailToolContext, input: MailReadInput): Promise<{
|
|
1516
|
+
outcome: "success";
|
|
1517
|
+
summary: string;
|
|
1518
|
+
entities: {
|
|
1519
|
+
kind: "mailbox";
|
|
1520
|
+
id: string;
|
|
1521
|
+
title: string;
|
|
1522
|
+
}[];
|
|
1523
|
+
nextSteps: string[];
|
|
1524
|
+
} | {
|
|
1525
|
+
outcome: "success";
|
|
1526
|
+
summary: string;
|
|
1527
|
+
entities: {
|
|
1528
|
+
kind: "message";
|
|
1529
|
+
id: string;
|
|
1530
|
+
title: string;
|
|
1531
|
+
}[];
|
|
1532
|
+
nextSteps: string[];
|
|
1533
|
+
} | {
|
|
1534
|
+
outcome: "success";
|
|
1535
|
+
summary: string;
|
|
1536
|
+
entities: {
|
|
1537
|
+
kind: "thread";
|
|
1538
|
+
id: string;
|
|
1539
|
+
title: string;
|
|
1540
|
+
}[];
|
|
1541
|
+
nextSteps: string[];
|
|
1542
|
+
} | {
|
|
1543
|
+
outcome: "success";
|
|
1544
|
+
summary: string;
|
|
1545
|
+
entities: {
|
|
1546
|
+
kind: "attachment";
|
|
1547
|
+
id: string;
|
|
1548
|
+
title: string;
|
|
1549
|
+
}[];
|
|
1550
|
+
nextSteps: string[];
|
|
1551
|
+
} | {
|
|
1552
|
+
outcome: "error";
|
|
1553
|
+
summary: string;
|
|
1554
|
+
entities: never[];
|
|
1555
|
+
nextSteps: string[];
|
|
1556
|
+
}>;
|
|
1557
|
+
} | {
|
|
1558
|
+
name: string;
|
|
1559
|
+
description: string;
|
|
1560
|
+
sideEffects: "read";
|
|
1561
|
+
inputSchema: {
|
|
1562
|
+
type: "object";
|
|
1563
|
+
required: string[];
|
|
1564
|
+
properties: {
|
|
1565
|
+
query: {
|
|
1566
|
+
type: "string";
|
|
1567
|
+
description: string;
|
|
1568
|
+
};
|
|
1569
|
+
folder: {
|
|
1570
|
+
type: "string";
|
|
1571
|
+
description: string;
|
|
1572
|
+
};
|
|
1573
|
+
mode: {
|
|
1574
|
+
type: "string";
|
|
1575
|
+
enum: string[];
|
|
1576
|
+
description: string;
|
|
1577
|
+
};
|
|
1578
|
+
since: {
|
|
1579
|
+
type: "string";
|
|
1580
|
+
description: string;
|
|
1581
|
+
};
|
|
1582
|
+
before: {
|
|
1583
|
+
type: "string";
|
|
1584
|
+
description: string;
|
|
1585
|
+
};
|
|
1586
|
+
hasAttachments: {
|
|
1587
|
+
type: "boolean";
|
|
1588
|
+
description: string;
|
|
1589
|
+
};
|
|
1590
|
+
unreadOnly: {
|
|
1591
|
+
type: "boolean";
|
|
1592
|
+
description: string;
|
|
1593
|
+
};
|
|
1594
|
+
limit: {
|
|
1595
|
+
type: "integer";
|
|
1596
|
+
description: string;
|
|
1597
|
+
};
|
|
1598
|
+
view?: never;
|
|
1599
|
+
uid?: never;
|
|
1600
|
+
threadId?: never;
|
|
1601
|
+
partPath?: never;
|
|
1602
|
+
refresh?: never;
|
|
1603
|
+
action?: never;
|
|
1604
|
+
input?: never;
|
|
1605
|
+
uids?: never;
|
|
1606
|
+
destination?: never;
|
|
1607
|
+
labels?: never;
|
|
1608
|
+
path?: never;
|
|
1609
|
+
oldPath?: never;
|
|
1610
|
+
newPath?: never;
|
|
1611
|
+
folders?: never;
|
|
1612
|
+
bodies?: never;
|
|
1613
|
+
};
|
|
1614
|
+
};
|
|
1615
|
+
handler(ctx: EmailToolContext, input: MailSearchInput): Promise<{
|
|
1616
|
+
outcome: "success";
|
|
1617
|
+
summary: string;
|
|
1618
|
+
entities: {
|
|
1619
|
+
kind: "message";
|
|
1620
|
+
id: string;
|
|
1621
|
+
title: string;
|
|
1622
|
+
}[];
|
|
1623
|
+
nextSteps: string[];
|
|
1624
|
+
} | {
|
|
1625
|
+
outcome: "error";
|
|
1626
|
+
summary: string;
|
|
1627
|
+
entities: never[];
|
|
1628
|
+
nextSteps: string[];
|
|
1629
|
+
}>;
|
|
1630
|
+
} | {
|
|
1631
|
+
name: string;
|
|
1632
|
+
description: string;
|
|
1633
|
+
sideEffects: "external";
|
|
1634
|
+
inputSchema: {
|
|
1635
|
+
type: "object";
|
|
1636
|
+
required: string[];
|
|
1637
|
+
properties: {
|
|
1638
|
+
action: {
|
|
1639
|
+
type: "string";
|
|
1640
|
+
enum: string[];
|
|
1641
|
+
};
|
|
1642
|
+
folder: {
|
|
1643
|
+
type: "string";
|
|
1644
|
+
description: string;
|
|
1645
|
+
};
|
|
1646
|
+
uid: {
|
|
1647
|
+
type: "integer";
|
|
1648
|
+
description: string;
|
|
1649
|
+
};
|
|
1650
|
+
input: {
|
|
1651
|
+
type: "object";
|
|
1652
|
+
description: string;
|
|
1653
|
+
};
|
|
1654
|
+
view?: never;
|
|
1655
|
+
threadId?: never;
|
|
1656
|
+
partPath?: never;
|
|
1657
|
+
limit?: never;
|
|
1658
|
+
unreadOnly?: never;
|
|
1659
|
+
refresh?: never;
|
|
1660
|
+
query?: never;
|
|
1661
|
+
mode?: never;
|
|
1662
|
+
since?: never;
|
|
1663
|
+
before?: never;
|
|
1664
|
+
hasAttachments?: never;
|
|
1665
|
+
uids?: never;
|
|
1666
|
+
destination?: never;
|
|
1667
|
+
labels?: never;
|
|
1668
|
+
path?: never;
|
|
1669
|
+
oldPath?: never;
|
|
1670
|
+
newPath?: never;
|
|
1671
|
+
folders?: never;
|
|
1672
|
+
bodies?: never;
|
|
1673
|
+
};
|
|
1674
|
+
};
|
|
1675
|
+
handler(ctx: EmailToolContext, input: MailComposeInput): Promise<{
|
|
1676
|
+
outcome: "success";
|
|
1677
|
+
summary: string;
|
|
1678
|
+
entities: {
|
|
1679
|
+
kind: "message";
|
|
1680
|
+
id: string;
|
|
1681
|
+
title: string;
|
|
1682
|
+
}[];
|
|
1683
|
+
nextSteps: string[];
|
|
1684
|
+
} | {
|
|
1685
|
+
outcome: "error";
|
|
1686
|
+
summary: string;
|
|
1687
|
+
entities: never[];
|
|
1688
|
+
nextSteps: string[];
|
|
1689
|
+
}>;
|
|
1690
|
+
} | {
|
|
1691
|
+
name: string;
|
|
1692
|
+
description: string;
|
|
1693
|
+
sideEffects: "write";
|
|
1694
|
+
inputSchema: {
|
|
1695
|
+
type: "object";
|
|
1696
|
+
required: string[];
|
|
1697
|
+
properties: {
|
|
1698
|
+
action: {
|
|
1699
|
+
type: "string";
|
|
1700
|
+
enum: string[];
|
|
1701
|
+
};
|
|
1702
|
+
folder: {
|
|
1703
|
+
type: "string";
|
|
1704
|
+
description: string;
|
|
1705
|
+
};
|
|
1706
|
+
uids: {
|
|
1707
|
+
type: "array";
|
|
1708
|
+
items: {
|
|
1709
|
+
type: "integer";
|
|
1710
|
+
};
|
|
1711
|
+
description: string;
|
|
1712
|
+
};
|
|
1713
|
+
destination: {
|
|
1714
|
+
type: "string";
|
|
1715
|
+
description: string;
|
|
1716
|
+
};
|
|
1717
|
+
labels: {
|
|
1718
|
+
type: "array";
|
|
1719
|
+
items: {
|
|
1720
|
+
type: "string";
|
|
1721
|
+
};
|
|
1722
|
+
description: string;
|
|
1723
|
+
};
|
|
1724
|
+
path: {
|
|
1725
|
+
type: "string";
|
|
1726
|
+
description: string;
|
|
1727
|
+
};
|
|
1728
|
+
oldPath: {
|
|
1729
|
+
type: "string";
|
|
1730
|
+
description: string;
|
|
1731
|
+
};
|
|
1732
|
+
newPath: {
|
|
1733
|
+
type: "string";
|
|
1734
|
+
description: string;
|
|
1735
|
+
};
|
|
1736
|
+
view?: never;
|
|
1737
|
+
uid?: never;
|
|
1738
|
+
threadId?: never;
|
|
1739
|
+
partPath?: never;
|
|
1740
|
+
limit?: never;
|
|
1741
|
+
unreadOnly?: never;
|
|
1742
|
+
refresh?: never;
|
|
1743
|
+
query?: never;
|
|
1744
|
+
mode?: never;
|
|
1745
|
+
since?: never;
|
|
1746
|
+
before?: never;
|
|
1747
|
+
hasAttachments?: never;
|
|
1748
|
+
input?: never;
|
|
1749
|
+
folders?: never;
|
|
1750
|
+
bodies?: never;
|
|
1751
|
+
};
|
|
1752
|
+
};
|
|
1753
|
+
handler(ctx: EmailToolContext, input: MailOrganizeInput): Promise<{
|
|
1754
|
+
outcome: "success";
|
|
1755
|
+
summary: string;
|
|
1756
|
+
entities: {
|
|
1757
|
+
kind: "message";
|
|
1758
|
+
id: string;
|
|
1759
|
+
title: string;
|
|
1760
|
+
}[];
|
|
1761
|
+
nextSteps: never[];
|
|
1762
|
+
} | {
|
|
1763
|
+
outcome: "success";
|
|
1764
|
+
summary: string;
|
|
1765
|
+
entities: {
|
|
1766
|
+
kind: "mailbox";
|
|
1767
|
+
id: string;
|
|
1768
|
+
title: string;
|
|
1769
|
+
}[];
|
|
1770
|
+
nextSteps: string[];
|
|
1771
|
+
} | {
|
|
1772
|
+
outcome: "error";
|
|
1773
|
+
summary: string;
|
|
1774
|
+
entities: never[];
|
|
1775
|
+
nextSteps: string[];
|
|
1776
|
+
}>;
|
|
1777
|
+
} | {
|
|
1778
|
+
name: string;
|
|
1779
|
+
description: string;
|
|
1780
|
+
sideEffects: "external";
|
|
1781
|
+
inputSchema: {
|
|
1782
|
+
type: "object";
|
|
1783
|
+
required: string[];
|
|
1784
|
+
properties: {
|
|
1785
|
+
action: {
|
|
1786
|
+
type: "string";
|
|
1787
|
+
enum: string[];
|
|
1788
|
+
};
|
|
1789
|
+
folders: {
|
|
1790
|
+
type: "array";
|
|
1791
|
+
items: {
|
|
1792
|
+
type: "string";
|
|
1793
|
+
};
|
|
1794
|
+
description: string;
|
|
1795
|
+
};
|
|
1796
|
+
bodies: {
|
|
1797
|
+
type: "string";
|
|
1798
|
+
enum: string[];
|
|
1799
|
+
description: string;
|
|
1800
|
+
};
|
|
1801
|
+
view?: never;
|
|
1802
|
+
folder?: never;
|
|
1803
|
+
uid?: never;
|
|
1804
|
+
threadId?: never;
|
|
1805
|
+
partPath?: never;
|
|
1806
|
+
limit?: never;
|
|
1807
|
+
unreadOnly?: never;
|
|
1808
|
+
refresh?: never;
|
|
1809
|
+
query?: never;
|
|
1810
|
+
mode?: never;
|
|
1811
|
+
since?: never;
|
|
1812
|
+
before?: never;
|
|
1813
|
+
hasAttachments?: never;
|
|
1814
|
+
input?: never;
|
|
1815
|
+
uids?: never;
|
|
1816
|
+
destination?: never;
|
|
1817
|
+
labels?: never;
|
|
1818
|
+
path?: never;
|
|
1819
|
+
oldPath?: never;
|
|
1820
|
+
newPath?: never;
|
|
1821
|
+
};
|
|
1822
|
+
};
|
|
1823
|
+
handler(ctx: EmailToolContext, input: MailSyncInput): Promise<{
|
|
1824
|
+
outcome: "success";
|
|
1825
|
+
summary: string;
|
|
1826
|
+
entities: {
|
|
1827
|
+
kind: "mailbox";
|
|
1828
|
+
id: string;
|
|
1829
|
+
title: string;
|
|
1830
|
+
}[];
|
|
1831
|
+
nextSteps: string[];
|
|
1832
|
+
} | {
|
|
1833
|
+
outcome: "error";
|
|
1834
|
+
summary: string;
|
|
1835
|
+
entities: never[];
|
|
1836
|
+
nextSteps: string[];
|
|
1837
|
+
}>;
|
|
1838
|
+
})[];
|
|
1839
|
+
|
|
1840
|
+
declare function getEmailToolByName(name: string): {
|
|
1841
|
+
name: string;
|
|
1842
|
+
description: string;
|
|
1843
|
+
sideEffects: "read";
|
|
1844
|
+
inputSchema: {
|
|
1845
|
+
type: "object";
|
|
1846
|
+
required: string[];
|
|
1847
|
+
properties: {
|
|
1848
|
+
view: {
|
|
1849
|
+
type: "string";
|
|
1850
|
+
enum: string[];
|
|
1851
|
+
description: string;
|
|
1852
|
+
};
|
|
1853
|
+
folder: {
|
|
1854
|
+
type: "string";
|
|
1855
|
+
description: string;
|
|
1856
|
+
};
|
|
1857
|
+
uid: {
|
|
1858
|
+
type: "integer";
|
|
1859
|
+
description: string;
|
|
1860
|
+
};
|
|
1861
|
+
threadId: {
|
|
1862
|
+
type: "string";
|
|
1863
|
+
description: string;
|
|
1864
|
+
};
|
|
1865
|
+
partPath: {
|
|
1866
|
+
type: "string";
|
|
1867
|
+
description: string;
|
|
1868
|
+
};
|
|
1869
|
+
limit: {
|
|
1870
|
+
type: "integer";
|
|
1871
|
+
description: string;
|
|
1872
|
+
};
|
|
1873
|
+
unreadOnly: {
|
|
1874
|
+
type: "boolean";
|
|
1875
|
+
description: string;
|
|
1876
|
+
};
|
|
1877
|
+
refresh: {
|
|
1878
|
+
type: "boolean";
|
|
1879
|
+
description: string;
|
|
1880
|
+
};
|
|
1881
|
+
query?: never;
|
|
1882
|
+
mode?: never;
|
|
1883
|
+
since?: never;
|
|
1884
|
+
before?: never;
|
|
1885
|
+
hasAttachments?: never;
|
|
1886
|
+
action?: never;
|
|
1887
|
+
input?: never;
|
|
1888
|
+
uids?: never;
|
|
1889
|
+
destination?: never;
|
|
1890
|
+
labels?: never;
|
|
1891
|
+
path?: never;
|
|
1892
|
+
oldPath?: never;
|
|
1893
|
+
newPath?: never;
|
|
1894
|
+
folders?: never;
|
|
1895
|
+
bodies?: never;
|
|
1896
|
+
};
|
|
1897
|
+
};
|
|
1898
|
+
handler(ctx: EmailToolContext, input: {
|
|
1899
|
+
view: "folders";
|
|
1900
|
+
refresh?: boolean;
|
|
1901
|
+
} | {
|
|
1902
|
+
view: "queue";
|
|
1903
|
+
folder?: string;
|
|
1904
|
+
unreadOnly?: boolean;
|
|
1905
|
+
limit?: number;
|
|
1906
|
+
refresh?: boolean;
|
|
1907
|
+
} | {
|
|
1908
|
+
view: "thread";
|
|
1909
|
+
threadId: string;
|
|
1910
|
+
} | {
|
|
1911
|
+
view: "message";
|
|
1912
|
+
folder: string;
|
|
1913
|
+
uid: number;
|
|
1914
|
+
} | {
|
|
1915
|
+
view: "attachment";
|
|
1916
|
+
folder: string;
|
|
1917
|
+
uid: number;
|
|
1918
|
+
partPath?: string;
|
|
1919
|
+
} | {
|
|
1920
|
+
view: "eml";
|
|
1921
|
+
folder: string;
|
|
1922
|
+
uid: number;
|
|
1923
|
+
}): Promise<{
|
|
1924
|
+
outcome: "success";
|
|
1925
|
+
summary: string;
|
|
1926
|
+
entities: {
|
|
1927
|
+
kind: "mailbox";
|
|
1928
|
+
id: string;
|
|
1929
|
+
title: string;
|
|
1930
|
+
}[];
|
|
1931
|
+
nextSteps: string[];
|
|
1932
|
+
} | {
|
|
1933
|
+
outcome: "success";
|
|
1934
|
+
summary: string;
|
|
1935
|
+
entities: {
|
|
1936
|
+
kind: "message";
|
|
1937
|
+
id: string;
|
|
1938
|
+
title: string;
|
|
1939
|
+
}[];
|
|
1940
|
+
nextSteps: string[];
|
|
1941
|
+
} | {
|
|
1942
|
+
outcome: "success";
|
|
1943
|
+
summary: string;
|
|
1944
|
+
entities: {
|
|
1945
|
+
kind: "thread";
|
|
1946
|
+
id: string;
|
|
1947
|
+
title: string;
|
|
1948
|
+
}[];
|
|
1949
|
+
nextSteps: string[];
|
|
1950
|
+
} | {
|
|
1951
|
+
outcome: "success";
|
|
1952
|
+
summary: string;
|
|
1953
|
+
entities: {
|
|
1954
|
+
kind: "attachment";
|
|
1955
|
+
id: string;
|
|
1956
|
+
title: string;
|
|
1957
|
+
}[];
|
|
1958
|
+
nextSteps: string[];
|
|
1959
|
+
} | {
|
|
1960
|
+
outcome: "error";
|
|
1961
|
+
summary: string;
|
|
1962
|
+
entities: never[];
|
|
1963
|
+
nextSteps: string[];
|
|
1964
|
+
}>;
|
|
1965
|
+
} | {
|
|
1966
|
+
name: string;
|
|
1967
|
+
description: string;
|
|
1968
|
+
sideEffects: "read";
|
|
1969
|
+
inputSchema: {
|
|
1970
|
+
type: "object";
|
|
1971
|
+
required: string[];
|
|
1972
|
+
properties: {
|
|
1973
|
+
query: {
|
|
1974
|
+
type: "string";
|
|
1975
|
+
description: string;
|
|
1976
|
+
};
|
|
1977
|
+
folder: {
|
|
1978
|
+
type: "string";
|
|
1979
|
+
description: string;
|
|
1980
|
+
};
|
|
1981
|
+
mode: {
|
|
1982
|
+
type: "string";
|
|
1983
|
+
enum: string[];
|
|
1984
|
+
description: string;
|
|
1985
|
+
};
|
|
1986
|
+
since: {
|
|
1987
|
+
type: "string";
|
|
1988
|
+
description: string;
|
|
1989
|
+
};
|
|
1990
|
+
before: {
|
|
1991
|
+
type: "string";
|
|
1992
|
+
description: string;
|
|
1993
|
+
};
|
|
1994
|
+
hasAttachments: {
|
|
1995
|
+
type: "boolean";
|
|
1996
|
+
description: string;
|
|
1997
|
+
};
|
|
1998
|
+
unreadOnly: {
|
|
1999
|
+
type: "boolean";
|
|
2000
|
+
description: string;
|
|
2001
|
+
};
|
|
2002
|
+
limit: {
|
|
2003
|
+
type: "integer";
|
|
2004
|
+
description: string;
|
|
2005
|
+
};
|
|
2006
|
+
view?: never;
|
|
2007
|
+
uid?: never;
|
|
2008
|
+
threadId?: never;
|
|
2009
|
+
partPath?: never;
|
|
2010
|
+
refresh?: never;
|
|
2011
|
+
action?: never;
|
|
2012
|
+
input?: never;
|
|
2013
|
+
uids?: never;
|
|
2014
|
+
destination?: never;
|
|
2015
|
+
labels?: never;
|
|
2016
|
+
path?: never;
|
|
2017
|
+
oldPath?: never;
|
|
2018
|
+
newPath?: never;
|
|
2019
|
+
folders?: never;
|
|
2020
|
+
bodies?: never;
|
|
2021
|
+
};
|
|
2022
|
+
};
|
|
2023
|
+
handler(ctx: EmailToolContext, input: {
|
|
2024
|
+
query: string;
|
|
2025
|
+
folder?: string;
|
|
2026
|
+
mode?: "local" | "remote";
|
|
2027
|
+
since?: string;
|
|
2028
|
+
before?: string;
|
|
2029
|
+
hasAttachments?: boolean;
|
|
2030
|
+
unreadOnly?: boolean;
|
|
2031
|
+
limit?: number;
|
|
2032
|
+
}): Promise<{
|
|
2033
|
+
outcome: "success";
|
|
2034
|
+
summary: string;
|
|
2035
|
+
entities: {
|
|
2036
|
+
kind: "message";
|
|
2037
|
+
id: string;
|
|
2038
|
+
title: string;
|
|
2039
|
+
}[];
|
|
2040
|
+
nextSteps: string[];
|
|
2041
|
+
} | {
|
|
2042
|
+
outcome: "error";
|
|
2043
|
+
summary: string;
|
|
2044
|
+
entities: never[];
|
|
2045
|
+
nextSteps: string[];
|
|
2046
|
+
}>;
|
|
2047
|
+
} | {
|
|
2048
|
+
name: string;
|
|
2049
|
+
description: string;
|
|
2050
|
+
sideEffects: "external";
|
|
2051
|
+
inputSchema: {
|
|
2052
|
+
type: "object";
|
|
2053
|
+
required: string[];
|
|
2054
|
+
properties: {
|
|
2055
|
+
action: {
|
|
2056
|
+
type: "string";
|
|
2057
|
+
enum: string[];
|
|
2058
|
+
};
|
|
2059
|
+
folder: {
|
|
2060
|
+
type: "string";
|
|
2061
|
+
description: string;
|
|
2062
|
+
};
|
|
2063
|
+
uid: {
|
|
2064
|
+
type: "integer";
|
|
2065
|
+
description: string;
|
|
2066
|
+
};
|
|
2067
|
+
input: {
|
|
2068
|
+
type: "object";
|
|
2069
|
+
description: string;
|
|
2070
|
+
};
|
|
2071
|
+
view?: never;
|
|
2072
|
+
threadId?: never;
|
|
2073
|
+
partPath?: never;
|
|
2074
|
+
limit?: never;
|
|
2075
|
+
unreadOnly?: never;
|
|
2076
|
+
refresh?: never;
|
|
2077
|
+
query?: never;
|
|
2078
|
+
mode?: never;
|
|
2079
|
+
since?: never;
|
|
2080
|
+
before?: never;
|
|
2081
|
+
hasAttachments?: never;
|
|
2082
|
+
uids?: never;
|
|
2083
|
+
destination?: never;
|
|
2084
|
+
labels?: never;
|
|
2085
|
+
path?: never;
|
|
2086
|
+
oldPath?: never;
|
|
2087
|
+
newPath?: never;
|
|
2088
|
+
folders?: never;
|
|
2089
|
+
bodies?: never;
|
|
2090
|
+
};
|
|
2091
|
+
};
|
|
2092
|
+
handler(ctx: EmailToolContext, input: {
|
|
2093
|
+
action: "send";
|
|
2094
|
+
input: ComposeInput;
|
|
2095
|
+
} | {
|
|
2096
|
+
action: "reply";
|
|
2097
|
+
folder: string;
|
|
2098
|
+
uid: number;
|
|
2099
|
+
input: ReplyInput;
|
|
2100
|
+
} | {
|
|
2101
|
+
action: "forward";
|
|
2102
|
+
folder: string;
|
|
2103
|
+
uid: number;
|
|
2104
|
+
input: ForwardInput;
|
|
2105
|
+
} | {
|
|
2106
|
+
action: "save_draft";
|
|
2107
|
+
input: ComposeInput;
|
|
2108
|
+
} | {
|
|
2109
|
+
action: "update_draft";
|
|
2110
|
+
uid: number;
|
|
2111
|
+
input: ComposeInput;
|
|
2112
|
+
} | {
|
|
2113
|
+
action: "send_draft";
|
|
2114
|
+
uid: number;
|
|
2115
|
+
}): Promise<{
|
|
2116
|
+
outcome: "success";
|
|
2117
|
+
summary: string;
|
|
2118
|
+
entities: {
|
|
2119
|
+
kind: "message";
|
|
2120
|
+
id: string;
|
|
2121
|
+
title: string;
|
|
2122
|
+
}[];
|
|
2123
|
+
nextSteps: string[];
|
|
2124
|
+
} | {
|
|
2125
|
+
outcome: "error";
|
|
2126
|
+
summary: string;
|
|
2127
|
+
entities: never[];
|
|
2128
|
+
nextSteps: string[];
|
|
2129
|
+
}>;
|
|
2130
|
+
} | {
|
|
2131
|
+
name: string;
|
|
2132
|
+
description: string;
|
|
2133
|
+
sideEffects: "write";
|
|
2134
|
+
inputSchema: {
|
|
2135
|
+
type: "object";
|
|
2136
|
+
required: string[];
|
|
2137
|
+
properties: {
|
|
2138
|
+
action: {
|
|
2139
|
+
type: "string";
|
|
2140
|
+
enum: string[];
|
|
2141
|
+
};
|
|
2142
|
+
folder: {
|
|
2143
|
+
type: "string";
|
|
2144
|
+
description: string;
|
|
2145
|
+
};
|
|
2146
|
+
uids: {
|
|
2147
|
+
type: "array";
|
|
2148
|
+
items: {
|
|
2149
|
+
type: "integer";
|
|
2150
|
+
};
|
|
2151
|
+
description: string;
|
|
2152
|
+
};
|
|
2153
|
+
destination: {
|
|
2154
|
+
type: "string";
|
|
2155
|
+
description: string;
|
|
2156
|
+
};
|
|
2157
|
+
labels: {
|
|
2158
|
+
type: "array";
|
|
2159
|
+
items: {
|
|
2160
|
+
type: "string";
|
|
2161
|
+
};
|
|
2162
|
+
description: string;
|
|
2163
|
+
};
|
|
2164
|
+
path: {
|
|
2165
|
+
type: "string";
|
|
2166
|
+
description: string;
|
|
2167
|
+
};
|
|
2168
|
+
oldPath: {
|
|
2169
|
+
type: "string";
|
|
2170
|
+
description: string;
|
|
2171
|
+
};
|
|
2172
|
+
newPath: {
|
|
2173
|
+
type: "string";
|
|
2174
|
+
description: string;
|
|
2175
|
+
};
|
|
2176
|
+
view?: never;
|
|
2177
|
+
uid?: never;
|
|
2178
|
+
threadId?: never;
|
|
2179
|
+
partPath?: never;
|
|
2180
|
+
limit?: never;
|
|
2181
|
+
unreadOnly?: never;
|
|
2182
|
+
refresh?: never;
|
|
2183
|
+
query?: never;
|
|
2184
|
+
mode?: never;
|
|
2185
|
+
since?: never;
|
|
2186
|
+
before?: never;
|
|
2187
|
+
hasAttachments?: never;
|
|
2188
|
+
input?: never;
|
|
2189
|
+
folders?: never;
|
|
2190
|
+
bodies?: never;
|
|
2191
|
+
};
|
|
2192
|
+
};
|
|
2193
|
+
handler(ctx: EmailToolContext, input: {
|
|
2194
|
+
action: "mark_read" | "mark_unread" | "star" | "unstar" | "mark_answered";
|
|
2195
|
+
folder: string;
|
|
2196
|
+
uids: number[];
|
|
2197
|
+
} | {
|
|
2198
|
+
action: "copy" | "move";
|
|
2199
|
+
folder: string;
|
|
2200
|
+
uids: number[];
|
|
2201
|
+
destination: string;
|
|
2202
|
+
} | {
|
|
2203
|
+
action: "archive" | "trash" | "junk";
|
|
2204
|
+
folder: string;
|
|
2205
|
+
uids: number[];
|
|
2206
|
+
} | {
|
|
2207
|
+
action: "not_junk";
|
|
2208
|
+
folder: string;
|
|
2209
|
+
uids: number[];
|
|
2210
|
+
destination?: string;
|
|
2211
|
+
} | {
|
|
2212
|
+
action: "set_labels" | "add_labels" | "remove_labels";
|
|
2213
|
+
folder: string;
|
|
2214
|
+
uids: number[];
|
|
2215
|
+
labels: string[];
|
|
2216
|
+
} | {
|
|
2217
|
+
action: "create_folder";
|
|
2218
|
+
path: string;
|
|
2219
|
+
} | {
|
|
2220
|
+
action: "rename_folder";
|
|
2221
|
+
oldPath: string;
|
|
2222
|
+
newPath: string;
|
|
2223
|
+
} | {
|
|
2224
|
+
action: "delete_folder" | "subscribe_folder" | "unsubscribe_folder";
|
|
2225
|
+
path: string;
|
|
2226
|
+
}): Promise<{
|
|
2227
|
+
outcome: "success";
|
|
2228
|
+
summary: string;
|
|
2229
|
+
entities: {
|
|
2230
|
+
kind: "message";
|
|
2231
|
+
id: string;
|
|
2232
|
+
title: string;
|
|
2233
|
+
}[];
|
|
2234
|
+
nextSteps: never[];
|
|
2235
|
+
} | {
|
|
2236
|
+
outcome: "success";
|
|
2237
|
+
summary: string;
|
|
2238
|
+
entities: {
|
|
2239
|
+
kind: "mailbox";
|
|
2240
|
+
id: string;
|
|
2241
|
+
title: string;
|
|
2242
|
+
}[];
|
|
2243
|
+
nextSteps: string[];
|
|
2244
|
+
} | {
|
|
2245
|
+
outcome: "error";
|
|
2246
|
+
summary: string;
|
|
2247
|
+
entities: never[];
|
|
2248
|
+
nextSteps: string[];
|
|
2249
|
+
}>;
|
|
2250
|
+
} | {
|
|
2251
|
+
name: string;
|
|
2252
|
+
description: string;
|
|
2253
|
+
sideEffects: "external";
|
|
2254
|
+
inputSchema: {
|
|
2255
|
+
type: "object";
|
|
2256
|
+
required: string[];
|
|
2257
|
+
properties: {
|
|
2258
|
+
action: {
|
|
2259
|
+
type: "string";
|
|
2260
|
+
enum: string[];
|
|
2261
|
+
};
|
|
2262
|
+
folders: {
|
|
2263
|
+
type: "array";
|
|
2264
|
+
items: {
|
|
2265
|
+
type: "string";
|
|
2266
|
+
};
|
|
2267
|
+
description: string;
|
|
2268
|
+
};
|
|
2269
|
+
bodies: {
|
|
2270
|
+
type: "string";
|
|
2271
|
+
enum: string[];
|
|
2272
|
+
description: string;
|
|
2273
|
+
};
|
|
2274
|
+
view?: never;
|
|
2275
|
+
folder?: never;
|
|
2276
|
+
uid?: never;
|
|
2277
|
+
threadId?: never;
|
|
2278
|
+
partPath?: never;
|
|
2279
|
+
limit?: never;
|
|
2280
|
+
unreadOnly?: never;
|
|
2281
|
+
refresh?: never;
|
|
2282
|
+
query?: never;
|
|
2283
|
+
mode?: never;
|
|
2284
|
+
since?: never;
|
|
2285
|
+
before?: never;
|
|
2286
|
+
hasAttachments?: never;
|
|
2287
|
+
input?: never;
|
|
2288
|
+
uids?: never;
|
|
2289
|
+
destination?: never;
|
|
2290
|
+
labels?: never;
|
|
2291
|
+
path?: never;
|
|
2292
|
+
oldPath?: never;
|
|
2293
|
+
newPath?: never;
|
|
2294
|
+
};
|
|
2295
|
+
};
|
|
2296
|
+
handler(ctx: EmailToolContext, input: {
|
|
2297
|
+
action: "connect" | "disconnect" | "reconnect";
|
|
2298
|
+
} | {
|
|
2299
|
+
action: "sync";
|
|
2300
|
+
folders?: string[];
|
|
2301
|
+
bodies?: "none" | "missing" | "all";
|
|
2302
|
+
} | {
|
|
2303
|
+
action: "refresh_folders";
|
|
2304
|
+
} | {
|
|
2305
|
+
action: "watch";
|
|
2306
|
+
folders?: string[];
|
|
2307
|
+
}): Promise<{
|
|
2308
|
+
outcome: "success";
|
|
2309
|
+
summary: string;
|
|
2310
|
+
entities: {
|
|
2311
|
+
kind: "mailbox";
|
|
2312
|
+
id: string;
|
|
2313
|
+
title: string;
|
|
2314
|
+
}[];
|
|
2315
|
+
nextSteps: string[];
|
|
2316
|
+
} | {
|
|
2317
|
+
outcome: "error";
|
|
2318
|
+
summary: string;
|
|
2319
|
+
entities: never[];
|
|
2320
|
+
nextSteps: string[];
|
|
2321
|
+
}>;
|
|
2322
|
+
} | undefined;
|
|
2323
|
+
|
|
2324
|
+
type index$1_EmailToolContext = EmailToolContext;
|
|
2325
|
+
type index$1_EmailToolDefinition<TInput = unknown> = EmailToolDefinition<TInput>;
|
|
2326
|
+
type index$1_EmailToolResult = EmailToolResult;
|
|
2327
|
+
type index$1_JsonSchema = JsonSchema;
|
|
2328
|
+
type index$1_JsonSchemaType = JsonSchemaType;
|
|
2329
|
+
type index$1_ToolEntityKind = ToolEntityKind;
|
|
2330
|
+
type index$1_ToolEntityRef = ToolEntityRef;
|
|
2331
|
+
type index$1_ToolOutcomeKind = ToolOutcomeKind;
|
|
2332
|
+
type index$1_ToolSideEffects = ToolSideEffects;
|
|
2333
|
+
declare const index$1_emailTools: typeof emailTools;
|
|
2334
|
+
declare const index$1_getEmailToolByName: typeof getEmailToolByName;
|
|
2335
|
+
declare namespace index$1 {
|
|
2336
|
+
export { type index$1_EmailToolContext as EmailToolContext, type index$1_EmailToolDefinition as EmailToolDefinition, type index$1_EmailToolResult as EmailToolResult, type index$1_JsonSchema as JsonSchema, type index$1_JsonSchemaType as JsonSchemaType, type index$1_ToolEntityKind as ToolEntityKind, type index$1_ToolEntityRef as ToolEntityRef, type index$1_ToolOutcomeKind as ToolOutcomeKind, type index$1_ToolSideEffects as ToolSideEffects, index$1_emailTools as emailTools, index$1_getEmailToolByName as getEmailToolByName };
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
declare const DEFAULT_CONNECTION_TIMEOUT = 30000;
|
|
2340
|
+
declare const DEFAULT_SOCKET_TIMEOUT = 300000;
|
|
2341
|
+
declare const DEFAULT_KEEPALIVE_INTERVAL = 300000;
|
|
2342
|
+
declare const DEFAULT_MAX_RECONNECT_DELAY = 60000;
|
|
2343
|
+
declare const DEFAULT_MAX_RECONNECT_ATTEMPTS = 10;
|
|
2344
|
+
declare const DEFAULT_MAX_CONNECTIONS = 6;
|
|
2345
|
+
declare const DEFAULT_PIPELINING = false;
|
|
2346
|
+
declare const DEFAULT_COMPRESS = true;
|
|
2347
|
+
declare const DEFAULT_TAG_PREFIX = "A";
|
|
2348
|
+
declare const DEFAULT_BATCH_SIZE = 500;
|
|
2349
|
+
declare const DEFAULT_AUTO_EXPUNGE = false;
|
|
2350
|
+
declare const DEFAULT_SYNC_DELETED_FOLDERS = false;
|
|
2351
|
+
declare const DEFAULT_MAX_BODY_CACHE = 1000;
|
|
2352
|
+
declare const DEFAULT_MAX_ATTACHMENT_CACHE = 100;
|
|
2353
|
+
declare const DEFAULT_IDLE_TIMEOUT = 1500000;
|
|
2354
|
+
declare const DEFAULT_WATCH_FOLDERS: readonly ["INBOX"];
|
|
2355
|
+
declare const DEFAULT_MAX_NESTING_DEPTH = 50;
|
|
2356
|
+
declare const DEFAULT_MAX_MESSAGE_SIZE = 26214400;
|
|
2357
|
+
declare const DEFAULT_CHARSET = "utf-8";
|
|
2358
|
+
|
|
2359
|
+
type index_Account = Account;
|
|
2360
|
+
type index_AccountStats = AccountStats;
|
|
2361
|
+
type index_Address = Address;
|
|
2362
|
+
type index_Attachment = Attachment;
|
|
2363
|
+
type index_AttachmentMeta = AttachmentMeta;
|
|
2364
|
+
type index_AuthConfig = AuthConfig;
|
|
2365
|
+
type index_BodyPart = BodyPart;
|
|
2366
|
+
type index_ComposeAttachment = ComposeAttachment;
|
|
2367
|
+
type index_ComposeInput = ComposeInput;
|
|
2368
|
+
type index_ContinuationResponse = ContinuationResponse;
|
|
2369
|
+
declare const index_DEFAULT_AUTO_EXPUNGE: typeof DEFAULT_AUTO_EXPUNGE;
|
|
2370
|
+
declare const index_DEFAULT_BATCH_SIZE: typeof DEFAULT_BATCH_SIZE;
|
|
2371
|
+
declare const index_DEFAULT_CHARSET: typeof DEFAULT_CHARSET;
|
|
2372
|
+
declare const index_DEFAULT_COMPRESS: typeof DEFAULT_COMPRESS;
|
|
2373
|
+
declare const index_DEFAULT_CONNECTION_TIMEOUT: typeof DEFAULT_CONNECTION_TIMEOUT;
|
|
2374
|
+
declare const index_DEFAULT_IDLE_TIMEOUT: typeof DEFAULT_IDLE_TIMEOUT;
|
|
2375
|
+
declare const index_DEFAULT_KEEPALIVE_INTERVAL: typeof DEFAULT_KEEPALIVE_INTERVAL;
|
|
2376
|
+
declare const index_DEFAULT_MAX_ATTACHMENT_CACHE: typeof DEFAULT_MAX_ATTACHMENT_CACHE;
|
|
2377
|
+
declare const index_DEFAULT_MAX_BODY_CACHE: typeof DEFAULT_MAX_BODY_CACHE;
|
|
2378
|
+
declare const index_DEFAULT_MAX_CONNECTIONS: typeof DEFAULT_MAX_CONNECTIONS;
|
|
2379
|
+
declare const index_DEFAULT_MAX_MESSAGE_SIZE: typeof DEFAULT_MAX_MESSAGE_SIZE;
|
|
2380
|
+
declare const index_DEFAULT_MAX_NESTING_DEPTH: typeof DEFAULT_MAX_NESTING_DEPTH;
|
|
2381
|
+
declare const index_DEFAULT_MAX_RECONNECT_ATTEMPTS: typeof DEFAULT_MAX_RECONNECT_ATTEMPTS;
|
|
2382
|
+
declare const index_DEFAULT_MAX_RECONNECT_DELAY: typeof DEFAULT_MAX_RECONNECT_DELAY;
|
|
2383
|
+
declare const index_DEFAULT_PIPELINING: typeof DEFAULT_PIPELINING;
|
|
2384
|
+
declare const index_DEFAULT_SOCKET_TIMEOUT: typeof DEFAULT_SOCKET_TIMEOUT;
|
|
2385
|
+
declare const index_DEFAULT_SYNC_DELETED_FOLDERS: typeof DEFAULT_SYNC_DELETED_FOLDERS;
|
|
2386
|
+
declare const index_DEFAULT_TAG_PREFIX: typeof DEFAULT_TAG_PREFIX;
|
|
2387
|
+
declare const index_DEFAULT_WATCH_FOLDERS: typeof DEFAULT_WATCH_FOLDERS;
|
|
2388
|
+
type index_EmailConfig = EmailConfig;
|
|
2389
|
+
type index_EmailNetworkSurface = EmailNetworkSurface;
|
|
2390
|
+
type index_EmailReadSurface = EmailReadSurface;
|
|
2391
|
+
type index_EmailRuntimeSurface = EmailRuntimeSurface;
|
|
2392
|
+
type index_EmailWriteSurface = EmailWriteSurface;
|
|
2393
|
+
type index_FetchResult = FetchResult;
|
|
2394
|
+
type index_Folder = Folder;
|
|
2395
|
+
type index_FolderRole = FolderRole;
|
|
2396
|
+
type index_FolderStatus = FolderStatus;
|
|
2397
|
+
type index_ForwardInput = ForwardInput;
|
|
2398
|
+
type index_ImapResponse = ImapResponse;
|
|
2399
|
+
type index_ImapToken = ImapToken;
|
|
2400
|
+
type index_InsertMessageInput = InsertMessageInput;
|
|
2401
|
+
type index_LocalSearchOptions = LocalSearchOptions;
|
|
2402
|
+
type index_Message = Message;
|
|
2403
|
+
type index_MessageBody = MessageBody;
|
|
2404
|
+
type index_MessageDetail = MessageDetail;
|
|
2405
|
+
type index_MessageListOptions = MessageListOptions;
|
|
2406
|
+
type index_NegotiatedExtensions = NegotiatedExtensions;
|
|
2407
|
+
type index_ParsedEnvelope = ParsedEnvelope;
|
|
2408
|
+
type index_ReplyInput = ReplyInput;
|
|
2409
|
+
type index_ResponseCode = ResponseCode;
|
|
2410
|
+
type index_SearchQuery = SearchQuery;
|
|
2411
|
+
type index_SelectedFolder = SelectedFolder;
|
|
2412
|
+
type index_SmtpErrorCategory = SmtpErrorCategory;
|
|
2413
|
+
type index_SmtpResponse = SmtpResponse;
|
|
2414
|
+
type index_SyncFolderResult = SyncFolderResult;
|
|
2415
|
+
type index_SyncOptions = SyncOptions;
|
|
2416
|
+
type index_SyncResult = SyncResult;
|
|
2417
|
+
type index_TaggedResponse = TaggedResponse;
|
|
2418
|
+
type index_Thread = Thread;
|
|
2419
|
+
type index_ThreadListOptions = ThreadListOptions;
|
|
2420
|
+
type index_ThreadMessage = ThreadMessage;
|
|
2421
|
+
type index_TokenType = TokenType;
|
|
2422
|
+
type index_UntaggedResponse = UntaggedResponse;
|
|
2423
|
+
type index_WatchEvent = WatchEvent;
|
|
2424
|
+
type index_WatchOptions = WatchOptions;
|
|
2425
|
+
declare namespace index {
|
|
2426
|
+
export { type index_Account as Account, type index_AccountStats as AccountStats, type index_Address as Address, type index_Attachment as Attachment, type index_AttachmentMeta as AttachmentMeta, type index_AuthConfig as AuthConfig, type index_BodyPart as BodyPart, type index_ComposeAttachment as ComposeAttachment, type index_ComposeInput as ComposeInput, type index_ContinuationResponse as ContinuationResponse, index_DEFAULT_AUTO_EXPUNGE as DEFAULT_AUTO_EXPUNGE, index_DEFAULT_BATCH_SIZE as DEFAULT_BATCH_SIZE, index_DEFAULT_CHARSET as DEFAULT_CHARSET, index_DEFAULT_COMPRESS as DEFAULT_COMPRESS, index_DEFAULT_CONNECTION_TIMEOUT as DEFAULT_CONNECTION_TIMEOUT, index_DEFAULT_IDLE_TIMEOUT as DEFAULT_IDLE_TIMEOUT, index_DEFAULT_KEEPALIVE_INTERVAL as DEFAULT_KEEPALIVE_INTERVAL, index_DEFAULT_MAX_ATTACHMENT_CACHE as DEFAULT_MAX_ATTACHMENT_CACHE, index_DEFAULT_MAX_BODY_CACHE as DEFAULT_MAX_BODY_CACHE, index_DEFAULT_MAX_CONNECTIONS as DEFAULT_MAX_CONNECTIONS, index_DEFAULT_MAX_MESSAGE_SIZE as DEFAULT_MAX_MESSAGE_SIZE, index_DEFAULT_MAX_NESTING_DEPTH as DEFAULT_MAX_NESTING_DEPTH, index_DEFAULT_MAX_RECONNECT_ATTEMPTS as DEFAULT_MAX_RECONNECT_ATTEMPTS, index_DEFAULT_MAX_RECONNECT_DELAY as DEFAULT_MAX_RECONNECT_DELAY, index_DEFAULT_PIPELINING as DEFAULT_PIPELINING, index_DEFAULT_SOCKET_TIMEOUT as DEFAULT_SOCKET_TIMEOUT, index_DEFAULT_SYNC_DELETED_FOLDERS as DEFAULT_SYNC_DELETED_FOLDERS, index_DEFAULT_TAG_PREFIX as DEFAULT_TAG_PREFIX, index_DEFAULT_WATCH_FOLDERS as DEFAULT_WATCH_FOLDERS, type index_EmailConfig as EmailConfig, type index_EmailNetworkSurface as EmailNetworkSurface, type index_EmailReadSurface as EmailReadSurface, type index_EmailRuntimeSurface as EmailRuntimeSurface, type index_EmailWriteSurface as EmailWriteSurface, type index_FetchResult as FetchResult, type index_Folder as Folder, type index_FolderRole as FolderRole, type index_FolderStatus as FolderStatus, type index_ForwardInput as ForwardInput, type index_ImapResponse as ImapResponse, type index_ImapToken as ImapToken, type index_InsertMessageInput as InsertMessageInput, type index_LocalSearchOptions as LocalSearchOptions, type index_Message as Message, type index_MessageBody as MessageBody, type index_MessageDetail as MessageDetail, type index_MessageListOptions as MessageListOptions, type index_NegotiatedExtensions as NegotiatedExtensions, type index_ParsedEnvelope as ParsedEnvelope, type index_ReplyInput as ReplyInput, type index_ResponseCode as ResponseCode, type index_SearchQuery as SearchQuery, type index_SelectedFolder as SelectedFolder, type index_SmtpErrorCategory as SmtpErrorCategory, type index_SmtpResponse as SmtpResponse, type index_SyncFolderResult as SyncFolderResult, type index_SyncOptions as SyncOptions, type index_SyncResult as SyncResult, type index_TaggedResponse as TaggedResponse, type index_Thread as Thread, type index_ThreadListOptions as ThreadListOptions, type index_ThreadMessage as ThreadMessage, type index_TokenType as TokenType, type index_UntaggedResponse as UntaggedResponse, type index_WatchEvent as WatchEvent, type index_WatchOptions as WatchOptions };
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
type CreateWriteSurfaceOptions = {
|
|
2430
|
+
config: EmailConfig;
|
|
2431
|
+
accountId: number;
|
|
2432
|
+
session?: ImapSession | null;
|
|
2433
|
+
};
|
|
2434
|
+
declare function createWriteSurface(db: EmailDb, options: CreateWriteSurfaceOptions): EmailWriteSurface;
|
|
2435
|
+
|
|
2436
|
+
type write_CreateWriteSurfaceOptions = CreateWriteSurfaceOptions;
|
|
2437
|
+
declare const write_createWriteSurface: typeof createWriteSurface;
|
|
2438
|
+
declare namespace write {
|
|
2439
|
+
export { type write_CreateWriteSurfaceOptions as CreateWriteSurfaceOptions, write_createWriteSurface as createWriteSurface };
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
export { type Account, type AccountStats, type Address, type Attachment, type AttachmentMeta, type AuthConfig, type BodyPart, type ComposeAttachment, type ComposeInput, type ContinuationResponse, DEFAULT_AUTO_EXPUNGE, DEFAULT_BATCH_SIZE, DEFAULT_CHARSET, DEFAULT_COMPRESS, DEFAULT_CONNECTION_TIMEOUT, DEFAULT_IDLE_TIMEOUT, DEFAULT_KEEPALIVE_INTERVAL, DEFAULT_MAX_ATTACHMENT_CACHE, DEFAULT_MAX_BODY_CACHE, DEFAULT_MAX_CONNECTIONS, DEFAULT_MAX_MESSAGE_SIZE, DEFAULT_MAX_NESTING_DEPTH, DEFAULT_MAX_RECONNECT_ATTEMPTS, DEFAULT_MAX_RECONNECT_DELAY, DEFAULT_PIPELINING, DEFAULT_SOCKET_TIMEOUT, DEFAULT_SYNC_DELETED_FOLDERS, DEFAULT_TAG_PREFIX, DEFAULT_WATCH_FOLDERS, EmailAuthError, type EmailConfig, EmailConnectionError, type EmailDb, EmailEnvelopeRejectedError, EmailError, type EmailErrorCode, EmailInvariantError, type EmailNetworkSurface, EmailNotFoundError, EmailProtocolError, EmailQuotaError, type EmailReadSurface, type EmailRuntimeSurface, type EmailSkill, type EmailSkillRegistry, type EmailSoul, type EmailSoulTrait, EmailStateError, EmailTimeoutError, type EmailToolContext, type EmailToolDefinition, type EmailToolResult, EmailUnsupportedError, EmailValidationError, type EmailWriteSurface, type FetchResult, type Folder, type FolderRole, type FolderStatus, type ForwardInput, type ImapResponse, type ImapToken, type InsertMessageInput, type JsonSchema, type JsonSchemaType, type LocalSearchOptions, Mailbox, type Message, type MessageBody, type MessageDetail, type MessageListOptions, type NegotiatedExtensions, type ParsedEnvelope, type ReplyInput, type ResponseCode, type SearchQuery, type SelectedFolder, type SmtpErrorCategory, type SmtpResponse, type SyncFolderResult, type SyncOptions, type SyncResult, type TaggedResponse, type Thread, type ThreadListOptions, type ThreadMessage, type TokenType, type ToolEntityKind, type ToolEntityRef, type ToolOutcomeKind, type ToolSideEffects, type UntaggedResponse, type WatchEvent, type WatchOptions, attachmentWorkflowSkill, composeAndSendSkill, connectAndSyncSkill, defineEmailSkill, emailSkills, emailSoul, emailSoulEssence, emailSoulTraits, emailTools, errors, getEmailSkillByName, getEmailToolByName, index$8 as imap, initSchema, isEmailError, isRetriable, index$7 as mime, network, organizeBulkSkill, read, readAndReplySkill, recoverFromDisruptionSkill, renderEmailSoulPromptFoundation, runtime, index$6 as schema, searchAndActSkill, index$5 as skills, index$4 as smtp, soul, index$3 as store, index$2 as sync, index$1 as tools, triageInboxSkill, index as types, write };
|