agentmail-toolkit 0.1.18 → 0.1.19

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/index.d.ts CHANGED
@@ -3,103 +3,103 @@ export { T as Tool, t as tools } from './tools-DFoMkoW0.js';
3
3
 
4
4
  declare const ListItemsParams: z.ZodObject<{
5
5
  limit: z.ZodOptional<z.ZodNumber>;
6
- last_key: z.ZodOptional<z.ZodString>;
6
+ lastKey: z.ZodOptional<z.ZodString>;
7
7
  }, "strip", z.ZodTypeAny, {
8
8
  limit?: number | undefined;
9
- last_key?: string | undefined;
9
+ lastKey?: string | undefined;
10
10
  }, {
11
11
  limit?: number | undefined;
12
- last_key?: string | undefined;
12
+ lastKey?: string | undefined;
13
13
  }>;
14
14
  declare const GetInboxParams: z.ZodObject<{
15
- inbox_id: z.ZodString;
15
+ inboxId: z.ZodString;
16
16
  }, "strip", z.ZodTypeAny, {
17
- inbox_id: string;
17
+ inboxId: string;
18
18
  }, {
19
- inbox_id: string;
19
+ inboxId: string;
20
20
  }>;
21
21
  declare const CreateInboxParams: z.ZodObject<{
22
22
  username: z.ZodOptional<z.ZodString>;
23
23
  domain: z.ZodOptional<z.ZodString>;
24
- display_name: z.ZodOptional<z.ZodString>;
24
+ displayName: z.ZodOptional<z.ZodString>;
25
25
  }, "strip", z.ZodTypeAny, {
26
26
  username?: string | undefined;
27
27
  domain?: string | undefined;
28
- display_name?: string | undefined;
28
+ displayName?: string | undefined;
29
29
  }, {
30
30
  username?: string | undefined;
31
31
  domain?: string | undefined;
32
- display_name?: string | undefined;
32
+ displayName?: string | undefined;
33
33
  }>;
34
34
  declare const ListThreadsParams: z.ZodObject<z.objectUtil.extendShape<{
35
35
  limit: z.ZodOptional<z.ZodNumber>;
36
- last_key: z.ZodOptional<z.ZodString>;
36
+ lastKey: z.ZodOptional<z.ZodString>;
37
37
  }, {
38
- inbox_id: z.ZodString;
38
+ inboxId: z.ZodString;
39
39
  labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
40
40
  }>, "strip", z.ZodTypeAny, {
41
- inbox_id: string;
41
+ inboxId: string;
42
42
  limit?: number | undefined;
43
- last_key?: string | undefined;
43
+ lastKey?: string | undefined;
44
44
  labels?: string[] | undefined;
45
45
  }, {
46
- inbox_id: string;
46
+ inboxId: string;
47
47
  limit?: number | undefined;
48
- last_key?: string | undefined;
48
+ lastKey?: string | undefined;
49
49
  labels?: string[] | undefined;
50
50
  }>;
51
51
  declare const GetThreadParams: z.ZodObject<{
52
- inbox_id: z.ZodString;
53
- thread_id: z.ZodString;
52
+ inboxId: z.ZodString;
53
+ threadId: z.ZodString;
54
54
  }, "strip", z.ZodTypeAny, {
55
- inbox_id: string;
56
- thread_id: string;
55
+ inboxId: string;
56
+ threadId: string;
57
57
  }, {
58
- inbox_id: string;
59
- thread_id: string;
58
+ inboxId: string;
59
+ threadId: string;
60
60
  }>;
61
61
  declare const ListMessagesParams: z.ZodObject<z.objectUtil.extendShape<{
62
62
  limit: z.ZodOptional<z.ZodNumber>;
63
- last_key: z.ZodOptional<z.ZodString>;
63
+ lastKey: z.ZodOptional<z.ZodString>;
64
64
  }, {
65
- inbox_id: z.ZodString;
65
+ inboxId: z.ZodString;
66
66
  labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
67
67
  }>, "strip", z.ZodTypeAny, {
68
- inbox_id: string;
68
+ inboxId: string;
69
69
  limit?: number | undefined;
70
- last_key?: string | undefined;
70
+ lastKey?: string | undefined;
71
71
  labels?: string[] | undefined;
72
72
  }, {
73
- inbox_id: string;
73
+ inboxId: string;
74
74
  limit?: number | undefined;
75
- last_key?: string | undefined;
75
+ lastKey?: string | undefined;
76
76
  labels?: string[] | undefined;
77
77
  }>;
78
78
  declare const GetMessageParams: z.ZodObject<{
79
- inbox_id: z.ZodString;
80
- message_id: z.ZodString;
79
+ inboxId: z.ZodString;
80
+ messageId: z.ZodString;
81
81
  }, "strip", z.ZodTypeAny, {
82
- inbox_id: string;
83
- message_id: string;
82
+ inboxId: string;
83
+ messageId: string;
84
84
  }, {
85
- inbox_id: string;
86
- message_id: string;
85
+ inboxId: string;
86
+ messageId: string;
87
87
  }>;
88
88
  declare const GetAttachmentParams: z.ZodObject<{
89
- inbox_id: z.ZodString;
90
- message_id: z.ZodString;
91
- attachment_id: z.ZodString;
89
+ inboxId: z.ZodString;
90
+ messageId: z.ZodString;
91
+ attachmentId: z.ZodString;
92
92
  }, "strip", z.ZodTypeAny, {
93
- inbox_id: string;
94
- message_id: string;
95
- attachment_id: string;
93
+ inboxId: string;
94
+ messageId: string;
95
+ attachmentId: string;
96
96
  }, {
97
- inbox_id: string;
98
- message_id: string;
99
- attachment_id: string;
97
+ inboxId: string;
98
+ messageId: string;
99
+ attachmentId: string;
100
100
  }>;
101
101
  declare const SendMessageParams: z.ZodObject<{
102
- inbox_id: z.ZodString;
102
+ inboxId: z.ZodString;
103
103
  to: z.ZodArray<z.ZodString, "many">;
104
104
  cc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
105
105
  bcc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -107,7 +107,7 @@ declare const SendMessageParams: z.ZodObject<{
107
107
  text: z.ZodOptional<z.ZodString>;
108
108
  html: z.ZodOptional<z.ZodString>;
109
109
  }, "strip", z.ZodTypeAny, {
110
- inbox_id: string;
110
+ inboxId: string;
111
111
  to: string[];
112
112
  cc?: string[] | undefined;
113
113
  bcc?: string[] | undefined;
@@ -115,7 +115,7 @@ declare const SendMessageParams: z.ZodObject<{
115
115
  text?: string | undefined;
116
116
  html?: string | undefined;
117
117
  }, {
118
- inbox_id: string;
118
+ inboxId: string;
119
119
  to: string[];
120
120
  cc?: string[] | undefined;
121
121
  bcc?: string[] | undefined;
@@ -124,18 +124,18 @@ declare const SendMessageParams: z.ZodObject<{
124
124
  html?: string | undefined;
125
125
  }>;
126
126
  declare const ReplyToMessageParams: z.ZodObject<{
127
- inbox_id: z.ZodString;
128
- message_id: z.ZodString;
127
+ inboxId: z.ZodString;
128
+ messageId: z.ZodString;
129
129
  text: z.ZodOptional<z.ZodString>;
130
130
  html: z.ZodOptional<z.ZodString>;
131
131
  }, "strip", z.ZodTypeAny, {
132
- inbox_id: string;
133
- message_id: string;
132
+ inboxId: string;
133
+ messageId: string;
134
134
  text?: string | undefined;
135
135
  html?: string | undefined;
136
136
  }, {
137
- inbox_id: string;
138
- message_id: string;
137
+ inboxId: string;
138
+ messageId: string;
139
139
  text?: string | undefined;
140
140
  html?: string | undefined;
141
141
  }>;
package/dist/index.js CHANGED
@@ -38,39 +38,39 @@ module.exports = __toCommonJS(index_exports);
38
38
  var import_zod = require("zod");
39
39
  var ListItemsParams = import_zod.z.object({
40
40
  limit: import_zod.z.number().optional().describe("The maximum number of items to return"),
41
- last_key: import_zod.z.string().optional().describe("The last key to use for pagination")
41
+ lastKey: import_zod.z.string().optional().describe("The last key to use for pagination")
42
42
  });
43
43
  var GetInboxParams = import_zod.z.object({
44
- inbox_id: import_zod.z.string().describe("The ID of the inbox to get")
44
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get")
45
45
  });
46
46
  var CreateInboxParams = import_zod.z.object({
47
47
  username: import_zod.z.string().optional().describe("The username of the inbox to create"),
48
48
  domain: import_zod.z.string().optional().describe("The domain of the inbox to create"),
49
- display_name: import_zod.z.string().optional().describe("The display name of the inbox to create")
49
+ displayName: import_zod.z.string().optional().describe("The display name of the inbox to create")
50
50
  });
51
51
  var ListThreadsParams = ListItemsParams.extend({
52
- inbox_id: import_zod.z.string().describe("The ID of the inbox to list threads for"),
52
+ inboxId: import_zod.z.string().describe("The ID of the inbox to list threads for"),
53
53
  labels: import_zod.z.array(import_zod.z.string()).optional().describe("The labels to filter threads by")
54
54
  });
55
55
  var GetThreadParams = import_zod.z.object({
56
- inbox_id: import_zod.z.string().describe("The ID of the inbox to get the thread for"),
57
- thread_id: import_zod.z.string().describe("The ID of the thread to get")
56
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get the thread for"),
57
+ threadId: import_zod.z.string().describe("The ID of the thread to get")
58
58
  });
59
59
  var ListMessagesParams = ListItemsParams.extend({
60
- inbox_id: import_zod.z.string().describe("The ID of the inbox to list messages for"),
60
+ inboxId: import_zod.z.string().describe("The ID of the inbox to list messages for"),
61
61
  labels: import_zod.z.array(import_zod.z.string()).optional().describe("The labels to filter messages by")
62
62
  });
63
63
  var GetMessageParams = import_zod.z.object({
64
- inbox_id: import_zod.z.string().describe("The ID of the inbox to get the message for"),
65
- message_id: import_zod.z.string().describe("The ID of the message to get")
64
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get the message for"),
65
+ messageId: import_zod.z.string().describe("The ID of the message to get")
66
66
  });
67
67
  var GetAttachmentParams = import_zod.z.object({
68
- inbox_id: import_zod.z.string().describe("The ID of the inbox to get the attachment for"),
69
- message_id: import_zod.z.string().describe("The ID of the message to get the attachment for"),
70
- attachment_id: import_zod.z.string().describe("The ID of the attachment to get")
68
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get the attachment for"),
69
+ messageId: import_zod.z.string().describe("The ID of the message to get the attachment for"),
70
+ attachmentId: import_zod.z.string().describe("The ID of the attachment to get")
71
71
  });
72
72
  var SendMessageParams = import_zod.z.object({
73
- inbox_id: import_zod.z.string().describe("The ID of the inbox to send the message from"),
73
+ inboxId: import_zod.z.string().describe("The ID of the inbox to send the message from"),
74
74
  to: import_zod.z.array(import_zod.z.string()).describe("The list of recipients"),
75
75
  cc: import_zod.z.array(import_zod.z.string()).optional().describe("The list of CC recipients"),
76
76
  bcc: import_zod.z.array(import_zod.z.string()).optional().describe("The list of BCC recipients"),
@@ -79,8 +79,8 @@ var SendMessageParams = import_zod.z.object({
79
79
  html: import_zod.z.string().optional().describe("The HTML body of the message")
80
80
  });
81
81
  var ReplyToMessageParams = import_zod.z.object({
82
- inbox_id: import_zod.z.string().describe("The inbox ID of the inbox to reply to the message from"),
83
- message_id: import_zod.z.string().describe("The message ID of the message you wish to reply to"),
82
+ inboxId: import_zod.z.string().describe("The inbox ID of the inbox to reply to the message from"),
83
+ messageId: import_zod.z.string().describe("The message ID of the message you wish to reply to"),
84
84
  text: import_zod.z.string().optional().describe("The plain text body of the reply"),
85
85
  html: import_zod.z.string().optional().describe("The HTML body of the reply")
86
86
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/schemas.ts","../src/tools.ts"],"sourcesContent":["export * from './schemas'\nexport * from './tools'\n","import { z } from 'zod'\n\nexport const ListItemsParams = z.object({\n limit: z.number().optional().describe('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"],"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AAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AACJ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/schemas.ts","../src/tools.ts"],"sourcesContent":["export * from './schemas'\nexport * from './tools'\n","import { z } from 'zod'\n\nexport const ListItemsParams = z.object({\n limit: z.number().optional().describe('The maximum number of items to return'),\n lastKey: z.string().optional().describe('The last key to use for pagination'),\n})\n\nexport const GetInboxParams = z.object({\n inboxId: 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 displayName: z.string().optional().describe('The display name of the inbox to create'),\n})\n\nexport const ListThreadsParams = ListItemsParams.extend({\n inboxId: 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 inboxId: z.string().describe('The ID of the inbox to get the thread for'),\n threadId: z.string().describe('The ID of the thread to get'),\n})\n\nexport const ListMessagesParams = ListItemsParams.extend({\n inboxId: 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 inboxId: z.string().describe('The ID of the inbox to get the message for'),\n messageId: z.string().describe('The ID of the message to get'),\n})\n\nexport const GetAttachmentParams = z.object({\n inboxId: z.string().describe('The ID of the inbox to get the attachment for'),\n messageId: z.string().describe('The ID of the message to get the attachment for'),\n attachmentId: z.string().describe('The ID of the attachment to get'),\n})\n\nexport const SendMessageParams = z.object({\n inboxId: 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 inboxId: z.string().describe('The inbox ID of the inbox to reply to the message from'),\n messageId: 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAEX,IAAM,kBAAkB,aAAE,OAAO;AAAA,EACpC,OAAO,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,uCAAuC;AAAA,EAC7E,SAAS,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,oCAAoC;AAChF,CAAC;AAEM,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACnC,SAAS,aAAE,OAAO,EAAE,SAAS,4BAA4B;AAC7D,CAAC;AAEM,IAAM,oBAAoB,aAAE,OAAO;AAAA,EACtC,UAAU,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,qCAAqC;AAAA,EAC9E,QAAQ,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,mCAAmC;AAAA,EAC1E,aAAa,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,yCAAyC;AACzF,CAAC;AAEM,IAAM,oBAAoB,gBAAgB,OAA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EACA;AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AACJ;","names":[]}
package/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  ReplyToMessageParams,
11
11
  SendMessageParams,
12
12
  tools
13
- } from "./chunk-QBOE34GE.mjs";
13
+ } from "./chunk-DNXRYZOH.mjs";
14
14
  export {
15
15
  CreateInboxParams,
16
16
  GetAttachmentParams,
@@ -1,6 +1,6 @@
1
1
  import { StructuredTool } from '@langchain/core/tools';
2
2
  import { AgentMailClient } from 'agentmail';
3
- import { L as ListToolkit } from './toolkit-DtDXApKD.mjs';
3
+ import { L as ListToolkit } from './toolkit-BMavPn6k.mjs';
4
4
  import { T as Tool } from './tools-DFoMkoW0.mjs';
5
5
  import 'zod';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { StructuredTool } from '@langchain/core/tools';
2
2
  import { AgentMailClient } from 'agentmail';
3
- import { L as ListToolkit } from './toolkit-Dc7siZcx.js';
3
+ import { L as ListToolkit } from './toolkit-Cbpp0Kix.js';
4
4
  import { T as Tool } from './tools-DFoMkoW0.js';
5
5
  import 'zod';
6
6
 
package/dist/langchain.js CHANGED
@@ -32,20 +32,22 @@ var Wrapper = class {
32
32
  this.client = client;
33
33
  if (!this.client) this.client = new import_agentmail.AgentMailClient();
34
34
  }
35
- async callMethod(method, args) {
35
+ async call(method, args) {
36
36
  const parts = method.split(".");
37
37
  const methodKey = parts.pop();
38
38
  if (!methodKey) throw new Error("Method name empty");
39
39
  let parent = this.client;
40
40
  for (const part of parts) parent = parent[part];
41
- return await parent[methodKey].call(parent, args);
41
+ const { inboxId, ...options } = args;
42
+ if (inboxId) return await parent[methodKey].call(parent, inboxId, options);
43
+ else return await parent[methodKey].call(parent, options);
42
44
  }
43
- async callMethodAndStringify(method, args) {
45
+ async safeCall(method, args) {
44
46
  try {
45
- const result = await this.callMethod(method, args);
46
- return JSON.stringify(result, null, 2);
47
+ return { isError: false, result: await this.call(method, args) };
47
48
  } catch (error) {
48
- return JSON.stringify(error, null, 2);
49
+ if (error instanceof Error) return { isError: true, result: error.message };
50
+ else return { isError: true, result: "Unknown error" };
49
51
  }
50
52
  }
51
53
  };
@@ -54,39 +56,39 @@ var Wrapper = class {
54
56
  var import_zod = require("zod");
55
57
  var ListItemsParams = import_zod.z.object({
56
58
  limit: import_zod.z.number().optional().describe("The maximum number of items to return"),
57
- last_key: import_zod.z.string().optional().describe("The last key to use for pagination")
59
+ lastKey: import_zod.z.string().optional().describe("The last key to use for pagination")
58
60
  });
59
61
  var GetInboxParams = import_zod.z.object({
60
- inbox_id: import_zod.z.string().describe("The ID of the inbox to get")
62
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get")
61
63
  });
62
64
  var CreateInboxParams = import_zod.z.object({
63
65
  username: import_zod.z.string().optional().describe("The username of the inbox to create"),
64
66
  domain: import_zod.z.string().optional().describe("The domain of the inbox to create"),
65
- display_name: import_zod.z.string().optional().describe("The display name of the inbox to create")
67
+ displayName: import_zod.z.string().optional().describe("The display name of the inbox to create")
66
68
  });
67
69
  var ListThreadsParams = ListItemsParams.extend({
68
- inbox_id: import_zod.z.string().describe("The ID of the inbox to list threads for"),
70
+ inboxId: import_zod.z.string().describe("The ID of the inbox to list threads for"),
69
71
  labels: import_zod.z.array(import_zod.z.string()).optional().describe("The labels to filter threads by")
70
72
  });
71
73
  var GetThreadParams = import_zod.z.object({
72
- inbox_id: import_zod.z.string().describe("The ID of the inbox to get the thread for"),
73
- thread_id: import_zod.z.string().describe("The ID of the thread to get")
74
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get the thread for"),
75
+ threadId: import_zod.z.string().describe("The ID of the thread to get")
74
76
  });
75
77
  var ListMessagesParams = ListItemsParams.extend({
76
- inbox_id: import_zod.z.string().describe("The ID of the inbox to list messages for"),
78
+ inboxId: import_zod.z.string().describe("The ID of the inbox to list messages for"),
77
79
  labels: import_zod.z.array(import_zod.z.string()).optional().describe("The labels to filter messages by")
78
80
  });
79
81
  var GetMessageParams = import_zod.z.object({
80
- inbox_id: import_zod.z.string().describe("The ID of the inbox to get the message for"),
81
- message_id: import_zod.z.string().describe("The ID of the message to get")
82
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get the message for"),
83
+ messageId: import_zod.z.string().describe("The ID of the message to get")
82
84
  });
83
85
  var GetAttachmentParams = import_zod.z.object({
84
- inbox_id: import_zod.z.string().describe("The ID of the inbox to get the attachment for"),
85
- message_id: import_zod.z.string().describe("The ID of the message to get the attachment for"),
86
- attachment_id: import_zod.z.string().describe("The ID of the attachment to get")
86
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get the attachment for"),
87
+ messageId: import_zod.z.string().describe("The ID of the message to get the attachment for"),
88
+ attachmentId: import_zod.z.string().describe("The ID of the attachment to get")
87
89
  });
88
90
  var SendMessageParams = import_zod.z.object({
89
- inbox_id: import_zod.z.string().describe("The ID of the inbox to send the message from"),
91
+ inboxId: import_zod.z.string().describe("The ID of the inbox to send the message from"),
90
92
  to: import_zod.z.array(import_zod.z.string()).describe("The list of recipients"),
91
93
  cc: import_zod.z.array(import_zod.z.string()).optional().describe("The list of CC recipients"),
92
94
  bcc: import_zod.z.array(import_zod.z.string()).optional().describe("The list of BCC recipients"),
@@ -95,8 +97,8 @@ var SendMessageParams = import_zod.z.object({
95
97
  html: import_zod.z.string().optional().describe("The HTML body of the message")
96
98
  });
97
99
  var ReplyToMessageParams = import_zod.z.object({
98
- inbox_id: import_zod.z.string().describe("The inbox ID of the inbox to reply to the message from"),
99
- message_id: import_zod.z.string().describe("The message ID of the message you wish to reply to"),
100
+ inboxId: import_zod.z.string().describe("The inbox ID of the inbox to reply to the message from"),
101
+ messageId: import_zod.z.string().describe("The message ID of the message you wish to reply to"),
100
102
  text: import_zod.z.string().optional().describe("The plain text body of the reply"),
101
103
  html: import_zod.z.string().optional().describe("The HTML body of the reply")
102
104
  });
@@ -183,7 +185,7 @@ var AgentMailToolkit = class extends ListToolkit {
183
185
  super(client);
184
186
  }
185
187
  buildTool(tool) {
186
- return (0, import_tools2.tool)((args) => this.callMethodAndStringify(tool.method, args), {
188
+ return (0, import_tools2.tool)(async (args) => JSON.stringify((await this.safeCall(tool.method, args)).result, null, 2), {
187
189
  name: tool.name,
188
190
  description: tool.description,
189
191
  schema: tool.schema
@@ -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((args) => this.callMethodAndStringify(tool.method, args), {\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 callMethod(method: string, args: unknown) {\n const parts = method.split('.')\n const methodKey = parts.pop()\n\n if (!methodKey) throw new Error('Method name empty')\n\n let parent: any = this.client\n for (const part of parts) parent = parent[part]\n\n return await parent[methodKey].call(parent, args)\n }\n\n public async callMethodAndStringify(method: string, args: unknown) {\n try {\n const result = await this.callMethod(method, args)\n return JSON.stringify(result, null, 2)\n } catch (error) {\n return JSON.stringify(error, null, 2)\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,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;AAAA,EACZ;AAAA,EACA;AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AACJ;;;AC9EO,IAAe,cAAf,cAAsC,QAAQ;AAAA,EAC9B,QAAa,CAAC;AAAA,EAEjC,YAAY,QAA0B;AAClC,UAAM,MAAM;AAEZ,SAAK,QAAQ,MAAM,IAAI,CAAC,SAAS,KAAK,UAAU,IAAI,CAAC;AAAA,EACzD;AAAA,EAIO,WAAW;AACd,WAAO,KAAK;AAAA,EAChB;AACJ;;;AJbO,IAAM,mBAAN,cAA+B,YAA4B;AAAA,EAC9D,YAAY,QAA0B;AAClC,UAAM,MAAM;AAAA,EAChB;AAAA,EAEU,UAAU,MAA4B;AAC5C,eAAO,cAAAC,MAAc,CAAC,SAAS,KAAK,uBAAuB,KAAK,QAAQ,IAAI,GAAG;AAAA,MAC3E,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'\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 lastKey: z.string().optional().describe('The last key to use for pagination'),\n})\n\nexport const GetInboxParams = z.object({\n inboxId: 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 displayName: z.string().optional().describe('The display name of the inbox to create'),\n})\n\nexport const ListThreadsParams = ListItemsParams.extend({\n inboxId: 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 inboxId: z.string().describe('The ID of the inbox to get the thread for'),\n threadId: z.string().describe('The ID of the thread to get'),\n})\n\nexport const ListMessagesParams = ListItemsParams.extend({\n inboxId: 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 inboxId: z.string().describe('The ID of the inbox to get the message for'),\n messageId: z.string().describe('The ID of the message to get'),\n})\n\nexport const GetAttachmentParams = z.object({\n inboxId: z.string().describe('The ID of the inbox to get the attachment for'),\n messageId: z.string().describe('The ID of the message to get the attachment for'),\n attachmentId: z.string().describe('The ID of the attachment to get'),\n})\n\nexport const SendMessageParams = z.object({\n inboxId: 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 inboxId: z.string().describe('The inbox ID of the inbox to reply to the message from'),\n messageId: 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,MAAW;AAC7C,QAAI;AACA,aAAO,EAAE,SAAS,OAAO,QAAQ,MAAM,KAAK,KAAK,QAAQ,IAAI,EAAE;A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AM,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,8 +1,8 @@
1
1
  import {
2
2
  ListToolkit
3
- } from "./chunk-H3V5ORVZ.mjs";
4
- import "./chunk-3TR24M4E.mjs";
5
- import "./chunk-QBOE34GE.mjs";
3
+ } from "./chunk-WEXYSRNX.mjs";
4
+ import "./chunk-XAJA2AYA.mjs";
5
+ import "./chunk-DNXRYZOH.mjs";
6
6
 
7
7
  // src/langchain.ts
8
8
  import { tool as langchainTool } from "@langchain/core/tools";
@@ -11,7 +11,7 @@ var AgentMailToolkit = class extends ListToolkit {
11
11
  super(client);
12
12
  }
13
13
  buildTool(tool) {
14
- return langchainTool((args) => this.callMethodAndStringify(tool.method, args), {
14
+ return langchainTool(async (args) => JSON.stringify((await this.safeCall(tool.method, args)).result, null, 2), {
15
15
  name: tool.name,
16
16
  description: tool.description,
17
17
  schema: tool.schema
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/langchain.ts"],"sourcesContent":["import { type StructuredTool, tool as langchainTool } from '@langchain/core/tools'\nimport { AgentMailClient } from 'agentmail'\n\nimport { 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((args) => this.callMethodAndStringify(tool.method, args), {\n name: tool.name,\n description: tool.description,\n schema: tool.schema,\n })\n }\n}\n"],"mappings":";;;;;;;AAAA,SAA8B,QAAQ,qBAAqB;AAMpD,IAAM,mBAAN,cAA+B,YAA4B;AAAA,EAC9D,YAAY,QAA0B;AAClC,UAAM,MAAM;AAAA,EAChB;AAAA,EAEU,UAAU,MAA4B;AAC5C,WAAO,cAAc,CAAC,SAAS,KAAK,uBAAuB,KAAK,QAAQ,IAAI,GAAG;AAAA,MAC3E,MAAM,KAAK;AAAA,MACX,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,IACjB,CAAC;AAAA,EACL;AACJ;","names":[]}
1
+ {"version":3,"sources":["../src/langchain.ts"],"sourcesContent":["import { type StructuredTool, tool as langchainTool } from '@langchain/core/tools'\nimport { AgentMailClient } from 'agentmail'\n\nimport { ListToolkit } from './toolkit'\nimport { type Tool } from './tools'\n\nexport class AgentMailToolkit extends ListToolkit<StructuredTool> {\n constructor(client?: AgentMailClient) {\n super(client)\n }\n\n protected buildTool(tool: Tool): StructuredTool {\n return langchainTool(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;AAMpD,IAAM,mBAAN,cAA+B,YAA4B;AAAA,EAC9D,YAAY,QAA0B;AAClC,UAAM,MAAM;AAAA,EAChB;AAAA,EAEU,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.js CHANGED
@@ -32,20 +32,22 @@ var Wrapper = class {
32
32
  this.client = client;
33
33
  if (!this.client) this.client = new import_agentmail.AgentMailClient();
34
34
  }
35
- async callMethod(method, args) {
35
+ async call(method, args) {
36
36
  const parts = method.split(".");
37
37
  const methodKey = parts.pop();
38
38
  if (!methodKey) throw new Error("Method name empty");
39
39
  let parent = this.client;
40
40
  for (const part of parts) parent = parent[part];
41
- return await parent[methodKey].call(parent, args);
41
+ const { inboxId, ...options } = args;
42
+ if (inboxId) return await parent[methodKey].call(parent, inboxId, options);
43
+ else return await parent[methodKey].call(parent, options);
42
44
  }
43
- async callMethodAndStringify(method, args) {
45
+ async safeCall(method, args) {
44
46
  try {
45
- const result = await this.callMethod(method, args);
46
- return JSON.stringify(result, null, 2);
47
+ return { isError: false, result: await this.call(method, args) };
47
48
  } catch (error) {
48
- return JSON.stringify(error, null, 2);
49
+ if (error instanceof Error) return { isError: true, result: error.message };
50
+ else return { isError: true, result: "Unknown error" };
49
51
  }
50
52
  }
51
53
  };
@@ -54,39 +56,39 @@ var Wrapper = class {
54
56
  var import_zod = require("zod");
55
57
  var ListItemsParams = import_zod.z.object({
56
58
  limit: import_zod.z.number().optional().describe("The maximum number of items to return"),
57
- last_key: import_zod.z.string().optional().describe("The last key to use for pagination")
59
+ lastKey: import_zod.z.string().optional().describe("The last key to use for pagination")
58
60
  });
59
61
  var GetInboxParams = import_zod.z.object({
60
- inbox_id: import_zod.z.string().describe("The ID of the inbox to get")
62
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get")
61
63
  });
62
64
  var CreateInboxParams = import_zod.z.object({
63
65
  username: import_zod.z.string().optional().describe("The username of the inbox to create"),
64
66
  domain: import_zod.z.string().optional().describe("The domain of the inbox to create"),
65
- display_name: import_zod.z.string().optional().describe("The display name of the inbox to create")
67
+ displayName: import_zod.z.string().optional().describe("The display name of the inbox to create")
66
68
  });
67
69
  var ListThreadsParams = ListItemsParams.extend({
68
- inbox_id: import_zod.z.string().describe("The ID of the inbox to list threads for"),
70
+ inboxId: import_zod.z.string().describe("The ID of the inbox to list threads for"),
69
71
  labels: import_zod.z.array(import_zod.z.string()).optional().describe("The labels to filter threads by")
70
72
  });
71
73
  var GetThreadParams = import_zod.z.object({
72
- inbox_id: import_zod.z.string().describe("The ID of the inbox to get the thread for"),
73
- thread_id: import_zod.z.string().describe("The ID of the thread to get")
74
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get the thread for"),
75
+ threadId: import_zod.z.string().describe("The ID of the thread to get")
74
76
  });
75
77
  var ListMessagesParams = ListItemsParams.extend({
76
- inbox_id: import_zod.z.string().describe("The ID of the inbox to list messages for"),
78
+ inboxId: import_zod.z.string().describe("The ID of the inbox to list messages for"),
77
79
  labels: import_zod.z.array(import_zod.z.string()).optional().describe("The labels to filter messages by")
78
80
  });
79
81
  var GetMessageParams = import_zod.z.object({
80
- inbox_id: import_zod.z.string().describe("The ID of the inbox to get the message for"),
81
- message_id: import_zod.z.string().describe("The ID of the message to get")
82
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get the message for"),
83
+ messageId: import_zod.z.string().describe("The ID of the message to get")
82
84
  });
83
85
  var GetAttachmentParams = import_zod.z.object({
84
- inbox_id: import_zod.z.string().describe("The ID of the inbox to get the attachment for"),
85
- message_id: import_zod.z.string().describe("The ID of the message to get the attachment for"),
86
- attachment_id: import_zod.z.string().describe("The ID of the attachment to get")
86
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get the attachment for"),
87
+ messageId: import_zod.z.string().describe("The ID of the message to get the attachment for"),
88
+ attachmentId: import_zod.z.string().describe("The ID of the attachment to get")
87
89
  });
88
90
  var SendMessageParams = import_zod.z.object({
89
- inbox_id: import_zod.z.string().describe("The ID of the inbox to send the message from"),
91
+ inboxId: import_zod.z.string().describe("The ID of the inbox to send the message from"),
90
92
  to: import_zod.z.array(import_zod.z.string()).describe("The list of recipients"),
91
93
  cc: import_zod.z.array(import_zod.z.string()).optional().describe("The list of CC recipients"),
92
94
  bcc: import_zod.z.array(import_zod.z.string()).optional().describe("The list of BCC recipients"),
@@ -95,8 +97,8 @@ var SendMessageParams = import_zod.z.object({
95
97
  html: import_zod.z.string().optional().describe("The HTML body of the message")
96
98
  });
97
99
  var ReplyToMessageParams = import_zod.z.object({
98
- inbox_id: import_zod.z.string().describe("The inbox ID of the inbox to reply to the message from"),
99
- message_id: import_zod.z.string().describe("The message ID of the message you wish to reply to"),
100
+ inboxId: import_zod.z.string().describe("The inbox ID of the inbox to reply to the message from"),
101
+ messageId: import_zod.z.string().describe("The message ID of the message you wish to reply to"),
100
102
  text: import_zod.z.string().optional().describe("The plain text body of the reply"),
101
103
  html: import_zod.z.string().optional().describe("The HTML body of the reply")
102
104
  });
@@ -175,14 +177,10 @@ var AgentMailMcpServer = class extends import_mcp.McpServer {
175
177
  });
176
178
  this.wrapper = new Wrapper(client);
177
179
  for (const tool of tools) {
178
- this.tool(tool.name, tool.description, tool.schema.shape, async (args) => ({
179
- content: [
180
- {
181
- type: "text",
182
- text: await this.wrapper.callMethodAndStringify(tool.method, args)
183
- }
184
- ]
185
- }));
180
+ this.tool(tool.name, tool.description, tool.schema.shape, async (args) => {
181
+ const { isError, result } = await this.wrapper.safeCall(tool.method, args);
182
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], isError };
183
+ });
186
184
  }
187
185
  }
188
186
  };