openenv-kosa8
kosa8: Zero Trust cybersecurity infrastructure for AI agents. Every agent sealed in its own microVM. Every action verified and recorded.
Run OpenEnv environment servers (the RL environment standard used by Hugging Face TRL) in kosa8 Cloud microVM sandboxes.
Kosa8Provider is an OpenEnv ContainerProvider, like the Docker, Modal, Daytona and Hugging Face providers. It boots an environment image as a kosa8 sandbox, starts the server and gives EnvClient a base_url that carries HTTP and the /ws WebSocket. Tested against openenv 0.15.
Install
pip install openenv-kosa8
Set KOSA8_API_KEY to a kosa8 Cloud API key (create one at app.kosa8.com, or run kosa8 login). The Starter plan is free, no card needed; plans are at kosa8.com/pricing.
Example
from echo_env import EchoEnv # or any OpenEnv client
from openenv_kosa8 import Kosa8Provider
provider = Kosa8Provider(image="registry.hf.space/openenv-echo-env:latest")
base_url = provider.start_container()
provider.wait_for_ready(base_url)
# The client stops the provider, deleting the sandbox, when the block ends.
with EchoEnv(base_url=base_url, provider=provider).sync() as env:
env.reset()
print(env.call_tool("echo_message", message="Hello!"))
Clients that do not need a base_url up front (non-MCP clients such as CodingEnv) can also take the provider alone: CodingEnv(provider=provider) starts it on connect.
For many rollouts, start one provider per environment and run them concurrently (see OpenEnv's runtime providers guide).
How it works
- Source.
imageis an OCI registry image, which kosa8 Cloud pulls and boots as the sandbox's root filesystem. Images built byopenenv build, and Hugging Face Space images such asregistry.hf.space/openenv-echo-env:latest, work as they are. The image'sCMDis not run: the provider builds the server command fromopenenv.yaml(/app/env/openenv.yaml, or the first one under/app), or takescmd=. Build and push Dockerfiles first. - Ingress. The server port (8000 unless
port=says otherwise) is opened as a kosa8 preview: anhttps://URL that proxies the/wsupgrade. A preview is private by default and needs a token header thatEnvClientdoes not send, sostart_container()returns a loopback URL (http://127.0.0.1:<port>) whose proxy adds the token and forwards HTTP and WebSocket traffic overhttps/wss.public=Trueopens a public preview and returns itshttps://URL; anyone who holds that URL can drive the environment. - Lifetime. Each sandbox gets
ttl_s(default one hour); kosa8 deletes it when that runs out, and the preview token expires at the same time (seven days at most). The sandbox never auto-sleeps, since a sleeping sandbox would drop a live/wsmid-episode.stop_container(),close()and the client'swithblock delete it, also after a failed start. Each sandbox carries the labelopenenv=1. - Security. The API key stays in your process and never enters the sandbox. Preview tokens and public URLs are never put in errors or logs, and server output is withheld from errors unless
surface_server_logs=True(then redacted and bounded). Cloud metadata endpoints are not reachable from kosa8 sandboxes;egress={"internet": False}denies all other outbound traffic too.
Options
Kosa8Provider(**options):
| Option | Default | |
|---|---|---|
image |
none | OCI image, if not given to start_container() |
env_vars |
none | environment variables for the server (never logged or returned by kosa8) |
api_key |
KOSA8_API_KEY, then the key kosa8 login saved |
kosa8 Cloud API key |
cloud_url |
https://api.kosa8.com |
kosa8 Cloud API address |
size |
"1x2" |
vCPU x GiB: 0.25x0.5, 0.5x1, 1x2, 2x4, 4x8, 8x16 or 16x32 |
ttl_s |
3600 |
sandbox lifetime, 60 s to 90 days |
egress |
the organization's policy | network policy at boot, e.g. {"internet": False, "allow": ["pypi.org"]} |
labels |
none | extra sandbox labels |
cmd |
from openenv.yaml |
shell command that starts the server |
public |
False |
public preview, returned directly as https:// |
surface_server_logs |
False |
include redacted server output in startup errors |
start_container(image=None, port=None, env_vars=None, cmd=None, **create_kwargs) passes any other keyword (region, disk_gb, secrets, ...) to kosa8.Cloud().sandboxes.create. provider.sandbox_id is the active sandbox's id.
Tests
uv run --group test pytest # unit tests, against fakes
KOSA8_API_KEY=... uv run --group test pytest tests/test_live.py # live tier, on kosa8 Cloud
The unit tests cover sandbox creation and its arguments, server command discovery and quoting, private and public previews, the loopback proxy, readiness and crash reporting (with redaction), cleanup on every failure path, and the exact kosa8 SDK methods and keyword arguments the provider calls (checked against the installed SDK). The live tier runs OpenEnv's echo environment on kosa8 Cloud with a private and a public preview: /ws upgrade 101 (and 401 without the token), reset() and step(), metadata and default-deny egress checks, and confirms the sandbox is deleted.
License
MIT (see NOTICE for code adapted from OpenEnv under BSD-3-Clause).
Metadata
Release files for openenv-kosa8 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| openenv_kosa8-0.1.0.tar.gz | 19.9 kB | Without provenance | Details for openenv_kosa8-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openenv_kosa8-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for openenv_kosa8-0.1.0-py3-none-any.whl |
Total release size: 34.6 kB
Release files / openenv_kosa8-0.1.0.tar.gz
| Download URL | openenv_kosa8-0.1.0.tar.gz |
|---|---|
| Size | 19.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a23c63a144fc4ecc86bd12613abb447bc0b7702c709fa603a816563e56f0afdd
|
|
BLAKE2b-256 checksum How to use checksums |
12417319a934e38c058e1af30c612f2bf45451bdec20f559e6d00b9767b02dd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Release files / openenv_kosa8-0.1.0-py3-none-any.whl
| Download URL | openenv_kosa8-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b6e34175c994438eb54e2d978bf480cfc04aaf67b1f7981156078c4ec0b15f32
|
|
BLAKE2b-256 checksum How to use checksums |
38a9b059fac8f59b3e20a8a85bf56bde0cb59df6bdf2f85824a7a608a55ed724
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Security for openenv-kosa8 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.