feat: allow user specific home dir (#38903)

This commit is contained in:
wangxiaolei authored and GitHub committed 2026-07-14 08:07:47 +00:00
1 parent 2c4d8ef098
commit f71a30bebf
10 files changed
+113 -7

No files matched your search

+1
View File
@@ -66,6 +66,7 @@ def create_app(settings: ServerSettings | None = None) -> FastAPI:
inner_api_url=resolved_settings.inner_api_url,
inner_api_key=resolved_settings.inner_api_key or "",
shell_provider=shell_provider,
shell_home_root=resolved_settings.shell_home_root,
agent_stub_api_base_url=resolved_settings.agent_stub_api_base_url,
agent_stub_token_factory=agent_stub_token_factory,
)
@@ -44,6 +44,7 @@ class ServerSettings(BaseSettings):
shell_provider: Literal["shellctl", "enterprise"] = "shellctl"
shellctl_entrypoint: str | None = None
shellctl_auth_token: str | None = None
shell_home_root: str = "/home"
enterprise_sandbox_gateway_endpoint: str | None = None
enterprise_sandbox_gateway_auth_token: str | None = None
enterprise_sandbox_gateway_timeout: float = Field(default=30.0, gt=0)
@@ -125,6 +126,17 @@ class ServerSettings(BaseSettings):
stripped = value.strip()
return stripped or None
@field_validator("shell_home_root")
@classmethod
def normalize_shell_home_root(cls, value: str) -> str:
"""Normalize the root used for per-Agent shell HOME directories."""
stripped = value.strip().rstrip("/")
if not stripped:
raise ValueError("DIFY_AGENT_SHELL_HOME_ROOT must not be empty")
if not stripped.startswith("/"):
raise ValueError("DIFY_AGENT_SHELL_HOME_ROOT must be an absolute path")
return stripped
@model_validator(mode="after")
def validate_agent_stub_requirements(self) -> "ServerSettings":
"""Require Agent Stub settings while allowing deployments without inner API calls."""