Skip to main content

Python SDK for the All-in-One Sandbox API

Project description

Agent Sandbox Python SDK

A Python SDK for the All-in-One Sandbox API, providing access to sandbox, shell, file, jupyter, nodejs, and mcp services.

Installation

pip install agent-sandbox

Usage

from agent_sandbox import Sandbox

client = Sandbox(base_url="http://localhost:8091")

ctx = client.sandbox.get_sandbox_context()
print(ctx)

result = client.shell.exec_command(command="ls -la")
print(result)

Async Support

The SDK also provides async support through the AsyncSandbox class:

import asyncio
from agent_sandbox import AsyncSandbox

async def main():
    client = AsyncSandbox(base_url="http://localhost:8091")
    
    # Get sandbox context
    ctx = await client.sandbox.get_sandbox_context()
    print(ctx)

    result = await client.shell.exec_command(command="ls -la")
    print(result)

asyncio.run(main())

Cloud Providers

Volcengine

Create a sandbox instance using the Volcengine provider. For more details, please refer to examples/provider_volcengine.py.

from __future__ import print_function

import os
import sys

# Add the parent directory to Python path so we can import agent_sandbox
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from agent_sandbox.providers import VolcengineProvider


def main():
    """
    Main function demonstrating Volcengine provider usage.
    """
    # Configuration - replace with your actual credentials
    access_key = os.getenv("VOLC_ACCESSKEY")
    secret_key = os.getenv("VOLC_SECRETKEY")
    region = os.getenv("VOLCENGINE_REGION", "cn-beijing")
    
    # Initialize the Volcengine provider
    provider = VolcengineProvider(
        access_key=access_key,
        secret_key=secret_key,
        region=region
    )
    
    print("=== Volcengine Sandbox Provider Example ===\n")
    
    function_id = "yatoczqh"
    
    print("1. Creating a sandbox...")
    sandbox_id = provider.create_sandbox(function_id=function_id)
    print(f"Create response: {sandbox_id}")


if __name__ == "__main__":
    main()

Features

  • Sandbox: Access sandbox environment information and installed packages
  • Shell: Execute shell commands with session management
  • File: Read, write, search, and manage files
  • Jupyter: Execute Python code in Jupyter kernels
  • Node.js: Execute JavaScript code in Node.js environment
  • MCP: Interact with Model Context Protocol servers

Requirements

  • Python 3.8+
  • httpx
  • pydantic
  • typing_extensions (for Python < 3.10)

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

agent_sandbox-0.0.9.tar.gz (55.8 kB view details)

Uploaded Source

Built Distribution

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

agent_sandbox-0.0.9-py2.py3-none-any.whl (121.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file agent_sandbox-0.0.9.tar.gz.

File metadata

  • Download URL: agent_sandbox-0.0.9.tar.gz
  • Upload date:
  • Size: 55.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for agent_sandbox-0.0.9.tar.gz
Algorithm Hash digest
SHA256 921e2c9f62623a59dfd5a3d86531f7dba12734d40d3d80ab9006bf7019f5ec43
MD5 7eb70dfe598e9eaccd53e64c8a784cd6
BLAKE2b-256 4cfd60f2821a0b3a59f1597d98eef4be7487fcc76d1977ac4722421e4a5d6475

See more details on using hashes here.

File details

Details for the file agent_sandbox-0.0.9-py2.py3-none-any.whl.

File metadata

  • Download URL: agent_sandbox-0.0.9-py2.py3-none-any.whl
  • Upload date:
  • Size: 121.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for agent_sandbox-0.0.9-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e40af266f8f468f85a6661f8ac874a273f9bbb3fa9c752b16ce429911185fc29
MD5 462fd689ae21124b52d4385e4705d47f
BLAKE2b-256 81a15bb9fa0ea13b4a7093b5fb00c267e36e5b323bd51085854b98e7ec642b93

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