OpenWA icon indicating copy to clipboard operation
OpenWA copied to clipboard

feat(engine): opaque per-engine config (engine-agnostic EngineFactory)

Open rmyndharis opened this issue 5 months ago • 0 comments

Summary

Makes EngineFactory engine-agnostic: it passes only engine-neutral fields (sessionId/proxyUrl/proxyType) to a plugin's createEngine, and supplies engine-specific config (Puppeteer for whatsapp-web.js) as an opaque blob via the plugin context. This is the one real neutral-layer blocker for adding a non-browser engine — so a future Baileys engine can be added without the factory knowing browser fields.

Spec #2 of the engine-pluggability work (#265). No env-var or behavior change for existing deployments — the adapter receives byte-identical config.

Changes

  • registerBuiltInPlugin gains an optional config parameter (default {}, so existing callers are unaffected).
  • EngineFactory.create() passes only { sessionId, proxyUrl, proxyType }; registerBuiltInEngines() feeds configService.get('engine') as the opaque blob; the whatsapp-web.js plugin reads its own browser config (puppeteer.*, sessionDataPath) from context.config.
  • Two existing #219 tests are rewritten to assert the new opaque-config behavior — the guarantee that env config reaches the adapter now flows through context.config (proven by registration-feeds-blob + plugin-reads-blob + the e2e boot), not through create()'s arguments.

Notes

  • configuration.ts and createFallbackEngine() are unchanged; env-var names are unchanged → fully backward-compatible.
  • A future Baileys engine reads context.config.baileys.*; the factory needs no change. The Baileys adapter itself (event model, auth/QR, JID normalization, ~70 methods) is a separate follow-up.

Tests

  • 514/514 unit, e2e boot 4/4 (proves the registration → context.config → createEngine flow boots and a session creates its engine).
  • Build + lint clean (backend + dashboard).

Relates to #265.

rmyndharis avatar Jun 17 '26 12:06 rmyndharis