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:
- forwardRef() injection (fragile, hides dependency direction)
- @Global() module (chosen — clean, explicit, standard NestJS pattern)
- Move tool to EngineModule (rejected — would create circular deps)
- 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
APIs/backend-vitto-api/src/app/engine/local-bridge.module.tsAPIs/backend-vitto-api/src/app/app.module.tsAPIs/backend-vitto-api/src/app/engine/engine.module.ts
🔗 Related
- Decision ID:
dev_1772808165708_cafc6uz - Session: 183
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation