@bulletproof-sh/ctrl-daemon 0.0.18 → 0.1.1-alpha.15

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,63 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable */
3
+ // @ts-nocheck
4
+
5
+ /**
6
+ * ctrl-daemon bin shim — resolves the platform-specific compiled binary.
7
+ *
8
+ * Resolution order:
9
+ * 1. CTRL_DAEMON_BINARY_PATH env override (dev/testing)
10
+ * 2. Platform package binary (installed via optionalDependencies)
11
+ */
12
+
13
+ 'use strict';
14
+
15
+ const { execFileSync } = require('node:child_process');
16
+ const { existsSync } = require('node:fs');
17
+
18
+ const platformPackages = {
19
+ 'darwin-arm64': '@bulletproof-sh/ctrl-daemon-darwin-arm64',
20
+ 'darwin-x64': '@bulletproof-sh/ctrl-daemon-darwin-x64',
21
+ 'linux-arm64': '@bulletproof-sh/ctrl-daemon-linux-arm64',
22
+ 'linux-x64': '@bulletproof-sh/ctrl-daemon-linux-x64',
23
+ };
24
+
25
+ function getBinaryPath() {
26
+ if (process.env.CTRL_DAEMON_BINARY_PATH) {
27
+ return process.env.CTRL_DAEMON_BINARY_PATH;
28
+ }
29
+
30
+ const key = `${process.platform}-${process.arch}`;
31
+ const pkg = platformPackages[key];
32
+ if (pkg) {
33
+ try {
34
+ const binPath = require.resolve(`${pkg}/bin/ctrl-daemon`);
35
+ if (existsSync(binPath)) {
36
+ return binPath;
37
+ }
38
+ } catch {
39
+ // Platform package not installed
40
+ }
41
+ }
42
+
43
+ return null;
44
+ }
45
+
46
+ const binaryPath = getBinaryPath();
47
+
48
+ if (!binaryPath) {
49
+ const key = `${process.platform}-${process.arch}`;
50
+ const supported = Object.keys(platformPackages).join(', ');
51
+ console.error(
52
+ `ctrl-daemon: no binary available for ${key}.\n\n` +
53
+ `Supported platforms: ${supported}\n` +
54
+ 'If you installed with --no-optional, reinstall without that flag.',
55
+ );
56
+ process.exit(1);
57
+ }
58
+
59
+ try {
60
+ execFileSync(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
61
+ } catch (err) {
62
+ process.exit(err.status ?? 1);
63
+ }
package/package.json CHANGED
@@ -1,28 +1,36 @@
1
1
  {
2
2
  "name": "@bulletproof-sh/ctrl-daemon",
3
- "version": "0.0.18",
3
+ "version": "0.1.1-alpha.15",
4
4
  "description": "WebSocket daemon for ctrl — watches Claude Code sessions and broadcasts agent state",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",
7
7
  "bin": {
8
- "ctrl-daemon": "bin/ctrl-daemon.js"
8
+ "ctrl-daemon": "bin/ctrl-daemon.cjs"
9
9
  },
10
10
  "files": [
11
- "bin/",
12
- "dist/"
11
+ "bin/"
13
12
  ],
14
13
  "scripts": {
15
14
  "dev": "bun --watch src/index.ts",
16
15
  "start": "bun src/index.ts",
17
- "build": "bun build src/index.ts --outdir dist --target bun",
16
+ "build": "bun build src/index.ts --outdir dist --target bun --minify",
17
+ "build:binaries": "bun scripts/build-binaries.ts",
18
18
  "check": "biome check .",
19
- "verify": "bunx tsc --noEmit && biome check .",
20
- "prepublishOnly": "bun run build"
19
+ "verify": "bunx tsc --noEmit && biome check . && vitest run",
20
+ "test": "vitest run",
21
+ "test:watch": "vitest"
21
22
  },
22
23
  "devDependencies": {
23
24
  "@biomejs/biome": "^2.4.4",
24
25
  "@types/bun": "latest",
25
- "typescript": "~5.9.3"
26
+ "typescript": "~5.9.3",
27
+ "vitest": "^4.0.18"
28
+ },
29
+ "optionalDependencies": {
30
+ "@bulletproof-sh/ctrl-daemon-darwin-arm64": "0.1.1-alpha.15",
31
+ "@bulletproof-sh/ctrl-daemon-darwin-x64": "0.1.1-alpha.15",
32
+ "@bulletproof-sh/ctrl-daemon-linux-arm64": "0.1.1-alpha.15",
33
+ "@bulletproof-sh/ctrl-daemon-linux-x64": "0.1.1-alpha.15"
26
34
  },
27
35
  "dependencies": {
28
36
  "posthog-node": "^5.26.0"
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
- import { execFileSync } from 'node:child_process';
3
- import { dirname, join } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
-
6
- const __dirname = dirname(fileURLToPath(import.meta.url));
7
- const entry = join(__dirname, '..', 'dist', 'index.js');
8
-
9
- // Check for bun in PATH
10
- try {
11
- execFileSync('bun', ['--version'], { stdio: 'ignore' });
12
- } catch {
13
- console.error(
14
- 'ctrl-daemon requires Bun to run.\n\nInstall Bun: https://bun.sh\n curl -fsSL https://bun.sh/install | bash',
15
- );
16
- process.exit(1);
17
- }
18
-
19
- // Forward all CLI args to the daemon entry point
20
- const args = ['run', entry, ...process.argv.slice(2)];
21
-
22
- try {
23
- execFileSync('bun', args, { stdio: 'inherit' });
24
- } catch (err) {
25
- // execFileSync throws on non-zero exit — just propagate the code
26
- process.exit(err.status ?? 1);
27
- }