Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
feat(messaging): typing simulation (anti-ban) + fix duplicate dashboard messages (#264)
Yudhi Armyndharisea4026d83dd3
diff --git a/.env.example b/.env.exampleindex 481927467..8e95be4e3 100644--- a/.env.example+++ b/.env.example@@ -73,6 +73,13 @@ PUPPETEER_ARGS=--no-sandbox,--disable-setuid-sandbox,--disable-dev-shm-usage,--d# 2.3000.1023204257 is confirmed to reach "ready" (incl. ARM64 / Raspberry Pi 5) — uncomment it:# WWEBJS_WEB_VERSION=2.3000.1023204257+# Humanise single sends: show a "typing…" indicator and pause briefly (length-scaled, jittered)+# before each text send so messages don't look instantaneous (anti-ban). ON by default — set to+# false to disable. SIMULATE_TYPING_MAX_MS caps the pause (default 5000). Does not affect bulk+# sends, which have their own delayBetweenMessages throttle.+# SIMULATE_TYPING=false+# SIMULATE_TYPING_MAX_MS=5000+# Observability — Prometheus scrape endpoint at GET /api/metrics.# Disabled by default; set a token to enable. Scrapers must send `Authorization: Bearer <token>`.# METRICS_TOKEN=change-me-to-a-long-random-stringdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex beac8fc2e..34c25c28c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,8 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Added++- **Typing simulation before single sends (anti-ban), on by default.** A text send now shows a "typing…"+ indicator and pauses briefly (length-scaled, jittered) before sending, so automated messages don't look+ instantaneous. Disable with `SIMULATE_TYPING=false`; cap the pause with `SIMULATE_TYPING_MAX_MS`+ (default 5000). Exposed engine-agnostically via `IWhatsAppEngine.sendChatState` and a new+ `POST /sessions/:id/chats/typing` endpoint (`state`: `typing` | `recording` | `paused`). Bulk sends are+ unaffected (they keep their own `delayBetweenMessages` throttle).+- The engine API (`GET /infra/engines`) and the dashboard Active Engine card now report the **underlying+ engine library version** (e.g. `whatsapp-web.js 1.34.7`), distinct from the adapter plugin version.+### Fixed+- **Duplicate outgoing messages in the dashboard Chats view.** A race between the optimistic placeholder+ and the realtime `message.sent` echo could render a sent message twice. Reconciliation is now race-safe.+ (Display-only — the recipient always received exactly one message.)- Dashboard (simple nginx image) proxied API/WebSocket requests to a `openwa` host that doesn't match thebackend service name; `dashboard/nginx.conf` now targets `openwa-api` for both `/api/` and `/socket.io/`,matching the production compose and `Dockerfile.traefik`. Thanks @Abhishekrajpurohit (#259).@@ -16,6 +30,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0from session profiles on start, so a session can re-launch after an unclean shutdown instead of failing with"profile appears to be in use by another Chromium process" (exit Code 21). Thanks @Abhishekrajpurohit (#259).+### Changed++- `mark-chat-read` `chatId` validation is now engine-neutral (accepts any engine's JID scheme, e.g. a+ Baileys `…@s.whatsapp.net`) instead of hardcoding the whatsapp-web.js `@c.us`/`@g.us`/`@lid` format.+## [0.2.6] - 2026-06-16A patch release: stop Chromium from failing to launch on hardened `read_only` containers, and make thediff --git a/dashboard/src/pages/Chats.tsx b/dashboard/src/pages/Chats.tsxindex 48afaf5ee..eafb8327c 100644--- a/dashboard/src/pages/Chats.tsx+++ b/dashboard/src/pages/Chats.tsx@@ -512,11 +512,19 @@ export function Chats() {result = await messageApi.sendText(selectedSessionId, activeChat.id, textToSend);}- setMessages(prev =>- prev.map(m =>+ setMessages(prev => {+ // Race guard: the realtime `message.sent` echo can arrive before this response and already+ // append the message by its real WA id (the dedup at receive time misses because the+ // optimistic placeholder still carries the temp id). If so, drop the placeholder instead of+ // renaming it — otherwise both the echo and the renamed temp render as duplicate bubbles.+ const echoAlreadyAdded = prev.some(m => m.id === result.messageId || m.waMessageId === result.messageId);+ if (echoAlreadyAdded) {+ return prev.filter(m => m.id !== tempId);+ }+ return prev.map(m =>m.id === tempId ? { ...m, id: result.messageId, waMessageId: result.messageId, status: 'sent' } : m,- ),- );+ );+ });// Update sidebar chat list (move active chat to the top with the new snippet)setChats(prevChats => {diff --git a/dashboard/src/pages/Plugins.tsx b/dashboard/src/pages/Plugins.tsxindex c30285510..9e6260f30 100644--- a/dashboard/src/pages/Plugins.tsx+++ b/dashboard/src/pages/Plugins.tsx@@ -178,7 +178,10 @@ export default function Plugins() {</div><div><h3 className="engine-title">{t('plugins.engineCard')}</h3>- <span className="engine-name">{currentEngine}</span>+ <span className="engine-name">+ {currentEngine}+ {activeEngine?.library && ` · ${activeEngine.library.name} ${activeEngine.library.version}`}+ </span></div></div><span className="status-badge connected">{t('plugins.running')}</span>diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.tsindex 10d7ae5ad..4027cfd8e 100644--- a/dashboard/src/services/api.ts+++ b/dashboard/src/services/api.ts@@ -492,6 +492,8 @@ export interface Engine {name: string;enabled: boolean;features: string[];+ /** Underlying engine library (e.g. whatsapp-web.js 1.34.7), distinct from the adapter version. */+ library?: { name: string; version: string };}// =============================================================================diff --git a/src/core/plugins/plugin.interfaces.ts b/src/core/plugins/plugin.interfaces.tsindex 6726fff49..7cb7e6e36 100644--- a/src/core/plugins/plugin.interfaces.ts+++ b/src/core/plugins/plugin.interfaces.ts@@ -147,6 +147,10 @@ export interface IEnginePlugin extends IPlugin {// Get supported featuresgetFeatures: () => string[];++ // Underlying engine library name + version (e.g. { name: 'whatsapp-web.js', version: '1.34.7' }) —+ // distinct from the adapter/plugin's own manifest version. Optional: an engine may not report it.+ getEngineLibrary?: () => { name: string; version: string };}// ============================================================================diff --git a/src/engine/adapters/whatsapp-web-js.adapter.ts b/src/engine/adapters/whatsapp-web-js.adapter.tsindex 5879bf9f0..7c82c4878 100644--- a/src/engine/adapters/whatsapp-web-js.adapter.ts+++ b/src/engine/adapters/whatsapp-web-js.adapter.ts@@ -27,6 +27,7 @@ import {ProductQueryOptions,PaginatedProducts,ChatSummary,+ ChatState,RevokedMessage,ReactionEvent,} from '../interfaces/whatsapp-engine.interface';@@ -1157,6 +1158,23 @@ export class WhatsAppWebJsAdapter extends EventEmitter implements IWhatsAppEngin}}+ async sendChatState(chatId: string, state: ChatState): Promise<void> {+ this.ensureReady();+ try {+ const chat = await this.client!.getChatById(chatId);+ if (state === 'typing') {+ await chat.sendStateTyping();+ } else if (state === 'recording') {+ await chat.sendStateRecording();+ } else {+ await chat.clearState();+ }+ } catch (error) {+ // Presence is best-effort — a failure here must never break the surrounding send.+ this.logger.error(`Error setting chat state '${state}' for ${chatId}`, String(error));+ }+ }+private ensureReady(): void {if (this.status !== EngineStatus.READY || !this.client) {// Typed so the global filter returns 409 Conflict ("session not connected")diff --git a/src/engine/engine.factory.ts b/src/engine/engine.factory.tsindex 76d37769d..0548d2c07 100644--- a/src/engine/engine.factory.ts+++ b/src/engine/engine.factory.ts@@ -124,17 +124,28 @@ export class EngineFactory implements OnModuleInit {// Query Methods for API/Dashboard// ============================================================================- getAvailableEngines(): Array<{ id: string; name: string; enabled: boolean; features: string[] }> {+ getAvailableEngines(): Array<{+ id: string;+ name: string;+ enabled: boolean;+ features: string[];+ library?: { name: string; version: string };+ }> {const enginePlugins = this.pluginLoader.getPluginsByType(PluginType.ENGINE);return enginePlugins.map(plugin => {- const features = plugin.instance && this.isEnginePlugin(plugin.instance) ? plugin.instance.getFeatures() : [];+ const inst = plugin.instance;+ const features = inst && this.isEnginePlugin(inst) ? inst.getFeatures() : [];+ // The real underlying library version (e.g. whatsapp-web.js 1.34.7), distinct from the+ // plugin's manifest version — so the dashboard can show which engine is actually running.+ const library = inst && this.isEnginePlugin(inst) ? inst.getEngineLibrary?.() : undefined;return {id: plugin.manifest.id,name: plugin.manifest.name,enabled: this.pluginLoader.isPluginEnabled(plugin.manifest.id),features,+ library,};});}diff --git a/src/engine/interfaces/whatsapp-engine.interface.ts b/src/engine/interfaces/whatsapp-engine.interface.tsindex 9dd98857f..16b035e6b 100644--- a/src/engine/interfaces/whatsapp-engine.interface.ts+++ b/src/engine/interfaces/whatsapp-engine.interface.ts@@ -226,6 +226,12 @@ export interface ChatSummary {lastMessage?: string;}+/**+ * Engine-neutral chat presence state. `typing`/`recording` show the indicator to the chat;+ * `paused` clears it. Best-effort: engines without a presence concept may no-op.+ */+export type ChatState = 'typing' | 'recording' | 'paused';+/*** Structured payload for a remotely-revoked ("deleted for everyone") message.* The engine layer never emits a localized display string; `body` is intentionally@@ -369,4 +375,9 @@ export interface IWhatsAppEngine {// ChatsgetChats(): Promise<ChatSummary[]>;sendSeen(chatId: string): Promise<boolean>;+ /**+ * Send a typing/recording presence indicator to a chat, or clear it (`paused`).+ * Engine-agnostic and best-effort: engines without a presence concept should no-op.+ */+ sendChatState(chatId: string, state: ChatState): Promise<void>;}diff --git a/src/modules/message/message.service.spec.ts b/src/modules/message/message.service.spec.tsindex bc05e053e..9fade9d2b 100644--- a/src/modules/message/message.service.spec.ts+++ b/src/modules/message/message.service.spec.ts@@ -28,6 +28,7 @@ function createMockEngine() {getMessageReactions: jest.fn().mockResolvedValue([]),deleteMessage: jest.fn().mockResolvedValue(undefined),getChatHistory: jest.fn().mockResolvedValue([]),+ sendChatState: jest.fn().mockResolvedValue(undefined),};}@@ -39,6 +40,16 @@ describe('MessageService', () => {let templateService: jest.Mocked<Partial<TemplateService>>;let mockEngine: ReturnType<typeof createMockEngine>;+ // Auto-typing is on by default; disable it for the unrelated send tests so they don't incur the+ // real setTimeout delay and don't add an extra sendChatState call. The auto-typing suite opts in.+ beforeEach(() => {+ process.env.SIMULATE_TYPING = 'false';+ });+ afterEach(() => {+ delete process.env.SIMULATE_TYPING;+ delete process.env.SIMULATE_TYPING_MAX_MS;+ });+beforeEach(async () => {repository = {create: jest.fn().mockImplementation((data: Partial<Message>) => ({ id: 'msg-uuid-1', ...data }) as Message),@@ -81,6 +92,24 @@ describe('MessageService', () => {// ── sendText ──────────────────────────────────────────────────────+ describe('auto-typing before send (SIMULATE_TYPING, on by default)', () => {+ it('sends a typing presence before the message by default', async () => {+ delete process.env.SIMULATE_TYPING; // default = on+ process.env.SIMULATE_TYPING_MAX_MS = '1'; // keep the humanising delay ~instant in tests++ await service.sendText('sess-1', { chatId: '[email protected]', text: 'Hello' });++ expect(mockEngine.sendChatState).toHaveBeenCalledWith('[email protected]', 'typing');+ expect(mockEngine.sendTextMessage).toHaveBeenCalledWith('[email protected]', 'Hello');+ });++ it('does not send typing presence when SIMULATE_TYPING=false', async () => {+ process.env.SIMULATE_TYPING = 'false';+ await service.sendText('sess-1', { chatId: '[email protected]', text: 'Hello' });+ expect(mockEngine.sendChatState).not.toHaveBeenCalled();+ });+ });+describe('sendText', () => {it('should send text message and return messageId + timestamp', async () => {const result = await service.sendText('sess-1', {diff --git a/src/modules/message/message.service.ts b/src/modules/message/message.service.tsindex 0fb17ffc2..24e6a5d11 100644--- a/src/modules/message/message.service.ts+++ b/src/modules/message/message.service.ts@@ -4,7 +4,7 @@ import { Repository } from 'typeorm';import { SessionService } from '../session/session.service';import { SendTextMessageDto, SendMediaMessageDto, MessageResponseDto } from './dto';import { SendTemplateMessageDto } from './dto/send-template.dto';-import { MediaInput } from '../../engine/interfaces/whatsapp-engine.interface';+import { MediaInput, IWhatsAppEngine } from '../../engine/interfaces/whatsapp-engine.interface';import { Message, MessageDirection, MessageStatus } from './entities/message.entity';import { HookManager } from '../../core/hooks';import { TemplateService } from '../template/template.service';@@ -54,6 +54,9 @@ export class MessageService {type: 'text',});+ // Opt-in humanising "typing…" pause before the actual send (anti-automation signal).+ await this.simulateTypingIfEnabled(engine, finalDto.chatId, finalDto.text);+try {const result = await engine.sendTextMessage(finalDto.chatId, finalDto.text);@@ -565,6 +568,27 @@ export class MessageService {return engine;}+ /**+ * Humanising delay: show the engine's typing indicator and pause for a length-scaled, jittered+ * interval before the real send, so automated single sends don't look instantaneous (anti-ban).+ * ON by default — set `SIMULATE_TYPING=false` to disable. Engine-agnostic (goes through+ * `sendChatState`) and strictly best-effort — it never throws and never blocks the send if presence+ * fails or the engine has no presence concept. `SIMULATE_TYPING_MAX_MS` (default 5000) caps the pause.+ * Note: this covers single sends only; bulk sends use their own `delayBetweenMessages` throttle.+ */+ private async simulateTypingIfEnabled(engine: IWhatsAppEngine, chatId: string, text: string): Promise<void> {+ if (process.env.SIMULATE_TYPING === 'false') return;+ try {+ await engine.sendChatState(chatId, 'typing');+ const maxMs = Number(process.env.SIMULATE_TYPING_MAX_MS) || 5000;+ const planned = Math.min(maxMs, 500 + text.length * 45);+ const jittered = Math.round(planned * (0.85 + Math.random() * 0.3)); // ±15% so it isn't metronomic+ await new Promise(resolve => setTimeout(resolve, jittered));+ } catch (error) {+ this.logger.warn(`simulateTyping skipped: ${error instanceof Error ? error.message : String(error)}`);+ }+ }+/*** Map a blocked outbound media fetch (SSRF guard) to an HTTP 400 so a* caller-supplied internal/unsafe URL returns a client error instead of a 500.diff --git a/src/modules/session/dto/index.ts b/src/modules/session/dto/index.tsindex 5a903a8ed..0b28b7c84 100644--- a/src/modules/session/dto/index.ts+++ b/src/modules/session/dto/index.ts@@ -1,4 +1,5 @@export * from './create-session.dto';export * from './session-response.dto';export * from './mark-chat-read.dto';+export * from './send-chat-state.dto';export * from './request-pairing-code.dto';diff --git a/src/modules/session/dto/mark-chat-read.dto.spec.ts b/src/modules/session/dto/mark-chat-read.dto.spec.tsindex 61f8c9322..f62f04268 100644--- a/src/modules/session/dto/mark-chat-read.dto.spec.ts+++ b/src/modules/session/dto/mark-chat-read.dto.spec.ts@@ -5,12 +5,17 @@ import { MarkChatReadDto } from './mark-chat-read.dto';const errorCount = (chatId: unknown): number => validateSync(plainToInstance(MarkChatReadDto, { chatId })).length;describe('MarkChatReadDto chatId validation', () => {- it.each(['[email protected]', '[email protected]', '1234567890@lid'])('accepts a valid JID: %s', chatId => {- expect(errorCount(chatId)).toBe(0);- });+ // Engine-neutral: accept any active engine's JID scheme — whatsapp-web.js (@c.us/@g.us/@lid)+ // AND a swapped engine like Baileys (@s.whatsapp.net). The adapter validates/normalises further.+ 'accepts a valid JID across engines: %s',+ chatId => {+ expect(errorCount(chatId)).toBe(0);+ },+ );- 'rejects an invalid chatId: %s',+ it.each(['', 'not-a-jid', 'no-at-host', '1234567890@', '@host.example', 'has [email protected]'])(+ 'rejects a malformed chatId: %s',chatId => {expect(errorCount(chatId)).toBeGreaterThan(0);},diff --git a/src/modules/session/dto/mark-chat-read.dto.ts b/src/modules/session/dto/mark-chat-read.dto.tsindex 2ba021a27..b7ae660c8 100644--- a/src/modules/session/dto/mark-chat-read.dto.ts+++ b/src/modules/session/dto/mark-chat-read.dto.ts@@ -3,15 +3,16 @@ import { IsNotEmpty, IsString, Matches } from 'class-validator';export class MarkChatReadDto {@ApiProperty({- description: 'WhatsApp chat ID to mark as read (e.g., [email protected], [email protected], or 1234567890@lid)',+ description: "Chat ID in the active engine's native format (e.g. [email protected] on whatsapp-web.js)",example: '[email protected]',})@IsString()@IsNotEmpty()- // Reject malformed IDs early with a clear 400 instead of a silent no-op at the engine layer.- // @lid is the privacy "Linked ID" address newer WhatsApp assigns to some 1:1 contacts.- @Matches(/^[0-9-]+@(?:[cg]\.us|lid)$/, {- message: 'chatId must be a valid WhatsApp JID (e.g. [email protected], [email protected], or 1234567890@lid)',+ // Engine-neutral structural check (localpart@host, no whitespace) so a different engine's JID+ // scheme (e.g. Baileys [email protected]) is accepted too; the adapter validates/normalises+ // further for its own engine. Keeps the early-400 on obvious garbage without coupling to wwebjs.+ @Matches(/^[^\s@]+@[^\s@]+$/, {+ message: 'chatId must be a valid chat JID in the form localpart@host',})chatId: string;}diff --git a/src/modules/session/dto/send-chat-state.dto.ts b/src/modules/session/dto/send-chat-state.dto.tsnew file mode 100644index 000000000..e7259e63b--- /dev/null+++ b/src/modules/session/dto/send-chat-state.dto.ts@@ -0,0 +1,24 @@+import { ApiProperty } from '@nestjs/swagger';+import { IsIn, IsNotEmpty, IsString } from 'class-validator';+import type { ChatState } from '../../../engine/interfaces/whatsapp-engine.interface';++export class SendChatStateDto {+ @ApiProperty({+ // Engine-neutral on purpose: the chat id is whatever the active engine uses+ // (e.g. <number>@c.us on whatsapp-web.js, <number>@s.whatsapp.net on Baileys).+ // The adapter validates/normalises it — we only require a non-empty string here.+ description: "Chat ID, in the active engine's native format (e.g. [email protected])",+ example: '[email protected]',+ })+ @IsString()+ @IsNotEmpty()+ chatId: string;++ @ApiProperty({+ description: "Presence to send: 'typing' or 'recording' shows the indicator; 'paused' clears it",+ enum: ['typing', 'recording', 'paused'],+ example: 'typing',+ })+ @IsIn(['typing', 'recording', 'paused'])+ state: ChatState;+}diff --git a/src/modules/session/session.controller.ts b/src/modules/session/session.controller.tsindex b435f4e1b..a065241cc 100644--- a/src/modules/session/session.controller.ts+++ b/src/modules/session/session.controller.ts@@ -6,6 +6,7 @@ import {SessionResponseDto,QRCodeResponseDto,MarkChatReadDto,+ SendChatStateDto,RequestPairingCodeDto,PairingCodeResponseDto,} from './dto';@@ -212,6 +213,17 @@ export class SessionController {return { success };}+ @Post(':id/chats/typing')+ @RequireRole(ApiKeyRole.OPERATOR)+ @ApiOperation({ summary: "Send a typing/recording presence indicator to a chat (or clear it with 'paused')" })+ @ApiParam({ name: 'id', description: 'Session ID' })+ @ApiResponse({ status: 200, description: 'Presence sent' })+ @ApiResponse({ status: 404, description: 'Session not found' })+ async sendChatState(@Param('id') id: string, @Body() dto: SendChatStateDto): Promise<{ success: boolean }> {+ await this.sessionService.sendChatState(id, dto.chatId, dto.state);+ return { success: true };+ }+@Get('stats/overview')@ApiOperation({summary: 'Get session statistics for multi-session monitoring',diff --git a/src/modules/session/session.service.spec.ts b/src/modules/session/session.service.spec.tsindex ceb20af3d..fa25192c1 100644--- a/src/modules/session/session.service.spec.ts+++ b/src/modules/session/session.service.spec.ts@@ -77,6 +77,7 @@ describe('SessionService', () => {getGroups: jest.fn().mockResolvedValue([]),getChats: jest.fn().mockResolvedValue([]),sendSeen: jest.fn().mockResolvedValue(true),+ sendChatState: jest.fn().mockResolvedValue(undefined),};engineFactory = {@@ -676,6 +677,29 @@ describe('SessionService', () => {});});+ // ── sendChatState (typing/recording/paused) ───────────────────────++ describe('sendChatState', () => {+ it('should delegate to engine.sendChatState with the chatId and state', async () => {+ const session = createMockSession();+ (repository.findOne as jest.Mock).mockResolvedValue(session);+ (repository.update as jest.Mock).mockResolvedValue({ affected: 1 });++ await service.start('sess-uuid-1');++ await service.sendChatState('sess-uuid-1', '[email protected]', 'typing');++ expect(mockEngine.sendChatState).toHaveBeenCalledWith('[email protected]', 'typing');+ });++ it('should throw BadRequestException when session is not started', async () => {+ const session = createMockSession();+ (repository.findOne as jest.Mock).mockResolvedValue(session);++ await expect(service.sendChatState('sess-uuid-1', '[email protected]', 'typing')).rejects.toThrow(BadRequestException);+ });+ });+// ── onMessageRevoked (no localized string) ────────────────────────describe('onMessageRevoked callback', () => {diff --git a/src/modules/session/session.service.ts b/src/modules/session/session.service.tsindex 9bfb4572a..b687bcc7e 100644--- a/src/modules/session/session.service.ts+++ b/src/modules/session/session.service.ts@@ -17,6 +17,7 @@ import {IWhatsAppEngine,EngineStatus,ChatSummary,+ ChatState,IncomingMessage,} from '../../engine/interfaces/whatsapp-engine.interface';import { createLogger } from '../../common/services/logger.service';@@ -804,6 +805,17 @@ export class SessionService implements OnModuleDestroy, OnModuleInit, OnApplicatreturn engine.sendSeen(chatId);}+ async sendChatState(id: string, chatId: string, state: ChatState): Promise<void> {+ await this.findOne(id); // Verify session exists+ const engine = this.engines.get(id);++ if (!engine) {+ throw new BadRequestException('Session is not started');+ }++ await engine.sendChatState(chatId, state);+ }+private async updateStatus(id: string, status: SessionStatus): Promise<void> {await this.sessionRepository.update(id, { status });this.logger.debug(`Session status updated to ${status}`, {diff --git a/src/plugins/engines/whatsapp-web-js/index.ts b/src/plugins/engines/whatsapp-web-js/index.tsindex 1da371397..ce147b7d1 100644--- a/src/plugins/engines/whatsapp-web-js/index.ts+++ b/src/plugins/engines/whatsapp-web-js/index.ts@@ -92,6 +92,19 @@ export class WhatsAppWebJsPlugin implements IEnginePlugin {];}+ getEngineLibrary(): { name: string; version: string } {+ // The actual whatsapp-web.js library version (e.g. 1.34.7), surfaced so operators can see which+ // engine version is really running — distinct from this adapter plugin's manifest version (1.0.0).+ let version = 'unknown';+ try {+ // eslint-disable-next-line @typescript-eslint/no-require-imports+ version = (require('whatsapp-web.js/package.json') as { version: string }).version;+ } catch {+ // Keep 'unknown' if the package metadata can't be resolved at runtime.+ }+ return { name: 'whatsapp-web.js', version };+ }+healthCheck(): Promise<{ healthy: boolean; message?: string }> {return Promise.resolve({ healthy: true, message: 'WhatsApp-web.js engine is available' });}