hedgequantx 2.7.42 → 2.7.44

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.42",
3
+ "version": "2.7.44",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -57,27 +57,45 @@ const draw2ColTable = (title, titleColor, items, backText, W) => {
57
57
  console.log(chalk.cyan('╚' + '═'.repeat(W) + '╝'));
58
58
  };
59
59
 
60
+ /**
61
+ * Draw centered 2-column row
62
+ * @param {string} leftText - Left column text
63
+ * @param {string} rightText - Right column text
64
+ * @param {number} W - Inner width
65
+ */
66
+ const draw2ColRowCentered = (leftText, rightText, W) => {
67
+ const colWidth = Math.floor(W / 2);
68
+ const leftLen = visibleLength(leftText);
69
+ const rightLen = visibleLength(rightText || '');
70
+
71
+ // Center left text in left column
72
+ const leftPadTotal = colWidth - leftLen;
73
+ const leftPadL = Math.floor(leftPadTotal / 2);
74
+ const leftPadR = leftPadTotal - leftPadL;
75
+ const leftCol = ' '.repeat(Math.max(0, leftPadL)) + leftText + ' '.repeat(Math.max(0, leftPadR));
76
+
77
+ // Center right text in right column
78
+ const rightColWidth = W - colWidth;
79
+ const rightPadTotal = rightColWidth - rightLen;
80
+ const rightPadL = Math.floor(rightPadTotal / 2);
81
+ const rightPadR = rightPadTotal - rightPadL;
82
+ const rightCol = ' '.repeat(Math.max(0, rightPadL)) + (rightText || '') + ' '.repeat(Math.max(0, rightPadR));
83
+
84
+ console.log(chalk.cyan('║') + leftCol + rightCol + chalk.cyan('║'));
85
+ };
86
+
60
87
  /**
61
88
  * Draw providers table
62
89
  * @param {Array} providers - List of AI providers
63
90
  * @param {Object} config - Current config
64
91
  * @param {number} boxWidth - Box width
65
- * @param {string} cliproxyUrl - Current CLIProxy URL (optional)
66
92
  */
67
- const drawProvidersTable = (providers, config, boxWidth, cliproxyUrl = null) => {
93
+ const drawProvidersTable = (providers, config, boxWidth) => {
68
94
  const W = boxWidth - 2;
69
95
 
70
96
  // New rectangle (banner is always closed)
71
97
  console.log(chalk.cyan('╔' + '═'.repeat(W) + '╗'));
72
98
  console.log(chalk.cyan('║') + chalk.yellow.bold(centerText('AI AGENTS CONFIGURATION', W)) + chalk.cyan('║'));
73
-
74
- // Show CLIProxy URL if provided
75
- if (cliproxyUrl) {
76
- console.log(chalk.cyan('╠' + '─'.repeat(W) + '╣'));
77
- const proxyText = chalk.gray('CLIProxy: ') + chalk.cyan(cliproxyUrl);
78
- console.log(chalk.cyan('║') + centerText(proxyText, W) + chalk.cyan('║'));
79
- }
80
-
81
99
  console.log(chalk.cyan('╠' + '═'.repeat(W) + '╣'));
82
100
 
83
101
  const items = providers.map((p, i) => {
@@ -89,11 +107,9 @@ const drawProvidersTable = (providers, config, boxWidth, cliproxyUrl = null) =>
89
107
  for (let row = 0; row < rows; row++) {
90
108
  const left = items[row];
91
109
  const right = items[row + rows];
92
- draw2ColRow(left || '', right || '', W);
110
+ draw2ColRowCentered(left || '', right || '', W);
93
111
  }
94
112
 
95
- console.log(chalk.cyan('╠' + '─'.repeat(W) + '╣'));
96
- console.log(chalk.cyan('║') + chalk.gray(centerText('[S] CLIPROXY STATUS', W)) + chalk.cyan('║'));
97
113
  console.log(chalk.cyan('╠' + '─'.repeat(W) + '╣'));
98
114
  console.log(chalk.cyan('║') + chalk.red(centerText('[B] BACK TO MENU', W)) + chalk.cyan('║'));
99
115
  console.log(chalk.cyan('╚' + '═'.repeat(W) + '╝'));
@@ -250,6 +250,7 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
250
250
  restartSpinner.text = 'WAITING FOR CLIPROXYAPI TO LOAD TOKENS...';
251
251
  let modelsResult = { success: false, models: [] };
252
252
 
253
+ let foundModels = false;
253
254
  for (let i = 0; i < 15; i++) {
254
255
  await new Promise(r => setTimeout(r, 2000));
255
256
  restartSpinner.text = `LOADING MODELS (${i + 1}/15)...`;
@@ -260,13 +261,19 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
260
261
  modelsResult = await cliproxy.fetchProviderModels(provider.id);
261
262
  if (modelsResult.success && modelsResult.models.length > 0) {
262
263
  restartSpinner.succeed(`CLIPROXYAPI READY - ${modelsResult.models.length} MODELS FOUND`);
264
+ foundModels = true;
263
265
  break;
264
266
  }
265
267
  }
266
268
  }
267
269
 
270
+ // Stop spinner if still running (no models found after 15 tries)
271
+ if (!foundModels) {
272
+ restartSpinner.warn('NO MODELS FOUND - USING AUTO MODE');
273
+ }
274
+
268
275
  // Show model selection or fallback to auto
269
- if (modelsResult.success && modelsResult.models.length > 0) {
276
+ if (foundModels && modelsResult.models.length > 0) {
270
277
  const selectedModel = await selectModelFromList(provider, modelsResult.models, boxWidth);
271
278
  if (selectedModel) {
272
279
  activateProvider(config, provider.id, {
@@ -278,17 +285,19 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
278
285
  console.log(chalk.green(`\n ✓ ${provider.name.toUpperCase()} CONNECTED VIA PAID PLAN`));
279
286
  console.log(chalk.cyan(` MODEL: ${selectedModel.name.toUpperCase()}`));
280
287
  }
288
+ await prompts.waitForEnter();
289
+ return true;
281
290
  }
282
- } else {
283
- // No models but auth might have worked
284
- activateProvider(config, provider.id, {
285
- connectionType: 'cliproxy',
286
- modelId: null,
287
- modelName: 'AUTO'
288
- });
289
- if (saveConfig(config)) {
290
- console.log(chalk.green(`\n ${provider.name.toUpperCase()} CONNECTED VIA PAID PLAN (AUTO MODE)`));
291
- }
291
+ }
292
+
293
+ // No models or user cancelled - use auto mode
294
+ activateProvider(config, provider.id, {
295
+ connectionType: 'cliproxy',
296
+ modelId: null,
297
+ modelName: 'AUTO'
298
+ });
299
+ if (saveConfig(config)) {
300
+ console.log(chalk.green(`\n ✓ ${provider.name.toUpperCase()} CONNECTED VIA PAID PLAN (AUTO MODE)`));
292
301
  }
293
302
 
294
303
  await prompts.waitForEnter();
@@ -392,26 +401,6 @@ const getActiveProvider = () => {
392
401
  /** Count active AI agents */
393
402
  const getActiveAgentCount = () => getActiveProvider() ? 1 : 0;
394
403
 
395
- /** Show CLIProxy status */
396
- const showCliProxyStatus = async () => {
397
- clearWithBanner();
398
- console.log(chalk.yellow('\n CLIPROXYAPI STATUS\n'));
399
-
400
- const installed = cliproxy.isInstalled();
401
- console.log(chalk.gray(' INSTALLED: ') + (installed ? chalk.green('YES') : chalk.red('NO')));
402
-
403
- if (installed) {
404
- const status = await cliproxy.isRunning();
405
- console.log(chalk.gray(' RUNNING: ') + (status.running ? chalk.green('YES') : chalk.red('NO')));
406
- console.log(chalk.gray(' VERSION: ') + chalk.cyan(cliproxy.CLIPROXY_VERSION));
407
- console.log(chalk.gray(' PORT: ') + chalk.cyan(cliproxy.DEFAULT_PORT));
408
- console.log(chalk.gray(' INSTALL DIR: ') + chalk.cyan(cliproxy.INSTALL_DIR));
409
- }
410
-
411
- console.log();
412
- await prompts.waitForEnter();
413
- };
414
-
415
404
  /** Main AI Agents menu */
416
405
  const aiAgentsMenu = async () => {
417
406
  let config = loadConfig();
@@ -419,20 +408,13 @@ const aiAgentsMenu = async () => {
419
408
 
420
409
  while (true) {
421
410
  clearWithBanner();
422
- const status = await cliproxy.isRunning();
423
- const statusText = status.running ? `LOCALHOST:${cliproxy.DEFAULT_PORT}` : 'NOT RUNNING';
424
- drawProvidersTable(AI_PROVIDERS, config, boxWidth, statusText);
411
+ drawProvidersTable(AI_PROVIDERS, config, boxWidth);
425
412
 
426
- const input = await prompts.textInput(chalk.cyan('SELECT (1-8/S/B): '));
413
+ const input = await prompts.textInput(chalk.cyan('SELECT (1-8/B): '));
427
414
  const choice = (input || '').toLowerCase().trim();
428
415
 
429
416
  if (choice === 'b' || choice === '') break;
430
417
 
431
- if (choice === 's') {
432
- await showCliProxyStatus();
433
- continue;
434
- }
435
-
436
418
  const num = parseInt(choice);
437
419
  if (!isNaN(num) && num >= 1 && num <= AI_PROVIDERS.length) {
438
420
  config = await handleProviderConfig(AI_PROVIDERS[num - 1], config);