crabot 0.1.3 → 0.1.5

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/README.md CHANGED
@@ -4,13 +4,16 @@ Local-first AI agent runtime with a gateway, operator console, and CLI.
4
4
 
5
5
  ## Requirements
6
6
 
7
- `crabot` runs as a self-contained standalone binary with the runtime embedded —
8
- the program itself needs no Bun or Node install. The package ships no install
9
- script; on the first `crabot` run a small launcher (running under the Node that
10
- npm already provides) downloads the prebuilt binary matching your platform from
11
- the matching GitHub release, verifies its checksum, and caches it for later runs.
12
-
13
- Supported platforms: Linux (x64, arm64), macOS (x64, arm64), Windows (x64).
7
+ `crabot` is a self-contained standalone binary with the runtime embedded — it
8
+ needs no Bun or Node install. The package bundles the binary directly (a small
9
+ Node launcher execs it), so installing it downloads nothing extra and runs no
10
+ install scripts.
11
+
12
+ **Currently macOS arm64 only.** Other platforms are not yet published; build
13
+ from source at [the repository](https://github.com/gotry-io/Crabot). A macOS
14
+ arm64 binary is also attached to each
15
+ [GitHub release](https://github.com/gotry-io/Crabot/releases) for direct
16
+ download.
14
17
 
15
18
  ## Install
16
19
 
package/bin/crabot.mjs CHANGED
@@ -1,31 +1,32 @@
1
1
  #!/usr/bin/env node
2
- // Launcher for the `crabot` distribution. The real program is a standalone executable (the Bun
3
- // runtime is embedded) downloaded from the matching GitHub release lazily here on first run (the
4
- // package ships no install script). No Bun or Node runtime is required to run crabot.
2
+ // Launcher for the `crabot` distribution. The macOS arm64 standalone binary (the Bun runtime is
3
+ // embedded) is bundled in this package under vendor/, so there is nothing to download and crabot
4
+ // needs no extra runtime. Only macOS arm64 is shipped today; other platforms build from source.
5
5
  import { spawn } from "node:child_process";
6
+ import { chmodSync } from "node:fs";
7
+ import { dirname, join } from "node:path";
6
8
  import { fileURLToPath } from "node:url";
7
- import { ensureBinary } from "../scripts/install.mjs";
8
9
 
9
- let binaryPath;
10
- try {
11
- binaryPath = await ensureBinary();
12
- } catch (error) {
13
- process.stderr.write(`${error.message}\n`);
10
+ if (process.platform !== "darwin" || process.arch !== "arm64") {
11
+ process.stderr.write(
12
+ `crabot currently ships only a macOS arm64 build (detected ${process.platform}-${process.arch}). ` +
13
+ `Build from source: https://github.com/gotry-io/Crabot\n`
14
+ );
14
15
  process.exit(1);
15
16
  }
16
17
 
17
- // The downloaded binary lives at a version-pinned cache path that `npm update` orphans, so its own
18
- // process.execPath is not a stable launch target. Expose the stable command that re-launches crabot —
19
- // this launcher under Node, which re-resolves the matching binary on demand so `crabot service
20
- // install` writes a service unit that survives upgrades. This launcher path is stable across upgrades
21
- // (npm replaces the package in place).
22
- const child = spawn(binaryPath, process.argv.slice(2), {
23
- stdio: "inherit",
24
- env: {
25
- ...process.env,
26
- CRABOT_LAUNCH_VECTOR: JSON.stringify([process.execPath, fileURLToPath(import.meta.url)])
27
- }
28
- });
18
+ const binaryPath = join(dirname(fileURLToPath(import.meta.url)), "..", "vendor", "crabot");
19
+
20
+ // npm does not reliably preserve the executable bit on bundled (non-bin) files, so set it before
21
+ // launching; ignore failures (already executable, or a read-only install spawn will surface a real
22
+ // problem).
23
+ try {
24
+ chmodSync(binaryPath, 0o755);
25
+ } catch {
26
+ // best effort
27
+ }
28
+
29
+ const child = spawn(binaryPath, process.argv.slice(2), { stdio: "inherit" });
29
30
 
30
31
  // Forward termination signals so `crabot serve` shuts the gateway down gracefully when a process
31
32
  // manager signals this wrapper. Unsupported signal names throw on registration; ignore those.
package/package.json CHANGED
@@ -1,14 +1,20 @@
1
1
  {
2
2
  "name": "crabot",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Local-first AI agent runtime with a gateway, operator console, and CLI.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "crabot": "bin/crabot.mjs"
8
8
  },
9
+ "os": [
10
+ "darwin"
11
+ ],
12
+ "cpu": [
13
+ "arm64"
14
+ ],
9
15
  "files": [
10
16
  "bin",
11
- "scripts",
17
+ "vendor",
12
18
  "README.md",
13
19
  "LICENSE"
14
20
  ],
package/vendor/crabot ADDED
Binary file
@@ -1,76 +0,0 @@
1
- #!/usr/bin/env node
2
- // Downloads the crabot standalone binary for the host platform from the GitHub release that matches
3
- // this package's version, verifies its SHA-256, and caches it. Invoked by the launcher on first run
4
- // when the binary is not cached yet; the package ships no install script, so nothing runs at install
5
- // time. The binary embeds the Bun runtime, so running crabot needs no Bun or Node install.
6
- import { createHash } from "node:crypto";
7
- import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
8
- import { homedir } from "node:os";
9
- import { dirname, join } from "node:path";
10
- import { fileURLToPath } from "node:url";
11
-
12
- const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
13
- const { version } = JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8"));
14
- const repository = "gotry-io/Crabot";
15
-
16
- // process.platform-process.arch -> GitHub release asset name.
17
- const assets = {
18
- "linux-x64": "crabot-linux-x64",
19
- "linux-arm64": "crabot-linux-arm64",
20
- "darwin-x64": "crabot-macos-x64",
21
- "darwin-arm64": "crabot-macos-arm64",
22
- "win32-x64": "crabot-windows-x64.exe"
23
- };
24
-
25
- function cachedBinaryPath() {
26
- const base = process.platform === "win32"
27
- ? process.env.LOCALAPPDATA || join(homedir(), "AppData", "Local")
28
- : process.env.XDG_CACHE_HOME || join(homedir(), ".cache");
29
- const name = process.platform === "win32" ? "crabot.exe" : "crabot";
30
- return join(base, "crabot", `v${version}`, name);
31
- }
32
-
33
- async function fetchBuffer(url) {
34
- const response = await fetch(url, { redirect: "follow" });
35
- if (!response.ok) {
36
- throw new Error(`request failed (${response.status}) for ${url}`);
37
- }
38
-
39
- return Buffer.from(await response.arrayBuffer());
40
- }
41
-
42
- export async function ensureBinary() {
43
- const target = cachedBinaryPath();
44
- if (existsSync(target)) {
45
- return target;
46
- }
47
-
48
- const key = `${process.platform}-${process.arch}`;
49
- const asset = assets[key];
50
- if (asset === undefined) {
51
- throw new Error(`crabot: no prebuilt binary for ${key}. See https://github.com/${repository}/releases`);
52
- }
53
-
54
- const base = `https://github.com/${repository}/releases/download/v${version}`;
55
- process.stderr.write(`crabot: downloading ${asset} (v${version})...\n`);
56
- const [binary, checksum] = await Promise.all([
57
- fetchBuffer(`${base}/${asset}`),
58
- fetchBuffer(`${base}/${asset}.sha256`).then((buffer) => buffer.toString("utf8"))
59
- ]);
60
-
61
- const expected = checksum.trim().split(/\s+/u)[0];
62
- const actual = createHash("sha256").update(binary).digest("hex");
63
- if (expected !== actual) {
64
- throw new Error(`crabot: checksum mismatch for ${asset} (expected ${expected}, got ${actual})`);
65
- }
66
-
67
- mkdirSync(dirname(target), { recursive: true });
68
- // Write to a sibling temp file then rename, so a concurrent install never sees a partial binary.
69
- const temporary = `${target}.${process.pid}.download`;
70
- writeFileSync(temporary, binary);
71
- if (process.platform !== "win32") {
72
- chmodSync(temporary, 0o755);
73
- }
74
- renameSync(temporary, target);
75
- return target;
76
- }