JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix:下掉allow_path
Zql9931769a461513
diff --git a/jiuwenswarm/server/runtime/agent_adapter/evolution_version.py b/jiuwenswarm/server/runtime/agent_adapter/evolution_version.pyindex fa1a4f1495..4b8b0e8b1a 100644--- a/jiuwenswarm/server/runtime/agent_adapter/evolution_version.py+++ b/jiuwenswarm/server/runtime/agent_adapter/evolution_version.py@@ -80,36 +80,6 @@ def disk_only_evolution_skill_dirs(params: dict[str, Any] | None = None) -> listreturn [str(p) for p in resolve_agent_registered_skill_dirs()]-def allowed_skill_roots_for_path(- adapter_dirs: Sequence[str | Path],- skill_path: str | None = None,-) -> list[str]:- """Union adapter dirs, live registered dirs, and control-plane skill_path root.-- Disk-only / control-plane RPCs may pass an explicit ``…/<name>/SKILL.md`` whose- skills root is outside a warm agent's workspace-only snapshot. Include that root- so path validation matches enterprise AgentManager binding semantics.- """- roots: list[str] = []- seen: set[str] = set()- for raw in (- *adapter_dirs,- *(str(p) for p in resolve_agent_registered_skill_dirs()),- ):- try:- key = str(Path(str(raw)).expanduser().resolve())- except OSError:- key = str(raw)- if not key or key in seen:- continue- seen.add(key)- roots.append(key)- skill_root = skills_root_from_skill_md_path(skill_path)- if skill_root and skill_root not in seen:- roots.append(skill_root)- return roots--def get_disk_evolution_store(skills_dirs: str | list[str] | None = None) -> EvolutionStore:"""Build a disk-only EvolutionStore (no EvolutionRail / LLM)."""if skills_dirs is None:@@ -161,9 +131,8 @@ def validate_rebuild_skill_path(skill_path: str,*,skill_name: str,- allowed_roots: Sequence[str | Path],) -> str:- """Ensure skill_path is SKILL.md under an allowed skills root and matches name."""+ """Normalize skill_path; require SKILL.md and matching skill directory name."""try:resolved = Path(str(skill_path).strip()).expanduser().resolve()except OSError as exc:@@ -175,23 +144,7 @@ def validate_rebuild_skill_path(f"skill_path directory name must match skill name "f"(expected={skill_name}, resolve_path={resolved})")- allowed: list[Path] = []- for raw in allowed_roots:- try:- allowed.append(Path(str(raw)).expanduser().resolve())- except OSError:- continue- for root in allowed:- try:- resolved.relative_to(root)- return str(resolved)- except ValueError:- continue- allowed_display = ", ".join(str(p) for p in allowed[:5]) or "(none)"- raise ValueError(- f"skill_path outside registered skill roots: "- f"resolve_path={resolved}, allowed_path={allowed_display}"- )+ return str(resolved)def normalize_record_ids(raw: Any) -> list[str] | None:@@ -466,7 +419,6 @@ def is_body_archive_name(archive_name: str) -> bool:__all__ = [- "allowed_skill_roots_for_path","disk_only_evolution_skill_dirs","do_evolve_rollback","finalize_rebuild_followup",diff --git a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.pyindex ab972bdf36..679e036ad4 100644--- a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py+++ b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py@@ -11172,14 +11172,9 @@ class JiuWenSwarmDeepAdapter:)skill_path = params.get("skill_path") or params.get("path")if skill_path:- allowed = evolution_version_ctl.allowed_skill_roots_for_path(- self._resolve_skill_dirs(),- str(skill_path),- )evolution_version_ctl.validate_rebuild_skill_path(str(skill_path),skill_name=skill_name,- allowed_roots=allowed,)skills_base = evolution_version_ctl.skills_root_from_skill_md_path(str(skill_path))store = evolution_version_ctl.get_disk_evolution_store(@@ -11244,16 +11239,10 @@ class JiuWenSwarmDeepAdapter:store_dirs = [str(skills_dirs_param).strip()]else:store_dirs = None- resolve_dirs = store_dirs if store_dirs is not None else self._resolve_skill_dirs()if skill_path:- allowed = evolution_version_ctl.allowed_skill_roots_for_path(- resolve_dirs,- str(skill_path),- )resolved_skill_md = evolution_version_ctl.validate_rebuild_skill_path(str(skill_path),skill_name=name,- allowed_roots=allowed,)logger.info(diff --git a/tests/unit_tests/agentserver/test_skills_evolution_version_rpc.py b/tests/unit_tests/agentserver/test_skills_evolution_version_rpc.pyindex 04cac66ba1..a58e9cfe7f 100644--- a/tests/unit_tests/agentserver/test_skills_evolution_version_rpc.py+++ b/tests/unit_tests/agentserver/test_skills_evolution_version_rpc.py@@ -250,27 +250,6 @@ async def test_do_evolve_rollback_clears_live_evolutions(tmp_path):assert live["entries"] == []-def test_allowed_skill_roots_for_path_includes_control_plane_root(tmp_path: Path, monkeypatch):- workspace_skills = tmp_path / "workspace" / "skills"- workspace_skills.mkdir(parents=True)- project_skills = tmp_path / "relay-claw" / ".office-claw" / "skills"- skill_md = project_skills / "tianqi" / "SKILL.md"- skill_md.parent.mkdir(parents=True)- skill_md.write_text("# tianqi\n", encoding="utf-8")-- monkeypatch.setattr(- evolution_version_ctl,- "resolve_agent_registered_skill_dirs",- lambda: [workspace_skills],- )- roots = evolution_version_ctl.allowed_skill_roots_for_path(- [str(workspace_skills)],- str(skill_md),- )- assert str(workspace_skills.resolve()) in roots- assert str(project_skills.resolve()) in roots--@pytest.mark.anyioasync def test_handle_skills_evolution_rollback_accepts_office_claw_skill_path(tmp_path, monkeypatch,@@ -336,42 +315,6 @@ async def test_handle_skills_evolution_rollback_accepts_office_claw_skill_path(assert skill_md.read_text(encoding="utf-8") == "# archived-body\n"-async def test_handle_skills_evolution_rollback_rejects_path_outside_allowed(- tmp_path, monkeypatch,-):- workspace_skills = tmp_path / "workspace" / "skills"- workspace_skills.mkdir(parents=True)- other = tmp_path / "other" / "skills" / "demo-skill"- other.mkdir(parents=True)- skill_md = other / "SKILL.md"- skill_md.write_text("# demo\n", encoding="utf-8")-- adapter = JiuWenSwarmDeepAdapter()- monkeypatch.setattr(adapter, "_resolve_skill_dirs", lambda: [str(workspace_skills)])- monkeypatch.setattr(- evolution_version_ctl,- "resolve_agent_registered_skill_dirs",- lambda: [workspace_skills],- )- # Do not include skill_path root via helper path: validate with stale roots only- # by forcing allowed_skill_roots_for_path to omit the control-plane root.- monkeypatch.setattr(- evolution_version_ctl,- "allowed_skill_roots_for_path",- lambda _adapter_dirs, _skill_path=None: [str(workspace_skills.resolve())],- )-- with pytest.raises(ValueError, match="outside registered skill roots"):- await adapter.handle_skills_evolution_rollback(- {- "name": "demo-skill",- "version": "latest",- "skill_path": str(skill_md),- }- )--@pytest.mark.anyioasync def test_handle_skills_evolution_rollback_rejects_mismatched_skill_dir_name(tmp_path, monkeypatch,