# [DEF:Dependencies:Module] # @SEMANTICS: dependency, injection, singleton, factory # @PURPOSE: Manages the creation and provision of shared application dependencies, such as the PluginLoader and TaskManager, to avoid circular imports. # @LAYER: Core # @RELATION: Used by the main app and API routers to get access to shared instances. from pathlib import Path from .core.plugin_loader import PluginLoader from .core.task_manager import TaskManager from .core.config_manager import ConfigManager # Initialize singletons # Use absolute path relative to this file to ensure plugins are found regardless of CWD project_root = Path(__file__).parent.parent.parent config_path = project_root / "config.json" config_manager = ConfigManager(config_path=str(config_path)) def get_config_manager() -> ConfigManager: """Dependency injector for the ConfigManager.""" return config_manager plugin_dir = Path(__file__).parent / "plugins" plugin_loader = PluginLoader(plugin_dir=str(plugin_dir)) task_manager = TaskManager(plugin_loader) def get_plugin_loader() -> PluginLoader: """Dependency injector for the PluginLoader.""" return plugin_loader def get_task_manager() -> TaskManager: """Dependency injector for the TaskManager.""" return task_manager # [/DEF]