Metadata-Version: 2.4
Name: dsb-sdk
Version: 0.10.7
Summary: Python SDK for DSB (Distributed Sandboxes)
Project-URL: Homepage, https://github.com/pengye91/dsb
Project-URL: Documentation, https://github.com/pengye91/dsb/blob/master/sdks/python/README.md
Project-URL: Repository, https://github.com/pengye91/dsb.git
Project-URL: Issues, https://github.com/pengye91/dsb/issues
Author: DSB Contributors
License: MIT
License-File: LICENSE
Keywords: api,async,docker,dsb,sandbox
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: anyio>=4.0.0
Requires-Dist: httpx[http2]>=0.27.0
Requires-Dist: prometheus-client>=0.20.0
Requires-Dist: pybreaker>=1.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: sse-starlette>=2.0.0
Requires-Dist: structlog>=24.0.0
Requires-Dist: tenacity>=8.5.0
Requires-Dist: typing-extensions>=4.12.0
Requires-Dist: websocket-client>=1.8.0
Provides-Extra: dev
Requires-Dist: bandit>=1.7.0; extra == 'dev'
Requires-Dist: mypy>=1.12.0; extra == 'dev'
Requires-Dist: pip-audit>=2.7.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest-benchmark>=4.0.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
Requires-Dist: pytest-mock>=3.14.0; extra == 'dev'
Requires-Dist: pytest-xdist>=3.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.8.0; extra == 'dev'
Requires-Dist: safety>=3.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# DSB Python SDK

Python SDK for interacting with Distributed Sandboxes (DSB), including sandbox management, SSH sessions, terminals, and web automation.

## Installation

```bash
pip install dsb-sdk
```

## Initialization

The SDK provides both synchronous and asynchronous clients. Always use context managers (`with` or `async with`) to ensure proper resource cleanup.

```python
from dsb_sdk import DSBClient, AsyncDSBClient

# Synchronous client
with DSBClient(api_url="http://localhost:8080/api") as client:
    pass # Use the client

# Asynchronous client
async with AsyncDSBClient(api_url="http://localhost:8080/api") as async_client:
    pass # Use the async client
```

## Quickstart: Sandbox Management

Create, check, and delete a sandbox easily.

```python
from dsb_sdk import DSBClient

with DSBClient(api_url="http://localhost:8080/api") as client:
    # Create a sandbox
    sandbox = client.sandbox.create(image="python:3.12", name="my-sandbox")
    print(f"Created sandbox: {sandbox.id}")
    
    # Check status
    status = client.sandbox.get(sandbox.id)
    print(f"Sandbox status: {status.state}")
    
    # Delete the sandbox
    client.sandbox.delete(sandbox.id)
    print("Sandbox deleted")
```

## Executing Code

Run commands directly inside a running sandbox.

```python
from dsb_sdk import DSBClient
from dsb_sdk.types.exec import ExecRequest

with DSBClient(api_url="http://localhost:8080/api") as client:
    sandbox = client.sandbox.create(image="python:3.12")
    
    # Execute a command
    request = ExecRequest(cmd=["echo", "Hello from DSB!"])
    response = client.sandbox.exec(sandbox.id, request)
    print(response.stdout)
    
    client.sandbox.delete(sandbox.id)
```

## Other Features

### SSH Access
Retrieve SSH connection details for a sandbox.
```python
with DSBClient(api_url="http://localhost:8080/api") as client:
    ssh_session = client.ssh.create_session(sandbox.id)
    print(f"Connect via: ssh -p {ssh_session.port} {ssh_session.user}@{ssh_session.host}")
```

### Web Automation
Scrape a webpage.
```python
with DSBClient(api_url="http://localhost:8080/api") as client:
    result = client.web.scrape("https://example.com")
    print(result.markdown)
```

## Async Support

All synchronous methods have an asynchronous equivalent when using `AsyncDSBClient`. Simply append `_async` to the method name.

```python
async with AsyncDSBClient(api_url="http://localhost:8080/api") as client:
    sandbox = await client.sandbox.create_async(image="python:3.12")
    await client.sandbox.delete_async(sandbox.id)
```
