hedgequantx 2.5.28 → 2.5.30
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 +1 -1
- package/src/menus/ai-agent.js +62 -16
package/package.json
CHANGED
package/src/menus/ai-agent.js
CHANGED
|
@@ -181,17 +181,39 @@ const showAgentDetails = async (agent) => {
|
|
|
181
181
|
|
|
182
182
|
console.log(makeLine(chalk.white('NAME: ') + providerColor(agent.name)));
|
|
183
183
|
console.log(makeLine(chalk.white('PROVIDER: ') + chalk.white(agent.provider?.name || agent.providerId)));
|
|
184
|
-
console.log(makeLine(chalk.white('MODEL: ') + chalk.white(agent.model)));
|
|
184
|
+
console.log(makeLine(chalk.white('MODEL: ') + chalk.white(agent.model || 'N/A')));
|
|
185
185
|
console.log(makeLine(chalk.white('STATUS: ') + (agent.isActive ? chalk.green('ACTIVE') : chalk.white('STANDBY'))));
|
|
186
186
|
|
|
187
187
|
console.log(chalk.cyan('╠' + '═'.repeat(W) + '╣'));
|
|
188
188
|
|
|
189
|
+
// Menu in 2 columns
|
|
190
|
+
const colWidth = Math.floor(W / 2);
|
|
191
|
+
|
|
192
|
+
const menuRow = (col1, col2 = '') => {
|
|
193
|
+
const c1Plain = col1.replace(/\x1b\[[0-9;]*m/g, '');
|
|
194
|
+
const c2Plain = col2.replace(/\x1b\[[0-9;]*m/g, '');
|
|
195
|
+
|
|
196
|
+
const pad1Left = Math.floor((colWidth - c1Plain.length) / 2);
|
|
197
|
+
const pad1Right = colWidth - c1Plain.length - pad1Left;
|
|
198
|
+
|
|
199
|
+
const col2Width = W - colWidth;
|
|
200
|
+
const pad2Left = Math.floor((col2Width - c2Plain.length) / 2);
|
|
201
|
+
const pad2Right = col2Width - c2Plain.length - pad2Left;
|
|
202
|
+
|
|
203
|
+
const line =
|
|
204
|
+
' '.repeat(pad1Left) + col1 + ' '.repeat(pad1Right) +
|
|
205
|
+
' '.repeat(pad2Left) + col2 + ' '.repeat(pad2Right);
|
|
206
|
+
|
|
207
|
+
console.log(chalk.cyan('║') + line + chalk.cyan('║'));
|
|
208
|
+
};
|
|
209
|
+
|
|
189
210
|
if (!agent.isActive) {
|
|
190
|
-
|
|
211
|
+
menuRow(chalk.cyan('[A] SET AS ACTIVE'), chalk.yellow('[M] CHANGE MODEL'));
|
|
212
|
+
menuRow(chalk.red('[R] REMOVE'), chalk.white('[<] BACK'));
|
|
213
|
+
} else {
|
|
214
|
+
menuRow(chalk.yellow('[M] CHANGE MODEL'), chalk.red('[R] REMOVE'));
|
|
215
|
+
menuRow(chalk.white('[<] BACK'), '');
|
|
191
216
|
}
|
|
192
|
-
console.log(makeLine(chalk.yellow('[M] CHANGE MODEL')));
|
|
193
|
-
console.log(makeLine(chalk.red('[R] REMOVE')));
|
|
194
|
-
console.log(makeLine(chalk.white('[<] BACK')));
|
|
195
217
|
|
|
196
218
|
drawBoxFooter(boxWidth);
|
|
197
219
|
|
|
@@ -912,20 +934,44 @@ const setupConnection = async (provider, option) => {
|
|
|
912
934
|
return await selectProviderOption(provider);
|
|
913
935
|
}
|
|
914
936
|
|
|
915
|
-
|
|
937
|
+
spinner.text = 'FETCHING AVAILABLE MODELS...';
|
|
938
|
+
|
|
939
|
+
// Fetch models from real API
|
|
940
|
+
const { fetchAnthropicModels, fetchGeminiModels, fetchOpenAIModels } = require('../services/ai/client');
|
|
941
|
+
|
|
942
|
+
let models = null;
|
|
943
|
+
if (provider.id === 'anthropic') {
|
|
944
|
+
models = await fetchAnthropicModels(credentials.apiKey);
|
|
945
|
+
} else if (provider.id === 'gemini') {
|
|
946
|
+
models = await fetchGeminiModels(credentials.apiKey);
|
|
947
|
+
} else {
|
|
948
|
+
const endpoint = credentials.endpoint || provider.endpoint;
|
|
949
|
+
models = await fetchOpenAIModels(endpoint, credentials.apiKey);
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
if (!models || models.length === 0) {
|
|
953
|
+
spinner.fail('COULD NOT FETCH MODELS FROM API');
|
|
954
|
+
console.log(chalk.white(' Check your API key or network connection.'));
|
|
955
|
+
await prompts.waitForEnter();
|
|
956
|
+
return await selectProviderOption(provider);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
spinner.succeed(`FOUND ${models.length} MODELS`);
|
|
960
|
+
|
|
961
|
+
// Let user select a model
|
|
962
|
+
const selectedModel = await selectModelFromList(models, provider.name);
|
|
963
|
+
if (!selectedModel) {
|
|
964
|
+
return await selectProviderOption(provider);
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// Add as new agent with selected model
|
|
916
968
|
try {
|
|
917
|
-
|
|
918
|
-
await aiService.addAgent(provider.id, option.id, credentials, model, provider.name);
|
|
919
|
-
spinner.succeed(`AGENT ADDED: ${provider.name}`);
|
|
920
|
-
|
|
921
|
-
// Show available models for local providers
|
|
922
|
-
if (validation.models && validation.models.length > 0) {
|
|
923
|
-
console.log(chalk.white(` AVAILABLE MODELS: ${validation.models.slice(0, 5).join(', ')}`));
|
|
924
|
-
}
|
|
969
|
+
await aiService.addAgent(provider.id, option.id, credentials, selectedModel, provider.name);
|
|
925
970
|
|
|
926
|
-
console.log(chalk.
|
|
971
|
+
console.log(chalk.green(`\n AGENT ADDED: ${provider.name}`));
|
|
972
|
+
console.log(chalk.white(` MODEL: ${selectedModel}`));
|
|
927
973
|
} catch (error) {
|
|
928
|
-
|
|
974
|
+
console.log(chalk.red(`\n FAILED TO SAVE: ${error.message}`));
|
|
929
975
|
}
|
|
930
976
|
|
|
931
977
|
await prompts.waitForEnter();
|