agentmail-toolkit 0.1.9 → 0.1.10

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/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # AgentMail Toolkit
2
+
3
+ The AgentMail Toolkit integrates popular agent frameworks and protocols including OpenAI Agents SDK, Vercel AI SDK, and Model Context Protocol (MCP) with the AgentMail API.
4
+
5
+ ## Setup
6
+
7
+ Get your API key from [AgentMail](https://agentmail.to)
8
+
9
+ ### Installation
10
+
11
+ ```sh
12
+ npm install agentmail-toolkit
13
+ ```
14
+
15
+ ### Configuration
16
+
17
+ ```sh
18
+ export AGENTMAIL_API_KEY=your-api-key
19
+ ```
20
+
21
+ ### Usage
22
+
23
+ ```typescript
24
+ import { streamText } from 'ai'
25
+ import { openai } from '@ai-sdk/openai'
26
+ import { AgentMailToolkit } from 'agentmail-toolkit/ai-sdk'
27
+
28
+ const result = streamText({
29
+ model: openai('gpt-4o'),
30
+ messages,
31
+ system: 'You are an agent that can send, receive, and manage emails. You were created by AgentMail. When asked to introduce yourself, offer to demonstrate your capabilities.',
32
+ tools: new AgentMailToolkit().getTools(),
33
+ maxSteps: 4,
34
+ })
35
+ ```
@@ -0,0 +1,26 @@
1
+ import { Tool as Tool$1 } from 'ai';
2
+ import { AgentMailClient } from 'agentmail';
3
+ import { z } from 'zod';
4
+
5
+ type Tool = {
6
+ name: string;
7
+ methodName: string;
8
+ description: string;
9
+ paramsSchema: z.ZodObject<any>;
10
+ };
11
+
12
+ declare abstract class Toolkit<T> {
13
+ private readonly client?;
14
+ private readonly tools;
15
+ constructor(client?: AgentMailClient | undefined);
16
+ protected abstract buildTool(tool: Tool): T;
17
+ getTools(): Record<string, T>;
18
+ callMethod(methodName: string, args: unknown): Promise<any>;
19
+ }
20
+
21
+ declare class AgentMailToolkit extends Toolkit<Tool$1> {
22
+ constructor(client?: AgentMailClient);
23
+ protected buildTool(tool: Tool): Tool$1;
24
+ }
25
+
26
+ export { AgentMailToolkit };
package/dist/ai-sdk.d.ts CHANGED
@@ -1,8 +1,26 @@
1
- import { type Tool as AiSdkTool } from 'ai';
1
+ import { Tool as Tool$1 } from 'ai';
2
2
  import { AgentMailClient } from 'agentmail';
3
- import { Toolkit } from './toolkit';
4
- import { type Tool } from './tools';
5
- export declare class AgentMailToolkit extends Toolkit<AiSdkTool> {
3
+ import { z } from 'zod';
4
+
5
+ type Tool = {
6
+ name: string;
7
+ methodName: string;
8
+ description: string;
9
+ paramsSchema: z.ZodObject<any>;
10
+ };
11
+
12
+ declare abstract class Toolkit<T> {
13
+ private readonly client?;
14
+ private readonly tools;
15
+ constructor(client?: AgentMailClient | undefined);
16
+ protected abstract buildTool(tool: Tool): T;
17
+ getTools(): Record<string, T>;
18
+ callMethod(methodName: string, args: unknown): Promise<any>;
19
+ }
20
+
21
+ declare class AgentMailToolkit extends Toolkit<Tool$1> {
6
22
  constructor(client?: AgentMailClient);
7
- protected buildTool(tool: Tool): AiSdkTool;
23
+ protected buildTool(tool: Tool): Tool$1;
8
24
  }
25
+
26
+ export { AgentMailToolkit };
package/dist/ai-sdk.js CHANGED
@@ -1,17 +1,211 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AgentMailToolkit = void 0;
4
- const toolkit_1 = require("./toolkit");
5
- class AgentMailToolkit extends toolkit_1.Toolkit {
6
- constructor(client) {
7
- super(client);
8
- }
9
- buildTool(tool) {
10
- return {
11
- description: tool.description,
12
- parameters: tool.paramsSchema,
13
- execute: (args) => this.callMethod(tool.methodName, args),
14
- };
15
- }
16
- }
17
- exports.AgentMailToolkit = AgentMailToolkit;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var __async = (__this, __arguments, generator) => {
20
+ return new Promise((resolve, reject) => {
21
+ var fulfilled = (value) => {
22
+ try {
23
+ step(generator.next(value));
24
+ } catch (e) {
25
+ reject(e);
26
+ }
27
+ };
28
+ var rejected = (value) => {
29
+ try {
30
+ step(generator.throw(value));
31
+ } catch (e) {
32
+ reject(e);
33
+ }
34
+ };
35
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
36
+ step((generator = generator.apply(__this, __arguments)).next());
37
+ });
38
+ };
39
+
40
+ // src/ai-sdk.ts
41
+ var ai_sdk_exports = {};
42
+ __export(ai_sdk_exports, {
43
+ AgentMailToolkit: () => AgentMailToolkit
44
+ });
45
+ module.exports = __toCommonJS(ai_sdk_exports);
46
+
47
+ // src/toolkit.ts
48
+ var import_agentmail = require("agentmail");
49
+
50
+ // src/schemas.ts
51
+ var import_zod = require("zod");
52
+ var ListItemsParams = import_zod.z.object({
53
+ limit: import_zod.z.number().optional().describe("The maximum number of items to return"),
54
+ last_key: import_zod.z.string().optional().describe("The last key to use for pagination")
55
+ });
56
+ var GetInboxParams = import_zod.z.object({
57
+ inbox_id: import_zod.z.string().describe("The ID of the inbox to get")
58
+ });
59
+ var CreateInboxParams = import_zod.z.object({
60
+ username: import_zod.z.string().optional().describe("The username of the inbox to create."),
61
+ domain: import_zod.z.string().optional().describe("The domain of the inbox to create."),
62
+ display_name: import_zod.z.string().optional().describe("The display name of the inbox to create.")
63
+ });
64
+ var ListThreadsParams = ListItemsParams.extend({
65
+ inbox_id: import_zod.z.string().describe("The ID of the inbox to list threads for"),
66
+ received: import_zod.z.boolean().optional().describe("Whether to filter by received threads"),
67
+ sent: import_zod.z.boolean().optional().describe("Whether to filter by sent threads")
68
+ });
69
+ var GetThreadParams = import_zod.z.object({
70
+ inbox_id: import_zod.z.string().describe("The ID of the inbox to get the thread for"),
71
+ thread_id: import_zod.z.string().describe("The ID of the thread to get")
72
+ });
73
+ var ListMessagesParams = ListItemsParams.extend({
74
+ inbox_id: import_zod.z.string().describe("The ID of the inbox to list messages for")
75
+ });
76
+ var GetMessageParams = import_zod.z.object({
77
+ inbox_id: import_zod.z.string().describe("The ID of the inbox to get the message for"),
78
+ message_id: import_zod.z.string().describe("The ID of the message to get")
79
+ });
80
+ var GetAttachmentParams = import_zod.z.object({
81
+ inbox_id: import_zod.z.string().describe("The ID of the inbox to get the attachment for"),
82
+ message_id: import_zod.z.string().describe("The ID of the message to get the attachment for"),
83
+ attachment_id: import_zod.z.string().describe("The ID of the attachment to get")
84
+ });
85
+ var SendMessageParams = import_zod.z.object({
86
+ inbox_id: import_zod.z.string().describe("The ID of the inbox to send the message from"),
87
+ to: import_zod.z.array(import_zod.z.string()).describe("The list of recipients"),
88
+ cc: import_zod.z.array(import_zod.z.string()).optional().describe("The list of CC recipients"),
89
+ bcc: import_zod.z.array(import_zod.z.string()).optional().describe("The list of BCC recipients"),
90
+ subject: import_zod.z.string().optional().describe("The subject of the message"),
91
+ text: import_zod.z.string().optional().describe("The plain text body of the message"),
92
+ html: import_zod.z.string().optional().describe("The HTML body of the message")
93
+ });
94
+ var ReplyToMessageParams = import_zod.z.object({
95
+ inbox_id: import_zod.z.string().describe("The inboc ID of the inbox to reply to the message from"),
96
+ message_id: import_zod.z.string().describe("The message ID of the message you wish to reply to"),
97
+ text: import_zod.z.string().optional().describe("The plain text body of the reply"),
98
+ html: import_zod.z.string().optional().describe("The HTML body of the reply")
99
+ });
100
+
101
+ // src/tools.ts
102
+ var tools = [
103
+ {
104
+ name: "list_inboxes",
105
+ methodName: "inboxes.list",
106
+ description: "List all inboxes",
107
+ paramsSchema: ListItemsParams
108
+ },
109
+ {
110
+ name: "get_inbox",
111
+ methodName: "inboxes.get",
112
+ description: "Get an inbox by ID",
113
+ paramsSchema: GetInboxParams
114
+ },
115
+ {
116
+ name: "create_inbox",
117
+ methodName: "inboxes.create",
118
+ description: "Create a new inbox",
119
+ paramsSchema: CreateInboxParams
120
+ },
121
+ {
122
+ name: "list_threads",
123
+ methodName: "threads.list",
124
+ description: "List all threads",
125
+ paramsSchema: ListThreadsParams
126
+ },
127
+ {
128
+ name: "get_thread",
129
+ methodName: "threads.get",
130
+ description: "Get a thread by ID",
131
+ paramsSchema: GetThreadParams
132
+ },
133
+ {
134
+ name: "list_messages",
135
+ methodName: "messages.list",
136
+ description: "List all messages",
137
+ paramsSchema: ListMessagesParams
138
+ },
139
+ {
140
+ name: "get_message",
141
+ methodName: "messages.get",
142
+ description: "Get a message by ID",
143
+ paramsSchema: GetMessageParams
144
+ },
145
+ {
146
+ name: "get_attachment",
147
+ methodName: "attachments.get",
148
+ description: "Get an attachment by ID",
149
+ paramsSchema: GetAttachmentParams
150
+ },
151
+ {
152
+ name: "send_message",
153
+ methodName: "messages.send",
154
+ description: "Send a message",
155
+ paramsSchema: SendMessageParams
156
+ },
157
+ {
158
+ name: "reply_to_message",
159
+ methodName: "messages.reply",
160
+ description: "Reply to a message",
161
+ paramsSchema: ReplyToMessageParams
162
+ }
163
+ ];
164
+
165
+ // src/toolkit.ts
166
+ var Toolkit = class {
167
+ constructor(client) {
168
+ this.client = client;
169
+ this.tools = {};
170
+ if (!this.client) this.client = new import_agentmail.AgentMailClient();
171
+ this.tools = tools.reduce(
172
+ (acc, tool) => {
173
+ acc[tool.name] = this.buildTool(tool);
174
+ return acc;
175
+ },
176
+ {}
177
+ );
178
+ }
179
+ getTools() {
180
+ return this.tools;
181
+ }
182
+ callMethod(methodName, args) {
183
+ return __async(this, null, function* () {
184
+ const parts = methodName.split(".");
185
+ const methodKey = parts.pop();
186
+ if (!methodKey) throw new Error("Method name empty");
187
+ let parent = this.client;
188
+ for (const part of parts) parent = parent[part];
189
+ return yield parent[methodKey].call(parent, args);
190
+ });
191
+ }
192
+ };
193
+
194
+ // src/ai-sdk.ts
195
+ var AgentMailToolkit = class extends Toolkit {
196
+ constructor(client) {
197
+ super(client);
198
+ }
199
+ buildTool(tool) {
200
+ return {
201
+ description: tool.description,
202
+ parameters: tool.paramsSchema,
203
+ execute: (args) => this.callMethod(tool.methodName, args)
204
+ };
205
+ }
206
+ };
207
+ // Annotate the CommonJS export names for ESM import in node:
208
+ 0 && (module.exports = {
209
+ AgentMailToolkit
210
+ });
211
+ //# sourceMappingURL=ai-sdk.js.map
@@ -0,0 +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","import { AgentMailClient } from 'agentmail'\nimport { type Tool, tools } from './tools'\n\nexport abstract class Toolkit<T> {\n private 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,a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AAmB;AAAA,EACrD,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,YAAY,IAAI;AAAA,IAC5D;AAAA,EACJ;AACJ;","names":[]}
@@ -0,0 +1,185 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+
22
+ // src/toolkit.ts
23
+ import { AgentMailClient } from "agentmail";
24
+
25
+ // src/schemas.ts
26
+ import { z } from "zod";
27
+ var ListItemsParams = z.object({
28
+ limit: z.number().optional().describe("The maximum number of items to return"),
29
+ last_key: z.string().optional().describe("The last key to use for pagination")
30
+ });
31
+ var GetInboxParams = z.object({
32
+ inbox_id: z.string().describe("The ID of the inbox to get")
33
+ });
34
+ var CreateInboxParams = z.object({
35
+ username: z.string().optional().describe("The username of the inbox to create."),
36
+ domain: z.string().optional().describe("The domain of the inbox to create."),
37
+ display_name: z.string().optional().describe("The display name of the inbox to create.")
38
+ });
39
+ var ListThreadsParams = ListItemsParams.extend({
40
+ inbox_id: z.string().describe("The ID of the inbox to list threads for"),
41
+ received: z.boolean().optional().describe("Whether to filter by received threads"),
42
+ sent: z.boolean().optional().describe("Whether to filter by sent threads")
43
+ });
44
+ var GetThreadParams = z.object({
45
+ inbox_id: z.string().describe("The ID of the inbox to get the thread for"),
46
+ thread_id: z.string().describe("The ID of the thread to get")
47
+ });
48
+ var ListMessagesParams = ListItemsParams.extend({
49
+ inbox_id: z.string().describe("The ID of the inbox to list messages for")
50
+ });
51
+ var GetMessageParams = z.object({
52
+ inbox_id: z.string().describe("The ID of the inbox to get the message for"),
53
+ message_id: z.string().describe("The ID of the message to get")
54
+ });
55
+ var GetAttachmentParams = z.object({
56
+ inbox_id: z.string().describe("The ID of the inbox to get the attachment for"),
57
+ message_id: z.string().describe("The ID of the message to get the attachment for"),
58
+ attachment_id: z.string().describe("The ID of the attachment to get")
59
+ });
60
+ var SendMessageParams = z.object({
61
+ inbox_id: z.string().describe("The ID of the inbox to send the message from"),
62
+ to: z.array(z.string()).describe("The list of recipients"),
63
+ cc: z.array(z.string()).optional().describe("The list of CC recipients"),
64
+ bcc: z.array(z.string()).optional().describe("The list of BCC recipients"),
65
+ subject: z.string().optional().describe("The subject of the message"),
66
+ text: z.string().optional().describe("The plain text body of the message"),
67
+ html: z.string().optional().describe("The HTML body of the message")
68
+ });
69
+ var ReplyToMessageParams = z.object({
70
+ inbox_id: z.string().describe("The inboc ID of the inbox to reply to the message from"),
71
+ message_id: z.string().describe("The message ID of the message you wish to reply to"),
72
+ text: z.string().optional().describe("The plain text body of the reply"),
73
+ html: z.string().optional().describe("The HTML body of the reply")
74
+ });
75
+
76
+ // src/tools.ts
77
+ var tools = [
78
+ {
79
+ name: "list_inboxes",
80
+ methodName: "inboxes.list",
81
+ description: "List all inboxes",
82
+ paramsSchema: ListItemsParams
83
+ },
84
+ {
85
+ name: "get_inbox",
86
+ methodName: "inboxes.get",
87
+ description: "Get an inbox by ID",
88
+ paramsSchema: GetInboxParams
89
+ },
90
+ {
91
+ name: "create_inbox",
92
+ methodName: "inboxes.create",
93
+ description: "Create a new inbox",
94
+ paramsSchema: CreateInboxParams
95
+ },
96
+ {
97
+ name: "list_threads",
98
+ methodName: "threads.list",
99
+ description: "List all threads",
100
+ paramsSchema: ListThreadsParams
101
+ },
102
+ {
103
+ name: "get_thread",
104
+ methodName: "threads.get",
105
+ description: "Get a thread by ID",
106
+ paramsSchema: GetThreadParams
107
+ },
108
+ {
109
+ name: "list_messages",
110
+ methodName: "messages.list",
111
+ description: "List all messages",
112
+ paramsSchema: ListMessagesParams
113
+ },
114
+ {
115
+ name: "get_message",
116
+ methodName: "messages.get",
117
+ description: "Get a message by ID",
118
+ paramsSchema: GetMessageParams
119
+ },
120
+ {
121
+ name: "get_attachment",
122
+ methodName: "attachments.get",
123
+ description: "Get an attachment by ID",
124
+ paramsSchema: GetAttachmentParams
125
+ },
126
+ {
127
+ name: "send_message",
128
+ methodName: "messages.send",
129
+ description: "Send a message",
130
+ paramsSchema: SendMessageParams
131
+ },
132
+ {
133
+ name: "reply_to_message",
134
+ methodName: "messages.reply",
135
+ description: "Reply to a message",
136
+ paramsSchema: ReplyToMessageParams
137
+ }
138
+ ];
139
+
140
+ // src/toolkit.ts
141
+ var Toolkit = class {
142
+ constructor(client) {
143
+ this.client = client;
144
+ this.tools = {};
145
+ if (!this.client) this.client = new AgentMailClient();
146
+ this.tools = tools.reduce(
147
+ (acc, tool) => {
148
+ acc[tool.name] = this.buildTool(tool);
149
+ return acc;
150
+ },
151
+ {}
152
+ );
153
+ }
154
+ getTools() {
155
+ return this.tools;
156
+ }
157
+ callMethod(methodName, args) {
158
+ return __async(this, null, function* () {
159
+ const parts = methodName.split(".");
160
+ const methodKey = parts.pop();
161
+ if (!methodKey) throw new Error("Method name empty");
162
+ let parent = this.client;
163
+ for (const part of parts) parent = parent[part];
164
+ return yield parent[methodKey].call(parent, args);
165
+ });
166
+ }
167
+ };
168
+
169
+ // src/ai-sdk.ts
170
+ var AgentMailToolkit = class extends Toolkit {
171
+ constructor(client) {
172
+ super(client);
173
+ }
174
+ buildTool(tool) {
175
+ return {
176
+ description: tool.description,
177
+ parameters: tool.paramsSchema,
178
+ execute: (args) => this.callMethod(tool.methodName, args)
179
+ };
180
+ }
181
+ };
182
+ export {
183
+ AgentMailToolkit
184
+ };
185
+ //# sourceMappingURL=ai-sdk.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/toolkit.ts","../src/schemas.ts","../src/tools.ts","../src/ai-sdk.ts"],"sourcesContent":["import { AgentMailClient } from 'agentmail'\nimport { type Tool, tools } from './tools'\n\nexport abstract class Toolkit<T> {\n private 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","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,uBAAuB;;;ACAhC,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,oCAAoC;AACjF,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;AAAA,EAC/E,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,oCAAoC;AAAA,EAC3E,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,0CAA0C;AAC3F,CAAC;AAEM,IAAM,oBAAoB,gBAAgB,OAAO;A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,aAAa;AAAA,IACb,cAAc;AAAA,EAClB;AACJ;;;AFhFO,IAAe,UAAf,MAA0B;AAAA,EAG7B,YAA6B,QAA0B;AAA1B;AAF7B,SAAiB,QAA2B,CAAC;AAGzC,QAAI,CAAC,KAAK,OAAQ,MAAK,SAAS,IAAI,gBAAgB;AAEpD,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;AAAA,EAEa,WAAW,YAAoB,MAAe;AAAA;AACvD,YAAM,QAAQ,WAAW,MAAM,GAAG;AAClC,YAAM,YAAY,MAAM,IAAI;AAE5B,UAAI,CAAC,UAAW,OAAM,IAAI,MAAM,mBAAmB;AAEnD,UAAI,SAAc,KAAK;AACvB,iBAAW,QAAQ,MAAO,UAAS,OAAO,IAAI;AAE9C,aAAO,MAAM,OAAO,SAAS,EAAE,KAAK,QAAQ,IAAI;AAAA,IACpD;AAAA;AACJ;;;AG7BO,IAAM,mBAAN,cAA+B,QAAmB;AAAA,EACrD,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,YAAY,IAAI;AAAA,IAC5D;AAAA,EACJ;AACJ;","names":[]}
package/package.json CHANGED
@@ -1,16 +1,19 @@
1
1
  {
2
2
  "name": "agentmail-toolkit",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "AgentMail Toolkit",
5
- "files": ["dist/**/*"],
5
+ "files": [
6
+ "dist/**/*"
7
+ ],
6
8
  "exports": {
7
9
  "./ai-sdk": {
8
10
  "types": "./dist/ai-sdk.d.ts",
9
- "default": "./dist/ai-sdk.js"
11
+ "import": "./dist/ai-sdk.mjs",
12
+ "require": "./dist/ai-sdk.js"
10
13
  }
11
14
  },
12
15
  "scripts": {
13
- "build": "tsc",
16
+ "build": "tsup",
14
17
  "lint": "eslint .",
15
18
  "test": "echo \"Error: no test specified\" && exit 1"
16
19
  },
@@ -35,6 +38,7 @@
35
38
  "globals": "^16.0.0",
36
39
  "prettier": "3.5.3",
37
40
  "ts-node": "^10.9.2",
41
+ "tsup": "^8.4.0",
38
42
  "typescript": "^5.8.2",
39
43
  "typescript-eslint": "^8.26.1"
40
44
  },
package/dist/schemas.d.ts DELETED
@@ -1,139 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const ListItemsParams: z.ZodObject<{
3
- limit: z.ZodOptional<z.ZodNumber>;
4
- last_key: z.ZodOptional<z.ZodString>;
5
- }, "strip", z.ZodTypeAny, {
6
- limit?: number | undefined;
7
- last_key?: string | undefined;
8
- }, {
9
- limit?: number | undefined;
10
- last_key?: string | undefined;
11
- }>;
12
- export declare const GetInboxParams: z.ZodObject<{
13
- inbox_id: z.ZodString;
14
- }, "strip", z.ZodTypeAny, {
15
- inbox_id: string;
16
- }, {
17
- inbox_id: string;
18
- }>;
19
- export declare const CreateInboxParams: z.ZodObject<{
20
- username: z.ZodOptional<z.ZodString>;
21
- domain: z.ZodOptional<z.ZodString>;
22
- display_name: z.ZodOptional<z.ZodString>;
23
- }, "strip", z.ZodTypeAny, {
24
- username?: string | undefined;
25
- domain?: string | undefined;
26
- display_name?: string | undefined;
27
- }, {
28
- username?: string | undefined;
29
- domain?: string | undefined;
30
- display_name?: string | undefined;
31
- }>;
32
- export declare const ListThreadsParams: z.ZodObject<z.objectUtil.extendShape<{
33
- limit: z.ZodOptional<z.ZodNumber>;
34
- last_key: z.ZodOptional<z.ZodString>;
35
- }, {
36
- inbox_id: z.ZodString;
37
- received: z.ZodOptional<z.ZodBoolean>;
38
- sent: z.ZodOptional<z.ZodBoolean>;
39
- }>, "strip", z.ZodTypeAny, {
40
- inbox_id: string;
41
- limit?: number | undefined;
42
- last_key?: string | undefined;
43
- received?: boolean | undefined;
44
- sent?: boolean | undefined;
45
- }, {
46
- inbox_id: string;
47
- limit?: number | undefined;
48
- last_key?: string | undefined;
49
- received?: boolean | undefined;
50
- sent?: boolean | undefined;
51
- }>;
52
- export declare const GetThreadParams: z.ZodObject<{
53
- inbox_id: z.ZodString;
54
- thread_id: z.ZodString;
55
- }, "strip", z.ZodTypeAny, {
56
- inbox_id: string;
57
- thread_id: string;
58
- }, {
59
- inbox_id: string;
60
- thread_id: string;
61
- }>;
62
- export declare const ListMessagesParams: z.ZodObject<z.objectUtil.extendShape<{
63
- limit: z.ZodOptional<z.ZodNumber>;
64
- last_key: z.ZodOptional<z.ZodString>;
65
- }, {
66
- inbox_id: z.ZodString;
67
- }>, "strip", z.ZodTypeAny, {
68
- inbox_id: string;
69
- limit?: number | undefined;
70
- last_key?: string | undefined;
71
- }, {
72
- inbox_id: string;
73
- limit?: number | undefined;
74
- last_key?: string | undefined;
75
- }>;
76
- export declare const GetMessageParams: z.ZodObject<{
77
- inbox_id: z.ZodString;
78
- message_id: z.ZodString;
79
- }, "strip", z.ZodTypeAny, {
80
- inbox_id: string;
81
- message_id: string;
82
- }, {
83
- inbox_id: string;
84
- message_id: string;
85
- }>;
86
- export declare const GetAttachmentParams: z.ZodObject<{
87
- inbox_id: z.ZodString;
88
- message_id: z.ZodString;
89
- attachment_id: z.ZodString;
90
- }, "strip", z.ZodTypeAny, {
91
- inbox_id: string;
92
- message_id: string;
93
- attachment_id: string;
94
- }, {
95
- inbox_id: string;
96
- message_id: string;
97
- attachment_id: string;
98
- }>;
99
- export declare const SendMessageParams: z.ZodObject<{
100
- inbox_id: z.ZodString;
101
- to: z.ZodArray<z.ZodString, "many">;
102
- cc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
103
- bcc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
104
- subject: z.ZodOptional<z.ZodString>;
105
- text: z.ZodOptional<z.ZodString>;
106
- html: z.ZodOptional<z.ZodString>;
107
- }, "strip", z.ZodTypeAny, {
108
- inbox_id: string;
109
- to: string[];
110
- cc?: string[] | undefined;
111
- bcc?: string[] | undefined;
112
- subject?: string | undefined;
113
- text?: string | undefined;
114
- html?: string | undefined;
115
- }, {
116
- inbox_id: string;
117
- to: string[];
118
- cc?: string[] | undefined;
119
- bcc?: string[] | undefined;
120
- subject?: string | undefined;
121
- text?: string | undefined;
122
- html?: string | undefined;
123
- }>;
124
- export declare const ReplyToMessageParams: z.ZodObject<{
125
- inbox_id: z.ZodString;
126
- message_id: z.ZodString;
127
- text: z.ZodOptional<z.ZodString>;
128
- html: z.ZodOptional<z.ZodString>;
129
- }, "strip", z.ZodTypeAny, {
130
- inbox_id: string;
131
- message_id: string;
132
- text?: string | undefined;
133
- html?: string | undefined;
134
- }, {
135
- inbox_id: string;
136
- message_id: string;
137
- text?: string | undefined;
138
- html?: string | undefined;
139
- }>;
package/dist/schemas.js DELETED
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReplyToMessageParams = exports.SendMessageParams = exports.GetAttachmentParams = exports.GetMessageParams = exports.ListMessagesParams = exports.GetThreadParams = exports.ListThreadsParams = exports.CreateInboxParams = exports.GetInboxParams = exports.ListItemsParams = void 0;
4
- const zod_1 = require("zod");
5
- exports.ListItemsParams = zod_1.z.object({
6
- limit: zod_1.z.number().optional().describe('The maximum number of items to return'),
7
- last_key: zod_1.z.string().optional().describe('The last key to use for pagination'),
8
- });
9
- exports.GetInboxParams = zod_1.z.object({
10
- inbox_id: zod_1.z.string().describe('The ID of the inbox to get'),
11
- });
12
- exports.CreateInboxParams = zod_1.z.object({
13
- username: zod_1.z.string().optional().describe('The username of the inbox to create.'),
14
- domain: zod_1.z.string().optional().describe('The domain of the inbox to create.'),
15
- display_name: zod_1.z.string().optional().describe('The display name of the inbox to create.'),
16
- });
17
- exports.ListThreadsParams = exports.ListItemsParams.extend({
18
- inbox_id: zod_1.z.string().describe('The ID of the inbox to list threads for'),
19
- received: zod_1.z.boolean().optional().describe('Whether to filter by received threads'),
20
- sent: zod_1.z.boolean().optional().describe('Whether to filter by sent threads'),
21
- });
22
- exports.GetThreadParams = zod_1.z.object({
23
- inbox_id: zod_1.z.string().describe('The ID of the inbox to get the thread for'),
24
- thread_id: zod_1.z.string().describe('The ID of the thread to get'),
25
- });
26
- exports.ListMessagesParams = exports.ListItemsParams.extend({
27
- inbox_id: zod_1.z.string().describe('The ID of the inbox to list messages for'),
28
- });
29
- exports.GetMessageParams = zod_1.z.object({
30
- inbox_id: zod_1.z.string().describe('The ID of the inbox to get the message for'),
31
- message_id: zod_1.z.string().describe('The ID of the message to get'),
32
- });
33
- exports.GetAttachmentParams = zod_1.z.object({
34
- inbox_id: zod_1.z.string().describe('The ID of the inbox to get the attachment for'),
35
- message_id: zod_1.z.string().describe('The ID of the message to get the attachment for'),
36
- attachment_id: zod_1.z.string().describe('The ID of the attachment to get'),
37
- });
38
- exports.SendMessageParams = zod_1.z.object({
39
- inbox_id: zod_1.z.string().describe('The ID of the inbox to send the message from'),
40
- to: zod_1.z.array(zod_1.z.string()).describe('The list of recipients'),
41
- cc: zod_1.z.array(zod_1.z.string()).optional().describe('The list of CC recipients'),
42
- bcc: zod_1.z.array(zod_1.z.string()).optional().describe('The list of BCC recipients'),
43
- subject: zod_1.z.string().optional().describe('The subject of the message'),
44
- text: zod_1.z.string().optional().describe('The plain text body of the message'),
45
- html: zod_1.z.string().optional().describe('The HTML body of the message'),
46
- });
47
- exports.ReplyToMessageParams = zod_1.z.object({
48
- inbox_id: zod_1.z.string().describe('The inboc ID of the inbox to reply to the message from'),
49
- message_id: zod_1.z.string().describe('The message ID of the message you wish to reply to'),
50
- text: zod_1.z.string().optional().describe('The plain text body of the reply'),
51
- html: zod_1.z.string().optional().describe('The HTML body of the reply'),
52
- });
package/dist/toolkit.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { AgentMailClient } from 'agentmail';
2
- import { type Tool } from './tools';
3
- export declare abstract class Toolkit<T> {
4
- private readonly client?;
5
- private readonly tools;
6
- constructor(client?: AgentMailClient | undefined);
7
- protected abstract buildTool(tool: Tool): T;
8
- getTools(): Record<string, T>;
9
- callMethod(methodName: string, args: unknown): Promise<any>;
10
- }
package/dist/toolkit.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Toolkit = void 0;
13
- const agentmail_1 = require("agentmail");
14
- const tools_1 = require("./tools");
15
- class Toolkit {
16
- constructor(client) {
17
- this.client = client;
18
- this.tools = {};
19
- if (!this.client)
20
- this.client = new agentmail_1.AgentMailClient();
21
- this.tools = tools_1.tools.reduce((acc, tool) => {
22
- acc[tool.name] = this.buildTool(tool);
23
- return acc;
24
- }, {});
25
- }
26
- getTools() {
27
- return this.tools;
28
- }
29
- callMethod(methodName, args) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- const parts = methodName.split('.');
32
- const methodKey = parts.pop();
33
- if (!methodKey)
34
- throw new Error('Method name empty');
35
- let parent = this.client;
36
- for (const part of parts)
37
- parent = parent[part];
38
- return yield parent[methodKey].call(parent, args);
39
- });
40
- }
41
- }
42
- exports.Toolkit = Toolkit;
package/dist/tools.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { z } from 'zod';
2
- export type Tool = {
3
- name: string;
4
- methodName: string;
5
- description: string;
6
- paramsSchema: z.ZodObject<any>;
7
- };
8
- export declare const tools: Tool[];
package/dist/tools.js DELETED
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tools = void 0;
4
- const schemas_1 = require("./schemas");
5
- exports.tools = [
6
- {
7
- name: 'list_inboxes',
8
- methodName: 'inboxes.list',
9
- description: 'List all inboxes',
10
- paramsSchema: schemas_1.ListItemsParams,
11
- },
12
- {
13
- name: 'get_inbox',
14
- methodName: 'inboxes.get',
15
- description: 'Get an inbox by ID',
16
- paramsSchema: schemas_1.GetInboxParams,
17
- },
18
- {
19
- name: 'create_inbox',
20
- methodName: 'inboxes.create',
21
- description: 'Create a new inbox',
22
- paramsSchema: schemas_1.CreateInboxParams,
23
- },
24
- {
25
- name: 'list_threads',
26
- methodName: 'threads.list',
27
- description: 'List all threads',
28
- paramsSchema: schemas_1.ListThreadsParams,
29
- },
30
- {
31
- name: 'get_thread',
32
- methodName: 'threads.get',
33
- description: 'Get a thread by ID',
34
- paramsSchema: schemas_1.GetThreadParams,
35
- },
36
- {
37
- name: 'list_messages',
38
- methodName: 'messages.list',
39
- description: 'List all messages',
40
- paramsSchema: schemas_1.ListMessagesParams,
41
- },
42
- {
43
- name: 'get_message',
44
- methodName: 'messages.get',
45
- description: 'Get a message by ID',
46
- paramsSchema: schemas_1.GetMessageParams,
47
- },
48
- {
49
- name: 'get_attachment',
50
- methodName: 'attachments.get',
51
- description: 'Get an attachment by ID',
52
- paramsSchema: schemas_1.GetAttachmentParams,
53
- },
54
- {
55
- name: 'send_message',
56
- methodName: 'messages.send',
57
- description: 'Send a message',
58
- paramsSchema: schemas_1.SendMessageParams,
59
- },
60
- {
61
- name: 'reply_to_message',
62
- methodName: 'messages.reply',
63
- description: 'Reply to a message',
64
- paramsSchema: schemas_1.ReplyToMessageParams,
65
- },
66
- ];