hedgequantx 2.6.98 → 2.6.99

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.6.98",
3
+ "version": "2.6.99",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -782,9 +782,7 @@ const getOAuthConfig = (providerId) => {
782
782
 
783
783
  /**
784
784
  * Setup OAuth connection for any provider with OAuth support
785
- * Automatically detects environment and uses the appropriate method:
786
- * - Local (PC/Mac): Uses CLIProxyAPI for automatic token management
787
- * - Remote (VPS/Server): Uses cli.hedgequantx.com as OAuth relay
785
+ * Unified flow: copy code from URL (works on local and VPS)
788
786
  */
789
787
  const setupOAuthConnection = async (provider) => {
790
788
  const config = getOAuthConfig(provider.id);
@@ -794,47 +792,8 @@ const setupOAuthConnection = async (provider) => {
794
792
  return await selectProviderOption(provider);
795
793
  }
796
794
 
797
- // Check if we can open a browser locally
798
- const canUseBrowser = proxyManager.canOpenBrowser();
799
- const isServer = proxyManager.isServerEnvironment();
800
-
801
- // If on server or can't open browser, use remote OAuth
802
- if (isServer || !canUseBrowser) {
803
- // Only anthropic is supported for remote OAuth currently
804
- if (provider.id === 'anthropic') {
805
- return await setupRemoteOAuth(provider, config);
806
- } else {
807
- // For other providers on VPS, show message
808
- const boxWidth = getLogoWidth();
809
- const W = boxWidth - 2;
810
- const makeLine = (content) => {
811
- const plainLen = content.replace(/\x1b\[[0-9;]*m/g, '').length;
812
- const padding = W - plainLen;
813
- return chalk.cyan('║') + ' ' + content + ' '.repeat(Math.max(0, padding - 1)) + chalk.cyan('║');
814
- };
815
-
816
- console.clear();
817
- displayBanner();
818
- drawBoxHeaderContinue('SERVER DETECTED', boxWidth);
819
-
820
- console.log(makeLine(chalk.yellow('VPS/SERVER ENVIRONMENT DETECTED')));
821
- console.log(makeLine(''));
822
- console.log(makeLine(chalk.white('OAuth for this provider requires a browser.')));
823
- console.log(makeLine(''));
824
- console.log(makeLine(chalk.white('OPTIONS:')));
825
- console.log(makeLine(chalk.cyan('1. Use Claude (supports remote OAuth)')));
826
- console.log(makeLine(chalk.cyan('2. Use API Key instead of OAuth')));
827
- console.log(makeLine(chalk.cyan('3. Run this on a local machine first')));
828
- console.log(makeLine(''));
829
-
830
- drawBoxFooter(boxWidth);
831
- await prompts.waitForEnter();
832
- return await selectProviderOption(provider);
833
- }
834
- }
835
-
836
- // Local machine - use CLIProxyAPI
837
- return await setupProxyOAuth(provider, config);
795
+ // Use unified manual flow for all providers and environments
796
+ return await setupRemoteOAuth(provider, config);
838
797
  };
839
798
 
840
799
  /**
@@ -851,8 +810,24 @@ const setupRemoteOAuth = async (provider, config) => {
851
810
  return chalk.cyan('║') + ' ' + content + ' '.repeat(Math.max(0, padding - 1)) + chalk.cyan('║');
852
811
  };
853
812
 
854
- // Generate OAuth URL using the existing oauth module
855
- const authResult = oauthAnthropic.authorize('max');
813
+ // Get the right OAuth module for this provider
814
+ const oauthModules = {
815
+ anthropic: oauthAnthropic,
816
+ openai: oauthOpenai,
817
+ gemini: oauthGemini,
818
+ qwen: oauthQwen,
819
+ iflow: oauthIflow
820
+ };
821
+
822
+ const oauthModule = oauthModules[provider.id];
823
+ if (!oauthModule) {
824
+ console.log(chalk.red(`OAuth not supported for ${provider.id}`));
825
+ await prompts.waitForEnter();
826
+ return await selectProviderOption(provider);
827
+ }
828
+
829
+ // Generate OAuth URL using the provider's oauth module
830
+ const authResult = oauthModule.authorize(config.optionId || 'max');
856
831
  const url = authResult.url;
857
832
  const verifier = authResult.verifier;
858
833
 
@@ -895,7 +870,7 @@ const setupRemoteOAuth = async (provider, config) => {
895
870
  // Exchange code for tokens
896
871
  const spinner = ora({ text: 'Exchanging code for tokens...', color: 'cyan' }).start();
897
872
 
898
- const result = await oauthAnthropic.exchange(code.trim(), verifier);
873
+ const result = await oauthModule.exchange(code.trim(), verifier);
899
874
 
900
875
  if (result.type === 'failed') {
901
876
  spinner.fail(`Authentication failed: ${result.error || 'Invalid code'}`);
@@ -922,8 +897,8 @@ const setupRemoteOAuth = async (provider, config) => {
922
897
 
923
898
  let models = [];
924
899
  try {
925
- const { fetchAnthropicModelsOAuth } = require('../services/ai/client');
926
- models = await fetchAnthropicModelsOAuth(result.access);
900
+ const { fetchModelsWithOAuth } = require('../services/ai/client');
901
+ models = await fetchModelsWithOAuth(provider.id, result.access);
927
902
  } catch (e) {
928
903
  // Ignore - will use defaults
929
904
  }