natureco-cli 2.2.8 → 2.3.1

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": "2.2.8",
3
+ "version": "2.3.1",
4
4
  "description": "NatureCo AI Bot Terminal Interface",
5
5
  "main": "bin/natureco.js",
6
6
  "bin": {
@@ -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.2.8</div>
214
+ <div class="version-badge" id="version-badge">v2.3.1</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.2.8',
344
+ version: 'v2.3.1',
345
345
  bots: cfg.bots || [],
346
346
  telegramToken: cfg.telegramToken || null,
347
347
  whatsappConnected: cfg.whatsappConnected || false,
@@ -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.1...', '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.apiKey) {
146
- log('gateway', 'No API key found. Run "natureco login" first.', 'red');
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
 
@@ -209,12 +209,18 @@ async function startWhatsAppProvider(sessionDir, config) {
209
209
  retryRequestDelayMs: 2000,
210
210
  });
211
211
 
212
+ // Connection update handler
212
213
  sock.ev.on('connection.update', async (update) => {
213
214
  const { connection, lastDisconnect } = update;
214
215
 
215
216
  if (connection === 'close') {
216
217
  const statusCode = lastDisconnect?.error?.output?.statusCode;
217
218
 
219
+ // Remove all event listeners before reconnecting
220
+ sock.ev.removeAllListeners('connection.update');
221
+ sock.ev.removeAllListeners('messages.upsert');
222
+ sock.ev.removeAllListeners('creds.update');
223
+
218
224
  if (statusCode === 515 || statusCode === 408) {
219
225
  log('whatsapp', 'connection lost, reconnecting in 10s...', 'yellow');
220
226
  setTimeout(() => startWhatsAppProvider(sessionDir, config), 10000);
@@ -293,10 +299,17 @@ async function startWhatsAppProvider(sessionDir, config) {
293
299
  log('whatsapp', `Inbound message +${sender} -> +${ownNumber} (${messageText.length} chars)`, 'cyan');
294
300
 
295
301
  try {
302
+ // v2.x: Send to universal provider (Groq/OpenAI/Anthropic)
296
303
  const { sendMessage } = require('../utils/api');
297
- log('whatsapp', 'Sending to NatureCo API...', 'cyan');
304
+ log('whatsapp', 'Sending to AI provider...', 'cyan');
305
+
306
+ // Use WhatsApp-specific conversation ID for context
307
+ const conversationId = `whatsapp_${sender}`;
308
+
309
+ // WhatsApp system prompt
310
+ 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.`;
298
311
 
299
- const response = await sendMessage(config.apiKey, config.whatsappBotId, messageText, null, '');
312
+ const response = await sendMessage(null, null, messageText, conversationId, systemPrompt);
300
313
  const reply = response?.reply || response?.message || '';
301
314
 
302
315
  if (reply) {
@@ -309,10 +322,10 @@ async function startWhatsAppProvider(sessionDir, config) {
309
322
 
310
323
  log('whatsapp', `Reply sent (${reply.length} chars)`, 'green');
311
324
  } else {
312
- log('whatsapp', 'No reply from API', 'yellow');
325
+ log('whatsapp', 'No reply from provider', 'yellow');
313
326
  }
314
327
  } catch (err) {
315
- log('whatsapp', `API error: ${err.message}`, 'red');
328
+ log('whatsapp', `Provider error: ${err.message}`, 'red');
316
329
  }
317
330
  }
318
331
  });
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