30 lines
1.1 KiB
Python
Executable File
30 lines
1.1 KiB
Python
Executable File
# [DEF:PluginsRouter:Module]
|
|
# @SEMANTICS: api, router, plugins, list
|
|
# @PURPOSE: Defines the FastAPI router for plugin-related endpoints, allowing clients to list available plugins.
|
|
# @LAYER: UI (API)
|
|
# @RELATION: Depends on the PluginLoader and PluginConfig. It is included by the main app.
|
|
from typing import List
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from ...core.plugin_base import PluginConfig
|
|
from ...dependencies import get_plugin_loader
|
|
from ...core.logger import belief_scope
|
|
|
|
router = APIRouter()
|
|
|
|
# [DEF:list_plugins:Function]
|
|
# @PURPOSE: Retrieve a list of all available plugins.
|
|
# @PRE: plugin_loader is injected via Depends.
|
|
# @POST: Returns a list of PluginConfig objects.
|
|
# @RETURN: List[PluginConfig] - List of registered plugins.
|
|
@router.get("", response_model=List[PluginConfig])
|
|
async def list_plugins(
|
|
plugin_loader = Depends(get_plugin_loader)
|
|
):
|
|
with belief_scope("list_plugins"):
|
|
"""
|
|
Retrieve a list of all available plugins.
|
|
"""
|
|
return plugin_loader.get_all_plugin_configs()
|
|
# [/DEF:list_plugins:Function]
|
|
# [/DEF:PluginsRouter:Module] |