agentmail-cli 0.0.1 → 0.6.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/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # AgentMail CLI
2
+
3
+ The official CLI for the [AgentMail API](https://docs.agentmail.to).
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install -g agentmail-cli
9
+ ```
10
+
11
+ ## Setup
12
+
13
+ ```sh
14
+ export AGENTMAIL_API_KEY=am_us_xxx
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```sh
20
+ agentmail inboxes list
21
+ agentmail inboxes create --display-name "My Inbox"
22
+ agentmail inboxes:messages send --inbox-id inb_xxx --to user@example.com --subject "Hello" --text "Hi"
23
+ agentmail inboxes:threads list --inbox-id inb_xxx
24
+ ```
25
+
26
+ Run `agentmail --help` to see all available commands.
27
+
28
+ ## Documentation
29
+
30
+ [docs.agentmail.to](https://docs.agentmail.to)
Binary file
package/bin/agentmail ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execFileSync } = require("child_process");
4
+ const path = require("path");
5
+
6
+ const ext = process.platform === "win32" ? ".exe" : "";
7
+ const binary = path.join(__dirname, `.agentmail${ext}`);
8
+
9
+ try {
10
+ execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
11
+ } catch (err) {
12
+ if (err.status != null) {
13
+ process.exit(err.status);
14
+ }
15
+ console.error(`Failed to run agentmail: ${err.message}`);
16
+ console.error("Try reinstalling: npm install -g @agentmail/cli");
17
+ process.exit(1);
18
+ }
package/package.json CHANGED
@@ -1,12 +1,27 @@
1
1
  {
2
2
  "name": "agentmail-cli",
3
- "version": "0.0.1",
4
- "description": "Reserved package name",
5
- "main": "index.js",
3
+ "version": "0.6.0",
4
+ "description": "The official CLI for the AgentMail API",
5
+ "bin": {
6
+ "agentmail": "./bin/agentmail"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node scripts/postinstall.js"
10
+ },
11
+ "binaryVersion": "0.6.0",
12
+ "keywords": [
13
+ "agentmail",
14
+ "cli",
15
+ "email",
16
+ "api"
17
+ ],
18
+ "homepage": "https://agentmail.to",
6
19
  "repository": {
7
20
  "type": "git",
8
- "url": ""
21
+ "url": "https://github.com/agentmail-to/agentmail-cli"
9
22
  },
10
- "author": "",
11
- "license": "MIT"
23
+ "license": "Apache-2.0",
24
+ "engines": {
25
+ "node": ">=16"
26
+ }
12
27
  }
@@ -0,0 +1,122 @@
1
+ const { execSync } = require("child_process");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const https = require("https");
5
+ const { createWriteStream } = require("fs");
6
+
7
+ const REPO = "agentmail-to/agentmail-cli";
8
+ const BINARY_NAME = "agentmail";
9
+
10
+ const PLATFORM_MAP = {
11
+ darwin: "macos",
12
+ linux: "linux",
13
+ win32: "windows",
14
+ };
15
+
16
+ const ARCH_MAP = {
17
+ arm64: "arm64",
18
+ x64: "amd64",
19
+ ia32: "386",
20
+ };
21
+
22
+ function getPlatformArch() {
23
+ const platform = PLATFORM_MAP[process.platform];
24
+ const arch = ARCH_MAP[process.arch];
25
+
26
+ if (!platform || !arch) {
27
+ console.error(
28
+ `Unsupported platform: ${process.platform} ${process.arch}`
29
+ );
30
+ process.exit(1);
31
+ }
32
+
33
+ return { platform, arch };
34
+ }
35
+
36
+ function getAssetName(version, platform, arch) {
37
+ const ext = platform === "linux" ? "tar.gz" : "zip";
38
+ return `${BINARY_NAME}_${version}_${platform}_${arch}.${ext}`;
39
+ }
40
+
41
+ function fetch(url) {
42
+ return new Promise((resolve, reject) => {
43
+ https
44
+ .get(url, { headers: { "User-Agent": "agentmail-cli-npm" } }, (res) => {
45
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
46
+ return fetch(res.headers.location).then(resolve).catch(reject);
47
+ }
48
+ if (res.statusCode !== 200) {
49
+ return reject(new Error(`HTTP ${res.statusCode} for ${url}`));
50
+ }
51
+ resolve(res);
52
+ })
53
+ .on("error", reject);
54
+ });
55
+ }
56
+
57
+ async function download(url, dest) {
58
+ const res = await fetch(url);
59
+ return new Promise((resolve, reject) => {
60
+ const file = createWriteStream(dest);
61
+ res.pipe(file);
62
+ file.on("finish", () => file.close(resolve));
63
+ file.on("error", reject);
64
+ });
65
+ }
66
+
67
+ function extract(archive, destDir) {
68
+ if (archive.endsWith(".tar.gz")) {
69
+ execSync(`tar -xzf "${archive}" -C "${destDir}"`, { stdio: "ignore" });
70
+ } else if (archive.endsWith(".zip")) {
71
+ if (process.platform === "win32") {
72
+ execSync(
73
+ `powershell -Command "Expand-Archive -Path '${archive}' -DestinationPath '${destDir}' -Force"`,
74
+ { stdio: "ignore" }
75
+ );
76
+ } else {
77
+ execSync(`unzip -o "${archive}" -d "${destDir}"`, { stdio: "ignore" });
78
+ }
79
+ }
80
+ }
81
+
82
+ async function main() {
83
+ const { platform, arch } = getPlatformArch();
84
+ const pkg = require("../package.json");
85
+ const version = pkg.binaryVersion || pkg.version;
86
+
87
+ const assetName = getAssetName(version, platform, arch);
88
+ const url = `https://github.com/${REPO}/releases/download/v${version}/${assetName}`;
89
+
90
+ const binDir = path.join(__dirname, "..", "bin");
91
+ const tmpDir = path.join(__dirname, "..", ".tmp");
92
+
93
+ fs.mkdirSync(binDir, { recursive: true });
94
+ fs.mkdirSync(tmpDir, { recursive: true });
95
+
96
+ const archivePath = path.join(tmpDir, assetName);
97
+
98
+ console.log(`Downloading ${BINARY_NAME} v${version} for ${platform}/${arch}...`);
99
+
100
+ try {
101
+ await download(url, archivePath);
102
+ } catch (err) {
103
+ console.error(`Failed to download ${url}: ${err.message}`);
104
+ process.exit(1);
105
+ }
106
+
107
+ extract(archivePath, tmpDir);
108
+
109
+ const binaryExt = platform === "windows" ? ".exe" : "";
110
+ const binarySource = path.join(tmpDir, `${BINARY_NAME}${binaryExt}`);
111
+ const binaryDest = path.join(binDir, `.${BINARY_NAME}${binaryExt}`);
112
+
113
+ fs.copyFileSync(binarySource, binaryDest);
114
+ fs.chmodSync(binaryDest, 0o755);
115
+
116
+ // Cleanup
117
+ fs.rmSync(tmpDir, { recursive: true, force: true });
118
+
119
+ console.log(`${BINARY_NAME} v${version} installed successfully.`);
120
+ }
121
+
122
+ main();
package/index.js DELETED
@@ -1,2 +0,0 @@
1
- // Reserved package
2
- module.exports = {};