natureco-cli 2.23.21 → 2.23.22

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "natureco-cli",
3
- "version": "2.23.21",
3
+ "version": "2.23.22",
4
4
  "description": "NatureCo AI Bot Terminal Interface",
5
5
  "bin": {
6
6
  "natureco": "bin/natureco.js"
@@ -194,15 +194,16 @@ async function generateCommitMessage(diff, providerConfig) {
194
194
 
195
195
  async function streamMessage(providerConfig, messages, tools) {
196
196
  const result = await streamProviderCompletion(providerConfig, messages, tools);
197
+ if (!result) return { text: '', toolCalls: [] };
197
198
  if (result.type === 'text') {
198
199
  return { text: result.content, toolCalls: [] };
199
200
  }
200
- const toolCalls = result.message.tool_calls.map(tc => ({
201
+ const toolCalls = result?.message?.tool_calls?.map(tc => ({
201
202
  id: tc.id,
202
203
  name: tc.function.name,
203
204
  input: (() => { try { return JSON.parse(tc.function.arguments); } catch { return {}; } })(),
204
- }));
205
- return { text: result.message.content || '', toolCalls };
205
+ })) || [];
206
+ return { text: result?.message?.content || '', toolCalls };
206
207
  }
207
208
 
208
209
  // ── Tool execution ────────────────────────────────────────────────────────────
@@ -628,6 +629,12 @@ ${indexPrompt}`;
628
629
  return;
629
630
  }
630
631
 
632
+ if (!streamResult) {
633
+ console.log(chalk.red('\nNo response received\n'));
634
+ conversationMessages.pop();
635
+ return;
636
+ }
637
+
631
638
  const assistantMsg = { role: 'assistant', content: streamResult.text || '' };
632
639
  if (streamResult.toolCalls?.length) {
633
640
  assistantMsg.tool_calls = streamResult.toolCalls.map(tc => ({
@@ -645,7 +652,7 @@ ${indexPrompt}`;
645
652
  break;
646
653
  }
647
654
 
648
- console.log(chalk.yellow(`\n🔧 ${streamResult.toolCalls.length} tool çalıştırılıyor...\n`));
655
+ console.log(chalk.yellow(`\n🔧 ${streamResult?.toolCalls?.length ?? 0} tool çalıştırılıyor...\n`));
649
656
 
650
657
  for (let ti = 0; ti < streamResult.toolCalls.length; ti++) {
651
658
  const toolCall = streamResult.toolCalls[ti];