natureco-cli 5.9.4 → 5.9.6

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.6",
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`);
@@ -243,7 +246,9 @@ function apiRequest(providerUrl, providerApiKey, body, stream = false) {
243
246
  const isMM = isMiniMax(providerUrl);
244
247
  const endpoint = isMM
245
248
  ? `${providerUrl.replace(/\/+$/, '')}/v1/text/chatcompletion_v2`
246
- : `${providerUrl.replace(/\/+$/, '')}/chat/completions`;
249
+ : isGemini(providerUrl)
250
+ ? `${providerUrl.replace(/\/+$/, '')}/openai/chat/completions`
251
+ : `${providerUrl.replace(/\/+$/, '')}/chat/completions`;
247
252
  const req = https.request(endpoint, {
248
253
  method: 'POST',
249
254
  headers: {
@@ -272,6 +277,7 @@ function apiRequest(providerUrl, providerApiKey, body, stream = false) {
272
277
 
273
278
  async function sendStreaming(providerUrl, providerApiKey, messages, model, onChunk, onToolCall) {
274
279
  const isMM = isMiniMax(providerUrl);
280
+ const isGM = isGemini(providerUrl);
275
281
  const toolDefs = getToolDefs();
276
282
  const toolParam = toOpenAIFormat(toolDefs);
277
283
  guardrails.reset();
@@ -312,7 +318,7 @@ async function sendStreaming(providerUrl, providerApiKey, messages, model, onChu
312
318
  iterations++;
313
319
  // v5.7.18: Preflight compress before each iteration to prevent context bloat
314
320
  currentMessages = preflightCompress(currentMessages);
315
- const shouldStream = !isMM; // MiniMax streaming endpoint doesn't support tool_calls
321
+ const shouldStream = !isMM && !isGM; // MiniMax + Gemini non-stream (tool_calls reliability)
316
322
  const body = {
317
323
  model,
318
324
  messages: currentMessages,
@@ -321,7 +327,7 @@ async function sendStreaming(providerUrl, providerApiKey, messages, model, onChu
321
327
  max_tokens: 2048,
322
328
  };
323
329
  if (toolParam) body.tools = toolParam;
324
- if (isMM) body.tool_choice = 'auto'; // MiniMax için explicit
330
+ if (isMM || isGM) body.tool_choice = 'auto'; // MiniMax + Gemini için explicit
325
331
 
326
332
  if (!shouldStream) {
327
333
  // MiniMax (non-stream) — tool_calls desteklemiyor varsayalım
@@ -344,10 +350,12 @@ async function sendStreaming(providerUrl, providerApiKey, messages, model, onChu
344
350
  }
345
351
 
346
352
  // OpenAI uyumlu streaming (veya MiniMax /v1/text/chatcompletion_v2)
347
- // v4.8.2: MiniMax tool calling sadece özel endpoint'inde çalışıyor
353
+ // v5.9.5: Gemini /openai/chat/completions provider-detect.js buildChatEndpoint
348
354
  const endpoint = isMM
349
355
  ? `${providerUrl.replace(/\/+$/, '')}/v1/text/chatcompletion_v2`
350
- : `${providerUrl.replace(/\/+$/, '')}/chat/completions`;
356
+ : isGemini(providerUrl)
357
+ ? `${providerUrl.replace(/\/+$/, '')}/openai/chat/completions`
358
+ : `${providerUrl.replace(/\/+$/, '')}/chat/completions`;
351
359
  const result = await new Promise((resolve, reject) => {
352
360
  const req = https.request(endpoint, {
353
361
  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
  };