openenv-kosa8 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - First version: `Kosa8Provider`, an OpenEnv `ContainerProvider` that boots an OpenEnv environment image as a kosa8 Cloud sandbox (microVM), starts the server from `openenv.yaml` (or `cmd=`) and returns a `base_url` for `EnvClient`, including the `/ws` WebSocket (openenv 0.15).
6
+ - Private, token-gated preview by default, reached through a loopback proxy that adds the token; `public=True` returns the preview's `https://` URL directly.
7
+ - Every sandbox gets a size (`1x2`), a lifetime (`ttl_s`, default 1 hour), the label `openenv=1`, and never auto-sleeps; `stop_container()`/`close()` delete it, also after a failed start. `egress=` sets its network policy.
8
+ - The same provider is proposed upstream as `openenv[kosa8]`.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kosa8
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,39 @@
1
+ The MIT License in LICENSE covers the source code in this repository, the kosa8
2
+ OpenEnv provider (openenv-kosa8), only. It does not cover kosa8 itself (the
3
+ kosa8 CLI, the kosa8d daemon or any other kosa8 software), which is licensed
4
+ separately.
5
+
6
+ openenv_kosa8/_provider.py adapts code from OpenEnv
7
+ (https://github.com/openenv/OpenEnv), in particular the loopback auth proxy of
8
+ src/openenv/core/containers/runtime/hf_sandbox_provider.py. That code is under
9
+ the following license:
10
+
11
+ BSD 3-Clause License
12
+
13
+ Copyright (c) 2026, Hugging Face, Inc.
14
+ Copyright (c) Meta Platforms, Inc. and affiliates.
15
+
16
+ Redistribution and use in source and binary forms, with or without modification,
17
+ are permitted provided that the following conditions are met:
18
+
19
+ 1. Redistributions of source code must retain the above copyright notice, this
20
+ list of conditions and the following disclaimer.
21
+
22
+ 2. Redistributions in binary form must reproduce the above copyright notice,
23
+ this list of conditions and the following disclaimer in the documentation
24
+ and/or other materials provided with the distribution.
25
+
26
+ 3. Neither the name of the copyright holder nor the names of its contributors
27
+ may be used to endorse or promote products derived from this software without
28
+ specific prior written permission.
29
+
30
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
34
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
36
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
38
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
39
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.5
2
+ Name: openenv-kosa8
3
+ Version: 0.1.0
4
+ Summary: kosa8 Cloud microVM sandboxes as an OpenEnv container provider: run OpenEnv environment servers for RL
5
+ Project-URL: Homepage, https://kosa8.com
6
+ Project-URL: Documentation, https://github.com/kosa8ai/openenv-kosa8#readme
7
+ Project-URL: Repository, https://github.com/kosa8ai/openenv-kosa8
8
+ Project-URL: Issues, https://github.com/kosa8ai/openenv-kosa8/issues
9
+ Author: kosa8
10
+ License: MIT
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: kosa8,microvm,openenv,reinforcement-learning,rl,sandbox,trl
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Requires-Python: <4.0,>=3.10
24
+ Requires-Dist: kosa8<1,>=0.12.0
25
+ Requires-Dist: openenv>=0.15.0
26
+ Description-Content-Type: text/markdown
27
+
28
+ # openenv-kosa8
29
+
30
+ **[kosa8](https://kosa8.com): Zero Trust cybersecurity infrastructure for AI agents.** Every agent sealed in its own microVM. Every action verified and recorded.
31
+
32
+ Run [OpenEnv](https://github.com/openenv/OpenEnv) environment servers (the RL environment standard used by Hugging Face TRL) in [kosa8 Cloud](https://kosa8.com) microVM sandboxes.
33
+
34
+ `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.
35
+
36
+ ## Install
37
+
38
+ ```bash
39
+ pip install openenv-kosa8
40
+ ```
41
+
42
+ Set `KOSA8_API_KEY` to a kosa8 Cloud API key (create one at [app.kosa8.com](https://app.kosa8.com), or run `kosa8 login`). The Starter plan is free, no card needed; plans are at [kosa8.com/pricing](https://kosa8.com/pricing/).
43
+
44
+ ## Example
45
+
46
+ ```python
47
+ from echo_env import EchoEnv # or any OpenEnv client
48
+ from openenv_kosa8 import Kosa8Provider
49
+
50
+ provider = Kosa8Provider(image="registry.hf.space/openenv-echo-env:latest")
51
+ base_url = provider.start_container()
52
+ provider.wait_for_ready(base_url)
53
+
54
+ # The client stops the provider, deleting the sandbox, when the block ends.
55
+ with EchoEnv(base_url=base_url, provider=provider).sync() as env:
56
+ env.reset()
57
+ print(env.call_tool("echo_message", message="Hello!"))
58
+ ```
59
+
60
+ 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.
61
+
62
+ For many rollouts, start one provider per environment and run them concurrently (see OpenEnv's [runtime providers guide](https://github.com/openenv/OpenEnv/blob/main/docs/source/guides/runtime-providers.md)).
63
+
64
+ ## How it works
65
+
66
+ - **Source.** `image` is an OCI registry image, which kosa8 Cloud pulls and boots as the sandbox's root filesystem. Images built by `openenv build`, and Hugging Face Space images such as `registry.hf.space/openenv-echo-env:latest`, work as they are. The image's `CMD` is not run: the provider builds the server command from `openenv.yaml` (`/app/env/openenv.yaml`, or the first one under `/app`), or takes `cmd=`. Build and push Dockerfiles first.
67
+ - **Ingress.** The server port (8000 unless `port=` says otherwise) is opened as a kosa8 preview: an `https://` URL that proxies the `/ws` upgrade. A preview is private by default and needs a token header that `EnvClient` does not send, so `start_container()` returns a loopback URL (`http://127.0.0.1:<port>`) whose proxy adds the token and forwards HTTP and WebSocket traffic over `https`/`wss`. `public=True` opens a public preview and returns its `https://` URL; anyone who holds that URL can drive the environment.
68
+ - **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 `/ws` mid-episode. `stop_container()`, `close()` and the client's `with` block delete it, also after a failed start. Each sandbox carries the label `openenv=1`.
69
+ - **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.
70
+
71
+ ## Options
72
+
73
+ `Kosa8Provider(**options)`:
74
+
75
+ | Option | Default | |
76
+ |---|---|---|
77
+ | `image` | none | OCI image, if not given to `start_container()` |
78
+ | `env_vars` | none | environment variables for the server (never logged or returned by kosa8) |
79
+ | `api_key` | `KOSA8_API_KEY`, then the key `kosa8 login` saved | kosa8 Cloud API key |
80
+ | `cloud_url` | `https://api.kosa8.com` | kosa8 Cloud API address |
81
+ | `size` | `"1x2"` | vCPU x GiB: `0.25x0.5`, `0.5x1`, `1x2`, `2x4`, `4x8`, `8x16` or `16x32` |
82
+ | `ttl_s` | `3600` | sandbox lifetime, 60 s to 90 days |
83
+ | `egress` | the organization's policy | network policy at boot, e.g. `{"internet": False, "allow": ["pypi.org"]}` |
84
+ | `labels` | none | extra sandbox labels |
85
+ | `cmd` | from `openenv.yaml` | shell command that starts the server |
86
+ | `public` | `False` | public preview, returned directly as `https://` |
87
+ | `surface_server_logs` | `False` | include redacted server output in startup errors |
88
+
89
+ `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.
90
+
91
+ ## Tests
92
+
93
+ ```bash
94
+ uv run --group test pytest # unit tests, against fakes
95
+ KOSA8_API_KEY=... uv run --group test pytest tests/test_live.py # live tier, on kosa8 Cloud
96
+ ```
97
+
98
+ 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.
99
+
100
+ ## License
101
+
102
+ MIT (see [NOTICE](NOTICE) for code adapted from OpenEnv under BSD-3-Clause).
@@ -0,0 +1,75 @@
1
+ # openenv-kosa8
2
+
3
+ **[kosa8](https://kosa8.com): Zero Trust cybersecurity infrastructure for AI agents.** Every agent sealed in its own microVM. Every action verified and recorded.
4
+
5
+ Run [OpenEnv](https://github.com/openenv/OpenEnv) environment servers (the RL environment standard used by Hugging Face TRL) in [kosa8 Cloud](https://kosa8.com) microVM sandboxes.
6
+
7
+ `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.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install openenv-kosa8
13
+ ```
14
+
15
+ Set `KOSA8_API_KEY` to a kosa8 Cloud API key (create one at [app.kosa8.com](https://app.kosa8.com), or run `kosa8 login`). The Starter plan is free, no card needed; plans are at [kosa8.com/pricing](https://kosa8.com/pricing/).
16
+
17
+ ## Example
18
+
19
+ ```python
20
+ from echo_env import EchoEnv # or any OpenEnv client
21
+ from openenv_kosa8 import Kosa8Provider
22
+
23
+ provider = Kosa8Provider(image="registry.hf.space/openenv-echo-env:latest")
24
+ base_url = provider.start_container()
25
+ provider.wait_for_ready(base_url)
26
+
27
+ # The client stops the provider, deleting the sandbox, when the block ends.
28
+ with EchoEnv(base_url=base_url, provider=provider).sync() as env:
29
+ env.reset()
30
+ print(env.call_tool("echo_message", message="Hello!"))
31
+ ```
32
+
33
+ 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.
34
+
35
+ For many rollouts, start one provider per environment and run them concurrently (see OpenEnv's [runtime providers guide](https://github.com/openenv/OpenEnv/blob/main/docs/source/guides/runtime-providers.md)).
36
+
37
+ ## How it works
38
+
39
+ - **Source.** `image` is an OCI registry image, which kosa8 Cloud pulls and boots as the sandbox's root filesystem. Images built by `openenv build`, and Hugging Face Space images such as `registry.hf.space/openenv-echo-env:latest`, work as they are. The image's `CMD` is not run: the provider builds the server command from `openenv.yaml` (`/app/env/openenv.yaml`, or the first one under `/app`), or takes `cmd=`. Build and push Dockerfiles first.
40
+ - **Ingress.** The server port (8000 unless `port=` says otherwise) is opened as a kosa8 preview: an `https://` URL that proxies the `/ws` upgrade. A preview is private by default and needs a token header that `EnvClient` does not send, so `start_container()` returns a loopback URL (`http://127.0.0.1:<port>`) whose proxy adds the token and forwards HTTP and WebSocket traffic over `https`/`wss`. `public=True` opens a public preview and returns its `https://` URL; anyone who holds that URL can drive the environment.
41
+ - **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 `/ws` mid-episode. `stop_container()`, `close()` and the client's `with` block delete it, also after a failed start. Each sandbox carries the label `openenv=1`.
42
+ - **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.
43
+
44
+ ## Options
45
+
46
+ `Kosa8Provider(**options)`:
47
+
48
+ | Option | Default | |
49
+ |---|---|---|
50
+ | `image` | none | OCI image, if not given to `start_container()` |
51
+ | `env_vars` | none | environment variables for the server (never logged or returned by kosa8) |
52
+ | `api_key` | `KOSA8_API_KEY`, then the key `kosa8 login` saved | kosa8 Cloud API key |
53
+ | `cloud_url` | `https://api.kosa8.com` | kosa8 Cloud API address |
54
+ | `size` | `"1x2"` | vCPU x GiB: `0.25x0.5`, `0.5x1`, `1x2`, `2x4`, `4x8`, `8x16` or `16x32` |
55
+ | `ttl_s` | `3600` | sandbox lifetime, 60 s to 90 days |
56
+ | `egress` | the organization's policy | network policy at boot, e.g. `{"internet": False, "allow": ["pypi.org"]}` |
57
+ | `labels` | none | extra sandbox labels |
58
+ | `cmd` | from `openenv.yaml` | shell command that starts the server |
59
+ | `public` | `False` | public preview, returned directly as `https://` |
60
+ | `surface_server_logs` | `False` | include redacted server output in startup errors |
61
+
62
+ `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.
63
+
64
+ ## Tests
65
+
66
+ ```bash
67
+ uv run --group test pytest # unit tests, against fakes
68
+ KOSA8_API_KEY=... uv run --group test pytest tests/test_live.py # live tier, on kosa8 Cloud
69
+ ```
70
+
71
+ 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.
72
+
73
+ ## License
74
+
75
+ MIT (see [NOTICE](NOTICE) for code adapted from OpenEnv under BSD-3-Clause).
@@ -0,0 +1,29 @@
1
+ """Run OpenEnv's echo environment in a kosa8 Cloud sandbox and call it.
2
+
3
+ pip install openenv-kosa8
4
+ export KOSA8_API_KEY=k8_... # or: kosa8 login
5
+ python examples/echo_env.py
6
+ """
7
+
8
+ from openenv.core.mcp_client import MCPToolClient
9
+
10
+ from openenv_kosa8 import Kosa8Provider
11
+
12
+
13
+ def main() -> None:
14
+ provider = Kosa8Provider(
15
+ image="registry.hf.space/openenv-echo-env:latest",
16
+ ttl_s=900,
17
+ egress={"internet": False}, # default-deny: the echo server needs no network
18
+ )
19
+ base_url = provider.start_container()
20
+ provider.wait_for_ready(base_url, timeout_s=180)
21
+ # The client stops the provider, deleting the sandbox, when the block ends.
22
+ with MCPToolClient(base_url=base_url, provider=provider).sync() as env:
23
+ env.reset()
24
+ print("tools:", [t.name for t in env.list_tools()])
25
+ print("echo_message ->", env.call_tool("echo_message", message="Hello from kosa8!"))
26
+
27
+
28
+ if __name__ == "__main__":
29
+ main()
@@ -0,0 +1,7 @@
1
+ """openenv-kosa8: run OpenEnv environment servers in kosa8 Cloud microVM sandboxes."""
2
+
3
+ from ._provider import Kosa8Provider
4
+
5
+ __version__ = "0.1.0"
6
+
7
+ __all__ = ["Kosa8Provider", "__version__"]