thrust-cli 1.0.4 → 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 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 enableAutoLaunchSafe();
31
+ await setupNativeStartup();
32
32
 
33
33
  startDaemon(parseInt(options.port, 10));
34
34
  });
@@ -58,33 +58,35 @@ program
58
58
 
59
59
  program.parse(process.argv);
60
60
 
61
- async function enableAutoLaunchSafe() {
61
+ // --- NATIVE, VISIBLE OS STARTUP LOGIC ---
62
+ async function setupNativeStartup() {
62
63
  if (process.env.TERMUX_VERSION) {
63
- console.log('šŸ“± Termux detected: Skipping desktop AutoLaunch. (Tip: Use termux-boot to run on startup)');
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
- try {
73
- const thrustAutoLauncher = new AutoLaunch({
74
- name: 'ThrustAgent',
75
- path: process.execPath,
76
- args: [__filename]
77
- });
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');
78
73
 
79
- const isEnabled = await thrustAutoLauncher.isEnabled();
80
- if (!isEnabled) {
81
- await thrustAutoLauncher.enable();
82
- console.log('āš™ļø Added to OS Startup programs.');
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`;
77
+
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.');
83
88
  } else {
84
- // NEW: Always reassure the user that startup is active!
85
- console.log('āš™ļø OS Startup auto-launch is active.');
89
+ console.log('āš™ļø Mac/Linux detected: Run via PM2 or Systemd for background startup.');
86
90
  }
87
- } catch (err) {
88
- console.log(`āš ļø Auto-launch setup skipped (not supported on this setup).`);
89
91
  }
90
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thrust-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "The local agent for Thrust AI Director",
5
5
  "type": "module",
6
6
  "homepage": "https://thrust.web.app",
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
- // OS-Specific Chrome Executable Names to force App Mode
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 isn't installed, fail gracefully to the default normal browser
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 automatically. Please open the URL above manually.\n");
179
+ console.log("\nšŸ‘‰ OS security prevented auto-launching the browser. Please open the URL above manually.\n");
182
180
  }
183
181
  }
184
182
  }