Metadata-Version: 2.4
Name: opendsec
Version: 0.2.0
Summary: Async Python client for opendsec: open-source Sandboxes for RL rollouts.
Keywords: sandbox,reinforcement-learning,rollouts,evals,agents
Author: Vibrant Labs
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Dist: httpx>=0.28.1
Requires-Python: >=3.12
Project-URL: Documentation, https://opendsec.vibrantlabs.com
Description-Content-Type: text/markdown

# opendsec

Async Python client for [opendsec](https://opendsec.vibrantlabs.com): open-source Sandboxes for RL rollouts.

Each trial gets a **World**: a **Sandbox** for the agent's workspace and one for every service the task needs, on one private network, started and torn down as one.

```sh
pip install opendsec
```

```python
import asyncio

import opendsec


async def main():
    # Reads OPENDSEC_URL (default http://localhost:7700) and OPENDSEC_TOKEN.
    async with opendsec.Client() as client:
        world = await client.create_world(
            [
                opendsec.Sandbox(name="env", image="docker.io/library/python:3.12-slim",
                                 command=["python", "-m", "http.server", "8080"],
                                 aliases=["svc.internal"]),
                opendsec.Sandbox(name="main", image="docker.io/library/python:3.12-slim",
                                 command=["sleep", "infinity"]),
            ],
            ttl="5m",
        )
        result = await world.exec("main", "getent hosts svc.internal")
        print(result.exit_code, result.stdout)
        await world.stop()


asyncio.run(main())
```

- `Client.create_world(sandboxes, ttl)` returns once every Sandbox is ready, or raises `WorldFailed` if the platform couldn't deliver the World.
- `Client.build_image(dir)` builds an image on the platform from a Dockerfile and its build context, and returns once it is ready (a lookup if those files were built before). Use its `ref` as a Sandbox's `image`. No Docker needed; only you can run it.
- `World.exec`, `upload` and `download` act in one Sandbox, by name.
- `get_world` and `list_worlds` look Worlds up.

Run Harbor rollouts on the hosted test bed: https://opendsec.vibrantlabs.com

Licensed under Apache-2.0.
