Skip to main content

Python client library for NoxRunner-compatible sandbox execution backends (zero dependencies, standard library only)

Project description

๐Ÿš€ NoxRunner - Python Client for Sandbox Execution Backends

PyPI version Python 3.8+ License Documentation CI

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 secure sandbox system. 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
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
tar_data = client.download_files(session_id)

# Delete sandbox
client.delete_sandbox(session_id)

As a CLI Tool

Remote Mode (Default):

# Health check
noxrunner health

# Create sandbox
noxrunner create my-session --wait

# Execute command
noxrunner exec my-session python3 --version

# Upload files
noxrunner upload my-session script.py data.txt

# Download files
noxrunner download my-session --extract ./output

# Interactive shell
noxrunner shell my-session

# Delete sandbox
noxrunner delete my-session

Local Testing Mode (for offline testing):

# Use --local-test flag for offline testing
noxrunner --local-test create my-session
noxrunner --local-test exec my-session echo "Hello"
noxrunner --local-test upload my-session script.py
noxrunner --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

๐Ÿ—๏ธ Project Structure

noxrunner/
โ”œโ”€โ”€ noxrunner/          # Python package
โ”‚   โ”œโ”€โ”€ __init__.py    # Package initialization
โ”‚   โ”œโ”€โ”€ client.py      # NoxRunnerClient class
โ”‚   โ”œโ”€โ”€ exceptions.py  # Exception classes
โ”‚   โ””โ”€โ”€ cli.py         # CLI tool
โ”œโ”€โ”€ tests/             # Test suite
โ”œโ”€โ”€ 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 unit tests (excludes integration tests)
make test

# Run integration tests (requires running NoxRunner backend)
make test-integration

# Run with coverage
make test-cov

# Run linting
make lint

# Format code
make format

# Run all checks
make check

Testing Modes

  • Unit Tests: Test local functionality using the local sandbox backend (no external dependencies)
  • Integration Tests: Test against a real remote NoxRunner backend (requires backend service)

See the documentation for more details on testing.

๐Ÿ“ License

MIT License - see LICENSE file for details.

๐Ÿค Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

๐Ÿ”— Links

๐Ÿ™ Acknowledgments

NoxRunner was originally developed as part of Agentsmith, a commercial distributed secure sandbox 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

noxrunner-1.0.0.tar.gz (35.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

noxrunner-1.0.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file noxrunner-1.0.0.tar.gz.

File metadata

  • Download URL: noxrunner-1.0.0.tar.gz
  • Upload date:
  • Size: 35.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for noxrunner-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6acf386beddce980bd2118abec4a31aad9e87243b6247f61e492e63bf068b342
MD5 e5d041f9655a10c9380b7c8c93a02682
BLAKE2b-256 d82d033b2c5f61514569b5a56a0757429b956f2eb32cc2cedc286af1ada2c47f

See more details on using hashes here.

File details

Details for the file noxrunner-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: noxrunner-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for noxrunner-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3913465a16a3f80b7954d990c92118d8203c3974402b13a2ec75d2879487bf4c
MD5 71de67069489b05e54ec10720765150d
BLAKE2b-256 0484ba0c03682600890c37e48524bfaf568450343ce43968b53a21c60115d2e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page