hedgequantx 2.8.0 → 2.8.2

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.0",
3
+ "version": "2.8.2",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -242,18 +242,10 @@ const handleUpdate = async () => {
242
242
 
243
243
  spinner.succeed(`UPDATED TO V${latestVersion}!`);
244
244
  console.log(chalk.green('\n ✓ UPDATE SUCCESSFUL!'));
245
- console.log(chalk.cyan('\n RESTARTING HQX...'));
246
-
247
- // Restart CLI with new version using spawn detached
248
- const { spawn } = require('child_process');
249
- const child = spawn('hqx', [], {
250
- detached: true,
251
- stdio: 'inherit',
252
- shell: true
253
- });
254
- child.unref();
255
-
256
- // Exit current process to let new one take over
245
+ console.log(chalk.yellow('\n Please restart HQX to use the new version.'));
246
+ console.log(chalk.cyan(' Run: hqx'));
247
+ console.log();
248
+ await prompts.waitForEnter();
257
249
  process.exit(0);
258
250
 
259
251
  } catch (error) {
@@ -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) + '╝'));
@@ -322,11 +329,18 @@ const drawConnectionTest = async (agents, boxWidth, clearWithBanner) => {
322
329
  const results = await runPreflightCheck(agents);
323
330
  spinner.stop();
324
331
 
332
+ // Clear and redraw with results
333
+ clearWithBanner();
334
+ console.log(chalk.cyan('╔' + '═'.repeat(W) + '╗'));
335
+ console.log(chalk.cyan('║') + chalk.yellow.bold(centerText('AI AGENTS CONNECTION TEST', W)) + chalk.cyan('║'));
336
+ console.log(chalk.cyan('╠' + '═'.repeat(W) + '╣'));
337
+
325
338
  // Display results
326
339
  const lines = formatPreflightResults(results, boxWidth);
327
340
  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('║'));
341
+ const lineLen = visibleLength(line);
342
+ const padding = Math.max(0, W - lineLen);
343
+ console.log(chalk.cyan('║') + line + ' '.repeat(padding) + chalk.cyan('║'));
330
344
  }
331
345
 
332
346
  // 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('');