hedgequantx 2.9.17 → 2.9.19

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.9.17",
3
+ "version": "2.9.19",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -334,19 +334,27 @@ const drawConnectionTest = async (agents, boxWidth, clearWithBanner) => {
334
334
 
335
335
  const W = boxWidth - 2;
336
336
 
337
- // Show loading state with complete box (centered vertically and horizontally)
337
+ // Show loading state with spinner
338
338
  clearWithBanner();
339
339
  console.log(chalk.cyan('╔' + '═'.repeat(W) + '╗'));
340
340
  console.log(chalk.cyan('║') + chalk.yellow.bold(centerText('AI AGENTS CONNECTION TEST', W)) + chalk.cyan('║'));
341
341
  console.log(chalk.cyan('╠' + '═'.repeat(W) + '╣'));
342
342
  console.log(chalk.cyan('║') + ' '.repeat(W) + chalk.cyan('║'));
343
- console.log(chalk.cyan('║') + chalk.yellow(centerText('Testing connections... Please wait', W)) + chalk.cyan('║'));
344
- console.log(chalk.cyan('║') + ' '.repeat(W) + chalk.cyan('║'));
345
- console.log(chalk.cyan('╚' + '═'.repeat(W) + '╝'));
346
343
 
347
- // Run pre-flight check (no spinner, box stays complete)
344
+ // Start spinner on the loading line
345
+ const spinnerText = 'Testing connections... Please wait';
346
+ const spinner = ora({
347
+ text: spinnerText,
348
+ spinner: 'dots',
349
+ color: 'yellow'
350
+ }).start();
351
+
352
+ // Run pre-flight check
348
353
  const results = await runPreflightCheck(agents);
349
354
 
355
+ // Stop spinner
356
+ spinner.stop();
357
+
350
358
  // Clear and redraw with results
351
359
  clearWithBanner();
352
360
  console.log(chalk.cyan('╔' + '═'.repeat(W) + '╗'));
@@ -13,6 +13,17 @@ const { calculateConsensus, isApproved, applyOptimizations } = require('./consen
13
13
  const { runPreflightCheck, formatPreflightResults, getPreflightSummary } = require('./health');
14
14
  const cliproxy = require('../cliproxy');
15
15
 
16
+ /**
17
+ * API endpoints for direct API key providers
18
+ */
19
+ const API_CHAT_ENDPOINTS = {
20
+ minimax: 'https://api.minimaxi.chat/v1/chat/completions',
21
+ deepseek: 'https://api.deepseek.com/v1/chat/completions',
22
+ mistral: 'https://api.mistral.ai/v1/chat/completions',
23
+ xai: 'https://api.x.ai/v1/chat/completions',
24
+ openrouter: 'https://openrouter.ai/api/v1/chat/completions',
25
+ };
26
+
16
27
  /**
17
28
  * SupervisionEngine class - manages multi-agent supervision
18
29
  */
@@ -125,14 +136,53 @@ class SupervisionEngine {
125
136
 
126
137
  /**
127
138
  * Direct API call for API key connections
139
+ * Uses fetch API for direct HTTPS requests to provider endpoints
128
140
  */
129
141
  async callDirectAPI(agent, prompt) {
130
- // This would be implemented per provider
131
- // For now, return error to use CLIProxy instead
132
- return {
133
- success: false,
134
- error: 'Direct API not implemented - use CLIProxy'
135
- };
142
+ const endpoint = API_CHAT_ENDPOINTS[agent.provider];
143
+
144
+ if (!endpoint) {
145
+ return { success: false, error: `No endpoint for provider: ${agent.provider}` };
146
+ }
147
+
148
+ if (!agent.apiKey) {
149
+ return { success: false, error: 'Missing API key' };
150
+ }
151
+
152
+ try {
153
+ const controller = new AbortController();
154
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
155
+
156
+ const response = await fetch(endpoint, {
157
+ method: 'POST',
158
+ headers: {
159
+ 'Content-Type': 'application/json',
160
+ 'Authorization': `Bearer ${agent.apiKey}`
161
+ },
162
+ body: JSON.stringify({
163
+ model: agent.modelId,
164
+ messages: [{ role: 'user', content: prompt }],
165
+ max_tokens: 500,
166
+ stream: false
167
+ }),
168
+ signal: controller.signal
169
+ });
170
+
171
+ clearTimeout(timeoutId);
172
+ const data = await response.json();
173
+
174
+ if (response.ok) {
175
+ const content = data.choices?.[0]?.message?.content || '';
176
+ return { success: true, content, error: null };
177
+ } else {
178
+ return { success: false, error: data.error?.message || `HTTP ${response.status}` };
179
+ }
180
+ } catch (e) {
181
+ if (e.name === 'AbortError') {
182
+ return { success: false, error: 'Timeout' };
183
+ }
184
+ return { success: false, error: e.message };
185
+ }
136
186
  }
137
187
 
138
188
  /**