hedgequantx 2.6.96 → 2.6.97
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 +1 -1
- package/src/menus/ai-agent.js +56 -49
package/package.json
CHANGED
package/src/menus/ai-agent.js
CHANGED
|
@@ -838,8 +838,8 @@ const setupOAuthConnection = async (provider) => {
|
|
|
838
838
|
};
|
|
839
839
|
|
|
840
840
|
/**
|
|
841
|
-
* Setup OAuth via
|
|
842
|
-
*
|
|
841
|
+
* Setup OAuth via Manual Code Entry (for VPS/Server users)
|
|
842
|
+
* User copies the authorization code from the browser
|
|
843
843
|
*/
|
|
844
844
|
const setupRemoteOAuth = async (provider, config) => {
|
|
845
845
|
const boxWidth = getLogoWidth();
|
|
@@ -851,45 +851,31 @@ const setupRemoteOAuth = async (provider, config) => {
|
|
|
851
851
|
return chalk.cyan('║') + ' ' + content + ' '.repeat(Math.max(0, padding - 1)) + chalk.cyan('║');
|
|
852
852
|
};
|
|
853
853
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
console.log(makeLine(chalk.yellow('REMOTE AUTHENTICATION (VPS/SERVER)')));
|
|
859
|
-
console.log(makeLine(''));
|
|
860
|
-
console.log(makeLine(chalk.white('CREATING SECURE SESSION...')));
|
|
861
|
-
|
|
862
|
-
drawBoxFooter(boxWidth);
|
|
863
|
-
|
|
864
|
-
const spinner = ora({ text: 'Creating OAuth session...', color: 'cyan' }).start();
|
|
865
|
-
|
|
866
|
-
let sessionData;
|
|
867
|
-
try {
|
|
868
|
-
sessionData = await proxyManager.createRemoteSession(provider.id);
|
|
869
|
-
} catch (error) {
|
|
870
|
-
spinner.fail(`Failed to create session: ${error.message}`);
|
|
871
|
-
await prompts.waitForEnter();
|
|
872
|
-
return await selectProviderOption(provider);
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
spinner.stop();
|
|
854
|
+
// Generate OAuth URL using the existing oauth module
|
|
855
|
+
const authResult = oauthAnthropic.authorize('max');
|
|
856
|
+
const url = authResult.url;
|
|
857
|
+
const verifier = authResult.verifier;
|
|
876
858
|
|
|
877
|
-
// Show
|
|
859
|
+
// Show instructions
|
|
878
860
|
console.clear();
|
|
879
861
|
displayBanner();
|
|
880
|
-
drawBoxHeaderContinue(`CONNECT ${config.name}`, boxWidth);
|
|
862
|
+
drawBoxHeaderContinue(`CONNECT ${config.name} (VPS MODE)`, boxWidth);
|
|
881
863
|
|
|
882
|
-
console.log(makeLine(chalk.yellow('
|
|
864
|
+
console.log(makeLine(chalk.yellow('MANUAL AUTHORIZATION')));
|
|
883
865
|
console.log(makeLine(''));
|
|
884
866
|
console.log(makeLine(chalk.white('1. OPEN THE LINK BELOW IN ANY BROWSER')));
|
|
885
867
|
console.log(makeLine(chalk.white(' (Phone, laptop, any device)')));
|
|
886
868
|
console.log(makeLine(''));
|
|
887
869
|
console.log(makeLine(chalk.white(`2. LOGIN WITH YOUR ${config.accountName.toUpperCase()} ACCOUNT`)));
|
|
888
870
|
console.log(makeLine(''));
|
|
889
|
-
console.log(makeLine(chalk.white('3. AUTHORIZE
|
|
871
|
+
console.log(makeLine(chalk.white('3. CLICK "AUTHORIZE"')));
|
|
872
|
+
console.log(makeLine(''));
|
|
873
|
+
console.log(makeLine(chalk.green('4. COPY THE CODE SHOWN ON SCREEN')));
|
|
874
|
+
console.log(makeLine(chalk.white(' (Format: abc123...#xyz789...)')));
|
|
890
875
|
console.log(makeLine(''));
|
|
891
|
-
console.log(makeLine(chalk.
|
|
876
|
+
console.log(makeLine(chalk.white('5. PASTE THE CODE BELOW')));
|
|
892
877
|
console.log(makeLine(''));
|
|
878
|
+
console.log(makeLine(chalk.white('TYPE < TO CANCEL')));
|
|
893
879
|
|
|
894
880
|
drawBoxFooter(boxWidth);
|
|
895
881
|
|
|
@@ -897,40 +883,61 @@ const setupRemoteOAuth = async (provider, config) => {
|
|
|
897
883
|
console.log();
|
|
898
884
|
console.log(chalk.yellow(' OPEN THIS URL IN YOUR BROWSER:'));
|
|
899
885
|
console.log();
|
|
900
|
-
console.log(chalk.cyan(` ${
|
|
886
|
+
console.log(chalk.cyan(` ${url}`));
|
|
901
887
|
console.log();
|
|
902
888
|
|
|
903
|
-
//
|
|
904
|
-
const
|
|
889
|
+
// Get code from user
|
|
890
|
+
const code = await prompts.textInput(chalk.cyan('PASTE AUTHORIZATION CODE:'));
|
|
905
891
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
892
|
+
if (!code || code.trim() === '<' || code.trim() === '') {
|
|
893
|
+
return await selectProviderOption(provider);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
// Exchange code for tokens
|
|
897
|
+
const spinner = ora({ text: 'Exchanging code for tokens...', color: 'cyan' }).start();
|
|
898
|
+
|
|
899
|
+
const result = await oauthAnthropic.exchange(code.trim(), verifier);
|
|
900
|
+
|
|
901
|
+
if (result.type === 'failed') {
|
|
902
|
+
spinner.fail(`Authentication failed: ${result.error || 'Invalid code'}`);
|
|
913
903
|
await prompts.waitForEnter();
|
|
914
904
|
return await selectProviderOption(provider);
|
|
915
905
|
}
|
|
916
906
|
|
|
917
|
-
|
|
907
|
+
spinner.succeed('Authorization successful!');
|
|
918
908
|
|
|
919
909
|
// Save credentials
|
|
920
910
|
const credentials = {
|
|
921
911
|
oauth: {
|
|
922
|
-
access:
|
|
923
|
-
refresh:
|
|
924
|
-
expires:
|
|
925
|
-
|
|
926
|
-
|
|
912
|
+
access: result.access,
|
|
913
|
+
refresh: result.refresh,
|
|
914
|
+
expires: result.expires,
|
|
915
|
+
apiKey: result.apiKey,
|
|
916
|
+
email: result.email
|
|
917
|
+
}
|
|
927
918
|
};
|
|
928
919
|
|
|
929
|
-
//
|
|
930
|
-
|
|
931
|
-
|
|
920
|
+
// Try to fetch models with the new token
|
|
921
|
+
spinner.text = 'Fetching available models...';
|
|
922
|
+
spinner.start();
|
|
932
923
|
|
|
933
|
-
|
|
924
|
+
let models = [];
|
|
925
|
+
try {
|
|
926
|
+
const { fetchAnthropicModelsOAuth } = require('../services/ai/client');
|
|
927
|
+
models = await fetchAnthropicModelsOAuth(result.access);
|
|
928
|
+
} catch (e) {
|
|
929
|
+
// Ignore - will use defaults
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// Use defaults if API doesn't return models
|
|
933
|
+
if (!models || models.length === 0) {
|
|
934
|
+
models = getDefaultModelsForProvider(provider.id);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
spinner.succeed(`Found ${models.length} models`);
|
|
938
|
+
|
|
939
|
+
// Let user select model
|
|
940
|
+
const selectedModel = await selectModelFromList(models, config.name);
|
|
934
941
|
if (!selectedModel) {
|
|
935
942
|
return await selectProviderOption(provider);
|
|
936
943
|
}
|