natureco-cli 2.23.0 → 2.23.2

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.0",
3
+ "version": "2.23.2",
4
4
  "description": "NatureCo AI Bot Terminal Interface",
5
5
  "main": "bin/natureco.js",
6
6
  "bin": {
@@ -260,14 +260,14 @@ async function streamMessage(providerConfig, messages, tools) {
260
260
  if (tc.id != null) {
261
261
  toolCallsBuffer[idx].id = tc.id;
262
262
  }
263
+ // OpenAI format: tc.function.name / tc.function.arguments
263
264
  if (tc.function) {
264
- if (tc.function.name != null) {
265
- toolCallsBuffer[idx].name += tc.function.name;
266
- }
267
- if (tc.function.arguments != null) {
268
- toolCallsBuffer[idx].arguments += tc.function.arguments;
269
- }
265
+ if (tc.function.name != null) toolCallsBuffer[idx].name += tc.function.name;
266
+ if (tc.function.arguments != null) toolCallsBuffer[idx].arguments += tc.function.arguments;
270
267
  }
268
+ // Alternate format (llama-4-scout etc.): tc.name / tc.arguments directly
269
+ if (tc.name != null) toolCallsBuffer[idx].name += tc.name;
270
+ if (tc.arguments != null) toolCallsBuffer[idx].arguments += tc.arguments;
271
271
  }
272
272
  }
273
273
  } catch {}
@@ -702,15 +702,17 @@ ${indexPrompt}`;
702
702
 
703
703
  console.log(chalk.yellow(`\n🔧 ${streamResult.toolCalls.length} tool çalıştırılıyor...\n`));
704
704
 
705
- for (const toolCall of streamResult.toolCalls) {
705
+ for (let ti = 0; ti < streamResult.toolCalls.length; ti++) {
706
+ const toolCall = streamResult.toolCalls[ti];
706
707
  const result = await runToolCall(toolCall, stats);
707
708
  const resultStr = result.success !== false
708
709
  ? (result.output || JSON.stringify(result))
709
710
  : `Hata: ${result.error}`;
710
711
 
712
+ const matchedId = assistantMsg.tool_calls?.[ti]?.id || toolCall.id;
711
713
  conversationMessages.push({
712
714
  role: 'tool',
713
- tool_call_id: assistantMsg.tool_calls?.find(tc => tc.function.name === toolCall.name)?.id || toolCall.id,
715
+ tool_call_id: matchedId,
714
716
  name: toolCall.name,
715
717
  content: resultStr.slice(0, 3000),
716
718
  });
@@ -719,20 +721,21 @@ ${indexPrompt}`;
719
721
  console.log();
720
722
  }
721
723
 
722
- // Session'a kaydet
723
- const lastAssistant = [...conversationMessages].reverse().find(m => m.role === 'assistant');
724
- if (lastAssistant?.content) {
725
- addToHistory(bot.id, userMessage, lastAssistant.content, null);
726
- addMessageToSession(bot.id, session.id, userMessage, lastAssistant.content);
727
- }
724
+ try {
725
+ const lastAssistant = [...conversationMessages].reverse().find(m => m.role === 'assistant');
726
+ if (lastAssistant?.content) {
727
+ addToHistory(bot.id, userMessage, lastAssistant.content, null);
728
+ addMessageToSession(bot.id, session.id, userMessage, lastAssistant.content);
729
+ }
728
730
 
729
- // ── Test runner dosya değiştiyse sor ───────────────────────────────────
730
- if (stats.filesChanged > prevFilesChanged && projectIndex.packageJson?.scripts?.test) {
731
- const fixPrompt = await runTests(projectIndex, conversationMessages, tools, providerConfig, displayBotName);
732
- if (fixPrompt) {
733
- // Test hatasını agent'a gönder
734
- await handleMessage(fixPrompt);
731
+ if (stats.filesChanged > prevFilesChanged && projectIndex.packageJson?.scripts?.test) {
732
+ const fixPrompt = await runTests(projectIndex, conversationMessages, tools, providerConfig, displayBotName);
733
+ if (fixPrompt) {
734
+ await handleMessage(fixPrompt);
735
+ }
735
736
  }
737
+ } catch (err) {
738
+ console.log(chalk.red(`\n ❌ Kayıt hatası: ${err.message}\n`));
736
739
  }
737
740
  }
738
741
 
@@ -761,7 +764,11 @@ ${indexPrompt}`;
761
764
  async function promptLoop() {
762
765
  rl.question('', async (msg) => {
763
766
  process.stdout.write('\x1b[1A\x1b[2K');
764
- await handleMessage(msg);
767
+ try {
768
+ await handleMessage(msg);
769
+ } catch (err) {
770
+ console.log(chalk.red(`\n ❌ Beklenmeyen hata: ${err.message}\n`));
771
+ }
765
772
  promptLoop();
766
773
  });
767
774
  }
@@ -35,6 +35,7 @@ module.exports = {
35
35
 
36
36
  return {
37
37
  success: true,
38
+ output: `Dosya başarıyla yazıldı: ${filePath} (${stats.size} bytes)`,
38
39
  path: filePath,
39
40
  size: stats.size
40
41
  };