hedgequantx 2.8.1 → 2.8.3

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.8.1",
3
+ "version": "2.8.3",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -92,8 +92,9 @@ const draw2ColRowCentered = (leftText, rightText, W) => {
92
92
  * @param {Array} providers - List of AI providers
93
93
  * @param {Object} config - Current config
94
94
  * @param {number} boxWidth - Box width
95
+ * @param {boolean} showTest - Show [T] TEST option
95
96
  */
96
- const drawProvidersTable = (providers, config, boxWidth) => {
97
+ const drawProvidersTable = (providers, config, boxWidth, showTest = false) => {
97
98
  const W = boxWidth - 2;
98
99
  const colWidth = Math.floor(W / 2);
99
100
 
@@ -158,6 +159,12 @@ const drawProvidersTable = (providers, config, boxWidth) => {
158
159
  console.log(chalk.cyan('║') + leftCol + rightCol + chalk.cyan('║'));
159
160
  }
160
161
 
162
+ // Show [T] TEST option if agents are configured
163
+ if (showTest) {
164
+ console.log(chalk.cyan('╠' + '─'.repeat(W) + '╣'));
165
+ console.log(chalk.cyan('║') + chalk.green(centerText('[T] TEST ALL CONNECTIONS', W)) + chalk.cyan('║'));
166
+ }
167
+
161
168
  console.log(chalk.cyan('╠' + '─'.repeat(W) + '╣'));
162
169
  console.log(chalk.cyan('║') + chalk.red(centerText('[B] BACK TO MENU', W)) + chalk.cyan('║'));
163
170
  console.log(chalk.cyan('╚' + '═'.repeat(W) + '╝'));
@@ -309,24 +316,33 @@ const drawConnectionTest = async (agents, boxWidth, clearWithBanner) => {
309
316
  return { success: false, error: 'No agents' };
310
317
  }
311
318
 
312
- clearWithBanner();
313
319
  const W = boxWidth - 2;
314
320
 
321
+ // Show loading state with complete box
322
+ clearWithBanner();
315
323
  console.log(chalk.cyan('╔' + '═'.repeat(W) + '╗'));
316
324
  console.log(chalk.cyan('║') + chalk.yellow.bold(centerText('AI AGENTS CONNECTION TEST', W)) + chalk.cyan('║'));
317
325
  console.log(chalk.cyan('╠' + '═'.repeat(W) + '╣'));
326
+ const loadingText = ' Testing connections... Please wait';
327
+ console.log(chalk.cyan('║') + chalk.yellow(loadingText) + ' '.repeat(W - loadingText.length) + chalk.cyan('║'));
318
328
  console.log(chalk.cyan('║') + ' '.repeat(W) + chalk.cyan('║'));
329
+ console.log(chalk.cyan('╚' + '═'.repeat(W) + '╝'));
319
330
 
320
- // Run pre-flight check
321
- const spinner = ora({ text: 'Testing connections...', color: 'yellow' }).start();
331
+ // Run pre-flight check (no spinner, box stays complete)
322
332
  const results = await runPreflightCheck(agents);
323
- spinner.stop();
333
+
334
+ // Clear and redraw with results
335
+ clearWithBanner();
336
+ console.log(chalk.cyan('╔' + '═'.repeat(W) + '╗'));
337
+ console.log(chalk.cyan('║') + chalk.yellow.bold(centerText('AI AGENTS CONNECTION TEST', W)) + chalk.cyan('║'));
338
+ console.log(chalk.cyan('╠' + '═'.repeat(W) + '╣'));
324
339
 
325
340
  // Display results
326
341
  const lines = formatPreflightResults(results, boxWidth);
327
342
  for (const line of lines) {
328
- const paddedLine = line.length < W - 1 ? line + ' '.repeat(W - 1 - visibleLength(line)) : line;
329
- console.log(chalk.cyan('║') + ' ' + paddedLine + chalk.cyan('║'));
343
+ const lineLen = visibleLength(line);
344
+ const padding = Math.max(0, W - lineLen);
345
+ console.log(chalk.cyan('║') + line + ' '.repeat(padding) + chalk.cyan('║'));
330
346
  }
331
347
 
332
348
  // Summary
@@ -439,13 +439,8 @@ const aiAgentsMenu = async () => {
439
439
 
440
440
  while (true) {
441
441
  clearWithBanner();
442
- drawProvidersTable(AI_PROVIDERS, config, boxWidth);
443
-
444
- // Show [T] TEST option if agents are configured
445
442
  const agentCount = getActiveAgentCount();
446
- if (agentCount > 0) {
447
- console.log(chalk.cyan(' [T] TEST ALL CONNECTIONS'));
448
- }
443
+ drawProvidersTable(AI_PROVIDERS, config, boxWidth, agentCount > 0);
449
444
  console.log();
450
445
 
451
446
  const promptText = agentCount > 0 ? 'SELECT (1-8/T/B): ' : 'SELECT (1-8/B): ';
@@ -15,8 +15,8 @@ const cliproxy = require('../cliproxy');
15
15
  const TEST_PROMPT = `You are being tested. Respond ONLY with this exact JSON, nothing else:
16
16
  {"decision":"approve","confidence":100,"reason":"test-ok"}`;
17
17
 
18
- /** Timeout for agent response (agents should respond in < 1 second) */
19
- const AGENT_TIMEOUT = 2000;
18
+ /** Timeout for agent response (increased for slower providers like Gemini) */
19
+ const AGENT_TIMEOUT = 15000;
20
20
 
21
21
  /**
22
22
  * Check if CLIProxy is running and responding
@@ -211,19 +211,27 @@ const runPreflightCheck = async (agents) => {
211
211
  const formatPreflightResults = (results, boxWidth) => {
212
212
  const chalk = require('chalk');
213
213
  const lines = [];
214
- const W = boxWidth - 2;
214
+ const W = boxWidth - 4; // Account for borders and padding
215
+
216
+ // Helper to create dotted line with proper alignment
217
+ const dottedLine = (label, value, labelPad = 3) => {
218
+ const valueLen = value.replace(/\x1b\[[0-9;]*m/g, '').length; // Strip ANSI
219
+ const labelLen = label.length;
220
+ const dotsLen = W - labelPad - labelLen - valueLen - 1;
221
+ return ' '.repeat(labelPad) + chalk.white(label) + chalk.gray('.'.repeat(Math.max(3, dotsLen))) + value;
222
+ };
215
223
 
216
224
  // CLIProxy status
217
225
  if (results.cliproxy.success) {
218
- lines.push(chalk.white(' CLIProxy Status') + chalk.gray('.'.repeat(Math.max(1, W - 35))) + chalk.green(' ✓ RUNNING'));
226
+ lines.push(dottedLine('CLIProxy Status', chalk.green('✓ RUNNING')));
219
227
  } else {
220
- lines.push(chalk.white(' CLIProxy Status') + chalk.gray('.'.repeat(Math.max(1, W - 35))) + chalk.red(' ✗ NOT RUNNING'));
221
- lines.push(chalk.red(` Error: ${results.cliproxy.error}`));
228
+ lines.push(dottedLine('CLIProxy Status', chalk.red('✗ NOT RUNNING')));
229
+ lines.push(chalk.red(` Error: ${results.cliproxy.error}`));
222
230
  return lines;
223
231
  }
224
232
 
225
233
  lines.push('');
226
- lines.push(chalk.white(` Testing ${results.summary.total} agent(s):`));
234
+ lines.push(chalk.white(` Testing ${results.summary.total} agent(s):`));
227
235
  lines.push('');
228
236
 
229
237
  // Each agent
@@ -231,15 +239,15 @@ const formatPreflightResults = (results, boxWidth) => {
231
239
  const agent = results.agents[i];
232
240
  const num = `[${i + 1}/${results.summary.total}]`;
233
241
 
234
- lines.push(chalk.cyan(` ${num} ${agent.name} (${agent.modelId || agent.provider})`));
242
+ lines.push(chalk.cyan(` ${num} ${agent.name} (${agent.modelId || agent.provider})`));
235
243
 
236
244
  if (agent.success) {
237
- const latencyStr = `${agent.latency}ms`;
238
- lines.push(chalk.gray(' Connection') + chalk.gray('.'.repeat(Math.max(1, W - 40))) + chalk.green(` ✓ OK ${latencyStr}`));
239
- lines.push(chalk.gray(' Format') + chalk.gray('.'.repeat(Math.max(1, W - 36))) + chalk.green(' ✓ VALID'));
245
+ const latencyStr = `✓ OK ${agent.latency}ms`;
246
+ lines.push(dottedLine('Connection', chalk.green(latencyStr), 9));
247
+ lines.push(dottedLine('Format', chalk.green('✓ VALID'), 9));
240
248
  } else {
241
- lines.push(chalk.gray(' Connection') + chalk.gray('.'.repeat(Math.max(1, W - 38))) + chalk.red(' ✗ FAILED'));
242
- lines.push(chalk.red(` Error: ${agent.error}`));
249
+ lines.push(dottedLine('Connection', chalk.red('✗ FAILED'), 9));
250
+ lines.push(chalk.red(` Error: ${agent.error}`));
243
251
  }
244
252
 
245
253
  lines.push('');