@beeos-ai/cli 0.1.2

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/README.md +49 -0
  2. package/bin/beeos.js +161 -0
  3. package/package.json +35 -0
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # BeeOS CLI
2
+
3
+ Run AI agents from your desktop with a single command.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @beeos-ai/cli
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ # Start an agent (downloads automatically on first run)
15
+ beeos start openclaw
16
+
17
+ # Check running agents
18
+ beeos status openclaw
19
+
20
+ # Update an agent to the latest version
21
+ beeos update openclaw
22
+
23
+ # Stop a running agent
24
+ beeos stop openclaw
25
+ ```
26
+
27
+ ## How It Works
28
+
29
+ BeeOS CLI downloads and manages AI agent binaries on your machine. When you run `beeos start`, the CLI:
30
+
31
+ 1. Downloads the agent binary (if not already installed)
32
+ 2. Generates a secure Ed25519 identity for your device
33
+ 3. Connects to the BeeOS platform and pairs the agent with your account
34
+ 4. Launches the agent in the background
35
+
36
+ ## Requirements
37
+
38
+ - **Node.js** 18 or later
39
+ - **macOS** (Apple Silicon / Intel), **Linux** (x64 / ARM64), or **Windows** (x64)
40
+
41
+ ## Links
42
+
43
+ - **Website**: [https://beeos.ai](https://beeos.ai)
44
+ - **Dashboard**: [https://app.beeos.ai](https://app.beeos.ai)
45
+ - **GitHub**: [https://github.com/beeos-ai/beeos](https://github.com/beeos-ai/beeos)
46
+
47
+ ## License
48
+
49
+ MIT
package/bin/beeos.js ADDED
@@ -0,0 +1,161 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync, execFileSync } = require("child_process");
4
+ const path = require("path");
5
+ const fs = require("fs");
6
+ const os = require("os");
7
+ const zlib = require("zlib");
8
+
9
+ const PLATFORMS = {
10
+ "darwin-arm64": "@beeos-ai/cli-darwin-arm64",
11
+ "darwin-x64": "@beeos-ai/cli-darwin-x64",
12
+ "linux-x64": "@beeos-ai/cli-linux-x64-gnu",
13
+ "linux-arm64": "@beeos-ai/cli-linux-arm64-gnu",
14
+ "win32-x64": "@beeos-ai/cli-win32-x64-msvc",
15
+ };
16
+
17
+ const VERSION = require("../package.json").version;
18
+
19
+ function getPlatformKey() {
20
+ return process.platform + "-" + process.arch;
21
+ }
22
+
23
+ function getBinName() {
24
+ return process.platform === "win32" ? "beeos.exe" : "beeos";
25
+ }
26
+
27
+ function tryResolve() {
28
+ var key = getPlatformKey();
29
+ var pkg = PLATFORMS[key];
30
+ if (!pkg) return null;
31
+ try {
32
+ return require.resolve(path.join(pkg, "bin", getBinName()));
33
+ } catch (_) {
34
+ return null;
35
+ }
36
+ }
37
+
38
+ function getCachePath() {
39
+ var cacheDir = path.join(os.homedir(), ".beeos", "bin");
40
+ var name = process.platform === "win32"
41
+ ? "beeos-" + VERSION + ".exe"
42
+ : "beeos-" + VERSION;
43
+ return path.join(cacheDir, name);
44
+ }
45
+
46
+ function extractBinaryFromTarball(tgzBuffer, targetBinName) {
47
+ var tar = zlib.gunzipSync(tgzBuffer);
48
+ var offset = 0;
49
+ while (offset < tar.length) {
50
+ var header = tar.subarray(offset, offset + 512);
51
+ if (header.every(function(b) { return b === 0; })) break;
52
+
53
+ var name = header.subarray(0, 100).toString("utf8").replace(/\0/g, "");
54
+ var sizeOctal = header.subarray(124, 136).toString("utf8").replace(/\0/g, "").trim();
55
+ var size = parseInt(sizeOctal, 8) || 0;
56
+ var dataStart = offset + 512;
57
+ var dataEnd = dataStart + size;
58
+
59
+ if (name === "package/bin/" + targetBinName || name.endsWith("/" + targetBinName)) {
60
+ return tar.subarray(dataStart, dataEnd);
61
+ }
62
+
63
+ offset = dataStart + Math.ceil(size / 512) * 512;
64
+ }
65
+ return null;
66
+ }
67
+
68
+ function getTarballUrl(pkg) {
69
+ var parts = pkg.split("/");
70
+ var scope = parts[0];
71
+ var pkgName = parts[1];
72
+ return "https://registry.npmjs.org/" + scope + "/" + pkgName + "/-/" + pkgName + "-" + VERSION + ".tgz";
73
+ }
74
+
75
+ function downloadBinary() {
76
+ var key = getPlatformKey();
77
+ var pkg = PLATFORMS[key];
78
+ if (!pkg) {
79
+ console.error(
80
+ "beeos: unsupported platform " + key + "\n" +
81
+ "Supported: " + Object.keys(PLATFORMS).join(", ")
82
+ );
83
+ process.exit(1);
84
+ }
85
+
86
+ var cached = getCachePath();
87
+ if (fs.existsSync(cached)) return cached;
88
+
89
+ var tarballUrl = getTarballUrl(pkg);
90
+ console.error("beeos: downloading binary for " + key + " (v" + VERSION + ")...");
91
+
92
+ try {
93
+ var script = [
94
+ 'var https = require("https");',
95
+ "function fetch(url) {",
96
+ " return new Promise(function(resolve, reject) {",
97
+ " https.get(url, function(res) {",
98
+ " if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location)",
99
+ " return fetch(res.headers.location).then(resolve, reject);",
100
+ " if (res.statusCode !== 200)",
101
+ ' return reject(new Error("HTTP " + res.statusCode));',
102
+ " var c = [];",
103
+ ' res.on("data", function(d) { c.push(d); });',
104
+ ' res.on("end", function() { resolve(Buffer.concat(c)); });',
105
+ ' res.on("error", reject);',
106
+ ' }).on("error", reject);',
107
+ " });",
108
+ "}",
109
+ "fetch(" + JSON.stringify(tarballUrl) + ").then(function(b) {",
110
+ " process.stdout.write(b);",
111
+ "}).catch(function(e) {",
112
+ " process.stderr.write(e.message);",
113
+ " process.exit(1);",
114
+ "});"
115
+ ].join("\n");
116
+
117
+ var tgz = execFileSync(process.execPath, ["-e", script], {
118
+ maxBuffer: 50 * 1024 * 1024,
119
+ });
120
+
121
+ var binName = getBinName();
122
+ var binary = extractBinaryFromTarball(tgz, binName);
123
+ if (!binary) {
124
+ console.error("beeos: could not find bin/" + binName + " in tarball");
125
+ process.exit(1);
126
+ }
127
+
128
+ var cacheDir = path.dirname(cached);
129
+ fs.mkdirSync(cacheDir, { recursive: true });
130
+
131
+ var tmp = cached + ".tmp";
132
+ fs.writeFileSync(tmp, binary);
133
+ if (process.platform !== "win32") {
134
+ fs.chmodSync(tmp, 0o755);
135
+ }
136
+ fs.renameSync(tmp, cached);
137
+
138
+ console.error("beeos: binary cached at " + cached);
139
+ return cached;
140
+ } catch (err) {
141
+ console.error(
142
+ "beeos: failed to download binary for " + key + ".\n" +
143
+ " " + err.message + "\n" +
144
+ "Try: npm install -g @beeos-ai/cli@" + VERSION
145
+ );
146
+ process.exit(1);
147
+ }
148
+ }
149
+
150
+ var binaryPath = tryResolve() || downloadBinary();
151
+ var result = spawnSync(binaryPath, process.argv.slice(2), {
152
+ stdio: "inherit",
153
+ env: process.env,
154
+ });
155
+
156
+ if (result.error) {
157
+ console.error("beeos: failed to start:", result.error.message);
158
+ process.exit(1);
159
+ }
160
+
161
+ process.exit(result.status != null ? result.status : 1);
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@beeos-ai/cli",
3
+ "version": "0.1.2",
4
+ "description": "BeeOS CLI – run AI agents from your desktop",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "beeos": "bin/beeos.js"
8
+ },
9
+ "files": [
10
+ "bin/"
11
+ ],
12
+ "optionalDependencies": {
13
+ "@beeos-ai/cli-darwin-arm64": "0.1.2",
14
+ "@beeos-ai/cli-darwin-x64": "0.1.2",
15
+ "@beeos-ai/cli-linux-x64-gnu": "0.1.2",
16
+ "@beeos-ai/cli-linux-arm64-gnu": "0.1.2",
17
+ "@beeos-ai/cli-win32-x64-msvc": "0.1.2"
18
+ },
19
+ "keywords": [
20
+ "beeos",
21
+ "ai",
22
+ "agent",
23
+ "cli",
24
+ "openclaw"
25
+ ],
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/beeos-ai/beeos.git",
29
+ "directory": "cli/beeos"
30
+ },
31
+ "homepage": "https://beeos.ai",
32
+ "bugs": {
33
+ "url": "https://github.com/beeos-ai/beeos/issues"
34
+ }
35
+ }