hedgequantx 2.7.73 → 2.7.75

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.73",
3
+ "version": "2.7.75",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -141,21 +141,14 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
141
141
  console.log(chalk.green(' ✓ CLIPROXYAPI IS RUNNING'));
142
142
  }
143
143
 
144
- // Check if provider supports OAuth
145
- const oauthProviders = ['anthropic', 'openai', 'google', 'qwen'];
146
- if (!oauthProviders.includes(provider.id)) {
147
- // Try to fetch models directly
148
- console.log(chalk.gray(` CHECKING AVAILABLE MODELS FOR ${provider.name.toUpperCase()}...`));
149
- const modelsResult = await cliproxy.fetchProviderModels(provider.id);
150
-
151
- if (!modelsResult.success || modelsResult.models.length === 0) {
152
- console.log(chalk.red(` NO MODELS AVAILABLE FOR ${provider.name.toUpperCase()}`));
153
- console.log(chalk.gray(' THIS PROVIDER MAY REQUIRE API KEY CONNECTION.'));
154
- await prompts.waitForEnter();
155
- return false;
156
- }
157
-
158
- const selectedModel = await selectModelFromList(provider, modelsResult.models, boxWidth);
144
+ // First, check if models are already available (existing auth)
145
+ console.log(chalk.gray(` CHECKING EXISTING AUTHENTICATION...`));
146
+ const existingModels = await cliproxy.fetchProviderModels(provider.id);
147
+
148
+ if (existingModels.success && existingModels.models.length > 0) {
149
+ // Models already available - skip OAuth, go directly to model selection
150
+ console.log(chalk.green(` ✓ ALREADY AUTHENTICATED`));
151
+ const selectedModel = await selectModelFromList(provider, existingModels.models, boxWidth);
159
152
  if (!selectedModel) return false;
160
153
 
161
154
  activateProvider(config, provider.id, {
@@ -172,6 +165,15 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
172
165
  return true;
173
166
  }
174
167
 
168
+ // Check if provider supports OAuth
169
+ const oauthProviders = ['anthropic', 'openai', 'google', 'qwen'];
170
+ if (!oauthProviders.includes(provider.id)) {
171
+ console.log(chalk.red(` NO MODELS AVAILABLE FOR ${provider.name.toUpperCase()}`));
172
+ console.log(chalk.gray(' THIS PROVIDER MAY REQUIRE API KEY CONNECTION.'));
173
+ await prompts.waitForEnter();
174
+ return false;
175
+ }
176
+
175
177
  // OAuth flow - get login URL
176
178
  console.log(chalk.cyan(`\n STARTING OAUTH LOGIN FOR ${provider.name.toUpperCase()}...`));
177
179
  const loginResult = await cliproxy.getLoginUrl(provider.id);
@@ -222,19 +224,29 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
222
224
  spinner.text = 'EXCHANGING TOKEN...';
223
225
 
224
226
  // Wait for login process to exit naturally (it saves auth file then exits)
227
+ // Process typically exits 1-2 seconds after callback
225
228
  await new Promise((resolve) => {
226
229
  if (!loginResult.childProcess) return resolve();
227
230
 
228
- const timeout = setTimeout(() => {
229
- // Safety timeout after 15s - kill if still running
230
- try { loginResult.childProcess.kill(); } catch (e) { /* ignore */ }
231
- resolve();
232
- }, 15000);
233
-
234
- loginResult.childProcess.on('exit', () => {
235
- clearTimeout(timeout);
236
- resolve();
237
- });
231
+ // Check every 500ms if process is still running, max 15s
232
+ let elapsed = 0;
233
+ const checkInterval = setInterval(() => {
234
+ elapsed += 500;
235
+
236
+ // Check if process exited (exitCode is set when process exits)
237
+ if (loginResult.childProcess.exitCode !== null || loginResult.childProcess.killed) {
238
+ clearInterval(checkInterval);
239
+ resolve();
240
+ return;
241
+ }
242
+
243
+ // Safety timeout after 15s
244
+ if (elapsed >= 15000) {
245
+ clearInterval(checkInterval);
246
+ try { loginResult.childProcess.kill(); } catch (e) { /* ignore */ }
247
+ resolve();
248
+ }
249
+ }, 500);
238
250
  });
239
251
 
240
252
  spinner.succeed('AUTHENTICATION SUCCESSFUL!');