natureco-cli 5.6.39 → 5.6.41
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": "5.6.
|
|
3
|
+
"version": "5.6.41",
|
|
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"
|
|
@@ -1476,6 +1476,9 @@ function findImsgBin() {
|
|
|
1476
1476
|
return null;
|
|
1477
1477
|
}
|
|
1478
1478
|
|
|
1479
|
+
// Track recent outgoing messages to prevent loops
|
|
1480
|
+
const recentOutgoingMessages = new Map(); // sender -> [{text, timestamp}, ...]
|
|
1481
|
+
|
|
1479
1482
|
async function processImessageMessage(msg, config) {
|
|
1480
1483
|
try {
|
|
1481
1484
|
// Deduplicate
|
|
@@ -1483,26 +1486,44 @@ async function processImessageMessage(msg, config) {
|
|
|
1483
1486
|
if (msg.id) imessageLastMessageId = msg.id;
|
|
1484
1487
|
|
|
1485
1488
|
// v5.6.39: Skip outgoing messages - TÜM olası field adlarını kontrol et
|
|
1486
|
-
// imsg history kullanırsa is_from_me, watch kullanırsa fromMe/isFromMe olabilir
|
|
1487
1489
|
if (msg.is_from_me || msg.isFromMe || msg.from_me || msg.fromMe) {
|
|
1488
|
-
log('imessage', `Skipping own message (is_from_me
|
|
1490
|
+
log('imessage', `Skipping own message (is_from_me=true)`, 'gray');
|
|
1489
1491
|
return;
|
|
1490
1492
|
}
|
|
1491
1493
|
|
|
1492
|
-
// v5.6.39: Sender kontrolü - sender kendimiz (bot) ise yut
|
|
1493
|
-
// 'sender' alanı kendi numaramız ise skip
|
|
1494
|
-
const myNumber = config.imessageBotId || ''; // bot ID değilse boş
|
|
1495
1494
|
const sender = msg.sender || msg.from || msg.address || msg.handle || '';
|
|
1496
|
-
|
|
1497
1495
|
const text = msg.text || msg.message || msg.body || '';
|
|
1498
1496
|
|
|
1499
1497
|
if (!text.trim() || !sender) return;
|
|
1500
|
-
|
|
1501
|
-
// Boş sender veya placeholder ise skip
|
|
1502
1498
|
if (sender === 'me' || sender === 'self') return;
|
|
1503
1499
|
|
|
1500
|
+
// v5.6.40: Loop prevention - son gönderdiğimiz mesajla aynıysa skip
|
|
1501
|
+
const recentOut = recentOutgoingMessages.get(sender) || [];
|
|
1502
|
+
const now = Date.now();
|
|
1503
|
+
// 30 saniye içinde aynı mesajı gönderdiysek, bu bize gelen mesaj değil (echo)
|
|
1504
|
+
const isEcho = recentOut.some(m =>
|
|
1505
|
+
m.text === text && (now - m.timestamp) < 30000
|
|
1506
|
+
);
|
|
1507
|
+
if (isEcho) {
|
|
1508
|
+
log('imessage', `Skipping echo of our own message to ${sender}`, 'gray');
|
|
1509
|
+
return;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1504
1512
|
log('imessage', `Inbound from ${sender}: "${text.slice(0, 80)}"`, 'cyan');
|
|
1505
1513
|
|
|
1514
|
+
// v5.6.41: Slash-prefix komut sistemi - sadece / ile başlayan mesajlara cevap ver
|
|
1515
|
+
if (!text.startsWith('/')) {
|
|
1516
|
+
log('imessage', `Skipping non-command from ${sender}: "${text.slice(0, 40)}..."`, 'gray');
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1519
|
+
// / prefix'i kaldır
|
|
1520
|
+
const cleanCommand = text.replace(/^\/+/, '').trim();
|
|
1521
|
+
if (!cleanCommand) {
|
|
1522
|
+
log('imessage', `Empty command from ${sender}`, 'gray');
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
log('imessage', `Slash command: /${cleanCommand.slice(0, 60)}`, 'yellow');
|
|
1526
|
+
|
|
1506
1527
|
const { sendMessage } = require('../utils/api');
|
|
1507
1528
|
const { getMemoryPrompt } = require('../utils/memory');
|
|
1508
1529
|
const { getConfig, saveConfig } = require('../utils/config');
|
|
@@ -1526,6 +1547,13 @@ async function processImessageMessage(msg, config) {
|
|
|
1526
1547
|
timeout: 15000, stdio: 'pipe',
|
|
1527
1548
|
});
|
|
1528
1549
|
log('imessage', `Reply sent to ${sender} (${reply.length} chars)`, 'green');
|
|
1550
|
+
|
|
1551
|
+
// v5.6.40: Track outgoing message for loop prevention
|
|
1552
|
+
const senderHistory = recentOutgoingMessages.get(sender) || [];
|
|
1553
|
+
senderHistory.push({ text: reply, timestamp: Date.now() });
|
|
1554
|
+
// Keep only last 5 messages
|
|
1555
|
+
if (senderHistory.length > 5) senderHistory.shift();
|
|
1556
|
+
recentOutgoingMessages.set(sender, senderHistory);
|
|
1529
1557
|
}
|
|
1530
1558
|
} catch (err) {
|
|
1531
1559
|
log('imessage', `Message error: ${err.message}`, 'red');
|