natureco-cli 5.26.0 → 5.28.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to NatureCo CLI will be documented in this file.
4
4
 
5
+ ## [5.28.0] - 2026-07-04 — "AJAN EXEC GÜVENLİK POLİTİKASI (deny-by-default)"
6
+
7
+ ### 🔒 Güvenlik
8
+ - **Ajan exec politikasi**: agentic yolda `bash` artik deny-by-default — ajan yalnizca guvenli komut SINIFLARINI otonom calistirir (node/npm/npx/python/pip/go/cargo/git-local/ls/grep/mkdir/test-runner...). Ag/yayin/sistem/ayricalik komutlari (curl, wget, ssh, scp, sudo, git push, npm publish, docker, systemctl...) OTOMATIK CALISTIRILMAZ; zincirdeki gizli komut da yakalanir (`ls && curl` → blok). Neden interaktif y/n degil: pipe/CI/non-TTY'de calismaz + REPL readline'iyla cakisir + kullanici tikla-gec yapar → deny-by-default politika otonom ajan icin daha guvenli. Power-user: `NATURECO_AGENT_EXEC=full`.
9
+ - Katmanli guvenlik: yikici-komut guard (rm -rf) + exec politikasi + bash.js approvals + agentic allowlist (yalnizca 7 arac).
10
+
11
+ Doğrulama: mesru kodlama komutlari (node/npm) E2E calisir; curl/git push/npm publish engellenir; **489 test yeşil**, ESLint temiz.
12
+
13
+ ## [5.27.0] - 2026-07-04 — "GEMINI DÜZELTMESİ + DÖNGÜ BİRLEŞTİRME (2 sağlayıcı E2E)"
14
+
15
+ ### 🐛 Düzeltme / ✨ İyileştirme
16
+ - **Gemini artik calisiyor**: `supportsToolCalls()` Gemini'yi robust agentic-runner yoluna aldi. Neden: `gemini-2.5-flash` bir "thinking" modeli — plan-bazli yoldaki dusuk `max_tokens` (orn. 20) cagrilarinda tum butceyi ic dusunmede harcayip BOS donuyordu. Agentic yol (yuksek max_tokens + native tool_calls/XML parse) bunu cozer. (Kod yorumu zaten "Gemini desteklemez" diyordu ama uygulanmamisti — tutarsizlik giderildi.)
17
+ - **Dongu birlestirme (dogrulanmis)**: `agentic-runner` artik 2 farkli saglayici ailesinde E2E dogrulandi — **MiniMax** (native XML tool-call) + **Gemini** (OpenAI-compat, gercek key ile dosya olusturma + memory recall "Gencay"). Groq/Ollama/localhost da bu yolu kullanir. OpenAI/Anthropic native `tool_calls` yolunda kalir (standart, dokunulmadi).
18
+
19
+ Doğrulama: Gemini gercek key ile E2E (dosya olusturma + hafiza); **484 test yeşil**, ESLint temiz.
20
+
5
21
  ## [5.26.0] - 2026-07-04 — "CANLI STREAMING + KEŞFET→DÜZENLE→DOĞRULA"
6
22
 
7
23
  ### ✨ Yeni
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "natureco-cli",
3
- "version": "5.26.0",
3
+ "version": "5.28.0",
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"
@@ -47,6 +47,42 @@ function defaultIsDangerous(cmd) {
47
47
  try { return require('../utils/approvals').isDangerousCommand(cmd); } catch { return false; }
48
48
  }
49
49
 
50
+ // Ajan exec politikasi (deny-by-default): ajan yalnizca guvenli komut SINIFLARINI
51
+ // otonom calistirir. Ag/yayin/sistem/ayricalik komutlari (curl, wget, ssh, sudo,
52
+ // git push, npm publish, docker, systemctl...) engellenir — model urettigi komut
53
+ // milyonlarca cihazda kontrolsuz calismasin. Power-user: NATURECO_AGENT_EXEC=full.
54
+ // Interaktif y/n yerine bunu sectik: pipe/CI/non-TTY'de calisir, readline cakismaz,
55
+ // deterministik + test edilebilir (kullanici tikla-gec etmez).
56
+ const AGENT_EXEC_ALLOW = new Set([
57
+ 'node', 'npm', 'npx', 'yarn', 'pnpm', 'bun', 'deno',
58
+ 'python', 'python3', 'py', 'pip', 'pip3', 'pipx', 'pytest', 'poetry',
59
+ 'go', 'cargo', 'rustc', 'java', 'javac', 'mvn', 'gradle', 'ruby', 'gem', 'bundle',
60
+ 'php', 'composer', 'dotnet', 'tsc', 'tsx', 'ts-node', 'jest', 'vitest', 'mocha',
61
+ 'eslint', 'prettier', 'ruff', 'black', 'flake8', 'mypy', 'make', 'cmake', 'meson', 'ninja',
62
+ 'ls', 'dir', 'cat', 'type', 'head', 'tail', 'pwd', 'echo', 'printf', 'grep', 'findstr',
63
+ 'find', 'wc', 'which', 'where', 'whereis', 'tree', 'stat', 'file', 'sort', 'uniq', 'diff',
64
+ 'mkdir', 'touch', 'cp', 'copy', 'mv', 'move', 'git', 'jq', 'sed', 'awk', 'date', 'env', 'whoami',
65
+ ]);
66
+ const AGENT_EXEC_BLOCK_PATTERNS = [
67
+ /\bnpm\s+publish\b/i, /\byarn\s+publish\b/i, /\bpnpm\s+publish\b/i,
68
+ /\bgit\s+push\b/i, /\bgit\s+remote\s+(add|set-url)\b/i,
69
+ /\bnpm\s+(un)?deprecate\b/i, /\bnpm\s+owner\b/i,
70
+ ];
71
+ function agentExecAllowed(command) {
72
+ if (String(process.env.NATURECO_AGENT_EXEC || '').toLowerCase() === 'full') return true;
73
+ const cmd = String(command || '').trim();
74
+ if (!cmd) return false;
75
+ if (AGENT_EXEC_BLOCK_PATTERNS.some(re => re.test(cmd))) return false;
76
+ // pipe/zincir (&&, ||, |, ;) ile ayrilmis HER segmentin ilk komutunu dogrula
77
+ const segments = cmd.split(/&&|\|\||\||;/).map(s => s.trim()).filter(Boolean);
78
+ for (const seg of segments) {
79
+ const first = (seg.split(/\s+/)[0] || '').replace(/^["']|["']$/g, '');
80
+ const base = (first.split(/[\\/]/).pop() || '').toLowerCase().replace(/\.(exe|cmd|bat|ps1)$/, '');
81
+ if (!AGENT_EXEC_ALLOW.has(base)) return false;
82
+ }
83
+ return true;
84
+ }
85
+
50
86
  /**
51
87
  * Model metninden agentic tool cagrilarini cikar.
52
88
  * Destekler: <invoke name><parameter name> (opsiyonel <minimax:tool_call> sarmali),
@@ -249,6 +285,11 @@ async function executeCall(call, opts = {}) {
249
285
  records.push({ tool: 'bash', status: 'error', args: { command: cmd }, error: 'Yikici/tehlikeli komut ajan modunda engellendi' });
250
286
  return { records, feedback: `bash: "${cmd.slice(0, 80)}" yikici/tehlikeli goruldugu icin ajan tarafindan CALISTIRILMADI. Gerekirse kullanici komutu kendisi calistirabilir.` };
251
287
  }
288
+ const execOk = opts.agentExecAllowed || agentExecAllowed;
289
+ if (!execOk(cmd)) {
290
+ records.push({ tool: 'bash', status: 'error', args: { command: cmd }, error: 'Ajan exec politikasi disinda' });
291
+ return { records, feedback: `bash: "${cmd.slice(0, 80)}" ajan guvenlik politikasi disinda (ag/yayin/sistem komutu olabilir). Otomatik CALISTIRILMADI. Kullanici manuel calistirabilir; tum komutlara izin: NATURECO_AGENT_EXEC=full.` };
292
+ }
252
293
  }
253
294
 
254
295
  let mod;
@@ -319,4 +360,4 @@ async function runAgentic({ callModel, systemPrompt, historyMessages, task, tool
319
360
  return { records: allRecords, reply: finalReply, iterations };
320
361
  }
321
362
 
322
- module.exports = { parseAgenticCalls, stripProtocolTokens, executeCall, runAgentic, expandHome, makeStreamFilter, makeSanitizeStream, TOOL_ALIASES, DEFAULT_ALLOWED };
363
+ module.exports = { parseAgenticCalls, stripProtocolTokens, executeCall, runAgentic, expandHome, makeStreamFilter, makeSanitizeStream, agentExecAllowed, TOOL_ALIASES, DEFAULT_ALLOWED };
@@ -201,8 +201,10 @@ async function workflow(params) {
201
201
  // Non-tool-calling model tespiti
202
202
  function supportsToolCalls() {
203
203
  const url = (providerUrl || '').toLowerCase();
204
- // MiniMax, Gemini (direct), Ollama, Mistral (direct) tool calling'i desteklemez
204
+ // Bu saglayicilar OpenAI-tarzi tool_calls JSON'unu guvenilir uretmiyor (ya native
205
+ // XML uretiyor ya da dusuk max_tokens'ta bos donuyor) → robust agentic-runner yolu.
205
206
  if (url.includes('minimax')) return false;
207
+ if (url.includes('generativelanguage') || url.includes('gemini')) return false; // Gemini 2.5 "thinking" — plan yolundaki dusuk max_tokens'ta bos doner
206
208
  if (url.includes('ollama')) return false;
207
209
  if (url.includes('localhost')) return false;
208
210
  if (url.includes('groq')) return false;