natureco-cli 2.23.20 → 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 +1 -1
- package/src/commands/code.js +11 -4
- package/src/utils/api.js +13 -3
package/package.json
CHANGED
package/src/commands/code.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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];
|
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
|
-
|
|
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
|
-
|
|
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
|
|
679
|
+
finalResponse = assistantMessage?.content;
|
|
670
680
|
break;
|
|
671
681
|
}
|
|
672
682
|
|