app-manager-edge-worker 1.1.4 → 1.1.5
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/README.md +6 -0
- package/package.json +1 -1
- package/src/banner.js +1 -1
- package/src/client.js +1 -1
- package/src/config.js +1 -1
- package/src/handlers/whatsappHandler.js +15 -2
package/README.md
CHANGED
|
@@ -203,6 +203,12 @@ Log levels: `[INFO]` · `[SUCCESS]` · `[WARN]` · `[ERROR]` · `[TASK]` (job di
|
|
|
203
203
|
|
|
204
204
|
## 📝 Changelog
|
|
205
205
|
|
|
206
|
+
### v1.1.5
|
|
207
|
+
- **Real-Time WhatsApp Task & Document Streaming Telemetry**:
|
|
208
|
+
- Added timestamped terminal logging for incoming WhatsApp text and document task receipts.
|
|
209
|
+
- Live progress logs for authenticated PDF document streaming, byte transfer size, and SHA-256 integrity validation.
|
|
210
|
+
- Real-time typing presence simulation status and delivery confirmations with official message IDs (`wamid`).
|
|
211
|
+
|
|
206
212
|
### v1.1.4
|
|
207
213
|
- **Persistent MongoDB Session Restoration for WhatsApp**:
|
|
208
214
|
- Automatically restores WhatsApp companion device credentials (`creds.json`, pre-keys, session keys) from cluster MongoDB on worker boot.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "app-manager-edge-worker",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Distributed Scraper Edge Worker for Apps Manager. Run on any local machine, VPS, or Termux Android device to serve browser and HTTP scraping jobs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/banner.js
CHANGED
package/src/client.js
CHANGED
|
@@ -12,7 +12,7 @@ import fs from "fs";
|
|
|
12
12
|
import { getWhatsAppHandler } from "./handlers/whatsappHandler.js";
|
|
13
13
|
import { printBanner, logInfo, logSuccess, logWarn, logError, logJob } from "./banner.js";
|
|
14
14
|
|
|
15
|
-
let workerPkgVersion = "1.1.
|
|
15
|
+
let workerPkgVersion = "1.1.5";
|
|
16
16
|
try {
|
|
17
17
|
const pkg = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
18
18
|
if (pkg?.version) workerPkgVersion = pkg.version;
|
package/src/config.js
CHANGED
|
@@ -111,7 +111,7 @@ export async function resolveWorkerConfig() {
|
|
|
111
111
|
const cli = parseCliArgs();
|
|
112
112
|
|
|
113
113
|
if (cli.help) {
|
|
114
|
-
let pkgVer = "1.1.
|
|
114
|
+
let pkgVer = "1.1.5";
|
|
115
115
|
try {
|
|
116
116
|
const pkg = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
117
117
|
if (pkg?.version) pkgVer = pkg.version;
|
|
@@ -11,6 +11,7 @@ import path from "path";
|
|
|
11
11
|
import os from "os";
|
|
12
12
|
import crypto from "crypto";
|
|
13
13
|
import axios from "axios";
|
|
14
|
+
import { logInfo, logSuccess, logWarn } from "../banner.js";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* WhatsApp Companion Device Engine for App Manager Edge Worker.
|
|
@@ -463,6 +464,7 @@ export class WhatsAppWorkerHandler {
|
|
|
463
464
|
* Sends a plain text WhatsApp message with typing simulation and jitter.
|
|
464
465
|
*/
|
|
465
466
|
async sendMessage({ recipientPhone, message, idempotencyKey = null }) {
|
|
467
|
+
logInfo(`[WhatsApp] Incoming message dispatch for ${recipientPhone}`);
|
|
466
468
|
await this.initialize(false);
|
|
467
469
|
if (!this.sock || this.status !== "CONNECTED") {
|
|
468
470
|
throw new Error("WhatsApp companion device is not connected. Please pair via Admin Panel.");
|
|
@@ -474,6 +476,7 @@ export class WhatsAppWorkerHandler {
|
|
|
474
476
|
if (idempotencyKey) {
|
|
475
477
|
const alreadyDelivered = await this.reconcileDelivery(recipientPhone, idempotencyKey);
|
|
476
478
|
if (alreadyDelivered) {
|
|
479
|
+
logInfo(`[WhatsApp] Reconciled delivery for ${recipientPhone}; duplicate aborted.`);
|
|
477
480
|
return {
|
|
478
481
|
success: true,
|
|
479
482
|
reconciled: true,
|
|
@@ -492,6 +495,7 @@ export class WhatsAppWorkerHandler {
|
|
|
492
495
|
const targetJid = verified.jid || jid;
|
|
493
496
|
|
|
494
497
|
// 3. Human Typing Simulation
|
|
498
|
+
logInfo(`[WhatsApp] Simulating human typing for ${digits}...`);
|
|
495
499
|
await this.sock.sendPresenceUpdate("composing", targetJid).catch(() => {});
|
|
496
500
|
const typingDurationMs = Math.min(Math.max((message.length || 20) * 35, 2000), 4500);
|
|
497
501
|
await new Promise((r) => setTimeout(r, typingDurationMs));
|
|
@@ -507,10 +511,12 @@ export class WhatsAppWorkerHandler {
|
|
|
507
511
|
// 5. Dispatch
|
|
508
512
|
const result = await this.sock.sendMessage(targetJid, { text: finalMessage });
|
|
509
513
|
this._resetIdleTimer();
|
|
514
|
+
const msgId = result?.key?.id || `wamid-${Date.now()}`;
|
|
515
|
+
logSuccess(`[WhatsApp] Text message successfully delivered to ${recipientPhone} (ID: ${msgId})`);
|
|
510
516
|
|
|
511
517
|
return {
|
|
512
518
|
success: true,
|
|
513
|
-
messageId:
|
|
519
|
+
messageId: msgId,
|
|
514
520
|
timestamp: Date.now(),
|
|
515
521
|
};
|
|
516
522
|
}
|
|
@@ -528,6 +534,7 @@ export class WhatsAppWorkerHandler {
|
|
|
528
534
|
caption = "",
|
|
529
535
|
idempotencyKey = null,
|
|
530
536
|
}) {
|
|
537
|
+
logInfo(`[WhatsApp] Incoming document task for ${recipientPhone} (${fileName})`);
|
|
531
538
|
await this.initialize(false);
|
|
532
539
|
if (!this.sock || this.status !== "CONNECTED") {
|
|
533
540
|
throw new Error("WhatsApp companion device is not connected. Please pair via Admin Panel.");
|
|
@@ -539,6 +546,7 @@ export class WhatsAppWorkerHandler {
|
|
|
539
546
|
if (idempotencyKey) {
|
|
540
547
|
const alreadyDelivered = await this.reconcileDelivery(recipientPhone, idempotencyKey);
|
|
541
548
|
if (alreadyDelivered) {
|
|
549
|
+
logInfo(`[WhatsApp] Reconciled delivery for ${recipientPhone}; duplicate aborted.`);
|
|
542
550
|
return {
|
|
543
551
|
success: true,
|
|
544
552
|
reconciled: true,
|
|
@@ -557,6 +565,7 @@ export class WhatsAppWorkerHandler {
|
|
|
557
565
|
const targetJid = verified.jid || jid;
|
|
558
566
|
|
|
559
567
|
// 3. Stream PDF from authenticated URL (Zero buffer in central WebSocket)
|
|
568
|
+
logInfo(`[WhatsApp] Streaming document attachment (${fileName})...`);
|
|
560
569
|
const response = await axios.get(downloadUrl, {
|
|
561
570
|
responseType: "arraybuffer",
|
|
562
571
|
timeout: 25000,
|
|
@@ -581,8 +590,10 @@ export class WhatsAppWorkerHandler {
|
|
|
581
590
|
);
|
|
582
591
|
}
|
|
583
592
|
}
|
|
593
|
+
logInfo(`[WhatsApp] Document received (${(buffer.length / 1024).toFixed(1)} KB), SHA-256 integrity verified (${actualSha256.substring(0, 12)}...)`);
|
|
584
594
|
|
|
585
595
|
// 5. Human Typing Simulation
|
|
596
|
+
logInfo(`[WhatsApp] Simulating human typing for ${digits}...`);
|
|
586
597
|
await this.sock.sendPresenceUpdate("composing", targetJid).catch(() => {});
|
|
587
598
|
await new Promise((r) => setTimeout(r, 2500));
|
|
588
599
|
await this.sock.sendPresenceUpdate("paused", targetJid).catch(() => {});
|
|
@@ -603,10 +614,12 @@ export class WhatsAppWorkerHandler {
|
|
|
603
614
|
});
|
|
604
615
|
|
|
605
616
|
this._resetIdleTimer();
|
|
617
|
+
const msgId = result?.key?.id || `wamid-${Date.now()}`;
|
|
618
|
+
logSuccess(`[WhatsApp] Document successfully delivered to ${recipientPhone} (ID: ${msgId})`);
|
|
606
619
|
|
|
607
620
|
return {
|
|
608
621
|
success: true,
|
|
609
|
-
messageId:
|
|
622
|
+
messageId: msgId,
|
|
610
623
|
timestamp: Date.now(),
|
|
611
624
|
};
|
|
612
625
|
}
|