feat: 添加插件运行时配置类,增强会话令牌管理和插件目录支持

This commit is contained in:
DrSmoothl
2026-03-13 00:11:00 +08:00
parent 52e9d43a90
commit f3270d4d41
8 changed files with 156 additions and 25 deletions

View File

@@ -26,6 +26,7 @@ from .official_configs import (
LPMMKnowledgeConfig,
MaiSakaConfig,
MaimMessageConfig,
PluginRuntimeConfig,
MemoryConfig,
MessageReceiveConfig,
PersonalityConfig,
@@ -54,7 +55,7 @@ CONFIG_DIR: Path = PROJECT_ROOT / "config"
BOT_CONFIG_PATH: Path = (CONFIG_DIR / "bot_config.toml").resolve().absolute()
MODEL_CONFIG_PATH: Path = (CONFIG_DIR / "model_config.toml").resolve().absolute()
MMC_VERSION: str = "1.0.0"
CONFIG_VERSION: str = "8.0.0"
CONFIG_VERSION: str = "8.1.0"
MODEL_CONFIG_VERSION: str = "1.12.0"
logger = get_logger("config")
@@ -131,6 +132,9 @@ class Config(ConfigBase):
maisaka: MaiSakaConfig = Field(default_factory=MaiSakaConfig)
"""MaiSaka对话系统配置类"""
plugin_runtime: PluginRuntimeConfig = Field(default_factory=PluginRuntimeConfig)
"""插件运行时配置类"""
class ModelConfig(ConfigBase):
"""模型配置类"""

View File

@@ -1608,3 +1608,82 @@ class MaiSakaConfig(ConfigBase):
},
)
"""QQ API 密钥"""
class PluginRuntimeConfig(ConfigBase):
"""插件运行时配置类"""
__ui_label__ = "插件运行时"
__ui_icon__ = "puzzle"
enabled: bool = Field(
default=True,
json_schema_extra={
"x-widget": "switch",
"x-icon": "power",
},
)
"""启用插件系统"""
builtin_plugin_dir: str = Field(
default="src/plugins/built_in",
json_schema_extra={
"x-widget": "input",
"x-icon": "folder",
},
)
"""内置插件目录(相对于项目根目录)"""
thirdparty_plugin_dir: str = Field(
default="plugins",
json_schema_extra={
"x-widget": "input",
"x-icon": "folder-open",
},
)
"""第三方插件目录(相对于项目根目录)"""
health_check_interval_sec: float = Field(
default=30.0,
json_schema_extra={
"x-widget": "number",
"x-icon": "activity",
},
)
"""健康检查间隔(秒)"""
max_restart_attempts: int = Field(
default=3,
json_schema_extra={
"x-widget": "number",
"x-icon": "refresh-cw",
},
)
"""Runner 崩溃后最大自动重启次数"""
runner_spawn_timeout_sec: float = Field(
default=30.0,
json_schema_extra={
"x-widget": "number",
"x-icon": "clock",
},
)
"""等待 Runner 子进程启动并注册的超时时间(秒)"""
workflow_blocking_timeout_sec: float = Field(
default=120.0,
json_schema_extra={
"x-widget": "number",
"x-icon": "timer",
},
)
"""Workflow 阻塞步骤的全局超时上限(秒)"""
ipc_socket_path: str = Field(
default="",
json_schema_extra={
"x-widget": "input",
"x-icon": "link",
},
)
"""_wrap_\n 自定义 IPC Socket 路径(仅 Linux/macOS 生效)\n 留空则自动生成临时路径"""