agentmail-toolkit 0.1.20 → 0.1.22
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 +3 -4
- package/dist/ai-sdk.d.ts +3 -4
- package/dist/ai-sdk.js +53 -59
- package/dist/ai-sdk.js.map +1 -1
- package/dist/ai-sdk.mjs +2 -6
- package/dist/ai-sdk.mjs.map +1 -1
- package/dist/chunk-CIU3KR25.mjs +117 -0
- package/dist/chunk-CIU3KR25.mjs.map +1 -0
- package/dist/chunk-GWFZG2RN.mjs +117 -0
- package/dist/chunk-GWFZG2RN.mjs.map +1 -0
- package/dist/chunk-UODX72KA.mjs +40 -0
- package/dist/chunk-UODX72KA.mjs.map +1 -0
- package/dist/chunk-W2LJOBDV.mjs +71 -0
- package/dist/chunk-W2LJOBDV.mjs.map +1 -0
- package/dist/index.d.mts +17 -30
- package/dist/index.d.ts +17 -30
- package/dist/index.js +40 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -3
- package/dist/langchain.d.mts +3 -4
- package/dist/langchain.d.ts +3 -4
- package/dist/langchain.js +58 -61
- package/dist/langchain.js.map +1 -1
- package/dist/langchain.mjs +2 -6
- package/dist/langchain.mjs.map +1 -1
- package/dist/mcp.d.mts +14 -6
- package/dist/mcp.d.ts +14 -6
- package/dist/mcp.js +77 -69
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs +14 -20
- package/dist/mcp.mjs.map +1 -1
- package/dist/toolkit-3F468CU6.d.ts +26 -0
- package/dist/toolkit-BLAprE02.d.mts +26 -0
- package/dist/tools-Dzp_FZN_.d.mts +11 -0
- package/dist/tools-Dzp_FZN_.d.ts +11 -0
- package/package.json +15 -15
package/dist/langchain.js
CHANGED
|
@@ -28,9 +28,8 @@ var import_tools2 = require("@langchain/core/tools");
|
|
|
28
28
|
// src/wrapper.ts
|
|
29
29
|
var import_agentmail = require("agentmail");
|
|
30
30
|
var Wrapper = class {
|
|
31
|
-
constructor(client) {
|
|
31
|
+
constructor(client = new import_agentmail.AgentMailClient()) {
|
|
32
32
|
this.client = client;
|
|
33
|
-
if (!this.client) this.client = new import_agentmail.AgentMailClient();
|
|
34
33
|
}
|
|
35
34
|
async call(method, args) {
|
|
36
35
|
const parts = method.split(".");
|
|
@@ -55,52 +54,47 @@ var Wrapper = class {
|
|
|
55
54
|
// src/schemas.ts
|
|
56
55
|
var import_zod = require("zod");
|
|
57
56
|
var ListItemsParams = import_zod.z.object({
|
|
58
|
-
limit: import_zod.z.number().optional().describe("
|
|
59
|
-
|
|
57
|
+
limit: import_zod.z.number().optional().describe("Max number of items to return"),
|
|
58
|
+
page_token: import_zod.z.string().optional().describe("Page token for pagination")
|
|
60
59
|
});
|
|
61
60
|
var GetInboxParams = import_zod.z.object({
|
|
62
|
-
inbox_id: import_zod.z.string().describe("
|
|
61
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to get")
|
|
63
62
|
});
|
|
64
63
|
var CreateInboxParams = import_zod.z.object({
|
|
65
|
-
username: import_zod.z.string().optional().describe("
|
|
66
|
-
domain: import_zod.z.string().optional().describe("
|
|
67
|
-
display_name: import_zod.z.string().optional().describe("
|
|
64
|
+
username: import_zod.z.string().optional().describe("Username of inbox to create"),
|
|
65
|
+
domain: import_zod.z.string().optional().describe("Domain of inbox to create"),
|
|
66
|
+
display_name: import_zod.z.string().optional().describe("Display name of inbox to create")
|
|
68
67
|
});
|
|
69
68
|
var ListThreadsParams = ListItemsParams.extend({
|
|
70
|
-
inbox_id: import_zod.z.string().describe("
|
|
71
|
-
labels: import_zod.z.array(import_zod.z.string()).optional().describe("
|
|
69
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to list threads from"),
|
|
70
|
+
labels: import_zod.z.array(import_zod.z.string()).optional().describe("Labels to filter threads by")
|
|
72
71
|
});
|
|
73
72
|
var GetThreadParams = import_zod.z.object({
|
|
74
|
-
inbox_id: import_zod.z.string().describe("
|
|
75
|
-
thread_id: import_zod.z.string().describe("
|
|
73
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to get thread from"),
|
|
74
|
+
thread_id: import_zod.z.string().describe("ID of thread to get")
|
|
76
75
|
});
|
|
77
76
|
var ListMessagesParams = ListItemsParams.extend({
|
|
78
|
-
inbox_id: import_zod.z.string().describe("
|
|
79
|
-
labels: import_zod.z.array(import_zod.z.string()).optional().describe("
|
|
77
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to list messages from"),
|
|
78
|
+
labels: import_zod.z.array(import_zod.z.string()).optional().describe("Labels to filter messages by")
|
|
80
79
|
});
|
|
81
80
|
var GetMessageParams = import_zod.z.object({
|
|
82
|
-
inbox_id: import_zod.z.string().describe("
|
|
83
|
-
message_id: import_zod.z.string().describe("
|
|
84
|
-
});
|
|
85
|
-
var GetAttachmentParams = import_zod.z.object({
|
|
86
|
-
inbox_id: import_zod.z.string().describe("The ID of the inbox to get the attachment for"),
|
|
87
|
-
message_id: import_zod.z.string().describe("The ID of the message to get the attachment for"),
|
|
88
|
-
attachment_id: import_zod.z.string().describe("The ID of the attachment to get")
|
|
81
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to get message from"),
|
|
82
|
+
message_id: import_zod.z.string().describe("ID of message to get")
|
|
89
83
|
});
|
|
90
84
|
var SendMessageParams = import_zod.z.object({
|
|
91
|
-
inbox_id: import_zod.z.string().describe("
|
|
92
|
-
to: import_zod.z.array(import_zod.z.string()).describe("
|
|
93
|
-
cc: import_zod.z.array(import_zod.z.string()).optional().describe("
|
|
94
|
-
bcc: import_zod.z.array(import_zod.z.string()).optional().describe("
|
|
95
|
-
subject: import_zod.z.string().optional().describe("
|
|
96
|
-
text: import_zod.z.string().optional().describe("
|
|
97
|
-
html: import_zod.z.string().optional().describe("
|
|
85
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to send message from"),
|
|
86
|
+
to: import_zod.z.array(import_zod.z.string()).describe("Recipients of message"),
|
|
87
|
+
cc: import_zod.z.array(import_zod.z.string()).optional().describe("CC recipients of message"),
|
|
88
|
+
bcc: import_zod.z.array(import_zod.z.string()).optional().describe("BCC recipients of message"),
|
|
89
|
+
subject: import_zod.z.string().optional().describe("Subject of message"),
|
|
90
|
+
text: import_zod.z.string().optional().describe("Plain text body of message"),
|
|
91
|
+
html: import_zod.z.string().optional().describe("HTML body of message")
|
|
98
92
|
});
|
|
99
93
|
var ReplyToMessageParams = import_zod.z.object({
|
|
100
|
-
inbox_id: import_zod.z.string().describe("
|
|
101
|
-
message_id: import_zod.z.string().describe("
|
|
102
|
-
text: import_zod.z.string().optional().describe("
|
|
103
|
-
html: import_zod.z.string().optional().describe("
|
|
94
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to reply to message from"),
|
|
95
|
+
message_id: import_zod.z.string().describe("ID of message to reply to"),
|
|
96
|
+
text: import_zod.z.string().optional().describe("Plain text body of reply"),
|
|
97
|
+
html: import_zod.z.string().optional().describe("HTML body of reply")
|
|
104
98
|
});
|
|
105
99
|
|
|
106
100
|
// src/tools.ts
|
|
@@ -108,82 +102,85 @@ var tools = [
|
|
|
108
102
|
{
|
|
109
103
|
name: "list_inboxes",
|
|
110
104
|
method: "inboxes.list",
|
|
111
|
-
description: "List
|
|
105
|
+
description: "List inboxes",
|
|
112
106
|
schema: ListItemsParams
|
|
113
107
|
},
|
|
114
108
|
{
|
|
115
109
|
name: "get_inbox",
|
|
116
110
|
method: "inboxes.get",
|
|
117
|
-
description: "Get
|
|
111
|
+
description: "Get inbox",
|
|
118
112
|
schema: GetInboxParams
|
|
119
113
|
},
|
|
120
114
|
{
|
|
121
115
|
name: "create_inbox",
|
|
122
116
|
method: "inboxes.create",
|
|
123
|
-
description: "Create
|
|
117
|
+
description: "Create inbox. Use default username, domain, and display name unless otherwise specified.",
|
|
124
118
|
schema: CreateInboxParams
|
|
125
119
|
},
|
|
126
120
|
{
|
|
127
121
|
name: "list_threads",
|
|
128
|
-
method: "threads.list",
|
|
129
|
-
description: "List
|
|
122
|
+
method: "inboxes.threads.list",
|
|
123
|
+
description: "List threads in inbox",
|
|
130
124
|
schema: ListThreadsParams
|
|
131
125
|
},
|
|
132
126
|
{
|
|
133
127
|
name: "get_thread",
|
|
134
|
-
method: "threads.get",
|
|
135
|
-
description: "Get
|
|
128
|
+
method: "inboxes.threads.get",
|
|
129
|
+
description: "Get thread",
|
|
136
130
|
schema: GetThreadParams
|
|
137
131
|
},
|
|
138
132
|
{
|
|
139
133
|
name: "list_messages",
|
|
140
|
-
method: "messages.list",
|
|
141
|
-
description: "List
|
|
134
|
+
method: "inboxes.messages.list",
|
|
135
|
+
description: "List messages in inbox",
|
|
142
136
|
schema: ListMessagesParams
|
|
143
137
|
},
|
|
144
138
|
{
|
|
145
139
|
name: "get_message",
|
|
146
|
-
method: "messages.get",
|
|
147
|
-
description: "Get
|
|
140
|
+
method: "inboxes.messages.get",
|
|
141
|
+
description: "Get message",
|
|
148
142
|
schema: GetMessageParams
|
|
149
143
|
},
|
|
150
|
-
{
|
|
151
|
-
name: "get_attachment",
|
|
152
|
-
method: "attachments.get",
|
|
153
|
-
description: "Get an attachment by ID",
|
|
154
|
-
schema: GetAttachmentParams
|
|
155
|
-
},
|
|
156
144
|
{
|
|
157
145
|
name: "send_message",
|
|
158
|
-
method: "messages.send",
|
|
159
|
-
description: "Send
|
|
146
|
+
method: "inboxes.messages.send",
|
|
147
|
+
description: "Send message",
|
|
160
148
|
schema: SendMessageParams
|
|
161
149
|
},
|
|
162
150
|
{
|
|
163
151
|
name: "reply_to_message",
|
|
164
|
-
method: "messages.reply",
|
|
165
|
-
description: "Reply to
|
|
152
|
+
method: "inboxes.messages.reply",
|
|
153
|
+
description: "Reply to message",
|
|
166
154
|
schema: ReplyToMessageParams
|
|
167
155
|
}
|
|
168
156
|
];
|
|
169
157
|
|
|
170
158
|
// src/toolkit.ts
|
|
171
|
-
var
|
|
172
|
-
tools =
|
|
159
|
+
var BaseToolkit = class extends Wrapper {
|
|
160
|
+
tools = {};
|
|
173
161
|
constructor(client) {
|
|
174
162
|
super(client);
|
|
175
|
-
this.tools = tools.
|
|
163
|
+
this.tools = tools.reduce(
|
|
164
|
+
(acc, tool) => {
|
|
165
|
+
acc[tool.name] = this.buildTool(tool);
|
|
166
|
+
return acc;
|
|
167
|
+
},
|
|
168
|
+
{}
|
|
169
|
+
);
|
|
176
170
|
}
|
|
177
|
-
|
|
178
|
-
|
|
171
|
+
};
|
|
172
|
+
var ListToolkit = class extends BaseToolkit {
|
|
173
|
+
getTools(names) {
|
|
174
|
+
if (!names) return Object.values(this.tools);
|
|
175
|
+
return names.reduce((acc, name) => {
|
|
176
|
+
if (name in this.tools) acc.push(this.tools[name]);
|
|
177
|
+
return acc;
|
|
178
|
+
}, []);
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
|
|
182
182
|
// src/langchain.ts
|
|
183
183
|
var AgentMailToolkit = class extends ListToolkit {
|
|
184
|
-
constructor(client) {
|
|
185
|
-
super(client);
|
|
186
|
-
}
|
|
187
184
|
buildTool(tool) {
|
|
188
185
|
return (0, import_tools2.tool)(async (args) => JSON.stringify((await this.safeCall(tool.method, args)).result, null, 2), {
|
|
189
186
|
name: tool.name,
|
package/dist/langchain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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(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","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 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 { inboxId, ...options } = args\n\n if (inboxId) return await parent[methodKey].call(parent, inboxId, options)\n else return await parent[methodKey].call(parent, options)\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('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,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,SAAS,GAAG,QAAQ,IAAI;AAEhC,QAAI,QAAS,QAAO,MAAM,OAAO,SAAS,EAAE,KAAK,QAAQ,SAAS,OAAO;AAAA,QACpE,QAAO,MAAM,OAAO,SAAS,EAAE,KAAK,QAAQ,OAAO;AAAA,EAC5D;AAAA,EAEA,MAAa,SAAS,QAAgB,MA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M;AAAA,EAChB;AAAA,EAEU,UAAU,MAA4B;AAC5C,eAAO,cAAAC,MAAc,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":["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'\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","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 { inboxId, ...options } = args\n\n if (inboxId) return await parent[methodKey].call(parent, inboxId, options)\n else return await parent[methodKey].call(parent, options)\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 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 = ListItemsParams.extend({\n inbox_id: z.string().describe('ID of inbox to list threads from'),\n labels: z.array(z.string()).optional().describe('Labels to filter threads by'),\n})\n\nexport const GetThreadParams = z.object({\n inbox_id: z.string().describe('ID of inbox to get thread from'),\n thread_id: z.string().describe('ID of thread to get'),\n})\n\nexport const ListMessagesParams = ListItemsParams.extend({\n inbox_id: z.string().describe('ID of inbox to list messages from'),\n labels: z.array(z.string()).optional().describe('Labels to filter messages by'),\n})\n\nexport const GetMessageParams = z.object({\n inbox_id: z.string().describe('ID of inbox to get message from'),\n message_id: z.string().describe('ID of message 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})\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})\n","import { AnyZodObject } from 'zod'\n\nimport {\n ListItemsParams,\n GetInboxParams,\n CreateInboxParams,\n ListThreadsParams,\n GetThreadParams,\n ListMessagesParams,\n GetMessageParams,\n SendMessageParams,\n ReplyToMessageParams,\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. Use default username, domain, and display name unless otherwise specified.',\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: 'get_thread',\n method: 'inboxes.threads.get',\n description: 'Get thread',\n schema: GetThreadParams,\n },\n {\n name: 'list_messages',\n method: 'inboxes.messages.list',\n description: 'List messages in inbox',\n schema: ListMessagesParams,\n },\n {\n name: 'get_message',\n method: 'inboxes.messages.get',\n description: 'Get message',\n schema: GetMessageParams,\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","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;AAAA,IAAAA,gBAA2D;;;ACA3D,uBAAgC;AAEzB,IAAM,UA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,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;AAGJ;AAEO,IAAe,cAAf,cAAsC,YAAe;AAAA,EACjD,SAAS,OAAkB;AAC9B,QAAI,CAAC,MAAO,QAAO,OAAO,OAAO,KAAK,KAAK;AAE3C,WAAO,MAAM,OAAO,CAAC,KAAK,SAAS;AAC/B,UAAI,QAAQ,KAAK,MAAO,KAAI,KAAK,KAAK,MAAM,IAAI,CAAC;AACjD,aAAO;AAAA,IACX,GAAG,CAAC,CAAQ;AAAA,EAChB;AACJ;;;AJ3BO,IAAM,mBAAN,cAA+B,YAA4B;AAAA,EACpD,UAAU,MAA4B;AAC5C,eAAO,cAAAC,MAAc,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":["import_tools","langchainTool"]}
|
package/dist/langchain.mjs
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ListToolkit
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-QBOE34GE.mjs";
|
|
3
|
+
} from "./chunk-W2LJOBDV.mjs";
|
|
4
|
+
import "./chunk-CIU3KR25.mjs";
|
|
6
5
|
|
|
7
6
|
// src/langchain.ts
|
|
8
7
|
import { tool as langchainTool } from "@langchain/core/tools";
|
|
9
8
|
var AgentMailToolkit = class extends ListToolkit {
|
|
10
|
-
constructor(client) {
|
|
11
|
-
super(client);
|
|
12
|
-
}
|
|
13
9
|
buildTool(tool) {
|
|
14
10
|
return langchainTool(async (args) => JSON.stringify((await this.safeCall(tool.method, args)).result, null, 2), {
|
|
15
11
|
name: tool.name,
|
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'\
|
|
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,9 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { ZodRawShape } from 'zod';
|
|
3
|
+
import { L as ListToolkit } from './toolkit-BLAprE02.mjs';
|
|
4
|
+
import { T as Tool } from './tools-Dzp_FZN_.mjs';
|
|
5
|
+
import 'agentmail';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
interface McpTool {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
paramsSchema: ZodRawShape;
|
|
11
|
+
callback: ToolCallback<ZodRawShape>;
|
|
12
|
+
}
|
|
13
|
+
declare class AgentMailToolkit extends ListToolkit<McpTool> {
|
|
14
|
+
protected buildTool(tool: Tool): McpTool;
|
|
7
15
|
}
|
|
8
16
|
|
|
9
|
-
export {
|
|
17
|
+
export { AgentMailToolkit };
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { ZodRawShape } from 'zod';
|
|
3
|
+
import { L as ListToolkit } from './toolkit-3F468CU6.js';
|
|
4
|
+
import { T as Tool } from './tools-Dzp_FZN_.js';
|
|
5
|
+
import 'agentmail';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
interface McpTool {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
paramsSchema: ZodRawShape;
|
|
11
|
+
callback: ToolCallback<ZodRawShape>;
|
|
12
|
+
}
|
|
13
|
+
declare class AgentMailToolkit extends ListToolkit<McpTool> {
|
|
14
|
+
protected buildTool(tool: Tool): McpTool;
|
|
7
15
|
}
|
|
8
16
|
|
|
9
|
-
export {
|
|
17
|
+
export { AgentMailToolkit };
|
package/dist/mcp.js
CHANGED
|
@@ -20,17 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/mcp.ts
|
|
21
21
|
var mcp_exports = {};
|
|
22
22
|
__export(mcp_exports, {
|
|
23
|
-
|
|
23
|
+
AgentMailToolkit: () => AgentMailToolkit
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(mcp_exports);
|
|
26
|
-
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
27
26
|
|
|
28
27
|
// src/wrapper.ts
|
|
29
28
|
var import_agentmail = require("agentmail");
|
|
30
29
|
var Wrapper = class {
|
|
31
|
-
constructor(client) {
|
|
30
|
+
constructor(client = new import_agentmail.AgentMailClient()) {
|
|
32
31
|
this.client = client;
|
|
33
|
-
if (!this.client) this.client = new import_agentmail.AgentMailClient();
|
|
34
32
|
}
|
|
35
33
|
async call(method, args) {
|
|
36
34
|
const parts = method.split(".");
|
|
@@ -55,52 +53,47 @@ var Wrapper = class {
|
|
|
55
53
|
// src/schemas.ts
|
|
56
54
|
var import_zod = require("zod");
|
|
57
55
|
var ListItemsParams = import_zod.z.object({
|
|
58
|
-
limit: import_zod.z.number().optional().describe("
|
|
59
|
-
|
|
56
|
+
limit: import_zod.z.number().optional().describe("Max number of items to return"),
|
|
57
|
+
page_token: import_zod.z.string().optional().describe("Page token for pagination")
|
|
60
58
|
});
|
|
61
59
|
var GetInboxParams = import_zod.z.object({
|
|
62
|
-
inbox_id: import_zod.z.string().describe("
|
|
60
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to get")
|
|
63
61
|
});
|
|
64
62
|
var CreateInboxParams = import_zod.z.object({
|
|
65
|
-
username: import_zod.z.string().optional().describe("
|
|
66
|
-
domain: import_zod.z.string().optional().describe("
|
|
67
|
-
display_name: import_zod.z.string().optional().describe("
|
|
63
|
+
username: import_zod.z.string().optional().describe("Username of inbox to create"),
|
|
64
|
+
domain: import_zod.z.string().optional().describe("Domain of inbox to create"),
|
|
65
|
+
display_name: import_zod.z.string().optional().describe("Display name of inbox to create")
|
|
68
66
|
});
|
|
69
67
|
var ListThreadsParams = ListItemsParams.extend({
|
|
70
|
-
inbox_id: import_zod.z.string().describe("
|
|
71
|
-
labels: import_zod.z.array(import_zod.z.string()).optional().describe("
|
|
68
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to list threads from"),
|
|
69
|
+
labels: import_zod.z.array(import_zod.z.string()).optional().describe("Labels to filter threads by")
|
|
72
70
|
});
|
|
73
71
|
var GetThreadParams = import_zod.z.object({
|
|
74
|
-
inbox_id: import_zod.z.string().describe("
|
|
75
|
-
thread_id: import_zod.z.string().describe("
|
|
72
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to get thread from"),
|
|
73
|
+
thread_id: import_zod.z.string().describe("ID of thread to get")
|
|
76
74
|
});
|
|
77
75
|
var ListMessagesParams = ListItemsParams.extend({
|
|
78
|
-
inbox_id: import_zod.z.string().describe("
|
|
79
|
-
labels: import_zod.z.array(import_zod.z.string()).optional().describe("
|
|
76
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to list messages from"),
|
|
77
|
+
labels: import_zod.z.array(import_zod.z.string()).optional().describe("Labels to filter messages by")
|
|
80
78
|
});
|
|
81
79
|
var GetMessageParams = import_zod.z.object({
|
|
82
|
-
inbox_id: import_zod.z.string().describe("
|
|
83
|
-
message_id: import_zod.z.string().describe("
|
|
84
|
-
});
|
|
85
|
-
var GetAttachmentParams = import_zod.z.object({
|
|
86
|
-
inbox_id: import_zod.z.string().describe("The ID of the inbox to get the attachment for"),
|
|
87
|
-
message_id: import_zod.z.string().describe("The ID of the message to get the attachment for"),
|
|
88
|
-
attachment_id: import_zod.z.string().describe("The ID of the attachment to get")
|
|
80
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to get message from"),
|
|
81
|
+
message_id: import_zod.z.string().describe("ID of message to get")
|
|
89
82
|
});
|
|
90
83
|
var SendMessageParams = import_zod.z.object({
|
|
91
|
-
inbox_id: import_zod.z.string().describe("
|
|
92
|
-
to: import_zod.z.array(import_zod.z.string()).describe("
|
|
93
|
-
cc: import_zod.z.array(import_zod.z.string()).optional().describe("
|
|
94
|
-
bcc: import_zod.z.array(import_zod.z.string()).optional().describe("
|
|
95
|
-
subject: import_zod.z.string().optional().describe("
|
|
96
|
-
text: import_zod.z.string().optional().describe("
|
|
97
|
-
html: import_zod.z.string().optional().describe("
|
|
84
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to send message from"),
|
|
85
|
+
to: import_zod.z.array(import_zod.z.string()).describe("Recipients of message"),
|
|
86
|
+
cc: import_zod.z.array(import_zod.z.string()).optional().describe("CC recipients of message"),
|
|
87
|
+
bcc: import_zod.z.array(import_zod.z.string()).optional().describe("BCC recipients of message"),
|
|
88
|
+
subject: import_zod.z.string().optional().describe("Subject of message"),
|
|
89
|
+
text: import_zod.z.string().optional().describe("Plain text body of message"),
|
|
90
|
+
html: import_zod.z.string().optional().describe("HTML body of message")
|
|
98
91
|
});
|
|
99
92
|
var ReplyToMessageParams = import_zod.z.object({
|
|
100
|
-
inbox_id: import_zod.z.string().describe("
|
|
101
|
-
message_id: import_zod.z.string().describe("
|
|
102
|
-
text: import_zod.z.string().optional().describe("
|
|
103
|
-
html: import_zod.z.string().optional().describe("
|
|
93
|
+
inbox_id: import_zod.z.string().describe("ID of inbox to reply to message from"),
|
|
94
|
+
message_id: import_zod.z.string().describe("ID of message to reply to"),
|
|
95
|
+
text: import_zod.z.string().optional().describe("Plain text body of reply"),
|
|
96
|
+
html: import_zod.z.string().optional().describe("HTML body of reply")
|
|
104
97
|
});
|
|
105
98
|
|
|
106
99
|
// src/tools.ts
|
|
@@ -108,84 +101,99 @@ var tools = [
|
|
|
108
101
|
{
|
|
109
102
|
name: "list_inboxes",
|
|
110
103
|
method: "inboxes.list",
|
|
111
|
-
description: "List
|
|
104
|
+
description: "List inboxes",
|
|
112
105
|
schema: ListItemsParams
|
|
113
106
|
},
|
|
114
107
|
{
|
|
115
108
|
name: "get_inbox",
|
|
116
109
|
method: "inboxes.get",
|
|
117
|
-
description: "Get
|
|
110
|
+
description: "Get inbox",
|
|
118
111
|
schema: GetInboxParams
|
|
119
112
|
},
|
|
120
113
|
{
|
|
121
114
|
name: "create_inbox",
|
|
122
115
|
method: "inboxes.create",
|
|
123
|
-
description: "Create
|
|
116
|
+
description: "Create inbox. Use default username, domain, and display name unless otherwise specified.",
|
|
124
117
|
schema: CreateInboxParams
|
|
125
118
|
},
|
|
126
119
|
{
|
|
127
120
|
name: "list_threads",
|
|
128
|
-
method: "threads.list",
|
|
129
|
-
description: "List
|
|
121
|
+
method: "inboxes.threads.list",
|
|
122
|
+
description: "List threads in inbox",
|
|
130
123
|
schema: ListThreadsParams
|
|
131
124
|
},
|
|
132
125
|
{
|
|
133
126
|
name: "get_thread",
|
|
134
|
-
method: "threads.get",
|
|
135
|
-
description: "Get
|
|
127
|
+
method: "inboxes.threads.get",
|
|
128
|
+
description: "Get thread",
|
|
136
129
|
schema: GetThreadParams
|
|
137
130
|
},
|
|
138
131
|
{
|
|
139
132
|
name: "list_messages",
|
|
140
|
-
method: "messages.list",
|
|
141
|
-
description: "List
|
|
133
|
+
method: "inboxes.messages.list",
|
|
134
|
+
description: "List messages in inbox",
|
|
142
135
|
schema: ListMessagesParams
|
|
143
136
|
},
|
|
144
137
|
{
|
|
145
138
|
name: "get_message",
|
|
146
|
-
method: "messages.get",
|
|
147
|
-
description: "Get
|
|
139
|
+
method: "inboxes.messages.get",
|
|
140
|
+
description: "Get message",
|
|
148
141
|
schema: GetMessageParams
|
|
149
142
|
},
|
|
150
|
-
{
|
|
151
|
-
name: "get_attachment",
|
|
152
|
-
method: "attachments.get",
|
|
153
|
-
description: "Get an attachment by ID",
|
|
154
|
-
schema: GetAttachmentParams
|
|
155
|
-
},
|
|
156
143
|
{
|
|
157
144
|
name: "send_message",
|
|
158
|
-
method: "messages.send",
|
|
159
|
-
description: "Send
|
|
145
|
+
method: "inboxes.messages.send",
|
|
146
|
+
description: "Send message",
|
|
160
147
|
schema: SendMessageParams
|
|
161
148
|
},
|
|
162
149
|
{
|
|
163
150
|
name: "reply_to_message",
|
|
164
|
-
method: "messages.reply",
|
|
165
|
-
description: "Reply to
|
|
151
|
+
method: "inboxes.messages.reply",
|
|
152
|
+
description: "Reply to message",
|
|
166
153
|
schema: ReplyToMessageParams
|
|
167
154
|
}
|
|
168
155
|
];
|
|
169
156
|
|
|
170
|
-
// src/
|
|
171
|
-
var
|
|
172
|
-
|
|
157
|
+
// src/toolkit.ts
|
|
158
|
+
var BaseToolkit = class extends Wrapper {
|
|
159
|
+
tools = {};
|
|
173
160
|
constructor(client) {
|
|
174
|
-
super(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
161
|
+
super(client);
|
|
162
|
+
this.tools = tools.reduce(
|
|
163
|
+
(acc, tool) => {
|
|
164
|
+
acc[tool.name] = this.buildTool(tool);
|
|
165
|
+
return acc;
|
|
166
|
+
},
|
|
167
|
+
{}
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
var ListToolkit = class extends BaseToolkit {
|
|
172
|
+
getTools(names) {
|
|
173
|
+
if (!names) return Object.values(this.tools);
|
|
174
|
+
return names.reduce((acc, name) => {
|
|
175
|
+
if (name in this.tools) acc.push(this.tools[name]);
|
|
176
|
+
return acc;
|
|
177
|
+
}, []);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// src/mcp.ts
|
|
182
|
+
var AgentMailToolkit = class extends ListToolkit {
|
|
183
|
+
buildTool(tool) {
|
|
184
|
+
return {
|
|
185
|
+
name: tool.name,
|
|
186
|
+
description: tool.description,
|
|
187
|
+
paramsSchema: tool.schema.shape,
|
|
188
|
+
callback: async (args) => {
|
|
189
|
+
const { isError, result } = await this.safeCall(tool.method, args);
|
|
182
190
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], isError };
|
|
183
|
-
}
|
|
184
|
-
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
185
193
|
}
|
|
186
194
|
};
|
|
187
195
|
// Annotate the CommonJS export names for ESM import in node:
|
|
188
196
|
0 && (module.exports = {
|
|
189
|
-
|
|
197
|
+
AgentMailToolkit
|
|
190
198
|
});
|
|
191
199
|
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mcp.ts","../src/wrapper.ts","../src/schemas.ts","../src/tools.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { AgentMailClient } from 'agentmail'\n\nimport { Wrapper } from './wrapper'\nimport { tools } from './tools'\n\nexport class AgentMailMcpServer extends McpServer {\n private wrapper: Wrapper\n\n constructor(client?: AgentMailClient) {\n super({\n name: 'AgentMail',\n version: '0.1.0',\n })\n\n this.wrapper = new Wrapper(client)\n\n for (const tool of tools) {\n this.tool(tool.name, tool.description, tool.schema.shape, async (args: unknown) => {\n const { isError, result } = await this.wrapper.safeCall(tool.method, args)\n return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }], isError }\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 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 { inboxId, ...options } = args\n\n if (inboxId) return await parent[methodKey].call(parent, inboxId, options)\n else return await parent[methodKey].call(parent, options)\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('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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA0B;;;ACA1B,uBAAgC;AAEzB,IAAM,UAAN,MAAc;AAAA,EACjB,YAA6B,QAA0B;AAA1B;AACzB,QAAI,CAAC,KAAK,OAAQ,MAAK,SAAS,IAAI,iCAAgB;AAAA,EACxD;AAAA,EAEA,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,SAAS,GAAG,QAAQ,IAAI;AAEhC,QAAI,QAAS,QAAO,MAAM,OAAO,SAAS,EAAE,KAAK,QAAQ,SAAS,OAAO;AAAA,QACpE,QAAO,MAAM,OAAO,SAAS,EAAE,KAAK,QAAQ,OAAO;AAAA,EAC5D;AAAA,EAEA,MAAa,SAAS,Q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MAAM,KAAK,QAAQ,SAAS,KAAK,QAAQ,IAAI;AACzE,eAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,EAAE,CAAC,GAAG,QAAQ;AAAA,MAClG,CAAC;AAAA,IACL;AAAA,EACJ;AACJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/mcp.ts","../src/wrapper.ts","../src/schemas.ts","../src/tools.ts","../src/toolkit.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","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 { inboxId, ...options } = args\n\n if (inboxId) return await parent[methodKey].call(parent, inboxId, options)\n else return await parent[methodKey].call(parent, options)\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 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 = ListItemsParams.extend({\n inbox_id: z.string().describe('ID of inbox to list threads from'),\n labels: z.array(z.string()).optional().describe('Labels to filter threads by'),\n})\n\nexport const GetThreadParams = z.object({\n inbox_id: z.string().describe('ID of inbox to get thread from'),\n thread_id: z.string().describe('ID of thread to get'),\n})\n\nexport const ListMessagesParams = ListItemsParams.extend({\n inbox_id: z.string().describe('ID of inbox to list messages from'),\n labels: z.array(z.string()).optional().describe('Labels to filter messages by'),\n})\n\nexport const GetMessageParams = z.object({\n inbox_id: z.string().describe('ID of inbox to get message from'),\n message_id: z.string().describe('ID of message 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})\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})\n","import { AnyZodObject } from 'zod'\n\nimport {\n ListItemsParams,\n GetInboxParams,\n CreateInboxParams,\n ListThreadsParams,\n GetThreadParams,\n ListMessagesParams,\n GetMessageParams,\n SendMessageParams,\n ReplyToMessageParams,\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. Use default username, domain, and display name unless otherwise specified.',\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: 'get_thread',\n method: 'inboxes.threads.get',\n description: 'Get thread',\n schema: GetThreadParams,\n },\n {\n name: 'list_messages',\n method: 'inboxes.messages.list',\n description: 'List messages in inbox',\n schema: ListMessagesParams,\n },\n {\n name: 'get_message',\n method: 'inboxes.messages.get',\n description: 'Get message',\n schema: GetMessageParams,\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","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;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