hedgequantx 2.7.76 → 2.7.78
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/package.json
CHANGED
package/src/pages/ai-agents.js
CHANGED
|
@@ -125,7 +125,7 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
|
|
|
125
125
|
spinner.succeed('CLIPROXYAPI INSTALLED');
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
// Check if running, start if not
|
|
128
|
+
// Check if running, start if not (or restart if config missing)
|
|
129
129
|
let status = await cliproxy.isRunning();
|
|
130
130
|
if (!status.running) {
|
|
131
131
|
const spinner = ora({ text: 'STARTING CLIPROXYAPI...', color: 'yellow' }).start();
|
|
@@ -138,7 +138,21 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
|
|
|
138
138
|
}
|
|
139
139
|
spinner.succeed('CLIPROXYAPI STARTED');
|
|
140
140
|
} else {
|
|
141
|
-
|
|
141
|
+
// Running, but check if config exists (for proper API key auth)
|
|
142
|
+
const configPath = require('path').join(require('os').homedir(), '.hqx', 'cliproxy', 'config.yaml');
|
|
143
|
+
if (!require('fs').existsSync(configPath)) {
|
|
144
|
+
console.log(chalk.yellow(' RESTARTING CLIPROXYAPI WITH PROPER CONFIG...'));
|
|
145
|
+
await cliproxy.stop();
|
|
146
|
+
const startResult = await cliproxy.start();
|
|
147
|
+
if (!startResult.success) {
|
|
148
|
+
console.log(chalk.red(` FAILED TO RESTART: ${startResult.error.toUpperCase()}`));
|
|
149
|
+
await prompts.waitForEnter();
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
console.log(chalk.green(' ✓ CLIPROXYAPI RESTARTED'));
|
|
153
|
+
} else {
|
|
154
|
+
console.log(chalk.green(' ✓ CLIPROXYAPI IS RUNNING'));
|
|
155
|
+
}
|
|
142
156
|
}
|
|
143
157
|
|
|
144
158
|
// First, check if models are already available (existing auth)
|
|
@@ -296,12 +296,36 @@ const stop = async () => {
|
|
|
296
296
|
try {
|
|
297
297
|
if (status.pid) {
|
|
298
298
|
process.kill(status.pid, 'SIGTERM');
|
|
299
|
+
} else {
|
|
300
|
+
// No PID - try to find and kill by port
|
|
301
|
+
const { execSync } = require('child_process');
|
|
302
|
+
try {
|
|
303
|
+
if (process.platform === 'win32') {
|
|
304
|
+
// Windows: find PID by port and kill
|
|
305
|
+
const result = execSync(`netstat -ano | findstr :${DEFAULT_PORT}`, { encoding: 'utf8' });
|
|
306
|
+
const match = result.match(/LISTENING\s+(\d+)/);
|
|
307
|
+
if (match) process.kill(parseInt(match[1]), 'SIGTERM');
|
|
308
|
+
} else {
|
|
309
|
+
// Unix: use lsof or fuser
|
|
310
|
+
try {
|
|
311
|
+
execSync(`lsof -ti:${DEFAULT_PORT} | xargs kill -9 2>/dev/null || true`, { encoding: 'utf8' });
|
|
312
|
+
} catch (e) {
|
|
313
|
+
// Try fuser as fallback
|
|
314
|
+
execSync(`fuser -k ${DEFAULT_PORT}/tcp 2>/dev/null || true`, { encoding: 'utf8' });
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
} catch (e) {
|
|
318
|
+
// Ignore errors - process may already be dead
|
|
319
|
+
}
|
|
299
320
|
}
|
|
300
321
|
|
|
301
322
|
if (fs.existsSync(PID_FILE)) {
|
|
302
323
|
fs.unlinkSync(PID_FILE);
|
|
303
324
|
}
|
|
304
325
|
|
|
326
|
+
// Wait for port to be released
|
|
327
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
328
|
+
|
|
305
329
|
return { success: true, error: null };
|
|
306
330
|
} catch (error) {
|
|
307
331
|
return { success: false, error: error.message };
|