hedgequantx 2.9.18 → 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
|
@@ -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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
success: false,
|
|
134
|
-
|
|
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
|
/**
|