alaya-mcp 0.0.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 +65 -0
- package/package.json +36 -0
- package/scripts/postinstall.js +82 -0
package/bin/run.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const path = require("path");
|
|
6
|
+
|
|
7
|
+
const PLATFORMS = {
|
|
8
|
+
"darwin-arm64": "@alaya-mcp/cli-darwin-arm64",
|
|
9
|
+
"darwin-x64": "@alaya-mcp/cli-darwin-x64",
|
|
10
|
+
"linux-x64": "@alaya-mcp/cli-linux-x64",
|
|
11
|
+
"win32-x64": "@alaya-mcp/cli-win32-x64",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function getBinaryPath() {
|
|
15
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
16
|
+
const pkg = PLATFORMS[platformKey];
|
|
17
|
+
if (!pkg) {
|
|
18
|
+
console.error(
|
|
19
|
+
`alaya-mcp: unsupported platform ${platformKey}\n` +
|
|
20
|
+
`Supported: ${Object.keys(PLATFORMS).join(", ")}\n` +
|
|
21
|
+
`Build from source: cargo build --release --features "mcp llm"`
|
|
22
|
+
);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const binary = process.platform === "win32" ? "alaya-mcp.exe" : "alaya-mcp";
|
|
27
|
+
|
|
28
|
+
// Try optionalDependencies first
|
|
29
|
+
try {
|
|
30
|
+
const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
|
|
31
|
+
return path.join(pkgDir, binary);
|
|
32
|
+
} catch {
|
|
33
|
+
// pass
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Try postinstall fallback location
|
|
37
|
+
const fallback = path.join(__dirname, "..", "bin", binary);
|
|
38
|
+
try {
|
|
39
|
+
require("fs").accessSync(fallback, require("fs").constants.X_OK);
|
|
40
|
+
return fallback;
|
|
41
|
+
} catch {
|
|
42
|
+
// pass
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.error(
|
|
46
|
+
`alaya-mcp: could not find binary for ${platformKey}\n` +
|
|
47
|
+
`Package ${pkg} is not installed.\n` +
|
|
48
|
+
`Try: npm install alaya-mcp --include=optional\n` +
|
|
49
|
+
`Or build from source: cargo build --release --features "mcp llm"`
|
|
50
|
+
);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const binary = getBinaryPath();
|
|
55
|
+
const result = require("child_process").spawnSync(binary, process.argv.slice(2), {
|
|
56
|
+
stdio: "inherit",
|
|
57
|
+
env: process.env,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (result.error) {
|
|
61
|
+
console.error(`alaya-mcp: failed to start: ${result.error.message}`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
process.exit(result.status ?? 1);
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "alaya-mcp",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Alaya MCP Server — a memory engine for AI agents that remembers, forgets, and learns",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/SecurityRonin/alaya"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/SecurityRonin/alaya",
|
|
11
|
+
"bin": {
|
|
12
|
+
"alaya-mcp": "bin/run.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin/",
|
|
16
|
+
"scripts/",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"optionalDependencies": {
|
|
20
|
+
"@alaya-mcp/cli-linux-x64": "0.0.0",
|
|
21
|
+
"@alaya-mcp/cli-darwin-arm64": "0.0.0",
|
|
22
|
+
"@alaya-mcp/cli-darwin-x64": "0.0.0",
|
|
23
|
+
"@alaya-mcp/cli-win32-x64": "0.0.0"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"postinstall": "node scripts/postinstall.js"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"mcp",
|
|
30
|
+
"memory",
|
|
31
|
+
"ai",
|
|
32
|
+
"agent",
|
|
33
|
+
"alaya",
|
|
34
|
+
"llm"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Postinstall fallback: if the platform-specific optionalDependency was not
|
|
4
|
+
// installed (e.g. --ignore-optional, unsupported package manager), download
|
|
5
|
+
// the binary from the GitHub Release.
|
|
6
|
+
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const https = require("https");
|
|
10
|
+
const { execSync } = require("child_process");
|
|
11
|
+
|
|
12
|
+
const PLATFORMS = {
|
|
13
|
+
"darwin-arm64": { artifact: "alaya-mcp-darwin-arm64", binary: "alaya-mcp", pkg: "@alaya-mcp/cli-darwin-arm64" },
|
|
14
|
+
"darwin-x64": { artifact: "alaya-mcp-darwin-x64", binary: "alaya-mcp", pkg: "@alaya-mcp/cli-darwin-x64" },
|
|
15
|
+
"linux-x64": { artifact: "alaya-mcp-linux-x64", binary: "alaya-mcp", pkg: "@alaya-mcp/cli-linux-x64" },
|
|
16
|
+
"win32-x64": { artifact: "alaya-mcp-win32-x64", binary: "alaya-mcp.exe", pkg: "@alaya-mcp/cli-win32-x64" },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function main() {
|
|
20
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
21
|
+
const platform = PLATFORMS[platformKey];
|
|
22
|
+
if (!platform) {
|
|
23
|
+
// Unsupported platform — run.js will report a clear error
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Check if optionalDependency already installed
|
|
28
|
+
try {
|
|
29
|
+
require.resolve(`${platform.pkg}/package.json`);
|
|
30
|
+
return; // Binary available via optionalDependencies
|
|
31
|
+
} catch {
|
|
32
|
+
// Not installed — download from GitHub Release
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const pkg = require("../package.json");
|
|
36
|
+
const version = pkg.version;
|
|
37
|
+
const isWindows = process.platform === "win32";
|
|
38
|
+
const ext = isWindows ? "zip" : "tar.gz";
|
|
39
|
+
const url = `https://github.com/SecurityRonin/alaya/releases/download/v${version}/${platform.artifact}.${ext}`;
|
|
40
|
+
const binDir = path.join(__dirname, "..", "bin");
|
|
41
|
+
const dest = path.join(binDir, platform.binary);
|
|
42
|
+
|
|
43
|
+
// Skip if already downloaded
|
|
44
|
+
if (fs.existsSync(dest)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
console.log(`alaya-mcp: downloading binary for ${platformKey}...`);
|
|
49
|
+
|
|
50
|
+
const tmpFile = path.join(binDir, `download.${ext}`);
|
|
51
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
// Use curl/wget for simplicity and redirect handling
|
|
55
|
+
try {
|
|
56
|
+
execSync(`curl -fsSL "${url}" -o "${tmpFile}"`, { stdio: "pipe" });
|
|
57
|
+
} catch {
|
|
58
|
+
execSync(`wget -q "${url}" -O "${tmpFile}"`, { stdio: "pipe" });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Extract
|
|
62
|
+
if (isWindows) {
|
|
63
|
+
execSync(`powershell -Command "Expand-Archive -Path '${tmpFile}' -DestinationPath '${binDir}' -Force"`, { stdio: "pipe" });
|
|
64
|
+
} else {
|
|
65
|
+
execSync(`tar xzf "${tmpFile}" -C "${binDir}"`, { stdio: "pipe" });
|
|
66
|
+
fs.chmodSync(dest, 0o755);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Cleanup
|
|
70
|
+
fs.unlinkSync(tmpFile);
|
|
71
|
+
console.log(`alaya-mcp: binary installed successfully`);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
console.warn(
|
|
74
|
+
`alaya-mcp: failed to download binary (${err.message})\n` +
|
|
75
|
+
`You can build from source: cargo build --release --features "mcp llm"`
|
|
76
|
+
);
|
|
77
|
+
// Clean up partial downloads
|
|
78
|
+
try { fs.unlinkSync(tmpFile); } catch {}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
main();
|