thrust-cli 1.0.6 → 1.0.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.
Files changed (2) hide show
  1. package/index.js +72 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -58,35 +58,93 @@ program
58
58
 
59
59
  program.parse(process.argv);
60
60
 
61
- // --- NATIVE, VISIBLE OS STARTUP LOGIC ---
61
+ // --- NATIVE, CROSS-PLATFORM OS STARTUP LOGIC ---
62
62
  async function setupNativeStartup() {
63
+ // 1. Termux (Android)
63
64
  if (process.env.TERMUX_VERSION) {
64
- console.log('📱 Termux detected: Use `termux-boot` for OS startup.');
65
+ console.log('📱 Termux detected: (Tip: Use the `termux-boot` app for OS startup).');
65
66
  return;
66
67
  }
67
68
 
69
+ // 2. Windows - Clean, direct global execution
68
70
  if (process.platform === 'win32') {
69
71
  try {
70
- // Path to the current user's Windows Startup folder
71
72
  const startupFolder = path.join(os.homedir(), 'AppData', 'Roaming', 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup');
72
73
  const batFilePath = path.join(startupFolder, 'thrust-agent.bat');
74
+
75
+ // Clean batch script that simply calls the global `thrust` command
76
+ const batContent = `@echo off\ntitle Thrust Local Agent\necho Starting Thrust...\ntimeout /t 2 /nobreak > NUL\nthrust\npause`;
73
77
 
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
78
+ if (!fs.existsSync(startupFolder)) fs.mkdirSync(startupFolder, { recursive: true });
79
79
  fs.writeFileSync(batFilePath, batContent, 'utf8');
80
- console.log('⚙️ Windows Startup Script active. (A terminal will open automatically on next reboot).');
80
+ console.log('⚙️ Windows Startup Script active.');
81
81
  } catch (err) {
82
82
  console.log(`⚠️ Failed to create Windows startup script: ${err.message}`);
83
83
  }
84
84
  }
85
- else if (process.platform === 'darwin' || process.platform === 'linux') {
86
- if (!process.env.DISPLAY) {
87
- console.log('🖥️ Headless Linux detected: Skipping GUI AutoLaunch.');
88
- } else {
89
- console.log('⚙️ Mac/Linux detected: Run via PM2 or Systemd for background startup.');
85
+
86
+ // 3. macOS - Requires absolute paths due to empty launchd $PATH
87
+ else if (process.platform === 'darwin') {
88
+ try {
89
+ const launchAgentsDir = path.join(os.homedir(), 'Library', 'LaunchAgents');
90
+ const plistPath = path.join(launchAgentsDir, 'com.thrust.agent.plist');
91
+
92
+ const plistContent = `<?xml version="1.0" encoding="UTF-8"?>
93
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
94
+ <plist version="1.0">
95
+ <dict>
96
+ <key>Label</key>
97
+ <string>com.thrust.agent</string>
98
+ <key>ProgramArguments</key>
99
+ <array>
100
+ <string>${process.execPath}</string>
101
+ <string>${__filename}</string>
102
+ </array>
103
+ <key>RunAtLoad</key>
104
+ <true/>
105
+ <key>KeepAlive</key>
106
+ <true/>
107
+ </dict>
108
+ </plist>`;
109
+
110
+ if (!fs.existsSync(launchAgentsDir)) fs.mkdirSync(launchAgentsDir, { recursive: true });
111
+ fs.writeFileSync(plistPath, plistContent, 'utf8');
112
+
113
+ import('child_process').then(({ exec }) => {
114
+ exec(`launchctl load -w "${plistPath}"`, () => {});
115
+ });
116
+ console.log('⚙️ macOS LaunchAgent active (Will run silently in background on boot).');
117
+ } catch (err) {
118
+ console.log(`⚠️ Failed to create macOS LaunchAgent: ${err.message}`);
119
+ }
120
+ }
121
+
122
+ // 4. Linux - Requires absolute paths for FreeDesktop compliance
123
+ else if (process.platform === 'linux') {
124
+ try {
125
+ if (!process.env.DISPLAY) {
126
+ console.log('🖥️ Headless Linux detected: Skipping GUI Autostart.');
127
+ return;
128
+ }
129
+
130
+ const autostartDir = path.join(os.homedir(), '.config', 'autostart');
131
+ const desktopPath = path.join(autostartDir, 'thrust-agent.desktop');
132
+
133
+ const desktopContent = `[Desktop Entry]
134
+ Type=Application
135
+ Exec="${process.execPath}" "${__filename}"
136
+ Hidden=false
137
+ NoDisplay=false
138
+ X-GNOME-Autostart-enabled=true
139
+ Name=Thrust Local Agent
140
+ Comment=Proactive AI Project Director
141
+ Terminal=true`;
142
+
143
+ if (!fs.existsSync(autostartDir)) fs.mkdirSync(autostartDir, { recursive: true });
144
+ fs.writeFileSync(desktopPath, desktopContent, 'utf8');
145
+ console.log('⚙️ Linux Autostart active (A terminal will open automatically on next reboot).');
146
+ } catch (err) {
147
+ console.log(`⚠️ Failed to create Linux startup script: ${err.message}`);
90
148
  }
91
149
  }
92
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thrust-cli",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "The local agent for Thrust AI Director",
5
5
  "type": "module",
6
6
  "homepage": "https://thrust.web.app",