@anona-labs/anona-compute 0.0.0-stage → 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.
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ // Shim: execs the real anona-compute binary that install.js downloaded next to this file.
3
+ "use strict";
4
+
5
+ const path = require("node:path");
6
+ const { spawnSync } = require("node:child_process");
7
+
8
+ const exeName = process.platform === "win32" ? "anona-compute.exe" : "anona-compute-bin";
9
+ const target = path.join(__dirname, exeName);
10
+
11
+ const result = spawnSync(target, process.argv.slice(2), { stdio: "inherit" });
12
+ if (result.error) {
13
+ if (result.error.code === "ENOENT") {
14
+ console.error(
15
+ "anona-compute binary not found; reinstall the package (npm install -g @anonalabs/anona-compute)."
16
+ );
17
+ } else {
18
+ console.error(result.error.message);
19
+ }
20
+ process.exit(1);
21
+ }
22
+ process.exit(result.status === null ? 1 : result.status);
package/install.js ADDED
@@ -0,0 +1,107 @@
1
+ // postinstall: downloads the anona-compute release binary matching this
2
+ // package's version and this machine's OS/arch from GitHub Releases,
3
+ // verifies it against the release's checksums.txt, and drops it next to
4
+ // bin/anona-compute (the JS shim that execs it).
5
+ "use strict";
6
+
7
+ const fs = require("node:fs");
8
+ const os = require("node:os");
9
+ const path = require("node:path");
10
+ const https = require("node:https");
11
+ const crypto = require("node:crypto");
12
+ const { spawnSync } = require("node:child_process");
13
+
14
+ const pkg = require("./package.json");
15
+
16
+ const PLATFORMS = { linux: "linux", darwin: "darwin", win32: "windows" };
17
+ const ARCHES = { x64: "amd64", arm64: "arm64" };
18
+
19
+ function fail(message) {
20
+ console.error(`@anonalabs/anona-compute: ${message}`);
21
+ process.exit(1);
22
+ }
23
+
24
+ function download(url, destPath, redirectsLeft = 5) {
25
+ return new Promise((resolve, reject) => {
26
+ const file = fs.createWriteStream(destPath);
27
+ https
28
+ .get(url, { headers: { "User-Agent": "anona-compute-npm-installer" } }, (res) => {
29
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
30
+ file.close();
31
+ fs.unlinkSync(destPath);
32
+ if (redirectsLeft <= 0) return reject(new Error("too many redirects"));
33
+ return resolve(download(res.headers.location, destPath, redirectsLeft - 1));
34
+ }
35
+ if (res.statusCode !== 200) {
36
+ file.close();
37
+ return reject(new Error(`GET ${url} -> ${res.statusCode}`));
38
+ }
39
+ res.pipe(file);
40
+ file.on("finish", () => file.close(resolve));
41
+ })
42
+ .on("error", reject);
43
+ });
44
+ }
45
+
46
+ async function fetchText(url) {
47
+ const tmp = path.join(os.tmpdir(), `anona-compute-${crypto.randomUUID()}.txt`);
48
+ await download(url, tmp);
49
+ const text = fs.readFileSync(tmp, "utf8");
50
+ fs.unlinkSync(tmp);
51
+ return text;
52
+ }
53
+
54
+ function sha256File(filePath) {
55
+ const hash = crypto.createHash("sha256");
56
+ hash.update(fs.readFileSync(filePath));
57
+ return hash.digest("hex");
58
+ }
59
+
60
+ async function main() {
61
+ const goos = PLATFORMS[process.platform];
62
+ const goarch = ARCHES[process.arch];
63
+ if (!goos || !goarch) {
64
+ fail(`unsupported platform ${process.platform}/${process.arch}`);
65
+ }
66
+
67
+ const version = pkg.version;
68
+ const base = `https://github.com/anonalabs/Anona-Compute/releases/download/v${version}`;
69
+ const ext = goos === "windows" ? "zip" : "tar.gz";
70
+ const archiveName = `anona-compute_${version}_${goos}_${goarch}.${ext}`;
71
+ const archiveUrl = `${base}/${archiveName}`;
72
+ const binDir = path.join(__dirname, "bin");
73
+ const archivePath = path.join(os.tmpdir(), `${archiveName}-${crypto.randomUUID()}`);
74
+
75
+ console.log(`@anonalabs/anona-compute: downloading ${archiveName}`);
76
+ await download(archiveUrl, archivePath);
77
+
78
+ const checksums = await fetchText(`${base}/checksums.txt`);
79
+ const line = checksums.split("\n").find((l) => l.endsWith(archiveName));
80
+ if (!line) fail(`checksums.txt has no entry for ${archiveName}`);
81
+ const expected = line.split(/\s+/)[0];
82
+ const actual = sha256File(archivePath);
83
+ if (expected !== actual) {
84
+ fs.unlinkSync(archivePath);
85
+ fail(`checksum mismatch for ${archiveName}: expected ${expected}, got ${actual}`);
86
+ }
87
+
88
+ const finalName = goos === "windows" ? "anona-compute.exe" : "anona-compute-bin";
89
+ if (goos === "windows") {
90
+ const result = spawnSync("powershell.exe", [
91
+ "-NoProfile",
92
+ "-Command",
93
+ `Expand-Archive -LiteralPath '${archivePath}' -DestinationPath '${binDir}' -Force`,
94
+ ]);
95
+ if (result.status !== 0) fail(`Expand-Archive failed: ${result.stderr}`);
96
+ } else {
97
+ const result = spawnSync("tar", ["-xzf", archivePath, "-C", binDir, "anona-compute"]);
98
+ if (result.status !== 0) fail(`tar extraction failed: ${result.stderr}`);
99
+ fs.renameSync(path.join(binDir, "anona-compute"), path.join(binDir, finalName));
100
+ }
101
+
102
+ fs.unlinkSync(archivePath);
103
+ fs.chmodSync(path.join(binDir, finalName), 0o755);
104
+ console.log(`@anonalabs/anona-compute: installed ${finalName}`);
105
+ }
106
+
107
+ main().catch((err) => fail(err.message));
package/package.json CHANGED
@@ -1,6 +1,30 @@
1
1
  {
2
2
  "name": "@anona-labs/anona-compute",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Anona Compute CLI and MCP server",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/anonalabs/Anona-Compute.git",
9
+ "directory": "npm/anona-compute"
10
+ },
11
+ "bin": {
12
+ "anona-compute": "bin/anona-compute"
13
+ },
14
+ "files": [
15
+ "bin/anona-compute",
16
+ "install.js"
17
+ ],
18
+ "scripts": {
19
+ "postinstall": "node install.js"
20
+ },
21
+ "os": [
22
+ "darwin",
23
+ "linux",
24
+ "win32"
25
+ ],
26
+ "cpu": [
27
+ "x64",
28
+ "arm64"
29
+ ]
30
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.