navada-edge-cli 3.5.3 → 3.5.4
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/lib/agent.js +5 -14
- package/lib/commands/ai.js +7 -7
- package/package.json +1 -1
package/lib/agent.js
CHANGED
|
@@ -750,10 +750,7 @@ async function openAIChat(key, userMessage, conversationHistory = []) {
|
|
|
750
750
|
response = await streamOpenAI(key, messages, model);
|
|
751
751
|
} catch (e) {
|
|
752
752
|
if (e.message.includes('401') || e.message.includes('429') || e.message.includes('billing')) {
|
|
753
|
-
|
|
754
|
-
console.log(ui.warn('OpenAI API unavailable, using Grok free tier. /login with a valid key to switch.'));
|
|
755
|
-
sessionState._openaiWarned = true;
|
|
756
|
-
}
|
|
753
|
+
sessionState._openaiWarned = true;
|
|
757
754
|
return grokChat(userMessage, conversationHistory);
|
|
758
755
|
}
|
|
759
756
|
throw e;
|
|
@@ -846,15 +843,12 @@ async function chat(userMessage, conversationHistory = []) {
|
|
|
846
843
|
...conversationHistory.map(m => ({ role: m.role, content: typeof m.content === 'string' ? m.content : JSON.stringify(m.content) })),
|
|
847
844
|
{ role: 'user', content: userMessage },
|
|
848
845
|
];
|
|
849
|
-
process.stdout.write(ui.dim(' NAVADA > '));
|
|
850
846
|
try {
|
|
847
|
+
process.stdout.write(ui.dim(' '));
|
|
851
848
|
const result = await streamGemini(effectiveGeminiKey, messages, geminiModel);
|
|
852
849
|
return result.content;
|
|
853
850
|
} catch (e) {
|
|
854
|
-
|
|
855
|
-
console.log(ui.warn('Gemini API unavailable, using Grok free tier.'));
|
|
856
|
-
sessionState._geminiWarned = true;
|
|
857
|
-
}
|
|
851
|
+
sessionState._geminiWarned = true;
|
|
858
852
|
return grokChat(userMessage, conversationHistory);
|
|
859
853
|
}
|
|
860
854
|
}
|
|
@@ -869,7 +863,7 @@ async function chat(userMessage, conversationHistory = []) {
|
|
|
869
863
|
...conversationHistory.map(m => ({ role: m.role, content: typeof m.content === 'string' ? m.content : JSON.stringify(m.content) })),
|
|
870
864
|
{ role: 'user', content: userMessage },
|
|
871
865
|
];
|
|
872
|
-
process.stdout.write(ui.dim('
|
|
866
|
+
process.stdout.write(ui.dim(' '));
|
|
873
867
|
const result = await streamNvidia(effectiveNvidiaKey, messages, nvidiaModel);
|
|
874
868
|
return result.content;
|
|
875
869
|
}
|
|
@@ -1003,10 +997,7 @@ async function chat(userMessage, conversationHistory = []) {
|
|
|
1003
997
|
const errMsg = e.message || '';
|
|
1004
998
|
// If billing/rate limit/auth error, fall back to free tier
|
|
1005
999
|
if (errMsg.includes('400') || errMsg.includes('401') || errMsg.includes('429') || errMsg.includes('usage limits')) {
|
|
1006
|
-
|
|
1007
|
-
console.log(ui.warn('Anthropic API unavailable, using Grok free tier. /login with a valid key to switch.'));
|
|
1008
|
-
sessionState._anthropicWarned = true;
|
|
1009
|
-
}
|
|
1000
|
+
sessionState._anthropicWarned = true;
|
|
1010
1001
|
return grokChat(userMessage, conversationHistory);
|
|
1011
1002
|
}
|
|
1012
1003
|
throw e;
|
package/lib/commands/ai.js
CHANGED
|
@@ -13,11 +13,12 @@ module.exports = function(reg) {
|
|
|
13
13
|
|
|
14
14
|
const hasKey = config.getApiKey() || config.get('anthropicKey') || process.env.ANTHROPIC_API_KEY;
|
|
15
15
|
|
|
16
|
-
//
|
|
16
|
+
// Reset streaming flag before each chat
|
|
17
|
+
sessionState._lastStreamed = false;
|
|
18
|
+
|
|
19
|
+
// Show thinking indicator
|
|
17
20
|
let spinner;
|
|
18
|
-
if (
|
|
19
|
-
process.stdout.write(ui.dim(' NAVADA > '));
|
|
20
|
-
} else {
|
|
21
|
+
if (hasKey) {
|
|
21
22
|
const ora = require('ora');
|
|
22
23
|
spinner = ora({ text: ' NAVADA thinking...', color: 'white' }).start();
|
|
23
24
|
}
|
|
@@ -33,17 +34,16 @@ module.exports = function(reg) {
|
|
|
33
34
|
|
|
34
35
|
// Only print if not already streamed to stdout
|
|
35
36
|
if (response && !sessionState._lastStreamed) {
|
|
36
|
-
console.log(
|
|
37
|
+
console.log('');
|
|
37
38
|
console.log(` ${response}`);
|
|
38
39
|
}
|
|
39
|
-
sessionState._lastStreamed = false;
|
|
40
40
|
|
|
41
41
|
// Track usage
|
|
42
42
|
reportTelemetry('chat', { messageLength: msg.length });
|
|
43
43
|
} catch (e) {
|
|
44
44
|
if (spinner) spinner.stop();
|
|
45
45
|
console.log(ui.error(e.message));
|
|
46
|
-
console.log(ui.dim('
|
|
46
|
+
console.log(ui.dim('/config to check providers, or /setup to configure.'));
|
|
47
47
|
}
|
|
48
48
|
}, { category: 'AI', aliases: ['ask'] });
|
|
49
49
|
|
package/package.json
CHANGED