agentmail-toolkit 0.1.12 → 0.1.14
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 +2 -3
- package/dist/ai-sdk.d.ts +2 -3
- package/dist/ai-sdk.js +50 -48
- package/dist/ai-sdk.js.map +1 -1
- package/dist/ai-sdk.mjs +5 -8
- package/dist/ai-sdk.mjs.map +1 -1
- package/dist/chunk-7HJYREI4.mjs +165 -0
- package/dist/chunk-7HJYREI4.mjs.map +1 -0
- package/dist/chunk-MTGL2LMT.mjs +165 -0
- package/dist/chunk-MTGL2LMT.mjs.map +1 -0
- package/dist/langchain.d.mts +3 -6
- package/dist/langchain.d.ts +3 -6
- package/dist/langchain.js +52 -56
- package/dist/langchain.js.map +1 -1
- package/dist/langchain.mjs +6 -9
- package/dist/langchain.mjs.map +1 -1
- package/dist/toolkit-DicBg_sN.d.mts +30 -0
- package/dist/toolkit-DicBg_sN.d.ts +30 -0
- package/package.json +3 -2
package/dist/ai-sdk.d.mts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Tool } from 'ai';
|
|
2
2
|
import { AgentMailClient } from 'agentmail';
|
|
3
|
-
import {
|
|
3
|
+
import { M as MapToolkit, T as Tool$1 } from './toolkit-DicBg_sN.mjs';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
|
-
declare class AgentMailToolkit extends
|
|
6
|
+
declare class AgentMailToolkit extends MapToolkit<Tool> {
|
|
7
7
|
constructor(client?: AgentMailClient);
|
|
8
8
|
protected buildTool(tool: Tool$1): Tool;
|
|
9
|
-
getTools(): Record<string, Tool>;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export { AgentMailToolkit };
|
package/dist/ai-sdk.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Tool } from 'ai';
|
|
2
2
|
import { AgentMailClient } from 'agentmail';
|
|
3
|
-
import {
|
|
3
|
+
import { M as MapToolkit, T as Tool$1 } from './toolkit-DicBg_sN.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
|
-
declare class AgentMailToolkit extends
|
|
6
|
+
declare class AgentMailToolkit extends MapToolkit<Tool> {
|
|
7
7
|
constructor(client?: AgentMailClient);
|
|
8
8
|
protected buildTool(tool: Tool$1): Tool;
|
|
9
|
-
getTools(): Record<string, Tool>;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export { AgentMailToolkit };
|
package/dist/ai-sdk.js
CHANGED
|
@@ -24,8 +24,22 @@ __export(ai_sdk_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(ai_sdk_exports);
|
|
26
26
|
|
|
27
|
-
// src/
|
|
27
|
+
// src/wrapper.ts
|
|
28
28
|
var import_agentmail = require("agentmail");
|
|
29
|
+
var Wrapper = class {
|
|
30
|
+
constructor(client) {
|
|
31
|
+
this.client = client;
|
|
32
|
+
if (!this.client) this.client = new import_agentmail.AgentMailClient();
|
|
33
|
+
}
|
|
34
|
+
async callMethod(method, args) {
|
|
35
|
+
const parts = method.split(".");
|
|
36
|
+
const methodKey = parts.pop();
|
|
37
|
+
if (!methodKey) throw new Error("Method name empty");
|
|
38
|
+
let parent = this.client;
|
|
39
|
+
for (const part of parts) parent = parent[part];
|
|
40
|
+
return await parent[methodKey].call(parent, args);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
29
43
|
|
|
30
44
|
// src/schemas.ts
|
|
31
45
|
var import_zod = require("zod");
|
|
@@ -37,21 +51,21 @@ var GetInboxParams = import_zod.z.object({
|
|
|
37
51
|
inbox_id: import_zod.z.string().describe("The ID of the inbox to get")
|
|
38
52
|
});
|
|
39
53
|
var CreateInboxParams = import_zod.z.object({
|
|
40
|
-
username: import_zod.z.string().optional().describe("The username of the inbox to create
|
|
41
|
-
domain: import_zod.z.string().optional().describe("The domain of the inbox to create
|
|
42
|
-
display_name: import_zod.z.string().optional().describe("The display name of the inbox to create
|
|
54
|
+
username: import_zod.z.string().optional().describe("The username of the inbox to create"),
|
|
55
|
+
domain: import_zod.z.string().optional().describe("The domain of the inbox to create"),
|
|
56
|
+
display_name: import_zod.z.string().optional().describe("The display name of the inbox to create")
|
|
43
57
|
});
|
|
44
58
|
var ListThreadsParams = ListItemsParams.extend({
|
|
45
59
|
inbox_id: import_zod.z.string().describe("The ID of the inbox to list threads for"),
|
|
46
|
-
|
|
47
|
-
sent: import_zod.z.boolean().optional().describe("Whether to filter by sent threads")
|
|
60
|
+
labels: import_zod.z.array(import_zod.z.string()).optional().describe("The labels to filter threads by")
|
|
48
61
|
});
|
|
49
62
|
var GetThreadParams = import_zod.z.object({
|
|
50
63
|
inbox_id: import_zod.z.string().describe("The ID of the inbox to get the thread for"),
|
|
51
64
|
thread_id: import_zod.z.string().describe("The ID of the thread to get")
|
|
52
65
|
});
|
|
53
66
|
var ListMessagesParams = ListItemsParams.extend({
|
|
54
|
-
inbox_id: import_zod.z.string().describe("The ID of the inbox to list messages for")
|
|
67
|
+
inbox_id: import_zod.z.string().describe("The ID of the inbox to list messages for"),
|
|
68
|
+
labels: import_zod.z.array(import_zod.z.string()).optional().describe("The labels to filter messages by")
|
|
55
69
|
});
|
|
56
70
|
var GetMessageParams = import_zod.z.object({
|
|
57
71
|
inbox_id: import_zod.z.string().describe("The ID of the inbox to get the message for"),
|
|
@@ -72,7 +86,7 @@ var SendMessageParams = import_zod.z.object({
|
|
|
72
86
|
html: import_zod.z.string().optional().describe("The HTML body of the message")
|
|
73
87
|
});
|
|
74
88
|
var ReplyToMessageParams = import_zod.z.object({
|
|
75
|
-
inbox_id: import_zod.z.string().describe("The
|
|
89
|
+
inbox_id: import_zod.z.string().describe("The inbox ID of the inbox to reply to the message from"),
|
|
76
90
|
message_id: import_zod.z.string().describe("The message ID of the message you wish to reply to"),
|
|
77
91
|
text: import_zod.z.string().optional().describe("The plain text body of the reply"),
|
|
78
92
|
html: import_zod.z.string().optional().describe("The HTML body of the reply")
|
|
@@ -82,71 +96,71 @@ var ReplyToMessageParams = import_zod.z.object({
|
|
|
82
96
|
var tools = [
|
|
83
97
|
{
|
|
84
98
|
name: "list_inboxes",
|
|
85
|
-
|
|
99
|
+
method: "inboxes.list",
|
|
86
100
|
description: "List all inboxes",
|
|
87
|
-
|
|
101
|
+
schema: ListItemsParams
|
|
88
102
|
},
|
|
89
103
|
{
|
|
90
104
|
name: "get_inbox",
|
|
91
|
-
|
|
105
|
+
method: "inboxes.get",
|
|
92
106
|
description: "Get an inbox by ID",
|
|
93
|
-
|
|
107
|
+
schema: GetInboxParams
|
|
94
108
|
},
|
|
95
109
|
{
|
|
96
110
|
name: "create_inbox",
|
|
97
|
-
|
|
111
|
+
method: "inboxes.create",
|
|
98
112
|
description: "Create a new inbox",
|
|
99
|
-
|
|
113
|
+
schema: CreateInboxParams
|
|
100
114
|
},
|
|
101
115
|
{
|
|
102
116
|
name: "list_threads",
|
|
103
|
-
|
|
117
|
+
method: "threads.list",
|
|
104
118
|
description: "List all threads",
|
|
105
|
-
|
|
119
|
+
schema: ListThreadsParams
|
|
106
120
|
},
|
|
107
121
|
{
|
|
108
122
|
name: "get_thread",
|
|
109
|
-
|
|
123
|
+
method: "threads.get",
|
|
110
124
|
description: "Get a thread by ID",
|
|
111
|
-
|
|
125
|
+
schema: GetThreadParams
|
|
112
126
|
},
|
|
113
127
|
{
|
|
114
128
|
name: "list_messages",
|
|
115
|
-
|
|
129
|
+
method: "messages.list",
|
|
116
130
|
description: "List all messages",
|
|
117
|
-
|
|
131
|
+
schema: ListMessagesParams
|
|
118
132
|
},
|
|
119
133
|
{
|
|
120
134
|
name: "get_message",
|
|
121
|
-
|
|
135
|
+
method: "messages.get",
|
|
122
136
|
description: "Get a message by ID",
|
|
123
|
-
|
|
137
|
+
schema: GetMessageParams
|
|
124
138
|
},
|
|
125
139
|
{
|
|
126
140
|
name: "get_attachment",
|
|
127
|
-
|
|
141
|
+
method: "attachments.get",
|
|
128
142
|
description: "Get an attachment by ID",
|
|
129
|
-
|
|
143
|
+
schema: GetAttachmentParams
|
|
130
144
|
},
|
|
131
145
|
{
|
|
132
146
|
name: "send_message",
|
|
133
|
-
|
|
147
|
+
method: "messages.send",
|
|
134
148
|
description: "Send a message",
|
|
135
|
-
|
|
149
|
+
schema: SendMessageParams
|
|
136
150
|
},
|
|
137
151
|
{
|
|
138
152
|
name: "reply_to_message",
|
|
139
|
-
|
|
153
|
+
method: "messages.reply",
|
|
140
154
|
description: "Reply to a message",
|
|
141
|
-
|
|
155
|
+
schema: ReplyToMessageParams
|
|
142
156
|
}
|
|
143
157
|
];
|
|
144
158
|
|
|
145
159
|
// src/toolkit.ts
|
|
146
|
-
var
|
|
160
|
+
var MapToolkit = class extends Wrapper {
|
|
161
|
+
tools = {};
|
|
147
162
|
constructor(client) {
|
|
148
|
-
|
|
149
|
-
if (!this.client) this.client = new import_agentmail.AgentMailClient();
|
|
163
|
+
super(client);
|
|
150
164
|
this.tools = tools.reduce(
|
|
151
165
|
(acc, tool) => {
|
|
152
166
|
acc[tool.name] = this.buildTool(tool);
|
|
@@ -155,35 +169,23 @@ var Toolkit = class {
|
|
|
155
169
|
{}
|
|
156
170
|
);
|
|
157
171
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
// return this.tools
|
|
161
|
-
// }
|
|
162
|
-
async callMethod(methodName, args) {
|
|
163
|
-
const parts = methodName.split(".");
|
|
164
|
-
const methodKey = parts.pop();
|
|
165
|
-
if (!methodKey) throw new Error("Method name empty");
|
|
166
|
-
let parent = this.client;
|
|
167
|
-
for (const part of parts) parent = parent[part];
|
|
168
|
-
return await parent[methodKey].call(parent, args);
|
|
172
|
+
getTools() {
|
|
173
|
+
return this.tools;
|
|
169
174
|
}
|
|
170
175
|
};
|
|
171
176
|
|
|
172
177
|
// src/ai-sdk.ts
|
|
173
|
-
var AgentMailToolkit = class extends
|
|
178
|
+
var AgentMailToolkit = class extends MapToolkit {
|
|
174
179
|
constructor(client) {
|
|
175
180
|
super(client);
|
|
176
181
|
}
|
|
177
182
|
buildTool(tool) {
|
|
178
183
|
return {
|
|
179
184
|
description: tool.description,
|
|
180
|
-
parameters: tool.
|
|
181
|
-
execute: (args) => this.callMethod(tool.
|
|
185
|
+
parameters: tool.schema,
|
|
186
|
+
execute: (args) => this.callMethod(tool.method, args)
|
|
182
187
|
};
|
|
183
188
|
}
|
|
184
|
-
getTools() {
|
|
185
|
-
return this.tools;
|
|
186
|
-
}
|
|
187
189
|
};
|
|
188
190
|
// Annotate the CommonJS export names for ESM import in node:
|
|
189
191
|
0 && (module.exports = {
|
package/dist/ai-sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ai-sdk.ts","../src/toolkit.ts","../src/schemas.ts","../src/tools.ts"],"sourcesContent":["import { type Tool as AiSdkTool } from 'ai'\nimport { AgentMailClient } from 'agentmail'\n\nimport { Toolkit } from './toolkit'\nimport { type Tool } from './tools'\n\nexport class AgentMailToolkit extends Toolkit<AiSdkTool> {\n constructor(client?: AgentMailClient) {\n super(client)\n }\n\n protected buildTool(tool: Tool): AiSdkTool {\n return {\n description: tool.description,\n parameters: tool.paramsSchema,\n execute: (args) => this.callMethod(tool.methodName, args),\n }\n }\n\n public getTools() {\n return this.tools\n }\n}\n","import { AgentMailClient } from 'agentmail'\nimport { type Tool, tools } from './tools'\n\nexport abstract class Toolkit<T> {\n protected readonly tools: Record<string, T> = {}\n\n constructor(private readonly client?: AgentMailClient) {\n if (!this.client) this.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 // public getTools() {\n // return this.tools\n // }\n\n public async callMethod(methodName: string, args: unknown) {\n const parts = methodName.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 return await parent[methodKey].call(parent, args)\n }\n}\n","import { z } from 'zod'\n\nexport const ListItemsParams = z.object({\n limit: z.number().optional().describe('The maximum number of items to return'),\n last_key: z.string().optional().describe('The last key to use for pagination'),\n})\n\nexport const GetInboxParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get'),\n})\n\nexport const CreateInboxParams = z.object({\n username: z.string().optional().describe('The username of the inbox to create.'),\n domain: z.string().optional().describe('The domain of the inbox to create.'),\n display_name: z.string().optional().describe('The display name of the inbox to create.'),\n})\n\nexport const ListThreadsParams = ListItemsParams.extend({\n inbox_id: z.string().describe('The ID of the inbox to list threads for'),\n received: z.boolean().optional().describe('Whether to filter by received threads'),\n sent: z.boolean().optional().describe('Whether to filter by sent threads'),\n})\n\nexport const GetThreadParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the thread for'),\n thread_id: z.string().describe('The ID of the thread to get'),\n})\n\nexport const ListMessagesParams = ListItemsParams.extend({\n inbox_id: z.string().describe('The ID of the inbox to list messages for'),\n})\n\nexport const GetMessageParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the message for'),\n message_id: z.string().describe('The ID of the message to get'),\n})\n\nexport const GetAttachmentParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the attachment for'),\n message_id: z.string().describe('The ID of the message to get the attachment for'),\n attachment_id: z.string().describe('The ID of the attachment to get'),\n})\n\nexport const SendMessageParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to send the message from'),\n to: z.array(z.string()).describe('The list of recipients'),\n cc: z.array(z.string()).optional().describe('The list of CC recipients'),\n bcc: z.array(z.string()).optional().describe('The list of BCC recipients'),\n subject: z.string().optional().describe('The subject of the message'),\n text: z.string().optional().describe('The plain text body of the message'),\n html: z.string().optional().describe('The HTML body of the message'),\n})\n\nexport const ReplyToMessageParams = z.object({\n inbox_id: z.string().describe('The inboc ID of the inbox to reply to the message from'),\n message_id: z.string().describe('The message ID of the message you wish to reply to'),\n text: z.string().optional().describe('The plain text body of the reply'),\n html: z.string().optional().describe('The HTML body of the reply'),\n})\n","import { z } from 'zod'\n\nimport {\n ListItemsParams,\n GetInboxParams,\n CreateInboxParams,\n ListThreadsParams,\n GetThreadParams,\n ListMessagesParams,\n GetMessageParams,\n GetAttachmentParams,\n SendMessageParams,\n ReplyToMessageParams,\n} from './schemas'\n\nexport type Tool = {\n name: string\n methodName: string\n description: string\n paramsSchema: z.ZodObject<any>\n}\n\nexport const tools: Tool[] = [\n {\n name: 'list_inboxes',\n methodName: 'inboxes.list',\n description: 'List all inboxes',\n paramsSchema: ListItemsParams,\n },\n {\n name: 'get_inbox',\n methodName: 'inboxes.get',\n description: 'Get an inbox by ID',\n paramsSchema: GetInboxParams,\n },\n {\n name: 'create_inbox',\n methodName: 'inboxes.create',\n description: 'Create a new inbox',\n paramsSchema: CreateInboxParams,\n },\n {\n name: 'list_threads',\n methodName: 'threads.list',\n description: 'List all threads',\n paramsSchema: ListThreadsParams,\n },\n {\n name: 'get_thread',\n methodName: 'threads.get',\n description: 'Get a thread by ID',\n paramsSchema: GetThreadParams,\n },\n {\n name: 'list_messages',\n methodName: 'messages.list',\n description: 'List all messages',\n paramsSchema: ListMessagesParams,\n },\n {\n name: 'get_message',\n methodName: 'messages.get',\n description: 'Get a message by ID',\n paramsSchema: GetMessageParams,\n },\n {\n name: 'get_attachment',\n methodName: 'attachments.get',\n description: 'Get an attachment by ID',\n paramsSchema: GetAttachmentParams,\n },\n {\n name: 'send_message',\n methodName: 'messages.send',\n description: 'Send a message',\n paramsSchema: SendMessageParams,\n },\n {\n name: 'reply_to_message',\n methodName: 'messages.reply',\n description: 'Reply to a message',\n paramsSchema: ReplyToMessageParams,\n },\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAAgC;;;ACAhC,iBAAkB;AAEX,IAAM,kBAAkB,aAAE,OAAO;AAAA,EACpC,OAAO,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,uCAAuC;AAAA,EAC7E,UAAU,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AAAA,MACH,aAAa,KAAK;AAAA,MAClB,YAAY,KAAK;AAAA,MACjB,SAAS,CAAC,SAAS,KAAK,WAAW,KAAK,YAAY,IAAI;AAAA,IAC5D;AAAA,EACJ;AAAA,EAEO,WAAW;AACd,WAAO,KAAK;AAAA,EAChB;AACJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/ai-sdk.ts","../src/wrapper.ts","../src/schemas.ts","../src/tools.ts","../src/toolkit.ts"],"sourcesContent":["import { type Tool as AiSdkTool } from 'ai'\nimport { AgentMailClient } from 'agentmail'\n\nimport { MapToolkit } from './toolkit'\nimport { type Tool } from './tools'\n\nexport class AgentMailToolkit extends MapToolkit<AiSdkTool> {\n constructor(client?: AgentMailClient) {\n super(client)\n }\n\n protected buildTool(tool: Tool): AiSdkTool {\n return {\n description: tool.description,\n parameters: tool.schema,\n execute: (args) => this.callMethod(tool.method, args),\n }\n }\n}\n","import { AgentMailClient } from 'agentmail'\n\nexport class Wrapper {\n constructor(private readonly client?: AgentMailClient) {\n if (!this.client) this.client = new AgentMailClient()\n }\n\n public async callMethod(method: string, args: unknown) {\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 return await parent[methodKey].call(parent, args)\n }\n}\n","import { z } from 'zod'\n\nexport const ListItemsParams = z.object({\n limit: z.number().optional().describe('The maximum number of items to return'),\n last_key: z.string().optional().describe('The last key to use for pagination'),\n})\n\nexport const GetInboxParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get'),\n})\n\nexport const CreateInboxParams = z.object({\n username: z.string().optional().describe('The username of the inbox to create'),\n domain: z.string().optional().describe('The domain of the inbox to create'),\n display_name: z.string().optional().describe('The display name of the inbox to create'),\n})\n\nexport const ListThreadsParams = ListItemsParams.extend({\n inbox_id: z.string().describe('The ID of the inbox to list threads for'),\n labels: z.array(z.string()).optional().describe('The labels to filter threads by'),\n})\n\nexport const GetThreadParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the thread for'),\n thread_id: z.string().describe('The ID of the thread to get'),\n})\n\nexport const ListMessagesParams = ListItemsParams.extend({\n inbox_id: z.string().describe('The ID of the inbox to list messages for'),\n labels: z.array(z.string()).optional().describe('The labels to filter messages by'),\n})\n\nexport const GetMessageParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the message for'),\n message_id: z.string().describe('The ID of the message to get'),\n})\n\nexport const GetAttachmentParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the attachment for'),\n message_id: z.string().describe('The ID of the message to get the attachment for'),\n attachment_id: z.string().describe('The ID of the attachment to get'),\n})\n\nexport const SendMessageParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to send the message from'),\n to: z.array(z.string()).describe('The list of recipients'),\n cc: z.array(z.string()).optional().describe('The list of CC recipients'),\n bcc: z.array(z.string()).optional().describe('The list of BCC recipients'),\n subject: z.string().optional().describe('The subject of the message'),\n text: z.string().optional().describe('The plain text body of the message'),\n html: z.string().optional().describe('The HTML body of the message'),\n})\n\nexport const ReplyToMessageParams = z.object({\n inbox_id: z.string().describe('The inbox ID of the inbox to reply to the message from'),\n message_id: z.string().describe('The message ID of the message you wish to reply to'),\n text: z.string().optional().describe('The plain text body of the reply'),\n html: z.string().optional().describe('The HTML body of the reply'),\n})\n","import { AnyZodObject } from 'zod'\n\nimport {\n ListItemsParams,\n GetInboxParams,\n CreateInboxParams,\n ListThreadsParams,\n GetThreadParams,\n ListMessagesParams,\n GetMessageParams,\n GetAttachmentParams,\n SendMessageParams,\n ReplyToMessageParams,\n} from './schemas'\n\nexport type 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 all inboxes',\n schema: ListItemsParams,\n },\n {\n name: 'get_inbox',\n method: 'inboxes.get',\n description: 'Get an inbox by ID',\n schema: GetInboxParams,\n },\n {\n name: 'create_inbox',\n method: 'inboxes.create',\n description: 'Create a new inbox',\n schema: CreateInboxParams,\n },\n {\n name: 'list_threads',\n method: 'threads.list',\n description: 'List all threads',\n schema: ListThreadsParams,\n },\n {\n name: 'get_thread',\n method: 'threads.get',\n description: 'Get a thread by ID',\n schema: GetThreadParams,\n },\n {\n name: 'list_messages',\n method: 'messages.list',\n description: 'List all messages',\n schema: ListMessagesParams,\n },\n {\n name: 'get_message',\n method: 'messages.get',\n description: 'Get a message by ID',\n schema: GetMessageParams,\n },\n {\n name: 'get_attachment',\n method: 'attachments.get',\n description: 'Get an attachment by ID',\n schema: GetAttachmentParams,\n },\n {\n name: 'send_message',\n method: 'messages.send',\n description: 'Send a message',\n schema: SendMessageParams,\n },\n {\n name: 'reply_to_message',\n method: 'messages.reply',\n description: 'Reply to a message',\n schema: ReplyToMessageParams,\n },\n]\n","import { AgentMailClient } from 'agentmail'\n\nimport { Wrapper } from './wrapper'\nimport { type Tool, tools } from './tools'\n\nexport abstract class ListToolkit<T> extends Wrapper {\n protected readonly tools: T[] = []\n\n constructor(client?: AgentMailClient) {\n super(client)\n\n this.tools = tools.map((tool) => this.buildTool(tool))\n }\n\n protected abstract buildTool(tool: Tool): T\n\n public getTools() {\n return this.tools\n }\n}\n\nexport abstract class MapToolkit<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 public getTools() {\n return this.tools\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAAgC;AAEzB,IAAM,UAAN,MAAc;AAAA,EACjB,YAA6B,QAA0B;AAA1B;AACzB,QAAI,CAAC,KAAK,OAAQ,MAAK,SAAS,IAAI,iCAAgB;AAAA,EACxD;AAAA,EAEA,MAAa,WAAW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AAA,EAChB;AACJ;;;AJnCO,IAAM,mBAAN,cAA+B,WAAsB;AAAA,EACxD,YAAY,QAA0B;AAClC,UAAM,MAAM;AAAA,EAChB;AAAA,EAEU,UAAU,MAAuB;AACvC,WAAO;AAAA,MACH,aAAa,KAAK;AAAA,MAClB,YAAY,KAAK;AAAA,MACjB,SAAS,CAAC,SAAS,KAAK,WAAW,KAAK,QAAQ,IAAI;AAAA,IACxD;AAAA,EACJ;AACJ;","names":[]}
|
package/dist/ai-sdk.mjs
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
MapToolkit
|
|
3
|
+
} from "./chunk-MTGL2LMT.mjs";
|
|
4
4
|
|
|
5
5
|
// src/ai-sdk.ts
|
|
6
|
-
var AgentMailToolkit = class extends
|
|
6
|
+
var AgentMailToolkit = class extends MapToolkit {
|
|
7
7
|
constructor(client) {
|
|
8
8
|
super(client);
|
|
9
9
|
}
|
|
10
10
|
buildTool(tool) {
|
|
11
11
|
return {
|
|
12
12
|
description: tool.description,
|
|
13
|
-
parameters: tool.
|
|
14
|
-
execute: (args) => this.callMethod(tool.
|
|
13
|
+
parameters: tool.schema,
|
|
14
|
+
execute: (args) => this.callMethod(tool.method, args)
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
getTools() {
|
|
18
|
-
return this.tools;
|
|
19
|
-
}
|
|
20
17
|
};
|
|
21
18
|
export {
|
|
22
19
|
AgentMailToolkit
|
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'\nimport { AgentMailClient } from 'agentmail'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/ai-sdk.ts"],"sourcesContent":["import { type Tool as AiSdkTool } from 'ai'\nimport { AgentMailClient } from 'agentmail'\n\nimport { MapToolkit } from './toolkit'\nimport { type Tool } from './tools'\n\nexport class AgentMailToolkit extends MapToolkit<AiSdkTool> {\n constructor(client?: AgentMailClient) {\n super(client)\n }\n\n protected buildTool(tool: Tool): AiSdkTool {\n return {\n description: tool.description,\n parameters: tool.schema,\n execute: (args) => this.callMethod(tool.method, args),\n }\n }\n}\n"],"mappings":";;;;;AAMO,IAAM,mBAAN,cAA+B,WAAsB;AAAA,EACxD,YAAY,QAA0B;AAClC,UAAM,MAAM;AAAA,EAChB;AAAA,EAEU,UAAU,MAAuB;AACvC,WAAO;AAAA,MACH,aAAa,KAAK;AAAA,MAClB,YAAY,KAAK;AAAA,MACjB,SAAS,CAAC,SAAS,KAAK,WAAW,KAAK,QAAQ,IAAI;AAAA,IACxD;AAAA,EACJ;AACJ;","names":[]}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// src/wrapper.ts
|
|
2
|
+
import { AgentMailClient } from "agentmail";
|
|
3
|
+
var Wrapper = class {
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
if (!this.client) this.client = new AgentMailClient();
|
|
7
|
+
}
|
|
8
|
+
async callMethod(method, args) {
|
|
9
|
+
const parts = method.split(".");
|
|
10
|
+
const methodKey = parts.pop();
|
|
11
|
+
if (!methodKey) throw new Error("Method name empty");
|
|
12
|
+
let parent = this.client;
|
|
13
|
+
for (const part of parts) parent = parent[part];
|
|
14
|
+
return await parent[methodKey].call(parent, args);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/schemas.ts
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
var ListItemsParams = z.object({
|
|
21
|
+
limit: z.number().optional().describe("The maximum number of items to return"),
|
|
22
|
+
last_key: z.string().optional().describe("The last key to use for pagination. Only use the last_key value returned by the previous response.")
|
|
23
|
+
});
|
|
24
|
+
var GetInboxParams = z.object({
|
|
25
|
+
inbox_id: z.string().describe("The ID of the inbox to get")
|
|
26
|
+
});
|
|
27
|
+
var CreateInboxParams = z.object({
|
|
28
|
+
username: z.string().optional().describe("The username of the inbox to create."),
|
|
29
|
+
domain: z.string().optional().describe("The domain of the inbox to create."),
|
|
30
|
+
display_name: z.string().optional().describe("The display name of the inbox to create.")
|
|
31
|
+
});
|
|
32
|
+
var ListThreadsParams = ListItemsParams.extend({
|
|
33
|
+
inbox_id: z.string().describe("The ID of the inbox to list threads for"),
|
|
34
|
+
labels: z.array(z.string()).optional().describe("The labels to filter threads by")
|
|
35
|
+
});
|
|
36
|
+
var GetThreadParams = z.object({
|
|
37
|
+
inbox_id: z.string().describe("The ID of the inbox to get the thread for"),
|
|
38
|
+
thread_id: z.string().describe("The ID of the thread to get")
|
|
39
|
+
});
|
|
40
|
+
var ListMessagesParams = ListItemsParams.extend({
|
|
41
|
+
inbox_id: z.string().describe("The ID of the inbox to list messages for"),
|
|
42
|
+
labels: z.array(z.string()).optional().describe("The labels to filter messages by")
|
|
43
|
+
});
|
|
44
|
+
var GetMessageParams = z.object({
|
|
45
|
+
inbox_id: z.string().describe("The ID of the inbox to get the message for"),
|
|
46
|
+
message_id: z.string().describe("The ID of the message to get")
|
|
47
|
+
});
|
|
48
|
+
var GetAttachmentParams = z.object({
|
|
49
|
+
inbox_id: z.string().describe("The ID of the inbox to get the attachment for"),
|
|
50
|
+
message_id: z.string().describe("The ID of the message to get the attachment for"),
|
|
51
|
+
attachment_id: z.string().describe("The ID of the attachment to get")
|
|
52
|
+
});
|
|
53
|
+
var SendMessageParams = z.object({
|
|
54
|
+
inbox_id: z.string().describe("The ID of the inbox to send the message from"),
|
|
55
|
+
to: z.array(z.string()).describe("The list of recipients"),
|
|
56
|
+
cc: z.array(z.string()).optional().describe("The list of CC recipients"),
|
|
57
|
+
bcc: z.array(z.string()).optional().describe("The list of BCC recipients"),
|
|
58
|
+
subject: z.string().optional().describe("The subject of the message"),
|
|
59
|
+
text: z.string().optional().describe("The plain text body of the message"),
|
|
60
|
+
html: z.string().optional().describe("The HTML body of the message")
|
|
61
|
+
});
|
|
62
|
+
var ReplyToMessageParams = z.object({
|
|
63
|
+
inbox_id: z.string().describe("The inbox ID of the inbox to reply to the message from"),
|
|
64
|
+
message_id: z.string().describe("The message ID of the message you wish to reply to"),
|
|
65
|
+
text: z.string().optional().describe("The plain text body of the reply"),
|
|
66
|
+
html: z.string().optional().describe("The HTML body of the reply")
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// src/tools.ts
|
|
70
|
+
var tools = [
|
|
71
|
+
{
|
|
72
|
+
name: "list_inboxes",
|
|
73
|
+
method: "inboxes.list",
|
|
74
|
+
description: "List all inboxes",
|
|
75
|
+
schema: ListItemsParams
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "get_inbox",
|
|
79
|
+
method: "inboxes.get",
|
|
80
|
+
description: "Get an inbox by ID",
|
|
81
|
+
schema: GetInboxParams
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "create_inbox",
|
|
85
|
+
method: "inboxes.create",
|
|
86
|
+
description: "Create a new inbox",
|
|
87
|
+
schema: CreateInboxParams
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "list_threads",
|
|
91
|
+
method: "threads.list",
|
|
92
|
+
description: "List all threads",
|
|
93
|
+
schema: ListThreadsParams
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "get_thread",
|
|
97
|
+
method: "threads.get",
|
|
98
|
+
description: "Get a thread by ID",
|
|
99
|
+
schema: GetThreadParams
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "list_messages",
|
|
103
|
+
method: "messages.list",
|
|
104
|
+
description: "List all messages",
|
|
105
|
+
schema: ListMessagesParams
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "get_message",
|
|
109
|
+
method: "messages.get",
|
|
110
|
+
description: "Get a message by ID",
|
|
111
|
+
schema: GetMessageParams
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "get_attachment",
|
|
115
|
+
method: "attachments.get",
|
|
116
|
+
description: "Get an attachment by ID",
|
|
117
|
+
schema: GetAttachmentParams
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "send_message",
|
|
121
|
+
method: "messages.send",
|
|
122
|
+
description: "Send a message",
|
|
123
|
+
schema: SendMessageParams
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "reply_to_message",
|
|
127
|
+
method: "messages.reply",
|
|
128
|
+
description: "Reply to a message",
|
|
129
|
+
schema: ReplyToMessageParams
|
|
130
|
+
}
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
// src/toolkit.ts
|
|
134
|
+
var ListToolkit = class extends Wrapper {
|
|
135
|
+
tools = [];
|
|
136
|
+
constructor(client) {
|
|
137
|
+
super(client);
|
|
138
|
+
this.tools = tools.map((tool) => this.buildTool(tool));
|
|
139
|
+
}
|
|
140
|
+
getTools() {
|
|
141
|
+
return this.tools;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
var MapToolkit = class extends Wrapper {
|
|
145
|
+
tools = {};
|
|
146
|
+
constructor(client) {
|
|
147
|
+
super(client);
|
|
148
|
+
this.tools = tools.reduce(
|
|
149
|
+
(acc, tool) => {
|
|
150
|
+
acc[tool.name] = this.buildTool(tool);
|
|
151
|
+
return acc;
|
|
152
|
+
},
|
|
153
|
+
{}
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
getTools() {
|
|
157
|
+
return this.tools;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export {
|
|
162
|
+
ListToolkit,
|
|
163
|
+
MapToolkit
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=chunk-7HJYREI4.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?: AgentMailClient) {\n if (!this.client) this.client = new AgentMailClient()\n }\n\n public async callMethod(method: string, args: unknown) {\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 return await parent[methodKey].call(parent, args)\n }\n}\n","import { z } from 'zod'\n\nexport const ListItemsParams = z.object({\n limit: z.number().optional().describe('The maximum number of items to return'),\n last_key: z.string().optional().describe('The last key to use for pagination. Only use the last_key value returned by the previous response.'),\n})\n\nexport const GetInboxParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get'),\n})\n\nexport const CreateInboxParams = z.object({\n username: z.string().optional().describe('The username of the inbox to create.'),\n domain: z.string().optional().describe('The domain of the inbox to create.'),\n display_name: z.string().optional().describe('The display name of the inbox to create.'),\n})\n\nexport const ListThreadsParams = ListItemsParams.extend({\n inbox_id: z.string().describe('The ID of the inbox to list threads for'),\n labels: z.array(z.string()).optional().describe('The labels to filter threads by'),\n})\n\nexport const GetThreadParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the thread for'),\n thread_id: z.string().describe('The ID of the thread to get'),\n})\n\nexport const ListMessagesParams = ListItemsParams.extend({\n inbox_id: z.string().describe('The ID of the inbox to list messages for'),\n labels: z.array(z.string()).optional().describe('The labels to filter messages by'),\n})\n\nexport const GetMessageParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the message for'),\n message_id: z.string().describe('The ID of the message to get'),\n})\n\nexport const GetAttachmentParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the attachment for'),\n message_id: z.string().describe('The ID of the message to get the attachment for'),\n attachment_id: z.string().describe('The ID of the attachment to get'),\n})\n\nexport const SendMessageParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to send the message from'),\n to: z.array(z.string()).describe('The list of recipients'),\n cc: z.array(z.string()).optional().describe('The list of CC recipients'),\n bcc: z.array(z.string()).optional().describe('The list of BCC recipients'),\n subject: z.string().optional().describe('The subject of the message'),\n text: z.string().optional().describe('The plain text body of the message'),\n html: z.string().optional().describe('The HTML body of the message'),\n})\n\nexport const ReplyToMessageParams = z.object({\n inbox_id: z.string().describe('The inbox ID of the inbox to reply to the message from'),\n message_id: z.string().describe('The message ID of the message you wish to reply to'),\n text: z.string().optional().describe('The plain text body of the reply'),\n html: z.string().optional().describe('The HTML body of the reply'),\n})\n","import { AnyZodObject } from 'zod'\n\nimport {\n ListItemsParams,\n GetInboxParams,\n CreateInboxParams,\n ListThreadsParams,\n GetThreadParams,\n ListMessagesParams,\n GetMessageParams,\n GetAttachmentParams,\n SendMessageParams,\n ReplyToMessageParams,\n} from './schemas'\n\nexport type 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 all inboxes',\n schema: ListItemsParams,\n },\n {\n name: 'get_inbox',\n method: 'inboxes.get',\n description: 'Get an inbox by ID',\n schema: GetInboxParams,\n },\n {\n name: 'create_inbox',\n method: 'inboxes.create',\n description: 'Create a new inbox',\n schema: CreateInboxParams,\n },\n {\n name: 'list_threads',\n method: 'threads.list',\n description: 'List all threads',\n schema: ListThreadsParams,\n },\n {\n name: 'get_thread',\n method: 'threads.get',\n description: 'Get a thread by ID',\n schema: GetThreadParams,\n },\n {\n name: 'list_messages',\n method: 'messages.list',\n description: 'List all messages',\n schema: ListMessagesParams,\n },\n {\n name: 'get_message',\n method: 'messages.get',\n description: 'Get a message by ID',\n schema: GetMessageParams,\n },\n {\n name: 'get_attachment',\n method: 'attachments.get',\n description: 'Get an attachment by ID',\n schema: GetAttachmentParams,\n },\n {\n name: 'send_message',\n method: 'messages.send',\n description: 'Send a message',\n schema: SendMessageParams,\n },\n {\n name: 'reply_to_message',\n method: 'messages.reply',\n description: 'Reply to a message',\n schema: ReplyToMessageParams,\n },\n]\n","import { AgentMailClient } from 'agentmail'\n\nimport { Wrapper } from './wrapper'\nimport { type Tool, tools } from './tools'\n\nexport abstract class ListToolkit<T> extends Wrapper {\n protected readonly tools: T[] = []\n\n constructor(client?: AgentMailClient) {\n super(client)\n\n this.tools = tools.map((tool) => this.buildTool(tool))\n }\n\n protected abstract buildTool(tool: Tool): T\n\n public getTools() {\n return this.tools\n }\n}\n\nexport abstract class MapToolkit<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 public getTools() {\n return this.tools\n }\n}\n"],"mappings":";AAAA,SAAS,uBAAuB;AAEzB,IAAM,UAAN,MAAc;AAAA,EACjB,YAA6B,QAA0B;AAA1B;AACzB,QAAI,CAAC,KAAK,OAAQ,MAAK,SAAS,IAAI,gBAAgB;AAAA,EACxD;AAAA,EAEA,MAAa,WAAW,QAAgB,MAAe;AACnD,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,WAAO,MAAM,OAAO,SAAS,EAAE,KAAK,QAAQ,IAAI;AAAA,EACpD;AACJ;;;AClBA,SAAS,SAAS;AAEX,IAAM,kBAAkB,EAAE,OAAO;AAAA,EACpC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,uCAAuC;AAAA,EAC7E,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,oGAAoG;AACjJ,CAAC;AAEM,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACnC,UAAU,EAAE,OAAO,EAAE,SAAS,4BAA4B;AAC9D,CAAC;AAEM,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACtC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,sCAAsC;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IACI,MAAM;AAAA,IACN,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;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AACJ;;;AC9EO,IAAe,cAAf,cAAsC,QAAQ;AAAA,EAC9B,QAAa,CAAC;AAAA,EAEjC,YAAY,QAA0B;AAClC,UAAM,MAAM;AAEZ,SAAK,QAAQ,MAAM,IAAI,CAAC,SAAS,KAAK,UAAU,IAAI,CAAC;AAAA,EACzD;AAAA,EAIO,WAAW;AACd,WAAO,KAAK;AAAA,EAChB;AACJ;AAEO,IAAe,aAAf,cAAqC,QAAQ;AAAA,EAC7B,QAA2B,CAAC;AAAA,EAE/C,YAAY,QAA0B;AAClC,UAAM,MAAM;AAEZ,SAAK,QAAQ,MAAM;AAAA,MACf,CAAC,KAAK,SAAS;AACX,YAAI,KAAK,IAAI,IAAI,KAAK,UAAU,IAAI;AACpC,eAAO;AAAA,MACX;AAAA,MACA,CAAC;AAAA,IACL;AAAA,EACJ;AAAA,EAIO,WAAW;AACd,WAAO,KAAK;AAAA,EAChB;AACJ;","names":[]}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// src/wrapper.ts
|
|
2
|
+
import { AgentMailClient } from "agentmail";
|
|
3
|
+
var Wrapper = class {
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
if (!this.client) this.client = new AgentMailClient();
|
|
7
|
+
}
|
|
8
|
+
async callMethod(method, args) {
|
|
9
|
+
const parts = method.split(".");
|
|
10
|
+
const methodKey = parts.pop();
|
|
11
|
+
if (!methodKey) throw new Error("Method name empty");
|
|
12
|
+
let parent = this.client;
|
|
13
|
+
for (const part of parts) parent = parent[part];
|
|
14
|
+
return await parent[methodKey].call(parent, args);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/schemas.ts
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
var ListItemsParams = z.object({
|
|
21
|
+
limit: z.number().optional().describe("The maximum number of items to return"),
|
|
22
|
+
last_key: z.string().optional().describe("The last key to use for pagination")
|
|
23
|
+
});
|
|
24
|
+
var GetInboxParams = z.object({
|
|
25
|
+
inbox_id: z.string().describe("The ID of the inbox to get")
|
|
26
|
+
});
|
|
27
|
+
var CreateInboxParams = z.object({
|
|
28
|
+
username: z.string().optional().describe("The username of the inbox to create"),
|
|
29
|
+
domain: z.string().optional().describe("The domain of the inbox to create"),
|
|
30
|
+
display_name: z.string().optional().describe("The display name of the inbox to create")
|
|
31
|
+
});
|
|
32
|
+
var ListThreadsParams = ListItemsParams.extend({
|
|
33
|
+
inbox_id: z.string().describe("The ID of the inbox to list threads for"),
|
|
34
|
+
labels: z.array(z.string()).optional().describe("The labels to filter threads by")
|
|
35
|
+
});
|
|
36
|
+
var GetThreadParams = z.object({
|
|
37
|
+
inbox_id: z.string().describe("The ID of the inbox to get the thread for"),
|
|
38
|
+
thread_id: z.string().describe("The ID of the thread to get")
|
|
39
|
+
});
|
|
40
|
+
var ListMessagesParams = ListItemsParams.extend({
|
|
41
|
+
inbox_id: z.string().describe("The ID of the inbox to list messages for"),
|
|
42
|
+
labels: z.array(z.string()).optional().describe("The labels to filter messages by")
|
|
43
|
+
});
|
|
44
|
+
var GetMessageParams = z.object({
|
|
45
|
+
inbox_id: z.string().describe("The ID of the inbox to get the message for"),
|
|
46
|
+
message_id: z.string().describe("The ID of the message to get")
|
|
47
|
+
});
|
|
48
|
+
var GetAttachmentParams = z.object({
|
|
49
|
+
inbox_id: z.string().describe("The ID of the inbox to get the attachment for"),
|
|
50
|
+
message_id: z.string().describe("The ID of the message to get the attachment for"),
|
|
51
|
+
attachment_id: z.string().describe("The ID of the attachment to get")
|
|
52
|
+
});
|
|
53
|
+
var SendMessageParams = z.object({
|
|
54
|
+
inbox_id: z.string().describe("The ID of the inbox to send the message from"),
|
|
55
|
+
to: z.array(z.string()).describe("The list of recipients"),
|
|
56
|
+
cc: z.array(z.string()).optional().describe("The list of CC recipients"),
|
|
57
|
+
bcc: z.array(z.string()).optional().describe("The list of BCC recipients"),
|
|
58
|
+
subject: z.string().optional().describe("The subject of the message"),
|
|
59
|
+
text: z.string().optional().describe("The plain text body of the message"),
|
|
60
|
+
html: z.string().optional().describe("The HTML body of the message")
|
|
61
|
+
});
|
|
62
|
+
var ReplyToMessageParams = z.object({
|
|
63
|
+
inbox_id: z.string().describe("The inbox ID of the inbox to reply to the message from"),
|
|
64
|
+
message_id: z.string().describe("The message ID of the message you wish to reply to"),
|
|
65
|
+
text: z.string().optional().describe("The plain text body of the reply"),
|
|
66
|
+
html: z.string().optional().describe("The HTML body of the reply")
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// src/tools.ts
|
|
70
|
+
var tools = [
|
|
71
|
+
{
|
|
72
|
+
name: "list_inboxes",
|
|
73
|
+
method: "inboxes.list",
|
|
74
|
+
description: "List all inboxes",
|
|
75
|
+
schema: ListItemsParams
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "get_inbox",
|
|
79
|
+
method: "inboxes.get",
|
|
80
|
+
description: "Get an inbox by ID",
|
|
81
|
+
schema: GetInboxParams
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "create_inbox",
|
|
85
|
+
method: "inboxes.create",
|
|
86
|
+
description: "Create a new inbox",
|
|
87
|
+
schema: CreateInboxParams
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "list_threads",
|
|
91
|
+
method: "threads.list",
|
|
92
|
+
description: "List all threads",
|
|
93
|
+
schema: ListThreadsParams
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "get_thread",
|
|
97
|
+
method: "threads.get",
|
|
98
|
+
description: "Get a thread by ID",
|
|
99
|
+
schema: GetThreadParams
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "list_messages",
|
|
103
|
+
method: "messages.list",
|
|
104
|
+
description: "List all messages",
|
|
105
|
+
schema: ListMessagesParams
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "get_message",
|
|
109
|
+
method: "messages.get",
|
|
110
|
+
description: "Get a message by ID",
|
|
111
|
+
schema: GetMessageParams
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "get_attachment",
|
|
115
|
+
method: "attachments.get",
|
|
116
|
+
description: "Get an attachment by ID",
|
|
117
|
+
schema: GetAttachmentParams
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "send_message",
|
|
121
|
+
method: "messages.send",
|
|
122
|
+
description: "Send a message",
|
|
123
|
+
schema: SendMessageParams
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "reply_to_message",
|
|
127
|
+
method: "messages.reply",
|
|
128
|
+
description: "Reply to a message",
|
|
129
|
+
schema: ReplyToMessageParams
|
|
130
|
+
}
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
// src/toolkit.ts
|
|
134
|
+
var ListToolkit = class extends Wrapper {
|
|
135
|
+
tools = [];
|
|
136
|
+
constructor(client) {
|
|
137
|
+
super(client);
|
|
138
|
+
this.tools = tools.map((tool) => this.buildTool(tool));
|
|
139
|
+
}
|
|
140
|
+
getTools() {
|
|
141
|
+
return this.tools;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
var MapToolkit = class extends Wrapper {
|
|
145
|
+
tools = {};
|
|
146
|
+
constructor(client) {
|
|
147
|
+
super(client);
|
|
148
|
+
this.tools = tools.reduce(
|
|
149
|
+
(acc, tool) => {
|
|
150
|
+
acc[tool.name] = this.buildTool(tool);
|
|
151
|
+
return acc;
|
|
152
|
+
},
|
|
153
|
+
{}
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
getTools() {
|
|
157
|
+
return this.tools;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export {
|
|
162
|
+
ListToolkit,
|
|
163
|
+
MapToolkit
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=chunk-MTGL2LMT.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?: AgentMailClient) {\n if (!this.client) this.client = new AgentMailClient()\n }\n\n public async callMethod(method: string, args: unknown) {\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 return await parent[methodKey].call(parent, args)\n }\n}\n","import { z } from 'zod'\n\nexport const ListItemsParams = z.object({\n limit: z.number().optional().describe('The maximum number of items to return'),\n last_key: z.string().optional().describe('The last key to use for pagination'),\n})\n\nexport const GetInboxParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get'),\n})\n\nexport const CreateInboxParams = z.object({\n username: z.string().optional().describe('The username of the inbox to create'),\n domain: z.string().optional().describe('The domain of the inbox to create'),\n display_name: z.string().optional().describe('The display name of the inbox to create'),\n})\n\nexport const ListThreadsParams = ListItemsParams.extend({\n inbox_id: z.string().describe('The ID of the inbox to list threads for'),\n labels: z.array(z.string()).optional().describe('The labels to filter threads by'),\n})\n\nexport const GetThreadParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the thread for'),\n thread_id: z.string().describe('The ID of the thread to get'),\n})\n\nexport const ListMessagesParams = ListItemsParams.extend({\n inbox_id: z.string().describe('The ID of the inbox to list messages for'),\n labels: z.array(z.string()).optional().describe('The labels to filter messages by'),\n})\n\nexport const GetMessageParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the message for'),\n message_id: z.string().describe('The ID of the message to get'),\n})\n\nexport const GetAttachmentParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the attachment for'),\n message_id: z.string().describe('The ID of the message to get the attachment for'),\n attachment_id: z.string().describe('The ID of the attachment to get'),\n})\n\nexport const SendMessageParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to send the message from'),\n to: z.array(z.string()).describe('The list of recipients'),\n cc: z.array(z.string()).optional().describe('The list of CC recipients'),\n bcc: z.array(z.string()).optional().describe('The list of BCC recipients'),\n subject: z.string().optional().describe('The subject of the message'),\n text: z.string().optional().describe('The plain text body of the message'),\n html: z.string().optional().describe('The HTML body of the message'),\n})\n\nexport const ReplyToMessageParams = z.object({\n inbox_id: z.string().describe('The inbox ID of the inbox to reply to the message from'),\n message_id: z.string().describe('The message ID of the message you wish to reply to'),\n text: z.string().optional().describe('The plain text body of the reply'),\n html: z.string().optional().describe('The HTML body of the reply'),\n})\n","import { AnyZodObject } from 'zod'\n\nimport {\n ListItemsParams,\n GetInboxParams,\n CreateInboxParams,\n ListThreadsParams,\n GetThreadParams,\n ListMessagesParams,\n GetMessageParams,\n GetAttachmentParams,\n SendMessageParams,\n ReplyToMessageParams,\n} from './schemas'\n\nexport type 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 all inboxes',\n schema: ListItemsParams,\n },\n {\n name: 'get_inbox',\n method: 'inboxes.get',\n description: 'Get an inbox by ID',\n schema: GetInboxParams,\n },\n {\n name: 'create_inbox',\n method: 'inboxes.create',\n description: 'Create a new inbox',\n schema: CreateInboxParams,\n },\n {\n name: 'list_threads',\n method: 'threads.list',\n description: 'List all threads',\n schema: ListThreadsParams,\n },\n {\n name: 'get_thread',\n method: 'threads.get',\n description: 'Get a thread by ID',\n schema: GetThreadParams,\n },\n {\n name: 'list_messages',\n method: 'messages.list',\n description: 'List all messages',\n schema: ListMessagesParams,\n },\n {\n name: 'get_message',\n method: 'messages.get',\n description: 'Get a message by ID',\n schema: GetMessageParams,\n },\n {\n name: 'get_attachment',\n method: 'attachments.get',\n description: 'Get an attachment by ID',\n schema: GetAttachmentParams,\n },\n {\n name: 'send_message',\n method: 'messages.send',\n description: 'Send a message',\n schema: SendMessageParams,\n },\n {\n name: 'reply_to_message',\n method: 'messages.reply',\n description: 'Reply to a message',\n schema: ReplyToMessageParams,\n },\n]\n","import { AgentMailClient } from 'agentmail'\n\nimport { Wrapper } from './wrapper'\nimport { type Tool, tools } from './tools'\n\nexport abstract class ListToolkit<T> extends Wrapper {\n protected readonly tools: T[] = []\n\n constructor(client?: AgentMailClient) {\n super(client)\n\n this.tools = tools.map((tool) => this.buildTool(tool))\n }\n\n protected abstract buildTool(tool: Tool): T\n\n public getTools() {\n return this.tools\n }\n}\n\nexport abstract class MapToolkit<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 public getTools() {\n return this.tools\n }\n}\n"],"mappings":";AAAA,SAAS,uBAAuB;AAEzB,IAAM,UAAN,MAAc;AAAA,EACjB,YAA6B,QAA0B;AAA1B;AACzB,QAAI,CAAC,KAAK,OAAQ,MAAK,SAAS,IAAI,gBAAgB;AAAA,EACxD;AAAA,EAEA,MAAa,WAAW,QAAgB,MAAe;AACnD,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,WAAO,MAAM,OAAO,SAAS,EAAE,KAAK,QAAQ,IAAI;AAAA,EACpD;AACJ;;;AClBA,SAAS,SAAS;AAEX,IAAM,kBAAkB,EAAE,OAAO;AAAA,EACpC,OAAO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
1
|
import { StructuredTool } from '@langchain/core/tools';
|
|
3
2
|
import { AgentMailClient } from 'agentmail';
|
|
4
|
-
import {
|
|
3
|
+
import { L as ListToolkit, T as Tool } from './toolkit-DicBg_sN.mjs';
|
|
4
|
+
import 'zod';
|
|
5
5
|
|
|
6
|
-
declare class AgentMailToolkit extends
|
|
6
|
+
declare class AgentMailToolkit extends ListToolkit<StructuredTool> {
|
|
7
7
|
constructor(client?: AgentMailClient);
|
|
8
8
|
protected buildTool(tool: Tool): StructuredTool;
|
|
9
|
-
getTools(): StructuredTool<zod.ZodObject<any, any, any, any, {
|
|
10
|
-
[x: string]: any;
|
|
11
|
-
}>>[];
|
|
12
9
|
}
|
|
13
10
|
|
|
14
11
|
export { AgentMailToolkit };
|
package/dist/langchain.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import * as zod from 'zod';
|
|
2
1
|
import { StructuredTool } from '@langchain/core/tools';
|
|
3
2
|
import { AgentMailClient } from 'agentmail';
|
|
4
|
-
import {
|
|
3
|
+
import { L as ListToolkit, T as Tool } from './toolkit-DicBg_sN.js';
|
|
4
|
+
import 'zod';
|
|
5
5
|
|
|
6
|
-
declare class AgentMailToolkit extends
|
|
6
|
+
declare class AgentMailToolkit extends ListToolkit<StructuredTool> {
|
|
7
7
|
constructor(client?: AgentMailClient);
|
|
8
8
|
protected buildTool(tool: Tool): StructuredTool;
|
|
9
|
-
getTools(): StructuredTool<zod.ZodObject<any, any, any, any, {
|
|
10
|
-
[x: string]: any;
|
|
11
|
-
}>>[];
|
|
12
9
|
}
|
|
13
10
|
|
|
14
11
|
export { AgentMailToolkit };
|
package/dist/langchain.js
CHANGED
|
@@ -25,8 +25,22 @@ __export(langchain_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(langchain_exports);
|
|
26
26
|
var import_tools2 = require("@langchain/core/tools");
|
|
27
27
|
|
|
28
|
-
// src/
|
|
28
|
+
// src/wrapper.ts
|
|
29
29
|
var import_agentmail = require("agentmail");
|
|
30
|
+
var Wrapper = class {
|
|
31
|
+
constructor(client) {
|
|
32
|
+
this.client = client;
|
|
33
|
+
if (!this.client) this.client = new import_agentmail.AgentMailClient();
|
|
34
|
+
}
|
|
35
|
+
async callMethod(method, args) {
|
|
36
|
+
const parts = method.split(".");
|
|
37
|
+
const methodKey = parts.pop();
|
|
38
|
+
if (!methodKey) throw new Error("Method name empty");
|
|
39
|
+
let parent = this.client;
|
|
40
|
+
for (const part of parts) parent = parent[part];
|
|
41
|
+
return await parent[methodKey].call(parent, args);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
30
44
|
|
|
31
45
|
// src/schemas.ts
|
|
32
46
|
var import_zod = require("zod");
|
|
@@ -38,21 +52,21 @@ var GetInboxParams = import_zod.z.object({
|
|
|
38
52
|
inbox_id: import_zod.z.string().describe("The ID of the inbox to get")
|
|
39
53
|
});
|
|
40
54
|
var CreateInboxParams = import_zod.z.object({
|
|
41
|
-
username: import_zod.z.string().optional().describe("The username of the inbox to create
|
|
42
|
-
domain: import_zod.z.string().optional().describe("The domain of the inbox to create
|
|
43
|
-
display_name: import_zod.z.string().optional().describe("The display name of the inbox to create
|
|
55
|
+
username: import_zod.z.string().optional().describe("The username of the inbox to create"),
|
|
56
|
+
domain: import_zod.z.string().optional().describe("The domain of the inbox to create"),
|
|
57
|
+
display_name: import_zod.z.string().optional().describe("The display name of the inbox to create")
|
|
44
58
|
});
|
|
45
59
|
var ListThreadsParams = ListItemsParams.extend({
|
|
46
60
|
inbox_id: import_zod.z.string().describe("The ID of the inbox to list threads for"),
|
|
47
|
-
|
|
48
|
-
sent: import_zod.z.boolean().optional().describe("Whether to filter by sent threads")
|
|
61
|
+
labels: import_zod.z.array(import_zod.z.string()).optional().describe("The labels to filter threads by")
|
|
49
62
|
});
|
|
50
63
|
var GetThreadParams = import_zod.z.object({
|
|
51
64
|
inbox_id: import_zod.z.string().describe("The ID of the inbox to get the thread for"),
|
|
52
65
|
thread_id: import_zod.z.string().describe("The ID of the thread to get")
|
|
53
66
|
});
|
|
54
67
|
var ListMessagesParams = ListItemsParams.extend({
|
|
55
|
-
inbox_id: import_zod.z.string().describe("The ID of the inbox to list messages for")
|
|
68
|
+
inbox_id: import_zod.z.string().describe("The ID of the inbox to list messages for"),
|
|
69
|
+
labels: import_zod.z.array(import_zod.z.string()).optional().describe("The labels to filter messages by")
|
|
56
70
|
});
|
|
57
71
|
var GetMessageParams = import_zod.z.object({
|
|
58
72
|
inbox_id: import_zod.z.string().describe("The ID of the inbox to get the message for"),
|
|
@@ -73,7 +87,7 @@ var SendMessageParams = import_zod.z.object({
|
|
|
73
87
|
html: import_zod.z.string().optional().describe("The HTML body of the message")
|
|
74
88
|
});
|
|
75
89
|
var ReplyToMessageParams = import_zod.z.object({
|
|
76
|
-
inbox_id: import_zod.z.string().describe("The
|
|
90
|
+
inbox_id: import_zod.z.string().describe("The inbox ID of the inbox to reply to the message from"),
|
|
77
91
|
message_id: import_zod.z.string().describe("The message ID of the message you wish to reply to"),
|
|
78
92
|
text: import_zod.z.string().optional().describe("The plain text body of the reply"),
|
|
79
93
|
html: import_zod.z.string().optional().describe("The HTML body of the reply")
|
|
@@ -83,114 +97,96 @@ var ReplyToMessageParams = import_zod.z.object({
|
|
|
83
97
|
var tools = [
|
|
84
98
|
{
|
|
85
99
|
name: "list_inboxes",
|
|
86
|
-
|
|
100
|
+
method: "inboxes.list",
|
|
87
101
|
description: "List all inboxes",
|
|
88
|
-
|
|
102
|
+
schema: ListItemsParams
|
|
89
103
|
},
|
|
90
104
|
{
|
|
91
105
|
name: "get_inbox",
|
|
92
|
-
|
|
106
|
+
method: "inboxes.get",
|
|
93
107
|
description: "Get an inbox by ID",
|
|
94
|
-
|
|
108
|
+
schema: GetInboxParams
|
|
95
109
|
},
|
|
96
110
|
{
|
|
97
111
|
name: "create_inbox",
|
|
98
|
-
|
|
112
|
+
method: "inboxes.create",
|
|
99
113
|
description: "Create a new inbox",
|
|
100
|
-
|
|
114
|
+
schema: CreateInboxParams
|
|
101
115
|
},
|
|
102
116
|
{
|
|
103
117
|
name: "list_threads",
|
|
104
|
-
|
|
118
|
+
method: "threads.list",
|
|
105
119
|
description: "List all threads",
|
|
106
|
-
|
|
120
|
+
schema: ListThreadsParams
|
|
107
121
|
},
|
|
108
122
|
{
|
|
109
123
|
name: "get_thread",
|
|
110
|
-
|
|
124
|
+
method: "threads.get",
|
|
111
125
|
description: "Get a thread by ID",
|
|
112
|
-
|
|
126
|
+
schema: GetThreadParams
|
|
113
127
|
},
|
|
114
128
|
{
|
|
115
129
|
name: "list_messages",
|
|
116
|
-
|
|
130
|
+
method: "messages.list",
|
|
117
131
|
description: "List all messages",
|
|
118
|
-
|
|
132
|
+
schema: ListMessagesParams
|
|
119
133
|
},
|
|
120
134
|
{
|
|
121
135
|
name: "get_message",
|
|
122
|
-
|
|
136
|
+
method: "messages.get",
|
|
123
137
|
description: "Get a message by ID",
|
|
124
|
-
|
|
138
|
+
schema: GetMessageParams
|
|
125
139
|
},
|
|
126
140
|
{
|
|
127
141
|
name: "get_attachment",
|
|
128
|
-
|
|
142
|
+
method: "attachments.get",
|
|
129
143
|
description: "Get an attachment by ID",
|
|
130
|
-
|
|
144
|
+
schema: GetAttachmentParams
|
|
131
145
|
},
|
|
132
146
|
{
|
|
133
147
|
name: "send_message",
|
|
134
|
-
|
|
148
|
+
method: "messages.send",
|
|
135
149
|
description: "Send a message",
|
|
136
|
-
|
|
150
|
+
schema: SendMessageParams
|
|
137
151
|
},
|
|
138
152
|
{
|
|
139
153
|
name: "reply_to_message",
|
|
140
|
-
|
|
154
|
+
method: "messages.reply",
|
|
141
155
|
description: "Reply to a message",
|
|
142
|
-
|
|
156
|
+
schema: ReplyToMessageParams
|
|
143
157
|
}
|
|
144
158
|
];
|
|
145
159
|
|
|
146
160
|
// src/toolkit.ts
|
|
147
|
-
var
|
|
161
|
+
var ListToolkit = class extends Wrapper {
|
|
162
|
+
tools = [];
|
|
148
163
|
constructor(client) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.tools = tools.reduce(
|
|
152
|
-
(acc, tool) => {
|
|
153
|
-
acc[tool.name] = this.buildTool(tool);
|
|
154
|
-
return acc;
|
|
155
|
-
},
|
|
156
|
-
{}
|
|
157
|
-
);
|
|
164
|
+
super(client);
|
|
165
|
+
this.tools = tools.map((tool) => this.buildTool(tool));
|
|
158
166
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// return this.tools
|
|
162
|
-
// }
|
|
163
|
-
async callMethod(methodName, args) {
|
|
164
|
-
const parts = methodName.split(".");
|
|
165
|
-
const methodKey = parts.pop();
|
|
166
|
-
if (!methodKey) throw new Error("Method name empty");
|
|
167
|
-
let parent = this.client;
|
|
168
|
-
for (const part of parts) parent = parent[part];
|
|
169
|
-
return await parent[methodKey].call(parent, args);
|
|
167
|
+
getTools() {
|
|
168
|
+
return this.tools;
|
|
170
169
|
}
|
|
171
170
|
};
|
|
172
171
|
|
|
173
172
|
// src/langchain.ts
|
|
174
|
-
var AgentMailToolkit = class extends
|
|
173
|
+
var AgentMailToolkit = class extends ListToolkit {
|
|
175
174
|
constructor(client) {
|
|
176
175
|
super(client);
|
|
177
176
|
}
|
|
178
177
|
buildTool(tool) {
|
|
179
178
|
return (0, import_tools2.tool)(
|
|
180
179
|
async (args) => {
|
|
181
|
-
const result = await this.callMethod(tool.
|
|
182
|
-
return
|
|
180
|
+
const result = await this.callMethod(tool.method, args);
|
|
181
|
+
return JSON.stringify(result, null, 2);
|
|
183
182
|
},
|
|
184
183
|
{
|
|
185
184
|
name: tool.name,
|
|
186
185
|
description: tool.description,
|
|
187
|
-
schema: tool.
|
|
186
|
+
schema: tool.schema
|
|
188
187
|
}
|
|
189
188
|
);
|
|
190
189
|
}
|
|
191
|
-
getTools() {
|
|
192
|
-
return Object.values(this.tools);
|
|
193
|
-
}
|
|
194
190
|
};
|
|
195
191
|
// Annotate the CommonJS export names for ESM import in node:
|
|
196
192
|
0 && (module.exports = {
|
package/dist/langchain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/langchain.ts","../src/toolkit.ts","../src/schemas.ts","../src/tools.ts"],"sourcesContent":["import { type StructuredTool, tool as langchainTool } from '@langchain/core/tools'\nimport { AgentMailClient } from 'agentmail'\n\nimport { Toolkit } from './toolkit'\nimport { type Tool } from './tools'\n\nexport class AgentMailToolkit extends Toolkit<StructuredTool> {\n constructor(client?: AgentMailClient) {\n super(client)\n }\n\n protected buildTool(tool: Tool): StructuredTool {\n return langchainTool(\n async (args) => {\n const result = await this.callMethod(tool.methodName, args)\n return result.toString()\n },\n {\n name: tool.name,\n description: tool.description,\n schema: tool.paramsSchema,\n }\n )\n }\n\n public getTools() {\n return Object.values(this.tools)\n }\n}\n","import { AgentMailClient } from 'agentmail'\nimport { type Tool, tools } from './tools'\n\nexport abstract class Toolkit<T> {\n protected readonly tools: Record<string, T> = {}\n\n constructor(private readonly client?: AgentMailClient) {\n if (!this.client) this.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 // public getTools() {\n // return this.tools\n // }\n\n public async callMethod(methodName: string, args: unknown) {\n const parts = methodName.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 return await parent[methodKey].call(parent, args)\n }\n}\n","import { z } from 'zod'\n\nexport const ListItemsParams = z.object({\n limit: z.number().optional().describe('The maximum number of items to return'),\n last_key: z.string().optional().describe('The last key to use for pagination'),\n})\n\nexport const GetInboxParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get'),\n})\n\nexport const CreateInboxParams = z.object({\n username: z.string().optional().describe('The username of the inbox to create.'),\n domain: z.string().optional().describe('The domain of the inbox to create.'),\n display_name: z.string().optional().describe('The display name of the inbox to create.'),\n})\n\nexport const ListThreadsParams = ListItemsParams.extend({\n inbox_id: z.string().describe('The ID of the inbox to list threads for'),\n received: z.boolean().optional().describe('Whether to filter by received threads'),\n sent: z.boolean().optional().describe('Whether to filter by sent threads'),\n})\n\nexport const GetThreadParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the thread for'),\n thread_id: z.string().describe('The ID of the thread to get'),\n})\n\nexport const ListMessagesParams = ListItemsParams.extend({\n inbox_id: z.string().describe('The ID of the inbox to list messages for'),\n})\n\nexport const GetMessageParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the message for'),\n message_id: z.string().describe('The ID of the message to get'),\n})\n\nexport const GetAttachmentParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the attachment for'),\n message_id: z.string().describe('The ID of the message to get the attachment for'),\n attachment_id: z.string().describe('The ID of the attachment to get'),\n})\n\nexport const SendMessageParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to send the message from'),\n to: z.array(z.string()).describe('The list of recipients'),\n cc: z.array(z.string()).optional().describe('The list of CC recipients'),\n bcc: z.array(z.string()).optional().describe('The list of BCC recipients'),\n subject: z.string().optional().describe('The subject of the message'),\n text: z.string().optional().describe('The plain text body of the message'),\n html: z.string().optional().describe('The HTML body of the message'),\n})\n\nexport const ReplyToMessageParams = z.object({\n inbox_id: z.string().describe('The inboc ID of the inbox to reply to the message from'),\n message_id: z.string().describe('The message ID of the message you wish to reply to'),\n text: z.string().optional().describe('The plain text body of the reply'),\n html: z.string().optional().describe('The HTML body of the reply'),\n})\n","import { z } from 'zod'\n\nimport {\n ListItemsParams,\n GetInboxParams,\n CreateInboxParams,\n ListThreadsParams,\n GetThreadParams,\n ListMessagesParams,\n GetMessageParams,\n GetAttachmentParams,\n SendMessageParams,\n ReplyToMessageParams,\n} from './schemas'\n\nexport type Tool = {\n name: string\n methodName: string\n description: string\n paramsSchema: z.ZodObject<any>\n}\n\nexport const tools: Tool[] = [\n {\n name: 'list_inboxes',\n methodName: 'inboxes.list',\n description: 'List all inboxes',\n paramsSchema: ListItemsParams,\n },\n {\n name: 'get_inbox',\n methodName: 'inboxes.get',\n description: 'Get an inbox by ID',\n paramsSchema: GetInboxParams,\n },\n {\n name: 'create_inbox',\n methodName: 'inboxes.create',\n description: 'Create a new inbox',\n paramsSchema: CreateInboxParams,\n },\n {\n name: 'list_threads',\n methodName: 'threads.list',\n description: 'List all threads',\n paramsSchema: ListThreadsParams,\n },\n {\n name: 'get_thread',\n methodName: 'threads.get',\n description: 'Get a thread by ID',\n paramsSchema: GetThreadParams,\n },\n {\n name: 'list_messages',\n methodName: 'messages.list',\n description: 'List all messages',\n paramsSchema: ListMessagesParams,\n },\n {\n name: 'get_message',\n methodName: 'messages.get',\n description: 'Get a message by ID',\n paramsSchema: GetMessageParams,\n },\n {\n name: 'get_attachment',\n methodName: 'attachments.get',\n description: 'Get an attachment by ID',\n paramsSchema: GetAttachmentParams,\n },\n {\n name: 'send_message',\n methodName: 'messages.send',\n description: 'Send a message',\n paramsSchema: SendMessageParams,\n },\n {\n name: 'reply_to_message',\n methodName: 'messages.reply',\n description: 'Reply to a message',\n paramsSchema: ReplyToMessageParams,\n },\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA2D;;;ACA3D,uBAAgC;;;ACAhC,iBAAkB;AAEX,IAAM,kBAAkB,aAAE,OAAO;AAAA,EACpC,OAAO,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,uCAAuC;AAAA,EAC7E,UAAU,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,oCAAoC;AACjF,CAAC;AAEM,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACnC,UAAU,aAAE,OAAO,EAAE,SAAS,4BAA4B;AAC9D,CAAC;AAEM,IAAM,oBAAoB,aAAE,OAAO;AAAA,EACtC,UAAU,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,sCAAsC;AAAA,EAC/E,QAAQ,aAAE,OAAO,EAAE,SAAS,EAAE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AAA,EACnC;AACJ;","names":["import_tools","langchainTool"]}
|
|
1
|
+
{"version":3,"sources":["../src/langchain.ts","../src/wrapper.ts","../src/schemas.ts","../src/tools.ts","../src/toolkit.ts"],"sourcesContent":["import { type StructuredTool, tool as langchainTool } from '@langchain/core/tools'\nimport { AgentMailClient } from 'agentmail'\n\nimport { ListToolkit } from './toolkit'\nimport { type Tool } from './tools'\n\nexport class AgentMailToolkit extends ListToolkit<StructuredTool> {\n constructor(client?: AgentMailClient) {\n super(client)\n }\n\n protected buildTool(tool: Tool): StructuredTool {\n return langchainTool(\n async (args) => {\n const result = await this.callMethod(tool.method, args)\n return JSON.stringify(result, null, 2)\n },\n {\n name: tool.name,\n description: tool.description,\n schema: tool.schema,\n }\n )\n }\n}\n","import { AgentMailClient } from 'agentmail'\n\nexport class Wrapper {\n constructor(private readonly client?: AgentMailClient) {\n if (!this.client) this.client = new AgentMailClient()\n }\n\n public async callMethod(method: string, args: unknown) {\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 return await parent[methodKey].call(parent, args)\n }\n}\n","import { z } from 'zod'\n\nexport const ListItemsParams = z.object({\n limit: z.number().optional().describe('The maximum number of items to return'),\n last_key: z.string().optional().describe('The last key to use for pagination'),\n})\n\nexport const GetInboxParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get'),\n})\n\nexport const CreateInboxParams = z.object({\n username: z.string().optional().describe('The username of the inbox to create'),\n domain: z.string().optional().describe('The domain of the inbox to create'),\n display_name: z.string().optional().describe('The display name of the inbox to create'),\n})\n\nexport const ListThreadsParams = ListItemsParams.extend({\n inbox_id: z.string().describe('The ID of the inbox to list threads for'),\n labels: z.array(z.string()).optional().describe('The labels to filter threads by'),\n})\n\nexport const GetThreadParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the thread for'),\n thread_id: z.string().describe('The ID of the thread to get'),\n})\n\nexport const ListMessagesParams = ListItemsParams.extend({\n inbox_id: z.string().describe('The ID of the inbox to list messages for'),\n labels: z.array(z.string()).optional().describe('The labels to filter messages by'),\n})\n\nexport const GetMessageParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the message for'),\n message_id: z.string().describe('The ID of the message to get'),\n})\n\nexport const GetAttachmentParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to get the attachment for'),\n message_id: z.string().describe('The ID of the message to get the attachment for'),\n attachment_id: z.string().describe('The ID of the attachment to get'),\n})\n\nexport const SendMessageParams = z.object({\n inbox_id: z.string().describe('The ID of the inbox to send the message from'),\n to: z.array(z.string()).describe('The list of recipients'),\n cc: z.array(z.string()).optional().describe('The list of CC recipients'),\n bcc: z.array(z.string()).optional().describe('The list of BCC recipients'),\n subject: z.string().optional().describe('The subject of the message'),\n text: z.string().optional().describe('The plain text body of the message'),\n html: z.string().optional().describe('The HTML body of the message'),\n})\n\nexport const ReplyToMessageParams = z.object({\n inbox_id: z.string().describe('The inbox ID of the inbox to reply to the message from'),\n message_id: z.string().describe('The message ID of the message you wish to reply to'),\n text: z.string().optional().describe('The plain text body of the reply'),\n html: z.string().optional().describe('The HTML body of the reply'),\n})\n","import { AnyZodObject } from 'zod'\n\nimport {\n ListItemsParams,\n GetInboxParams,\n CreateInboxParams,\n ListThreadsParams,\n GetThreadParams,\n ListMessagesParams,\n GetMessageParams,\n GetAttachmentParams,\n SendMessageParams,\n ReplyToMessageParams,\n} from './schemas'\n\nexport type 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 all inboxes',\n schema: ListItemsParams,\n },\n {\n name: 'get_inbox',\n method: 'inboxes.get',\n description: 'Get an inbox by ID',\n schema: GetInboxParams,\n },\n {\n name: 'create_inbox',\n method: 'inboxes.create',\n description: 'Create a new inbox',\n schema: CreateInboxParams,\n },\n {\n name: 'list_threads',\n method: 'threads.list',\n description: 'List all threads',\n schema: ListThreadsParams,\n },\n {\n name: 'get_thread',\n method: 'threads.get',\n description: 'Get a thread by ID',\n schema: GetThreadParams,\n },\n {\n name: 'list_messages',\n method: 'messages.list',\n description: 'List all messages',\n schema: ListMessagesParams,\n },\n {\n name: 'get_message',\n method: 'messages.get',\n description: 'Get a message by ID',\n schema: GetMessageParams,\n },\n {\n name: 'get_attachment',\n method: 'attachments.get',\n description: 'Get an attachment by ID',\n schema: GetAttachmentParams,\n },\n {\n name: 'send_message',\n method: 'messages.send',\n description: 'Send a message',\n schema: SendMessageParams,\n },\n {\n name: 'reply_to_message',\n method: 'messages.reply',\n description: 'Reply to a message',\n schema: ReplyToMessageParams,\n },\n]\n","import { AgentMailClient } from 'agentmail'\n\nimport { Wrapper } from './wrapper'\nimport { type Tool, tools } from './tools'\n\nexport abstract class ListToolkit<T> extends Wrapper {\n protected readonly tools: T[] = []\n\n constructor(client?: AgentMailClient) {\n super(client)\n\n this.tools = tools.map((tool) => this.buildTool(tool))\n }\n\n protected abstract buildTool(tool: Tool): T\n\n public getTools() {\n return this.tools\n }\n}\n\nexport abstract class MapToolkit<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 public getTools() {\n return this.tools\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA2D;;;ACA3D,uBAAgC;AAEzB,IAAM,UAAN,MAAc;AAAA,EACjB,YAA6B,QAA0B;AAA1B;AACzB,QAAI,CAAC,KAAK,OAAQ,MAAK,SAAS,IAAI,iCAAgB;AAAA,EACxD;AAAA,EAEA,MAAa,WAAW,QAAgB,MAAe;AACnD,UAAM,QAAQ,OAAO,MAAM,GAAG;AAC9B,UAAM,YAAY,M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AA,MACH,OAAO,SAAS;AACZ,cAAM,SAAS,MAAM,KAAK,WAAW,KAAK,QAAQ,IAAI;AACtD,eAAO,KAAK,UAAU,QAAQ,MAAM,CAAC;AAAA,MACzC;AAAA,MACA;AAAA,QACI,MAAM,KAAK;AAAA,QACX,aAAa,KAAK;AAAA,QAClB,QAAQ,KAAK;AAAA,MACjB;AAAA,IACJ;AAAA,EACJ;AACJ;","names":["import_tools","langchainTool"]}
|
package/dist/langchain.mjs
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
ListToolkit
|
|
3
|
+
} from "./chunk-MTGL2LMT.mjs";
|
|
4
4
|
|
|
5
5
|
// src/langchain.ts
|
|
6
6
|
import { tool as langchainTool } from "@langchain/core/tools";
|
|
7
|
-
var AgentMailToolkit = class extends
|
|
7
|
+
var AgentMailToolkit = class extends ListToolkit {
|
|
8
8
|
constructor(client) {
|
|
9
9
|
super(client);
|
|
10
10
|
}
|
|
11
11
|
buildTool(tool) {
|
|
12
12
|
return langchainTool(
|
|
13
13
|
async (args) => {
|
|
14
|
-
const result = await this.callMethod(tool.
|
|
15
|
-
return
|
|
14
|
+
const result = await this.callMethod(tool.method, args);
|
|
15
|
+
return JSON.stringify(result, null, 2);
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
name: tool.name,
|
|
19
19
|
description: tool.description,
|
|
20
|
-
schema: tool.
|
|
20
|
+
schema: tool.schema
|
|
21
21
|
}
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
|
-
getTools() {
|
|
25
|
-
return Object.values(this.tools);
|
|
26
|
-
}
|
|
27
24
|
};
|
|
28
25
|
export {
|
|
29
26
|
AgentMailToolkit
|
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'\nimport { AgentMailClient } from 'agentmail'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/langchain.ts"],"sourcesContent":["import { type StructuredTool, tool as langchainTool } from '@langchain/core/tools'\nimport { AgentMailClient } from 'agentmail'\n\nimport { ListToolkit } from './toolkit'\nimport { type Tool } from './tools'\n\nexport class AgentMailToolkit extends ListToolkit<StructuredTool> {\n constructor(client?: AgentMailClient) {\n super(client)\n }\n\n protected buildTool(tool: Tool): StructuredTool {\n return langchainTool(\n async (args) => {\n const result = await this.callMethod(tool.method, args)\n return JSON.stringify(result, null, 2)\n },\n {\n name: tool.name,\n description: tool.description,\n schema: tool.schema,\n }\n )\n }\n}\n"],"mappings":";;;;;AAAA,SAA8B,QAAQ,qBAAqB;AAMpD,IAAM,mBAAN,cAA+B,YAA4B;AAAA,EAC9D,YAAY,QAA0B;AAClC,UAAM,MAAM;AAAA,EAChB;AAAA,EAEU,UAAU,MAA4B;AAC5C,WAAO;AAAA,MACH,OAAO,SAAS;AACZ,cAAM,SAAS,MAAM,KAAK,WAAW,KAAK,QAAQ,IAAI;AACtD,eAAO,KAAK,UAAU,QAAQ,MAAM,CAAC;AAAA,MACzC;AAAA,MACA;AAAA,QACI,MAAM,KAAK;AAAA,QACX,aAAa,KAAK;AAAA,QAClB,QAAQ,KAAK;AAAA,MACjB;AAAA,IACJ;AAAA,EACJ;AACJ;","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AgentMailClient } from 'agentmail';
|
|
2
|
+
import { AnyZodObject } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare class Wrapper {
|
|
5
|
+
private readonly client?;
|
|
6
|
+
constructor(client?: AgentMailClient | undefined);
|
|
7
|
+
callMethod(method: string, args: unknown): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type Tool = {
|
|
11
|
+
name: string;
|
|
12
|
+
method: string;
|
|
13
|
+
description: string;
|
|
14
|
+
schema: AnyZodObject;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
declare abstract class ListToolkit<T> extends Wrapper {
|
|
18
|
+
protected readonly tools: T[];
|
|
19
|
+
constructor(client?: AgentMailClient);
|
|
20
|
+
protected abstract buildTool(tool: Tool): T;
|
|
21
|
+
getTools(): T[];
|
|
22
|
+
}
|
|
23
|
+
declare abstract class MapToolkit<T> extends Wrapper {
|
|
24
|
+
protected readonly tools: Record<string, T>;
|
|
25
|
+
constructor(client?: AgentMailClient);
|
|
26
|
+
protected abstract buildTool(tool: Tool): T;
|
|
27
|
+
getTools(): Record<string, T>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { ListToolkit as L, MapToolkit as M, type Tool as T };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AgentMailClient } from 'agentmail';
|
|
2
|
+
import { AnyZodObject } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare class Wrapper {
|
|
5
|
+
private readonly client?;
|
|
6
|
+
constructor(client?: AgentMailClient | undefined);
|
|
7
|
+
callMethod(method: string, args: unknown): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type Tool = {
|
|
11
|
+
name: string;
|
|
12
|
+
method: string;
|
|
13
|
+
description: string;
|
|
14
|
+
schema: AnyZodObject;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
declare abstract class ListToolkit<T> extends Wrapper {
|
|
18
|
+
protected readonly tools: T[];
|
|
19
|
+
constructor(client?: AgentMailClient);
|
|
20
|
+
protected abstract buildTool(tool: Tool): T;
|
|
21
|
+
getTools(): T[];
|
|
22
|
+
}
|
|
23
|
+
declare abstract class MapToolkit<T> extends Wrapper {
|
|
24
|
+
protected readonly tools: Record<string, T>;
|
|
25
|
+
constructor(client?: AgentMailClient);
|
|
26
|
+
protected abstract buildTool(tool: Tool): T;
|
|
27
|
+
getTools(): Record<string, T>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { ListToolkit as L, MapToolkit as M, type Tool as T };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentmail-toolkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "AgentMail Toolkit",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
@@ -47,11 +47,12 @@
|
|
|
47
47
|
"typescript-eslint": "^8.26.1"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"agentmail": "^0.0.
|
|
50
|
+
"agentmail": "^0.0.23",
|
|
51
51
|
"zod": "^3.24.2"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@langchain/core": "^0.3.43",
|
|
55
|
+
"@modelcontextprotocol/sdk": "^1.8.0",
|
|
55
56
|
"ai": "^4.2.8"
|
|
56
57
|
}
|
|
57
58
|
}
|