natureco-cli 2.2.7 → 2.3.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/dashboard.js +2 -2
- package/src/commands/discord.js +18 -63
- package/src/commands/gateway-server.js +14 -7
- package/src/commands/slack.js +16 -61
- package/src/commands/whatsapp.js +6 -30
- package/src/utils/api.js +6 -0
package/package.json
CHANGED
|
@@ -211,7 +211,7 @@ body::before{
|
|
|
211
211
|
<div class="header-bot-name" id="header-bot-name">Nature Bot</div>
|
|
212
212
|
<div class="header-bot-model" id="header-bot-model">NatureCo</div>
|
|
213
213
|
</div>
|
|
214
|
-
<div class="version-badge" id="version-badge">v2.
|
|
214
|
+
<div class="version-badge" id="version-badge">v2.3.0</div>
|
|
215
215
|
</div>
|
|
216
216
|
<div class="messages" id="messages"></div>
|
|
217
217
|
<div class="input-area">
|
|
@@ -341,7 +341,7 @@ function dashboard(action) {
|
|
|
341
341
|
apiKey: cfg.apiKey,
|
|
342
342
|
defaultBot: cfg.defaultBot,
|
|
343
343
|
defaultBotId: cfg.defaultBotId,
|
|
344
|
-
version: 'v2.
|
|
344
|
+
version: 'v2.3.0',
|
|
345
345
|
bots: cfg.bots || [],
|
|
346
346
|
telegramToken: cfg.telegramToken || null,
|
|
347
347
|
whatsappConnected: cfg.whatsappConnected || false,
|
package/src/commands/discord.js
CHANGED
|
@@ -22,39 +22,16 @@ async function discord(action) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
async function connectDiscord() {
|
|
25
|
-
const apiKey = getApiKey();
|
|
26
|
-
|
|
27
|
-
if (!apiKey) {
|
|
28
|
-
console.log(chalk.red('\n❌ Not logged in. Run "natureco login" first.\n'));
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
25
|
const config = getConfig();
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
let botList;
|
|
37
|
-
try {
|
|
38
|
-
botList = await getBots(apiKey);
|
|
39
|
-
} catch (err) {
|
|
40
|
-
console.log(chalk.red(`\n❌ Error: ${err.message}\n`));
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!botList || !botList.bots || botList.bots.length === 0) {
|
|
45
|
-
console.log(chalk.gray('No bots found. Create one at https://developers.natureco.me\n'));
|
|
27
|
+
if (!config.providerUrl) {
|
|
28
|
+
console.log(chalk.red('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n'));
|
|
46
29
|
process.exit(1);
|
|
47
30
|
}
|
|
48
31
|
|
|
49
32
|
process.stdin.resume();
|
|
50
33
|
|
|
51
34
|
const answers = await inquirer.prompt([
|
|
52
|
-
{
|
|
53
|
-
type: 'list',
|
|
54
|
-
name: 'botId',
|
|
55
|
-
message: 'Select bot to connect:',
|
|
56
|
-
choices: botList.bots.map(b => ({ name: b.name, value: b.id })),
|
|
57
|
-
},
|
|
58
35
|
{
|
|
59
36
|
type: 'input',
|
|
60
37
|
name: 'token',
|
|
@@ -63,44 +40,22 @@ async function connectDiscord() {
|
|
|
63
40
|
},
|
|
64
41
|
]);
|
|
65
42
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!response.ok) {
|
|
84
|
-
const error = await response.text();
|
|
85
|
-
throw new Error(error);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const data = await response.json();
|
|
89
|
-
|
|
90
|
-
console.log(chalk.green('✅ Discord connected successfully!\n'));
|
|
91
|
-
console.log(chalk.cyan('Bot:'), chalk.white(selectedBot.name));
|
|
92
|
-
console.log(chalk.cyan('Discord Bot:'), chalk.white(data.bot_username || 'Unknown'));
|
|
93
|
-
console.log(chalk.gray('\nYour bot is now active on Discord.'));
|
|
94
|
-
console.log(chalk.gray('Users can interact with /sor command.\n'));
|
|
95
|
-
|
|
96
|
-
// Save to config
|
|
97
|
-
config.discordToken = answers.token.trim();
|
|
98
|
-
config.discordBotId = answers.botId;
|
|
99
|
-
saveConfig(config);
|
|
100
|
-
} catch (err) {
|
|
101
|
-
console.log(chalk.red(`\n❌ Connection failed: ${err.message}\n`));
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
|
43
|
+
// Discord için bot ID oluştur (timestamp-based)
|
|
44
|
+
const botId = `discord_${Date.now()}`;
|
|
45
|
+
const selectedBot = { name: 'Discord Bot', id: botId };
|
|
46
|
+
|
|
47
|
+
console.log(chalk.yellow('\n⏳ Discord bağlantısı kaydediliyor...\n'));
|
|
48
|
+
|
|
49
|
+
// Save to config (v2.x - no backend call)
|
|
50
|
+
config.discordToken = answers.token.trim();
|
|
51
|
+
config.discordBotId = botId;
|
|
52
|
+
saveConfig(config);
|
|
53
|
+
|
|
54
|
+
console.log(chalk.green('✅ Discord token kaydedildi!\n'));
|
|
55
|
+
console.log(chalk.cyan('Bot ID:'), chalk.white(botId));
|
|
56
|
+
console.log(chalk.cyan('Token:'), chalk.white(answers.token.slice(0, 20) + '...'));
|
|
57
|
+
console.log(chalk.gray('\nNot: Discord botunuzu Discord Developer Portal\'dan yapılandırmanız gerekiyor.'));
|
|
58
|
+
console.log(chalk.gray('Token config\'e kaydedildi: ~/.natureco/config.json\n'));
|
|
104
59
|
}
|
|
105
60
|
|
|
106
61
|
async function disconnectDiscord() {
|
|
@@ -136,14 +136,14 @@ async function startGateway() {
|
|
|
136
136
|
|
|
137
137
|
async function runGatewayWorker() {
|
|
138
138
|
// This runs in the background
|
|
139
|
-
log('gateway', 'Starting NatureCo Gateway...', 'green');
|
|
139
|
+
log('gateway', 'Starting NatureCo Gateway v2.3.0...', 'green');
|
|
140
140
|
|
|
141
141
|
// Load config
|
|
142
142
|
const { getConfig } = require('../utils/config');
|
|
143
143
|
const config = getConfig();
|
|
144
144
|
|
|
145
|
-
if (!config || !config.
|
|
146
|
-
log('gateway', '
|
|
145
|
+
if (!config || !config.providerUrl) {
|
|
146
|
+
log('gateway', 'Setup yapılmamış. Run "natureco setup" first.', 'red');
|
|
147
147
|
process.exit(1);
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -293,10 +293,17 @@ async function startWhatsAppProvider(sessionDir, config) {
|
|
|
293
293
|
log('whatsapp', `Inbound message +${sender} -> +${ownNumber} (${messageText.length} chars)`, 'cyan');
|
|
294
294
|
|
|
295
295
|
try {
|
|
296
|
+
// v2.x: Send to universal provider (Groq/OpenAI/Anthropic)
|
|
296
297
|
const { sendMessage } = require('../utils/api');
|
|
297
|
-
log('whatsapp', 'Sending to
|
|
298
|
+
log('whatsapp', 'Sending to AI provider...', 'cyan');
|
|
298
299
|
|
|
299
|
-
|
|
300
|
+
// Use WhatsApp-specific conversation ID for context
|
|
301
|
+
const conversationId = `whatsapp_${sender}`;
|
|
302
|
+
|
|
303
|
+
// WhatsApp system prompt
|
|
304
|
+
const systemPrompt = `You are a helpful WhatsApp assistant. Keep responses concise and friendly. Use emojis when appropriate. If users ask for file operations or system commands, politely explain that those features are available in the terminal version.`;
|
|
305
|
+
|
|
306
|
+
const response = await sendMessage(null, null, messageText, conversationId, systemPrompt);
|
|
300
307
|
const reply = response?.reply || response?.message || '';
|
|
301
308
|
|
|
302
309
|
if (reply) {
|
|
@@ -309,10 +316,10 @@ async function startWhatsAppProvider(sessionDir, config) {
|
|
|
309
316
|
|
|
310
317
|
log('whatsapp', `Reply sent (${reply.length} chars)`, 'green');
|
|
311
318
|
} else {
|
|
312
|
-
log('whatsapp', 'No reply from
|
|
319
|
+
log('whatsapp', 'No reply from provider', 'yellow');
|
|
313
320
|
}
|
|
314
321
|
} catch (err) {
|
|
315
|
-
log('whatsapp', `
|
|
322
|
+
log('whatsapp', `Provider error: ${err.message}`, 'red');
|
|
316
323
|
}
|
|
317
324
|
}
|
|
318
325
|
});
|
package/src/commands/slack.js
CHANGED
|
@@ -22,39 +22,16 @@ async function slack(action) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
async function connectSlack() {
|
|
25
|
-
const apiKey = getApiKey();
|
|
26
|
-
|
|
27
|
-
if (!apiKey) {
|
|
28
|
-
console.log(chalk.red('\n❌ Not logged in. Run "natureco login" first.\n'));
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
25
|
const config = getConfig();
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
let botList;
|
|
37
|
-
try {
|
|
38
|
-
botList = await getBots(apiKey);
|
|
39
|
-
} catch (err) {
|
|
40
|
-
console.log(chalk.red(`\n❌ Error: ${err.message}\n`));
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!botList || !botList.bots || botList.bots.length === 0) {
|
|
45
|
-
console.log(chalk.gray('No bots found. Create one at https://developers.natureco.me\n'));
|
|
27
|
+
if (!config.providerUrl) {
|
|
28
|
+
console.log(chalk.red('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n'));
|
|
46
29
|
process.exit(1);
|
|
47
30
|
}
|
|
48
31
|
|
|
49
32
|
process.stdin.resume();
|
|
50
33
|
|
|
51
34
|
const answers = await inquirer.prompt([
|
|
52
|
-
{
|
|
53
|
-
type: 'list',
|
|
54
|
-
name: 'botId',
|
|
55
|
-
message: 'Select bot to connect:',
|
|
56
|
-
choices: botList.bots.map(b => ({ name: b.name, value: b.id })),
|
|
57
|
-
},
|
|
58
35
|
{
|
|
59
36
|
type: 'input',
|
|
60
37
|
name: 'token',
|
|
@@ -68,44 +45,22 @@ async function connectSlack() {
|
|
|
68
45
|
},
|
|
69
46
|
]);
|
|
70
47
|
|
|
71
|
-
|
|
48
|
+
// Slack için bot ID oluştur (timestamp-based)
|
|
49
|
+
const botId = `slack_${Date.now()}`;
|
|
50
|
+
const selectedBot = { name: 'Slack Bot', id: botId };
|
|
72
51
|
|
|
73
|
-
console.log(chalk.yellow('\n⏳
|
|
52
|
+
console.log(chalk.yellow('\n⏳ Slack bağlantısı kaydediliyor...\n'));
|
|
74
53
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}),
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
if (!response.ok) {
|
|
89
|
-
const error = await response.text();
|
|
90
|
-
throw new Error(error);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const data = await response.json();
|
|
94
|
-
|
|
95
|
-
console.log(chalk.green('✅ Slack connected successfully!\n'));
|
|
96
|
-
console.log(chalk.cyan('Bot:'), chalk.white(selectedBot.name));
|
|
97
|
-
console.log(chalk.cyan('Slack Bot:'), chalk.white(data.bot_name || 'Unknown'));
|
|
98
|
-
console.log(chalk.gray('\nYour bot is now active on Slack.'));
|
|
99
|
-
console.log(chalk.gray('Users can mention the bot or use slash commands.\n'));
|
|
100
|
-
|
|
101
|
-
// Save to config
|
|
102
|
-
config.slackToken = answers.token.trim();
|
|
103
|
-
config.slackBotId = answers.botId;
|
|
104
|
-
saveConfig(config);
|
|
105
|
-
} catch (err) {
|
|
106
|
-
console.log(chalk.red(`\n❌ Connection failed: ${err.message}\n`));
|
|
107
|
-
process.exit(1);
|
|
108
|
-
}
|
|
54
|
+
// Save to config (v2.x - no backend call)
|
|
55
|
+
config.slackToken = answers.token.trim();
|
|
56
|
+
config.slackBotId = botId;
|
|
57
|
+
saveConfig(config);
|
|
58
|
+
|
|
59
|
+
console.log(chalk.green('✅ Slack token kaydedildi!\n'));
|
|
60
|
+
console.log(chalk.cyan('Bot ID:'), chalk.white(botId));
|
|
61
|
+
console.log(chalk.cyan('Token:'), chalk.white(answers.token.slice(0, 20) + '...'));
|
|
62
|
+
console.log(chalk.gray('\nNot: Slack botunuzu Slack App settings\'ten yapılandırmanız gerekiyor.'));
|
|
63
|
+
console.log(chalk.gray('Token config\'e kaydedildi: ~/.natureco/config.json\n'));
|
|
109
64
|
}
|
|
110
65
|
|
|
111
66
|
async function disconnectSlack() {
|
package/src/commands/whatsapp.js
CHANGED
|
@@ -58,42 +58,18 @@ async function whatsapp(action) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
async function connectWhatsApp() {
|
|
61
|
-
const apiKey = getApiKey();
|
|
62
|
-
|
|
63
|
-
if (!apiKey) {
|
|
64
|
-
console.log(chalk.red('\n❌ Not logged in. Run "natureco login" first.\n'));
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
61
|
const config = getConfig();
|
|
69
62
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
let botList;
|
|
73
|
-
try {
|
|
74
|
-
botList = await getBots(apiKey);
|
|
75
|
-
} catch (err) {
|
|
76
|
-
console.log(chalk.red(`\n❌ Error: ${err.message}\n`));
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (!botList || !botList.bots || botList.bots.length === 0) {
|
|
81
|
-
console.log(chalk.gray('No bots found. Create one at https://developers.natureco.me\n'));
|
|
63
|
+
if (!config.providerUrl) {
|
|
64
|
+
console.log(chalk.red('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n'));
|
|
82
65
|
process.exit(1);
|
|
83
66
|
}
|
|
84
67
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const { botId } = await inquirer.prompt([
|
|
88
|
-
{
|
|
89
|
-
type: 'list',
|
|
90
|
-
name: 'botId',
|
|
91
|
-
message: 'Select bot to connect:',
|
|
92
|
-
choices: botList.bots.map(b => ({ name: b.name, value: b.id })),
|
|
93
|
-
},
|
|
94
|
-
]);
|
|
68
|
+
console.log(chalk.yellow('\n⏳ WhatsApp bağlantısı hazırlanıyor...\n'));
|
|
95
69
|
|
|
96
|
-
|
|
70
|
+
// WhatsApp için bot ID oluştur (timestamp-based)
|
|
71
|
+
const botId = `whatsapp_${Date.now()}`;
|
|
72
|
+
const selectedBot = { name: 'WhatsApp Bot', id: botId };
|
|
97
73
|
|
|
98
74
|
console.log(chalk.cyan('\n📱 WhatsApp bağlantısı başlatılıyor...'));
|
|
99
75
|
console.log(chalk.gray('Telefonunuzda WhatsApp\'ı açın ve QR kodu taratın.\n'));
|
package/src/utils/api.js
CHANGED
|
@@ -302,8 +302,14 @@ function clearConversation(conversationId) {
|
|
|
302
302
|
|
|
303
303
|
/**
|
|
304
304
|
* Legacy function for compatibility
|
|
305
|
+
* Now supports custom system prompts for different platforms (terminal, WhatsApp, etc.)
|
|
305
306
|
*/
|
|
306
307
|
async function sendMessage(apiKey, botId, message, conversationId = null, skillPrompts = '') {
|
|
308
|
+
// If skillPrompts is actually a system prompt (string), use it directly
|
|
309
|
+
if (typeof skillPrompts === 'string' && skillPrompts.includes('assistant')) {
|
|
310
|
+
return sendMessageToProvider(apiKey, message, conversationId, skillPrompts);
|
|
311
|
+
}
|
|
312
|
+
|
|
307
313
|
// Get user's home directory
|
|
308
314
|
const homeDir = os.homedir();
|
|
309
315
|
|