agentmail-toolkit 0.1.0
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/src/ai-sdk.js +17 -0
- package/dist/src/index.js +17 -0
- package/dist/src/schemas.js +52 -0
- package/dist/src/toolkit.js +42 -0
- package/dist/src/tools.js +66 -0
- package/package.json +48 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentMailToolkit = void 0;
|
|
4
|
+
const toolkit_1 = require("./toolkit");
|
|
5
|
+
class AgentMailToolkit extends toolkit_1.Toolkit {
|
|
6
|
+
constructor(client) {
|
|
7
|
+
super(client);
|
|
8
|
+
}
|
|
9
|
+
buildTool(tool) {
|
|
10
|
+
return {
|
|
11
|
+
description: tool.description,
|
|
12
|
+
parameters: tool.paramsSchema,
|
|
13
|
+
execute: (args) => this.callMethod(tool.methodName, args),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.AgentMailToolkit = AgentMailToolkit;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ai-sdk"), exports);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReplyToMessageParams = exports.SendMessageParams = exports.GetAttachmentParams = exports.GetMessageParams = exports.ListMessagesParams = exports.GetThreadParams = exports.ListThreadsParams = exports.CreateInboxParams = exports.GetInboxParams = exports.ListItemsParams = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.ListItemsParams = zod_1.z.object({
|
|
6
|
+
limit: zod_1.z.number().optional().describe('The maximum number of items to return'),
|
|
7
|
+
last_key: zod_1.z.string().optional().describe('The last key to use for pagination'),
|
|
8
|
+
});
|
|
9
|
+
exports.GetInboxParams = zod_1.z.object({
|
|
10
|
+
inbox_id: zod_1.z.string().describe('The ID of the inbox to get'),
|
|
11
|
+
});
|
|
12
|
+
exports.CreateInboxParams = zod_1.z.object({
|
|
13
|
+
username: zod_1.z.string().optional().describe('The username of the inbox to create.'),
|
|
14
|
+
domain: zod_1.z.string().optional().describe('The domain of the inbox to create.'),
|
|
15
|
+
display_name: zod_1.z.string().optional().describe('The display name of the inbox to create.'),
|
|
16
|
+
});
|
|
17
|
+
exports.ListThreadsParams = exports.ListItemsParams.extend({
|
|
18
|
+
inbox_id: zod_1.z.string().describe('The ID of the inbox to list threads for'),
|
|
19
|
+
received: zod_1.z.boolean().optional().describe('Whether to filter by received threads'),
|
|
20
|
+
sent: zod_1.z.boolean().optional().describe('Whether to filter by sent threads'),
|
|
21
|
+
});
|
|
22
|
+
exports.GetThreadParams = zod_1.z.object({
|
|
23
|
+
inbox_id: zod_1.z.string().describe('The ID of the inbox to get the thread for'),
|
|
24
|
+
thread_id: zod_1.z.string().describe('The ID of the thread to get'),
|
|
25
|
+
});
|
|
26
|
+
exports.ListMessagesParams = exports.ListItemsParams.extend({
|
|
27
|
+
inbox_id: zod_1.z.string().describe('The ID of the inbox to list messages for'),
|
|
28
|
+
});
|
|
29
|
+
exports.GetMessageParams = zod_1.z.object({
|
|
30
|
+
inbox_id: zod_1.z.string().describe('The ID of the inbox to get the message for'),
|
|
31
|
+
message_id: zod_1.z.string().describe('The ID of the message to get'),
|
|
32
|
+
});
|
|
33
|
+
exports.GetAttachmentParams = zod_1.z.object({
|
|
34
|
+
inbox_id: zod_1.z.string().describe('The ID of the inbox to get the attachment for'),
|
|
35
|
+
message_id: zod_1.z.string().describe('The ID of the message to get the attachment for'),
|
|
36
|
+
attachment_id: zod_1.z.string().describe('The ID of the attachment to get'),
|
|
37
|
+
});
|
|
38
|
+
exports.SendMessageParams = zod_1.z.object({
|
|
39
|
+
inbox_id: zod_1.z.string().describe('The ID of the inbox to send the message from'),
|
|
40
|
+
to: zod_1.z.array(zod_1.z.string()).describe('The list of recipients'),
|
|
41
|
+
cc: zod_1.z.array(zod_1.z.string()).optional().describe('The list of CC recipients'),
|
|
42
|
+
bcc: zod_1.z.array(zod_1.z.string()).optional().describe('The list of BCC recipients'),
|
|
43
|
+
subject: zod_1.z.string().optional().describe('The subject of the message'),
|
|
44
|
+
text: zod_1.z.string().optional().describe('The plain text body of the message'),
|
|
45
|
+
html: zod_1.z.string().optional().describe('The HTML body of the message'),
|
|
46
|
+
});
|
|
47
|
+
exports.ReplyToMessageParams = zod_1.z.object({
|
|
48
|
+
inbox_id: zod_1.z.string().describe('The inboc ID of the inbox to reply to the message from'),
|
|
49
|
+
message_id: zod_1.z.string().describe('The message ID of the message you wish to reply to'),
|
|
50
|
+
text: zod_1.z.string().optional().describe('The plain text body of the reply'),
|
|
51
|
+
html: zod_1.z.string().optional().describe('The HTML body of the reply'),
|
|
52
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Toolkit = void 0;
|
|
13
|
+
const agentmail_1 = require("agentmail");
|
|
14
|
+
const tools_1 = require("./tools");
|
|
15
|
+
class Toolkit {
|
|
16
|
+
constructor(client) {
|
|
17
|
+
this.client = client;
|
|
18
|
+
this.tools = {};
|
|
19
|
+
if (!this.client)
|
|
20
|
+
this.client = new agentmail_1.AgentMailClient();
|
|
21
|
+
this.tools = tools_1.tools.reduce((acc, tool) => {
|
|
22
|
+
acc[tool.name] = this.buildTool(tool);
|
|
23
|
+
return acc;
|
|
24
|
+
}, {});
|
|
25
|
+
}
|
|
26
|
+
getTools() {
|
|
27
|
+
return this.tools;
|
|
28
|
+
}
|
|
29
|
+
callMethod(methodName, args) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const parts = methodName.split('.');
|
|
32
|
+
const methodKey = parts.pop();
|
|
33
|
+
if (!methodKey)
|
|
34
|
+
throw new Error('Method name empty');
|
|
35
|
+
let parent = this.client;
|
|
36
|
+
for (const part of parts)
|
|
37
|
+
parent = parent[part];
|
|
38
|
+
return yield parent[methodKey].call(parent, args);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.Toolkit = Toolkit;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tools = void 0;
|
|
4
|
+
const schemas_1 = require("./schemas");
|
|
5
|
+
exports.tools = [
|
|
6
|
+
{
|
|
7
|
+
name: 'list_inboxes',
|
|
8
|
+
methodName: 'inboxes.list',
|
|
9
|
+
description: 'List all inboxes',
|
|
10
|
+
paramsSchema: schemas_1.ListItemsParams,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: 'get_inbox',
|
|
14
|
+
methodName: 'inboxes.get',
|
|
15
|
+
description: 'Get an inbox by ID',
|
|
16
|
+
paramsSchema: schemas_1.GetInboxParams,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'create_inbox',
|
|
20
|
+
methodName: 'inboxes.create',
|
|
21
|
+
description: 'Create a new inbox',
|
|
22
|
+
paramsSchema: schemas_1.CreateInboxParams,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'list_threads',
|
|
26
|
+
methodName: 'threads.list',
|
|
27
|
+
description: 'List all threads',
|
|
28
|
+
paramsSchema: schemas_1.ListThreadsParams,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'get_thread',
|
|
32
|
+
methodName: 'threads.get',
|
|
33
|
+
description: 'Get a thread by ID',
|
|
34
|
+
paramsSchema: schemas_1.GetThreadParams,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'list_messages',
|
|
38
|
+
methodName: 'messages.list',
|
|
39
|
+
description: 'List all messages',
|
|
40
|
+
paramsSchema: schemas_1.ListMessagesParams,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'get_message',
|
|
44
|
+
methodName: 'messages.get',
|
|
45
|
+
description: 'Get a message by ID',
|
|
46
|
+
paramsSchema: schemas_1.GetMessageParams,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'get_attachment',
|
|
50
|
+
methodName: 'attachments.get',
|
|
51
|
+
description: 'Get an attachment by ID',
|
|
52
|
+
paramsSchema: schemas_1.GetAttachmentParams,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'send_message',
|
|
56
|
+
methodName: 'messages.send',
|
|
57
|
+
description: 'Send a message',
|
|
58
|
+
paramsSchema: schemas_1.SendMessageParams,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'reply_to_message',
|
|
62
|
+
methodName: 'messages.reply',
|
|
63
|
+
description: 'Reply to a message',
|
|
64
|
+
paramsSchema: schemas_1.ReplyToMessageParams,
|
|
65
|
+
},
|
|
66
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agentmail-toolkit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AgentMail Toolkit",
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/src",
|
|
8
|
+
"README.md",
|
|
9
|
+
"LICENSE"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"lint": "eslint .",
|
|
14
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
15
|
+
},
|
|
16
|
+
"author": "AgentMail",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/agentmail-to/agentmail-toolkit"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"Agents",
|
|
24
|
+
"Email",
|
|
25
|
+
"AgentMail",
|
|
26
|
+
"Toolkit"
|
|
27
|
+
],
|
|
28
|
+
"packageManager": "pnpm@10.6.4",
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@eslint/js": "^9.22.0",
|
|
31
|
+
"@types/node": "^22.13.10",
|
|
32
|
+
"eslint": "^9.22.0",
|
|
33
|
+
"eslint-config-prettier": "^10.1.1",
|
|
34
|
+
"globals": "^16.0.0",
|
|
35
|
+
"prettier": "3.5.3",
|
|
36
|
+
"ts-node": "^10.9.2",
|
|
37
|
+
"typescript": "^5.8.2",
|
|
38
|
+
"typescript-eslint": "^8.26.1"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@ai-sdk/openai": "^1.3.4",
|
|
42
|
+
"agentmail": "^0.0.22",
|
|
43
|
+
"zod": "^3.24.2"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"ai": "^4.2.8"
|
|
47
|
+
}
|
|
48
|
+
}
|