@genesis-agent/channel-slack 0.5.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/bin/run.js +7 -0
- package/install.js +115 -0
- package/package.json +33 -0
package/bin/run.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execFileSync } = require("child_process");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
5
|
+
const bin = path.join(__dirname, `channel-slack${ext}`);
|
|
6
|
+
try { execFileSync(bin, process.argv.slice(2), { stdio: "inherit" }); }
|
|
7
|
+
catch (e) { process.exit(e.status || 1); }
|
package/install.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const https = require("https");
|
|
8
|
+
const { execSync } = require("child_process");
|
|
9
|
+
|
|
10
|
+
const VERSION = require("./package.json").version;
|
|
11
|
+
const REPO = "deadraid/genesis";
|
|
12
|
+
|
|
13
|
+
const PLATFORM_MAP = {
|
|
14
|
+
"darwin-arm64": "channel-slack-macos-aarch64",
|
|
15
|
+
"darwin-x64": "channel-slack-macos-x86_64",
|
|
16
|
+
"linux-x64": "channel-slack-linux-x86_64",
|
|
17
|
+
"linux-arm64": "channel-slack-linux-aarch64",
|
|
18
|
+
"win32-x64": "channel-slack-windows-x86_64",
|
|
19
|
+
"win32-arm64": "channel-slack-windows-aarch64",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function getPlatformKey() {
|
|
23
|
+
const platform = process.platform;
|
|
24
|
+
const arch = process.arch;
|
|
25
|
+
const key = `${platform}-${arch}`;
|
|
26
|
+
|
|
27
|
+
if (!PLATFORM_MAP[key]) {
|
|
28
|
+
console.error(`Unsupported platform: ${key}`);
|
|
29
|
+
console.error(`Supported: ${Object.keys(PLATFORM_MAP).join(", ")}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return key;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getBinaryName(platformKey) {
|
|
37
|
+
const name = PLATFORM_MAP[platformKey];
|
|
38
|
+
return platformKey.startsWith("win32") ? `${name}.exe` : name;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getDownloadUrl(binaryName) {
|
|
42
|
+
return `https://github.com/${REPO}/releases/download/v${VERSION}/${binaryName}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function download(url, dest) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
const follow = (url, redirects) => {
|
|
48
|
+
if (redirects > 5) return reject(new Error("Too many redirects"));
|
|
49
|
+
|
|
50
|
+
https
|
|
51
|
+
.get(url, (res) => {
|
|
52
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
53
|
+
return follow(res.headers.location, redirects + 1);
|
|
54
|
+
}
|
|
55
|
+
if (res.statusCode !== 200) {
|
|
56
|
+
return reject(new Error(`Download failed: HTTP ${res.statusCode}`));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const file = fs.createWriteStream(dest);
|
|
60
|
+
res.pipe(file);
|
|
61
|
+
file.on("finish", () => {
|
|
62
|
+
file.close();
|
|
63
|
+
resolve();
|
|
64
|
+
});
|
|
65
|
+
file.on("error", reject);
|
|
66
|
+
})
|
|
67
|
+
.on("error", reject);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
follow(url, 0);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function main() {
|
|
75
|
+
const platformKey = getPlatformKey();
|
|
76
|
+
const binaryName = getBinaryName(platformKey);
|
|
77
|
+
const url = getDownloadUrl(binaryName);
|
|
78
|
+
const binDir = path.join(__dirname, "bin");
|
|
79
|
+
const destName = process.platform === "win32" ? "channel-slack.exe" : "channel-slack";
|
|
80
|
+
const dest = path.join(binDir, destName);
|
|
81
|
+
|
|
82
|
+
if (fs.existsSync(dest)) {
|
|
83
|
+
try {
|
|
84
|
+
const current = execSync(`"${dest}" --version`, { encoding: "utf-8" }).trim();
|
|
85
|
+
if (current === VERSION || current === `v${VERSION}`) {
|
|
86
|
+
console.log(`channel-slack v${VERSION} already installed, skipping download.`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
console.log(`Updating channel-slack ${current} → v${VERSION}...`);
|
|
90
|
+
fs.unlinkSync(dest);
|
|
91
|
+
} catch {
|
|
92
|
+
fs.unlinkSync(dest);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
97
|
+
|
|
98
|
+
console.log(`Downloading channel-slack v${VERSION} for ${platformKey}...`);
|
|
99
|
+
console.log(` ${url}`);
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
await download(url, dest);
|
|
103
|
+
if (process.platform !== "win32") {
|
|
104
|
+
fs.chmodSync(dest, 0o755);
|
|
105
|
+
}
|
|
106
|
+
console.log("channel-slack installed successfully.");
|
|
107
|
+
} catch (err) {
|
|
108
|
+
console.error(`Failed to download channel-slack: ${err.message}`);
|
|
109
|
+
console.error("You can download manually from:");
|
|
110
|
+
console.error(` https://github.com/${REPO}/releases/tag/v${VERSION}`);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@genesis-agent/channel-slack",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Slack channel adapter for Genesis — DMs, file uploads, threads",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/deadraid/genesis.git",
|
|
9
|
+
"directory": "channels/slack"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"channel-slack": "bin/run.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"postinstall": "node install.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin/",
|
|
19
|
+
"install.js"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=16"
|
|
23
|
+
},
|
|
24
|
+
"os": ["darwin", "linux", "win32"],
|
|
25
|
+
"cpu": ["x64", "arm64"],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"genesis",
|
|
28
|
+
"channel",
|
|
29
|
+
"slack",
|
|
30
|
+
"ai",
|
|
31
|
+
"agent"
|
|
32
|
+
]
|
|
33
|
+
}
|