fix(运行时): 将插件路径匹配移到宿主

新增宿主侧精确路径匹配和插件级 match.paths 配置。\n按请求路径固定插件会话链,移除 Lua 插件内的路径判断与 bypass 状态,并迁移现有插件配置和测试。
This commit is contained in:
starrrLight committed 2026-10-15 15:49:05 +08:00
1 parent f905aa22cc
commit d1f5f69454
12 files changed
+126 -200

No files matched your search

+28
View File
@@ -109,14 +109,42 @@ class PluginLLMAccess(Model):
allow: list[str] = Field(default_factory=list)
class PluginMatch(Model):
paths: list[str] = Field(min_length=1)
@field_validator("paths")
@classmethod
def paths_valid(cls, value: list[str]) -> list[str]:
if len(value) != len(set(value)):
raise ValueError("plugin match.paths contains a duplicate path")
for path in value:
if not path.startswith("/"):
raise ValueError("plugin match.paths entries must be absolute paths")
if any(ord(char) < 0x20 or ord(char) == 0x7F for char in path):
raise ValueError("plugin match.paths entries must not contain control characters")
if any(char in path for char in "*?#"):
raise ValueError("plugin match.paths entries must be exact paths without wildcards")
return value
def matches(self, path: str) -> bool:
return path in self.paths
class PluginConfig(Model):
id: str = Field(pattern=r"^[a-zA-Z0-9_-]{1,64}$")
file: Path
enabled: bool = True
match: PluginMatch | None = None
config: dict = Field(default_factory=dict)
network: NetworkPolicy = Field(default_factory=NetworkPolicy)
llm: PluginLLMAccess = Field(default_factory=PluginLLMAccess)
@model_validator(mode="after")
def reject_legacy_path_match(self):
if "paths" in self.config:
raise ValueError(f"plugin {self.id}: config.paths is unsupported; use match.paths")
return self
class Limits(Model):
max_sessions: int = Field(default=4, gt=0)