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.
- package/agents/toolkits/connery.cjs +1 -0
- package/agents/toolkits/connery.d.ts +1 -0
- package/agents/toolkits/connery.js +1 -0
- package/dist/agents/toolkits/connery/index.cjs +39 -0
- package/dist/agents/toolkits/connery/index.d.ts +23 -0
- package/dist/agents/toolkits/connery/index.js +35 -0
- package/dist/document_loaders/fs/obsidian.cjs +240 -0
- package/dist/document_loaders/fs/obsidian.d.ts +26 -0
- package/dist/document_loaders/fs/obsidian.js +233 -0
- package/dist/embeddings/gradient_ai.cjs +1 -0
- package/dist/embeddings/gradient_ai.js +1 -0
- package/dist/load/import_constants.cjs +2 -0
- package/dist/load/import_constants.js +2 -0
- package/dist/load/import_map.cjs +5 -3
- package/dist/load/import_map.d.ts +2 -0
- package/dist/load/import_map.js +2 -0
- package/dist/tools/connery.cjs +279 -0
- package/dist/tools/connery.d.ts +145 -0
- package/dist/tools/connery.js +274 -0
- package/dist/tools/gmail/base.cjs +69 -0
- package/dist/tools/gmail/base.d.ts +19 -0
- package/dist/tools/gmail/base.js +65 -0
- package/dist/tools/gmail/create_draft.cjs +62 -0
- package/dist/tools/gmail/create_draft.d.ts +35 -0
- package/dist/tools/gmail/create_draft.js +58 -0
- package/dist/tools/gmail/descriptions.cjs +118 -0
- package/dist/tools/gmail/descriptions.d.ts +5 -0
- package/dist/tools/gmail/descriptions.js +115 -0
- package/dist/tools/gmail/get_message.cjs +83 -0
- package/dist/tools/gmail/get_message.d.ts +18 -0
- package/dist/tools/gmail/get_message.js +79 -0
- package/dist/tools/gmail/get_thread.cjs +89 -0
- package/dist/tools/gmail/get_thread.d.ts +18 -0
- package/dist/tools/gmail/get_thread.js +85 -0
- package/dist/tools/gmail/index.cjs +13 -0
- package/dist/tools/gmail/index.d.ts +11 -0
- package/dist/tools/gmail/index.js +5 -0
- package/dist/tools/gmail/search.cjs +118 -0
- package/dist/tools/gmail/search.d.ts +29 -0
- package/dist/tools/gmail/search.js +114 -0
- package/dist/tools/gmail/send_message.cjs +74 -0
- package/dist/tools/gmail/send_message.d.ts +35 -0
- package/dist/tools/gmail/send_message.js +70 -0
- package/dist/tools/wolframalpha.cjs +1 -1
- package/dist/tools/wolframalpha.js +1 -1
- package/document_loaders/fs/obsidian.cjs +1 -0
- package/document_loaders/fs/obsidian.d.ts +1 -0
- package/document_loaders/fs/obsidian.js +1 -0
- package/package.json +35 -3
- package/tools/connery.cjs +1 -0
- package/tools/connery.d.ts +1 -0
- package/tools/connery.js +1 -0
- package/tools/gmail.cjs +1 -0
- package/tools/gmail.d.ts +1 -0
- package/tools/gmail.js +1 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GmailSearch = 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 GmailSearch 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: "search_gmail"
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(this, "schema", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: zod_1.z.object({
|
|
21
|
+
query: zod_1.z.string(),
|
|
22
|
+
maxResults: zod_1.z.number().optional(),
|
|
23
|
+
resource: zod_1.z.enum(["messages", "threads"]).optional(),
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "description", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: descriptions_js_1.SEARCH_DESCRIPTION
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async _call(arg) {
|
|
34
|
+
const { query, maxResults = 10, resource = "messages" } = arg;
|
|
35
|
+
const response = await this.gmail.users.messages.list({
|
|
36
|
+
userId: "me",
|
|
37
|
+
q: query,
|
|
38
|
+
maxResults,
|
|
39
|
+
});
|
|
40
|
+
const { data } = response;
|
|
41
|
+
if (!data) {
|
|
42
|
+
throw new Error("No data returned from Gmail");
|
|
43
|
+
}
|
|
44
|
+
const { messages } = data;
|
|
45
|
+
if (!messages) {
|
|
46
|
+
throw new Error("No messages returned from Gmail");
|
|
47
|
+
}
|
|
48
|
+
if (resource === "messages") {
|
|
49
|
+
const parsedMessages = await this.parseMessages(messages);
|
|
50
|
+
return `Result for the query ${query}:\n${JSON.stringify(parsedMessages)}`;
|
|
51
|
+
}
|
|
52
|
+
else if (resource === "threads") {
|
|
53
|
+
const parsedThreads = await this.parseThreads(messages);
|
|
54
|
+
return `Result for the query ${query}:\n${JSON.stringify(parsedThreads)}`;
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`Invalid resource: ${resource}`);
|
|
57
|
+
}
|
|
58
|
+
async parseMessages(messages) {
|
|
59
|
+
const parsedMessages = await Promise.all(messages.map(async (message) => {
|
|
60
|
+
const messageData = await this.gmail.users.messages.get({
|
|
61
|
+
userId: "me",
|
|
62
|
+
format: "raw",
|
|
63
|
+
id: message.id ?? "",
|
|
64
|
+
});
|
|
65
|
+
const headers = messageData.data.payload?.headers || [];
|
|
66
|
+
const subject = headers.find((header) => header.name === "Subject");
|
|
67
|
+
const sender = headers.find((header) => header.name === "From");
|
|
68
|
+
let body = "";
|
|
69
|
+
if (messageData.data.payload?.parts) {
|
|
70
|
+
body = messageData.data.payload.parts
|
|
71
|
+
.map((part) => part.body?.data ?? "")
|
|
72
|
+
.join("");
|
|
73
|
+
}
|
|
74
|
+
else if (messageData.data.payload?.body?.data) {
|
|
75
|
+
body = messageData.data.payload.body.data;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
id: message.id,
|
|
79
|
+
threadId: message.threadId,
|
|
80
|
+
snippet: message.snippet,
|
|
81
|
+
body,
|
|
82
|
+
subject,
|
|
83
|
+
sender,
|
|
84
|
+
};
|
|
85
|
+
}));
|
|
86
|
+
return parsedMessages;
|
|
87
|
+
}
|
|
88
|
+
async parseThreads(threads) {
|
|
89
|
+
const parsedThreads = await Promise.all(threads.map(async (thread) => {
|
|
90
|
+
const threadData = await this.gmail.users.threads.get({
|
|
91
|
+
userId: "me",
|
|
92
|
+
format: "raw",
|
|
93
|
+
id: thread.id ?? "",
|
|
94
|
+
});
|
|
95
|
+
const headers = threadData.data.messages?.[0]?.payload?.headers || [];
|
|
96
|
+
const subject = headers.find((header) => header.name === "Subject");
|
|
97
|
+
const sender = headers.find((header) => header.name === "From");
|
|
98
|
+
let body = "";
|
|
99
|
+
if (threadData.data.messages?.[0]?.payload?.parts) {
|
|
100
|
+
body = threadData.data.messages[0].payload.parts
|
|
101
|
+
.map((part) => part.body?.data ?? "")
|
|
102
|
+
.join("");
|
|
103
|
+
}
|
|
104
|
+
else if (threadData.data.messages?.[0]?.payload?.body?.data) {
|
|
105
|
+
body = threadData.data.messages[0].payload.body.data;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
id: thread.id,
|
|
109
|
+
snippet: thread.snippet,
|
|
110
|
+
body,
|
|
111
|
+
subject,
|
|
112
|
+
sender,
|
|
113
|
+
};
|
|
114
|
+
}));
|
|
115
|
+
return parsedThreads;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.GmailSearch = GmailSearch;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { gmail_v1 } from "googleapis";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { GmailBaseTool, GmailBaseToolParams } from "./base.js";
|
|
4
|
+
export declare class GmailSearch extends GmailBaseTool {
|
|
5
|
+
name: string;
|
|
6
|
+
schema: z.ZodObject<{
|
|
7
|
+
query: z.ZodString;
|
|
8
|
+
maxResults: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
resource: z.ZodOptional<z.ZodEnum<["messages", "threads"]>>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
query: string;
|
|
12
|
+
maxResults?: number | undefined;
|
|
13
|
+
resource?: "messages" | "threads" | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
query: string;
|
|
16
|
+
maxResults?: number | undefined;
|
|
17
|
+
resource?: "messages" | "threads" | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
description: string;
|
|
20
|
+
constructor(fields?: GmailBaseToolParams);
|
|
21
|
+
_call(arg: z.output<typeof this.schema>): Promise<string>;
|
|
22
|
+
parseMessages(messages: gmail_v1.Schema$Message[]): Promise<gmail_v1.Schema$Message[]>;
|
|
23
|
+
parseThreads(threads: gmail_v1.Schema$Thread[]): Promise<gmail_v1.Schema$Thread[]>;
|
|
24
|
+
}
|
|
25
|
+
export type SearchSchema = {
|
|
26
|
+
query: string;
|
|
27
|
+
maxResults?: number;
|
|
28
|
+
resource?: "messages" | "threads";
|
|
29
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { GmailBaseTool } from "./base.js";
|
|
3
|
+
import { SEARCH_DESCRIPTION } from "./descriptions.js";
|
|
4
|
+
export class GmailSearch extends GmailBaseTool {
|
|
5
|
+
constructor(fields) {
|
|
6
|
+
super(fields);
|
|
7
|
+
Object.defineProperty(this, "name", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: "search_gmail"
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(this, "schema", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: z.object({
|
|
18
|
+
query: z.string(),
|
|
19
|
+
maxResults: z.number().optional(),
|
|
20
|
+
resource: z.enum(["messages", "threads"]).optional(),
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "description", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: SEARCH_DESCRIPTION
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async _call(arg) {
|
|
31
|
+
const { query, maxResults = 10, resource = "messages" } = arg;
|
|
32
|
+
const response = await this.gmail.users.messages.list({
|
|
33
|
+
userId: "me",
|
|
34
|
+
q: query,
|
|
35
|
+
maxResults,
|
|
36
|
+
});
|
|
37
|
+
const { data } = response;
|
|
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
|
+
if (resource === "messages") {
|
|
46
|
+
const parsedMessages = await this.parseMessages(messages);
|
|
47
|
+
return `Result for the query ${query}:\n${JSON.stringify(parsedMessages)}`;
|
|
48
|
+
}
|
|
49
|
+
else if (resource === "threads") {
|
|
50
|
+
const parsedThreads = await this.parseThreads(messages);
|
|
51
|
+
return `Result for the query ${query}:\n${JSON.stringify(parsedThreads)}`;
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`Invalid resource: ${resource}`);
|
|
54
|
+
}
|
|
55
|
+
async parseMessages(messages) {
|
|
56
|
+
const parsedMessages = await Promise.all(messages.map(async (message) => {
|
|
57
|
+
const messageData = await this.gmail.users.messages.get({
|
|
58
|
+
userId: "me",
|
|
59
|
+
format: "raw",
|
|
60
|
+
id: message.id ?? "",
|
|
61
|
+
});
|
|
62
|
+
const headers = messageData.data.payload?.headers || [];
|
|
63
|
+
const subject = headers.find((header) => header.name === "Subject");
|
|
64
|
+
const sender = headers.find((header) => header.name === "From");
|
|
65
|
+
let body = "";
|
|
66
|
+
if (messageData.data.payload?.parts) {
|
|
67
|
+
body = messageData.data.payload.parts
|
|
68
|
+
.map((part) => part.body?.data ?? "")
|
|
69
|
+
.join("");
|
|
70
|
+
}
|
|
71
|
+
else if (messageData.data.payload?.body?.data) {
|
|
72
|
+
body = messageData.data.payload.body.data;
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
id: message.id,
|
|
76
|
+
threadId: message.threadId,
|
|
77
|
+
snippet: message.snippet,
|
|
78
|
+
body,
|
|
79
|
+
subject,
|
|
80
|
+
sender,
|
|
81
|
+
};
|
|
82
|
+
}));
|
|
83
|
+
return parsedMessages;
|
|
84
|
+
}
|
|
85
|
+
async parseThreads(threads) {
|
|
86
|
+
const parsedThreads = await Promise.all(threads.map(async (thread) => {
|
|
87
|
+
const threadData = await this.gmail.users.threads.get({
|
|
88
|
+
userId: "me",
|
|
89
|
+
format: "raw",
|
|
90
|
+
id: thread.id ?? "",
|
|
91
|
+
});
|
|
92
|
+
const headers = threadData.data.messages?.[0]?.payload?.headers || [];
|
|
93
|
+
const subject = headers.find((header) => header.name === "Subject");
|
|
94
|
+
const sender = headers.find((header) => header.name === "From");
|
|
95
|
+
let body = "";
|
|
96
|
+
if (threadData.data.messages?.[0]?.payload?.parts) {
|
|
97
|
+
body = threadData.data.messages[0].payload.parts
|
|
98
|
+
.map((part) => part.body?.data ?? "")
|
|
99
|
+
.join("");
|
|
100
|
+
}
|
|
101
|
+
else if (threadData.data.messages?.[0]?.payload?.body?.data) {
|
|
102
|
+
body = threadData.data.messages[0].payload.body.data;
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
id: thread.id,
|
|
106
|
+
snippet: thread.snippet,
|
|
107
|
+
body,
|
|
108
|
+
subject,
|
|
109
|
+
sender,
|
|
110
|
+
};
|
|
111
|
+
}));
|
|
112
|
+
return parsedThreads;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GmailSendMessage = 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 GmailSendMessage 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_send_message"
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(this, "schema", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: zod_1.z.object({
|
|
21
|
+
message: zod_1.z.string(),
|
|
22
|
+
to: zod_1.z.array(zod_1.z.string()),
|
|
23
|
+
subject: zod_1.z.string(),
|
|
24
|
+
cc: zod_1.z.array(zod_1.z.string()).optional(),
|
|
25
|
+
bcc: zod_1.z.array(zod_1.z.string()).optional(),
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(this, "description", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: descriptions_js_1.GET_MESSAGE_DESCRIPTION
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
createEmailMessage({ message, to, subject, cc, bcc, }) {
|
|
36
|
+
const emailLines = [];
|
|
37
|
+
// Format the recipient(s)
|
|
38
|
+
const formatEmailList = (emails) => Array.isArray(emails) ? emails.join(",") : emails;
|
|
39
|
+
emailLines.push(`To: ${formatEmailList(to)}`);
|
|
40
|
+
if (cc)
|
|
41
|
+
emailLines.push(`Cc: ${formatEmailList(cc)}`);
|
|
42
|
+
if (bcc)
|
|
43
|
+
emailLines.push(`Bcc: ${formatEmailList(bcc)}`);
|
|
44
|
+
emailLines.push(`Subject: ${subject}`);
|
|
45
|
+
emailLines.push("");
|
|
46
|
+
emailLines.push(message);
|
|
47
|
+
// Convert the email message to base64url string
|
|
48
|
+
const email = emailLines.join("\r\n").trim();
|
|
49
|
+
// this encode may be an issue
|
|
50
|
+
return Buffer.from(email).toString("base64url");
|
|
51
|
+
}
|
|
52
|
+
async _call({ message, to, subject, cc, bcc, }) {
|
|
53
|
+
const rawMessage = this.createEmailMessage({
|
|
54
|
+
message,
|
|
55
|
+
to,
|
|
56
|
+
subject,
|
|
57
|
+
cc,
|
|
58
|
+
bcc,
|
|
59
|
+
});
|
|
60
|
+
try {
|
|
61
|
+
const response = await this.gmail.users.messages.send({
|
|
62
|
+
userId: "me",
|
|
63
|
+
requestBody: {
|
|
64
|
+
raw: rawMessage,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
return `Message sent. Message Id: ${response.data.id}`;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
throw new Error(`An error occurred while sending the message: ${error}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.GmailSendMessage = GmailSendMessage;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { GmailBaseTool, GmailBaseToolParams } from "./base.js";
|
|
3
|
+
export declare class GmailSendMessage extends GmailBaseTool {
|
|
4
|
+
name: string;
|
|
5
|
+
schema: z.ZodObject<{
|
|
6
|
+
message: z.ZodString;
|
|
7
|
+
to: z.ZodArray<z.ZodString, "many">;
|
|
8
|
+
subject: z.ZodString;
|
|
9
|
+
cc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
+
bcc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
message: string;
|
|
13
|
+
subject: string;
|
|
14
|
+
to: string[];
|
|
15
|
+
cc?: string[] | undefined;
|
|
16
|
+
bcc?: string[] | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
message: string;
|
|
19
|
+
subject: string;
|
|
20
|
+
to: string[];
|
|
21
|
+
cc?: string[] | undefined;
|
|
22
|
+
bcc?: string[] | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
description: string;
|
|
25
|
+
constructor(fields?: GmailBaseToolParams);
|
|
26
|
+
private createEmailMessage;
|
|
27
|
+
_call({ message, to, subject, cc, bcc, }: z.output<typeof this.schema>): Promise<string>;
|
|
28
|
+
}
|
|
29
|
+
export type SendMessageSchema = {
|
|
30
|
+
message: string;
|
|
31
|
+
to: string[];
|
|
32
|
+
subject: string;
|
|
33
|
+
cc?: string[];
|
|
34
|
+
bcc?: string[];
|
|
35
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { GmailBaseTool } from "./base.js";
|
|
3
|
+
import { GET_MESSAGE_DESCRIPTION } from "./descriptions.js";
|
|
4
|
+
export class GmailSendMessage 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_send_message"
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(this, "schema", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: z.object({
|
|
18
|
+
message: z.string(),
|
|
19
|
+
to: z.array(z.string()),
|
|
20
|
+
subject: z.string(),
|
|
21
|
+
cc: z.array(z.string()).optional(),
|
|
22
|
+
bcc: z.array(z.string()).optional(),
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(this, "description", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: GET_MESSAGE_DESCRIPTION
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
createEmailMessage({ message, to, subject, cc, bcc, }) {
|
|
33
|
+
const emailLines = [];
|
|
34
|
+
// Format the recipient(s)
|
|
35
|
+
const formatEmailList = (emails) => Array.isArray(emails) ? emails.join(",") : emails;
|
|
36
|
+
emailLines.push(`To: ${formatEmailList(to)}`);
|
|
37
|
+
if (cc)
|
|
38
|
+
emailLines.push(`Cc: ${formatEmailList(cc)}`);
|
|
39
|
+
if (bcc)
|
|
40
|
+
emailLines.push(`Bcc: ${formatEmailList(bcc)}`);
|
|
41
|
+
emailLines.push(`Subject: ${subject}`);
|
|
42
|
+
emailLines.push("");
|
|
43
|
+
emailLines.push(message);
|
|
44
|
+
// Convert the email message to base64url string
|
|
45
|
+
const email = emailLines.join("\r\n").trim();
|
|
46
|
+
// this encode may be an issue
|
|
47
|
+
return Buffer.from(email).toString("base64url");
|
|
48
|
+
}
|
|
49
|
+
async _call({ message, to, subject, cc, bcc, }) {
|
|
50
|
+
const rawMessage = this.createEmailMessage({
|
|
51
|
+
message,
|
|
52
|
+
to,
|
|
53
|
+
subject,
|
|
54
|
+
cc,
|
|
55
|
+
bcc,
|
|
56
|
+
});
|
|
57
|
+
try {
|
|
58
|
+
const response = await this.gmail.users.messages.send({
|
|
59
|
+
userId: "me",
|
|
60
|
+
requestBody: {
|
|
61
|
+
raw: rawMessage,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
return `Message sent. Message Id: ${response.data.id}`;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
throw new Error(`An error occurred while sending the message: ${error}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -41,7 +41,7 @@ class WolframAlphaTool extends base_js_1.Tool {
|
|
|
41
41
|
return "WolframAlphaTool";
|
|
42
42
|
}
|
|
43
43
|
async _call(query) {
|
|
44
|
-
const url = `https://www.wolframalpha.com/api/v1/llm-api?appid=${this.appid}&input=${query}`;
|
|
44
|
+
const url = `https://www.wolframalpha.com/api/v1/llm-api?appid=${this.appid}&input=${encodeURIComponent(query)}`;
|
|
45
45
|
const res = await fetch(url);
|
|
46
46
|
return res.text();
|
|
47
47
|
}
|
|
@@ -38,7 +38,7 @@ export class WolframAlphaTool extends Tool {
|
|
|
38
38
|
return "WolframAlphaTool";
|
|
39
39
|
}
|
|
40
40
|
async _call(query) {
|
|
41
|
-
const url = `https://www.wolframalpha.com/api/v1/llm-api?appid=${this.appid}&input=${query}`;
|
|
41
|
+
const url = `https://www.wolframalpha.com/api/v1/llm-api?appid=${this.appid}&input=${encodeURIComponent(query)}`;
|
|
42
42
|
const res = await fetch(url);
|
|
43
43
|
return res.text();
|
|
44
44
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/document_loaders/fs/obsidian.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/document_loaders/fs/obsidian.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/document_loaders/fs/obsidian.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.201",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
"agents/toolkits/aws_sfn.cjs",
|
|
29
29
|
"agents/toolkits/aws_sfn.js",
|
|
30
30
|
"agents/toolkits/aws_sfn.d.ts",
|
|
31
|
+
"agents/toolkits/connery.cjs",
|
|
32
|
+
"agents/toolkits/connery.js",
|
|
33
|
+
"agents/toolkits/connery.d.ts",
|
|
31
34
|
"agents/toolkits/sql.cjs",
|
|
32
35
|
"agents/toolkits/sql.js",
|
|
33
36
|
"agents/toolkits/sql.d.ts",
|
|
@@ -70,6 +73,9 @@
|
|
|
70
73
|
"tools/calculator.cjs",
|
|
71
74
|
"tools/calculator.js",
|
|
72
75
|
"tools/calculator.d.ts",
|
|
76
|
+
"tools/connery.cjs",
|
|
77
|
+
"tools/connery.js",
|
|
78
|
+
"tools/connery.d.ts",
|
|
73
79
|
"tools/render.cjs",
|
|
74
80
|
"tools/render.js",
|
|
75
81
|
"tools/render.d.ts",
|
|
@@ -79,6 +85,9 @@
|
|
|
79
85
|
"tools/webbrowser.cjs",
|
|
80
86
|
"tools/webbrowser.js",
|
|
81
87
|
"tools/webbrowser.d.ts",
|
|
88
|
+
"tools/gmail.cjs",
|
|
89
|
+
"tools/gmail.js",
|
|
90
|
+
"tools/gmail.d.ts",
|
|
82
91
|
"tools/google_calendar.cjs",
|
|
83
92
|
"tools/google_calendar.js",
|
|
84
93
|
"tools/google_calendar.d.ts",
|
|
@@ -481,6 +490,9 @@
|
|
|
481
490
|
"document_loaders/fs/notion.cjs",
|
|
482
491
|
"document_loaders/fs/notion.js",
|
|
483
492
|
"document_loaders/fs/notion.d.ts",
|
|
493
|
+
"document_loaders/fs/obsidian.cjs",
|
|
494
|
+
"document_loaders/fs/obsidian.js",
|
|
495
|
+
"document_loaders/fs/obsidian.d.ts",
|
|
484
496
|
"document_loaders/fs/unstructured.cjs",
|
|
485
497
|
"document_loaders/fs/unstructured.js",
|
|
486
498
|
"document_loaders/fs/unstructured.d.ts",
|
|
@@ -854,7 +866,7 @@
|
|
|
854
866
|
"lint": "yarn lint:eslint && yarn lint:dpdm",
|
|
855
867
|
"lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
|
|
856
868
|
"precommit": "lint-staged",
|
|
857
|
-
"clean": "rimraf dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre",
|
|
869
|
+
"clean": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre",
|
|
858
870
|
"prepack": "yarn build",
|
|
859
871
|
"release": "release-it --only-version --config .release-it.json",
|
|
860
872
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
|
|
@@ -1420,7 +1432,7 @@
|
|
|
1420
1432
|
},
|
|
1421
1433
|
"dependencies": {
|
|
1422
1434
|
"@anthropic-ai/sdk": "^0.9.1",
|
|
1423
|
-
"@langchain/core": "~0.0.
|
|
1435
|
+
"@langchain/core": "~0.0.8",
|
|
1424
1436
|
"binary-extensions": "^2.2.0",
|
|
1425
1437
|
"expr-eval": "^2.0.2",
|
|
1426
1438
|
"flat": "^5.0.2",
|
|
@@ -1486,6 +1498,11 @@
|
|
|
1486
1498
|
"import": "./agents/toolkits/aws_sfn.js",
|
|
1487
1499
|
"require": "./agents/toolkits/aws_sfn.cjs"
|
|
1488
1500
|
},
|
|
1501
|
+
"./agents/toolkits/connery": {
|
|
1502
|
+
"types": "./agents/toolkits/connery.d.ts",
|
|
1503
|
+
"import": "./agents/toolkits/connery.js",
|
|
1504
|
+
"require": "./agents/toolkits/connery.cjs"
|
|
1505
|
+
},
|
|
1489
1506
|
"./agents/toolkits/sql": {
|
|
1490
1507
|
"types": "./agents/toolkits/sql.d.ts",
|
|
1491
1508
|
"import": "./agents/toolkits/sql.js",
|
|
@@ -1556,6 +1573,11 @@
|
|
|
1556
1573
|
"import": "./tools/calculator.js",
|
|
1557
1574
|
"require": "./tools/calculator.cjs"
|
|
1558
1575
|
},
|
|
1576
|
+
"./tools/connery": {
|
|
1577
|
+
"types": "./tools/connery.d.ts",
|
|
1578
|
+
"import": "./tools/connery.js",
|
|
1579
|
+
"require": "./tools/connery.cjs"
|
|
1580
|
+
},
|
|
1559
1581
|
"./tools/render": {
|
|
1560
1582
|
"types": "./tools/render.d.ts",
|
|
1561
1583
|
"import": "./tools/render.js",
|
|
@@ -1571,6 +1593,11 @@
|
|
|
1571
1593
|
"import": "./tools/webbrowser.js",
|
|
1572
1594
|
"require": "./tools/webbrowser.cjs"
|
|
1573
1595
|
},
|
|
1596
|
+
"./tools/gmail": {
|
|
1597
|
+
"types": "./tools/gmail.d.ts",
|
|
1598
|
+
"import": "./tools/gmail.js",
|
|
1599
|
+
"require": "./tools/gmail.cjs"
|
|
1600
|
+
},
|
|
1574
1601
|
"./tools/google_calendar": {
|
|
1575
1602
|
"types": "./tools/google_calendar.d.ts",
|
|
1576
1603
|
"import": "./tools/google_calendar.js",
|
|
@@ -2241,6 +2268,11 @@
|
|
|
2241
2268
|
"import": "./document_loaders/fs/notion.js",
|
|
2242
2269
|
"require": "./document_loaders/fs/notion.cjs"
|
|
2243
2270
|
},
|
|
2271
|
+
"./document_loaders/fs/obsidian": {
|
|
2272
|
+
"types": "./document_loaders/fs/obsidian.d.ts",
|
|
2273
|
+
"import": "./document_loaders/fs/obsidian.js",
|
|
2274
|
+
"require": "./document_loaders/fs/obsidian.cjs"
|
|
2275
|
+
},
|
|
2244
2276
|
"./document_loaders/fs/unstructured": {
|
|
2245
2277
|
"types": "./document_loaders/fs/unstructured.d.ts",
|
|
2246
2278
|
"import": "./document_loaders/fs/unstructured.js",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/tools/connery.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/tools/connery.js'
|
package/tools/connery.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/tools/connery.js'
|
package/tools/gmail.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/tools/gmail/index.cjs');
|
package/tools/gmail.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/tools/gmail/index.js'
|
package/tools/gmail.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/tools/gmail/index.js'
|