mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-20 12:54:45 +08:00
* Refactor sandbox state management and improve Docker integration - Removed FileSandboxStateStore and SandboxStateStore classes for a cleaner architecture. - Enhanced LocalContainerBackend to handle port allocation retries and introduced environment variable support for sandbox host configuration. - Updated Paths class to include host_base_dir for Docker volume mounts and ensured proper permissions for sandbox directories. - Modified ExtensionsConfig to improve error handling when loading configuration files and adjusted environment variable resolution. - Updated sandbox configuration to include a replicas option for managing concurrent sandbox containers. - Improved logging and context management in SandboxMiddleware for better sandbox lifecycle handling. - Enhanced network port allocation logic to bind to 0.0.0.0 for compatibility with Docker. - Updated Docker Compose files to ensure proper volume management and environment variable configuration. - Created scripts to ensure necessary configuration files are present before starting services. - Cleaned up unused MCP server configurations in extensions_config.example.json. * Address Copilot review suggestions from PR #1068 (#9) --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
62 lines
2.7 KiB
Python
62 lines
2.7 KiB
Python
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class VolumeMountConfig(BaseModel):
|
|
"""Configuration for a volume mount."""
|
|
|
|
host_path: str = Field(..., description="Path on the host machine")
|
|
container_path: str = Field(..., description="Path inside the container")
|
|
read_only: bool = Field(default=False, description="Whether the mount is read-only")
|
|
|
|
|
|
class SandboxConfig(BaseModel):
|
|
"""Config section for a sandbox.
|
|
|
|
Common options:
|
|
use: Class path of the sandbox provider (required)
|
|
|
|
AioSandboxProvider specific options:
|
|
image: Docker image to use (default: enterprise-public-cn-beijing.cr.volces.com/vefaas-public/all-in-one-sandbox:latest)
|
|
port: Base port for sandbox containers (default: 8080)
|
|
replicas: Maximum number of concurrent sandbox containers (default: 3). When the limit is reached the least-recently-used sandbox is evicted to make room.
|
|
container_prefix: Prefix for container names (default: deer-flow-sandbox)
|
|
idle_timeout: Idle timeout in seconds before sandbox is released (default: 600 = 10 minutes). Set to 0 to disable.
|
|
mounts: List of volume mounts to share directories with the container
|
|
environment: Environment variables to inject into the container (values starting with $ are resolved from host env)
|
|
"""
|
|
|
|
use: str = Field(
|
|
...,
|
|
description="Class path of the sandbox provider (e.g. src.sandbox.local:LocalSandboxProvider)",
|
|
)
|
|
image: str | None = Field(
|
|
default=None,
|
|
description="Docker image to use for the sandbox container",
|
|
)
|
|
port: int | None = Field(
|
|
default=None,
|
|
description="Base port for sandbox containers",
|
|
)
|
|
replicas: int | None = Field(
|
|
default=None,
|
|
description="Maximum number of concurrent sandbox containers (default: 3). When the limit is reached the least-recently-used sandbox is evicted to make room.",
|
|
)
|
|
container_prefix: str | None = Field(
|
|
default=None,
|
|
description="Prefix for container names",
|
|
)
|
|
idle_timeout: int | None = Field(
|
|
default=None,
|
|
description="Idle timeout in seconds before sandbox is released (default: 600 = 10 minutes). Set to 0 to disable.",
|
|
)
|
|
mounts: list[VolumeMountConfig] = Field(
|
|
default_factory=list,
|
|
description="List of volume mounts to share directories between host and container",
|
|
)
|
|
environment: dict[str, str] = Field(
|
|
default_factory=dict,
|
|
description="Environment variables to inject into the sandbox container. Values starting with $ will be resolved from host environment variables.",
|
|
)
|
|
|
|
model_config = ConfigDict(extra="allow")
|