fix: preserve internal tool write scopes

Maintainer edit: keep capability-specific allowed_dir boundaries active even when the outer workspace scope is full access, and cover Dream plus ordinary full-access filesystem behavior.
This commit is contained in:
chengyongru
2026-06-18 00:03:26 +08:00
committed by Xubin Ren
parent 51f2dae855
commit 42ce294665
3 changed files with 66 additions and 6 deletions
+1 -3
View File
@@ -101,15 +101,13 @@ class _FsTool(Tool):
return current_file_states(self._fallback_file_states)
def _effective_allowed_root(self, access_allowed_root: Path | None) -> Path | None:
if access_allowed_root is None:
return None
if self._allowed_dir is None or self._workspace is None:
return access_allowed_root
try:
allowed_dir = Path(self._allowed_dir).expanduser().resolve(strict=False)
workspace = Path(self._workspace).expanduser().resolve(strict=False)
except (OSError, RuntimeError, TypeError, ValueError):
return access_allowed_root
return access_allowed_root if access_allowed_root is not None else self._allowed_dir
if allowed_dir == workspace:
return access_allowed_root
return allowed_dir