natureco-cli 2.3.0 → 2.3.2

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.3.0",
3
+ "version": "2.3.2",
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.3.0</div>
214
+ <div class="version-badge" id="version-badge">v2.3.2</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.3.0',
344
+ version: 'v2.3.2',
345
345
  bots: cfg.bots || [],
346
346
  telegramToken: cfg.telegramToken || null,
347
347
  whatsappConnected: cfg.whatsappConnected || false,
@@ -24,25 +24,17 @@ function loadBaileys() {
24
24
  }
25
25
  }
26
26
 
27
- // Log helper
27
+ // Log helper - only writes to console in worker, file writing handled by stdio redirect
28
28
  function log(module, message, color = 'white') {
29
29
  const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 19);
30
30
  const logLine = `[${timestamp}] [${module}] ${message}`;
31
31
 
32
- // Console output with color
32
+ // Console output with color (will be redirected to file by parent process)
33
33
  const colorFn = chalk[color] || chalk.white;
34
34
  console.log(colorFn(logLine));
35
35
 
36
- // File output (no color)
37
- try {
38
- const dir = path.dirname(LOG_FILE);
39
- if (!fs.existsSync(dir)) {
40
- fs.mkdirSync(dir, { recursive: true });
41
- }
42
- fs.appendFileSync(LOG_FILE, logLine + '\n', 'utf-8');
43
- } catch (err) {
44
- // Ignore file write errors
45
- }
36
+ // Note: File writing removed - parent process redirects stdout/stderr to log file
37
+ // This prevents duplicate log entries
46
38
  }
47
39
 
48
40
  // Number matching helper - compare last 10 digits only
@@ -136,7 +128,7 @@ async function startGateway() {
136
128
 
137
129
  async function runGatewayWorker() {
138
130
  // This runs in the background
139
- log('gateway', 'Starting NatureCo Gateway v2.3.0...', 'green');
131
+ log('gateway', 'Starting NatureCo Gateway v2.3.2...', 'green');
140
132
 
141
133
  // Load config
142
134
  const { getConfig } = require('../utils/config');
@@ -209,12 +201,18 @@ async function startWhatsAppProvider(sessionDir, config) {
209
201
  retryRequestDelayMs: 2000,
210
202
  });
211
203
 
204
+ // Connection update handler
212
205
  sock.ev.on('connection.update', async (update) => {
213
206
  const { connection, lastDisconnect } = update;
214
207
 
215
208
  if (connection === 'close') {
216
209
  const statusCode = lastDisconnect?.error?.output?.statusCode;
217
210
 
211
+ // Remove all event listeners before reconnecting
212
+ sock.ev.removeAllListeners('connection.update');
213
+ sock.ev.removeAllListeners('messages.upsert');
214
+ sock.ev.removeAllListeners('creds.update');
215
+
218
216
  if (statusCode === 515 || statusCode === 408) {
219
217
  log('whatsapp', 'connection lost, reconnecting in 10s...', 'yellow');
220
218
  setTimeout(() => startWhatsAppProvider(sessionDir, config), 10000);