From 7c6d387ed32f33c463bfba00e29733e78a8433e9 Mon Sep 17 00:00:00 2001 From: Ali Muhammad Date: Fri, 24 Jul 2026 07:00:14 +0500 Subject: [PATCH 1/8] refactor(sandbox): generalize secret reference prefixes --- src/anycode/sandbox/_secrets.py | 25 +++++++++++++++++++++++++ src/anycode/sandbox/daytona.py | 6 +++++- src/anycode/sandbox/models.py | 9 +++++++-- tests/test_sandbox.py | 16 +++++++++++++++- 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 src/anycode/sandbox/_secrets.py diff --git a/src/anycode/sandbox/_secrets.py b/src/anycode/sandbox/_secrets.py new file mode 100644 index 0000000..e574eee --- /dev/null +++ b/src/anycode/sandbox/_secrets.py @@ -0,0 +1,25 @@ +"""Shared helpers for provider-prefixed sandbox secret references.""" + +from __future__ import annotations + +from anycode.contracts.models import ContractError +from anycode.sandbox.models import SandboxSpec + + +def strip_secret_prefix(provider: str, reference: str) -> str: + """Return the secret name behind ``:``, rejecting foreign prefixes.""" + prefix = f"{provider}:" + if not reference.startswith(prefix): + raise ValueError(f"Secret reference {reference!r} is not scoped to provider {provider!r}; expected the {prefix!r} prefix") + return reference.removeprefix(prefix) + + +def validate_secret_references(provider: str, spec: SandboxSpec) -> ContractError | None: + """Reject references scoped to another provider before any sandbox is created.""" + for name, reference in spec.secret_references.items(): + if not reference.startswith(f"{provider}:"): + return ContractError( + code="sandbox_secret_reference_invalid", + message=f"Secret reference for {name!r} must use the '{provider}:' prefix", + ) + return None diff --git a/src/anycode/sandbox/daytona.py b/src/anycode/sandbox/daytona.py index 0d35301..e58f76f 100644 --- a/src/anycode/sandbox/daytona.py +++ b/src/anycode/sandbox/daytona.py @@ -8,6 +8,7 @@ from anycode.contracts.models import ContractError from anycode.helpers.uuid7 import uuid7 +from anycode.sandbox._secrets import strip_secret_prefix, validate_secret_references from anycode.sandbox.models import ( SandboxActionResult, SandboxCapabilities, @@ -59,7 +60,7 @@ def _creation_params(self, spec: SandboxSpec) -> Any | None: }, "public": False, "ephemeral": not spec.persistent, - "secrets": {name: reference.removeprefix("daytona:") for name, reference in spec.secret_references.items()}, + "secrets": {name: strip_secret_prefix("daytona", reference) for name, reference in spec.secret_references.items()}, "network_block_all": spec.network == "none", "network_allow_list": ",".join(spec.allowed_cidrs) or None, "domain_allow_list": ",".join(spec.allowed_domains) or None, @@ -78,6 +79,9 @@ async def _resolve(self, handle: SandboxHandle) -> Any: return sandbox async def create(self, spec: SandboxSpec) -> SandboxCreateResult: + secret_error = validate_secret_references("daytona", spec) + if secret_error is not None: + return SandboxCreateResult(ok=False, error=secret_error) try: client = self._client_or_raise() params = self._creation_params(spec) diff --git a/src/anycode/sandbox/models.py b/src/anycode/sandbox/models.py index 13a207e..10da621 100644 --- a/src/anycode/sandbox/models.py +++ b/src/anycode/sandbox/models.py @@ -3,6 +3,7 @@ from __future__ import annotations import hashlib +import re from datetime import datetime from typing import Literal @@ -13,6 +14,10 @@ SANDBOX_CONTRACT_VERSION = "1.0" +# Secret values are provider-prefixed references like "daytona:token-name"; +# each provider accepts only its own prefix at create time. +_SECRET_REFERENCE_PATTERN = re.compile(r"^[a-z][a-z0-9_-]*:\S+$") + class SandboxCapabilities(ContractModel): provider: str = Field(min_length=1) @@ -51,8 +56,8 @@ def _validate_spec(self) -> SandboxSpec: raise ValueError("Network allowlists require network='allowlist'") if self.network == "allowlist" and not (self.allowed_domains or self.allowed_cidrs): raise ValueError("network='allowlist' requires a domain or CIDR") - if any(not reference.startswith("daytona:") for reference in self.secret_references.values()): - raise ValueError("Sandbox secrets must be Daytona secret references, never plaintext values") + if any(not _SECRET_REFERENCE_PATTERN.fullmatch(reference) for reference in self.secret_references.values()): + raise ValueError("Sandbox secrets must be provider-prefixed secret references (e.g. 'daytona:token-name'), never plaintext values") return self diff --git a/tests/test_sandbox.py b/tests/test_sandbox.py index b918a18..f9843a8 100644 --- a/tests/test_sandbox.py +++ b/tests/test_sandbox.py @@ -139,6 +139,21 @@ def test_sandbox_spec_rejects_network_and_plaintext_secret_misconfiguration() -> SandboxCommand(command="run", environment={"API_TOKEN": "plaintext"}) +def test_sandbox_spec_accepts_any_provider_prefixed_secret_reference() -> None: + spec = SandboxSpec(run_id="run", correlation_id="corr", context=_context(), secret_references={"API_KEY": "e2b:api-key"}) + assert spec.secret_references == {"API_KEY": "e2b:api-key"} + + +async def test_daytona_create_rejects_foreign_secret_prefix() -> None: + provider = DaytonaSandboxProvider(FakeDaytonaClient(), session_request_factory=lambda **kwargs: SimpleNamespace(**kwargs)) + spec = SandboxSpec(run_id="run", correlation_id="corr", context=_context(), secret_references={"API_KEY": "modal:api-key"}) + + created = await provider.create(spec) + + assert not created.ok and created.error is not None + assert created.error.code == "sandbox_secret_reference_invalid" + + class DenySandboxPolicy: async def decide(self, request: PolicyRequest) -> PolicyDecision: return PolicyDecision( @@ -166,4 +181,3 @@ async def test_policy_wrapper_denies_before_sandbox_creation_and_audits_context( assert not client.sandbox.deleted and not client.sandbox.stopped assert len(audit.events) == 1 and audit.events[0].boundary == "sandbox" assert audit.events[0].context["tenant_scope"] == "tenant-a" - From 6398b672356312055197da4a799ca83cffa91c9e Mon Sep 17 00:00:00 2001 From: Ali Muhammad Date: Fri, 24 Jul 2026 07:01:50 +0500 Subject: [PATCH 2/8] feat(sandbox): add create_sandbox_provider factory --- src/anycode/__init__.py | 2 ++ src/anycode/sandbox/__init__.py | 3 +++ src/anycode/sandbox/factory.py | 28 ++++++++++++++++++++++++++++ tests/test_sandbox_providers.py | 25 +++++++++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 src/anycode/sandbox/factory.py create mode 100644 tests/test_sandbox_providers.py diff --git a/src/anycode/__init__.py b/src/anycode/__init__.py index 927ba17..47c8b04 100644 --- a/src/anycode/__init__.py +++ b/src/anycode/__init__.py @@ -197,6 +197,7 @@ SandboxCommand, SandboxProvider, SandboxSpec, + create_sandbox_provider, ) from anycode.schedule.scheduler import RunScheduler, SweepReport, sweep_once from anycode.schedule.tasks import ScheduledTask, ScheduledTaskResult, run_scheduled_task @@ -611,6 +612,7 @@ "SandboxCommand", "SandboxProvider", "SandboxSpec", + "create_sandbox_provider", # Managed hosting "A2A_AGENT_CARD_PATH", "A2AAgentCard", diff --git a/src/anycode/sandbox/__init__.py b/src/anycode/sandbox/__init__.py index 5f1aa44..80b1bd1 100644 --- a/src/anycode/sandbox/__init__.py +++ b/src/anycode/sandbox/__init__.py @@ -2,6 +2,7 @@ from anycode.sandbox.companion import CompanionSandboxAdapter, CompanionSandboxClient from anycode.sandbox.daytona import DaytonaSandboxProvider +from anycode.sandbox.factory import SANDBOX_PROVIDER_EXTRAS, create_sandbox_provider from anycode.sandbox.models import ( SANDBOX_CONTRACT_VERSION, SandboxActionResult, @@ -21,6 +22,7 @@ __all__ = [ "SANDBOX_CONTRACT_VERSION", + "SANDBOX_PROVIDER_EXTRAS", "CompanionSandboxAdapter", "CompanionSandboxClient", "DaytonaSandboxProvider", @@ -37,4 +39,5 @@ "SandboxOutputChunk", "SandboxProvider", "SandboxSpec", + "create_sandbox_provider", ] diff --git a/src/anycode/sandbox/factory.py b/src/anycode/sandbox/factory.py new file mode 100644 index 0000000..82c08cb --- /dev/null +++ b/src/anycode/sandbox/factory.py @@ -0,0 +1,28 @@ +"""Factory for constructing sandbox providers by name.""" + +from __future__ import annotations + +from typing import Any + +from anycode.sandbox.protocol import SandboxProvider + +# Provider name -> install extra carrying its SDK. SDKs load lazily on first +# use, so construction never imports them. +SANDBOX_PROVIDER_EXTRAS: dict[str, str] = { + "daytona": "sandbox", +} + + +def create_sandbox_provider(name: str, **kwargs: Any) -> SandboxProvider: + """Build a sandbox provider by name. + + Construction is cheap and offline; the provider's SDK is imported on first + use and a missing SDK surfaces the matching ``pip install "anycode-py[...]"`` + guidance. + """ + if name == "daytona": + from anycode.sandbox.daytona import DaytonaSandboxProvider + + return DaytonaSandboxProvider(**kwargs) + + raise ValueError(f"Unknown sandbox provider: {name!r}. Available: {sorted(SANDBOX_PROVIDER_EXTRAS)}") diff --git a/tests/test_sandbox_providers.py b/tests/test_sandbox_providers.py new file mode 100644 index 0000000..4d74992 --- /dev/null +++ b/tests/test_sandbox_providers.py @@ -0,0 +1,25 @@ +"""Factory and conformance tests for the expanded sandbox provider catalog.""" + +from __future__ import annotations + +import pytest + +from anycode.sandbox import SANDBOX_PROVIDER_EXTRAS, DaytonaSandboxProvider, create_sandbox_provider + + +def test_factory_builds_daytona_provider() -> None: + provider = create_sandbox_provider("daytona") + assert isinstance(provider, DaytonaSandboxProvider) + assert provider.capabilities().provider == "daytona" + + +def test_factory_rejects_unknown_provider() -> None: + with pytest.raises(ValueError, match="Unknown sandbox provider: 'firecracker'"): + create_sandbox_provider("firecracker") + + +def test_every_factory_provider_declares_an_extra() -> None: + for name, extra in SANDBOX_PROVIDER_EXTRAS.items(): + provider = create_sandbox_provider(name) + assert provider.capabilities().provider == name + assert extra.startswith("sandbox") From 9ba597b77ad1b5b50f65cb73bb2d8aa40196f58d Mon Sep 17 00:00:00 2001 From: Ali Muhammad Date: Fri, 24 Jul 2026 07:07:26 +0500 Subject: [PATCH 3/8] feat(sandbox): add e2b sandbox provider --- .github/workflows/ci.yml | 3 + pyproject.toml | 3 + src/anycode/__init__.py | 2 + src/anycode/sandbox/__init__.py | 2 + src/anycode/sandbox/_base.py | 110 +++++++++++++++++++ src/anycode/sandbox/e2b.py | 182 ++++++++++++++++++++++++++++++++ src/anycode/sandbox/factory.py | 5 + tests/test_sandbox_providers.py | 146 ++++++++++++++++++++++++- uv.lock | 89 +++++++++++++++- 9 files changed, 540 insertions(+), 2 deletions(-) create mode 100644 src/anycode/sandbox/_base.py create mode 100644 src/anycode/sandbox/e2b.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8886e53..cd451d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -151,6 +151,9 @@ jobs: - extra: sandbox sync-args: --extra sandbox imports: daytona anycode.sandbox.daytona + - extra: sandbox-e2b + sync-args: --extra sandbox-e2b + imports: e2b anycode.sandbox.e2b - extra: all sync-args: --extra all imports: anycode diff --git a/pyproject.toml b/pyproject.toml index e1cfccb..9495392 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -99,6 +99,9 @@ cli = [ sandbox = [ "daytona>=0.197,<1", ] +sandbox-e2b = [ + "e2b>=1.0", +] all = [ "anthropic>=0.40", "openai>=1.50", diff --git a/src/anycode/__init__.py b/src/anycode/__init__.py index 47c8b04..2d275a2 100644 --- a/src/anycode/__init__.py +++ b/src/anycode/__init__.py @@ -192,6 +192,7 @@ from anycode.sandbox import ( CompanionSandboxAdapter, DaytonaSandboxProvider, + E2BSandboxProvider, PolicySandboxProvider, SandboxCapabilities, SandboxCommand, @@ -607,6 +608,7 @@ # Sandboxes "CompanionSandboxAdapter", "DaytonaSandboxProvider", + "E2BSandboxProvider", "PolicySandboxProvider", "SandboxCapabilities", "SandboxCommand", diff --git a/src/anycode/sandbox/__init__.py b/src/anycode/sandbox/__init__.py index 80b1bd1..d495bd0 100644 --- a/src/anycode/sandbox/__init__.py +++ b/src/anycode/sandbox/__init__.py @@ -2,6 +2,7 @@ from anycode.sandbox.companion import CompanionSandboxAdapter, CompanionSandboxClient from anycode.sandbox.daytona import DaytonaSandboxProvider +from anycode.sandbox.e2b import E2BSandboxProvider from anycode.sandbox.factory import SANDBOX_PROVIDER_EXTRAS, create_sandbox_provider from anycode.sandbox.models import ( SANDBOX_CONTRACT_VERSION, @@ -26,6 +27,7 @@ "CompanionSandboxAdapter", "CompanionSandboxClient", "DaytonaSandboxProvider", + "E2BSandboxProvider", "PolicySandboxProvider", "SandboxActionResult", "SandboxCapabilities", diff --git a/src/anycode/sandbox/_base.py b/src/anycode/sandbox/_base.py new file mode 100644 index 0000000..3d693c5 --- /dev/null +++ b/src/anycode/sandbox/_base.py @@ -0,0 +1,110 @@ +"""Shared scaffolding for remote sandbox provider adapters.""" + +from __future__ import annotations + +import inspect +import shlex +from collections.abc import AsyncIterable, AsyncIterator, Awaitable, Callable +from typing import Any + +from anycode.contracts.models import ContractError +from anycode.sandbox.models import SandboxCommand, SandboxCommandResult, SandboxOutputChunk, SandboxSpec + + +async def call_maybe_async(fn: Any, *args: Any, **kwargs: Any) -> Any: + """Invoke an SDK callable that may be sync, async, or expose an ``.aio`` twin.""" + aio = getattr(fn, "aio", None) + target = aio if callable(aio) else fn + result = target(*args, **kwargs) + if inspect.isawaitable(result): + return await result + return result + + +async def read_streamish(value: Any) -> str: + """Normalize SDK output shapes (str, bytes, callable, or object with read()).""" + if callable(value): + value = await call_maybe_async(value) + reader = getattr(value, "read", None) + if callable(reader): + value = await call_maybe_async(reader) + if value is None: + return "" + if isinstance(value, bytes | bytearray): + return bytes(value).decode("utf-8", errors="replace") + return str(value) + + +def to_bytes(value: Any) -> bytes: + if value is None: + return b"" + if isinstance(value, bytes | bytearray): + return bytes(value) + return str(value).encode("utf-8") + + +def network_policy_error(provider: str, spec: SandboxSpec, *, supported: tuple[str, ...]) -> ContractError | None: + """Fail closed when a backend cannot enforce the requested network mode.""" + if spec.network in supported: + return None + return ContractError( + code="sandbox_network_policy_unsupported", + message=f"{provider} cannot enforce network='{spec.network}'; supported modes: {', '.join(supported)}", + ) + + +def secrets_unsupported_error(provider: str, spec: SandboxSpec) -> ContractError | None: + if not spec.secret_references: + return None + return ContractError( + code="sandbox_secrets_unsupported", + message=f"{provider} has no managed secret store; configure credentials on the provider side instead", + ) + + +def snapshot_restore_unsupported_error(provider: str, spec: SandboxSpec) -> ContractError | None: + if not spec.snapshot: + return None + return ContractError( + code="sandbox_snapshot_unsupported", + message=f"{provider} cannot create a sandbox from a snapshot reference", + ) + + +def first_guard_error(*guards: ContractError | None) -> ContractError | None: + for guard in guards: + if guard is not None: + return guard + return None + + +def shell_command(command: SandboxCommand) -> str: + """Fold cwd and environment into one POSIX shell string for id-based exec APIs.""" + parts: list[str] = [] + for key, value in command.environment.items(): + parts.append(f"export {key}={shlex.quote(value)}") + if command.cwd: + parts.append(f"cd {shlex.quote(command.cwd)}") + parts.append(command.command) + return " && ".join(parts) + + +def buffered_stream( + execute: Callable[..., Awaitable[SandboxCommandResult]], + handle: Any, + command: SandboxCommand, +) -> AsyncIterable[SandboxOutputChunk]: + """Satisfy the streaming contract from a buffered execute() implementation.""" + + async def generate() -> AsyncIterator[SandboxOutputChunk]: + result = await execute(handle, command) + if not result.ok and result.error is not None: + yield SandboxOutputChunk(stream="error", data=result.error.message, sequence=1) + return + sequence = 0 + for stream_name, data in (("stdout", result.stdout), ("stderr", result.stderr)): + if data: + sequence += 1 + yield SandboxOutputChunk(stream=stream_name, data=data, sequence=sequence) # type: ignore[arg-type] + + return generate() diff --git a/src/anycode/sandbox/e2b.py b/src/anycode/sandbox/e2b.py new file mode 100644 index 0000000..e79e5a0 --- /dev/null +++ b/src/anycode/sandbox/e2b.py @@ -0,0 +1,182 @@ +"""E2B sandbox provider adapter.""" + +from __future__ import annotations + +from collections.abc import AsyncIterable +from typing import Any + +from anycode.contracts.models import ContractError +from anycode.sandbox._base import ( + buffered_stream, + call_maybe_async, + first_guard_error, + network_policy_error, + secrets_unsupported_error, + shell_command, + snapshot_restore_unsupported_error, + to_bytes, +) +from anycode.sandbox.models import ( + SandboxActionResult, + SandboxCapabilities, + SandboxCommand, + SandboxCommandResult, + SandboxCreateResult, + SandboxEvidence, + SandboxFileResult, + SandboxHandle, + SandboxHealth, + SandboxOutputChunk, + SandboxSpec, +) +from anycode.security.redaction import safe_exception_message + + +class E2BSandboxProvider: + """E2B microVM sandboxes; ``E2B_API_KEY`` stays in SDK configuration.""" + + def __init__(self, client: Any | None = None) -> None: + self._client = client + self._sandboxes: dict[str, Any] = {} + + def _client_or_raise(self) -> Any: + if self._client is not None: + return self._client + try: + from e2b import AsyncSandbox # type: ignore[import-not-found] + except ImportError as error: + message = 'E2BSandboxProvider requires the optional "e2b" package. Install it with: pip install "anycode-py[sandbox-e2b]"' + raise ImportError(message) from error + self._client = AsyncSandbox + return self._client + + async def _resolve(self, handle: SandboxHandle) -> Any: + sandbox = self._sandboxes.get(handle.id) + if sandbox is not None: + return sandbox + sandbox = await call_maybe_async(self._client_or_raise().connect, handle.id) + self._sandboxes[handle.id] = sandbox + return sandbox + + async def create(self, spec: SandboxSpec) -> SandboxCreateResult: + guard = first_guard_error( + network_policy_error("e2b", spec, supported=("unrestricted",)), + secrets_unsupported_error("e2b", spec), + snapshot_restore_unsupported_error("e2b", spec), + ) + if guard is not None: + return SandboxCreateResult(ok=False, error=guard) + try: + sandbox_cls = self._client_or_raise() + kwargs: dict[str, Any] = { + "metadata": { + **spec.labels, + "anycode.run_id": spec.run_id, + "anycode.tenant": spec.context.tenant_scope, + "anycode.classification": spec.context.classification, + } + } + if spec.image: + kwargs["template"] = spec.image + sandbox = await call_maybe_async(sandbox_cls.create, **kwargs) + sandbox_id = str(getattr(sandbox, "sandbox_id", None) or getattr(sandbox, "id", "")) + self._sandboxes[sandbox_id] = sandbox + handle = SandboxHandle( + id=sandbox_id, + provider="e2b", + run_id=spec.run_id, + task_id=spec.task_id, + correlation_id=spec.correlation_id, + context=spec.context, + capabilities=self.capabilities(), + ) + return SandboxCreateResult(ok=True, handle=handle) + except Exception as error: + return SandboxCreateResult( + ok=False, + error=ContractError(code="sandbox_create_failed", message=safe_exception_message(error), retryable=True), + ) + + async def execute(self, handle: SandboxHandle, command: SandboxCommand) -> SandboxCommandResult: + try: + sandbox = await self._resolve(handle) + result = await call_maybe_async(sandbox.commands.run, shell_command(command), timeout=command.timeout_seconds) + stdout = str(getattr(result, "stdout", "") or "") + stderr = str(getattr(result, "stderr", "") or "") + exit_code = int(getattr(result, "exit_code", 0) or 0) + evidence = SandboxEvidence.from_bytes("command", f"{stdout}\0{stderr}".encode(), metadata={"exit_code": exit_code}) + return SandboxCommandResult(ok=exit_code == 0, exit_code=exit_code, stdout=stdout, stderr=stderr, evidence=evidence) + except Exception as error: + return SandboxCommandResult( + ok=False, + error=ContractError(code="sandbox_command_failed", message=safe_exception_message(error), retryable=True), + ) + + def stream(self, handle: SandboxHandle, command: SandboxCommand) -> AsyncIterable[SandboxOutputChunk]: + return buffered_stream(self.execute, handle, command) + + async def write_file(self, handle: SandboxHandle, path: str, data: bytes) -> SandboxFileResult: + try: + sandbox = await self._resolve(handle) + await call_maybe_async(sandbox.files.write, path, data) + return SandboxFileResult(ok=True, evidence=SandboxEvidence.from_bytes("file.write", data, metadata={"path": path})) + except Exception as error: + return SandboxFileResult(ok=False, error=ContractError(code="sandbox_file_write_failed", message=safe_exception_message(error))) + + async def read_file(self, handle: SandboxHandle, path: str) -> SandboxFileResult: + try: + sandbox = await self._resolve(handle) + data = to_bytes(await call_maybe_async(sandbox.files.read, path)) + return SandboxFileResult(ok=True, data=data, evidence=SandboxEvidence.from_bytes("file.read", data, metadata={"path": path})) + except Exception as error: + return SandboxFileResult(ok=False, error=ContractError(code="sandbox_file_read_failed", message=safe_exception_message(error))) + + async def cancel(self, handle: SandboxHandle) -> SandboxActionResult: + try: + sandbox = await self._resolve(handle) + await call_maybe_async(sandbox.kill) + return SandboxActionResult(ok=True, evidence=SandboxEvidence.from_bytes("sandbox.cancel", handle.id.encode())) + except Exception as error: + return SandboxActionResult(ok=False, error=ContractError(code="sandbox_cancel_failed", message=safe_exception_message(error))) + + async def snapshot(self, handle: SandboxHandle, name: str) -> SandboxActionResult: + del handle, name + return SandboxActionResult( + ok=False, + error=ContractError(code="sandbox_snapshot_unsupported", message="E2B does not expose point-in-time sandbox snapshots."), + ) + + async def destroy(self, handle: SandboxHandle) -> SandboxActionResult: + try: + sandbox = await self._resolve(handle) + await call_maybe_async(sandbox.kill) + self._sandboxes.pop(handle.id, None) + return SandboxActionResult(ok=True, evidence=SandboxEvidence.from_bytes("sandbox.destroy", handle.id.encode())) + except Exception as error: + return SandboxActionResult(ok=False, error=ContractError(code="sandbox_destroy_failed", message=safe_exception_message(error))) + + async def health(self) -> SandboxHealth: + try: + self._client_or_raise() + except Exception as error: + return SandboxHealth(status="unavailable", message=safe_exception_message(error)) + return SandboxHealth(status="healthy") + + def capabilities(self) -> SandboxCapabilities: + return SandboxCapabilities( + provider="e2b", + isolation="microvm", + networking="unrestricted", + persistent_filesystem=True, + snapshots=False, + command_streaming=False, + cancellation=True, + file_transfer=True, + evidence=True, + limitations=( + "Network egress cannot be restricted through the stable adapter; network='none' and allowlists fail closed.", + "No managed secret store; sandbox secret references are rejected.", + "Command streaming is buffered: output arrives after the command completes.", + "Cancellation kills the whole sandbox rather than only one command.", + ), + ) diff --git a/src/anycode/sandbox/factory.py b/src/anycode/sandbox/factory.py index 82c08cb..d35ab89 100644 --- a/src/anycode/sandbox/factory.py +++ b/src/anycode/sandbox/factory.py @@ -10,6 +10,7 @@ # use, so construction never imports them. SANDBOX_PROVIDER_EXTRAS: dict[str, str] = { "daytona": "sandbox", + "e2b": "sandbox-e2b", } @@ -24,5 +25,9 @@ def create_sandbox_provider(name: str, **kwargs: Any) -> SandboxProvider: from anycode.sandbox.daytona import DaytonaSandboxProvider return DaytonaSandboxProvider(**kwargs) + if name == "e2b": + from anycode.sandbox.e2b import E2BSandboxProvider + + return E2BSandboxProvider(**kwargs) raise ValueError(f"Unknown sandbox provider: {name!r}. Available: {sorted(SANDBOX_PROVIDER_EXTRAS)}") diff --git a/tests/test_sandbox_providers.py b/tests/test_sandbox_providers.py index 4d74992..87eaa7b 100644 --- a/tests/test_sandbox_providers.py +++ b/tests/test_sandbox_providers.py @@ -2,9 +2,153 @@ from __future__ import annotations +import sys +from types import SimpleNamespace + import pytest -from anycode.sandbox import SANDBOX_PROVIDER_EXTRAS, DaytonaSandboxProvider, create_sandbox_provider +from anycode.identity.context import ExecutionContext +from anycode.sandbox import ( + SANDBOX_PROVIDER_EXTRAS, + DaytonaSandboxProvider, + E2BSandboxProvider, + SandboxCommand, + SandboxProvider, + SandboxSpec, + create_sandbox_provider, +) + + +def _context() -> ExecutionContext: + return ExecutionContext(principal="user:1", tenant_scope="tenant-a", classification="confidential", allowed_regions=("eu",)) + + +def _spec(**overrides: object) -> SandboxSpec: + defaults: dict = { + "run_id": "run-1", + "task_id": "task-1", + "correlation_id": "corr-1", + "context": _context(), + "network": "unrestricted", + } + defaults.update(overrides) + return SandboxSpec(**defaults) + + +async def _assert_lifecycle_conformance(provider: SandboxProvider, *, snapshots: bool) -> None: + """Shared create -> execute -> stream -> file roundtrip -> cancel -> snapshot -> destroy contract.""" + assert isinstance(provider, SandboxProvider) + created = await provider.create(_spec()) + assert created.ok and created.handle is not None + handle = created.handle + + command = await provider.execute(handle, SandboxCommand(command="echo hello")) + assert command.ok and command.exit_code == 0 and command.evidence is not None + assert command.evidence.digest.startswith("sha256:") + + chunks = [chunk async for chunk in provider.stream(handle, SandboxCommand(command="echo hello"))] + assert chunks and [chunk.sequence for chunk in chunks] == list(range(1, len(chunks) + 1)) + assert all(chunk.stream in ("stdout", "stderr") for chunk in chunks) + + written = await provider.write_file(handle, "/workspace/file.txt", b"payload") + read = await provider.read_file(handle, "/workspace/file.txt") + assert written.ok and written.evidence is not None + assert read.ok and read.data == b"payload" + + canceled = await provider.cancel(handle) + assert canceled.ok + + snapshot = await provider.snapshot(handle, "point-in-time") + if snapshots: + assert snapshot.ok and snapshot.reference + else: + assert not snapshot.ok and snapshot.error is not None and snapshot.error.code == "sandbox_snapshot_unsupported" + + destroyed = await provider.destroy(handle) + assert destroyed.ok + assert (await provider.health()).status == "healthy" + + +# --------------------------------------------------------------------------- +# E2B fakes +# --------------------------------------------------------------------------- + + +class FakeE2BCommands: + async def run(self, command: str, timeout: object = None) -> SimpleNamespace: + del timeout + return SimpleNamespace(stdout=f"ran:{command}", stderr="", exit_code=0) + + +class FakeE2BFiles: + def __init__(self) -> None: + self.files: dict[str, bytes] = {} + + async def write(self, path: str, data: bytes) -> None: + self.files[path] = data + + async def read(self, path: str) -> bytes: + return self.files[path] + + +class FakeE2BSandbox: + def __init__(self) -> None: + self.sandbox_id = "e2b-1" + self.commands = FakeE2BCommands() + self.files = FakeE2BFiles() + self.killed = False + + async def kill(self) -> None: + self.killed = True + + +class FakeE2BSandboxClass: + """Stands in for the e2b.AsyncSandbox class surface.""" + + def __init__(self) -> None: + self.sandbox = FakeE2BSandbox() + + async def create(self, **kwargs: object) -> FakeE2BSandbox: + del kwargs + return self.sandbox + + async def connect(self, sandbox_id: str) -> FakeE2BSandbox: + assert sandbox_id == self.sandbox.sandbox_id + return self.sandbox + + +async def test_e2b_provider_passes_lifecycle_conformance() -> None: + provider = E2BSandboxProvider(FakeE2BSandboxClass()) + await _assert_lifecycle_conformance(provider, snapshots=False) + + +async def test_e2b_rejects_restricted_network_and_secrets() -> None: + provider = E2BSandboxProvider(FakeE2BSandboxClass()) + + denied_network = await provider.create(_spec(network="none")) + assert not denied_network.ok and denied_network.error is not None + assert denied_network.error.code == "sandbox_network_policy_unsupported" + + denied_secrets = await provider.create(_spec(secret_references={"API_KEY": "e2b:key"})) + assert not denied_secrets.ok and denied_secrets.error is not None + assert denied_secrets.error.code == "sandbox_secrets_unsupported" + + +async def test_e2b_reports_missing_sdk_guidance(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setitem(sys.modules, "e2b", None) + provider = E2BSandboxProvider() + + created = await provider.create(_spec()) + + assert not created.ok and created.error is not None + assert "anycode-py[sandbox-e2b]" in created.error.message + assert (await provider.health()).status == "unavailable" + + +def test_e2b_capabilities_are_honest() -> None: + caps = E2BSandboxProvider(FakeE2BSandboxClass()).capabilities() + assert caps.provider == "e2b" and caps.isolation == "microvm" + assert not caps.snapshots and not caps.command_streaming def test_factory_builds_daytona_provider() -> None: diff --git a/uv.lock b/uv.lock index 44f2b35..8c2ec77 100644 --- a/uv.lock +++ b/uv.lock @@ -267,6 +267,9 @@ redis = [ sandbox = [ { name = "daytona" }, ] +sandbox-e2b = [ + { name = "e2b" }, +] telemetry = [ { name = "opentelemetry-api" }, { name = "opentelemetry-exporter-otlp-proto-grpc" }, @@ -320,6 +323,7 @@ requires-dist = [ { name = "chromadb", marker = "extra == 'vector'", specifier = ">=0.5" }, { name = "daytona", marker = "extra == 'all'", specifier = ">=0.197,<1" }, { name = "daytona", marker = "extra == 'sandbox'", specifier = ">=0.197,<1" }, + { name = "e2b", marker = "extra == 'sandbox-e2b'", specifier = ">=1.0" }, { name = "google-genai", marker = "extra == 'all'", specifier = ">=1.0" }, { name = "google-genai", marker = "extra == 'google'", specifier = ">=1.0" }, { name = "google-genai", marker = "extra == 'providers'", specifier = ">=1.0" }, @@ -351,7 +355,7 @@ requires-dist = [ { name = "typer", marker = "extra == 'all'", specifier = ">=0.12" }, { name = "typer", marker = "extra == 'cli'", specifier = ">=0.12" }, ] -provides-extras = ["anthropic", "openai", "telemetry", "persistence", "redis", "tokens", "vector", "google", "ollama", "bedrock", "azure", "providers", "mcp", "cli", "sandbox", "all"] +provides-extras = ["anthropic", "openai", "telemetry", "persistence", "redis", "tokens", "vector", "google", "ollama", "bedrock", "azure", "providers", "mcp", "cli", "sandbox", "sandbox-e2b", "all"] [package.metadata.requires-dev] dev = [ @@ -518,6 +522,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/16/f3/c1fbaff4c509c616fd01f44357283a8992f10b3a05d932b22e602aa3a221/botocore-1.42.85-py3-none-any.whl", hash = "sha256:828b67722caeb7e240eefedee74050e803d1fa102958ead9c4009101eefd5381", size = 14839741, upload-time = "2026-04-07T19:40:40.733Z" }, ] +[[package]] +name = "bracex" +version = "3.0.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ac/01/5f394b8bcd6e5b92f73130990960423bbb19711f906bd9fe9ea5557c667c/bracex-3.0.1.tar.gz", hash = "sha256:4e38e32392e4a4780fe15d644bfc7c8514057cfc3861e060b11814ce829c25e4", size = 44019, upload-time = "2026-07-20T13:43:00.335Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b8/8f/6f7273a7adb8d73fc8d21ede4376a3e475e52f98435c6007f69100dec8ca/bracex-3.0.1-py3-none-any.whl", hash = "sha256:6523ad83aeb5098a4ee597cff0f964442ff74e460bd3fafaffab6a013ff2288c", size = 11940, upload-time = "2026-07-20T13:42:59.268Z" }, +] + [[package]] name = "build" version = "1.4.2" @@ -984,6 +997,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/12/b3/231ffd4ab1fc9d679809f356cebee130ac7daa00d6d6f3206dd4fd137e9e/distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2", size = 20277, upload-time = "2023-12-24T09:54:30.421Z" }, ] +[[package]] +name = "dockerfile-parse" +version = "2.0.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/92/df/929ee0b5d2c8bd8d713c45e71b94ab57c7e11e322130724d54f469b2cd48/dockerfile-parse-2.0.1.tar.gz", hash = "sha256:3184ccdc513221983e503ac00e1aa504a2aa8f84e5de673c46b0b6eee99ec7bc", size = 24556, upload-time = "2023-07-18T13:36:07.897Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7a/6c/79cd5bc1b880d8c1a9a5550aa8dacd57353fa3bb2457227e1fb47383eb49/dockerfile_parse-2.0.1-py2.py3-none-any.whl", hash = "sha256:bdffd126d2eb26acf1066acb54cb2e336682e1d72b974a40894fac76a4df17f6", size = 14845, upload-time = "2023-07-18T13:36:06.052Z" }, +] + [[package]] name = "docstring-parser" version = "0.17.0" @@ -1011,6 +1033,28 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b0/0d/9feae160378a3553fa9a339b0e9c1a048e147a4127210e286ef18b730f03/durationpy-0.10-py3-none-any.whl", hash = "sha256:3b41e1b601234296b4fb368338fdcd3e13e0b4fb5b67345948f4f2bf9868b286", size = 3922, upload-time = "2025-05-17T13:52:36.463Z" }, ] +[[package]] +name = "e2b" +version = "2.34.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "attrs" }, + { name = "dockerfile-parse" }, + { name = "h2" }, + { name = "httpcore" }, + { name = "httpx" }, + { name = "packaging" }, + { name = "protobuf" }, + { name = "python-dateutil" }, + { name = "rich" }, + { name = "typing-extensions" }, + { name = "wcmatch" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5b/22/5bcf34304b62e6984df9089eb996a4b2aa63618f901befe1f7cc73a24437/e2b-2.34.0.tar.gz", hash = "sha256:0dcc2694b3ead62e87b3d1070a05f66842dd2fa320fc1d7bd84c8fcfadeaf1b1", size = 189367, upload-time = "2026-07-17T09:59:23.844Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6d/ec/b2f9297afc25de7c27ab5a85db4060783680e2b132285e2498fdbad484cf/e2b-2.34.0-py3-none-any.whl", hash = "sha256:873323571d18bf633be45e59fc6271410b30dfbc81e8df85e711f4f184c03fea", size = 343447, upload-time = "2026-07-17T09:59:22.553Z" }, +] + [[package]] name = "filelock" version = "3.25.2" @@ -1248,6 +1292,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, ] +[[package]] +name = "h2" +version = "4.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "hpack" }, + { name = "hyperframe" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/30/d4/a7d6fb3f58be99d65cbf2d3f766896217a2921d0f3ab10711c45dc1519ee/h2-4.4.0.tar.gz", hash = "sha256:46b551bdcdc7e83cf5c04d0bf93badb8a939bd2287d9fee1abb23a445b9e0580", size = 2156691, upload-time = "2026-07-23T19:14:19.442Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f6/df/5b14a118322d6097cb9bb30ec6bacad268e546a8ecfcb1f6d0de618dac2f/h2-4.4.0-py3-none-any.whl", hash = "sha256:6acffe1aeab79098d7eb0f8385c1add11f2c7a94815f6fa2b7060eeddee3d87c", size = 62368, upload-time = "2026-07-23T19:14:16.143Z" }, +] + [[package]] name = "hatchling" version = "1.29.0" @@ -1355,6 +1412,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/35/d6/191e6741addc97bcf5e755661f8c82f0fd0aa35f07ece56e858da689b57e/hiredis-3.3.1-cp314-cp314t-win_amd64.whl", hash = "sha256:ab1f646ff531d70bfd25f01e60708dfa3d105eb458b7dedd9fe9a443039fd809", size = 23811, upload-time = "2026-03-16T15:20:34.292Z" }, ] +[[package]] +name = "hpack" +version = "4.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/26/5b/fcabf6028144a8723726318b07a32c2f3314acdff6265743cf08a344b18e/hpack-4.2.0.tar.gz", hash = "sha256:0895cfa3b5531fc65fe439c05eb65144f123bf7a394fcaa56aa423548d8e45c0", size = 51300, upload-time = "2026-06-23T18:34:46.667Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/71/b4/4a9fcfb2aef6ba44d9073ecd301443aa00b3dac95de5619f2a7de7ec8a91/hpack-4.2.0-py3-none-any.whl", hash = "sha256:858ac0b02280fa582b5080d68db0899c62a80375e0e5413a74970c5e518b6986", size = 34246, upload-time = "2026-06-23T18:34:45.472Z" }, +] + [[package]] name = "httpcore" version = "1.0.9" @@ -1456,6 +1522,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/73/37/0d15d16150e1829f3e90962c99f28257f6de9e526a680b4c6f5acdb54fd2/huggingface_hub-1.9.0-py3-none-any.whl", hash = "sha256:2999328c058d39fd19ab748dd09bd4da2fbaa4f4c1ddea823eab103051e14a1f", size = 637355, upload-time = "2026-04-03T08:35:53.897Z" }, ] +[[package]] +name = "hyperframe" +version = "6.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/02/e7/94f8232d4a74cc99514c13a9f995811485a6903d48e5d952771ef6322e30/hyperframe-6.1.0.tar.gz", hash = "sha256:f630908a00854a7adeabd6382b43923a4c4cd4b821fcb527e6ab9e15382a3b08", size = 26566, upload-time = "2025-01-22T21:41:49.302Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/48/30/47d0bf6072f7252e6521f3447ccfa40b421b6824517f82854703d0f5a98b/hyperframe-6.1.0-py3-none-any.whl", hash = "sha256:b03380493a519fce58ea5af42e4a42317bf9bd425596f7a0835ffce80f1a42e5", size = 13007, upload-time = "2025-01-22T21:41:47.295Z" }, +] + [[package]] name = "id" version = "1.6.1" @@ -3999,6 +4074,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/e3/bd/fa9bb053192491b3867ba07d2343d9f2252e00811567d30ae8d0f78136fe/watchfiles-1.1.1-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:a916a2932da8f8ab582f242c065f5c81bed3462849ca79ee357dd9551b0e9b01", size = 622112, upload-time = "2025-10-14T15:05:50.941Z" }, ] +[[package]] +name = "wcmatch" +version = "10.2.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "bracex" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/11/15/dc61746d8c0852f6d711ad09c774b63cf7c8211aa49e30871ac3d342b7e2/wcmatch-10.2.1.tar.gz", hash = "sha256:ecac70a5c70e62ba854b78318d3a1408e8651f8f1c96e5837743b71aa6a4fb92", size = 132497, upload-time = "2026-07-02T17:21:48.484Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/82/ba/20b48eedeab5316bf9a502bb9eb7e3b1588bd61d0f565822fefa8f06e10b/wcmatch-10.2.1-py3-none-any.whl", hash = "sha256:2d775395b93f233af66690f62cb9d52b084ec159a31cc4084f4069d72f437acd", size = 39763, upload-time = "2026-07-02T17:21:47.134Z" }, +] + [[package]] name = "webencodings" version = "0.5.1" From 3b1b05f4b063f26791a32d08a9b0913edb03d50e Mon Sep 17 00:00:00 2001 From: Ali Muhammad Date: Fri, 24 Jul 2026 07:09:22 +0500 Subject: [PATCH 4/8] feat(sandbox): add modal sandbox provider --- .github/workflows/ci.yml | 3 + pyproject.toml | 3 + src/anycode/__init__.py | 2 + src/anycode/sandbox/__init__.py | 2 + src/anycode/sandbox/factory.py | 5 + src/anycode/sandbox/modal.py | 208 ++++++++++++++++++++++++++++++++ tests/test_sandbox_providers.py | 133 ++++++++++++++++++++ uv.lock | 113 ++++++++++++++++- 8 files changed, 468 insertions(+), 1 deletion(-) create mode 100644 src/anycode/sandbox/modal.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd451d9..f42681c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -154,6 +154,9 @@ jobs: - extra: sandbox-e2b sync-args: --extra sandbox-e2b imports: e2b anycode.sandbox.e2b + - extra: sandbox-modal + sync-args: --extra sandbox-modal + imports: modal anycode.sandbox.modal - extra: all sync-args: --extra all imports: anycode diff --git a/pyproject.toml b/pyproject.toml index 9495392..e5994be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -102,6 +102,9 @@ sandbox = [ sandbox-e2b = [ "e2b>=1.0", ] +sandbox-modal = [ + "modal>=1.0", +] all = [ "anthropic>=0.40", "openai>=1.50", diff --git a/src/anycode/__init__.py b/src/anycode/__init__.py index 2d275a2..750aff5 100644 --- a/src/anycode/__init__.py +++ b/src/anycode/__init__.py @@ -193,6 +193,7 @@ CompanionSandboxAdapter, DaytonaSandboxProvider, E2BSandboxProvider, + ModalSandboxProvider, PolicySandboxProvider, SandboxCapabilities, SandboxCommand, @@ -609,6 +610,7 @@ "CompanionSandboxAdapter", "DaytonaSandboxProvider", "E2BSandboxProvider", + "ModalSandboxProvider", "PolicySandboxProvider", "SandboxCapabilities", "SandboxCommand", diff --git a/src/anycode/sandbox/__init__.py b/src/anycode/sandbox/__init__.py index d495bd0..1c3558f 100644 --- a/src/anycode/sandbox/__init__.py +++ b/src/anycode/sandbox/__init__.py @@ -4,6 +4,7 @@ from anycode.sandbox.daytona import DaytonaSandboxProvider from anycode.sandbox.e2b import E2BSandboxProvider from anycode.sandbox.factory import SANDBOX_PROVIDER_EXTRAS, create_sandbox_provider +from anycode.sandbox.modal import ModalSandboxProvider from anycode.sandbox.models import ( SANDBOX_CONTRACT_VERSION, SandboxActionResult, @@ -28,6 +29,7 @@ "CompanionSandboxClient", "DaytonaSandboxProvider", "E2BSandboxProvider", + "ModalSandboxProvider", "PolicySandboxProvider", "SandboxActionResult", "SandboxCapabilities", diff --git a/src/anycode/sandbox/factory.py b/src/anycode/sandbox/factory.py index d35ab89..4ab3fa7 100644 --- a/src/anycode/sandbox/factory.py +++ b/src/anycode/sandbox/factory.py @@ -11,6 +11,7 @@ SANDBOX_PROVIDER_EXTRAS: dict[str, str] = { "daytona": "sandbox", "e2b": "sandbox-e2b", + "modal": "sandbox-modal", } @@ -29,5 +30,9 @@ def create_sandbox_provider(name: str, **kwargs: Any) -> SandboxProvider: from anycode.sandbox.e2b import E2BSandboxProvider return E2BSandboxProvider(**kwargs) + if name == "modal": + from anycode.sandbox.modal import ModalSandboxProvider + + return ModalSandboxProvider(**kwargs) raise ValueError(f"Unknown sandbox provider: {name!r}. Available: {sorted(SANDBOX_PROVIDER_EXTRAS)}") diff --git a/src/anycode/sandbox/modal.py b/src/anycode/sandbox/modal.py new file mode 100644 index 0000000..8350fe8 --- /dev/null +++ b/src/anycode/sandbox/modal.py @@ -0,0 +1,208 @@ +"""Modal sandbox provider adapter.""" + +from __future__ import annotations + +from collections.abc import AsyncIterable +from typing import Any + +from anycode.contracts.models import ContractError +from anycode.sandbox._base import ( + buffered_stream, + call_maybe_async, + first_guard_error, + read_streamish, + shell_command, + snapshot_restore_unsupported_error, + to_bytes, +) +from anycode.sandbox._secrets import strip_secret_prefix, validate_secret_references +from anycode.sandbox.models import ( + SandboxActionResult, + SandboxCapabilities, + SandboxCommand, + SandboxCommandResult, + SandboxCreateResult, + SandboxEvidence, + SandboxFileResult, + SandboxHandle, + SandboxHealth, + SandboxOutputChunk, + SandboxSpec, +) +from anycode.security.redaction import safe_exception_message + + +class ModalSandboxProvider: + """Modal gVisor sandboxes; tokens stay in Modal's own configuration.""" + + def __init__(self, client: Any | None = None, *, app_name: str = "anycode-sandbox") -> None: + self._client = client + self._app_name = app_name + self._sandboxes: dict[str, Any] = {} + + def _client_or_raise(self) -> Any: + if self._client is not None: + return self._client + try: + import modal # type: ignore[import-not-found] + except ImportError as error: + message = 'ModalSandboxProvider requires the optional "modal" package. Install it with: pip install "anycode-py[sandbox-modal]"' + raise ImportError(message) from error + self._client = modal + return self._client + + def _network_guard(self, spec: SandboxSpec) -> ContractError | None: + if spec.network == "allowlist" and spec.allowed_domains: + return ContractError( + code="sandbox_network_policy_unsupported", + message="modal enforces CIDR allowlists only; domain allowlists fail closed", + ) + return None + + async def _resolve(self, handle: SandboxHandle) -> Any: + sandbox = self._sandboxes.get(handle.id) + if sandbox is not None: + return sandbox + sandbox = await call_maybe_async(self._client_or_raise().Sandbox.from_id, handle.id) + self._sandboxes[handle.id] = sandbox + return sandbox + + async def create(self, spec: SandboxSpec) -> SandboxCreateResult: + guard = first_guard_error( + self._network_guard(spec), + validate_secret_references("modal", spec), + snapshot_restore_unsupported_error("modal", spec), + ) + if guard is not None: + return SandboxCreateResult(ok=False, error=guard) + try: + modal_mod = self._client_or_raise() + app = await call_maybe_async(modal_mod.App.lookup, self._app_name, create_if_missing=True) + image = await call_maybe_async(modal_mod.Image.from_registry, spec.image) if spec.image else None + kwargs: dict[str, Any] = {"app": app} + if image is not None: + kwargs["image"] = image + if spec.network == "none": + kwargs["block_network"] = True + elif spec.network == "allowlist": + kwargs["cidr_allowlist"] = list(spec.allowed_cidrs) + if spec.secret_references: + kwargs["secrets"] = [ + await call_maybe_async(modal_mod.Secret.from_name, strip_secret_prefix("modal", reference)) + for reference in spec.secret_references.values() + ] + sandbox = await call_maybe_async(modal_mod.Sandbox.create, **kwargs) + sandbox_id = str(getattr(sandbox, "object_id", None) or getattr(sandbox, "id", "")) + self._sandboxes[sandbox_id] = sandbox + handle = SandboxHandle( + id=sandbox_id, + provider="modal", + run_id=spec.run_id, + task_id=spec.task_id, + correlation_id=spec.correlation_id, + context=spec.context, + capabilities=self.capabilities(), + ) + return SandboxCreateResult(ok=True, handle=handle) + except Exception as error: + return SandboxCreateResult( + ok=False, + error=ContractError(code="sandbox_create_failed", message=safe_exception_message(error), retryable=True), + ) + + async def execute(self, handle: SandboxHandle, command: SandboxCommand) -> SandboxCommandResult: + try: + sandbox = await self._resolve(handle) + kwargs: dict[str, Any] = {} + if command.timeout_seconds is not None: + kwargs["timeout"] = command.timeout_seconds + process = await call_maybe_async(sandbox.exec, "bash", "-lc", shell_command(command), **kwargs) + waiter = getattr(process, "wait", None) + if callable(waiter): + await call_maybe_async(waiter) + stdout = await read_streamish(getattr(process, "stdout", "")) + stderr = await read_streamish(getattr(process, "stderr", "")) + exit_code = int(getattr(process, "returncode", 0) or 0) + evidence = SandboxEvidence.from_bytes("command", f"{stdout}\0{stderr}".encode(), metadata={"exit_code": exit_code}) + return SandboxCommandResult(ok=exit_code == 0, exit_code=exit_code, stdout=stdout, stderr=stderr, evidence=evidence) + except Exception as error: + return SandboxCommandResult( + ok=False, + error=ContractError(code="sandbox_command_failed", message=safe_exception_message(error), retryable=True), + ) + + def stream(self, handle: SandboxHandle, command: SandboxCommand) -> AsyncIterable[SandboxOutputChunk]: + return buffered_stream(self.execute, handle, command) + + async def write_file(self, handle: SandboxHandle, path: str, data: bytes) -> SandboxFileResult: + try: + sandbox = await self._resolve(handle) + handle_file = await call_maybe_async(sandbox.open, path, "wb") + await call_maybe_async(handle_file.write, data) + await call_maybe_async(handle_file.close) + return SandboxFileResult(ok=True, evidence=SandboxEvidence.from_bytes("file.write", data, metadata={"path": path})) + except Exception as error: + return SandboxFileResult(ok=False, error=ContractError(code="sandbox_file_write_failed", message=safe_exception_message(error))) + + async def read_file(self, handle: SandboxHandle, path: str) -> SandboxFileResult: + try: + sandbox = await self._resolve(handle) + handle_file = await call_maybe_async(sandbox.open, path, "rb") + data = to_bytes(await call_maybe_async(handle_file.read)) + await call_maybe_async(handle_file.close) + return SandboxFileResult(ok=True, data=data, evidence=SandboxEvidence.from_bytes("file.read", data, metadata={"path": path})) + except Exception as error: + return SandboxFileResult(ok=False, error=ContractError(code="sandbox_file_read_failed", message=safe_exception_message(error))) + + async def cancel(self, handle: SandboxHandle) -> SandboxActionResult: + try: + sandbox = await self._resolve(handle) + await call_maybe_async(sandbox.terminate) + return SandboxActionResult(ok=True, evidence=SandboxEvidence.from_bytes("sandbox.cancel", handle.id.encode())) + except Exception as error: + return SandboxActionResult(ok=False, error=ContractError(code="sandbox_cancel_failed", message=safe_exception_message(error))) + + async def snapshot(self, handle: SandboxHandle, name: str) -> SandboxActionResult: + try: + sandbox = await self._resolve(handle) + image = await call_maybe_async(sandbox.snapshot_filesystem) + reference = str(getattr(image, "object_id", None) or image) + evidence = SandboxEvidence.from_bytes("sandbox.snapshot", reference.encode(), metadata={"name": name}) + return SandboxActionResult(ok=True, reference=reference, evidence=evidence) + except Exception as error: + return SandboxActionResult(ok=False, error=ContractError(code="sandbox_snapshot_failed", message=safe_exception_message(error))) + + async def destroy(self, handle: SandboxHandle) -> SandboxActionResult: + try: + sandbox = await self._resolve(handle) + await call_maybe_async(sandbox.terminate) + self._sandboxes.pop(handle.id, None) + return SandboxActionResult(ok=True, evidence=SandboxEvidence.from_bytes("sandbox.destroy", handle.id.encode())) + except Exception as error: + return SandboxActionResult(ok=False, error=ContractError(code="sandbox_destroy_failed", message=safe_exception_message(error))) + + async def health(self) -> SandboxHealth: + try: + self._client_or_raise() + except Exception as error: + return SandboxHealth(status="unavailable", message=safe_exception_message(error)) + return SandboxHealth(status="healthy") + + def capabilities(self) -> SandboxCapabilities: + return SandboxCapabilities( + provider="modal", + isolation="container", + networking="allowlist", + persistent_filesystem=True, + snapshots=True, + command_streaming=False, + cancellation=True, + file_transfer=True, + evidence=True, + limitations=( + "gVisor container isolation, not a dedicated VM per sandbox.", + "Network allowlists are CIDR-only; domain allowlists fail closed.", + "Command streaming is buffered: output arrives after the command completes.", + "Snapshots capture the filesystem as a Modal image reference, not a running-process checkpoint.", + ), + ) diff --git a/tests/test_sandbox_providers.py b/tests/test_sandbox_providers.py index 87eaa7b..1b2c1f3 100644 --- a/tests/test_sandbox_providers.py +++ b/tests/test_sandbox_providers.py @@ -12,6 +12,7 @@ SANDBOX_PROVIDER_EXTRAS, DaytonaSandboxProvider, E2BSandboxProvider, + ModalSandboxProvider, SandboxCommand, SandboxProvider, SandboxSpec, @@ -151,6 +152,138 @@ def test_e2b_capabilities_are_honest() -> None: assert not caps.snapshots and not caps.command_streaming +# --------------------------------------------------------------------------- +# Modal fakes +# --------------------------------------------------------------------------- + + +class FakeModalFile: + def __init__(self, store: dict[str, bytes], path: str, mode: str) -> None: + self._store = store + self._path = path + self._mode = mode + + async def write(self, data: bytes) -> None: + self._store[self._path] = data + + async def read(self) -> bytes: + return self._store[self._path] + + async def close(self) -> None: + return None + + +class FakeModalProcess: + def __init__(self, command: str) -> None: + self.stdout = f"ran:{command}" + self.stderr = "" + self.returncode = 0 + + async def wait(self) -> None: + return None + + +class FakeModalSandbox: + def __init__(self) -> None: + self.object_id = "modal-1" + self.files: dict[str, bytes] = {} + self.terminated = False + self.create_kwargs: dict[str, object] = {} + + async def exec(self, *args: str, **kwargs: object) -> FakeModalProcess: + del kwargs + return FakeModalProcess(args[-1]) + + async def open(self, path: str, mode: str) -> FakeModalFile: + return FakeModalFile(self.files, path, mode) + + async def terminate(self) -> None: + self.terminated = True + + async def snapshot_filesystem(self) -> SimpleNamespace: + return SimpleNamespace(object_id="im-snapshot-1") + + +class FakeModalModule: + """Stands in for the imported modal module surface.""" + + def __init__(self) -> None: + self.sandbox = FakeModalSandbox() + self.secret_names: list[str] = [] + outer = self + + class App: + @staticmethod + async def lookup(name: str, *, create_if_missing: bool = False) -> SimpleNamespace: + del create_if_missing + return SimpleNamespace(name=name) + + class Image: + @staticmethod + def from_registry(image: str) -> SimpleNamespace: + return SimpleNamespace(image=image) + + class Secret: + @staticmethod + def from_name(name: str) -> SimpleNamespace: + outer.secret_names.append(name) + return SimpleNamespace(name=name) + + class Sandbox: + @staticmethod + async def create(**kwargs: object) -> FakeModalSandbox: + outer.sandbox.create_kwargs = dict(kwargs) + return outer.sandbox + + @staticmethod + async def from_id(sandbox_id: str) -> FakeModalSandbox: + assert sandbox_id == outer.sandbox.object_id + return outer.sandbox + + self.App = App + self.Image = Image + self.Secret = Secret + self.Sandbox = Sandbox + + +async def test_modal_provider_passes_lifecycle_conformance() -> None: + provider = ModalSandboxProvider(FakeModalModule()) + await _assert_lifecycle_conformance(provider, snapshots=True) + + +async def test_modal_maps_network_and_secrets_to_sdk_arguments() -> None: + modal_mod = FakeModalModule() + provider = ModalSandboxProvider(modal_mod) + + created = await provider.create(_spec(network="none", secret_references={"API_KEY": "modal:prod-key"})) + + assert created.ok + assert modal_mod.sandbox.create_kwargs["block_network"] is True + assert modal_mod.secret_names == ["prod-key"] + + +async def test_modal_fails_closed_on_domain_allowlists_and_foreign_secrets() -> None: + provider = ModalSandboxProvider(FakeModalModule()) + + domains = await provider.create(_spec(network="allowlist", allowed_domains=("example.com",))) + assert not domains.ok and domains.error is not None + assert domains.error.code == "sandbox_network_policy_unsupported" + + foreign = await provider.create(_spec(secret_references={"API_KEY": "daytona:key"})) + assert not foreign.ok and foreign.error is not None + assert foreign.error.code == "sandbox_secret_reference_invalid" + + +async def test_modal_reports_missing_sdk_guidance(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setitem(sys.modules, "modal", None) + provider = ModalSandboxProvider() + + created = await provider.create(_spec()) + + assert not created.ok and created.error is not None + assert "anycode-py[sandbox-modal]" in created.error.message + + def test_factory_builds_daytona_provider() -> None: provider = create_sandbox_provider("daytona") assert isinstance(provider, DaytonaSandboxProvider) diff --git a/uv.lock b/uv.lock index 8c2ec77..8e621cc 100644 --- a/uv.lock +++ b/uv.lock @@ -270,6 +270,9 @@ sandbox = [ sandbox-e2b = [ { name = "e2b" }, ] +sandbox-modal = [ + { name = "modal" }, +] telemetry = [ { name = "opentelemetry-api" }, { name = "opentelemetry-exporter-otlp-proto-grpc" }, @@ -332,6 +335,7 @@ requires-dist = [ { name = "httpx", marker = "extra == 'providers'", specifier = ">=0.27" }, { name = "mcp", marker = "extra == 'all'", specifier = ">=1.0" }, { name = "mcp", marker = "extra == 'mcp'", specifier = ">=1.0" }, + { name = "modal", marker = "extra == 'sandbox-modal'", specifier = ">=1.0" }, { name = "openai", marker = "extra == 'all'", specifier = ">=1.50" }, { name = "openai", marker = "extra == 'azure'", specifier = ">=1.50" }, { name = "openai", marker = "extra == 'openai'", specifier = ">=1.50" }, @@ -355,7 +359,7 @@ requires-dist = [ { name = "typer", marker = "extra == 'all'", specifier = ">=0.12" }, { name = "typer", marker = "extra == 'cli'", specifier = ">=0.12" }, ] -provides-extras = ["anthropic", "openai", "telemetry", "persistence", "redis", "tokens", "vector", "google", "ollama", "bedrock", "azure", "providers", "mcp", "cli", "sandbox", "sandbox-e2b", "all"] +provides-extras = ["anthropic", "openai", "telemetry", "persistence", "redis", "tokens", "vector", "google", "ollama", "bedrock", "azure", "providers", "mcp", "cli", "sandbox", "sandbox-e2b", "sandbox-modal", "all"] [package.metadata.requires-dev] dev = [ @@ -573,6 +577,46 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/bf/e0/5011747466414c12cac8a8df77aa235068669a6a5a5df301a96209db6054/cairosvg-2.9.0-py3-none-any.whl", hash = "sha256:4b82d07d145377dffdfc19d9791bd5fb65539bb4da0adecf0bdbd9cd4ffd7c68", size = 45962, upload-time = "2026-03-14T13:56:33.512Z" }, ] +[[package]] +name = "cbor2" +version = "6.1.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/3a/6f/07b4af8da8bd27f640362b1ac8271d80895407f2ede0c2bcc9433c06e1ca/cbor2-6.1.3.tar.gz", hash = "sha256:8d70680acb55c04ea5b5ad86da094f9612b53d5a8a65d0f5b3aafc3ce917ecbb", size = 89503, upload-time = "2026-07-04T10:36:48.793Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/31/16/cff14259c3d19a7f0ae88b6996fe4c85f6ff1764dad889ac8a39e843e39c/cbor2-6.1.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3d939f55097c21e032f5a2d67592fcc57298986281f219356e2f519e4466f4ea", size = 412779, upload-time = "2026-07-04T10:36:04.975Z" }, + { url = "https://files.pythonhosted.org/packages/50/6c/f3641d19b7b85a63cb2756c10164131489c2cb46b379ec51ae22283fefb9/cbor2-6.1.3-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:b025009478d644dab407164fd60e3ef4381af284f5af6966df94c663756d949e", size = 457781, upload-time = "2026-07-04T10:36:06.349Z" }, + { url = "https://files.pythonhosted.org/packages/55/85/0c55a66f3037056bfb8e1c7184168085fdea67ae5830404498bcf466233b/cbor2-6.1.3-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:2226d32e102e375737656ad5d141ad8c6ae3e705e04e263f24756f0eb379c6c1", size = 468373, upload-time = "2026-07-04T10:36:07.769Z" }, + { url = "https://files.pythonhosted.org/packages/46/74/40f7db3e0d880560193916a5c9b744fcf299558bed7113f77c28237c7c29/cbor2-6.1.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e61d465244d66ffed36492eef3b44d43795d76a2bba0663a2f15c186af7f7513", size = 523844, upload-time = "2026-07-04T10:36:09.404Z" }, + { url = "https://files.pythonhosted.org/packages/b5/a1/b5e07d6a08441c3a552fe2ae48ccb7e9dfc5065b9f6a3bae9879b4f0fbc0/cbor2-6.1.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:87fe7be8fab6ec4796aa127c1a52e09e79dbafd2aa31caf809cf04b8080a5975", size = 536238, upload-time = "2026-07-04T10:36:10.914Z" }, + { url = "https://files.pythonhosted.org/packages/c9/99/e166be0fd74bf3a91f5a0d103e34883efbc438d970f72cc8200e274787e5/cbor2-6.1.3-cp312-cp312-win32.whl", hash = "sha256:da25d345f01e6a40b2e5c57ef96b4dcff7be69394fb62f0f70e07f437f2376a9", size = 279858, upload-time = "2026-07-04T10:36:12.247Z" }, + { url = "https://files.pythonhosted.org/packages/d2/1b/90b4a121e40aba189c55a5822dd3c698eaf487e1d4a780ab18c804a5ef1c/cbor2-6.1.3-cp312-cp312-win_amd64.whl", hash = "sha256:d5514f693db6fa6f433b4096e9b604e6a7bf151c9ef1d2db86d0858e4c5e768f", size = 300929, upload-time = "2026-07-04T10:36:13.564Z" }, + { url = "https://files.pythonhosted.org/packages/19/db/52c58a8d33464927389dde8103997b3fa51b081ce29b347ac2cc4fd0dfbf/cbor2-6.1.3-cp312-cp312-win_arm64.whl", hash = "sha256:3d43183d7beb3d3cd198d69b31bd2ee487ed704a1150c75cb0a66d6ad63d8c1a", size = 290908, upload-time = "2026-07-04T10:36:14.857Z" }, + { url = "https://files.pythonhosted.org/packages/1c/8c/5024d623dcf3f2057ec8c991f584b939ba5f9025a5ce8c31f6fac067137a/cbor2-6.1.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:21c74b8ab67977c8b87b727247eeb730145b0068ad6d47f71e9f80f6b48c65f8", size = 412334, upload-time = "2026-07-04T10:36:16.299Z" }, + { url = "https://files.pythonhosted.org/packages/61/f3/e50654203c3b746166a96bea680eb6463b20c2c160cc14dfbe43f215ef6c/cbor2-6.1.3-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:f291a0ae4c1ed96eadb0afa9752568c7424f7d6fa818676d5e33005fcd22ddd9", size = 457125, upload-time = "2026-07-04T10:36:17.684Z" }, + { url = "https://files.pythonhosted.org/packages/44/86/6ef007f0d4f7afba90a80cb1657984de542e7474d2afaa7e920ac9860df3/cbor2-6.1.3-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:dc8e44c7bf172687195dcd428157885bc00ea06efc0ea30fb371163b92bef733", size = 467651, upload-time = "2026-07-04T10:36:19.007Z" }, + { url = "https://files.pythonhosted.org/packages/b2/f4/b5aa27813c02f37e03eb86bd908163562edd6fc7f99665bc7bbb25ef5e6c/cbor2-6.1.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:8ccf4d263983d830dd429d2b01f27be58ac02ba7c790c45d861f767eb63963e5", size = 523296, upload-time = "2026-07-04T10:36:20.504Z" }, + { url = "https://files.pythonhosted.org/packages/5b/46/e17b2bce2efdc26bfa045b4f6168f02923ac5f0e79732a1b3c42ce9ca9de/cbor2-6.1.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:8719a7a2a2a82168844533389957b8f617a139f5f40e4d0ad7ed905fd3abebd1", size = 535537, upload-time = "2026-07-04T10:36:21.761Z" }, + { url = "https://files.pythonhosted.org/packages/54/bc/add350acf37f367ae429f997f2e047b042f2d5ef9ca62461c923fbb0f3c3/cbor2-6.1.3-cp313-cp313-win32.whl", hash = "sha256:c73b54ce09dd8d522f3c1540426e36172ba0f34abf3d89eb93909a5e14590003", size = 279233, upload-time = "2026-07-04T10:36:23.071Z" }, + { url = "https://files.pythonhosted.org/packages/e8/6f/1bbfce3b3131e4e03e8a86966a38ff92ebb72215fcf36aeecea1547f3e4b/cbor2-6.1.3-cp313-cp313-win_amd64.whl", hash = "sha256:b77df56c462c10eb3444db8ef78d8c3e71d9ef8d021ea92e97c1f9e3aa918690", size = 300585, upload-time = "2026-07-04T10:36:24.563Z" }, + { url = "https://files.pythonhosted.org/packages/e7/65/3945702dd84b6e5b7800c9c7f1ada038d33d12d0042de10e38164cc03dfd/cbor2-6.1.3-cp313-cp313-win_arm64.whl", hash = "sha256:b144be2ab3e9584ee7b6359d2a92fee0a5bec1d00dbd34c215ccc2040ac0b2ab", size = 290357, upload-time = "2026-07-04T10:36:25.983Z" }, + { url = "https://files.pythonhosted.org/packages/8f/40/04ad7d34182b27487a1824422b361b32d2607727ef20e563056eba62d12a/cbor2-6.1.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:3f3167ca9920b90db4ff72652db109dfd93b56ee0d583aca12f3a5d9a7019477", size = 414615, upload-time = "2026-07-04T10:36:27.299Z" }, + { url = "https://files.pythonhosted.org/packages/8e/29/94238c61f90653a606535e7509a2af312089fe10dafcb4cf82d6905a7a1a/cbor2-6.1.3-cp314-cp314-manylinux_2_28_aarch64.whl", hash = "sha256:48c677971e4b71e685491e1a267d9924dc205e7ddbe3f34fd2562f16c0f6bfca", size = 459084, upload-time = "2026-07-04T10:36:28.717Z" }, + { url = "https://files.pythonhosted.org/packages/c8/cb/6bd33461e8be8ded7ebb0fa38994a63752aefae2b4fcd1b2cc71ee3c06f1/cbor2-6.1.3-cp314-cp314-manylinux_2_28_x86_64.whl", hash = "sha256:ad4f3c6dfc6b83331eb04c6975efb2839ab65a3aa81502bc2b3f7945d4c4aa44", size = 469310, upload-time = "2026-07-04T10:36:30.136Z" }, + { url = "https://files.pythonhosted.org/packages/8e/d1/94195bcd8fcc1030ecaf22a7a825faa08891b5bb2d3553e465e50fe115f5/cbor2-6.1.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:8bcd609eab4a39745123bfb28e73311abba3d14975a87f5906e0e8b910d918ac", size = 524287, upload-time = "2026-07-04T10:36:31.453Z" }, + { url = "https://files.pythonhosted.org/packages/06/55/57178fbf2d1206af5299c688f9c917b83f30636694c8f932dc89c6652545/cbor2-6.1.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:672727ecb27d7fb3ca0bf8a58fc489d5374ab1fee680ed3d0348a11d9d3ca78f", size = 537031, upload-time = "2026-07-04T10:36:32.769Z" }, + { url = "https://files.pythonhosted.org/packages/fb/01/beefe26258d66ce39a9b057b679bc67dba81698d5a63e0ada5b4752a5c87/cbor2-6.1.3-cp314-cp314-win32.whl", hash = "sha256:1413cef2aa7f478a38298cd3492a055e8e8e45d17fb53bbe103e79ca15c33f3c", size = 286256, upload-time = "2026-07-04T10:36:34.078Z" }, + { url = "https://files.pythonhosted.org/packages/1b/2d/79eb513a2586a2053a6f18b33693beda65e2c766820d99676a306573fed5/cbor2-6.1.3-cp314-cp314-win_amd64.whl", hash = "sha256:59df264d4a508ba61daaa0bf3c2f92d63275509549a0875c1fa38176f651e4f8", size = 313744, upload-time = "2026-07-04T10:36:35.58Z" }, + { url = "https://files.pythonhosted.org/packages/a1/c7/ab9828e4efc26badf89f1397f866f3ef03ef65cdcd55518254b84bdaf86e/cbor2-6.1.3-cp314-cp314-win_arm64.whl", hash = "sha256:b62b5d80a0eb4305cd5f0217faa4d7747bd64fe0dff9b88415e7be3782f8249b", size = 304280, upload-time = "2026-07-04T10:36:36.865Z" }, + { url = "https://files.pythonhosted.org/packages/33/cf/54a497ad1026833c1c92d482edbda0bdebb48314b51563d2fcea24ab89b4/cbor2-6.1.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:856ab525bfc599588b8d2a45babb7c3400c693ea0bb574d818467d997102fe24", size = 409638, upload-time = "2026-07-04T10:36:38.089Z" }, + { url = "https://files.pythonhosted.org/packages/3b/03/efdecd0848b9c9e43242537f6dd8ac5d441a077d362e5e6954c7775b866a/cbor2-6.1.3-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:a076f35abf1dd0a4de6e2f7f4d4932abafc951a26275b6aa4a3b370c2fd3bbf4", size = 452193, upload-time = "2026-07-04T10:36:39.56Z" }, + { url = "https://files.pythonhosted.org/packages/ef/bf/b5f43c75dc5f0ca3127919d3273d8671917932aa3e90767da63867e0f06f/cbor2-6.1.3-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:37ccab1d0bd3f57ff536a41e44165d0c99cb166ac6e5ffb8b93c42304b56e48d", size = 466614, upload-time = "2026-07-04T10:36:40.936Z" }, + { url = "https://files.pythonhosted.org/packages/23/ee/e85b2ddd46b3b43e39a986704353b433efab0881234e1b4d824229fc2a75/cbor2-6.1.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:76d257ce797e651fa430b0269e8e8c43549c54ce8b0d12860569b3709bf1326f", size = 518503, upload-time = "2026-07-04T10:36:42.289Z" }, + { url = "https://files.pythonhosted.org/packages/60/13/c740c0002f127dc3e9e87b61a5d1285dd3b71aa11d8e0f6a408fc1f36173/cbor2-6.1.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:4af35baadb66f7c9cbb3998eab469767c04641552416c1c69dd4d3d183797119", size = 534236, upload-time = "2026-07-04T10:36:43.641Z" }, + { url = "https://files.pythonhosted.org/packages/73/cd/a57d97177f3777c96f3406efb0ad60794fdbf249d497ec24559bfd1d0328/cbor2-6.1.3-cp314-cp314t-win32.whl", hash = "sha256:61c92661665bccfed4ffa69d1fe10097f2c820d262f56a8cf909a5ebf9f6d8c6", size = 282446, upload-time = "2026-07-04T10:36:44.888Z" }, + { url = "https://files.pythonhosted.org/packages/11/c8/dd54878589df22c863d526cb82e1bb20e953d40223436449a52481c49804/cbor2-6.1.3-cp314-cp314t-win_amd64.whl", hash = "sha256:dc6bcd030bf5043662b84b0ca0f0ca942491bf509105db30cedca6e2ce82d158", size = 310300, upload-time = "2026-07-04T10:36:46.212Z" }, + { url = "https://files.pythonhosted.org/packages/05/d0/b0780a396d145e3356bfdc48578d021ade1818a6c7d7842a3d6bc6f16fbb/cbor2-6.1.3-cp314-cp314t-win_arm64.whl", hash = "sha256:da98a5e0ae9487bed497ac74e2c850b49975a3b7b5314b76c3843e2c83a6c8c4", size = 299391, upload-time = "2026-07-04T10:36:47.629Z" }, +] + [[package]] name = "certifi" version = "2026.2.25" @@ -1283,6 +1327,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/e5/8c/bbe6baf2557262834f2070cf668515fa308b2d38a4bbf771f8f7872a7036/grpcio-1.80.0-cp314-cp314-win_amd64.whl", hash = "sha256:3b01e1f5464c583d2f567b2e46ff0d516ef979978f72091fd81f5ab7fa6e2e7f", size = 5019457, upload-time = "2026-03-30T08:48:37.308Z" }, ] +[[package]] +name = "grpclib" +version = "0.4.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "h2" }, + { name = "multidict" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5b/28/5a2c299ec82a876a252c5919aa895a6f1d1d35c96417c5ce4a4660dc3a80/grpclib-0.4.9.tar.gz", hash = "sha256:cc589c330fa81004c6400a52a566407574498cb5b055fa927013361e21466c46", size = 84798, upload-time = "2025-12-14T22:23:14.349Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5c/90/b0cbbd9efcc82816c58f31a34963071aa19fb792a212a5d9caf8e0fc3097/grpclib-0.4.9-py3-none-any.whl", hash = "sha256:7762ec1c8ed94dfad597475152dd35cbd11aecaaca2f243e29702435ca24cf0e", size = 77063, upload-time = "2025-12-14T22:23:13.224Z" }, +] + [[package]] name = "h11" version = "0.16.0" @@ -2116,6 +2173,30 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/a0/0f/59204bf136d1201f8d7884cfbaf7498c5b4674e87a4c693f9bde63741ce1/mmh3-5.2.1-cp314-cp314t-win_arm64.whl", hash = "sha256:dfd51b4c56b673dfbc43d7d27ef857dd91124801e2806c69bb45585ce0fa019b", size = 40391, upload-time = "2026-03-05T15:55:56.697Z" }, ] +[[package]] +name = "modal" +version = "1.5.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "aiohttp" }, + { name = "cbor2" }, + { name = "certifi" }, + { name = "click" }, + { name = "grpclib" }, + { name = "protobuf" }, + { name = "rich" }, + { name = "synchronicity" }, + { name = "toml" }, + { name = "types-certifi" }, + { name = "types-toml" }, + { name = "typing-extensions" }, + { name = "watchfiles" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/09/13/c54908743129b75f9761ebcc767f8de5e5b16e2a0303e171f7ae38d90d4d/modal-1.5.3.tar.gz", hash = "sha256:0551c6fa2386ce78619f1a058eb4dd3ca527a54048952ea870e26704557c76c4", size = 844542, upload-time = "2026-07-23T21:06:49.14Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cd/5d/834ba7387383077538f28a1d17d2df95d596e225a44a1ea1207ad90977f3/modal-1.5.3-py3-none-any.whl", hash = "sha256:d3fbe1d95321d1e4bdb08140bf42711084d705e7e3de644f7ae55c9b96b6c51d", size = 961068, upload-time = "2026-07-23T21:06:46.866Z" }, +] + [[package]] name = "more-itertools" version = "11.0.2" @@ -3726,6 +3807,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/a2/09/77d55d46fd61b4a135c444fc97158ef34a095e5681d0a6c10b75bf356191/sympy-1.14.0-py3-none-any.whl", hash = "sha256:e091cc3e99d2141a0ba2847328f5479b05d94a6635cb96148ccb3f34671bd8f5", size = 6299353, upload-time = "2025-04-27T18:04:59.103Z" }, ] +[[package]] +name = "synchronicity" +version = "0.12.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5d/1c/f51dc54bbd302991026a53f9790735540e0e9e1184e9d5939f02446aa5bc/synchronicity-0.12.5.tar.gz", hash = "sha256:94d96b1d85698e3056b96a793b8c0949af6584e4a7d877fabdeb5385efe230aa", size = 60745, upload-time = "2026-06-18T21:06:23.545Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/06/74/ad9b99520f70c0bc3318e582e359d360cfc0f7afd7bf368a7f24013cece7/synchronicity-0.12.5-py3-none-any.whl", hash = "sha256:fdbbb10d437bc08a6b0f814fc66fddd1b58ffed314533d42f1ab555801e781af", size = 41107, upload-time = "2026-06-18T21:06:22.505Z" }, +] + [[package]] name = "tenacity" version = "9.1.4" @@ -3885,6 +3978,24 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/4a/91/48db081e7a63bb37284f9fbcefda7c44c277b18b0e13fbc36ea2335b71e6/typer-0.24.1-py3-none-any.whl", hash = "sha256:112c1f0ce578bfb4cab9ffdabc68f031416ebcc216536611ba21f04e9aa84c9e", size = 56085, upload-time = "2026-02-21T16:54:41.616Z" }, ] +[[package]] +name = "types-certifi" +version = "2021.10.8.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/52/68/943c3aeaf14624712a0357c4a67814dba5cea36d194f5c764dad7959a00c/types-certifi-2021.10.8.3.tar.gz", hash = "sha256:72cf7798d165bc0b76e1c10dd1ea3097c7063c42c21d664523b928e88b554a4f", size = 2095, upload-time = "2022-06-09T15:19:05.244Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b5/63/2463d89481e811f007b0e1cd0a91e52e141b47f9de724d20db7b861dcfec/types_certifi-2021.10.8.3-py3-none-any.whl", hash = "sha256:b2d1e325e69f71f7c78e5943d410e650b4707bb0ef32e4ddf3da37f54176e88a", size = 2136, upload-time = "2022-06-09T15:19:03.127Z" }, +] + +[[package]] +name = "types-toml" +version = "0.10.8.20260518" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/4b/11/6ece999e91f2ccb848ab4420f3f4816e78ac0541f739e6864affdaaa5737/types_toml-0.10.8.20260518.tar.gz", hash = "sha256:80e10facd24fdeda9d5c672187d72be3ac284843788d67f5aae59e3e016db6fe", size = 9419, upload-time = "2026-05-18T06:02:16.719Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/91/25/489751806bf5c95e4007f8e17409199c54d31e49ffbea07c5729b1286c8e/types_toml-0.10.8.20260518-py3-none-any.whl", hash = "sha256:0e564ab05f6fde62a315b3b5a9b6624fda569399795d30a37e64705a70459303", size = 9669, upload-time = "2026-05-18T06:02:15.86Z" }, +] + [[package]] name = "typing-extensions" version = "4.15.0" From 10956eaa2b89826723cdc3699afe215acd01b9a7 Mon Sep 17 00:00:00 2001 From: Ali Muhammad Date: Fri, 24 Jul 2026 07:11:34 +0500 Subject: [PATCH 5/8] feat(sandbox): add runloop sandbox provider --- .github/workflows/ci.yml | 3 + pyproject.toml | 3 + src/anycode/__init__.py | 2 + src/anycode/sandbox/__init__.py | 2 + src/anycode/sandbox/factory.py | 5 + src/anycode/sandbox/runloop.py | 183 ++++++++++++++++++++++++++++++++ tests/test_sandbox_providers.py | 91 ++++++++++++++++ uv.lock | 95 ++++++++++++++++- 8 files changed, 383 insertions(+), 1 deletion(-) create mode 100644 src/anycode/sandbox/runloop.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f42681c..72315e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -157,6 +157,9 @@ jobs: - extra: sandbox-modal sync-args: --extra sandbox-modal imports: modal anycode.sandbox.modal + - extra: sandbox-runloop + sync-args: --extra sandbox-runloop + imports: runloop_api_client anycode.sandbox.runloop - extra: all sync-args: --extra all imports: anycode diff --git a/pyproject.toml b/pyproject.toml index e5994be..7ae2b44 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,6 +105,9 @@ sandbox-e2b = [ sandbox-modal = [ "modal>=1.0", ] +sandbox-runloop = [ + "runloop-api-client>=0.30", +] all = [ "anthropic>=0.40", "openai>=1.50", diff --git a/src/anycode/__init__.py b/src/anycode/__init__.py index 750aff5..ced414c 100644 --- a/src/anycode/__init__.py +++ b/src/anycode/__init__.py @@ -195,6 +195,7 @@ E2BSandboxProvider, ModalSandboxProvider, PolicySandboxProvider, + RunloopSandboxProvider, SandboxCapabilities, SandboxCommand, SandboxProvider, @@ -612,6 +613,7 @@ "E2BSandboxProvider", "ModalSandboxProvider", "PolicySandboxProvider", + "RunloopSandboxProvider", "SandboxCapabilities", "SandboxCommand", "SandboxProvider", diff --git a/src/anycode/sandbox/__init__.py b/src/anycode/sandbox/__init__.py index 1c3558f..79dde8b 100644 --- a/src/anycode/sandbox/__init__.py +++ b/src/anycode/sandbox/__init__.py @@ -21,6 +21,7 @@ ) from anycode.sandbox.policy import PolicySandboxProvider from anycode.sandbox.protocol import SandboxProvider +from anycode.sandbox.runloop import RunloopSandboxProvider __all__ = [ "SANDBOX_CONTRACT_VERSION", @@ -31,6 +32,7 @@ "E2BSandboxProvider", "ModalSandboxProvider", "PolicySandboxProvider", + "RunloopSandboxProvider", "SandboxActionResult", "SandboxCapabilities", "SandboxCommand", diff --git a/src/anycode/sandbox/factory.py b/src/anycode/sandbox/factory.py index 4ab3fa7..4c0a5e9 100644 --- a/src/anycode/sandbox/factory.py +++ b/src/anycode/sandbox/factory.py @@ -12,6 +12,7 @@ "daytona": "sandbox", "e2b": "sandbox-e2b", "modal": "sandbox-modal", + "runloop": "sandbox-runloop", } @@ -34,5 +35,9 @@ def create_sandbox_provider(name: str, **kwargs: Any) -> SandboxProvider: from anycode.sandbox.modal import ModalSandboxProvider return ModalSandboxProvider(**kwargs) + if name == "runloop": + from anycode.sandbox.runloop import RunloopSandboxProvider + + return RunloopSandboxProvider(**kwargs) raise ValueError(f"Unknown sandbox provider: {name!r}. Available: {sorted(SANDBOX_PROVIDER_EXTRAS)}") diff --git a/src/anycode/sandbox/runloop.py b/src/anycode/sandbox/runloop.py new file mode 100644 index 0000000..1d2c3e0 --- /dev/null +++ b/src/anycode/sandbox/runloop.py @@ -0,0 +1,183 @@ +"""Runloop devbox sandbox provider adapter.""" + +from __future__ import annotations + +from collections.abc import AsyncIterable +from typing import Any + +from anycode.contracts.models import ContractError +from anycode.sandbox._base import ( + buffered_stream, + call_maybe_async, + first_guard_error, + network_policy_error, + secrets_unsupported_error, + shell_command, + to_bytes, +) +from anycode.sandbox.models import ( + SandboxActionResult, + SandboxCapabilities, + SandboxCommand, + SandboxCommandResult, + SandboxCreateResult, + SandboxEvidence, + SandboxFileResult, + SandboxHandle, + SandboxHealth, + SandboxOutputChunk, + SandboxSpec, +) +from anycode.security.redaction import safe_exception_message + + +class RunloopSandboxProvider: + """Runloop devboxes; ``RUNLOOP_API_KEY`` stays in SDK configuration.""" + + def __init__(self, client: Any | None = None) -> None: + self._client = client + + def _client_or_raise(self) -> Any: + if self._client is not None: + return self._client + try: + from runloop_api_client import AsyncRunloop # type: ignore[import-not-found] + except ImportError as error: + message = ( + 'RunloopSandboxProvider requires the optional "runloop_api_client" package. ' + 'Install it with: pip install "anycode-py[sandbox-runloop]"' + ) + raise ImportError(message) from error + self._client = AsyncRunloop() + return self._client + + async def create(self, spec: SandboxSpec) -> SandboxCreateResult: + guard = first_guard_error( + network_policy_error("runloop", spec, supported=("unrestricted",)), + secrets_unsupported_error("runloop", spec), + ) + if guard is not None: + return SandboxCreateResult(ok=False, error=guard) + try: + devboxes = self._client_or_raise().devboxes + kwargs: dict[str, Any] = { + "metadata": { + **spec.labels, + "anycode.run_id": spec.run_id, + "anycode.tenant": spec.context.tenant_scope, + "anycode.classification": spec.context.classification, + } + } + if spec.image: + kwargs["blueprint_name"] = spec.image + if spec.snapshot: + kwargs["snapshot_id"] = spec.snapshot + creator = getattr(devboxes, "create_and_await_running", None) or devboxes.create + devbox = await call_maybe_async(creator, **kwargs) + devbox_id = str(getattr(devbox, "id", "")) + handle = SandboxHandle( + id=devbox_id, + provider="runloop", + run_id=spec.run_id, + task_id=spec.task_id, + correlation_id=spec.correlation_id, + context=spec.context, + capabilities=self.capabilities(), + ) + return SandboxCreateResult(ok=True, handle=handle) + except Exception as error: + return SandboxCreateResult( + ok=False, + error=ContractError(code="sandbox_create_failed", message=safe_exception_message(error), retryable=True), + ) + + async def execute(self, handle: SandboxHandle, command: SandboxCommand) -> SandboxCommandResult: + try: + devboxes = self._client_or_raise().devboxes + result = await call_maybe_async(devboxes.execute_sync, handle.id, command=shell_command(command)) + stdout = str(getattr(result, "stdout", "") or "") + stderr = str(getattr(result, "stderr", "") or "") + exit_code = int(getattr(result, "exit_status", None) or getattr(result, "exit_code", 0) or 0) + evidence = SandboxEvidence.from_bytes("command", f"{stdout}\0{stderr}".encode(), metadata={"exit_code": exit_code}) + return SandboxCommandResult(ok=exit_code == 0, exit_code=exit_code, stdout=stdout, stderr=stderr, evidence=evidence) + except Exception as error: + return SandboxCommandResult( + ok=False, + error=ContractError(code="sandbox_command_failed", message=safe_exception_message(error), retryable=True), + ) + + def stream(self, handle: SandboxHandle, command: SandboxCommand) -> AsyncIterable[SandboxOutputChunk]: + return buffered_stream(self.execute, handle, command) + + async def write_file(self, handle: SandboxHandle, path: str, data: bytes) -> SandboxFileResult: + try: + devboxes = self._client_or_raise().devboxes + writer = getattr(devboxes, "upload_file", None) + if writer is not None: + await call_maybe_async(writer, handle.id, path=path, file=data) + else: + await call_maybe_async(devboxes.write_file_contents, handle.id, file_path=path, contents=data.decode("utf-8", errors="replace")) + return SandboxFileResult(ok=True, evidence=SandboxEvidence.from_bytes("file.write", data, metadata={"path": path})) + except Exception as error: + return SandboxFileResult(ok=False, error=ContractError(code="sandbox_file_write_failed", message=safe_exception_message(error))) + + async def read_file(self, handle: SandboxHandle, path: str) -> SandboxFileResult: + try: + devboxes = self._client_or_raise().devboxes + reader = getattr(devboxes, "download_file", None) or devboxes.read_file_contents + data = to_bytes(await call_maybe_async(reader, handle.id, file_path=path)) + return SandboxFileResult(ok=True, data=data, evidence=SandboxEvidence.from_bytes("file.read", data, metadata={"path": path})) + except Exception as error: + return SandboxFileResult(ok=False, error=ContractError(code="sandbox_file_read_failed", message=safe_exception_message(error))) + + async def cancel(self, handle: SandboxHandle) -> SandboxActionResult: + try: + devboxes = self._client_or_raise().devboxes + await call_maybe_async(devboxes.suspend, handle.id) + return SandboxActionResult(ok=True, evidence=SandboxEvidence.from_bytes("sandbox.cancel", handle.id.encode())) + except Exception as error: + return SandboxActionResult(ok=False, error=ContractError(code="sandbox_cancel_failed", message=safe_exception_message(error))) + + async def snapshot(self, handle: SandboxHandle, name: str) -> SandboxActionResult: + try: + devboxes = self._client_or_raise().devboxes + snapshot = await call_maybe_async(devboxes.snapshot_disk, handle.id) + reference = str(getattr(snapshot, "id", None) or snapshot) + evidence = SandboxEvidence.from_bytes("sandbox.snapshot", reference.encode(), metadata={"name": name}) + return SandboxActionResult(ok=True, reference=reference, evidence=evidence) + except Exception as error: + return SandboxActionResult(ok=False, error=ContractError(code="sandbox_snapshot_failed", message=safe_exception_message(error))) + + async def destroy(self, handle: SandboxHandle) -> SandboxActionResult: + try: + devboxes = self._client_or_raise().devboxes + await call_maybe_async(devboxes.shutdown, handle.id) + return SandboxActionResult(ok=True, evidence=SandboxEvidence.from_bytes("sandbox.destroy", handle.id.encode())) + except Exception as error: + return SandboxActionResult(ok=False, error=ContractError(code="sandbox_destroy_failed", message=safe_exception_message(error))) + + async def health(self) -> SandboxHealth: + try: + self._client_or_raise() + except Exception as error: + return SandboxHealth(status="unavailable", message=safe_exception_message(error)) + return SandboxHealth(status="healthy") + + def capabilities(self) -> SandboxCapabilities: + return SandboxCapabilities( + provider="runloop", + isolation="vm", + networking="unrestricted", + persistent_filesystem=True, + snapshots=True, + command_streaming=False, + cancellation=True, + file_transfer=True, + evidence=True, + limitations=( + "Network egress cannot be restricted through the stable adapter; network='none' and allowlists fail closed.", + "No managed secret store; sandbox secret references are rejected.", + "Command streaming is buffered: output arrives after the command completes.", + "Cancellation suspends the devbox; resume it from the Runloop console or API.", + ), + ) diff --git a/tests/test_sandbox_providers.py b/tests/test_sandbox_providers.py index 1b2c1f3..cd96629 100644 --- a/tests/test_sandbox_providers.py +++ b/tests/test_sandbox_providers.py @@ -13,6 +13,7 @@ DaytonaSandboxProvider, E2BSandboxProvider, ModalSandboxProvider, + RunloopSandboxProvider, SandboxCommand, SandboxProvider, SandboxSpec, @@ -284,6 +285,96 @@ async def test_modal_reports_missing_sdk_guidance(monkeypatch: pytest.MonkeyPatc assert "anycode-py[sandbox-modal]" in created.error.message +# --------------------------------------------------------------------------- +# Runloop fakes +# --------------------------------------------------------------------------- + + +class FakeRunloopDevboxes: + def __init__(self) -> None: + self.files: dict[str, bytes] = {} + self.suspended = False + self.shutdown_called = False + + async def create(self, **kwargs: object) -> SimpleNamespace: + del kwargs + return SimpleNamespace(id="devbox-1") + + async def execute_sync(self, devbox_id: str, *, command: str) -> SimpleNamespace: + assert devbox_id == "devbox-1" + return SimpleNamespace(stdout=f"ran:{command}", stderr="", exit_status=0) + + async def write_file_contents(self, devbox_id: str, *, file_path: str, contents: str) -> None: + assert devbox_id == "devbox-1" + self.files[file_path] = contents.encode("utf-8") + + async def read_file_contents(self, devbox_id: str, *, file_path: str) -> str: + assert devbox_id == "devbox-1" + return self.files[file_path].decode("utf-8") + + async def suspend(self, devbox_id: str) -> None: + assert devbox_id == "devbox-1" + self.suspended = True + + async def snapshot_disk(self, devbox_id: str) -> SimpleNamespace: + assert devbox_id == "devbox-1" + return SimpleNamespace(id="snapshot-1") + + async def shutdown(self, devbox_id: str) -> None: + assert devbox_id == "devbox-1" + self.shutdown_called = True + + +class FakeRunloopClient: + def __init__(self) -> None: + self.devboxes = FakeRunloopDevboxes() + + +async def test_runloop_provider_passes_lifecycle_conformance() -> None: + provider = RunloopSandboxProvider(FakeRunloopClient()) + await _assert_lifecycle_conformance(provider, snapshots=True) + + +async def test_runloop_maps_image_and_snapshot_to_blueprint_arguments() -> None: + client = FakeRunloopClient() + captured: dict[str, object] = {} + + async def create(**kwargs: object) -> SimpleNamespace: + captured.update(kwargs) + return SimpleNamespace(id="devbox-1") + + client.devboxes.create = create # type: ignore[method-assign] + provider = RunloopSandboxProvider(client) + + assert (await provider.create(_spec(image="py-blueprint"))).ok + assert captured["blueprint_name"] == "py-blueprint" + + assert (await provider.create(_spec(snapshot="snap-9"))).ok + assert captured["snapshot_id"] == "snap-9" + + +async def test_runloop_rejects_restricted_network_and_secrets() -> None: + provider = RunloopSandboxProvider(FakeRunloopClient()) + + denied_network = await provider.create(_spec(network="none")) + assert not denied_network.ok and denied_network.error is not None + assert denied_network.error.code == "sandbox_network_policy_unsupported" + + denied_secrets = await provider.create(_spec(secret_references={"API_KEY": "runloop:key"})) + assert not denied_secrets.ok and denied_secrets.error is not None + assert denied_secrets.error.code == "sandbox_secrets_unsupported" + + +async def test_runloop_reports_missing_sdk_guidance(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setitem(sys.modules, "runloop_api_client", None) + provider = RunloopSandboxProvider() + + created = await provider.create(_spec()) + + assert not created.ok and created.error is not None + assert "anycode-py[sandbox-runloop]" in created.error.message + + def test_factory_builds_daytona_provider() -> None: provider = create_sandbox_provider("daytona") assert isinstance(provider, DaytonaSandboxProvider) diff --git a/uv.lock b/uv.lock index 8e621cc..0a3253b 100644 --- a/uv.lock +++ b/uv.lock @@ -273,6 +273,9 @@ sandbox-e2b = [ sandbox-modal = [ { name = "modal" }, ] +sandbox-runloop = [ + { name = "runloop-api-client" }, +] telemetry = [ { name = "opentelemetry-api" }, { name = "opentelemetry-exporter-otlp-proto-grpc" }, @@ -354,12 +357,13 @@ requires-dist = [ { name = "redis", extras = ["hiredis"], marker = "extra == 'redis'", specifier = ">=5.0" }, { name = "rich", marker = "extra == 'all'", specifier = ">=13.0" }, { name = "rich", marker = "extra == 'cli'", specifier = ">=13.0" }, + { name = "runloop-api-client", marker = "extra == 'sandbox-runloop'", specifier = ">=0.30" }, { name = "tiktoken", marker = "extra == 'all'", specifier = ">=0.8" }, { name = "tiktoken", marker = "extra == 'tokens'", specifier = ">=0.8" }, { name = "typer", marker = "extra == 'all'", specifier = ">=0.12" }, { name = "typer", marker = "extra == 'cli'", specifier = ">=0.12" }, ] -provides-extras = ["anthropic", "openai", "telemetry", "persistence", "redis", "tokens", "vector", "google", "ollama", "bedrock", "azure", "providers", "mcp", "cli", "sandbox", "sandbox-e2b", "sandbox-modal", "all"] +provides-extras = ["anthropic", "openai", "telemetry", "persistence", "redis", "tokens", "vector", "google", "ollama", "bedrock", "azure", "providers", "mcp", "cli", "sandbox", "sandbox-e2b", "sandbox-modal", "sandbox-runloop", "all"] [package.metadata.requires-dev] dev = [ @@ -1535,6 +1539,11 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" }, ] +[package.optional-dependencies] +http2 = [ + { name = "h2" }, +] + [[package]] name = "httpx-sse" version = "0.4.3" @@ -3717,6 +3726,24 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/15/e2/77be4fff062fa78d9b2a4dea85d14785dac5f1d0c1fb58ed52331f0ebe28/ruff-0.15.8-py3-none-win_arm64.whl", hash = "sha256:cf891fa8e3bb430c0e7fac93851a5978fc99c8fa2c053b57b118972866f8e5f2", size = 11048175, upload-time = "2026-03-26T18:40:01.06Z" }, ] +[[package]] +name = "runloop-api-client" +version = "1.24.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "distro" }, + { name = "httpx", extra = ["http2"] }, + { name = "pydantic" }, + { name = "sniffio" }, + { name = "typing-extensions" }, + { name = "uuid-utils" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/79/b6/0ae77e09a0625a595a1a96602c7da094736b944858a123eecb4f24fa52f5/runloop_api_client-1.24.0.tar.gz", hash = "sha256:27824e86b52302bd92ebbe896e1fea407a59ff2b4e9482541875d64eb80b1f6d", size = 652367, upload-time = "2026-07-22T22:27:33.669Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3f/0d/db34f906095acf821ceaea11b1b7ab8b9bd560f9a0871769522f6077eb25/runloop_api_client-1.24.0-py3-none-any.whl", hash = "sha256:55da80a2c3a061d65e396ca5f200d1b44dd7cff10f1eaf963b21a8a672680506", size = 400882, upload-time = "2026-07-22T22:27:32.004Z" }, +] + [[package]] name = "s3transfer" version = "0.16.0" @@ -4026,6 +4053,72 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/39/08/aaaad47bc4e9dc8c725e68f9d04865dbcb2052843ff09c97b08904852d84/urllib3-2.6.3-py3-none-any.whl", hash = "sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4", size = 131584, upload-time = "2026-01-07T16:24:42.685Z" }, ] +[[package]] +name = "uuid-utils" +version = "0.17.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e7/91/63938e0e7e7876658e5e40178e7c0735b53527886fe11797a11699c55edd/uuid_utils-0.17.0.tar.gz", hash = "sha256:abb5667a36119019b3fa320c4d10c21ebccfcc87c8a739e6a0056cee7f48dde2", size = 43220, upload-time = "2026-07-09T13:49:58.433Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/20/80/a7e685968e3cec99d6fe2fb25d0f5726310e1bba356da68c13dfd8b7d140/uuid_utils-0.17.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:9205068badf453d2f0821fd5d340389b4679992d7ff79d4f3e5608996dd1b287", size = 556403, upload-time = "2026-07-09T13:48:27.022Z" }, + { url = "https://files.pythonhosted.org/packages/56/47/3102d93bcb7b0bfe6bede63ff8f221a7f91348e10a37f682773be27c56d9/uuid_utils-0.17.0-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:0fcca4e838af9ac9243b3358d7c14afa4dca286a87781124c272d6c4cad9c968", size = 285608, upload-time = "2026-07-09T13:48:28.769Z" }, + { url = "https://files.pythonhosted.org/packages/55/fb/d59695f0f8db065b93c63316eaafa05a22d75a0486978a33736c52c646d5/uuid_utils-0.17.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0f3729e839209f3457d0d8b6a35a376fdf65577a5aecaf4cc3587d3305759ba6", size = 319926, upload-time = "2026-07-09T13:48:29.965Z" }, + { url = "https://files.pythonhosted.org/packages/5a/03/62fabcd1e990e07a0e220e8d552af45bc16f107fa8e55c2014a706bb1a1e/uuid_utils-0.17.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:3dac0ad0cd9a2818d1775215365a4e8c2f8ada215529dd26f3f8cceeb67a6988", size = 327172, upload-time = "2026-07-09T13:48:31.187Z" }, + { url = "https://files.pythonhosted.org/packages/d9/37/a5081391338b459e2f8d8b12581f00f8caa6317fab510e0e85c18c59e938/uuid_utils-0.17.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e671b2322ef09106ecb1ca0f4c398b134d5e2c1f80d7a4f3336847a3072c0e94", size = 439075, upload-time = "2026-07-09T13:48:32.295Z" }, + { url = "https://files.pythonhosted.org/packages/59/30/91795bd01e17a13661280d4899fbf38fb05e3f38e873f9aaec106ec30aa0/uuid_utils-0.17.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8eb3e5caca8d3a6f72ea4cce024583f989f6f2e9186f98800213fff0176e8bcc", size = 320247, upload-time = "2026-07-09T13:48:33.64Z" }, + { url = "https://files.pythonhosted.org/packages/e5/11/09102b78303e4eb62069d6d88ef9fd661dc523e8f429e1fd67eaa78a6f44/uuid_utils-0.17.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:8b72c2002202038666bf647f9a790906214c7c11cd0d6efef77b7d07bef3034a", size = 344738, upload-time = "2026-07-09T13:48:34.786Z" }, + { url = "https://files.pythonhosted.org/packages/74/f9/be95bad6954b60328878c3800258f01a6accd24fd75112d13f023462d53f/uuid_utils-0.17.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:4e2ac1c0b56f2c91b6f158e29ed96b1503223fe8aa6e79b1be1dc55bd8a5131c", size = 496845, upload-time = "2026-07-09T13:48:36.057Z" }, + { url = "https://files.pythonhosted.org/packages/2d/02/8a19a34e0530d987488a068a71576a236f5c8c746630b870b57f71eb24ef/uuid_utils-0.17.0-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:6c142bd0cb4dba31c10babe00d59f7ef6460f0ef55eaa9c1a9da270684af996a", size = 603233, upload-time = "2026-07-09T13:48:37.512Z" }, + { url = "https://files.pythonhosted.org/packages/f4/a8/b1abab36ff73b0248d82179816467f6d39a2e80fd64329a895ca94f3508e/uuid_utils-0.17.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:e252db239eb41c32248e096e0d170bce5896a4fd3405556362bc3dd83d912206", size = 561401, upload-time = "2026-07-09T13:48:38.977Z" }, + { url = "https://files.pythonhosted.org/packages/61/91/70e7b528b351cc03a9ca43e6116371cdde31bb12bcead7ca2ca1367366cc/uuid_utils-0.17.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:237722b6581bb5b4eb4cefbcbe5c6e2980a440aabe781fbe50ebf1cb71eee4cc", size = 525314, upload-time = "2026-07-09T13:48:40.599Z" }, + { url = "https://files.pythonhosted.org/packages/d6/f6/9167e90cf9937d6558f92d022ff3024a69d938a514d9c8faa4080f73b001/uuid_utils-0.17.0-cp312-cp312-win32.whl", hash = "sha256:46a73cacdf512f473a81f65dbf84186e08cfe6e9118fa582b6c6b33a8288a30d", size = 166831, upload-time = "2026-07-09T13:48:41.862Z" }, + { url = "https://files.pythonhosted.org/packages/5c/7d/0b889654d9ee3413f810cf4685e241285f650d98a4103ac9f3c6bcc95f29/uuid_utils-0.17.0-cp312-cp312-win_amd64.whl", hash = "sha256:e59b60a0a4cb7541480e02090d37dc2df3b72df4c2e776fff64ce3a4e3dd4637", size = 172944, upload-time = "2026-07-09T13:48:42.992Z" }, + { url = "https://files.pythonhosted.org/packages/be/35/8c6e1bf65e4d400352885dadc656ad6d0af96e89231e3f04686bc2197128/uuid_utils-0.17.0-cp312-cp312-win_arm64.whl", hash = "sha256:d561a4c5747a1e6c7fa7c49a0292e78b4e8c456332caa084fc7abad8de828652", size = 172459, upload-time = "2026-07-09T13:48:44.271Z" }, + { url = "https://files.pythonhosted.org/packages/d2/dd/614fb9912157ac0128e6050859ccf06d9f13df9a944a803e8f80f6157e38/uuid_utils-0.17.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:d11a7bc1e02da8984d32e6de9e0826c6edac00eac17de270f372bf32f9a0af63", size = 557259, upload-time = "2026-07-09T13:48:45.664Z" }, + { url = "https://files.pythonhosted.org/packages/3e/11/d072711704de3d21bec08b6c2f36a215200ca1d5e01a390ea1ac434080a0/uuid_utils-0.17.0-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:7a49f47ac26df3e431c56b825c1bae8e6d3d591fdbb7438c227cc9845a7e3d73", size = 286271, upload-time = "2026-07-09T13:48:47.018Z" }, + { url = "https://files.pythonhosted.org/packages/18/6d/8a63e5eb2d5a6ba69a6c2036e305075bd6f5a022e7ea25fc6ce0eb7c51d2/uuid_utils-0.17.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:32df1944808877702ceea398c103881c09a679bb672a215e01c2a84231266bf9", size = 320025, upload-time = "2026-07-09T13:48:48.208Z" }, + { url = "https://files.pythonhosted.org/packages/f7/2d/bdc2caf9719d9090d7c46043242ae6136cba4f7a7ee384992ab905ad9aa1/uuid_utils-0.17.0-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:98c88d3edd08e7245562e9815996dbc6f0bd4745e1c76462f24af5ae4e187dd1", size = 327931, upload-time = "2026-07-09T13:48:49.673Z" }, + { url = "https://files.pythonhosted.org/packages/b6/33/9219d09d51ead282b578b2a4e0a515c2cce3ec52076cada8bfb7e35727d5/uuid_utils-0.17.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5a4370089c8b2e42f1db51d76408c7fa8eaa2934bf854d17983d16179c07c098", size = 438537, upload-time = "2026-07-09T13:48:50.842Z" }, + { url = "https://files.pythonhosted.org/packages/d8/79/e8e0f8b3955f2081c116157119d87659937893242eb834aa170da04d660b/uuid_utils-0.17.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:09a55b7a5ae764985cb46467496a1787678d0a1400356157a080ad95b1a36869", size = 320656, upload-time = "2026-07-09T13:48:52.164Z" }, + { url = "https://files.pythonhosted.org/packages/d5/5e/d1ceddc430ff04b6e21704b2030d4438074a2f478b265dab43da957791c1/uuid_utils-0.17.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:56aa6488b931246fae11924e4bd0e2b32677e63945eecb71c29e3c2ca0dc3131", size = 345310, upload-time = "2026-07-09T13:48:54.076Z" }, + { url = "https://files.pythonhosted.org/packages/d5/62/89438e12f389a843e626b7e37691319a057b3d6b80914609106891faadda/uuid_utils-0.17.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:309a35f12d99dde19032bc2259cda6431c85eeac0879134dc777cc3087d7e1cb", size = 496771, upload-time = "2026-07-09T13:48:55.365Z" }, + { url = "https://files.pythonhosted.org/packages/87/d2/eedcd99f522d60e238ead03844f0d51743ba84d33044959e230b756bf212/uuid_utils-0.17.0-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:21c79b61ff750abcf057163dd764ccb6196cde7a26cda1b31b45cd97769e03b3", size = 603631, upload-time = "2026-07-09T13:48:56.746Z" }, + { url = "https://files.pythonhosted.org/packages/0e/a8/bb1b38aaddd7243b6e562c6694f499bf094800918316192fd8cb2cdc2620/uuid_utils-0.17.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:4134353bfe3026ddab8e886002dc52bc5a0ab04611aabb0eaae23c32e6e57f64", size = 562008, upload-time = "2026-07-09T13:48:58.241Z" }, + { url = "https://files.pythonhosted.org/packages/b4/77/5f7ed930dc105e293845c09e4d5bd84076318a12f45a46783e1af64906d7/uuid_utils-0.17.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:7c89359affecebe2e39e6a116d069b363c936511a9572b308402489a26957d89", size = 525527, upload-time = "2026-07-09T13:48:59.784Z" }, + { url = "https://files.pythonhosted.org/packages/fd/25/1b55697adf6811a6f92cff6340e6b03e31fd6bc51066a5c10698c29b3679/uuid_utils-0.17.0-cp313-cp313-pyemscripten_2025_0_wasm32.whl", hash = "sha256:6a019a31bc4db89a0903a3e4f6b218571f3a6ff0ad4b3d3fe1c8f91a05ff6e3e", size = 97965, upload-time = "2026-07-09T13:49:01.217Z" }, + { url = "https://files.pythonhosted.org/packages/26/bf/cd729343de4684230be8a966bad7bfc2cf10ce3e643b1189a8b5370dbe35/uuid_utils-0.17.0-cp313-cp313-win32.whl", hash = "sha256:b3131a82d0c7611f0aa480a6d36929e001a3f54ba0fc029a8118a5863cce513c", size = 167316, upload-time = "2026-07-09T13:49:02.354Z" }, + { url = "https://files.pythonhosted.org/packages/76/f0/e602ae0a1b139a7826e5189b93d91902564def06d5006324fd2faf82c8fc/uuid_utils-0.17.0-cp313-cp313-win_amd64.whl", hash = "sha256:9e311f908d2f842fca4c7dcebc4f10306b8089b204ef04cf6704b4332c9ff6ff", size = 173630, upload-time = "2026-07-09T13:49:03.529Z" }, + { url = "https://files.pythonhosted.org/packages/1a/52/024ebece265b387154115dc4f1d9727174ef82623069f4bec8b7ed7e73f7/uuid_utils-0.17.0-cp313-cp313-win_arm64.whl", hash = "sha256:c351737e2e65497c7200ab4ffb8af97e9f48be6488309abdd265fe08d66ee92f", size = 173214, upload-time = "2026-07-09T13:49:04.836Z" }, + { url = "https://files.pythonhosted.org/packages/56/44/e2fd3fdf356e1b55d2acf1b956b4f3f29ffb215a99c387eba04b1c5fba66/uuid_utils-0.17.0-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:673d89cc434cc9b97a0b4cf61272f6fca70a81f64eb0afbface2a0d9f77f06cd", size = 562232, upload-time = "2026-07-09T13:49:06.201Z" }, + { url = "https://files.pythonhosted.org/packages/19/28/65e0980d668a6d44e699f59d1acf43d6b5d4893592c115ce7c680bb4dfa1/uuid_utils-0.17.0-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:387cf7437c94ddec08651a0f1081381299c7075bc48a6251d8922bf39973378a", size = 287858, upload-time = "2026-07-09T13:49:07.45Z" }, + { url = "https://files.pythonhosted.org/packages/8f/8d/5e97bcebc90fb6a10f98af3dc1ba552e04183aba59e2edc0b9cf486dd998/uuid_utils-0.17.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:220b52746d99e11964badac3c0869016e0c24bafb70a7dd5c2c072a6be3da9cc", size = 321587, upload-time = "2026-07-09T13:49:09.489Z" }, + { url = "https://files.pythonhosted.org/packages/8b/d7/88b2a2370cc3d455ba0515fb6f5c8f7ac0c0f55a86801b6e56a432f22c17/uuid_utils-0.17.0-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0ab4a66e7a035ad6625cfc1fbdb34f5c2d25a80ae1ef4bfee458ea2036333c6d", size = 328964, upload-time = "2026-07-09T13:49:11.292Z" }, + { url = "https://files.pythonhosted.org/packages/bd/0f/181c5da673953dfc0958cb4fb3a4984a9098673ddb05cac68e994bc8511b/uuid_utils-0.17.0-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5641071337eb11d61a001ea08793bf72216f3241f0a433ed2764804b2a3e3cc7", size = 442909, upload-time = "2026-07-09T13:49:12.644Z" }, + { url = "https://files.pythonhosted.org/packages/ec/38/5c5e665af542884a8fd3c61725c38453239e13940326b5b70f3ef8881a97/uuid_utils-0.17.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9082e709014946b1f6e96ae6ecd93652efca2d2a6a3ab67dbe151c8b4bf193a4", size = 323076, upload-time = "2026-07-09T13:49:13.897Z" }, + { url = "https://files.pythonhosted.org/packages/f5/35/7de97de18cbf226c2a4f2104ad15e56ca4491717c81c0b71795c0c585b4e/uuid_utils-0.17.0-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1fd6f0e8a162dc0e9255b6aebe3cd175e76c33202f1bf39da9e6294b93db0099", size = 347360, upload-time = "2026-07-09T13:49:15.237Z" }, + { url = "https://files.pythonhosted.org/packages/26/a1/9915d5dd59fdd1957ded5d188c0ea0b9db5a1d84d42c8d8828a7b83b366e/uuid_utils-0.17.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:d63010803d7c368963bbe6f7ec379593e76dd581d7db0f29118d88713c9e0354", size = 499267, upload-time = "2026-07-09T13:49:16.774Z" }, + { url = "https://files.pythonhosted.org/packages/c0/05/88108405262ec850cea0f95733445d6873e5772af3292baabd9ef8457740/uuid_utils-0.17.0-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:a46bedc273b6f58f11dee816ff74999625ef8d007890f411b7a4975bf1c89330", size = 604940, upload-time = "2026-07-09T13:49:18.147Z" }, + { url = "https://files.pythonhosted.org/packages/89/d5/6dbcd300de47cc443cff2656cd5327a385751213dcb2101cfee7388170b2/uuid_utils-0.17.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:405233a5f625b3d995648f4647fa6befa4567cf3f74e1f6b9837e16f7310f0e0", size = 564172, upload-time = "2026-07-09T13:49:19.593Z" }, + { url = "https://files.pythonhosted.org/packages/ab/94/e8057f2288a415fba8a978bca4b589f5cb6b91a028a5dc07a1775938b33f/uuid_utils-0.17.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:b6c5d2d71e1f17329150ad9427d27f4a3f29a01792e7ecdc64a98ac5368fc4d5", size = 528533, upload-time = "2026-07-09T13:49:21.075Z" }, + { url = "https://files.pythonhosted.org/packages/f0/6b/31713148c77e48e62f51aa042a98a54a8be0396912ea5130f83f52ae722d/uuid_utils-0.17.0-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:f7e9b8728ba07a3cb2f29d5aa1a266c2664eb8ef0fd43afa34627c92f7fac8f0", size = 99197, upload-time = "2026-07-09T13:49:22.351Z" }, + { url = "https://files.pythonhosted.org/packages/f3/f3/ca6f6ac5428312df8ed632f6dd9f9e6aba23090471fcdeae53eab027e8b3/uuid_utils-0.17.0-cp314-cp314-win32.whl", hash = "sha256:58838921e377791ef22c64cc92141bfae030f43651ff9272f0f28a208a9e6a5a", size = 169540, upload-time = "2026-07-09T13:49:23.563Z" }, + { url = "https://files.pythonhosted.org/packages/c6/cd/7ede0db66411fa09817d79b680f7454ea9bee2d374e1922e4efd065760a3/uuid_utils-0.17.0-cp314-cp314-win_amd64.whl", hash = "sha256:42275ebd0e8e74e32cdbfb8bd88fc99576567d51d54a508020611fd8f4f463a0", size = 175984, upload-time = "2026-07-09T13:49:24.703Z" }, + { url = "https://files.pythonhosted.org/packages/f0/81/533b5f80cd4918c0693f4e1b7b90ceb1caa45f4266ae8b528135d7ecca5d/uuid_utils-0.17.0-cp314-cp314-win_arm64.whl", hash = "sha256:b5d11cccba076a32321ef1380dea956821f0b51794ef59df64e58fb1cd543aae", size = 174749, upload-time = "2026-07-09T13:49:25.886Z" }, + { url = "https://files.pythonhosted.org/packages/a0/13/f400ac39d06fd8be5b099c09e41bb975205926722a3e8d53348817cb7ff9/uuid_utils-0.17.0-cp314-cp314t-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:fae8b282f0cb22a5de222999f7723f4e5ec04f6fcdf4aaef879b5b36625ae2b0", size = 562610, upload-time = "2026-07-09T13:49:27.374Z" }, + { url = "https://files.pythonhosted.org/packages/03/8c/c71c8312304c56f6d0bcba87cd402fa79bec35d18ffc8c41954196ca68e5/uuid_utils-0.17.0-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:967955620df45e6cffe2e9950cb9903cb455649396f896b26b04363a91a5054b", size = 289473, upload-time = "2026-07-09T13:49:28.989Z" }, + { url = "https://files.pythonhosted.org/packages/bb/cd/522117e2e5184ca1d4f0f85ee833e9e21bd8c6b99eff8a4d1a8e5a194e33/uuid_utils-0.17.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:375cde148430d60a4a07c03abaa0774c4fddfdd90de99b4ba02f24088bc9d750", size = 321600, upload-time = "2026-07-09T13:49:30.4Z" }, + { url = "https://files.pythonhosted.org/packages/6d/f4/0d81f9bd346fc717bc561c08fa6457e0328966eb76e536b938fe77d56459/uuid_utils-0.17.0-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:975c17da26c5b9d46c336b03c52a057ac28378d6f9d98b58d32a038589bb3912", size = 329569, upload-time = "2026-07-09T13:49:31.732Z" }, + { url = "https://files.pythonhosted.org/packages/5e/41/26e1363f36a94c9e8ec2dd21d5f63088d3e7c723adbb12dcc8fdc77be417/uuid_utils-0.17.0-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3150d836290c88f1d26eb59c4db280d87417dd3bfaadd2889c77416c8f0ff6fa", size = 442051, upload-time = "2026-07-09T13:49:33.024Z" }, + { url = "https://files.pythonhosted.org/packages/2b/a7/2c1ed1b34d7df7fdcc11c28fd26d94d44843b37d9af2435ff9fd8abdbc08/uuid_utils-0.17.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9472a8de37faf8bd216c628e0e68c8f6bef730d3ba0a5060f3b0fa460c992ac2", size = 324372, upload-time = "2026-07-09T13:49:34.554Z" }, + { url = "https://files.pythonhosted.org/packages/78/bf/328d3c6bb22c496944a1b3b732207d71aa6964eb604e5e3b9dcb91ed0a00/uuid_utils-0.17.0-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d27c531edb8d1f38ca2eddaa1fa24913a460aeb721f2efd4ef42a124ce94e354", size = 348548, upload-time = "2026-07-09T13:49:35.898Z" }, + { url = "https://files.pythonhosted.org/packages/3e/76/a07de5cb7b90582fdbbc830fd19be129cbbb9897cfe239fef469d7bd2d09/uuid_utils-0.17.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:5670c52a438e21483ce715776144914a4e2a2a5c62d9dee15f8a3e90cf128ae6", size = 498985, upload-time = "2026-07-09T13:49:37.142Z" }, + { url = "https://files.pythonhosted.org/packages/f4/62/9966e46ae34fcec6b06119631fb3c09705ea78835035ce3a82d3348eb61a/uuid_utils-0.17.0-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:6f29689a76fe7a49cbd629a794d0ec1eab48814e323a00a146a741b0195bde68", size = 605183, upload-time = "2026-07-09T13:49:38.648Z" }, + { url = "https://files.pythonhosted.org/packages/d7/4e/bb962ba0fe31e903b199f22cf4c1a6cba35a8987aef526d287277ab8ca8b/uuid_utils-0.17.0-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:4441600447d340ae103a353f01dbcd22ff680e5ee1a22988efe8d7b791d8fdb3", size = 565412, upload-time = "2026-07-09T13:49:40.115Z" }, + { url = "https://files.pythonhosted.org/packages/ce/9e/122adfeeeae8a84ccfd43bce627b104d12a2180a93bffd2c0e1b54dad7a6/uuid_utils-0.17.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:e7b04935a79c03c41ad08d0a5f390aac968bfb561f1268897bc5b0f077971efd", size = 529885, upload-time = "2026-07-09T13:49:41.513Z" }, + { url = "https://files.pythonhosted.org/packages/b3/4f/257304dded339dc35fc9bf35722ac68fd4fdb930f255b8f7bccdf74ebba9/uuid_utils-0.17.0-cp314-cp314t-win32.whl", hash = "sha256:239d8a281fe10bae33205b5d43185834d556b18434e0a113b5dc1dfb2fd97e91", size = 169472, upload-time = "2026-07-09T13:49:42.871Z" }, + { url = "https://files.pythonhosted.org/packages/35/c8/e78c06db7e9ce317ce7b8759ff2058333eac75caa8c22b75f0059589c9be/uuid_utils-0.17.0-cp314-cp314t-win_amd64.whl", hash = "sha256:e288a06cbbbcd01b44386e767985c9e21d2ad9bf59829aa7058d9a2a494804ab", size = 176271, upload-time = "2026-07-09T13:49:44.105Z" }, + { url = "https://files.pythonhosted.org/packages/a7/11/bd1c70e1ad3301163cebe66c8d26de26e6814d52f642a849448bd2833626/uuid_utils-0.17.0-cp314-cp314t-win_arm64.whl", hash = "sha256:1776a80d16369999b21627028cc5dbce819be83e1e079fdd7a51b587d2916db9", size = 175004, upload-time = "2026-07-09T13:49:45.591Z" }, +] + [[package]] name = "uvicorn" version = "0.43.0" From b384235c108e9f1946bff40b6b3add382730aa5a Mon Sep 17 00:00:00 2001 From: Ali Muhammad Date: Fri, 24 Jul 2026 07:13:40 +0500 Subject: [PATCH 6/8] feat(sandbox): add vercel sandbox provider --- .github/workflows/ci.yml | 3 + pyproject.toml | 3 + src/anycode/__init__.py | 2 + src/anycode/sandbox/__init__.py | 2 + src/anycode/sandbox/factory.py | 5 + src/anycode/sandbox/vercel.py | 178 ++++++++++++++++++++++++++++++++ tests/test_sandbox_providers.py | 87 ++++++++++++++++ uv.lock | 93 ++++++++++++++++- 8 files changed, 372 insertions(+), 1 deletion(-) create mode 100644 src/anycode/sandbox/vercel.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72315e3..17d1809 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -160,6 +160,9 @@ jobs: - extra: sandbox-runloop sync-args: --extra sandbox-runloop imports: runloop_api_client anycode.sandbox.runloop + - extra: sandbox-vercel + sync-args: --extra sandbox-vercel + imports: vercel anycode.sandbox.vercel - extra: all sync-args: --extra all imports: anycode diff --git a/pyproject.toml b/pyproject.toml index 7ae2b44..8928cde 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,6 +108,9 @@ sandbox-modal = [ sandbox-runloop = [ "runloop-api-client>=0.30", ] +sandbox-vercel = [ + "vercel>=0.1,<1", +] all = [ "anthropic>=0.40", "openai>=1.50", diff --git a/src/anycode/__init__.py b/src/anycode/__init__.py index ced414c..c6653db 100644 --- a/src/anycode/__init__.py +++ b/src/anycode/__init__.py @@ -200,6 +200,7 @@ SandboxCommand, SandboxProvider, SandboxSpec, + VercelSandboxProvider, create_sandbox_provider, ) from anycode.schedule.scheduler import RunScheduler, SweepReport, sweep_once @@ -618,6 +619,7 @@ "SandboxCommand", "SandboxProvider", "SandboxSpec", + "VercelSandboxProvider", "create_sandbox_provider", # Managed hosting "A2A_AGENT_CARD_PATH", diff --git a/src/anycode/sandbox/__init__.py b/src/anycode/sandbox/__init__.py index 79dde8b..d035b83 100644 --- a/src/anycode/sandbox/__init__.py +++ b/src/anycode/sandbox/__init__.py @@ -22,6 +22,7 @@ from anycode.sandbox.policy import PolicySandboxProvider from anycode.sandbox.protocol import SandboxProvider from anycode.sandbox.runloop import RunloopSandboxProvider +from anycode.sandbox.vercel import VercelSandboxProvider __all__ = [ "SANDBOX_CONTRACT_VERSION", @@ -45,5 +46,6 @@ "SandboxOutputChunk", "SandboxProvider", "SandboxSpec", + "VercelSandboxProvider", "create_sandbox_provider", ] diff --git a/src/anycode/sandbox/factory.py b/src/anycode/sandbox/factory.py index 4c0a5e9..dac313b 100644 --- a/src/anycode/sandbox/factory.py +++ b/src/anycode/sandbox/factory.py @@ -13,6 +13,7 @@ "e2b": "sandbox-e2b", "modal": "sandbox-modal", "runloop": "sandbox-runloop", + "vercel": "sandbox-vercel", } @@ -39,5 +40,9 @@ def create_sandbox_provider(name: str, **kwargs: Any) -> SandboxProvider: from anycode.sandbox.runloop import RunloopSandboxProvider return RunloopSandboxProvider(**kwargs) + if name == "vercel": + from anycode.sandbox.vercel import VercelSandboxProvider + + return VercelSandboxProvider(**kwargs) raise ValueError(f"Unknown sandbox provider: {name!r}. Available: {sorted(SANDBOX_PROVIDER_EXTRAS)}") diff --git a/src/anycode/sandbox/vercel.py b/src/anycode/sandbox/vercel.py new file mode 100644 index 0000000..5db21c3 --- /dev/null +++ b/src/anycode/sandbox/vercel.py @@ -0,0 +1,178 @@ +"""Vercel Sandbox provider adapter.""" + +from __future__ import annotations + +from collections.abc import AsyncIterable +from typing import Any + +from anycode.contracts.models import ContractError +from anycode.sandbox._base import ( + buffered_stream, + call_maybe_async, + first_guard_error, + network_policy_error, + read_streamish, + secrets_unsupported_error, + shell_command, + snapshot_restore_unsupported_error, + to_bytes, +) +from anycode.sandbox.models import ( + SandboxActionResult, + SandboxCapabilities, + SandboxCommand, + SandboxCommandResult, + SandboxCreateResult, + SandboxEvidence, + SandboxFileResult, + SandboxHandle, + SandboxHealth, + SandboxOutputChunk, + SandboxSpec, +) +from anycode.security.redaction import safe_exception_message + + +class VercelSandboxProvider: + """Vercel Sandbox microVMs; auth stays in Vercel SDK env configuration.""" + + def __init__(self, client: Any | None = None) -> None: + self._client = client + self._sandboxes: dict[str, Any] = {} + + def _client_or_raise(self) -> Any: + if self._client is not None: + return self._client + try: + from vercel.sandbox import AsyncSandbox # type: ignore[import-not-found] + except ImportError as error: + message = 'VercelSandboxProvider requires the optional "vercel" package. Install it with: pip install "anycode-py[sandbox-vercel]"' + raise ImportError(message) from error + self._client = AsyncSandbox + return self._client + + async def _resolve(self, handle: SandboxHandle) -> Any: + sandbox = self._sandboxes.get(handle.id) + if sandbox is not None: + return sandbox + sandbox = await call_maybe_async(self._client_or_raise().get, sandbox_id=handle.id) + self._sandboxes[handle.id] = sandbox + return sandbox + + async def create(self, spec: SandboxSpec) -> SandboxCreateResult: + guard = first_guard_error( + network_policy_error("vercel", spec, supported=("unrestricted",)), + secrets_unsupported_error("vercel", spec), + snapshot_restore_unsupported_error("vercel", spec), + ) + if guard is not None: + return SandboxCreateResult(ok=False, error=guard) + try: + sandbox_cls = self._client_or_raise() + kwargs: dict[str, Any] = {} + if spec.image: + kwargs["runtime"] = spec.image + sandbox = await call_maybe_async(sandbox_cls.create, **kwargs) + sandbox_id = str(getattr(sandbox, "sandbox_id", None) or getattr(sandbox, "id", "")) + self._sandboxes[sandbox_id] = sandbox + handle = SandboxHandle( + id=sandbox_id, + provider="vercel", + run_id=spec.run_id, + task_id=spec.task_id, + correlation_id=spec.correlation_id, + context=spec.context, + capabilities=self.capabilities(), + ) + return SandboxCreateResult(ok=True, handle=handle) + except Exception as error: + return SandboxCreateResult( + ok=False, + error=ContractError(code="sandbox_create_failed", message=safe_exception_message(error), retryable=True), + ) + + async def execute(self, handle: SandboxHandle, command: SandboxCommand) -> SandboxCommandResult: + try: + sandbox = await self._resolve(handle) + cmd = await call_maybe_async(sandbox.run_command, "bash", ["-lc", shell_command(command)]) + stdout = await read_streamish(getattr(cmd, "stdout", "")) + stderr = await read_streamish(getattr(cmd, "stderr", "")) + exit_code = int(getattr(cmd, "exit_code", 0) or 0) + evidence = SandboxEvidence.from_bytes("command", f"{stdout}\0{stderr}".encode(), metadata={"exit_code": exit_code}) + return SandboxCommandResult(ok=exit_code == 0, exit_code=exit_code, stdout=stdout, stderr=stderr, evidence=evidence) + except Exception as error: + return SandboxCommandResult( + ok=False, + error=ContractError(code="sandbox_command_failed", message=safe_exception_message(error), retryable=True), + ) + + def stream(self, handle: SandboxHandle, command: SandboxCommand) -> AsyncIterable[SandboxOutputChunk]: + return buffered_stream(self.execute, handle, command) + + async def write_file(self, handle: SandboxHandle, path: str, data: bytes) -> SandboxFileResult: + try: + sandbox = await self._resolve(handle) + await call_maybe_async(sandbox.write_files, [{"path": path, "content": data}]) + return SandboxFileResult(ok=True, evidence=SandboxEvidence.from_bytes("file.write", data, metadata={"path": path})) + except Exception as error: + return SandboxFileResult(ok=False, error=ContractError(code="sandbox_file_write_failed", message=safe_exception_message(error))) + + async def read_file(self, handle: SandboxHandle, path: str) -> SandboxFileResult: + try: + sandbox = await self._resolve(handle) + data = to_bytes(await call_maybe_async(sandbox.read_file, path)) + return SandboxFileResult(ok=True, data=data, evidence=SandboxEvidence.from_bytes("file.read", data, metadata={"path": path})) + except Exception as error: + return SandboxFileResult(ok=False, error=ContractError(code="sandbox_file_read_failed", message=safe_exception_message(error))) + + async def cancel(self, handle: SandboxHandle) -> SandboxActionResult: + try: + sandbox = await self._resolve(handle) + await call_maybe_async(sandbox.stop) + return SandboxActionResult(ok=True, evidence=SandboxEvidence.from_bytes("sandbox.cancel", handle.id.encode())) + except Exception as error: + return SandboxActionResult(ok=False, error=ContractError(code="sandbox_cancel_failed", message=safe_exception_message(error))) + + async def snapshot(self, handle: SandboxHandle, name: str) -> SandboxActionResult: + del handle, name + return SandboxActionResult( + ok=False, + error=ContractError(code="sandbox_snapshot_unsupported", message="Vercel Sandbox does not expose point-in-time snapshots."), + ) + + async def destroy(self, handle: SandboxHandle) -> SandboxActionResult: + try: + sandbox = await self._resolve(handle) + await call_maybe_async(sandbox.stop) + self._sandboxes.pop(handle.id, None) + return SandboxActionResult(ok=True, evidence=SandboxEvidence.from_bytes("sandbox.destroy", handle.id.encode())) + except Exception as error: + return SandboxActionResult(ok=False, error=ContractError(code="sandbox_destroy_failed", message=safe_exception_message(error))) + + async def health(self) -> SandboxHealth: + try: + self._client_or_raise() + except Exception as error: + return SandboxHealth(status="unavailable", message=safe_exception_message(error)) + return SandboxHealth(status="healthy") + + def capabilities(self) -> SandboxCapabilities: + return SandboxCapabilities( + provider="vercel", + isolation="microvm", + networking="unrestricted", + persistent_filesystem=True, + snapshots=False, + command_streaming=False, + cancellation=True, + file_transfer=True, + evidence=True, + limitations=( + "The Vercel Python SDK is in beta; pin the extra when reproducibility matters.", + "spec.image selects a Vercel runtime string; arbitrary container images are unsupported.", + "Network egress cannot be restricted through the stable adapter; network='none' and allowlists fail closed.", + "No managed secret store; sandbox secret references are rejected.", + "Command streaming is buffered: output arrives after the command completes.", + "Sandbox lifetime is capped by the Vercel sandbox timeout.", + ), + ) diff --git a/tests/test_sandbox_providers.py b/tests/test_sandbox_providers.py index cd96629..14517b8 100644 --- a/tests/test_sandbox_providers.py +++ b/tests/test_sandbox_providers.py @@ -17,6 +17,7 @@ SandboxCommand, SandboxProvider, SandboxSpec, + VercelSandboxProvider, create_sandbox_provider, ) @@ -375,6 +376,92 @@ async def test_runloop_reports_missing_sdk_guidance(monkeypatch: pytest.MonkeyPa assert "anycode-py[sandbox-runloop]" in created.error.message +# --------------------------------------------------------------------------- +# Vercel fakes +# --------------------------------------------------------------------------- + + +class FakeVercelCommand: + def __init__(self, command: str) -> None: + self.exit_code = 0 + self._stdout = f"ran:{command}" + + async def stdout(self) -> str: + return self._stdout + + async def stderr(self) -> str: + return "" + + +class FakeVercelSandbox: + def __init__(self) -> None: + self.sandbox_id = "vercel-1" + self.files: dict[str, bytes] = {} + self.stopped = False + self.create_kwargs: dict[str, object] = {} + + async def run_command(self, command: str, args: list[str]) -> FakeVercelCommand: + del command + return FakeVercelCommand(args[-1]) + + async def write_files(self, files: list[dict[str, object]]) -> None: + for entry in files: + self.files[str(entry["path"])] = bytes(entry["content"]) # type: ignore[arg-type] + + async def read_file(self, path: str) -> bytes: + return self.files[path] + + async def stop(self) -> None: + self.stopped = True + + +class FakeVercelSandboxClass: + """Stands in for the vercel.sandbox.AsyncSandbox class surface.""" + + def __init__(self) -> None: + self.sandbox = FakeVercelSandbox() + + async def create(self, **kwargs: object) -> FakeVercelSandbox: + self.sandbox.create_kwargs = dict(kwargs) + return self.sandbox + + async def get(self, *, sandbox_id: str) -> FakeVercelSandbox: + assert sandbox_id == self.sandbox.sandbox_id + return self.sandbox + + +async def test_vercel_provider_passes_lifecycle_conformance() -> None: + provider = VercelSandboxProvider(FakeVercelSandboxClass()) + await _assert_lifecycle_conformance(provider, snapshots=False) + + +async def test_vercel_maps_image_to_runtime_and_rejects_restrictions() -> None: + sandbox_cls = FakeVercelSandboxClass() + provider = VercelSandboxProvider(sandbox_cls) + + created = await provider.create(_spec(image="python3.13")) + assert created.ok and sandbox_cls.sandbox.create_kwargs == {"runtime": "python3.13"} + + denied_network = await provider.create(_spec(network="allowlist", allowed_cidrs=("10.0.0.0/8",))) + assert not denied_network.ok and denied_network.error is not None + assert denied_network.error.code == "sandbox_network_policy_unsupported" + + denied_secrets = await provider.create(_spec(secret_references={"API_KEY": "vercel:key"})) + assert not denied_secrets.ok and denied_secrets.error is not None + assert denied_secrets.error.code == "sandbox_secrets_unsupported" + + +async def test_vercel_reports_missing_sdk_guidance(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setitem(sys.modules, "vercel", None) + monkeypatch.setitem(sys.modules, "vercel.sandbox", None) + provider = VercelSandboxProvider() + + created = await provider.create(_spec()) + + assert not created.ok and created.error is not None + assert "anycode-py[sandbox-vercel]" in created.error.message + + def test_factory_builds_daytona_provider() -> None: provider = create_sandbox_provider("daytona") assert isinstance(provider, DaytonaSandboxProvider) diff --git a/uv.lock b/uv.lock index 0a3253b..e42f313 100644 --- a/uv.lock +++ b/uv.lock @@ -276,6 +276,9 @@ sandbox-modal = [ sandbox-runloop = [ { name = "runloop-api-client" }, ] +sandbox-vercel = [ + { name = "vercel" }, +] telemetry = [ { name = "opentelemetry-api" }, { name = "opentelemetry-exporter-otlp-proto-grpc" }, @@ -362,8 +365,9 @@ requires-dist = [ { name = "tiktoken", marker = "extra == 'tokens'", specifier = ">=0.8" }, { name = "typer", marker = "extra == 'all'", specifier = ">=0.12" }, { name = "typer", marker = "extra == 'cli'", specifier = ">=0.12" }, + { name = "vercel", marker = "extra == 'sandbox-vercel'", specifier = ">=0.1,<1" }, ] -provides-extras = ["anthropic", "openai", "telemetry", "persistence", "redis", "tokens", "vector", "google", "ollama", "bedrock", "azure", "providers", "mcp", "cli", "sandbox", "sandbox-e2b", "sandbox-modal", "sandbox-runloop", "all"] +provides-extras = ["anthropic", "openai", "telemetry", "persistence", "redis", "tokens", "vector", "google", "ollama", "bedrock", "azure", "providers", "mcp", "cli", "sandbox", "sandbox-e2b", "sandbox-modal", "sandbox-runloop", "sandbox-vercel", "all"] [package.metadata.requires-dev] dev = [ @@ -4175,6 +4179,93 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/e4/16/c1fd27e9549f3c4baf1dc9c20c456cd2f822dbf8de9f463824b0c0357e06/uvloop-0.22.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:6cde23eeda1a25c75b2e07d39970f3374105d5eafbaab2a4482be82f272d5a5e", size = 4296730, upload-time = "2025-10-16T22:17:00.744Z" }, ] +[[package]] +name = "vercel" +version = "0.7.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "cbor2" }, + { name = "httpx" }, + { name = "pydantic" }, + { name = "python-dotenv" }, + { name = "vercel-cache" }, + { name = "vercel-headers" }, + { name = "vercel-internal-telemetry" }, + { name = "vercel-oidc" }, + { name = "vercel-workers" }, + { name = "websockets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b1/1c/853fce420affd46a72a14cf37ac415951c8e8a0666bec19cc27ea5c7dfd9/vercel-0.7.2.tar.gz", hash = "sha256:ccee833cb3b9f53ce4afd18a5a399d25f5e89005bfc7ffab2ce8843203e7d9c7", size = 185547, upload-time = "2026-07-21T21:06:01.746Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/77/40/836f9b42b0c1bcf371f26a9eb571e4bc47269404ac61165dd79a4a3c28fd/vercel-0.7.2-py3-none-any.whl", hash = "sha256:fceab7b354a19d088e2dd6463d3c9f1358ec71bdad2d9452e10ffa9092101066", size = 211802, upload-time = "2026-07-21T21:06:00.539Z" }, +] + +[[package]] +name = "vercel-cache" +version = "0.7.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "httpx" }, + { name = "vercel-headers" }, + { name = "vercel-internal-telemetry" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/d2/77/72a93d0c59d1a6ab4970532f7af2b9e348bcc5003613c996c887ce86c28d/vercel_cache-0.7.1.tar.gz", hash = "sha256:2664f79442849bdaee89c300181f07d3c5b601d52665889263f9f90a32319489", size = 9210, upload-time = "2026-07-16T14:47:31.732Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/70/94/349467bc8b9388763ce17bd4393db239719ea5f89d06ea56f814397715fa/vercel_cache-0.7.1-py3-none-any.whl", hash = "sha256:c0ef0fd76be697c2e2069399c9634581d25b93be5dba3d6b9484ab9a66f96fc9", size = 10346, upload-time = "2026-07-16T14:47:30.955Z" }, +] + +[[package]] +name = "vercel-headers" +version = "0.7.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/20/50/2fbe5563b1f710c5cec3076efe94df887dd89c7ce0f4238b81f169f5d733/vercel_headers-0.7.1.tar.gz", hash = "sha256:46e63a99a3095f3b4fa324c80e5aeee5886ca474ef5ecbfe6eabb5f2bd64928a", size = 5410, upload-time = "2026-07-16T14:23:35.768Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/28/b8/5484e7ecf876c031831623efc547edcf94e2e33db4251d17c2d117c18cb0/vercel_headers-0.7.1-py3-none-any.whl", hash = "sha256:6ef65f0baffdf19775b693265d6118e125251456fb192324f4006dd341c77abc", size = 3907, upload-time = "2026-07-16T14:23:34.942Z" }, +] + +[[package]] +name = "vercel-internal-telemetry" +version = "0.7.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "httpx" }, + { name = "vercel-oidc" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/40/d4/74e3ad2f737b182b337aa6adbdb96a474bf8241940006a6cf725ba0b3c5f/vercel_internal_telemetry-0.7.1.tar.gz", hash = "sha256:486edae45db9a9a340324509b824534c29bf91564e79e701d907200c79dac136", size = 8467, upload-time = "2026-07-16T14:28:09.337Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/91/e7/9fb15e1be9a7c3384948fb09285a54f56f2e4d7aeff41758310b8686d89d/vercel_internal_telemetry-0.7.1-py3-none-any.whl", hash = "sha256:28ee2ebf91ba882e1ae368abd21813e36d7fadd54f7f404a598d0e767d5cc249", size = 8252, upload-time = "2026-07-16T14:28:08.436Z" }, +] + +[[package]] +name = "vercel-oidc" +version = "0.7.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "httpx" }, + { name = "vercel-headers" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b0/1e/e46268d09daaf31222fd3961238056168916036fb84ee12f4dc1d9a115f4/vercel_oidc-0.7.1.tar.gz", hash = "sha256:1014faaed74d4f74ade0c350d4c5c2f01c25153d8aa086ba840f91feb86f88bb", size = 8060, upload-time = "2026-07-16T14:25:29.896Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3c/bc/d62d569e508eb48131d001a49b1b62a98c1fa84217e845106fc7c63b88c6/vercel_oidc-0.7.1-py3-none-any.whl", hash = "sha256:db9fb82b01daf2fb3ed2c0190906a6c4f5b8f0f3bb86c08aafeffa74f765733c", size = 8052, upload-time = "2026-07-16T14:25:28.845Z" }, +] + +[[package]] +name = "vercel-workers" +version = "0.0.25" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "httpx" }, + { name = "pydantic" }, + { name = "python-dotenv" }, + { name = "vercel" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/30/df/04d37021ad7ca53b7599c313e411d91623c7a005c741f491d1eefb7a9f0c/vercel_workers-0.0.25.tar.gz", hash = "sha256:212ded01400b524be51d251df49f801caf115ad7d48cca7eb168cbeceda3def3", size = 64149, upload-time = "2026-06-20T19:26:27.177Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/85/5a/2ae6debc94fcfd7ce06b0e4ac5505be29ca04e76d6c99af35d4372dd7eda/vercel_workers-0.0.25-py3-none-any.whl", hash = "sha256:6901228a90e83e292e6a176161e66e6a7c43d9f4fd9e13d6bd87092ad09ffd8b", size = 61680, upload-time = "2026-06-20T19:26:25.971Z" }, +] + [[package]] name = "verspec" version = "0.1.0" From 6920bcdcc92296cca77d73a12b20023aa5cfca64 Mon Sep 17 00:00:00 2001 From: Ali Muhammad Date: Fri, 24 Jul 2026 07:16:05 +0500 Subject: [PATCH 7/8] feat(sandbox): add langsmith sandbox provider --- .github/workflows/ci.yml | 3 + pyproject.toml | 3 + src/anycode/__init__.py | 2 + src/anycode/sandbox/__init__.py | 2 + src/anycode/sandbox/factory.py | 5 + src/anycode/sandbox/langsmith.py | 204 +++++++++++++++++++++++++++++++ tests/test_sandbox_providers.py | 82 +++++++++++++ uv.lock | 201 +++++++++++++++++++++++++++++- 8 files changed, 501 insertions(+), 1 deletion(-) create mode 100644 src/anycode/sandbox/langsmith.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17d1809..baae14a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -163,6 +163,9 @@ jobs: - extra: sandbox-vercel sync-args: --extra sandbox-vercel imports: vercel anycode.sandbox.vercel + - extra: sandbox-langsmith + sync-args: --extra sandbox-langsmith + imports: langsmith anycode.sandbox.langsmith - extra: all sync-args: --extra all imports: anycode diff --git a/pyproject.toml b/pyproject.toml index 8928cde..4e74f74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,6 +111,9 @@ sandbox-runloop = [ sandbox-vercel = [ "vercel>=0.1,<1", ] +sandbox-langsmith = [ + "langsmith[sandbox]>=0.4", +] all = [ "anthropic>=0.40", "openai>=1.50", diff --git a/src/anycode/__init__.py b/src/anycode/__init__.py index c6653db..79f90d8 100644 --- a/src/anycode/__init__.py +++ b/src/anycode/__init__.py @@ -193,6 +193,7 @@ CompanionSandboxAdapter, DaytonaSandboxProvider, E2BSandboxProvider, + LangSmithSandboxProvider, ModalSandboxProvider, PolicySandboxProvider, RunloopSandboxProvider, @@ -612,6 +613,7 @@ "CompanionSandboxAdapter", "DaytonaSandboxProvider", "E2BSandboxProvider", + "LangSmithSandboxProvider", "ModalSandboxProvider", "PolicySandboxProvider", "RunloopSandboxProvider", diff --git a/src/anycode/sandbox/__init__.py b/src/anycode/sandbox/__init__.py index d035b83..f164a66 100644 --- a/src/anycode/sandbox/__init__.py +++ b/src/anycode/sandbox/__init__.py @@ -4,6 +4,7 @@ from anycode.sandbox.daytona import DaytonaSandboxProvider from anycode.sandbox.e2b import E2BSandboxProvider from anycode.sandbox.factory import SANDBOX_PROVIDER_EXTRAS, create_sandbox_provider +from anycode.sandbox.langsmith import LangSmithSandboxProvider from anycode.sandbox.modal import ModalSandboxProvider from anycode.sandbox.models import ( SANDBOX_CONTRACT_VERSION, @@ -31,6 +32,7 @@ "CompanionSandboxClient", "DaytonaSandboxProvider", "E2BSandboxProvider", + "LangSmithSandboxProvider", "ModalSandboxProvider", "PolicySandboxProvider", "RunloopSandboxProvider", diff --git a/src/anycode/sandbox/factory.py b/src/anycode/sandbox/factory.py index dac313b..6cc7080 100644 --- a/src/anycode/sandbox/factory.py +++ b/src/anycode/sandbox/factory.py @@ -11,6 +11,7 @@ SANDBOX_PROVIDER_EXTRAS: dict[str, str] = { "daytona": "sandbox", "e2b": "sandbox-e2b", + "langsmith": "sandbox-langsmith", "modal": "sandbox-modal", "runloop": "sandbox-runloop", "vercel": "sandbox-vercel", @@ -44,5 +45,9 @@ def create_sandbox_provider(name: str, **kwargs: Any) -> SandboxProvider: from anycode.sandbox.vercel import VercelSandboxProvider return VercelSandboxProvider(**kwargs) + if name == "langsmith": + from anycode.sandbox.langsmith import LangSmithSandboxProvider + + return LangSmithSandboxProvider(**kwargs) raise ValueError(f"Unknown sandbox provider: {name!r}. Available: {sorted(SANDBOX_PROVIDER_EXTRAS)}") diff --git a/src/anycode/sandbox/langsmith.py b/src/anycode/sandbox/langsmith.py new file mode 100644 index 0000000..21ce316 --- /dev/null +++ b/src/anycode/sandbox/langsmith.py @@ -0,0 +1,204 @@ +"""LangSmith sandbox provider adapter.""" + +from __future__ import annotations + +import base64 +import shlex +from collections.abc import AsyncIterable +from typing import Any + +from anycode.contracts.models import ContractError +from anycode.sandbox._base import ( + buffered_stream, + call_maybe_async, + first_guard_error, + network_policy_error, + secrets_unsupported_error, + shell_command, + snapshot_restore_unsupported_error, +) +from anycode.sandbox.models import ( + SandboxActionResult, + SandboxCapabilities, + SandboxCommand, + SandboxCommandResult, + SandboxCreateResult, + SandboxEvidence, + SandboxFileResult, + SandboxHandle, + SandboxHealth, + SandboxOutputChunk, + SandboxSpec, +) +from anycode.security.redaction import safe_exception_message + + +class LangSmithSandboxProvider: + """LangSmith microVM sandboxes; ``LANGSMITH_API_KEY`` stays in SDK configuration.""" + + def __init__(self, client: Any | None = None) -> None: + self._client = client + self._sandboxes: dict[str, Any] = {} + + def _client_or_raise(self) -> Any: + if self._client is not None: + return self._client + try: + from langsmith import sandbox as ls_sandbox # type: ignore[import-not-found] + except ImportError as error: + message = ( + 'LangSmithSandboxProvider requires the optional "langsmith[sandbox]" package. ' + 'Install it with: pip install "anycode-py[sandbox-langsmith]"' + ) + raise ImportError(message) from error + client_cls = getattr(ls_sandbox, "AsyncSandboxClient", None) or ls_sandbox.SandboxClient + self._client = client_cls() + return self._client + + async def _resolve(self, handle: SandboxHandle) -> Any: + sandbox = self._sandboxes.get(handle.id) + if sandbox is not None: + return sandbox + client = self._client_or_raise() + getter = getattr(client, "get_sandbox", None) + if getter is None: + raise LookupError(f"Sandbox {handle.id!r} is not tracked by this provider instance") + sandbox = await call_maybe_async(getter, handle.id) + self._sandboxes[handle.id] = sandbox + return sandbox + + async def create(self, spec: SandboxSpec) -> SandboxCreateResult: + guard = first_guard_error( + network_policy_error("langsmith", spec, supported=("unrestricted",)), + secrets_unsupported_error("langsmith", spec), + snapshot_restore_unsupported_error("langsmith", spec), + ) + if guard is not None: + return SandboxCreateResult(ok=False, error=guard) + try: + client = self._client_or_raise() + creator = getattr(client, "create_sandbox", None) or client.create + kwargs: dict[str, Any] = {} + if spec.image: + kwargs["image"] = spec.image + sandbox = await call_maybe_async(creator, **kwargs) + sandbox_id = str(getattr(sandbox, "id", None) or getattr(sandbox, "sandbox_id", None) or getattr(sandbox, "name", "")) + self._sandboxes[sandbox_id] = sandbox + handle = SandboxHandle( + id=sandbox_id, + provider="langsmith", + run_id=spec.run_id, + task_id=spec.task_id, + correlation_id=spec.correlation_id, + context=spec.context, + capabilities=self.capabilities(), + ) + return SandboxCreateResult(ok=True, handle=handle) + except Exception as error: + return SandboxCreateResult( + ok=False, + error=ContractError(code="sandbox_create_failed", message=safe_exception_message(error), retryable=True), + ) + + async def _run(self, handle: SandboxHandle, command_text: str) -> tuple[str, str, int]: + sandbox = await self._resolve(handle) + result = await call_maybe_async(sandbox.run, command_text) + stdout = str(getattr(result, "stdout", "") or "") + stderr = str(getattr(result, "stderr", "") or "") + exit_code = int(getattr(result, "exit_code", None) or getattr(result, "returncode", 0) or 0) + return stdout, stderr, exit_code + + async def execute(self, handle: SandboxHandle, command: SandboxCommand) -> SandboxCommandResult: + try: + stdout, stderr, exit_code = await self._run(handle, shell_command(command)) + evidence = SandboxEvidence.from_bytes("command", f"{stdout}\0{stderr}".encode(), metadata={"exit_code": exit_code}) + return SandboxCommandResult(ok=exit_code == 0, exit_code=exit_code, stdout=stdout, stderr=stderr, evidence=evidence) + except Exception as error: + return SandboxCommandResult( + ok=False, + error=ContractError(code="sandbox_command_failed", message=safe_exception_message(error), retryable=True), + ) + + def stream(self, handle: SandboxHandle, command: SandboxCommand) -> AsyncIterable[SandboxOutputChunk]: + return buffered_stream(self.execute, handle, command) + + async def write_file(self, handle: SandboxHandle, path: str, data: bytes) -> SandboxFileResult: + try: + encoded = base64.b64encode(data).decode("ascii") + quoted = shlex.quote(path) + stdout, stderr, exit_code = await self._run( + handle, f'mkdir -p "$(dirname {quoted})" && printf %s {shlex.quote(encoded)} | base64 -d > {quoted}' + ) + if exit_code != 0: + return SandboxFileResult(ok=False, error=ContractError(code="sandbox_file_write_failed", message=stderr or stdout)) + return SandboxFileResult(ok=True, evidence=SandboxEvidence.from_bytes("file.write", data, metadata={"path": path})) + except Exception as error: + return SandboxFileResult(ok=False, error=ContractError(code="sandbox_file_write_failed", message=safe_exception_message(error))) + + async def read_file(self, handle: SandboxHandle, path: str) -> SandboxFileResult: + try: + stdout, stderr, exit_code = await self._run(handle, f"base64 {shlex.quote(path)}") + if exit_code != 0: + return SandboxFileResult(ok=False, error=ContractError(code="sandbox_file_read_failed", message=stderr or stdout)) + data = base64.b64decode("".join(stdout.split())) + return SandboxFileResult(ok=True, data=data, evidence=SandboxEvidence.from_bytes("file.read", data, metadata={"path": path})) + except Exception as error: + return SandboxFileResult(ok=False, error=ContractError(code="sandbox_file_read_failed", message=safe_exception_message(error))) + + async def _delete(self, handle: SandboxHandle) -> None: + sandbox = self._sandboxes.get(handle.id) + deleter = getattr(sandbox, "delete", None) if sandbox is not None else None + if deleter is not None: + await call_maybe_async(deleter) + return + client = self._client_or_raise() + await call_maybe_async(getattr(client, "delete_sandbox"), handle.id) + + async def cancel(self, handle: SandboxHandle) -> SandboxActionResult: + try: + await self._delete(handle) + return SandboxActionResult(ok=True, evidence=SandboxEvidence.from_bytes("sandbox.cancel", handle.id.encode())) + except Exception as error: + return SandboxActionResult(ok=False, error=ContractError(code="sandbox_cancel_failed", message=safe_exception_message(error))) + + async def snapshot(self, handle: SandboxHandle, name: str) -> SandboxActionResult: + del handle, name + return SandboxActionResult( + ok=False, + error=ContractError(code="sandbox_snapshot_unsupported", message="LangSmith sandboxes do not expose point-in-time snapshots."), + ) + + async def destroy(self, handle: SandboxHandle) -> SandboxActionResult: + try: + await self._delete(handle) + self._sandboxes.pop(handle.id, None) + return SandboxActionResult(ok=True, evidence=SandboxEvidence.from_bytes("sandbox.destroy", handle.id.encode())) + except Exception as error: + return SandboxActionResult(ok=False, error=ContractError(code="sandbox_destroy_failed", message=safe_exception_message(error))) + + async def health(self) -> SandboxHealth: + try: + self._client_or_raise() + except Exception as error: + return SandboxHealth(status="unavailable", message=safe_exception_message(error)) + return SandboxHealth(status="healthy") + + def capabilities(self) -> SandboxCapabilities: + return SandboxCapabilities( + provider="langsmith", + isolation="microvm", + networking="unrestricted", + persistent_filesystem=True, + snapshots=False, + command_streaming=False, + cancellation=True, + file_transfer=True, + evidence=True, + limitations=( + "Network egress cannot be restricted through the stable adapter; network='none' and allowlists fail closed.", + "No managed secret store; sandbox secret references are rejected.", + "Command streaming is buffered: output arrives after the command completes.", + "File transfer runs through in-sandbox shell base64, so the image must provide a POSIX shell and base64.", + "Cancellation deletes the sandbox rather than only one command.", + ), + ) diff --git a/tests/test_sandbox_providers.py b/tests/test_sandbox_providers.py index 14517b8..aa926b7 100644 --- a/tests/test_sandbox_providers.py +++ b/tests/test_sandbox_providers.py @@ -2,6 +2,8 @@ from __future__ import annotations +import base64 +import re import sys from types import SimpleNamespace @@ -12,6 +14,7 @@ SANDBOX_PROVIDER_EXTRAS, DaytonaSandboxProvider, E2BSandboxProvider, + LangSmithSandboxProvider, ModalSandboxProvider, RunloopSandboxProvider, SandboxCommand, @@ -462,6 +465,85 @@ async def test_vercel_reports_missing_sdk_guidance(monkeypatch: pytest.MonkeyPat assert "anycode-py[sandbox-vercel]" in created.error.message +# --------------------------------------------------------------------------- +# LangSmith fakes +# --------------------------------------------------------------------------- + + +class FakeLangSmithSandbox: + """run()-only sandbox with a tiny in-memory filesystem for the base64 shell transfers.""" + + def __init__(self) -> None: + self.id = "ls-1" + self.files: dict[str, bytes] = {} + self.deleted = False + + async def run(self, command: str) -> SimpleNamespace: + write_match = re.search(r"printf %s (\S+) \| base64 -d > (.+)$", command) + if write_match: + encoded = write_match.group(1).strip("'\"") + path = write_match.group(2).strip("'\"") + self.files[path] = base64.b64decode(encoded) + return SimpleNamespace(stdout="", stderr="", exit_code=0) + read_match = re.match(r"^base64 (.+)$", command) + if read_match: + path = read_match.group(1).strip("'\"") + if path not in self.files: + return SimpleNamespace(stdout="", stderr=f"base64: {path}: No such file", exit_code=1) + return SimpleNamespace(stdout=base64.b64encode(self.files[path]).decode("ascii"), stderr="", exit_code=0) + return SimpleNamespace(stdout=f"ran:{command}", stderr="", exit_code=0) + + async def delete(self) -> None: + self.deleted = True + + +class FakeLangSmithClient: + def __init__(self) -> None: + self.sandbox = FakeLangSmithSandbox() + + async def create_sandbox(self, **kwargs: object) -> FakeLangSmithSandbox: + del kwargs + return self.sandbox + + +async def test_langsmith_provider_passes_lifecycle_conformance() -> None: + provider = LangSmithSandboxProvider(FakeLangSmithClient()) + await _assert_lifecycle_conformance(provider, snapshots=False) + + +async def test_langsmith_read_missing_file_fails_with_shell_error() -> None: + provider = LangSmithSandboxProvider(FakeLangSmithClient()) + created = await provider.create(_spec()) + assert created.handle is not None + + read = await provider.read_file(created.handle, "/workspace/missing.txt") + + assert not read.ok and read.error is not None and read.error.code == "sandbox_file_read_failed" + + +async def test_langsmith_rejects_restricted_network_and_secrets() -> None: + provider = LangSmithSandboxProvider(FakeLangSmithClient()) + + denied_network = await provider.create(_spec(network="none")) + assert not denied_network.ok and denied_network.error is not None + assert denied_network.error.code == "sandbox_network_policy_unsupported" + + denied_secrets = await provider.create(_spec(secret_references={"API_KEY": "langsmith:key"})) + assert not denied_secrets.ok and denied_secrets.error is not None + assert denied_secrets.error.code == "sandbox_secrets_unsupported" + + +async def test_langsmith_reports_missing_sdk_guidance(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setitem(sys.modules, "langsmith", None) + monkeypatch.setitem(sys.modules, "langsmith.sandbox", None) + provider = LangSmithSandboxProvider() + + created = await provider.create(_spec()) + + assert not created.ok and created.error is not None + assert "anycode-py[sandbox-langsmith]" in created.error.message + + def test_factory_builds_daytona_provider() -> None: provider = create_sandbox_provider("daytona") assert isinstance(provider, DaytonaSandboxProvider) diff --git a/uv.lock b/uv.lock index e42f313..83dcd73 100644 --- a/uv.lock +++ b/uv.lock @@ -270,6 +270,9 @@ sandbox = [ sandbox-e2b = [ { name = "e2b" }, ] +sandbox-langsmith = [ + { name = "langsmith" }, +] sandbox-modal = [ { name = "modal" }, ] @@ -339,6 +342,7 @@ requires-dist = [ { name = "httpx", marker = "extra == 'all'", specifier = ">=0.27" }, { name = "httpx", marker = "extra == 'ollama'", specifier = ">=0.27" }, { name = "httpx", marker = "extra == 'providers'", specifier = ">=0.27" }, + { name = "langsmith", extras = ["sandbox"], marker = "extra == 'sandbox-langsmith'", specifier = ">=0.4" }, { name = "mcp", marker = "extra == 'all'", specifier = ">=1.0" }, { name = "mcp", marker = "extra == 'mcp'", specifier = ">=1.0" }, { name = "modal", marker = "extra == 'sandbox-modal'", specifier = ">=1.0" }, @@ -367,7 +371,7 @@ requires-dist = [ { name = "typer", marker = "extra == 'cli'", specifier = ">=0.12" }, { name = "vercel", marker = "extra == 'sandbox-vercel'", specifier = ">=0.1,<1" }, ] -provides-extras = ["anthropic", "openai", "telemetry", "persistence", "redis", "tokens", "vector", "google", "ollama", "bedrock", "azure", "providers", "mcp", "cli", "sandbox", "sandbox-e2b", "sandbox-modal", "sandbox-runloop", "sandbox-vercel", "all"] +provides-extras = ["anthropic", "openai", "telemetry", "persistence", "redis", "tokens", "vector", "google", "ollama", "bedrock", "azure", "providers", "mcp", "cli", "sandbox", "sandbox-e2b", "sandbox-modal", "sandbox-runloop", "sandbox-vercel", "sandbox-langsmith", "all"] [package.metadata.requires-dev] dev = [ @@ -1835,6 +1839,31 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/0c/70/05b685ea2dffcb2adbf3cdcea5d8865b7bc66f67249084cf845012a0ff13/kubernetes-35.0.0-py2.py3-none-any.whl", hash = "sha256:39e2b33b46e5834ef6c3985ebfe2047ab39135d41de51ce7641a7ca5b372a13d", size = 2017602, upload-time = "2026-01-16T01:05:25.991Z" }, ] +[[package]] +name = "langsmith" +version = "0.10.10" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "distro" }, + { name = "httpx" }, + { name = "orjson", marker = "platform_python_implementation != 'PyPy'" }, + { name = "packaging" }, + { name = "pydantic" }, + { name = "requests" }, + { name = "requests-toolbelt" }, + { name = "sniffio" }, + { name = "typing-extensions" }, + { name = "uuid-utils" }, + { name = "websockets" }, + { name = "xxhash" }, + { name = "zstandard" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/10/38/c709ff119172e490a8e8bccd10deeda8da239f15f11521009a58c7b904ac/langsmith-0.10.10.tar.gz", hash = "sha256:e0e175e9dd8de6d96dbb55244482e20590a2691ec7c5e087afc1f302e33d98fe", size = 4739726, upload-time = "2026-07-23T04:18:56.246Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3e/ec/0b2348bea502e07cb3c2a6e5109423debd82aef9fcef6f807c159ceb5297/langsmith-0.10.10-py3-none-any.whl", hash = "sha256:eb5e9da635f5853fc657cddd1c27f40a8e8b2f00c38051555d608c8e57eb605d", size = 675232, upload-time = "2026-07-23T04:18:54.399Z" }, +] + [[package]] name = "markdown" version = "3.10.2" @@ -4520,6 +4549,119 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/a4/f5/10b68b7b1544245097b2a1b8238f66f2fc6dcaeb24ba5d917f52bd2eed4f/wsproto-1.3.2-py3-none-any.whl", hash = "sha256:61eea322cdf56e8cc904bd3ad7573359a242ba65688716b0710a5eb12beab584", size = 24405, upload-time = "2025-11-20T18:18:00.454Z" }, ] +[[package]] +name = "xxhash" +version = "3.8.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/8e/63/71aa56b151a1b28770037a61bd4e461c2619cfc8866a4fcaf1548605e325/xxhash-3.8.1.tar.gz", hash = "sha256:b0de4bf3aa66363552d52c6a89003c479911f12098cd48a53d44a0f7a25f7c46", size = 86223, upload-time = "2026-07-06T10:49:58.937Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/42/91/f65c34a7aa7b4e7cf4854f8e6ef3f7ee32ceac41d4f008da0780db0612f6/xxhash-3.8.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:e6e49370822c1f4d8d90e678b06dbcb08b51a026a7c4b55479e7d467f2e813bc", size = 34680, upload-time = "2026-07-06T10:44:40.932Z" }, + { url = "https://files.pythonhosted.org/packages/57/04/b10a245a4c09a9cfa88f8e9ae755029413ad1ac17047f9a61906e5ae0799/xxhash-3.8.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:220d68130f83f7cc86d6edfdeab176adc73d7200bf3a8ec10c629e8cf605c215", size = 32397, upload-time = "2026-07-06T10:44:42.196Z" }, + { url = "https://files.pythonhosted.org/packages/3a/75/45ab795b5945b6388583bd75202106af505537935566c15a1577797a0e08/xxhash-3.8.1-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:4d365ee1892c1fa803536f8c6ce21d24b29c9718ec75eb856095c07830f8c478", size = 220549, upload-time = "2026-07-06T10:44:43.603Z" }, + { url = "https://files.pythonhosted.org/packages/13/44/5ba2bd0a14ddf4193fc7d8ec29625f659f22c06d60b28f04bf46305d8330/xxhash-3.8.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:852bfe059720632e2f16a6a4745e41d20937b2bf2a42a401e2412046bb6971cc", size = 241186, upload-time = "2026-07-06T10:44:45.534Z" }, + { url = "https://files.pythonhosted.org/packages/23/32/c4147def4d1e4538b906f82731e0ba23424377fc50a7cddd03cd284c8f63/xxhash-3.8.1-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:2f8c25a7061d952de589bd0ea0eaadee32378ff83dd6a677b267f9cd86f401f8", size = 264852, upload-time = "2026-07-06T10:44:47.199Z" }, + { url = "https://files.pythonhosted.org/packages/6c/bd/71ed14f4f0318bb7fd7b2ec51999413487fa8da8d41208e84d50d1ef0f98/xxhash-3.8.1-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:868a8dcaff1a84ba78038e1cef14fc88ccf84d9b4d12ea604696e0693296aa56", size = 242663, upload-time = "2026-07-06T10:44:48.846Z" }, + { url = "https://files.pythonhosted.org/packages/91/09/70af22c565a8473b3f2ae73f88e7721af281bc4a575236dbd1970c9f76f6/xxhash-3.8.1-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:6536d8677d2fff7e64cd0b98b976df9de7aee0e69590044c2af5f51b76b7a170", size = 473510, upload-time = "2026-07-06T10:44:50.695Z" }, + { url = "https://files.pythonhosted.org/packages/18/96/34db781c8f0cf99c544ca1f2bc2e5bf55426e1eb4ca6de8ea5da56a9f352/xxhash-3.8.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:82c0cedd280eab2e8291270e6c04894dbc096f8159a39dcf1807429f026ca3cc", size = 220469, upload-time = "2026-07-06T10:44:52.422Z" }, + { url = "https://files.pythonhosted.org/packages/93/5f/9a184f615fa5a4dce30c01534f62946ce5a11ce40f73785cbd356ccabaa9/xxhash-3.8.1-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:daa86e4b68221d38e669bb236ba112d0335353829fb627c82e5909e4bbe8694c", size = 310290, upload-time = "2026-07-06T10:44:54.142Z" }, + { url = "https://files.pythonhosted.org/packages/a9/dc/9b9a9789011ee153723a5eb9e7dd7fcbae2ba9b3fe7a729249ca7c252056/xxhash-3.8.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:2bc7113e6f2b6b3922dd61796ca9f36af09da3773898e7003038dc992fc83b8d", size = 238173, upload-time = "2026-07-06T10:44:55.693Z" }, + { url = "https://files.pythonhosted.org/packages/ec/4d/71c6005ada9dcb608a4e1902e8475ecadb5f3fbfa04e1e244d276a2d0c43/xxhash-3.8.1-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:5eed32dad81d6ba8e62dc7b9ffa0500199385d7810a8dd9d4eafaceb8c6e20bb", size = 269026, upload-time = "2026-07-06T10:44:57.424Z" }, + { url = "https://files.pythonhosted.org/packages/2f/87/d6c036ba25dfbd9c8633be5aa86fc9474bbb9e2c68212a841d090abe7344/xxhash-3.8.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:83697b0ea1f10e7f5d8b26a4906fa851393c61546c63839643a2b7fe2d868061", size = 224970, upload-time = "2026-07-06T10:44:59.085Z" }, + { url = "https://files.pythonhosted.org/packages/48/62/4c1f035a41c5752aa05e195b6c904c07b94fe9061a16de61e72a6e6b135f/xxhash-3.8.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:36fc69160465ae75c6ec4ac9f781bb2aa16ae7ff869e73c26fee85fbb11b9887", size = 240820, upload-time = "2026-07-06T10:45:00.746Z" }, + { url = "https://files.pythonhosted.org/packages/da/14/d39d565069b87e86d21a2af2a31d04db79249d25aa8d5b62959056a89857/xxhash-3.8.1-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:445e0f5a31f2f3546ae0895d4811e159518cdc9d824c11419898d40cfadb677e", size = 300619, upload-time = "2026-07-06T10:45:02.716Z" }, + { url = "https://files.pythonhosted.org/packages/13/22/75467acc887edc8cf71c97ab1708feb3df7a88bda589b9f399765c6387d2/xxhash-3.8.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:dfe0580fbfd5e4af87d0cc52d2044f155d55ebd8c8a93568758a2ea7d8e15975", size = 443267, upload-time = "2026-07-06T10:45:04.653Z" }, + { url = "https://files.pythonhosted.org/packages/a4/b6/1da3baa5fa6ef705e3425fddd382be7dfc4dfba2686df90a20f16e9c7b1b/xxhash-3.8.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:095e1323fa108be1292c54c86da3ef3c7a7dc015b105a52133973bc07a6ad11a", size = 217338, upload-time = "2026-07-06T10:45:06.304Z" }, + { url = "https://files.pythonhosted.org/packages/78/dd/b5295a9f97484e7a1c2b283a742ca45e3104991c55a1ef670dde161829ba/xxhash-3.8.1-cp312-cp312-win32.whl", hash = "sha256:bf28f55e427e0483acb1f666bd0d869b6d5e5a716680c216ad7befe3d4cfba2e", size = 31970, upload-time = "2026-07-06T10:45:07.823Z" }, + { url = "https://files.pythonhosted.org/packages/ec/31/3fa0b807d7e21515cd975e7fe5c039d52ac3e9401a96d6ad68dae6305215/xxhash-3.8.1-cp312-cp312-win_amd64.whl", hash = "sha256:2256e80e4960ee282f63428adb349cb7f8bd8efe4db770d88eb815f4b9860724", size = 32741, upload-time = "2026-07-06T10:45:09.42Z" }, + { url = "https://files.pythonhosted.org/packages/b8/05/86feada74e239600e6875aa507afb40482a89b92700aa74a92da83bdcb77/xxhash-3.8.1-cp312-cp312-win_arm64.whl", hash = "sha256:9df56e6df96a60590935e22373041cccc91fd55858763dcffb55bf63b3a2b396", size = 29234, upload-time = "2026-07-06T10:45:10.809Z" }, + { url = "https://files.pythonhosted.org/packages/6b/8c/446bb782cd0d27007a917b5569a08dd73219c3e8d6e459014db104b27bdb/xxhash-3.8.1-cp313-cp313-android_21_arm64_v8a.whl", hash = "sha256:3c682fcd96eb4bf64be32a4d95f96107e1588005831bd8a741b324fdda01b913", size = 38562, upload-time = "2026-07-06T10:45:12.425Z" }, + { url = "https://files.pythonhosted.org/packages/d7/ec/c0c45627eaa6be7a5d6117423adf8f7a15b17ee74b4b17072cca5959a225/xxhash-3.8.1-cp313-cp313-android_21_x86_64.whl", hash = "sha256:036a024d8b9c01f70782e09ed98d532e76fd23f950ae7154bd950fe94e90ebec", size = 36656, upload-time = "2026-07-06T10:45:13.932Z" }, + { url = "https://files.pythonhosted.org/packages/f6/94/8324c04cc7597154caaeba6c094e01fbd2e7601d01e7a13eea9f5420e77b/xxhash-3.8.1-cp313-cp313-ios_13_0_arm64_iphoneos.whl", hash = "sha256:d6a5c0bce213b23b0166fe0d35bcbbe23ce4b968f257cc7eb6fd57cb8e1e6297", size = 31169, upload-time = "2026-07-06T10:45:15.687Z" }, + { url = "https://files.pythonhosted.org/packages/40/a4/beb6bb26e1184e126dbe7a5682330214ef54dcfbf882078aa9f4b5428d42/xxhash-3.8.1-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:5177aa44eddaa97c6ef0cc00c6d540edb64d51781d2f8fb941612ec61a92c9ed", size = 32177, upload-time = "2026-07-06T10:45:17.035Z" }, + { url = "https://files.pythonhosted.org/packages/56/0f/fc4c92a5a528f839b34b6419b2e53c8597f2a629d5a1f5d721f65bfa1fd6/xxhash-3.8.1-cp313-cp313-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:7801b7223db017b9c0c9ccf37e44524edb35a1544a1c032add22c061c6af0276", size = 34642, upload-time = "2026-07-06T10:45:18.39Z" }, + { url = "https://files.pythonhosted.org/packages/d4/58/edbfb141d4000767ac6a9694f8ac0763e2c2e983e65c9e31620ba56e2667/xxhash-3.8.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:9e80238259655bf69d7bcd08226a970d7f42605f3157786bfa76dd13472d7fa0", size = 34684, upload-time = "2026-07-06T10:45:20.033Z" }, + { url = "https://files.pythonhosted.org/packages/07/3f/5072f1f0f5714186f0ac2a0b5a4929ce30d4b845e94886b6c01b6ebda0be/xxhash-3.8.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:bcab50a389cc04d87f90092af78a6adba2ab3deca63175a3344ca83514045315", size = 32401, upload-time = "2026-07-06T10:45:21.414Z" }, + { url = "https://files.pythonhosted.org/packages/49/c7/802ea2f9c2ed59219934d6d65c470d502b1788043eae277a52af8658bda6/xxhash-3.8.1-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:a2489d3a776fa380cb8e71f54c7fda268a9baf3de9b1395093fd280f95735907", size = 220617, upload-time = "2026-07-06T10:45:23.234Z" }, + { url = "https://files.pythonhosted.org/packages/99/a8/e10488efd31fcb13fcd6acbc6e788f10c6f8e3a0cc4ae3eb89dc19c55a12/xxhash-3.8.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:32ab1e5432690276e71192be7401b55f96db2d0eedea5d44eb1f164505669cc0", size = 241295, upload-time = "2026-07-06T10:45:25.364Z" }, + { url = "https://files.pythonhosted.org/packages/18/cc/14180b17d44892a631f8ae7323c30bfbb1328efc8209e528a480293528ac/xxhash-3.8.1-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:b30e01a0b97a4bc3f519a4d7a82da3dc53251fb0de5eeea8660dcd4ff094c0c2", size = 264688, upload-time = "2026-07-06T10:45:27.09Z" }, + { url = "https://files.pythonhosted.org/packages/a9/72/a14019d0c5f6c41ee407a503036ae32787c91325ca218a96a9b5627be651/xxhash-3.8.1-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:1f44275ddb0978b67a58a951501903f04d49335a91f7681c9ce122ecb8ccb329", size = 242740, upload-time = "2026-07-06T10:45:28.753Z" }, + { url = "https://files.pythonhosted.org/packages/68/08/92550e556c6fcfcb96c6a336945eb53a431ed43120ed749636debb16c5cf/xxhash-3.8.1-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:e3b87cbd974512c0c5fc7b469c36b2cdc9ee6d76e4ec78bccb2c7184611c49b0", size = 473599, upload-time = "2026-07-06T10:45:30.524Z" }, + { url = "https://files.pythonhosted.org/packages/29/83/e361d3c1acd1b21e1d489616de6fa4aaf843365d8179f612e3743eac20a9/xxhash-3.8.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:98ee81b4b7f3023c9cb04a78cc67610baffcb5812d92f2096cb5a5efc6f19437", size = 220559, upload-time = "2026-07-06T10:45:32.979Z" }, + { url = "https://files.pythonhosted.org/packages/05/01/006a4243c2c2a6831827f9999f6d1c23feeef100eb023c1f886022a00bf3/xxhash-3.8.1-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:2666f059a1588a99267e33605365ed89cea92f424b3522806a9f4bd8ad2e3d62", size = 310383, upload-time = "2026-07-06T10:45:35.875Z" }, + { url = "https://files.pythonhosted.org/packages/d8/20/af388e8bf9f9a0f89eeef7d2a1935d176ee1c20bc6adeda05035879379cf/xxhash-3.8.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:b0093cf7eeb91b84776e8742113afa4bdf47533d36cf719179aaaf1f56f6f8bf", size = 238228, upload-time = "2026-07-06T10:45:38.02Z" }, + { url = "https://files.pythonhosted.org/packages/63/6b/4666579a87eebd1744663c404297355fa0658617b015cedfa58810ee7036/xxhash-3.8.1-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:3a800912a2e5e975d4128969d645c4a2a80aa886ccd6c9b1c6f44529e327e8cf", size = 269137, upload-time = "2026-07-06T10:45:39.954Z" }, + { url = "https://files.pythonhosted.org/packages/de/d3/e963a8a46f900a137d91b02144d8ea07a8f812971b138204a3b2f8b8e55c/xxhash-3.8.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:0fe37f72a207223d22a4eddc3149d4298993385aa9daef25c039246ca5a309f3", size = 225068, upload-time = "2026-07-06T10:45:41.718Z" }, + { url = "https://files.pythonhosted.org/packages/aa/80/9d181dbcde4b0fe48375f48833a5832d4b8cd2b349b15110c92ee472d874/xxhash-3.8.1-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:5db43f249b4be9f99ef4b967863f37094fb40e67effafb78ba4f0356b6396104", size = 240874, upload-time = "2026-07-06T10:45:43.414Z" }, + { url = "https://files.pythonhosted.org/packages/39/15/ce3ab5a1cd27ead25a5196e55a7284220f6ad6e316da494ffd900b2b600f/xxhash-3.8.1-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:c4ed42965c2cd9081f011be22f69d0e65d3b6165fe7734072fd0c232840bbd4e", size = 300702, upload-time = "2026-07-06T10:45:45.135Z" }, + { url = "https://files.pythonhosted.org/packages/96/c0/2281a8ab5f2a62dbf57a23c58a01ccc1d98abf40f71193c8a81f59e759b5/xxhash-3.8.1-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:3557bec8fcb11738a8920eeb68974bc76b75262f6947998d3147954ce0a4b893", size = 443351, upload-time = "2026-07-06T10:45:47.188Z" }, + { url = "https://files.pythonhosted.org/packages/81/2e/071a58c1a53a52d4f7a3aa0987be0c396dffd40da8204805fe1b130a81f4/xxhash-3.8.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:00de40f3b42240db23a82a5c682b55d7263d84a26a953240c1aee463409660e3", size = 217396, upload-time = "2026-07-06T10:45:48.925Z" }, + { url = "https://files.pythonhosted.org/packages/68/44/36ab58134badd9d3433fc7b53c4ca8d113d8e807782885628640f8297a4d/xxhash-3.8.1-cp313-cp313-win32.whl", hash = "sha256:b5196cc2574cfec572a5f3fb7cfa5ade27305ae3d06516a082132441aff4c83a", size = 31974, upload-time = "2026-07-06T10:45:50.591Z" }, + { url = "https://files.pythonhosted.org/packages/96/2a/2a0b84798448e766f7b89ceed073cb0cb5a43fc9ebbacbdea74a38de18e3/xxhash-3.8.1-cp313-cp313-win_amd64.whl", hash = "sha256:538f5f865df6cd8c32dd63158a0e5b4f5dd08d732a7da8b7228a5a0776c8ce55", size = 32739, upload-time = "2026-07-06T10:45:52.221Z" }, + { url = "https://files.pythonhosted.org/packages/d4/60/bb51dbf7c363ff88a7cbd50b7959718219577ef44d7cf255929ffc4a2194/xxhash-3.8.1-cp313-cp313-win_arm64.whl", hash = "sha256:a6617f30641ba0d8baa1635fbefb1dffc5165ec36d26921bd5cee13497cd937a", size = 29239, upload-time = "2026-07-06T10:45:53.714Z" }, + { url = "https://files.pythonhosted.org/packages/56/d3/827ca123c2ee5443a6aaed3c5dd199237dc2f010e2bebd7ec09ef36f3a5f/xxhash-3.8.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:bfcd82852c62a60e314670a9602de354c4460f8adad916e2e42a20860c7870bc", size = 34964, upload-time = "2026-07-06T10:45:55.535Z" }, + { url = "https://files.pythonhosted.org/packages/05/67/67ae2a3ccdeb8b8ef025d35aee9edd1d26c3abe5051d47da9286232afbf8/xxhash-3.8.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:08ea2081f5e88615fec8622a9f87fbe21b8ea58d88cfc02163ca11026ee62a92", size = 32697, upload-time = "2026-07-06T10:45:57.288Z" }, + { url = "https://files.pythonhosted.org/packages/38/5a/3d3994346e1f45493679cb5c1ffc2bf454e410e9d1e8a662d253becee91e/xxhash-3.8.1-cp313-cp313t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:2e32855b6f9e5b18f449e59d45e3d5778bdeb660632ef2693cca267a11246c75", size = 225954, upload-time = "2026-07-06T10:45:58.897Z" }, + { url = "https://files.pythonhosted.org/packages/3f/2c/53169270309b7cd8e05504e07fe123bac053b89d00ac63617faacf0a2ec0/xxhash-3.8.1-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a6e088bd7870775624256a0d84c2a6714afd223b2eeb56b0ca58398e52a32fda", size = 249776, upload-time = "2026-07-06T10:46:00.977Z" }, + { url = "https://files.pythonhosted.org/packages/70/e0/5c551d8d592f944506f7c5185e210255c15e672a3c6008c156a1bd9b775e/xxhash-3.8.1-cp313-cp313t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:72eb5ae575cc7ae2b23f6f8064a8b10f638c7149819ae9cc6d20ebd4d37a1629", size = 274776, upload-time = "2026-07-06T10:46:02.869Z" }, + { url = "https://files.pythonhosted.org/packages/a0/2a/d3a762270cee2d7bcd0e25e28c623e5f3f5c0dc637b66e3e47dd5b0bb3f0/xxhash-3.8.1-cp313-cp313t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:d0b48cdf690a64cedf7258c3dc9506cc41fc86edd7739c40e3098952265dc068", size = 252056, upload-time = "2026-07-06T10:46:04.688Z" }, + { url = "https://files.pythonhosted.org/packages/c1/8f/b78e4373b2cb6d1c42af60ea2d7e9146ad0710b239ac7f706d5d31d5bb98/xxhash-3.8.1-cp313-cp313t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:fb9e256a357dfcede7818c6d34e70db2d6b664394803d1de4b6984d2de76c0f1", size = 482108, upload-time = "2026-07-06T10:46:06.498Z" }, + { url = "https://files.pythonhosted.org/packages/e6/0d/642d923336ea61a15f8ce64fc7e078729e6e06c3a026e517fa79b2c23b7a/xxhash-3.8.1-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:51f71a6e2ad071e70c937e41fcb6c19f82c3f9f49831eba850ed4a106ffbb647", size = 226739, upload-time = "2026-07-06T10:46:08.598Z" }, + { url = "https://files.pythonhosted.org/packages/a6/0a/a37d6da6427d45a8d23e3ee3a0ca9c9d4a90364849c6637fe2963a755f9b/xxhash-3.8.1-cp313-cp313t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:e4a6443968c4e8dc69967e12776776a5952c119cc1bd94168ad1c5ad667c2be1", size = 319658, upload-time = "2026-07-06T10:46:10.504Z" }, + { url = "https://files.pythonhosted.org/packages/4a/51/ebbd40da8a3f1bc53b4b7a9a87f8e28bd95c5f21bc14b8a57860cf367d1b/xxhash-3.8.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:714503083a1f2065c9ad15340dd49ac8a8e948a505a705ffa1750cb951519113", size = 246059, upload-time = "2026-07-06T10:46:12.634Z" }, + { url = "https://files.pythonhosted.org/packages/24/4c/d9014030147e1f0bb26e7da47aa240dd9ec61c763c573e558111d869f8e1/xxhash-3.8.1-cp313-cp313t-musllinux_1_2_armv7l.whl", hash = "sha256:77f74e45a1e5574bbbf80181c8027b3a4c65c2248fffbd557bd596fff13102f9", size = 275535, upload-time = "2026-07-06T10:46:14.614Z" }, + { url = "https://files.pythonhosted.org/packages/84/86/caee2db41fadcd5a25aa4323213f9afec5a8586d4e419241e3d659362bd7/xxhash-3.8.1-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:4e0e1b0fb0259c1b75d1251ac0bb4d7ab675d36f7a6bf4ba6aa630dae94f9ffa", size = 231292, upload-time = "2026-07-06T10:46:16.452Z" }, + { url = "https://files.pythonhosted.org/packages/0b/60/f52f08bcdc904c4514ea5c25caa19e9f3214144434a6ff96dc82dc1cbddd/xxhash-3.8.1-cp313-cp313t-musllinux_1_2_ppc64le.whl", hash = "sha256:10e4393ec33633c2f05ad01869e546ad080b1a18f2650503731f153774608b31", size = 250490, upload-time = "2026-07-06T10:46:18.318Z" }, + { url = "https://files.pythonhosted.org/packages/24/a0/94dc7ae310838f250669c6ad7168e6d6fca17d49dac1053f06dc232c4a56/xxhash-3.8.1-cp313-cp313t-musllinux_1_2_riscv64.whl", hash = "sha256:b3ba794c3d885803db6c3116686923f1ec13bc86e621e169a375282b63ea1cc6", size = 309861, upload-time = "2026-07-06T10:46:20.503Z" }, + { url = "https://files.pythonhosted.org/packages/8b/f9/adeead7d0eb28cdfc2832544ea639ffbc6749ccde47a8e228d667459182e/xxhash-3.8.1-cp313-cp313t-musllinux_1_2_s390x.whl", hash = "sha256:57189a69c0891e4818853feaa521c972d22c880a001453addea015f48e3c3398", size = 448739, upload-time = "2026-07-06T10:46:22.79Z" }, + { url = "https://files.pythonhosted.org/packages/04/a4/22ec0e07db57d901c9298ae98aa3cf2be45bafded6f07c13131e85b89032/xxhash-3.8.1-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:d59e71153fe9ff85648d00e18649b07e9b22c797291abb7e27274fa06df8b838", size = 223657, upload-time = "2026-07-06T10:46:24.831Z" }, + { url = "https://files.pythonhosted.org/packages/94/32/8a9531f37b59e5a013003db7cb7414baf4ce7e0e1268e0d5947cd3d6a2df/xxhash-3.8.1-cp313-cp313t-win32.whl", hash = "sha256:5b96f0024e9840f449bd91b2d005c921a4b666055a0d1b6492463799f32aae22", size = 32377, upload-time = "2026-07-06T10:46:26.86Z" }, + { url = "https://files.pythonhosted.org/packages/e7/ab/2ca45fd7f671de5f81fc297ef1c95080b40c86ec6be0cc6034b8f7707ac8/xxhash-3.8.1-cp313-cp313t-win_amd64.whl", hash = "sha256:37d5a56c36dcc0b9a87b814cd992598d33863ff683749de6c86081f278d5e629", size = 33274, upload-time = "2026-07-06T10:46:28.39Z" }, + { url = "https://files.pythonhosted.org/packages/5a/54/20d7163463ddb6438b73a427d1655a77a502cf9b9b0c3ada3599629d9c0a/xxhash-3.8.1-cp313-cp313t-win_arm64.whl", hash = "sha256:6696c8752aded28ff3b16f33ef28ce28fb5d209b80c206746f943199fcf5fd65", size = 29375, upload-time = "2026-07-06T10:46:29.962Z" }, + { url = "https://files.pythonhosted.org/packages/c2/8b/df2ba04f22a6cd6b39f96a6577329a8471a55c90ef8d8e2f7c102363613f/xxhash-3.8.1-cp314-cp314-android_24_arm64_v8a.whl", hash = "sha256:9db455cb649dcfe4504d6d68a6d83a7315a99a3ca59871dc3ff840671f99adba", size = 38430, upload-time = "2026-07-06T10:46:31.496Z" }, + { url = "https://files.pythonhosted.org/packages/b2/4f/6a059e8ad3ca8deedc91dfe335b211204900895152212c03ebbe721de68b/xxhash-3.8.1-cp314-cp314-android_24_x86_64.whl", hash = "sha256:affb37f152e55b5e4494bb9d0107f7bb08515c6704fbed82d9f61214d74adc17", size = 36558, upload-time = "2026-07-06T10:46:33.078Z" }, + { url = "https://files.pythonhosted.org/packages/cb/95/40be178205acce092ae418feb20ac737b32a02c7b864926ed0717354c9f8/xxhash-3.8.1-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:460261045936975193bfd20549a0de1cd52a33b405cbb972f0d80940c42266cd", size = 31181, upload-time = "2026-07-06T10:46:34.793Z" }, + { url = "https://files.pythonhosted.org/packages/3f/89/2da4dbf051bafa156c0e3f12012db2b0ac3b84ff37ca1f021f6bfffcdfbb/xxhash-3.8.1-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:38c887aedb696ef8bca19983206d270848558cfae4a91afa6a2fb05dde58ffc5", size = 32192, upload-time = "2026-07-06T10:46:36.393Z" }, + { url = "https://files.pythonhosted.org/packages/7c/4e/e000bbae3566bc8e0be771a8a0f294aa99075e3f0bc4ef43922ebffdebc8/xxhash-3.8.1-cp314-cp314-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:594131ce1aad18db3689781f806db1b065cdaa04f4df36b4c038d2013aefd0bf", size = 34691, upload-time = "2026-07-06T10:46:38.1Z" }, + { url = "https://files.pythonhosted.org/packages/b4/4a/ea954aacc7d1c8711880ac2b55da94429a9b4296b151c4fc0966549ca1ee/xxhash-3.8.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:78c794b643d214f1522e7a288bcf5a2de120d26cd170516749a4009dc92722c9", size = 34807, upload-time = "2026-07-06T10:46:39.647Z" }, + { url = "https://files.pythonhosted.org/packages/ca/29/df598e738ff37558ac627264deb2e560902d9bf7f46d3bd5175c9eee593e/xxhash-3.8.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:af0c9fedc4a2c24e8664953882fe8185f3790b8338c9c700f76f5ad660817711", size = 32410, upload-time = "2026-07-06T10:46:41.359Z" }, + { url = "https://files.pythonhosted.org/packages/59/9c/81ab40e7d33ada0b3df5d1bc884894d15dbf4f805cd645b685e4606bb8e0/xxhash-3.8.1-cp314-cp314-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:115772daeb71b2f3b9381177017f53e6cf3f3439c840737fdabd21aba6e54920", size = 220564, upload-time = "2026-07-06T10:46:43.463Z" }, + { url = "https://files.pythonhosted.org/packages/fd/6f/62ae6f5c8606320a0e2a41c2dc8c6d91cc5d63d0f84dd9582e9543779dd8/xxhash-3.8.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:000435984a0469b0f822fe76f35bddea0f96a4d6521b3339a60a6428cdee1edc", size = 241462, upload-time = "2026-07-06T10:46:45.509Z" }, + { url = "https://files.pythonhosted.org/packages/15/a1/9c3a0ec6cb524396f551eddd102a76690a795494eb9784fc67542b0daa37/xxhash-3.8.1-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:2f1c68394818e0595569c2ff3cbc1e6d5a36a434e796f5c526b987b80c8a8c62", size = 264491, upload-time = "2026-07-06T10:46:47.655Z" }, + { url = "https://files.pythonhosted.org/packages/64/f2/700a4674e4308eb59d2fdb973977e82eae231bea5044753fee5c9eec0e0c/xxhash-3.8.1-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:46b39976d008e2a845758650f0ff7136bca004f40da0c8798bd37ac37860154f", size = 242905, upload-time = "2026-07-06T10:46:49.857Z" }, + { url = "https://files.pythonhosted.org/packages/f3/8a/72d9874375c8d4cbc64a8cd1d659d5695a8765c3db82efa82dc5bd9f14d0/xxhash-3.8.1-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:d5006c65ec507a333479e76e00e2c368781f16c24ededa764763956b32a0e93e", size = 473873, upload-time = "2026-07-06T10:46:51.953Z" }, + { url = "https://files.pythonhosted.org/packages/03/f0/6db07590ed7e0a77f186ef0bcea8d52553bf1ba57833e09467a2411f0f2d/xxhash-3.8.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c31a2649bcf1fe97cf11c79848d761df33ac46b3896942d31b640557b486ff6b", size = 220765, upload-time = "2026-07-06T10:46:55.41Z" }, + { url = "https://files.pythonhosted.org/packages/8f/10/00d12d8b8beabbf49a8bbc626fb9f40445145a8887eb41a6acfb69149ac4/xxhash-3.8.1-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:8f759eed402448c2bdbb492e4fba1f20668ffe29688605ea61f0f67f9e4e386d", size = 310478, upload-time = "2026-07-06T10:46:57.729Z" }, + { url = "https://files.pythonhosted.org/packages/1f/f9/12a82394eefb0f185d15a7f7b9f627c61c475a72dd83718436a5b84b42ac/xxhash-3.8.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7b5f97ecfede10d5b2870383620e2d25c8561e217c7bf9081073802b54248d2b", size = 238393, upload-time = "2026-07-06T10:46:59.87Z" }, + { url = "https://files.pythonhosted.org/packages/20/f3/53f963e320b9ce678337aa7273f39ce692ded8b99e3d22a866ec722159ab/xxhash-3.8.1-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:1da930bbcac3e8fbe2191850e2abb57977a99348c12c4b385e1058ac1b0a9ecc", size = 268704, upload-time = "2026-07-06T10:47:01.806Z" }, + { url = "https://files.pythonhosted.org/packages/0a/50/5b5badbd87c82d9f9b5f58ac74a3f29ef08f6fc387b324b8fd482450b862/xxhash-3.8.1-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:747476436f6891b9773374ce8d48edcc8b12cb5b61b67c6fb6289633747d088f", size = 225015, upload-time = "2026-07-06T10:47:03.784Z" }, + { url = "https://files.pythonhosted.org/packages/30/93/3ca68265afe7b4e69435e08a7b6a1d9d0f2a071e889da1f8041ed00fe878/xxhash-3.8.1-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:4ef09bbc2519a93cd0f95f2ceb5f7b85919dffea643278e02362bf40e3c4bed1", size = 240951, upload-time = "2026-07-06T10:47:05.816Z" }, + { url = "https://files.pythonhosted.org/packages/dd/a6/27e19670c40f46b5e76e11f2f4713d21054804568425d870670e757172ad/xxhash-3.8.1-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:a5eed9d41995a83f3332b4e3396abb7f433cac584222bd7e305b606d8353861e", size = 300751, upload-time = "2026-07-06T10:47:07.95Z" }, + { url = "https://files.pythonhosted.org/packages/bc/fb/b33e27689959fe7ed2ae0b830af41560d65213943983afa9db3a8d481bce/xxhash-3.8.1-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:53f3ed9118397074ff63a79b66b7fec1c84c782eecde35c5bc94e420a971c231", size = 443480, upload-time = "2026-07-06T10:47:10Z" }, + { url = "https://files.pythonhosted.org/packages/26/60/0e0d973be5fe280753ef02fbc89349492ad6e903bf1dcb870b668f94b662/xxhash-3.8.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:d247b34bf433c92b41689318fd25d246313cab2275a6a47e2efac178b80d6efe", size = 217657, upload-time = "2026-07-06T10:47:12.196Z" }, + { url = "https://files.pythonhosted.org/packages/ad/68/c9e3ecef4a9a417d464cb5bd200aa12f73192dee677901b9e08e0ad0d1bb/xxhash-3.8.1-cp314-cp314-win32.whl", hash = "sha256:d58ce8b6cfa9c4d2f230557f69caf7c06369e318015d0b19485095bc2c5963ab", size = 32690, upload-time = "2026-07-06T10:47:14.204Z" }, + { url = "https://files.pythonhosted.org/packages/d7/99/e9e44588c0b62837bbec5ba7927816de0afa03406b1a0b6c7a7e1d1a30a0/xxhash-3.8.1-cp314-cp314-win_amd64.whl", hash = "sha256:6cee733fe4ccb1737e0997135283c82341e5cfa9cf214b165f9087fb663aaf4f", size = 33460, upload-time = "2026-07-06T10:47:16.021Z" }, + { url = "https://files.pythonhosted.org/packages/45/2b/64f36d86380b3657ad9031967ab814f3ef31307174650853f69c18932ebc/xxhash-3.8.1-cp314-cp314-win_arm64.whl", hash = "sha256:58346024d47e84f7d8b3e7f5d6faa1d58acbbe49a8771497872059f58c1d8ea5", size = 30092, upload-time = "2026-07-06T10:47:17.81Z" }, + { url = "https://files.pythonhosted.org/packages/92/cb/18b64bff88c58a0ca209dc533e63cf02d7ae5aa6b1b9a9fd14e81b5dbd60/xxhash-3.8.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:01cab782f8a0a05ecad2c63d7ef10f7ab475f660e0d6419d069418c14d88de7c", size = 35024, upload-time = "2026-07-06T10:47:19.821Z" }, + { url = "https://files.pythonhosted.org/packages/af/1d/72d8a70520e5dcddb472ea0486d299da3240745a10658290cd7b5690ede2/xxhash-3.8.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:717b12fdc51819833704e85e6926d76981ffa3f780ef92e33ebb8b26d46bb230", size = 32697, upload-time = "2026-07-06T10:47:21.649Z" }, + { url = "https://files.pythonhosted.org/packages/9c/b8/e041f555903c56db3d0a731b3d72a6575d75e0ed868b1bd2e5176111ca44/xxhash-3.8.1-cp314-cp314t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:ec55d80e9b8a519d742669e0b49e8ce9e6747be42bf3c138158b6543a9c8e489", size = 226044, upload-time = "2026-07-06T10:47:23.612Z" }, + { url = "https://files.pythonhosted.org/packages/3a/7e/5cdcf06bf6ec4b5d2ac073feb23432ec1d603fd438864cbd2c09c7cb45e1/xxhash-3.8.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:98d8ac1129b4dd39098cffed94d1284aceb61c3aa396757ccc736ac392e4cee5", size = 249899, upload-time = "2026-07-06T10:47:25.812Z" }, + { url = "https://files.pythonhosted.org/packages/c0/c0/eb7e059cb5e1dba11fd30d2fdf882f56e5a417a3eaa43669d43623767f45/xxhash-3.8.1-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:3bc0fa90830df1e1277f33cc6e55de9990b83c0319fd8c7412866cfde38b025e", size = 274892, upload-time = "2026-07-06T10:47:27.931Z" }, + { url = "https://files.pythonhosted.org/packages/66/74/a600aaf7cd39957fd1510adeedb1749c1e7eb82bd632a1153d9c664c3135/xxhash-3.8.1-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:c73b6f652f0745425aa6378319c331293b5341756262e9408ed3d45f183375e6", size = 252243, upload-time = "2026-07-06T10:47:30.288Z" }, + { url = "https://files.pythonhosted.org/packages/ad/04/78d88fa75a6763e5d09bf1b947a392a27988903381b219006f92f3c68fc8/xxhash-3.8.1-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:f6114692261eff4266386cdec0f7d87eee24e317ab397c218b7ae6a76b4c6339", size = 482191, upload-time = "2026-07-06T10:47:32.45Z" }, + { url = "https://files.pythonhosted.org/packages/7f/06/07a8aea1108d682de8791ce608cdf367d75ff4e7e57cd3c154bdc6f47b23/xxhash-3.8.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4df57c0b161ec1b3ed0526a67b0db0914b557e86ee8aae51887aec941b261542", size = 226877, upload-time = "2026-07-06T10:47:34.705Z" }, + { url = "https://files.pythonhosted.org/packages/ed/b5/86bade5618a524d2c06c4041aa2fe8e5749ce16e88afba60d67c1684a21f/xxhash-3.8.1-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:9043877a917be88ccf230aa5667c1bd059bce80f4c2727e4defa1b29b7f48b08", size = 319794, upload-time = "2026-07-06T10:47:37.08Z" }, + { url = "https://files.pythonhosted.org/packages/23/69/9b1a2b89b1621bb740fbcb7beb512f60f99480c1bdc680c0c90e1f56ff75/xxhash-3.8.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:559e3cabe522231909f9de98ef06929edbd53782046bd21aae0c72db6f2a0775", size = 246202, upload-time = "2026-07-06T10:47:39.676Z" }, + { url = "https://files.pythonhosted.org/packages/08/ea/662ed6cb49f1d34078b6a3a3e0f3d29ff93fd7b5a03c0bc9ecfd9b2159c3/xxhash-3.8.1-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:264710bd335016f303763ce1275c6486df30bb57c2245c91b224c983d7ac39b8", size = 275628, upload-time = "2026-07-06T10:47:41.99Z" }, + { url = "https://files.pythonhosted.org/packages/13/f5/49fc9e4c6728a5a3bd8fe639199d2fa67609b3a84f938aff6e8568dd3e4f/xxhash-3.8.1-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:e14800b9b10bb39d7a60ad4a310e403164d7b8988a27ae933d4e40618a44088e", size = 231390, upload-time = "2026-07-06T10:47:44.233Z" }, + { url = "https://files.pythonhosted.org/packages/64/9d/3acaf8f599c0e0b30e910a3a11ba32929da53c86dc73c7c55fe6a010b4e9/xxhash-3.8.1-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:ea6a3e734b0fd41b82784a400be946821900daebe610c050a5e0760838a34f99", size = 250600, upload-time = "2026-07-06T10:47:47.611Z" }, + { url = "https://files.pythonhosted.org/packages/23/64/8acab4c5ec60dbe664b5b9858fd44c2413b07e535b09556a0a5022e78aa6/xxhash-3.8.1-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:cf399fac542a1c7a4734a435b93df2c55e858c7d31abf6c1bdf46f9ae67fbfd0", size = 310032, upload-time = "2026-07-06T10:47:49.88Z" }, + { url = "https://files.pythonhosted.org/packages/56/47/a0288d7329b1fe63e2734a32d19d444a96ae2b4810f545bc61e561224917/xxhash-3.8.1-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:44c89d915a75c11d2547eaee9098fcd80398987c4bff2974a0497a925bf92c07", size = 448882, upload-time = "2026-07-06T10:47:52.631Z" }, + { url = "https://files.pythonhosted.org/packages/01/e7/3071dfd3beb5c38204ce1cf56bf7749fce08de900fa92714b81d1d8ca1f2/xxhash-3.8.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:358650d5bda9c635da699c53adf4e8134af492ecc79c960f917eebf088bb6799", size = 223728, upload-time = "2026-07-06T10:47:55.093Z" }, + { url = "https://files.pythonhosted.org/packages/12/11/b99949f0ba2b07e9f9ffe83b9c86faa685f9080725dc21a916a607313be5/xxhash-3.8.1-cp314-cp314t-win32.whl", hash = "sha256:c240939e963653054fc7e4a17c382829cda4aa88a7daf0af841715dbded1b497", size = 33150, upload-time = "2026-07-06T10:47:57.274Z" }, + { url = "https://files.pythonhosted.org/packages/54/1c/09703eb341f8416e74e58d6c6732d4b5c46de59c942363203cb237cc95b0/xxhash-3.8.1-cp314-cp314t-win_amd64.whl", hash = "sha256:7258ee276e8772599bc19e14b36f6260306e21b637190cd7cb489a2449d48684", size = 34005, upload-time = "2026-07-06T10:47:59.434Z" }, + { url = "https://files.pythonhosted.org/packages/d6/f9/6ed7251bb6a8af10ac73b1821c60583d2826e5b2064e45a979c935287c98/xxhash-3.8.1-cp314-cp314t-win_arm64.whl", hash = "sha256:8f454166c2ffed45636c8d501741e649851ba2f346c4eb73a64c07ac00428f20", size = 30239, upload-time = "2026-07-06T10:48:01.874Z" }, +] + [[package]] name = "yarl" version = "1.24.2" @@ -4601,3 +4743,60 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/65/a4/ba80dccd3593ff1f01051a818694d07b58cb8232677ee9a22a5a1f93a9fc/yarl-1.24.2-cp314-cp314t-win_arm64.whl", hash = "sha256:e434a45ce2e7a947f951fc5a8944c8cc080b7e59f9c50ae80fd39107cf88126d", size = 91219, upload-time = "2026-05-19T21:31:01.934Z" }, { url = "https://files.pythonhosted.org/packages/fd/4d/4b880086bd0d3e034d25647be1d830afc3e3f610e98c4ab3490af6b1b6d5/yarl-1.24.2-py3-none-any.whl", hash = "sha256:2783d9226db8797636cd6896e4de81feed252d1db72265686c9558d97a4d94b9", size = 53576, upload-time = "2026-05-19T21:31:03.909Z" }, ] + +[[package]] +name = "zstandard" +version = "0.25.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fd/aa/3e0508d5a5dd96529cdc5a97011299056e14c6505b678fd58938792794b1/zstandard-0.25.0.tar.gz", hash = "sha256:7713e1179d162cf5c7906da876ec2ccb9c3a9dcbdffef0cc7f70c3667a205f0b", size = 711513, upload-time = "2025-09-14T22:15:54.002Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/82/fc/f26eb6ef91ae723a03e16eddb198abcfce2bc5a42e224d44cc8b6765e57e/zstandard-0.25.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7b3c3a3ab9daa3eed242d6ecceead93aebbb8f5f84318d82cee643e019c4b73b", size = 795738, upload-time = "2025-09-14T22:16:56.237Z" }, + { url = "https://files.pythonhosted.org/packages/aa/1c/d920d64b22f8dd028a8b90e2d756e431a5d86194caa78e3819c7bf53b4b3/zstandard-0.25.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:913cbd31a400febff93b564a23e17c3ed2d56c064006f54efec210d586171c00", size = 640436, upload-time = "2025-09-14T22:16:57.774Z" }, + { url = "https://files.pythonhosted.org/packages/53/6c/288c3f0bd9fcfe9ca41e2c2fbfd17b2097f6af57b62a81161941f09afa76/zstandard-0.25.0-cp312-cp312-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:011d388c76b11a0c165374ce660ce2c8efa8e5d87f34996aa80f9c0816698b64", size = 5343019, upload-time = "2025-09-14T22:16:59.302Z" }, + { url = "https://files.pythonhosted.org/packages/1e/15/efef5a2f204a64bdb5571e6161d49f7ef0fffdbca953a615efbec045f60f/zstandard-0.25.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6dffecc361d079bb48d7caef5d673c88c8988d3d33fb74ab95b7ee6da42652ea", size = 5063012, upload-time = "2025-09-14T22:17:01.156Z" }, + { url = "https://files.pythonhosted.org/packages/b7/37/a6ce629ffdb43959e92e87ebdaeebb5ac81c944b6a75c9c47e300f85abdf/zstandard-0.25.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:7149623bba7fdf7e7f24312953bcf73cae103db8cae49f8154dd1eadc8a29ecb", size = 5394148, upload-time = "2025-09-14T22:17:03.091Z" }, + { url = "https://files.pythonhosted.org/packages/e3/79/2bf870b3abeb5c070fe2d670a5a8d1057a8270f125ef7676d29ea900f496/zstandard-0.25.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:6a573a35693e03cf1d67799fd01b50ff578515a8aeadd4595d2a7fa9f3ec002a", size = 5451652, upload-time = "2025-09-14T22:17:04.979Z" }, + { url = "https://files.pythonhosted.org/packages/53/60/7be26e610767316c028a2cbedb9a3beabdbe33e2182c373f71a1c0b88f36/zstandard-0.25.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5a56ba0db2d244117ed744dfa8f6f5b366e14148e00de44723413b2f3938a902", size = 5546993, upload-time = "2025-09-14T22:17:06.781Z" }, + { url = "https://files.pythonhosted.org/packages/85/c7/3483ad9ff0662623f3648479b0380d2de5510abf00990468c286c6b04017/zstandard-0.25.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:10ef2a79ab8e2974e2075fb984e5b9806c64134810fac21576f0668e7ea19f8f", size = 5046806, upload-time = "2025-09-14T22:17:08.415Z" }, + { url = "https://files.pythonhosted.org/packages/08/b3/206883dd25b8d1591a1caa44b54c2aad84badccf2f1de9e2d60a446f9a25/zstandard-0.25.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:aaf21ba8fb76d102b696781bddaa0954b782536446083ae3fdaa6f16b25a1c4b", size = 5576659, upload-time = "2025-09-14T22:17:10.164Z" }, + { url = "https://files.pythonhosted.org/packages/9d/31/76c0779101453e6c117b0ff22565865c54f48f8bd807df2b00c2c404b8e0/zstandard-0.25.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1869da9571d5e94a85a5e8d57e4e8807b175c9e4a6294e3b66fa4efb074d90f6", size = 4953933, upload-time = "2025-09-14T22:17:11.857Z" }, + { url = "https://files.pythonhosted.org/packages/18/e1/97680c664a1bf9a247a280a053d98e251424af51f1b196c6d52f117c9720/zstandard-0.25.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:809c5bcb2c67cd0ed81e9229d227d4ca28f82d0f778fc5fea624a9def3963f91", size = 5268008, upload-time = "2025-09-14T22:17:13.627Z" }, + { url = "https://files.pythonhosted.org/packages/1e/73/316e4010de585ac798e154e88fd81bb16afc5c5cb1a72eeb16dd37e8024a/zstandard-0.25.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:f27662e4f7dbf9f9c12391cb37b4c4c3cb90ffbd3b1fb9284dadbbb8935fa708", size = 5433517, upload-time = "2025-09-14T22:17:16.103Z" }, + { url = "https://files.pythonhosted.org/packages/5b/60/dd0f8cfa8129c5a0ce3ea6b7f70be5b33d2618013a161e1ff26c2b39787c/zstandard-0.25.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:99c0c846e6e61718715a3c9437ccc625de26593fea60189567f0118dc9db7512", size = 5814292, upload-time = "2025-09-14T22:17:17.827Z" }, + { url = "https://files.pythonhosted.org/packages/fc/5f/75aafd4b9d11b5407b641b8e41a57864097663699f23e9ad4dbb91dc6bfe/zstandard-0.25.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:474d2596a2dbc241a556e965fb76002c1ce655445e4e3bf38e5477d413165ffa", size = 5360237, upload-time = "2025-09-14T22:17:19.954Z" }, + { url = "https://files.pythonhosted.org/packages/ff/8d/0309daffea4fcac7981021dbf21cdb2e3427a9e76bafbcdbdf5392ff99a4/zstandard-0.25.0-cp312-cp312-win32.whl", hash = "sha256:23ebc8f17a03133b4426bcc04aabd68f8236eb78c3760f12783385171b0fd8bd", size = 436922, upload-time = "2025-09-14T22:17:24.398Z" }, + { url = "https://files.pythonhosted.org/packages/79/3b/fa54d9015f945330510cb5d0b0501e8253c127cca7ebe8ba46a965df18c5/zstandard-0.25.0-cp312-cp312-win_amd64.whl", hash = "sha256:ffef5a74088f1e09947aecf91011136665152e0b4b359c42be3373897fb39b01", size = 506276, upload-time = "2025-09-14T22:17:21.429Z" }, + { url = "https://files.pythonhosted.org/packages/ea/6b/8b51697e5319b1f9ac71087b0af9a40d8a6288ff8025c36486e0c12abcc4/zstandard-0.25.0-cp312-cp312-win_arm64.whl", hash = "sha256:181eb40e0b6a29b3cd2849f825e0fa34397f649170673d385f3598ae17cca2e9", size = 462679, upload-time = "2025-09-14T22:17:23.147Z" }, + { url = "https://files.pythonhosted.org/packages/35/0b/8df9c4ad06af91d39e94fa96cc010a24ac4ef1378d3efab9223cc8593d40/zstandard-0.25.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ec996f12524f88e151c339688c3897194821d7f03081ab35d31d1e12ec975e94", size = 795735, upload-time = "2025-09-14T22:17:26.042Z" }, + { url = "https://files.pythonhosted.org/packages/3f/06/9ae96a3e5dcfd119377ba33d4c42a7d89da1efabd5cb3e366b156c45ff4d/zstandard-0.25.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a1a4ae2dec3993a32247995bdfe367fc3266da832d82f8438c8570f989753de1", size = 640440, upload-time = "2025-09-14T22:17:27.366Z" }, + { url = "https://files.pythonhosted.org/packages/d9/14/933d27204c2bd404229c69f445862454dcc101cd69ef8c6068f15aaec12c/zstandard-0.25.0-cp313-cp313-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:e96594a5537722fdfb79951672a2a63aec5ebfb823e7560586f7484819f2a08f", size = 5343070, upload-time = "2025-09-14T22:17:28.896Z" }, + { url = "https://files.pythonhosted.org/packages/6d/db/ddb11011826ed7db9d0e485d13df79b58586bfdec56e5c84a928a9a78c1c/zstandard-0.25.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:bfc4e20784722098822e3eee42b8e576b379ed72cca4a7cb856ae733e62192ea", size = 5063001, upload-time = "2025-09-14T22:17:31.044Z" }, + { url = "https://files.pythonhosted.org/packages/db/00/87466ea3f99599d02a5238498b87bf84a6348290c19571051839ca943777/zstandard-0.25.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:457ed498fc58cdc12fc48f7950e02740d4f7ae9493dd4ab2168a47c93c31298e", size = 5394120, upload-time = "2025-09-14T22:17:32.711Z" }, + { url = "https://files.pythonhosted.org/packages/2b/95/fc5531d9c618a679a20ff6c29e2b3ef1d1f4ad66c5e161ae6ff847d102a9/zstandard-0.25.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:fd7a5004eb1980d3cefe26b2685bcb0b17989901a70a1040d1ac86f1d898c551", size = 5451230, upload-time = "2025-09-14T22:17:34.41Z" }, + { url = "https://files.pythonhosted.org/packages/63/4b/e3678b4e776db00f9f7b2fe58e547e8928ef32727d7a1ff01dea010f3f13/zstandard-0.25.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:8e735494da3db08694d26480f1493ad2cf86e99bdd53e8e9771b2752a5c0246a", size = 5547173, upload-time = "2025-09-14T22:17:36.084Z" }, + { url = "https://files.pythonhosted.org/packages/4e/d5/ba05ed95c6b8ec30bd468dfeab20589f2cf709b5c940483e31d991f2ca58/zstandard-0.25.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:3a39c94ad7866160a4a46d772e43311a743c316942037671beb264e395bdd611", size = 5046736, upload-time = "2025-09-14T22:17:37.891Z" }, + { url = "https://files.pythonhosted.org/packages/50/d5/870aa06b3a76c73eced65c044b92286a3c4e00554005ff51962deef28e28/zstandard-0.25.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:172de1f06947577d3a3005416977cce6168f2261284c02080e7ad0185faeced3", size = 5576368, upload-time = "2025-09-14T22:17:40.206Z" }, + { url = "https://files.pythonhosted.org/packages/5d/35/398dc2ffc89d304d59bc12f0fdd931b4ce455bddf7038a0a67733a25f550/zstandard-0.25.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:3c83b0188c852a47cd13ef3bf9209fb0a77fa5374958b8c53aaa699398c6bd7b", size = 4954022, upload-time = "2025-09-14T22:17:41.879Z" }, + { url = "https://files.pythonhosted.org/packages/9a/5c/36ba1e5507d56d2213202ec2b05e8541734af5f2ce378c5d1ceaf4d88dc4/zstandard-0.25.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:1673b7199bbe763365b81a4f3252b8e80f44c9e323fc42940dc8843bfeaf9851", size = 5267889, upload-time = "2025-09-14T22:17:43.577Z" }, + { url = "https://files.pythonhosted.org/packages/70/e8/2ec6b6fb7358b2ec0113ae202647ca7c0e9d15b61c005ae5225ad0995df5/zstandard-0.25.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:0be7622c37c183406f3dbf0cba104118eb16a4ea7359eeb5752f0794882fc250", size = 5433952, upload-time = "2025-09-14T22:17:45.271Z" }, + { url = "https://files.pythonhosted.org/packages/7b/01/b5f4d4dbc59ef193e870495c6f1275f5b2928e01ff5a81fecb22a06e22fb/zstandard-0.25.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:5f5e4c2a23ca271c218ac025bd7d635597048b366d6f31f420aaeb715239fc98", size = 5814054, upload-time = "2025-09-14T22:17:47.08Z" }, + { url = "https://files.pythonhosted.org/packages/b2/e5/fbd822d5c6f427cf158316d012c5a12f233473c2f9c5fe5ab1ae5d21f3d8/zstandard-0.25.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4f187a0bb61b35119d1926aee039524d1f93aaf38a9916b8c4b78ac8514a0aaf", size = 5360113, upload-time = "2025-09-14T22:17:48.893Z" }, + { url = "https://files.pythonhosted.org/packages/8e/e0/69a553d2047f9a2c7347caa225bb3a63b6d7704ad74610cb7823baa08ed7/zstandard-0.25.0-cp313-cp313-win32.whl", hash = "sha256:7030defa83eef3e51ff26f0b7bfb229f0204b66fe18e04359ce3474ac33cbc09", size = 436936, upload-time = "2025-09-14T22:17:52.658Z" }, + { url = "https://files.pythonhosted.org/packages/d9/82/b9c06c870f3bd8767c201f1edbdf9e8dc34be5b0fbc5682c4f80fe948475/zstandard-0.25.0-cp313-cp313-win_amd64.whl", hash = "sha256:1f830a0dac88719af0ae43b8b2d6aef487d437036468ef3c2ea59c51f9d55fd5", size = 506232, upload-time = "2025-09-14T22:17:50.402Z" }, + { url = "https://files.pythonhosted.org/packages/d4/57/60c3c01243bb81d381c9916e2a6d9e149ab8627c0c7d7abb2d73384b3c0c/zstandard-0.25.0-cp313-cp313-win_arm64.whl", hash = "sha256:85304a43f4d513f5464ceb938aa02c1e78c2943b29f44a750b48b25ac999a049", size = 462671, upload-time = "2025-09-14T22:17:51.533Z" }, + { url = "https://files.pythonhosted.org/packages/3d/5c/f8923b595b55fe49e30612987ad8bf053aef555c14f05bb659dd5dbe3e8a/zstandard-0.25.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:e29f0cf06974c899b2c188ef7f783607dbef36da4c242eb6c82dcd8b512855e3", size = 795887, upload-time = "2025-09-14T22:17:54.198Z" }, + { url = "https://files.pythonhosted.org/packages/8d/09/d0a2a14fc3439c5f874042dca72a79c70a532090b7ba0003be73fee37ae2/zstandard-0.25.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:05df5136bc5a011f33cd25bc9f506e7426c0c9b3f9954f056831ce68f3b6689f", size = 640658, upload-time = "2025-09-14T22:17:55.423Z" }, + { url = "https://files.pythonhosted.org/packages/5d/7c/8b6b71b1ddd517f68ffb55e10834388d4f793c49c6b83effaaa05785b0b4/zstandard-0.25.0-cp314-cp314-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:f604efd28f239cc21b3adb53eb061e2a205dc164be408e553b41ba2ffe0ca15c", size = 5379849, upload-time = "2025-09-14T22:17:57.372Z" }, + { url = "https://files.pythonhosted.org/packages/a4/86/a48e56320d0a17189ab7a42645387334fba2200e904ee47fc5a26c1fd8ca/zstandard-0.25.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:223415140608d0f0da010499eaa8ccdb9af210a543fac54bce15babbcfc78439", size = 5058095, upload-time = "2025-09-14T22:17:59.498Z" }, + { url = "https://files.pythonhosted.org/packages/f8/ad/eb659984ee2c0a779f9d06dbfe45e2dc39d99ff40a319895df2d3d9a48e5/zstandard-0.25.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:2e54296a283f3ab5a26fc9b8b5d4978ea0532f37b231644f367aa588930aa043", size = 5551751, upload-time = "2025-09-14T22:18:01.618Z" }, + { url = "https://files.pythonhosted.org/packages/61/b3/b637faea43677eb7bd42ab204dfb7053bd5c4582bfe6b1baefa80ac0c47b/zstandard-0.25.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:ca54090275939dc8ec5dea2d2afb400e0f83444b2fc24e07df7fdef677110859", size = 6364818, upload-time = "2025-09-14T22:18:03.769Z" }, + { url = "https://files.pythonhosted.org/packages/31/dc/cc50210e11e465c975462439a492516a73300ab8caa8f5e0902544fd748b/zstandard-0.25.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e09bb6252b6476d8d56100e8147b803befa9a12cea144bbe629dd508800d1ad0", size = 5560402, upload-time = "2025-09-14T22:18:05.954Z" }, + { url = "https://files.pythonhosted.org/packages/c9/ae/56523ae9c142f0c08efd5e868a6da613ae76614eca1305259c3bf6a0ed43/zstandard-0.25.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:a9ec8c642d1ec73287ae3e726792dd86c96f5681eb8df274a757bf62b750eae7", size = 4955108, upload-time = "2025-09-14T22:18:07.68Z" }, + { url = "https://files.pythonhosted.org/packages/98/cf/c899f2d6df0840d5e384cf4c4121458c72802e8bda19691f3b16619f51e9/zstandard-0.25.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:a4089a10e598eae6393756b036e0f419e8c1d60f44a831520f9af41c14216cf2", size = 5269248, upload-time = "2025-09-14T22:18:09.753Z" }, + { url = "https://files.pythonhosted.org/packages/1b/c0/59e912a531d91e1c192d3085fc0f6fb2852753c301a812d856d857ea03c6/zstandard-0.25.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:f67e8f1a324a900e75b5e28ffb152bcac9fbed1cc7b43f99cd90f395c4375344", size = 5430330, upload-time = "2025-09-14T22:18:11.966Z" }, + { url = "https://files.pythonhosted.org/packages/a0/1d/7e31db1240de2df22a58e2ea9a93fc6e38cc29353e660c0272b6735d6669/zstandard-0.25.0-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:9654dbc012d8b06fc3d19cc825af3f7bf8ae242226df5f83936cb39f5fdc846c", size = 5811123, upload-time = "2025-09-14T22:18:13.907Z" }, + { url = "https://files.pythonhosted.org/packages/f6/49/fac46df5ad353d50535e118d6983069df68ca5908d4d65b8c466150a4ff1/zstandard-0.25.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:4203ce3b31aec23012d3a4cf4a2ed64d12fea5269c49aed5e4c3611b938e4088", size = 5359591, upload-time = "2025-09-14T22:18:16.465Z" }, + { url = "https://files.pythonhosted.org/packages/c2/38/f249a2050ad1eea0bb364046153942e34abba95dd5520af199aed86fbb49/zstandard-0.25.0-cp314-cp314-win32.whl", hash = "sha256:da469dc041701583e34de852d8634703550348d5822e66a0c827d39b05365b12", size = 444513, upload-time = "2025-09-14T22:18:20.61Z" }, + { url = "https://files.pythonhosted.org/packages/3a/43/241f9615bcf8ba8903b3f0432da069e857fc4fd1783bd26183db53c4804b/zstandard-0.25.0-cp314-cp314-win_amd64.whl", hash = "sha256:c19bcdd826e95671065f8692b5a4aa95c52dc7a02a4c5a0cac46deb879a017a2", size = 516118, upload-time = "2025-09-14T22:18:17.849Z" }, + { url = "https://files.pythonhosted.org/packages/f0/ef/da163ce2450ed4febf6467d77ccb4cd52c4c30ab45624bad26ca0a27260c/zstandard-0.25.0-cp314-cp314-win_arm64.whl", hash = "sha256:d7541afd73985c630bafcd6338d2518ae96060075f9463d7dc14cfb33514383d", size = 476940, upload-time = "2025-09-14T22:18:19.088Z" }, +] From 574c54aba5f6289d701b1c9a1c9d05d7bc474cd4 Mon Sep 17 00:00:00 2001 From: Ali Muhammad Date: Fri, 24 Jul 2026 07:21:15 +0500 Subject: [PATCH 8/8] docs: document the expanded sandbox provider catalog --- CHANGELOG.md | 8 ++++++ site_docs/getting-started/installation.md | 6 ++++ site_docs/guides/sandbox-providers.md | 34 +++++++++++++++++++---- site_docs/reference/public-api.md | 14 +++++++++- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8189a2..7f030a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- **Expanded sandbox provider catalog** - E2B, Modal, Runloop, Vercel Sandbox, and LangSmith backends now implement the `SandboxProvider` protocol alongside Daytona, each behind its own install extra (`sandbox-e2b`, `sandbox-modal`, `sandbox-runloop`, `sandbox-vercel`, `sandbox-langsmith`) with lazy SDK imports, honest capability reports, evidence digests, and fail-closed handling of unsupported network modes, snapshot restores, and secret schemes. A new `create_sandbox_provider(name)` factory builds any backend by name. + +### Changed + +- **Provider-prefixed sandbox secrets** - `SandboxSpec.secret_references` now accepts any `:` reference instead of only `daytona:`; each backend validates its own prefix at create time and returns `sandbox_secret_reference_invalid` for foreign prefixes. Existing `daytona:` references keep working unchanged. + ## [0.8.2] - 2026-07-19 ### Changed diff --git a/site_docs/getting-started/installation.md b/site_docs/getting-started/installation.md index 12bc6eb..17643c6 100644 --- a/site_docs/getting-started/installation.md +++ b/site_docs/getting-started/installation.md @@ -78,6 +78,12 @@ Extras are additive — combine any of them in a single bracketed list, and inst | `azure` | Azure OpenAI provider support | | `tokens` | Token counting through `tiktoken` | | `providers` | All built-in provider SDKs | +| `sandbox` | Daytona sandbox provider support | +| `sandbox-e2b` | E2B sandbox provider support | +| `sandbox-modal` | Modal sandbox provider support | +| `sandbox-runloop` | Runloop sandbox provider support | +| `sandbox-vercel` | Vercel Sandbox provider support (beta SDK) | +| `sandbox-langsmith` | LangSmith sandbox provider support | | `all` | Every optional provider and framework integration | !!! note "Install only what the workload uses" diff --git a/site_docs/guides/sandbox-providers.md b/site_docs/guides/sandbox-providers.md index e7bb826..07c45ae 100644 --- a/site_docs/guides/sandbox-providers.md +++ b/site_docs/guides/sandbox-providers.md @@ -1,12 +1,36 @@ --- title: "Run AnyCode Work in Sandbox Providers" -description: Configure Daytona or companion sandboxes for AnyCode with identity, network policy, secret references, streamed commands, files, cancellation, and evidence. -keywords: AnyCode sandbox, Daytona Python sandbox, AI agent code execution, policy sandbox provider, isolated agent tools +description: Run AnyCode work in Daytona, E2B, Modal, Runloop, Vercel, or LangSmith sandboxes behind one protocol with network policy, secret references, and evidence. +keywords: AnyCode sandbox, Daytona E2B Modal Runloop Vercel LangSmith sandbox, AI agent code execution, policy sandbox provider, isolated agent tools --- # Run work through sandbox providers -The `SandboxProvider` protocol gives AnyCode one explicit boundary for remote execution, files, streaming, cancellation, cleanup, health, and evidence. Use `DaytonaSandboxProvider` for the maintained Daytona SDK or `CompanionSandboxAdapter` for a separately deployed sandbox service. Wrap either provider with `PolicySandboxProvider` when every operation needs an external authorization decision. +The `SandboxProvider` protocol gives AnyCode one explicit boundary for remote execution, files, streaming, cancellation, cleanup, health, and evidence. Six remote backends implement it — Daytona, E2B, Modal, Runloop, Vercel Sandbox, and LangSmith — plus `CompanionSandboxAdapter` for a separately deployed sandbox service. Wrap any provider with `PolicySandboxProvider` when every operation needs an external authorization decision. + +## Choose a provider + +Each backend ships behind its own install extra, and `create_sandbox_provider(name)` builds any of them without importing the SDK until first use: + +```python +from anycode import create_sandbox_provider + +provider = create_sandbox_provider("e2b") # or daytona, modal, runloop, vercel, langsmith +print(provider.capabilities()) +``` + +| Provider | Extra | Isolation | Snapshots | Live streaming | Network policy | Secret references | +| --- | --- | --- | --- | --- | --- | --- | +| `daytona` | `sandbox` | remote | no | yes | none / allowlist | `daytona:` | +| `e2b` | `sandbox-e2b` | microVM | no | buffered | unrestricted only | rejected | +| `modal` | `sandbox-modal` | container (gVisor) | yes | buffered | none / CIDR allowlist | `modal:` | +| `runloop` | `sandbox-runloop` | VM | yes | buffered | unrestricted only | rejected | +| `vercel` | `sandbox-vercel` | microVM | no | buffered | unrestricted only | rejected | +| `langsmith` | `sandbox-langsmith` | microVM | no | buffered | unrestricted only | rejected | + +Every backend fails closed: when a spec requests a network mode, snapshot restore, or secret scheme the provider cannot enforce, `create()` returns a typed error (`sandbox_network_policy_unsupported`, `sandbox_snapshot_unsupported`, `sandbox_secrets_unsupported`, or `sandbox_secret_reference_invalid`) instead of silently granting more than requested. "Buffered" streaming satisfies the streaming contract but delivers output after the command completes. Check `provider.capabilities()` — including its `limitations` tuple — before trusting a workload to a backend. + +Credentials always stay in each SDK's own configuration (`E2B_API_KEY`, Modal tokens, `RUNLOOP_API_KEY`, `VERCEL_TOKEN`/`VERCEL_OIDC_TOKEN` with team and project ids, `LANGSMITH_API_KEY`). Do not place credentials in `SandboxSpec`, a command environment, labels, logs, or durable run data. ## Install the Daytona integration @@ -14,7 +38,7 @@ The `SandboxProvider` protocol gives AnyCode one explicit boundary for remote ex uv add "anycode-py[sandbox]" ``` -Configure Daytona credentials through the SDK's supported host configuration. Do not place credentials in `SandboxSpec`, a command environment, labels, logs, or durable run data. +Configure Daytona credentials through the SDK's supported host configuration. ## Create and use a Daytona sandbox @@ -69,7 +93,7 @@ Choose either `image` or `snapshot`, never both. The Daytona adapter currently r | `network="none"` | No allowlist entries may be supplied | | `network="allowlist"` | At least one domain or CIDR is required | | `network="unrestricted"` | The provider may allow unrestricted egress; use only under reviewed host policy | -| `secret_references` | Every value must start with `daytona:` | +| `secret_references` | Every value is a provider-prefixed reference (e.g. `daytona:token-name`); each backend accepts only its own prefix | | `SandboxCommand.environment` | Credential-like variable names are rejected | The provider and host must enforce the requested network policy. The model validates the request, but that validation is not proof of kernel, container, VM, or network isolation. diff --git a/site_docs/reference/public-api.md b/site_docs/reference/public-api.md index 062b9ef..5aa2063 100644 --- a/site_docs/reference/public-api.md +++ b/site_docs/reference/public-api.md @@ -765,14 +765,26 @@ Carry tenant, principal, and delegation context through a run, and enforce an ex ## Sandboxes -Run commands and file operations inside an isolated provider, gated by a capability and network policy. `PolicySandboxProvider` wraps any provider with policy checks; the Daytona and companion providers are concrete backends. See [run work in sandboxes](../guides/sandbox-providers.md). +Run commands and file operations inside an isolated provider, gated by a capability and network policy. `PolicySandboxProvider` wraps any provider with policy checks; Daytona, E2B, Modal, Runloop, Vercel, LangSmith, and companion providers are concrete backends, and `create_sandbox_provider` builds any of them by name. See [run work in sandboxes](../guides/sandbox-providers.md). ::: anycode.sandbox.protocol.SandboxProvider +::: anycode.sandbox.factory.create_sandbox_provider + ::: anycode.sandbox.policy.PolicySandboxProvider ::: anycode.sandbox.daytona.DaytonaSandboxProvider +::: anycode.sandbox.e2b.E2BSandboxProvider + +::: anycode.sandbox.modal.ModalSandboxProvider + +::: anycode.sandbox.runloop.RunloopSandboxProvider + +::: anycode.sandbox.vercel.VercelSandboxProvider + +::: anycode.sandbox.langsmith.LangSmithSandboxProvider + ::: anycode.sandbox.companion.CompanionSandboxAdapter ::: anycode.sandbox.models.SandboxSpec