OpenWA
OpenWA copied to clipboard
feat(engine): opaque per-engine config (engine-agnostic EngineFactory)
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
registerBuiltInPlugingains an optionalconfigparameter (default{}, so existing callers are unaffected).EngineFactory.create()passes only{ sessionId, proxyUrl, proxyType };registerBuiltInEngines()feedsconfigService.get('engine')as the opaque blob; the whatsapp-web.js plugin reads its own browser config (puppeteer.*,sessionDataPath) fromcontext.config.- Two existing
#219tests are rewritten to assert the new opaque-config behavior — the guarantee that env config reaches the adapter now flows throughcontext.config(proven by registration-feeds-blob + plugin-reads-blob + the e2e boot), not throughcreate()'s arguments.
Notes
configuration.tsandcreateFallbackEngine()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→createEngineflow boots and a session creates its engine). - Build + lint clean (backend + dashboard).
Relates to #265.