natureco-cli 4.8.3 → 4.8.4

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": "4.8.3",
3
+ "version": "4.8.4",
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"
@@ -1,6 +1,22 @@
1
1
  const { getConfig } = require('../utils/config');
2
2
 
3
3
  const PROVIDERS = {
4
+ // v4.8.4: Pollinations.ai — TAMAMEN ÜCRETSİZ, API key gerektirmez
5
+ // Default provider olarak ayarlandı (herkes kullanabilsin)
6
+ pollinations: {
7
+ name: 'Pollinations.ai (Ücretsiz, key gerekmez)',
8
+ async generate({ prompt, width, height, seed, model }) {
9
+ const w = width || 1024;
10
+ const h = height || 1024;
11
+ const m = model || 'flux'; // flux, turbo, sd, etc.
12
+ const s = seed || Date.now() % 1000000;
13
+ const url = `https://image.pollinations.ai/prompt/${encodeURIComponent(prompt)}?width=${w}&height=${h}&seed=${s}&model=${m}&nologo=true`;
14
+ const response = await fetch(url, { method: 'GET' });
15
+ if (!response.ok) throw new Error(`Pollinations error ${response.status}: ${await response.text()}`);
16
+ const buffer = Buffer.from(await response.arrayBuffer());
17
+ return [{ url, buffer, mime: 'image/jpeg' }];
18
+ }
19
+ },
4
20
  openai: {
5
21
  name: 'OpenAI DALL-E',
6
22
  async generate({ prompt, size, n, apiKey }) {
@@ -58,23 +74,40 @@ module.exports = {
58
74
  async execute(params) {
59
75
  try {
60
76
  const config = getConfig();
61
- const provider = params.provider || config.imageProvider || 'openai';
77
+
78
+ // v4.8.4: Önce key varsa openai/together/fal dene, yoksa Pollinations (ücretsiz)
79
+ const openaiKey = params.apiKey || config.openaiApiKey || process.env.OPENAI_API_KEY;
80
+ const falKey = params.apiKey || config.falApiKey || process.env.FAL_KEY;
81
+ const togetherKey = params.apiKey || config.togetherApiKey || process.env.TOGETHER_API_KEY;
82
+
83
+ // Explicit provider tercih edilmişse onu kullan
84
+ let provider = params.provider || config.imageProvider;
85
+ let apiKey;
86
+
87
+ if (provider) {
88
+ // Explicit provider
89
+ if (provider === 'openai') apiKey = openaiKey;
90
+ else if (provider === 'fal') apiKey = falKey;
91
+ else if (provider === 'together') apiKey = togetherKey;
92
+ else if (provider === 'pollinations') apiKey = 'free'; // key gereksiz
93
+ } else {
94
+ // Auto-fallback: key varsa onu kullan, yoksa Pollinations
95
+ if (openaiKey) { provider = 'openai'; apiKey = openaiKey; }
96
+ else if (togetherKey) { provider = 'together'; apiKey = togetherKey; }
97
+ else if (falKey) { provider = 'fal'; apiKey = falKey; }
98
+ else { provider = 'pollinations'; apiKey = 'free'; }
99
+ }
62
100
 
63
101
  const providerConfig = PROVIDERS[provider];
64
102
  if (!providerConfig) {
65
103
  return { success: false, error: `Desteklenmeyen provider: ${provider}. Kullanılabilir: ${Object.keys(PROVIDERS).join(', ')}` };
66
104
  }
67
105
 
68
- let apiKey;
69
- if (provider === 'openai') apiKey = params.apiKey || config.openaiApiKey || process.env.OPENAI_API_KEY;
70
- else if (provider === 'fal') apiKey = params.apiKey || config.falApiKey || process.env.FAL_KEY;
71
- else if (provider === 'together') apiKey = params.apiKey || config.togetherApiKey || process.env.TOGETHER_API_KEY;
72
-
73
- if (!apiKey) {
74
- return {
75
- success: false,
76
- error: `${providerConfig.name} API key gerekli.\nKur: natureco config set ${provider}ApiKey <key>`
77
- };
106
+ // Pollinations hariç — key yoksa hata
107
+ if (provider !== 'pollinations' && !apiKey) {
108
+ // Son fallback: Pollinations'a geç
109
+ provider = 'pollinations';
110
+ apiKey = 'free';
78
111
  }
79
112
 
80
113
  const images = await providerConfig.generate({