thrust-cli 1.0.5 ā 1.0.6
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/index.js +24 -26
- package/package.json +1 -1
- package/utils/daemon.js +7 -9
package/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
|
+
import os from 'os';
|
|
6
7
|
import { fileURLToPath } from 'url';
|
|
7
|
-
import AutoLaunch from 'auto-launch';
|
|
8
8
|
import { startDaemon } from './utils/daemon.js';
|
|
9
9
|
import { getConfig, saveConfig } from './utils/config.js';
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ program
|
|
|
28
28
|
.action(async (options) => {
|
|
29
29
|
console.log('š Booting Thrust Agent...');
|
|
30
30
|
|
|
31
|
-
await
|
|
31
|
+
await setupNativeStartup();
|
|
32
32
|
|
|
33
33
|
startDaemon(parseInt(options.port, 10));
|
|
34
34
|
});
|
|
@@ -58,37 +58,35 @@ program
|
|
|
58
58
|
|
|
59
59
|
program.parse(process.argv);
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// --- NATIVE, VISIBLE OS STARTUP LOGIC ---
|
|
62
|
+
async function setupNativeStartup() {
|
|
62
63
|
if (process.env.TERMUX_VERSION) {
|
|
63
|
-
console.log('š± Termux detected:
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (process.platform === 'linux' && !process.env.DISPLAY) {
|
|
68
|
-
console.log('š„ļø Headless Linux detected: Skipping GUI AutoLaunch. (Tip: Set up a systemd service)');
|
|
64
|
+
console.log('š± Termux detected: Use `termux-boot` for OS startup.');
|
|
69
65
|
return;
|
|
70
66
|
}
|
|
71
67
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
if (process.platform === 'win32') {
|
|
69
|
+
try {
|
|
70
|
+
// Path to the current user's Windows Startup folder
|
|
71
|
+
const startupFolder = path.join(os.homedir(), 'AppData', 'Roaming', 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup');
|
|
72
|
+
const batFilePath = path.join(startupFolder, 'thrust-agent.bat');
|
|
76
73
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
74
|
+
// The exact commands Windows will run on boot
|
|
75
|
+
// We use 'timeout' to give Windows network drivers 3 seconds to wake up before starting
|
|
76
|
+
const batContent = `@echo off\ntitle Thrust Local Agent\necho Starting Thrust...\ntimeout /t 3 /nobreak > NUL\nthrust\npause`;
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
// Write the .bat file if it doesn't already exist or if we need to update it
|
|
79
|
+
fs.writeFileSync(batFilePath, batContent, 'utf8');
|
|
80
|
+
console.log('āļø Windows Startup Script active. (A terminal will open automatically on next reboot).');
|
|
81
|
+
} catch (err) {
|
|
82
|
+
console.log(`ā ļø Failed to create Windows startup script: ${err.message}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else if (process.platform === 'darwin' || process.platform === 'linux') {
|
|
86
|
+
if (!process.env.DISPLAY) {
|
|
87
|
+
console.log('š„ļø Headless Linux detected: Skipping GUI AutoLaunch.');
|
|
86
88
|
} else {
|
|
87
|
-
|
|
88
|
-
await thrustAutoLauncher.enable();
|
|
89
|
-
console.log('āļø OS Startup auto-launch is active (Registry updated).');
|
|
89
|
+
console.log('āļø Mac/Linux detected: Run via PM2 or Systemd for background startup.');
|
|
90
90
|
}
|
|
91
|
-
} catch (err) {
|
|
92
|
-
console.log(`ā ļø Auto-launch setup skipped (not supported on this setup).`);
|
|
93
91
|
}
|
|
94
92
|
}
|
package/package.json
CHANGED
package/utils/daemon.js
CHANGED
|
@@ -151,7 +151,7 @@ export async function startDaemon(preferredPort) {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
// --- BULLETPROOF BROWSER OPENER ---
|
|
154
|
+
// --- BULLETPROOF BROWSER OPENER WITH LOGGING ---
|
|
155
155
|
async function safeOpenBrowser(url) {
|
|
156
156
|
try {
|
|
157
157
|
if (process.env.TERMUX_VERSION) {
|
|
@@ -161,24 +161,22 @@ async function safeOpenBrowser(url) {
|
|
|
161
161
|
} else if (!process.env.DISPLAY && process.platform === 'linux') {
|
|
162
162
|
console.log("š [Headless] Please open the URL manually in a browser.");
|
|
163
163
|
} else {
|
|
164
|
+
console.log("š Attempting to launch browser window...");
|
|
164
165
|
try {
|
|
165
|
-
//
|
|
166
|
+
// Try Chrome App Mode First
|
|
166
167
|
const chromeName = process.platform === 'darwin' ? 'google chrome' :
|
|
167
168
|
process.platform === 'win32' ? 'chrome' : 'google-chrome';
|
|
168
169
|
|
|
169
|
-
// Force a small, docked 800x600 native app window without toolbars
|
|
170
170
|
await open(url, {
|
|
171
|
-
app: {
|
|
172
|
-
name: chromeName,
|
|
173
|
-
arguments: [`--app=${url}`, '--window-size=800,600']
|
|
174
|
-
}
|
|
171
|
+
app: { name: chromeName, arguments: [`--app=${url}`, '--window-size=1000,800'] }
|
|
175
172
|
});
|
|
176
173
|
} catch (err) {
|
|
177
|
-
// If Chrome
|
|
174
|
+
// If Chrome fails (e.g., Windows Server EC2 often doesn't have Chrome in path),
|
|
175
|
+
// just use the absolute default system opener.
|
|
178
176
|
try {
|
|
179
177
|
await open(url);
|
|
180
178
|
} catch (fallbackErr) {
|
|
181
|
-
console.log("\nš OS prevented launching the browser
|
|
179
|
+
console.log("\nš OS security prevented auto-launching the browser. Please open the URL above manually.\n");
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
182
|
}
|