Metadata-Version: 2.4
Name: deepagents-microsandbox
Version: 1.0.0
Summary: Microsandbox backend for DeepAgents
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: deepagents>=0.3.10
Requires-Dist: microsandbox>=0.1.8
Description-Content-Type: text/markdown

# deepagents-microsandbox

Microsandbox backend for the [DeepAgents](https://github.com/shkarupa-alex/deepagents) framework. This package enables DeepAgents to launch and control isolated sandbox environments using [Microsandbox](https://github.com/shkarupa-alex/microsandbox).

## Key Features

- **Sandbox Provider**: Manages the lifecycle of microsandbox instances (create, list, delete).
- **Sandbox Backend**: Provides a standard interface for file operations and command execution within a sandbox.
- **DeepAgents Integration**: Fully compatible with the DeepAgents `SandboxProvider` and `SandboxBackend` interfaces.

## Installation

```bash
pip install deepagents-microsandbox
```

## Usage

```python
from deepagents_microsandbox import MicrosandboxProvider

# Initialize the provider connecting to a microsandbox server
provider = MicrosandboxProvider(server_url="http://localhost:5555")

# Create or get a sandbox
sandbox = provider.get_or_create(sandbox_id=None)

# Execute a command
result = sandbox.execute("echo 'Hello World'")
print(result.stdout)

# Clean up
provider.delete(sandbox_id=sandbox.id)
```

## Development

This project uses `uv` for dependency management.

### Prerequisites

- [uv](https://github.com/astral-sh/uv) installed.
- Python 3.11 or higher.

### Setup

Install dependencies:

```bash
uv sync
```

### Testing

Tests are split into unit tests (mocked) and integration tests (requiring a real server).

**Run Unit Tests (Mocked)**
These tests mock the HTTP interactions and do not require a running server.
```bash
uv run pytest
```

**Run Integration Tests**
These tests verify behavior against a real microsandbox server.
1. Start a microsandbox server in dev mode:
   ```bash
   msb server start --dev
   ```
2. Run the tests with the environment variable:
   ```bash
   MICROSANDBOX_DEV_SERVER=http://127.0.0.1:5555 uv run pytest
   ```
