agentmail-toolkit 0.1.17 → 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.
Files changed (41) hide show
  1. package/dist/ai-sdk.d.mts +2 -1
  2. package/dist/ai-sdk.d.ts +2 -1
  3. package/dist/ai-sdk.js +24 -22
  4. package/dist/ai-sdk.js.map +1 -1
  5. package/dist/ai-sdk.mjs +4 -3
  6. package/dist/ai-sdk.mjs.map +1 -1
  7. package/dist/chunk-3TR24M4E.mjs +29 -0
  8. package/dist/chunk-3TR24M4E.mjs.map +1 -0
  9. package/dist/chunk-DNXRYZOH.mjs +129 -0
  10. package/dist/chunk-DNXRYZOH.mjs.map +1 -0
  11. package/dist/chunk-H3V5ORVZ.mjs +40 -0
  12. package/dist/chunk-H3V5ORVZ.mjs.map +1 -0
  13. package/dist/chunk-QBOE34GE.mjs +129 -0
  14. package/dist/chunk-QBOE34GE.mjs.map +1 -0
  15. package/dist/chunk-WEXYSRNX.mjs +40 -0
  16. package/dist/chunk-WEXYSRNX.mjs.map +1 -0
  17. package/dist/chunk-XAJA2AYA.mjs +31 -0
  18. package/dist/chunk-XAJA2AYA.mjs.map +1 -0
  19. package/dist/index.d.mts +143 -0
  20. package/dist/index.d.ts +143 -0
  21. package/dist/index.js +165 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/index.mjs +27 -0
  24. package/dist/index.mjs.map +1 -0
  25. package/dist/langchain.d.mts +2 -1
  26. package/dist/langchain.d.ts +2 -1
  27. package/dist/langchain.js +24 -22
  28. package/dist/langchain.js.map +1 -1
  29. package/dist/langchain.mjs +4 -3
  30. package/dist/langchain.mjs.map +1 -1
  31. package/dist/mcp.js +27 -29
  32. package/dist/mcp.js.map +1 -1
  33. package/dist/mcp.mjs +8 -10
  34. package/dist/mcp.mjs.map +1 -1
  35. package/dist/toolkit-BMavPn6k.d.mts +27 -0
  36. package/dist/toolkit-Cbpp0Kix.d.ts +27 -0
  37. package/dist/toolkit-Dc7siZcx.d.ts +24 -0
  38. package/dist/toolkit-DtDXApKD.d.mts +24 -0
  39. package/dist/tools-DFoMkoW0.d.mts +11 -0
  40. package/dist/tools-DFoMkoW0.d.ts +11 -0
  41. package/package.json +6 -1
@@ -0,0 +1,31 @@
1
+ // src/wrapper.ts
2
+ import { AgentMailClient } from "agentmail";
3
+ var Wrapper = class {
4
+ constructor(client) {
5
+ this.client = client;
6
+ if (!this.client) this.client = new AgentMailClient();
7
+ }
8
+ async call(method, args) {
9
+ const parts = method.split(".");
10
+ const methodKey = parts.pop();
11
+ if (!methodKey) throw new Error("Method name empty");
12
+ let parent = this.client;
13
+ for (const part of parts) parent = parent[part];
14
+ const { inboxId, ...options } = args;
15
+ if (inboxId) return await parent[methodKey].call(parent, inboxId, options);
16
+ else return await parent[methodKey].call(parent, options);
17
+ }
18
+ async safeCall(method, args) {
19
+ try {
20
+ return { isError: false, result: await this.call(method, args) };
21
+ } catch (error) {
22
+ if (error instanceof Error) return { isError: true, result: error.message };
23
+ else return { isError: true, result: "Unknown error" };
24
+ }
25
+ }
26
+ };
27
+
28
+ export {
29
+ Wrapper
30
+ };
31
+ //# sourceMappingURL=chunk-XAJA2AYA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/wrapper.ts"],"sourcesContent":["import { AgentMailClient } from 'agentmail'\n\nexport class Wrapper {\n constructor(private readonly client?: AgentMailClient) {\n if (!this.client) this.client = new AgentMailClient()\n }\n\n public async 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"],"mappings":";AAAA,SAAS,uBAAuB;AAEzB,IAAM,UAAN,MAAc;AAAA,EACjB,YAA6B,QAA0B;AAA1B;AACzB,QAAI,CAAC,KAAK,OAAQ,MAAK,SAAS,IAAI,gBAAgB;AAAA,EACxD;AAAA,EAEA,MAAa,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;AAAA,IACnE,SAAS,OAAO;AACZ,UAAI,iBAAiB,MAAO,QAAO,EAAE,SAAS,MAAM,QAAQ,MAAM,QAAQ;AAAA,UACrE,QAAO,EAAE,SAAS,MAAM,QAAQ,gBAAgB;AAAA,IACzD;AAAA,EACJ;AACJ;","names":[]}
@@ -0,0 +1,143 @@
1
+ import { z } from 'zod';
2
+ export { T as Tool, t as tools } from './tools-DFoMkoW0.mjs';
3
+
4
+ declare const ListItemsParams: z.ZodObject<{
5
+ limit: z.ZodOptional<z.ZodNumber>;
6
+ lastKey: z.ZodOptional<z.ZodString>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ limit?: number | undefined;
9
+ lastKey?: string | undefined;
10
+ }, {
11
+ limit?: number | undefined;
12
+ lastKey?: string | undefined;
13
+ }>;
14
+ declare const GetInboxParams: z.ZodObject<{
15
+ inboxId: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ inboxId: string;
18
+ }, {
19
+ inboxId: string;
20
+ }>;
21
+ declare const CreateInboxParams: z.ZodObject<{
22
+ username: z.ZodOptional<z.ZodString>;
23
+ domain: z.ZodOptional<z.ZodString>;
24
+ displayName: z.ZodOptional<z.ZodString>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ username?: string | undefined;
27
+ domain?: string | undefined;
28
+ displayName?: string | undefined;
29
+ }, {
30
+ username?: string | undefined;
31
+ domain?: string | undefined;
32
+ displayName?: string | undefined;
33
+ }>;
34
+ declare const ListThreadsParams: z.ZodObject<z.objectUtil.extendShape<{
35
+ limit: z.ZodOptional<z.ZodNumber>;
36
+ lastKey: z.ZodOptional<z.ZodString>;
37
+ }, {
38
+ inboxId: z.ZodString;
39
+ labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
40
+ }>, "strip", z.ZodTypeAny, {
41
+ inboxId: string;
42
+ limit?: number | undefined;
43
+ lastKey?: string | undefined;
44
+ labels?: string[] | undefined;
45
+ }, {
46
+ inboxId: string;
47
+ limit?: number | undefined;
48
+ lastKey?: string | undefined;
49
+ labels?: string[] | undefined;
50
+ }>;
51
+ declare const GetThreadParams: z.ZodObject<{
52
+ inboxId: z.ZodString;
53
+ threadId: z.ZodString;
54
+ }, "strip", z.ZodTypeAny, {
55
+ inboxId: string;
56
+ threadId: string;
57
+ }, {
58
+ inboxId: string;
59
+ threadId: string;
60
+ }>;
61
+ declare const ListMessagesParams: z.ZodObject<z.objectUtil.extendShape<{
62
+ limit: z.ZodOptional<z.ZodNumber>;
63
+ lastKey: z.ZodOptional<z.ZodString>;
64
+ }, {
65
+ inboxId: z.ZodString;
66
+ labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
67
+ }>, "strip", z.ZodTypeAny, {
68
+ inboxId: string;
69
+ limit?: number | undefined;
70
+ lastKey?: string | undefined;
71
+ labels?: string[] | undefined;
72
+ }, {
73
+ inboxId: string;
74
+ limit?: number | undefined;
75
+ lastKey?: string | undefined;
76
+ labels?: string[] | undefined;
77
+ }>;
78
+ declare const GetMessageParams: z.ZodObject<{
79
+ inboxId: z.ZodString;
80
+ messageId: z.ZodString;
81
+ }, "strip", z.ZodTypeAny, {
82
+ inboxId: string;
83
+ messageId: string;
84
+ }, {
85
+ inboxId: string;
86
+ messageId: string;
87
+ }>;
88
+ declare const GetAttachmentParams: z.ZodObject<{
89
+ inboxId: z.ZodString;
90
+ messageId: z.ZodString;
91
+ attachmentId: z.ZodString;
92
+ }, "strip", z.ZodTypeAny, {
93
+ inboxId: string;
94
+ messageId: string;
95
+ attachmentId: string;
96
+ }, {
97
+ inboxId: string;
98
+ messageId: string;
99
+ attachmentId: string;
100
+ }>;
101
+ declare const SendMessageParams: z.ZodObject<{
102
+ inboxId: z.ZodString;
103
+ to: z.ZodArray<z.ZodString, "many">;
104
+ cc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
105
+ bcc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
106
+ subject: z.ZodOptional<z.ZodString>;
107
+ text: z.ZodOptional<z.ZodString>;
108
+ html: z.ZodOptional<z.ZodString>;
109
+ }, "strip", z.ZodTypeAny, {
110
+ inboxId: string;
111
+ to: string[];
112
+ cc?: string[] | undefined;
113
+ bcc?: string[] | undefined;
114
+ subject?: string | undefined;
115
+ text?: string | undefined;
116
+ html?: string | undefined;
117
+ }, {
118
+ inboxId: string;
119
+ to: string[];
120
+ cc?: string[] | undefined;
121
+ bcc?: string[] | undefined;
122
+ subject?: string | undefined;
123
+ text?: string | undefined;
124
+ html?: string | undefined;
125
+ }>;
126
+ declare const ReplyToMessageParams: z.ZodObject<{
127
+ inboxId: z.ZodString;
128
+ messageId: z.ZodString;
129
+ text: z.ZodOptional<z.ZodString>;
130
+ html: z.ZodOptional<z.ZodString>;
131
+ }, "strip", z.ZodTypeAny, {
132
+ inboxId: string;
133
+ messageId: string;
134
+ text?: string | undefined;
135
+ html?: string | undefined;
136
+ }, {
137
+ inboxId: string;
138
+ messageId: string;
139
+ text?: string | undefined;
140
+ html?: string | undefined;
141
+ }>;
142
+
143
+ export { CreateInboxParams, GetAttachmentParams, GetInboxParams, GetMessageParams, GetThreadParams, ListItemsParams, ListMessagesParams, ListThreadsParams, ReplyToMessageParams, SendMessageParams };
@@ -0,0 +1,143 @@
1
+ import { z } from 'zod';
2
+ export { T as Tool, t as tools } from './tools-DFoMkoW0.js';
3
+
4
+ declare const ListItemsParams: z.ZodObject<{
5
+ limit: z.ZodOptional<z.ZodNumber>;
6
+ lastKey: z.ZodOptional<z.ZodString>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ limit?: number | undefined;
9
+ lastKey?: string | undefined;
10
+ }, {
11
+ limit?: number | undefined;
12
+ lastKey?: string | undefined;
13
+ }>;
14
+ declare const GetInboxParams: z.ZodObject<{
15
+ inboxId: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ inboxId: string;
18
+ }, {
19
+ inboxId: string;
20
+ }>;
21
+ declare const CreateInboxParams: z.ZodObject<{
22
+ username: z.ZodOptional<z.ZodString>;
23
+ domain: z.ZodOptional<z.ZodString>;
24
+ displayName: z.ZodOptional<z.ZodString>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ username?: string | undefined;
27
+ domain?: string | undefined;
28
+ displayName?: string | undefined;
29
+ }, {
30
+ username?: string | undefined;
31
+ domain?: string | undefined;
32
+ displayName?: string | undefined;
33
+ }>;
34
+ declare const ListThreadsParams: z.ZodObject<z.objectUtil.extendShape<{
35
+ limit: z.ZodOptional<z.ZodNumber>;
36
+ lastKey: z.ZodOptional<z.ZodString>;
37
+ }, {
38
+ inboxId: z.ZodString;
39
+ labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
40
+ }>, "strip", z.ZodTypeAny, {
41
+ inboxId: string;
42
+ limit?: number | undefined;
43
+ lastKey?: string | undefined;
44
+ labels?: string[] | undefined;
45
+ }, {
46
+ inboxId: string;
47
+ limit?: number | undefined;
48
+ lastKey?: string | undefined;
49
+ labels?: string[] | undefined;
50
+ }>;
51
+ declare const GetThreadParams: z.ZodObject<{
52
+ inboxId: z.ZodString;
53
+ threadId: z.ZodString;
54
+ }, "strip", z.ZodTypeAny, {
55
+ inboxId: string;
56
+ threadId: string;
57
+ }, {
58
+ inboxId: string;
59
+ threadId: string;
60
+ }>;
61
+ declare const ListMessagesParams: z.ZodObject<z.objectUtil.extendShape<{
62
+ limit: z.ZodOptional<z.ZodNumber>;
63
+ lastKey: z.ZodOptional<z.ZodString>;
64
+ }, {
65
+ inboxId: z.ZodString;
66
+ labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
67
+ }>, "strip", z.ZodTypeAny, {
68
+ inboxId: string;
69
+ limit?: number | undefined;
70
+ lastKey?: string | undefined;
71
+ labels?: string[] | undefined;
72
+ }, {
73
+ inboxId: string;
74
+ limit?: number | undefined;
75
+ lastKey?: string | undefined;
76
+ labels?: string[] | undefined;
77
+ }>;
78
+ declare const GetMessageParams: z.ZodObject<{
79
+ inboxId: z.ZodString;
80
+ messageId: z.ZodString;
81
+ }, "strip", z.ZodTypeAny, {
82
+ inboxId: string;
83
+ messageId: string;
84
+ }, {
85
+ inboxId: string;
86
+ messageId: string;
87
+ }>;
88
+ declare const GetAttachmentParams: z.ZodObject<{
89
+ inboxId: z.ZodString;
90
+ messageId: z.ZodString;
91
+ attachmentId: z.ZodString;
92
+ }, "strip", z.ZodTypeAny, {
93
+ inboxId: string;
94
+ messageId: string;
95
+ attachmentId: string;
96
+ }, {
97
+ inboxId: string;
98
+ messageId: string;
99
+ attachmentId: string;
100
+ }>;
101
+ declare const SendMessageParams: z.ZodObject<{
102
+ inboxId: z.ZodString;
103
+ to: z.ZodArray<z.ZodString, "many">;
104
+ cc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
105
+ bcc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
106
+ subject: z.ZodOptional<z.ZodString>;
107
+ text: z.ZodOptional<z.ZodString>;
108
+ html: z.ZodOptional<z.ZodString>;
109
+ }, "strip", z.ZodTypeAny, {
110
+ inboxId: string;
111
+ to: string[];
112
+ cc?: string[] | undefined;
113
+ bcc?: string[] | undefined;
114
+ subject?: string | undefined;
115
+ text?: string | undefined;
116
+ html?: string | undefined;
117
+ }, {
118
+ inboxId: string;
119
+ to: string[];
120
+ cc?: string[] | undefined;
121
+ bcc?: string[] | undefined;
122
+ subject?: string | undefined;
123
+ text?: string | undefined;
124
+ html?: string | undefined;
125
+ }>;
126
+ declare const ReplyToMessageParams: z.ZodObject<{
127
+ inboxId: z.ZodString;
128
+ messageId: z.ZodString;
129
+ text: z.ZodOptional<z.ZodString>;
130
+ html: z.ZodOptional<z.ZodString>;
131
+ }, "strip", z.ZodTypeAny, {
132
+ inboxId: string;
133
+ messageId: string;
134
+ text?: string | undefined;
135
+ html?: string | undefined;
136
+ }, {
137
+ inboxId: string;
138
+ messageId: string;
139
+ text?: string | undefined;
140
+ html?: string | undefined;
141
+ }>;
142
+
143
+ export { CreateInboxParams, GetAttachmentParams, GetInboxParams, GetMessageParams, GetThreadParams, ListItemsParams, ListMessagesParams, ListThreadsParams, ReplyToMessageParams, SendMessageParams };
package/dist/index.js ADDED
@@ -0,0 +1,165 @@
1
+ "use strict";
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
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ CreateInboxParams: () => CreateInboxParams,
24
+ GetAttachmentParams: () => GetAttachmentParams,
25
+ GetInboxParams: () => GetInboxParams,
26
+ GetMessageParams: () => GetMessageParams,
27
+ GetThreadParams: () => GetThreadParams,
28
+ ListItemsParams: () => ListItemsParams,
29
+ ListMessagesParams: () => ListMessagesParams,
30
+ ListThreadsParams: () => ListThreadsParams,
31
+ ReplyToMessageParams: () => ReplyToMessageParams,
32
+ SendMessageParams: () => SendMessageParams,
33
+ tools: () => tools
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/schemas.ts
38
+ var import_zod = require("zod");
39
+ var ListItemsParams = import_zod.z.object({
40
+ limit: import_zod.z.number().optional().describe("The maximum number of items to return"),
41
+ lastKey: import_zod.z.string().optional().describe("The last key to use for pagination")
42
+ });
43
+ var GetInboxParams = import_zod.z.object({
44
+ inboxId: import_zod.z.string().describe("The ID of the inbox to get")
45
+ });
46
+ var CreateInboxParams = import_zod.z.object({
47
+ username: import_zod.z.string().optional().describe("The username of the inbox to create"),
48
+ domain: import_zod.z.string().optional().describe("The domain of the inbox to create"),
49
+ displayName: import_zod.z.string().optional().describe("The display name of the inbox to create")
50
+ });
51
+ var ListThreadsParams = ListItemsParams.extend({
52
+ inboxId: import_zod.z.string().describe("The ID of the inbox to list threads for"),
53
+ labels: import_zod.z.array(import_zod.z.string()).optional().describe("The labels to filter threads by")
54
+ });
55
+ var GetThreadParams = import_zod.z.object({
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
+ });
59
+ var ListMessagesParams = ListItemsParams.extend({
60
+ inboxId: import_zod.z.string().describe("The ID of the inbox to list messages for"),
61
+ labels: import_zod.z.array(import_zod.z.string()).optional().describe("The labels to filter messages by")
62
+ });
63
+ var GetMessageParams = import_zod.z.object({
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
+ });
67
+ var GetAttachmentParams = import_zod.z.object({
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
+ });
72
+ var SendMessageParams = import_zod.z.object({
73
+ inboxId: import_zod.z.string().describe("The ID of the inbox to send the message from"),
74
+ to: import_zod.z.array(import_zod.z.string()).describe("The list of recipients"),
75
+ cc: import_zod.z.array(import_zod.z.string()).optional().describe("The list of CC recipients"),
76
+ bcc: import_zod.z.array(import_zod.z.string()).optional().describe("The list of BCC recipients"),
77
+ subject: import_zod.z.string().optional().describe("The subject of the message"),
78
+ text: import_zod.z.string().optional().describe("The plain text body of the message"),
79
+ html: import_zod.z.string().optional().describe("The HTML body of the message")
80
+ });
81
+ var ReplyToMessageParams = import_zod.z.object({
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
+ text: import_zod.z.string().optional().describe("The plain text body of the reply"),
85
+ html: import_zod.z.string().optional().describe("The HTML body of the reply")
86
+ });
87
+
88
+ // src/tools.ts
89
+ var tools = [
90
+ {
91
+ name: "list_inboxes",
92
+ method: "inboxes.list",
93
+ description: "List all inboxes",
94
+ schema: ListItemsParams
95
+ },
96
+ {
97
+ name: "get_inbox",
98
+ method: "inboxes.get",
99
+ description: "Get an inbox by ID",
100
+ schema: GetInboxParams
101
+ },
102
+ {
103
+ name: "create_inbox",
104
+ method: "inboxes.create",
105
+ description: "Create a new inbox",
106
+ schema: CreateInboxParams
107
+ },
108
+ {
109
+ name: "list_threads",
110
+ method: "threads.list",
111
+ description: "List all threads",
112
+ schema: ListThreadsParams
113
+ },
114
+ {
115
+ name: "get_thread",
116
+ method: "threads.get",
117
+ description: "Get a thread by ID",
118
+ schema: GetThreadParams
119
+ },
120
+ {
121
+ name: "list_messages",
122
+ method: "messages.list",
123
+ description: "List all messages",
124
+ schema: ListMessagesParams
125
+ },
126
+ {
127
+ name: "get_message",
128
+ method: "messages.get",
129
+ description: "Get a message by ID",
130
+ schema: GetMessageParams
131
+ },
132
+ {
133
+ name: "get_attachment",
134
+ method: "attachments.get",
135
+ description: "Get an attachment by ID",
136
+ schema: GetAttachmentParams
137
+ },
138
+ {
139
+ name: "send_message",
140
+ method: "messages.send",
141
+ description: "Send a message",
142
+ schema: SendMessageParams
143
+ },
144
+ {
145
+ name: "reply_to_message",
146
+ method: "messages.reply",
147
+ description: "Reply to a message",
148
+ schema: ReplyToMessageParams
149
+ }
150
+ ];
151
+ // Annotate the CommonJS export names for ESM import in node:
152
+ 0 && (module.exports = {
153
+ CreateInboxParams,
154
+ GetAttachmentParams,
155
+ GetInboxParams,
156
+ GetMessageParams,
157
+ GetThreadParams,
158
+ ListItemsParams,
159
+ ListMessagesParams,
160
+ ListThreadsParams,
161
+ ReplyToMessageParams,
162
+ SendMessageParams,
163
+ tools
164
+ });
165
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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 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,OAAO;AA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AAAA,IACI,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,QAAQ;AAAA,EACZ;AACJ;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,27 @@
1
+ import {
2
+ CreateInboxParams,
3
+ GetAttachmentParams,
4
+ GetInboxParams,
5
+ GetMessageParams,
6
+ GetThreadParams,
7
+ ListItemsParams,
8
+ ListMessagesParams,
9
+ ListThreadsParams,
10
+ ReplyToMessageParams,
11
+ SendMessageParams,
12
+ tools
13
+ } from "./chunk-DNXRYZOH.mjs";
14
+ export {
15
+ CreateInboxParams,
16
+ GetAttachmentParams,
17
+ GetInboxParams,
18
+ GetMessageParams,
19
+ GetThreadParams,
20
+ ListItemsParams,
21
+ ListMessagesParams,
22
+ ListThreadsParams,
23
+ ReplyToMessageParams,
24
+ SendMessageParams,
25
+ tools
26
+ };
27
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +1,7 @@
1
1
  import { StructuredTool } from '@langchain/core/tools';
2
2
  import { AgentMailClient } from 'agentmail';
3
- import { L as ListToolkit, T as Tool } from './toolkit-oWNeOd1D.mjs';
3
+ import { L as ListToolkit } from './toolkit-BMavPn6k.mjs';
4
+ import { T as Tool } from './tools-DFoMkoW0.mjs';
4
5
  import 'zod';
5
6
 
6
7
  declare class AgentMailToolkit extends ListToolkit<StructuredTool> {
@@ -1,6 +1,7 @@
1
1
  import { StructuredTool } from '@langchain/core/tools';
2
2
  import { AgentMailClient } from 'agentmail';
3
- import { L as ListToolkit, T as Tool } from './toolkit-oWNeOd1D.js';
3
+ import { L as ListToolkit } from './toolkit-Cbpp0Kix.js';
4
+ import { T as Tool } from './tools-DFoMkoW0.js';
4
5
  import 'zod';
5
6
 
6
7
  declare class AgentMailToolkit extends ListToolkit<StructuredTool> {
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