fluxy-bot 0.1.6 → 0.1.8

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/cli.js CHANGED
@@ -140,14 +140,22 @@ function createConfig() {
140
140
  }
141
141
  }
142
142
 
143
+ const MIN_CF_SIZE = 10 * 1024 * 1024; // 10 MB — valid cloudflared is ~30-50 MB
144
+
143
145
  function hasCloudflared() {
144
- try {
145
- const cmd = process.platform === 'win32' ? 'where cloudflared' : 'which cloudflared';
146
- execSync(cmd, { stdio: 'ignore' });
147
- return true;
148
- } catch {}
146
+ // Check system-wide install
147
+ const which = process.platform === 'win32' ? 'where cloudflared' : 'which cloudflared';
148
+ try { execSync(which, { stdio: 'ignore' }); return true; } catch {}
149
+
150
+ // Check local install (validate by file size, never execute — avoids Windows popup)
149
151
  const cfExe = process.platform === 'win32' ? CF_PATH + '.exe' : CF_PATH;
150
- return fs.existsSync(cfExe);
152
+ if (!fs.existsSync(cfExe)) return false;
153
+ const size = fs.statSync(cfExe).size;
154
+ if (size < MIN_CF_SIZE) {
155
+ fs.unlinkSync(cfExe);
156
+ return false;
157
+ }
158
+ return true;
151
159
  }
152
160
 
153
161
  async function installCloudflared() {
@@ -156,11 +164,14 @@ async function installCloudflared() {
156
164
  fs.mkdirSync(BIN_DIR, { recursive: true });
157
165
 
158
166
  const platform = os.platform();
159
- const arch = os.arch();
167
+ // os.arch() returns Node's arch, not the OS. Use PROCESSOR_ARCHITECTURE on Windows for real OS arch.
168
+ const arch = platform === 'win32'
169
+ ? (process.env.PROCESSOR_ARCHITECTURE || os.arch()).toLowerCase()
170
+ : os.arch();
160
171
  let url;
161
172
 
162
173
  if (platform === 'win32') {
163
- url = arch === 'arm64'
174
+ url = arch.includes('arm')
164
175
  ? 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-arm64.exe'
165
176
  : 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe';
166
177
  } else if (platform === 'darwin') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxy-bot",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Self-hosted AI bot — run your own AI assistant from anywhere",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -7,11 +7,21 @@ import { log } from '../shared/logger.js';
7
7
 
8
8
  let proc: ChildProcess | null = null;
9
9
 
10
+ const MIN_CF_SIZE = 10 * 1024 * 1024; // 10 MB — valid cloudflared is ~30-50 MB
11
+
10
12
  function findBinary(): string | null {
11
- const cmd = process.platform === 'win32' ? 'where cloudflared' : 'which cloudflared';
12
- try { execSync(cmd, { stdio: 'ignore' }); return 'cloudflared'; } catch {}
13
- if (fs.existsSync(paths.cloudflared)) return paths.cloudflared;
14
- return null;
13
+ // Check system-wide install
14
+ const which = process.platform === 'win32' ? 'where cloudflared' : 'which cloudflared';
15
+ try { execSync(which, { stdio: 'ignore' }); return 'cloudflared'; } catch {}
16
+
17
+ // Check local install (validate by file size, never execute — avoids Windows popup)
18
+ if (!fs.existsSync(paths.cloudflared)) return null;
19
+ const size = fs.statSync(paths.cloudflared).size;
20
+ if (size < MIN_CF_SIZE) {
21
+ fs.unlinkSync(paths.cloudflared);
22
+ return null;
23
+ }
24
+ return paths.cloudflared;
15
25
  }
16
26
 
17
27
  export async function installCloudflared(): Promise<string> {
@@ -21,11 +31,14 @@ export async function installCloudflared(): Promise<string> {
21
31
  const dir = path.dirname(paths.cloudflared);
22
32
  fs.mkdirSync(dir, { recursive: true });
23
33
 
24
- const p = os.platform(), a = os.arch();
34
+ const p = os.platform();
35
+ const a = p === 'win32'
36
+ ? (process.env.PROCESSOR_ARCHITECTURE || os.arch()).toLowerCase()
37
+ : os.arch();
25
38
  const base = 'https://github.com/cloudflare/cloudflared/releases/latest/download';
26
39
 
27
40
  let url: string;
28
- if (p === 'win32') url = `${base}/cloudflared-windows-${a === 'arm64' ? 'arm64' : 'amd64'}.exe`;
41
+ if (p === 'win32') url = `${base}/cloudflared-windows-${a.includes('arm') ? 'arm64' : 'amd64'}.exe`;
29
42
  else if (p === 'darwin') url = `${base}/cloudflared-darwin-${a === 'arm64' ? 'arm64' : 'amd64'}.tgz`;
30
43
  else if (a === 'arm64' || a === 'aarch64') url = `${base}/cloudflared-linux-arm64`;
31
44
  else if (a.startsWith('arm')) url = `${base}/cloudflared-linux-arm`;