agentmail-toolkit 0.3.0 → 0.4.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/dist/ai-sdk.cjs +168 -26
- package/dist/ai-sdk.cjs.map +1 -1
- package/dist/ai-sdk.js +1 -1
- package/dist/chunk-2WFL2XH4.js +596 -0
- package/dist/chunk-2WFL2XH4.js.map +1 -0
- package/dist/clawdbot.cjs +168 -26
- package/dist/clawdbot.cjs.map +1 -1
- package/dist/clawdbot.js +1 -1
- package/dist/index.cjs +168 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/langchain.cjs +168 -26
- package/dist/langchain.cjs.map +1 -1
- package/dist/langchain.js +1 -1
- package/dist/langchain.js.map +1 -1
- package/dist/mcp.cjs +170 -27
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.js +3 -2
- package/dist/mcp.js.map +1 -1
- package/package.json +89 -88
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
// src/util.ts
|
|
2
|
+
import { getDocumentProxy, extractText } from "unpdf";
|
|
3
|
+
import JSZip from "jszip";
|
|
4
|
+
var safeFunc = async (func, client, args) => {
|
|
5
|
+
try {
|
|
6
|
+
return { isError: false, result: await func(client, args) };
|
|
7
|
+
} catch (error) {
|
|
8
|
+
if (error instanceof Error) return { isError: true, result: error.message };
|
|
9
|
+
else return { isError: true, result: "Unknown error" };
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
function detectFileType(bytes) {
|
|
13
|
+
if (bytes[0] === 37 && bytes[1] === 80 && bytes[2] === 68 && bytes[3] === 70) {
|
|
14
|
+
return "application/pdf";
|
|
15
|
+
}
|
|
16
|
+
if (bytes[0] === 80 && bytes[1] === 75 && bytes[2] === 3 && bytes[3] === 4) {
|
|
17
|
+
return "application/zip";
|
|
18
|
+
}
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
async function extractPdfText(bytes) {
|
|
22
|
+
const pdf = await getDocumentProxy(bytes);
|
|
23
|
+
const { text } = await extractText(pdf);
|
|
24
|
+
return Array.isArray(text) ? text.join("\n") : text;
|
|
25
|
+
}
|
|
26
|
+
async function extractDocxText(bytes) {
|
|
27
|
+
const zip = await JSZip.loadAsync(bytes);
|
|
28
|
+
const documentXml = await zip.file("word/document.xml")?.async("string");
|
|
29
|
+
if (!documentXml) return void 0;
|
|
30
|
+
return documentXml.replace(/<w:p[^>]*>/g, "\n").replace(/<[^>]+>/g, "").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'").replace(/\n{3,}/g, "\n\n").trim();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/toolkit.ts
|
|
34
|
+
import { AgentMailClient } from "agentmail";
|
|
35
|
+
|
|
36
|
+
// src/schemas.ts
|
|
37
|
+
import { z } from "zod";
|
|
38
|
+
var InboxIdSchema = z.string().describe("ID of inbox");
|
|
39
|
+
var ThreadIdSchema = z.string().describe("ID of thread");
|
|
40
|
+
var MessageIdSchema = z.string().describe("ID of message");
|
|
41
|
+
var AttachmentIdSchema = z.string().describe("ID of attachment");
|
|
42
|
+
var DraftIdSchema = z.string().describe("ID of draft");
|
|
43
|
+
var ListItemsParams = z.object({
|
|
44
|
+
limit: z.number().optional().default(10).describe("Max number of items to return"),
|
|
45
|
+
pageToken: z.string().optional().describe("Page token for pagination")
|
|
46
|
+
});
|
|
47
|
+
var GetInboxParams = z.object({
|
|
48
|
+
inboxId: InboxIdSchema
|
|
49
|
+
});
|
|
50
|
+
var CreateInboxParams = z.object({
|
|
51
|
+
username: z.string().optional().describe("Username"),
|
|
52
|
+
domain: z.string().optional().describe("Domain"),
|
|
53
|
+
displayName: z.string().optional().describe("Display name"),
|
|
54
|
+
clientId: z.string().optional().describe("Client-provided ID for idempotent creation"),
|
|
55
|
+
metadata: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional().describe("Custom metadata key-value pairs to attach to the inbox")
|
|
56
|
+
});
|
|
57
|
+
var UpdateInboxParams = z.object({
|
|
58
|
+
inboxId: InboxIdSchema,
|
|
59
|
+
displayName: z.string().optional().describe("Display name"),
|
|
60
|
+
metadata: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])).nullable().optional().describe("Metadata to merge into existing metadata. Set a key to null to remove it, or the whole field to null to clear all metadata")
|
|
61
|
+
});
|
|
62
|
+
var ListInboxItemsParams = ListItemsParams.extend({
|
|
63
|
+
inboxId: InboxIdSchema,
|
|
64
|
+
labels: z.array(z.string()).optional().describe("Labels to filter items by"),
|
|
65
|
+
before: z.string().pipe(z.coerce.date()).optional().describe("Filter items before datetime"),
|
|
66
|
+
after: z.string().pipe(z.coerce.date()).optional().describe("Filter items after datetime"),
|
|
67
|
+
ascending: z.boolean().optional().describe("Sort by oldest first instead of most recent first")
|
|
68
|
+
});
|
|
69
|
+
var ListThreadsParams = ListInboxItemsParams.extend({
|
|
70
|
+
senders: z.array(z.string()).optional().describe("Filter threads by senders (substring match; all values must match)"),
|
|
71
|
+
recipients: z.array(z.string()).optional().describe("Filter threads by recipients (substring match; all values must match)"),
|
|
72
|
+
subject: z.array(z.string()).optional().describe("Filter threads by subject (substring match; all values must match)"),
|
|
73
|
+
includeSpam: z.boolean().optional().describe("Include threads in spam"),
|
|
74
|
+
includeTrash: z.boolean().optional().describe("Include threads in trash")
|
|
75
|
+
});
|
|
76
|
+
var SearchInboxItemsParams = ListItemsParams.extend({
|
|
77
|
+
inboxId: InboxIdSchema,
|
|
78
|
+
q: z.string().describe("Full-text search query"),
|
|
79
|
+
before: z.string().pipe(z.coerce.date()).optional().describe("Filter items before datetime"),
|
|
80
|
+
after: z.string().pipe(z.coerce.date()).optional().describe("Filter items after datetime")
|
|
81
|
+
});
|
|
82
|
+
var GetThreadParams = z.object({
|
|
83
|
+
inboxId: InboxIdSchema,
|
|
84
|
+
threadId: ThreadIdSchema
|
|
85
|
+
});
|
|
86
|
+
var UpdateThreadParams = GetThreadParams.extend({
|
|
87
|
+
addLabels: z.array(z.string()).optional().describe("Labels to add"),
|
|
88
|
+
removeLabels: z.array(z.string()).optional().describe("Labels to remove")
|
|
89
|
+
});
|
|
90
|
+
var GetAttachmentParams = z.object({
|
|
91
|
+
inboxId: InboxIdSchema,
|
|
92
|
+
threadId: ThreadIdSchema,
|
|
93
|
+
attachmentId: AttachmentIdSchema
|
|
94
|
+
});
|
|
95
|
+
var AttachmentSchema = z.object({
|
|
96
|
+
filename: z.string().optional().describe("Filename"),
|
|
97
|
+
content_id: z.string().optional().describe("Content ID for inline attachments"),
|
|
98
|
+
content: z.string().optional().describe("Base64 encoded content"),
|
|
99
|
+
url: z.url().optional().describe("URL")
|
|
100
|
+
});
|
|
101
|
+
var BaseMessageParams = z.object({
|
|
102
|
+
inboxId: InboxIdSchema,
|
|
103
|
+
text: z.string().optional().describe("Plain text body"),
|
|
104
|
+
html: z.string().optional().describe("HTML body"),
|
|
105
|
+
labels: z.array(z.string()).optional().describe("Labels"),
|
|
106
|
+
attachments: z.array(AttachmentSchema).optional().describe("Attachments")
|
|
107
|
+
});
|
|
108
|
+
var SendMessageParams = BaseMessageParams.extend({
|
|
109
|
+
to: z.array(z.string()).describe("Recipients"),
|
|
110
|
+
cc: z.array(z.string()).optional().describe("CC recipients"),
|
|
111
|
+
bcc: z.array(z.string()).optional().describe("BCC recipients"),
|
|
112
|
+
subject: z.string().optional().describe("Subject"),
|
|
113
|
+
replyTo: z.array(z.string()).optional().describe("Reply-to addresses")
|
|
114
|
+
});
|
|
115
|
+
var ReplyToMessageParams = BaseMessageParams.extend({
|
|
116
|
+
messageId: MessageIdSchema,
|
|
117
|
+
replyAll: z.boolean().optional().describe("Reply to all recipients"),
|
|
118
|
+
to: z.array(z.string()).optional().describe("Override reply recipients"),
|
|
119
|
+
cc: z.array(z.string()).optional().describe("Override CC recipients"),
|
|
120
|
+
bcc: z.array(z.string()).optional().describe("Override BCC recipients"),
|
|
121
|
+
replyTo: z.array(z.string()).optional().describe("Reply-to addresses")
|
|
122
|
+
});
|
|
123
|
+
var ForwardMessageParams = SendMessageParams.extend({
|
|
124
|
+
messageId: MessageIdSchema
|
|
125
|
+
});
|
|
126
|
+
var UpdateMessageParams = z.object({
|
|
127
|
+
inboxId: InboxIdSchema,
|
|
128
|
+
messageId: MessageIdSchema,
|
|
129
|
+
addLabels: z.array(z.string()).optional().describe("Labels to add"),
|
|
130
|
+
removeLabels: z.array(z.string()).optional().describe("Labels to remove")
|
|
131
|
+
});
|
|
132
|
+
var ListMessagesParams = ListInboxItemsParams.extend({
|
|
133
|
+
from: z.array(z.string()).optional().describe("Filter messages by sender (substring match; all values must match)"),
|
|
134
|
+
to: z.array(z.string()).optional().describe("Filter messages by recipients (substring match; all values must match)"),
|
|
135
|
+
subject: z.array(z.string()).optional().describe("Filter messages by subject (substring match; all values must match)"),
|
|
136
|
+
includeSpam: z.boolean().optional().describe("Include messages in spam"),
|
|
137
|
+
includeTrash: z.boolean().optional().describe("Include messages in trash")
|
|
138
|
+
});
|
|
139
|
+
var CreateDraftParams = BaseMessageParams.extend({
|
|
140
|
+
to: z.array(z.string()).optional().describe("Recipients"),
|
|
141
|
+
cc: z.array(z.string()).optional().describe("CC recipients"),
|
|
142
|
+
bcc: z.array(z.string()).optional().describe("BCC recipients"),
|
|
143
|
+
subject: z.string().optional().describe("Subject"),
|
|
144
|
+
replyTo: z.array(z.string()).optional().describe("Reply-to addresses"),
|
|
145
|
+
inReplyTo: z.string().optional().describe("Message ID this draft is replying to"),
|
|
146
|
+
sendAt: z.string().pipe(z.coerce.date()).optional().describe("ISO 8601 datetime to schedule sending (e.g. 2026-04-01T09:00:00Z)"),
|
|
147
|
+
clientId: z.string().optional().describe("Client-provided ID for idempotent creation")
|
|
148
|
+
});
|
|
149
|
+
var ListDraftsParams = ListInboxItemsParams;
|
|
150
|
+
var GetDraftParams = z.object({
|
|
151
|
+
inboxId: InboxIdSchema,
|
|
152
|
+
draftId: DraftIdSchema
|
|
153
|
+
});
|
|
154
|
+
var UpdateDraftParams = z.object({
|
|
155
|
+
inboxId: InboxIdSchema,
|
|
156
|
+
draftId: DraftIdSchema,
|
|
157
|
+
to: z.array(z.string()).optional().describe("Recipients"),
|
|
158
|
+
cc: z.array(z.string()).optional().describe("CC recipients"),
|
|
159
|
+
bcc: z.array(z.string()).optional().describe("BCC recipients"),
|
|
160
|
+
subject: z.string().optional().describe("Subject"),
|
|
161
|
+
text: z.string().optional().describe("Plain text body"),
|
|
162
|
+
html: z.string().optional().describe("HTML body"),
|
|
163
|
+
replyTo: z.array(z.string()).optional().describe("Reply-to addresses"),
|
|
164
|
+
sendAt: z.string().pipe(z.coerce.date()).optional().describe("ISO 8601 datetime to reschedule sending")
|
|
165
|
+
});
|
|
166
|
+
var SendDraftParams = z.object({
|
|
167
|
+
inboxId: InboxIdSchema,
|
|
168
|
+
draftId: DraftIdSchema
|
|
169
|
+
});
|
|
170
|
+
var DeleteDraftParams = z.object({
|
|
171
|
+
inboxId: InboxIdSchema,
|
|
172
|
+
draftId: DraftIdSchema
|
|
173
|
+
});
|
|
174
|
+
var AuthMeParams = z.object({});
|
|
175
|
+
|
|
176
|
+
// src/functions.ts
|
|
177
|
+
async function listInboxes(client, args) {
|
|
178
|
+
return client.inboxes.list(args);
|
|
179
|
+
}
|
|
180
|
+
async function getInbox(client, args) {
|
|
181
|
+
const { inboxId, ...options } = args;
|
|
182
|
+
return client.inboxes.get(inboxId, options);
|
|
183
|
+
}
|
|
184
|
+
async function createInbox(client, args) {
|
|
185
|
+
return client.inboxes.create(args);
|
|
186
|
+
}
|
|
187
|
+
async function updateInbox(client, args) {
|
|
188
|
+
const { inboxId, ...options } = args;
|
|
189
|
+
return client.inboxes.update(inboxId, options);
|
|
190
|
+
}
|
|
191
|
+
async function deleteInbox(client, args) {
|
|
192
|
+
const { inboxId } = args;
|
|
193
|
+
return client.inboxes.delete(inboxId);
|
|
194
|
+
}
|
|
195
|
+
async function listThreads(client, args) {
|
|
196
|
+
const { inboxId, ...options } = args;
|
|
197
|
+
return client.inboxes.threads.list(inboxId, options);
|
|
198
|
+
}
|
|
199
|
+
async function searchThreads(client, args) {
|
|
200
|
+
const { inboxId, q, ...options } = args;
|
|
201
|
+
return client.inboxes.threads.search(inboxId, { q, ...options });
|
|
202
|
+
}
|
|
203
|
+
async function getThread(client, args) {
|
|
204
|
+
const { inboxId, threadId, ...options } = args;
|
|
205
|
+
return client.inboxes.threads.get(inboxId, threadId, options);
|
|
206
|
+
}
|
|
207
|
+
async function updateThread(client, args) {
|
|
208
|
+
const { inboxId, threadId, ...options } = args;
|
|
209
|
+
return client.inboxes.threads.update(inboxId, threadId, options);
|
|
210
|
+
}
|
|
211
|
+
async function deleteThread(client, args) {
|
|
212
|
+
const { inboxId, threadId } = args;
|
|
213
|
+
return client.inboxes.threads.delete(inboxId, threadId);
|
|
214
|
+
}
|
|
215
|
+
async function getAttachment(client, args) {
|
|
216
|
+
const { inboxId, threadId, attachmentId } = args;
|
|
217
|
+
const attachment = await client.inboxes.threads.getAttachment(inboxId, threadId, attachmentId);
|
|
218
|
+
try {
|
|
219
|
+
const response = await fetch(attachment.downloadUrl);
|
|
220
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
221
|
+
const fileBytes = new Uint8Array(arrayBuffer);
|
|
222
|
+
const detectedType = detectFileType(fileBytes);
|
|
223
|
+
if (detectedType === "application/pdf") {
|
|
224
|
+
return { ...attachment, text: await extractPdfText(fileBytes) };
|
|
225
|
+
} else if (detectedType === "application/zip") {
|
|
226
|
+
return { ...attachment, text: await extractDocxText(fileBytes) };
|
|
227
|
+
}
|
|
228
|
+
} catch {
|
|
229
|
+
}
|
|
230
|
+
return attachment;
|
|
231
|
+
}
|
|
232
|
+
async function listMessages(client, args) {
|
|
233
|
+
const { inboxId, ...options } = args;
|
|
234
|
+
return client.inboxes.messages.list(inboxId, options);
|
|
235
|
+
}
|
|
236
|
+
async function searchMessages(client, args) {
|
|
237
|
+
const { inboxId, q, ...options } = args;
|
|
238
|
+
return client.inboxes.messages.search(inboxId, { q, ...options });
|
|
239
|
+
}
|
|
240
|
+
async function sendMessage(client, args) {
|
|
241
|
+
const { inboxId, ...options } = args;
|
|
242
|
+
return client.inboxes.messages.send(inboxId, options);
|
|
243
|
+
}
|
|
244
|
+
async function replyToMessage(client, args) {
|
|
245
|
+
const { inboxId, messageId, ...options } = args;
|
|
246
|
+
return client.inboxes.messages.reply(inboxId, messageId, options);
|
|
247
|
+
}
|
|
248
|
+
async function forwardMessage(client, args) {
|
|
249
|
+
const { inboxId, messageId, ...options } = args;
|
|
250
|
+
return client.inboxes.messages.forward(inboxId, messageId, options);
|
|
251
|
+
}
|
|
252
|
+
async function updateMessage(client, args) {
|
|
253
|
+
const { inboxId, messageId, ...options } = args;
|
|
254
|
+
return client.inboxes.messages.update(inboxId, messageId, options);
|
|
255
|
+
}
|
|
256
|
+
async function createDraft(client, args) {
|
|
257
|
+
const { inboxId, ...options } = args;
|
|
258
|
+
return client.inboxes.drafts.create(inboxId, options);
|
|
259
|
+
}
|
|
260
|
+
async function listDrafts(client, args) {
|
|
261
|
+
const { inboxId, ...options } = args;
|
|
262
|
+
return client.inboxes.drafts.list(inboxId, options);
|
|
263
|
+
}
|
|
264
|
+
async function getDraft(client, args) {
|
|
265
|
+
const { inboxId, draftId } = args;
|
|
266
|
+
return client.inboxes.drafts.get(inboxId, draftId);
|
|
267
|
+
}
|
|
268
|
+
async function updateDraft(client, args) {
|
|
269
|
+
const { inboxId, draftId, ...options } = args;
|
|
270
|
+
return client.inboxes.drafts.update(inboxId, draftId, options);
|
|
271
|
+
}
|
|
272
|
+
async function sendDraft(client, args) {
|
|
273
|
+
const { inboxId, draftId } = args;
|
|
274
|
+
return client.inboxes.drafts.send(inboxId, draftId, {});
|
|
275
|
+
}
|
|
276
|
+
async function deleteDraft(client, args) {
|
|
277
|
+
const { inboxId, draftId } = args;
|
|
278
|
+
return client.inboxes.drafts.delete(inboxId, draftId);
|
|
279
|
+
}
|
|
280
|
+
async function authMe(client) {
|
|
281
|
+
return client.auth.me();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// src/tools.ts
|
|
285
|
+
var tools = [
|
|
286
|
+
{
|
|
287
|
+
name: "list_inboxes",
|
|
288
|
+
description: "List email inboxes, paginated.",
|
|
289
|
+
paramsSchema: ListItemsParams,
|
|
290
|
+
func: listInboxes,
|
|
291
|
+
annotations: {
|
|
292
|
+
readOnlyHint: true,
|
|
293
|
+
openWorldHint: false
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
name: "get_inbox",
|
|
298
|
+
description: "Get an inbox by ID.",
|
|
299
|
+
paramsSchema: GetInboxParams,
|
|
300
|
+
func: getInbox,
|
|
301
|
+
annotations: {
|
|
302
|
+
readOnlyHint: true,
|
|
303
|
+
openWorldHint: false
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
name: "create_inbox",
|
|
308
|
+
description: "Create a new email inbox. Optionally specify username, domain, display name, and metadata.",
|
|
309
|
+
paramsSchema: CreateInboxParams,
|
|
310
|
+
func: createInbox,
|
|
311
|
+
annotations: {
|
|
312
|
+
readOnlyHint: false,
|
|
313
|
+
destructiveHint: false,
|
|
314
|
+
idempotentHint: false,
|
|
315
|
+
openWorldHint: false
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: "update_inbox",
|
|
320
|
+
description: "Update an inbox's display name or metadata. Metadata keys are merged; set a key to null to remove it, or set metadata to null to clear all.",
|
|
321
|
+
paramsSchema: UpdateInboxParams,
|
|
322
|
+
func: updateInbox,
|
|
323
|
+
annotations: {
|
|
324
|
+
readOnlyHint: false,
|
|
325
|
+
destructiveHint: true,
|
|
326
|
+
idempotentHint: true,
|
|
327
|
+
openWorldHint: false
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
name: "delete_inbox",
|
|
332
|
+
description: "Delete an inbox by ID.",
|
|
333
|
+
paramsSchema: GetInboxParams,
|
|
334
|
+
func: deleteInbox,
|
|
335
|
+
annotations: {
|
|
336
|
+
readOnlyHint: false,
|
|
337
|
+
destructiveHint: true,
|
|
338
|
+
idempotentHint: true,
|
|
339
|
+
openWorldHint: false
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: "list_threads",
|
|
344
|
+
description: "List email threads in an inbox. Filter by labels, sender, recipient, subject, or before/after datetime, paginated.",
|
|
345
|
+
paramsSchema: ListThreadsParams,
|
|
346
|
+
func: listThreads,
|
|
347
|
+
annotations: {
|
|
348
|
+
readOnlyHint: true,
|
|
349
|
+
openWorldHint: true
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
name: "search_threads",
|
|
354
|
+
description: "Search threads in an inbox with a full-text query, ranked by relevance. Matches senders, recipients, subject, and message body. Spam and trash are excluded.",
|
|
355
|
+
paramsSchema: SearchInboxItemsParams,
|
|
356
|
+
func: searchThreads,
|
|
357
|
+
annotations: {
|
|
358
|
+
readOnlyHint: true,
|
|
359
|
+
openWorldHint: true
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: "get_thread",
|
|
364
|
+
description: "Get a thread by ID, including its messages.",
|
|
365
|
+
paramsSchema: GetThreadParams,
|
|
366
|
+
func: getThread,
|
|
367
|
+
annotations: {
|
|
368
|
+
readOnlyHint: true,
|
|
369
|
+
openWorldHint: true
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
name: "get_attachment",
|
|
374
|
+
description: "Get an attachment from a thread. Returns metadata and a download URL, plus extracted text for PDF and DOCX files.",
|
|
375
|
+
paramsSchema: GetAttachmentParams,
|
|
376
|
+
func: getAttachment,
|
|
377
|
+
annotations: {
|
|
378
|
+
readOnlyHint: true,
|
|
379
|
+
openWorldHint: true
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: "update_thread",
|
|
384
|
+
description: "Update a thread's labels (add or remove). System labels cannot be modified.",
|
|
385
|
+
paramsSchema: UpdateThreadParams,
|
|
386
|
+
func: updateThread,
|
|
387
|
+
annotations: {
|
|
388
|
+
readOnlyHint: false,
|
|
389
|
+
destructiveHint: true,
|
|
390
|
+
idempotentHint: true,
|
|
391
|
+
openWorldHint: false
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "delete_thread",
|
|
396
|
+
description: "Delete a thread from an inbox.",
|
|
397
|
+
paramsSchema: GetThreadParams,
|
|
398
|
+
func: deleteThread,
|
|
399
|
+
annotations: {
|
|
400
|
+
readOnlyHint: false,
|
|
401
|
+
destructiveHint: true,
|
|
402
|
+
idempotentHint: false,
|
|
403
|
+
openWorldHint: false
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
name: "list_messages",
|
|
408
|
+
description: "List messages in an inbox. Filter by labels, sender, recipient, subject, or before/after datetime, paginated.",
|
|
409
|
+
paramsSchema: ListMessagesParams,
|
|
410
|
+
func: listMessages,
|
|
411
|
+
annotations: {
|
|
412
|
+
readOnlyHint: true,
|
|
413
|
+
openWorldHint: true
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
name: "search_messages",
|
|
418
|
+
description: "Search messages in an inbox with a full-text query, ranked by relevance. Matches sender, recipients, subject, and message body. Spam and trash are excluded.",
|
|
419
|
+
paramsSchema: SearchInboxItemsParams,
|
|
420
|
+
func: searchMessages,
|
|
421
|
+
annotations: {
|
|
422
|
+
readOnlyHint: true,
|
|
423
|
+
openWorldHint: true
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
name: "send_message",
|
|
428
|
+
description: "Send an email from an inbox to one or more recipients.",
|
|
429
|
+
paramsSchema: SendMessageParams,
|
|
430
|
+
func: sendMessage,
|
|
431
|
+
annotations: {
|
|
432
|
+
readOnlyHint: false,
|
|
433
|
+
destructiveHint: true,
|
|
434
|
+
idempotentHint: false,
|
|
435
|
+
openWorldHint: true
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
name: "reply_to_message",
|
|
440
|
+
description: "Reply to a message in its thread. Set replyAll to include all original recipients.",
|
|
441
|
+
paramsSchema: ReplyToMessageParams,
|
|
442
|
+
func: replyToMessage,
|
|
443
|
+
annotations: {
|
|
444
|
+
readOnlyHint: false,
|
|
445
|
+
destructiveHint: true,
|
|
446
|
+
idempotentHint: false,
|
|
447
|
+
openWorldHint: true
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
name: "forward_message",
|
|
452
|
+
description: "Forward a message to new recipients.",
|
|
453
|
+
paramsSchema: ForwardMessageParams,
|
|
454
|
+
func: forwardMessage,
|
|
455
|
+
annotations: {
|
|
456
|
+
readOnlyHint: false,
|
|
457
|
+
destructiveHint: true,
|
|
458
|
+
idempotentHint: false,
|
|
459
|
+
openWorldHint: true
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
name: "update_message",
|
|
464
|
+
description: "Update a message's labels (add or remove).",
|
|
465
|
+
paramsSchema: UpdateMessageParams,
|
|
466
|
+
func: updateMessage,
|
|
467
|
+
annotations: {
|
|
468
|
+
readOnlyHint: false,
|
|
469
|
+
destructiveHint: true,
|
|
470
|
+
idempotentHint: true,
|
|
471
|
+
openWorldHint: false
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
name: "create_draft",
|
|
476
|
+
description: "Create a draft email. Use sendAt (ISO 8601 datetime) to schedule it for later sending.",
|
|
477
|
+
paramsSchema: CreateDraftParams,
|
|
478
|
+
func: createDraft,
|
|
479
|
+
annotations: {
|
|
480
|
+
readOnlyHint: false,
|
|
481
|
+
destructiveHint: false,
|
|
482
|
+
idempotentHint: false,
|
|
483
|
+
openWorldHint: false
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
name: "list_drafts",
|
|
488
|
+
description: 'List drafts in inbox. Filter by labels (e.g. "scheduled") to find scheduled drafts.',
|
|
489
|
+
paramsSchema: ListDraftsParams,
|
|
490
|
+
func: listDrafts,
|
|
491
|
+
annotations: {
|
|
492
|
+
readOnlyHint: true,
|
|
493
|
+
openWorldHint: false
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
name: "get_draft",
|
|
498
|
+
description: "Get a draft by ID, including its content, status, and scheduled send time.",
|
|
499
|
+
paramsSchema: GetDraftParams,
|
|
500
|
+
func: getDraft,
|
|
501
|
+
annotations: {
|
|
502
|
+
readOnlyHint: true,
|
|
503
|
+
openWorldHint: false
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
name: "update_draft",
|
|
508
|
+
description: "Update a draft. Use sendAt to reschedule a scheduled draft.",
|
|
509
|
+
paramsSchema: UpdateDraftParams,
|
|
510
|
+
func: updateDraft,
|
|
511
|
+
annotations: {
|
|
512
|
+
readOnlyHint: false,
|
|
513
|
+
destructiveHint: true,
|
|
514
|
+
idempotentHint: true,
|
|
515
|
+
openWorldHint: false
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
name: "send_draft",
|
|
520
|
+
description: "Send a draft immediately. The draft is converted to a sent message and deleted.",
|
|
521
|
+
paramsSchema: SendDraftParams,
|
|
522
|
+
func: sendDraft,
|
|
523
|
+
annotations: {
|
|
524
|
+
readOnlyHint: false,
|
|
525
|
+
destructiveHint: true,
|
|
526
|
+
idempotentHint: false,
|
|
527
|
+
openWorldHint: true
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
name: "delete_draft",
|
|
532
|
+
description: "Delete a draft. Also used to cancel a scheduled send.",
|
|
533
|
+
paramsSchema: DeleteDraftParams,
|
|
534
|
+
func: deleteDraft,
|
|
535
|
+
annotations: {
|
|
536
|
+
readOnlyHint: false,
|
|
537
|
+
destructiveHint: true,
|
|
538
|
+
idempotentHint: true,
|
|
539
|
+
openWorldHint: false
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
name: "auth_me",
|
|
544
|
+
description: "Get the identity and scope of the authenticated credential, including organization, pod, and inbox IDs.",
|
|
545
|
+
paramsSchema: AuthMeParams,
|
|
546
|
+
func: authMe,
|
|
547
|
+
annotations: {
|
|
548
|
+
readOnlyHint: true,
|
|
549
|
+
openWorldHint: false
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
];
|
|
553
|
+
|
|
554
|
+
// src/toolkit.ts
|
|
555
|
+
var BaseToolkit = class {
|
|
556
|
+
client;
|
|
557
|
+
tools = {};
|
|
558
|
+
constructor(client) {
|
|
559
|
+
this.client = client ?? new AgentMailClient();
|
|
560
|
+
this.tools = tools.reduce(
|
|
561
|
+
(acc, tool) => {
|
|
562
|
+
acc[tool.name] = this.buildTool(tool);
|
|
563
|
+
return acc;
|
|
564
|
+
},
|
|
565
|
+
{}
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
var ListToolkit = class extends BaseToolkit {
|
|
570
|
+
getTools(names) {
|
|
571
|
+
if (!names) return Object.values(this.tools);
|
|
572
|
+
return names.reduce((acc, name) => {
|
|
573
|
+
if (name in this.tools) acc.push(this.tools[name]);
|
|
574
|
+
return acc;
|
|
575
|
+
}, []);
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
var MapToolkit = class extends BaseToolkit {
|
|
579
|
+
getTools(names) {
|
|
580
|
+
if (!names) return this.tools;
|
|
581
|
+
return names.reduce(
|
|
582
|
+
(acc, name) => {
|
|
583
|
+
if (name in this.tools) acc[name] = this.tools[name];
|
|
584
|
+
return acc;
|
|
585
|
+
},
|
|
586
|
+
{}
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
export {
|
|
592
|
+
safeFunc,
|
|
593
|
+
ListToolkit,
|
|
594
|
+
MapToolkit
|
|
595
|
+
};
|
|
596
|
+
//# sourceMappingURL=chunk-2WFL2XH4.js.map
|