hedgequantx 2.7.32 → 2.7.34

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "2.7.32",
3
+ "version": "2.7.34",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -187,12 +187,15 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
187
187
 
188
188
  // Different flow for VPS/headless vs local
189
189
  if (loginResult.isHeadless) {
190
- console.log(chalk.magenta(' ══════════════════════════════════════════════════════'));
190
+ console.log(chalk.magenta(' ══════════════════════════════════════════════════════════'));
191
191
  console.log(chalk.magenta(' VPS/SSH DETECTED - MANUAL CALLBACK REQUIRED'));
192
- console.log(chalk.magenta(' ══════════════════════════════════════════════════════\n'));
193
- console.log(chalk.white(' AFTER AUTHORIZING IN BROWSER, YOU WILL SEE A BLANK PAGE.'));
194
- console.log(chalk.white(' COPY THE URL FROM BROWSER ADDRESS BAR (STARTS WITH LOCALHOST)'));
195
- console.log(chalk.white(' AND PASTE IT BELOW:\n'));
192
+ console.log(chalk.magenta(' ══════════════════════════════════════════════════════════\n'));
193
+ console.log(chalk.white(' 1. OPEN THE URL ABOVE IN YOUR LOCAL BROWSER'));
194
+ console.log(chalk.white(' 2. AUTHORIZE THE APPLICATION'));
195
+ console.log(chalk.white(' 3. YOU WILL SEE A BLANK PAGE - THIS IS NORMAL'));
196
+ console.log(chalk.white(' 4. COPY THE FULL URL FROM YOUR BROWSER ADDRESS BAR'));
197
+ console.log(chalk.white(' (IT STARTS WITH: http://localhost:' + cliproxy.CALLBACK_PORT + '/...)'));
198
+ console.log(chalk.white(' 5. PASTE IT BELOW:\n'));
196
199
 
197
200
  const callbackUrl = await prompts.textInput(chalk.cyan(' CALLBACK URL: '));
198
201
 
@@ -203,21 +206,30 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
203
206
  return false;
204
207
  }
205
208
 
206
- // Process the callback
209
+ // Process the callback - send to the login process listening on CALLBACK_PORT
207
210
  const spinner = ora({ text: 'PROCESSING CALLBACK...', color: 'yellow' }).start();
208
- const callbackResult = await cliproxy.processCallback(callbackUrl.trim());
209
211
 
210
- if (!callbackResult.success) {
211
- spinner.fail(`CALLBACK FAILED: ${callbackResult.error.toUpperCase()}`);
212
+ try {
213
+ const callbackResult = await cliproxy.processCallback(callbackUrl.trim());
214
+
215
+ if (!callbackResult.success) {
216
+ spinner.fail(`CALLBACK FAILED: ${callbackResult.error}`);
217
+ if (loginResult.childProcess) loginResult.childProcess.kill();
218
+ await prompts.waitForEnter();
219
+ return false;
220
+ }
221
+
222
+ spinner.succeed('AUTHENTICATION SUCCESSFUL!');
223
+ } catch (err) {
224
+ spinner.fail(`ERROR: ${err.message}`);
212
225
  if (loginResult.childProcess) loginResult.childProcess.kill();
213
226
  await prompts.waitForEnter();
214
227
  return false;
215
228
  }
216
229
 
217
- spinner.succeed('AUTHENTICATION SUCCESSFUL!');
230
+ // Wait for token to be saved
231
+ await new Promise(r => setTimeout(r, 3000));
218
232
 
219
- // Wait for CLIProxyAPI to process the token
220
- await new Promise(r => setTimeout(r, 2000));
221
233
  } else {
222
234
  console.log(chalk.gray(' AFTER AUTHENTICATING, PRESS ENTER TO CONTINUE...'));
223
235
  await prompts.waitForEnter();
@@ -228,10 +240,20 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
228
240
  try { loginResult.childProcess.kill(); } catch (e) { /* ignore */ }
229
241
  }
230
242
 
243
+ // Restart CLIProxyAPI to load new tokens
244
+ console.log(chalk.gray(' RESTARTING CLIPROXYAPI...'));
245
+ await cliproxy.stop();
246
+ await new Promise(r => setTimeout(r, 1000));
247
+ await cliproxy.start();
248
+ await new Promise(r => setTimeout(r, 2000));
249
+
231
250
  // Try to fetch models after auth
251
+ const modelSpinner = ora({ text: 'FETCHING AVAILABLE MODELS...', color: 'yellow' }).start();
232
252
  const modelsResult = await cliproxy.fetchProviderModels(provider.id);
233
253
 
234
254
  if (modelsResult.success && modelsResult.models.length > 0) {
255
+ modelSpinner.succeed(`FOUND ${modelsResult.models.length} MODELS`);
256
+
235
257
  const selectedModel = await selectModelFromList(provider, modelsResult.models, boxWidth);
236
258
  if (selectedModel) {
237
259
  activateProvider(config, provider.id, {
@@ -245,6 +267,7 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
245
267
  }
246
268
  }
247
269
  } else {
270
+ modelSpinner.warn('NO MODELS FOUND - USING AUTO MODE');
248
271
  // No models but auth might have worked
249
272
  activateProvider(config, provider.id, {
250
273
  connectionType: 'cliproxy',
@@ -14,13 +14,16 @@ const {
14
14
  INSTALL_DIR,
15
15
  AUTH_DIR,
16
16
  DEFAULT_PORT,
17
+ CALLBACK_PORT,
17
18
  isInstalled,
19
+ isHeadless,
18
20
  install,
19
21
  isRunning,
20
22
  start,
21
23
  stop,
22
24
  ensureRunning,
23
- getLoginUrl
25
+ getLoginUrl,
26
+ processCallback
24
27
  } = manager;
25
28
 
26
29
  // Internal API key (must match config.yaml)
@@ -174,13 +177,16 @@ module.exports = {
174
177
  INSTALL_DIR,
175
178
  AUTH_DIR,
176
179
  DEFAULT_PORT,
180
+ CALLBACK_PORT,
177
181
  isInstalled,
182
+ isHeadless,
178
183
  install,
179
184
  isRunning,
180
185
  start,
181
186
  stop,
182
187
  ensureRunning,
183
188
  getLoginUrl,
189
+ processCallback,
184
190
 
185
191
  // API
186
192
  fetchLocal,
@@ -21,7 +21,8 @@ const INSTALL_DIR = path.join(os.homedir(), '.hqx', 'cliproxy');
21
21
  const BINARY_NAME = process.platform === 'win32' ? 'cli-proxy-api.exe' : 'cli-proxy-api';
22
22
  const BINARY_PATH = path.join(INSTALL_DIR, BINARY_NAME);
23
23
  const PID_FILE = path.join(INSTALL_DIR, 'cliproxy.pid');
24
- const AUTH_DIR = path.join(INSTALL_DIR, 'auths');
24
+ // Use default CLIProxyAPI auth directory (where -claude-login saves tokens)
25
+ const AUTH_DIR = path.join(os.homedir(), '.cli-proxy-api');
25
26
 
26
27
  // Default port
27
28
  const DEFAULT_PORT = 8317;
@@ -210,11 +211,10 @@ const isRunning = async () => {
210
211
  const CONFIG_PATH = path.join(INSTALL_DIR, 'config.yaml');
211
212
 
212
213
  /**
213
- * Create config file if not exists
214
+ * Create or update config file
214
215
  */
215
216
  const ensureConfig = () => {
216
- if (fs.existsSync(CONFIG_PATH)) return;
217
-
217
+ // Always write config to ensure auth-dir is correct
218
218
  const config = `# HQX CLIProxyAPI Config
219
219
  host: "127.0.0.1"
220
220
  port: ${DEFAULT_PORT}