cybara 1.0.1226

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/cybara.cjs ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ const { spawnSync } = require("child_process");
4
+ const { existsSync } = require("fs");
5
+ const { join } = require("path");
6
+
7
+ const binaryName = process.platform === "win32" ? "cybara-bin.exe" : "cybara-bin";
8
+ const binary = join(__dirname, binaryName);
9
+
10
+ if (!existsSync(binary)) {
11
+ console.error(
12
+ "[cybara] Native binary not found. Reinstall to fetch it: npm install -g cybara"
13
+ );
14
+ process.exit(1);
15
+ }
16
+
17
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
18
+ if (result.error) {
19
+ console.error(`[cybara] ${result.error.message}`);
20
+ process.exit(1);
21
+ }
22
+ process.exit(result.status === null ? 1 : result.status);
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "cybara",
3
+ "version": "1.0.1226",
4
+ "description": "Self-hosted, open-source AI agent platform — CLI",
5
+ "bin": {
6
+ "cybara": "bin/cybara.cjs"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node scripts/postinstall.cjs"
10
+ },
11
+ "files": [
12
+ "bin/cybara.cjs",
13
+ "scripts/postinstall.cjs"
14
+ ],
15
+ "keywords": [
16
+ "ai",
17
+ "agent",
18
+ "cli",
19
+ "self-hosted",
20
+ "mcp",
21
+ "cybara"
22
+ ],
23
+ "homepage": "https://cybara.ai",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/metaspartan/cybara.git"
27
+ },
28
+ "license": "MIT",
29
+ "os": [
30
+ "darwin",
31
+ "linux",
32
+ "win32"
33
+ ],
34
+ "cpu": [
35
+ "x64",
36
+ "arm64"
37
+ ],
38
+ "engines": {
39
+ "node": ">=18"
40
+ }
41
+ }
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const https = require("https");
6
+ const crypto = require("crypto");
7
+
8
+ const pkg = require(path.join(__dirname, "..", "package.json"));
9
+ const version = pkg.version;
10
+ const repo = "metaspartan/cybara";
11
+
12
+ function slugFor(platform, arch) {
13
+ const map = {
14
+ "darwin:arm64": "darwin-arm64",
15
+ "darwin:x64": "darwin-x64",
16
+ "linux:arm64": "linux-arm64",
17
+ "linux:x64": "linux-x64",
18
+ "win32:x64": "windows-x64",
19
+ };
20
+ return map[`${platform}:${arch}`] || null;
21
+ }
22
+
23
+ function fetch(url) {
24
+ return new Promise((resolve, reject) => {
25
+ https
26
+ .get(url, { headers: { "User-Agent": "cybara-npm" } }, (res) => {
27
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
28
+ res.resume();
29
+ resolve(fetch(res.headers.location));
30
+ return;
31
+ }
32
+ if (res.statusCode !== 200) {
33
+ res.resume();
34
+ reject(new Error(`HTTP ${res.statusCode} for ${url}`));
35
+ return;
36
+ }
37
+ const chunks = [];
38
+ res.on("data", (chunk) => chunks.push(chunk));
39
+ res.on("end", () => resolve(Buffer.concat(chunks)));
40
+ res.on("error", reject);
41
+ })
42
+ .on("error", reject);
43
+ });
44
+ }
45
+
46
+ async function main() {
47
+ const slug = slugFor(process.platform, process.arch);
48
+ if (!slug) {
49
+ console.warn(
50
+ `[cybara] No prebuilt binary for ${process.platform}/${process.arch}; skipping download.`
51
+ );
52
+ return;
53
+ }
54
+ const isWindows = process.platform === "win32";
55
+ const asset = `cybara-v${version}-${slug}-cli${isWindows ? ".exe" : ""}`;
56
+ const base = `https://github.com/${repo}/releases/download/v${version}`;
57
+
58
+ const payload = await fetch(`${base}/${asset}`);
59
+
60
+ let expected = null;
61
+ try {
62
+ const sidecar = (await fetch(`${base}/${asset}.sha256`)).toString("utf8").trim();
63
+ const first = sidecar.split(/\s+/)[0];
64
+ if (first) expected = first.toLowerCase();
65
+ } catch {
66
+ expected = null;
67
+ }
68
+ if (expected) {
69
+ const actual = crypto.createHash("sha256").update(payload).digest("hex");
70
+ if (actual !== expected) {
71
+ throw new Error(`checksum mismatch for ${asset}`);
72
+ }
73
+ }
74
+
75
+ const binDir = path.join(__dirname, "..", "bin");
76
+ fs.mkdirSync(binDir, { recursive: true });
77
+ const dest = path.join(binDir, isWindows ? "cybara-bin.exe" : "cybara-bin");
78
+ fs.writeFileSync(dest, payload);
79
+ if (!isWindows) fs.chmodSync(dest, 0o755);
80
+ console.log(`[cybara] Installed ${asset}`);
81
+ }
82
+
83
+ main().catch((error) => {
84
+ console.error(`[cybara] postinstall failed: ${error.message}`);
85
+ process.exit(1);
86
+ });