@box0/cli 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.
Files changed (3) hide show
  1. package/bin/b0.js +30 -0
  2. package/install.js +92 -0
  3. package/package.json +20 -0
package/bin/b0.js ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execFileSync } = require("child_process");
4
+ const path = require("path");
5
+ const os = require("os");
6
+ const fs = require("fs");
7
+
8
+ const platform = os.platform();
9
+ const arch = os.arch();
10
+
11
+ const BINARY_NAME = platform === "win32" ? "b0.exe" : "b0";
12
+ const binaryPath = path.join(__dirname, BINARY_NAME);
13
+
14
+ if (!fs.existsSync(binaryPath)) {
15
+ console.error(
16
+ `Box0 binary not found at ${binaryPath}\n` +
17
+ `Run 'npm install' or 'npx box0' to download it.\n` +
18
+ `Platform: ${platform}-${arch}`
19
+ );
20
+ process.exit(1);
21
+ }
22
+
23
+ try {
24
+ execFileSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
25
+ } catch (e) {
26
+ if (e.status !== undefined) {
27
+ process.exit(e.status);
28
+ }
29
+ throw e;
30
+ }
package/install.js ADDED
@@ -0,0 +1,92 @@
1
+ const https = require("https");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const os = require("os");
5
+ const { execSync } = require("child_process");
6
+
7
+ const VERSION = "0.1.0";
8
+ const REPO = "risingwavelabs/box0";
9
+
10
+ function getPlatformKey() {
11
+ const platform = os.platform();
12
+ const arch = os.arch();
13
+
14
+ const map = {
15
+ "darwin-arm64": "darwin-arm64",
16
+ "darwin-x64": "darwin-x64",
17
+ "linux-x64": "linux-x64",
18
+ "linux-arm64": "linux-arm64",
19
+ "win32-x64": "windows-x64",
20
+ };
21
+
22
+ const key = `${platform}-${arch}`;
23
+ if (!map[key]) {
24
+ console.error(`Unsupported platform: ${key}`);
25
+ console.error(`Supported: ${Object.keys(map).join(", ")}`);
26
+ process.exit(1);
27
+ }
28
+ return map[key];
29
+ }
30
+
31
+ function getBinaryName() {
32
+ return os.platform() === "win32" ? "b0.exe" : "b0";
33
+ }
34
+
35
+ async function download(url, dest) {
36
+ return new Promise((resolve, reject) => {
37
+ const follow = (url) => {
38
+ https.get(url, (res) => {
39
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
40
+ follow(res.headers.location);
41
+ return;
42
+ }
43
+ if (res.statusCode !== 200) {
44
+ reject(new Error(`Download failed: HTTP ${res.statusCode} from ${url}`));
45
+ return;
46
+ }
47
+ const file = fs.createWriteStream(dest);
48
+ res.pipe(file);
49
+ file.on("finish", () => {
50
+ file.close();
51
+ resolve();
52
+ });
53
+ }).on("error", reject);
54
+ };
55
+ follow(url);
56
+ });
57
+ }
58
+
59
+ async function main() {
60
+ const platformKey = getPlatformKey();
61
+ const binaryName = getBinaryName();
62
+ const destPath = path.join(__dirname, "bin", binaryName);
63
+
64
+ // Skip if binary already exists
65
+ if (fs.existsSync(destPath)) {
66
+ return;
67
+ }
68
+
69
+ const ext = os.platform() === "win32" ? ".exe" : "";
70
+ const assetName = `b0-${platformKey}${ext}`;
71
+ const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${assetName}`;
72
+
73
+ console.log(`Downloading Box0 v${VERSION} for ${platformKey}...`);
74
+
75
+ try {
76
+ await download(url, destPath);
77
+ if (os.platform() !== "win32") {
78
+ fs.chmodSync(destPath, 0o755);
79
+ }
80
+ console.log("Box0 installed successfully.");
81
+ } catch (e) {
82
+ console.error(`Failed to download Box0: ${e.message}`);
83
+ console.error(`URL: ${url}`);
84
+ console.error(`\nYou can build from source instead:`);
85
+ console.error(` git clone https://github.com/${REPO}.git`);
86
+ console.error(` cd box0 && cargo build --release`);
87
+ // Don't exit with error - let npm install succeed
88
+ // The binary wrapper will show a helpful error when run
89
+ }
90
+ }
91
+
92
+ main();
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@box0/cli",
3
+ "version": "0.1.0",
4
+ "description": "Multi-agent platform for AI agents",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/risingwavelabs/box0"
9
+ },
10
+ "bin": {
11
+ "b0": "bin/b0.js"
12
+ },
13
+ "scripts": {
14
+ "postinstall": "node install.js"
15
+ },
16
+ "files": [
17
+ "bin/",
18
+ "install.js"
19
+ ]
20
+ }