natureco-cli 5.9.4 → 5.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "natureco-cli",
3
- "version": "5.9.4",
3
+ "version": "5.9.5",
4
4
  "description": "OpenClaw'dan daha güvenli, daha hızlı, daha ucuz AI agent CLI. Multi-agent, self-evolving skills, audit log, maliyet optimizasyonu ve NatureCo platform-native.",
5
5
  "bin": {
6
6
  "natureco": "bin/natureco.js"
@@ -137,6 +137,9 @@ function getConfig() {
137
137
  function isMiniMax(url) {
138
138
  return url && (url.includes('minimax.io') || url.includes('minimaxi.com') || url.includes('minimax.cn'));
139
139
  }
140
+ function isGemini(url) {
141
+ return url && (url.includes('generativelanguage.googleapis.com') || url.includes('gemini'));
142
+ }
140
143
 
141
144
  function loadMemory(username) {
142
145
  const file = path.join(MEMORY_DIR, `${(username || 'default').toLowerCase()}.json`);
@@ -344,10 +347,12 @@ async function sendStreaming(providerUrl, providerApiKey, messages, model, onChu
344
347
  }
345
348
 
346
349
  // OpenAI uyumlu streaming (veya MiniMax /v1/text/chatcompletion_v2)
347
- // v4.8.2: MiniMax tool calling sadece özel endpoint'inde çalışıyor
350
+ // v5.9.5: Gemini /openai/chat/completions provider-detect.js buildChatEndpoint
348
351
  const endpoint = isMM
349
352
  ? `${providerUrl.replace(/\/+$/, '')}/v1/text/chatcompletion_v2`
350
- : `${providerUrl.replace(/\/+$/, '')}/chat/completions`;
353
+ : isGemini(providerUrl)
354
+ ? `${providerUrl.replace(/\/+$/, '')}/openai/chat/completions`
355
+ : `${providerUrl.replace(/\/+$/, '')}/chat/completions`;
351
356
  const result = await new Promise((resolve, reject) => {
352
357
  const req = https.request(endpoint, {
353
358
  method: 'POST',
package/src/utils/api.js CHANGED
@@ -21,7 +21,7 @@ const guardrails = new ToolGuardrails();
21
21
  * re-exported here so the historical `detectProvider` reference inside
22
22
  * api.js continues to work without touching every call site.
23
23
  */
24
- const { detectProvider, isMiniMax } = require('./provider-detect');
24
+ const { detectProvider, isMiniMax, isGemini } = require('./provider-detect');
25
25
 
26
26
  /**
27
27
  * v5.5.0: Tool definitions'ı provider'a göre normalize et
@@ -548,10 +548,12 @@ function formatToolsForAnthropic() {
548
548
  */
549
549
  async function sendMessageOpenAICompatible(providerConfig, messages, tools) {
550
550
  const baseUrl = providerConfig.url.replace(/\/+$/, '');
551
- // MiniMax özel endpoint tespiti provider-detect.js'deki kanonik tanım.
551
+ // v5.9.5: buildChatEndpoint handles MiniMax, Gemini, and OpenAI-compatible.
552
552
  const endpoint = isMiniMax(baseUrl)
553
553
  ? `${baseUrl}/v1/text/chatcompletion_v2`
554
- : `${baseUrl}/chat/completions`;
554
+ : isGemini(baseUrl)
555
+ ? `${baseUrl}/openai/chat/completions`
556
+ : `${baseUrl}/chat/completions`;
555
557
  const requestBody = {
556
558
  model: providerConfig.model,
557
559
  messages: messages,
@@ -1019,10 +1021,12 @@ async function streamProviderCompletion(providerConfig, messages, tools) {
1019
1021
 
1020
1022
  async function streamOpenAICompletion(providerConfig, messages, tools) {
1021
1023
  const baseUrl = providerConfig.url.replace(/\/+$/, '');
1022
- // MiniMax özel endpoint tespiti (streaming için de aynı) — provider-detect.js.
1024
+ // v5.9.5: buildChatEndpoint handles MiniMax, Gemini, and OpenAI-compatible.
1023
1025
  const endpoint = isMiniMax(baseUrl)
1024
1026
  ? `${baseUrl}/v1/text/chatcompletion_v2`
1025
- : `${baseUrl}/chat/completions`;
1027
+ : isGemini(baseUrl)
1028
+ ? `${baseUrl}/openai/chat/completions`
1029
+ : `${baseUrl}/chat/completions`;
1026
1030
 
1027
1031
  const requestBody = {
1028
1032
  model: providerConfig.model,
@@ -69,10 +69,29 @@ function isOllama(url) {
69
69
  return u.includes('localhost') || u.includes('127.0.0.1') || u.includes('ollama');
70
70
  }
71
71
 
72
+ function isGemini(url) {
73
+ const u = (url || '').toLowerCase();
74
+ return u.includes('generativelanguage.googleapis.com') || u.includes('gemini');
75
+ }
76
+
77
+ /**
78
+ * Build the correct chat completions endpoint for a given provider URL.
79
+ * Handles MiniMax (non-standard path), Gemini (OpenAI-compat path under /openai/),
80
+ * and standard OpenAI-compatible providers.
81
+ */
82
+ function buildChatEndpoint(providerUrl) {
83
+ const base = (providerUrl || '').replace(/\/+$/, '');
84
+ if (isMiniMax(base)) return `${base}/v1/text/chatcompletion_v2`;
85
+ if (isGemini(base)) return `${base}/openai/chat/completions`;
86
+ return `${base}/chat/completions`;
87
+ }
88
+
72
89
  module.exports = {
73
90
  detectProvider,
74
91
  isAnthropic,
75
92
  isGroq,
76
93
  isMiniMax,
77
94
  isOllama,
95
+ isGemini,
96
+ buildChatEndpoint,
78
97
  };