- 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.
32 lines
796 B
Python
32 lines
796 B
Python
"""Hook 参数模型构造辅助。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from copy import deepcopy
|
|
from typing import Any, Dict, Sequence
|
|
|
|
|
|
def build_object_schema(
|
|
properties: Dict[str, Dict[str, Any]],
|
|
*,
|
|
required: Sequence[str] | None = None,
|
|
) -> Dict[str, Any]:
|
|
"""构造对象级 JSON Schema。
|
|
|
|
Args:
|
|
properties: 字段定义映射。
|
|
required: 必填字段名列表。
|
|
|
|
Returns:
|
|
Dict[str, Any]: 标准化后的对象级 Schema。
|
|
"""
|
|
|
|
schema: Dict[str, Any] = {
|
|
"type": "object",
|
|
"properties": deepcopy(properties),
|
|
}
|
|
normalized_required = [str(item).strip() for item in (required or []) if str(item).strip()]
|
|
if normalized_required:
|
|
schema["required"] = normalized_required
|
|
return schema
|