agent-telegram 0.2.0 → 0.3.1
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 +2 -2
- package/bin/run.js +36 -8
- package/binaries/agent-telegram-darwin-amd64 +0 -0
- package/binaries/agent-telegram-darwin-arm64 +0 -0
- package/binaries/agent-telegram-linux-amd64 +0 -0
- package/binaries/agent-telegram-linux-arm64 +0 -0
- package/binaries/agent-telegram-windows-amd64.exe +0 -0
- package/binaries/agent-telegram-windows-arm64.exe +0 -0
- package/package.json +2 -5
- package/scripts/build-all.sh +0 -39
- package/scripts/install.js +0 -171
package/README.md
CHANGED
|
@@ -11,7 +11,6 @@ By Aslan Dukaev [X](https://x.com/dukaev) ·[Telegram](https://t.me/dukaev)
|
|
|
11
11
|
```bash
|
|
12
12
|
bun add -g agent-telegram
|
|
13
13
|
npm install -g agent-telegram
|
|
14
|
-
pnpm add -g agent-telegram
|
|
15
14
|
```
|
|
16
15
|
|
|
17
16
|
### From Source
|
|
@@ -25,7 +24,6 @@ go build -o agent-telegram .
|
|
|
25
24
|
## Quick Start
|
|
26
25
|
|
|
27
26
|
```bash
|
|
28
|
-
agent-telegram serve # Start IPC server (runs in background)
|
|
29
27
|
agent-telegram login # Interactive login
|
|
30
28
|
agent-telegram my-info # Get your profile
|
|
31
29
|
agent-telegram chat list # List all chats
|
|
@@ -42,6 +40,8 @@ agent-telegram stop # Stop server
|
|
|
42
40
|
agent-telegram login # Interactive login
|
|
43
41
|
agent-telegram logout # Logout and clear session
|
|
44
42
|
agent-telegram my-info # Get your profile information
|
|
43
|
+
agent-telegram llms-txt # Generate full CLI documentation for LLMs
|
|
44
|
+
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
### Send Messages
|
package/bin/run.js
CHANGED
|
@@ -2,9 +2,41 @@
|
|
|
2
2
|
|
|
3
3
|
const { spawn } = require("child_process");
|
|
4
4
|
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
|
|
7
|
+
const PLATFORM_MAP = {
|
|
8
|
+
darwin: "darwin",
|
|
9
|
+
linux: "linux",
|
|
10
|
+
win32: "windows",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const ARCH_MAP = {
|
|
14
|
+
x64: "amd64",
|
|
15
|
+
arm64: "arm64",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function getBinaryPath() {
|
|
19
|
+
const platform = PLATFORM_MAP[process.platform];
|
|
20
|
+
const arch = ARCH_MAP[process.arch];
|
|
21
|
+
|
|
22
|
+
if (!platform || !arch) {
|
|
23
|
+
console.error(`Unsupported platform: ${process.platform}-${process.arch}`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const ext = platform === "windows" ? ".exe" : "";
|
|
28
|
+
const binaryName = `agent-telegram-${platform}-${arch}${ext}`;
|
|
29
|
+
|
|
30
|
+
return path.join(__dirname, "..", "binaries", binaryName);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const binaryPath = getBinaryPath();
|
|
34
|
+
|
|
35
|
+
if (!fs.existsSync(binaryPath)) {
|
|
36
|
+
console.error(`Binary not found: ${binaryPath}`);
|
|
37
|
+
console.error(`Platform: ${process.platform}, Arch: ${process.arch}`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
8
40
|
|
|
9
41
|
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
10
42
|
stdio: "inherit",
|
|
@@ -12,12 +44,8 @@ const child = spawn(binaryPath, process.argv.slice(2), {
|
|
|
12
44
|
});
|
|
13
45
|
|
|
14
46
|
child.on("error", (err) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
console.error("Run 'npm run postinstall' or build from source");
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
throw err;
|
|
47
|
+
console.error(`Failed to start: ${err.message}`);
|
|
48
|
+
process.exit(1);
|
|
21
49
|
});
|
|
22
50
|
|
|
23
51
|
child.on("exit", (code) => {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-telegram",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Telegram IPC agent CLI - interact with Telegram via command line",
|
|
5
5
|
"bin": {
|
|
6
6
|
"agent-telegram": "./bin/run.js"
|
|
7
7
|
},
|
|
8
|
-
"scripts": {
|
|
9
|
-
"postinstall": "node ./scripts/install.js"
|
|
10
|
-
},
|
|
11
8
|
"files": [
|
|
12
9
|
"bin/",
|
|
13
|
-
"
|
|
10
|
+
"binaries/"
|
|
14
11
|
],
|
|
15
12
|
"keywords": [
|
|
16
13
|
"telegram",
|
package/scripts/build-all.sh
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Build binaries for all supported platforms
|
|
4
|
-
# Run from project root: ./scripts/build-all.sh
|
|
5
|
-
|
|
6
|
-
set -e
|
|
7
|
-
|
|
8
|
-
VERSION=${1:-$(node -p "require('./package.json').version")}
|
|
9
|
-
OUTPUT_DIR="dist"
|
|
10
|
-
BINARY_NAME="agent-telegram"
|
|
11
|
-
|
|
12
|
-
# Platforms to build for
|
|
13
|
-
PLATFORMS=(
|
|
14
|
-
"darwin/amd64"
|
|
15
|
-
"darwin/arm64"
|
|
16
|
-
"linux/amd64"
|
|
17
|
-
"linux/arm64"
|
|
18
|
-
"windows/amd64"
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
echo "Building ${BINARY_NAME} v${VERSION}..."
|
|
22
|
-
mkdir -p "${OUTPUT_DIR}"
|
|
23
|
-
|
|
24
|
-
for PLATFORM in "${PLATFORMS[@]}"; do
|
|
25
|
-
GOOS="${PLATFORM%/*}"
|
|
26
|
-
GOARCH="${PLATFORM#*/}"
|
|
27
|
-
|
|
28
|
-
OUTPUT="${OUTPUT_DIR}/${BINARY_NAME}-${GOOS}-${GOARCH}"
|
|
29
|
-
if [ "$GOOS" = "windows" ]; then
|
|
30
|
-
OUTPUT="${OUTPUT}.exe"
|
|
31
|
-
fi
|
|
32
|
-
|
|
33
|
-
echo "Building ${GOOS}/${GOARCH}..."
|
|
34
|
-
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w -X main.version=${VERSION}" -o "$OUTPUT" .
|
|
35
|
-
done
|
|
36
|
-
|
|
37
|
-
echo ""
|
|
38
|
-
echo "Built binaries:"
|
|
39
|
-
ls -lh "${OUTPUT_DIR}/"
|
package/scripts/install.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const https = require("https");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const { execSync } = require("child_process");
|
|
7
|
-
const zlib = require("zlib");
|
|
8
|
-
|
|
9
|
-
const PACKAGE = require("../package.json");
|
|
10
|
-
const BINARY_NAME = "agent-telegram";
|
|
11
|
-
const REPO = "dukaev/agent-telegram";
|
|
12
|
-
|
|
13
|
-
// Map Node.js platform/arch to Go GOOS/GOARCH
|
|
14
|
-
const PLATFORM_MAP = {
|
|
15
|
-
darwin: "darwin",
|
|
16
|
-
linux: "linux",
|
|
17
|
-
win32: "windows",
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const ARCH_MAP = {
|
|
21
|
-
x64: "amd64",
|
|
22
|
-
arm64: "arm64",
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
function getPlatform() {
|
|
26
|
-
const platform = PLATFORM_MAP[process.platform];
|
|
27
|
-
const arch = ARCH_MAP[process.arch];
|
|
28
|
-
|
|
29
|
-
if (!platform || !arch) {
|
|
30
|
-
throw new Error(
|
|
31
|
-
`Unsupported platform: ${process.platform}-${process.arch}`
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return { platform, arch };
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getBinaryName(platform) {
|
|
39
|
-
return platform === "windows" ? `${BINARY_NAME}.exe` : BINARY_NAME;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function getDownloadUrl(version, platform, arch) {
|
|
43
|
-
// GoReleaser archive format: agent-telegram_0.1.0_darwin_arm64.tar.gz
|
|
44
|
-
const ext = platform === "windows" ? "zip" : "tar.gz";
|
|
45
|
-
return `https://github.com/${REPO}/releases/download/v${version}/${BINARY_NAME}_${version}_${platform}_${arch}.${ext}`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function fetch(url) {
|
|
49
|
-
return new Promise((resolve, reject) => {
|
|
50
|
-
const request = (url) => {
|
|
51
|
-
https
|
|
52
|
-
.get(url, (response) => {
|
|
53
|
-
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
54
|
-
request(response.headers.location);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (response.statusCode !== 200) {
|
|
58
|
-
reject(new Error(`HTTP ${response.statusCode}: ${url}`));
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
resolve(response);
|
|
62
|
-
})
|
|
63
|
-
.on("error", reject);
|
|
64
|
-
};
|
|
65
|
-
request(url);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function downloadAndExtract(url, destDir, binaryName) {
|
|
70
|
-
console.log(`Downloading from ${url}...`);
|
|
71
|
-
|
|
72
|
-
const response = await fetch(url);
|
|
73
|
-
const chunks = [];
|
|
74
|
-
|
|
75
|
-
await new Promise((resolve, reject) => {
|
|
76
|
-
response.on("data", (chunk) => chunks.push(chunk));
|
|
77
|
-
response.on("end", resolve);
|
|
78
|
-
response.on("error", reject);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const buffer = Buffer.concat(chunks);
|
|
82
|
-
|
|
83
|
-
if (url.endsWith(".tar.gz")) {
|
|
84
|
-
// Extract tar.gz using tar command
|
|
85
|
-
const archivePath = path.join(destDir, "archive.tar.gz");
|
|
86
|
-
fs.writeFileSync(archivePath, buffer);
|
|
87
|
-
execSync(`tar -xzf "${archivePath}" -C "${destDir}"`, { stdio: "pipe" });
|
|
88
|
-
fs.unlinkSync(archivePath);
|
|
89
|
-
} else if (url.endsWith(".zip")) {
|
|
90
|
-
// For Windows zip files
|
|
91
|
-
const archivePath = path.join(destDir, "archive.zip");
|
|
92
|
-
fs.writeFileSync(archivePath, buffer);
|
|
93
|
-
try {
|
|
94
|
-
execSync(`unzip -o "${archivePath}" -d "${destDir}"`, { stdio: "pipe" });
|
|
95
|
-
} catch {
|
|
96
|
-
// Try PowerShell on Windows
|
|
97
|
-
execSync(
|
|
98
|
-
`powershell -command "Expand-Archive -Path '${archivePath}' -DestinationPath '${destDir}' -Force"`,
|
|
99
|
-
{ stdio: "pipe" }
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
fs.unlinkSync(archivePath);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Find and move binary to bin directory
|
|
106
|
-
const extractedBinary = findBinary(destDir, binaryName);
|
|
107
|
-
if (extractedBinary) {
|
|
108
|
-
const finalPath = path.join(destDir, binaryName);
|
|
109
|
-
if (extractedBinary !== finalPath) {
|
|
110
|
-
fs.renameSync(extractedBinary, finalPath);
|
|
111
|
-
}
|
|
112
|
-
fs.chmodSync(finalPath, 0o755);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Clean up extra files from archive
|
|
116
|
-
const keepFiles = [binaryName, "run.js"];
|
|
117
|
-
for (const file of fs.readdirSync(destDir)) {
|
|
118
|
-
if (!keepFiles.includes(file)) {
|
|
119
|
-
const filePath = path.join(destDir, file);
|
|
120
|
-
const stat = fs.statSync(filePath);
|
|
121
|
-
if (stat.isFile() && !file.endsWith(".js")) {
|
|
122
|
-
// Keep JS files, remove others like LICENSE, README
|
|
123
|
-
fs.unlinkSync(filePath);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function findBinary(dir, binaryName) {
|
|
130
|
-
const files = fs.readdirSync(dir);
|
|
131
|
-
for (const file of files) {
|
|
132
|
-
const filePath = path.join(dir, file);
|
|
133
|
-
const stat = fs.statSync(filePath);
|
|
134
|
-
if (stat.isDirectory()) {
|
|
135
|
-
const found = findBinary(filePath, binaryName);
|
|
136
|
-
if (found) return found;
|
|
137
|
-
} else if (file === binaryName) {
|
|
138
|
-
return filePath;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async function main() {
|
|
145
|
-
const binDir = path.join(__dirname, "..", "bin");
|
|
146
|
-
const { platform, arch } = getPlatform();
|
|
147
|
-
const binaryName = getBinaryName(platform);
|
|
148
|
-
const binaryPath = path.join(binDir, binaryName);
|
|
149
|
-
|
|
150
|
-
// Skip if binary already exists
|
|
151
|
-
if (fs.existsSync(binaryPath)) {
|
|
152
|
-
console.log(`Binary already exists at ${binaryPath}`);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const url = getDownloadUrl(PACKAGE.version, platform, arch);
|
|
157
|
-
|
|
158
|
-
try {
|
|
159
|
-
await downloadAndExtract(url, binDir, binaryName);
|
|
160
|
-
console.log(`Successfully installed ${BINARY_NAME} v${PACKAGE.version}`);
|
|
161
|
-
} catch (error) {
|
|
162
|
-
console.error(`Failed to download binary: ${error.message}`);
|
|
163
|
-
console.error("");
|
|
164
|
-
console.error("Manual installation options:");
|
|
165
|
-
console.error(` 1. Download from: https://github.com/${REPO}/releases`);
|
|
166
|
-
console.error(" 2. Build from source: go build -o bin/agent-telegram .");
|
|
167
|
-
process.exit(1);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
main();
|