beast-agent 0.23.1 → 0.23.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,7 +1,7 @@
1
1
  {
2
2
  "name": "beast-agent",
3
3
  "productName": "Beast Agent",
4
- "version": "0.23.1",
4
+ "version": "0.23.2",
5
5
  "description": "Ultra-fast local agent shell for Windows.",
6
6
  "author": "algokodcom (AlgoKod)",
7
7
  "license": "MIT",
@@ -58,6 +58,7 @@ class WhatsAppBridge {
58
58
  this.reconnectTimer = null;
59
59
  this._tracked = new Map(); // msgId -> { jid, preview, ts, status, receiptDetail }
60
60
  this._watchJids = new Set(); // presence aboneliği tutulacak sohbetler
61
+ this._seenIds = new Set(); // işlenen mesaj id'leri — offline replay + notify çift işlemeyi önler
61
62
  }
62
63
 
63
64
  /* main tarafı waChats anahtarlarını bildirir; bağlantı varsa anında abone olunur */
@@ -126,7 +127,10 @@ class WhatsAppBridge {
126
127
  printQRInTerminal: false,
127
128
  browser: ['Beast Agent', 'Chrome', '1.0.0'],
128
129
  syncFullHistory: false,
129
- markOnlineOnConnect: true, // telefonda ajan çevrimiçi görünsün
130
+ /* false OLMALI: bot "çevrimiçi" işaretlenirse WhatsApp sunucusu kesintide
131
+ gelen mesajları bu cihaz için kuyruklamayı aksatıyor. false ile kesintideki
132
+ mesajlar sunucuda bekler, bağlantı dönünce 'append' upsert'iyle iletilir. */
133
+ markOnlineOnConnect: false,
130
134
  });
131
135
 
132
136
  this.sock.ev.on('creds.update', saveCreds);
@@ -263,14 +267,38 @@ class WhatsAppBridge {
263
267
  }
264
268
 
265
269
  _handleMessages(m) {
266
- if (m.type !== 'notify') return;
270
+ /* 'notify' = canlı mesaj akışı
271
+ 'append' = bağlantı kesintisinde KAÇIRILMIŞ mesajlar — bağlantı dönünce
272
+ sunucu bunları oynatır; FALLOUT sorunu tam olarak burasıydı:
273
+ yalnızca 'notify' işlendiği için kesintideki mesajlar sessizce
274
+ düşüyor ve cevapsız kalıyordu. 'append' içindeki eski history
275
+ kayıtlarını elemek için son 15 dk tazelik filtresi kullanılır. */
276
+ if (m.type !== 'notify' && m.type !== 'append') return;
277
+ const nowMs = Date.now();
267
278
  for (const msg of m.messages || []) {
279
+ /* aynı mesaj hem 'append' hem 'notify' ile gelebilir — ID dedup */
280
+ const mid = msg.key && msg.key.id;
281
+ if (mid) {
282
+ if (this._seenIds.has(mid)) continue;
283
+ this._seenIds.add(mid);
284
+ if (this._seenIds.size > 600) {
285
+ for (const k of [...this._seenIds].slice(0, 300)) this._seenIds.delete(k);
286
+ }
287
+ }
268
288
  /* tepkiler ayrı kanal: onay kapısı bunları dinler */
269
289
  const rm = msg.message && msg.message.reactionMessage;
270
290
  if (rm) {
271
291
  this._handleReaction(msg, rm);
272
292
  continue;
273
293
  }
294
+ if (m.type === 'append') {
295
+ const ts = Number(msg.messageTimestamp) || 0;
296
+ const tsMs = ts > 1e12 ? ts : ts * 1000; // saniye/ms normalizasyonu
297
+ if (!tsMs || nowMs - tsMs > 15 * 60 * 1000) continue; // eski history — işleme
298
+ try {
299
+ waLogSafe(`offline/append mesaj işleniyor (kesintiden kalan, ${new Date(tsMs).toISOString()})`);
300
+ } catch {}
301
+ }
274
302
  this._processIncoming(msg).catch(() => {});
275
303
  }
276
304
  }