natureco-cli 4.8.2 → 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 +1 -1
- package/src/commands/repl.js +4 -1
- package/src/tools/image_generation.js +44 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natureco-cli",
|
|
3
|
-
"version": "4.8.
|
|
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"
|
package/src/commands/repl.js
CHANGED
|
@@ -211,7 +211,9 @@ function apiRequest(providerUrl, providerApiKey, body, stream = false) {
|
|
|
211
211
|
async function sendStreaming(providerUrl, providerApiKey, messages, model, onChunk, onToolCall) {
|
|
212
212
|
const isMM = isMiniMax(providerUrl);
|
|
213
213
|
const toolDefs = getToolDefs();
|
|
214
|
-
|
|
214
|
+
// v4.8.2: MiniMax da tools destekliyor — endpoint'te fark var,
|
|
215
|
+
// ama tools parametresi aynı
|
|
216
|
+
const toolParam = toOpenAIFormat(toolDefs);
|
|
215
217
|
|
|
216
218
|
// v4.8.0: Tool calling + streaming + multi-turn tool execution
|
|
217
219
|
let currentMessages = messages;
|
|
@@ -229,6 +231,7 @@ async function sendStreaming(providerUrl, providerApiKey, messages, model, onChu
|
|
|
229
231
|
max_tokens: 2048,
|
|
230
232
|
};
|
|
231
233
|
if (toolParam) body.tools = toolParam;
|
|
234
|
+
if (isMM) body.tool_choice = 'auto'; // MiniMax için explicit
|
|
232
235
|
|
|
233
236
|
if (!body.stream) {
|
|
234
237
|
// MiniMax (non-stream) — tool_calls desteklemiyor varsayalım
|
|
@@ -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
|
-
|
|
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
|
-
|
|
69
|
-
if (provider
|
|
70
|
-
|
|
71
|
-
|
|
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({
|