This commit is contained in:
dsyoon
2025-12-27 14:06:26 +09:00
parent 23f5388c56
commit 46460b77f8
33 changed files with 4600 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
"""backend.engines package
엔진 레지스트리.
서브패키지를 순회해 각 엔진 모듈이 노출한
`TOOL_ID` 와 `TOOL_INFO` 를 자동 수집하여 `TOOLS` dict 로 제공한다.
외부(backend.app 등)에서는 from engines import TOOLS 로 공통 접근.
"""
from importlib import import_module
import pkgutil
# Dictionary mapping tool_id to its info
TOOLS = {}
# Discover and import all subpackages to collect TOOL_INFO
package_name = __name__
for _, module_name, is_pkg in pkgutil.iter_modules(__path__):
if not is_pkg:
# Skip if it's not a package (we expect dirs)
continue
try:
module = import_module(f"{package_name}.{module_name}")
# Each engine package must expose TOOL_ID and TOOL_INFO
if hasattr(module, "TOOL_ID") and hasattr(module, "TOOL_INFO"):
TOOLS[module.TOOL_ID] = module.TOOL_INFO
except ModuleNotFoundError:
# If submodule import fails, skip silently
continue