Skip to content

exxec_config

Class info

Re-exported classes

Class Module Description
BaseExecutionEnvironmentConfig exxec_config.configs Base execution environment configuration.
BeamExecutionEnvironmentConfig exxec_config.configs Beam execution environment configuration.
CloudflareExecutionEnvironmentConfig exxec_config.configs Cloudflare sandbox execution environment configuration.
DaytonaExecutionEnvironmentConfig exxec_config.configs Daytona execution environment configuration.
DockerExecutionEnvironmentConfig exxec_config.configs Docker execution environment configuration.
E2bExecutionEnvironmentConfig exxec_config.configs E2B execution environment configuration.
HopxExecutionEnvironmentConfig exxec_config.configs Hopx execution environment configuration.
LocalExecutionEnvironmentConfig exxec_config.configs Local execution environment configuration.
MicrosandboxExecutionEnvironmentConfig exxec_config.configs Microsandbox execution environment configuration.
MockExecutionEnvironmentConfig exxec_config.configs Mock execution environment configuration.
ModalExecutionEnvironmentConfig exxec_config.configs Modal execution environment configuration.
PyodideExecutionEnvironmentConfig exxec_config.configs Pyodide execution environment configuration.
SRTExecutionEnvironmentConfig exxec_config.configs Sandboxed execution environment using Anthropic's sandbox-runtime.
SandboxConfig exxec_config.srt_sandbox_config Configuration for sandbox-runtime restrictions.
SpritesExecutionEnvironmentConfig exxec_config.configs Sprites execution environment configuration.
SshExecutionEnvironmentConfig exxec_config.configs SSH execution environment configuration.
VercelExecutionEnvironmentConfig exxec_config.configs Vercel execution environment configuration.

🛈 DocStrings

Execution environment configuration.

This is a lightweight config-only package for fast imports. For the actual execution environments, use from exxec import ....

BaseExecutionEnvironmentConfig

Bases: Schema

Base execution environment configuration.

Source code in src/exxec_config/configs.py
class BaseExecutionEnvironmentConfig(Schema):
    """Base execution environment configuration."""

    type: str = Field(init=False)
    """Execution environment type."""

    dependencies: list[str] | None = Field(
        default=None,
        title="Dependencies",
        examples=["numpy", "pandas"],
    )
    """List of packages to install (pip for Python, npm for JS/TS)."""

    default_command_timeout: float | None = Field(
        default=None,
        gt=0.0,
        title="Default Command Timeout",
        examples=[30.0, 60.0, 120.0],
    )
    """Default timeout for individual command execution in seconds. None means no timeout."""

    cwd: str | None = Field(
        default=None,
        title="Working Directory",
        examples=["/home/user/project", "/tmp/workspace"],
    )
    """Working directory for the environment (None means use default/auto)."""

    env_vars: dict[str, str] | None = Field(
        default=None,
        title="Environment Variables",
        examples=[{"API_KEY": "secret", "DEBUG": "1"}],
    )
    """Environment variables to set for all executions."""

    inherit_env: bool = Field(
        default=False,
        title="Inherit Environment",
    )
    """If True, inherit environment variables from os.environ (default False for security)."""

cwd class-attribute instance-attribute

cwd: str | None = Field(
    default=None, title="Working Directory", examples=["/home/user/project", "/tmp/workspace"]
)

Working directory for the environment (None means use default/auto).

default_command_timeout class-attribute instance-attribute

default_command_timeout: float | None = Field(
    default=None, gt=0.0, title="Default Command Timeout", examples=[30.0, 60.0, 120.0]
)

Default timeout for individual command execution in seconds. None means no timeout.

dependencies class-attribute instance-attribute

dependencies: list[str] | None = Field(
    default=None, title="Dependencies", examples=["numpy", "pandas"]
)

List of packages to install (pip for Python, npm for JS/TS).

env_vars class-attribute instance-attribute

env_vars: dict[str, str] | None = Field(
    default=None, title="Environment Variables", examples=[{"API_KEY": "secret", "DEBUG": "1"}]
)

Environment variables to set for all executions.

inherit_env class-attribute instance-attribute

inherit_env: bool = Field(default=False, title='Inherit Environment')

If True, inherit environment variables from os.environ (default False for security).

type class-attribute instance-attribute

type: str = Field(init=False)

Execution environment type.

BeamExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Beam execution environment configuration.

Executes code in Beam cloud sandboxes for scalable, serverless execution environments.

Source code in src/exxec_config/configs.py
class BeamExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Beam execution environment configuration.

    Executes code in Beam cloud sandboxes for scalable, serverless execution environments.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Beam Execution Environment"})

    type: Literal["beam"] = Field("beam", init=False)

    cpu: float | str = Field(
        default=1.0,
        ge=0.1,
        le=64.0,
        title="CPU Cores",
        examples=[0.5, 1.0, 2.0, "1500m"],
    )
    """CPU cores allocated to the container."""

    memory: int | str = Field(default=128, title="Memory (MiB)", examples=[128, "1Gi"])
    """Memory allocated to the container in MiB."""

    keep_warm_seconds: int = Field(default=600, title="Keep Warm Duration", examples=[300, 600, -1])
    """Seconds to keep sandbox alive, -1 for no timeout."""

    sandbox_timeout: float = Field(
        default=300.0,
        gt=0.0,
        title="Sandbox Lifetime",
        examples=[300.0, 600.0, 3600.0],
    )
    """How long the sandbox stays alive in seconds."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> BeamExecutionEnvironment:
        """Create Beam execution environment instance."""
        from exxec.beam_provider import BeamExecutionEnvironment

        return BeamExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            cpu=self.cpu,
            memory=self.memory,
            keep_warm_seconds=self.keep_warm_seconds,
            timeout=self.sandbox_timeout,
            default_command_timeout=self.default_command_timeout,
            language=self.language,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

cpu class-attribute instance-attribute

cpu: float | str = Field(
    default=1.0, ge=0.1, le=64.0, title="CPU Cores", examples=[0.5, 1.0, 2.0, "1500m"]
)

CPU cores allocated to the container.

keep_warm_seconds class-attribute instance-attribute

keep_warm_seconds: int = Field(default=600, title='Keep Warm Duration', examples=[300, 600, -1])

Seconds to keep sandbox alive, -1 for no timeout.

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

memory class-attribute instance-attribute

memory: int | str = Field(default=128, title='Memory (MiB)', examples=[128, '1Gi'])

Memory allocated to the container in MiB.

sandbox_timeout class-attribute instance-attribute

sandbox_timeout: float = Field(
    default=300.0, gt=0.0, title="Sandbox Lifetime", examples=[300.0, 600.0, 3600.0]
)

How long the sandbox stays alive in seconds.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> BeamExecutionEnvironment

Create Beam execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> BeamExecutionEnvironment:
    """Create Beam execution environment instance."""
    from exxec.beam_provider import BeamExecutionEnvironment

    return BeamExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        cpu=self.cpu,
        memory=self.memory,
        keep_warm_seconds=self.keep_warm_seconds,
        timeout=self.sandbox_timeout,
        default_command_timeout=self.default_command_timeout,
        language=self.language,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

CloudflareExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Cloudflare sandbox execution environment configuration.

Executes code in a Cloudflare Worker sandbox deployment via HTTP API.

Source code in src/exxec_config/configs.py
class CloudflareExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Cloudflare sandbox execution environment configuration.

    Executes code in a Cloudflare Worker sandbox deployment via HTTP API.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Cloudflare Execution Environment"})
    type: Literal["cloudflare"] = Field("cloudflare", init=False)
    base_url: str = Field(
        ...,
        title="Worker Base URL",
        examples=["https://my-sandbox.workers.dev"],
    )
    """Base URL of the Cloudflare Sandbox Worker deployment."""

    api_token: SecretStr | None = Field(
        default=None,
        title="API Token",
    )
    """API token for authentication (optional)."""

    account_id: str | None = Field(
        default=None,
        title="Account ID",
    )
    """Cloudflare account ID (optional)."""

    session_id: str | None = Field(
        default=None,
        title="Session ID",
    )
    """Explicit session ID (auto-generated if None)."""

    timeout: float = Field(
        default=30.0,
        gt=0.0,
        title="HTTP Timeout",
        examples=[30.0, 60.0],
    )
    """HTTP request timeout in seconds."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> CloudflareExecutionEnvironment:
        """Create Cloudflare execution environment instance."""
        from exxec.cloudflare_provider import CloudflareExecutionEnvironment

        return CloudflareExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            base_url=self.base_url,
            api_token=self.api_token.get_secret_value() if self.api_token else None,
            account_id=self.account_id,
            session_id=self.session_id,
            timeout=self.timeout,
            default_command_timeout=self.default_command_timeout,
            language=self.language,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

account_id class-attribute instance-attribute

account_id: str | None = Field(default=None, title='Account ID')

Cloudflare account ID (optional).

api_token class-attribute instance-attribute

api_token: SecretStr | None = Field(default=None, title='API Token')

API token for authentication (optional).

base_url class-attribute instance-attribute

base_url: str = Field(..., title='Worker Base URL', examples=['https://my-sandbox.workers.dev'])

Base URL of the Cloudflare Sandbox Worker deployment.

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

session_id class-attribute instance-attribute

session_id: str | None = Field(default=None, title='Session ID')

Explicit session ID (auto-generated if None).

timeout class-attribute instance-attribute

timeout: float = Field(default=30.0, gt=0.0, title='HTTP Timeout', examples=[30.0, 60.0])

HTTP request timeout in seconds.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> CloudflareExecutionEnvironment

Create Cloudflare execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> CloudflareExecutionEnvironment:
    """Create Cloudflare execution environment instance."""
    from exxec.cloudflare_provider import CloudflareExecutionEnvironment

    return CloudflareExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        base_url=self.base_url,
        api_token=self.api_token.get_secret_value() if self.api_token else None,
        account_id=self.account_id,
        session_id=self.session_id,
        timeout=self.timeout,
        default_command_timeout=self.default_command_timeout,
        language=self.language,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

DaytonaExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Daytona execution environment configuration.

Executes code in remote Daytona sandboxes for cloud-based development environments.

Source code in src/exxec_config/configs.py
class DaytonaExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Daytona execution environment configuration.

    Executes code in remote Daytona sandboxes for cloud-based development environments.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Daytona Execution Environment"})
    type: Literal["daytona"] = Field("daytona", init=False)
    api_url: str | None = Field(
        default=None,
        title="API URL",
        examples=["https://api.daytona.io", "http://localhost:3986"],
    )
    """Daytona API URL (optional, uses env vars if not provided)."""

    api_key: SecretStr | None = Field(default=None, title="API Key")
    """API key for authentication."""

    target: str | None = Field(
        default=None,
        title="Target Configuration",
        examples=["local", "docker", "kubernetes"],
    )
    """Target configuration."""

    image: str = Field(
        default="python:3.13-slim",
        title="Container Image",
        examples=["python:3.13-slim", "node:20-alpine", "ubuntu:22.04"],
    )
    """Container image."""

    keep_alive: bool = Field(default=False, title="Keep Alive")
    """Keep sandbox running after execution."""

    sandbox_timeout: float = Field(
        default=300.0,
        gt=0.0,
        title="Sandbox Lifetime",
        examples=[300.0, 600.0, 3600.0],
    )
    """How long the sandbox stays alive in seconds."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> DaytonaExecutionEnvironment:
        """Create Daytona execution environment instance."""
        from exxec.daytona_provider import DaytonaExecutionEnvironment

        api_key_str = self.api_key.get_secret_value() if self.api_key else None
        return DaytonaExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            api_url=self.api_url,
            api_key=api_key_str,
            target=self.target,
            image=self.image,
            timeout=self.sandbox_timeout,
            default_command_timeout=self.default_command_timeout,
            keep_alive=self.keep_alive,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

api_key class-attribute instance-attribute

api_key: SecretStr | None = Field(default=None, title='API Key')

API key for authentication.

api_url class-attribute instance-attribute

api_url: str | None = Field(
    default=None, title="API URL", examples=["https://api.daytona.io", "http://localhost:3986"]
)

Daytona API URL (optional, uses env vars if not provided).

image class-attribute instance-attribute

image: str = Field(
    default="python:3.13-slim",
    title="Container Image",
    examples=["python:3.13-slim", "node:20-alpine", "ubuntu:22.04"],
)

Container image.

keep_alive class-attribute instance-attribute

keep_alive: bool = Field(default=False, title='Keep Alive')

Keep sandbox running after execution.

sandbox_timeout class-attribute instance-attribute

sandbox_timeout: float = Field(
    default=300.0, gt=0.0, title="Sandbox Lifetime", examples=[300.0, 600.0, 3600.0]
)

How long the sandbox stays alive in seconds.

target class-attribute instance-attribute

target: str | None = Field(
    default=None, title="Target Configuration", examples=["local", "docker", "kubernetes"]
)

Target configuration.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> DaytonaExecutionEnvironment

Create Daytona execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> DaytonaExecutionEnvironment:
    """Create Daytona execution environment instance."""
    from exxec.daytona_provider import DaytonaExecutionEnvironment

    api_key_str = self.api_key.get_secret_value() if self.api_key else None
    return DaytonaExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        api_url=self.api_url,
        api_key=api_key_str,
        target=self.target,
        image=self.image,
        timeout=self.sandbox_timeout,
        default_command_timeout=self.default_command_timeout,
        keep_alive=self.keep_alive,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

DockerExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Docker execution environment configuration.

Executes code in Docker containers for strong isolation and reproducible environments.

Source code in src/exxec_config/configs.py
class DockerExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Docker execution environment configuration.

    Executes code in Docker containers for strong isolation and reproducible environments.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Docker Execution Environment"})

    type: Literal["docker"] = Field("docker", init=False)

    image: str = Field(
        default="python:3.13-slim",
        title="Docker Image",
        examples=["python:3.13-slim", "node:20-alpine", "ubuntu:22.04"],
    )
    """Docker image to use."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> DockerExecutionEnvironment:
        """Create Docker execution environment instance."""
        from exxec.docker_provider import DockerExecutionEnvironment

        return DockerExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            image=self.image,
            default_command_timeout=self.default_command_timeout,
            language=self.language,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

image class-attribute instance-attribute

image: str = Field(
    default="python:3.13-slim",
    title="Docker Image",
    examples=["python:3.13-slim", "node:20-alpine", "ubuntu:22.04"],
)

Docker image to use.

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> DockerExecutionEnvironment

Create Docker execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> DockerExecutionEnvironment:
    """Create Docker execution environment instance."""
    from exxec.docker_provider import DockerExecutionEnvironment

    return DockerExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        image=self.image,
        default_command_timeout=self.default_command_timeout,
        language=self.language,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

E2bExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

E2B execution environment configuration.

Executes code in E2B sandboxes for secure, ephemeral execution environments.

Source code in src/exxec_config/configs.py
class E2bExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """E2B execution environment configuration.

    Executes code in E2B sandboxes for secure, ephemeral execution environments.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "E2B Execution Environment"})
    type: Literal["e2b"] = Field("e2b", init=False)
    template: str | None = Field(
        default=None,
        title="E2B Template",
        examples=["python", "nodejs", "custom-template-id"],
    )
    """E2B template to use."""

    sandbox_timeout: float = Field(
        default=300.0,
        gt=0.0,
        title="Sandbox Lifetime",
        examples=[300.0, 600.0, 3600.0],
    )
    """How long the sandbox stays alive in seconds."""

    keep_alive: bool = Field(default=False, title="Keep Alive")
    """Keep sandbox running after execution."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> E2bExecutionEnvironment:
        """Create E2B execution environment instance."""
        from exxec.e2b_provider import E2bExecutionEnvironment

        return E2bExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            template=self.template,
            timeout=self.sandbox_timeout,
            default_command_timeout=self.default_command_timeout,
            keep_alive=self.keep_alive,
            language=self.language,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

keep_alive class-attribute instance-attribute

keep_alive: bool = Field(default=False, title='Keep Alive')

Keep sandbox running after execution.

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

sandbox_timeout class-attribute instance-attribute

sandbox_timeout: float = Field(
    default=300.0, gt=0.0, title="Sandbox Lifetime", examples=[300.0, 600.0, 3600.0]
)

How long the sandbox stays alive in seconds.

template class-attribute instance-attribute

template: str | None = Field(
    default=None, title="E2B Template", examples=["python", "nodejs", "custom-template-id"]
)

E2B template to use.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> E2bExecutionEnvironment

Create E2B execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> E2bExecutionEnvironment:
    """Create E2B execution environment instance."""
    from exxec.e2b_provider import E2bExecutionEnvironment

    return E2bExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        template=self.template,
        timeout=self.sandbox_timeout,
        default_command_timeout=self.default_command_timeout,
        keep_alive=self.keep_alive,
        language=self.language,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

HopxExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Hopx execution environment configuration.

Executes code in Hopx cloud VM sandboxes for secure, ephemeral execution environments.

Source code in src/exxec_config/configs.py
class HopxExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Hopx execution environment configuration.

    Executes code in Hopx cloud VM sandboxes for secure, ephemeral execution environments.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Hopx Execution Environment"})
    type: Literal["hopx"] = Field("hopx", init=False)
    template: str | None = Field(
        default=None,
        title="Hopx Template",
        examples=["code-interpreter", "base"],
    )
    """Hopx template name to use."""

    template_id: str | None = Field(
        default=None,
        title="Hopx Template ID",
    )
    """Hopx template ID (alternative to template name)."""

    api_key: SecretStr | None = Field(
        default=None,
        title="Hopx API Key",
    )
    """Hopx API key (or use HOPX_API_KEY env var)."""

    base_url: str = Field(
        default="https://api.hopx.dev",
        title="API Base URL",
    )
    """Hopx API base URL."""

    region: str | None = Field(
        default=None,
        title="Region",
    )
    """Preferred region for sandbox creation."""

    sandbox_timeout: float = Field(
        default=300.0,
        gt=0.0,
        title="Sandbox Lifetime",
        examples=[300.0, 600.0, 3600.0],
    )
    """How long the sandbox stays alive in seconds."""

    keep_alive: bool = Field(default=False, title="Keep Alive")
    """Keep sandbox running after execution."""

    internet_access: bool | None = Field(
        default=None,
        title="Internet Access",
    )
    """Enable internet access in the sandbox."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> HopxExecutionEnvironment:
        """Create Hopx execution environment instance."""
        from exxec.hopx_provider import HopxExecutionEnvironment

        return HopxExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            template=self.template,
            template_id=self.template_id,
            timeout=self.sandbox_timeout,
            default_command_timeout=self.default_command_timeout,
            keep_alive=self.keep_alive,
            language=self.language,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
            api_key=self.api_key.get_secret_value() if self.api_key else None,
            base_url=self.base_url,
            region=self.region,
            internet_access=self.internet_access,
        )

api_key class-attribute instance-attribute

api_key: SecretStr | None = Field(default=None, title='Hopx API Key')

Hopx API key (or use HOPX_API_KEY env var).

base_url class-attribute instance-attribute

base_url: str = Field(default='https://api.hopx.dev', title='API Base URL')

Hopx API base URL.

internet_access class-attribute instance-attribute

internet_access: bool | None = Field(default=None, title='Internet Access')

Enable internet access in the sandbox.

keep_alive class-attribute instance-attribute

keep_alive: bool = Field(default=False, title='Keep Alive')

Keep sandbox running after execution.

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

region class-attribute instance-attribute

region: str | None = Field(default=None, title='Region')

Preferred region for sandbox creation.

sandbox_timeout class-attribute instance-attribute

sandbox_timeout: float = Field(
    default=300.0, gt=0.0, title="Sandbox Lifetime", examples=[300.0, 600.0, 3600.0]
)

How long the sandbox stays alive in seconds.

template class-attribute instance-attribute

template: str | None = Field(
    default=None, title="Hopx Template", examples=["code-interpreter", "base"]
)

Hopx template name to use.

template_id class-attribute instance-attribute

template_id: str | None = Field(default=None, title='Hopx Template ID')

Hopx template ID (alternative to template name).

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> HopxExecutionEnvironment

Create Hopx execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> HopxExecutionEnvironment:
    """Create Hopx execution environment instance."""
    from exxec.hopx_provider import HopxExecutionEnvironment

    return HopxExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        template=self.template,
        template_id=self.template_id,
        timeout=self.sandbox_timeout,
        default_command_timeout=self.default_command_timeout,
        keep_alive=self.keep_alive,
        language=self.language,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
        api_key=self.api_key.get_secret_value() if self.api_key else None,
        base_url=self.base_url,
        region=self.region,
        internet_access=self.internet_access,
    )

LocalExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Local execution environment configuration.

Executes code in the same process. Fastest option but offers no isolation.

Source code in src/exxec_config/configs.py
class LocalExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Local execution environment configuration.

    Executes code in the same process. Fastest option but offers no isolation.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Local Execution Environment"})

    type: Literal["local"] = Field("local", init=False)

    executable: str | None = Field(
        default=None,
        title="Python Executable",
        examples=["/usr/bin/python3", "python3.13", "/opt/conda/bin/python"],
    )
    """Python executable to use (if None, auto-detect based on language)."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    isolated: bool = Field(default=False, title="Isolated Execution")
    """Whether to run code in a subprocess."""

    root_path: str | None = Field(
        default=None,
        title="Root path",
        examples=["/app", "/home/user"],
    )
    """Path to become the root of the filesystem."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> LocalExecutionEnvironment:
        """Create local execution environment instance."""
        from exxec.local_provider import LocalExecutionEnvironment

        return LocalExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            default_command_timeout=self.default_command_timeout,
            isolated=self.isolated,
            executable=self.executable,
            language=self.language,
            root_path=self.root_path,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

executable class-attribute instance-attribute

executable: str | None = Field(
    default=None,
    title="Python Executable",
    examples=["/usr/bin/python3", "python3.13", "/opt/conda/bin/python"],
)

Python executable to use (if None, auto-detect based on language).

isolated class-attribute instance-attribute

isolated: bool = Field(default=False, title='Isolated Execution')

Whether to run code in a subprocess.

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

root_path class-attribute instance-attribute

root_path: str | None = Field(default=None, title='Root path', examples=['/app', '/home/user'])

Path to become the root of the filesystem.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> LocalExecutionEnvironment

Create local execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> LocalExecutionEnvironment:
    """Create local execution environment instance."""
    from exxec.local_provider import LocalExecutionEnvironment

    return LocalExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        default_command_timeout=self.default_command_timeout,
        isolated=self.isolated,
        executable=self.executable,
        language=self.language,
        root_path=self.root_path,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

MicrosandboxExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Microsandbox execution environment configuration.

Executes code in lightweight microVMs for strong isolation.

Source code in src/exxec_config/configs.py
class MicrosandboxExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Microsandbox execution environment configuration.

    Executes code in lightweight microVMs for strong isolation.
    """

    model_config = ConfigDict(
        json_schema_extra={"x-doc-title": "Microsandbox Execution Environment"}
    )

    type: Literal["microsandbox"] = Field("microsandbox", init=False)

    namespace: str = Field(default="exxec", title="Namespace")
    """Prefix for the sandbox name (a unique suffix is appended)."""

    api_key: SecretStr | None = Field(default=None, title="API Key")
    """API key for authentication (uses MSB_API_KEY env var if None)."""

    memory: int = Field(default=512, ge=128, title="Memory (MiB)")
    """Memory limit in MiB."""

    cpus: int = Field(default=1, ge=1, title="Virtual CPUs")
    """Number of virtual CPUs."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    image: str | None = Field(
        default=None,
        title="Docker Image",
        examples=["python:3.13-slim", "node:20-alpine"],
    )
    """Custom Docker image (uses default for language if None)."""

    sandbox_timeout: float = Field(
        default=300.0,
        gt=0.0,
        title="Sandbox Lifetime",
        examples=[300.0, 600.0, 3600.0],
    )
    """How long the sandbox stays alive in seconds."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> MicrosandboxExecutionEnvironment:
        """Create Microsandbox execution environment instance."""
        from exxec.microsandbox_provider import MicrosandboxExecutionEnvironment

        api_key_str = self.api_key.get_secret_value() if self.api_key else None
        return MicrosandboxExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            namespace=self.namespace,
            api_key=api_key_str,
            memory=self.memory,
            cpus=self.cpus,
            timeout=self.sandbox_timeout,
            default_command_timeout=self.default_command_timeout,
            language=self.language,
            image=self.image,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

api_key class-attribute instance-attribute

api_key: SecretStr | None = Field(default=None, title='API Key')

API key for authentication (uses MSB_API_KEY env var if None).

cpus class-attribute instance-attribute

cpus: int = Field(default=1, ge=1, title='Virtual CPUs')

Number of virtual CPUs.

image class-attribute instance-attribute

image: str | None = Field(
    default=None, title="Docker Image", examples=["python:3.13-slim", "node:20-alpine"]
)

Custom Docker image (uses default for language if None).

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

memory class-attribute instance-attribute

memory: int = Field(default=512, ge=128, title='Memory (MiB)')

Memory limit in MiB.

namespace class-attribute instance-attribute

namespace: str = Field(default='exxec', title='Namespace')

Prefix for the sandbox name (a unique suffix is appended).

sandbox_timeout class-attribute instance-attribute

sandbox_timeout: float = Field(
    default=300.0, gt=0.0, title="Sandbox Lifetime", examples=[300.0, 600.0, 3600.0]
)

How long the sandbox stays alive in seconds.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> MicrosandboxExecutionEnvironment

Create Microsandbox execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> MicrosandboxExecutionEnvironment:
    """Create Microsandbox execution environment instance."""
    from exxec.microsandbox_provider import MicrosandboxExecutionEnvironment

    api_key_str = self.api_key.get_secret_value() if self.api_key else None
    return MicrosandboxExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        namespace=self.namespace,
        api_key=api_key_str,
        memory=self.memory,
        cpus=self.cpus,
        timeout=self.sandbox_timeout,
        default_command_timeout=self.default_command_timeout,
        language=self.language,
        image=self.image,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

MockExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Mock execution environment configuration.

For testing purposes. Uses an in-memory filesystem and configurable results. Dicts are passed as **kwargs to ExecutionResult/ProcessOutput constructors.

Source code in src/exxec_config/configs.py
class MockExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Mock execution environment configuration.

    For testing purposes. Uses an in-memory filesystem and configurable results.
    Dicts are passed as **kwargs to ExecutionResult/ProcessOutput constructors.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Mock Execution Environment"})

    type: Literal["mock"] = Field("mock", init=False)

    code_results: dict[str, dict[str, Any]] | None = Field(
        default=None,
        title="Code Results",
        examples=[{"print('hello')": {"stdout": "hello", "success": True}}],
    )
    """Map of code string to ExecutionResult kwargs dict."""

    command_results: dict[str, dict[str, Any]] | None = Field(
        default=None,
        title="Command Results",
        examples=[{"ls": {"stdout": "file1.txt", "success": True}}],
    )
    """Map of command string to ExecutionResult kwargs dict."""

    default_result: dict[str, Any] | None = Field(
        default=None,
        title="Default Result",
        examples=[{"stdout": "", "success": True}],
    )
    """Default ExecutionResult kwargs when no specific match is found."""

    deterministic_ids: bool = Field(
        default=False,
        title="Deterministic IDs",
    )
    """Use sequential IDs instead of UUIDs for processes (useful for snapshot testing)."""

    files: dict[str, str] | None = Field(
        default=None,
        title="Files",
        examples=[{"/test/hello.txt": "Hello, World!", "/data/config.json": '{"key": "value"}'}],
    )
    """Map of file paths to contents to pre-populate in the in-memory filesystem."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> MockExecutionEnvironment:
        """Create mock execution environment instance."""
        from exxec.mock_provider import MockExecutionEnvironment
        from exxec.models import ExecutionResult

        code_results = None
        if self.code_results:
            code_results = {k: ExecutionResult(**v) for k, v in self.code_results.items()}

        command_results = None
        if self.command_results:
            command_results = {k: ExecutionResult(**v) for k, v in self.command_results.items()}

        default_result = None
        if self.default_result:
            default_result = ExecutionResult(**self.default_result)

        env = MockExecutionEnvironment(
            code_results=code_results,
            command_results=command_results,
            default_result=default_result,
            deterministic_ids=self.deterministic_ids,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

        # Pre-populate files in the in-memory filesystem
        if self.files:
            for path, content in self.files.items():
                env._sync_fs.pipe_file(
                    path, content.encode() if isinstance(content, str) else content
                )

        return env

code_results class-attribute instance-attribute

code_results: dict[str, dict[str, Any]] | None = Field(
    default=None,
    title="Code Results",
    examples=[{"print('hello')": {"stdout": "hello", "success": True}}],
)

Map of code string to ExecutionResult kwargs dict.

command_results class-attribute instance-attribute

command_results: dict[str, dict[str, Any]] | None = Field(
    default=None,
    title="Command Results",
    examples=[{"ls": {"stdout": "file1.txt", "success": True}}],
)

Map of command string to ExecutionResult kwargs dict.

default_result class-attribute instance-attribute

default_result: dict[str, Any] | None = Field(
    default=None, title="Default Result", examples=[{"stdout": "", "success": True}]
)

Default ExecutionResult kwargs when no specific match is found.

deterministic_ids class-attribute instance-attribute

deterministic_ids: bool = Field(default=False, title='Deterministic IDs')

Use sequential IDs instead of UUIDs for processes (useful for snapshot testing).

files class-attribute instance-attribute

files: dict[str, str] | None = Field(
    default=None,
    title="Files",
    examples=[{"/test/hello.txt": "Hello, World!", "/data/config.json": '{"key": "value"}'}],
)

Map of file paths to contents to pre-populate in the in-memory filesystem.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> MockExecutionEnvironment

Create mock execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> MockExecutionEnvironment:
    """Create mock execution environment instance."""
    from exxec.mock_provider import MockExecutionEnvironment
    from exxec.models import ExecutionResult

    code_results = None
    if self.code_results:
        code_results = {k: ExecutionResult(**v) for k, v in self.code_results.items()}

    command_results = None
    if self.command_results:
        command_results = {k: ExecutionResult(**v) for k, v in self.command_results.items()}

    default_result = None
    if self.default_result:
        default_result = ExecutionResult(**self.default_result)

    env = MockExecutionEnvironment(
        code_results=code_results,
        command_results=command_results,
        default_result=default_result,
        deterministic_ids=self.deterministic_ids,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

    # Pre-populate files in the in-memory filesystem
    if self.files:
        for path, content in self.files.items():
            env._sync_fs.pipe_file(
                path, content.encode() if isinstance(content, str) else content
            )

    return env

ModalExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Modal execution environment configuration.

Executes code in Modal serverless sandboxes for scalable cloud execution.

Source code in src/exxec_config/configs.py
class ModalExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Modal execution environment configuration.

    Executes code in Modal serverless sandboxes for scalable cloud execution.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Modal Execution Environment"})

    type: Literal["modal"] = Field("modal", init=False)

    app_name: str | None = Field(
        default=None,
        title="App Name",
        examples=["my-app", "anyenv-execution"],
    )
    """Modal app name (creates if missing)."""

    cpu: float | None = Field(default=None, ge=0.1, title="CPU Cores")
    """CPU allocation in cores."""

    memory: int | None = Field(default=None, ge=128, title="Memory (MB)")
    """Memory allocation in MB."""

    gpu: str | None = Field(default=None, title="GPU Type", examples=["T4", "A100", "A10G"])
    """GPU type."""

    timeout: int = Field(default=60, title="Timeout")
    """Timeout for the sandbox."""

    idle_timeout: int | None = Field(default=None, title="Idle Timeout (seconds)")
    """Idle timeout in seconds."""

    workdir: str = Field(default="/tmp", title="Working Directory")
    """Working directory in sandbox."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> ModalExecutionEnvironment:
        """Create Modal execution environment instance."""
        from exxec.modal_provider import ModalExecutionEnvironment

        return ModalExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            app_name=self.app_name,
            cpu=self.cpu,
            memory=self.memory,
            gpu=self.gpu,
            timeout=int(self.timeout),
            default_command_timeout=self.default_command_timeout,
            idle_timeout=self.idle_timeout,
            workdir=self.workdir,
            language=self.language,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

app_name class-attribute instance-attribute

app_name: str | None = Field(
    default=None, title="App Name", examples=["my-app", "anyenv-execution"]
)

Modal app name (creates if missing).

cpu class-attribute instance-attribute

cpu: float | None = Field(default=None, ge=0.1, title='CPU Cores')

CPU allocation in cores.

gpu class-attribute instance-attribute

gpu: str | None = Field(default=None, title='GPU Type', examples=['T4', 'A100', 'A10G'])

GPU type.

idle_timeout class-attribute instance-attribute

idle_timeout: int | None = Field(default=None, title='Idle Timeout (seconds)')

Idle timeout in seconds.

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

memory class-attribute instance-attribute

memory: int | None = Field(default=None, ge=128, title='Memory (MB)')

Memory allocation in MB.

timeout class-attribute instance-attribute

timeout: int = Field(default=60, title='Timeout')

Timeout for the sandbox.

workdir class-attribute instance-attribute

workdir: str = Field(default='/tmp', title='Working Directory')

Working directory in sandbox.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> ModalExecutionEnvironment

Create Modal execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> ModalExecutionEnvironment:
    """Create Modal execution environment instance."""
    from exxec.modal_provider import ModalExecutionEnvironment

    return ModalExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        app_name=self.app_name,
        cpu=self.cpu,
        memory=self.memory,
        gpu=self.gpu,
        timeout=int(self.timeout),
        default_command_timeout=self.default_command_timeout,
        idle_timeout=self.idle_timeout,
        workdir=self.workdir,
        language=self.language,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

PyodideExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Pyodide execution environment configuration.

Executes Python code in WASM via Deno for sandboxed browser-like execution.

Source code in src/exxec_config/configs.py
class PyodideExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Pyodide execution environment configuration.

    Executes Python code in WASM via Deno for sandboxed browser-like execution.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Pyodide Execution Environment"})

    type: Literal["pyodide"] = Field("pyodide", init=False)

    startup_timeout: float = Field(default=60.0, gt=0.0, title="Startup Timeout")
    """Timeout for Pyodide initialization in seconds."""

    allow_net: bool | list[str] = Field(default=True, title="Network Access")
    """Network access (True=all, list=specific hosts, False=none)."""

    allow_read: bool | list[str] = Field(default=False, title="File Read Access")
    """File read access."""

    allow_write: bool | list[str] = Field(default=False, title="File Write Access")
    """File write access."""

    allow_env: bool | list[str] = Field(default=False, title="Environment Variable Access")
    """Environment variable access."""

    allow_run: bool | list[str] = Field(default=False, title="Subprocess Execution")
    """Subprocess execution (limited in WASM)."""

    allow_ffi: bool | list[str] = Field(default=False, title="FFI Access")
    """Foreign function interface access."""

    deno_executable: str | None = Field(
        default=None,
        title="Deno Executable",
        examples=["deno", "/usr/local/bin/deno"],
    )
    """Path to deno executable (auto-detected if None)."""

    sandbox_timeout: float = Field(
        default=300.0,
        gt=0.0,
        title="Sandbox Lifetime",
        examples=[300.0, 600.0, 3600.0],
    )
    """How long the sandbox stays alive in seconds."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> PyodideExecutionEnvironment:
        """Create Pyodide execution environment instance."""
        from exxec.pyodide_provider import PyodideExecutionEnvironment

        return PyodideExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            timeout=self.sandbox_timeout,
            default_command_timeout=self.default_command_timeout,
            startup_timeout=self.startup_timeout,
            allow_net=self.allow_net,
            allow_read=self.allow_read,
            allow_write=self.allow_write,
            allow_env=self.allow_env,
            allow_run=self.allow_run,
            allow_ffi=self.allow_ffi,
            deno_executable=self.deno_executable,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

allow_env class-attribute instance-attribute

allow_env: bool | list[str] = Field(default=False, title='Environment Variable Access')

Environment variable access.

allow_ffi class-attribute instance-attribute

allow_ffi: bool | list[str] = Field(default=False, title='FFI Access')

Foreign function interface access.

allow_net class-attribute instance-attribute

allow_net: bool | list[str] = Field(default=True, title='Network Access')

Network access (True=all, list=specific hosts, False=none).

allow_read class-attribute instance-attribute

allow_read: bool | list[str] = Field(default=False, title='File Read Access')

File read access.

allow_run class-attribute instance-attribute

allow_run: bool | list[str] = Field(default=False, title='Subprocess Execution')

Subprocess execution (limited in WASM).

allow_write class-attribute instance-attribute

allow_write: bool | list[str] = Field(default=False, title='File Write Access')

File write access.

deno_executable class-attribute instance-attribute

deno_executable: str | None = Field(
    default=None, title="Deno Executable", examples=["deno", "/usr/local/bin/deno"]
)

Path to deno executable (auto-detected if None).

sandbox_timeout class-attribute instance-attribute

sandbox_timeout: float = Field(
    default=300.0, gt=0.0, title="Sandbox Lifetime", examples=[300.0, 600.0, 3600.0]
)

How long the sandbox stays alive in seconds.

startup_timeout class-attribute instance-attribute

startup_timeout: float = Field(default=60.0, gt=0.0, title='Startup Timeout')

Timeout for Pyodide initialization in seconds.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> PyodideExecutionEnvironment

Create Pyodide execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> PyodideExecutionEnvironment:
    """Create Pyodide execution environment instance."""
    from exxec.pyodide_provider import PyodideExecutionEnvironment

    return PyodideExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        timeout=self.sandbox_timeout,
        default_command_timeout=self.default_command_timeout,
        startup_timeout=self.startup_timeout,
        allow_net=self.allow_net,
        allow_read=self.allow_read,
        allow_write=self.allow_write,
        allow_env=self.allow_env,
        allow_run=self.allow_run,
        allow_ffi=self.allow_ffi,
        deno_executable=self.deno_executable,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

SRTExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Sandboxed execution environment using Anthropic's sandbox-runtime.

Executes code locally with OS-level sandboxing for network and filesystem restrictions. Requires srt CLI: npm install -g @anthropic-ai/sandbox-runtime

dependencies are installed with pip install outside the sandbox (they come from this configuration, not from the sandboxed code).

Source code in src/exxec_config/configs.py
class SRTExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Sandboxed execution environment using Anthropic's sandbox-runtime.

    Executes code locally with OS-level sandboxing for network and filesystem restrictions.
    Requires `srt` CLI: `npm install -g @anthropic-ai/sandbox-runtime`

    `dependencies` are installed with `pip install` outside the sandbox (they come from
    this configuration, not from the sandboxed code).
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "SRT Execution Environment"})

    type: Literal["srt"] = Field("srt", init=False)

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    executable: str | None = Field(
        default=None,
        title="Executable",
        examples=["/usr/bin/python3", "python3.13"],
    )
    """Executable to use (auto-detect if None)."""

    sandbox: SandboxConfig = Field(default_factory=SandboxConfig)
    """Sandbox restrictions configuration."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> SRTExecutionEnvironment:
        """Create sandboxed execution environment instance."""
        from exxec.srt_provider import SRTExecutionEnvironment

        return SRTExecutionEnvironment(
            sandbox_config=self.sandbox,
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            default_command_timeout=self.default_command_timeout,
            executable=self.executable,
            language=self.language,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

executable class-attribute instance-attribute

executable: str | None = Field(
    default=None, title="Executable", examples=["/usr/bin/python3", "python3.13"]
)

Executable to use (auto-detect if None).

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

sandbox class-attribute instance-attribute

sandbox: SandboxConfig = Field(default_factory=SandboxConfig)

Sandbox restrictions configuration.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> SRTExecutionEnvironment

Create sandboxed execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> SRTExecutionEnvironment:
    """Create sandboxed execution environment instance."""
    from exxec.srt_provider import SRTExecutionEnvironment

    return SRTExecutionEnvironment(
        sandbox_config=self.sandbox,
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        default_command_timeout=self.default_command_timeout,
        executable=self.executable,
        language=self.language,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

SandboxConfig

Bases: BaseModel

Configuration for sandbox-runtime restrictions.

Source code in src/exxec_config/srt_sandbox_config.py
class SandboxConfig(BaseModel):
    """Configuration for sandbox-runtime restrictions."""

    # Network settings
    allowed_domains: list[str] = Field(
        default_factory=list,
        title="Allowed Domains",
        examples=[["github.com", "*.github.com", "pypi.org"]],
    )
    """Domains that can be accessed. Empty = no network access."""

    denied_domains: list[str] = Field(
        default_factory=list,
        title="Denied Domains",
        examples=[["malicious.com"]],
    )
    """Domains explicitly blocked (checked before allowed_domains)."""

    allow_unix_sockets: list[str] = Field(
        default_factory=list,
        title="Allowed Unix Sockets",
        examples=[["/var/run/docker.sock"]],
    )
    """Specific Unix socket paths to allow (e.g., Docker socket)."""

    allow_all_unix_sockets: bool = Field(default=False, title="Allow All Unix Sockets")
    """Allow all Unix sockets (less secure)."""

    allow_local_binding: bool = Field(default=False, title="Allow Local Binding")
    """Allow binding to localhost ports."""

    # Filesystem read settings (deny-only pattern)
    deny_read: list[str] = Field(
        default_factory=lambda: ["~/.ssh", "~/.aws", "~/.gnupg"],
        title="Deny Read Paths",
        examples=[["~/.ssh", "~/.aws"]],
    )
    """Paths blocked from reading. Empty = full read access."""

    # Filesystem write settings (allow-only pattern)
    allow_write: list[str] = Field(
        default_factory=lambda: ["."],
        title="Allow Write Paths",
        examples=[["."], [".", "/tmp"]],
    )
    """Paths where writes are permitted. Empty = no write access."""

    deny_write: list[str] = Field(
        default_factory=list,
        title="Deny Write Paths",
        examples=[[".env", "secrets/"]],
    )
    """Paths denied within allowed write paths."""

    def to_srt_settings(self) -> dict[str, dict[str, Any]]:
        """Convert to srt-settings.json format."""
        return {
            "network": {
                "allowedDomains": self.allowed_domains,
                "deniedDomains": self.denied_domains,
                "allowUnixSockets": self.allow_unix_sockets,
                "allowAllUnixSockets": self.allow_all_unix_sockets,
                "allowLocalBinding": self.allow_local_binding,
            },
            "filesystem": {
                "denyRead": self.deny_read,
                "allowWrite": self.allow_write,
                "denyWrite": self.deny_write,
            },
        }

allow_all_unix_sockets class-attribute instance-attribute

allow_all_unix_sockets: bool = Field(default=False, title='Allow All Unix Sockets')

Allow all Unix sockets (less secure).

allow_local_binding class-attribute instance-attribute

allow_local_binding: bool = Field(default=False, title='Allow Local Binding')

Allow binding to localhost ports.

allow_unix_sockets class-attribute instance-attribute

allow_unix_sockets: list[str] = Field(
    default_factory=list, title="Allowed Unix Sockets", examples=[["/var/run/docker.sock"]]
)

Specific Unix socket paths to allow (e.g., Docker socket).

allow_write class-attribute instance-attribute

allow_write: list[str] = Field(
    default_factory=lambda: ["."], title="Allow Write Paths", examples=[["."], [".", "/tmp"]]
)

Paths where writes are permitted. Empty = no write access.

allowed_domains class-attribute instance-attribute

allowed_domains: list[str] = Field(
    default_factory=list,
    title="Allowed Domains",
    examples=[["github.com", "*.github.com", "pypi.org"]],
)

Domains that can be accessed. Empty = no network access.

denied_domains class-attribute instance-attribute

denied_domains: list[str] = Field(
    default_factory=list, title="Denied Domains", examples=[["malicious.com"]]
)

Domains explicitly blocked (checked before allowed_domains).

deny_read class-attribute instance-attribute

deny_read: list[str] = Field(
    default_factory=lambda: ["~/.ssh", "~/.aws", "~/.gnupg"],
    title="Deny Read Paths",
    examples=[["~/.ssh", "~/.aws"]],
)

Paths blocked from reading. Empty = full read access.

deny_write class-attribute instance-attribute

deny_write: list[str] = Field(
    default_factory=list, title="Deny Write Paths", examples=[[".env", "secrets/"]]
)

Paths denied within allowed write paths.

to_srt_settings

to_srt_settings() -> dict[str, dict[str, Any]]

Convert to srt-settings.json format.

Source code in src/exxec_config/srt_sandbox_config.py
def to_srt_settings(self) -> dict[str, dict[str, Any]]:
    """Convert to srt-settings.json format."""
    return {
        "network": {
            "allowedDomains": self.allowed_domains,
            "deniedDomains": self.denied_domains,
            "allowUnixSockets": self.allow_unix_sockets,
            "allowAllUnixSockets": self.allow_all_unix_sockets,
            "allowLocalBinding": self.allow_local_binding,
        },
        "filesystem": {
            "denyRead": self.deny_read,
            "allowWrite": self.allow_write,
            "denyWrite": self.deny_write,
        },
    }

SpritesExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Sprites execution environment configuration.

Executes code in Sprites (Fly.io) cloud VMs for secure, ephemeral execution.

Source code in src/exxec_config/configs.py
class SpritesExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Sprites execution environment configuration.

    Executes code in Sprites (Fly.io) cloud VMs for secure, ephemeral execution.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Sprites Execution Environment"})
    type: Literal["sprites"] = Field("sprites", init=False)
    name: str | None = Field(
        default=None,
        title="Sprite Name",
    )
    """Sprite name (auto-generated if None)."""

    token: SecretStr | None = Field(
        default=None,
        title="Sprites API Token",
    )
    """Sprites API token (or use SPRITES_TOKEN env var)."""

    base_url: str = Field(
        default="https://api.sprites.dev",
        title="API Base URL",
    )
    """Sprites API base URL."""

    region: str | None = Field(
        default=None,
        title="Region",
    )
    """Preferred region for sprite creation."""

    ram_mb: int | None = Field(
        default=None,
        gt=0,
        title="RAM (MB)",
        examples=[256, 512, 1024],
    )
    """RAM in MB for the sprite."""

    cpus: int | None = Field(
        default=None,
        gt=0,
        title="CPUs",
        examples=[1, 2, 4],
    )
    """Number of CPUs for the sprite."""

    storage_gb: int | None = Field(
        default=None,
        gt=0,
        title="Storage (GB)",
        examples=[1, 5, 10],
    )
    """Storage in GB for the sprite."""

    timeout: float = Field(
        default=300.0,
        gt=0.0,
        title="Default Timeout",
        examples=[300.0, 600.0],
    )
    """Default command timeout in seconds."""

    keep_alive: bool = Field(default=False, title="Keep Alive")
    """Keep sprite running after exiting context manager."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> SpritesExecutionEnvironment:
        """Create Sprites execution environment instance."""
        from exxec.sprites_provider import SpritesExecutionEnvironment

        return SpritesExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            name=self.name,
            timeout=self.timeout,
            default_command_timeout=self.default_command_timeout,
            keep_alive=self.keep_alive,
            language=self.language,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
            token=self.token.get_secret_value() if self.token else None,
            base_url=self.base_url,
            ram_mb=self.ram_mb,
            cpus=self.cpus,
            region=self.region,
            storage_gb=self.storage_gb,
        )

base_url class-attribute instance-attribute

base_url: str = Field(default='https://api.sprites.dev', title='API Base URL')

Sprites API base URL.

cpus class-attribute instance-attribute

cpus: int | None = Field(default=None, gt=0, title='CPUs', examples=[1, 2, 4])

Number of CPUs for the sprite.

keep_alive class-attribute instance-attribute

keep_alive: bool = Field(default=False, title='Keep Alive')

Keep sprite running after exiting context manager.

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

name class-attribute instance-attribute

name: str | None = Field(default=None, title='Sprite Name')

Sprite name (auto-generated if None).

ram_mb class-attribute instance-attribute

ram_mb: int | None = Field(default=None, gt=0, title='RAM (MB)', examples=[256, 512, 1024])

RAM in MB for the sprite.

region class-attribute instance-attribute

region: str | None = Field(default=None, title='Region')

Preferred region for sprite creation.

storage_gb class-attribute instance-attribute

storage_gb: int | None = Field(default=None, gt=0, title='Storage (GB)', examples=[1, 5, 10])

Storage in GB for the sprite.

timeout class-attribute instance-attribute

timeout: float = Field(default=300.0, gt=0.0, title='Default Timeout', examples=[300.0, 600.0])

Default command timeout in seconds.

token class-attribute instance-attribute

token: SecretStr | None = Field(default=None, title='Sprites API Token')

Sprites API token (or use SPRITES_TOKEN env var).

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> SpritesExecutionEnvironment

Create Sprites execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> SpritesExecutionEnvironment:
    """Create Sprites execution environment instance."""
    from exxec.sprites_provider import SpritesExecutionEnvironment

    return SpritesExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        name=self.name,
        timeout=self.timeout,
        default_command_timeout=self.default_command_timeout,
        keep_alive=self.keep_alive,
        language=self.language,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
        token=self.token.get_secret_value() if self.token else None,
        base_url=self.base_url,
        ram_mb=self.ram_mb,
        cpus=self.cpus,
        region=self.region,
        storage_gb=self.storage_gb,
    )

SshExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

SSH execution environment configuration.

Executes code on a remote machine via SSH connection.

Source code in src/exxec_config/configs.py
class SshExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """SSH execution environment configuration.

    Executes code on a remote machine via SSH connection.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "SSH Execution Environment"})

    type: Literal["ssh"] = Field("ssh", init=False)

    host: str = Field(title="Host", examples=["192.168.1.100", "example.com"])
    """Remote host to connect to."""

    username: str = Field(title="Username", examples=["ubuntu", "root"])
    """SSH username."""

    password: SecretStr | None = Field(default=None, title="Password")
    """SSH password (if not using key auth)."""

    private_key_path: str | None = Field(
        default=None,
        title="Private Key Path",
        examples=["~/.ssh/id_rsa", "/path/to/key"],
    )
    """Path to SSH private key file."""

    port: int = Field(default=22, ge=1, le=65535, title="SSH Port")
    """SSH port."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    sandbox_timeout: float = Field(
        default=300.0,
        gt=0.0,
        title="Connection Timeout",
        examples=[300.0, 600.0, 3600.0],
    )
    """SSH connection timeout in seconds."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> SshExecutionEnvironment:
        """Create SSH execution environment instance."""
        from exxec.ssh_provider import SshExecutionEnvironment

        password_str = self.password.get_secret_value() if self.password else None
        return SshExecutionEnvironment(
            host=self.host,
            username=self.username,
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            password=password_str,
            private_key_path=self.private_key_path,
            port=self.port,
            timeout=self.sandbox_timeout,
            default_command_timeout=self.default_command_timeout,
            language=self.language,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

host class-attribute instance-attribute

host: str = Field(title='Host', examples=['192.168.1.100', 'example.com'])

Remote host to connect to.

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

password class-attribute instance-attribute

password: SecretStr | None = Field(default=None, title='Password')

SSH password (if not using key auth).

port class-attribute instance-attribute

port: int = Field(default=22, ge=1, le=65535, title='SSH Port')

SSH port.

private_key_path class-attribute instance-attribute

private_key_path: str | None = Field(
    default=None, title="Private Key Path", examples=["~/.ssh/id_rsa", "/path/to/key"]
)

Path to SSH private key file.

sandbox_timeout class-attribute instance-attribute

sandbox_timeout: float = Field(
    default=300.0, gt=0.0, title="Connection Timeout", examples=[300.0, 600.0, 3600.0]
)

SSH connection timeout in seconds.

username class-attribute instance-attribute

username: str = Field(title='Username', examples=['ubuntu', 'root'])

SSH username.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> SshExecutionEnvironment

Create SSH execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> SshExecutionEnvironment:
    """Create SSH execution environment instance."""
    from exxec.ssh_provider import SshExecutionEnvironment

    password_str = self.password.get_secret_value() if self.password else None
    return SshExecutionEnvironment(
        host=self.host,
        username=self.username,
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        password=password_str,
        private_key_path=self.private_key_path,
        port=self.port,
        timeout=self.sandbox_timeout,
        default_command_timeout=self.default_command_timeout,
        language=self.language,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

VercelExecutionEnvironmentConfig

Bases: BaseExecutionEnvironmentConfig

Vercel execution environment configuration.

Executes code in Vercel cloud sandboxes for serverless execution.

Source code in src/exxec_config/configs.py
class VercelExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Vercel execution environment configuration.

    Executes code in Vercel cloud sandboxes for serverless execution.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Vercel Execution Environment"})

    type: Literal["vercel"] = Field("vercel", init=False)

    image: str | None = Field(default=None, title="Image")
    """Vercel Container Registry image reference (uses Vercel default if None)."""

    vcpus: int | None = Field(default=None, title="vCPUs")
    """Number of virtual CPUs for the sandbox."""

    memory: int | None = Field(default=None, title="Memory")
    """Memory in MB for the sandbox."""

    ports: list[int] = Field(default=[3000], title="Ports")
    """List of ports to expose."""

    timeout: int = Field(default=60, title="Timeout")
    """Timeout for the sandbox."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    token: SecretStr | None = Field(default=None, title="API Token")
    """Vercel API token (uses environment if None)."""

    project_id: str | None = Field(default=None, title="Project ID")
    """Vercel project ID (uses environment if None)."""

    team_id: str | None = Field(default=None, title="Team ID")
    """Vercel team ID (uses environment if None)."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> VercelExecutionEnvironment:
        """Create Vercel execution environment instance."""
        from vercel.sandbox import SandboxResources

        from exxec.vercel_provider import VercelExecutionEnvironment

        token_str = self.token.get_secret_value() if self.token else None
        return VercelExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            image=self.image,
            default_command_timeout=self.default_command_timeout,
            timeout=self.timeout,
            resources=SandboxResources(vcpus=self.vcpus, memory=self.memory)
            if self.vcpus is not None or self.memory is not None
            else None,
            ports=self.ports,
            language=self.language,
            token=token_str,
            project_id=self.project_id,
            team_id=self.team_id,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

image class-attribute instance-attribute

image: str | None = Field(default=None, title='Image')

Vercel Container Registry image reference (uses Vercel default if None).

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

memory class-attribute instance-attribute

memory: int | None = Field(default=None, title='Memory')

Memory in MB for the sandbox.

ports class-attribute instance-attribute

ports: list[int] = Field(default=[3000], title='Ports')

List of ports to expose.

project_id class-attribute instance-attribute

project_id: str | None = Field(default=None, title='Project ID')

Vercel project ID (uses environment if None).

team_id class-attribute instance-attribute

team_id: str | None = Field(default=None, title='Team ID')

Vercel team ID (uses environment if None).

timeout class-attribute instance-attribute

timeout: int = Field(default=60, title='Timeout')

Timeout for the sandbox.

token class-attribute instance-attribute

token: SecretStr | None = Field(default=None, title='API Token')

Vercel API token (uses environment if None).

vcpus class-attribute instance-attribute

vcpus: int | None = Field(default=None, title='vCPUs')

Number of virtual CPUs for the sandbox.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> VercelExecutionEnvironment

Create Vercel execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> VercelExecutionEnvironment:
    """Create Vercel execution environment instance."""
    from vercel.sandbox import SandboxResources

    from exxec.vercel_provider import VercelExecutionEnvironment

    token_str = self.token.get_secret_value() if self.token else None
    return VercelExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        image=self.image,
        default_command_timeout=self.default_command_timeout,
        timeout=self.timeout,
        resources=SandboxResources(vcpus=self.vcpus, memory=self.memory)
        if self.vcpus is not None or self.memory is not None
        else None,
        ports=self.ports,
        language=self.language,
        token=token_str,
        project_id=self.project_id,
        team_id=self.team_id,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )