Python client library for NoxRunner-compatible sandbox execution backends (zero dependencies, standard library only)
Project description
๐ NoxRunner - Python Client for Sandbox Execution Backends
NoxRunner is a Python client library for interacting with NoxRunner-compatible sandbox execution backends. It uses only Python standard library - zero external dependencies.
๐ About This Project
NoxRunner is the client library extracted from Agentsmith, a commercial distributed, high-concurrency AI-Agent development and operating platform. In the commercial Agentsmith platform, sandboxes run on enterprise private cloud clusters with comprehensive security policies, operational standards, automated container management, image building, resource allocation, and content auditing capabilities. These enterprise features are not part of this open-source release.
What's Open Source:
- โ Client Library: This Python client library for interacting with NoxRunner backends
- โ Backend Specification: The complete API specification (see SPECS.md)
- โ Local Sandbox Mode: A local device simulation mode for development, testing, and POC demos
Use Cases:
- ๐งช Development & Testing: Use the local sandbox mode to develop and test AI agents without the overhead of managing a full cluster
- ๐ Production Deployment: When ready to deploy publicly, switch to a real NoxRunner backend cluster for production workloads
- ๐ง Mock Backend: Perfect for building simple AI agents that need a sandbox execution environment during development
This approach significantly reduces operational and debugging burden during the development phase while maintaining compatibility with production-grade sandbox infrastructure.
โจ Features
- โ Zero Dependencies: Only uses Python standard library
- โ Complete API Coverage: All NoxRunner backend endpoints
- โ
Shell Command Interface: Natural shell command execution with
exec_shell()method - โ Environment Variable Support: Full support for environment variable expansion in shell commands
- โ Friendly CLI: Colored output, interactive shell
- โ Local Testing Mode: Offline testing with local sandbox backend
- โ Easy to Use: Simple API with clear error messages
- โ Well Documented: Comprehensive documentation and examples
- โ Type Hints: Full type support for better IDE experience
๐ฆ Installation
Install from Source
# Clone the repository
git clone https://github.com/noxrunner/noxrunner.git
cd noxrunner
# Install in development mode
pip install -e .
# Or install with development dependencies
pip install -e ".[dev]"
Install from PyPI (when published)
pip install noxrunner
๐ Quick Start
As a Library
from noxrunner import NoxRunnerClient
# Create client (local test mode for development)
client = NoxRunnerClient(local_test=True)
# Or connect to remote backend
# client = NoxRunnerClient("http://127.0.0.1:8080")
# Create sandbox
session_id = "my-session"
result = client.create_sandbox(session_id)
print(f"Sandbox: {result['podName']}")
# Wait for sandbox ready
client.wait_for_pod_ready(session_id)
# Execute command (array format)
result = client.exec(session_id, ["python3", "--version"])
print(result["stdout"])
# Execute shell command (string format - more natural!)
result = client.exec_shell(session_id, "python3 --version")
print(result["stdout"])
# Shell commands with environment variables
result = client.exec_shell(
session_id,
"echo $MY_VAR && ls -la",
env={"MY_VAR": "test_value"}
)
print(result["stdout"])
# Upload files
client.upload_files(session_id, {
"script.py": "print('Hello from NoxRunner!')"
})
# Download files as tar archive
tar_data = client.download_files(session_id)
# Download and extract to local directory (recommended)
import tempfile
from pathlib import Path
with tempfile.TemporaryDirectory() as tmpdir:
client.download_workspace(session_id, tmpdir)
# Files are now in tmpdir
# Delete sandbox
client.delete_sandbox(session_id)
As a CLI Tool
Remote Mode (Default):
# Health check
noxrc health
# Create sandbox
noxrc create my-session --wait
# Execute command
noxrc exec my-session python3 --version
# Upload files
noxrc upload my-session script.py data.txt
# Download files
noxrc download my-session --extract ./output
# Interactive shell
noxrc shell my-session
# Delete sandbox
noxrc delete my-session
Local Testing Mode (for offline testing):
# Use --local-test flag for offline testing
noxrc --local-test create my-session
noxrc --local-test exec my-session echo "Hello"
noxrc --local-test upload my-session script.py
noxrc --local-test delete my-session
โ ๏ธ Warning: Local testing mode executes commands in your local environment using /tmp directories. This can cause data loss or security risks!
๐ Documentation
- API Reference - Complete API documentation
- Backend Specification - Implement your own NoxRunner-compatible backend
- Examples - Usage examples
- Contributing - How to contribute
๐๏ธ Project Structure
noxrunner/
โโโ noxrunner/ # Python package
โ โโโ __init__.py
โ โโโ client.py # NoxRunnerClient class
โ โโโ exceptions.py # Exception classes
โ โโโ backend/ # Backend implementations
โ โ โโโ base.py # Abstract base class
โ โ โโโ local.py # LocalBackend
โ โ โโโ http.py # HTTPSandboxBackend
โ โโโ security/ # Security utilities
โ โ โโโ command_validator.py
โ โ โโโ path_sanitizer.py
โ โโโ fileops/ # File operation utilities
โ โโโ tar_handler.py
โโโ tests/ # Test suite
โ โโโ test_security.py
โ โโโ test_fileops.py
โ โโโ test_backend_local.py
โ โโโ test_backend_http.py
โ โโโ test_integration.py
โโโ examples/ # Example scripts
โโโ docs/ # Sphinx documentation
โโโ README.md # This file
๐ Backend Compatibility
NoxRunner is designed to work with any backend that implements the NoxRunner Backend Specification. This includes:
- Kubernetes-based sandbox managers
- Docker-based execution backends
- VM-based sandbox systems
- Any custom implementation following the spec
๐งช Testing
# Run all unit tests
pytest tests/test_security.py tests/test_fileops.py tests/test_backend_local.py tests/test_backend_http.py
# Run local backend integration tests
pytest tests/test_integration.py::TestLocalBackendIntegration
# Run HTTP backend integration tests (requires running backend)
NOXRUNNER_ENABLE_INTEGRATION=1 NOXRUNNER_BASE_URL=http://127.0.0.1:8080 pytest tests/test_integration.py::TestHTTPSandboxBackendIntegration
# Run with coverage
pytest --cov=noxrunner --cov-report=html
# Run all tests
pytest tests/
Testing Modes
- Unit Tests: Test individual modules (security, fileops, backend mocks)
- Local Integration Tests: Test LocalBackend with real file operations
- HTTP Integration Tests: Test HTTPSandboxBackend against running backend service
See USAGE.md for more details on testing.
๐ License
MIT License - see LICENSE file for details.
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
๐ Links
- Repository: https://github.com/noxrunner/noxrunner
- Documentation: https://noxrunner.readthedocs.io
- Issues: https://github.com/noxrunner/noxrunner/issues
๐ Acknowledgments
NoxRunner was originally developed as part of Agentsmith, a commercial distributed AI-Agent development and operating platform. The client library and backend specification have been extracted and open-sourced to enable broader adoption and community contribution. The local sandbox simulation mode was added to facilitate development, testing, and POC demonstrations without requiring access to production infrastructure.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file noxrunner-2.0.0.tar.gz.
File metadata
- Download URL: noxrunner-2.0.0.tar.gz
- Upload date:
- Size: 43.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5f23c8505d7acf212234bc7f0ca0809690ded1e5b4bc32c116e7b30282e01b8
|
|
| MD5 |
ac1086f014b258a12aa26b79e47eaae4
|
|
| BLAKE2b-256 |
f977ed4a1289ead83eef67b9463c8c3267cfc45c63f74e1c2868500d7a98eabd
|
File details
Details for the file noxrunner-2.0.0-py3-none-any.whl.
File metadata
- Download URL: noxrunner-2.0.0-py3-none-any.whl
- Upload date:
- Size: 27.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc6518b49eb463551d97a0f5b0222a7b0cce0b8ec0f588a508323b59a0b2c852
|
|
| MD5 |
bc3e0c42a16cbc03cf07134f5c881143
|
|
| BLAKE2b-256 |
55046505967db7572134994a613cc89bd70bc2dcf8d1000eed3701f65de5436e
|