- Added `inactive_plugins` field to `RunnerReadyPayload` and `ReloadPluginResultPayload` to track plugins that are not activated due to being disabled or unmet dependencies. - Introduced `InspectPluginConfigPayload` and `InspectPluginConfigResultPayload` for inspecting plugin configuration metadata. - Implemented `PluginActivationStatus` enum to better represent plugin activation states. - Updated `_activate_plugin` method to return activation status and handle inactive plugins accordingly. - Added hooks for send service to allow modification of messages before and after sending. - Created new runtime routes for listing hook specifications in the WebUI. - Refactored plugin configuration handling to utilize runtime inspection for better accuracy and flexibility. - Enhanced error handling and logging for plugin configuration operations.
29 lines
895 B
Python
29 lines
895 B
Python
"""插件运行时相关 WebUI 路由。"""
|
|
|
|
from typing import Optional
|
|
|
|
from fastapi import APIRouter, Cookie
|
|
|
|
from src.plugin_runtime.component_query import component_query_service
|
|
|
|
from .schemas import HookSpecListResponse, HookSpecResponse
|
|
from .support import require_plugin_token
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/runtime/hooks", response_model=HookSpecListResponse)
|
|
async def list_runtime_hook_specs(maibot_session: Optional[str] = Cookie(None)) -> HookSpecListResponse:
|
|
"""返回当前插件运行时公开的 Hook 规格清单。
|
|
|
|
Args:
|
|
maibot_session: 当前 WebUI 会话令牌。
|
|
|
|
Returns:
|
|
HookSpecListResponse: Hook 规格列表响应。
|
|
"""
|
|
|
|
require_plugin_token(maibot_session)
|
|
hooks = [HookSpecResponse(**hook_data) for hook_data in component_query_service.list_hook_specs()]
|
|
return HookSpecListResponse(success=True, hooks=hooks)
|