navada-edge-cli 3.5.3 → 3.5.5
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 +11 -20
- 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;
|
|
@@ -804,6 +801,12 @@ function detectIntent(message) {
|
|
|
804
801
|
// Anthropic Claude API — conversational agent with tool use
|
|
805
802
|
// ---------------------------------------------------------------------------
|
|
806
803
|
async function chat(userMessage, conversationHistory = []) {
|
|
804
|
+
// Local action interceptor — file/folder ops work on ALL tiers without LLM
|
|
805
|
+
const localResult = tryLocalAction(userMessage);
|
|
806
|
+
if (localResult) {
|
|
807
|
+
return `${localResult}\n\nWhat would you like to do next?`;
|
|
808
|
+
}
|
|
809
|
+
|
|
807
810
|
const anthropicKey = config.get('anthropicKey') || process.env.ANTHROPIC_API_KEY || '';
|
|
808
811
|
const openaiKey = config.get('openaiKey') || process.env.OPENAI_API_KEY || '';
|
|
809
812
|
const nvidiaKey = config.get('nvidiaKey') || process.env.NVIDIA_API_KEY || '';
|
|
@@ -846,15 +849,12 @@ async function chat(userMessage, conversationHistory = []) {
|
|
|
846
849
|
...conversationHistory.map(m => ({ role: m.role, content: typeof m.content === 'string' ? m.content : JSON.stringify(m.content) })),
|
|
847
850
|
{ role: 'user', content: userMessage },
|
|
848
851
|
];
|
|
849
|
-
process.stdout.write(ui.dim(' NAVADA > '));
|
|
850
852
|
try {
|
|
853
|
+
process.stdout.write(ui.dim(' '));
|
|
851
854
|
const result = await streamGemini(effectiveGeminiKey, messages, geminiModel);
|
|
852
855
|
return result.content;
|
|
853
856
|
} catch (e) {
|
|
854
|
-
|
|
855
|
-
console.log(ui.warn('Gemini API unavailable, using Grok free tier.'));
|
|
856
|
-
sessionState._geminiWarned = true;
|
|
857
|
-
}
|
|
857
|
+
sessionState._geminiWarned = true;
|
|
858
858
|
return grokChat(userMessage, conversationHistory);
|
|
859
859
|
}
|
|
860
860
|
}
|
|
@@ -869,7 +869,7 @@ async function chat(userMessage, conversationHistory = []) {
|
|
|
869
869
|
...conversationHistory.map(m => ({ role: m.role, content: typeof m.content === 'string' ? m.content : JSON.stringify(m.content) })),
|
|
870
870
|
{ role: 'user', content: userMessage },
|
|
871
871
|
];
|
|
872
|
-
process.stdout.write(ui.dim('
|
|
872
|
+
process.stdout.write(ui.dim(' '));
|
|
873
873
|
const result = await streamNvidia(effectiveNvidiaKey, messages, nvidiaModel);
|
|
874
874
|
return result.content;
|
|
875
875
|
}
|
|
@@ -1003,10 +1003,7 @@ async function chat(userMessage, conversationHistory = []) {
|
|
|
1003
1003
|
const errMsg = e.message || '';
|
|
1004
1004
|
// If billing/rate limit/auth error, fall back to free tier
|
|
1005
1005
|
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
|
-
}
|
|
1006
|
+
sessionState._anthropicWarned = true;
|
|
1010
1007
|
return grokChat(userMessage, conversationHistory);
|
|
1011
1008
|
}
|
|
1012
1009
|
throw e;
|
|
@@ -1179,12 +1176,6 @@ function tryLocalAction(userMessage) {
|
|
|
1179
1176
|
}
|
|
1180
1177
|
|
|
1181
1178
|
async function grokChat(userMessage, conversationHistory = []) {
|
|
1182
|
-
// Try local action first — enables file ops on free tier
|
|
1183
|
-
const localResult = tryLocalAction(userMessage);
|
|
1184
|
-
if (localResult) {
|
|
1185
|
-
return `${localResult}\n\nWhat would you like to do next?`;
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
1179
|
const messages = [
|
|
1189
1180
|
...conversationHistory.slice(-20).map(m => ({
|
|
1190
1181
|
role: m.role,
|
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