praisonai-kosa8
kosa8 Cloud microVM sandboxes as a PraisonAI sandbox backend.
Installing the package registers kosa8 in PraisonAI's praisonai.sandbox entry-point group. Then SandboxConfig(sandbox_type="kosa8") and Agent(..., tools_run_on="kosa8") run code and shell tools in a kosa8 Cloud sandbox: a microVM with its own kernel, created on first use and deleted when the sandbox stops.
Install
pip install praisonai-kosa8
or, with the PraisonAI plugins package:
pip install "praisonai-plugins[kosa8]"
You need a kosa8 Cloud API key. Create one in the kosa8 Cloud dashboard and export it:
export KOSA8_API_KEY=k8c_live_...
kosa8 Cloud is a paid service; plans start at $29/month. See kosa8.com for plans.
Quick start
import asyncio
from praisonaiagents.sandbox import SandboxConfig, SandboxManager
async def main() -> None:
manager = SandboxManager(SandboxConfig(sandbox_type="kosa8"))
result = await manager.run_code("print(6 * 7)")
print(result.stdout) # 42
asyncio.run(main())
run_code creates a sandbox, runs the code and deletes the sandbox. To keep one sandbox for several calls, use the manager as a context manager:
async with SandboxManager(SandboxConfig(sandbox_type="kosa8")) as sandbox:
await sandbox.write_file("data.csv", "a,b\n1,2\n")
result = await sandbox.run_command("wc -l data.csv")
print(result.stdout)
Run an agent's tools in kosa8
from praisonaiagents import Agent
agent = Agent(
instructions="You are a coding assistant.",
tools_run_on="kosa8", # shell and file tools run in a kosa8 Cloud sandbox
)
agent.start("Write a Python script that prints the first ten primes and run it.")
PraisonAI wraps the sandbox in its one-environment compute adapter: the sandbox is created when the agent first needs it and deleted when the agent shuts down. tools_run_on= finds plugin sandboxes through the registry in praisonai-code, which the full praisonai package installs.
Network
The sandbox has no network unless you allow it. With PraisonAI's defaults (ResourceLimits.network_enabled=False, SecurityPolicy.allow_network=False) the sandbox is created with the kosa8 egress policy {"internet": false}, enforced on the host from the VM's first packet.
from praisonaiagents.sandbox import ResourceLimits, SandboxConfig
# Open network:
SandboxConfig(sandbox_type="kosa8", resource_limits=ResourceLimits(network_enabled=True))
# Only some hosts (a kosa8 egress policy, sent as is):
SandboxConfig(sandbox_type="kosa8", metadata={"kosa8_egress": {"allow": ["pypi.org", "files.pythonhosted.org"]}})
The policy is set when the sandbox is created; limits passed to a single call do not change it.
Options
SandboxConfig fields that are used:
| Field | Meaning |
|---|---|
env |
Environment variables for every command (per-call env is merged over it). |
working_dir |
Where commands start and relative paths point. Default /workspace. |
resource_limits.timeout_seconds |
Command timeout, enforced inside the sandbox. A timeout answers SandboxStatus.TIMEOUT. |
resource_limits.network_enabled, security_policy.allow_network |
Either one True leaves the network open. |
metadata["kosa8_template"] |
Template key (GET /v1/templates). Default python. |
metadata["kosa8_region"] |
Region id, such as eu-hel1. Default: the org's. |
metadata["kosa8_ttl_s"] |
Seconds until kosa8 Cloud deletes the sandbox even if it is never stopped (60 s to 90 days). Default 3600. |
metadata["kosa8_egress"] |
A full kosa8 egress policy: {internet, allow, deny, presets}. |
Kosa8Sandbox(config, ...) also takes these as keyword arguments (template, region, ttl_s, sleep_after_s, network_enabled, egress), plus api_key, base_url, and sandbox_id to attach to a sandbox you already started (it is then not deleted by stop()).
What runs where
| Method | kosa8 behaviour |
|---|---|
execute(code, language) |
python (python3), bash/sh, javascript (node, if the template has it). The code is passed on stdin, so it has no length limit. |
run_command(cmd) |
A string runs through the shell (pipes, redirects, &&); a list is quoted argument by argument. |
execute_file(path, args) |
Uploads the local file and runs it by extension (.py, .sh, .js). |
write_file, read_file |
Any path; parent directories are created. Files under /workspace go through the kosa8 files API, others through exec. read_file returns str for UTF-8 and bytes otherwise. |
list_files(path) |
Absolute paths of a directory's entries. |
stop(), cleanup() |
Delete the sandbox. reset() replaces it with a new one. |
API errors come back as a SandboxResult with status=FAILED and the error. When kosa8 Cloud refuses work for billing (402), error is the API's agent_message, a sentence to relay to the person.
Tests
uv sync --group dev
uv run pytest # unit tests, against a fake API
KOSA8_API_KEY=k8c_live_... uv run pytest tests/integration_tests # live
The live tests create sandboxes with a 10-minute lifetime and delete them.
Security
kosa8's SOC 2 audit is in progress; there is no SOC 2 report yet. Report security issues to contact@kosa8.com.
License
MIT
Metadata
Release files for praisonai-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 |
|---|---|---|---|---|
| praisonai_kosa8-0.1.0.tar.gz | 33.4 kB | Without provenance | Details for praisonai_kosa8-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| praisonai_kosa8-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for praisonai_kosa8-0.1.0-py3-none-any.whl |
Total release size: 61.6 kB
Release files / praisonai_kosa8-0.1.0.tar.gz
| Download URL | praisonai_kosa8-0.1.0.tar.gz |
|---|---|
| Size | 33.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87914e5b3dab4b5043139ac35a8d6a3b15ccbbf51eb872ebac405420c4b8d88f
|
|
BLAKE2b-256 checksum How to use checksums |
5154576332e293f4471678fea151557636d4677b34bc4e7cc304c7bd87811a9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Release files / praisonai_kosa8-0.1.0-py3-none-any.whl
| Download URL | praisonai_kosa8-0.1.0-py3-none-any.whl |
|---|---|
| Size | 28.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d59afd389a2c776d4821cd79a9dd2bbc52e3d8838442223febc42659b5a5aeb
|
|
BLAKE2b-256 checksum How to use checksums |
03fd4d9ed6e4524ca9ccbc24ee8906c5e891f1d98beb7bbe854462098481052e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Security for praisonai-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.