agentmail-toolkit 0.1.28 → 0.1.29
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.d.mts +1 -2
- package/dist/ai-sdk.d.ts +1 -2
- package/dist/ai-sdk.mjs +1 -2
- package/dist/ai-sdk.mjs.map +1 -1
- package/dist/chunk-NXBM2DQE.mjs +226 -0
- package/dist/chunk-NXBM2DQE.mjs.map +1 -0
- package/dist/index.d.mts +17 -215
- package/dist/index.d.ts +17 -215
- package/dist/index.js +64 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -29
- package/dist/index.mjs.map +1 -1
- package/dist/langchain.d.mts +1 -2
- package/dist/langchain.d.ts +1 -2
- package/dist/langchain.mjs +1 -2
- package/dist/langchain.mjs.map +1 -1
- package/dist/mcp.d.mts +1 -2
- package/dist/mcp.d.ts +1 -2
- package/dist/mcp.mjs +1 -2
- package/dist/mcp.mjs.map +1 -1
- package/dist/toolkit-B8QHBdtC.d.mts +33 -0
- package/dist/toolkit-B8QHBdtC.d.ts +33 -0
- package/package.json +1 -1
package/dist/ai-sdk.d.mts
CHANGED
package/dist/ai-sdk.d.ts
CHANGED
package/dist/ai-sdk.mjs
CHANGED
package/dist/ai-sdk.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ai-sdk.ts"],"sourcesContent":["import { type Tool as AiSdkTool } from 'ai'\n\nimport { MapToolkit } from './toolkit'\nimport { type Tool } from './tools'\n\nexport class AgentMailToolkit extends MapToolkit<AiSdkTool> {\n protected buildTool(tool: Tool): AiSdkTool {\n return {\n description: tool.description,\n parameters: tool.schema,\n execute: async (args) => (await this.safeCall(tool.method, args)).result,\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/ai-sdk.ts"],"sourcesContent":["import { type Tool as AiSdkTool } from 'ai'\n\nimport { MapToolkit } from './toolkit'\nimport { type Tool } from './tools'\n\nexport class AgentMailToolkit extends MapToolkit<AiSdkTool> {\n protected buildTool(tool: Tool): AiSdkTool {\n return {\n description: tool.description,\n parameters: tool.schema,\n execute: async (args) => (await this.safeCall(tool.method, args)).result,\n }\n }\n}\n"],"mappings":";;;;;AAKO,IAAM,mBAAN,cAA+B,WAAsB;AAAA,EAC9C,UAAU,MAAuB;AACvC,WAAO;AAAA,MACH,aAAa,KAAK;AAAA,MAClB,YAAY,KAAK;AAAA,MACjB,SAAS,OAAO,UAAU,MAAM,KAAK,SAAS,KAAK,QAAQ,IAAI,GAAG;AAAA,IACtE;AAAA,EACJ;AACJ;","names":[]}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// src/wrapper.ts
|
|
2
|
+
import { AgentMailClient } from "agentmail";
|
|
3
|
+
var Wrapper = class {
|
|
4
|
+
constructor(client = new AgentMailClient()) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
async call(method, args) {
|
|
8
|
+
const parts = method.split(".");
|
|
9
|
+
const methodKey = parts.pop();
|
|
10
|
+
if (!methodKey) throw new Error("Method name empty");
|
|
11
|
+
let parent = this.client;
|
|
12
|
+
for (const part of parts) parent = parent[part];
|
|
13
|
+
const { inbox_id, thread_id, message_id, draft_id, attachment_id, ...options } = args;
|
|
14
|
+
const methodArgs = [inbox_id, thread_id, message_id, draft_id, attachment_id, options].filter(Boolean);
|
|
15
|
+
return await parent[methodKey].call(parent, ...methodArgs);
|
|
16
|
+
}
|
|
17
|
+
async safeCall(method, args) {
|
|
18
|
+
try {
|
|
19
|
+
return { isError: false, result: await this.call(method, args) };
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (error instanceof Error) return { isError: true, result: error.message };
|
|
22
|
+
else return { isError: true, result: "Unknown error" };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/schemas.ts
|
|
28
|
+
import { z } from "zod";
|
|
29
|
+
var ListItemsParams = z.object({
|
|
30
|
+
limit: z.number().optional().describe("Max number of items to return"),
|
|
31
|
+
page_token: z.string().optional().describe("Page token for pagination")
|
|
32
|
+
});
|
|
33
|
+
var ListInboxItemsParams = ListItemsParams.extend({
|
|
34
|
+
labels: z.array(z.string()).optional().describe("Labels to filter items by"),
|
|
35
|
+
ascending: z.boolean().optional().describe("Sort items in ascending order")
|
|
36
|
+
});
|
|
37
|
+
var GetInboxParams = z.object({
|
|
38
|
+
inbox_id: z.string().describe("ID of inbox to get")
|
|
39
|
+
});
|
|
40
|
+
var CreateInboxParams = z.object({
|
|
41
|
+
username: z.string().optional().describe("Username of inbox to create"),
|
|
42
|
+
domain: z.string().optional().describe("Domain of inbox to create"),
|
|
43
|
+
display_name: z.string().optional().describe("Display name of inbox to create")
|
|
44
|
+
});
|
|
45
|
+
var ListThreadsParams = ListInboxItemsParams.extend({
|
|
46
|
+
inbox_id: z.string().describe("ID of inbox to list threads from")
|
|
47
|
+
});
|
|
48
|
+
var GetThreadParams = z.object({
|
|
49
|
+
thread_id: z.string().describe("ID of thread to get")
|
|
50
|
+
});
|
|
51
|
+
var SendMessageParams = z.object({
|
|
52
|
+
inbox_id: z.string().describe("ID of inbox to send message from"),
|
|
53
|
+
to: z.array(z.string()).describe("Recipients of message"),
|
|
54
|
+
cc: z.array(z.string()).optional().describe("CC recipients of message"),
|
|
55
|
+
bcc: z.array(z.string()).optional().describe("BCC recipients of message"),
|
|
56
|
+
subject: z.string().optional().describe("Subject of message"),
|
|
57
|
+
text: z.string().optional().describe("Plain text body of message"),
|
|
58
|
+
html: z.string().optional().describe("HTML body of message"),
|
|
59
|
+
labels: z.array(z.string()).optional().describe("Labels to add to message")
|
|
60
|
+
});
|
|
61
|
+
var ReplyToMessageParams = z.object({
|
|
62
|
+
inbox_id: z.string().describe("ID of inbox to reply to message from"),
|
|
63
|
+
message_id: z.string().describe("ID of message to reply to"),
|
|
64
|
+
text: z.string().optional().describe("Plain text body of reply"),
|
|
65
|
+
html: z.string().optional().describe("HTML body of reply"),
|
|
66
|
+
labels: z.array(z.string()).optional().describe("Labels to add to reply")
|
|
67
|
+
});
|
|
68
|
+
var UpdateMessageParams = z.object({
|
|
69
|
+
inbox_id: z.string().describe("ID of inbox to update message from"),
|
|
70
|
+
message_id: z.string().describe("ID of message to update"),
|
|
71
|
+
add_labels: z.array(z.string()).optional().describe("Labels to add to message"),
|
|
72
|
+
remove_labels: z.array(z.string()).optional().describe("Labels to remove from message")
|
|
73
|
+
});
|
|
74
|
+
var ListDraftsParams = ListInboxItemsParams.extend({
|
|
75
|
+
inbox_id: z.string().describe("ID of inbox to list drafts from")
|
|
76
|
+
});
|
|
77
|
+
var GetDraftParams = z.object({
|
|
78
|
+
inbox_id: z.string().describe("ID of inbox to get draft from"),
|
|
79
|
+
draft_id: z.string().describe("ID of draft to get")
|
|
80
|
+
});
|
|
81
|
+
var CreateDraftParams = z.object({
|
|
82
|
+
inbox_id: z.string().describe("ID of inbox to create draft from"),
|
|
83
|
+
to: z.array(z.string()).describe("Recipients of draft"),
|
|
84
|
+
cc: z.array(z.string()).optional().describe("CC recipients of draft"),
|
|
85
|
+
bcc: z.array(z.string()).optional().describe("BCC recipients of draft"),
|
|
86
|
+
subject: z.string().optional().describe("Subject of draft"),
|
|
87
|
+
text: z.string().optional().describe("Plain text body of draft"),
|
|
88
|
+
html: z.string().optional().describe("HTML body of draft"),
|
|
89
|
+
labels: z.array(z.string()).optional().describe("Labels to add to draft")
|
|
90
|
+
});
|
|
91
|
+
var SendDraftParams = z.object({
|
|
92
|
+
inbox_id: z.string().describe("ID of inbox to send draft from"),
|
|
93
|
+
draft_id: z.string().describe("ID of draft to send"),
|
|
94
|
+
add_labels: z.array(z.string()).optional().describe("Labels to add to sent message"),
|
|
95
|
+
remove_labels: z.array(z.string()).optional().describe("Labels to remove from sent message")
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// src/tools.ts
|
|
99
|
+
var tools = [
|
|
100
|
+
{
|
|
101
|
+
name: "list_inboxes",
|
|
102
|
+
method: "inboxes.list",
|
|
103
|
+
description: "List inboxes",
|
|
104
|
+
schema: ListItemsParams
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "get_inbox",
|
|
108
|
+
method: "inboxes.get",
|
|
109
|
+
description: "Get inbox",
|
|
110
|
+
schema: GetInboxParams
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "create_inbox",
|
|
114
|
+
method: "inboxes.create",
|
|
115
|
+
description: "Create inbox",
|
|
116
|
+
schema: CreateInboxParams
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "list_threads",
|
|
120
|
+
method: "inboxes.threads.list",
|
|
121
|
+
description: "List threads in inbox",
|
|
122
|
+
schema: ListThreadsParams
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "list_all_threads",
|
|
126
|
+
method: "threads.list",
|
|
127
|
+
description: "List threads in all inboxes",
|
|
128
|
+
schema: ListInboxItemsParams
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "get_thread",
|
|
132
|
+
method: "threads.get",
|
|
133
|
+
description: "Get thread",
|
|
134
|
+
schema: GetThreadParams
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "send_message",
|
|
138
|
+
method: "inboxes.messages.send",
|
|
139
|
+
description: "Send message",
|
|
140
|
+
schema: SendMessageParams
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "reply_to_message",
|
|
144
|
+
method: "inboxes.messages.reply",
|
|
145
|
+
description: "Reply to message",
|
|
146
|
+
schema: ReplyToMessageParams
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "update_message",
|
|
150
|
+
method: "inboxes.messages.update",
|
|
151
|
+
description: "Update message",
|
|
152
|
+
schema: UpdateMessageParams
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "list_drafts",
|
|
156
|
+
method: "inboxes.drafts.list",
|
|
157
|
+
description: "List drafts in inbox",
|
|
158
|
+
schema: ListDraftsParams
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "list_all_drafts",
|
|
162
|
+
method: "drafts.list",
|
|
163
|
+
description: "List drafts in all inboxes",
|
|
164
|
+
schema: ListInboxItemsParams
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "get_draft",
|
|
168
|
+
method: "drafts.get",
|
|
169
|
+
description: "Get draft",
|
|
170
|
+
schema: GetDraftParams
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: "create_draft",
|
|
174
|
+
method: "inboxes.drafts.create",
|
|
175
|
+
description: "Create draft",
|
|
176
|
+
schema: CreateDraftParams
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "send_draft",
|
|
180
|
+
method: "inboxes.drafts.send",
|
|
181
|
+
description: "Send draft",
|
|
182
|
+
schema: SendDraftParams
|
|
183
|
+
}
|
|
184
|
+
];
|
|
185
|
+
|
|
186
|
+
// src/toolkit.ts
|
|
187
|
+
var BaseToolkit = class extends Wrapper {
|
|
188
|
+
tools = {};
|
|
189
|
+
constructor(client) {
|
|
190
|
+
super(client);
|
|
191
|
+
this.tools = tools.reduce(
|
|
192
|
+
(acc, tool) => {
|
|
193
|
+
acc[tool.name] = this.buildTool(tool);
|
|
194
|
+
return acc;
|
|
195
|
+
},
|
|
196
|
+
{}
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
var ListToolkit = class extends BaseToolkit {
|
|
201
|
+
getTools(names) {
|
|
202
|
+
if (!names) return Object.values(this.tools);
|
|
203
|
+
return names.reduce((acc, name) => {
|
|
204
|
+
if (name in this.tools) acc.push(this.tools[name]);
|
|
205
|
+
return acc;
|
|
206
|
+
}, []);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
var MapToolkit = class extends BaseToolkit {
|
|
210
|
+
getTools(names) {
|
|
211
|
+
if (!names) return this.tools;
|
|
212
|
+
return names.reduce(
|
|
213
|
+
(acc, name) => {
|
|
214
|
+
if (name in this.tools) acc[name] = this.tools[name];
|
|
215
|
+
return acc;
|
|
216
|
+
},
|
|
217
|
+
{}
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export {
|
|
223
|
+
ListToolkit,
|
|
224
|
+
MapToolkit
|
|
225
|
+
};
|
|
226
|
+
//# sourceMappingURL=chunk-NXBM2DQE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/wrapper.ts","../src/schemas.ts","../src/tools.ts","../src/toolkit.ts"],"sourcesContent":["import { AgentMailClient } from 'agentmail'\n\nexport class Wrapper {\n constructor(private readonly client = new AgentMailClient()) {}\n\n public async call(method: string, args: any) {\n const parts = method.split('.')\n const methodKey = parts.pop()\n\n if (!methodKey) throw new Error('Method name empty')\n\n let parent: any = this.client\n for (const part of parts) parent = parent[part]\n\n const { inbox_id, thread_id, message_id, draft_id, attachment_id, ...options } = args\n const methodArgs = [inbox_id, thread_id, message_id, draft_id, attachment_id, options].filter(Boolean)\n\n return await parent[methodKey].call(parent, ...methodArgs)\n }\n\n public async safeCall(method: string, args: any) {\n try {\n return { isError: false, result: await this.call(method, 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}\n","import { z } from 'zod'\n\nexport const ListItemsParams = z.object({\n limit: z.number().optional().describe('Max number of items to return'),\n page_token: z.string().optional().describe('Page token for pagination'),\n})\n\nexport const ListInboxItemsParams = ListItemsParams.extend({\n labels: z.array(z.string()).optional().describe('Labels to filter items by'),\n ascending: z.boolean().optional().describe('Sort items in ascending order'),\n})\n\nexport const GetInboxParams = z.object({\n inbox_id: z.string().describe('ID of inbox to get'),\n})\n\nexport const CreateInboxParams = z.object({\n username: z.string().optional().describe('Username of inbox to create'),\n domain: z.string().optional().describe('Domain of inbox to create'),\n display_name: z.string().optional().describe('Display name of inbox to create'),\n})\n\nexport const ListThreadsParams = ListInboxItemsParams.extend({\n inbox_id: z.string().describe('ID of inbox to list threads from'),\n})\n\nexport const GetThreadParams = z.object({\n thread_id: z.string().describe('ID of thread to get'),\n})\n\nexport const SendMessageParams = z.object({\n inbox_id: z.string().describe('ID of inbox to send message from'),\n to: z.array(z.string()).describe('Recipients of message'),\n cc: z.array(z.string()).optional().describe('CC recipients of message'),\n bcc: z.array(z.string()).optional().describe('BCC recipients of message'),\n subject: z.string().optional().describe('Subject of message'),\n text: z.string().optional().describe('Plain text body of message'),\n html: z.string().optional().describe('HTML body of message'),\n labels: z.array(z.string()).optional().describe('Labels to add to message'),\n})\n\nexport const ReplyToMessageParams = z.object({\n inbox_id: z.string().describe('ID of inbox to reply to message from'),\n message_id: z.string().describe('ID of message to reply to'),\n text: z.string().optional().describe('Plain text body of reply'),\n html: z.string().optional().describe('HTML body of reply'),\n labels: z.array(z.string()).optional().describe('Labels to add to reply'),\n})\n\nexport const UpdateMessageParams = z.object({\n inbox_id: z.string().describe('ID of inbox to update message from'),\n message_id: z.string().describe('ID of message to update'),\n add_labels: z.array(z.string()).optional().describe('Labels to add to message'),\n remove_labels: z.array(z.string()).optional().describe('Labels to remove from message'),\n})\n\nexport const ListDraftsParams = ListInboxItemsParams.extend({\n inbox_id: z.string().describe('ID of inbox to list drafts from'),\n})\n\nexport const GetDraftParams = z.object({\n inbox_id: z.string().describe('ID of inbox to get draft from'),\n draft_id: z.string().describe('ID of draft to get'),\n})\n\nexport const CreateDraftParams = z.object({\n inbox_id: z.string().describe('ID of inbox to create draft from'),\n to: z.array(z.string()).describe('Recipients of draft'),\n cc: z.array(z.string()).optional().describe('CC recipients of draft'),\n bcc: z.array(z.string()).optional().describe('BCC recipients of draft'),\n subject: z.string().optional().describe('Subject of draft'),\n text: z.string().optional().describe('Plain text body of draft'),\n html: z.string().optional().describe('HTML body of draft'),\n labels: z.array(z.string()).optional().describe('Labels to add to draft'),\n})\n\nexport const SendDraftParams = z.object({\n inbox_id: z.string().describe('ID of inbox to send draft from'),\n draft_id: z.string().describe('ID of draft to send'),\n add_labels: z.array(z.string()).optional().describe('Labels to add to sent message'),\n remove_labels: z.array(z.string()).optional().describe('Labels to remove from sent message'),\n})\n","import { AnyZodObject } from 'zod'\n\nimport {\n ListItemsParams,\n ListInboxItemsParams,\n GetInboxParams,\n CreateInboxParams,\n ListThreadsParams,\n GetThreadParams,\n SendMessageParams,\n ReplyToMessageParams,\n UpdateMessageParams,\n ListDraftsParams,\n GetDraftParams,\n CreateDraftParams,\n SendDraftParams,\n} from './schemas'\n\nexport interface Tool {\n name: string\n method: string\n description: string\n schema: AnyZodObject\n}\n\nexport const tools: Tool[] = [\n {\n name: 'list_inboxes',\n method: 'inboxes.list',\n description: 'List inboxes',\n schema: ListItemsParams,\n },\n {\n name: 'get_inbox',\n method: 'inboxes.get',\n description: 'Get inbox',\n schema: GetInboxParams,\n },\n {\n name: 'create_inbox',\n method: 'inboxes.create',\n description: 'Create inbox',\n schema: CreateInboxParams,\n },\n {\n name: 'list_threads',\n method: 'inboxes.threads.list',\n description: 'List threads in inbox',\n schema: ListThreadsParams,\n },\n {\n name: 'list_all_threads',\n method: 'threads.list',\n description: 'List threads in all inboxes',\n schema: ListInboxItemsParams,\n },\n {\n name: 'get_thread',\n method: 'threads.get',\n description: 'Get thread',\n schema: GetThreadParams,\n },\n {\n name: 'send_message',\n method: 'inboxes.messages.send',\n description: 'Send message',\n schema: SendMessageParams,\n },\n {\n name: 'reply_to_message',\n method: 'inboxes.messages.reply',\n description: 'Reply to message',\n schema: ReplyToMessageParams,\n },\n {\n name: 'update_message',\n method: 'inboxes.messages.update',\n description: 'Update message',\n schema: UpdateMessageParams,\n },\n {\n name: 'list_drafts',\n method: 'inboxes.drafts.list',\n description: 'List drafts in inbox',\n schema: ListDraftsParams,\n },\n {\n name: 'list_all_drafts',\n method: 'drafts.list',\n description: 'List drafts in all inboxes',\n schema: ListInboxItemsParams,\n },\n {\n name: 'get_draft',\n method: 'drafts.get',\n description: 'Get draft',\n schema: GetDraftParams,\n },\n {\n name: 'create_draft',\n method: 'inboxes.drafts.create',\n description: 'Create draft',\n schema: CreateDraftParams,\n },\n {\n name: 'send_draft',\n method: 'inboxes.drafts.send',\n description: 'Send draft',\n schema: SendDraftParams,\n },\n]\n","import { AgentMailClient } from 'agentmail'\n\nimport { Wrapper } from './wrapper'\nimport { type Tool, tools } from './tools'\n\nexport abstract class BaseToolkit<T> extends Wrapper {\n protected readonly tools: Record<string, T> = {}\n\n constructor(client?: AgentMailClient) {\n super(client)\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"],"mappings":";AAAA,SAAS,uBAAuB;AAEzB,IAAM,UAAN,MAAc;AAAA,EACjB,YAA6B,SAAS,IAAI,gBAAgB,GAAG;AAAhC;AAAA,EAAiC;AAAA,EAE9D,MAAa,KAAK,QAAgB,MAAW;AACzC,UAAM,QAAQ,OAAO,MAAM,GAAG;AAC9B,UAAM,YAAY,MAAM,IAAI;AAE5B,QAAI,CAAC,UAAW,OAAM,IAAI,MAAM,mBAAmB;AAEnD,QAAI,SAAc,KAAK;AACvB,eAAW,QAAQ,MAAO,UAAS,OAAO,IAAI;AAE9C,UAAM,EAAE,UAAU,WAAW,YAAY,UAAU,eAAe,GAAG,QAAQ,IAAI;AACjF,UAAM,aAAa,CAAC,UAAU,WAAW,YAAY,UAAU,eAAe,OAAO,EAA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|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
19
|
-
ascending: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
-
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
limit?: number | undefined;
|
|
22
|
-
page_token?: string | undefined;
|
|
23
|
-
labels?: string[] | undefined;
|
|
24
|
-
ascending?: boolean | undefined;
|
|
25
|
-
}, {
|
|
26
|
-
limit?: number | undefined;
|
|
27
|
-
page_token?: string | undefined;
|
|
28
|
-
labels?: string[] | undefined;
|
|
29
|
-
ascending?: boolean | undefined;
|
|
30
|
-
}>;
|
|
31
|
-
declare const GetInboxParams: z.ZodObject<{
|
|
32
|
-
inbox_id: z.ZodString;
|
|
33
|
-
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
inbox_id: string;
|
|
35
|
-
}, {
|
|
36
|
-
inbox_id: string;
|
|
37
|
-
}>;
|
|
38
|
-
declare const CreateInboxParams: z.ZodObject<{
|
|
39
|
-
username: z.ZodOptional<z.ZodString>;
|
|
40
|
-
domain: z.ZodOptional<z.ZodString>;
|
|
41
|
-
display_name: z.ZodOptional<z.ZodString>;
|
|
42
|
-
}, "strip", z.ZodTypeAny, {
|
|
43
|
-
username?: string | undefined;
|
|
44
|
-
domain?: string | undefined;
|
|
45
|
-
display_name?: string | undefined;
|
|
46
|
-
}, {
|
|
47
|
-
username?: string | undefined;
|
|
48
|
-
domain?: string | undefined;
|
|
49
|
-
display_name?: string | undefined;
|
|
50
|
-
}>;
|
|
51
|
-
declare const ListThreadsParams: z.ZodObject<{
|
|
52
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
53
|
-
page_token: z.ZodOptional<z.ZodString>;
|
|
54
|
-
} & {
|
|
55
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
56
|
-
ascending: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
-
} & {
|
|
58
|
-
inbox_id: z.ZodString;
|
|
59
|
-
}, "strip", z.ZodTypeAny, {
|
|
60
|
-
inbox_id: string;
|
|
61
|
-
limit?: number | undefined;
|
|
62
|
-
page_token?: string | undefined;
|
|
63
|
-
labels?: string[] | undefined;
|
|
64
|
-
ascending?: boolean | undefined;
|
|
65
|
-
}, {
|
|
66
|
-
inbox_id: string;
|
|
67
|
-
limit?: number | undefined;
|
|
68
|
-
page_token?: string | undefined;
|
|
69
|
-
labels?: string[] | undefined;
|
|
70
|
-
ascending?: boolean | undefined;
|
|
71
|
-
}>;
|
|
72
|
-
declare const GetThreadParams: z.ZodObject<{
|
|
73
|
-
thread_id: z.ZodString;
|
|
74
|
-
}, "strip", z.ZodTypeAny, {
|
|
75
|
-
thread_id: string;
|
|
76
|
-
}, {
|
|
77
|
-
thread_id: string;
|
|
78
|
-
}>;
|
|
79
|
-
declare const SendMessageParams: z.ZodObject<{
|
|
80
|
-
inbox_id: z.ZodString;
|
|
81
|
-
to: z.ZodArray<z.ZodString, "many">;
|
|
82
|
-
cc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
83
|
-
bcc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
84
|
-
subject: z.ZodOptional<z.ZodString>;
|
|
85
|
-
text: z.ZodOptional<z.ZodString>;
|
|
86
|
-
html: z.ZodOptional<z.ZodString>;
|
|
87
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
88
|
-
}, "strip", z.ZodTypeAny, {
|
|
89
|
-
inbox_id: string;
|
|
90
|
-
to: string[];
|
|
91
|
-
labels?: string[] | undefined;
|
|
92
|
-
cc?: string[] | undefined;
|
|
93
|
-
bcc?: string[] | undefined;
|
|
94
|
-
subject?: string | undefined;
|
|
95
|
-
text?: string | undefined;
|
|
96
|
-
html?: string | undefined;
|
|
97
|
-
}, {
|
|
98
|
-
inbox_id: string;
|
|
99
|
-
to: string[];
|
|
100
|
-
labels?: string[] | undefined;
|
|
101
|
-
cc?: string[] | undefined;
|
|
102
|
-
bcc?: string[] | undefined;
|
|
103
|
-
subject?: string | undefined;
|
|
104
|
-
text?: string | undefined;
|
|
105
|
-
html?: string | undefined;
|
|
106
|
-
}>;
|
|
107
|
-
declare const ReplyToMessageParams: z.ZodObject<{
|
|
108
|
-
inbox_id: z.ZodString;
|
|
109
|
-
message_id: z.ZodString;
|
|
110
|
-
text: z.ZodOptional<z.ZodString>;
|
|
111
|
-
html: z.ZodOptional<z.ZodString>;
|
|
112
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
113
|
-
}, "strip", z.ZodTypeAny, {
|
|
114
|
-
inbox_id: string;
|
|
115
|
-
message_id: string;
|
|
116
|
-
labels?: string[] | undefined;
|
|
117
|
-
text?: string | undefined;
|
|
118
|
-
html?: string | undefined;
|
|
119
|
-
}, {
|
|
120
|
-
inbox_id: string;
|
|
121
|
-
message_id: string;
|
|
122
|
-
labels?: string[] | undefined;
|
|
123
|
-
text?: string | undefined;
|
|
124
|
-
html?: string | undefined;
|
|
125
|
-
}>;
|
|
126
|
-
declare const UpdateMessageParams: z.ZodObject<{
|
|
127
|
-
inbox_id: z.ZodString;
|
|
128
|
-
message_id: z.ZodString;
|
|
129
|
-
add_labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
130
|
-
remove_labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
131
|
-
}, "strip", z.ZodTypeAny, {
|
|
132
|
-
inbox_id: string;
|
|
133
|
-
message_id: string;
|
|
134
|
-
add_labels?: string[] | undefined;
|
|
135
|
-
remove_labels?: string[] | undefined;
|
|
136
|
-
}, {
|
|
137
|
-
inbox_id: string;
|
|
138
|
-
message_id: string;
|
|
139
|
-
add_labels?: string[] | undefined;
|
|
140
|
-
remove_labels?: string[] | undefined;
|
|
141
|
-
}>;
|
|
142
|
-
declare const ListDraftsParams: z.ZodObject<{
|
|
143
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
144
|
-
page_token: z.ZodOptional<z.ZodString>;
|
|
145
|
-
} & {
|
|
146
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
147
|
-
ascending: z.ZodOptional<z.ZodBoolean>;
|
|
148
|
-
} & {
|
|
149
|
-
inbox_id: z.ZodString;
|
|
150
|
-
}, "strip", z.ZodTypeAny, {
|
|
151
|
-
inbox_id: string;
|
|
152
|
-
limit?: number | undefined;
|
|
153
|
-
page_token?: string | undefined;
|
|
154
|
-
labels?: string[] | undefined;
|
|
155
|
-
ascending?: boolean | undefined;
|
|
156
|
-
}, {
|
|
157
|
-
inbox_id: string;
|
|
158
|
-
limit?: number | undefined;
|
|
159
|
-
page_token?: string | undefined;
|
|
160
|
-
labels?: string[] | undefined;
|
|
161
|
-
ascending?: boolean | undefined;
|
|
162
|
-
}>;
|
|
163
|
-
declare const GetDraftParams: z.ZodObject<{
|
|
164
|
-
inbox_id: z.ZodString;
|
|
165
|
-
draft_id: z.ZodString;
|
|
166
|
-
}, "strip", z.ZodTypeAny, {
|
|
167
|
-
inbox_id: string;
|
|
168
|
-
draft_id: string;
|
|
169
|
-
}, {
|
|
170
|
-
inbox_id: string;
|
|
171
|
-
draft_id: string;
|
|
172
|
-
}>;
|
|
173
|
-
declare const CreateDraftParams: z.ZodObject<{
|
|
174
|
-
inbox_id: z.ZodString;
|
|
175
|
-
to: z.ZodArray<z.ZodString, "many">;
|
|
176
|
-
cc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
177
|
-
bcc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
178
|
-
subject: z.ZodOptional<z.ZodString>;
|
|
179
|
-
text: z.ZodOptional<z.ZodString>;
|
|
180
|
-
html: z.ZodOptional<z.ZodString>;
|
|
181
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
182
|
-
}, "strip", z.ZodTypeAny, {
|
|
183
|
-
inbox_id: string;
|
|
184
|
-
to: string[];
|
|
185
|
-
labels?: string[] | undefined;
|
|
186
|
-
cc?: string[] | undefined;
|
|
187
|
-
bcc?: string[] | undefined;
|
|
188
|
-
subject?: string | undefined;
|
|
189
|
-
text?: string | undefined;
|
|
190
|
-
html?: string | undefined;
|
|
191
|
-
}, {
|
|
192
|
-
inbox_id: string;
|
|
193
|
-
to: string[];
|
|
194
|
-
labels?: string[] | undefined;
|
|
195
|
-
cc?: string[] | undefined;
|
|
196
|
-
bcc?: string[] | undefined;
|
|
197
|
-
subject?: string | undefined;
|
|
198
|
-
text?: string | undefined;
|
|
199
|
-
html?: string | undefined;
|
|
200
|
-
}>;
|
|
201
|
-
declare const SendDraftParams: z.ZodObject<{
|
|
202
|
-
inbox_id: z.ZodString;
|
|
203
|
-
draft_id: z.ZodString;
|
|
204
|
-
add_labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
205
|
-
remove_labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
206
|
-
}, "strip", z.ZodTypeAny, {
|
|
207
|
-
inbox_id: string;
|
|
208
|
-
draft_id: string;
|
|
209
|
-
add_labels?: string[] | undefined;
|
|
210
|
-
remove_labels?: string[] | undefined;
|
|
211
|
-
}, {
|
|
212
|
-
inbox_id: string;
|
|
213
|
-
draft_id: string;
|
|
214
|
-
add_labels?: string[] | undefined;
|
|
215
|
-
remove_labels?: string[] | undefined;
|
|
216
|
-
}>;
|
|
5
|
+
type Tool = {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
schema: z.AnyZodObject;
|
|
9
|
+
fn: (args: any) => Promise<any>;
|
|
10
|
+
};
|
|
11
|
+
declare class AgentMailToolkit extends ListToolkit<Tool> {
|
|
12
|
+
protected buildTool(tool: Tool$1): {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
schema: z.AnyZodObject;
|
|
16
|
+
fn: (args: z.infer<typeof tool.schema>) => Promise<any>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
217
19
|
|
|
218
|
-
export {
|
|
20
|
+
export { AgentMailToolkit };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,218 +1,20 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
2
|
+
import { L as ListToolkit, T as Tool$1 } from './toolkit-B8QHBdtC.js';
|
|
3
|
+
import 'agentmail';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
19
|
-
ascending: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
-
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
limit?: number | undefined;
|
|
22
|
-
page_token?: string | undefined;
|
|
23
|
-
labels?: string[] | undefined;
|
|
24
|
-
ascending?: boolean | undefined;
|
|
25
|
-
}, {
|
|
26
|
-
limit?: number | undefined;
|
|
27
|
-
page_token?: string | undefined;
|
|
28
|
-
labels?: string[] | undefined;
|
|
29
|
-
ascending?: boolean | undefined;
|
|
30
|
-
}>;
|
|
31
|
-
declare const GetInboxParams: z.ZodObject<{
|
|
32
|
-
inbox_id: z.ZodString;
|
|
33
|
-
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
inbox_id: string;
|
|
35
|
-
}, {
|
|
36
|
-
inbox_id: string;
|
|
37
|
-
}>;
|
|
38
|
-
declare const CreateInboxParams: z.ZodObject<{
|
|
39
|
-
username: z.ZodOptional<z.ZodString>;
|
|
40
|
-
domain: z.ZodOptional<z.ZodString>;
|
|
41
|
-
display_name: z.ZodOptional<z.ZodString>;
|
|
42
|
-
}, "strip", z.ZodTypeAny, {
|
|
43
|
-
username?: string | undefined;
|
|
44
|
-
domain?: string | undefined;
|
|
45
|
-
display_name?: string | undefined;
|
|
46
|
-
}, {
|
|
47
|
-
username?: string | undefined;
|
|
48
|
-
domain?: string | undefined;
|
|
49
|
-
display_name?: string | undefined;
|
|
50
|
-
}>;
|
|
51
|
-
declare const ListThreadsParams: z.ZodObject<{
|
|
52
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
53
|
-
page_token: z.ZodOptional<z.ZodString>;
|
|
54
|
-
} & {
|
|
55
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
56
|
-
ascending: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
-
} & {
|
|
58
|
-
inbox_id: z.ZodString;
|
|
59
|
-
}, "strip", z.ZodTypeAny, {
|
|
60
|
-
inbox_id: string;
|
|
61
|
-
limit?: number | undefined;
|
|
62
|
-
page_token?: string | undefined;
|
|
63
|
-
labels?: string[] | undefined;
|
|
64
|
-
ascending?: boolean | undefined;
|
|
65
|
-
}, {
|
|
66
|
-
inbox_id: string;
|
|
67
|
-
limit?: number | undefined;
|
|
68
|
-
page_token?: string | undefined;
|
|
69
|
-
labels?: string[] | undefined;
|
|
70
|
-
ascending?: boolean | undefined;
|
|
71
|
-
}>;
|
|
72
|
-
declare const GetThreadParams: z.ZodObject<{
|
|
73
|
-
thread_id: z.ZodString;
|
|
74
|
-
}, "strip", z.ZodTypeAny, {
|
|
75
|
-
thread_id: string;
|
|
76
|
-
}, {
|
|
77
|
-
thread_id: string;
|
|
78
|
-
}>;
|
|
79
|
-
declare const SendMessageParams: z.ZodObject<{
|
|
80
|
-
inbox_id: z.ZodString;
|
|
81
|
-
to: z.ZodArray<z.ZodString, "many">;
|
|
82
|
-
cc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
83
|
-
bcc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
84
|
-
subject: z.ZodOptional<z.ZodString>;
|
|
85
|
-
text: z.ZodOptional<z.ZodString>;
|
|
86
|
-
html: z.ZodOptional<z.ZodString>;
|
|
87
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
88
|
-
}, "strip", z.ZodTypeAny, {
|
|
89
|
-
inbox_id: string;
|
|
90
|
-
to: string[];
|
|
91
|
-
labels?: string[] | undefined;
|
|
92
|
-
cc?: string[] | undefined;
|
|
93
|
-
bcc?: string[] | undefined;
|
|
94
|
-
subject?: string | undefined;
|
|
95
|
-
text?: string | undefined;
|
|
96
|
-
html?: string | undefined;
|
|
97
|
-
}, {
|
|
98
|
-
inbox_id: string;
|
|
99
|
-
to: string[];
|
|
100
|
-
labels?: string[] | undefined;
|
|
101
|
-
cc?: string[] | undefined;
|
|
102
|
-
bcc?: string[] | undefined;
|
|
103
|
-
subject?: string | undefined;
|
|
104
|
-
text?: string | undefined;
|
|
105
|
-
html?: string | undefined;
|
|
106
|
-
}>;
|
|
107
|
-
declare const ReplyToMessageParams: z.ZodObject<{
|
|
108
|
-
inbox_id: z.ZodString;
|
|
109
|
-
message_id: z.ZodString;
|
|
110
|
-
text: z.ZodOptional<z.ZodString>;
|
|
111
|
-
html: z.ZodOptional<z.ZodString>;
|
|
112
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
113
|
-
}, "strip", z.ZodTypeAny, {
|
|
114
|
-
inbox_id: string;
|
|
115
|
-
message_id: string;
|
|
116
|
-
labels?: string[] | undefined;
|
|
117
|
-
text?: string | undefined;
|
|
118
|
-
html?: string | undefined;
|
|
119
|
-
}, {
|
|
120
|
-
inbox_id: string;
|
|
121
|
-
message_id: string;
|
|
122
|
-
labels?: string[] | undefined;
|
|
123
|
-
text?: string | undefined;
|
|
124
|
-
html?: string | undefined;
|
|
125
|
-
}>;
|
|
126
|
-
declare const UpdateMessageParams: z.ZodObject<{
|
|
127
|
-
inbox_id: z.ZodString;
|
|
128
|
-
message_id: z.ZodString;
|
|
129
|
-
add_labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
130
|
-
remove_labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
131
|
-
}, "strip", z.ZodTypeAny, {
|
|
132
|
-
inbox_id: string;
|
|
133
|
-
message_id: string;
|
|
134
|
-
add_labels?: string[] | undefined;
|
|
135
|
-
remove_labels?: string[] | undefined;
|
|
136
|
-
}, {
|
|
137
|
-
inbox_id: string;
|
|
138
|
-
message_id: string;
|
|
139
|
-
add_labels?: string[] | undefined;
|
|
140
|
-
remove_labels?: string[] | undefined;
|
|
141
|
-
}>;
|
|
142
|
-
declare const ListDraftsParams: z.ZodObject<{
|
|
143
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
144
|
-
page_token: z.ZodOptional<z.ZodString>;
|
|
145
|
-
} & {
|
|
146
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
147
|
-
ascending: z.ZodOptional<z.ZodBoolean>;
|
|
148
|
-
} & {
|
|
149
|
-
inbox_id: z.ZodString;
|
|
150
|
-
}, "strip", z.ZodTypeAny, {
|
|
151
|
-
inbox_id: string;
|
|
152
|
-
limit?: number | undefined;
|
|
153
|
-
page_token?: string | undefined;
|
|
154
|
-
labels?: string[] | undefined;
|
|
155
|
-
ascending?: boolean | undefined;
|
|
156
|
-
}, {
|
|
157
|
-
inbox_id: string;
|
|
158
|
-
limit?: number | undefined;
|
|
159
|
-
page_token?: string | undefined;
|
|
160
|
-
labels?: string[] | undefined;
|
|
161
|
-
ascending?: boolean | undefined;
|
|
162
|
-
}>;
|
|
163
|
-
declare const GetDraftParams: z.ZodObject<{
|
|
164
|
-
inbox_id: z.ZodString;
|
|
165
|
-
draft_id: z.ZodString;
|
|
166
|
-
}, "strip", z.ZodTypeAny, {
|
|
167
|
-
inbox_id: string;
|
|
168
|
-
draft_id: string;
|
|
169
|
-
}, {
|
|
170
|
-
inbox_id: string;
|
|
171
|
-
draft_id: string;
|
|
172
|
-
}>;
|
|
173
|
-
declare const CreateDraftParams: z.ZodObject<{
|
|
174
|
-
inbox_id: z.ZodString;
|
|
175
|
-
to: z.ZodArray<z.ZodString, "many">;
|
|
176
|
-
cc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
177
|
-
bcc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
178
|
-
subject: z.ZodOptional<z.ZodString>;
|
|
179
|
-
text: z.ZodOptional<z.ZodString>;
|
|
180
|
-
html: z.ZodOptional<z.ZodString>;
|
|
181
|
-
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
182
|
-
}, "strip", z.ZodTypeAny, {
|
|
183
|
-
inbox_id: string;
|
|
184
|
-
to: string[];
|
|
185
|
-
labels?: string[] | undefined;
|
|
186
|
-
cc?: string[] | undefined;
|
|
187
|
-
bcc?: string[] | undefined;
|
|
188
|
-
subject?: string | undefined;
|
|
189
|
-
text?: string | undefined;
|
|
190
|
-
html?: string | undefined;
|
|
191
|
-
}, {
|
|
192
|
-
inbox_id: string;
|
|
193
|
-
to: string[];
|
|
194
|
-
labels?: string[] | undefined;
|
|
195
|
-
cc?: string[] | undefined;
|
|
196
|
-
bcc?: string[] | undefined;
|
|
197
|
-
subject?: string | undefined;
|
|
198
|
-
text?: string | undefined;
|
|
199
|
-
html?: string | undefined;
|
|
200
|
-
}>;
|
|
201
|
-
declare const SendDraftParams: z.ZodObject<{
|
|
202
|
-
inbox_id: z.ZodString;
|
|
203
|
-
draft_id: z.ZodString;
|
|
204
|
-
add_labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
205
|
-
remove_labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
206
|
-
}, "strip", z.ZodTypeAny, {
|
|
207
|
-
inbox_id: string;
|
|
208
|
-
draft_id: string;
|
|
209
|
-
add_labels?: string[] | undefined;
|
|
210
|
-
remove_labels?: string[] | undefined;
|
|
211
|
-
}, {
|
|
212
|
-
inbox_id: string;
|
|
213
|
-
draft_id: string;
|
|
214
|
-
add_labels?: string[] | undefined;
|
|
215
|
-
remove_labels?: string[] | undefined;
|
|
216
|
-
}>;
|
|
5
|
+
type Tool = {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
schema: z.AnyZodObject;
|
|
9
|
+
fn: (args: any) => Promise<any>;
|
|
10
|
+
};
|
|
11
|
+
declare class AgentMailToolkit extends ListToolkit<Tool> {
|
|
12
|
+
protected buildTool(tool: Tool$1): {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
schema: z.AnyZodObject;
|
|
16
|
+
fn: (args: z.infer<typeof tool.schema>) => Promise<any>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
217
19
|
|
|
218
|
-
export {
|
|
20
|
+
export { AgentMailToolkit };
|
package/dist/index.js
CHANGED
|
@@ -20,23 +20,36 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
|
|
24
|
-
CreateInboxParams: () => CreateInboxParams,
|
|
25
|
-
GetDraftParams: () => GetDraftParams,
|
|
26
|
-
GetInboxParams: () => GetInboxParams,
|
|
27
|
-
GetThreadParams: () => GetThreadParams,
|
|
28
|
-
ListDraftsParams: () => ListDraftsParams,
|
|
29
|
-
ListInboxItemsParams: () => ListInboxItemsParams,
|
|
30
|
-
ListItemsParams: () => ListItemsParams,
|
|
31
|
-
ListThreadsParams: () => ListThreadsParams,
|
|
32
|
-
ReplyToMessageParams: () => ReplyToMessageParams,
|
|
33
|
-
SendDraftParams: () => SendDraftParams,
|
|
34
|
-
SendMessageParams: () => SendMessageParams,
|
|
35
|
-
UpdateMessageParams: () => UpdateMessageParams,
|
|
36
|
-
tools: () => tools
|
|
23
|
+
AgentMailToolkit: () => AgentMailToolkit
|
|
37
24
|
});
|
|
38
25
|
module.exports = __toCommonJS(index_exports);
|
|
39
26
|
|
|
27
|
+
// src/wrapper.ts
|
|
28
|
+
var import_agentmail = require("agentmail");
|
|
29
|
+
var Wrapper = class {
|
|
30
|
+
constructor(client = new import_agentmail.AgentMailClient()) {
|
|
31
|
+
this.client = client;
|
|
32
|
+
}
|
|
33
|
+
async call(method, args) {
|
|
34
|
+
const parts = method.split(".");
|
|
35
|
+
const methodKey = parts.pop();
|
|
36
|
+
if (!methodKey) throw new Error("Method name empty");
|
|
37
|
+
let parent = this.client;
|
|
38
|
+
for (const part of parts) parent = parent[part];
|
|
39
|
+
const { inbox_id, thread_id, message_id, draft_id, attachment_id, ...options } = args;
|
|
40
|
+
const methodArgs = [inbox_id, thread_id, message_id, draft_id, attachment_id, options].filter(Boolean);
|
|
41
|
+
return await parent[methodKey].call(parent, ...methodArgs);
|
|
42
|
+
}
|
|
43
|
+
async safeCall(method, args) {
|
|
44
|
+
try {
|
|
45
|
+
return { isError: false, result: await this.call(method, args) };
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (error instanceof Error) return { isError: true, result: error.message };
|
|
48
|
+
else return { isError: true, result: "Unknown error" };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
40
53
|
// src/schemas.ts
|
|
41
54
|
var import_zod = require("zod");
|
|
42
55
|
var ListItemsParams = import_zod.z.object({
|
|
@@ -195,21 +208,44 @@ var tools = [
|
|
|
195
208
|
schema: SendDraftParams
|
|
196
209
|
}
|
|
197
210
|
];
|
|
211
|
+
|
|
212
|
+
// src/toolkit.ts
|
|
213
|
+
var BaseToolkit = class extends Wrapper {
|
|
214
|
+
tools = {};
|
|
215
|
+
constructor(client) {
|
|
216
|
+
super(client);
|
|
217
|
+
this.tools = tools.reduce(
|
|
218
|
+
(acc, tool) => {
|
|
219
|
+
acc[tool.name] = this.buildTool(tool);
|
|
220
|
+
return acc;
|
|
221
|
+
},
|
|
222
|
+
{}
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
var ListToolkit = class extends BaseToolkit {
|
|
227
|
+
getTools(names) {
|
|
228
|
+
if (!names) return Object.values(this.tools);
|
|
229
|
+
return names.reduce((acc, name) => {
|
|
230
|
+
if (name in this.tools) acc.push(this.tools[name]);
|
|
231
|
+
return acc;
|
|
232
|
+
}, []);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// src/index.ts
|
|
237
|
+
var AgentMailToolkit = class extends ListToolkit {
|
|
238
|
+
buildTool(tool) {
|
|
239
|
+
return {
|
|
240
|
+
name: tool.name,
|
|
241
|
+
description: tool.description,
|
|
242
|
+
schema: tool.schema,
|
|
243
|
+
fn: (args) => this.call(tool.method, args)
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
};
|
|
198
247
|
// Annotate the CommonJS export names for ESM import in node:
|
|
199
248
|
0 && (module.exports = {
|
|
200
|
-
|
|
201
|
-
CreateInboxParams,
|
|
202
|
-
GetDraftParams,
|
|
203
|
-
GetInboxParams,
|
|
204
|
-
GetThreadParams,
|
|
205
|
-
ListDraftsParams,
|
|
206
|
-
ListInboxItemsParams,
|
|
207
|
-
ListItemsParams,
|
|
208
|
-
ListThreadsParams,
|
|
209
|
-
ReplyToMessageParams,
|
|
210
|
-
SendDraftParams,
|
|
211
|
-
SendMessageParams,
|
|
212
|
-
UpdateMessageParams,
|
|
213
|
-
tools
|
|
249
|
+
AgentMailToolkit
|
|
214
250
|
});
|
|
215
251
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/schemas.ts","../src/tools.ts"],"sourcesContent":["export * from './schemas'\nexport * from './tools'\n","import { z } from 'zod'\n\nexport const ListItemsParams = z.object({\n limit: z.number().optional().describe('Max number of items to return'),\n page_token: z.string().optional().describe('Page token for pagination'),\n})\n\nexport const ListInboxItemsParams = ListItemsParams.extend({\n labels: z.array(z.string()).optional().describe('Labels to filter items by'),\n ascending: z.boolean().optional().describe('Sort items in ascending order'),\n})\n\nexport const GetInboxParams = z.object({\n inbox_id: z.string().describe('ID of inbox to get'),\n})\n\nexport const CreateInboxParams = z.object({\n username: z.string().optional().describe('Username of inbox to create'),\n domain: z.string().optional().describe('Domain of inbox to create'),\n display_name: z.string().optional().describe('Display name of inbox to create'),\n})\n\nexport const ListThreadsParams = ListInboxItemsParams.extend({\n inbox_id: z.string().describe('ID of inbox to list threads from'),\n})\n\nexport const GetThreadParams = z.object({\n thread_id: z.string().describe('ID of thread to get'),\n})\n\nexport const SendMessageParams = z.object({\n inbox_id: z.string().describe('ID of inbox to send message from'),\n to: z.array(z.string()).describe('Recipients of message'),\n cc: z.array(z.string()).optional().describe('CC recipients of message'),\n bcc: z.array(z.string()).optional().describe('BCC recipients of message'),\n subject: z.string().optional().describe('Subject of message'),\n text: z.string().optional().describe('Plain text body of message'),\n html: z.string().optional().describe('HTML body of message'),\n labels: z.array(z.string()).optional().describe('Labels to add to message'),\n})\n\nexport const ReplyToMessageParams = z.object({\n inbox_id: z.string().describe('ID of inbox to reply to message from'),\n message_id: z.string().describe('ID of message to reply to'),\n text: z.string().optional().describe('Plain text body of reply'),\n html: z.string().optional().describe('HTML body of reply'),\n labels: z.array(z.string()).optional().describe('Labels to add to reply'),\n})\n\nexport const UpdateMessageParams = z.object({\n inbox_id: z.string().describe('ID of inbox to update message from'),\n message_id: z.string().describe('ID of message to update'),\n add_labels: z.array(z.string()).optional().describe('Labels to add to message'),\n remove_labels: z.array(z.string()).optional().describe('Labels to remove from message'),\n})\n\nexport const ListDraftsParams = ListInboxItemsParams.extend({\n inbox_id: z.string().describe('ID of inbox to list drafts from'),\n})\n\nexport const GetDraftParams = z.object({\n inbox_id: z.string().describe('ID of inbox to get draft from'),\n draft_id: z.string().describe('ID of draft to get'),\n})\n\nexport const CreateDraftParams = z.object({\n inbox_id: z.string().describe('ID of inbox to create draft from'),\n to: z.array(z.string()).describe('Recipients of draft'),\n cc: z.array(z.string()).optional().describe('CC recipients of draft'),\n bcc: z.array(z.string()).optional().describe('BCC recipients of draft'),\n subject: z.string().optional().describe('Subject of draft'),\n text: z.string().optional().describe('Plain text body of draft'),\n html: z.string().optional().describe('HTML body of draft'),\n labels: z.array(z.string()).optional().describe('Labels to add to draft'),\n})\n\nexport const SendDraftParams = z.object({\n inbox_id: z.string().describe('ID of inbox to send draft from'),\n draft_id: z.string().describe('ID of draft to send'),\n add_labels: z.array(z.string()).optional().describe('Labels to add to sent message'),\n remove_labels: z.array(z.string()).optional().describe('Labels to remove from sent message'),\n})\n","import { AnyZodObject } from 'zod'\n\nimport {\n ListItemsParams,\n ListInboxItemsParams,\n GetInboxParams,\n CreateInboxParams,\n ListThreadsParams,\n GetThreadParams,\n SendMessageParams,\n ReplyToMessageParams,\n UpdateMessageParams,\n ListDraftsParams,\n GetDraftParams,\n CreateDraftParams,\n SendDraftParams,\n} from './schemas'\n\nexport interface Tool {\n name: string\n method: string\n description: string\n schema: AnyZodObject\n}\n\nexport const tools: Tool[] = [\n {\n name: 'list_inboxes',\n method: 'inboxes.list',\n description: 'List inboxes',\n schema: ListItemsParams,\n },\n {\n name: 'get_inbox',\n method: 'inboxes.get',\n description: 'Get inbox',\n schema: GetInboxParams,\n },\n {\n name: 'create_inbox',\n method: 'inboxes.create',\n description: 'Create inbox',\n schema: CreateInboxParams,\n },\n {\n name: 'list_threads',\n method: 'inboxes.threads.list',\n description: 'List threads in inbox',\n schema: ListThreadsParams,\n },\n {\n name: 'list_all_threads',\n method: 'threads.list',\n description: 'List threads in all inboxes',\n schema: ListInboxItemsParams,\n },\n {\n name: 'get_thread',\n method: 'threads.get',\n description: 'Get thread',\n schema: GetThreadParams,\n },\n {\n name: 'send_message',\n method: 'inboxes.messages.send',\n description: 'Send message',\n schema: SendMessageParams,\n },\n {\n name: 'reply_to_message',\n method: 'inboxes.messages.reply',\n description: 'Reply to message',\n schema: ReplyToMessageParams,\n },\n {\n name: 'update_message',\n method: 'inboxes.messages.update',\n description: 'Update message',\n schema: UpdateMessageParams,\n },\n {\n name: 'list_drafts',\n method: 'inboxes.drafts.list',\n description: 'List drafts in inbox',\n schema: ListDraftsParams,\n },\n {\n name: 'list_all_drafts',\n method: 'drafts.list',\n description: 'List drafts in all inboxes',\n schema: ListInboxItemsParams,\n },\n {\n name: 'get_draft',\n method: 'drafts.get',\n description: 'Get draft',\n schema: GetDraftParams,\n },\n {\n name: 'create_draft',\n method: 'inboxes.drafts.create',\n description: 'Create draft',\n schema: CreateDraftParams,\n },\n {\n name: 'send_draft',\n method: 'inboxes.drafts.send',\n description: 'Send draft',\n schema: SendDraftParams,\n },\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAEX,IAAM,kBAAkB,aAAE,OAAO;AAAA,EACpC,OAAO,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,+BAA+B;AAAA,EACrE,YAAY,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,2BAA2B;AAC1E,CAAC;AAEM,IAAM,uBAAuB,gBAAgB,OAAO;AAAA,EACvD,QAAQ,aAAE,MAAM,aAAE,OAAO,CAAC,EAAE,SAAS,EAAE,SAAS,2BAA2B;AAAA,EAC3E,WAAW,aAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,+BAA+B;AAC9E,CAAC;AAEM,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACnC,UAAU,aAAE,OAAO,EAAE,SAAS,oBAAoB;AACtD,CAAC;AAEM,IAAM,oBAAoB,aAAE,OAAO;AAAA,EACtC,UAAU,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,6BAA6B;AAAA,EACtE,QAAQ,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,2BAA2B;AAAA,EAClE,cAAc,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,iCAAiC;AAClF,CAAC;AAEM,IAAM,oBAAoB,qBAAqB,OAAO;AAAA,EACzD,UAAU,aAAE,OAAO,EAAE,SAAS,kCAAk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N,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AACJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/wrapper.ts","../src/schemas.ts","../src/tools.ts","../src/toolkit.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { ListToolkit } from './toolkit'\nimport { type Tool as BaseTool } from './tools'\n\ntype Tool = {\n name: string\n description: string\n schema: z.AnyZodObject\n fn: (args: any) => Promise<any>\n}\n\nexport class AgentMailToolkit extends ListToolkit<Tool> {\n protected buildTool(tool: BaseTool) {\n return {\n name: tool.name,\n description: tool.description,\n schema: tool.schema,\n fn: (args: z.infer<typeof tool.schema>) => this.call(tool.method, args),\n }\n }\n}\n","import { AgentMailClient } from 'agentmail'\n\nexport class Wrapper {\n constructor(private readonly client = new AgentMailClient()) {}\n\n public async call(method: string, args: any) {\n const parts = method.split('.')\n const methodKey = parts.pop()\n\n if (!methodKey) throw new Error('Method name empty')\n\n let parent: any = this.client\n for (const part of parts) parent = parent[part]\n\n const { inbox_id, thread_id, message_id, draft_id, attachment_id, ...options } = args\n const methodArgs = [inbox_id, thread_id, message_id, draft_id, attachment_id, options].filter(Boolean)\n\n return await parent[methodKey].call(parent, ...methodArgs)\n }\n\n public async safeCall(method: string, args: any) {\n try {\n return { isError: false, result: await this.call(method, 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}\n","import { z } from 'zod'\n\nexport const ListItemsParams = z.object({\n limit: z.number().optional().describe('Max number of items to return'),\n page_token: z.string().optional().describe('Page token for pagination'),\n})\n\nexport const ListInboxItemsParams = ListItemsParams.extend({\n labels: z.array(z.string()).optional().describe('Labels to filter items by'),\n ascending: z.boolean().optional().describe('Sort items in ascending order'),\n})\n\nexport const GetInboxParams = z.object({\n inbox_id: z.string().describe('ID of inbox to get'),\n})\n\nexport const CreateInboxParams = z.object({\n username: z.string().optional().describe('Username of inbox to create'),\n domain: z.string().optional().describe('Domain of inbox to create'),\n display_name: z.string().optional().describe('Display name of inbox to create'),\n})\n\nexport const ListThreadsParams = ListInboxItemsParams.extend({\n inbox_id: z.string().describe('ID of inbox to list threads from'),\n})\n\nexport const GetThreadParams = z.object({\n thread_id: z.string().describe('ID of thread to get'),\n})\n\nexport const SendMessageParams = z.object({\n inbox_id: z.string().describe('ID of inbox to send message from'),\n to: z.array(z.string()).describe('Recipients of message'),\n cc: z.array(z.string()).optional().describe('CC recipients of message'),\n bcc: z.array(z.string()).optional().describe('BCC recipients of message'),\n subject: z.string().optional().describe('Subject of message'),\n text: z.string().optional().describe('Plain text body of message'),\n html: z.string().optional().describe('HTML body of message'),\n labels: z.array(z.string()).optional().describe('Labels to add to message'),\n})\n\nexport const ReplyToMessageParams = z.object({\n inbox_id: z.string().describe('ID of inbox to reply to message from'),\n message_id: z.string().describe('ID of message to reply to'),\n text: z.string().optional().describe('Plain text body of reply'),\n html: z.string().optional().describe('HTML body of reply'),\n labels: z.array(z.string()).optional().describe('Labels to add to reply'),\n})\n\nexport const UpdateMessageParams = z.object({\n inbox_id: z.string().describe('ID of inbox to update message from'),\n message_id: z.string().describe('ID of message to update'),\n add_labels: z.array(z.string()).optional().describe('Labels to add to message'),\n remove_labels: z.array(z.string()).optional().describe('Labels to remove from message'),\n})\n\nexport const ListDraftsParams = ListInboxItemsParams.extend({\n inbox_id: z.string().describe('ID of inbox to list drafts from'),\n})\n\nexport const GetDraftParams = z.object({\n inbox_id: z.string().describe('ID of inbox to get draft from'),\n draft_id: z.string().describe('ID of draft to get'),\n})\n\nexport const CreateDraftParams = z.object({\n inbox_id: z.string().describe('ID of inbox to create draft from'),\n to: z.array(z.string()).describe('Recipients of draft'),\n cc: z.array(z.string()).optional().describe('CC recipients of draft'),\n bcc: z.array(z.string()).optional().describe('BCC recipients of draft'),\n subject: z.string().optional().describe('Subject of draft'),\n text: z.string().optional().describe('Plain text body of draft'),\n html: z.string().optional().describe('HTML body of draft'),\n labels: z.array(z.string()).optional().describe('Labels to add to draft'),\n})\n\nexport const SendDraftParams = z.object({\n inbox_id: z.string().describe('ID of inbox to send draft from'),\n draft_id: z.string().describe('ID of draft to send'),\n add_labels: z.array(z.string()).optional().describe('Labels to add to sent message'),\n remove_labels: z.array(z.string()).optional().describe('Labels to remove from sent message'),\n})\n","import { AnyZodObject } from 'zod'\n\nimport {\n ListItemsParams,\n ListInboxItemsParams,\n GetInboxParams,\n CreateInboxParams,\n ListThreadsParams,\n GetThreadParams,\n SendMessageParams,\n ReplyToMessageParams,\n UpdateMessageParams,\n ListDraftsParams,\n GetDraftParams,\n CreateDraftParams,\n SendDraftParams,\n} from './schemas'\n\nexport interface Tool {\n name: string\n method: string\n description: string\n schema: AnyZodObject\n}\n\nexport const tools: Tool[] = [\n {\n name: 'list_inboxes',\n method: 'inboxes.list',\n description: 'List inboxes',\n schema: ListItemsParams,\n },\n {\n name: 'get_inbox',\n method: 'inboxes.get',\n description: 'Get inbox',\n schema: GetInboxParams,\n },\n {\n name: 'create_inbox',\n method: 'inboxes.create',\n description: 'Create inbox',\n schema: CreateInboxParams,\n },\n {\n name: 'list_threads',\n method: 'inboxes.threads.list',\n description: 'List threads in inbox',\n schema: ListThreadsParams,\n },\n {\n name: 'list_all_threads',\n method: 'threads.list',\n description: 'List threads in all inboxes',\n schema: ListInboxItemsParams,\n },\n {\n name: 'get_thread',\n method: 'threads.get',\n description: 'Get thread',\n schema: GetThreadParams,\n },\n {\n name: 'send_message',\n method: 'inboxes.messages.send',\n description: 'Send message',\n schema: SendMessageParams,\n },\n {\n name: 'reply_to_message',\n method: 'inboxes.messages.reply',\n description: 'Reply to message',\n schema: ReplyToMessageParams,\n },\n {\n name: 'update_message',\n method: 'inboxes.messages.update',\n description: 'Update message',\n schema: UpdateMessageParams,\n },\n {\n name: 'list_drafts',\n method: 'inboxes.drafts.list',\n description: 'List drafts in inbox',\n schema: ListDraftsParams,\n },\n {\n name: 'list_all_drafts',\n method: 'drafts.list',\n description: 'List drafts in all inboxes',\n schema: ListInboxItemsParams,\n },\n {\n name: 'get_draft',\n method: 'drafts.get',\n description: 'Get draft',\n schema: GetDraftParams,\n },\n {\n name: 'create_draft',\n method: 'inboxes.drafts.create',\n description: 'Create draft',\n schema: CreateDraftParams,\n },\n {\n name: 'send_draft',\n method: 'inboxes.drafts.send',\n description: 'Send draft',\n schema: SendDraftParams,\n },\n]\n","import { AgentMailClient } from 'agentmail'\n\nimport { Wrapper } from './wrapper'\nimport { type Tool, tools } from './tools'\n\nexport abstract class BaseToolkit<T> extends Wrapper {\n protected readonly tools: Record<string, T> = {}\n\n constructor(client?: AgentMailClient) {\n super(client)\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAAgC;AAEzB,IAAM,UAAN,MAAc;AAAA,EACjB,YAA6B,SAAS,IAAI,iCAAgB,GAAG;AAAhC;AAAA,EAAiC;AAAA,EAE9D,MAAa,KAAK,QAAgB,MAAW;AACzC,UAAM,QAAQ,OAAO,MAAM,GAAG;AAC9B,UAAM,YAAY,MAAM,IAAI;AAE5B,QAAI,CAAC,UAAW,OA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
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from "./chunk-IDOYVQL3.mjs";
|
|
2
|
+
ListToolkit
|
|
3
|
+
} from "./chunk-NXBM2DQE.mjs";
|
|
4
|
+
|
|
5
|
+
// src/index.ts
|
|
6
|
+
var AgentMailToolkit = class extends ListToolkit {
|
|
7
|
+
buildTool(tool) {
|
|
8
|
+
return {
|
|
9
|
+
name: tool.name,
|
|
10
|
+
description: tool.description,
|
|
11
|
+
schema: tool.schema,
|
|
12
|
+
fn: (args) => this.call(tool.method, args)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
};
|
|
17
16
|
export {
|
|
18
|
-
|
|
19
|
-
CreateInboxParams,
|
|
20
|
-
GetDraftParams,
|
|
21
|
-
GetInboxParams,
|
|
22
|
-
GetThreadParams,
|
|
23
|
-
ListDraftsParams,
|
|
24
|
-
ListInboxItemsParams,
|
|
25
|
-
ListItemsParams,
|
|
26
|
-
ListThreadsParams,
|
|
27
|
-
ReplyToMessageParams,
|
|
28
|
-
SendDraftParams,
|
|
29
|
-
SendMessageParams,
|
|
30
|
-
UpdateMessageParams,
|
|
31
|
-
tools
|
|
17
|
+
AgentMailToolkit
|
|
32
18
|
};
|
|
33
19
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { ListToolkit } from './toolkit'\nimport { type Tool as BaseTool } from './tools'\n\ntype Tool = {\n name: string\n description: string\n schema: z.AnyZodObject\n fn: (args: any) => Promise<any>\n}\n\nexport class AgentMailToolkit extends ListToolkit<Tool> {\n protected buildTool(tool: BaseTool) {\n return {\n name: tool.name,\n description: tool.description,\n schema: tool.schema,\n fn: (args: z.infer<typeof tool.schema>) => this.call(tool.method, args),\n }\n }\n}\n"],"mappings":";;;;;AAYO,IAAM,mBAAN,cAA+B,YAAkB;AAAA,EAC1C,UAAU,MAAgB;AAChC,WAAO;AAAA,MACH,MAAM,KAAK;AAAA,MACX,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,MACb,IAAI,CAAC,SAAsC,KAAK,KAAK,KAAK,QAAQ,IAAI;AAAA,IAC1E;AAAA,EACJ;AACJ;","names":[]}
|
package/dist/langchain.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { StructuredTool } from '@langchain/core/tools';
|
|
2
|
-
import { L as ListToolkit } from './toolkit-
|
|
3
|
-
import { T as Tool } from './tools-Dzp_FZN_.mjs';
|
|
2
|
+
import { L as ListToolkit, T as Tool } from './toolkit-B8QHBdtC.mjs';
|
|
4
3
|
import 'agentmail';
|
|
5
4
|
import 'zod';
|
|
6
5
|
|
package/dist/langchain.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { StructuredTool } from '@langchain/core/tools';
|
|
2
|
-
import { L as ListToolkit } from './toolkit-
|
|
3
|
-
import { T as Tool } from './tools-Dzp_FZN_.js';
|
|
2
|
+
import { L as ListToolkit, T as Tool } from './toolkit-B8QHBdtC.js';
|
|
4
3
|
import 'agentmail';
|
|
5
4
|
import 'zod';
|
|
6
5
|
|
package/dist/langchain.mjs
CHANGED
package/dist/langchain.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/langchain.ts"],"sourcesContent":["import { type StructuredTool, tool as langchainTool } from '@langchain/core/tools'\n\nimport { ListToolkit } from './toolkit'\nimport { type Tool } from './tools'\n\nexport class AgentMailToolkit extends ListToolkit<StructuredTool> {\n protected buildTool(tool: Tool): StructuredTool {\n return langchainTool(async (args) => JSON.stringify((await this.safeCall(tool.method, args)).result, null, 2), {\n name: tool.name,\n description: tool.description,\n schema: tool.schema,\n })\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/langchain.ts"],"sourcesContent":["import { type StructuredTool, tool as langchainTool } from '@langchain/core/tools'\n\nimport { ListToolkit } from './toolkit'\nimport { type Tool } from './tools'\n\nexport class AgentMailToolkit extends ListToolkit<StructuredTool> {\n protected buildTool(tool: Tool): StructuredTool {\n return langchainTool(async (args) => JSON.stringify((await this.safeCall(tool.method, args)).result, null, 2), {\n name: tool.name,\n description: tool.description,\n schema: tool.schema,\n })\n }\n}\n"],"mappings":";;;;;AAAA,SAA8B,QAAQ,qBAAqB;AAKpD,IAAM,mBAAN,cAA+B,YAA4B;AAAA,EACpD,UAAU,MAA4B;AAC5C,WAAO,cAAc,OAAO,SAAS,KAAK,WAAW,MAAM,KAAK,SAAS,KAAK,QAAQ,IAAI,GAAG,QAAQ,MAAM,CAAC,GAAG;AAAA,MAC3G,MAAM,KAAK;AAAA,MACX,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,IACjB,CAAC;AAAA,EACL;AACJ;","names":[]}
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { ZodRawShape } from 'zod';
|
|
3
|
-
import { L as ListToolkit } from './toolkit-
|
|
4
|
-
import { T as Tool } from './tools-Dzp_FZN_.mjs';
|
|
3
|
+
import { L as ListToolkit, T as Tool } from './toolkit-B8QHBdtC.mjs';
|
|
5
4
|
import 'agentmail';
|
|
6
5
|
|
|
7
6
|
interface McpTool {
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { ZodRawShape } from 'zod';
|
|
3
|
-
import { L as ListToolkit } from './toolkit-
|
|
4
|
-
import { T as Tool } from './tools-Dzp_FZN_.js';
|
|
3
|
+
import { L as ListToolkit, T as Tool } from './toolkit-B8QHBdtC.js';
|
|
5
4
|
import 'agentmail';
|
|
6
5
|
|
|
7
6
|
interface McpTool {
|
package/dist/mcp.mjs
CHANGED
package/dist/mcp.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mcp.ts"],"sourcesContent":["import { type ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { type ZodRawShape } from 'zod'\n\nimport { ListToolkit } from './toolkit'\nimport { type Tool } from './tools'\n\ninterface McpTool {\n name: string\n description: string\n paramsSchema: ZodRawShape\n callback: ToolCallback<ZodRawShape>\n}\n\nexport class AgentMailToolkit extends ListToolkit<McpTool> {\n protected buildTool(tool: Tool): McpTool {\n return {\n name: tool.name,\n description: tool.description,\n paramsSchema: tool.schema.shape,\n callback: async (args) => {\n const { isError, result } = await this.safeCall(tool.method, args)\n return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }], isError }\n },\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/mcp.ts"],"sourcesContent":["import { type ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { type ZodRawShape } from 'zod'\n\nimport { ListToolkit } from './toolkit'\nimport { type Tool } from './tools'\n\ninterface McpTool {\n name: string\n description: string\n paramsSchema: ZodRawShape\n callback: ToolCallback<ZodRawShape>\n}\n\nexport class AgentMailToolkit extends ListToolkit<McpTool> {\n protected buildTool(tool: Tool): McpTool {\n return {\n name: tool.name,\n description: tool.description,\n paramsSchema: tool.schema.shape,\n callback: async (args) => {\n const { isError, result } = await this.safeCall(tool.method, args)\n return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }], isError }\n },\n }\n }\n}\n"],"mappings":";;;;;AAaO,IAAM,mBAAN,cAA+B,YAAqB;AAAA,EAC7C,UAAU,MAAqB;AACrC,WAAO;AAAA,MACH,MAAM,KAAK;AAAA,MACX,aAAa,KAAK;AAAA,MAClB,cAAc,KAAK,OAAO;AAAA,MAC1B,UAAU,OAAO,SAAS;AACtB,cAAM,EAAE,SAAS,OAAO,IAAI,MAAM,KAAK,SAAS,KAAK,QAAQ,IAAI;AACjE,eAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,EAAE,CAAC,GAAG,QAAQ;AAAA,MAClG;AAAA,IACJ;AAAA,EACJ;AACJ;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AgentMailClient } from 'agentmail';
|
|
2
|
+
import { AnyZodObject } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare class Wrapper {
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(client?: AgentMailClient);
|
|
7
|
+
call(method: string, args: any): Promise<any>;
|
|
8
|
+
safeCall(method: string, args: any): Promise<{
|
|
9
|
+
isError: boolean;
|
|
10
|
+
result: any;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface Tool {
|
|
15
|
+
name: string;
|
|
16
|
+
method: string;
|
|
17
|
+
description: string;
|
|
18
|
+
schema: AnyZodObject;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare abstract class BaseToolkit<T> extends Wrapper {
|
|
22
|
+
protected readonly tools: Record<string, T>;
|
|
23
|
+
constructor(client?: AgentMailClient);
|
|
24
|
+
protected abstract buildTool(tool: Tool): T;
|
|
25
|
+
}
|
|
26
|
+
declare abstract class ListToolkit<T> extends BaseToolkit<T> {
|
|
27
|
+
getTools(names?: string[]): T[];
|
|
28
|
+
}
|
|
29
|
+
declare abstract class MapToolkit<T> extends BaseToolkit<T> {
|
|
30
|
+
getTools(names?: string[]): Record<string, T>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { ListToolkit as L, MapToolkit as M, type Tool as T };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AgentMailClient } from 'agentmail';
|
|
2
|
+
import { AnyZodObject } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare class Wrapper {
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(client?: AgentMailClient);
|
|
7
|
+
call(method: string, args: any): Promise<any>;
|
|
8
|
+
safeCall(method: string, args: any): Promise<{
|
|
9
|
+
isError: boolean;
|
|
10
|
+
result: any;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface Tool {
|
|
15
|
+
name: string;
|
|
16
|
+
method: string;
|
|
17
|
+
description: string;
|
|
18
|
+
schema: AnyZodObject;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare abstract class BaseToolkit<T> extends Wrapper {
|
|
22
|
+
protected readonly tools: Record<string, T>;
|
|
23
|
+
constructor(client?: AgentMailClient);
|
|
24
|
+
protected abstract buildTool(tool: Tool): T;
|
|
25
|
+
}
|
|
26
|
+
declare abstract class ListToolkit<T> extends BaseToolkit<T> {
|
|
27
|
+
getTools(names?: string[]): T[];
|
|
28
|
+
}
|
|
29
|
+
declare abstract class MapToolkit<T> extends BaseToolkit<T> {
|
|
30
|
+
getTools(names?: string[]): Record<string, T>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { ListToolkit as L, MapToolkit as M, type Tool as T };
|