agentmail-toolkit 0.2.1 → 0.2.2
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/clawdbot.cjs +352 -0
- package/dist/clawdbot.cjs.map +1 -0
- package/dist/clawdbot.d.cts +11 -0
- package/dist/clawdbot.d.ts +11 -0
- package/dist/clawdbot.js +27 -0
- package/dist/clawdbot.js.map +1 -0
- package/package.json +13 -1
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/clawdbot.ts
|
|
31
|
+
var clawdbot_exports = {};
|
|
32
|
+
__export(clawdbot_exports, {
|
|
33
|
+
AgentMailToolkit: () => AgentMailToolkit
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(clawdbot_exports);
|
|
36
|
+
var import_zod2 = require("zod");
|
|
37
|
+
|
|
38
|
+
// src/toolkit.ts
|
|
39
|
+
var import_agentmail = require("agentmail");
|
|
40
|
+
|
|
41
|
+
// src/schemas.ts
|
|
42
|
+
var import_zod = require("zod");
|
|
43
|
+
var InboxIdSchema = import_zod.z.string().describe("ID of inbox");
|
|
44
|
+
var ThreadIdSchema = import_zod.z.string().describe("ID of thread");
|
|
45
|
+
var MessageIdSchema = import_zod.z.string().describe("ID of message");
|
|
46
|
+
var AttachmentIdSchema = import_zod.z.string().describe("ID of attachment");
|
|
47
|
+
var ListItemsParams = import_zod.z.object({
|
|
48
|
+
limit: import_zod.z.number().optional().default(10).describe("Max number of items to return"),
|
|
49
|
+
pageToken: import_zod.z.string().optional().describe("Page token for pagination")
|
|
50
|
+
});
|
|
51
|
+
var GetInboxParams = import_zod.z.object({
|
|
52
|
+
inboxId: InboxIdSchema
|
|
53
|
+
});
|
|
54
|
+
var CreateInboxParams = import_zod.z.object({
|
|
55
|
+
username: import_zod.z.string().optional().describe("Username"),
|
|
56
|
+
domain: import_zod.z.string().optional().describe("Domain"),
|
|
57
|
+
displayName: import_zod.z.string().optional().describe("Display name")
|
|
58
|
+
});
|
|
59
|
+
var ListInboxItemsParams = ListItemsParams.extend({
|
|
60
|
+
inboxId: InboxIdSchema,
|
|
61
|
+
labels: import_zod.z.array(import_zod.z.string()).optional().describe("Labels to filter items by"),
|
|
62
|
+
before: import_zod.z.string().pipe(import_zod.z.coerce.date()).optional().describe("Filter items before datetime"),
|
|
63
|
+
after: import_zod.z.string().pipe(import_zod.z.coerce.date()).optional().describe("Filter items after datetime")
|
|
64
|
+
});
|
|
65
|
+
var GetThreadParams = import_zod.z.object({
|
|
66
|
+
inboxId: InboxIdSchema,
|
|
67
|
+
threadId: ThreadIdSchema
|
|
68
|
+
});
|
|
69
|
+
var GetAttachmentParams = import_zod.z.object({
|
|
70
|
+
inboxId: InboxIdSchema,
|
|
71
|
+
threadId: ThreadIdSchema,
|
|
72
|
+
attachmentId: AttachmentIdSchema
|
|
73
|
+
});
|
|
74
|
+
var BaseMessageParams = import_zod.z.object({
|
|
75
|
+
inboxId: InboxIdSchema,
|
|
76
|
+
text: import_zod.z.string().optional().describe("Plain text body"),
|
|
77
|
+
html: import_zod.z.string().optional().describe("HTML body"),
|
|
78
|
+
labels: import_zod.z.array(import_zod.z.string()).optional().describe("Labels")
|
|
79
|
+
});
|
|
80
|
+
var SendMessageParams = BaseMessageParams.extend({
|
|
81
|
+
to: import_zod.z.array(import_zod.z.string()).describe("Recipients"),
|
|
82
|
+
cc: import_zod.z.array(import_zod.z.string()).optional().describe("CC recipients"),
|
|
83
|
+
bcc: import_zod.z.array(import_zod.z.string()).optional().describe("BCC recipients"),
|
|
84
|
+
subject: import_zod.z.string().optional().describe("Subject")
|
|
85
|
+
});
|
|
86
|
+
var ReplyToMessageParams = BaseMessageParams.extend({
|
|
87
|
+
messageId: MessageIdSchema,
|
|
88
|
+
replyAll: import_zod.z.boolean().optional().describe("Reply to all recipients")
|
|
89
|
+
});
|
|
90
|
+
var ForwardMessageParams = SendMessageParams.extend({
|
|
91
|
+
messageId: MessageIdSchema
|
|
92
|
+
});
|
|
93
|
+
var UpdateMessageParams = import_zod.z.object({
|
|
94
|
+
inboxId: InboxIdSchema,
|
|
95
|
+
messageId: MessageIdSchema,
|
|
96
|
+
addLabels: import_zod.z.array(import_zod.z.string()).optional().describe("Labels to add"),
|
|
97
|
+
removeLabels: import_zod.z.array(import_zod.z.string()).optional().describe("Labels to remove")
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// src/util.ts
|
|
101
|
+
var import_unpdf = require("unpdf");
|
|
102
|
+
var import_jszip = __toESM(require("jszip"), 1);
|
|
103
|
+
function detectFileType(bytes) {
|
|
104
|
+
if (bytes[0] === 37 && bytes[1] === 80 && bytes[2] === 68 && bytes[3] === 70) {
|
|
105
|
+
return "application/pdf";
|
|
106
|
+
}
|
|
107
|
+
if (bytes[0] === 80 && bytes[1] === 75 && bytes[2] === 3 && bytes[3] === 4) {
|
|
108
|
+
return "application/zip";
|
|
109
|
+
}
|
|
110
|
+
return void 0;
|
|
111
|
+
}
|
|
112
|
+
async function extractPdfText(bytes) {
|
|
113
|
+
const pdf = await (0, import_unpdf.getDocumentProxy)(bytes);
|
|
114
|
+
const { text } = await (0, import_unpdf.extractText)(pdf);
|
|
115
|
+
return Array.isArray(text) ? text.join("\n") : text;
|
|
116
|
+
}
|
|
117
|
+
async function extractDocxText(bytes) {
|
|
118
|
+
const zip = await import_jszip.default.loadAsync(bytes);
|
|
119
|
+
const documentXml = await zip.file("word/document.xml")?.async("string");
|
|
120
|
+
if (!documentXml) return void 0;
|
|
121
|
+
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();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/functions.ts
|
|
125
|
+
async function listInboxes(client, args) {
|
|
126
|
+
return client.inboxes.list(args);
|
|
127
|
+
}
|
|
128
|
+
async function getInbox(client, args) {
|
|
129
|
+
const { inboxId, ...options } = args;
|
|
130
|
+
return client.inboxes.get(inboxId, options);
|
|
131
|
+
}
|
|
132
|
+
async function createInbox(client, args) {
|
|
133
|
+
return client.inboxes.create(args);
|
|
134
|
+
}
|
|
135
|
+
async function deleteInbox(client, args) {
|
|
136
|
+
const { inboxId } = args;
|
|
137
|
+
return client.inboxes.delete(inboxId);
|
|
138
|
+
}
|
|
139
|
+
async function listThreads(client, args) {
|
|
140
|
+
const { inboxId, ...options } = args;
|
|
141
|
+
return client.inboxes.threads.list(inboxId, options);
|
|
142
|
+
}
|
|
143
|
+
async function getThread(client, args) {
|
|
144
|
+
const { inboxId, threadId, ...options } = args;
|
|
145
|
+
return client.inboxes.threads.get(inboxId, threadId, options);
|
|
146
|
+
}
|
|
147
|
+
async function getAttachment(client, args) {
|
|
148
|
+
const { threadId, attachmentId } = args;
|
|
149
|
+
const { downloadUrl } = await client.threads.getAttachment(threadId, attachmentId);
|
|
150
|
+
const response = await fetch(downloadUrl);
|
|
151
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
152
|
+
const fileBytes = new Uint8Array(arrayBuffer);
|
|
153
|
+
const detectedType = detectFileType(fileBytes);
|
|
154
|
+
if (detectedType === "application/pdf") {
|
|
155
|
+
return { text: await extractPdfText(fileBytes), fileType: detectedType };
|
|
156
|
+
} else if (detectedType === "application/zip") {
|
|
157
|
+
const text = await extractDocxText(fileBytes);
|
|
158
|
+
if (text) return { text, fileType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" };
|
|
159
|
+
}
|
|
160
|
+
return { error: "Unsupported file type", fileType: detectedType || "unknown" };
|
|
161
|
+
}
|
|
162
|
+
async function sendMessage(client, args) {
|
|
163
|
+
const { inboxId, ...options } = args;
|
|
164
|
+
return client.inboxes.messages.send(inboxId, options);
|
|
165
|
+
}
|
|
166
|
+
async function replyToMessage(client, args) {
|
|
167
|
+
const { inboxId, messageId, ...options } = args;
|
|
168
|
+
return client.inboxes.messages.reply(inboxId, messageId, options);
|
|
169
|
+
}
|
|
170
|
+
async function forwardMessage(client, args) {
|
|
171
|
+
const { inboxId, messageId, ...options } = args;
|
|
172
|
+
return client.inboxes.messages.forward(inboxId, messageId, options);
|
|
173
|
+
}
|
|
174
|
+
async function updateMessage(client, args) {
|
|
175
|
+
const { inboxId, messageId, ...options } = args;
|
|
176
|
+
return client.inboxes.messages.update(inboxId, messageId, options);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// src/tools.ts
|
|
180
|
+
var tools = [
|
|
181
|
+
{
|
|
182
|
+
name: "list_inboxes",
|
|
183
|
+
description: "List inboxes",
|
|
184
|
+
paramsSchema: ListItemsParams,
|
|
185
|
+
func: listInboxes,
|
|
186
|
+
annotations: {
|
|
187
|
+
readOnlyHint: true,
|
|
188
|
+
openWorldHint: false
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "get_inbox",
|
|
193
|
+
description: "Get inbox",
|
|
194
|
+
paramsSchema: GetInboxParams,
|
|
195
|
+
func: getInbox,
|
|
196
|
+
annotations: {
|
|
197
|
+
readOnlyHint: true,
|
|
198
|
+
openWorldHint: false
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "create_inbox",
|
|
203
|
+
description: "Create inbox",
|
|
204
|
+
paramsSchema: CreateInboxParams,
|
|
205
|
+
func: createInbox,
|
|
206
|
+
annotations: {
|
|
207
|
+
readOnlyHint: false,
|
|
208
|
+
destructiveHint: false,
|
|
209
|
+
idempotentHint: false,
|
|
210
|
+
openWorldHint: false
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "delete_inbox",
|
|
215
|
+
description: "Delete inbox",
|
|
216
|
+
paramsSchema: GetInboxParams,
|
|
217
|
+
func: deleteInbox,
|
|
218
|
+
annotations: {
|
|
219
|
+
readOnlyHint: false,
|
|
220
|
+
destructiveHint: true,
|
|
221
|
+
idempotentHint: true,
|
|
222
|
+
openWorldHint: false
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: "list_threads",
|
|
227
|
+
description: "List threads in inbox",
|
|
228
|
+
paramsSchema: ListInboxItemsParams,
|
|
229
|
+
func: listThreads,
|
|
230
|
+
annotations: {
|
|
231
|
+
readOnlyHint: true,
|
|
232
|
+
openWorldHint: true
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "get_thread",
|
|
237
|
+
description: "Get thread",
|
|
238
|
+
paramsSchema: GetThreadParams,
|
|
239
|
+
func: getThread,
|
|
240
|
+
annotations: {
|
|
241
|
+
readOnlyHint: true,
|
|
242
|
+
openWorldHint: true
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "get_attachment",
|
|
247
|
+
description: "Get attachment",
|
|
248
|
+
paramsSchema: GetAttachmentParams,
|
|
249
|
+
func: getAttachment,
|
|
250
|
+
annotations: {
|
|
251
|
+
readOnlyHint: true,
|
|
252
|
+
openWorldHint: true
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
name: "send_message",
|
|
257
|
+
description: "Send message",
|
|
258
|
+
paramsSchema: SendMessageParams,
|
|
259
|
+
func: sendMessage,
|
|
260
|
+
annotations: {
|
|
261
|
+
readOnlyHint: false,
|
|
262
|
+
destructiveHint: false,
|
|
263
|
+
idempotentHint: false,
|
|
264
|
+
openWorldHint: true
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: "reply_to_message",
|
|
269
|
+
description: "Reply to message",
|
|
270
|
+
paramsSchema: ReplyToMessageParams,
|
|
271
|
+
func: replyToMessage,
|
|
272
|
+
annotations: {
|
|
273
|
+
readOnlyHint: false,
|
|
274
|
+
destructiveHint: false,
|
|
275
|
+
idempotentHint: false,
|
|
276
|
+
openWorldHint: true
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: "forward_message",
|
|
281
|
+
description: "Forward message",
|
|
282
|
+
paramsSchema: ForwardMessageParams,
|
|
283
|
+
func: forwardMessage,
|
|
284
|
+
annotations: {
|
|
285
|
+
readOnlyHint: false,
|
|
286
|
+
destructiveHint: false,
|
|
287
|
+
idempotentHint: false,
|
|
288
|
+
openWorldHint: true
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
name: "update_message",
|
|
293
|
+
description: "Update message",
|
|
294
|
+
paramsSchema: UpdateMessageParams,
|
|
295
|
+
func: updateMessage,
|
|
296
|
+
annotations: {
|
|
297
|
+
readOnlyHint: false,
|
|
298
|
+
destructiveHint: false,
|
|
299
|
+
idempotentHint: true,
|
|
300
|
+
openWorldHint: false
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
];
|
|
304
|
+
|
|
305
|
+
// src/toolkit.ts
|
|
306
|
+
var BaseToolkit = class {
|
|
307
|
+
client;
|
|
308
|
+
tools = {};
|
|
309
|
+
constructor(client) {
|
|
310
|
+
this.client = client ?? new import_agentmail.AgentMailClient();
|
|
311
|
+
this.tools = tools.reduce(
|
|
312
|
+
(acc, tool) => {
|
|
313
|
+
acc[tool.name] = this.buildTool(tool);
|
|
314
|
+
return acc;
|
|
315
|
+
},
|
|
316
|
+
{}
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
var ListToolkit = class extends BaseToolkit {
|
|
321
|
+
getTools(names) {
|
|
322
|
+
if (!names) return Object.values(this.tools);
|
|
323
|
+
return names.reduce((acc, name) => {
|
|
324
|
+
if (name in this.tools) acc.push(this.tools[name]);
|
|
325
|
+
return acc;
|
|
326
|
+
}, []);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// src/clawdbot.ts
|
|
331
|
+
var AgentMailToolkit = class extends ListToolkit {
|
|
332
|
+
buildTool(tool) {
|
|
333
|
+
return {
|
|
334
|
+
name: tool.name,
|
|
335
|
+
label: tool.name,
|
|
336
|
+
description: tool.description,
|
|
337
|
+
parameters: (0, import_zod2.toJSONSchema)(tool.paramsSchema),
|
|
338
|
+
execute: async (_toolCallId, args) => {
|
|
339
|
+
const response = await tool.func(this.client, args);
|
|
340
|
+
return {
|
|
341
|
+
content: [{ type: "text", text: JSON.stringify(response) }],
|
|
342
|
+
details: response
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
349
|
+
0 && (module.exports = {
|
|
350
|
+
AgentMailToolkit
|
|
351
|
+
});
|
|
352
|
+
//# sourceMappingURL=clawdbot.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/clawdbot.ts","../src/toolkit.ts","../src/schemas.ts","../src/util.ts","../src/functions.ts","../src/tools.ts"],"sourcesContent":["import type { AgentTool } from '@mariozechner/pi-agent-core'\nimport type { TSchema } from '@sinclair/typebox'\nimport { toJSONSchema } from 'zod'\n\nimport { ListToolkit } from './toolkit.js'\nimport type { Tool } from './tools.js'\nimport type { Args } from './functions.js'\n\nexport class AgentMailToolkit extends ListToolkit<AgentTool> {\n protected buildTool(tool: Tool): AgentTool {\n return {\n name: tool.name,\n label: tool.name,\n description: tool.description,\n parameters: toJSONSchema(tool.paramsSchema) as unknown as TSchema,\n execute: async (_toolCallId, args) => {\n const response = await tool.func(this.client, args as Args)\n return {\n content: [{ type: 'text', text: JSON.stringify(response) }],\n details: response,\n }\n },\n }\n }\n}\n","import { AgentMailClient } from 'agentmail'\n\nimport { type Tool, tools } from './tools.js'\n\nexport abstract class BaseToolkit<T> {\n protected readonly client: AgentMailClient\n protected readonly tools: Record<string, T> = {}\n\n constructor(client?: AgentMailClient) {\n this.client = client ?? new AgentMailClient()\n\n this.tools = tools.reduce(\n (acc, tool) => {\n acc[tool.name] = this.buildTool(tool)\n return acc\n },\n {} as Record<string, T>\n )\n }\n\n protected abstract buildTool(tool: Tool): T\n}\n\nexport abstract class ListToolkit<T> extends BaseToolkit<T> {\n public getTools(names?: string[]) {\n if (!names) return Object.values(this.tools)\n\n return names.reduce((acc, name) => {\n if (name in this.tools) acc.push(this.tools[name])\n return acc\n }, [] as T[])\n }\n}\n\nexport abstract class MapToolkit<T> extends BaseToolkit<T> {\n public getTools(names?: string[]) {\n if (!names) return this.tools\n\n return names.reduce(\n (acc, name) => {\n if (name in this.tools) acc[name] = this.tools[name]\n return acc\n },\n {} as Record<string, T>\n )\n }\n}\n","import { z } from 'zod'\n\nconst InboxIdSchema = z.string().describe('ID of inbox')\nconst ThreadIdSchema = z.string().describe('ID of thread')\nconst MessageIdSchema = z.string().describe('ID of message')\nconst AttachmentIdSchema = z.string().describe('ID of attachment')\n\nexport const ListItemsParams = z.object({\n limit: z.number().optional().default(10).describe('Max number of items to return'),\n pageToken: z.string().optional().describe('Page token for pagination'),\n})\n\nexport const GetInboxParams = z.object({\n inboxId: InboxIdSchema,\n})\n\nexport const CreateInboxParams = z.object({\n username: z.string().optional().describe('Username'),\n domain: z.string().optional().describe('Domain'),\n displayName: z.string().optional().describe('Display name'),\n})\n\nexport const ListInboxItemsParams = ListItemsParams.extend({\n inboxId: InboxIdSchema,\n labels: z.array(z.string()).optional().describe('Labels to filter items by'),\n before: z.string().pipe(z.coerce.date()).optional().describe('Filter items before datetime'),\n after: z.string().pipe(z.coerce.date()).optional().describe('Filter items after datetime'),\n})\n\nexport const GetThreadParams = z.object({\n inboxId: InboxIdSchema,\n threadId: ThreadIdSchema,\n})\n\nexport const GetAttachmentParams = z.object({\n inboxId: InboxIdSchema,\n threadId: ThreadIdSchema,\n attachmentId: AttachmentIdSchema,\n})\n\nconst BaseMessageParams = z.object({\n inboxId: InboxIdSchema,\n text: z.string().optional().describe('Plain text body'),\n html: z.string().optional().describe('HTML body'),\n labels: z.array(z.string()).optional().describe('Labels'),\n})\n\nexport const SendMessageParams = BaseMessageParams.extend({\n to: z.array(z.string()).describe('Recipients'),\n cc: z.array(z.string()).optional().describe('CC recipients'),\n bcc: z.array(z.string()).optional().describe('BCC recipients'),\n subject: z.string().optional().describe('Subject'),\n})\n\nexport const ReplyToMessageParams = BaseMessageParams.extend({\n messageId: MessageIdSchema,\n replyAll: z.boolean().optional().describe('Reply to all recipients'),\n})\n\nexport const ForwardMessageParams = SendMessageParams.extend({\n messageId: MessageIdSchema,\n})\n\nexport const UpdateMessageParams = z.object({\n inboxId: InboxIdSchema,\n messageId: MessageIdSchema,\n addLabels: z.array(z.string()).optional().describe('Labels to add'),\n removeLabels: z.array(z.string()).optional().describe('Labels to remove'),\n})\n","import { AgentMailClient } from 'agentmail'\nimport { getDocumentProxy, extractText } from 'unpdf'\nimport JSZip from 'jszip'\n\nexport const safeFunc = async <T>(\n func: (client: AgentMailClient, args: Record<string, any>) => Promise<T>,\n client: AgentMailClient,\n args: Record<string, any>\n) => {\n try {\n return { isError: false, result: await func(client, args) }\n } catch (error) {\n if (error instanceof Error) return { isError: true, result: error.message }\n else return { isError: true, result: 'Unknown error' }\n }\n}\n\nexport function detectFileType(bytes: Uint8Array): string | undefined {\n // PDF: starts with %PDF (0x25 0x50 0x44 0x46)\n if (bytes[0] === 0x25 && bytes[1] === 0x50 && bytes[2] === 0x44 && bytes[3] === 0x46) {\n return 'application/pdf'\n }\n // ZIP (DOCX is a ZIP): starts with PK\\x03\\x04 (0x50 0x4B 0x03 0x04)\n if (bytes[0] === 0x50 && bytes[1] === 0x4b && bytes[2] === 0x03 && bytes[3] === 0x04) {\n return 'application/zip'\n }\n return undefined\n}\n\nexport async function extractPdfText(bytes: Uint8Array): Promise<string> {\n const pdf = await getDocumentProxy(bytes)\n const { text } = await extractText(pdf)\n return Array.isArray(text) ? text.join('\\n') : text\n}\n\nexport async function extractDocxText(bytes: Uint8Array): Promise<string | undefined> {\n const zip = await JSZip.loadAsync(bytes)\n const documentXml = await zip.file('word/document.xml')?.async('string')\n if (!documentXml) return undefined\n return documentXml\n .replace(/<w:p[^>]*>/g, '\\n')\n .replace(/<[^>]+>/g, '')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/&/g, '&')\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim()\n}\n","import { AgentMailClient } from 'agentmail'\nimport { detectFileType, extractPdfText, extractDocxText } from './util.js'\n\nexport type Args = Record<string, any>\n\ninterface Attachment {\n text?: string\n error?: string\n fileType?: string\n}\n\nexport async function listInboxes(client: AgentMailClient, args: Args) {\n return client.inboxes.list(args)\n}\n\nexport async function getInbox(client: AgentMailClient, args: Args) {\n const { inboxId, ...options } = args\n return client.inboxes.get(inboxId, options)\n}\n\nexport async function createInbox(client: AgentMailClient, args: Args) {\n return client.inboxes.create(args)\n}\n\nexport async function deleteInbox(client: AgentMailClient, args: Args) {\n const { inboxId } = args\n return client.inboxes.delete(inboxId)\n}\n\nexport async function listThreads(client: AgentMailClient, args: Args) {\n const { inboxId, ...options } = args\n return client.inboxes.threads.list(inboxId, options)\n}\n\nexport async function getThread(client: AgentMailClient, args: Args) {\n const { inboxId, threadId, ...options } = args\n return client.inboxes.threads.get(inboxId, threadId, options)\n}\n\nexport async function getAttachment(client: AgentMailClient, args: Args): Promise<Attachment> {\n const { threadId, attachmentId } = args\n\n const { downloadUrl } = await client.threads.getAttachment(threadId, attachmentId)\n const response = await fetch(downloadUrl)\n const arrayBuffer = await response.arrayBuffer()\n const fileBytes = new Uint8Array(arrayBuffer)\n\n const detectedType = detectFileType(fileBytes)\n\n if (detectedType === 'application/pdf') {\n return { text: await extractPdfText(fileBytes), fileType: detectedType }\n } else if (detectedType === 'application/zip') {\n const text = await extractDocxText(fileBytes)\n if (text) return { text, fileType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }\n }\n\n return { error: 'Unsupported file type', fileType: detectedType || 'unknown' }\n}\n\nexport async function sendMessage(client: AgentMailClient, args: Args) {\n const { inboxId, ...options } = args\n return client.inboxes.messages.send(inboxId, options)\n}\n\nexport async function replyToMessage(client: AgentMailClient, args: Args) {\n const { inboxId, messageId, ...options } = args\n return client.inboxes.messages.reply(inboxId, messageId, options)\n}\n\nexport async function forwardMessage(client: AgentMailClient, args: Args) {\n const { inboxId, messageId, ...options } = args\n return client.inboxes.messages.forward(inboxId, messageId, options)\n}\n\nexport async function updateMessage(client: AgentMailClient, args: Args) {\n const { inboxId, messageId, ...options } = args\n return client.inboxes.messages.update(inboxId, messageId, options)\n}\n","import { z } from 'zod'\nimport { AgentMailClient } from 'agentmail'\nimport { type ToolAnnotations } from '@modelcontextprotocol/sdk/types.js'\n\nimport {\n ListItemsParams,\n ListInboxItemsParams,\n GetInboxParams,\n CreateInboxParams,\n GetThreadParams,\n GetAttachmentParams,\n SendMessageParams,\n ReplyToMessageParams,\n UpdateMessageParams,\n ForwardMessageParams,\n} from './schemas.js'\nimport {\n type Args,\n listInboxes,\n getInbox,\n createInbox,\n deleteInbox,\n listThreads,\n getThread,\n getAttachment,\n sendMessage,\n replyToMessage,\n updateMessage,\n forwardMessage,\n} from './functions.js'\nexport interface Tool {\n name: string\n description: string\n paramsSchema: z.ZodObject<any>\n func: (client: AgentMailClient, args: Args) => Promise<any>\n annotations?: ToolAnnotations\n}\n\nexport const tools: Tool[] = [\n {\n name: 'list_inboxes',\n description: 'List inboxes',\n paramsSchema: ListItemsParams,\n func: listInboxes,\n annotations: {\n readOnlyHint: true,\n openWorldHint: false,\n },\n },\n {\n name: 'get_inbox',\n description: 'Get inbox',\n paramsSchema: GetInboxParams,\n func: getInbox,\n annotations: {\n readOnlyHint: true,\n openWorldHint: false,\n },\n },\n {\n name: 'create_inbox',\n description: 'Create inbox',\n paramsSchema: CreateInboxParams,\n func: createInbox,\n annotations: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: false,\n },\n },\n {\n name: 'delete_inbox',\n description: 'Delete inbox',\n paramsSchema: GetInboxParams,\n func: deleteInbox,\n annotations: {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: true,\n openWorldHint: false,\n },\n },\n {\n name: 'list_threads',\n description: 'List threads in inbox',\n paramsSchema: ListInboxItemsParams,\n func: listThreads,\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n },\n {\n name: 'get_thread',\n description: 'Get thread',\n paramsSchema: GetThreadParams,\n func: getThread,\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n },\n {\n name: 'get_attachment',\n description: 'Get attachment',\n paramsSchema: GetAttachmentParams,\n func: getAttachment,\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n },\n {\n name: 'send_message',\n description: 'Send message',\n paramsSchema: SendMessageParams,\n func: sendMessage,\n annotations: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n },\n },\n {\n name: 'reply_to_message',\n description: 'Reply to message',\n paramsSchema: ReplyToMessageParams,\n func: replyToMessage,\n annotations: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n },\n },\n {\n name: 'forward_message',\n description: 'Forward message',\n paramsSchema: ForwardMessageParams,\n func: forwardMessage,\n annotations: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n },\n },\n {\n name: 'update_message',\n description: 'Update message',\n paramsSchema: UpdateMessageParams,\n func: updateMessage,\n annotations: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n },\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,cAA6B;;;ACF7B,uBAAgC;;;ACAhC,iBAAkB;AAElB,IAAM,gBAAgB,aAAE,OAAO,EAAE,SAAS,aAAa;AACvD,IAAM,iBAAiB,aAAE,OAAO,EAAE,SAAS,cAAc;AACzD,IAAM,kBAAkB,aAAE,OAAO,EAAE,SAAS,eAAe;AAC3D,IAAM,qBAAqB,aAAE,OAAO,EAAE,SAAS,kBAAkB;AAE1D,IAAM,kBAAkB,aAAE,OAAO;AAAA,EACpC,OAAO,aAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,+BAA+B;AAAA,EACjF,WAAW,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,2BAA2B;AACzE,CAAC;AAEM,IAAM,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;AAAA,UACH,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,EAAE,CAAC;AAAA,UAC1D,SAAS;AAAA,QACb;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;","names":["import_zod","JSZip"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AgentTool } from '@mariozechner/pi-agent-core';
|
|
2
|
+
import { L as ListToolkit, T as Tool } from './toolkit-BBmENfEu.cjs';
|
|
3
|
+
import 'agentmail';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
|
|
7
|
+
declare class AgentMailToolkit extends ListToolkit<AgentTool> {
|
|
8
|
+
protected buildTool(tool: Tool): AgentTool;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { AgentMailToolkit };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AgentTool } from '@mariozechner/pi-agent-core';
|
|
2
|
+
import { L as ListToolkit, T as Tool } from './toolkit-BBmENfEu.js';
|
|
3
|
+
import 'agentmail';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
|
|
7
|
+
declare class AgentMailToolkit extends ListToolkit<AgentTool> {
|
|
8
|
+
protected buildTool(tool: Tool): AgentTool;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { AgentMailToolkit };
|
package/dist/clawdbot.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ListToolkit
|
|
3
|
+
} from "./chunk-KMHACGIU.js";
|
|
4
|
+
|
|
5
|
+
// src/clawdbot.ts
|
|
6
|
+
import { toJSONSchema } from "zod";
|
|
7
|
+
var AgentMailToolkit = class extends ListToolkit {
|
|
8
|
+
buildTool(tool) {
|
|
9
|
+
return {
|
|
10
|
+
name: tool.name,
|
|
11
|
+
label: tool.name,
|
|
12
|
+
description: tool.description,
|
|
13
|
+
parameters: toJSONSchema(tool.paramsSchema),
|
|
14
|
+
execute: async (_toolCallId, args) => {
|
|
15
|
+
const response = await tool.func(this.client, args);
|
|
16
|
+
return {
|
|
17
|
+
content: [{ type: "text", text: JSON.stringify(response) }],
|
|
18
|
+
details: response
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
AgentMailToolkit
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=clawdbot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/clawdbot.ts"],"sourcesContent":["import type { AgentTool } from '@mariozechner/pi-agent-core'\nimport type { TSchema } from '@sinclair/typebox'\nimport { toJSONSchema } from 'zod'\n\nimport { ListToolkit } from './toolkit.js'\nimport type { Tool } from './tools.js'\nimport type { Args } from './functions.js'\n\nexport class AgentMailToolkit extends ListToolkit<AgentTool> {\n protected buildTool(tool: Tool): AgentTool {\n return {\n name: tool.name,\n label: tool.name,\n description: tool.description,\n parameters: toJSONSchema(tool.paramsSchema) as unknown as TSchema,\n execute: async (_toolCallId, args) => {\n const response = await tool.func(this.client, args as Args)\n return {\n content: [{ type: 'text', text: JSON.stringify(response) }],\n details: response,\n }\n },\n }\n }\n}\n"],"mappings":";;;;;AAEA,SAAS,oBAAoB;AAMtB,IAAM,mBAAN,cAA+B,YAAuB;AAAA,EAC/C,UAAU,MAAuB;AACvC,WAAO;AAAA,MACH,MAAM,KAAK;AAAA,MACX,OAAO,KAAK;AAAA,MACZ,aAAa,KAAK;AAAA,MAClB,YAAY,aAAa,KAAK,YAAY;AAAA,MAC1C,SAAS,OAAO,aAAa,SAAS;AAClC,cAAM,WAAW,MAAM,KAAK,KAAK,KAAK,QAAQ,IAAY;AAC1D,eAAO;AAAA,UACH,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,EAAE,CAAC;AAAA,UAC1D,SAAS;AAAA,QACb;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentmail-toolkit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "AgentMail Toolkit",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
@@ -47,6 +47,11 @@
|
|
|
47
47
|
"types": "./dist/mcp.d.ts",
|
|
48
48
|
"import": "./dist/mcp.js",
|
|
49
49
|
"require": "./dist/mcp.cjs"
|
|
50
|
+
},
|
|
51
|
+
"./clawdbot": {
|
|
52
|
+
"types": "./dist/clawdbot.d.ts",
|
|
53
|
+
"import": "./dist/clawdbot.js",
|
|
54
|
+
"require": "./dist/clawdbot.cjs"
|
|
50
55
|
}
|
|
51
56
|
},
|
|
52
57
|
"dependencies": {
|
|
@@ -58,6 +63,7 @@
|
|
|
58
63
|
"peerDependencies": {
|
|
59
64
|
"@modelcontextprotocol/sdk": "^1.24.1",
|
|
60
65
|
"ai": "^6.0.0-beta.150",
|
|
66
|
+
"clawdbot": "*",
|
|
61
67
|
"langchain": "^1.2.0"
|
|
62
68
|
},
|
|
63
69
|
"peerDependenciesMeta": {
|
|
@@ -67,13 +73,19 @@
|
|
|
67
73
|
"ai": {
|
|
68
74
|
"optional": true
|
|
69
75
|
},
|
|
76
|
+
"clawdbot": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
70
79
|
"langchain": {
|
|
71
80
|
"optional": true
|
|
72
81
|
}
|
|
73
82
|
},
|
|
74
83
|
"devDependencies": {
|
|
75
84
|
"@eslint/js": "^9.39.1",
|
|
85
|
+
"@mariozechner/pi-agent-core": "^0.50.1",
|
|
86
|
+
"@sinclair/typebox": "^0.34.47",
|
|
76
87
|
"@types/node": "^24.10.1",
|
|
88
|
+
"clawdbot": "2026.1.24-3",
|
|
77
89
|
"eslint": "^9.39.1",
|
|
78
90
|
"eslint-config-prettier": "^10.1.8",
|
|
79
91
|
"globals": "^16.5.0",
|