hedgequantx 2.6.119 → 2.6.120

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.119",
3
+ "version": "2.6.120",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -1104,71 +1104,82 @@ const setupProxyOAuth = async (provider, config) => {
1104
1104
  return await selectProviderOption(provider);
1105
1105
  }
1106
1106
 
1107
- // Step 5: Fetch models from CLIProxyAPI
1108
- const modelSpinner = ora({ text: 'Fetching available models from API...', color: 'cyan' }).start();
1109
-
1110
- let models = [];
1107
+ // Wrap entire post-auth flow in try-catch to catch any uncaught errors
1111
1108
  try {
1112
- models = await proxyManager.getModels();
1113
- modelSpinner.succeed(`Found ${models.length} models`);
1114
- } catch (error) {
1115
- modelSpinner.fail(`Failed to fetch models: ${error.message}`);
1109
+ // Step 5: Fetch models from CLIProxyAPI
1110
+ const modelSpinner = ora({ text: 'Fetching available models from API...', color: 'cyan' }).start();
1111
+
1112
+ let models = [];
1113
+ try {
1114
+ models = await proxyManager.getModels();
1115
+ modelSpinner.succeed(`Found ${models.length} models`);
1116
+ } catch (error) {
1117
+ modelSpinner.fail(`Failed to fetch models: ${error.message}`);
1118
+ await prompts.waitForEnter();
1119
+ return await selectProviderOption(provider);
1120
+ }
1121
+
1122
+ // Filter models for this provider
1123
+ const providerPrefixes = {
1124
+ anthropic: ['claude'],
1125
+ openai: ['gpt', 'o1', 'o3', 'o4'],
1126
+ gemini: ['gemini'],
1127
+ qwen: ['qwen'],
1128
+ iflow: ['deepseek', 'kimi', 'glm']
1129
+ };
1130
+
1131
+ const prefixes = providerPrefixes[provider.id] || [];
1132
+ const filteredModels = models.filter(m => {
1133
+ const modelLower = m.toLowerCase();
1134
+ return prefixes.some(p => modelLower.includes(p));
1135
+ });
1136
+
1137
+ // Use filtered models if available, otherwise use all models
1138
+ const availableModels = filteredModels.length > 0 ? filteredModels : models;
1139
+
1140
+ if (!availableModels || availableModels.length === 0) {
1141
+ console.log();
1142
+ console.log(chalk.red(' ERROR: No models found for this provider'));
1143
+ console.log(chalk.gray(' Make sure your subscription is active.'));
1144
+ console.log();
1145
+ await prompts.waitForEnter();
1146
+ return await selectProviderOption(provider);
1147
+ }
1148
+
1149
+ // Step 6: Let user select model
1150
+ const selectedModel = await selectModelFromList(availableModels, config.name);
1151
+ if (!selectedModel) {
1152
+ return await selectProviderOption(provider);
1153
+ }
1154
+
1155
+ // Step 7: Save agent config (CLIProxyAPI stores the actual tokens)
1156
+ // We just save a reference to use the proxy
1157
+ const credentials = {
1158
+ useProxy: true,
1159
+ provider: provider.id
1160
+ };
1161
+
1162
+ try {
1163
+ await aiService.addAgent(provider.id, config.optionId, credentials, selectedModel, config.agentName);
1164
+
1165
+ console.log(chalk.green(`\n CONNECTED TO ${config.name}`));
1166
+ console.log(chalk.white(` MODEL: ${selectedModel}`));
1167
+ console.log(chalk.white(' UNLIMITED USAGE WITH YOUR SUBSCRIPTION'));
1168
+ } catch (error) {
1169
+ console.log(chalk.red(`\n FAILED TO SAVE: ${error.message}`));
1170
+ }
1171
+
1116
1172
  await prompts.waitForEnter();
1117
- return await selectProviderOption(provider);
1118
- }
1119
-
1120
- // Filter models for this provider
1121
- const providerPrefixes = {
1122
- anthropic: ['claude'],
1123
- openai: ['gpt', 'o1', 'o3', 'o4'],
1124
- gemini: ['gemini'],
1125
- qwen: ['qwen'],
1126
- iflow: ['deepseek', 'kimi', 'glm']
1127
- };
1128
-
1129
- const prefixes = providerPrefixes[provider.id] || [];
1130
- const filteredModels = models.filter(m => {
1131
- const modelLower = m.toLowerCase();
1132
- return prefixes.some(p => modelLower.includes(p));
1133
- });
1134
-
1135
- // Use filtered models if available, otherwise use all models
1136
- const availableModels = filteredModels.length > 0 ? filteredModels : models;
1137
-
1138
- if (!availableModels || availableModels.length === 0) {
1173
+ return await aiAgentMenu();
1174
+ } catch (unexpectedError) {
1175
+ // Catch any uncaught errors in the post-auth flow
1139
1176
  console.log();
1140
- console.log(chalk.red(' ERROR: No models found for this provider'));
1141
- console.log(chalk.gray(' Make sure your subscription is active.'));
1177
+ console.log(chalk.red(` UNEXPECTED ERROR: ${unexpectedError.message}`));
1178
+ console.log(chalk.gray(` Stack: ${unexpectedError.stack}`));
1142
1179
  console.log();
1143
1180
  await prompts.waitForEnter();
1144
1181
  return await selectProviderOption(provider);
1145
1182
  }
1146
-
1147
- // Step 6: Let user select model
1148
- const selectedModel = await selectModelFromList(availableModels, config.name);
1149
- if (!selectedModel) {
1150
- return await selectProviderOption(provider);
1151
- }
1152
-
1153
- // Step 7: Save agent config (CLIProxyAPI stores the actual tokens)
1154
- // We just save a reference to use the proxy
1155
- const credentials = {
1156
- useProxy: true,
1157
- provider: provider.id
1158
- };
1159
-
1160
- try {
1161
- await aiService.addAgent(provider.id, config.optionId, credentials, selectedModel, config.agentName);
1162
-
1163
- console.log(chalk.green(`\n CONNECTED TO ${config.name}`));
1164
- console.log(chalk.white(` MODEL: ${selectedModel}`));
1165
- console.log(chalk.white(' UNLIMITED USAGE WITH YOUR SUBSCRIPTION'));
1166
- } catch (error) {
1167
- console.log(chalk.red(`\n FAILED TO SAVE: ${error.message}`));
1168
- }
1169
-
1170
- await prompts.waitForEnter();
1171
- return await aiAgentMenu();
1172
1183
  };
1173
1184
 
1174
1185
  /**