langchain 0.0.200 → 0.0.201

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 (55) hide show
  1. package/agents/toolkits/connery.cjs +1 -0
  2. package/agents/toolkits/connery.d.ts +1 -0
  3. package/agents/toolkits/connery.js +1 -0
  4. package/dist/agents/toolkits/connery/index.cjs +39 -0
  5. package/dist/agents/toolkits/connery/index.d.ts +23 -0
  6. package/dist/agents/toolkits/connery/index.js +35 -0
  7. package/dist/document_loaders/fs/obsidian.cjs +240 -0
  8. package/dist/document_loaders/fs/obsidian.d.ts +26 -0
  9. package/dist/document_loaders/fs/obsidian.js +233 -0
  10. package/dist/embeddings/gradient_ai.cjs +1 -0
  11. package/dist/embeddings/gradient_ai.js +1 -0
  12. package/dist/load/import_constants.cjs +2 -0
  13. package/dist/load/import_constants.js +2 -0
  14. package/dist/load/import_map.cjs +5 -3
  15. package/dist/load/import_map.d.ts +2 -0
  16. package/dist/load/import_map.js +2 -0
  17. package/dist/tools/connery.cjs +279 -0
  18. package/dist/tools/connery.d.ts +145 -0
  19. package/dist/tools/connery.js +274 -0
  20. package/dist/tools/gmail/base.cjs +69 -0
  21. package/dist/tools/gmail/base.d.ts +19 -0
  22. package/dist/tools/gmail/base.js +65 -0
  23. package/dist/tools/gmail/create_draft.cjs +62 -0
  24. package/dist/tools/gmail/create_draft.d.ts +35 -0
  25. package/dist/tools/gmail/create_draft.js +58 -0
  26. package/dist/tools/gmail/descriptions.cjs +118 -0
  27. package/dist/tools/gmail/descriptions.d.ts +5 -0
  28. package/dist/tools/gmail/descriptions.js +115 -0
  29. package/dist/tools/gmail/get_message.cjs +83 -0
  30. package/dist/tools/gmail/get_message.d.ts +18 -0
  31. package/dist/tools/gmail/get_message.js +79 -0
  32. package/dist/tools/gmail/get_thread.cjs +89 -0
  33. package/dist/tools/gmail/get_thread.d.ts +18 -0
  34. package/dist/tools/gmail/get_thread.js +85 -0
  35. package/dist/tools/gmail/index.cjs +13 -0
  36. package/dist/tools/gmail/index.d.ts +11 -0
  37. package/dist/tools/gmail/index.js +5 -0
  38. package/dist/tools/gmail/search.cjs +118 -0
  39. package/dist/tools/gmail/search.d.ts +29 -0
  40. package/dist/tools/gmail/search.js +114 -0
  41. package/dist/tools/gmail/send_message.cjs +74 -0
  42. package/dist/tools/gmail/send_message.d.ts +35 -0
  43. package/dist/tools/gmail/send_message.js +70 -0
  44. package/dist/tools/wolframalpha.cjs +1 -1
  45. package/dist/tools/wolframalpha.js +1 -1
  46. package/document_loaders/fs/obsidian.cjs +1 -0
  47. package/document_loaders/fs/obsidian.d.ts +1 -0
  48. package/document_loaders/fs/obsidian.js +1 -0
  49. package/package.json +35 -3
  50. package/tools/connery.cjs +1 -0
  51. package/tools/connery.d.ts +1 -0
  52. package/tools/connery.js +1 -0
  53. package/tools/gmail.cjs +1 -0
  54. package/tools/gmail.d.ts +1 -0
  55. package/tools/gmail.js +1 -0
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SEARCH_DESCRIPTION = exports.SEND_MESSAGE_DESCRIPTION = exports.GET_THREAD_DESCRIPTION = exports.GET_MESSAGE_DESCRIPTION = exports.CREATE_DRAFT_DESCRIPTION = void 0;
4
+ exports.CREATE_DRAFT_DESCRIPTION = `A tool for creating draft emails in Gmail.
5
+
6
+ INPUT example:
7
+ {
8
+ "message": "Hello, this is a test draft",
9
+ "to": ["example1@email.com", "example2@email.com"],
10
+ "subject": "Test Draft",
11
+ "cc": ["cc1@email.com"],
12
+ "bcc": ["bcc1@email.com"]
13
+ }
14
+
15
+ OUTPUT:
16
+ The output is a confirmation message with the draft ID.
17
+ `;
18
+ exports.GET_MESSAGE_DESCRIPTION = `A tool for retrieving a specific email message from Gmail using its message ID.
19
+
20
+ INPUT example:
21
+ {
22
+ "messageId": "unique_message_id_string"
23
+ }
24
+
25
+ OUTPUT:
26
+ The output includes detailed information about the retrieved email message. This includes the subject, body, sender (from), recipients (to), date of the email, and the message ID. If any of these details are not available in the email, the tool will throw an error indicating the missing information.
27
+
28
+ Example Output:
29
+ "Result for the prompt unique_message_id_string
30
+ {
31
+ 'subject': 'Email Subject',
32
+ 'body': 'Email Body Content',
33
+ 'from': 'sender@email.com',
34
+ 'to': 'recipient@email.com',
35
+ 'date': 'Email Date',
36
+ 'messageId': 'unique_message_id_string'
37
+ }"
38
+ `;
39
+ exports.GET_THREAD_DESCRIPTION = `A tool for retrieving an entire email thread from Gmail using the thread ID.
40
+
41
+ INPUT example:
42
+ {
43
+ "threadId": "unique_thread_id_string"
44
+ }
45
+
46
+ OUTPUT:
47
+ The output includes an array of all the messages in the specified thread. Each message in the array contains detailed information including the subject, body, sender (from), recipients (to), date of the email, and the message ID. If any of these details are not available in a message, the tool will throw an error indicating the missing information.
48
+
49
+ Example Output:
50
+ "Result for the prompt unique_thread_id_string
51
+ [
52
+ {
53
+ 'subject': 'Email Subject',
54
+ 'body': 'Email Body Content',
55
+ 'from': 'sender@email.com',
56
+ 'to': 'recipient@email.com',
57
+ 'date': 'Email Date',
58
+ 'messageId': 'unique_message_id_string'
59
+ },
60
+ ... (other messages in the thread)
61
+ ]"
62
+ `;
63
+ exports.SEND_MESSAGE_DESCRIPTION = `A tool for sending an email message using Gmail. It allows users to specify recipients, subject, and the content of the message, along with optional cc and bcc fields.
64
+
65
+ INPUT example:
66
+ {
67
+ "message": "Hello, this is a test email",
68
+ "to": ["recipient1@email.com", "recipient2@email.com"],
69
+ "subject": "Test Email",
70
+ "cc": ["cc1@email.com"],
71
+ "bcc": ["bcc1@email.com"]
72
+ }
73
+
74
+ OUTPUT:
75
+ The output is a confirmation message with the ID of the sent email. If there is an error during the sending process, the tool will throw an error with a description of the problem.
76
+
77
+ Example Output:
78
+ "Message sent. Message Id: unique_message_id_string"
79
+ `;
80
+ exports.SEARCH_DESCRIPTION = `A tool for searching email messages or threads in Gmail using a specific query. It offers the flexibility to choose between messages and threads as the search resource.
81
+
82
+ INPUT example:
83
+ {
84
+ "query": "specific search query",
85
+ "maxResults": 10, // Optional: number of results to return
86
+ "resource": "messages" // Optional: can be "messages" or "threads"
87
+ }
88
+
89
+ OUTPUT:
90
+ The output is a JSON list of either email messages or threads, depending on the specified resource, that matches the search query. For 'messages', the output includes details like the message ID, thread ID, snippet, body, subject, and sender of each message. For 'threads', it includes the thread ID, snippet, body, subject, and sender of the first message in each thread. If no data is returned, or if the specified resource is invalid, the tool throws an error with a relevant message.
91
+
92
+ Example Output for 'messages':
93
+ "Result for the query 'specific search query':
94
+ [
95
+ {
96
+ 'id': 'message_id',
97
+ 'threadId': 'thread_id',
98
+ 'snippet': 'message snippet',
99
+ 'body': 'message body',
100
+ 'subject': 'message subject',
101
+ 'sender': 'sender's email'
102
+ },
103
+ ... (other messages matching the query)
104
+ ]"
105
+
106
+ Example Output for 'threads':
107
+ "Result for the query 'specific search query':
108
+ [
109
+ {
110
+ 'id': 'thread_id',
111
+ 'snippet': 'thread snippet',
112
+ 'body': 'first message body',
113
+ 'subject': 'first message subject',
114
+ 'sender': 'first message sender'
115
+ },
116
+ ... (other threads matching the query)
117
+ ]"
118
+ `;
@@ -0,0 +1,5 @@
1
+ export declare const CREATE_DRAFT_DESCRIPTION = "A tool for creating draft emails in Gmail.\n\nINPUT example:\n{\n \"message\": \"Hello, this is a test draft\",\n \"to\": [\"example1@email.com\", \"example2@email.com\"],\n \"subject\": \"Test Draft\",\n \"cc\": [\"cc1@email.com\"],\n \"bcc\": [\"bcc1@email.com\"]\n}\n\nOUTPUT:\nThe output is a confirmation message with the draft ID.\n";
2
+ export declare const GET_MESSAGE_DESCRIPTION = "A tool for retrieving a specific email message from Gmail using its message ID.\n\nINPUT example:\n{\n \"messageId\": \"unique_message_id_string\"\n}\n\nOUTPUT:\nThe output includes detailed information about the retrieved email message. This includes the subject, body, sender (from), recipients (to), date of the email, and the message ID. If any of these details are not available in the email, the tool will throw an error indicating the missing information.\n\nExample Output:\n\"Result for the prompt unique_message_id_string\n{\n 'subject': 'Email Subject',\n 'body': 'Email Body Content',\n 'from': 'sender@email.com',\n 'to': 'recipient@email.com',\n 'date': 'Email Date',\n 'messageId': 'unique_message_id_string'\n}\"\n";
3
+ export declare const GET_THREAD_DESCRIPTION = "A tool for retrieving an entire email thread from Gmail using the thread ID.\n\nINPUT example:\n{\n \"threadId\": \"unique_thread_id_string\"\n}\n\nOUTPUT:\nThe output includes an array of all the messages in the specified thread. Each message in the array contains detailed information including the subject, body, sender (from), recipients (to), date of the email, and the message ID. If any of these details are not available in a message, the tool will throw an error indicating the missing information.\n\nExample Output:\n\"Result for the prompt unique_thread_id_string\n[\n {\n 'subject': 'Email Subject',\n 'body': 'Email Body Content',\n 'from': 'sender@email.com',\n 'to': 'recipient@email.com',\n 'date': 'Email Date',\n 'messageId': 'unique_message_id_string'\n },\n ... (other messages in the thread)\n]\"\n";
4
+ export declare const SEND_MESSAGE_DESCRIPTION = "A tool for sending an email message using Gmail. It allows users to specify recipients, subject, and the content of the message, along with optional cc and bcc fields.\n\nINPUT example:\n{\n \"message\": \"Hello, this is a test email\",\n \"to\": [\"recipient1@email.com\", \"recipient2@email.com\"],\n \"subject\": \"Test Email\",\n \"cc\": [\"cc1@email.com\"],\n \"bcc\": [\"bcc1@email.com\"]\n}\n\nOUTPUT:\nThe output is a confirmation message with the ID of the sent email. If there is an error during the sending process, the tool will throw an error with a description of the problem.\n\nExample Output:\n\"Message sent. Message Id: unique_message_id_string\"\n";
5
+ export declare const SEARCH_DESCRIPTION = "A tool for searching email messages or threads in Gmail using a specific query. It offers the flexibility to choose between messages and threads as the search resource.\n\nINPUT example:\n{\n \"query\": \"specific search query\",\n \"maxResults\": 10, // Optional: number of results to return\n \"resource\": \"messages\" // Optional: can be \"messages\" or \"threads\"\n}\n\nOUTPUT:\nThe output is a JSON list of either email messages or threads, depending on the specified resource, that matches the search query. For 'messages', the output includes details like the message ID, thread ID, snippet, body, subject, and sender of each message. For 'threads', it includes the thread ID, snippet, body, subject, and sender of the first message in each thread. If no data is returned, or if the specified resource is invalid, the tool throws an error with a relevant message.\n\nExample Output for 'messages':\n\"Result for the query 'specific search query':\n[\n {\n 'id': 'message_id',\n 'threadId': 'thread_id',\n 'snippet': 'message snippet',\n 'body': 'message body',\n 'subject': 'message subject',\n 'sender': 'sender's email'\n },\n ... (other messages matching the query)\n]\"\n\nExample Output for 'threads':\n\"Result for the query 'specific search query':\n[\n {\n 'id': 'thread_id',\n 'snippet': 'thread snippet',\n 'body': 'first message body',\n 'subject': 'first message subject',\n 'sender': 'first message sender'\n },\n ... (other threads matching the query)\n]\"\n";
@@ -0,0 +1,115 @@
1
+ export const CREATE_DRAFT_DESCRIPTION = `A tool for creating draft emails in Gmail.
2
+
3
+ INPUT example:
4
+ {
5
+ "message": "Hello, this is a test draft",
6
+ "to": ["example1@email.com", "example2@email.com"],
7
+ "subject": "Test Draft",
8
+ "cc": ["cc1@email.com"],
9
+ "bcc": ["bcc1@email.com"]
10
+ }
11
+
12
+ OUTPUT:
13
+ The output is a confirmation message with the draft ID.
14
+ `;
15
+ export const GET_MESSAGE_DESCRIPTION = `A tool for retrieving a specific email message from Gmail using its message ID.
16
+
17
+ INPUT example:
18
+ {
19
+ "messageId": "unique_message_id_string"
20
+ }
21
+
22
+ OUTPUT:
23
+ The output includes detailed information about the retrieved email message. This includes the subject, body, sender (from), recipients (to), date of the email, and the message ID. If any of these details are not available in the email, the tool will throw an error indicating the missing information.
24
+
25
+ Example Output:
26
+ "Result for the prompt unique_message_id_string
27
+ {
28
+ 'subject': 'Email Subject',
29
+ 'body': 'Email Body Content',
30
+ 'from': 'sender@email.com',
31
+ 'to': 'recipient@email.com',
32
+ 'date': 'Email Date',
33
+ 'messageId': 'unique_message_id_string'
34
+ }"
35
+ `;
36
+ export const GET_THREAD_DESCRIPTION = `A tool for retrieving an entire email thread from Gmail using the thread ID.
37
+
38
+ INPUT example:
39
+ {
40
+ "threadId": "unique_thread_id_string"
41
+ }
42
+
43
+ OUTPUT:
44
+ The output includes an array of all the messages in the specified thread. Each message in the array contains detailed information including the subject, body, sender (from), recipients (to), date of the email, and the message ID. If any of these details are not available in a message, the tool will throw an error indicating the missing information.
45
+
46
+ Example Output:
47
+ "Result for the prompt unique_thread_id_string
48
+ [
49
+ {
50
+ 'subject': 'Email Subject',
51
+ 'body': 'Email Body Content',
52
+ 'from': 'sender@email.com',
53
+ 'to': 'recipient@email.com',
54
+ 'date': 'Email Date',
55
+ 'messageId': 'unique_message_id_string'
56
+ },
57
+ ... (other messages in the thread)
58
+ ]"
59
+ `;
60
+ export const SEND_MESSAGE_DESCRIPTION = `A tool for sending an email message using Gmail. It allows users to specify recipients, subject, and the content of the message, along with optional cc and bcc fields.
61
+
62
+ INPUT example:
63
+ {
64
+ "message": "Hello, this is a test email",
65
+ "to": ["recipient1@email.com", "recipient2@email.com"],
66
+ "subject": "Test Email",
67
+ "cc": ["cc1@email.com"],
68
+ "bcc": ["bcc1@email.com"]
69
+ }
70
+
71
+ OUTPUT:
72
+ The output is a confirmation message with the ID of the sent email. If there is an error during the sending process, the tool will throw an error with a description of the problem.
73
+
74
+ Example Output:
75
+ "Message sent. Message Id: unique_message_id_string"
76
+ `;
77
+ export const SEARCH_DESCRIPTION = `A tool for searching email messages or threads in Gmail using a specific query. It offers the flexibility to choose between messages and threads as the search resource.
78
+
79
+ INPUT example:
80
+ {
81
+ "query": "specific search query",
82
+ "maxResults": 10, // Optional: number of results to return
83
+ "resource": "messages" // Optional: can be "messages" or "threads"
84
+ }
85
+
86
+ OUTPUT:
87
+ The output is a JSON list of either email messages or threads, depending on the specified resource, that matches the search query. For 'messages', the output includes details like the message ID, thread ID, snippet, body, subject, and sender of each message. For 'threads', it includes the thread ID, snippet, body, subject, and sender of the first message in each thread. If no data is returned, or if the specified resource is invalid, the tool throws an error with a relevant message.
88
+
89
+ Example Output for 'messages':
90
+ "Result for the query 'specific search query':
91
+ [
92
+ {
93
+ 'id': 'message_id',
94
+ 'threadId': 'thread_id',
95
+ 'snippet': 'message snippet',
96
+ 'body': 'message body',
97
+ 'subject': 'message subject',
98
+ 'sender': 'sender's email'
99
+ },
100
+ ... (other messages matching the query)
101
+ ]"
102
+
103
+ Example Output for 'threads':
104
+ "Result for the query 'specific search query':
105
+ [
106
+ {
107
+ 'id': 'thread_id',
108
+ 'snippet': 'thread snippet',
109
+ 'body': 'first message body',
110
+ 'subject': 'first message subject',
111
+ 'sender': 'first message sender'
112
+ },
113
+ ... (other threads matching the query)
114
+ ]"
115
+ `;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GmailGetMessage = void 0;
4
+ const zod_1 = require("zod");
5
+ const base_js_1 = require("./base.cjs");
6
+ const descriptions_js_1 = require("./descriptions.cjs");
7
+ class GmailGetMessage extends base_js_1.GmailBaseTool {
8
+ constructor(fields) {
9
+ super(fields);
10
+ Object.defineProperty(this, "name", {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value: "gmail_get_message"
15
+ });
16
+ Object.defineProperty(this, "schema", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: zod_1.z.object({
21
+ messageId: zod_1.z.string(),
22
+ })
23
+ });
24
+ Object.defineProperty(this, "description", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: descriptions_js_1.GET_MESSAGE_DESCRIPTION
29
+ });
30
+ }
31
+ async _call(arg) {
32
+ const { messageId } = arg;
33
+ const message = await this.gmail.users.messages.get({
34
+ userId: "me",
35
+ id: messageId,
36
+ });
37
+ const { data } = message;
38
+ if (!data) {
39
+ throw new Error("No data returned from Gmail");
40
+ }
41
+ const { payload } = data;
42
+ if (!payload) {
43
+ throw new Error("No payload returned from Gmail");
44
+ }
45
+ const { headers } = payload;
46
+ if (!headers) {
47
+ throw new Error("No headers returned from Gmail");
48
+ }
49
+ const subject = headers.find((header) => header.name === "Subject");
50
+ if (!subject) {
51
+ throw new Error("No subject returned from Gmail");
52
+ }
53
+ const body = headers.find((header) => header.name === "Body");
54
+ if (!body) {
55
+ throw new Error("No body returned from Gmail");
56
+ }
57
+ const from = headers.find((header) => header.name === "From");
58
+ if (!from) {
59
+ throw new Error("No from returned from Gmail");
60
+ }
61
+ const to = headers.find((header) => header.name === "To");
62
+ if (!to) {
63
+ throw new Error("No to returned from Gmail");
64
+ }
65
+ const date = headers.find((header) => header.name === "Date");
66
+ if (!date) {
67
+ throw new Error("No date returned from Gmail");
68
+ }
69
+ const messageIdHeader = headers.find((header) => header.name === "Message-ID");
70
+ if (!messageIdHeader) {
71
+ throw new Error("No message id returned from Gmail");
72
+ }
73
+ return `Result for the prompt ${messageId} \n${JSON.stringify({
74
+ subject: subject.value,
75
+ body: body.value,
76
+ from: from.value,
77
+ to: to.value,
78
+ date: date.value,
79
+ messageId: messageIdHeader.value,
80
+ })}`;
81
+ }
82
+ }
83
+ exports.GmailGetMessage = GmailGetMessage;
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ import { GmailBaseToolParams, GmailBaseTool } from "./base.js";
3
+ export declare class GmailGetMessage extends GmailBaseTool {
4
+ name: string;
5
+ schema: z.ZodObject<{
6
+ messageId: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ messageId: string;
9
+ }, {
10
+ messageId: string;
11
+ }>;
12
+ description: string;
13
+ constructor(fields?: GmailBaseToolParams);
14
+ _call(arg: z.output<typeof this.schema>): Promise<string>;
15
+ }
16
+ export type GetMessageSchema = {
17
+ messageId: string;
18
+ };
@@ -0,0 +1,79 @@
1
+ import { z } from "zod";
2
+ import { GmailBaseTool } from "./base.js";
3
+ import { GET_MESSAGE_DESCRIPTION } from "./descriptions.js";
4
+ export class GmailGetMessage extends GmailBaseTool {
5
+ constructor(fields) {
6
+ super(fields);
7
+ Object.defineProperty(this, "name", {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value: "gmail_get_message"
12
+ });
13
+ Object.defineProperty(this, "schema", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: z.object({
18
+ messageId: z.string(),
19
+ })
20
+ });
21
+ Object.defineProperty(this, "description", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: GET_MESSAGE_DESCRIPTION
26
+ });
27
+ }
28
+ async _call(arg) {
29
+ const { messageId } = arg;
30
+ const message = await this.gmail.users.messages.get({
31
+ userId: "me",
32
+ id: messageId,
33
+ });
34
+ const { data } = message;
35
+ if (!data) {
36
+ throw new Error("No data returned from Gmail");
37
+ }
38
+ const { payload } = data;
39
+ if (!payload) {
40
+ throw new Error("No payload returned from Gmail");
41
+ }
42
+ const { headers } = payload;
43
+ if (!headers) {
44
+ throw new Error("No headers returned from Gmail");
45
+ }
46
+ const subject = headers.find((header) => header.name === "Subject");
47
+ if (!subject) {
48
+ throw new Error("No subject returned from Gmail");
49
+ }
50
+ const body = headers.find((header) => header.name === "Body");
51
+ if (!body) {
52
+ throw new Error("No body returned from Gmail");
53
+ }
54
+ const from = headers.find((header) => header.name === "From");
55
+ if (!from) {
56
+ throw new Error("No from returned from Gmail");
57
+ }
58
+ const to = headers.find((header) => header.name === "To");
59
+ if (!to) {
60
+ throw new Error("No to returned from Gmail");
61
+ }
62
+ const date = headers.find((header) => header.name === "Date");
63
+ if (!date) {
64
+ throw new Error("No date returned from Gmail");
65
+ }
66
+ const messageIdHeader = headers.find((header) => header.name === "Message-ID");
67
+ if (!messageIdHeader) {
68
+ throw new Error("No message id returned from Gmail");
69
+ }
70
+ return `Result for the prompt ${messageId} \n${JSON.stringify({
71
+ subject: subject.value,
72
+ body: body.value,
73
+ from: from.value,
74
+ to: to.value,
75
+ date: date.value,
76
+ messageId: messageIdHeader.value,
77
+ })}`;
78
+ }
79
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GmailGetThread = void 0;
4
+ const zod_1 = require("zod");
5
+ const base_js_1 = require("./base.cjs");
6
+ const descriptions_js_1 = require("./descriptions.cjs");
7
+ class GmailGetThread extends base_js_1.GmailBaseTool {
8
+ constructor(fields) {
9
+ super(fields);
10
+ Object.defineProperty(this, "name", {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value: "gmail_get_thread"
15
+ });
16
+ Object.defineProperty(this, "schema", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: zod_1.z.object({
21
+ threadId: zod_1.z.string(),
22
+ })
23
+ });
24
+ Object.defineProperty(this, "description", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: descriptions_js_1.GET_THREAD_DESCRIPTION
29
+ });
30
+ }
31
+ async _call(arg) {
32
+ const { threadId } = arg;
33
+ const thread = await this.gmail.users.threads.get({
34
+ userId: "me",
35
+ id: threadId,
36
+ });
37
+ const { data } = thread;
38
+ if (!data) {
39
+ throw new Error("No data returned from Gmail");
40
+ }
41
+ const { messages } = data;
42
+ if (!messages) {
43
+ throw new Error("No messages returned from Gmail");
44
+ }
45
+ return `Result for the prompt ${threadId} \n${JSON.stringify(messages.map((message) => {
46
+ const { payload } = message;
47
+ if (!payload) {
48
+ throw new Error("No payload returned from Gmail");
49
+ }
50
+ const { headers } = payload;
51
+ if (!headers) {
52
+ throw new Error("No headers returned from Gmail");
53
+ }
54
+ const subject = headers.find((header) => header.name === "Subject");
55
+ if (!subject) {
56
+ throw new Error("No subject returned from Gmail");
57
+ }
58
+ const body = headers.find((header) => header.name === "Body");
59
+ if (!body) {
60
+ throw new Error("No body returned from Gmail");
61
+ }
62
+ const from = headers.find((header) => header.name === "From");
63
+ if (!from) {
64
+ throw new Error("No from returned from Gmail");
65
+ }
66
+ const to = headers.find((header) => header.name === "To");
67
+ if (!to) {
68
+ throw new Error("No to returned from Gmail");
69
+ }
70
+ const date = headers.find((header) => header.name === "Date");
71
+ if (!date) {
72
+ throw new Error("No date returned from Gmail");
73
+ }
74
+ const messageIdHeader = headers.find((header) => header.name === "Message-ID");
75
+ if (!messageIdHeader) {
76
+ throw new Error("No message id returned from Gmail");
77
+ }
78
+ return {
79
+ subject: subject.value,
80
+ body: body.value,
81
+ from: from.value,
82
+ to: to.value,
83
+ date: date.value,
84
+ messageId: messageIdHeader.value,
85
+ };
86
+ }))}`;
87
+ }
88
+ }
89
+ exports.GmailGetThread = GmailGetThread;
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ import { GmailBaseTool, GmailBaseToolParams } from "./base.js";
3
+ export declare class GmailGetThread extends GmailBaseTool {
4
+ name: string;
5
+ schema: z.ZodObject<{
6
+ threadId: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ threadId: string;
9
+ }, {
10
+ threadId: string;
11
+ }>;
12
+ description: string;
13
+ constructor(fields?: GmailBaseToolParams);
14
+ _call(arg: z.output<typeof this.schema>): Promise<string>;
15
+ }
16
+ export type GetThreadSchema = {
17
+ threadId: string;
18
+ };
@@ -0,0 +1,85 @@
1
+ import { z } from "zod";
2
+ import { GmailBaseTool } from "./base.js";
3
+ import { GET_THREAD_DESCRIPTION } from "./descriptions.js";
4
+ export class GmailGetThread extends GmailBaseTool {
5
+ constructor(fields) {
6
+ super(fields);
7
+ Object.defineProperty(this, "name", {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value: "gmail_get_thread"
12
+ });
13
+ Object.defineProperty(this, "schema", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: z.object({
18
+ threadId: z.string(),
19
+ })
20
+ });
21
+ Object.defineProperty(this, "description", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: GET_THREAD_DESCRIPTION
26
+ });
27
+ }
28
+ async _call(arg) {
29
+ const { threadId } = arg;
30
+ const thread = await this.gmail.users.threads.get({
31
+ userId: "me",
32
+ id: threadId,
33
+ });
34
+ const { data } = thread;
35
+ if (!data) {
36
+ throw new Error("No data returned from Gmail");
37
+ }
38
+ const { messages } = data;
39
+ if (!messages) {
40
+ throw new Error("No messages returned from Gmail");
41
+ }
42
+ return `Result for the prompt ${threadId} \n${JSON.stringify(messages.map((message) => {
43
+ const { payload } = message;
44
+ if (!payload) {
45
+ throw new Error("No payload returned from Gmail");
46
+ }
47
+ const { headers } = payload;
48
+ if (!headers) {
49
+ throw new Error("No headers returned from Gmail");
50
+ }
51
+ const subject = headers.find((header) => header.name === "Subject");
52
+ if (!subject) {
53
+ throw new Error("No subject returned from Gmail");
54
+ }
55
+ const body = headers.find((header) => header.name === "Body");
56
+ if (!body) {
57
+ throw new Error("No body returned from Gmail");
58
+ }
59
+ const from = headers.find((header) => header.name === "From");
60
+ if (!from) {
61
+ throw new Error("No from returned from Gmail");
62
+ }
63
+ const to = headers.find((header) => header.name === "To");
64
+ if (!to) {
65
+ throw new Error("No to returned from Gmail");
66
+ }
67
+ const date = headers.find((header) => header.name === "Date");
68
+ if (!date) {
69
+ throw new Error("No date returned from Gmail");
70
+ }
71
+ const messageIdHeader = headers.find((header) => header.name === "Message-ID");
72
+ if (!messageIdHeader) {
73
+ throw new Error("No message id returned from Gmail");
74
+ }
75
+ return {
76
+ subject: subject.value,
77
+ body: body.value,
78
+ from: from.value,
79
+ to: to.value,
80
+ date: date.value,
81
+ messageId: messageIdHeader.value,
82
+ };
83
+ }))}`;
84
+ }
85
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GmailSendMessage = exports.GmailSearch = exports.GmailGetThread = exports.GmailGetMessage = exports.GmailCreateDraft = void 0;
4
+ var create_draft_js_1 = require("./create_draft.cjs");
5
+ Object.defineProperty(exports, "GmailCreateDraft", { enumerable: true, get: function () { return create_draft_js_1.GmailCreateDraft; } });
6
+ var get_message_js_1 = require("./get_message.cjs");
7
+ Object.defineProperty(exports, "GmailGetMessage", { enumerable: true, get: function () { return get_message_js_1.GmailGetMessage; } });
8
+ var get_thread_js_1 = require("./get_thread.cjs");
9
+ Object.defineProperty(exports, "GmailGetThread", { enumerable: true, get: function () { return get_thread_js_1.GmailGetThread; } });
10
+ var search_js_1 = require("./search.cjs");
11
+ Object.defineProperty(exports, "GmailSearch", { enumerable: true, get: function () { return search_js_1.GmailSearch; } });
12
+ var send_message_js_1 = require("./send_message.cjs");
13
+ Object.defineProperty(exports, "GmailSendMessage", { enumerable: true, get: function () { return send_message_js_1.GmailSendMessage; } });
@@ -0,0 +1,11 @@
1
+ export { GmailCreateDraft } from "./create_draft.js";
2
+ export { GmailGetMessage } from "./get_message.js";
3
+ export { GmailGetThread } from "./get_thread.js";
4
+ export { GmailSearch } from "./search.js";
5
+ export { GmailSendMessage } from "./send_message.js";
6
+ export type { GmailBaseToolParams } from "./base.js";
7
+ export type { CreateDraftSchema } from "./create_draft.js";
8
+ export type { GetMessageSchema } from "./get_message.js";
9
+ export type { GetThreadSchema } from "./get_thread.js";
10
+ export type { SearchSchema } from "./search.js";
11
+ export type { SendMessageSchema } from "./send_message.js";
@@ -0,0 +1,5 @@
1
+ export { GmailCreateDraft } from "./create_draft.js";
2
+ export { GmailGetMessage } from "./get_message.js";
3
+ export { GmailGetThread } from "./get_thread.js";
4
+ export { GmailSearch } from "./search.js";
5
+ export { GmailSendMessage } from "./send_message.js";