Coverage for integrations / vision / __init__.py: 62.5%

8 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-05-12 04:49 +0000

1""" 

2Vision Sidecar — packages MiniCPM + frame handling for desktop apps. 

3 

4Replaces external Redis with in-process FrameStore. 

5Manages MiniCPM as a subprocess sidecar with auto-download. 

6Provides continuous scene descriptions for the embodied AI agent. 

7""" 

8from .frame_store import FrameStore 

9from .vision_service import VisionService 

10 

11__all__ = ['FrameStore', 'VisionService', 'get_vision_service'] 

12 

13 

14_vision_service_singleton: 'VisionService | None' = None 

15 

16 

17def get_vision_service() -> VisionService: 

18 """Return the process-wide VisionService singleton. 

19 

20 Callers (admin toggle, agent approval handler, parse_visual_context 

21 tool) should always go through this helper so we never end up with 

22 two VisionService instances fighting over the WebSocket port and 

23 the MiniCPM sidecar subprocess. Lazy-instantiates on first call — 

24 actual start/stop is still explicit via .start() / .stop(). 

25 """ 

26 global _vision_service_singleton 

27 if _vision_service_singleton is None: 

28 _vision_service_singleton = VisionService() 

29 return _vision_service_singleton