natureco-cli 2.23.20 → 2.23.21

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/utils/api.js +13 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "natureco-cli",
3
- "version": "2.23.20",
3
+ "version": "2.23.21",
4
4
  "description": "NatureCo AI Bot Terminal Interface",
5
5
  "bin": {
6
6
  "natureco": "bin/natureco.js"
package/src/utils/api.js CHANGED
@@ -599,13 +599,23 @@ async function sendMessageToProvider(apiKey, message, conversationId = null, sys
599
599
  : await sendMessageOpenAICompatible(providerConfig, messages, tools);
600
600
  }
601
601
 
602
- debugLog('[Provider] Response type:', assistantMessage.tool_calls ? 'tool_calls' : 'text');
602
+ if (!assistantMessage) {
603
+ return {
604
+ reply: 'No response from provider',
605
+ conversation_id: convId,
606
+ message_id: `msg_${Date.now()}`,
607
+ success: false
608
+ };
609
+ }
610
+
611
+ debugLog('[Provider] Response type:', assistantMessage?.tool_calls ? 'tool_calls' : 'text');
603
612
 
604
613
  // Add assistant message to history
605
614
  messages.push(assistantMessage);
606
615
 
607
616
  // Check for tool calls
608
- if (assistantMessage.tool_calls && assistantMessage.tool_calls.length > 0) {
617
+ const hasToolCalls = assistantMessage?.tool_calls?.length > 0;
618
+ if (hasToolCalls) {
609
619
  debugLog(`[Provider] Tool calls: ${assistantMessage.tool_calls.length}`);
610
620
 
611
621
  // Separate local and MCP tool calls
@@ -666,7 +676,7 @@ async function sendMessageToProvider(apiKey, message, conversationId = null, sys
666
676
  }
667
677
 
668
678
  // No tool calls, we have final response
669
- finalResponse = assistantMessage.content;
679
+ finalResponse = assistantMessage?.content;
670
680
  break;
671
681
  }
672
682