hedgequantx 2.9.15 → 2.9.17
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
package/src/menus/dashboard.js
CHANGED
|
@@ -243,10 +243,7 @@ const handleUpdate = async () => {
|
|
|
243
243
|
|
|
244
244
|
spinner.succeed(`UPDATED TO V${latestVersion}!`);
|
|
245
245
|
console.log(chalk.green('\n ✓ UPDATE SUCCESSFUL!'));
|
|
246
|
-
console.log(chalk.yellow('\n
|
|
247
|
-
|
|
248
|
-
// Small delay then exit - the user will run hqx again
|
|
249
|
-
await new Promise(r => setTimeout(r, 1500));
|
|
246
|
+
console.log(chalk.yellow('\n Run ') + chalk.cyan('hqx') + chalk.yellow(' to start the new version.\n'));
|
|
250
247
|
process.exit(0);
|
|
251
248
|
|
|
252
249
|
} catch (error) {
|
|
@@ -56,83 +56,59 @@ const API_CHAT_ENDPOINTS = {
|
|
|
56
56
|
* @param {Object} agent - Agent config
|
|
57
57
|
* @returns {Promise<Object>} { success, latency, formatValid, error }
|
|
58
58
|
*/
|
|
59
|
-
const testApiKeyConnection = (agent) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const body = JSON.stringify({
|
|
71
|
-
model: agent.modelId,
|
|
72
|
-
messages: [{ role: 'user', content: TEST_PROMPT }],
|
|
73
|
-
max_tokens: 100,
|
|
74
|
-
stream: false
|
|
75
|
-
});
|
|
59
|
+
const testApiKeyConnection = async (agent) => {
|
|
60
|
+
const startTime = Date.now();
|
|
61
|
+
const endpoint = API_CHAT_ENDPOINTS[agent.provider];
|
|
62
|
+
|
|
63
|
+
if (!endpoint || !agent.apiKey) {
|
|
64
|
+
return { success: false, latency: 0, formatValid: false, error: 'Missing endpoint or API key' };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const controller = new AbortController();
|
|
69
|
+
const timeoutId = setTimeout(() => controller.abort(), AGENT_TIMEOUT);
|
|
76
70
|
|
|
77
|
-
const
|
|
78
|
-
hostname: url.hostname,
|
|
79
|
-
path: url.pathname,
|
|
71
|
+
const response = await fetch(endpoint, {
|
|
80
72
|
method: 'POST',
|
|
81
73
|
headers: {
|
|
82
74
|
'Content-Type': 'application/json',
|
|
83
|
-
'Authorization': `Bearer ${agent.apiKey}
|
|
84
|
-
'Content-Length': Buffer.byteLength(body)
|
|
75
|
+
'Authorization': `Bearer ${agent.apiKey}`
|
|
85
76
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const latency = Date.now() - startTime;
|
|
94
|
-
try {
|
|
95
|
-
// Handle potential SSE format (data: {...}\n\ndata: {...})
|
|
96
|
-
let jsonData = data.trim();
|
|
97
|
-
if (jsonData.startsWith('data:')) {
|
|
98
|
-
// SSE format - extract last complete JSON
|
|
99
|
-
const lines = jsonData.split('\n').filter(l => l.startsWith('data:'));
|
|
100
|
-
const lastData = lines.filter(l => l !== 'data: [DONE]').pop();
|
|
101
|
-
if (lastData) jsonData = lastData.replace('data: ', '');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const parsed = JSON.parse(jsonData);
|
|
105
|
-
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
106
|
-
const content = parsed.choices?.[0]?.message?.content ||
|
|
107
|
-
parsed.choices?.[0]?.delta?.content || '';
|
|
108
|
-
const formatResult = validateResponseFormat(content);
|
|
109
|
-
resolve({
|
|
110
|
-
success: formatResult.valid,
|
|
111
|
-
latency,
|
|
112
|
-
formatValid: formatResult.valid,
|
|
113
|
-
error: formatResult.valid ? null : formatResult.error,
|
|
114
|
-
response: content
|
|
115
|
-
});
|
|
116
|
-
} else {
|
|
117
|
-
resolve({ success: false, latency, formatValid: false,
|
|
118
|
-
error: parsed.error?.message || `HTTP ${res.statusCode}` });
|
|
119
|
-
}
|
|
120
|
-
} catch (e) {
|
|
121
|
-
resolve({ success: false, latency, formatValid: false, error: `Parse error: ${e.message}` });
|
|
122
|
-
}
|
|
123
|
-
});
|
|
77
|
+
body: JSON.stringify({
|
|
78
|
+
model: agent.modelId,
|
|
79
|
+
messages: [{ role: 'user', content: TEST_PROMPT }],
|
|
80
|
+
max_tokens: 100,
|
|
81
|
+
stream: false
|
|
82
|
+
}),
|
|
83
|
+
signal: controller.signal
|
|
124
84
|
});
|
|
125
85
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
86
|
+
clearTimeout(timeoutId);
|
|
87
|
+
const latency = Date.now() - startTime;
|
|
88
|
+
|
|
89
|
+
const data = await response.json();
|
|
90
|
+
|
|
91
|
+
if (response.ok) {
|
|
92
|
+
const content = data.choices?.[0]?.message?.content || '';
|
|
93
|
+
const formatResult = validateResponseFormat(content);
|
|
94
|
+
return {
|
|
95
|
+
success: formatResult.valid,
|
|
96
|
+
latency,
|
|
97
|
+
formatValid: formatResult.valid,
|
|
98
|
+
error: formatResult.valid ? null : formatResult.error,
|
|
99
|
+
response: content
|
|
100
|
+
};
|
|
101
|
+
} else {
|
|
102
|
+
return { success: false, latency, formatValid: false,
|
|
103
|
+
error: data.error?.message || `HTTP ${response.status}` };
|
|
104
|
+
}
|
|
105
|
+
} catch (e) {
|
|
106
|
+
const latency = Date.now() - startTime;
|
|
107
|
+
if (e.name === 'AbortError') {
|
|
108
|
+
return { success: false, latency: AGENT_TIMEOUT, formatValid: false, error: 'Timeout' };
|
|
109
|
+
}
|
|
110
|
+
return { success: false, latency, formatValid: false, error: e.message };
|
|
111
|
+
}
|
|
136
112
|
};
|
|
137
113
|
|
|
138
114
|
/**
|