crewai-kosa8
kosa8: Zero Trust cybersecurity infrastructure for AI agents. Every agent sealed in its own microVM. Every action verified and recorded.
Give a CrewAI agent a kosa8 Cloud microVM sandbox to run shell commands, Python and file edits in, instead of your machine.
Three tools, shaped like the E2B and Daytona sandbox tools in crewai-tools, so you can swap one for another:
Kosa8ExecTool(kosa8 Sandbox Exec): run a shell command, get the exit code, stdout and stderr.Kosa8PythonTool(kosa8 Sandbox Python): run Python in a stateful kernel, get stdout, stderr, the last expression's value and any error.Kosa8FileTool(kosa8 Sandbox Files): read, write, append, list, delete, mkdir, info, exists, move, find (content grep), search (name glob), chmod and replace.
Install
pip install crewai-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 and needs no card; plans are at kosa8.com/pricing.
export KOSA8_API_KEY="k8c_live_..."
KOSA8_CLOUD_URL overrides the API address (default https://api.kosa8.com).
Example
import kosa8
from crewai import Agent, Crew, Task
from crewai_kosa8 import Kosa8ExecTool, Kosa8FileTool, Kosa8PythonTool
# One sandbox for the whole crew; `with` deletes it on the way out, error or not.
with kosa8.Cloud().sandboxes.create(template="python", persistent=True, ttl_s=3600) as box:
coder = Agent(
role="Engineer",
goal="Write and test small programs",
backstory="You work only inside the kosa8 sandbox.",
tools=[Kosa8ExecTool(sandbox_id=box.id), Kosa8FileTool(sandbox_id=box.id), Kosa8PythonTool(sandbox_id=box.id)],
)
task = Task(
description="Write /workspace/fizzbuzz.py, run it for 1..15 and report the output.",
expected_output="The program's output",
agent=coder,
)
print(Crew(agents=[coder], tasks=[task]).kickoff())
Each tool can also be called directly:
from crewai_kosa8 import Kosa8PythonTool
print(Kosa8PythonTool().run(code="print(sum(range(10)))"))
Sandbox lifecycle
All three tools share the same lifecycle controls from Kosa8BaseTool:
| Mode | When the sandbox is created | When it is deleted |
|---|---|---|
Ephemeral (default, persistent=False) |
On every call | At the end of that same call |
Persistent (persistent=True) |
Lazily on first use | At process exit (via atexit), or on tool.close() |
Attach (sandbox_id="sbx_...") |
Never: the tool attaches to an existing sandbox | Never: the tool will not delete a sandbox it did not create |
Every sandbox a tool creates also gets a lifetime (ttl_s, default 3600 s): kosa8 Cloud deletes it then even if the process dies before cleanup runs.
Each persistent tool keeps its own sandbox. To share one between tools, attach the others to the first one's id:
exec_tool = Kosa8ExecTool(persistent=True)
exec_tool.run(command="pip install httpx")
files = Kosa8FileTool(sandbox_id=exec_tool.active_sandbox_id)
Options
Every tool takes these:
| Option | Default | |
|---|---|---|
api_key |
KOSA8_API_KEY, then the key kosa8 login saved |
kosa8 Cloud API key |
base_url |
KOSA8_CLOUD_URL, then https://api.kosa8.com |
API address |
persistent |
False |
reuse one sandbox for every call of this tool |
sandbox_id |
none | attach to an existing sandbox |
template |
"python" |
kosa8 template for new sandboxes |
ttl_s |
3600 |
lifetime of new sandboxes, in seconds |
labels |
none | labels on new sandboxes, merged over {"integration": "crewai"} |
create_params |
none | anything else for cloud.sandboxes.create: size (0.25x0.5 to 16x32), image, region, env, egress (for example {"internet": False}), secrets, persistent, ... |
workdir |
/workspace |
where Kosa8ExecTool commands start when no cwd is given |
How it maps to kosa8
Kosa8ExecToolrunscd <cwd> && <command>with kosa8's buffered exec. A buffered command runs at most 90 s; a longer one comes back as{"timed_out": true, ...}. Each stream keeps its first and last 1 MiB ("truncated": truewhen the middle was dropped).Kosa8PythonTooluses kosa8's code kernel (sandbox.run_code), so variables persist percontextwithin a sandbox. The kernel needs kosa8's long-lived container, so sandboxes this tool creates are made withpersistent=True. Attached to a sandbox without one, it runs the code as apython3script instead. Images and other rich results are reported by type, not returned as bytes.Kosa8FileTooluses the kosa8 files API for read, write, append, list, delete, mkdir, info, exists and replace, and a shell command for move, find, search and chmod.- Only
/workspaceis promised to persist between commands unless the sandbox was created withcreate_params={"persistent": True}. - kosa8 Cloud errors (for example a payment or plan limit, with its
upgrade_url) are raised as the SDK's typed errors, and CrewAI shows them to the agent.
Tests
uv run --group test pytest # unit tests, against a mocked kosa8 client
KOSA8_API_KEY=... uv run --group test pytest tests/test_live.py # live tier, on kosa8 Cloud
The live tier (skipped without KOSA8_API_KEY) creates sandboxes with a 600 s lifetime and a crewai-kosa8-test label, runs every tool and a CrewAI Agent driven by a scripted LLM (no model provider is called), and checks that no sandbox it made is left behind.
License
MIT
Metadata
Release files for crewai-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 |
|---|---|---|---|---|
| crewai_kosa8-0.1.0.tar.gz | 16.1 kB | Without provenance | Details for crewai_kosa8-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| crewai_kosa8-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for crewai_kosa8-0.1.0-py3-none-any.whl |
Total release size: 30.0 kB
Release files / crewai_kosa8-0.1.0.tar.gz
| Download URL | crewai_kosa8-0.1.0.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c249d432b02f2c722fe430c9073bf00769fe8de97202f067f77751c86527672e
|
|
BLAKE2b-256 checksum How to use checksums |
08fcf1f6d57a34cb3cc7660a39ca982021b53654736bc316d5c7fddfd37469eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Release files / crewai_kosa8-0.1.0-py3-none-any.whl
| Download URL | crewai_kosa8-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fbac6039628aa44d8f6509c2dfc263b3cb00104c88b5a9323e2ef27723f5c591
|
|
BLAKE2b-256 checksum How to use checksums |
759d051506a4770ea6ab891c534a84ec81f2a882a3b9f5dd846e2a241eca4a12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Security for crewai-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.