natureco-cli 5.5.3 → 5.6.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/package.json +1 -1
- package/src/commands/gateway-server.js +12 -12
- package/src/commands/reset.js +88 -80
- package/src/commands/setup.js +58 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natureco-cli",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.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"
|
|
@@ -142,7 +142,7 @@ async function runGatewayWorker() {
|
|
|
142
142
|
log('gateway', `Starting NatureCo Gateway v${pkg.version}...`, 'green');
|
|
143
143
|
|
|
144
144
|
// Load config
|
|
145
|
-
const { getConfig } = require('../utils/config');
|
|
145
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
146
146
|
const config = getConfig();
|
|
147
147
|
|
|
148
148
|
if (!config || !config.providerUrl) {
|
|
@@ -391,7 +391,7 @@ async function startWhatsAppProvider(sessionDir, config) {
|
|
|
391
391
|
try {
|
|
392
392
|
const { sendMessage } = require('../utils/api');
|
|
393
393
|
const { getMemoryPrompt, extractMemoryFromMessage, addMemoryEntry } = require('../utils/memory');
|
|
394
|
-
const { getConfig } = require('../utils/config');
|
|
394
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
395
395
|
const cfg = getConfig();
|
|
396
396
|
|
|
397
397
|
log('whatsapp', 'Sending to AI provider...', 'cyan');
|
|
@@ -615,7 +615,7 @@ async function startTelegramProvider(config) {
|
|
|
615
615
|
try {
|
|
616
616
|
const { sendMessage } = require('../utils/api');
|
|
617
617
|
const { getMemoryPrompt, extractMemoryFromMessage, addMemoryEntry } = require('../utils/memory');
|
|
618
|
-
const { getConfig } = require('../utils/config');
|
|
618
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
619
619
|
const cfg = getConfig();
|
|
620
620
|
|
|
621
621
|
log('telegram', 'Sending to AI provider...', 'cyan');
|
|
@@ -886,7 +886,7 @@ async function processSignalEnvelope(envelope, config) {
|
|
|
886
886
|
try {
|
|
887
887
|
const { sendMessage } = require('../utils/api');
|
|
888
888
|
const { getMemoryPrompt, extractMemoryFromMessage, addMemoryEntry } = require('../utils/memory');
|
|
889
|
-
const { getConfig } = require('../utils/config');
|
|
889
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
890
890
|
const cfg = getConfig();
|
|
891
891
|
|
|
892
892
|
const conversationId = `signal_${sender}`;
|
|
@@ -1140,7 +1140,7 @@ async function processIrcMessage(config, sender, target, text, socket) {
|
|
|
1140
1140
|
try {
|
|
1141
1141
|
const { sendMessage } = require('../utils/api');
|
|
1142
1142
|
const { getMemoryPrompt } = require('../utils/memory');
|
|
1143
|
-
const { getConfig } = require('../utils/config');
|
|
1143
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
1144
1144
|
const cfg = getConfig();
|
|
1145
1145
|
|
|
1146
1146
|
const conversationId = `irc_${sender}_${target}`;
|
|
@@ -1324,7 +1324,7 @@ async function handleMattermostPost(data, broadcast, config) {
|
|
|
1324
1324
|
// Get AI response
|
|
1325
1325
|
const { sendMessage } = require('../utils/api');
|
|
1326
1326
|
const { getMemoryPrompt } = require('../utils/memory');
|
|
1327
|
-
const { getConfig } = require('../utils/config');
|
|
1327
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
1328
1328
|
const cfg = getConfig();
|
|
1329
1329
|
|
|
1330
1330
|
const conversationId = `mattermost_${channelId}`;
|
|
@@ -1446,7 +1446,7 @@ async function processImessageMessage(msg, config) {
|
|
|
1446
1446
|
|
|
1447
1447
|
const { sendMessage } = require('../utils/api');
|
|
1448
1448
|
const { getMemoryPrompt } = require('../utils/memory');
|
|
1449
|
-
const { getConfig } = require('../utils/config');
|
|
1449
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
1450
1450
|
const cfg = getConfig();
|
|
1451
1451
|
|
|
1452
1452
|
const conversationId = `imessage_${sender}`;
|
|
@@ -1614,7 +1614,7 @@ async function handleSmsWebhook(config, body, req) {
|
|
|
1614
1614
|
try {
|
|
1615
1615
|
const { sendMessage } = require('../utils/api');
|
|
1616
1616
|
const { getMemoryPrompt } = require('../utils/memory');
|
|
1617
|
-
const { getConfig } = require('../utils/config');
|
|
1617
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
1618
1618
|
const cfg = getConfig();
|
|
1619
1619
|
|
|
1620
1620
|
const conversationId = `sms_${from}`;
|
|
@@ -1664,7 +1664,7 @@ function startHttpServer() {
|
|
|
1664
1664
|
|
|
1665
1665
|
if (req.method === 'POST' && req.url === '/webhooks/sms') {
|
|
1666
1666
|
// Twilio SMS webhook handler
|
|
1667
|
-
const { getConfig } = require('../utils/config');
|
|
1667
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
1668
1668
|
const cfg = getConfig();
|
|
1669
1669
|
|
|
1670
1670
|
let body = '';
|
|
@@ -1745,7 +1745,7 @@ function startHttpServer() {
|
|
|
1745
1745
|
res.end(JSON.stringify({ success: true, channel: 'telegram', target }));
|
|
1746
1746
|
|
|
1747
1747
|
} else if (channel === 'signal') {
|
|
1748
|
-
const { getConfig } = require('../utils/config');
|
|
1748
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
1749
1749
|
const cfg = getConfig();
|
|
1750
1750
|
if (!cfg.signalHttpUrl) {
|
|
1751
1751
|
res.writeHead(503, { 'Content-Type': 'application/json' });
|
|
@@ -1857,7 +1857,7 @@ function startCronJobs(config) {
|
|
|
1857
1857
|
|
|
1858
1858
|
try {
|
|
1859
1859
|
// Get provider config
|
|
1860
|
-
const { getConfig } = require('../utils/config');
|
|
1860
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
1861
1861
|
const cfg = getConfig();
|
|
1862
1862
|
|
|
1863
1863
|
if (!cfg.providerUrl || !cfg.providerApiKey) {
|
|
@@ -1950,7 +1950,7 @@ function startCronJobs(config) {
|
|
|
1950
1950
|
await global.telegramBot.sendMessage(cronJob.target, reply);
|
|
1951
1951
|
log('cron', `Sent to Telegram: ${cronJob.target}`, 'green');
|
|
1952
1952
|
} else if (cronJob.action === 'signal') {
|
|
1953
|
-
const { getConfig } = require('../utils/config');
|
|
1953
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
1954
1954
|
const cfg = getConfig();
|
|
1955
1955
|
if (!cfg.signalHttpUrl) {
|
|
1956
1956
|
log('cron', 'Signal not connected, skipping', 'red');
|
package/src/commands/reset.js
CHANGED
|
@@ -1,101 +1,109 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* natureco reset - Her seyi sifirla (v5.6.0)
|
|
3
|
+
*
|
|
4
|
+
* Options:
|
|
5
|
+
* --all Config, memory, sessions, soul hepsini sil
|
|
6
|
+
* --config Sadece config.json
|
|
7
|
+
* --memory Sadece memory
|
|
8
|
+
* --sessions Sadece sessions
|
|
9
|
+
* --soul Sadece soul
|
|
10
|
+
* --personal Personal klasoru (sadece v5.6.0+)
|
|
11
|
+
*
|
|
12
|
+
* Confirmation gerekli (y/n)
|
|
13
|
+
*/
|
|
14
|
+
|
|
2
15
|
const fs = require('fs');
|
|
3
16
|
const path = require('path');
|
|
4
17
|
const os = require('os');
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const BASE_DIR = path.join(os.homedir(), '.natureco');
|
|
8
|
-
const CONFIG_FILE = path.join(BASE_DIR, 'config.json');
|
|
9
|
-
const WORKSPACE_DIR = path.join(BASE_DIR, 'workspace');
|
|
10
|
-
|
|
11
|
-
function rlQuestion(query) {
|
|
12
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
13
|
-
return new Promise(resolve => {
|
|
14
|
-
rl.question(query, answer => { rl.close(); resolve(answer.trim().toLowerCase()); });
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async function reset(params) {
|
|
19
|
-
try {
|
|
20
|
-
const [action] = params || [];
|
|
21
|
-
|
|
22
|
-
if (!action || action === 'list') return cmdList();
|
|
23
|
-
if (action === 'config') return await cmdConfig();
|
|
24
|
-
if (action === 'workspace') return await cmdWorkspace();
|
|
25
|
-
if (action === 'all') return await cmdAll();
|
|
26
|
-
|
|
27
|
-
console.log(chalk.red(`\n Unknown reset action: ${action}\n`));
|
|
28
|
-
console.log(chalk.gray(' Usage: natureco reset [config|workspace|all|list]\n'));
|
|
29
|
-
} catch (err) {
|
|
30
|
-
console.log(chalk.red(`\n Reset error: ${err.message}\n`));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function cmdList() {
|
|
35
|
-
console.log(chalk.cyan('\n Reset — What Would Be Removed\n'));
|
|
36
|
-
|
|
37
|
-
if (fs.existsSync(CONFIG_FILE)) console.log(chalk.gray(' • ') + chalk.white('Config file') + chalk.gray(' (' + CONFIG_FILE + ')'));
|
|
38
|
-
else console.log(chalk.gray(' • Config file — ') + chalk.gray('not found'));
|
|
39
|
-
|
|
40
|
-
if (fs.existsSync(WORKSPACE_DIR)) console.log(chalk.gray(' • ') + chalk.white('Workspace directory') + chalk.gray(' (' + WORKSPACE_DIR + ')'));
|
|
41
|
-
else console.log(chalk.gray(' • Workspace directory — ') + chalk.gray('not found'));
|
|
18
|
+
const inquirer = require('../utils/inquirer-wrapper');
|
|
19
|
+
const chalk = require('chalk');
|
|
42
20
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
21
|
+
async function reset() {
|
|
22
|
+
const args = process.argv.slice(3);
|
|
23
|
+
const home = os.homedir();
|
|
24
|
+
const baseDir = path.join(home, '.natureco');
|
|
25
|
+
|
|
26
|
+
console.log(chalk.yellow('\n\u26a0 RESET - Tum veriler silinecek!\n'));
|
|
27
|
+
|
|
28
|
+
const whatToReset = {
|
|
29
|
+
config: args.includes('--all') || args.includes('--config'),
|
|
30
|
+
memory: args.includes('--all') || args.includes('--memory'),
|
|
31
|
+
sessions: args.includes('--all') || args.includes('--sessions'),
|
|
32
|
+
soul: args.includes('--all') || args.includes('--soul'),
|
|
33
|
+
personal: args.includes('--all') || args.includes('--personal'),
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Eger hicbir flag yoksa hepsini sifirla
|
|
37
|
+
if (!args.some(a => a.startsWith('--'))) {
|
|
38
|
+
whatToReset.config = true;
|
|
39
|
+
whatToReset.memory = true;
|
|
40
|
+
whatToReset.sessions = true;
|
|
41
|
+
whatToReset.soul = true;
|
|
48
42
|
}
|
|
49
43
|
|
|
50
|
-
console.log('');
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
|
|
44
|
+
console.log('Silinecek:');
|
|
45
|
+
if (whatToReset.config) console.log(' - config.json');
|
|
46
|
+
if (whatToReset.memory) console.log(' - memory/');
|
|
47
|
+
if (whatToReset.sessions) console.log(' - sessions/');
|
|
48
|
+
if (whatToReset.soul) console.log(' - soul/ (generic default doner)');
|
|
49
|
+
if (whatToReset.personal) console.log(' - personal/');
|
|
50
|
+
|
|
51
|
+
// Onay
|
|
52
|
+
const ans = await inquirer.prompt([{
|
|
53
|
+
type: 'confirm',
|
|
54
|
+
name: 'confirm',
|
|
55
|
+
message: 'Tum verileri silmek istediginize emin misiniz?',
|
|
56
|
+
default: false,
|
|
57
|
+
}]);
|
|
58
|
+
|
|
59
|
+
if (!ans.confirm) {
|
|
60
|
+
console.log(chalk.gray('\nIptal edildi.'));
|
|
56
61
|
return;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
// Sil
|
|
65
|
+
if (whatToReset.config) {
|
|
66
|
+
const f = path.join(baseDir, 'config.json');
|
|
67
|
+
if (fs.existsSync(f)) {
|
|
68
|
+
fs.unlinkSync(f);
|
|
69
|
+
console.log(chalk.green(' \u2713 config.json silindi'));
|
|
70
|
+
}
|
|
63
71
|
}
|
|
64
72
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
console.log(chalk.yellow('\n No workspace directory to remove.\n'));
|
|
72
|
-
return;
|
|
73
|
+
if (whatToReset.memory) {
|
|
74
|
+
const d = path.join(baseDir, 'memory');
|
|
75
|
+
if (fs.existsSync(d)) {
|
|
76
|
+
fs.rmSync(d, { recursive: true });
|
|
77
|
+
console.log(chalk.green(' \u2713 memory/ silindi'));
|
|
78
|
+
}
|
|
73
79
|
}
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
if (whatToReset.sessions) {
|
|
82
|
+
const d = path.join(baseDir, 'sessions');
|
|
83
|
+
if (fs.existsSync(d)) {
|
|
84
|
+
fs.rmSync(d, { recursive: true });
|
|
85
|
+
console.log(chalk.green(' \u2713 sessions/ silindi'));
|
|
86
|
+
}
|
|
79
87
|
}
|
|
80
88
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
console.log(chalk.yellow('\n Nothing to remove — ~/.natureco does not exist.\n'));
|
|
88
|
-
return;
|
|
89
|
+
if (whatToReset.soul) {
|
|
90
|
+
const d = path.join(baseDir, 'soul');
|
|
91
|
+
if (fs.existsSync(d)) {
|
|
92
|
+
fs.rmSync(d, { recursive: true });
|
|
93
|
+
console.log(chalk.green(' \u2713 soul/ silindi (generic doner)'));
|
|
94
|
+
}
|
|
89
95
|
}
|
|
90
96
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
if (whatToReset.personal) {
|
|
98
|
+
const d = path.join(baseDir, 'personal');
|
|
99
|
+
if (fs.existsSync(d)) {
|
|
100
|
+
fs.rmSync(d, { recursive: true });
|
|
101
|
+
console.log(chalk.green(' \u2713 personal/ silindi'));
|
|
102
|
+
}
|
|
95
103
|
}
|
|
96
104
|
|
|
97
|
-
|
|
98
|
-
console.log(chalk.
|
|
105
|
+
console.log(chalk.cyan('\n\u2705 Reset tamamlandi!'));
|
|
106
|
+
console.log(chalk.gray(' Yeniden kurmak icin: natureco setup\n'));
|
|
99
107
|
}
|
|
100
108
|
|
|
101
|
-
module.exports = reset;
|
|
109
|
+
module.exports = { reset };
|
package/src/commands/setup.js
CHANGED
|
@@ -147,6 +147,24 @@ async function cmdWizard() {
|
|
|
147
147
|
const apiKey = await rlQuestion(` API Key ${currentKey ? '(leave blank to keep current)' : ''}: `);
|
|
148
148
|
if (apiKey) {
|
|
149
149
|
cfg.providerApiKey = apiKey;
|
|
150
|
+
// v5.6.0: API key dogrula
|
|
151
|
+
console.log('\n Doğrulanıyor...');
|
|
152
|
+
const isValid = await validateApiKey(cfg.providerUrl, apiKey);
|
|
153
|
+
if (!isValid) {
|
|
154
|
+
console.log(' ❌ API key gecersiz! Lutfen kontrol edin.');
|
|
155
|
+
const retry = await inquirer.prompt([{
|
|
156
|
+
type: 'confirm',
|
|
157
|
+
name: 'continue',
|
|
158
|
+
message: 'Yine de devam etmek istiyor musunuz? (key sonra duzeltilebilir)',
|
|
159
|
+
default: false,
|
|
160
|
+
}]);
|
|
161
|
+
if (!retry.continue) {
|
|
162
|
+
console.log(' Setup iptal edildi. Tekrar deneyin: natureco setup');
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
console.log(' ✓ API key gecerli!');
|
|
167
|
+
}
|
|
150
168
|
}
|
|
151
169
|
|
|
152
170
|
// Step 3: Bot & User identity
|
|
@@ -300,3 +318,43 @@ function cmdDirs() {
|
|
|
300
318
|
}
|
|
301
319
|
|
|
302
320
|
module.exports = setup;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* v5.6.0: API key dogrulama — test istegi gonder
|
|
324
|
+
* Boylece kullanici yanlis key ile devam etmez
|
|
325
|
+
*/
|
|
326
|
+
async function validateApiKey(providerUrl, apiKey) {
|
|
327
|
+
return new Promise((resolve) => {
|
|
328
|
+
const https = require('https');
|
|
329
|
+
const url = new URL(providerUrl);
|
|
330
|
+
const endpoint = url.hostname.includes('minimax')
|
|
331
|
+
? providerUrl.replace(/\/+$/, '') + '/v1/text/chatcompletion_v2'
|
|
332
|
+
: providerUrl.replace(/\/+$/, '') + '/chat/completions';
|
|
333
|
+
|
|
334
|
+
const data = JSON.stringify({
|
|
335
|
+
model: 'test',
|
|
336
|
+
messages: [{ role: 'user', content: 'ping' }],
|
|
337
|
+
max_tokens: 5
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
const u = new URL(endpoint);
|
|
341
|
+
const req = https.request({
|
|
342
|
+
hostname: u.hostname,
|
|
343
|
+
port: u.port || 443,
|
|
344
|
+
path: u.pathname,
|
|
345
|
+
method: 'POST',
|
|
346
|
+
headers: {
|
|
347
|
+
'Authorization': 'Bearer ' + apiKey,
|
|
348
|
+
'Content-Type': 'application/json',
|
|
349
|
+
'Content-Length': Buffer.byteLength(data)
|
|
350
|
+
},
|
|
351
|
+
timeout: 10000
|
|
352
|
+
}, (res) => {
|
|
353
|
+
resolve(res.statusCode >= 200 && res.statusCode < 400);
|
|
354
|
+
});
|
|
355
|
+
req.on('error', () => resolve(false));
|
|
356
|
+
req.on('timeout', () => { req.destroy(); resolve(false); });
|
|
357
|
+
req.write(data);
|
|
358
|
+
req.end();
|
|
359
|
+
});
|
|
360
|
+
}
|