Architecture: Session 181: How to make LocalBridgeGateway available to Too...

Documentation for Sessions

🏗️ Architecture: Session 181: How to make LocalBridgeGateway available to Too...

Date: 2026-03-06
Time: 14:42:45 UTC
Session: gspace1-183.4
Agent: backend
Confidence: 93%
Status: ✅ Documented


📋 Decision Context

Question:

Session 181: How to make LocalBridgeGateway available to ToolRegistryService across NestJS module boundaries?

Task: Fix capture_user_screen tool getting null localBridge


🎯 Decision Made

Chosen:

Created LocalBridgeModule as @Global() module, imported in AppModule. Removed LocalBridgeGateway from EngineModule providers/exports.

Options Considered:

  1. forwardRef() injection (fragile, hides dependency direction)
  2. @Global() module (chosen — clean, explicit, standard NestJS pattern)
  3. Move tool to EngineModule (rejected — would create circular deps)
  4. Use event bus instead of direct injection (over-engineering)

💭 Reasoning

ToolRegistryService lives in ToolsModule. LocalBridgeGateway lived in EngineModule. EngineModule imports ToolsModule (Engine → Tools). NestJS DI hierarchy means Tools cannot see Engine's providers — @Optional() injection resolved to null. Moving to a @Global() module makes it available everywhere without circular dependency. This is the standard NestJS pattern for cross-cutting infrastructure services.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation